summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/Accessibility/AccessibilityHints.cxx115
-rw-r--r--sc/source/ui/Accessibility/AccessibleCell.cxx456
-rw-r--r--sc/source/ui/Accessibility/AccessibleCellBase.cxx342
-rw-r--r--sc/source/ui/Accessibility/AccessibleContextBase.cxx626
-rw-r--r--sc/source/ui/Accessibility/AccessibleCsvControl.cxx1676
-rw-r--r--sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx736
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx2115
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentBase.cxx52
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx1891
-rw-r--r--sc/source/ui/Accessibility/AccessibleEditObject.cxx354
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterMenu.cxx400
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx207
-rw-r--r--sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx129
-rw-r--r--sc/source/ui/Accessibility/AccessibleGlobal.cxx97
-rw-r--r--sc/source/ui/Accessibility/AccessiblePageHeader.cxx442
-rw-r--r--sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx327
-rw-r--r--sc/source/ui/Accessibility/AccessiblePreviewCell.cxx318
-rw-r--r--sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx444
-rw-r--r--sc/source/ui/Accessibility/AccessiblePreviewTable.cxx769
-rw-r--r--sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx996
-rw-r--r--sc/source/ui/Accessibility/AccessibleTableBase.cxx494
-rw-r--r--sc/source/ui/Accessibility/AccessibleText.cxx1846
-rw-r--r--sc/source/ui/Accessibility/DrawModelBroadcaster.cxx95
-rw-r--r--sc/source/ui/Accessibility/makefile.mk92
-rw-r--r--sc/source/ui/app/client.cxx258
-rw-r--r--sc/source/ui/app/drwtrans.cxx804
-rw-r--r--sc/source/ui/app/inputhdl.cxx3828
-rw-r--r--sc/source/ui/app/inputwin.cxx1812
-rw-r--r--sc/source/ui/app/lnktrans.cxx99
-rw-r--r--sc/source/ui/app/makefile.mk73
-rw-r--r--sc/source/ui/app/msgpool.cxx125
-rw-r--r--sc/source/ui/app/rfindlst.cxx69
-rw-r--r--sc/source/ui/app/scdll.cxx349
-rw-r--r--sc/source/ui/app/scmod.cxx2289
-rw-r--r--sc/source/ui/app/scmod2.cxx109
-rw-r--r--sc/source/ui/app/seltrans.cxx451
-rw-r--r--sc/source/ui/app/template.cxx81
-rw-r--r--sc/source/ui/app/transobj.cxx869
-rw-r--r--sc/source/ui/app/typemap.cxx139
-rw-r--r--sc/source/ui/app/uiitems.cxx724
-rw-r--r--sc/source/ui/app/wtcdummy.cxx68
-rw-r--r--sc/source/ui/attrdlg/attrdlg.cxx147
-rw-r--r--sc/source/ui/attrdlg/condfrmt.cxx831
-rw-r--r--sc/source/ui/attrdlg/makefile.mk61
-rw-r--r--sc/source/ui/attrdlg/scabstdlg.cxx59
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx1631
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx594
-rw-r--r--sc/source/ui/attrdlg/scuiexp.cxx58
-rw-r--r--sc/source/ui/attrdlg/tabpages.cxx253
-rw-r--r--sc/source/ui/cctrl/cbuttonw.cxx180
-rw-r--r--sc/source/ui/cctrl/dpcontrol.cxx1424
-rw-r--r--sc/source/ui/cctrl/dpcontrol.src79
-rw-r--r--sc/source/ui/cctrl/editfield.cxx86
-rw-r--r--sc/source/ui/cctrl/makefile.mk69
-rw-r--r--sc/source/ui/cctrl/popmenu.cxx50
-rw-r--r--sc/source/ui/cctrl/tbinsert.cxx234
-rw-r--r--sc/source/ui/cctrl/tbzoomsliderctrl.cxx533
-rw-r--r--sc/source/ui/dbgui/asciiopt.cxx406
-rw-r--r--sc/source/ui/dbgui/asciiopt.hrc71
-rw-r--r--sc/source/ui/dbgui/asciiopt.src305
-rw-r--r--sc/source/ui/dbgui/consdlg.cxx657
-rw-r--r--sc/source/ui/dbgui/consdlg.hrc61
-rw-r--r--sc/source/ui/dbgui/consdlg.src217
-rw-r--r--sc/source/ui/dbgui/csvcontrol.cxx339
-rw-r--r--sc/source/ui/dbgui/csvgrid.cxx1357
-rw-r--r--sc/source/ui/dbgui/csvruler.cxx684
-rw-r--r--sc/source/ui/dbgui/csvsplits.cxx122
-rw-r--r--sc/source/ui/dbgui/csvtablebox.cxx436
-rw-r--r--sc/source/ui/dbgui/dapidata.cxx231
-rw-r--r--sc/source/ui/dbgui/dapitype.cxx144
-rw-r--r--sc/source/ui/dbgui/dapitype.hrc53
-rw-r--r--sc/source/ui/dbgui/dapitype.src308
-rw-r--r--sc/source/ui/dbgui/dbnamdlg.cxx723
-rw-r--r--sc/source/ui/dbgui/dpgroupdlg.cxx358
-rw-r--r--sc/source/ui/dbgui/dpgroupdlg.hrc64
-rw-r--r--sc/source/ui/dbgui/dpgroupdlg.src270
-rw-r--r--sc/source/ui/dbgui/expftext.cxx97
-rw-r--r--sc/source/ui/dbgui/fieldwnd.cxx778
-rw-r--r--sc/source/ui/dbgui/filtdlg.cxx1190
-rw-r--r--sc/source/ui/dbgui/foptmgr.cxx340
-rw-r--r--sc/source/ui/dbgui/imoptdlg.cxx93
-rw-r--r--sc/source/ui/dbgui/imoptdlg.hrc44
-rw-r--r--sc/source/ui/dbgui/imoptdlg.src141
-rw-r--r--sc/source/ui/dbgui/makefile.mk120
-rw-r--r--sc/source/ui/dbgui/outline.src51
-rw-r--r--sc/source/ui/dbgui/pfiltdlg.cxx622
-rw-r--r--sc/source/ui/dbgui/pivot.hrc81
-rw-r--r--sc/source/ui/dbgui/pivot.src328
-rw-r--r--sc/source/ui/dbgui/pvfundlg.cxx858
-rw-r--r--sc/source/ui/dbgui/pvfundlg.hrc83
-rw-r--r--sc/source/ui/dbgui/pvfundlg.src515
-rw-r--r--sc/source/ui/dbgui/pvglob.hxx45
-rw-r--r--sc/source/ui/dbgui/pvlaydlg.cxx1871
-rw-r--r--sc/source/ui/dbgui/scendlg.cxx245
-rw-r--r--sc/source/ui/dbgui/scendlg.hrc57
-rw-r--r--sc/source/ui/dbgui/scendlg.src195
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx726
-rw-r--r--sc/source/ui/dbgui/scuiimoptdlg.cxx319
-rw-r--r--sc/source/ui/dbgui/sfiltdlg.cxx532
-rw-r--r--sc/source/ui/dbgui/sortdlg.cxx110
-rw-r--r--sc/source/ui/dbgui/subtdlg.cxx71
-rw-r--r--sc/source/ui/dbgui/textimportoptions.cxx123
-rw-r--r--sc/source/ui/dbgui/textimportoptions.src110
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx1085
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx688
-rw-r--r--sc/source/ui/dbgui/validate.cxx998
-rw-r--r--sc/source/ui/dbgui/validate.src407
-rw-r--r--sc/source/ui/docshell/arealink.cxx531
-rw-r--r--sc/source/ui/docshell/autostyl.cxx246
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx1504
-rw-r--r--sc/source/ui/docshell/dbdocimp.cxx725
-rw-r--r--sc/source/ui/docshell/docfunc.cxx4946
-rw-r--r--sc/source/ui/docshell/docsh.cxx3081
-rw-r--r--sc/source/ui/docshell/docsh2.cxx266
-rw-r--r--sc/source/ui/docshell/docsh3.cxx1412
-rw-r--r--sc/source/ui/docshell/docsh4.cxx2718
-rw-r--r--sc/source/ui/docshell/docsh5.cxx1034
-rw-r--r--sc/source/ui/docshell/docsh6.cxx542
-rw-r--r--sc/source/ui/docshell/docsh7.cxx47
-rw-r--r--sc/source/ui/docshell/docsh8.cxx1184
-rw-r--r--sc/source/ui/docshell/docshimp.hxx59
-rw-r--r--sc/source/ui/docshell/editable.cxx164
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx2555
-rw-r--r--sc/source/ui/docshell/hiranges.cxx55
-rw-r--r--sc/source/ui/docshell/impex.cxx2071
-rw-r--r--sc/source/ui/docshell/macromgr.cxx219
-rw-r--r--sc/source/ui/docshell/makefile.mk141
-rw-r--r--sc/source/ui/docshell/olinefun.cxx799
-rw-r--r--sc/source/ui/docshell/pagedata.cxx141
-rw-r--r--sc/source/ui/docshell/pntlock.cxx63
-rw-r--r--sc/source/ui/docshell/servobj.cxx279
-rw-r--r--sc/source/ui/docshell/sizedev.cxx79
-rw-r--r--sc/source/ui/docshell/tablink.cxx623
-rw-r--r--sc/source/ui/docshell/tpstat.cxx103
-rw-r--r--sc/source/ui/docshell/tpstat.hrc36
-rw-r--r--sc/source/ui/docshell/tpstat.src112
-rw-r--r--sc/source/ui/drawfunc/chartsh.cxx83
-rw-r--r--sc/source/ui/drawfunc/drawsh.cxx485
-rw-r--r--sc/source/ui/drawfunc/drawsh2.cxx397
-rw-r--r--sc/source/ui/drawfunc/drawsh4.cxx117
-rw-r--r--sc/source/ui/drawfunc/drawsh5.cxx756
-rw-r--r--sc/source/ui/drawfunc/drformsh.cxx83
-rw-r--r--sc/source/ui/drawfunc/drformsh.src250
-rw-r--r--sc/source/ui/drawfunc/drtxtob.cxx1076
-rw-r--r--sc/source/ui/drawfunc/drtxtob1.cxx150
-rw-r--r--sc/source/ui/drawfunc/drtxtob2.cxx301
-rw-r--r--sc/source/ui/drawfunc/fuconarc.cxx236
-rw-r--r--sc/source/ui/drawfunc/fuconcustomshape.cxx291
-rw-r--r--sc/source/ui/drawfunc/fuconpol.cxx358
-rw-r--r--sc/source/ui/drawfunc/fuconrec.cxx317
-rw-r--r--sc/source/ui/drawfunc/fuconstr.cxx337
-rw-r--r--sc/source/ui/drawfunc/fuconuno.cxx192
-rw-r--r--sc/source/ui/drawfunc/fudraw.cxx862
-rw-r--r--sc/source/ui/drawfunc/fuins1.cxx436
-rw-r--r--sc/source/ui/drawfunc/fuins2.cxx851
-rw-r--r--sc/source/ui/drawfunc/fumark.cxx292
-rw-r--r--sc/source/ui/drawfunc/fupoor.cxx388
-rw-r--r--sc/source/ui/drawfunc/fusel.cxx657
-rw-r--r--sc/source/ui/drawfunc/fusel2.cxx187
-rw-r--r--sc/source/ui/drawfunc/futext.cxx884
-rw-r--r--sc/source/ui/drawfunc/futext2.cxx309
-rw-r--r--sc/source/ui/drawfunc/futext3.cxx200
-rw-r--r--sc/source/ui/drawfunc/graphsh.cxx150
-rw-r--r--sc/source/ui/drawfunc/makefile.mk87
-rw-r--r--sc/source/ui/drawfunc/mediash.cxx146
-rw-r--r--sc/source/ui/drawfunc/objdraw.src1541
-rw-r--r--sc/source/ui/drawfunc/oleobjsh.cxx83
-rw-r--r--sc/source/ui/formdlg/dwfunctr.cxx1184
-rw-r--r--sc/source/ui/formdlg/dwfunctr.hrc37
-rw-r--r--sc/source/ui/formdlg/dwfunctr.src155
-rw-r--r--sc/source/ui/formdlg/formdata.cxx63
-rw-r--r--sc/source/ui/formdlg/formdlgs.src29
-rw-r--r--sc/source/ui/formdlg/formula.cxx684
-rw-r--r--sc/source/ui/formdlg/makefile.mk53
-rw-r--r--sc/source/ui/formdlg/privsplt.cxx424
-rw-r--r--sc/source/ui/inc/AccessibilityHints.hxx100
-rw-r--r--sc/source/ui/inc/AccessibleCell.hxx176
-rw-r--r--sc/source/ui/inc/AccessibleCellBase.hxx156
-rw-r--r--sc/source/ui/inc/AccessibleContextBase.hxx345
-rw-r--r--sc/source/ui/inc/AccessibleCsvControl.hxx668
-rw-r--r--sc/source/ui/inc/AccessibleDataPilotControl.hxx148
-rw-r--r--sc/source/ui/inc/AccessibleDocument.hxx331
-rw-r--r--sc/source/ui/inc/AccessibleDocumentBase.hxx50
-rw-r--r--sc/source/ui/inc/AccessibleDocumentPagePreview.hxx157
-rw-r--r--sc/source/ui/inc/AccessibleEditObject.hxx181
-rw-r--r--sc/source/ui/inc/AccessiblePageHeader.hxx114
-rw-r--r--sc/source/ui/inc/AccessiblePageHeaderArea.hxx138
-rw-r--r--sc/source/ui/inc/AccessiblePreviewCell.hxx123
-rw-r--r--sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx155
-rw-r--r--sc/source/ui/inc/AccessiblePreviewTable.hxx185
-rw-r--r--sc/source/ui/inc/AccessibleSpreadsheet.hxx292
-rw-r--r--sc/source/ui/inc/AccessibleTableBase.hxx301
-rw-r--r--sc/source/ui/inc/AccessibleText.hxx360
-rw-r--r--sc/source/ui/inc/ChartRangeSelectionListener.hxx82
-rw-r--r--sc/source/ui/inc/DrawModelBroadcaster.hxx62
-rw-r--r--sc/source/ui/inc/IAnyRefDialog.hxx67
-rw-r--r--sc/source/ui/inc/ScDevChart.hxx87
-rw-r--r--sc/source/ui/inc/acredlin.hrc75
-rw-r--r--sc/source/ui/inc/acredlin.hxx257
-rw-r--r--sc/source/ui/inc/anyrefdg.hxx277
-rw-r--r--sc/source/ui/inc/areasave.hxx86
-rw-r--r--sc/source/ui/inc/areasdlg.hxx106
-rw-r--r--sc/source/ui/inc/asciiopt.hxx112
-rw-r--r--sc/source/ui/inc/attrdlg.hrc51
-rw-r--r--sc/source/ui/inc/attrdlg.hxx71
-rw-r--r--sc/source/ui/inc/auditsh.hxx61
-rw-r--r--sc/source/ui/inc/autofmt.hxx141
-rw-r--r--sc/source/ui/inc/autostyl.hxx70
-rw-r--r--sc/source/ui/inc/cbutton.hxx86
-rw-r--r--sc/source/ui/inc/cellmergeoption.hxx61
-rw-r--r--sc/source/ui/inc/cellsh.hxx110
-rw-r--r--sc/source/ui/inc/chartsh.hxx55
-rw-r--r--sc/source/ui/inc/client.hxx64
-rw-r--r--sc/source/ui/inc/colrowba.hxx112
-rw-r--r--sc/source/ui/inc/condfrmt.hrc73
-rw-r--r--sc/source/ui/inc/condfrmt.hxx157
-rw-r--r--sc/source/ui/inc/conflictsdlg.hrc43
-rw-r--r--sc/source/ui/inc/conflictsdlg.hxx215
-rw-r--r--sc/source/ui/inc/consdlg.hxx130
-rw-r--r--sc/source/ui/inc/content.hxx170
-rw-r--r--sc/source/ui/inc/corodlg.hxx77
-rw-r--r--sc/source/ui/inc/crdlg.hxx65
-rw-r--r--sc/source/ui/inc/crnrdlg.hrc46
-rw-r--r--sc/source/ui/inc/crnrdlg.hxx114
-rw-r--r--sc/source/ui/inc/csvcontrol.hxx434
-rw-r--r--sc/source/ui/inc/csvgrid.hxx360
-rw-r--r--sc/source/ui/inc/csvruler.hxx202
-rw-r--r--sc/source/ui/inc/csvsplits.hxx105
-rw-r--r--sc/source/ui/inc/csvtablebox.hxx158
-rw-r--r--sc/source/ui/inc/dapidata.hxx72
-rw-r--r--sc/source/ui/inc/dapitype.hxx95
-rw-r--r--sc/source/ui/inc/datafdlg.hrc42
-rw-r--r--sc/source/ui/inc/datafdlg.hxx114
-rw-r--r--sc/source/ui/inc/dbdocfun.hxx127
-rw-r--r--sc/source/ui/inc/dbfunc.hxx137
-rw-r--r--sc/source/ui/inc/dbnamdlg.hrc51
-rw-r--r--sc/source/ui/inc/dbnamdlg.hxx123
-rw-r--r--sc/source/ui/inc/delcldlg.hxx66
-rw-r--r--sc/source/ui/inc/delcodlg.hxx76
-rw-r--r--sc/source/ui/inc/docfunc.hxx199
-rw-r--r--sc/source/ui/inc/docsh.hxx483
-rw-r--r--sc/source/ui/inc/dpcontrol.hrc40
-rw-r--r--sc/source/ui/inc/dpcontrol.hxx366
-rw-r--r--sc/source/ui/inc/dpgroupdlg.hxx168
-rw-r--r--sc/source/ui/inc/drawsh.hxx94
-rw-r--r--sc/source/ui/inc/drawutil.hxx53
-rw-r--r--sc/source/ui/inc/drawview.hxx151
-rw-r--r--sc/source/ui/inc/drformsh.hxx58
-rw-r--r--sc/source/ui/inc/drtxtob.hxx91
-rw-r--r--sc/source/ui/inc/drwtrans.hxx112
-rw-r--r--sc/source/ui/inc/dwfunctr.hxx154
-rw-r--r--sc/source/ui/inc/editable.hxx88
-rw-r--r--sc/source/ui/inc/editfield.hxx52
-rw-r--r--sc/source/ui/inc/editsh.hxx88
-rw-r--r--sc/source/ui/inc/expftext.hxx48
-rw-r--r--sc/source/ui/inc/fieldwnd.hxx223
-rw-r--r--sc/source/ui/inc/filldlg.hxx134
-rw-r--r--sc/source/ui/inc/filtdlg.hxx263
-rw-r--r--sc/source/ui/inc/filter.hrc82
-rw-r--r--sc/source/ui/inc/foptmgr.hxx116
-rw-r--r--sc/source/ui/inc/formatsh.hxx85
-rw-r--r--sc/source/ui/inc/formdata.hxx68
-rw-r--r--sc/source/ui/inc/formula.hxx138
-rw-r--r--sc/source/ui/inc/fuconarc.hxx64
-rw-r--r--sc/source/ui/inc/fuconcustomshape.hxx63
-rw-r--r--sc/source/ui/inc/fuconpol.hxx65
-rw-r--r--sc/source/ui/inc/fuconrec.hxx64
-rw-r--r--sc/source/ui/inc/fuconstr.hxx70
-rw-r--r--sc/source/ui/inc/fuconuno.hxx69
-rw-r--r--sc/source/ui/inc/fudraw.hxx80
-rw-r--r--sc/source/ui/inc/fuedipo.hxx62
-rw-r--r--sc/source/ui/inc/fuinsert.hxx87
-rw-r--r--sc/source/ui/inc/fumark.hxx76
-rw-r--r--sc/source/ui/inc/funcpage.hxx128
-rw-r--r--sc/source/ui/inc/funcutl.hxx197
-rw-r--r--sc/source/ui/inc/fupoor.hxx138
-rw-r--r--sc/source/ui/inc/fusel.hxx83
-rw-r--r--sc/source/ui/inc/futext.hxx83
-rw-r--r--sc/source/ui/inc/graphsh.hxx60
-rw-r--r--sc/source/ui/inc/gridmerg.hxx66
-rw-r--r--sc/source/ui/inc/gridwin.hxx430
-rw-r--r--sc/source/ui/inc/groupdlg.hxx63
-rw-r--r--sc/source/ui/inc/hdrcont.hxx141
-rw-r--r--sc/source/ui/inc/hfedtdlg.hxx59
-rw-r--r--sc/source/ui/inc/highred.hrc71
-rw-r--r--sc/source/ui/inc/highred.hxx116
-rw-r--r--sc/source/ui/inc/hintwin.hxx56
-rw-r--r--sc/source/ui/inc/hiranges.hxx66
-rw-r--r--sc/source/ui/inc/imoptdlg.hxx110
-rw-r--r--sc/source/ui/inc/impex.hxx193
-rw-r--r--sc/source/ui/inc/inputhdl.hxx302
-rw-r--r--sc/source/ui/inc/inputwin.hxx228
-rw-r--r--sc/source/ui/inc/inscldlg.hxx64
-rw-r--r--sc/source/ui/inc/inscodlg.hxx118
-rw-r--r--sc/source/ui/inc/instbdlg.hrc52
-rw-r--r--sc/source/ui/inc/instbdlg.hxx126
-rw-r--r--sc/source/ui/inc/invmerge.hxx63
-rw-r--r--sc/source/ui/inc/lbseldlg.hxx69
-rw-r--r--sc/source/ui/inc/linkarea.hrc42
-rw-r--r--sc/source/ui/inc/linkarea.hxx106
-rw-r--r--sc/source/ui/inc/lnktrans.hxx55
-rw-r--r--sc/source/ui/inc/makefile.mk26
-rw-r--r--sc/source/ui/inc/mediash.hxx57
-rw-r--r--sc/source/ui/inc/miscdlgs.hrc188
-rw-r--r--sc/source/ui/inc/msgpool.hxx79
-rw-r--r--sc/source/ui/inc/mtrindlg.hxx78
-rw-r--r--sc/source/ui/inc/mvtabdlg.hxx81
-rw-r--r--sc/source/ui/inc/namecrea.hxx57
-rw-r--r--sc/source/ui/inc/namedlg.hrc52
-rw-r--r--sc/source/ui/inc/namedlg.hxx119
-rw-r--r--sc/source/ui/inc/namepast.hxx62
-rw-r--r--sc/source/ui/inc/navcitem.hxx57
-rw-r--r--sc/source/ui/inc/navipi.hxx368
-rw-r--r--sc/source/ui/inc/navsett.hxx61
-rw-r--r--sc/source/ui/inc/notemark.hxx80
-rw-r--r--sc/source/ui/inc/oleobjsh.hxx55
-rw-r--r--sc/source/ui/inc/olinefun.hxx70
-rw-r--r--sc/source/ui/inc/olinewin.hxx246
-rw-r--r--sc/source/ui/inc/opredlin.hrc38
-rw-r--r--sc/source/ui/inc/opredlin.hxx78
-rw-r--r--sc/source/ui/inc/optdlg.hrc197
-rw-r--r--sc/source/ui/inc/optload.hrc40
-rw-r--r--sc/source/ui/inc/optload.hxx68
-rw-r--r--sc/source/ui/inc/optsolver.hrc98
-rw-r--r--sc/source/ui/inc/optsolver.hxx266
-rw-r--r--sc/source/ui/inc/output.hxx275
-rw-r--r--sc/source/ui/inc/overlayobject.hxx61
-rw-r--r--sc/source/ui/inc/pagedata.hxx97
-rw-r--r--sc/source/ui/inc/parawin.hxx171
-rw-r--r--sc/source/ui/inc/pfiltdlg.hxx135
-rw-r--r--sc/source/ui/inc/pfuncache.hxx127
-rw-r--r--sc/source/ui/inc/pgbrksh.hxx55
-rw-r--r--sc/source/ui/inc/pivotsh.hxx63
-rw-r--r--sc/source/ui/inc/pntlock.hxx69
-rw-r--r--sc/source/ui/inc/popmenu.hxx53
-rw-r--r--sc/source/ui/inc/preview.hxx173
-rw-r--r--sc/source/ui/inc/prevloc.hxx159
-rw-r--r--sc/source/ui/inc/prevwsh.hxx140
-rw-r--r--sc/source/ui/inc/printfun.hxx368
-rw-r--r--sc/source/ui/inc/privsplt.hxx89
-rw-r--r--sc/source/ui/inc/protectiondlg.hrc44
-rw-r--r--sc/source/ui/inc/protectiondlg.hxx85
-rw-r--r--sc/source/ui/inc/pvfundlg.hxx254
-rw-r--r--sc/source/ui/inc/pvlaydlg.hxx236
-rw-r--r--sc/source/ui/inc/redcom.hxx68
-rw-r--r--sc/source/ui/inc/reffact.hxx125
-rw-r--r--sc/source/ui/inc/refundo.hxx71
-rw-r--r--sc/source/ui/inc/retypepassdlg.hrc71
-rw-r--r--sc/source/ui/inc/retypepassdlg.hxx177
-rw-r--r--sc/source/ui/inc/rfindlst.hxx77
-rw-r--r--sc/source/ui/inc/scendlg.hxx82
-rw-r--r--sc/source/ui/inc/scui_def.hxx59
-rw-r--r--sc/source/ui/inc/scuiasciiopt.hxx149
-rw-r--r--sc/source/ui/inc/scuiautofmt.hxx90
-rw-r--r--sc/source/ui/inc/scuiimoptdlg.hxx80
-rw-r--r--sc/source/ui/inc/scuitphfedit.hxx167
-rw-r--r--sc/source/ui/inc/select.hxx128
-rw-r--r--sc/source/ui/inc/selectionstate.hxx81
-rw-r--r--sc/source/ui/inc/seltrans.hxx83
-rw-r--r--sc/source/ui/inc/servobj.hxx79
-rw-r--r--sc/source/ui/inc/sharedocdlg.hrc44
-rw-r--r--sc/source/ui/inc/sharedocdlg.hxx79
-rw-r--r--sc/source/ui/inc/shtabdlg.hxx71
-rw-r--r--sc/source/ui/inc/simpref.hrc37
-rw-r--r--sc/source/ui/inc/simpref.hxx116
-rw-r--r--sc/source/ui/inc/sizedev.hxx57
-rw-r--r--sc/source/ui/inc/solveroptions.hrc47
-rw-r--r--sc/source/ui/inc/solveroptions.hxx123
-rw-r--r--sc/source/ui/inc/solverutil.hxx52
-rw-r--r--sc/source/ui/inc/solvrdlg.hrc46
-rw-r--r--sc/source/ui/inc/solvrdlg.hxx111
-rw-r--r--sc/source/ui/inc/sortdlg.hrc91
-rw-r--r--sc/source/ui/inc/sortdlg.hxx90
-rw-r--r--sc/source/ui/inc/spelldialog.hxx105
-rw-r--r--sc/source/ui/inc/spelleng.hxx171
-rw-r--r--sc/source/ui/inc/spellparam.hxx89
-rw-r--r--sc/source/ui/inc/strindlg.hxx68
-rw-r--r--sc/source/ui/inc/styledlg.hrc39
-rw-r--r--sc/source/ui/inc/styledlg.hxx61
-rw-r--r--sc/source/ui/inc/submenu.hrc68
-rw-r--r--sc/source/ui/inc/subtdlg.hrc64
-rw-r--r--sc/source/ui/inc/subtdlg.hxx55
-rw-r--r--sc/source/ui/inc/tabbgcolordlg.hxx81
-rw-r--r--sc/source/ui/inc/tabcont.hxx91
-rw-r--r--sc/source/ui/inc/tabopdlg.hrc50
-rw-r--r--sc/source/ui/inc/tabopdlg.hxx116
-rw-r--r--sc/source/ui/inc/tabpages.hxx84
-rw-r--r--sc/source/ui/inc/tabpopsh.hxx55
-rw-r--r--sc/source/ui/inc/tabsplit.hxx62
-rw-r--r--sc/source/ui/inc/tabview.hxx529
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx431
-rw-r--r--sc/source/ui/inc/target.hxx54
-rw-r--r--sc/source/ui/inc/tbinsert.hrc32
-rw-r--r--sc/source/ui/inc/tbinsert.hxx90
-rw-r--r--sc/source/ui/inc/tbzoomsliderctrl.hxx80
-rw-r--r--sc/source/ui/inc/textdlgs.hxx74
-rw-r--r--sc/source/ui/inc/textimportoptions.hrc42
-rw-r--r--sc/source/ui/inc/textimportoptions.hxx79
-rw-r--r--sc/source/ui/inc/tpcalc.hxx104
-rw-r--r--sc/source/ui/inc/tpcompatibility.hxx64
-rw-r--r--sc/source/ui/inc/tpformula.hxx100
-rw-r--r--sc/source/ui/inc/tphf.hxx105
-rw-r--r--sc/source/ui/inc/tphfedit.hxx140
-rw-r--r--sc/source/ui/inc/tpprint.hxx58
-rw-r--r--sc/source/ui/inc/tpsort.hxx225
-rw-r--r--sc/source/ui/inc/tpstat.hxx68
-rw-r--r--sc/source/ui/inc/tpsubt.hxx190
-rw-r--r--sc/source/ui/inc/tptable.hxx118
-rw-r--r--sc/source/ui/inc/tpusrlst.hxx119
-rw-r--r--sc/source/ui/inc/tpview.hxx173
-rw-r--r--sc/source/ui/inc/transobj.hxx117
-rw-r--r--sc/source/ui/inc/ui_pch.hxx329
-rw-r--r--sc/source/ui/inc/uiitems.hxx373
-rw-r--r--sc/source/ui/inc/undobase.hxx173
-rw-r--r--sc/source/ui/inc/undoblk.hxx999
-rw-r--r--sc/source/ui/inc/undocell.hxx377
-rw-r--r--sc/source/ui/inc/undodat.hxx540
-rw-r--r--sc/source/ui/inc/undodraw.hxx65
-rw-r--r--sc/source/ui/inc/undoolk.hxx47
-rw-r--r--sc/source/ui/inc/undostyl.hxx119
-rw-r--r--sc/source/ui/inc/undotab.hxx523
-rw-r--r--sc/source/ui/inc/undoutil.hxx69
-rw-r--r--sc/source/ui/inc/validate.hrc88
-rw-r--r--sc/source/ui/inc/validate.hxx349
-rw-r--r--sc/source/ui/inc/viewdata.hxx570
-rw-r--r--sc/source/ui/inc/viewfunc.hxx381
-rw-r--r--sc/source/ui/inc/viewutil.hxx118
-rw-r--r--sc/source/ui/inc/warnbox.hxx76
-rw-r--r--sc/source/ui/miscdlgs/acredlin.cxx2137
-rw-r--r--sc/source/ui/miscdlgs/acredlin.src258
-rw-r--r--sc/source/ui/miscdlgs/anyrefdg.cxx1013
-rw-r--r--sc/source/ui/miscdlgs/autofmt.cxx569
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.cxx861
-rw-r--r--sc/source/ui/miscdlgs/conflictsdlg.src109
-rw-r--r--sc/source/ui/miscdlgs/crdlg.cxx89
-rw-r--r--sc/source/ui/miscdlgs/crnrdlg.cxx1175
-rw-r--r--sc/source/ui/miscdlgs/datafdlg.cxx425
-rw-r--r--sc/source/ui/miscdlgs/delcldlg.cxx122
-rw-r--r--sc/source/ui/miscdlgs/delcodlg.cxx182
-rw-r--r--sc/source/ui/miscdlgs/filldlg.cxx377
-rw-r--r--sc/source/ui/miscdlgs/groupdlg.cxx85
-rw-r--r--sc/source/ui/miscdlgs/highred.cxx303
-rw-r--r--sc/source/ui/miscdlgs/highred.src133
-rw-r--r--sc/source/ui/miscdlgs/inscldlg.cxx122
-rw-r--r--sc/source/ui/miscdlgs/inscodlg.cxx374
-rw-r--r--sc/source/ui/miscdlgs/instbdlg.cxx435
-rw-r--r--sc/source/ui/miscdlgs/instbdlg.src184
-rw-r--r--sc/source/ui/miscdlgs/lbseldlg.cxx103
-rw-r--r--sc/source/ui/miscdlgs/linkarea.cxx368
-rw-r--r--sc/source/ui/miscdlgs/linkarea.src120
-rw-r--r--sc/source/ui/miscdlgs/makefile.mk126
-rw-r--r--sc/source/ui/miscdlgs/mtrindlg.cxx188
-rw-r--r--sc/source/ui/miscdlgs/mvtabdlg.cxx207
-rw-r--r--sc/source/ui/miscdlgs/namecrea.cxx81
-rw-r--r--sc/source/ui/miscdlgs/namepast.cxx135
-rw-r--r--sc/source/ui/miscdlgs/optsolver.cxx1068
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.cxx165
-rw-r--r--sc/source/ui/miscdlgs/protectiondlg.src127
-rw-r--r--sc/source/ui/miscdlgs/redcom.cxx187
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.cxx547
-rw-r--r--sc/source/ui/miscdlgs/retypepassdlg.src313
-rw-r--r--sc/source/ui/miscdlgs/scuiautofmt.cxx479
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.cxx238
-rw-r--r--sc/source/ui/miscdlgs/sharedocdlg.src110
-rw-r--r--sc/source/ui/miscdlgs/shtabdlg.cxx113
-rw-r--r--sc/source/ui/miscdlgs/simpref.cxx259
-rw-r--r--sc/source/ui/miscdlgs/solveroptions.cxx494
-rw-r--r--sc/source/ui/miscdlgs/solverutil.cxx231
-rw-r--r--sc/source/ui/miscdlgs/solvrdlg.cxx315
-rw-r--r--sc/source/ui/miscdlgs/strindlg.cxx109
-rw-r--r--sc/source/ui/miscdlgs/tabbgcolordlg.cxx201
-rw-r--r--sc/source/ui/miscdlgs/tabopdlg.cxx373
-rw-r--r--sc/source/ui/miscdlgs/textdlgs.cxx132
-rw-r--r--sc/source/ui/miscdlgs/warnbox.cxx93
-rw-r--r--sc/source/ui/namedlg/makefile.mk49
-rw-r--r--sc/source/ui/namedlg/namedlg.cxx651
-rw-r--r--sc/source/ui/navipi/content.cxx1517
-rw-r--r--sc/source/ui/navipi/makefile.mk55
-rw-r--r--sc/source/ui/navipi/navcitem.cxx129
-rw-r--r--sc/source/ui/navipi/navipi.cxx1508
-rw-r--r--sc/source/ui/navipi/navipi.hrc63
-rw-r--r--sc/source/ui/navipi/navipi.src414
-rw-r--r--sc/source/ui/navipi/scenwnd.cxx311
-rw-r--r--sc/source/ui/optdlg/makefile.mk67
-rw-r--r--sc/source/ui/optdlg/opredlin.cxx291
-rw-r--r--sc/source/ui/optdlg/tpcalc.cxx307
-rw-r--r--sc/source/ui/optdlg/tpcompatibility.cxx108
-rw-r--r--sc/source/ui/optdlg/tpformula.cxx294
-rw-r--r--sc/source/ui/optdlg/tpprint.cxx146
-rw-r--r--sc/source/ui/optdlg/tpusrlst.cxx829
-rw-r--r--sc/source/ui/optdlg/tpview.cxx747
-rw-r--r--sc/source/ui/pagedlg/areasdlg.cxx909
-rw-r--r--sc/source/ui/pagedlg/hfedtdlg.cxx187
-rw-r--r--sc/source/ui/pagedlg/hfedtdlg.hrc64
-rw-r--r--sc/source/ui/pagedlg/hfedtdlg.src829
-rw-r--r--sc/source/ui/pagedlg/makefile.mk72
-rw-r--r--sc/source/ui/pagedlg/pagedlg.hrc103
-rw-r--r--sc/source/ui/pagedlg/pagedlg.src416
-rw-r--r--sc/source/ui/pagedlg/scuitphfedit.cxx1002
-rw-r--r--sc/source/ui/pagedlg/tphf.cxx332
-rw-r--r--sc/source/ui/pagedlg/tphf.src64
-rw-r--r--sc/source/ui/pagedlg/tphfedit.cxx567
-rw-r--r--sc/source/ui/pagedlg/tptable.cxx572
-rw-r--r--sc/source/ui/src/attrdlg.src203
-rw-r--r--sc/source/ui/src/autofmt.src271
-rw-r--r--sc/source/ui/src/condfrmt.src398
-rw-r--r--sc/source/ui/src/crnrdlg.src166
-rw-r--r--sc/source/ui/src/datafdlg.src99
-rw-r--r--sc/source/ui/src/dbnamdlg.src198
-rw-r--r--sc/source/ui/src/filter.src820
-rw-r--r--sc/source/ui/src/globstr.src1829
-rw-r--r--sc/source/ui/src/hdrcont.src256
-rw-r--r--sc/source/ui/src/makefile.mk76
-rw-r--r--sc/source/ui/src/miscdlgs.src1463
-rw-r--r--sc/source/ui/src/namedlg.src165
-rw-r--r--sc/source/ui/src/opredlin.src136
-rw-r--r--sc/source/ui/src/optdlg.src865
-rw-r--r--sc/source/ui/src/optsolver.src540
-rw-r--r--sc/source/ui/src/popup.src544
-rw-r--r--sc/source/ui/src/pseudo.src62
-rw-r--r--sc/source/ui/src/sc.src49
-rw-r--r--sc/source/ui/src/scerrors.src170
-rw-r--r--sc/source/ui/src/scfuncs.src9043
-rw-r--r--sc/source/ui/src/scstring.src771
-rw-r--r--sc/source/ui/src/scwarngs.src83
-rw-r--r--sc/source/ui/src/simpref.src105
-rw-r--r--sc/source/ui/src/solveroptions.src189
-rw-r--r--sc/source/ui/src/solvrdlg.src135
-rw-r--r--sc/source/ui/src/sortdlg.src361
-rw-r--r--sc/source/ui/src/subtdlg.src291
-rw-r--r--sc/source/ui/src/tabopdlg.src142
-rw-r--r--sc/source/ui/src/textdlgs.src197
-rw-r--r--sc/source/ui/src/toolbox.src299
-rw-r--r--sc/source/ui/styleui/makefile.mk55
-rw-r--r--sc/source/ui/styleui/scstyles.src70
-rw-r--r--sc/source/ui/styleui/styledlg.cxx219
-rw-r--r--sc/source/ui/styleui/styledlg.src172
-rw-r--r--sc/source/ui/styleui/template.curbin0 -> 326 bytes
-rw-r--r--sc/source/ui/undo/areasave.cxx232
-rw-r--r--sc/source/ui/undo/makefile.mk83
-rw-r--r--sc/source/ui/undo/refundo.cxx216
-rw-r--r--sc/source/ui/undo/target.cxx48
-rw-r--r--sc/source/ui/undo/undobase.cxx541
-rw-r--r--sc/source/ui/undo/undoblk.cxx2277
-rw-r--r--sc/source/ui/undo/undoblk2.cxx217
-rw-r--r--sc/source/ui/undo/undoblk3.cxx2181
-rw-r--r--sc/source/ui/undo/undocell.cxx1147
-rw-r--r--sc/source/ui/undo/undodat.cxx2241
-rw-r--r--sc/source/ui/undo/undodraw.cxx271
-rw-r--r--sc/source/ui/undo/undoolk.cxx104
-rw-r--r--sc/source/ui/undo/undostyl.cxx313
-rw-r--r--sc/source/ui/undo/undotab.cxx1668
-rw-r--r--sc/source/ui/undo/undoutil.cxx136
-rw-r--r--sc/source/ui/unoobj/ChartRangeSelectionListener.cxx98
-rw-r--r--sc/source/ui/unoobj/addruno.cxx329
-rw-r--r--sc/source/ui/unoobj/afmtuno.cxx886
-rw-r--r--sc/source/ui/unoobj/appluno.cxx1087
-rw-r--r--sc/source/ui/unoobj/celllistsource.cxx452
-rw-r--r--sc/source/ui/unoobj/celllistsource.hxx178
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx9855
-rw-r--r--sc/source/ui/unoobj/cellvaluebinding.cxx666
-rw-r--r--sc/source/ui/unoobj/cellvaluebinding.hxx174
-rw-r--r--sc/source/ui/unoobj/chart2uno.cxx3865
-rw-r--r--sc/source/ui/unoobj/chartuno.cxx818
-rw-r--r--sc/source/ui/unoobj/confuno.cxx490
-rw-r--r--sc/source/ui/unoobj/convuno.cxx66
-rw-r--r--sc/source/ui/unoobj/cursuno.cxx512
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx3556
-rw-r--r--sc/source/ui/unoobj/datauno.cxx2373
-rw-r--r--sc/source/ui/unoobj/defltuno.cxx389
-rw-r--r--sc/source/ui/unoobj/detreg.cxx113
-rw-r--r--sc/source/ui/unoobj/dispuno.cxx417
-rw-r--r--sc/source/ui/unoobj/docuno.cxx3726
-rw-r--r--sc/source/ui/unoobj/drdefuno.cxx85
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx375
-rw-r--r--sc/source/ui/unoobj/eventuno.cxx203
-rw-r--r--sc/source/ui/unoobj/fielduno.cxx1530
-rw-r--r--sc/source/ui/unoobj/filtuno.cxx314
-rw-r--r--sc/source/ui/unoobj/fmtuno.cxx1063
-rw-r--r--sc/source/ui/unoobj/forbiuno.cxx95
-rw-r--r--sc/source/ui/unoobj/funcuno.cxx746
-rw-r--r--sc/source/ui/unoobj/linkuno.cxx1823
-rw-r--r--sc/source/ui/unoobj/listenercalls.cxx91
-rw-r--r--sc/source/ui/unoobj/makefile.mk117
-rw-r--r--sc/source/ui/unoobj/miscuno.cxx330
-rw-r--r--sc/source/ui/unoobj/nameuno.cxx1186
-rw-r--r--sc/source/ui/unoobj/notesuno.cxx735
-rw-r--r--sc/source/ui/unoobj/optuno.cxx238
-rw-r--r--sc/source/ui/unoobj/pageuno.cxx81
-rw-r--r--sc/source/ui/unoobj/scdetect.cxx903
-rw-r--r--sc/source/ui/unoobj/scdetect.hxx98
-rw-r--r--sc/source/ui/unoobj/servuno.cxx614
-rw-r--r--sc/source/ui/unoobj/shapeuno.cxx1527
-rw-r--r--sc/source/ui/unoobj/srchuno.cxx280
-rw-r--r--sc/source/ui/unoobj/styleuno.cxx2137
-rw-r--r--sc/source/ui/unoobj/targuno.cxx317
-rw-r--r--sc/source/ui/unoobj/textuno.cxx1147
-rw-r--r--sc/source/ui/unoobj/tokenuno.cxx471
-rw-r--r--sc/source/ui/unoobj/unodoc.cxx69
-rw-r--r--sc/source/ui/unoobj/unoreflist.cxx75
-rw-r--r--sc/source/ui/unoobj/viewuno.cxx2376
-rw-r--r--sc/source/ui/unoobj/warnpassword.cxx97
-rw-r--r--sc/source/ui/vba/excelvbahelper.cxx437
-rw-r--r--sc/source/ui/vba/excelvbahelper.hxx83
-rw-r--r--sc/source/ui/vba/helperdecl.hxx55
-rw-r--r--sc/source/ui/vba/makefile.mk136
-rw-r--r--sc/source/ui/vba/service.cxx137
-rw-r--r--sc/source/ui/vba/testvba/README37
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/ApplicationRunTest.xlsbin0 -> 25088 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/AutoFilter.xlsbin0 -> 54272 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcFont.xlsbin0 -> 73728 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcZoom.xlsbin0 -> 62976 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncTests.xlsbin0 -> 71168 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncs.xlsbin0 -> 47104 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscOperatorTests.xlsbin0 -> 66048 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscRangeTests.xlsbin0 -> 126976 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/PageBreaks.xlsbin0 -> 63488 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-2.xlsbin0 -> 2209280 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-3.xlsbin0 -> 54784 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges.xlsbin0 -> 2236416 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/Shapes.xlsbin0 -> 74240 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/StrConv-test.xlsbin0 -> 65024 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/Template.xlsbin0 -> 65024 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestAddress.xlsbin0 -> 84480 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest.xlsbin0 -> 67584 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest2.xlsbin0 -> 71680 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestIntersection.xlsbin0 -> 81408 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestUnion.xlsbin0 -> 72192 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/VariantTest.xlsbin0 -> 68608 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/Window.xlsbin0 -> 87040 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/bytearraystring.xlsbin0 -> 58880 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/dateserial.xlsbin0 -> 57344 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/datevalue.xlsbin0 -> 61952 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/format.xlsbin0 -> 102400 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/AutoFilter.log20
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/MiscRangeTests.log45
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-2.log68
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-3.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges.log280
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestAddress.log62
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest.log60
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest2.log64
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/format.log36
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/AutoFilter.log20
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcFont.log17
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcZoom.log18
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/FinancialFuncTests.log31
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscOperatorTests.log30
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscRangeTests.log45
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/PageBreaks.log10
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-2.log68
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-3.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges.log280
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Shapes.log77
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/StrConv-test.log9
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Template.log14
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestAddress.log67
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest.log60
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest2.log65
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestIntersection.log26
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestUnion.log17
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/VariantTest.log47
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Window.log46
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/bytearraystring.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/dateserial.log9
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/datevalue.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/format.log36
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/pagesetup.log77
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/partition.log11
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/range-4.log16
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/replace.log14
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/stringplusdouble.log62
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/window2.log41
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/AutoFilter.log20
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/CalcFont.log17
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscOperatorTests.log29
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscRangeTests.log45
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/PageBreaks.log10
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-2.log68
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-3.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges.log280
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Shapes.log77
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/StrConv-test.log9
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Template.log14
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestAddress.log67
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest.log60
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest2.log65
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestIntersection.log26
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestUnion.log17
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/VariantTest.log47
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Window.log46
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/bytearraystring.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/dateserial.log9
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/datevalue.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/format.log36
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/pagesetup.log87
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/partition.log11
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/range-4.log16
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/replace.log14
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/stringplusdouble.log62
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/window2.log41
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/error.xlsbin0 -> 38400 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/imagecontrols.xlsbin0 -> 2415104 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/keyword.xlsbin0 -> 50688 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/objectmodule.xlsbin0 -> 62464 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/stringtodouble.odsbin0 -> 13260 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/partition.xlsbin0 -> 65536 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/range-4.xlsbin0 -> 2192384 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/replace.xlsbin0 -> 64512 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/stringplusdouble.xlsbin0 -> 75264 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments-ooo-build/window2.xlsbin0 -> 72192 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/ApplicationRunTest.xlsbin0 -> 25088 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/AutoFilter.xlsbin0 -> 54272 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/CalcFont.xlsbin0 -> 73728 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/FinancialFuncs.xlsbin0 -> 47104 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xlsbin0 -> 126976 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xlsbin0 -> 63488 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xlsbin0 -> 2209280 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xlsbin0 -> 54784 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/Ranges.xlsbin0 -> 2236416 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/Shapes.xlsbin0 -> 74240 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/StrConv-test.xlsbin0 -> 65024 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/Template.xlsbin0 -> 65024 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/TestAddress.xlsbin0 -> 84480 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xlsbin0 -> 67584 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xlsbin0 -> 71680 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/TestIntersection.xlsbin0 -> 81408 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/TestUnion.xlsbin0 -> 72192 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/Window.xlsbin0 -> 87040 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/bytearraystring.xlsbin0 -> 58880 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/dateserial.xlsbin0 -> 57344 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/datevalue.xlsbin0 -> 61952 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/format.xlsbin0 -> 102400 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/AutoFilter.log20
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/MiscRangeTests.log45
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-2.log68
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-3.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges.log280
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestAddress.log62
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest.log60
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest2.log64
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/AutoFilter.log20
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/CalcFont.log17
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/MiscRangeTests.log45
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/PageBreaks.log10
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-2.log68
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-3.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log280
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/Shapes.log77
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/StrConv-test.log9
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/Template.log14
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log67
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest.log60
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest2.log65
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestIntersection.log26
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestUnion.log17
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/Window.log46
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/bytearraystring.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/dateserial.log9
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/datevalue.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log36
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/pagesetup.log77
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/partition.log11
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/range-4.log16
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log14
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/stringplusdouble.log62
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log41
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/AutoFilter.log20
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/MiscRangeTests.log45
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-2.log68
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-3.log8
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges.log280
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/Shapes.log77
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/TestAddress.log62
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest.log60
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest2.log65
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/pagesetup.log87
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log14
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/pagesetup.xlsbin0 -> 72704 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/partition.xlsbin0 -> 65536 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/range-4.xlsbin0 -> 2192384 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/replace.xlsbin0 -> 64512 bytes
-rw-r--r--sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xlsbin0 -> 75264 bytes
-rwxr-xr-xsc/source/ui/vba/testvba/TestDocuments/window2.xlsbin0 -> 72192 bytes
-rw-r--r--sc/source/ui/vba/testvba/launchTest.pl45
-rw-r--r--sc/source/ui/vba/testvba/makefile.mk69
-rwxr-xr-xsc/source/ui/vba/testvba/runTests.pl121
-rw-r--r--sc/source/ui/vba/testvba/testResult.pl171
-rwxr-xr-xsc/source/ui/vba/testvba/testResults.pl163
-rwxr-xr-xsc/source/ui/vba/testvba/testclientbin0 -> 50595 bytes
-rw-r--r--sc/source/ui/vba/testvba/testvba.cxx312
-rwxr-xr-xsc/source/ui/vba/testvba/timestampsClean.pl73
-rw-r--r--sc/source/ui/vba/vbaapplication.cxx1813
-rw-r--r--sc/source/ui/vba/vbaapplication.hxx147
-rw-r--r--sc/source/ui/vba/vbaassistant.cxx135
-rw-r--r--sc/source/ui/vba/vbaassistant.hxx73
-rw-r--r--sc/source/ui/vba/vbaaxes.cxx205
-rw-r--r--sc/source/ui/vba/vbaaxes.hxx54
-rw-r--r--sc/source/ui/vba/vbaaxis.cxx672
-rw-r--r--sc/source/ui/vba/vbaaxis.hxx101
-rw-r--r--sc/source/ui/vba/vbaaxistitle.cxx60
-rw-r--r--sc/source/ui/vba/vbaaxistitle.hxx47
-rw-r--r--sc/source/ui/vba/vbaborders.cxx577
-rw-r--r--sc/source/ui/vba/vbaborders.hxx78
-rw-r--r--sc/source/ui/vba/vbacharacters.cxx138
-rw-r--r--sc/source/ui/vba/vbacharacters.hxx77
-rw-r--r--sc/source/ui/vba/vbachart.cxx1255
-rw-r--r--sc/source/ui/vba/vbachart.hxx117
-rw-r--r--sc/source/ui/vba/vbachartobject.cxx213
-rw-r--r--sc/source/ui/vba/vbachartobject.hxx83
-rw-r--r--sc/source/ui/vba/vbachartobjects.cxx196
-rw-r--r--sc/source/ui/vba/vbachartobjects.hxx78
-rw-r--r--sc/source/ui/vba/vbacharts.cxx122
-rw-r--r--sc/source/ui/vba/vbacharts.hxx63
-rw-r--r--sc/source/ui/vba/vbacharttitle.cxx60
-rw-r--r--sc/source/ui/vba/vbacharttitle.hxx47
-rw-r--r--sc/source/ui/vba/vbacomment.cxx252
-rw-r--r--sc/source/ui/vba/vbacomment.hxx83
-rw-r--r--sc/source/ui/vba/vbacomments.cxx119
-rw-r--r--sc/source/ui/vba/vbacomments.hxx67
-rw-r--r--sc/source/ui/vba/vbacommentshape.cxx49
-rw-r--r--sc/source/ui/vba/vbacommentshape.hxx49
-rw-r--r--sc/source/ui/vba/vbacondition.cxx177
-rw-r--r--sc/source/ui/vba/vbacondition.hxx57
-rw-r--r--sc/source/ui/vba/vbadialog.cxx114
-rw-r--r--sc/source/ui/vba/vbadialog.hxx56
-rw-r--r--sc/source/ui/vba/vbadialogs.cxx78
-rw-r--r--sc/source/ui/vba/vbadialogs.hxx59
-rw-r--r--sc/source/ui/vba/vbaeventshelper.cxx764
-rw-r--r--sc/source/ui/vba/vbaeventshelper.hxx91
-rw-r--r--sc/source/ui/vba/vbafiledialog.cxx186
-rw-r--r--sc/source/ui/vba/vbafiledialog.hxx63
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.cxx157
-rw-r--r--sc/source/ui/vba/vbafiledialogselecteditems.hxx90
-rw-r--r--sc/source/ui/vba/vbafilesearch.cxx245
-rw-r--r--sc/source/ui/vba/vbafilesearch.hxx80
-rw-r--r--sc/source/ui/vba/vbafont.cxx504
-rw-r--r--sc/source/ui/vba/vbafont.hxx92
-rw-r--r--sc/source/ui/vba/vbaformat.cxx845
-rw-r--r--sc/source/ui/vba/vbaformat.hxx111
-rw-r--r--sc/source/ui/vba/vbaformatcondition.cxx179
-rw-r--r--sc/source/ui/vba/vbaformatcondition.hxx73
-rw-r--r--sc/source/ui/vba/vbaformatconditions.cxx303
-rw-r--r--sc/source/ui/vba/vbaformatconditions.hxx68
-rw-r--r--sc/source/ui/vba/vbafoundfiles.cxx146
-rw-r--r--sc/source/ui/vba/vbafoundfiles.hxx91
-rw-r--r--sc/source/ui/vba/vbaglobals.cxx313
-rw-r--r--sc/source/ui/vba/vbaglobals.hxx99
-rw-r--r--sc/source/ui/vba/vbahelper.cxx761
-rw-r--r--sc/source/ui/vba/vbahyperlink.cxx249
-rw-r--r--sc/source/ui/vba/vbahyperlink.hxx90
-rw-r--r--sc/source/ui/vba/vbahyperlinks.cxx296
-rw-r--r--sc/source/ui/vba/vbahyperlinks.hxx153
-rw-r--r--sc/source/ui/vba/vbainterior.cxx419
-rw-r--r--sc/source/ui/vba/vbainterior.hxx90
-rw-r--r--sc/source/ui/vba/vbamenu.cxx87
-rw-r--r--sc/source/ui/vba/vbamenu.hxx57
-rw-r--r--sc/source/ui/vba/vbamenubar.cxx69
-rw-r--r--sc/source/ui/vba/vbamenubar.hxx53
-rw-r--r--sc/source/ui/vba/vbamenubars.cxx140
-rw-r--r--sc/source/ui/vba/vbamenubars.hxx64
-rw-r--r--sc/source/ui/vba/vbamenuitem.cxx85
-rw-r--r--sc/source/ui/vba/vbamenuitem.hxx58
-rw-r--r--sc/source/ui/vba/vbamenuitems.cxx153
-rw-r--r--sc/source/ui/vba/vbamenuitems.hxx63
-rw-r--r--sc/source/ui/vba/vbamenus.cxx139
-rw-r--r--sc/source/ui/vba/vbamenus.hxx63
-rw-r--r--sc/source/ui/vba/vbaname.cxx234
-rw-r--r--sc/source/ui/vba/vbaname.hxx90
-rw-r--r--sc/source/ui/vba/vbanames.cxx262
-rw-r--r--sc/source/ui/vba/vbanames.hxx84
-rw-r--r--sc/source/ui/vba/vbaoleobject.cxx167
-rw-r--r--sc/source/ui/vba/vbaoleobject.hxx69
-rw-r--r--sc/source/ui/vba/vbaoleobjects.cxx188
-rw-r--r--sc/source/ui/vba/vbaoleobjects.hxx59
-rw-r--r--sc/source/ui/vba/vbaoutline.cxx68
-rw-r--r--sc/source/ui/vba/vbaoutline.hxx55
-rw-r--r--sc/source/ui/vba/vbapagebreak.cxx174
-rw-r--r--sc/source/ui/vba/vbapagebreak.hxx106
-rw-r--r--sc/source/ui/vba/vbapagebreaks.cxx321
-rw-r--r--sc/source/ui/vba/vbapagebreaks.hxx100
-rw-r--r--sc/source/ui/vba/vbapagesetup.cxx734
-rw-r--r--sc/source/ui/vba/vbapagesetup.hxx95
-rw-r--r--sc/source/ui/vba/vbapalette.cxx116
-rw-r--r--sc/source/ui/vba/vbapalette.hxx56
-rw-r--r--sc/source/ui/vba/vbapane.cxx209
-rw-r--r--sc/source/ui/vba/vbapane.hxx70
-rw-r--r--sc/source/ui/vba/vbapivotcache.cxx73
-rw-r--r--sc/source/ui/vba/vbapivotcache.hxx56
-rw-r--r--sc/source/ui/vba/vbapivottable.cxx66
-rw-r--r--sc/source/ui/vba/vbapivottable.hxx52
-rw-r--r--sc/source/ui/vba/vbapivottables.cxx97
-rw-r--r--sc/source/ui/vba/vbapivottables.hxx68
-rw-r--r--sc/source/ui/vba/vbapropvalue.cxx48
-rw-r--r--sc/source/ui/vba/vbapropvalue.hxx60
-rw-r--r--sc/source/ui/vba/vbaquerytable.cxx90
-rw-r--r--sc/source/ui/vba/vbaquerytable.hxx62
-rw-r--r--sc/source/ui/vba/vbarange.cxx6239
-rw-r--r--sc/source/ui/vba/vbarange.hxx312
-rw-r--r--sc/source/ui/vba/vbaseriescollection.cxx82
-rw-r--r--sc/source/ui/vba/vbaseriescollection.hxx57
-rw-r--r--sc/source/ui/vba/vbasheetobject.cxx520
-rw-r--r--sc/source/ui/vba/vbasheetobject.hxx223
-rw-r--r--sc/source/ui/vba/vbasheetobjects.cxx537
-rw-r--r--sc/source/ui/vba/vbasheetobjects.hxx116
-rw-r--r--sc/source/ui/vba/vbastyle.cxx189
-rw-r--r--sc/source/ui/vba/vbastyle.hxx99
-rw-r--r--sc/source/ui/vba/vbastyles.cxx185
-rw-r--r--sc/source/ui/vba/vbastyles.hxx60
-rw-r--r--sc/source/ui/vba/vbatextboxshape.cxx69
-rw-r--r--sc/source/ui/vba/vbatextboxshape.hxx53
-rw-r--r--sc/source/ui/vba/vbatextframe.cxx81
-rw-r--r--sc/source/ui/vba/vbatextframe.hxx52
-rw-r--r--sc/source/ui/vba/vbatitle.hxx166
-rw-r--r--sc/source/ui/vba/vbavalidation.cxx346
-rw-r--r--sc/source/ui/vba/vbavalidation.hxx74
-rw-r--r--sc/source/ui/vba/vbawindow.cxx861
-rw-r--r--sc/source/ui/vba/vbawindow.hxx126
-rw-r--r--sc/source/ui/vba/vbawindows.cxx262
-rw-r--r--sc/source/ui/vba/vbawindows.hxx66
-rw-r--r--sc/source/ui/vba/vbaworkbook.cxx435
-rw-r--r--sc/source/ui/vba/vbaworkbook.hxx90
-rw-r--r--sc/source/ui/vba/vbaworkbooks.cxx370
-rw-r--r--sc/source/ui/vba/vbaworkbooks.hxx74
-rw-r--r--sc/source/ui/vba/vbaworksheet.cxx1112
-rw-r--r--sc/source/ui/vba/vbaworksheet.hxx177
-rw-r--r--sc/source/ui/vba/vbaworksheets.cxx504
-rw-r--r--sc/source/ui/vba/vbaworksheets.hxx86
-rw-r--r--sc/source/ui/vba/vbawsfunction.cxx322
-rw-r--r--sc/source/ui/vba/vbawsfunction.hxx59
-rw-r--r--sc/source/ui/view/auditsh.cxx157
-rw-r--r--sc/source/ui/view/cellmergeoption.cxx87
-rw-r--r--sc/source/ui/view/cellsh.cxx1007
-rw-r--r--sc/source/ui/view/cellsh1.cxx2198
-rw-r--r--sc/source/ui/view/cellsh2.cxx1392
-rw-r--r--sc/source/ui/view/cellsh3.cxx932
-rw-r--r--sc/source/ui/view/cellsh4.cxx456
-rw-r--r--sc/source/ui/view/colrowba.cxx419
-rw-r--r--sc/source/ui/view/dbfunc.cxx515
-rw-r--r--sc/source/ui/view/dbfunc2.cxx79
-rw-r--r--sc/source/ui/view/dbfunc3.cxx2374
-rw-r--r--sc/source/ui/view/dbfunc4.cxx104
-rw-r--r--sc/source/ui/view/drawattr.cxx84
-rw-r--r--sc/source/ui/view/drawutil.cxx118
-rw-r--r--sc/source/ui/view/drawvie2.cxx64
-rw-r--r--sc/source/ui/view/drawvie3.cxx184
-rw-r--r--sc/source/ui/view/drawvie4.cxx358
-rw-r--r--sc/source/ui/view/drawview.cxx810
-rw-r--r--sc/source/ui/view/editsh.cxx1202
-rw-r--r--sc/source/ui/view/formatsh.cxx2274
-rw-r--r--sc/source/ui/view/galwrap.cxx81
-rw-r--r--sc/source/ui/view/gridmerg.cxx176
-rw-r--r--sc/source/ui/view/gridwin.cxx5852
-rw-r--r--sc/source/ui/view/gridwin2.cxx1075
-rw-r--r--sc/source/ui/view/gridwin3.cxx445
-rw-r--r--sc/source/ui/view/gridwin4.cxx1939
-rw-r--r--sc/source/ui/view/gridwin5.cxx440
-rw-r--r--sc/source/ui/view/hdrcont.cxx1039
-rw-r--r--sc/source/ui/view/hintwin.cxx111
-rw-r--r--sc/source/ui/view/imapwrap.cxx78
-rw-r--r--sc/source/ui/view/invmerge.cxx194
-rw-r--r--sc/source/ui/view/makefile.mk174
-rw-r--r--sc/source/ui/view/notemark.cxx202
-rw-r--r--sc/source/ui/view/olinewin.cxx1047
-rw-r--r--sc/source/ui/view/olkact.cxx284
-rw-r--r--sc/source/ui/view/output.cxx2443
-rw-r--r--sc/source/ui/view/output2.cxx3887
-rw-r--r--sc/source/ui/view/output3.cxx278
-rw-r--r--sc/source/ui/view/overlayobject.cxx107
-rw-r--r--sc/source/ui/view/pfuncache.cxx200
-rw-r--r--sc/source/ui/view/pgbrksh.cxx87
-rw-r--r--sc/source/ui/view/pivotsh.cxx202
-rw-r--r--sc/source/ui/view/preview.cxx1616
-rw-r--r--sc/source/ui/view/prevloc.cxx756
-rw-r--r--sc/source/ui/view/prevwsh.cxx1236
-rw-r--r--sc/source/ui/view/prevwsh2.cxx359
-rw-r--r--sc/source/ui/view/printfun.cxx3204
-rw-r--r--sc/source/ui/view/reffact.cxx437
-rw-r--r--sc/source/ui/view/scextopt.cxx227
-rw-r--r--sc/source/ui/view/select.cxx871
-rw-r--r--sc/source/ui/view/selectionstate.cxx91
-rw-r--r--sc/source/ui/view/spelldialog.cxx281
-rw-r--r--sc/source/ui/view/spelleng.cxx460
-rw-r--r--sc/source/ui/view/tabcont.cxx665
-rw-r--r--sc/source/ui/view/tabpopsh.cxx75
-rw-r--r--sc/source/ui/view/tabsplit.cxx107
-rw-r--r--sc/source/ui/view/tabview.cxx2457
-rw-r--r--sc/source/ui/view/tabview2.cxx1434
-rw-r--r--sc/source/ui/view/tabview3.cxx2641
-rw-r--r--sc/source/ui/view/tabview4.cxx567
-rw-r--r--sc/source/ui/view/tabview5.cxx690
-rw-r--r--sc/source/ui/view/tabvwsh.cxx120
-rw-r--r--sc/source/ui/view/tabvwsh2.cxx482
-rw-r--r--sc/source/ui/view/tabvwsh3.cxx1237
-rw-r--r--sc/source/ui/view/tabvwsh4.cxx2028
-rw-r--r--sc/source/ui/view/tabvwsh5.cxx430
-rw-r--r--sc/source/ui/view/tabvwsh8.cxx106
-rw-r--r--sc/source/ui/view/tabvwsh9.cxx297
-rw-r--r--sc/source/ui/view/tabvwsha.cxx894
-rw-r--r--sc/source/ui/view/tabvwshb.cxx502
-rw-r--r--sc/source/ui/view/tabvwshc.cxx335
-rw-r--r--sc/source/ui/view/tabvwshd.cxx102
-rw-r--r--sc/source/ui/view/tabvwshe.cxx343
-rw-r--r--sc/source/ui/view/tabvwshf.cxx954
-rw-r--r--sc/source/ui/view/tabvwshg.cxx142
-rw-r--r--sc/source/ui/view/tabvwshh.cxx295
-rw-r--r--sc/source/ui/view/viewdata.cxx3118
-rw-r--r--sc/source/ui/view/viewfun2.cxx3159
-rw-r--r--sc/source/ui/view/viewfun3.cxx1947
-rw-r--r--sc/source/ui/view/viewfun4.cxx830
-rw-r--r--sc/source/ui/view/viewfun5.cxx732
-rw-r--r--sc/source/ui/view/viewfun6.cxx363
-rw-r--r--sc/source/ui/view/viewfun7.cxx456
-rw-r--r--sc/source/ui/view/viewfunc.cxx3035
-rw-r--r--sc/source/ui/view/viewutil.cxx642
-rw-r--r--sc/source/ui/view/waitoff.cxx72
1016 files changed, 354078 insertions, 0 deletions
diff --git a/sc/source/ui/Accessibility/AccessibilityHints.cxx b/sc/source/ui/Accessibility/AccessibilityHints.cxx
new file mode 100644
index 000000000000..349cca39a58d
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibilityHints.cxx
@@ -0,0 +1,115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "AccessibilityHints.hxx"
+
+using namespace ::com::sun::star;
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScAccWinFocusLostHint, SfxHint);
+
+// -----------------------------------------------------------------------
+// ScAccWinFocusLostHint - the current window lost its focus (to another application, view or document)
+// -----------------------------------------------------------------------
+
+ScAccWinFocusLostHint::ScAccWinFocusLostHint(
+ const uno::Reference< uno::XInterface >& xOld )
+ :
+ xOldAccessible(xOld)
+{
+}
+
+ScAccWinFocusLostHint::~ScAccWinFocusLostHint()
+{
+}
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScAccWinFocusGotHint, SfxHint);
+
+// -----------------------------------------------------------------------
+// ScAccWinFocusGotHint - the window got the focus (from another application, view or document)
+// -----------------------------------------------------------------------
+
+ScAccWinFocusGotHint::ScAccWinFocusGotHint(
+ const uno::Reference< uno::XInterface >& xNew )
+ :
+ xNewAccessible(xNew)
+{
+}
+
+ScAccWinFocusGotHint::~ScAccWinFocusGotHint()
+{
+}
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScAccGridWinFocusLostHint, SfxHint);
+
+// -----------------------------------------------------------------------
+// ScAccGridWinFocusLostHint - the current grid window lost its focus (to another application, view or document)
+// -----------------------------------------------------------------------
+
+ScAccGridWinFocusLostHint::ScAccGridWinFocusLostHint(ScSplitPos eOld,
+ const uno::Reference< uno::XInterface >& xOld )
+ :
+ ScAccWinFocusLostHint(xOld),
+ eOldGridWin(eOld)
+{
+}
+
+ScAccGridWinFocusLostHint::~ScAccGridWinFocusLostHint()
+{
+}
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScAccGridWinFocusGotHint, SfxHint);
+
+// -----------------------------------------------------------------------
+// ScAccGridWinFocusGotHint - the grid window got the focus (from another application, view or document)
+// -----------------------------------------------------------------------
+
+ScAccGridWinFocusGotHint::ScAccGridWinFocusGotHint(ScSplitPos eNew,
+ const uno::Reference< uno::XInterface >& xNew )
+ :
+ ScAccWinFocusGotHint(xNew),
+ eNewGridWin(eNew)
+{
+}
+
+ScAccGridWinFocusGotHint::~ScAccGridWinFocusGotHint()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx
new file mode 100644
index 000000000000..79f9957aa9c2
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -0,0 +1,456 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleCell.hxx"
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include "AccessibleText.hxx"
+#include "AccessibleDocument.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "attrib.hxx"
+#include "miscuno.hxx"
+#include "editsrc.hxx"
+#include "dociter.hxx"
+#include "cell.hxx"
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/accessibility/XAccessibleTable.hpp>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <editeng/brshitem.hxx>
+#include <comphelper/sequence.hxx>
+#include <float.h>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessibleCell::ScAccessibleCell(
+ const uno::Reference<XAccessible>& rxParent,
+ ScTabViewShell* pViewShell,
+ ScAddress& rCellAddress,
+ sal_Int32 nIndex,
+ ScSplitPos eSplitPos,
+ ScAccessibleDocument* pAccDoc)
+ :
+ ScAccessibleCellBase(rxParent, GetDocument(pViewShell), rCellAddress, nIndex),
+ ::accessibility::AccessibleStaticTextBase(CreateEditSource(pViewShell, rCellAddress, eSplitPos)),
+ mpViewShell(pViewShell),
+ mpAccDoc(pAccDoc),
+ meSplitPos(eSplitPos)
+{
+ if (pViewShell)
+ pViewShell->AddAccessibilityObject(*this);
+}
+
+ScAccessibleCell::~ScAccessibleCell()
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void ScAccessibleCell::Init()
+{
+ ScAccessibleCellBase::Init();
+
+ SetEventSource(this);
+}
+
+void SAL_CALL ScAccessibleCell::disposing()
+{
+ SolarMutexGuard aGuard;
+ // #100593# dispose in AccessibleStaticTextBase
+ Dispose();
+
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+ mpAccDoc = NULL;
+
+ ScAccessibleCellBase::disposing();
+}
+
+ //===== XInterface =====================================================
+
+IMPLEMENT_FORWARD_XINTERFACE2( ScAccessibleCell, ScAccessibleCellBase, AccessibleStaticTextBase )
+
+ //===== XTypeProvider ===================================================
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScAccessibleCell, ScAccessibleCellBase, AccessibleStaticTextBase )
+
+ //===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleCell::getAccessibleAtPoint(
+ const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ return AccessibleStaticTextBase::getAccessibleAtPoint(rPoint);
+}
+
+void SAL_CALL ScAccessibleCell::grabFocus( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is() && mpViewShell)
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ {
+ xAccessibleComponent->grabFocus();
+ mpViewShell->SetCursor(maCellAddress.Col(), maCellAddress.Row());
+ }
+ }
+}
+
+Rectangle ScAccessibleCell::GetBoundingBoxOnScreen(void) const
+ throw (uno::RuntimeException)
+{
+ Rectangle aCellRect(GetBoundingBox());
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
+ aCellRect.setX(aCellRect.getX() + aRect.getX());
+ aCellRect.setY(aCellRect.getY() + aRect.getY());
+ }
+ }
+ return aCellRect;
+}
+
+Rectangle ScAccessibleCell::GetBoundingBox(void) const
+ throw (uno::RuntimeException)
+{
+ Rectangle aCellRect;
+ if (mpViewShell)
+ {
+ long nSizeX, nSizeY;
+ mpViewShell->GetViewData()->GetMergeSizePixel(
+ maCellAddress.Col(), maCellAddress.Row(), nSizeX, nSizeY);
+ aCellRect.SetSize(Size(nSizeX, nSizeY));
+ aCellRect.SetPos(mpViewShell->GetViewData()->GetScrPos(maCellAddress.Col(), maCellAddress.Row(), meSplitPos, TRUE));
+
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ {
+ Rectangle aRect(pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow()));
+ aRect.Move(-aRect.Left(), -aRect.Top());
+ aCellRect = aRect.Intersection(aCellRect);
+ }
+
+ /* #i19430# Gnopernicus reads text partly if it sticks out of the cell
+ boundaries. This leads to wrong results in cases where the cell
+ text is rotated, because rotation is not taken into account when
+ calculating the visible part of the text. In these cases we will
+ simply expand the cell size to the width of the unrotated text. */
+ if (mpDoc)
+ {
+ const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
+ mpDoc->GetAttr( maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_ROTATE_VALUE ) );
+ if( pItem && (pItem->GetValue() != 0) )
+ {
+ Rectangle aParaRect = GetParagraphBoundingBox();
+ if( !aParaRect.IsEmpty() && (aCellRect.GetWidth() < aParaRect.GetWidth()) )
+ aCellRect.SetSize( Size( aParaRect.GetWidth(), aCellRect.GetHeight() ) );
+ }
+ }
+ }
+ if (aCellRect.IsEmpty())
+ aCellRect.SetPos(Point(-1, -1));
+ return aCellRect;
+}
+
+ //===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL
+ ScAccessibleCell::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ return AccessibleStaticTextBase::getAccessibleChildCount();
+}
+
+uno::Reference< XAccessible > SAL_CALL
+ ScAccessibleCell::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException,
+ lang::IndexOutOfBoundsException)
+{
+ return AccessibleStaticTextBase::getAccessibleChild(nIndex);
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessibleCell::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ if (IsEditable(xParentStates))
+ {
+ pStateSet->AddState(AccessibleStateType::EDITABLE);
+ pStateSet->AddState(AccessibleStateType::RESIZABLE);
+ }
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::MULTI_LINE);
+ pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE);
+ if (IsOpaque(xParentStates))
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ pStateSet->AddState(AccessibleStateType::SELECTABLE);
+ if (IsSelected())
+ pStateSet->AddState(AccessibleStateType::SELECTED);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ pStateSet->AddState(AccessibleStateType::TRANSIENT);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+uno::Reference<XAccessibleRelationSet> SAL_CALL
+ ScAccessibleCell::getAccessibleRelationSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ utl::AccessibleRelationSetHelper* pRelationSet = NULL;
+ if (mpAccDoc)
+ pRelationSet = mpAccDoc->GetRelationSet(&maCellAddress);
+ if (!pRelationSet)
+ pRelationSet = new utl::AccessibleRelationSetHelper();
+ FillDependends(pRelationSet);
+ FillPrecedents(pRelationSet);
+ return pRelationSet;
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleCell::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleCell"));
+}
+
+uno::Sequence< ::rtl::OUString> SAL_CALL
+ ScAccessibleCell::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.AccessibleCell"));
+
+ return aSequence;
+}
+
+ //==== internal =========================================================
+
+sal_Bool ScAccessibleCell::IsDefunc(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpDoc == NULL) || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+sal_Bool ScAccessibleCell::IsEditable(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ sal_Bool bEditable(sal_True);
+ if (rxParentStates.is() && !rxParentStates->contains(AccessibleStateType::EDITABLE) &&
+ mpDoc)
+ {
+ // here I have to test whether the protection of the table should influence this cell.
+ const ScProtectionAttr* pItem = (const ScProtectionAttr*)mpDoc->GetAttr(
+ maCellAddress.Col(), maCellAddress.Row(),
+ maCellAddress.Tab(), ATTR_PROTECTION);
+ if (pItem)
+ bEditable = !pItem->GetProtection();
+ }
+ return bEditable;
+}
+
+sal_Bool ScAccessibleCell::IsOpaque(
+ const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
+{
+ // test whether there is a background color
+ sal_Bool bOpaque(sal_True);
+ if (mpDoc)
+ {
+ const SvxBrushItem* pItem = (const SvxBrushItem*)mpDoc->GetAttr(
+ maCellAddress.Col(), maCellAddress.Row(),
+ maCellAddress.Tab(), ATTR_BACKGROUND);
+ if (pItem)
+ bOpaque = pItem->GetColor() != COL_TRANSPARENT;
+ }
+ return bOpaque;
+}
+
+sal_Bool ScAccessibleCell::IsSelected()
+{
+ sal_Bool bResult(sal_False);
+ if (mpViewShell && mpViewShell->GetViewData())
+ {
+ const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
+ bResult = rMarkdata.IsCellMarked(maCellAddress.Col(), maCellAddress.Row());
+ }
+ return bResult;
+}
+
+ScDocument* ScAccessibleCell::GetDocument(ScTabViewShell* pViewShell)
+{
+ ScDocument* pDoc = NULL;
+ if (pViewShell && pViewShell->GetViewData())
+ pDoc = pViewShell->GetViewData()->GetDocument();
+ return pDoc;
+}
+
+::std::auto_ptr< SvxEditSource > ScAccessibleCell::CreateEditSource(ScTabViewShell* pViewShell, ScAddress aCell, ScSplitPos eSplitPos)
+{
+ ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData
+ ( new ScAccessibleCellTextData( pViewShell, aCell, eSplitPos, this ) );
+ ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleCellTextData));
+
+ return pEditSource;
+}
+
+void ScAccessibleCell::FillDependends(utl::AccessibleRelationSetHelper* pRelationSet)
+{
+ if (mpDoc)
+ {
+ ScCellIterator aCellIter( mpDoc, 0,0, maCellAddress.Tab(), MAXCOL,MAXROW, maCellAddress.Tab() );
+ ScBaseCell* pCell = aCellIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ sal_Bool bFound(sal_False);
+ ScDetectiveRefIter aIter( (ScFormulaCell*) pCell );
+ ScRange aRef;
+ while ( !bFound && aIter.GetNextRef( aRef ) )
+ {
+ if (aRef.In(maCellAddress))
+ bFound = sal_True;
+ }
+ if (bFound)
+ AddRelation(ScAddress(aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab()), AccessibleRelationType::CONTROLLER_FOR, pRelationSet);
+ }
+ pCell = aCellIter.GetNext();
+ }
+ }
+}
+
+void ScAccessibleCell::FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet)
+{
+ if (mpDoc)
+ {
+ ScBaseCell* pBaseCell = mpDoc->GetCell(maCellAddress);
+ if (pBaseCell && (pBaseCell->GetCellType() == CELLTYPE_FORMULA))
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*) pBaseCell;
+
+ ScDetectiveRefIter aIter( pFCell );
+ ScRange aRef;
+ while ( aIter.GetNextRef( aRef ) )
+ {
+ AddRelation( aRef, AccessibleRelationType::CONTROLLED_BY, pRelationSet);
+ }
+ }
+ }
+}
+
+void ScAccessibleCell::AddRelation(const ScAddress& rCell,
+ const sal_uInt16 aRelationType,
+ utl::AccessibleRelationSetHelper* pRelationSet)
+{
+ AddRelation(ScRange(rCell, rCell), aRelationType, pRelationSet);
+}
+
+void ScAccessibleCell::AddRelation(const ScRange& rRange,
+ const sal_uInt16 aRelationType,
+ utl::AccessibleRelationSetHelper* pRelationSet)
+{
+ uno::Reference < XAccessibleTable > xTable ( getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY );
+ if (xTable.is())
+ {
+ sal_uInt32 nCount(static_cast<sal_uInt32>(rRange.aEnd.Col() -
+ rRange.aStart.Col() + 1) * (rRange.aEnd.Row() -
+ rRange.aStart.Row() + 1));
+ uno::Sequence < uno::Reference < uno::XInterface > > aTargetSet( nCount );
+ uno::Reference < uno::XInterface >* pTargetSet = aTargetSet.getArray();
+ if (pTargetSet)
+ {
+ sal_uInt32 nPos(0);
+ for (sal_uInt32 nRow = rRange.aStart.Row(); nRow <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Row()); ++nRow)
+ {
+ for (sal_uInt32 nCol = rRange.aStart.Col(); nCol <= sal::static_int_cast<sal_uInt32>(rRange.aEnd.Col()); ++nCol)
+ {
+ pTargetSet[nPos] = xTable->getAccessibleCellAt(nRow, nCol);
+ ++nPos;
+ }
+ }
+ DBG_ASSERT(nCount == nPos, "something wents wrong");
+ }
+ AccessibleRelation aRelation;
+ aRelation.RelationType = aRelationType;
+ aRelation.TargetSet = aTargetSet;
+ pRelationSet->AddRelation(aRelation);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleCellBase.cxx b/sc/source/ui/Accessibility/AccessibleCellBase.cxx
new file mode 100644
index 000000000000..1ba7938a6a9b
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleCellBase.cxx
@@ -0,0 +1,342 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleCellBase.hxx"
+#include "attrib.hxx"
+#include "scitems.hxx"
+#include "miscuno.hxx"
+#include "document.hxx"
+#include "docfunc.hxx"
+#include "cell.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "unonames.hxx"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <tools/debug.hxx>
+#include <editeng/brshitem.hxx>
+#include <rtl/uuid.h>
+#include <comphelper/sequence.hxx>
+#include <sfx2/objsh.hxx>
+#include <vcl/svapp.hxx>
+
+#include <float.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessibleCellBase::ScAccessibleCellBase(
+ const uno::Reference<XAccessible>& rxParent,
+ ScDocument* pDoc,
+ const ScAddress& rCellAddress,
+ sal_Int32 nIndex)
+ :
+ ScAccessibleContextBase(rxParent, AccessibleRole::TABLE_CELL),
+ maCellAddress(rCellAddress),
+ mpDoc(pDoc),
+ mnIndex(nIndex)
+{
+}
+
+ScAccessibleCellBase::~ScAccessibleCellBase()
+{
+}
+
+ //===== XAccessibleComponent ============================================
+
+sal_Bool SAL_CALL ScAccessibleCellBase::isVisible( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ // test whether the cell is hidden (column/row - hidden/filtered)
+ sal_Bool bVisible(sal_True);
+ if (mpDoc)
+ {
+ bool bColHidden = mpDoc->ColHidden(maCellAddress.Col(), maCellAddress.Tab());
+ bool bRowHidden = mpDoc->RowHidden(maCellAddress.Row(), maCellAddress.Tab());
+ bool bColFiltered = mpDoc->ColFiltered(maCellAddress.Col(), maCellAddress.Tab());
+ bool bRowFiltered = mpDoc->RowFiltered(maCellAddress.Row(), maCellAddress.Tab());
+
+ if (bColHidden || bColFiltered || bRowHidden || bRowFiltered)
+ bVisible = sal_False;
+ }
+ return bVisible;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCellBase::getForeground()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nColor(0);
+ if (mpDoc)
+ {
+ SfxObjectShell* pObjSh = mpDoc->GetDocumentShell();
+ if ( pObjSh )
+ {
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( pObjSh->GetModel(), uno::UNO_QUERY );
+ if ( xSpreadDoc.is() )
+ {
+ uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
+ uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
+ if ( xIndex.is() )
+ {
+ uno::Any aTable = xIndex->getByIndex(maCellAddress.Tab());
+ uno::Reference<sheet::XSpreadsheet> xTable;
+ if (aTable>>=xTable)
+ {
+ uno::Reference<table::XCell> xCell = xTable->getCellByPosition(maCellAddress.Col(), maCellAddress.Row());
+ if (xCell.is())
+ {
+ uno::Reference<beans::XPropertySet> xCellProps(xCell, uno::UNO_QUERY);
+ if (xCellProps.is())
+ {
+ uno::Any aAny = xCellProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CCOLOR)));
+ aAny >>= nColor;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return nColor;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCellBase::getBackground()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nColor(0);
+
+ if (mpDoc)
+ {
+ SfxObjectShell* pObjSh = mpDoc->GetDocumentShell();
+ if ( pObjSh )
+ {
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( pObjSh->GetModel(), uno::UNO_QUERY );
+ if ( xSpreadDoc.is() )
+ {
+ uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
+ uno::Reference<container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
+ if ( xIndex.is() )
+ {
+ uno::Any aTable = xIndex->getByIndex(maCellAddress.Tab());
+ uno::Reference<sheet::XSpreadsheet> xTable;
+ if (aTable>>=xTable)
+ {
+ uno::Reference<table::XCell> xCell = xTable->getCellByPosition(maCellAddress.Col(), maCellAddress.Row());
+ if (xCell.is())
+ {
+ uno::Reference<beans::XPropertySet> xCellProps(xCell, uno::UNO_QUERY);
+ if (xCellProps.is())
+ {
+ uno::Any aAny = xCellProps->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_CELLBACK)));
+ aAny >>= nColor;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nColor;
+}
+
+ //===== XInterface =====================================================
+
+uno::Any SAL_CALL ScAccessibleCellBase::queryInterface( uno::Type const & rType )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny (ScAccessibleCellBaseImpl::queryInterface(rType));
+ return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessibleCellBase::acquire()
+ throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessibleCellBase::release()
+ throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+ //===== XAccessibleContext ==============================================
+
+sal_Int32
+ ScAccessibleCellBase::getAccessibleIndexInParent(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return mnIndex;
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleCellBase::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ rtl::OUString sDescription = String(ScResId(STR_ACC_CELL_DESCR));
+
+ return sDescription;
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleCellBase::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ String sName( ScResId(STR_ACC_CELL_NAME) );
+ String sAddress;
+ // Document not needed, because only the cell address, but not the tablename is needed
+ // always us OOO notation
+ maCellAddress.Format( sAddress, SCA_VALID, NULL );
+ sName.SearchAndReplaceAscii("%1", sAddress);
+ /* #i65103# ZoomText merges cell address and contents, e.g. if value 2 is
+ contained in cell A1, ZT reads "cell A twelve" instead of "cell A1 - 2".
+ Simple solution: Append a space character to the cell address. */
+ sName.Append( ' ' );
+ return rtl::OUString(sName);
+}
+
+ //===== XAccessibleValue ================================================
+
+uno::Any SAL_CALL
+ ScAccessibleCellBase::getCurrentValue( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Any aAny;
+ if (mpDoc)
+ aAny <<= mpDoc->GetValue(maCellAddress);
+
+ return aAny;
+}
+
+sal_Bool SAL_CALL
+ ScAccessibleCellBase::setCurrentValue( const uno::Any& aNumber )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ double fValue = 0;
+ sal_Bool bResult(sal_False);
+ if((aNumber >>= fValue) && mpDoc && mpDoc->GetDocumentShell())
+ {
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ if (IsEditable(xParentStates))
+ {
+ ScDocShell* pDocShell = (ScDocShell*) mpDoc->GetDocumentShell();
+ ScDocFunc aFunc(*pDocShell);
+ bResult = aFunc.PutCell( maCellAddress, new ScValueCell(fValue), TRUE );
+ }
+ }
+ return bResult;
+}
+
+uno::Any SAL_CALL
+ ScAccessibleCellBase::getMaximumValue( )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny;
+ aAny <<= DBL_MAX;
+
+ return aAny;
+}
+
+uno::Any SAL_CALL
+ ScAccessibleCellBase::getMinimumValue( )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny;
+ aAny <<= -DBL_MAX;
+
+ return aAny;
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleCellBase::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleCellBase"));
+}
+
+ //===== XTypeProvider ===================================================
+
+uno::Sequence< uno::Type > SAL_CALL ScAccessibleCellBase::getTypes()
+ throw (uno::RuntimeException)
+{
+ return comphelper::concatSequences(ScAccessibleCellBaseImpl::getTypes(), ScAccessibleContextBase::getTypes());
+}
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleCellBase::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+sal_Bool ScAccessibleCellBase::IsEditable(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ sal_Bool bEditable(sal_False);
+ if (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::EDITABLE))
+ bEditable = sal_True;
+ return bEditable;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
new file mode 100644
index 000000000000..da2075947bc3
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
@@ -0,0 +1,626 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleContextBase.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <tools/gen.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <svl/smplhint.hxx>
+#include <comphelper/sequence.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <vcl/unohelp.hxx>
+#include <tools/color.hxx>
+#include <comphelper/accessibleeventnotifier.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+DBG_NAME(ScAccessibleContextBase)
+
+ScAccessibleContextBase::ScAccessibleContextBase(
+ const uno::Reference<XAccessible>& rxParent,
+ const sal_Int16 aRole)
+ :
+ ScAccessibleContextBaseWeakImpl(m_aMutex),
+ mxParent(rxParent),
+ mnClientId(0),
+ maRole(aRole)
+{
+ DBG_CTOR(ScAccessibleContextBase, NULL);
+}
+
+
+ScAccessibleContextBase::~ScAccessibleContextBase(void)
+{
+ DBG_DTOR(ScAccessibleContextBase, NULL);
+
+ if (!IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void ScAccessibleContextBase::Init()
+{
+ // hold reference to make sure that the destructor is not called
+ uno::Reference< XAccessibleContext > xOwnContext(this);
+
+ if (mxParent.is())
+ {
+ uno::Reference< XAccessibleEventBroadcaster > xBroadcaster (mxParent->getAccessibleContext(), uno::UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->addEventListener(this);
+ }
+ msName = createAccessibleName();
+ msDescription = createAccessibleDescription();
+}
+
+void SAL_CALL ScAccessibleContextBase::disposing()
+{
+ SolarMutexGuard aGuard;
+// CommitDefunc(); not necessary and should not be send, because it cost a lot of time
+
+ // hold reference to make sure that the destructor is not called
+ uno::Reference< XAccessibleContext > xOwnContext(this);
+
+ if ( mnClientId )
+ {
+ sal_Int32 nTemClientId(mnClientId);
+ mnClientId = 0;
+ comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nTemClientId, *this );
+ }
+
+ if (mxParent.is())
+ {
+ uno::Reference< XAccessibleEventBroadcaster > xBroadcaster (mxParent->getAccessibleContext(), uno::UNO_QUERY);
+ if (xBroadcaster.is())
+ xBroadcaster->removeEventListener(this);
+ mxParent = NULL;
+ }
+
+ ScAccessibleContextBaseWeakImpl::disposing();
+}
+
+//===== XInterface =====================================================
+
+uno::Any SAL_CALL ScAccessibleContextBase::queryInterface( uno::Type const & rType )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny (ScAccessibleContextBaseWeakImpl::queryInterface(rType));
+ return aAny.hasValue() ? aAny : ScAccessibleContextBaseImplEvent::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessibleContextBase::acquire()
+ throw ()
+{
+ ScAccessibleContextBaseWeakImpl::acquire();
+}
+
+void SAL_CALL ScAccessibleContextBase::release()
+ throw ()
+{
+ ScAccessibleContextBaseWeakImpl::release();
+}
+
+//===== SfxListener =====================================================
+
+void ScAccessibleContextBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ) )
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ if (rRef.GetId() == SFX_HINT_DYING)
+ {
+ // it seems the Broadcaster is dying, since the view is dying
+ dispose();
+ }
+ }
+}
+
+//===== XAccessible =========================================================
+
+uno::Reference< XAccessibleContext> SAL_CALL
+ ScAccessibleContextBase::getAccessibleContext(void)
+ throw (uno::RuntimeException)
+{
+ return this;
+}
+
+//===== XAccessibleComponent ================================================
+
+sal_Bool SAL_CALL ScAccessibleContextBase::containsPoint(const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return Rectangle (Point(), GetBoundingBox().GetSize()).IsInside(VCLPoint(rPoint));
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleContextBase::getAccessibleAtPoint(
+ const awt::Point& /* rPoint */ )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+ return uno::Reference<XAccessible>();
+}
+
+awt::Rectangle SAL_CALL ScAccessibleContextBase::getBounds( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return AWTRectangle(GetBoundingBox());
+}
+
+awt::Point SAL_CALL ScAccessibleContextBase::getLocation( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return AWTPoint(GetBoundingBox().TopLeft());
+}
+
+awt::Point SAL_CALL ScAccessibleContextBase::getLocationOnScreen( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return AWTPoint(GetBoundingBoxOnScreen().TopLeft());
+}
+
+awt::Size SAL_CALL ScAccessibleContextBase::getSize( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return AWTSize(GetBoundingBox().GetSize());
+}
+
+sal_Bool SAL_CALL ScAccessibleContextBase::isShowing( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Bool bShowing(sal_False);
+ if (mxParent.is())
+ {
+ uno::Reference<XAccessibleComponent> xParentComponent (mxParent->getAccessibleContext(), uno::UNO_QUERY);
+ if (xParentComponent.is())
+ {
+ Rectangle aParentBounds(VCLRectangle(xParentComponent->getBounds()));
+ Rectangle aBounds(VCLRectangle(getBounds()));
+ bShowing = aBounds.IsOver(aParentBounds);
+ }
+ }
+ return bShowing;
+}
+
+sal_Bool SAL_CALL ScAccessibleContextBase::isVisible( )
+ throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+
+void SAL_CALL ScAccessibleContextBase::grabFocus( )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+sal_Int32 SAL_CALL ScAccessibleContextBase::getForeground( )
+ throw (uno::RuntimeException)
+{
+ return COL_BLACK;
+}
+
+sal_Int32 SAL_CALL ScAccessibleContextBase::getBackground( )
+ throw (uno::RuntimeException)
+{
+ return COL_WHITE;
+}
+
+//===== XAccessibleContext ==================================================
+
+sal_Int32 SAL_CALL
+ ScAccessibleContextBase::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("should be implemented in the abrevated class");
+ return 0;
+}
+
+uno::Reference<XAccessible> SAL_CALL
+ ScAccessibleContextBase::getAccessibleChild(sal_Int32 /* nIndex */)
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ DBG_ERROR("should be implemented in the abrevated class");
+ return uno::Reference<XAccessible>();
+}
+
+uno::Reference<XAccessible> SAL_CALL
+ ScAccessibleContextBase::getAccessibleParent(void)
+ throw (uno::RuntimeException)
+{
+ return mxParent;
+}
+
+sal_Int32 SAL_CALL
+ ScAccessibleContextBase::getAccessibleIndexInParent(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ // Use a simple but slow solution for now. Optimize later.
+ // Return -1 to indicate that this object's parent does not know about the
+ // object.
+ sal_Int32 nIndex(-1);
+
+ // Iterate over all the parent's children and search for this object.
+ if (mxParent.is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext (
+ mxParent->getAccessibleContext());
+ if (xParentContext.is())
+ {
+ sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
+ for (sal_Int32 i=0; i<nChildCount; ++i)
+ {
+ uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i));
+ if (xChild.is())
+ {
+ if (xChild.get() == this)
+ nIndex = i;
+ }
+ }
+ }
+ }
+
+ return nIndex;
+}
+
+sal_Int16 SAL_CALL
+ ScAccessibleContextBase::getAccessibleRole(void)
+ throw (uno::RuntimeException)
+{
+ return maRole;
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleContextBase::getAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!msDescription.getLength())
+ {
+ OUString sDescription(createAccessibleDescription());
+// DBG_ASSERT(sDescription.getLength(), "We should give always a descripition.");
+
+ if (msDescription != sDescription)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.OldValue <<= msDescription;
+ aEvent.NewValue <<= sDescription;
+
+ msDescription = sDescription;
+
+ CommitChange(aEvent);
+ }
+ }
+ return msDescription;
+}
+
+OUString SAL_CALL
+ ScAccessibleContextBase::getAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!msName.getLength())
+ {
+ OUString sName(createAccessibleName());
+ DBG_ASSERT(sName.getLength(), "We should give always a name.");
+
+ if (msName != sName)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::NAME_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.OldValue <<= msName;
+ aEvent.NewValue <<= sName;
+
+ msName = sName;
+
+ CommitChange(aEvent);
+ }
+ }
+ return msName;
+}
+
+uno::Reference<XAccessibleRelationSet> SAL_CALL
+ ScAccessibleContextBase::getAccessibleRelationSet(void)
+ throw (uno::RuntimeException)
+{
+ return new utl::AccessibleRelationSetHelper();
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessibleContextBase::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ return uno::Reference<XAccessibleStateSet>();
+}
+
+lang::Locale SAL_CALL
+ ScAccessibleContextBase::getLocale(void)
+ throw (IllegalAccessibleComponentStateException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mxParent.is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext (
+ mxParent->getAccessibleContext());
+ if (xParentContext.is())
+ return xParentContext->getLocale ();
+ }
+
+ // No locale and no parent. Therefore throw exception to indicate this
+ // cluelessness.
+ throw IllegalAccessibleComponentStateException ();
+}
+
+ //===== XAccessibleEventBroadcaster =====================================
+
+void SAL_CALL
+ ScAccessibleContextBase::addEventListener(
+ const uno::Reference<XAccessibleEventListener>& xListener)
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!IsDefunc())
+ {
+ if (!mnClientId)
+ mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
+ comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
+ }
+ }
+}
+
+void SAL_CALL
+ ScAccessibleContextBase::removeEventListener(
+ const uno::Reference<XAccessibleEventListener>& xListener)
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ SolarMutexGuard aGuard;
+ if (!IsDefunc() && mnClientId)
+ {
+ sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener );
+ if ( !nListenerCount )
+ {
+ // no listeners anymore
+ // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
+ // and at least to us not firing any events anymore, in case somebody calls
+ // NotifyAccessibleEvent, again
+ comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
+ mnClientId = 0;
+ }
+ }
+ }
+}
+
+ //===== XAccessibleEventListener ========================================
+
+void SAL_CALL ScAccessibleContextBase::disposing(
+ const lang::EventObject& rSource )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (rSource.Source == mxParent)
+ dispose();
+}
+
+void SAL_CALL ScAccessibleContextBase::notifyEvent(
+ const AccessibleEventObject& /* aEvent */ )
+ throw (uno::RuntimeException)
+{
+}
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL
+ ScAccessibleContextBase::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleContextBase"));
+}
+
+sal_Bool SAL_CALL
+ ScAccessibleContextBase::supportsService(const OUString& sServiceName)
+ throw (uno::RuntimeException)
+{
+ // Iterate over all supported service names and return true if on of them
+ // matches the given name.
+ uno::Sequence< ::rtl::OUString> aSupportedServices (
+ getSupportedServiceNames ());
+ sal_Int32 nLength(aSupportedServices.getLength());
+ const OUString* pServiceNames = aSupportedServices.getConstArray();
+ for (int i=0; i<nLength; ++i, ++pServiceNames)
+ if (sServiceName == *pServiceNames)
+ return sal_True;
+ return sal_False;
+}
+
+uno::Sequence< ::rtl::OUString> SAL_CALL
+ ScAccessibleContextBase::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence<OUString> aServiceNames(2);
+ OUString* pServiceNames = aServiceNames.getArray();
+ if (pServiceNames)
+ {
+ pServiceNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.accessibility.Accessible"));
+ pServiceNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.accessibility.AccessibleContext"));
+ }
+
+ return aServiceNames;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence< uno::Type > SAL_CALL ScAccessibleContextBase::getTypes()
+ throw (uno::RuntimeException)
+{
+ return comphelper::concatSequences(ScAccessibleContextBaseWeakImpl::getTypes(), ScAccessibleContextBaseImplEvent::getTypes());
+}
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleContextBase::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+//===== internal ============================================================
+
+::rtl::OUString SAL_CALL
+ ScAccessibleContextBase::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("should be implemented in the abrevated class");
+ return rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleContextBase::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("should be implemented in the abrevated class");
+ return rtl::OUString();
+}
+
+void ScAccessibleContextBase::CommitChange(const AccessibleEventObject& rEvent) const
+{
+ if (mnClientId)
+ comphelper::AccessibleEventNotifier::addEvent( mnClientId, rEvent );
+}
+
+void ScAccessibleContextBase::ChangeName()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::NAME_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(const_cast<ScAccessibleContextBase*>(this));
+ aEvent.OldValue <<= msName;
+
+ msName = rtl::OUString(); // reset the name so it will be hold again
+ getAccessibleName(); // create the new name
+
+ aEvent.NewValue <<= msName;
+
+ CommitChange(aEvent);
+}
+
+void ScAccessibleContextBase::CommitFocusGained() const
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::STATE_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(const_cast<ScAccessibleContextBase*>(this));
+ aEvent.NewValue <<= AccessibleStateType::FOCUSED;
+
+ CommitChange(aEvent);
+
+ ::vcl::unohelper::NotifyAccessibleStateEventGlobally(aEvent);
+}
+
+void ScAccessibleContextBase::CommitFocusLost() const
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::STATE_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(const_cast<ScAccessibleContextBase*>(this));
+ aEvent.OldValue <<= AccessibleStateType::FOCUSED;
+
+ CommitChange(aEvent);
+
+ vcl::unohelper::NotifyAccessibleStateEventGlobally(aEvent);
+}
+
+Rectangle ScAccessibleContextBase::GetBoundingBoxOnScreen(void) const
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+ return Rectangle();
+}
+
+Rectangle ScAccessibleContextBase::GetBoundingBox(void) const
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+ return Rectangle();
+}
+
+void ScAccessibleContextBase::IsObjectValid() const
+ throw (lang::DisposedException)
+{
+ if (rBHelper.bDisposed || rBHelper.bInDispose)
+ throw lang::DisposedException();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleCsvControl.cxx b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
new file mode 100644
index 000000000000..b6829243ecf8
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleCsvControl.cxx
@@ -0,0 +1,1676 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// ============================================================================
+#include "AccessibleCsvControl.hxx"
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleTextType.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
+#include <tools/debug.hxx>
+#include <rtl/uuid.h>
+#include <toolkit/helper/convert.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/sequence.hxx>
+#include "scitems.hxx"
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/langitem.hxx>
+#include "csvcontrol.hxx"
+#include "csvruler.hxx"
+#include "csvgrid.hxx"
+#include "AccessibleText.hxx"
+#include "editsrc.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "scmod.hxx"
+#include <svtools/colorcfg.hxx>
+#include <vcl/svapp.hxx>
+// ause
+#include "editutil.hxx"
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::utl::AccessibleRelationSetHelper;
+using ::utl::AccessibleStateSetHelper;
+using ::accessibility::AccessibleStaticTextBase;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::lang::DisposedException;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
+using ::com::sun::star::lang::IllegalArgumentException;
+using ::com::sun::star::beans::PropertyValue;
+using namespace ::com::sun::star::accessibility;
+
+
+// ----------------------------------------------------------------------------
+
+const sal_uInt16 nRulerRole = AccessibleRole::TEXT;
+const sal_uInt16 nGridRole = AccessibleRole::TABLE;
+const sal_uInt16 nCellRole = AccessibleRole::TEXT;
+
+#define CREATE_OUSTRING( name ) OUString( RTL_CONSTASCII_USTRINGPARAM( name ) )
+
+#define RULER_IMPL_NAME "ScAccessibleCsvRuler"
+#define GRID_IMPL_NAME "ScAccessibleCsvGrid"
+#define CELL_IMPL_NAME "ScAccessibleCsvCell"
+
+const sal_Unicode cRulerDot = '.';
+const sal_Unicode cRulerLine = '|';
+
+const sal_Int32 CSV_LINE_HEADER = CSV_POS_INVALID;
+const sal_uInt32 CSV_COLUMN_HEADER = CSV_COLUMN_INVALID;
+
+
+// CSV base control ===========================================================
+
+DBG_NAME( ScAccessibleCsvControl )
+
+ScAccessibleCsvControl::ScAccessibleCsvControl(
+ const Reference< XAccessible >& rxParent,
+ ScCsvControl& rControl,
+ sal_uInt16 nRole ) :
+ ScAccessibleContextBase( rxParent, nRole ),
+ mpControl( &rControl )
+{
+ DBG_CTOR( ScAccessibleCsvControl, NULL );
+}
+
+ScAccessibleCsvControl::~ScAccessibleCsvControl()
+{
+ DBG_DTOR( ScAccessibleCsvControl, NULL );
+ implDispose();
+}
+
+void SAL_CALL ScAccessibleCsvControl::disposing()
+{
+ SolarMutexGuard aGuard;
+ mpControl = NULL;
+ ScAccessibleContextBase::disposing();
+}
+
+
+// XAccessibleComponent -------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvControl::getAccessibleAtPoint( const AwtPoint& /* rPoint */ )
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvControl::isVisible() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetControl().IsVisible();
+}
+
+void SAL_CALL ScAccessibleCsvControl::grabFocus() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ implGetControl().GrabFocus();
+}
+
+
+// events ---------------------------------------------------------------------
+
+void ScAccessibleCsvControl::SendFocusEvent( bool bFocused )
+{
+ if( bFocused )
+ CommitFocusGained();
+ else
+ CommitFocusLost();
+}
+
+void ScAccessibleCsvControl::SendCaretEvent()
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendCaretEvent - Illegal call" );
+}
+
+void ScAccessibleCsvControl::SendVisibleEvent()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ CommitChange( aEvent );
+}
+
+void ScAccessibleCsvControl::SendSelectionEvent()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ CommitChange( aEvent );
+}
+
+void ScAccessibleCsvControl::SendTableUpdateEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */, bool /* bAllRows */ )
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendTableUpdateEvent - Illegal call" );
+}
+
+void ScAccessibleCsvControl::SendInsertColumnEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */ )
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendInsertColumnEvent - Illegal call" );
+}
+
+void ScAccessibleCsvControl::SendRemoveColumnEvent( sal_uInt32 /* nFirstColumn */, sal_uInt32 /* nLastColumn */ )
+{
+ DBG_ERRORFILE( "ScAccessibleCsvControl::SendRemoveColumnEvent - Illegal call" );
+}
+
+
+// helpers --------------------------------------------------------------------
+
+Rectangle ScAccessibleCsvControl::GetBoundingBoxOnScreen() const throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetControl().GetWindowExtentsRelative( NULL );
+}
+
+Rectangle ScAccessibleCsvControl::GetBoundingBox() const throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetControl().GetWindowExtentsRelative( implGetControl().GetAccessibleParentWindow() );
+}
+
+void ScAccessibleCsvControl::getUuid( Sequence< sal_Int8 >& rSeq )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ if( !rSeq.hasElements() )
+ {
+ rSeq.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( rSeq.getArray() ), NULL, sal_True );
+ }
+}
+
+void ScAccessibleCsvControl::ensureAlive() const throw( DisposedException )
+{
+ if( !implIsAlive() )
+ throw DisposedException();
+}
+
+ScCsvControl& ScAccessibleCsvControl::implGetControl() const
+{
+ DBG_ASSERT( mpControl, "ScAccessibleCsvControl::implGetControl - missing control" );
+ return *mpControl;
+}
+
+Reference< XAccessible > ScAccessibleCsvControl::implGetChildByRole(
+ const Reference< XAccessible >& rxParentObj, sal_uInt16 nRole ) throw( RuntimeException )
+{
+ Reference< XAccessible > xAccObj;
+ if( rxParentObj.is() )
+ {
+ Reference< XAccessibleContext > xParentCtxt = rxParentObj->getAccessibleContext();
+ if( xParentCtxt.is() )
+ {
+ sal_Int32 nCount = xParentCtxt->getAccessibleChildCount();
+ sal_Int32 nIndex = 0;
+ while( !xAccObj.is() && (nIndex < nCount) )
+ {
+ Reference< XAccessible > xCurrObj = xParentCtxt->getAccessibleChild( nIndex );
+ if( xCurrObj.is() )
+ {
+ Reference< XAccessibleContext > xCurrCtxt = xCurrObj->getAccessibleContext();
+ if( xCurrCtxt.is() && (xCurrCtxt->getAccessibleRole() == nRole) )
+ xAccObj = xCurrObj;
+ }
+ ++nIndex;
+ }
+ }
+ }
+ return xAccObj;
+}
+
+AccessibleStateSetHelper* ScAccessibleCsvControl::implCreateStateSet()
+{
+ SolarMutexGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = new AccessibleStateSetHelper();
+ if( implIsAlive() )
+ {
+ const ScCsvControl& rCtrl = implGetControl();
+ pStateSet->AddState( AccessibleStateType::OPAQUE );
+ if( rCtrl.IsEnabled() )
+ pStateSet->AddState( AccessibleStateType::ENABLED );
+ if( isShowing() )
+ pStateSet->AddState( AccessibleStateType::SHOWING );
+ if( isVisible() )
+ pStateSet->AddState( AccessibleStateType::VISIBLE );
+ }
+ else
+ pStateSet->AddState( AccessibleStateType::DEFUNC );
+ return pStateSet;
+}
+
+void ScAccessibleCsvControl::implDispose()
+{
+ if( implIsAlive() )
+ {
+ // prevent multiple call of dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+Point ScAccessibleCsvControl::implGetAbsPos( const Point& rPos ) const
+{
+ return rPos + implGetControl().GetWindowExtentsRelative( NULL ).TopLeft();
+}
+
+
+// Ruler ======================================================================
+
+/** Converts a ruler cursor position to API text index. */
+sal_Int32 lcl_GetApiPos( sal_Int32 nRulerPos )
+{
+ sal_Int32 nApiPos = nRulerPos;
+ sal_Int32 nStart = (nRulerPos - 1) / 10;
+ sal_Int32 nExp = 1;
+ while( nStart >= nExp )
+ {
+ nApiPos += nStart - nExp + 1;
+ nExp *= 10;
+ }
+ return ::std::max( nApiPos, static_cast<sal_Int32>(0) );
+}
+
+/** Converts an API text index to a ruler cursor position. */
+sal_Int32 lcl_GetRulerPos( sal_Int32 nApiPos )
+{
+ sal_Int32 nDiv = 10;
+ sal_Int32 nExp = 10;
+ sal_Int32 nRulerPos = 0;
+ sal_Int32 nApiBase = 0;
+ sal_Int32 nApiLimit = 10;
+ while( nApiPos >= nApiLimit )
+ {
+ ++nDiv;
+ nRulerPos = nExp;
+ nExp *= 10;
+ nApiBase = nApiLimit;
+ nApiLimit = lcl_GetApiPos( nExp );
+ }
+ sal_Int32 nRelPos = nApiPos - nApiBase;
+ return nRulerPos + nRelPos / nDiv * 10 + ::std::max( nRelPos % nDiv - nDiv + 10L, 0L );
+}
+
+/** Expands the sequence's size and returns the base index of the new inserted elements. */
+inline sal_Int32 lcl_ExpandSequence( Sequence< PropertyValue >& rSeq, sal_Int32 nExp )
+{
+ DBG_ASSERT( nExp > 0, "lcl_ExpandSequence - invalid value" );
+ rSeq.realloc( rSeq.getLength() + nExp );
+ return rSeq.getLength() - nExp;
+}
+
+/** Fills the property value rVal with the specified name and value from the item. */
+inline void lcl_FillProperty( PropertyValue& rVal, const OUString& rPropName, const SfxPoolItem& rItem, sal_uInt8 nMID )
+{
+ rVal.Name = rPropName;
+ rItem.QueryValue( rVal.Value, nMID );
+}
+
+/** Fills the sequence with all font attributes of rFont. */
+void lcl_FillFontAttributes( Sequence< PropertyValue >& rSeq, const Font& rFont )
+{
+ SvxFontItem aFontItem( rFont.GetFamily(), rFont.GetName(), rFont.GetStyleName(), rFont.GetPitch(), rFont.GetCharSet(), ATTR_FONT );
+ SvxFontHeightItem aHeightItem( rFont.GetSize().Height(), 100, ATTR_FONT_HEIGHT );
+ SvxLanguageItem aLangItem( rFont.GetLanguage(), ATTR_FONT_LANGUAGE );
+
+ sal_Int32 nIndex = lcl_ExpandSequence( rSeq, 7 );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharFontName" ), aFontItem, MID_FONT_FAMILY_NAME );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharFontFamily" ), aFontItem, MID_FONT_FAMILY );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharFontStyleName" ), aFontItem, MID_FONT_STYLE_NAME );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharFontCharSet" ), aFontItem, MID_FONT_PITCH );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharFontPitch" ), aFontItem, MID_FONT_CHAR_SET );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharHeight" ), aHeightItem, MID_FONTHEIGHT );
+ lcl_FillProperty( rSeq[ nIndex++ ], CREATE_OUSTRING( "CharLocale" ), aLangItem, MID_LANG_LOCALE );
+}
+
+
+
+// ----------------------------------------------------------------------------
+
+DBG_NAME( ScAccessibleCsvRuler )
+
+ScAccessibleCsvRuler::ScAccessibleCsvRuler( ScCsvRuler& rRuler ) :
+ ScAccessibleCsvControl( rRuler.GetAccessibleParentWindow()->GetAccessible(), rRuler, nRulerRole )
+{
+ DBG_CTOR( ScAccessibleCsvRuler, NULL );
+ constructStringBuffer();
+}
+
+ScAccessibleCsvRuler::~ScAccessibleCsvRuler()
+{
+ DBG_DTOR( ScAccessibleCsvRuler, NULL );
+ implDispose();
+}
+
+// XAccessibleComponent -----------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getForeground( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetRuler().GetSettings().GetStyleSettings().GetLabelTextColor().GetColor();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getBackground( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetRuler().GetSettings().GetStyleSettings().GetFaceColor().GetColor();
+}
+
+// XAccessibleContext ---------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getAccessibleChildCount() throw( RuntimeException )
+{
+ ensureAlive();
+ return 0;
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvRuler::getAccessibleChild( sal_Int32 /* nIndex */ )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ throw IndexOutOfBoundsException();
+}
+
+Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleRelationSet()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper();
+ Reference< XAccessible > xAccObj = implGetChildByRole( getAccessibleParent(), nGridRole );
+ if( xAccObj.is() )
+ {
+ Sequence< Reference< XInterface > > aSeq( 1 );
+ aSeq[ 0 ] = xAccObj;
+ pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLER_FOR, aSeq ) );
+ }
+ return pRelationSet;
+}
+
+Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvRuler::getAccessibleStateSet()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = implCreateStateSet();
+ if( implIsAlive() )
+ {
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ pStateSet->AddState( AccessibleStateType::SINGLE_LINE );
+ if( implGetRuler().HasFocus() )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ }
+ return pStateSet;
+}
+
+
+// XAccessibleText ------------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getCaretPosition() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return lcl_GetApiPos( implGetRuler().GetRulerCursorPos() );
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvRuler::setCaretPosition( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ ScCsvRuler& rRuler = implGetRuler();
+ sal_Int32 nOldCursor = rRuler.GetRulerCursorPos();
+ rRuler.Execute( CSVCMD_MOVERULERCURSOR, lcl_GetRulerPos( nIndex ) );
+ return rRuler.GetRulerCursorPos() != nOldCursor;
+}
+
+sal_Unicode SAL_CALL ScAccessibleCsvRuler::getCharacter( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ return maBuffer.charAt( nIndex );
+}
+
+Sequence< PropertyValue > SAL_CALL ScAccessibleCsvRuler::getCharacterAttributes( sal_Int32 nIndex,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* aRequestedAttributes */ )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndexWithEnd( nIndex );
+ Sequence< PropertyValue > aSeq;
+ lcl_FillFontAttributes( aSeq, implGetRuler().GetFont() );
+//! TODO split attribute: waiting for #102221#
+// if( implHasSplit( nIndex ) )
+// {
+// sal_Int32 nIndex = lcl_ExpandSequence( aSeq, 1 );
+// aSeq[ nIndex ].Name = CREATE_OUSTRING( "..." );
+// aSeq[ nIndex ].Value <<= ...;
+// }
+ return aSeq;
+}
+
+ScAccessibleCsvRuler::AwtRectangle SAL_CALL ScAccessibleCsvRuler::getCharacterBounds( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndexWithEnd( nIndex );
+ ScCsvRuler& rRuler = implGetRuler();
+ Point aPos( rRuler.GetX( lcl_GetRulerPos( nIndex ) ) - rRuler.GetCharWidth() / 2, 0 );
+ AwtRectangle aRect( aPos.X(), aPos.Y(), rRuler.GetCharWidth(), rRuler.GetSizePixel().Height() );
+ // #107054# do not return rectangle out of window
+ sal_Int32 nWidth = rRuler.GetOutputSizePixel().Width();
+ if( aRect.X >= nWidth )
+ throw IndexOutOfBoundsException();
+ if( aRect.X + aRect.Width > nWidth )
+ aRect.Width = nWidth - aRect.X;
+ return aRect;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getCharacterCount() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetTextLength();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getIndexAtPoint( const AwtPoint& rPoint )
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ScCsvRuler& rRuler = implGetRuler();
+ // #107054# use object's coordinate system, convert to API position
+ return lcl_GetApiPos( ::std::min( ::std::max( rRuler.GetPosFromX( rPoint.X ), static_cast<sal_Int32>(0) ), rRuler.GetPosCount() ) );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getSelectedText() throw( RuntimeException )
+{
+ ensureAlive();
+ return OUString();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getSelectionStart() throw( RuntimeException )
+{
+ ensureAlive();
+ return -1;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvRuler::getSelectionEnd() throw( RuntimeException )
+{
+ ensureAlive();
+ return -1;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvRuler::setSelection( sal_Int32 /* nStartIndex */, sal_Int32 /* nEndIndex */ )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getText() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return OUString( maBuffer.getStr(), implGetTextLength() );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidRange( nStartIndex, nEndIndex );
+ return OUString( maBuffer.getStr() + nStartIndex, nEndIndex - nStartIndex );
+}
+
+TextSegment SAL_CALL ScAccessibleCsvRuler::getTextAtIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, IllegalArgumentException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+
+ TextSegment aResult;
+ aResult.SegmentStart = -1;
+ aResult.SegmentEnd = -1;
+
+ if( (nIndex == implGetTextLength()) && (nTextType != AccessibleTextType::LINE) )
+ return aResult;
+
+ ensureValidIndex( nIndex );
+
+ OUStringBuffer aResultText; // will be assigned to aResult.SegmentText below
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+
+ switch( nTextType )
+ {
+ // single character
+ case AccessibleTextType::CHARACTER:
+ {
+ aResult.SegmentStart = nIndex;
+ aResultText.append( maBuffer.charAt( nIndex ) );
+ }
+ break;
+
+ // entire number or single dot/line
+ case AccessibleTextType::WORD:
+ case AccessibleTextType::GLYPH:
+ aResult.SegmentStart = nIndex;
+ if( nRulerPos % 10 )
+ aResultText.append( maBuffer.charAt( nIndex ) );
+ else
+ aResultText.append( nRulerPos ); // string representation of sal_Int32!!!
+ break;
+
+ // entire text
+ case AccessibleTextType::SENTENCE:
+ case AccessibleTextType::PARAGRAPH:
+ case AccessibleTextType::LINE:
+ aResult.SegmentStart = 0;
+ aResultText.append( maBuffer.getStr(), implGetTextLength() );
+ break;
+
+ // equal-formatted text
+ case AccessibleTextType::ATTRIBUTE_RUN:
+ {
+ sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
+ sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
+ aResult.SegmentStart = nFirstIndex;
+ aResultText.append( maBuffer.getStr() + nFirstIndex, nLastIndex - nFirstIndex + 1 );
+ }
+ break;
+
+ default:
+ throw RuntimeException();
+ }
+
+ aResult.SegmentText = aResultText.makeStringAndClear();
+ aResult.SegmentEnd = aResult.SegmentStart + aResult.SegmentText.getLength();
+ return aResult;
+}
+
+TextSegment SAL_CALL ScAccessibleCsvRuler::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, IllegalArgumentException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndexWithEnd( nIndex );
+
+ TextSegment aResult;
+ aResult.SegmentStart = -1;
+ aResult.SegmentEnd = -1;
+
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+
+ switch( nTextType )
+ {
+ // single character
+ case AccessibleTextType::CHARACTER:
+ if( nIndex > 0 )
+ aResult = getTextAtIndex( nIndex - 1, nTextType );
+ // else empty
+ break;
+
+ // entire number or single dot/line
+ case AccessibleTextType::WORD:
+ case AccessibleTextType::GLYPH:
+ if( nRulerPos > 0 )
+ aResult = getTextAtIndex( lcl_GetApiPos( nRulerPos - 1 ), nTextType );
+ // else empty
+ break;
+
+ // entire text
+ case AccessibleTextType::SENTENCE:
+ case AccessibleTextType::PARAGRAPH:
+ case AccessibleTextType::LINE:
+ // empty
+ break;
+
+ // equal-formatted text
+ case AccessibleTextType::ATTRIBUTE_RUN:
+ {
+ sal_Int32 nFirstIndex = implGetFirstEqualFormatted( nIndex );
+ if( nFirstIndex > 0 )
+ aResult = getTextAtIndex( nFirstIndex - 1, nTextType );
+ // else empty
+ }
+ break;
+
+ default:
+ throw RuntimeException();
+ }
+ return aResult;
+}
+
+TextSegment SAL_CALL ScAccessibleCsvRuler::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 nTextType )
+ throw( IndexOutOfBoundsException, IllegalArgumentException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndexWithEnd( nIndex );
+
+ TextSegment aResult;
+ aResult.SegmentStart = -1;
+ aResult.SegmentEnd = -1;
+
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nIndex );
+ sal_Int32 nLastValid = implGetTextLength();
+
+ switch( nTextType )
+ {
+ // single character
+ case AccessibleTextType::CHARACTER:
+ if( nIndex < nLastValid )
+ aResult = getTextAtIndex( nIndex + 1, nTextType );
+ // else empty
+ break;
+
+ // entire number or single dot/line
+ case AccessibleTextType::WORD:
+ case AccessibleTextType::GLYPH:
+ if( nRulerPos < implGetRuler().GetPosCount() )
+ aResult = getTextAtIndex( lcl_GetApiPos( nRulerPos + 1 ), nTextType );
+ // else empty
+ break;
+
+ // entire text
+ case AccessibleTextType::SENTENCE:
+ case AccessibleTextType::PARAGRAPH:
+ case AccessibleTextType::LINE:
+ // empty
+ break;
+
+ // equal-formatted text
+ case AccessibleTextType::ATTRIBUTE_RUN:
+ {
+ sal_Int32 nLastIndex = implGetLastEqualFormatted( nIndex );
+ if( nLastIndex < nLastValid )
+ aResult = getTextAtIndex( nLastIndex + 1, nTextType );
+ // else empty
+ }
+ break;
+
+ default:
+ throw RuntimeException();
+ }
+ return aResult;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvRuler::copyText( sal_Int32 /* nStartIndex */, sal_Int32 /* nEndIndex */ )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+
+// XInterface -----------------------------------------------------------------
+
+Any SAL_CALL ScAccessibleCsvRuler::queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( RuntimeException )
+{
+ Any aAny( ScAccessibleCsvRulerImpl::queryInterface( rType ) );
+ return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
+}
+
+void SAL_CALL ScAccessibleCsvRuler::acquire() throw ()
+{
+ ScAccessibleCsvControl::acquire();
+}
+
+void SAL_CALL ScAccessibleCsvRuler::release() throw ()
+{
+ ScAccessibleCsvControl::release();
+}
+
+
+// XServiceInfo ---------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvRuler::getImplementationName() throw( RuntimeException )
+{
+ return CREATE_OUSTRING( RULER_IMPL_NAME );
+}
+
+
+// XTypeProvider --------------------------------------------------------------
+
+Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvRuler::getTypes() throw( RuntimeException )
+{
+ Sequence< ::com::sun::star::uno::Type > aSeq( 1 );
+ aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleText >* >( NULL ) );
+ return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
+}
+
+Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvRuler::getImplementationId() throw( RuntimeException )
+{
+ static Sequence< sal_Int8 > aSeq;
+ getUuid( aSeq );
+ return aSeq;
+}
+
+
+// events ---------------------------------------------------------------------
+
+void ScAccessibleCsvRuler::SendCaretEvent()
+{
+ sal_Int32 nPos = implGetRuler().GetRulerCursorPos();
+ if( nPos != CSV_POS_INVALID )
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CARET_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= nPos;
+ CommitChange( aEvent );
+ }
+}
+
+
+// helpers --------------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvRuler::createAccessibleName() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVRULER_NAME ) );
+}
+
+OUString SAL_CALL ScAccessibleCsvRuler::createAccessibleDescription() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVRULER_DESCR ) );
+}
+
+void ScAccessibleCsvRuler::ensureValidIndex( sal_Int32 nIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( (nIndex < 0) || (nIndex >= implGetTextLength()) )
+ throw IndexOutOfBoundsException();
+}
+
+void ScAccessibleCsvRuler::ensureValidIndexWithEnd( sal_Int32 nIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( (nIndex < 0) || (nIndex > implGetTextLength()) )
+ throw IndexOutOfBoundsException();
+}
+
+void ScAccessibleCsvRuler::ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( rnStartIndex > rnEndIndex )
+ ::std::swap( rnStartIndex, rnEndIndex );
+ if( (rnStartIndex < 0) || (rnEndIndex > implGetTextLength()) )
+ throw IndexOutOfBoundsException();
+}
+
+ScCsvRuler& ScAccessibleCsvRuler::implGetRuler() const
+{
+ return static_cast< ScCsvRuler& >( implGetControl() );
+}
+
+void ScAccessibleCsvRuler::constructStringBuffer() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ // extend existing string buffer to new ruler size
+ sal_Int32 nRulerCount = implGetRuler().GetPosCount();
+ sal_Int32 nRulerPos = lcl_GetRulerPos( maBuffer.getLength() );
+ for( ; nRulerPos <= nRulerCount; ++nRulerPos ) // include last position
+ {
+ switch( nRulerPos % 10 )
+ {
+ case 0: maBuffer.append( nRulerPos ); break;
+ case 5: maBuffer.append( cRulerLine ); break;
+ default: maBuffer.append( cRulerDot );
+ }
+ }
+}
+
+sal_Int32 ScAccessibleCsvRuler::implGetTextLength() const
+{
+ return lcl_GetApiPos( implGetRuler().GetPosCount() + 1 );
+}
+
+bool ScAccessibleCsvRuler::implHasSplit( sal_Int32 nApiPos )
+{
+ sal_Int32 nRulerPos = lcl_GetRulerPos( nApiPos );
+ return implGetRuler().HasSplit( nRulerPos ) && (nApiPos == lcl_GetApiPos( nRulerPos ));
+}
+
+sal_Int32 ScAccessibleCsvRuler::implGetFirstEqualFormatted( sal_Int32 nApiPos )
+{
+ bool bSplit = implHasSplit( nApiPos );
+ while( (nApiPos > 0) && (implHasSplit( nApiPos - 1 ) == bSplit) )
+ --nApiPos;
+ return nApiPos;
+}
+
+sal_Int32 ScAccessibleCsvRuler::implGetLastEqualFormatted( sal_Int32 nApiPos )
+{
+ bool bSplit = implHasSplit( nApiPos );
+ sal_Int32 nLength = implGetTextLength();
+ while( (nApiPos < nLength - 1) && (implHasSplit( nApiPos + 1 ) == bSplit) )
+ ++nApiPos;
+ return nApiPos;
+}
+
+
+// Grid =======================================================================
+
+/** Converts a grid columnm index to an API column index. */
+inline sal_Int32 lcl_GetApiColumn( sal_uInt32 nGridColumn )
+{
+ return (nGridColumn != CSV_COLUMN_HEADER) ? static_cast< sal_Int32 >( nGridColumn + 1 ) : 0;
+}
+
+/** Converts an API columnm index to a ScCsvGrid column index. */
+inline sal_uInt32 lcl_GetGridColumn( sal_Int32 nApiColumn )
+{
+ return (nApiColumn > 0) ? static_cast< sal_uInt32 >( nApiColumn - 1 ) : CSV_COLUMN_HEADER;
+}
+
+
+// ----------------------------------------------------------------------------
+
+DBG_NAME( ScAccessibleCsvGrid )
+
+ScAccessibleCsvGrid::ScAccessibleCsvGrid( ScCsvGrid& rGrid ) :
+ ScAccessibleCsvControl( rGrid.GetAccessibleParentWindow()->GetAccessible(), rGrid, nGridRole )
+{
+ DBG_CTOR( ScAccessibleCsvGrid, NULL );
+}
+
+ScAccessibleCsvGrid::~ScAccessibleCsvGrid()
+{
+ DBG_DTOR( ScAccessibleCsvGrid, NULL );
+ implDispose();
+}
+
+
+// XAccessibleComponent -------------------------------------------------------
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleAtPoint( const AwtPoint& rPoint )
+ throw( RuntimeException )
+{
+ Reference< XAccessible > xRet;
+ if( containsPoint( rPoint ) )
+ {
+ SolarMutexGuard aGuard;
+ ensureAlive();
+
+ const ScCsvGrid& rGrid = implGetGrid();
+ // #102679#; use <= instead of <, because the offset is the size and not the point
+ sal_Int32 nColumn = ((rGrid.GetFirstX() <= rPoint.X) && (rPoint.X <= rGrid.GetLastX())) ?
+ lcl_GetApiColumn( rGrid.GetColumnFromX( rPoint.X ) ) : 0;
+ sal_Int32 nRow = (rPoint.Y >= rGrid.GetHdrHeight()) ?
+ (rGrid.GetLineFromY( rPoint.Y ) - rGrid.GetFirstVisLine() + 1) : 0;
+ xRet = implCreateCellObj( nRow, nColumn );
+ }
+ return xRet;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getForeground( )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetGrid().GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getBackground( )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
+}
+
+// XAccessibleContext ---------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleChildCount() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetCellCount();
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleChild( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nIndex );
+ return implCreateCellObj( implGetRow( nIndex ), implGetColumn( nIndex ) );
+}
+
+Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleRelationSet()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ AccessibleRelationSetHelper* pRelationSet = new AccessibleRelationSetHelper();
+ Reference< XAccessible > xAccObj = implGetChildByRole( getAccessibleParent(), nRulerRole );
+ if( xAccObj.is() )
+ {
+ Sequence< Reference< XInterface > > aSeq( 1 );
+ aSeq[ 0 ] = xAccObj;
+ pRelationSet->AddRelation( AccessibleRelation( AccessibleRelationType::CONTROLLED_BY, aSeq ) );
+ }
+ return pRelationSet;
+}
+
+Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvGrid::getAccessibleStateSet()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = implCreateStateSet();
+ if( implIsAlive() )
+ {
+ pStateSet->AddState( AccessibleStateType::FOCUSABLE );
+ pStateSet->AddState( AccessibleStateType::MULTI_SELECTABLE );
+ pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS );
+ if( implGetGrid().HasFocus() )
+ pStateSet->AddState( AccessibleStateType::FOCUSED );
+ }
+ else
+ pStateSet->AddState( AccessibleStateType::DEFUNC );
+ return pStateSet;
+}
+
+
+// XAccessibleTable -----------------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowCount() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetRowCount();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnCount() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetColumnCount();
+}
+
+OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleRowDescription( sal_Int32 nRow )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( nRow, 0 );
+ return implGetCellText( nRow, 0 );
+}
+
+OUString SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( 0, nColumn );
+ return implGetCellText( 0, nColumn );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ ensureValidPosition( nRow, nColumn );
+ return 1;
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ ensureValidPosition( nRow, nColumn );
+ return 1;
+}
+
+Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleRowHeaders()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+Reference< XAccessibleTable > SAL_CALL ScAccessibleCsvGrid::getAccessibleColumnHeaders()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleRows()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return Sequence< sal_Int32 >();
+}
+
+Sequence< sal_Int32 > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleColumns()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+
+ ScCsvGrid& rGrid = implGetGrid();
+ Sequence< sal_Int32 > aSeq( implGetColumnCount() );
+
+ sal_Int32 nSeqIx = 0;
+ sal_uInt32 nColIx = rGrid.GetFirstSelected();
+ for( ; nColIx != CSV_COLUMN_INVALID; ++nSeqIx, nColIx = rGrid.GetNextSelected( nColIx ) )
+ aSeq[ nSeqIx ] = lcl_GetApiColumn( nColIx );
+
+ aSeq.realloc( nSeqIx );
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleRowSelected( sal_Int32 /* nRow */ )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ ensureAlive();
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nColumn );
+ return implIsColumnSelected( nColumn );
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( nRow, nColumn );
+ return implCreateCellObj( nRow, nColumn );
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleCaption()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getAccessibleSummary()
+ throw( RuntimeException )
+{
+ ensureAlive();
+ return NULL;
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleSelected( sal_Int32 /* nRow */, sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ return isAccessibleColumnSelected( nColumn );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidPosition( nRow, nColumn );
+ return implGetIndex( nRow, nColumn );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleRow( sal_Int32 nChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nChildIndex );
+ return implGetRow( nChildIndex );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getAccessibleColumn( sal_Int32 nChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nChildIndex );
+ return implGetColumn( nChildIndex );
+}
+
+
+// XAccessibleSelection -------------------------------------------------------
+
+void SAL_CALL ScAccessibleCsvGrid::selectAccessibleChild( sal_Int32 nChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nChildIndex );
+ sal_Int32 nColumn = implGetColumn( nChildIndex );
+ if( nChildIndex == 0 )
+ implGetGrid().SelectAll();
+ else
+ implSelectColumn( nColumn, true );
+}
+
+sal_Bool SAL_CALL ScAccessibleCsvGrid::isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ensureValidIndex( nChildIndex );
+ sal_Int32 nColumn = implGetColumn( nChildIndex );
+ return implIsColumnSelected( nColumn );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::clearAccessibleSelection() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ implGetGrid().SelectAll( false );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::selectAllAccessibleChildren() throw( RuntimeException )
+{
+ selectAccessibleChild( 0 );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChildCount() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetRowCount() * implGetSelColumnCount();
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvGrid::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ sal_Int32 nColumns = implGetSelColumnCount();
+ if( nColumns == 0 )
+ throw IndexOutOfBoundsException();
+
+ sal_Int32 nRow = nSelectedChildIndex / nColumns;
+ sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
+ return getAccessibleCellAt( nRow, nColumn );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ sal_Int32 nColumns = implGetSelColumnCount();
+ if( nColumns == 0 )
+ throw IndexOutOfBoundsException();
+
+ sal_Int32 nColumn = implGetSelColumn( nSelectedChildIndex % nColumns );
+ ensureValidPosition( nSelectedChildIndex / nColumns, nColumn );
+ if( nColumn > 0 )
+ implSelectColumn( nColumn, false );
+}
+
+
+// XInterface -----------------------------------------------------------------
+
+Any SAL_CALL ScAccessibleCsvGrid::queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( RuntimeException )
+{
+ Any aAny( ScAccessibleCsvGridImpl::queryInterface( rType ) );
+ return aAny.hasValue() ? aAny : ScAccessibleCsvControl::queryInterface( rType );
+}
+
+void SAL_CALL ScAccessibleCsvGrid::acquire() throw ()
+{
+ ScAccessibleCsvControl::acquire();
+}
+
+void SAL_CALL ScAccessibleCsvGrid::release() throw ()
+{
+ ScAccessibleCsvControl::release();
+}
+
+
+// XServiceInfo ---------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvGrid::getImplementationName() throw( RuntimeException )
+{
+ return CREATE_OUSTRING( GRID_IMPL_NAME );
+}
+
+
+// XTypeProvider --------------------------------------------------------------
+
+Sequence< ::com::sun::star::uno::Type > SAL_CALL ScAccessibleCsvGrid::getTypes() throw( RuntimeException )
+{
+ Sequence< ::com::sun::star::uno::Type > aSeq( 2 );
+ aSeq[ 0 ] = getCppuType( static_cast< const Reference< XAccessibleTable >* >( NULL ) );
+ aSeq[ 1 ] = getCppuType( static_cast< const Reference< XAccessibleSelection >* >( NULL ) );
+ return ::comphelper::concatSequences( ScAccessibleCsvControl::getTypes(), aSeq );
+}
+
+Sequence< sal_Int8 > SAL_CALL ScAccessibleCsvGrid::getImplementationId() throw( RuntimeException )
+{
+ static Sequence< sal_Int8 > aSeq;
+ getUuid( aSeq );
+ return aSeq;
+}
+
+
+// events ---------------------------------------------------------------------
+
+void ScAccessibleCsvGrid::SendFocusEvent( bool bFocused )
+{
+ ScAccessibleCsvControl::SendFocusEvent( bFocused );
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ (bFocused ? aEvent.NewValue : aEvent.OldValue) <<=
+ getAccessibleCellAt( 0, lcl_GetApiColumn( implGetGrid().GetFocusColumn() ) );
+ CommitChange( aEvent );
+}
+
+void ScAccessibleCsvGrid::SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
+{
+ if( nFirstColumn <= nLastColumn )
+ {
+ AccessibleTableModelChange aModelChange(
+ AccessibleTableModelChangeType::UPDATE, 0, bAllRows ? implGetRowCount() - 1 : 0,
+ lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= aModelChange;
+ CommitChange( aEvent );
+ }
+}
+
+void ScAccessibleCsvGrid::SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( nFirstColumn <= nLastColumn )
+ {
+ AccessibleTableModelChange aModelChange(
+ AccessibleTableModelChangeType::INSERT, 0, implGetRowCount() - 1,
+ lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= aModelChange;
+ CommitChange( aEvent );
+ }
+}
+
+void ScAccessibleCsvGrid::SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( nFirstColumn <= nLastColumn )
+ {
+ AccessibleTableModelChange aModelChange(
+ AccessibleTableModelChangeType::DELETE, 0, implGetRowCount() - 1,
+ lcl_GetApiColumn( nFirstColumn ), lcl_GetApiColumn( nLastColumn ) );
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
+ aEvent.Source = Reference< XAccessible >( this );
+ aEvent.NewValue <<= aModelChange;
+ CommitChange( aEvent );
+ }
+}
+
+
+// helpers --------------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvGrid::createAccessibleName() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVGRID_NAME ) );
+}
+
+OUString SAL_CALL ScAccessibleCsvGrid::createAccessibleDescription() throw( RuntimeException )
+{
+ return String( ScResId( STR_ACC_CSVGRID_DESCR ) );
+}
+
+void ScAccessibleCsvGrid::ensureValidIndex( sal_Int32 nIndex ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( (nIndex < 0) || (nIndex >= implGetCellCount()) )
+ throw IndexOutOfBoundsException();
+}
+
+void ScAccessibleCsvGrid::ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
+ throw( IndexOutOfBoundsException )
+{
+ if( (nRow < 0) || (nRow >= implGetRowCount()) || (nColumn < 0) || (nColumn >= implGetColumnCount()) )
+ throw IndexOutOfBoundsException();
+}
+
+ScCsvGrid& ScAccessibleCsvGrid::implGetGrid() const
+{
+ return static_cast< ScCsvGrid& >( implGetControl() );
+}
+
+bool ScAccessibleCsvGrid::implIsColumnSelected( sal_Int32 nColumn ) const
+{
+ return (nColumn > 0) && implGetGrid().IsSelected( lcl_GetGridColumn( nColumn ) );
+}
+
+void ScAccessibleCsvGrid::implSelectColumn( sal_Int32 nColumn, bool bSelect )
+{
+ if( nColumn > 0 )
+ implGetGrid().Select( lcl_GetGridColumn( nColumn ), bSelect );
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetRowCount() const
+{
+ return static_cast< sal_Int32 >( implGetGrid().GetLastVisLine() - implGetGrid().GetFirstVisLine() + 2 );
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetColumnCount() const
+{
+ return static_cast< sal_Int32 >( implGetGrid().GetColumnCount() + 1 );
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetSelColumnCount() const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nCount = 0;
+ for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = rGrid.GetNextSelected( nColIx ) )
+ ++nCount;
+ return nCount;
+}
+
+sal_Int32 ScAccessibleCsvGrid::implGetSelColumn( sal_Int32 nSelColumn ) const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nColumn = 0;
+ for( sal_uInt32 nColIx = rGrid.GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = rGrid.GetNextSelected( nColIx ) )
+ {
+ if( nColumn == nSelColumn )
+ return static_cast< sal_Int32 >( nColIx + 1 );
+ ++nColumn;
+ }
+ return 0;
+}
+
+String ScAccessibleCsvGrid::implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ sal_Int32 nLine = nRow + rGrid.GetFirstVisLine() - 1;
+ String aCellStr;
+ if( (nColumn > 0) && (nRow > 0) )
+ aCellStr = rGrid.GetCellText( lcl_GetGridColumn( nColumn ), nLine );
+ else if( nRow > 0 )
+ aCellStr = String::CreateFromInt32( nLine + 1L );
+ else if( nColumn > 0 )
+ aCellStr = rGrid.GetColumnTypeName( lcl_GetGridColumn( nColumn ) );
+ return aCellStr;
+}
+
+
+ScAccessibleCsvControl* ScAccessibleCsvGrid::implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const
+{
+ return new ScAccessibleCsvCell( implGetGrid(), implGetCellText( nRow, nColumn ), nRow, nColumn );
+}
+
+
+// ============================================================================
+
+DBG_NAME( ScAccessibleCsvCell )
+
+ScAccessibleCsvCell::ScAccessibleCsvCell(
+ ScCsvGrid& rGrid,
+ const String& rCellText,
+ sal_Int32 nRow, sal_Int32 nColumn ) :
+ ScAccessibleCsvControl( rGrid.GetAccessible(), rGrid, nCellRole ),
+ AccessibleStaticTextBase( SvxEditSourcePtr( NULL ) ),
+ maCellText( rCellText ),
+ mnLine( nRow ? (nRow + rGrid.GetFirstVisLine() - 1) : CSV_LINE_HEADER ),
+ mnColumn( lcl_GetGridColumn( nColumn ) ),
+ mnIndex( nRow * (rGrid.GetColumnCount() + 1) + nColumn )
+{
+ DBG_CTOR( ScAccessibleCsvCell, NULL );
+ SetEditSource( implCreateEditSource() );
+}
+
+ScAccessibleCsvCell::~ScAccessibleCsvCell()
+{
+ DBG_DTOR( ScAccessibleCsvCell, NULL );
+}
+
+void SAL_CALL ScAccessibleCsvCell::disposing()
+{
+ SolarMutexGuard aGuard;
+ SetEditSource( SvxEditSourcePtr( NULL ) );
+ ScAccessibleCsvControl::disposing();
+}
+
+
+// XAccessibleComponent -------------------------------------------------------
+
+void SAL_CALL ScAccessibleCsvCell::grabFocus() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ ScCsvGrid& rGrid = implGetGrid();
+ rGrid.Execute( CSVCMD_MOVEGRIDCURSOR, rGrid.GetColumnPos( mnColumn ) );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getForeground( )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetGrid().GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getBackground( )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
+}
+
+// XAccessibleContext -----------------------------------------------------
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getAccessibleChildCount() throw( RuntimeException )
+{
+ return AccessibleStaticTextBase::getAccessibleChildCount();
+}
+
+Reference< XAccessible > SAL_CALL ScAccessibleCsvCell::getAccessibleChild( sal_Int32 nIndex )
+ throw( IndexOutOfBoundsException, RuntimeException )
+{
+ return AccessibleStaticTextBase::getAccessibleChild( nIndex );
+}
+
+sal_Int32 SAL_CALL ScAccessibleCsvCell::getAccessibleIndexInParent() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return mnIndex;
+}
+
+Reference< XAccessibleRelationSet > SAL_CALL ScAccessibleCsvCell::getAccessibleRelationSet()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return new AccessibleRelationSetHelper();
+}
+
+Reference< XAccessibleStateSet > SAL_CALL ScAccessibleCsvCell::getAccessibleStateSet()
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ AccessibleStateSetHelper* pStateSet = implCreateStateSet();
+ if( implIsAlive() )
+ {
+ const ScCsvGrid& rGrid = implGetGrid();
+ pStateSet->AddState( AccessibleStateType::SINGLE_LINE );
+ if( mnColumn != CSV_COLUMN_HEADER )
+ pStateSet->AddState( AccessibleStateType::SELECTABLE );
+ if( rGrid.HasFocus() && (rGrid.GetFocusColumn() == mnColumn) && (mnLine == CSV_LINE_HEADER) )
+ pStateSet->AddState( AccessibleStateType::ACTIVE );
+ if( rGrid.IsSelected( mnColumn ) )
+ pStateSet->AddState( AccessibleStateType::SELECTED );
+ }
+ return pStateSet;
+}
+
+// XInterface -----------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XINTERFACE2( ScAccessibleCsvCell, ScAccessibleCsvControl, AccessibleStaticTextBase )
+
+// XTypeProvider --------------------------------------------------------------
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScAccessibleCsvCell, ScAccessibleCsvControl, AccessibleStaticTextBase )
+
+// XServiceInfo ---------------------------------------------------------------
+
+OUString SAL_CALL ScAccessibleCsvCell::getImplementationName() throw( RuntimeException )
+{
+ return CREATE_OUSTRING( CELL_IMPL_NAME );
+}
+
+// helpers --------------------------------------------------------------------
+
+Rectangle ScAccessibleCsvCell::GetBoundingBoxOnScreen() const throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ Rectangle aRect( implGetBoundingBox() );
+ aRect.SetPos( implGetAbsPos( aRect.TopLeft() ) );
+ return aRect;
+}
+
+Rectangle ScAccessibleCsvCell::GetBoundingBox() const throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ ensureAlive();
+ return implGetBoundingBox();
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::createAccessibleName() throw( RuntimeException )
+{
+ return maCellText;
+}
+
+OUString SAL_CALL ScAccessibleCsvCell::createAccessibleDescription() throw( RuntimeException )
+{
+ return OUString();
+}
+
+ScCsvGrid& ScAccessibleCsvCell::implGetGrid() const
+{
+ return static_cast< ScCsvGrid& >( implGetControl() );
+}
+
+Point ScAccessibleCsvCell::implGetRealPos() const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ return Point(
+ (mnColumn == CSV_COLUMN_HEADER) ? rGrid.GetHdrX() : rGrid.GetColumnX( mnColumn ),
+ (mnLine == CSV_LINE_HEADER) ? 0 : rGrid.GetY( mnLine ) );
+}
+
+sal_uInt32 ScAccessibleCsvCell::implCalcPixelWidth(sal_uInt32 nChars) const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ return rGrid.GetCharWidth() * nChars;
+}
+
+Size ScAccessibleCsvCell::implGetRealSize() const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ return Size(
+ (mnColumn == CSV_COLUMN_HEADER) ? rGrid.GetHdrWidth() : implCalcPixelWidth( rGrid.GetColumnWidth( mnColumn ) ),
+ (mnLine == CSV_LINE_HEADER) ? rGrid.GetHdrHeight() : rGrid.GetLineHeight() );
+}
+
+Rectangle ScAccessibleCsvCell::implGetBoundingBox() const
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ Rectangle aClipRect( Point( 0, 0 ), rGrid.GetSizePixel() );
+ if( mnColumn != CSV_COLUMN_HEADER )
+ {
+ aClipRect.Left() = rGrid.GetFirstX();
+ aClipRect.Right() = rGrid.GetLastX();
+ }
+ if( mnLine != CSV_LINE_HEADER )
+ aClipRect.Top() = rGrid.GetHdrHeight();
+
+ Rectangle aRect( implGetRealPos(), implGetRealSize() );
+ aRect.Intersection( aClipRect );
+ if( (aRect.GetWidth() <= 0) || (aRect.GetHeight() <= 0) )
+ aRect.SetSize( Size( -1, -1 ) );
+ return aRect;
+}
+
+::std::auto_ptr< SvxEditSource > ScAccessibleCsvCell::implCreateEditSource()
+{
+ ScCsvGrid& rGrid = implGetGrid();
+ Rectangle aBoundRect( implGetBoundingBox() );
+ aBoundRect -= implGetRealPos();
+
+ ::std::auto_ptr< ScAccessibleTextData > pCsvTextData( new ScAccessibleCsvTextData(
+ &rGrid, rGrid.GetEditEngine(), maCellText, aBoundRect, implGetRealSize() ) );
+
+ ::std::auto_ptr< SvxEditSource > pEditSource( new ScAccessibilityEditSource( pCsvTextData ) );
+ return pEditSource;
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx b/sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx
new file mode 100644
index 000000000000..198223430a26
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx
@@ -0,0 +1,736 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "AccessibleDataPilotControl.hxx"
+#include "fieldwnd.hxx"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <rtl/uuid.h>
+#include <tools/gen.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+class ScAccessibleDataPilotButton
+ : public ScAccessibleContextBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleDataPilotButton(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScDPFieldWindow* pDPFieldWindow,
+ sal_Int32 nIndex);
+
+ virtual void Init();
+
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ void SetIndex(sal_Int32 nIndex) { mnIndex = nIndex; }
+ void NameChanged();
+ void SetFocused();
+ void ResetFocused();
+protected:
+ virtual ~ScAccessibleDataPilotButton(void);
+public:
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isVisible( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return this objects index among the parents children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleIndexInParent(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScDPFieldWindow* mpDPFieldWindow;
+ sal_Int32 mnIndex;
+};
+
+ //===== internal ========================================================
+ScAccessibleDataPilotControl::ScAccessibleDataPilotControl(
+ const uno::Reference<XAccessible>& rxParent,
+ ScDPFieldWindow* pDPFieldWindow)
+ :
+ ScAccessibleContextBase(rxParent, AccessibleRole::GROUP_BOX),
+ mpDPFieldWindow(pDPFieldWindow)
+{
+ if (mpDPFieldWindow)
+ maChildren.resize(mpDPFieldWindow->GetFieldCount());
+}
+
+ScAccessibleDataPilotControl::~ScAccessibleDataPilotControl(void)
+{
+ if (!IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void ScAccessibleDataPilotControl::Init()
+{
+}
+
+void SAL_CALL ScAccessibleDataPilotControl::disposing()
+{
+ SolarMutexGuard aGuard;
+ mpDPFieldWindow = NULL;
+
+ ScAccessibleContextBase::disposing();
+}
+
+void ScAccessibleDataPilotControl::AddField(sal_Int32 nNewIndex)
+{
+ sal_Bool bAdded(sal_False);
+ if (static_cast<sal_uInt32>(nNewIndex) == maChildren.size())
+ {
+ maChildren.push_back(AccessibleWeak());
+ bAdded = sal_True;
+ }
+ else if (static_cast<sal_uInt32>(nNewIndex) < maChildren.size())
+ {
+ ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nNewIndex;
+ maChildren.insert(aItr, AccessibleWeak());
+
+ ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end();
+ aItr = maChildren.begin() + nNewIndex + 1;
+ uno::Reference< XAccessible > xTempAcc;
+ sal_Int32 nIndex = nNewIndex + 1;
+ while (aItr != aEndItr)
+ {
+ xTempAcc = aItr->xWeakAcc;
+ if (xTempAcc.is() && aItr->pAcc)
+ aItr->pAcc->SetIndex(nIndex);
+ ++nIndex;
+ ++aItr;
+ }
+ bAdded = sal_True;
+ }
+ else
+ {
+ DBG_ERRORFILE("did not recognize a child count change");
+ }
+
+ if (bAdded)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.NewValue <<= getAccessibleChild(nNewIndex);
+
+ CommitChange(aEvent); // new child - event
+ }
+}
+
+void ScAccessibleDataPilotControl::RemoveField(sal_Int32 nOldIndex)
+{
+ sal_Bool bRemoved(sal_False);
+ uno::Reference< XAccessible > xTempAcc;
+ ScAccessibleDataPilotButton* pField = NULL;
+ if (static_cast<sal_uInt32>(nOldIndex) < maChildren.size())
+ {
+ xTempAcc = getAccessibleChild(nOldIndex);
+ pField = maChildren[nOldIndex].pAcc;
+
+ ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nOldIndex;
+ aItr = maChildren.erase(aItr);
+
+ ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end();
+ uno::Reference< XAccessible > xItrAcc;
+ while (aItr != aEndItr)
+ {
+ xItrAcc = aItr->xWeakAcc;
+ if (xItrAcc.is() && aItr->pAcc)
+ aItr->pAcc->SetIndex(nOldIndex);
+ ++nOldIndex;
+ ++aItr;
+ }
+ bRemoved = sal_True;
+ }
+ else
+ {
+ DBG_ERRORFILE("did not recognize a child count change");
+ }
+
+ if (bRemoved)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.NewValue <<= xTempAcc;
+
+ CommitChange(aEvent); // gone child - event
+
+ if (pField)
+ pField->dispose();
+ }
+}
+
+void ScAccessibleDataPilotControl::FieldFocusChange(sal_Int32 nOldIndex, sal_Int32 nNewIndex)
+{
+ DBG_ASSERT(static_cast<sal_uInt32>(nOldIndex) < maChildren.size() &&
+ static_cast<sal_uInt32>(nNewIndex) < maChildren.size(), "did not recognize a child count change");
+
+ uno::Reference < XAccessible > xTempAcc = maChildren[nOldIndex].xWeakAcc;
+ if (xTempAcc.is() && maChildren[nOldIndex].pAcc)
+ maChildren[nOldIndex].pAcc->ResetFocused();
+
+ xTempAcc = maChildren[nNewIndex].xWeakAcc;
+ if (xTempAcc.is() && maChildren[nNewIndex].pAcc)
+ maChildren[nNewIndex].pAcc->SetFocused();
+}
+
+void ScAccessibleDataPilotControl::FieldNameChange(sal_Int32 nIndex)
+{
+ DBG_ASSERT(static_cast<sal_uInt32>(nIndex) < maChildren.size(), "did not recognize a child count change");
+
+ uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
+ if (xTempAcc.is() && maChildren[nIndex].pAcc)
+ maChildren[nIndex].pAcc->ChangeName();
+}
+
+void ScAccessibleDataPilotControl::GotFocus()
+{
+ if (mpDPFieldWindow)
+ {
+ DBG_ASSERT(static_cast<sal_uInt32>(mpDPFieldWindow->GetFieldCount()) == maChildren.size(), "did not recognize a child count change");
+
+ sal_Int32 nIndex(mpDPFieldWindow->GetSelectedField());
+ uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
+ if (xTempAcc.is() && maChildren[nIndex].pAcc)
+ maChildren[nIndex].pAcc->SetFocused();
+ }
+}
+
+void ScAccessibleDataPilotControl::LostFocus()
+{
+ if (mpDPFieldWindow)
+ {
+ DBG_ASSERT(static_cast<sal_uInt32>(mpDPFieldWindow->GetFieldCount()) == maChildren.size(), "did not recognize a child count change");
+
+ sal_Int32 nIndex(mpDPFieldWindow->GetSelectedField());
+ uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
+ if (xTempAcc.is() && maChildren[nIndex].pAcc)
+ maChildren[nIndex].pAcc->ResetFocused();
+ }
+}
+
+ ///===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotControl::getAccessibleAtPoint(
+ const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xAcc;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ {
+ Point aAbsPoint(VCLPoint(rPoint));
+ Point aControlEdge(GetBoundingBoxOnScreen().TopLeft());
+ Point aRelPoint(aAbsPoint - aControlEdge);
+ size_t nChildIndex(0);
+ if (mpDPFieldWindow->GetFieldIndex(aRelPoint, nChildIndex))
+ xAcc = getAccessibleChild(static_cast< long >( nChildIndex ));
+ }
+ }
+ return xAcc;
+}
+
+sal_Bool SAL_CALL ScAccessibleDataPilotControl::isVisible( )
+ throw (uno::RuntimeException)
+{
+ return sal_True;
+}
+
+void SAL_CALL ScAccessibleDataPilotControl::grabFocus( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ mpDPFieldWindow->GrabFocus();
+}
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getForeground( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nColor(0);
+ if (mpDPFieldWindow)
+ {
+ nColor = mpDPFieldWindow->GetSettings().GetStyleSettings().GetWindowTextColor().GetColor();
+ }
+ return nColor;
+}
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getBackground( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nColor(0);
+ if (mpDPFieldWindow)
+ {
+ if (mpDPFieldWindow->GetType() == TYPE_SELECT)
+ {
+ nColor = mpDPFieldWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
+ }
+ else
+ {
+ nColor = mpDPFieldWindow->GetSettings().GetStyleSettings().GetWindowColor().GetColor();
+ }
+ }
+ return nColor;
+}
+
+ ///===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ return mpDPFieldWindow->GetFieldCount();
+ else
+ return 0;
+}
+
+uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotControl::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference<XAccessible> xAcc;
+ if (mpDPFieldWindow)
+ {
+ if (nIndex < 0 || static_cast< size_t >( nIndex ) >= mpDPFieldWindow->GetFieldCount())
+ throw lang::IndexOutOfBoundsException();
+
+ DBG_ASSERT(static_cast<sal_uInt32>(mpDPFieldWindow->GetFieldCount()) == maChildren.size(), "did not recognize a child count change");
+
+ uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc;
+ if (!xTempAcc.is())
+ {
+ maChildren[nIndex].pAcc = new ScAccessibleDataPilotButton(this, mpDPFieldWindow, nIndex);
+ xTempAcc = maChildren[nIndex].pAcc;
+ maChildren[nIndex].xWeakAcc = xTempAcc;
+ }
+
+ xAcc = xTempAcc;
+ }
+ return xAcc;
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotControl::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+
+ if (IsDefunc())
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+
+ return pStateSet;
+}
+
+ ///===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotControl"));
+}
+
+ ///===== XTypeProvider ===================================================
+
+uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotControl::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+ //===== internal ========================================================
+
+::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ return mpDPFieldWindow->GetDescription();
+
+ return rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ return mpDPFieldWindow->GetName();
+
+ return rtl::OUString();
+}
+
+Rectangle ScAccessibleDataPilotControl::GetBoundingBoxOnScreen(void) const
+ throw (uno::RuntimeException)
+{
+ if (mpDPFieldWindow)
+ return mpDPFieldWindow->GetWindowExtentsRelative(NULL);
+ else
+ return Rectangle();
+}
+
+Rectangle ScAccessibleDataPilotControl::GetBoundingBox(void) const
+ throw (uno::RuntimeException)
+{
+ if (mpDPFieldWindow)
+ return mpDPFieldWindow->GetWindowExtentsRelative(mpDPFieldWindow->GetAccessibleParentWindow());
+ else
+ return Rectangle();
+}
+
+
+//===============================================================================
+
+ScAccessibleDataPilotButton::ScAccessibleDataPilotButton(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScDPFieldWindow* pDPFieldWindow,
+ sal_Int32 nIndex)
+ : ScAccessibleContextBase(rxParent, AccessibleRole::PUSH_BUTTON),
+ mpDPFieldWindow(pDPFieldWindow),
+ mnIndex(nIndex)
+{
+}
+
+ScAccessibleDataPilotButton::~ScAccessibleDataPilotButton(void)
+{
+ if (!IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void ScAccessibleDataPilotButton::Init()
+{
+}
+
+void SAL_CALL ScAccessibleDataPilotButton::disposing()
+{
+ SolarMutexGuard aGuard;
+ mpDPFieldWindow = NULL;
+
+ ScAccessibleContextBase::disposing();
+}
+
+void ScAccessibleDataPilotButton::SetFocused()
+{
+ CommitFocusGained();
+}
+
+void ScAccessibleDataPilotButton::ResetFocused()
+{
+ CommitFocusLost();
+}
+
+ ///===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotButton::getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& /* rPoint */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return NULL;
+}
+
+sal_Bool SAL_CALL ScAccessibleDataPilotButton::isVisible( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return sal_True;
+}
+
+void SAL_CALL ScAccessibleDataPilotButton::grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ {
+ mpDPFieldWindow->GrabFocusWithSel(getAccessibleIndexInParent());
+ }
+}
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getForeground( )
+throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nColor(0);
+ if (mpDPFieldWindow)
+ {
+ nColor = mpDPFieldWindow->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor();
+ }
+ return nColor;
+}
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getBackground( )
+throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nColor(0);
+ if (mpDPFieldWindow)
+ {
+ nColor = mpDPFieldWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor();
+ }
+ return nColor;
+}
+
+ ///===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+
+uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotButton::getAccessibleChild(sal_Int32 /* nIndex */)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException)
+{
+ throw lang::IndexOutOfBoundsException();
+}
+
+sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleIndexInParent(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return mnIndex;
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotButton::getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+
+ if (IsDefunc())
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ pStateSet->AddState(AccessibleStateType::FOCUSABLE);
+ if (mpDPFieldWindow && (sal::static_int_cast<sal_Int32>(mpDPFieldWindow->GetSelectedField()) == mnIndex))
+ pStateSet->AddState(AccessibleStateType::FOCUSED);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+
+ return pStateSet;
+}
+
+ ///===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotButton"));
+}
+
+ ///===== XTypeProvider ===================================================
+
+uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotButton::getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ return rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpDPFieldWindow)
+ return mpDPFieldWindow->GetFieldText(getAccessibleIndexInParent());
+
+ return rtl::OUString();
+}
+
+Rectangle ScAccessibleDataPilotButton::GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ Rectangle aRect(GetBoundingBox());
+
+ if (mpDPFieldWindow)
+ {
+ Point aParentPos(mpDPFieldWindow->GetWindowExtentsRelative(NULL).TopLeft());
+ aRect.Move(aParentPos.getX(), aParentPos.getY());
+ }
+
+ return aRect;
+}
+
+Rectangle ScAccessibleDataPilotButton::GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ if (mpDPFieldWindow)
+ return Rectangle (mpDPFieldWindow->GetFieldPosition(const_cast<ScAccessibleDataPilotButton*> (this)->getAccessibleIndexInParent()), mpDPFieldWindow->GetFieldSize());
+ else
+ return Rectangle();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx
new file mode 100644
index 000000000000..debe93c44a5f
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -0,0 +1,2115 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleDocument.hxx"
+#include "AccessibleSpreadsheet.hxx"
+#include "tabvwsh.hxx"
+#include "AccessibilityHints.hxx"
+#include "document.hxx"
+#include "drwlayer.hxx"
+#include "shapeuno.hxx"
+#include "DrawModelBroadcaster.hxx"
+#include "drawview.hxx"
+#include "gridwin.hxx"
+#include "AccessibleEditObject.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <tools/debug.hxx>
+#include <tools/gen.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/ShapeTypeHandler.hxx>
+#include <svx/AccessibleShape.hxx>
+#include <svx/AccessibleShapeTreeInfo.hxx>
+#include <svx/AccessibleShapeInfo.hxx>
+#include <comphelper/sequence.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/unoshcol.hxx>
+#include <svx/unoshape.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <vcl/svapp.hxx>
+
+#include <list>
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using ::std::for_each;
+
+ //===== internal ========================================================
+
+struct ScAccessibleShapeData
+{
+ ScAccessibleShapeData() : pAccShape(NULL), pRelationCell(NULL), bSelected(sal_False), bSelectable(sal_True) {}
+ ~ScAccessibleShapeData();
+ mutable ::accessibility::AccessibleShape* pAccShape;
+ mutable ScAddress* pRelationCell; // if it is NULL this shape is anchored on the table
+// SdrObject* pShape;
+ com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape;
+ mutable sal_Bool bSelected;
+ sal_Bool bSelectable;
+};
+
+ScAccessibleShapeData::~ScAccessibleShapeData()
+{
+ if (pAccShape)
+ {
+ pAccShape->dispose();
+ pAccShape->release();
+ }
+}
+
+struct ScShapeDataLess
+{
+ rtl::OUString msLayerId;
+ rtl::OUString msZOrder;
+ ScShapeDataLess()
+ : msLayerId(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )),
+ msZOrder(RTL_CONSTASCII_USTRINGPARAM( "ZOrder" ))
+ {
+ }
+ void ConvertLayerId(sal_Int16& rLayerID) const // changes the number of the LayerId so it the accessibility order
+ {
+ switch (rLayerID)
+ {
+ case SC_LAYER_FRONT:
+ rLayerID = 1;
+ break;
+ case SC_LAYER_BACK:
+ rLayerID = 0;
+ break;
+ case SC_LAYER_INTERN:
+ rLayerID = 2;
+ break;
+ case SC_LAYER_CONTROLS:
+ rLayerID = 3;
+ break;
+ }
+ }
+ sal_Bool LessThanSheet(const ScAccessibleShapeData* pData) const
+ {
+ sal_Bool bResult(sal_False);
+ uno::Reference< beans::XPropertySet> xProps(pData->xShape, uno::UNO_QUERY);
+ if (xProps.is())
+ {
+ uno::Any aPropAny = xProps->getPropertyValue(msLayerId);
+ sal_Int16 nLayerID = 0;
+ if( (aPropAny >>= nLayerID) )
+ {
+ if (nLayerID == SC_LAYER_BACK)
+ bResult = sal_True;
+ }
+ }
+ return bResult;
+ }
+ sal_Bool operator()(const ScAccessibleShapeData* pData1, const ScAccessibleShapeData* pData2) const
+ {
+ sal_Bool bResult(sal_False);
+ if (pData1 && pData2)
+ {
+ uno::Reference< beans::XPropertySet> xProps1(pData1->xShape, uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet> xProps2(pData2->xShape, uno::UNO_QUERY);
+ if (xProps1.is() && xProps2.is())
+ {
+ uno::Any aPropAny1 = xProps1->getPropertyValue(msLayerId);
+ uno::Any aPropAny2 = xProps2->getPropertyValue(msLayerId);
+ sal_Int16 nLayerID1(0);
+ sal_Int16 nLayerID2(0);
+ if( (aPropAny1 >>= nLayerID1) && (aPropAny2 >>= nLayerID2) )
+ {
+ if (nLayerID1 == nLayerID2)
+ {
+ uno::Any aAny1 = xProps1->getPropertyValue(msZOrder);
+ sal_Int32 nZOrder1 = 0;
+ uno::Any aAny2 = xProps2->getPropertyValue(msZOrder);
+ sal_Int32 nZOrder2 = 0;
+ if ( (aAny1 >>= nZOrder1) && (aAny2 >>= nZOrder2) )
+ bResult = (nZOrder1 < nZOrder2);
+ }
+ else
+ {
+ ConvertLayerId(nLayerID1);
+ ConvertLayerId(nLayerID2);
+ bResult = (nLayerID1 < nLayerID2);
+ }
+ }
+ }
+ }
+ else if (pData1 && !pData2)
+ bResult = LessThanSheet(pData1);
+ else if (!pData1 && pData2)
+ bResult = !LessThanSheet(pData2);
+ else
+ bResult = sal_False;
+ return bResult;
+ }
+};
+
+struct DeselectShape
+{
+ void operator() (const ScAccessibleShapeData* pAccShapeData) const
+ {
+ if (pAccShapeData)
+ {
+ pAccShapeData->bSelected = sal_False;
+ if (pAccShapeData->pAccShape)
+ pAccShapeData->pAccShape->ResetState(AccessibleStateType::SELECTED);
+ }
+ }
+};
+
+struct SelectShape
+{
+ uno::Reference < drawing::XShapes > xShapes;
+ SelectShape(uno::Reference<drawing::XShapes>& xTemp) : xShapes(xTemp) {}
+ void operator() (const ScAccessibleShapeData* pAccShapeData) const
+ {
+ if (pAccShapeData && pAccShapeData->bSelectable)
+ {
+ pAccShapeData->bSelected = sal_True;
+ if (pAccShapeData->pAccShape)
+ pAccShapeData->pAccShape->SetState(AccessibleStateType::SELECTED);
+ if (xShapes.is())
+ xShapes->add(pAccShapeData->xShape);
+ }
+ }
+};
+
+struct Destroy
+{
+ void operator() (ScAccessibleShapeData* pData)
+ {
+ if (pData)
+ DELETEZ(pData);
+ }
+};
+
+class ScChildrenShapes : public SfxListener,
+ public ::accessibility::IAccessibleParent
+{
+public:
+ ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
+ ~ScChildrenShapes();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== IAccessibleParent ===============================================
+
+ virtual sal_Bool ReplaceChild (
+ ::accessibility::AccessibleShape* pCurrentChild,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
+ const long _nIndex,
+ const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
+ ) throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== Internal ========================================================
+ void SetDrawBroadcaster();
+
+ sal_Int32 GetCount() const;
+ uno::Reference< XAccessible > Get(const ScAccessibleShapeData* pData) const;
+ uno::Reference< XAccessible > Get(sal_Int32 nIndex) const;
+ uno::Reference< XAccessible > GetAt(const awt::Point& rPoint) const;
+
+ // gets the index of the shape starting on 0 (without the index of the table)
+ // returns the selected shape
+ sal_Bool IsSelected(sal_Int32 nIndex,
+ com::sun::star::uno::Reference<com::sun::star::drawing::XShape>& rShape) const;
+
+ sal_Bool SelectionChanged();
+
+ void Select(sal_Int32 nIndex);
+ void DeselectAll(); // deselect also the table
+ void SelectAll();
+ sal_Int32 GetSelectedCount() const;
+ uno::Reference< XAccessible > GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const;
+ void Deselect(sal_Int32 nChildIndex);
+
+ SdrPage* GetDrawPage() const;
+
+ utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
+
+ void VisAreaChanged() const;
+private:
+ typedef std::vector<ScAccessibleShapeData*> SortedShapes;
+
+ mutable SortedShapes maZOrderedShapes; // a null pointer represents the sheet in the correct order
+
+ mutable ::accessibility::AccessibleShapeTreeInfo maShapeTreeInfo;
+ mutable com::sun::star::uno::Reference<com::sun::star::view::XSelectionSupplier> xSelectionSupplier;
+ mutable sal_uInt32 mnSdrObjCount;
+ mutable sal_uInt32 mnShapesSelected;
+ ScTabViewShell* mpViewShell;
+ ScAccessibleDocument* mpAccessibleDocument;
+ ScSplitPos meSplitPos;
+
+ void FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const;
+ sal_Bool FindSelectedShapesChanges(const com::sun::star::uno::Reference<com::sun::star::drawing::XShapes>& xShapes, sal_Bool bCommitChange) const;
+ void FillSelectionSupplier() const;
+
+ ScAddress* GetAnchor(const uno::Reference<drawing::XShape>& xShape) const;
+ uno::Reference<XAccessibleRelationSet> GetRelationSet(const ScAccessibleShapeData* pData) const;
+ void CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const;
+ void SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const;
+ void AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const;
+ void RemoveShape(const uno::Reference<drawing::XShape>& xShape) const;
+
+ sal_Bool FindShape(const uno::Reference<drawing::XShape>& xShape, SortedShapes::iterator& rItr) const;
+
+ sal_Int8 Compare(const ScAccessibleShapeData* pData1,
+ const ScAccessibleShapeData* pData2) const;
+};
+
+ScChildrenShapes::ScChildrenShapes(ScAccessibleDocument* pAccessibleDocument, ScTabViewShell* pViewShell, ScSplitPos eSplitPos)
+ :
+ mnShapesSelected(0),
+ mpViewShell(pViewShell),
+ mpAccessibleDocument(pAccessibleDocument),
+ meSplitPos(eSplitPos)
+{
+ FillSelectionSupplier();
+ maZOrderedShapes.push_back(NULL); // add an element which represents the table
+
+ GetCount(); // fill list with filtered shapes (no internal shapes)
+
+ if (mnShapesSelected)
+ {
+ //set flag on every selected shape
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+ if (xShapes.is())
+ FindSelectedShapesChanges(xShapes, sal_False);
+ }
+ if (pViewShell)
+ {
+ SfxBroadcaster* pDrawBC = pViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ {
+ StartListening(*pDrawBC);
+
+ maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(pViewShell->GetViewData()->GetDocument()->GetDrawLayer()) );
+ maShapeTreeInfo.SetSdrView(pViewShell->GetViewData()->GetScDrawView());
+ maShapeTreeInfo.SetController(NULL);
+ maShapeTreeInfo.SetWindow(pViewShell->GetWindowByPos(meSplitPos));
+ maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument);
+ }
+ }
+}
+
+ScChildrenShapes::~ScChildrenShapes()
+{
+ std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), Destroy());
+ if (mpViewShell)
+ {
+ SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ EndListening(*pDrawBC);
+ }
+}
+
+void ScChildrenShapes::SetDrawBroadcaster()
+{
+ if (mpViewShell)
+ {
+ SfxBroadcaster* pDrawBC = mpViewShell->GetViewData()->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ {
+ StartListening(*pDrawBC, TRUE);
+
+ maShapeTreeInfo.SetModelBroadcaster( new ScDrawModelBroadcaster(mpViewShell->GetViewData()->GetDocument()->GetDrawLayer()) );
+ maShapeTreeInfo.SetSdrView(mpViewShell->GetViewData()->GetScDrawView());
+ maShapeTreeInfo.SetController(NULL);
+ maShapeTreeInfo.SetWindow(mpViewShell->GetWindowByPos(meSplitPos));
+ maShapeTreeInfo.SetViewForwarder(mpAccessibleDocument);
+ }
+ }
+}
+
+void ScChildrenShapes::Notify(SfxBroadcaster&, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SdrHint ) )
+ {
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ if (pSdrHint)
+ {
+ SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject());
+ if (pObj && /*(pObj->GetLayer() != SC_LAYER_INTERN) && */(pObj->GetPage() == GetDrawPage()) &&
+ (pObj->GetPage() == pObj->GetObjList()) ) //#108480# only do something if the object lies direct on the page
+ {
+ switch (pSdrHint->GetKind())
+ {
+ case HINT_OBJCHG : // Objekt geaendert
+ {
+ uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
+ if (xShape.is())
+ {
+ ScShapeDataLess aLess;
+ std::sort(maZOrderedShapes.begin(), maZOrderedShapes.end(), aLess); // sort, because the z index or layer could be changed
+ CheckWhetherAnchorChanged(xShape);
+ }
+ }
+ break;
+ case HINT_OBJINSERTED : // Neues Zeichenobjekt eingefuegt
+ {
+ uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
+ if (xShape.is())
+ AddShape(xShape, sal_True);
+ }
+ break;
+ case HINT_OBJREMOVED : // Zeichenobjekt aus Liste entfernt
+ {
+ uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
+ if (xShape.is())
+ RemoveShape(xShape);
+ }
+ break;
+ default :
+ {
+ // other events are not interesting
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+sal_Bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentChild,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
+ const long _nIndex, const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo)
+ throw (uno::RuntimeException)
+{
+ // create the new child
+ ::accessibility::AccessibleShape* pReplacement = ::accessibility::ShapeTypeHandler::Instance().CreateAccessibleObject (
+ ::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this, _nIndex ),
+ _rShapeTreeInfo
+ );
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xNewChild( pReplacement ); // keep this alive (do this before calling Init!)
+ if ( pReplacement )
+ pReplacement->Init();
+
+ sal_Bool bResult(sal_False);
+ if (pCurrentChild && pReplacement)
+ {
+ DBG_ASSERT(pCurrentChild->GetXShape().get() == pReplacement->GetXShape().get(), "XShape changes and should be inserted sorted");
+ SortedShapes::iterator aItr;
+ FindShape(pCurrentChild->GetXShape(), aItr);
+ if (aItr != maZOrderedShapes.end() && (*aItr))
+ {
+ if ((*aItr)->pAccShape)
+ {
+ DBG_ASSERT((*aItr)->pAccShape == pCurrentChild, "wrong child found");
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
+ aEvent.OldValue <<= uno::makeAny(uno::Reference<XAccessible>(pCurrentChild));
+
+ mpAccessibleDocument->CommitChange(aEvent); // child is gone - event
+
+ pCurrentChild->dispose();
+ }
+ (*aItr)->pAccShape = pReplacement;
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
+ aEvent.NewValue <<= uno::makeAny(uno::Reference<XAccessible>(pReplacement));
+
+ mpAccessibleDocument->CommitChange(aEvent); // child is new - event
+ bResult = sal_True;
+ }
+ }
+ return bResult;
+}
+
+sal_Int32 ScChildrenShapes::GetCount() const
+{
+ SdrPage* pDrawPage = GetDrawPage();
+ if (pDrawPage && (maZOrderedShapes.size() == 1)) // the table is always in
+ {
+ mnSdrObjCount = pDrawPage->GetObjCount();
+ maZOrderedShapes.reserve(mnSdrObjCount + 1); // the table is always in
+ for (sal_uInt32 i = 0; i < mnSdrObjCount; ++i)
+ {
+ SdrObject* pObj = pDrawPage->GetObj(i);
+ if (pObj/* && (pObj->GetLayer() != SC_LAYER_INTERN)*/)
+ {
+ uno::Reference< drawing::XShape > xShape (pObj->getUnoShape(), uno::UNO_QUERY);
+ AddShape(xShape, sal_False); //inserts in the correct order
+ }
+ }
+ }
+ return maZOrderedShapes.size();
+}
+
+uno::Reference< XAccessible > ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const
+{
+ if (!pData)
+ return NULL;
+
+ if (!pData->pAccShape)
+ {
+ ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
+ ::accessibility::AccessibleShapeInfo aShapeInfo(pData->xShape, mpAccessibleDocument, const_cast<ScChildrenShapes*>(this));
+ pData->pAccShape = rShapeHandler.CreateAccessibleObject(
+ aShapeInfo, maShapeTreeInfo);
+ if (pData->pAccShape)
+ {
+ pData->pAccShape->acquire();
+ pData->pAccShape->Init();
+ if (pData->bSelected)
+ pData->pAccShape->SetState(AccessibleStateType::SELECTED);
+ if (!pData->bSelectable)
+ pData->pAccShape->ResetState(AccessibleStateType::SELECTABLE);
+ pData->pAccShape->SetRelationSet(GetRelationSet(pData));
+ }
+ }
+ return pData->pAccShape;
+ }
+
+uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const
+{
+ if (maZOrderedShapes.size() <= 1)
+ GetCount(); // fill list with filtered shapes (no internal shapes)
+
+ if (static_cast<sal_uInt32>(nIndex) >= maZOrderedShapes.size())
+ return NULL;
+
+ return Get(maZOrderedShapes[nIndex]);
+}
+
+uno::Reference< XAccessible > ScChildrenShapes::GetAt(const awt::Point& rPoint) const
+{
+ uno::Reference<XAccessible> xAccessible;
+ if(mpViewShell)
+ {
+ sal_Int32 i(maZOrderedShapes.size() - 1);
+ sal_Bool bFound(sal_False);
+ while (!bFound && i >= 0)
+ {
+ ScAccessibleShapeData* pShape = maZOrderedShapes[i];
+ if (pShape)
+ {
+ if (!pShape->pAccShape)
+ Get(pShape);
+
+ if (pShape->pAccShape)
+ {
+ Point aPoint(VCLPoint(rPoint));
+ aPoint -= VCLRectangle(pShape->pAccShape->getBounds()).TopLeft();
+ if (pShape->pAccShape->containsPoint(AWTPoint(aPoint)))
+ {
+ xAccessible = pShape->pAccShape;
+ bFound = sal_True;
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE("I should have an accessible shape now!");
+ }
+ }
+ else
+ bFound = sal_True; // this is the sheet and it lies before the rest of the shapes which are background shapes
+
+ --i;
+ }
+ }
+ return xAccessible;
+}
+
+sal_Bool ScChildrenShapes::IsSelected(sal_Int32 nIndex,
+ uno::Reference<drawing::XShape>& rShape) const
+{
+ sal_Bool bResult (sal_False);
+ if (maZOrderedShapes.size() <= 1)
+ GetCount(); // fill list with filtered shapes (no internal shapes)
+
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ if (!maZOrderedShapes[nIndex])
+ return sal_False;
+
+ bResult = maZOrderedShapes[nIndex]->bSelected;
+ rShape = maZOrderedShapes[nIndex]->xShape;
+
+#ifdef DBG_UTIL // test whether it is truly selected by a slower method
+ uno::Reference< drawing::XShape > xReturnShape;
+ sal_Bool bDebugResult(sal_False);
+ uno::Reference<container::XIndexAccess> xIndexAccess;
+ xSelectionSupplier->getSelection() >>= xIndexAccess;
+
+ if (xIndexAccess.is())
+ {
+ sal_Int32 nCount(xIndexAccess->getCount());
+ if (nCount)
+ {
+ uno::Reference< drawing::XShape > xShape;
+ uno::Reference< drawing::XShape > xIndexShape = maZOrderedShapes[nIndex]->xShape;
+ sal_Int32 i(0);
+ while (!bDebugResult && (i < nCount))
+ {
+ xIndexAccess->getByIndex(i) >>= xShape;
+ if (xShape.is() && (xIndexShape.get() == xShape.get()))
+ {
+ bDebugResult = sal_True;
+ xReturnShape = xShape;
+ }
+ else
+ ++i;
+ }
+ }
+ }
+ DBG_ASSERT((bResult == bDebugResult) && ((bResult && (rShape.get() == xReturnShape.get())) || !bResult), "found the wrong shape or result");
+#endif
+
+ return bResult;
+}
+
+sal_Bool ScChildrenShapes::SelectionChanged()
+{
+ sal_Bool bResult(sal_False);
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ uno::Reference<drawing::XShapes> xShapes(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+
+ bResult = FindSelectedShapesChanges(xShapes, sal_True);
+
+ return bResult;
+}
+
+void ScChildrenShapes::Select(sal_Int32 nIndex)
+{
+ if (maZOrderedShapes.size() <= 1)
+ GetCount(); // fill list with filtered shapes (no internal shapes)
+
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ if (!maZOrderedShapes[nIndex])
+ return;
+
+ uno::Reference<drawing::XShape> xShape;
+ if (!IsSelected(nIndex, xShape) && maZOrderedShapes[nIndex]->bSelectable)
+ {
+ uno::Reference<drawing::XShapes> xShapes;
+ xSelectionSupplier->getSelection() >>= xShapes;
+
+ if (!xShapes.is())
+ xShapes = new SvxShapeCollection();
+
+ xShapes->add(maZOrderedShapes[nIndex]->xShape);
+
+ try
+ {
+ xSelectionSupplier->select(uno::makeAny(xShapes));
+ maZOrderedShapes[nIndex]->bSelected = sal_True;
+ if (maZOrderedShapes[nIndex]->pAccShape)
+ maZOrderedShapes[nIndex]->pAccShape->SetState(AccessibleStateType::SELECTED);
+ }
+ catch (lang::IllegalArgumentException&)
+ {
+ }
+ }
+}
+
+void ScChildrenShapes::DeselectAll()
+{
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ sal_Bool bSomethingSelected(sal_True);
+ try
+ {
+ xSelectionSupplier->select(uno::Any()); //deselects all
+ }
+ catch (lang::IllegalArgumentException&)
+ {
+ DBG_ERRORFILE("nothing selected before");
+ bSomethingSelected = sal_False;
+ }
+
+ if (bSomethingSelected)
+ std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), DeselectShape());
+}
+
+void ScChildrenShapes::SelectAll()
+{
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ if (maZOrderedShapes.size() <= 1)
+ GetCount(); // fill list with filtered shapes (no internal shapes)
+
+ if (maZOrderedShapes.size() > 1)
+ {
+ uno::Reference<drawing::XShapes> xShapes;
+ xShapes = new SvxShapeCollection();
+
+ try
+ {
+ std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), SelectShape(xShapes));
+ xSelectionSupplier->select(uno::makeAny(xShapes));
+ }
+ catch (lang::IllegalArgumentException&)
+ {
+ SelectionChanged(); // find all selected shapes and set the flags
+ }
+ }
+}
+
+void ScChildrenShapes::FillShapes(std::vector < uno::Reference < drawing::XShape > >& rShapes) const
+{
+ uno::Reference<container::XIndexAccess> xIndexAccess;
+ xSelectionSupplier->getSelection() >>= xIndexAccess;
+
+ if (xIndexAccess.is())
+ {
+ sal_uInt32 nCount(xIndexAccess->getCount());
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ uno::Reference<drawing::XShape> xShape;
+ xIndexAccess->getByIndex(i) >>= xShape;
+ if (xShape.is())
+ rShapes.push_back(xShape);
+ }
+ }
+}
+
+sal_Int32 ScChildrenShapes::GetSelectedCount() const
+{
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ std::vector < uno::Reference < drawing::XShape > > aShapes;
+ FillShapes(aShapes);
+
+ return aShapes.size();
+}
+
+uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, sal_Bool bTabSelected) const
+{
+ uno::Reference< XAccessible > xAccessible;
+
+ if (maZOrderedShapes.size() <= 1)
+ GetCount(); // fill list with shapes
+
+ if (!bTabSelected)
+ {
+ std::vector < uno::Reference < drawing::XShape > > aShapes;
+ FillShapes(aShapes);
+
+ SortedShapes::iterator aItr;
+ if (FindShape(aShapes[nSelectedChildIndex], aItr))
+ xAccessible = Get(aItr - maZOrderedShapes.begin());
+ }
+ else
+ {
+ SortedShapes::iterator aItr = maZOrderedShapes.begin();
+ SortedShapes::iterator aEndItr = maZOrderedShapes.end();
+ sal_Bool bFound(sal_False);
+ while(!bFound && aItr != aEndItr)
+ {
+ if (*aItr)
+ {
+ if ((*aItr)->bSelected)
+ {
+ if (nSelectedChildIndex == 0)
+ bFound = sal_True;
+ else
+ --nSelectedChildIndex;
+ }
+ }
+ else
+ {
+ if (nSelectedChildIndex == 0)
+ bFound = sal_True;
+ else
+ --nSelectedChildIndex;
+ }
+ if (!bFound)
+ ++aItr;
+ }
+ if (bFound && *aItr)
+ xAccessible = (*aItr)->pAccShape;
+ }
+
+ return xAccessible;
+}
+
+void ScChildrenShapes::Deselect(sal_Int32 nChildIndex)
+{
+ uno::Reference<drawing::XShape> xShape;
+ if (IsSelected(nChildIndex, xShape)) // returns false if it is the sheet
+ {
+ if (xShape.is())
+ {
+ uno::Reference<drawing::XShapes> xShapes;
+ xSelectionSupplier->getSelection() >>= xShapes;
+ if (xShapes.is())
+ xShapes->remove(xShape);
+
+ try
+ {
+ xSelectionSupplier->select(uno::makeAny(xShapes));
+ }
+ catch (lang::IllegalArgumentException&)
+ {
+ DBG_ERRORFILE("something not selectable");
+ }
+
+ maZOrderedShapes[nChildIndex]->bSelected = sal_False;
+ if (maZOrderedShapes[nChildIndex]->pAccShape)
+ maZOrderedShapes[nChildIndex]->pAccShape->ResetState(AccessibleStateType::SELECTED);
+ }
+ }
+}
+
+
+SdrPage* ScChildrenShapes::GetDrawPage() const
+{
+ SCTAB nTab(mpAccessibleDocument->getVisibleTable());
+ SdrPage* pDrawPage = NULL;
+ if (mpViewShell)
+ {
+ ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
+ if (pDoc && pDoc->GetDrawLayer())
+ {
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
+ pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
+ }
+ }
+ return pDrawPage;
+}
+
+struct SetRelation
+{
+ const ScChildrenShapes* mpChildrenShapes;
+ mutable utl::AccessibleRelationSetHelper* mpRelationSet;
+ const ScAddress* mpAddress;
+ SetRelation(const ScChildrenShapes* pChildrenShapes, const ScAddress* pAddress)
+ :
+ mpChildrenShapes(pChildrenShapes),
+ mpRelationSet(NULL),
+ mpAddress(pAddress)
+ {
+ }
+ void operator() (const ScAccessibleShapeData* pAccShapeData) const
+ {
+ if (pAccShapeData &&
+ ((!pAccShapeData->pRelationCell && !mpAddress) ||
+ (pAccShapeData->pRelationCell && mpAddress && (*(pAccShapeData->pRelationCell) == *mpAddress))))
+ {
+ if (!mpRelationSet)
+ mpRelationSet = new utl::AccessibleRelationSetHelper();
+
+ AccessibleRelation aRelation;
+ aRelation.TargetSet.realloc(1);
+ aRelation.TargetSet[0] = mpChildrenShapes->Get(pAccShapeData);
+ aRelation.RelationType = AccessibleRelationType::CONTROLLER_FOR;
+
+ mpRelationSet->AddRelation(aRelation);
+ }
+ }
+};
+
+utl::AccessibleRelationSetHelper* ScChildrenShapes::GetRelationSet(const ScAddress* pAddress) const
+{
+ SetRelation aSetRelation(this, pAddress);
+ ::std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aSetRelation);
+ return aSetRelation.mpRelationSet;
+}
+
+sal_Bool ScChildrenShapes::FindSelectedShapesChanges(const uno::Reference<drawing::XShapes>& xShapes, sal_Bool /* bCommitChange */) const
+{
+ sal_Bool bResult(sal_False);
+ SortedShapes aShapesList;
+ uno::Reference<container::XIndexAccess> xIndexAcc(xShapes, uno::UNO_QUERY);
+ if (xIndexAcc.is())
+ {
+ mnShapesSelected = xIndexAcc->getCount();
+ for (sal_uInt32 i = 0; i < mnShapesSelected; ++i)
+ {
+ uno::Reference< drawing::XShape > xShape;
+ xIndexAcc->getByIndex(i) >>= xShape;
+ if (xShape.is())
+ {
+ ScAccessibleShapeData* pShapeData = new ScAccessibleShapeData();
+ pShapeData->xShape = xShape;
+ aShapesList.push_back(pShapeData);
+ }
+ }
+ }
+ else
+ mnShapesSelected = 0;
+ ScShapeDataLess aLess;
+ std::sort(aShapesList.begin(), aShapesList.end(), aLess);
+
+ SortedShapes::iterator aXShapesItr(aShapesList.begin());
+ SortedShapes::const_iterator aXShapesEndItr(aShapesList.end());
+ SortedShapes::iterator aDataItr(maZOrderedShapes.begin());
+ SortedShapes::const_iterator aDataEndItr(maZOrderedShapes.end());
+ SortedShapes::const_iterator aFocusedItr = aDataEndItr;
+ while((aDataItr != aDataEndItr))
+ {
+ if (*aDataItr) // is it realy a shape or only the sheet
+ {
+ sal_Int8 nComp(0);
+ if (aXShapesItr == aXShapesEndItr)
+ nComp = -1; // simulate that the Shape is lower, so the selction state will be removed
+ else
+ nComp = Compare(*aDataItr, *aXShapesItr);
+ if (nComp == 0)
+ {
+ if (!(*aDataItr)->bSelected)
+ {
+ (*aDataItr)->bSelected = sal_True;
+ if ((*aDataItr)->pAccShape)
+ {
+ (*aDataItr)->pAccShape->SetState(AccessibleStateType::SELECTED);
+ (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED);
+ bResult = sal_True;
+ }
+ aFocusedItr = aDataItr;
+ }
+ ++aDataItr;
+ ++aXShapesItr;
+ }
+ else if (nComp < 0)
+ {
+ if ((*aDataItr)->bSelected)
+ {
+ (*aDataItr)->bSelected = sal_False;
+ if ((*aDataItr)->pAccShape)
+ {
+ (*aDataItr)->pAccShape->ResetState(AccessibleStateType::SELECTED);
+ (*aDataItr)->pAccShape->ResetState(AccessibleStateType::FOCUSED);
+ bResult = sal_True;
+ }
+ }
+ ++aDataItr;
+ }
+ else
+ {
+ DBG_ERRORFILE("here is a selected shape which is not in the childlist");
+ ++aXShapesItr;
+ --mnShapesSelected;
+ }
+ }
+ else
+ ++aDataItr;
+ }
+ if ((aFocusedItr != aDataEndItr) && (*aFocusedItr)->pAccShape && (mnShapesSelected == 1))
+ (*aFocusedItr)->pAccShape->SetState(AccessibleStateType::FOCUSED);
+
+ std::for_each(aShapesList.begin(), aShapesList.end(), Destroy());
+
+ return bResult;
+}
+
+void ScChildrenShapes::FillSelectionSupplier() const
+{
+ if (!xSelectionSupplier.is() && mpViewShell)
+ {
+ SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
+ if (pViewFrame)
+ {
+ xSelectionSupplier = uno::Reference<view::XSelectionSupplier>(pViewFrame->GetFrame().GetController(), uno::UNO_QUERY);
+ if (xSelectionSupplier.is())
+ {
+ if (mpAccessibleDocument)
+ xSelectionSupplier->addSelectionChangeListener(mpAccessibleDocument);
+ uno::Reference<drawing::XShapes> xShapes (xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+ if (xShapes.is())
+ mnShapesSelected = xShapes->getCount();
+ }
+ }
+ }
+}
+
+ScAddress* ScChildrenShapes::GetAnchor(const uno::Reference<drawing::XShape>& xShape) const
+{
+ ScAddress* pAddress = NULL;
+ if (mpViewShell)
+ {
+ SvxShape* pShapeImp = SvxShape::getImplementation(xShape);
+ uno::Reference<beans::XPropertySet> xShapeProp(xShape, uno::UNO_QUERY);
+ if (pShapeImp && xShapeProp.is())
+ {
+ SdrObject *pSdrObj = pShapeImp->GetSdrObject();
+ if (pSdrObj)
+ {
+ if (ScDrawLayer::GetAnchor(pSdrObj) == SCA_CELL)
+ {
+ ScDocument* pDoc = mpViewShell->GetViewData()->GetDocument();
+ if (pDoc)
+ {
+ rtl::OUString sCaptionShape(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.CaptionShape"));
+ awt::Point aPoint(xShape->getPosition());
+ awt::Size aSize(xShape->getSize());
+ rtl::OUString sType(xShape->getShapeType());
+ Rectangle aRectangle(aPoint.X, aPoint.Y, aPoint.X + aSize.Width, aPoint.Y + aSize.Height);
+ if ( sType.equals(sCaptionShape) )
+ {
+ awt::Point aRelativeCaptionPoint;
+ rtl::OUString sCaptionPoint( RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" ));
+ xShapeProp->getPropertyValue( sCaptionPoint ) >>= aRelativeCaptionPoint;
+ Point aCoreRelativeCaptionPoint(aRelativeCaptionPoint.X, aRelativeCaptionPoint.Y);
+ Point aCoreAbsoluteCaptionPoint(aPoint.X, aPoint.Y);
+ aCoreAbsoluteCaptionPoint += aCoreRelativeCaptionPoint;
+ aRectangle.Union(Rectangle(aCoreAbsoluteCaptionPoint, aCoreAbsoluteCaptionPoint));
+ }
+ ScRange aRange = pDoc->GetRange(mpAccessibleDocument->getVisibleTable(), aRectangle);
+ pAddress = new ScAddress(aRange.aStart);
+ }
+ }
+// else
+// do nothing, because it is always a NULL Pointer
+ }
+ }
+ }
+
+ return pAddress;
+}
+
+uno::Reference<XAccessibleRelationSet> ScChildrenShapes::GetRelationSet(const ScAccessibleShapeData* pData) const
+{
+ utl::AccessibleRelationSetHelper* pRelationSet = new utl::AccessibleRelationSetHelper();
+
+ if(pData && pRelationSet && mpAccessibleDocument)
+ {
+ uno::Reference<XAccessible> xAccessible = mpAccessibleDocument->GetAccessibleSpreadsheet(); // should be the current table
+ if (pData->pRelationCell && xAccessible.is())
+ {
+ uno::Reference<XAccessibleTable> xAccTable (xAccessible->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccTable.is())
+ xAccessible = xAccTable->getAccessibleCellAt(pData->pRelationCell->Row(), pData->pRelationCell->Col());
+ }
+ AccessibleRelation aRelation;
+ aRelation.TargetSet.realloc(1);
+ aRelation.TargetSet[0] = xAccessible;
+ aRelation.RelationType = AccessibleRelationType::CONTROLLED_BY;
+ pRelationSet->AddRelation(aRelation);
+ }
+
+ return pRelationSet;
+}
+
+void ScChildrenShapes::CheckWhetherAnchorChanged(const uno::Reference<drawing::XShape>& xShape) const
+{
+ SortedShapes::iterator aItr;
+ if (FindShape(xShape, aItr))
+ SetAnchor(xShape, *aItr);
+}
+
+void ScChildrenShapes::SetAnchor(const uno::Reference<drawing::XShape>& xShape, ScAccessibleShapeData* pData) const
+{
+ if (pData)
+ {
+ ScAddress* pAddress = GetAnchor(xShape);
+ if ((pAddress && pData->pRelationCell && (*pAddress != *(pData->pRelationCell))) ||
+ (!pAddress && pData->pRelationCell) || (pAddress && !pData->pRelationCell))
+ {
+ if (pData->pRelationCell)
+ delete pData->pRelationCell;
+ pData->pRelationCell = pAddress;
+ if (pData->pAccShape)
+ pData->pAccShape->SetRelationSet(GetRelationSet(pData));
+ }
+ }
+}
+
+void ScChildrenShapes::AddShape(const uno::Reference<drawing::XShape>& xShape, sal_Bool bCommitChange) const
+{
+ SortedShapes::iterator aFindItr;
+ if (!FindShape(xShape, aFindItr))
+ {
+ ScAccessibleShapeData* pShape = new ScAccessibleShapeData();
+ pShape->xShape = xShape;
+ SortedShapes::iterator aNewItr = maZOrderedShapes.insert(aFindItr, pShape);
+ SetAnchor(xShape, pShape);
+
+ uno::Reference< beans::XPropertySet > xShapeProp(xShape, uno::UNO_QUERY);
+ if (xShapeProp.is())
+ {
+ uno::Any aPropAny = xShapeProp->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "LayerID" )));
+ sal_Int16 nLayerID = 0;
+ if( aPropAny >>= nLayerID )
+ {
+ if( (nLayerID == SC_LAYER_INTERN) || (nLayerID == SC_LAYER_HIDDEN) )
+ pShape->bSelectable = sal_False;
+ else
+ pShape->bSelectable = sal_True;
+ }
+ }
+
+
+ if (!xSelectionSupplier.is())
+ throw uno::RuntimeException();
+
+ uno::Reference<container::XEnumerationAccess> xEnumAcc(xSelectionSupplier->getSelection(), uno::UNO_QUERY);
+ if (xEnumAcc.is())
+ {
+ uno::Reference<container::XEnumeration> xEnum = xEnumAcc->createEnumeration();
+ if (xEnum.is())
+ {
+ uno::Reference<drawing::XShape> xSelectedShape;
+ sal_Bool bFound(sal_False);
+ while (!bFound && xEnum->hasMoreElements())
+ {
+ xEnum->nextElement() >>= xSelectedShape;
+ if (xShape.is() && (xShape.get() == xSelectedShape.get()))
+ {
+ pShape->bSelected = sal_True;
+ bFound = sal_True;
+ }
+ }
+ }
+ }
+ if (mpAccessibleDocument && bCommitChange)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
+ aEvent.NewValue <<= Get(aNewItr - maZOrderedShapes.begin());
+
+ mpAccessibleDocument->CommitChange(aEvent); // new child - event
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE("shape is always in the list");
+ }
+}
+
+void ScChildrenShapes::RemoveShape(const uno::Reference<drawing::XShape>& xShape) const
+{
+ SortedShapes::iterator aItr;
+ if (FindShape(xShape, aItr))
+ {
+ if (mpAccessibleDocument)
+ {
+ uno::Reference<XAccessible> xOldAccessible (Get(aItr - maZOrderedShapes.begin()));
+
+ delete *aItr;
+ maZOrderedShapes.erase(aItr);
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument);
+ aEvent.OldValue <<= uno::makeAny(xOldAccessible);
+
+ mpAccessibleDocument->CommitChange(aEvent); // child is gone - event
+ }
+ else
+ {
+ delete *aItr;
+ maZOrderedShapes.erase(aItr);
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE("shape was not in internal list");
+ }
+}
+
+sal_Bool ScChildrenShapes::FindShape(const uno::Reference<drawing::XShape>& xShape, ScChildrenShapes::SortedShapes::iterator& rItr) const
+{
+ sal_Bool bResult(sal_False);
+ ScAccessibleShapeData aShape;
+ aShape.xShape = xShape;
+ ScShapeDataLess aLess;
+ rItr = std::lower_bound(maZOrderedShapes.begin(), maZOrderedShapes.end(), &aShape, aLess);
+ if ((rItr != maZOrderedShapes.end()) && (*rItr != NULL) && ((*rItr)->xShape.get() == xShape.get()))
+ bResult = sal_True; // if the shape is found
+
+#ifdef DBG_UTIL // test whether it finds truly the correct shape (perhaps it is not really sorted)
+ SortedShapes::iterator aDebugItr = maZOrderedShapes.begin();
+ SortedShapes::iterator aEndItr = maZOrderedShapes.end();
+ sal_Bool bFound(sal_False);
+ while (!bFound && aDebugItr != aEndItr)
+ {
+ if (*aDebugItr && ((*aDebugItr)->xShape.get() == xShape.get()))
+ bFound = sal_True;
+ else
+ ++aDebugItr;
+ }
+ sal_Bool bResult2 = (aDebugItr != maZOrderedShapes.end());
+ DBG_ASSERT((bResult == bResult2) && ((bResult && (rItr == aDebugItr)) || !bResult), "wrong Shape found");
+#endif
+ return bResult;
+}
+
+sal_Int8 ScChildrenShapes::Compare(const ScAccessibleShapeData* pData1,
+ const ScAccessibleShapeData* pData2) const
+{
+ ScShapeDataLess aLess;
+
+ sal_Bool bResult1(aLess(pData1, pData2));
+ sal_Bool bResult2(aLess(pData2, pData1));
+
+ sal_Int8 nResult(0);
+ if (!bResult1 && bResult2)
+ nResult = 1;
+ else if (bResult1 && !bResult2)
+ nResult = -1;
+
+ return nResult;
+}
+
+struct ScVisAreaChanged
+{
+ ScAccessibleDocument* mpAccDoc;
+ ScVisAreaChanged(ScAccessibleDocument* pAccDoc) : mpAccDoc(pAccDoc) {}
+ void operator() (const ScAccessibleShapeData* pAccShapeData) const
+ {
+ if (pAccShapeData && pAccShapeData->pAccShape)
+ {
+ pAccShapeData->pAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpAccDoc);
+ }
+ }
+};
+
+void ScChildrenShapes::VisAreaChanged() const
+{
+ ScVisAreaChanged aVisAreaChanged(mpAccessibleDocument);
+ std::for_each(maZOrderedShapes.begin(), maZOrderedShapes.end(), aVisAreaChanged);
+}
+
+// ============================================================================
+
+ScAccessibleDocument::ScAccessibleDocument(
+ const uno::Reference<XAccessible>& rxParent,
+ ScTabViewShell* pViewShell,
+ ScSplitPos eSplitPos)
+ : ScAccessibleDocumentBase(rxParent),
+ mpViewShell(pViewShell),
+ meSplitPos(eSplitPos),
+ mpAccessibleSpreadsheet(NULL),
+ mpChildrenShapes(NULL),
+ mpTempAccEdit(NULL),
+ mbCompleteSheetSelected(sal_False)
+{
+ if (pViewShell)
+ {
+ pViewShell->AddAccessibilityObject(*this);
+ Window *pWin = pViewShell->GetWindowByPos(eSplitPos);
+ if( pWin )
+ {
+ pWin->AddChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener ));
+ USHORT nCount = pWin->GetChildCount();
+ for( sal_uInt16 i=0; i < nCount; ++i )
+ {
+ Window *pChildWin = pWin->GetChild( i );
+ if( pChildWin &&
+ AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
+ AddChild( pChildWin->GetAccessible(), sal_False );
+ }
+ }
+ if (pViewShell->GetViewData()->HasEditView( eSplitPos ))
+ {
+ uno::Reference<XAccessible> xAcc = new ScAccessibleEditObject(this, pViewShell->GetViewData()->GetEditView(eSplitPos),
+ pViewShell->GetWindowByPos(eSplitPos), GetCurrentCellName(), GetCurrentCellDescription(),
+ CellInEditMode);
+ AddChild(xAcc, sal_False);
+ }
+ }
+ maVisArea = GetVisibleArea_Impl();
+}
+
+void ScAccessibleDocument::Init()
+{
+ if(!mpChildrenShapes)
+ mpChildrenShapes = new ScChildrenShapes(this, mpViewShell, meSplitPos);
+}
+
+ScAccessibleDocument::~ScAccessibleDocument(void)
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessibleDocument::disposing()
+{
+ SolarMutexGuard aGuard;
+ FreeAccessibleSpreadsheet();
+ if (mpViewShell)
+ {
+ Window *pWin = mpViewShell->GetWindowByPos(meSplitPos);
+ if( pWin )
+ pWin->RemoveChildEventListener( LINK( this, ScAccessibleDocument, WindowChildEventListener ));
+
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+ if (mpChildrenShapes)
+ DELETEZ(mpChildrenShapes);
+
+ ScAccessibleDocumentBase::disposing();
+}
+
+void SAL_CALL ScAccessibleDocument::disposing( const lang::EventObject& /* Source */ )
+ throw (uno::RuntimeException)
+{
+ disposing();
+}
+
+ //===== SfxListener =====================================================
+
+IMPL_LINK( ScAccessibleDocument, WindowChildEventListener, VclSimpleEvent*, pEvent )
+{
+ DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
+ if ( pEvent && pEvent->ISA( VclWindowEvent ) )
+ {
+ VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
+ DBG_ASSERT( pVclEvent->GetWindow(), "Window???" );
+ switch ( pVclEvent->GetId() )
+ {
+ case VCLEVENT_WINDOW_SHOW: // send create on show for direct accessible children
+ {
+ Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() );
+ if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
+ {
+ AddChild( pChildWin->GetAccessible(), sal_True );
+ }
+ }
+ break;
+ case VCLEVENT_WINDOW_HIDE: // send destroy on hide for direct accessible children
+ {
+ Window* pChildWin = static_cast < Window * >( pVclEvent->GetData() );
+ if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
+ {
+ RemoveChild( pChildWin->GetAccessible(), sal_True );
+ }
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
+void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( ScAccGridWinFocusLostHint ) )
+ {
+ const ScAccGridWinFocusLostHint& rRef = (const ScAccGridWinFocusLostHint&)rHint;
+ if (rRef.GetOldGridWin() == meSplitPos)
+ {
+ if (mxTempAcc.is() && mpTempAccEdit)
+ mpTempAccEdit->LostFocus();
+ else if (mpAccessibleSpreadsheet)
+ mpAccessibleSpreadsheet->LostFocus();
+ else
+ CommitFocusLost();
+ }
+ }
+ else if (rHint.ISA( ScAccGridWinFocusGotHint ) )
+ {
+ const ScAccGridWinFocusGotHint& rRef = (const ScAccGridWinFocusGotHint&)rHint;
+ if (rRef.GetNewGridWin() == meSplitPos)
+ {
+ if (mxTempAcc.is() && mpTempAccEdit)
+ mpTempAccEdit->GotFocus();
+ else if (mpAccessibleSpreadsheet)
+ mpAccessibleSpreadsheet->GotFocus();
+ else
+ CommitFocusGained();
+ }
+ }
+ else if (rHint.ISA( SfxSimpleHint ))
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ // only notify if child exist, otherwise it is not necessary
+ if ((rRef.GetId() == SC_HINT_ACC_TABLECHANGED) &&
+ mpAccessibleSpreadsheet)
+ {
+ FreeAccessibleSpreadsheet();
+ if (mpChildrenShapes)
+ DELETEZ(mpChildrenShapes);
+
+ // #124567# Accessibility: Shapes / form controls after reload not accessible
+ if ( !mpChildrenShapes )
+ {
+ mpChildrenShapes = new ScChildrenShapes( this, mpViewShell, meSplitPos );
+ }
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::INVALIDATE_ALL_CHILDREN;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ CommitChange(aEvent); // all childs changed
+ }
+ else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
+ {
+ if (mpChildrenShapes)
+ mpChildrenShapes->SetDrawBroadcaster();
+ }
+ else if ((rRef.GetId() == SC_HINT_ACC_ENTEREDITMODE)) // this event comes only on creating edit field of a cell
+ {
+ if (mpViewShell && mpViewShell->GetViewData()->HasEditView(meSplitPos))
+ {
+ mpTempAccEdit = new ScAccessibleEditObject(this, mpViewShell->GetViewData()->GetEditView(meSplitPos),
+ mpViewShell->GetWindowByPos(meSplitPos), GetCurrentCellName(),
+ rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), CellInEditMode);
+ uno::Reference<XAccessible> xAcc = mpTempAccEdit;
+
+ AddChild(xAcc, sal_True);
+
+ if (mpAccessibleSpreadsheet)
+ mpAccessibleSpreadsheet->LostFocus();
+ else
+ CommitFocusLost();
+
+ mpTempAccEdit->GotFocus();
+ }
+ }
+ else if (rRef.GetId() == SC_HINT_ACC_LEAVEEDITMODE)
+ {
+ if (mxTempAcc.is())
+ {
+ if (mpTempAccEdit)
+ mpTempAccEdit->LostFocus();
+
+ mpTempAccEdit = NULL;
+ RemoveChild(mxTempAcc, sal_True);
+
+ if (mpAccessibleSpreadsheet)
+ mpAccessibleSpreadsheet->GotFocus();
+ else
+ CommitFocusGained();
+ }
+ }
+ else if ((rRef.GetId() == SC_HINT_ACC_VISAREACHANGED) || (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED))
+ {
+ Rectangle aOldVisArea(maVisArea);
+ maVisArea = GetVisibleArea_Impl();
+
+ if (maVisArea != aOldVisArea)
+ {
+ if (maVisArea.GetSize() != aOldVisArea.GetSize())
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);
+
+ if (mpAccessibleSpreadsheet)
+ mpAccessibleSpreadsheet->BoundingBoxChanged();
+ }
+ else if (mpAccessibleSpreadsheet)
+ {
+ mpAccessibleSpreadsheet->VisAreaChanged();
+ }
+ if (mpChildrenShapes)
+ mpChildrenShapes->VisAreaChanged();
+ }
+ }
+ }
+
+ ScAccessibleDocumentBase::Notify(rBC, rHint);
+}
+
+void SAL_CALL ScAccessibleDocument::selectionChanged( const lang::EventObject& /* aEvent */ )
+ throw (uno::RuntimeException)
+{
+ sal_Bool bSelectionChanged(sal_False);
+ if (mpAccessibleSpreadsheet)
+ {
+ sal_Bool bOldSelected(mbCompleteSheetSelected);
+ mbCompleteSheetSelected = IsTableSelected();
+ if (bOldSelected != mbCompleteSheetSelected)
+ {
+ mpAccessibleSpreadsheet->CompleteSelectionChanged(mbCompleteSheetSelected);
+ bSelectionChanged = sal_True;
+ }
+ }
+
+ if (mpChildrenShapes && mpChildrenShapes->SelectionChanged())
+ bSelectionChanged = sal_True;
+
+ if (bSelectionChanged)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);
+ }
+}
+
+ //===== XInterface =====================================================
+
+uno::Any SAL_CALL ScAccessibleDocument::queryInterface( uno::Type const & rType )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny (ScAccessibleDocumentImpl::queryInterface(rType));
+ return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessibleDocument::acquire()
+ throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessibleDocument::release()
+ throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+ //===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleDocument::getAccessibleAtPoint(
+ const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xAccessible = NULL;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpChildrenShapes)
+ xAccessible = mpChildrenShapes->GetAt(rPoint);
+ if(!xAccessible.is())
+ {
+ if (mxTempAcc.is())
+ {
+ uno::Reference< XAccessibleContext > xCont(mxTempAcc->getAccessibleContext());
+ uno::Reference< XAccessibleComponent > xComp(xCont, uno::UNO_QUERY);
+ if (xComp.is())
+ {
+ Rectangle aBound(VCLRectangle(xComp->getBounds()));
+ if (aBound.IsInside(VCLPoint(rPoint)))
+ xAccessible = mxTempAcc;
+ }
+ }
+ if (!xAccessible.is())
+ xAccessible = GetAccessibleSpreadsheet();
+ }
+ }
+ return xAccessible;
+}
+
+void SAL_CALL ScAccessibleDocument::grabFocus( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ {
+ xAccessibleComponent->grabFocus();
+ // grab only focus if it does not have the focus and it is not hidden
+ if (mpViewShell && mpViewShell->GetViewData() &&
+ (mpViewShell->GetViewData()->GetActivePart() != meSplitPos) &&
+ mpViewShell->GetWindowByPos(meSplitPos)->IsVisible())
+ {
+ mpViewShell->ActivatePart(meSplitPos);
+ }
+ }
+ }
+}
+
+ //===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+sal_Int32 SAL_CALL
+ ScAccessibleDocument::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nCount(1);
+ if (mpChildrenShapes)
+ nCount = mpChildrenShapes->GetCount(); // returns the count of the shapes inclusive the table
+
+ if (mxTempAcc.is())
+ ++nCount;
+
+ return nCount;
+}
+
+ /// Return the specified child or NULL if index is invalid.
+uno::Reference<XAccessible> SAL_CALL
+ ScAccessibleDocument::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException,
+ lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference<XAccessible> xAccessible;
+ if (nIndex >= 0)
+ {
+ sal_Int32 nCount(1);
+ if (mpChildrenShapes)
+ {
+ xAccessible = mpChildrenShapes->Get(nIndex); // returns NULL if it is the table or out of range
+ nCount = mpChildrenShapes->GetCount(); //there is always a table
+ }
+ if (!xAccessible.is())
+ {
+ if (nIndex < nCount)
+ xAccessible = GetAccessibleSpreadsheet();
+ else if (nIndex == nCount && mxTempAcc.is())
+ xAccessible = mxTempAcc;
+ }
+ }
+
+ if (!xAccessible.is())
+ throw lang::IndexOutOfBoundsException();
+
+ return xAccessible;
+}
+
+ /// Return the set of current states.
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessibleDocument::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ if (IsEditable(xParentStates))
+ pStateSet->AddState(AccessibleStateType::EDITABLE);
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+ ///===== XAccessibleSelection ===========================================
+
+void SAL_CALL
+ ScAccessibleDocument::selectAccessibleChild( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (mpChildrenShapes)
+ {
+ sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
+ if (mxTempAcc.is())
+ ++nCount;
+ if (nChildIndex < 0 || nChildIndex >= nCount)
+ throw lang::IndexOutOfBoundsException();
+
+ uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
+ if (xAccessible.is())
+ {
+ sal_Bool bWasTableSelected(IsTableSelected());
+
+ if (mpChildrenShapes)
+ mpChildrenShapes->Select(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high
+
+ if (bWasTableSelected)
+ mpViewShell->SelectAll();
+ }
+ else
+ {
+ if (mpViewShell)
+ mpViewShell->SelectAll();
+ }
+ }
+}
+
+sal_Bool SAL_CALL
+ ScAccessibleDocument::isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Bool bResult(sal_False);
+
+ if (mpChildrenShapes)
+ {
+ sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
+ if (mxTempAcc.is())
+ ++nCount;
+ if (nChildIndex < 0 || nChildIndex >= nCount)
+ throw lang::IndexOutOfBoundsException();
+
+ uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
+ if (xAccessible.is())
+ {
+ uno::Reference<drawing::XShape> xShape;
+ bResult = mpChildrenShapes->IsSelected(nChildIndex, xShape); // throws no lang::IndexOutOfBoundsException if Index is to high
+ }
+ else
+ {
+ if (mxTempAcc.is() && nChildIndex == nCount)
+ bResult = sal_True;
+ else
+ bResult = IsTableSelected();
+ }
+ }
+ return bResult;
+}
+
+void SAL_CALL
+ ScAccessibleDocument::clearAccessibleSelection( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (mpChildrenShapes)
+ mpChildrenShapes->DeselectAll(); //deselects all (also the table)
+}
+
+void SAL_CALL
+ ScAccessibleDocument::selectAllAccessibleChildren( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (mpChildrenShapes)
+ mpChildrenShapes->SelectAll();
+
+ // select table after shapes, because while selecting shapes the table will be deselected
+ if (mpViewShell)
+ {
+ mpViewShell->SelectAll();
+ }
+}
+
+sal_Int32 SAL_CALL
+ ScAccessibleDocument::getSelectedAccessibleChildCount( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nCount(0);
+
+ if (mpChildrenShapes)
+ nCount = mpChildrenShapes->GetSelectedCount();
+
+ if (IsTableSelected())
+ ++nCount;
+
+ if (mxTempAcc.is())
+ ++nCount;
+
+ return nCount;
+}
+
+uno::Reference<XAccessible > SAL_CALL
+ ScAccessibleDocument::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference<XAccessible> xAccessible;
+ if (mpChildrenShapes)
+ {
+ sal_Int32 nCount(getSelectedAccessibleChildCount()); //all shapes and the table
+ if (nSelectedChildIndex < 0 || nSelectedChildIndex >= nCount)
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Bool bTabMarked(IsTableSelected());
+
+ if (mpChildrenShapes)
+ xAccessible = mpChildrenShapes->GetSelected(nSelectedChildIndex, bTabMarked); // throws no lang::IndexOutOfBoundsException if Index is to high
+ if (mxTempAcc.is() && nSelectedChildIndex == nCount - 1)
+ xAccessible = mxTempAcc;
+ else if (bTabMarked)
+ xAccessible = GetAccessibleSpreadsheet();
+ }
+
+ DBG_ASSERT(xAccessible.is(), "here should always be an accessible object or a exception throwed");
+
+ return xAccessible;
+}
+
+void SAL_CALL
+ ScAccessibleDocument::deselectAccessibleChild( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (mpChildrenShapes)
+ {
+ sal_Int32 nCount(mpChildrenShapes->GetCount()); //all shapes and the table
+ if (mxTempAcc.is())
+ ++nCount;
+ if (nChildIndex < 0 || nChildIndex >= nCount)
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Bool bTabMarked(IsTableSelected());
+
+ uno::Reference < XAccessible > xAccessible = mpChildrenShapes->Get(nChildIndex);
+ if (xAccessible.is())
+ {
+ if (mpChildrenShapes)
+ mpChildrenShapes->Deselect(nChildIndex); // throws no lang::IndexOutOfBoundsException if Index is to high
+
+ if (bTabMarked)
+ mpViewShell->SelectAll(); // select the table again
+ }
+ else if (bTabMarked)
+ mpViewShell->Unmark();
+ }
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL
+ ScAccessibleDocument::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDocument"));
+}
+
+uno::Sequence< ::rtl::OUString> SAL_CALL
+ ScAccessibleDocument::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetDocumentView"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence< uno::Type > SAL_CALL ScAccessibleDocument::getTypes()
+ throw (uno::RuntimeException)
+{
+ return comphelper::concatSequences(ScAccessibleDocumentImpl::getTypes(), ScAccessibleContextBase::getTypes());
+}
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleDocument::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+///===== IAccessibleViewForwarder ========================================
+
+sal_Bool ScAccessibleDocument::IsValid (void) const
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose);
+}
+
+Rectangle ScAccessibleDocument::GetVisibleArea_Impl() const
+{
+ Rectangle aVisRect(GetBoundingBox());
+
+ Point aPoint(mpViewShell->GetViewData()->GetPixPos(meSplitPos)); // returns a negative Point
+ aPoint.setX(-aPoint.getX());
+ aPoint.setY(-aPoint.getY());
+ aVisRect.SetPos(aPoint);
+
+ ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
+ if (pWin)
+ aVisRect = pWin->PixelToLogic(aVisRect, pWin->GetDrawMapMode());
+
+ return aVisRect;
+}
+
+Rectangle ScAccessibleDocument::GetVisibleArea() const
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return maVisArea;
+}
+
+Point ScAccessibleDocument::LogicToPixel (const Point& rPoint) const
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ Point aPoint;
+ ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
+ if (pWin)
+ {
+ aPoint = pWin->LogicToPixel(rPoint, pWin->GetDrawMapMode());
+ aPoint += pWin->GetWindowExtentsRelative(NULL).TopLeft();
+ }
+ return aPoint;
+}
+
+Size ScAccessibleDocument::LogicToPixel (const Size& rSize) const
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ Size aSize;
+ ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
+ if (pWin)
+ aSize = pWin->LogicToPixel(rSize, pWin->GetDrawMapMode());
+ return aSize;
+}
+
+Point ScAccessibleDocument::PixelToLogic (const Point& rPoint) const
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ Point aPoint;
+ ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
+ if (pWin)
+ {
+ aPoint -= pWin->GetWindowExtentsRelative(NULL).TopLeft();
+ aPoint = pWin->PixelToLogic(rPoint, pWin->GetDrawMapMode());
+ }
+ return aPoint;
+}
+
+Size ScAccessibleDocument::PixelToLogic (const Size& rSize) const
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ Size aSize;
+ ScGridWindow* pWin = static_cast<ScGridWindow*>(mpViewShell->GetWindowByPos(meSplitPos));
+ if (pWin)
+ aSize = pWin->PixelToLogic(rSize, pWin->GetDrawMapMode());
+ return aSize;
+}
+
+ //===== internal ========================================================
+
+utl::AccessibleRelationSetHelper* ScAccessibleDocument::GetRelationSet(const ScAddress* pAddress) const
+{
+ utl::AccessibleRelationSetHelper* pRelationSet = NULL;
+ if (mpChildrenShapes)
+ pRelationSet = mpChildrenShapes->GetRelationSet(pAddress);
+ return pRelationSet;
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleDocument::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ rtl::OUString sDescription = String(ScResId(STR_ACC_DOC_DESCR));
+ return sDescription;
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleDocument::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ rtl::OUString sName = String(ScResId(STR_ACC_DOC_NAME));
+ sal_Int32 nNumber(sal_Int32(meSplitPos) + 1);
+ sName += rtl::OUString::valueOf(nNumber);
+ return sName;
+}
+
+Rectangle ScAccessibleDocument::GetBoundingBoxOnScreen() const
+ throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ aRect = pWindow->GetWindowExtentsRelative(NULL);
+ }
+ return aRect;
+}
+
+Rectangle ScAccessibleDocument::GetBoundingBox() const
+ throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
+ }
+ return aRect;
+}
+
+SCTAB ScAccessibleDocument::getVisibleTable() const
+{
+ SCTAB nVisibleTable(0);
+ if (mpViewShell && mpViewShell->GetViewData())
+ nVisibleTable = mpViewShell->GetViewData()->GetTabNo();
+ return nVisibleTable;
+}
+
+uno::Reference < XAccessible >
+ ScAccessibleDocument::GetAccessibleSpreadsheet()
+{
+ if (!mpAccessibleSpreadsheet && mpViewShell)
+ {
+ mpAccessibleSpreadsheet = new ScAccessibleSpreadsheet(this, mpViewShell, getVisibleTable(), meSplitPos);
+ mpAccessibleSpreadsheet->acquire();
+ mpAccessibleSpreadsheet->Init();
+ mbCompleteSheetSelected = IsTableSelected();
+ }
+ return mpAccessibleSpreadsheet;
+}
+
+void ScAccessibleDocument::FreeAccessibleSpreadsheet()
+{
+ if (mpAccessibleSpreadsheet)
+ {
+ mpAccessibleSpreadsheet->dispose();
+ mpAccessibleSpreadsheet->release();
+ mpAccessibleSpreadsheet = NULL;
+ }
+}
+
+sal_Bool ScAccessibleDocument::IsTableSelected() const
+{
+ sal_Bool bResult (sal_False);
+ if(mpViewShell)
+ {
+ SCTAB nTab(getVisibleTable());
+ //#103800#; use a copy of MarkData
+ ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
+ aMarkData.MarkToMulti();
+ if (aMarkData.IsAllMarked(ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))))
+ bResult = sal_True;
+ }
+ return bResult;
+}
+
+sal_Bool ScAccessibleDocument::IsDefunc(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+sal_Bool ScAccessibleDocument::IsEditable(
+ const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
+{
+ // what is with document protection or readonly documents?
+ return sal_True;
+}
+
+void ScAccessibleDocument::AddChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent)
+{
+ DBG_ASSERT(!mxTempAcc.is(), "this object should be removed before");
+ if (xAcc.is())
+ {
+ mxTempAcc = xAcc;
+ if( bFireEvent )
+ {
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext>(this);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.NewValue <<= mxTempAcc;
+ CommitChange( aEvent );
+ }
+ }
+}
+
+void ScAccessibleDocument::RemoveChild(const uno::Reference<XAccessible>& xAcc, sal_Bool bFireEvent)
+{
+ DBG_ASSERT(mxTempAcc.is(), "this object should be added before");
+ if (xAcc.is())
+ {
+ DBG_ASSERT(xAcc.get() == mxTempAcc.get(), "only the same object should be removed");
+ if( bFireEvent )
+ {
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext>(this);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.OldValue <<= mxTempAcc;
+ CommitChange( aEvent );
+ }
+ mxTempAcc = NULL;
+ }
+}
+
+rtl::OUString ScAccessibleDocument::GetCurrentCellName() const
+{
+ String sName( ScResId(STR_ACC_CELL_NAME) );
+ if (mpViewShell)
+ {
+ String sAddress;
+ // Document not needed, because only the cell address, but not the tablename is needed
+ mpViewShell->GetViewData()->GetCurPos().Format( sAddress, SCA_VALID, NULL );
+ sName.SearchAndReplaceAscii("%1", sAddress);
+ }
+ return rtl::OUString(sName);
+}
+
+rtl::OUString ScAccessibleDocument::GetCurrentCellDescription() const
+{
+ return rtl::OUString();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentBase.cxx b/sc/source/ui/Accessibility/AccessibleDocumentBase.cxx
new file mode 100644
index 000000000000..acc814b2bebb
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleDocumentBase.cxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleDocumentBase.hxx"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+ //===== internal ========================================================
+
+ScAccessibleDocumentBase::ScAccessibleDocumentBase(
+ const uno::Reference<XAccessible>& rxParent)
+ : ScAccessibleContextBase(rxParent, AccessibleRole::DOCUMENT)
+{
+}
+
+ScAccessibleDocumentBase::~ScAccessibleDocumentBase(void)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
new file mode 100644
index 000000000000..cc2fc0faeae5
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -0,0 +1,1891 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "AccessibleDocumentPagePreview.hxx"
+#include "AccessiblePreviewTable.hxx"
+#include "AccessiblePageHeader.hxx"
+#include "AccessibilityHints.hxx"
+#include "AccessibleText.hxx"
+#include "document.hxx"
+#include "prevwsh.hxx"
+#include "prevloc.hxx"
+#include "drwlayer.hxx"
+#include "editsrc.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "DrawModelBroadcaster.hxx"
+#include "docsh.hxx"
+#include "drawview.hxx"
+#include "preview.hxx"
+#include "postit.hxx"
+
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <tools/debug.hxx>
+#include <tools/gen.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/AccessibleTextHelper.hxx>
+#include <svx/AccessibleShape.hxx>
+#include <svx/ShapeTypeHandler.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <svx/unoshape.hxx>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <vcl/svapp.hxx>
+
+#include <vector>
+#include <list>
+#include <algorithm>
+#include <memory>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//=========================================================================
+
+typedef std::list< uno::Reference< XAccessible > > ScXAccList;
+
+
+struct ScAccNote
+{
+ String maNoteText;
+ Rectangle maRect;
+ ScAddress maNoteCell;
+ ::accessibility::AccessibleTextHelper* mpTextHelper;
+ sal_Int32 mnParaCount;
+ sal_Bool mbMarkNote;
+
+ ScAccNote() : mpTextHelper(NULL), mnParaCount(0) {}
+};
+
+class ScNotesChilds
+{
+public:
+ ScNotesChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc);
+ ~ScNotesChilds();
+ void Init(const Rectangle& rVisRect, sal_Int32 nOffset);
+
+ sal_Int32 GetChildsCount() const;
+ uno::Reference<XAccessible> GetChild(sal_Int32 nIndex) const;
+ uno::Reference<XAccessible> GetAt(const awt::Point& rPoint) const;
+
+ void DataChanged(const Rectangle& rVisRect);
+ void SetOffset(sal_Int32 nNewOffset);
+private:
+ ScPreviewShell* mpViewShell;
+ ScAccessibleDocumentPagePreview* mpAccDoc;
+ typedef std::vector<ScAccNote> ScAccNotes;
+ mutable ScAccNotes maNotes;
+ mutable ScAccNotes maMarks;
+ sal_Int32 mnParagraphs;
+ sal_Int32 mnOffset;
+
+ ::accessibility::AccessibleTextHelper* CreateTextHelper(const String& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, sal_Bool bMarkNote, sal_Int32 nChildOffset) const;
+ sal_Int32 AddNotes(const ScPreviewLocationData& rData, const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rNotes);
+
+ sal_Int8 CompareCell(const ScAddress& aCell1, const ScAddress& aCell2);
+ void CollectChilds(const ScAccNote& rNote, ScXAccList& rList);
+ sal_Int32 CheckChanges(const ScPreviewLocationData& rData, const Rectangle& rVisRect,
+ sal_Bool bMark, ScAccNotes& rOldNotes, ScAccNotes& rNewNotes,
+ ScXAccList& rOldParas, ScXAccList& rNewParas);
+
+ inline ScDocument* GetDocument() const;
+};
+
+ScNotesChilds::ScNotesChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc)
+ : mpViewShell(pViewShell),
+ mpAccDoc(pAccDoc),
+ mnParagraphs(0),
+ mnOffset(0)
+{
+}
+
+struct DeleteAccNote
+{
+ void operator()(ScAccNote& rNote)
+ {
+ if (rNote.mpTextHelper)
+ DELETEZ( rNote.mpTextHelper);
+ }
+};
+
+ScNotesChilds::~ScNotesChilds()
+{
+ std::for_each(maNotes.begin(), maNotes.end(), DeleteAccNote());
+ std::for_each(maMarks.begin(), maMarks.end(), DeleteAccNote());
+}
+
+::accessibility::AccessibleTextHelper* ScNotesChilds::CreateTextHelper(const String& rString, const Rectangle& rVisRect, const ScAddress& aCellPos, sal_Bool bMarkNote, sal_Int32 nChildOffset) const
+{
+ ::accessibility::AccessibleTextHelper* pTextHelper = NULL;
+
+ ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData
+ (new ScAccessibleNoteTextData(mpViewShell, rString, aCellPos, bMarkNote));
+ ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewHeaderCellTextData));
+
+ pTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource);
+
+ if (pTextHelper)
+ {
+ pTextHelper->SetEventSource(mpAccDoc);
+ pTextHelper->SetStartIndex(nChildOffset);
+ pTextHelper->SetOffset(rVisRect.TopLeft());
+ }
+
+ return pTextHelper;
+}
+
+sal_Int32 ScNotesChilds::AddNotes(const ScPreviewLocationData& rData, const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rNotes)
+{
+ sal_Int32 nCount = rData.GetNoteCountInRange(rVisRect, bMark);
+
+ rNotes.reserve(nCount);
+
+ sal_Int32 nParagraphs(0);
+ ScDocument* pDoc = GetDocument();
+ if (pDoc)
+ {
+ ScAccNote aNote;
+ aNote.mbMarkNote = bMark;
+ if (bMark)
+ aNote.mnParaCount = 1;
+ for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ if (rData.GetNoteInRange(rVisRect, nIndex, bMark, aNote.maNoteCell, aNote.maRect))
+ {
+ if (bMark)
+ {
+ // Document not needed, because only the cell address, but not the tablename is needed
+ aNote.maNoteCell.Format( aNote.maNoteText, SCA_VALID, NULL );
+ }
+ else
+ {
+ if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
+ aNote.maNoteText = pNote->GetText();
+ aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
+ if (aNote.mpTextHelper)
+ aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
+ }
+ nParagraphs += aNote.mnParaCount;
+ rNotes.push_back(aNote);
+ }
+ }
+ }
+ return nParagraphs;
+}
+
+void ScNotesChilds::Init(const Rectangle& rVisRect, sal_Int32 nOffset)
+{
+ if (mpViewShell && !mnParagraphs)
+ {
+ mnOffset = nOffset;
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+
+ mnParagraphs = AddNotes(rData, rVisRect, sal_False, maMarks);
+ mnParagraphs += AddNotes(rData, rVisRect, sal_True, maNotes);
+ }
+}
+
+sal_Int32 ScNotesChilds::GetChildsCount() const
+{
+ return mnParagraphs;
+}
+
+struct ScParaFound
+{
+ sal_Int32 mnIndex;
+ ScParaFound(sal_Int32 nIndex) : mnIndex(nIndex) {}
+ sal_Bool operator() (const ScAccNote& rNote)
+ {
+ sal_Bool bResult(sal_False);
+ if (rNote.mnParaCount > mnIndex)
+ bResult = sal_True;
+ else
+ mnIndex -= rNote.mnParaCount;
+ return bResult;
+ }
+};
+
+uno::Reference<XAccessible> ScNotesChilds::GetChild(sal_Int32 nIndex) const
+{
+ uno::Reference<XAccessible> xAccessible;
+
+ if (nIndex < mnParagraphs)
+ {
+ if (nIndex < static_cast<sal_Int32>(maMarks.size()))
+ {
+ ScAccNotes::iterator aEndItr = maMarks.end();
+ ScParaFound aParaFound(nIndex);
+ ScAccNotes::iterator aItr = std::find_if(maMarks.begin(), aEndItr, aParaFound);
+ if (aItr != aEndItr)
+ {
+ DBG_ASSERT((aItr->maNoteCell == maMarks[nIndex].maNoteCell) && (aItr->mbMarkNote == maMarks[nIndex].mbMarkNote), "wrong note found");
+ }
+ else
+ {
+ DBG_ERRORFILE("wrong note found");
+ }
+ if (!aItr->mpTextHelper)
+ aItr->mpTextHelper = CreateTextHelper(maMarks[nIndex].maNoteText, maMarks[nIndex].maRect, maMarks[nIndex].maNoteCell, maMarks[nIndex].mbMarkNote, nIndex + mnOffset); // the marks are the first and every mark has only one paragraph
+ xAccessible = aItr->mpTextHelper->GetChild(aParaFound.mnIndex + aItr->mpTextHelper->GetStartIndex());
+ }
+ else
+ {
+ nIndex -= maMarks.size();
+ ScAccNotes::iterator aEndItr = maNotes.end();
+ ScParaFound aParaFound(nIndex);
+ ScAccNotes::iterator aItr = std::find_if(maNotes.begin(), aEndItr, aParaFound);
+ if (aEndItr != aItr)
+ {
+ if (!aItr->mpTextHelper)
+ aItr->mpTextHelper = CreateTextHelper(aItr->maNoteText, aItr->maRect, aItr->maNoteCell, aItr->mbMarkNote, (nIndex - aParaFound.mnIndex) + mnOffset + maMarks.size());
+ xAccessible = aItr->mpTextHelper->GetChild(aParaFound.mnIndex + aItr->mpTextHelper->GetStartIndex());
+ }
+ }
+ }
+
+ return xAccessible;
+}
+
+struct ScPointFound
+{
+ Rectangle maPoint;
+ sal_Int32 mnParagraphs;
+ ScPointFound(const Point& rPoint) : maPoint(rPoint, Size(0, 0)), mnParagraphs(0) {}
+ sal_Bool operator() (const ScAccNote& rNote)
+ {
+ sal_Bool bResult(sal_False);
+ if (maPoint.IsInside(rNote.maRect))
+ bResult = sal_True;
+ else
+ mnParagraphs += rNote.mnParaCount;
+ return bResult;
+ }
+};
+
+uno::Reference<XAccessible> ScNotesChilds::GetAt(const awt::Point& rPoint) const
+{
+ uno::Reference<XAccessible> xAccessible;
+
+ ScPointFound aPointFound(Point(rPoint.X, rPoint.Y));
+
+ ScAccNotes::iterator aEndItr = maMarks.end();
+ ScAccNotes::iterator aItr = std::find_if(maMarks.begin(), aEndItr, aPointFound);
+ if (aEndItr == aItr)
+ {
+ aEndItr = maNotes.end();
+ aItr = std::find_if(maNotes.begin(), aEndItr, aPointFound);
+ }
+ if (aEndItr != aItr)
+ {
+ if (!aItr->mpTextHelper)
+ aItr->mpTextHelper = CreateTextHelper(aItr->maNoteText, aItr->maRect, aItr->maNoteCell, aItr->mbMarkNote, aPointFound.mnParagraphs + mnOffset);
+ xAccessible = aItr->mpTextHelper->GetAt(rPoint);
+ }
+
+ return xAccessible;
+}
+
+sal_Int8 ScNotesChilds::CompareCell(const ScAddress& aCell1, const ScAddress& aCell2)
+{
+ DBG_ASSERT(aCell1.Tab() == aCell2.Tab(), "the notes should be on the same table");
+ sal_Int8 nResult(0);
+ if (aCell1 != aCell2)
+ {
+ if (aCell1.Row() == aCell2.Row())
+ nResult = (aCell1.Col() < aCell2.Col()) ? -1 : 1;
+ else
+ nResult = (aCell1.Row() < aCell2.Row()) ? -1 : 1;
+ }
+ return nResult;
+}
+
+void ScNotesChilds::CollectChilds(const ScAccNote& rNote, ScXAccList& rList)
+{
+ if (rNote.mpTextHelper)
+ for (sal_Int32 i = 0; i < rNote.mnParaCount; ++i)
+ rList.push_back(rNote.mpTextHelper->GetChild(i + rNote.mpTextHelper->GetStartIndex()));
+}
+
+sal_Int32 ScNotesChilds::CheckChanges(const ScPreviewLocationData& rData,
+ const Rectangle& rVisRect, sal_Bool bMark, ScAccNotes& rOldNotes,
+ ScAccNotes& rNewNotes, ScXAccList& rOldParas, ScXAccList& rNewParas)
+{
+ sal_Int32 nCount = rData.GetNoteCountInRange(rVisRect, bMark);
+
+ rNewNotes.reserve(nCount);
+
+ sal_Int32 nParagraphs(0);
+ ScDocument* pDoc = GetDocument();
+ if (pDoc)
+ {
+ ScAccNote aNote;
+ aNote.mbMarkNote = bMark;
+ if (bMark)
+ aNote.mnParaCount = 1;
+ ScAccNotes::iterator aItr = rOldNotes.begin();
+ ScAccNotes::iterator aEndItr = rOldNotes.end();
+ sal_Bool bAddNote(sal_False);
+ for (sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ if (rData.GetNoteInRange(rVisRect, nIndex, bMark, aNote.maNoteCell, aNote.maRect))
+ {
+ if (bMark)
+ {
+ // Document not needed, because only the cell address, but not the tablename is needed
+ aNote.maNoteCell.Format( aNote.maNoteText, SCA_VALID, NULL );
+ }
+ else
+ {
+ if( ScPostIt* pNote = pDoc->GetNote( aNote.maNoteCell ) )
+ aNote.maNoteText = pNote->GetText();
+ }
+
+ sal_Int8 nCompare(-1); // if there are no more old childs it is always a new one
+ if (aItr != aEndItr)
+ nCompare = CompareCell(aNote.maNoteCell, aItr->maNoteCell);
+ if (nCompare == 0)
+ {
+ if (aNote.maNoteText == aItr->maNoteText)
+ {
+ aNote.mpTextHelper = aItr->mpTextHelper;
+ if (aNote.maRect != aItr->maRect) //neue VisArea setzen
+ {
+ aNote.mpTextHelper->SetOffset(aNote.maRect.TopLeft());
+ aNote.mpTextHelper->UpdateChildren();
+ //DBG_ASSERT(aItr->maRect.GetSize() == aNote.maRect.GetSize(), "size should be the same, because the text is not changed");
+ // could be changed, because only a part of the note is visible
+ }
+ }
+ else
+ {
+ aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
+ if (aNote.mpTextHelper)
+ aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
+ // collect removed childs
+ CollectChilds(*aItr, rOldParas);
+ DELETEZ(aItr->mpTextHelper);
+ // collect new childs
+ CollectChilds(aNote, rNewParas);
+ }
+ bAddNote = sal_True;
+ // not necessary, because this branch should not be reached if it is the end
+ //if (aItr != aEndItr)
+ ++aItr;
+ }
+ else if (nCompare < 0)
+ {
+ aNote.mpTextHelper = CreateTextHelper(aNote.maNoteText, aNote.maRect, aNote.maNoteCell, aNote.mbMarkNote, nParagraphs + mnOffset);
+ if (aNote.mpTextHelper)
+ aNote.mnParaCount = aNote.mpTextHelper->GetChildCount();
+ // collect new childs
+ CollectChilds(aNote, rNewParas);
+ bAddNote = sal_True;
+ }
+ else
+ {
+ // collect removed childs
+ CollectChilds(*aItr, rOldParas);
+ DELETEZ(aItr->mpTextHelper);
+
+ // no note to add
+ // not necessary, because this branch should not be reached if it is the end
+ //if (aItr != aEndItr)
+ ++aItr;
+ }
+ if (bAddNote)
+ {
+ nParagraphs += aNote.mnParaCount;
+ rNewNotes.push_back(aNote);
+ bAddNote = sal_False;
+ }
+ }
+ }
+ }
+ return nParagraphs;
+}
+
+struct ScChildGone
+{
+ ScAccessibleDocumentPagePreview* mpAccDoc;
+ ScChildGone(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {}
+ void operator() (const uno::Reference<XAccessible>& xAccessible) const
+ {
+ if (mpAccDoc)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc);
+ aEvent.OldValue <<= xAccessible;
+
+ mpAccDoc->CommitChange(aEvent); // gone child - event
+ }
+ }
+};
+
+struct ScChildNew
+{
+ ScAccessibleDocumentPagePreview* mpAccDoc;
+ ScChildNew(ScAccessibleDocumentPagePreview* pAccDoc) : mpAccDoc(pAccDoc) {}
+ void operator() (const uno::Reference<XAccessible>& xAccessible) const
+ {
+ if (mpAccDoc)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(mpAccDoc);
+ aEvent.NewValue <<= xAccessible;
+
+ mpAccDoc->CommitChange(aEvent); // new child - event
+ }
+ }
+};
+
+void ScNotesChilds::DataChanged(const Rectangle& rVisRect)
+{
+ if (mpViewShell && mpAccDoc)
+ {
+ ScXAccList aNewParas;
+ ScXAccList aOldParas;
+ ScAccNotes aNewMarks;
+ mnParagraphs = CheckChanges(mpViewShell->GetLocationData(), rVisRect, sal_True, maMarks, aNewMarks, aOldParas, aNewParas);
+ maMarks = aNewMarks;
+ ScAccNotes aNewNotes;
+ mnParagraphs += CheckChanges(mpViewShell->GetLocationData(), rVisRect, sal_False, maNotes, aNewNotes, aOldParas, aNewParas);
+ maNotes = aNewNotes;
+
+ std::for_each(aOldParas.begin(), aOldParas.end(), ScChildGone(mpAccDoc));
+ std::for_each(aNewParas.begin(), aNewParas.end(), ScChildNew(mpAccDoc));
+ }
+}
+
+struct ScChangeOffset
+{
+ sal_Int32 mnDiff;
+ ScChangeOffset(sal_Int32 nDiff) : mnDiff(nDiff) {}
+ void operator() (const ScAccNote& rNote)
+ {
+ if (rNote.mpTextHelper)
+ rNote.mpTextHelper->SetStartIndex(rNote.mpTextHelper->GetStartIndex() + mnDiff);
+ }
+};
+
+void ScNotesChilds::SetOffset(sal_Int32 nNewOffset)
+{
+ sal_Int32 nDiff(nNewOffset - mnOffset);
+ if (nDiff != 0)
+ {
+ std::for_each(maMarks.begin(), maMarks.end(), ScChangeOffset(nDiff));
+ std::for_each(maNotes.begin(), maNotes.end(), ScChangeOffset(nDiff));
+ mnOffset = nNewOffset;
+ }
+}
+
+inline ScDocument* ScNotesChilds::GetDocument() const
+{
+ ScDocument* pDoc = NULL;
+ if (mpViewShell)
+ pDoc = mpViewShell->GetDocument();
+ return pDoc;
+}
+
+class ScIAccessibleViewForwarder : public ::accessibility::IAccessibleViewForwarder
+{
+public:
+ ScIAccessibleViewForwarder();
+ ScIAccessibleViewForwarder(ScPreviewShell* pViewShell,
+ ScAccessibleDocumentPagePreview* pAccDoc,
+ const MapMode& aMapMode);
+ ~ScIAccessibleViewForwarder();
+
+ ///===== IAccessibleViewForwarder ========================================
+
+ virtual sal_Bool IsValid (void) const;
+ virtual Rectangle GetVisibleArea() const;
+ virtual Point LogicToPixel (const Point& rPoint) const;
+ virtual Size LogicToPixel (const Size& rSize) const;
+ virtual Point PixelToLogic (const Point& rPoint) const;
+ virtual Size PixelToLogic (const Size& rSize) const;
+
+private:
+ ScPreviewShell* mpViewShell;
+ ScAccessibleDocumentPagePreview* mpAccDoc;
+ MapMode maMapMode;
+ sal_Bool mbValid;
+};
+
+ScIAccessibleViewForwarder::ScIAccessibleViewForwarder()
+ : mbValid(sal_False)
+{
+}
+
+ScIAccessibleViewForwarder::ScIAccessibleViewForwarder(ScPreviewShell* pViewShell,
+ ScAccessibleDocumentPagePreview* pAccDoc,
+ const MapMode& aMapMode)
+ : mpViewShell(pViewShell),
+ mpAccDoc(pAccDoc),
+ maMapMode(aMapMode),
+ mbValid(sal_True)
+{
+}
+
+ScIAccessibleViewForwarder::~ScIAccessibleViewForwarder()
+{
+}
+
+///===== IAccessibleViewForwarder ========================================
+
+sal_Bool ScIAccessibleViewForwarder::IsValid (void) const
+{
+ SolarMutexGuard aGuard;
+ return mbValid;
+}
+
+Rectangle ScIAccessibleViewForwarder::GetVisibleArea() const
+{
+ SolarMutexGuard aGuard;
+ Rectangle aVisRect;
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ {
+ aVisRect.SetSize(pWin->GetOutputSizePixel());
+ aVisRect.SetPos(Point(0, 0));
+
+ aVisRect = pWin->PixelToLogic(aVisRect, maMapMode);
+ }
+
+ return aVisRect;
+}
+
+Point ScIAccessibleViewForwarder::LogicToPixel (const Point& rPoint) const
+{
+ SolarMutexGuard aGuard;
+ Point aPoint;
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin && mpAccDoc)
+ {
+ Rectangle aRect(mpAccDoc->GetBoundingBoxOnScreen());
+ aPoint = pWin->LogicToPixel(rPoint, maMapMode) + aRect.TopLeft();
+ }
+
+ return aPoint;
+}
+
+Size ScIAccessibleViewForwarder::LogicToPixel (const Size& rSize) const
+{
+ SolarMutexGuard aGuard;
+ Size aSize;
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ aSize = pWin->LogicToPixel(rSize, maMapMode);
+ return aSize;
+}
+
+Point ScIAccessibleViewForwarder::PixelToLogic (const Point& rPoint) const
+{
+ SolarMutexGuard aGuard;
+ Point aPoint;
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin && mpAccDoc)
+ {
+ Rectangle aRect(mpAccDoc->GetBoundingBoxOnScreen());
+ aPoint = pWin->PixelToLogic(rPoint - aRect.TopLeft(), maMapMode);
+ }
+ return aPoint;
+}
+
+Size ScIAccessibleViewForwarder::PixelToLogic (const Size& rSize) const
+{
+ SolarMutexGuard aGuard;
+ Size aSize;
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ aSize = pWin->PixelToLogic(rSize, maMapMode);
+ return aSize;
+}
+
+struct ScShapeChild
+{
+ ScShapeChild() : mpAccShape(NULL) {}
+ ScShapeChild(const ScShapeChild& rOld);
+ ~ScShapeChild();
+ mutable ::accessibility::AccessibleShape* mpAccShape;
+ com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxShape;
+ sal_Int32 mnRangeId;
+};
+
+ScShapeChild::ScShapeChild(const ScShapeChild& rOld)
+:
+mpAccShape(rOld.mpAccShape),
+mxShape(rOld.mxShape),
+mnRangeId(rOld.mnRangeId)
+{
+ if (mpAccShape)
+ mpAccShape->acquire();
+}
+
+ScShapeChild::~ScShapeChild()
+{
+ if (mpAccShape)
+ {
+ mpAccShape->dispose();
+ mpAccShape->release();
+ }
+}
+
+struct ScShapeChildLess
+{
+ sal_Bool operator()(const ScShapeChild& rChild1, const ScShapeChild& rChild2) const
+ {
+ sal_Bool bResult(sal_False);
+ if (rChild1.mxShape.is() && rChild2.mxShape.is())
+ bResult = (rChild1.mxShape.get() < rChild2.mxShape.get());
+ return bResult;
+ }
+};
+
+typedef std::vector<ScShapeChild> ScShapeChildVec;
+
+struct ScShapeRange
+{
+ ScShapeChildVec maBackShapes;
+ ScShapeChildVec maForeShapes; // inclusive internal shapes
+ ScShapeChildVec maControls;
+ Rectangle maPixelRect;
+ MapMode maMapMode;
+ ScIAccessibleViewForwarder maViewForwarder;
+};
+
+typedef std::vector<ScShapeRange> ScShapeRangeVec;
+
+class ScShapeChilds : public SfxListener,
+ public ::accessibility::IAccessibleParent
+{
+public:
+ ScShapeChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc);
+ ~ScShapeChilds();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== IAccessibleParent ==============================================
+
+ virtual sal_Bool ReplaceChild (
+ ::accessibility::AccessibleShape* pCurrentChild,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& _rxShape,
+ const long _nIndex,
+ const ::accessibility::AccessibleShapeTreeInfo& _rShapeTreeInfo
+ ) throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== Internal ========================================================
+
+ void Init();
+
+ sal_Int32 GetBackShapeCount() const;
+ uno::Reference<XAccessible> GetBackShape(sal_Int32 nIndex) const;
+ sal_Int32 GetForeShapeCount() const;
+ uno::Reference<XAccessible> GetForeShape(sal_Int32 nIndex) const;
+ sal_Int32 GetControlCount() const;
+ uno::Reference<XAccessible> GetControl(sal_Int32 nIndex) const;
+ uno::Reference<XAccessible> GetForegroundShapeAt(const awt::Point& rPoint) const; // inclusive controls
+ uno::Reference<XAccessible> GetBackgroundShapeAt(const awt::Point& rPoint) const;
+
+ void DataChanged();
+ void VisAreaChanged() const;
+
+ void SetDrawBroadcaster();
+private:
+ ScAccessibleDocumentPagePreview* mpAccDoc;
+ ScPreviewShell* mpViewShell;
+ ScShapeRangeVec maShapeRanges;
+
+ void FindChanged(ScShapeChildVec& aOld, ScShapeChildVec& aNew) const;
+ void FindChanged(ScShapeRange& aOld, ScShapeRange& aNew) const;
+ ::accessibility::AccessibleShape* GetAccShape(const ScShapeChild& rShape) const;
+ ::accessibility::AccessibleShape* GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const;
+ void FillShapes(const Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId);
+
+// void AddShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID);
+// void RemoveShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID);
+ SdrPage* GetDrawPage() const;
+};
+
+ScShapeChilds::ScShapeChilds(ScPreviewShell* pViewShell, ScAccessibleDocumentPagePreview* pAccDoc)
+ :
+ mpAccDoc(pAccDoc),
+ mpViewShell(pViewShell),
+ maShapeRanges(SC_PREVIEW_MAXRANGES)
+{
+ if (pViewShell)
+ {
+ SfxBroadcaster* pDrawBC = pViewShell->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ StartListening(*pDrawBC);
+ }
+}
+
+ScShapeChilds::~ScShapeChilds()
+{
+ if (mpViewShell)
+ {
+ SfxBroadcaster* pDrawBC = mpViewShell->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ EndListening(*pDrawBC);
+ }
+}
+
+void ScShapeChilds::SetDrawBroadcaster()
+{
+ if (mpViewShell)
+ {
+ SfxBroadcaster* pDrawBC = mpViewShell->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ StartListening(*pDrawBC, TRUE);
+ }
+}
+
+void ScShapeChilds::Notify(SfxBroadcaster&, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SdrHint ) )
+ {
+ const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
+ if (pSdrHint)
+ {
+ SdrObject* pObj = const_cast<SdrObject*>(pSdrHint->GetObject());
+ if (pObj && (pObj->GetPage() == GetDrawPage()))
+ {
+ switch (pSdrHint->GetKind())
+ {
+ case HINT_OBJCHG : // Objekt geaendert
+ {
+ }
+ break;
+ // no longer necessary
+/* case HINT_OBJINSERTED : // Neues Zeichenobjekt eingefuegt
+ {
+ uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
+ if (xShape.is())
+ AddShape(xShape, pObj->GetLayer());
+ }
+ break;
+ case HINT_OBJREMOVED : // Zeichenobjekt aus Liste entfernt
+ {
+ uno::Reference<drawing::XShape> xShape (pObj->getUnoShape(), uno::UNO_QUERY);
+ if (xShape.is())
+ RemoveShape(xShape, pObj->GetLayer());
+ }
+ break;*/
+ default :
+ {
+ // other events are not interesting
+ }
+ break;
+ }
+ }
+ }
+ }
+}
+
+void ScShapeChilds::FindChanged(ScShapeChildVec& rOld, ScShapeChildVec& rNew) const
+{
+ ScShapeChildVec::iterator aOldItr = rOld.begin();
+ ScShapeChildVec::iterator aOldEnd = rOld.end();
+ ScShapeChildVec::const_iterator aNewItr = rNew.begin();
+ ScShapeChildVec::const_iterator aNewEnd = rNew.begin();
+ uno::Reference<XAccessible> xAcc;
+ while ((aNewItr != aNewEnd) && (aOldItr != aOldEnd))
+ {
+ if (aNewItr->mxShape.get() == aOldItr->mxShape.get())
+ {
+ ++aOldItr;
+ ++aNewItr;
+ }
+ else if (aNewItr->mxShape.get() < aOldItr->mxShape.get())
+ {
+ xAcc = GetAccShape(*aNewItr);
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.NewValue <<= xAcc;
+ mpAccDoc->CommitChange(aEvent);
+ ++aNewItr;
+ }
+ else
+ {
+ xAcc = GetAccShape(*aOldItr);
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.OldValue <<= xAcc;
+ mpAccDoc->CommitChange(aEvent);
+ ++aOldItr;
+ }
+ }
+ while (aOldItr != aOldEnd)
+ {
+ xAcc = GetAccShape(*aOldItr);
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.OldValue <<= xAcc;
+ mpAccDoc->CommitChange(aEvent);
+ ++aOldItr;
+ }
+ while (aNewItr != aNewEnd)
+ {
+ xAcc = GetAccShape(*aNewItr);
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.NewValue <<= xAcc;
+ mpAccDoc->CommitChange(aEvent);
+ ++aNewItr;
+ }
+}
+
+void ScShapeChilds::FindChanged(ScShapeRange& rOld, ScShapeRange& rNew) const
+{
+ FindChanged(rOld.maBackShapes, rNew.maBackShapes);
+ FindChanged(rOld.maForeShapes, rNew.maForeShapes);
+ FindChanged(rOld.maControls, rNew.maControls);
+}
+
+void ScShapeChilds::DataChanged()
+{
+ ScShapeRangeVec aOldShapeRanges(maShapeRanges);
+ maShapeRanges.clear();
+ maShapeRanges.resize(SC_PREVIEW_MAXRANGES);
+ Init();
+ for (sal_Int32 i = 0; i < SC_PREVIEW_MAXRANGES; ++i)
+ {
+ FindChanged(aOldShapeRanges[i], maShapeRanges[i]);
+ }
+}
+
+struct ScVisAreaChanged
+{
+ const ScIAccessibleViewForwarder* mpViewForwarder;
+ ScVisAreaChanged(const ScIAccessibleViewForwarder* pViewForwarder) : mpViewForwarder(pViewForwarder) {}
+ void operator() (const ScShapeChild& rAccShapeData) const
+ {
+ if (rAccShapeData.mpAccShape)
+ {
+ rAccShapeData.mpAccShape->ViewForwarderChanged(::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA, mpViewForwarder);
+ }
+ }
+};
+
+void ScShapeChilds::VisAreaChanged() const
+{
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
+ while (aItr != aEndItr)
+ {
+ ScVisAreaChanged aVisAreaChanged(&(aItr->maViewForwarder));
+ std::for_each(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), aVisAreaChanged);
+ std::for_each(aItr->maControls.begin(), aItr->maControls.end(), aVisAreaChanged);
+ std::for_each(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), aVisAreaChanged);
+ ++aItr;
+ }
+}
+
+ ///===== IAccessibleParent ==============================================
+
+sal_Bool ScShapeChilds::ReplaceChild (::accessibility::AccessibleShape* /* pCurrentChild */,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& /* _rxShape */,
+ const long /* _nIndex */, const ::accessibility::AccessibleShapeTreeInfo& /* _rShapeTreeInfo */)
+ throw (uno::RuntimeException)
+{
+ DBG_ERRORFILE("should not be called in the page preview");
+ return sal_False;
+}
+
+ ///===== Internal ========================================================
+
+void ScShapeChilds::Init()
+{
+ if(mpViewShell)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ MapMode aMapMode;
+ Rectangle aPixelPaintRect;
+ sal_uInt8 nRangeId;
+ sal_uInt16 nCount(rData.GetDrawRanges());
+ for (sal_uInt16 i = 0; i < nCount; ++i)
+ {
+ rData.GetDrawRange(i, aPixelPaintRect, aMapMode, nRangeId);
+ FillShapes(aPixelPaintRect, aMapMode, nRangeId);
+ }
+ }
+}
+
+sal_Int32 ScShapeChilds::GetBackShapeCount() const
+{
+ sal_Int32 nCount(0);
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
+ nCount += aItr->maBackShapes.size();
+ return nCount;
+}
+
+uno::Reference<XAccessible> ScShapeChilds::GetBackShape(sal_Int32 nIndex) const
+{
+ uno::Reference<XAccessible> xAccessible;
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
+ while ((aItr != aEndItr) && !xAccessible.is())
+ {
+ sal_Int32 nCount(aItr->maBackShapes.size());
+ if(nIndex < nCount)
+ xAccessible = GetAccShape(aItr->maBackShapes, nIndex);
+ else
+ ++aItr;
+ nIndex -= nCount;
+ }
+
+ if (nIndex >= 0)
+ throw lang::IndexOutOfBoundsException();
+
+ return xAccessible;
+}
+
+sal_Int32 ScShapeChilds::GetForeShapeCount() const
+{
+ sal_Int32 nCount(0);
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
+ nCount += aItr->maForeShapes.size();
+ return nCount;
+}
+
+uno::Reference<XAccessible> ScShapeChilds::GetForeShape(sal_Int32 nIndex) const
+{
+ uno::Reference<XAccessible> xAccessible;
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
+ while ((aItr != aEndItr) && !xAccessible.is())
+ {
+ sal_Int32 nCount(aItr->maForeShapes.size());
+ if(nIndex < nCount)
+ xAccessible = GetAccShape(aItr->maForeShapes, nIndex);
+ else
+ ++aItr;
+ nIndex -= nCount;
+ }
+
+ if (nIndex >= 0)
+ throw lang::IndexOutOfBoundsException();
+
+ return xAccessible;
+}
+
+sal_Int32 ScShapeChilds::GetControlCount() const
+{
+ sal_Int32 nCount(0);
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ for ( ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin(); aItr != aEndItr; ++aItr )
+ nCount += aItr->maControls.size();
+ return nCount;
+}
+
+uno::Reference<XAccessible> ScShapeChilds::GetControl(sal_Int32 nIndex) const
+{
+ uno::Reference<XAccessible> xAccessible;
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
+ while ((aItr != aEndItr) && !xAccessible.is())
+ {
+ sal_Int32 nCount(aItr->maControls.size());
+ if(nIndex < nCount)
+ xAccessible = GetAccShape(aItr->maControls, nIndex);
+ else
+ ++aItr;
+ nIndex -= nCount;
+ }
+
+ if (nIndex >= 0)
+ throw lang::IndexOutOfBoundsException();
+
+ return xAccessible;
+}
+
+struct ScShapePointFound
+{
+ Point maPoint;
+ ScShapePointFound(const awt::Point& rPoint) : maPoint(VCLPoint(rPoint)) {}
+ sal_Bool operator() (const ScShapeChild& rShape)
+ {
+ sal_Bool bResult(sal_False);
+ if ((VCLRectangle(rShape.mpAccShape->getBounds())).IsInside(maPoint))
+ bResult = sal_True;
+ return bResult;
+ }
+};
+
+uno::Reference<XAccessible> ScShapeChilds::GetForegroundShapeAt(const awt::Point& rPoint) const //inclusive Controls
+{
+ uno::Reference<XAccessible> xAcc;
+
+ ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ while((aItr != aEndItr) && !xAcc.is())
+ {
+ ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maForeShapes.begin(), aItr->maForeShapes.end(), ScShapePointFound(rPoint));
+ if (aFindItr != aItr->maForeShapes.end())
+ xAcc = GetAccShape(*aFindItr);
+ else
+ {
+ ScShapeChildVec::const_iterator aCtrlItr = std::find_if(aItr->maControls.begin(), aItr->maControls.end(), ScShapePointFound(rPoint));
+ if (aCtrlItr != aItr->maControls.end())
+ xAcc = GetAccShape(*aCtrlItr);
+ else
+ ++aItr;
+ }
+ }
+
+ return xAcc;
+}
+
+uno::Reference<XAccessible> ScShapeChilds::GetBackgroundShapeAt(const awt::Point& rPoint) const
+{
+ uno::Reference<XAccessible> xAcc;
+
+ ScShapeRangeVec::const_iterator aItr = maShapeRanges.begin();
+ ScShapeRangeVec::const_iterator aEndItr = maShapeRanges.end();
+ while((aItr != aEndItr) && !xAcc.is())
+ {
+ ScShapeChildVec::const_iterator aFindItr = std::find_if(aItr->maBackShapes.begin(), aItr->maBackShapes.end(), ScShapePointFound(rPoint));
+ if (aFindItr != aItr->maBackShapes.end())
+ xAcc = GetAccShape(*aFindItr);
+ else
+ ++aItr;
+ }
+
+ return xAcc;
+}
+
+::accessibility::AccessibleShape* ScShapeChilds::GetAccShape(const ScShapeChild& rShape) const
+{
+ if (!rShape.mpAccShape)
+ {
+ ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
+ ::accessibility::AccessibleShapeInfo aShapeInfo(rShape.mxShape, mpAccDoc, const_cast<ScShapeChilds*>(this));
+
+ if (mpViewShell)
+ {
+ ::accessibility::AccessibleShapeTreeInfo aShapeTreeInfo;
+ aShapeTreeInfo.SetSdrView(mpViewShell->GetPreview()->GetDrawView());
+ aShapeTreeInfo.SetController(NULL);
+ aShapeTreeInfo.SetWindow(mpViewShell->GetWindow());
+ aShapeTreeInfo.SetViewForwarder(&(maShapeRanges[rShape.mnRangeId].maViewForwarder));
+ rShape.mpAccShape = rShapeHandler.CreateAccessibleObject(aShapeInfo, aShapeTreeInfo);
+ if (rShape.mpAccShape)
+ {
+ rShape.mpAccShape->acquire();
+ rShape.mpAccShape->Init();
+ }
+ }
+ }
+ return rShape.mpAccShape;
+}
+
+::accessibility::AccessibleShape* ScShapeChilds::GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const
+{
+ return (GetAccShape(rShapes[nIndex]));
+}
+
+void ScShapeChilds::FillShapes(const Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId)
+{
+ DBG_ASSERT(nRangeId < maShapeRanges.size(), "this is not a valid range for draw objects");
+ SdrPage* pPage = GetDrawPage();
+ Window* pWin = mpViewShell->GetWindow();
+ if (pPage && pWin)
+ {
+ sal_Bool bForeAdded(sal_False);
+ sal_Bool bBackAdded(sal_False);
+ sal_Bool bControlAdded(sal_False);
+ Rectangle aClippedPixelPaintRect(aPixelPaintRect);
+ if (mpAccDoc)
+ {
+ Rectangle aRect2(Point(0,0), mpAccDoc->GetBoundingBoxOnScreen().GetSize());
+ aClippedPixelPaintRect = aPixelPaintRect.GetIntersection(aRect2);
+ }
+ maShapeRanges[nRangeId].maPixelRect = aClippedPixelPaintRect;
+ maShapeRanges[nRangeId].maMapMode = aMapMode;
+ ScIAccessibleViewForwarder aViewForwarder(mpViewShell, mpAccDoc, aMapMode);
+ maShapeRanges[nRangeId].maViewForwarder = aViewForwarder;
+ sal_uInt32 nCount(pPage->GetObjCount());
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ SdrObject* pObj = pPage->GetObj(i);
+ if (pObj)
+ {
+ uno::Reference< drawing::XShape > xShape(pObj->getUnoShape(), uno::UNO_QUERY);
+ if (xShape.is())
+ {
+ Rectangle aRect(pWin->LogicToPixel(VCLPoint(xShape->getPosition()), aMapMode), pWin->LogicToPixel(VCLSize(xShape->getSize()), aMapMode));
+ if(!aClippedPixelPaintRect.GetIntersection(aRect).IsEmpty())
+ {
+ ScShapeChild aShape;
+ aShape.mxShape = xShape;
+ aShape.mnRangeId = nRangeId;
+ switch (pObj->GetLayer())
+ {
+ case SC_LAYER_INTERN:
+ case SC_LAYER_FRONT:
+ {
+ maShapeRanges[nRangeId].maForeShapes.push_back(aShape);
+ bForeAdded = sal_True;
+ }
+ break;
+ case SC_LAYER_BACK:
+ {
+ maShapeRanges[nRangeId].maBackShapes.push_back(aShape);
+ bBackAdded = sal_True;
+ }
+ break;
+ case SC_LAYER_CONTROLS:
+ {
+ maShapeRanges[nRangeId].maControls.push_back(aShape);
+ bControlAdded = sal_True;
+ }
+ break;
+ default:
+ {
+ DBG_ERRORFILE("I don't know this layer.");
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (bForeAdded)
+ std::sort(maShapeRanges[nRangeId].maForeShapes.begin(), maShapeRanges[nRangeId].maForeShapes.end(),ScShapeChildLess());
+ if (bBackAdded)
+ std::sort(maShapeRanges[nRangeId].maBackShapes.begin(), maShapeRanges[nRangeId].maBackShapes.end(),ScShapeChildLess());
+ if (bControlAdded)
+ std::sort(maShapeRanges[nRangeId].maControls.begin(), maShapeRanges[nRangeId].maControls.end(),ScShapeChildLess());
+ }
+}
+
+
+/*void ScShapeChilds::AddShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID)
+{
+ uno::Reference < XAccessible > xNew;
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ {
+ ScShapeRangeVec::iterator aEndItr = maShapeRanges.end();
+ ScShapeRangeVec::iterator aItr = maShapeRanges.begin();
+ sal_Bool bNotify(sal_False);
+ uno::Reference <XAccessible> xAcc;
+ while (aItr != aEndItr)
+ {
+ Rectangle aLogicPaintRect(pWin->PixelToLogic(aItr->maPixelRect, aItr->maMapMode));
+ Rectangle aRect(VCLPoint(xShape->getPosition()), VCLSize(xShape->getSize()));
+ if(!aRect.GetIntersection(aLogicPaintRect).IsEmpty())
+ {
+ ScShapeChild aShape;
+ aShape.mxShape = xShape;
+ switch (aLayerID)
+ {
+ case SC_LAYER_INTERN:
+ case SC_LAYER_FRONT:
+ {
+ SetAnchor(aShape);
+ aItr->maForeShapes.push_back(aShape);
+ std::sort(aItr->maForeShapes.begin(), aItr->maForeShapes.end(),ScShapeChildLess());
+
+ }
+ break;
+ case SC_LAYER_BACK:
+ {
+ aItr->maBackShapes.push_back(aShape);
+ std::sort(aItr->maBackShapes.begin(), aItr->maBackShapes.end(),ScShapeChildLess());
+ }
+ break;
+ case SC_LAYER_CONTROLS:
+ {
+ SetAnchor(aShape);
+ aItr->maControls.push_back(aShape);
+ std::sort(aItr->maControls.begin(), aItr->maControls.end(),ScShapeChildLess());
+ }
+ break;
+ default:
+ {
+ DBG_ERRORFILE("I don't know this layer.");
+ }
+ break;
+ }
+ if (bNotify)
+ {
+ xAcc = GetAccShape(aShape);
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.NewValue <<= xAcc;
+ mpAccDoc->CommitChange(aEvent);
+ bNotify = sal_False;
+ }
+ xAcc = NULL;
+ }
+ ++aItr;
+ }
+ }
+}*/
+
+/*sal_Bool HaveToNotify(uno::Reference<XAccessible>& xAcc, ScShapeChildVec::iterator aItr)
+{
+ sal_Bool bResult(sal_False);
+ if (aItr->mpAccShape)
+ {
+ bResult = sal_True;
+ xAcc = aItr->mpAccShape;
+ }
+ else
+ DBG_ERRORFILE("No Accessible object found. Don't know how to notify.");
+ return bResult;
+}*/
+
+/*void ScShapeChilds::RemoveShape(const uno::Reference<drawing::XShape>& xShape, SdrLayerID aLayerID)
+{
+ ScShapeRangeVec::iterator aEndItr = maShapeRanges.end();
+ ScShapeRangeVec::iterator aItr = maShapeRanges.begin();
+ ScShapeChildVec::iterator aEraseItr;
+ sal_Bool bNotify(sal_False);
+ uno::Reference <XAccessible> xAcc;
+ while (aItr != aEndItr)
+ {
+ switch (aLayerID)
+ {
+ case SC_LAYER_INTERN:
+ case SC_LAYER_FRONT:
+ {
+ if (FindShape(aItr->maForeShapes, xShape, aEraseItr))
+ {
+ bNotify = HaveToNotify(xAcc, aEraseItr);
+ aItr->maForeShapes.erase(aEraseItr);
+ }
+ }
+ break;
+ case SC_LAYER_BACK:
+ {
+ if (FindShape(aItr->maBackShapes, xShape, aEraseItr))
+ {
+ bNotify = HaveToNotify(xAcc, aEraseItr);
+ aItr->maBackShapes.erase(aEraseItr);
+ }
+ }
+ break;
+ case SC_LAYER_CONTROLS:
+ {
+ if (FindShape(aItr->maControls, xShape, aEraseItr))
+ {
+ bNotify = HaveToNotify(xAcc, aEraseItr);
+ aItr->maControls.erase(aEraseItr);
+ }
+ }
+ break;
+ default:
+ {
+ DBG_ERRORFILE("I don't know this layer.");
+ }
+ break;
+ }
+ if (bNotify)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.Source = uno::Reference<XAccessibleContext> (mpAccDoc);
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.OldValue <<= xAcc;
+ mpAccDoc->CommitChange(aEvent);
+ bNotify = sal_False;
+ }
+ xAcc = NULL;
+ ++aItr;
+ }
+}*/
+
+SdrPage* ScShapeChilds::GetDrawPage() const
+{
+ SCTAB nTab( mpViewShell->GetLocationData().GetPrintTab() );
+ SdrPage* pDrawPage = NULL;
+ if (mpViewShell)
+ {
+ ScDocument* pDoc = mpViewShell->GetDocument();
+ if (pDoc && pDoc->GetDrawLayer())
+ {
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
+ pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
+ }
+ }
+ return pDrawPage;
+}
+
+struct ScPagePreviewCountData
+{
+ // order is background shapes, header, table or notes, footer, foreground shapes, controls
+
+ Rectangle aVisRect;
+ long nBackShapes;
+ long nHeaders;
+ long nTables;
+ long nNoteParagraphs;
+ long nFooters;
+ long nForeShapes;
+ long nControls;
+
+ ScPagePreviewCountData( const ScPreviewLocationData& rData, Window* pSizeWindow,
+ ScNotesChilds* pNotesChilds, ScShapeChilds* pShapeChilds );
+
+ long GetTotal() const
+ {
+ return nBackShapes + nHeaders + nTables + nNoteParagraphs + nFooters + nForeShapes + nControls;
+ }
+};
+
+ScPagePreviewCountData::ScPagePreviewCountData( const ScPreviewLocationData& rData,
+ Window* pSizeWindow, ScNotesChilds* pNotesChilds,
+ ScShapeChilds* pShapeChilds) :
+ nBackShapes( 0 ),
+ nHeaders( 0 ),
+ nTables( 0 ),
+ nNoteParagraphs( 0 ),
+ nFooters( 0 ),
+ nForeShapes( 0 ),
+ nControls( 0 )
+{
+ Size aOutputSize;
+ if ( pSizeWindow )
+ aOutputSize = pSizeWindow->GetOutputSizePixel();
+ Point aPoint;
+ aVisRect = Rectangle( aPoint, aOutputSize );
+
+ Rectangle aObjRect;
+
+ if ( rData.GetHeaderPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) )
+ nHeaders = 1;
+
+ if ( rData.GetFooterPosition( aObjRect ) && aObjRect.IsOver( aVisRect ) )
+ nFooters = 1;
+
+ if ( rData.HasCellsInRange( aVisRect ) )
+ nTables = 1;
+
+ //! shapes...
+ nBackShapes = pShapeChilds->GetBackShapeCount();
+ nForeShapes = pShapeChilds->GetForeShapeCount();
+ nControls = pShapeChilds->GetControlCount();
+
+ // there are only notes if there is no table
+ if (nTables == 0)
+ nNoteParagraphs = pNotesChilds->GetChildsCount();
+}
+
+//===== internal ========================================================
+
+ScAccessibleDocumentPagePreview::ScAccessibleDocumentPagePreview(
+ const uno::Reference<XAccessible>& rxParent, ScPreviewShell* pViewShell ) :
+ ScAccessibleDocumentBase(rxParent),
+ mpViewShell(pViewShell),
+ mpNotesChilds(NULL),
+ mpShapeChilds(NULL),
+ mpTable(NULL),
+ mpHeader(NULL),
+ mpFooter(NULL)
+{
+ if (pViewShell)
+ pViewShell->AddAccessibilityObject(*this);
+
+// GetNotesChilds(); not neccessary and reduces the creation performance
+// GetShapeChilds();
+}
+
+ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview(void)
+{
+ if (!ScAccessibleDocumentBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpTable)
+ {
+ mpTable->release();
+ mpTable = NULL;
+ }
+ if (mpHeader)
+ {
+ mpHeader->release();
+ mpHeader = NULL;
+ }
+ if (mpFooter)
+ {
+ mpFooter->release();
+ mpFooter = NULL;
+ }
+
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+
+ // #100593# no need to Dispose the AccessibleTextHelper,
+ // as long as mpNotesChilds are destructed here
+ if (mpNotesChilds)
+ DELETEZ(mpNotesChilds);
+
+ if (mpShapeChilds)
+ DELETEZ(mpShapeChilds);
+
+ ScAccessibleDocumentBase::disposing();
+}
+
+//===== SfxListener =====================================================
+
+void ScAccessibleDocumentPagePreview::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ) )
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ // only notify if child exist, otherwise it is not necessary
+ if ((rRef.GetId() == SC_HINT_DATACHANGED))
+ {
+ if (mpTable) // if there is no table there is nothing to notify, because no one recongnizes the change
+ {
+ {
+ uno::Reference<XAccessible> xAcc = mpTable;
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.OldValue <<= xAcc;
+ CommitChange(aEvent);
+ }
+
+ mpTable->dispose();
+ mpTable->release();
+ mpTable = NULL;
+ }
+
+ Size aOutputSize;
+ Window* pSizeWindow = mpViewShell->GetWindow();
+ if ( pSizeWindow )
+ aOutputSize = pSizeWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+ GetNotesChilds()->DataChanged(aVisRect);
+
+ GetShapeChilds()->DataChanged();
+
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
+
+ if (aCount.nTables > 0)
+ {
+ //! order is background shapes, header, table or notes, footer, foreground shapes, controls
+ sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
+
+ mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
+ mpTable->acquire();
+ mpTable->Init();
+
+ {
+ uno::Reference<XAccessible> xAcc = mpTable;
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.NewValue <<= xAcc;
+ CommitChange(aEvent);
+ }
+ }
+ }
+ else if (rRef.GetId() == SC_HINT_ACC_MAKEDRAWLAYER)
+ {
+ GetShapeChilds()->SetDrawBroadcaster();
+ }
+ else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
+ {
+ Size aOutputSize;
+ Window* pSizeWindow = mpViewShell->GetWindow();
+ if ( pSizeWindow )
+ aOutputSize = pSizeWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+ GetNotesChilds()->DataChanged(aVisRect);
+
+ GetShapeChilds()->VisAreaChanged();
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ CommitChange(aEvent);
+ }
+ }
+ else if ( rHint.ISA(ScAccWinFocusLostHint) )
+ {
+ CommitFocusLost();
+ }
+ else if ( rHint.ISA(ScAccWinFocusGotHint) )
+ {
+ CommitFocusGained();
+ }
+ ScAccessibleDocumentBase::Notify(rBC, rHint);
+}
+
+//===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleAtPoint( const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xAccessible;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if ( mpViewShell )
+ {
+ xAccessible = GetShapeChilds()->GetForegroundShapeAt(rPoint);
+ if (!xAccessible.is())
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
+
+/* if ( rData.HasCellsInRange( Rectangle( rPoint, rPoint ) ) )
+ {
+ if ( !mpTable && (aCount.nTables > 0) )
+ {
+ //! order is background shapes, header, table or notes, footer, foreground shapes, controls
+ sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
+
+ mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
+ mpTable->acquire();
+ mpTable->Init();
+ }
+ xAccessible = mpTable;
+ }*/
+ if ( !mpTable && (aCount.nTables > 0) )
+ {
+ //! order is background shapes, header, table or notes, footer, foreground shapes, controls
+ sal_Int32 nIndex (aCount.nBackShapes + aCount.nHeaders);
+
+ mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
+ mpTable->acquire();
+ mpTable->Init();
+ }
+ if (mpTable && VCLRectangle(mpTable->getBounds()).IsInside(VCLPoint(rPoint)))
+ xAccessible = mpTable;
+ }
+ if (!xAccessible.is())
+ xAccessible = GetNotesChilds()->GetAt(rPoint);
+ if (!xAccessible.is())
+ {
+ if (!mpHeader || !mpFooter)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
+
+ if (!mpHeader)
+ {
+ mpHeader = new ScAccessiblePageHeader( this, mpViewShell, sal_True, aCount.nBackShapes + aCount.nHeaders - 1);
+ mpHeader->acquire();
+ }
+ if (!mpFooter)
+ {
+ mpFooter = new ScAccessiblePageHeader( this, mpViewShell, sal_False, aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters - 1 );
+ mpFooter->acquire();
+ }
+ }
+
+ Point aPoint(VCLPoint(rPoint));
+
+ if (VCLRectangle(mpHeader->getBounds()).IsInside(aPoint))
+ xAccessible = mpHeader;
+ else if (VCLRectangle(mpFooter->getBounds()).IsInside(aPoint))
+ xAccessible = mpFooter;
+ }
+ if (!xAccessible.is())
+ xAccessible = GetShapeChilds()->GetBackgroundShapeAt(rPoint);
+ }
+ }
+
+ return xAccessible;
+}
+
+void SAL_CALL ScAccessibleDocumentPagePreview::grabFocus() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ {
+ // just grab the focus for the window
+ xAccessibleComponent->grabFocus();
+ }
+ }
+}
+
+//===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChildCount(void) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ long nRet = 0;
+ if ( mpViewShell )
+ {
+ ScPagePreviewCountData aCount( mpViewShell->GetLocationData(), mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
+ nRet = aCount.GetTotal();
+ }
+
+ return nRet;
+}
+
+uno::Reference<XAccessible> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference<XAccessible> xAccessible;
+
+ if ( mpViewShell )
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
+
+ if ( nIndex < aCount.nBackShapes )
+ {
+ xAccessible = GetShapeChilds()->GetBackShape(nIndex);
+ }
+ else if ( nIndex < aCount.nBackShapes + aCount.nHeaders )
+ {
+ if ( !mpHeader )
+ {
+ mpHeader = new ScAccessiblePageHeader( this, mpViewShell, sal_True, nIndex );
+ mpHeader->acquire();
+ }
+
+ xAccessible = mpHeader;
+ }
+ else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables )
+ {
+ if ( !mpTable )
+ {
+ mpTable = new ScAccessiblePreviewTable( this, mpViewShell, nIndex );
+ mpTable->acquire();
+ mpTable->Init();
+ }
+ xAccessible = mpTable;
+ }
+ else if ( nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nNoteParagraphs )
+ {
+ xAccessible = GetNotesChilds()->GetChild(nIndex - aCount.nBackShapes - aCount.nHeaders);
+ }
+ else if ( (nIndex < aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters) )
+ {
+ if ( !mpFooter )
+ {
+ mpFooter = new ScAccessiblePageHeader( this, mpViewShell, sal_False, nIndex );
+ mpFooter->acquire();
+ }
+ xAccessible = mpFooter;
+ }
+ else
+ {
+ sal_Int32 nIdx(nIndex - (aCount.nBackShapes + aCount.nHeaders + aCount.nTables + aCount.nNoteParagraphs + aCount.nFooters));
+ if (nIdx < aCount.nForeShapes)
+ xAccessible = GetShapeChilds()->GetForeShape(nIdx);
+ else
+ xAccessible = GetShapeChilds()->GetControl(nIdx - aCount.nForeShapes);
+ }
+ }
+
+ if ( !xAccessible.is() )
+ throw lang::IndexOutOfBoundsException();
+
+ return xAccessible;
+}
+
+ /// Return the set of current states.
+uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDocumentPagePreview::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ // never editable
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessibleDocumentPagePreview"));
+}
+
+uno::Sequence< ::rtl::OUString> SAL_CALL ScAccessibleDocumentPagePreview::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheetPageView"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleDocumentPagePreview::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+//===== internal ========================================================
+
+::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ rtl::OUString sDescription = String(ScResId(STR_ACC_PREVIEWDOC_DESCR));
+ return sDescription;
+}
+
+::rtl::OUString SAL_CALL ScAccessibleDocumentPagePreview::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ rtl::OUString sName = String(ScResId(STR_ACC_PREVIEWDOC_NAME));
+ return sName;
+}
+
+Rectangle ScAccessibleDocumentPagePreview::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ aRect = pWindow->GetWindowExtentsRelative(NULL);
+ }
+ return aRect;
+}
+
+Rectangle ScAccessibleDocumentPagePreview::GetBoundingBox() const throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ aRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
+ }
+ return aRect;
+}
+
+sal_Bool ScAccessibleDocumentPagePreview::IsDefunc(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ return ScAccessibleContextBase::IsDefunc() || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+ScNotesChilds* ScAccessibleDocumentPagePreview::GetNotesChilds()
+{
+ if (!mpNotesChilds && mpViewShell)
+ {
+ mpNotesChilds = new ScNotesChilds(mpViewShell, this);
+
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ ScPagePreviewCountData aCount( rData, mpViewShell->GetWindow(), GetNotesChilds(), GetShapeChilds() );
+
+ //! order is background shapes, header, table or notes, footer, foreground shapes, controls
+ mpNotesChilds->Init(aCount.aVisRect, aCount.nBackShapes + aCount.nHeaders);
+ }
+ return mpNotesChilds;
+}
+
+ScShapeChilds* ScAccessibleDocumentPagePreview::GetShapeChilds()
+{
+ if (!mpShapeChilds && mpViewShell)
+ {
+ mpShapeChilds = new ScShapeChilds(mpViewShell, this);
+ mpShapeChilds->Init();
+ }
+
+ return mpShapeChilds;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleEditObject.cxx b/sc/source/ui/Accessibility/AccessibleEditObject.cxx
new file mode 100644
index 000000000000..b0cc9e936725
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleEditObject.cxx
@@ -0,0 +1,354 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "AccessibleEditObject.hxx"
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include "AccessibleText.hxx"
+#include "editsrc.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <svx/AccessibleTextHelper.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/svdmodel.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessibleEditObject::ScAccessibleEditObject(
+ const uno::Reference<XAccessible>& rxParent,
+ EditView* pEditView, Window* pWin, const rtl::OUString& rName,
+ const rtl::OUString& rDescription, EditObjectType eObjectType)
+ :
+ ScAccessibleContextBase(rxParent, AccessibleRole::TEXT_FRAME),
+ mpTextHelper(NULL),
+ mpEditView(pEditView),
+ mpWindow(pWin),
+ meObjectType(eObjectType),
+ mbHasFocus(sal_False)
+{
+ CreateTextHelper();
+ SetName(rName);
+ SetDescription(rDescription);
+}
+
+ScAccessibleEditObject::~ScAccessibleEditObject()
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessibleEditObject::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpTextHelper)
+ DELETEZ(mpTextHelper);
+
+ ScAccessibleContextBase::disposing();
+}
+
+void ScAccessibleEditObject::LostFocus()
+{
+ mbHasFocus = sal_False;
+ if (mpTextHelper)
+ mpTextHelper->SetFocus(sal_False);
+ CommitFocusLost();
+}
+
+void ScAccessibleEditObject::GotFocus()
+{
+ mbHasFocus = sal_True;
+ CommitFocusGained();
+ if (mpTextHelper)
+ mpTextHelper->SetFocus(sal_True);
+}
+
+ //===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleEditObject::getAccessibleAtPoint(
+ const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xRet;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if(!mpTextHelper)
+ CreateTextHelper();
+
+ xRet = mpTextHelper->GetAt(rPoint);
+ }
+
+ return xRet;
+}
+
+Rectangle ScAccessibleEditObject::GetBoundingBoxOnScreen(void) const
+ throw (uno::RuntimeException)
+{
+ Rectangle aScreenBounds;
+
+ if ( mpWindow )
+ {
+ if ( meObjectType == CellInEditMode )
+ {
+ if ( mpEditView && mpEditView->GetEditEngine() )
+ {
+ MapMode aMapMode( mpEditView->GetEditEngine()->GetRefMapMode() );
+ aScreenBounds = mpWindow->LogicToPixel( mpEditView->GetOutputArea(), aMapMode );
+ Point aCellLoc = aScreenBounds.TopLeft();
+ Rectangle aWindowRect = mpWindow->GetWindowExtentsRelative( NULL );
+ Point aWindowLoc = aWindowRect.TopLeft();
+ Point aPos( aCellLoc.getX() + aWindowLoc.getX(), aCellLoc.getY() + aWindowLoc.getY() );
+ aScreenBounds.SetPos( aPos );
+ }
+ }
+ else
+ {
+ aScreenBounds = mpWindow->GetWindowExtentsRelative( NULL );
+ }
+ }
+
+ return aScreenBounds;
+}
+
+Rectangle ScAccessibleEditObject::GetBoundingBox(void) const
+ throw (uno::RuntimeException)
+{
+ Rectangle aBounds( GetBoundingBoxOnScreen() );
+
+ if ( mpWindow )
+ {
+ uno::Reference< XAccessible > xThis( mpWindow->GetAccessible() );
+ if ( xThis.is() )
+ {
+ uno::Reference< XAccessibleContext > xContext( xThis->getAccessibleContext() );
+ if ( xContext.is() )
+ {
+ uno::Reference< XAccessible > xParent( xContext->getAccessibleParent() );
+ if ( xParent.is() )
+ {
+ uno::Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), uno::UNO_QUERY );
+ if ( xParentComponent.is() )
+ {
+ Point aScreenLoc = aBounds.TopLeft();
+ awt::Point aParentScreenLoc = xParentComponent->getLocationOnScreen();
+ Point aPos( aScreenLoc.getX() - aParentScreenLoc.X, aScreenLoc.getY() - aParentScreenLoc.Y );
+ aBounds.SetPos( aPos );
+ }
+ }
+ }
+ }
+ }
+
+ return aBounds;
+}
+
+ //===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL
+ ScAccessibleEditObject::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChildCount();
+}
+
+uno::Reference< XAccessible > SAL_CALL
+ ScAccessibleEditObject::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException,
+ lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChild(nIndex);
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessibleEditObject::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ // all states are const, because this object exists only in one state
+ pStateSet->AddState(AccessibleStateType::EDITABLE);
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::SENSITIVE);
+ pStateSet->AddState(AccessibleStateType::MULTI_LINE);
+ pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE);
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleEditObject::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+// DBG_ERRORFILE("Should never be called, because is set in the constructor.")
+ return rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleEditObject::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ DBG_ERRORFILE("Should never be called, because is set in the constructor.");
+ return rtl::OUString();
+}
+
+ ///===== XAccessibleEventBroadcaster =====================================
+
+void SAL_CALL
+ ScAccessibleEditObject::addEventListener(const uno::Reference<XAccessibleEventListener>& xListener)
+ throw (uno::RuntimeException)
+{
+ if (!mpTextHelper)
+ CreateTextHelper();
+
+ mpTextHelper->AddEventListener(xListener);
+
+ ScAccessibleContextBase::addEventListener(xListener);
+}
+
+void SAL_CALL
+ ScAccessibleEditObject::removeEventListener(const uno::Reference<XAccessibleEventListener>& xListener)
+ throw (uno::RuntimeException)
+{
+ if (!mpTextHelper)
+ CreateTextHelper();
+
+ mpTextHelper->RemoveEventListener(xListener);
+
+ ScAccessibleContextBase::removeEventListener(xListener);
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleEditObject::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleEditObject"));
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleEditObject::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+ //==== internal =========================================================
+
+sal_Bool ScAccessibleEditObject::IsDefunc(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ return ScAccessibleContextBase::IsDefunc() || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+void ScAccessibleEditObject::CreateTextHelper()
+{
+ if (!mpTextHelper)
+ {
+ ::std::auto_ptr < ScAccessibleTextData > pAccessibleTextData;
+ if (meObjectType == CellInEditMode || meObjectType == EditControl)
+ {
+ pAccessibleTextData.reset
+ (new ScAccessibleEditObjectTextData(mpEditView, mpWindow));
+ }
+ else
+ {
+ pAccessibleTextData.reset
+ (new ScAccessibleEditLineTextData(NULL, mpWindow));
+ }
+
+ ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleTextData));
+ mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource );
+ mpTextHelper->SetEventSource(this);
+ mpTextHelper->SetFocus(mbHasFocus);
+
+ // #i54814# activate cell in edit mode
+ if( meObjectType == CellInEditMode )
+ {
+ // do not activate cell object, if top edit line is active
+ const ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if( pInputHdl && !pInputHdl->IsTopMode() )
+ {
+ SdrHint aHint( HINT_BEGEDIT );
+ mpTextHelper->GetEditSource().GetBroadcaster().Broadcast( aHint );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx b/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
new file mode 100644
index 000000000000..2bbb515b952a
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleFilterMenu.cxx
@@ -0,0 +1,400 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include "precompiled_sc.hxx"
+#include "AccessibleGlobal.hxx"
+#include "AccessibleFilterMenu.hxx"
+#include "AccessibleFilterMenuItem.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+
+#include "tools/gen.hxx"
+#include "editeng/unoedsrc.hxx"
+#include "editeng/editdata.hxx"
+#include "editeng/outliner.hxx"
+#include "vcl/unohelp.hxx"
+#include "dpcontrol.hxx"
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::accessibility::AccessibleStateType;
+
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
+using ::com::sun::star::lang::IllegalArgumentException;
+using ::com::sun::star::uno::RuntimeException;
+using ::rtl::OUString;
+using ::std::for_each;
+using ::std::vector;
+
+// ============================================================================
+
+namespace {
+
+class AddRemoveEventListener : public ::std::unary_function<void, Reference<XAccessible> >
+{
+public:
+ explicit AddRemoveEventListener(const Reference<XAccessibleEventListener>& rListener, bool bAdd) :
+ mxListener(rListener), mbAdd(bAdd) {}
+
+ void operator() (const Reference<XAccessible>& xAccessible) const
+ {
+ if (!xAccessible.is())
+ return;
+
+ Reference<XAccessibleEventBroadcaster> xBc(xAccessible, UNO_QUERY);
+ if (xBc.is())
+ {
+ if (mbAdd)
+ xBc->addEventListener(mxListener);
+ else
+ xBc->removeEventListener(mxListener);
+ }
+ }
+private:
+ Reference<XAccessibleEventListener> mxListener;
+ bool mbAdd;
+};
+
+}
+
+// ============================================================================
+
+ScAccessibleFilterMenu::ScAccessibleFilterMenu(const Reference<XAccessible>& rxParent, ScMenuFloatingWindow* pWin, const OUString& rName, size_t nMenuPos, ScDocument* pDoc) :
+ ScAccessibleContextBase(rxParent, AccessibleRole::MENU),
+ mnMenuPos(nMenuPos),
+ mpWindow(pWin),
+ mpDoc(pDoc),
+ mbEnabled(true)
+{
+ SetName(rName);
+}
+
+ScAccessibleFilterMenu::~ScAccessibleFilterMenu()
+{
+}
+
+// XAccessibleComponent
+
+Reference<XAccessible> ScAccessibleFilterMenu::getAccessibleAtPoint( const ::com::sun::star::awt::Point& /*rPoint*/ )
+ throw (RuntimeException)
+{
+ return this;
+}
+
+sal_Bool ScAccessibleFilterMenu::isVisible() throw (RuntimeException)
+{
+ return mpWindow->IsVisible();
+}
+
+void ScAccessibleFilterMenu::grabFocus()
+ throw (RuntimeException)
+{
+}
+
+sal_Int32 ScAccessibleFilterMenu::getForeground()
+ throw (RuntimeException)
+{
+ return 0;
+}
+
+sal_Int32 ScAccessibleFilterMenu::getBackground()
+ throw (RuntimeException)
+{
+ return 0;
+}
+
+// XAccessibleContext
+
+OUString ScAccessibleFilterMenu::getAccessibleName() throw (RuntimeException)
+{
+ return ScAccessibleContextBase::getAccessibleName();
+}
+
+sal_Int32 ScAccessibleFilterMenu::getAccessibleChildCount()
+ throw (RuntimeException)
+{
+ return getMenuItemCount();
+}
+
+Reference<XAccessible> ScAccessibleFilterMenu::getAccessibleChild(sal_Int32 nIndex)
+ throw (RuntimeException, IndexOutOfBoundsException)
+{
+ if (maMenuItems.size() <= static_cast<size_t>(nIndex))
+ throw IndexOutOfBoundsException();
+
+ return maMenuItems[nIndex];
+}
+
+Reference<XAccessibleStateSet> ScAccessibleFilterMenu::getAccessibleStateSet()
+ throw (RuntimeException)
+{
+ updateStates();
+ return mxStateSet;
+}
+
+OUString ScAccessibleFilterMenu::getImplementationName()
+ throw (RuntimeException)
+{
+ return OUString::createFromAscii("ScAccessibleFilterMenu");
+}
+
+// XAccessibleEventBroadcaster
+
+void ScAccessibleFilterMenu::addEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException)
+{
+ ScAccessibleContextBase::addEventListener(xListener);
+ for_each(maMenuItems.begin(), maMenuItems.end(), AddRemoveEventListener(xListener, true));
+}
+
+void ScAccessibleFilterMenu::removeEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException)
+{
+ ScAccessibleContextBase::removeEventListener(xListener);
+ for_each(maMenuItems.begin(), maMenuItems.end(), AddRemoveEventListener(xListener, false));
+}
+
+// XAccessibleSelection
+
+void ScAccessibleFilterMenu::selectAccessibleChild(sal_Int32 nChildIndex)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ throw IndexOutOfBoundsException();
+
+ mpWindow->setSelectedMenuItem(nChildIndex, false, true);
+}
+
+sal_Bool ScAccessibleFilterMenu::isAccessibleChildSelected(sal_Int32 nChildIndex)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ throw IndexOutOfBoundsException();
+
+ return mpWindow->isMenuItemSelected(static_cast<size_t>(nChildIndex));
+}
+
+void ScAccessibleFilterMenu::clearAccessibleSelection() throw (RuntimeException)
+{
+ mpWindow->clearSelectedMenuItem();
+}
+
+void ScAccessibleFilterMenu::selectAllAccessibleChildren() throw (RuntimeException)
+{
+ // not suported - this is a menu, you can't select all menu items.
+}
+
+sal_Int32 ScAccessibleFilterMenu::getSelectedAccessibleChildCount() throw (RuntimeException)
+{
+ // Since this is a menu, either one menu item is selected, or none at all.
+ return mpWindow->getSelectedMenuItem() == ScMenuFloatingWindow::MENU_NOT_SELECTED ? 0 : 1;
+}
+
+Reference<XAccessible> ScAccessibleFilterMenu::getSelectedAccessibleChild(sal_Int32 nChildIndex)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ throw IndexOutOfBoundsException();
+
+ return maMenuItems[nChildIndex];
+}
+
+void ScAccessibleFilterMenu::deselectAccessibleChild(sal_Int32 nChildIndex) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ if (static_cast<size_t>(nChildIndex) >= maMenuItems.size())
+ throw IndexOutOfBoundsException();
+
+ mpWindow->selectMenuItem(nChildIndex, false, false);
+}
+
+// XInterface
+
+uno::Any SAL_CALL ScAccessibleFilterMenu::queryInterface( uno::Type const & rType )
+ throw (RuntimeException)
+{
+ Any any = ScAccessibleContextBase::queryInterface(rType);
+ if (any.hasValue())
+ return any;
+
+ return ScAccessibleFilterMenu_BASE::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessibleFilterMenu::acquire() throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessibleFilterMenu::release() throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+// XTypeProvider
+
+Sequence<sal_Int8> ScAccessibleFilterMenu::getImplementationId()
+ throw (RuntimeException)
+{
+ Sequence<sal_Int8> aId(16);
+ return aId;
+}
+
+Rectangle ScAccessibleFilterMenu::GetBoundingBoxOnScreen() const
+ throw (RuntimeException)
+{
+ if (mnMenuPos == ScMenuFloatingWindow::MENU_NOT_SELECTED)
+ return Rectangle();
+
+ // Menu object's bounding box is the bounding box of the menu item that
+ // launches the menu, which belongs to the parent window.
+ ScMenuFloatingWindow* pParentWin = mpWindow->getParentMenuWindow();
+ if (!pParentWin)
+ return Rectangle();
+
+ if (!pParentWin->IsVisible())
+ return Rectangle();
+
+ Point aPos = pParentWin->OutputToAbsoluteScreenPixel(Point(0,0));
+ Point aMenuPos;
+ Size aMenuSize;
+ pParentWin->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aPos + aMenuPos, aMenuSize);
+ return aRect;
+}
+
+Rectangle ScAccessibleFilterMenu::GetBoundingBox() const
+ throw (RuntimeException)
+{
+ if (mnMenuPos == ScMenuFloatingWindow::MENU_NOT_SELECTED)
+ return Rectangle();
+
+ // Menu object's bounding box is the bounding box of the menu item that
+ // launches the menu, which belongs to the parent window.
+ ScMenuFloatingWindow* pParentWin = mpWindow->getParentMenuWindow();
+ if (!pParentWin)
+ return Rectangle();
+
+ if (!pParentWin->IsVisible())
+ return Rectangle();
+
+ Point aMenuPos;
+ Size aMenuSize;
+ pParentWin->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aMenuPos, aMenuSize);
+ return aRect;
+}
+
+void ScAccessibleFilterMenu::appendMenuItem(const OUString& rName, bool bEnabled, size_t nMenuPos)
+{
+ // Check weather this menu item is a sub menu or a regular menu item.
+ ScMenuFloatingWindow* pSubMenu = mpWindow->getSubMenuWindow(nMenuPos);
+ Reference<XAccessible> xAccessible;
+ if (pSubMenu)
+ {
+ xAccessible = pSubMenu->CreateAccessible();
+ ScAccessibleFilterMenu* p =
+ static_cast<ScAccessibleFilterMenu*>(xAccessible.get());
+ p->setEnabled(bEnabled);
+ p->setMenuPos(nMenuPos);
+ }
+ else
+ {
+ xAccessible.set(new ScAccessibleFilterMenuItem(this, mpWindow, rName, nMenuPos));
+ ScAccessibleFilterMenuItem* p =
+ static_cast<ScAccessibleFilterMenuItem*>(xAccessible.get());
+ p->setEnabled(bEnabled);
+ }
+ maMenuItems.push_back(xAccessible);
+}
+
+void ScAccessibleFilterMenu::setMenuPos(size_t nMenuPos)
+{
+ mnMenuPos = nMenuPos;
+}
+
+void ScAccessibleFilterMenu::setEnabled(bool bEnabled)
+{
+ mbEnabled = bEnabled;
+}
+
+sal_Int32 ScAccessibleFilterMenu::getMenuItemCount() const
+{
+ return maMenuItems.size();
+}
+
+bool ScAccessibleFilterMenu::isSelected() const
+{
+ // Check to see if any of the child menu items is selected.
+ return mpWindow->isMenuItemSelected(mnMenuPos);
+}
+
+bool ScAccessibleFilterMenu::isFocused() const
+{
+ return isSelected();
+}
+
+void ScAccessibleFilterMenu::updateStates()
+{
+ if (!mxStateSet.is())
+ mxStateSet.set(new ScAccessibleStateSet);
+
+ ScAccessibleStateSet* p = static_cast<ScAccessibleStateSet*>(
+ mxStateSet.get());
+
+ p->clear();
+
+ p->insert(ENABLED);
+ p->insert(FOCUSABLE);
+ p->insert(SELECTABLE);
+ p->insert(SENSITIVE);
+ p->insert(OPAQUE);
+
+ if (isFocused())
+ p->insert(FOCUSED);
+
+ if (isSelected())
+ p->insert(SELECTED);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx b/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx
new file mode 100644
index 000000000000..e02aa923deb0
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleFilterMenuItem.cxx
@@ -0,0 +1,207 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include "precompiled_sc.hxx"
+#include "AccessibleGlobal.hxx"
+#include "AccessibleFilterMenuItem.hxx"
+#include "dpcontrol.hxx"
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleEventObject.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/TextSegment.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using namespace ::com::sun::star::accessibility::AccessibleStateType;
+
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
+using ::com::sun::star::uno::RuntimeException;
+using ::rtl::OUString;
+
+ScAccessibleFilterMenuItem::ScAccessibleFilterMenuItem(
+ const Reference<XAccessible>& rxParent, ScMenuFloatingWindow* pWin, const OUString& rName, size_t nMenuPos) :
+ ScAccessibleContextBase(rxParent, AccessibleRole::MENU_ITEM),
+ mpWindow(pWin),
+ maName(rName),
+ mnMenuPos(nMenuPos),
+ mbEnabled(true)
+{
+ SetName(rName);
+}
+
+ScAccessibleFilterMenuItem::~ScAccessibleFilterMenuItem()
+{
+}
+
+sal_Int32 ScAccessibleFilterMenuItem::getAccessibleChildCount()
+ throw (RuntimeException)
+{
+ return 0;
+}
+
+Reference<XAccessible> ScAccessibleFilterMenuItem::getAccessibleChild(sal_Int32 /*nIndex*/)
+ throw (RuntimeException, IndexOutOfBoundsException)
+{
+ throw IndexOutOfBoundsException();
+}
+
+Reference<XAccessibleStateSet> ScAccessibleFilterMenuItem::getAccessibleStateSet()
+ throw (RuntimeException)
+{
+ updateStateSet();
+ return mxStateSet;
+}
+
+OUString ScAccessibleFilterMenuItem::getImplementationName()
+ throw (RuntimeException)
+{
+ return OUString::createFromAscii("ScAccessibleFilterMenuItem");
+}
+
+// XAccessibleAction
+
+sal_Int32 ScAccessibleFilterMenuItem::getAccessibleActionCount() throw (RuntimeException)
+{
+ return 1;
+}
+
+sal_Bool ScAccessibleFilterMenuItem::doAccessibleAction(sal_Int32 /*nIndex*/)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ mpWindow->executeMenuItem(mnMenuPos);
+ return true;
+}
+
+OUString ScAccessibleFilterMenuItem::getAccessibleActionDescription(sal_Int32 /*nIndex*/)
+ throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return OUString::createFromAscii("click");
+}
+
+Reference<XAccessibleKeyBinding> ScAccessibleFilterMenuItem::getAccessibleActionKeyBinding(
+ sal_Int32 /*nIndex*/) throw (IndexOutOfBoundsException, RuntimeException)
+{
+ return Reference<XAccessibleKeyBinding>();
+}
+
+Any SAL_CALL ScAccessibleFilterMenuItem::queryInterface( uno::Type const & rType )
+ throw (RuntimeException)
+{
+ Any any = ScAccessibleContextBase::queryInterface(rType);
+ if (any.hasValue())
+ return any;
+
+ return ScAccessibleFilterMenuItem_BASE::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessibleFilterMenuItem::acquire() throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessibleFilterMenuItem::release() throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+bool ScAccessibleFilterMenuItem::isSelected() const
+{
+ return mpWindow->isMenuItemSelected(mnMenuPos);
+}
+
+bool ScAccessibleFilterMenuItem::isFocused() const
+{
+ return isSelected();
+}
+
+void ScAccessibleFilterMenuItem::setEnabled(bool bEnabled)
+{
+ mbEnabled = bEnabled;
+}
+
+Rectangle ScAccessibleFilterMenuItem::GetBoundingBoxOnScreen() const
+ throw (RuntimeException)
+{
+ if (!mpWindow->IsVisible())
+ return Rectangle();
+
+ Point aPos = mpWindow->OutputToAbsoluteScreenPixel(Point(0,0));
+ Point aMenuPos;
+ Size aMenuSize;
+ mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aPos + aMenuPos, aMenuSize);
+ return aRect;
+}
+
+Rectangle ScAccessibleFilterMenuItem::GetBoundingBox() const
+ throw (RuntimeException)
+{
+ if (!mpWindow->IsVisible())
+ return Rectangle();
+
+ Point aMenuPos;
+ Size aMenuSize;
+ mpWindow->getMenuItemPosSize(mnMenuPos, aMenuPos, aMenuSize);
+ Rectangle aRect(aMenuPos, aMenuSize);
+ return aRect;
+}
+
+void ScAccessibleFilterMenuItem::updateStateSet()
+{
+ if (!mxStateSet.is())
+ mxStateSet.set(new ScAccessibleStateSet);
+
+ ScAccessibleStateSet* p = static_cast<ScAccessibleStateSet*>(
+ mxStateSet.get());
+
+ p->clear();
+
+ p->insert(ENABLED);
+ p->insert(FOCUSABLE);
+ p->insert(SELECTABLE);
+ p->insert(SENSITIVE);
+ p->insert(OPAQUE);
+
+ if (isFocused())
+ p->insert(FOCUSED);
+
+ if (isSelected())
+ p->insert(SELECTED);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx b/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx
new file mode 100644
index 000000000000..f5a8027b16b1
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleFilterTopWindow.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include "precompiled_sc.hxx"
+#include "AccessibleFilterTopWindow.hxx"
+#include "AccessibleFilterMenu.hxx"
+#include "dpcontrol.hxx"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::rtl::OUString;
+
+ScAccessibleFilterTopWindow::ScAccessibleFilterTopWindow(
+ const Reference<XAccessible>& rxParent, ScDPFieldPopupWindow* pWin, const OUString& rName, ScDocument* pDoc) :
+ ScAccessibleFilterMenu(rxParent, pWin, rName, ScMenuFloatingWindow::MENU_NOT_SELECTED, pDoc),
+ mpWindow(pWin),
+ mpDoc(pDoc)
+{
+ SetName(rName);
+}
+
+ScAccessibleFilterTopWindow::~ScAccessibleFilterTopWindow()
+{
+}
+
+// XAccessibleContext
+
+sal_Int32 ScAccessibleFilterTopWindow::getAccessibleChildCount() throw (RuntimeException)
+{
+ sal_Int32 nMenuCount = getMenuItemCount();
+ return nMenuCount + 6;
+}
+
+Reference<XAccessible> ScAccessibleFilterTopWindow::getAccessibleChild(
+ sal_Int32 nIndex) throw (RuntimeException, IndexOutOfBoundsException)
+{
+ if (nIndex >= getAccessibleChildCount())
+ throw IndexOutOfBoundsException();
+
+ sal_Int32 nMenuCount = getMenuItemCount();
+ if (nIndex < nMenuCount)
+ return ScAccessibleFilterMenu::getAccessibleChild(nIndex);
+
+ nIndex -= nMenuCount;
+ switch (nIndex)
+ {
+ case 0:
+ return mxAccListBox;
+ case 1:
+ return mxAccToggleAll;
+ case 2:
+ return mxAccSingleOnBtn;
+ case 3:
+ return mxAccSingleOffBtn;
+ case 4:
+ return mxAccOkBtn;
+ case 5:
+ return mxAccCancelBtn;
+ default:
+ ;
+ }
+
+ return Reference<XAccessible>();
+}
+
+OUString ScAccessibleFilterTopWindow::getImplementationName() throw (RuntimeException)
+{
+ return OUString::createFromAscii("ScAccessibleFilterTopWindow");
+}
+
+void ScAccessibleFilterTopWindow::setAccessibleChild(
+ const Reference<XAccessible>& rAccessible, ChildControlType eType)
+{
+ switch (eType)
+ {
+ case LISTBOX:
+ mxAccListBox = rAccessible;
+ break;
+ case TOGGLE_ALL:
+ mxAccToggleAll = rAccessible;
+ break;
+ case SINGLE_ON_BTN:
+ mxAccSingleOnBtn = rAccessible;
+ break;
+ case SINGLE_OFF_BTN:
+ mxAccSingleOffBtn = rAccessible;
+ break;
+ case OK_BTN:
+ mxAccOkBtn = rAccessible;
+ break;
+ case CANCEL_BTN:
+ mxAccCancelBtn = rAccessible;
+ break;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleGlobal.cxx b/sc/source/ui/Accessibility/AccessibleGlobal.cxx
new file mode 100644
index 000000000000..5698954771c3
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleGlobal.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+#include "precompiled_sc.hxx"
+#include "AccessibleGlobal.hxx"
+
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::std::set;
+
+ScAccessibleStateSet::ScAccessibleStateSet()
+{
+}
+
+ScAccessibleStateSet::~ScAccessibleStateSet()
+{
+}
+
+// XAccessibleStateSet
+
+sal_Bool SAL_CALL ScAccessibleStateSet::isEmpty() throw (RuntimeException)
+{
+ return maStates.empty();
+}
+
+sal_Bool SAL_CALL ScAccessibleStateSet::contains(sal_Int16 nState)
+ throw (RuntimeException)
+{
+ return maStates.count(nState) != 0;
+}
+
+sal_Bool SAL_CALL ScAccessibleStateSet::containsAll(
+ const Sequence<sal_Int16>& aStateSet) throw (RuntimeException)
+{
+ sal_Int32 n = aStateSet.getLength();
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ if (!maStates.count(aStateSet[i]))
+ // This state is not set.
+ return false;
+ }
+ // All specified states are set.
+ return true;
+}
+
+Sequence<sal_Int16> SAL_CALL ScAccessibleStateSet::getStates()
+ throw (RuntimeException)
+{
+ Sequence<sal_Int16> aSeq(0);
+ set<sal_Int16>::const_iterator itr = maStates.begin(), itrEnd = maStates.end();
+ for (size_t i = 0; itr != itrEnd; ++itr, ++i)
+ {
+ aSeq.realloc(i+1);
+ aSeq[i] = *itr;
+ }
+ return aSeq;
+}
+
+void ScAccessibleStateSet::insert(sal_Int16 nState)
+{
+ maStates.insert(nState);
+}
+
+void ScAccessibleStateSet::clear()
+{
+ maStates.clear();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessiblePageHeader.cxx b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx
new file mode 100644
index 000000000000..ff9f21b820ea
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessiblePageHeader.cxx
@@ -0,0 +1,442 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "AccessiblePageHeader.hxx"
+#include "AccessiblePageHeaderArea.hxx"
+#include "AccessibilityHints.hxx"
+#include "prevwsh.hxx"
+#include "miscuno.hxx"
+#include "prevloc.hxx"
+#include "document.hxx"
+#include "stlpool.hxx"
+#include "scitems.hxx"
+#include "attrib.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+
+#include <vcl/window.hxx>
+#include <svl/smplhint.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <svl/style.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/editobj.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+const sal_uInt8 MAX_AREAS = 3;
+
+//===== internal ============================================================
+struct Acquire
+{
+ void operator() (ScAccessiblePageHeaderArea* pArea)
+ {
+ if (pArea)
+ pArea->acquire();
+ }
+};
+
+struct Release
+{
+ void operator() (ScAccessiblePageHeaderArea*& pArea)
+ {
+ if (pArea)
+ pArea->release();
+ }
+};
+
+struct Dispose
+{
+ void operator() (ScAccessiblePageHeaderArea*& pArea)
+ {
+ if (pArea)
+ {
+ pArea->dispose();
+ pArea->release();
+ }
+ pArea = NULL;
+ }
+};
+
+ScAccessiblePageHeader::ScAccessiblePageHeader( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell, sal_Bool bHeader, sal_Int32 nIndex ) :
+ScAccessibleContextBase( rxParent, bHeader ? AccessibleRole::HEADER : AccessibleRole::FOOTER ),
+ mpViewShell( pViewShell ),
+ mnIndex( nIndex ),
+ mbHeader( bHeader ),
+ maAreas(MAX_AREAS, NULL),
+ mnChildCount(-1)
+{
+ if (mpViewShell)
+ mpViewShell->AddAccessibilityObject(*this);
+}
+
+ScAccessiblePageHeader::~ScAccessiblePageHeader()
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessiblePageHeader::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+ std::for_each(maAreas.begin(), maAreas.end(), Dispose());
+
+ ScAccessibleContextBase::disposing();
+}
+
+//===== SfxListener =====================================================
+
+void ScAccessiblePageHeader::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ) )
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ // only notify if child exist, otherwise it is not necessary
+ if ((rRef.GetId() == SC_HINT_DATACHANGED))
+ {
+ ScHFAreas aOldAreas(maAreas);
+ std::for_each(aOldAreas.begin(), aOldAreas.end(), Acquire());
+ mnChildCount = -1;
+ getAccessibleChildCount();
+ for (sal_uInt8 i = 0; i < MAX_AREAS; ++i)
+ {
+ if ((aOldAreas[i] && maAreas[i] && !ScGlobal::EETextObjEqual(aOldAreas[i]->GetEditTextObject(), maAreas[i]->GetEditTextObject())) ||
+ (aOldAreas[i] && !maAreas[i]) || (!aOldAreas[i] && maAreas[i]))
+ {
+ if (aOldAreas[i] && aOldAreas[i]->GetEditTextObject())
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.OldValue = uno::makeAny(uno::Reference<XAccessible>(aOldAreas[i]));
+
+ CommitChange(aEvent); // child gone - event
+ aOldAreas[i]->dispose();
+ }
+ if (maAreas[i] && maAreas[i]->GetEditTextObject())
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::CHILD;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.NewValue = uno::makeAny(uno::Reference<XAccessible>(maAreas[i]));
+
+ CommitChange(aEvent); // new child - event
+ }
+ }
+ }
+ std::for_each(aOldAreas.begin(), aOldAreas.end(), Release());
+ }
+ else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ CommitChange(aEvent);
+ }
+ }
+
+ ScAccessibleContextBase::Notify(rBC, rHint);
+}
+
+//===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleAtPoint( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xRet;
+
+ if (containsPoint(aPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ sal_Int32 nCount(getAccessibleChildCount()); // fill the areas
+
+ if (nCount)
+ {
+ // return the first with content, because they have all the same Bounding Box
+ sal_uInt8 i(0);
+ while(!xRet.is() && i < MAX_AREAS)
+ {
+ if (maAreas[i])
+ xRet = maAreas[i];
+ else
+ ++i;
+ }
+ }
+ }
+
+ return xRet;
+}
+
+void SAL_CALL ScAccessiblePageHeader::grabFocus() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ xAccessibleComponent->grabFocus();
+ }
+}
+
+//===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessiblePageHeader::getAccessibleChildCount() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if((mnChildCount < 0) && mpViewShell)
+ {
+ mnChildCount = 0;
+ ScDocument* pDoc = mpViewShell->GetDocument();
+ if (pDoc)
+ {
+ // find out how many regions (left,center, right) are with content
+
+ SfxStyleSheetBase* pStyle = pDoc->GetStyleSheetPool()->Find(pDoc->GetPageStyle(mpViewShell->GetLocationData().GetPrintTab()), SFX_STYLE_FAMILY_PAGE);
+ if (pStyle)
+ {
+ sal_uInt16 nPageWhichId(0);
+ if (mbHeader)
+ nPageWhichId = mpViewShell->GetLocationData().IsHeaderLeft() ? ATTR_PAGE_HEADERLEFT : ATTR_PAGE_HEADERRIGHT;
+ else
+ nPageWhichId = mpViewShell->GetLocationData().IsFooterLeft() ? ATTR_PAGE_FOOTERLEFT : ATTR_PAGE_FOOTERRIGHT;
+
+ const ScPageHFItem& rPageItem = static_cast<const ScPageHFItem&>(pStyle->GetItemSet().Get(nPageWhichId));
+ AddChild(rPageItem.GetLeftArea(), 0, SVX_ADJUST_LEFT);
+ AddChild(rPageItem.GetCenterArea(), 1, SVX_ADJUST_CENTER);
+ AddChild(rPageItem.GetRightArea(), 2, SVX_ADJUST_RIGHT);
+ }
+ }
+ }
+
+ return mnChildCount;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeader::getAccessibleChild( sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ uno::Reference<XAccessible> xRet;
+
+ if(mnChildCount < 0)
+ getAccessibleChildCount();
+
+ ScHFAreas::iterator aItr = maAreas.begin();
+ ScHFAreas::iterator aEndItr = maAreas.end();
+ while (!xRet.is() && (nIndex >= 0) && (aItr != aEndItr))
+ {
+ if (*aItr)
+ {
+ if (nIndex == 0)
+ xRet = *aItr;
+ else
+ --nIndex;
+ }
+ else
+ ++aItr;
+ }
+
+ if ( !xRet.is() )
+ throw lang::IndexOutOfBoundsException();
+
+ return xRet;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePageHeader::getAccessibleIndexInParent() throw (uno::RuntimeException)
+{
+ return mnIndex;
+}
+
+uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePageHeader::getAccessibleStateSet()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+//===== XServiceInfo ====================================================
+
+rtl::OUString SAL_CALL ScAccessiblePageHeader::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePageHeader"));
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePageHeader::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AccessibleHeaderFooterView"));
+
+ return aSequence;
+}
+
+//==== internal =========================================================
+
+::rtl::OUString SAL_CALL ScAccessiblePageHeader::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ String sDesc(ScResId(mbHeader ? STR_ACC_HEADER_DESCR : STR_ACC_FOOTER_DESCR));
+ sDesc.SearchAndReplaceAscii("%1", String(ScResId(SCSTR_UNKNOWN)));
+ return rtl::OUString( sDesc );
+}
+
+::rtl::OUString SAL_CALL ScAccessiblePageHeader::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ String sName(ScResId(mbHeader ? STR_ACC_HEADER_NAME : STR_ACC_FOOTER_NAME));
+ sName.SearchAndReplaceAscii("%1", String(ScResId(SCSTR_UNKNOWN)));
+ return rtl::OUString( sName );
+}
+
+Rectangle ScAccessiblePageHeader::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
+{
+ Rectangle aCellRect(GetBoundingBox());
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
+ aCellRect.setX(aCellRect.getX() + aRect.getX());
+ aCellRect.setY(aCellRect.getY() + aRect.getY());
+ }
+ }
+ return aCellRect;
+}
+
+Rectangle ScAccessiblePageHeader::GetBoundingBox() const throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ if ( mbHeader )
+ rData.GetHeaderPosition( aRect );
+ else
+ rData.GetFooterPosition( aRect );
+
+ // the Rectangle could contain negative coordinates so it should be cliped
+ Rectangle aClipRect(Point(0, 0), aRect.GetSize());
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ aClipRect = pWindow->GetWindowExtentsRelative(pWindow->GetAccessibleParentWindow());
+ aRect = aClipRect.GetIntersection(aRect);
+ }
+ if (aRect.IsEmpty())
+ aRect.SetSize(Size(-1, -1));
+
+ return aRect;
+}
+
+sal_Bool ScAccessiblePageHeader::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+void ScAccessiblePageHeader::AddChild(const EditTextObject* pArea, sal_uInt32 nIndex, SvxAdjust eAdjust)
+{
+ if (pArea && (pArea->GetText(0).Len() || (pArea->GetParagraphCount() > 1)))
+ {
+ if (maAreas[nIndex])
+ {
+ if (!ScGlobal::EETextObjEqual(maAreas[nIndex]->GetEditTextObject(), pArea))
+ {
+ maAreas[nIndex]->release();
+ maAreas[nIndex] = new ScAccessiblePageHeaderArea(this, mpViewShell, pArea, mbHeader, eAdjust);
+ maAreas[nIndex]->acquire();
+ }
+ }
+ else
+ {
+ maAreas[nIndex] = new ScAccessiblePageHeaderArea(this, mpViewShell, pArea, mbHeader, eAdjust);
+ maAreas[nIndex]->acquire();
+ }
+ ++mnChildCount;
+ }
+ else
+ {
+ if (maAreas[nIndex])
+ {
+ maAreas[nIndex]->release();
+ maAreas[nIndex] = NULL;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
new file mode 100644
index 000000000000..ea167540ebcd
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessiblePageHeaderArea.cxx
@@ -0,0 +1,327 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <tools/gen.hxx>
+#include "AccessiblePageHeaderArea.hxx"
+#include "AccessibleText.hxx"
+#include "AccessibilityHints.hxx"
+#include "editsrc.hxx"
+#include "prevwsh.hxx"
+#include "prevloc.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <editeng/editobj.hxx>
+#include <svx/AccessibleTextHelper.hxx>
+#include <rtl/uuid.h>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+ //===== internal ========================================================
+
+ScAccessiblePageHeaderArea::ScAccessiblePageHeaderArea(
+ const uno::Reference<XAccessible>& rxParent,
+ ScPreviewShell* pViewShell,
+ const EditTextObject* pEditObj,
+ sal_Bool bHeader,
+ SvxAdjust eAdjust)
+ : ScAccessibleContextBase(rxParent, AccessibleRole::TEXT),
+ mpEditObj(pEditObj->Clone()),
+ mpTextHelper(NULL),
+ mpViewShell(pViewShell),
+ mbHeader(bHeader),
+ meAdjust(eAdjust)
+{
+ if (mpViewShell)
+ mpViewShell->AddAccessibilityObject(*this);
+}
+
+ScAccessiblePageHeaderArea::~ScAccessiblePageHeaderArea(void)
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessiblePageHeaderArea::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+ if (mpTextHelper)
+ DELETEZ(mpTextHelper);
+ if (mpEditObj)
+ DELETEZ(mpEditObj);
+
+ ScAccessibleContextBase::disposing();
+}
+
+//===== SfxListener =====================================================
+
+void ScAccessiblePageHeaderArea::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ) )
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ // only notify if child exist, otherwise it is not necessary
+ if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
+ {
+ if (mpTextHelper)
+ mpTextHelper->UpdateChildren();
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ CommitChange(aEvent);
+ }
+ }
+ ScAccessibleContextBase::Notify(rBC, rHint);
+}
+ //===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePageHeaderArea::getAccessibleAtPoint(
+ const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xRet;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if(!mpTextHelper)
+ CreateTextHelper();
+
+ xRet = mpTextHelper->GetAt(rPoint);
+ }
+
+ return xRet;
+}
+
+ //===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL
+ ScAccessiblePageHeaderArea::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChildCount();
+}
+
+uno::Reference< XAccessible > SAL_CALL
+ ScAccessiblePageHeaderArea::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException,
+ lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChild(nIndex);
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessiblePageHeaderArea::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc())
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::MULTI_LINE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+//===== XServiceInfo ========================================================
+
+::rtl::OUString SAL_CALL
+ ScAccessiblePageHeaderArea::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessiblePageHeaderArea"));
+}
+
+uno::Sequence< ::rtl::OUString> SAL_CALL
+ ScAccessiblePageHeaderArea::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.AccessiblePageHeaderFooterAreasView"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessiblePageHeaderArea::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+//===== internal ==============================================================
+rtl::OUString SAL_CALL ScAccessiblePageHeaderArea::createAccessibleDescription(void)
+ throw(uno::RuntimeException)
+{
+ rtl::OUString sDesc;
+ switch (meAdjust)
+ {
+ case SVX_ADJUST_LEFT :
+ sDesc = String(ScResId(STR_ACC_LEFTAREA_DESCR));
+ break;
+ case SVX_ADJUST_RIGHT:
+ sDesc = String(ScResId(STR_ACC_RIGHTAREA_DESCR));
+ break;
+ case SVX_ADJUST_CENTER:
+ sDesc = String(ScResId(STR_ACC_CENTERAREA_DESCR));
+ break;
+ default:
+ DBG_ERRORFILE("wrong adjustment found");
+ }
+
+ return sDesc;
+}
+
+rtl::OUString SAL_CALL ScAccessiblePageHeaderArea::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ rtl::OUString sName;
+ switch (meAdjust)
+ {
+ case SVX_ADJUST_LEFT :
+ sName = String(ScResId(STR_ACC_LEFTAREA_NAME));
+ break;
+ case SVX_ADJUST_RIGHT:
+ sName = String(ScResId(STR_ACC_RIGHTAREA_NAME));
+ break;
+ case SVX_ADJUST_CENTER:
+ sName = String(ScResId(STR_ACC_CENTERAREA_NAME));
+ break;
+ default:
+ DBG_ERRORFILE("wrong adjustment found");
+ }
+
+ return sName;
+}
+
+Rectangle ScAccessiblePageHeaderArea::GetBoundingBoxOnScreen(void) const
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mxParent.is())
+ {
+ uno::Reference<XAccessibleContext> xContext = mxParent->getAccessibleContext();
+ uno::Reference<XAccessibleComponent> xComp(xContext, uno::UNO_QUERY);
+ if (xComp.is())
+ {
+ // has the same size and position on screen like the parent
+ aRect = Rectangle(VCLPoint(xComp->getLocationOnScreen()), VCLRectangle(xComp->getBounds()).GetSize());
+ }
+ }
+ return aRect;
+}
+
+Rectangle ScAccessiblePageHeaderArea::GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mxParent.is())
+ {
+ uno::Reference<XAccessibleContext> xContext = mxParent->getAccessibleContext();
+ uno::Reference<XAccessibleComponent> xComp(xContext, uno::UNO_QUERY);
+ if (xComp.is())
+ {
+ // has the same size and position on screen like the parent and so the pos is (0, 0)
+ Rectangle aNewRect(Point(0, 0), VCLRectangle(xComp->getBounds()).GetSize());
+ aRect = aNewRect;
+ }
+ }
+
+ return aRect;
+}
+
+void ScAccessiblePageHeaderArea::CreateTextHelper()
+{
+ if (!mpTextHelper)
+ {
+ ::std::auto_ptr < ScAccessibleTextData > pAccessibleHeaderTextData
+ (new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust));
+ ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessibleHeaderTextData));
+
+ mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource );
+ mpTextHelper->SetEventSource(this);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx
new file mode 100644
index 000000000000..70355c65c889
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessiblePreviewCell.cxx
@@ -0,0 +1,318 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <tools/gen.hxx>
+#include "AccessibleText.hxx"
+#include "editsrc.hxx"
+#include "AccessiblePreviewCell.hxx"
+#include "AccessibilityHints.hxx"
+#include "prevwsh.hxx"
+#include "prevloc.hxx"
+#include "document.hxx"
+#include <svx/AccessibleTextHelper.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <editeng/brshitem.hxx>
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessiblePreviewCell::ScAccessiblePreviewCell( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell, /* const */ ScAddress& rCellAddress,
+ sal_Int32 nIndex ) :
+ ScAccessibleCellBase( rxParent, ( pViewShell ? pViewShell->GetDocument() : NULL ), rCellAddress, nIndex ),
+ mpViewShell( pViewShell ),
+ mpTextHelper(NULL)
+{
+ if (mpViewShell)
+ mpViewShell->AddAccessibilityObject(*this);
+}
+
+ScAccessiblePreviewCell::~ScAccessiblePreviewCell()
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ // call dispose to inform object wich have a weak reference to this object
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessiblePreviewCell::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+
+ if (mpTextHelper)
+ DELETEZ(mpTextHelper);
+
+ ScAccessibleCellBase::disposing();
+}
+
+void ScAccessiblePreviewCell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ))
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
+ {
+ if (mpTextHelper)
+ mpTextHelper->UpdateChildren();
+ }
+ }
+
+ ScAccessibleContextBase::Notify(rBC, rHint);
+}
+
+//===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewCell::getAccessibleAtPoint( const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xRet;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if(!mpTextHelper)
+ CreateTextHelper();
+
+ xRet = mpTextHelper->GetAt(rPoint);
+ }
+
+ return xRet;
+}
+
+void SAL_CALL ScAccessiblePreviewCell::grabFocus() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ xAccessibleComponent->grabFocus();
+ }
+}
+
+//===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessiblePreviewCell::getAccessibleChildCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChildCount();
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewCell::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChild(nIndex);
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessiblePreviewCell::getAccessibleStateSet()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::MULTI_LINE);
+ if (IsOpaque(xParentStates))
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ pStateSet->AddState(AccessibleStateType::TRANSIENT);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ // #111635# MANAGES_DESCENDANTS (for paragraphs)
+ pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
+ }
+ return pStateSet;
+}
+
+//===== XServiceInfo ====================================================
+
+rtl::OUString SAL_CALL ScAccessiblePreviewCell::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewCell"));
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewCell::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleCellView"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessiblePreviewCell::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+//==== internal =========================================================
+
+Rectangle ScAccessiblePreviewCell::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
+{
+ Rectangle aCellRect;
+ if (mpViewShell)
+ {
+ mpViewShell->GetLocationData().GetCellPosition( maCellAddress, aCellRect );
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
+ aCellRect.setX(aCellRect.getX() + aRect.getX());
+ aCellRect.setY(aCellRect.getY() + aRect.getY());
+ }
+ }
+ return aCellRect;
+}
+
+Rectangle ScAccessiblePreviewCell::GetBoundingBox() const throw (uno::RuntimeException)
+{
+ Rectangle aCellRect;
+ if (mpViewShell)
+ {
+ mpViewShell->GetLocationData().GetCellPosition( maCellAddress, aCellRect );
+ uno::Reference<XAccessible> xAccParent = const_cast<ScAccessiblePreviewCell*>(this)->getAccessibleParent();
+ if (xAccParent.is())
+ {
+ uno::Reference<XAccessibleContext> xAccParentContext = xAccParent->getAccessibleContext();
+ uno::Reference<XAccessibleComponent> xAccParentComp (xAccParentContext, uno::UNO_QUERY);
+ if (xAccParentComp.is())
+ {
+ Rectangle aParentRect (VCLRectangle(xAccParentComp->getBounds()));
+ aCellRect.setX(aCellRect.getX() - aParentRect.getX());
+ aCellRect.setY(aCellRect.getY() - aParentRect.getY());
+ }
+ }
+ }
+ return aCellRect;
+}
+
+sal_Bool ScAccessiblePreviewCell::IsDefunc(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpDoc == NULL) || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+sal_Bool ScAccessiblePreviewCell::IsEditable(
+ const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
+{
+ return sal_False;
+}
+
+sal_Bool ScAccessiblePreviewCell::IsOpaque(
+ const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
+{
+ // test whether there is a background color
+ //! could be moved to ScAccessibleCellBase
+
+ sal_Bool bOpaque(sal_True);
+ if (mpDoc)
+ {
+ const SvxBrushItem* pItem = (const SvxBrushItem*)mpDoc->GetAttr(
+ maCellAddress.Col(), maCellAddress.Row(), maCellAddress.Tab(), ATTR_BACKGROUND);
+ if (pItem)
+ bOpaque = pItem->GetColor() != COL_TRANSPARENT;
+ }
+ return bOpaque;
+}
+
+void ScAccessiblePreviewCell::CreateTextHelper()
+{
+ if (!mpTextHelper)
+ {
+ ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewCellTextData
+ (new ScAccessiblePreviewCellTextData(mpViewShell, maCellAddress));
+ ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewCellTextData));
+
+ mpTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
+ mpTextHelper->SetEventSource( this );
+
+ // #111635# paragraphs in preview are transient
+ ::accessibility::AccessibleTextHelper::VectorOfStates aChildStates;
+ aChildStates.push_back( AccessibleStateType::TRANSIENT );
+ mpTextHelper->SetAdditionalChildStates( aChildStates );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx
new file mode 100644
index 000000000000..e83feaf075ff
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessiblePreviewHeaderCell.cxx
@@ -0,0 +1,444 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <tools/gen.hxx>
+#include "AccessibleText.hxx"
+#include "editsrc.hxx"
+#include <svx/AccessibleTextHelper.hxx>
+#include "AccessiblePreviewHeaderCell.hxx"
+#include "AccessibilityHints.hxx"
+#include "prevwsh.hxx"
+#include "miscuno.hxx"
+#include "prevloc.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/smplhint.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/sequence.hxx>
+#include <toolkit/helper/convert.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessiblePreviewHeaderCell::ScAccessiblePreviewHeaderCell( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell,
+ const ScAddress& rCellPos, sal_Bool bIsColHdr, sal_Bool bIsRowHdr,
+ sal_Int32 nIndex ) :
+ ScAccessibleContextBase( rxParent, AccessibleRole::TABLE_CELL ),
+ mpViewShell( pViewShell ),
+ mpTextHelper( NULL ),
+ mnIndex( nIndex ),
+ maCellPos( rCellPos ),
+ mbColumnHeader( bIsColHdr ),
+ mbRowHeader( bIsRowHdr ),
+ mpTableInfo( NULL )
+{
+ if (mpViewShell)
+ mpViewShell->AddAccessibilityObject(*this);
+}
+
+ScAccessiblePreviewHeaderCell::~ScAccessiblePreviewHeaderCell()
+{
+ if (mpViewShell)
+ mpViewShell->RemoveAccessibilityObject(*this);
+}
+
+void SAL_CALL ScAccessiblePreviewHeaderCell::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+
+ if (mpTableInfo)
+ DELETEZ (mpTableInfo);
+
+ ScAccessibleContextBase::disposing();
+}
+
+//===== SfxListener =====================================================
+
+void ScAccessiblePreviewHeaderCell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ))
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ ULONG nId = rRef.GetId();
+ if (nId == SC_HINT_ACC_VISAREACHANGED)
+ {
+ if (mpTextHelper)
+ mpTextHelper->UpdateChildren();
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ {
+ // column / row layout may change with any document change,
+ // so it must be invalidated
+ DELETEZ( mpTableInfo );
+ }
+ }
+
+ ScAccessibleContextBase::Notify(rBC, rHint);
+}
+
+//===== XInterface =====================================================
+
+uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::queryInterface( uno::Type const & rType )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny (ScAccessiblePreviewHeaderCellImpl::queryInterface(rType));
+ return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessiblePreviewHeaderCell::acquire()
+ throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessiblePreviewHeaderCell::release()
+ throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+//===== XAccessibleValue ================================================
+
+uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getCurrentValue() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ double fValue(0.0);
+ if (mbColumnHeader)
+ fValue = maCellPos.Col();
+ else
+ fValue = maCellPos.Row();
+
+ uno::Any aAny;
+ aAny <<= fValue;
+ return aAny;
+}
+
+sal_Bool SAL_CALL ScAccessiblePreviewHeaderCell::setCurrentValue( const uno::Any& /* aNumber */ )
+ throw (uno::RuntimeException)
+{
+ // it is not possible to set a value
+ return sal_False;
+}
+
+uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMaximumValue() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ double fValue(0.0);
+ if (mbColumnHeader)
+ fValue = MAXCOL;
+ else
+ fValue = MAXROW;
+ uno::Any aAny;
+ aAny <<= fValue;
+ return aAny;
+}
+
+uno::Any SAL_CALL ScAccessiblePreviewHeaderCell::getMinimumValue() throw (uno::RuntimeException)
+{
+ double fValue(0.0);
+ uno::Any aAny;
+ aAny <<= fValue;
+ return aAny;
+}
+
+//===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleAtPoint( const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xRet;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if(!mpTextHelper)
+ CreateTextHelper();
+
+ xRet = mpTextHelper->GetAt(rPoint);
+ }
+
+ return xRet;
+}
+
+void SAL_CALL ScAccessiblePreviewHeaderCell::grabFocus() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ xAccessibleComponent->grabFocus();
+ }
+}
+
+//===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChildCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChildCount();
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (!mpTextHelper)
+ CreateTextHelper();
+ return mpTextHelper->GetChild(nIndex);
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleIndexInParent() throw (uno::RuntimeException)
+{
+ return mnIndex;
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessiblePreviewHeaderCell::getAccessibleStateSet()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::MULTI_LINE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ pStateSet->AddState(AccessibleStateType::TRANSIENT);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+//===== XServiceInfo ====================================================
+
+rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewHeaderCell"));
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewHeaderCell::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleCellView"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewHeaderCell::getTypes()
+ throw (uno::RuntimeException)
+{
+ return comphelper::concatSequences(ScAccessiblePreviewHeaderCellImpl::getTypes(), ScAccessibleContextBase::getTypes());
+}
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessiblePreviewHeaderCell::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+//==== internal =========================================================
+
+Rectangle ScAccessiblePreviewHeaderCell::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
+{
+ Rectangle aCellRect;
+
+ FillTableInfo();
+
+ if (mpTableInfo)
+ {
+ const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[maCellPos.Col()];
+ const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[maCellPos.Row()];
+
+ aCellRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
+ }
+
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
+ aCellRect.setX(aCellRect.getX() + aRect.getX());
+ aCellRect.setY(aCellRect.getY() + aRect.getY());
+ }
+ }
+ return aCellRect;
+}
+
+Rectangle ScAccessiblePreviewHeaderCell::GetBoundingBox() const throw (uno::RuntimeException)
+{
+ FillTableInfo();
+
+ if (mpTableInfo)
+ {
+ const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[maCellPos.Col()];
+ const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[maCellPos.Row()];
+
+ Rectangle aCellRect( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
+ uno::Reference<XAccessible> xAccParent = const_cast<ScAccessiblePreviewHeaderCell*>(this)->getAccessibleParent();
+ if (xAccParent.is())
+ {
+ uno::Reference<XAccessibleContext> xAccParentContext = xAccParent->getAccessibleContext();
+ uno::Reference<XAccessibleComponent> xAccParentComp (xAccParentContext, uno::UNO_QUERY);
+ if (xAccParentComp.is())
+ {
+ Rectangle aParentRect (VCLRectangle(xAccParentComp->getBounds()));
+ aCellRect.setX(aCellRect.getX() - aParentRect.getX());
+ aCellRect.setY(aCellRect.getY() - aParentRect.getY());
+ }
+ }
+ return aCellRect;
+ }
+ return Rectangle();
+}
+
+rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::createAccessibleDescription() throw(uno::RuntimeException)
+{
+ rtl::OUString sDescription = String(ScResId(STR_ACC_HEADERCELL_DESCR));
+ return sDescription;
+}
+
+rtl::OUString SAL_CALL ScAccessiblePreviewHeaderCell::createAccessibleName() throw(uno::RuntimeException)
+{
+ rtl::OUString sName = String(ScResId(STR_ACC_HEADERCELL_NAME));
+
+ if ( mbColumnHeader )
+ {
+ if ( mbRowHeader )
+ {
+ //! name for corner cell?
+
+// sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Column/Row Header"));
+ }
+ else
+ {
+ // name of column header
+ sName += ScColToAlpha( maCellPos.Col() );
+ }
+ }
+ else
+ {
+ // name of row header
+ sName += rtl::OUString::valueOf( (sal_Int32) ( maCellPos.Row() + 1 ) );
+ }
+
+ return sName;
+}
+
+sal_Bool ScAccessiblePreviewHeaderCell::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+void ScAccessiblePreviewHeaderCell::CreateTextHelper()
+{
+ if (!mpTextHelper)
+ {
+ ::std::auto_ptr < ScAccessibleTextData > pAccessiblePreviewHeaderCellTextData
+ (new ScAccessiblePreviewHeaderCellTextData(mpViewShell, String(getAccessibleName()), maCellPos, mbColumnHeader, mbRowHeader));
+ ::std::auto_ptr< SvxEditSource > pEditSource (new ScAccessibilityEditSource(pAccessiblePreviewHeaderCellTextData));
+
+ mpTextHelper = new ::accessibility::AccessibleTextHelper(pEditSource );
+ mpTextHelper->SetEventSource(this);
+ }
+}
+
+void ScAccessiblePreviewHeaderCell::FillTableInfo() const
+{
+ if ( mpViewShell && !mpTableInfo )
+ {
+ Size aOutputSize;
+ Window* pWindow = mpViewShell->GetWindow();
+ if ( pWindow )
+ aOutputSize = pWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+
+ mpTableInfo = new ScPreviewTableInfo;
+ mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
new file mode 100644
index 000000000000..d0fb20d19e10
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessiblePreviewTable.cxx
@@ -0,0 +1,769 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include "AccessiblePreviewTable.hxx"
+#include "AccessiblePreviewCell.hxx"
+#include "AccessiblePreviewHeaderCell.hxx"
+#include "AccessibilityHints.hxx"
+#include "prevwsh.hxx"
+#include "miscuno.hxx"
+#include "prevloc.hxx"
+#include "attrib.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/smplhint.hxx>
+#include <unotools/accessiblestatesethelper.hxx>
+#include <comphelper/sequence.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessiblePreviewTable::ScAccessiblePreviewTable( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell, sal_Int32 nIndex ) :
+ ScAccessibleContextBase( rxParent, AccessibleRole::TABLE ),
+ mpViewShell( pViewShell ),
+ mnIndex( nIndex ),
+ mpTableInfo( NULL )
+{
+ if (mpViewShell)
+ mpViewShell->AddAccessibilityObject(*this);
+}
+
+ScAccessiblePreviewTable::~ScAccessiblePreviewTable()
+{
+ if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
+ {
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+void SAL_CALL ScAccessiblePreviewTable::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+
+ if (mpTableInfo)
+ DELETEZ (mpTableInfo);
+
+ ScAccessibleContextBase::disposing();
+}
+
+//===== SfxListener =====================================================
+
+void ScAccessiblePreviewTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ))
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ ULONG nId = rRef.GetId();
+ if ( nId == SFX_HINT_DATACHANGED )
+ {
+ // column / row layout may change with any document change,
+ // so it must be invalidated
+ DELETEZ( mpTableInfo );
+ }
+ else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ CommitChange(aEvent);
+ }
+ }
+
+ ScAccessibleContextBase::Notify(rBC, rHint);
+}
+
+//===== XInterface =====================================================
+
+uno::Any SAL_CALL ScAccessiblePreviewTable::queryInterface( uno::Type const & rType )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny (ScAccessiblePreviewTableImpl::queryInterface(rType));
+ return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessiblePreviewTable::acquire()
+ throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessiblePreviewTable::release()
+ throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+//===== XAccessibleTable ================================================
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowCount() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nRet = 0;
+ if ( mpTableInfo )
+ nRet = mpTableInfo->GetRows();
+ return nRet;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnCount() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nRet = 0;
+ if ( mpTableInfo )
+ nRet = mpTableInfo->GetCols();
+ return nRet;
+}
+
+rtl::OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleRowDescription( sal_Int32 nRow )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ // is not supported or specified so not implemented
+/* SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ rtl::OUString sName;
+ if ( mpTableInfo && nRow >= 0 && nRow < mpTableInfo->GetRows() )
+ {
+ const ScPreviewColRowInfo& rInfo = mpTableInfo->GetRowInfo()[nRow];
+ if ( rInfo.bIsHeader )
+ {
+ //! name of column headers row?
+
+ sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Column Headers"));
+ }
+ else
+ {
+ // normal row name
+ sName = rtl::OUString::valueOf( (sal_Int32) ( rInfo.nDocIndex + 1 ) );
+ }
+ }
+ else
+ throw lang::IndexOutOfBoundsException();*/
+
+ SolarMutexGuard aGuard;
+ FillTableInfo();
+ if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
+ throw lang::IndexOutOfBoundsException();
+
+ return rtl::OUString();
+}
+
+rtl::OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ // is not supported or specified so not implemented
+/* SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ rtl::OUString sName;
+ if ( mpTableInfo && nColumn >= 0 && nColumn < mpTableInfo->GetCols() )
+ {
+ const ScPreviewColRowInfo& rInfo = mpTableInfo->GetColInfo()[nColumn];
+ if ( rInfo.bIsHeader )
+ {
+ //! name of row headers column?
+
+ sName = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Row Headers"));
+ }
+ else
+ {
+ // normal column name
+ sName = ScColToAlpha( rInfo.nDocIndex );
+ }
+ }
+ else
+ throw lang::IndexOutOfBoundsException();*/
+
+ SolarMutexGuard aGuard;
+ FillTableInfo();
+ if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
+ throw lang::IndexOutOfBoundsException();
+
+ return rtl::OUString();
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nRows = 1;
+ if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
+ nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
+ {
+ const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
+ const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
+
+ if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
+ {
+ // header cells only span a single cell
+ }
+ else
+ {
+ ScDocument* pDoc = mpViewShell->GetDocument();
+ const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
+ static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
+ if ( pItem && pItem->GetRowMerge() > 0 )
+ nRows = pItem->GetRowMerge();
+ }
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return nRows;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nColumns = 1;
+ if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
+ nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
+ {
+ const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
+ const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
+
+ if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
+ {
+ // header cells only span a single cell
+ }
+ else
+ {
+ ScDocument* pDoc = mpViewShell->GetDocument();
+ const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
+ static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
+ if ( pItem && pItem->GetColMerge() > 0 )
+ nColumns = pItem->GetColMerge();
+ }
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return nColumns;
+}
+
+uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleRowHeaders() throw (uno::RuntimeException)
+{
+ //! missing
+ return NULL;
+}
+
+uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnHeaders() throw (uno::RuntimeException)
+{
+ //! missing
+ return NULL;
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleRows() throw (uno::RuntimeException)
+{
+ // in the page preview, there is no selection
+ return uno::Sequence<sal_Int32>(0);
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleColumns() throw (uno::RuntimeException)
+{
+ // in the page preview, there is no selection
+ return uno::Sequence<sal_Int32>(0);
+}
+
+sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleRowSelected( sal_Int32 nRow )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ // in the page preview, there is no selection
+
+ SolarMutexGuard aGuard;
+ FillTableInfo();
+ if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
+ throw lang::IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ // in the page preview, there is no selection
+
+ SolarMutexGuard aGuard;
+ FillTableInfo();
+ if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
+ throw lang::IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ uno::Reference<XAccessible> xRet;
+ if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
+ {
+ // index iterates horizontally
+ long nNewIndex = nRow * mpTableInfo->GetCols() + nColumn;
+
+ const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
+ const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
+
+ ScAddress aCellPos( static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab() );
+ if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
+ {
+ ScAccessiblePreviewHeaderCell* pHeaderCell = new ScAccessiblePreviewHeaderCell( this, mpViewShell, aCellPos,
+ rRowInfo.bIsHeader, rColInfo.bIsHeader, nNewIndex );
+ xRet = pHeaderCell;
+ pHeaderCell->Init();
+ }
+ else
+ {
+ ScAccessiblePreviewCell* pCell = new ScAccessiblePreviewCell( this, mpViewShell, aCellPos, nNewIndex );
+ xRet = pCell;
+ pCell->Init();
+ }
+ }
+
+ if ( !xRet.is() )
+ throw lang::IndexOutOfBoundsException();
+
+ return xRet;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCaption() throw (uno::RuntimeException)
+{
+ //! missing
+ return NULL;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleSummary() throw (uno::RuntimeException)
+{
+ //! missing
+ return NULL;
+}
+
+sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ // in the page preview, there is no selection
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
+ {
+ // index iterates horizontally
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nRet = 0;
+ if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
+ {
+ // index iterates horizontally
+ nRet = nRow * mpTableInfo->GetCols() + nColumn;
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return nRet;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRow( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nRow = 0;
+ if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
+ {
+ nRow = nChildIndex / mpTableInfo->GetCols();
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return nRow;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumn( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ sal_Int32 nCol = 0;
+ if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
+ {
+ nCol = nChildIndex % static_cast<sal_Int32>(mpTableInfo->GetCols());
+ }
+ else
+ throw lang::IndexOutOfBoundsException();
+
+ return nCol;
+}
+
+//===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleAtPoint( const awt::Point& aPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<XAccessible> xRet;
+ if (containsPoint(aPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ if ( mpTableInfo )
+ {
+ SCCOL nCols = mpTableInfo->GetCols();
+ SCROW nRows = mpTableInfo->GetRows();
+ const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
+ const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
+
+ Rectangle aScreenRect(GetBoundingBox());
+
+ awt::Point aMovedPoint = aPoint;
+ aMovedPoint.X += aScreenRect.Left();
+ aMovedPoint.Y += aScreenRect.Top();
+
+ if ( nCols > 0 && nRows > 0 && aMovedPoint.X >= pColInfo[0].nPixelStart && aMovedPoint.Y >= pRowInfo[0].nPixelStart )
+ {
+ SCCOL nColIndex = 0;
+ while ( nColIndex < nCols && aMovedPoint.X > pColInfo[nColIndex].nPixelEnd )
+ ++nColIndex;
+ SCROW nRowIndex = 0;
+ while ( nRowIndex < nRows && aMovedPoint.Y > pRowInfo[nRowIndex].nPixelEnd )
+ ++nRowIndex;
+ if ( nColIndex < nCols && nRowIndex < nRows )
+ {
+ try
+ {
+ xRet = getAccessibleCellAt( nRowIndex, nColIndex );
+ }
+ catch (uno::Exception&)
+ {
+ }
+ }
+ }
+ }
+ }
+
+ return xRet;
+}
+
+void SAL_CALL ScAccessiblePreviewTable::grabFocus() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ xAccessibleComponent->grabFocus();
+ }
+}
+
+//===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleChildCount() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ long nRet = 0;
+ if ( mpTableInfo )
+ nRet = static_cast<sal_Int32>(mpTableInfo->GetCols()) * mpTableInfo->GetRows();
+ return nRet;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleChild( sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ FillTableInfo();
+
+ uno::Reference<XAccessible> xRet;
+ if ( mpTableInfo )
+ {
+ long nColumns = mpTableInfo->GetCols();
+ if ( nColumns > 0 )
+ {
+ // nCol, nRow are within the visible table, not the document
+ long nCol = nIndex % nColumns;
+ long nRow = nIndex / nColumns;
+
+ xRet = getAccessibleCellAt( nRow, nCol );
+ }
+ }
+
+ if ( !xRet.is() )
+ throw lang::IndexOutOfBoundsException();
+
+ return xRet;
+}
+
+sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndexInParent() throw (uno::RuntimeException)
+{
+ return mnIndex;
+}
+
+uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePreviewTable::getAccessibleStateSet()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+//===== XServiceInfo ====================================================
+
+rtl::OUString SAL_CALL ScAccessiblePreviewTable::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScAccessiblePreviewTable"));
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScAccessiblePreviewTable::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.AccessibleTableView"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider ===================================================
+
+uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewTable::getTypes()
+ throw (uno::RuntimeException)
+{
+ return comphelper::concatSequences(ScAccessiblePreviewTableImpl::getTypes(), ScAccessibleContextBase::getTypes());
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScAccessiblePreviewTable::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+//==== internal =========================================================
+
+::rtl::OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ String sDesc(ScResId(STR_ACC_TABLE_DESCR));
+/* if (mpViewShell && mpViewShell->GetDocument())
+ {
+ FillTableInfo();
+
+ if ( mpTableInfo )
+ {
+ String sCoreName;
+ if (mpViewShell->GetDocument()->GetName( mpTableInfo->GetTab(), sCoreName ))
+ sDesc.SearchAndReplaceAscii("%1", sCoreName);
+ }
+ }
+ sDesc.SearchAndReplaceAscii("%2", String(ScResId(SCSTR_UNKNOWN)));*/
+ return rtl::OUString(sDesc);
+}
+
+::rtl::OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ String sName(ScResId(STR_ACC_TABLE_NAME));
+
+ if (mpViewShell && mpViewShell->GetDocument())
+ {
+ FillTableInfo();
+
+ if ( mpTableInfo )
+ {
+ String sCoreName;
+ if (mpViewShell->GetDocument()->GetName( mpTableInfo->GetTab(), sCoreName ))
+ sName.SearchAndReplaceAscii("%1", sCoreName);
+ }
+ }
+
+ return rtl::OUString(sName);
+}
+
+Rectangle ScAccessiblePreviewTable::GetBoundingBoxOnScreen() const throw (uno::RuntimeException)
+{
+ Rectangle aCellRect(GetBoundingBox());
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ {
+ Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
+ aCellRect.setX(aCellRect.getX() + aRect.getX());
+ aCellRect.setY(aCellRect.getY() + aRect.getY());
+ }
+ }
+ return aCellRect;
+}
+
+Rectangle ScAccessiblePreviewTable::GetBoundingBox() const throw (uno::RuntimeException)
+{
+ FillTableInfo();
+
+ Rectangle aRect;
+ if ( mpTableInfo )
+ {
+ SCCOL nColumns = mpTableInfo->GetCols();
+ SCROW nRows = mpTableInfo->GetRows();
+ if ( nColumns > 0 && nRows > 0 )
+ {
+ const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
+ const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
+
+ aRect = Rectangle( pColInfo[0].nPixelStart,
+ pRowInfo[0].nPixelStart,
+ pColInfo[nColumns-1].nPixelEnd,
+ pRowInfo[nRows-1].nPixelEnd );
+ }
+ }
+ return aRect;
+}
+
+sal_Bool ScAccessiblePreviewTable::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+void ScAccessiblePreviewTable::FillTableInfo() const
+{
+ if ( mpViewShell && !mpTableInfo )
+ {
+ Size aOutputSize;
+ Window* pWindow = mpViewShell->GetWindow();
+ if ( pWindow )
+ aOutputSize = pWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+
+ mpTableInfo = new ScPreviewTableInfo;
+ mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
new file mode 100644
index 000000000000..49e345a93039
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx
@@ -0,0 +1,996 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleSpreadsheet.hxx"
+#include "AccessibilityHints.hxx"
+#include "AccessibleCell.hxx"
+#include "AccessibleDocument.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "hints.hxx"
+#include "scmod.hxx"
+
+#include <unotools/accessiblestatesethelper.hxx>
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <tools/gen.hxx>
+#include <svtools/colorcfg.hxx>
+#include <vcl/svapp.hxx>
+
+#include <algorithm>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessibleSpreadsheet::ScAccessibleSpreadsheet(
+ ScAccessibleDocument* pAccDoc,
+ ScTabViewShell* pViewShell,
+ SCTAB nTab,
+ ScSplitPos eSplitPos)
+ :
+ ScAccessibleTableBase (pAccDoc, GetDocument(pViewShell),
+ ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))),
+ mbIsSpreadsheet( sal_True )
+{
+ ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos );
+}
+
+ScAccessibleSpreadsheet::ScAccessibleSpreadsheet(
+ ScAccessibleSpreadsheet& rParent, const ScRange& rRange ) :
+ ScAccessibleTableBase( rParent.mpAccDoc, rParent.mpDoc, rRange),
+ mbIsSpreadsheet( sal_False )
+{
+ ConstructScAccessibleSpreadsheet( rParent.mpAccDoc, rParent.mpViewShell, rParent.mnTab, rParent.meSplitPos );
+}
+
+ScAccessibleSpreadsheet::~ScAccessibleSpreadsheet()
+{
+ if (mpMarkedRanges)
+ delete mpMarkedRanges;
+ if (mpSortedMarkedCells)
+ delete mpSortedMarkedCells;
+ if (mpViewShell)
+ mpViewShell->RemoveAccessibilityObject(*this);
+}
+
+void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet(
+ ScAccessibleDocument* pAccDoc,
+ ScTabViewShell* pViewShell,
+ SCTAB nTab,
+ ScSplitPos eSplitPos)
+{
+ mpViewShell = pViewShell;
+ mpMarkedRanges = 0;
+ mpSortedMarkedCells = 0;
+ mpAccDoc = pAccDoc;
+ mpAccCell = 0;
+ meSplitPos = eSplitPos;
+ mnTab = nTab;
+ mbHasSelection = sal_False;
+ mbDelIns = sal_False;
+ mbIsFocusSend = sal_False;
+ maVisCells = GetVisCells(GetVisArea(mpViewShell, meSplitPos));
+ if (mpViewShell)
+ {
+ mpViewShell->AddAccessibilityObject(*this);
+
+ const ScViewData& rViewData = *mpViewShell->GetViewData();
+ const ScMarkData& rMarkData = rViewData.GetMarkData();
+ maActiveCell = rViewData.GetCurPos();
+ mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) &&
+ (rMarkData.IsMarked() || rMarkData.IsMultiMarked());
+ mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col());
+ mpAccCell->acquire();
+ mpAccCell->Init();
+ }
+}
+
+void SAL_CALL ScAccessibleSpreadsheet::disposing()
+{
+ SolarMutexGuard aGuard;
+ if (mpViewShell)
+ {
+ mpViewShell->RemoveAccessibilityObject(*this);
+ mpViewShell = NULL;
+ }
+ if (mpAccCell)
+ {
+ mpAccCell->release();
+ mpAccCell = NULL;
+ }
+
+ ScAccessibleTableBase::disposing();
+}
+
+void ScAccessibleSpreadsheet::CompleteSelectionChanged(sal_Bool bNewState)
+{
+ if (mpMarkedRanges)
+ DELETEZ(mpMarkedRanges);
+ if (mpSortedMarkedCells)
+ DELETEZ(mpSortedMarkedCells);
+
+ mbHasSelection = bNewState;
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::STATE_CHANGED;
+ if (bNewState)
+ aEvent.NewValue = uno::makeAny(AccessibleStateType::SELECTED);
+ else
+ aEvent.OldValue = uno::makeAny(AccessibleStateType::SELECTED);
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);
+}
+
+void ScAccessibleSpreadsheet::LostFocus()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ uno::Reference< XAccessible > xOld = mpAccCell;
+ aEvent.OldValue <<= xOld;
+
+ CommitChange(aEvent);
+
+ CommitFocusLost();
+}
+
+void ScAccessibleSpreadsheet::GotFocus()
+{
+ CommitFocusGained();
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ uno::Reference< XAccessible > xNew = mpAccCell;
+ aEvent.NewValue <<= xNew;
+
+ CommitChange(aEvent);
+}
+
+void ScAccessibleSpreadsheet::BoundingBoxChanged()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);
+}
+
+void ScAccessibleSpreadsheet::VisAreaChanged()
+{
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);
+}
+
+ //===== SfxListener =====================================================
+
+void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA( SfxSimpleHint ) )
+ {
+ const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
+ // only notify if child exist, otherwise it is not necessary
+ if ((rRef.GetId() == SC_HINT_ACC_CURSORCHANGED))
+ {
+ if (mpViewShell)
+ {
+ ScAddress aNewCell = mpViewShell->GetViewData()->GetCurPos();
+ sal_Bool bNewMarked(mpViewShell->GetViewData()->GetMarkData().GetTableSelect(aNewCell.Tab()) &&
+ (mpViewShell->GetViewData()->GetMarkData().IsMarked() ||
+ mpViewShell->GetViewData()->GetMarkData().IsMultiMarked()));
+ sal_Bool bNewCellSelected(isAccessibleSelected(aNewCell.Row(), aNewCell.Col()));
+ if ((bNewMarked != mbHasSelection) ||
+ (!bNewCellSelected && bNewMarked) ||
+ (bNewCellSelected && mbHasSelection))
+ {
+ if (mpMarkedRanges)
+ DELETEZ(mpMarkedRanges);
+ if (mpSortedMarkedCells)
+ DELETEZ(mpSortedMarkedCells);
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ mbHasSelection = bNewMarked;
+
+ CommitChange(aEvent);
+ }
+
+ // active descendant changed event (new cell selected)
+ bool bFireActiveDescChanged = (aNewCell != maActiveCell) &&
+ (aNewCell.Tab() == maActiveCell.Tab()) && IsFocused();
+
+ /* Remember old active cell and set new active cell.
+ #i82409# always update the class members mpAccCell and
+ maActiveCell, even if the sheet is not focused, e.g. when
+ using the name box in the toolbar. */
+ uno::Reference< XAccessible > xOld = mpAccCell;
+ mpAccCell->release();
+ mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col());
+ mpAccCell->acquire();
+ mpAccCell->Init();
+ uno::Reference< XAccessible > xNew = mpAccCell;
+ maActiveCell = aNewCell;
+
+ // #i14108# fire event only if sheet is focused
+ if( bFireActiveDescChanged )
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.OldValue <<= xOld;
+ aEvent.NewValue <<= xNew;
+ CommitChange(aEvent);
+ }
+ }
+ }
+ else if ((rRef.GetId() == SC_HINT_DATACHANGED))
+ {
+ if (!mbDelIns)
+ CommitTableModelChange(maRange.aStart.Row(), maRange.aStart.Col(), maRange.aEnd.Row(), maRange.aEnd.Col(), AccessibleTableModelChangeType::UPDATE);
+ else
+ mbDelIns = sal_False;
+ }
+ // no longer needed, because the document calls the VisAreaChanged method
+/* else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);*/
+ // commented out, because to use a ModelChangeEvent is not the right way
+ // at the moment there is no way, but the Java/Gnome Api should be extended sometime
+/* if (mpViewShell)
+ {
+ Rectangle aNewVisCells(GetVisCells(GetVisArea(mpViewShell, meSplitPos)));
+
+ Rectangle aNewPos(aNewVisCells);
+
+ if (aNewVisCells.IsOver(maVisCells))
+ aNewPos.Union(maVisCells);
+ else
+ CommitTableModelChange(maVisCells.Top(), maVisCells.Left(), maVisCells.Bottom(), maVisCells.Right(), AccessibleTableModelChangeType::UPDATE);
+
+ maVisCells = aNewVisCells;
+
+ CommitTableModelChange(aNewPos.Top(), aNewPos.Left(), aNewPos.Bottom(), aNewPos.Right(), AccessibleTableModelChangeType::UPDATE);
+ }
+ }*/
+ // no longer needed, because the document calls the BoundingBoxChanged method
+/* else if (rRef.GetId() == SC_HINT_ACC_WINDOWRESIZED)
+ {
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+
+ CommitChange(aEvent);
+ }*/
+ }
+ else if (rHint.ISA( ScUpdateRefHint ))
+ {
+ const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+ if (rRef.GetMode() == URM_INSDEL && rRef.GetDz() == 0) //#107250# test whether table is inserted or deleted
+ {
+ if (((rRef.GetRange().aStart.Col() == maRange.aStart.Col()) &&
+ (rRef.GetRange().aEnd.Col() == maRange.aEnd.Col())) ||
+ ((rRef.GetRange().aStart.Row() == maRange.aStart.Row()) &&
+ (rRef.GetRange().aEnd.Row() == maRange.aEnd.Row())))
+ {
+ // ignore next SC_HINT_DATACHANGED notification
+ mbDelIns = sal_True;
+
+ sal_Int16 nId(0);
+ SCsCOL nX(rRef.GetDx());
+ SCsROW nY(rRef.GetDy());
+ ScRange aRange(rRef.GetRange());
+ if ((nX < 0) || (nY < 0))
+ {
+ DBG_ASSERT(!((nX < 0) && (nY < 0)), "should not be possible to remove row and column at the same time");
+ nId = AccessibleTableModelChangeType::DELETE;
+ if (nX < 0)
+ {
+ nX = -nX;
+ nY = aRange.aEnd.Row() - aRange.aStart.Row();
+ }
+ else
+ {
+ nY = -nY;
+ nX = aRange.aEnd.Col() - aRange.aStart.Col();
+ }
+ }
+ else if ((nX > 0) || (nY > 0))
+ {
+ DBG_ASSERT(!((nX > 0) && (nY > 0)), "should not be possible to add row and column at the same time");
+ nId = AccessibleTableModelChangeType::INSERT;
+ if (nX < 0)
+ nY = aRange.aEnd.Row() - aRange.aStart.Row();
+ else
+ nX = aRange.aEnd.Col() - aRange.aStart.Col();
+ }
+ else
+ {
+ DBG_ERROR("is it a deletion or a insertion?");
+ }
+
+ CommitTableModelChange(rRef.GetRange().aStart.Row(),
+ rRef.GetRange().aStart.Col(),
+ rRef.GetRange().aStart.Row() + nY,
+ rRef.GetRange().aStart.Col() + nX, nId);
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ uno::Reference< XAccessible > xNew = mpAccCell;
+ aEvent.NewValue <<= xNew;
+
+ CommitChange(aEvent);
+ }
+ }
+ }
+
+ ScAccessibleTableBase::Notify(rBC, rHint);
+}
+
+ //===== XAccessibleTable ================================================
+
+uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleRowHeaders( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference< XAccessibleTable > xAccessibleTable;
+ if( mpDoc && mbIsSpreadsheet )
+ {
+ if( const ScRange* pRowRange = mpDoc->GetRepeatRowRange( mnTab ) )
+ {
+ SCROW nStart = pRowRange->aStart.Row();
+ SCROW nEnd = pRowRange->aEnd.Row();
+ if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXROW) )
+ xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( 0, nStart, mnTab, MAXCOL, nEnd, mnTab ) ) );
+ }
+ }
+ return xAccessibleTable;
+}
+
+uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleColumnHeaders( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference< XAccessibleTable > xAccessibleTable;
+ if( mpDoc && mbIsSpreadsheet )
+ {
+ if( const ScRange* pColRange = mpDoc->GetRepeatColRange( mnTab ) )
+ {
+ SCCOL nStart = pColRange->aStart.Col();
+ SCCOL nEnd = pColRange->aEnd.Col();
+ if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXCOL) )
+ xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( nStart, 0, mnTab, nEnd, MAXROW, mnTab ) ) );
+ }
+ }
+ return xAccessibleTable;
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleRows( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Sequence<sal_Int32> aSequence;
+ if (mpViewShell && mpViewShell->GetViewData())
+ {
+ aSequence.realloc(maRange.aEnd.Row() - maRange.aStart.Row() + 1);
+ const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
+ sal_Int32* pSequence = aSequence.getArray();
+ sal_Int32 nCount(0);
+ for (SCROW i = maRange.aStart.Row(); i <= maRange.aEnd.Row(); ++i)
+ {
+ if (rMarkdata.IsRowMarked(i))
+ {
+ pSequence[nCount] = i;
+ ++nCount;
+ }
+ }
+ aSequence.realloc(nCount);
+ }
+ else
+ aSequence.realloc(0);
+ return aSequence;
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleColumns( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Sequence<sal_Int32> aSequence;
+ if (mpViewShell && mpViewShell->GetViewData())
+ {
+ aSequence.realloc(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
+ const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
+ sal_Int32* pSequence = aSequence.getArray();
+ sal_Int32 nCount(0);
+ for (SCCOL i = maRange.aStart.Col(); i <= maRange.aEnd.Col(); ++i)
+ {
+ if (rMarkdata.IsColumnMarked(i))
+ {
+ pSequence[nCount] = i;
+ ++nCount;
+ }
+ }
+ aSequence.realloc(nCount);
+ }
+ else
+ aSequence.realloc(0);
+ return aSequence;
+}
+
+sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nRow )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Bool bResult(sal_False);
+ if (mpViewShell && mpViewShell->GetViewData())
+ {
+ const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
+ bResult = rMarkdata.IsRowMarked((SCROW)nRow);
+ }
+ return bResult;
+}
+
+sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Bool bResult(sal_False);
+ if (mpViewShell && mpViewShell->GetViewData())
+ {
+ const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
+ bResult = rMarkdata.IsColumnMarked((SCCOL)nColumn);
+ }
+ return bResult;
+}
+
+ScAccessibleCell* ScAccessibleSpreadsheet::GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn)
+{
+ ScAccessibleCell* pAccessibleCell = NULL;
+ ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn),
+ static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab());
+ if ((aCellAddress == maActiveCell) && mpAccCell)
+ {
+ pAccessibleCell = mpAccCell;
+ }
+ else
+ pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc);
+
+ return pAccessibleCell;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) ||
+ nRow < 0 ||
+ nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) ||
+ nColumn < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ uno::Reference<XAccessible> xAccessible;
+ ScAccessibleCell* pAccessibleCell = GetAccessibleCellAt(nRow, nColumn);
+ xAccessible = pAccessibleCell;
+ pAccessibleCell->Init();
+ return xAccessible;
+}
+
+sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
+ (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Bool bResult(sal_False);
+ if (mpViewShell)
+ {
+ const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
+ bResult = rMarkdata.IsCellMarked(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow));
+ }
+ return bResult;
+}
+
+ //===== XAccessibleComponent ============================================
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleAtPoint(
+ const awt::Point& rPoint )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< XAccessible > xAccessible;
+ if (containsPoint(rPoint))
+ {
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpViewShell)
+ {
+ SCsCOL nX;
+ SCsROW nY;
+ mpViewShell->GetViewData()->GetPosFromPixel( rPoint.X, rPoint.Y, meSplitPos, nX, nY);
+ xAccessible = getAccessibleCellAt(nY, nX);
+ }
+ }
+ return xAccessible;
+}
+
+void SAL_CALL ScAccessibleSpreadsheet::grabFocus( )
+ throw (uno::RuntimeException)
+{
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
+ if (xAccessibleComponent.is())
+ xAccessibleComponent->grabFocus();
+ }
+}
+
+sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getForeground( )
+ throw (uno::RuntimeException)
+{
+ return COL_BLACK;
+}
+
+sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getBackground( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
+}
+
+ //===== XAccessibleContext ==============================================
+
+uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleSpreadsheet::getAccessibleRelationSet(void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ utl::AccessibleRelationSetHelper* pRelationSet = NULL;
+ if(mpAccDoc)
+ pRelationSet = mpAccDoc->GetRelationSet(NULL);
+ if (!pRelationSet)
+ pRelationSet = new utl::AccessibleRelationSetHelper();
+ return pRelationSet;
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessibleSpreadsheet::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<XAccessibleStateSet> xParentStates;
+ if (getAccessibleParent().is())
+ {
+ uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
+ xParentStates = xParentContext->getAccessibleStateSet();
+ }
+ utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
+ if (IsDefunc(xParentStates))
+ pStateSet->AddState(AccessibleStateType::DEFUNC);
+ else
+ {
+ pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
+ if (IsEditable(xParentStates))
+ pStateSet->AddState(AccessibleStateType::EDITABLE);
+ pStateSet->AddState(AccessibleStateType::ENABLED);
+ pStateSet->AddState(AccessibleStateType::FOCUSABLE);
+ if (IsFocused())
+ pStateSet->AddState(AccessibleStateType::FOCUSED);
+ pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE);
+ pStateSet->AddState(AccessibleStateType::OPAQUE);
+ pStateSet->AddState(AccessibleStateType::SELECTABLE);
+ if (IsCompleteSheetSelected())
+ pStateSet->AddState(AccessibleStateType::SELECTED);
+ if (isShowing())
+ pStateSet->AddState(AccessibleStateType::SHOWING);
+ if (isVisible())
+ pStateSet->AddState(AccessibleStateType::VISIBLE);
+ }
+ return pStateSet;
+}
+
+ ///===== XAccessibleSelection ===========================================
+
+void SAL_CALL
+ ScAccessibleSpreadsheet::selectAccessibleChild( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
+ throw lang::IndexOutOfBoundsException();
+
+ if (mpViewShell)
+ {
+ sal_Int32 nCol(getAccessibleColumn(nChildIndex));
+ sal_Int32 nRow(getAccessibleRow(nChildIndex));
+
+ SelectCell(nRow, nCol, sal_False);
+ }
+}
+
+void SAL_CALL
+ ScAccessibleSpreadsheet::clearAccessibleSelection( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpViewShell)
+ {
+ mpViewShell->Unmark();
+ }
+}
+
+void SAL_CALL
+ ScAccessibleSpreadsheet::selectAllAccessibleChildren( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ if (mpViewShell)
+ {
+ mpViewShell->SelectAll();
+ }
+}
+
+sal_Int32 SAL_CALL
+ ScAccessibleSpreadsheet::getSelectedAccessibleChildCount( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ sal_Int32 nResult(0);
+ if (mpViewShell)
+ {
+ if (!mpMarkedRanges)
+ {
+ mpMarkedRanges = new ScRangeList();
+ ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
+ aMarkData.MarkToMulti();
+ aMarkData.FillRangeListWithMarks(mpMarkedRanges, sal_False);
+ }
+ // is possible, because there shouldn't be overlapped ranges in it
+ if (mpMarkedRanges)
+ nResult = mpMarkedRanges->GetCellCount();
+ }
+ return nResult;
+}
+
+uno::Reference<XAccessible > SAL_CALL
+ ScAccessibleSpreadsheet::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ uno::Reference < XAccessible > xAccessible;
+ if (mpViewShell)
+ {
+ if (!mpMarkedRanges)
+ {
+ mpMarkedRanges = new ScRangeList();
+ mpViewShell->GetViewData()->GetMarkData().FillRangeListWithMarks(mpMarkedRanges, sal_False);
+ }
+ if (mpMarkedRanges)
+ {
+ if (!mpSortedMarkedCells)
+ CreateSortedMarkedCells();
+ if (mpSortedMarkedCells)
+ {
+ if ((nSelectedChildIndex < 0) ||
+ (mpSortedMarkedCells->size() <= static_cast<sal_uInt32>(nSelectedChildIndex)))
+ throw lang::IndexOutOfBoundsException();
+ else
+ xAccessible = getAccessibleCellAt((*mpSortedMarkedCells)[nSelectedChildIndex].Row(), (*mpSortedMarkedCells)[nSelectedChildIndex].Col());
+ }
+ }
+ }
+ return xAccessible;
+}
+
+void SAL_CALL
+ ScAccessibleSpreadsheet::deselectAccessibleChild( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
+ throw lang::IndexOutOfBoundsException();
+
+ if (mpViewShell)
+ {
+ sal_Int32 nCol(getAccessibleColumn(nChildIndex));
+ sal_Int32 nRow(getAccessibleRow(nChildIndex));
+
+ if (mpViewShell->GetViewData()->GetMarkData().IsCellMarked(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow)))
+ SelectCell(nRow, nCol, sal_True);
+ }
+}
+
+void ScAccessibleSpreadsheet::SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect)
+{
+ mpViewShell->SetTabNo( maRange.aStart.Tab() );
+
+ mpViewShell->DoneBlockMode( sal_True ); // continue selecting
+ mpViewShell->InitBlockMode( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), maRange.aStart.Tab(), bDeselect, sal_False, sal_False );
+
+ mpViewShell->SelectionChanged();
+}
+
+void ScAccessibleSpreadsheet::CreateSortedMarkedCells()
+{
+ mpSortedMarkedCells = new std::vector<ScMyAddress>();
+ mpSortedMarkedCells->reserve(mpMarkedRanges->GetCellCount());
+ ScRange* pRange = mpMarkedRanges->First();
+ while (pRange)
+ {
+ if (pRange->aStart.Tab() != pRange->aEnd.Tab())
+ {
+ if ((maActiveCell.Tab() >= pRange->aStart.Tab()) ||
+ maActiveCell.Tab() <= pRange->aEnd.Tab())
+ {
+ ScRange aRange(*pRange);
+ aRange.aStart.SetTab(maActiveCell.Tab());
+ aRange.aEnd.SetTab(maActiveCell.Tab());
+ AddMarkedRange(aRange);
+ }
+ else
+ {
+ DBG_ERROR("Range of wrong table");
+ }
+ }
+ else if(pRange->aStart.Tab() == maActiveCell.Tab())
+ AddMarkedRange(*pRange);
+ else
+ {
+ DBG_ERROR("Range of wrong table");
+ }
+ pRange = mpMarkedRanges->Next();
+ }
+ std::sort(mpSortedMarkedCells->begin(), mpSortedMarkedCells->end());
+}
+
+void ScAccessibleSpreadsheet::AddMarkedRange(const ScRange& rRange)
+{
+ for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
+ {
+ for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
+ {
+ ScMyAddress aCell(nCol, nRow, maActiveCell.Tab());
+ mpSortedMarkedCells->push_back(aCell);
+ }
+ }
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleSpreadsheet::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleSpreadsheet"));
+}
+
+uno::Sequence< ::rtl::OUString> SAL_CALL
+ ScAccessibleSpreadsheet::getSupportedServiceNames (void)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleTableBase::getSupportedServiceNames();
+ sal_Int32 nOldSize(aSequence.getLength());
+ aSequence.realloc(nOldSize + 1);
+ ::rtl::OUString* pNames = aSequence.getArray();
+
+ pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheet"));
+
+ return aSequence;
+}
+
+//===== XTypeProvider =======================================================
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleSpreadsheet::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+///===== XAccessibleEventBroadcaster =====================================
+
+void SAL_CALL ScAccessibleSpreadsheet::addEventListener(const uno::Reference<XAccessibleEventListener>& xListener)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ ScAccessibleTableBase::addEventListener(xListener);
+
+ if (!mbIsFocusSend)
+ {
+ mbIsFocusSend = sal_True;
+ CommitFocusGained();
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.NewValue <<= getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col());
+
+ CommitChange(aEvent);
+ }
+}
+
+ //==== internal =========================================================
+
+Rectangle ScAccessibleSpreadsheet::GetBoundingBoxOnScreen() const
+ throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ aRect = pWindow->GetWindowExtentsRelative(NULL);
+ }
+ return aRect;
+}
+
+Rectangle ScAccessibleSpreadsheet::GetBoundingBox() const
+ throw (uno::RuntimeException)
+{
+ Rectangle aRect;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ //#101986#; extends to the same window, because the parent is the document and it has the same window
+ aRect = pWindow->GetWindowExtentsRelative(pWindow);
+ }
+ return aRect;
+}
+
+sal_Bool ScAccessibleSpreadsheet::IsDefunc(
+ const uno::Reference<XAccessibleStateSet>& rxParentStates)
+{
+ return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
+ (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
+}
+
+sal_Bool ScAccessibleSpreadsheet::IsEditable(
+ const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
+{
+ sal_Bool bProtected(sal_False);
+ if (mpDoc && mpDoc->IsTabProtected(maRange.aStart.Tab()))
+ bProtected = sal_True;
+ return !bProtected;
+}
+
+sal_Bool ScAccessibleSpreadsheet::IsFocused()
+{
+ sal_Bool bFocused(sal_False);
+ if (mpViewShell)
+ {
+ if (mpViewShell->GetViewData()->GetActivePart() == meSplitPos)
+ bFocused = mpViewShell->GetActiveWin()->HasFocus();
+ }
+ return bFocused;
+}
+
+sal_Bool ScAccessibleSpreadsheet::IsCompleteSheetSelected()
+{
+ sal_Bool bResult(sal_False);
+ if(mpViewShell)
+ {
+ //#103800#; use a copy of MarkData
+ ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
+ aMarkData.MarkToMulti();
+ if (aMarkData.IsAllMarked(maRange))
+ bResult = sal_True;
+ }
+ return bResult;
+}
+
+ScDocument* ScAccessibleSpreadsheet::GetDocument(ScTabViewShell* pViewShell)
+{
+ ScDocument* pDoc = NULL;
+ if (pViewShell)
+ pDoc = pViewShell->GetViewData()->GetDocument();
+ return pDoc;
+}
+
+Rectangle ScAccessibleSpreadsheet::GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos)
+{
+ Rectangle aVisArea;
+ if (pViewShell)
+ {
+ Window* pWindow = pViewShell->GetWindowByPos(eSplitPos);
+ if (pWindow)
+ {
+ aVisArea.SetPos(pViewShell->GetViewData()->GetPixPos(eSplitPos));
+ aVisArea.SetSize(pWindow->GetSizePixel());
+ }
+ }
+ return aVisArea;
+}
+
+Rectangle ScAccessibleSpreadsheet::GetVisCells(const Rectangle& rVisArea)
+{
+ if (mpViewShell)
+ {
+ SCsCOL nStartX, nEndX;
+ SCsROW nStartY, nEndY;
+
+ mpViewShell->GetViewData()->GetPosFromPixel( 1, 1, meSplitPos, nStartX, nStartY);
+ mpViewShell->GetViewData()->GetPosFromPixel( rVisArea.GetWidth(), rVisArea.GetHeight(), meSplitPos, nEndX, nEndY);
+
+ return Rectangle(nStartX, nStartY, nEndX, nEndY);
+ }
+ else
+ return Rectangle();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleTableBase.cxx b/sc/source/ui/Accessibility/AccessibleTableBase.cxx
new file mode 100644
index 000000000000..bf0ef109cf68
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleTableBase.cxx
@@ -0,0 +1,494 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "AccessibleTableBase.hxx"
+#include "miscuno.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+#include <com/sun/star/accessibility/AccessibleRole.hpp>
+#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
+#include <rtl/uuid.h>
+#include <tools/debug.hxx>
+#include <comphelper/sequence.hxx>
+#include <vcl/svapp.hxx>
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::accessibility;
+
+//===== internal ============================================================
+
+ScAccessibleTableBase::ScAccessibleTableBase(
+ const uno::Reference<XAccessible>& rxParent,
+ ScDocument* pDoc,
+ const ScRange& rRange)
+ :
+ ScAccessibleContextBase (rxParent, AccessibleRole::TABLE),
+ maRange(rRange),
+ mpDoc(pDoc)
+{
+}
+
+ScAccessibleTableBase::~ScAccessibleTableBase()
+{
+}
+
+void SAL_CALL ScAccessibleTableBase::disposing()
+{
+ SolarMutexGuard aGuard;
+ mpDoc = NULL;
+
+ ScAccessibleContextBase::disposing();
+}
+
+ //===== XInterface =====================================================
+
+uno::Any SAL_CALL ScAccessibleTableBase::queryInterface( uno::Type const & rType )
+ throw (uno::RuntimeException)
+{
+ uno::Any aAny (ScAccessibleTableBaseImpl::queryInterface(rType));
+ return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
+}
+
+void SAL_CALL ScAccessibleTableBase::acquire()
+ throw ()
+{
+ ScAccessibleContextBase::acquire();
+}
+
+void SAL_CALL ScAccessibleTableBase::release()
+ throw ()
+{
+ ScAccessibleContextBase::release();
+}
+
+ //===== XAccessibleTable ================================================
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowCount( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return maRange.aEnd.Row() - maRange.aStart.Row() + 1;
+}
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnCount( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return maRange.aEnd.Col() - maRange.aStart.Col() + 1;
+}
+
+::rtl::OUString SAL_CALL ScAccessibleTableBase::getAccessibleRowDescription( sal_Int32 nRow )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ DBG_ERROR("Here should be a implementation to fill the description");
+
+ if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ //setAccessibleRowDescription(nRow, xAccessible); // to remember the created Description
+ return rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL ScAccessibleTableBase::getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ DBG_ERROR("Here should be a implementation to fill the description");
+
+ if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ //setAccessibleColumnDescription(nColumn, xAccessible); // to remember the created Description
+ return rtl::OUString();
+}
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
+ (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Int32 nCount(1); // the same cell
+ nRow += maRange.aStart.Row();
+ nColumn += maRange.aStart.Col();
+
+ if (mpDoc)
+ {
+ SCROW nEndRow(0);
+ SCCOL nEndCol(0);
+ if (mpDoc->ExtendMerge(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow),
+ nEndCol, nEndRow, maRange.aStart.Tab()))
+ {
+ if (nEndRow > nRow)
+ nCount = nEndRow - nRow + 1;
+ }
+ }
+
+ return nCount;
+}
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
+ (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Int32 nCount(1); // the same cell
+ nRow += maRange.aStart.Row();
+ nColumn += maRange.aStart.Col();
+
+ if (mpDoc)
+ {
+ SCROW nEndRow(0);
+ SCCOL nEndCol(0);
+ if (mpDoc->ExtendMerge(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow),
+ nEndCol, nEndRow, maRange.aStart.Tab()))
+ {
+ if (nEndCol > nColumn)
+ nCount = nEndCol - nColumn + 1;
+ }
+ }
+
+ return nCount;
+}
+
+uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleTableBase::getAccessibleRowHeaders( )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< XAccessibleTable > xAccessibleTable;
+ DBG_ERROR("Here should be a implementation to fill the row headers");
+
+ //CommitChange
+ return xAccessibleTable;
+}
+
+uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleTableBase::getAccessibleColumnHeaders( )
+ throw (uno::RuntimeException)
+{
+ uno::Reference< XAccessibleTable > xAccessibleTable;
+ DBG_ERROR("Here should be a implementation to fill the column headers");
+
+ //CommitChange
+ return xAccessibleTable;
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleTableBase::getSelectedAccessibleRows( )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented yet");
+ uno::Sequence< sal_Int32 > aSequence;
+ return aSequence;
+}
+
+uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleTableBase::getSelectedAccessibleColumns( )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented yet");
+ uno::Sequence< sal_Int32 > aSequence;
+ return aSequence;
+}
+
+sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleRowSelected( sal_Int32 /* nRow */ )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ DBG_ERROR("not implemented yet");
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleColumnSelected( sal_Int32 /* nColumn */ )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ DBG_ERROR("not implemented yet");
+ return sal_False;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleCellAt( sal_Int32 /* nRow */, sal_Int32 /* nColumn */ )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ DBG_ERROR("not implemented yet");
+ uno::Reference< XAccessible > xAccessible;
+ return xAccessible;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleCaption( )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented yet");
+ uno::Reference< XAccessible > xAccessible;
+ return xAccessible;
+}
+
+uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleSummary( )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented yet");
+ uno::Reference< XAccessible > xAccessible;
+ return xAccessible;
+}
+
+sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleSelected( sal_Int32 /* nRow */, sal_Int32 /* nColumn */ )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ DBG_ERROR("not implemented yet");
+ return sal_False;
+}
+
+ //===== XAccessibleExtendedTable ========================================
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) ||
+ nRow < 0 ||
+ nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) ||
+ nColumn < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ nRow -= maRange.aStart.Row();
+ nColumn -= maRange.aStart.Col();
+ return (nRow * (maRange.aEnd.Col() + 1)) + nColumn;
+}
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRow( sal_Int32 nChildIndex )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ return nChildIndex / (maRange.aEnd.Col() - maRange.aStart.Col() + 1);
+}
+
+sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumn( sal_Int32 nChildIndex )
+ throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ return nChildIndex % static_cast<sal_Int32>(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
+}
+
+ //===== XAccessibleContext ==============================================
+
+sal_Int32 SAL_CALL
+ ScAccessibleTableBase::getAccessibleChildCount(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ return static_cast<sal_Int32>(maRange.aEnd.Row() - maRange.aStart.Row() + 1) *
+ (maRange.aEnd.Col() - maRange.aStart.Col() + 1);
+// return 1;
+}
+
+uno::Reference< XAccessible > SAL_CALL
+ ScAccessibleTableBase::getAccessibleChild(sal_Int32 nIndex)
+ throw (uno::RuntimeException,
+ lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+
+ if (nIndex >= getAccessibleChildCount() || nIndex < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ sal_Int32 nRow(0);
+ sal_Int32 nColumn(0);
+ sal_Int32 nTemp(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
+ nRow = nIndex / nTemp;
+ nColumn = nIndex % nTemp;
+ return getAccessibleCellAt(nRow, nColumn);
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleTableBase::createAccessibleDescription(void)
+ throw (uno::RuntimeException)
+{
+ String sDesc(ScResId(STR_ACC_TABLE_DESCR));
+/* String sCoreName;
+ if (mpDoc && mpDoc->GetName( maRange.aStart.Tab(), sCoreName ))
+ sDesc.SearchAndReplaceAscii("%1", sCoreName);
+ sDesc.SearchAndReplaceAscii("%2", String(ScResId(SCSTR_UNKNOWN)));*/
+ return rtl::OUString(sDesc);
+}
+
+::rtl::OUString SAL_CALL
+ ScAccessibleTableBase::createAccessibleName(void)
+ throw (uno::RuntimeException)
+{
+ String sName(ScResId(STR_ACC_TABLE_NAME));
+ String sCoreName;
+ if (mpDoc && mpDoc->GetName( maRange.aStart.Tab(), sCoreName ))
+ sName.SearchAndReplaceAscii("%1", sCoreName);
+ return rtl::OUString(sName);
+}
+
+uno::Reference<XAccessibleRelationSet> SAL_CALL
+ ScAccessibleTableBase::getAccessibleRelationSet(void)
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("should be implemented in the abrevated class");
+ return uno::Reference<XAccessibleRelationSet>();
+}
+
+uno::Reference<XAccessibleStateSet> SAL_CALL
+ ScAccessibleTableBase::getAccessibleStateSet(void)
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("should be implemented in the abrevated class");
+ uno::Reference< XAccessibleStateSet > xAccessibleStateSet;
+ return xAccessibleStateSet;
+}
+
+ ///===== XAccessibleSelection ===========================================
+
+void SAL_CALL
+ ScAccessibleTableBase::selectAccessibleChild( sal_Int32 /* nChildIndex */ )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+}
+
+sal_Bool SAL_CALL
+ ScAccessibleTableBase::isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ // I don't need to guard, because the called funtions have a guard
+// SolarMutexGuard aGuard;
+ if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
+ throw lang::IndexOutOfBoundsException();
+ return isAccessibleSelected(getAccessibleRow(nChildIndex), getAccessibleColumn(nChildIndex));
+}
+
+void SAL_CALL
+ ScAccessibleTableBase::clearAccessibleSelection( )
+ throw (uno::RuntimeException)
+{
+}
+
+void SAL_CALL
+ ScAccessibleTableBase::selectAllAccessibleChildren( )
+ throw (uno::RuntimeException)
+{
+}
+
+sal_Int32 SAL_CALL
+ ScAccessibleTableBase::getSelectedAccessibleChildCount( )
+ throw (uno::RuntimeException)
+{
+ sal_Int32 nResult(0);
+ return nResult;
+}
+
+uno::Reference<XAccessible > SAL_CALL
+ ScAccessibleTableBase::getSelectedAccessibleChild( sal_Int32 /* nSelectedChildIndex */ )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ uno::Reference < XAccessible > xAccessible;
+ return xAccessible;
+}
+
+void SAL_CALL
+ ScAccessibleTableBase::deselectAccessibleChild( sal_Int32 /* nSelectedChildIndex */ )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+}
+
+ //===== XServiceInfo ====================================================
+
+::rtl::OUString SAL_CALL ScAccessibleTableBase::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleTableBase"));
+}
+
+ //===== XTypeProvider ===================================================
+
+uno::Sequence< uno::Type > SAL_CALL ScAccessibleTableBase::getTypes()
+ throw (uno::RuntimeException)
+{
+ return comphelper::concatSequences(ScAccessibleTableBaseImpl::getTypes(), ScAccessibleContextBase::getTypes());
+}
+
+uno::Sequence<sal_Int8> SAL_CALL
+ ScAccessibleTableBase::getImplementationId(void)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ IsObjectValid();
+ static uno::Sequence<sal_Int8> aId;
+ if (aId.getLength() == 0)
+ {
+ aId.realloc (16);
+ rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True);
+ }
+ return aId;
+}
+
+void ScAccessibleTableBase::CommitTableModelChange(sal_Int32 nStartRow, sal_Int32 nStartCol, sal_Int32 nEndRow, sal_Int32 nEndCol, sal_uInt16 nId)
+{
+ AccessibleTableModelChange aModelChange;
+ aModelChange.FirstRow = nStartRow;
+ aModelChange.FirstColumn = nStartCol;
+ aModelChange.LastRow = nEndRow;
+ aModelChange.LastColumn = nEndCol;
+ aModelChange.Type = nId;
+
+ AccessibleEventObject aEvent;
+ aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
+ aEvent.Source = uno::Reference< XAccessibleContext >(this);
+ aEvent.NewValue <<= aModelChange;
+
+ CommitChange(aEvent);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
new file mode 100644
index 000000000000..2f7c5e861b6f
--- /dev/null
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -0,0 +1,1846 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <memory>
+#include "AccessibleText.hxx"
+#include "AccessibleCell.hxx"
+#include "tabvwsh.hxx"
+#include "editutil.hxx"
+#include "document.hxx"
+#include "scmod.hxx"
+#include "prevwsh.hxx"
+#include "docsh.hxx"
+#include "prevloc.hxx"
+#include "patattr.hxx"
+#include "inputwin.hxx"
+#include <editeng/unofored.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/unoedhlp.hxx>
+#include <vcl/virdev.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/algitem.hxx>
+#include <vcl/svapp.hxx>
+
+
+// ============================================================================
+
+class ScViewForwarder : public SvxViewForwarder
+{
+ ScTabViewShell* mpViewShell;
+ ScAddress maCellPos;
+ ScSplitPos meSplitPos;
+public:
+ ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell);
+ virtual ~ScViewForwarder();
+
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
+
+ void SetInvalid();
+};
+
+ScViewForwarder::ScViewForwarder(ScTabViewShell* pViewShell, ScSplitPos eSplitPos, const ScAddress& rCell)
+ :
+ mpViewShell(pViewShell),
+ maCellPos(rCell),
+ meSplitPos(eSplitPos)
+{
+}
+
+ScViewForwarder::~ScViewForwarder()
+{
+}
+
+BOOL ScViewForwarder::IsValid() const
+{
+ return mpViewShell != NULL;
+}
+
+Rectangle ScViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ {
+ aVisArea.SetSize(pWindow->GetSizePixel());
+
+ ScHSplitPos eWhichH = ((meSplitPos == SC_SPLIT_TOPLEFT) || (meSplitPos == SC_SPLIT_BOTTOMLEFT)) ?
+ SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
+ ScVSplitPos eWhichV = ((meSplitPos == SC_SPLIT_TOPLEFT) || (meSplitPos == SC_SPLIT_TOPRIGHT)) ?
+ SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
+
+ Point aBaseCellPos(mpViewShell->GetViewData()->GetScrPos(mpViewShell->GetViewData()->GetPosX(eWhichH),
+ mpViewShell->GetViewData()->GetPosY(eWhichV), meSplitPos, sal_True));
+ Point aCellPos(mpViewShell->GetViewData()->GetScrPos(maCellPos.Col(), maCellPos.Row(), meSplitPos, sal_True));
+ aVisArea.SetPos(aCellPos - aBaseCellPos);
+ }
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return aVisArea;
+}
+
+Point ScViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ return pWindow->LogicToPixel( rPoint, rMapMode );
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+Point ScViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
+ if (pWindow)
+ return pWindow->PixelToLogic( rPoint, rMapMode );
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+void ScViewForwarder::SetInvalid()
+{
+ mpViewShell = NULL;
+}
+
+// ============================================================================
+
+class ScEditObjectViewForwarder : public SvxViewForwarder
+{
+ Window* mpWindow;
+ // #i49561# EditView needed for access to its visible area.
+ const EditView* mpEditView;
+public:
+ ScEditObjectViewForwarder( Window* pWindow,
+ const EditView* _pEditView);
+ virtual ~ScEditObjectViewForwarder();
+
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
+
+ void SetInvalid();
+};
+
+ScEditObjectViewForwarder::ScEditObjectViewForwarder( Window* pWindow,
+ const EditView* _pEditView )
+ :
+ mpWindow(pWindow),
+ mpEditView( _pEditView )
+{
+}
+
+ScEditObjectViewForwarder::~ScEditObjectViewForwarder()
+{
+}
+
+BOOL ScEditObjectViewForwarder::IsValid() const
+{
+ return (mpWindow != NULL);
+}
+
+Rectangle ScEditObjectViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (mpWindow)
+ {
+ Rectangle aVisRect(mpWindow->GetWindowExtentsRelative(mpWindow->GetAccessibleParentWindow()));
+
+ aVisRect.SetPos(Point(0, 0));
+
+ aVisArea = aVisRect;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return aVisArea;
+}
+
+Point ScEditObjectViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpWindow)
+ {
+ // #i49561# - consider offset of the visible area
+ // of the EditView before converting point to pixel.
+ Point aPoint( rPoint );
+ if ( mpEditView )
+ {
+ Rectangle aEditViewVisArea( mpEditView->GetVisArea() );
+ aPoint += aEditViewVisArea.TopLeft();
+ }
+ return mpWindow->LogicToPixel( aPoint, rMapMode );
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+Point ScEditObjectViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpWindow)
+ {
+ // #i49561# - consider offset of the visible area
+ // of the EditView after converting point to logic.
+ Point aPoint( mpWindow->PixelToLogic( rPoint, rMapMode ) );
+ if ( mpEditView )
+ {
+ Rectangle aEditViewVisArea( mpEditView->GetVisArea() );
+ aPoint -= aEditViewVisArea.TopLeft();
+ }
+ return aPoint;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+void ScEditObjectViewForwarder::SetInvalid()
+{
+ mpWindow = NULL;
+}
+
+class ScPreviewViewForwarder : public SvxViewForwarder
+{
+protected:
+ ScPreviewShell* mpViewShell;
+ mutable ScPreviewTableInfo* mpTableInfo;
+public:
+ ScPreviewViewForwarder(ScPreviewShell* pViewShell);
+ virtual ~ScPreviewViewForwarder();
+
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
+
+ void SetInvalid();
+
+ Rectangle GetVisRect() const;
+
+ // clips the VisArea and calculates with the negativ coordinates
+ Rectangle CorrectVisArea(const Rectangle& rVisArea) const;
+};
+
+ScPreviewViewForwarder::ScPreviewViewForwarder(ScPreviewShell* pViewShell)
+ :
+ mpViewShell(pViewShell),
+ mpTableInfo(NULL)
+{
+}
+
+ScPreviewViewForwarder::~ScPreviewViewForwarder()
+{
+ delete mpTableInfo;
+}
+
+BOOL ScPreviewViewForwarder::IsValid() const
+{
+ return mpViewShell != NULL;
+}
+
+Rectangle ScPreviewViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ DBG_ERROR("should be implemented in an abrevated class");
+ return aVisArea;
+}
+
+Point ScPreviewViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ {
+ MapMode aMapMode(pWindow->GetMapMode().GetMapUnit());
+ Point aPoint2( OutputDevice::LogicToLogic( rPoint, rMapMode, aMapMode) );
+ return pWindow->LogicToPixel(aPoint2);
+ }
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+Point ScPreviewViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpViewShell)
+ {
+ Window* pWindow = mpViewShell->GetWindow();
+ if (pWindow)
+ {
+ MapMode aMapMode(pWindow->GetMapMode());
+ aMapMode.SetOrigin(Point());
+ Point aPoint1( pWindow->PixelToLogic( rPoint ) );
+ Point aPoint2( OutputDevice::LogicToLogic( aPoint1,
+ aMapMode.GetMapUnit(),
+ rMapMode ) );
+ return aPoint2;
+ }
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+void ScPreviewViewForwarder::SetInvalid()
+{
+ mpViewShell = NULL;
+}
+
+Rectangle ScPreviewViewForwarder::GetVisRect() const
+{
+ if ( mpViewShell )
+ {
+ Size aOutputSize;
+ Window* pWindow = mpViewShell->GetWindow();
+ if ( pWindow )
+ aOutputSize = pWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+ return aVisRect;
+ }
+ return Rectangle();
+}
+
+Rectangle ScPreviewViewForwarder::CorrectVisArea(const Rectangle& rVisArea) const
+{
+ Rectangle aVisArea(rVisArea);
+ Point aPos = aVisArea.TopLeft(); // get first the position to remember negative positions after clipping
+
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ aVisArea = pWin->GetWindowExtentsRelative(pWin).GetIntersection(aVisArea);
+
+ sal_Int32 nX(aPos.getX());
+ sal_Int32 nY(aPos.getY());
+
+ if (nX > 0)
+ nX = 0;
+ else if (nX < 0)
+ nX = -nX;
+ if (nY > 0)
+ nY = 0;
+ else if (nY < 0)
+ nY = -nY;
+ aVisArea.SetPos(Point(nX, nY));
+
+ return aVisArea;
+}
+
+class ScPreviewHeaderFooterViewForwarder : public ScPreviewViewForwarder
+{
+ sal_Bool mbHeader;
+public:
+ ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, sal_Bool bHeader);
+ virtual ~ScPreviewHeaderFooterViewForwarder();
+
+ virtual Rectangle GetVisArea() const;
+};
+
+ScPreviewHeaderFooterViewForwarder::ScPreviewHeaderFooterViewForwarder(ScPreviewShell* pViewShell, sal_Bool bHeader)
+ :
+ ScPreviewViewForwarder(pViewShell),
+ mbHeader(bHeader)
+{
+}
+
+ScPreviewHeaderFooterViewForwarder::~ScPreviewHeaderFooterViewForwarder()
+{
+}
+
+Rectangle ScPreviewHeaderFooterViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (mpViewShell)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ if ( mbHeader )
+ rData.GetHeaderPosition( aVisArea );
+ else
+ rData.GetFooterPosition( aVisArea );
+
+ aVisArea = CorrectVisArea(aVisArea);
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return aVisArea;
+}
+
+class ScPreviewCellViewForwarder : public ScPreviewViewForwarder
+{
+ ScAddress maCellPos;
+public:
+ ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
+ ScAddress aCellPos);
+ virtual ~ScPreviewCellViewForwarder();
+
+ virtual Rectangle GetVisArea() const;
+};
+
+ScPreviewCellViewForwarder::ScPreviewCellViewForwarder(ScPreviewShell* pViewShell,
+ ScAddress aCellPos)
+ :
+ ScPreviewViewForwarder(pViewShell),
+ maCellPos(aCellPos)
+{
+}
+
+ScPreviewCellViewForwarder::~ScPreviewCellViewForwarder()
+{
+}
+
+Rectangle ScPreviewCellViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (mpViewShell)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ aVisArea = rData.GetCellOutputRect(maCellPos);
+
+ aVisArea = CorrectVisArea(aVisArea);
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return aVisArea;
+}
+
+class ScPreviewHeaderCellViewForwarder : public ScPreviewViewForwarder
+{
+ ScAddress maCellPos;
+ sal_Bool mbColHeader;
+ sal_Bool mbRowHeader;
+public:
+ ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
+ ScAddress aCellPos,
+ sal_Bool bColHeader, sal_Bool bRowHeader);
+ virtual ~ScPreviewHeaderCellViewForwarder();
+
+ virtual Rectangle GetVisArea() const;
+};
+
+ScPreviewHeaderCellViewForwarder::ScPreviewHeaderCellViewForwarder(ScPreviewShell* pViewShell,
+ ScAddress aCellPos,
+ sal_Bool bColHeader, sal_Bool bRowHeader)
+ :
+ ScPreviewViewForwarder(pViewShell),
+ maCellPos(aCellPos),
+ mbColHeader(bColHeader),
+ mbRowHeader(bRowHeader)
+{
+}
+
+ScPreviewHeaderCellViewForwarder::~ScPreviewHeaderCellViewForwarder()
+{
+}
+
+Rectangle ScPreviewHeaderCellViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (mpViewShell)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ aVisArea = rData.GetHeaderCellOutputRect(GetVisRect(), maCellPos, mbColHeader);
+
+ aVisArea = CorrectVisArea(aVisArea);
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return aVisArea;
+}
+
+class ScPreviewNoteViewForwarder : public ScPreviewViewForwarder
+{
+ ScAddress maCellPos;
+ sal_Bool mbNoteMark;
+public:
+ ScPreviewNoteViewForwarder(ScPreviewShell* pViewShell,
+ ScAddress aCellPos,
+ sal_Bool bNoteMark);
+ virtual ~ScPreviewNoteViewForwarder();
+
+ virtual Rectangle GetVisArea() const;
+};
+
+ScPreviewNoteViewForwarder::ScPreviewNoteViewForwarder(ScPreviewShell* pViewShell,
+ ScAddress aCellPos,
+ sal_Bool bNoteMark)
+ :
+ ScPreviewViewForwarder(pViewShell),
+ maCellPos(aCellPos),
+ mbNoteMark(bNoteMark)
+{
+}
+
+ScPreviewNoteViewForwarder::~ScPreviewNoteViewForwarder()
+{
+}
+
+Rectangle ScPreviewNoteViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (mpViewShell)
+ {
+ const ScPreviewLocationData& rData = mpViewShell->GetLocationData();
+ aVisArea = rData.GetNoteInRangeOutputRect(GetVisRect(), mbNoteMark, maCellPos);
+
+ aVisArea = CorrectVisArea(aVisArea);
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return aVisArea;
+}
+
+class ScEditViewForwarder : public SvxEditViewForwarder
+{
+ EditView* mpEditView;
+ Window* mpWindow;
+public:
+ ScEditViewForwarder(EditView* pEditView, Window* pWin);
+ virtual ~ScEditViewForwarder();
+
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual sal_Bool GetSelection( ESelection& rSelection ) const;
+ virtual sal_Bool SetSelection( const ESelection& rSelection );
+ virtual sal_Bool Copy();
+ virtual sal_Bool Cut();
+ virtual sal_Bool Paste();
+
+ void GrabFocus();
+
+ void SetInvalid();
+};
+
+ScEditViewForwarder::ScEditViewForwarder(EditView* pEditView, Window* pWin)
+ : mpEditView(pEditView),
+ mpWindow(pWin)
+{
+ GrabFocus();
+}
+
+ScEditViewForwarder::~ScEditViewForwarder()
+{
+}
+
+BOOL ScEditViewForwarder::IsValid() const
+{
+ sal_Bool bResult(sal_False);
+ if (mpWindow && mpEditView)
+ {
+ bResult = sal_True;
+ }
+ return bResult;
+}
+
+Rectangle ScEditViewForwarder::GetVisArea() const
+{
+ Rectangle aVisArea;
+ if (IsValid() && mpEditView->GetEditEngine())
+ {
+ MapMode aMapMode(mpEditView->GetEditEngine()->GetRefMapMode());
+
+ aVisArea = mpWindow->LogicToPixel( mpEditView->GetVisArea(), aMapMode );
+ }
+ else
+ {
+ DBG_ERROR("this EditViewForwarder is no longer valid");
+ }
+ return aVisArea;
+}
+
+Point ScEditViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpWindow)
+ return mpWindow->LogicToPixel( rPoint, rMapMode );
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+Point ScEditViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if (mpWindow)
+ return mpWindow->PixelToLogic( rPoint, rMapMode );
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return Point();
+}
+
+sal_Bool ScEditViewForwarder::GetSelection( ESelection& rSelection ) const
+{
+ sal_Bool bResult(sal_False);
+ if (IsValid())
+ {
+ rSelection = mpEditView->GetSelection();
+ bResult = sal_True;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return bResult;
+}
+
+sal_Bool ScEditViewForwarder::SetSelection( const ESelection& rSelection )
+{
+ sal_Bool bResult(sal_False);
+ if (IsValid())
+ {
+ mpEditView->SetSelection(rSelection);
+ bResult = sal_True;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return bResult;
+}
+
+sal_Bool ScEditViewForwarder::Copy()
+{
+ sal_Bool bResult(sal_False);
+ if (IsValid())
+ {
+ mpEditView->Copy();
+ bResult = sal_True;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return bResult;
+}
+
+sal_Bool ScEditViewForwarder::Cut()
+{
+ sal_Bool bResult(sal_False);
+ if (IsValid())
+ {
+ mpEditView->Cut();
+ bResult = sal_True;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return bResult;
+}
+
+sal_Bool ScEditViewForwarder::Paste()
+{
+ sal_Bool bResult(sal_False);
+ if (IsValid())
+ {
+ mpEditView->Paste();
+ bResult = sal_True;
+ }
+ else
+ {
+ DBG_ERROR("this ViewForwarder is not valid");
+ }
+ return bResult;
+}
+
+void ScEditViewForwarder::GrabFocus()
+{
+}
+
+void ScEditViewForwarder::SetInvalid()
+{
+ mpWindow = NULL;
+ mpEditView = NULL;
+}
+
+// ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
+
+ScAccessibleCellTextData::ScAccessibleCellTextData(ScTabViewShell* pViewShell,
+ const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell)
+ : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
+ mpViewForwarder(NULL),
+ mpEditViewForwarder(NULL),
+ mpViewShell(pViewShell),
+ meSplitPos(eSplitPos),
+ mbViewEditEngine(sal_False),
+ mpAccessibleCell( pAccCell )
+{
+}
+
+ScAccessibleCellTextData::~ScAccessibleCellTextData()
+{
+ if (pEditEngine)
+ pEditEngine->SetNotifyHdl(Link());
+ if (mpViewForwarder)
+ delete mpViewForwarder;
+ if (mpEditViewForwarder)
+ delete mpEditViewForwarder;
+}
+
+void ScAccessibleCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ mpViewShell = NULL; // invalid now
+ if (mpViewForwarder)
+ mpViewForwarder->SetInvalid();
+ if (mpEditViewForwarder)
+ mpEditViewForwarder->SetInvalid();
+ }
+ }
+ ScAccessibleCellBaseTextData::Notify(rBC, rHint);
+}
+
+ScAccessibleTextData* ScAccessibleCellTextData::Clone() const
+{
+ return new ScAccessibleCellTextData( mpViewShell, aCellPos, meSplitPos, mpAccessibleCell );
+}
+
+void ScAccessibleCellTextData::GetCellText(const ScAddress& rCellPos, String& rText)
+{
+// #104893#; don't use the input string
+// ScCellTextData::GetCellText(rCellPos, rText);
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ // #104893#; use the displayed string
+ pDoc->GetString(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText);
+ if (mpViewShell)
+ {
+ const ScViewOptions& aOptions = mpViewShell->GetViewData()->GetOptions();
+ CellType aCellType;
+ pDoc->GetCellType(rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), aCellType);
+ if (aCellType == CELLTYPE_FORMULA && aOptions.GetOption( VOPT_FORMULAS ))
+ {
+ pDoc->GetFormula( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText);
+ }
+ else if (!aOptions.GetOption( VOPT_NULLVALS ))
+ {
+ if ((aCellType == CELLTYPE_VALUE || aCellType == CELLTYPE_FORMULA) && pDoc->GetValue(rCellPos) == 0.0)
+ rText.Erase();
+ }
+ }
+ }
+}
+
+SvxTextForwarder* ScAccessibleCellTextData::GetTextForwarder()
+{
+/* sal_Bool bHasForwarder(sal_False);
+ if (mpViewShell && mpViewShell->GetViewData() &&
+ (mpViewShell->GetViewData()->GetCurPos() == aCellPos) &&
+ (mpViewShell->GetViewData()->HasEditView(meSplitPos)) &&
+ (mpViewShell->GetViewData()->GetEditViewCol() == aCellPos.Col()) &&
+ (mpViewShell->GetViewData()->GetEditViewRow() == aCellPos.Row()))
+ {
+ if (!mbViewEditEngine)
+ {
+ if (pForwarder)
+ DELETEZ( pForwarder );
+ if (pEditEngine)
+ DELETEZ( pEditEngine );
+
+ SCCOL nCol;
+ SCROW nRow;
+ EditView* pEditView;
+ mpViewShell->GetViewData()->GetEditView( meSplitPos, pEditView, nCol, nRow );
+ if (pEditView)
+ {
+ pEditEngine = (ScFieldEditEngine*)pEditView->GetEditEngine();
+ pForwarder = new SvxEditEngineForwarder(*pEditEngine);
+ bHasForwarder = sal_True;
+ }
+ }
+ else
+ bHasForwarder = sal_True;
+ }
+ else if (mbViewEditEngine)
+ {
+ // remove Forwarder created with EditEngine from EditView
+ if (pForwarder)
+ DELETEZ( pForwarder );
+ pEditEngine->SetNotifyHdl(Link());
+ // don't delete, because it is the EditEngine of the EditView
+ pEditEngine = NULL;
+ mbViewEditEngine = sal_False;
+ }
+
+ if (!bHasForwarder)*/
+ ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
+
+ ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL );
+ if ( pDoc && pEditEngine && mpViewShell )
+ {
+ long nSizeX, nSizeY;
+ mpViewShell->GetViewData()->GetMergeSizePixel(
+ aCellPos.Col(), aCellPos.Row(), nSizeX, nSizeY);
+
+ Size aSize(nSizeX, nSizeY);
+
+ // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
+ long nIndent = 0;
+ const SvxHorJustifyItem* pHorJustifyItem = static_cast< const SvxHorJustifyItem* >(
+ pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_HOR_JUSTIFY ) );
+ SvxCellHorJustify eHorJust = ( pHorJustifyItem ? static_cast< SvxCellHorJustify >( pHorJustifyItem->GetValue() ) : SVX_HOR_JUSTIFY_STANDARD );
+ if ( eHorJust == SVX_HOR_JUSTIFY_LEFT )
+ {
+ const SfxUInt16Item* pIndentItem = static_cast< const SfxUInt16Item* >(
+ pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_INDENT ) );
+ if ( pIndentItem )
+ {
+ nIndent = static_cast< long >( pIndentItem->GetValue() );
+ }
+ }
+
+ const SvxMarginItem* pMarginItem = static_cast< const SvxMarginItem* >(
+ pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_MARGIN ) );
+ ScViewData* pViewData = mpViewShell->GetViewData();
+ double nPPTX = ( pViewData ? pViewData->GetPPTX() : 0 );
+ double nPPTY = ( pViewData ? pViewData->GetPPTY() : 0 );
+ long nLeftM = ( pMarginItem ? static_cast< long >( ( pMarginItem->GetLeftMargin() + nIndent ) * nPPTX ) : 0 );
+ long nTopM = ( pMarginItem ? static_cast< long >( pMarginItem->GetTopMargin() * nPPTY ) : 0 );
+ long nRightM = ( pMarginItem ? static_cast< long >( pMarginItem->GetRightMargin() * nPPTX ) : 0 );
+ long nBottomM = ( pMarginItem ? static_cast< long >( pMarginItem->GetBottomMargin() * nPPTY ) : 0 );
+ long nWidth = aSize.getWidth() - nLeftM - nRightM;
+ aSize.setWidth( nWidth );
+ aSize.setHeight( aSize.getHeight() - nTopM - nBottomM );
+
+ Window* pWin = mpViewShell->GetWindowByPos( meSplitPos );
+ if ( pWin )
+ {
+ aSize = pWin->PixelToLogic( aSize, pEditEngine->GetRefMapMode() );
+ }
+
+ /* #i19430# Gnopernicus reads text partly if it sticks out of the cell
+ boundaries. This leads to wrong results in cases where the cell text
+ is rotated, because rotation is not taken into account when calcu-
+ lating the visible part of the text. In these cases we will expand
+ the cell size passed as paper size to the edit engine. The function
+ accessibility::AccessibleStaticTextBase::GetParagraphBoundingBox()
+ (see svx/source/accessibility/AccessibleStaticTextBase.cxx) will
+ return the size of the complete text then, which is used to expand
+ the cell bounding box in ScAccessibleCell::GetBoundingBox()
+ (see sc/source/ui/Accessibility/AccessibleCell.cxx). */
+ const SfxInt32Item* pItem = static_cast< const SfxInt32Item* >(
+ pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_ROTATE_VALUE ) );
+ if( pItem && (pItem->GetValue() != 0) )
+ {
+ pEditEngine->SetPaperSize( Size( LONG_MAX, aSize.getHeight() ) );
+ long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
+ aSize.setWidth( std::max( aSize.getWidth(), nTxtWidth + 2 ) );
+ }
+ else
+ {
+ // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
+ const SfxBoolItem* pLineBreakItem = static_cast< const SfxBoolItem* >(
+ pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_LINEBREAK ) );
+ bool bLineBreak = ( pLineBreakItem && pLineBreakItem->GetValue() );
+ if ( !bLineBreak )
+ {
+ long nTxtWidth = static_cast< long >( pEditEngine->CalcTextWidth() );
+ aSize.setWidth( ::std::max( aSize.getWidth(), nTxtWidth ) );
+ }
+ }
+
+ pEditEngine->SetPaperSize( aSize );
+
+ // #i92143# text getRangeExtents reports incorrect 'x' values for spreadsheet cells
+ if ( eHorJust == SVX_HOR_JUSTIFY_STANDARD && pDoc->HasValueData( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab() ) )
+ {
+ pEditEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ }
+
+ Size aTextSize;
+ if ( pWin )
+ {
+ aTextSize = pWin->LogicToPixel( Size( pEditEngine->CalcTextWidth(), pEditEngine->GetTextHeight() ), pEditEngine->GetRefMapMode() );
+ }
+ long nTextWidth = aTextSize.Width();
+ long nTextHeight = aTextSize.Height();
+
+ long nOffsetX = nLeftM;
+ long nDiffX = nTextWidth - nWidth;
+ if ( nDiffX > 0 )
+ {
+ switch ( eHorJust )
+ {
+ case SVX_HOR_JUSTIFY_RIGHT:
+ {
+ nOffsetX -= nDiffX;
+ }
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ {
+ nOffsetX -= nDiffX / 2;
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+ }
+
+ long nOffsetY = 0;
+ const SvxVerJustifyItem* pVerJustifyItem = static_cast< const SvxVerJustifyItem* >(
+ pDoc->GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_VER_JUSTIFY ) );
+ SvxCellVerJustify eVerJust = ( pVerJustifyItem ? static_cast< SvxCellVerJustify >( pVerJustifyItem->GetValue() ) : SVX_VER_JUSTIFY_STANDARD );
+ switch ( eVerJust )
+ {
+ case SVX_VER_JUSTIFY_STANDARD:
+ case SVX_VER_JUSTIFY_BOTTOM:
+ {
+ nOffsetY = nSizeY - nBottomM - nTextHeight;
+ }
+ break;
+ case SVX_VER_JUSTIFY_CENTER:
+ {
+ nOffsetY = ( nSizeY - nTopM - nBottomM - nTextHeight ) / 2 + nTopM;
+ }
+ break;
+ default:
+ {
+ nOffsetY = nTopM;
+ }
+ break;
+ }
+
+ if ( mpAccessibleCell )
+ {
+ mpAccessibleCell->SetOffset( Point( nOffsetX, nOffsetY ) );
+ }
+
+ pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
+ }
+
+ return pForwarder;
+}
+
+SvxViewForwarder* ScAccessibleCellTextData::GetViewForwarder()
+{
+ if (!mpViewForwarder)
+ mpViewForwarder = new ScViewForwarder(mpViewShell, meSplitPos, aCellPos);
+ return mpViewForwarder;
+}
+
+SvxEditViewForwarder* ScAccessibleCellTextData::GetEditViewForwarder( sal_Bool /* bCreate */ )
+{
+ //#102219#; there should no EditViewForwarder be, because the cell is now readonly in this interface
+/* if (!mpEditViewForwarder)
+ {
+ SCCOL nCol;
+ SCROW nRow;
+ EditView* pEditView;
+ mpViewShell->GetViewData()->GetEditView( meSplitPos, pEditView, nCol, nRow );
+
+ mpEditViewForwarder = new ScEditViewForwarder(pEditView, mpViewShell->GetWindowByPos(meSplitPos));
+ }
+ else if (bCreate)
+ mpEditViewForwarder->GrabFocus();
+ return mpEditViewForwarder;*/
+ return NULL;
+}
+
+IMPL_LINK(ScAccessibleCellTextData, NotifyHdl, EENotify*, aNotify)
+{
+ if( aNotify )
+ {
+ ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
+
+ if( aHint.get() )
+ GetBroadcaster().Broadcast( *aHint.get() );
+ }
+
+ return 0;
+}
+
+ScDocShell* ScAccessibleCellTextData::GetDocShell(ScTabViewShell* pViewShell)
+{
+ ScDocShell* pDocSh = NULL;
+ if (pViewShell)
+ pDocSh = pViewShell->GetViewData()->GetDocShell();
+ return pDocSh;
+}
+
+
+ScAccessibleEditObjectTextData::ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin)
+ :
+ mpViewForwarder(NULL),
+ mpEditViewForwarder(NULL),
+ mpEditView(pEditView),
+ mpEditEngine(pEditView ? pEditView->GetEditEngine() : 0),
+ mpForwarder(NULL),
+ mpWindow(pWin)
+{
+ if (mpEditEngine)
+ mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
+}
+
+ScAccessibleEditObjectTextData::~ScAccessibleEditObjectTextData()
+{
+ if (mpEditEngine)
+ mpEditEngine->SetNotifyHdl(Link());
+ if (mpViewForwarder)
+ delete mpViewForwarder;
+ if (mpEditViewForwarder)
+ delete mpEditViewForwarder;
+ if (mpForwarder)
+ delete mpForwarder;
+}
+
+void ScAccessibleEditObjectTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ mpWindow = NULL;
+ mpEditView = NULL;
+ mpEditEngine = NULL;
+ DELETEZ(mpForwarder);
+ if (mpViewForwarder)
+ mpViewForwarder->SetInvalid();
+ if (mpEditViewForwarder)
+ mpEditViewForwarder->SetInvalid();
+ }
+ }
+ ScAccessibleTextData::Notify(rBC, rHint);
+}
+
+ScAccessibleTextData* ScAccessibleEditObjectTextData::Clone() const
+{
+ return new ScAccessibleEditObjectTextData(mpEditView, mpWindow);
+}
+
+SvxTextForwarder* ScAccessibleEditObjectTextData::GetTextForwarder()
+{
+ if ((!mpForwarder && mpEditView) || (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet()))
+ {
+ if (!mpEditEngine)
+ mpEditEngine = mpEditView->GetEditEngine();
+ if (mpEditEngine && !mpEditEngine->GetNotifyHdl().IsSet())
+ mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
+ if(!mpForwarder)
+ mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
+ }
+ return mpForwarder;
+}
+
+SvxViewForwarder* ScAccessibleEditObjectTextData::GetViewForwarder()
+{
+ if (!mpViewForwarder)
+ {
+ // --> OD 2005-12-21 #i49561#
+ mpViewForwarder = new ScEditObjectViewForwarder( mpWindow, mpEditView );
+ // <--
+ }
+ return mpViewForwarder;
+}
+
+SvxEditViewForwarder* ScAccessibleEditObjectTextData::GetEditViewForwarder( sal_Bool bCreate )
+{
+ if (!mpEditViewForwarder && mpEditView)
+ mpEditViewForwarder = new ScEditViewForwarder(mpEditView, mpWindow);
+ if (bCreate)
+ {
+ if (!mpEditView && mpEditViewForwarder)
+ {
+ DELETEZ(mpEditViewForwarder);
+ }
+ else if (mpEditViewForwarder)
+ mpEditViewForwarder->GrabFocus();
+ }
+ return mpEditViewForwarder;
+}
+
+IMPL_LINK(ScAccessibleEditObjectTextData, NotifyHdl, EENotify*, aNotify)
+{
+ if( aNotify )
+ {
+ ::std::auto_ptr< SfxHint > aHint = SvxEditSourceHelper::EENotification2Hint( aNotify );
+
+ if( aHint.get() )
+ GetBroadcaster().Broadcast( *aHint.get() );
+ }
+
+ return 0;
+}
+
+ScAccessibleEditLineTextData::ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin)
+ :
+ ScAccessibleEditObjectTextData(pEditView, pWin),
+ mbEditEngineCreated(sal_False)
+{
+ ScTextWnd* pTxtWnd = (ScTextWnd*)pWin;
+
+ if (pTxtWnd)
+ pTxtWnd->InsertAccessibleTextData( *this );
+}
+
+ScAccessibleEditLineTextData::~ScAccessibleEditLineTextData()
+{
+ ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+
+ if (pTxtWnd)
+ pTxtWnd->RemoveAccessibleTextData( *this );
+
+ if (mbEditEngineCreated && mpEditEngine)
+ {
+ delete mpEditEngine;
+ mpEditEngine = NULL; // #103346# don't access in ScAccessibleEditObjectTextData dtor!
+ }
+ else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
+ {
+ // #103346# the NotifyHdl also has to be removed from the ScTextWnd's EditEngine
+ // (it's set in ScAccessibleEditLineTextData::GetTextForwarder, and mpEditEngine
+ // is reset there)
+ pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
+ }
+}
+
+void ScAccessibleEditLineTextData::Dispose()
+{
+ ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+
+ if (pTxtWnd)
+ pTxtWnd->RemoveAccessibleTextData( *this );
+
+ ResetEditMode();
+ mpWindow = NULL;
+}
+
+ScAccessibleTextData* ScAccessibleEditLineTextData::Clone() const
+{
+ return new ScAccessibleEditLineTextData(mpEditView, mpWindow);
+}
+
+SvxTextForwarder* ScAccessibleEditLineTextData::GetTextForwarder()
+{
+ ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+
+ if (pTxtWnd)
+ {
+ mpEditView = pTxtWnd->GetEditView();
+ if (mpEditView)
+ {
+ if (mbEditEngineCreated && mpEditEngine)
+ ResetEditMode();
+ mbEditEngineCreated = sal_False;
+
+ mpEditView = pTxtWnd->GetEditView();
+ ScAccessibleEditObjectTextData::GetTextForwarder(); // fill the mpForwarder
+ mpEditEngine = NULL;
+ }
+ else
+ {
+ if (mpEditEngine && !mbEditEngineCreated)
+ ResetEditMode();
+ if (!mpEditEngine)
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, TRUE );
+ mbEditEngineCreated = sal_True;
+ // currently, GetPortions doesn't work if UpdateMode is FALSE,
+ // this will be fixed (in EditEngine) by src600
+ // pEditEngine->SetUpdateMode( FALSE );
+ mpEditEngine->EnableUndo( FALSE );
+ mpEditEngine->SetRefMapMode( MAP_100TH_MM );
+ mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
+
+ mpEditEngine->SetText(pTxtWnd->GetTextString());
+
+ Size aSize(pTxtWnd->GetSizePixel());
+
+ aSize = pTxtWnd->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
+
+ mpEditEngine->SetPaperSize(aSize);
+
+ mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleEditObjectTextData, NotifyHdl) );
+ }
+ }
+ }
+ return mpForwarder;
+}
+
+SvxEditViewForwarder* ScAccessibleEditLineTextData::GetEditViewForwarder( sal_Bool bCreate )
+{
+ ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+
+ if (pTxtWnd)
+ {
+ mpEditView = pTxtWnd->GetEditView();
+ if (!mpEditView && bCreate)
+ {
+ if ( !pTxtWnd->IsInputActive() )
+ {
+ pTxtWnd->StartEditEngine();
+ pTxtWnd->GrabFocus();
+// pTxtWnd->SetTextString( rText );
+// pTxtWnd->GetEditView()->SetSelection( rSel );
+
+ mpEditView = pTxtWnd->GetEditView();
+ }
+ }
+ }
+
+ return ScAccessibleEditObjectTextData::GetEditViewForwarder(bCreate);
+}
+
+void ScAccessibleEditLineTextData::ResetEditMode()
+{
+ ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+
+ if (mbEditEngineCreated && mpEditEngine)
+ delete mpEditEngine;
+ else if (pTxtWnd && pTxtWnd->GetEditView() && pTxtWnd->GetEditView()->GetEditEngine())
+ pTxtWnd->GetEditView()->GetEditEngine()->SetNotifyHdl(Link());
+ mpEditEngine = NULL;
+
+ DELETEZ(mpForwarder);
+ DELETEZ(mpEditViewForwarder);
+ DELETEZ(mpViewForwarder);
+ mbEditEngineCreated = sal_False;
+}
+
+void ScAccessibleEditLineTextData::TextChanged()
+{
+ if (mbEditEngineCreated && mpEditEngine)
+ {
+ ScTextWnd* pTxtWnd = (ScTextWnd*)mpWindow;
+
+ if (pTxtWnd)
+ mpEditEngine->SetText(pTxtWnd->GetTextString());
+ }
+}
+
+void ScAccessibleEditLineTextData::StartEdit()
+{
+ ResetEditMode();
+ mpEditView = NULL;
+
+ // send HINT_BEGEDIT
+ SdrHint aHint(HINT_BEGEDIT);
+ GetBroadcaster().Broadcast( aHint );
+}
+
+void ScAccessibleEditLineTextData::EndEdit()
+{
+ // send HINT_ENDEDIT
+ SdrHint aHint(HINT_ENDEDIT);
+ GetBroadcaster().Broadcast( aHint );
+
+ ResetEditMode();
+ mpEditView = NULL;
+}
+
+
+// ScAccessiblePreviewCellTextData: shared data between sub objects of a accessible cell text object
+
+ScAccessiblePreviewCellTextData::ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
+ const ScAddress& rP)
+ : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
+ mpViewForwarder(NULL),
+ mpViewShell(pViewShell)
+{
+}
+
+ScAccessiblePreviewCellTextData::~ScAccessiblePreviewCellTextData()
+{
+ if (pEditEngine)
+ pEditEngine->SetNotifyHdl(Link());
+ if (mpViewForwarder)
+ delete mpViewForwarder;
+}
+
+void ScAccessiblePreviewCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ mpViewShell = NULL; // invalid now
+ if (mpViewForwarder)
+ mpViewForwarder->SetInvalid();
+ }
+ }
+ ScAccessibleCellBaseTextData::Notify(rBC, rHint);
+}
+
+ScAccessibleTextData* ScAccessiblePreviewCellTextData::Clone() const
+{
+ return new ScAccessiblePreviewCellTextData(mpViewShell, aCellPos);
+}
+
+SvxTextForwarder* ScAccessiblePreviewCellTextData::GetTextForwarder()
+{
+ sal_Bool bEditEngineBefore(pEditEngine != NULL);
+
+ ScCellTextData::GetTextForwarder(); // creates Forwarder and EditEngine
+
+ if (!bEditEngineBefore && pEditEngine)
+ {
+ Size aSize(mpViewShell->GetLocationData().GetCellOutputRect(aCellPos).GetSize());
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ aSize = pWin->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
+ pEditEngine->SetPaperSize(aSize);
+ }
+
+ if (pEditEngine)
+ pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
+
+ return pForwarder;
+}
+
+SvxViewForwarder* ScAccessiblePreviewCellTextData::GetViewForwarder()
+{
+ if (!mpViewForwarder)
+ mpViewForwarder = new ScPreviewCellViewForwarder(mpViewShell, aCellPos);
+ return mpViewForwarder;
+}
+
+ScDocShell* ScAccessiblePreviewCellTextData::GetDocShell(ScPreviewShell* pViewShell)
+{
+ ScDocShell* pDocSh = NULL;
+ if (pViewShell && pViewShell->GetDocument())
+ pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
+ return pDocSh;
+}
+
+
+// ScAccessiblePreviewHeaderCellTextData: shared data between sub objects of a accessible cell text object
+
+ScAccessiblePreviewHeaderCellTextData::ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
+ const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader)
+ : ScAccessibleCellBaseTextData(GetDocShell(pViewShell), rP),
+ mpViewForwarder(NULL),
+ mpViewShell(pViewShell),
+ maText(rText),
+ mbColHeader(bColHeader),
+ mbRowHeader(bRowHeader)
+{
+}
+
+ScAccessiblePreviewHeaderCellTextData::~ScAccessiblePreviewHeaderCellTextData()
+{
+ if (pEditEngine)
+ pEditEngine->SetNotifyHdl(Link());
+ if (mpViewForwarder)
+ delete mpViewForwarder;
+}
+
+void ScAccessiblePreviewHeaderCellTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ mpViewShell = NULL; // invalid now
+ if (mpViewForwarder)
+ mpViewForwarder->SetInvalid();
+ }
+ }
+ ScAccessibleCellBaseTextData::Notify(rBC, rHint);
+}
+
+ScAccessibleTextData* ScAccessiblePreviewHeaderCellTextData::Clone() const
+{
+ return new ScAccessiblePreviewHeaderCellTextData(mpViewShell, maText, aCellPos, mbColHeader, mbRowHeader);
+}
+
+SvxTextForwarder* ScAccessiblePreviewHeaderCellTextData::GetTextForwarder()
+{
+ if (!pEditEngine)
+ {
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pEditEngine = pDoc->CreateFieldEditEngine();
+ }
+ else
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, TRUE );
+ }
+ // currently, GetPortions doesn't work if UpdateMode is FALSE,
+ // this will be fixed (in EditEngine) by src600
+// pEditEngine->SetUpdateMode( FALSE );
+ pEditEngine->EnableUndo( FALSE );
+ if (pDocShell)
+ pEditEngine->SetRefDevice(pDocShell->GetRefDevice());
+ else
+ pEditEngine->SetRefMapMode( MAP_100TH_MM );
+ pForwarder = new SvxEditEngineForwarder(*pEditEngine);
+ }
+
+ if (bDataValid)
+ return pForwarder;
+
+ if (maText.Len() && pEditEngine)
+ {
+
+ if ( mpViewShell )
+ {
+ Size aOutputSize;
+ Window* pWindow = mpViewShell->GetWindow();
+ if ( pWindow )
+ aOutputSize = pWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+ Size aSize(mpViewShell->GetLocationData().GetHeaderCellOutputRect(aVisRect, aCellPos, mbColHeader).GetSize());
+ if (pWindow)
+ aSize = pWindow->PixelToLogic(aSize, pEditEngine->GetRefMapMode());
+ pEditEngine->SetPaperSize(aSize);
+ }
+ pEditEngine->SetText( maText );
+ }
+
+ bDataValid = TRUE;
+
+ if (pEditEngine)
+ pEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
+
+ return pForwarder;
+}
+
+SvxViewForwarder* ScAccessiblePreviewHeaderCellTextData::GetViewForwarder()
+{
+ if (!mpViewForwarder)
+ mpViewForwarder = new ScPreviewHeaderCellViewForwarder(mpViewShell, aCellPos, mbColHeader, mbRowHeader);
+ return mpViewForwarder;
+}
+
+ScDocShell* ScAccessiblePreviewHeaderCellTextData::GetDocShell(ScPreviewShell* pViewShell)
+{
+ ScDocShell* pDocSh = NULL;
+ if (pViewShell && pViewShell->GetDocument())
+ pDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
+ return pDocSh;
+}
+
+ScAccessibleHeaderTextData::ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
+ const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust)
+ :
+ mpViewForwarder(NULL),
+ mpViewShell(pViewShell),
+ mpEditEngine(NULL),
+ mpForwarder(NULL),
+ mpDocSh(NULL),
+ mpEditObj(pEditObj),
+ mbHeader(bHeader),
+ mbDataValid(sal_False),
+ meAdjust(eAdjust)
+{
+ if (pViewShell && pViewShell->GetDocument())
+ mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
+ if (mpDocSh)
+ mpDocSh->GetDocument()->AddUnoObject(*this);
+}
+
+ScAccessibleHeaderTextData::~ScAccessibleHeaderTextData()
+{
+ SolarMutexGuard aGuard; // needed for EditEngine dtor
+
+ if (mpDocSh)
+ mpDocSh->GetDocument()->RemoveUnoObject(*this);
+ if (mpEditEngine)
+ mpEditEngine->SetNotifyHdl(Link());
+ delete mpEditEngine;
+ delete mpForwarder;
+}
+
+ScAccessibleTextData* ScAccessibleHeaderTextData::Clone() const
+{
+ return new ScAccessibleHeaderTextData(mpViewShell, mpEditObj, mbHeader, meAdjust);
+}
+
+void ScAccessibleHeaderTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ mpViewShell = NULL;// invalid now
+ mpDocSh = NULL;
+ if (mpViewForwarder)
+ mpViewForwarder->SetInvalid();
+ }
+ }
+}
+
+SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
+{
+ if (!mpEditEngine)
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, TRUE );
+
+ pHdrEngine->EnableUndo( FALSE );
+ pHdrEngine->SetRefMapMode( MAP_TWIP );
+
+ // default font must be set, independently of document
+ // -> use global pool from module
+
+ SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() );
+ const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN);
+ rPattern.FillEditItemSet( &aDefaults );
+ // FillEditItemSet adjusts font height to 1/100th mm,
+ // but for header/footer twips is needed, as in the PatternAttr:
+ aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
+ aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
+ aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+ aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
+ pHdrEngine->SetDefaults( aDefaults );
+
+ ScHeaderFieldData aData;
+ if (mpViewShell)
+ mpViewShell->FillFieldData(aData);
+ else
+ ScHeaderFooterTextObj::FillDummyFieldData( aData );
+ pHdrEngine->SetData( aData );
+
+ mpEditEngine = pHdrEngine;
+ mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
+ }
+
+ if (mbDataValid)
+ return mpForwarder;
+
+ if ( mpViewShell )
+ {
+ Rectangle aVisRect;
+ mpViewShell->GetLocationData().GetHeaderPosition(aVisRect);
+ Size aSize(aVisRect.GetSize());
+ Window* pWin = mpViewShell->GetWindow();
+ if (pWin)
+ aSize = pWin->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
+ mpEditEngine->SetPaperSize(aSize);
+ }
+ if (mpEditObj)
+ mpEditEngine->SetText(*mpEditObj);
+
+ mbDataValid = sal_True;
+ return mpForwarder;
+}
+
+SvxViewForwarder* ScAccessibleHeaderTextData::GetViewForwarder()
+{
+ if (!mpViewForwarder)
+ mpViewForwarder = new ScPreviewHeaderFooterViewForwarder(mpViewShell, mbHeader);
+ return mpViewForwarder;
+}
+
+ScAccessibleNoteTextData::ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
+ const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote)
+ :
+ mpViewForwarder(NULL),
+ mpViewShell(pViewShell),
+ mpEditEngine(NULL),
+ mpForwarder(NULL),
+ mpDocSh(NULL),
+ msText(sText),
+ maCellPos(aCellPos),
+ mbMarkNote(bMarkNote),
+ mbDataValid(sal_False)
+{
+ if (pViewShell && pViewShell->GetDocument())
+ mpDocSh = (ScDocShell*) pViewShell->GetDocument()->GetDocumentShell();
+ if (mpDocSh)
+ mpDocSh->GetDocument()->AddUnoObject(*this);
+}
+
+ScAccessibleNoteTextData::~ScAccessibleNoteTextData()
+{
+ SolarMutexGuard aGuard; // needed for EditEngine dtor
+
+ if (mpDocSh)
+ mpDocSh->GetDocument()->RemoveUnoObject(*this);
+ if (mpEditEngine)
+ mpEditEngine->SetNotifyHdl(Link());
+ delete mpEditEngine;
+ delete mpForwarder;
+}
+
+ScAccessibleTextData* ScAccessibleNoteTextData::Clone() const
+{
+ return new ScAccessibleNoteTextData(mpViewShell, msText, maCellPos, mbMarkNote);
+}
+
+void ScAccessibleNoteTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ mpViewShell = NULL;// invalid now
+ mpDocSh = NULL;
+ if (mpViewForwarder)
+ mpViewForwarder->SetInvalid();
+ }
+ }
+}
+
+SvxTextForwarder* ScAccessibleNoteTextData::GetTextForwarder()
+{
+ if (!mpEditEngine)
+ {
+ if ( mpDocSh )
+ {
+ ScDocument* pDoc = mpDocSh->GetDocument();
+ mpEditEngine = pDoc->CreateFieldEditEngine();
+ }
+ else
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ mpEditEngine = new ScFieldEditEngine( pEnginePool, NULL, TRUE );
+ }
+ // currently, GetPortions doesn't work if UpdateMode is FALSE,
+ // this will be fixed (in EditEngine) by src600
+// pEditEngine->SetUpdateMode( FALSE );
+ mpEditEngine->EnableUndo( FALSE );
+ if (mpDocSh)
+ mpEditEngine->SetRefDevice(mpDocSh->GetRefDevice());
+ else
+ mpEditEngine->SetRefMapMode( MAP_100TH_MM );
+ mpForwarder = new SvxEditEngineForwarder(*mpEditEngine);
+ }
+
+ if (mbDataValid)
+ return mpForwarder;
+
+ if (msText.Len() && mpEditEngine)
+ {
+
+ if ( mpViewShell )
+ {
+ Size aOutputSize;
+ Window* pWindow = mpViewShell->GetWindow();
+ if ( pWindow )
+ aOutputSize = pWindow->GetOutputSizePixel();
+ Point aPoint;
+ Rectangle aVisRect( aPoint, aOutputSize );
+ Size aSize(mpViewShell->GetLocationData().GetNoteInRangeOutputRect(aVisRect, mbMarkNote, maCellPos).GetSize());
+ if (pWindow)
+ aSize = pWindow->PixelToLogic(aSize, mpEditEngine->GetRefMapMode());
+ mpEditEngine->SetPaperSize(aSize);
+ }
+ mpEditEngine->SetText( msText );
+ }
+
+ mbDataValid = TRUE;
+
+ if (mpEditEngine)
+ mpEditEngine->SetNotifyHdl( LINK(this, ScAccessibleCellTextData, NotifyHdl) );
+
+ return mpForwarder;
+}
+
+SvxViewForwarder* ScAccessibleNoteTextData::GetViewForwarder()
+{
+ if (!mpViewForwarder)
+ mpViewForwarder = new ScPreviewNoteViewForwarder(mpViewShell, maCellPos, mbMarkNote);
+ return mpViewForwarder;
+}
+
+
+// CSV import =================================================================
+
+class ScCsvViewForwarder : public SvxViewForwarder
+{
+ Rectangle maBoundBox;
+ Window* mpWindow;
+
+public:
+ explicit ScCsvViewForwarder( Window* pWindow, const Rectangle& rBoundBox );
+
+ virtual BOOL IsValid() const;
+ virtual Rectangle GetVisArea() const;
+ virtual Point LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const;
+ virtual Point PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const;
+
+ void SetInvalid();
+};
+
+ScCsvViewForwarder::ScCsvViewForwarder( Window* pWindow, const Rectangle& rBoundBox ) :
+ maBoundBox( rBoundBox ),
+ mpWindow( pWindow )
+{
+}
+
+BOOL ScCsvViewForwarder::IsValid() const
+{
+ return mpWindow != NULL;
+}
+
+Rectangle ScCsvViewForwarder::GetVisArea() const
+{
+ return maBoundBox;
+}
+
+Point ScCsvViewForwarder::LogicToPixel( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if( !mpWindow ) return Point();
+ return mpWindow->LogicToPixel( rPoint, rMapMode );
+}
+
+Point ScCsvViewForwarder::PixelToLogic( const Point& rPoint, const MapMode& rMapMode ) const
+{
+ if( !mpWindow ) return Point();
+ return mpWindow->PixelToLogic( rPoint, rMapMode );
+}
+
+void ScCsvViewForwarder::SetInvalid()
+{
+ mpWindow = NULL;
+}
+
+ScAccessibleCsvTextData::ScAccessibleCsvTextData(
+ Window* pWindow, EditEngine* pEditEngine,
+ const String& rCellText, const Rectangle& rBoundBox, const Size& rCellSize ) :
+ mpWindow( pWindow ),
+ mpEditEngine( pEditEngine ),
+ maCellText( rCellText ),
+ maBoundBox( rBoundBox ),
+ maCellSize( rCellSize )
+{
+}
+
+ScAccessibleCsvTextData::~ScAccessibleCsvTextData()
+{
+}
+
+void ScAccessibleCsvTextData::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if( nId == SFX_HINT_DYING )
+ {
+ mpWindow = NULL;
+ mpEditEngine = NULL;
+ if (mpViewForwarder.get())
+ mpViewForwarder->SetInvalid();
+ }
+ }
+ ScAccessibleTextData::Notify( rBC, rHint );
+}
+
+ScAccessibleTextData* ScAccessibleCsvTextData::Clone() const
+{
+ return new ScAccessibleCsvTextData( mpWindow, mpEditEngine, maCellText, maBoundBox, maCellSize );
+}
+
+SvxTextForwarder* ScAccessibleCsvTextData::GetTextForwarder()
+{
+ if( mpEditEngine )
+ {
+ mpEditEngine->SetPaperSize( maCellSize );
+ mpEditEngine->SetText( maCellText );
+ if( !mpTextForwarder.get() )
+ mpTextForwarder.reset( new SvxEditEngineForwarder( *mpEditEngine ) );
+ }
+ else
+ mpTextForwarder.reset( NULL );
+ return mpTextForwarder.get();
+}
+
+SvxViewForwarder* ScAccessibleCsvTextData::GetViewForwarder()
+{
+ if( !mpViewForwarder.get() )
+ mpViewForwarder.reset( new ScCsvViewForwarder( mpWindow, maBoundBox ) );
+ return mpViewForwarder.get();
+}
+
+SvxEditViewForwarder* ScAccessibleCsvTextData::GetEditViewForwarder( sal_Bool /* bCreate */ )
+{
+ return NULL;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx b/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx
new file mode 100644
index 000000000000..5954c167248b
--- /dev/null
+++ b/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "DrawModelBroadcaster.hxx"
+#include <svx/svdmodel.hxx>
+#include <svx/unomod.hxx>
+#include <tools/debug.hxx>
+
+using namespace ::com::sun::star;
+
+ScDrawModelBroadcaster::ScDrawModelBroadcaster( SdrModel *pDrawModel ) :
+ maEventListeners( maListenerMutex ),
+ mpDrawModel( pDrawModel )
+{
+ if (mpDrawModel)
+ StartListening( *mpDrawModel );
+}
+
+ScDrawModelBroadcaster::~ScDrawModelBroadcaster()
+{
+ if (mpDrawModel)
+ EndListening( *mpDrawModel );
+}
+
+void SAL_CALL ScDrawModelBroadcaster::addEventListener( const uno::Reference< document::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maEventListeners.addInterface( xListener );
+}
+
+void SAL_CALL ScDrawModelBroadcaster::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ maEventListeners.removeInterface( xListener );
+}
+
+void ScDrawModelBroadcaster::Notify( SfxBroadcaster&,
+ const SfxHint& rHint )
+{
+ const SdrHint *pSdrHint = PTR_CAST( SdrHint, &rHint );
+ if( !pSdrHint )
+ return;
+
+ document::EventObject aEvent;
+ if( !SvxUnoDrawMSFactory::createEvent( mpDrawModel, pSdrHint, aEvent ) )
+ return;
+
+ ::cppu::OInterfaceIteratorHelper aIter( maEventListeners );
+ while( aIter.hasMoreElements() )
+ {
+ uno::Reference < document::XEventListener > xListener( aIter.next(), uno::UNO_QUERY );
+ try
+ {
+ xListener->notifyEvent( aEvent );
+ }
+ catch( uno::RuntimeException& r )
+ {
+ (void) r;
+#if OSL_DEBUG_LEVEL > 1
+ ByteString aError( "Runtime exception caught while notifying shape.:\n" );
+ aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US );
+ DBG_ERROR( aError.GetBuffer() );
+#endif
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/Accessibility/makefile.mk b/sc/source/ui/Accessibility/makefile.mk
new file mode 100644
index 000000000000..f041ca095bdd
--- /dev/null
+++ b/sc/source/ui/Accessibility/makefile.mk
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=accessibility
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/AccessibleContextBase.obj \
+ $(SLO)$/AccessibleTableBase.obj \
+ $(SLO)$/AccessibleDocument.obj \
+ $(SLO)$/AccessibleGlobal.obj \
+ $(SLO)$/AccessibleSpreadsheet.obj \
+ $(SLO)$/AccessibleCell.obj \
+ $(SLO)$/AccessibilityHints.obj \
+ $(SLO)$/AccessibleDocumentBase.obj \
+ $(SLO)$/AccessibleCellBase.obj \
+ $(SLO)$/AccessibleDocumentPagePreview.obj \
+ $(SLO)$/AccessibleFilterMenu.obj \
+ $(SLO)$/AccessibleFilterMenuItem.obj \
+ $(SLO)$/AccessibleFilterTopWindow.obj \
+ $(SLO)$/AccessiblePreviewTable.obj \
+ $(SLO)$/AccessiblePreviewCell.obj \
+ $(SLO)$/AccessiblePreviewHeaderCell.obj \
+ $(SLO)$/AccessiblePageHeader.obj \
+ $(SLO)$/AccessibleText.obj \
+ $(SLO)$/AccessiblePageHeaderArea.obj \
+ $(SLO)$/DrawModelBroadcaster.obj \
+ $(SLO)$/AccessibleEditObject.obj \
+ $(SLO)$/AccessibleDataPilotControl.obj \
+ $(SLO)$/AccessibleCsvControl.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/AccessibleContextBase.obj \
+ $(SLO)$/AccessibleTableBase.obj \
+ $(SLO)$/AccessibleDocument.obj \
+ $(SLO)$/AccessibleGlobal.obj \
+ $(SLO)$/AccessibleSpreadsheet.obj \
+ $(SLO)$/AccessibleCell.obj \
+ $(SLO)$/AccessibleDocumentBase.obj \
+ $(SLO)$/AccessibleCellBase.obj \
+ $(SLO)$/AccessibleDocumentPagePreview.obj \
+ $(SLO)$/AccessibleFilterMenu.obj \
+ $(SLO)$/AccessibleFilterMenuItem.obj \
+ $(SLO)$/AccessibleFilterTopWindow.obj \
+ $(SLO)$/AccessiblePreviewTable.obj \
+ $(SLO)$/AccessiblePreviewCell.obj \
+ $(SLO)$/AccessiblePreviewHeaderCell.obj \
+ $(SLO)$/AccessiblePageHeader.obj \
+ $(SLO)$/AccessiblePageHeaderArea.obj \
+ $(SLO)$/DrawModelBroadcaster.obj \
+ $(SLO)$/AccessibleEditObject.obj \
+ $(SLO)$/AccessibleDataPilotControl.obj \
+ $(SLO)$/AccessibleCsvControl.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sc/source/ui/app/client.cxx b/sc/source/ui/app/client.cxx
new file mode 100644
index 000000000000..68cefe7825a1
--- /dev/null
+++ b/sc/source/ui/app/client.cxx
@@ -0,0 +1,258 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sot/sotref.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdograf.hxx>
+#include <svtools/embedhlp.hxx>
+
+#include "client.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+ScClient::ScClient( ScTabViewShell* pViewShell, Window* pDraw, SdrModel* pSdrModel, SdrOle2Obj* pObj ) :
+ SfxInPlaceClient( pViewShell, pDraw, pObj->GetAspect() ),
+ pModel( pSdrModel ),
+ pGrafEdit( 0 )
+{
+ SetObject( pObj->GetObjRef() );
+}
+
+__EXPORT ScClient::~ScClient()
+{
+}
+
+SdrOle2Obj* ScClient::GetDrawObj()
+{
+ uno::Reference < embed::XEmbeddedObject > xObj = GetObject();
+ SdrOle2Obj* pOle2Obj = NULL;
+ String aName = GetViewShell()->GetObjectShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj );
+
+ USHORT nPages = pModel->GetPageCount();
+ for (USHORT nPNr=0; nPNr<nPages && !pOle2Obj; nPNr++)
+ {
+ SdrPage* pPage = pModel->GetPage(nPNr);
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !pOle2Obj)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 )
+ {
+ // name from InfoObject is PersistName
+ if ( ((SdrOle2Obj*)pObject)->GetPersistName() == aName )
+ pOle2Obj = (SdrOle2Obj*)pObject;
+ }
+ pObject = aIter.Next();
+ }
+ }
+ return pOle2Obj;
+}
+
+void __EXPORT ScClient::RequestNewObjectArea( Rectangle& aLogicRect )
+{
+ SfxViewShell* pSfxViewSh = GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pSfxViewSh );
+ if (!pViewSh)
+ {
+ DBG_ERROR("Wrong ViewShell");
+ return;
+ }
+
+ Rectangle aOldRect = GetObjArea();
+ SdrOle2Obj* pDrawObj = GetDrawObj();
+ if ( pDrawObj )
+ {
+ if ( pDrawObj->IsResizeProtect() )
+ aLogicRect.SetSize( aOldRect.GetSize() );
+
+ if ( pDrawObj->IsMoveProtect() )
+ aLogicRect.SetPos( aOldRect.TopLeft() );
+ }
+
+ USHORT nTab = pViewSh->GetViewData()->GetTabNo();
+ SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(static_cast<sal_Int16>(nTab)));
+ if ( pPage && aLogicRect != aOldRect )
+ {
+ Point aPos;
+ Size aSize = pPage->GetSize();
+ if ( aSize.Width() < 0 )
+ {
+ aPos.X() = aSize.Width() + 1; // negative
+ aSize.Width() = -aSize.Width(); // positive
+ }
+ Rectangle aPageRect( aPos, aSize );
+
+ if (aLogicRect.Right() > aPageRect.Right())
+ {
+ long nDiff = aLogicRect.Right() - aPageRect.Right();
+ aLogicRect.Left() -= nDiff;
+ aLogicRect.Right() -= nDiff;
+ }
+ if (aLogicRect.Bottom() > aPageRect.Bottom())
+ {
+ long nDiff = aLogicRect.Bottom() - aPageRect.Bottom();
+ aLogicRect.Top() -= nDiff;
+ aLogicRect.Bottom() -= nDiff;
+ }
+
+ if (aLogicRect.Left() < aPageRect.Left())
+ {
+ long nDiff = aLogicRect.Left() - aPageRect.Left();
+ aLogicRect.Right() -= nDiff;
+ aLogicRect.Left() -= nDiff;
+ }
+ if (aLogicRect.Top() < aPageRect.Top())
+ {
+ long nDiff = aLogicRect.Top() - aPageRect.Top();
+ aLogicRect.Bottom() -= nDiff;
+ aLogicRect.Top() -= nDiff;
+ }
+ }
+}
+
+void __EXPORT ScClient::ObjectAreaChanged()
+{
+ SfxViewShell* pSfxViewSh = GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pSfxViewSh );
+ if (!pViewSh)
+ {
+ DBG_ERROR("Wrong ViewShell");
+ return;
+ }
+
+ // Position und Groesse ins Dokument uebernehmen
+ SdrOle2Obj* pDrawObj = GetDrawObj();
+ if (pDrawObj)
+ {
+ pDrawObj->SetLogicRect( GetScaledObjArea() );
+
+ // set document modified (SdrModel::SetChanged is not used)
+ // TODO/LATER: is there a reason that this code is not executed in Draw?
+// SfxViewShell* pSfxViewSh = GetViewShell();
+// ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pSfxViewSh );
+ if (pViewSh)
+ pViewSh->GetViewData()->GetDocShell()->SetDrawModified();
+ }
+
+ if (pDrawObj)
+ pViewSh->ScrollToObject( pDrawObj );
+}
+
+void __EXPORT ScClient::ViewChanged()
+{
+ if ( GetAspect() == embed::Aspects::MSOLE_ICON )
+ {
+ // the iconified object seems not to need such a scaling handling
+ // since the replacement image and the size a completely controlled by the container
+ // TODO/LATER: when the icon exchange is implemented the scaling handling might be required again here
+
+ return;
+ }
+
+ uno::Reference < embed::XEmbeddedObject > xObj = GetObject();
+
+ // TODO/LEAN: working with Visual Area can switch object to running state
+ awt::Size aSz;
+ try {
+ aSz = xObj->getVisualAreaSize( GetAspect() );
+ } catch ( embed::NoVisualAreaSizeException& )
+ {
+ DBG_ERROR("The visual area size must be available!\n");
+ }
+
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( GetAspect() ) );
+ Size aVisSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aMapUnit, MAP_100TH_MM );
+
+ // Groesse ins Dokument uebernehmen
+ SdrOle2Obj* pDrawObj = GetDrawObj();
+ if (pDrawObj)
+ {
+ Rectangle aLogicRect = pDrawObj->GetLogicRect();
+ Fraction aFractX = GetScaleWidth();
+ Fraction aFractY = GetScaleHeight();
+ aFractX *= aVisSize.Width();
+ aFractY *= aVisSize.Height();
+ aVisSize = Size( (long) aFractX, (long) aFractY ); // skaliert fuer Draw-Model
+
+ // pClientData->SetObjArea vor pDrawObj->SetLogicRect, damit keine
+ // falschen Skalierungen ausgerechnet werden:
+ //Rectangle aObjArea = aLogicRect;
+ //aObjArea.SetSize( aVisSize ); // Dokument-Groesse vom Server
+ //SetObjArea( aObjArea );
+
+ SfxViewShell* pSfxViewSh = GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pSfxViewSh );
+ if ( pViewSh )
+ {
+ Window* pWin = pViewSh->GetActiveWin();
+ if ( pWin->LogicToPixel( aVisSize ) != pWin->LogicToPixel( aLogicRect.GetSize() ) )
+ {
+ aLogicRect.SetSize( aVisSize );
+ pDrawObj->SetLogicRect( aLogicRect );
+
+ // set document modified (SdrModel::SetChanged is not used)
+ pViewSh->GetViewData()->GetDocShell()->SetDrawModified();
+ }
+ }
+ }
+}
+
+void __EXPORT ScClient::MakeVisible()
+{
+ SdrOle2Obj* pDrawObj = GetDrawObj();
+ if (pDrawObj)
+ {
+ SfxViewShell* pSfxViewSh = GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pSfxViewSh );
+ if (pViewSh)
+ pViewSh->ScrollToObject( pDrawObj );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
new file mode 100644
index 000000000000..c41bd8762d76
--- /dev/null
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -0,0 +1,804 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <unotools/streamwrap.hxx>
+
+#include <svx/unomodel.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/storagehelper.hxx>
+
+#include <svtools/embedtransfer.hxx>
+#include <sot/storage.hxx>
+#include <vcl/virdev.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdxcgv.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/itempool.hxx>
+#include <svl/urlbmk.hxx>
+#include <tools/urlobj.hxx>
+#include <osl/mutex.hxx>
+
+#include "drwtrans.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "drawview.hxx"
+#include "viewdata.hxx"
+#include "scmod.hxx"
+
+// #108584#
+#include "scitems.hxx"
+
+// #108584#
+#include <editeng/eeitem.hxx>
+
+// #108584#
+#include <editeng/fhgtitem.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+#define SCDRAWTRANS_TYPE_EMBOBJ 1
+#define SCDRAWTRANS_TYPE_DRAWMODEL 2
+#define SCDRAWTRANS_TYPE_DOCUMENT 3
+
+// -----------------------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+ScDrawTransferObj::ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell,
+ const TransferableObjectDescriptor& rDesc ) :
+ pModel( pClipModel ),
+ aObjDesc( rDesc ),
+ pBookmark( NULL ),
+ bGraphic( FALSE ),
+ bGrIsBit( FALSE ),
+ bOleObj( FALSE ),
+ pDragSourceView( NULL ),
+ nDragSourceFlags( 0 ),
+ bDragWasInternal( FALSE ),
+ nSourceDocID( 0 )
+{
+ //
+ // check what kind of objects are contained
+ //
+
+ SdrPage* pPage = pModel->GetPage(0);
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_FLAT );
+ SdrObject* pObject = aIter.Next();
+ if (pObject && !aIter.Next()) // exactly one object?
+ {
+ //
+ // OLE object
+ //
+
+ UINT16 nSdrObjKind = pObject->GetObjIdentifier();
+ if (nSdrObjKind == OBJ_OLE2)
+ {
+ // if object has no persistence it must be copied as a part of document
+ try
+ {
+ uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObject)->GetObjRef(), uno::UNO_QUERY );
+ if ( xPersObj.is() && xPersObj->hasEntry() )
+ bOleObj = TRUE;
+ }
+ catch( uno::Exception& )
+ {}
+ // aOleData is initialized later
+ }
+
+ //
+ // Graphic object
+ //
+
+ if (nSdrObjKind == OBJ_GRAF)
+ {
+ bGraphic = TRUE;
+ if ( ((SdrGrafObj*)pObject)->GetGraphic().GetType() == GRAPHIC_BITMAP )
+ bGrIsBit = TRUE;
+ }
+
+ //
+ // URL button
+ //
+
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObject);
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
+ DBG_ASSERT( xControlModel.is(), "uno control without model" );
+ if ( xControlModel.is() )
+ {
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
+
+ rtl::OUString sPropButtonType = rtl::OUString::createFromAscii( "ButtonType" );
+ rtl::OUString sPropTargetURL = rtl::OUString::createFromAscii( "TargetURL" );
+ rtl::OUString sPropLabel = rtl::OUString::createFromAscii( "Label" );
+
+ if(xInfo->hasPropertyByName( sPropButtonType ))
+ {
+ uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
+ form::FormButtonType eTmp;
+ if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
+ {
+ // URL
+ if(xInfo->hasPropertyByName( sPropTargetURL ))
+ {
+ aAny = xPropSet->getPropertyValue( sPropTargetURL );
+ rtl::OUString sTmp;
+ if ( (aAny >>= sTmp) && sTmp.getLength() )
+ {
+ String aUrl = sTmp;
+ String aAbs;
+ const SfxMedium* pMedium;
+ if (pContainerShell && (pMedium = pContainerShell->GetMedium()) != NULL)
+ {
+ bool bWasAbs = true;
+ aAbs = pMedium->GetURLObject().smartRel2Abs( aUrl, bWasAbs ).
+ GetMainURL(INetURLObject::NO_DECODE);
+ // full path as stored INetBookmark must be encoded
+ }
+ else
+ aAbs = aUrl;
+
+ // Label
+ String aLabel;
+ if(xInfo->hasPropertyByName( sPropLabel ))
+ {
+ aAny = xPropSet->getPropertyValue( sPropLabel );
+ if ( (aAny >>= sTmp) && sTmp.getLength() )
+ {
+ aLabel = String(sTmp);
+ }
+ }
+ pBookmark = new INetBookmark( aAbs, aLabel );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //
+ // get size for object descriptor
+ //
+
+ // #i71538# use complete SdrViews
+ // SdrExchangeView aView(pModel);
+ SdrView aView(pModel);
+ SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0));
+ aView.MarkAllObj(pPv);
+ aSrcSize = aView.GetAllMarkedRect().GetSize();
+
+ if ( bOleObj ) // single OLE object
+ {
+ SdrOle2Obj* pObj = GetSingleObject();
+ if ( pObj && pObj->GetObjRef().is() )
+ SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() );
+ }
+
+ aObjDesc.maSize = aSrcSize;
+ PrepareOLE( aObjDesc );
+
+ //
+ // remember a unique ID of the source document
+ //
+ if ( pContainerShell )
+ {
+ const ScDocument* pDoc = pContainerShell->GetDocument();
+ if ( pDoc )
+ nSourceDocID = pDoc->GetDocumentID();
+ }
+}
+
+ScDrawTransferObj::~ScDrawTransferObj()
+{
+ SolarMutexGuard aSolarGuard;
+
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetClipData().pDrawClipboard == this )
+ {
+ DBG_ERROR("ScDrawTransferObj wasn't released");
+ pScMod->SetClipObject( NULL, NULL );
+ }
+ if ( pScMod->GetDragData().pDrawTransfer == this )
+ {
+ DBG_ERROR("ScDrawTransferObj wasn't released");
+ pScMod->ResetDragObject();
+ }
+
+ aOleData = TransferableDataHelper(); // clear before releasing the mutex
+ aDocShellRef.Clear();
+
+ delete pModel;
+ aDrawPersistRef.Clear(); // after the model
+
+ delete pBookmark;
+ delete pDragSourceView;
+}
+
+// static
+ScDrawTransferObj* ScDrawTransferObj::GetOwnClipboard( Window* )
+{
+ ScDrawTransferObj* pObj = SC_MOD()->GetClipData().pDrawClipboard;
+ return pObj;
+}
+
+BOOL lcl_HasOnlyControls( SdrModel* pModel )
+{
+ BOOL bOnlyControls = FALSE; // default if there are no objects
+
+ if ( pModel )
+ {
+ SdrPage* pPage = pModel->GetPage(0);
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObj = aIter.Next();
+ if ( pObj )
+ {
+ bOnlyControls = TRUE; // only set if there are any objects at all
+ while ( pObj )
+ {
+ if (!pObj->ISA(SdrUnoObj))
+ {
+ bOnlyControls = FALSE;
+ break;
+ }
+ pObj = aIter.Next();
+ }
+ }
+ }
+ }
+
+ return bOnlyControls;
+}
+
+void ScDrawTransferObj::AddSupportedFormats()
+{
+ if ( bGrIsBit ) // single bitmap graphic
+ {
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ AddFormat( SOT_FORMAT_BITMAP );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ }
+ else if ( bGraphic ) // other graphic
+ {
+ // #i25616#
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMAT_BITMAP );
+ }
+ else if ( pBookmark ) // url button
+ {
+// AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ }
+ else if ( bOleObj ) // single OLE object
+ {
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+
+ if ( !aOleData.GetTransferable().is() )
+ {
+ SdrOle2Obj* pObj = GetSingleObject();
+ if ( pObj && pObj->GetObjRef().is() )
+ aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ;
+ }
+ if ( aOleData.GetTransferable().is() )
+ {
+ // get format list from object snapshot
+ // (this must be after inserting the default formats!)
+
+ DataFlavorExVector aVector( aOleData.GetDataFlavorExVector() );
+ DataFlavorExVector::iterator aIter( aVector.begin() ), aEnd( aVector.end() );
+
+ while( aIter != aEnd )
+ AddFormat( *aIter++ );
+ }
+ }
+ else // any drawing objects
+ {
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+
+ // #103556# leave out bitmap and metafile if there are only controls
+ if ( !lcl_HasOnlyControls( pModel ) )
+ {
+ AddFormat( SOT_FORMAT_BITMAP );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ }
+ }
+
+// if( pImageMap )
+// AddFormat( SOT_FORMATSTR_ID_SVIM );
+}
+
+sal_Bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ sal_Bool bOK = sal_False;
+ sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
+
+ if ( bOleObj && nFormat != SOT_FORMAT_GDIMETAFILE )
+ {
+ if ( !aOleData.GetTransferable().is() )
+ {
+ SdrOle2Obj* pObj = GetSingleObject();
+ if ( pObj && pObj->GetObjRef().is() )
+ aOleData = TransferableDataHelper( new SvEmbedTransferHelper( pObj->GetObjRef(), pObj->GetGraphic(), pObj->GetAspect() ) ) ;
+ }
+
+ if( aOleData.GetTransferable().is() && aOleData.HasFormat( rFlavor ) )
+ {
+ ULONG nOldSwapMode = 0;
+
+ if( pModel )
+ {
+ nOldSwapMode = pModel->GetSwapGraphicsMode();
+ pModel->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_PURGE );
+ }
+
+ bOK = SetAny( aOleData.GetAny( rFlavor ), rFlavor );
+
+ if( pModel )
+ pModel->SetSwapGraphicsMode( nOldSwapMode );
+
+ return bOK;
+ }
+ }
+
+ if( HasFormat( nFormat ) )
+ {
+ if ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
+ {
+ bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
+ }
+ else if ( nFormat == SOT_FORMATSTR_ID_DRAWING )
+ {
+ bOK = SetObject( pModel, SCDRAWTRANS_TYPE_DRAWMODEL, rFlavor );
+ }
+ else if ( nFormat == SOT_FORMAT_BITMAP || nFormat == SOT_FORMAT_GDIMETAFILE )
+ {
+ // #i71538# use complete SdrViews
+ // SdrExchangeView aView( pModel );
+ SdrView aView( pModel );
+ SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0));
+ DBG_ASSERT( pPv, "pPv not there..." );
+ aView.MarkAllObj( pPv );
+ if ( nFormat == SOT_FORMAT_GDIMETAFILE )
+ bOK = SetGDIMetaFile( aView.GetAllMarkedMetaFile( TRUE ), rFlavor );
+ else
+ bOK = SetBitmap( aView.GetAllMarkedBitmap( TRUE ), rFlavor );
+ }
+ else if ( nFormat == SOT_FORMATSTR_ID_SVXB )
+ {
+ // only enabled for single graphics object
+
+ SdrPage* pPage = pModel->GetPage(0);
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_FLAT );
+ SdrObject* pObject = aIter.Next();
+ if (pObject && pObject->GetObjIdentifier() == OBJ_GRAF)
+ {
+ SdrGrafObj* pGraphObj = (SdrGrafObj*) pObject;
+ bOK = SetGraphic( pGraphObj->GetGraphic(), rFlavor );
+ }
+ }
+ }
+ else if ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ {
+ if ( bOleObj ) // single OLE object
+ {
+ SdrOle2Obj* pObj = GetSingleObject();
+ if ( pObj && pObj->GetObjRef().is() )
+ {
+ bOK = SetObject( pObj->GetObjRef().get(), SCDRAWTRANS_TYPE_EMBOBJ, rFlavor );
+ }
+ }
+ else // create object from contents
+ {
+ //TODO/LATER: needs new Format, because now single OLE and "this" are different
+ InitDocShell(); // set aDocShellRef
+
+ SfxObjectShell* pEmbObj = aDocShellRef;
+ bOK = SetObject( pEmbObj, SCDRAWTRANS_TYPE_DOCUMENT, rFlavor );
+ }
+ }
+ else if( pBookmark )
+ {
+ bOK = SetINetBookmark( *pBookmark, rFlavor );
+ }
+ }
+ return bOK;
+}
+
+sal_Bool ScDrawTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
+ const ::com::sun::star::datatransfer::DataFlavor& /* rFlavor */ )
+{
+ // called from SetObject, put data into stream
+
+ sal_Bool bRet = sal_False;
+ switch (nUserObjectId)
+ {
+ case SCDRAWTRANS_TYPE_DRAWMODEL:
+ {
+ SdrModel* pDrawModel = (SdrModel*)pUserObject;
+ rxOStm->SetBufferSize( 0xff00 );
+
+ // #108584#
+ // for the changed pool defaults from drawing layer pool set those
+ // attributes as hard attributes to preserve them for saving
+ const SfxItemPool& rItemPool = pModel->GetItemPool();
+ const SvxFontHeightItem& rDefaultFontHeight = (const SvxFontHeightItem&)rItemPool.GetDefaultItem(EE_CHAR_FONTHEIGHT);
+
+ // SW should have no MasterPages
+ DBG_ASSERT(0L == pModel->GetMasterPageCount(), "SW with MasterPages (!)");
+
+ for(sal_uInt16 a(0); a < pModel->GetPageCount(); a++)
+ {
+ const SdrPage* pPage = pModel->GetPage(a);
+ SdrObjListIter aIter(*pPage, IM_DEEPNOGROUPS);
+
+ while(aIter.IsMore())
+ {
+ SdrObject* pObj = aIter.Next();
+ const SvxFontHeightItem& rItem = (const SvxFontHeightItem&)pObj->GetMergedItem(EE_CHAR_FONTHEIGHT);
+
+ if(rItem.GetHeight() == rDefaultFontHeight.GetHeight())
+ {
+ pObj->SetMergedItem(rDefaultFontHeight);
+ }
+ }
+ }
+
+ {
+ com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
+ if( SvxDrawingLayerExport( pDrawModel, xDocOut ) )
+ rxOStm->Commit();
+ }
+
+ bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ }
+ break;
+
+ case SCDRAWTRANS_TYPE_EMBOBJ:
+ {
+ // impl. for "single OLE"
+ embed::XEmbeddedObject* pEmbObj = (embed::XEmbeddedObject*) pUserObject;
+
+ ::utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Reference< embed::XStorage > xWorkStore =
+ ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
+
+ uno::Reference < embed::XEmbedPersist > xPers( (embed::XVisualObject*)pEmbObj, uno::UNO_QUERY );
+ if ( xPers.is() )
+ {
+ try
+ {
+ uno::Sequence < beans::PropertyValue > aSeq;
+ ::rtl::OUString aDummyName = ::rtl::OUString::createFromAscii("Dummy");
+ xPers->storeToEntry( xWorkStore, aDummyName, aSeq, aSeq );
+ if ( xWorkStore->isStreamElement( aDummyName ) )
+ {
+ uno::Reference < io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) );
+ uno::Reference < io::XStream > xNewStream = xWorkStore->openStreamElement( aDummyName, embed::ElementModes::READ );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xNewStream->getInputStream(), xDocOut );
+ }
+ else
+ {
+ uno::Reference < io::XStream > xDocStr( new utl::OStreamWrapper( *rxOStm ) );
+ uno::Reference< embed::XStorage > xDocStg = ::comphelper::OStorageHelper::GetStorageFromStream( xDocStr );
+ uno::Reference < embed::XStorage > xNewStg = xWorkStore->openStorageElement( aDummyName, embed::ElementModes::READ );
+ xNewStg->copyToStorage( xDocStg );
+ uno::Reference < embed::XTransactedObject > xTrans( xDocStg, uno::UNO_QUERY );
+ if ( xTrans.is() )
+ xTrans->commit();
+ }
+
+ rxOStm->Commit();
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+
+ break;
+ }
+ case SCDRAWTRANS_TYPE_DOCUMENT:
+ {
+ // impl. for "DocShell"
+ SfxObjectShell* pEmbObj = (SfxObjectShell*) pUserObject;
+
+ try
+ {
+ ::utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Reference< embed::XStorage > xWorkStore =
+ ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
+
+ // write document storage
+ pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
+
+ // mba: no relative ULRs for clipboard!
+ SfxMedium aMedium( xWorkStore, String() );
+ bRet = pEmbObj->DoSaveObjectAs( aMedium, FALSE );
+ pEmbObj->DoSaveCompleted();
+
+ uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
+ if ( xTransact.is() )
+ xTransact->commit();
+
+ SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
+ if( pSrcStm )
+ {
+ rxOStm->SetBufferSize( 0xff00 );
+ *rxOStm << *pSrcStm;
+ delete pSrcStm;
+ }
+
+ bRet = TRUE;
+
+ xWorkStore->dispose();
+ xWorkStore = uno::Reference < embed::XStorage >();
+ rxOStm->Commit();
+ }
+ catch ( uno::Exception& )
+ {}
+
+ bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ }
+ break;
+
+ default:
+ DBG_ERROR("unknown object id");
+ }
+ return bRet;
+}
+
+void ScDrawTransferObj::ObjectReleased()
+{
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetClipData().pDrawClipboard == this )
+ pScMod->SetClipObject( NULL, NULL );
+
+ TransferableHelper::ObjectReleased();
+}
+
+void ScDrawTransferObj::DragFinished( sal_Int8 nDropAction )
+{
+ if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) )
+ {
+ // move: delete source objects
+
+ if ( pDragSourceView )
+ pDragSourceView->DeleteMarked();
+ }
+
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetDragData().pDrawTransfer == this )
+ pScMod->ResetDragObject();
+
+ DELETEZ( pDragSourceView );
+
+ TransferableHelper::DragFinished( nDropAction );
+}
+
+void ScDrawTransferObj::SetDrawPersist( const SfxObjectShellRef& rRef )
+{
+ aDrawPersistRef = rRef;
+}
+
+void lcl_InitMarks( SdrMarkView& rDest, const SdrMarkView& rSource, SCTAB nTab )
+{
+ rDest.ShowSdrPage(rDest.GetModel()->GetPage(nTab));
+ SdrPageView* pDestPV = rDest.GetSdrPageView();
+ DBG_ASSERT(pDestPV,"PageView ?");
+
+ const SdrMarkList& rMarkList = rSource.GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ SdrMark* pMark = rMarkList.GetMark(i);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ rDest.MarkObj(pObj, pDestPV);
+ }
+}
+
+void ScDrawTransferObj::SetDragSource( ScDrawView* pView )
+{
+ DELETEZ( pDragSourceView );
+ pDragSourceView = new SdrView( pView->GetModel() );
+ lcl_InitMarks( *pDragSourceView, *pView, pView->GetTab() );
+
+ //! add as listener with document, delete pDragSourceView if document gone
+}
+
+void ScDrawTransferObj::SetDragSourceObj( SdrObject* pObj, SCTAB nTab )
+{
+ DELETEZ( pDragSourceView );
+ pDragSourceView = new SdrView( pObj->GetModel() );
+ pDragSourceView->ShowSdrPage(pDragSourceView->GetModel()->GetPage(nTab));
+ SdrPageView* pPV = pDragSourceView->GetSdrPageView();
+ pDragSourceView->MarkObj(pObj, pPV);
+
+ //! add as listener with document, delete pDragSourceView if document gone
+}
+
+void ScDrawTransferObj::SetDragSourceFlags( USHORT nFlags )
+{
+ nDragSourceFlags = nFlags;
+}
+
+void ScDrawTransferObj::SetDragWasInternal()
+{
+ bDragWasInternal = TRUE;
+}
+
+SdrOle2Obj* ScDrawTransferObj::GetSingleObject()
+{
+ // if single OLE object was copied, get its object
+
+ SdrPage* pPage = pModel->GetPage(0);
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_FLAT );
+ SdrObject* pObject = aIter.Next();
+ if (pObject && pObject->GetObjIdentifier() == OBJ_OLE2)
+ {
+ return (SdrOle2Obj*) pObject;
+ }
+ }
+
+ return NULL;
+}
+
+//
+// initialize aDocShellRef with a live document from the ClipDoc
+//
+
+void ScDrawTransferObj::InitDocShell()
+{
+ if ( !aDocShellRef.Is() )
+ {
+ ScDocShell* pDocSh = new ScDocShell;
+ aDocShellRef = pDocSh; // ref must be there before InitNew
+
+ pDocSh->DoInitNew(NULL);
+
+ ScDocument* pDestDoc = pDocSh->GetDocument();
+ pDestDoc->InitDrawLayer( pDocSh );
+
+ SdrModel* pDestModel = pDestDoc->GetDrawLayer();
+ // #i71538# use complete SdrViews
+ // SdrExchangeView aDestView( pDestModel );
+ SdrView aDestView( pDestModel );
+ aDestView.ShowSdrPage(aDestView.GetModel()->GetPage(0));
+ aDestView.Paste( *pModel, Point( aSrcSize.Width()/2, aSrcSize.Height()/2 ) );
+
+ // put objects to right layer (see ScViewFunc::PasteDataFormat for SOT_FORMATSTR_ID_DRAWING)
+
+ SdrPage* pPage = pDestModel->GetPage(0);
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->ISA(SdrUnoObj) )
+ pObject->NbcSetLayer(SC_LAYER_CONTROLS);
+ else
+ pObject->NbcSetLayer(SC_LAYER_FRONT);
+ pObject = aIter.Next();
+ }
+ }
+
+ Point aTmpPoint;
+ Rectangle aDestArea( aTmpPoint, aSrcSize );
+ pDocSh->SetVisArea( aDestArea );
+
+ ScViewOptions aViewOpt( pDestDoc->GetViewOptions() );
+ aViewOpt.SetOption( VOPT_GRID, FALSE );
+ pDestDoc->SetViewOptions( aViewOpt );
+
+ ScViewData aViewData( pDocSh, NULL );
+ aViewData.SetTabNo( 0 );
+ aViewData.SetScreen( aDestArea );
+ aViewData.SetCurX( 0 );
+ aViewData.SetCurY( 0 );
+ pDocSh->UpdateOle(&aViewData, TRUE);
+ }
+}
+
+const com::sun::star::uno::Sequence< sal_Int8 >& ScDrawTransferObj::getUnoTunnelId()
+{
+ static com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ if( !aSeq.getLength() )
+ {
+ static osl::Mutex aCreateMutex;
+ osl::Guard< osl::Mutex > aGuard( aCreateMutex );
+ aSeq.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
+ }
+ return aSeq;
+}
+
+sal_Int64 SAL_CALL ScDrawTransferObj::getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException )
+{
+ sal_Int64 nRet;
+ if( ( rId.getLength() == 16 ) &&
+ ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
+ {
+ nRet = reinterpret_cast< sal_Int64 >( this );
+ }
+ else
+ nRet = TransferableHelper::getSomething(rId);
+ return nRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
new file mode 100644
index 000000000000..d50a5818f193
--- /dev/null
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -0,0 +1,3828 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <editeng/acorrcfg.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/svxacorr.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/sound.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <vcl/help.hxx>
+#include <vcl/cursor.hxx>
+#include <tools/urlobj.hxx>
+#include <formula/formulahelper.hxx>
+
+#include "inputwin.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "patattr.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "editutil.hxx"
+#include "collect.hxx"
+#include "appoptio.hxx"
+#include "docoptio.hxx"
+#include "validat.hxx"
+#include "userlist.hxx"
+#include "rfindlst.hxx"
+#include "inputopt.hxx"
+#include "cell.hxx" // fuer Formel-Preview
+#include "compiler.hxx" // fuer Formel-Preview
+#include "editable.hxx"
+#include "funcdesc.hxx"
+
+#define _INPUTHDL_CXX
+#include "inputhdl.hxx"
+
+// max. Ranges im RangeFinder
+#define RANGEFIND_MAX 32
+
+using namespace formula;
+
+// STATIC DATA -----------------------------------------------------------
+
+BOOL ScInputHandler::bOptLoaded = FALSE; // App-Optionen ausgewertet
+BOOL ScInputHandler::bAutoComplete = FALSE; // wird in KeyInput gesetzt
+
+// delimiters (in addition to ScEditUtil) needed for range finder:
+// only characters that are allowed in formulas next to references
+// and the quotation mark (so string constants can be skipped)
+
+static const sal_Char __FAR_DATA pMinDelimiters[] = " !\"";
+
+extern USHORT nEditAdjust; //! Member an ViewData
+
+//==================================================================
+
+static sal_Unicode lcl_getSheetSeparator(ScDocument* pDoc)
+{
+ ScCompiler aComp(pDoc, ScAddress());
+ aComp.SetGrammar(pDoc->GetGrammar());
+ return aComp.GetNativeAddressSymbol(ScCompiler::Convention::SHEET_SEPARATOR);
+}
+
+void ScInputHandler::InitRangeFinder( const String& rFormula )
+{
+ DeleteRangeFinder();
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ const sal_Unicode cSheetSep = lcl_getSheetSeparator(pDoc);
+
+ if ( !pActiveViewSh || !SC_MOD()->GetInputOptions().GetRangeFinder() )
+ return;
+
+// String aDelimiters = pEngine->GetWordDelimiters();
+ String aDelimiters = ScEditUtil::ModifyDelimiters(
+ String::CreateFromAscii( pMinDelimiters ) );
+
+ xub_StrLen nColon = aDelimiters.Search(':');
+ if ( nColon != STRING_NOTFOUND )
+ aDelimiters.Erase( nColon, 1 ); // Delimiter ohne Doppelpunkt
+ xub_StrLen nDot = aDelimiters.Search(cSheetSep);
+ if ( nDot != STRING_NOTFOUND )
+ aDelimiters.Erase( nDot, 1 ); // Delimiter ohne Punkt
+
+ const sal_Unicode* pChar = rFormula.GetBuffer();
+ xub_StrLen nLen = rFormula.Len();
+ xub_StrLen nPos = 0;
+ xub_StrLen nStart = 0;
+ USHORT nCount = 0;
+ ScRange aRange;
+ while ( nPos < nLen && nCount < RANGEFIND_MAX )
+ {
+ // Trenner ueberlesen
+ while ( nPos<nLen && ScGlobal::UnicodeStrChr( aDelimiters.GetBuffer(), pChar[nPos] ) )
+ {
+ if ( pChar[nPos] == '"' ) // String
+ {
+ ++nPos;
+ while (nPos<nLen && pChar[nPos] != '"') // bis zum Ende ueberlesen
+ ++nPos;
+ }
+ ++nPos; // Trennzeichen oder schliessender Quote
+ }
+
+ // Text zwischen Trennern
+ nStart = nPos;
+handle_r1c1:
+ while ( nPos<nLen && !ScGlobal::UnicodeStrChr( aDelimiters.GetBuffer(), pChar[nPos] ) )
+ ++nPos;
+
+ // for R1C1 '-' in R[-]... or C[-]... are not delimiters
+ // Nothing heroic here to ensure that there are '[]' around a negative
+ // integer. we need to clean up this code.
+ if( nPos < nLen && nPos > 0 &&
+ '-' == pChar[nPos] && '[' == pChar[nPos-1] &&
+ NULL != pDoc &&
+ formula::FormulaGrammar::CONV_XL_R1C1 == pDoc->GetAddressConvention() )
+ {
+ nPos++;
+ goto handle_r1c1;
+ }
+
+ if ( nPos > nStart )
+ {
+ String aTest = rFormula.Copy( nStart, nPos-nStart );
+ const ScAddress::Details aAddrDetails( pDoc, aCursorPos );
+ USHORT nFlags = aRange.ParseAny( aTest, pDoc, aAddrDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ // Tabelle setzen, wenn nicht angegeben
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ aRange.aStart.SetTab( pActiveViewSh->GetViewData()->GetTabNo() );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ aRange.aEnd.SetTab( aRange.aStart.Tab() );
+
+ if ( ( nFlags & ( SCA_VALID_COL2 | SCA_VALID_ROW2 | SCA_VALID_TAB2 ) ) == 0 )
+ {
+ // #i73766# if a single ref was parsed, set the same "abs" flags for ref2,
+ // so Format doesn't output a double ref because of different flags.
+ USHORT nAbsFlags = nFlags & ( SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE );
+ nFlags |= nAbsFlags << 4;
+ }
+
+ if (!nCount)
+ {
+ pEngine->SetUpdateMode( FALSE );
+ pRangeFindList = new ScRangeFindList( pDocSh->GetTitle() );
+ }
+
+ ScRangeFindData* pNew = new ScRangeFindData( aRange, nFlags, nStart, nPos );
+ pRangeFindList->Insert( pNew );
+
+ ESelection aSel( 0, nStart, 0, nPos );
+ SfxItemSet aSet( pEngine->GetEmptyItemSet() );
+ aSet.Put( SvxColorItem( Color( ScRangeFindList::GetColorName( nCount ) ),
+ EE_CHAR_COLOR ) );
+ pEngine->QuickSetAttribs( aSet, aSel );
+ ++nCount;
+ }
+ }
+
+ // letzten Trenner nicht ueberlesen, koennte ja ein Quote sein (?)
+ }
+
+ if (nCount)
+ {
+ pEngine->SetUpdateMode( TRUE );
+
+ pDocSh->Broadcast( SfxSimpleHint( SC_HINT_SHOWRANGEFINDER ) );
+ }
+}
+
+void lcl_Replace( EditView* pView, const String& rNewStr, const ESelection& rOldSel )
+{
+ if ( pView )
+ {
+ ESelection aOldSel = pView->GetSelection();
+ if (aOldSel.HasRange())
+ pView->SetSelection( ESelection( aOldSel.nEndPara, aOldSel.nEndPos,
+ aOldSel.nEndPara, aOldSel.nEndPos ) );
+
+ EditEngine* pEngine = pView->GetEditEngine();
+ pEngine->QuickInsertText( rNewStr, rOldSel );
+
+ // Dummy-InsertText fuer Update und Paint
+ // dafuer muss oben die Selektion aufgehoben werden (vor QuickInsertText)
+ pView->InsertText( EMPTY_STRING, FALSE );
+
+ xub_StrLen nLen = pEngine->GetTextLen(0);
+ ESelection aSel( 0, nLen, 0, nLen );
+ pView->SetSelection( aSel ); // Cursor ans Ende
+ }
+}
+
+void ScInputHandler::UpdateRange( USHORT nIndex, const ScRange& rNew )
+{
+ ScTabViewShell* pDocView = pRefViewSh ? pRefViewSh : pActiveViewSh;
+ if ( pDocView && pRangeFindList && nIndex < pRangeFindList->Count() )
+ {
+ ScRangeFindData* pData = pRangeFindList->GetObject( nIndex );
+ xub_StrLen nOldStart = pData->nSelStart;
+ xub_StrLen nOldEnd = pData->nSelEnd;
+
+ ScRange aJustified = rNew;
+ aJustified.Justify(); // Ref in der Formel immer richtigherum anzeigen
+ String aNewStr;
+ ScDocument* pDoc = pDocView->GetViewData()->GetDocument();
+ const ScAddress::Details aAddrDetails( pDoc, aCursorPos );
+ aJustified.Format( aNewStr, pData->nFlags, pDoc, aAddrDetails );
+ ESelection aOldSel( 0, nOldStart, 0, nOldEnd );
+
+ DataChanging();
+
+ lcl_Replace( pTopView, aNewStr, aOldSel );
+ lcl_Replace( pTableView, aNewStr, aOldSel );
+
+ bInRangeUpdate = TRUE;
+ DataChanged();
+ bInRangeUpdate = FALSE;
+
+ long nDiff = aNewStr.Len() - (long)(nOldEnd-nOldStart);
+
+ pData->aRef = rNew;
+ pData->nSelEnd = (xub_StrLen)(pData->nSelEnd + nDiff);
+
+ USHORT nCount = (USHORT) pRangeFindList->Count();
+ for (USHORT i=nIndex+1; i<nCount; i++)
+ {
+ ScRangeFindData* pNext = pRangeFindList->GetObject( i );
+ pNext->nSelStart = (xub_StrLen)(pNext->nSelStart + nDiff);
+ pNext->nSelEnd = (xub_StrLen)(pNext->nSelEnd + nDiff);
+ }
+ }
+ else
+ {
+ DBG_ERROR("UpdateRange: da fehlt was");
+ }
+}
+
+void ScInputHandler::DeleteRangeFinder()
+{
+ ScTabViewShell* pPaintView = pRefViewSh ? pRefViewSh : pActiveViewSh;
+ if ( pRangeFindList && pPaintView )
+ {
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
+ pRangeFindList->SetHidden(TRUE);
+ pDocSh->Broadcast( SfxSimpleHint( SC_HINT_SHOWRANGEFINDER ) ); // wegnehmen
+ DELETEZ(pRangeFindList);
+ }
+}
+
+//==================================================================
+
+inline String GetEditText(EditEngine* pEng)
+{
+ return ScEditUtil::GetSpaceDelimitedString(*pEng);
+}
+
+void lcl_RemoveTabs(String& rStr)
+{
+ xub_StrLen nPos;
+ while ( (nPos=rStr.Search('\t')) != STRING_NOTFOUND )
+ rStr.SetChar( nPos, ' ' );
+}
+
+void lcl_RemoveLineEnd(String& rStr)
+{
+ rStr.ConvertLineEnd(LINEEND_LF);
+ xub_StrLen nPos;
+ while ( (nPos=rStr.Search('\n')) != STRING_NOTFOUND )
+ rStr.SetChar( nPos, ' ' );
+}
+
+xub_StrLen lcl_MatchParenthesis( const String& rStr, xub_StrLen nPos )
+{
+ int nDir;
+ sal_Unicode c1, c2 = 0;
+ c1 = rStr.GetChar( nPos );
+ switch ( c1 )
+ {
+ case '(' :
+ c2 = ')';
+ nDir = 1;
+ break;
+ case ')' :
+ c2 = '(';
+ nDir = -1;
+ break;
+ case '<' :
+ c2 = '>';
+ nDir = 1;
+ break;
+ case '>' :
+ c2 = '<';
+ nDir = -1;
+ break;
+ case '{' :
+ c2 = '}';
+ nDir = 1;
+ break;
+ case '}' :
+ c2 = '{';
+ nDir = -1;
+ break;
+ case '[' :
+ c2 = ']';
+ nDir = 1;
+ break;
+ case ']' :
+ c2 = '[';
+ nDir = -1;
+ break;
+ default:
+ nDir = 0;
+ }
+ if ( !nDir )
+ return STRING_NOTFOUND;
+ xub_StrLen nLen = rStr.Len();
+ const sal_Unicode* p0 = rStr.GetBuffer();
+ register const sal_Unicode* p;
+ const sal_Unicode* p1;
+ USHORT nQuotes = 0;
+ if ( nPos < nLen / 2 )
+ {
+ p = p0;
+ p1 = p0 + nPos;
+ }
+ else
+ {
+ p = p0 + nPos;
+ p1 = p0 + nLen;
+ }
+ while ( p < p1 )
+ {
+ if ( *p++ == '\"' )
+ nQuotes++;
+ }
+ // Odd number of quotes that we find ourselves in a string
+ BOOL bLookInString = ((nQuotes % 2) != 0);
+ BOOL bInString = bLookInString;
+ p = p0 + nPos;
+ p1 = (nDir < 0 ? p0 : p0 + nLen) ;
+ USHORT nLevel = 1;
+ while ( p != p1 && nLevel )
+ {
+ p += nDir;
+ if ( *p == '\"' )
+ {
+ bInString = !bInString;
+ if ( bLookInString && !bInString )
+ p = p1; //That's it then
+ }
+ else if ( bInString == bLookInString )
+ {
+ if ( *p == c1 )
+ nLevel++;
+ else if ( *p == c2 )
+ nLevel--;
+ }
+ }
+ if ( nLevel )
+ return STRING_NOTFOUND;
+ return (xub_StrLen) (p - p0);
+}
+
+//==================================================================
+
+ScInputHandler::ScInputHandler()
+ : pInputWin( NULL ),
+ pEngine( NULL ),
+ pTableView( NULL ),
+ pTopView( NULL ),
+ pColumnData( NULL ),
+ pFormulaData( NULL ),
+ pFormulaDataPara( NULL ),
+ pTipVisibleParent( NULL ),
+ nTipVisible( 0 ),
+ pTipVisibleSecParent( NULL ),
+ nTipVisibleSec( 0 ),
+ nAutoPos( SCPOS_INVALID ),
+ bUseTab( FALSE ),
+ bTextValid( TRUE ),
+ nFormSelStart( 0 ),
+ nFormSelEnd( 0 ),
+ nAutoPar( 0 ),
+ eMode( SC_INPUT_NONE ),
+ bModified( FALSE ),
+ bSelIsRef( FALSE ),
+ bFormulaMode( FALSE ),
+ bInRangeUpdate( FALSE ),
+ bParenthesisShown( FALSE ),
+ bCreatingFuncView( FALSE ),
+ bInEnterHandler( FALSE ),
+ bCommandErrorShown( FALSE ),
+ bInOwnChange( FALSE ),
+ bProtected( FALSE ),
+ bCellHasPercentFormat( FALSE ),
+ nValidation( 0 ),
+ eAttrAdjust( SVX_HOR_JUSTIFY_STANDARD ),
+ aScaleX( 1,1 ),
+ aScaleY( 1,1 ),
+ pRefViewSh( NULL ),
+ pLastPattern( NULL ),
+ pEditDefaults( NULL ),
+ bLastIsSymbol( FALSE ),
+ pLastState( NULL ),
+ pDelayTimer( NULL ),
+ pRangeFindList( NULL )
+{
+ // The InputHandler is constructed with the view, so SfxViewShell::Current
+ // doesn't have the right view yet. pActiveViewSh is updated in NotifyChange.
+ pActiveViewSh = NULL;
+
+ // Bindings (nur noch fuer Invalidate benutzt) werden bei Bedarf aktuell geholt
+}
+
+__EXPORT ScInputHandler::~ScInputHandler()
+{
+ // Wenn dies der Applikations-InputHandler ist, wird der dtor erst nach SfxApplication::Main
+ // gerufen, darf sich also auf keine Sfx-Funktionen mehr verlassen
+
+ if ( !SFX_APP()->IsDowning() ) // inplace
+ EnterHandler(); // Eingabe noch abschliessen
+
+ if (SC_MOD()->GetRefInputHdl()==this)
+ SC_MOD()->SetRefInputHdl(NULL);
+
+ if ( pInputWin && pInputWin->GetInputHandler() == this )
+ pInputWin->SetInputHandler( NULL );
+
+ delete pRangeFindList;
+ delete pEditDefaults;
+ delete pEngine;
+ delete pLastState;
+ delete pDelayTimer;
+ delete pColumnData;
+ delete pFormulaData;
+ delete pFormulaDataPara;
+}
+
+void ScInputHandler::SetRefScale( const Fraction& rX, const Fraction& rY )
+{
+ if ( rX != aScaleX || rY != aScaleY )
+ {
+ aScaleX = rX;
+ aScaleY = rY;
+ if (pEngine)
+ {
+ MapMode aMode( MAP_100TH_MM, Point(), aScaleX, aScaleY );
+ pEngine->SetRefMapMode( aMode );
+ }
+ }
+}
+
+void ScInputHandler::UpdateRefDevice()
+{
+ if (!pEngine)
+ return;
+
+ BOOL bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
+ if ( bTextWysiwyg && pActiveViewSh )
+ pEngine->SetRefDevice( pActiveViewSh->GetViewData()->GetDocument()->GetPrinter() );
+ else
+ pEngine->SetRefDevice( NULL );
+
+ MapMode aMode( MAP_100TH_MM, Point(), aScaleX, aScaleY );
+ pEngine->SetRefMapMode( aMode );
+
+ // SetRefDevice(NULL) uses VirtualDevice, SetRefMapMode forces creation of a local VDev,
+ // so the DigitLanguage can be safely modified (might use an own VDev instead of NULL).
+ if ( !( bTextWysiwyg && pActiveViewSh ) )
+ {
+ pEngine->GetRefDevice()->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
+ }
+}
+
+void ScInputHandler::ImplCreateEditEngine()
+{
+ if ( !pEngine )
+ {
+ if ( pActiveViewSh )
+ {
+ const ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+ pEngine = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+ }
+ else
+ pEngine = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, TRUE );
+ pEngine->SetWordDelimiters( ScEditUtil::ModifyDelimiters( pEngine->GetWordDelimiters() ) );
+ UpdateRefDevice(); // also sets MapMode
+ pEngine->SetPaperSize( Size( 1000000, 1000000 ) );
+ pEditDefaults = new SfxItemSet( pEngine->GetEmptyItemSet() );
+
+ pEngine->SetControlWord( pEngine->GetControlWord() | EE_CNTRL_AUTOCORRECT );
+ pEngine->SetModifyHdl( LINK( this, ScInputHandler, ModifyHdl ) );
+ }
+}
+
+void ScInputHandler::UpdateAutoCorrFlag()
+{
+ ULONG nCntrl = pEngine->GetControlWord();
+ ULONG nOld = nCntrl;
+
+ // don't use pLastPattern here (may be invalid because of AutoStyle)
+
+ BOOL bDisable = bLastIsSymbol || bFormulaMode;
+ if ( bDisable )
+ nCntrl &= ~EE_CNTRL_AUTOCORRECT;
+ else
+ nCntrl |= EE_CNTRL_AUTOCORRECT;
+
+ if ( nCntrl != nOld )
+ pEngine->SetControlWord(nCntrl);
+}
+
+void ScInputHandler::UpdateSpellSettings( BOOL bFromStartTab )
+{
+ if ( pActiveViewSh )
+ {
+ ScViewData* pViewData = pActiveViewSh->GetViewData();
+ BOOL bOnlineSpell = pViewData->GetDocument()->GetDocOptions().IsAutoSpell();
+
+ // SetDefaultLanguage is independent of the language attributes,
+ // ScGlobal::GetEditDefaultLanguage is always used.
+ // It must be set every time in case the office language was changed.
+
+ pEngine->SetDefaultLanguage( ScGlobal::GetEditDefaultLanguage() );
+
+ // if called for changed options, update flags only if already editing
+ // if called from StartTable, always update flags
+
+ if ( bFromStartTab || eMode != SC_INPUT_NONE )
+ {
+ ULONG nCntrl = pEngine->GetControlWord();
+ ULONG nOld = nCntrl;
+ if( bOnlineSpell )
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ // kein AutoCorrect auf Symbol-Font (EditEngine wertet Default nicht aus)
+ if ( pLastPattern && pLastPattern->IsSymbolFont() )
+ nCntrl &= ~EE_CNTRL_AUTOCORRECT;
+ else
+ nCntrl |= EE_CNTRL_AUTOCORRECT;
+ if ( nCntrl != nOld )
+ pEngine->SetControlWord(nCntrl);
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ pEngine->SetForbiddenCharsTable( pDoc->GetForbiddenCharacters() );
+ pEngine->SetAsianCompressionMode( pDoc->GetAsianCompression() );
+ pEngine->SetKernAsianPunctuation( pDoc->GetAsianKerning() );
+ pEngine->SetDefaultHorizontalTextDirection(
+ (EEHorizontalTextDirection)pDoc->GetEditTextDirection( pViewData->GetTabNo() ) );
+ pEngine->SetFirstWordCapitalization( FALSE );
+ }
+
+ // language is set separately, so the speller is needed only if online
+ // spelling is active
+
+ if ( bOnlineSpell ) {
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
+ pEngine->SetSpeller( xXSpellChecker1 );
+ }
+
+ BOOL bHyphen = pLastPattern && ((const SfxBoolItem&)pLastPattern->GetItem(ATTR_HYPHENATE)).GetValue();
+ if ( bHyphen ) {
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() );
+ pEngine->SetHyphenator( xXHyphenator );
+ }
+ }
+}
+
+//
+// Funktionen/Bereichsnamen etc. als Tip-Hilfe
+//
+
+#define SC_STRTYPE_FUNCTIONS 1
+// die anderen Typen sind in ScDocument::GetFormulaEntries festgelegt
+
+void ScInputHandler::GetFormulaData()
+{
+ if ( pActiveViewSh )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+
+ if ( pFormulaData )
+ pFormulaData->FreeAll();
+ else
+ pFormulaData = new TypedScStrCollection;
+
+ if( pFormulaDataPara )
+ pFormulaDataPara->FreeAll();
+ else
+ pFormulaDataPara = new TypedScStrCollection;
+
+ // MRU-Funktionen aus dem Funktions-Autopiloten
+ // wie in ScPosWnd::FillFunctions (inputwin.cxx)
+
+ const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
+ USHORT nMRUCount = rOpt.GetLRUFuncListCount();
+ const USHORT* pMRUList = rOpt.GetLRUFuncList();
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ ULONG nListCount = pFuncList->GetCount();
+ if (pMRUList)
+ {
+ for (USHORT i=0; i<nMRUCount; i++)
+ {
+ USHORT nId = pMRUList[i];
+ for (ULONG j=0; j<nListCount; j++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction( j );
+ if ( pDesc->nFIndex == nId && pDesc->pFuncName )
+ {
+ String aEntry = *pDesc->pFuncName;
+ aEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+ TypedStrData* pData = new TypedStrData( aEntry, 0.0, SC_STRTYPE_FUNCTIONS );
+ if (!pFormulaData->Insert(pData))
+ delete pData;
+ break; // nicht weitersuchen
+ }
+ }
+ }
+ }
+ for(ULONG i=0;i<nListCount;i++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction( i );
+ if ( pDesc->pFuncName )
+ {
+ pDesc->initArgumentInfo();
+ String aEntry = pDesc->GetSignature();
+ TypedStrData* pData = new TypedStrData( aEntry, 0.0, SC_STRTYPE_FUNCTIONS );
+ if (!pFormulaDataPara->Insert(pData))
+ delete pData;
+ }
+ }
+ pDoc->GetFormulaEntries( *pFormulaData );
+ pDoc->GetFormulaEntries( *pFormulaDataPara );
+ }
+}
+
+IMPL_LINK( ScInputHandler, ShowHideTipVisibleParentListener, VclWindowEvent*, pEvent )
+{
+ if( pEvent->GetId() == VCLEVENT_OBJECT_DYING || pEvent->GetId() == VCLEVENT_WINDOW_HIDE )
+ HideTip();
+ return 0;
+}
+
+IMPL_LINK( ScInputHandler, ShowHideTipVisibleSecParentListener, VclWindowEvent*, pEvent )
+{
+ if( pEvent->GetId() == VCLEVENT_OBJECT_DYING || pEvent->GetId() == VCLEVENT_WINDOW_HIDE )
+ HideTipBelow();
+ return 0;
+}
+
+void ScInputHandler::HideTip()
+{
+ if ( nTipVisible )
+ {
+ if (pTipVisibleParent)
+ pTipVisibleParent->RemoveEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) );
+ Help::HideTip( nTipVisible );
+ nTipVisible = 0;
+ pTipVisibleParent = NULL;
+ }
+ aManualTip.Erase();
+}
+void ScInputHandler::HideTipBelow()
+{
+ if ( nTipVisibleSec )
+ {
+ if (pTipVisibleSecParent)
+ pTipVisibleSecParent->RemoveEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) );
+ Help::HideTip( nTipVisibleSec );
+ nTipVisibleSec = 0;
+ pTipVisibleSecParent = NULL;
+ }
+ aManualTip.Erase();
+}
+
+void ScInputHandler::ShowTipCursor()
+{
+ HideTip();
+ HideTipBelow();
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ const sal_Unicode cSheetSep = lcl_getSheetSeparator(pDocSh->GetDocument());
+
+ if ( bFormulaMode && pActiveView && pFormulaDataPara && pEngine->GetParagraphCount() == 1 )
+ {
+ String aFormula = pEngine->GetText( (USHORT) 0 );
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+ xub_StrLen nLeftParentPos = 0;
+ if( aSel.nEndPos )
+ {
+ if ( aFormula.Len() < aSel.nEndPos )
+ return;
+ xub_StrLen nPos = aSel.nEndPos;
+ String aSelText = aFormula.Copy( 0, nPos );
+ xub_StrLen nNextFStart = 0;
+ xub_StrLen nNextFEnd = 0;
+ xub_StrLen nArgPos = 0;
+ const IFunctionDescription* ppFDesc;
+ ::std::vector< ::rtl::OUString> aArgs;
+ USHORT nArgs;
+ BOOL bFound = FALSE;
+ FormulaHelper aHelper(ScGlobal::GetStarCalcFunctionMgr());
+
+ while( !bFound )
+ {
+ aSelText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
+ nLeftParentPos = lcl_MatchParenthesis( aSelText, aSelText.Len()-1 );
+ if( nLeftParentPos != STRING_NOTFOUND )
+ {
+ sal_Unicode c = ( nLeftParentPos > 0 ) ? aSelText.GetChar( nLeftParentPos-1 ) : 0;
+ if( !((c >= 'A' && c<= 'Z') || (c>= 'a' && c<= 'z' )) )
+ continue;
+ nNextFStart = aHelper.GetFunctionStart( aSelText, nLeftParentPos, TRUE);
+ if( aHelper.GetNextFunc( aSelText, FALSE, nNextFStart, &nNextFEnd, &ppFDesc, &aArgs ) )
+ {
+ if( ppFDesc->getFunctionName().getLength() )
+ {
+ nArgPos = aHelper.GetArgStart( aSelText, nNextFStart, 0 );
+ nArgs = static_cast<USHORT>(ppFDesc->getParameterCount());
+
+ USHORT nActive = 0;
+ USHORT nCount = 0;
+ USHORT nCountSemicolon = 0;
+ USHORT nCountDot = 0;
+ USHORT nStartPosition = 0;
+ USHORT nEndPosition = 0;
+ BOOL bFlag = FALSE;
+ String aNew;
+ USHORT nParAutoPos = SCPOS_INVALID;
+ if( pFormulaDataPara->FindText( ppFDesc->getFunctionName(), aNew, nParAutoPos, FALSE ) )
+ {
+ for( USHORT i=0; i < nArgs; i++ )
+ {
+ xub_StrLen nLength = static_cast<xub_StrLen>(aArgs[i].getLength());
+ if( nArgPos <= aSelText.Len()-1 )
+ {
+ nActive = i+1;
+ bFlag = TRUE;
+ }
+ nArgPos+=nLength+1;
+ }
+ if( bFlag )
+ {
+ nCountSemicolon = aNew.GetTokenCount(cSep)-1;
+ nCountDot = aNew.GetTokenCount(cSheetSep)-1;
+
+ if( !nCountSemicolon )
+ {
+ for( USHORT i = 0; i < aNew.Len(); i++ )
+ {
+ sal_Unicode cNext = aNew.GetChar( i );
+ if( cNext == '(' )
+ {
+ nStartPosition = i+1;
+ }
+ }
+ }
+ else if( !nCountDot )
+ {
+ for( USHORT i = 0; i < aNew.Len(); i++ )
+ {
+ sal_Unicode cNext = aNew.GetChar( i );
+ if( cNext == '(' )
+ {
+ nStartPosition = i+1;
+ }
+ else if( cNext == cSep )
+ {
+ nCount ++;
+ nEndPosition = i;
+ if( nCount == nActive )
+ {
+ break;
+ }
+ nStartPosition = nEndPosition+1;
+ }
+ }
+ }
+ else
+ {
+ for( USHORT i = 0; i < aNew.Len(); i++ )
+ {
+ sal_Unicode cNext = aNew.GetChar( i );
+ if( cNext == '(' )
+ {
+ nStartPosition = i+1;
+ }
+ else if( cNext == cSep )
+ {
+ nCount ++;
+ nEndPosition = i;
+ if( nCount == nActive )
+ {
+ break;
+ }
+ nStartPosition = nEndPosition+1;
+ }
+ else if( cNext == cSheetSep )
+ {
+ continue;
+ }
+ }
+ }
+
+ if( nStartPosition )
+ {
+ aNew.Insert( 0x25BA, nStartPosition );
+ ShowTipBelow( aNew );
+ bFound = TRUE;
+ }
+ }
+ else
+ {
+ ShowTipBelow( aNew );
+ bFound = TRUE;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ USHORT nPosition = 0;
+ String aText = pEngine->GetWord( 0, aSel.nEndPos-1 );
+ if( aText.GetChar( aSel.nEndPos-1 ) == '=' )
+ {
+ break;
+ }
+ String aNew;
+ USHORT nParAutoPos = SCPOS_INVALID;
+ nPosition = aText.Len()+1;
+ if( pFormulaDataPara->FindText( aText, aNew, nParAutoPos, FALSE ) )
+ {
+ if( aFormula.GetChar( nPosition ) =='(' )
+ {
+ ShowTipBelow( aNew );
+ bFound = TRUE;
+ }
+ else
+ break;
+ }
+ else
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+void ScInputHandler::ShowTip( const String& rText )
+{
+ // aManualTip muss hinterher von aussen gesetzt werden
+ HideTip();
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (pActiveView)
+ {
+ Point aPos;
+ pTipVisibleParent = pActiveView->GetWindow();
+ Cursor* pCur = pActiveView->GetCursor();
+ if (pCur)
+ aPos = pTipVisibleParent->LogicToPixel( pCur->GetPos() );
+ aPos = pTipVisibleParent->OutputToScreenPixel( aPos );
+ Rectangle aRect( aPos, aPos );
+
+ USHORT nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
+ nTipVisible = Help::ShowTip(pTipVisibleParent, aRect, rText, nAlign);
+ pTipVisibleParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleParentListener ) );
+ }
+}
+
+void ScInputHandler::ShowTipBelow( const String& rText )
+{
+ HideTipBelow();
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if ( pActiveView )
+ {
+ Point aPos;
+ pTipVisibleSecParent = pActiveView->GetWindow();
+ Cursor* pCur = pActiveView->GetCursor();
+ if ( pCur )
+ {
+ Point aLogicPos = pCur->GetPos();
+ aLogicPos.Y() += pCur->GetHeight();
+ aPos = pTipVisibleSecParent->LogicToPixel( aLogicPos );
+ }
+ aPos = pTipVisibleSecParent->OutputToScreenPixel( aPos );
+ Rectangle aRect( aPos, aPos );
+ USHORT nAlign = QUICKHELP_LEFT | QUICKHELP_TOP | QUICKHELP_NOEVADEPOINTER;
+ nTipVisibleSec = Help::ShowTip(pTipVisibleSecParent, aRect, rText, nAlign);
+ pTipVisibleSecParent->AddEventListener( LINK( this, ScInputHandler, ShowHideTipVisibleSecParentListener ) );
+ }
+}
+
+void ScInputHandler::UseFormulaData()
+{
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ const sal_Unicode cSheetSep = lcl_getSheetSeparator(pDocSh->GetDocument());
+
+ // Formeln duerfen nur 1 Absatz haben
+ if ( pActiveView && pFormulaData && pEngine->GetParagraphCount() == 1 )
+ {
+ String aTotal = pEngine->GetText( (USHORT) 0 );
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+
+ // #59348# Durch Differenzen zwischen Tabelle und Eingabezeile
+ // (z.B. Clipboard mit Zeilenumbruechen) kann es sein, dass die Selektion
+ // nicht mehr zur EditEngine passt. Dann halt kommentarlos abbrechen:
+
+ if ( aSel.nEndPos > aTotal.Len() )
+ return;
+
+ // steht der Cursor am Ende eines Wortes?
+
+ if ( aSel.nEndPos > 0 )
+ {
+ xub_StrLen nPos = aSel.nEndPos;
+ String aFormula = aTotal.Copy( 0, nPos );;
+ xub_StrLen nLeftParentPos = 0;
+ xub_StrLen nNextFStart = 0;
+ xub_StrLen nNextFEnd = 0;
+ xub_StrLen nArgPos = 0;
+ const IFunctionDescription* ppFDesc;
+ ::std::vector< ::rtl::OUString> aArgs;
+ USHORT nArgs;
+ BOOL bFound = FALSE;
+
+ String aText = pEngine->GetWord( 0, aSel.nEndPos-1 );
+ if ( aText.Len() )
+ {
+ String aNew;
+ nAutoPos = SCPOS_INVALID;
+ if ( pFormulaData->FindText( aText, aNew, nAutoPos, FALSE ) )
+ {
+ ShowTip( aNew );
+ aAutoSearch = aText;
+ }
+ }
+ FormulaHelper aHelper(ScGlobal::GetStarCalcFunctionMgr());
+
+ while( !bFound )
+ {
+ aFormula.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) );
+ nLeftParentPos = lcl_MatchParenthesis( aFormula, aFormula.Len()-1 );
+ if( nLeftParentPos == STRING_NOTFOUND )
+ break;
+
+ // #160063# nLeftParentPos can be 0 if a parenthesis is inserted before the formula
+ sal_Unicode c = ( nLeftParentPos > 0 ) ? aFormula.GetChar( nLeftParentPos-1 ) : 0;
+ if( !((c >= 'A' && c<= 'Z') || (c>= 'a' && c<= 'z') ) )
+ continue;
+ nNextFStart = aHelper.GetFunctionStart( aFormula, nLeftParentPos, TRUE);
+ if( aHelper.GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd, &ppFDesc, &aArgs ) )
+ {
+ if( ppFDesc->getFunctionName().getLength() )
+ {
+ nArgPos = aHelper.GetArgStart( aFormula, nNextFStart, 0 );
+ nArgs = static_cast<USHORT>(ppFDesc->getParameterCount());
+
+ USHORT nActive = 0;
+ USHORT nCount = 0;
+ USHORT nCountSemicolon = 0;
+ USHORT nCountDot = 0;
+ USHORT nStartPosition = 0;
+ USHORT nEndPosition = 0;
+ BOOL bFlag = FALSE;
+ String aNew;
+ USHORT nParAutoPos = SCPOS_INVALID;
+ if( pFormulaDataPara->FindText( ppFDesc->getFunctionName(), aNew, nParAutoPos, FALSE ) )
+ {
+ for( USHORT i=0; i < nArgs; i++ )
+ {
+ xub_StrLen nLength = static_cast<xub_StrLen>(aArgs[i].getLength());
+ if( nArgPos <= aFormula.Len()-1 )
+ {
+ nActive = i+1;
+ bFlag = TRUE;
+ }
+ nArgPos+=nLength+1;
+ }
+ if( bFlag )
+ {
+ nCountSemicolon = aNew.GetTokenCount(cSep)-1;
+ nCountDot = aNew.GetTokenCount(cSheetSep)-1;
+
+ if( !nCountSemicolon )
+ {
+ for( USHORT i = 0; i < aNew.Len(); i++ )
+ {
+ sal_Unicode cNext = aNew.GetChar( i );
+ if( cNext == '(' )
+ {
+ nStartPosition = i+1;
+ }
+ }
+ }
+ else if( !nCountDot )
+ {
+ for( USHORT i = 0; i < aNew.Len(); i++ )
+ {
+ sal_Unicode cNext = aNew.GetChar( i );
+ if( cNext == '(' )
+ {
+ nStartPosition = i+1;
+ }
+ else if( cNext == cSep )
+ {
+ nCount ++;
+ nEndPosition = i;
+ if( nCount == nActive )
+ {
+ break;
+ }
+ nStartPosition = nEndPosition+1;
+ }
+ }
+ }
+ else
+ {
+ for( USHORT i = 0; i < aNew.Len(); i++ )
+ {
+ sal_Unicode cNext = aNew.GetChar( i );
+ if( cNext == '(' )
+ {
+ nStartPosition = i+1;
+ }
+ else if( cNext == cSep )
+ {
+ nCount ++;
+ nEndPosition = i;
+ if( nCount == nActive )
+ {
+ break;
+ }
+ nStartPosition = nEndPosition+1;
+ }
+ else if( cNext == cSheetSep )
+ {
+ continue;
+ }
+ }
+ }
+
+ if( nStartPosition )
+ {
+ aNew.Insert( 0x25BA, nStartPosition );
+ ShowTipBelow( aNew );
+ bFound = TRUE;
+ }
+ }
+ else
+ {
+ ShowTipBelow( aNew );
+ bFound = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void ScInputHandler::NextFormulaEntry( BOOL bBack )
+{
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if ( pActiveView && pFormulaData )
+ {
+ String aNew;
+ if ( pFormulaData->FindText( aAutoSearch, aNew, nAutoPos, bBack ) )
+ ShowTip( aNew ); // als QuickHelp anzeigen
+ }
+
+ // bei Tab wird vorher immer HideCursor gerufen
+
+ if (pActiveView)
+ pActiveView->ShowCursor();
+}
+
+void lcl_CompleteFunction( EditView* pView, const String& rInsert, BOOL& rParInserted )
+{
+ if (pView)
+ {
+ ESelection aSel = pView->GetSelection();
+ --aSel.nStartPos;
+ --aSel.nEndPos;
+ pView->SetSelection(aSel);
+ pView->SelectCurrentWord();
+
+ String aInsStr = rInsert;
+ xub_StrLen nInsLen = aInsStr.Len();
+ BOOL bDoParen = ( nInsLen > 1 && aInsStr.GetChar(nInsLen-2) == '('
+ && aInsStr.GetChar(nInsLen-1) == ')' );
+ if ( bDoParen )
+ {
+ // Klammern hinter Funktionsnamen nicht einfuegen, wenn direkt dahinter
+ // schon eine Klammer steht (z.B. wenn der Funktionsname geaendert wurde,
+ // #39393#).
+
+ ESelection aWordSel = pView->GetSelection();
+ String aOld = pView->GetEditEngine()->GetText((USHORT)0);
+ sal_Unicode cNext = aOld.GetChar(aWordSel.nEndPos);
+ if ( cNext == '(' )
+ {
+ bDoParen = FALSE;
+ aInsStr.Erase( nInsLen - 2 ); // Klammern weglassen
+ }
+ }
+
+ pView->InsertText( aInsStr, FALSE );
+
+ if ( bDoParen ) // Cursor zwischen die Klammern setzen
+ {
+ aSel = pView->GetSelection();
+ --aSel.nStartPos;
+ --aSel.nEndPos;
+ pView->SetSelection(aSel);
+
+ rParInserted = TRUE;
+ }
+ }
+}
+
+void ScInputHandler::PasteFunctionData()
+{
+ if ( pFormulaData && nAutoPos != SCPOS_INVALID )
+ {
+ TypedStrData* pData = (*pFormulaData)[nAutoPos];
+ if (pData)
+ {
+ String aInsert = pData->GetString();
+ BOOL bParInserted = FALSE;
+
+ DataChanging(); // kann nicht neu sein
+ lcl_CompleteFunction( pTopView, aInsert, bParInserted );
+ lcl_CompleteFunction( pTableView, aInsert, bParInserted );
+ DataChanged();
+ ShowTipCursor();
+
+ if (bParInserted)
+ AutoParAdded();
+ }
+ }
+
+ HideTip();
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (pActiveView)
+ pActiveView->ShowCursor();
+}
+
+//
+// Selektion berechnen und als Tip-Hilfe anzeigen
+//
+
+String lcl_Calculate( const String& rFormula, ScDocument* pDoc, const ScAddress &rPos )
+{
+ //! mit ScFormulaDlg::CalcValue zusammenfassen und ans Dokument verschieben !!!!
+ //! (Anfuehrungszeichen bei Strings werden nur hier eingefuegt)
+
+ String aValue;
+
+ if (rFormula.Len())
+ {
+ ScFormulaCell* pCell = new ScFormulaCell( pDoc, rPos, rFormula );
+
+ // #35521# HACK! um bei ColRowNames kein #REF! zu bekommen,
+ // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
+ // eingefuegt wird, bei der Einzeldarstellung aber als
+ // single-Zellbezug interpretiert wird
+ BOOL bColRowName = pCell->HasColRowName();
+ if ( bColRowName )
+ {
+ // ColRowName im RPN-Code?
+ if ( pCell->GetCode()->GetCodeLen() <= 1 )
+ { // ==1: einzelner ist als Parameter immer Bereich
+ // ==0: es waere vielleicht einer, wenn..
+ String aBraced( '(' );
+ aBraced += rFormula;
+ aBraced += ')';
+ delete pCell;
+ pCell = new ScFormulaCell( pDoc, rPos, aBraced );
+ }
+ else
+ bColRowName = FALSE;
+ }
+
+ USHORT nErrCode = pCell->GetErrCode();
+ if ( nErrCode == 0 )
+ {
+ SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
+ Color* pColor;
+ if ( pCell->IsValue() )
+ {
+ double n = pCell->GetValue();
+ ULONG nFormat = aFormatter.GetStandardFormat( n, 0,
+ pCell->GetFormatType(), ScGlobal::eLnge );
+ aFormatter.GetInputLineString( n, nFormat, aValue );
+ //! display OutputString but insert InputLineString
+ }
+ else
+ {
+ String aStr;
+
+ pCell->GetString( aStr );
+ ULONG nFormat = aFormatter.GetStandardFormat(
+ pCell->GetFormatType(), ScGlobal::eLnge);
+ aFormatter.GetOutputString( aStr, nFormat,
+ aValue, &pColor );
+
+ aValue.Insert('"',0); // in Anfuehrungszeichen
+ aValue+='"';
+ //! Anfuehrungszeichen im String escapen ????
+ }
+
+ ScRange aTestRange;
+ if ( bColRowName || (aTestRange.Parse(rFormula) & SCA_VALID) )
+ aValue.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." )); // Bereich
+ }
+ else
+ aValue = ScGlobal::GetErrorString(nErrCode);
+ delete pCell;
+ }
+
+ return aValue;
+}
+
+void ScInputHandler::FormulaPreview()
+{
+ String aValue;
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if ( pActiveView && pActiveViewSh )
+ {
+ String aPart = pActiveView->GetSelected();
+ if (!aPart.Len())
+ aPart = pEngine->GetText((USHORT)0);
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+ aValue = lcl_Calculate( aPart, pDoc, aCursorPos );
+ }
+
+ if (aValue.Len())
+ {
+ ShowTip( aValue ); // als QuickHelp anzeigen
+ aManualTip = aValue; // nach ShowTip setzen
+ nAutoPos = SCPOS_INVALID; // Formel-Autocomplete aufheben
+ }
+}
+
+void ScInputHandler::PasteManualTip()
+{
+ // drei Punkte am Ende -> Bereichsreferenz -> nicht einfuegen
+ // (wenn wir mal Matrix-Konstanten haben, kann das geaendert werden)
+
+ xub_StrLen nTipLen = aManualTip.Len();
+ if ( nTipLen && ( nTipLen < 3 || !aManualTip.Copy( nTipLen-3 ).EqualsAscii("...") ) )
+ {
+ DataChanging(); // kann nicht neu sein
+
+ String aInsert = aManualTip;
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (!pActiveView->HasSelection())
+ {
+ // nichts selektiert -> alles selektieren
+ xub_StrLen nOldLen = pEngine->GetTextLen(0);
+ ESelection aAllSel( 0, 0, 0, nOldLen );
+ if ( pTopView )
+ pTopView->SetSelection( aAllSel );
+ if ( pTableView )
+ pTableView->SetSelection( aAllSel );
+ }
+
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+ DBG_ASSERT( !aSel.nStartPara && !aSel.nEndPara, "Zuviele Absaetze in Formel" );
+ if ( !aSel.nStartPos ) // Selektion ab Anfang?
+ {
+ if ( aSel.nEndPos == pEngine->GetTextLen(0) )
+ {
+ // alles selektiert -> Anfuehrungszeichen weglassen
+ if ( aInsert.GetChar(0) == '"' )
+ aInsert.Erase(0,1);
+ xub_StrLen nInsLen = aInsert.Len();
+ if ( nInsLen && aInsert.GetChar(nInsLen-1) == '"' )
+ aInsert.Erase( nInsLen-1 );
+ }
+ else if ( aSel.nEndPos )
+ {
+ // nicht alles selektiert -> Gleichheitszeichen nicht ueberschreiben
+ //! doppelte Gleichheitszeichen auch ???
+
+ aSel.nStartPos = 1;
+ if ( pTopView )
+ pTopView->SetSelection( aSel );
+ if ( pTableView )
+ pTableView->SetSelection( aSel );
+ }
+ }
+ if ( pTopView )
+ pTopView->InsertText( aInsert, TRUE );
+ if ( pTableView )
+ pTableView->InsertText( aInsert, TRUE );
+
+ DataChanged();
+ }
+
+ HideTip();
+}
+
+void ScInputHandler::ResetAutoPar()
+{
+ nAutoPar = 0;
+}
+
+void ScInputHandler::AutoParAdded()
+{
+ ++nAutoPar; // closing parenthesis can be overwritten
+}
+
+BOOL ScInputHandler::CursorAtClosingPar()
+{
+ // test if the cursor is before a closing parenthesis
+
+ // selection from SetReference has been removed before
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if ( pActiveView && !pActiveView->HasSelection() && bFormulaMode )
+ {
+ ESelection aSel = pActiveView->GetSelection();
+ xub_StrLen nPos = aSel.nStartPos;
+ String aFormula = pEngine->GetText((USHORT)0);
+ if ( nPos < aFormula.Len() && aFormula.GetChar(nPos) == ')' )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void ScInputHandler::SkipClosingPar()
+{
+ // this is called when a ')' is typed and the cursor is before a ')'
+ // that can be overwritten -> just set the cursor behind the ')'
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (pActiveView)
+ {
+ ESelection aSel = pActiveView->GetSelection();
+ ++aSel.nStartPos;
+ ++aSel.nEndPos;
+
+ // this is in a formula (only one paragraph), so the selection
+ // can be used directly for the TopView
+
+ if ( pTopView )
+ pTopView->SetSelection( aSel );
+ if ( pTableView )
+ pTableView->SetSelection( aSel );
+ }
+
+ DBG_ASSERT(nAutoPar, "SkipClosingPar: count is wrong");
+ --nAutoPar;
+}
+
+//
+// Auto-Eingabe
+//
+
+void ScInputHandler::GetColData()
+{
+ if ( pActiveViewSh )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+
+ if ( pColumnData )
+ pColumnData->FreeAll();
+ else
+ {
+ pColumnData = new TypedScStrCollection;
+ pColumnData->SetCaseSensitive( TRUE ); // equal strings are handled in FindText
+ }
+
+ pDoc->GetDataEntries( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(),
+ *pColumnData, TRUE );
+ }
+}
+
+void ScInputHandler::UseColData() // beim Tippen
+{
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if ( pActiveView && pColumnData )
+ {
+ // nur anpassen, wenn Cursor am Ende steht
+
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+
+ USHORT nParCnt = pEngine->GetParagraphCount();
+ if ( aSel.nEndPara+1 == nParCnt )
+ {
+ xub_StrLen nParLen = pEngine->GetTextLen( aSel.nEndPara );
+ if ( aSel.nEndPos == nParLen )
+ {
+ String aText = GetEditText(pEngine);
+ if (aText.Len())
+ {
+ String aNew;
+ nAutoPos = SCPOS_INVALID; // nix
+ if ( pColumnData->FindText( aText, aNew, nAutoPos, FALSE ) )
+ {
+ // #45434# durch dBase Import etc. koennen Umbrueche im String sein,
+ // das wuerde hier mehrere Absaetze ergeben -> nicht gut
+ //! GetExactMatch funktioniert dann auch nicht
+ lcl_RemoveLineEnd( aNew );
+
+ // Absaetze beibehalten, nur den Rest anfuegen
+ //! genaue Ersetzung im EnterHandler !!!
+
+ // ein Space zwischen Absaetzen:
+ ULONG nEdLen = pEngine->GetTextLen() + nParCnt - 1;
+ String aIns = aNew.Copy( (xub_StrLen)nEdLen );
+
+ // selection must be "backwards", so the cursor stays behind the last
+ // typed character
+ ESelection aSelection( aSel.nEndPara, aSel.nEndPos + aIns.Len(),
+ aSel.nEndPara, aSel.nEndPos );
+
+ // when editing in input line, apply to both edit views
+ if ( pTableView )
+ {
+ pTableView->InsertText( aIns, FALSE );
+ pTableView->SetSelection( aSelection );
+ }
+ if ( pTopView )
+ {
+ pTopView->InsertText( aIns, FALSE );
+ pTopView->SetSelection( aSelection );
+ }
+
+ aAutoSearch = aText; // zum Weitersuchen - nAutoPos ist gesetzt
+
+ if ( aText.Len() == aNew.Len() )
+ {
+ // Wenn der eingegebene Text gefunden wurde, TAB nur dann
+ // verschlucken, wenn noch etwas kommt
+
+ String aDummy;
+ USHORT nNextPos = nAutoPos;
+ bUseTab = pColumnData->FindText( aText, aDummy, nNextPos, FALSE );
+ }
+ else
+ bUseTab = TRUE;
+ }
+ }
+ }
+ }
+ }
+}
+
+void ScInputHandler::NextAutoEntry( BOOL bBack )
+{
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if ( pActiveView && pColumnData )
+ {
+ if ( nAutoPos != SCPOS_INVALID && aAutoSearch.Len() )
+ {
+ // stimmt die Selektion noch? (kann per Maus geaendert sein)
+
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+ USHORT nParCnt = pEngine->GetParagraphCount();
+ if ( aSel.nEndPara+1 == nParCnt && aSel.nStartPara == aSel.nEndPara )
+ {
+ String aText = GetEditText(pEngine);
+ xub_StrLen nSelLen = aSel.nEndPos - aSel.nStartPos;
+ xub_StrLen nParLen = pEngine->GetTextLen( aSel.nEndPara );
+ if ( aSel.nEndPos == nParLen && aText.Len() == aAutoSearch.Len() + nSelLen )
+ {
+ String aNew;
+ if ( pColumnData->FindText( aAutoSearch, aNew, nAutoPos, bBack ) )
+ {
+ bInOwnChange = TRUE; // disable ModifyHdl (reset below)
+
+ lcl_RemoveLineEnd( aNew );
+ String aIns = aNew.Copy( aAutoSearch.Len() );
+
+ // when editing in input line, apply to both edit views
+ if ( pTableView )
+ {
+ pTableView->DeleteSelected();
+ pTableView->InsertText( aIns, FALSE );
+ pTableView->SetSelection( ESelection(
+ aSel.nEndPara, aSel.nStartPos + aIns.Len(),
+ aSel.nEndPara, aSel.nStartPos ) );
+ }
+ if ( pTopView )
+ {
+ pTopView->DeleteSelected();
+ pTopView->InsertText( aIns, FALSE );
+ pTopView->SetSelection( ESelection(
+ aSel.nEndPara, aSel.nStartPos + aIns.Len(),
+ aSel.nEndPara, aSel.nStartPos ) );
+ }
+
+ bInOwnChange = FALSE;
+ }
+ else
+ {
+ // mehr gibts nicht
+
+ Sound::Beep();
+ }
+ }
+ }
+ }
+ }
+
+ // bei Tab wird vorher immer HideCursor gerufen
+
+ if (pActiveView)
+ pActiveView->ShowCursor();
+}
+
+//
+// Klammern hervorheben
+//
+
+void ScInputHandler::UpdateParenthesis()
+{
+ // Klammern suchen
+
+ //! Klammer-Hervorhebung einzeln abschaltbar ????
+
+ BOOL bFound = FALSE;
+ if ( bFormulaMode && eMode != SC_INPUT_TOP )
+ {
+ if ( pTableView && !pTableView->HasSelection() ) // Selektion ist immer unten
+ {
+ ESelection aSel = pTableView->GetSelection();
+ if (aSel.nStartPos)
+ {
+ // Das Zeichen links vom Cursor wird angeschaut
+
+ xub_StrLen nPos = aSel.nStartPos - 1;
+ String aFormula = pEngine->GetText((USHORT)0);
+ sal_Unicode c = aFormula.GetChar(nPos);
+ if ( c == '(' || c == ')' )
+ {
+ xub_StrLen nOther = lcl_MatchParenthesis( aFormula, nPos );
+ if ( nOther != STRING_NOTFOUND )
+ {
+ SfxItemSet aSet( pEngine->GetEmptyItemSet() );
+ aSet.Put( SvxWeightItem( WEIGHT_BOLD, EE_CHAR_WEIGHT ) );
+ //! Unterscheidung, wenn die Zelle schon fett ist !!!!
+
+ if (bParenthesisShown)
+ {
+ // alte Hervorhebung wegnehmen
+ USHORT nCount = pEngine->GetParagraphCount();
+ for (USHORT i=0; i<nCount; i++)
+ pEngine->QuickRemoveCharAttribs( i, EE_CHAR_WEIGHT );
+ }
+
+ ESelection aSelThis( 0,nPos, 0,nPos+1 );
+ pEngine->QuickSetAttribs( aSet, aSelThis );
+ ESelection aSelOther( 0,nOther, 0,nOther+1 );
+ pEngine->QuickSetAttribs( aSet, aSelOther );
+
+ // Dummy-InsertText fuer Update und Paint (Selektion ist leer)
+ pTableView->InsertText( EMPTY_STRING, FALSE );
+
+ bFound = TRUE;
+ }
+ }
+ }
+
+ // mark parenthesis right of cursor if it will be overwritten (nAutoPar)
+ // with different color (COL_LIGHTBLUE) ??
+ }
+ }
+
+ // alte Hervorhebung wegnehmen, wenn keine neue gesetzt
+
+ if ( bParenthesisShown && !bFound && pTableView )
+ {
+ USHORT nCount = pEngine->GetParagraphCount();
+ for (USHORT i=0; i<nCount; i++)
+ pTableView->RemoveCharAttribs( i, EE_CHAR_WEIGHT );
+ }
+
+ bParenthesisShown = bFound;
+}
+
+void ScInputHandler::ViewShellGone(ScTabViewShell* pViewSh) // wird synchron aufgerufen!
+{
+ if ( pViewSh == pActiveViewSh )
+ {
+ delete pLastState;
+ pLastState = NULL;
+ pLastPattern = NULL;
+ }
+
+ if ( pViewSh == pRefViewSh )
+ {
+ //! Die Eingabe kommt aus dem EnterHandler nicht mehr an
+ // Trotzdem wird immerhin der Editmodus beendet
+
+ EnterHandler();
+ bFormulaMode = FALSE;
+ pRefViewSh = NULL;
+ SFX_APP()->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
+ SC_MOD()->SetRefInputHdl(NULL);
+ if (pInputWin)
+ pInputWin->SetFormulaMode(FALSE);
+ UpdateAutoCorrFlag();
+ }
+
+ pActiveViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+
+ if ( pActiveViewSh && pActiveViewSh == pViewSh )
+ {
+ DBG_ERROR("pActiveViewSh weg");
+ pActiveViewSh = NULL;
+ }
+
+ if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
+ UpdateRefDevice(); // don't keep old document's printer as RefDevice
+}
+
+void ScInputHandler::UpdateActiveView()
+{
+ ImplCreateEditEngine();
+
+ // #i20588# Don't rely on focus to find the active edit view. Instead, the
+ // active pane at the start of editing is now stored (GetEditActivePart).
+ // GetActiveWin (the currently active pane) fails for ref input across the
+ // panes of a split view.
+
+ Window* pShellWin = pActiveViewSh ?
+ pActiveViewSh->GetWindowByPos( pActiveViewSh->GetViewData()->GetEditActivePart() ) :
+ NULL;
+
+ USHORT nCount = pEngine->GetViewCount();
+ if (nCount > 0)
+ {
+ pTableView = pEngine->GetView(0);
+ for (USHORT i=1; i<nCount; i++)
+ {
+ EditView* pThis = pEngine->GetView(i);
+ Window* pWin = pThis->GetWindow();
+ if ( pWin==pShellWin )
+ pTableView = pThis;
+ }
+ }
+ else
+ pTableView = NULL;
+
+ if (pInputWin)
+ pTopView = pInputWin->GetEditView();
+ else
+ pTopView = NULL;
+}
+
+void ScInputHandler::StopInputWinEngine( BOOL bAll )
+{
+ if (pInputWin)
+ pInputWin->StopEditEngine( bAll );
+
+ pTopView = NULL; // invalid now
+}
+
+EditView* ScInputHandler::GetActiveView()
+{
+ UpdateActiveView();
+ return pTopView ? pTopView : pTableView;
+}
+
+void ScInputHandler::ForgetLastPattern()
+{
+ pLastPattern = NULL;
+ if ( !pLastState && pActiveViewSh )
+ pActiveViewSh->UpdateInputHandler( TRUE ); // Status neu holen
+ else
+ NotifyChange( pLastState, TRUE );
+}
+
+void ScInputHandler::UpdateAdjust( sal_Unicode cTyped )
+{
+ SvxAdjust eSvxAdjust;
+ switch (eAttrAdjust)
+ {
+ case SVX_HOR_JUSTIFY_STANDARD:
+ {
+ BOOL bNumber = FALSE;
+ if (cTyped) // neu angefangen
+ bNumber = (cTyped>='0' && cTyped<='9'); // nur Ziffern sind Zahlen
+ else if ( pActiveViewSh )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+ bNumber = ( pDoc->GetCellType( aCursorPos ) == CELLTYPE_VALUE );
+ }
+ eSvxAdjust = bNumber ? SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT;
+ }
+ break;
+ case SVX_HOR_JUSTIFY_BLOCK:
+ eSvxAdjust = SVX_ADJUST_BLOCK;
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ eSvxAdjust = SVX_ADJUST_RIGHT;
+ break;
+ default: // SVX_HOR_JUSTIFY_LEFT
+ eSvxAdjust = SVX_ADJUST_LEFT;
+ break;
+ }
+
+ BOOL bAsianVertical = pLastPattern &&
+ ((const SfxBoolItem&)pLastPattern->GetItem( ATTR_STACKED )).GetValue() &&
+ ((const SfxBoolItem&)pLastPattern->GetItem( ATTR_VERTICAL_ASIAN )).GetValue();
+ if ( bAsianVertical )
+ {
+ // always edit at top of cell -> LEFT when editing vertically
+ eSvxAdjust = SVX_ADJUST_LEFT;
+ }
+
+ pEditDefaults->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
+ pEngine->SetDefaults( *pEditDefaults );
+
+ nEditAdjust = sal::static_int_cast<USHORT>(eSvxAdjust); //! set at ViewData or with PostEditView
+
+ pEngine->SetVertical( bAsianVertical );
+}
+
+void ScInputHandler::RemoveAdjust()
+{
+ // harte Ausrichtungs-Attribute loeschen
+
+ BOOL bUndo = pEngine->IsUndoEnabled();
+ if ( bUndo )
+ pEngine->EnableUndo( FALSE );
+
+ // #89403# non-default paragraph attributes (e.g. from clipboard)
+ // must be turned into character attributes
+ pEngine->RemoveParaAttribs();
+
+ if ( bUndo )
+ pEngine->EnableUndo( TRUE );
+
+}
+
+void ScInputHandler::RemoveRangeFinder()
+{
+ // pRangeFindList und Farben loeschen
+
+ pEngine->SetUpdateMode(FALSE);
+ USHORT nCount = pEngine->GetParagraphCount(); // koennte gerade neu eingefuegt worden sein
+ for (USHORT i=0; i<nCount; i++)
+ pEngine->QuickRemoveCharAttribs( i, EE_CHAR_COLOR );
+ pEngine->SetUpdateMode(TRUE);
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ pActiveView->ShowCursor( FALSE, TRUE );
+
+ DeleteRangeFinder(); // loescht die Liste und die Markierungen auf der Tabelle
+}
+
+bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated )
+{
+ bool bNewTable = false;
+
+ if (bModified || !ValidCol(aCursorPos.Col()))
+ return false;
+
+ if (pActiveViewSh)
+ {
+ ImplCreateEditEngine();
+ UpdateActiveView();
+ SyncViews();
+
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocShell()->GetDocument();
+
+ const ScMarkData& rMark = pActiveViewSh->GetViewData()->GetMarkData();
+ ScEditableTester aTester;
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ aTester.TestSelection( pDoc, rMark );
+ else
+ aTester.TestSelectedBlock(
+ pDoc, aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Col(), aCursorPos.Row(), rMark );
+
+ bool bStartInputMode = true;
+
+ if (!aTester.IsEditable())
+ {
+ bProtected = TRUE;
+ // We allow read-only input mode activation when explicit cell
+ // activation is requested (double-click or F2) and if it's not
+ // part of an array.
+ bool bShowError = !bInputActivated || aTester.GetMessageId() != STR_PROTECTIONERR;
+ if (bShowError)
+ {
+ eMode = SC_INPUT_NONE;
+ StopInputWinEngine( TRUE );
+ UpdateFormulaMode();
+ if ( pActiveViewSh && ( !bFromCommand || !bCommandErrorShown ) )
+ {
+ // #97673# Prevent repeated error messages for the same cell from command events
+ // (for keyboard events, multiple messages are wanted).
+ // Set the flag before showing the error message because the command handler
+ // for the next IME command may be called when showing the dialog.
+ if ( bFromCommand )
+ bCommandErrorShown = TRUE;
+
+ pActiveViewSh->GetActiveWin()->GrabFocus();
+ pActiveViewSh->ErrorMessage(aTester.GetMessageId());
+ }
+ bStartInputMode = false;
+ }
+ }
+
+ if (bStartInputMode)
+ {
+ // UpdateMode is enabled again in ScViewData::SetEditEngine (and not needed otherwise)
+ pEngine->SetUpdateMode( FALSE );
+
+ // Attribute in EditEngine uebernehmen
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( aCursorPos.Col(),
+ aCursorPos.Row(),
+ aCursorPos.Tab() );
+ if (pPattern != pLastPattern)
+ {
+ // Prozent-Format?
+
+ const SfxItemSet& rAttrSet = pPattern->GetItemSet();
+ const SfxPoolItem* pItem;
+
+ if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALUE_FORMAT, TRUE, &pItem ) )
+ {
+ ULONG nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ bCellHasPercentFormat = ( NUMBERFORMAT_PERCENT ==
+ pDoc->GetFormatTable()->GetType( nFormat ) );
+ }
+ else
+ bCellHasPercentFormat = FALSE; // Default: kein Prozent
+
+ // Gueltigkeit angegeben?
+
+ if ( SFX_ITEM_SET == rAttrSet.GetItemState( ATTR_VALIDDATA, TRUE, &pItem ) )
+ nValidation = ((const SfxUInt32Item*)pItem)->GetValue();
+ else
+ nValidation = 0;
+
+ // EditEngine Defaults
+
+ // Hier auf keinen Fall SetParaAttribs, weil die EditEngine evtl.
+ // schon gefuellt ist (bei Edit-Zellen).
+ // SetParaAttribs wuerde dann den Inhalt aendern
+
+ //! ER 30.08.00 The SetDefaults is now (since MUST/src602
+ //! EditEngine changes) implemented as a SetParaAttribs.
+ //! Any problems?
+
+ pPattern->FillEditItemSet( pEditDefaults );
+ pEngine->SetDefaults( *pEditDefaults );
+ pLastPattern = pPattern;
+ bLastIsSymbol = pPattern->IsSymbolFont();
+
+ // Background color must be known for automatic font color.
+ // For transparent cell background, the document background color must be used.
+
+ Color aBackCol = ((const SvxBrushItem&)
+ pPattern->GetItem( ATTR_BACKGROUND )).GetColor();
+ ScModule* pScMod = SC_MOD();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ if ( aBackCol.GetTransparency() > 0 ||
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+ pEngine->SetBackgroundColor( aBackCol );
+
+ // Ausrichtung
+
+ eAttrAdjust = (SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
+ GetItem(ATTR_HOR_JUSTIFY)).GetValue();
+ if ( eAttrAdjust == SVX_HOR_JUSTIFY_REPEAT &&
+ static_cast<const SfxBoolItem&>(pPattern->GetItem(ATTR_LINEBREAK)).GetValue() )
+ {
+ // #i31843# "repeat" with "line breaks" is treated as default alignment
+ eAttrAdjust = SVX_HOR_JUSTIFY_STANDARD;
+ }
+ }
+
+ // UpdateSpellSettings enables online spelling if needed
+ // -> also call if attributes are unchanged
+
+ UpdateSpellSettings( TRUE ); // uses pLastPattern
+
+ // Edit-Engine fuellen
+
+ String aStr;
+ if (bTextValid)
+ {
+ pEngine->SetText(aCurrentText);
+ aStr = aCurrentText;
+ bTextValid = FALSE;
+ aCurrentText.Erase();
+ }
+ else
+ aStr = GetEditText(pEngine);
+
+ if (aStr.Len() > 3 && // Matrix-Formel ?
+ aStr.GetChar(0) == '{' &&
+ aStr.GetChar(1) == '=' &&
+ aStr.GetChar(aStr.Len()-1) == '}')
+ {
+ aStr.Erase(0,1);
+ aStr.Erase(aStr.Len()-1,1);
+ pEngine->SetText(aStr);
+ if ( pInputWin )
+ pInputWin->SetTextString(aStr);
+ }
+
+ UpdateAdjust( cTyped );
+
+ if ( bAutoComplete )
+ GetColData();
+
+ if ( ( aStr.GetChar(0) == '=' || aStr.GetChar(0) == '+' || aStr.GetChar(0) == '-' ) &&
+ !cTyped && !bCreatingFuncView )
+ InitRangeFinder(aStr); // Formel wird editiert -> RangeFinder
+
+ bNewTable = true; // -> PostEditView-Aufruf
+ }
+ }
+
+ if (!bProtected && pInputWin)
+ pInputWin->SetOkCancelMode();
+
+ return bNewTable;
+}
+
+void lcl_SetTopSelection( EditView* pEditView, ESelection& rSel )
+{
+ DBG_ASSERT( rSel.nStartPara==0 && rSel.nEndPara==0, "SetTopSelection: Para != 0" );
+
+ EditEngine* pEngine = pEditView->GetEditEngine();
+ USHORT nCount = pEngine->GetParagraphCount();
+ if (nCount > 1)
+ {
+ xub_StrLen nParLen = pEngine->GetTextLen(rSel.nStartPara);
+ while (rSel.nStartPos > nParLen && rSel.nStartPara+1 < nCount)
+ {
+ rSel.nStartPos -= nParLen + 1; // incl. Leerzeichen vom Umbruch
+ nParLen = pEngine->GetTextLen(++rSel.nStartPara);
+ }
+
+ nParLen = pEngine->GetTextLen(rSel.nEndPara);
+ while (rSel.nEndPos > nParLen && rSel.nEndPara+1 < nCount)
+ {
+ rSel.nEndPos -= nParLen + 1; // incl. Leerzeichen vom Umbruch
+ nParLen = pEngine->GetTextLen(++rSel.nEndPara);
+ }
+ }
+
+ ESelection aSel = pEditView->GetSelection();
+
+ if ( rSel.nStartPara != aSel.nStartPara || rSel.nEndPara != aSel.nEndPara
+ || rSel.nStartPos != aSel.nStartPos || rSel.nEndPos != aSel.nEndPos )
+ pEditView->SetSelection( rSel );
+}
+
+void ScInputHandler::SyncViews( EditView* pSourceView )
+{
+ ESelection aSel;
+
+ if (pSourceView)
+ {
+ aSel = pSourceView->GetSelection();
+ if (pTopView && pTopView != pSourceView)
+ pTopView->SetSelection( aSel );
+ if (pTableView && pTableView != pSourceView)
+ lcl_SetTopSelection( pTableView, aSel );
+ }
+ else if (pTopView && pTableView)
+ {
+ aSel = pTopView->GetSelection();
+ lcl_SetTopSelection( pTableView, aSel );
+ }
+}
+
+IMPL_LINK( ScInputHandler, ModifyHdl, void *, EMPTYARG )
+{
+ if ( !bInOwnChange && ( eMode==SC_INPUT_TYPE || eMode==SC_INPUT_TABLE ) &&
+ pEngine && pEngine->GetUpdateMode() && pInputWin )
+ {
+ // #102745# update input line from ModifyHdl for changes that are not
+ // wrapped by DataChanging/DataChanged calls (like Drag&Drop)
+
+ String aText = GetEditText(pEngine);
+ lcl_RemoveTabs(aText);
+ pInputWin->SetTextString(aText);
+ }
+ return 0;
+}
+
+BOOL ScInputHandler::DataChanging( sal_Unicode cTyped, BOOL bFromCommand ) // return TRUE = new view created
+{
+ pActiveViewSh->GetViewData()->SetPasteMode( SC_PASTE_NONE );
+ bInOwnChange = TRUE; // disable ModifyHdl (reset in DataChanged)
+
+ if ( eMode == SC_INPUT_NONE )
+ return StartTable( cTyped, bFromCommand, false );
+ else
+ return FALSE;
+}
+
+void ScInputHandler::DataChanged( BOOL bFromTopNotify )
+{
+ ImplCreateEditEngine();
+
+ if (eMode==SC_INPUT_NONE)
+ eMode = SC_INPUT_TYPE;
+
+ if ( eMode == SC_INPUT_TOP && pTopView && !bFromTopNotify )
+ {
+ // table EditEngine is formatted below, input line needs formatting after paste
+ // #i20282# not when called from the input line's modify handler
+ pTopView->GetEditEngine()->QuickFormatDoc( TRUE );
+
+ // #i23720# QuickFormatDoc hides the cursor, but can't show it again because it
+ // can't safely access the EditEngine's current view, so the cursor has to be
+ // shown again here.
+ pTopView->ShowCursor();
+ }
+
+ bModified = TRUE;
+ bSelIsRef = FALSE;
+
+ if ( pRangeFindList && !bInRangeUpdate )
+ RemoveRangeFinder(); // Attribute und Markierung loeschen
+
+ UpdateParenthesis(); // Hervorhebung der Klammern neu
+
+ // ER 31.08.00 New SetDefaults sets ParaAttribs, don't clear them away ...
+// RemoveAdjust(); // #40255# harte Ausrichtungs-Attribute loeschen
+
+ if (eMode==SC_INPUT_TYPE || eMode==SC_INPUT_TABLE)
+ {
+ String aText = GetEditText(pEngine);
+ lcl_RemoveTabs(aText);
+
+ if ( pInputWin )
+ pInputWin->SetTextString(aText);
+ }
+
+ // wenn der Cursor vor dem Absatzende steht, werden Teile rechts rausgeschoben
+ // (unabhaengig von eMode) -> View anpassen!
+ // wenn der Cursor am Ende steht, reicht der Status-Handler an der ViewData
+
+ // #93767# first make sure the status handler is called now if the cursor
+ // is outside the visible area
+ pEngine->QuickFormatDoc();
+
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (pActiveView && pActiveViewSh)
+ {
+ ScViewData* pViewData = pActiveViewSh->GetViewData();
+
+ BOOL bNeedGrow = ( nEditAdjust != SVX_ADJUST_LEFT ); // rechtsbuendig immer
+ if (!bNeedGrow)
+ {
+ // Cursor vor dem Ende?
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+ bNeedGrow = ( aSel.nEndPos != pEngine->GetTextLen(aSel.nEndPara) );
+ }
+ if (!bNeedGrow)
+ {
+ bNeedGrow = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+ }
+ if (bNeedGrow)
+ {
+ // adjust inplace view
+ pViewData->EditGrowY();
+ pViewData->EditGrowX();
+ }
+ }
+
+ UpdateFormulaMode();
+ bTextValid = FALSE; // Aenderungen sind nur in der Edit-Engine
+ bInOwnChange = FALSE;
+}
+
+void ScInputHandler::UpdateFormulaMode()
+{
+ SfxApplication* pSfxApp = SFX_APP();
+
+ if ( pEngine->GetParagraphCount() == 1 &&
+ ( pEngine->GetText((USHORT)0).GetChar(0) == '=' ||
+ pEngine->GetText((USHORT)0).GetChar(0) == '+' ||
+ pEngine->GetText((USHORT)0).GetChar(0) == '-' ) &&
+ !bProtected )
+ {
+ if (!bFormulaMode)
+ {
+ bFormulaMode = TRUE;
+ pRefViewSh = pActiveViewSh;
+ pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
+ SC_MOD()->SetRefInputHdl(this);
+ if (pInputWin)
+ pInputWin->SetFormulaMode(TRUE);
+
+ if ( bAutoComplete )
+ GetFormulaData();
+
+ UpdateParenthesis();
+ UpdateAutoCorrFlag();
+ }
+ }
+ else // ausschalten
+ {
+ if (bFormulaMode)
+ {
+ ShowRefFrame();
+ bFormulaMode = FALSE;
+ pRefViewSh = NULL;
+ pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
+ SC_MOD()->SetRefInputHdl(NULL);
+ if (pInputWin)
+ pInputWin->SetFormulaMode(FALSE);
+ UpdateAutoCorrFlag();
+ }
+ }
+}
+
+void ScInputHandler::ShowRefFrame()
+{
+ // #123169# Modifying pActiveViewSh here would interfere with the bInEnterHandler / bRepeat
+ // checks in NotifyChange, and lead to keeping the wrong value in pActiveViewSh.
+ // A local variable is used instead.
+ ScTabViewShell* pVisibleSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ if ( pRefViewSh && pRefViewSh != pVisibleSh )
+ {
+ BOOL bFound = FALSE;
+ SfxViewFrame* pRefFrame = pRefViewSh->GetViewFrame();
+ SfxViewFrame* pOneFrame = SfxViewFrame::GetFirst();
+ while ( pOneFrame && !bFound )
+ {
+ if ( pOneFrame == pRefFrame )
+ bFound = TRUE;
+ pOneFrame = SfxViewFrame::GetNext( *pOneFrame );
+ }
+
+ if (bFound)
+ {
+ // Hier wird sich darauf verlassen, dass Activate synchron funktioniert
+ // (dabei wird pActiveViewSh umgesetzt)
+
+ pRefViewSh->SetActive(); // Appear und SetViewFrame
+
+ // pLastState wird im NotifyChange aus dem Activate richtig gesetzt
+ }
+ else
+ {
+ DBG_ERROR("ViewFrame fuer Referenzeingabe ist nicht mehr da");
+ }
+ }
+}
+
+void ScInputHandler::RemoveSelection()
+{
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (!pActiveView)
+ return;
+
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.nStartPara = aSel.nEndPara;
+ aSel.nStartPos = aSel.nEndPos;
+ if (pTableView)
+ pTableView->SetSelection( aSel );
+ if (pTopView)
+ pTopView->SetSelection( aSel );
+}
+
+void ScInputHandler::InvalidateAttribs()
+{
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ {
+ SfxBindings& rBindings = pViewFrm->GetBindings();
+
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
+
+ rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+
+ rBindings.Invalidate( SID_HYPERLINK_GETLINK );
+ }
+}
+
+//
+// --------------- public Methoden --------------------------------------------
+//
+
+void ScInputHandler::SetMode( ScInputMode eNewMode )
+{
+ if ( eMode == eNewMode )
+ return;
+
+ ImplCreateEditEngine();
+
+ if (bProtected)
+ {
+ eMode = SC_INPUT_NONE;
+ StopInputWinEngine( TRUE );
+ if (pActiveViewSh)
+ pActiveViewSh->GetActiveWin()->GrabFocus();
+ return;
+ }
+
+ if (eNewMode != SC_INPUT_NONE)
+ // Disable paste mode when edit mode starts.
+ pActiveViewSh->GetViewData()->SetPasteMode( SC_PASTE_NONE );
+
+ bInOwnChange = TRUE; // disable ModifyHdl (reset below)
+
+ ScInputMode eOldMode = eMode;
+ eMode = eNewMode;
+ if (eOldMode == SC_INPUT_TOP && eNewMode != eOldMode)
+ StopInputWinEngine( FALSE );
+
+ if (eMode==SC_INPUT_TOP || eMode==SC_INPUT_TABLE)
+ {
+ if (eOldMode == SC_INPUT_NONE) // not when switching between modes
+ {
+ if (StartTable(0, false, eMode == SC_INPUT_TABLE))
+ {
+ if (pActiveViewSh)
+ pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
+ }
+ }
+
+ USHORT nPara = pEngine->GetParagraphCount()-1;
+ xub_StrLen nLen = pEngine->GetText(nPara).Len();
+ USHORT nCount = pEngine->GetViewCount();
+
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if ( eMode == SC_INPUT_TABLE && eOldMode == SC_INPUT_TOP )
+ {
+ // Selektion bleibt
+ }
+ else
+ {
+ pEngine->GetView(i)->
+ SetSelection( ESelection( nPara, nLen, nPara, nLen ) );
+ }
+ pEngine->GetView(i)->ShowCursor(FALSE);
+ }
+ }
+
+ UpdateActiveView();
+ if (eMode==SC_INPUT_TABLE || eMode==SC_INPUT_TYPE)
+ {
+ if (pTableView)
+ pTableView->SetEditEngineUpdateMode(TRUE);
+ }
+ else
+ {
+ if (pTopView)
+ pTopView->SetEditEngineUpdateMode(TRUE);
+ }
+
+ if (eNewMode != eOldMode)
+ UpdateFormulaMode();
+
+ bInOwnChange = FALSE;
+}
+
+//----------------------------------------------------------------------------------------
+
+// lcl_IsNumber - TRUE, wenn nur Ziffern (dann keine Autokorrektur)
+
+BOOL lcl_IsNumber(const String& rString)
+{
+ xub_StrLen nLen = rString.Len();
+ for (xub_StrLen i=0; i<nLen; i++)
+ {
+ sal_Unicode c = rString.GetChar(i);
+ if ( c < '0' || c > '9' )
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void lcl_SelectionToEnd( EditView* pView )
+{
+ if ( pView )
+ {
+ EditEngine* pEngine = pView->GetEditEngine();
+ USHORT nParCnt = pEngine->GetParagraphCount();
+ if ( nParCnt == 0 )
+ nParCnt = 1;
+ ESelection aSel( nParCnt-1, pEngine->GetTextLen(nParCnt-1) ); // empty selection, cursor at the end
+ pView->SetSelection( aSel );
+ }
+}
+
+void ScInputHandler::EnterHandler( BYTE nBlockMode )
+{
+ // #62806# Bei Makro-Aufrufen fuer Gueltigkeit kann Tod und Teufel passieren,
+ // darum dafuer sorgen, dass EnterHandler nicht verschachtelt gerufen wird:
+
+ if (bInEnterHandler) return;
+ bInEnterHandler = TRUE;
+ bInOwnChange = TRUE; // disable ModifyHdl (reset below)
+
+ ImplCreateEditEngine();
+
+ BOOL bMatrix = ( nBlockMode == SC_ENTER_MATRIX );
+
+ SfxApplication* pSfxApp = SFX_APP();
+ EditTextObject* pObject = NULL;
+ ScPatternAttr* pCellAttrs = NULL;
+ BOOL bAttrib = FALSE; // Formatierung vorhanden ?
+ BOOL bForget = FALSE; // wegen Gueltigkeit streichen ?
+
+ String aString = GetEditText(pEngine);
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ if (bModified && pActiveView && aString.Len() && !lcl_IsNumber(aString))
+ {
+ if ( pColumnData && nAutoPos != SCPOS_INVALID )
+ {
+ // #i47125# If AutoInput appended something, do the final AutoCorrect
+ // with the cursor at the end of the input.
+
+ lcl_SelectionToEnd(pTopView);
+ lcl_SelectionToEnd(pTableView);
+ }
+
+ Window* pFrameWin = pActiveViewSh ? pActiveViewSh->GetFrameWin() : NULL;
+
+ if (pTopView)
+ pTopView->CompleteAutoCorrect(); // #59759# CompleteAutoCorrect fuer beide Views
+ if (pTableView)
+ pTableView->CompleteAutoCorrect(pFrameWin);
+ aString = GetEditText(pEngine);
+ }
+ lcl_RemoveTabs(aString);
+
+ // Test, ob zulaessig (immer mit einfachem String)
+
+ if ( bModified && nValidation && pActiveViewSh )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocument();
+ const ScValidationData* pData = pDoc->GetValidationEntry( nValidation );
+ if (pData && pData->HasErrMsg())
+ {
+ // #i67990# don't use pLastPattern in EnterHandler
+ const ScPatternAttr* pPattern = pDoc->GetPattern( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() );
+ BOOL bOk = pData->IsDataValid( aString, *pPattern, aCursorPos );
+
+ if (!bOk)
+ {
+ if ( pActiveViewSh ) // falls aus MouseButtonDown gekommen
+ pActiveViewSh->StopMarking(); // (die InfoBox verschluckt das MouseButtonUp)
+
+ //! es gibt noch Probleme, wenn die Eingabe durch Aktivieren einer
+ //! anderen View ausgeloest wurde
+
+ Window* pParent = Application::GetDefDialogParent();
+ if ( pData->DoError( pParent, aString, aCursorPos ) )
+ bForget = TRUE; // Eingabe nicht uebernehmen
+ }
+ }
+ }
+
+ // check for input into DataPilot table
+
+ if ( bModified && pActiveViewSh && !bForget )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() );
+ if ( pDPObj )
+ {
+ // any input within the DataPilot table is either a valid renaming
+ // or an invalid action - normal cell input is always aborted
+
+ pActiveViewSh->DataPilotInput( aCursorPos, aString );
+ bForget = TRUE;
+ }
+ }
+
+ pEngine->CompleteOnlineSpelling();
+ BOOL bSpellErrors = !bFormulaMode && pEngine->HasOnlineSpellErrors();
+ if ( bSpellErrors )
+ {
+ // #i3820# If the spell checker flags numerical input as error,
+ // it still has to be treated as number, not EditEngine object.
+
+ if ( pActiveViewSh )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocument();
+ // #i67990# don't use pLastPattern in EnterHandler
+ const ScPatternAttr* pPattern = pDoc->GetPattern( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab() );
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ // without conditional format, as in ScColumn::SetString
+ sal_uInt32 nFormat = pPattern->GetNumberFormat( pFormatter );
+ double nVal;
+ if ( pFormatter->IsNumberFormat( aString, nFormat, nVal ) )
+ {
+ bSpellErrors = FALSE; // ignore the spelling errors
+ }
+ }
+ }
+
+ // After RemoveAdjust, the EditView must not be repainted (has wrong font size etc).
+ // SetUpdateMode must come after CompleteOnlineSpelling.
+ // The view is hidden in any case below (Broadcast).
+ pEngine->SetUpdateMode( FALSE );
+
+ if ( bModified && !bForget ) // was wird eingeben (Text/Objekt) ?
+ {
+ USHORT nParCnt = pEngine->GetParagraphCount();
+ if ( nParCnt == 0 )
+ nParCnt = 1;
+
+ bool bUniformAttribs = true;
+ SfxItemSet aPara1Attribs = pEngine->GetAttribs(0, 0, pEngine->GetTextLen(0));
+ for (USHORT nPara = 1; nPara < nParCnt; ++nPara)
+ {
+ SfxItemSet aPara2Attribs = pEngine->GetAttribs(nPara, 0, pEngine->GetTextLen(nPara));
+ if (!(aPara1Attribs == aPara2Attribs))
+ {
+ // paragraph format different from that of the 1st paragraph.
+ bUniformAttribs = false;
+ break;
+ }
+ }
+
+ ESelection aSel( 0, 0, nParCnt-1, pEngine->GetTextLen(nParCnt-1) );
+ SfxItemSet aOldAttribs = pEngine->GetAttribs( aSel );
+ const SfxPoolItem* pItem = NULL;
+
+ // find common (cell) attributes before RemoveAdjust
+
+ if ( pActiveViewSh && bUniformAttribs )
+ {
+ SfxItemSet* pCommonAttrs = NULL;
+ for (USHORT nId = EE_CHAR_START; nId <= EE_CHAR_END; nId++)
+ {
+ SfxItemState eState = aOldAttribs.GetItemState( nId, FALSE, &pItem );
+ if ( eState == SFX_ITEM_SET &&
+ nId != EE_CHAR_ESCAPEMENT && nId != EE_CHAR_PAIRKERNING &&
+ nId != EE_CHAR_KERNING && nId != EE_CHAR_XMLATTRIBS &&
+ *pItem != pEditDefaults->Get(nId) )
+ {
+ if ( !pCommonAttrs )
+ pCommonAttrs = new SfxItemSet( pEngine->GetEmptyItemSet() );
+ pCommonAttrs->Put( *pItem );
+ }
+ }
+
+ if ( pCommonAttrs )
+ {
+ ScDocument* pDoc = pActiveViewSh->GetViewData()->GetDocument();
+ pCellAttrs = new ScPatternAttr( pDoc->GetPool() );
+ pCellAttrs->GetFromEditItemSet( pCommonAttrs );
+ delete pCommonAttrs;
+ }
+ }
+
+ // clear ParaAttribs (including adjustment)
+
+ RemoveAdjust();
+
+ // check if EditObject is needed
+
+ if ( bSpellErrors || nParCnt > 1 )
+ bAttrib = TRUE;
+ else
+ {
+ for (USHORT nId = EE_CHAR_START; nId <= EE_CHAR_END && !bAttrib; nId++)
+ {
+ SfxItemState eState = aOldAttribs.GetItemState( nId, FALSE, &pItem );
+ if (eState == SFX_ITEM_DONTCARE)
+ bAttrib = TRUE;
+ else if (eState == SFX_ITEM_SET)
+ {
+ // keep same items in EditEngine as in ScEditAttrTester
+ if ( nId == EE_CHAR_ESCAPEMENT || nId == EE_CHAR_PAIRKERNING ||
+ nId == EE_CHAR_KERNING || nId == EE_CHAR_XMLATTRIBS )
+ {
+ if ( *pItem != pEditDefaults->Get(nId) )
+ bAttrib = TRUE;
+ }
+ }
+ }
+
+ // Feldbefehle enthalten?
+
+ SfxItemState eFieldState = aOldAttribs.GetItemState( EE_FEATURE_FIELD, FALSE );
+ if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
+ bAttrib = TRUE;
+
+ // not converted characters?
+
+ SfxItemState eConvState = aOldAttribs.GetItemState( EE_FEATURE_NOTCONV, FALSE );
+ if ( eConvState == SFX_ITEM_DONTCARE || eConvState == SFX_ITEM_SET )
+ bAttrib = TRUE;
+
+ // Formeln immer als Formeln erkennen (#38309#)
+ // (der Test vorher ist trotzdem noetig wegen Zell-Attributen)
+ }
+
+ if (bMatrix)
+ bAttrib = FALSE;
+
+ if (bAttrib)
+ {
+ ULONG nCtrl = pEngine->GetControlWord();
+ ULONG nWantBig = bSpellErrors ? EE_CNTRL_ALLOWBIGOBJS : 0;
+ if ( ( nCtrl & EE_CNTRL_ALLOWBIGOBJS ) != nWantBig )
+ pEngine->SetControlWord( (nCtrl & ~EE_CNTRL_ALLOWBIGOBJS) | nWantBig );
+ pObject = pEngine->CreateTextObject();
+ }
+ else if (bAutoComplete) // Gross-/Kleinschreibung anpassen
+ {
+ // Perform case-matching only when the typed text is partial.
+ if (pColumnData && aAutoSearch.Len() < aString.Len())
+ pColumnData->GetExactMatch(aString);
+ }
+ }
+
+ // don't rely on ShowRefFrame switching the active view synchronously
+ // execute the function directly on the correct view's bindings instead
+ // pRefViewSh is reset in ShowRefFrame - get pointer before ShowRefFrame call
+ ScTabViewShell* pExecuteSh = pRefViewSh ? pRefViewSh : pActiveViewSh;
+
+ if (bFormulaMode)
+ {
+ ShowRefFrame();
+
+ if (pExecuteSh)
+ {
+ pExecuteSh->SetTabNo(aCursorPos.Tab());
+ pExecuteSh->ActiveGrabFocus();
+ }
+
+ bFormulaMode = FALSE;
+ pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
+ SC_MOD()->SetRefInputHdl(NULL);
+ if (pInputWin)
+ pInputWin->SetFormulaMode(FALSE);
+ UpdateAutoCorrFlag();
+ }
+ pRefViewSh = NULL; // auch ohne FormulaMode wegen Funktions-AP
+ DeleteRangeFinder();
+ ResetAutoPar();
+
+ BOOL bOldMod = bModified;
+
+ bModified = FALSE;
+ bSelIsRef = FALSE;
+ eMode = SC_INPUT_NONE;
+ StopInputWinEngine( TRUE );
+
+ // #123344# Text input (through number formats) or ApplySelectionPattern modify
+ // the cell's attributes, so pLastPattern is no longer valid
+ pLastPattern = NULL;
+
+ if (bOldMod && !bProtected && !bForget)
+ {
+ // keine typographische Anfuehrungszeichen in Formeln
+
+ if ( aString.GetChar(0) == '=' )
+ {
+ SvxAutoCorrect* pAuto = SvxAutoCorrCfg::Get()->GetAutoCorrect();
+ if ( pAuto )
+ {
+ sal_Unicode cReplace = pAuto->GetStartDoubleQuote();
+ if( !cReplace )
+ cReplace = ScGlobal::pLocaleData->getDoubleQuotationMarkStart().GetChar(0);
+ if ( cReplace != '"' )
+ aString.SearchAndReplaceAll( cReplace, '"' );
+
+ cReplace = pAuto->GetEndDoubleQuote();
+ if( !cReplace )
+ cReplace = ScGlobal::pLocaleData->getDoubleQuotationMarkEnd().GetChar(0);
+ if ( cReplace != '"' )
+ aString.SearchAndReplaceAll( cReplace, '"' );
+
+ cReplace = pAuto->GetStartSingleQuote();
+ if( !cReplace )
+ cReplace = ScGlobal::pLocaleData->getQuotationMarkStart().GetChar(0);
+ if ( cReplace != '\'' )
+ aString.SearchAndReplaceAll( cReplace, '\'' );
+
+ cReplace = pAuto->GetEndSingleQuote();
+ if( !cReplace )
+ cReplace = ScGlobal::pLocaleData->getQuotationMarkEnd().GetChar(0);
+ if ( cReplace != '\'' )
+ aString.SearchAndReplaceAll( cReplace, '\'' );
+ }
+ }
+
+ pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW_NOPAINT ) );
+
+ if ( pExecuteSh )
+ {
+ SfxBindings& rBindings = pExecuteSh->GetViewFrame()->GetBindings();
+
+ USHORT nId = FID_INPUTLINE_ENTER;
+ if ( nBlockMode == SC_ENTER_BLOCK )
+ nId = FID_INPUTLINE_BLOCK;
+ else if ( nBlockMode == SC_ENTER_MATRIX )
+ nId = FID_INPUTLINE_MATRIX;
+
+ ScInputStatusItem aItem( FID_INPUTLINE_STATUS,
+ aCursorPos, aCursorPos, aCursorPos,
+ aString, pObject );
+ const SfxPoolItem* aArgs[2];
+ aArgs[0] = &aItem;
+ aArgs[1] = NULL;
+ rBindings.Execute( nId, aArgs );
+ }
+
+ delete pLastState; // pLastState enthaelt noch den alten Text
+ pLastState = NULL;
+ }
+ else
+ pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
+
+ if ( bOldMod && pExecuteSh && pCellAttrs && !bForget )
+ {
+ // mit Eingabe zusammenfassen ?
+ pExecuteSh->ApplySelectionPattern( *pCellAttrs, TRUE, TRUE );
+ pExecuteSh->AdjustBlockHeight();
+ }
+
+ delete pCellAttrs;
+ delete pObject;
+
+ HideTip();
+ HideTipBelow();
+
+ nFormSelStart = nFormSelEnd = 0;
+ aFormText.Erase();
+
+ bInOwnChange = FALSE;
+ bInEnterHandler = FALSE;
+}
+
+void ScInputHandler::CancelHandler()
+{
+ bInOwnChange = TRUE; // disable ModifyHdl (reset below)
+
+ ImplCreateEditEngine();
+
+ bModified = FALSE;
+
+ // don't rely on ShowRefFrame switching the active view synchronously
+ // execute the function directly on the correct view's bindings instead
+ // pRefViewSh is reset in ShowRefFrame - get pointer before ShowRefFrame call
+ ScTabViewShell* pExecuteSh = pRefViewSh ? pRefViewSh : pActiveViewSh;
+
+ if (bFormulaMode)
+ {
+ ShowRefFrame();
+ if (pExecuteSh)
+ {
+ pExecuteSh->SetTabNo(aCursorPos.Tab());
+ pExecuteSh->ActiveGrabFocus();
+ }
+ bFormulaMode = FALSE;
+ SFX_APP()->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
+ SC_MOD()->SetRefInputHdl(NULL);
+ if (pInputWin)
+ pInputWin->SetFormulaMode(FALSE);
+ UpdateAutoCorrFlag();
+ }
+ pRefViewSh = NULL; // auch ohne FormulaMode wegen Funktions-AP
+ DeleteRangeFinder();
+ ResetAutoPar();
+
+ eMode = SC_INPUT_NONE;
+ StopInputWinEngine( TRUE );
+ if (pExecuteSh)
+ pExecuteSh->StopEditShell();
+
+ aCursorPos.Set(MAXCOL+1,0,0); // Flag, dass ungueltig
+ pEngine->SetText(String());
+
+ if ( !pLastState && pExecuteSh )
+ pExecuteSh->UpdateInputHandler( TRUE ); // Status neu holen
+ else
+ NotifyChange( pLastState, TRUE );
+
+ nFormSelStart = nFormSelEnd = 0;
+ aFormText.Erase();
+
+ bInOwnChange = FALSE;
+}
+
+BOOL ScInputHandler::IsModalMode( SfxObjectShell* pDocSh )
+{
+ // Referenzen auf unbenanntes Dokument gehen nicht
+
+ return bFormulaMode && pRefViewSh
+ && pRefViewSh->GetViewData()->GetDocument()->GetDocumentShell() != pDocSh
+ && !pDocSh->HasName();
+}
+
+void ScInputHandler::AddRefEntry()
+{
+ const sal_Unicode cSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ UpdateActiveView();
+ if (!pTableView && !pTopView)
+ return; // z.B. FillMode
+
+ DataChanging(); // kann nicht neu sein
+
+ RemoveSelection();
+ if (pTableView)
+ pTableView->InsertText( cSep, FALSE );
+ if (pTopView)
+ pTopView->InsertText( cSep, FALSE );
+
+ DataChanged();
+}
+
+void ScInputHandler::SetReference( const ScRange& rRef, ScDocument* pDoc )
+{
+ HideTip();
+
+ BOOL bOtherDoc = ( pRefViewSh &&
+ pRefViewSh->GetViewData()->GetDocument() != pDoc );
+ if (bOtherDoc)
+ if (!pDoc->GetDocumentShell()->HasName())
+ {
+ // Referenzen auf unbenanntes Dokument gehen nicht
+ // (SetReference sollte dann auch nicht gerufen werden)
+
+ return;
+ }
+
+ UpdateActiveView();
+ if (!pTableView && !pTopView)
+ return; // z.B. FillMode
+
+ // nie das "=" ueberschreiben!
+ EditView* pActiveView = pTopView ? pTopView : pTableView;
+ ESelection aSel = pActiveView->GetSelection();
+ aSel.Adjust();
+ if ( aSel.nStartPara == 0 && aSel.nStartPos == 0 )
+ return;
+
+ DataChanging(); // kann nicht neu sein
+
+ // Selektion umdrehen, falls rueckwaerts (noetig ???)
+
+ if (pTableView)
+ {
+ ESelection aTabSel = pTableView->GetSelection();
+ if (aTabSel.nStartPos > aTabSel.nEndPos && aTabSel.nStartPara == aTabSel.nEndPara)
+ {
+ aTabSel.Adjust();
+ pTableView->SetSelection(aTabSel);
+ }
+ }
+ if (pTopView)
+ {
+ ESelection aTopSel = pTopView->GetSelection();
+ if (aTopSel.nStartPos > aTopSel.nEndPos && aTopSel.nStartPara == aTopSel.nEndPara)
+ {
+ aTopSel.Adjust();
+ pTopView->SetSelection(aTopSel);
+ }
+ }
+
+ // String aus Referenz erzeugen
+
+ String aRefStr;
+ const ScAddress::Details aAddrDetails( pDoc, aCursorPos );
+ if (bOtherDoc)
+ {
+ // Referenz auf anderes Dokument
+
+ DBG_ASSERT(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
+
+ String aTmp;
+ rRef.Format( aTmp, SCA_VALID|SCA_TAB_3D, pDoc, aAddrDetails ); // immer 3d
+
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ // #i75893# convert escaped URL of the document to something user friendly
+// String aFileName = pObjSh->GetMedium()->GetName();
+ String aFileName = pObjSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+
+ aRefStr = '\'';
+ aRefStr += aFileName;
+ aRefStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "'#" ));
+ aRefStr += aTmp;
+ }
+ else
+ {
+ if ( ( rRef.aStart.Tab() != aCursorPos.Tab() ||
+ rRef.aStart.Tab() != rRef.aEnd.Tab() ) && pDoc )
+ rRef.Format( aRefStr, SCA_VALID|SCA_TAB_3D, pDoc, aAddrDetails );
+ else
+ rRef.Format( aRefStr, SCA_VALID, pDoc, aAddrDetails );
+ }
+
+ if (pTableView || pTopView)
+ {
+ if (pTableView)
+ pTableView->InsertText( aRefStr, TRUE );
+ if (pTopView)
+ pTopView->InsertText( aRefStr, TRUE );
+
+ DataChanged();
+ }
+
+ bSelIsRef = TRUE;
+}
+
+void ScInputHandler::InsertFunction( const String& rFuncName, BOOL bAddPar )
+{
+ if ( eMode == SC_INPUT_NONE )
+ {
+ DBG_ERROR("InsertFunction, nicht im Eingabemodus");
+ return;
+ }
+
+ UpdateActiveView();
+ if (!pTableView && !pTopView)
+ return; // z.B. FillMode
+
+ DataChanging(); // kann nicht neu sein
+
+ String aText = rFuncName;
+ if (bAddPar)
+ aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+
+ if (pTableView)
+ {
+ pTableView->InsertText( aText, FALSE );
+ if (bAddPar)
+ {
+ ESelection aSel = pTableView->GetSelection();
+ --aSel.nStartPos;
+ --aSel.nEndPos;
+ pTableView->SetSelection(aSel);
+ }
+ }
+ if (pTopView)
+ {
+ pTopView->InsertText( aText, FALSE );
+ if (bAddPar)
+ {
+ ESelection aSel = pTopView->GetSelection();
+ --aSel.nStartPos;
+ --aSel.nEndPos;
+ pTopView->SetSelection(aSel);
+ }
+ }
+
+ DataChanged();
+
+ if (bAddPar)
+ AutoParAdded();
+}
+
+void ScInputHandler::ClearText()
+{
+ if ( eMode == SC_INPUT_NONE )
+ {
+ DBG_ERROR("ClearText, nicht im Eingabemodus");
+ return;
+ }
+
+ UpdateActiveView();
+ if (!pTableView && !pTopView)
+ return; // z.B. FillMode
+
+ DataChanging(); // darf nicht neu sein
+
+ String aEmpty;
+ if (pTableView)
+ {
+ pTableView->GetEditEngine()->SetText( aEmpty );
+ pTableView->SetSelection( ESelection(0,0, 0,0) );
+ }
+ if (pTopView)
+ {
+ pTopView->GetEditEngine()->SetText( aEmpty );
+ pTopView->SetSelection( ESelection(0,0, 0,0) );
+ }
+
+ DataChanged();
+}
+
+BOOL ScInputHandler::KeyInput( const KeyEvent& rKEvt, BOOL bStartEdit /* = FALSE */ )
+{
+ if (!bOptLoaded)
+ {
+ bAutoComplete = SC_MOD()->GetAppOptions().GetAutoComplete();
+ bOptLoaded = TRUE;
+ }
+
+ KeyCode aCode = rKEvt.GetKeyCode();
+ USHORT nModi = aCode.GetModifier();
+ BOOL bShift = aCode.IsShift();
+ BOOL bControl = aCode.IsMod1();
+ BOOL bAlt = aCode.IsMod2();
+ USHORT nCode = aCode.GetCode();
+ sal_Unicode nChar = rKEvt.GetCharCode();
+
+ if (bAlt && !bControl && nCode != KEY_RETURN)
+ // Alt-Return and Alt-Ctrl-* are accepted. Everything else with ALT are not.
+ return false;
+
+ if (!bControl && nCode == KEY_TAB)
+ {
+ // Normal TAB moves the cursor right.
+ EnterHandler();
+
+ if (pActiveViewSh)
+ pActiveViewSh->FindNextUnprot( bShift );
+ return true;
+ }
+
+ BOOL bInputLine = ( eMode==SC_INPUT_TOP );
+
+ BOOL bUsed = FALSE;
+ BOOL bSkip = FALSE;
+ BOOL bDoEnter = FALSE;
+
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ if (bControl && !bShift && !bInputLine)
+ bDoEnter = TRUE;
+ else if ( nModi == 0 && nTipVisible && pFormulaData && nAutoPos != SCPOS_INVALID )
+ {
+ PasteFunctionData();
+ bUsed = TRUE;
+ }
+ else if ( nModi == 0 && nTipVisible && aManualTip.Len() )
+ {
+ PasteManualTip();
+ bUsed = TRUE;
+ }
+ else
+ {
+ BYTE nMode = SC_ENTER_NORMAL;
+ if ( bShift && bControl )
+ nMode = SC_ENTER_MATRIX;
+ else if ( bAlt )
+ nMode = SC_ENTER_BLOCK;
+ EnterHandler( nMode );
+
+ if (pActiveViewSh)
+ pActiveViewSh->MoveCursorEnter( bShift && !bControl );
+
+ bUsed = TRUE;
+ }
+ break;
+ case KEY_TAB:
+ if (bControl && !bAlt)
+ {
+ if ( pFormulaData && nTipVisible && nAutoPos != SCPOS_INVALID )
+ {
+ // blaettern
+
+ NextFormulaEntry( bShift );
+ bUsed = true;
+ }
+ else if ( pColumnData && bUseTab && nAutoPos != SCPOS_INVALID )
+ {
+ // in den Eintraegen der AutoEingabe blaettern
+
+ NextAutoEntry( bShift );
+ bUsed = true;
+ }
+ }
+ break;
+ case KEY_ESCAPE:
+ if ( nTipVisible )
+ {
+ HideTip();
+ bUsed = TRUE;
+ }
+ else if( nTipVisibleSec )
+ {
+ HideTipBelow();
+ bUsed = TRUE;
+ }
+ else if (eMode != SC_INPUT_NONE)
+ {
+ CancelHandler();
+ bUsed = TRUE;
+ }
+ else
+ bSkip = TRUE;
+ break;
+ case KEY_F2:
+ if ( !bShift && !bControl && !bAlt && eMode == SC_INPUT_TABLE )
+ {
+ eMode = SC_INPUT_TYPE;
+ bUsed = TRUE;
+ }
+ break;
+ }
+
+ // Cursortasten nur ausfuehren, wenn schon im Edit-Modus
+ // z.B. wegen Shift-Ctrl-PageDn (ist nicht als Accelerator definiert)
+
+ BOOL bCursorKey = EditEngine::DoesKeyMoveCursor(rKEvt);
+ BOOL bInsKey = ( nCode == KEY_INSERT && !nModi ); // Insert wie Cursortasten behandeln
+ if ( !bUsed && !bSkip && ( bDoEnter || EditEngine::DoesKeyChangeText(rKEvt) ||
+ ( eMode != SC_INPUT_NONE && ( bCursorKey || bInsKey ) ) ) )
+ {
+ HideTip();
+ HideTipBelow();
+
+ if (bSelIsRef)
+ {
+ RemoveSelection();
+ bSelIsRef = FALSE;
+ }
+
+ UpdateActiveView();
+ BOOL bNewView = DataChanging( nChar );
+
+ if (bProtected) // Zelle geschuetzt?
+ bUsed = TRUE; // Key-Event nicht weiterleiten
+ else // Aenderungen erlaubt
+ {
+ if (bNewView ) // neu anlegen
+ {
+ if (pActiveViewSh)
+ pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
+ UpdateActiveView();
+ if (eMode==SC_INPUT_NONE)
+ if (pTableView || pTopView)
+ {
+ String aStrLoP;
+
+ if ( bStartEdit && bCellHasPercentFormat && ((nChar >= '0' && nChar <= '9') || nChar == '-') )
+ aStrLoP = '%';
+
+ if (pTableView)
+ {
+ pTableView->GetEditEngine()->SetText( aStrLoP );
+ if ( aStrLoP.Len() )
+ pTableView->SetSelection( ESelection(0,0, 0,0) ); // before the '%'
+
+ // don't call SetSelection if the string is empty anyway,
+ // to avoid breaking the bInitial handling in ScViewData::EditGrowY
+ }
+ if (pTopView)
+ {
+ pTopView->GetEditEngine()->SetText( aStrLoP );
+ if ( aStrLoP.Len() )
+ pTopView->SetSelection( ESelection(0,0, 0,0) ); // before the '%'
+ }
+ }
+ SyncViews();
+ }
+
+ if (pTableView || pTopView)
+ {
+// pActiveView->SetEditEngineUpdateMode(TRUE); //! gibt Muell !!!!
+
+ if (bDoEnter)
+ {
+ if (pTableView)
+ if( pTableView->PostKeyEvent( KeyEvent( CHAR_CR, KeyCode(KEY_RETURN) ) ) )
+ bUsed = TRUE;
+ if (pTopView)
+ if( pTopView->PostKeyEvent( KeyEvent( CHAR_CR, KeyCode(KEY_RETURN) ) ) )
+ bUsed = TRUE;
+ }
+ else if ( nAutoPar && nChar == ')' && CursorAtClosingPar() )
+ {
+ SkipClosingPar();
+ bUsed = TRUE;
+ }
+ else
+ {
+ if (pTableView)
+ {
+ Window* pFrameWin = pActiveViewSh ? pActiveViewSh->GetFrameWin() : NULL;
+ if ( pTableView->PostKeyEvent( rKEvt, pFrameWin ) )
+ bUsed = TRUE;
+ }
+ if (pTopView)
+ if ( pTopView->PostKeyEvent( rKEvt ) )
+ bUsed = TRUE;
+ }
+
+ // Auto-Eingabe:
+
+ if ( bUsed && bAutoComplete )
+ {
+ bUseTab = FALSE;
+ nAutoPos = SCPOS_INVALID; // do not search further
+
+ KeyFuncType eFunc = rKEvt.GetKeyCode().GetFunction();
+ if ( nChar && nChar != 8 && nChar != 127 && // no 'backspace', no 'delete'
+ KEYFUNC_CUT != eFunc) // and no 'CTRL-X'
+ {
+ if (bFormulaMode)
+ UseFormulaData();
+ else
+ UseColData();
+ }
+ }
+
+ // when the selection is changed manually or an opening parenthesis
+ // is typed, stop overwriting parentheses
+ if ( bUsed && nChar == '(' )
+ ResetAutoPar();
+
+ if ( KEY_INSERT == nCode )
+ {
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
+ }
+ if( bUsed && bFormulaMode && ( bCursorKey || bInsKey || nCode == KEY_DELETE || nCode == KEY_BACKSPACE ) )
+ {
+ ShowTipCursor();
+ }
+ }
+
+ DataChanged(); // ruft auch UpdateParenthesis()
+ InvalidateAttribs(); //! in DataChanged ?
+ }
+ }
+
+ if (pTopView && eMode != SC_INPUT_NONE)
+ SyncViews();
+
+ return bUsed;
+}
+
+BOOL ScInputHandler::InputCommand( const CommandEvent& rCEvt, BOOL bForce )
+{
+ BOOL bUsed = FALSE;
+
+ if ( rCEvt.GetCommand() == COMMAND_CURSORPOS )
+ {
+ // #90346# for COMMAND_CURSORPOS, do as little as possible, because
+ // with remote VCL, even a ShowCursor will generate another event.
+ if ( eMode != SC_INPUT_NONE )
+ {
+ UpdateActiveView();
+ if (pTableView || pTopView)
+ {
+ if (pTableView)
+ pTableView->Command( rCEvt );
+ else if (pTopView) // call only once
+ pTopView->Command( rCEvt );
+ bUsed = TRUE;
+ }
+ }
+ }
+ else
+ {
+ if ( bForce || eMode != SC_INPUT_NONE )
+ {
+ if (!bOptLoaded)
+ {
+ bAutoComplete = SC_MOD()->GetAppOptions().GetAutoComplete();
+ bOptLoaded = TRUE;
+ }
+
+ HideTip();
+ HideTipBelow();
+
+ if ( bSelIsRef )
+ {
+ RemoveSelection();
+ bSelIsRef = FALSE;
+ }
+
+ UpdateActiveView();
+ BOOL bNewView = DataChanging( 0, TRUE );
+
+ if (bProtected) // cell protected
+ bUsed = TRUE; // event is used
+ else // changes allowed
+ {
+ if (bNewView) // create new edit view
+ {
+ if (pActiveViewSh)
+ pActiveViewSh->GetViewData()->GetDocShell()->PostEditView( pEngine, aCursorPos );
+ UpdateActiveView();
+ if (eMode==SC_INPUT_NONE)
+ if (pTableView || pTopView)
+ {
+ String aStrLoP;
+ if (pTableView)
+ {
+ pTableView->GetEditEngine()->SetText( aStrLoP );
+ pTableView->SetSelection( ESelection(0,0, 0,0) );
+ }
+ if (pTopView)
+ {
+ pTopView->GetEditEngine()->SetText( aStrLoP );
+ pTopView->SetSelection( ESelection(0,0, 0,0) );
+ }
+ }
+ SyncViews();
+ }
+
+ if (pTableView || pTopView)
+ {
+ if (pTableView)
+ pTableView->Command( rCEvt );
+ if (pTopView)
+ pTopView->Command( rCEvt );
+
+ bUsed = TRUE;
+
+ if ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT )
+ {
+ // AutoInput after ext text input
+
+ nAutoPos = SCPOS_INVALID;
+ if (bFormulaMode)
+ UseFormulaData();
+ else
+ UseColData();
+ }
+ }
+
+ DataChanged(); // calls UpdateParenthesis()
+ InvalidateAttribs(); //! in DataChanged ?
+ }
+ }
+
+ if (pTopView && eMode != SC_INPUT_NONE)
+ SyncViews();
+ }
+
+ return bUsed;
+}
+
+void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
+ BOOL bForce, ScTabViewShell* pSourceSh,
+ BOOL bStopEditing)
+{
+ // #62806# Wenn der Aufruf aus einem Makro-Aufruf im EnterHandler kommt,
+ // gleich abbrechen und nicht den Status durcheinander bringen
+ if (bInEnterHandler)
+ return;
+
+ BOOL bRepeat = (pState == pLastState);
+ if (!bRepeat && pState && pLastState)
+ bRepeat = sal::static_int_cast<BOOL>(*pState == *pLastState);
+ if (bRepeat && !bForce)
+ return;
+
+ bInOwnChange = TRUE; // disable ModifyHdl (reset below)
+
+ if ( pState && !pLastState ) // wieder enablen
+ bForce = TRUE;
+
+ BOOL bHadObject = pLastState && pLastState->GetEditData();
+
+ //! Before EditEngine gets eventually created (so it gets the right pools)
+ if ( pSourceSh )
+ pActiveViewSh = pSourceSh;
+ else
+ pActiveViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+
+ ImplCreateEditEngine();
+
+ if ( pState != pLastState )
+ {
+ delete pLastState;
+ pLastState = pState ? new ScInputHdlState( *pState ) : NULL;
+ }
+
+ if ( pState && pActiveViewSh )
+ {
+ ScModule* pScMod = SC_MOD();
+
+ if ( pState )
+ {
+ BOOL bIgnore = FALSE;
+
+ // hier auch fremde Referenzeingabe beruecksichtigen (z.B. Funktions-AP),
+ // FormEditData falls gerade von der Hilfe auf Calc umgeschaltet wird:
+
+ if ( !bFormulaMode && !pScMod->IsFormulaMode() && !pScMod->GetFormEditData() )
+ {
+ if ( bModified )
+ {
+ if (pState->GetPos() != aCursorPos)
+ {
+ if (!bProtected)
+ EnterHandler();
+ }
+ else
+ bIgnore = TRUE;
+ }
+
+ if ( !bIgnore /* || bRepeat */ )
+ {
+ const ScAddress& rSPos = pState->GetStartPos();
+ const ScAddress& rEPos = pState->GetEndPos();
+ const EditTextObject* pData = pState->GetEditData();
+ String aString = pState->GetString();
+ BOOL bTxtMod = FALSE;
+ ScDocShell* pDocSh = pActiveViewSh->GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ aCursorPos = pState->GetPos();
+
+ if ( pData /* || bRepeat */ )
+ bTxtMod = TRUE;
+ else if ( bHadObject )
+ bTxtMod = TRUE;
+ else if ( bTextValid )
+ bTxtMod = ( aString != aCurrentText );
+ else
+ bTxtMod = ( aString != GetEditText(pEngine) );
+
+ if ( bTxtMod || bForce )
+ {
+ if (pData)
+ {
+ pEngine->SetText( *pData );
+ aString = GetEditText(pEngine);
+ lcl_RemoveTabs(aString);
+ bTextValid = FALSE;
+ aCurrentText.Erase();
+ }
+ else
+ {
+ aCurrentText = aString;
+ bTextValid = TRUE; //! erst nur als String merken
+ }
+
+ if ( pInputWin )
+ pInputWin->SetTextString(aString);
+ }
+
+ if ( pInputWin ) // Bereichsanzeige
+ {
+ String aPosStr;
+ const ScAddress::Details aAddrDetails( pDoc, aCursorPos );
+
+ // Ist der Bereich ein Name?
+ //! per Timer suchen ???
+
+ if ( pActiveViewSh )
+ pActiveViewSh->GetViewData()->GetDocument()->
+ GetRangeAtBlock( ScRange( rSPos, rEPos ), &aPosStr );
+
+ if ( !aPosStr.Len() ) // kein Name -> formatieren
+ {
+ USHORT nFlags = 0;
+ if( aAddrDetails.eConv == formula::FormulaGrammar::CONV_XL_R1C1 )
+ nFlags |= SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE;
+ if ( rSPos != rEPos )
+ {
+ ScRange r(rSPos, rEPos);
+ nFlags |= (nFlags << 4);
+ r.Format( aPosStr, SCA_VALID | nFlags, pDoc, aAddrDetails );
+ }
+ else
+ aCursorPos.Format( aPosStr, SCA_VALID | nFlags, pDoc, aAddrDetails );
+ }
+
+ pInputWin->SetPosString(aPosStr);
+ pInputWin->SetSumAssignMode();
+ }
+
+ if (bStopEditing)
+ SFX_APP()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
+
+ // As long as the content is not edited, turn off online spelling.
+ // Online spelling is turned back on in StartTable, after setting
+ // the right language from cell attributes.
+
+ ULONG nCntrl = pEngine->GetControlWord();
+ if ( nCntrl & EE_CNTRL_ONLINESPELLING )
+ pEngine->SetControlWord( nCntrl & ~EE_CNTRL_ONLINESPELLING );
+
+ bModified = FALSE;
+ bSelIsRef = FALSE;
+ bProtected = FALSE;
+ bCommandErrorShown = FALSE;
+ }
+ }
+ }
+
+// bProtected = FALSE;
+
+ if ( pInputWin)
+ {
+ if(!pScMod->IsFormulaMode()&& !pScMod->IsRefDialogOpen()) //BugID 54702
+ { //Wenn RefDialog offen, dann nicht enablen
+ if ( !pInputWin->IsEnabled())
+ {
+ pInputWin->Enable();
+ if(pDelayTimer )
+ {
+ DELETEZ( pDelayTimer );
+ }
+ }
+ }
+ else if(pScMod->IsRefDialogOpen())
+ { // Da jedes Dokument eigenes InputWin hat, sollte
+ if ( !pDelayTimer ) // nochmals Timer gestartet werden, da sonst Ein-
+ { // gabezeile evt. noch aktiv ist.
+ pDelayTimer = new Timer;
+ pDelayTimer->SetTimeout( 500 ); // 100ms Verzoegerung
+ pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
+ pDelayTimer->Start();
+ }
+ }
+ }
+ }
+ else // !pState || !pActiveViewSh
+ {
+ if ( !pDelayTimer )
+ {
+ pDelayTimer = new Timer;
+ pDelayTimer->SetTimeout( 500 ); // 100ms Verzoegerung
+ pDelayTimer->SetTimeoutHdl( LINK( this, ScInputHandler, DelayTimer ) );
+ pDelayTimer->Start();
+ }
+ }
+
+ HideTip();
+ HideTipBelow();
+ bInOwnChange = FALSE;
+}
+
+void ScInputHandler::UpdateCellAdjust( SvxCellHorJustify eJust )
+{
+ eAttrAdjust = eJust;
+ UpdateAdjust( 0 );
+}
+
+void ScInputHandler::ResetDelayTimer()
+{
+ if(pDelayTimer!=NULL)
+ {
+ DELETEZ( pDelayTimer );
+
+ if ( pInputWin)
+ {
+ pInputWin->Enable();
+ }
+ }
+}
+
+IMPL_LINK( ScInputHandler, DelayTimer, Timer*, pTimer )
+{
+ if ( pTimer == pDelayTimer )
+ {
+ DELETEZ( pDelayTimer );
+
+ if ( NULL == pLastState || SC_MOD()->IsFormulaMode() || SC_MOD()->IsRefDialogOpen())
+ {
+ //! new method at ScModule to query if function autopilot is open
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
+ {
+ if ( pInputWin)
+ {
+ pInputWin->EnableButtons( FALSE );
+ pInputWin->Disable();
+ }
+ }
+ else if ( !bFormulaMode ) // #39210# Formel auch z.B. bei Hilfe behalten
+ {
+ bInOwnChange = TRUE; // disable ModifyHdl (reset below)
+
+ pActiveViewSh = NULL;
+ pEngine->SetText( EMPTY_STRING );
+ if ( pInputWin )
+ {
+ pInputWin->SetPosString( EMPTY_STRING );
+ pInputWin->SetTextString( EMPTY_STRING );
+ pInputWin->Disable();
+ }
+
+ bInOwnChange = FALSE;
+ }
+ }
+ }
+ return 0;
+}
+
+void ScInputHandler::InputSelection( EditView* pView )
+{
+ SyncViews( pView );
+ ShowTipCursor();
+ UpdateParenthesis(); // Selektion geaendert -> Klammer-Hervorhebung neu
+
+ // when the selection is changed manually, stop overwriting parentheses
+ ResetAutoPar();
+}
+
+void ScInputHandler::InputChanged( EditView* pView, BOOL bFromNotify )
+{
+ ESelection aSelection = pView->GetSelection();
+
+ UpdateActiveView();
+
+ // #i20282# DataChanged needs to know if this is from the input line's modify handler
+ BOOL bFromTopNotify = ( bFromNotify && pView == pTopView );
+
+ BOOL bNewView = DataChanging(); //! kann das hier ueberhaupt sein?
+ aCurrentText = pView->GetEditEngine()->GetText(); // auch den String merken
+ pEngine->SetText( aCurrentText );
+ DataChanged( bFromTopNotify );
+ bTextValid = TRUE; // wird in DataChanged auf FALSE gesetzt
+
+ if ( pActiveViewSh )
+ {
+ ScViewData* pViewData = pActiveViewSh->GetViewData();
+ if ( bNewView )
+ pViewData->GetDocShell()->PostEditView( pEngine, aCursorPos );
+
+ pViewData->EditGrowY();
+ pViewData->EditGrowX();
+ }
+
+ SyncViews( pView );
+}
+
+const String& ScInputHandler::GetEditString()
+{
+ if (pEngine)
+ {
+ aCurrentText = pEngine->GetText(); // immer neu aus Engine
+ bTextValid = TRUE;
+ }
+
+ return aCurrentText;
+}
+
+Size ScInputHandler::GetTextSize()
+{
+ Size aSize;
+ if ( pEngine )
+ aSize = Size( pEngine->CalcTextWidth(), pEngine->GetTextHeight() );
+
+ return aSize;
+}
+
+BOOL ScInputHandler::GetTextAndFields( ScEditEngineDefaulter& rDestEngine )
+{
+ BOOL bRet = FALSE;
+ if (pEngine)
+ {
+ // Feldbefehle enthalten?
+
+ USHORT nParCnt = pEngine->GetParagraphCount();
+ SfxItemSet aSet = pEngine->GetAttribs( ESelection(0,0,nParCnt,0) );
+ SfxItemState eFieldState = aSet.GetItemState( EE_FEATURE_FIELD, FALSE );
+ if ( eFieldState == SFX_ITEM_DONTCARE || eFieldState == SFX_ITEM_SET )
+ {
+ // Inhalt kopieren
+
+ EditTextObject* pObj = pEngine->CreateTextObject();
+ rDestEngine.SetText(*pObj);
+ delete pObj;
+
+ // Attribute loeschen
+
+ for (USHORT i=0; i<nParCnt; i++)
+ rDestEngine.QuickRemoveCharAttribs( i );
+
+ // Absaetze zusammenfassen
+
+ while ( nParCnt > 1 )
+ {
+ xub_StrLen nLen = rDestEngine.GetTextLen( (USHORT)0 );
+ ESelection aSel( 0,nLen, 1,0 );
+ rDestEngine.QuickInsertText( ' ', aSel ); // Umbruch durch Space ersetzen
+ --nParCnt;
+ }
+
+ bRet = TRUE;
+ }
+ }
+ return bRet;
+}
+
+//------------------------------------------------------------------------
+// Methoden fuer FunktionsAutopiloten:
+// InputGetSelection, InputSetSelection, InputReplaceSelection, InputGetFormulaStr
+//------------------------------------------------------------------------
+
+void ScInputHandler::InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd )
+{
+ rStart = nFormSelStart;
+ rEnd = nFormSelEnd;
+}
+
+//------------------------------------------------------------------------
+
+EditView* ScInputHandler::GetFuncEditView()
+{
+ UpdateActiveView(); // wegen pTableView
+
+ EditView* pView = NULL;
+ if ( pInputWin )
+ {
+ pInputWin->MakeDialogEditView();
+ pView = pInputWin->GetEditView();
+ }
+ else
+ {
+ if ( eMode != SC_INPUT_TABLE )
+ {
+ bCreatingFuncView = TRUE; // RangeFinder nicht anzeigen
+ SetMode( SC_INPUT_TABLE );
+ bCreatingFuncView = FALSE;
+ if ( pTableView )
+ pTableView->GetEditEngine()->SetText( EMPTY_STRING );
+ }
+ pView = pTableView;
+ }
+
+ return pView;
+}
+
+//------------------------------------------------------------------------
+
+void ScInputHandler::InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd )
+{
+ if ( nStart <= nEnd )
+ {
+ nFormSelStart = nStart;
+ nFormSelEnd = nEnd;
+ }
+ else
+ {
+ nFormSelEnd = nStart;
+ nFormSelStart = nEnd;
+ }
+
+ EditView* pView = GetFuncEditView();
+ if (pView)
+ pView->SetSelection( ESelection(0,nStart, 0,nEnd) );
+
+ bModified = TRUE;
+}
+
+//------------------------------------------------------------------------
+
+void ScInputHandler::InputReplaceSelection( const String& rStr )
+{
+ if (!pRefViewSh)
+ pRefViewSh = pActiveViewSh;
+
+ DBG_ASSERT(nFormSelEnd>=nFormSelStart,"Selektion kaputt...");
+
+ xub_StrLen nOldLen = nFormSelEnd-nFormSelStart;
+ xub_StrLen nNewLen = rStr.Len();
+ if (nOldLen)
+ aFormText.Erase( nFormSelStart, nOldLen );
+ if (nNewLen)
+ aFormText.Insert( rStr, nFormSelStart );
+ nFormSelEnd = nFormSelStart + nNewLen;
+
+ EditView* pView = GetFuncEditView();
+ if (pView)
+ {
+ pView->SetEditEngineUpdateMode( FALSE );
+// pView->InsertText( rStr, TRUE );
+ pView->GetEditEngine()->SetText( aFormText );
+ pView->SetSelection( ESelection(0,nFormSelStart, 0,nFormSelEnd) );
+ pView->SetEditEngineUpdateMode( TRUE );
+ }
+ bModified = TRUE;
+}
+
+//------------------------------------------------------------------------
+
+String ScInputHandler::InputGetFormulaStr()
+{
+ return aFormText; //! eigene Membervariable?
+}
+
+//========================================================================
+// ScInputHdlState
+//========================================================================
+
+ScInputHdlState::ScInputHdlState( const ScAddress& rCurPos,
+ const ScAddress& rStartPos,
+ const ScAddress& rEndPos,
+ const String& rString,
+ const EditTextObject* pData )
+ : aCursorPos ( rCurPos ),
+ aStartPos ( rStartPos ),
+ aEndPos ( rEndPos ),
+ aString ( rString ),
+ pEditData ( pData ? pData->Clone() : NULL )
+{
+}
+
+//------------------------------------------------------------------------
+
+ScInputHdlState::ScInputHdlState( const ScInputHdlState& rCpy )
+ : pEditData ( NULL )
+{
+ *this = rCpy;
+}
+
+//------------------------------------------------------------------------
+
+ScInputHdlState::~ScInputHdlState()
+{
+ delete pEditData;
+}
+
+//------------------------------------------------------------------------
+
+int ScInputHdlState::operator==( const ScInputHdlState& r ) const
+{
+ return ( (aStartPos == r.aStartPos)
+ && (aEndPos == r.aEndPos)
+ && (aCursorPos == r.aCursorPos)
+ && (aString == r.aString)
+ && ScGlobal::EETextObjEqual( pEditData, r.pEditData ) );
+}
+
+//------------------------------------------------------------------------
+
+ScInputHdlState& ScInputHdlState::operator=( const ScInputHdlState& r )
+{
+ delete pEditData;
+
+ aCursorPos = r.aCursorPos;
+ aStartPos = r.aStartPos;
+ aEndPos = r.aEndPos;
+ aString = r.aString;
+ pEditData = r.pEditData ? r.pEditData->Clone() : NULL;
+
+ return *this;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
new file mode 100644
index 000000000000..ae77794ff999
--- /dev/null
+++ b/sc/source/ui/app/inputwin.cxx
@@ -0,0 +1,1812 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <algorithm>
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/imgmgr.hxx>
+#include <stdlib.h> // qsort
+#include <editeng/scriptspaceitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <vcl/cursor.hxx>
+#include <vcl/help.hxx>
+#include <svl/stritem.hxx>
+
+#include "inputwin.hxx"
+#include "scmod.hxx"
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "editutil.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "appoptio.hxx"
+#include "rangenam.hxx"
+#include <formula/compiler.hrc>
+#include "dbcolect.hxx"
+#include "rangeutl.hxx"
+#include "docfunc.hxx"
+#include "funcdesc.hxx"
+#include <editeng/fontitem.hxx>
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include "AccessibleEditObject.hxx"
+#include "AccessibleText.hxx"
+
+#define TEXT_STARTPOS 3
+#define THESIZE 1000000 //!!! langt... :-)
+#define TBX_WINDOW_HEIGHT 22 // in Pixeln - fuer alle Systeme gleich?
+
+enum ScNameInputType
+{
+ SC_NAME_INPUT_CELL,
+ SC_NAME_INPUT_RANGE,
+ SC_NAME_INPUT_NAMEDRANGE,
+ SC_NAME_INPUT_DATABASE,
+ SC_NAME_INPUT_ROW,
+ SC_NAME_INPUT_SHEET,
+ SC_NAME_INPUT_DEFINE,
+ SC_NAME_INPUT_BAD_NAME,
+ SC_NAME_INPUT_BAD_SELECTION
+};
+
+
+//==================================================================
+// class ScInputWindowWrapper
+//==================================================================
+
+SFX_IMPL_CHILDWINDOW(ScInputWindowWrapper,FID_INPUTLINE_STATUS)
+
+ScInputWindowWrapper::ScInputWindowWrapper( Window* pParentP,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* /* pInfo */ )
+ : SfxChildWindow( pParentP, nId )
+{
+ ScInputWindow* pWin=new ScInputWindow( pParentP, pBindings );
+ pWindow = pWin;
+
+ pWin->Show();
+
+ pWin->SetSizePixel( pWin->CalcWindowSizePixel() );
+
+ eChildAlignment = SFX_ALIGN_LOWESTTOP;
+ pBindings->Invalidate( FID_TOGGLEINPUTLINE );
+}
+
+// GetInfo fliegt wieder raus, wenn es ein SFX_IMPL_TOOLBOX gibt !!!!
+
+SfxChildWinInfo __EXPORT ScInputWindowWrapper::GetInfo() const
+{
+ SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
+ return aInfo;
+}
+
+//==================================================================
+
+#define IMAGE(id) pImgMgr->SeekImage(id, bHC)
+
+//==================================================================
+// class ScInputWindow
+//==================================================================
+
+ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) :
+#ifdef OS2
+// #37192# ohne WB_CLIPCHILDREN wg. os/2 Paintproblem
+ ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK) ),
+#else
+// mit WB_CLIPCHILDREN, sonst Flicker
+ ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ),
+#endif
+ aWndPos ( this ),
+ aTextWindow ( this ),
+ pInputHdl ( NULL ),
+ pBindings ( pBind ),
+ aTextOk ( ScResId( SCSTR_QHELP_BTNOK ) ), // nicht immer neu aus Resource
+ aTextCancel ( ScResId( SCSTR_QHELP_BTNCANCEL ) ),
+ aTextSum ( ScResId( SCSTR_QHELP_BTNSUM ) ),
+ aTextEqual ( ScResId( SCSTR_QHELP_BTNEQUAL ) ),
+ bIsOkCancelMode ( FALSE )
+{
+ ScModule* pScMod = SC_MOD();
+ SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
+
+ // #i73615# don't rely on SfxViewShell::Current while constructing the input line
+ // (also for GetInputHdl below)
+ ScTabViewShell* pViewSh = NULL;
+ SfxDispatcher* pDisp = pBind->GetDispatcher();
+ if ( pDisp )
+ {
+ SfxViewFrame* pViewFrm = pDisp->GetFrame();
+ if ( pViewFrm )
+ pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
+ }
+ DBG_ASSERT( pViewSh, "no view shell for input window" );
+
+ BOOL bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ // Positionsfenster, 3 Buttons, Eingabefenster
+ InsertWindow ( 1, &aWndPos, 0, 0 );
+ InsertSeparator ( 1 );
+ InsertItem ( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ), 0, 2 );
+ InsertItem ( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), 0, 3 );
+ InsertItem ( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), 0, 4 );
+ InsertSeparator ( 5 );
+ InsertWindow ( 7, &aTextWindow, 0, 6 );
+
+ aWndPos .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) );
+ aWndPos .SetHelpId ( HID_INSWIN_POS );
+ aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) );
+ aTextWindow.SetHelpId ( HID_INSWIN_INPUT );
+
+ // kein SetHelpText, die Hilfetexte kommen aus der Hilfe
+
+ SetItemText ( SID_INPUT_FUNCTION, ScResId( SCSTR_QHELP_BTNCALC ) );
+ SetHelpId ( SID_INPUT_FUNCTION, HID_INSWIN_CALC );
+
+ SetItemText ( SID_INPUT_SUM, aTextSum );
+ SetHelpId ( SID_INPUT_SUM, HID_INSWIN_SUMME );
+
+ SetItemText ( SID_INPUT_EQUAL, aTextEqual );
+ SetHelpId ( SID_INPUT_EQUAL, HID_INSWIN_FUNC );
+
+ SetHelpId( HID_SC_INPUTWIN ); // fuer die ganze Eingabezeile
+
+ aWndPos .Show();
+ aTextWindow .Show();
+
+ pInputHdl = SC_MOD()->GetInputHdl( pViewSh, FALSE ); // use own handler even if ref-handler is set
+ if (pInputHdl)
+ pInputHdl->SetInputWindow( this );
+
+ if ( pInputHdl && pInputHdl->GetFormString().Len() )
+ {
+ // Umschalten waehrend der Funktionsautopilot aktiv ist
+ // -> Inhalt des Funktionsautopiloten wieder anzeigen
+ //! auch Selektion (am InputHdl gemerkt) wieder anzeigen
+
+ aTextWindow.SetTextString( pInputHdl->GetFormString() );
+ }
+ else if ( pInputHdl && pInputHdl->IsInputMode() )
+ {
+ // wenn waehrend des Editierens die Eingabezeile weg war
+ // (Editieren einer Formel, dann umschalten zu fremdem Dokument/Hilfe),
+ // wieder den gerade editierten Text aus dem InputHandler anzeigen
+
+ aTextWindow.SetTextString( pInputHdl->GetEditString() ); // Text anzeigen
+ if ( pInputHdl->IsTopMode() )
+ pInputHdl->SetMode( SC_INPUT_TABLE ); // Focus kommt eh nach unten
+ }
+ else if ( pViewSh )
+ pViewSh->UpdateInputHandler( TRUE ); // unbedingtes Update
+
+ pImgMgr->RegisterToolBox( this );
+}
+
+__EXPORT ScInputWindow::~ScInputWindow()
+{
+ BOOL bDown = ( ScGlobal::pSysLocale == NULL ); // after Clear?
+
+ // if any view's input handler has a pointer to this input window, reset it
+ // (may be several ones, #74522#)
+ // member pInputHdl is not used here
+
+ if ( !bDown )
+ {
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh )
+ {
+ ScInputHandler* pHdl = ((ScTabViewShell*)pSh)->GetInputHandler();
+ if ( pHdl && pHdl->GetInputWindow() == this )
+ {
+ pHdl->SetInputWindow( NULL );
+ pHdl->StopInputWinEngine( FALSE ); // #125841# reset pTopView pointer
+ }
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+ }
+
+ SfxImageManager::GetImageManager( SC_MOD() )->ReleaseToolBox( this );
+}
+
+void ScInputWindow::SetInputHandler( ScInputHandler* pNew )
+{
+ // wird im Activate der View gerufen...
+
+ if ( pNew != pInputHdl )
+ {
+ // Bei Reload (letzte Version) ist pInputHdl der Input-Handler der alten,
+ // geloeschten ViewShell, darum hier auf keinen Fall anfassen!
+
+ pInputHdl = pNew;
+ if (pInputHdl)
+ pInputHdl->SetInputWindow( this );
+ }
+}
+
+sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
+{
+ sal_Bool bSubTotal(sal_False);
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ if ( pViewSh )
+ {
+ ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+ sal_Int32 nRangeCount (pRangeList->Count());
+ sal_Int32 nRangeIndex (0);
+ while (!bSubTotal && nRangeIndex < nRangeCount)
+ {
+ const ScRange* pRange = pRangeList->GetObject( nRangeIndex );
+ if( pRange )
+ {
+ SCTAB nTabEnd(pRange->aEnd.Tab());
+ SCTAB nTab(pRange->aStart.Tab());
+ while (!bSubTotal && nTab <= nTabEnd)
+ {
+ SCROW nRowEnd(pRange->aEnd.Row());
+ SCROW nRow(pRange->aStart.Row());
+ while (!bSubTotal && nRow <= nRowEnd)
+ {
+ if (pDoc->RowFiltered(nRow, nTab))
+ bSubTotal = sal_True;
+ else
+ ++nRow;
+ }
+ ++nTab;
+ }
+ }
+ ++nRangeIndex;
+ }
+
+ ScDBCollection* pDBCollection = pDoc->GetDBCollection();
+ sal_uInt16 nDBCount (pDBCollection->GetCount());
+ sal_uInt16 nDBIndex (0);
+ while (!bSubTotal && nDBIndex < nDBCount)
+ {
+ ScDBData* pDB = (*pDBCollection)[nDBIndex];
+ if (pDB && pDB->HasAutoFilter())
+ {
+ nRangeIndex = 0;
+ while (!bSubTotal && nRangeIndex < nRangeCount)
+ {
+ const ScRange* pRange = pRangeList->GetObject( nRangeIndex );
+ if( pRange )
+ {
+ ScRange aDBArea;
+ pDB->GetArea(aDBArea);
+ if (aDBArea.Intersects(*pRange))
+ bSubTotal = sal_True;
+ }
+ ++nRangeIndex;
+ }
+ }
+ ++nDBIndex;
+ }
+ }
+ return bSubTotal;
+}
+
+void __EXPORT ScInputWindow::Select()
+{
+ ScModule* pScMod = SC_MOD();
+ ToolBox::Select();
+
+ switch ( GetCurItemId() )
+ {
+ case SID_INPUT_FUNCTION:
+ {
+ //! new method at ScModule to query if function autopilot is open
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
+ {
+ pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+
+ // die Toolbox wird sowieso disabled, also braucht auch nicht umgeschaltet
+ // zu werden, egal ob's geklappt hat oder nicht
+// SetOkCancelMode();
+ }
+ }
+ break;
+
+ case SID_INPUT_CANCEL:
+ pScMod->InputCancelHandler();
+ SetSumAssignMode();
+ break;
+
+ case SID_INPUT_OK:
+ pScMod->InputEnterHandler();
+ SetSumAssignMode();
+ aTextWindow.Invalidate(); // sonst bleibt Selektion stehen
+ break;
+
+ case SID_INPUT_SUM:
+ {
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ if ( pViewSh )
+ {
+ const ScMarkData& rMark = pViewSh->GetViewData()->GetMarkData();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ ScRangeList aMarkRangeList;
+ rMark.FillRangeListWithMarks( &aMarkRangeList, FALSE );
+ ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+
+ // check if one of the marked ranges is empty
+ bool bEmpty = false;
+ const ULONG nCount = aMarkRangeList.Count();
+ for ( ULONG i = 0; i < nCount; ++i )
+ {
+ const ScRange aRange( *aMarkRangeList.GetObject( i ) );
+ if ( pDoc->IsBlockEmpty( aRange.aStart.Tab(),
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row() ) )
+ {
+ bEmpty = true;
+ break;
+ }
+ }
+
+ if ( bEmpty )
+ {
+ ScRangeList aRangeList;
+ const BOOL bDataFound = pViewSh->GetAutoSumArea( aRangeList );
+ if ( bDataFound )
+ {
+ ScAddress aAddr = aRangeList.Last()->aEnd;
+ aAddr.IncRow();
+ const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) );
+ pViewSh->EnterAutoSum( aRangeList, bSubTotal, aAddr );
+ }
+ }
+ else
+ {
+ const sal_Bool bSubTotal( UseSubTotal( &aMarkRangeList ) );
+ for ( ULONG i = 0; i < nCount; ++i )
+ {
+ const ScRange aRange( *aMarkRangeList.GetObject( i ) );
+ const bool bSetCursor = ( i == nCount - 1 ? true : false );
+ const bool bContinue = ( i != 0 ? true : false );
+ if ( !pViewSh->AutoSum( aRange, bSubTotal, bSetCursor, bContinue ) )
+ {
+ pViewSh->MarkRange( aRange, FALSE, FALSE );
+ pViewSh->SetCursor( aRange.aEnd.Col(), aRange.aEnd.Row() );
+ const ScRangeList aRangeList;
+ ScAddress aAddr = aRange.aEnd;
+ aAddr.IncRow();
+ const String aFormula = pViewSh->GetAutoSumFormula(
+ aRangeList, bSubTotal, aAddr );
+ SetFuncString( aFormula );
+ break;
+ }
+ }
+ }
+ }
+ else // nur in Eingabezeile einfuegen
+ {
+ ScRangeList aRangeList;
+ const BOOL bDataFound = pViewSh->GetAutoSumArea( aRangeList );
+ const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) );
+ ScAddress aAddr = pViewSh->GetViewData()->GetCurPos();
+ const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal, aAddr );
+ SetFuncString( aFormula );
+
+ if ( bDataFound && pScMod->IsEditMode() )
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if ( pHdl )
+ {
+ pHdl->InitRangeFinder( aFormula );
+
+ //! SetSelection am InputHandler ???
+ //! bSelIsRef setzen ???
+ const xub_StrLen nOpen = aFormula.Search('(');
+ const xub_StrLen nLen = aFormula.Len();
+ if ( nOpen != STRING_NOTFOUND && nLen > nOpen )
+ {
+ sal_uInt8 nAdd(1);
+ if (bSubTotal)
+ nAdd = 3;
+ ESelection aSel(0,nOpen+nAdd,0,nLen-1);
+ EditView* pTableView = pHdl->GetTableView();
+ if (pTableView)
+ pTableView->SetSelection(aSel);
+ EditView* pTopView = pHdl->GetTopView();
+ if (pTopView)
+ pTopView->SetSelection(aSel);
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_INPUT_EQUAL:
+ {
+ aTextWindow.StartEditEngine();
+ if ( pScMod->IsEditMode() ) // nicht, wenn z.B. geschuetzt
+ {
+ aTextWindow.GrabFocus();
+ aTextWindow.SetTextString( '=' );
+
+ EditView* pView = aTextWindow.GetEditView();
+ if (pView)
+ {
+ pView->SetSelection( ESelection(0,1, 0,1) );
+ pScMod->InputChanged(pView);
+ SetOkCancelMode();
+ pView->SetEditEngineUpdateMode(TRUE);
+ }
+ }
+ break;
+ }
+ }
+}
+
+void __EXPORT ScInputWindow::Resize()
+{
+ ToolBox::Resize();
+
+ long nWidth = GetSizePixel().Width();
+ long nLeft = aTextWindow.GetPosPixel().X();
+ Size aSize = aTextWindow.GetSizePixel();
+
+ aSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 );
+ aTextWindow.SetSizePixel( aSize );
+ aTextWindow.Invalidate();
+}
+
+void ScInputWindow::SetFuncString( const String& rString, BOOL bDoEdit )
+{
+ //! new method at ScModule to query if function autopilot is open
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
+ aTextWindow.StartEditEngine();
+
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->IsEditMode() )
+ {
+ if ( bDoEdit )
+ aTextWindow.GrabFocus();
+ aTextWindow.SetTextString( rString );
+ EditView* pView = aTextWindow.GetEditView();
+ if (pView)
+ {
+ xub_StrLen nLen = rString.Len();
+
+ if ( nLen > 0 )
+ {
+ nLen--;
+ pView->SetSelection( ESelection( 0, nLen, 0, nLen ) );
+ }
+
+ pScMod->InputChanged(pView);
+ if ( bDoEdit )
+ SetOkCancelMode(); // nicht, wenn gleich hinterher Enter/Cancel
+
+ pView->SetEditEngineUpdateMode(TRUE);
+ }
+ }
+}
+
+void ScInputWindow::SetPosString( const String& rStr )
+{
+ aWndPos.SetPos( rStr );
+}
+
+void ScInputWindow::SetTextString( const String& rString )
+{
+ if (rString.Len() <= 32767)
+ aTextWindow.SetTextString(rString);
+ else
+ {
+ String aNew = rString;
+ aNew.Erase(32767);
+ aTextWindow.SetTextString(aNew);
+ }
+}
+
+void ScInputWindow::SetOkCancelMode()
+{
+ //! new method at ScModule to query if function autopilot is open
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
+
+ ScModule* pScMod = SC_MOD();
+ SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
+ if (!bIsOkCancelMode)
+ {
+ BOOL bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ RemoveItem( 3 ); // SID_INPUT_SUM und SID_INPUT_EQUAL entfernen
+ RemoveItem( 3 );
+ InsertItem( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ), 0, 3 );
+ InsertItem( SID_INPUT_OK, IMAGE( SID_INPUT_OK ), 0, 4 );
+ SetItemText ( SID_INPUT_CANCEL, aTextCancel );
+ SetHelpId ( SID_INPUT_CANCEL, HID_INSWIN_CANCEL );
+ SetItemText ( SID_INPUT_OK, aTextOk );
+ SetHelpId ( SID_INPUT_OK, HID_INSWIN_OK );
+ bIsOkCancelMode = TRUE;
+ }
+}
+
+void ScInputWindow::SetSumAssignMode()
+{
+ //! new method at ScModule to query if function autopilot is open
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) );
+
+ ScModule* pScMod = SC_MOD();
+ SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
+ if (bIsOkCancelMode)
+ {
+ BOOL bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ // SID_INPUT_CANCEL, und SID_INPUT_OK entfernen
+ RemoveItem( 3 );
+ RemoveItem( 3 );
+ InsertItem( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), 0, 3 );
+ InsertItem( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), 0, 4 );
+ SetItemText ( SID_INPUT_SUM, aTextSum );
+ SetHelpId ( SID_INPUT_SUM, HID_INSWIN_SUMME );
+ SetItemText ( SID_INPUT_EQUAL, aTextEqual );
+ SetHelpId ( SID_INPUT_EQUAL, HID_INSWIN_FUNC );
+ bIsOkCancelMode = FALSE;
+
+ SetFormulaMode(FALSE); // kein editieren -> keine Formel
+ }
+}
+
+void ScInputWindow::SetFormulaMode( BOOL bSet )
+{
+ aWndPos.SetFormulaMode(bSet);
+ aTextWindow.SetFormulaMode(bSet);
+}
+
+void __EXPORT ScInputWindow::SetText( const String& rString )
+{
+ ToolBox::SetText(rString);
+}
+
+String __EXPORT ScInputWindow::GetText() const
+{
+ return ToolBox::GetText();
+}
+
+BOOL ScInputWindow::IsInputActive()
+{
+ return aTextWindow.IsInputActive();
+}
+
+EditView* ScInputWindow::GetEditView()
+{
+ return aTextWindow.GetEditView();
+}
+
+void ScInputWindow::MakeDialogEditView()
+{
+ aTextWindow.MakeDialogEditView();
+}
+
+void ScInputWindow::StopEditEngine( BOOL bAll )
+{
+ aTextWindow.StopEditEngine( bAll );
+}
+
+void ScInputWindow::TextGrabFocus()
+{
+ aTextWindow.GrabFocus();
+}
+
+void ScInputWindow::TextInvalidate()
+{
+ aTextWindow.Invalidate();
+}
+
+void ScInputWindow::SwitchToTextWin()
+{
+ // used for shift-ctrl-F2
+
+ aTextWindow.StartEditEngine();
+ if ( SC_MOD()->IsEditMode() )
+ {
+ aTextWindow.GrabFocus();
+ EditView* pView = aTextWindow.GetEditView();
+ if (pView)
+ {
+ xub_StrLen nLen = pView->GetEditEngine()->GetTextLen(0);
+ ESelection aSel( 0, nLen, 0, nLen );
+ pView->SetSelection( aSel ); // set cursor to end of text
+ }
+ }
+}
+
+void ScInputWindow::PosGrabFocus()
+{
+ aWndPos.GrabFocus();
+}
+
+void ScInputWindow::EnableButtons( BOOL bEnable )
+{
+ // when enabling buttons, always also enable the input window itself
+ if ( bEnable && !IsEnabled() )
+ Enable();
+
+ EnableItem( SID_INPUT_FUNCTION, bEnable );
+ EnableItem( bIsOkCancelMode ? SID_INPUT_CANCEL : SID_INPUT_SUM, bEnable );
+ EnableItem( bIsOkCancelMode ? SID_INPUT_OK : SID_INPUT_EQUAL, bEnable );
+// Invalidate();
+}
+
+void ScInputWindow::StateChanged( StateChangedType nType )
+{
+ ToolBox::StateChanged( nType );
+
+ if ( nType == STATE_CHANGE_INITSHOW ) Resize();
+}
+
+void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ // update item images
+
+ ScModule* pScMod = SC_MOD();
+ SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod );
+ BOOL bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+ // IMAGE macro uses pScMod, pImgMgr, bHC
+
+ SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) );
+ if ( bIsOkCancelMode )
+ {
+ SetItemImage( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ) );
+ SetItemImage( SID_INPUT_OK, IMAGE( SID_INPUT_OK ) );
+ }
+ else
+ {
+ SetItemImage( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ) );
+ SetItemImage( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ) );
+ }
+ }
+
+ ToolBox::DataChanged( rDCEvt );
+}
+
+//========================================================================
+// Eingabefenster
+//========================================================================
+
+ScTextWnd::ScTextWnd( Window* pParent )
+ : Window ( pParent, WinBits(WB_HIDE | WB_BORDER) ),
+ DragSourceHelper( this ),
+ pEditEngine ( NULL ),
+ pEditView ( NULL ),
+ bIsInsertMode( TRUE ),
+ bFormulaMode ( FALSE ),
+ bInputMode ( FALSE )
+{
+ EnableRTL( FALSE ); // #106269# EditEngine can't be used with VCL EnableRTL
+
+ bIsRTL = GetSettings().GetLayoutRTL();
+
+ // #79096# always use application font, so a font with cjk chars can be installed
+ Font aAppFont = GetFont();
+ aTextFont = aAppFont;
+ aTextFont.SetSize( PixelToLogic( aAppFont.GetSize(), MAP_TWIP ) ); // AppFont ist in Pixeln
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ Color aBgColor= rStyleSettings.GetWindowColor();
+ Color aTxtColor= rStyleSettings.GetWindowTextColor();
+
+ aTextFont.SetTransparent ( TRUE );
+ aTextFont.SetFillColor ( aBgColor );
+ //aTextFont.SetColor ( COL_FIELDTEXT );
+ aTextFont.SetColor (aTxtColor);
+ aTextFont.SetWeight ( WEIGHT_NORMAL );
+
+ SetSizePixel ( Size(1,TBX_WINDOW_HEIGHT) );
+ SetBackground ( aBgColor );
+ SetLineColor ( COL_BLACK );
+ SetMapMode ( MAP_TWIP );
+ SetPointer ( POINTER_TEXT );
+}
+
+__EXPORT ScTextWnd::~ScTextWnd()
+{
+ while (!maAccTextDatas.empty()) {
+ maAccTextDatas.back()->Dispose();
+ }
+ delete pEditView;
+ delete pEditEngine;
+}
+
+void __EXPORT ScTextWnd::Paint( const Rectangle& rRec )
+{
+ if (pEditView)
+ pEditView->Paint( rRec );
+ else
+ {
+ SetFont( aTextFont );
+
+ long nDiff = GetOutputSizePixel().Height()
+ - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+// if (nDiff<2) nDiff=2; // mind. 1 Pixel
+
+ long nStartPos = TEXT_STARTPOS;
+ if ( bIsRTL )
+ {
+ // right-align
+ nStartPos += GetOutputSizePixel().Width() - 2*TEXT_STARTPOS -
+ LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width();
+
+ // LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include SvxFrameDirectionItem
+ }
+
+ DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString );
+ }
+}
+
+void __EXPORT ScTextWnd::Resize()
+{
+ if (pEditView)
+ {
+ Size aSize = GetOutputSizePixel();
+ long nDiff = aSize.Height()
+ - LogicToPixel( Size( 0, GetTextHeight() ) ).Height();
+
+#ifdef OS2_DOCH_NICHT
+ nDiff-=2; // wird durch 2 geteilt
+ // passt sonst nicht zur normalen Textausgabe
+#endif
+
+ aSize.Width() -= 2 * TEXT_STARTPOS - 1;
+
+ pEditView->SetOutputArea(
+ PixelToLogic( Rectangle( Point( TEXT_STARTPOS, (nDiff > 0) ? nDiff/2 : 1 ),
+ aSize ) ) );
+ }
+}
+
+void __EXPORT ScTextWnd::MouseMove( const MouseEvent& rMEvt )
+{
+ if (pEditView)
+ pEditView->MouseMove( rMEvt );
+}
+
+void __EXPORT ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if (!HasFocus())
+ {
+ StartEditEngine();
+ if ( SC_MOD()->IsEditMode() )
+ GrabFocus();
+ }
+
+ if (pEditView)
+ {
+ pEditView->SetEditEngineUpdateMode( TRUE );
+ pEditView->MouseButtonDown( rMEvt );
+ }
+}
+
+void __EXPORT ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if (pEditView)
+ if (pEditView->MouseButtonUp( rMEvt ))
+ {
+ if ( rMEvt.IsMiddle() &&
+ GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION )
+ {
+ // EditView may have pasted from selection
+ SC_MOD()->InputChanged( pEditView );
+ }
+ else
+ SC_MOD()->InputSelection( pEditView );
+ }
+}
+
+void __EXPORT ScTextWnd::Command( const CommandEvent& rCEvt )
+{
+ bInputMode = TRUE;
+ USHORT nCommand = rCEvt.GetCommand();
+ if ( pEditView /* && ( nCommand == COMMAND_STARTDRAG || nCommand == COMMAND_VOICE ) */ )
+ {
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pStartViewSh = ScTabViewShell::GetActiveViewShell();
+
+ // #109441# don't modify the font defaults here - the right defaults are
+ // already set in StartEditEngine when the EditEngine is created
+
+ // #63263# verhindern, dass die EditView beim View-Umschalten wegkommt
+ pScMod->SetInEditCommand( TRUE );
+ pEditView->Command( rCEvt );
+ pScMod->SetInEditCommand( FALSE );
+
+ // #48929# COMMAND_STARTDRAG heiss noch lange nicht, dass der Inhalt geaendert wurde
+ // darum in dem Fall kein InputChanged
+ //! erkennen, ob mit Move gedraggt wurde, oder Drag&Move irgendwie verbieten
+
+ if ( nCommand == COMMAND_STARTDRAG )
+ {
+ // ist auf eine andere View gedraggt worden?
+ ScTabViewShell* pEndViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pEndViewSh != pStartViewSh && pStartViewSh != NULL )
+ {
+ ScViewData* pViewData = pStartViewSh->GetViewData();
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pStartViewSh );
+ if ( pHdl && pViewData->HasEditView( pViewData->GetActivePart() ) )
+ {
+ pHdl->CancelHandler();
+ pViewData->GetView()->ShowCursor(); // fehlt bei KillEditView, weil nicht aktiv
+ }
+ }
+ }
+ else if ( nCommand == COMMAND_CURSORPOS )
+ {
+ // don't call InputChanged for COMMAND_CURSORPOS
+ }
+ else if ( nCommand == COMMAND_INPUTLANGUAGECHANGE )
+ {
+ // #i55929# Font and font size state depends on input language if nothing is selected,
+ // so the slots have to be invalidated when the input language is changed.
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ {
+ SfxBindings& rBindings = pViewFrm->GetBindings();
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ }
+ }
+ else
+ SC_MOD()->InputChanged( pEditView );
+ }
+ else
+ Window::Command(rCEvt); // sonst soll sich die Basisklasse drum kuemmern...
+
+ bInputMode = FALSE;
+}
+
+void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
+{
+ if ( pEditView )
+ {
+ CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, TRUE );
+ pEditView->Command( aDragEvent );
+
+ // handling of d&d to different view (CancelHandler) can't be done here,
+ // because the call returns before d&d is complete.
+ }
+}
+
+void __EXPORT ScTextWnd::KeyInput(const KeyEvent& rKEvt)
+{
+ bInputMode = TRUE;
+ if (!SC_MOD()->InputKeyEvent( rKEvt ))
+ {
+ BOOL bUsed = FALSE;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ bUsed = pViewSh->SfxKeyInput(rKEvt); // nur Acceleratoren, keine Eingabe
+ if (!bUsed)
+ Window::KeyInput( rKEvt );
+ }
+ bInputMode = FALSE;
+}
+
+void __EXPORT ScTextWnd::GetFocus()
+{
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ pViewSh->SetFormShellAtTop( FALSE ); // focus in input line -> FormShell no longer on top
+}
+
+void __EXPORT ScTextWnd::LoseFocus()
+{
+}
+
+String __EXPORT ScTextWnd::GetText() const
+{
+ // ueberladen, um per Testtool an den Text heranzukommen
+
+ if ( pEditEngine )
+ return pEditEngine->GetText();
+ else
+ return GetTextString();
+}
+
+void ScTextWnd::SetFormulaMode( BOOL bSet )
+{
+ if ( bSet != bFormulaMode )
+ {
+ bFormulaMode = bSet;
+ UpdateAutoCorrFlag();
+ }
+}
+
+void ScTextWnd::UpdateAutoCorrFlag()
+{
+ if ( pEditEngine )
+ {
+ ULONG nControl = pEditEngine->GetControlWord();
+ ULONG nOld = nControl;
+ if ( bFormulaMode )
+ nControl &= ~EE_CNTRL_AUTOCORRECT; // keine Autokorrektur in Formeln
+ else
+ nControl |= EE_CNTRL_AUTOCORRECT; // sonst schon
+ if ( nControl != nOld )
+ pEditEngine->SetControlWord( nControl );
+ }
+}
+
+void lcl_ExtendEditFontAttribs( SfxItemSet& rSet )
+{
+ const SfxPoolItem& rFontItem = rSet.Get( EE_CHAR_FONTINFO );
+ rSet.Put( rFontItem, EE_CHAR_FONTINFO_CJK );
+ rSet.Put( rFontItem, EE_CHAR_FONTINFO_CTL );
+ const SfxPoolItem& rHeightItem = rSet.Get( EE_CHAR_FONTHEIGHT );
+ rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CJK );
+ rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CTL );
+ const SfxPoolItem& rWeightItem = rSet.Get( EE_CHAR_WEIGHT );
+ rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
+ rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
+ const SfxPoolItem& rItalicItem = rSet.Get( EE_CHAR_ITALIC );
+ rSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
+ rSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
+ const SfxPoolItem& rLangItem = rSet.Get( EE_CHAR_LANGUAGE );
+ rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
+ rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
+}
+
+void lcl_ModifyRTLDefaults( SfxItemSet& rSet )
+{
+ rSet.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+
+ // always using rtl writing direction would break formulas
+ //rSet.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
+
+ // PaperSize width is limited to USHRT_MAX in RTL mode (because of EditEngine's
+ // USHORT values in EditLine), so the text may be wrapped and line spacing must be
+ // increased to not see the beginning of the next line.
+ SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 200 );
+ rSet.Put( aItem );
+}
+
+void lcl_ModifyRTLVisArea( EditView* pEditView )
+{
+ Rectangle aVisArea = pEditView->GetVisArea();
+ Size aPaper = pEditView->GetEditEngine()->GetPaperSize();
+ long nDiff = aPaper.Width() - aVisArea.Right();
+ aVisArea.Left() += nDiff;
+ aVisArea.Right() += nDiff;
+ pEditView->SetVisArea(aVisArea);
+}
+
+void ScTextWnd::StartEditEngine()
+{
+ // #31147# Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren
+ SfxObjectShell* pObjSh = SfxObjectShell::Current();
+ if ( pObjSh && pObjSh->IsInModalMode() )
+ return;
+
+ if ( !pEditView || !pEditEngine )
+ {
+ ScFieldEditEngine* pNew;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ {
+ const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+ pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+ }
+ else
+ pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, TRUE );
+ pNew->SetExecuteURL( FALSE );
+ pEditEngine = pNew;
+
+ pEditEngine->SetUpdateMode( FALSE );
+ pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
+ pEditEngine->SetWordDelimiters(
+ ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
+
+ UpdateAutoCorrFlag();
+
+ {
+ SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+ pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
+ lcl_ExtendEditFontAttribs( *pSet );
+ // turn off script spacing to match DrawText output
+ pSet->Put( SvxScriptSpaceItem( FALSE, EE_PARA_ASIANCJKSPACING ) );
+ if ( bIsRTL )
+ lcl_ModifyRTLDefaults( *pSet );
+ pEditEngine->SetDefaults( pSet );
+ }
+
+ // #57254# Wenn in der Zelle URL-Felder enthalten sind, muessen die auch in
+ // die Eingabezeile uebernommen werden, weil sonst die Positionen nicht stimmen.
+
+ BOOL bFilled = FALSE;
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ if ( pHdl ) //! Testen, ob's der richtige InputHdl ist?
+ bFilled = pHdl->GetTextAndFields( *pEditEngine );
+
+ pEditEngine->SetUpdateMode( TRUE );
+
+ // aString ist die Wahrheit...
+ if ( bFilled && pEditEngine->GetText() == aString )
+ Invalidate(); // Repaint fuer (hinterlegte) Felder
+ else
+ pEditEngine->SetText(aString); // dann wenigstens den richtigen Text
+
+ pEditView = new EditView( pEditEngine, this );
+ pEditView->SetInsertMode(bIsInsertMode);
+
+ // Text aus Clipboard wird als ASCII einzeilig uebernommen
+ ULONG n = pEditView->GetControlWord();
+ pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE );
+
+ pEditEngine->InsertView( pEditView, EE_APPEND );
+
+ Resize();
+
+ if ( bIsRTL )
+ lcl_ModifyRTLVisArea( pEditView );
+
+ pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl));
+
+ if (!maAccTextDatas.empty())
+ maAccTextDatas.back()->StartEdit();
+
+ // as long as EditEngine and DrawText sometimes differ for CTL text,
+ // repaint now to have the EditEngine's version visible
+// SfxObjectShell* pObjSh = SfxObjectShell::Current();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); // any document
+ BYTE nScript = pDoc->GetStringScriptType( aString );
+ if ( nScript & SCRIPTTYPE_COMPLEX )
+ Invalidate();
+ }
+ }
+
+ SC_MOD()->SetInputMode( SC_INPUT_TOP );
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
+}
+
+IMPL_LINK(ScTextWnd, NotifyHdl, EENotify*, EMPTYARG)
+{
+ if (pEditView && !bInputMode)
+ {
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+
+ // #105354# Use the InputHandler's InOwnChange flag to prevent calling InputChanged
+ // while an InputHandler method is modifying the EditEngine content
+
+ if ( pHdl && !pHdl->IsInOwnChange() )
+ pHdl->InputChanged( pEditView, TRUE ); // #i20282# InputChanged must know if called from modify handler
+ }
+
+ return 0;
+}
+
+void ScTextWnd::StopEditEngine( BOOL bAll )
+{
+ if (pEditView)
+ {
+ if (!maAccTextDatas.empty())
+ maAccTextDatas.back()->EndEdit();
+
+ ScModule* pScMod = SC_MOD();
+
+ if (!bAll)
+ pScMod->InputSelection( pEditView );
+ aString = pEditEngine->GetText();
+ bIsInsertMode = pEditView->IsInsertMode();
+ BOOL bSelection = pEditView->HasSelection();
+ pEditEngine->SetModifyHdl(Link());
+ DELETEZ(pEditView);
+ DELETEZ(pEditEngine);
+
+ if ( pScMod->IsEditMode() && !bAll )
+ pScMod->SetInputMode(SC_INPUT_TABLE);
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT );
+
+ if (bSelection)
+ Invalidate(); // damit Selektion nicht stehenbleibt
+ }
+}
+
+void ScTextWnd::SetTextString( const String& rNewString )
+{
+ if ( rNewString != aString )
+ {
+ bInputMode = TRUE;
+
+ // Position der Aenderung suchen, nur Rest painten
+
+ long nInvPos = 0;
+ long nStartPos = 0;
+ long nTextSize = 0;
+
+ if (!pEditEngine)
+ {
+ BOOL bPaintAll;
+ if ( bIsRTL )
+ bPaintAll = TRUE;
+ else
+ {
+ // test if CTL script type is involved
+ BYTE nOldScript = 0;
+ BYTE nNewScript = 0;
+ SfxObjectShell* pObjSh = SfxObjectShell::Current();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ // any document can be used (used only for its break iterator)
+ ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();
+ nOldScript = pDoc->GetStringScriptType( aString );
+ nNewScript = pDoc->GetStringScriptType( rNewString );
+ }
+ bPaintAll = ( nOldScript & SCRIPTTYPE_COMPLEX ) || ( nNewScript & SCRIPTTYPE_COMPLEX );
+ }
+
+ if ( bPaintAll )
+ {
+ // if CTL is involved, the whole text has to be redrawn
+ Invalidate();
+ }
+ else
+ {
+ xub_StrLen nDifPos;
+ if (rNewString.Len() > aString.Len())
+ nDifPos = rNewString.Match(aString);
+ else
+ nDifPos = aString.Match(rNewString);
+
+ long nSize1 = GetTextWidth(aString);
+ long nSize2 = GetTextWidth(rNewString);
+ if ( nSize1>0 && nSize2>0 )
+ nTextSize = Max( nSize1, nSize2 );
+ else
+ nTextSize = GetOutputSize().Width(); // Ueberlauf
+
+ if (nDifPos == STRING_MATCH)
+ nDifPos = 0;
+
+ // -1 wegen Rundung und "A"
+ Point aLogicStart = PixelToLogic(Point(TEXT_STARTPOS-1,0));
+ nStartPos = aLogicStart.X();
+ nInvPos = nStartPos;
+ if (nDifPos)
+ nInvPos += GetTextWidth(aString,0,nDifPos);
+
+ USHORT nFlags = 0;
+ if ( nDifPos == aString.Len() ) // only new characters appended
+ nFlags = INVALIDATE_NOERASE; // then background is already clear
+
+ Invalidate( Rectangle( nInvPos, 0,
+ nStartPos+nTextSize, GetOutputSize().Height()-1 ),
+ nFlags );
+ }
+ }
+ else
+ {
+ pEditEngine->SetText(rNewString);
+ }
+
+ aString = rNewString;
+
+ if (!maAccTextDatas.empty())
+ maAccTextDatas.back()->TextChanged();
+
+ bInputMode = FALSE;
+ }
+}
+
+const String& ScTextWnd::GetTextString() const
+{
+ return aString;
+}
+
+BOOL ScTextWnd::IsInputActive()
+{
+ return HasFocus();
+}
+
+EditView* ScTextWnd::GetEditView()
+{
+ return pEditView;
+}
+
+void ScTextWnd::MakeDialogEditView()
+{
+ if ( pEditView ) return;
+
+ ScFieldEditEngine* pNew;
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ {
+ const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument();
+ pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() );
+ }
+ else
+ pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, TRUE );
+ pNew->SetExecuteURL( FALSE );
+ pEditEngine = pNew;
+
+ pEditEngine->SetUpdateMode( FALSE );
+ pEditEngine->SetWordDelimiters( pEditEngine->GetWordDelimiters() += '=' );
+ pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) );
+
+ SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+ pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont );
+ lcl_ExtendEditFontAttribs( *pSet );
+ if ( bIsRTL )
+ lcl_ModifyRTLDefaults( *pSet );
+ pEditEngine->SetDefaults( pSet );
+ pEditEngine->SetUpdateMode( TRUE );
+
+ pEditView = new EditView( pEditEngine, this );
+ pEditEngine->InsertView( pEditView, EE_APPEND );
+
+ Resize();
+
+ if ( bIsRTL )
+ lcl_ModifyRTLVisArea( pEditView );
+
+ if (!maAccTextDatas.empty())
+ maAccTextDatas.back()->StartEdit();
+}
+
+void ScTextWnd::ImplInitSettings()
+{
+ bIsRTL = GetSettings().GetLayoutRTL();
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+
+ Color aBgColor= rStyleSettings.GetWindowColor();
+ Color aTxtColor= rStyleSettings.GetWindowTextColor();
+
+ aTextFont.SetFillColor ( aBgColor );
+ aTextFont.SetColor (aTxtColor);
+ SetBackground ( aBgColor );
+ Invalidate();
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScTextWnd::CreateAccessible()
+{
+ return new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), NULL, this,
+ rtl::OUString(String(ScResId(STR_ACC_EDITLINE_NAME))),
+ rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), EditLine);
+}
+
+void ScTextWnd::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
+{
+ OSL_ENSURE( ::std::find( maAccTextDatas.begin(), maAccTextDatas.end(), &rTextData ) == maAccTextDatas.end(),
+ "ScTextWnd::InsertAccessibleTextData - passed object already registered" );
+ maAccTextDatas.push_back( &rTextData );
+}
+
+void ScTextWnd::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData )
+{
+ AccTextDataVector::iterator aEnd = maAccTextDatas.end();
+ AccTextDataVector::iterator aIt = ::std::find( maAccTextDatas.begin(), aEnd, &rTextData );
+ OSL_ENSURE( aIt != aEnd, "ScTextWnd::RemoveAccessibleTextData - passed object not registered" );
+ if( aIt != aEnd )
+ maAccTextDatas.erase( aIt );
+}
+
+// -----------------------------------------------------------------------
+
+void ScTextWnd::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings();
+ Invalidate();
+ }
+ else
+ Window::DataChanged( rDCEvt );
+}
+
+
+//========================================================================
+// Positionsfenster
+//========================================================================
+
+ScPosWnd::ScPosWnd( Window* pParent ) :
+ ComboBox ( pParent, WinBits(WB_HIDE | WB_DROPDOWN) ),
+ pAccel ( NULL ),
+ nTipVisible ( 0 ),
+ bFormulaMode( FALSE )
+{
+ Size aSize( GetTextWidth( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GW99999:GW99999")) ),
+ GetTextHeight() );
+ aSize.Width() += 25; // ??
+ aSize.Height() = CalcWindowSizePixel(11); // Funktionen: 10 MRU + "andere..."
+ SetSizePixel( aSize );
+
+ FillRangeNames();
+
+ StartListening( *SFX_APP() ); // fuer Navigator-Bereichsnamen-Updates
+}
+
+__EXPORT ScPosWnd::~ScPosWnd()
+{
+ EndListening( *SFX_APP() );
+
+ HideTip();
+
+ delete pAccel;
+}
+
+void ScPosWnd::SetFormulaMode( BOOL bSet )
+{
+ if ( bSet != bFormulaMode )
+ {
+ bFormulaMode = bSet;
+
+ if ( bSet )
+ FillFunctions();
+ else
+ FillRangeNames();
+
+ HideTip();
+ }
+}
+
+void ScPosWnd::SetPos( const String& rPosStr )
+{
+ if ( aPosStr != rPosStr )
+ {
+ aPosStr = rPosStr;
+ SetText(aPosStr);
+ }
+}
+
+void ScPosWnd::FillRangeNames()
+{
+ Clear();
+
+ SfxObjectShell* pObjSh = SfxObjectShell::Current();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument();
+
+ // per Hand sortieren, weil Funktionen nicht sortiert werden:
+
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ USHORT nCount = pRangeNames->GetCount();
+ if ( nCount > 0 )
+ {
+ USHORT nValidCount = 0;
+ ScRange aDummy;
+ USHORT i;
+ for ( i=0; i<nCount; i++ )
+ {
+ ScRangeData* pData = (*pRangeNames)[i];
+ if (pData->IsValidReference(aDummy))
+ nValidCount++;
+ }
+ if ( nValidCount )
+ {
+ ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
+ USHORT j;
+ for ( i=0, j=0; i<nCount; i++ )
+ {
+ ScRangeData* pData = (*pRangeNames)[i];
+ if (pData->IsValidReference(aDummy))
+ ppSortArray[j++] = pData;
+ }
+#ifndef ICC
+ qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ &ScRangeData_QsortNameCompare );
+#else
+ qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ ICCQsortNameCompare );
+#endif
+ for ( j=0; j<nValidCount; j++ )
+ InsertEntry( ppSortArray[j]->GetName() );
+ delete [] ppSortArray;
+ }
+ }
+ }
+ SetText(aPosStr);
+}
+
+void ScPosWnd::FillFunctions()
+{
+ Clear();
+
+ String aFirstName;
+ const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
+ USHORT nMRUCount = rOpt.GetLRUFuncListCount();
+ const USHORT* pMRUList = rOpt.GetLRUFuncList();
+ if (pMRUList)
+ {
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ ULONG nListCount = pFuncList->GetCount();
+ for (USHORT i=0; i<nMRUCount; i++)
+ {
+ USHORT nId = pMRUList[i];
+ for (ULONG j=0; j<nListCount; j++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction( j );
+ if ( pDesc->nFIndex == nId && pDesc->pFuncName )
+ {
+ InsertEntry( *pDesc->pFuncName );
+ if (!aFirstName.Len())
+ aFirstName = *pDesc->pFuncName;
+ break; // nicht weitersuchen
+ }
+ }
+ }
+ }
+
+ //! Eintrag "Andere..." fuer Funktions-Autopilot wieder aufnehmen,
+ //! wenn der Funktions-Autopilot mit dem bisher eingegebenen Text arbeiten kann!
+
+// InsertEntry( ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) );
+
+ SetText(aFirstName);
+}
+
+void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( !bFormulaMode )
+ {
+ // muss die Liste der Bereichsnamen updgedated werden?
+
+ if ( rHint.ISA(SfxSimpleHint) )
+ {
+ ULONG nHintId = ((SfxSimpleHint&)rHint).GetId();
+ if ( nHintId == SC_HINT_AREAS_CHANGED || nHintId == SC_HINT_NAVIGATOR_UPDATEALL)
+ FillRangeNames();
+ }
+ else if ( rHint.ISA(SfxEventHint) )
+ {
+ ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
+ if ( nEventId == SFX_EVENT_ACTIVATEDOC )
+ FillRangeNames();
+ }
+ }
+}
+
+void ScPosWnd::HideTip()
+{
+ if ( nTipVisible )
+ {
+ Help::HideTip( nTipVisible );
+ nTipVisible = 0;
+ }
+}
+
+ScNameInputType lcl_GetInputType( const String& rText )
+{
+ ScNameInputType eRet = SC_NAME_INPUT_BAD_NAME; // the more general error
+
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ // test in same order as in SID_CURRENTCELL execute
+
+ ScRange aRange;
+ ScAddress aAddress;
+ ScRangeUtil aRangeUtil;
+ SCTAB nNameTab;
+ sal_Int32 nNumeric;
+
+ if ( aRange.Parse( rText, pDoc, eConv ) & SCA_VALID )
+ eRet = SC_NAME_INPUT_NAMEDRANGE;
+ else if ( aAddress.Parse( rText, pDoc, eConv ) & SCA_VALID )
+ eRet = SC_NAME_INPUT_CELL;
+ else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_NAMES, eConv ) )
+ eRet = SC_NAME_INPUT_NAMEDRANGE;
+ else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_DBASE, eConv ) )
+ eRet = SC_NAME_INPUT_DATABASE;
+ else if ( ByteString( rText, RTL_TEXTENCODING_ASCII_US ).IsNumericAscii() &&
+ ( nNumeric = rText.ToInt32() ) > 0 && nNumeric <= MAXROW+1 )
+ eRet = SC_NAME_INPUT_ROW;
+ else if ( pDoc->GetTable( rText, nNameTab ) )
+ eRet = SC_NAME_INPUT_SHEET;
+ else if ( ScRangeData::IsNameValid( rText, pDoc ) ) // nothing found, create new range?
+ {
+ if ( pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ eRet = SC_NAME_INPUT_DEFINE;
+ else
+ eRet = SC_NAME_INPUT_BAD_SELECTION;
+ }
+ else
+ eRet = SC_NAME_INPUT_BAD_NAME;
+ }
+
+ return eRet;
+}
+
+void ScPosWnd::Modify()
+{
+ ComboBox::Modify();
+
+ HideTip();
+
+ if ( !IsTravelSelect() && !bFormulaMode )
+ {
+ // determine the action that would be taken for the current input
+
+ ScNameInputType eType = lcl_GetInputType( GetText() ); // uses current view
+ USHORT nStrId = 0;
+ switch ( eType )
+ {
+ case SC_NAME_INPUT_CELL:
+ nStrId = STR_NAME_INPUT_CELL;
+ break;
+ case SC_NAME_INPUT_RANGE:
+ case SC_NAME_INPUT_NAMEDRANGE:
+ nStrId = STR_NAME_INPUT_RANGE; // named range or range reference
+ break;
+ case SC_NAME_INPUT_DATABASE:
+ nStrId = STR_NAME_INPUT_DBRANGE;
+ break;
+ case SC_NAME_INPUT_ROW:
+ nStrId = STR_NAME_INPUT_ROW;
+ break;
+ case SC_NAME_INPUT_SHEET:
+ nStrId = STR_NAME_INPUT_SHEET;
+ break;
+ case SC_NAME_INPUT_DEFINE:
+ nStrId = STR_NAME_INPUT_DEFINE;
+ break;
+ default:
+ // other cases (error): no tip help
+ break;
+ }
+
+ if ( nStrId )
+ {
+ // show the help tip at the text cursor position
+
+ Window* pWin = GetSubEdit();
+ if (!pWin)
+ pWin = this;
+ Point aPos;
+ Cursor* pCur = pWin->GetCursor();
+ if (pCur)
+ aPos = pWin->LogicToPixel( pCur->GetPos() );
+ aPos = pWin->OutputToScreenPixel( aPos );
+ Rectangle aRect( aPos, aPos );
+
+ String aText = ScGlobal::GetRscString( nStrId );
+ USHORT nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
+ nTipVisible = Help::ShowTip(pWin, aRect, aText, nAlign);
+ }
+ }
+}
+
+void __EXPORT ScPosWnd::Select()
+{
+ ComboBox::Select(); // in VCL gibt GetText() erst danach den ausgewaehlten Eintrag
+
+ HideTip();
+
+ if (!IsTravelSelect())
+ DoEnter();
+}
+
+void ScPosWnd::DoEnter()
+{
+ String aText = GetText();
+ if ( aText.Len() )
+ {
+ if ( bFormulaMode )
+ {
+ ScModule* pScMod = SC_MOD();
+ if ( aText == ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) )
+ {
+ // Funktions-Autopilot
+ //! mit dem bisher eingegebenen Text weiterarbeiten !!!
+
+ //! new method at ScModule to query if function autopilot is open
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) )
+ pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ }
+ else
+ {
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if (pHdl)
+ pHdl->InsertFunction( aText );
+ }
+ }
+ else
+ {
+ // depending on the input, select something or create a new named range
+
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ {
+ ScNameInputType eType = lcl_GetInputType( aText );
+ if ( eType == SC_NAME_INPUT_BAD_NAME || eType == SC_NAME_INPUT_BAD_SELECTION )
+ {
+ USHORT nId = ( eType == SC_NAME_INPUT_BAD_NAME ) ? STR_NAME_ERROR_NAME : STR_NAME_ERROR_SELECTION;
+ pViewSh->ErrorMessage( nId );
+ }
+ else if ( eType == SC_NAME_INPUT_DEFINE )
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangeName* pNames = pDoc->GetRangeName();
+ ScRange aSelection;
+ USHORT nIndex = 0;
+ if ( pNames && !pNames->SearchName( aText, nIndex ) &&
+ (pViewData->GetSimpleArea( aSelection ) == SC_MARK_SIMPLE) )
+ {
+ ScRangeName aNewRanges( *pNames );
+ ScAddress aCursor( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
+ String aContent;
+ aSelection.Format( aContent, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ ScRangeData* pNew = new ScRangeData( pDoc, aText, aContent, aCursor );
+ if ( aNewRanges.Insert(pNew) )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.ModifyRangeNames( aNewRanges );
+ pViewSh->UpdateInputHandler(TRUE);
+ }
+ else
+ delete pNew; // shouldn't happen
+ }
+ }
+ else
+ {
+ // for all selection types, excecute the SID_CURRENTCELL slot
+
+ SfxStringItem aPosItem( SID_CURRENTCELL, aText );
+ SfxBoolItem aUnmarkItem( FN_PARAM_1, TRUE ); // remove existing selection
+
+ pViewSh->GetViewData()->GetDispatcher().Execute( SID_CURRENTCELL,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aPosItem, &aUnmarkItem, 0L );
+ }
+ }
+ }
+ }
+ else
+ SetText( aPosStr );
+
+ ReleaseFocus_Impl();
+}
+
+long __EXPORT ScPosWnd::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+
+ switch ( pKEvt->GetKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ DoEnter();
+ nHandled = 1;
+ break;
+
+ case KEY_ESCAPE:
+ if (nTipVisible)
+ {
+ // escape when the tip help is shown: only hide the tip
+ HideTip();
+ }
+ else
+ {
+ if (!bFormulaMode)
+ SetText( aPosStr );
+ ReleaseFocus_Impl();
+ }
+ nHandled = 1;
+ break;
+ }
+ }
+
+ if ( !nHandled )
+ nHandled = ComboBox::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_LOSEFOCUS )
+ HideTip();
+
+ return nHandled;
+}
+
+void ScPosWnd::ReleaseFocus_Impl()
+{
+ HideTip();
+
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( PTR_CAST( ScTabViewShell, pCurSh ) );
+ if ( pHdl && pHdl->IsTopMode() )
+ {
+ // Focus wieder in die Eingabezeile?
+
+ ScInputWindow* pInputWin = pHdl->GetInputWindow();
+ if (pInputWin)
+ {
+ pInputWin->TextGrabFocus();
+ return;
+ }
+ }
+
+ // Focus auf die aktive View
+
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/lnktrans.cxx b/sc/source/ui/app/lnktrans.cxx
new file mode 100644
index 000000000000..3e31b8d1814c
--- /dev/null
+++ b/sc/source/ui/app/lnktrans.cxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+
+#include <svl/urlbmk.hxx>
+
+#include "lnktrans.hxx"
+#include "scmod.hxx"
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+ScLinkTransferObj::ScLinkTransferObj()
+{
+}
+
+ScLinkTransferObj::~ScLinkTransferObj()
+{
+}
+
+void ScLinkTransferObj::SetLinkURL( const String& rURL, const String& rText )
+{
+ aLinkURL = rURL;
+ aLinkText = rText;
+}
+
+void ScLinkTransferObj::AddSupportedFormats()
+{
+ if ( aLinkURL.Len() )
+ {
+ // TransferableHelper::SetINetBookmark formats
+
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_FILECONTENT );
+ }
+}
+
+sal_Bool ScLinkTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ sal_Bool bOK = sal_False;
+ if ( aLinkURL.Len() )
+ {
+ INetBookmark aBmk( aLinkURL, aLinkText );
+ bOK = SetINetBookmark( aBmk, rFlavor );
+ }
+ return bOK;
+}
+
+void ScLinkTransferObj::ObjectReleased()
+{
+ TransferableHelper::ObjectReleased();
+}
+
+void ScLinkTransferObj::DragFinished( sal_Int8 nDropAction )
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->ResetDragObject();
+
+ TransferableHelper::DragFinished( nDropAction );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/makefile.mk b/sc/source/ui/app/makefile.mk
new file mode 100644
index 000000000000..9d487ba207fc
--- /dev/null
+++ b/sc/source/ui/app/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=app
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/scmod.obj \
+ $(SLO)$/scmod2.obj \
+ $(SLO)$/scdll.obj \
+ $(SLO)$/typemap.obj \
+ $(SLO)$/transobj.obj \
+ $(SLO)$/drwtrans.obj \
+ $(SLO)$/lnktrans.obj \
+ $(SLO)$/seltrans.obj \
+ $(SLO)$/inputhdl.obj \
+ $(SLO)$/inputwin.obj \
+ $(SLO)$/rfindlst.obj \
+ $(SLO)$/uiitems.obj \
+ $(SLO)$/msgpool.obj \
+ $(SLO)$/client.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/drwtrans.obj \
+ $(SLO)$/scdll.obj \
+ $(SLO)$/scmod2.obj \
+ $(SLO)$/scmod.obj \
+ $(SLO)$/typemap.obj \
+ $(SLO)$/client.obj \
+ $(SLO)$/inputwin.obj
+
+#LIB3TARGET=$(SLB)$/ysclib.lib
+#LIB3OBJFILES=$(SLO)$/sclib.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(SRS)$/app.srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
diff --git a/sc/source/ui/app/msgpool.cxx b/sc/source/ui/app/msgpool.cxx
new file mode 100644
index 000000000000..9068594c2d53
--- /dev/null
+++ b/sc/source/ui/app/msgpool.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "scitems.hxx"
+#include <svx/dialogs.hrc>
+
+#include "sc.hrc"
+#include "docpool.hxx"
+#include "msgpool.hxx"
+
+//------------------------------------------------------------------------
+
+static SfxItemInfo __READONLY_DATA aMsgItemInfos[] =
+{
+ { 0, SFX_ITEM_POOLABLE }, // SCITEM_STRING
+ { 0, SFX_ITEM_POOLABLE }, // SCITEM_SEARCHDATA - nicht mehr benutzt !!!
+ { SID_SORT, SFX_ITEM_POOLABLE }, // SCITEM_SORTDATA
+ { SID_QUERY, SFX_ITEM_POOLABLE }, // SCITEM_QUERYDATA
+ { SID_SUBTOTALS, SFX_ITEM_POOLABLE }, // SCITEM_SUBTDATA
+ { SID_CONSOLIDATE, SFX_ITEM_POOLABLE }, // SCITEM_CONSOLIDATEDATA
+ { SID_PIVOT_TABLE, SFX_ITEM_POOLABLE }, // SCITEM_PIVOTDATA
+ { SID_SOLVE, SFX_ITEM_POOLABLE }, // SCITEM_SOLVEDATA
+ { SID_SCUSERLISTS, SFX_ITEM_POOLABLE }, // SCITEM_USERLIST
+ { SID_PRINTER_NOTFOUND_WARN, SFX_ITEM_POOLABLE } // SCITEM_PRINTWARN
+};
+
+//------------------------------------------------------------------------
+
+ScMessagePool::ScMessagePool()
+ : SfxItemPool ( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScMessagePool")),
+ MSGPOOL_START, MSGPOOL_END,
+ aMsgItemInfos, NULL ),
+ //
+ aGlobalStringItem ( SfxStringItem ( SCITEM_STRING, String() ) ),
+ aGlobalSearchItem ( SvxSearchItem ( SCITEM_SEARCHDATA ) ),
+ aGlobalSortItem ( ScSortItem ( SCITEM_SORTDATA, NULL ) ),
+ aGlobalQueryItem ( ScQueryItem ( SCITEM_QUERYDATA, NULL, NULL ) ),
+ aGlobalSubTotalItem ( ScSubTotalItem ( SCITEM_SUBTDATA, NULL, NULL ) ),
+ aGlobalConsolidateItem ( ScConsolidateItem ( SCITEM_CONSOLIDATEDATA, NULL ) ),
+ aGlobalPivotItem ( ScPivotItem ( SCITEM_PIVOTDATA, NULL, NULL, FALSE ) ),
+ aGlobalSolveItem ( ScSolveItem ( SCITEM_SOLVEDATA, NULL ) ),
+ aGlobalUserListItem ( ScUserListItem ( SCITEM_USERLIST ) ),
+ //
+ aPrintWarnItem ( SfxBoolItem ( SCITEM_PRINTWARN, FALSE ) )
+{
+ ppPoolDefaults = new SfxPoolItem*[MSGPOOL_END - MSGPOOL_START + 1];
+
+ ppPoolDefaults[SCITEM_STRING - MSGPOOL_START] = &aGlobalStringItem;
+ ppPoolDefaults[SCITEM_SEARCHDATA - MSGPOOL_START] = &aGlobalSearchItem;
+ ppPoolDefaults[SCITEM_SORTDATA - MSGPOOL_START] = &aGlobalSortItem;
+ ppPoolDefaults[SCITEM_QUERYDATA - MSGPOOL_START] = &aGlobalQueryItem;
+ ppPoolDefaults[SCITEM_SUBTDATA - MSGPOOL_START] = &aGlobalSubTotalItem;
+ ppPoolDefaults[SCITEM_CONSOLIDATEDATA - MSGPOOL_START] = &aGlobalConsolidateItem;
+ ppPoolDefaults[SCITEM_PIVOTDATA - MSGPOOL_START] = &aGlobalPivotItem;
+ ppPoolDefaults[SCITEM_SOLVEDATA - MSGPOOL_START] = &aGlobalSolveItem;
+ ppPoolDefaults[SCITEM_USERLIST - MSGPOOL_START] = &aGlobalUserListItem;
+ ppPoolDefaults[SCITEM_PRINTWARN - MSGPOOL_START] = &aPrintWarnItem;
+
+ SetDefaults( ppPoolDefaults );
+
+ pDocPool = new ScDocumentPool;
+
+ SetSecondaryPool( pDocPool );
+}
+
+
+__EXPORT ScMessagePool::~ScMessagePool()
+{
+ Delete();
+ SetSecondaryPool( NULL ); // before deleting defaults (accesses defaults)
+
+ for ( USHORT i=0; i <= MSGPOOL_END-MSGPOOL_START; i++ )
+ SetRefCount( *ppPoolDefaults[i], 0 );
+
+ delete[] ppPoolDefaults;
+
+ SfxItemPool::Free(pDocPool);
+}
+
+
+SfxMapUnit __EXPORT ScMessagePool::GetMetric( USHORT nWhich ) const
+{
+ // eigene Attribute: Twips, alles andere 1/100 mm
+
+ if ( nWhich >= ATTR_STARTINDEX && nWhich <= ATTR_ENDINDEX )
+ return SFX_MAPUNIT_TWIP;
+ else
+ return SFX_MAPUNIT_100TH_MM;
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/rfindlst.cxx b/sc/source/ui/app/rfindlst.cxx
new file mode 100644
index 000000000000..9831a8b95b04
--- /dev/null
+++ b/sc/source/ui/app/rfindlst.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "rfindlst.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+#define SC_RANGECOLORS 8
+
+static ColorData aColNames[SC_RANGECOLORS] =
+ { COL_LIGHTBLUE, COL_LIGHTRED, COL_LIGHTMAGENTA, COL_GREEN,
+ COL_BLUE, COL_RED, COL_MAGENTA, COL_BROWN };
+
+//==================================================================
+
+ScRangeFindList::ScRangeFindList(const String& rName) :
+ aDocName( rName ),
+ bHidden( FALSE )
+{
+}
+
+ScRangeFindList::~ScRangeFindList()
+{
+ void* pEntry = aEntries.First();
+ while ( pEntry )
+ {
+ delete (ScRangeFindData*) aEntries.Remove( pEntry );
+ pEntry = aEntries.Next();
+ }
+}
+
+ColorData ScRangeFindList::GetColorName( USHORT nIndex ) // static
+{
+ return aColNames[nIndex % SC_RANGECOLORS];
+}
+
+//==================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scdll.cxx b/sc/source/ui/app/scdll.cxx
new file mode 100644
index 000000000000..ca15f48364b9
--- /dev/null
+++ b/sc/source/ui/app/scdll.cxx
@@ -0,0 +1,349 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <editeng/eeitem.hxx>
+
+
+#include <svx/fmobjfac.hxx>
+#include <svx/objfac3d.hxx>
+#include <svx/tbxcolor.hxx>
+
+#include <sot/clsids.hxx>
+#include <sfx2/taskpane.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include <avmedia/mediaplayer.hxx>
+#include <avmedia/mediatoolbox.hxx>
+#include <comphelper/types.hxx>
+#include <svx/extrusioncolorcontrol.hxx>
+#include <svx/fontworkgallery.hxx>
+#include <svx/tbxcustomshapes.hxx>
+
+#include <svtools/parhtml.hxx>
+#include <sot/formats.hxx>
+#define SOT_FORMATSTR_ID_STARCALC_30 SOT_FORMATSTR_ID_STARCALC
+
+#include "scitems.hxx" // fuer tbxctrls etc.
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "cfgids.hxx"
+
+//! die Registrierung wird wegen CLOOKs in ein eigenes File wandern muessen...
+
+// Interface-Registrierung
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "prevwsh.hxx"
+#include "drawsh.hxx"
+#include "drformsh.hxx"
+#include "drtxtob.hxx"
+#include "editsh.hxx"
+#include "pivotsh.hxx"
+#include "auditsh.hxx"
+#include "cellsh.hxx"
+#include "oleobjsh.hxx"
+#include "chartsh.hxx"
+#include "graphsh.hxx"
+#include "mediash.hxx"
+#include "pgbrksh.hxx"
+
+#include "docpool.hxx"
+#include "appoptio.hxx"
+
+// Controls
+
+#include <svx/tbxalign.hxx>
+#include <svx/tbxctl.hxx>
+#include <svx/fillctrl.hxx>
+#include <svx/linectrl.hxx>
+#include <svx/tbcontrl.hxx>
+#include <svx/selctrl.hxx>
+#include <svx/insctrl.hxx>
+#include <svx/zoomctrl.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/modctrl.hxx>
+#include <svx/pszctrl.hxx>
+#include <svx/fntctl.hxx>
+#include <svx/fntszctl.hxx>
+#include <svx/grafctrl.hxx>
+#include <svx/galbrws.hxx>
+#include <svx/clipboardctl.hxx>
+#include <svx/lboxctrl.hxx>
+#include <svx/verttexttbxctrl.hxx>
+#include <svx/formatpaintbrushctrl.hxx>
+#include "tbinsert.hxx"
+#include "tbzoomsliderctrl.hxx"
+#include <svx/zoomsliderctrl.hxx>
+
+#include <svx/xmlsecctrl.hxx>
+// Child-Windows
+#include "reffact.hxx"
+#include "navipi.hxx"
+#include "inputwin.hxx"
+#include "spelldialog.hxx"
+#include <svx/fontwork.hxx>
+#include <svx/srchdlg.hxx>
+#include <svx/hyprlink.hxx>
+#include <svx/hyperdlg.hxx>
+#include <svx/imapdlg.hxx>
+
+#include "editutil.hxx"
+#include <svx/svdfield.hxx> // SdrRegisterFieldClasses
+#include <rtl/logfile.hxx>
+
+#include "dwfunctr.hxx"
+#include "acredlin.hxx"
+
+//------------------------------------------------------------------
+
+
+//------------------------------------------------------------------
+
+ScResId::ScResId( USHORT nId ) :
+ ResId( nId, *SC_MOD()->GetResMgr() )
+{
+}
+
+//------------------------------------------------------------------
+
+void ScDLL::Init()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDLL::Init" );
+
+ ScModule **ppShlPtr = (ScModule**) GetAppData(SHL_CALC);
+ if ( *ppShlPtr )
+ return;
+
+ ScDocumentPool::InitVersionMaps(); // wird im ScModule ctor gebraucht
+
+ ScModule* pMod = new ScModule( &ScDocShell::Factory() );
+ (*ppShlPtr) = pMod;
+
+//REMOVE ScDocShell::RegisterFactory( SDT_SC_DOCFACTPRIO );
+
+ ScDocShell::Factory().SetDocumentServiceName( rtl::OUString::createFromAscii( "com.sun.star.sheet.SpreadsheetDocument" ) );
+
+ ScGlobal::Init(); // erst wenn der ResManager initialisiert ist
+ // erst nach ScGlobal::Init duerfen die App-Optionen
+ // initialisiert werden
+
+ // register your view-factories here
+
+ ScTabViewShell ::RegisterFactory(1);
+ ScPreviewShell ::RegisterFactory(2);
+
+ // register your shell-interfaces here
+
+ ScModule ::RegisterInterface(pMod);
+ ScDocShell ::RegisterInterface(pMod);
+ ScTabViewShell ::RegisterInterface(pMod);
+ ScPreviewShell ::RegisterInterface(pMod);
+ ScDrawShell ::RegisterInterface(pMod);
+ ScDrawFormShell ::RegisterInterface(pMod);
+ ScDrawTextObjectBar ::RegisterInterface(pMod);
+ ScEditShell ::RegisterInterface(pMod);
+ ScPivotShell ::RegisterInterface(pMod);
+ ScAuditingShell ::RegisterInterface(pMod);
+ ScFormatShell ::RegisterInterface(pMod);
+ ScCellShell ::RegisterInterface(pMod);
+ ScOleObjectShell ::RegisterInterface(pMod);
+ ScChartShell ::RegisterInterface(pMod);
+ ScGraphicShell ::RegisterInterface(pMod);
+ ScMediaShell ::RegisterInterface(pMod);
+ ScPageBreakShell ::RegisterInterface(pMod);
+
+ // eigene Controller
+ ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSERT, pMod);
+ ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSCELLS, pMod);
+ ScTbxInsertCtrl ::RegisterControl(SID_TBXCTL_INSOBJ, pMod);
+ ScZoomSliderControl ::RegisterControl(SID_PREVIEW_SCALINGFACTOR, pMod);
+
+ // Svx-Toolbox-Controller
+ SvxTbxCtlDraw ::RegisterControl(SID_INSERT_DRAW, pMod);
+ SvxTbxCtlCustomShapes ::RegisterControl(SID_DRAWTBX_CS_BASIC, pMod);
+ SvxTbxCtlCustomShapes ::RegisterControl(SID_DRAWTBX_CS_SYMBOL, pMod);
+ SvxTbxCtlCustomShapes ::RegisterControl(SID_DRAWTBX_CS_ARROW, pMod);
+ SvxTbxCtlCustomShapes ::RegisterControl(SID_DRAWTBX_CS_FLOWCHART, pMod);
+ SvxTbxCtlCustomShapes ::RegisterControl(SID_DRAWTBX_CS_CALLOUT, pMod);
+ SvxTbxCtlCustomShapes ::RegisterControl(SID_DRAWTBX_CS_STAR, pMod);
+ SvxTbxCtlAlign ::RegisterControl(SID_OBJECT_ALIGN, pMod);
+ SvxFillToolBoxControl ::RegisterControl(0, pMod);
+ SvxLineStyleToolBoxControl ::RegisterControl(0, pMod);
+ SvxLineWidthToolBoxControl ::RegisterControl(0, pMod);
+ SvxLineColorToolBoxControl ::RegisterControl(0, pMod);
+ SvxLineEndToolBoxControl ::RegisterControl(SID_ATTR_LINEEND_STYLE, pMod);
+ SvxStyleToolBoxControl ::RegisterControl(SID_STYLE_APPLY, pMod);
+ SvxFontNameToolBoxControl ::RegisterControl(SID_ATTR_CHAR_FONT, pMod);
+// SvxFontHeightToolBoxControl ::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod);
+ SvxFontColorToolBoxControl ::RegisterControl(SID_ATTR_CHAR_COLOR, pMod);
+ SvxColorToolBoxControl ::RegisterControl(SID_BACKGROUND_COLOR, pMod);
+ SvxFrameToolBoxControl ::RegisterControl(SID_ATTR_BORDER, pMod);
+ SvxFrameLineStyleToolBoxControl ::RegisterControl(SID_FRAME_LINESTYLE, pMod);
+ SvxFrameLineColorToolBoxControl ::RegisterControl(SID_FRAME_LINECOLOR, pMod);
+ SvxClipBoardControl ::RegisterControl(SID_PASTE, pMod );
+ SvxUndoRedoControl ::RegisterControl(SID_UNDO, pMod );
+ SvxUndoRedoControl ::RegisterControl(SID_REDO, pMod );
+ svx::FormatPaintBrushToolBoxControl::RegisterControl(SID_FORMATPAINTBRUSH, pMod );
+
+ SvxGrafModeToolBoxControl ::RegisterControl(SID_ATTR_GRAF_MODE, pMod);
+ SvxGrafRedToolBoxControl ::RegisterControl(SID_ATTR_GRAF_RED, pMod);
+ SvxGrafGreenToolBoxControl ::RegisterControl(SID_ATTR_GRAF_GREEN, pMod);
+ SvxGrafBlueToolBoxControl ::RegisterControl(SID_ATTR_GRAF_BLUE, pMod);
+ SvxGrafLuminanceToolBoxControl ::RegisterControl(SID_ATTR_GRAF_LUMINANCE, pMod);
+ SvxGrafContrastToolBoxControl ::RegisterControl(SID_ATTR_GRAF_CONTRAST, pMod);
+ SvxGrafGammaToolBoxControl ::RegisterControl(SID_ATTR_GRAF_GAMMA, pMod);
+ SvxGrafTransparenceToolBoxControl::RegisterControl(SID_ATTR_GRAF_TRANSPARENCE, pMod);
+ SvxGrafFilterToolBoxControl ::RegisterControl(SID_GRFFILTER, pMod);
+
+ SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_CAPTION_VERTICAL, pMod);
+ SvxVertTextTbxCtrl::RegisterControl(SID_DRAW_TEXT_VERTICAL, pMod);
+ SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_LEFT_TO_RIGHT, pMod);
+ SvxVertTextTbxCtrl::RegisterControl(SID_TEXTDIRECTION_TOP_TO_BOTTOM, pMod);
+ SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_LEFT_TO_RIGHT, pMod);
+ SvxCTLTextTbxCtrl::RegisterControl(SID_ATTR_PARA_RIGHT_TO_LEFT, pMod);
+
+ //Media Controller
+ ::avmedia::MediaToolBoxControl::RegisterControl( SID_AVMEDIA_TOOLBOX, pMod );
+
+ // common SFX controller
+ ::sfx2::TaskPaneWrapper::RegisterChildWindow( FALSE, pMod );
+
+ // Svx-StatusBar-Controller
+ SvxInsertStatusBarControl ::RegisterControl(SID_ATTR_INSERT, pMod);
+ SvxSelectionModeControl ::RegisterControl(SID_STATUS_SELMODE, pMod);
+ SvxZoomStatusBarControl ::RegisterControl(SID_ATTR_ZOOM, pMod);
+ SvxZoomSliderControl ::RegisterControl(SID_ATTR_ZOOMSLIDER, pMod);
+ SvxModifyControl ::RegisterControl(SID_DOC_MODIFIED, pMod);
+ XmlSecStatusBarControl ::RegisterControl( SID_SIGNATURE, pMod );
+
+ SvxPosSizeStatusBarControl ::RegisterControl(SID_ATTR_SIZE, pMod);
+
+ // Svx-Menue-Controller
+ SvxFontMenuControl ::RegisterControl(SID_ATTR_CHAR_FONT, pMod);
+ SvxFontSizeMenuControl ::RegisterControl(SID_ATTR_CHAR_FONTHEIGHT, pMod);
+
+ // CustomShape extrusion controller
+ svx::ExtrusionColorControl::RegisterControl( SID_EXTRUSION_3D_COLOR, pMod );
+ svx::FontWorkShapeTypeControl::RegisterControl( SID_FONTWORK_SHAPE_TYPE, pMod );
+
+ // Child-Windows
+
+ // Hack: Eingabezeile mit 42 registrieren, damit sie im PlugIn immer sichtbar ist
+ ScInputWindowWrapper ::RegisterChildWindow(42, pMod, SFX_CHILDWIN_TASK|SFX_CHILDWIN_FORCEDOCK);
+ ScNavigatorDialogWrapper ::RegisterChildWindowContext(
+ sal::static_int_cast<sal_uInt16>(ScTabViewShell::GetInterfaceId()), pMod);
+ ScSolverDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScOptSolverDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScNameDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScPivotLayoutWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScTabOpDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScFilterDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScSpecialFilterDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScDbNameDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScConsolidateDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScPrintAreasDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScCondFormatDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScColRowNameRangesDlgWrapper::RegisterChildWindow(FALSE, pMod);
+ ScFormulaDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+
+ // First docking Window for Calc
+ ScFunctionChildWindow ::RegisterChildWindow(FALSE, pMod);
+
+ // Redlining- Window
+ ScAcceptChgDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ ScSimpleRefDlgWrapper ::RegisterChildWindow(FALSE, pMod, SFX_CHILDWIN_ALWAYSAVAILABLE|SFX_CHILDWIN_NEVERHIDE );
+ ScHighlightChgDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+
+ SvxSearchDialogWrapper ::RegisterChildWindow(FALSE, pMod);
+ SvxHlinkDlgWrapper ::RegisterChildWindow(FALSE, pMod);
+ SvxFontWorkChildWindow ::RegisterChildWindow(FALSE, pMod);
+ SvxHyperlinkDlgWrapper ::RegisterChildWindow(FALSE, pMod, SFX_CHILDWIN_FORCEDOCK);
+ SvxIMapDlgChildWindow ::RegisterChildWindow(FALSE, pMod);
+ GalleryChildWindow ::RegisterChildWindow(FALSE, pMod);
+ ScSpellDialogChildWindow ::RegisterChildWindow(FALSE, pMod);
+ ::avmedia::MediaPlayer ::RegisterChildWindow(FALSE, pMod);
+
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ ScValidityRefChildWin::RegisterChildWindow(FALSE, pMod);
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+
+ // Edit-Engine-Felder, soweit nicht schon in OfficeApplication::Init
+
+ SvClassManager& rClassManager = SvxFieldItem::GetClassManager();
+// rClassManager.SV_CLASS_REGISTER( SvxURLField );
+// rClassManager.SV_CLASS_REGISTER( SvxDateField );
+// rClassManager.SV_CLASS_REGISTER( SvxPageField );
+ rClassManager.SV_CLASS_REGISTER( SvxPagesField );
+// rClassManager.SV_CLASS_REGISTER( SvxTimeField );
+ rClassManager.SV_CLASS_REGISTER( SvxFileField );
+// rClassManager.SV_CLASS_REGISTER( SvxExtFileField );
+ rClassManager.SV_CLASS_REGISTER( SvxTableField );
+
+ SdrRegisterFieldClasses(); // SvDraw-Felder registrieren
+
+ // 3D-Objekt-Factory eintragen
+ E3dObjFactory();
+
+ // ::com::sun::star::form::component::Form-Objekt-Factory eintragen
+ FmFormObjFactory();
+
+ pMod->PutItem( SfxUInt16Item( SID_ATTR_METRIC, sal::static_int_cast<UINT16>(pMod->GetAppOptions().GetAppMetric()) ) );
+
+ // StarOne Services are now handled in the registry
+}
+
+void ScDLL::Exit()
+{
+ // the SxxModule must be destroyed
+ ScModule **ppShlPtr = (ScModule**) GetAppData(SHL_CALC);
+ delete (*ppShlPtr);
+ (*ppShlPtr) = NULL;
+
+ // ScGlobal::Clear ist schon im Module-dtor
+}
+
+//------------------------------------------------------------------
+// Statusbar
+//------------------------------------------------------------------
+
+#define TEXT_WIDTH(s) rStatusBar.GetTextWidth((s))
+
+#undef TEXT_WIDTH
+
+// DetectFilter functionality has moved - please update your bookmarks
+// see sc/source/ui/unoobj/scdetect.cxx, have a nice day.
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
new file mode 100644
index 000000000000..0382970bbb9e
--- /dev/null
+++ b/sc/source/ui/app/scmod.cxx
@@ -0,0 +1,2289 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <comphelper/processfactory.hxx>
+
+
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/app.hxx>
+#include <editeng/eeitem.hxx>
+
+#include <editeng/flditem.hxx>
+#include <editeng/outliner.hxx>
+#include <basic/sbstar.hxx>
+
+#include <sfx2/sfxdlg.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objface.hxx>
+
+#include <svx/hyprlink.hxx>
+#include "IAnyRefDialog.hxx"
+
+#include <svtools/ehdl.hxx>
+#include <svtools/accessibilityoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/status.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/macrconf.hxx>
+#include <sfx2/printer.hxx>
+#include <editeng/langitem.hxx>
+#include <svtools/colorcfg.hxx>
+
+#include <svl/whiter.hxx>
+#include <svx/selctrl.hxx>
+#include <svx/insctrl.hxx>
+#include <svx/zoomctrl.hxx>
+#include <svx/modctrl.hxx>
+#include <svx/pszctrl.hxx>
+#include <svx/zoomsliderctrl.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/inethist.hxx>
+#include <vcl/waitobj.hxx>
+#include <svx/svxerr.hxx>
+
+
+
+#include "scmod.hxx"
+#include "global.hxx"
+#include "viewopti.hxx"
+#include "docoptio.hxx"
+#include "appoptio.hxx"
+#include "inputopt.hxx"
+#include "printopt.hxx"
+#include "navicfg.hxx"
+#include "addincfg.hxx"
+#include "tabvwsh.hxx"
+#include "prevwsh.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "uiitems.hxx"
+#include "sc.hrc"
+#include "cfgids.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "msgpool.hxx"
+#include "scresid.hxx"
+#include "anyrefdg.hxx"
+#include "dwfunctr.hxx"
+#include "formdata.hxx"
+#include "tpprint.hxx"
+#include "transobj.hxx"
+#include "detfunc.hxx"
+#include "preview.hxx"
+
+#include <svx/xmlsecctrl.hxx>
+
+
+#define ScModule
+#include "scslots.hxx"
+
+#include "scabstdlg.hxx"
+
+#define SC_IDLE_MIN 150
+#define SC_IDLE_MAX 3000
+#define SC_IDLE_STEP 75
+#define SC_IDLE_COUNT 50
+
+static USHORT nIdleCount = 0;
+
+//------------------------------------------------------------------
+
+SFX_IMPL_INTERFACE( ScModule, SfxShell, ScResId(RID_APPTITLE) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER,
+ ScResId(RID_OBJECTBAR_APP) );
+ SFX_STATUSBAR_REGISTRATION( ScResId(SCCFG_STATUSBAR) ); // nur ID wichtig
+ SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() );
+}
+
+//------------------------------------------------------------------
+
+ScModule::ScModule( SfxObjectFactory* pFact ) :
+ SfxModule( SfxApplication::CreateResManager( "sc" ), FALSE, pFact, NULL ),
+ pSelTransfer( NULL ),
+ pMessagePool( NULL ),
+ pRefInputHandler( NULL ),
+ pViewCfg( NULL ),
+ pDocCfg( NULL ),
+ pAppCfg( NULL ),
+ pInputCfg( NULL ),
+ pPrintCfg( NULL ),
+ pNavipiCfg( NULL ),
+ pAddInCfg( NULL ),
+ pColorConfig( NULL ),
+ pAccessOptions( NULL ),
+ pCTLOptions( NULL ),
+ pUserOptions( NULL ),
+ pErrorHdl( NULL ),
+ pSvxErrorHdl( NULL ),
+ pFormEditData( NULL ),
+ nCurRefDlgId( 0 ),
+ bIsWaterCan( FALSE ),
+ bIsInEditCommand( FALSE ),
+ bIsInExecuteDrop( FALSE ),
+ mbIsInSharedDocLoading( false ),
+ mbIsInSharedDocSaving( false )
+{
+ // im ctor ist der ResManager (DLL-Daten) noch nicht initialisiert!
+
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("StarCalc"))); // fuer Basic
+
+ ResetDragObject();
+ SetClipObject( NULL, NULL );
+
+ // InputHandler braucht nicht mehr angelegt zu werden
+
+ // ErrorHandler anlegen - war in Init()
+ // zwischen OfficeApplication::Init und ScGlobal::Init
+ SvxErrorHandler::Get();
+ pErrorHdl = new SfxErrorHandler( RID_ERRHDLSC,
+ ERRCODE_AREA_SC,
+ ERRCODE_AREA_APP2-1,
+ GetResMgr() );
+
+ aSpellTimer.SetTimeout(10);
+ aSpellTimer.SetTimeoutHdl( LINK( this, ScModule, SpellTimerHdl ) );
+ aIdleTimer.SetTimeout(SC_IDLE_MIN);
+ aIdleTimer.SetTimeoutHdl( LINK( this, ScModule, IdleHandler ) );
+ aIdleTimer.Start();
+
+ pMessagePool = new ScMessagePool;
+ pMessagePool->FreezeIdRanges();
+ SetPool( pMessagePool );
+ ScGlobal::InitTextHeight( pMessagePool );
+
+ StartListening( *SFX_APP() ); // for SFX_HINT_DEINITIALIZING
+}
+
+ScModule::~ScModule()
+{
+ DBG_ASSERT( !pSelTransfer, "Selection Transfer object not deleted" );
+
+ // InputHandler braucht nicht mehr geloescht zu werden (gibt keinen an der App mehr)
+
+ SfxItemPool::Free(pMessagePool);
+
+ DELETEZ( pFormEditData );
+
+ delete pErrorHdl;
+// delete pSvxErrorHdl;
+
+ ScGlobal::Clear(); // ruft auch ScDocumentPool::DeleteVersionMaps();
+
+ DeleteCfg(); // wurde mal aus Exit() gerufen
+}
+
+//------------------------------------------------------------------
+void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 )
+{
+ if ( p == pColorConfig || p == pAccessOptions )
+ {
+ // Test if detective objects have to be updated with new colors
+ // (if the detective colors haven't been used yet, there's nothing to update)
+ if ( ScDetectiveFunc::IsColorsInitialized() )
+ {
+ const svtools::ColorConfig& rColors = GetColorConfig();
+ BOOL bArrows =
+ ( ScDetectiveFunc::GetArrowColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVE).nColor ||
+ ScDetectiveFunc::GetErrorColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVEERROR).nColor );
+ BOOL bComments =
+ ( ScDetectiveFunc::GetCommentColor() != (ColorData)rColors.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor );
+ if ( bArrows || bComments )
+ {
+ ScDetectiveFunc::InitializeColors(); // get the new colors
+
+ // update detective objects in all open documents
+ SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
+ while ( pObjSh )
+ {
+ if ( pObjSh->Type() == TYPE(ScDocShell) )
+ {
+ ScDocShell* pDocSh = ((ScDocShell*)pObjSh);
+ if ( bArrows )
+ ScDetectiveFunc( pDocSh->GetDocument(), 0 ).UpdateAllArrowColors();
+ if ( bComments )
+ ScDetectiveFunc::UpdateAllComments( *pDocSh->GetDocument() );
+ }
+ pObjSh = SfxObjectShell::GetNext( *pObjSh );
+ }
+ }
+ }
+
+ // force all views to repaint, using the new options
+
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while(pViewShell)
+ {
+ if ( pViewShell->ISA(ScTabViewShell) )
+ {
+ ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell;
+ pViewSh->PaintGrid();
+ pViewSh->PaintTop();
+ pViewSh->PaintLeft();
+ pViewSh->PaintExtras();
+
+ ScInputHandler* pHdl = pViewSh->GetInputHandler();
+ if ( pHdl )
+ pHdl->ForgetLastPattern(); // EditEngine BackgroundColor may change
+ }
+ else if ( pViewShell->ISA(ScPreviewShell) )
+ {
+ Window* pWin = pViewShell->GetWindow();
+ if (pWin)
+ pWin->Invalidate();
+ }
+ pViewShell = SfxViewShell::GetNext( *pViewShell );
+ }
+ }
+ else if ( p == pCTLOptions )
+ {
+ // for all documents: set digit language for printer, recalc output factor, update row heights
+ SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
+ while ( pObjSh )
+ {
+ if ( pObjSh->Type() == TYPE(ScDocShell) )
+ {
+ ScDocShell* pDocSh = ((ScDocShell*)pObjSh);
+ OutputDevice* pPrinter = pDocSh->GetPrinter();
+ if ( pPrinter )
+ pPrinter->SetDigitLanguage( GetOptDigitLanguage() );
+
+ pDocSh->CalcOutputFactor();
+
+ SCTAB nTabCount = pDocSh->GetDocument()->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ pDocSh->AdjustRowHeight( 0, MAXROW, nTab );
+ }
+ pObjSh = SfxObjectShell::GetNext( *pObjSh );
+ }
+
+ // for all views (table and preview): update digit language
+ SfxViewShell* pSh = SfxViewShell::GetFirst();
+ while ( pSh )
+ {
+ if ( pSh->ISA( ScTabViewShell ) )
+ {
+ ScTabViewShell* pViewSh = (ScTabViewShell*)pSh;
+
+ // set ref-device for EditEngine (re-evaluates digit settings)
+ ScInputHandler* pHdl = GetInputHdl(pViewSh);
+ if (pHdl)
+ pHdl->UpdateRefDevice();
+
+ pViewSh->DigitLanguageChanged();
+ pViewSh->PaintGrid();
+ }
+ else if ( pSh->ISA( ScPreviewShell ) )
+ {
+ ScPreviewShell* pPreviewSh = (ScPreviewShell*)pSh;
+ ScPreview* pPreview = pPreviewSh->GetPreview();
+
+ pPreview->SetDigitLanguage( GetOptDigitLanguage() );
+ pPreview->Invalidate();
+ }
+
+ pSh = SfxViewShell::GetNext( *pSh );
+ }
+ }
+}
+
+void ScModule::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA(SfxSimpleHint) )
+ {
+ ULONG nHintId = ((SfxSimpleHint&)rHint).GetId();
+ if ( nHintId == SFX_HINT_DEINITIALIZING )
+ {
+ // ConfigItems must be removed before ConfigManager
+ DeleteCfg();
+ }
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScModule::DeleteCfg()
+{
+ DELETEZ( pViewCfg ); // Speichern passiert vor Exit() automatisch
+ DELETEZ( pDocCfg );
+ DELETEZ( pAppCfg );
+ DELETEZ( pInputCfg );
+ DELETEZ( pPrintCfg );
+ DELETEZ( pNavipiCfg );
+ DELETEZ( pAddInCfg );
+
+ if ( pColorConfig )
+ {
+ pColorConfig->RemoveListener(this);
+ DELETEZ( pColorConfig );
+ }
+ if ( pAccessOptions )
+ {
+ pAccessOptions->RemoveListener(this);
+ DELETEZ( pAccessOptions );
+ }
+ if ( pCTLOptions )
+ {
+ pCTLOptions->RemoveListener(this);
+ DELETEZ( pCTLOptions );
+ }
+ if( pUserOptions )
+ {
+ DELETEZ( pUserOptions );
+ }
+}
+
+//------------------------------------------------------------------
+
+#define TEXT_WIDTH(s) rStatusBar.GetTextWidth((s))
+
+void ScModule::FillStatusBar(StatusBar& rStatusBar)
+{
+ // Dokumentposition (Tabelle x / y)
+ rStatusBar.InsertItem( SID_STATUS_DOCPOS,
+ TEXT_WIDTH( String().Fill( 10, 'X' ) ),
+ SIB_LEFT|SIB_AUTOSIZE );
+ rStatusBar.SetHelpId( SID_STATUS_DOCPOS, SID_STATUS_DOCPOS );
+
+ // Seitenvorlage
+ rStatusBar.InsertItem( SID_STATUS_PAGESTYLE,
+ TEXT_WIDTH( String().Fill( 15, 'X' ) ),
+ SIB_LEFT|SIB_AUTOSIZE );
+ rStatusBar.SetHelpId( SID_STATUS_PAGESTYLE, SID_STATUS_PAGESTYLE );
+
+ // Einfuege-/Ueberschreibmodus
+ rStatusBar.InsertItem( SID_ATTR_INSERT,
+ SvxInsertStatusBarControl::GetDefItemWidth(rStatusBar),
+ SIB_CENTER );
+ rStatusBar.SetHelpId( SID_ATTR_INSERT, SID_ATTR_INSERT );
+
+ // Selektionsmodus
+ rStatusBar.InsertItem( SID_STATUS_SELMODE,
+ SvxSelectionModeControl::GetDefItemWidth(rStatusBar),
+ SIB_CENTER );
+ rStatusBar.SetHelpId( SID_STATUS_SELMODE, SID_STATUS_SELMODE );
+
+ // Dokument geaendert
+ rStatusBar.InsertItem( SID_DOC_MODIFIED,
+ SvxModifyControl::GetDefItemWidth(rStatusBar));
+
+ // signatures
+ rStatusBar.InsertItem( SID_SIGNATURE, XmlSecStatusBarControl::GetDefItemWidth( rStatusBar ), SIB_USERDRAW );
+ rStatusBar.SetHelpId(SID_SIGNATURE, SID_SIGNATURE);
+
+
+ rStatusBar.SetHelpId( SID_DOC_MODIFIED, SID_DOC_MODIFIED );
+
+ // den aktuellen Kontext anzeigen Uhrzeit / FramePos / TabellenInfo / Errors
+ rStatusBar.InsertItem( SID_ATTR_SIZE,
+ SvxPosSizeStatusBarControl::GetDefItemWidth(rStatusBar),
+ SIB_AUTOSIZE|SIB_LEFT|SIB_USERDRAW);
+ rStatusBar.SetHelpId( SID_ATTR_SIZE, SID_ATTR_SIZE );
+
+ // Ma"sstab
+ rStatusBar.InsertItem( SID_ATTR_ZOOM,
+ SvxZoomStatusBarControl::GetDefItemWidth(rStatusBar),
+ SIB_CENTER );
+ rStatusBar.SetHelpId( SID_ATTR_ZOOM, SID_ATTR_ZOOM );
+
+ // ZoomSlider
+ rStatusBar.InsertItem( SID_ATTR_ZOOMSLIDER,
+ TEXT_WIDTH( String().Fill( 15, 'X' ) ),
+ SIB_CENTER );
+ rStatusBar.SetHelpId( SID_ATTR_ZOOMSLIDER, SID_ATTR_ZOOMSLIDER );
+}
+
+#undef TEXT_WIDTH
+
+//------------------------------------------------------------------
+//
+// von der Applikation verschoben:
+//
+//------------------------------------------------------------------
+
+void ScModule::Execute( SfxRequest& rReq )
+{
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : NULL;
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_CHOOSE_DESIGN:
+ {
+ String aMacroName =
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Template.Samples.ShowStyles"));
+ SfxApplication* pApp = SFX_APP();
+ pApp->EnterBasicCall();
+ pApp->GetMacroConfig()->Call( NULL, aMacroName, pApp->GetBasicManager() );
+ pApp->LeaveBasicCall();
+ }
+ break;
+ case SID_EURO_CONVERTER:
+ {
+ String aMacroName =
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Euro.ConvertRun.Main"));
+ SfxApplication* pApp = SFX_APP();
+ pApp->EnterBasicCall();
+ pApp->GetMacroConfig()->Call( NULL, aMacroName, pApp->GetBasicManager() );
+ pApp->LeaveBasicCall();
+ }
+ break;
+ case SID_AUTOSPELL_CHECK:
+ {
+ BOOL bSet;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, TRUE, &pItem ) )
+ bSet = ((const SfxBoolItem*)pItem)->GetValue();
+ else
+ { // Toggle
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
+ if ( pDocSh )
+ bSet = !pDocSh->GetDocument()->GetDocOptions().IsAutoSpell();
+ else
+ bSet = !GetDocOptions().IsAutoSpell();
+ }
+
+ SfxItemSet aSet( GetPool(), SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK );
+ aSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, bSet ) );
+ ModifyOptions( aSet );
+ rReq.Done();
+ }
+ break;
+
+ case SID_ATTR_METRIC:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, TRUE, &pItem ) )
+ {
+ FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue();
+ switch( eUnit )
+ {
+ case FUNIT_MM: // nur die Einheiten, die auch im Dialog stehen
+ case FUNIT_CM:
+ case FUNIT_INCH:
+ case FUNIT_PICA:
+ case FUNIT_POINT:
+ {
+ PutItem( *pItem );
+ ScAppOptions aNewOpts( GetAppOptions() );
+ aNewOpts.SetAppMetric( eUnit );
+ SetAppOptions( aNewOpts );
+ rReq.Done();
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ }
+ break;
+
+ case FID_AUTOCOMPLETE:
+ {
+ ScAppOptions aNewOpts( GetAppOptions() );
+ BOOL bNew = !aNewOpts.GetAutoComplete();
+ aNewOpts.SetAutoComplete( bNew );
+ SetAppOptions( aNewOpts );
+ ScInputHandler::SetAutoComplete( bNew );
+ if (pBindings)
+ pBindings->Invalidate( FID_AUTOCOMPLETE );
+ rReq.Done();
+ }
+ break;
+
+ case SID_DETECTIVE_AUTO:
+ {
+ ScAppOptions aNewOpts( GetAppOptions() );
+ BOOL bNew = !aNewOpts.GetDetectiveAuto();
+ SFX_REQUEST_ARG( rReq, pAuto, SfxBoolItem, SID_DETECTIVE_AUTO, sal_False );
+ if ( pAuto )
+ bNew = pAuto->GetValue();
+
+ aNewOpts.SetDetectiveAuto( bNew );
+ SetAppOptions( aNewOpts );
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_AUTO );
+ rReq.AppendItem( SfxBoolItem( SID_DETECTIVE_AUTO, bNew ) );
+ rReq.Done();
+ }
+ break;
+
+ case SID_PSZ_FUNCTION:
+ if (pReqArgs)
+ {
+ const SfxUInt16Item& rItem = (const SfxUInt16Item&)pReqArgs->Get(SID_PSZ_FUNCTION);
+ DBG_ASSERT(rItem.ISA(SfxUInt16Item),"falscher Parameter");
+
+ ScAppOptions aNewOpts( GetAppOptions() );
+ aNewOpts.SetStatusFunc( rItem.GetValue() );
+ SetAppOptions( aNewOpts );
+
+ if (pBindings)
+ {
+ pBindings->Invalidate( SID_TABLE_CELL );
+ pBindings->Update( SID_TABLE_CELL ); // sofort
+
+ pBindings->Invalidate( SID_PSZ_FUNCTION );
+ pBindings->Update( SID_PSZ_FUNCTION );
+ // falls Menue gleich wieder aufgeklappt wird
+ }
+ }
+ break;
+
+ case SID_ATTR_LANGUAGE:
+ case SID_ATTR_CHAR_CJK_LANGUAGE:
+ case SID_ATTR_CHAR_CTL_LANGUAGE:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( GetPool().GetWhich(nSlot), TRUE, &pItem ) )
+ {
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
+ ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL;
+ if ( pDoc )
+ {
+ LanguageType eNewLang = ((SvxLanguageItem*)pItem)->GetLanguage();
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ LanguageType eOld = ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) ? eCjk :
+ ( ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) ? eCtl : eLatin );
+ if ( eNewLang != eOld )
+ {
+ if ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE )
+ eCjk = eNewLang;
+ else if ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE )
+ eCtl = eNewLang;
+ else
+ eLatin = eNewLang;
+
+ pDoc->SetLanguage( eLatin, eCjk, eCtl );
+
+ ScInputHandler* pInputHandler = GetInputHdl();
+ if ( pInputHandler )
+ pInputHandler->UpdateSpellSettings(); // EditEngine-Flags
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ if ( pViewSh )
+ pViewSh->UpdateDrawTextOutliner(); // EditEngine-Flags
+
+ pDocSh->SetDocumentModified();
+ }
+ }
+ }
+ }
+ break;
+
+ case FID_FOCUS_POSWND:
+ {
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ {
+ ScInputWindow* pWin = pHdl->GetInputWindow();
+ if (pWin)
+ pWin->PosGrabFocus();
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), com::sun::star::uno::UNO_QUERY);
+ if( xDialog.is() )
+ {
+ xDialog->execute();
+ }
+ }
+ catch( ::com::sun::star::uno::RuntimeException& )
+ {
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "ScApplication: Unknown Message." );
+ break;
+ }
+}
+
+void ScModule::GetState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case FID_AUTOCOMPLETE:
+ rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetAutoComplete() ) );
+ break;
+ case SID_DETECTIVE_AUTO:
+ rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetDetectiveAuto() ) );
+ break;
+ case SID_PSZ_FUNCTION:
+ rSet.Put( SfxUInt16Item( nWhich, GetAppOptions().GetStatusFunc() ) );
+ break;
+ case SID_ATTR_METRIC:
+ rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<UINT16>(GetAppOptions().GetAppMetric()) ) );
+ break;
+ case SID_AUTOSPELL_CHECK:
+ {
+ BOOL bAuto;
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
+ if ( pDocSh )
+ bAuto = pDocSh->GetDocument()->GetDocOptions().IsAutoSpell();
+ else
+ {
+ USHORT nDummyLang, nDummyCjk, nDummyCtl;
+ GetSpellSettings( nDummyLang, nDummyCjk, nDummyCtl, bAuto );
+ }
+ rSet.Put( SfxBoolItem( nWhich, bAuto ) );
+ }
+ break;
+ case SID_ATTR_LANGUAGE:
+ case ATTR_CJK_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CJK_LANGUAGE
+ case ATTR_CTL_FONT_LANGUAGE: // WID for SID_ATTR_CHAR_CTL_LANGUAGE
+ {
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
+ ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL;
+ if ( pDoc )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ LanguageType eLang = ( nWhich == ATTR_CJK_FONT_LANGUAGE ) ? eCjk :
+ ( ( nWhich == ATTR_CTL_FONT_LANGUAGE ) ? eCtl : eLatin );
+ rSet.Put( SvxLanguageItem( eLang, nWhich ) );
+ }
+ }
+ break;
+
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+void ScModule::HideDisabledSlots( SfxItemSet& rSet )
+{
+ if( SfxViewFrame* pViewFrm = SfxViewFrame::Current() )
+ {
+ SfxBindings& rBindings = pViewFrm->GetBindings();
+ SfxWhichIter aIter( rSet );
+ for( USHORT nWhich = aIter.FirstWhich(); nWhich != 0; nWhich = aIter.NextWhich() )
+ {
+ ScViewUtil::HideDisabledSlot( rSet, rBindings, nWhich );
+ // always disable the slots
+ rSet.DisableItem( nWhich );
+ }
+ }
+}
+
+
+//------------------------------------------------------------------
+
+void ScModule::ResetDragObject()
+{
+ aDragData.pCellTransfer = NULL;
+ aDragData.pDrawTransfer = NULL;
+
+ aDragData.aLinkDoc.Erase();
+ aDragData.aLinkTable.Erase();
+ aDragData.aLinkArea.Erase();
+ aDragData.pJumpLocalDoc = NULL;
+ aDragData.aJumpTarget.Erase();
+ aDragData.aJumpText.Erase();
+}
+
+void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj )
+{
+ ResetDragObject();
+ aDragData.pCellTransfer = pCellObj;
+ aDragData.pDrawTransfer = pDrawObj;
+}
+
+void ScModule::SetDragLink( const String& rDoc, const String& rTab, const String& rArea )
+{
+ ResetDragObject();
+
+ aDragData.aLinkDoc = rDoc;
+ aDragData.aLinkTable = rTab;
+ aDragData.aLinkArea = rArea;
+}
+
+void ScModule::SetDragJump( ScDocument* pLocalDoc, const String& rTarget, const String& rText )
+{
+ ResetDragObject();
+
+ aDragData.pJumpLocalDoc = pLocalDoc;
+ aDragData.aJumpTarget = rTarget;
+ aDragData.aJumpText = rText;
+}
+
+//------------------------------------------------------------------
+
+void ScModule::SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj )
+{
+ DBG_ASSERT( !pCellObj || !pDrawObj, "SetClipObject: not allowed to set both objects" );
+
+ aClipData.pCellClipboard = pCellObj;
+ aClipData.pDrawClipboard = pDrawObj;
+}
+
+ScDocument* ScModule::GetClipDoc()
+{
+ // called from document
+
+ ScTransferObj* pObj = ScTransferObj::GetOwnClipboard( NULL );
+ if (pObj)
+ return pObj->GetDocument();
+
+ return NULL;
+}
+
+//------------------------------------------------------------------
+
+void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew )
+{
+ pSelTransfer = pNew;
+}
+
+//------------------------------------------------------------------
+
+void ScModule::InitFormEditData()
+{
+ pFormEditData = new ScFormEditData;
+}
+
+void ScModule::ClearFormEditData()
+{
+ DELETEZ( pFormEditData );
+}
+
+//------------------------------------------------------------------
+
+void ScModule::SetViewOptions( const ScViewOptions& rOpt )
+{
+ if ( !pViewCfg )
+ pViewCfg = new ScViewCfg;
+
+ pViewCfg->SetOptions( rOpt );
+}
+
+const ScViewOptions& ScModule::GetViewOptions()
+{
+ if ( !pViewCfg )
+ pViewCfg = new ScViewCfg;
+
+ return *pViewCfg;
+}
+
+void ScModule::SetDocOptions( const ScDocOptions& rOpt )
+{
+ if ( !pDocCfg )
+ pDocCfg = new ScDocCfg;
+
+ pDocCfg->SetOptions( rOpt );
+}
+
+const ScDocOptions& ScModule::GetDocOptions()
+{
+ if ( !pDocCfg )
+ pDocCfg = new ScDocCfg;
+
+ return *pDocCfg;
+}
+
+#ifndef LRU_MAX
+#define LRU_MAX 10
+#endif
+
+void ScModule::InsertEntryToLRUList(USHORT nFIndex)
+{
+ if(nFIndex != 0)
+ {
+ const ScAppOptions& rAppOpt = GetAppOptions();
+ USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX );
+ USHORT* pLRUListIds = rAppOpt.GetLRUFuncList();
+
+ USHORT aIdxList[LRU_MAX];
+ USHORT n = 0;
+ BOOL bFound = FALSE;
+
+ while ((n < LRU_MAX) && n<nLRUFuncCount) // alte Liste abklappern
+ {
+ if (!bFound && (pLRUListIds[n]== nFIndex))
+ bFound = TRUE; // erster! Treffer
+ else if (bFound)
+ aIdxList[n ] = pLRUListIds[n]; // hinter Treffer kopieren
+ else if ((n+1) < LRU_MAX)
+ aIdxList[n+1] = pLRUListIds[n]; // vor Treffer verschieben
+ n++;
+ }
+ if (!bFound && (n < LRU_MAX)) // Eintrag nicht gefunden?
+ n++; // einen mehr
+ aIdxList[0] = nFIndex; // Current on Top
+
+ ScAppOptions aNewOpts(rAppOpt); // an App melden
+ aNewOpts.SetLRUFuncList(aIdxList, n);
+ SetAppOptions(aNewOpts);
+
+ RecentFunctionsChanged();
+ }
+}
+
+void ScModule::RecentFunctionsChanged()
+{
+ // update function list window
+ USHORT nFuncListID = ScFunctionChildWindow::GetChildWindowId();
+
+ //! notify all views
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && pViewFrm->HasChildWindow(nFuncListID) )
+ {
+ ScFunctionChildWindow* pWnd =(ScFunctionChildWindow*)pViewFrm->GetChildWindow( nFuncListID );
+
+ ScFunctionDockWin* pFuncList=(ScFunctionDockWin*)pWnd->GetWindow();
+
+ pFuncList->InitLRUList();
+ }
+}
+
+void ScModule::SetAppOptions( const ScAppOptions& rOpt )
+{
+ if ( !pAppCfg )
+ pAppCfg = new ScAppCfg;
+
+ pAppCfg->SetOptions( rOpt );
+}
+
+void global_InitAppOptions()
+{
+ SC_MOD()->GetAppOptions();
+}
+
+const ScAppOptions& ScModule::GetAppOptions()
+{
+ if ( !pAppCfg )
+ pAppCfg = new ScAppCfg;
+
+ return *pAppCfg;
+}
+
+void ScModule::SetInputOptions( const ScInputOptions& rOpt )
+{
+ if ( !pInputCfg )
+ pInputCfg = new ScInputCfg;
+
+ pInputCfg->SetOptions( rOpt );
+}
+
+const ScInputOptions& ScModule::GetInputOptions()
+{
+ if ( !pInputCfg )
+ pInputCfg = new ScInputCfg;
+
+ return *pInputCfg;
+}
+
+void ScModule::SetPrintOptions( const ScPrintOptions& rOpt )
+{
+ if ( !pPrintCfg )
+ pPrintCfg = new ScPrintCfg;
+
+ pPrintCfg->SetOptions( rOpt );
+}
+
+const ScPrintOptions& ScModule::GetPrintOptions()
+{
+ if ( !pPrintCfg )
+ pPrintCfg = new ScPrintCfg;
+
+ return *pPrintCfg;
+}
+
+ScNavipiCfg& ScModule::GetNavipiCfg()
+{
+ if ( !pNavipiCfg )
+ pNavipiCfg = new ScNavipiCfg;
+
+ return *pNavipiCfg;
+}
+
+ScAddInCfg& ScModule::GetAddInCfg()
+{
+ if ( !pAddInCfg )
+ pAddInCfg = new ScAddInCfg;
+
+ return *pAddInCfg;
+}
+
+svtools::ColorConfig& ScModule::GetColorConfig()
+{
+ if ( !pColorConfig )
+ {
+ pColorConfig = new svtools::ColorConfig;
+ pColorConfig->AddListener(this);
+ }
+
+ return *pColorConfig;
+}
+
+SvtAccessibilityOptions& ScModule::GetAccessOptions()
+{
+ if ( !pAccessOptions )
+ {
+ pAccessOptions = new SvtAccessibilityOptions;
+ pAccessOptions->AddListener(this);
+ }
+
+ return *pAccessOptions;
+}
+
+SvtCTLOptions& ScModule::GetCTLOptions()
+{
+ if ( !pCTLOptions )
+ {
+ pCTLOptions = new SvtCTLOptions;
+ pCTLOptions->AddListener(this);
+ }
+
+ return *pCTLOptions;
+}
+
+SvtUserOptions& ScModule::GetUserOptions()
+{
+ if( !pUserOptions )
+ {
+ pUserOptions = new SvtUserOptions;
+ }
+ return *pUserOptions;
+}
+
+USHORT ScModule::GetOptDigitLanguage()
+{
+ SvtCTLOptions::TextNumerals eNumerals = GetCTLOptions().GetCTLTextNumerals();
+ return ( eNumerals == SvtCTLOptions::NUMERALS_ARABIC ) ? LANGUAGE_ENGLISH_US :
+ ( eNumerals == SvtCTLOptions::NUMERALS_HINDI) ? LANGUAGE_ARABIC_SAUDI_ARABIA :
+ LANGUAGE_SYSTEM;
+}
+
+//------------------------------------------------------------------
+//
+// Optionen
+//
+//------------------------------------------------------------------
+
+//
+// ModifyOptions - Items aus Calc-Options-Dialog
+// und SID_AUTOSPELL_CHECK
+//
+
+#define IS_AVAILABLE(w,item) (SFX_ITEM_SET==rOptSet.GetItemState((w),TRUE,&item))
+
+void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
+{
+ USHORT nOldSpellLang, nOldCjkLang, nOldCtlLang;
+ BOOL bOldAutoSpell;
+ GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang, bOldAutoSpell );
+
+ if (!pAppCfg)
+ GetAppOptions();
+ DBG_ASSERT( pAppCfg, "AppOptions not initialised :-(" );
+
+ if (!pInputCfg)
+ GetInputOptions();
+ DBG_ASSERT( pInputCfg, "InputOptions not initialised :-(" );
+
+ //--------------------------------------------------------------
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : NULL;
+
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
+ ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL;
+ const SfxPoolItem* pItem = NULL;
+ BOOL bRepaint = FALSE;
+ BOOL bUpdateMarks = FALSE;
+ BOOL bUpdateRefDev = FALSE;
+ BOOL bCalcAll = FALSE;
+ BOOL bSaveSpellCheck = FALSE;
+ BOOL bSaveAppOptions = FALSE;
+ BOOL bSaveInputOptions = FALSE;
+
+ //--------------------------------------------------------------------------
+
+ // SFX_APP()->SetOptions( rOptSet );
+
+ // Linguistik nicht mehr
+
+ if ( IS_AVAILABLE(SID_ATTR_METRIC,pItem) )
+ {
+ PutItem( *pItem );
+ pAppCfg->SetAppMetric( (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue() );
+ bSaveAppOptions = TRUE;
+ }
+
+ if ( IS_AVAILABLE(SCITEM_USERLIST,pItem) )
+ {
+ ScGlobal::SetUserList( ((const ScUserListItem*)pItem)->GetUserList() );
+ bSaveAppOptions = TRUE;
+ }
+
+ if ( IS_AVAILABLE(SID_SC_OPT_SYNCZOOM,pItem) )
+ {
+ pAppCfg->SetSynchronizeZoom( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+ bSaveAppOptions = TRUE;
+ }
+
+ //============================================
+ // ViewOptions
+ //============================================
+
+ if ( IS_AVAILABLE(SID_SCVIEWOPTIONS,pItem) )
+ {
+ const ScViewOptions& rNewOpt = ((const ScTpViewItem*)pItem)->GetViewOptions();
+
+ if ( pViewSh )
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ const ScViewOptions& rOldOpt = pViewData->GetOptions();
+
+ BOOL bAnchorList = ( rOldOpt.GetOption( VOPT_ANCHOR ) !=
+ rNewOpt.GetOption( VOPT_ANCHOR ) );
+
+ if ( rOldOpt != rNewOpt )
+ {
+ pViewData->SetOptions( rNewOpt ); // veraendert rOldOpt
+ pViewData->GetDocument()->SetViewOptions( rNewOpt );
+ pDocSh->SetDocumentModified();
+ bRepaint = TRUE;
+ }
+ if ( bAnchorList )
+ pViewSh->UpdateAnchorHandles();
+ }
+ SetViewOptions( rNewOpt );
+ if (pBindings)
+ pBindings->Invalidate(SID_HELPLINES_MOVE);
+ }
+
+ //============================================
+ // GridOptions, Auswertung nach ViewOptions,
+ // da GridOptions Member der ViewOptions ist!
+ //============================================
+
+ if ( IS_AVAILABLE(SID_ATTR_GRID_OPTIONS,pItem) )
+ {
+ ScGridOptions aNewGridOpt( (const SvxOptionsGrid&)((const SvxGridItem&)*pItem) );
+
+ if ( pViewSh )
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScViewOptions aNewViewOpt( pViewData->GetOptions() );
+ const ScGridOptions& rOldGridOpt = aNewViewOpt.GetGridOptions();
+
+ if ( rOldGridOpt != aNewGridOpt )
+ {
+ aNewViewOpt.SetGridOptions( aNewGridOpt );
+ pViewData->SetOptions( aNewViewOpt );
+ pViewData->GetDocument()->SetViewOptions( aNewViewOpt );
+ pDocSh->SetDocumentModified();
+ bRepaint = TRUE;
+ }
+ }
+ ScViewOptions aNewViewOpt ( GetViewOptions() );
+ aNewViewOpt.SetGridOptions( aNewGridOpt );
+ SetViewOptions( aNewViewOpt );
+ if (pBindings)
+ {
+ pBindings->Invalidate(SID_GRID_VISIBLE);
+ pBindings->Invalidate(SID_GRID_USE);
+ }
+ }
+
+
+ //============================================
+ // DocOptions
+ //============================================
+
+ if ( IS_AVAILABLE(SID_SCDOCOPTIONS,pItem) )
+ {
+ const ScDocOptions& rNewOpt = ((const ScTpCalcItem*)pItem)->GetDocOptions();
+
+ if ( pDoc )
+ {
+ const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
+ ScOptionsUtil::KeyBindingType eKeyOld = rOldOpt.GetKeyBindingType();
+ ScOptionsUtil::KeyBindingType eKeyNew = rNewOpt.GetKeyBindingType();
+ if (eKeyOld != eKeyNew)
+ pDocSh->ResetKeyBindings(eKeyNew);
+
+ bRepaint = ( bRepaint || ( rOldOpt != rNewOpt ) );
+ bCalcAll = bRepaint &&
+ ( rOldOpt.IsIter() != rNewOpt.IsIter()
+ || rOldOpt.GetIterCount() != rNewOpt.GetIterCount()
+ || rOldOpt.GetIterEps() != rNewOpt.GetIterEps()
+ || rOldOpt.IsIgnoreCase() != rNewOpt.IsIgnoreCase()
+ || rOldOpt.IsCalcAsShown() != rNewOpt.IsCalcAsShown()
+ || (rNewOpt.IsCalcAsShown() &&
+ rOldOpt.GetStdPrecision() != rNewOpt.GetStdPrecision())
+ || rOldOpt.IsMatchWholeCell() != rNewOpt.IsMatchWholeCell()
+ || rOldOpt.GetYear2000() != rNewOpt.GetYear2000()
+ || rOldOpt.IsFormulaRegexEnabled() != rNewOpt.IsFormulaRegexEnabled()
+ );
+ pDoc->SetDocOptions( rNewOpt );
+ pDocSh->SetDocumentModified();
+ }
+ SetDocOptions( rNewOpt );
+ }
+
+ // nach den eigentlichen DocOptions auch noch die TabDistance setzen
+ if ( IS_AVAILABLE(SID_ATTR_DEFTABSTOP,pItem) )
+ {
+ USHORT nTabDist = ((SfxUInt16Item*)pItem)->GetValue();
+ ScDocOptions aOpt(GetDocOptions());
+ aOpt.SetTabDistance(nTabDist);
+ SetDocOptions( aOpt );
+
+ if ( pDoc )
+ {
+ ScDocOptions aDocOpt(pDoc->GetDocOptions());
+ aDocOpt.SetTabDistance(nTabDist);
+ pDoc->SetDocOptions( aDocOpt );
+ pDocSh->SetDocumentModified();
+ if(pDoc->GetDrawLayer())
+ pDoc->GetDrawLayer()->SetDefaultTabulator(nTabDist);
+ }
+ }
+
+ // AutoSpell nach den Doc-Options (weil Member)
+
+ if ( IS_AVAILABLE(SID_AUTOSPELL_CHECK,pItem) ) // an Doc-Options
+ {
+ BOOL bDoAutoSpell = ((const SfxBoolItem*)pItem)->GetValue();
+
+ if (pDoc)
+ {
+ ScDocOptions aNewOpt = pDoc->GetDocOptions();
+ if ( aNewOpt.IsAutoSpell() != bDoAutoSpell )
+ {
+ aNewOpt.SetAutoSpell( bDoAutoSpell );
+ pDoc->SetDocOptions( aNewOpt );
+
+ if (bDoAutoSpell)
+ pDoc->SetOnlineSpellPos( ScAddress(0,0,0) ); // vorne anfangen
+ else
+ {
+ WaitObject aWait( pDocSh->GetActiveDialogParent() );
+ pDoc->RemoveAutoSpellObj(); // Edit-Text-Objekte wieder zurueckwandeln
+ }
+
+ //#92038#; don't set document modified, because this flag is no longer saved
+// pDocSh->SetDocumentModified();
+
+ bRepaint = TRUE; // weil HideAutoSpell evtl. ungueltig
+ //! alle Views painten ???
+ }
+ }
+
+ if ( bOldAutoSpell != bDoAutoSpell )
+ {
+ SetAutoSpellProperty( bDoAutoSpell );
+ bSaveSpellCheck = TRUE;
+ }
+ if ( pDocSh )
+ pDocSh->PostPaintGridAll(); // wegen Markierungen
+ ScInputHandler* pInputHandler = GetInputHdl();
+ if ( pInputHandler )
+ pInputHandler->UpdateSpellSettings(); // EditEngine-Flags
+ if ( pViewSh )
+ pViewSh->UpdateDrawTextOutliner(); // EditEngine-Flags
+
+ if (pBindings)
+ pBindings->Invalidate( SID_AUTOSPELL_CHECK );
+ }
+
+ //============================================
+ // InputOptions
+ //============================================
+
+ if ( IS_AVAILABLE(SID_SC_INPUT_SELECTIONPOS,pItem) )
+ {
+ pInputCfg->SetMoveDir( ((const SfxUInt16Item*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_SELECTION,pItem) )
+ {
+ pInputCfg->SetMoveSelection( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_EDITMODE,pItem) )
+ {
+ pInputCfg->SetEnterEdit( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_FMT_EXPAND,pItem) )
+ {
+ pInputCfg->SetExtendFormat( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_RANGEFINDER,pItem) )
+ {
+ pInputCfg->SetRangeFinder( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_REF_EXPAND,pItem) )
+ {
+ pInputCfg->SetExpandRefs( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_MARK_HEADER,pItem) )
+ {
+ pInputCfg->SetMarkHeader( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ bUpdateMarks = TRUE;
+ }
+ if ( IS_AVAILABLE(SID_SC_INPUT_TEXTWYSIWYG,pItem) )
+ {
+ BOOL bNew = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( bNew != pInputCfg->GetTextWysiwyg() )
+ {
+ pInputCfg->SetTextWysiwyg( bNew );
+ bSaveInputOptions = TRUE;
+ bUpdateRefDev = TRUE;
+ }
+ }
+ if( IS_AVAILABLE( SID_SC_INPUT_REPLCELLSWARN, pItem ) )
+ {
+ pInputCfg->SetReplaceCellsWarn( ((const SfxBoolItem*)pItem)->GetValue() );
+ bSaveInputOptions = TRUE;
+ }
+
+ //============================================
+ // PrintOptions
+ //============================================
+
+ if ( IS_AVAILABLE(SID_SCPRINTOPTIONS,pItem) )
+ {
+ const ScPrintOptions& rNewOpt = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
+ SetPrintOptions( rNewOpt );
+
+ // broadcast causes all previews to recalc page numbers
+ SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) );
+ }
+
+ //----------------------------------------------------------
+
+// if ( bSaveSpellCheck )
+// {
+ // currently LinguProperties are saved only at program exit.
+ // if a save method becomes available, it should be called here.
+// }
+
+ if ( bSaveAppOptions )
+ pAppCfg->OptionsChanged();
+
+ if ( bSaveInputOptions )
+ pInputCfg->OptionsChanged();
+
+ // Neuberechnung anstossen?
+
+ if ( pDoc && bCalcAll )
+ {
+ WaitObject aWait( pDocSh->GetActiveDialogParent() );
+ pDoc->CalcAll();
+ if ( pViewSh )
+ pViewSh->UpdateCharts( TRUE );
+ else
+ ScDBFunc::DoUpdateCharts( ScAddress(), pDoc, TRUE );
+ if (pBindings)
+ pBindings->Invalidate( SID_ATTR_SIZE ); //SvxPosSize-StatusControl-Update
+ }
+
+ if ( pViewSh && bUpdateMarks )
+ pViewSh->UpdateAutoFillMark();
+
+ // View neuzeichnen?
+
+ if ( pViewSh && bRepaint )
+ {
+ pViewSh->UpdateFixPos();
+ pViewSh->PaintGrid();
+ pViewSh->PaintTop();
+ pViewSh->PaintLeft();
+ pViewSh->PaintExtras();
+ pViewSh->InvalidateBorder();
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue
+ pBindings->Invalidate( FID_TOGGLESYNTAX );
+ }
+ }
+
+ // update ref device (for all documents)
+
+ if ( bUpdateRefDev )
+ {
+ // for all documents: recalc output factor, update row heights
+ SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
+ while ( pObjSh )
+ {
+ if ( pObjSh->Type() == TYPE(ScDocShell) )
+ {
+ ScDocShell* pOneDocSh = ((ScDocShell*)pObjSh);
+ pOneDocSh->CalcOutputFactor();
+ SCTAB nTabCount = pOneDocSh->GetDocument()->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ pOneDocSh->AdjustRowHeight( 0, MAXROW, nTab );
+ }
+ pObjSh = SfxObjectShell::GetNext( *pObjSh );
+ }
+
+ // for all (tab-) views:
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh )
+ {
+ ScTabViewShell* pOneViewSh = (ScTabViewShell*)pSh;
+
+ // set ref-device for EditEngine
+ ScInputHandler* pHdl = GetInputHdl(pOneViewSh);
+ if (pHdl)
+ pHdl->UpdateRefDevice();
+
+ // update view scale
+ ScViewData* pViewData = pOneViewSh->GetViewData();
+ pOneViewSh->SetZoom( pViewData->GetZoomX(), pViewData->GetZoomY(), FALSE );
+
+ // repaint
+ pOneViewSh->PaintGrid();
+ pOneViewSh->PaintTop();
+ pOneViewSh->PaintLeft();
+
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+ }
+}
+
+#undef IS_AVAILABLE
+
+//------------------------------------------------------------------
+//
+// Input-Handler
+//
+//------------------------------------------------------------------
+
+ScInputHandler* ScModule::GetInputHdl( ScTabViewShell* pViewSh, BOOL bUseRef )
+{
+ if ( pRefInputHandler && bUseRef )
+ return pRefInputHandler;
+
+ ScInputHandler* pHdl = NULL;
+ if ( !pViewSh )
+ {
+ // in case a UIActive embedded object has no ViewShell ( UNO component )
+ // the own calc view shell will be set as current, but no handling should happen
+
+ ScTabViewShell* pCurViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ if ( pCurViewSh && !pCurViewSh->GetUIActiveClient() )
+ pViewSh = pCurViewSh;
+ }
+
+ if ( pViewSh )
+ pHdl = pViewSh->GetInputHandler(); // Viewshell hat jetzt immer einen
+
+ // #57989# wenn keine ViewShell uebergeben oder aktiv, kann NULL herauskommen
+ DBG_ASSERT( pHdl || !pViewSh, "GetInputHdl: kein InputHandler gefunden" );
+ return pHdl;
+}
+
+void ScModule::ViewShellChanged()
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ ScTabViewShell* pShell = ScTabViewShell::GetActiveViewShell();
+ if ( pShell && pHdl )
+ pShell->UpdateInputHandler();
+}
+
+void ScModule::SetInputMode( ScInputMode eMode )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->SetMode( eMode );
+}
+
+BOOL ScModule::IsEditMode()
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ return pHdl && pHdl->IsEditMode();
+}
+
+BOOL ScModule::IsInputMode()
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ return pHdl && pHdl->IsInputMode();
+}
+
+BOOL ScModule::InputKeyEvent( const KeyEvent& rKEvt, BOOL bStartEdit )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ return ( pHdl ? pHdl->KeyInput( rKEvt, bStartEdit ) : FALSE );
+}
+
+void ScModule::InputEnterHandler( BYTE nBlockMode )
+{
+ if ( !SFX_APP()->IsDowning() ) // nicht beim Programmende
+ {
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->EnterHandler( nBlockMode );
+ }
+}
+
+void ScModule::InputCancelHandler()
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->CancelHandler();
+}
+
+void ScModule::InputSelection( EditView* pView )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->InputSelection( pView );
+}
+
+void ScModule::InputChanged( EditView* pView )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->InputChanged( pView );
+}
+
+void ScModule::ViewShellGone( ScTabViewShell* pViewSh )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->ViewShellGone( pViewSh );
+}
+
+void ScModule::SetRefInputHdl( ScInputHandler* pNew )
+{
+ pRefInputHandler = pNew;
+}
+
+ScInputHandler* ScModule::GetRefInputHdl()
+{
+ return pRefInputHandler;
+}
+
+//------------------------------------------------------------------------
+// Olk's Krempel:
+
+void ScModule::InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->InputGetSelection( rStart, rEnd );
+}
+
+void ScModule::InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->InputSetSelection( nStart, nEnd );
+}
+
+void ScModule::InputReplaceSelection( const String& rStr )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->InputReplaceSelection( rStr );
+}
+
+String ScModule::InputGetFormulaStr()
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ String aStr;
+ if ( pHdl )
+ aStr = pHdl->InputGetFormulaStr();
+ return aStr;
+}
+
+void ScModule::ActivateInputWindow( const String* pStrFormula, BOOL bMatrix )
+{
+ ScInputHandler* pHdl = GetInputHdl();
+ if ( pHdl )
+ {
+ ScInputWindow* pWin = pHdl->GetInputWindow();
+ if ( pStrFormula )
+ {
+ // Formel uebernehmen
+ if ( pWin )
+ {
+ pWin->SetFuncString( *pStrFormula, FALSE );
+ // SetSumAssignMode wegen FALSE nicht noetig
+ }
+ BYTE nMode = bMatrix ? SC_ENTER_MATRIX : SC_ENTER_NORMAL;
+ pHdl->EnterHandler( nMode );
+
+ // ohne Invalidate bleibt die Selektion stehen, wenn die Formel unveraendert ist
+ if (pWin)
+ pWin->TextInvalidate();
+ }
+ else
+ {
+ // Abbrechen
+ if ( pWin )
+ {
+ pWin->SetFuncString( EMPTY_STRING, FALSE );
+ // SetSumAssignMode wegen FALSE nicht noetig
+ }
+ pHdl->CancelHandler();
+ }
+ }
+}
+
+//------------------------------------------------------------------
+//
+// Referenz - Dialoge
+//
+//------------------------------------------------------------------
+
+void ScModule::SetRefDialog( USHORT nId, BOOL bVis, SfxViewFrame* pViewFrm )
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ if(nCurRefDlgId==0 || (nId==nCurRefDlgId && !bVis))
+ {
+ if ( !pViewFrm )
+ pViewFrm = SfxViewFrame::Current();
+
+ // #79379# bindings update causes problems with update of stylist if
+ // current style family has changed
+ //if ( pViewFrm )
+ // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher
+
+ nCurRefDlgId = bVis ? nId : 0 ; // before SetChildWindow
+
+ if ( pViewFrm )
+ {
+ // store the dialog id also in the view shell
+ SfxViewShell* pViewSh = pViewFrm->GetViewShell();
+ if ( pViewSh && pViewSh->ISA( ScTabViewShell ) )
+ ((ScTabViewShell*)pViewSh)->SetCurRefDlgId( nCurRefDlgId );
+ else
+ {
+ // no ScTabViewShell - possible for example from a Basic macro
+ bVis = FALSE;
+ nCurRefDlgId = 0; // don't set nCurRefDlgId if no dialog is created
+ }
+
+ pViewFrm->SetChildWindow( nId, bVis );
+ }
+
+ SfxApplication* pSfxApp = SFX_APP();
+ pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
+ }
+}
+
+SfxChildWindow* lcl_GetChildWinFromAnyView( USHORT nId )
+{
+ // first try the current view
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ // #i46999# current view frame can be null (for example, when closing help)
+ SfxChildWindow* pChildWnd = pViewFrm ? pViewFrm->GetChildWindow( nId ) : NULL;
+ if ( pChildWnd )
+ return pChildWnd; // found in the current view
+
+ // if not found there, get the child window from any open view
+ // it can be open only in one view because nCurRefDlgId is global
+
+ pViewFrm = SfxViewFrame::GetFirst();
+ while ( pViewFrm )
+ {
+ pChildWnd = pViewFrm->GetChildWindow( nId );
+ if ( pChildWnd )
+ return pChildWnd; // found in any view
+
+ pViewFrm = SfxViewFrame::GetNext( *pViewFrm );
+ }
+
+ return NULL; // none found
+}
+
+BOOL ScModule::IsModalMode(SfxObjectShell* pDocSh)
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ BOOL bIsModal = FALSE;
+
+ if ( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ if ( pChildWnd )
+ {
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+ bIsModal = pChildWnd->IsVisible() &&
+ !( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) );
+ }
+ else
+ {
+ // in 592 and above, the dialog isn't visible in other views
+ // if the dialog is open but can't be accessed, disable input
+
+ bIsModal = TRUE;
+ }
+
+ // pChildWnd kann 0 sein, wenn der Dialog nach dem Umschalten
+ // von einer anderen Shell noch nicht erzeugt wurde (z.B. in GetFocus)
+ }
+ else if (pDocSh)
+ {
+ ScInputHandler* pHdl = GetInputHdl();
+ if ( pHdl )
+ bIsModal = pHdl->IsModalMode(pDocSh);
+ }
+
+ return bIsModal;
+}
+
+BOOL ScModule::IsTableLocked()
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ BOOL bLocked = FALSE;
+
+ // bisher nur bei ScAnyRefDlg
+
+ if ( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ if ( pChildWnd )
+ bLocked = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow())->IsTableLocked();
+ else
+ bLocked = TRUE; // for other views, see IsModalMode
+ }
+
+ return bLocked;
+}
+
+BOOL ScModule::IsRefDialogOpen()
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ BOOL bIsOpen = FALSE;
+
+ if ( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ if ( pChildWnd )
+ bIsOpen = pChildWnd->IsVisible();
+ else
+ bIsOpen = TRUE; // for other views, see IsModalMode
+ }
+
+ return bIsOpen;
+}
+
+BOOL ScModule::IsFormulaMode()
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ BOOL bIsFormula = FALSE;
+
+ if ( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ if ( pChildWnd )
+ {
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+ bIsFormula = pChildWnd->IsVisible() && pRefDlg->IsRefInputMode();
+ }
+ }
+ else
+ {
+ ScInputHandler* pHdl = GetInputHdl();
+ if ( pHdl )
+ bIsFormula = pHdl->IsFormulaMode();
+ }
+
+ if (bIsInEditCommand)
+ bIsFormula = TRUE;
+
+ return bIsFormula;
+}
+
+void lcl_MarkedTabs( const ScMarkData& rMark, SCTAB& rStartTab, SCTAB& rEndTab )
+{
+ if (rMark.GetSelectCount() > 1)
+ {
+ BOOL bFirst = TRUE;
+ for (SCTAB i=0; i<=MAXTAB; i++)
+ if (rMark.GetTableSelect(i))
+ {
+ if (bFirst)
+ rStartTab = i;
+ rEndTab = i;
+ bFirst = FALSE;
+ }
+ }
+}
+
+void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
+ const ScMarkData* pMarkData )
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ // in Ref-Dialogen wird hiermit auch das Zoom-In ausgeloest,
+ // wenn Start und Ende der Ref unterschiedlich sind
+
+ ScRange aNew = rRef;
+ aNew.Justify(); // immer "richtig herum"
+
+ if( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ DBG_ASSERT( pChildWnd, "NoChildWin" );
+ if ( pChildWnd )
+ {
+ if ( nCurRefDlgId == SID_OPENDLG_CONSOLIDATE && pMarkData )
+ {
+ SCTAB nStartTab = aNew.aStart.Tab();
+ SCTAB nEndTab = aNew.aEnd.Tab();
+ lcl_MarkedTabs( *pMarkData, nStartTab, nEndTab );
+ aNew.aStart.SetTab(nStartTab);
+ aNew.aEnd.SetTab(nEndTab);
+ }
+
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+
+ // hide the (color) selection now instead of later from LoseFocus,
+ // don't abort the ref input that causes this call (bDoneRefMode = FALSE)
+ pRefDlg->HideReference( FALSE );
+ pRefDlg->SetReference( aNew, pDoc );
+ }
+ }
+ else
+ {
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->SetReference( aNew, pDoc );
+ else
+ {
+ DBG_ERROR("SetReference ohne Empfaenger");
+ }
+ }
+}
+
+void ScModule::AddRefEntry() // "Mehrfachselektion"
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ if ( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ DBG_ASSERT( pChildWnd, "NoChildWin" );
+ if ( pChildWnd )
+ {
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+ pRefDlg->AddRefEntry();
+ }
+ }
+ else
+ {
+ ScInputHandler* pHdl = GetInputHdl();
+ if (pHdl)
+ pHdl->AddRefEntry();
+ }
+}
+
+void ScModule::EndReference()
+{
+ //! move reference dialog handling to view
+ //! (only keep function autopilot here for references to other documents)
+
+ // in Ref-Dialogen wird hiermit auch das Zoom-In wieder aufgehoben
+
+ //! ShowRefFrame am InputHdl, wenn der Funktions-AP offen ist ???
+
+ if ( nCurRefDlgId )
+ {
+ SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
+ DBG_ASSERT( pChildWnd, "NoChildWin" );
+ if ( pChildWnd )
+ {
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+ pRefDlg->SetActive();
+ }
+ }
+}
+
+//------------------------------------------------------------------
+//
+// Idle / Online-Spelling
+//
+//------------------------------------------------------------------
+
+void ScModule::AnythingChanged()
+{
+ ULONG nOldTime = aIdleTimer.GetTimeout();
+ if ( nOldTime != SC_IDLE_MIN )
+ aIdleTimer.SetTimeout( SC_IDLE_MIN );
+
+ nIdleCount = 0;
+}
+
+void lcl_CheckNeedsRepaint( ScDocShell* pDocShell )
+{
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while ( pFrame )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if ( pViewSh )
+ pViewSh->CheckNeedsRepaint();
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+}
+
+IMPL_LINK( ScModule, IdleHandler, Timer*, EMPTYARG )
+{
+ if ( Application::AnyInput( INPUT_MOUSEANDKEYBOARD ) )
+ {
+ aIdleTimer.Start(); // Timeout unveraendert
+ return 0;
+ }
+
+ BOOL bMore = FALSE;
+ ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ BOOL bLinks = pDoc->IdleCheckLinks();
+ BOOL bWidth = pDoc->IdleCalcTextWidth();
+ BOOL bSpell = pDoc->ContinueOnlineSpelling();
+ if ( bSpell )
+ aSpellTimer.Start(); // da ist noch was
+
+ bMore = bLinks || bWidth || bSpell; // ueberhaupt noch was?
+
+ // While calculating a Basic formula, a paint event may have occured,
+ // so check the bNeedsRepaint flags for this document's views
+ if (bWidth)
+ lcl_CheckNeedsRepaint( pDocSh );
+ }
+
+ ULONG nOldTime = aIdleTimer.GetTimeout();
+ ULONG nNewTime = nOldTime;
+ if ( bMore )
+ {
+ nNewTime = SC_IDLE_MIN;
+ nIdleCount = 0;
+ }
+ else
+ {
+ // SC_IDLE_COUNT mal mit initialem Timeout, dann hochzaehlen
+
+ if ( nIdleCount < SC_IDLE_COUNT )
+ ++nIdleCount;
+ else
+ {
+ nNewTime += SC_IDLE_STEP;
+ if ( nNewTime > SC_IDLE_MAX )
+ nNewTime = SC_IDLE_MAX;
+ }
+ }
+ if ( nNewTime != nOldTime )
+ aIdleTimer.SetTimeout( nNewTime );
+
+ aIdleTimer.Start();
+ return 0;
+}
+
+IMPL_LINK( ScModule, SpellTimerHdl, Timer*, EMPTYARG )
+{
+ if ( Application::AnyInput( INPUT_KEYBOARD ) )
+ {
+ aSpellTimer.Start();
+ return 0; // dann spaeter wieder...
+ }
+
+ ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ if ( pDoc->ContinueOnlineSpelling() )
+ aSpellTimer.Start();
+ }
+ return 0;
+}
+
+ //virtuelle Methoden fuer den Optionendialog
+SfxItemSet* ScModule::CreateItemSet( USHORT nId )
+{
+ SfxItemSet* pRet = 0;
+ if(SID_SC_EDITOPTIONS == nId)
+ {
+ pRet = new SfxItemSet( GetPool(),
+ // TP_CALC:
+ SID_SCDOCOPTIONS, SID_SCDOCOPTIONS,
+ // TP_VIEW:
+ SID_SCVIEWOPTIONS, SID_SCVIEWOPTIONS,
+ SID_SC_OPT_SYNCZOOM, SID_SC_OPT_SYNCZOOM,
+ // TP_INPUT:
+ SID_SC_INPUT_SELECTION,SID_SC_INPUT_MARK_HEADER,
+ SID_SC_INPUT_TEXTWYSIWYG,SID_SC_INPUT_TEXTWYSIWYG,
+ SID_SC_INPUT_REPLCELLSWARN,SID_SC_INPUT_REPLCELLSWARN,
+ // TP_USERLISTS:
+ SCITEM_USERLIST, SCITEM_USERLIST,
+ // TP_PRINT:
+ SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
+ // TP_GRID:
+ SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
+ //
+ SID_ATTR_METRIC, SID_ATTR_METRIC,
+ SID_ATTR_DEFTABSTOP, SID_ATTR_DEFTABSTOP,
+ 0 );
+
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell,
+ SfxObjectShell::Current());
+ ScDocOptions aCalcOpt = pDocSh
+ ? pDocSh->GetDocument()->GetDocOptions()
+ : GetDocOptions();
+
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,
+ SfxViewShell::Current());
+ ScViewOptions aViewOpt = pViewSh
+ ? pViewSh->GetViewData()->GetOptions()
+ : GetViewOptions();
+
+ ScUserListItem aULItem( SCITEM_USERLIST );
+ ScUserList* pUL = ScGlobal::GetUserList();
+
+ // SFX_APP()->GetOptions( aSet );
+
+ pRet->Put( SfxUInt16Item( SID_ATTR_METRIC,
+ sal::static_int_cast<UINT16>(GetAppOptions().GetAppMetric()) ) );
+
+ // TP_CALC
+ pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP,
+ aCalcOpt.GetTabDistance()));
+ pRet->Put( ScTpCalcItem( SID_SCDOCOPTIONS, aCalcOpt ) );
+
+ // TP_VIEW
+ pRet->Put( ScTpViewItem( SID_SCVIEWOPTIONS, aViewOpt ) );
+ pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, GetAppOptions().GetSynchronizeZoom() ) );
+
+ // TP_INPUT
+ const ScInputOptions& rInpOpt = GetInputOptions();
+ pRet->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS,
+ rInpOpt.GetMoveDir() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_SELECTION,
+ rInpOpt.GetMoveSelection() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE,
+ rInpOpt.GetEnterEdit() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND,
+ rInpOpt.GetExtendFormat() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER,
+ rInpOpt.GetRangeFinder() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND,
+ rInpOpt.GetExpandRefs() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER,
+ rInpOpt.GetMarkHeader() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG,
+ rInpOpt.GetTextWysiwyg() ) );
+ pRet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN,
+ rInpOpt.GetReplaceCellsWarn() ) );
+
+ // RID_SC_TP_PRINT
+ pRet->Put( ScTpPrintItem( SID_SCPRINTOPTIONS, GetPrintOptions() ) );
+
+ // TP_GRID
+ SvxGridItem* pSvxGridItem = aViewOpt.CreateGridItem();
+ pRet->Put( *pSvxGridItem );
+ delete pSvxGridItem;
+
+ // TP_USERLISTS
+ if ( pUL )
+ aULItem.SetUserList( *pUL );
+ pRet->Put( aULItem );
+
+ }
+ return pRet;
+}
+
+void ScModule::ApplyItemSet( USHORT nId, const SfxItemSet& rSet )
+{
+ if(SID_SC_EDITOPTIONS == nId)
+ {
+ ModifyOptions( rSet );
+ }
+}
+
+SfxTabPage* ScModule::CreateTabPage( USHORT nId, Window* pParent, const SfxItemSet& rSet )
+{
+ SfxTabPage* pRet = NULL;
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ switch(nId)
+ {
+ case SID_SC_TP_LAYOUT:
+ {
+ ::CreateTabPage ScTpLayoutOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_LAYOUT );
+ if ( ScTpLayoutOptionsCreate )
+ pRet = (*ScTpLayoutOptionsCreate) (pParent, rSet);
+ }
+ break;
+ case SID_SC_TP_CONTENT:
+ {
+ ::CreateTabPage ScTpContentOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SCPAGE_CONTENT);
+ if ( ScTpContentOptionsCreate )
+ pRet = (*ScTpContentOptionsCreate)(pParent, rSet);
+ }
+ break;
+ case SID_SC_TP_GRID: pRet = SvxGridTabPage::Create(pParent, rSet); break;
+ case SID_SC_TP_USERLISTS:
+ {
+ ::CreateTabPage ScTpUserListsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_USERLISTS );
+ if ( ScTpUserListsCreate )
+ pRet = (*ScTpUserListsCreate)( pParent, rSet);
+ }
+ break;
+ case SID_SC_TP_CALC:
+ {
+ ::CreateTabPage ScTpCalcOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_CALC );
+ if ( ScTpCalcOptionsCreate )
+ pRet = (*ScTpCalcOptionsCreate)(pParent, rSet);
+ }
+ break;
+ case SID_SC_TP_FORMULA:
+ {
+ ::CreateTabPage ScTpFormulaOptionsCreate = pFact->GetTabPageCreatorFunc (RID_SCPAGE_FORMULA);
+ if (ScTpFormulaOptionsCreate)
+ pRet = (*ScTpFormulaOptionsCreate)(pParent, rSet);
+ }
+ break;
+ case SID_SC_TP_COMPATIBILITY:
+ {
+ ::CreateTabPage ScTpCompatOptionsCreate = pFact->GetTabPageCreatorFunc (RID_SCPAGE_COMPATIBILITY);
+ if (ScTpCompatOptionsCreate)
+ pRet = (*ScTpCompatOptionsCreate)(pParent, rSet);
+ }
+ break;
+ case SID_SC_TP_CHANGES:
+ {
+ ::CreateTabPage ScRedlineOptionsTabPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE );
+ if ( ScRedlineOptionsTabPageCreate )
+ pRet =(*ScRedlineOptionsTabPageCreate)(pParent, rSet);
+ }
+ break;
+ case RID_SC_TP_PRINT:
+ {
+ ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
+ if ( ScTpPrintOptionsCreate )
+ pRet = (*ScTpPrintOptionsCreate)( pParent, rSet);
+ }
+ break;
+ case RID_OFA_TP_INTERNATIONAL:
+ {
+ SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
+ if ( pSfxFact )
+ {
+ ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
+ if ( fnCreatePage )
+ pRet = (*fnCreatePage)( pParent, rSet );
+ }
+ }
+ }
+
+ DBG_ASSERT( pRet, "ScModule::CreateTabPage(): no valid ID for TabPage!" );
+
+ return pRet;
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo )
+{
+ //! mit ScFieldEditEngine zusammenfassen !!!
+
+ if (pInfo)
+ {
+ const SvxFieldItem& rField = pInfo->GetField();
+ const SvxFieldData* pField = rField.GetField();
+
+ if (pField && pField->ISA(SvxURLField))
+ {
+ /******************************************************************
+ * URL-Field
+ ******************************************************************/
+
+ const SvxURLField* pURLField = (const SvxURLField*) pField;
+ String aURL = pURLField->GetURL();
+
+ switch ( pURLField->GetFormat() )
+ {
+ case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
+ case SVXURLFORMAT_REPR:
+ {
+ pInfo->SetRepresentation( pURLField->GetRepresentation() );
+ }
+ break;
+
+ case SVXURLFORMAT_URL:
+ {
+ pInfo->SetRepresentation( aURL );
+ }
+ break;
+ }
+
+ svtools::ColorConfigEntry eEntry =
+ INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
+ pInfo->SetTxtColor( GetColorConfig().GetColorValue(eEntry).nColor );
+ }
+ else
+ {
+ DBG_ERROR("unbekannter Feldbefehl");
+ pInfo->SetRepresentation(String('?'));
+ }
+ }
+
+ return 0;
+}
+
+BOOL ScModule::RegisterRefWindow( USHORT nSlotId, Window *pWnd )
+{
+ std::list<Window*> & rlRefWindow = m_mapRefWindow[nSlotId];
+
+ if( std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ) == rlRefWindow.end() )
+ {
+ rlRefWindow.push_back( pWnd );
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL ScModule::UnregisterRefWindow( USHORT nSlotId, Window *pWnd )
+{
+ std::map<USHORT, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId );
+
+ if( iSlot == m_mapRefWindow.end() )
+ return FALSE;
+
+ std::list<Window*> & rlRefWindow = iSlot->second;
+
+ std::list<Window*>::iterator i = std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd );
+
+ if( i == rlRefWindow.end() )
+ return FALSE;
+
+ rlRefWindow.erase( i );
+
+ if( !rlRefWindow.size() )
+ m_mapRefWindow.erase( nSlotId );
+
+ return TRUE;
+}
+
+BOOL ScModule::IsAliveRefDlg( USHORT nSlotId, Window *pWnd )
+{
+ std::map<USHORT, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId );
+
+ if( iSlot == m_mapRefWindow.end() )
+ return FALSE;
+
+ std::list<Window*> & rlRefWindow = iSlot->second;
+
+ return rlRefWindow.end() != std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd );
+}
+
+Window * ScModule::Find1RefWindow( USHORT nSlotId, Window *pWndAncestor )
+{
+ if (!pWndAncestor)
+ return NULL;
+
+ std::map<USHORT, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId );
+
+ if( iSlot == m_mapRefWindow.end() )
+ return NULL;
+
+ std::list<Window*> & rlRefWindow = iSlot->second;
+
+ while( Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent;
+
+ for( std::list<Window*>::iterator i = rlRefWindow.begin(); i!=rlRefWindow.end(); i++ )
+ if ( pWndAncestor->IsWindowOrChild( *i, (*i)->IsSystemWindow() ) )
+ return *i;
+
+ return NULL;
+}
+
+Window * ScModule::Find1RefWindow( Window *pWndAncestor )
+{
+ if (!pWndAncestor)
+ return NULL;
+
+ while( Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent;
+
+ for( std::map<USHORT, std::list<Window*> >::iterator i = m_mapRefWindow.begin();
+ i!=m_mapRefWindow.end(); i++ )
+ for( std::list<Window*>::iterator j = i->second.begin(); j!=i->second.end(); j++ )
+ if ( pWndAncestor->IsWindowOrChild( *j, (*j)->IsSystemWindow() ) )
+ return *j;
+
+ return NULL;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scmod2.cxx b/sc/source/ui/app/scmod2.cxx
new file mode 100644
index 000000000000..390d9c29ad55
--- /dev/null
+++ b/sc/source/ui/app/scmod2.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <editeng/unolingu.hxx>
+#include <unotools/lingucfg.hxx>
+#include <i18npool/mslangid.hxx>
+#include <com/sun/star/i18n/ScriptType.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+
+using namespace com::sun::star;
+
+#include "scmod.hxx"
+
+//------------------------------------------------------------------
+
+#define LINGUPROP_AUTOSPELL "IsSpellAuto"
+
+//------------------------------------------------------------------
+
+// static
+void ScModule::GetSpellSettings( USHORT& rDefLang, USHORT& rCjkLang, USHORT& rCtlLang,
+ BOOL& rAutoSpell )
+{
+ // use SvtLinguConfig instead of service LinguProperties to avoid
+ // loading the linguistic component
+ SvtLinguConfig aConfig;
+
+ SvtLinguOptions aOptions;
+ aConfig.GetOptions( aOptions );
+
+ rDefLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN);
+ rCjkLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN);
+ rCtlLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX);
+ rAutoSpell = aOptions.bIsSpellAuto;
+}
+
+// static
+void ScModule::SetAutoSpellProperty( BOOL bSet )
+{
+ // use SvtLinguConfig instead of service LinguProperties to avoid
+ // loading the linguistic component
+ SvtLinguConfig aConfig;
+
+ uno::Any aAny;
+ aAny <<= bSet;
+ aConfig.SetProperty( rtl::OUString::createFromAscii( LINGUPROP_AUTOSPELL ), aAny );
+}
+
+
+
+// static
+BOOL ScModule::HasThesaurusLanguage( USHORT nLang )
+{
+ if ( nLang == LANGUAGE_NONE )
+ return FALSE;
+
+ lang::Locale aLocale;
+ SvxLanguageToLocale( aLocale, nLang );
+
+ BOOL bHasLang = FALSE;
+ try
+ {
+ uno::Reference< linguistic2::XThesaurus > xThes(LinguMgr::GetThesaurus());
+ if ( xThes.is() )
+ bHasLang = xThes->hasLocale( aLocale );
+ }
+ catch( uno::Exception& )
+ {
+ DBG_ERROR("Error in Thesaurus");
+ }
+
+ return bHasLang;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/seltrans.cxx b/sc/source/ui/app/seltrans.cxx
new file mode 100644
index 000000000000..74356ed46188
--- /dev/null
+++ b/sc/source/ui/app/seltrans.cxx
@@ -0,0 +1,451 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+
+#include <tools/urlobj.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdouno.hxx>
+
+#include "seltrans.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "scmod.hxx"
+#include "dbfunc.hxx" // for CopyToClip
+#include "docsh.hxx"
+#include "drawview.hxx"
+#include "drwlayer.hxx"
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+BOOL lcl_IsURLButton( SdrObject* pObject )
+{
+ BOOL bRet = FALSE;
+
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObject);
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
+ DBG_ASSERT( xControlModel.is(), "uno control without model" );
+ if ( xControlModel.is() )
+ {
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
+
+ rtl::OUString sPropButtonType = rtl::OUString::createFromAscii( "ButtonType" );
+ if(xInfo->hasPropertyByName( sPropButtonType ))
+ {
+ uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
+ form::FormButtonType eTmp;
+ if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+// static
+
+ScSelectionTransferObj* ScSelectionTransferObj::CreateFromView( ScTabView* pView )
+{
+ ScSelectionTransferObj* pRet = NULL;
+
+ if ( pView )
+ {
+ ScSelectionTransferMode eMode = SC_SELTRANS_INVALID;
+
+ SdrView* pSdrView = pView->GetSdrView();
+ if ( pSdrView )
+ {
+ // handle selection on drawing layer
+ const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+ if ( nMarkCount )
+ {
+ if ( nMarkCount == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ UINT16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ if ( nSdrObjKind == OBJ_GRAF )
+ {
+ if ( ((SdrGrafObj*)pObj)->GetGraphic().GetType() == GRAPHIC_BITMAP )
+ eMode = SC_SELTRANS_DRAW_BITMAP;
+ else
+ eMode = SC_SELTRANS_DRAW_GRAPHIC;
+ }
+ else if ( nSdrObjKind == OBJ_OLE2 )
+ eMode = SC_SELTRANS_DRAW_OLE;
+ else if ( lcl_IsURLButton( pObj ) )
+ eMode = SC_SELTRANS_DRAW_BOOKMARK;
+ }
+
+ if ( eMode == SC_SELTRANS_INVALID )
+ eMode = SC_SELTRANS_DRAW_OTHER; // something selected but no special selection
+ }
+ }
+ if ( eMode == SC_SELTRANS_INVALID ) // no drawing object selected
+ {
+ ScRange aRange;
+ ScViewData* pViewData = pView->GetViewData();
+ const ScMarkData& rMark = pViewData->GetMarkData();
+ // allow MultiMarked because GetSimpleArea may be able to merge into a simple range
+ // (GetSimpleArea modifies a local copy of MarkData)
+ // Also allow simple filtered area.
+ ScMarkType eMarkType;
+ if ( ( rMark.IsMarked() || rMark.IsMultiMarked() ) &&
+ (((eMarkType = pViewData->GetSimpleArea( aRange )) == SC_MARK_SIMPLE) ||
+ (eMarkType == SC_MARK_SIMPLE_FILTERED)) )
+ {
+ // only for "real" selection, cursor alone isn't used
+ if ( aRange.aStart == aRange.aEnd )
+ eMode = SC_SELTRANS_CELL;
+ else
+ eMode = SC_SELTRANS_CELLS;
+ }
+ }
+
+ if ( eMode != SC_SELTRANS_INVALID )
+ pRet = new ScSelectionTransferObj( pView, eMode );
+ }
+
+ return pRet;
+}
+
+
+ScSelectionTransferObj::ScSelectionTransferObj( ScTabView* pSource, ScSelectionTransferMode eNewMode ) :
+ pView( pSource ),
+ eMode( eNewMode ),
+ pCellData( NULL ),
+ pDrawData( NULL )
+{
+ //! store range for StillValid
+}
+
+ScSelectionTransferObj::~ScSelectionTransferObj()
+{
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetSelectionTransfer() == this )
+ {
+ // this is reached when the object wasn't really copied to the selection
+ // (CopyToSelection has no effect under Windows)
+
+ ForgetView();
+ pScMod->SetSelectionTransfer( NULL );
+ }
+
+ DBG_ASSERT( !pView, "ScSelectionTransferObj dtor: ForgetView not called" );
+}
+
+BOOL ScSelectionTransferObj::StillValid()
+{
+ //! check if view still has same cell selection
+ //! (but return FALSE if data has changed inbetween)
+ return FALSE;
+}
+
+void ScSelectionTransferObj::ForgetView()
+{
+ pView = NULL;
+ eMode = SC_SELTRANS_INVALID;
+
+ if (pCellData)
+ {
+ pCellData->release();
+ pCellData = NULL;
+ }
+ if (pDrawData)
+ {
+ pDrawData->release();
+ pDrawData = NULL;
+ }
+}
+
+void ScSelectionTransferObj::AddSupportedFormats()
+{
+ // AddSupportedFormats must work without actually creating the
+ // "real" transfer object
+
+ switch (eMode)
+ {
+ case SC_SELTRANS_CELL:
+ case SC_SELTRANS_CELLS:
+ // same formats as in ScTransferObj::AddSupportedFormats
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMAT_BITMAP );
+ AddFormat( SOT_FORMATSTR_ID_HTML );
+ AddFormat( SOT_FORMATSTR_ID_SYLK );
+ AddFormat( SOT_FORMATSTR_ID_LINK );
+ AddFormat( SOT_FORMATSTR_ID_DIF );
+ AddFormat( SOT_FORMAT_STRING );
+ AddFormat( SOT_FORMAT_RTF );
+ if ( eMode == SC_SELTRANS_CELL )
+ AddFormat( SOT_FORMATSTR_ID_EDITENGINE );
+ break;
+
+ // different graphic formats as in ScDrawTransferObj::AddSupportedFormats:
+
+ case SC_SELTRANS_DRAW_BITMAP:
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ AddFormat( SOT_FORMAT_BITMAP );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ break;
+
+ case SC_SELTRANS_DRAW_GRAPHIC:
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_SVXB );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMAT_BITMAP );
+ break;
+
+ case SC_SELTRANS_DRAW_BOOKMARK:
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_SOLK );
+ AddFormat( SOT_FORMAT_STRING );
+ AddFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR );
+ AddFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ break;
+
+ case SC_SELTRANS_DRAW_OLE:
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ break;
+
+ case SC_SELTRANS_DRAW_OTHER:
+ // other drawing objects
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMATSTR_ID_DRAWING );
+ AddFormat( SOT_FORMAT_BITMAP );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+}
+
+void ScSelectionTransferObj::CreateCellData()
+{
+ DBG_ASSERT( !pCellData, "CreateCellData twice" );
+ if ( pView )
+ {
+ ScViewData* pViewData = pView->GetViewData();
+ ScMarkData aNewMark( pViewData->GetMarkData() ); // use local copy for MarkToSimple
+ aNewMark.MarkToSimple();
+
+ // similar to ScViewFunctionSet::BeginDrag
+ if ( aNewMark.IsMarked() && !aNewMark.IsMultiMarked() )
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ ScRange aSelRange;
+ aNewMark.GetMarkArea( aSelRange );
+ ScDocShellRef aDragShellRef;
+ if ( pDocSh->GetDocument()->HasOLEObjectsInArea( aSelRange, &aNewMark ) )
+ {
+ aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately
+ aDragShellRef->DoInitNew(NULL);
+ }
+ ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
+
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ // bApi = TRUE -> no error mesages
+ // #i18364# bStopEdit = FALSE -> don't end edit mode
+ // (this may be called from pasting into the edit line)
+ BOOL bCopied = pViewData->GetView()->CopyToClip( pClipDoc, FALSE, TRUE, TRUE, FALSE );
+
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ if ( bCopied )
+ {
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScTransferObj ctor
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ // SetDragHandlePos is not used - there is no mouse position
+ //? pTransferObj->SetVisibleTab( nTab );
+
+ SfxObjectShellRef aPersistRef( aDragShellRef );
+ pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive
+
+ pTransferObj->SetDragSource( pDocSh, aNewMark );
+
+ pCellData = pTransferObj;
+ pCellData->acquire(); // keep ref count up - released in ForgetView
+ }
+ else
+ delete pClipDoc;
+ }
+ }
+ DBG_ASSERT( pCellData, "can't create CellData" );
+}
+
+//! make static member of ScDrawView
+extern void lcl_CheckOle( const SdrMarkList& rMarkList, BOOL& rAnyOle, BOOL& rOneOle );
+
+void ScSelectionTransferObj::CreateDrawData()
+{
+ DBG_ASSERT( !pDrawData, "CreateDrawData twice" );
+ if ( pView )
+ {
+ // similar to ScDrawView::BeginDrag
+
+ ScDrawView* pDrawView = pView->GetScDrawView();
+ if ( pDrawView )
+ {
+ BOOL bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ //---------------------------------------------------------
+ ScDocShellRef aDragShellRef;
+ if (bAnyOle)
+ {
+ aDragShellRef = new ScDocShell; // ohne Ref lebt die DocShell nicht !!!
+ aDragShellRef->DoInitNew(NULL);
+ }
+ //---------------------------------------------------------
+
+ ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
+ SdrModel* pModel = pDrawView->GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ ScViewData* pViewData = pView->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ SfxObjectShellRef aPersistRef( aDragShellRef );
+ pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive
+ pTransferObj->SetDragSource( pDrawView ); // copies selection
+
+ pDrawData = pTransferObj;
+ pDrawData->acquire(); // keep ref count up - released in ForgetView
+ }
+ }
+ DBG_ASSERT( pDrawData, "can't create DrawData" );
+}
+
+ScTransferObj* ScSelectionTransferObj::GetCellData()
+{
+ if ( !pCellData && ( eMode == SC_SELTRANS_CELL || eMode == SC_SELTRANS_CELLS ) )
+ CreateCellData();
+ return pCellData;
+}
+
+ScDrawTransferObj* ScSelectionTransferObj::GetDrawData()
+{
+ if ( !pDrawData && ( eMode == SC_SELTRANS_DRAW_BITMAP || eMode == SC_SELTRANS_DRAW_GRAPHIC ||
+ eMode == SC_SELTRANS_DRAW_BOOKMARK || eMode == SC_SELTRANS_DRAW_OLE ||
+ eMode == SC_SELTRANS_DRAW_OTHER ) )
+ CreateDrawData();
+ return pDrawData;
+}
+
+sal_Bool ScSelectionTransferObj::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor )
+{
+ sal_Bool bOK = sal_False;
+
+ uno::Reference<datatransfer::XTransferable> xSource;
+ switch (eMode)
+ {
+ case SC_SELTRANS_CELL:
+ case SC_SELTRANS_CELLS:
+ xSource = GetCellData();
+ break;
+ case SC_SELTRANS_DRAW_BITMAP:
+ case SC_SELTRANS_DRAW_GRAPHIC:
+ case SC_SELTRANS_DRAW_BOOKMARK:
+ case SC_SELTRANS_DRAW_OLE:
+ case SC_SELTRANS_DRAW_OTHER:
+ xSource = GetDrawData();
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if ( xSource.is() )
+ {
+ TransferableDataHelper aHelper( xSource );
+ uno::Any aAny = aHelper.GetAny( rFlavor );
+ bOK = SetAny( aAny, rFlavor );
+ }
+
+ return bOK;
+}
+
+void ScSelectionTransferObj::ObjectReleased()
+{
+ // called when another selection is set from outside
+
+ ForgetView();
+
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetSelectionTransfer() == this )
+ pScMod->SetSelectionTransfer( NULL );
+
+ TransferableHelper::ObjectReleased();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/template.cxx b/sc/source/ui/app/template.cxx
new file mode 100644
index 000000000000..afec56dd0a9c
--- /dev/null
+++ b/sc/source/ui/app/template.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "template.hxx"
+
+//------------------------------------------------------------------------
+
+ScTemplateDlg::ScTemplateDlg(Window * pParent, USHORT nAppResource) :
+// SfxTemplateDlg( pParent, nAppResource )
+ SfxTemplateDialog( pParent )
+{
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScTemplateDlg::~ScTemplateDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScTemplateDlg::New(String &rNewName)
+{
+ return TRUE;
+}
+
+
+void ScTemplateDlg::Edit(const String &)
+{
+}
+
+
+BOOL ScTemplateDlg::Delete(const String &)
+{
+ return TRUE;
+}
+
+
+void ScTemplateDlg::InvalidateTemplates()
+{
+}
+
+
+void ScTemplateDlg::ToggleApplyTemplate()
+{
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
new file mode 100644
index 000000000000..d2978210361b
--- /dev/null
+++ b/sc/source/ui/app/transobj.cxx
@@ -0,0 +1,869 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <editeng/justifyitem.hxx>
+
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+
+#include <unotools/tempfile.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <sot/storage.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
+#include <osl/mutex.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+
+#include "transobj.hxx"
+#include "document.hxx"
+#include "viewopti.hxx"
+#include "editutil.hxx"
+#include "impex.hxx"
+#include "cell.hxx"
+#include "printfun.hxx"
+#include "docfunc.hxx"
+#include "scmod.hxx"
+
+// for InitDocShell
+#include <editeng/paperinf.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/algitem.hxx>
+#include <svl/intitem.hxx>
+#include <svl/zforlist.hxx>
+#include "docsh.hxx"
+#include "markdata.hxx"
+#include "stlpool.hxx"
+#include "viewdata.hxx"
+#include "dociter.hxx"
+#include "cellsuno.hxx"
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+#define SCTRANS_TYPE_IMPEX 1
+#define SCTRANS_TYPE_EDIT_RTF 2
+#define SCTRANS_TYPE_EDIT_BIN 3
+#define SCTRANS_TYPE_EMBOBJ 4
+
+// -----------------------------------------------------------------------
+
+// static
+void ScTransferObj::GetAreaSize( ScDocument* pDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol )
+{
+ SCCOL nMaxCol = 0;
+ SCROW nMaxRow = 0;
+ for( SCTAB nTab = nTab1; nTab <= nTab2; nTab++ )
+ {
+ SCCOL nLastCol = 0;
+ SCROW nLastRow = 0;
+ // GetPrintArea instead of GetCellArea - include drawing objects
+ if( pDoc->GetPrintArea( nTab, nLastCol, nLastRow ) )
+ {
+ if( nLastCol > nMaxCol )
+ nMaxCol = nLastCol;
+ if( nLastRow > nMaxRow )
+ nMaxRow = nLastRow;
+ }
+ }
+ nRow = nMaxRow;
+ nCol = nMaxCol;
+}
+
+// static
+void ScTransferObj::PaintToDev( OutputDevice* pDev, ScDocument* pDoc, double nPrintFactor,
+ const ScRange& rBlock, BOOL bMetaFile )
+{
+ if (!pDoc)
+ return;
+
+ Point aPoint;
+ Rectangle aBound( aPoint, pDev->GetOutputSize() ); //! use size from clip area?
+
+ ScViewData aViewData(NULL,NULL);
+ aViewData.InitData( pDoc );
+
+ aViewData.SetTabNo( rBlock.aEnd.Tab() );
+ aViewData.SetScreen( rBlock.aStart.Col(), rBlock.aStart.Row(),
+ rBlock.aEnd.Col(), rBlock.aEnd.Row() );
+
+ ScPrintFunc::DrawToDev( pDoc, pDev, nPrintFactor, aBound, &aViewData, bMetaFile );
+}
+
+// -----------------------------------------------------------------------
+
+ScTransferObj::ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDescriptor& rDesc ) :
+ pDoc( pClipDoc ),
+ aObjDesc( rDesc ),
+ nDragHandleX( 0 ),
+ nDragHandleY( 0 ),
+ nDragSourceFlags( 0 ),
+ bDragWasInternal( FALSE ),
+ bUsedForLink( FALSE )
+{
+ DBG_ASSERT(pDoc->IsClipboard(), "wrong document");
+
+ //
+ // get aBlock from clipboard doc
+ //
+
+ SCCOL nCol1;
+ SCROW nRow1;
+ SCCOL nCol2;
+ SCROW nRow2;
+ pDoc->GetClipStart( nCol1, nRow1 );
+ pDoc->GetClipArea( nCol2, nRow2, TRUE ); // real source area - include filtered rows
+ nCol2 = sal::static_int_cast<SCCOL>( nCol2 + nCol1 );
+ nRow2 = sal::static_int_cast<SCROW>( nRow2 + nRow1 );
+
+ SCCOL nDummy;
+ pDoc->GetClipArea( nDummy, nNonFiltered, FALSE );
+ bHasFiltered = (nNonFiltered < (nRow2 - nRow1));
+ ++nNonFiltered; // to get count instead of diff
+
+ SCTAB nTab1=0;
+ SCTAB nTab2=0;
+ BOOL bFirst = TRUE;
+ for (SCTAB i=0; i<=MAXTAB; i++)
+ if (pDoc->HasTable(i))
+ {
+ if (bFirst)
+ nTab1 = i;
+ nTab2 = i;
+ bFirst = FALSE;
+ }
+ DBG_ASSERT(!bFirst, "no sheet selected");
+
+ // only limit to used cells if whole sheet was marked
+ // (so empty cell areas can be copied)
+ if ( nCol2>=MAXCOL && nRow2>=MAXROW )
+ {
+ SCROW nMaxRow;
+ SCCOL nMaxCol;
+ GetAreaSize( pDoc, nTab1, nTab2, nMaxRow, nMaxCol );
+ if( nMaxRow < nRow2 )
+ nRow2 = nMaxRow;
+ if( nMaxCol < nCol2 )
+ nCol2 = nMaxCol;
+ }
+
+ aBlock = ScRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ nVisibleTab = nTab1; // valid table as default
+
+ Rectangle aMMRect = pDoc->GetMMRect( nCol1,nRow1, nCol2,nRow2, nTab1 );
+ aObjDesc.maSize = aMMRect.GetSize();
+ PrepareOLE( aObjDesc );
+}
+
+ScTransferObj::~ScTransferObj()
+{
+ SolarMutexGuard aSolarGuard;
+
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetClipData().pCellClipboard == this )
+ {
+ DBG_ERROR("ScTransferObj wasn't released");
+ pScMod->SetClipObject( NULL, NULL );
+ }
+ if ( pScMod->GetDragData().pCellTransfer == this )
+ {
+ DBG_ERROR("ScTransferObj wasn't released");
+ pScMod->ResetDragObject();
+ }
+
+ delete pDoc; // ScTransferObj is owner of clipboard document
+
+ aDocShellRef.Clear(); // before releasing the mutex
+
+ aDrawPersistRef.Clear(); // after the model
+
+}
+
+// static
+ScTransferObj* ScTransferObj::GetOwnClipboard( Window* pUIWin )
+{
+ ScTransferObj* pObj = SC_MOD()->GetClipData().pCellClipboard;
+ if ( pObj && pUIWin )
+ {
+ // check formats to see if pObj is really in the system clipboard
+
+ // pUIWin is NULL when called from core (IsClipboardSource),
+ // in that case don't access the system clipboard, because the call
+ // may be from other clipboard operations (like flushing, #86059#)
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pUIWin ) );
+ if ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_DIF ) )
+ {
+// DBG_ERROR("ScTransferObj wasn't released");
+ pObj = NULL;
+ }
+ }
+ return pObj;
+}
+
+void ScTransferObj::AddSupportedFormats()
+{
+ AddFormat( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR );
+ AddFormat( SOT_FORMAT_GDIMETAFILE );
+ AddFormat( SOT_FORMAT_BITMAP );
+
+ // ScImportExport formats
+ AddFormat( SOT_FORMATSTR_ID_HTML );
+ AddFormat( SOT_FORMATSTR_ID_SYLK );
+ AddFormat( SOT_FORMATSTR_ID_LINK );
+ AddFormat( SOT_FORMATSTR_ID_DIF );
+ AddFormat( SOT_FORMAT_STRING );
+
+ AddFormat( SOT_FORMAT_RTF );
+ if ( aBlock.aStart == aBlock.aEnd )
+ AddFormat( SOT_FORMATSTR_ID_EDITENGINE );
+}
+
+sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor )
+{
+ sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
+ sal_Bool bOK = sal_False;
+
+ if( HasFormat( nFormat ) )
+ {
+ if ( nFormat == SOT_FORMATSTR_ID_LINKSRCDESCRIPTOR || nFormat == SOT_FORMATSTR_ID_OBJECTDESCRIPTOR )
+ {
+ bOK = SetTransferableObjectDescriptor( aObjDesc, rFlavor );
+ }
+ else if ( ( nFormat == SOT_FORMAT_RTF || nFormat == SOT_FORMATSTR_ID_EDITENGINE ) &&
+ aBlock.aStart == aBlock.aEnd )
+ {
+ // RTF from a single cell is handled by EditEngine
+
+ SCCOL nCol = aBlock.aStart.Col();
+ SCROW nRow = aBlock.aStart.Row();
+ SCTAB nTab = aBlock.aStart.Tab();
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ ScTabEditEngine aEngine( *pPattern, pDoc->GetEditPool() );
+ ScBaseCell* pCell = NULL;
+ pDoc->GetCell( nCol, nRow, nTab, pCell );
+ if (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ const EditTextObject* pObj;
+ ((ScEditCell*)pCell)->GetData(pObj);
+ aEngine.SetText( *pObj );
+ }
+ else
+ {
+ String aText;
+ pDoc->GetString( nCol, nRow, nTab, aText );
+ aEngine.SetText(aText);
+ }
+ }
+
+ bOK = SetObject( &aEngine,
+ (nFormat == FORMAT_RTF) ? SCTRANS_TYPE_EDIT_RTF : SCTRANS_TYPE_EDIT_BIN,
+ rFlavor );
+ }
+ else if ( ScImportExport::IsFormatSupported( nFormat ) || nFormat == SOT_FORMAT_RTF )
+ {
+ // if this transfer object was used to create a DDE link, filtered rows
+ // have to be included for subsequent calls (to be consistent with link data)
+ if ( nFormat == SOT_FORMATSTR_ID_LINK )
+ bUsedForLink = TRUE;
+
+ BOOL bIncludeFiltered = pDoc->IsCutMode() || bUsedForLink;
+
+ ScImportExport aObj( pDoc, aBlock );
+ if ( bUsedForLink )
+ aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, ' ', false ) );
+ aObj.SetFormulas( pDoc->GetViewOptions().GetOption( VOPT_FORMULAS ) );
+ aObj.SetIncludeFiltered( bIncludeFiltered );
+
+ // DataType depends on format type:
+
+ if ( rFlavor.DataType.equals( ::getCppuType( (const ::rtl::OUString*) 0 ) ) )
+ {
+ rtl::OUString aString;
+ if ( aObj.ExportString( aString, nFormat ) )
+ bOK = SetString( aString, rFlavor );
+ }
+ else if ( rFlavor.DataType.equals( ::getCppuType( (const uno::Sequence< sal_Int8 >*) 0 ) ) )
+ {
+ // SetObject converts a stream into a Int8-Sequence
+ bOK = SetObject( &aObj, SCTRANS_TYPE_IMPEX, rFlavor );
+ }
+ else
+ {
+ DBG_ERROR("unknown DataType");
+ }
+ }
+ else if ( nFormat == SOT_FORMAT_BITMAP )
+ {
+ Rectangle aMMRect = pDoc->GetMMRect( aBlock.aStart.Col(), aBlock.aStart.Row(),
+ aBlock.aEnd.Col(), aBlock.aEnd.Row(),
+ aBlock.aStart.Tab() );
+ VirtualDevice aVirtDev;
+ aVirtDev.SetOutputSizePixel( aVirtDev.LogicToPixel( aMMRect.GetSize(), MAP_100TH_MM ) );
+
+ PaintToDev( &aVirtDev, pDoc, 1.0, aBlock, FALSE );
+
+ aVirtDev.SetMapMode( MapMode( MAP_PIXEL ) );
+ Bitmap aBmp = aVirtDev.GetBitmap( Point(), aVirtDev.GetOutputSize() );
+ bOK = SetBitmap( aBmp, rFlavor );
+ }
+ else if ( nFormat == SOT_FORMAT_GDIMETAFILE )
+ {
+ InitDocShell();
+ SfxObjectShell* pEmbObj = aDocShellRef;
+
+ // like SvEmbeddedTransfer::GetData:
+
+ GDIMetaFile aMtf;
+ VirtualDevice aVDev;
+ MapMode aMapMode( pEmbObj->GetMapUnit() );
+ Rectangle aVisArea( pEmbObj->GetVisArea( ASPECT_CONTENT ) );
+
+ aVDev.EnableOutput( FALSE );
+ aVDev.SetMapMode( aMapMode );
+ aMtf.SetPrefSize( aVisArea.GetSize() );
+ aMtf.SetPrefMapMode( aMapMode );
+ aMtf.Record( &aVDev );
+
+ pEmbObj->DoDraw( &aVDev, Point(), aVisArea.GetSize(), JobSetup(), ASPECT_CONTENT );
+
+ aMtf.Stop();
+ aMtf.WindStart();
+
+ bOK = SetGDIMetaFile( aMtf, rFlavor );
+ }
+ else if ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ {
+ //TODO/LATER: differentiate between formats?!
+ InitDocShell(); // set aDocShellRef
+
+ SfxObjectShell* pEmbObj = aDocShellRef;
+ bOK = SetObject( pEmbObj, SCTRANS_TYPE_EMBOBJ, rFlavor );
+ }
+ }
+ return bOK;
+}
+
+sal_Bool ScTransferObj::WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
+ const datatransfer::DataFlavor& rFlavor )
+{
+ // called from SetObject, put data into stream
+
+ sal_Bool bRet = sal_False;
+ switch (nUserObjectId)
+ {
+ case SCTRANS_TYPE_IMPEX:
+ {
+ ScImportExport* pImpEx = (ScImportExport*)pUserObject;
+
+ sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor );
+ // mba: no BaseURL for data exchange
+ if ( pImpEx->ExportStream( *rxOStm, String(), nFormat ) )
+ bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ }
+ break;
+
+ case SCTRANS_TYPE_EDIT_RTF:
+ case SCTRANS_TYPE_EDIT_BIN:
+ {
+ ScTabEditEngine* pEngine = (ScTabEditEngine*)pUserObject;
+ if ( nUserObjectId == SCTRANS_TYPE_EDIT_RTF )
+ {
+ pEngine->Write( *rxOStm, EE_FORMAT_RTF );
+ bRet = ( rxOStm->GetError() == ERRCODE_NONE );
+ }
+ else
+ {
+ // #107722# can't use Write for EditEngine format because that would
+ // write old format without support for unicode characters.
+ // Get the data from the EditEngine's transferable instead.
+
+ USHORT nParCnt = pEngine->GetParagraphCount();
+ if ( nParCnt == 0 )
+ nParCnt = 1;
+ ESelection aSel( 0, 0, nParCnt-1, pEngine->GetTextLen(nParCnt-1) );
+
+ uno::Reference<datatransfer::XTransferable> xEditTrans = pEngine->CreateTransferable( aSel );
+ TransferableDataHelper aEditHelper( xEditTrans );
+
+ bRet = aEditHelper.GetSotStorageStream( rFlavor, rxOStm );
+ }
+ }
+ break;
+
+ case SCTRANS_TYPE_EMBOBJ:
+ {
+ // TODO/MBA: testing
+ SfxObjectShell* pEmbObj = (SfxObjectShell*) pUserObject;
+ ::utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+ uno::Reference< embed::XStorage > xWorkStore =
+ ::comphelper::OStorageHelper::GetStorageFromURL( aTempFile.GetURL(), embed::ElementModes::READWRITE );
+
+ // write document storage
+ pEmbObj->SetupStorage( xWorkStore, SOFFICE_FILEFORMAT_CURRENT, sal_False );
+
+ // mba: no relative ULRs for clipboard!
+ SfxMedium aMedium( xWorkStore, String() );
+ bRet = pEmbObj->DoSaveObjectAs( aMedium, FALSE );
+ pEmbObj->DoSaveCompleted();
+
+ uno::Reference< embed::XTransactedObject > xTransact( xWorkStore, uno::UNO_QUERY );
+ if ( xTransact.is() )
+ xTransact->commit();
+
+ SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), STREAM_READ );
+ if( pSrcStm )
+ {
+ rxOStm->SetBufferSize( 0xff00 );
+ *rxOStm << *pSrcStm;
+ delete pSrcStm;
+ }
+
+ bRet = TRUE;
+
+ xWorkStore->dispose();
+ xWorkStore = uno::Reference < embed::XStorage >();
+ rxOStm->Commit();
+ }
+ break;
+
+ default:
+ DBG_ERROR("unknown object id");
+ }
+ return bRet;
+}
+
+void ScTransferObj::ObjectReleased()
+{
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetClipData().pCellClipboard == this )
+ pScMod->SetClipObject( NULL, NULL );
+
+ TransferableHelper::ObjectReleased();
+}
+
+void ScTransferObj::DragFinished( sal_Int8 nDropAction )
+{
+ if ( nDropAction == DND_ACTION_MOVE && !bDragWasInternal && !(nDragSourceFlags & SC_DROP_NAVIGATOR) )
+ {
+ // move: delete source data
+ ScDocShell* pSourceSh = GetSourceDocShell();
+ if (pSourceSh)
+ {
+ ScMarkData aMarkData = GetSourceMarkData();
+ // external drag&drop doesn't copy objects, so they also aren't deleted:
+ // #105703# bApi=TRUE, don't show error messages from drag&drop
+ pSourceSh->GetDocFunc().DeleteContents( aMarkData, IDF_ALL & ~IDF_OBJECTS, TRUE, TRUE );
+ }
+ }
+
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod->GetDragData().pCellTransfer == this )
+ pScMod->ResetDragObject();
+
+ xDragSourceRanges = NULL; // don't keep source after dropping
+
+ TransferableHelper::DragFinished( nDropAction );
+}
+
+void ScTransferObj::SetDragHandlePos( SCCOL nX, SCROW nY )
+{
+ nDragHandleX = nX;
+ nDragHandleY = nY;
+}
+
+void ScTransferObj::SetVisibleTab( SCTAB nNew )
+{
+ nVisibleTab = nNew;
+}
+
+void ScTransferObj::SetDrawPersist( const SfxObjectShellRef& rRef )
+{
+ aDrawPersistRef = rRef;
+}
+
+void ScTransferObj::SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark )
+{
+ ScRangeList aRanges;
+ rMark.FillRangeListWithMarks( &aRanges, FALSE );
+ xDragSourceRanges = new ScCellRangesObj( pSourceShell, aRanges );
+}
+
+void ScTransferObj::SetDragSourceFlags( USHORT nFlags )
+{
+ nDragSourceFlags = nFlags;
+}
+
+void ScTransferObj::SetDragWasInternal()
+{
+ bDragWasInternal = TRUE;
+}
+
+ScDocument* ScTransferObj::GetSourceDocument()
+{
+ ScDocShell* pSourceDocSh = GetSourceDocShell();
+ if (pSourceDocSh)
+ return pSourceDocSh->GetDocument();
+ return NULL;
+}
+
+ScDocShell* ScTransferObj::GetSourceDocShell()
+{
+ ScCellRangesBase* pRangesObj = ScCellRangesBase::getImplementation( xDragSourceRanges );
+ if (pRangesObj)
+ return pRangesObj->GetDocShell();
+
+ return NULL; // none set
+}
+
+ScMarkData ScTransferObj::GetSourceMarkData()
+{
+ ScMarkData aMarkData;
+ ScCellRangesBase* pRangesObj = ScCellRangesBase::getImplementation( xDragSourceRanges );
+ if (pRangesObj)
+ {
+ const ScRangeList& rRanges = pRangesObj->GetRangeList();
+ aMarkData.MarkFromRangeList( rRanges, FALSE );
+ }
+ return aMarkData;
+}
+
+//
+// initialize aDocShellRef with a live document from the ClipDoc
+//
+
+void ScTransferObj::InitDocShell()
+{
+ if ( !aDocShellRef.Is() )
+ {
+ ScDocShell* pDocSh = new ScDocShell;
+ aDocShellRef = pDocSh; // ref must be there before InitNew
+
+ pDocSh->DoInitNew(NULL);
+
+ ScDocument* pDestDoc = pDocSh->GetDocument();
+ ScMarkData aDestMark;
+ aDestMark.SelectTable( 0, TRUE );
+
+ pDestDoc->SetDocOptions( pDoc->GetDocOptions() ); // #i42666#
+
+ String aTabName;
+ pDoc->GetName( aBlock.aStart.Tab(), aTabName );
+ pDestDoc->RenameTab( 0, aTabName, FALSE ); // no UpdateRef (empty)
+
+ pDestDoc->CopyStdStylesFrom( pDoc );
+
+ SCCOL nStartX = aBlock.aStart.Col();
+ SCROW nStartY = aBlock.aStart.Row();
+ SCCOL nEndX = aBlock.aEnd.Col();
+ SCROW nEndY = aBlock.aEnd.Row();
+
+ // widths / heights
+ // (must be copied before CopyFromClip, for drawing objects)
+
+ SCCOL nCol, nLastCol;
+ SCTAB nSrcTab = aBlock.aStart.Tab();
+ pDestDoc->SetLayoutRTL(0, pDoc->IsLayoutRTL(nSrcTab));
+ for (nCol=nStartX; nCol<=nEndX; nCol++)
+ if ( pDoc->ColHidden(nCol, nSrcTab, nLastCol) )
+ pDestDoc->ShowCol( nCol, 0, FALSE );
+ else
+ pDestDoc->SetColWidth( nCol, 0, pDoc->GetColWidth( nCol, nSrcTab ) );
+
+ ScBitMaskCompressedArray< SCROW, BYTE> & rDestRowFlags =
+ pDestDoc->GetRowFlagsArrayModifiable(0);
+
+ for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow)
+ {
+ BYTE nSourceFlags = pDoc->GetRowFlags(nRow, nSrcTab);
+ SCROW nLastRow = -1;
+ if ( pDoc->RowHidden(nRow, nSrcTab, nLastRow) )
+ pDestDoc->ShowRow( nRow, 0, FALSE );
+ else
+ {
+ pDestDoc->SetRowHeight( nRow, 0, pDoc->GetOriginalHeight( nRow, nSrcTab ) );
+
+ // if height was set manually, that flag has to be copied, too
+ if ( nSourceFlags & CR_MANUALSIZE )
+ rDestRowFlags.OrValue( nRow, CR_MANUALSIZE);
+ }
+ }
+
+ if ( pDoc->GetDrawLayer() )
+ pDocSh->MakeDrawLayer();
+
+ // cell range is copied to the original position, but on the first sheet
+ // -> bCutMode must be set
+ // pDoc is always a Clipboard-document
+
+ ScRange aDestRange( nStartX,nStartY,0, nEndX,nEndY,0 );
+ BOOL bWasCut = pDoc->IsCutMode();
+ if (!bWasCut)
+ pDoc->SetClipArea( aDestRange, TRUE ); // Cut
+ pDestDoc->CopyFromClip( aDestRange, aDestMark, IDF_ALL, NULL, pDoc, FALSE );
+ pDoc->SetClipArea( aDestRange, bWasCut );
+
+ StripRefs( pDoc, nStartX,nStartY, nEndX,nEndY, pDestDoc, 0,0 );
+
+ ScRange aMergeRange = aDestRange;
+ pDestDoc->ExtendMerge( aMergeRange, TRUE );
+
+ pDoc->CopyDdeLinks( pDestDoc ); // copy values of DDE Links
+
+ // page format (grid etc) and page size (maximum size for ole object)
+
+ Size aPaperSize = SvxPaperInfo::GetPaperSize( PAPER_A4 ); // Twips
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ String aStyleName = pDoc->GetPageStyle( aBlock.aStart.Tab() );
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
+ if (pStyleSheet)
+ {
+ const SfxItemSet& rSourceSet = pStyleSheet->GetItemSet();
+ aPaperSize = ((const SvxSizeItem&) rSourceSet.Get(ATTR_PAGE_SIZE)).GetSize();
+
+ // CopyStyleFrom kopiert SetItems mit richtigem Pool
+ ScStyleSheetPool* pDestPool = pDestDoc->GetStyleSheetPool();
+ pDestPool->CopyStyleFrom( pStylePool, aStyleName, SFX_STYLE_FAMILY_PAGE );
+ }
+
+ ScViewData aViewData( pDocSh, NULL );
+ aViewData.SetScreen( nStartX,nStartY, nEndX,nEndY );
+ aViewData.SetCurX( nStartX );
+ aViewData.SetCurY( nStartY );
+
+ pDestDoc->SetViewOptions( pDoc->GetViewOptions() );
+
+ // Size
+ //! get while copying sizes
+
+ long nPosX = 0;
+ long nPosY = 0;
+
+ for (nCol=0; nCol<nStartX; nCol++)
+ nPosX += pDestDoc->GetColWidth( nCol, 0 );
+ nPosY += pDestDoc->GetRowHeight( 0, nStartY-1, 0 );
+ nPosX = (long) ( nPosX * HMM_PER_TWIPS );
+ nPosY = (long) ( nPosY * HMM_PER_TWIPS );
+
+
+ aPaperSize.Width() *= 2; // limit OLE object to double of page size
+ aPaperSize.Height() *= 2;
+
+ long nSizeX = 0;
+ long nSizeY = 0;
+ for (nCol=nStartX; nCol<=nEndX; nCol++)
+ {
+ long nAdd = pDestDoc->GetColWidth( nCol, 0 );
+ if ( nSizeX+nAdd > aPaperSize.Width() && nSizeX ) // above limit?
+ break;
+ nSizeX += nAdd;
+ }
+ for (SCROW nRow=nStartY; nRow<=nEndY; nRow++)
+ {
+ long nAdd = pDestDoc->GetRowHeight( nRow, 0 );
+ if ( nSizeY+nAdd > aPaperSize.Height() && nSizeY ) // above limit?
+ break;
+ nSizeY += nAdd;
+ }
+ nSizeX = (long) ( nSizeX * HMM_PER_TWIPS );
+ nSizeY = (long) ( nSizeY * HMM_PER_TWIPS );
+
+// pDocSh->SetVisAreaSize( Size(nSizeX,nSizeY) );
+
+ Rectangle aNewArea( Point(nPosX,nPosY), Size(nSizeX,nSizeY) );
+ //TODO/LATER: why twice?!
+ //pDocSh->SvInPlaceObject::SetVisArea( aNewArea );
+ pDocSh->SetVisArea( aNewArea );
+
+ pDocSh->UpdateOle(&aViewData, TRUE);
+
+ //! SetDocumentModified?
+ if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
+ pDestDoc->UpdateChartListenerCollection();
+ }
+}
+
+// static
+SfxObjectShell* ScTransferObj::SetDrawClipDoc( BOOL bAnyOle )
+{
+ // update ScGlobal::pDrawClipDocShellRef
+
+ delete ScGlobal::pDrawClipDocShellRef;
+ if (bAnyOle)
+ {
+ ScGlobal::pDrawClipDocShellRef =
+ new ScDocShellRef(new ScDocShell(SFX_CREATE_MODE_INTERNAL)); // there must be a ref
+ (*ScGlobal::pDrawClipDocShellRef)->DoInitNew(NULL);
+ return *ScGlobal::pDrawClipDocShellRef;
+ }
+ else
+ {
+ ScGlobal::pDrawClipDocShellRef = NULL;
+ return NULL;
+ }
+}
+
+// static
+void ScTransferObj::StripRefs( ScDocument* pDoc,
+ SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
+ ScDocument* pDestDoc, SCCOL nSubX, SCROW nSubY )
+{
+ if (!pDestDoc)
+ {
+ pDestDoc = pDoc;
+ DBG_ASSERT(nSubX==0&&nSubY==0, "can't move within the document");
+ }
+
+ // In a clipboard doc the data don't have to be on the first sheet
+
+ SCTAB nSrcTab = 0;
+ while (nSrcTab<MAXTAB && !pDoc->HasTable(nSrcTab))
+ ++nSrcTab;
+ SCTAB nDestTab = 0;
+ while (nDestTab<MAXTAB && !pDestDoc->HasTable(nDestTab))
+ ++nDestTab;
+
+ if (!pDoc->HasTable(nSrcTab) || !pDestDoc->HasTable(nDestTab))
+ {
+ DBG_ERROR("Sheet not found in ScTransferObj::StripRefs");
+ return;
+ }
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ ScRange aRef;
+
+ ScCellIterator aIter( pDoc, nStartX, nStartY, nSrcTab, nEndX, nEndY, nSrcTab );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
+ BOOL bOut = FALSE;
+ ScDetectiveRefIter aRefIter( pFCell );
+ while ( !bOut && aRefIter.GetNextRef( aRef ) )
+ {
+ if ( aRef.aStart.Tab() != nSrcTab || aRef.aEnd.Tab() != nSrcTab ||
+ aRef.aStart.Col() < nStartX || aRef.aEnd.Col() > nEndX ||
+ aRef.aStart.Row() < nStartY || aRef.aEnd.Row() > nEndY )
+ bOut = TRUE;
+ }
+ if (bOut)
+ {
+ SCCOL nCol = aIter.GetCol() - nSubX;
+ SCROW nRow = aIter.GetRow() - nSubY;
+
+ ScBaseCell* pNew = 0;
+ USHORT nErrCode = pFCell->GetErrCode();
+ if (nErrCode)
+ {
+ pNew = new ScStringCell( ScGlobal::GetErrorString(nErrCode) );
+ if ( ((const SvxHorJustifyItem*) pDestDoc->GetAttr(
+ nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY))->GetValue() ==
+ SVX_HOR_JUSTIFY_STANDARD )
+ pDestDoc->ApplyAttr( nCol,nRow,nDestTab,
+ SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY) );
+ }
+ else if (pFCell->IsValue())
+ {
+ double fVal = pFCell->GetValue();
+ pNew = new ScValueCell( fVal );
+ }
+ else
+ {
+ String aStr;
+ pFCell->GetString(aStr);
+ if ( pFCell->IsMultilineResult() )
+ pNew = new ScEditCell( aStr, pDestDoc );
+ else
+ pNew = new ScStringCell( aStr );
+ }
+ pDestDoc->PutCell( nCol,nRow,nDestTab, pNew );
+
+ // number formats
+
+ ULONG nOldFormat = ((const SfxUInt32Item*)
+ pDestDoc->GetAttr(nCol,nRow,nDestTab, ATTR_VALUE_FORMAT))->GetValue();
+ if ( (nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ {
+ ULONG nNewFormat = pFCell->GetStandardFormat( *pFormatter,
+ nOldFormat );
+ pDestDoc->ApplyAttr( nCol,nRow,nDestTab,
+ SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) );
+ }
+ }
+ }
+ pCell = aIter.GetNext();
+ }
+}
+
+const com::sun::star::uno::Sequence< sal_Int8 >& ScTransferObj::getUnoTunnelId()
+{
+ static com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ if( !aSeq.getLength() )
+ {
+ static osl::Mutex aCreateMutex;
+ osl::Guard< osl::Mutex > aGuard( aCreateMutex );
+ aSeq.realloc( 16 );
+ rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True );
+ }
+ return aSeq;
+}
+
+sal_Int64 SAL_CALL ScTransferObj::getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException )
+{
+ sal_Int64 nRet;
+ if( ( rId.getLength() == 16 ) &&
+ ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) )
+ {
+ nRet = reinterpret_cast< sal_Int64 >( this );
+ }
+ else
+ nRet = TransferableHelper::getSomething(rId);
+ return nRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/typemap.cxx b/sc/source/ui/app/typemap.cxx
new file mode 100644
index 000000000000..97a004e0b3ed
--- /dev/null
+++ b/sc/source/ui/app/typemap.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <svx/svxids.hrc>
+#include "sc.hrc"
+#include "scitems.hxx"
+#include <editeng/memberids.hrc>
+
+
+#define ITEMID_DBTYPE 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#include <sfx2/msg.hxx>
+#include <svl/stritem.hxx>
+#include <svl/slstitm.hxx>
+#include <sfx2/objitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/postattr.hxx>
+#include <editeng/postitem.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <svx/zoomitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/bolnitem.hxx>
+#include <svl/ptitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/algitem.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xtextit0.hxx>
+#include <svx/xftadit.hxx>
+#include <svx/xftdiit.hxx>
+#include <svx/xftstit.hxx>
+#include <svx/xftmrit.hxx>
+#include <svx/xftouit.hxx>
+#include <svx/xftshit.hxx>
+#include <svx/xftshcit.hxx>
+#include <svx/xftshxy.hxx>
+#include <svx/xftsfit.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/grafctrl.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/brkitem.hxx>
+#include <editeng/charreliefitem.hxx>
+#include <svx/rotmodit.hxx>
+#include <svx/drawitem.hxx>
+#include <svl/ilstitem.hxx>
+#include <svl/globalnameitem.hxx>
+#include <svx/chrtitem.hxx>
+#include <svx/zoomslideritem.hxx>
+
+// #i25616#
+#include <svx/sdshitm.hxx>
+
+#include <svl/aeitem.hxx>
+#include <avmedia/mediaitem.hxx>
+#include "attrib.hxx"
+
+#define SvxDrawToolItem SfxAllEnumItem
+#define SvxDrawAlignItem SfxAllEnumItem
+#define SvxChooseControlItem SfxEnumItem
+#define avmedia_MediaItem ::avmedia::MediaItem
+
+#define SFX_TYPEMAP
+#include "scslots.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/uiitems.cxx b/sc/source/ui/app/uiitems.cxx
new file mode 100644
index 000000000000..2d3472263ee6
--- /dev/null
+++ b/sc/source/ui/app/uiitems.cxx
@@ -0,0 +1,724 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <editeng/editobj.hxx>
+
+#include "userlist.hxx"
+#include "uiitems.hxx"
+#include "dpsave.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScInputStatusItem, SfxPoolItem);
+TYPEINIT1(ScSortItem, SfxPoolItem);
+TYPEINIT1(ScQueryItem, SfxPoolItem);
+TYPEINIT1(ScSubTotalItem, SfxPoolItem);
+TYPEINIT1(ScUserListItem, SfxPoolItem);
+TYPEINIT1(ScConsolidateItem, SfxPoolItem);
+TYPEINIT1(ScPivotItem, SfxPoolItem);
+TYPEINIT1(ScSolveItem, SfxPoolItem);
+TYPEINIT1(ScTabOpItem, SfxPoolItem);
+TYPEINIT1(ScCondFrmtItem, SfxPoolItem);
+
+TYPEINIT1(ScTablesHint, SfxHint);
+TYPEINIT1(ScEditViewHint, SfxHint);
+TYPEINIT1(ScIndexHint, SfxHint);
+
+// -----------------------------------------------------------------------
+// ScInputStatusItem - Status-Update fuer Eingabezeile
+// -----------------------------------------------------------------------
+
+ScInputStatusItem::ScInputStatusItem( USHORT nWhichP,
+ const ScAddress& rCurPos,
+ const ScAddress& rStartPos,
+ const ScAddress& rEndPos,
+ const String& rString,
+ const EditTextObject* pData )
+ : SfxPoolItem ( nWhichP ),
+ aCursorPos ( rCurPos ),
+ aStartPos ( rStartPos ),
+ aEndPos ( rEndPos ),
+ aString ( rString ),
+ pEditData ( pData ? pData->Clone() : NULL )
+{
+}
+
+ScInputStatusItem::ScInputStatusItem( const ScInputStatusItem& rItem )
+ : SfxPoolItem ( rItem ),
+ aCursorPos ( rItem.aCursorPos ),
+ aStartPos ( rItem.aStartPos ),
+ aEndPos ( rItem.aEndPos ),
+ aString ( rItem.aString ),
+ pEditData ( rItem.pEditData ? rItem.pEditData->Clone() : NULL )
+{
+}
+
+__EXPORT ScInputStatusItem::~ScInputStatusItem()
+{
+ delete pEditData;
+}
+
+String __EXPORT ScInputStatusItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("InputStatus"));
+}
+
+int __EXPORT ScInputStatusItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ return ( (aStartPos == ((ScInputStatusItem&)rItem).aStartPos)
+ && (aEndPos == ((ScInputStatusItem&)rItem).aEndPos)
+ && (aCursorPos == ((ScInputStatusItem&)rItem).aCursorPos)
+ && (aString == ((ScInputStatusItem&)rItem).aString) );
+ //! Edit-Daten vergleichen!
+}
+
+SfxPoolItem* __EXPORT ScInputStatusItem::Clone( SfxItemPool * ) const
+{
+ return new ScInputStatusItem( *this );
+}
+
+//
+// ScPaintHint ist nach schints.cxx verschoben
+//
+
+// -----------------------------------------------------------------------
+// ScTablesHint - Views anpassen, wenn Tabellen eingefuegt / geloescht
+// -----------------------------------------------------------------------
+
+ScTablesHint::ScTablesHint(USHORT nNewId, SCTAB nTable1, SCTAB nTable2) :
+ nId( nNewId ),
+ nTab1( nTable1 ),
+ nTab2( nTable2 )
+{
+}
+
+ScTablesHint::~ScTablesHint()
+{
+}
+
+
+// -----------------------------------------------------------------------
+// ScIndexHint
+// -----------------------------------------------------------------------
+
+ScIndexHint::ScIndexHint(USHORT nNewId, USHORT nIdx) :
+ nId( nNewId ),
+ nIndex( nIdx )
+{
+}
+
+ScIndexHint::~ScIndexHint()
+{
+}
+
+
+// -----------------------------------------------------------------------
+// ScEditViewHint - neue EditView fuer Cursorposition anlegen
+// -----------------------------------------------------------------------
+
+ScEditViewHint::ScEditViewHint( ScEditEngineDefaulter* pEngine, const ScAddress& rCurPos ) :
+ pEditEngine( pEngine ),
+ aCursorPos( rCurPos )
+{
+}
+
+ScEditViewHint::~ScEditViewHint()
+{
+}
+
+// -----------------------------------------------------------------------
+// ScSortItem - Daten fuer den Sortierdialog
+// -----------------------------------------------------------------------
+
+ScSortItem::ScSortItem( USHORT nWhichP,
+ ScViewData* ptrViewData,
+ const ScSortParam* pSortData ) :
+ SfxPoolItem ( nWhichP ),
+ pViewData ( ptrViewData )
+{
+ if ( pSortData ) theSortData = *pSortData;
+}
+
+//------------------------------------------------------------------------
+
+ScSortItem::ScSortItem( USHORT nWhichP,
+ const ScSortParam* pSortData ) :
+ SfxPoolItem ( nWhichP ),
+ pViewData ( NULL )
+{
+ if ( pSortData ) theSortData = *pSortData;
+}
+
+//------------------------------------------------------------------------
+
+ScSortItem::ScSortItem( const ScSortItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ pViewData ( rItem.pViewData ),
+ theSortData ( rItem.theSortData )
+{
+}
+
+__EXPORT ScSortItem::~ScSortItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScSortItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("SortItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScSortItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScSortItem& rOther = (const ScSortItem&)rItem;
+
+ return ( (pViewData == rOther.pViewData)
+ && (theSortData == rOther.theSortData) );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScSortItem::Clone( SfxItemPool * ) const
+{
+ return new ScSortItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+bool ScSortItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /* nMemberUd */ ) const
+{
+ // Return empty value as there is no useful conversion
+ rVal = com::sun::star::uno::Any();
+ return true;
+}
+
+// -----------------------------------------------------------------------
+// ScQueryItem - Daten fuer den Filterdialog
+// -----------------------------------------------------------------------
+
+ScQueryItem::ScQueryItem( USHORT nWhichP,
+ ScViewData* ptrViewData,
+ const ScQueryParam* pQueryData ) :
+ SfxPoolItem ( nWhichP ),
+ pViewData ( ptrViewData ),
+ bIsAdvanced ( FALSE )
+{
+ if ( pQueryData ) theQueryData = *pQueryData;
+}
+
+//------------------------------------------------------------------------
+
+ScQueryItem::ScQueryItem( USHORT nWhichP,
+ const ScQueryParam* pQueryData ) :
+ SfxPoolItem ( nWhichP ),
+ pViewData ( NULL ),
+ bIsAdvanced ( FALSE )
+{
+ if ( pQueryData ) theQueryData = *pQueryData;
+}
+
+//------------------------------------------------------------------------
+
+ScQueryItem::ScQueryItem( const ScQueryItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ pViewData ( rItem.pViewData ),
+ theQueryData( rItem.theQueryData ),
+ bIsAdvanced ( rItem.bIsAdvanced ),
+ aAdvSource ( rItem.aAdvSource )
+{
+}
+
+__EXPORT ScQueryItem::~ScQueryItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+void ScQueryItem::SetAdvancedQuerySource(const ScRange* pSource)
+{
+ if (pSource)
+ {
+ aAdvSource = *pSource;
+ bIsAdvanced = TRUE;
+ }
+ else
+ bIsAdvanced = FALSE;
+}
+
+BOOL ScQueryItem::GetAdvancedQuerySource(ScRange& rSource) const
+{
+ rSource = aAdvSource;
+ return bIsAdvanced;
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScQueryItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("QueryItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScQueryItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)rItem;
+
+ return ( (pViewData == rQueryItem.pViewData)
+ && (bIsAdvanced == rQueryItem.bIsAdvanced)
+ && (aAdvSource == rQueryItem.aAdvSource)
+ && (theQueryData == rQueryItem.theQueryData) );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScQueryItem::Clone( SfxItemPool * ) const
+{
+ return new ScQueryItem( *this );
+}
+
+// -----------------------------------------------------------------------
+// ScSubTotalItem - Daten fuer den Zwischenergebnisdialog
+// -----------------------------------------------------------------------
+
+ScSubTotalItem::ScSubTotalItem( USHORT nWhichP,
+ ScViewData* ptrViewData,
+ const ScSubTotalParam* pSubTotalData ) :
+ SfxPoolItem ( nWhichP ),
+ pViewData ( ptrViewData )
+{
+ if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
+}
+
+//------------------------------------------------------------------------
+
+ScSubTotalItem::ScSubTotalItem( USHORT nWhichP,
+ const ScSubTotalParam* pSubTotalData ) :
+ SfxPoolItem ( nWhichP ),
+ pViewData ( NULL )
+{
+ if ( pSubTotalData ) theSubTotalData = *pSubTotalData;
+}
+
+//------------------------------------------------------------------------
+
+ScSubTotalItem::ScSubTotalItem( const ScSubTotalItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ pViewData ( rItem.pViewData ),
+ theSubTotalData ( rItem.theSubTotalData )
+{
+}
+
+__EXPORT ScSubTotalItem::~ScSubTotalItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScSubTotalItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("SubTotalItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScSubTotalItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScSubTotalItem& rSTItem = (const ScSubTotalItem&)rItem;
+
+ return ( (pViewData == rSTItem.pViewData)
+ && (theSubTotalData == rSTItem.theSubTotalData) );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScSubTotalItem::Clone( SfxItemPool * ) const
+{
+ return new ScSubTotalItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+bool ScSubTotalItem::QueryValue( com::sun::star::uno::Any& rVal, BYTE /* nMemberUd */ ) const
+{
+ // Return empty value as there is no useful conversion
+ rVal = com::sun::star::uno::Any();
+ return true;
+}
+
+// -----------------------------------------------------------------------
+// ScUserListItem - Transporter fuer den Benutzerlisten-TabPage
+// -----------------------------------------------------------------------
+
+ScUserListItem::ScUserListItem( USHORT nWhichP )
+ : SfxPoolItem ( nWhichP ),
+ pUserList ( NULL )
+{
+}
+
+//------------------------------------------------------------------------
+
+ScUserListItem::ScUserListItem( const ScUserListItem& rItem )
+ : SfxPoolItem ( rItem )
+{
+ if ( rItem.pUserList )
+ pUserList = new ScUserList( *(rItem.pUserList) );
+ else
+ pUserList = NULL;
+}
+
+__EXPORT ScUserListItem::~ScUserListItem()
+{
+ delete pUserList;
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScUserListItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScUserListItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScUserListItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScUserListItem& r = (const ScUserListItem&)rItem;
+ BOOL bEqual = FALSE;
+
+ if ( !pUserList || !(r.pUserList) )
+ bEqual = ( !pUserList && !(r.pUserList) );
+ else
+ bEqual = ( *pUserList == *(r.pUserList) );
+
+ return bEqual;
+}
+
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScUserListItem::Clone( SfxItemPool * ) const
+{
+ return new ScUserListItem( *this );
+}
+
+//------------------------------------------------------------------------
+
+void ScUserListItem::SetUserList( const ScUserList& rUserList )
+{
+ delete pUserList;
+ pUserList = new ScUserList( rUserList );
+}
+
+// -----------------------------------------------------------------------
+// ScConsolidateItem - Daten fuer den Konsolidieren-Dialog
+// -----------------------------------------------------------------------
+
+ScConsolidateItem::ScConsolidateItem(
+ USHORT nWhichP,
+ const ScConsolidateParam* pConsolidateData ) :
+ SfxPoolItem ( nWhichP )
+{
+ if ( pConsolidateData ) theConsData = *pConsolidateData;
+}
+
+//------------------------------------------------------------------------
+
+ScConsolidateItem::ScConsolidateItem( const ScConsolidateItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ theConsData ( rItem.theConsData )
+{
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScConsolidateItem::~ScConsolidateItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScConsolidateItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScConsolidateItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScConsolidateItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScConsolidateItem& rCItem = (const ScConsolidateItem&)rItem;
+
+ return ( theConsData == rCItem.theConsData);
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScConsolidateItem::Clone( SfxItemPool * ) const
+{
+ return new ScConsolidateItem( *this );
+}
+
+
+// -----------------------------------------------------------------------
+// ScPivotItem - Daten fuer den Pivot-Dialog
+// -----------------------------------------------------------------------
+
+ScPivotItem::ScPivotItem( USHORT nWhichP, const ScDPSaveData* pData,
+ const ScRange* pRange, BOOL bNew ) :
+ SfxPoolItem ( nWhichP )
+{
+ // pSaveData must always exist
+ if ( pData )
+ pSaveData = new ScDPSaveData(*pData);
+ else
+ pSaveData = new ScDPSaveData;
+ if ( pRange ) aDestRange = *pRange;
+ bNewSheet = bNew;
+}
+
+//------------------------------------------------------------------------
+
+ScPivotItem::ScPivotItem( const ScPivotItem& rItem ) :
+ SfxPoolItem ( rItem ),
+ aDestRange ( rItem.aDestRange ),
+ bNewSheet ( rItem.bNewSheet )
+{
+ DBG_ASSERT(rItem.pSaveData, "pSaveData");
+ pSaveData = new ScDPSaveData(*rItem.pSaveData);
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScPivotItem::~ScPivotItem()
+{
+ delete pSaveData;
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScPivotItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScPivotItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScPivotItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScPivotItem& rPItem = (const ScPivotItem&)rItem;
+ DBG_ASSERT( pSaveData && rPItem.pSaveData, "pSaveData" );
+ return ( *pSaveData == *rPItem.pSaveData &&
+ aDestRange == rPItem.aDestRange &&
+ bNewSheet == rPItem.bNewSheet );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScPivotItem::Clone( SfxItemPool * ) const
+{
+ return new ScPivotItem( *this );
+}
+
+
+// -----------------------------------------------------------------------
+// ScSolveItem - Daten fuer den Solver-Dialog
+// -----------------------------------------------------------------------
+
+ScSolveItem::ScSolveItem( USHORT nWhichP,
+ const ScSolveParam* pSolveData )
+ : SfxPoolItem ( nWhichP )
+{
+ if ( pSolveData ) theSolveData = *pSolveData;
+}
+
+//------------------------------------------------------------------------
+
+ScSolveItem::ScSolveItem( const ScSolveItem& rItem )
+ : SfxPoolItem ( rItem ),
+ theSolveData ( rItem.theSolveData )
+{
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScSolveItem::~ScSolveItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScSolveItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScSolveItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScSolveItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScSolveItem& rPItem = (const ScSolveItem&)rItem;
+
+ return ( theSolveData == rPItem.theSolveData );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScSolveItem::Clone( SfxItemPool * ) const
+{
+ return new ScSolveItem( *this );
+}
+
+// -----------------------------------------------------------------------
+// ScTabOpItem - Daten fuer den TabOp-Dialog
+// -----------------------------------------------------------------------
+
+ScTabOpItem::ScTabOpItem( USHORT nWhichP,
+ const ScTabOpParam* pTabOpData )
+ : SfxPoolItem ( nWhichP )
+{
+ if ( pTabOpData ) theTabOpData = *pTabOpData;
+}
+
+//------------------------------------------------------------------------
+
+ScTabOpItem::ScTabOpItem( const ScTabOpItem& rItem )
+ : SfxPoolItem ( rItem ),
+ theTabOpData ( rItem.theTabOpData )
+{
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScTabOpItem::~ScTabOpItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScTabOpItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScTabOpItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScTabOpItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScTabOpItem& rPItem = (const ScTabOpItem&)rItem;
+
+ return ( theTabOpData == rPItem.theTabOpData );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScTabOpItem::Clone( SfxItemPool * ) const
+{
+ return new ScTabOpItem( *this );
+}
+
+
+// -----------------------------------------------------------------------
+// ScCondFrmtItem - Daten fuer den Dialog bedingte Formatierung
+// -----------------------------------------------------------------------
+
+ScCondFrmtItem::ScCondFrmtItem( USHORT nWhichP,
+//! const ScConditionalFormat* pCondFrmt )
+ const ScConditionalFormat& rCondFrmt )
+ : SfxPoolItem ( nWhichP ),
+ theCondFrmtData ( rCondFrmt ) //!
+{
+//! if ( pCondFrmt ) theCondFrmtData = *pCondFrmt;
+}
+
+//------------------------------------------------------------------------
+
+ScCondFrmtItem::ScCondFrmtItem( const ScCondFrmtItem& rItem )
+ : SfxPoolItem ( rItem ),
+ theCondFrmtData ( rItem.theCondFrmtData )
+{
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScCondFrmtItem::~ScCondFrmtItem()
+{
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScCondFrmtItem::GetValueText() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScCondFrmtItem"));
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScCondFrmtItem::operator==( const SfxPoolItem& rItem ) const
+{
+ DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+ const ScCondFrmtItem& rPItem = (const ScCondFrmtItem&)rItem;
+
+ return ( theCondFrmtData == rPItem.theCondFrmtData );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT ScCondFrmtItem::Clone( SfxItemPool * ) const
+{
+ return new ScCondFrmtItem( *this );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/wtcdummy.cxx b/sc/source/ui/app/wtcdummy.cxx
new file mode 100644
index 000000000000..c1f5eed9b82d
--- /dev/null
+++ b/sc/source/ui/app/wtcdummy.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <tlgen.hxx>
+
+class SdbColumns
+{
+ public:
+ SdbColumns();
+ ~SdbColumns();
+};
+
+SdbColumns::SdbColumns()
+{
+ DBG_ERROR("WATCOM Hack failed !");
+}
+
+SdbColumns::~SdbColumns()
+{
+ DBG_ERROR("WATCOM Hack failed !");
+}
+
+class SdbRow
+{
+ public:
+ SdbRow();
+ ~SdbRow();
+};
+
+SdbRow::SdbRow()
+{
+ DBG_ERROR("WATCOM Hack failed !");
+}
+
+SdbRow::~SdbRow()
+{
+ DBG_ERROR("WATCOM Hack failed !");
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/attrdlg.cxx b/sc/source/ui/attrdlg/attrdlg.cxx
new file mode 100644
index 000000000000..b7716e75fd4d
--- /dev/null
+++ b/sc/source/ui/attrdlg/attrdlg.cxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scitems.hxx"
+
+#include <sfx2/objsh.hxx>
+#include <sfx2/tabdlg.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include "tabpages.hxx"
+#include "attrdlg.hxx"
+#include "scresid.hxx"
+#include "attrdlg.hrc"
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/flagsdef.hxx>
+#include <editeng/flstitem.hxx>
+#include <sfx2/app.hxx>
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <layout/layout-pre.hxx>
+#endif
+
+//==================================================================
+
+ScAttrDlg::ScAttrDlg( SfxViewFrame* pFrameP,
+ Window* pParent,
+ const SfxItemSet* pCellAttrs )
+
+ : SfxTabDialog( pFrameP,
+ pParent,
+ ScResId( RID_SCDLG_ATTR ),
+ pCellAttrs )
+{
+ SvtCJKOptions aCJKOptions;
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageCreatorFunc fail!");
+#if LAYOUT_SFX_TABDIALOG_BROKEN
+ AddTabPage( TP_NUMBER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), 0 );
+#else
+ String number(RTL_CONSTASCII_USTRINGPARAM("Numbers"));
+ AddTabPage( TP_NUMBER, number, pFact->GetTabPageCreatorFunc (RID_SVXPAGE_NUMBERFORMAT), 0, FALSE, TAB_APPEND);
+#endif
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
+ AddTabPage( TP_FONT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), 0 );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
+ AddTabPage( TP_FONTEFF, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), 0 );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageCreatorFunc fail!");
+ AddTabPage( TP_ALIGNMENT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), 0 );
+
+ if ( aCJKOptions.IsAsianTypographyEnabled() )
+ {
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
+ AddTabPage( TP_ASIAN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), 0 );
+ }
+ else
+ RemoveTabPage( TP_ASIAN );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
+ AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
+ AddTabPage( TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
+ AddTabPage( TP_PROTECTION, ScTabPageProtection::Create, 0 );
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScAttrDlg::~ScAttrDlg()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScAttrDlg::PageCreated( USHORT nPageId, SfxTabPage& rTabPage )
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch ( nPageId )
+ {
+ case TP_NUMBER:
+ {
+ aSet.Put (SfxLinkItem( SID_LINK_TYPE, LINK( this, ScAttrDlg, OkHandler )));
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ case TP_FONT:
+ {
+ const SfxPoolItem* pInfoItem = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
+
+ DBG_ASSERT( pInfoItem, "FontListItem not found :-(" );
+
+ aSet.Put (SvxFontListItem(((const SvxFontListItem*)pInfoItem)->GetFontList(), SID_ATTR_CHAR_FONTLIST ));
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScAttrDlg, OkHandler, void*, EMPTYARG )
+{
+ ((Link&)GetOKButton().GetClickHdl()).Call( NULL );
+
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/condfrmt.cxx b/sc/source/ui/attrdlg/condfrmt.cxx
new file mode 100644
index 000000000000..c9da6a740266
--- /dev/null
+++ b/sc/source/ui/attrdlg/condfrmt.cxx
@@ -0,0 +1,831 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+
+#include "tabvwsh.hxx"
+#include "reffact.hxx"
+#include "conditio.hxx"
+#include "stlpool.hxx"
+#include "uiitems.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+
+#include "condfrmt.hrc"
+#include "globstr.hrc"
+
+#define _CONDFRMT_CXX
+#include "condfrmt.hxx"
+#undef _CONDFRMT_CXX
+
+
+//============================================================================
+// class ScConditionalFormat
+
+//----------------------------------------------------------------------------
+// Konstruktor
+
+ScConditionalFormatDlg::ScConditionalFormatDlg(
+ SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pCurDoc,
+ const ScConditionalFormat* pCurrentFormat )
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_CONDFORMAT ),
+
+ aCbxCond1 ( this, ScResId( CBX_COND1 ) ),
+ aLbCond11 ( this, ScResId( LB_COND1_1 ) ),
+ aLbCond12 ( this, ScResId( LB_COND1_2 ) ),
+ aEdtCond11 ( this, this, ScResId( EDT_COND1_1 ) ),
+ aRbCond11 ( this, ScResId( RB_COND1_1 ), &aEdtCond11,this ),
+ aFtCond1And ( this, ScResId( FT_COND1_AND ) ),
+ aEdtCond12 ( this, this, ScResId( EDT_COND1_2 ) ),
+ aRbCond12 ( this, ScResId( RB_COND1_2 ), &aEdtCond12,this ),
+ aFtCond1Template ( this, ScResId( FT_COND1_TEMPLATE ) ),
+ aLbCond1Template ( this, ScResId( LB_COND1_TEMPLATE ) ),
+ aBtnNew1 ( this, ScResId( BTN_COND1_NEW ) ),
+ aFlSep1 ( this, ScResId( FL_SEP1 ) ),
+
+ aCbxCond2 ( this, ScResId( CBX_COND2 ) ),
+ aLbCond21 ( this, ScResId( LB_COND2_1 ) ),
+ aLbCond22 ( this, ScResId( LB_COND2_2 ) ),
+ aEdtCond21 ( this, this, ScResId( EDT_COND2_1 ) ),
+ aRbCond21 ( this, ScResId( RB_COND2_1 ), &aEdtCond21,this ),
+ aFtCond2And ( this, ScResId( FT_COND2_AND ) ),
+ aEdtCond22 ( this, this, ScResId( EDT_COND2_2 ) ),
+ aRbCond22 ( this, ScResId( RB_COND2_2 ), &aEdtCond22,this ),
+ aFtCond2Template ( this, ScResId( FT_COND2_TEMPLATE ) ),
+ aLbCond2Template ( this, ScResId( LB_COND2_TEMPLATE ) ),
+ aBtnNew2 ( this, ScResId( BTN_COND2_NEW ) ),
+ aFlSep2 ( this, ScResId( FL_SEP2 ) ),
+
+ aCbxCond3 ( this, ScResId( CBX_COND3 ) ),
+ aLbCond31 ( this, ScResId( LB_COND3_1 ) ),
+ aLbCond32 ( this, ScResId( LB_COND3_2 ) ),
+ aEdtCond31 ( this, this, ScResId( EDT_COND3_1 ) ),
+ aRbCond31 ( this, ScResId( RB_COND3_1 ), &aEdtCond31,this ),
+ aFtCond3And ( this, ScResId( FT_COND3_AND ) ),
+ aEdtCond32 ( this, this, ScResId( EDT_COND3_2 ) ),
+ aRbCond32 ( this, ScResId( RB_COND3_2 ), &aEdtCond32,this ),
+ aFtCond3Template ( this, ScResId( FT_COND3_TEMPLATE ) ),
+ aLbCond3Template ( this, ScResId( LB_COND3_TEMPLATE ) ),
+ aBtnNew3 ( this, ScResId( BTN_COND3_NEW ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+
+ pDoc ( pCurDoc )
+{
+ Point aPos;
+ String aName;
+ SfxStyleSheetBase* pStyle;
+
+ FreeResource();
+
+ // Handler setzen
+ aCbxCond1.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond1Hdl ) );
+ aLbCond11.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond11Hdl ) );
+ aLbCond12.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond12Hdl ) );
+
+ aCbxCond2.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond2Hdl ) );
+ aLbCond21.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond21Hdl ) );
+ aLbCond22.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond22Hdl ) );
+
+ aCbxCond3.SetClickHdl ( LINK( this, ScConditionalFormatDlg, ClickCond3Hdl ) );
+ aLbCond31.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond31Hdl ) );
+ aLbCond32.SetSelectHdl( LINK( this, ScConditionalFormatDlg, ChangeCond32Hdl ) );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
+//? aBtnCancel.SetClickHdl( LINK( this, ScConditionalFormatDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScConditionalFormatDlg, NewBtnHdl );
+ aBtnNew1.SetClickHdl( aLink );
+ aBtnNew2.SetClickHdl( aLink );
+ aBtnNew3.SetClickHdl( aLink );
+
+ aLink = LINK( this, ScConditionalFormatDlg, GetFocusHdl );
+ aEdtCond11.SetGetFocusHdl( aLink );
+ aEdtCond12.SetGetFocusHdl( aLink );
+ aEdtCond21.SetGetFocusHdl( aLink );
+ aEdtCond22.SetGetFocusHdl( aLink );
+ aEdtCond31.SetGetFocusHdl( aLink );
+ aEdtCond32.SetGetFocusHdl( aLink );
+ aRbCond11.SetGetFocusHdl( aLink );
+ aRbCond12.SetGetFocusHdl( aLink );
+ aRbCond21.SetGetFocusHdl( aLink );
+ aRbCond22.SetGetFocusHdl( aLink );
+ aRbCond31.SetGetFocusHdl( aLink );
+ aRbCond32.SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScConditionalFormatDlg, LoseFocusHdl );
+ aEdtCond11.SetLoseFocusHdl( aLink );
+ aEdtCond12.SetLoseFocusHdl( aLink );
+ aEdtCond21.SetLoseFocusHdl( aLink );
+ aEdtCond22.SetLoseFocusHdl( aLink );
+ aEdtCond31.SetLoseFocusHdl( aLink );
+ aEdtCond32.SetLoseFocusHdl( aLink );
+ aRbCond11.SetLoseFocusHdl( aLink );
+ aRbCond12.SetLoseFocusHdl( aLink );
+ aRbCond21.SetLoseFocusHdl( aLink );
+ aRbCond22.SetLoseFocusHdl( aLink );
+ aRbCond31.SetLoseFocusHdl( aLink );
+ aRbCond32.SetLoseFocusHdl( aLink );
+
+ // Condition 1
+ aCond1Pos1 = aLbCond12.GetPosPixel(); // Position Edit ohne Listbox
+ aCond1Pos2 = aEdtCond11.GetPosPixel(); // Position Edit mit Listbox
+ aRBtn1Pos1 = aRbCond11.GetPosPixel();
+ aRBtn1Pos2 = aRbCond12.GetPosPixel();
+ aPos = aEdtCond12.GetPosPixel();
+ aPos.X() += aEdtCond12.GetSizePixel().Width(); // rechter Rand
+ aCond1Size3 = aEdtCond11.GetSizePixel();
+ aCond1Size2 = Size( aPos.X() - aCond1Pos2.X(), aCond1Size3.Height() );
+ aCond1Size1 = Size( aPos.X() - aCond1Pos1.X(), aCond1Size3.Height() );
+
+ aCbxCond1.Check();
+ aLbCond11.SelectEntryPos( 0 );
+ aLbCond12.SelectEntryPos( 0 );
+
+ // Condition 2
+ aCond2Pos1 = aLbCond22.GetPosPixel(); // Position Edit ohne Listbox
+ aCond2Pos2 = aEdtCond21.GetPosPixel(); // Position Edit mit Listbox
+ aRBtn2Pos1 = aRbCond21.GetPosPixel();
+ aRBtn2Pos2 = aRbCond22.GetPosPixel();
+ aPos = aEdtCond22.GetPosPixel();
+ aPos.X() += aEdtCond22.GetSizePixel().Width(); // rechter Rand
+ aCond2Size3 = aEdtCond21.GetSizePixel();
+ aCond2Size2 = Size( aPos.X() - aCond2Pos2.X(), aCond2Size3.Height() );
+ aCond2Size1 = Size( aPos.X() - aCond2Pos1.X(), aCond2Size3.Height() );
+
+ aCbxCond2.Check( FALSE );
+ aLbCond21.SelectEntryPos( 0 );
+ aLbCond22.SelectEntryPos( 0 );
+
+ // Condition 3
+ aCond3Pos1 = aLbCond32.GetPosPixel(); // Position Edit ohne Listbox
+ aCond3Pos2 = aEdtCond31.GetPosPixel(); // Position Edit mit Listbox
+ aRBtn3Pos1 = aRbCond31.GetPosPixel();
+ aRBtn3Pos2 = aRbCond32.GetPosPixel();
+ aPos = aEdtCond32.GetPosPixel();
+ aPos.X() += aEdtCond32.GetSizePixel().Width(); // rechter Rand
+ aCond3Size3 = aEdtCond31.GetSizePixel();
+ aCond3Size2 = Size( aPos.X() - aCond3Pos2.X(), aCond3Size3.Height() );
+ aCond3Size1 = Size( aPos.X() - aCond3Pos1.X(), aCond3Size3.Height() );
+
+ aCbxCond3.Check( FALSE );
+ aLbCond31.SelectEntryPos( 0 );
+ aLbCond32.SelectEntryPos( 0 );
+
+ // Vorlagen aus pDoc holen
+ SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
+ for ( pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
+ {
+ aName = pStyle->GetName();
+ aLbCond1Template.InsertEntry( aName );
+ aLbCond2Template.InsertEntry( aName );
+ aLbCond3Template.InsertEntry( aName );
+ }
+
+ // Vorlagen eintragen
+//! pStyle = pDoc->GetSelectionStyle( /* ??? const ScMarkData& rMark ??? */ );
+ pStyle = NULL; //!
+ if (pStyle)
+ aName = pStyle->GetName();
+ else
+ aName = ScGlobal::GetRscString(STR_STYLENAME_STANDARD);
+ aLbCond1Template.SelectEntry( aName );
+ aLbCond2Template.SelectEntry( aName );
+ aLbCond3Template.SelectEntry( aName );
+
+ ScAddress aCurPos;
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ ScViewData* pData = pViewShell->GetViewData();
+ aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+ }
+
+ // Inhalt aus ConditionalFormat holen
+ if ( pCurrentFormat )
+ {
+ const ScCondFormatEntry* pEntry;
+ if ( pCurrentFormat->Count() > 0 )
+ {
+ pEntry= pCurrentFormat->GetEntry( 0 );
+ aEdtCond11.SetText( pEntry->GetExpression( aCurPos, 0 ) );
+ aLbCond1Template.SelectEntry( pEntry->GetStyle() );
+
+ ScConditionMode eMode = pEntry->GetOperation();
+ if ( eMode == SC_COND_DIRECT ) // via Formel
+ {
+ aLbCond11.SelectEntryPos( 1 );
+ ChangeCond11Hdl( NULL );
+ }
+ else if ( eMode == SC_COND_NONE ) // ???
+ ;
+ else // via Werte
+ {
+ aLbCond12.SelectEntryPos( sal::static_int_cast<USHORT>( eMode ) );
+ if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
+ aEdtCond12.SetText( pEntry->GetExpression( aCurPos, 1 ) );
+ }
+ }
+
+
+ if ( pCurrentFormat->Count() > 1 )
+ {
+ aCbxCond2.Check( TRUE );
+ pEntry= pCurrentFormat->GetEntry( 1 );
+ aEdtCond21.SetText( pEntry->GetExpression( aCurPos, 0 ) );
+ aLbCond2Template.SelectEntry( pEntry->GetStyle() );
+
+ ScConditionMode eMode = pEntry->GetOperation();
+ if ( eMode == SC_COND_DIRECT ) // via Formel
+ {
+ aLbCond21.SelectEntryPos( 1 );
+ ChangeCond21Hdl( NULL );
+ }
+ else if ( eMode == SC_COND_NONE ) // ???
+ ;
+ else // via Werte
+ {
+ aLbCond22.SelectEntryPos( sal::static_int_cast<USHORT>( eMode ) );
+ if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
+ aEdtCond22.SetText( pEntry->GetExpression( aCurPos, 1 ) );
+ }
+ }
+
+ if ( pCurrentFormat->Count() > 2 )
+ {
+ aCbxCond3.Check( TRUE );
+ pEntry= pCurrentFormat->GetEntry( 2 );
+ aEdtCond31.SetText( pEntry->GetExpression( aCurPos, 0 ) );
+ aLbCond3Template.SelectEntry( pEntry->GetStyle() );
+
+ ScConditionMode eMode = pEntry->GetOperation();
+ if ( eMode == SC_COND_DIRECT ) // via Formel
+ {
+ aLbCond31.SelectEntryPos( 1 );
+ ChangeCond31Hdl( NULL );
+ }
+ else if ( eMode == SC_COND_NONE ) // ???
+ ;
+ else // via Werte
+ {
+ aLbCond32.SelectEntryPos( sal::static_int_cast<USHORT>( eMode ) );
+ if ( ( eMode == SC_COND_BETWEEN ) || ( eMode == SC_COND_NOTBETWEEN ) )
+ aEdtCond32.SetText( pEntry->GetExpression( aCurPos, 1 ) );
+ }
+ }
+ }
+
+ ClickCond1Hdl( NULL );
+ ClickCond2Hdl( NULL );
+ ClickCond3Hdl( NULL );
+
+ ChangeCond12Hdl( NULL );
+ ChangeCond22Hdl( NULL );
+ ChangeCond32Hdl( NULL );
+
+ aEdtCond11.GrabFocus();
+ pEdActive = &aEdtCond11;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus
+// SFX_APPWINDOW->Disable();
+}
+
+
+//----------------------------------------------------------------------------
+// Destruktor
+
+__EXPORT ScConditionalFormatDlg::~ScConditionalFormatDlg()
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScConditionalFormatDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ rRef.Format( aStr, SCR_ABS_3D, pDocP, pDocP->GetAddressConvention () );
+ String aVal( pEdActive->GetText() );
+ Selection aSel( pEdActive->GetSelection() );
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ pEdActive->SetRefString( aVal );
+ pEdActive->SetSelection( aNewSel );
+// pEdActive->SetModifyFlag();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScConditionalFormatDlg::AddRefEntry()
+{
+ if ( pEdActive )
+ {
+ String aVal = pEdActive->GetText();
+ aVal += ';';
+ pEdActive->SetText(aVal);
+
+ xub_StrLen nLen = aVal.Len();
+ pEdActive->SetSelection( Selection( nLen, nLen ) );
+// pEdActive->SetModifyFlag();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScConditionalFormatDlg::IsRefInputMode() const
+{
+ return (pEdActive != NULL);
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScConditionalFormatDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+// Holt die ausgewaehlte bedingte Formatierung ab
+
+void ScConditionalFormatDlg::GetConditionalFormat( ScConditionalFormat& rCndFmt )
+{
+ ScConditionMode eOper;
+ String sExpr1;
+ String sExpr2;
+ String sStyle;
+ ScAddress aCurPos;
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ ScViewData* pData = pViewShell->GetViewData();
+ aCurPos = ScAddress( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+ }
+
+ if ( aCbxCond1.IsChecked() )
+ {
+ if ( aLbCond11.GetSelectEntryPos() == 1 ) // via Formel
+ eOper = SC_COND_DIRECT;
+ else
+ eOper = (ScConditionMode)aLbCond12.GetSelectEntryPos();
+ sExpr1 = aEdtCond11.GetText();
+ sExpr2 = aEdtCond12.GetText();
+ sStyle = aLbCond1Template.GetSelectEntry();
+ ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
+ rCndFmt.AddEntry( aNewEntry );
+ }
+
+ if ( aCbxCond2.IsChecked() )
+ {
+ if ( aLbCond21.GetSelectEntryPos() == 1 ) // via Formel???
+ eOper = SC_COND_DIRECT;
+ else
+ eOper = (ScConditionMode)aLbCond22.GetSelectEntryPos();
+ sExpr1 = aEdtCond21.GetText();
+ sExpr2 = aEdtCond22.GetText();
+ sStyle = aLbCond2Template.GetSelectEntry();
+ ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
+ rCndFmt.AddEntry( aNewEntry );
+ }
+
+ if ( aCbxCond3.IsChecked() )
+ {
+ if ( aLbCond31.GetSelectEntryPos() == 1 ) // via Formel???
+ eOper = SC_COND_DIRECT;
+ else
+ eOper = (ScConditionMode)aLbCond32.GetSelectEntryPos();
+ sExpr1 = aEdtCond31.GetText();
+ sExpr2 = aEdtCond32.GetText();
+ sStyle = aLbCond3Template.GetSelectEntry();
+ ScCondFormatEntry aNewEntry( eOper, sExpr1, sExpr2, pDoc, aCurPos, sStyle );
+ rCndFmt.AddEntry( aNewEntry );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Zerstoert den Dialog
+
+BOOL ScConditionalFormatDlg::Close()
+{
+ return DoClose( ScCondFormatDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+
+//----------------------------------------------------------------------------
+// Enabled/Disabled Condition1-Controls
+
+IMPL_LINK( ScConditionalFormatDlg, ClickCond1Hdl, void *, EMPTYARG )
+{
+ BOOL bChecked = aCbxCond1.IsChecked();
+
+ aLbCond11.Enable( bChecked );
+ aLbCond12.Enable( bChecked );
+ aEdtCond11.Enable( bChecked );
+ aRbCond11.Enable( bChecked );
+ aFtCond1And.Enable( bChecked );
+ aEdtCond12.Enable( bChecked );
+ aRbCond12.Enable( bChecked );
+ aFtCond1Template.Enable( bChecked );
+ aLbCond1Template.Enable( bChecked );
+ aBtnNew1.Enable( bChecked );
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// Zellwert/Formel
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond11Hdl, void *, EMPTYARG )
+{
+ USHORT nPos = aLbCond11.GetSelectEntryPos();
+
+ if( nPos == 0 ) // Zellwert
+ {
+ aLbCond12.Show();
+ aEdtCond11.SetPosPixel( aCond1Pos2 );
+ }
+ else // Formel
+ {
+ aLbCond12.Hide();
+ aFtCond1And.Hide();
+ aEdtCond12.Hide();
+ aRbCond12.Hide();
+ aRbCond11.SetPosPixel( aRBtn1Pos2 );
+ aEdtCond11.SetPosSizePixel( aCond1Pos1, aCond1Size1 );
+ }
+
+ ChangeCond12Hdl( NULL );
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// zwischen, gleich, groesser, ...
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond12Hdl, void *, EMPTYARG )
+{
+ if( aLbCond12.IsVisible() )
+ {
+ USHORT nPos = aLbCond12.GetSelectEntryPos();
+
+ if( nPos == 6 || nPos == 7 ) // zwischen, n. zwischen
+ {
+ aEdtCond11.SetSizePixel( aCond1Size3 );
+ aRbCond11.SetPosPixel( aRBtn1Pos1 );
+ aFtCond1And.Show();
+ aEdtCond12.Show();
+ aRbCond12.Show();
+ }
+ else // gleich, n. gleich ...
+ {
+ aEdtCond12.Hide();
+ aRbCond12.Hide();
+ aFtCond1And.Hide();
+ aRbCond11.SetPosPixel( aRBtn1Pos2 );
+ aEdtCond11.SetSizePixel( aCond1Size2 );
+ }
+ }
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// Enabled/Disabled Condition2-Controls
+
+IMPL_LINK( ScConditionalFormatDlg, ClickCond2Hdl, void *, EMPTYARG )
+{
+ BOOL bChecked = aCbxCond2.IsChecked();
+
+ aLbCond21.Enable( bChecked );
+ aLbCond22.Enable( bChecked );
+ aEdtCond21.Enable( bChecked );
+ aRbCond21.Enable( bChecked );
+ aFtCond2And.Enable( bChecked );
+ aEdtCond22.Enable( bChecked );
+ aRbCond22.Enable( bChecked );
+ aFtCond2Template.Enable( bChecked );
+ aLbCond2Template.Enable( bChecked );
+ aBtnNew2.Enable( bChecked );
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// Zellwert/Formel
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond21Hdl, void *, EMPTYARG )
+{
+ USHORT nPos = aLbCond21.GetSelectEntryPos();
+
+ if( nPos == 0 ) // Zellwert
+ {
+ aLbCond22.Show();
+ aEdtCond21.SetPosPixel( aCond2Pos2 );
+ }
+ else // Formel
+ {
+ aLbCond22.Hide();
+ aFtCond2And.Hide();
+ aEdtCond22.Hide();
+ aRbCond22.Hide();
+ aRbCond21.SetPosPixel( aRBtn2Pos2 );
+ aEdtCond21.SetPosSizePixel( aCond2Pos1, aCond2Size1 );
+ }
+
+ ChangeCond22Hdl( NULL );
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// zwischen, gleich, groesser, ...
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond22Hdl, void *, EMPTYARG )
+{
+ if( aLbCond22.IsVisible() )
+ {
+ USHORT nPos = aLbCond22.GetSelectEntryPos();
+
+ if( nPos == 6 || nPos == 7 ) // zwischen, n. zwischen
+ {
+ aEdtCond21.SetSizePixel( aCond2Size3 );
+ aRbCond21.SetPosPixel( aRBtn2Pos1 );
+ aFtCond2And.Show();
+ aEdtCond22.Show();
+ aRbCond22.Show();
+ }
+ else // gleich, n. gleich ...
+ {
+ aEdtCond22.Hide();
+ aRbCond22.Hide();
+ aFtCond2And.Hide();
+ aRbCond21.SetPosPixel( aRBtn2Pos2 );
+ aEdtCond21.SetSizePixel( aCond2Size2 );
+ }
+ }
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// Enabled/Disabled Condition3-Controls
+
+IMPL_LINK( ScConditionalFormatDlg, ClickCond3Hdl, void *, EMPTYARG )
+{
+ BOOL bChecked = aCbxCond3.IsChecked();
+
+ aLbCond31.Enable( bChecked );
+ aLbCond32.Enable( bChecked );
+ aEdtCond31.Enable( bChecked );
+ aRbCond31.Enable( bChecked );
+ aFtCond3And.Enable( bChecked );
+ aEdtCond32.Enable( bChecked );
+ aRbCond32.Enable( bChecked );
+ aFtCond3Template.Enable( bChecked );
+ aLbCond3Template.Enable( bChecked );
+ aBtnNew3.Enable( bChecked );
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// Zellwert/Formel
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond31Hdl, void *, EMPTYARG )
+{
+ USHORT nPos = aLbCond31.GetSelectEntryPos();
+
+ if( nPos == 0 ) // Zellwert
+ {
+ aLbCond32.Show();
+ aEdtCond31.SetPosPixel( aCond3Pos2 );
+ }
+ else // Formel
+ {
+ aLbCond32.Hide();
+ aFtCond3And.Hide();
+ aEdtCond32.Hide();
+ aRbCond32.Hide();
+ aRbCond31.SetPosPixel( aRBtn3Pos2 );
+ aEdtCond31.SetPosSizePixel( aCond3Pos1, aCond3Size1 );
+ }
+
+ ChangeCond32Hdl( NULL );
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+// zwischen, gleich, groesser, ...
+
+IMPL_LINK( ScConditionalFormatDlg, ChangeCond32Hdl, void *, EMPTYARG )
+{
+ if( aLbCond32.IsVisible() )
+ {
+ USHORT nPos = aLbCond32.GetSelectEntryPos();
+
+ if( nPos == 6 || nPos == 7 ) // zwischen, n. zwischen
+ {
+ aEdtCond31.SetSizePixel( aCond3Size3 );
+ aRbCond31.SetPosPixel( aRBtn3Pos1 );
+ aFtCond3And.Show();
+ aEdtCond32.Show();
+ aRbCond32.Show();
+ }
+ else // gleich, n. gleich ...
+ {
+ aEdtCond32.Hide();
+ aRbCond32.Hide();
+ aFtCond3And.Hide();
+ aRbCond31.SetPosPixel( aRBtn3Pos2 );
+ aEdtCond31.SetSizePixel( aCond3Size2 );
+ }
+ }
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConditionalFormatDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdtCond11) || (pCtrl == (Control*)&aRbCond11) )
+ pEdActive = &aEdtCond11;
+ else if( (pCtrl == (Control*)&aEdtCond12) || (pCtrl == (Control*)&aRbCond12) )
+ pEdActive = &aEdtCond12;
+ else if( (pCtrl == (Control*)&aEdtCond21) || (pCtrl == (Control*)&aRbCond21) )
+ pEdActive = &aEdtCond21;
+ else if( (pCtrl == (Control*)&aEdtCond22) || (pCtrl == (Control*)&aRbCond22) )
+ pEdActive = &aEdtCond22;
+ else if( (pCtrl == (Control*)&aEdtCond31) || (pCtrl == (Control*)&aRbCond31) )
+ pEdActive = &aEdtCond31;
+ else if( (pCtrl == (Control*)&aEdtCond32) || (pCtrl == (Control*)&aRbCond32) )
+ pEdActive = &aEdtCond32;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConditionalFormatDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+// [OK], [Cancel]
+
+IMPL_LINK( ScConditionalFormatDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ ScConditionalFormat aCondFrmt( 0, pDoc );
+ GetConditionalFormat( aCondFrmt );
+ ScCondFrmtItem aOutItem( FID_CONDITIONAL_FORMAT, aCondFrmt );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( FID_CONDITIONAL_FORMAT,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else if ( pBtn == &aBtnCancel )
+ Close();
+
+ return( 0L );
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConditionalFormatDlg, NewBtnHdl, PushButton*, pBtn )
+{
+ SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
+ SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
+
+ // unlock the dispatcher so SID_STYLE_NEW can be executed
+ // (SetDispatcherLock would affect all Calc documents)
+ SfxDispatcher* pDisp = GetBindings().GetDispatcher();
+ BOOL bLocked = pDisp->IsLocked();
+ if (bLocked)
+ pDisp->Lock(sal_False);
+
+ // Execute the "new style" slot, complete with undo and all necessary updates.
+ // The return value (SfxUInt16Item) is ignored, look for new styles instead.
+ pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
+ &aFamilyItem,
+ &aRefItem,
+ 0L );
+
+ if (bLocked)
+ pDisp->Lock(sal_True);
+
+ // Find the new style and add it into the style list boxes
+ String aNewStyle;
+ SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
+ for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
+ {
+ String aName = pStyle->GetName();
+ if ( aLbCond1Template.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND ) // all lists contain the same entries
+ {
+ aLbCond1Template.InsertEntry( aName );
+ aLbCond2Template.InsertEntry( aName );
+ aLbCond3Template.InsertEntry( aName );
+ // if there are several new styles (from API or a different view),
+ // assume the last one is the result of the dialog
+ aNewStyle = aName;
+ }
+ }
+
+ // select the new style in the list box for which the button was pressed
+ if ( aNewStyle.Len() )
+ {
+ ListBox* pListBox = &aLbCond1Template;
+ if ( pBtn == &aBtnNew2 )
+ pListBox = &aLbCond2Template;
+ else if ( pBtn == &aBtnNew3 )
+ pListBox = &aLbCond3Template;
+
+ pListBox->SelectEntry( aNewStyle );
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/makefile.mk b/sc/source/ui/attrdlg/makefile.mk
new file mode 100644
index 000000000000..9b4dc49dec57
--- /dev/null
+++ b/sc/source/ui/attrdlg/makefile.mk
@@ -0,0 +1,61 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=attrdlg
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = attrdlg.cxx \
+ tabpages.cxx \
+ condfrmt.cxx
+
+SLOFILES = $(SLO)$/attrdlg.obj \
+ $(SLO)$/tabpages.obj \
+ $(SLO)$/condfrmt.obj \
+ $(SLO)$/scabstdlg.obj \
+ $(SLO)$/scuiexp.obj \
+ $(SLO)$/scdlgfact.obj
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/condfrmt.obj \
+ $(SLO)$/scabstdlg.obj
+
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/sc/source/ui/attrdlg/scabstdlg.cxx b/sc/source/ui/attrdlg/scabstdlg.cxx
new file mode 100644
index 000000000000..79481ffdc183
--- /dev/null
+++ b/sc/source/ui/attrdlg/scabstdlg.cxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scabstdlg.hxx"
+
+#include <osl/module.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using ::rtl::OUStringBuffer;
+
+typedef ScAbstractDialogFactory* (__LOADONCALLAPI *ScFuncPtrCreateDialogFactory)();
+
+extern "C" { static void SAL_CALL thisModule() {} }
+
+ScAbstractDialogFactory* ScAbstractDialogFactory::Create()
+{
+ ScFuncPtrCreateDialogFactory fp = 0;
+ static ::osl::Module aDialogLibrary;
+
+ OUStringBuffer aStrBuf;
+ aStrBuf.appendAscii( SVLIBRARY("scui") );
+
+ if ( aDialogLibrary.is() || aDialogLibrary.loadRelative( &thisModule, aStrBuf.makeStringAndClear() ) )
+ fp = ( ScAbstractDialogFactory* (__LOADONCALLAPI*)() )
+ aDialogLibrary.getFunctionSymbol( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CreateDialogFactory")) );
+ if ( fp )
+ return fp();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
new file mode 100644
index 000000000000..fa14720608ea
--- /dev/null
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -0,0 +1,1631 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#if ! ENABLE_LAYOUT_EXPERIMENTAL
+#undef ENABLE_LAYOUT
+#endif
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "scdlgfact.hxx"
+
+#include "sc.hrc"
+#include "scuiasciiopt.hxx" //add for ScImportAsciiDlg
+#include "scuiautofmt.hxx" //add for ScAutoFormatDlg
+#include "corodlg.hxx" //add for ScColRowLabelDlg
+#include "crdlg.hxx" //add for ScColOrRowDlg
+#include "dapidata.hxx" //add for ScDataPilotDatabaseDlg
+#include "dapitype.hxx" //add for ScDataPilotSourceTypeDlg, ScDataPilotServiceDlg
+#include "delcldlg.hxx" //add for ScDeleteCellDlg
+#include "delcodlg.hxx" //add for ScDeleteContentsDlg
+#include "filldlg.hxx" //add for ScFillSeriesDlg
+#include "groupdlg.hxx" //add for ScGroupDlg
+#include "inscldlg.hxx" //add for ScInsertCellDlg
+#include "inscodlg.hxx" //add for ScInsertContentsDlg
+#include "instbdlg.hxx" //add for ScInsertTableDlg
+#include "lbseldlg.hxx" //add for ScSelEntryDlg
+#include "linkarea.hxx" //add for ScLinkedAreaDlg
+#include "mtrindlg.hxx" //add for ScMetricInputDlg
+#include "mvtabdlg.hxx" //add for ScMoveTableDlg
+#include "namecrea.hxx" //add for ScNameCreateDlg
+#include "namepast.hxx" //add for ScNamePasteDlg
+#include "pfiltdlg.hxx" //add for ScPivotFilterDlg
+#include "pvfundlg.hxx" //add for ScDPFunctionDlg
+#include "dpgroupdlg.hxx"
+#include "scendlg.hxx" //add for ScNewScenarioDlg
+#include "shtabdlg.hxx" //add for ScShowTabDlg
+#include "strindlg.hxx" //add for ScStringInputDlg
+#include "tabbgcolordlg.hxx"//add for ScTabBgColorDlg
+#include "scuiimoptdlg.hxx" //add for ScImportOptionsDlg
+#include "attrdlg.hxx" //add for ScAttrDlg
+#include "hfedtdlg.hxx" //add for ScHFEditDlg
+#include "styledlg.hxx" //add for ScStyleDlg
+#include "subtdlg.hxx" //add for ScSubTotalDlg
+#include "textdlgs.hxx" //add for ScCharDlg, ScParagraphDlg
+#include "validate.hxx" //add for ScValidationDlg
+#include "validate.hrc" //add for ScValidationDlg
+#include "sortdlg.hxx" //add for ScSortDlg
+#include "textimportoptions.hxx"
+#include "opredlin.hxx" //add for ScRedlineOptionsTabPage
+#include "tpcalc.hxx" //add for ScTpCalcOptions
+#include "tpprint.hxx" //add for ScTpPrintOptions
+#include "tpstat.hxx" //add for ScDocStatPage
+#include "tpusrlst.hxx" //add for ScTpUserLists
+#include "tpview.hxx" //add for ScTpContentOptions
+#include "tpformula.hxx"
+#include "datafdlg.hxx" //add for ScDataFormDlg
+#include "tpcompatibility.hxx"
+
+// ause
+#include "editutil.hxx"
+#include <sfx2/layout.hxx>
+
+IMPL_ABSTDLG_BASE(VclAbstractDialog_Impl); //add for ScColOrRowDlg
+IMPL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl);//add for ScImportAsciiDlg
+IMPL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl); //add for ScAutoFormatDlg
+IMPL_ABSTDLG_BASE(AbstractScColRowLabelDlg_Impl); //add for ScColRowLabelDlg
+IMPL_ABSTDLG_BASE(AbstractScDataPilotDatabaseDlg_Impl); //add for ScDataPilotDatabaseDlg
+IMPL_ABSTDLG_BASE(AbstractScDataPilotSourceTypeDlg_Impl); //add for ScDataPilotSourceTypeDlg
+IMPL_ABSTDLG_BASE(AbstractScDataPilotServiceDlg_Impl); //add for ScDataPilotServiceDlg
+IMPL_ABSTDLG_BASE(AbstractScDeleteCellDlg_Impl); //add for ScDeleteCellDlg
+//for dataform
+IMPL_ABSTDLG_BASE(AbstractScDataFormDlg_Impl); //add for ScDataFormDlg
+IMPL_ABSTDLG_BASE(AbstractScDeleteContentsDlg_Impl); //add for ScDeleteContentsDlg
+IMPL_ABSTDLG_BASE(AbstractScFillSeriesDlg_Impl); //add for ScFillSeriesDlg
+IMPL_ABSTDLG_BASE(AbstractScGroupDlg_Impl); //add for ScGroupDlg
+IMPL_ABSTDLG_BASE(AbstractScInsertCellDlg_Impl); //add for ScInsertCellDlg
+IMPL_ABSTDLG_BASE(AbstractScInsertContentsDlg_Impl); //add for ScInsertContentsDlg
+IMPL_ABSTDLG_BASE(AbstractScInsertTableDlg_Impl); //add for ScInsertTableDlg
+IMPL_ABSTDLG_BASE(AbstractScSelEntryDlg_Impl); //add for ScSelEntryDlg
+IMPL_ABSTDLG2_BASE(AbstractScLinkedAreaDlg_Impl); //add for ScLinkedAreaDlg
+IMPL_ABSTDLG_BASE(AbstractScMetricInputDlg_Impl); //add for ScMetricInputDlg
+IMPL_ABSTDLG_BASE(AbstractScMoveTableDlg_Impl); //add for ScMoveTableDlg
+IMPL_ABSTDLG_BASE(AbstractScNameCreateDlg_Impl); //add for ScNameCreateDlg
+IMPL_ABSTDLG_BASE(AbstractScNamePasteDlg_Impl); //add for ScNamePasteDlg
+IMPL_ABSTDLG_BASE(AbstractScPivotFilterDlg_Impl); //add for ScPivotFilterDlg
+IMPL_ABSTDLG_BASE(AbstractScDPFunctionDlg_Impl); //add for ScDPFunctionDlg
+IMPL_ABSTDLG_BASE(AbstractScDPSubtotalDlg_Impl); //add for ScDPSubtotalDlg
+IMPL_ABSTDLG_BASE(AbstractScDPNumGroupDlg_Impl);
+IMPL_ABSTDLG_BASE(AbstractScDPDateGroupDlg_Impl);
+IMPL_ABSTDLG_BASE(AbstractScDPShowDetailDlg_Impl); //add for ScDPShowDetailDlg
+IMPL_ABSTDLG_BASE(AbstractScNewScenarioDlg_Impl); //add for ScNewScenarioDlg
+IMPL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl); //add for ScShowTabDlg
+IMPL_ABSTDLG_BASE(AbstractScStringInputDlg_Impl); //add for ScStringInputDlg
+IMPL_ABSTDLG_BASE(AbstractScTabBgColorDlg_Impl); //add for ScTabBgColorDlg
+IMPL_ABSTDLG_BASE(AbstractScImportOptionsDlg_Impl); //add for ScImportOptionsDlg
+IMPL_ABSTDLG_BASE(AbstractScTextImportOptionsDlg_Impl);
+IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg
+
+// AbstractTabDialog_Impl begin
+void AbstractTabDialog_Impl::SetCurPageId( USHORT nId )
+{
+ pDlg->SetCurPageId( nId );
+}
+
+const SfxItemSet* AbstractTabDialog_Impl::GetOutputItemSet() const
+{
+ return pDlg->GetOutputItemSet();
+}
+
+const USHORT* AbstractTabDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+{
+ return pDlg->GetInputRanges( pItem );
+}
+
+void AbstractTabDialog_Impl::SetInputSet( const SfxItemSet* pInSet )
+{
+ pDlg->SetInputSet( pInSet );
+}
+//From class Window.
+void AbstractTabDialog_Impl::SetText( const XubString& rStr )
+{
+ pDlg->SetText( rStr );
+}
+String AbstractTabDialog_Impl::GetText() const
+{
+ return pDlg->GetText();
+}
+
+#if ENABLE_LAYOUT
+namespace layout
+{
+IMPL_ABSTDLG_BASE(AbstractTabDialog_Impl); //add for ScAttrDlg, ScHFEditDlg, ScStyleDlg, ScSubTotalDlg,ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg
+
+// AbstractTabDialog_Impl begin
+void AbstractTabDialog_Impl::SetCurPageId( USHORT nId )
+{
+ pDlg->SetCurPageId( nId );
+}
+
+const SfxItemSet* AbstractTabDialog_Impl::GetOutputItemSet() const
+{
+ return pDlg->GetOutputItemSet();
+}
+
+const USHORT* AbstractTabDialog_Impl::GetInputRanges(const SfxItemPool& pItem )
+{
+ return pDlg->GetInputRanges( pItem );
+}
+
+void AbstractTabDialog_Impl::SetInputSet( const SfxItemSet* pInSet )
+{
+ pDlg->SetInputSet( pInSet );
+}
+//From class Window.
+void AbstractTabDialog_Impl::SetText( const XubString& rStr )
+{
+ pDlg->SetText( rStr );
+}
+String AbstractTabDialog_Impl::GetText() const
+{
+ return pDlg->GetText();
+}
+}
+#endif /* ENABLE_LAYOUT */
+
+//add for AbstractTabDialog_Impl end
+// AbstractScImportAsciiDlg_Impl begin
+void AbstractScImportAsciiDlg_Impl::GetOptions( ScAsciiOptions& rOpt )
+{
+ pDlg->GetOptions( rOpt );
+}
+
+void AbstractScImportAsciiDlg_Impl::SetTextToColumnsMode()
+{
+ pDlg->SetTextToColumnsMode();
+}
+
+void AbstractScImportAsciiDlg_Impl::SaveParameters()
+{
+ pDlg->SaveParameters();
+}
+
+// AbstractScImportAsciiDlg_Impl end
+
+//AbstractScAutoFormatDlg_Impl begin
+USHORT AbstractScAutoFormatDlg_Impl::GetIndex() const
+{
+ return pDlg->GetIndex();
+}
+
+String AbstractScAutoFormatDlg_Impl::GetCurrFormatName()
+{
+ return pDlg->GetCurrFormatName();
+}
+
+//AbstractScAutoFormatDlg_Impl end
+
+
+
+//AbstractScColRowLabelDlg_Impl begin
+BOOL AbstractScColRowLabelDlg_Impl::IsCol()
+{
+ return pDlg->IsCol();
+}
+BOOL AbstractScColRowLabelDlg_Impl::IsRow()
+{
+ return pDlg->IsRow();
+}
+
+//AbstractScColRowLabelDlg_Impl end
+
+
+//AbstractScDataPilotDatabaseDlg_Impl begin
+
+
+void AbstractScDataPilotDatabaseDlg_Impl::GetValues( ScImportSourceDesc& rDesc )
+{
+ pDlg->GetValues(rDesc);
+}
+
+//AbstractScDataPilotDatabaseDlg_Impl end
+
+//AbstractScDataPilotSourceTypeDlg_Impl begin
+
+BOOL AbstractScDataPilotSourceTypeDlg_Impl::IsDatabase() const
+{
+ return pDlg->IsDatabase();
+}
+
+BOOL AbstractScDataPilotSourceTypeDlg_Impl::IsExternal() const
+{
+ return pDlg->IsExternal();
+}
+
+//AbstractScDataPilotSourceTypeDlg_Impl end
+
+
+// AbstractScDataPilotServiceDlg_Impl begin
+String AbstractScDataPilotServiceDlg_Impl::GetServiceName() const
+{
+ return pDlg->GetServiceName();
+}
+
+String AbstractScDataPilotServiceDlg_Impl::GetParSource() const
+{
+ return pDlg->GetParSource();
+}
+String AbstractScDataPilotServiceDlg_Impl::GetParName() const
+{
+ return pDlg->GetParName();
+}
+String AbstractScDataPilotServiceDlg_Impl::GetParUser() const
+{
+ return pDlg->GetParUser();
+}
+String AbstractScDataPilotServiceDlg_Impl::GetParPass() const
+{
+ return pDlg->GetParPass();
+}
+
+//AbstractScDataPilotServiceDlg_Impl end
+
+//AbstractScDeleteCellDlg_Impl begin
+DelCellCmd AbstractScDeleteCellDlg_Impl::GetDelCellCmd() const //add for ScDeleteCellDlg
+{
+ return pDlg->GetDelCellCmd();
+}
+//AbstractScDeleteCellDlg_Impl end
+
+//add for AbstractScDeleteContentsDlg_Impl begin
+void AbstractScDeleteContentsDlg_Impl::DisableObjects()
+{
+ pDlg->DisableObjects();
+}
+USHORT AbstractScDeleteContentsDlg_Impl::GetDelContentsCmdBits() const
+{
+ return pDlg->GetDelContentsCmdBits();
+}
+//add for AbstractScDeleteContentsDlg_Impl end
+
+//add for AbstractScFillSeriesDlg_Impl begin
+FillDir AbstractScFillSeriesDlg_Impl::GetFillDir() const
+{
+ return pDlg->GetFillDir();
+}
+
+FillCmd AbstractScFillSeriesDlg_Impl::GetFillCmd() const
+{
+ return pDlg->GetFillCmd();
+}
+
+FillDateCmd AbstractScFillSeriesDlg_Impl::GetFillDateCmd() const
+{
+ return pDlg->GetFillDateCmd();
+}
+
+double AbstractScFillSeriesDlg_Impl::GetStart() const
+{
+ return pDlg->GetStart();
+}
+double AbstractScFillSeriesDlg_Impl::GetStep() const
+{
+ return pDlg->GetStep();
+}
+double AbstractScFillSeriesDlg_Impl::GetMax() const
+{
+ return pDlg->GetMax();
+}
+String AbstractScFillSeriesDlg_Impl::GetStartStr() const
+{
+ return pDlg->GetStartStr();
+}
+void AbstractScFillSeriesDlg_Impl::SetEdStartValEnabled(BOOL bFlag)
+{
+ pDlg->SetEdStartValEnabled(bFlag);
+}
+//add for AbstractScFillSeriesDlg_Impl end
+
+//add for AbstractScGroupDlg_Impl begin
+BOOL AbstractScGroupDlg_Impl::GetColsChecked() const
+{
+ return pDlg->GetColsChecked();
+}
+//add for AbstractScGroupDlg_Impl end
+
+
+//add for AbstractScInsertCellDlg_Impl begin
+InsCellCmd AbstractScInsertCellDlg_Impl::GetInsCellCmd() const
+{
+ return pDlg->GetInsCellCmd();
+}
+
+//add for AbstractScInsertCellDlg_Impl end
+
+
+//add for AbstractScInsertContentsDlg_Impl begin
+USHORT AbstractScInsertContentsDlg_Impl::GetInsContentsCmdBits() const
+{
+ return pDlg->GetInsContentsCmdBits();
+}
+
+
+USHORT AbstractScInsertContentsDlg_Impl::GetFormulaCmdBits() const
+{
+ return pDlg->GetFormulaCmdBits();
+}
+BOOL AbstractScInsertContentsDlg_Impl::IsSkipEmptyCells() const
+{
+ return pDlg->IsSkipEmptyCells();
+}
+BOOL AbstractScInsertContentsDlg_Impl::IsLink() const
+{
+ return pDlg->IsLink();
+}
+void AbstractScInsertContentsDlg_Impl::SetFillMode( BOOL bSet )
+{
+ pDlg->SetFillMode( bSet );
+}
+
+void AbstractScInsertContentsDlg_Impl::SetOtherDoc( BOOL bSet )
+{
+ pDlg->SetOtherDoc( bSet );
+}
+
+BOOL AbstractScInsertContentsDlg_Impl::IsTranspose() const
+{
+ return pDlg->IsTranspose();
+}
+void AbstractScInsertContentsDlg_Impl::SetChangeTrack( BOOL bSet )
+{
+ pDlg->SetChangeTrack( bSet );
+}
+void AbstractScInsertContentsDlg_Impl::SetCellShiftDisabled( int nDisable )
+{
+ pDlg->SetCellShiftDisabled( nDisable );
+}
+
+InsCellCmd AbstractScInsertContentsDlg_Impl::GetMoveMode()
+{
+ return pDlg->GetMoveMode();
+}
+//add for AbstractScInsertContentsDlg_Impl end
+
+
+//add for AbstractScInsertTableDlg_Impl begin
+BOOL AbstractScInsertTableDlg_Impl::GetTablesFromFile()
+{
+ return pDlg->GetTablesFromFile();
+}
+
+BOOL AbstractScInsertTableDlg_Impl::GetTablesAsLink()
+{
+ return pDlg->GetTablesAsLink();
+}
+const String* AbstractScInsertTableDlg_Impl::GetFirstTable( USHORT* pN )
+{
+ return pDlg->GetFirstTable( pN );
+}
+ScDocShell* AbstractScInsertTableDlg_Impl::GetDocShellTables()
+{
+ return pDlg->GetDocShellTables();
+}
+BOOL AbstractScInsertTableDlg_Impl::IsTableBefore()
+{
+ return pDlg->IsTableBefore();
+}
+USHORT AbstractScInsertTableDlg_Impl::GetTableCount()
+{
+ return pDlg->GetTableCount();
+}
+const String* AbstractScInsertTableDlg_Impl::GetNextTable( USHORT* pN )
+{
+ return pDlg->GetNextTable( pN );
+}
+//add for AbstractScInsertTableDlg_Impl end
+
+//add for AbstractScSelEntryDlg_Impl begin
+String AbstractScSelEntryDlg_Impl::GetSelectEntry() const
+{
+ return pDlg->GetSelectEntry();
+}
+//add for AbstractScSelEntryDlg_Impl end
+
+//add for AbstractScLinkedAreaDlg_Impl begin
+void AbstractScLinkedAreaDlg_Impl::InitFromOldLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ ULONG nRefresh )
+{
+ pDlg->InitFromOldLink( rFile, rFilter, rOptions, rSource, nRefresh);
+}
+
+String AbstractScLinkedAreaDlg_Impl::GetURL()
+{
+ return pDlg->GetURL();
+}
+String AbstractScLinkedAreaDlg_Impl::GetFilter()
+{
+ return pDlg->GetFilter();
+}
+String AbstractScLinkedAreaDlg_Impl::GetOptions()
+{
+ return pDlg->GetOptions();
+}
+String AbstractScLinkedAreaDlg_Impl::GetSource()
+{
+ return pDlg->GetSource();
+}
+ULONG AbstractScLinkedAreaDlg_Impl::GetRefresh()
+{
+ return pDlg->GetRefresh();
+}
+//add for AbstractScLinkedAreaDlg_Impl end
+
+
+//add for AbstractScMetricInputDlg_Impl begin
+long AbstractScMetricInputDlg_Impl::GetInputValue( FieldUnit eUnit ) const
+{
+
+ return pDlg->GetInputValue( eUnit );
+}
+//add for AbstractScMetricInputDlg_Impl end
+
+//add for AbstractScMoveTableDlg_Impl begin
+USHORT AbstractScMoveTableDlg_Impl::GetSelectedDocument() const //add for ScMoveTableDlg
+{
+ return pDlg->GetSelectedDocument();
+}
+
+USHORT AbstractScMoveTableDlg_Impl::GetSelectedTable() const
+{
+ return pDlg->GetSelectedTable();
+}
+BOOL AbstractScMoveTableDlg_Impl::GetCopyTable() const
+{
+ return pDlg->GetCopyTable();
+}
+void AbstractScMoveTableDlg_Impl::SetCopyTable(BOOL bFla)
+{
+ return pDlg->SetCopyTable( bFla );
+}
+void AbstractScMoveTableDlg_Impl::EnableCopyTable(BOOL bFlag)
+{
+ return pDlg->EnableCopyTable( bFlag);
+}
+//add for AbstractScMoveTableDlg_Impl end
+
+//add for AbstractScNameCreateDlg_Impl begin
+USHORT AbstractScNameCreateDlg_Impl::GetFlags() const //add for ScNameCreateDlg
+{
+ return pDlg->GetFlags();
+}
+//add for AbstractScNameCreateDlg_Impl end
+
+//add for AbstractScNamePasteDlg_Impl begin
+String AbstractScNamePasteDlg_Impl::GetSelectedName() const //add for ScNamePasteDlg
+{
+ return pDlg->GetSelectedName();
+}
+
+//add for AbstractScNamePasteDlg_Impl end
+
+//add for AbstractScPivotFilterDlg_Impl begin
+const ScQueryItem& AbstractScPivotFilterDlg_Impl::GetOutputItem() //add for ScPivotFilterDlg
+{
+ return pDlg->GetOutputItem();
+}
+//add for AbstractScPivotFilterDlg_Impl end
+
+//add for AbstractScDPFunctionDlg_Impl begin
+USHORT AbstractScDPFunctionDlg_Impl::GetFuncMask() const //add for ScDPFunctionDlg
+{
+ return pDlg->GetFuncMask();
+}
+::com::sun::star::sheet::DataPilotFieldReference AbstractScDPFunctionDlg_Impl::GetFieldRef() const
+{
+ return pDlg->GetFieldRef();
+}
+//add for AbstractScDPFunctionDlg_Impl end
+
+//add for AbstractScDPSubtotalDlg_Impl begin
+USHORT AbstractScDPSubtotalDlg_Impl::GetFuncMask() const //add for ScDPSubtotalDlg
+{
+ return pDlg->GetFuncMask();
+}
+void AbstractScDPSubtotalDlg_Impl::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ pDlg->FillLabelData( rLabelData );
+}
+//add for AbstractScDPSubtotalDlg_Impl end
+
+ScDPNumGroupInfo AbstractScDPNumGroupDlg_Impl::GetGroupInfo() const
+{
+ return pDlg->GetGroupInfo();
+}
+
+ScDPNumGroupInfo AbstractScDPDateGroupDlg_Impl::GetGroupInfo() const
+{
+ return pDlg->GetGroupInfo();
+}
+
+sal_Int32 AbstractScDPDateGroupDlg_Impl::GetDatePart() const
+{
+ return pDlg->GetDatePart();
+}
+
+//add for AbstractScDPShowDetailDlg_Impl begin
+String AbstractScDPShowDetailDlg_Impl::GetDimensionName() const
+{
+ return pDlg->GetDimensionName();
+}
+//add for AbstractScDPShowDetailDlg_Impl end
+
+//add for AbstractScNewScenarioDlg_Impl begin
+void AbstractScNewScenarioDlg_Impl::SetScenarioData( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags )
+{
+ pDlg->SetScenarioData(rName,rComment, rColor,nFlags);
+}
+
+void AbstractScNewScenarioDlg_Impl::GetScenarioData( String& rName, String& rComment,
+ Color& rColor, USHORT& rFlags ) const
+{
+ pDlg->GetScenarioData( rName,rComment,rColor,rFlags);
+}
+
+//add for AbstractScNewScenarioDlg_Impl end
+
+//add for AbstractScShowTabDlg_Impl begin
+void AbstractScShowTabDlg_Impl::Insert( const String& rString, BOOL bSelected ) //add for ScShowTabDlg
+{
+ pDlg->Insert( rString, bSelected);
+}
+
+USHORT AbstractScShowTabDlg_Impl::GetSelectEntryCount() const
+{
+ return pDlg->GetSelectEntryCount();
+}
+void AbstractScShowTabDlg_Impl::SetDescription(
+ const String& rTitle, const String& rFixedText,
+ ULONG nDlgHelpId, ULONG nLbHelpId )
+{
+ pDlg->SetDescription( rTitle, rFixedText,nDlgHelpId, nLbHelpId );
+}
+USHORT AbstractScShowTabDlg_Impl::GetSelectEntryPos(USHORT nPos) const
+{
+ return pDlg->GetSelectEntryPos( nPos);
+}
+String AbstractScShowTabDlg_Impl::GetSelectEntry(USHORT nPos) const
+{
+ return pDlg->GetSelectEntry(nPos);
+}
+//add for AbstractScShowTabDlg_Impl end
+
+//add for AbstractScStringInputDlg_Impl begin
+void AbstractScStringInputDlg_Impl::GetInputString( String& rString ) const //add for ScStringInputDlg
+{
+ pDlg->GetInputString( rString );
+}
+//add for AbstractScStringInputDlg_Impl end
+
+//add for AbstractScTabBgColorDlg_Impl begin
+void AbstractScTabBgColorDlg_Impl::GetSelectedColor( Color& rColor ) const //add for ScTabBgColorDlg
+{
+ pDlg->GetSelectedColor( rColor );
+}
+//add for AbstractScTabBgColorDlg_Impl end
+
+
+//add for AbstractScImportOptionsDlg_Impl begin
+void AbstractScImportOptionsDlg_Impl::GetImportOptions( ScImportOptions& rOptions ) const //add for ScImportOptionsDlg
+{
+ pDlg->GetImportOptions(rOptions);
+}
+// add for AbstractScImportOptionsDlg_Impl end
+
+//add for AbstractScLangChooserDlg_Impl begin
+LanguageType AbstractScTextImportOptionsDlg_Impl::GetLanguageType() const
+{
+ return pDlg->getLanguageType();
+}
+
+bool AbstractScTextImportOptionsDlg_Impl::IsDateConversionSet() const
+{
+ return pDlg->isDateConversionSet();
+}
+
+//add for AbstractScLangChooserDlg_Impl end
+
+// =========================Factories for createdialog ===================
+
+//add for ScImportAsciiDlg begin
+AbstractScImportAsciiDlg * ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg ( Window* pParent, String aDatName,
+ SvStream* pInStream, int nId, sal_Unicode cSep )
+{
+ ScImportAsciiDlg* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_ASCII :
+ pDlg = new ScImportAsciiDlg( pParent, aDatName,pInStream, cSep );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScImportAsciiDlg_Impl( pDlg );
+ return 0;
+}
+// ScImportAsciiDlg end
+
+AbstractScTextImportOptionsDlg * ScAbstractDialogFactory_Impl::CreateScTextImportOptionsDlg( Window* pParent, int nId )
+{
+ ScTextImportOptionsDlg* pDlg = NULL;
+ switch (nId)
+ {
+ case RID_SCDLG_TEXT_IMPORT_OPTIONS:
+ pDlg = new ScTextImportOptionsDlg(pParent);
+ break;
+ default:
+ ;
+ }
+
+ return pDlg ? new AbstractScTextImportOptionsDlg_Impl(pDlg) : NULL;
+}
+
+//add for ScAutoFormatDlg begin
+
+AbstractScAutoFormatDlg * ScAbstractDialogFactory_Impl::CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg
+ ScAutoFormat* pAutoFormat,
+ const ScAutoFormatData* pSelFormatData,
+ ScDocument* pDoc,
+ int nId)
+{
+ ScAutoFormatDlg* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_AUTOFORMAT :
+ pDlg = new ScAutoFormatDlg( pParent, pAutoFormat,pSelFormatData, pDoc );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScAutoFormatDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScAutoFormatDlg end
+
+//add for ScColRowLabelDlg begin
+
+AbstractScColRowLabelDlg * ScAbstractDialogFactory_Impl::CreateScColRowLabelDlg(Window* pParent, //add for ScColRowLabelDlg
+ int nId,
+ BOOL bCol ,
+ BOOL bRow)
+{
+ ScColRowLabelDlg* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_CHARTCOLROW :
+ pDlg = new ScColRowLabelDlg( pParent, bCol,bRow );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScColRowLabelDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScColRowLabelDlg end
+
+
+//add for ScColOrRowDlg begin
+
+VclAbstractDialog * ScAbstractDialogFactory_Impl::CreateScColOrRowDlg(Window* pParent,
+ const String& rStrTitle,
+ const String& rStrLabel,
+ int nId,
+ BOOL bColDefault)
+{
+ Dialog * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_COLORROW :
+ pDlg = new ScColOrRowDlg( pParent, rStrTitle,rStrLabel,bColDefault );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new VclAbstractDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScColOrRowDlg end
+
+//add for ScSortWarningDlg begin
+VclAbstractDialog * ScAbstractDialogFactory_Impl::CreateScSortWarningDlg( Window* pParent, const String& rExtendText,
+ const String& rCurrentText, int nId )
+{
+ Dialog * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_SORT_WARNING:
+ pDlg = new ScSortWarningDlg( pParent, rExtendText, rCurrentText );
+ break;
+ default:
+ break;
+ }
+ if( pDlg )
+ return new VclAbstractDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScSortWarningDlg end
+
+//add for ScDataPilotDatabaseDlg begin
+
+AbstractScDataPilotDatabaseDlg * ScAbstractDialogFactory_Impl::CreateScDataPilotDatabaseDlg (Window* pParent ,
+ int nId ) //add for ScDataPilotDatabaseDlg
+{
+ ScDataPilotDatabaseDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DAPIDATA :
+ pDlg = new ScDataPilotDatabaseDlg( pParent );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDataPilotDatabaseDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScDataPilotDatabaseDlg end
+
+//add for ScDataPilotSourceTypeDlg begin
+AbstractScDataPilotSourceTypeDlg* ScAbstractDialogFactory_Impl::CreateScDataPilotSourceTypeDlg( Window* pParent,
+ BOOL bEnableExternal,
+ int nId )
+{
+ ScDataPilotSourceTypeDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DAPITYPE :
+ pDlg = new ScDataPilotSourceTypeDlg( pParent, bEnableExternal );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDataPilotSourceTypeDlg_Impl( pDlg );
+ return 0;
+}
+
+// add for ScDataPilotSourceTypeDlg end
+
+
+//add for ScDataPilotServiceDlg begin
+AbstractScDataPilotServiceDlg* ScAbstractDialogFactory_Impl::CreateScDataPilotServiceDlg( Window* pParent,
+ const com::sun::star::uno::Sequence<rtl::OUString>& rServices,
+ int nId )
+{
+ ScDataPilotServiceDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DAPISERVICE :
+ pDlg = new ScDataPilotServiceDlg( pParent, rServices );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDataPilotServiceDlg_Impl( pDlg );
+ return 0;
+}
+
+// add for ScDataPilotServiceDlg end
+
+//add for ScDeleteCellDlg begin
+AbstractScDeleteCellDlg* ScAbstractDialogFactory_Impl::CreateScDeleteCellDlg( Window* pParent, int nId,
+ BOOL bDisallowCellMove )
+{
+ ScDeleteCellDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DELCELL :
+ pDlg = new ScDeleteCellDlg( pParent, bDisallowCellMove );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDeleteCellDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScDeleteCellDlg end
+
+//add for ScDataFormDlg begin
+AbstractScDataFormDlg* ScAbstractDialogFactory_Impl::CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell )
+{
+ ScDataFormDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DATAFORM :
+ pDlg = new ScDataFormDlg( pParent, pTabViewShell);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDataFormDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScDataFormDlg end
+
+//add for ScDeleteContentsDlg begin
+AbstractScDeleteContentsDlg* ScAbstractDialogFactory_Impl::CreateScDeleteContentsDlg(Window* pParent,int nId, //add for ScDeleteContentsDlg
+ USHORT nCheckDefaults )
+{
+ ScDeleteContentsDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DELCONT :
+ pDlg = new ScDeleteContentsDlg( pParent, nCheckDefaults );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDeleteContentsDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScDeleteContentsDlg end
+
+//add for ScFillSeriesDlg begin
+AbstractScFillSeriesDlg* ScAbstractDialogFactory_Impl::CreateScFillSeriesDlg( Window* pParent, //add for ScFillSeriesDlg
+ ScDocument& rDocument,
+ FillDir eFillDir,
+ FillCmd eFillCmd,
+ FillDateCmd eFillDateCmd,
+ String aStartStr,
+ double fStep,
+ double fMax,
+ USHORT nPossDir,
+ int nId)
+{
+ ScFillSeriesDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_FILLSERIES :
+ pDlg = new ScFillSeriesDlg( pParent, rDocument,eFillDir, eFillCmd,eFillDateCmd, aStartStr,fStep,fMax,nPossDir);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScFillSeriesDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScFillSeriesDlg end
+
+//add for ScGroupDlg begin
+AbstractScGroupDlg* ScAbstractDialogFactory_Impl::CreateAbstractScGroupDlg( Window* pParent,
+ USHORT nResId,
+ int nId,
+ BOOL bUnGroup ,
+ BOOL bRows )
+{
+ ScGroupDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_GRP_KILL :
+ case RID_SCDLG_GRP_MAKE :
+ pDlg = new ScGroupDlg( pParent, nResId,bUnGroup, bRows);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScGroupDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScGroupDlg end
+
+
+//add for ScInsertCellDlg begin
+AbstractScInsertCellDlg * ScAbstractDialogFactory_Impl::CreateScInsertCellDlg( Window* pParent, //add for ScInsertCellDlg
+ int nId,
+ BOOL bDisallowCellMove )
+{
+ ScInsertCellDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_INSCELL :
+ pDlg = new ScInsertCellDlg( pParent, bDisallowCellMove);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScInsertCellDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScInsertCellDlg end
+
+//add for ScInsertContentsDlg begin
+AbstractScInsertContentsDlg * ScAbstractDialogFactory_Impl::CreateScInsertContentsDlg( Window* pParent,
+ int nId,
+ USHORT nCheckDefaults,
+ const String* pStrTitle )
+{
+ ScInsertContentsDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_INSCONT :
+ pDlg = new ScInsertContentsDlg( pParent, nCheckDefaults,pStrTitle );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScInsertContentsDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScInsertContentsDlg end
+
+//add for ScInsertTableDlg begin
+AbstractScInsertTableDlg * ScAbstractDialogFactory_Impl::CreateScInsertTableDlg ( Window* pParent, ScViewData& rViewData,
+ SCTAB nTabCount, bool bFromFile, int nId)
+{
+ ScInsertTableDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_INSERT_TABLE :
+ pDlg = new ScInsertTableDlg( pParent, rViewData,nTabCount, bFromFile );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScInsertTableDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScInsertTableDlg end
+
+// add for ScSelEntryDlg begin
+AbstractScSelEntryDlg * ScAbstractDialogFactory_Impl::CreateScSelEntryDlg ( Window* pParent,
+ USHORT nResId,
+ const String& aTitle,
+ const String& aLbTitle,
+ List& aEntryList,
+ int nId )
+{
+ ScSelEntryDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_SELECTDB :
+ pDlg = new ScSelEntryDlg( pParent, nResId,aTitle, aLbTitle, aEntryList );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScSelEntryDlg_Impl( pDlg );
+ return 0;
+}
+// add for ScSelEntryDlg end
+
+//add for ScLinkedAreaDlg begin
+AbstractScLinkedAreaDlg * ScAbstractDialogFactory_Impl::CreateScLinkedAreaDlg ( Window* pParent,
+ int nId)
+{
+ ScLinkedAreaDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_LINKAREA :
+ pDlg = new ScLinkedAreaDlg( pParent );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScLinkedAreaDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScLinkedAreaDlg end
+
+//add for ScMetricInputDlg begin
+AbstractScMetricInputDlg * ScAbstractDialogFactory_Impl::CreateScMetricInputDlg ( Window* pParent,
+ USHORT nResId, // Ableitung fuer jeden Dialog!
+ long nCurrent,
+ long nDefault,
+ int nId ,
+ FieldUnit eFUnit,
+ USHORT nDecimals,
+ long nMaximum ,
+ long nMinimum,
+ long nFirst,
+ long nLast )
+{
+ ScMetricInputDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_ROW_MAN :
+ case RID_SCDLG_ROW_OPT :
+ case RID_SCDLG_COL_MAN :
+ case RID_SCDLG_COL_OPT :
+ pDlg = new ScMetricInputDlg( pParent , nResId,nCurrent ,nDefault, eFUnit,
+ nDecimals, nMaximum , nMinimum , nFirst, nLast);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScMetricInputDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScMetricInputDlg end
+
+
+//add for ScMoveTableDlg begin
+AbstractScMoveTableDlg * ScAbstractDialogFactory_Impl::CreateScMoveTableDlg( Window* pParent, int nId )
+{
+ ScMoveTableDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_MOVETAB :
+ pDlg = new ScMoveTableDlg( pParent );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScMoveTableDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScMoveTableDlg end
+
+
+//add for ScNameCreateDlg begin
+AbstractScNameCreateDlg * ScAbstractDialogFactory_Impl::CreateScNameCreateDlg ( Window * pParent, USHORT nFlags, int nId )
+{
+ ScNameCreateDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_NAMES_CREATE :
+ pDlg = new ScNameCreateDlg( pParent, nFlags );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScNameCreateDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScNameCreateDlg end
+
+
+//add for ScNamePasteDlg begin
+ AbstractScNamePasteDlg * ScAbstractDialogFactory_Impl::CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList,
+ int nId , BOOL bInsList )
+{
+ ScNamePasteDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_NAMES_PASTE :
+ pDlg = new ScNamePasteDlg( pParent, pList, bInsList );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScNamePasteDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScNamePasteDlg end
+
+//add for ScPivotFilterDlg begin
+AbstractScPivotFilterDlg * ScAbstractDialogFactory_Impl::CreateScPivotFilterDlg ( Window* pParent,
+ const SfxItemSet& rArgSet, USHORT nSourceTab , int nId )
+{
+ ScPivotFilterDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_PIVOTFILTER :
+ pDlg = new ScPivotFilterDlg( pParent, rArgSet, nSourceTab );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScPivotFilterDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScPivotFilterDlg end
+
+
+//add for ScDPFunctionDlg begin
+AbstractScDPFunctionDlg * ScAbstractDialogFactory_Impl::CreateScDPFunctionDlg ( Window* pParent,
+ int nId,
+ const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData,
+ const ScDPFuncData& rFuncData )
+{
+ ScDPFunctionDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_DPDATAFIELD :
+ pDlg = new ScDPFunctionDlg( pParent, rLabelVec, rLabelData, rFuncData );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDPFunctionDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScDPFunctionDlg end
+
+//add for ScDPSubtotalDlg begin
+AbstractScDPSubtotalDlg * ScAbstractDialogFactory_Impl::CreateScDPSubtotalDlg ( Window* pParent,
+ int nId,
+ ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData,
+ const ScDPFuncData& rFuncData,
+ const ScDPNameVec& rDataFields,
+ bool bEnableLayout )
+{
+ ScDPSubtotalDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_PIVOTSUBT :
+ pDlg = new ScDPSubtotalDlg( pParent, rDPObj, rLabelData, rFuncData, rDataFields, bEnableLayout );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScDPSubtotalDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScDPSubtotalDlg end
+
+AbstractScDPNumGroupDlg * ScAbstractDialogFactory_Impl::CreateScDPNumGroupDlg(
+ Window* pParent, int nId, const ScDPNumGroupInfo& rInfo )
+{
+ if( nId == RID_SCDLG_DPNUMGROUP )
+ return new AbstractScDPNumGroupDlg_Impl( new ScDPNumGroupDlg( pParent, rInfo ) );
+ return 0;
+}
+
+AbstractScDPDateGroupDlg * ScAbstractDialogFactory_Impl::CreateScDPDateGroupDlg(
+ Window* pParent, int nId,
+ const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart, const Date& rNullDate )
+{
+ if( nId == RID_SCDLG_DPDATEGROUP )
+ return new AbstractScDPDateGroupDlg_Impl( new ScDPDateGroupDlg( pParent, rInfo, nDatePart, rNullDate ) );
+ return 0;
+}
+
+//add for ScDPShowDetailDlg begin
+AbstractScDPShowDetailDlg * ScAbstractDialogFactory_Impl::CreateScDPShowDetailDlg (
+ Window* pParent, int nId, ScDPObject& rDPObj, USHORT nOrient )
+{
+ if( nId == RID_SCDLG_DPSHOWDETAIL )
+ return new AbstractScDPShowDetailDlg_Impl( new ScDPShowDetailDlg( pParent, rDPObj, nOrient ) );
+ return 0;
+}
+//add for ScDPShowDetailDlg end
+
+//add for ScNewScenarioDlg begin
+AbstractScNewScenarioDlg * ScAbstractDialogFactory_Impl::CreateScNewScenarioDlg ( Window* pParent, const String& rName,
+ int nId,
+ BOOL bEdit , BOOL bSheetProtected )
+{
+ ScNewScenarioDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_NEWSCENARIO :
+ pDlg = new ScNewScenarioDlg( pParent, rName, bEdit,bSheetProtected );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScNewScenarioDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScNewScenarioDlg end
+
+//add for ScShowTabDlg begin
+AbstractScShowTabDlg * ScAbstractDialogFactory_Impl::CreateScShowTabDlg ( Window* pParent, int nId )
+{
+ ScShowTabDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_SHOW_TAB :
+ pDlg = new ScShowTabDlg( pParent);
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScShowTabDlg_Impl( pDlg );
+ return 0;
+}
+
+//add for ScShowTabDlg end
+
+
+//add for ScStringInputDlg begin
+ AbstractScStringInputDlg * ScAbstractDialogFactory_Impl::CreateScStringInputDlg ( Window* pParent,
+ const String& rTitle,
+ const String& rEditTitle,
+ const String& rDefault,
+ ULONG nHelpId ,
+ int nId )
+{
+ ScStringInputDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_STRINPUT :
+ pDlg = new ScStringInputDlg( pParent, rTitle, rEditTitle,rDefault, nHelpId );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScStringInputDlg_Impl( pDlg );
+ return 0;
+}
+ //add for ScStringInputDlg end
+
+//add for ScTabBgColorDlg begin
+AbstractScTabBgColorDlg * ScAbstractDialogFactory_Impl::CreateScTabBgColorDlg (
+ Window* pParent,
+ const String& rTitle,
+ const String& rTabBgColorNoColorText,
+ const Color& rDefaultColor,
+ ULONG nHelpId ,
+ int nId )
+{
+ScTabBgColorDlg * pDlg=NULL;
+switch ( nId )
+{
+ case RID_SCDLG_TAB_BG_COLOR :
+ pDlg = new ScTabBgColorDlg( pParent, rTitle, rTabBgColorNoColorText, rDefaultColor, nHelpId );
+ break;
+ default:
+ break;
+}
+
+if ( pDlg )
+ return new AbstractScTabBgColorDlg_Impl( pDlg );
+return 0;
+}
+//add for ScTabBgColorDlg end
+
+//add for ScImportOptionsDlg begin
+AbstractScImportOptionsDlg * ScAbstractDialogFactory_Impl::CreateScImportOptionsDlg ( Window* pParent,
+ int nId,
+ BOOL bAscii,
+ const ScImportOptions* pOptions,
+ const String* pStrTitle,
+ BOOL bMultiByte,
+ BOOL bOnlyDbtoolsEncodings,
+ BOOL bImport )
+{
+ ScImportOptionsDlg * pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_IMPORTOPT :
+ pDlg = new ScImportOptionsDlg( pParent, bAscii, pOptions,pStrTitle, bMultiByte,bOnlyDbtoolsEncodings, bImport );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractScImportOptionsDlg_Impl( pDlg );
+ return 0;
+}
+//add for ScImportOptionsDlg end
+
+#if ENABLE_LAYOUT && !LAYOUT_SFX_TABDIALOG_BROKEN
+#define SfxTabDialog layout::SfxTabDialog
+#define AbstractTabDialog_Impl layout::AbstractTabDialog_Impl
+#endif /* ENABLE_LAYOUT */
+//add for ScAttrDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScAttrDlg( SfxViewFrame* pFrame,
+ Window* pParent,
+ const SfxItemSet* pCellAttrs,
+ int nId)
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_ATTR :
+ pDlg = new ScAttrDlg( pFrame, pParent, pCellAttrs );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+
+}
+//add for ScAttrDlg end
+#undef SfxTabDialog
+#undef AbstractTabDialog_Impl
+
+//add for ScHFEditDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScHFEditDlg( SfxViewFrame* pFrame,
+ Window* pParent,
+ const SfxItemSet& rCoreSet,
+ const String& rPageStyle,
+ int nId,
+ USHORT nResId )
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_HFEDIT :
+ pDlg = new ScHFEditDlg( pFrame, pParent, rCoreSet,rPageStyle, nResId );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScHFEditDlg end
+
+//add for ScStyleDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScStyleDlg( Window* pParent,
+ SfxStyleSheetBase& rStyleBase,
+ USHORT nRscId,
+ int nId)
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_STYLES_PAGE :
+ case RID_SCDLG_STYLES_PAR :
+ pDlg = new ScStyleDlg( pParent, rStyleBase, nRscId );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScStyleDlg end
+
+//add for ScSubTotalDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScSubTotalDlg( Window* pParent,
+ const SfxItemSet* pArgSet,
+ int nId)
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_SUBTOTALS :
+ pDlg = new ScSubTotalDlg( pParent, pArgSet );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScSubTotalDlg end
+
+//add for ScCharDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScCharDlg( Window* pParent, const SfxItemSet* pAttr,
+ const SfxObjectShell* pDocShell, int nId )
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_CHAR :
+ pDlg = new ScCharDlg( pParent, pAttr, pDocShell );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScCharDlg end
+
+//add for ScParagraphDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScParagraphDlg( Window* pParent, const SfxItemSet* pAttr ,
+ int nId )
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_PARAGRAPH :
+ pDlg = new ScParagraphDlg( pParent, pAttr );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScParagraphDlg end
+
+//add for ScValidationDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScValidationDlg( Window* pParent,
+//<!--Modified by PengYunQuan for Validity Cell Range Picker
+// const SfxItemSet* pArgSet,int nId )
+ const SfxItemSet* pArgSet,int nId, ScTabViewShell *pTabVwSh )
+//-->Modified by PengYunQuan for Validity Cell Range Picke
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case TAB_DLG_VALIDATION :
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //pDlg = new ScValidationDlg( pParent, pArgSet );
+ pDlg = new ScValidationDlg( pParent, pArgSet, pTabVwSh );
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+//add for ScValidationDlg end
+
+#if ENABLE_LAYOUT && !LAYOUT_SFX_TABDIALOG_BROKEN
+#define SfxTabDialog layout::SfxTabDialog
+#define AbstractTabDialog_Impl layout::AbstractTabDialog_Impl
+#endif /* ENABLE_LAYOUT */
+//add for ScSortDlg begin
+SfxAbstractTabDialog * ScAbstractDialogFactory_Impl::CreateScSortDlg( Window* pParent,
+ const SfxItemSet* pArgSet,int nId )
+{
+ SfxTabDialog* pDlg=NULL;
+ switch ( nId )
+ {
+ case RID_SCDLG_SORT :
+ pDlg = new ScSortDlg( pParent, pArgSet );
+ break;
+ default:
+ break;
+ }
+
+ if ( pDlg )
+ return new AbstractTabDialog_Impl( pDlg );
+ return 0;
+}
+#undef SfxTabDialog
+#undef AbstractTabDialog_Impl
+
+//add for ScSortDlg end
+//------------------ Factories for TabPages--------------------
+CreateTabPage ScAbstractDialogFactory_Impl::GetTabPageCreatorFunc( USHORT nId )
+{
+ switch ( nId )
+ {
+ case RID_SCPAGE_OPREDLINE :
+ return ScRedlineOptionsTabPage::Create;
+ //break;
+ case RID_SCPAGE_CALC :
+ return ScTpCalcOptions::Create;
+ //break;
+ case RID_SCPAGE_FORMULA:
+ return ScTpFormulaOptions::Create;
+ case RID_SCPAGE_COMPATIBILITY:
+ return ScTpCompatOptions::Create;
+ case RID_SCPAGE_PRINT :
+ return ScTpPrintOptions::Create;
+ //break;
+ case RID_SCPAGE_STAT :
+ return ScDocStatPage::Create;
+ //break;
+ case RID_SCPAGE_USERLISTS :
+ return ScTpUserLists::Create;
+ //break;
+ case RID_SCPAGE_CONTENT :
+ return ScTpContentOptions::Create;
+ //break;
+ case RID_SCPAGE_LAYOUT :
+ return ScTpLayoutOptions::Create;
+ //break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+GetTabPageRanges ScAbstractDialogFactory_Impl::GetTabPageRangesFunc( USHORT nId )
+{
+ switch ( nId )
+ {
+ case TP_VALIDATION_VALUES :
+ return ScTPValidationValue::GetRanges;
+ //break;
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+void ScDPFunctionDlg_Dummy()
+{
+ // use ScDPListBoxWrapper to avoid warning (this isn't called)
+ ListBox* pListBox = NULL;
+ ScDPListBoxWrapper aWrapper( *pListBox );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
new file mode 100644
index 000000000000..f1ec2a54c7ad
--- /dev/null
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -0,0 +1,594 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SC_DLGFACT_HXX
+#define _SC_DLGFACT_HXX
+
+// include ---------------------------------------------------------------
+#include "scabstdlg.hxx"
+class Dialog;
+class ScImportAsciiDlg;
+class ScAutoFormatDlg;
+class ScColRowLabelDlg;
+class ScDataPilotDatabaseDlg;
+class ScDataPilotSourceTypeDlg;
+class ScDataPilotServiceDlg;
+class ScDeleteCellDlg;
+class ScDataFormDlg;
+class ScDeleteContentsDlg;
+class ScFillSeriesDlg;
+class ScGroupDlg;
+class ScInsertCellDlg;
+class ScInsertContentsDlg;
+class ScInsertTableDlg;
+class ScSelEntryDlg;
+class ScLinkedAreaDlg;
+class ScMetricInputDlg;
+class ScMoveTableDlg;
+class ScNameCreateDlg;
+class ScNamePasteDlg;
+class ScPivotFilterDlg;
+class ScDPFunctionDlg;
+class ScDPSubtotalDlg;
+class ScDPNumGroupDlg;
+class ScDPDateGroupDlg;
+class ScDPShowDetailDlg;
+class ScNewScenarioDlg;
+class ScShowTabDlg;
+class ScStringInputDlg;
+class ScTabBgColorDlg;
+class ScImportOptionsDlg;
+class SfxTabDialog;
+class ScSortWarningDlg;
+class ScTextImportOptionsDlg;
+
+#define DECL_ABSTDLG_BASE(Class,DialogClass) \
+ DialogClass* pDlg; \
+public: \
+ Class( DialogClass* p) \
+ : pDlg(p) \
+ {} \
+ virtual ~Class(); \
+ virtual short Execute() ;
+
+#define DECL_ABSTDLG2_BASE(Class,DialogClass) \
+ DialogClass* pDlg; \
+public: \
+ Class( DialogClass* p) \
+ : pDlg(p) \
+ {} \
+ virtual ~Class(); \
+ virtual void StartExecuteModal( const Link& rEndDialogHdl ); \
+ long GetResult();
+
+#define IMPL_ABSTDLG_BASE(Class) \
+Class::~Class() \
+{ \
+ delete pDlg; \
+} \
+short Class::Execute() \
+{ \
+ return pDlg->Execute(); \
+}
+
+#define IMPL_ABSTDLG2_BASE(Class) \
+Class::~Class() \
+{ \
+ delete pDlg; \
+} \
+void Class::StartExecuteModal( const Link& rEndDialogHdl ) \
+{ \
+ pDlg->StartExecuteModal( rEndDialogHdl ) ; \
+} \
+long Class::GetResult() \
+{ \
+ return pDlg->GetResult(); \
+}
+
+class VclAbstractDialog_Impl : public VclAbstractDialog //add for ScColOrRowDlg
+{
+ DECL_ABSTDLG_BASE(VclAbstractDialog_Impl,Dialog)
+};
+
+class AbstractScImportAsciiDlg_Impl : public AbstractScImportAsciiDlg //add for ScImportAsciiDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScImportAsciiDlg_Impl, ScImportAsciiDlg)
+ virtual void GetOptions( ScAsciiOptions& rOpt );
+ virtual void SetTextToColumnsMode();
+ virtual void SaveParameters();
+};
+
+class AbstractScAutoFormatDlg_Impl : public AbstractScAutoFormatDlg //add for ScAutoFormatDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScAutoFormatDlg_Impl, ScAutoFormatDlg)
+ virtual USHORT GetIndex() const;
+ virtual String GetCurrFormatName();
+};
+
+class AbstractScColRowLabelDlg_Impl : public AbstractScColRowLabelDlg //add for ScColRowLabelDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScColRowLabelDlg_Impl,ScColRowLabelDlg)
+ virtual BOOL IsCol();
+ virtual BOOL IsRow();
+};
+
+class AbstractScDataPilotDatabaseDlg_Impl :public AbstractScDataPilotDatabaseDlg //add for ScDataPilotDatabaseDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScDataPilotDatabaseDlg_Impl, ScDataPilotDatabaseDlg)
+ virtual void GetValues( ScImportSourceDesc& rDesc );
+};
+
+class AbstractScDataPilotSourceTypeDlg_Impl :public AbstractScDataPilotSourceTypeDlg //add for ScDataPilotSourceTypeDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScDataPilotSourceTypeDlg_Impl, ScDataPilotSourceTypeDlg)
+ virtual BOOL IsDatabase() const;
+ virtual BOOL IsExternal() const;
+};
+
+class AbstractScDataPilotServiceDlg_Impl : public AbstractScDataPilotServiceDlg //add for ScDataPilotServiceDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScDataPilotServiceDlg_Impl, ScDataPilotServiceDlg)
+ virtual String GetServiceName() const;
+ virtual String GetParSource() const;
+ virtual String GetParName() const;
+ virtual String GetParUser() const;
+ virtual String GetParPass() const;
+};
+
+class AbstractScDeleteCellDlg_Impl : public AbstractScDeleteCellDlg //add for ScDeleteCellDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScDeleteCellDlg_Impl,ScDeleteCellDlg)
+ virtual DelCellCmd GetDelCellCmd() const;
+};
+
+//for dataform
+class AbstractScDataFormDlg_Impl : public AbstractScDataFormDlg //add for ScDataFormDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScDataFormDlg_Impl,ScDataFormDlg);
+};
+
+class AbstractScDeleteContentsDlg_Impl : public AbstractScDeleteContentsDlg //add for ScDeleteContentsDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScDeleteContentsDlg_Impl,ScDeleteContentsDlg)
+ virtual void DisableObjects();
+ virtual USHORT GetDelContentsCmdBits() const;
+};
+
+class AbstractScFillSeriesDlg_Impl:public AbstractScFillSeriesDlg //add for ScFillSeriesDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScFillSeriesDlg_Impl, ScFillSeriesDlg)
+ virtual FillDir GetFillDir() const;
+ virtual FillCmd GetFillCmd() const;
+ virtual FillDateCmd GetFillDateCmd() const;
+ virtual double GetStart() const;
+ virtual double GetStep() const;
+ virtual double GetMax() const;
+ virtual String GetStartStr() const;
+ virtual void SetEdStartValEnabled(BOOL bFlag=FALSE);
+};
+
+class AbstractScGroupDlg_Impl : public AbstractScGroupDlg //add for ScGroupDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScGroupDlg_Impl, ScGroupDlg)
+ virtual BOOL GetColsChecked() const;
+};
+
+class AbstractScInsertCellDlg_Impl : public AbstractScInsertCellDlg //add for ScInsertCellDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScInsertCellDlg_Impl, ScInsertCellDlg)
+ virtual InsCellCmd GetInsCellCmd() const ;
+};
+
+class AbstractScInsertContentsDlg_Impl : public AbstractScInsertContentsDlg //add for ScInsertContentsDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScInsertContentsDlg_Impl, ScInsertContentsDlg)
+ virtual USHORT GetInsContentsCmdBits() const;
+ virtual USHORT GetFormulaCmdBits() const;
+ virtual BOOL IsSkipEmptyCells() const;
+ virtual BOOL IsLink() const;
+ virtual void SetFillMode( BOOL bSet );
+ virtual void SetOtherDoc( BOOL bSet );
+ virtual BOOL IsTranspose() const;
+ virtual void SetChangeTrack( BOOL bSet );
+ virtual void SetCellShiftDisabled( int nDisable );
+ virtual InsCellCmd GetMoveMode();
+};
+
+class AbstractScInsertTableDlg_Impl : public AbstractScInsertTableDlg //add for ScInsertTableDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScInsertTableDlg_Impl, ScInsertTableDlg)
+ virtual BOOL GetTablesFromFile();
+ virtual BOOL GetTablesAsLink();
+ virtual const String* GetFirstTable( USHORT* pN = NULL );
+ virtual ScDocShell* GetDocShellTables();
+ virtual BOOL IsTableBefore();
+ virtual USHORT GetTableCount();
+ virtual const String* GetNextTable( USHORT* pN = NULL );
+
+};
+
+class AbstractScSelEntryDlg_Impl : public AbstractScSelEntryDlg //add for ScSelEntryDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScSelEntryDlg_Impl, ScSelEntryDlg )
+ virtual String GetSelectEntry() const;
+};
+
+class AbstractScLinkedAreaDlg_Impl : public AbstractScLinkedAreaDlg //add for ScLinkedAreaDlg
+{
+ DECL_ABSTDLG2_BASE( AbstractScLinkedAreaDlg_Impl, ScLinkedAreaDlg)
+
+ virtual void InitFromOldLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ ULONG nRefresh );
+ virtual String GetURL();
+ virtual String GetFilter(); // may be empty
+ virtual String GetOptions(); // filter options
+ virtual String GetSource(); // separated by ";"
+ virtual ULONG GetRefresh(); // 0 if disabled
+};
+
+class AbstractScMetricInputDlg_Impl : public AbstractScMetricInputDlg //add for ScMetricInputDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScMetricInputDlg_Impl, ScMetricInputDlg)
+ virtual long GetInputValue( FieldUnit eUnit = FUNIT_TWIP ) const;
+};
+
+class AbstractScMoveTableDlg_Impl : public AbstractScMoveTableDlg //add for ScMoveTableDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScMoveTableDlg_Impl, ScMoveTableDlg)
+ virtual USHORT GetSelectedDocument () const;
+ virtual USHORT GetSelectedTable () const;
+ virtual BOOL GetCopyTable () const;
+ virtual void SetCopyTable (BOOL bFlag=TRUE);
+ virtual void EnableCopyTable (BOOL bFlag=TRUE);
+};
+
+class AbstractScNameCreateDlg_Impl : public AbstractScNameCreateDlg //add for ScNameCreateDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScNameCreateDlg_Impl, ScNameCreateDlg)
+ virtual USHORT GetFlags() const;
+};
+
+class AbstractScNamePasteDlg_Impl : public AbstractScNamePasteDlg //add for ScNamePasteDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScNamePasteDlg_Impl, ScNamePasteDlg )
+ virtual String GetSelectedName() const;
+};
+
+class AbstractScPivotFilterDlg_Impl : public AbstractScPivotFilterDlg //add for ScPivotFilterDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScPivotFilterDlg_Impl, ScPivotFilterDlg)
+ virtual const ScQueryItem& GetOutputItem();
+};
+
+class AbstractScDPFunctionDlg_Impl : public AbstractScDPFunctionDlg //add for ScDPFunctionDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScDPFunctionDlg_Impl, ScDPFunctionDlg)
+ virtual USHORT GetFuncMask() const;
+ virtual ::com::sun::star::sheet::DataPilotFieldReference GetFieldRef() const;
+};
+
+class AbstractScDPSubtotalDlg_Impl : public AbstractScDPSubtotalDlg //add for ScDPSubtotalDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScDPSubtotalDlg_Impl, ScDPSubtotalDlg)
+ virtual USHORT GetFuncMask() const;
+ virtual void FillLabelData( ScDPLabelData& rLabelData ) const;
+};
+
+class AbstractScDPNumGroupDlg_Impl : public AbstractScDPNumGroupDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScDPNumGroupDlg_Impl, ScDPNumGroupDlg )
+ virtual ScDPNumGroupInfo GetGroupInfo() const;
+};
+
+class AbstractScDPDateGroupDlg_Impl : public AbstractScDPDateGroupDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScDPDateGroupDlg_Impl, ScDPDateGroupDlg )
+ virtual ScDPNumGroupInfo GetGroupInfo() const;
+ virtual sal_Int32 GetDatePart() const;
+};
+
+class AbstractScDPShowDetailDlg_Impl : public AbstractScDPShowDetailDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScDPShowDetailDlg_Impl, ScDPShowDetailDlg)
+ virtual String GetDimensionName() const;
+};
+
+class AbstractScNewScenarioDlg_Impl : public AbstractScNewScenarioDlg //add for ScNewScenarioDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScNewScenarioDlg_Impl, ScNewScenarioDlg )
+ virtual void SetScenarioData( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags );
+
+ virtual void GetScenarioData( String& rName, String& rComment,
+ Color& rColor, USHORT& rFlags ) const;
+};
+
+class AbstractScShowTabDlg_Impl : public AbstractScShowTabDlg //add for ScShowTabDlg
+{
+ DECL_ABSTDLG_BASE(AbstractScShowTabDlg_Impl,ScShowTabDlg)
+ virtual void Insert( const String& rString, BOOL bSelected );
+ virtual USHORT GetSelectEntryCount() const;
+ virtual void SetDescription(const String& rTitle, const String& rFixedText,ULONG nDlgHelpId, ULONG nLbHelpId );
+ virtual String GetSelectEntry(USHORT nPos) const;
+ virtual USHORT GetSelectEntryPos(USHORT nPos) const;
+};
+
+class AbstractScStringInputDlg_Impl : public AbstractScStringInputDlg //add for ScStringInputDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScStringInputDlg_Impl, ScStringInputDlg )
+ virtual void GetInputString( String& rString ) const;
+};
+
+class AbstractScTabBgColorDlg_Impl : public AbstractScTabBgColorDlg //add for ScTabBgColorDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScTabBgColorDlg_Impl, ScTabBgColorDlg )
+ virtual void GetSelectedColor( Color& rColor ) const;
+};
+
+class AbstractScImportOptionsDlg_Impl : public AbstractScImportOptionsDlg //add for ScImportOptionsDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScImportOptionsDlg_Impl, ScImportOptionsDlg)
+ virtual void GetImportOptions( ScImportOptions& rOptions ) const;
+};
+
+class AbstractScTextImportOptionsDlg_Impl : public AbstractScTextImportOptionsDlg
+{
+ DECL_ABSTDLG_BASE( AbstractScTextImportOptionsDlg_Impl, ScTextImportOptionsDlg)
+ virtual LanguageType GetLanguageType() const;
+ virtual bool IsDateConversionSet() const;
+};
+
+//add for ScAttrDlg , ScHFEditDlg, ScStyleDlg, ScSubTotalDlg, ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg
+class AbstractTabDialog_Impl : public SfxAbstractTabDialog
+{
+ DECL_ABSTDLG_BASE( AbstractTabDialog_Impl,SfxTabDialog )
+ virtual void SetCurPageId( USHORT nId );
+ virtual const SfxItemSet* GetOutputItemSet() const;
+ virtual const USHORT* GetInputRanges( const SfxItemPool& pItem );
+ virtual void SetInputSet( const SfxItemSet* pInSet );
+ //From class Window.
+ virtual void SetText( const XubString& rStr );
+ virtual String GetText() const;
+};
+#if ENABLE_LAYOUT
+namespace layout
+{
+//add for ScAttrDlg , ScHFEditDlg, ScStyleDlg, ScSubTotalDlg, ScCharDlg, ScParagraphDlg, ScValidationDlg, ScSortDlg
+class AbstractTabDialog_Impl : public SfxAbstractTabDialog
+{
+ DECL_ABSTDLG_BASE( AbstractTabDialog_Impl,SfxTabDialog )
+ virtual void SetCurPageId( USHORT nId );
+ virtual const SfxItemSet* GetOutputItemSet() const;
+ virtual const USHORT* GetInputRanges( const SfxItemPool& pItem );
+ virtual void SetInputSet( const SfxItemSet* pInSet );
+ //From class Window.
+ virtual void SetText( const XubString& rStr );
+ virtual String GetText() const;
+};
+} // end namespace layout
+#endif /* ENABLE_LAYOUT */
+//------------------------------------------------------------------------
+//AbstractDialogFactory_Impl implementations
+class ScAbstractDialogFactory_Impl : public ScAbstractDialogFactory
+{
+
+public:
+ virtual AbstractScImportAsciiDlg * CreateScImportAsciiDlg( Window* pParent, String aDatName, //add for ScImportAsciiDlg
+ SvStream* pInStream, int nId,
+ sal_Unicode cSep = '\t');
+
+ virtual AbstractScTextImportOptionsDlg * CreateScTextImportOptionsDlg( Window* pParent, int nId );
+
+ virtual AbstractScAutoFormatDlg * CreateScAutoFormatDlg( Window* pParent, //add for ScAutoFormatDlg
+ ScAutoFormat* pAutoFormat,
+ const ScAutoFormatData* pSelFormatData,
+ ScDocument* pDoc,
+ int nId);
+ virtual AbstractScColRowLabelDlg * CreateScColRowLabelDlg (Window* pParent, //add for ScColRowLabelDlg
+ int nId,
+ BOOL bCol = FALSE,
+ BOOL bRow = FALSE);
+
+ virtual VclAbstractDialog * CreateScColOrRowDlg( Window* pParent, //add for ScColOrRowDlg
+ const String& rStrTitle,
+ const String& rStrLabel,
+ int nId,
+ BOOL bColDefault = TRUE );
+
+ virtual VclAbstractDialog * CreateScSortWarningDlg( Window* pParent, const String& rExtendText, const String& rCurrentText, int nId );
+
+ virtual AbstractScDataPilotDatabaseDlg * CreateScDataPilotDatabaseDlg (Window* pParent ,int nId ); //add for ScDataPilotDatabaseDlg
+
+ virtual AbstractScDataPilotSourceTypeDlg * CreateScDataPilotSourceTypeDlg ( Window* pParent, BOOL bEnableExternal, int nId ) ; //add for ScDataPilotSourceTypeDlg
+
+ virtual AbstractScDataPilotServiceDlg * CreateScDataPilotServiceDlg( Window* pParent, //add for ScDataPilotServiceDlg
+ const com::sun::star::uno::Sequence<rtl::OUString>& rServices,
+ int nId );
+ virtual AbstractScDeleteCellDlg * CreateScDeleteCellDlg( Window* pParent, int nId,
+ BOOL bDisallowCellMove = FALSE ); //add for ScDeleteCellDlg
+
+ //for dataform
+ virtual AbstractScDataFormDlg * CreateScDataFormDlg( Window* pParent, int nId, ScTabViewShell* pTabViewShell); //add for ScDeleteCellDlg
+
+ virtual AbstractScDeleteContentsDlg * CreateScDeleteContentsDlg(Window* pParent,int nId, //add for ScDeleteContentsDlg
+ USHORT nCheckDefaults = 0 );
+
+ virtual AbstractScFillSeriesDlg * CreateScFillSeriesDlg( Window* pParent, //add for ScFillSeriesDlg
+ ScDocument& rDocument,
+ FillDir eFillDir,
+ FillCmd eFillCmd,
+ FillDateCmd eFillDateCmd,
+ String aStartStr,
+ double fStep,
+ double fMax,
+ USHORT nPossDir,
+ int nId);
+ virtual AbstractScGroupDlg * CreateAbstractScGroupDlg( Window* pParent, //add for ScGroupDlg
+ USHORT nResId,
+ int nId,
+ BOOL bUnGroup = FALSE,
+ BOOL bRows = TRUE );
+
+ virtual AbstractScInsertCellDlg * CreateScInsertCellDlg( Window* pParent, //add for ScInsertCellDlg
+ int nId,
+ BOOL bDisallowCellMove = FALSE );
+
+ virtual AbstractScInsertContentsDlg * CreateScInsertContentsDlg( Window* pParent, //add for ScInsertContentsDlg
+ int nId,
+ USHORT nCheckDefaults = 0,
+ const String* pStrTitle = NULL );
+
+ virtual AbstractScInsertTableDlg * CreateScInsertTableDlg ( Window* pParent, ScViewData& rViewData, //add for ScInsertTableDlg
+ SCTAB nTabCount, bool bFromFile, int nId);
+
+ virtual AbstractScSelEntryDlg * CreateScSelEntryDlg ( Window* pParent, // add for ScSelEntryDlg
+ USHORT nResId,
+ const String& aTitle,
+ const String& aLbTitle,
+ List& aEntryList,
+ int nId );
+
+ virtual AbstractScLinkedAreaDlg * CreateScLinkedAreaDlg ( Window* pParent, //add for ScLinkedAreaDlg
+ int nId);
+
+ virtual AbstractScMetricInputDlg * CreateScMetricInputDlg ( Window* pParent, //add for ScMetricInputDlg
+ USHORT nResId, // Ableitung fuer jeden Dialog!
+ long nCurrent,
+ long nDefault,
+ int nId ,
+ FieldUnit eFUnit = FUNIT_MM,
+ USHORT nDecimals = 2,
+ long nMaximum = 1000,
+ long nMinimum = 0,
+ long nFirst = 1,
+ long nLast = 100 );
+
+ virtual AbstractScMoveTableDlg * CreateScMoveTableDlg( Window* pParent, int nId ); //add for ScMoveTableDlg
+ virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, USHORT nFlags, int nId ); //add for ScNameCreateDlg
+
+ virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
+ int nId , BOOL bInsList=TRUE );
+
+ virtual AbstractScPivotFilterDlg * CreateScPivotFilterDlg ( Window* pParent, //add for ScPivotFilterDlg
+ const SfxItemSet& rArgSet, USHORT nSourceTab , int nId );
+
+ virtual AbstractScDPFunctionDlg * CreateScDPFunctionDlg( Window* pParent, int nId,
+ const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData,
+ const ScDPFuncData& rFuncData );
+
+ virtual AbstractScDPSubtotalDlg * CreateScDPSubtotalDlg( Window* pParent, int nId,
+ ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData,
+ const ScDPFuncData& rFuncData,
+ const ScDPNameVec& rDataFields,
+ bool bEnableLayout );
+
+ virtual AbstractScDPNumGroupDlg * CreateScDPNumGroupDlg( Window* pParent,
+ int nId,
+ const ScDPNumGroupInfo& rInfo );
+
+ virtual AbstractScDPDateGroupDlg * CreateScDPDateGroupDlg( Window* pParent,
+ int nId,
+ const ScDPNumGroupInfo& rInfo,
+ sal_Int32 nDatePart,
+ const Date& rNullDate );
+
+ virtual AbstractScDPShowDetailDlg * CreateScDPShowDetailDlg( Window* pParent, int nId,
+ ScDPObject& rDPObj,
+ USHORT nOrient );
+
+ virtual AbstractScNewScenarioDlg * CreateScNewScenarioDlg ( Window* pParent, const String& rName, //add for ScNewScenarioDlg
+ int nId,
+ BOOL bEdit = FALSE, BOOL bSheetProtected = FALSE );
+ virtual AbstractScShowTabDlg * CreateScShowTabDlg ( Window* pParent, int nId ); //add for ScShowTabDlg
+
+ virtual AbstractScStringInputDlg * CreateScStringInputDlg ( Window* pParent, //add for ScStringInputDlg
+ const String& rTitle,
+ const String& rEditTitle,
+ const String& rDefault,
+ ULONG nHelpId ,
+ int nId );
+
+ virtual AbstractScTabBgColorDlg * CreateScTabBgColorDlg ( Window* pParent, //add for ScStringInputDlg
+ const String& rTitle, //Dialog Title
+ const String& rTabBgColorNoColorText, //Label for no tab color
+ const Color& rDefaultColor, //Currently selected Color
+ ULONG nHelpId ,
+ int nId );
+
+ virtual AbstractScImportOptionsDlg * CreateScImportOptionsDlg ( Window* pParent, //add for ScImportOptionsDlg
+ int nId,
+ BOOL bAscii = TRUE,
+ const ScImportOptions* pOptions = NULL,
+ const String* pStrTitle = NULL,
+ BOOL bMultiByte = FALSE,
+ BOOL bOnlyDbtoolsEncodings = FALSE,
+ BOOL bImport = TRUE );
+ virtual SfxAbstractTabDialog * CreateScAttrDlg( SfxViewFrame* pFrame, //add for ScAttrDlg
+ Window* pParent,
+ const SfxItemSet* pCellAttrs,
+ int nId);
+
+ virtual SfxAbstractTabDialog * CreateScHFEditDlg( SfxViewFrame* pFrame, //add for ScHFEditDlg
+ Window* pParent,
+ const SfxItemSet& rCoreSet,
+ const String& rPageStyle,
+ int nId,
+ USHORT nResId = RID_SCDLG_HFEDIT );
+
+ virtual SfxAbstractTabDialog * CreateScStyleDlg( Window* pParent,//add for ScStyleDlg
+ SfxStyleSheetBase& rStyleBase,
+ USHORT nRscId,
+ int nId);
+
+ virtual SfxAbstractTabDialog * CreateScSubTotalDlg( Window* pParent, //add for ScSubTotalDlg
+ const SfxItemSet* pArgSet,
+ int nId);
+ virtual SfxAbstractTabDialog * CreateScCharDlg( Window* pParent, const SfxItemSet* pAttr,//add for ScCharDlg
+ const SfxObjectShell* pDocShell, int nId );
+
+ virtual SfxAbstractTabDialog * CreateScParagraphDlg( Window* pParent, const SfxItemSet* pAttr ,//add for ScParagraphDlg
+ int nId );
+
+ virtual SfxAbstractTabDialog * CreateScValidationDlg( Window* pParent, //add for ScValidationDlg
+ const SfxItemSet* pArgSet,int nId, ScTabViewShell *pTabVwSh );
+
+ virtual SfxAbstractTabDialog * CreateScSortDlg( Window* pParent, //add for ScSortDlg
+ const SfxItemSet* pArgSet,int nId );
+ // For TabPage
+ virtual CreateTabPage GetTabPageCreatorFunc( USHORT nId );
+
+ virtual GetTabPageRanges GetTabPageRangesFunc( USHORT nId );
+
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/scuiexp.cxx b/sc/source/ui/attrdlg/scuiexp.cxx
new file mode 100644
index 000000000000..9f5dbc1dc3e8
--- /dev/null
+++ b/sc/source/ui/attrdlg/scuiexp.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "scdlgfact.hxx"
+#include "sal/types.h"
+
+namespace scui
+{
+ static ScAbstractDialogFactory_Impl* pFactory=NULL;
+ ScAbstractDialogFactory_Impl* GetFactory()
+ {
+ if ( !pFactory )
+ pFactory = new ScAbstractDialogFactory_Impl;
+ //if ( !pSwResMgr)
+ // ScDialogsResMgr::GetResMgr();
+ return pFactory;
+ }
+}
+
+extern "C"
+{
+ SAL_DLLPUBLIC_EXPORT ScAbstractDialogFactory* CreateDialogFactory()
+ {
+ return ::scui::GetFactory();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/attrdlg/tabpages.cxx b/sc/source/ui/attrdlg/tabpages.cxx
new file mode 100644
index 000000000000..ecc536c0ba6c
--- /dev/null
+++ b/sc/source/ui/attrdlg/tabpages.cxx
@@ -0,0 +1,253 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "global.hxx"
+#include "document.hxx"
+#include "attrib.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+#include "attrdlg.hrc"
+#include "tabpages.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pProtectionRanges[] =
+{
+ SID_SCATTR_PROTECTION,
+ SID_SCATTR_PROTECTION,
+ 0
+};
+
+//========================================================================
+// Zellschutz-Tabpage:
+//========================================================================
+
+ScTabPageProtection::ScTabPageProtection( Window* pParent,
+ const SfxItemSet& rCoreAttrs )
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_PROTECTION ),
+ rCoreAttrs ),
+ //
+ aFlProtect ( this, ScResId( FL_PROTECTION ) ),
+ aBtnHideCell ( this, ScResId( BTN_HIDE_ALL ) ),
+ aBtnProtect ( this, ScResId( BTN_PROTECTED ) ),
+ aBtnHideFormula ( this, ScResId( BTN_HIDE_FORMULAR ) ),
+ aTxtHint ( this, ScResId( FT_HINT ) ),
+ aFlPrint ( this, ScResId( FL_PRINT ) ),
+ aBtnHidePrint ( this, ScResId( BTN_HIDE_PRINT ) ),
+ aTxtHint2 ( this, ScResId( FT_HINT2 ) )
+{
+ // diese Page braucht ExchangeSupport
+ SetExchangeSupport();
+
+ // States werden in Reset gesetzt
+ bTriEnabled = bDontCare = bProtect = bHideForm = bHideCell = bHidePrint = FALSE;
+
+ aBtnProtect.SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
+ aBtnHideCell.SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
+ aBtnHideFormula.SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
+ aBtnHidePrint.SetClickHdl( LINK( this, ScTabPageProtection, ButtonClickHdl ) );
+
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTabPageProtection::~ScTabPageProtection()
+{
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTabPageProtection::GetRanges()
+{
+ return pProtectionRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTabPageProtection::Create( Window* pParent,
+ const SfxItemSet& rAttrSet )
+{
+ return ( new ScTabPageProtection( pParent, rAttrSet ) );
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScTabPageProtection::Reset( const SfxItemSet& rCoreAttrs )
+{
+ // Variablen initialisieren
+
+ USHORT nWhich = GetWhich( SID_SCATTR_PROTECTION );
+ const ScProtectionAttr* pProtAttr = NULL;
+ SfxItemState eItemState = rCoreAttrs.GetItemState( nWhich, FALSE,
+ (const SfxPoolItem**)&pProtAttr );
+
+ // handelt es sich um ein Default-Item?
+ if ( eItemState == SFX_ITEM_DEFAULT )
+ pProtAttr = (const ScProtectionAttr*)&(rCoreAttrs.Get(nWhich));
+ // bei SFX_ITEM_DONTCARE auf 0 lassen
+
+ bTriEnabled = ( pProtAttr == NULL ); // TriState, wenn DontCare
+ bDontCare = bTriEnabled;
+ if (bTriEnabled)
+ {
+ // Defaults, die erscheinen wenn ein TriState weggeklickt wird:
+ // (weil alles zusammen ein Attribut ist, kann auch nur alles zusammen
+ // auf DontCare stehen - #38543#)
+ bProtect = TRUE;
+ bHideForm = bHideCell = bHidePrint = FALSE;
+ }
+ else
+ {
+ bProtect = pProtAttr->GetProtection();
+ bHideCell = pProtAttr->GetHideCell();
+ bHideForm = pProtAttr->GetHideFormula();
+ bHidePrint = pProtAttr->GetHidePrint();
+ }
+
+ // Controls initialisieren
+
+ aBtnProtect .EnableTriState( bTriEnabled );
+ aBtnHideCell .EnableTriState( bTriEnabled );
+ aBtnHideFormula .EnableTriState( bTriEnabled );
+ aBtnHidePrint .EnableTriState( bTriEnabled );
+
+ UpdateButtons();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTabPageProtection::FillItemSet( SfxItemSet& rCoreAttrs )
+{
+ BOOL bAttrsChanged = FALSE;
+ USHORT nWhich = GetWhich( SID_SCATTR_PROTECTION );
+ const SfxPoolItem* pOldItem = GetOldItem( rCoreAttrs, SID_SCATTR_PROTECTION );
+ const SfxItemSet& rOldSet = GetItemSet();
+ SfxItemState eItemState = rOldSet.GetItemState( nWhich, FALSE );
+ ScProtectionAttr aProtAttr;
+
+ if ( !bDontCare )
+ {
+ aProtAttr.SetProtection( bProtect );
+ aProtAttr.SetHideCell( bHideCell );
+ aProtAttr.SetHideFormula( bHideForm );
+ aProtAttr.SetHidePrint( bHidePrint );
+
+ if ( bTriEnabled )
+ bAttrsChanged = TRUE; // DontCare -> richtiger Wert
+ else
+ bAttrsChanged = !pOldItem || !( aProtAttr == *(const ScProtectionAttr*)pOldItem );
+ }
+
+ //--------------------------------------------------
+
+ if ( bAttrsChanged )
+ rCoreAttrs.Put( aProtAttr );
+ else if ( eItemState == SFX_ITEM_DEFAULT )
+ rCoreAttrs.ClearItem( nWhich );
+
+ return bAttrsChanged;
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScTabPageProtection::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return LEAVE_PAGE;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageProtection, ButtonClickHdl, TriStateBox*, pBox )
+{
+ TriState eState = pBox->GetState();
+ if ( eState == STATE_DONTKNOW )
+ bDontCare = TRUE; // alles zusammen auf DontCare
+ else
+ {
+ bDontCare = FALSE; // DontCare ueberall aus
+ BOOL bOn = ( eState == STATE_CHECK ); // ausgewaehlter Wert
+
+ if ( pBox == &aBtnProtect )
+ bProtect = bOn;
+ else if ( pBox == &aBtnHideCell )
+ bHideCell = bOn;
+ else if ( pBox == &aBtnHideFormula )
+ bHideForm = bOn;
+ else if ( pBox == &aBtnHidePrint )
+ bHidePrint = bOn;
+ else
+ {
+ DBG_ERRORFILE("falscher Button");
+ }
+ }
+
+ UpdateButtons(); // TriState und Enable-Logik
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+void ScTabPageProtection::UpdateButtons()
+{
+ if ( bDontCare )
+ {
+ aBtnProtect.SetState( STATE_DONTKNOW );
+ aBtnHideCell.SetState( STATE_DONTKNOW );
+ aBtnHideFormula.SetState( STATE_DONTKNOW );
+ aBtnHidePrint.SetState( STATE_DONTKNOW );
+ }
+ else
+ {
+ aBtnProtect.SetState( bProtect ? STATE_CHECK : STATE_NOCHECK );
+ aBtnHideCell.SetState( bHideCell ? STATE_CHECK : STATE_NOCHECK );
+ aBtnHideFormula.SetState( bHideForm ? STATE_CHECK : STATE_NOCHECK );
+ aBtnHidePrint.SetState( bHidePrint ? STATE_CHECK : STATE_NOCHECK );
+ }
+
+ BOOL bEnable = ( aBtnHideCell.GetState() != STATE_CHECK );
+ {
+ aBtnProtect.Enable( bEnable );
+ aBtnHideFormula.Enable( bEnable );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/cbuttonw.cxx b/sc/source/ui/cctrl/cbuttonw.cxx
new file mode 100644
index 000000000000..d6e072901a6e
--- /dev/null
+++ b/sc/source/ui/cctrl/cbuttonw.cxx
@@ -0,0 +1,180 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <vcl/outdev.hxx>
+#include <vcl/window.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/svapp.hxx>
+#include "cbutton.hxx"
+
+//========================================================================
+// class ScDDComboBoxButton
+//========================================================================
+
+ScDDComboBoxButton::ScDDComboBoxButton( OutputDevice* pOutputDevice )
+ : pOut( pOutputDevice )
+{
+ SetOptSizePixel();
+}
+
+// -------------------------------------------------------------------------
+
+__EXPORT ScDDComboBoxButton::~ScDDComboBoxButton()
+{
+}
+
+// -------------------------------------------------------------------------
+
+void ScDDComboBoxButton::SetOutputDevice( OutputDevice* pOutputDevice )
+{
+ pOut = pOutputDevice;
+}
+
+// -------------------------------------------------------------------------
+
+void ScDDComboBoxButton::SetOptSizePixel()
+{
+ aBtnSize = pOut->LogicToPixel( Size(0,11), MAP_APPFONT );
+ //aBtnSize.Width() = GetSystemMetrics( SM_CXVSCROLL ) - 1; // Win SDK-Funktion
+ aBtnSize.Width() = pOut->GetSettings().GetStyleSettings().GetScrollBarSize();
+}
+
+// -------------------------------------------------------------------------
+
+void ScDDComboBoxButton::Draw( const Point& rAt,
+ const Size& rSize,
+ BOOL bState,
+ BOOL bBtnIn /* = FALSE */ )
+{
+ if ( rSize.Width() == 0 || rSize.Height() == 0 )
+ return; // #i43092# rectangle with size 0 would have RECT_EMPTY as end position
+
+ // save old state
+ BOOL bHadFill = pOut->IsFillColor();
+ Color aOldFill = pOut->GetFillColor();
+ BOOL bHadLine = pOut->IsLineColor();
+ Color aOldLine = pOut->GetLineColor();
+ BOOL bOldEnable = pOut->IsMapModeEnabled();
+
+ Size aLogPix( 1, 1 );
+ Rectangle aBtnRect( rAt, rSize );
+ Rectangle aInnerRect = aBtnRect;
+
+ pOut->EnableMapMode( FALSE );
+
+ DecorationView aDecoView( pOut);
+
+ USHORT nButtonStyle = BUTTON_DRAW_DEFAULT;
+ if( bBtnIn ) // gedrueckt?
+ {
+ nButtonStyle = BUTTON_DRAW_PRESSED;
+ }
+
+ aInnerRect=aDecoView.DrawButton( aBtnRect, nButtonStyle );
+
+
+ aInnerRect.Left() += 1;
+ aInnerRect.Top() += 1;
+ aInnerRect.Right() -= 1;
+ aInnerRect.Bottom() -= 1;
+
+ Size aInnerSize = aInnerRect.GetSize();
+ Point aInnerCenter = aInnerRect.Center();
+
+ aInnerRect.Top() = aInnerCenter.Y() - (aInnerSize.Width()>>1);
+ aInnerRect.Bottom()= aInnerCenter.Y() + (aInnerSize.Width()>>1);
+
+ ImpDrawArrow( aInnerRect, bState );
+
+
+ // restore old state
+ pOut->EnableMapMode( bOldEnable );
+ if (bHadLine)
+ pOut->SetLineColor(aOldLine);
+ else
+ pOut->SetLineColor();
+ if (bHadFill)
+ pOut->SetFillColor(aOldFill);
+ else
+ pOut->SetFillColor();
+}
+
+//------------------------------------------------------------------------
+
+void ScDDComboBoxButton::ImpDrawArrow( const Rectangle& rRect,
+ BOOL bState )
+{
+ // no need to save old line and fill color here (is restored after the call)
+
+ Rectangle aPixRect = rRect;
+ Point aCenter = aPixRect.Center();
+ Size aSize = aPixRect.GetSize();
+
+ Size aSize3;
+ aSize3.Width() = aSize.Width() >> 1;
+ aSize3.Height() = aSize.Height() >> 1;
+
+ Size aSize4;
+ aSize4.Width() = aSize.Width() >> 2;
+ aSize4.Height() = aSize.Height() >> 2;
+
+ Rectangle aTempRect = aPixRect;
+
+ const StyleSettings& rSett = Application::GetSettings().GetStyleSettings();
+ Color aColor( bState ? COL_LIGHTBLUE : rSett.GetButtonTextColor().GetColor() );
+ pOut->SetFillColor( aColor );
+ pOut->SetLineColor( aColor );
+
+ aTempRect.Left() = aCenter.X() - aSize4.Width();
+ aTempRect.Right() = aCenter.X() + aSize4.Width();
+ aTempRect.Top() = aCenter.Y() - aSize3.Height();
+ aTempRect.Bottom() = aCenter.Y() - 1;
+
+ pOut->DrawRect( aTempRect );
+
+ Point aPos1( aCenter.X()-aSize3.Width(), aCenter.Y() );
+ Point aPos2( aCenter.X()+aSize3.Width(), aCenter.Y() );
+ while( aPos1.X() <= aPos2.X() )
+ {
+ pOut->DrawLine( aPos1, aPos2 );
+ aPos1.X()++; aPos2.X()--;
+ aPos1.Y()++; aPos2.Y()++;
+ }
+
+ pOut->DrawLine( Point( aCenter.X() - aSize3.Width(), aPos1.Y()+1 ),
+ Point( aCenter.X() + aSize3.Width(), aPos1.Y()+1 ) );
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx
new file mode 100644
index 000000000000..8fc8dcb1ed44
--- /dev/null
+++ b/sc/source/ui/cctrl/dpcontrol.cxx
@@ -0,0 +1,1424 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "dpcontrol.hxx"
+#include "dpcontrol.hrc"
+
+#include <vcl/outdev.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/wintypes.hxx>
+#include <vcl/decoview.hxx>
+#include "strload.hxx"
+#include "global.hxx"
+#include "scitems.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "patattr.hxx"
+
+#include "AccessibleFilterMenu.hxx"
+#include "AccessibleFilterTopWindow.hxx"
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::accessibility::XAccessible;
+using ::com::sun::star::accessibility::XAccessibleContext;
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+using ::std::vector;
+using ::std::hash_map;
+using ::std::auto_ptr;
+
+ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY, ScDocument* pDoc) :
+ mpDoc(pDoc),
+ mpOutDev(pOutDev),
+ mpStyle(pStyle),
+ mbBaseButton(true),
+ mbPopupButton(false),
+ mbHasHiddenMember(false),
+ mbPopupPressed(false),
+ mbPopupLeft(false)
+{
+ if (pZoomX)
+ maZoomX = *pZoomX;
+ else
+ maZoomX = Fraction(1, 1);
+
+ if (pZoomY)
+ maZoomY = *pZoomY;
+ else
+ maZoomY = Fraction(1, 1);
+}
+
+ScDPFieldButton::~ScDPFieldButton()
+{
+}
+
+void ScDPFieldButton::setText(const OUString& rText)
+{
+ maText = rText;
+}
+
+void ScDPFieldButton::setBoundingBox(const Point& rPos, const Size& rSize, bool bLayoutRTL)
+{
+ maPos = rPos;
+ maSize = rSize;
+ if (bLayoutRTL)
+ {
+ // rPos is the logical-left position, adjust maPos to visual-left (inside the cell border)
+ maPos.X() -= maSize.Width() - 1;
+ }
+}
+
+void ScDPFieldButton::setDrawBaseButton(bool b)
+{
+ mbBaseButton = b;
+}
+
+void ScDPFieldButton::setDrawPopupButton(bool b)
+{
+ mbPopupButton = b;
+}
+
+void ScDPFieldButton::setHasHiddenMember(bool b)
+{
+ mbHasHiddenMember = b;
+}
+
+void ScDPFieldButton::setPopupPressed(bool b)
+{
+ mbPopupPressed = b;
+}
+
+void ScDPFieldButton::setPopupLeft(bool b)
+{
+ mbPopupLeft = b;
+}
+
+void ScDPFieldButton::draw()
+{
+ const long nMargin = 2;
+ bool bOldMapEnablaed = mpOutDev->IsMapModeEnabled();
+ mpOutDev->EnableMapMode(false);
+
+ if (mbBaseButton)
+ {
+ // Background
+ Rectangle aRect(maPos, maSize);
+ mpOutDev->SetLineColor(mpStyle->GetFaceColor());
+ mpOutDev->SetFillColor(mpStyle->GetFaceColor());
+ mpOutDev->DrawRect(aRect);
+
+ // Border lines
+ mpOutDev->SetLineColor(mpStyle->GetLightColor());
+ mpOutDev->DrawLine(Point(maPos), Point(maPos.X(), maPos.Y()+maSize.Height()-1));
+ mpOutDev->DrawLine(Point(maPos), Point(maPos.X()+maSize.Width()-1, maPos.Y()));
+
+ mpOutDev->SetLineColor(mpStyle->GetShadowColor());
+ mpOutDev->DrawLine(Point(maPos.X(), maPos.Y()+maSize.Height()-1),
+ Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1));
+ mpOutDev->DrawLine(Point(maPos.X()+maSize.Width()-1, maPos.Y()),
+ Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1));
+
+ // Field name.
+ // Get the font and size the same way as in scenario selection (lcl_DrawOneFrame in gridwin4.cxx)
+ Font aTextFont( mpStyle->GetAppFont() );
+ if ( mpDoc )
+ {
+ // use ScPatternAttr::GetFont only for font size
+ Font aAttrFont;
+ static_cast<const ScPatternAttr&>(mpDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).
+ GetFont( aAttrFont, SC_AUTOCOL_BLACK, mpOutDev, &maZoomY );
+ aTextFont.SetSize( aAttrFont.GetSize() );
+ }
+ mpOutDev->SetFont(aTextFont);
+ mpOutDev->SetTextColor(mpStyle->GetButtonTextColor());
+
+ Point aTextPos = maPos;
+ long nTHeight = mpOutDev->GetTextHeight();
+ aTextPos.setX(maPos.getX() + nMargin);
+ aTextPos.setY(maPos.getY() + (maSize.Height()-nTHeight)/2);
+
+ mpOutDev->Push(PUSH_CLIPREGION);
+ mpOutDev->IntersectClipRegion(aRect);
+ mpOutDev->DrawText(aTextPos, maText);
+ mpOutDev->Pop();
+ }
+
+ if (mbPopupButton)
+ drawPopupButton();
+
+ mpOutDev->EnableMapMode(bOldMapEnablaed);
+}
+
+void ScDPFieldButton::getPopupBoundingBox(Point& rPos, Size& rSize) const
+{
+ long nW = maSize.getWidth() / 2;
+ long nH = maSize.getHeight();
+ if (nW > 18)
+ nW = 18;
+ if (nH > 18)
+ nH = 18;
+
+ // #i114944# AutoFilter button is left-aligned in RTL.
+ // DataPilot button is always right-aligned for now, so text output isn't affected.
+ if (mbPopupLeft)
+ rPos.setX(maPos.getX());
+ else
+ rPos.setX(maPos.getX() + maSize.getWidth() - nW);
+ rPos.setY(maPos.getY() + maSize.getHeight() - nH);
+ rSize.setWidth(nW);
+ rSize.setHeight(nH);
+}
+
+void ScDPFieldButton::drawPopupButton()
+{
+ Point aPos;
+ Size aSize;
+ getPopupBoundingBox(aPos, aSize);
+
+ // Background & outer black border
+ mpOutDev->SetLineColor(COL_BLACK);
+ mpOutDev->SetFillColor(mpStyle->GetFaceColor());
+ mpOutDev->DrawRect(Rectangle(aPos, aSize));
+
+ if (!mbPopupPressed)
+ {
+ // border lines
+ mpOutDev->SetLineColor(mpStyle->GetLightColor());
+ mpOutDev->DrawLine(Point(aPos.X()+1, aPos.Y()+1), Point(aPos.X()+1, aPos.Y()+aSize.Height()-2));
+ mpOutDev->DrawLine(Point(aPos.X()+1, aPos.Y()+1), Point(aPos.X()+aSize.Width()-2, aPos.Y()+1));
+
+ mpOutDev->SetLineColor(mpStyle->GetShadowColor());
+ mpOutDev->DrawLine(Point(aPos.X()+1, aPos.Y()+aSize.Height()-2),
+ Point(aPos.X()+aSize.Width()-2, aPos.Y()+aSize.Height()-2));
+ mpOutDev->DrawLine(Point(aPos.X()+aSize.Width()-2, aPos.Y()+1),
+ Point(aPos.X()+aSize.Width()-2, aPos.Y()+aSize.Height()-2));
+ }
+
+ // the arrowhead
+ Color aArrowColor = mbHasHiddenMember ? mpStyle->GetHighlightLinkColor() : mpStyle->GetButtonTextColor();
+ mpOutDev->SetLineColor(aArrowColor);
+ mpOutDev->SetFillColor(aArrowColor);
+ Point aCenter(aPos.X() + (aSize.Width() >> 1), aPos.Y() + (aSize.Height() >> 1));
+ Point aPos1, aPos2;
+ aPos1.X() = aCenter.X() - 4;
+ aPos2.X() = aCenter.X() + 4;
+ aPos1.Y() = aCenter.Y() - 3;
+ aPos2.Y() = aCenter.Y() - 3;
+
+ if (mbPopupPressed)
+ {
+ aPos1.X() += 1;
+ aPos2.X() += 1;
+ aPos1.Y() += 1;
+ aPos2.Y() += 1;
+ }
+
+ do
+ {
+ ++aPos1.X();
+ --aPos2.X();
+ ++aPos1.Y();
+ ++aPos2.Y();
+ mpOutDev->DrawLine(aPos1, aPos2);
+ }
+ while (aPos1 != aPos2);
+
+ if (mbHasHiddenMember)
+ {
+ // tiny little box to display in presence of hidden member(s).
+ Point aBoxPos(aPos.X() + aSize.Width() - 5, aPos.Y() + aSize.Height() - 5);
+ if (mbPopupPressed)
+ {
+ aBoxPos.X() += 1;
+ aBoxPos.Y() += 1;
+ }
+ Size aBoxSize(3, 3);
+ mpOutDev->DrawRect(Rectangle(aBoxPos, aBoxSize));
+ }
+}
+
+// ============================================================================
+
+ScMenuFloatingWindow::MenuItemData::MenuItemData() :
+ mbEnabled(true),
+ mpAction(static_cast<ScDPFieldPopupWindow::Action*>(NULL)),
+ mpSubMenuWin(static_cast<ScMenuFloatingWindow*>(NULL))
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScMenuFloatingWindow::SubMenuItemData::SubMenuItemData(ScMenuFloatingWindow* pParent) :
+ mpSubMenu(NULL),
+ mnMenuPos(MENU_NOT_SELECTED),
+ mpParent(pParent)
+{
+ maTimer.SetTimeoutHdl( LINK(this, ScMenuFloatingWindow::SubMenuItemData, TimeoutHdl) );
+ maTimer.SetTimeout(mpParent->GetSettings().GetMouseSettings().GetMenuDelay());
+}
+
+void ScMenuFloatingWindow::SubMenuItemData::reset()
+{
+ mpSubMenu = NULL;
+ mnMenuPos = MENU_NOT_SELECTED;
+ maTimer.Stop();
+}
+
+IMPL_LINK( ScMenuFloatingWindow::SubMenuItemData, TimeoutHdl, void*, EMPTYARG )
+{
+ mpParent->handleMenuTimeout(this);
+ return 0;
+}
+
+// ----------------------------------------------------------------------------
+
+size_t ScMenuFloatingWindow::MENU_NOT_SELECTED = 999;
+
+ScMenuFloatingWindow::ScMenuFloatingWindow(Window* pParent, ScDocument* pDoc, USHORT nMenuStackLevel) :
+ PopupMenuFloatingWindow(pParent),
+ maOpenTimer(this),
+ maCloseTimer(this),
+ maName(RTL_CONSTASCII_USTRINGPARAM("ScMenuFloatingWindow")),
+ mnSelectedMenu(MENU_NOT_SELECTED),
+ mnClickedMenu(MENU_NOT_SELECTED),
+ mpDoc(pDoc),
+ mpParentMenu(dynamic_cast<ScMenuFloatingWindow*>(pParent)),
+ mpActiveSubMenu(NULL)
+{
+ SetMenuStackLevel(nMenuStackLevel);
+
+ // TODO: How do we get the right font to use here ?
+ const sal_uInt16 nPopupFontHeight = 12;
+ const StyleSettings& rStyle = GetSettings().GetStyleSettings();
+ maLabelFont = rStyle.GetLabelFont();
+ maLabelFont.SetHeight(nPopupFontHeight);
+ SetFont(maLabelFont);
+
+ SetText( OUString(RTL_CONSTASCII_USTRINGPARAM("ScMenuFloatingWindow")) );
+ SetPopupModeEndHdl( LINK(this, ScMenuFloatingWindow, PopupEndHdl) );
+}
+
+ScMenuFloatingWindow::~ScMenuFloatingWindow()
+{
+ EndPopupMode();
+}
+
+void ScMenuFloatingWindow::MouseMove(const MouseEvent& rMEvt)
+{
+ const Point& rPos = rMEvt.GetPosPixel();
+ size_t nSelectedMenu = getEnclosingMenuItem(rPos);
+ setSelectedMenuItem(nSelectedMenu, true, false);
+
+ Window::MouseMove(rMEvt);
+}
+
+void ScMenuFloatingWindow::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ const Point& rPos = rMEvt.GetPosPixel();
+ mnClickedMenu = getEnclosingMenuItem(rPos);
+ Window::MouseButtonDown(rMEvt);
+}
+
+void ScMenuFloatingWindow::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ executeMenuItem(mnClickedMenu);
+ mnClickedMenu = MENU_NOT_SELECTED;
+ Window::MouseButtonUp(rMEvt);
+}
+
+void ScMenuFloatingWindow::KeyInput(const KeyEvent& rKEvt)
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ bool bHandled = true;
+ size_t nSelectedMenu = mnSelectedMenu;
+ size_t nLastMenuPos = maMenuItems.size() - 1;
+ switch (rKeyCode.GetCode())
+ {
+ case KEY_UP:
+ if (nSelectedMenu == MENU_NOT_SELECTED || nSelectedMenu == 0)
+ nSelectedMenu = nLastMenuPos;
+ else
+ --nSelectedMenu;
+ setSelectedMenuItem(nSelectedMenu, false, false);
+ break;
+ case KEY_DOWN:
+ if (nSelectedMenu == MENU_NOT_SELECTED || nSelectedMenu == nLastMenuPos)
+ nSelectedMenu = 0;
+ else
+ ++nSelectedMenu;
+ setSelectedMenuItem(nSelectedMenu, false, false);
+ break;
+ case KEY_LEFT:
+ if (mpParentMenu)
+ mpParentMenu->endSubMenu(this);
+ break;
+ case KEY_RIGHT:
+ {
+ if (mnSelectedMenu >= maMenuItems.size() || mnSelectedMenu == MENU_NOT_SELECTED)
+ break;
+
+ const MenuItemData& rMenu = maMenuItems[mnSelectedMenu];
+ if (!rMenu.mbEnabled || !rMenu.mpSubMenuWin)
+ break;
+
+ maOpenTimer.mnMenuPos = mnSelectedMenu;
+ maOpenTimer.mpSubMenu = rMenu.mpSubMenuWin.get();
+ launchSubMenu(true);
+ }
+ break;
+ case KEY_RETURN:
+ if (nSelectedMenu != MENU_NOT_SELECTED)
+ executeMenuItem(nSelectedMenu);
+ break;
+ default:
+ bHandled = false;
+ }
+
+ if (!bHandled)
+ Window::KeyInput(rKEvt);
+}
+
+void ScMenuFloatingWindow::Paint(const Rectangle& /*rRect*/)
+{
+ const StyleSettings& rStyle = GetSettings().GetStyleSettings();
+ Color aBackColor = rStyle.GetMenuColor();
+ Color aBorderColor = rStyle.GetShadowColor();
+
+ Rectangle aCtrlRect(Point(0, 0), GetOutputSizePixel());
+
+ // Window background
+ bool bNativeDrawn = true;
+ if (IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
+ {
+ SetClipRegion();
+ bNativeDrawn = DrawNativeControl(
+ CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, aCtrlRect, CTRL_STATE_ENABLED,
+ ImplControlValue(), OUString());
+ }
+ else
+ bNativeDrawn = false;
+
+ if (!bNativeDrawn)
+ {
+ SetFillColor(aBackColor);
+ SetLineColor(aBorderColor);
+ DrawRect(aCtrlRect);
+ }
+
+ // Menu items
+ SetTextColor(rStyle.GetMenuTextColor());
+ drawAllMenuItems();
+}
+
+Reference<XAccessible> ScMenuFloatingWindow::CreateAccessible()
+{
+ if (!mxAccessible.is())
+ {
+ Reference<XAccessible> xAccParent = mpParentMenu ?
+ mpParentMenu->GetAccessible() : GetAccessibleParentWindow()->GetAccessible();
+
+ mxAccessible.set(new ScAccessibleFilterMenu(xAccParent, this, maName, 999, getDoc()));
+ ScAccessibleFilterMenu* p = static_cast<ScAccessibleFilterMenu*>(
+ mxAccessible.get());
+
+ vector<MenuItemData>::const_iterator itr, itrBeg = maMenuItems.begin(), itrEnd = maMenuItems.end();
+ for (itr = itrBeg; itr != itrEnd; ++itr)
+ {
+ size_t nPos = ::std::distance(itrBeg, itr);
+ p->appendMenuItem(itr->maText, itr->mbEnabled, nPos);
+ }
+ }
+
+ return mxAccessible;
+}
+
+void ScMenuFloatingWindow::addMenuItem(const OUString& rText, bool bEnabled, Action* pAction)
+{
+ MenuItemData aItem;
+ aItem.maText = rText;
+ aItem.mbEnabled = bEnabled;
+ aItem.mpAction.reset(pAction);
+ maMenuItems.push_back(aItem);
+}
+
+ScMenuFloatingWindow* ScMenuFloatingWindow::addSubMenuItem(const OUString& rText, bool bEnabled)
+{
+ MenuItemData aItem;
+ aItem.maText = rText;
+ aItem.mbEnabled = bEnabled;
+ aItem.mpSubMenuWin.reset(new ScMenuFloatingWindow(this, mpDoc, GetMenuStackLevel()+1));
+ aItem.mpSubMenuWin->setName(rText);
+ maMenuItems.push_back(aItem);
+ return aItem.mpSubMenuWin.get();
+}
+
+void ScMenuFloatingWindow::drawMenuItem(size_t nPos)
+{
+ if (nPos >= maMenuItems.size())
+ return;
+
+ Point aPos;
+ Size aSize;
+ getMenuItemPosSize(nPos, aPos, aSize);
+
+ DecorationView aDecoView(this);
+ long nXOffset = 5;
+ long nYOffset = (aSize.Height() - maLabelFont.GetHeight())/2;
+ DrawCtrlText(Point(aPos.X()+nXOffset, aPos.Y() + nYOffset), maMenuItems[nPos].maText, 0, STRING_LEN,
+ maMenuItems[nPos].mbEnabled ? TEXT_DRAW_MNEMONIC : TEXT_DRAW_DISABLE);
+
+ if (maMenuItems[nPos].mpSubMenuWin)
+ {
+ long nFontHeight = maLabelFont.GetHeight();
+ Point aMarkerPos = aPos;
+ aMarkerPos.Y() += aSize.Height()/2 - nFontHeight/4 + 1;
+ aMarkerPos.X() += aSize.Width() - nFontHeight + nFontHeight/4;
+ Size aMarkerSize(nFontHeight/2, nFontHeight/2);
+ aDecoView.DrawSymbol(Rectangle(aMarkerPos, aMarkerSize),
+ SYMBOL_SPIN_RIGHT, GetTextColor(), 0);
+ }
+}
+
+void ScMenuFloatingWindow::drawAllMenuItems()
+{
+ size_t n = maMenuItems.size();
+ for (size_t i = 0; i < n; ++i)
+ highlightMenuItem(i, i == mnSelectedMenu);
+}
+
+const Font& ScMenuFloatingWindow::getLabelFont() const
+{
+ return maLabelFont;
+}
+
+void ScMenuFloatingWindow::executeMenuItem(size_t nPos)
+{
+ if (nPos >= maMenuItems.size())
+ return;
+
+ if (!maMenuItems[nPos].mpAction)
+ // no action is defined.
+ return;
+
+ maMenuItems[nPos].mpAction->execute();
+ terminateAllPopupMenus();
+}
+
+void ScMenuFloatingWindow::setSelectedMenuItem(size_t nPos, bool bSubMenuTimer, bool bEnsureSubMenu)
+{
+ if (mnSelectedMenu == nPos)
+ // nothing to do.
+ return;
+
+ if (bEnsureSubMenu)
+ {
+ // Dismiss any child popup menu windows.
+ if (mnSelectedMenu < maMenuItems.size() &&
+ maMenuItems[mnSelectedMenu].mpSubMenuWin &&
+ maMenuItems[mnSelectedMenu].mpSubMenuWin->IsVisible())
+ {
+ maMenuItems[mnSelectedMenu].mpSubMenuWin->ensureSubMenuNotVisible();
+ }
+
+ // The popup is not visible, yet a menu item is selected. The request
+ // most likely comes from the accessible object. Make sure this
+ // window, as well as all its parent windows are visible.
+ if (!IsVisible() && mpParentMenu)
+ mpParentMenu->ensureSubMenuVisible(this);
+ }
+
+ selectMenuItem(mnSelectedMenu, false, bSubMenuTimer);
+ selectMenuItem(nPos, true, bSubMenuTimer);
+ mnSelectedMenu = nPos;
+
+ fireMenuHighlightedEvent();
+}
+
+size_t ScMenuFloatingWindow::getSelectedMenuItem() const
+{
+ return mnSelectedMenu;
+}
+
+void ScMenuFloatingWindow::handleMenuTimeout(SubMenuItemData* pTimer)
+{
+ if (pTimer == &maOpenTimer)
+ {
+ // Close any open submenu immediately.
+ if (maCloseTimer.mpSubMenu)
+ {
+ maCloseTimer.mpSubMenu->EndPopupMode();
+ maCloseTimer.mpSubMenu = NULL;
+ maCloseTimer.maTimer.Stop();
+ }
+
+ launchSubMenu(false);
+ }
+ else if (pTimer == &maCloseTimer)
+ {
+ // end submenu.
+ if (maCloseTimer.mpSubMenu)
+ {
+ maOpenTimer.mpSubMenu = NULL;
+
+ maCloseTimer.mpSubMenu->EndPopupMode();
+ maCloseTimer.mpSubMenu = NULL;
+
+ highlightMenuItem(maOpenTimer.mnMenuPos, false);
+ maOpenTimer.mnMenuPos = MENU_NOT_SELECTED;
+ }
+ }
+}
+
+void ScMenuFloatingWindow::queueLaunchSubMenu(size_t nPos, ScMenuFloatingWindow* pMenu)
+{
+ if (!pMenu)
+ return;
+
+ // Set the submenu on launch queue.
+ if (maOpenTimer.mpSubMenu)
+ {
+ if (maOpenTimer.mpSubMenu == pMenu)
+ {
+ if (pMenu == maCloseTimer.mpSubMenu)
+ maCloseTimer.reset();
+ return;
+ }
+
+ // new submenu is being requested.
+ queueCloseSubMenu();
+ }
+
+ maOpenTimer.mpSubMenu = pMenu;
+ maOpenTimer.mnMenuPos = nPos;
+ maOpenTimer.maTimer.Start();
+}
+
+void ScMenuFloatingWindow::queueCloseSubMenu()
+{
+ if (!maOpenTimer.mpSubMenu)
+ // There is no submenu to close.
+ return;
+
+ // Stop any submenu on queue for opening.
+ maOpenTimer.maTimer.Stop();
+
+ maCloseTimer.mpSubMenu = maOpenTimer.mpSubMenu;
+ maCloseTimer.mnMenuPos = maOpenTimer.mnMenuPos;
+ maCloseTimer.maTimer.Start();
+}
+
+void ScMenuFloatingWindow::launchSubMenu(bool bSetMenuPos)
+{
+ Point aPos;
+ Size aSize;
+ getMenuItemPosSize(maOpenTimer.mnMenuPos, aPos, aSize);
+ ScMenuFloatingWindow* pSubMenu = maOpenTimer.mpSubMenu;
+
+ if (!pSubMenu)
+ return;
+
+ sal_uInt32 nOldFlags = GetPopupModeFlags();
+ SetPopupModeFlags(nOldFlags | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE);
+ pSubMenu->resizeToFitMenuItems(); // set the size before launching the popup to get it positioned correctly.
+ pSubMenu->StartPopupMode(
+ Rectangle(aPos,aSize), (FLOATWIN_POPUPMODE_RIGHT | FLOATWIN_POPUPMODE_GRABFOCUS));
+ pSubMenu->AddPopupModeWindow(this);
+ if (bSetMenuPos)
+ pSubMenu->setSelectedMenuItem(0, false, false); // select menu item after the popup becomes fully visible.
+ SetPopupModeFlags(nOldFlags);
+}
+
+void ScMenuFloatingWindow::endSubMenu(ScMenuFloatingWindow* pSubMenu)
+{
+ if (!pSubMenu)
+ return;
+
+ pSubMenu->EndPopupMode();
+ maOpenTimer.reset();
+
+ size_t nMenuPos = getSubMenuPos(pSubMenu);
+ if (nMenuPos != MENU_NOT_SELECTED)
+ {
+ highlightMenuItem(nMenuPos, true);
+ mnSelectedMenu = nMenuPos;
+ fireMenuHighlightedEvent();
+ }
+}
+
+void ScMenuFloatingWindow::fillMenuItemsToAccessible(ScAccessibleFilterMenu* pAccMenu) const
+{
+ vector<MenuItemData>::const_iterator itr, itrBeg = maMenuItems.begin(), itrEnd = maMenuItems.end();
+ for (itr = itrBeg; itr != itrEnd; ++itr)
+ {
+ size_t nPos = ::std::distance(itrBeg, itr);
+ pAccMenu->appendMenuItem(itr->maText, itr->mbEnabled, nPos);
+ }
+}
+
+ScDocument* ScMenuFloatingWindow::getDoc()
+{
+ return mpDoc;
+}
+
+void ScMenuFloatingWindow::resizeToFitMenuItems()
+{
+ if (maMenuItems.empty())
+ return;
+
+ vector<MenuItemData>::const_iterator itr = maMenuItems.begin(), itrEnd = maMenuItems.end();
+ long nTextWidth = 0;
+ for (; itr != itrEnd; ++itr)
+ nTextWidth = ::std::max(GetTextWidth(itr->maText), nTextWidth);
+
+ size_t nLastPos = maMenuItems.size()-1;
+ Point aPos;
+ Size aSize;
+ getMenuItemPosSize(nLastPos, aPos, aSize);
+ aPos.X() += nTextWidth + 15;
+ aPos.Y() += aSize.Height() + 5;
+ SetOutputSizePixel(Size(aPos.X(), aPos.Y()));
+}
+
+void ScMenuFloatingWindow::selectMenuItem(size_t nPos, bool bSelected, bool bSubMenuTimer)
+{
+ if (nPos >= maMenuItems.size() || nPos == MENU_NOT_SELECTED)
+ {
+ queueCloseSubMenu();
+ return;
+ }
+
+ if (!maMenuItems[nPos].mbEnabled)
+ {
+ queueCloseSubMenu();
+ return;
+ }
+
+ highlightMenuItem(nPos, bSelected);
+
+ if (bSelected)
+ {
+ if (mpParentMenu)
+ mpParentMenu->setSubMenuFocused(this);
+
+ if (bSubMenuTimer)
+ {
+ if (maMenuItems[nPos].mpSubMenuWin)
+ {
+ ScMenuFloatingWindow* pSubMenu = maMenuItems[nPos].mpSubMenuWin.get();
+ queueLaunchSubMenu(nPos, pSubMenu);
+ }
+ else
+ queueCloseSubMenu();
+ }
+ }
+}
+
+void ScMenuFloatingWindow::clearSelectedMenuItem()
+{
+ selectMenuItem(mnSelectedMenu, false, false);
+ mnSelectedMenu = MENU_NOT_SELECTED;
+}
+
+ScMenuFloatingWindow* ScMenuFloatingWindow::getSubMenuWindow(size_t nPos) const
+{
+ if (maMenuItems.size() <= nPos)
+ return NULL;
+
+ return maMenuItems[nPos].mpSubMenuWin.get();
+}
+
+bool ScMenuFloatingWindow::isMenuItemSelected(size_t nPos) const
+{
+ return nPos == mnSelectedMenu;
+}
+
+void ScMenuFloatingWindow::setName(const OUString& rName)
+{
+ maName = rName;
+}
+
+const OUString& ScMenuFloatingWindow::getName() const
+{
+ return maName;
+}
+
+void ScMenuFloatingWindow::highlightMenuItem(size_t nPos, bool bSelected)
+{
+ if (nPos == MENU_NOT_SELECTED)
+ return;
+
+ const StyleSettings& rStyle = GetSettings().GetStyleSettings();
+ Color aBackColor = rStyle.GetMenuColor();
+ SetFillColor(aBackColor);
+ SetLineColor(aBackColor);
+
+ Point aPos;
+ Size aSize;
+ getMenuItemPosSize(nPos, aPos, aSize);
+ Rectangle aRegion(aPos,aSize);
+
+ if (IsNativeControlSupported(CTRL_MENU_POPUP, PART_ENTIRE_CONTROL))
+ {
+ Push(PUSH_CLIPREGION);
+ IntersectClipRegion(Rectangle(aPos, aSize));
+ Rectangle aCtrlRect(Point(0,0), GetOutputSizePixel());
+ DrawNativeControl(
+ CTRL_MENU_POPUP, PART_ENTIRE_CONTROL, aCtrlRect, CTRL_STATE_ENABLED,
+ ImplControlValue(), OUString());
+
+ Pop();
+ }
+
+ bool bNativeDrawn = true;
+ if (IsNativeControlSupported(CTRL_MENU_POPUP, PART_MENU_ITEM))
+ {
+ ControlState nState = bSelected ? CTRL_STATE_SELECTED : 0;
+ if (maMenuItems[nPos].mbEnabled)
+ nState |= CTRL_STATE_ENABLED;
+ bNativeDrawn = DrawNativeControl(
+ CTRL_MENU_POPUP, PART_MENU_ITEM, aRegion, nState, ImplControlValue(), OUString());
+ }
+ else
+ bNativeDrawn = false;
+
+ if (!bNativeDrawn)
+ {
+ if (bSelected)
+ {
+ aBackColor = rStyle.GetMenuHighlightColor();
+ SetFillColor(aBackColor);
+ SetLineColor(aBackColor);
+ }
+ DrawRect(Rectangle(aPos,aSize));
+ }
+
+ Color aTextColor = bSelected ? rStyle.GetMenuHighlightTextColor() : rStyle.GetMenuTextColor();
+ SetTextColor(aTextColor);
+ drawMenuItem(nPos);
+}
+
+void ScMenuFloatingWindow::getMenuItemPosSize(size_t nPos, Point& rPos, Size& rSize) const
+{
+ const sal_uInt16 nLeftMargin = 5;
+ const sal_uInt16 nTopMargin = 5;
+ const sal_uInt16 nMenuItemHeight = static_cast< sal_uInt16 >( maLabelFont.GetHeight()*1.8 );
+
+ Size aWndSize = GetSizePixel();
+
+ Point aPos1(nLeftMargin, nTopMargin);
+ Size aSize1(aWndSize.Width() - nLeftMargin*2, nMenuItemHeight);
+
+ rPos = aPos1;
+ rPos.Y() += aSize1.Height()*nPos;
+ rSize = aSize1;
+}
+
+ScMenuFloatingWindow* ScMenuFloatingWindow::getParentMenuWindow() const
+{
+ return mpParentMenu;
+}
+
+size_t ScMenuFloatingWindow::getEnclosingMenuItem(const Point& rPos) const
+{
+ size_t n = maMenuItems.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ Point aPos;
+ Size aSize;
+ getMenuItemPosSize(i, aPos, aSize);
+ Rectangle aRect(aPos, aSize);
+ if (aRect.IsInside(rPos))
+ return i;
+ }
+ return MENU_NOT_SELECTED;
+}
+
+size_t ScMenuFloatingWindow::getSubMenuPos(ScMenuFloatingWindow* pSubMenu)
+{
+ size_t n = maMenuItems.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ if (maMenuItems[i].mpSubMenuWin.get() == pSubMenu)
+ return i;
+ }
+ return MENU_NOT_SELECTED;
+}
+
+void ScMenuFloatingWindow::fireMenuHighlightedEvent()
+{
+ if (mnSelectedMenu == MENU_NOT_SELECTED)
+ return;
+
+ if (!mxAccessible.is())
+ return;
+
+ Reference<XAccessibleContext> xAccCxt = mxAccessible->getAccessibleContext();
+ if (!xAccCxt.is())
+ return;
+
+ Reference<XAccessible> xAccMenu = xAccCxt->getAccessibleChild(mnSelectedMenu);
+ if (!xAccMenu.is())
+ return;
+
+ VclAccessibleEvent aEvent(VCLEVENT_MENU_HIGHLIGHT, xAccMenu);
+ FireVclEvent(&aEvent);
+}
+
+void ScMenuFloatingWindow::setSubMenuFocused(ScMenuFloatingWindow* pSubMenu)
+{
+ maCloseTimer.reset();
+ size_t nMenuPos = getSubMenuPos(pSubMenu);
+ if (mnSelectedMenu != nMenuPos)
+ {
+ highlightMenuItem(nMenuPos, true);
+ mnSelectedMenu = nMenuPos;
+ }
+}
+
+void ScMenuFloatingWindow::ensureSubMenuVisible(ScMenuFloatingWindow* pSubMenu)
+{
+ if (mpParentMenu)
+ mpParentMenu->ensureSubMenuVisible(this);
+
+ if (pSubMenu->IsVisible())
+ return;
+
+ // Find the menu position of the submenu.
+ size_t nMenuPos = getSubMenuPos(pSubMenu);
+ if (nMenuPos != MENU_NOT_SELECTED)
+ {
+ setSelectedMenuItem(nMenuPos, false, false);
+
+ Point aPos;
+ Size aSize;
+ getMenuItemPosSize(nMenuPos, aPos, aSize);
+
+ sal_uInt32 nOldFlags = GetPopupModeFlags();
+ SetPopupModeFlags(nOldFlags | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE);
+ pSubMenu->resizeToFitMenuItems(); // set the size before launching the popup to get it positioned correctly.
+ pSubMenu->StartPopupMode(
+ Rectangle(aPos,aSize), (FLOATWIN_POPUPMODE_RIGHT | FLOATWIN_POPUPMODE_GRABFOCUS));
+ pSubMenu->AddPopupModeWindow(this);
+ SetPopupModeFlags(nOldFlags);
+ }
+}
+
+void ScMenuFloatingWindow::ensureSubMenuNotVisible()
+{
+ if (mnSelectedMenu <= maMenuItems.size() &&
+ maMenuItems[mnSelectedMenu].mpSubMenuWin &&
+ maMenuItems[mnSelectedMenu].mpSubMenuWin->IsVisible())
+ {
+ maMenuItems[mnSelectedMenu].mpSubMenuWin->ensureSubMenuNotVisible();
+ }
+
+ EndPopupMode();
+}
+
+void ScMenuFloatingWindow::terminateAllPopupMenus()
+{
+ EndPopupMode();
+ if (mpParentMenu)
+ mpParentMenu->terminateAllPopupMenus();
+}
+
+IMPL_LINK( ScMenuFloatingWindow, PopupEndHdl, void*, EMPTYARG )
+{
+ clearSelectedMenuItem();
+ return 0;
+}
+
+// ============================================================================
+
+ScDPFieldPopupWindow::Member::Member() :
+ mbVisible(true)
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPFieldPopupWindow::CancelButton::CancelButton(ScDPFieldPopupWindow* pParent) :
+ ::CancelButton(pParent), mpParent(pParent) {}
+
+void ScDPFieldPopupWindow::CancelButton::Click()
+{
+ mpParent->EndPopupMode();
+ ::CancelButton::Click();
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPFieldPopupWindow::ScDPFieldPopupWindow(Window* pParent, ScDocument* pDoc) :
+ ScMenuFloatingWindow(pParent, pDoc),
+ maChecks(this, 0),
+ maChkToggleAll(this, 0),
+ maBtnSelectSingle (this, 0),
+ maBtnUnselectSingle(this, 0),
+ maBtnOk(this),
+ maBtnCancel(this),
+ mnCurTabStop(0),
+ mpExtendedData(NULL),
+ mpOKAction(NULL),
+ maWndSize(240, 330),
+ mePrevToggleAllState(STATE_DONTKNOW)
+{
+ maTabStopCtrls.reserve(7);
+ maTabStopCtrls.push_back(this);
+ maTabStopCtrls.push_back(&maChecks);
+ maTabStopCtrls.push_back(&maChkToggleAll);
+ maTabStopCtrls.push_back(&maBtnSelectSingle);
+ maTabStopCtrls.push_back(&maBtnUnselectSingle);
+ maTabStopCtrls.push_back(&maBtnOk);
+ maTabStopCtrls.push_back(&maBtnCancel);
+
+ const StyleSettings& rStyle = GetSettings().GetStyleSettings();
+
+ Point aPos;
+ Size aSize;
+ getSectionPosSize(aPos, aSize, WHOLE);
+ SetOutputSizePixel(aSize);
+ Size aOutSize = GetOutputSizePixel();
+
+ getSectionPosSize(aPos, aSize, BTN_OK);
+ maBtnOk.SetPosSizePixel(aPos, aSize);
+ maBtnOk.SetFont(getLabelFont());
+ maBtnOk.SetClickHdl( LINK(this, ScDPFieldPopupWindow, ButtonHdl) );
+ maBtnOk.Show();
+
+ getSectionPosSize(aPos, aSize, BTN_CANCEL);
+ maBtnCancel.SetPosSizePixel(aPos, aSize);
+ maBtnCancel.SetFont(getLabelFont());
+ maBtnCancel.Show();
+
+ getSectionPosSize(aPos, aSize, LISTBOX_AREA_INNER);
+ maChecks.SetPosSizePixel(aPos, aSize);
+ maChecks.SetFont(getLabelFont());
+ maChecks.SetCheckButtonHdl( LINK(this, ScDPFieldPopupWindow, CheckHdl) );
+ maChecks.Show();
+
+ getSectionPosSize(aPos, aSize, CHECK_TOGGLE_ALL);
+ maChkToggleAll.SetPosSizePixel(aPos, aSize);
+ maChkToggleAll.SetFont(getLabelFont());
+ maChkToggleAll.SetText(ScRscStrLoader(RID_POPUP_FILTER, STR_BTN_TOGGLE_ALL).GetString());
+ maChkToggleAll.SetControlBackground(rStyle.GetMenuColor());
+ maChkToggleAll.SetClickHdl( LINK(this, ScDPFieldPopupWindow, TriStateHdl) );
+ maChkToggleAll.Show();
+
+ getSectionPosSize(aPos, aSize, BTN_SINGLE_SELECT);
+ maBtnSelectSingle.SetPosSizePixel(aPos, aSize);
+ maBtnSelectSingle.SetQuickHelpText(ScRscStrLoader(RID_POPUP_FILTER, STR_BTN_SELECT_CURRENT).GetString());
+ maBtnSelectSingle.SetModeImage(Image(ScResId(RID_IMG_SELECT_CURRENT)), BMP_COLOR_NORMAL);
+ maBtnSelectSingle.SetClickHdl( LINK(this, ScDPFieldPopupWindow, ButtonHdl) );
+ maBtnSelectSingle.Show();
+
+ getSectionPosSize(aPos, aSize, BTN_SINGLE_UNSELECT);
+ maBtnUnselectSingle.SetPosSizePixel(aPos, aSize);
+ maBtnUnselectSingle.SetQuickHelpText(ScRscStrLoader(RID_POPUP_FILTER, STR_BTN_UNSELECT_CURRENT).GetString());
+ maBtnUnselectSingle.SetModeImage(Image(ScResId(RID_IMG_UNSELECT_CURRENT)), BMP_COLOR_NORMAL);
+ maBtnUnselectSingle.SetClickHdl( LINK(this, ScDPFieldPopupWindow, ButtonHdl) );
+ maBtnUnselectSingle.Show();
+}
+
+ScDPFieldPopupWindow::~ScDPFieldPopupWindow()
+{
+}
+
+void ScDPFieldPopupWindow::getSectionPosSize(Point& rPos, Size& rSize, SectionType eType) const
+{
+ // constant parameters.
+ const sal_uInt16 nListBoxMargin = 5; // horizontal distance from the side of the dialog to the listbox border.
+ const sal_uInt16 nListBoxInnerPadding = 5;
+ const sal_uInt16 nTopMargin = 5;
+ const sal_uInt16 nMenuHeight = 60;
+ const sal_uInt16 nSingleItemBtnAreaHeight = 32; // height of the middle area below the list box where the single-action buttons are.
+ const sal_uInt16 nBottomBtnAreaHeight = 50; // height of the bottom area where the OK and Cancel buttons are.
+ const sal_uInt16 nBtnWidth = 90;
+ const sal_uInt16 nLabelHeight = static_cast< sal_uInt16 >( getLabelFont().GetHeight() );
+ const sal_uInt16 nBtnHeight = nLabelHeight*2;
+ const sal_uInt16 nBottomMargin = 10;
+ const sal_uInt16 nMenuListMargin = 20;
+
+ // parameters calculated from constants.
+ const sal_uInt16 nListBoxWidth = static_cast< sal_uInt16 >( maWndSize.Width() - nListBoxMargin*2 );
+ const sal_uInt16 nListBoxHeight = static_cast< sal_uInt16 >( maWndSize.Height() - nTopMargin - nMenuHeight -
+ nMenuListMargin - nSingleItemBtnAreaHeight - nBottomBtnAreaHeight );
+
+ const sal_uInt16 nSingleBtnAreaY = nTopMargin + nMenuHeight + nListBoxHeight + nMenuListMargin - 1;
+
+ switch (eType)
+ {
+ case WHOLE:
+ {
+ rPos = Point(0, 0);
+ rSize = maWndSize;
+ }
+ break;
+ case LISTBOX_AREA_OUTER:
+ {
+ rPos = Point(nListBoxMargin, nTopMargin + nMenuHeight + nMenuListMargin);
+ rSize = Size(nListBoxWidth, nListBoxHeight);
+ }
+ break;
+ case LISTBOX_AREA_INNER:
+ {
+ rPos = Point(nListBoxMargin, nTopMargin + nMenuHeight + nMenuListMargin);
+ rPos.X() += nListBoxInnerPadding;
+ rPos.Y() += nListBoxInnerPadding;
+
+ rSize = Size(nListBoxWidth, nListBoxHeight);
+ rSize.Width() -= nListBoxInnerPadding*2;
+ rSize.Height() -= nListBoxInnerPadding*2;
+ }
+ break;
+ case SINGLE_BTN_AREA:
+ {
+ rPos = Point(nListBoxMargin, nSingleBtnAreaY);
+ rSize = Size(nListBoxWidth, nSingleItemBtnAreaHeight);
+ }
+ break;
+ case CHECK_TOGGLE_ALL:
+ {
+ long h = nLabelHeight*3/2; // check box height is heuristically 150% of the text height.
+ rPos = Point(nListBoxMargin, nSingleBtnAreaY);
+ rPos.X() += 5;
+ rPos.Y() += (nSingleItemBtnAreaHeight - h)/2;
+ rSize = Size(70, h);
+ }
+ break;
+ case BTN_SINGLE_SELECT:
+ {
+ long h = 26;
+ rPos = Point(nListBoxMargin, nSingleBtnAreaY);
+ rPos.X() += 150;
+ rPos.Y() += (nSingleItemBtnAreaHeight - h)/2;
+ rSize = Size(h, h);
+ }
+ break;
+ case BTN_SINGLE_UNSELECT:
+ {
+ long h = 26;
+ rPos = Point(nListBoxMargin, nSingleBtnAreaY);
+ rPos.X() += 150 + h + 10;
+ rPos.Y() += (nSingleItemBtnAreaHeight - h)/2;
+ rSize = Size(h, h);
+ }
+ break;
+ case BTN_OK:
+ {
+ long x = (maWndSize.Width() - nBtnWidth*2)/3;
+ long y = maWndSize.Height() - nBottomMargin - nBtnHeight;
+ rPos = Point(x, y);
+ rSize = Size(nBtnWidth, nBtnHeight);
+ }
+ break;
+ case BTN_CANCEL:
+ {
+ long x = (maWndSize.Width() - nBtnWidth*2)/3*2 + nBtnWidth;
+ long y = maWndSize.Height() - nBottomMargin - nBtnHeight;
+ rPos = Point(x, y);
+ rSize = Size(nBtnWidth, nBtnHeight);
+ }
+ break;
+ default:
+ ;
+ }
+}
+
+void ScDPFieldPopupWindow::setAllMemberState(bool bSet)
+{
+ size_t n = maMembers.size();
+ for (size_t i = 0; i < n; ++i)
+ maChecks.CheckEntryPos(static_cast< USHORT >( i ), bSet);
+}
+
+void ScDPFieldPopupWindow::selectCurrentMemberOnly(bool bSet)
+{
+ setAllMemberState(!bSet);
+ sal_uInt16 nSelected = maChecks.GetSelectEntryPos();
+ maChecks.CheckEntryPos(nSelected, bSet);
+}
+
+void ScDPFieldPopupWindow::cycleFocus(bool bReverse)
+{
+ maTabStopCtrls[mnCurTabStop]->SetFakeFocus(false);
+ maTabStopCtrls[mnCurTabStop]->LoseFocus();
+ if (mnCurTabStop == 0)
+ clearSelectedMenuItem();
+
+ if (bReverse)
+ {
+ if (mnCurTabStop > 0)
+ --mnCurTabStop;
+ else
+ mnCurTabStop = maTabStopCtrls.size() - 1;
+ }
+ else
+ {
+ ++mnCurTabStop;
+ if (mnCurTabStop >= maTabStopCtrls.size())
+ mnCurTabStop = 0;
+ }
+ maTabStopCtrls[mnCurTabStop]->SetFakeFocus(true);
+ maTabStopCtrls[mnCurTabStop]->GrabFocus();
+}
+
+IMPL_LINK( ScDPFieldPopupWindow, ButtonHdl, Button*, pBtn )
+{
+ if (pBtn == &maBtnOk)
+ close(true);
+ else if (pBtn == &maBtnSelectSingle)
+ {
+ selectCurrentMemberOnly(true);
+ CheckHdl(&maChecks);
+ }
+ else if (pBtn == &maBtnUnselectSingle)
+ {
+ selectCurrentMemberOnly(false);
+ CheckHdl(&maChecks);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPFieldPopupWindow, TriStateHdl, TriStateBox*, EMPTYARG )
+{
+ switch (mePrevToggleAllState)
+ {
+ case STATE_NOCHECK:
+ maChkToggleAll.SetState(STATE_CHECK);
+ setAllMemberState(true);
+ break;
+ case STATE_CHECK:
+ maChkToggleAll.SetState(STATE_NOCHECK);
+ setAllMemberState(false);
+ break;
+ case STATE_DONTKNOW:
+ default:
+ maChkToggleAll.SetState(STATE_CHECK);
+ setAllMemberState(true);
+ break;
+ }
+
+ mePrevToggleAllState = maChkToggleAll.GetState();
+ return 0;
+}
+
+IMPL_LINK( ScDPFieldPopupWindow, CheckHdl, SvTreeListBox*, pChecks )
+{
+ if (pChecks != &maChecks)
+ return 0;
+
+ size_t nNumChecked = maChecks.GetCheckedEntryCount();
+ if (nNumChecked == maMembers.size())
+ // all members visible
+ maChkToggleAll.SetState(STATE_CHECK);
+ else if (nNumChecked == 0)
+ // no members visible
+ maChkToggleAll.SetState(STATE_NOCHECK);
+ else
+ maChkToggleAll.SetState(STATE_DONTKNOW);
+
+ mePrevToggleAllState = maChkToggleAll.GetState();
+ return 0;
+}
+
+void ScDPFieldPopupWindow::MouseMove(const MouseEvent& rMEvt)
+{
+ ScMenuFloatingWindow::MouseMove(rMEvt);
+
+ size_t nSelectedMenu = getSelectedMenuItem();
+ if (nSelectedMenu == MENU_NOT_SELECTED)
+ queueCloseSubMenu();
+}
+
+long ScDPFieldPopupWindow::Notify(NotifyEvent& rNEvt)
+{
+ switch (rNEvt.GetType())
+ {
+ case EVENT_KEYUP:
+ {
+ const KeyEvent* pKeyEvent = rNEvt.GetKeyEvent();
+ const KeyCode& rCode = pKeyEvent->GetKeyCode();
+ bool bShift = rCode.IsShift();
+ if (rCode.GetCode() == KEY_TAB)
+ {
+ cycleFocus(bShift);
+ return true;
+ }
+ }
+ break;
+ }
+ return ScMenuFloatingWindow::Notify(rNEvt);
+}
+
+void ScDPFieldPopupWindow::Paint(const Rectangle& rRect)
+{
+ ScMenuFloatingWindow::Paint(rRect);
+
+ const StyleSettings& rStyle = GetSettings().GetStyleSettings();
+ Color aMemberBackColor = rStyle.GetFieldColor();
+ Color aBorderColor = rStyle.GetShadowColor();
+
+ Point aPos;
+ Size aSize;
+ getSectionPosSize(aPos, aSize, LISTBOX_AREA_OUTER);
+
+ // Member list box background
+ SetFillColor(aMemberBackColor);
+ SetLineColor(aBorderColor);
+ DrawRect(Rectangle(aPos,aSize));
+
+ // Single-action button box
+ getSectionPosSize(aPos, aSize, SINGLE_BTN_AREA);
+ SetFillColor(rStyle.GetMenuColor());
+ DrawRect(Rectangle(aPos,aSize));
+}
+
+Window* ScDPFieldPopupWindow::GetPreferredKeyInputWindow()
+{
+ return maTabStopCtrls[mnCurTabStop];
+}
+
+Reference<XAccessible> ScDPFieldPopupWindow::CreateAccessible()
+{
+ if (!mxAccessible.is())
+ {
+ mxAccessible.set(new ScAccessibleFilterTopWindow(
+ GetAccessibleParentWindow()->GetAccessible(), this, getName(), getDoc()));
+ ScAccessibleFilterTopWindow* pAccTop = static_cast<ScAccessibleFilterTopWindow*>(mxAccessible.get());
+ fillMenuItemsToAccessible(pAccTop);
+
+ pAccTop->setAccessibleChild(
+ maChecks.CreateAccessible(), ScAccessibleFilterTopWindow::LISTBOX);
+ pAccTop->setAccessibleChild(
+ maChkToggleAll.CreateAccessible(), ScAccessibleFilterTopWindow::TOGGLE_ALL);
+ pAccTop->setAccessibleChild(
+ maBtnSelectSingle.CreateAccessible(), ScAccessibleFilterTopWindow::SINGLE_ON_BTN);
+ pAccTop->setAccessibleChild(
+ maBtnUnselectSingle.CreateAccessible(), ScAccessibleFilterTopWindow::SINGLE_OFF_BTN);
+ pAccTop->setAccessibleChild(
+ maBtnOk.CreateAccessible(), ScAccessibleFilterTopWindow::OK_BTN);
+ pAccTop->setAccessibleChild(
+ maBtnCancel.CreateAccessible(), ScAccessibleFilterTopWindow::CANCEL_BTN);
+ }
+
+ return mxAccessible;
+}
+
+void ScDPFieldPopupWindow::setMemberSize(size_t n)
+{
+ maMembers.reserve(n);
+}
+
+void ScDPFieldPopupWindow::addMember(const OUString& rName, bool bVisible)
+{
+ Member aMember;
+ aMember.maName = rName;
+ aMember.mbVisible = bVisible;
+ maMembers.push_back(aMember);
+}
+
+void ScDPFieldPopupWindow::initMembers()
+{
+ size_t n = maMembers.size();
+ size_t nVisMemCount = 0;
+ for (size_t i = 0; i < n; ++i)
+ {
+ maChecks.InsertEntry(maMembers[i].maName);
+ maChecks.CheckEntryPos(static_cast< USHORT >( i ), maMembers[i].mbVisible);
+ if (maMembers[i].mbVisible)
+ ++nVisMemCount;
+ }
+ if (nVisMemCount == n)
+ {
+ // all members visible
+ maChkToggleAll.SetState(STATE_CHECK);
+ mePrevToggleAllState = STATE_CHECK;
+ }
+ else if (nVisMemCount == 0)
+ {
+ // no members visible
+ maChkToggleAll.SetState(STATE_NOCHECK);
+ mePrevToggleAllState = STATE_NOCHECK;
+ }
+ else
+ {
+ maChkToggleAll.SetState(STATE_DONTKNOW);
+ mePrevToggleAllState = STATE_DONTKNOW;
+ }
+}
+
+const Size& ScDPFieldPopupWindow::getWindowSize() const
+{
+ return maWndSize;
+}
+
+void ScDPFieldPopupWindow::getResult(hash_map<OUString, bool, OUStringHash>& rResult)
+{
+ typedef hash_map<OUString, bool, OUStringHash> ResultMap;
+ ResultMap aResult;
+ size_t n = maMembers.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ bool bState = maChecks.IsChecked(static_cast< USHORT >( i ));
+ aResult.insert(ResultMap::value_type(maMembers[i].maName, bState));
+ }
+ rResult.swap(aResult);
+}
+
+void ScDPFieldPopupWindow::close(bool bOK)
+{
+ if (bOK && mpOKAction.get())
+ mpOKAction->execute();
+
+ EndPopupMode();
+}
+
+void ScDPFieldPopupWindow::setExtendedData(ExtendedData* p)
+{
+ mpExtendedData.reset(p);
+}
+
+ScDPFieldPopupWindow::ExtendedData* ScDPFieldPopupWindow::getExtendedData()
+{
+ return mpExtendedData.get();
+}
+
+void ScDPFieldPopupWindow::setOKAction(Action* p)
+{
+ mpOKAction.reset(p);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/dpcontrol.src b/sc/source/ui/cctrl/dpcontrol.src
new file mode 100644
index 000000000000..a992c5d17c98
--- /dev/null
+++ b/sc/source/ui/cctrl/dpcontrol.src
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dpcontrol.hrc"
+
+Resource RID_POPUP_FILTER
+{
+ String STR_MENU_SORT_ASC
+ {
+ Text [ en-US ] = "Sort Ascending" ;
+ };
+
+ String STR_MENU_SORT_DESC
+ {
+ Text [ en-US ] = "Sort Descending" ;
+ };
+
+ String STR_MENU_SORT_CUSTOM
+ {
+ Text [ en-US ] = "Custom Sort" ;
+ };
+
+ String STR_BTN_TOGGLE_ALL
+ {
+ Text [ en-US ] = "All" ;
+ };
+
+ String STR_BTN_SELECT_CURRENT
+ {
+ Text [ en-US ] = "Show only the current item." ;
+ };
+
+ String STR_BTN_UNSELECT_CURRENT
+ {
+ Text [ en-US ] = "Hide only the current item." ;
+ };
+};
+
+Image RID_IMG_SELECT_CURRENT
+{
+ ImageBitmap = Bitmap
+ {
+ File = "popup_select_current.png";
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+Image RID_IMG_UNSELECT_CURRENT
+{
+ ImageBitmap = Bitmap
+ {
+ File = "popup_unselect_current.png";
+ };
+ MaskColor = STD_MASKCOLOR;
+};
diff --git a/sc/source/ui/cctrl/editfield.cxx b/sc/source/ui/cctrl/editfield.cxx
new file mode 100644
index 000000000000..a393b4c38db5
--- /dev/null
+++ b/sc/source/ui/cctrl/editfield.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#ifdef SC_DLLIMPLEMENTATION
+#undef SC_DLLIMPLEMENTATION
+#endif
+#include "editfield.hxx"
+#include <rtl/math.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include "global.hxx"
+
+// ============================================================================
+
+namespace {
+
+sal_Unicode lclGetDecSep()
+{
+ return ScGlobal::GetpLocaleData()->getNumDecimalSep().GetChar( 0 );
+}
+
+sal_Unicode lclGetGroupSep()
+{
+ return ScGlobal::GetpLocaleData()->getNumThousandSep().GetChar( 0 );
+}
+
+} // namespace
+
+// ============================================================================
+
+ScDoubleField::ScDoubleField( Window* pParent, const ResId& rResId ) :
+ Edit( pParent, rResId )
+{
+}
+
+bool ScDoubleField::GetValue( double& rfValue ) const
+{
+ String aStr( GetText() );
+ aStr.EraseLeadingAndTrailingChars( ' ' );
+ bool bOk = aStr.Len() > 0;
+ if( bOk )
+ {
+ rtl_math_ConversionStatus eStatus;
+ sal_Int32 nEnd;
+ rfValue = rtl::math::stringToDouble( aStr, lclGetDecSep(), lclGetGroupSep(), &eStatus, &nEnd );
+ bOk = (eStatus == rtl_math_ConversionStatus_Ok) && (nEnd == static_cast< sal_Int32 >( aStr.Len() ));
+ }
+ return bOk;
+}
+
+void ScDoubleField::SetValue( double fValue, sal_Int32 nDecPlaces, bool bEraseTrailingDecZeros )
+{
+ SetText( ::rtl::math::doubleToUString( fValue, rtl_math_StringFormat_G,
+ nDecPlaces, lclGetDecSep(), bEraseTrailingDecZeros ) );
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/makefile.mk b/sc/source/ui/cctrl/makefile.mk
new file mode 100644
index 000000000000..70b5490a9626
--- /dev/null
+++ b/sc/source/ui/cctrl/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=cctrl
+LIBTARGET=NO
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/tbinsert.obj \
+ $(SLO)$/tbzoomsliderctrl.obj \
+ $(SLO)$/dpcontrol.obj
+
+SLOFILES = \
+ $(SLO)$/popmenu.obj \
+ $(SLO)$/tbinsert.obj \
+ $(SLO)$/cbuttonw.obj \
+ $(SLO)$/dpcontrol.obj \
+ $(SLO)$/editfield.obj \
+ $(EXCEPTIONSFILES)
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ dpcontrol.src
+
+LIB1TARGET=$(SLB)$/$(TARGET).lib
+LIB1OBJFILES= \
+ $(SLO)$/popmenu.obj \
+ $(SLO)$/tbinsert.obj \
+ $(SLO)$/cbuttonw.obj \
+ $(SLO)$/dpcontrol.obj \
+ $(SLO)$/tbzoomsliderctrl.obj
+
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/sc/source/ui/cctrl/popmenu.cxx b/sc/source/ui/cctrl/popmenu.cxx
new file mode 100644
index 000000000000..e473fa3ae80e
--- /dev/null
+++ b/sc/source/ui/cctrl/popmenu.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "popmenu.hxx"
+
+//------------------------------------------------------------------
+
+void __EXPORT ScPopupMenu::Select()
+{
+ nSel = GetCurItemId();
+ bHit = TRUE;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/tbinsert.cxx b/sc/source/ui/cctrl/tbinsert.cxx
new file mode 100644
index 000000000000..5f7b341ee06f
--- /dev/null
+++ b/sc/source/ui/cctrl/tbinsert.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+#include <string> // HACK: prevent conflict between STLPORT and Workshop headers
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <tools/shl.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <vcl/toolbox.hxx>
+
+#include "tbinsert.hxx"
+#include "tbinsert.hrc"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+// -----------------------------------------------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( ScTbxInsertCtrl, SfxUInt16Item);
+
+//------------------------------------------------------------------
+//
+// ToolBox - Controller
+//
+//------------------------------------------------------------------
+
+ScTbxInsertCtrl::ScTbxInsertCtrl( USHORT nSlotId, USHORT nId, ToolBox& rTbx ) :
+ SfxToolBoxControl( nSlotId, nId, rTbx ),
+ nLastSlotId(0)
+{
+ rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) );
+}
+
+__EXPORT ScTbxInsertCtrl::~ScTbxInsertCtrl()
+{
+}
+
+void __EXPORT ScTbxInsertCtrl::StateChanged( USHORT /* nSID */, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) );
+
+ if( eState == SFX_ITEM_AVAILABLE )
+ {
+
+ const SfxUInt16Item* pItem = PTR_CAST( SfxUInt16Item, pState );
+ if(pItem)
+ {
+ nLastSlotId = pItem->GetValue();
+ USHORT nImageId = nLastSlotId ? nLastSlotId : GetSlotId();
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( nImageId ));
+ Image aImage = GetImage( m_xFrame,
+ aSlotURL,
+ hasBigImages(),
+ GetToolBox().GetSettings().GetStyleSettings().GetHighContrastMode() );
+ GetToolBox().SetItemImage(GetId(), aImage);
+ }
+ }
+}
+
+SfxPopupWindow* __EXPORT ScTbxInsertCtrl::CreatePopupWindow()
+{
+// USHORT nWinResId, nTbxResId;
+ USHORT nSlotId = GetSlotId();
+ if (nSlotId == SID_TBXCTL_INSERT)
+ {
+ rtl::OUString aInsertBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertbar" ));
+ createAndPositionSubToolBar( aInsertBarResStr );
+// nWinResId = RID_TBXCTL_INSERT;
+// nTbxResId = RID_TOOLBOX_INSERT;
+ }
+ else if (nSlotId == SID_TBXCTL_INSCELLS)
+ {
+ rtl::OUString aInsertCellsBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertcellsbar" ));
+ createAndPositionSubToolBar( aInsertCellsBarResStr );
+// nWinResId = RID_TBXCTL_INSCELLS;
+// nTbxResId = RID_TOOLBOX_INSCELLS;
+ }
+ else /* SID_TBXCTL_INSOBJ */
+ {
+ rtl::OUString aInsertObjectBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertobjectbar" ));
+ createAndPositionSubToolBar( aInsertObjectBarResStr );
+// nWinResId = RID_TBXCTL_INSOBJ;
+// nTbxResId = RID_TOOLBOX_INSOBJ;
+ }
+/*
+ WindowAlign eNewAlign = ( GetToolBox().IsHorizontal() ) ? WINDOWALIGN_LEFT : WINDOWALIGN_TOP;
+ ScTbxInsertPopup *pWin = new ScTbxInsertPopup( nSlotId, eNewAlign,
+ ScResId(nWinResId), ScResId(nTbxResId), GetBindings() );
+ pWin->StartPopupMode(&GetToolBox(), TRUE);
+ pWin->StartSelection();
+ pWin->Show();
+ return pWin;
+*/
+ return NULL;
+}
+
+SfxPopupWindowType __EXPORT ScTbxInsertCtrl::GetPopupWindowType() const
+{
+ return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK;
+}
+
+void __EXPORT ScTbxInsertCtrl::Select( BOOL /* bMod1 */ )
+{
+ SfxViewShell* pCurSh( SfxViewShell::Current() );
+ SfxDispatcher* pDispatch( 0 );
+
+ if ( pCurSh )
+ {
+ SfxViewFrame* pViewFrame = pCurSh->GetViewFrame();
+ if ( pViewFrame )
+ pDispatch = pViewFrame->GetDispatcher();
+ }
+
+ if ( pDispatch )
+ pDispatch->Execute(nLastSlotId);
+}
+/*
+//------------------------------------------------------------------
+//
+// Popup - Window
+//
+//------------------------------------------------------------------
+
+ScTbxInsertPopup::ScTbxInsertPopup( USHORT nId, WindowAlign eNewAlign,
+ const ResId& rRIdWin, const ResId& rRIdTbx,
+ SfxBindings& rBindings ) :
+ SfxPopupWindow ( nId, rRIdWin, rBindings),
+ aTbx ( this, GetBindings(), rRIdTbx ),
+ aRIdWinTemp(rRIdWin),
+ aRIdTbxTemp(rRIdTbx)
+{
+ aTbx.UseDefault();
+ FreeResource();
+
+ aTbx.GetToolBox().SetAlign( eNewAlign );
+ if (eNewAlign == WINDOWALIGN_LEFT || eNewAlign == WINDOWALIGN_RIGHT)
+ SetText( EMPTY_STRING );
+
+ Size aSize = aTbx.CalcWindowSizePixel();
+ aTbx.SetPosSizePixel( Point(), aSize );
+ SetOutputSizePixel( aSize );
+ aTbx.GetToolBox().SetSelectHdl( LINK(this, ScTbxInsertPopup, TbxSelectHdl));
+ aTbxClickHdl = aTbx.GetToolBox().GetClickHdl();
+ aTbx.GetToolBox().SetClickHdl( LINK(this, ScTbxInsertPopup, TbxClickHdl));
+}
+
+ScTbxInsertPopup::~ScTbxInsertPopup()
+{
+}
+
+SfxPopupWindow* __EXPORT ScTbxInsertPopup::Clone() const
+{
+ return new ScTbxInsertPopup( GetId(), aTbx.GetToolBox().GetAlign(),
+ aRIdWinTemp, aRIdTbxTemp,
+ (SfxBindings&) GetBindings() );
+}
+
+void ScTbxInsertPopup::StartSelection()
+{
+ aTbx.GetToolBox().StartSelection();
+}
+
+IMPL_LINK(ScTbxInsertPopup, TbxSelectHdl, ToolBox*, pBox)
+{
+ EndPopupMode();
+
+ USHORT nLastSlotId = pBox->GetCurItemId();
+ SfxUInt16Item aItem( GetId(), nLastSlotId );
+ SfxDispatcher* pDisp = GetBindings().GetDispatcher();
+ pDisp->Execute( GetId(), SFX_CALLMODE_SYNCHRON, &aItem, 0L );
+ pDisp->Execute( nLastSlotId, SFX_CALLMODE_ASYNCHRON );
+ return 0;
+}
+
+IMPL_LINK(ScTbxInsertPopup, TbxClickHdl, ToolBox*, pBox)
+{
+ USHORT nLastSlotId = pBox->GetCurItemId();
+ SfxUInt16Item aItem( GetId(), nLastSlotId );
+ GetBindings().GetDispatcher()->Execute( GetId(), SFX_CALLMODE_SYNCHRON, &aItem, 0L );
+ if(aTbxClickHdl.IsSet())
+ aTbxClickHdl.Call(pBox);
+ return 0;
+}
+
+void __EXPORT ScTbxInsertPopup::PopupModeEnd()
+{
+ aTbx.GetToolBox().EndSelection();
+ SfxPopupWindow::PopupModeEnd();
+}
+*/
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
new file mode 100644
index 000000000000..cc8e9592d671
--- /dev/null
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -0,0 +1,533 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+#include "precompiled_sc.hxx"
+#include "tbzoomsliderctrl.hxx"
+#include <vcl/image.hxx>
+#include <vcl/toolbox.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/gradient.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objsh.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svx/dialmgr.hxx>
+#include <svx/dialogs.hrc>
+#include <set>
+#include "docsh.hxx"
+#include "stlpool.hxx"
+#include "scitems.hxx"
+#include "printfun.hxx"
+
+//========================================================================
+// class ScZoomSliderControl ---------------------------------------
+//========================================================================
+
+// -----------------------------------------------------------------------
+
+SFX_IMPL_TOOLBOX_CONTROL( ScZoomSliderControl, SvxZoomSliderItem );
+
+// -----------------------------------------------------------------------
+
+ScZoomSliderControl::ScZoomSliderControl(
+ USHORT nSlotId,
+ USHORT nId,
+ ToolBox& rTbx )
+ :SfxToolBoxControl( nSlotId, nId, rTbx )
+{
+ rTbx.Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScZoomSliderControl::~ScZoomSliderControl()
+{
+
+}
+
+// -----------------------------------------------------------------------
+
+void ScZoomSliderControl::StateChanged( USHORT /*nSID*/, SfxItemState eState,
+ const SfxPoolItem* pState )
+{
+ USHORT nId = GetId();
+ ToolBox& rTbx = GetToolBox();
+ ScZoomSliderWnd* pBox = (ScZoomSliderWnd*)(rTbx.GetItemWindow( nId ));
+ DBG_ASSERT( pBox ,"Control not found!" );
+
+ if ( SFX_ITEM_AVAILABLE != eState || pState->ISA( SfxVoidItem ) )
+ {
+ SvxZoomSliderItem aZoomSliderItem( 100 );
+ pBox->Disable();
+ pBox->UpdateFromItem( &aZoomSliderItem );
+ }
+ else
+ {
+ pBox->Enable();
+ DBG_ASSERT( pState->ISA( SvxZoomSliderItem ), "invalid item type" );
+ const SvxZoomSliderItem* pZoomSliderItem = dynamic_cast< const SvxZoomSliderItem* >( pState );
+
+ DBG_ASSERT( pZoomSliderItem, "Sc::ScZoomSliderControl::StateChanged(), wrong item type!" );
+ if( pZoomSliderItem )
+ pBox->UpdateFromItem( pZoomSliderItem );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+Window* ScZoomSliderControl::CreateItemWindow( Window *pParent )
+{
+ // #i98000# Don't try to get a value via SfxViewFrame::Current here.
+ // The view's value is always notified via StateChanged later.
+ ScZoomSliderWnd* pSlider = new ScZoomSliderWnd( pParent,
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >( m_xFrame->getController(),
+ ::com::sun::star::uno::UNO_QUERY ), m_xFrame, 100 );
+ return pSlider;
+}
+
+// -----------------------------------------------------------------------
+
+struct ScZoomSliderWnd::ScZoomSliderWnd_Impl
+{
+ USHORT mnCurrentZoom;
+ USHORT mnMinZoom;
+ USHORT mnMaxZoom;
+ USHORT mnSliderCenter;
+ std::vector< long > maSnappingPointOffsets;
+ std::vector< USHORT > maSnappingPointZooms;
+ Image maSliderButton;
+ Image maIncreaseButton;
+ Image maDecreaseButton;
+ bool mbValuesSet;
+ bool mbOmitPaint;
+
+ ScZoomSliderWnd_Impl( USHORT nCurrentZoom ) :
+ mnCurrentZoom( nCurrentZoom ),
+ mnMinZoom( 10 ),
+ mnMaxZoom( 400 ),
+ mnSliderCenter( 100 ),
+ maSnappingPointOffsets(),
+ maSnappingPointZooms(),
+ maSliderButton(),
+ maIncreaseButton(),
+ maDecreaseButton(),
+ mbValuesSet( true ),
+ mbOmitPaint( false )
+ {
+
+ }
+};
+
+// -----------------------------------------------------------------------
+
+const long nButtonWidth = 10;
+const long nButtonHeight = 10;
+const long nIncDecWidth = 11;
+const long nIncDecHeight = 11;
+const long nSliderHeight = 2; //
+const long nSliderWidth = 4; //
+const long nSnappingHeight = 4;
+const long nSliderXOffset = 20;
+const long nSnappingEpsilon = 5; // snapping epsilon in pixels
+const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points
+
+
+// -----------------------------------------------------------------------
+
+USHORT ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
+{
+ Size aSliderWindowSize = GetOutputSizePixel();
+ const long nControlWidth = aSliderWindowSize.Width();
+ USHORT nRet = 0;
+
+ if( nOffset < nSliderXOffset )
+ return mpImpl->mnMinZoom;
+ if( nOffset > nControlWidth - nSliderXOffset )
+ return mpImpl->mnMaxZoom;
+
+ // check for snapping points:
+ USHORT nCount = 0;
+ std::vector< long >::iterator aSnappingPointIter;
+ for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
+ aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
+ ++aSnappingPointIter )
+ {
+ const long nCurrent = *aSnappingPointIter;
+ if ( Abs(nCurrent - nOffset) < nSnappingEpsilon )
+ {
+ nOffset = nCurrent;
+ nRet = mpImpl->maSnappingPointZooms[ nCount ];
+ break;
+ }
+ ++nCount;
+ }
+
+ if( 0 == nRet )
+ {
+ if( nOffset < nControlWidth / 2 )
+ {
+ // first half of slider
+ const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
+ const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
+ const long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth;
+ const long nOffsetToSliderLeft = nOffset - nSliderXOffset;
+ nRet = mpImpl->mnMinZoom + USHORT( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
+ }
+ else
+ {
+ // second half of slider
+ const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
+ const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
+ const long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth;
+ const long nOffsetToSliderCenter = nOffset - nControlWidth/2;
+ nRet = mpImpl->mnSliderCenter + USHORT( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
+ }
+ }
+
+ if( nRet < mpImpl->mnMinZoom )
+ return mpImpl->mnMinZoom;
+
+ else if( nRet > mpImpl->mnMaxZoom )
+ return mpImpl->mnMaxZoom;
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------
+
+long ScZoomSliderWnd::Zoom2Offset( USHORT nCurrentZoom ) const
+{
+ Size aSliderWindowSize = GetOutputSizePixel();
+ const long nControlWidth = aSliderWindowSize.Width();
+ long nRect = nSliderXOffset;
+
+ const long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset;
+ if( nCurrentZoom <= mpImpl->mnSliderCenter )
+ {
+ nCurrentZoom = nCurrentZoom - mpImpl->mnMinZoom;
+ const long nFirstHalfRange = mpImpl->mnSliderCenter - mpImpl->mnMinZoom;
+ const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange;
+ const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
+ nRect += nOffset;
+ }
+ else
+ {
+ nCurrentZoom = nCurrentZoom - mpImpl->mnSliderCenter;
+ const long nSecondHalfRange = mpImpl->mnMaxZoom - mpImpl->mnSliderCenter;
+ const long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange;
+ const long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
+ nRect += nHalfSliderWidth + nOffset;
+ }
+ return nRect;
+}
+
+// -----------------------------------------------------------------------
+
+
+ScZoomSliderWnd::ScZoomSliderWnd( Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame , USHORT nCurrentZoom ):
+ Window( pParent ),
+ mpImpl( new ScZoomSliderWnd_Impl( nCurrentZoom ) ),
+ aLogicalSize( 115, 40 ),
+ m_xDispatchProvider( rDispatchProvider ),
+ m_xFrame( _xFrame )
+{
+ BOOL bIsHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+ mpImpl->maSliderButton = Image( SVX_RES( bIsHC ? RID_SVXBMP_SLIDERBUTTON_HC : RID_SVXBMP_SLIDERBUTTON ) );
+ mpImpl->maIncreaseButton = Image( SVX_RES( bIsHC ? RID_SVXBMP_SLIDERINCREASE_HC : RID_SVXBMP_SLIDERINCREASE ) );
+ mpImpl->maDecreaseButton = Image( SVX_RES( bIsHC ? RID_SVXBMP_SLIDERDECREASE_HC : RID_SVXBMP_SLIDERDECREASE ) );
+ Size aSliderSize = LogicToPixel( Size( aLogicalSize), MapMode( MAP_10TH_MM ) );
+ SetSizePixel( Size( aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight ) );
+}
+
+// -----------------------------------------------------------------------
+
+ScZoomSliderWnd::~ScZoomSliderWnd()
+{
+ delete mpImpl;
+}
+
+// -----------------------------------------------------------------------
+
+void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( !mpImpl->mbValuesSet )
+ return ;
+ Size aSliderWindowSize = GetOutputSizePixel();
+
+ const Point aPoint = rMEvt.GetPosPixel();
+
+ const long nButtonLeftOffset = ( nSliderXOffset - nIncDecWidth )/2;
+ const long nButtonRightOffset = ( nSliderXOffset + nIncDecWidth )/2;
+
+ const long nOldZoom = mpImpl->mnCurrentZoom;
+
+ // click to - button
+ if ( aPoint.X() >= nButtonLeftOffset && aPoint.X() <= nButtonRightOffset )
+ {
+ mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom - 5;
+ }
+ // click to + button
+ else if ( aPoint.X() >= aSliderWindowSize.Width() - nSliderXOffset + nButtonLeftOffset &&
+ aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset + nButtonRightOffset )
+ {
+ mpImpl->mnCurrentZoom = mpImpl->mnCurrentZoom + 5;
+ }
+ else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= aSliderWindowSize.Width() - nSliderXOffset )
+ {
+ mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() );
+ }
+
+ if( mpImpl->mnCurrentZoom < mpImpl->mnMinZoom )
+ mpImpl->mnCurrentZoom = mpImpl->mnMinZoom;
+ else if( mpImpl->mnCurrentZoom > mpImpl->mnMaxZoom )
+ mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom;
+
+ if( nOldZoom == mpImpl->mnCurrentZoom )
+ return ;
+
+ Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
+
+ Paint( aRect );
+ mpImpl->mbOmitPaint = true;
+
+ SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
+
+ ::com::sun::star::uno::Any a;
+ aZoomSliderItem.QueryValue( a );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScalingFactor" ));
+ aArgs[0].Value = a;
+
+ SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ScalingFactor"), aArgs );
+
+ mpImpl->mbOmitPaint = false;
+}
+
+// -----------------------------------------------------------------------
+
+void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( !mpImpl->mbValuesSet )
+ return ;
+
+ Size aSliderWindowSize = GetOutputSizePixel();
+ const long nControlWidth = aSliderWindowSize.Width();
+ const short nButtons = rMEvt.GetButtons();
+
+ // check mouse move with button pressed
+ if ( 1 == nButtons )
+ {
+ const Point aPoint = rMEvt.GetPosPixel();
+
+ if ( aPoint.X() >= nSliderXOffset && aPoint.X() <= nControlWidth - nSliderXOffset )
+ {
+ mpImpl->mnCurrentZoom = Offset2Zoom( aPoint.X() );
+
+ Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
+ Paint( aRect );
+
+ mpImpl->mbOmitPaint = true; // optimization: paint before executing command,
+
+ // commit state change
+ SvxZoomSliderItem aZoomSliderItem( mpImpl->mnCurrentZoom );
+
+ ::com::sun::star::uno::Any a;
+ aZoomSliderItem.QueryValue( a );
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScalingFactor" ));
+ aArgs[0].Value = a;
+
+ SfxToolBoxControl::Dispatch( m_xDispatchProvider, String::CreateFromAscii(".uno:ScalingFactor"), aArgs );
+
+ mpImpl->mbOmitPaint = false;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
+{
+ if( pZoomSliderItem )
+ {
+ mpImpl->mnCurrentZoom = pZoomSliderItem->GetValue();
+ mpImpl->mnMinZoom = pZoomSliderItem->GetMinZoom();
+ mpImpl->mnMaxZoom = pZoomSliderItem->GetMaxZoom();
+
+ DBG_ASSERT( mpImpl->mnMinZoom <= mpImpl->mnCurrentZoom &&
+ mpImpl->mnMinZoom < mpImpl->mnSliderCenter &&
+ mpImpl->mnMaxZoom >= mpImpl->mnCurrentZoom &&
+ mpImpl->mnMaxZoom > mpImpl->mnSliderCenter,
+ "Looks like the zoom slider item is corrupted" );
+ const com::sun::star::uno::Sequence < sal_Int32 > rSnappingPoints = pZoomSliderItem->GetSnappingPoints();
+ mpImpl->maSnappingPointOffsets.clear();
+ mpImpl->maSnappingPointZooms.clear();
+
+ // get all snapping points:
+ std::set< USHORT > aTmpSnappingPoints;
+ for ( USHORT j = 0; j < rSnappingPoints.getLength(); ++j )
+ {
+ const sal_Int32 nSnappingPoint = rSnappingPoints[j];
+ aTmpSnappingPoints.insert( (USHORT)nSnappingPoint );
+ }
+
+ // remove snapping points that are to close to each other:
+ std::set< USHORT >::iterator aSnappingPointIter;
+ long nLastOffset = 0;
+
+ for ( aSnappingPointIter = aTmpSnappingPoints.begin(); aSnappingPointIter != aTmpSnappingPoints.end(); ++aSnappingPointIter )
+ {
+ const USHORT nCurrent = *aSnappingPointIter;
+ const long nCurrentOffset = Zoom2Offset( nCurrent );
+
+ if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist )
+ {
+ mpImpl->maSnappingPointOffsets.push_back( nCurrentOffset );
+ mpImpl->maSnappingPointZooms.push_back( nCurrent );
+ nLastOffset = nCurrentOffset;
+ }
+ }
+ }
+
+ Size aSliderWindowSize = GetOutputSizePixel();
+ Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
+
+ if ( !mpImpl->mbOmitPaint )
+ Paint(aRect);
+}
+
+// -----------------------------------------------------------------------
+
+void ScZoomSliderWnd::Paint( const Rectangle& rRect )
+{
+ DoPaint( rRect );
+}
+
+// -----------------------------------------------------------------------
+
+void ScZoomSliderWnd::DoPaint( const Rectangle& /*rRect*/ )
+{
+ if( mpImpl->mbOmitPaint )
+ return;
+
+ Size aSliderWindowSize = GetOutputSizePixel();
+ Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
+
+ VirtualDevice* pVDev = new VirtualDevice( *this );
+ pVDev->SetOutputSizePixel( aSliderWindowSize );
+
+ Rectangle aSlider = aRect;
+
+ aSlider.Top() += ( aSliderWindowSize.Height() - nSliderHeight )/2 - 1;
+ aSlider.Bottom() = aSlider.Top() + nSliderHeight;
+ aSlider.Left() += nSliderXOffset;
+ aSlider.Right() -= nSliderXOffset;
+
+ Rectangle aFirstLine( aSlider );
+ aFirstLine.Bottom() = aFirstLine.Top();
+
+ Rectangle aSecondLine( aSlider );
+ aSecondLine.Top() = aSecondLine.Bottom();
+
+ Rectangle aLeft( aSlider );
+ aLeft.Right() = aLeft.Left();
+
+ Rectangle aRight( aSlider );
+ aRight.Left() = aRight.Right();
+
+ // draw VirtualDevice's background color
+ Color aStartColor,aEndColor;
+ aStartColor = GetSettings().GetStyleSettings().GetFaceColor();
+ aEndColor = GetSettings().GetStyleSettings().GetFaceColor();
+ if( aEndColor.IsDark() )
+ aStartColor = aEndColor;
+
+ Gradient g;
+ g.SetAngle( 0 );
+ g.SetStyle( GRADIENT_LINEAR );
+
+ g.SetStartColor( aStartColor );
+ g.SetEndColor( aEndColor );
+ pVDev->DrawGradient( aRect, g );
+
+ // draw slider
+ pVDev->SetLineColor( Color ( COL_WHITE ) );
+ pVDev->DrawRect( aSecondLine );
+ pVDev->DrawRect( aRight );
+
+ pVDev->SetLineColor( Color( COL_GRAY ) );
+ pVDev->DrawRect( aFirstLine );
+ pVDev->DrawRect( aLeft );
+
+ // draw snapping points:
+ std::vector< long >::iterator aSnappingPointIter;
+ for ( aSnappingPointIter = mpImpl->maSnappingPointOffsets.begin();
+ aSnappingPointIter != mpImpl->maSnappingPointOffsets.end();
+ ++aSnappingPointIter )
+ {
+ pVDev->SetLineColor( Color( COL_GRAY ) );
+ Rectangle aSnapping( aRect );
+ aSnapping.Bottom() = aSlider.Top();
+ aSnapping.Top() = aSnapping.Bottom() - nSnappingHeight;
+ aSnapping.Left() += *aSnappingPointIter;
+ aSnapping.Right() = aSnapping.Left();
+ pVDev->DrawRect( aSnapping );
+
+ aSnapping.Top() += nSnappingHeight + nSliderHeight;
+ aSnapping.Bottom() += nSnappingHeight + nSliderHeight;
+ pVDev->DrawRect( aSnapping );
+ }
+
+ // draw slider button
+ Point aImagePoint = aRect.TopLeft();
+ aImagePoint.X() += Zoom2Offset( mpImpl->mnCurrentZoom );
+ aImagePoint.X() -= nButtonWidth/2;
+ aImagePoint.Y() += ( aSliderWindowSize.Height() - nButtonHeight)/2;
+ pVDev->DrawImage( aImagePoint, mpImpl->maSliderButton );
+
+ // draw decrease button
+ aImagePoint = aRect.TopLeft();
+ aImagePoint.X() += (nSliderXOffset - nIncDecWidth)/2;
+ aImagePoint.Y() += ( aSliderWindowSize.Height() - nIncDecHeight)/2;
+ pVDev->DrawImage( aImagePoint, mpImpl->maDecreaseButton );
+
+ // draw increase button
+ aImagePoint.X() = aRect.TopLeft().X() + aSliderWindowSize.Width() - nIncDecWidth - (nSliderXOffset - nIncDecWidth)/2;
+ pVDev->DrawImage( aImagePoint, mpImpl->maIncreaseButton );
+
+ DrawOutDev( Point(0, 0), aSliderWindowSize, Point(0, 0), aSliderWindowSize, *pVDev );
+
+ delete pVDev;
+
+}
+
+// -----------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
new file mode 100644
index 000000000000..19aa38fbac58
--- /dev/null
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -0,0 +1,406 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "global.hxx"
+#include "scresid.hxx"
+#include "impex.hxx"
+#include "asciiopt.hxx"
+#include "asciiopt.hrc"
+#include <tools/debug.hxx>
+#include <rtl/tencinfo.h>
+#include <unotools/transliterationwrapper.hxx>
+// ause
+#include "editutil.hxx"
+
+// ============================================================================
+
+static const sal_Char __FAR_DATA pStrFix[] = "FIX";
+static const sal_Char __FAR_DATA pStrMrg[] = "MRG";
+
+
+// ============================================================================
+
+ScAsciiOptions::ScAsciiOptions() :
+ bFixedLen ( FALSE ),
+ aFieldSeps ( ';' ),
+ bMergeFieldSeps ( FALSE ),
+ bQuotedFieldAsText(false),
+ bDetectSpecialNumber(false),
+ cTextSep ( cDefaultTextSep ),
+ eCharSet ( gsl_getSystemTextEncoding() ),
+ eLang ( LANGUAGE_SYSTEM ),
+ bCharSetSystem ( FALSE ),
+ nStartRow ( 1 ),
+ nInfoCount ( 0 ),
+ pColStart ( NULL ),
+ pColFormat ( NULL )
+{
+}
+
+
+ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) :
+ bFixedLen ( rOpt.bFixedLen ),
+ aFieldSeps ( rOpt.aFieldSeps ),
+ bMergeFieldSeps ( rOpt.bMergeFieldSeps ),
+ bQuotedFieldAsText(rOpt.bQuotedFieldAsText),
+ bDetectSpecialNumber(rOpt.bDetectSpecialNumber),
+ cTextSep ( rOpt.cTextSep ),
+ eCharSet ( rOpt.eCharSet ),
+ eLang ( rOpt.eLang ),
+ bCharSetSystem ( rOpt.bCharSetSystem ),
+ nStartRow ( rOpt.nStartRow ),
+ nInfoCount ( rOpt.nInfoCount )
+{
+ if (nInfoCount)
+ {
+ pColStart = new xub_StrLen[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (USHORT i=0; i<nInfoCount; i++)
+ {
+ pColStart[i] = rOpt.pColStart[i];
+ pColFormat[i] = rOpt.pColFormat[i];
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+}
+
+
+ScAsciiOptions::~ScAsciiOptions()
+{
+ delete[] pColStart;
+ delete[] pColFormat;
+}
+
+
+void ScAsciiOptions::SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat )
+{
+ delete[] pColStart;
+ delete[] pColFormat;
+
+ nInfoCount = nCount;
+
+ if (nInfoCount)
+ {
+ pColStart = new xub_StrLen[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (USHORT i=0; i<nInfoCount; i++)
+ {
+ pColStart[i] = pStart[i];
+ pColFormat[i] = pFormat[i];
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+}
+
+
+void ScAsciiOptions::SetColumnInfo( const ScCsvExpDataVec& rDataVec )
+{
+ delete[] pColStart;
+ pColStart = NULL;
+ delete[] pColFormat;
+ pColFormat = NULL;
+
+ nInfoCount = static_cast< sal_uInt16 >( rDataVec.size() );
+ if( nInfoCount )
+ {
+ pColStart = new xub_StrLen[ nInfoCount ];
+ pColFormat = new sal_uInt8[ nInfoCount ];
+ for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx )
+ {
+ pColStart[ nIx ] = rDataVec[ nIx ].mnIndex;
+ pColFormat[ nIx ] = rDataVec[ nIx ].mnType;
+ }
+ }
+}
+
+
+ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy )
+{
+ SetColInfo( rCpy.nInfoCount, rCpy.pColStart, rCpy.pColFormat );
+
+ bFixedLen = rCpy.bFixedLen;
+ aFieldSeps = rCpy.aFieldSeps;
+ bMergeFieldSeps = rCpy.bMergeFieldSeps;
+ bQuotedFieldAsText = rCpy.bQuotedFieldAsText;
+ cTextSep = rCpy.cTextSep;
+ eCharSet = rCpy.eCharSet;
+ bCharSetSystem = rCpy.bCharSetSystem;
+ nStartRow = rCpy.nStartRow;
+
+ return *this;
+}
+
+
+BOOL ScAsciiOptions::operator==( const ScAsciiOptions& rCmp ) const
+{
+ if ( bFixedLen == rCmp.bFixedLen &&
+ aFieldSeps == rCmp.aFieldSeps &&
+ bMergeFieldSeps == rCmp.bMergeFieldSeps &&
+ bQuotedFieldAsText == rCmp.bQuotedFieldAsText &&
+ cTextSep == rCmp.cTextSep &&
+ eCharSet == rCmp.eCharSet &&
+ bCharSetSystem == rCmp.bCharSetSystem &&
+ nStartRow == rCmp.nStartRow &&
+ nInfoCount == rCmp.nInfoCount )
+ {
+ DBG_ASSERT( !nInfoCount || (pColStart && pColFormat && rCmp.pColStart && rCmp.pColFormat),
+ "0-Zeiger in ScAsciiOptions" );
+ for (USHORT i=0; i<nInfoCount; i++)
+ if ( pColStart[i] != rCmp.pColStart[i] ||
+ pColFormat[i] != rCmp.pColFormat[i] )
+ return FALSE;
+
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//
+// Der Options-String darf kein Semikolon mehr enthalten (wegen Pickliste)
+// darum ab Version 336 Komma stattdessen
+//
+
+
+void ScAsciiOptions::ReadFromString( const String& rString )
+{
+ xub_StrLen nCount = rString.GetTokenCount(',');
+ String aToken;
+ xub_StrLen nSub;
+ xub_StrLen i;
+
+ //
+ // Feld-Trenner
+ //
+
+ if ( nCount >= 1 )
+ {
+ bFixedLen = bMergeFieldSeps = FALSE;
+ aFieldSeps.Erase();
+
+ aToken = rString.GetToken(0,',');
+ if ( aToken.EqualsAscii(pStrFix) )
+ bFixedLen = TRUE;
+ nSub = aToken.GetTokenCount('/');
+ for ( i=0; i<nSub; i++ )
+ {
+ String aCode = aToken.GetToken( i, '/' );
+ if ( aCode.EqualsAscii(pStrMrg) )
+ bMergeFieldSeps = TRUE;
+ else
+ {
+ sal_Int32 nVal = aCode.ToInt32();
+ if ( nVal )
+ aFieldSeps += (sal_Unicode) nVal;
+ }
+ }
+ }
+
+ //
+ // Text-Trenner
+ //
+
+ if ( nCount >= 2 )
+ {
+ aToken = rString.GetToken(1,',');
+ sal_Int32 nVal = aToken.ToInt32();
+ cTextSep = (sal_Unicode) nVal;
+ }
+
+ //
+ // Zeichensatz
+ //
+
+ if ( nCount >= 3 )
+ {
+ aToken = rString.GetToken(2,',');
+ eCharSet = ScGlobal::GetCharsetValue( aToken );
+ }
+
+ //
+ // Startzeile
+ //
+
+ if ( nCount >= 4 )
+ {
+ aToken = rString.GetToken(3,',');
+ nStartRow = aToken.ToInt32();
+ }
+
+ //
+ // Spalten-Infos
+ //
+
+ if ( nCount >= 5 )
+ {
+ delete[] pColStart;
+ delete[] pColFormat;
+
+ aToken = rString.GetToken(4,',');
+ nSub = aToken.GetTokenCount('/');
+ nInfoCount = nSub / 2;
+ if (nInfoCount)
+ {
+ pColStart = new xub_StrLen[nInfoCount];
+ pColFormat = new BYTE[nInfoCount];
+ for (USHORT nInfo=0; nInfo<nInfoCount; nInfo++)
+ {
+ pColStart[nInfo] = (xub_StrLen) aToken.GetToken( 2*nInfo, '/' ).ToInt32();
+ pColFormat[nInfo] = (BYTE) aToken.GetToken( 2*nInfo+1, '/' ).ToInt32();
+ }
+ }
+ else
+ {
+ pColStart = NULL;
+ pColFormat = NULL;
+ }
+ }
+
+ // Language
+ if (nCount >= 6)
+ {
+ aToken = rString.GetToken(5, ',');
+ eLang = static_cast<LanguageType>(aToken.ToInt32());
+ }
+
+ // Import quoted field as text.
+ if (nCount >= 7)
+ {
+ aToken = rString.GetToken(6, ',');
+ bQuotedFieldAsText = aToken.EqualsAscii("true") ? true : false;
+ }
+
+ // Detect special nubmers.
+ if (nCount >= 8)
+ {
+ aToken = rString.GetToken(7, ',');
+ bDetectSpecialNumber = aToken.EqualsAscii("true") ? true : false;
+ }
+}
+
+
+String ScAsciiOptions::WriteToString() const
+{
+ String aOutStr;
+
+ //
+ // Feld-Trenner
+ //
+
+ if ( bFixedLen )
+ aOutStr.AppendAscii(pStrFix);
+ else if ( !aFieldSeps.Len() )
+ aOutStr += '0';
+ else
+ {
+ xub_StrLen nLen = aFieldSeps.Len();
+ for (xub_StrLen i=0; i<nLen; i++)
+ {
+ if (i)
+ aOutStr += '/';
+ aOutStr += String::CreateFromInt32(aFieldSeps.GetChar(i));
+ }
+ if ( bMergeFieldSeps )
+ {
+ aOutStr += '/';
+ aOutStr.AppendAscii(pStrMrg);
+ }
+ }
+
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Text-Trenner
+ //
+
+ aOutStr += String::CreateFromInt32(cTextSep);
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Zeichensatz
+ //
+
+ if ( bCharSetSystem ) // force "SYSTEM"
+ aOutStr += ScGlobal::GetCharsetString( RTL_TEXTENCODING_DONTKNOW );
+ else
+ aOutStr += ScGlobal::GetCharsetString( eCharSet );
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Startzeile
+ //
+
+ aOutStr += String::CreateFromInt32(nStartRow);
+ aOutStr += ','; // Token-Ende
+
+ //
+ // Spalten-Infos
+ //
+
+ DBG_ASSERT( !nInfoCount || (pColStart && pColFormat), "0-Zeiger in ScAsciiOptions" );
+ for (USHORT nInfo=0; nInfo<nInfoCount; nInfo++)
+ {
+ if (nInfo)
+ aOutStr += '/';
+ aOutStr += String::CreateFromInt32(pColStart[nInfo]);
+ aOutStr += '/';
+ aOutStr += String::CreateFromInt32(pColFormat[nInfo]);
+ }
+
+ // #i112025# the options string is used in macros and linked sheets,
+ // so new options must be added at the end, to remain compatible
+
+ aOutStr += ',';
+
+ // Language
+ aOutStr += String::CreateFromInt32(eLang);
+ aOutStr += ',';
+
+ // Import quoted field as text.
+ aOutStr += String::CreateFromAscii(bQuotedFieldAsText ? "true" : "false");
+ aOutStr += ',';
+
+ // Detect special nubmers.
+ aOutStr += String::CreateFromAscii(bDetectSpecialNumber ? "true" : "false");
+
+ return aOutStr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/asciiopt.hrc b/sc/source/ui/dbgui/asciiopt.hrc
new file mode 100644
index 000000000000..a251127ce586
--- /dev/null
+++ b/sc/source/ui/dbgui/asciiopt.hrc
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+//#define RID_SCDLG_ASCII 256
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_FIELDOPT 4
+#define FT_CHARSET 5
+#define LB_CHARSET 6
+#define FT_CUSTOMLANG 7
+#define LB_CUSTOMLANG 8
+#define FT_AT_ROW 9
+#define NF_AT_ROW 10
+
+#define FL_SEPOPT 11
+#define RB_FIXED 12
+#define RB_SEPARATED 13
+#define CKB_TAB 14
+#define CKB_COMMA 15
+#define CKB_OTHER 16
+#define ED_OTHER 17
+#define CKB_SEMICOLON 18
+#define CKB_SPACE 19
+#define CB_ASONCE 20
+#define CB_TEXTSEP 21
+#define FT_TEXTSEP 22
+
+#define FL_OTHER_OPTIONS 23
+#define CB_QUOTED_AS_TEXT 24
+#define CB_DETECT_SPECIAL_NUMBER 25
+
+#define FL_WIDTH 26
+#define FT_TYPE 27
+#define LB_TYPE1 28
+#define CTR_TABLEBOX 29
+#define STR_TEXTTOCOLUMNS 30
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/asciiopt.src b/sc/source/ui/dbgui/asciiopt.src
new file mode 100644
index 000000000000..1744ae4635bd
--- /dev/null
+++ b/sc/source/ui/dbgui/asciiopt.src
@@ -0,0 +1,305 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "asciiopt.hrc"
+
+ModalDialog RID_SCDLG_ASCII
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 320 , 305 ) ;
+ Text [ en-US ] = "Text Import" ;
+ Moveable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 264 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 264 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 264 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ FixedLine FL_FIELDOPT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Import" ;
+ };
+
+ FixedText FT_CHARSET
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Ch~aracter set" ;
+ };
+
+ ListBox LB_CHARSET
+ {
+ Pos = MAP_APPFONT ( 76 , 14 ) ;
+ Size = MAP_APPFONT ( 130 , 61 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE;
+ };
+
+ FixedText FT_CUSTOMLANG
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Language" ;
+ };
+
+ ListBox LB_CUSTOMLANG
+ {
+ Pos = MAP_APPFONT ( 76 , 30 ) ;
+ Size = MAP_APPFONT ( 130 , 61 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE;
+ };
+
+ FixedText FT_AT_ROW
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "From ro~w" ;
+ };
+
+ NumericField NF_AT_ROW
+ {
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 76 , 46 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ };
+
+ FixedLine FL_SEPOPT
+ {
+ Pos = MAP_APPFONT ( 6 , 63 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Separator options" ;
+ };
+ RadioButton RB_FIXED
+ {
+ Pos = MAP_APPFONT ( 12 , 75 ) ;
+ Size = MAP_APPFONT ( 243 , 10 ) ;
+ Text [ en-US ] = "~Fixed width" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_SEPARATED
+ {
+ Pos = MAP_APPFONT ( 12 , 89 ) ;
+ Size = MAP_APPFONT ( 243 , 10 ) ;
+ Text [ en-US ] = "~Separated by" ;
+ TabStop = TRUE ;
+ Check = TRUE ;
+ };
+
+ CheckBox CKB_TAB
+ {
+ Pos = MAP_APPFONT ( 20 , 102 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Tab" ;
+ };
+ CheckBox CKB_COMMA
+ {
+ Pos = MAP_APPFONT ( 92 , 102 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Comma" ;
+ };
+ CheckBox CKB_OTHER
+ {
+ Pos = MAP_APPFONT ( 164 , 102 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Other" ;
+ };
+ Edit ED_OTHER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 100 ) ;
+ Size = MAP_APPFONT ( 37 , 12 ) ;
+ TabStop = TRUE ;
+ MaxTextLength = 10 ;
+ };
+
+ CheckBox CKB_SEMICOLON
+ {
+ Pos = MAP_APPFONT ( 20 , 115 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "S~emicolon" ;
+ };
+ CheckBox CKB_SPACE
+ {
+ Pos = MAP_APPFONT ( 92 , 115 ) ;
+ Size = MAP_APPFONT ( 68 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "S~pace" ;
+ };
+
+ CheckBox CB_ASONCE
+ {
+ Pos = MAP_APPFONT ( 20 , 130 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Merge ~delimiters" ;
+ };
+
+ ComboBox CB_TEXTSEP
+ {
+ Pos = MAP_APPFONT ( 218 , 128 ) ;
+ Size = MAP_APPFONT ( 37 , 94 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_TEXTSEP
+ {
+ Pos = MAP_APPFONT ( 156 , 130 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Te~xt delimiter" ;
+ };
+
+ FixedLine FL_OTHER_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 146 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Other options" ;
+ };
+
+ CheckBox CB_QUOTED_AS_TEXT
+ {
+ Pos = MAP_APPFONT ( 12 , 158 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Quoted field as text" ;
+ };
+
+ CheckBox CB_DETECT_SPECIAL_NUMBER
+ {
+ Pos = MAP_APPFONT ( 12 , 171 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Detect special numbers" ;
+ };
+
+ FixedLine FL_WIDTH
+ {
+ Pos = MAP_APPFONT ( 6 , 187 ) ;
+ Size = MAP_APPFONT ( 252 , 8 ) ;
+ Text [ en-US ] = "Fields" ;
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 200 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Column t~ype";
+ };
+ ListBox LB_TYPE1
+ {
+ Pos = MAP_APPFONT ( 76 , 198 ) ;
+ Size = MAP_APPFONT ( 60 , 68 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ Control CTR_TABLEBOX
+ {
+ HelpId = HID_SC_ASCII_TABCTR ;
+ Border = TRUE ;
+ DialogControl = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 216 ) ;
+ Size = MAP_APPFONT ( 243 , 82 ) ;
+ };
+
+ String STR_TEXTTOCOLUMNS
+ {
+ Text [ en-US ] = "Text to Columns" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/consdlg.cxx b/sc/source/ui/dbgui/consdlg.cxx
new file mode 100644
index 000000000000..602241485a41
--- /dev/null
+++ b/sc/source/ui/dbgui/consdlg.cxx
@@ -0,0 +1,657 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+#include <sfx2/dispatch.hxx>
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "tabvwsh.hxx"
+#include "uiitems.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+
+#include "globstr.hrc"
+#include "consdlg.hrc"
+
+#define _CONSDLG_CXX
+#include "consdlg.hxx"
+#undef _CONSDLG_CXX
+#include <vcl/msgbox.hxx>
+
+#define INFOBOX(id) InfoBox(this, ScGlobal::GetRscString(id)).Execute()
+
+//============================================================================
+// class ScAreaData
+
+class ScAreaData
+{
+public:
+ ScAreaData() {}
+ ~ScAreaData() {}
+
+ void Set( const String& rName, const String& rArea, BOOL bDb )
+ {
+ aStrName = rName;
+ aStrArea = rArea;
+ bIsDbArea = bDb;
+ }
+
+ String aStrName;
+ String aStrArea;
+ BOOL bIsDbArea;
+};
+
+
+//============================================================================
+// class ScConsolidateDialog
+
+
+ScConsolidateDlg::ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_CONSOLIDATE ),
+ //
+ aFtFunc ( this, ScResId( FT_FUNC ) ),
+ aLbFunc ( this, ScResId( LB_FUNC ) ),
+
+ aFtConsAreas ( this, ScResId( FT_CONSAREAS ) ),
+ aLbConsAreas ( this, ScResId( LB_CONSAREAS ) ),
+
+ aLbDataArea ( this, ScResId( LB_DATA_AREA ) ),
+ aFtDataArea ( this, ScResId( FT_DATA_AREA ) ),
+ aEdDataArea ( this, this, ScResId( ED_DATA_AREA ) ),
+ aRbDataArea ( this, ScResId( RB_DATA_AREA ), &aEdDataArea, this ),
+
+ aLbDestArea ( this, ScResId( LB_DEST_AREA ) ),
+ aFtDestArea ( this, ScResId( FT_DEST_AREA ) ),
+ aEdDestArea ( this, this, ScResId( ED_DEST_AREA ) ),
+ aRbDestArea ( this, ScResId( RB_DEST_AREA ), &aEdDestArea, this),
+
+ aFlConsBy ( this, ScResId( FL_CONSBY ) ),
+ aBtnByRow ( this, ScResId( BTN_BYROW ) ),
+ aBtnByCol ( this, ScResId( BTN_BYCOL) ),
+
+ aFlSep ( this, ScResId( FL_SEP ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnRefs ( this, ScResId( BTN_REFS ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ //
+ theConsData ( ((const ScConsolidateItem&)
+ rArgSet.Get( rArgSet.GetPool()->
+ GetWhich( SID_CONSOLIDATE ) )
+ ).GetData() ),
+ pViewData ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData() ),
+ pDoc ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData()->GetDocument() ),
+ pRangeUtil ( new ScRangeUtil ),
+ pAreaData ( NULL ),
+ nAreaDataCount ( 0 ),
+ nWhichCons ( rArgSet.GetPool()->GetWhich( SID_CONSOLIDATE ) ),
+
+ pRefInputEdit ( &aEdDataArea )
+{
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScConsolidateDlg::~ScConsolidateDlg()
+{
+ delete [] pAreaData;
+ delete pRangeUtil;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScConsolidateDlg::Init()
+{
+ DBG_ASSERT( pViewData && pDoc && pRangeUtil, "Error in Ctor" );
+
+ String aStr;
+ USHORT i=0;
+
+ aEdDataArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aEdDestArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aLbDataArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aLbDestArea .SetGetFocusHdl( LINK( this, ScConsolidateDlg, GetFocusHdl ) );
+ aEdDataArea .SetModifyHdl ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
+ aEdDestArea .SetModifyHdl ( LINK( this, ScConsolidateDlg, ModifyHdl ) );
+ aLbConsAreas.SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
+ aLbDataArea .SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
+ aLbDestArea .SetSelectHdl ( LINK( this, ScConsolidateDlg, SelectHdl ) );
+ aBtnOk .SetClickHdl ( LINK( this, ScConsolidateDlg, OkHdl ) );
+ aBtnCancel .SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
+ aBtnAdd .SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
+ aBtnRemove .SetClickHdl ( LINK( this, ScConsolidateDlg, ClickHdl ) );
+
+ aBtnMore.AddWindow( &aFlConsBy );
+ aBtnMore.AddWindow( &aBtnByRow );
+ aBtnMore.AddWindow( &aBtnByCol );
+ aBtnMore.AddWindow( &aFlSep );
+ aBtnMore.AddWindow( &aFlOptions );
+ aBtnMore.AddWindow( &aBtnRefs );
+
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+
+ aBtnByRow.Check( theConsData.bByRow );
+ aBtnByCol.Check( theConsData.bByCol );
+ aBtnRefs .Check( theConsData.bReferenceData );
+
+ aLbFunc.SelectEntryPos( FuncToLbPos( theConsData.eFunction ) );
+
+ // Einlesen der Konsolidierungsbereiche
+ aLbConsAreas.Clear();
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ for ( i=0; i<theConsData.nDataAreaCount; i++ )
+ {
+ const ScArea& rArea = *(theConsData.ppDataAreas[i] );
+ if ( rArea.nTab < pDoc->GetTableCount() )
+ {
+ ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
+ rArea.nColEnd, rArea.nRowEnd, rArea.nTab ).Format( aStr,
+ SCR_ABS_3D, pDoc, eConv );
+ aLbConsAreas.InsertEntry( aStr );
+ }
+ }
+
+ if ( theConsData.nTab < pDoc->GetTableCount() )
+ {
+ ScAddress( theConsData.nCol, theConsData.nRow, theConsData.nTab
+ ).Format( aStr, SCA_ABS_3D, pDoc, eConv );
+ aEdDestArea.SetText( aStr );
+ }
+ else
+ aEdDestArea.SetText( EMPTY_STRING );
+
+ //----------------------------------------------------------
+
+ /*
+ * Aus den RangeNames und Datenbankbereichen werden sich
+ * in der Hilfsklasse ScAreaData die Bereichsnamen gemerkt,
+ * die in den ListBoxen erscheinen.
+ */
+
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ ScDBCollection* pDbNames = pDoc->GetDBCollection();
+ const USHORT nRangeCount = pRangeNames ? pRangeNames->GetCount() : 0;
+ const USHORT nDbCount = pDbNames ? pDbNames ->GetCount() : 0;
+
+ nAreaDataCount = nRangeCount+nDbCount;
+ pAreaData = NULL;
+
+ if ( nAreaDataCount > 0 )
+ {
+ pAreaData = new ScAreaData[nAreaDataCount];
+
+ String aStrName;
+ String aStrArea;
+ USHORT nAt = 0;
+ ScRange aRange;
+ ScAreaNameIterator aIter( pDoc );
+ while ( aIter.Next( aStrName, aRange ) )
+ {
+ aRange.Format( aStrArea, SCA_ABS_3D, pDoc, eConv );
+ pAreaData[nAt++].Set( aStrName, aStrArea, aIter.WasDBName() );
+ }
+ }
+
+ FillAreaLists();
+ ModifyHdl( &aEdDestArea );
+ aLbDataArea.SelectEntryPos( 0 );
+ aEdDataArea.SetText( EMPTY_STRING );
+ aEdDataArea.GrabFocus();
+
+ aFlSep.SetStyle( aFlSep.GetStyle() | WB_VERT );
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+}
+
+
+//----------------------------------------------------------------------------
+void ScConsolidateDlg::FillAreaLists()
+{
+ aLbDataArea.Clear();
+ aLbDestArea.Clear();
+ aLbDataArea.InsertEntry( aStrUndefined );
+ aLbDestArea.InsertEntry( aStrUndefined );
+
+ if ( pRangeUtil && pAreaData && (nAreaDataCount > 0) )
+ {
+ String aString;
+
+ for ( USHORT i=0;
+ (i<nAreaDataCount) && (pAreaData[i].aStrName.Len()>0);
+ i++ )
+ {
+ aLbDataArea.InsertEntry( pAreaData[i].aStrName, i+1 );
+
+// if ( !pAreaData[i].bIsDbArea )
+ aLbDestArea.InsertEntry( pAreaData[i].aStrName, i+1 );
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Fenster angezeigt wird.
+
+
+void ScConsolidateDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pRefInputEdit )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aStr;
+ USHORT nFmt = SCR_ABS_3D; //!!! nCurTab fehlt noch
+ const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
+
+ if ( rRef.aStart.Tab() != rRef.aEnd.Tab() )
+ nFmt |= SCA_TAB2_3D;
+
+ if ( pRefInputEdit == &aEdDataArea)
+ rRef.Format( aStr, nFmt, pDocP, eConv );
+ else if ( pRefInputEdit == &aEdDestArea )
+ rRef.aStart.Format( aStr, nFmt, pDocP, eConv );
+
+ pRefInputEdit->SetRefString( aStr );
+ }
+
+ ModifyHdl( pRefInputEdit );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScConsolidateDlg::Close()
+{
+ return DoClose( ScConsolidateDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScConsolidateDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+
+ if ( pRefInputEdit )
+ {
+ pRefInputEdit->GrabFocus();
+ ModifyHdl( pRefInputEdit );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScConsolidateDlg::Deactivate()
+{
+ bDlgLostFocus = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScConsolidateDlg::VerifyEdit( formula::RefEdit* pEd )
+{
+ if ( !pRangeUtil || !pDoc || !pViewData ||
+ ((pEd != &aEdDataArea) && (pEd != &aEdDestArea)) )
+ return FALSE;
+
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bEditOk = FALSE;
+ String theCompleteStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( pEd == &aEdDataArea )
+ {
+ bEditOk = pRangeUtil->IsAbsArea( pEd->GetText(), pDoc,
+ nTab, &theCompleteStr, NULL, NULL, eConv );
+ }
+ else if ( pEd == &aEdDestArea )
+ {
+ String aPosStr;
+
+ pRangeUtil->CutPosString( pEd->GetText(), aPosStr );
+ bEditOk = pRangeUtil->IsAbsPos( aPosStr, pDoc,
+ nTab, &theCompleteStr, NULL, eConv );
+ }
+
+ if ( bEditOk )
+ pEd->SetText( theCompleteStr );
+
+ return bEditOk;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScConsolidateDlg, GetFocusHdl, Control*, pCtr )
+{
+ if ( pCtr ==(Control*)&aEdDataArea ||
+ pCtr ==(Control*)&aEdDestArea)
+ {
+ pRefInputEdit = (formula::RefEdit*)pCtr;
+ }
+ else if(pCtr ==(Control*)&aLbDataArea )
+ {
+ pRefInputEdit = &aEdDataArea;
+ }
+ else if(pCtr ==(Control*)&aLbDestArea )
+ {
+ pRefInputEdit = &aEdDestArea;
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, OkHdl, void*, EMPTYARG )
+{
+ USHORT nDataAreaCount = aLbConsAreas.GetEntryCount();
+
+ if ( nDataAreaCount > 0 )
+ {
+ ScRefAddress aDestAddress;
+ SCTAB nTab = pViewData->GetTabNo();
+ String aDestPosStr( aEdDestArea.GetText() );
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( pRangeUtil->IsAbsPos( aDestPosStr, pDoc, nTab, NULL, &aDestAddress, eConv ) )
+ {
+ ScConsolidateParam theOutParam( theConsData );
+ ScArea** ppDataAreas = new ScArea*[nDataAreaCount];
+ ScArea* pArea;
+ USHORT i=0;
+
+ for ( i=0; i<nDataAreaCount; i++ )
+ {
+ pArea = new ScArea;
+ pRangeUtil->MakeArea( aLbConsAreas.GetEntry( i ),
+ *pArea, pDoc, nTab, eConv );
+ ppDataAreas[i] = pArea;
+ }
+
+ theOutParam.nCol = aDestAddress.Col();
+ theOutParam.nRow = aDestAddress.Row();
+ theOutParam.nTab = aDestAddress.Tab();
+ theOutParam.eFunction = LbPosToFunc( aLbFunc.GetSelectEntryPos() );
+ theOutParam.bByCol = aBtnByCol.IsChecked();
+ theOutParam.bByRow = aBtnByRow.IsChecked();
+ theOutParam.bReferenceData = aBtnRefs.IsChecked();
+ theOutParam.SetAreas( ppDataAreas, nDataAreaCount );
+
+ for ( i=0; i<nDataAreaCount; i++ )
+ delete ppDataAreas[i];
+ delete [] ppDataAreas;
+
+ ScConsolidateItem aOutItem( nWhichCons, &theOutParam );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_CONSOLIDATE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else
+ {
+ INFOBOX( STR_INVALID_TABREF );
+ aEdDestArea.GrabFocus();
+ }
+ }
+ else
+ Close(); // keine Datenbereiche definiert -> Cancel
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, ClickHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnCancel )
+ Close();
+ else if ( pBtn == &aBtnAdd )
+ {
+ if ( aEdDataArea.GetText().Len() > 0 )
+ {
+ String aNewEntry( aEdDataArea.GetText() );
+ ScArea** ppAreas = NULL;
+ USHORT nAreaCount = 0;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( pRangeUtil->IsAbsTabArea( aNewEntry, pDoc, &ppAreas, &nAreaCount, TRUE, eConv ) )
+ {
+ // IsAbsTabArea() legt ein Array von ScArea-Zeigern an,
+ // welche ebenfalls dynamisch erzeugt wurden.
+ // Diese Objekte muessen hier abgeraeumt werden.
+
+ for ( USHORT i=0; i<nAreaCount; i++ )
+ {
+ String aNewArea;
+
+ if ( ppAreas[i] )
+ {
+ const ScArea& rArea = *(ppAreas[i]);
+ ScRange( rArea.nColStart, rArea.nRowStart, rArea.nTab,
+ rArea.nColEnd, rArea.nRowEnd, rArea.nTab
+ ).Format( aNewArea, SCR_ABS_3D, pDoc, eConv );
+
+ if ( aLbConsAreas.GetEntryPos( aNewArea )
+ == LISTBOX_ENTRY_NOTFOUND )
+ {
+ aLbConsAreas.InsertEntry( aNewArea );
+ }
+ delete ppAreas[i];
+ }
+ }
+ delete [] ppAreas;
+ }
+ else if ( VerifyEdit( &aEdDataArea ) )
+ {
+ String aNewArea( aEdDataArea.GetText() );
+
+ if ( aLbConsAreas.GetEntryPos( aNewArea ) == LISTBOX_ENTRY_NOTFOUND )
+ aLbConsAreas.InsertEntry( aNewArea );
+ else
+ INFOBOX( STR_AREA_ALREADY_INSERTED );
+ }
+ else
+ {
+ INFOBOX( STR_INVALID_TABREF );
+ aEdDataArea.GrabFocus();
+ }
+ }
+ }
+ else if ( pBtn == &aBtnRemove )
+ {
+ while ( aLbConsAreas.GetSelectEntryCount() )
+ aLbConsAreas.RemoveEntry( aLbConsAreas.GetSelectEntryPos() );
+ aBtnRemove.Disable();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, SelectHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbConsAreas )
+ {
+ if ( aLbConsAreas.GetSelectEntryCount() > 0 )
+ aBtnRemove.Enable();
+ else
+ aBtnRemove.Disable();
+ }
+ else if ( (pLb == &aLbDataArea) || (pLb == &aLbDestArea) )
+ {
+ Edit* pEd = (pLb == &aLbDataArea) ? &aEdDataArea : &aEdDestArea;
+ USHORT nSelPos = pLb->GetSelectEntryPos();
+
+ if ( pRangeUtil
+ && (nSelPos > 0)
+ && (nAreaDataCount > 0)
+ && (pAreaData != NULL) )
+ {
+ if ( nSelPos <= nAreaDataCount )
+ {
+ String aString( pAreaData[nSelPos-1].aStrArea );
+
+ if ( pLb == &aLbDestArea )
+ pRangeUtil->CutPosString( aString, aString );
+
+ pEd->SetText( aString );
+
+ if ( pEd == &aEdDataArea )
+ aBtnAdd.Enable();
+ }
+ }
+ else
+ {
+ pEd->SetText( EMPTY_STRING );
+ if ( pEd == &aEdDataArea )
+ aBtnAdd.Enable();
+ }
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScConsolidateDlg, ModifyHdl, formula::RefEdit*, pEd )
+{
+ if ( pEd == &aEdDataArea )
+ {
+ String aAreaStr( pEd->GetText() );
+ if ( aAreaStr.Len() > 0 )
+ {
+ aBtnAdd.Enable();
+ }
+ else
+ aBtnAdd.Disable();
+ }
+ else if ( pEd == &aEdDestArea )
+ {
+ aLbDestArea.SelectEntryPos(0);
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+// Verallgemeinern!!! :
+// Resource der ListBox und diese beiden Umrechnungsmethoden gibt es
+// auch noch in tpsubt bzw. ueberall, wo StarCalc-Funktionen
+// auswaehlbar sind.
+
+ScSubTotalFunc ScConsolidateDlg::LbPosToFunc( USHORT nPos )
+{
+ switch ( nPos )
+ {
+ case 2: return SUBTOTAL_FUNC_AVE;
+ case 6: return SUBTOTAL_FUNC_CNT;
+ case 1: return SUBTOTAL_FUNC_CNT2;
+ case 3: return SUBTOTAL_FUNC_MAX;
+ case 4: return SUBTOTAL_FUNC_MIN;
+ case 5: return SUBTOTAL_FUNC_PROD;
+ case 7: return SUBTOTAL_FUNC_STD;
+ case 8: return SUBTOTAL_FUNC_STDP;
+ case 9: return SUBTOTAL_FUNC_VAR;
+ case 10: return SUBTOTAL_FUNC_VARP;
+ case 0:
+ default:
+ return SUBTOTAL_FUNC_SUM;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+USHORT ScConsolidateDlg::FuncToLbPos( ScSubTotalFunc eFunc )
+{
+ switch ( eFunc )
+ {
+ case SUBTOTAL_FUNC_AVE: return 2;
+ case SUBTOTAL_FUNC_CNT: return 6;
+ case SUBTOTAL_FUNC_CNT2: return 1;
+ case SUBTOTAL_FUNC_MAX: return 3;
+ case SUBTOTAL_FUNC_MIN: return 4;
+ case SUBTOTAL_FUNC_PROD: return 5;
+ case SUBTOTAL_FUNC_STD: return 7;
+ case SUBTOTAL_FUNC_STDP: return 8;
+ case SUBTOTAL_FUNC_VAR: return 9;
+ case SUBTOTAL_FUNC_VARP: return 10;
+ case SUBTOTAL_FUNC_NONE:
+ case SUBTOTAL_FUNC_SUM:
+ default:
+ return 0;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/consdlg.hrc b/sc/source/ui/dbgui/consdlg.hrc
new file mode 100644
index 000000000000..f1f6c26fad8b
--- /dev/null
+++ b/sc/source/ui/dbgui/consdlg.hrc
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_MORE 4
+
+#define BTN_ADD 5
+#define BTN_REMOVE 6
+
+#define FT_FUNC 11
+#define LB_FUNC 12
+
+#define FT_CONSAREAS 21
+#define LB_CONSAREAS 22
+
+#define FT_DATA_AREA 31
+#define LB_DATA_AREA 32
+#define ED_DATA_AREA 33
+#define RB_DATA_AREA 34
+
+#define FT_DEST_AREA 41
+#define LB_DEST_AREA 42
+#define ED_DEST_AREA 43
+#define RB_DEST_AREA 44
+
+#define FL_CONSBY 50
+#define BTN_BYROW 51
+#define BTN_BYCOL 52
+#define FL_SEP 59
+
+#define FL_OPTIONS 60
+#define BTN_REFS 61
+
diff --git a/sc/source/ui/dbgui/consdlg.src b/sc/source/ui/dbgui/consdlg.src
new file mode 100644
index 000000000000..56748a0c58c1
--- /dev/null
+++ b/sc/source/ui/dbgui/consdlg.src
@@ -0,0 +1,217 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "consdlg.hrc"
+ModelessDialog RID_SCDLG_CONSOLIDATE
+{
+ OutputSize = TRUE ;
+ HelpId = SID_OPENDLG_CONSOLIDATE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 280 , 154 ) ;
+ Text [ en-US ] = "Consolidate" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ ListBox LB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 212 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Sum" ; Default ; > ;
+ < "Count" ; Default ; > ;
+ < "Average" ; Default ; > ;
+ < "Max" ; Default ; > ;
+ < "Min" ; Default ; > ;
+ < "Product" ; Default ; > ;
+ < "Count (numbers only)" ; Default ; > ;
+ < "StDev (sample)" ; Default ; > ;
+ < "StDevP (population)" ; Default ; > ;
+ < "Var (sample)" ; Default ; > ;
+ < "VarP (population)" ; Default ; > ;
+ };
+ };
+ Edit ED_DATA_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 106 ) ;
+ Size = MAP_APPFONT ( 104 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ Edit ED_DEST_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 135 ) ;
+ Size = MAP_APPFONT ( 104 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_DATA_AREA
+ {
+ Pos = MAP_APPFONT ( 206 , 105 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ImageButton RB_DEST_AREA
+ {
+ Pos = MAP_APPFONT ( 206 , 134 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ListBox LB_DATA_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 106 ) ;
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_DEST_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 135 ) ;
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ MultiListBox LB_CONSAREAS
+ {
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 46 ) ;
+ Size = MAP_APPFONT ( 212 , 43 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_FUNC
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "~Function" ;
+ };
+ FixedText FT_CONSAREAS
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "~Consolidation ranges" ;
+ };
+ FixedText FT_DATA_AREA
+ {
+ Pos = MAP_APPFONT ( 6 , 95 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "~Source data range" ;
+ };
+ FixedText FT_DEST_AREA
+ {
+ Pos = MAP_APPFONT ( 6 , 124 ) ;
+ Size = MAP_APPFONT ( 212 , 8 ) ;
+ Text [ en-US ] = "Copy results ~to" ;
+ };
+ CheckBox BTN_BYROW
+ {
+ Pos = MAP_APPFONT ( 12 , 165 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ Text [ en-US ] = "~Row labels" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_BYCOL
+ {
+ Pos = MAP_APPFONT ( 12 , 179 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "C~olumn labels" ;
+ };
+ FixedLine FL_CONSBY
+ {
+ Pos = MAP_APPFONT ( 6 , 154 ) ;
+ Size = MAP_APPFONT ( 103 , 8 ) ;
+ Text [ en-US ] = "Consolidate by" ;
+ };
+ FixedLine FL_SEP
+ {
+ Pos = MAP_APPFONT ( 112 , 165 ) ;
+ Size = MAP_APPFONT ( 1 , 24 ) ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 115 , 154 ) ;
+ Size = MAP_APPFONT ( 103 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ CheckBox BTN_REFS
+ {
+ Pos = MAP_APPFONT ( 121 , 165 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ Text [ en-US ] = "~Link to source data" ;
+ TabStop = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 224 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 224 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 224 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 224 , 134 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 41 ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 224 , 114 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 224 , 96 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Add" ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/sc/source/ui/dbgui/csvcontrol.cxx b/sc/source/ui/dbgui/csvcontrol.cxx
new file mode 100644
index 000000000000..f69410eac2a8
--- /dev/null
+++ b/sc/source/ui/dbgui/csvcontrol.cxx
@@ -0,0 +1,339 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvcontrol.hxx"
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include "AccessibleCsvControl.hxx"
+
+
+// ============================================================================
+
+ScCsvLayoutData::ScCsvLayoutData() :
+ mnPosCount( 1 ),
+ mnPosOffset( 0 ),
+ mnWinWidth( 1 ),
+ mnHdrWidth( 0 ),
+ mnCharWidth( 1 ),
+ mnLineCount( 1 ),
+ mnLineOffset( 0 ),
+ mnWinHeight( 1 ),
+ mnHdrHeight( 0 ),
+ mnLineHeight( 1 ),
+ mnPosCursor( CSV_POS_INVALID ),
+ mnColCursor( 0 ),
+ mnNoRepaint( 0 ),
+ mbAppRTL( !!Application::GetSettings().GetLayoutRTL() )
+{
+}
+
+ScCsvDiff ScCsvLayoutData::GetDiff( const ScCsvLayoutData& rData ) const
+{
+ ScCsvDiff nRet = CSV_DIFF_EQUAL;
+ if( mnPosCount != rData.mnPosCount ) nRet |= CSV_DIFF_POSCOUNT;
+ if( mnPosOffset != rData.mnPosOffset ) nRet |= CSV_DIFF_POSOFFSET;
+ if( mnHdrWidth != rData.mnHdrWidth ) nRet |= CSV_DIFF_HDRWIDTH;
+ if( mnCharWidth != rData.mnCharWidth ) nRet |= CSV_DIFF_CHARWIDTH;
+ if( mnLineCount != rData.mnLineCount ) nRet |= CSV_DIFF_LINECOUNT;
+ if( mnLineOffset != rData.mnLineOffset ) nRet |= CSV_DIFF_LINEOFFSET;
+ if( mnHdrHeight != rData.mnHdrHeight ) nRet |= CSV_DIFF_HDRHEIGHT;
+ if( mnLineHeight != rData.mnLineHeight ) nRet |= CSV_DIFF_LINEHEIGHT;
+ if( mnPosCursor != rData.mnPosCursor ) nRet |= CSV_DIFF_RULERCURSOR;
+ if( mnColCursor != rData.mnColCursor ) nRet |= CSV_DIFF_GRIDCURSOR;
+ return nRet;
+}
+
+
+// ============================================================================
+
+ScCsvControl::ScCsvControl( ScCsvControl& rParent ) :
+ Control( &rParent, WB_TABSTOP | WB_NODIALOGCONTROL ),
+ mrData( rParent.GetLayoutData() ),
+ mpAccessible( NULL ),
+ mbValidGfx( false )
+{
+}
+
+ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle ) :
+ Control( pParent, nStyle ),
+ mrData( rData ),
+ mpAccessible( NULL ),
+ mbValidGfx( false )
+{
+}
+
+ScCsvControl::ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId ) :
+ Control( pParent, rResId ),
+ mrData( rData ),
+ mpAccessible( NULL ),
+ mbValidGfx( false )
+{
+}
+
+ScCsvControl::~ScCsvControl()
+{
+ if( mpAccessible )
+ mpAccessible->dispose();
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvControl::GetFocus()
+{
+ Control::GetFocus();
+ AccSendFocusEvent( true );
+}
+
+void ScCsvControl::LoseFocus()
+{
+ Control::LoseFocus();
+ AccSendFocusEvent( false );
+}
+
+void ScCsvControl::AccSendFocusEvent( bool bFocused )
+{
+ if( mpAccessible )
+ mpAccessible->SendFocusEvent( bFocused );
+}
+
+void ScCsvControl::AccSendCaretEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendCaretEvent();
+}
+
+void ScCsvControl::AccSendVisibleEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendVisibleEvent();
+}
+
+void ScCsvControl::AccSendSelectionEvent()
+{
+ if( mpAccessible )
+ mpAccessible->SendSelectionEvent();
+}
+
+void ScCsvControl::AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows )
+{
+ if( mpAccessible )
+ mpAccessible->SendTableUpdateEvent( nFirstColumn, nLastColumn, bAllRows );
+}
+
+void ScCsvControl::AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( mpAccessible )
+ mpAccessible->SendInsertColumnEvent( nFirstColumn, nLastColumn );
+}
+
+void ScCsvControl::AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn )
+{
+ if( mpAccessible )
+ mpAccessible->SendRemoveColumnEvent( nFirstColumn, nLastColumn );
+}
+
+
+// repaint helpers ------------------------------------------------------------
+
+void ScCsvControl::Repaint( bool bInvalidate )
+{
+ if( bInvalidate )
+ InvalidateGfx();
+ if( !IsNoRepaint() )
+ Execute( CSVCMD_REPAINT );
+}
+
+void ScCsvControl::DisableRepaint()
+{
+ ++mrData.mnNoRepaint;
+}
+
+void ScCsvControl::EnableRepaint( bool bInvalidate )
+{
+ DBG_ASSERT( IsNoRepaint(), "ScCsvControl::EnableRepaint - invalid call" );
+ --mrData.mnNoRepaint;
+ Repaint( bInvalidate );
+}
+
+
+// command handling -----------------------------------------------------------
+
+void ScCsvControl::Execute( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 )
+{
+ maCmd.Set( eType, nParam1, nParam2 );
+ maCmdHdl.Call( this );
+}
+
+
+// layout helpers -------------------------------------------------------------
+
+sal_Int32 ScCsvControl::GetVisPosCount() const
+{
+ return (mrData.mnWinWidth - GetHdrWidth()) / GetCharWidth();
+}
+
+sal_Int32 ScCsvControl::GetMaxPosOffset() const
+{
+ return Max( GetPosCount() - GetVisPosCount() + 2L, 0L );
+}
+
+bool ScCsvControl::IsValidSplitPos( sal_Int32 nPos ) const
+{
+ return (0 < nPos) && (nPos < GetPosCount() );
+}
+
+bool ScCsvControl::IsVisibleSplitPos( sal_Int32 nPos ) const
+{
+ return IsValidSplitPos( nPos ) && (GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos());
+}
+
+sal_Int32 ScCsvControl::GetHdrX() const
+{
+ return IsRTL() ? (mrData.mnWinWidth - GetHdrWidth()) : 0;
+}
+
+sal_Int32 ScCsvControl::GetFirstX() const
+{
+ return IsRTL() ? 0 : GetHdrWidth();
+}
+
+sal_Int32 ScCsvControl::GetLastX() const
+{
+ return mrData.mnWinWidth - (IsRTL() ? GetHdrWidth() : 0) - 1;
+}
+
+sal_Int32 ScCsvControl::GetX( sal_Int32 nPos ) const
+{
+ return GetFirstX() + (nPos - GetFirstVisPos()) * GetCharWidth();
+}
+
+sal_Int32 ScCsvControl::GetPosFromX( sal_Int32 nX ) const
+{
+ return (nX - GetFirstX() + GetCharWidth() / 2) / GetCharWidth() + GetFirstVisPos();
+}
+
+sal_Int32 ScCsvControl::GetVisLineCount() const
+{
+ return (mrData.mnWinHeight - GetHdrHeight() - 2) / GetLineHeight() + 1;
+}
+
+sal_Int32 ScCsvControl::GetLastVisLine() const
+{
+ return Min( GetFirstVisLine() + GetVisLineCount(), GetLineCount() ) - 1;
+}
+
+sal_Int32 ScCsvControl::GetMaxLineOffset() const
+{
+ return Max( GetLineCount() - GetVisLineCount() + 1L, 0L );
+}
+
+bool ScCsvControl::IsValidLine( sal_Int32 nLine ) const
+{
+ return (0 <= nLine) && (nLine < GetLineCount());
+}
+
+bool ScCsvControl::IsVisibleLine( sal_Int32 nLine ) const
+{
+ return IsValidLine( nLine ) && (GetFirstVisLine() <= nLine) && (nLine <= GetLastVisLine());
+}
+
+sal_Int32 ScCsvControl::GetY( sal_Int32 nLine ) const
+{
+ return GetHdrHeight() + (nLine - GetFirstVisLine()) * GetLineHeight();
+}
+
+sal_Int32 ScCsvControl::GetLineFromY( sal_Int32 nY ) const
+{
+ return (nY - GetHdrHeight()) / GetLineHeight() + GetFirstVisLine();
+}
+
+
+// static helpers -------------------------------------------------------------
+
+void ScCsvControl::ImplInvertRect( OutputDevice& rOutDev, const Rectangle& rRect )
+{
+ rOutDev.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR | PUSH_RASTEROP );
+ rOutDev.SetLineColor( Color( COL_BLACK ) );
+ rOutDev.SetFillColor( Color( COL_BLACK ) );
+ rOutDev.SetRasterOp( ROP_INVERT );
+ rOutDev.DrawRect( rRect );
+ rOutDev.Pop();
+}
+
+ScMoveMode ScCsvControl::GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd )
+{
+ switch( nCode )
+ {
+ case KEY_LEFT: return MOVE_PREV;
+ case KEY_RIGHT: return MOVE_NEXT;
+ }
+ if( bHomeEnd ) switch( nCode )
+ {
+ case KEY_HOME: return MOVE_FIRST;
+ case KEY_END: return MOVE_LAST;
+ }
+ return MOVE_NONE;
+}
+
+ScMoveMode ScCsvControl::GetVertDirection( sal_uInt16 nCode, bool bHomeEnd )
+{
+ switch( nCode )
+ {
+ case KEY_UP: return MOVE_PREV;
+ case KEY_DOWN: return MOVE_NEXT;
+ case KEY_PAGEUP: return MOVE_PREVPAGE;
+ case KEY_PAGEDOWN: return MOVE_NEXTPAGE;
+ }
+ if( bHomeEnd ) switch( nCode )
+ {
+ case KEY_HOME: return MOVE_FIRST;
+ case KEY_END: return MOVE_LAST;
+ }
+ return MOVE_NONE;
+}
+
+
+// accessibility --------------------------------------------------------------
+
+ScCsvControl::XAccessibleRef ScCsvControl::CreateAccessible()
+{
+ mpAccessible = ImplCreateAccessible();
+ mxAccessible = mpAccessible;
+ return mxAccessible;
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
new file mode 100644
index 000000000000..da1e5c2e2432
--- /dev/null
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -0,0 +1,1357 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvgrid.hxx"
+
+#include <algorithm>
+#include <svtools/colorcfg.hxx>
+#include <svl/smplhint.hxx>
+#include <tools/poly.hxx>
+#include "scmod.hxx"
+#include "asciiopt.hxx"
+#include "impex.hxx"
+#include "AccessibleCsvControl.hxx"
+
+// *** edit engine ***
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <editeng/colritem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <svl/itemset.hxx>
+#include "editutil.hxx"
+// *** edit engine ***
+
+
+// ============================================================================
+
+struct Func_SetType
+{
+ sal_Int32 mnType;
+ inline Func_SetType( sal_Int32 nType ) : mnType( nType ) {}
+ inline void operator()( ScCsvColState& rState ) { rState.mnType = mnType; }
+};
+
+struct Func_Select
+{
+ bool mbSelect;
+ inline Func_Select( bool bSelect ) : mbSelect( bSelect ) {}
+ inline void operator()( ScCsvColState& rState ) { rState.Select( mbSelect ); }
+};
+
+
+// ============================================================================
+
+ScCsvGrid::ScCsvGrid( ScCsvControl& rParent ) :
+ ScCsvControl( rParent ),
+ mrColorConfig( SC_MOD()->GetColorConfig() ),
+ mpEditEngine( new ScEditEngineDefaulter( EditEngine::CreatePool(), TRUE ) ),
+ maHeaderFont( GetFont() ),
+ maColStates( 1 ),
+ maTypeNames( 1 ),
+ mnFirstImpLine( 0 ),
+ mnRecentSelCol( CSV_COLUMN_INVALID )
+{
+ mpEditEngine->SetRefDevice( &maBackgrDev );
+ mpEditEngine->SetRefMapMode( MapMode( MAP_PIXEL ) );
+ maEdEngSize = mpEditEngine->GetPaperSize();
+
+ maPopup.SetMenuFlags( maPopup.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
+
+ EnableRTL( false ); // #107812# RTL
+ InitColors();
+ InitFonts();
+ ImplClearSplits();
+ mrColorConfig.AddListener(this);
+}
+
+ScCsvGrid::~ScCsvGrid()
+{
+ mrColorConfig.RemoveListener(this);
+}
+
+
+// common grid handling -------------------------------------------------------
+
+void ScCsvGrid::UpdateLayoutData()
+{
+ DisableRepaint();
+ SetFont( maMonoFont );
+ Execute( CSVCMD_SETCHARWIDTH, GetTextWidth( String( 'X' ) ) );
+ Execute( CSVCMD_SETLINEHEIGHT, GetTextHeight() + 1 );
+ SetFont( maHeaderFont );
+ Execute( CSVCMD_SETHDRHEIGHT, GetTextHeight() + 1 );
+ UpdateOffsetX();
+ EnableRepaint();
+}
+
+void ScCsvGrid::UpdateOffsetX()
+{
+ sal_Int32 nLastLine = GetLastVisLine() + 1;
+ sal_Int32 nDigits = 2;
+ while( nLastLine /= 10 ) ++nDigits;
+ nDigits = Max( nDigits, sal_Int32( 3 ) );
+ Execute( CSVCMD_SETHDRWIDTH, GetTextWidth( String( '0' ) ) * nDigits );
+}
+
+void ScCsvGrid::ApplyLayout( const ScCsvLayoutData& rOldData )
+{
+ ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData );
+ if( nDiff == CSV_DIFF_EQUAL ) return;
+
+ DisableRepaint();
+
+ if( nDiff & CSV_DIFF_RULERCURSOR )
+ {
+ ImplInvertCursor( rOldData.mnPosCursor );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+
+ if( nDiff & CSV_DIFF_POSCOUNT )
+ {
+ if( GetPosCount() < rOldData.mnPosCount )
+ {
+ SelectAll( false );
+ maSplits.RemoveRange( GetPosCount(), rOldData.mnPosCount );
+ }
+ else
+ maSplits.Remove( rOldData.mnPosCount );
+ maSplits.Insert( GetPosCount() );
+ maColStates.resize( maSplits.Count() - 1 );
+ }
+
+ if( nDiff & CSV_DIFF_LINEOFFSET )
+ {
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ UpdateOffsetX();
+ }
+
+ ScCsvDiff nHVDiff = nDiff & (CSV_DIFF_HORIZONTAL | CSV_DIFF_VERTICAL);
+ if( nHVDiff == CSV_DIFF_POSOFFSET )
+ ImplDrawHorzScrolled( rOldData.mnPosOffset );
+ else if( nHVDiff != CSV_DIFF_EQUAL )
+ InvalidateGfx();
+
+ EnableRepaint();
+
+ if( nDiff & (CSV_DIFF_POSOFFSET | CSV_DIFF_LINEOFFSET) )
+ AccSendVisibleEvent();
+}
+
+void ScCsvGrid::SetFirstImportedLine( sal_Int32 nLine )
+{
+ ImplDrawFirstLineSep( false );
+ mnFirstImpLine = nLine;
+ ImplDrawFirstLineSep( true );
+ ImplDrawGridDev();
+ Repaint();
+}
+
+sal_Int32 ScCsvGrid::GetNoScrollCol( sal_Int32 nPos ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != CSV_POS_INVALID )
+ {
+ if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
+ nNewPos = GetFirstVisPos() + nScroll;
+ }
+ else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1L )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
+ nNewPos = GetLastVisPos() - nScroll - 1;
+ }
+ }
+ return nNewPos;
+}
+
+void ScCsvGrid::InitColors()
+{
+ maBackColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::DOCCOLOR ).nColor ) );
+ maGridColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::CALCGRID ).nColor ) );
+ maGridPBColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::CALCPAGEBREAK ).nColor ) );
+ maAppBackColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::APPBACKGROUND ).nColor ) );
+ maTextColor.SetColor( static_cast< sal_uInt32 >( mrColorConfig.GetColorValue( ::svtools::FONTCOLOR ).nColor ) );
+
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ maHeaderBackColor = rSett.GetFaceColor();
+ maHeaderGridColor = rSett.GetDarkShadowColor();
+ maHeaderTextColor = rSett.GetButtonTextColor();
+ maSelectColor = rSett.GetActiveColor();
+
+ InvalidateGfx();
+}
+
+void ScCsvGrid::InitFonts()
+{
+ maMonoFont = OutputDevice::GetDefaultFont( DEFAULTFONT_FIXED, LANGUAGE_ENGLISH_US, 0 );
+ maMonoFont.SetSize( Size( maMonoFont.GetSize().Width(), maHeaderFont.GetSize().Height() ) );
+
+ /* *** Set edit engine defaults ***
+ maMonoFont for Latin script, smaller default font for Asian and Complex script. */
+
+ // get default fonts
+ SvxFontItem aLatinItem( EE_CHAR_FONTINFO );
+ SvxFontItem aAsianItem( EE_CHAR_FONTINFO_CJK );
+ SvxFontItem aComplexItem( EE_CHAR_FONTINFO_CTL );
+ ::GetDefaultFonts( aLatinItem, aAsianItem, aComplexItem );
+
+ // create item set for defaults
+ SfxItemSet aDefSet( mpEditEngine->GetEmptyItemSet() );
+ EditEngine::SetFontInfoInItemSet( aDefSet, maMonoFont );
+ aDefSet.Put( aAsianItem );
+ aDefSet.Put( aComplexItem );
+
+ // set Asian/Complex font size to height of character in Latin font
+ ULONG nFontHt = static_cast< ULONG >( maMonoFont.GetSize().Height() );
+ aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ aDefSet.Put( SvxFontHeightItem( nFontHt, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+
+ // copy other items from default font
+ const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
+ aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
+ aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
+ const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
+ aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
+ aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
+ const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
+ aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
+ aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
+
+ mpEditEngine->SetDefaults( aDefSet );
+ InvalidateGfx();
+}
+
+void ScCsvGrid::InitSizeData()
+{
+ maWinSize = GetSizePixel();
+ maBackgrDev.SetOutputSizePixel( maWinSize );
+ maGridDev.SetOutputSizePixel( maWinSize );
+ InvalidateGfx();
+}
+
+
+// split handling -------------------------------------------------------------
+
+void ScCsvGrid::InsertSplit( sal_Int32 nPos )
+{
+ if( ImplInsertSplit( nPos ) )
+ {
+ DisableRepaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ ImplDrawColumn( nColIx - 1 );
+ ImplDrawColumn( nColIx );
+ ValidateGfx(); // performance: do not redraw all columns
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::RemoveSplit( sal_Int32 nPos )
+{
+ if( ImplRemoveSplit( nPos ) )
+ {
+ DisableRepaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ ImplDrawColumn( GetColumnFromPos( nPos ) );
+ ValidateGfx(); // performance: do not redraw all columns
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
+{
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ if( nColIx != CSV_COLUMN_INVALID )
+ {
+ DisableRepaint();
+ if( (GetColumnPos( nColIx - 1 ) < nNewPos) && (nNewPos < GetColumnPos( nColIx + 1 )) )
+ {
+ // move a split in the range between 2 others -> keep selection state of both columns
+ maSplits.Remove( nPos );
+ maSplits.Insert( nNewPos );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ ImplDrawColumn( nColIx - 1 );
+ ImplDrawColumn( nColIx );
+ ValidateGfx(); // performance: do not redraw all columns
+ AccSendTableUpdateEvent( nColIx - 1, nColIx );
+ }
+ else
+ {
+ ImplRemoveSplit( nPos );
+ ImplInsertSplit( nNewPos );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ }
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::RemoveAllSplits()
+{
+ DisableRepaint();
+ ImplClearSplits();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ EnableRepaint();
+}
+
+void ScCsvGrid::SetSplits( const ScCsvSplits& rSplits )
+{
+ DisableRepaint();
+ ImplClearSplits();
+ sal_uInt32 nCount = rSplits.Count();
+ for( sal_uInt32 nIx = 0; nIx < nCount; ++nIx )
+ maSplits.Insert( rSplits[ nIx ] );
+ maColStates.clear();
+ maColStates.resize( maSplits.Count() - 1 );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ EnableRepaint();
+}
+
+bool ScCsvGrid::ImplInsertSplit( sal_Int32 nPos )
+{
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ bool bRet = (nColIx < GetColumnCount()) && maSplits.Insert( nPos );
+ if( bRet )
+ {
+ ScCsvColState aState( GetColumnType( nColIx ) );
+ aState.Select( IsSelected( nColIx ) && IsSelected( nColIx + 1 ) );
+ maColStates.insert( maColStates.begin() + nColIx + 1, aState );
+ AccSendInsertColumnEvent( nColIx + 1, nColIx + 1 );
+ AccSendTableUpdateEvent( nColIx, nColIx );
+ }
+ return bRet;
+}
+
+bool ScCsvGrid::ImplRemoveSplit( sal_Int32 nPos )
+{
+ bool bRet = maSplits.Remove( nPos );
+ if( bRet )
+ {
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ bool bSel = IsSelected( nColIx ) || IsSelected( nColIx + 1 );
+ maColStates.erase( maColStates.begin() + nColIx + 1 );
+ maColStates[ nColIx ].Select( bSel );
+ AccSendRemoveColumnEvent( nColIx + 1, nColIx + 1 );
+ AccSendTableUpdateEvent( nColIx, nColIx );
+ }
+ return bRet;
+}
+
+void ScCsvGrid::ImplClearSplits()
+{
+ sal_uInt32 nColumns = GetColumnCount();
+ maSplits.Clear();
+ maSplits.Insert( 0 );
+ maSplits.Insert( GetPosCount() );
+ maColStates.resize( 1 );
+ InvalidateGfx();
+ AccSendRemoveColumnEvent( 1, nColumns - 1 );
+}
+
+// columns/column types -------------------------------------------------------
+
+sal_uInt32 ScCsvGrid::GetFirstVisColumn() const
+{
+ return GetColumnFromPos( GetFirstVisPos() );
+}
+
+sal_uInt32 ScCsvGrid::GetLastVisColumn() const
+{
+ return GetColumnFromPos( Min( GetLastVisPos(), GetPosCount() ) - 1 );
+}
+
+bool ScCsvGrid::IsValidColumn( sal_uInt32 nColIndex ) const
+{
+ return nColIndex < GetColumnCount();
+}
+
+bool ScCsvGrid::IsVisibleColumn( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) &&
+ (GetColumnPos( nColIndex ) < GetLastVisPos()) &&
+ (GetFirstVisPos() < GetColumnPos( nColIndex + 1 ));
+}
+
+sal_Int32 ScCsvGrid::GetColumnX( sal_uInt32 nColIndex ) const
+{
+ return GetX( GetColumnPos( nColIndex ) );
+}
+
+sal_uInt32 ScCsvGrid::GetColumnFromX( sal_Int32 nX ) const
+{
+ sal_Int32 nPos = (nX - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
+ return ((GetFirstVisPos() <= nPos) && (nPos <= GetLastVisPos())) ?
+ GetColumnFromPos( nPos ) : CSV_COLUMN_INVALID;
+}
+
+sal_uInt32 ScCsvGrid::GetColumnFromPos( sal_Int32 nPos ) const
+{
+ return maSplits.UpperBound( nPos );
+}
+
+sal_Int32 ScCsvGrid::GetColumnWidth( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) ? (GetColumnPos( nColIndex + 1 ) - GetColumnPos( nColIndex )) : 0;
+}
+
+void ScCsvGrid::SetColumnStates( const ScCsvColStateVec& rStates )
+{
+ maColStates = rStates;
+ maColStates.resize( maSplits.Count() - 1 );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ AccSendTableUpdateEvent( 0, GetColumnCount(), false );
+ AccSendSelectionEvent();
+}
+
+sal_Int32 ScCsvGrid::GetColumnType( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) ? maColStates[ nColIndex ].mnType : CSV_TYPE_NOSELECTION;
+}
+
+void ScCsvGrid::SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType )
+{
+ if( IsValidColumn( nColIndex ) )
+ {
+ maColStates[ nColIndex ].mnType = nColType;
+ AccSendTableUpdateEvent( nColIndex, nColIndex, false );
+ }
+}
+
+sal_Int32 ScCsvGrid::GetSelColumnType() const
+{
+ sal_uInt32 nColIx = GetFirstSelected();
+ if( nColIx == CSV_COLUMN_INVALID )
+ return CSV_TYPE_NOSELECTION;
+
+ sal_Int32 nType = GetColumnType( nColIx );
+ while( (nColIx != CSV_COLUMN_INVALID) && (nType != CSV_TYPE_MULTI) )
+ {
+ if( nType != GetColumnType( nColIx ) )
+ nType = CSV_TYPE_MULTI;
+ nColIx = GetNextSelected( nColIx );
+ }
+ return nType;
+}
+
+void ScCsvGrid::SetSelColumnType( sal_Int32 nType )
+{
+ if( (nType != CSV_TYPE_MULTI) && (nType != CSV_TYPE_NOSELECTION) )
+ {
+ for( sal_uInt32 nColIx = GetFirstSelected(); nColIx != CSV_COLUMN_INVALID; nColIx = GetNextSelected( nColIx ) )
+ SetColumnType( nColIx, nType );
+ Repaint( true );
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ }
+}
+
+void ScCsvGrid::SetTypeNames( const StringVec& rTypeNames )
+{
+ DBG_ASSERT( !rTypeNames.empty(), "ScCsvGrid::SetTypeNames - vector is empty" );
+ maTypeNames = rTypeNames;
+ Repaint( true );
+
+ maPopup.Clear();
+ sal_uInt32 nCount = maTypeNames.size();
+ sal_uInt32 nIx;
+ sal_uInt16 nItemId;
+ for( nIx = 0, nItemId = 1; nIx < nCount; ++nIx, ++nItemId )
+ maPopup.InsertItem( nItemId, maTypeNames[ nIx ] );
+
+ ::std::for_each( maColStates.begin(), maColStates.end(), Func_SetType( CSV_TYPE_DEFAULT ) );
+}
+
+const String& ScCsvGrid::GetColumnTypeName( sal_uInt32 nColIndex ) const
+{
+ sal_uInt32 nTypeIx = static_cast< sal_uInt32 >( GetColumnType( nColIndex ) );
+ return (nTypeIx < maTypeNames.size()) ? maTypeNames[ nTypeIx ] : EMPTY_STRING;
+}
+
+sal_uInt8 lcl_GetExtColumnType( sal_Int32 nIntType )
+{
+ static sal_uInt8 pExtTypes[] =
+ { SC_COL_STANDARD, SC_COL_TEXT, SC_COL_DMY, SC_COL_MDY, SC_COL_YMD, SC_COL_ENGLISH, SC_COL_SKIP };
+ static sal_Int32 nExtTypeCount = sizeof( pExtTypes ) / sizeof( *pExtTypes );
+ return pExtTypes[ ((0 <= nIntType) && (nIntType < nExtTypeCount)) ? nIntType : 0 ];
+}
+
+void ScCsvGrid::FillColumnDataSep( ScAsciiOptions& rOptions ) const
+{
+ sal_uInt32 nCount = GetColumnCount();
+ ScCsvExpDataVec aDataVec;
+
+ for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
+ {
+ if( GetColumnType( nColIx ) != CSV_TYPE_DEFAULT )
+ // 1-based column index
+ aDataVec.push_back( ScCsvExpData(
+ static_cast< xub_StrLen >( nColIx + 1 ),
+ lcl_GetExtColumnType( GetColumnType( nColIx ) ) ) );
+ }
+ rOptions.SetColumnInfo( aDataVec );
+}
+
+void ScCsvGrid::FillColumnDataFix( ScAsciiOptions& rOptions ) const
+{
+ sal_uInt32 nCount = Min( GetColumnCount(), static_cast<sal_uInt32>(MAXCOLCOUNT) );
+ ScCsvExpDataVec aDataVec( nCount + 1 );
+
+ for( sal_uInt32 nColIx = 0; nColIx < nCount; ++nColIx )
+ {
+ ScCsvExpData& rData = aDataVec[ nColIx ];
+ rData.mnIndex = static_cast< xub_StrLen >(
+ Min( static_cast< sal_Int32 >( STRING_MAXLEN ), GetColumnPos( nColIx ) ) );
+ rData.mnType = lcl_GetExtColumnType( GetColumnType( nColIx ) );
+ }
+ aDataVec[ nCount ].mnIndex = STRING_MAXLEN;
+ aDataVec[ nCount ].mnType = SC_COL_SKIP;
+ rOptions.SetColumnInfo( aDataVec );
+}
+
+void ScCsvGrid::ScrollVertRel( ScMoveMode eDir )
+{
+ sal_Int32 nLine = GetFirstVisLine();
+ switch( eDir )
+ {
+ case MOVE_PREV: --nLine; break;
+ case MOVE_NEXT: ++nLine; break;
+ case MOVE_FIRST: nLine = 0; break;
+ case MOVE_LAST: nLine = GetMaxLineOffset(); break;
+ case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 2; break;
+ case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 2; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ Execute( CSVCMD_SETLINEOFFSET, nLine );
+}
+
+void ScCsvGrid::ExecutePopup( const Point& rPos )
+{
+ sal_uInt16 nItemId = maPopup.Execute( this, rPos );
+ if( nItemId ) // 0 = cancelled
+ Execute( CSVCMD_SETCOLUMNTYPE, maPopup.GetItemPos( nItemId ) );
+}
+
+
+// selection handling ---------------------------------------------------------
+
+bool ScCsvGrid::IsSelected( sal_uInt32 nColIndex ) const
+{
+ return IsValidColumn( nColIndex ) && maColStates[ nColIndex ].IsSelected();
+}
+
+sal_uInt32 ScCsvGrid::GetFirstSelected() const
+{
+ return IsSelected( 0 ) ? 0 : GetNextSelected( 0 );
+}
+
+sal_uInt32 ScCsvGrid::GetNextSelected( sal_uInt32 nFromIndex ) const
+{
+ sal_uInt32 nColCount = GetColumnCount();
+ for( sal_uInt32 nColIx = nFromIndex + 1; nColIx < nColCount; ++nColIx )
+ if( IsSelected( nColIx ) )
+ return nColIx;
+ return CSV_COLUMN_INVALID;
+}
+
+void ScCsvGrid::Select( sal_uInt32 nColIndex, bool bSelect )
+{
+ if( IsValidColumn( nColIndex ) )
+ {
+ maColStates[ nColIndex ].Select( bSelect );
+ ImplDrawColumnSelection( nColIndex );
+ Repaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ if( bSelect )
+ mnRecentSelCol = nColIndex;
+ AccSendSelectionEvent();
+ }
+}
+
+void ScCsvGrid::ToggleSelect( sal_uInt32 nColIndex )
+{
+ Select( nColIndex, !IsSelected( nColIndex ) );
+}
+
+void ScCsvGrid::SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect )
+{
+ if( nColIndex1 == CSV_COLUMN_INVALID )
+ Select( nColIndex2 );
+ else if( nColIndex2 == CSV_COLUMN_INVALID )
+ Select( nColIndex1 );
+ else if( nColIndex1 > nColIndex2 )
+ {
+ SelectRange( nColIndex2, nColIndex1, bSelect );
+ if( bSelect )
+ mnRecentSelCol = nColIndex1;
+ }
+ else if( IsValidColumn( nColIndex1 ) && IsValidColumn( nColIndex2 ) )
+ {
+ for( sal_uInt32 nColIx = nColIndex1; nColIx <= nColIndex2; ++nColIx )
+ {
+ maColStates[ nColIx ].Select( bSelect );
+ ImplDrawColumnSelection( nColIx );
+ }
+ Repaint();
+ Execute( CSVCMD_EXPORTCOLUMNTYPE );
+ if( bSelect )
+ mnRecentSelCol = nColIndex1;
+ AccSendSelectionEvent();
+ }
+}
+
+void ScCsvGrid::SelectAll( bool bSelect )
+{
+ SelectRange( 0, GetColumnCount() - 1, bSelect );
+}
+
+void ScCsvGrid::MoveCursor( sal_uInt32 nColIndex )
+{
+ DisableRepaint();
+ if( IsValidColumn( nColIndex ) )
+ {
+ sal_Int32 nPosBeg = GetColumnPos( nColIndex );
+ sal_Int32 nPosEnd = GetColumnPos( nColIndex + 1 );
+ sal_Int32 nMinPos = Max( nPosBeg - CSV_SCROLL_DIST, sal_Int32( 0 ) );
+ sal_Int32 nMaxPos = Min( nPosEnd - GetVisPosCount() + CSV_SCROLL_DIST + sal_Int32( 1 ), nMinPos );
+ if( nPosBeg - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nMinPos );
+ else if( nPosEnd + CSV_SCROLL_DIST >= GetLastVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nMaxPos );
+ }
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
+ EnableRepaint();
+}
+
+void ScCsvGrid::MoveCursorRel( ScMoveMode eDir )
+{
+ if( GetFocusColumn() != CSV_COLUMN_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ MoveCursor( 0 );
+ break;
+ case MOVE_LAST:
+ MoveCursor( GetColumnCount() - 1 );
+ break;
+ case MOVE_PREV:
+ if( GetFocusColumn() > 0 )
+ MoveCursor( GetFocusColumn() - 1 );
+ break;
+ case MOVE_NEXT:
+ if( GetFocusColumn() < GetColumnCount() - 1 )
+ MoveCursor( GetFocusColumn() + 1 );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+}
+
+void ScCsvGrid::ImplClearSelection()
+{
+ ::std::for_each( maColStates.begin(), maColStates.end(), Func_Select( false ) );
+ ImplDrawGridDev();
+}
+
+void ScCsvGrid::DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier )
+{
+ if( !(nModifier & KEY_MOD1) )
+ ImplClearSelection();
+ if( nModifier & KEY_SHIFT ) // SHIFT always expands
+ SelectRange( mnRecentSelCol, nColIndex );
+ else if( !(nModifier & KEY_MOD1) ) // no SHIFT/CTRL always selects 1 column
+ Select( nColIndex );
+ else if( IsTracking() ) // CTRL in tracking does not toggle
+ Select( nColIndex, mbMTSelecting );
+ else // CTRL only toggles
+ ToggleSelect( nColIndex );
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetColumnPos( nColIndex ) );
+}
+
+
+// cell contents --------------------------------------------------------------
+
+void ScCsvGrid::ImplSetTextLineSep(
+ sal_Int32 nLine, const String& rTextLine,
+ const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep )
+{
+ if( nLine < GetFirstVisLine() ) return;
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ while( maTexts.size() <= nLineIx )
+ maTexts.push_back( StringVec() );
+ StringVec& rStrVec = maTexts[ nLineIx ];
+ rStrVec.clear();
+
+ // scan for separators
+ String aCellText;
+ const sal_Unicode* pSepChars = rSepChars.GetBuffer();
+ const sal_Unicode* pChar = rTextLine.GetBuffer();
+ sal_uInt32 nColIx = 0;
+
+ while( *pChar && (nColIx < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT)) )
+ {
+ // scan for next cell text
+ bool bIsQuoted = false;
+ pChar = ScImportExport::ScanNextFieldFromString( pChar, aCellText, cTextSep, pSepChars, bMergeSep, bIsQuoted );
+
+ // update column width
+ sal_Int32 nWidth = Max( CSV_MINCOLWIDTH, aCellText.Len() + sal_Int32( 1 ) );
+ if( IsValidColumn( nColIx ) )
+ {
+ // expand existing column
+ sal_Int32 nDiff = nWidth - GetColumnWidth( nColIx );
+ if( nDiff > 0 )
+ {
+ Execute( CSVCMD_SETPOSCOUNT, GetPosCount() + nDiff );
+ for( sal_uInt32 nSplitIx = GetColumnCount() - 1; nSplitIx > nColIx; --nSplitIx )
+ {
+ sal_Int32 nPos = maSplits[ nSplitIx ];
+ maSplits.Remove( nPos );
+ maSplits.Insert( nPos + nDiff );
+ }
+ }
+ }
+ else
+ {
+ // append new column
+ sal_Int32 nLastPos = GetPosCount();
+ Execute( CSVCMD_SETPOSCOUNT, nLastPos + nWidth );
+ ImplInsertSplit( nLastPos );
+ }
+
+ if( aCellText.Len() <= CSV_MAXSTRLEN )
+ rStrVec.push_back( aCellText );
+ else
+ rStrVec.push_back( aCellText.Copy( 0, CSV_MAXSTRLEN ) );
+ ++nColIx;
+ }
+ InvalidateGfx();
+}
+
+void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine )
+{
+ if( nLine < GetFirstVisLine() ) return;
+
+ sal_Int32 nChars = rTextLine.Len();
+ if( nChars > GetPosCount() )
+ Execute( CSVCMD_SETPOSCOUNT, nChars );
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ while( maTexts.size() <= nLineIx )
+ maTexts.push_back( StringVec() );
+
+ StringVec& rStrVec = maTexts[ nLineIx ];
+ rStrVec.clear();
+ sal_uInt32 nColCount = GetColumnCount();
+ xub_StrLen nStrLen = rTextLine.Len();
+ xub_StrLen nStrIx = 0;
+ for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx )
+ {
+ xub_StrLen nColWidth = static_cast< xub_StrLen >( GetColumnWidth( nColIx ) );
+ rStrVec.push_back( rTextLine.Copy( nStrIx, Max( nColWidth, CSV_MAXSTRLEN ) ) );
+ nStrIx = sal::static_int_cast<xub_StrLen>( nStrIx + nColWidth );
+ }
+ InvalidateGfx();
+}
+
+const String& ScCsvGrid::GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const
+{
+ if( nLine < GetFirstVisLine() ) return EMPTY_STRING;
+
+ sal_uInt32 nLineIx = nLine - GetFirstVisLine();
+ if( nLineIx >= maTexts.size() ) return EMPTY_STRING;
+
+ const StringVec& rStrVec = maTexts[ nLineIx ];
+ if( nColIndex >= rStrVec.size() ) return EMPTY_STRING;
+
+ return rStrVec[ nColIndex ];
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvGrid::Resize()
+{
+ ScCsvControl::Resize();
+ InitSizeData();
+ Execute( CSVCMD_UPDATECELLTEXTS );
+}
+
+void ScCsvGrid::GetFocus()
+{
+ ScCsvControl::GetFocus();
+ Execute( CSVCMD_MOVEGRIDCURSOR, GetNoScrollCol( GetGridCursorPos() ) );
+ Repaint();
+}
+
+void ScCsvGrid::LoseFocus()
+{
+ ScCsvControl::LoseFocus();
+ Repaint();
+}
+
+void ScCsvGrid::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ DisableRepaint();
+ if( !HasFocus() )
+ GrabFocus();
+
+ Point aPos( rMEvt.GetPosPixel() );
+ sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
+
+ if( rMEvt.IsLeft() )
+ {
+ if( (GetFirstX() > aPos.X()) || (aPos.X() > GetLastX()) ) // in header column
+ {
+ if( aPos.Y() <= GetHdrHeight() )
+ SelectAll();
+ }
+ else if( IsValidColumn( nColIx ) )
+ {
+ DoSelectAction( nColIx, rMEvt.GetModifier() );
+ mnMTCurrCol = nColIx;
+ mbMTSelecting = IsSelected( nColIx );
+ StartTracking( STARTTRACK_BUTTONREPEAT );
+ }
+ }
+ EnableRepaint();
+}
+
+void ScCsvGrid::Tracking( const TrackingEvent& rTEvt )
+{
+ if( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingRepeat() )
+ {
+ DisableRepaint();
+ const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
+
+ sal_Int32 nPos = (rMEvt.GetPosPixel().X() - GetFirstX()) / GetCharWidth() + GetFirstVisPos();
+ // on mouse tracking: keep position valid
+ nPos = Max( Min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 0 ) );
+ Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
+
+ sal_uInt32 nColIx = GetColumnFromPos( nPos );
+ if( mnMTCurrCol != nColIx )
+ {
+ DoSelectAction( nColIx, rMEvt.GetModifier() );
+ mnMTCurrCol = nColIx;
+ }
+ EnableRepaint();
+ }
+}
+
+void ScCsvGrid::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = rKCode.GetCode();
+ bool bShift = rKCode.IsShift() == TRUE;
+ bool bMod1 = rKCode.IsMod1() == TRUE;
+
+ if( !rKCode.IsMod2() )
+ {
+ ScMoveMode eHDir = GetHorzDirection( nCode, !bMod1 );
+ ScMoveMode eVDir = GetVertDirection( nCode, bMod1 );
+
+ if( eHDir != MOVE_NONE )
+ {
+ DisableRepaint();
+ MoveCursorRel( eHDir );
+ if( !bMod1 )
+ ImplClearSelection();
+ if( bShift )
+ SelectRange( mnRecentSelCol, GetFocusColumn() );
+ else if( !bMod1 )
+ Select( GetFocusColumn() );
+ EnableRepaint();
+ }
+ else if( eVDir != MOVE_NONE )
+ ScrollVertRel( eVDir );
+ else if( nCode == KEY_SPACE )
+ {
+ if( !bMod1 )
+ ImplClearSelection();
+ if( bShift )
+ SelectRange( mnRecentSelCol, GetFocusColumn() );
+ else if( bMod1 )
+ ToggleSelect( GetFocusColumn() );
+ else
+ Select( GetFocusColumn() );
+ }
+ else if( !bShift && bMod1 )
+ {
+ if( nCode == KEY_A )
+ SelectAll();
+ else if( (KEY_1 <= nCode) && (nCode <= KEY_9) )
+ {
+ sal_uInt32 nType = nCode - KEY_1;
+ if( nType < maTypeNames.size() )
+ Execute( CSVCMD_SETCOLUMNTYPE, nType );
+ }
+ }
+ }
+
+ if( rKCode.GetGroup() != KEYGROUP_CURSOR )
+ ScCsvControl::KeyInput( rKEvt );
+}
+
+void ScCsvGrid::Command( const CommandEvent& rCEvt )
+{
+ switch( rCEvt.GetCommand() )
+ {
+ case COMMAND_CONTEXTMENU:
+ {
+ if( rCEvt.IsMouseEvent() )
+ {
+ Point aPos( rCEvt.GetMousePosPixel() );
+ sal_uInt32 nColIx = GetColumnFromX( aPos.X() );
+ if( IsValidColumn( nColIx ) && (GetFirstX() <= aPos.X()) && (aPos.X() <= GetLastX()) )
+ {
+ if( !IsSelected( nColIx ) )
+ DoSelectAction( nColIx, 0 ); // focus & select
+ ExecutePopup( aPos );
+ }
+ }
+ else
+ {
+ sal_uInt32 nColIx = GetFocusColumn();
+ if( !IsSelected( nColIx ) )
+ Select( nColIx );
+ sal_Int32 nX1 = Max( GetColumnX( nColIx ), GetFirstX() );
+ sal_Int32 nX2 = Min( GetColumnX( nColIx + 1 ), GetWidth() );
+ ExecutePopup( Point( (nX1 + nX2) / 2, GetHeight() / 2 ) );
+ }
+ }
+ break;
+ case COMMAND_WHEEL:
+ {
+ Point aPoint;
+ Rectangle aRect( aPoint, maWinSize );
+ if( aRect.IsInside( rCEvt.GetMousePosPixel() ) )
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if( pData && (pData->GetMode() == COMMAND_WHEEL_SCROLL) && !pData->IsHorz() )
+ Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() - pData->GetNotchDelta() );
+ }
+ }
+ break;
+ default:
+ ScCsvControl::Command( rCEvt );
+ }
+}
+
+void ScCsvGrid::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitColors();
+ InitFonts();
+ UpdateLayoutData();
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ }
+ ScCsvControl::DataChanged( rDCEvt );
+}
+
+void ScCsvGrid::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
+{
+ InitColors();
+ Repaint();
+}
+
+
+// painting -------------------------------------------------------------------
+
+void ScCsvGrid::Paint( const Rectangle& )
+{
+ Repaint();
+}
+
+void ScCsvGrid::ImplRedraw()
+{
+ if( IsVisible() )
+ {
+ if( !IsValidGfx() )
+ {
+ ValidateGfx();
+ ImplDrawBackgrDev();
+ ImplDrawGridDev();
+ }
+ DrawOutDev( Point(), maWinSize, Point(), maWinSize, maGridDev );
+ ImplDrawTrackingRect( GetFocusColumn() );
+ }
+}
+
+EditEngine* ScCsvGrid::GetEditEngine()
+{
+ return mpEditEngine.get();
+}
+
+void ScCsvGrid::ImplSetColumnClipRegion( OutputDevice& rOutDev, sal_uInt32 nColIndex )
+{
+ rOutDev.SetClipRegion( Region( Rectangle(
+ Max( GetColumnX( nColIndex ), GetFirstX() ) + 1, 0,
+ Min( GetColumnX( nColIndex + 1 ), GetLastX() ), GetHeight() - 1 ) ) );
+}
+
+void ScCsvGrid::ImplDrawColumnHeader( OutputDevice& rOutDev, sal_uInt32 nColIndex, Color aFillColor )
+{
+ sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
+ sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
+ sal_Int32 nHdrHt = GetHdrHeight();
+
+ rOutDev.SetLineColor();
+ rOutDev.SetFillColor( aFillColor );
+ rOutDev.DrawRect( Rectangle( nX1, 0, nX2, nHdrHt ) );
+
+ rOutDev.SetFont( maHeaderFont );
+ rOutDev.SetTextColor( maHeaderTextColor );
+ rOutDev.SetTextFillColor();
+ rOutDev.DrawText( Point( nX1 + 1, 0 ), GetColumnTypeName( nColIndex ) );
+
+ rOutDev.SetLineColor( maHeaderGridColor );
+ rOutDev.DrawLine( Point( nX1, nHdrHt ), Point( nX2, nHdrHt ) );
+ rOutDev.DrawLine( Point( nX2, 0 ), Point( nX2, nHdrHt ) );
+}
+
+void ScCsvGrid::ImplDrawCellText( const Point& rPos, const String& rText )
+{
+ String aPlainText( rText );
+ aPlainText.SearchAndReplaceAll( '\t', ' ' );
+ aPlainText.SearchAndReplaceAll( '\n', ' ' );
+ mpEditEngine->SetPaperSize( maEdEngSize );
+
+ /* #i60296# If string contains mixed script types, the space character
+ U+0020 may be drawn with a wrong width (from non-fixed-width Asian or
+ Complex font). Now we draw every non-space portion separately. */
+ xub_StrLen nTokenCount = aPlainText.GetTokenCount( ' ' );
+ xub_StrLen nCharIx = 0;
+ for( xub_StrLen nToken = 0; nToken < nTokenCount; ++nToken )
+ {
+ xub_StrLen nBeginIx = nCharIx;
+ String aToken = aPlainText.GetToken( 0, ' ', nCharIx );
+ if( aToken.Len() > 0 )
+ {
+ sal_Int32 nX = rPos.X() + GetCharWidth() * nBeginIx;
+ mpEditEngine->SetText( aToken );
+ mpEditEngine->Draw( &maBackgrDev, Point( nX, rPos.Y() ) );
+ }
+ }
+
+ nCharIx = 0;
+ while( (nCharIx = rText.Search( '\t', nCharIx )) != STRING_NOTFOUND )
+ {
+ sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
+ sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
+ sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
+ Color aColor( maTextColor );
+ maBackgrDev.SetLineColor( aColor );
+ maBackgrDev.DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
+ maBackgrDev.DrawLine( Point( nX2 - 2, nY - 2 ), Point( nX2, nY ) );
+ maBackgrDev.DrawLine( Point( nX2 - 2, nY + 2 ), Point( nX2, nY ) );
+ ++nCharIx;
+ }
+ nCharIx = 0;
+ while( (nCharIx = rText.Search( '\n', nCharIx )) != STRING_NOTFOUND )
+ {
+ sal_Int32 nX1 = rPos.X() + GetCharWidth() * nCharIx;
+ sal_Int32 nX2 = nX1 + GetCharWidth() - 2;
+ sal_Int32 nY = rPos.Y() + GetLineHeight() / 2;
+ Color aColor( maTextColor );
+ maBackgrDev.SetLineColor( aColor );
+ maBackgrDev.DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
+ maBackgrDev.DrawLine( Point( nX1 + 2, nY - 2 ), Point( nX1, nY ) );
+ maBackgrDev.DrawLine( Point( nX1 + 2, nY + 2 ), Point( nX1, nY ) );
+ maBackgrDev.DrawLine( Point( nX2, nY - 2 ), Point( nX2, nY ) );
+ ++nCharIx;
+ }
+}
+
+void ScCsvGrid::ImplDrawFirstLineSep( bool bSet )
+{
+ if( IsVisibleLine( mnFirstImpLine ) && (mnFirstImpLine != GetFirstVisLine() ) )
+ {
+ sal_Int32 nY = GetY( mnFirstImpLine );
+ sal_Int32 nX = Min( GetColumnX( GetLastVisColumn() + 1 ), GetLastX() );
+ maBackgrDev.SetLineColor( bSet ? maGridPBColor : maGridColor );
+ maBackgrDev.DrawLine( Point( GetFirstX() + 1, nY ), Point( nX, nY ) );
+ }
+}
+
+void ScCsvGrid::ImplDrawColumnBackgr( sal_uInt32 nColIndex )
+{
+ if( !IsVisibleColumn( nColIndex ) )
+ return;
+
+ ImplSetColumnClipRegion( maBackgrDev, nColIndex );
+
+ // grid
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maBackColor );
+ sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
+ sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
+ sal_Int32 nY2 = GetY( GetLastVisLine() + 1 );
+ sal_Int32 nHdrHt = GetHdrHeight();
+ Rectangle aRect( nX1, nHdrHt, nX2, nY2 );
+ maBackgrDev.DrawRect( aRect );
+ maBackgrDev.SetLineColor( maGridColor );
+ maBackgrDev.DrawGrid( aRect, Size( 1, GetLineHeight() ), GRID_HORZLINES );
+ maBackgrDev.DrawLine( Point( nX2, nHdrHt ), Point( nX2, nY2 ) );
+ ImplDrawFirstLineSep( true );
+
+ // cell texts
+ mpEditEngine->SetDefaultItem( SvxColorItem( maTextColor, EE_CHAR_COLOR ) );
+ size_t nLineCount = ::std::min( static_cast< size_t >( GetLastVisLine() - GetFirstVisLine() + 1 ), maTexts.size() );
+ // #i67432# cut string to avoid edit engine performance problems with very large strings
+ sal_Int32 nFirstVisPos = ::std::max( GetColumnPos( nColIndex ), GetFirstVisPos() );
+ sal_Int32 nLastVisPos = ::std::min( GetColumnPos( nColIndex + 1 ), GetLastVisPos() );
+ xub_StrLen nStrPos = static_cast< xub_StrLen >( nFirstVisPos - GetColumnPos( nColIndex ) );
+ xub_StrLen nStrLen = static_cast< xub_StrLen >( nLastVisPos - nFirstVisPos + 1 );
+ sal_Int32 nStrX = GetX( nFirstVisPos );
+ for( size_t nLine = 0; nLine < nLineCount; ++nLine )
+ {
+ StringVec& rStrVec = maTexts[ nLine ];
+ if( (nColIndex < rStrVec.size()) && (rStrVec[ nColIndex ].Len() > nStrPos) )
+ {
+ String aText( rStrVec[ nColIndex ], nStrPos, nStrLen );
+ ImplDrawCellText( Point( nStrX, GetY( GetFirstVisLine() + nLine ) ), aText );
+ }
+ }
+
+ // header
+ ImplDrawColumnHeader( maBackgrDev, nColIndex, maHeaderBackColor );
+
+ maBackgrDev.SetClipRegion();
+}
+
+void ScCsvGrid::ImplDrawRowHeaders()
+{
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maAppBackColor );
+ Point aPoint( GetHdrX(), 0 );
+ Rectangle aRect( aPoint, Size( GetHdrWidth() + 1, GetHeight() ) );
+ maBackgrDev.DrawRect( aRect );
+
+ maBackgrDev.SetFillColor( maHeaderBackColor );
+ aRect.Bottom() = GetY( GetLastVisLine() + 1 );
+ maBackgrDev.DrawRect( aRect );
+
+ // line numbers
+ maBackgrDev.SetFont( maHeaderFont );
+ maBackgrDev.SetTextColor( maHeaderTextColor );
+ maBackgrDev.SetTextFillColor();
+ sal_Int32 nLastLine = GetLastVisLine();
+ for( sal_Int32 nLine = GetFirstVisLine(); nLine <= nLastLine; ++nLine )
+ {
+ String aText( String::CreateFromInt32( nLine + 1 ) );
+ sal_Int32 nX = GetHdrX() + (GetHdrWidth() - maBackgrDev.GetTextWidth( aText )) / 2;
+ maBackgrDev.DrawText( Point( nX, GetY( nLine ) ), aText );
+ }
+
+ // grid
+ maBackgrDev.SetLineColor( maHeaderGridColor );
+ if( IsRTL() )
+ {
+ maBackgrDev.DrawLine( Point( 0, 0 ), Point( 0, GetHeight() - 1 ) );
+ maBackgrDev.DrawLine( aRect.TopLeft(), aRect.BottomLeft() );
+ }
+ else
+ maBackgrDev.DrawLine( aRect.TopRight(), aRect.BottomRight() );
+ aRect.Top() = GetHdrHeight();
+ maBackgrDev.DrawGrid( aRect, Size( 1, GetLineHeight() ), GRID_HORZLINES );
+}
+
+void ScCsvGrid::ImplDrawBackgrDev()
+{
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maAppBackColor );
+ maBackgrDev.DrawRect( Rectangle(
+ Point( GetFirstX() + 1, 0 ), Size( GetWidth() - GetHdrWidth(), GetHeight() ) ) );
+
+ sal_uInt32 nLastCol = GetLastVisColumn();
+ for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
+ ImplDrawColumnBackgr( nColIx );
+
+ ImplDrawRowHeaders();
+}
+
+void ScCsvGrid::ImplDrawColumnSelection( sal_uInt32 nColIndex )
+{
+ ImplInvertCursor( GetRulerCursorPos() );
+ ImplSetColumnClipRegion( maGridDev, nColIndex );
+ maGridDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
+
+ if( IsSelected( nColIndex ) )
+ {
+ sal_Int32 nX1 = GetColumnX( nColIndex ) + 1;
+ sal_Int32 nX2 = GetColumnX( nColIndex + 1 );
+
+ // header
+ Rectangle aRect( nX1, 0, nX2, GetHdrHeight() );
+ maGridDev.SetLineColor();
+ if( maHeaderBackColor.IsDark() )
+ // redraw with light gray background in dark mode
+ ImplDrawColumnHeader( maGridDev, nColIndex, COL_LIGHTGRAY );
+ else
+ {
+ // use transparent active color
+ maGridDev.SetFillColor( maSelectColor );
+ maGridDev.DrawTransparent( PolyPolygon( Polygon( aRect ) ), CSV_HDR_TRANSPARENCY );
+ }
+
+ // column selection
+ aRect = Rectangle( nX1, GetHdrHeight() + 1, nX2, GetY( GetLastVisLine() + 1 ) - 1 );
+ ImplInvertRect( maGridDev, aRect );
+ }
+
+ maGridDev.SetClipRegion();
+ ImplInvertCursor( GetRulerCursorPos() );
+}
+
+void ScCsvGrid::ImplDrawGridDev()
+{
+ maGridDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
+ sal_uInt32 nLastCol = GetLastVisColumn();
+ for( sal_uInt32 nColIx = GetFirstVisColumn(); nColIx <= nLastCol; ++nColIx )
+ ImplDrawColumnSelection( nColIx );
+}
+
+void ScCsvGrid::ImplDrawColumn( sal_uInt32 nColIndex )
+{
+ ImplDrawColumnBackgr( nColIndex );
+ ImplDrawColumnSelection( nColIndex );
+}
+
+void ScCsvGrid::ImplDrawHorzScrolled( sal_Int32 nOldPos )
+{
+ sal_Int32 nPos = GetFirstVisPos();
+ if( !IsValidGfx() || (nPos == nOldPos) )
+ return;
+ if( Abs( nPos - nOldPos ) > GetVisPosCount() / 2 )
+ {
+ ImplDrawBackgrDev();
+ ImplDrawGridDev();
+ return;
+ }
+
+ Point aSrc, aDest;
+ sal_uInt32 nFirstColIx, nLastColIx;
+ if( nPos < nOldPos )
+ {
+ aSrc = Point( GetFirstX() + 1, 0 );
+ aDest = Point( GetFirstX() + GetCharWidth() * (nOldPos - nPos) + 1, 0 );
+ nFirstColIx = GetColumnFromPos( nPos );
+ nLastColIx = GetColumnFromPos( nOldPos );
+ }
+ else
+ {
+ aSrc = Point( GetFirstX() + GetCharWidth() * (nPos - nOldPos) + 1, 0 );
+ aDest = Point( GetFirstX() + 1, 0 );
+ nFirstColIx = GetColumnFromPos( Min( nOldPos + GetVisPosCount(), GetPosCount() ) - 1 );
+ nLastColIx = GetColumnFromPos( Min( nPos + GetVisPosCount(), GetPosCount() ) - 1 );
+ }
+
+ ImplInvertCursor( GetRulerCursorPos() + (nPos - nOldPos) );
+ Rectangle aRectangle( GetFirstX(), 0, GetLastX(), GetHeight() - 1 );
+ Region aClipReg( aRectangle );
+ maBackgrDev.SetClipRegion( aClipReg );
+ maBackgrDev.CopyArea( aDest, aSrc, maWinSize );
+ maBackgrDev.SetClipRegion();
+ maGridDev.SetClipRegion( aClipReg );
+ maGridDev.CopyArea( aDest, aSrc, maWinSize );
+ maGridDev.SetClipRegion();
+ ImplInvertCursor( GetRulerCursorPos() );
+
+ for( sal_uInt32 nColIx = nFirstColIx; nColIx <= nLastColIx; ++nColIx )
+ ImplDrawColumn( nColIx );
+
+ sal_Int32 nLastX = GetX( GetPosCount() ) + 1;
+ if( nLastX <= GetLastX() )
+ {
+ Rectangle aRect( nLastX, 0, GetLastX(), GetHeight() - 1 );
+ maBackgrDev.SetLineColor();
+ maBackgrDev.SetFillColor( maAppBackColor );
+ maBackgrDev.DrawRect( aRect );
+ maGridDev.SetLineColor();
+ maGridDev.SetFillColor( maAppBackColor );
+ maGridDev.DrawRect( aRect );
+ }
+}
+
+void ScCsvGrid::ImplInvertCursor( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ sal_Int32 nX = GetX( nPos ) - 1;
+ Rectangle aRect( Point( nX, 0 ), Size( 3, GetHdrHeight() ) );
+ ImplInvertRect( maGridDev, aRect );
+ aRect.Top() = GetHdrHeight() + 1;
+ aRect.Bottom() = GetY( GetLastVisLine() + 1 );
+ ImplInvertRect( maGridDev, aRect );
+ }
+}
+
+void ScCsvGrid::ImplDrawTrackingRect( sal_uInt32 nColIndex )
+{
+ if( HasFocus() && IsVisibleColumn( nColIndex ) )
+ {
+ sal_Int32 nX1 = Max( GetColumnX( nColIndex ), GetFirstX() ) + 1;
+ sal_Int32 nX2 = Min( GetColumnX( nColIndex + 1 ) - sal_Int32( 1 ), GetLastX() );
+ sal_Int32 nY2 = Min( GetY( GetLastVisLine() + 1 ), GetHeight() ) - 1;
+ InvertTracking( Rectangle( nX1, 0, nX2, nY2 ), SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ }
+}
+
+
+// accessibility ==============================================================
+
+ScAccessibleCsvControl* ScCsvGrid::ImplCreateAccessible()
+{
+ return new ScAccessibleCsvGrid( *this );
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/csvruler.cxx b/sc/source/ui/dbgui/csvruler.cxx
new file mode 100644
index 000000000000..5f53e24d0dc6
--- /dev/null
+++ b/sc/source/ui/dbgui/csvruler.cxx
@@ -0,0 +1,684 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvruler.hxx"
+#include "AccessibleCsvControl.hxx"
+
+
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "miscuno.hxx"
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+
+
+// ============================================================================
+#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
+#define FIXED_WIDTH_LIST "FixedWidthList"
+
+
+// ============================================================================
+
+static void load_FixedWidthList(ScCsvSplits &aSplits)
+{
+ String sSplits;
+ OUString sFixedWidthLists;
+
+ Sequence<Any>aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+
+ if( pProperties[0].hasValue() )
+ {
+ aSplits.Clear();
+ pProperties[0] >>= sFixedWidthLists;
+
+ sSplits = String( sFixedWidthLists );
+
+ // String ends with a semi-colon so there is no 'int' after the last one.
+ xub_StrLen n = sSplits.GetTokenCount() - 1;
+ for (xub_StrLen i = 0; i < n; ++i)
+ aSplits.Insert( sSplits.GetToken(i).ToInt32() );
+ }
+}
+static void save_FixedWidthList(ScCsvSplits aSplits)
+{
+ String sSplits;
+ // Create a semi-colon separated string to save the splits
+ sal_uInt32 n = aSplits.Count();
+ for (sal_uInt32 i = 0; i < n; ++i)
+ {
+ sSplits.Append( String::CreateFromInt32( aSplits[i] ) );
+ sSplits.Append((char)';');
+ }
+
+ OUString sFixedWidthLists = OUString( sSplits );
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(1);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( FIXED_WIDTH_LIST );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[0] <<= sFixedWidthLists;
+
+ aItem.PutProperties(aNames, aValues);
+}
+
+ScCsvRuler::ScCsvRuler( ScCsvControl& rParent ) :
+ ScCsvControl( rParent ),
+ mnPosCursorLast( 1 )
+{
+ EnableRTL( false ); // #107812# RTL
+ InitColors();
+ InitSizeData();
+ maBackgrDev.SetFont( GetFont() );
+ maRulerDev.SetFont( GetFont() );
+
+ load_FixedWidthList( maSplits );
+}
+
+ScCsvRuler::~ScCsvRuler()
+{
+ save_FixedWidthList( maSplits );
+}
+
+
+// common ruler handling ------------------------------------------------------
+
+void ScCsvRuler::SetPosSizePixel(
+ long nX, long nY, long nWidth, long nHeight, USHORT nFlags )
+{
+ if( nFlags & WINDOW_POSSIZE_HEIGHT )
+ nHeight = GetTextHeight() + mnSplitSize + 2;
+ ScCsvControl::SetPosSizePixel( nX, nY, nWidth, nHeight, nFlags );
+}
+
+void ScCsvRuler::ApplyLayout( const ScCsvLayoutData& rOldData )
+{
+ ScCsvDiff nDiff = GetLayoutData().GetDiff( rOldData ) & (CSV_DIFF_HORIZONTAL | CSV_DIFF_RULERCURSOR);
+ if( nDiff == CSV_DIFF_EQUAL ) return;
+
+ DisableRepaint();
+ if( nDiff & CSV_DIFF_HORIZONTAL )
+ {
+ InitSizeData();
+ if( GetRulerCursorPos() >= GetPosCount() )
+ MoveCursor( GetPosCount() - 1 );
+ }
+ if( nDiff & CSV_DIFF_RULERCURSOR )
+ {
+ ImplInvertCursor( rOldData.mnPosCursor );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+ EnableRepaint();
+
+ if( nDiff & CSV_DIFF_POSOFFSET )
+ AccSendVisibleEvent();
+}
+
+void ScCsvRuler::InitColors()
+{
+ const StyleSettings& rSett = GetSettings().GetStyleSettings();
+ maBackColor = rSett.GetFaceColor();
+ maActiveColor = rSett.GetWindowColor();
+ maTextColor = rSett.GetLabelTextColor();
+ maSplitColor = maBackColor.IsDark() ? maTextColor : Color( COL_LIGHTRED );
+ InvalidateGfx();
+}
+
+void ScCsvRuler::InitSizeData()
+{
+ maWinSize = GetSizePixel();
+
+ mnSplitSize = (GetCharWidth() * 3 / 5) | 1; // make an odd number
+
+ sal_Int32 nActiveWidth = Min( GetWidth() - GetHdrWidth(), GetPosCount() * GetCharWidth() );
+ sal_Int32 nActiveHeight = GetTextHeight();
+
+ maActiveRect.SetPos( Point( GetFirstX(), (GetHeight() - nActiveHeight - 1) / 2 ) );
+ maActiveRect.SetSize( Size( nActiveWidth, nActiveHeight ) );
+
+ maBackgrDev.SetOutputSizePixel( maWinSize );
+ maRulerDev.SetOutputSizePixel( maWinSize );
+
+ InvalidateGfx();
+}
+
+void ScCsvRuler::MoveCursor( sal_Int32 nPos, bool bScroll )
+{
+ DisableRepaint();
+ if( bScroll )
+ Execute( CSVCMD_MAKEPOSVISIBLE, nPos );
+ Execute( CSVCMD_MOVERULERCURSOR, IsVisibleSplitPos( nPos ) ? nPos : CSV_POS_INVALID );
+ EnableRepaint();
+ AccSendCaretEvent();
+}
+
+void ScCsvRuler::MoveCursorRel( ScMoveMode eDir )
+{
+ if( GetRulerCursorPos() != CSV_POS_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ MoveCursor( 1 );
+ break;
+ case MOVE_LAST:
+ MoveCursor( GetPosCount() - 1 );
+ break;
+ case MOVE_PREV:
+ if( GetRulerCursorPos() > 1 )
+ MoveCursor( GetRulerCursorPos() - 1 );
+ break;
+ case MOVE_NEXT:
+ if( GetRulerCursorPos() < GetPosCount() - 1 )
+ MoveCursor( GetRulerCursorPos() + 1 );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+}
+
+void ScCsvRuler::MoveCursorToSplit( ScMoveMode eDir )
+{
+ if( GetRulerCursorPos() != CSV_POS_INVALID )
+ {
+ sal_uInt32 nIndex = CSV_VEC_NOTFOUND;
+ switch( eDir )
+ {
+ case MOVE_FIRST: nIndex = maSplits.LowerBound( 0 ); break;
+ case MOVE_LAST: nIndex = maSplits.UpperBound( GetPosCount() ); break;
+ case MOVE_PREV: nIndex = maSplits.UpperBound( GetRulerCursorPos() - 1 ); break;
+ case MOVE_NEXT: nIndex = maSplits.LowerBound( GetRulerCursorPos() + 1 ); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ sal_Int32 nPos = maSplits[ nIndex ];
+ if( nPos != CSV_POS_INVALID )
+ MoveCursor( nPos );
+ }
+}
+
+void ScCsvRuler::ScrollVertRel( ScMoveMode eDir )
+{
+ sal_Int32 nLine = GetFirstVisLine();
+ switch( eDir )
+ {
+ case MOVE_PREV: --nLine; break;
+ case MOVE_NEXT: ++nLine; break;
+ case MOVE_PREVPAGE: nLine -= GetVisLineCount() - 1; break;
+ case MOVE_NEXTPAGE: nLine += GetVisLineCount() - 1; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ Execute( CSVCMD_SETLINEOFFSET, nLine );
+}
+
+
+// split handling -------------------------------------------------------------
+
+sal_Int32 ScCsvRuler::GetNoScrollPos( sal_Int32 nPos ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != CSV_POS_INVALID )
+ {
+ if( nNewPos < GetFirstVisPos() + CSV_SCROLL_DIST )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() > 0) ? CSV_SCROLL_DIST : 0;
+ nNewPos = Max( nPos, GetFirstVisPos() + nScroll );
+ }
+ else if( nNewPos > GetLastVisPos() - CSV_SCROLL_DIST - 1L )
+ {
+ sal_Int32 nScroll = (GetFirstVisPos() < GetMaxPosOffset()) ? CSV_SCROLL_DIST : 0;
+ nNewPos = Min( nNewPos, GetLastVisPos() - nScroll - sal_Int32( 1 ) );
+ }
+ }
+ return nNewPos;
+}
+
+void ScCsvRuler::InsertSplit( sal_Int32 nPos )
+{
+ if( maSplits.Insert( nPos ) )
+ {
+ ImplDrawSplit( nPos );
+ Repaint();
+ }
+}
+
+void ScCsvRuler::RemoveSplit( sal_Int32 nPos )
+{
+ if( maSplits.Remove( nPos ) )
+ {
+ ImplEraseSplit( nPos );
+ Repaint();
+ }
+}
+
+void ScCsvRuler::MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos )
+{
+ bool bRemove = maSplits.Remove( nPos );
+ bool bInsert = maSplits.Insert( nNewPos );
+ if( bRemove || bInsert )
+ {
+ ImplEraseSplit( nPos );
+ ImplDrawSplit( nNewPos );
+ Repaint();
+ }
+}
+
+void ScCsvRuler::RemoveAllSplits()
+{
+ maSplits.Clear();
+ Repaint( true );
+}
+
+sal_Int32 ScCsvRuler::FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const
+{
+ sal_Int32 nNewPos = nPos;
+ if( nNewPos != CSV_POS_INVALID )
+ {
+ switch( eDir )
+ {
+ case MOVE_FIRST:
+ nNewPos = Min( nPos, FindEmptyPos( 0, MOVE_NEXT ) );
+ break;
+ case MOVE_LAST:
+ nNewPos = Max( nPos, FindEmptyPos( GetPosCount(), MOVE_PREV ) );
+ break;
+ case MOVE_PREV:
+ while( HasSplit( --nNewPos ) ) ;
+ break;
+ case MOVE_NEXT:
+ while( HasSplit( ++nNewPos ) ) ;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ return IsValidSplitPos( nNewPos ) ? nNewPos : CSV_POS_INVALID;
+}
+
+void ScCsvRuler::MoveCurrSplit( sal_Int32 nNewPos )
+{
+ DisableRepaint();
+ Execute( CSVCMD_MOVESPLIT, GetRulerCursorPos(), nNewPos );
+ MoveCursor( nNewPos );
+ EnableRepaint();
+}
+
+void ScCsvRuler::MoveCurrSplitRel( ScMoveMode eDir )
+{
+ if( HasSplit( GetRulerCursorPos() ) )
+ {
+ sal_Int32 nNewPos = FindEmptyPos( GetRulerCursorPos(), eDir );
+ if( nNewPos != CSV_POS_INVALID )
+ MoveCurrSplit( nNewPos );
+ }
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvRuler::Resize()
+{
+ ScCsvControl::Resize();
+ InitSizeData();
+ Repaint();
+}
+
+void ScCsvRuler::GetFocus()
+{
+ ScCsvControl::GetFocus();
+ DisableRepaint();
+ if( GetRulerCursorPos() == CSV_POS_INVALID )
+ MoveCursor( GetNoScrollPos( mnPosCursorLast ) );
+ EnableRepaint();
+}
+
+void ScCsvRuler::LoseFocus()
+{
+ ScCsvControl::LoseFocus();
+ mnPosCursorLast = GetRulerCursorPos();
+ MoveCursor( CSV_POS_INVALID );
+}
+
+void ScCsvRuler::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitColors();
+ Repaint();
+ }
+ ScCsvControl::DataChanged( rDCEvt );
+}
+
+void ScCsvRuler::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ DisableRepaint();
+ if( !HasFocus() )
+ GrabFocus();
+ if( rMEvt.IsLeft() )
+ {
+ sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
+ if( IsVisibleSplitPos( nPos ) )
+ StartMouseTracking( nPos );
+ ImplSetMousePointer( nPos );
+ }
+ EnableRepaint();
+}
+
+void ScCsvRuler::MouseMove( const MouseEvent& rMEvt )
+{
+ if( !rMEvt.IsModifierChanged() )
+ {
+ sal_Int32 nPos = GetPosFromX( rMEvt.GetPosPixel().X() );
+ if( IsTracking() )
+ {
+ // on mouse tracking: keep position valid
+ nPos = Max( Min( nPos, GetPosCount() - sal_Int32( 1 ) ), sal_Int32( 1 ) );
+ MoveMouseTracking( nPos );
+ }
+ else
+ {
+ Point aPoint;
+ Rectangle aRect( aPoint, maWinSize );
+ if( !IsVisibleSplitPos( nPos ) || !aRect.IsInside( rMEvt.GetPosPixel() ) )
+ // if focused, keep old cursor position for key input
+ nPos = HasFocus() ? GetRulerCursorPos() : CSV_POS_INVALID;
+ MoveCursor( nPos, false );
+ }
+ ImplSetMousePointer( nPos );
+ }
+}
+
+void ScCsvRuler::Tracking( const TrackingEvent& rTEvt )
+{
+ if( rTEvt.IsTrackingEnded() || rTEvt.IsTrackingRepeat() )
+ MouseMove( rTEvt.GetMouseEvent() );
+ if( rTEvt.IsTrackingEnded() )
+ EndMouseTracking( !rTEvt.IsTrackingCanceled() );
+}
+
+void ScCsvRuler::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKCode = rKEvt.GetKeyCode();
+ sal_uInt16 nCode = rKCode.GetCode();
+ bool bNoMod = !rKCode.GetModifier();
+ bool bShift = (rKCode.GetModifier() == KEY_SHIFT);
+ bool bJump = (rKCode.GetModifier() == KEY_MOD1);
+ bool bMove = (rKCode.GetModifier() == (KEY_MOD1 | KEY_SHIFT));
+
+ ScMoveMode eHDir = GetHorzDirection( nCode, true );
+ ScMoveMode eVDir = GetVertDirection( nCode, false );
+
+ if( bNoMod )
+ {
+ if( eHDir != MOVE_NONE )
+ MoveCursorRel( eHDir );
+ else if( eVDir != MOVE_NONE )
+ ScrollVertRel( eVDir );
+ else switch( nCode )
+ {
+ case KEY_SPACE: Execute( CSVCMD_TOGGLESPLIT, GetRulerCursorPos() ); break;
+ case KEY_INSERT: Execute( CSVCMD_INSERTSPLIT, GetRulerCursorPos() ); break;
+ case KEY_DELETE: Execute( CSVCMD_REMOVESPLIT, GetRulerCursorPos() ); break;
+ }
+ }
+ else if( bJump && (eHDir != MOVE_NONE) )
+ MoveCursorToSplit( eHDir );
+ else if( bMove && (eHDir != MOVE_NONE) )
+ MoveCurrSplitRel( eHDir );
+ else if( bShift && (nCode == KEY_DELETE) )
+ Execute( CSVCMD_REMOVEALLSPLITS );
+
+ if( rKCode.GetGroup() != KEYGROUP_CURSOR )
+ ScCsvControl::KeyInput( rKEvt );
+}
+
+void ScCsvRuler::StartMouseTracking( sal_Int32 nPos )
+{
+ mnPosMTStart = mnPosMTCurr = nPos;
+ mbPosMTMoved = false;
+ maOldSplits = maSplits;
+ Execute( CSVCMD_INSERTSPLIT, nPos );
+ if( HasSplit( nPos ) )
+ StartTracking( STARTTRACK_BUTTONREPEAT );
+}
+
+void ScCsvRuler::MoveMouseTracking( sal_Int32 nPos )
+{
+ if( mnPosMTCurr != nPos )
+ {
+ DisableRepaint();
+ MoveCursor( nPos );
+ if( (mnPosMTCurr != mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) )
+ Execute( CSVCMD_INSERTSPLIT, nPos );
+ else
+ Execute( CSVCMD_MOVESPLIT, mnPosMTCurr, nPos );
+ mnPosMTCurr = nPos;
+ mbPosMTMoved = true;
+ EnableRepaint();
+ }
+}
+
+void ScCsvRuler::EndMouseTracking( bool bApply )
+{
+ if( bApply ) // tracking finished successfully
+ {
+ // remove on simple click on an existing split
+ if( (mnPosMTCurr == mnPosMTStart) && maOldSplits.HasSplit( mnPosMTCurr ) && !mbPosMTMoved )
+ Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
+ }
+ else // tracking cancelled
+ {
+ MoveCursor( mnPosMTStart );
+ // move split to origin
+ if( maOldSplits.HasSplit( mnPosMTStart ) )
+ MoveMouseTracking( mnPosMTStart );
+ // remove temporarily inserted split
+ else if( !maOldSplits.HasSplit( mnPosMTCurr ) )
+ Execute( CSVCMD_REMOVESPLIT, mnPosMTCurr );
+ }
+ mnPosMTStart = CSV_POS_INVALID;
+}
+
+
+// painting -------------------------------------------------------------------
+
+void ScCsvRuler::Paint( const Rectangle& )
+{
+ Repaint();
+}
+
+void ScCsvRuler::ImplRedraw()
+{
+ if( IsVisible() )
+ {
+ if( !IsValidGfx() )
+ {
+ ValidateGfx();
+ ImplDrawBackgrDev();
+ ImplDrawRulerDev();
+ }
+ DrawOutDev( Point(), maWinSize, Point(), maWinSize, maRulerDev );
+ ImplDrawTrackingRect();
+ }
+}
+
+void ScCsvRuler::ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth )
+{
+ maBackgrDev.SetLineColor();
+ Rectangle aRect( Point( nPosX, 0 ), Size( nWidth, GetHeight() ) );
+ maBackgrDev.SetFillColor( maBackColor );
+ maBackgrDev.DrawRect( aRect );
+
+ aRect = maActiveRect;
+ aRect.Left() = Max( GetFirstX(), nPosX );
+ aRect.Right() = Min( Min( GetX( GetPosCount() ), GetLastX() ), nPosX + nWidth - sal_Int32( 1 ) );
+ if( aRect.Left() <= aRect.Right() )
+ {
+ maBackgrDev.SetFillColor( maActiveColor );
+ maBackgrDev.DrawRect( aRect );
+ }
+
+ maBackgrDev.SetLineColor( maTextColor );
+ sal_Int32 nY = GetHeight() - 1;
+ maBackgrDev.DrawLine( Point( nPosX, nY ), Point( nPosX + nWidth - 1, nY ) );
+}
+
+void ScCsvRuler::ImplDrawBackgrDev()
+{
+ ImplDrawArea( 0, GetWidth() );
+
+ // scale
+ maBackgrDev.SetLineColor( maTextColor );
+ maBackgrDev.SetFillColor();
+ sal_Int32 nPos;
+
+ sal_Int32 nFirstPos = Max( GetPosFromX( 0 ) - (sal_Int32)(1L), (sal_Int32)(0L) );
+ sal_Int32 nLastPos = GetPosFromX( GetWidth() );
+ sal_Int32 nY = (maActiveRect.Top() + maActiveRect.Bottom()) / 2;
+ for( nPos = nFirstPos; nPos <= nLastPos; ++nPos )
+ {
+ sal_Int32 nX = GetX( nPos );
+ if( nPos % 5 )
+ maBackgrDev.DrawPixel( Point( nX, nY ) );
+ else
+ maBackgrDev.DrawLine( Point( nX, nY - 1 ), Point( nX, nY + 1 ) );
+ }
+
+ // texts
+ maBackgrDev.SetTextColor( maTextColor );
+ maBackgrDev.SetTextFillColor();
+ for( nPos = ((nFirstPos + 9) / 10) * 10; nPos <= nLastPos; nPos += 10 )
+ {
+ String aText( String::CreateFromInt32( nPos ) );
+ sal_Int32 nTextWidth = maBackgrDev.GetTextWidth( aText );
+ sal_Int32 nTextX = GetX( nPos ) - nTextWidth / 2;
+ ImplDrawArea( nTextX - 1, nTextWidth + 2 );
+ maBackgrDev.DrawText( Point( nTextX, maActiveRect.Top() ), aText );
+ }
+}
+
+void ScCsvRuler::ImplDrawSplit( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ Point aPos( GetX( nPos ) - mnSplitSize / 2, GetHeight() - mnSplitSize - 2 );
+ Size aSize( mnSplitSize, mnSplitSize );
+ maRulerDev.SetLineColor( maTextColor );
+ maRulerDev.SetFillColor( maSplitColor );
+ maRulerDev.DrawEllipse( Rectangle( aPos, aSize ) );
+ maRulerDev.DrawPixel( Point( GetX( nPos ), GetHeight() - 2 ) );
+ }
+}
+
+void ScCsvRuler::ImplEraseSplit( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ ImplInvertCursor( GetRulerCursorPos() );
+ Point aPos( GetX( nPos ) - mnSplitSize / 2, 0 );
+ Size aSize( mnSplitSize, GetHeight() );
+ maRulerDev.DrawOutDev( aPos, aSize, aPos, aSize, maBackgrDev );
+ ImplInvertCursor( GetRulerCursorPos() );
+ }
+}
+
+void ScCsvRuler::ImplDrawRulerDev()
+{
+ maRulerDev.DrawOutDev( Point(), maWinSize, Point(), maWinSize, maBackgrDev );
+ ImplInvertCursor( GetRulerCursorPos() );
+
+ sal_uInt32 nFirst = maSplits.LowerBound( GetFirstVisPos() );
+ sal_uInt32 nLast = maSplits.UpperBound( GetLastVisPos() );
+ if( (nFirst != CSV_VEC_NOTFOUND) && (nLast != CSV_VEC_NOTFOUND) )
+ for( sal_uInt32 nIndex = nFirst; nIndex <= nLast; ++nIndex )
+ ImplDrawSplit( GetSplitPos( nIndex ) );
+}
+
+void ScCsvRuler::ImplInvertCursor( sal_Int32 nPos )
+{
+ if( IsVisibleSplitPos( nPos ) )
+ {
+ ImplInvertRect( maRulerDev, Rectangle( Point( GetX( nPos ) - 1, 0 ), Size( 3, GetHeight() - 1 ) ) );
+ if( HasSplit( nPos ) )
+ ImplDrawSplit( nPos );
+ }
+}
+
+void ScCsvRuler::ImplDrawTrackingRect()
+{
+ if( HasFocus() )
+ InvertTracking( Rectangle( 0, 0, GetWidth() - 1, GetHeight() - 2 ),
+ SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+}
+
+void ScCsvRuler::ImplSetMousePointer( sal_Int32 nPos )
+{
+ SetPointer( Pointer( HasSplit( nPos ) ? POINTER_HSPLIT : POINTER_ARROW ) );
+}
+
+
+// accessibility ==============================================================
+
+ScAccessibleCsvControl* ScCsvRuler::ImplCreateAccessible()
+{
+ return new ScAccessibleCsvRuler( *this );
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/csvsplits.cxx b/sc/source/ui/dbgui/csvsplits.cxx
new file mode 100644
index 000000000000..39ab20af9df8
--- /dev/null
+++ b/sc/source/ui/dbgui/csvsplits.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvsplits.hxx"
+#include <tools/debug.hxx>
+
+#include <algorithm>
+
+
+// ============================================================================
+
+bool ScCsvSplits::Insert( sal_Int32 nPos )
+{
+ bool bValid = (nPos >= 0);
+ if( bValid )
+ {
+ iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
+ bValid = (aIter == maVec.end()) || (*aIter != nPos);
+ if( bValid )
+ aIter = maVec.insert( aIter, nPos );
+ }
+ return bValid;
+}
+
+bool ScCsvSplits::Remove( sal_Int32 nPos )
+{
+ sal_uInt32 nIndex = GetIndex( nPos );
+ bool bValid = (nIndex != CSV_VEC_NOTFOUND);
+ if( bValid )
+ maVec.erase( maVec.begin() + nIndex );
+ return bValid;
+}
+
+void ScCsvSplits::RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd )
+{
+ sal_uInt32 nStartIx = LowerBound( nPosStart );
+ sal_uInt32 nEndIx = UpperBound( nPosEnd );
+ if( (nStartIx != CSV_VEC_NOTFOUND) && (nEndIx != CSV_VEC_NOTFOUND) && (nStartIx <= nEndIx) )
+ maVec.erase( maVec.begin() + nStartIx, maVec.begin() + nEndIx + 1 );
+}
+
+void ScCsvSplits::Clear()
+{
+ maVec.clear();
+}
+
+bool ScCsvSplits::HasSplit( sal_Int32 nPos ) const
+{
+ return GetIndex( nPos ) != CSV_VEC_NOTFOUND;
+}
+
+
+// ----------------------------------------------------------------------------
+
+sal_uInt32 ScCsvSplits::GetIndex( sal_Int32 nPos ) const
+{
+ const_iterator aIter = ::std::lower_bound( maVec.begin(), maVec.end(), nPos );
+ return GetIterIndex( ((aIter != maVec.end()) && (*aIter == nPos)) ? aIter : maVec.end() );
+}
+
+sal_uInt32 ScCsvSplits::LowerBound( sal_Int32 nPos ) const
+{
+ return GetIterIndex( ::std::lower_bound( maVec.begin(), maVec.end(), nPos ) );
+}
+
+sal_uInt32 ScCsvSplits::UpperBound( sal_Int32 nPos ) const
+{
+ sal_uInt32 nIndex = LowerBound( nPos );
+ if( nIndex == CSV_VEC_NOTFOUND )
+ return Count() ? (Count() - 1) : CSV_VEC_NOTFOUND;
+ if( GetPos( nIndex ) == nPos )
+ return nIndex;
+ return nIndex ? (nIndex - 1) : CSV_VEC_NOTFOUND;
+}
+
+sal_Int32 ScCsvSplits::GetPos( sal_uInt32 nIndex ) const
+{
+ return (nIndex < Count()) ? maVec[ nIndex ] : CSV_POS_INVALID;
+}
+
+
+// ----------------------------------------------------------------------------
+
+sal_uInt32 ScCsvSplits::GetIterIndex( const_iterator aIter ) const
+{
+ return (aIter == maVec.end()) ? CSV_VEC_NOTFOUND : (aIter - maVec.begin());
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/csvtablebox.cxx b/sc/source/ui/dbgui/csvtablebox.cxx
new file mode 100644
index 000000000000..7a4e5ec25f35
--- /dev/null
+++ b/sc/source/ui/dbgui/csvtablebox.cxx
@@ -0,0 +1,436 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+// ============================================================================
+#include "csvtablebox.hxx"
+#include <tools/debug.hxx>
+#include <vcl/lstbox.hxx>
+
+// ause
+#include "editutil.hxx"
+
+// ============================================================================
+
+ScCsvTableBox::ScCsvTableBox( Window* pParent, const ResId& rResId ) :
+ ScCsvControl( pParent, maData, rResId ),
+ maRuler( *this ),
+ maGrid( *this ),
+ maHScroll( this, WB_HORZ | WB_DRAG ),
+ maVScroll( this, WB_VERT | WB_DRAG ),
+ maScrollBox( this )
+{
+ Init();
+}
+
+
+// common table box handling --------------------------------------------------
+
+void ScCsvTableBox::SetSeparatorsMode()
+{
+ if( mbFixedMode )
+ {
+ // rescue data for fixed width mode
+ mnFixedWidth = GetPosCount();
+ maFixColStates = maGrid.GetColumnStates();
+ // switch to separators mode
+ mbFixedMode = false;
+ // reset and reinitialize controls
+ DisableRepaint();
+ Execute( CSVCMD_SETLINEOFFSET, 0 );
+ Execute( CSVCMD_SETPOSCOUNT, 1 );
+ Execute( CSVCMD_NEWCELLTEXTS );
+ maGrid.SetColumnStates( maSepColStates );
+ InitControls();
+ EnableRepaint();
+ }
+}
+
+void ScCsvTableBox::SetFixedWidthMode()
+{
+ if( !mbFixedMode )
+ {
+ // rescue data for separators mode
+ maSepColStates = maGrid.GetColumnStates();
+ // switch to fixed width mode
+ mbFixedMode = true;
+ // reset and reinitialize controls
+ DisableRepaint();
+ Execute( CSVCMD_SETLINEOFFSET, 0 );
+ Execute( CSVCMD_SETPOSCOUNT, mnFixedWidth );
+ maGrid.SetSplits( maRuler.GetSplits() );
+ maGrid.SetColumnStates( maFixColStates );
+ InitControls();
+ EnableRepaint();
+ }
+}
+
+void ScCsvTableBox::Init()
+{
+ mbFixedMode = false;
+ mnFixedWidth = 1;
+
+ maHScroll.EnableRTL( false ); // #107812# RTL
+ maHScroll.SetLineSize( 1 );
+ maVScroll.SetLineSize( 1 );
+
+ Link aLink = LINK( this, ScCsvTableBox, CsvCmdHdl );
+ SetCmdHdl( aLink );
+ maRuler.SetCmdHdl( aLink );
+ maGrid.SetCmdHdl( aLink );
+
+ aLink = LINK( this, ScCsvTableBox, ScrollHdl );
+ maHScroll.SetScrollHdl( aLink );
+ maVScroll.SetScrollHdl( aLink );
+
+ aLink = LINK( this, ScCsvTableBox, ScrollEndHdl );
+ maHScroll.SetEndScrollHdl( aLink );
+ maVScroll.SetEndScrollHdl( aLink );
+
+ InitControls();
+}
+
+void ScCsvTableBox::InitControls()
+{
+ maGrid.UpdateLayoutData();
+
+ long nScrollBarSize = GetSettings().GetStyleSettings().GetScrollBarSize();
+ Size aWinSize = CalcOutputSize( GetSizePixel() );
+ long nDataWidth = aWinSize.Width() - nScrollBarSize;
+ long nDataHeight = aWinSize.Height() - nScrollBarSize;
+
+ maData.mnWinWidth = nDataWidth;
+ maData.mnWinHeight = nDataHeight;
+
+ if( mbFixedMode )
+ {
+ // ruler sets height internally
+ maRuler.SetPosSizePixel( 0, 0, nDataWidth, 0 );
+ sal_Int32 nY = maRuler.GetSizePixel().Height();
+ maData.mnWinHeight -= nY;
+ maGrid.SetPosSizePixel( 0, nY, nDataWidth, maData.mnWinHeight );
+ }
+ else
+ maGrid.SetPosSizePixel( 0, 0, nDataWidth, nDataHeight );
+ maGrid.Show();
+ maRuler.Show( mbFixedMode );
+
+ // scrollbars always visible
+ maHScroll.SetPosSizePixel( 0, nDataHeight, nDataWidth, nScrollBarSize );
+ InitHScrollBar();
+ maHScroll.Show();
+
+ // scrollbars always visible
+ maVScroll.SetPosSizePixel( nDataWidth, 0, nScrollBarSize, nDataHeight );
+ InitVScrollBar();
+ maVScroll.Show();
+
+ bool bScrBox = maHScroll.IsVisible() && maVScroll.IsVisible();
+ if( bScrBox )
+ maScrollBox.SetPosSizePixel( nDataWidth, nDataHeight, nScrollBarSize, nScrollBarSize );
+ maScrollBox.Show( bScrBox );
+
+ // let the controls self-adjust to visible area
+ Execute( CSVCMD_SETPOSOFFSET, GetFirstVisPos() );
+ Execute( CSVCMD_SETLINEOFFSET, GetFirstVisLine() );
+}
+
+void ScCsvTableBox::InitHScrollBar()
+{
+ maHScroll.SetRange( Range( 0, GetPosCount() + 2 ) );
+ maHScroll.SetVisibleSize( GetVisPosCount() );
+ maHScroll.SetPageSize( GetVisPosCount() * 3 / 4 );
+ maHScroll.SetThumbPos( GetFirstVisPos() );
+}
+
+void ScCsvTableBox::InitVScrollBar()
+{
+ maVScroll.SetRange( Range( 0, GetLineCount() + 1 ) );
+ maVScroll.SetVisibleSize( GetVisLineCount() );
+ maVScroll.SetPageSize( GetVisLineCount() - 2 );
+ maVScroll.SetThumbPos( GetFirstVisLine() );
+}
+
+void ScCsvTableBox::MakePosVisible( sal_Int32 nPos )
+{
+ if( (0 <= nPos) && (nPos < GetPosCount()) )
+ {
+ if( nPos - CSV_SCROLL_DIST + 1 <= GetFirstVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nPos - CSV_SCROLL_DIST );
+ else if( nPos + CSV_SCROLL_DIST >= GetLastVisPos() )
+ Execute( CSVCMD_SETPOSOFFSET, nPos - GetVisPosCount() + CSV_SCROLL_DIST );
+ }
+}
+
+
+// cell contents --------------------------------------------------------------
+
+void ScCsvTableBox::SetUniStrings(
+ const String* pTextLines, const String& rSepChars,
+ sal_Unicode cTextSep, bool bMergeSep )
+{
+ // assuming that pTextLines is a string array with size CSV_PREVIEW_LINES
+ // -> will be dynamic sometime
+ DisableRepaint();
+ sal_Int32 nEndLine = GetFirstVisLine() + CSV_PREVIEW_LINES;
+ const String* pString = pTextLines;
+ for( sal_Int32 nLine = GetFirstVisLine(); nLine < nEndLine; ++nLine, ++pString )
+ {
+ if( mbFixedMode )
+ maGrid.ImplSetTextLineFix( nLine, *pString );
+ else
+ maGrid.ImplSetTextLineSep( nLine, *pString, rSepChars, cTextSep, bMergeSep );
+ }
+ EnableRepaint();
+}
+
+
+// column settings ------------------------------------------------------------
+
+void ScCsvTableBox::InitTypes( const ListBox& rListBox )
+{
+ sal_uInt16 nTypeCount = rListBox.GetEntryCount();
+ StringVec aTypeNames( nTypeCount );
+ for( sal_uInt16 nIndex = 0; nIndex < nTypeCount; ++nIndex )
+ aTypeNames[ nIndex ] = rListBox.GetEntry( nIndex );
+ maGrid.SetTypeNames( aTypeNames );
+}
+
+void ScCsvTableBox::FillColumnData( ScAsciiOptions& rOptions ) const
+{
+ if( mbFixedMode )
+ maGrid.FillColumnDataFix( rOptions );
+ else
+ maGrid.FillColumnDataSep( rOptions );
+}
+
+
+// event handling -------------------------------------------------------------
+
+void ScCsvTableBox::Resize()
+{
+ ScCsvControl::Resize();
+ InitControls();
+}
+
+void ScCsvTableBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ InitControls();
+ ScCsvControl::DataChanged( rDCEvt );
+}
+
+IMPL_LINK( ScCsvTableBox, CsvCmdHdl, ScCsvControl*, pCtrl )
+{
+ DBG_ASSERT( pCtrl, "ScCsvTableBox::CsvCmdHdl - missing sender" );
+
+ const ScCsvCmd& rCmd = pCtrl->GetCmd();
+ ScCsvCmdType eType = rCmd.GetType();
+ sal_Int32 nParam1 = rCmd.GetParam1();
+ sal_Int32 nParam2 = rCmd.GetParam2();
+
+ bool bFound = true;
+ switch( eType )
+ {
+ case CSVCMD_REPAINT:
+ if( !IsNoRepaint() )
+ {
+ maGrid.ImplRedraw();
+ maRuler.ImplRedraw();
+ InitHScrollBar();
+ InitVScrollBar();
+ }
+ break;
+ case CSVCMD_MAKEPOSVISIBLE:
+ MakePosVisible( nParam1 );
+ break;
+
+ case CSVCMD_NEWCELLTEXTS:
+ if( mbFixedMode )
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ else
+ {
+ DisableRepaint();
+ ScCsvColStateVec aStates( maGrid.GetColumnStates() );
+ sal_Int32 nPos = GetFirstVisPos();
+ Execute( CSVCMD_SETPOSCOUNT, 1 );
+ Execute( CSVCMD_UPDATECELLTEXTS );
+ Execute( CSVCMD_SETPOSOFFSET, nPos );
+ maGrid.SetColumnStates( aStates );
+ EnableRepaint();
+ }
+ break;
+ case CSVCMD_UPDATECELLTEXTS:
+ maUpdateTextHdl.Call( this );
+ break;
+ case CSVCMD_SETCOLUMNTYPE:
+ maGrid.SetSelColumnType( nParam1 );
+ break;
+ case CSVCMD_EXPORTCOLUMNTYPE:
+ maColTypeHdl.Call( this );
+ break;
+ case CSVCMD_SETFIRSTIMPORTLINE:
+ maGrid.SetFirstImportedLine( nParam1 );
+ break;
+
+ case CSVCMD_INSERTSPLIT:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::InsertSplit - invalid call" );
+ if( maRuler.GetSplitCount() + 1 < sal::static_int_cast<sal_uInt32>(CSV_MAXCOLCOUNT) )
+ {
+ maRuler.InsertSplit( nParam1 );
+ maGrid.InsertSplit( nParam1 );
+ }
+ break;
+ case CSVCMD_REMOVESPLIT:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::RemoveSplit - invalid call" );
+ maRuler.RemoveSplit( nParam1 );
+ maGrid.RemoveSplit( nParam1 );
+ break;
+ case CSVCMD_TOGGLESPLIT:
+ Execute( maRuler.HasSplit( nParam1 ) ? CSVCMD_REMOVESPLIT : CSVCMD_INSERTSPLIT, nParam1 );
+ break;
+ case CSVCMD_MOVESPLIT:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::MoveSplit - invalid call" );
+ maRuler.MoveSplit( nParam1, nParam2 );
+ maGrid.MoveSplit( nParam1, nParam2 );
+ break;
+ case CSVCMD_REMOVEALLSPLITS:
+ DBG_ASSERT( mbFixedMode, "ScCsvTableBox::CsvCmdHdl::RemoveAllSplits - invalid call" );
+ maRuler.RemoveAllSplits();
+ maGrid.RemoveAllSplits();
+ break;
+ default:
+ bFound = false;
+ }
+ if( bFound )
+ return 0;
+
+ const ScCsvLayoutData aOldData( maData );
+ switch( eType )
+ {
+ case CSVCMD_SETPOSCOUNT:
+ maData.mnPosCount = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetPosOffset( GetFirstVisPos() );
+ break;
+ case CSVCMD_SETPOSOFFSET:
+ ImplSetPosOffset( nParam1 );
+ break;
+ case CSVCMD_SETHDRWIDTH:
+ maData.mnHdrWidth = Max( nParam1, sal_Int32( 0 ) );
+ ImplSetPosOffset( GetFirstVisPos() );
+ break;
+ case CSVCMD_SETCHARWIDTH:
+ maData.mnCharWidth = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetPosOffset( GetFirstVisPos() );
+ break;
+ case CSVCMD_SETLINECOUNT:
+ maData.mnLineCount = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetLineOffset( GetFirstVisLine() );
+ break;
+ case CSVCMD_SETLINEOFFSET:
+ ImplSetLineOffset( nParam1 );
+ break;
+ case CSVCMD_SETHDRHEIGHT:
+ maData.mnHdrHeight = Max( nParam1, sal_Int32( 0 ) );
+ ImplSetLineOffset( GetFirstVisLine() );
+ break;
+ case CSVCMD_SETLINEHEIGHT:
+ maData.mnLineHeight = Max( nParam1, sal_Int32( 1 ) );
+ ImplSetLineOffset( GetFirstVisLine() );
+ break;
+ case CSVCMD_MOVERULERCURSOR:
+ maData.mnPosCursor = IsVisibleSplitPos( nParam1 ) ? nParam1 : CSV_POS_INVALID;
+ break;
+ case CSVCMD_MOVEGRIDCURSOR:
+ maData.mnColCursor = ((0 <= nParam1) && (nParam1 < GetPosCount())) ? nParam1 : CSV_POS_INVALID;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if( maData != aOldData )
+ {
+ DisableRepaint();
+ maRuler.ApplyLayout( aOldData );
+ maGrid.ApplyLayout( aOldData );
+ EnableRepaint();
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScCsvTableBox, ScrollHdl, ScrollBar*, pScrollBar )
+{
+ DBG_ASSERT( pScrollBar, "ScCsvTableBox::ScrollHdl - missing sender" );
+
+ if( pScrollBar == &maHScroll )
+ Execute( CSVCMD_SETPOSOFFSET, pScrollBar->GetThumbPos() );
+ else if( pScrollBar == &maVScroll )
+ Execute( CSVCMD_SETLINEOFFSET, pScrollBar->GetThumbPos() );
+
+ return 0;
+}
+
+IMPL_LINK( ScCsvTableBox, ScrollEndHdl, ScrollBar*, pScrollBar )
+{
+ DBG_ASSERT( pScrollBar, "ScCsvTableBox::ScrollEndHdl - missing sender" );
+
+ if( pScrollBar == &maHScroll )
+ {
+ if( GetRulerCursorPos() != CSV_POS_INVALID )
+ Execute( CSVCMD_MOVERULERCURSOR, maRuler.GetNoScrollPos( GetRulerCursorPos() ) );
+ if( GetGridCursorPos() != CSV_POS_INVALID )
+ Execute( CSVCMD_MOVEGRIDCURSOR, maGrid.GetNoScrollCol( GetGridCursorPos() ) );
+ }
+
+ return 0;
+}
+
+
+// accessibility --------------------------------------------------------------
+
+ScCsvTableBox::XAccessibleRef ScCsvTableBox::CreateAccessible()
+{
+ // do not use the ScCsvControl mechanism, return default accessible object
+ return Control::CreateAccessible();
+}
+
+ScAccessibleCsvControl* ScCsvTableBox::ImplCreateAccessible()
+{
+ return NULL; // not used, see CreateAccessible()
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/dapidata.cxx b/sc/source/ui/dbgui/dapidata.cxx
new file mode 100644
index 000000000000..34996739b1fd
--- /dev/null
+++ b/sc/source/ui/dbgui/dapidata.cxx
@@ -0,0 +1,231 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <tools/debug.hxx>
+#include <vcl/waitobj.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+
+using namespace com::sun::star;
+
+#include "dapidata.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "dapitype.hrc"
+#include "miscuno.hxx"
+#include "dpsdbtab.hxx" // ScImportSourceDesc
+
+//-------------------------------------------------------------------------
+
+#define DP_SERVICE_DBCONTEXT "com.sun.star.sdb.DatabaseContext"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
+
+// entries in the "type" ListBox
+#define DP_TYPELIST_TABLE 0
+#define DP_TYPELIST_QUERY 1
+#define DP_TYPELIST_SQL 2
+#define DP_TYPELIST_SQLNAT 3
+
+//-------------------------------------------------------------------------
+
+ScDataPilotDatabaseDlg::ScDataPilotDatabaseDlg( Window* pParent ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DAPIDATA ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aFtDatabase ( this, ScResId( FT_DATABASE ) ),
+ aLbDatabase ( this, ScResId( LB_DATABASE ) ),
+ aFtObject ( this, ScResId( FT_OBJECT ) ),
+ aCbObject ( this, ScResId( CB_OBJECT ) ),
+ aFtType ( this, ScResId( FT_OBJTYPE ) ),
+ aLbType ( this, ScResId( LB_OBJTYPE ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ FreeResource();
+
+ WaitObject aWait( this ); // initializing the database service the first time takes a while
+
+ try
+ {
+ // get database names
+
+ uno::Reference<container::XNameAccess> xContext(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( DP_SERVICE_DBCONTEXT ) ),
+ uno::UNO_QUERY);
+ if (xContext.is())
+ {
+ uno::Sequence<rtl::OUString> aNames = xContext->getElementNames();
+ long nCount = aNames.getLength();
+ const rtl::OUString* pArray = aNames.getConstArray();
+ for (long nPos = 0; nPos < nCount; nPos++)
+ {
+ String aName = pArray[nPos];
+ aLbDatabase.InsertEntry( aName );
+ }
+ }
+ }
+ catch(uno::Exception&)
+ {
+ DBG_ERROR("exception in database");
+ }
+
+ aLbDatabase.SelectEntryPos( 0 );
+ aLbType.SelectEntryPos( 0 );
+
+ FillObjects();
+
+ aLbDatabase.SetSelectHdl( LINK( this, ScDataPilotDatabaseDlg, SelectHdl ) );
+ aLbType.SetSelectHdl( LINK( this, ScDataPilotDatabaseDlg, SelectHdl ) );
+}
+
+ScDataPilotDatabaseDlg::~ScDataPilotDatabaseDlg()
+{
+}
+
+void ScDataPilotDatabaseDlg::GetValues( ScImportSourceDesc& rDesc )
+{
+ USHORT nSelect = aLbType.GetSelectEntryPos();
+
+ rDesc.aDBName = aLbDatabase.GetSelectEntry();
+ rDesc.aObject = aCbObject.GetText();
+
+ if ( !rDesc.aDBName.Len() || !rDesc.aObject.Len() )
+ rDesc.nType = sheet::DataImportMode_NONE;
+ else if ( nSelect == DP_TYPELIST_TABLE )
+ rDesc.nType = sheet::DataImportMode_TABLE;
+ else if ( nSelect == DP_TYPELIST_QUERY )
+ rDesc.nType = sheet::DataImportMode_QUERY;
+ else
+ rDesc.nType = sheet::DataImportMode_SQL;
+
+ rDesc.bNative = ( nSelect == DP_TYPELIST_SQLNAT );
+}
+
+IMPL_LINK( ScDataPilotDatabaseDlg, SelectHdl, ListBox*, EMPTYARG )
+{
+ FillObjects();
+ return 0;
+}
+
+void ScDataPilotDatabaseDlg::FillObjects()
+{
+ aCbObject.Clear();
+
+ String aDatabaseName = aLbDatabase.GetSelectEntry();
+ if (!aDatabaseName.Len())
+ return;
+
+ USHORT nSelect = aLbType.GetSelectEntryPos();
+ if ( nSelect > DP_TYPELIST_QUERY )
+ return; // only tables and queries
+
+ try
+ {
+ // open connection (for tables or queries)
+
+ uno::Reference<container::XNameAccess> xContext(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( DP_SERVICE_DBCONTEXT ) ),
+ uno::UNO_QUERY);
+ if ( !xContext.is() ) return;
+
+ uno::Any aSourceAny = xContext->getByName( aDatabaseName );
+ uno::Reference<sdb::XCompletedConnection> xSource(
+ ScUnoHelpFunctions::AnyToInterface( aSourceAny ), uno::UNO_QUERY );
+ if ( !xSource.is() ) return;
+
+ uno::Reference<task::XInteractionHandler> xHandler(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_INTHANDLER ) ),
+ uno::UNO_QUERY);
+
+ uno::Reference<sdbc::XConnection> xConnection = xSource->connectWithCompletion( xHandler );
+
+ uno::Sequence<rtl::OUString> aNames;
+ if ( nSelect == DP_TYPELIST_TABLE )
+ {
+ // get all tables
+
+ uno::Reference<sdbcx::XTablesSupplier> xTablesSupp( xConnection, uno::UNO_QUERY );
+ if ( !xTablesSupp.is() ) return;
+
+ uno::Reference<container::XNameAccess> xTables = xTablesSupp->getTables();
+ if ( !xTables.is() ) return;
+
+ aNames = xTables->getElementNames();
+ }
+ else
+ {
+ // get all queries
+
+ uno::Reference<sdb::XQueriesSupplier> xQueriesSupp( xConnection, uno::UNO_QUERY );
+ if ( !xQueriesSupp.is() ) return;
+
+ uno::Reference<container::XNameAccess> xQueries = xQueriesSupp->getQueries();
+ if ( !xQueries.is() ) return;
+
+ aNames = xQueries->getElementNames();
+ }
+
+ // fill list
+
+ long nCount = aNames.getLength();
+ const rtl::OUString* pArray = aNames.getConstArray();
+ for( long nPos=0; nPos<nCount; nPos++ )
+ {
+ String aName = pArray[nPos];
+ aCbObject.InsertEntry( aName );
+ }
+ }
+ catch(uno::Exception&)
+ {
+ // #71604# this may happen if an invalid database is selected -> no DBG_ERROR
+ DBG_WARNING("exception in database");
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/dapitype.cxx b/sc/source/ui/dbgui/dapitype.cxx
new file mode 100644
index 000000000000..b4943d265ffd
--- /dev/null
+++ b/sc/source/ui/dbgui/dapitype.cxx
@@ -0,0 +1,144 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "dapitype.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "dapitype.hrc"
+
+using namespace com::sun::star;
+
+//-------------------------------------------------------------------------
+
+ScDataPilotSourceTypeDlg::ScDataPilotSourceTypeDlg( Window* pParent, BOOL bEnableExternal ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DAPITYPE ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnSelection ( this, ScResId( BTN_SELECTION ) ),
+ aBtnDatabase ( this, ScResId( BTN_DATABASE ) ),
+ aBtnExternal ( this, ScResId( BTN_EXTERNAL ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ if (!bEnableExternal)
+ aBtnExternal.Disable();
+
+ aBtnSelection.Check();
+
+ FreeResource();
+}
+
+ScDataPilotSourceTypeDlg::~ScDataPilotSourceTypeDlg()
+{
+}
+
+BOOL ScDataPilotSourceTypeDlg::IsDatabase() const
+{
+ return aBtnDatabase.IsChecked();
+}
+
+BOOL ScDataPilotSourceTypeDlg::IsExternal() const
+{
+ return aBtnExternal.IsChecked();
+}
+
+//-------------------------------------------------------------------------
+
+ScDataPilotServiceDlg::ScDataPilotServiceDlg( Window* pParent,
+ const uno::Sequence<rtl::OUString>& rServices ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DAPISERVICE ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aFtService ( this, ScResId( FT_SERVICE ) ),
+ aLbService ( this, ScResId( LB_SERVICE ) ),
+ aFtSource ( this, ScResId( FT_SOURCE ) ),
+ aEdSource ( this, ScResId( ED_SOURCE ) ),
+ aFtName ( this, ScResId( FT_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ aFtUser ( this, ScResId( FT_USER ) ),
+ aEdUser ( this, ScResId( ED_USER ) ),
+ aFtPasswd ( this, ScResId( FT_PASSWD ) ),
+ aEdPasswd ( this, ScResId( ED_PASSWD ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ long nCount = rServices.getLength();
+ const rtl::OUString* pArray = rServices.getConstArray();
+ for (long i=0; i<nCount; i++)
+ {
+ String aName = pArray[i];
+ aLbService.InsertEntry( aName );
+ }
+ aLbService.SelectEntryPos( 0 );
+
+ FreeResource();
+}
+
+ScDataPilotServiceDlg::~ScDataPilotServiceDlg()
+{
+}
+
+String ScDataPilotServiceDlg::GetServiceName() const
+{
+ return aLbService.GetSelectEntry();
+}
+
+String ScDataPilotServiceDlg::GetParSource() const
+{
+ return aEdSource.GetText();
+}
+
+String ScDataPilotServiceDlg::GetParName() const
+{
+ return aEdName.GetText();
+}
+
+String ScDataPilotServiceDlg::GetParUser() const
+{
+ return aEdUser.GetText();
+}
+
+String ScDataPilotServiceDlg::GetParPass() const
+{
+ return aEdPasswd.GetText();
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/dapitype.hrc b/sc/source/ui/dbgui/dapitype.hrc
new file mode 100644
index 000000000000..c7800ca66840
--- /dev/null
+++ b/sc/source/ui/dbgui/dapitype.hrc
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_SELECTION 4
+#define BTN_DATABASE 5
+#define BTN_EXTERNAL 6
+#define FL_FRAME 7
+
+#define FT_SERVICE 8
+#define LB_SERVICE 9
+#define FT_SOURCE 10
+#define ED_SOURCE 11
+#define FT_NAME 12
+#define ED_NAME 13
+#define FT_USER 14
+#define ED_USER 15
+#define FT_PASSWD 16
+#define ED_PASSWD 17
+
+#define FT_DATABASE 18
+#define LB_DATABASE 19
+#define FT_OBJECT 20
+#define CB_OBJECT 21
+#define FT_OBJTYPE 22
+#define LB_OBJTYPE 23
+
diff --git a/sc/source/ui/dbgui/dapitype.src b/sc/source/ui/dbgui/dapitype.src
new file mode 100644
index 000000000000..7453f4af4121
--- /dev/null
+++ b/sc/source/ui/dbgui/dapitype.src
@@ -0,0 +1,308 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+#include "dapitype.hrc"
+
+
+ModalDialog RID_SCDLG_DAPITYPE
+{
+ OutputSize = TRUE ;
+ HelpId = HID_DATAPILOT_TYPE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 241 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 185 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 185 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 185 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_SELECTION
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Current selection";
+ };
+ RadioButton BTN_DATABASE
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Data source registered in %PRODUCTNAME";
+ };
+ RadioButton BTN_EXTERNAL
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~External source/interface";
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 173 , 8 ) ;
+ Text [ en-US ] = "Selection";
+ };
+ Text [ en-US ] = "Select Source";
+};
+
+
+//------------------------------------------------------------------------
+
+
+ModalDialog RID_SCDLG_DAPISERVICE
+{
+ OutputSize = TRUE ;
+ HelpId = HID_DATAPILOT_SERVICE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 241 , 94 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 185 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 185 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 185 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_SERVICE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Service";
+ };
+ ListBox LB_SERVICE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 12 ) ;
+ Size = MAP_APPFONT ( 120 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_SOURCE
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "So~urce";
+ };
+ Edit ED_SOURCE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 28 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 12 , 46 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Name";
+ };
+ Edit ED_NAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 44 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_USER
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "Us~er";
+ };
+ Edit ED_USER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 60 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_PASSWD
+ {
+ Pos = MAP_APPFONT ( 12 , 78 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "~Password";
+ };
+ Edit ED_PASSWD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 56 , 76 ) ;
+ Size = MAP_APPFONT ( 120 , 12 ) ;
+ TabStop = TRUE ;
+ PassWord = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 173 , 8 ) ;
+ Text [ en-US ] = "Selection";
+ };
+ Text [ en-US ] = "External Source";
+};
+
+
+//------------------------------------------------------------------------
+
+
+ModalDialog RID_SCDLG_DAPIDATA
+{
+ OutputSize = TRUE ;
+ HelpId = HID_DATAPILOT_DATABASE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 241 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 185 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 185 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 185 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ FixedText FT_DATABASE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "~Database";
+ };
+ ListBox LB_DATABASE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 12 ) ;
+ Size = MAP_APPFONT ( 110 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+
+ FixedText FT_OBJECT
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "Data so~urce";
+ };
+ ComboBox CB_OBJECT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 28 ) ;
+ Size = MAP_APPFONT ( 110 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+
+ FixedText FT_OBJTYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 46 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "~Type";
+ };
+ ListBox LB_OBJTYPE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 44 ) ;
+ Size = MAP_APPFONT ( 110 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Sheet" ; Default ; > ;
+ < "Query" ; Default ; > ;
+ < "Sql" ; Default ; > ;
+ < "Sql [Native]" ; Default ; > ;
+ };
+ };
+
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 173 , 8 ) ;
+ Text [ en-US ] = "Selection";
+ };
+ Text [ en-US ] = "Select Data Source";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/dbnamdlg.cxx b/sc/source/ui/dbgui/dbnamdlg.cxx
new file mode 100644
index 000000000000..e9bd5a888cd6
--- /dev/null
+++ b/sc/source/ui/dbgui/dbnamdlg.cxx
@@ -0,0 +1,723 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "dbnamdlg.hrc"
+#include "rangenam.hxx" // IsNameValid
+
+#define _DBNAMDLG_CXX
+#include "dbnamdlg.hxx"
+#undef _DBNAMDLG_CXX
+
+
+//============================================================================
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+//----------------------------------------------------------------------------
+
+class DBSaveData;
+
+static DBSaveData* pSaveObj = NULL;
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+//============================================================================
+// class DBSaveData
+
+class DBSaveData
+{
+public:
+ DBSaveData( Edit& rEd, CheckBox& rHdr, CheckBox& rSize, CheckBox& rFmt,
+ CheckBox& rStrip, ScRange& rArea )
+ : rEdAssign(rEd),
+ rBtnHeader(rHdr), rBtnSize(rSize), rBtnFormat(rFmt), rBtnStrip(rStrip),
+ rCurArea(rArea),
+ bHeader(FALSE), bSize(FALSE), bFormat(FALSE), bDirty(FALSE) {}
+ void Save();
+ void Restore();
+
+private:
+ Edit& rEdAssign;
+ CheckBox& rBtnHeader;
+ CheckBox& rBtnSize;
+ CheckBox& rBtnFormat;
+ CheckBox& rBtnStrip;
+ ScRange& rCurArea;
+ String aStr;
+ ScRange aArea;
+ BOOL bHeader:1;
+ BOOL bSize:1;
+ BOOL bFormat:1;
+ BOOL bStrip:1;
+ BOOL bDirty:1;
+};
+
+
+
+//----------------------------------------------------------------------------
+
+void DBSaveData::Save()
+{
+ aArea = rCurArea;
+ aStr = rEdAssign.GetText();
+ bHeader = rBtnHeader.IsChecked();
+ bSize = rBtnSize.IsChecked();
+ bFormat = rBtnFormat.IsChecked();
+ bStrip = rBtnStrip.IsChecked();
+ bDirty = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void DBSaveData::Restore()
+{
+ if ( bDirty )
+ {
+ rCurArea = aArea;
+ rEdAssign.SetText( aStr );
+ rBtnHeader.Check ( bHeader );
+ rBtnSize.Check ( bSize );
+ rBtnFormat.Check ( bFormat );
+ rBtnStrip.Check ( bStrip );
+ bDirty = FALSE;
+ }
+}
+
+
+//============================================================================
+// class ScDbNameDlg
+
+//----------------------------------------------------------------------------
+
+ScDbNameDlg::ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_DBNAMES ),
+ //
+ aFlName ( this, ScResId( FL_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aEdAssign ( this, this, ScResId( ED_DBAREA ) ),
+ aRbAssign ( this, ScResId( RB_DBAREA ), &aEdAssign, this ),
+
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnHeader ( this, ScResId( BTN_HEADER ) ),
+ aBtnDoSize ( this, ScResId( BTN_SIZE ) ),
+ aBtnKeepFmt ( this, ScResId( BTN_FORMAT ) ),
+ aBtnStripData ( this, ScResId( BTN_STRIPDATA ) ),
+ aFTSource ( this, ScResId( FT_SOURCE ) ),
+ aFTOperations ( this, ScResId( FT_OPERATIONS ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+
+ aStrAdd ( ScResId( STR_ADD ) ),
+ aStrModify ( ScResId( STR_MODIFY ) ),
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
+ aStrInvalid ( ScResId( STR_DB_INVALID ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ bRefInputMode ( FALSE ),
+ aAddrDetails ( pDoc->GetAddressConvention(), 0, 0 ),
+ aLocalDbCol ( *(pDoc->GetDBCollection()) )
+{
+ // WB_NOLABEL can't be set in resource...
+ aFTSource.SetStyle( aFTSource.GetStyle() | WB_NOLABEL );
+ aFTOperations.SetStyle( aFTOperations.GetStyle() | WB_NOLABEL );
+
+ // damit die Strings in der Resource bei den FixedTexten bleiben koennen:
+ aStrSource = aFTSource.GetText();
+ aStrOperations = aFTOperations.GetText();
+
+ pSaveObj = new DBSaveData( aEdAssign, aBtnHeader,
+ aBtnDoSize, aBtnKeepFmt, aBtnStripData, theCurArea );
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScDbNameDlg::~ScDbNameDlg()
+{
+ DELETEZ( pSaveObj );
+
+ ScRange* pEntry = (ScRange*)aRemoveList.First();
+ while ( pEntry )
+ {
+ aRemoveList.Remove( pEntry );
+ delete pEntry;
+ pEntry = (ScRange*)aRemoveList.Next();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDbNameDlg::Init()
+{
+ aBtnHeader.Check( TRUE ); // Default: mit Spaltenkoepfen
+
+ aBtnMore.AddWindow( &aFlOptions );
+ aBtnMore.AddWindow( &aBtnHeader );
+ aBtnMore.AddWindow( &aBtnDoSize );
+ aBtnMore.AddWindow( &aBtnKeepFmt );
+ aBtnMore.AddWindow( &aBtnStripData );
+ aBtnMore.AddWindow( &aFTSource );
+ aBtnMore.AddWindow( &aFTOperations );
+
+ String theAreaStr;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nStartTab = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ SCTAB nEndTab = 0;
+
+ aBtnOk.SetClickHdl ( LINK( this, ScDbNameDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScDbNameDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScDbNameDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScDbNameDlg, RemoveBtnHdl ) );
+ aEdName.SetModifyHdl ( LINK( this, ScDbNameDlg, NameModifyHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScDbNameDlg, AssModifyHdl ) );
+ UpdateNames();
+
+ if ( pViewData && pDoc )
+ {
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ ScDBData* pDBData = NULL;
+
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ theCurArea = ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
+ ScAddress( nEndCol, nEndRow, nEndTab ) );
+
+ theCurArea.Format( theAreaStr, ABS_DREF3D, pDoc, aAddrDetails );
+
+ if ( pDBColl )
+ {
+ // Feststellen, ob definierter DB-Bereich markiert wurde:
+ pDBData = pDBColl->GetDBAtCursor( nStartCol, nStartRow, nStartTab, TRUE );
+ if ( pDBData )
+ {
+ String theDbName;
+ ScAddress& rStart = theCurArea.aStart;
+ ScAddress& rEnd = theCurArea.aEnd;
+ SCCOL nCol1;
+ SCCOL nCol2;
+ SCROW nRow1;
+ SCROW nRow2;
+ SCTAB nTab;
+
+ pDBData->GetArea( nTab, nCol1, nRow1, nCol2, nRow2 );
+
+ if ( (rStart.Tab() == nTab)
+ && (rStart.Col() == nCol1) && (rStart.Row() == nRow1)
+ && (rEnd.Col() == nCol2) && (rEnd.Row() == nRow2 ) )
+ {
+ pDBData->GetName( theDbName );
+ if ( theDbName != aStrNoName )
+ aEdName.SetText( theDbName );
+ else
+ aEdName.SetText( EMPTY_STRING );
+ aBtnHeader.Check( pDBData->HasHeader() );
+ aBtnDoSize.Check( pDBData->IsDoSize() );
+ aBtnKeepFmt.Check( pDBData->IsKeepFmt() );
+ aBtnStripData.Check( pDBData->IsStripData() );
+ SetInfoStrings( pDBData );
+ }
+ }
+ }
+ }
+
+ aEdAssign.SetText( theAreaStr );
+ aEdName.GrabFocus();
+ bSaved=TRUE;
+ pSaveObj->Save();
+ NameModifyHdl( 0 );
+}
+
+
+void ScDbNameDlg::SetInfoStrings( const ScDBData* pDBData )
+{
+ String aSource = aStrSource;
+ if (pDBData)
+ {
+ aSource += ' ';
+ aSource += pDBData->GetSourceString();
+ }
+ aFTSource.SetText( aSource );
+
+ String aOper = aStrOperations;
+ if (pDBData)
+ {
+ aOper += ' ';
+ aOper += pDBData->GetOperations();
+ }
+ aFTOperations.SetText( aOper );
+}
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Fenster angezeigt wird.
+
+void ScDbNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( &aEdAssign );
+
+ theCurArea = rRef;
+
+ String aRefStr;
+ theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, aAddrDetails );
+ aEdAssign.SetRefString( aRefStr );
+ aBtnHeader.Enable();
+ aBtnDoSize.Enable();
+ aBtnKeepFmt.Enable();
+ aBtnStripData.Enable();
+ aFTSource.Enable();
+ aFTOperations.Enable();
+ aBtnAdd.Enable();
+ bSaved=TRUE;
+ pSaveObj->Save();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScDbNameDlg::Close()
+{
+ return DoClose( ScDbNameDlgWrapper::GetChildWindowId() );
+}
+
+//------------------------------------------------------------------------
+
+void ScDbNameDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+
+ // kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
+ // (nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
+ // (der ausgewaehlte DB-Name hat sich auch nicht veraendert)
+
+ RefInputDone();
+}
+
+//------------------------------------------------------------------------
+
+void ScDbNameDlg::UpdateNames()
+{
+ USHORT nNameCount = aLocalDbCol.GetCount();
+
+ aEdName.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ aEdName.Clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ if ( nNameCount > 0 )
+ {
+ ScDBData* pDbData = NULL;
+ String aString;
+
+ for ( USHORT i=0; i<nNameCount; i++ )
+ {
+ pDbData = (ScDBData*)(aLocalDbCol.At( i ));
+ if ( pDbData )
+ {
+ pDbData->GetName( aString );
+ if ( aString != aStrNoName )
+ aEdName.InsertEntry( aString );
+ }
+ }
+ }
+ else
+ {
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ //-----------------------------------------------------------
+ aEdName.SetUpdateMode( TRUE );
+ aEdName.Invalidate();
+}
+
+//------------------------------------------------------------------------
+
+void ScDbNameDlg::UpdateDBData( const String& rStrName )
+{
+ String theArea;
+ USHORT nAt;
+ ScDBData* pData;
+
+ aLocalDbCol.SearchName( rStrName, nAt );
+ pData = (ScDBData*)(aLocalDbCol.At( nAt ));
+
+ if ( pData )
+ {
+ SCCOL nColStart = 0;
+ SCROW nRowStart = 0;
+ SCCOL nColEnd = 0;
+ SCROW nRowEnd = 0;
+ SCTAB nTab = 0;
+
+ pData->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
+ theCurArea = ScRange( ScAddress( nColStart, nRowStart, nTab ),
+ ScAddress( nColEnd, nRowEnd, nTab ) );
+ theCurArea.Format( theArea, ABS_DREF3D, pDoc, aAddrDetails );
+ aEdAssign.SetText( theArea );
+ aBtnAdd.SetText( aStrModify );
+ aBtnHeader.Check( pData->HasHeader() );
+ aBtnDoSize.Check( pData->IsDoSize() );
+ aBtnKeepFmt.Check( pData->IsKeepFmt() );
+ aBtnStripData.Check( pData->IsStripData() );
+ SetInfoStrings( pData );
+ }
+
+ aBtnAdd.SetText( aStrModify );
+ aBtnAdd.Enable();
+ aBtnRemove.Enable();
+ aBtnHeader.Enable();
+ aBtnDoSize.Enable();
+ aBtnKeepFmt.Enable();
+ aBtnStripData.Enable();
+ aFTSource.Enable();
+ aFTOperations.Enable();
+}
+
+//------------------------------------------------------------------------
+
+
+BOOL ScDbNameDlg::IsRefInputMode() const
+{
+ return bRefInputMode;
+}
+
+//------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScDbNameDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ AddBtnHdl( 0 );
+
+ // Der View die Aenderungen und die Remove-Liste uebergeben:
+ // beide werden nur als Referenz uebergeben, so dass an dieser
+ // Stelle keine Speicherleichen entstehen koennen:
+ if ( pViewData )
+ pViewData->GetView()->
+ NotifyCloseDbNameDlg( aLocalDbCol, aRemoveList );
+
+ Close();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScDbNameDlg, CancelBtnHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ String aNewName = aEdName.GetText();
+ String aNewArea = aEdAssign.GetText();
+
+ aNewName.EraseLeadingChars( ' ' );
+ aNewName.EraseTrailingChars( ' ' );
+
+ if ( aNewName.Len() > 0 && aNewArea.Len() > 0 )
+ {
+ if ( ScRangeData::IsNameValid( aNewName, pDoc ) )
+ {
+ // weil jetzt editiert werden kann, muss erst geparst werden
+ ScRange aTmpRange;
+ String aText = aEdAssign.GetText();
+ if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
+ {
+ theCurArea = aTmpRange;
+ ScAddress aStart = theCurArea.aStart;
+ ScAddress aEnd = theCurArea.aEnd;
+
+ ScDBData* pOldEntry = NULL;
+ USHORT nFoundAt = 0;
+ if ( aLocalDbCol.SearchName( aNewName, nFoundAt ) )
+ pOldEntry = aLocalDbCol[nFoundAt];
+ if (pOldEntry)
+ {
+ // Bereich veraendern
+
+ pOldEntry->MoveTo( aStart.Tab(), aStart.Col(), aStart.Row(),
+ aEnd.Col(), aEnd.Row() );
+ pOldEntry->SetByRow( TRUE );
+ pOldEntry->SetHeader( aBtnHeader.IsChecked() );
+ pOldEntry->SetDoSize( aBtnDoSize.IsChecked() );
+ pOldEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
+ pOldEntry->SetStripData( aBtnStripData.IsChecked() );
+ }
+ else
+ {
+ // neuen Bereich einfuegen
+
+ ScDBData* pNewEntry = new ScDBData( aNewName, aStart.Tab(),
+ aStart.Col(), aStart.Row(),
+ aEnd.Col(), aEnd.Row(),
+ TRUE, aBtnHeader.IsChecked() );
+ pNewEntry->SetDoSize( aBtnDoSize.IsChecked() );
+ pNewEntry->SetKeepFmt( aBtnKeepFmt.IsChecked() );
+ pNewEntry->SetStripData( aBtnStripData.IsChecked() );
+
+ if ( !aLocalDbCol.Insert( pNewEntry ) )
+ delete pNewEntry;
+ }
+
+ UpdateNames();
+
+ aEdName.SetText( EMPTY_STRING );
+ aEdName.GrabFocus();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ aBtnHeader.Check( TRUE ); // Default: mit Spaltenkoepfen
+ aBtnDoSize.Check( FALSE );
+ aBtnKeepFmt.Check( FALSE );
+ aBtnStripData.Check( FALSE );
+ SetInfoStrings( NULL ); // leer
+ theCurArea = ScRange();
+ bSaved=TRUE;
+ pSaveObj->Save();
+ NameModifyHdl( 0 );
+ }
+ else
+ {
+ ERRORBOX( aStrInvalid );
+ aEdAssign.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdAssign.GrabFocus();
+ }
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
+ aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdName.GrabFocus();
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ USHORT nRemoveAt = 0;
+ const String aStrEntry = aEdName.GetText();
+
+ if ( aLocalDbCol.SearchName( aStrEntry, nRemoveAt ) )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aStrEntry;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES == QUERYBOX(aMsg) )
+ {
+ ScDBData* pEntry = (ScDBData*)aLocalDbCol.At(nRemoveAt);
+
+ if ( pEntry )
+ {
+ SCTAB nTab;
+ SCCOL nColStart, nColEnd;
+ SCROW nRowStart, nRowEnd;
+ pEntry->GetArea( nTab, nColStart, nRowStart, nColEnd, nRowEnd );
+ aRemoveList.Insert(
+ new ScRange( ScAddress( nColStart, nRowStart, nTab ),
+ ScAddress( nColEnd, nRowEnd, nTab ) ) );
+ }
+ aLocalDbCol.AtFree( nRemoveAt );
+
+ UpdateNames();
+
+ aEdName.SetText( EMPTY_STRING );
+ aEdName.GrabFocus();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = ScRange();
+ aBtnHeader.Check( TRUE ); // Default: mit Spaltenkoepfen
+ aBtnDoSize.Check( FALSE );
+ aBtnKeepFmt.Check( FALSE );
+ aBtnStripData.Check( FALSE );
+ SetInfoStrings( NULL ); // leer
+ bSaved=FALSE;
+ pSaveObj->Restore();
+ NameModifyHdl( 0 );
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, NameModifyHdl, void *, EMPTYARG )
+{
+ String theName = aEdName.GetText();
+ BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND
+ != aEdName.GetEntryPos( theName ));
+
+ if ( theName.Len() == 0 )
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd .Disable();
+ aBtnRemove .Disable();
+ aFlAssign .Disable();
+ aBtnHeader .Disable();
+ aBtnDoSize .Disable();
+ aBtnKeepFmt .Disable();
+ aBtnStripData.Disable();
+ aFTSource .Disable();
+ aFTOperations.Disable();
+ aEdAssign .Disable();
+ aRbAssign .Disable();
+ //bSaved=FALSE;
+ //pSaveObj->Restore();
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ bRefInputMode = FALSE;
+ }
+ else
+ {
+ if ( bNameFound )
+ {
+ if ( aBtnAdd.GetText() != aStrModify )
+ aBtnAdd.SetText( aStrModify );
+
+ if(!bSaved)
+ {
+ bSaved=TRUE;
+ pSaveObj->Save();
+ }
+ UpdateDBData( theName );
+ }
+ else
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+
+ bSaved=FALSE;
+ pSaveObj->Restore();
+
+ if ( aEdAssign.GetText().Len() > 0 )
+ {
+ aBtnAdd.Enable();
+ aBtnHeader.Enable();
+ aBtnDoSize.Enable();
+ aBtnKeepFmt.Enable();
+ aBtnStripData.Enable();
+ aFTSource.Enable();
+ aFTOperations.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnHeader.Disable();
+ aBtnDoSize.Disable();
+ aBtnKeepFmt.Disable();
+ aBtnStripData.Disable();
+ aFTSource.Disable();
+ aFTOperations.Disable();
+ }
+ aBtnRemove.Disable();
+ }
+
+ aFlAssign.Enable();
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ bRefInputMode = TRUE;
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScDbNameDlg, AssModifyHdl, void *, EMPTYARG )
+{
+ // hier parsen fuer Save() etc.
+
+ ScRange aTmpRange;
+ String aText = aEdAssign.GetText();
+ if ( aTmpRange.ParseAny( aText, pDoc, aAddrDetails ) & SCA_VALID )
+ theCurArea = aTmpRange;
+
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/dpgroupdlg.cxx b/sc/source/ui/dbgui/dpgroupdlg.cxx
new file mode 100644
index 000000000000..d206783c358a
--- /dev/null
+++ b/sc/source/ui/dbgui/dpgroupdlg.cxx
@@ -0,0 +1,358 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#ifdef SC_DLLIMPLEMENTATION
+#undef SC_DLLIMPLEMENTATION
+#endif
+
+
+#include "dpgroupdlg.hxx"
+#include "dpgroupdlg.hrc"
+#include <tools/resary.hxx>
+#include "scresid.hxx"
+#include "sc.hrc"
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+
+// ============================================================================
+
+namespace {
+
+/** Date part flags in order of the list box entries. */
+static const sal_Int32 spnDateParts[] =
+{
+ com::sun::star::sheet::DataPilotFieldGroupBy::SECONDS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::MINUTES,
+ com::sun::star::sheet::DataPilotFieldGroupBy::HOURS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::DAYS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::QUARTERS,
+ com::sun::star::sheet::DataPilotFieldGroupBy::YEARS
+};
+
+} // namespace
+
+// ============================================================================
+
+ScDPGroupEditHelper::ScDPGroupEditHelper( RadioButton& rRbAuto, RadioButton& rRbMan, Edit& rEdValue ) :
+ mrRbAuto( rRbAuto ),
+ mrRbMan( rRbMan ),
+ mrEdValue( rEdValue )
+{
+ mrRbAuto.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) );
+ mrRbMan.SetClickHdl( LINK( this, ScDPGroupEditHelper, ClickHdl ) );
+}
+
+bool ScDPGroupEditHelper::IsAuto() const
+{
+ return mrRbAuto.IsChecked();
+}
+
+double ScDPGroupEditHelper::GetValue() const
+{
+ double fValue;
+ if( !ImplGetValue( fValue ) )
+ fValue = 0.0;
+ return fValue;
+}
+
+void ScDPGroupEditHelper::SetValue( bool bAuto, double fValue )
+{
+ if( bAuto )
+ {
+ mrRbAuto.Check();
+ ClickHdl( &mrRbAuto );
+ }
+ else
+ {
+ mrRbMan.Check();
+ ClickHdl( &mrRbMan );
+ }
+ ImplSetValue( fValue );
+}
+
+IMPL_LINK( ScDPGroupEditHelper, ClickHdl, RadioButton*, pButton )
+{
+ if( pButton == &mrRbAuto )
+ {
+ // disable edit field on clicking "automatic" radio button
+ mrEdValue.Disable();
+ }
+ else if( pButton == &mrRbMan )
+ {
+ // enable and set focus to edit field on clicking "manual" radio button
+ mrEdValue.Enable();
+ mrEdValue.GrabFocus();
+ }
+ return 0;
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPNumGroupEditHelper::ScDPNumGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan, ScDoubleField& rEdValue ) :
+ ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ),
+ mrEdValue( rEdValue )
+{
+}
+
+bool ScDPNumGroupEditHelper::ImplGetValue( double& rfValue ) const
+{
+ return mrEdValue.GetValue( rfValue );
+}
+
+void ScDPNumGroupEditHelper::ImplSetValue( double fValue )
+{
+ mrEdValue.SetValue( fValue );
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPDateGroupEditHelper::ScDPDateGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan, DateField& rEdValue, const Date& rNullDate ) :
+ ScDPGroupEditHelper( rRbAuto, rRbMan, rEdValue ),
+ mrEdValue( rEdValue ),
+ maNullDate( rNullDate )
+{
+}
+
+bool ScDPDateGroupEditHelper::ImplGetValue( double& rfValue ) const
+{
+ rfValue = mrEdValue.GetDate() - maNullDate;
+ return true;
+}
+
+void ScDPDateGroupEditHelper::ImplSetValue( double fValue )
+{
+ Date aDate( maNullDate );
+ aDate += static_cast< sal_Int32 >( fValue );
+ mrEdValue.SetDate( aDate );
+}
+
+// ============================================================================
+// ============================================================================
+
+ScDPNumGroupDlg::ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPNUMGROUP ) ),
+ maFlStart ( this, ScResId( FL_START ) ),
+ maRbAutoStart ( this, ScResId( RB_AUTOSTART ) ),
+ maRbManStart ( this, ScResId( RB_MANSTART ) ),
+ maEdStart ( this, ScResId( ED_START ) ),
+ maFlEnd ( this, ScResId( FL_END ) ),
+ maRbAutoEnd ( this, ScResId( RB_AUTOEND ) ),
+ maRbManEnd ( this, ScResId( RB_MANEND ) ),
+ maEdEnd ( this, ScResId( ED_END ) ),
+ maFlBy ( this, ScResId( FL_BY ) ),
+ maEdBy ( this, ScResId( ED_BY ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maStartHelper ( maRbAutoStart, maRbManStart, maEdStart ),
+ maEndHelper ( maRbAutoEnd, maRbManEnd, maEdEnd )
+{
+ FreeResource();
+
+ maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
+ maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
+ maEdBy.SetValue( (rInfo.Step <= 0.0) ? 1.0 : rInfo.Step );
+
+ /* Set the initial focus, currently it is somewhere after calling all the radio
+ button click handlers. Now the first enabled editable control is focused. */
+ if( maEdStart.IsEnabled() )
+ maEdStart.GrabFocus();
+ else if( maEdEnd.IsEnabled() )
+ maEdEnd.GrabFocus();
+ else
+ maEdBy.GrabFocus();
+}
+
+ScDPNumGroupInfo ScDPNumGroupDlg::GetGroupInfo() const
+{
+ ScDPNumGroupInfo aInfo;
+ aInfo.Enable = sal_True;
+ aInfo.DateValues = sal_False;
+ aInfo.AutoStart = maStartHelper.IsAuto();
+ aInfo.AutoEnd = maEndHelper.IsAuto();
+
+ // get values and silently auto-correct them, if they are not valid
+ // TODO: error messages in OK event?
+ aInfo.Start = maStartHelper.GetValue();
+ aInfo.End = maEndHelper.GetValue();
+ if( !maEdBy.GetValue( aInfo.Step ) || (aInfo.Step <= 0.0) )
+ aInfo.Step = 1.0;
+ if( aInfo.End <= aInfo.Start )
+ aInfo.End = aInfo.Start + aInfo.Step;
+
+ return aInfo;
+}
+
+// ============================================================================
+
+ScDPDateGroupDlg::ScDPDateGroupDlg( Window* pParent,
+ const ScDPNumGroupInfo& rInfo, sal_Int32 nDatePart, const Date& rNullDate ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATEGROUP ) ),
+ maFlStart ( this, ScResId( FL_START ) ),
+ maRbAutoStart ( this, ScResId( RB_AUTOSTART ) ),
+ maRbManStart ( this, ScResId( RB_MANSTART ) ),
+ maEdStart ( this, ScResId( ED_START ) ),
+ maFlEnd ( this, ScResId( FL_END ) ),
+ maRbAutoEnd ( this, ScResId( RB_AUTOEND ) ),
+ maRbManEnd ( this, ScResId( RB_MANEND ) ),
+ maEdEnd ( this, ScResId( ED_END ) ),
+ maFlBy ( this, ScResId( FL_BY ) ),
+ maRbNumDays ( this, ScResId( RB_NUMDAYS ) ),
+ maRbUnits ( this, ScResId( RB_UNITS ) ),
+ maEdNumDays ( this, ScResId( ED_NUMDAYS ) ),
+ maLbUnits ( this, ScResId( LB_UNITS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maStartHelper ( maRbAutoStart, maRbManStart, maEdStart, rNullDate ),
+ maEndHelper ( maRbAutoEnd, maRbManEnd, maEdEnd, rNullDate )
+{
+ maLbUnits.SetHelpId( HID_SC_DPDATEGROUP_LB );
+ ResStringArray aArr( ScResId( STR_UNITS ) );
+ for( USHORT nIdx = 0, nCount = sal::static_int_cast<USHORT>(aArr.Count()); nIdx < nCount; ++nIdx )
+ maLbUnits.InsertEntry( aArr.GetString( nIdx ) );
+
+ FreeResource();
+
+ maEdStart.SetShowDateCentury( TRUE );
+ maEdEnd.SetShowDateCentury( TRUE );
+
+ maStartHelper.SetValue( rInfo.AutoStart, rInfo.Start );
+ maEndHelper.SetValue( rInfo.AutoEnd, rInfo.End );
+
+ if( nDatePart == 0 )
+ nDatePart = com::sun::star::sheet::DataPilotFieldGroupBy::MONTHS;
+ for( ULONG nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx )
+ maLbUnits.CheckEntryPos( static_cast< USHORT >( nIdx ), (nDatePart & spnDateParts[ nIdx ]) != 0 );
+
+ if( rInfo.DateValues )
+ {
+ maRbNumDays.Check();
+ ClickHdl( &maRbNumDays );
+
+ double fNumDays = rInfo.Step;
+ if( fNumDays < 1.0 )
+ fNumDays = 1.0;
+ else if( fNumDays > 32767.0 )
+ fNumDays = 32767.0;
+ maEdNumDays.SetValue( static_cast< long >( fNumDays ) );
+ }
+ else
+ {
+ maRbUnits.Check();
+ ClickHdl( &maRbUnits );
+ }
+
+ /* Set the initial focus, currently it is somewhere after calling all the radio
+ button click handlers. Now the first enabled editable control is focused. */
+ if( maEdStart.IsEnabled() )
+ maEdStart.GrabFocus();
+ else if( maEdEnd.IsEnabled() )
+ maEdEnd.GrabFocus();
+ else if( maEdNumDays.IsEnabled() )
+ maEdNumDays.GrabFocus();
+ else if( maLbUnits.IsEnabled() )
+ maLbUnits.GrabFocus();
+
+ maRbNumDays.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) );
+ maRbUnits.SetClickHdl( LINK( this, ScDPDateGroupDlg, ClickHdl ) );
+ maLbUnits.SetCheckButtonHdl( LINK( this, ScDPDateGroupDlg, CheckHdl ) );
+}
+
+ScDPNumGroupInfo ScDPDateGroupDlg::GetGroupInfo() const
+{
+ ScDPNumGroupInfo aInfo;
+ aInfo.Enable = sal_True;
+ aInfo.DateValues = maRbNumDays.IsChecked();
+ aInfo.AutoStart = maStartHelper.IsAuto();
+ aInfo.AutoEnd = maEndHelper.IsAuto();
+
+ // get values and silently auto-correct them, if they are not valid
+ // TODO: error messages in OK event?
+ aInfo.Start = maStartHelper.GetValue();
+ aInfo.End = maEndHelper.GetValue();
+ sal_Int64 nNumDays = maEdNumDays.GetValue();
+ aInfo.Step = static_cast<double>( aInfo.DateValues ? nNumDays : 0L );
+ if( aInfo.End <= aInfo.Start )
+ aInfo.End = aInfo.Start + nNumDays;
+
+ return aInfo;
+}
+
+sal_Int32 ScDPDateGroupDlg::GetDatePart() const
+{
+ // return DAYS for special "number of days" mode
+ if( maRbNumDays.IsChecked() )
+ return com::sun::star::sheet::DataPilotFieldGroupBy::DAYS;
+
+ // return listbox contents for "units" mode
+ sal_Int32 nDatePart = 0;
+ for( ULONG nIdx = 0, nCount = maLbUnits.GetEntryCount(); nIdx < nCount; ++nIdx )
+ if( maLbUnits.IsChecked( static_cast< USHORT >( nIdx ) ) )
+ nDatePart |= spnDateParts[ nIdx ];
+ return nDatePart;
+}
+
+IMPL_LINK( ScDPDateGroupDlg, ClickHdl, RadioButton*, pButton )
+{
+ if( pButton == &maRbNumDays )
+ {
+ maLbUnits.Disable();
+ // enable and set focus to edit field on clicking "num of days" radio button
+ maEdNumDays.Enable();
+ maEdNumDays.GrabFocus();
+ maBtnOk.Enable();
+ }
+ else if( pButton == &maRbUnits )
+ {
+ maEdNumDays.Disable();
+ // enable and set focus to listbox on clicking "units" radio button
+ maLbUnits.Enable();
+ maLbUnits.GrabFocus();
+ // disable OK button if no date part selected
+ CheckHdl( &maLbUnits );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPDateGroupDlg, CheckHdl, SvxCheckListBox*, pListBox )
+{
+ // enable/disable OK button on modifying check list box
+ if( pListBox == &maLbUnits )
+ maBtnOk.Enable( maLbUnits.GetCheckedEntryCount() > 0 );
+ return 0;
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/dpgroupdlg.hrc b/sc/source/ui/dbgui/dpgroupdlg.hrc
new file mode 100644
index 000000000000..a75edbb32345
--- /dev/null
+++ b/sc/source/ui/dbgui/dpgroupdlg.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DPGROUPDLG_HRC
+#define SC_DPGROUPDLG_HRC
+
+#include "sc.hrc"
+
+// push buttons
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+// fixed lines
+#define FL_START 1
+#define FL_END 2
+#define FL_BY 3
+
+// radio buttons
+#define RB_AUTOSTART 1
+#define RB_MANSTART 2
+#define RB_AUTOEND 3
+#define RB_MANEND 4
+#define RB_NUMDAYS 5
+#define RB_UNITS 6
+
+// edit fields
+#define ED_START 1
+#define ED_END 2
+#define ED_BY 3
+#define ED_NUMDAYS 4
+
+// list boxes
+#define LB_UNITS 1
+
+// strings/string arrays
+#define STR_UNITS 1
+
+#endif
+
diff --git a/sc/source/ui/dbgui/dpgroupdlg.src b/sc/source/ui/dbgui/dpgroupdlg.src
new file mode 100644
index 000000000000..ba2aaec3edc1
--- /dev/null
+++ b/sc/source/ui/dbgui/dpgroupdlg.src
@@ -0,0 +1,270 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dpgroupdlg.hrc"
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPNUMGROUP
+{
+ Size = MAP_APPFONT ( 220 , 110 ) ;
+ HelpId = HID_SC_DPNUMGROUP ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ FixedLine FL_START
+ {
+ Pos = MAP_APPFONT ( 6, 3 ) ;
+ Size = MAP_APPFONT ( 152, 8 ) ;
+ Text [ en-US ] = "Start" ;
+ };
+ RadioButton RB_AUTOSTART
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Automatically" ;
+ };
+ RadioButton RB_MANSTART
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Manually at" ;
+ };
+ Edit ED_START
+ {
+ Pos = MAP_APPFONT ( 94 , 26 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 6 , 42 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "End" ;
+ };
+ RadioButton RB_AUTOEND
+ {
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "A~utomatically" ;
+ };
+ RadioButton RB_MANEND
+ {
+ Pos = MAP_APPFONT ( 12 , 67 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Ma~nually at" ;
+ };
+ Edit ED_END
+ {
+ Pos = MAP_APPFONT ( 94 , 65 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_BY
+ {
+ Pos = MAP_APPFONT ( 6 , 81 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "~Group by" ;
+ };
+ Edit ED_BY
+ {
+ Pos = MAP_APPFONT ( 94 , 92 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Grouping" ;
+} ;
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPDATEGROUP
+{
+ Size = MAP_APPFONT ( 220 , 180 ) ;
+ HelpId = HID_SC_DPDATEGROUP ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ FixedLine FL_START
+ {
+ Pos = MAP_APPFONT ( 6, 3 ) ;
+ Size = MAP_APPFONT ( 152, 8 ) ;
+ Text [ en-US ] = "Start" ;
+ };
+ RadioButton RB_AUTOSTART
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Automatically" ;
+ };
+ RadioButton RB_MANSTART
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Manually at" ;
+ };
+ DateField ED_START
+ {
+ Pos = MAP_APPFONT ( 94 , 26 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 6 , 42 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "End" ;
+ };
+ RadioButton RB_AUTOEND
+ {
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "A~utomatically" ;
+ };
+ RadioButton RB_MANEND
+ {
+ Pos = MAP_APPFONT ( 12 , 67 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Ma~nually at" ;
+ };
+ DateField ED_END
+ {
+ Pos = MAP_APPFONT ( 94 , 65 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ };
+ FixedLine FL_BY
+ {
+ Pos = MAP_APPFONT ( 6 , 81 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "Group by" ;
+ };
+ RadioButton RB_NUMDAYS
+ {
+ Pos = MAP_APPFONT ( 12 , 94 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Number of ~days" ;
+ };
+ RadioButton RB_UNITS
+ {
+ Pos = MAP_APPFONT ( 12 , 110 ) ;
+ Size = MAP_APPFONT ( 80 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Intervals" ;
+ };
+ NumericField ED_NUMDAYS
+ {
+ Pos = MAP_APPFONT ( 94, 92 ) ;
+ Size = MAP_APPFONT ( 35, 12 ) ;
+ TabStop = TRUE ;
+ Border = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 32767 ;
+ SpinSize = 1 ;
+ };
+ Control LB_UNITS
+ {
+ Pos = MAP_APPFONT( 94, 110 );
+ Size = MAP_APPFONT( 58, 64 );
+ TabStop = TRUE;
+ Border = TRUE;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ StringArray STR_UNITS
+ {
+ ItemList [ en-US ] =
+ {
+ < "Seconds" ; Default ; > ;
+ < "Minutes" ; Default ; > ;
+ < "Hours" ; Default ; > ;
+ < "Days" ; Default ; > ;
+ < "Months" ; Default ; > ;
+ < "Quarters" ; Default ; > ;
+ < "Years" ; Default ; > ;
+ } ;
+ } ;
+ Text [ en-US ] = "Grouping" ;
+} ;
+
+// ----------------------------------------------------------------------------
+
diff --git a/sc/source/ui/dbgui/expftext.cxx b/sc/source/ui/dbgui/expftext.cxx
new file mode 100644
index 000000000000..01a66100d226
--- /dev/null
+++ b/sc/source/ui/dbgui/expftext.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "expftext.hxx"
+#include <vcl/help.hxx>
+
+/*************************************************************************
+#* Member: ScExpandedFixedText Datum:18.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: MD_Test
+#*
+#* Funktion: Konstruktor der Klasse SvxCtrDial
+#*
+#* Input: Parent- Window, Resource ID
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScExpandedFixedText::ScExpandedFixedText( Window* pParent,
+ const ResId& rResId) :
+ FixedText( pParent, rResId )
+{
+
+}
+
+/*************************************************************************
+#* Member: RequestHelp Datum:18.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScExpandedFixedText
+#*
+#* Funktion: Die Methode wird gerufen, um Hilfe fuer das Fenster
+#* anzuzeigen. Zeigt das Fenster einen gekuerzten Text
+#* an, so wird selbiger in voller Laenge angezeigt.
+#*
+#* Input: HelpEvent
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScExpandedFixedText::RequestHelp(const HelpEvent& rEvt)
+{
+ String aTxtStr = GetText();
+ long nTxtWidth = GetTextWidth(aTxtStr);
+ if ( ( rEvt.GetMode() & HELPMODE_QUICK ) == HELPMODE_QUICK &&
+ nTxtWidth > GetSizePixel().Width())
+ {
+ Point aShowPoint = OutputToScreenPixel(Point(0,0));
+ long nTxtHeight = GetTextHeight();
+
+ Help::ShowQuickHelp( this,
+ Rectangle( aShowPoint, Size(nTxtWidth,nTxtHeight) ), aTxtStr,
+ QUICKHELP_TOP|QUICKHELP_LEFT );
+ }
+ else
+ {
+ FixedText::RequestHelp( rEvt );
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
new file mode 100644
index 000000000000..2aa99870587f
--- /dev/null
+++ b/sc/source/ui/dbgui/fieldwnd.cxx
@@ -0,0 +1,778 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <vcl/virdev.hxx>
+#include <vcl/decoview.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/help.hxx>
+#include <tools/debug.hxx>
+
+#include "fieldwnd.hxx"
+#include "pvlaydlg.hxx"
+#include "pvglob.hxx"
+#include "AccessibleDataPilotControl.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+const size_t INVALID_INDEX = static_cast< size_t >( -1 );
+
+//===================================================================
+
+ScDPFieldWindow::ScDPFieldWindow(
+ ScDPLayoutDlg* pDialog,
+ const ResId& rResId,
+ ScDPFieldType eFieldType,
+ FixedText* pFtFieldCaption ) :
+ Control( pDialog, rResId ),
+ pDlg( pDialog ),
+ pFtCaption( pFtFieldCaption ),
+ eType( eFieldType ),
+ nFieldSelected( 0 ),
+ pAccessible( NULL )
+{
+ Init();
+ if (eType != TYPE_SELECT && pFtCaption)
+ aName = MnemonicGenerator::EraseAllMnemonicChars( pFtCaption->GetText() );
+}
+
+ScDPFieldWindow::ScDPFieldWindow(
+ ScDPLayoutDlg* pDialog,
+ const ResId& rResId,
+ ScDPFieldType eFieldType,
+ const String& rName ) :
+ Control( pDialog, rResId ),
+ aName(rName),
+ pDlg( pDialog ),
+ pFtCaption( NULL ),
+ eType( eFieldType ),
+ nFieldSelected( 0 ),
+ pAccessible( NULL )
+{
+ Init();
+}
+
+void ScDPFieldWindow::Init()
+{
+ aWndRect = Rectangle( GetPosPixel(), GetSizePixel() );
+ nFieldSize = (eType == TYPE_SELECT) ? PAGE_SIZE : ((eType == TYPE_PAGE) ? MAX_PAGEFIELDS : MAX_FIELDS);
+
+ if( pFtCaption )
+ {
+ Size aWinSize( aWndRect.GetSize() );
+ Size aTextSize( GetTextWidth( pFtCaption->GetText() ), GetTextHeight() );
+ aTextPos.X() = (aWinSize.Width() - aTextSize.Width()) / 2;
+ aTextPos.Y() = (aWinSize.Height() - aTextSize.Height()) / 2;
+ }
+
+ GetStyleSettings();
+}
+
+__EXPORT ScDPFieldWindow::~ScDPFieldWindow()
+{
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->dispose();
+ }
+}
+
+//-------------------------------------------------------------------
+
+void ScDPFieldWindow::GetStyleSettings()
+{
+ const StyleSettings& rStyleSet = GetSettings().GetStyleSettings();
+ aFaceColor = rStyleSet.GetFaceColor();
+ aWinColor = rStyleSet.GetWindowColor();
+ aTextColor = rStyleSet.GetButtonTextColor();
+ aWinTextColor = rStyleSet.GetWindowTextColor();
+}
+
+//-------------------------------------------------------------------
+
+Point ScDPFieldWindow::GetFieldPosition( size_t nIndex ) const
+{
+ Point aPos;
+ switch( eType )
+ {
+ case TYPE_PAGE:
+ aPos.X() = OWIDTH * (nIndex % (MAX_PAGEFIELDS / 2));
+ aPos.Y() = OHEIGHT * (nIndex / (MAX_PAGEFIELDS / 2));
+ break;
+ case TYPE_COL:
+ aPos.X() = OWIDTH * (nIndex % (MAX_FIELDS / 2));
+ aPos.Y() = OHEIGHT * (nIndex / (MAX_FIELDS / 2));
+ break;
+ case TYPE_ROW:
+ case TYPE_DATA:
+ aPos.X() = 0;
+ aPos.Y() = OHEIGHT * nIndex;
+ break;
+ case TYPE_SELECT:
+ aPos.X() = (OWIDTH + SSPACE) * (nIndex / LINE_SIZE);
+ aPos.Y() = (OHEIGHT + SSPACE) * (nIndex % LINE_SIZE);
+ break;
+ }
+ return aPos;
+}
+
+Size ScDPFieldWindow::GetFieldSize() const
+{
+ return Size( (eType == TYPE_DATA) ? GetSizePixel().Width() : OWIDTH, OHEIGHT );
+}
+
+Point ScDPFieldWindow::GetLastPosition() const
+{
+ return OutputToScreenPixel( GetFieldPosition( nFieldSize - 1 ) );
+}
+
+bool ScDPFieldWindow::GetFieldIndex( const Point& rPos, size_t& rnIndex ) const
+{
+ rnIndex = INVALID_INDEX;
+ if( (rPos.X() >= 0) && (rPos.Y() >= 0) )
+ {
+ switch( eType )
+ {
+ case TYPE_ROW:
+ case TYPE_DATA:
+ rnIndex = rPos.Y() / OHEIGHT;
+ break;
+ case TYPE_PAGE:
+ {
+ size_t nRow = rPos.Y() / OHEIGHT;
+ size_t nCol = rPos.X() / OWIDTH;
+ rnIndex = nRow * MAX_PAGEFIELDS / 2 + nCol;
+ }
+ break;
+ case TYPE_COL:
+ {
+ size_t nRow = rPos.Y() / OHEIGHT;
+ size_t nCol = rPos.X() / OWIDTH;
+ rnIndex = nRow * MAX_FIELDS / 2 + nCol;
+ }
+ break;
+ case TYPE_SELECT:
+ {
+ size_t nRow = rPos.Y() / (OHEIGHT + SSPACE);
+ size_t nCol = rPos.X() / (OWIDTH + SSPACE);
+ // is not between controls?
+ if( (rPos.Y() % (OHEIGHT + SSPACE) < OHEIGHT) && (rPos.X() % (OWIDTH + SSPACE) < OWIDTH) )
+ rnIndex = nCol * LINE_SIZE + nRow;
+ }
+ break;
+ }
+ }
+ return IsValidIndex( rnIndex );
+}
+
+//-------------------------------------------------------------------
+
+void ScDPFieldWindow::DrawBackground( OutputDevice& rDev )
+{
+ Point aPos0;
+ Size aSize( GetSizePixel() );
+
+ if ( eType == TYPE_SELECT )
+ {
+ rDev.SetLineColor();
+ rDev.SetFillColor( aFaceColor );
+ rDev.DrawRect( Rectangle( aPos0, aSize ) );
+ }
+ else
+ {
+ rDev.SetLineColor( aWinTextColor );
+ rDev.SetFillColor( aWinColor );
+ rDev.DrawRect( Rectangle( aPos0, aSize ) );
+
+ rDev.SetTextColor( aWinTextColor );
+
+ /* Draw the caption text. This needs some special handling, because we
+ support hard line breaks here. This part will draw each line of the
+ text for itself. */
+
+ xub_StrLen nTokenCnt = GetText().GetTokenCount( '\n' );
+ long nY = (aSize.Height() - nTokenCnt * rDev.GetTextHeight()) / 2;
+ for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
+ {
+ String aLine( GetText().GetToken( 0, '\n', nStringIx ) );
+ Point aLinePos( (aSize.Width() - rDev.GetCtrlTextWidth( aLine )) / 2, nY );
+ rDev.DrawCtrlText( aLinePos, aLine );
+ nY += rDev.GetTextHeight();
+ }
+ }
+}
+
+void ScDPFieldWindow::DrawField(
+ OutputDevice& rDev, const Rectangle& rRect, FieldString& rText, bool bFocus )
+{
+ VirtualDevice aVirDev( rDev );
+ // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
+ aVirDev.EnableRTL( IsRTLEnabled() );
+
+ String aText = rText.first;
+ Size aDevSize( rRect.GetSize() );
+ long nWidth = aDevSize.Width();
+ long nHeight = aDevSize.Height();
+ long nLabelWidth = rDev.GetTextWidth( aText );
+ long nLabelHeight = rDev.GetTextHeight();
+
+ // #i31600# if text is too long, cut and add ellipsis
+ rText.second = nLabelWidth + 6 <= nWidth;
+ if( !rText.second )
+ {
+ xub_StrLen nMinLen = 0;
+ xub_StrLen nMaxLen = aText.Len();
+ bool bFits = false;
+ do
+ {
+ xub_StrLen nCurrLen = (nMinLen + nMaxLen) / 2;
+ aText = String( rText.first, 0, nCurrLen ).AppendAscii( "..." );
+ nLabelWidth = rDev.GetTextWidth( aText );
+ bFits = nLabelWidth + 6 <= nWidth;
+ (bFits ? nMinLen : nMaxLen) = nCurrLen;
+ }
+ while( !bFits || (nMinLen + 1 < nMaxLen) );
+ }
+ Point aLabelPos( (nWidth - nLabelWidth) / 2, ::std::max< long >( (nHeight - nLabelHeight) / 2, 3 ) );
+
+ aVirDev.SetOutputSizePixel( aDevSize );
+ aVirDev.SetFont( rDev.GetFont() );
+ DecorationView aDecoView( &aVirDev );
+ aDecoView.DrawButton( Rectangle( Point( 0, 0 ), aDevSize ), bFocus ? BUTTON_DRAW_DEFAULT : 0 );
+ aVirDev.SetTextColor( aTextColor );
+ aVirDev.DrawText( aLabelPos, aText );
+ rDev.DrawBitmap( rRect.TopLeft(), aVirDev.GetBitmap( Point( 0, 0 ), aDevSize ) );
+}
+
+void ScDPFieldWindow::Redraw()
+{
+ VirtualDevice aVirDev;
+ // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
+ aVirDev.EnableRTL( IsRTLEnabled() );
+ aVirDev.SetMapMode( MAP_PIXEL );
+
+ Point aPos0;
+ Size aSize( GetSizePixel() );
+ Font aFont( GetFont() ); // Font vom Window
+ aFont.SetTransparent( TRUE );
+ aVirDev.SetFont( aFont );
+ aVirDev.SetOutputSizePixel( aSize );
+
+ DrawBackground( aVirDev );
+
+ if( !aFieldArr.empty() && (nFieldSelected >= aFieldArr.size()) )
+ nFieldSelected = aFieldArr.size() - 1;
+ Rectangle aFieldRect( aPos0, GetFieldSize() );
+ for( size_t nIx = 0; nIx < aFieldArr.size(); ++nIx )
+ {
+ aFieldRect.SetPos( GetFieldPosition( nIx ) );
+ bool bFocus = HasFocus() && (nIx == nFieldSelected);
+ DrawField( aVirDev, aFieldRect, aFieldArr[ nIx ], bFocus );
+ }
+ DrawBitmap( aPos0, aVirDev.GetBitmap( aPos0, aSize ) );
+
+ if( HasFocus() && (nFieldSelected < aFieldArr.size()) )
+ {
+ long nFieldWidth = aFieldRect.GetWidth();
+ long nSelectionWidth = Min( GetTextWidth( aFieldArr[ nFieldSelected ].first ) + 4, nFieldWidth - 6 );
+ Rectangle aSelection(
+ GetFieldPosition( nFieldSelected ) + Point( (nFieldWidth - nSelectionWidth) / 2, 3 ),
+ Size( nSelectionWidth, aFieldRect.GetHeight() - 6 ) );
+ InvertTracking( aSelection, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ }
+
+ UpdateStyle();
+}
+
+void ScDPFieldWindow::UpdateStyle()
+{
+ WinBits nMask = ~(WB_TABSTOP | WB_NOTABSTOP);
+ SetStyle( (GetStyle() & nMask) | (IsEmpty() ? WB_NOTABSTOP : WB_TABSTOP) );
+}
+
+//-------------------------------------------------------------------
+
+bool ScDPFieldWindow::IsValidIndex( size_t nIndex ) const
+{
+ return nIndex < nFieldSize;
+}
+
+bool ScDPFieldWindow::IsExistingIndex( size_t nIndex ) const
+{
+ return nIndex < aFieldArr.size();
+}
+
+bool ScDPFieldWindow::IsShortenedText( size_t nIndex ) const
+{
+ return (nIndex < aFieldArr.size()) && !aFieldArr[ nIndex ].second;
+}
+
+size_t ScDPFieldWindow::CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const
+{
+ size_t nNewField = nFieldSelected;
+ switch( eType )
+ {
+ case TYPE_PAGE:
+ nNewField += static_cast<SCsCOLROW>(nDX) + nDY * MAX_PAGEFIELDS / 2;
+ break;
+ case TYPE_COL:
+ nNewField += static_cast<SCsCOLROW>(nDX) + nDY * MAX_FIELDS / 2;
+ break;
+ case TYPE_ROW:
+ case TYPE_DATA:
+ nNewField += nDY;
+ break;
+ case TYPE_SELECT:
+ nNewField += static_cast<SCsCOLROW>(nDX) * LINE_SIZE + nDY;
+ break;
+ }
+
+ return IsExistingIndex( nNewField ) ? nNewField : nFieldSelected;
+}
+
+void ScDPFieldWindow::SetSelection( size_t nIndex )
+{
+ if( !aFieldArr.empty() )
+ {
+ if( nFieldSelected >= aFieldArr.size() )
+ nFieldSelected = aFieldArr.size() - 1;
+ if( nFieldSelected != nIndex )
+ {
+ sal_Int32 nOldSelected(nFieldSelected);
+ nFieldSelected = nIndex;
+ Redraw();
+
+ if (pAccessible && HasFocus())
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->FieldFocusChange(nOldSelected, nFieldSelected);
+ else
+ pAccessible = NULL;
+ }
+ }
+ }
+}
+
+void ScDPFieldWindow::SetSelectionHome()
+{
+ if( !aFieldArr.empty() )
+ {
+ if( eType == TYPE_SELECT )
+ pDlg->NotifyMoveSlider( KEY_HOME );
+ SetSelection( 0 );
+ }
+}
+
+void ScDPFieldWindow::SetSelectionEnd()
+{
+ if( !aFieldArr.empty() )
+ {
+ if( eType == TYPE_SELECT )
+ pDlg->NotifyMoveSlider( KEY_END );
+ SetSelection( aFieldArr.size() - 1 );
+ }
+}
+
+void ScDPFieldWindow::MoveSelection( USHORT nKeyCode, SCsCOL nDX, SCsROW nDY )
+{
+ size_t nNewIndex = CalcNewFieldIndex( nDX, nDY );
+ if( (eType == TYPE_SELECT) && (nNewIndex == nFieldSelected) )
+ {
+ if( pDlg->NotifyMoveSlider( nKeyCode ) )
+ {
+ switch( nKeyCode )
+ {
+ case KEY_UP: nNewIndex += (LINE_SIZE - 1); break;
+ case KEY_DOWN: nNewIndex -= (LINE_SIZE - 1); break;
+ }
+ }
+ }
+ SetSelection( nNewIndex );
+}
+
+void ScDPFieldWindow::ModifySelectionOffset( long nOffsetDiff )
+{
+ nFieldSelected -= nOffsetDiff;
+ Redraw();
+}
+
+void ScDPFieldWindow::SelectNext()
+{
+ if( eType == TYPE_SELECT )
+ MoveSelection( KEY_DOWN, 0, 1 );
+}
+
+void ScDPFieldWindow::GrabFocusWithSel( size_t nIndex )
+{
+ SetSelection( nIndex );
+ if( !HasFocus() )
+ GrabFocus();
+}
+
+void ScDPFieldWindow::MoveField( size_t nDestIndex )
+{
+ if( nDestIndex != nFieldSelected )
+ {
+ // "recycle" existing functionality
+ pDlg->NotifyMouseButtonDown( eType, nFieldSelected );
+ pDlg->NotifyMouseButtonUp( OutputToScreenPixel( GetFieldPosition( nDestIndex ) ) );
+ }
+}
+
+void ScDPFieldWindow::MoveFieldRel( SCsCOL nDX, SCsROW nDY )
+{
+ MoveField( CalcNewFieldIndex( nDX, nDY ) );
+}
+
+//-------------------------------------------------------------------
+
+void __EXPORT ScDPFieldWindow::Paint( const Rectangle& /* rRect */ )
+{
+ // #124828# hiding the caption is now done from StateChanged
+ Redraw();
+}
+
+void ScDPFieldWindow::UseMnemonic()
+{
+ // Now the FixedText has its mnemonic char. Grab the text and hide the
+ // FixedText to be able to handle tabstop and mnemonics separately.
+ if( pFtCaption )
+ {
+ SetText( pFtCaption->GetText() );
+ pFtCaption->Hide();
+ }
+
+ // after reading the mnemonics, tab stop style bits can be updated
+ UpdateStyle();
+}
+
+void __EXPORT ScDPFieldWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ GetStyleSettings();
+ Redraw();
+ }
+ Control::DataChanged( rDCEvt );
+}
+
+void __EXPORT ScDPFieldWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() )
+ {
+ size_t nIndex = 0;
+ if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsExistingIndex( nIndex ) )
+ {
+ GrabFocusWithSel( nIndex );
+
+ if( rMEvt.GetClicks() == 1 )
+ {
+ PointerStyle ePtr = pDlg->NotifyMouseButtonDown( eType, nIndex );
+ CaptureMouse();
+ SetPointer( Pointer( ePtr ) );
+ }
+ else
+ pDlg->NotifyDoubleClick( eType, nIndex );
+ }
+ }
+}
+
+void __EXPORT ScDPFieldWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if( rMEvt.IsLeft() )
+ {
+ if( rMEvt.GetClicks() == 1 )
+ {
+ pDlg->NotifyMouseButtonUp( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ }
+
+ if( IsMouseCaptured() )
+ ReleaseMouse();
+ }
+}
+
+void __EXPORT ScDPFieldWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ if( IsMouseCaptured() )
+ {
+ PointerStyle ePtr = pDlg->NotifyMouseMove( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
+ SetPointer( Pointer( ePtr ) );
+ }
+ size_t nIndex = 0;
+ if( GetFieldIndex( rMEvt.GetPosPixel(), nIndex ) && IsShortenedText( nIndex ) )
+ {
+ Point aPos = OutputToScreenPixel( rMEvt.GetPosPixel() );
+ Rectangle aRect( aPos, GetSizePixel() );
+ String aHelpText = GetFieldText(nIndex);
+ Help::ShowQuickHelp( this, aRect, aHelpText );
+ }
+}
+
+void __EXPORT ScDPFieldWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ USHORT nCode = rKeyCode.GetCode();
+ BOOL bKeyEvaluated = FALSE;
+
+ if( rKeyCode.IsMod1() && (eType != TYPE_SELECT) )
+ {
+ bKeyEvaluated = TRUE;
+ switch( nCode )
+ {
+ case KEY_UP: MoveFieldRel( 0, -1 ); break;
+ case KEY_DOWN: MoveFieldRel( 0, 1 ); break;
+ case KEY_LEFT: MoveFieldRel( -1, 0 ); break;
+ case KEY_RIGHT: MoveFieldRel( 1, 0 ); break;
+ case KEY_HOME: MoveField( 0 ); break;
+ case KEY_END: MoveField( aFieldArr.size() - 1 ); break;
+ default: bKeyEvaluated = FALSE;
+ }
+ }
+ else
+ {
+ bKeyEvaluated = TRUE;
+ switch( nCode )
+ {
+ case KEY_UP: MoveSelection( nCode, 0, -1 ); break;
+ case KEY_DOWN: MoveSelection( nCode, 0, 1 ); break;
+ case KEY_LEFT: MoveSelection( nCode, -1, 0 ); break;
+ case KEY_RIGHT: MoveSelection( nCode, 1, 0 ); break;
+ case KEY_HOME: SetSelectionHome(); break;
+ case KEY_END: SetSelectionEnd(); break;
+ case KEY_DELETE:
+ pDlg->NotifyRemoveField( eType, nFieldSelected ); break;
+ default: bKeyEvaluated = FALSE;
+ }
+ }
+
+ if( !bKeyEvaluated )
+ Control::KeyInput( rKEvt );
+}
+
+void __EXPORT ScDPFieldWindow::GetFocus()
+{
+ Control::GetFocus();
+ Redraw();
+ if( GetGetFocusFlags() & GETFOCUS_MNEMONIC ) // move field on shortcut
+ pDlg->NotifyMoveField( eType );
+ else // else change focus
+ pDlg->NotifyFieldFocus( eType, TRUE );
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->GotFocus();
+ else
+ pAccessible = NULL;
+ }
+}
+
+void __EXPORT ScDPFieldWindow::LoseFocus()
+{
+ Control::LoseFocus();
+ Redraw();
+ pDlg->NotifyFieldFocus( eType, FALSE );
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->LostFocus();
+ else
+ pAccessible = NULL;
+ }
+}
+
+//-------------------------------------------------------------------
+
+void ScDPFieldWindow::AddField( const String& rText, size_t nNewIndex )
+{
+ DBG_ASSERT( nNewIndex == aFieldArr.size(), "ScDPFieldWindow::AddField - invalid index" );
+ if( IsValidIndex( nNewIndex ) )
+ {
+ aFieldArr.push_back( FieldString( rText, true ) );
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->AddField(nNewIndex);
+ else
+ pAccessible = NULL;
+ }
+ }
+}
+
+void ScDPFieldWindow::DelField( size_t nDelIndex )
+{
+ if( IsExistingIndex( nDelIndex ) )
+ {
+ if (pAccessible) // before decrement fieldcount
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->RemoveField(nDelIndex);
+ else
+ pAccessible = NULL;
+ }
+ aFieldArr.erase( aFieldArr.begin() + nDelIndex );
+ Redraw();
+ }
+}
+
+void ScDPFieldWindow::ClearFields()
+{
+ if( eType == TYPE_SELECT || eType == TYPE_PAGE || eType == TYPE_COL || eType == TYPE_ROW || eType == TYPE_DATA)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (!xTempAcc.is() && pAccessible)
+ pAccessible = NULL;
+ if (pAccessible)
+ for( size_t nIdx = aFieldArr.size(); nIdx > 0; --nIdx )
+ pAccessible->RemoveField( nIdx - 1 );
+
+ aFieldArr.clear();
+ }
+}
+
+void ScDPFieldWindow::SetFieldText( const String& rText, size_t nIndex )
+{
+ if( IsExistingIndex( nIndex ) )
+ {
+ aFieldArr[ nIndex ] = FieldString( rText, true );
+ Redraw();
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->FieldNameChange(nIndex);
+ else
+ pAccessible = NULL;
+ }
+ }
+}
+
+const String& ScDPFieldWindow::GetFieldText( size_t nIndex ) const
+{
+ if( IsExistingIndex( nIndex ) )
+ return aFieldArr[ nIndex ].first;
+ return EMPTY_STRING;
+}
+
+//-------------------------------------------------------------------
+
+bool ScDPFieldWindow::AddField( const String& rText, const Point& rPos, size_t& rnIndex )
+{
+ if ( aFieldArr.size() == nFieldSize )
+ return FALSE;
+
+ size_t nNewIndex = 0;
+ if( GetFieldIndex( rPos, nNewIndex ) )
+ {
+ if( nNewIndex > aFieldArr.size() )
+ nNewIndex = aFieldArr.size();
+
+ aFieldArr.insert( aFieldArr.begin() + nNewIndex, FieldString( rText, true ) );
+ nFieldSelected = nNewIndex;
+ Redraw();
+ rnIndex = nNewIndex;
+
+ if (pAccessible)
+ {
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xTempAcc = xAccessible;
+ if (xTempAcc.is())
+ pAccessible->AddField(nNewIndex);
+ else
+ pAccessible = NULL;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+void ScDPFieldWindow::GetExistingIndex( const Point& rPos, size_t& rnIndex )
+{
+ if( !aFieldArr.empty() && (eType != TYPE_SELECT) && GetFieldIndex( rPos, rnIndex ) )
+ {
+ if( rnIndex >= aFieldArr.size() )
+ rnIndex = aFieldArr.size() - 1;
+ }
+ else
+ rnIndex = 0;
+}
+
+String ScDPFieldWindow::GetDescription() const
+{
+ String sDescription;
+ switch( eType )
+ {
+ case TYPE_COL:
+ sDescription = ScResId(STR_ACC_DATAPILOT_COL_DESCR);
+ break;
+ case TYPE_ROW:
+ sDescription = ScResId(STR_ACC_DATAPILOT_ROW_DESCR);
+ break;
+ case TYPE_DATA:
+ sDescription = ScResId(STR_ACC_DATAPILOT_DATA_DESCR);
+ break;
+ case TYPE_SELECT:
+ sDescription = ScResId(STR_ACC_DATAPILOT_SEL_DESCR);
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return sDescription;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScDPFieldWindow::CreateAccessible()
+{
+ pAccessible =
+ new ScAccessibleDataPilotControl(GetAccessibleParentWindow()->GetAccessible(), this);
+
+ com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xReturn = pAccessible;
+
+ pAccessible->Init();
+ xAccessible = xReturn;
+
+ return xReturn;
+}
+
+//===================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx
new file mode 100644
index 000000000000..d33a6743111b
--- /dev/null
+++ b/sc/source/ui/dbgui/filtdlg.cxx
@@ -0,0 +1,1190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+#include <rangelst.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/waitobj.hxx>
+
+#include "uiitems.hxx"
+#include "dbcolect.hxx"
+#include "reffact.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+
+#include "foptmgr.hxx"
+
+#include "globstr.hrc"
+#include "filter.hrc"
+
+#define _FILTDLG_CXX
+#include "filtdlg.hxx"
+#undef _FILTDLG_CXX
+#include <vcl/msgbox.hxx>
+
+// DEFINE --------------------------------------------------------------------
+
+#define ERRORBOX(rid) ErrorBox( this, WinBits( WB_OK|WB_DEF_OK), \
+ ScGlobal::GetRscString(rid) ).Execute()
+
+
+//============================================================================
+// class ScFilterDlg
+
+//----------------------------------------------------------------------------
+
+ScFilterDlg::ScFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_FILTER ),
+ //
+ aFlCriteria ( this, ScResId( FL_CRITERIA ) ),
+ aLbConnect1 ( this, ScResId( LB_OP1 ) ),
+ aLbField1 ( this, ScResId( LB_FIELD1 ) ),
+ aLbCond1 ( this, ScResId( LB_COND1 ) ),
+ aEdVal1 ( this, ScResId( ED_VAL1 ) ),
+ aLbConnect2 ( this, ScResId( LB_OP2 ) ),
+ aLbField2 ( this, ScResId( LB_FIELD2 ) ),
+ aLbCond2 ( this, ScResId( LB_COND2 ) ),
+ aEdVal2 ( this, ScResId( ED_VAL2 ) ),
+ aLbConnect3 ( this, ScResId( LB_OP3 ) ),
+ aLbField3 ( this, ScResId( LB_FIELD3 ) ),
+ aLbCond3 ( this, ScResId( LB_COND3 ) ),
+ aEdVal3 ( this, ScResId( ED_VAL3 ) ),
+ aLbConnect4 ( this, ScResId( LB_OP4 ) ),
+ aLbField4 ( this, ScResId( LB_FIELD4 ) ),
+ aLbCond4 ( this, ScResId( LB_COND4 ) ),
+ aEdVal4 ( this, ScResId( ED_VAL4 ) ),
+ aFtConnect ( this, ScResId( FT_OP ) ),
+ aFtField ( this, ScResId( FT_FIELD ) ),
+ aFtCond ( this, ScResId( FT_COND ) ),
+ aFtVal ( this, ScResId( FT_VAL ) ),
+ aFlSeparator ( this, ScResId( FL_SEPARATOR ) ),
+ aScrollBar ( this, ScResId( LB_SCROLL ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ _INIT_COMMON_FILTER_RSCOBJS
+ aStrEmpty ( ScResId( SCSTR_EMPTY ) ),
+ aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ),
+ aStrRow ( ScResId( SCSTR_ROW ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ //
+ pOptionsMgr ( NULL ),
+ nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
+ theQueryData ( ((const ScQueryItem&)
+ rArgSet.Get( nWhichQuery )).GetQueryData() ),
+ pOutItem ( NULL ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nSrcTab ( 0 ),
+ nFieldCount ( 0 ),
+ bRefInputMode ( FALSE ),
+ pTimer ( NULL )
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ pEntryLists[i] = NULL;
+ for (SCSIZE i=0;i<MAXQUERY;i++)
+ {
+ bRefreshExceptQuery[i]=FALSE;
+ }
+ aBtnMore.SetMoreText( String(ScResId( SCSTR_MOREBTN_MOREOPTIONS )) );
+ aBtnMore.SetLessText( String(ScResId( SCSTR_MOREBTN_FEWEROPTIONS )) );
+ Init( rArgSet );
+ FreeResource();
+
+ // Hack: RefInput-Kontrolle
+ pTimer = new Timer;
+ pTimer->SetTimeout( 50 ); // 50ms warten
+ pTimer->SetTimeoutHdl( LINK( this, ScFilterDlg, TimeOutHdl ) );
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScFilterDlg::~ScFilterDlg()
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ delete pEntryLists[i];
+
+ delete pOptionsMgr;
+ delete pOutItem;
+
+ // Hack: RefInput-Kontrolle
+ pTimer->Stop();
+ delete pTimer;
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScFilterDlg::Init( const SfxItemSet& rArgSet )
+{
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)
+ rArgSet.Get( nWhichQuery );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScFilterDlg, EndDlgHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScFilterDlg, EndDlgHdl ) );
+ aBtnMore.SetClickHdl ( LINK( this, ScFilterDlg, MoreClickHdl ) );
+ aBtnHeader.SetClickHdl ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
+ aBtnCase.SetClickHdl ( LINK( this, ScFilterDlg, CheckBoxHdl ) );
+ //
+ aLbField1.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbField2.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbField3.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbField4.SetSelectHdl ( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect3.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbConnect4.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+
+ aLbCond1.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbCond2.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbCond3.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+ aLbCond4.SetSelectHdl( LINK( this, ScFilterDlg, LbSelectHdl ) );
+
+ pViewData = rQueryItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+ nSrcTab = pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
+
+ // fuer leichteren Zugriff:
+ aFieldLbArr [0] = &aLbField1;
+ aFieldLbArr [1] = &aLbField2;
+ aFieldLbArr [2] = &aLbField3;
+ aFieldLbArr [3] = &aLbField4;
+ aValueEdArr [0] = &aEdVal1;
+ aValueEdArr [1] = &aEdVal2;
+ aValueEdArr [2] = &aEdVal3;
+ aValueEdArr [3] = &aEdVal4;
+ aCondLbArr [0] = &aLbCond1;
+ aCondLbArr [1] = &aLbCond2;
+ aCondLbArr [2] = &aLbCond3;
+ aCondLbArr [3] = &aLbCond4;
+ aConnLbArr [0] = &aLbConnect1;
+ aConnLbArr [1] = &aLbConnect2;
+ aConnLbArr [2] = &aLbConnect3;
+ aConnLbArr [3] = &aLbConnect4;
+
+ // Optionen initialisieren lassen:
+
+ pOptionsMgr = new ScFilterOptionsMgr(
+ this,
+ pViewData,
+ theQueryData,
+ aBtnMore,
+ aBtnCase,
+ aBtnRegExp,
+ aBtnHeader,
+ aBtnUnique,
+ aBtnCopyResult,
+ aBtnDestPers,
+ aLbCopyArea,
+ aEdCopyArea,
+ aRbCopyArea,
+ aFtDbAreaLabel,
+ aFtDbArea,
+ aFlOptions,
+ aStrNoName,
+ aStrUndefined );
+
+ // Feldlisten einlesen und Eintraege selektieren:
+
+ FillFieldLists();
+
+ for ( SCSIZE i=0; i<4; i++ )
+ {
+ String aValStr;
+ USHORT nCondPos = 0;
+ USHORT nFieldSelPos = 0;
+
+ ScQueryEntry& rEntry = theQueryData.GetEntry(i);
+ if ( rEntry.bDoQuery )
+ {
+ nCondPos = (USHORT)rEntry.eOp;
+ nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
+ if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrNotEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else
+ aValStr = *rEntry.pStr;
+ }
+ else if ( i == 0 )
+ {
+ nFieldSelPos = GetFieldSelPos( pViewData->GetCurX() );
+ rEntry.nField = nFieldSelPos ? (theQueryData.nCol1 +
+ static_cast<SCCOL>(nFieldSelPos) - 1) : static_cast<SCCOL>(0);
+ rEntry.bDoQuery=TRUE;
+ bRefreshExceptQuery[i]=TRUE;
+
+ }
+ aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
+ aCondLbArr [i]->SelectEntryPos( nCondPos );
+ aValueEdArr[i]->SetText( aValStr );
+ aValueEdArr[i]->SetModifyHdl( LINK( this, ScFilterDlg, ValModifyHdl ) );
+ UpdateValueList( static_cast<USHORT>(i+1) );
+ }
+
+ aScrollBar.SetEndScrollHdl( LINK( this, ScFilterDlg, ScrollHdl ) );
+ aScrollBar.SetScrollHdl( LINK( this, ScFilterDlg, ScrollHdl ) );
+
+ aScrollBar.SetRange( Range( 0, 4 ) );
+ aScrollBar.SetLineSize( 1 );
+ aLbConnect1.Hide();
+ // Disable/Enable Logik:
+
+ (aLbField1.GetSelectEntryPos() != 0)
+ && (aLbField2.GetSelectEntryPos() != 0)
+ ? aLbConnect2.SelectEntryPos( (USHORT)theQueryData.GetEntry(1).eConnect )
+ : aLbConnect2.SetNoSelection();
+
+ (aLbField2.GetSelectEntryPos() != 0)
+ && (aLbField3.GetSelectEntryPos() != 0)
+ ? aLbConnect3.SelectEntryPos( (USHORT)theQueryData.GetEntry(2).eConnect )
+ : aLbConnect3.SetNoSelection();
+
+ (aLbField3.GetSelectEntryPos() != 0)
+ && (aLbField4.GetSelectEntryPos() != 0)
+ ? aLbConnect4.SelectEntryPos( (USHORT)theQueryData.GetEntry(3).eConnect )
+ : aLbConnect4.SetNoSelection();
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.Disable();
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+ else if ( aLbConnect2.GetSelectEntryCount() == 0 )
+ {
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect3.Disable();
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ else if ( aLbConnect3.GetSelectEntryCount() == 0 )
+ {
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ if ( aLbField3.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect4.Disable();
+ aLbField4.Disable();
+ aLbCond4.Disable();
+ aEdVal4.Disable();
+ }
+ else if ( aLbConnect4.GetSelectEntryCount() == 0 )
+ {
+ aLbField4.Disable();
+ aLbCond4.Disable();
+ aEdVal4.Disable();
+ }
+
+ if(pDoc!=NULL &&
+ pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
+ // Modal-Modus einschalten
+// SetDispatcherLock( TRUE );
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+// SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFilterDlg::Close()
+{
+ if (pViewData)
+ pViewData->GetDocShell()->CancelAutoDBRange();
+
+ return DoClose( ScFilterDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+void ScFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( bRefInputMode ) // Nur moeglich, wenn im Referenz-Editmodus
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( &aEdCopyArea );
+ String aRefStr;
+ rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ aEdCopyArea.SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::SetActive()
+{
+ if ( bRefInputMode )
+ {
+ aEdCopyArea.GrabFocus();
+ if ( aEdCopyArea.GetModifyHdl().IsSet() )
+ ((Link&)aEdCopyArea.GetModifyHdl()).Call( &aEdCopyArea );
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::FillFieldLists()
+{
+ aLbField1.Clear();
+ aLbField2.Clear();
+ aLbField3.Clear();
+ aLbField4.Clear();
+ aLbField1.InsertEntry( aStrNone, 0 );
+ aLbField2.InsertEntry( aStrNone, 0 );
+ aLbField3.InsertEntry( aStrNone, 0 );
+ aLbField4.InsertEntry( aStrNone, 0 );
+
+ if ( pDoc )
+ {
+ String aFieldName;
+ SCTAB nTab = nSrcTab;
+ SCCOL nFirstCol = theQueryData.nCol1;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCCOL nMaxCol = theQueryData.nCol2;
+ SCCOL col = 0;
+ USHORT i=1;
+
+ for ( col=nFirstCol; col<=nMaxCol; col++ )
+ {
+ pDoc->GetString( col, nFirstRow, nTab, aFieldName );
+ if ( !aBtnHeader.IsChecked() || (aFieldName.Len() == 0) )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ScColToAlpha( col );
+ }
+ aLbField1.InsertEntry( aFieldName, i );
+ aLbField2.InsertEntry( aFieldName, i );
+ aLbField3.InsertEntry( aFieldName, i );
+ aLbField4.InsertEntry( aFieldName, i );
+ i++;
+ }
+ nFieldCount = i;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::UpdateValueList( USHORT nList )
+{
+ if ( pDoc && nList>0 && nList<=4 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
+ USHORT nListPos = 0;
+ String aCurValue = pValList->GetText();
+
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ nListPos = 2;
+
+ if ( nFieldSelPos )
+ {
+ WaitObject aWaiter( this ); // auch wenn nur die ListBox gefuellt wird
+
+ SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
+ if (!pEntryLists[nColumn])
+ {
+ USHORT nOffset = GetSliderPos();
+ SCTAB nTab = nSrcTab;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCROW nLastRow = theQueryData.bUseDynamicRange ? theQueryData.nDynamicEndRow : theQueryData.nRow2;
+ mbHasDates[nOffset+nList-1] = false;
+
+ // erstmal ohne die erste Zeile
+
+ pEntryLists[nColumn] = new TypedScStrCollection( 128, 128 );
+ pEntryLists[nColumn]->SetCaseSensitive( aBtnCase.IsChecked() );
+ pDoc->GetFilterEntriesArea( nColumn, nFirstRow+1, nLastRow,
+ nTab, *pEntryLists[nColumn], mbHasDates[nOffset+nList-1] );
+
+ // Eintrag fuer die erste Zeile
+ //! Eintrag (pHdrEntry) ohne Collection erzeugen?
+
+ nHeaderPos[nColumn] = USHRT_MAX;
+ TypedScStrCollection aHdrColl( 1, 1 );
+ bool bDummy = false;
+ pDoc->GetFilterEntriesArea( nColumn, nFirstRow, nFirstRow,
+ nTab, aHdrColl, bDummy );
+ TypedStrData* pHdrEntry = aHdrColl[0];
+ if ( pHdrEntry )
+ {
+ TypedStrData* pNewEntry = new TypedStrData(*pHdrEntry);
+ if ( pEntryLists[nColumn]->Insert( pNewEntry ) )
+ {
+ nHeaderPos[nColumn] = pEntryLists[nColumn]->IndexOf( pNewEntry );
+ DBG_ASSERT( nHeaderPos[nColumn] != USHRT_MAX,
+ "Header-Eintrag nicht wiedergefunden" );
+ }
+ else
+ delete pNewEntry; // war schon drin
+ }
+ }
+
+ TypedScStrCollection* pColl = pEntryLists[nColumn];
+ USHORT nValueCount = pColl->GetCount();
+ if ( nValueCount > 0 )
+ {
+ for ( USHORT i=0; i<nValueCount; i++ )
+ {
+ pValList->InsertEntry( (*pColl)[i]->GetString(), nListPos );
+ nListPos++;
+ }
+ }
+ }
+ pValList->SetText( aCurValue );
+ pValList->EnableDDAutoWidth(false);
+ }
+
+ UpdateHdrInValueList( nList );
+}
+
+void ScFilterDlg::UpdateHdrInValueList( USHORT nList )
+{
+ //! GetText / SetText ??
+
+ if ( pDoc && nList>0 && nList<=4 )
+ {
+ USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
+ if ( nFieldSelPos )
+ {
+ SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
+ if ( pEntryLists[nColumn] )
+ {
+ USHORT nPos = nHeaderPos[nColumn];
+ if ( nPos != USHRT_MAX )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ USHORT nListPos = nPos + 2; // nach "leer" und "nicht leer"
+
+ TypedStrData* pHdrEntry = (*pEntryLists[nColumn])[nPos];
+ if ( pHdrEntry )
+ {
+ String aHdrStr = pHdrEntry->GetString();
+ BOOL bWasThere = ( pValList->GetEntry(nListPos) == aHdrStr );
+ BOOL bInclude = !aBtnHeader.IsChecked();
+
+ if (bInclude) // Eintrag aufnehmen
+ {
+ if (!bWasThere)
+ pValList->InsertEntry(aHdrStr, nListPos);
+ }
+ else // Eintrag weglassen
+ {
+ if (bWasThere)
+ pValList->RemoveEntry(nListPos);
+ }
+ }
+ else
+ {
+ DBG_ERROR("Eintag in Liste nicht gefunden");
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR("Spalte noch nicht initialisiert");
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScFilterDlg::ClearValueList( USHORT nList )
+{
+ if ( nList>0 && nList<=4 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ pValList->SetText( EMPTY_STRING );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+USHORT ScFilterDlg::GetFieldSelPos( SCCOL nField )
+{
+ if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 )
+ return static_cast<USHORT>(nField - theQueryData.nCol1 + 1);
+ else
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+ScQueryItem* ScFilterDlg::GetOutputItem()
+{
+ ScAddress theCopyPos;
+ ScQueryParam theParam( theQueryData );
+ BOOL bCopyPosOk = FALSE;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ String theCopyStr( aEdCopyArea.GetText() );
+ xub_StrLen nColonPos = theCopyStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ theCopyStr.Erase( nColonPos );
+
+ USHORT nResult = theCopyPos.Parse( theCopyStr, pDoc, pDoc->GetAddressConvention() );
+ bCopyPosOk = ( SCA_VALID == (nResult & SCA_VALID) );
+ }
+
+ if ( aBtnCopyResult.IsChecked() && bCopyPosOk )
+ {
+ theParam.bInplace = FALSE;
+ theParam.nDestTab = theCopyPos.Tab();
+ theParam.nDestCol = theCopyPos.Col();
+ theParam.nDestRow = theCopyPos.Row();
+ }
+ else
+ {
+ theParam.bInplace = TRUE;
+ theParam.nDestTab = 0;
+ theParam.nDestCol = 0;
+ theParam.nDestRow = 0;
+ }
+
+ theParam.bHasHeader = aBtnHeader.IsChecked();
+ theParam.bByRow = TRUE;
+ theParam.bDuplicate = !aBtnUnique.IsChecked();
+ theParam.bCaseSens = aBtnCase.IsChecked();
+ theParam.bRegExp = aBtnRegExp.IsChecked();
+ theParam.bDestPers = aBtnDestPers.IsChecked();
+
+ // nur die drei eingestellten - alles andere zuruecksetzen
+
+ DELETEZ( pOutItem );
+ pOutItem = new ScQueryItem( nWhichQuery, &theParam );
+
+ return pOutItem;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScFilterDlg::IsRefInputMode() const
+{
+ return bRefInputMode;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScFilterDlg, EndDlgHdl, Button*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ BOOL bAreaInputOk = TRUE;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ if ( !pOptionsMgr->VerifyPosStr( aEdCopyArea.GetText() ) )
+ {
+ if ( !aBtnMore.GetState() )
+ aBtnMore.SetState( TRUE );
+
+ ERRORBOX( STR_INVALID_TABREF );
+ aEdCopyArea.GrabFocus();
+ bAreaInputOk = FALSE;
+ }
+ }
+
+ if ( bAreaInputOk )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( FID_FILTER_OK,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ GetOutputItem(), 0L, 0L );
+ Close();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, MoreClickHdl, MoreButton*, EMPTYARG )
+{
+ if ( aBtnMore.GetState() )
+ pTimer->Start();
+ else
+ {
+ pTimer->Stop();
+ bRefInputMode = FALSE;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, TimeOutHdl, Timer*, _pTimer )
+{
+ // alle 50ms nachschauen, ob RefInputMode noch stimmt
+
+ if( _pTimer == pTimer && IsActive() )
+ bRefInputMode = (aEdCopyArea.HasFocus() || aRbCopyArea.HasFocus());
+
+ if ( aBtnMore.GetState() )
+ pTimer->Start();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, LbSelectHdl, ListBox*, pLb )
+{
+ /*
+ * Behandlung der Enable/Disable-Logik,
+ * abhaengig davon, welche ListBox angefasst wurde:
+ */
+ USHORT nOffset = GetSliderPos();
+
+ if ( pLb == &aLbConnect1 )
+ {
+ aLbField1.Enable();
+ aLbCond1.Enable();
+ aEdVal1.Enable();
+
+ USHORT nConnect1 = aLbConnect1.GetSelectEntryPos();
+ USHORT nQE = nOffset;
+ theQueryData.GetEntry(nQE).eConnect =(ScQueryConnect)nConnect1;
+ bRefreshExceptQuery[nQE]=TRUE;
+ }
+
+ else if ( pLb == &aLbConnect2 )
+ {
+ aLbField2.Enable();
+ aLbCond2.Enable();
+ aEdVal2.Enable();
+
+ USHORT nConnect2 = aLbConnect2.GetSelectEntryPos();
+ USHORT nQE = 1+nOffset;
+ theQueryData.GetEntry(nQE).eConnect =(ScQueryConnect)nConnect2;
+ bRefreshExceptQuery[nQE]=TRUE;
+ }
+ else if ( pLb == &aLbConnect3 )
+ {
+ aLbField3.Enable();
+ aLbCond3.Enable();
+ aEdVal3.Enable();
+
+ USHORT nConnect3 = aLbConnect3.GetSelectEntryPos();
+ USHORT nQE = 2+nOffset;
+ theQueryData.GetEntry(nQE).eConnect = (ScQueryConnect)nConnect3;
+ bRefreshExceptQuery[nQE]=TRUE;
+
+ }
+ else if ( pLb == &aLbConnect4 )
+ {
+ aLbField4.Enable();
+ aLbCond4.Enable();
+ aEdVal4.Enable();
+
+ USHORT nConnect4 = aLbConnect4.GetSelectEntryPos();
+ USHORT nQE = 3+nOffset;
+ theQueryData.GetEntry(nQE).eConnect = (ScQueryConnect)nConnect4;
+ bRefreshExceptQuery[nQE]=TRUE;
+
+ }
+ else if ( pLb == &aLbField1 )
+ {
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.SetNoSelection();
+ aLbConnect3.SetNoSelection();
+ aLbConnect4.SetNoSelection();
+ aLbField2.SelectEntryPos( 0 );
+ aLbField3.SelectEntryPos( 0 );
+ aLbField4.SelectEntryPos( 0 );
+ aLbCond2.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ aLbCond4.SelectEntryPos( 0 );
+ ClearValueList( 1 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+ ClearValueList( 4 );
+
+ aLbConnect2.Disable();
+ aLbConnect3.Disable();
+ aLbConnect4.Disable();
+ aLbField2.Disable();
+ aLbField3.Disable();
+ aLbField4.Disable();
+ aLbCond2.Disable();
+ aLbCond3.Disable();
+ aLbCond4.Disable();
+ aEdVal2.Disable();
+ aEdVal3.Disable();
+ aEdVal4.Disable();
+ for (USHORT i= nOffset; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nOffset] =TRUE;
+ }
+ else
+ {
+ UpdateValueList( 1 );
+ if ( !aLbConnect2.IsEnabled() )
+ {
+ aLbConnect2.Enable();
+ }
+ theQueryData.GetEntry(nOffset).bDoQuery = TRUE;
+ USHORT nField = pLb->GetSelectEntryPos();
+ theQueryData.GetEntry(nOffset).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+ }
+ }
+ else if ( pLb == &aLbField2 )
+ {
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect3.SetNoSelection();
+ aLbConnect4.SetNoSelection();
+ aLbField3.SelectEntryPos( 0 );
+ aLbField4.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ aLbCond4.SelectEntryPos( 0 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+ ClearValueList( 4 );
+
+ aLbConnect3.Disable();
+ aLbConnect4.Disable();
+ aLbField3.Disable();
+ aLbField4.Disable();
+ aLbCond3.Disable();
+ aLbCond4.Disable();
+ aEdVal3.Disable();
+ aEdVal4.Disable();
+
+ USHORT nTemp=nOffset+1;
+ for (USHORT i= nTemp; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nTemp]=TRUE;
+ }
+ else
+ {
+ UpdateValueList( 2 );
+ if ( !aLbConnect3.IsEnabled() )
+ {
+ aLbConnect3.Enable();
+ }
+ USHORT nField = pLb->GetSelectEntryPos();
+ USHORT nQ=1+nOffset;
+ theQueryData.GetEntry(nQ).bDoQuery = TRUE;
+ theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+ }
+ }
+ else if ( pLb == &aLbField3 )
+ {
+ if ( aLbField3.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect4.SetNoSelection();
+ aLbField4.SelectEntryPos( 0 );
+ aLbCond4.SelectEntryPos( 0 );
+ ClearValueList( 3 );
+ ClearValueList( 4 );
+
+ aLbConnect4.Disable();
+ aLbField4.Disable();
+ aLbCond4.Disable();
+ aEdVal4.Disable();
+
+ USHORT nTemp=nOffset+2;
+ for (USHORT i= nTemp; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nTemp]=TRUE;
+ }
+ else
+ {
+ UpdateValueList( 3 );
+ if ( !aLbConnect4.IsEnabled() )
+ {
+ aLbConnect4.Enable();
+ }
+
+ USHORT nField = pLb->GetSelectEntryPos();
+ USHORT nQ=2+nOffset;
+ theQueryData.GetEntry(nQ).bDoQuery = TRUE;
+ theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+
+ }
+ }
+ else if ( pLb == &aLbField4 )
+ {
+ if ( aLbField4.GetSelectEntryPos() == 0 )
+ {
+ ClearValueList( 4 );
+ USHORT nTemp=nOffset+3;
+ for (USHORT i= nTemp; i< MAXQUERY; i++)
+ {
+ theQueryData.GetEntry(i).bDoQuery = FALSE;
+ bRefreshExceptQuery[i]=FALSE;
+ theQueryData.GetEntry(i).nField = static_cast<SCCOL>(0);
+ }
+ bRefreshExceptQuery[nTemp]=TRUE;
+ }
+ else
+ {
+ UpdateValueList( 4 );
+ USHORT nField = pLb->GetSelectEntryPos();
+ USHORT nQ=3+nOffset;
+ theQueryData.GetEntry(nQ).bDoQuery = TRUE;
+ theQueryData.GetEntry(nQ).nField = theQueryData.nCol1 + static_cast<SCCOL>(nField) - 1 ;
+ }
+
+ }
+ else if ( pLb == &aLbCond1)
+ {
+ theQueryData.GetEntry(nOffset).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+ else if ( pLb == &aLbCond2)
+ {
+ USHORT nQ=1+nOffset;
+ theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+ else if ( pLb == &aLbCond3)
+ {
+ USHORT nQ=2+nOffset;
+ theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+ else
+ {
+ USHORT nQ=3+nOffset;
+ theQueryData.GetEntry(nQ).eOp=(ScQueryOp)pLb->GetSelectEntryPos();
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, CheckBoxHdl, CheckBox*, pBox )
+{
+ // Spaltenkoepfe:
+ // FeldListen: Spaltexx <-> Spaltenkopf-String
+ // WertListen: Spaltenkopf-Wert entfaellt.
+ // Gross-/Kleinschreibung:
+ // WertListen: komplett neu
+
+ if ( pBox == &aBtnHeader ) // Feldlisten und Wertlisten
+ {
+ USHORT nCurSel1 = aLbField1.GetSelectEntryPos();
+ USHORT nCurSel2 = aLbField2.GetSelectEntryPos();
+ USHORT nCurSel3 = aLbField3.GetSelectEntryPos();
+ USHORT nCurSel4 = aLbField4.GetSelectEntryPos();
+ FillFieldLists();
+ aLbField1.SelectEntryPos( nCurSel1 );
+ aLbField2.SelectEntryPos( nCurSel2 );
+ aLbField3.SelectEntryPos( nCurSel3 );
+ aLbField4.SelectEntryPos( nCurSel4 );
+
+ UpdateHdrInValueList( 1 );
+ UpdateHdrInValueList( 2 );
+ UpdateHdrInValueList( 3 );
+ UpdateHdrInValueList( 4 );
+ }
+
+ if ( pBox == &aBtnCase ) // Wertlisten komplett
+ {
+ for (USHORT i=0; i<=MAXCOL; i++)
+ DELETEZ( pEntryLists[i] );
+
+ UpdateValueList( 1 ); // aktueller Text wird gemerkt
+ UpdateValueList( 2 );
+ UpdateValueList( 3 );
+ UpdateValueList( 4 );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterDlg, ValModifyHdl, ComboBox*, pEd )
+{
+ USHORT nOffset = GetSliderPos();
+ USHORT i=0;
+ USHORT nQE =i + nOffset;
+ if ( pEd )
+ {
+ String aStrVal = pEd->GetText();
+ ListBox* pLbCond = &aLbCond1;
+ ListBox* pLbField = &aLbField1;
+ if ( pEd == &aEdVal2 )
+ {
+ pLbCond = &aLbCond2;
+ pLbField = &aLbField2;
+ i=1;
+ nQE=i+nOffset;
+ }
+ if ( pEd == &aEdVal3 )
+ {
+ pLbCond = &aLbCond3;
+ pLbField = &aLbField3;
+ i=2;
+ nQE=i+nOffset;
+ }
+ if ( pEd == &aEdVal4 )
+ {
+ pLbCond = &aLbCond4;
+ pLbField = &aLbField4;
+ i=3;
+ nQE=i+nOffset;
+ }
+
+ if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal )
+ {
+ pLbCond->SelectEntry( '=' );
+ pLbCond->Disable();
+ }
+ else
+ pLbCond->Enable();
+
+ ScQueryEntry& rEntry = theQueryData.GetEntry( nQE );
+ BOOL bDoThis = (pLbField->GetSelectEntryPos() != 0);
+ rEntry.bDoQuery = bDoThis;
+
+ if ( rEntry.bDoQuery || bRefreshExceptQuery[nQE] )
+ {
+ if ( aStrVal == aStrEmpty )
+ {
+ rEntry.pStr->Erase();
+ rEntry.nVal = SC_EMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else if ( aStrVal == aStrNotEmpty )
+ {
+ rEntry.pStr->Erase();
+ rEntry.nVal = SC_NONEMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else
+ {
+ *rEntry.pStr = aStrVal;
+ rEntry.nVal = 0;
+ rEntry.bQueryByString = TRUE;
+ }
+
+ USHORT nField = pLbField->GetSelectEntryPos();
+ rEntry.nField = nField ? (theQueryData.nCol1 +
+ static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0);
+
+ ScQueryOp eOp = (ScQueryOp)pLbCond->GetSelectEntryPos();
+ rEntry.eOp = eOp;
+ rEntry.bQueryByDate = mbHasDates[nQE];
+
+ }
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+IMPL_LINK( ScFilterDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ SliderMoved();
+ return 0;
+}
+
+void ScFilterDlg::SliderMoved()
+{
+ USHORT nOffset = GetSliderPos();
+ RefreshEditRow( nOffset);
+}
+USHORT ScFilterDlg::GetSliderPos()
+{
+ return (USHORT) aScrollBar.GetThumbPos();
+}
+void ScFilterDlg::RefreshEditRow( USHORT nOffset )
+{
+ if (nOffset==0)
+ aConnLbArr[0]->Hide();
+ else
+ aConnLbArr[0]->Show();
+
+ for ( USHORT i=0; i<4; i++ )
+ {
+ String aValStr;
+ USHORT nCondPos = 0;
+ USHORT nFieldSelPos = 0;
+ USHORT nQE = i+nOffset;
+
+ ScQueryEntry& rEntry = theQueryData.GetEntry( nQE);
+ if ( rEntry.bDoQuery || bRefreshExceptQuery[nQE] )
+ {
+ nCondPos = (USHORT)rEntry.eOp;
+ if(rEntry.bDoQuery)
+ nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
+
+ if ( rEntry.nVal == SC_EMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else if ( rEntry.nVal == SC_NONEMPTYFIELDS && !rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING )
+ {
+ aValStr = aStrNotEmpty;
+ aCondLbArr[i]->Disable();
+ }
+ else
+ {
+ aValStr = *rEntry.pStr;
+ aCondLbArr[i]->Enable();
+ }
+ aFieldLbArr[i]->Enable();
+ aValueEdArr[i]->Enable();
+
+ if (nOffset==0)
+ {
+ if (i<3)
+ {
+ if(rEntry.bDoQuery)
+ aConnLbArr[i+1]->Enable();
+ else
+ aConnLbArr[i+1]->Disable();
+ USHORT nQENext = nQE+1;
+ if(theQueryData.GetEntry(nQENext).bDoQuery || bRefreshExceptQuery[nQENext])
+ aConnLbArr[i+1]->SelectEntryPos( (USHORT) theQueryData.GetEntry(nQENext).eConnect );
+ else
+ aConnLbArr[i+1]->SetNoSelection();
+ }
+ }
+ else
+ {
+ if(theQueryData.GetEntry( nQE-1).bDoQuery)
+ aConnLbArr[i]->Enable();
+ else
+ aConnLbArr[i]->Disable();
+
+ if(rEntry.bDoQuery || bRefreshExceptQuery[nQE])
+ aConnLbArr[i]->SelectEntryPos( (USHORT) rEntry.eConnect );
+ else
+ aConnLbArr[i]->SetNoSelection();
+ }
+
+ }
+ else
+ {
+ if (nOffset==0)
+ {
+ if(i<3)
+ {
+ aConnLbArr[i+1]->SetNoSelection();
+ aConnLbArr[i+1]->Disable();
+ }
+ }
+ else
+ {
+ if(theQueryData.GetEntry( nQE-1).bDoQuery)
+ aConnLbArr[i]->Enable();
+ else
+ aConnLbArr[i]->Disable();
+ aConnLbArr[i]->SetNoSelection();
+ }
+ aFieldLbArr[i]->Disable();
+ aCondLbArr[i]->Disable();
+ aValueEdArr[i]->Disable();
+ }
+ aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
+ aCondLbArr [i]->SelectEntryPos( nCondPos );
+ aValueEdArr[i]->SetText( aValStr );
+ UpdateValueList( static_cast<USHORT>(i+1) );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/foptmgr.cxx b/sc/source/ui/dbgui/foptmgr.cxx
new file mode 100644
index 000000000000..894e1ae80bd9
--- /dev/null
+++ b/sc/source/ui/dbgui/foptmgr.cxx
@@ -0,0 +1,340 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <vcl/morebtn.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include "anyrefdg.hxx"
+#include "rangeutl.hxx"
+#include "dbcolect.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "queryparam.hxx"
+
+#define _FOPTMGR_CXX
+#include "foptmgr.hxx"
+#undef _FOPTMGR_CXX
+
+//----------------------------------------------------------------------------
+
+ScFilterOptionsMgr::ScFilterOptionsMgr(
+ Dialog* ptrDlg,
+ ScViewData* ptrViewData,
+ const ScQueryParam& refQueryData,
+ MoreButton& refBtnMore,
+ CheckBox& refBtnCase,
+ CheckBox& refBtnRegExp,
+ CheckBox& refBtnHeader,
+ CheckBox& refBtnUnique,
+ CheckBox& refBtnCopyResult,
+ CheckBox& refBtnDestPers,
+ ListBox& refLbCopyArea,
+ Edit& refEdCopyArea,
+ formula::RefButton& refRbCopyArea,
+ FixedText& refFtDbAreaLabel,
+ FixedInfo& refFtDbArea,
+ FixedLine& refFlOptions,
+ const String& refStrNoName,
+ const String& refStrUndefined )
+
+ : pDlg ( ptrDlg ),
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData ? ptrViewData->GetDocument() : NULL ),
+ rBtnMore ( refBtnMore ),
+ rBtnCase ( refBtnCase ),
+ rBtnRegExp ( refBtnRegExp ),
+ rBtnHeader ( refBtnHeader ),
+ rBtnUnique ( refBtnUnique ),
+ rBtnCopyResult ( refBtnCopyResult ),
+ rBtnDestPers ( refBtnDestPers ),
+ rLbCopyPos ( refLbCopyArea ),
+ rEdCopyPos ( refEdCopyArea ),
+ rRbCopyPos ( refRbCopyArea ),
+ rFtDbAreaLabel ( refFtDbAreaLabel ),
+ rFtDbArea ( refFtDbArea ),
+ rFlOptions ( refFlOptions ),
+ rStrNoName ( refStrNoName ),
+ rStrUndefined ( refStrUndefined ),
+ rQueryData ( refQueryData )
+{
+ Init();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScFilterOptionsMgr::~ScFilterOptionsMgr()
+{
+ USHORT nEntries = rLbCopyPos.GetEntryCount();
+ USHORT i;
+
+ for ( i=2; i<nEntries; i++ )
+ delete (String*)rLbCopyPos.GetEntryData( i );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScFilterOptionsMgr::Init()
+{
+ DBG_ASSERT( pViewData && pDoc, "Init failed :-/" );
+
+ rLbCopyPos.SetSelectHdl ( LINK( this, ScFilterOptionsMgr, LbPosSelHdl ) );
+ rEdCopyPos.SetModifyHdl ( LINK( this, ScFilterOptionsMgr, EdPosModifyHdl ) );
+ rBtnCopyResult.SetClickHdl( LINK( this, ScFilterOptionsMgr, BtnCopyResultHdl ) );
+
+ rBtnMore.AddWindow( &rBtnCase );
+ rBtnMore.AddWindow( &rBtnRegExp );
+ rBtnMore.AddWindow( &rBtnHeader );
+ rBtnMore.AddWindow( &rBtnUnique );
+ rBtnMore.AddWindow( &rBtnCopyResult );
+ rBtnMore.AddWindow( &rBtnDestPers );
+ rBtnMore.AddWindow( &rLbCopyPos );
+ rBtnMore.AddWindow( &rEdCopyPos );
+ rBtnMore.AddWindow( &rRbCopyPos );
+ rBtnMore.AddWindow( &rFtDbAreaLabel );
+ rBtnMore.AddWindow( &rFtDbArea );
+ rBtnMore.AddWindow( &rFlOptions );
+
+ rBtnCase .Check( rQueryData.bCaseSens );
+ rBtnHeader .Check( rQueryData.bHasHeader );
+ rBtnRegExp .Check( rQueryData.bRegExp );
+ rBtnUnique .Check( !rQueryData.bDuplicate );
+
+ if ( pViewData && pDoc )
+ {
+ String theAreaStr;
+ ScRange theCurArea ( ScAddress( rQueryData.nCol1,
+ rQueryData.nRow1,
+ pViewData->GetTabNo() ),
+ ScAddress( rQueryData.nCol2,
+ rQueryData.nRow2,
+ pViewData->GetTabNo() ) );
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ String theDbArea;
+ String theDbName = rStrNoName;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ theCurArea.Format( theAreaStr, SCR_ABS_3D, pDoc, eConv );
+
+ // Zielbereichsliste fuellen
+
+ rLbCopyPos.Clear();
+ rLbCopyPos.InsertEntry( rStrUndefined, 0 );
+
+ ScAreaNameIterator aIter( pDoc );
+ String aName;
+ ScRange aRange;
+ String aRefStr;
+ while ( aIter.Next( aName, aRange ) )
+ {
+ USHORT nInsert = rLbCopyPos.InsertEntry( aName );
+
+ aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, eConv );
+ rLbCopyPos.SetEntryData( nInsert, new String( aRefStr ) );
+ }
+
+ rBtnDestPers.Check( TRUE ); // beim Aufruf immer an
+ rLbCopyPos.SelectEntryPos( 0 );
+ rEdCopyPos.SetText( EMPTY_STRING );
+
+ /*
+ * Ueberpruefen, ob es sich bei dem uebergebenen
+ * Bereich um einen Datenbankbereich handelt:
+ */
+
+ theDbArea = theAreaStr;
+
+ if ( pDBColl )
+ {
+ ScAddress& rStart = theCurArea.aStart;
+ ScAddress& rEnd = theCurArea.aEnd;
+ ScDBData* pDBData = pDBColl->GetDBAtArea( rStart.Tab(),
+ rStart.Col(), rStart.Row(),
+ rEnd.Col(), rEnd.Row() );
+ if ( pDBData )
+ {
+ rBtnHeader.Check( pDBData->HasHeader() );
+ pDBData->GetName( theDbName );
+
+ if ( theDbName != rStrNoName )
+ {
+ rBtnHeader.Disable();
+ }
+ }
+ }
+
+ theDbArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
+ theDbArea += theDbName;
+ theDbArea += ')';
+ rFtDbArea.SetText( theDbArea );
+
+ //------------------------------------------------------
+ // Kopierposition:
+
+ if ( !rQueryData.bInplace )
+ {
+ String aString;
+
+ ScAddress( rQueryData.nDestCol,
+ rQueryData.nDestRow,
+ rQueryData.nDestTab
+ ).Format( aString, SCA_ABS_3D, pDoc, eConv );
+
+ rBtnCopyResult.Check( TRUE );
+ rEdCopyPos.SetText( aString );
+ EdPosModifyHdl( &rEdCopyPos );
+ rLbCopyPos.Enable();
+ rEdCopyPos.Enable();
+ rRbCopyPos.Enable();
+ rBtnDestPers.Enable();
+ }
+ else
+ {
+ rBtnCopyResult.Check( FALSE );
+ rEdCopyPos.SetText( EMPTY_STRING );
+ rLbCopyPos.Disable();
+ rEdCopyPos.Disable();
+ rRbCopyPos.Disable();
+ rBtnDestPers.Disable();
+ }
+ }
+ else
+ rEdCopyPos.SetText( EMPTY_STRING );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScFilterOptionsMgr::VerifyPosStr( const String& rPosStr ) const
+{
+ String aPosStr( rPosStr );
+ xub_StrLen nColonPos = aPosStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ aPosStr.Erase( nColonPos );
+
+ USHORT nResult = ScAddress().Parse( aPosStr, pDoc, pDoc->GetAddressConvention() );
+
+ return ( SCA_VALID == (nResult & SCA_VALID) );
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterOptionsMgr, LbPosSelHdl, ListBox*, pLb )
+{
+ if ( pLb == &rLbCopyPos )
+ {
+ String aString;
+ USHORT nSelPos = rLbCopyPos.GetSelectEntryPos();
+
+ if ( nSelPos > 0 )
+ aString = *(String*)rLbCopyPos.GetEntryData( nSelPos );
+
+ rEdCopyPos.SetText( aString );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterOptionsMgr, EdPosModifyHdl, Edit*, pEd )
+{
+ if ( pEd == &rEdCopyPos )
+ {
+ String theCurPosStr = pEd->GetText();
+ USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = rLbCopyPos.GetEntryCount();
+
+ for ( i=2; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)rLbCopyPos.GetEntryData( i );
+ bFound = (theCurPosStr == *pStr);
+ }
+
+ if ( bFound )
+ rLbCopyPos.SelectEntryPos( --i );
+ else
+ rLbCopyPos.SelectEntryPos( 0 );
+ }
+ else
+ rLbCopyPos.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFilterOptionsMgr, BtnCopyResultHdl, CheckBox*, pBox )
+{
+ if ( pBox == &rBtnCopyResult )
+ {
+ if ( pBox->IsChecked() )
+ {
+ rBtnDestPers.Enable();
+ rLbCopyPos.Enable();
+ rEdCopyPos.Enable();
+ rRbCopyPos.Enable();
+ rEdCopyPos.GrabFocus();
+ }
+ else
+ {
+ rBtnDestPers.Disable();
+ rLbCopyPos.Disable();
+ rEdCopyPos.Disable();
+ rRbCopyPos.Disable();
+ }
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/imoptdlg.cxx b/sc/source/ui/dbgui/imoptdlg.cxx
new file mode 100644
index 000000000000..b7a614e9224f
--- /dev/null
+++ b/sc/source/ui/dbgui/imoptdlg.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "imoptdlg.hxx"
+#include "scresid.hxx"
+#include "imoptdlg.hrc"
+#include <rtl/tencinfo.h>
+
+static const sal_Char pStrFix[] = "FIX";
+
+//------------------------------------------------------------------------
+// Der Options-String darf kein Semikolon mehr enthalten (wegen Pickliste)
+// darum ab Version 336 Komma stattdessen
+
+
+ScImportOptions::ScImportOptions( const String& rStr )
+{
+ bFixedWidth = FALSE;
+ nFieldSepCode = 0;
+ if ( rStr.GetTokenCount(',') >= 3 )
+ {
+ String aToken( rStr.GetToken( 0, ',' ) );
+ if( aToken.EqualsIgnoreCaseAscii( pStrFix ) )
+ bFixedWidth = TRUE;
+ else
+ nFieldSepCode = (sal_Unicode) aToken.ToInt32();
+ nTextSepCode = (sal_Unicode) rStr.GetToken(1,',').ToInt32();
+ aStrFont = rStr.GetToken(2,',');
+ eCharSet = ScGlobal::GetCharsetValue(aStrFont);
+ bSaveAsShown = (rStr.GetToken( 3, ',' ).ToInt32() ? TRUE : FALSE);
+ }
+}
+
+//------------------------------------------------------------------------
+
+String ScImportOptions::BuildString() const
+{
+ String aResult;
+
+ if( bFixedWidth )
+ aResult.AppendAscii( pStrFix );
+ else
+ aResult += String::CreateFromInt32(nFieldSepCode);
+ aResult += ',';
+ aResult += String::CreateFromInt32(nTextSepCode);
+ aResult += ',';
+ aResult += aStrFont;
+ aResult += ',';
+ aResult += String::CreateFromInt32( bSaveAsShown ? 1 : 0 );
+
+ return aResult;
+}
+
+//------------------------------------------------------------------------
+
+void ScImportOptions::SetTextEncoding( rtl_TextEncoding nEnc )
+{
+ eCharSet = (nEnc == RTL_TEXTENCODING_DONTKNOW ?
+ gsl_getSystemTextEncoding() : nEnc);
+ aStrFont = ScGlobal::GetCharsetString( nEnc );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/imoptdlg.hrc b/sc/source/ui/dbgui/imoptdlg.hrc
new file mode 100644
index 000000000000..b6f1bf5555d2
--- /dev/null
+++ b/sc/source/ui/dbgui/imoptdlg.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+
+//#define RID_SCDLG_IMPORTOPT 2256
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define FT_FIELDSEP 4
+#define ED_FIELDSEP 5
+#define FT_TEXTSEP 6
+#define ED_TEXTSEP 7
+#define FT_FONT 8
+#define DDLB_FONT 9
+#define LB_FONT 10
+#define FL_FIELDOPT 11
+#define CB_FIXEDWIDTH 12
+#define CB_SAVESHOWN 13
+
diff --git a/sc/source/ui/dbgui/imoptdlg.src b/sc/source/ui/dbgui/imoptdlg.src
new file mode 100644
index 000000000000..af38520aadb3
--- /dev/null
+++ b/sc/source/ui/dbgui/imoptdlg.src
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "imoptdlg.hrc"
+
+ModalDialog RID_SCDLG_IMPORTOPT
+{
+ HelpId = HID_SC_INPORTOPT ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 256 , 66 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Text [ en-US ] = "Import File" ;
+ FixedText FT_FIELDSEP
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Text [ en-US ] = "~Field delimiter" ;
+ };
+ ComboBox ED_FIELDSEP
+ {
+ Pos = MAP_APPFONT ( 70 , 30 ) ;
+ Size = MAP_APPFONT ( 121 , 60 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_TEXTSEP
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Text [ en-US ] = "~Text delimiter" ;
+ };
+ ComboBox ED_TEXTSEP
+ {
+ Pos = MAP_APPFONT ( 70 , 46 ) ;
+ Size = MAP_APPFONT ( 121 , 60 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_FONT
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 55 , 8 ) ;
+ Text [ en-US ] = "~Character set" ;
+ };
+ ListBox DDLB_FONT
+ {
+ Border = TRUE;
+ Sort = TRUE;
+ DropDown = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 14 ) ;
+ Size = MAP_APPFONT ( 121 , 52 ) ;
+ };
+ ListBox LB_FONT
+ {
+ Border = TRUE;
+ Sort = TRUE;
+ DropDown = FALSE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 179 , 50 ) ;
+ };
+ FixedLine FL_FIELDOPT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 188 , 8 ) ;
+ Text [ en-US ] = "Field options" ;
+ };
+ CheckBox CB_FIXEDWIDTH
+ {
+ Pos = MAP_APPFONT( 12, 80 );
+ Size = MAP_APPFONT( 172, 10 );
+ Hide = TRUE;
+ Text [ en-US ] = "Fixed column ~width";
+ };
+ CheckBox CB_SAVESHOWN
+ {
+ Pos = MAP_APPFONT( 12, 66 );
+ Size = MAP_APPFONT( 172, 10 );
+ TabStop = TRUE;
+ Hide = TRUE;
+ Text [ en-US ] = "Save cell content as ~shown";
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 202 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 202 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 202 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/makefile.mk b/sc/source/ui/dbgui/makefile.mk
new file mode 100644
index 000000000000..ab632bf1b1e7
--- /dev/null
+++ b/sc/source/ui/dbgui/makefile.mk
@@ -0,0 +1,120 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=dbgui
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/sortdlg.obj \
+ $(SLO)$/tpsort.obj \
+ $(SLO)$/filtdlg.obj \
+ $(SLO)$/sfiltdlg.obj \
+ $(SLO)$/foptmgr.obj \
+ $(SLO)$/pfiltdlg.obj \
+ $(SLO)$/dbnamdlg.obj \
+ $(SLO)$/expftext.obj \
+ $(SLO)$/textimportoptions.obj \
+ $(SLO)$/subtdlg.obj \
+ $(SLO)$/tpsubt.obj \
+ $(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvlaydlg.obj \
+ $(SLO)$/pvfundlg.obj \
+ $(SLO)$/dpgroupdlg.obj \
+ $(SLO)$/dapitype.obj \
+ $(SLO)$/dapidata.obj \
+ $(SLO)$/consdlg.obj \
+ $(SLO)$/scendlg.obj \
+ $(SLO)$/imoptdlg.obj \
+ $(SLO)$/validate.obj \
+ $(SLO)$/csvsplits.obj \
+ $(SLO)$/csvcontrol.obj \
+ $(SLO)$/csvruler.obj \
+ $(SLO)$/csvgrid.obj \
+ $(SLO)$/csvtablebox.obj \
+ $(SLO)$/asciiopt.obj \
+ $(SLO)$/scuiasciiopt.obj \
+ $(SLO)$/scuiimoptdlg.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/csvgrid.obj \
+ $(SLO)$/csvruler.obj \
+ $(SLO)$/csvsplits.obj \
+ $(SLO)$/csvtablebox.obj \
+ $(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvfundlg.obj \
+ $(SLO)$/pvlaydlg.obj \
+ $(SLO)$/dapidata.obj \
+ $(SLO)$/validate.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ textimportoptions.src \
+ pivot.src \
+ pvfundlg.src \
+ dpgroupdlg.src \
+ dapitype.src \
+ consdlg.src \
+ scendlg.src \
+ imoptdlg.src \
+ validate.src \
+ asciiopt.src \
+ outline.src
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/filtdlg.obj \
+ $(SLO)$/sfiltdlg.obj \
+ $(SLO)$/foptmgr.obj \
+ $(SLO)$/dbnamdlg.obj \
+ $(SLO)$/expftext.obj \
+ $(SLO)$/fieldwnd.obj \
+ $(SLO)$/pvlaydlg.obj \
+ $(SLO)$/consdlg.obj \
+ $(SLO)$/imoptdlg.obj \
+ $(SLO)$/csvsplits.obj \
+ $(SLO)$/csvcontrol.obj \
+ $(SLO)$/csvruler.obj \
+ $(SLO)$/csvgrid.obj \
+ $(SLO)$/csvtablebox.obj \
+ $(SLO)$/asciiopt.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/sc/source/ui/dbgui/outline.src b/sc/source/ui/dbgui/outline.src
new file mode 100644
index 000000000000..7f8eab69f716
--- /dev/null
+++ b/sc/source/ui/dbgui/outline.src
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+
+// Imageliste hier, damit sie nicht in ui.src beim Zusammenbauen der
+// "echten" Imagelisten stoert
+
+#define OUTLINE_ID_LIST \
+ IdList = { 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; }; \
+ IdCount = { 12; };
+
+ImageList RID_OUTLINEBITMAPS
+{
+ Prefix = "ou";
+ MaskColor = STD_MASKCOLOR;
+ OUTLINE_ID_LIST
+};
+
+ImageList RID_OUTLINEBITMAPS_H
+{
+ Prefix = "ouh";
+ MaskColor = SC_HC_MASKCOLOR;
+ OUTLINE_ID_LIST
+};
+
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
new file mode 100644
index 000000000000..5108b69b2d1f
--- /dev/null
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -0,0 +1,622 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#ifndef PCH
+#include <vcl/waitobj.hxx>
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "dbcolect.hxx"
+#include "scresid.hxx"
+
+#include "sc.hrc"
+#include "filter.hrc"
+#include "globstr.hrc"
+
+#define _PFILTDLG_CXX
+#include "pfiltdlg.hxx"
+#undef _PFILTDLG_CXX
+#include <svl/zforlist.hxx>
+
+//==================================================================
+
+ScPivotFilterDlg::ScPivotFilterDlg( Window* pParent,
+ const SfxItemSet& rArgSet,
+ SCTAB nSourceTab )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTFILTER ) ),
+ //
+ aFlCriteria ( this, ScResId( FL_CRITERIA ) ),
+ aLbField1 ( this, ScResId( LB_FIELD1 ) ),
+ aLbCond1 ( this, ScResId( LB_COND1 ) ),
+ aEdVal1 ( this, ScResId( ED_VAL1 ) ),
+ aLbConnect1 ( this, ScResId( LB_OP1 ) ),
+ aLbField2 ( this, ScResId( LB_FIELD2 ) ),
+ aLbCond2 ( this, ScResId( LB_COND2 ) ),
+ aEdVal2 ( this, ScResId( ED_VAL2 ) ),
+ aLbConnect2 ( this, ScResId( LB_OP2 ) ),
+ aLbField3 ( this, ScResId( LB_FIELD3 ) ),
+ aLbCond3 ( this, ScResId( LB_COND3 ) ),
+ aEdVal3 ( this, ScResId( ED_VAL3 ) ),
+ aFtConnect ( this, ScResId( FT_OP ) ),
+ aFtField ( this, ScResId( FT_FIELD ) ),
+ aFtCond ( this, ScResId( FT_COND ) ),
+ aFtVal ( this, ScResId( FT_VAL ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnCase ( this, ScResId( BTN_CASE ) ),
+ aBtnRegExp ( this, ScResId( BTN_REGEXP ) ),
+ aBtnUnique ( this, ScResId( BTN_UNIQUE ) ),
+ aFtDbAreaLabel ( this, ScResId( FT_DBAREA_LABEL ) ),
+ aFtDbArea ( this, ScResId( FT_DBAREA ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
+ aStrNone ( ScResId( SCSTR_NONE ) ),
+ aStrEmpty ( ScResId( SCSTR_EMPTY ) ),
+ aStrNotEmpty ( ScResId( SCSTR_NOTEMPTY ) ),
+ aStrRow ( ScResId( SCSTR_ROW ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ //
+ nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
+ theQueryData ( ((const ScQueryItem&)
+ rArgSet.Get( nWhichQuery )).GetQueryData() ),
+ pOutItem ( NULL ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nSrcTab ( nSourceTab ), // ist nicht im QueryParam
+ nFieldCount ( 0 )
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ pEntryLists[i] = NULL;
+
+ Init( rArgSet );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScPivotFilterDlg::~ScPivotFilterDlg()
+{
+ for (USHORT i=0; i<=MAXCOL; i++)
+ delete pEntryLists[i];
+
+ if ( pOutItem )
+ delete pOutItem;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScPivotFilterDlg::Init( const SfxItemSet& rArgSet )
+{
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)
+ rArgSet.Get( nWhichQuery );
+
+ aBtnCase.SetClickHdl ( LINK( this, ScPivotFilterDlg, CheckBoxHdl ) );
+
+ aLbField1.SetSelectHdl ( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbField2.SetSelectHdl ( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbField3.SetSelectHdl ( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbConnect1.SetSelectHdl( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+ aLbConnect2.SetSelectHdl( LINK( this, ScPivotFilterDlg, LbSelectHdl ) );
+
+ aBtnMore.AddWindow( &aBtnCase );
+ aBtnMore.AddWindow( &aBtnRegExp );
+ aBtnMore.AddWindow( &aBtnUnique );
+ aBtnMore.AddWindow( &aFtDbAreaLabel );
+ aBtnMore.AddWindow( &aFtDbArea );
+ aBtnMore.AddWindow( &aFlOptions );
+
+ aBtnCase .Check( theQueryData.bCaseSens );
+ aBtnRegExp .Check( theQueryData.bRegExp );
+ aBtnUnique .Check( !theQueryData.bDuplicate );
+
+ pViewData = rQueryItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+
+ // fuer leichteren Zugriff:
+ aFieldLbArr [0] = &aLbField1;
+ aFieldLbArr [1] = &aLbField2;
+ aFieldLbArr [2] = &aLbField3;
+ aValueEdArr [0] = &aEdVal1;
+ aValueEdArr [1] = &aEdVal2;
+ aValueEdArr [2] = &aEdVal3;
+ aCondLbArr [0] = &aLbCond1;
+ aCondLbArr [1] = &aLbCond2;
+ aCondLbArr [2] = &aLbCond3;
+
+ if ( pViewData && pDoc )
+ {
+ String theAreaStr;
+ ScRange theCurArea ( ScAddress( theQueryData.nCol1,
+ theQueryData.nRow1,
+ nSrcTab ),
+ ScAddress( theQueryData.nCol2,
+ theQueryData.nRow2,
+ nSrcTab ) );
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ String theDbArea;
+ String theDbName = aStrNoName;
+
+ /*
+ * Ueberpruefen, ob es sich bei dem uebergebenen
+ * Bereich um einen Datenbankbereich handelt:
+ */
+
+ theCurArea.Format( theAreaStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+
+ if ( pDBColl )
+ {
+ ScAddress& rStart = theCurArea.aStart;
+ ScAddress& rEnd = theCurArea.aEnd;
+ ScDBData* pDBData = pDBColl->GetDBAtArea( rStart.Tab(),
+ rStart.Col(), rStart.Row(),
+ rEnd.Col(), rEnd.Row() );
+ if ( pDBData )
+ pDBData->GetName( theDbName );
+ }
+
+ theDbArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
+ theDbArea += theDbName;
+ theDbArea += ')';
+ aFtDbArea.SetText( theDbArea );
+ }
+ else
+ {
+ aFtDbArea.SetText( EMPTY_STRING );
+ }
+
+ // Feldlisten einlesen und Eintraege selektieren:
+
+ FillFieldLists();
+
+ for ( SCSIZE i=0; i<3; i++ )
+ {
+ if ( theQueryData.GetEntry(i).bDoQuery )
+ {
+ ScQueryEntry& rEntry = theQueryData.GetEntry(i);
+
+ String aValStr = *rEntry.pStr;
+ if (!rEntry.bQueryByString && aValStr == EMPTY_STRING)
+ {
+ if (rEntry.nVal == SC_EMPTYFIELDS)
+ aValStr = aStrEmpty;
+ else if (rEntry.nVal == SC_NONEMPTYFIELDS)
+ aValStr = aStrNotEmpty;
+ }
+ USHORT nCondPos = (USHORT)rEntry.eOp;
+ USHORT nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) );
+
+ aFieldLbArr[i]->SelectEntryPos( nFieldSelPos );
+ aCondLbArr [i]->SelectEntryPos( nCondPos );
+ UpdateValueList( static_cast<USHORT>(i+1) );
+ aValueEdArr[i]->SetText( aValStr );
+ if (aValStr == aStrEmpty || aValStr == aStrNotEmpty)
+ aCondLbArr[i]->Disable();
+ }
+ else
+ {
+ aFieldLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren
+ aCondLbArr [i]->SelectEntryPos( 0 ); // "=" selektieren
+ UpdateValueList( static_cast<USHORT>(i) );
+ aValueEdArr[i]->SetText( EMPTY_STRING );
+ }
+ aValueEdArr[i]->SetModifyHdl( LINK( this, ScPivotFilterDlg, ValModifyHdl ) );
+ }
+
+ // Disable/Enable Logik:
+
+ (aLbField1.GetSelectEntryPos() != 0)
+ && (aLbField2.GetSelectEntryPos() != 0)
+ ? aLbConnect1.SelectEntryPos( (USHORT)theQueryData.GetEntry(1).eConnect )
+ : aLbConnect1.SetNoSelection();
+
+ (aLbField2.GetSelectEntryPos() != 0)
+ && (aLbField3.GetSelectEntryPos() != 0)
+ ? aLbConnect2.SelectEntryPos( (USHORT)theQueryData.GetEntry(2).eConnect )
+ : aLbConnect2.SetNoSelection();
+
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect1.Disable();
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+ else if ( aLbConnect1.GetSelectEntryCount() == 0 )
+ {
+ aLbField2.Disable();
+ aLbCond2.Disable();
+ aEdVal2.Disable();
+ }
+
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.Disable();
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ else if ( aLbConnect2.GetSelectEntryCount() == 0 )
+ {
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScPivotFilterDlg::FillFieldLists()
+{
+ aLbField1.Clear();
+ aLbField2.Clear();
+ aLbField3.Clear();
+ aLbField1.InsertEntry( aStrNone, 0 );
+ aLbField2.InsertEntry( aStrNone, 0 );
+ aLbField3.InsertEntry( aStrNone, 0 );
+
+ if ( pDoc )
+ {
+ String aFieldName;
+ SCTAB nTab = nSrcTab;
+ SCCOL nFirstCol = theQueryData.nCol1;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCCOL nMaxCol = theQueryData.nCol2;
+ SCCOL col = 0;
+ USHORT i=1;
+
+ for ( col=nFirstCol; col<=nMaxCol; col++ )
+ {
+ pDoc->GetString( col, nFirstRow, nTab, aFieldName );
+ if ( aFieldName.Len() == 0 )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ScColToAlpha( col );
+ }
+ aLbField1.InsertEntry( aFieldName, i );
+ aLbField2.InsertEntry( aFieldName, i );
+ aLbField3.InsertEntry( aFieldName, i );
+ i++;
+ }
+ nFieldCount = i;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScPivotFilterDlg::UpdateValueList( USHORT nList )
+{
+ if ( pDoc && nList>0 && nList<=3 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ USHORT nFieldSelPos = aFieldLbArr[nList-1]->GetSelectEntryPos();
+ USHORT nListPos = 0;
+ String aCurValue = pValList->GetText();
+
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ nListPos = 2;
+
+ if ( pDoc && nFieldSelPos )
+ {
+ SCCOL nColumn = theQueryData.nCol1 + static_cast<SCCOL>(nFieldSelPos) - 1;
+ if (!pEntryLists[nColumn])
+ {
+ WaitObject aWaiter( this );
+
+ SCTAB nTab = nSrcTab;
+ SCROW nFirstRow = theQueryData.nRow1;
+ SCROW nLastRow = theQueryData.nRow2;
+ nFirstRow++;
+ bool bHasDates = false;
+
+ pEntryLists[nColumn] = new TypedScStrCollection( 128, 128 );
+ pEntryLists[nColumn]->SetCaseSensitive( aBtnCase.IsChecked() );
+ pDoc->GetFilterEntriesArea( nColumn, nFirstRow, nLastRow,
+ nTab, *pEntryLists[nColumn], bHasDates );
+ }
+
+ TypedScStrCollection* pColl = pEntryLists[nColumn];
+ USHORT nValueCount = pColl->GetCount();
+ if ( nValueCount > 0 )
+ {
+ for ( USHORT i=0; i<nValueCount; i++ )
+ {
+ pValList->InsertEntry( (*pColl)[i]->GetString(), nListPos );
+ nListPos++;
+ }
+ }
+ }
+ pValList->SetText( aCurValue );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScPivotFilterDlg::ClearValueList( USHORT nList )
+{
+ if ( nList>0 && nList<=3 )
+ {
+ ComboBox* pValList = aValueEdArr[nList-1];
+ pValList->Clear();
+ pValList->InsertEntry( aStrNotEmpty, 0 );
+ pValList->InsertEntry( aStrEmpty, 1 );
+ pValList->SetText( EMPTY_STRING );
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScPivotFilterDlg::GetFieldSelPos( SCCOL nField )
+{
+ if ( nField >= theQueryData.nCol1 && nField <= theQueryData.nCol2 )
+ return static_cast<USHORT>(nField - theQueryData.nCol1 + 1);
+ else
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+const ScQueryItem& ScPivotFilterDlg::GetOutputItem()
+{
+ ScQueryParam theParam( theQueryData );
+ USHORT nConnect1 = aLbConnect1.GetSelectEntryPos();
+ USHORT nConnect2 = aLbConnect2.GetSelectEntryPos();
+
+ for ( SCSIZE i=0; i<3; i++ )
+ {
+ USHORT nField = aFieldLbArr[i]->GetSelectEntryPos();
+ ScQueryOp eOp = (ScQueryOp)aCondLbArr[i]->GetSelectEntryPos();
+
+ BOOL bDoThis = (aFieldLbArr[i]->GetSelectEntryPos() != 0);
+ theParam.GetEntry(i).bDoQuery = bDoThis;
+
+ if ( bDoThis )
+ {
+ ScQueryEntry& rEntry = theParam.GetEntry(i);
+
+ String aStrVal( aValueEdArr[i]->GetText() );
+
+ /*
+ * Dialog liefert die ausgezeichneten Feldwerte "leer"/"nicht leer"
+ * als Konstanten in nVal in Verbindung mit dem Schalter
+ * bQueryByString auf FALSE.
+ */
+ if ( aStrVal == aStrEmpty )
+ {
+ *rEntry.pStr = EMPTY_STRING;
+ rEntry.nVal = SC_EMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else if ( aStrVal == aStrNotEmpty )
+ {
+ *rEntry.pStr = EMPTY_STRING;
+ rEntry.nVal = SC_NONEMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ }
+ else
+ {
+ *rEntry.pStr = aStrVal;
+ rEntry.nVal = 0;
+ rEntry.bQueryByString = TRUE;
+ }
+
+ rEntry.nField = nField ? (theQueryData.nCol1 +
+ static_cast<SCCOL>(nField) - 1) : static_cast<SCCOL>(0);
+ rEntry.eOp = eOp;
+ }
+ }
+
+ theParam.GetEntry(1).eConnect = (nConnect1 != LISTBOX_ENTRY_NOTFOUND)
+ ? (ScQueryConnect)nConnect1
+ : SC_AND;
+ theParam.GetEntry(2).eConnect = (nConnect2 != LISTBOX_ENTRY_NOTFOUND)
+ ? (ScQueryConnect)nConnect2
+ : SC_AND;
+
+ theParam.bInplace = FALSE;
+ theParam.nDestTab = 0; // Woher kommen diese Werte?
+ theParam.nDestCol = 0;
+ theParam.nDestRow = 0;
+
+ theParam.bDuplicate = !aBtnUnique.IsChecked();
+ theParam.bCaseSens = aBtnCase.IsChecked();
+ theParam.bRegExp = aBtnRegExp.IsChecked();
+
+ if ( pOutItem ) DELETEZ( pOutItem );
+ pOutItem = new ScQueryItem( nWhichQuery, &theParam );
+
+ return *pOutItem;
+}
+
+//------------------------------------------------------------------------
+// Handler:
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFilterDlg, LbSelectHdl, ListBox*, pLb )
+{
+ /*
+ * Behandlung der Enable/Disable-Logik,
+ * abhaengig davon, welche ListBox angefasst wurde:
+ */
+
+ if ( pLb == &aLbConnect1 )
+ {
+ if ( !aLbField2.IsEnabled() )
+ {
+ aLbField2.Enable();
+ aLbCond2.Enable();
+ aEdVal2.Enable();
+ }
+ }
+ else if ( pLb == &aLbConnect2 )
+ {
+ if ( !aLbField3.IsEnabled() )
+ {
+ aLbField3.Enable();
+ aLbCond3.Enable();
+ aEdVal3.Enable();
+ }
+ }
+ else if ( pLb == &aLbField1 )
+ {
+ if ( aLbField1.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect1.SetNoSelection();
+ aLbConnect2.SetNoSelection();
+ aLbField2.SelectEntryPos( 0 );
+ aLbField3.SelectEntryPos( 0 );
+ aLbCond2.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ ClearValueList( 1 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+
+ aLbConnect1.Disable();
+ aLbConnect2.Disable();
+ aLbField2.Disable();
+ aLbField3.Disable();
+ aLbCond2.Disable();
+ aLbCond3.Disable();
+ aEdVal2.Disable();
+ aEdVal3.Disable();
+ }
+ else
+ {
+ UpdateValueList( 1 );
+ if ( !aLbConnect1.IsEnabled() )
+ {
+ aLbConnect1.Enable();
+ }
+ }
+ }
+ else if ( pLb == &aLbField2 )
+ {
+ if ( aLbField2.GetSelectEntryPos() == 0 )
+ {
+ aLbConnect2.SetNoSelection();
+ aLbField3.SelectEntryPos( 0 );
+ aLbCond3.SelectEntryPos( 0 );
+ ClearValueList( 2 );
+ ClearValueList( 3 );
+
+ aLbConnect2.Disable();
+ aLbField3.Disable();
+ aLbCond3.Disable();
+ aEdVal3.Disable();
+ }
+ else
+ {
+ UpdateValueList( 2 );
+ if ( !aLbConnect2.IsEnabled() )
+ {
+ aLbConnect2.Enable();
+ }
+ }
+ }
+ else if ( pLb == &aLbField3 )
+ {
+ ( aLbField3.GetSelectEntryPos() == 0 )
+ ? ClearValueList( 3 )
+ : UpdateValueList( 3 );
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFilterDlg, CheckBoxHdl, CheckBox*, pBox )
+{
+ // bei Gross-/Kleinschreibung die Werte-Listen aktualisieren
+
+ if ( pBox == &aBtnCase ) // Wertlisten
+ {
+ for (USHORT i=0; i<=MAXCOL; i++)
+ DELETEZ( pEntryLists[i] );
+
+ String aCurVal1 = aEdVal1.GetText();
+ String aCurVal2 = aEdVal2.GetText();
+ String aCurVal3 = aEdVal3.GetText();
+ UpdateValueList( 1 );
+ UpdateValueList( 2 );
+ UpdateValueList( 3 );
+ aEdVal1.SetText( aCurVal1 );
+ aEdVal2.SetText( aCurVal2 );
+ aEdVal3.SetText( aCurVal3 );
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScPivotFilterDlg, ValModifyHdl, ComboBox*, pEd )
+{
+ if ( pEd )
+ {
+ String aStrVal = pEd->GetText();
+ ListBox* pLb = &aLbCond1;
+
+ if ( pEd == &aEdVal2 ) pLb = &aLbCond2;
+ else if ( pEd == &aEdVal3 ) pLb = &aLbCond3;
+
+ // wenn einer der Sonderwerte leer/nicht-leer
+ // gewaehlt wird, so macht nur der =-Operator Sinn:
+
+ if ( aStrEmpty == aStrVal || aStrNotEmpty == aStrVal )
+ {
+ pLb->SelectEntry( '=' );
+ pLb->Disable();
+ }
+ else
+ pLb->Enable();
+ }
+
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/pivot.hrc b/sc/source/ui/dbgui/pivot.hrc
new file mode 100644
index 000000000000..097b0931ff3a
--- /dev/null
+++ b/sc/source/ui/dbgui/pivot.hrc
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc" // ->RID_SCDLG_PIVOT_LAYOUT
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_MORE 4
+#define BTN_REMOVE 5
+#define BTN_OPTIONS 6
+
+#define FL_LAYOUT 10
+#define WND_COL 11
+#define WND_ROW 12
+#define WND_DATA 13
+#define WND_SELECT 14
+#define WND_FIELD 15
+#define WND_FIELD_SPACE 16
+#define WND_HSCROLL 17
+#define WND_PAGE 18
+#define FT_COL 31
+#define FT_ROW 32
+#define FT_DATA 33
+#define STR_SELECT 34
+#define FT_PAGE 35
+
+#define PTR_FIELD 18
+#define FT_INFO 19
+
+#define FL_OUTPUT 20
+#define FT_OUTAREA 21
+#define LB_OUTAREA 22
+#define ED_OUTAREA 23
+#define RB_OUTAREA 24
+#define BTN_IGNEMPTYROWS 25
+#define BTN_DETECTCAT 26
+#define BTN_TOTALCOL 27
+#define BTN_TOTALROW 28
+#define BTN_FILTER 29
+#define BTN_DRILLDOWN 30
+
+#define FT_INAREA 40
+#define RB_INAREA 41
+#define ED_INAREA 42
+
+#define PIVOTSTR_SUM 1
+#define PIVOTSTR_COUNT 2
+#define PIVOTSTR_AVG 3
+#define PIVOTSTR_MAX 4
+#define PIVOTSTR_MIN 5
+#define PIVOTSTR_PROD 6
+#define PIVOTSTR_COUNT2 7
+#define PIVOTSTR_DEV 8
+#define PIVOTSTR_DEV2 9
+#define PIVOTSTR_VAR 10
+#define PIVOTSTR_VAR2 11
+
diff --git a/sc/source/ui/dbgui/pivot.src b/sc/source/ui/dbgui/pivot.src
new file mode 100644
index 000000000000..7e7fe2491ced
--- /dev/null
+++ b/sc/source/ui/dbgui/pivot.src
@@ -0,0 +1,328 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pivot.hrc"
+
+ModelessDialog RID_SCDLG_PIVOT_LAYOUT
+{
+ OutputSize = TRUE ;
+ HelpId = SID_OPENDLG_PIVOTTABLE ;
+ Size = MAP_APPFONT ( 336 , 190 ) ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Text [ en-US ] = "DataPilot" ;
+
+ FixedText FT_PAGE
+ {
+ Pos = MAP_APPFONT ( 194 , 168 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text[ en-US ] = "Page Fields" ;
+ };
+ Control WND_PAGE
+ {
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 182 , 24 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_COL
+ {
+ Pos = MAP_APPFONT ( 231 , 168 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text [ en-US ] = "Column Fields" ;
+ };
+ Control WND_COL
+ {
+ Pos = MAP_APPFONT ( 44 , 40 ) ;
+ Size = MAP_APPFONT ( 144 , 24 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_ROW
+ {
+ Pos = MAP_APPFONT ( 194 , 176 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text [ en-US ] = "Row\nFields" ;
+ };
+ Control WND_ROW
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 36 , 96 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_DATA
+ {
+ Pos = MAP_APPFONT ( 231, 176 ) ;
+ Size = MAP_APPFONT ( 37 , 8 ) ;
+ Text [ en-US ] = "Data Fields" ;
+ };
+ Control WND_DATA
+ {
+ Pos = MAP_APPFONT ( 44 , 66 ) ;
+ Size = MAP_APPFONT ( 144 , 96 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_SELECT
+ {
+ Pos = MAP_APPFONT ( 194 , 14 ) ;
+ Size = MAP_APPFONT ( 70 , 126 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_SELECT
+ {
+ Text [ en-US ] = "Selection area";
+ };
+ ScrollBar WND_HSCROLL
+ {
+ Pos = MAP_APPFONT ( 194 , 144 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ HScroll = TRUE ;
+ TabStop = FALSE ;
+ };
+ FixedText FT_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 168 ) ;
+ Size = MAP_APPFONT ( 182 , 16 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Drag the fields from the right into the desired position." ;
+ };
+ FixedLine FL_LAYOUT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 268 , 8 ) ;
+ Text [ en-US ] = "Layout";
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 280 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 280 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 280 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 280 , 63 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Remove";
+ };
+ PushButton BTN_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 280 , 80 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Options...";
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 280 , 170 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 90 ;
+ };
+ Window WND_FIELD
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 36 , 12 ) ;
+ };
+ Window WND_FIELD_SPACE
+ {
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 2 , 2 ) ;
+ };
+ FixedLine FL_OUTPUT
+ {
+ Pos = MAP_APPFONT ( 6 , 190 ) ;
+ Size = MAP_APPFONT ( 268 , 8 ) ;
+ Text [ en-US ] = "Result" ;
+ Hide = TRUE ;
+ };
+
+ FixedText FT_INAREA
+ {
+ Pos = MAP_APPFONT ( 12 , 203 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Selection from" ;
+ };
+ Edit ED_INAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 73 , 201 ) ;
+ Size = MAP_APPFONT ( 100 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ ImageButton RB_INAREA
+ {
+ Pos = MAP_APPFONT ( 177 , 200 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+
+ FixedText FT_OUTAREA
+ {
+ Pos = MAP_APPFONT ( 12 , 221 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Results to" ;
+ };
+ ListBox LB_OUTAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 73 , 219 ) ;
+ Size = MAP_APPFONT ( 75 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Hide = TRUE ;
+ };
+ Edit ED_OUTAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 152 , 219 ) ;
+ Size = MAP_APPFONT ( 100 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ };
+ ImageButton RB_OUTAREA
+ {
+ Pos = MAP_APPFONT ( 256 , 218 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ CheckBox BTN_IGNEMPTYROWS
+ {
+ Pos = MAP_APPFONT ( 12 , 237 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Ignore ~empty rows" ;
+ };
+ CheckBox BTN_DETECTCAT
+ {
+ Pos = MAP_APPFONT ( 142 , 237 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "~Identify categories" ;
+ };
+ CheckBox BTN_TOTALCOL
+ {
+ Pos = MAP_APPFONT ( 12 , 251 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Total columns" ;
+ };
+ CheckBox BTN_TOTALROW
+ {
+ Pos = MAP_APPFONT ( 142 , 251 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "~Total rows" ;
+ };
+ CheckBox BTN_FILTER
+ {
+ Pos = MAP_APPFONT ( 12 , 265 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "~Add filter" ;
+ };
+ CheckBox BTN_DRILLDOWN
+ {
+ Pos = MAP_APPFONT ( 142 , 265 ) ;
+ Size = MAP_APPFONT ( 124 , 10 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Ena~ble drill to details" ;
+ };
+ String PIVOTSTR_SUM
+ {
+ Text [ en-US ] = "Sum - " ;
+ };
+ String PIVOTSTR_COUNT
+ {
+ Text [ en-US ] = "Count - " ;
+ };
+ String PIVOTSTR_AVG
+ {
+ Text [ en-US ] = "Mean - " ;
+ };
+ String PIVOTSTR_MAX
+ {
+ Text [ en-US ] = "Max - " ;
+ };
+ String PIVOTSTR_MIN
+ {
+ Text [ en-US ] = "Min - " ;
+ };
+ String PIVOTSTR_PROD
+ {
+ Text [ en-US ] = "Product - " ;
+ };
+ String PIVOTSTR_COUNT2
+ {
+ Text [ en-US ] = "Count - " ;
+ };
+ String PIVOTSTR_DEV
+ {
+ Text [ en-US ] = "StDev - " ;
+ };
+ String PIVOTSTR_DEV2
+ {
+ Text [ en-US ] = "StDevP - " ;
+ };
+ String PIVOTSTR_VAR
+ {
+ Text [ en-US ] = "Var - " ;
+ };
+ String PIVOTSTR_VAR2
+ {
+ Text [ en-US ] = "VarP - " ;
+ };
+};
+
diff --git a/sc/source/ui/dbgui/pvfundlg.cxx b/sc/source/ui/dbgui/pvfundlg.cxx
new file mode 100644
index 000000000000..ca4fbafb1400
--- /dev/null
+++ b/sc/source/ui/dbgui/pvfundlg.cxx
@@ -0,0 +1,858 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "pvfundlg.hxx"
+
+#include <com/sun/star/sheet/DataPilotFieldReferenceType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldReferenceItemType.hpp>
+#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldShowItemsMode.hpp>
+
+#include <tools/resary.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "scresid.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "pvfundlg.hrc"
+#include "globstr.hrc"
+
+#include <vector>
+
+// ============================================================================
+
+using namespace ::com::sun::star::sheet;
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::Sequence;
+using ::std::vector;
+
+// ============================================================================
+
+namespace {
+
+/** Appends all strings from the Sequence to the list box.
+
+ Empty strings are replaced by a localized "(empty)" entry and inserted at
+ the specified position.
+
+ @return true = The passed string list contains an empty string entry.
+ */
+template< typename ListBoxType >
+bool lclFillListBox( ListBoxType& rLBox, const Sequence< OUString >& rStrings, USHORT nEmptyPos = LISTBOX_APPEND )
+{
+ bool bEmpty = false;
+ if( const OUString* pStr = rStrings.getConstArray() )
+ {
+ for( const OUString* pEnd = pStr + rStrings.getLength(); pStr != pEnd; ++pStr )
+ {
+ if( pStr->getLength() )
+ rLBox.InsertEntry( *pStr );
+ else
+ {
+ rLBox.InsertEntry( ScGlobal::GetRscString( STR_EMPTYDATA ), nEmptyPos );
+ bEmpty = true;
+ }
+ }
+ }
+ return bEmpty;
+}
+
+template< typename ListBoxType >
+bool lclFillListBox( ListBoxType& rLBox, const vector<ScDPLabelData::Member>& rMembers, USHORT nEmptyPos = LISTBOX_APPEND )
+{
+ bool bEmpty = false;
+ vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ OUString aName = itr->getDisplayName();
+ if (aName.getLength())
+ rLBox.InsertEntry(aName);
+ else
+ {
+ rLBox.InsertEntry(ScGlobal::GetRscString(STR_EMPTYDATA), nEmptyPos);
+ bEmpty = true;
+ }
+ }
+ return bEmpty;
+}
+
+/** This table represents the order of the strings in the resource string array. */
+static const USHORT spnFunctions[] =
+{
+ PIVOT_FUNC_SUM,
+ PIVOT_FUNC_COUNT,
+ PIVOT_FUNC_AVERAGE,
+ PIVOT_FUNC_MAX,
+ PIVOT_FUNC_MIN,
+ PIVOT_FUNC_PRODUCT,
+ PIVOT_FUNC_COUNT_NUM,
+ PIVOT_FUNC_STD_DEV,
+ PIVOT_FUNC_STD_DEVP,
+ PIVOT_FUNC_STD_VAR,
+ PIVOT_FUNC_STD_VARP
+};
+
+const USHORT SC_BASEITEM_PREV_POS = 0;
+const USHORT SC_BASEITEM_NEXT_POS = 1;
+const USHORT SC_BASEITEM_USER_POS = 2;
+
+const USHORT SC_SORTNAME_POS = 0;
+const USHORT SC_SORTDATA_POS = 1;
+
+const long SC_SHOW_DEFAULT = 10;
+
+static const ScDPListBoxWrapper::MapEntryType spRefTypeMap[] =
+{
+ { 0, DataPilotFieldReferenceType::NONE },
+ { 1, DataPilotFieldReferenceType::ITEM_DIFFERENCE },
+ { 2, DataPilotFieldReferenceType::ITEM_PERCENTAGE },
+ { 3, DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE },
+ { 4, DataPilotFieldReferenceType::RUNNING_TOTAL },
+ { 5, DataPilotFieldReferenceType::ROW_PERCENTAGE },
+ { 6, DataPilotFieldReferenceType::COLUMN_PERCENTAGE },
+ { 7, DataPilotFieldReferenceType::TOTAL_PERCENTAGE },
+ { 8, DataPilotFieldReferenceType::INDEX },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldReferenceType::NONE }
+};
+
+static const ScDPListBoxWrapper::MapEntryType spLayoutMap[] =
+{
+ { 0, DataPilotFieldLayoutMode::TABULAR_LAYOUT },
+ { 1, DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_TOP },
+ { 2, DataPilotFieldLayoutMode::OUTLINE_SUBTOTALS_BOTTOM },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldLayoutMode::TABULAR_LAYOUT }
+};
+
+static const ScDPListBoxWrapper::MapEntryType spShowFromMap[] =
+{
+ { 0, DataPilotFieldShowItemsMode::FROM_TOP },
+ { 1, DataPilotFieldShowItemsMode::FROM_BOTTOM },
+ { LISTBOX_ENTRY_NOTFOUND, DataPilotFieldShowItemsMode::FROM_TOP }
+};
+
+} // namespace
+
+// ============================================================================
+
+ScDPFunctionListBox::ScDPFunctionListBox( Window* pParent, const ResId& rResId ) :
+ MultiListBox( pParent, rResId )
+{
+ FillFunctionNames();
+}
+
+void ScDPFunctionListBox::SetSelection( USHORT nFuncMask )
+{
+ if( (nFuncMask == PIVOT_FUNC_NONE) || (nFuncMask == PIVOT_FUNC_AUTO) )
+ SetNoSelection();
+ else
+ for( USHORT nEntry = 0, nCount = GetEntryCount(); nEntry < nCount; ++nEntry )
+ SelectEntryPos( nEntry, (nFuncMask & spnFunctions[ nEntry ]) != 0 );
+}
+
+USHORT ScDPFunctionListBox::GetSelection() const
+{
+ USHORT nFuncMask = PIVOT_FUNC_NONE;
+ for( USHORT nSel = 0, nCount = GetSelectEntryCount(); nSel < nCount; ++nSel )
+ nFuncMask |= spnFunctions[ GetSelectEntryPos( nSel ) ];
+ return nFuncMask;
+}
+
+void ScDPFunctionListBox::FillFunctionNames()
+{
+ DBG_ASSERT( !GetEntryCount(), "ScDPFunctionListBox::FillFunctionNames - do not add texts to resource" );
+ Clear();
+ ResStringArray aArr( ScResId( SCSTR_DPFUNCLISTBOX ) );
+ for( USHORT nIndex = 0, nCount = sal::static_int_cast<USHORT>(aArr.Count()); nIndex < nCount; ++nIndex )
+ InsertEntry( aArr.GetString( nIndex ) );
+}
+
+// ============================================================================
+
+ScDPFunctionDlg::ScDPFunctionDlg(
+ Window* pParent, const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPDATAFIELD ) ),
+ maFlFunc ( this, ScResId( FL_FUNC ) ),
+ maLbFunc ( this, ScResId( LB_FUNC ) ),
+ maFtNameLabel ( this, ScResId( FT_NAMELABEL ) ),
+ maFtName ( this, ScResId( FT_NAME ) ),
+ maFlDisplay ( this, ScResId( FL_DISPLAY ) ),
+ maFtType ( this, ScResId( FT_TYPE ) ),
+ maLbType ( this, ScResId( LB_TYPE ) ),
+ maFtBaseField ( this, ScResId( FT_BASEFIELD ) ),
+ maLbBaseField ( this, ScResId( LB_BASEFIELD ) ),
+ maFtBaseItem ( this, ScResId( FT_BASEITEM ) ),
+ maLbBaseItem ( this, ScResId( LB_BASEITEM ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnMore ( this, ScResId( BTN_MORE ) ),
+ maLbTypeWrp ( maLbType, spRefTypeMap ),
+ mrLabelVec ( rLabelVec ),
+ mbEmptyItem ( false )
+{
+ FreeResource();
+ Init( rLabelData, rFuncData );
+}
+
+USHORT ScDPFunctionDlg::GetFuncMask() const
+{
+ return maLbFunc.GetSelection();
+}
+
+DataPilotFieldReference ScDPFunctionDlg::GetFieldRef() const
+{
+ DataPilotFieldReference aRef;
+
+ aRef.ReferenceType = maLbTypeWrp.GetControlValue();
+ aRef.ReferenceField = GetBaseFieldName(maLbBaseField.GetSelectEntry());
+
+ USHORT nBaseItemPos = maLbBaseItem.GetSelectEntryPos();
+ switch( nBaseItemPos )
+ {
+ case SC_BASEITEM_PREV_POS:
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::PREVIOUS;
+ break;
+ case SC_BASEITEM_NEXT_POS:
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NEXT;
+ break;
+ default:
+ {
+ aRef.ReferenceItemType = DataPilotFieldReferenceItemType::NAMED;
+ if( !mbEmptyItem || (nBaseItemPos > SC_BASEITEM_USER_POS) )
+ aRef.ReferenceItemName = GetBaseItemName(maLbBaseItem.GetSelectEntry());
+ }
+ }
+
+ return aRef;
+}
+
+void ScDPFunctionDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+{
+ // list box
+ USHORT nFuncMask = (rFuncData.mnFuncMask == PIVOT_FUNC_NONE) ? PIVOT_FUNC_SUM : rFuncData.mnFuncMask;
+ maLbFunc.SetSelection( nFuncMask );
+
+ // field name
+ maFtName.SetText(rLabelData.getDisplayName());
+
+ // "More button" controls
+ maBtnMore.AddWindow( &maFlDisplay );
+ maBtnMore.AddWindow( &maFtType );
+ maBtnMore.AddWindow( &maLbType );
+ maBtnMore.AddWindow( &maFtBaseField );
+ maBtnMore.AddWindow( &maLbBaseField );
+ maBtnMore.AddWindow( &maFtBaseItem );
+ maBtnMore.AddWindow( &maLbBaseItem );
+
+ // handlers
+ maLbFunc.SetDoubleClickHdl( LINK( this, ScDPFunctionDlg, DblClickHdl ) );
+ maLbType.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+ maLbBaseField.SetSelectHdl( LINK( this, ScDPFunctionDlg, SelectHdl ) );
+
+ // base field list box
+ OUString aSelectedEntry;
+ for( ScDPLabelDataVec::const_iterator aIt = mrLabelVec.begin(), aEnd = mrLabelVec.end(); aIt != aEnd; ++aIt )
+ {
+ maLbBaseField.InsertEntry(aIt->getDisplayName());
+ maBaseFieldNameMap.insert(
+ NameMapType::value_type(aIt->getDisplayName(), aIt->maName));
+ if (aIt->maName == rFuncData.maFieldRef.ReferenceField)
+ aSelectedEntry = aIt->getDisplayName();
+ }
+
+ // base item list box
+ maLbBaseItem.SetSeparatorPos( SC_BASEITEM_USER_POS - 1 );
+
+ // select field reference type
+ maLbTypeWrp.SetControlValue( rFuncData.maFieldRef.ReferenceType );
+ SelectHdl( &maLbType ); // enables base field/item list boxes
+
+ // select base field
+ maLbBaseField.SelectEntry(aSelectedEntry);
+ if( maLbBaseField.GetSelectEntryPos() >= maLbBaseField.GetEntryCount() )
+ maLbBaseField.SelectEntryPos( 0 );
+ SelectHdl( &maLbBaseField ); // fills base item list, selects base item
+
+ // select base item
+ switch( rFuncData.maFieldRef.ReferenceItemType )
+ {
+ case DataPilotFieldReferenceItemType::PREVIOUS:
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_PREV_POS );
+ break;
+ case DataPilotFieldReferenceItemType::NEXT:
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_NEXT_POS );
+ break;
+ default:
+ {
+ if( mbEmptyItem && !rFuncData.maFieldRef.ReferenceItemName.getLength() )
+ {
+ // select special "(empty)" entry added before other items
+ maLbBaseItem.SelectEntryPos( SC_BASEITEM_USER_POS );
+ }
+ else
+ {
+ USHORT nStartPos = mbEmptyItem ? (SC_BASEITEM_USER_POS + 1) : SC_BASEITEM_USER_POS;
+ USHORT nPos = FindBaseItemPos( rFuncData.maFieldRef.ReferenceItemName, nStartPos );
+ if( nPos >= maLbBaseItem.GetEntryCount() )
+ nPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+ maLbBaseItem.SelectEntryPos( nPos );
+ }
+ }
+ }
+}
+
+const OUString& ScDPFunctionDlg::GetBaseFieldName(const OUString& rLayoutName) const
+{
+ NameMapType::const_iterator itr = maBaseFieldNameMap.find(rLayoutName);
+ return itr == maBaseFieldNameMap.end() ? rLayoutName : itr->second;
+}
+
+const OUString& ScDPFunctionDlg::GetBaseItemName(const OUString& rLayoutName) const
+{
+ NameMapType::const_iterator itr = maBaseItemNameMap.find(rLayoutName);
+ return itr == maBaseItemNameMap.end() ? rLayoutName : itr->second;
+}
+
+sal_uInt16 ScDPFunctionDlg::FindBaseItemPos( const String& rEntry, USHORT nStartPos ) const
+{
+ sal_uInt16 nPos = nStartPos;
+ bool bFound = false;
+ while (nPos < maLbBaseItem.GetEntryCount())
+ {
+ // translate the displayed field name back to its original field name.
+ const OUString& rName = GetBaseItemName(maLbBaseItem.GetEntry(nPos));
+ if (rName.equals(rEntry))
+ {
+ bFound = true;
+ break;
+ }
+ ++nPos;
+ }
+ return bFound ? nPos : LISTBOX_ENTRY_NOTFOUND;
+}
+
+IMPL_LINK( ScDPFunctionDlg, SelectHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbType )
+ {
+ bool bEnableField, bEnableItem;
+ switch( maLbTypeWrp.GetControlValue() )
+ {
+ case DataPilotFieldReferenceType::ITEM_DIFFERENCE:
+ case DataPilotFieldReferenceType::ITEM_PERCENTAGE:
+ case DataPilotFieldReferenceType::ITEM_PERCENTAGE_DIFFERENCE:
+ bEnableField = bEnableItem = true;
+ break;
+
+ case DataPilotFieldReferenceType::RUNNING_TOTAL:
+ bEnableField = true;
+ bEnableItem = false;
+ break;
+
+ default:
+ bEnableField = bEnableItem = false;
+ }
+
+ bEnableField &= maLbBaseField.GetEntryCount() > 0;
+ maFtBaseField.Enable( bEnableField );
+ maLbBaseField.Enable( bEnableField );
+
+ bEnableItem &= bEnableField;
+ maFtBaseItem.Enable( bEnableItem );
+ maLbBaseItem.Enable( bEnableItem );
+ }
+ else if( pLBox == &maLbBaseField )
+ {
+ // keep "previous" and "next" entries
+ while( maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS )
+ maLbBaseItem.RemoveEntry( SC_BASEITEM_USER_POS );
+
+ // update item list for current base field
+ mbEmptyItem = false;
+ size_t nBasePos = maLbBaseField.GetSelectEntryPos();
+ if( nBasePos < mrLabelVec.size() )
+ {
+ const vector<ScDPLabelData::Member>& rMembers = mrLabelVec[nBasePos].maMembers;
+ mbEmptyItem = lclFillListBox( maLbBaseItem, rMembers, SC_BASEITEM_USER_POS );
+ // build cache for base names.
+ NameMapType aMap;
+ vector<ScDPLabelData::Member>::const_iterator itr = rMembers.begin(), itrEnd = rMembers.end();
+ for (; itr != itrEnd; ++itr)
+ aMap.insert(NameMapType::value_type(itr->getDisplayName(), itr->maName));
+ maBaseItemNameMap.swap(aMap);
+ }
+
+ // select base item
+ USHORT nItemPos = (maLbBaseItem.GetEntryCount() > SC_BASEITEM_USER_POS) ? SC_BASEITEM_USER_POS : SC_BASEITEM_PREV_POS;
+ maLbBaseItem.SelectEntryPos( nItemPos );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPFunctionDlg, DblClickHdl, MultiListBox*, EMPTYARG )
+{
+ maBtnOk.Click();
+ return 0;
+}
+
+// ============================================================================
+
+ScDPSubtotalDlg::ScDPSubtotalDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData,
+ const ScDPNameVec& rDataFields, bool bEnableLayout ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_PIVOTSUBT ) ),
+ maFlSubt ( this, ScResId( FL_FUNC ) ),
+ maRbNone ( this, ScResId( RB_NONE ) ),
+ maRbAuto ( this, ScResId( RB_AUTO ) ),
+ maRbUser ( this, ScResId( RB_USER ) ),
+ maLbFunc ( this, ScResId( LB_FUNC ) ),
+ maFtNameLabel ( this, ScResId( FT_NAMELABEL ) ),
+ maFtName ( this, ScResId( FT_NAME ) ),
+ maCbShowAll ( this, ScResId( CB_SHOWALL ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnOptions ( this, ScResId( BTN_OPTIONS ) ),
+ mrDPObj ( rDPObj ),
+ mrDataFields ( rDataFields ),
+ maLabelData ( rLabelData ),
+ mbEnableLayout ( bEnableLayout )
+{
+ FreeResource();
+ Init( rLabelData, rFuncData );
+}
+
+USHORT ScDPSubtotalDlg::GetFuncMask() const
+{
+ USHORT nFuncMask = PIVOT_FUNC_NONE;
+
+ if( maRbAuto.IsChecked() )
+ nFuncMask = PIVOT_FUNC_AUTO;
+ else if( maRbUser.IsChecked() )
+ nFuncMask = maLbFunc.GetSelection();
+
+ return nFuncMask;
+}
+
+void ScDPSubtotalDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ rLabelData.mnFuncMask = GetFuncMask();
+ rLabelData.mnUsedHier = maLabelData.mnUsedHier;
+ rLabelData.mbShowAll = maCbShowAll.IsChecked();
+ rLabelData.maMembers = maLabelData.maMembers;
+ rLabelData.maSortInfo = maLabelData.maSortInfo;
+ rLabelData.maLayoutInfo = maLabelData.maLayoutInfo;
+ rLabelData.maShowInfo = maLabelData.maShowInfo;
+}
+
+void ScDPSubtotalDlg::Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData )
+{
+ // field name
+ maFtName.SetText(rLabelData.getDisplayName());
+
+ // radio buttons
+ maRbNone.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+ maRbAuto.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+ maRbUser.SetClickHdl( LINK( this, ScDPSubtotalDlg, RadioClickHdl ) );
+
+ RadioButton* pRBtn = 0;
+ switch( rFuncData.mnFuncMask )
+ {
+ case PIVOT_FUNC_NONE: pRBtn = &maRbNone; break;
+ case PIVOT_FUNC_AUTO: pRBtn = &maRbAuto; break;
+ default: pRBtn = &maRbUser;
+ }
+ pRBtn->Check();
+ RadioClickHdl( pRBtn );
+
+ // list box
+ maLbFunc.SetSelection( rFuncData.mnFuncMask );
+ maLbFunc.SetDoubleClickHdl( LINK( this, ScDPSubtotalDlg, DblClickHdl ) );
+
+ // show all
+ maCbShowAll.Check( rLabelData.mbShowAll );
+
+ // options
+ maBtnOptions.SetClickHdl( LINK( this, ScDPSubtotalDlg, ClickHdl ) );
+}
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPSubtotalDlg, RadioClickHdl, RadioButton*, pBtn )
+{
+ maLbFunc.Enable( pBtn == &maRbUser );
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalDlg, DblClickHdl, MultiListBox*, EMPTYARG )
+{
+ maBtnOk.Click();
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalDlg, ClickHdl, PushButton*, pBtn )
+{
+ if( pBtn == &maBtnOptions )
+ {
+ ScDPSubtotalOptDlg* pDlg = new ScDPSubtotalOptDlg( this, mrDPObj, maLabelData, mrDataFields, mbEnableLayout );
+ if( pDlg->Execute() == RET_OK )
+ pDlg->FillLabelData( maLabelData );
+ delete pDlg;
+ }
+ return 0;
+}
+
+// ============================================================================
+
+ScDPSubtotalOptDlg::ScDPSubtotalOptDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPNameVec& rDataFields,
+ bool bEnableLayout ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPSUBTOTAL_OPT ) ),
+ maFlSortBy ( this, ScResId( FL_SORT_BY ) ),
+ maLbSortBy ( this, ScResId( LB_SORT_BY ) ),
+ maRbSortAsc ( this, ScResId( RB_SORT_ASC ) ),
+ maRbSortDesc ( this, ScResId( RB_SORT_DESC ) ),
+ maRbSortMan ( this, ScResId( RB_SORT_MAN ) ),
+ maFlLayout ( this, ScResId( FL_LAYOUT ) ),
+ maFtLayout ( this, ScResId( FT_LAYOUT ) ),
+ maLbLayout ( this, ScResId( LB_LAYOUT ) ),
+ maCbLayoutEmpty ( this, ScResId( CB_LAYOUT_EMPTY ) ),
+ maFlAutoShow ( this, ScResId( FL_AUTOSHOW ) ),
+ maCbShow ( this, ScResId( CB_SHOW ) ),
+ maNfShow ( this, ScResId( NF_SHOW ) ),
+ maFtShow ( this, ScResId( FT_SHOW ) ),
+ maFtShowFrom ( this, ScResId( FT_SHOW_FROM ) ),
+ maLbShowFrom ( this, ScResId( LB_SHOW_FROM ) ),
+ maFtShowUsing ( this, ScResId( FT_SHOW_USING ) ),
+ maLbShowUsing ( this, ScResId( LB_SHOW_USING ) ),
+ maFlHide ( this, ScResId( FL_HIDE ) ),
+ maLbHide ( this, ScResId( CT_HIDE ) ),
+ maFtHierarchy ( this, ScResId( FT_HIERARCHY ) ),
+ maLbHierarchy ( this, ScResId( LB_HIERARCHY ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maLbLayoutWrp ( maLbLayout, spLayoutMap ),
+ maLbShowFromWrp ( maLbShowFrom, spShowFromMap ),
+ mrDPObj ( rDPObj ),
+ maLabelData ( rLabelData )
+{
+ FreeResource();
+ Init( rDataFields, bEnableLayout );
+}
+
+void ScDPSubtotalOptDlg::FillLabelData( ScDPLabelData& rLabelData ) const
+{
+ // *** SORTING ***
+
+ if( maRbSortMan.IsChecked() )
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::MANUAL;
+ else if( maLbSortBy.GetSelectEntryPos() == SC_SORTNAME_POS )
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::NAME;
+ else
+ rLabelData.maSortInfo.Mode = DataPilotFieldSortMode::DATA;
+
+ rLabelData.maSortInfo.Field = GetFieldName(maLbSortBy.GetSelectEntry());
+ rLabelData.maSortInfo.IsAscending = maRbSortAsc.IsChecked();
+
+ // *** LAYOUT MODE ***
+
+ rLabelData.maLayoutInfo.LayoutMode = maLbLayoutWrp.GetControlValue();
+ rLabelData.maLayoutInfo.AddEmptyLines = maCbLayoutEmpty.IsChecked();
+
+ // *** AUTO SHOW ***
+
+ rLabelData.maShowInfo.IsEnabled = maCbShow.IsChecked();
+ rLabelData.maShowInfo.ShowItemsMode = maLbShowFromWrp.GetControlValue();
+ rLabelData.maShowInfo.ItemCount = sal::static_int_cast<sal_Int32>( maNfShow.GetValue() );
+ rLabelData.maShowInfo.DataField = GetFieldName(maLbShowUsing.GetSelectEntry());
+
+ // *** HIDDEN ITEMS ***
+
+ rLabelData.maMembers = maLabelData.maMembers;
+ ULONG nVisCount = maLbHide.GetEntryCount();
+ for( USHORT nPos = 0; nPos < nVisCount; ++nPos )
+ rLabelData.maMembers[nPos].mbVisible = !maLbHide.IsChecked(nPos);
+
+ // *** HIERARCHY ***
+
+ rLabelData.mnUsedHier = maLbHierarchy.GetSelectEntryCount() ? maLbHierarchy.GetSelectEntryPos() : 0;
+}
+
+void ScDPSubtotalOptDlg::Init( const ScDPNameVec& rDataFields, bool bEnableLayout )
+{
+ // *** SORTING ***
+
+ sal_Int32 nSortMode = maLabelData.maSortInfo.Mode;
+
+ // sort fields list box
+ maLbSortBy.InsertEntry(maLabelData.getDisplayName());
+
+ for( ScDPNameVec::const_iterator aIt = rDataFields.begin(), aEnd = rDataFields.end(); aIt != aEnd; ++aIt )
+ {
+ // Cache names for later lookup.
+ maDataFieldNameMap.insert(NameMapType::value_type(aIt->maLayoutName, aIt->maName));
+
+ maLbSortBy.InsertEntry( aIt->maLayoutName );
+ maLbShowUsing.InsertEntry( aIt->maLayoutName ); // for AutoShow
+ }
+
+ if( maLbSortBy.GetEntryCount() > SC_SORTDATA_POS )
+ maLbSortBy.SetSeparatorPos( SC_SORTDATA_POS - 1 );
+
+ USHORT nSortPos = SC_SORTNAME_POS;
+ if( nSortMode == DataPilotFieldSortMode::DATA )
+ {
+ nSortPos = FindListBoxEntry( maLbSortBy, maLabelData.maSortInfo.Field, SC_SORTDATA_POS );
+ if( nSortPos >= maLbSortBy.GetEntryCount() )
+ {
+ nSortPos = SC_SORTNAME_POS;
+ nSortMode = DataPilotFieldSortMode::MANUAL;
+ }
+ }
+ maLbSortBy.SelectEntryPos( nSortPos );
+
+ // sorting mode
+ maRbSortAsc.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+ maRbSortDesc.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+ maRbSortMan.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, RadioClickHdl ) );
+
+ RadioButton* pRBtn = 0;
+ switch( nSortMode )
+ {
+ case DataPilotFieldSortMode::NONE:
+ case DataPilotFieldSortMode::MANUAL:
+ pRBtn = &maRbSortMan;
+ break;
+ default:
+ pRBtn = maLabelData.maSortInfo.IsAscending ? &maRbSortAsc : &maRbSortDesc;
+ }
+ pRBtn->Check();
+ RadioClickHdl( pRBtn );
+
+ // *** LAYOUT MODE ***
+
+ maFlLayout.Enable( bEnableLayout );
+ maFtLayout.Enable( bEnableLayout );
+ maLbLayout.Enable( bEnableLayout );
+ maCbLayoutEmpty.Enable( bEnableLayout );
+
+ maLbLayoutWrp.SetControlValue( maLabelData.maLayoutInfo.LayoutMode );
+ maCbLayoutEmpty.Check( maLabelData.maLayoutInfo.AddEmptyLines );
+
+ // *** AUTO SHOW ***
+
+ maCbShow.Check( maLabelData.maShowInfo.IsEnabled );
+ maCbShow.SetClickHdl( LINK( this, ScDPSubtotalOptDlg, CheckHdl ) );
+
+ maLbShowFromWrp.SetControlValue( maLabelData.maShowInfo.ShowItemsMode );
+ long nCount = static_cast< long >( maLabelData.maShowInfo.ItemCount );
+ if( nCount < 1 )
+ nCount = SC_SHOW_DEFAULT;
+ maNfShow.SetValue( nCount );
+
+ // maLbShowUsing already filled above
+ maLbShowUsing.SelectEntry( maLabelData.maShowInfo.DataField );
+ if( maLbShowUsing.GetSelectEntryPos() >= maLbShowUsing.GetEntryCount() )
+ maLbShowUsing.SelectEntryPos( 0 );
+
+ CheckHdl( &maCbShow ); // enable/disable dependent controls
+
+ // *** HIDDEN ITEMS ***
+
+ maLbHide.SetHelpId( HID_SC_DPSUBT_HIDE );
+ InitHideListBox();
+
+ // *** HIERARCHY ***
+
+ if( maLabelData.maHiers.getLength() > 1 )
+ {
+ lclFillListBox( maLbHierarchy, maLabelData.maHiers );
+ sal_Int32 nHier = maLabelData.mnUsedHier;
+ if( (nHier < 0) || (nHier >= maLabelData.maHiers.getLength()) ) nHier = 0;
+ maLbHierarchy.SelectEntryPos( static_cast< USHORT >( nHier ) );
+ maLbHierarchy.SetSelectHdl( LINK( this, ScDPSubtotalOptDlg, SelectHdl ) );
+ }
+ else
+ {
+ maFtHierarchy.Disable();
+ maLbHierarchy.Disable();
+ }
+}
+
+void ScDPSubtotalOptDlg::InitHideListBox()
+{
+ maLbHide.Clear();
+ lclFillListBox( maLbHide, maLabelData.maMembers );
+ size_t n = maLabelData.maMembers.size();
+ for (size_t i = 0; i < n; ++i)
+ maLbHide.CheckEntryPos(static_cast<USHORT>(i), !maLabelData.maMembers[i].mbVisible);
+ bool bEnable = maLbHide.GetEntryCount() > 0;
+ maFlHide.Enable( bEnable );
+ maLbHide.Enable( bEnable );
+}
+
+const OUString& ScDPSubtotalOptDlg::GetFieldName(const OUString& rLayoutName) const
+{
+ NameMapType::const_iterator itr = maDataFieldNameMap.find(rLayoutName);
+ return itr == maDataFieldNameMap.end() ? rLayoutName : itr->second;
+}
+
+sal_uInt16 ScDPSubtotalOptDlg::FindListBoxEntry(
+ const ListBox& rLBox, const String& rEntry, USHORT nStartPos ) const
+{
+ sal_uInt16 nPos = nStartPos;
+ bool bFound = false;
+ while (nPos < rLBox.GetEntryCount())
+ {
+ // translate the displayed field name back to its original field name.
+ const OUString& rName = GetFieldName(rLBox.GetEntry(nPos));
+ if (rName.equals(rEntry))
+ {
+ bFound = true;
+ break;
+ }
+ ++nPos;
+ }
+ return bFound ? nPos : LISTBOX_ENTRY_NOTFOUND;
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, RadioClickHdl, RadioButton*, pBtn )
+{
+ maLbSortBy.Enable( pBtn != &maRbSortMan );
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, CheckHdl, CheckBox*, pCBox )
+{
+ if( pCBox == &maCbShow )
+ {
+ bool bEnable = maCbShow.IsChecked();
+ maNfShow.Enable( bEnable );
+ maFtShow.Enable( bEnable );
+ maFtShowFrom.Enable( bEnable );
+ maLbShowFrom.Enable( bEnable );
+
+ bool bEnableUsing = bEnable && (maLbShowUsing.GetEntryCount() > 0);
+ maFtShowUsing.Enable( bEnableUsing );
+ maLbShowUsing.Enable( bEnableUsing );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDPSubtotalOptDlg, SelectHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbHierarchy )
+ {
+ mrDPObj.GetMembers(maLabelData.mnCol, maLbHierarchy.GetSelectEntryPos(), maLabelData.maMembers);
+ InitHideListBox();
+ }
+ return 0;
+}
+
+// ============================================================================
+
+ScDPShowDetailDlg::ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHORT nOrient ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DPSHOWDETAIL ) ),
+ maFtDims ( this, ScResId( FT_DIMS ) ),
+ maLbDims ( this, ScResId( LB_DIMS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ mrDPObj(rDPObj)
+{
+ FreeResource();
+
+ ScDPSaveData* pSaveData = rDPObj.GetSaveData();
+ long nDimCount = rDPObj.GetDimCount();
+ for (long nDim=0; nDim<nDimCount; nDim++)
+ {
+ BOOL bIsDataLayout;
+ sal_Int32 nDimFlags = 0;
+ String aName = rDPObj.GetDimName( nDim, bIsDataLayout, &nDimFlags );
+ if ( !bIsDataLayout && !rDPObj.IsDuplicated( nDim ) && ScDPObject::IsOrientationAllowed( nOrient, nDimFlags ) )
+ {
+ const ScDPSaveDimension* pDimension = pSaveData ? pSaveData->GetExistingDimensionByName(aName) : 0;
+ if ( !pDimension || (pDimension->GetOrientation() != nOrient) )
+ {
+ if (pDimension)
+ {
+ const OUString* pLayoutName = pDimension->GetLayoutName();
+ if (pLayoutName)
+ aName = *pLayoutName;
+ }
+ maLbDims.InsertEntry( aName );
+ maNameIndexMap.insert(DimNameIndexMap::value_type(aName, nDim));
+ }
+ }
+ }
+ if( maLbDims.GetEntryCount() )
+ maLbDims.SelectEntryPos( 0 );
+
+ maLbDims.SetDoubleClickHdl( LINK( this, ScDPShowDetailDlg, DblClickHdl ) );
+}
+
+short ScDPShowDetailDlg::Execute()
+{
+ return maLbDims.GetEntryCount() ? ModalDialog::Execute() : RET_CANCEL;
+}
+
+String ScDPShowDetailDlg::GetDimensionName() const
+{
+ // Look up the internal dimension name which may be different from the
+ // displayed field name.
+ String aSelectedName = maLbDims.GetSelectEntry();
+ DimNameIndexMap::const_iterator itr = maNameIndexMap.find(aSelectedName);
+ if (itr == maNameIndexMap.end())
+ // This should never happen!
+ return aSelectedName;
+
+ long nDim = itr->second;
+ BOOL bIsDataLayout = false;
+ return mrDPObj.GetDimName(nDim, bIsDataLayout);
+}
+
+IMPL_LINK( ScDPShowDetailDlg, DblClickHdl, ListBox*, pLBox )
+{
+ if( pLBox == &maLbDims )
+ maBtnOk.Click();
+ return 0;
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/pvfundlg.hrc b/sc/source/ui/dbgui/pvfundlg.hrc
new file mode 100644
index 000000000000..4e155cadf1b9
--- /dev/null
+++ b/sc/source/ui/dbgui/pvfundlg.hrc
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+// RID_SCDLG_DPDATAFIELD - DataPilot Data Field Function
+// RID_SCDLG_PIVOTSUBT - DataPilot Page/Row/Column Field Subtotals
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define BTN_MORE 4
+#define BTN_OPTIONS 5
+
+#define RB_NONE 1
+#define RB_AUTO 2
+#define RB_USER 3
+#define RB_SORT_ASC 4
+#define RB_SORT_DESC 5
+#define RB_SORT_MAN 6
+
+#define FL_FUNC 1
+#define FL_DISPLAY 2
+#define FL_SORT_BY 3
+#define FL_LAYOUT 4
+#define FL_AUTOSHOW 5
+#define FL_HIDE 6
+
+#define LB_FUNC 1
+#define LB_TYPE 2
+#define LB_BASEFIELD 3
+#define LB_BASEITEM 4
+#define LB_SORT_BY 5
+#define LB_LAYOUT 6
+#define LB_SHOW_FROM 7
+#define LB_SHOW_USING 8
+#define LB_HIERARCHY 9
+#define LB_DIMS 10
+
+#define FT_NAMELABEL 1
+#define FT_NAME 2
+#define FT_TYPE 3
+#define FT_BASEFIELD 4
+#define FT_BASEITEM 5
+#define FT_LAYOUT 6
+#define FT_SHOW 7
+#define FT_SHOW_FROM 8
+#define FT_SHOW_USING 9
+#define FT_HIERARCHY 10
+#define FT_DIMS 11
+
+#define CB_SHOWALL 1
+#define CB_LAYOUT_EMPTY 2
+#define CB_SHOW 3
+
+#define NF_SHOW 1
+
+#define CT_HIDE 1
+
diff --git a/sc/source/ui/dbgui/pvfundlg.src b/sc/source/ui/dbgui/pvfundlg.src
new file mode 100644
index 000000000000..b3ff8cab02bf
--- /dev/null
+++ b/sc/source/ui/dbgui/pvfundlg.src
@@ -0,0 +1,515 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pvfundlg.hrc"
+
+StringArray SCSTR_DPFUNCLISTBOX
+{
+ ItemList [ en-US ] =
+ {
+ < "Sum" ; Default ; > ;
+ < "Count" ; Default ; > ;
+ < "Average" ; Default ; > ;
+ < "Max" ; Default ; > ;
+ < "Min" ; Default ; > ;
+ < "Product" ; Default ; > ;
+ < "Count (Numbers only)" ; Default ; > ;
+ < "StDev (Sample)" ; Default ; > ;
+ < "StDevP (Population)" ; Default ; > ;
+ < "Var (Sample)" ; Default ; > ;
+ < "VarP (Population)" ; Default ; > ;
+ };
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPDATAFIELD
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_DPDATAFIELD ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 220 , 99 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ FixedLine FL_FUNC
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "~Function" ;
+ };
+ MultiListBox LB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 140 , 65 ) ;
+ TabStop = TRUE ;
+ AutoHScroll = TRUE ;
+ SimpleMode = TRUE ;
+ };
+ FixedText FT_NAMELABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 85 ) ;
+ Size = MAP_APPFONT ( 25 , 8 ) ;
+ Text [ en-US ] = "Name:" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 32 , 85 ) ;
+ Size = MAP_APPFONT ( 126 , 8 ) ;
+ };
+ FixedLine FL_DISPLAY
+ {
+ Pos = MAP_APPFONT( 6, 99 );
+ Size = MAP_APPFONT( 152, 8 );
+ Text [ en-US ] = "Displayed value";
+ };
+ FixedText FT_TYPE
+ {
+ Pos = MAP_APPFONT( 12, 112 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~Type";
+ };
+ ListBox LB_TYPE
+ {
+ Pos = MAP_APPFONT( 75, 110 );
+ Size = MAP_APPFONT( 77, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Normal"; Default; >;
+ < "Difference from"; Default; >;
+ < "% of"; Default; >;
+ < "% difference from"; Default; >;
+ < "Running total in"; Default; >;
+ < "% of row"; Default; >;
+ < "% of column"; Default; >;
+ < "% of total"; Default; >;
+ < "Index"; Default; >;
+ };
+ };
+ FixedText FT_BASEFIELD
+ {
+ Pos = MAP_APPFONT( 12, 128 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~Base field";
+ };
+ ListBox LB_BASEFIELD
+ {
+ Pos = MAP_APPFONT( 75, 126 );
+ Size = MAP_APPFONT( 77, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ FixedText FT_BASEITEM
+ {
+ Pos = MAP_APPFONT( 12, 144 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "Ba~se item";
+ };
+ ListBox LB_BASEITEM
+ {
+ Pos = MAP_APPFONT( 75, 142 );
+ Size = MAP_APPFONT( 77, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "- previous item -"; Default; >;
+ < "- next item -"; Default; >;
+ };
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 164 , 79 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 61 ;
+ };
+ Text [ en-US ] = "Data Field" ;
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_PIVOTSUBT
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_PIVOTSUBT ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 220 , 155 ) ;
+ Text [ en-US ] = "Data Field" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ Hide = TRUE ;
+ RadioButton RB_NONE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 140 , 10 ) ;
+ Text [ en-US ] = "~None" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_AUTO
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 140 , 10 ) ;
+ Text [ en-US ] = "~Automatic" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_USER
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 140 , 10 ) ;
+ Text [ en-US ] = "~User-defined" ;
+ TabStop = TRUE ;
+ };
+ MultiListBox LB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 140 , 65 ) ;
+ TabStop = TRUE ;
+ AutoHScroll = TRUE ;
+ SimpleMode = TRUE ;
+ };
+ FixedLine FL_FUNC
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 152 , 8 ) ;
+ Text [ en-US ] = "Subtotals" ;
+ };
+ CheckBox CB_SHOWALL
+ {
+ Pos = MAP_APPFONT ( 6 , 127 ) ;
+ Size = MAP_APPFONT ( 152 , 10 ) ;
+ Text [ en-US ] = "Show it~ems without data";
+ TabStop = TRUE ;
+ };
+ FixedText FT_NAMELABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 141 ) ;
+ Size = MAP_APPFONT ( 25 , 8 ) ;
+ Text [ en-US ] = "Name:" ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 32 , 141 ) ;
+ Size = MAP_APPFONT ( 126 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 164 , 135 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Options...";
+ };
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPSUBTOTAL_OPT
+{
+ OutputSize = TRUE;
+ HelpId = HID_SC_DPSUBT_OPT;
+ SVLook = TRUE;
+ Size = MAP_APPFONT( 266, 240 );
+ Moveable = TRUE;
+ Closeable = FALSE;
+ Hide = TRUE;
+ FixedLine FL_SORT_BY
+ {
+ Pos = MAP_APPFONT( 6, 3 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Sort ~by";
+ };
+ ListBox LB_SORT_BY
+ {
+ Pos = MAP_APPFONT( 12, 26 );
+ Size = MAP_APPFONT( 96, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ RadioButton RB_SORT_ASC
+ {
+ Pos = MAP_APPFONT( 114, 14 );
+ Size = MAP_APPFONT( 84, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Ascending";
+ };
+ RadioButton RB_SORT_DESC
+ {
+ Pos = MAP_APPFONT( 114, 28 );
+ Size = MAP_APPFONT( 84, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Descending";
+ };
+ RadioButton RB_SORT_MAN
+ {
+ Pos = MAP_APPFONT( 114, 42 );
+ Size = MAP_APPFONT( 84, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Manual";
+ };
+ FixedLine FL_LAYOUT
+ {
+ Pos = MAP_APPFONT( 6, 56 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Display options";
+ };
+ FixedText FT_LAYOUT
+ {
+ Pos = MAP_APPFONT( 12, 69 );
+ Size = MAP_APPFONT( 70, 8 );
+ Text [ en-US ] = "~Layout";
+ };
+ ListBox LB_LAYOUT
+ {
+ Pos = MAP_APPFONT( 84, 67 );
+ Size = MAP_APPFONT( 114, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Tabular layout"; Default; >;
+ < "Outline layout with subtotals at the top"; Default; >;
+ < "Outline layout with subtotals at the bottom"; Default; >;
+ };
+ };
+ CheckBox CB_LAYOUT_EMPTY
+ {
+ Pos = MAP_APPFONT( 12, 85 );
+ Size = MAP_APPFONT( 186, 10 );
+ TabStop = TRUE;
+ Text [ en-US ] = "~Empty line after each item";
+ };
+ FixedLine FL_AUTOSHOW
+ {
+ Pos = MAP_APPFONT( 6, 99 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Show automatically";
+ };
+ CheckBox CB_SHOW
+ {
+ Pos = MAP_APPFONT( 12, 112 );
+ Size = MAP_APPFONT( 70, 10 );
+ TabStop = TRUE;
+ Text[ en-US ] = "~Show";
+ };
+ NumericField NF_SHOW
+ {
+ Pos = MAP_APPFONT( 84, 110 );
+ Size = MAP_APPFONT( 30, 12 );
+ TabStop = TRUE;
+ Border = TRUE;
+ Repeat = TRUE;
+ Spin = TRUE;
+ Minimum = 1;
+ Maximum = 999;
+ SpinSize = 1;
+ StrictFormat = TRUE;
+ };
+ FixedText FT_SHOW
+ {
+ Pos = MAP_APPFONT( 118, 112 );
+ Size = MAP_APPFONT( 80, 8 );
+ Text [ en-US ] = "items";
+ };
+ FixedText FT_SHOW_FROM
+ {
+ Pos = MAP_APPFONT( 22, 128 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~From";
+ };
+ ListBox LB_SHOW_FROM
+ {
+ Pos = MAP_APPFONT( 84, 126 );
+ Size = MAP_APPFONT( 114, 50 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Top"; Default; >;
+ < "Bottom"; Default; >;
+ };
+ };
+ FixedText FT_SHOW_USING
+ {
+ Pos = MAP_APPFONT( 22, 144 );
+ Size = MAP_APPFONT( 60, 8 );
+ Text [ en-US ] = "~Using field";
+ };
+ ListBox LB_SHOW_USING
+ {
+ Pos = MAP_APPFONT( 84, 142 );
+ Size = MAP_APPFONT( 114, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ FixedLine FL_HIDE
+ {
+ Pos = MAP_APPFONT( 6, 160 );
+ Size = MAP_APPFONT( 198, 8 );
+ Text [ en-US ] = "Hide i~tems";
+ };
+ Control CT_HIDE
+ {
+ Pos = MAP_APPFONT( 12, 171 );
+ Size = MAP_APPFONT( 186, 45 );
+ TabStop = TRUE;
+ Border = TRUE;
+ };
+ FixedText FT_HIERARCHY
+ {
+ Pos = MAP_APPFONT( 6, 224 );
+ Size = MAP_APPFONT( 76, 8 );
+ Text [ en-US ] = "Hierarch~y";
+ };
+ ListBox LB_HIERARCHY
+ {
+ Pos = MAP_APPFONT( 84, 222 );
+ Size = MAP_APPFONT( 114, 120 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = TRUE;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT( 210, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT( 210, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT( 210, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ Text [ en-US ] = "Data Field Options";
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_DPSHOWDETAIL
+{
+ OutputSize = TRUE;
+ HelpId = HID_SC_DPSHOWDETAIL;
+ SVLook = TRUE;
+ Size = MAP_APPFONT( 200, 116 );
+ Moveable = TRUE;
+ Closeable = FALSE;
+ FixedText FT_DIMS
+ {
+ Pos = MAP_APPFONT( 6, 3 );
+ Size = MAP_APPFONT( 132, 24 );
+ WordBreak = TRUE;
+ Text [ en-US ] = "~Choose the field containing the detail you want to show";
+ };
+ ListBox LB_DIMS
+ {
+ Pos = MAP_APPFONT( 6, 30 );
+ Size = MAP_APPFONT( 132, 80 );
+ TabStop = TRUE;
+ Border = TRUE;
+ DropDown = FALSE;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT( 144, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT( 144, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT( 144, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+ Text [ en-US ] = "Show Detail";
+};
+
+// ----------------------------------------------------------------------------
+
diff --git a/sc/source/ui/dbgui/pvglob.hxx b/sc/source/ui/dbgui/pvglob.hxx
new file mode 100644
index 000000000000..33e192afc4b3
--- /dev/null
+++ b/sc/source/ui/dbgui/pvglob.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PVGLOB_HXX
+#define SC_PVGLOB_HXX
+
+//-------------------------------------------------------------------
+
+class PivotGlobal
+{
+public:
+ static long nObjHeight;
+ static long nObjWidth;
+ static long nSelSpace;
+};
+
+
+#endif // SC_PVGLOB_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/pvlaydlg.cxx b/sc/source/ui/dbgui/pvlaydlg.cxx
new file mode 100644
index 000000000000..9757259181b7
--- /dev/null
+++ b/sc/source/ui/dbgui/pvlaydlg.cxx
@@ -0,0 +1,1871 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "pvlaydlg.hxx"
+#include "dbdocfun.hxx"
+
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+
+#include "uiitems.hxx"
+#include "rangeutl.hxx"
+#include "document.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "reffact.hxx"
+#include "scresid.hxx"
+#include "pvglob.hxx"
+#include "globstr.hrc"
+#include "pivot.hrc"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpshttab.hxx"
+#include "scmod.hxx"
+
+#include "sc.hrc"
+#include "scabstdlg.hxx"
+using namespace com::sun::star;
+using ::rtl::OUString;
+using ::std::vector;
+
+//----------------------------------------------------------------------------
+
+#define FSTR(index) aFuncNameArr[index-1]
+#define STD_FORMAT SCA_VALID | SCA_TAB_3D \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+
+long PivotGlobal::nObjHeight = 0; // initialized with resource data
+long PivotGlobal::nObjWidth = 0;
+long PivotGlobal::nSelSpace = 0;
+
+
+//============================================================================
+
+namespace {
+
+void lcl_FillToPivotField( PivotField& rPivotField, const ScDPFuncData& rFuncData )
+{
+ rPivotField.nCol = rFuncData.mnCol;
+ rPivotField.nFuncMask = rFuncData.mnFuncMask;
+ rPivotField.maFieldRef = rFuncData.maFieldRef;
+}
+
+PointerStyle lclGetPointerForField( ScDPFieldType eType )
+{
+ switch( eType )
+ {
+ case TYPE_PAGE: return POINTER_PIVOT_FIELD;
+ case TYPE_COL: return POINTER_PIVOT_COL;
+ case TYPE_ROW: return POINTER_PIVOT_ROW;
+ case TYPE_DATA: return POINTER_PIVOT_FIELD;
+ case TYPE_SELECT: return POINTER_PIVOT_FIELD;
+ }
+ return POINTER_ARROW;
+}
+
+} // namespace
+
+//============================================================================
+
+//----------------------------------------------------------------------------
+
+ScDPLayoutDlg::ScDPLayoutDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const ScDPObject& rDPObject, bool bNewOutput )
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_PIVOT_LAYOUT ),
+ aFlLayout ( this, ScResId( FL_LAYOUT ) ),
+ aFtPage ( this, ScResId( FT_PAGE ) ),
+ aWndPage ( this, ScResId( WND_PAGE ), TYPE_PAGE, &aFtPage ),
+ aFtCol ( this, ScResId( FT_COL ) ),
+ aWndCol ( this, ScResId( WND_COL ), TYPE_COL, &aFtCol ),
+ aFtRow ( this, ScResId( FT_ROW ) ),
+ aWndRow ( this, ScResId( WND_ROW ), TYPE_ROW, &aFtRow ),
+ aFtData ( this, ScResId( FT_DATA ) ),
+ aWndData ( this, ScResId( WND_DATA ), TYPE_DATA, &aFtData ),
+ aWndSelect ( this, ScResId( WND_SELECT ), TYPE_SELECT, String(ScResId(STR_SELECT)) ),
+ aSlider ( this, ScResId( WND_HSCROLL ) ),
+ aFtInfo ( this, ScResId( FT_INFO ) ),
+
+ aFlAreas ( this, ScResId( FL_OUTPUT ) ),
+
+ aFtInArea ( this, ScResId( FT_INAREA) ),
+ aEdInPos ( this, ScResId( ED_INAREA) ),
+ aRbInPos ( this, ScResId( RB_INAREA ), &aEdInPos, this ),
+
+ aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
+ aFtOutArea ( this, ScResId( FT_OUTAREA ) ),
+ aEdOutPos ( this, this, ScResId( ED_OUTAREA ) ),
+ aRbOutPos ( this, ScResId( RB_OUTAREA ), &aEdOutPos, this ),
+ aBtnIgnEmptyRows( this, ScResId( BTN_IGNEMPTYROWS ) ),
+ aBtnDetectCat ( this, ScResId( BTN_DETECTCAT ) ),
+ aBtnTotalCol ( this, ScResId( BTN_TOTALCOL ) ),
+ aBtnTotalRow ( this, ScResId( BTN_TOTALROW ) ),
+ aBtnFilter ( this, ScResId( BTN_FILTER ) ),
+ aBtnDrillDown ( this, ScResId( BTN_DRILLDOWN ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnOptions ( this, ScResId( BTN_OPTIONS ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrNewTable ( ScResId( SCSTR_NEWTABLE ) ),
+
+ bIsDrag ( FALSE ),
+
+ pEditActive ( NULL ),
+
+ eLastActiveType ( TYPE_SELECT ),
+ nOffset ( 0 ),
+ //
+ xDlgDPObject ( new ScDPObject( rDPObject ) ),
+ pViewData ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData() ),
+ pDoc ( ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData()->GetDocument() ),
+ bRefInputMode ( FALSE )
+{
+ xDlgDPObject->SetAlive( TRUE ); // needed to get structure information
+ xDlgDPObject->FillOldParam( thePivotData, FALSE );
+ xDlgDPObject->FillLabelData( thePivotData );
+
+ Init(bNewOutput);
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScDPLayoutDlg::~ScDPLayoutDlg()
+{
+ USHORT nEntries = aLbOutPos.GetEntryCount();
+ USHORT i;
+
+ for ( i=2; i<nEntries; i++ )
+ delete (String*)aLbOutPos.GetEntryData( i );
+}
+
+
+//----------------------------------------------------------------------------
+
+ScDPFieldWindow& ScDPLayoutDlg::GetFieldWindow( ScDPFieldType eType )
+{
+ switch( eType )
+ {
+ case TYPE_PAGE: return aWndPage;
+ case TYPE_ROW: return aWndRow;
+ case TYPE_COL: return aWndCol;
+ case TYPE_DATA: return aWndData;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return aWndSelect;
+}
+
+void __EXPORT ScDPLayoutDlg::Init(bool bNewOutput)
+{
+ DBG_ASSERT( pViewData && pDoc,
+ "Ctor-Initialisierung fehlgeschlagen!" );
+
+ aBtnRemove.SetClickHdl( LINK( this, ScDPLayoutDlg, ClickHdl ) );
+ aBtnOptions.SetClickHdl( LINK( this, ScDPLayoutDlg, ClickHdl ) );
+
+ aFuncNameArr.reserve( FUNC_COUNT );
+ for ( USHORT i = 0; i < FUNC_COUNT; ++i )
+ aFuncNameArr.push_back( String( ScResId( i + 1 ) ) );
+
+ aBtnMore.AddWindow( &aFlAreas );
+ aBtnMore.AddWindow( &aFtInArea );
+ aBtnMore.AddWindow( &aEdInPos );
+ aBtnMore.AddWindow( &aRbInPos );
+ aBtnMore.AddWindow( &aFtOutArea );
+ aBtnMore.AddWindow( &aLbOutPos );
+ aBtnMore.AddWindow( &aEdOutPos );
+ aBtnMore.AddWindow( &aRbOutPos );
+ aBtnMore.AddWindow( &aBtnIgnEmptyRows );
+ aBtnMore.AddWindow( &aBtnDetectCat );
+ aBtnMore.AddWindow( &aBtnTotalCol );
+ aBtnMore.AddWindow( &aBtnTotalRow );
+ aBtnMore.AddWindow( &aBtnFilter );
+ aBtnMore.AddWindow( &aBtnDrillDown );
+ aBtnMore.SetClickHdl( LINK( this, ScDPLayoutDlg, MoreClickHdl ) );
+
+ {
+ Size aFieldSize( Window( this, ScResId( WND_FIELD ) ).GetSizePixel() );
+ OHEIGHT = aFieldSize.Height();
+ OWIDTH = aFieldSize.Width();
+ }
+ SSPACE = Window( this, ScResId( WND_FIELD_SPACE ) ).GetSizePixel().Width();
+
+ CalcWndSizes();
+
+ aSelectArr.resize( MAX_LABELS );
+ aPageArr.resize( MAX_PAGEFIELDS );
+ aColArr.resize( MAX_FIELDS );
+ aRowArr.resize( MAX_FIELDS );
+ aDataArr.resize( MAX_FIELDS );
+
+ ScRange inRange;
+ String inString;
+ if (xDlgDPObject->GetSheetDesc())
+ {
+ aEdInPos.Enable();
+ aRbInPos.Enable();
+ aOldRange = xDlgDPObject->GetSheetDesc()->aSourceRange;
+ aOldRange.Format( inString, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdInPos.SetText(inString);
+ }
+ else
+ {
+ /* Data is not reachable, so could be a remote database */
+ aEdInPos.Disable();
+ aRbInPos.Disable();
+ }
+
+ InitFields();
+
+ aLbOutPos .SetSelectHdl( LINK( this, ScDPLayoutDlg, SelAreaHdl ) );
+ aEdOutPos .SetModifyHdl( LINK( this, ScDPLayoutDlg, EdModifyHdl ) );
+ aEdInPos .SetModifyHdl( LINK( this, ScDPLayoutDlg, EdInModifyHdl ) );
+ aBtnOk .SetClickHdl ( LINK( this, ScDPLayoutDlg, OkHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScDPLayoutDlg, CancelHdl ) );
+ Link aLink = LINK( this, ScDPLayoutDlg, GetFocusHdl );
+ if ( aEdInPos.IsEnabled() )
+ // Once disabled it will never get enabled, so no need to handle focus.
+ aEdInPos.SetGetFocusHdl( aLink );
+ aEdOutPos.SetGetFocusHdl( aLink );
+
+ if ( pViewData && pDoc )
+ {
+ /*
+ * Aus den RangeNames des Dokumentes werden nun die
+ * in einem Zeiger-Array gemerkt, bei denen es sich
+ * um sinnvolle Bereiche handelt
+ */
+
+ aLbOutPos.Clear();
+ aLbOutPos.InsertEntry( aStrUndefined, 0 );
+ aLbOutPos.InsertEntry( aStrNewTable, 1 );
+
+ ScAreaNameIterator aIter( pDoc );
+ String aName;
+ ScRange aRange;
+ String aRefStr;
+ while ( aIter.Next( aName, aRange ) )
+ {
+ if ( !aIter.WasDBName() ) // hier keine DB-Bereiche !
+ {
+ USHORT nInsert = aLbOutPos.InsertEntry( aName );
+
+ aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
+ }
+ }
+ }
+
+ if (bNewOutput)
+ {
+ // Output to a new sheet by default for a brand-new output.
+ aLbOutPos.SelectEntryPos(1);
+ aEdOutPos.Disable();
+ aRbOutPos.Disable();
+ }
+ else
+ {
+ // Modifying an existing dp output.
+
+ if ( thePivotData.nTab != MAXTAB+1 )
+ {
+ String aStr;
+ ScAddress( thePivotData.nCol,
+ thePivotData.nRow,
+ thePivotData.nTab ).Format( aStr, STD_FORMAT, pDoc, pDoc->GetAddressConvention() );
+ aEdOutPos.SetText( aStr );
+ EdModifyHdl(0);
+ }
+ else
+ {
+ aLbOutPos.SelectEntryPos( aLbOutPos.GetEntryCount()-1 );
+ SelAreaHdl(NULL);
+ }
+ }
+
+ aBtnIgnEmptyRows.Check( thePivotData.bIgnoreEmptyRows );
+ aBtnDetectCat .Check( thePivotData.bDetectCategories );
+ aBtnTotalCol .Check( thePivotData.bMakeTotalCol );
+ aBtnTotalRow .Check( thePivotData.bMakeTotalRow );
+
+ if( const ScDPSaveData* pSaveData = xDlgDPObject->GetSaveData() )
+ {
+ aBtnFilter.Check( pSaveData->GetFilterButton() );
+ aBtnDrillDown.Check( pSaveData->GetDrillDown() );
+ }
+ else
+ {
+ aBtnFilter.Check();
+ aBtnDrillDown.Check();
+ }
+
+ aWndPage.SetHelpId( HID_SC_DPLAY_PAGE );
+ aWndCol.SetHelpId( HID_SC_DPLAY_COLUMN );
+ aWndRow.SetHelpId( HID_SC_DPLAY_ROW );
+ aWndData.SetHelpId( HID_SC_DPLAY_DATA );
+ aWndSelect.SetHelpId( HID_SC_DPLAY_SELECT );
+
+ InitFocus();
+
+// SetDispatcherLock( TRUE ); // Modal-Modus einschalten
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScDPLayoutDlg::Close()
+{
+ return DoClose( ScPivotLayoutWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::StateChanged( StateChangedType nStateChange )
+{
+ ScAnyRefDlg::StateChanged( nStateChange );
+
+ if ( nStateChange == STATE_CHANGE_INITSHOW )
+ {
+ // #124828# Hiding the FixedTexts and clearing the tab stop style bits
+ // has to be done after assigning the mnemonics, but Paint is too late,
+ // because the test tool may send key events to the dialog when it isn't visible.
+ // Mnemonics are assigned in the Dialog::StateChanged for STATE_CHANGE_INITSHOW,
+ // so this can be done immediately afterwards.
+
+ aWndPage.UseMnemonic();
+ aWndCol.UseMnemonic();
+ aWndRow.UseMnemonic();
+ aWndData.UseMnemonic();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::InitWndSelect( const vector<ScDPLabelDataRef>& rLabels )
+{
+ size_t nLabelCount = rLabels.size();
+ if (nLabelCount > MAX_LABELS)
+ nLabelCount = MAX_LABELS;
+ size_t nLast = (nLabelCount > PAGE_SIZE) ? (PAGE_SIZE - 1) : (nLabelCount - 1);
+
+ aLabelDataArr.clear();
+ aLabelDataArr.reserve( nLabelCount );
+ for ( size_t i=0; i < nLabelCount; i++ )
+ {
+ aLabelDataArr.push_back(*rLabels[i]);
+
+ if ( i <= nLast )
+ {
+ aWndSelect.AddField(aLabelDataArr[i].getDisplayName(), i);
+ aSelectArr[i].reset( new ScDPFuncData( aLabelDataArr[i].mnCol, aLabelDataArr[i].mnFuncMask ) );
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::InitWnd( PivotField* pArr, long nCount, ScDPFieldType eType )
+{
+ if ( pArr && (eType != TYPE_SELECT) )
+ {
+ ScDPFuncDataVec* pInitArr = NULL;
+ ScDPFieldWindow* pInitWnd = NULL;
+ BOOL bDataArr = FALSE;
+
+ switch ( eType )
+ {
+ case TYPE_PAGE:
+ pInitArr = &aPageArr;
+ pInitWnd = &aWndPage;
+ break;
+
+ case TYPE_COL:
+ pInitArr = &aColArr;
+ pInitWnd = &aWndCol;
+ break;
+
+ case TYPE_ROW:
+ pInitArr = &aRowArr;
+ pInitWnd = &aWndRow;
+ break;
+
+ case TYPE_DATA:
+ pInitArr = &aDataArr;
+ pInitWnd = &aWndData;
+ bDataArr = TRUE;
+ break;
+ default:
+ break;
+ }
+
+ if ( pInitArr && pInitWnd )
+ {
+ long j=0;
+ for ( long i=0; (i<nCount); i++ )
+ {
+ SCCOL nCol = pArr[i].nCol;
+ USHORT nMask = pArr[i].nFuncMask;
+
+ if ( nCol != PIVOT_DATA_FIELD )
+ {
+ (*pInitArr)[j].reset( new ScDPFuncData( nCol, nMask, pArr[i].maFieldRef ) );
+
+ if ( !bDataArr )
+ {
+ pInitWnd->AddField( GetLabelString( nCol ), j );
+ }
+ else
+ {
+ ScDPLabelData* pData = GetLabelData( nCol );
+ DBG_ASSERT( pData, "ScDPLabelData not found" );
+ if (pData)
+ {
+ OUString aStr = pData->maLayoutName;
+ if (!aStr.getLength())
+ {
+ USHORT nInitMask = (*pInitArr)[j]->mnFuncMask;
+ aStr = GetFuncString(nInitMask, pData->mbIsValue);
+ aStr += pData->maName;
+ }
+
+ pInitWnd->AddField( aStr, j );
+
+ pData->mnFuncMask = nMask;
+ }
+ }
+ ++j;
+ }
+ }
+// Do not redraw here -> first the FixedText has to get its mnemonic char
+// pInitWnd->Redraw();
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::InitFocus()
+{
+ if( aWndSelect.IsEmpty() )
+ {
+ aBtnOk.GrabFocus();
+ NotifyFieldFocus( TYPE_SELECT, FALSE );
+ }
+ else
+ aWndSelect.GrabFocus();
+}
+
+void ScDPLayoutDlg::InitFields()
+{
+ InitWndSelect(thePivotData.maLabelArray);
+ InitWnd( thePivotData.aPageArr, static_cast<long>(thePivotData.nPageCount), TYPE_PAGE );
+ InitWnd( thePivotData.aColArr, static_cast<long>(thePivotData.nColCount), TYPE_COL );
+ InitWnd( thePivotData.aRowArr, static_cast<long>(thePivotData.nRowCount), TYPE_ROW );
+ InitWnd( thePivotData.aDataArr, static_cast<long>(thePivotData.nDataCount), TYPE_DATA );
+
+ size_t nLabels = thePivotData.maLabelArray.size();
+ aSlider.SetPageSize( PAGE_SIZE );
+ aSlider.SetVisibleSize( PAGE_SIZE );
+ aSlider.SetLineSize( LINE_SIZE );
+ aSlider.SetRange( Range( 0, static_cast<long>(((nLabels+LINE_SIZE-1)/LINE_SIZE)*LINE_SIZE) ) );
+
+ if ( nLabels > PAGE_SIZE )
+ {
+ aSlider.SetEndScrollHdl( LINK( this, ScDPLayoutDlg, ScrollHdl ) );
+ aSlider.Show();
+ }
+ else
+ aSlider.Hide();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::AddField( size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
+{
+ ScDPFuncData fData( *(aSelectArr[nFromIndex]) );
+ size_t nAt = 0;
+ ScDPFieldWindow* toWnd = NULL;
+ ScDPFieldWindow* rmWnd1 = NULL;
+ ScDPFieldWindow* rmWnd2 = NULL;
+ ScDPFuncDataVec* toArr = NULL;
+ ScDPFuncDataVec* rmArr1 = NULL;
+ ScDPFuncDataVec* rmArr2 = NULL;
+ BOOL bDataArr = FALSE;
+
+ switch ( eToType )
+ {
+ case TYPE_PAGE:
+ toWnd = &aWndPage;
+ rmWnd1 = &aWndRow;
+ rmWnd2 = &aWndCol;
+ toArr = &aPageArr;
+ rmArr1 = &aRowArr;
+ rmArr2 = &aColArr;
+ break;
+
+ case TYPE_COL:
+ toWnd = &aWndCol;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndRow;
+ toArr = &aColArr;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aRowArr;
+ break;
+
+ case TYPE_ROW:
+ toWnd = &aWndRow;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndCol;
+ toArr = &aRowArr;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aColArr;
+ break;
+
+ case TYPE_DATA:
+ toWnd = &aWndData;
+ toArr = &aDataArr;
+ bDataArr = TRUE;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
+ if ( bAllowed
+ && (toArr->back().get() == NULL)
+ && (!Contains( toArr, fData.mnCol, nAt )) )
+ {
+ // ggF. in anderem Fenster entfernen
+ if ( rmArr1 )
+ {
+ if ( Contains( rmArr1, fData.mnCol, nAt ) )
+ {
+ rmWnd1->DelField( nAt );
+ Remove( rmArr1, nAt );
+ }
+ }
+ if ( rmArr2 )
+ {
+ if ( Contains( rmArr2, fData.mnCol, nAt ) )
+ {
+ rmWnd2->DelField( nAt );
+ Remove( rmArr2, nAt );
+ }
+ }
+
+ ScDPLabelData& rData = aLabelDataArr[nFromIndex+nOffset];
+ size_t nAddedAt = 0;
+
+ if ( !bDataArr )
+ {
+ if ( toWnd->AddField( rData.getDisplayName(),
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+ else
+ {
+ ScDPLabelData* p = GetLabelData(fData.mnCol);
+ OUString aStr = p->maLayoutName;
+ USHORT nMask = fData.mnFuncMask;
+ if (!aStr.getLength())
+ {
+ aStr = GetFuncString(nMask);
+ aStr += p->maName;
+ }
+
+ if ( toWnd->AddField( aStr,
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ fData.mnFuncMask = nMask;
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::MoveField( ScDPFieldType eFromType, size_t nFromIndex, ScDPFieldType eToType, const Point& rAtPos )
+{
+ if ( eFromType == TYPE_SELECT )
+ AddField( nFromIndex, eToType, rAtPos );
+ else if ( eFromType != eToType )
+ {
+ ScDPFieldWindow* fromWnd = NULL;
+ ScDPFieldWindow* toWnd = NULL;
+ ScDPFieldWindow* rmWnd1 = NULL;
+ ScDPFieldWindow* rmWnd2 = NULL;
+ ScDPFuncDataVec* fromArr = NULL;
+ ScDPFuncDataVec* toArr = NULL;
+ ScDPFuncDataVec* rmArr1 = NULL;
+ ScDPFuncDataVec* rmArr2 = NULL;
+ size_t nAt = 0;
+ BOOL bDataArr = FALSE;
+
+ switch ( eFromType )
+ {
+ case TYPE_PAGE:
+ fromWnd = &aWndPage;
+ fromArr = &aPageArr;
+ break;
+
+ case TYPE_COL:
+ fromWnd = &aWndCol;
+ fromArr = &aColArr;
+ break;
+
+ case TYPE_ROW:
+ fromWnd = &aWndRow;
+ fromArr = &aRowArr;
+ break;
+
+ case TYPE_DATA:
+ fromWnd = &aWndData;
+ fromArr = &aDataArr;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ switch ( eToType )
+ {
+ case TYPE_PAGE:
+ toWnd = &aWndPage;
+ toArr = &aPageArr;
+ rmWnd1 = &aWndCol;
+ rmWnd2 = &aWndRow;
+ rmArr1 = &aColArr;
+ rmArr2 = &aRowArr;
+ break;
+
+ case TYPE_COL:
+ toWnd = &aWndCol;
+ toArr = &aColArr;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndRow;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aRowArr;
+ break;
+
+ case TYPE_ROW:
+ toWnd = &aWndRow;
+ toArr = &aRowArr;
+ rmWnd1 = &aWndPage;
+ rmWnd2 = &aWndCol;
+ rmArr1 = &aPageArr;
+ rmArr2 = &aColArr;
+ break;
+
+ case TYPE_DATA:
+ toWnd = &aWndData;
+ toArr = &aDataArr;
+ bDataArr = TRUE;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if ( fromArr && toArr && fromWnd && toWnd )
+ {
+ ScDPFuncData fData( *((*fromArr)[nFromIndex]) );
+
+ bool bAllowed = IsOrientationAllowed( fData.mnCol, eToType );
+ if ( bAllowed && Contains( fromArr, fData.mnCol, nAt ) )
+ {
+ fromWnd->DelField( nAt );
+ Remove( fromArr, nAt );
+
+ if ( (toArr->back().get() == NULL)
+ && (!Contains( toArr, fData.mnCol, nAt )) )
+ {
+ size_t nAddedAt = 0;
+ if ( !bDataArr )
+ {
+ // ggF. in anderem Fenster entfernen
+ if ( rmArr1 )
+ {
+ if ( Contains( rmArr1, fData.mnCol, nAt ) )
+ {
+ rmWnd1->DelField( nAt );
+ Remove( rmArr1, nAt );
+ }
+ }
+ if ( rmArr2 )
+ {
+ if ( Contains( rmArr2, fData.mnCol, nAt ) )
+ {
+ rmWnd2->DelField( nAt );
+ Remove( rmArr2, nAt );
+ }
+ }
+
+ if ( toWnd->AddField( GetLabelString( fData.mnCol ),
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+ else
+ {
+ ScDPLabelData* p = GetLabelData(fData.mnCol);
+ OUString aStr = p->maLayoutName;
+ USHORT nMask = fData.mnFuncMask;
+ if (!aStr.getLength())
+ {
+ aStr = GetFuncString(nMask);
+ aStr += p->maName;
+ }
+
+ if ( toWnd->AddField( aStr,
+ DlgPos2WndPos( rAtPos, *toWnd ),
+ nAddedAt ) )
+ {
+ fData.mnFuncMask = nMask;
+ Insert( toArr, fData, nAddedAt );
+ toWnd->GrabFocus();
+ }
+ }
+ }
+ }
+ }
+ }
+ else // -> eFromType == eToType
+ {
+ ScDPFieldWindow* theWnd = NULL;
+ ScDPFuncDataVec* theArr = NULL;
+ size_t nAt = 0;
+ size_t nToIndex = 0;
+ Point aToPos;
+ BOOL bDataArr = FALSE;
+
+ switch ( eFromType )
+ {
+ case TYPE_PAGE:
+ theWnd = &aWndPage;
+ theArr = &aPageArr;
+ break;
+
+ case TYPE_COL:
+ theWnd = &aWndCol;
+ theArr = &aColArr;
+ break;
+
+ case TYPE_ROW:
+ theWnd = &aWndRow;
+ theArr = &aRowArr;
+ break;
+
+ case TYPE_DATA:
+ theWnd = &aWndData;
+ theArr = &aDataArr;
+ bDataArr = TRUE;
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ ScDPFuncData fData( *((*theArr)[nFromIndex]) );
+
+ if ( Contains( theArr, fData.mnCol, nAt ) )
+ {
+ aToPos = DlgPos2WndPos( rAtPos, *theWnd );
+ theWnd->GetExistingIndex( aToPos, nToIndex );
+
+ if ( nToIndex != nAt )
+ {
+ size_t nAddedAt = 0;
+
+ theWnd->DelField( nAt );
+ Remove( theArr, nAt );
+
+ if ( !bDataArr )
+ {
+ if ( theWnd->AddField( GetLabelString( fData.mnCol ),
+ aToPos,
+ nAddedAt ) )
+ {
+ Insert( theArr, fData, nAddedAt );
+ }
+ }
+ else
+ {
+ ScDPLabelData* p = GetLabelData(fData.mnCol);
+ OUString aStr = p->maLayoutName;
+ USHORT nMask = fData.mnFuncMask;
+ if (!aStr.getLength())
+ {
+ aStr = GetFuncString(nMask);
+ aStr += p->maName;
+ }
+
+ if ( theWnd->AddField( aStr,
+ DlgPos2WndPos( rAtPos, *theWnd ),
+ nAddedAt ) )
+ {
+ fData.mnFuncMask = nMask;
+ Insert( theArr, fData, nAddedAt );
+ }
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::RemoveField( ScDPFieldType eFromType, size_t nIndex )
+{
+ ScDPFuncDataVec* pArr = NULL;
+ switch( eFromType )
+ {
+ case TYPE_PAGE: pArr = &aPageArr; break;
+ case TYPE_COL: pArr = &aColArr; break;
+ case TYPE_ROW: pArr = &aRowArr; break;
+ case TYPE_DATA: pArr = &aDataArr; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if( pArr )
+ {
+ ScDPFieldWindow& rWnd = GetFieldWindow( eFromType );
+ rWnd.DelField( nIndex );
+ Remove( pArr, nIndex );
+ if( rWnd.IsEmpty() ) InitFocus();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyMouseButtonUp( const Point& rAt )
+{
+ if ( bIsDrag )
+ {
+ bIsDrag = FALSE;
+
+ ScDPFieldType eDnDToType = TYPE_SELECT;
+ Point aPos = ScreenToOutputPixel( rAt );
+ BOOL bDel = FALSE;
+
+ if ( aRectPage.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_PAGE;
+ bDel = FALSE;
+ }
+ else if ( aRectCol.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_COL;
+ bDel = FALSE;
+ }
+ else if ( aRectRow.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_ROW;
+ bDel = FALSE;
+ }
+ else if ( aRectData.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_DATA;
+ bDel = FALSE;
+ }
+ else if ( aRectSelect.IsInside( aPos ) )
+ {
+ eDnDToType = TYPE_SELECT;
+ bDel = TRUE;
+ }
+ else
+ bDel = TRUE;
+
+ if ( bDel )
+ RemoveField( eDnDFromType, nDnDFromIndex );
+ else
+ MoveField( eDnDFromType, nDnDFromIndex, eDnDToType, aPos );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+PointerStyle ScDPLayoutDlg::NotifyMouseMove( const Point& rAt )
+{
+ PointerStyle ePtr = POINTER_ARROW;
+
+ if ( bIsDrag )
+ {
+ Point aPos = ScreenToOutputPixel( rAt );
+ ScDPFieldType eCheckTarget = TYPE_SELECT;
+
+ if ( aRectPage.IsInside( aPos ) )
+ eCheckTarget = TYPE_PAGE;
+ else if ( aRectCol.IsInside( aPos ) )
+ eCheckTarget = TYPE_COL;
+ else if ( aRectRow.IsInside( aPos ) )
+ eCheckTarget = TYPE_ROW;
+ else if ( aRectData.IsInside( aPos ) )
+ eCheckTarget = TYPE_DATA;
+ else if ( eDnDFromType != TYPE_SELECT )
+ ePtr = POINTER_PIVOT_DELETE;
+ else if ( aRectSelect.IsInside( aPos ) )
+ ePtr = lclGetPointerForField( TYPE_SELECT );
+ else
+ ePtr = POINTER_NOTALLOWED;
+
+ if ( eCheckTarget != TYPE_SELECT )
+ {
+ // check if the target orientation is allowed for this field
+ ScDPFuncDataVec* fromArr = NULL;
+ switch ( eDnDFromType )
+ {
+ case TYPE_PAGE: fromArr = &aPageArr; break;
+ case TYPE_COL: fromArr = &aColArr; break;
+ case TYPE_ROW: fromArr = &aRowArr; break;
+ case TYPE_DATA: fromArr = &aDataArr; break;
+ case TYPE_SELECT: fromArr = &aSelectArr; break;
+ }
+ ScDPFuncData fData( *((*fromArr)[nDnDFromIndex]) );
+ if (IsOrientationAllowed( fData.mnCol, eCheckTarget ))
+ ePtr = lclGetPointerForField( eCheckTarget );
+ else
+ ePtr = POINTER_NOTALLOWED;
+ }
+ }
+
+ return ePtr;
+}
+
+
+//----------------------------------------------------------------------------
+
+PointerStyle ScDPLayoutDlg::NotifyMouseButtonDown( ScDPFieldType eType, size_t nFieldIndex )
+{
+ bIsDrag = TRUE;
+ eDnDFromType = eType;
+ nDnDFromIndex = nFieldIndex;
+ return lclGetPointerForField( eType );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyDoubleClick( ScDPFieldType eType, size_t nFieldIndex )
+{
+ ScDPFuncDataVec* pArr = NULL;
+ switch ( eType )
+ {
+ case TYPE_PAGE: pArr = &aPageArr; break;
+ case TYPE_COL: pArr = &aColArr; break;
+ case TYPE_ROW: pArr = &aRowArr; break;
+ case TYPE_DATA: pArr = &aDataArr; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if ( pArr )
+ {
+ if ( nFieldIndex >= pArr->size() )
+ {
+ DBG_ERROR("invalid selection");
+ return;
+ }
+
+ size_t nArrPos = 0;
+ if( ScDPLabelData* pData = GetLabelData( (*pArr)[nFieldIndex]->mnCol, &nArrPos ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ switch ( eType )
+ {
+ case TYPE_PAGE:
+ case TYPE_COL:
+ case TYPE_ROW:
+ {
+ // list of names of all data fields
+ vector<ScDPName> aDataFieldNames;
+ for( ScDPFuncDataVec::const_iterator aIt = aDataArr.begin(), aEnd = aDataArr.end();
+ (aIt != aEnd) && aIt->get(); ++aIt )
+ {
+ ScDPLabelData* pDFData = GetLabelData((*aIt)->mnCol);
+ if (!pDFData)
+ continue;
+
+ if (!pDFData->maName.getLength())
+ continue;
+
+ OUString aLayoutName = pDFData->maLayoutName;
+ if (!aLayoutName.getLength())
+ {
+ // No layout name exists. Use the stock name.
+ USHORT nMask = (*aIt)->mnFuncMask;
+ OUString aFuncStr = GetFuncString(nMask);
+ aLayoutName = aFuncStr + pDFData->maName;
+ }
+ aDataFieldNames.push_back(ScDPName(pDFData->maName, aLayoutName));
+ }
+
+ bool bLayout = (eType == TYPE_ROW) &&
+ ((aDataFieldNames.size() > 1) || ((nFieldIndex + 1 < pArr->size()) && (*pArr)[nFieldIndex+1].get()));
+
+ AbstractScDPSubtotalDlg* pDlg = pFact->CreateScDPSubtotalDlg(
+ this, RID_SCDLG_PIVOTSUBT,
+ *xDlgDPObject, *pData, *(*pArr)[nFieldIndex], aDataFieldNames, bLayout );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ pDlg->FillLabelData( *pData );
+ (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask;
+ }
+ delete pDlg;
+ }
+ break;
+
+ case TYPE_DATA:
+ {
+ AbstractScDPFunctionDlg* pDlg = pFact->CreateScDPFunctionDlg(
+ this, RID_SCDLG_DPDATAFIELD,
+ aLabelDataArr, *pData, *(*pArr)[nFieldIndex] );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ (*pArr)[nFieldIndex]->mnFuncMask = pData->mnFuncMask = pDlg->GetFuncMask();
+ (*pArr)[nFieldIndex]->maFieldRef = pDlg->GetFieldRef();
+
+ ScDPLabelData* p = GetLabelData(aDataArr[nFieldIndex]->mnCol);
+ OUString aStr = p->maLayoutName;
+ if (!aStr.getLength())
+ {
+ // Layout name is not available. Use default name.
+ aStr = GetFuncString (aDataArr[nFieldIndex]->mnFuncMask);
+ aStr += p->maName;
+ }
+ aWndData.SetFieldText( aStr, nFieldIndex );
+ }
+ delete pDlg;
+ }
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyFieldFocus( ScDPFieldType eType, BOOL bGotFocus )
+{
+ /* Enable Remove/Options buttons on GetFocus in field window.
+ #107616# Enable them also, if dialog is deactivated (click into document).
+ The !IsActive() condition handles the case that a LoseFocus event of a
+ field window would follow the Deactivate event of this dialog. */
+ BOOL bEnable = (bGotFocus || !IsActive()) && (eType != TYPE_SELECT);
+
+ // #128113# The TestTool may set the focus into an empty field.
+ // Then the Remove/Options buttons must be disabled.
+ if ( bEnable && bGotFocus && GetFieldWindow( eType ).IsEmpty() )
+ bEnable = FALSE;
+
+ aBtnRemove.Enable( bEnable );
+ aBtnOptions.Enable( bEnable );
+ if( bGotFocus )
+ eLastActiveType = eType;
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyMoveField( ScDPFieldType eToType )
+{
+ ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
+ if( (eToType != TYPE_SELECT) && !rWnd.IsEmpty() )
+ {
+ MoveField( eLastActiveType, rWnd.GetSelectedField(), eToType, GetFieldWindow( eToType ).GetLastPosition() );
+ if( rWnd.IsEmpty() )
+ NotifyFieldFocus( eToType, TRUE );
+ else
+ rWnd.GrabFocus();
+ if( eLastActiveType == TYPE_SELECT )
+ aWndSelect.SelectNext();
+ }
+ else
+ InitFocus();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::NotifyRemoveField( ScDPFieldType eType, size_t nFieldIndex )
+{
+ if( eType != TYPE_SELECT )
+ RemoveField( eType, nFieldIndex );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScDPLayoutDlg::NotifyMoveSlider( USHORT nKeyCode )
+{
+ long nOldPos = aSlider.GetThumbPos();
+ switch( nKeyCode )
+ {
+ case KEY_HOME: aSlider.DoScroll( 0 ); break;
+ case KEY_END: aSlider.DoScroll( aSlider.GetRangeMax() ); break;
+ case KEY_UP:
+ case KEY_LEFT: aSlider.DoScrollAction( SCROLL_LINEUP ); break;
+ case KEY_DOWN:
+ case KEY_RIGHT: aSlider.DoScrollAction( SCROLL_LINEDOWN ); break;
+ }
+ return nOldPos != aSlider.GetThumbPos();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::Deactivate()
+{
+ /* #107616# If the dialog has been deactivated (click into document), the LoseFocus
+ event from field window disables Remove/Options buttons. Re-enable them here by
+ simulating a GetFocus event. Event order of LoseFocus and Deactivate is not important.
+ The last event will enable the buttons in both cases (see NotifyFieldFocus). */
+ NotifyFieldFocus( eLastActiveType, TRUE );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScDPLayoutDlg::Contains( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt )
+{
+ if ( !pArr )
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ size_t i = 0;
+
+ while ( (i<pArr->size()) && ((*pArr)[i].get() != NULL) && !bFound )
+ {
+ bFound = ((*pArr)[i]->mnCol == nCol);
+ if ( bFound )
+ nAt = i;
+ i++;
+ }
+
+ return bFound;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::Remove( ScDPFuncDataVec* pArr, size_t nAt )
+{
+ if ( !pArr || (nAt>=pArr->size()) )
+ return;
+
+ pArr->erase( pArr->begin() + nAt );
+ pArr->push_back( ScDPFuncDataRef() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::Insert( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, size_t nAt )
+{
+ if ( !pArr || (nAt>=pArr->size()) )
+ return;
+
+ if ( (*pArr)[nAt].get() == NULL )
+ {
+ (*pArr)[nAt].reset( new ScDPFuncData( rFData ) );
+ }
+ else
+ {
+ if ( pArr->back().get() == NULL ) // mind. ein Slot frei?
+ {
+ pArr->insert( pArr->begin() + nAt, ScDPFuncDataRef( new ScDPFuncData( rFData ) ) );
+ pArr->erase( pArr->end() - 1 );
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+ScDPLabelData* ScDPLayoutDlg::GetLabelData( SCsCOL nCol, size_t* pnPos )
+{
+ ScDPLabelData* pData = 0;
+ for( ScDPLabelDataVec::iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); !pData && (aIt != aEnd); ++aIt )
+ {
+ if( aIt->mnCol == nCol )
+ {
+ pData = &*aIt;
+ if( pnPos ) *pnPos = aIt - aLabelDataArr.begin();
+ }
+ }
+ return pData;
+}
+
+
+//----------------------------------------------------------------------------
+
+String ScDPLayoutDlg::GetLabelString( SCsCOL nCol )
+{
+ ScDPLabelData* pData = GetLabelData( nCol );
+ DBG_ASSERT( pData, "LabelData not found" );
+ if (pData)
+ return pData->getDisplayName();
+ return String();
+}
+
+//----------------------------------------------------------------------------
+
+bool ScDPLayoutDlg::IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType )
+{
+ bool bAllowed = true;
+ ScDPLabelData* pData = GetLabelData( nCol );
+ DBG_ASSERT( pData, "LabelData not found" );
+ if (pData)
+ {
+ sheet::DataPilotFieldOrientation eOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+ switch (eType)
+ {
+ case TYPE_PAGE: eOrient = sheet::DataPilotFieldOrientation_PAGE; break;
+ case TYPE_COL: eOrient = sheet::DataPilotFieldOrientation_COLUMN; break;
+ case TYPE_ROW: eOrient = sheet::DataPilotFieldOrientation_ROW; break;
+ case TYPE_DATA: eOrient = sheet::DataPilotFieldOrientation_DATA; break;
+ case TYPE_SELECT: eOrient = sheet::DataPilotFieldOrientation_HIDDEN; break;
+ }
+ bAllowed = ScDPObject::IsOrientationAllowed( (USHORT)eOrient, pData->mnFlags );
+ }
+ return bAllowed;
+}
+
+//----------------------------------------------------------------------------
+
+String ScDPLayoutDlg::GetFuncString( USHORT& rFuncMask, BOOL bIsValue )
+{
+ String aStr;
+
+ if ( rFuncMask == PIVOT_FUNC_NONE
+ || rFuncMask == PIVOT_FUNC_AUTO )
+ {
+ if ( bIsValue )
+ {
+ aStr = FSTR(PIVOTSTR_SUM);
+ rFuncMask = PIVOT_FUNC_SUM;
+ }
+ else
+ {
+ aStr = FSTR(PIVOTSTR_COUNT);
+ rFuncMask = PIVOT_FUNC_COUNT;
+ }
+ }
+ else if ( rFuncMask == PIVOT_FUNC_SUM ) aStr = FSTR(PIVOTSTR_SUM);
+ else if ( rFuncMask == PIVOT_FUNC_COUNT ) aStr = FSTR(PIVOTSTR_COUNT);
+ else if ( rFuncMask == PIVOT_FUNC_AVERAGE ) aStr = FSTR(PIVOTSTR_AVG);
+ else if ( rFuncMask == PIVOT_FUNC_MAX ) aStr = FSTR(PIVOTSTR_MAX);
+ else if ( rFuncMask == PIVOT_FUNC_MIN ) aStr = FSTR(PIVOTSTR_MIN);
+ else if ( rFuncMask == PIVOT_FUNC_PRODUCT ) aStr = FSTR(PIVOTSTR_PROD);
+ else if ( rFuncMask == PIVOT_FUNC_COUNT_NUM ) aStr = FSTR(PIVOTSTR_COUNT2);
+ else if ( rFuncMask == PIVOT_FUNC_STD_DEV ) aStr = FSTR(PIVOTSTR_DEV);
+ else if ( rFuncMask == PIVOT_FUNC_STD_DEVP ) aStr = FSTR(PIVOTSTR_DEV2);
+ else if ( rFuncMask == PIVOT_FUNC_STD_VAR ) aStr = FSTR(PIVOTSTR_VAR);
+ else if ( rFuncMask == PIVOT_FUNC_STD_VARP ) aStr = FSTR(PIVOTSTR_VAR2);
+ else
+ {
+ aStr = ScGlobal::GetRscString( STR_TABLE_ERGEBNIS );
+ aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " ));
+ }
+
+ return aStr;
+}
+
+
+//----------------------------------------------------------------------------
+
+Point ScDPLayoutDlg::DlgPos2WndPos( const Point& rPt, Window& rWnd )
+{
+ Point aWndPt( rPt );
+ aWndPt.X() = rPt.X()-rWnd.GetPosPixel().X();
+ aWndPt.Y() = rPt.Y()-rWnd.GetPosPixel().Y();
+
+ return aWndPt;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::CalcWndSizes()
+{
+ // row/column/data area sizes
+ aWndPage.SetSizePixel( Size( MAX_PAGEFIELDS * OWIDTH / 2, 2 * OHEIGHT ) );
+ aWndRow.SetSizePixel( Size( OWIDTH, MAX_FIELDS * OHEIGHT ) );
+ aWndCol.SetSizePixel( Size( MAX_FIELDS * OWIDTH / 2, 2 * OHEIGHT ) );
+ aWndData.SetSizePixel( Size( MAX_FIELDS * OWIDTH / 2, MAX_FIELDS * OHEIGHT ) );
+
+ // #i29203# align right border of page window with data window
+ long nDataPosX = aWndData.GetPosPixel().X() + aWndData.GetSizePixel().Width();
+ aWndPage.SetPosPixel( Point( nDataPosX - aWndPage.GetSizePixel().Width(), aWndPage.GetPosPixel().Y() ) );
+
+ // selection area
+ aWndSelect.SetSizePixel( Size(
+ 2 * OWIDTH + SSPACE, LINE_SIZE * OHEIGHT + (LINE_SIZE - 1) * SSPACE ) );
+
+ // scroll bar
+ Point aSliderPos( aWndSelect.GetPosPixel() );
+ Size aSliderSize( aWndSelect.GetSizePixel() );
+ aSliderPos.Y() += aSliderSize.Height() + SSPACE;
+ aSliderSize.Height() = GetSettings().GetStyleSettings().GetScrollBarSize();
+ aSlider.SetPosSizePixel( aSliderPos, aSliderSize );
+
+ aRectPage = Rectangle( aWndPage.GetPosPixel(), aWndPage.GetSizePixel() );
+ aRectRow = Rectangle( aWndRow.GetPosPixel(), aWndRow.GetSizePixel() );
+ aRectCol = Rectangle( aWndCol.GetPosPixel(), aWndCol.GetSizePixel() );
+ aRectData = Rectangle( aWndData.GetPosPixel(), aWndData.GetSizePixel() );
+ aRectSelect = Rectangle( aWndSelect.GetPosPixel(), aWndSelect.GetSizePixel() );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScDPLayoutDlg::GetPivotArrays( PivotField* pPageArr,
+ PivotField* pColArr,
+ PivotField* pRowArr,
+ PivotField* pDataArr,
+ USHORT& rPageCount,
+ USHORT& rColCount,
+ USHORT& rRowCount,
+ USHORT& rDataCount )
+{
+ BOOL bFit = TRUE;
+ USHORT i=0;
+
+ for ( i=0; (i<aDataArr.size()) && (aDataArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pDataArr[i], *aDataArr[i] );
+ rDataCount = i;
+
+ for ( i=0; (i<aPageArr.size()) && (aPageArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pPageArr[i], *aPageArr[i] );
+ rPageCount = i;
+
+ for ( i=0; (i<aColArr.size()) && (aColArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pColArr[i], *aColArr[i] );
+ rColCount = i;
+
+ for ( i=0; (i<aRowArr.size()) && (aRowArr[i].get() != NULL ); i++ )
+ lcl_FillToPivotField( pRowArr[i], *aRowArr[i] );
+ rRowCount = i;
+
+ if ( rRowCount < aRowArr.size() )
+ pRowArr[rRowCount++].nCol = PIVOT_DATA_FIELD;
+ else if ( rColCount < aColArr.size() )
+ pColArr[rColCount++].nCol = PIVOT_DATA_FIELD;
+ else
+ bFit = FALSE; // kein Platz fuer Datenfeld
+
+ return bFit;
+}
+
+void ScDPLayoutDlg::UpdateSrcRange()
+{
+ String theCurPosStr = aEdInPos.GetText();
+ USHORT nResult = ScRange().Parse(theCurPosStr, pDoc, pDoc->GetAddressConvention());
+
+ if ( SCA_VALID != (nResult & SCA_VALID) )
+ // invalid source range.
+ return;
+
+ ScRefAddress start, end;
+ ConvertDoubleRef(pDoc, theCurPosStr, 1, start, end, pDoc->GetAddressConvention());
+ ScRange aNewRange(start.GetAddress(), end.GetAddress());
+ ScSheetSourceDesc inSheet = *xDlgDPObject->GetSheetDesc();
+
+ if (inSheet.aSourceRange == aNewRange)
+ // new range is identical to the current range. Nothing to do.
+ return;
+
+ ScTabViewShell * pTabViewShell = pViewData->GetViewShell();
+ inSheet.aSourceRange = aNewRange;
+ xDlgDPObject->SetSheetDesc(inSheet);
+ xDlgDPObject->FillOldParam( thePivotData, FALSE );
+ xDlgDPObject->FillLabelData(thePivotData);
+
+ pTabViewShell->SetDialogDPObject(xDlgDPObject.get());
+ aLabelDataArr.clear();
+ aWndSelect.ClearFields();
+ aWndData.ClearFields();
+ aWndRow.ClearFields();
+ aWndCol.ClearFields();
+ aWndPage.ClearFields();
+
+ for (size_t i = 0; i < MAX_LABELS; ++i)
+ aSelectArr[i].reset();
+
+ for (size_t i = 0; i < MAX_FIELDS; ++i)
+ {
+ aRowArr[i].reset();
+ aColArr[i].reset();
+ aDataArr[i].reset();
+ }
+
+ for (size_t i = 0; i < MAX_PAGEFIELDS; ++i)
+ aPageArr[i].reset();
+
+ InitFields();
+}
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( !bRefInputMode || !pEditActive )
+ return;
+
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pEditActive );
+
+ if ( pEditActive == &aEdInPos )
+ {
+ String aRefStr;
+ rRef.Format( aRefStr, SCR_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ pEditActive->SetRefString( aRefStr );
+ }
+ else if ( pEditActive == &aEdOutPos )
+ {
+ String aRefStr;
+ rRef.aStart.Format( aRefStr, STD_FORMAT, pDocP, pDocP->GetAddressConvention() );
+ pEditActive->SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScDPLayoutDlg::SetActive()
+{
+ if ( bRefInputMode )
+ {
+ if ( pEditActive )
+ pEditActive->GrabFocus();
+
+ if ( pEditActive == &aEdInPos )
+ EdInModifyHdl( NULL );
+ else if ( pEditActive == &aEdOutPos )
+ EdModifyHdl( NULL );
+ }
+ else
+ {
+ GrabFocus();
+ }
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, ClickHdl, PushButton *, pBtn )
+{
+ if( pBtn == &aBtnRemove )
+ {
+ ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
+ RemoveField( eLastActiveType, rWnd.GetSelectedField() );
+ if( !rWnd.IsEmpty() ) rWnd.GrabFocus();
+ }
+ else if( pBtn == &aBtnOptions )
+ {
+ ScDPFieldWindow& rWnd = GetFieldWindow( eLastActiveType );
+ NotifyDoubleClick( eLastActiveType, rWnd.GetSelectedField() );
+ rWnd.GrabFocus();
+ }
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, OkHdl, OKButton *, EMPTYARG )
+{
+ String aOutPosStr( aEdOutPos.GetText() );
+ ScAddress aAdrDest;
+ BOOL bToNewTable = (aLbOutPos.GetSelectEntryPos() == 1);
+ USHORT nResult = !bToNewTable ? aAdrDest.Parse( aOutPosStr, pDoc, pDoc->GetAddressConvention() ) : 0;
+
+ if ( bToNewTable
+ || ( (aOutPosStr.Len() > 0) && (SCA_VALID == (nResult & SCA_VALID)) ) )
+ {
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+
+ ScPivotParam theOutParam;
+ PivotPageFieldArr aPageFieldArr;
+ PivotFieldArr aColFieldArr;
+ PivotFieldArr aRowFieldArr;
+ PivotFieldArr aDataFieldArr;
+ USHORT nPageCount;
+ USHORT nColCount;
+ USHORT nRowCount;
+ USHORT nDataCount;
+
+ BOOL bFit = GetPivotArrays( aPageFieldArr, aColFieldArr, aRowFieldArr, aDataFieldArr,
+ nPageCount, nColCount, nRowCount, nDataCount );
+ if ( bFit )
+ {
+ ScDPSaveData* pOldSaveData = xDlgDPObject->GetSaveData();
+
+ ScRange aOutRange( aAdrDest ); // bToNewTable is passed separately
+
+ ScDPSaveData aSaveData;
+ aSaveData.SetIgnoreEmptyRows( aBtnIgnEmptyRows.IsChecked() );
+ aSaveData.SetRepeatIfEmpty( aBtnDetectCat.IsChecked() );
+ aSaveData.SetColumnGrand( aBtnTotalCol.IsChecked() );
+ aSaveData.SetRowGrand( aBtnTotalRow.IsChecked() );
+ aSaveData.SetFilterButton( aBtnFilter.IsChecked() );
+ aSaveData.SetDrillDown( aBtnDrillDown.IsChecked() );
+
+ uno::Reference<sheet::XDimensionsSupplier> xSource = xDlgDPObject->GetSource();
+
+ ScDPObject::ConvertOrientation( aSaveData, aPageFieldArr, nPageCount,
+ sheet::DataPilotFieldOrientation_PAGE, NULL, 0, 0, xSource, FALSE );
+ ScDPObject::ConvertOrientation( aSaveData, aColFieldArr, nColCount,
+ sheet::DataPilotFieldOrientation_COLUMN, NULL, 0, 0, xSource, FALSE );
+ ScDPObject::ConvertOrientation( aSaveData, aRowFieldArr, nRowCount,
+ sheet::DataPilotFieldOrientation_ROW, NULL, 0, 0, xSource, FALSE );
+ ScDPObject::ConvertOrientation( aSaveData, aDataFieldArr, nDataCount,
+ sheet::DataPilotFieldOrientation_DATA, NULL, 0, 0, xSource, FALSE,
+ aColFieldArr, nColCount, aRowFieldArr, nRowCount, aPageFieldArr, nPageCount );
+
+ for( ScDPLabelDataVec::const_iterator aIt = aLabelDataArr.begin(), aEnd = aLabelDataArr.end(); aIt != aEnd; ++aIt )
+ {
+ if( ScDPSaveDimension* pDim = aSaveData.GetExistingDimensionByName( aIt->maName ) )
+ {
+ pDim->SetUsedHierarchy( aIt->mnUsedHier );
+ pDim->SetShowEmpty( aIt->mbShowAll );
+ pDim->SetSortInfo( &aIt->maSortInfo );
+ pDim->SetLayoutInfo( &aIt->maLayoutInfo );
+ pDim->SetAutoShowInfo( &aIt->maShowInfo );
+ ScDPSaveDimension* pOldDim = NULL;
+ if (pOldSaveData)
+ {
+ // Transfer the existing layout names to new dimension instance.
+ pOldDim = pOldSaveData->GetExistingDimensionByName(aIt->maName);
+ if (pOldDim)
+ {
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
+
+ const OUString* pSubtotalName = pOldDim->GetSubtotalName();
+ if (pSubtotalName)
+ pDim->SetSubtotalName(*pSubtotalName);
+ }
+ }
+
+ bool bManualSort = ( aIt->maSortInfo.Mode == sheet::DataPilotFieldSortMode::MANUAL );
+
+ // visibility of members
+ for (vector<ScDPLabelData::Member>::const_iterator itr = aIt->maMembers.begin(), itrEnd = aIt->maMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ ScDPSaveMember* pMember = pDim->GetMemberByName(itr->maName);
+
+ // #i40054# create/access members only if flags are not default
+ // (or in manual sorting mode - to keep the order)
+ if (bManualSort || !itr->mbVisible || !itr->mbShowDetails)
+ {
+ pMember->SetIsVisible(itr->mbVisible);
+ pMember->SetShowDetails(itr->mbShowDetails);
+ }
+ if (pOldDim)
+ {
+ // Transfer the existing layout name.
+ ScDPSaveMember* pOldMember = pOldDim->GetMemberByName(itr->maName);
+ if (pOldMember)
+ {
+ const OUString* pLayoutName = pOldMember->GetLayoutName();
+ if (pLayoutName)
+ pMember->SetLayoutName(*pLayoutName);
+ }
+ }
+ }
+ }
+ }
+ ScDPSaveDimension* pDim = aSaveData.GetDataLayoutDimension();
+ if (pDim && pOldSaveData)
+ {
+ ScDPSaveDimension* pOldDim = pOldSaveData->GetDataLayoutDimension();
+ if (pOldDim)
+ {
+ const OUString* pLayoutName = pOldDim->GetLayoutName();
+ if (pLayoutName)
+ pDim->SetLayoutName(*pLayoutName);
+ }
+ }
+
+ USHORT nWhichPivot = SC_MOD()->GetPool().GetWhich( SID_PIVOT_TABLE );
+ ScPivotItem aOutItem( nWhichPivot, &aSaveData, &aOutRange, bToNewTable );
+
+ bRefInputMode = FALSE; // to allow deselecting when switching sheets
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+
+ // #95513# don't hide the dialog before executing the slot, instead it is used as
+ // parent for message boxes in ScTabViewShell::GetDialogParent
+
+ const SfxPoolItem* pRet = GetBindings().GetDispatcher()->Execute(
+ SID_PIVOT_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aOutItem, 0L, 0L );
+
+ bool bSuccess = true;
+ if (pRet)
+ {
+ const SfxBoolItem* pItem = dynamic_cast<const SfxBoolItem*>(pRet);
+ if (pItem)
+ bSuccess = pItem->GetValue();
+ }
+ if (bSuccess)
+ // Table successfully inserted.
+ Close();
+ else
+ {
+ // Table insertion failed. Keep the dialog open.
+ bRefInputMode = true;
+ SetDispatcherLock(true);
+ }
+ }
+ else
+ {
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_PIVOT_ERROR )
+ ).Execute();
+ }
+ }
+ else
+ {
+ if ( !aBtnMore.GetState() )
+ aBtnMore.SetState( TRUE );
+
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_INVALID_TABREF )
+ ).Execute();
+ aEdOutPos.GrabFocus();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, CancelHdl, CancelButton *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, MoreClickHdl, MoreButton *, EMPTYARG )
+{
+ if ( aBtnMore.GetState() )
+ {
+ bRefInputMode = TRUE;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ if ( aEdInPos.IsEnabled() )
+ {
+ aEdInPos.Enable();
+ aEdInPos.GrabFocus();
+ aEdInPos.Enable();
+ }
+ else
+ {
+ aEdOutPos.Enable();
+ aEdOutPos.GrabFocus();
+ aEdOutPos.Enable();
+ }
+ }
+ else
+ {
+ bRefInputMode = FALSE;
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, EdModifyHdl, Edit *, EMPTYARG )
+{
+ String theCurPosStr = aEdOutPos.GetText();
+ USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = aLbOutPos.GetEntryCount();
+
+ for ( i=2; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)aLbOutPos.GetEntryData( i );
+ bFound = (theCurPosStr == *pStr);
+ }
+
+ if ( bFound )
+ aLbOutPos.SelectEntryPos( --i );
+ else
+ aLbOutPos.SelectEntryPos( 0 );
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ScDPLayoutDlg, EdInModifyHdl, Edit *, EMPTYARG )
+{
+ UpdateSrcRange();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, SelAreaHdl, ListBox *, EMPTYARG )
+{
+ String aString;
+ USHORT nSelPos = aLbOutPos.GetSelectEntryPos();
+
+ if ( nSelPos > 1 )
+ {
+ aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
+ }
+ else if ( nSelPos == aLbOutPos.GetEntryCount()-1 ) // auf neue Tabelle?
+ {
+ aEdOutPos.Disable();
+ aRbOutPos.Disable();
+ }
+ else
+ {
+ aEdOutPos.Enable();
+ aRbOutPos.Enable();
+ }
+
+ aEdOutPos.SetText( aString );
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, ScrollHdl, ScrollBar *, EMPTYARG )
+{
+ long nNewOffset = aSlider.GetThumbPos();
+ long nOffsetDiff = nNewOffset - nOffset;
+ nOffset = nNewOffset;
+
+ size_t nFields = std::min< size_t >( aLabelDataArr.size() - nOffset, PAGE_SIZE );
+
+ aWndSelect.ClearFields();
+
+ size_t i=0;
+ for ( i=0; i<nFields; i++ )
+ {
+ const ScDPLabelData& rData = aLabelDataArr[nOffset+i];
+ aWndSelect.AddField(rData.getDisplayName(), i);
+ aSelectArr[i].reset( new ScDPFuncData( rData.mnCol, rData.mnFuncMask ) );
+ }
+ for ( ; i<aSelectArr.size(); i++ )
+ aSelectArr[i].reset();
+
+ aWndSelect.ModifySelectionOffset( nOffsetDiff ); // adjusts selection & redraws
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScDPLayoutDlg, GetFocusHdl, Control*, pCtrl )
+{
+ pEditActive = NULL;
+ if ( pCtrl == &aEdInPos )
+ pEditActive = &aEdInPos;
+ else if ( pCtrl == &aEdOutPos )
+ pEditActive = &aEdOutPos;
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/scendlg.cxx b/sc/source/ui/dbgui/scendlg.cxx
new file mode 100644
index 000000000000..113274a25688
--- /dev/null
+++ b/sc/source/ui/dbgui/scendlg.cxx
@@ -0,0 +1,245 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scitems.hxx"
+#include <svx/drawitem.hxx>
+#include <svx/xtable.hxx>
+#include <sfx2/objsh.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "global.hxx"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "scendlg.hrc"
+#include "scendlg.hxx"
+
+//========================================================================
+
+ScNewScenarioDlg::ScNewScenarioDlg( Window* pParent, const String& rName, BOOL bEdit, BOOL bSheetProtected)
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_NEWSCENARIO ) ),
+ aFlName ( this, ScResId( FL_NAME )),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ aFlComment ( this, ScResId( FL_COMMENT ) ),
+ aEdComment ( this, ScResId( ED_COMMENT ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aCbShowFrame ( this, ScResId( CB_SHOWFRAME ) ),
+ aLbColor ( this, ScResId( LB_COLOR ) ),
+ //aCbPrintFrame ( this, ScResId( CB_PRINTFRAME ) ),
+ aCbTwoWay ( this, ScResId( CB_TWOWAY ) ),
+ //aCbAttrib ( this, ScResId( CB_ATTRIB ) ),
+ //aCbValue ( this, ScResId( CB_VALUE ) ),
+ aCbCopyAll ( this, ScResId( CB_COPYALL ) ),
+ aCbProtect ( this, ScResId( CB_PROTECT ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aDefScenarioName( rName ),
+ bIsEdit ( bEdit )
+{
+ if (bIsEdit)
+ SetText(String(ScResId(STR_EDIT)));
+
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ if ( pDocSh )
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+ if ( pItem )
+ {
+ XColorTable* pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
+ if (pColorTable)
+ {
+ aLbColor.SetUpdateMode( FALSE );
+ long nCount = pColorTable->Count();
+ for ( long n=0; n<nCount; n++ )
+ {
+ XColorEntry* pEntry = pColorTable->GetColor(n);
+ aLbColor.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ aLbColor.SetUpdateMode( TRUE );
+ }
+ }
+ }
+
+ SvtUserOptions aUserOpt;
+
+ String aComment( ScResId( STR_CREATEDBY ) );
+
+ aComment += ' ';
+ aComment += (String)aUserOpt.GetFirstName();
+ aComment += ' ';
+ aComment += (String)aUserOpt.GetLastName();
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
+ aComment += String( ScResId( STR_ON ) );
+ aComment += ' ';
+ aComment += ScGlobal::GetpLocaleData()->getDate( Date() );
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
+ aComment += ScGlobal::GetpLocaleData()->getTime( Time() );
+
+ aEdComment .SetText( aComment );
+ aEdName .SetText( rName );
+ aBtnOk .SetClickHdl( LINK( this, ScNewScenarioDlg, OkHdl ) );
+ aCbShowFrame.SetClickHdl( LINK( this, ScNewScenarioDlg, EnableHdl ) );
+
+ FreeResource();
+
+ aLbColor.SelectEntry( Color( COL_LIGHTGRAY ) );
+ aCbShowFrame.Check(TRUE);
+ //aCbPrintFrame.Check(TRUE);
+ aCbTwoWay.Check(TRUE);
+ //aCbAttrib.Check(FALSE);
+ //aCbValue.Check(FALSE);
+ aCbCopyAll.Check(FALSE);
+ aCbProtect.Check(TRUE);
+
+ if (bIsEdit)
+ aCbCopyAll.Enable(FALSE);
+ // If the Sheet is protected then we disable the Scenario Protect input
+ // and default it to true above. Note we are in 'Add' mode here as: if
+ // Sheet && scenario protection are true, then we cannot edit this dialog.
+ if (bSheetProtected)
+ aCbProtect.Enable(FALSE);
+
+ //! die drei funktionieren noch nicht...
+ /*
+ aCbPrintFrame.Enable(FALSE);
+ aCbAttrib.Enable(FALSE);
+ aCbValue.Enable(FALSE);
+ */
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScNewScenarioDlg::~ScNewScenarioDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+void ScNewScenarioDlg::GetScenarioData( String& rName, String& rComment,
+ Color& rColor, USHORT& rFlags ) const
+{
+ rComment = aEdComment.GetText();
+ rName = aEdName.GetText();
+
+ if ( rName.Len() == 0 )
+ rName = aDefScenarioName;
+
+ rColor = aLbColor.GetSelectEntryColor();
+ USHORT nBits = 0;
+ if (aCbShowFrame.IsChecked())
+ nBits |= SC_SCENARIO_SHOWFRAME;
+ /*
+ if (aCbPrintFrame.IsChecked())
+ nBits |= SC_SCENARIO_PRINTFRAME;
+ */
+ if (aCbTwoWay.IsChecked())
+ nBits |= SC_SCENARIO_TWOWAY;
+ /*
+ if (aCbAttrib.IsChecked())
+ nBits |= SC_SCENARIO_ATTRIB;
+ if (aCbValue.IsChecked())
+ nBits |= SC_SCENARIO_VALUE;
+ */
+ if (aCbCopyAll.IsChecked())
+ nBits |= SC_SCENARIO_COPYALL;
+ if (aCbProtect.IsChecked())
+ nBits |= SC_SCENARIO_PROTECT;
+ rFlags = nBits;
+}
+
+void ScNewScenarioDlg::SetScenarioData( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags )
+{
+ aEdComment.SetText(rComment);
+ aEdName.SetText(rName);
+ aLbColor.SelectEntry(rColor);
+
+ aCbShowFrame.Check ( (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
+ EnableHdl( &aCbShowFrame );
+ //aCbPrintFrame.Check( (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
+ aCbTwoWay.Check ( (nFlags & SC_SCENARIO_TWOWAY) != 0 );
+ //aCbAttrib.Check ( (nFlags & SC_SCENARIO_ATTRIB) != 0 );
+ //aCbValue.Check ( (nFlags & SC_SCENARIO_VALUE) != 0 );
+ // CopyAll nicht
+ aCbProtect.Check ( (nFlags & SC_SCENARIO_PROTECT) != 0 );
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScNewScenarioDlg, OkHdl, OKButton *, EMPTYARG )
+{
+ String aName ( aEdName.GetText() );
+ ScDocument* pDoc = ((ScTabViewShell*)SfxViewShell::Current())->
+ GetViewData()->GetDocument();
+
+ aName.EraseLeadingChars( ' ' );
+ aName.EraseTrailingChars( ' ' );
+ aEdName.SetText( aName );
+
+ if ( !pDoc->ValidTabName( aName ) )
+ {
+ InfoBox( this, ScGlobal::GetRscString( STR_INVALIDTABNAME ) ).
+ Execute();
+ aEdName.GrabFocus();
+ }
+ else if ( !bIsEdit && !pDoc->ValidNewTabName( aName ) )
+ {
+ InfoBox( this, ScGlobal::GetRscString( STR_NEWTABNAMENOTUNIQUE ) ).
+ Execute();
+ aEdName.GrabFocus();
+ }
+ else
+ EndDialog( RET_OK );
+ return 0;
+
+ //! beim Editieren testen, ob eine andere Tabelle den Namen hat!
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScNewScenarioDlg, EnableHdl, CheckBox *, pBox )
+{
+ if( pBox == &aCbShowFrame )
+ aLbColor.Enable( aCbShowFrame.IsChecked() );
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/scendlg.hrc b/sc/source/ui/dbgui/scendlg.hrc
new file mode 100644
index 000000000000..fe01da8ffb48
--- /dev/null
+++ b/sc/source/ui/dbgui/scendlg.hrc
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+//#define RID_SCDLG_NEWSCENARIO 256
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_NAME 10
+#define ED_NAME 11
+#define FL_COMMENT 12
+#define ED_COMMENT 13
+
+#define FL_OPTIONS 20
+#define CB_SHOWFRAME 21
+#define LB_COLOR 22
+#define CB_PRINTFRAME 23
+#define CB_TWOWAY 24
+#define CB_ATTRIB 25
+#define CB_VALUE 26
+#define CB_COPYALL 27
+#define CB_PROTECT 28
+
+#ifdef STR_ON
+#undef STR_ON
+#endif
+#ifdef STR_EDIT
+#undef STR_EDIT
+#endif
+
+#define STR_CREATEDBY 31
+#define STR_ON 32
+#define STR_EDIT 33
diff --git a/sc/source/ui/dbgui/scendlg.src b/sc/source/ui/dbgui/scendlg.src
new file mode 100644
index 000000000000..7e08ec7816cf
--- /dev/null
+++ b/sc/source/ui/dbgui/scendlg.src
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "scendlg.hrc"
+ModalDialog RID_SCDLG_NEWSCENARIO
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 165 ) ;
+ Text [ en-US ] = "Create Scenario" ;
+ Moveable = TRUE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 204 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 204 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MultiLineEdit ED_COMMENT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 43 ) ;
+ Size = MAP_APPFONT ( 183 , 46 ) ;
+ TabStop = TRUE ;
+ MaxTextLength = 512 ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ Edit ED_NAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 183 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox CB_SHOWFRAME
+ {
+ Pos = MAP_APPFONT ( 12 , 107 ) ;
+ Size = MAP_APPFONT ( 109 , 10 ) ;
+ Text [ en-US ] = "~Display border";
+ };
+ ListBox LB_COLOR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 125 , 105 ) ;
+ Size = MAP_APPFONT ( 70 , 86 ) ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ CheckBox CB_PRINTFRAME
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 121 , 243 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Print border" ;
+ };
+ CheckBox CB_TWOWAY
+ {
+ Pos = MAP_APPFONT ( 12 , 121 ) ;
+ Size = MAP_APPFONT ( 183 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zurückkopieren : Zur³ckkopieren */
+ Text [ en-US ] = "Copy ~back" ;
+ };
+ CheckBox CB_ATTRIB
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 243 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Attributes" ;
+ };
+ CheckBox CB_VALUE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 230 , 243 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Copy values only" ;
+ };
+ CheckBox CB_COPYALL
+ {
+ Pos = MAP_APPFONT ( 12 , 135 ) ;
+ Size = MAP_APPFONT ( 183 , 10 ) ;
+ Text [ en-US ] = "Copy ~entire sheet" ;
+ };
+ CheckBox CB_PROTECT
+ {
+ Pos = MAP_APPFONT ( 12 , 149 ) ;
+ Size = MAP_APPFONT ( 183 , 10 ) ;
+ Text [ en-US ] = "~Prevent changes" ;
+ };
+ String STR_EDIT
+ {
+ Text [ en-US ] = "Edit Scenario" ;
+ };
+ String STR_CREATEDBY
+ {
+ Text [ en-US ] = "Created by" ;
+ };
+ String STR_ON
+ {
+ Text [ en-US ] = "on" ;
+ };
+ FixedLine FL_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "~Name of scenario";
+ };
+ FixedLine FL_COMMENT
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "~Comment";
+ };
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 95 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "Settings";
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
new file mode 100644
index 000000000000..1fe0fcc9e91f
--- /dev/null
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -0,0 +1,726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "global.hxx"
+#include "scresid.hxx"
+#include "impex.hxx"
+#include "scuiasciiopt.hxx"
+#include "asciiopt.hrc"
+#include <tools/debug.hxx>
+#include <rtl/tencinfo.h>
+#include <unotools/transliterationwrapper.hxx>
+// ause
+#include "editutil.hxx"
+
+#include <optutil.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "miscuno.hxx"
+
+
+//! TODO make dynamic
+#ifdef WIN
+const SCSIZE ASCIIDLG_MAXROWS = 10000;
+#else
+const SCSIZE ASCIIDLG_MAXROWS = MAXROWCOUNT;
+#endif
+
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+// Defines - CSV Import Preserve Options
+#define FIXED_WIDTH "FixedWidth"
+#define FROM_ROW "FromRow"
+#define CHAR_SET "CharSet"
+#define SEPARATORS "Separators"
+#define TEXT_SEPARATORS "TextSeparators"
+#define MERGE_DELIMITERS "MergeDelimiters"
+#define QUOTED_AS_TEXT "QuotedFieldAsText"
+#define DETECT_SPECIAL_NUM "DetectSpecialNumbers"
+#define LANGUAGE "Language"
+#define SEP_PATH "Office.Calc/Dialogs/CSVImport"
+
+// ============================================================================
+
+void lcl_FillCombo( ComboBox& rCombo, const String& rList, sal_Unicode cSelect )
+{
+ xub_StrLen i;
+ xub_StrLen nCount = rList.GetTokenCount('\t');
+ for ( i=0; i<nCount; i+=2 )
+ rCombo.InsertEntry( rList.GetToken(i,'\t') );
+
+ if ( cSelect )
+ {
+ String aStr;
+ for ( i=0; i<nCount; i+=2 )
+ if ( (sal_Unicode)rList.GetToken(i+1,'\t').ToInt32() == cSelect )
+ aStr = rList.GetToken(i,'\t');
+ if (!aStr.Len())
+ aStr = cSelect; // Ascii
+
+ rCombo.SetText(aStr);
+ }
+}
+
+sal_Unicode lcl_CharFromCombo( ComboBox& rCombo, const String& rList )
+{
+ sal_Unicode c = 0;
+ String aStr = rCombo.GetText();
+ if ( aStr.Len() )
+ {
+ xub_StrLen nCount = rList.GetTokenCount('\t');
+ for ( xub_StrLen i=0; i<nCount; i+=2 )
+ {
+ if ( ScGlobal::GetpTransliteration()->isEqual( aStr, rList.GetToken(i,'\t') ) )
+ c = (sal_Unicode)rList.GetToken(i+1,'\t').ToInt32();
+ }
+ if (!c && aStr.Len())
+ {
+ sal_Unicode cFirst = aStr.GetChar( 0 );
+ // #i24235# first try the first character of the string directly
+ if( (aStr.Len() == 1) || (cFirst < '0') || (cFirst > '9') )
+ c = cFirst;
+ else // keep old behaviour for compatibility (i.e. "39" -> "'")
+ c = (sal_Unicode) aStr.ToInt32(); // Ascii
+ }
+ }
+ return c;
+}
+
+static void load_Separators( OUString &sFieldSeparators, OUString &sTextSeparators,
+ bool &bMergeDelimiters, bool& bQuotedAsText, bool& bDetectSpecialNum,
+ bool &bFixedWidth, sal_Int32 &nFromRow, sal_Int32 &nCharSet,
+ sal_Int32& nLanguage )
+{
+ Sequence<Any>aValues;
+ const Any *pProperties;
+ Sequence<OUString> aNames(9);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
+ pNames[1] = OUString::createFromAscii( SEPARATORS );
+ pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
+ pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
+ pNames[4] = OUString::createFromAscii( FROM_ROW );
+ pNames[5] = OUString::createFromAscii( CHAR_SET );
+ pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
+ pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM );
+ pNames[8] = OUString::createFromAscii( LANGUAGE );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getConstArray();
+ if( pProperties[1].hasValue() )
+ pProperties[1] >>= sFieldSeparators;
+
+ if( pProperties[2].hasValue() )
+ pProperties[2] >>= sTextSeparators;
+
+ if( pProperties[0].hasValue() )
+ bMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[0] );
+
+ if( pProperties[3].hasValue() )
+ bFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[3] );
+
+ if( pProperties[4].hasValue() )
+ pProperties[4] >>= nFromRow;
+
+ if( pProperties[5].hasValue() )
+ pProperties[5] >>= nCharSet;
+
+ if ( pProperties[6].hasValue() )
+ pProperties[6] >>= bQuotedAsText;
+
+ if ( pProperties[7].hasValue() )
+ pProperties[7] >>= bDetectSpecialNum;
+
+ if ( pProperties[8].hasValue() )
+ pProperties[8] >>= nLanguage;
+}
+
+static void save_Separators(
+ String maSeparators, String maTxtSep, bool bMergeDelimiters, bool bQuotedAsText,
+ bool bDetectSpecialNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage )
+{
+ OUString sFieldSeparators = OUString( maSeparators );
+ OUString sTextSeparators = OUString( maTxtSep );
+ Sequence<Any> aValues;
+ Any *pProperties;
+ Sequence<OUString> aNames(9);
+ OUString* pNames = aNames.getArray();
+ ScLinkConfigItem aItem( OUString::createFromAscii( SEP_PATH ) );
+
+ pNames[0] = OUString::createFromAscii( MERGE_DELIMITERS );
+ pNames[1] = OUString::createFromAscii( SEPARATORS );
+ pNames[2] = OUString::createFromAscii( TEXT_SEPARATORS );
+ pNames[3] = OUString::createFromAscii( FIXED_WIDTH );
+ pNames[4] = OUString::createFromAscii( FROM_ROW );
+ pNames[5] = OUString::createFromAscii( CHAR_SET );
+ pNames[6] = OUString::createFromAscii( QUOTED_AS_TEXT );
+ pNames[7] = OUString::createFromAscii( DETECT_SPECIAL_NUM );
+ pNames[8] = OUString::createFromAscii( LANGUAGE );
+ aValues = aItem.GetProperties( aNames );
+ pProperties = aValues.getArray();
+ pProperties[1] <<= sFieldSeparators;
+ pProperties[2] <<= sTextSeparators;
+ ScUnoHelpFunctions::SetBoolInAny( pProperties[0], bMergeDelimiters );
+ ScUnoHelpFunctions::SetBoolInAny( pProperties[3], bFixedWidth );
+ pProperties[4] <<= nFromRow;
+ pProperties[5] <<= nCharSet;
+ pProperties[6] <<= static_cast<sal_Bool>(bQuotedAsText);
+ pProperties[7] <<= static_cast<sal_Bool>(bDetectSpecialNum);
+ pProperties[8] <<= nLanguage;
+
+ aItem.PutProperties(aNames, aValues);
+}
+
+// ----------------------------------------------------------------------------
+
+ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent,String aDatName,
+ SvStream* pInStream, sal_Unicode /*cSep*/ ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_ASCII ) ),
+ mpDatStream ( pInStream ),
+ mnStreamPos( pInStream ? pInStream->Tell() : 0 ),
+
+ mpRowPosArray( NULL ),
+ mnRowPosCount(0),
+
+ aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ),
+ aFtCharSet ( this, ScResId( FT_CHARSET ) ),
+ aLbCharSet ( this, ScResId( LB_CHARSET ) ),
+ aFtCustomLang( this, ScResId( FT_CUSTOMLANG ) ),
+ aLbCustomLang( this, ScResId( LB_CUSTOMLANG ) ),
+
+ aFtRow ( this, ScResId( FT_AT_ROW ) ),
+ aNfRow ( this, ScResId( NF_AT_ROW ) ),
+
+ aFlSepOpt ( this, ScResId( FL_SEPOPT ) ),
+ aRbFixed ( this, ScResId( RB_FIXED ) ),
+ aRbSeparated( this, ScResId( RB_SEPARATED ) ),
+
+ aCkbTab ( this, ScResId( CKB_TAB ) ),
+ aCkbSemicolon(this, ScResId( CKB_SEMICOLON ) ),
+ aCkbComma ( this, ScResId( CKB_COMMA ) ),
+ aCkbSpace ( this, ScResId( CKB_SPACE ) ),
+ aCkbOther ( this, ScResId( CKB_OTHER ) ),
+ aEdOther ( this, ScResId( ED_OTHER ) ),
+ aCkbAsOnce ( this, ScResId( CB_ASONCE) ),
+ aFlOtherOpt ( this, ScResId( FL_OTHER_OPTIONS ) ),
+
+ aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
+ aCbTextSep ( this, ScResId( CB_TEXTSEP ) ),
+
+ aCkbQuotedAsText( this, ScResId(CB_QUOTED_AS_TEXT) ),
+ aCkbDetectNumber( this, ScResId(CB_DETECT_SPECIAL_NUMBER) ),
+
+ aFlWidth ( this, ScResId( FL_WIDTH ) ),
+ aFtType ( this, ScResId( FT_TYPE ) ),
+ aLbType ( this, ScResId( LB_TYPE1 ) ),
+
+ maTableBox ( this, ScResId( CTR_TABLEBOX ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ aCharSetUser( ScResId( SCSTR_CHARSET_USER ) ),
+ aColumnUser ( ScResId( SCSTR_COLUMN_USER ) ),
+ aFldSepList ( ScResId( SCSTR_FIELDSEP ) ),
+ aTextSepList( ScResId( SCSTR_TEXTSEP ) ),
+ mcTextSep ( ScAsciiOptions::cDefaultTextSep ),
+ maStrTextToColumns( ScResId( STR_TEXTTOCOLUMNS ) ),
+ mbFileImport(true)
+{
+ FreeResource();
+ mbFileImport = aDatName.Len() > 0;
+
+ String aName = GetText();
+ // aDatName is empty if invoked during paste from clipboard.
+ if (mbFileImport)
+ {
+ aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - ["));
+ aName += aDatName;
+ aName += ']';
+ }
+ SetText( aName );
+
+
+ OUString sFieldSeparators;
+ OUString sTextSeparators;
+ bool bMergeDelimiters = false;
+ bool bFixedWidth = false;
+ bool bQuotedFieldAsText = true;
+ bool bDetectSpecialNum = false;
+ sal_Int32 nFromRow = 1;
+ sal_Int32 nCharSet = -1;
+ sal_Int32 nLanguage = 0;
+ if (mbFileImport)
+ // load separators only when importing csv files.
+ load_Separators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
+ bQuotedFieldAsText, bDetectSpecialNum, bFixedWidth, nFromRow, nCharSet, nLanguage);
+ maFieldSeparators = String(sFieldSeparators);
+
+ if( bMergeDelimiters )
+ aCkbAsOnce.Check();
+ if (bQuotedFieldAsText)
+ aCkbQuotedAsText.Check();
+ if (bDetectSpecialNum)
+ aCkbDetectNumber.Check();
+ if( bFixedWidth )
+ aRbFixed.Check();
+ if( nFromRow != 1 )
+ aNfRow.SetValue( nFromRow );
+
+ ByteString bString(maFieldSeparators,RTL_TEXTENCODING_MS_1252);
+ const sal_Char *aSep = bString.GetBuffer();
+ int len = maFieldSeparators.Len();
+ for (int i = 0; i < len; ++i)
+ {
+ switch( aSep[i] )
+ {
+ case '\t': aCkbTab.Check(); break;
+ case ';': aCkbSemicolon.Check(); break;
+ case ',': aCkbComma.Check(); break;
+ case ' ': aCkbSpace.Check(); break;
+ default:
+ aCkbOther.Check();
+ aEdOther.SetText( aEdOther.GetText() + OUString( aSep[i] ) );
+ }
+ }
+
+ // Get Separators from the dialog
+ maFieldSeparators = GetSeparators();
+
+ // Clipboard is always Unicode, else detect.
+ bool bPreselectUnicode = !mbFileImport;
+ // Sniff for Unicode / not
+ if( !bPreselectUnicode && mpDatStream )
+ {
+ Seek( 0 );
+ mpDatStream->StartReadingUnicodeText();
+ ULONG nUniPos = mpDatStream->Tell();
+ if ( nUniPos > 0 )
+ bPreselectUnicode = TRUE; // read 0xfeff/0xfffe
+ else
+ {
+ UINT16 n;
+ *mpDatStream >> n;
+ // Assume that normal ASCII/ANSI/ISO/etc. text doesn't start with
+ // control characters except CR,LF,TAB
+ if ( (n & 0xff00) < 0x2000 )
+ {
+ switch ( n & 0xff00 )
+ {
+ case 0x0900 :
+ case 0x0a00 :
+ case 0x0d00 :
+ break;
+ default:
+ bPreselectUnicode = TRUE;
+ }
+ }
+ mpDatStream->Seek(0);
+ }
+ mnStreamPos = mpDatStream->Tell();
+ }
+
+ aNfRow.SetModifyHdl( LINK( this, ScImportAsciiDlg, FirstRowHdl ) );
+
+ // *** Separator characters ***
+ lcl_FillCombo( aCbTextSep, aTextSepList, mcTextSep );
+ aCbTextSep.SetText( sTextSeparators );
+
+ Link aSeparatorHdl =LINK( this, ScImportAsciiDlg, SeparatorHdl );
+ aCbTextSep.SetSelectHdl( aSeparatorHdl );
+ aCbTextSep.SetModifyHdl( aSeparatorHdl );
+ aCkbTab.SetClickHdl( aSeparatorHdl );
+ aCkbSemicolon.SetClickHdl( aSeparatorHdl );
+ aCkbComma.SetClickHdl( aSeparatorHdl );
+ aCkbAsOnce.SetClickHdl( aSeparatorHdl );
+ aCkbQuotedAsText.SetClickHdl( aSeparatorHdl );
+ aCkbDetectNumber.SetClickHdl( aSeparatorHdl );
+ aCkbSpace.SetClickHdl( aSeparatorHdl );
+ aCkbOther.SetClickHdl( aSeparatorHdl );
+ aEdOther.SetModifyHdl( aSeparatorHdl );
+
+ // *** text encoding ListBox ***
+ // all encodings allowed, including Unicode, but subsets are excluded
+ aLbCharSet.FillFromTextEncodingTable( TRUE );
+ // Insert one "SYSTEM" entry for compatibility in AsciiOptions and system
+ // independent document linkage.
+ aLbCharSet.InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser );
+ aLbCharSet.SelectTextEncoding( bPreselectUnicode ?
+ RTL_TEXTENCODING_UNICODE : gsl_getSystemTextEncoding() );
+
+ if( nCharSet >= 0 )
+ aLbCharSet.SelectEntryPos( static_cast<USHORT>(nCharSet) );
+
+ SetSelectedCharSet();
+ aLbCharSet.SetSelectHdl( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
+
+ aLbCustomLang.SetLanguageList(
+ LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
+ aLbCustomLang.InsertLanguage(LANGUAGE_SYSTEM);
+ aLbCustomLang.SelectLanguage(static_cast<LanguageType>(nLanguage), true);
+
+ // *** column type ListBox ***
+ xub_StrLen nCount = aColumnUser.GetTokenCount();
+ for (xub_StrLen i=0; i<nCount; i++)
+ aLbType.InsertEntry( aColumnUser.GetToken( i ) );
+
+ aLbType.SetSelectHdl( LINK( this, ScImportAsciiDlg, LbColTypeHdl ) );
+ aFtType.Disable();
+ aLbType.Disable();
+
+ // *** table box preview ***
+ maTableBox.SetUpdateTextHdl( LINK( this, ScImportAsciiDlg, UpdateTextHdl ) );
+ maTableBox.InitTypes( aLbType );
+ maTableBox.SetColTypeHdl( LINK( this, ScImportAsciiDlg, ColTypeHdl ) );
+
+ aRbSeparated.SetClickHdl( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
+ aRbFixed.SetClickHdl( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
+
+ SetupSeparatorCtrls();
+ RbSepFixHdl( &aRbFixed );
+
+ UpdateVertical();
+
+ maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+}
+
+
+ScImportAsciiDlg::~ScImportAsciiDlg()
+{
+ delete[] mpRowPosArray;
+}
+
+
+// ----------------------------------------------------------------------------
+
+bool ScImportAsciiDlg::GetLine( ULONG nLine, String &rText )
+{
+ if (nLine >= ASCIIDLG_MAXROWS || !mpDatStream)
+ return false;
+
+ bool bRet = true;
+ bool bFixed = aRbFixed.IsChecked();
+
+ if (!mpRowPosArray)
+ mpRowPosArray = new ULONG[ASCIIDLG_MAXROWS + 2];
+
+ if (!mnRowPosCount) // complete re-fresh
+ {
+ memset( mpRowPosArray, 0, sizeof(mpRowPosArray[0]) * (ASCIIDLG_MAXROWS+2));
+
+ Seek(0);
+ if ( mpDatStream->GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
+ mpDatStream->StartReadingUnicodeText();
+
+ mnStreamPos = mpDatStream->Tell();
+ mpRowPosArray[mnRowPosCount] = mnStreamPos;
+ }
+
+ if (nLine >= mnRowPosCount)
+ {
+ // need to work out some more line information
+ do
+ {
+ if (!Seek( mpRowPosArray[mnRowPosCount]) ||
+ mpDatStream->GetError() != ERRCODE_NONE ||
+ mpDatStream->IsEof())
+ {
+ bRet = false;
+ break;
+ }
+ mpDatStream->ReadCsvLine( rText, !bFixed, maFieldSeparators,
+ mcTextSep);
+ mnStreamPos = mpDatStream->Tell();
+ mpRowPosArray[++mnRowPosCount] = mnStreamPos;
+ } while (nLine >= mnRowPosCount &&
+ mpDatStream->GetError() == ERRCODE_NONE &&
+ !mpDatStream->IsEof());
+ if (mpDatStream->IsEof() &&
+ mnStreamPos == mpRowPosArray[mnRowPosCount-1])
+ {
+ // the very end, not even an empty line read
+ bRet = false;
+ --mnRowPosCount;
+ }
+ }
+ else
+ {
+ Seek( mpRowPosArray[nLine]);
+ mpDatStream->ReadCsvLine( rText, !bFixed, maFieldSeparators, mcTextSep);
+ mnStreamPos = mpDatStream->Tell();
+ }
+
+ // #107455# If the file content isn't unicode, ReadUniStringLine
+ // may try to seek beyond the file's end and cause a CANTSEEK error
+ // (depending on the stream type). The error code has to be cleared,
+ // or further read operations (including non-unicode) will fail.
+ if ( mpDatStream->GetError() == ERRCODE_IO_CANTSEEK )
+ mpDatStream->ResetError();
+
+ return bRet;
+}
+
+
+void ScImportAsciiDlg::GetOptions( ScAsciiOptions& rOpt )
+{
+ rOpt.SetCharSet( meCharSet );
+ rOpt.SetCharSetSystem( mbCharSetSystem );
+ rOpt.SetLanguage(aLbCustomLang.GetSelectLanguage());
+ rOpt.SetFixedLen( aRbFixed.IsChecked() );
+ rOpt.SetStartRow( (long)aNfRow.GetValue() );
+ maTableBox.FillColumnData( rOpt );
+ if( aRbSeparated.IsChecked() )
+ {
+ rOpt.SetFieldSeps( GetSeparators() );
+ rOpt.SetMergeSeps( aCkbAsOnce.IsChecked() );
+ rOpt.SetTextSep( lcl_CharFromCombo( aCbTextSep, aTextSepList ) );
+ }
+
+ rOpt.SetQuotedAsText(aCkbQuotedAsText.IsChecked());
+ rOpt.SetDetectSpecialNumber(aCkbDetectNumber.IsChecked());
+}
+
+void ScImportAsciiDlg::SetTextToColumnsMode()
+{
+ SetText( maStrTextToColumns );
+ aFtCharSet.Disable();
+ aLbCharSet.Disable();
+ aFtCustomLang.Disable();
+ aLbCustomLang.SelectLanguage(LANGUAGE_SYSTEM);
+ aLbCustomLang.Disable();
+ aFtRow.Disable();
+ aNfRow.Disable();
+
+ // Quoted field as text option is not used for text-to-columns mode.
+ aCkbQuotedAsText.Check(false);
+ aCkbQuotedAsText.Disable();
+
+ // Always detect special numbers for text-to-columns mode.
+ aCkbDetectNumber.Check();
+ aCkbDetectNumber.Disable();
+}
+
+void ScImportAsciiDlg::SaveParameters()
+{
+ if (!mbFileImport)
+ // We save parameters only for file import.
+ return;
+
+ save_Separators( maFieldSeparators, aCbTextSep.GetText(), aCkbAsOnce.IsChecked(),
+ aCkbQuotedAsText.IsChecked(), aCkbDetectNumber.IsChecked(),
+ aRbFixed.IsChecked(),
+ static_cast<sal_Int32>(aNfRow.GetValue()),
+ static_cast<sal_Int32>(aLbCharSet.GetSelectEntryPos()),
+ static_cast<sal_Int32>(aLbCustomLang.GetSelectLanguage()) );
+}
+
+void ScImportAsciiDlg::SetSelectedCharSet()
+{
+ meCharSet = aLbCharSet.GetSelectTextEncoding();
+ mbCharSetSystem = (meCharSet == RTL_TEXTENCODING_DONTKNOW);
+ if( mbCharSetSystem )
+ meCharSet = gsl_getSystemTextEncoding();
+}
+
+String ScImportAsciiDlg::GetSeparators() const
+{
+ String aSepChars;
+ if( aCkbTab.IsChecked() )
+ aSepChars += '\t';
+ if( aCkbSemicolon.IsChecked() )
+ aSepChars += ';';
+ if( aCkbComma.IsChecked() )
+ aSepChars += ',';
+ if( aCkbSpace.IsChecked() )
+ aSepChars += ' ';
+ if( aCkbOther.IsChecked() )
+ aSepChars += aEdOther.GetText();
+ return aSepChars;
+}
+
+void ScImportAsciiDlg::SetupSeparatorCtrls()
+{
+ BOOL bEnable = aRbSeparated.IsChecked();
+ aCkbTab.Enable( bEnable );
+ aCkbSemicolon.Enable( bEnable );
+ aCkbComma.Enable( bEnable );
+ aCkbSpace.Enable( bEnable );
+ aCkbOther.Enable( bEnable );
+ aEdOther.Enable( bEnable );
+ aCkbAsOnce.Enable( bEnable );
+ aFtTextSep.Enable( bEnable );
+ aCbTextSep.Enable( bEnable );
+}
+
+void ScImportAsciiDlg::UpdateVertical()
+{
+ mnRowPosCount = 0;
+ if (mpDatStream)
+ mpDatStream->SetStreamCharSet(meCharSet);
+}
+
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScImportAsciiDlg, RbSepFixHdl, RadioButton*, pButton )
+{
+ DBG_ASSERT( pButton, "ScImportAsciiDlg::RbSepFixHdl - missing sender" );
+
+ if( (pButton == &aRbFixed) || (pButton == &aRbSeparated) )
+ {
+ SetPointer( Pointer( POINTER_WAIT ) );
+ if( aRbFixed.IsChecked() )
+ maTableBox.SetFixedWidthMode();
+ else
+ maTableBox.SetSeparatorsMode();
+ SetPointer( Pointer( POINTER_ARROW ) );
+
+ SetupSeparatorCtrls();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, SeparatorHdl, Control*, pCtrl )
+{
+ DBG_ASSERT( pCtrl, "ScImportAsciiDlg::SeparatorHdl - missing sender" );
+ DBG_ASSERT( !aRbFixed.IsChecked(), "ScImportAsciiDlg::SeparatorHdl - not allowed in fixed width" );
+
+ /* #i41550# First update state of the controls. The GetSeparators()
+ function needs final state of the check boxes. */
+ if( (pCtrl == &aCkbOther) && aCkbOther.IsChecked() )
+ aEdOther.GrabFocus();
+ else if( pCtrl == &aEdOther )
+ aCkbOther.Check( aEdOther.GetText().Len() > 0 );
+
+ String aOldFldSeps( maFieldSeparators);
+ maFieldSeparators = GetSeparators();
+ sal_Unicode cOldSep = mcTextSep;
+ mcTextSep = lcl_CharFromCombo( aCbTextSep, aTextSepList );
+ // Any separator changed may result in completely different lines due to
+ // embedded line breaks.
+ if (cOldSep != mcTextSep || aOldFldSeps != maFieldSeparators)
+ UpdateVertical();
+
+ maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, CharSetHdl, SvxTextEncodingBox*, pCharSetBox )
+{
+ DBG_ASSERT( pCharSetBox, "ScImportAsciiDlg::CharSetHdl - missing sender" );
+
+ if( (pCharSetBox == &aLbCharSet) && (pCharSetBox->GetSelectEntryCount() == 1) )
+ {
+ SetPointer( Pointer( POINTER_WAIT ) );
+ CharSet eOldCharSet = meCharSet;
+ SetSelectedCharSet();
+ // switching char-set invalidates 8bit -> String conversions
+ if (eOldCharSet != meCharSet)
+ UpdateVertical();
+
+ maTableBox.Execute( CSVCMD_NEWCELLTEXTS );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, FirstRowHdl, NumericField*, pNumField )
+{
+ DBG_ASSERT( pNumField, "ScImportAsciiDlg::FirstRowHdl - missing sender" );
+ maTableBox.Execute( CSVCMD_SETFIRSTIMPORTLINE, sal::static_int_cast<sal_Int32>( pNumField->GetValue() - 1 ) );
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, LbColTypeHdl, ListBox*, pListBox )
+{
+ DBG_ASSERT( pListBox, "ScImportAsciiDlg::LbColTypeHdl - missing sender" );
+ if( pListBox == &aLbType )
+ maTableBox.Execute( CSVCMD_SETCOLUMNTYPE, pListBox->GetSelectEntryPos() );
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, UpdateTextHdl, ScCsvTableBox*, EMPTYARG )
+{
+ sal_Int32 nBaseLine = maTableBox.GetFirstVisLine();
+ sal_Int32 nRead = maTableBox.GetVisLineCount();
+ // If mnRowPosCount==0, this is an initializing call, read ahead for row
+ // count and resulting scroll bar size and position to be able to scroll at
+ // all. When adding lines, read only the amount of next lines to be
+ // displayed.
+ if (!mnRowPosCount || nRead > CSV_PREVIEW_LINES)
+ nRead = CSV_PREVIEW_LINES;
+
+ sal_Int32 i;
+ for (i = 0; i < nRead; i++)
+ {
+ if (!GetLine( nBaseLine + i, maPreviewLine[i]))
+ break;
+ }
+ for (; i < CSV_PREVIEW_LINES; i++)
+ maPreviewLine[i].Erase();
+
+ maTableBox.Execute( CSVCMD_SETLINECOUNT, mnRowPosCount);
+ bool bMergeSep = (aCkbAsOnce.IsChecked() == TRUE);
+ maTableBox.SetUniStrings( maPreviewLine, maFieldSeparators, mcTextSep, bMergeSep);
+
+ return 0;
+}
+
+IMPL_LINK( ScImportAsciiDlg, ColTypeHdl, ScCsvTableBox*, pTableBox )
+{
+ DBG_ASSERT( pTableBox, "ScImportAsciiDlg::ColTypeHdl - missing sender" );
+
+ sal_Int32 nType = pTableBox->GetSelColumnType();
+ sal_Int32 nTypeCount = aLbType.GetEntryCount();
+ bool bEmpty = (nType == CSV_TYPE_MULTI);
+ bool bEnable = ((0 <= nType) && (nType < nTypeCount)) || bEmpty;
+
+ aFtType.Enable( bEnable );
+ aLbType.Enable( bEnable );
+
+ Link aSelHdl = aLbType.GetSelectHdl();
+ aLbType.SetSelectHdl( Link() );
+ if( bEmpty )
+ aLbType.SetNoSelection();
+ else if( bEnable )
+ aLbType.SelectEntryPos( static_cast< sal_uInt16 >( nType ) );
+ aLbType.SetSelectHdl( aSelHdl );
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/scuiimoptdlg.cxx b/sc/source/ui/dbgui/scuiimoptdlg.cxx
new file mode 100644
index 000000000000..67d874a0a271
--- /dev/null
+++ b/sc/source/ui/dbgui/scuiimoptdlg.cxx
@@ -0,0 +1,319 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scuiimoptdlg.hxx"
+#include "scresid.hxx"
+#include "imoptdlg.hrc"
+#include <rtl/tencinfo.h>
+//========================================================================
+// ScDelimiterTable
+//========================================================================
+
+class ScDelimiterTable
+{
+public:
+ ScDelimiterTable( const String& rDelTab )
+ : theDelTab ( rDelTab ),
+ cSep ( '\t' ),
+ nCount ( rDelTab.GetTokenCount('\t') ),
+ nIter ( 0 )
+ {}
+
+ USHORT GetCode( const String& rDelimiter ) const;
+ String GetDelimiter( sal_Unicode nCode ) const;
+
+ String FirstDel() { nIter = 0; return theDelTab.GetToken( nIter, cSep ); }
+ String NextDel() { nIter +=2; return theDelTab.GetToken( nIter, cSep ); }
+
+private:
+ const String theDelTab;
+ const sal_Unicode cSep;
+ const xub_StrLen nCount;
+ xub_StrLen nIter;
+};
+
+//------------------------------------------------------------------------
+
+USHORT ScDelimiterTable::GetCode( const String& rDel ) const
+{
+ sal_Unicode nCode = 0;
+ xub_StrLen i = 0;
+
+ if ( nCount >= 2 )
+ {
+ while ( i<nCount )
+ {
+ if ( rDel == theDelTab.GetToken( i, cSep ) )
+ {
+ nCode = (sal_Unicode) theDelTab.GetToken( i+1, cSep ).ToInt32();
+ i = nCount;
+ }
+ else
+ i += 2;
+ }
+ }
+
+ return nCode;
+}
+
+//------------------------------------------------------------------------
+
+String ScDelimiterTable::GetDelimiter( sal_Unicode nCode ) const
+{
+ String aStrDel;
+ xub_StrLen i = 0;
+
+ if ( nCount >= 2 )
+ {
+ while ( i<nCount )
+ {
+ if ( nCode == (sal_Unicode) theDelTab.GetToken( i+1, cSep ).ToInt32() )
+ {
+ aStrDel = theDelTab.GetToken( i, cSep );
+ i = nCount;
+ }
+ else
+ i += 2;
+ }
+ }
+
+ return aStrDel;
+}
+
+//========================================================================
+// ScImportOptionsDlg
+//========================================================================
+
+ScImportOptionsDlg::ScImportOptionsDlg(
+ Window* pParent,
+ BOOL bAscii,
+ const ScImportOptions* pOptions,
+ const String* pStrTitle,
+ BOOL bMultiByte,
+ BOOL bOnlyDbtoolsEncodings,
+ BOOL bImport )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_IMPORTOPT ) ),
+ aFlFieldOpt ( this, ScResId( FL_FIELDOPT ) ),
+ aFtFont ( this, ScResId( FT_FONT ) ),
+ aLbFont ( this, ScResId( bAscii ? DDLB_FONT : LB_FONT ) ),
+ aFtFieldSep ( this, ScResId( FT_FIELDSEP ) ),
+ aEdFieldSep ( this, ScResId( ED_FIELDSEP ) ),
+ aFtTextSep ( this, ScResId( FT_TEXTSEP ) ),
+ aEdTextSep ( this, ScResId( ED_TEXTSEP ) ),
+ aCbFixed ( this, ScResId( CB_FIXEDWIDTH ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aCbShown ( this, ScResId( CB_SAVESHOWN ) )
+{
+ // im Ctor-Initializer nicht moeglich (MSC kann das nicht):
+ pFieldSepTab = new ScDelimiterTable( String(ScResId(SCSTR_FIELDSEP)) );
+ pTextSepTab = new ScDelimiterTable( String(ScResId(SCSTR_TEXTSEP)) );
+
+ String aStr = pFieldSepTab->FirstDel();
+ sal_Unicode nCode;
+
+ while ( aStr.Len() > 0 )
+ {
+ aEdFieldSep.InsertEntry( aStr );
+ aStr = pFieldSepTab->NextDel();
+ }
+
+ aStr = pTextSepTab->FirstDel();
+
+ while ( aStr.Len() > 0 )
+ {
+ aEdTextSep.InsertEntry( aStr );
+ aStr = pTextSepTab->NextDel();
+ }
+
+ aEdFieldSep.SetText( aEdFieldSep.GetEntry(0) );
+ aEdTextSep.SetText( aEdTextSep.GetEntry(0) );
+
+ if ( bOnlyDbtoolsEncodings )
+ {
+ // Even dBase export allows multibyte now
+ if ( bMultiByte )
+ aLbFont.FillFromDbTextEncodingMap( bImport );
+ else
+ aLbFont.FillFromDbTextEncodingMap( bImport, RTL_TEXTENCODING_INFO_MULTIBYTE );
+ }
+ else if ( !bAscii )
+ { //!TODO: Unicode would need work in each filter
+ if ( bMultiByte )
+ aLbFont.FillFromTextEncodingTable( bImport, RTL_TEXTENCODING_INFO_UNICODE );
+ else
+ aLbFont.FillFromTextEncodingTable( bImport, RTL_TEXTENCODING_INFO_UNICODE |
+ RTL_TEXTENCODING_INFO_MULTIBYTE );
+ }
+ else
+ {
+ if ( pOptions )
+ {
+ nCode = pOptions->nFieldSepCode;
+ aStr = pFieldSepTab->GetDelimiter( nCode );
+
+ if ( !aStr.Len() )
+ aEdFieldSep.SetText( String((sal_Unicode)nCode) );
+ else
+ aEdFieldSep.SetText( aStr );
+
+ nCode = pOptions->nTextSepCode;
+ aStr = pTextSepTab->GetDelimiter( nCode );
+
+ if ( !aStr.Len() )
+ aEdTextSep.SetText( String((sal_Unicode)nCode) );
+ else
+ aEdTextSep.SetText( aStr );
+ }
+ // all encodings allowed, even Unicode
+ aLbFont.FillFromTextEncodingTable( bImport );
+ }
+
+ if( bAscii )
+ {
+ Size aWinSize( GetSizePixel() );
+ aWinSize.Height() = aCbFixed.GetPosPixel().Y() + aCbFixed.GetSizePixel().Height();
+ Size aDiffSize( LogicToPixel( Size( 0, 6 ), MapMode( MAP_APPFONT ) ) );
+ aWinSize.Height() += aDiffSize.Height();
+ SetSizePixel( aWinSize );
+ aCbFixed.Show();
+ aCbFixed.SetClickHdl( LINK( this, ScImportOptionsDlg, FixedWidthHdl ) );
+ aCbFixed.Check( FALSE );
+ aCbShown.Show();
+ aCbShown.Check( TRUE );
+ }
+ else
+ {
+ aFlFieldOpt.SetText( aFtFont.GetText() );
+ aFtFieldSep.Hide();
+ aFtTextSep.Hide();
+ aFtFont.Hide();
+ aEdFieldSep.Hide();
+ aEdTextSep.Hide();
+ aCbFixed.Hide();
+ aCbShown.Hide();
+ aLbFont.GrabFocus();
+ aLbFont.SetDoubleClickHdl( LINK( this, ScImportOptionsDlg, DoubleClickHdl ) );
+ }
+
+ aLbFont.SelectTextEncoding( pOptions ? pOptions->eCharSet :
+ gsl_getSystemTextEncoding() );
+
+ // optionaler Titel:
+ if ( pStrTitle )
+ SetText( *pStrTitle );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScImportOptionsDlg::~ScImportOptionsDlg()
+{
+ delete pFieldSepTab;
+ delete pTextSepTab;
+}
+
+//------------------------------------------------------------------------
+
+void ScImportOptionsDlg::GetImportOptions( ScImportOptions& rOptions ) const
+{
+ rOptions.SetTextEncoding( aLbFont.GetSelectTextEncoding() );
+
+ if ( aCbFixed.IsVisible() )
+ {
+ rOptions.nFieldSepCode = GetCodeFromCombo( aEdFieldSep );
+ rOptions.nTextSepCode = GetCodeFromCombo( aEdTextSep );
+ rOptions.bFixedWidth = aCbFixed.IsChecked();
+ rOptions.bSaveAsShown = aCbShown.IsChecked();
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScImportOptionsDlg::GetCodeFromCombo( const ComboBox& rEd ) const
+{
+ ScDelimiterTable* pTab;
+ String aStr( rEd.GetText() );
+ USHORT nCode;
+
+ if ( &rEd == &aEdTextSep )
+ pTab = pTextSepTab;
+ else
+ pTab = pFieldSepTab;
+
+ if ( !aStr.Len() )
+ {
+ nCode = 0; // kein Trennzeichen
+ }
+ else
+ {
+ nCode = pTab->GetCode( aStr );
+
+ if ( nCode == 0 )
+ nCode = (USHORT)aStr.GetChar(0);
+ }
+
+ return nCode;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScImportOptionsDlg, FixedWidthHdl, CheckBox*, pCheckBox )
+{
+ if( pCheckBox == &aCbFixed )
+ {
+ BOOL bEnable = !aCbFixed.IsChecked();
+ aFtFieldSep.Enable( bEnable );
+ aEdFieldSep.Enable( bEnable );
+ aFtTextSep.Enable( bEnable );
+ aEdTextSep.Enable( bEnable );
+ aCbShown.Enable( bEnable );
+ }
+ return 0;
+}
+
+ IMPL_LINK( ScImportOptionsDlg, DoubleClickHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbFont )
+ {
+ aBtnOk.Click();
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/sfiltdlg.cxx b/sc/source/ui/dbgui/sfiltdlg.cxx
new file mode 100644
index 000000000000..2d8c43b88ae8
--- /dev/null
+++ b/sc/source/ui/dbgui/sfiltdlg.cxx
@@ -0,0 +1,532 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+#include <sfx2/dispatch.hxx>
+
+#include "uiitems.hxx"
+#include "rangenam.hxx"
+#include "dbcolect.hxx"
+#include "reffact.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+
+#include "foptmgr.hxx"
+
+#include "globstr.hrc"
+#include "filter.hrc"
+
+#define _SFILTDLG_CXX
+#include "filtdlg.hxx"
+#undef _SFILTDLG_CXX
+#include <vcl/msgbox.hxx>
+
+// DEFINE --------------------------------------------------------------------
+
+#define ERRORBOX(rid) ErrorBox( this, WinBits( WB_OK|WB_DEF_OK),\
+ ScGlobal::GetRscString(rid) ).Execute()
+
+
+//============================================================================
+// class ScSpecialFilterDialog
+
+//----------------------------------------------------------------------------
+
+ScSpecialFilterDlg::ScSpecialFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SPEC_FILTER ),
+ //
+ aLbFilterArea ( this, ScResId( LB_CRITERIA_AREA ) ),
+ aFtFilterArea ( this, ScResId( FT_CRITERIA_AREA ) ),
+ aEdFilterArea ( this, this, ScResId( ED_CRITERIA_AREA ) ),
+ aRbFilterArea ( this, ScResId( RB_CRITERIA_AREA ), &aEdFilterArea, this ),
+ //
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ _INIT_COMMON_FILTER_RSCOBJS
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ //
+ pOptionsMgr ( NULL ),
+ nWhichQuery ( rArgSet.GetPool()->GetWhich( SID_QUERY ) ),
+ theQueryData ( ((const ScQueryItem&)
+ rArgSet.Get( nWhichQuery )).GetQueryData() ),
+ pOutItem ( NULL ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ pRefInputEdit ( NULL ),
+ bRefInputMode ( FALSE ),
+ pTimer ( NULL )
+{
+ Init( rArgSet );
+ aEdFilterArea.GrabFocus();
+
+ FreeResource();
+
+ // Hack: RefInput-Kontrolle
+ pTimer = new Timer;
+ pTimer->SetTimeout( 50 ); // 50ms warten
+ pTimer->SetTimeoutHdl( LINK( this, ScSpecialFilterDlg, TimeOutHdl ) );
+ pTimer->Start();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScSpecialFilterDlg::~ScSpecialFilterDlg()
+{
+ USHORT nEntries = aLbFilterArea.GetEntryCount();
+ USHORT i;
+
+ for ( i=1; i<nEntries; i++ )
+ delete (String*)aLbFilterArea.GetEntryData( i );
+
+ delete pOptionsMgr;
+
+ if ( pOutItem )
+ delete pOutItem;
+
+ // Hack: RefInput-Kontrolle
+ pTimer->Stop();
+ delete pTimer;
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScSpecialFilterDlg::Init( const SfxItemSet& rArgSet )
+{
+ const ScQueryItem& rQueryItem = (const ScQueryItem&)
+ rArgSet.Get( nWhichQuery );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScSpecialFilterDlg, EndDlgHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScSpecialFilterDlg, EndDlgHdl ) );
+ aLbFilterArea.SetSelectHdl ( LINK( this, ScSpecialFilterDlg, FilterAreaSelHdl ) );
+ aEdFilterArea.SetModifyHdl ( LINK( this, ScSpecialFilterDlg, FilterAreaModHdl ) );
+
+ pViewData = rQueryItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+
+ aEdFilterArea.SetText( EMPTY_STRING ); // may be overwritten below
+
+ if ( pViewData && pDoc )
+ {
+ if(pDoc->GetChangeTrack()!=NULL) aBtnCopyResult.Disable();
+
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+
+ /*
+ * Aus den RangeNames des Dokumentes werden nun die
+ * gemerkt, bei denen es sich um Filter-Bereiche handelt
+ */
+
+ aLbFilterArea.Clear();
+ aLbFilterArea.InsertEntry( aStrUndefined, 0 );
+
+ if ( nCount > 0 )
+ {
+ String aString;
+ ScRangeData* pData = NULL;
+ USHORT nInsert = 0;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (ScRangeData*)(pRangeNames->At( i ));
+ if ( pData )
+ {
+ if ( pData->HasType( RT_CRITERIA ) )
+ {
+ pData->GetName( aString );
+ nInsert = aLbFilterArea.InsertEntry( aString );
+ pData->GetSymbol( aString );
+ aLbFilterArea.SetEntryData( nInsert,
+ new String( aString ) );
+ }
+ }
+ }
+ }
+
+ // is there a stored source range?
+
+ ScRange aAdvSource;
+ if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
+ {
+ String aRefStr;
+ aAdvSource.Format( aRefStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdFilterArea.SetRefString( aRefStr );
+ }
+ }
+
+ aLbFilterArea.SelectEntryPos( 0 );
+
+ // Optionen initialisieren lassen:
+
+ pOptionsMgr = new ScFilterOptionsMgr(
+ this,
+ pViewData,
+ theQueryData,
+ aBtnMore,
+ aBtnCase,
+ aBtnRegExp,
+ aBtnHeader,
+ aBtnUnique,
+ aBtnCopyResult,
+ aBtnDestPers,
+ aLbCopyArea,
+ aEdCopyArea,
+ aRbCopyArea,
+ aFtDbAreaLabel,
+ aFtDbArea,
+ aFlOptions,
+ aStrNoName,
+ aStrUndefined );
+
+ // #35206# Spezialfilter braucht immer Spaltenkoepfe
+ aBtnHeader.Check(TRUE);
+ aBtnHeader.Disable();
+
+ // Modal-Modus einschalten
+// SetDispatcherLock( TRUE );
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSpecialFilterDlg::Close()
+{
+ if (pViewData)
+ pViewData->GetDocShell()->CancelAutoDBRange();
+
+ return DoClose( ScSpecialFilterDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+void ScSpecialFilterDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( bRefInputMode && pRefInputEdit ) // Nur moeglich, wenn im Referenz-Editmodus
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aRefStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDocP->GetAddressConvention();
+
+ if ( pRefInputEdit == &aEdCopyArea)
+ rRef.aStart.Format( aRefStr, SCA_ABS_3D, pDocP, eConv );
+ else if ( pRefInputEdit == &aEdFilterArea)
+ rRef.Format( aRefStr, SCR_ABS_3D, pDocP, eConv );
+
+ pRefInputEdit->SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScSpecialFilterDlg::SetActive()
+{
+ if ( bRefInputMode )
+ {
+ if ( pRefInputEdit == &aEdCopyArea )
+ {
+ aEdCopyArea.GrabFocus();
+ if ( aEdCopyArea.GetModifyHdl().IsSet() )
+ ((Link&)aEdCopyArea.GetModifyHdl()).Call( &aEdCopyArea );
+ }
+ else if ( pRefInputEdit == &aEdFilterArea )
+ {
+ aEdFilterArea.GrabFocus();
+ FilterAreaModHdl( &aEdFilterArea );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScQueryItem* ScSpecialFilterDlg::GetOutputItem( const ScQueryParam& rParam,
+ const ScRange& rSource )
+{
+ if ( pOutItem ) DELETEZ( pOutItem );
+ pOutItem = new ScQueryItem( nWhichQuery, &rParam );
+ pOutItem->SetAdvancedQuerySource( &rSource );
+
+ return pOutItem;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScSpecialFilterDlg::IsRefInputMode() const
+{
+ return bRefInputMode;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScSpecialFilterDlg, EndDlgHdl, Button*, pBtn )
+{
+ DBG_ASSERT( pDoc && pViewData, "Document or ViewData not found. :-/" );
+
+ if ( (pBtn == &aBtnOk) && pDoc && pViewData )
+ {
+ String theCopyStr( aEdCopyArea.GetText() );
+ String theAreaStr( aEdFilterArea.GetText() );
+ ScQueryParam theOutParam( theQueryData );
+ ScAddress theAdrCopy;
+ BOOL bEditInputOk = TRUE;
+ BOOL bQueryOk = FALSE;
+ ScRange theFilterArea;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ xub_StrLen nColonPos = theCopyStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ theCopyStr.Erase( nColonPos );
+
+ USHORT nResult = theAdrCopy.Parse( theCopyStr, pDoc, eConv );
+
+ if ( SCA_VALID != (nResult & SCA_VALID) )
+ {
+ if ( !aBtnMore.GetState() )
+ aBtnMore.SetState( TRUE );
+
+ ERRORBOX( STR_INVALID_TABREF );
+ aEdCopyArea.GrabFocus();
+ bEditInputOk = FALSE;
+ }
+ }
+
+ if ( bEditInputOk )
+ {
+ USHORT nResult = ScRange().Parse( theAreaStr, pDoc, eConv );
+
+ if ( SCA_VALID != (nResult & SCA_VALID) )
+ {
+ ERRORBOX( STR_INVALID_TABREF );
+ aEdFilterArea.GrabFocus();
+ bEditInputOk = FALSE;
+ }
+ }
+
+ if ( bEditInputOk )
+ {
+ /*
+ * Alle Edit-Felder enthalten gueltige Bereiche.
+ * Nun wird versucht aus dem Filterbereich
+ * ein ScQueryParam zu erzeugen:
+ */
+
+ USHORT nResult = theFilterArea.Parse( theAreaStr, pDoc, eConv );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ ScAddress& rStart = theFilterArea.aStart;
+ ScAddress& rEnd = theFilterArea.aEnd;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ theOutParam.bInplace = FALSE;
+ theOutParam.nDestTab = theAdrCopy.Tab();
+ theOutParam.nDestCol = theAdrCopy.Col();
+ theOutParam.nDestRow = theAdrCopy.Row();
+ }
+ else
+ {
+ theOutParam.bInplace = TRUE;
+ theOutParam.nDestTab = 0;
+ theOutParam.nDestCol = 0;
+ theOutParam.nDestRow = 0;
+ }
+
+ theOutParam.bHasHeader = aBtnHeader.IsChecked();
+ theOutParam.bByRow = TRUE;
+ theOutParam.bCaseSens = aBtnCase.IsChecked();
+ theOutParam.bRegExp = aBtnRegExp.IsChecked();
+ theOutParam.bDuplicate = !aBtnUnique.IsChecked();
+ theOutParam.bDestPers = aBtnDestPers.IsChecked();
+
+ bQueryOk =
+ pDoc->CreateQueryParam( rStart.Col(),
+ rStart.Row(),
+ rEnd.Col(),
+ rEnd.Row(),
+ rStart.Tab(),
+ theOutParam );
+
+ // an der DB-Collection koennen nur MAXQUERY Filter-Eintraege
+ // gespeichert werden
+
+ if ( bQueryOk && theOutParam.GetEntryCount() > MAXQUERY &&
+ theOutParam.GetEntry(MAXQUERY).bDoQuery )
+ {
+ bQueryOk = FALSE; // zu viele
+ //! andere Fehlermeldung ??
+ }
+ }
+ }
+
+ if ( bQueryOk )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( FID_FILTER_OK,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ GetOutputItem( theOutParam, theFilterArea ), 0L, 0L );
+ Close();
+ }
+ else
+ {
+ ERRORBOX( STR_INVALID_QUERYAREA );
+ aEdFilterArea.GrabFocus();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSpecialFilterDlg, TimeOutHdl, Timer*, _pTimer )
+{
+ // alle 50ms nachschauen, ob RefInputMode noch stimmt
+
+ if( (_pTimer == pTimer) && IsActive() )
+ {
+ if( aEdCopyArea.HasFocus() || aRbCopyArea.HasFocus() )
+ {
+ pRefInputEdit = &aEdCopyArea;
+ bRefInputMode = TRUE;
+ }
+ else if( aEdFilterArea.HasFocus() || aRbFilterArea.HasFocus() )
+ {
+ pRefInputEdit = &aEdFilterArea;
+ bRefInputMode = TRUE;
+ }
+ else if( bRefInputMode )
+ {
+ pRefInputEdit = NULL;
+ bRefInputMode = FALSE;
+ }
+ }
+
+ pTimer->Start();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSpecialFilterDlg, FilterAreaSelHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbFilterArea )
+ {
+ String aString;
+ USHORT nSelPos = aLbFilterArea.GetSelectEntryPos();
+
+ if ( nSelPos > 0 )
+ aString = *(String*)aLbFilterArea.GetEntryData( nSelPos );
+
+ aEdFilterArea.SetText( aString );
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSpecialFilterDlg, FilterAreaModHdl, formula::RefEdit*, pEd )
+{
+ if ( pEd == &aEdFilterArea )
+ {
+ if ( pDoc && pViewData )
+ {
+ String theCurAreaStr = pEd->GetText();
+ USHORT nResult = ScRange().Parse( theCurAreaStr, pDoc );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = aLbFilterArea.GetEntryCount();
+
+ for ( i=1; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)aLbFilterArea.GetEntryData( i );
+ bFound = (theCurAreaStr == *pStr);
+ }
+
+ if ( bFound )
+ aLbFilterArea.SelectEntryPos( --i );
+ else
+ aLbFilterArea.SelectEntryPos( 0 );
+ }
+ }
+ else
+ aLbFilterArea.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/sortdlg.cxx b/sc/source/ui/dbgui/sortdlg.cxx
new file mode 100644
index 000000000000..878922312e5d
--- /dev/null
+++ b/sc/source/ui/dbgui/sortdlg.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+#include <vcl/msgbox.hxx>
+#include "tpsort.hxx"
+#include "sortdlg.hxx"
+#include "scresid.hxx"
+#include "sortdlg.hrc"
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <layout/layout-pre.hxx>
+#endif
+
+ScSortDlg::ScSortDlg( Window* pParent,
+ const SfxItemSet* pArgSet ) :
+ SfxTabDialog( pParent,
+ ScResId( RID_SCDLG_SORT ),
+ pArgSet ),
+ bIsHeaders ( FALSE ),
+ bIsByRows ( FALSE )
+
+{
+#if LAYOUT_SFX_TABDIALOG_BROKEN
+ AddTabPage( TP_FIELDS, ScTabPageSortFields::Create, 0 );
+ AddTabPage( TP_OPTIONS, ScTabPageSortOptions::Create, 0 );
+#else
+ String fields = rtl::OUString::createFromAscii ("fields");
+ AddTabPage( TP_FIELDS, fields, ScTabPageSortFields::Create, 0, FALSE, TAB_APPEND);
+ String options = rtl::OUString::createFromAscii ("options");
+ AddTabPage( TP_OPTIONS, options, ScTabPageSortOptions::Create, 0, FALSE, TAB_APPEND);
+#endif
+ FreeResource();
+}
+
+__EXPORT ScSortDlg::~ScSortDlg()
+{
+}
+
+//==================================================================
+ScSortWarningDlg::ScSortWarningDlg( Window* pParent,
+ const String& rExtendText,
+ const String& rCurrentText ):
+ ModalDialog ( pParent, ScResId( RID_SCDLG_SORT_WARNING ) ),
+ aFtText ( this, ScResId( FT_TEXT ) ),
+ aFtTip ( this, ScResId( FT_TIP ) ),
+ aBtnExtSort ( this, ScResId( BTN_EXTSORT ) ),
+ aBtnCurSort ( this, ScResId( BTN_CURSORT ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ String sTextName = aFtText.GetText();
+ sTextName.SearchAndReplaceAscii("%1", rExtendText);
+ sTextName.SearchAndReplaceAscii("%2", rCurrentText);
+ aFtText.SetText( sTextName );
+
+ aBtnExtSort .SetClickHdl( LINK( this, ScSortWarningDlg, BtnHdl ) );
+ aBtnCurSort .SetClickHdl( LINK( this, ScSortWarningDlg, BtnHdl ) );
+
+ FreeResource();
+}
+
+ScSortWarningDlg::~ScSortWarningDlg()
+{
+}
+
+IMPL_LINK( ScSortWarningDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnExtSort )
+ {
+ EndDialog( BTN_EXTEND_RANGE );
+ }
+ else if( pBtn == &aBtnCurSort )
+ {
+ EndDialog( BTN_CURRENT_SELECTION );
+ }
+ return 0;
+}
+//========================================================================//
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/subtdlg.cxx b/sc/source/ui/dbgui/subtdlg.cxx
new file mode 100644
index 000000000000..97f7e2e8d005
--- /dev/null
+++ b/sc/source/ui/dbgui/subtdlg.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "tpsubt.hxx"
+#include "scresid.hxx"
+#include "subtdlg.hxx"
+#include "subtdlg.hrc"
+
+
+//==================================================================
+
+ScSubTotalDlg::ScSubTotalDlg( Window* pParent,
+ const SfxItemSet* pArgSet ) :
+ SfxTabDialog( pParent,
+ ScResId( RID_SCDLG_SUBTOTALS ),
+ pArgSet ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) )
+{
+ AddTabPage( PAGE_GROUP1, ScTpSubTotalGroup1::Create, 0 );
+ AddTabPage( PAGE_GROUP2, ScTpSubTotalGroup2::Create, 0 );
+ AddTabPage( PAGE_GROUP3, ScTpSubTotalGroup3::Create, 0 );
+ AddTabPage( PAGE_OPTIONS, ScTpSubTotalOptions::Create, 0 );
+ aBtnRemove.SetClickHdl( LINK( this, ScSubTotalDlg, RemoveHdl ) );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScSubTotalDlg, RemoveHdl, PushButton *, pBtn )
+{
+ if ( pBtn == &aBtnRemove )
+ {
+ EndDialog( SCRET_REMOVE );
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScSubTotalDlg, RemoveHdl, PushButton *, pBtn )
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/textimportoptions.cxx b/sc/source/ui/dbgui/textimportoptions.cxx
new file mode 100644
index 000000000000..9dd22f0aee57
--- /dev/null
+++ b/sc/source/ui/dbgui/textimportoptions.cxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: langbox.hxx,v $
+ * $Revision: 1.4.242.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------------
+
+#include "textimportoptions.hxx"
+#include "textimportoptions.hrc"
+
+#include "scresid.hxx"
+#include "vcl/window.hxx"
+#include "vcl/msgbox.hxx"
+#include "vcl/svapp.hxx"
+
+ScTextImportOptionsDlg::ScTextImportOptionsDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_TEXT_IMPORT_OPTIONS)),
+
+ maBtnOk(this, ScResId(BTN_OK)),
+ maBtnCancel(this, ScResId(BTN_CANCEL)),
+ maBtnHelp(this, ScResId(BTN_HELP)),
+ maFlChooseLang(this, ScResId(FL_CHOOSE_LANG)),
+ maRbAutomatic(this, ScResId(RB_AUTOMATIC)),
+ maRbCustom(this, ScResId(RB_CUSTOM)),
+ maLbCustomLang(this, ScResId(LB_CUSTOM_LANG)),
+ maFlOption(this, ScResId(FL_OPTION)),
+ maBtnConvertDate(this, ScResId(BTN_CONVERT_DATE))
+{
+ FreeResource();
+ init();
+}
+
+ScTextImportOptionsDlg::~ScTextImportOptionsDlg()
+{
+}
+
+short ScTextImportOptionsDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+LanguageType ScTextImportOptionsDlg::getLanguageType() const
+{
+ if (maRbAutomatic.IsChecked())
+ return LANGUAGE_SYSTEM;
+
+ return maLbCustomLang.GetSelectLanguage();
+}
+
+bool ScTextImportOptionsDlg::isDateConversionSet() const
+{
+ return maBtnConvertDate.IsChecked();
+}
+
+void ScTextImportOptionsDlg::init()
+{
+ Link aLink = LINK( this, ScTextImportOptionsDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+ aLink = LINK( this, ScTextImportOptionsDlg, RadioHdl );
+ maRbAutomatic.SetClickHdl(aLink);
+ maRbCustom.SetClickHdl(aLink);
+
+ maRbAutomatic.Check(true);
+
+ maLbCustomLang.SetLanguageList(
+ LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, false, false);
+
+ LanguageType eLang = Application::GetSettings().GetLanguage();
+ maLbCustomLang.SelectLanguage(eLang);
+ maLbCustomLang.Disable();
+}
+
+IMPL_LINK( ScTextImportOptionsDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScTextImportOptionsDlg, RadioHdl, RadioButton*, pBtn )
+{
+ if (pBtn == &maRbAutomatic)
+ {
+ maLbCustomLang.Disable();
+ }
+ else if (pBtn == &maRbCustom)
+ {
+ maLbCustomLang.Enable();
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/textimportoptions.src b/sc/source/ui/dbgui/textimportoptions.src
new file mode 100644
index 000000000000..eacd8f008a46
--- /dev/null
+++ b/sc/source/ui/dbgui/textimportoptions.src
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: retypepassdlg.src,v $
+ * $Revision: 1.1.2.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "textimportoptions.hrc"
+
+ModalDialog RID_SCDLG_TEXT_IMPORT_OPTIONS
+{
+ Text [ en-US ] = "Import Options" ;
+ Size = MAP_APPFONT ( 230 , 101 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OutputSize = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 175, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 175, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 175, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ FixedLine FL_CHOOSE_LANG
+ {
+ Pos = MAP_APPFONT( 6, 3 ) ;
+ Size = MAP_APPFONT( 165, 14 ) ;
+
+ Text [ en-US ] = "Select the language to use for import" ;
+ };
+
+ RadioButton RB_AUTOMATIC
+ {
+ Pos = MAP_APPFONT( 12, 20 ) ;
+ Size = MAP_APPFONT( 159, 10 ) ;
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Automatic" ;
+ };
+
+ RadioButton RB_CUSTOM
+ {
+ Pos = MAP_APPFONT( 12, 34 ) ;
+ Size = MAP_APPFONT( 159, 10 ) ;
+ TabStop = TRUE ;
+
+ Text [ en-US ] = "Custom" ;
+ };
+
+ ListBox LB_CUSTOM_LANG
+ {
+ Pos = MAP_APPFONT( 20, 50 ) ;
+ Size = MAP_APPFONT( 140, 120 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+
+ FixedLine FL_OPTION
+ {
+ Pos = MAP_APPFONT( 6, 70 );
+ Size = MAP_APPFONT( 165, 14 );
+ Text [ en-US ] = "Options" ;
+ };
+
+ CheckBox BTN_CONVERT_DATE
+ {
+ Pos = MAP_APPFONT( 12, 86 );
+ Size = MAP_APPFONT( 159, 10 );
+ TabStop = TRUE ;
+ Text [ en-US ] = "Detect special numbers (such as dates)." ;
+ };
+};
+
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
new file mode 100644
index 000000000000..6d5f6dc5c8d1
--- /dev/null
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -0,0 +1,1085 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include <vcl/msgbox.hxx>
+#include <i18npool/mslangid.hxx>
+#include <svtools/collatorres.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "scitems.hxx"
+#include "uiitems.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "global.hxx"
+#include "dbcolect.hxx"
+#include "userlist.hxx"
+#include "rangeutl.hxx"
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot IDs
+#include "globstr.hrc"
+
+#include "sortdlg.hxx"
+#include "sortdlg.hrc"
+
+#define _TPSORT_CXX
+#include "tpsort.hxx"
+#undef _TPSORT_CXX
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pSortRanges[] =
+{
+ SID_SORT,
+ SID_SORT,
+ 0
+};
+
+// -----------------------------------------------------------------------
+
+/*
+ * Da sich Einstellungen auf der zweiten TabPage (Optionen) auf
+ * die erste TabPage auswirken, muss es die Moeglichkeit geben,
+ * dies der jeweils anderen Seite mitzuteilen.
+ *
+ * Im Moment wird dieses Problem ueber zwei Datenmember des TabDialoges
+ * geloest. Wird eine Seite Aktiviert/Deaktiviert, so gleicht sie diese
+ * Datenmember mit dem eigenen Zustand ab (->Activate()/Deactivate()).
+ *
+ * 31.01.95:
+ * Die Klasse SfxTabPage bietet mittlerweile ein Verfahren an:
+ *
+ * virtual BOOL HasExchangeSupport() const; -> return TRUE;
+ * virtual void ActivatePage(const SfxItemSet &);
+ * virtual int DeactivatePage(SfxItemSet * = 0);
+ *
+ * muss noch geaendert werden!
+ */
+
+//========================================================================
+//========================================================================
+// Sortierkriterien-Tabpage:
+
+ScTabPageSortFields::ScTabPageSortFields( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_SORT_FIELDS ),
+ rArgSet ),
+ //
+ aFlSort1 ( this, ScResId( FL_SORT1 ) ),
+ aLbSort1 ( this, ScResId( LB_SORT1 ) ),
+ aBtnUp1 ( this, ScResId( BTN_UP1 ) ),
+ aBtnDown1 ( this, ScResId( BTN_DOWN1 ) ),
+ //
+ aFlSort2 ( this, ScResId( FL_SORT2 ) ),
+ aLbSort2 ( this, ScResId( LB_SORT2 ) ),
+ aBtnUp2 ( this, ScResId( BTN_UP2 ) ),
+ aBtnDown2 ( this, ScResId( BTN_DOWN2 ) ),
+ //
+ aFlSort3 ( this, ScResId( FL_SORT3 ) ),
+ aLbSort3 ( this, ScResId( LB_SORT3 ) ),
+ aBtnUp3 ( this, ScResId( BTN_UP3 ) ),
+ aBtnDown3 ( this, ScResId( BTN_DOWN3 ) ),
+
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ aStrRow ( ScResId( SCSTR_ROW ) ),
+ //
+ nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
+ pDlg ( (ScSortDlg*)(GetParent()->GetParent()) ),
+ pViewData ( NULL ),
+ rSortData ( ((const ScSortItem&)
+ rArgSet.Get( nWhichSort )).
+ GetSortData() ),
+ nFieldCount ( 0 ),
+ bHasHeader ( FALSE ),
+ bSortByRows ( FALSE )
+{
+ Init();
+ FreeResource();
+ SetExchangeSupport();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTabPageSortFields::~ScTabPageSortFields()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::Init()
+{
+ const ScSortItem& rSortItem = (const ScSortItem&)
+ GetItemSet().Get( nWhichSort );
+
+ pViewData = rSortItem.GetViewData();
+
+ DBG_ASSERT( pViewData, "ViewData not found!" );
+
+ nFieldArr[0] = 0;
+ nFirstCol = 0;
+ nFirstRow = 0;
+
+ aLbSort1.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+ aLbSort2.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+ aLbSort3.SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+ aLbSort1.Clear();
+ aLbSort2.Clear();
+ aLbSort3.Clear();
+
+ aSortLbArr[0] = &aLbSort1;
+ aSortLbArr[1] = &aLbSort2;
+ aSortLbArr[2] = &aLbSort3;
+ aDirBtnArr[0][0] = &aBtnUp1;
+ aDirBtnArr[0][1] = &aBtnDown1;
+ aDirBtnArr[1][0] = &aBtnUp2;
+ aDirBtnArr[1][1] = &aBtnDown2;
+ aDirBtnArr[2][0] = &aBtnUp3;
+ aDirBtnArr[2][1] = &aBtnDown3;
+ aFlArr[0] = &aFlSort1;
+ aFlArr[1] = &aFlSort2;
+ aFlArr[2] = &aFlSort3;
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTabPageSortFields::GetRanges()
+{
+ return pSortRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTabPageSortFields::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTabPageSortFields( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
+{
+ bSortByRows = rSortData.bByRow;
+ bHasHeader = rSortData.bHasHeader;
+
+ if ( aLbSort1.GetEntryCount() == 0 )
+ FillFieldLists();
+
+ // Selektieren der ListBoxen:
+
+ if ( rSortData.bDoSort[0] )
+ {
+ for ( USHORT i=0; i<3; i++ )
+ {
+ if ( rSortData.bDoSort[i] )
+ {
+ aSortLbArr[i]->SelectEntryPos(
+ GetFieldSelPos( rSortData.nField[i] ) );
+
+ (rSortData.bAscending[i])
+ ? aDirBtnArr[i][0]->Check() // Up
+ : aDirBtnArr[i][1]->Check(); // Down
+ }
+ else
+ {
+ aSortLbArr[i]->SelectEntryPos( 0 ); // "keiner" selektieren
+ aDirBtnArr[i][0]->Check(); // Up
+ }
+ }
+
+ EnableField( 1 );
+ EnableField( 2 );
+ EnableField( 3 );
+ if ( aLbSort1.GetSelectEntryPos() == 0 )
+ DisableField( 2 );
+ if ( aLbSort2.GetSelectEntryPos() == 0 )
+ DisableField( 3 );
+ }
+ else
+ {
+ SCCOL nCol = pViewData->GetCurX();
+
+ if( nCol < rSortData.nCol1 )
+ nCol = rSortData.nCol1;
+ else if( nCol > rSortData.nCol2 )
+ nCol = rSortData.nCol2;
+
+ USHORT nSort1Pos = nCol - rSortData.nCol1+1;
+ aLbSort1.SelectEntryPos( nSort1Pos );
+ aLbSort2.SelectEntryPos( 0 );
+ aLbSort3.SelectEntryPos( 0 );
+ aBtnUp1.Check();
+ aBtnUp2.Check();
+ aBtnUp3.Check();
+ EnableField ( 1 );
+ EnableField ( 2 );
+ DisableField( 3 );
+ }
+
+ if ( pDlg )
+ {
+ pDlg->SetByRows ( bSortByRows );
+ pDlg->SetHeaders( bHasHeader );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTabPageSortFields::FillItemSet( SfxItemSet& rArgSet )
+{
+ ScSortParam theSortData = rSortData;
+ if (pDlg)
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSortData = ((const ScSortItem*)pItem)->GetSortData();
+ }
+
+ USHORT nSort1Pos = aLbSort1.GetSelectEntryPos();
+ USHORT nSort2Pos = aLbSort2.GetSelectEntryPos();
+ USHORT nSort3Pos = aLbSort3.GetSelectEntryPos();
+
+ DBG_ASSERT( (nSort1Pos <= SC_MAXFIELDS)
+ && (nSort2Pos <= SC_MAXFIELDS)
+ && (nSort3Pos <= SC_MAXFIELDS),
+ "Array-Range Fehler!" );
+
+ if ( nSort1Pos == LISTBOX_ENTRY_NOTFOUND ) nSort1Pos = 0;
+ if ( nSort2Pos == LISTBOX_ENTRY_NOTFOUND ) nSort2Pos = 0;
+ if ( nSort3Pos == LISTBOX_ENTRY_NOTFOUND ) nSort3Pos = 0;
+
+ if ( nSort1Pos > 0 )
+ {
+ theSortData.bDoSort[0] = (nSort1Pos > 0);
+ theSortData.bDoSort[1] = (nSort2Pos > 0);
+ theSortData.bDoSort[2] = (nSort3Pos > 0);
+
+ // wenn auf Optionen-Seite "OK" gewaehlt wurde und
+ // dabei die Sortierrichtung umgestellt wurde, so
+ // wird das erste Feld der jeweiligen Richtung als
+ // Sortierkriterium gewaehlt (steht in nFieldArr[0]):
+ if ( bSortByRows != pDlg->GetByRows() )
+ {
+ theSortData.nField[0] =
+ theSortData.nField[1] =
+ theSortData.nField[2] = ( bSortByRows ?
+ static_cast<SCCOLROW>(nFirstRow) :
+ static_cast<SCCOLROW>(nFirstCol) );
+ }
+ else
+ {
+ theSortData.nField[0] = nFieldArr[nSort1Pos];
+ theSortData.nField[1] = nFieldArr[nSort2Pos];
+ theSortData.nField[2] = nFieldArr[nSort3Pos];
+ }
+
+ theSortData.bAscending[0] = aBtnUp1.IsChecked();
+ theSortData.bAscending[1] = aBtnUp2.IsChecked();
+ theSortData.bAscending[2] = aBtnUp3.IsChecked();
+ // bHasHeader ist in ScTabPageSortOptions::FillItemSet, wo es hingehoert
+ }
+ else
+ {
+ theSortData.bDoSort[0] =
+ theSortData.bDoSort[1] =
+ theSortData.bDoSort[2] = FALSE;
+ }
+
+ rArgSet.Put( ScSortItem( SCITEM_SORTDATA, NULL, &theSortData ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
+// void ScTabPageSortFields::ActivatePage( const SfxItemSet& rSet )
+
+void __EXPORT ScTabPageSortFields::ActivatePage()
+{
+ if ( pDlg )
+ {
+ if ( bHasHeader != pDlg->GetHeaders()
+ || bSortByRows != pDlg->GetByRows() )
+ {
+ USHORT nCurSel1 = aLbSort1.GetSelectEntryPos();
+ USHORT nCurSel2 = aLbSort2.GetSelectEntryPos();
+ USHORT nCurSel3 = aLbSort3.GetSelectEntryPos();
+
+ bHasHeader = pDlg->GetHeaders();
+ bSortByRows = pDlg->GetByRows();
+ FillFieldLists();
+ aLbSort1.SelectEntryPos( nCurSel1 );
+ aLbSort2.SelectEntryPos( nCurSel2 );
+ aLbSort3.SelectEntryPos( nCurSel3 );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+int __EXPORT ScTabPageSortFields::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pDlg )
+ {
+ if ( bHasHeader != pDlg->GetHeaders() )
+ pDlg->SetHeaders( bHasHeader );
+
+ if ( bSortByRows != pDlg->GetByRows() )
+ pDlg->SetByRows( bSortByRows );
+ }
+
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return SfxTabPage::LEAVE_PAGE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::DisableField( USHORT nField )
+{
+ nField--;
+
+ if ( nField<=2 )
+ {
+ aSortLbArr[nField] ->Disable();
+ aDirBtnArr[nField][0]->Disable();
+ aDirBtnArr[nField][1]->Disable();
+ aFlArr[nField] ->Disable();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::EnableField( USHORT nField )
+{
+ nField--;
+
+ if ( nField<=2 )
+ {
+ aSortLbArr[nField] ->Enable();
+ aDirBtnArr[nField][0]->Enable();
+ aDirBtnArr[nField][1]->Enable();
+ aFlArr[nField] ->Enable();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortFields::FillFieldLists()
+{
+ if ( pViewData )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ if ( pDoc )
+ {
+ aLbSort1.Clear();
+ aLbSort2.Clear();
+ aLbSort3.Clear();
+ aLbSort1.InsertEntry( aStrUndefined, 0 );
+ aLbSort2.InsertEntry( aStrUndefined, 0 );
+ aLbSort3.InsertEntry( aStrUndefined, 0 );
+
+ SCCOL nFirstSortCol = rSortData.nCol1;
+ SCROW nFirstSortRow = rSortData.nRow1;
+ SCTAB nTab = pViewData->GetTabNo();
+ USHORT i = 1;
+
+ if ( bSortByRows )
+ {
+ String aFieldName;
+ SCCOL nMaxCol = rSortData.nCol2;
+ SCCOL col;
+
+ for ( col=nFirstSortCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
+ {
+ pDoc->GetString( col, nFirstSortRow, nTab, aFieldName );
+ if ( !bHasHeader || (aFieldName.Len() == 0) )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ScColToAlpha( col );
+ }
+ nFieldArr[i] = col;
+ aLbSort1.InsertEntry( aFieldName, i );
+ aLbSort2.InsertEntry( aFieldName, i );
+ aLbSort3.InsertEntry( aFieldName, i );
+ i++;
+ }
+ }
+ else
+ {
+ String aFieldName;
+ SCROW nMaxRow = rSortData.nRow2;
+ SCROW row;
+
+ for ( row=nFirstSortRow; row<=nMaxRow && i<SC_MAXFIELDS; row++ )
+ {
+ pDoc->GetString( nFirstSortCol, row, nTab, aFieldName );
+ if ( !bHasHeader || (aFieldName.Len() == 0) )
+ {
+ aFieldName = aStrRow;
+ aFieldName += ' ';
+ aFieldName += String::CreateFromInt32( row+1 );
+ }
+ nFieldArr[i] = row;
+ aLbSort1.InsertEntry( aFieldName, i );
+ aLbSort2.InsertEntry( aFieldName, i );
+ aLbSort3.InsertEntry( aFieldName, i );
+ i++;
+ }
+ }
+ nFieldCount = i;
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
+{
+ USHORT nFieldPos = 0;
+ BOOL bFound = FALSE;
+
+ for ( USHORT n=1; n<nFieldCount && !bFound; n++ )
+ {
+ if ( nFieldArr[n] == nField )
+ {
+ nFieldPos = n;
+ bFound = TRUE;
+ }
+ }
+
+ return nFieldPos;
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
+{
+ String aSelEntry = pLb->GetSelectEntry();
+
+ if ( pLb == &aLbSort1 )
+ {
+ if ( aSelEntry == aStrUndefined )
+ {
+ aLbSort2.SelectEntryPos( 0 );
+ aLbSort3.SelectEntryPos( 0 );
+
+ if ( aFlSort2.IsEnabled() )
+ DisableField( 2 );
+
+ if ( aFlSort3.IsEnabled() )
+ DisableField( 3 );
+ }
+ else
+ {
+ if ( !aFlSort2.IsEnabled() )
+ EnableField( 2 );
+ }
+ }
+ else if ( pLb == &aLbSort2 )
+ {
+ if ( aSelEntry == aStrUndefined )
+ {
+ aLbSort3.SelectEntryPos( 0 );
+ if ( aFlSort3.IsEnabled() )
+ DisableField( 3 );
+ }
+ else
+ {
+ if ( !aFlSort3.IsEnabled() )
+ EnableField( 3 );
+ }
+ }
+ return 0;
+}
+
+//========================================================================
+// Sortieroptionen-Tabpage:
+//========================================================================
+
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef SfxTabPage
+#define SfxTabPage( parent, id, args ) SfxTabPage( parent, "sort-options.xml", id, &args )
+#endif /* ENABLE_LAYOUT */
+
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+
+ScTabPageSortOptions::ScTabPageSortOptions( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_SORT_OPTIONS ),
+ rArgSet ),
+ //
+ aBtnCase ( this, ScResId( BTN_CASESENSITIVE ) ),
+ aBtnHeader ( this, ScResId( BTN_LABEL ) ),
+ aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
+ aBtnNaturalSort ( this, ScResId( BTN_NATURALSORT ) ),
+ aBtnCopyResult ( this, ScResId( BTN_COPYRESULT ) ),
+ aLbOutPos ( this, ScResId( LB_OUTAREA ) ),
+ aEdOutPos ( this, ScResId( ED_OUTAREA ) ),
+ aBtnSortUser ( this, ScResId( BTN_SORT_USER ) ),
+ aLbSortUser ( this, ScResId( LB_SORT_USER ) ),
+ aFtLanguage ( this, ScResId( FT_LANGUAGE ) ),
+ aLbLanguage ( this, ScResId( LB_LANGUAGE ) ),
+ aFtAlgorithm ( this, ScResId( FT_ALGORITHM ) ),
+ aLbAlgorithm ( this, ScResId( LB_ALGORITHM ) ),
+ aLineDirection ( this, ScResId( FL_DIRECTION ) ),
+ aBtnTopDown ( this, ScResId( BTN_TOP_DOWN ) ),
+ aBtnLeftRight ( this, ScResId( BTN_LEFT_RIGHT ) ),
+// aFtAreaLabel ( this, ScResId( FT_AREA_LABEL ) ),
+// aFtArea ( this, ScResId( FT_AREA ) ),
+ //
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#undef this
+#undef ScResId
+#define ScResId(x) this, #x
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+ aStrRowLabel ( ScResId( STR_ROW_LABEL ) ),
+ aStrColLabel ( ScResId( STR_COL_LABEL ) ),
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ),
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ),
+ //
+ nWhichSort ( rArgSet.GetPool()->GetWhich( SID_SORT ) ),
+ rSortData ( ((const ScSortItem&)
+ rArgSet.Get( nWhichSort )).GetSortData() ),
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ pDlg ( (ScSortDlg*)(GetParent() ? GetParent()->GetParent() : 0 ) ),
+ pColRes ( NULL ),
+ pColWrap ( NULL )
+{
+ Init();
+ FreeResource();
+ SetExchangeSupport();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTabPageSortOptions::~ScTabPageSortOptions()
+{
+ USHORT nEntries = aLbOutPos.GetEntryCount();
+
+ for ( USHORT i=1; i<nEntries; i++ )
+ delete (String*)aLbOutPos.GetEntryData( i );
+
+ delete pColRes;
+ delete pColWrap; //! not if from document
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortOptions::Init()
+{
+// aStrAreaLabel = aFtAreaLabel.GetText();
+// aStrAreaLabel.Append( (sal_Unicode) ' ' );
+
+ // CollatorRessource has user-visible names for sort algorithms
+ pColRes = new CollatorRessource();
+
+ //! use CollatorWrapper from document?
+ pColWrap = new CollatorWrapper( comphelper::getProcessServiceFactory() );
+
+ const ScSortItem& rSortItem = (const ScSortItem&)
+ GetItemSet().Get( nWhichSort );
+
+ aLbOutPos.SetSelectHdl ( LINK( this, ScTabPageSortOptions, SelOutPosHdl ) );
+ aBtnCopyResult.SetClickHdl( LINK( this, ScTabPageSortOptions, EnableHdl ) );
+ aBtnSortUser.SetClickHdl ( LINK( this, ScTabPageSortOptions, EnableHdl ) );
+ aBtnTopDown.SetClickHdl ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
+ aBtnLeftRight.SetClickHdl ( LINK( this, ScTabPageSortOptions, SortDirHdl ) );
+ aLbLanguage.SetSelectHdl ( LINK( this, ScTabPageSortOptions, FillAlgorHdl ) );
+
+ pViewData = rSortItem.GetViewData();
+ pDoc = pViewData ? pViewData->GetDocument() : NULL;
+
+ DBG_ASSERT( pViewData, "ViewData not found! :-/" );
+
+ if ( pViewData && pDoc )
+ {
+ String theArea;
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ String theDbArea;
+ String theDbName = aStrNoName;
+ const SCTAB nCurTab = pViewData->GetTabNo();
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ aLbOutPos.Clear();
+ aLbOutPos.InsertEntry( aStrUndefined, 0 );
+ aLbOutPos.Disable();
+
+ ScAreaNameIterator aIter( pDoc );
+ String aName;
+ ScRange aRange;
+ String aRefStr;
+ while ( aIter.Next( aName, aRange ) )
+ {
+ USHORT nInsert = aLbOutPos.InsertEntry( aName );
+
+ aRange.aStart.Format( aRefStr, SCA_ABS_3D, pDoc, eConv );
+ aLbOutPos.SetEntryData( nInsert, new String( aRefStr ) );
+ }
+
+ aLbOutPos.SelectEntryPos( 0 );
+ aEdOutPos.SetText( EMPTY_STRING );
+
+ /*
+ * Ueberpruefen, ob es sich bei dem uebergebenen
+ * Bereich um einen Datenbankbereich handelt:
+ */
+
+ ScAddress aScAddress( rSortData.nCol1, rSortData.nRow1, nCurTab );
+ ScRange( aScAddress,
+ ScAddress( rSortData.nCol2, rSortData.nRow2, nCurTab )
+ ).Format( theArea, SCR_ABS, pDoc, eConv );
+
+ if ( pDBColl )
+ {
+ ScDBData* pDBData
+ = pDBColl->GetDBAtArea( nCurTab,
+ rSortData.nCol1, rSortData.nRow1,
+ rSortData.nCol2, rSortData.nRow2 );
+ if ( pDBData )
+ {
+ pDBData->GetName( theDbName );
+ aBtnHeader.Check( pDBData->HasHeader() );
+ }
+ }
+
+ theArea.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" ("));
+ theArea += theDbName;
+ theArea += ')';
+
+ //aFtArea.SetText( theArea );
+ //theArea.Insert( aStrAreaLabel, 0 );
+ //aFtAreaLabel.SetText( theArea );
+
+ aBtnHeader.SetText( aStrColLabel );
+ }
+
+ FillUserSortListBox();
+
+ // get available languages
+
+ aLbLanguage.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE );
+ aLbLanguage.InsertLanguage( LANGUAGE_SYSTEM );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTabPageSortOptions::GetRanges()
+{
+ return pSortRanges;
+}
+
+// -----------------------------------------------------------------------
+
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#undef SfxTabPage
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+SfxTabPage* __EXPORT ScTabPageSortOptions::Create(
+ Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTabPageSortOptions( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabPageSortOptions::Reset( const SfxItemSet& /* rArgSet */ )
+{
+ if ( rSortData.bUserDef )
+ {
+ aBtnSortUser.Check( TRUE );
+ aLbSortUser.Enable();
+ aLbSortUser.SelectEntryPos( rSortData.nUserIndex );
+ }
+ else
+ {
+ aBtnSortUser.Check( FALSE );
+ aLbSortUser.Disable();
+ aLbSortUser.SelectEntryPos( 0 );
+ }
+
+ aBtnCase.Check ( rSortData.bCaseSens );
+ aBtnFormats.Check ( rSortData.bIncludePattern );
+ aBtnHeader.Check ( rSortData.bHasHeader );
+ aBtnNaturalSort.Check ( rSortData.bNaturalSort );
+
+ if ( rSortData.bByRow )
+ {
+ aBtnTopDown.Check();
+ aBtnHeader.SetText( aStrColLabel );
+ }
+ else
+ {
+ aBtnLeftRight.Check();
+ aBtnHeader.SetText( aStrRowLabel );
+ }
+
+ LanguageType eLang = MsLangId::convertLocaleToLanguage( rSortData.aCollatorLocale );
+ if ( eLang == LANGUAGE_DONTKNOW )
+ eLang = LANGUAGE_SYSTEM;
+ aLbLanguage.SelectLanguage( eLang );
+ FillAlgorHdl( &aLbLanguage ); // get algorithms, select default
+ if ( rSortData.aCollatorAlgorithm.Len() )
+ aLbAlgorithm.SelectEntry( pColRes->GetTranslation( rSortData.aCollatorAlgorithm ) );
+
+ if ( pDoc && !rSortData.bInplace )
+ {
+ String aStr;
+ USHORT nFormat = (rSortData.nDestTab != pViewData->GetTabNo())
+ ? SCR_ABS_3D
+ : SCR_ABS;
+
+ theOutPos.Set( rSortData.nDestCol,
+ rSortData.nDestRow,
+ rSortData.nDestTab );
+
+ theOutPos.Format( aStr, nFormat, pDoc, pDoc->GetAddressConvention() );
+ aBtnCopyResult.Check();
+ aLbOutPos.Enable();
+ aEdOutPos.Enable();
+ aEdOutPos.SetText( aStr );
+ EdOutPosModHdl( &aEdOutPos );
+ aEdOutPos.GrabFocus();
+ aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ else
+ {
+ aBtnCopyResult.Check( FALSE );
+ aLbOutPos.Disable();
+ aEdOutPos.Disable();
+ aEdOutPos.SetText( EMPTY_STRING );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTabPageSortOptions::FillItemSet( SfxItemSet& rArgSet )
+{
+ ScSortParam theSortData = rSortData;
+ if (pDlg)
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSort, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSortData = ((const ScSortItem*)pItem)->GetSortData();
+ }
+
+ theSortData.bByRow = aBtnTopDown.IsChecked();
+ theSortData.bHasHeader = aBtnHeader.IsChecked();
+ theSortData.bCaseSens = aBtnCase.IsChecked();
+ theSortData.bNaturalSort = aBtnNaturalSort.IsChecked();
+ theSortData.bIncludePattern = aBtnFormats.IsChecked();
+ theSortData.bInplace = !aBtnCopyResult.IsChecked();
+ theSortData.nDestCol = theOutPos.Col();
+ theSortData.nDestRow = theOutPos.Row();
+ theSortData.nDestTab = theOutPos.Tab();
+ theSortData.bUserDef = aBtnSortUser.IsChecked();
+ theSortData.nUserIndex = (aBtnSortUser.IsChecked())
+ ? aLbSortUser.GetSelectEntryPos()
+ : 0;
+
+ // get locale
+ LanguageType eLang = aLbLanguage.GetSelectLanguage();
+ theSortData.aCollatorLocale = MsLangId::convertLanguageToLocale( eLang, false );
+
+ // get algorithm
+ String sAlg;
+ if ( eLang != LANGUAGE_SYSTEM )
+ {
+ uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms(
+ theSortData.aCollatorLocale );
+ USHORT nSel = aLbAlgorithm.GetSelectEntryPos();
+ if ( nSel < aAlgos.getLength() )
+ sAlg = aAlgos[nSel];
+ }
+ theSortData.aCollatorAlgorithm = sAlg;
+
+ rArgSet.Put( ScSortItem( SCITEM_SORTDATA, &theSortData ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+// fuer Datenaustausch ohne Dialog-Umweg: (! noch zu tun !)
+// void ScTabPageSortOptions::ActivatePage( const SfxItemSet& rSet )
+void __EXPORT ScTabPageSortOptions::ActivatePage()
+{
+ if ( pDlg )
+ {
+ if ( aBtnHeader.IsChecked() != pDlg->GetHeaders() )
+ {
+ aBtnHeader.Check( pDlg->GetHeaders() );
+ }
+
+ if ( aBtnTopDown.IsChecked() != pDlg->GetByRows() )
+ {
+ aBtnTopDown.Check( pDlg->GetByRows() );
+ aBtnLeftRight.Check( !pDlg->GetByRows() );
+ }
+
+ aBtnHeader.SetText( (pDlg->GetByRows())
+ ? aStrColLabel
+ : aStrRowLabel );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+int __EXPORT ScTabPageSortOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ BOOL bPosInputOk = TRUE;
+
+ if ( aBtnCopyResult.IsChecked() )
+ {
+ String thePosStr = aEdOutPos.GetText();
+ ScAddress thePos;
+ xub_StrLen nColonPos = thePosStr.Search( ':' );
+
+ if ( STRING_NOTFOUND != nColonPos )
+ thePosStr.Erase( nColonPos );
+
+ if ( pViewData )
+ {
+ // visible table is default for input without table
+ // must be changed to GetRefTabNo when sorting has RefInput!
+ thePos.SetTab( pViewData->GetTabNo() );
+ }
+
+ USHORT nResult = thePos.Parse( thePosStr, pDoc, pDoc->GetAddressConvention() );
+
+ bPosInputOk = ( SCA_VALID == (nResult & SCA_VALID) );
+
+ if ( !bPosInputOk )
+ {
+#if !ENABLE_LAYOUT_EXPERIMENTAL
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_INVALID_TABREF )
+ ).Execute();
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+ aEdOutPos.GrabFocus();
+ aEdOutPos.SetSelection( Selection( 0, SELECTION_MAX ) );
+ theOutPos.Set(0,0,0);
+ }
+ else
+ {
+ aEdOutPos.SetText( thePosStr );
+ theOutPos = thePos;
+ }
+ }
+
+ if ( pDlg && bPosInputOk )
+ {
+ pDlg->SetHeaders( aBtnHeader.IsChecked() );
+ pDlg->SetByRows ( aBtnTopDown.IsChecked() );
+ }
+
+ if ( pSetP && bPosInputOk )
+ FillItemSet( *pSetP );
+
+ return bPosInputOk ? SfxTabPage::LEAVE_PAGE : SfxTabPage::KEEP_PAGE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTabPageSortOptions::FillUserSortListBox()
+{
+ ScUserList* pUserLists = ScGlobal::GetUserList();
+
+ aLbSortUser.Clear();
+ if ( pUserLists )
+ {
+ USHORT nCount = pUserLists->GetCount();
+ if ( nCount > 0 )
+ for ( USHORT i=0; i<nCount; i++ )
+ aLbSortUser.InsertEntry( (*pUserLists)[i]->GetString() );
+ }
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTabPageSortOptions, EnableHdl, CheckBox *, pBox )
+{
+ if ( pBox == &aBtnCopyResult )
+ {
+ if ( pBox->IsChecked() )
+ {
+ aLbOutPos.Enable();
+ aEdOutPos.Enable();
+ aEdOutPos.GrabFocus();
+ }
+ else
+ {
+ aLbOutPos.Disable();
+ aEdOutPos.Disable();
+ }
+ }
+ else if ( pBox == &aBtnSortUser )
+ {
+ if ( pBox->IsChecked() )
+ {
+ aLbSortUser.Enable();
+ aLbSortUser.GrabFocus();
+ }
+ else
+ aLbSortUser.Disable();
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageSortOptions, SelOutPosHdl, ListBox *, pLb )
+{
+ if ( pLb == &aLbOutPos )
+ {
+ String aString;
+ USHORT nSelPos = aLbOutPos.GetSelectEntryPos();
+
+ if ( nSelPos > 0 )
+ aString = *(String*)aLbOutPos.GetEntryData( nSelPos );
+
+ aEdOutPos.SetText( aString );
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageSortOptions, SortDirHdl, RadioButton *, pBtn )
+{
+ if ( pBtn == &aBtnTopDown )
+ {
+ aBtnHeader.SetText( aStrColLabel );
+ }
+ else if ( pBtn == &aBtnLeftRight )
+ {
+ aBtnHeader.SetText( aStrRowLabel );
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabPageSortOptions::EdOutPosModHdl( Edit* pEd )
+{
+ if ( pEd == &aEdOutPos )
+ {
+ String theCurPosStr = aEdOutPos.GetText();
+ USHORT nResult = ScAddress().Parse( theCurPosStr, pDoc, pDoc->GetAddressConvention() );
+
+ if ( SCA_VALID == (nResult & SCA_VALID) )
+ {
+ String* pStr = NULL;
+ BOOL bFound = FALSE;
+ USHORT i = 0;
+ USHORT nCount = aLbOutPos.GetEntryCount();
+
+ for ( i=2; i<nCount && !bFound; i++ )
+ {
+ pStr = (String*)aLbOutPos.GetEntryData( i );
+ bFound = (theCurPosStr == *pStr);
+ }
+
+ if ( bFound )
+ aLbOutPos.SelectEntryPos( --i );
+ else
+ aLbOutPos.SelectEntryPos( 0 );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTabPageSortOptions, FillAlgorHdl, void *, EMPTYARG )
+{
+ aLbAlgorithm.SetUpdateMode( FALSE );
+ aLbAlgorithm.Clear();
+
+ LanguageType eLang = aLbLanguage.GetSelectLanguage();
+ if ( eLang == LANGUAGE_SYSTEM )
+ {
+ // for LANGUAGE_SYSTEM no algorithm can be selected because
+ // it wouldn't necessarily exist for other languages
+ // -> leave list box empty if LANGUAGE_SYSTEM is selected
+ aFtAlgorithm.Enable( FALSE ); // nothing to select
+ aLbAlgorithm.Enable( FALSE ); // nothing to select
+ }
+ else
+ {
+ lang::Locale aLocale( MsLangId::convertLanguageToLocale( eLang ));
+ uno::Sequence<rtl::OUString> aAlgos = pColWrap->listCollatorAlgorithms( aLocale );
+
+ long nCount = aAlgos.getLength();
+ const rtl::OUString* pArray = aAlgos.getConstArray();
+ for (long i=0; i<nCount; i++)
+ {
+ String sAlg = pArray[i];
+ String sUser = pColRes->GetTranslation( sAlg );
+ aLbAlgorithm.InsertEntry( sUser, LISTBOX_APPEND );
+ }
+ aLbAlgorithm.SelectEntryPos( 0 ); // first entry is default
+ aFtAlgorithm.Enable( nCount > 1 ); // enable only if there is a choice
+ aLbAlgorithm.Enable( nCount > 1 ); // enable only if there is a choice
+ }
+
+ aLbAlgorithm.SetUpdateMode( TRUE );
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx
new file mode 100644
index 000000000000..cceac3df79e5
--- /dev/null
+++ b/sc/source/ui/dbgui/tpsubt.cxx
@@ -0,0 +1,688 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "scitems.hxx"
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "userlist.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot IDs
+
+#include "subtdlg.hxx"
+#include "subtdlg.hrc"
+#include "tpsubt.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pSubTotalsRanges[] =
+{
+ SID_SUBTOTALS,
+ SID_SUBTOTALS,
+ 0
+};
+
+//========================================================================
+// Zwischenergebnisgruppen-Tabpage:
+
+ScTpSubTotalGroup::ScTpSubTotalGroup( Window* pParent, USHORT nResId,
+ const SfxItemSet& rArgSet )
+ : SfxTabPage ( pParent,
+ ScResId( nResId ),
+ rArgSet ),
+ //
+ aFtGroup ( this, ScResId( FT_GROUP ) ),
+ aLbGroup ( this, ScResId( LB_GROUP ) ),
+ aFtColumns ( this, ScResId( FT_COLUMNS ) ),
+ aLbColumns ( this, ScResId( WND_COLUMNS ) ),
+ aFtFunctions ( this, ScResId( FT_FUNCTIONS ) ),
+ aLbFunctions ( this, ScResId( LB_FUNCTIONS ) ),
+ aStrNone ( ScResId( SCSTR_NONE ) ),
+ aStrColumn ( ScResId( SCSTR_COLUMN ) ),
+ //
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
+ rSubTotalData ( ((const ScSubTotalItem&)
+ rArgSet.Get( nWhichSubTotals )).
+ GetSubTotalData() ),
+ nFieldCount ( 0 )
+{
+ // Font is correctly initialized by SvTreeListBox ctor
+ aLbColumns.SetSelectionMode( SINGLE_SELECTION );
+ aLbColumns.SetDragDropMode( SV_DRAGDROP_NONE );
+ aLbColumns.SetSpaceBetweenEntries( 0 );
+ aLbColumns.Show();
+
+ Init ();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTpSubTotalGroup::~ScTpSubTotalGroup()
+{
+ USHORT nCount = (USHORT)aLbColumns.GetEntryCount();
+
+ if ( nCount > 0 )
+ {
+ USHORT* pData = NULL;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (USHORT*)(aLbColumns.GetEntryData( i ));
+ DBG_ASSERT( pData, "EntryData not found" );
+
+ delete pData;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalGroup::Init()
+{
+ const ScSubTotalItem& rSubTotalItem = (const ScSubTotalItem&)
+ GetItemSet().Get( nWhichSubTotals );
+
+ pViewData = rSubTotalItem.GetViewData();
+ pDoc = ( pViewData ) ? pViewData->GetDocument() : NULL;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData or Document not found :-(" );
+
+ aLbGroup.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
+ aLbColumns.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
+ aLbColumns.SetCheckButtonHdl ( LINK( this, ScTpSubTotalGroup, CheckHdl ) );
+ aLbFunctions.SetSelectHdl ( LINK( this, ScTpSubTotalGroup, SelectHdl ) );
+
+ nFieldArr[0] = 0;
+ FillListBoxes();
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTpSubTotalGroup::GetRanges()
+{
+ return pSubTotalsRanges;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScTpSubTotalGroup::DoReset( USHORT nGroupNo,
+ const SfxItemSet& rArgSet )
+{
+ USHORT nGroupIdx = 0;
+
+ DBG_ASSERT( (nGroupNo<=3) && (nGroupNo>0), "Invalid group" );
+
+ if ( (nGroupNo > 3) || (nGroupNo == 0) )
+ return FALSE;
+ else
+ nGroupIdx = nGroupNo-1;
+
+ //----------------------------------------------------------
+
+ // #79058# first we have to clear the listboxes...
+ for ( USHORT nLbEntry = 0; nLbEntry < aLbColumns.GetEntryCount(); ++nLbEntry )
+ {
+ aLbColumns.CheckEntryPos( nLbEntry, FALSE );
+ *((USHORT*)aLbColumns.GetEntryData( nLbEntry )) = 0;
+ }
+ aLbFunctions.SelectEntryPos( 0 );
+
+ ScSubTotalParam theSubTotalData( ((const ScSubTotalItem&)
+ rArgSet.Get( nWhichSubTotals )).
+ GetSubTotalData() );
+
+ if ( theSubTotalData.bGroupActive[nGroupIdx] )
+ {
+ SCCOL nField = theSubTotalData.nField[nGroupIdx];
+ SCCOL nSubTotals = theSubTotalData.nSubTotals[nGroupIdx];
+ SCCOL* pSubTotals = theSubTotalData.pSubTotals[nGroupIdx];
+ ScSubTotalFunc* pFunctions = theSubTotalData.pFunctions[nGroupIdx];
+
+ aLbGroup.SelectEntryPos( GetFieldSelPos( nField )+1 );
+
+ for ( USHORT i=0; i<nSubTotals; i++ )
+ {
+ USHORT nCheckPos = GetFieldSelPos( pSubTotals[i] );
+ USHORT* pFunction = (USHORT*)aLbColumns.GetEntryData( nCheckPos );
+
+ aLbColumns.CheckEntryPos( nCheckPos );
+ *pFunction = FuncToLbPos( pFunctions[i] );
+ }
+ aLbColumns.SelectEntryPos( 0 );
+ }
+ else
+ {
+ aLbGroup.SelectEntryPos( (nGroupNo == 1) ? 1 : 0 );
+ aLbColumns.SelectEntryPos( 0 );
+ aLbFunctions.SelectEntryPos( 0 );
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScTpSubTotalGroup::DoFillItemSet( USHORT nGroupNo,
+ SfxItemSet& rArgSet )
+{
+ USHORT nGroupIdx = 0;
+
+ DBG_ASSERT( (nGroupNo<=3) && (nGroupNo>0), "Invalid group" );
+ DBG_ASSERT( (aLbGroup.GetEntryCount() > 0)
+ && (aLbColumns.GetEntryCount() > 0)
+ && (aLbFunctions.GetEntryCount() > 0),
+ "Non-initialized Lists" );
+
+
+ if ( (nGroupNo > 3) || (nGroupNo == 0)
+ || (aLbGroup.GetEntryCount() == 0)
+ || (aLbColumns.GetEntryCount() == 0)
+ || (aLbFunctions.GetEntryCount() == 0)
+ )
+ return FALSE;
+ else
+ nGroupIdx = nGroupNo-1;
+
+ //----------------------------------------------------------
+
+ ScSubTotalParam theSubTotalData; // auslesen, wenn schon teilweise gefuellt
+ SfxTabDialog* pDlg = GetTabDialog();
+ if ( pDlg )
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSubTotals, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSubTotalData = ((const ScSubTotalItem*)pItem)->GetSubTotalData();
+ }
+
+ ScSubTotalFunc* pFunctions = NULL;
+ SCCOL* pSubTotals = NULL;
+ USHORT nGroup = aLbGroup.GetSelectEntryPos();
+ USHORT nEntryCount = (USHORT)aLbColumns.GetEntryCount();
+ USHORT nCheckCount = aLbColumns.GetCheckedEntryCount();
+
+ theSubTotalData.nCol1 = rSubTotalData.nCol1;
+ theSubTotalData.nRow1 = rSubTotalData.nRow1;
+ theSubTotalData.nCol2 = rSubTotalData.nCol2;
+ theSubTotalData.nRow2 = rSubTotalData.nRow2;
+ theSubTotalData.bGroupActive[nGroupIdx] = (nGroup != 0);
+ theSubTotalData.nField[nGroupIdx] = (nGroup != 0)
+ ? nFieldArr[nGroup-1]
+ : static_cast<SCCOL>(0);
+
+ if ( nEntryCount>0 && nCheckCount>0 && nGroup!=0 )
+ {
+ USHORT nFunction = 0;
+
+ pSubTotals = new SCCOL [nCheckCount];
+ pFunctions = new ScSubTotalFunc [nCheckCount];
+
+ for ( USHORT i=0, nCheck=0; i<nEntryCount; i++ )
+ {
+ if ( aLbColumns.IsChecked( i ) )
+ {
+ DBG_ASSERT( nCheck <= nCheckCount,
+ "Range error :-(" );
+ nFunction = *((USHORT*)aLbColumns.GetEntryData( i ));
+ pSubTotals[nCheck] = nFieldArr[i];
+ pFunctions[nCheck] = LbPosToFunc( nFunction );
+ nCheck++;
+ }
+ }
+ theSubTotalData.SetSubTotals( nGroupNo, // Gruppen-Nr.
+ pSubTotals,
+ pFunctions,
+ nCheckCount ); // Anzahl der Array-Elemente
+
+ }
+
+ rArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, &theSubTotalData ) );
+
+ if ( pSubTotals ) delete [] pSubTotals;
+ if ( pFunctions ) delete [] pFunctions;
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalGroup::FillListBoxes()
+{
+ DBG_ASSERT( pViewData && pDoc, "ViewData or Document not found :-/" );
+
+ if ( pViewData && pDoc )
+ {
+ SCCOL nFirstCol = rSubTotalData.nCol1;
+ SCROW nFirstRow = rSubTotalData.nRow1;
+ SCTAB nTab = pViewData->GetTabNo();
+ SCCOL nMaxCol = rSubTotalData.nCol2;
+ SCCOL col;
+ USHORT i=0;
+ String aFieldName;
+
+ aLbGroup.Clear();
+ aLbColumns.Clear();
+ aLbGroup.InsertEntry( aStrNone, 0 );
+
+ i=0;
+ for ( col=nFirstCol; col<=nMaxCol && i<SC_MAXFIELDS; col++ )
+ {
+ pDoc->GetString( col, nFirstRow, nTab, aFieldName );
+ if ( aFieldName.Len() == 0 )
+ {
+ aFieldName = aStrColumn;
+ aFieldName += ' ';
+ aFieldName += ::ScColToAlpha( col ); // from global.hxx
+ }
+ nFieldArr[i] = col;
+ aLbGroup.InsertEntry( aFieldName, i+1 );
+ aLbColumns.InsertEntry( aFieldName, i );
+ aLbColumns.SetEntryData( i, new USHORT(0) );
+ i++;
+ }
+ // Nachtraegliche "Konstanteninitialisierung":
+ (USHORT&)nFieldCount = i;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+USHORT ScTpSubTotalGroup::GetFieldSelPos( SCCOL nField )
+{
+ USHORT nFieldPos = 0;
+ BOOL bFound = FALSE;
+
+ for ( USHORT n=0; n<nFieldCount && !bFound; n++ )
+ {
+ if ( nFieldArr[n] == nField )
+ {
+ nFieldPos = n;
+ bFound = TRUE;
+ }
+ }
+
+ return nFieldPos;
+}
+
+// -----------------------------------------------------------------------
+
+ScSubTotalFunc ScTpSubTotalGroup::LbPosToFunc( USHORT nPos )
+{
+ switch ( nPos )
+ {
+// case 0: return SUBTOTAL_FUNC_NONE;
+ case 2: return SUBTOTAL_FUNC_AVE;
+ case 6: return SUBTOTAL_FUNC_CNT;
+ case 1: return SUBTOTAL_FUNC_CNT2;
+ case 3: return SUBTOTAL_FUNC_MAX;
+ case 4: return SUBTOTAL_FUNC_MIN;
+ case 5: return SUBTOTAL_FUNC_PROD;
+ case 7: return SUBTOTAL_FUNC_STD;
+ case 8: return SUBTOTAL_FUNC_STDP;
+ case 0: return SUBTOTAL_FUNC_SUM;
+ case 9: return SUBTOTAL_FUNC_VAR;
+ case 10: return SUBTOTAL_FUNC_VARP;
+ default:
+ DBG_ERROR( "ScTpSubTotalGroup::LbPosToFunc" );
+ return SUBTOTAL_FUNC_NONE;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+USHORT ScTpSubTotalGroup::FuncToLbPos( ScSubTotalFunc eFunc )
+{
+ switch ( eFunc )
+ {
+// case SUBTOTAL_FUNC_NONE: return 0;
+ case SUBTOTAL_FUNC_AVE: return 2;
+ case SUBTOTAL_FUNC_CNT: return 6;
+ case SUBTOTAL_FUNC_CNT2: return 1;
+ case SUBTOTAL_FUNC_MAX: return 3;
+ case SUBTOTAL_FUNC_MIN: return 4;
+ case SUBTOTAL_FUNC_PROD: return 5;
+ case SUBTOTAL_FUNC_STD: return 7;
+ case SUBTOTAL_FUNC_STDP: return 8;
+ case SUBTOTAL_FUNC_SUM: return 0;
+ case SUBTOTAL_FUNC_VAR: return 9;
+ case SUBTOTAL_FUNC_VARP: return 10;
+ default:
+ DBG_ERROR( "ScTpSubTotalGroup::FuncToLbPos" );
+ return 0;
+ }
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScTpSubTotalGroup, SelectHdl, ListBox *, pLb )
+{
+ if ( (aLbColumns.GetEntryCount() > 0)
+ && (aLbColumns.GetSelectionCount() > 0) )
+ {
+ USHORT nFunction = aLbFunctions.GetSelectEntryPos();
+ USHORT nColumn = aLbColumns.GetSelectEntryPos();
+ USHORT* pFunction = (USHORT*)aLbColumns.GetEntryData( nColumn );
+
+ DBG_ASSERT( pFunction, "EntryData nicht gefunden!" );
+ if ( !pFunction )
+ return 0;
+
+ if ( ((SvxCheckListBox*)pLb) == &aLbColumns )
+ {
+ aLbFunctions.SelectEntryPos( *pFunction );
+ }
+ else if ( pLb == &aLbFunctions )
+ {
+ *pFunction = nFunction;
+// aLbColumns.CheckEntryPos( nColumn, (nFunction != 0) );//XXX
+ aLbColumns.CheckEntryPos( nColumn, TRUE );
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTpSubTotalGroup, CheckHdl, ListBox *, pLb )
+{
+ if ( ((SvxCheckListBox*)pLb) == &aLbColumns )
+ {
+ SvLBoxEntry* pEntry = aLbColumns.GetHdlEntry();
+
+ if ( pEntry )
+ {
+ aLbColumns.SelectEntryPos( (USHORT)aLbColumns.GetModel()->GetAbsPos( pEntry ) );
+ SelectHdl( pLb );
+ }
+ }
+ return 0;
+}
+
+//========================================================================
+// Abgeleitete Gruppen-TabPages:
+
+SfxTabPage* __EXPORT ScTpSubTotalGroup1::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+ { return ( new ScTpSubTotalGroup1( pParent, rArgSet ) ); }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpSubTotalGroup2::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+ { return ( new ScTpSubTotalGroup2( pParent, rArgSet ) ); }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpSubTotalGroup3::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+ { return ( new ScTpSubTotalGroup3( pParent, rArgSet ) ); }
+
+// -----------------------------------------------------------------------
+
+ScTpSubTotalGroup1::ScTpSubTotalGroup1( Window* pParent, const SfxItemSet& rArgSet ) :
+ ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP1, rArgSet )
+{}
+
+ScTpSubTotalGroup2::ScTpSubTotalGroup2( Window* pParent, const SfxItemSet& rArgSet ) :
+ ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP2, rArgSet )
+{}
+
+ScTpSubTotalGroup3::ScTpSubTotalGroup3( Window* pParent, const SfxItemSet& rArgSet ) :
+ ScTpSubTotalGroup( pParent, RID_SCPAGE_SUBT_GROUP3, rArgSet )
+{}
+
+// -----------------------------------------------------------------------
+
+
+#define RESET(i) (ScTpSubTotalGroup::DoReset( (i), rArgSet ))
+
+void __EXPORT ScTpSubTotalGroup1::Reset( const SfxItemSet& rArgSet ) { RESET(1); }
+
+void __EXPORT ScTpSubTotalGroup2::Reset( const SfxItemSet& rArgSet ) { RESET(2); }
+
+void __EXPORT ScTpSubTotalGroup3::Reset( const SfxItemSet& rArgSet ) { RESET(3); }
+
+#undef RESET
+
+// -----------------------------------------------------------------------
+
+#define FILLSET(i) (ScTpSubTotalGroup::DoFillItemSet( (i), rArgSet ))
+
+BOOL __EXPORT ScTpSubTotalGroup1::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(1); }
+
+BOOL __EXPORT ScTpSubTotalGroup2::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(2); }
+
+BOOL __EXPORT ScTpSubTotalGroup3::FillItemSet( SfxItemSet& rArgSet ) { return FILLSET(3); }
+
+#undef FILL
+
+//========================================================================
+// Optionen-Tabpage:
+
+ScTpSubTotalOptions::ScTpSubTotalOptions( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_SUBT_OPTIONS ),
+ rArgSet ),
+ //
+ aFlGroup ( this, ScResId( FL_GROUP ) ),
+ aBtnPagebreak ( this, ScResId( BTN_PAGEBREAK ) ),
+ aBtnCase ( this, ScResId( BTN_CASE ) ),
+ aBtnSort ( this, ScResId( BTN_SORT ) ),
+ aFlSort ( this, ScResId( FL_SORT ) ),
+ aBtnAscending ( this, ScResId( BTN_ASCENDING ) ),
+ aBtnDescending ( this, ScResId( BTN_DESCENDING ) ),
+ aBtnFormats ( this, ScResId( BTN_FORMATS ) ),
+ aBtnUserDef ( this, ScResId( BTN_USERDEF ) ),
+ aLbUserDef ( this, ScResId( LB_USERDEF ) ),
+ //
+ pViewData ( NULL ),
+ pDoc ( NULL ),
+ nWhichSubTotals ( rArgSet.GetPool()->GetWhich( SID_SUBTOTALS ) ),
+ rSubTotalData ( ((const ScSubTotalItem&)
+ rArgSet.Get( nWhichSubTotals )).
+ GetSubTotalData() )
+{
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTpSubTotalOptions::~ScTpSubTotalOptions()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalOptions::Init()
+{
+ const ScSubTotalItem& rSubTotalItem = (const ScSubTotalItem&)
+ GetItemSet().Get( nWhichSubTotals );
+
+ pViewData = rSubTotalItem.GetViewData();
+ pDoc = ( pViewData ) ? pViewData->GetDocument() : NULL;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ aBtnSort.SetClickHdl ( LINK( this, ScTpSubTotalOptions, CheckHdl ) );
+ aBtnUserDef.SetClickHdl ( LINK( this, ScTpSubTotalOptions, CheckHdl ) );
+
+ FillUserSortListBox();
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpSubTotalOptions::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTpSubTotalOptions( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTpSubTotalOptions::Reset( const SfxItemSet& /* rArgSet */ )
+{
+ aBtnPagebreak.Check ( rSubTotalData.bPagebreak );
+ aBtnCase.Check ( rSubTotalData.bCaseSens );
+ aBtnFormats.Check ( rSubTotalData.bIncludePattern );
+ aBtnSort.Check ( rSubTotalData.bDoSort );
+ aBtnAscending.Check ( rSubTotalData.bAscending );
+ aBtnDescending.Check( !rSubTotalData.bAscending );
+
+ if ( rSubTotalData.bUserDef )
+ {
+ aBtnUserDef.Check( TRUE );
+ aLbUserDef.Enable();
+ aLbUserDef.SelectEntryPos( rSubTotalData.nUserIndex );
+ }
+ else
+ {
+ aBtnUserDef.Check( FALSE );
+ aLbUserDef.Disable();
+ aLbUserDef.SelectEntryPos( 0 );
+ }
+
+ CheckHdl( &aBtnSort );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTpSubTotalOptions::FillItemSet( SfxItemSet& rArgSet )
+{
+ ScSubTotalParam theSubTotalData; // auslesen, wenn schon teilweise gefuellt
+ SfxTabDialog* pDlg = GetTabDialog();
+ if ( pDlg )
+ {
+ const SfxItemSet* pExample = pDlg->GetExampleSet();
+ const SfxPoolItem* pItem;
+ if ( pExample && pExample->GetItemState( nWhichSubTotals, TRUE, &pItem ) == SFX_ITEM_SET )
+ theSubTotalData = ((const ScSubTotalItem*)pItem)->GetSubTotalData();
+ }
+
+ theSubTotalData.bPagebreak = aBtnPagebreak.IsChecked();
+ theSubTotalData.bReplace = TRUE;
+ theSubTotalData.bCaseSens = aBtnCase.IsChecked();
+ theSubTotalData.bIncludePattern = aBtnFormats.IsChecked();
+ theSubTotalData.bDoSort = aBtnSort.IsChecked();
+ theSubTotalData.bAscending = aBtnAscending.IsChecked();
+ theSubTotalData.bUserDef = aBtnUserDef.IsChecked();
+ theSubTotalData.nUserIndex = (aBtnUserDef.IsChecked())
+ ? aLbUserDef.GetSelectEntryPos()
+ : 0;
+
+ rArgSet.Put( ScSubTotalItem( nWhichSubTotals, &theSubTotalData ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpSubTotalOptions::FillUserSortListBox()
+{
+ ScUserList* pUserLists = ScGlobal::GetUserList();
+
+ aLbUserDef.Clear();
+ if ( pUserLists )
+ {
+ USHORT nCount = pUserLists->GetCount();
+ if ( nCount > 0 )
+ for ( USHORT i=0; i<nCount; i++ )
+ aLbUserDef.InsertEntry( (*pUserLists)[i]->GetString() );
+ }
+}
+
+// -----------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTpSubTotalOptions, CheckHdl, CheckBox *, pBox )
+{
+ if ( pBox == &aBtnSort )
+ {
+ if ( aBtnSort.IsChecked() )
+ {
+ aFlSort .Enable();
+ aBtnFormats .Enable();
+ aBtnUserDef .Enable();
+ aBtnAscending .Enable();
+ aBtnDescending .Enable();
+
+ if ( aBtnUserDef.IsChecked() )
+ aLbUserDef.Enable();
+ }
+ else
+ {
+ aFlSort .Disable();
+ aBtnFormats .Disable();
+ aBtnUserDef .Disable();
+ aBtnAscending .Disable();
+ aBtnDescending .Disable();
+ aLbUserDef .Disable();
+ }
+ }
+ else if ( pBox == &aBtnUserDef )
+ {
+ if ( aBtnUserDef.IsChecked() )
+ {
+ aLbUserDef.Enable();
+ aLbUserDef.GrabFocus();
+ }
+ else
+ aLbUserDef.Disable();
+ }
+
+ return 0;
+}
+
+__EXPORT ScTpSubTotalGroup1::~ScTpSubTotalGroup1()
+{
+}
+
+__EXPORT ScTpSubTotalGroup2::~ScTpSubTotalGroup2()
+{
+}
+
+__EXPORT ScTpSubTotalGroup3::~ScTpSubTotalGroup3()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/validate.cxx b/sc/source/ui/dbgui/validate.cxx
new file mode 100644
index 000000000000..9ec9740e1208
--- /dev/null
+++ b/sc/source/ui/dbgui/validate.cxx
@@ -0,0 +1,998 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#ifdef SC_DLLIMPLEMENTATION
+#undef SC_DLLIMPLEMENTATION
+#endif
+
+#include <vcl/svapp.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/intitem.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbmod.hxx>
+#include <sfx2/app.hxx>
+
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot IDs
+
+#include "validat.hxx"
+#include "validate.hrc"
+#include "validate.hxx"
+#include "compiler.hxx"
+#include "formula/opcode.hxx"
+
+// cell range picker
+#include "tabvwsh.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/childwin.hxx>
+#include "reffact.hxx"
+
+// ============================================================================
+
+static USHORT pValueRanges[] =
+{
+ FID_VALID_MODE, FID_VALID_ERRTEXT,
+ FID_VALID_LISTTYPE, FID_VALID_LISTTYPE,
+ 0
+};
+
+
+// ============================================================================
+
+ScValidationDlg::ScValidationDlg( Window* pParent,
+ const SfxItemSet* pArgSet,
+ ScTabViewShell *pTabViewSh,
+ SfxBindings *pB /*= NULL*/
+ ) :
+ ScValidationDlgBase( pParent ? pParent : SFX_APP()->GetTopWindow(), TAB_DLG_VALIDATION, pArgSet, pB ),
+ m_bOwnRefHdlr( false ),
+ m_pTabVwSh( pTabViewSh ),
+ m_bRefInputting( false )
+{
+ AddTabPage( TP_VALIDATION_VALUES, ScTPValidationValue::Create, 0 );
+ AddTabPage( TP_VALIDATION_INPUTHELP, ScTPValidationHelp::Create, 0 );
+ AddTabPage( TP_VALIDATION_ERROR, ScTPValidationError::Create, 0 );
+ FreeResource();
+}
+
+void ScTPValidationValue::SetReferenceHdl( const ScRange&rRange , ScDocument* pDoc )
+{
+ if ( rRange.aStart != rRange.aEnd )
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( m_pRefEdit )
+ pValidationDlg->RefInputStart( m_pRefEdit );
+
+ if ( m_pRefEdit )
+ {
+ String aStr;
+ rRange.Format( aStr, SCR_ABS_3D, pDoc );
+ m_pRefEdit->SetRefString( aStr );
+ }
+}
+
+void ScTPValidationValue:: SetActiveHdl()
+{
+ if ( m_pRefEdit ) m_pRefEdit->GrabFocus();
+
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( m_pRefEdit )
+ {
+ pValidationDlg->RefInputDone();
+ }
+}
+
+void ScTPValidationValue::RefInputStartPreHdl( ScRefEdit* pEdit, ScRefButton* pButton )
+{
+ if ( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ {
+ if( pEdit == m_pRefEdit )
+ {
+ if( Window *pPreWnd = pEdit==&maEdMax?&maFtMax:(pEdit==&maEdMin?&maFtMin:NULL) )
+ {
+ pPreWnd->SetParent( pValidationDlg );
+ pPreWnd->Hide();
+ }
+
+ m_pRefEdit->SetParent( pValidationDlg );
+ }
+
+ if( pButton == &m_btnRef )m_btnRef.SetParent( pValidationDlg );
+ }
+}
+
+void ScTPValidationValue::RefInputDonePreHdl()
+{
+
+ if( m_pRefEdit && m_pRefEdit->GetParent()!= this )
+ {
+ if( Window *pPreWnd = m_pRefEdit==&maEdMax?&maFtMax:(m_pRefEdit==&maEdMin?&maFtMin:NULL) )
+ {
+ pPreWnd->SetParent( this );
+ pPreWnd->Show();
+ }
+
+ m_pRefEdit->SetParent( this );
+
+ m_btnRef.SetParent( m_pRefEdit ); //if Edit SetParent but button not, the tab order will be incorrect, need button to setparent to anthor window and restore parent later in order to restore the tab order
+ }
+
+ if( m_btnRef.GetParent()!=this ) m_btnRef.SetParent( this );
+}
+
+void ScTPValidationValue::RefInputDonePostHdl()
+{
+
+
+ if( m_pRefEdit && !m_pRefEdit->HasFocus() )
+ m_pRefEdit->GrabFocus();
+
+}
+
+
+BOOL ScValidationDlg::Close()
+{
+ if( m_bOwnRefHdlr )
+ if( SfxTabPage* pPage = GetTabPage( TP_VALIDATION_VALUES ) )
+ static_cast<ScTPValidationValue*>(pPage)->RemoveRefDlg();
+
+ return ScValidationDlgBase::Close();
+}
+
+ScValidationDlg::~ScValidationDlg()
+{
+ if( m_bOwnRefHdlr )
+ RemoveRefDlg( FALSE );
+}
+
+
+// ============================================================================
+
+namespace {
+
+/** Converts the passed ScValidationMode to the position in the list box. */
+USHORT lclGetPosFromValMode( ScValidationMode eValMode )
+{
+ USHORT nLbPos = SC_VALIDDLG_ALLOW_ANY;
+ switch( eValMode )
+ {
+ case SC_VALID_ANY: nLbPos = SC_VALIDDLG_ALLOW_ANY; break;
+ case SC_VALID_WHOLE: nLbPos = SC_VALIDDLG_ALLOW_WHOLE; break;
+ case SC_VALID_DECIMAL: nLbPos = SC_VALIDDLG_ALLOW_DECIMAL; break;
+ case SC_VALID_DATE: nLbPos = SC_VALIDDLG_ALLOW_DATE; break;
+ case SC_VALID_TIME: nLbPos = SC_VALIDDLG_ALLOW_TIME; break;
+ case SC_VALID_TEXTLEN: nLbPos = SC_VALIDDLG_ALLOW_TEXTLEN; break;
+ case SC_VALID_LIST: nLbPos = SC_VALIDDLG_ALLOW_RANGE; break;
+ case SC_VALID_CUSTOM: nLbPos = SC_VALIDDLG_ALLOW_ANY; break; // not supported
+ default: DBG_ERRORFILE( "lclGetPosFromValMode - unknown validity mode" );
+ }
+ return nLbPos;
+}
+
+/** Converts the passed list box position to an ScValidationMode. */
+ScValidationMode lclGetValModeFromPos( USHORT nLbPos )
+{
+ ScValidationMode eValMode = SC_VALID_ANY;
+ switch( nLbPos )
+ {
+ case SC_VALIDDLG_ALLOW_ANY: eValMode = SC_VALID_ANY; break;
+ case SC_VALIDDLG_ALLOW_WHOLE: eValMode = SC_VALID_WHOLE; break;
+ case SC_VALIDDLG_ALLOW_DECIMAL: eValMode = SC_VALID_DECIMAL; break;
+ case SC_VALIDDLG_ALLOW_DATE: eValMode = SC_VALID_DATE; break;
+ case SC_VALIDDLG_ALLOW_TIME: eValMode = SC_VALID_TIME; break;
+ case SC_VALIDDLG_ALLOW_RANGE: eValMode = SC_VALID_LIST; break;
+ case SC_VALIDDLG_ALLOW_LIST: eValMode = SC_VALID_LIST; break;
+ case SC_VALIDDLG_ALLOW_TEXTLEN: eValMode = SC_VALID_TEXTLEN; break;
+ default: DBG_ERRORFILE( "lclGetValModeFromPos - invalid list box position" );
+ }
+ return eValMode;
+}
+
+/** Converts the passed ScConditionMode to the position in the list box. */
+USHORT lclGetPosFromCondMode( ScConditionMode eCondMode )
+{
+ USHORT nLbPos = SC_VALIDDLG_DATA_EQUAL;
+ switch( eCondMode )
+ {
+ case SC_COND_NONE: // #111771# may occur in old XML files after Excel import
+ case SC_COND_EQUAL: nLbPos = SC_VALIDDLG_DATA_EQUAL; break;
+ case SC_COND_LESS: nLbPos = SC_VALIDDLG_DATA_LESS; break;
+ case SC_COND_GREATER: nLbPos = SC_VALIDDLG_DATA_GREATER; break;
+ case SC_COND_EQLESS: nLbPos = SC_VALIDDLG_DATA_EQLESS; break;
+ case SC_COND_EQGREATER: nLbPos = SC_VALIDDLG_DATA_EQGREATER; break;
+ case SC_COND_NOTEQUAL: nLbPos = SC_VALIDDLG_DATA_NOTEQUAL; break;
+ case SC_COND_BETWEEN: nLbPos = SC_VALIDDLG_DATA_BETWEEN; break;
+ case SC_COND_NOTBETWEEN: nLbPos = SC_VALIDDLG_DATA_NOTBETWEEN; break;
+ default: DBG_ERRORFILE( "lclGetPosFromCondMode - unknown condition mode" );
+ }
+ return nLbPos;
+}
+
+/** Converts the passed list box position to an ScConditionMode. */
+ScConditionMode lclGetCondModeFromPos( USHORT nLbPos )
+{
+ ScConditionMode eCondMode = SC_COND_EQUAL;
+ switch( nLbPos )
+ {
+ case SC_VALIDDLG_DATA_EQUAL: eCondMode = SC_COND_EQUAL; break;
+ case SC_VALIDDLG_DATA_LESS: eCondMode = SC_COND_LESS; break;
+ case SC_VALIDDLG_DATA_GREATER: eCondMode = SC_COND_GREATER; break;
+ case SC_VALIDDLG_DATA_EQLESS: eCondMode = SC_COND_EQLESS; break;
+ case SC_VALIDDLG_DATA_EQGREATER: eCondMode = SC_COND_EQGREATER; break;
+ case SC_VALIDDLG_DATA_NOTEQUAL: eCondMode = SC_COND_NOTEQUAL; break;
+ case SC_VALIDDLG_DATA_BETWEEN: eCondMode = SC_COND_BETWEEN; break;
+ case SC_VALIDDLG_DATA_NOTBETWEEN: eCondMode = SC_COND_NOTBETWEEN; break;
+ default: DBG_ERRORFILE( "lclGetCondModeFromPos - invalid list box position" );
+ }
+ return eCondMode;
+}
+
+/** Converts line feed separated string to a formula with strings separated by semicolons.
+ @descr Keeps all empty strings.
+ Example: abc\ndef\n\nghi -> "abc";"def";"";"ghi".
+ @param rFmlaStr (out-param) The converted formula string. */
+void lclGetFormulaFromStringList( String& rFmlaStr, const String& rStringList, sal_Unicode cFmlaSep )
+{
+ rFmlaStr.Erase();
+ xub_StrLen nTokenCnt = rStringList.GetTokenCount( '\n' );
+ for( xub_StrLen nToken = 0, nStringIx = 0; nToken < nTokenCnt; ++nToken )
+ {
+ String aToken( rStringList.GetToken( 0, '\n', nStringIx ) );
+ ScGlobal::AddQuotes( aToken, '"' );
+ ScGlobal::AddToken( rFmlaStr, aToken, cFmlaSep );
+ }
+ if( !rFmlaStr.Len() )
+ rFmlaStr.AssignAscii( "\"\"" );
+}
+
+
+/** Converts formula with strings separated by semicolons to line feed separated string.
+ @descr Keeps all empty strings. Ignores all empty tokens (multiple semicolons).
+ Example: "abc";;;"def";"";"ghi" -> abc\ndef\n\nghi.
+ @param rStringList (out-param) The converted line feed separated string list.
+ @return true = Conversion successful. */
+bool lclGetStringListFromFormula( String& rStringList, const String& rFmlaStr, sal_Unicode cFmlaSep )
+{
+ String aQuotes( RTL_CONSTASCII_USTRINGPARAM( "\"\"" ) );
+ xub_StrLen nTokenCnt = rFmlaStr.GetQuotedTokenCount( aQuotes, cFmlaSep );
+
+ rStringList.Erase();
+ bool bIsStringList = (nTokenCnt > 0);
+ bool bTokenAdded = false;
+
+ for( xub_StrLen nToken = 0, nStringIx = 0; bIsStringList && (nToken < nTokenCnt); ++nToken )
+ {
+ String aToken( rFmlaStr.GetQuotedToken( 0, aQuotes, cFmlaSep, nStringIx ) );
+ aToken.EraseLeadingAndTrailingChars();
+ if( aToken.Len() ) // ignore empty tokens, i.e. "a";;"b"
+ {
+ bIsStringList = ScGlobal::IsQuoted( aToken, '"' );
+ if( bIsStringList )
+ {
+ ScGlobal::EraseQuotes( aToken, '"' );
+ ScGlobal::AddToken( rStringList, aToken, '\n', 1, bTokenAdded );
+ bTokenAdded = true;
+ }
+ }
+ }
+
+ return bIsStringList;
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+ScTPValidationValue::ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet ) :
+ SfxTabPage( pParent, ScResId( TP_VALIDATION_VALUES ), rArgSet ),
+ maFtAllow ( this, ScResId( FT_ALLOW ) ),
+ maLbAllow ( this, ScResId( LB_ALLOW ) ),
+ maCbAllow ( this, ScResId( TSB_ALLOW_BLANKS ) ),
+ maCbShow ( this, ScResId( CB_SHOWLIST ) ),
+ maCbSort ( this, ScResId( CB_SORTLIST ) ),
+ maFtValue ( this, ScResId( FT_VALUE ) ),
+ maLbValue ( this, ScResId( LB_VALUE ) ),
+ maFtMin ( this, ScResId( FT_MIN ) ),
+ maEdMin ( this, ScResId( EDT_MIN ) ),
+ maEdList ( this, ScResId( EDT_LIST ) ),
+ maFtMax ( this, ScResId( FT_MAX ) ),
+ maEdMax ( this, ScResId( EDT_MAX ) ),
+ maFtHint ( this, ScResId( FT_SOURCEHINT ) ),
+ maStrMin ( ScResId( SCSTR_VALID_MINIMUM ) ),
+ maStrMax ( ScResId( SCSTR_VALID_MAXIMUM ) ),
+ maStrValue( ScResId( SCSTR_VALID_VALUE ) ),
+ maStrRange( ScResId( SCSTR_VALID_RANGE ) ),
+ maStrList ( ScResId( SCSTR_VALID_LIST ) ),
+ m_btnRef( this, ScResId( RB_VALIDITY_REF ) )
+{
+ Init();
+ FreeResource();
+
+ // list separator in formulas
+ String aListSep = ::GetScCompilerNativeSymbol( ocSep );
+ DBG_ASSERT( aListSep.Len() == 1, "ScTPValidationValue::ScTPValidationValue - list separator error" );
+ mcFmlaSep = aListSep.Len() ? aListSep.GetChar( 0 ) : ';';
+ m_btnRef.Hide(); // cell range picker
+}
+
+ScTPValidationValue::~ScTPValidationValue()
+{
+}
+
+void ScTPValidationValue::Init()
+{
+ maLbAllow.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
+ maLbValue.SetSelectHdl( LINK( this, ScTPValidationValue, SelectHdl ) );
+ maCbShow.SetClickHdl( LINK( this, ScTPValidationValue, CheckHdl ) );
+
+ // cell range picker
+ maEdMin.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
+ maEdMin.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
+ maEdMax.SetGetFocusHdl( LINK( this, ScTPValidationValue, EditSetFocusHdl ) );
+ m_btnRef.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
+ maEdMax.SetLoseFocusHdl( LINK( this, ScTPValidationValue, KillFocusHdl ) );
+
+ maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_ANY );
+ maLbValue.SelectEntryPos( SC_VALIDDLG_DATA_EQUAL );
+
+ SelectHdl( NULL );
+ CheckHdl( NULL );
+}
+
+SfxTabPage* ScTPValidationValue::Create( Window* pParent, const SfxItemSet& rArgSet )
+{
+ return( new ScTPValidationValue( pParent, rArgSet ) );
+}
+
+USHORT* ScTPValidationValue::GetRanges()
+{
+ return pValueRanges;
+}
+
+void ScTPValidationValue::Reset( const SfxItemSet& rArgSet )
+{
+ const SfxPoolItem* pItem;
+
+ USHORT nLbPos = SC_VALIDDLG_ALLOW_ANY;
+ if( rArgSet.GetItemState( FID_VALID_MODE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nLbPos = lclGetPosFromValMode( static_cast< ScValidationMode >(
+ static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
+ maLbAllow.SelectEntryPos( nLbPos );
+
+ nLbPos = SC_VALIDDLG_DATA_EQUAL;
+ if( rArgSet.GetItemState( FID_VALID_CONDMODE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nLbPos = lclGetPosFromCondMode( static_cast< ScConditionMode >(
+ static_cast< const SfxAllEnumItem* >( pItem )->GetValue() ) );
+ maLbValue.SelectEntryPos( nLbPos );
+
+ // *** check boxes ***
+ BOOL bCheck = TRUE;
+ if( rArgSet.GetItemState( FID_VALID_BLANK, TRUE, &pItem ) == SFX_ITEM_SET )
+ bCheck = static_cast< const SfxBoolItem* >( pItem )->GetValue();
+ maCbAllow.Check( bCheck );
+
+ sal_Int32 nListType = ValidListType::UNSORTED;
+ if( rArgSet.GetItemState( FID_VALID_LISTTYPE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nListType = static_cast< const SfxInt16Item* >( pItem )->GetValue();
+ maCbShow.Check( nListType != ValidListType::INVISIBLE );
+ maCbSort.Check( nListType == ValidListType::SORTEDASCENDING );
+
+ // *** formulas ***
+ String aFmlaStr;
+ if ( rArgSet.GetItemState( FID_VALID_VALUE1, TRUE, &pItem ) == SFX_ITEM_SET )
+ aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
+ SetFirstFormula( aFmlaStr );
+
+ aFmlaStr.Erase();
+ if ( rArgSet.GetItemState( FID_VALID_VALUE2, TRUE, &pItem ) == SFX_ITEM_SET )
+ aFmlaStr = static_cast< const SfxStringItem* >( pItem )->GetValue();
+ SetSecondFormula( aFmlaStr );
+
+ SelectHdl( NULL );
+ CheckHdl( NULL );
+}
+
+BOOL ScTPValidationValue::FillItemSet( SfxItemSet& rArgSet )
+{
+ sal_Int16 nListType = maCbShow.IsChecked() ?
+ (maCbSort.IsChecked() ? ValidListType::SORTEDASCENDING : ValidListType::UNSORTED) :
+ ValidListType::INVISIBLE;
+
+ rArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<USHORT>(
+ lclGetValModeFromPos( maLbAllow.GetSelectEntryPos() ) ) ) );
+ rArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<USHORT>(
+ lclGetCondModeFromPos( maLbValue.GetSelectEntryPos() ) ) ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_VALUE1, GetFirstFormula() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_VALUE2, GetSecondFormula() ) );
+ rArgSet.Put( SfxBoolItem( FID_VALID_BLANK, maCbAllow.IsChecked() ) );
+ rArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
+ return TRUE;
+}
+
+String ScTPValidationValue::GetFirstFormula() const
+{
+ String aFmlaStr;
+ if( maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_LIST )
+ lclGetFormulaFromStringList( aFmlaStr, maEdList.GetText(), mcFmlaSep );
+ else
+ aFmlaStr = maEdMin.GetText();
+ return aFmlaStr;
+}
+
+String ScTPValidationValue::GetSecondFormula() const
+{
+ return maEdMax.GetText();
+}
+
+void ScTPValidationValue::SetFirstFormula( const String& rFmlaStr )
+{
+ // try if formula is a string list, validation mode must already be set
+ String aStringList;
+ if( (maLbAllow.GetSelectEntryPos() == SC_VALIDDLG_ALLOW_RANGE) &&
+ lclGetStringListFromFormula( aStringList, rFmlaStr, mcFmlaSep ) )
+ {
+ maEdList.SetText( aStringList );
+ maEdMin.SetText( EMPTY_STRING );
+ // change validation mode to string list
+ maLbAllow.SelectEntryPos( SC_VALIDDLG_ALLOW_LIST );
+ }
+ else
+ {
+ maEdMin.SetText( rFmlaStr );
+ maEdList.SetText( EMPTY_STRING );
+ }
+}
+
+void ScTPValidationValue::SetSecondFormula( const String& rFmlaStr )
+{
+ maEdMax.SetText( rFmlaStr );
+}
+
+ScValidationDlg * ScTPValidationValue::GetValidationDlg()
+{
+ if( Window *pParent = GetParent() )
+ do{
+ if ( dynamic_cast<ScValidationDlg*>( pParent ) )
+ return static_cast< ScValidationDlg * >( pParent );
+ }while ( NULL != ( pParent = pParent->GetParent() ) );
+ return NULL;
+}
+
+void ScTPValidationValue::SetupRefDlg()
+{
+ if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( pValidationDlg->SetupRefDlg() )
+ {
+ pValidationDlg->SetHandler( this );
+ pValidationDlg->SetSetRefHdl( (ScRefHandlerHelper::PFUNCSETREFHDLTYPE)( &ScTPValidationValue::SetReferenceHdl ) );
+ pValidationDlg->SetSetActHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::SetActiveHdl ) );
+ pValidationDlg->SetRefInputStartPreHdl( (ScRefHandlerHelper::PINPUTSTARTDLTYPE)( &ScTPValidationValue::RefInputStartPreHdl ) );
+ pValidationDlg->SetRefInputDonePreHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePreHdl ) );
+ pValidationDlg->SetRefInputDonePostHdl( (ScRefHandlerHelper::PCOMMONHDLTYPE)( &ScTPValidationValue::RefInputDonePostHdl ) );
+
+ if ( maEdMax.IsVisible() ) { m_pRefEdit = &maEdMax; }
+ else if ( maEdMin.IsVisible() ) { m_pRefEdit = &maEdMin; }
+
+ if( m_pRefEdit && !m_pRefEdit->HasFocus() ) m_pRefEdit->GrabFocus();
+
+ if( m_pRefEdit ) m_pRefEdit->SetRefDialog( pValidationDlg );
+ m_btnRef.SetReferences( pValidationDlg, m_pRefEdit );
+ }
+}
+
+void ScTPValidationValue::RemoveRefDlg()
+{
+ if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if( pValidationDlg->RemoveRefDlg() )
+ {
+ pValidationDlg->SetHandler( NULL );
+ pValidationDlg->SetSetRefHdl( NULL );
+ pValidationDlg->SetSetActHdl( NULL );
+ pValidationDlg->SetRefInputStartPreHdl( NULL );
+ pValidationDlg->SetRefInputDonePreHdl( NULL );
+ pValidationDlg->SetRefInputDonePostHdl( NULL );
+
+ if( m_pRefEdit ) m_pRefEdit->SetRefDialog( NULL );
+ m_pRefEdit = NULL;
+
+ m_btnRef.SetReferences( NULL, NULL );
+
+#if ! defined( WNT ) && !defined( _MSC_VER )
+ TidyListBoxes();
+#endif
+ }
+}
+
+void ScTPValidationValue::TidyListBoxes()
+{
+ if ( Window *pWnd = GetChild( 0 ) )
+ {
+ bool bFindLst = false;
+ std::list<Window*> alstOrder;
+
+ do{
+ if( pWnd->GetParent() == this )
+ {
+ if ( !bFindLst )
+ {
+ try{
+ if( dynamic_cast<ListBox*>(pWnd)||dynamic_cast<ListBox*>(pWnd->GetWindow(WINDOW_CLIENT) ) )
+ bFindLst = true;
+ }
+ catch( ... )
+ {
+ if ( *(void**)pWnd == *(void**)&maLbValue )
+ bFindLst = true;
+ else if ( Window *pClient = pWnd->GetWindow( WINDOW_CLIENT ) )
+ if ( *(void**)pClient == *(void**)&maLbValue )
+ bFindLst = true;
+ }
+ }
+
+ if ( bFindLst )
+ alstOrder.push_back( pWnd->GetWindow( WINDOW_CLIENT ) );
+ }
+ }while( NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT ) ) );
+
+ pWnd = GetChild(0);
+
+ while( std::find( alstOrder.begin(), alstOrder.end(), pWnd ) != alstOrder.end() && NULL != ( pWnd = pWnd->GetWindow( WINDOW_NEXT) ) ) ;
+
+ if ( pWnd )
+ {
+ for ( std::list<Window*>::iterator i = alstOrder.begin(); i!=alstOrder.end(); i++ )
+ {
+ Window *pParent = (*i)->GetParent();
+ (*i)->SetParent( pWnd );
+ (*i)->SetParent( pParent );
+ }
+ }
+ }
+}
+
+IMPL_LINK( ScTPValidationValue, EditSetFocusHdl, Edit *, EMPTYARG)
+{
+ USHORT nPos=maLbAllow.GetSelectEntryPos();
+
+ if ( nPos == SC_VALIDDLG_ALLOW_RANGE )
+ {
+ SetupRefDlg();
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScTPValidationValue, KillFocusHdl, Window *, pWnd )
+{
+ if( pWnd == m_pRefEdit || pWnd == &m_btnRef )
+ if( ScValidationDlg *pValidationDlg = GetValidationDlg() )
+ if ( (pValidationDlg->IsActive() || pValidationDlg->IsChildFocus() ) && !pValidationDlg->IsRefInputting() )
+ if( ( !m_pRefEdit || !m_pRefEdit->HasFocus()) && !m_btnRef.HasFocus() )
+ {
+ RemoveRefDlg();
+ }
+
+ return 0;
+}
+
+// ----------------------------------------------------------------------------
+
+IMPL_LINK( ScTPValidationValue, SelectHdl, ListBox*, EMPTYARG )
+{
+ USHORT nLbPos = maLbAllow.GetSelectEntryPos();
+ bool bEnable = (nLbPos != SC_VALIDDLG_ALLOW_ANY);
+ bool bRange = (nLbPos == SC_VALIDDLG_ALLOW_RANGE);
+ bool bList = (nLbPos == SC_VALIDDLG_ALLOW_LIST);
+
+ maCbAllow.Enable( bEnable ); // Empty cell
+ maFtValue.Enable( bEnable );
+ maLbValue.Enable( bEnable );
+ maFtMin.Enable( bEnable );
+ maEdMin.Enable( bEnable );
+ maEdList.Enable( bEnable );
+ maFtMax.Enable( bEnable );
+ maEdMax.Enable( bEnable );
+
+ bool bShowMax = false;
+ if( bRange )
+ maFtMin.SetText( maStrRange );
+ else if( bList )
+ maFtMin.SetText( maStrList );
+ else
+ {
+ switch( maLbValue.GetSelectEntryPos() )
+ {
+ case SC_VALIDDLG_DATA_EQUAL:
+ case SC_VALIDDLG_DATA_NOTEQUAL: maFtMin.SetText( maStrValue ); break;
+
+ case SC_VALIDDLG_DATA_LESS:
+ case SC_VALIDDLG_DATA_EQLESS: maFtMin.SetText( maStrMax ); break;
+
+ case SC_VALIDDLG_DATA_BETWEEN:
+ case SC_VALIDDLG_DATA_NOTBETWEEN: bShowMax = true; // fall through
+ case SC_VALIDDLG_DATA_GREATER:
+ case SC_VALIDDLG_DATA_EQGREATER: maFtMin.SetText( maStrMin ); break;
+
+ default:
+ DBG_ERRORFILE( "ScTPValidationValue::SelectHdl - unknown condition mode" );
+ }
+ }
+
+ maCbShow.Show( bRange || bList );
+ maCbSort.Show( bRange || bList );
+ maFtValue.Show( !bRange && !bList );
+ maLbValue.Show( !bRange && !bList );
+ maEdMin.Show( !bList );
+ maEdList.Show( bList );
+ maFtMax.Show( bShowMax );
+ maEdMax.Show( bShowMax );
+ maFtHint.Show( bRange );
+ m_btnRef.Show( bRange ); // cell range picker
+ return 0;
+}
+
+IMPL_LINK( ScTPValidationValue, CheckHdl, CheckBox*, EMPTYARG )
+{
+ maCbSort.Enable( maCbShow.IsChecked() );
+ return 0;
+}
+
+
+//========================================================================
+//========================================================================
+// Input Help Page
+
+ScTPValidationHelp::ScTPValidationHelp( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( TP_VALIDATION_INPUTHELP ),
+ rArgSet ),
+ aTsbHelp ( this, ScResId( TSB_HELP ) ),
+ aFlContent ( this, ScResId( FL_CONTENT ) ),
+ aFtTitle ( this, ScResId( FT_TITLE ) ),
+ aEdtTitle ( this, ScResId( EDT_TITLE ) ),
+ aFtInputHelp ( this, ScResId( FT_INPUTHELP ) ),
+ aEdInputHelp ( this, ScResId( EDT_INPUTHELP ) ),
+
+ mrArgSet ( rArgSet )
+{
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTPValidationHelp::~ScTPValidationHelp()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTPValidationHelp::Init()
+{
+ aTsbHelp.EnableTriState( FALSE );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTPValidationHelp::GetRanges()
+{
+ return pValueRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTPValidationHelp::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTPValidationHelp( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTPValidationHelp::Reset( const SfxItemSet& rArgSet )
+{
+ const SfxPoolItem* pItem;
+
+ if ( rArgSet.GetItemState( FID_VALID_SHOWHELP, TRUE, &pItem ) == SFX_ITEM_SET )
+ aTsbHelp.SetState( ((const SfxBoolItem*)pItem)->GetValue() ? STATE_CHECK : STATE_NOCHECK );
+ else
+ aTsbHelp.SetState( STATE_NOCHECK );
+
+ if ( rArgSet.GetItemState( FID_VALID_HELPTITLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdtTitle.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdtTitle.SetText( EMPTY_STRING );
+
+ if ( rArgSet.GetItemState( FID_VALID_HELPTEXT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdInputHelp.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdInputHelp.SetText( EMPTY_STRING );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTPValidationHelp::FillItemSet( SfxItemSet& rArgSet )
+{
+ rArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, aTsbHelp.GetState() == STATE_CHECK ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aEdtTitle.GetText() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aEdInputHelp.GetText() ) );
+
+ return TRUE;
+}
+
+//========================================================================
+//========================================================================
+// Error Alert Page
+
+ScTPValidationError::ScTPValidationError( Window* pParent,
+ const SfxItemSet& rArgSet )
+
+ : SfxTabPage ( pParent,
+ ScResId( TP_VALIDATION_ERROR ),
+ rArgSet ),
+ aTsbShow ( this, ScResId( TSB_SHOW ) ),
+ aFlContent ( this, ScResId( FL_CONTENT ) ),
+ aFtAction ( this, ScResId( FT_ACTION ) ),
+ aLbAction ( this, ScResId( LB_ACTION ) ),
+ aBtnSearch ( this, ScResId( BTN_SEARCH ) ),
+ aFtTitle ( this, ScResId( FT_TITLE ) ),
+ aEdtTitle ( this, ScResId( EDT_TITLE ) ),
+ aFtError ( this, ScResId( FT_ERROR ) ),
+ aEdError ( this, ScResId( EDT_ERROR ) ),
+
+ mrArgSet ( rArgSet )
+{
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTPValidationError::~ScTPValidationError()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void ScTPValidationError::Init()
+{
+ aLbAction.SetSelectHdl( LINK( this, ScTPValidationError, SelectActionHdl ) );
+ aBtnSearch.SetClickHdl( LINK( this, ScTPValidationError, ClickSearchHdl ) );
+
+ aLbAction.SelectEntryPos( 0 );
+ aTsbShow.EnableTriState( FALSE );
+
+ SelectActionHdl( NULL );
+}
+
+//------------------------------------------------------------------------
+
+USHORT* __EXPORT ScTPValidationError::GetRanges()
+{
+ return pValueRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTPValidationError::Create( Window* pParent,
+ const SfxItemSet& rArgSet )
+{
+ return ( new ScTPValidationError( pParent, rArgSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTPValidationError::Reset( const SfxItemSet& rArgSet )
+{
+ const SfxPoolItem* pItem;
+
+ if ( rArgSet.GetItemState( FID_VALID_SHOWERR, TRUE, &pItem ) == SFX_ITEM_SET )
+ aTsbShow.SetState( ((const SfxBoolItem*)pItem)->GetValue() ? STATE_CHECK : STATE_NOCHECK );
+ else
+ aTsbShow.SetState( STATE_CHECK ); // #111720# check by default
+
+ if ( rArgSet.GetItemState( FID_VALID_ERRSTYLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aLbAction.SelectEntryPos( ((const SfxAllEnumItem*)pItem)->GetValue() );
+ else
+ aLbAction.SelectEntryPos( 0 );
+
+ if ( rArgSet.GetItemState( FID_VALID_ERRTITLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdtTitle.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdtTitle.SetText( EMPTY_STRING );
+
+ if ( rArgSet.GetItemState( FID_VALID_ERRTEXT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aEdError.SetText( ((const SfxStringItem*)pItem)->GetValue() );
+ else
+ aEdError.SetText( EMPTY_STRING );
+
+ SelectActionHdl( NULL );
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTPValidationError::FillItemSet( SfxItemSet& rArgSet )
+{
+ rArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, aTsbShow.GetState() == STATE_CHECK ) );
+ rArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, aLbAction.GetSelectEntryPos() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aEdtTitle.GetText() ) );
+ rArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aEdError.GetText() ) );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTPValidationError, SelectActionHdl, ListBox*, EMPTYARG )
+{
+ ScValidErrorStyle eStyle = (ScValidErrorStyle) aLbAction.GetSelectEntryPos();
+ BOOL bMacro = ( eStyle == SC_VALERR_MACRO );
+
+ aBtnSearch.Enable( bMacro );
+ aFtError.Enable( !bMacro );
+ aEdError.Enable( !bMacro );
+
+ return( 0L );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTPValidationError, ClickSearchHdl, PushButton*, EMPTYARG )
+{
+ Window* pOld = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+
+ // Use static SfxApplication method to bring up selector dialog for
+ // choosing a script
+ ::rtl::OUString aScriptURL = SfxApplication::ChooseScript();
+
+ Application::SetDefDialogParent( pOld );
+
+ if ( aScriptURL != NULL && aScriptURL.getLength() != 0 )
+ {
+ aEdtTitle.SetText( aScriptURL );
+ }
+
+ return( 0L );
+}
+
+bool ScValidationDlg::EnterRefStatus()
+{
+ ScTabViewShell *pTabViewShell = GetTabViewShell();
+
+ if( !pTabViewShell ) return false;
+
+ USHORT nId = SLOTID;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ if ( pWnd && pWnd->GetWindow()!= this ) pWnd = NULL;
+
+ SC_MOD()->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+
+ return true;
+}
+
+bool ScValidationDlg::LeaveRefStatus()
+{
+ ScTabViewShell *pTabViewShell = GetTabViewShell();
+
+ if( !pTabViewShell ) return false;
+
+ USHORT nId = SLOTID;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ if ( pViewFrm->GetChildWindow( nId ) )
+ {
+ DoClose( nId );
+ }
+ return true;
+}
+
+bool ScValidationDlg::SetupRefDlg()
+{
+ if ( m_bOwnRefHdlr ) return false;
+ if( EnterRefMode() )
+ {
+ SetModal( FALSE );
+ return m_bOwnRefHdlr = true && EnterRefStatus();
+ }
+
+ return false;
+}
+
+bool ScValidationDlg::RemoveRefDlg( BOOL bRestoreModal /* = TRUE */ )
+{
+ bool bVisLock = false;
+ bool bFreeWindowLock = false;
+
+ ScTabViewShell *pTabVwSh = GetTabViewShell();
+
+ if( !pTabVwSh ) return false;
+
+ if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
+ {
+ bVisLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( true );
+ bFreeWindowLock = static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( true );
+ }
+
+ if ( !m_bOwnRefHdlr ) return false;
+ if( LeaveRefStatus() && LeaveRefMode() )
+ {
+ m_bOwnRefHdlr = false;
+
+ if( bRestoreModal )
+ SetModal( TRUE );
+ }
+
+ if ( SfxChildWindow* pWnd = pTabVwSh->GetViewFrame()->GetChildWindow( SID_VALIDITY_REFERENCE ) )
+ {
+ static_cast<ScValidityRefChildWin*>(pWnd)->LockVisible( bVisLock );
+ static_cast<ScValidityRefChildWin*>(pWnd)->LockFreeWindow( bFreeWindowLock );
+ }
+
+ return true;
+}
+
+void ScTPValidationValue::ScRefButtonEx::Click()
+{
+ if( ScTPValidationValue *pParent = dynamic_cast< ScTPValidationValue*>( GetParent() ) )
+ pParent->OnClick( this );
+
+ ScRefButton::Click();
+}
+
+void ScTPValidationValue::OnClick( Button *pBtn )
+{
+ if( pBtn == &m_btnRef )
+ SetupRefDlg();
+}
+
+BOOL ScValidationDlg::IsChildFocus()
+{
+ if ( const Window *pWin = Application::GetFocusWindow() )
+ while( NULL != ( pWin = pWin->GetParent() ) )
+ if( pWin == this )
+ return TRUE;
+
+ return FALSE;
+}
+
+
+bool ScValidationDlg::IsAlive()
+{
+ return SC_MOD()->IsAliveRefDlg( SLOTID, this );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/dbgui/validate.src b/sc/source/ui/dbgui/validate.src
new file mode 100644
index 000000000000..67207cdfaba2
--- /dev/null
+++ b/sc/source/ui/dbgui/validate.src
@@ -0,0 +1,407 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "validate.hrc"
+
+
+TabDialog TAB_DLG_VALIDATION
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Moveable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_VALIDATION_VALUES ;
+ PageResID = TP_VALIDATION_VALUES ;
+ Text [ en-US ] = "Criteria";
+ };
+ PageItem
+ {
+ Identifier = TP_VALIDATION_INPUTHELP ;
+ PageResID = TP_VALIDATION_INPUTHELP ;
+ Text [ en-US ] = "Input Help" ;
+ };
+ PageItem
+ {
+ Identifier = TP_VALIDATION_ERROR ;
+ PageResID = TP_VALIDATION_ERROR ;
+ Text [ en-US ] = "Error Alert" ;
+ };
+ };
+ };
+ Text [ en-US ] = "Validity" ;
+};
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#define OFFSET_X 30
+//-->Added by PengYunQuan for Validity Cell Range Picker
+TabPage TP_VALIDATION_VALUES
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Text [ en-US ] = "Values" ;
+ FixedText FT_ALLOW
+ {
+ Pos = MAP_APPFONT ( 6 , 16 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "~Allow" ;
+ };
+ ListBox LB_ALLOW
+ {
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 14 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 14 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 90 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "All values" ; SC_VALIDDLG_ALLOW_ANY ; > ;
+ < "Whole Numbers" ; SC_VALIDDLG_ALLOW_WHOLE ; > ;
+ < "Decimal" ; SC_VALIDDLG_ALLOW_DECIMAL ; > ;
+ < "Date" ; SC_VALIDDLG_ALLOW_DATE ; > ;
+ < "Time" ; SC_VALIDDLG_ALLOW_TIME ; > ;
+ < "Cell range" ; SC_VALIDDLG_ALLOW_RANGE ; > ;
+ < "List" ; SC_VALIDDLG_ALLOW_LIST ; > ;
+ < "Text length" ; SC_VALIDDLG_ALLOW_TEXTLEN ; > ;
+ };
+ };
+ FixedText FT_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 58 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "~Data" ;
+ };
+ ListBox LB_VALUE
+ {
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 56 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 56 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ // Reihenfolge entspricht enum ScConditionMode
+ StringList [ en-US ] =
+ {
+ < "equal" ; SC_VALIDDLG_DATA_EQUAL ; > ;
+ < "less than" ; SC_VALIDDLG_DATA_LESS ; > ;
+ < "greater than" ; SC_VALIDDLG_DATA_GREATER ; > ;
+ < "less than or equal" ; SC_VALIDDLG_DATA_EQLESS ; > ;
+ < "greater than or equal to" ; SC_VALIDDLG_DATA_EQGREATER ; > ;
+ < "not equal" ; SC_VALIDDLG_DATA_NOTEQUAL ; > ;
+ < "between" ; SC_VALIDDLG_DATA_BETWEEN ; > ;
+ < "not between" ; SC_VALIDDLG_DATA_NOTBETWEEN ; > ;
+ };
+ };
+ FixedText FT_MIN
+ {
+ Pos = MAP_APPFONT ( 6 , 76 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "~Minimum" ;
+ };
+ Edit EDT_MIN
+ {
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 74 ) ;
+ //Size = MAP_APPFONT ( 174 , 12 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 74 ) ;
+ Size = MAP_APPFONT ( 90 , 12 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ TabStop = TRUE ;
+ };
+ MultiLineEdit EDT_LIST
+ {
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 74 ) ;
+ //Size = MAP_APPFONT ( 174 , 105 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 74 ) ;
+ Size = MAP_APPFONT ( 174 + OFFSET_X , 105 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ FixedText FT_MAX
+ {
+ Pos = MAP_APPFONT ( 6 , 92 ) ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Size = MAP_APPFONT ( 70 , 8 ) ;
+ Size = MAP_APPFONT ( 70 - OFFSET_X , 8 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Text [ en-US ] = "Ma~ximum" ;
+ };
+ Edit EDT_MAX
+ {
+ Border = TRUE ;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 90 ) ;
+ //Size = MAP_APPFONT ( 174 , 12 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 90 ) ;
+ Size = MAP_APPFONT ( 90 , 12 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ TabStop = TRUE ;
+ };
+ CheckBox TSB_ALLOW_BLANKS
+ {
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 30 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 30 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 174 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Allow ~blank cells" ;
+ };
+ CheckBox CB_SHOWLIST
+ {
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 80 , 44 ) ;
+ Pos = MAP_APPFONT ( 80 - OFFSET_X , 44 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 174 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show selection ~list" ;
+ };
+ CheckBox CB_SORTLIST
+ {
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Pos = MAP_APPFONT ( 90 , 58 ) ;
+ Pos = MAP_APPFONT ( 90 - OFFSET_X , 58 ) ;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ Size = MAP_APPFONT ( 164 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Sor~t entries ascending" ;
+ };
+ FixedText FT_SOURCEHINT
+ {
+ Pos = MAP_APPFONT ( 80 , 90 ) ;
+ Size = MAP_APPFONT ( 174 , 64 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "A valid source can only consist of a contiguous selection of rows and columns, or a formula that results in an area or array.";
+ };
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ ImageButton RB_VALIDITY_REF
+ {
+ Pos = MAP_APPFONT ( 142 , 73 ) ;
+ Size = MAP_APPFONT ( 13 , 14 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+};
+
+TabPage TP_VALIDATION_INPUTHELP
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Text = "Eingabehilfe" ;
+ TriStateBox TSB_HELP
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Show input help when cell is selected" ;
+ };
+ FixedLine FL_CONTENT
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Contents" ;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Title" ;
+ };
+ FixedText FT_INPUTHELP
+ {
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Input help" ;
+ };
+ Edit EDT_TITLE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 33 ) ;
+ Size = MAP_APPFONT ( 171 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ MultiLineEdit EDT_INPUTHELP
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 51 ) ;
+ Size = MAP_APPFONT ( 171 , 128 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+};
+
+TabPage TP_VALIDATION_ERROR
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedLine FL_CONTENT
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Contents" ;
+ };
+ TriStateBox TSB_SHOW
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show error ~message when invalid values are entered" ;
+ };
+ MultiLineEdit EDT_ERROR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 69 ) ;
+ Size = MAP_APPFONT ( 171 , 110 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ Edit EDT_TITLE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 51 ) ;
+ Size = MAP_APPFONT ( 171 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_ERROR
+ {
+ Pos = MAP_APPFONT ( 12 , 71 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Error message" ;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT ( 12 , 53 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Title" ;
+ };
+ FixedText FT_ACTION
+ {
+ Pos = MAP_APPFONT ( 12 , 35 ) ;
+ Size = MAP_APPFONT ( 64 , 8 ) ;
+ Text [ en-US ] = "~Action" ;
+ };
+ ListBox LB_ACTION
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 80 , 33 ) ;
+ Size = MAP_APPFONT ( 107 , 76 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ // Reihenfolge entspricht enum ScValidErrorStyle
+ StringList [ en-US ] =
+ {
+ < "Stop" ; Default ; > ;
+ < "Warning" ; Default ; > ;
+ < "Information" ; Default ; > ;
+ < "Macro" ; Default ; > ;
+ };
+ };
+ PushButton BTN_SEARCH
+ {
+ Pos = MAP_APPFONT ( 191 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Browse..." ;
+ };
+ Text [ en-US ] = "Error Alert" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
new file mode 100644
index 000000000000..3e3804584e2f
--- /dev/null
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -0,0 +1,531 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/linkmgr.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "arealink.hxx"
+
+#include "tablink.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "rangenam.hxx"
+#include "dbcolect.hxx"
+#include "undoblk.hxx"
+#include "globstr.hrc"
+#include "markdata.hxx"
+#include "hints.hxx"
+#include "filter.hxx"
+
+#include "attrib.hxx" // raus, wenn ResetAttrib am Dokument
+#include "patattr.hxx" // raus, wenn ResetAttrib am Dokument
+#include "docpool.hxx" // raus, wenn ResetAttrib am Dokument
+
+#include "sc.hrc"
+#include "scabstdlg.hxx"
+#include "clipparam.hxx"
+
+struct AreaLink_Impl
+{
+ ScDocShell* m_pDocSh;
+ AbstractScLinkedAreaDlg* m_pDialog;
+
+ AreaLink_Impl() : m_pDocSh( NULL ), m_pDialog( NULL ) {}
+};
+
+TYPEINIT1(ScAreaLink,::sfx2::SvBaseLink);
+
+//------------------------------------------------------------------------
+
+ScAreaLink::ScAreaLink( SfxObjectShell* pShell, const String& rFile,
+ const String& rFilter, const String& rOpt,
+ const String& rArea, const ScRange& rDest,
+ ULONG nRefresh ) :
+ ::sfx2::SvBaseLink(sfx2::LINKUPDATE_ONCALL,FORMAT_FILE),
+ ScRefreshTimer ( nRefresh ),
+ pImpl ( new AreaLink_Impl() ),
+ aFileName (rFile),
+ aFilterName (rFilter),
+ aOptions (rOpt),
+ aSourceArea (rArea),
+ aDestArea (rDest),
+ bAddUndo (TRUE),
+ bInCreate (FALSE),
+ bDoInsert (TRUE)
+{
+ DBG_ASSERT(pShell->ISA(ScDocShell), "ScAreaLink mit falscher ObjectShell");
+ pImpl->m_pDocSh = static_cast< ScDocShell* >( pShell );
+ SetRefreshHandler( LINK( this, ScAreaLink, RefreshHdl ) );
+ SetRefreshControl( pImpl->m_pDocSh->GetDocument()->GetRefreshTimerControlAddress() );
+}
+
+__EXPORT ScAreaLink::~ScAreaLink()
+{
+ StopRefreshTimer();
+ delete pImpl;
+}
+
+void __EXPORT ScAreaLink::Edit(Window* pParent, const Link& /* rEndEditHdl */ )
+{
+ // use own dialog instead of SvBaseLink::Edit...
+ // DefModalDialogParent setzen, weil evtl. aus der DocShell beim ConvertFrom
+ // ein Optionen-Dialog kommt...
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScLinkedAreaDlg* pDlg = pFact->CreateScLinkedAreaDlg( pParent, RID_SCDLG_LINKAREA);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->InitFromOldLink( aFileName, aFilterName, aOptions, aSourceArea, GetRefreshDelay() );
+ pImpl->m_pDialog = pDlg;
+ pDlg->StartExecuteModal( LINK( this, ScAreaLink, AreaEndEditHdl ) );
+}
+
+void __EXPORT ScAreaLink::DataChanged( const String&,
+ const ::com::sun::star::uno::Any& )
+{
+ // bei bInCreate nichts tun, damit Update gerufen werden kann, um den Status im
+ // LinkManager zu setzen, ohne die Daten im Dokument zu aendern
+
+ if (bInCreate)
+ return;
+
+ sfx2::LinkManager* pLinkManager=pImpl->m_pDocSh->GetDocument()->GetLinkManager();
+ if (pLinkManager!=NULL)
+ {
+ String aFile;
+ String aFilter;
+ String aArea;
+ pLinkManager->GetDisplayNames( this,0,&aFile,&aArea,&aFilter);
+
+ // the file dialog returns the filter name with the application prefix
+ // -> remove prefix
+ ScDocumentLoader::RemoveAppPrefix( aFilter );
+
+ // #81155# dialog doesn't set area, so keep old one
+ if ( !aArea.Len() )
+ {
+ aArea = aSourceArea;
+
+ // adjust in dialog:
+ String aNewLinkName;
+ sfx2::MakeLnkName( aNewLinkName, NULL, aFile, aArea, &aFilter );
+ SetName( aNewLinkName );
+ }
+
+ Refresh( aFile, aFilter, aArea, GetRefreshDelay() );
+ }
+}
+
+void __EXPORT ScAreaLink::Closed()
+{
+ // Verknuepfung loeschen: Undo
+
+ ScDocument* pDoc = pImpl->m_pDocSh->GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ if (bAddUndo && bUndo)
+ {
+ pImpl->m_pDocSh->GetUndoManager()->AddUndoAction( new ScUndoRemoveAreaLink( pImpl->m_pDocSh,
+ aFileName, aFilterName, aOptions,
+ aSourceArea, aDestArea, GetRefreshDelay() ) );
+
+ bAddUndo = FALSE; // nur einmal
+ }
+
+ SCTAB nDestTab = aDestArea.aStart.Tab();
+ if (pDoc->IsStreamValid(nDestTab))
+ pDoc->SetStreamValid(nDestTab, FALSE);
+
+ SvBaseLink::Closed();
+}
+
+void ScAreaLink::SetDestArea(const ScRange& rNew)
+{
+ aDestArea = rNew; // fuer Undo
+}
+
+void ScAreaLink::SetSource(const String& rDoc, const String& rFlt, const String& rOpt,
+ const String& rArea)
+{
+ aFileName = rDoc;
+ aFilterName = rFlt;
+ aOptions = rOpt;
+ aSourceArea = rArea;
+
+ // also update link name for dialog
+ String aNewLinkName;
+ sfx2::MakeLnkName( aNewLinkName, NULL, aFileName, aSourceArea, &aFilterName );
+ SetName( aNewLinkName );
+}
+
+BOOL ScAreaLink::IsEqual( const String& rFile, const String& rFilter, const String& rOpt,
+ const String& rSource, const ScRange& rDest ) const
+{
+ return aFileName == rFile && aFilterName == rFilter && aOptions == rOpt &&
+ aSourceArea == rSource && aDestArea.aStart == rDest.aStart;
+}
+
+// find a range with name >rAreaName< in >pSrcDoc<, return it in >rRange<
+BOOL ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const String& rAreaName )
+{
+ BOOL bFound = FALSE;
+ ScRangeName* pNames = pSrcDoc->GetRangeName();
+ USHORT nPos;
+ if (pNames) // benannte Bereiche
+ {
+ if (pNames->SearchName( rAreaName, nPos ))
+ if ( (*pNames)[nPos]->IsValidReference( rRange ) )
+ bFound = TRUE;
+ }
+ if (!bFound) // Datenbankbereiche
+ {
+ ScDBCollection* pDBColl = pSrcDoc->GetDBCollection();
+ if (pDBColl)
+ if (pDBColl->SearchName( rAreaName, nPos ))
+ {
+ SCTAB nTab;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ (*pDBColl)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
+ rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
+ bFound = TRUE;
+ }
+ }
+ if (!bFound) // direct reference (range or cell)
+ {
+ ScAddress::Details aDetails(pSrcDoc->GetAddressConvention(), 0, 0);
+ if ( rRange.ParseAny( rAreaName, pSrcDoc, aDetails ) & SCA_VALID )
+ bFound = TRUE;
+ }
+ return bFound;
+}
+
+// ausfuehren:
+
+BOOL ScAreaLink::Refresh( const String& rNewFile, const String& rNewFilter,
+ const String& rNewArea, ULONG nNewRefresh )
+{
+ // Dokument laden - wie TabLink
+
+ if (!rNewFile.Len() || !rNewFilter.Len())
+ return FALSE;
+
+ String aNewUrl( ScGlobal::GetAbsDocName( rNewFile, pImpl->m_pDocSh ) );
+ BOOL bNewUrlName = (aNewUrl != aFileName);
+
+ const SfxFilter* pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
+ if (!pFilter)
+ return FALSE;
+
+ ScDocument* pDoc = pImpl->m_pDocSh->GetDocument();
+
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ pDoc->SetInLinkUpdate( TRUE );
+
+ // wenn neuer Filter ausgewaehlt wurde, Optionen vergessen
+ if ( rNewFilter != aFilterName )
+ aOptions.Erase();
+
+ // ItemSet immer anlegen, damit die DocShell die Optionen setzen kann
+ SfxItemSet* pSet = new SfxAllItemSet( SFX_APP()->GetPool() );
+ if ( aOptions.Len() )
+ pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
+
+ SfxMedium* pMed = new SfxMedium(aNewUrl, STREAM_STD_READ, FALSE, pFilter);
+
+ ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
+//REMOVE SvEmbeddedObjectRef aRef = pSrcShell;
+ SfxObjectShellRef aRef = pSrcShell;
+ pSrcShell->DoLoad(pMed);
+
+ ScDocument* pSrcDoc = pSrcShell->GetDocument();
+
+ // Optionen koennten gesetzt worden sein
+ String aNewOpt = ScDocumentLoader::GetOptions(*pMed);
+ if (!aNewOpt.Len())
+ aNewOpt = aOptions;
+
+ // correct source range name list for web query import
+ String aTempArea;
+
+ if( rNewFilter == ScDocShell::GetWebQueryFilterName() )
+ aTempArea = ScFormatFilter::Get().GetHTMLRangeNameList( pSrcDoc, rNewArea );
+ else
+ aTempArea = rNewArea;
+
+ // find total size of source area
+ SCCOL nWidth = 0;
+ SCROW nHeight = 0;
+ xub_StrLen nTokenCnt = aTempArea.GetTokenCount( ';' );
+ xub_StrLen nStringIx = 0;
+ xub_StrLen nToken;
+
+ for( nToken = 0; nToken < nTokenCnt; nToken++ )
+ {
+ String aToken( aTempArea.GetToken( 0, ';', nStringIx ) );
+ ScRange aTokenRange;
+ if( FindExtRange( aTokenRange, pSrcDoc, aToken ) )
+ {
+ // columns: find maximum
+ nWidth = Max( nWidth, (SCCOL)(aTokenRange.aEnd.Col() - aTokenRange.aStart.Col() + 1) );
+ // rows: add row range + 1 empty row
+ nHeight += aTokenRange.aEnd.Row() - aTokenRange.aStart.Row() + 2;
+ }
+ }
+ // remove the last empty row
+ if( nHeight > 0 )
+ nHeight--;
+
+ // alte Daten loeschen / neue kopieren
+
+ ScAddress aDestPos = aDestArea.aStart;
+ SCTAB nDestTab = aDestPos.Tab();
+ ScRange aOldRange = aDestArea;
+ ScRange aNewRange = aDestArea; // alter Bereich, wenn Datei nicht gefunden o.ae.
+ if (nWidth > 0 && nHeight > 0)
+ {
+ aNewRange.aEnd.SetCol( aNewRange.aStart.Col() + nWidth - 1 );
+ aNewRange.aEnd.SetRow( aNewRange.aStart.Row() + nHeight - 1 );
+ }
+
+ //! check CanFitBlock only if bDoInsert is set?
+ BOOL bCanDo = ValidColRow( aNewRange.aEnd.Col(), aNewRange.aEnd.Row() ) &&
+ pDoc->CanFitBlock( aOldRange, aNewRange );
+ if (bCanDo)
+ {
+ ScDocShellModificator aModificator( *pImpl->m_pDocSh );
+
+ SCCOL nOldEndX = aOldRange.aEnd.Col();
+ SCROW nOldEndY = aOldRange.aEnd.Row();
+ SCCOL nNewEndX = aNewRange.aEnd.Col();
+ SCROW nNewEndY = aNewRange.aEnd.Row();
+ ScRange aMaxRange( aDestPos,
+ ScAddress(Max(nOldEndX,nNewEndX), Max(nOldEndY,nNewEndY), nDestTab) );
+
+ // Undo initialisieren
+
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRedoDoc = NULL;
+ if ( bAddUndo && bUndo )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ if ( bDoInsert )
+ {
+ if ( nNewEndX != nOldEndX || nNewEndY != nOldEndY ) // Bereich veraendert?
+ {
+ pUndoDoc->InitUndo( pDoc, 0, pDoc->GetTableCount()-1 );
+ pDoc->CopyToDocument( 0,0,0,MAXCOL,MAXROW,MAXTAB,
+ IDF_FORMULA, FALSE, pUndoDoc ); // alle Formeln
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nDestTab, nDestTab ); // nur Zieltabelle
+ pDoc->CopyToDocument( aOldRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
+ }
+ else // ohne Einfuegen
+ {
+ pUndoDoc->InitUndo( pDoc, nDestTab, nDestTab ); // nur Zieltabelle
+ pDoc->CopyToDocument( aMaxRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
+ }
+ }
+
+ // Zellen einfuegen / loeschen
+ // DeleteAreaTab loescht auch MERGE_FLAG Attribute
+
+ if (bDoInsert)
+ pDoc->FitBlock( aOldRange, aNewRange ); // incl. loeschen
+ else
+ pDoc->DeleteAreaTab( aMaxRange, IDF_ALL & ~IDF_NOTE );
+
+ // Daten kopieren
+
+ if (nWidth > 0 && nHeight > 0)
+ {
+ ScDocument aClipDoc( SCDOCMODE_CLIP );
+ ScRange aNewTokenRange( aNewRange.aStart );
+ nStringIx = 0;
+ for( nToken = 0; nToken < nTokenCnt; nToken++ )
+ {
+ String aToken( aTempArea.GetToken( 0, ';', nStringIx ) );
+ ScRange aTokenRange;
+ if( FindExtRange( aTokenRange, pSrcDoc, aToken ) )
+ {
+ SCTAB nSrcTab = aTokenRange.aStart.Tab();
+ ScMarkData aSourceMark;
+ aSourceMark.SelectOneTable( nSrcTab ); // selektieren fuer CopyToClip
+ aSourceMark.SetMarkArea( aTokenRange );
+
+ ScClipParam aClipParam(aTokenRange, false);
+ pSrcDoc->CopyToClip(aClipParam, &aClipDoc, &aSourceMark);
+
+ if ( aClipDoc.HasAttrib( 0,0,nSrcTab, MAXCOL,MAXROW,nSrcTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ //! ResetAttrib am Dokument !!!
+
+ ScPatternAttr aPattern( pSrcDoc->GetPool() );
+ aPattern.GetItemSet().Put( ScMergeAttr() ); // Defaults
+ aPattern.GetItemSet().Put( ScMergeFlagAttr() );
+ aClipDoc.ApplyPatternAreaTab( 0,0, MAXCOL,MAXROW, nSrcTab, aPattern );
+ }
+
+ aNewTokenRange.aEnd.SetCol( aNewTokenRange.aStart.Col() + (aTokenRange.aEnd.Col() - aTokenRange.aStart.Col()) );
+ aNewTokenRange.aEnd.SetRow( aNewTokenRange.aStart.Row() + (aTokenRange.aEnd.Row() - aTokenRange.aStart.Row()) );
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( nDestTab );
+ aDestMark.SetMarkArea( aNewTokenRange );
+ pDoc->CopyFromClip( aNewTokenRange, aDestMark, IDF_ALL, NULL, &aClipDoc, FALSE );
+ aNewTokenRange.aStart.SetRow( aNewTokenRange.aEnd.Row() + 2 );
+ }
+ }
+ }
+ else
+ {
+ String aErr = ScGlobal::GetRscString(STR_LINKERROR);
+ pDoc->SetString( aDestPos.Col(), aDestPos.Row(), aDestPos.Tab(), aErr );
+ }
+
+ // Undo eintragen
+
+ if ( bAddUndo && bUndo)
+ {
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, nDestTab, nDestTab );
+ pDoc->CopyToDocument( aNewRange, IDF_ALL & ~IDF_NOTE, FALSE, pRedoDoc );
+
+ pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoUpdateAreaLink( pImpl->m_pDocSh,
+ aFileName, aFilterName, aOptions,
+ aSourceArea, aOldRange, GetRefreshDelay(),
+ aNewUrl, rNewFilter, aNewOpt,
+ rNewArea, aNewRange, nNewRefresh,
+ pUndoDoc, pRedoDoc, bDoInsert ) );
+ }
+
+ // neue Einstellungen merken
+
+ if ( bNewUrlName )
+ aFileName = aNewUrl;
+ if ( rNewFilter != aFilterName )
+ aFilterName = rNewFilter;
+ if ( rNewArea != aSourceArea )
+ aSourceArea = rNewArea;
+ if ( aNewOpt != aOptions )
+ aOptions = aNewOpt;
+
+ if ( aNewRange != aDestArea )
+ aDestArea = aNewRange;
+
+ if ( nNewRefresh != GetRefreshDelay() )
+ SetRefreshDelay( nNewRefresh );
+
+ SCCOL nPaintEndX = Max( aOldRange.aEnd.Col(), aNewRange.aEnd.Col() );
+ SCROW nPaintEndY = Max( aOldRange.aEnd.Row(), aNewRange.aEnd.Row() );
+
+ if ( aOldRange.aEnd.Col() != aNewRange.aEnd.Col() )
+ nPaintEndX = MAXCOL;
+ if ( aOldRange.aEnd.Row() != aNewRange.aEnd.Row() )
+ nPaintEndY = MAXROW;
+
+ if ( !pImpl->m_pDocSh->AdjustRowHeight( aDestPos.Row(), nPaintEndY, nDestTab ) )
+ pImpl->m_pDocSh->PostPaint( aDestPos.Col(),aDestPos.Row(),nDestTab,
+ nPaintEndX,nPaintEndY,nDestTab, PAINT_GRID );
+ aModificator.SetDocumentModified();
+ }
+ else
+ {
+ // CanFitBlock FALSE -> Probleme mit zusammengefassten Zellen
+ // oder Tabellengrenze erreicht!
+ //! Zellschutz ???
+
+ //! Link-Dialog muss Default-Parent setzen
+ // "kann keine Zeilen einfuegen"
+ InfoBox aBox( Application::GetDefDialogParent(),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_2 ) );
+ aBox.Execute();
+ }
+
+ // aufraeumen
+
+ aRef->DoClose();
+
+ pDoc->SetInLinkUpdate( FALSE );
+
+ if (bCanDo)
+ {
+ // notify Uno objects (for XRefreshListener)
+ //! also notify Uno objects if file name was changed!
+ ScLinkRefreshedHint aHint;
+ aHint.SetAreaLink( aDestPos );
+ pDoc->BroadcastUno( aHint );
+ }
+
+ return bCanDo;
+}
+
+
+IMPL_LINK( ScAreaLink, RefreshHdl, ScAreaLink*, EMPTYARG )
+{
+ long nRes = Refresh( aFileName, aFilterName, aSourceArea,
+ GetRefreshDelay() ) != 0;
+ return nRes;
+}
+
+IMPL_LINK( ScAreaLink, AreaEndEditHdl, void*, EMPTYARG )
+{
+ // #i76514# can't use link argument to access the dialog,
+ // because it's the ScLinkedAreaDlg, not AbstractScLinkedAreaDlg
+
+ if ( pImpl->m_pDialog && pImpl->m_pDialog->GetResult() == RET_OK )
+ {
+ aOptions = pImpl->m_pDialog->GetOptions();
+ Refresh( pImpl->m_pDialog->GetURL(), pImpl->m_pDialog->GetFilter(),
+ pImpl->m_pDialog->GetSource(), pImpl->m_pDialog->GetRefresh() );
+
+ // copy source data from members (set in Refresh) into link name for dialog
+ String aNewLinkName;
+ sfx2::MakeLnkName( aNewLinkName, NULL, aFileName, aSourceArea, &aFilterName );
+ SetName( aNewLinkName );
+ }
+ pImpl->m_pDialog = NULL; // dialog is deleted with parent
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/autostyl.cxx b/sc/source/ui/docshell/autostyl.cxx
new file mode 100644
index 000000000000..8b275b231b28
--- /dev/null
+++ b/sc/source/ui/docshell/autostyl.cxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <time.h>
+#include "autostyl.hxx"
+
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "sc.hrc"
+
+//==================================================================
+
+struct ScAutoStyleInitData
+{
+ ScRange aRange;
+ String aStyle1;
+ ULONG nTimeout;
+ String aStyle2;
+
+ ScAutoStyleInitData( const ScRange& rR, const String& rSt1, ULONG nT, const String& rSt2 ) :
+ aRange(rR), aStyle1(rSt1), nTimeout(nT), aStyle2(rSt2) {}
+};
+
+struct ScAutoStyleData
+{
+ ULONG nTimeout;
+ ScRange aRange;
+ String aStyle;
+
+ ScAutoStyleData( ULONG nT, const ScRange& rR, const String& rT ) :
+ nTimeout(nT), aRange(rR), aStyle(rT) {}
+};
+
+//==================================================================
+
+inline ULONG TimeNow() // Sekunden
+{
+ return (ULONG) time(0);
+}
+
+//==================================================================
+
+ScAutoStyleList::ScAutoStyleList(ScDocShell* pShell) :
+ pDocSh( pShell )
+{
+ aTimer.SetTimeoutHdl( LINK( this, ScAutoStyleList, TimerHdl ) );
+ aInitTimer.SetTimeoutHdl( LINK( this, ScAutoStyleList, InitHdl ) );
+ aInitTimer.SetTimeout( 0 );
+}
+
+ScAutoStyleList::~ScAutoStyleList()
+{
+ ULONG i;
+ ULONG nCount = aEntries.Count();
+ for (i=0; i<nCount; i++)
+ delete (ScAutoStyleData*) aEntries.GetObject(i);
+ nCount = aInitials.Count();
+ for (i=0; i<nCount; i++)
+ delete (ScAutoStyleInitData*) aInitials.GetObject(i);
+}
+
+//==================================================================
+
+// initial short delay (asynchronous call)
+
+void ScAutoStyleList::AddInitial( const ScRange& rRange, const String& rStyle1,
+ ULONG nTimeout, const String& rStyle2 )
+{
+ ScAutoStyleInitData* pNew =
+ new ScAutoStyleInitData( rRange, rStyle1, nTimeout, rStyle2 );
+ aInitials.Insert( pNew, aInitials.Count() );
+ aInitTimer.Start();
+}
+
+IMPL_LINK( ScAutoStyleList, InitHdl, Timer*, EMPTYARG )
+{
+ ULONG nCount = aInitials.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScAutoStyleInitData* pData = (ScAutoStyleInitData*) aInitials.GetObject(i);
+
+ // apply first style immediately
+ pDocSh->DoAutoStyle( pData->aRange, pData->aStyle1 );
+
+ // add second style to list
+ if ( pData->nTimeout )
+ AddEntry( pData->nTimeout, pData->aRange, pData->aStyle2 );
+
+ delete pData;
+ }
+ aInitials.Clear();
+
+ return 0;
+}
+
+//==================================================================
+
+void ScAutoStyleList::AddEntry( ULONG nTimeout, const ScRange& rRange, const String& rStyle )
+{
+ aTimer.Stop();
+ ULONG nNow = TimeNow();
+
+ // alten Eintrag loeschen
+
+ ULONG nCount = aEntries.Count();
+ ULONG i;
+ for (i=0; i<nCount; i++)
+ {
+ ScAutoStyleData* pData = (ScAutoStyleData*) aEntries.GetObject(i);
+ if (pData->aRange == rRange)
+ {
+ delete pData;
+ aEntries.Remove(i);
+ --nCount;
+ break; // nicht weitersuchen - es kann nur einen geben
+ }
+ }
+
+ // Timeouts von allen Eintraegen anpassen
+
+ if (nCount && nNow != nTimerStart)
+ {
+ DBG_ASSERT(nNow>nTimerStart, "Zeit laeuft rueckwaerts?");
+ AdjustEntries((nNow-nTimerStart)*1000);
+ }
+
+ // Einfuege-Position suchen
+
+ ULONG nPos = LIST_APPEND;
+ for (i=0; i<nCount && nPos == LIST_APPEND; i++)
+ if (nTimeout <= ((ScAutoStyleData*) aEntries.GetObject(i))->nTimeout)
+ nPos = i;
+
+ ScAutoStyleData* pNew = new ScAutoStyleData( nTimeout, rRange, rStyle );
+ aEntries.Insert( pNew, nPos );
+
+ // abgelaufene ausfuehren, Timer neu starten
+
+ ExecuteEntries();
+ StartTimer(nNow);
+}
+
+void ScAutoStyleList::AdjustEntries( ULONG nDiff ) // Millisekunden
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScAutoStyleData* pData = (ScAutoStyleData*) aEntries.GetObject(i);
+ if ( pData->nTimeout <= nDiff )
+ pData->nTimeout = 0; // abgelaufen
+ else
+ pData->nTimeout -= nDiff; // weiterzaehlen
+ }
+}
+
+void ScAutoStyleList::ExecuteEntries()
+{
+ ScAutoStyleData* pData;
+ while ((pData = (ScAutoStyleData*) aEntries.GetObject(0)) != NULL && pData->nTimeout == 0)
+ {
+ pDocSh->DoAutoStyle( pData->aRange, pData->aStyle ); //! oder Request ???
+
+ delete pData;
+ aEntries.Remove((ULONG)0);
+ }
+}
+
+void ScAutoStyleList::ExecuteAllNow()
+{
+ aTimer.Stop();
+
+ ULONG nCount = aEntries.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScAutoStyleData* pData = (ScAutoStyleData*) aEntries.GetObject(i);
+
+ pDocSh->DoAutoStyle( pData->aRange, pData->aStyle ); //! oder Request ???
+
+ delete pData;
+ }
+ aEntries.Clear();
+}
+
+void ScAutoStyleList::StartTimer( ULONG nNow ) // Sekunden
+{
+ // ersten Eintrag mit Timeout != 0 suchen
+
+ ULONG nPos = 0;
+ ScAutoStyleData* pData;
+ while ( (pData = (ScAutoStyleData*) aEntries.GetObject(nPos)) != NULL && pData->nTimeout == 0 )
+ ++nPos;
+
+ if (pData)
+ {
+ aTimer.SetTimeout( pData->nTimeout );
+ aTimer.Start();
+ }
+ nTimerStart = nNow;
+}
+
+IMPL_LINK( ScAutoStyleList, TimerHdl, Timer*, EMPTYARG )
+{
+ ULONG nNow = TimeNow();
+ AdjustEntries(aTimer.GetTimeout()); // eingestellte Wartezeit
+ ExecuteEntries();
+ StartTimer(nNow);
+
+ return 0;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
new file mode 100644
index 000000000000..032d3b1d4bbb
--- /dev/null
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -0,0 +1,1504 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+#include "dbdocfun.hxx"
+#include "sc.hrc"
+#include "dbcolect.hxx"
+#include "undodat.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "patattr.hxx"
+#include "rangenam.hxx"
+#include "olinetab.hxx"
+#include "dpobject.hxx"
+#include "dociter.hxx" // for lcl_EmptyExcept
+#include "cell.hxx" // for lcl_EmptyExcept
+#include "editable.hxx"
+#include "attrib.hxx"
+#include "drwlayer.hxx"
+#include "dpshttab.hxx"
+#include "hints.hxx"
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::AddDBRange( const String& rName, const ScRange& rRange, BOOL /* bApi */ )
+{
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScDBCollection* pDocColl = pDoc->GetDBCollection();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ ScDBCollection* pUndoColl = NULL;
+ if (bUndo)
+ pUndoColl = new ScDBCollection( *pDocColl );
+
+ ScDBData* pNew = new ScDBData( rName, rRange.aStart.Tab(),
+ rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row() );
+
+ // #i55926# While loading XML, formula cells only have a single string token,
+ // so CompileDBFormula would never find any name (index) tokens, and would
+ // unnecessarily loop through all cells.
+ BOOL bCompile = !pDoc->IsImportingXML();
+
+ if ( bCompile )
+ pDoc->CompileDBFormula( TRUE ); // CreateFormulaString
+ BOOL bOk = pDocColl->Insert( pNew );
+ if ( bCompile )
+ pDoc->CompileDBFormula( FALSE ); // CompileFormulaString
+
+ if (!bOk)
+ {
+ delete pNew;
+ delete pUndoColl;
+ return FALSE;
+ }
+
+ if (bUndo)
+ {
+ ScDBCollection* pRedoColl = new ScDBCollection( *pDocColl );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDBData( &rDocShell, pUndoColl, pRedoColl ) );
+ }
+
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ return TRUE;
+}
+
+BOOL ScDBDocFunc::DeleteDBRange( const String& rName, BOOL /* bApi */ )
+{
+ BOOL bDone = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScDBCollection* pDocColl = pDoc->GetDBCollection();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ USHORT nPos = 0;
+ if (pDocColl->SearchName( rName, nPos ))
+ {
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDBCollection* pUndoColl = NULL;
+ if (bUndo)
+ pUndoColl = new ScDBCollection( *pDocColl );
+
+ pDoc->CompileDBFormula( TRUE ); // CreateFormulaString
+ pDocColl->AtFree( nPos );
+ pDoc->CompileDBFormula( FALSE ); // CompileFormulaString
+
+ if (bUndo)
+ {
+ ScDBCollection* pRedoColl = new ScDBCollection( *pDocColl );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDBData( &rDocShell, pUndoColl, pRedoColl ) );
+ }
+
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ bDone = TRUE;
+ }
+
+ return bDone;
+}
+
+BOOL ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew, BOOL /* bApi */ )
+{
+ BOOL bDone = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScDBCollection* pDocColl = pDoc->GetDBCollection();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ USHORT nPos = 0;
+ USHORT nDummy = 0;
+ if ( pDocColl->SearchName( rOld, nPos ) &&
+ !pDocColl->SearchName( rNew, nDummy ) )
+ {
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDBData* pData = (*pDocColl)[nPos];
+ ScDBData* pNewData = new ScDBData(*pData);
+ pNewData->SetName(rNew);
+
+ ScDBCollection* pUndoColl = new ScDBCollection( *pDocColl );
+
+ pDoc->CompileDBFormula( TRUE ); // CreateFormulaString
+ pDocColl->AtFree( nPos );
+ BOOL bInserted = pDocColl->Insert( pNewData );
+ if (!bInserted) // Fehler -> alten Zustand wiederherstellen
+ {
+ delete pNewData;
+ pDoc->SetDBCollection( pUndoColl ); // gehoert dann dem Dokument
+ }
+ pDoc->CompileDBFormula( FALSE ); // CompileFormulaString
+
+ if (bInserted) // Einfuegen hat geklappt
+ {
+ if (bUndo)
+ {
+ ScDBCollection* pRedoColl = new ScDBCollection( *pDocColl );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDBData( &rDocShell, pUndoColl, pRedoColl ) );
+ }
+ else
+ delete pUndoColl;
+
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ bDone = TRUE;
+ }
+ }
+
+ return bDone;
+}
+
+BOOL ScDBDocFunc::ModifyDBData( const ScDBData& rNewData, BOOL /* bApi */ )
+{
+ BOOL bDone = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScDBCollection* pDocColl = pDoc->GetDBCollection();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ USHORT nPos = 0;
+ if (pDocColl->SearchName( rNewData.GetName(), nPos ))
+ {
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDBData* pData = (*pDocColl)[nPos];
+
+ ScRange aOldRange, aNewRange;
+ pData->GetArea(aOldRange);
+ rNewData.GetArea(aNewRange);
+ BOOL bAreaChanged = ( aOldRange != aNewRange ); // dann muss neu compiliert werden
+
+ ScDBCollection* pUndoColl = NULL;
+ if (bUndo)
+ pUndoColl = new ScDBCollection( *pDocColl );
+
+ *pData = rNewData;
+ if (bAreaChanged)
+ pDoc->CompileDBFormula();
+
+ if (bUndo)
+ {
+ ScDBCollection* pRedoColl = new ScDBCollection( *pDocColl );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDBData( &rDocShell, pUndoColl, pRedoColl ) );
+ }
+
+ aModificator.SetDocumentModified();
+ bDone = TRUE;
+ }
+
+ return bDone;
+}
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::RepeatDB( const String& rDBName, BOOL bRecord, BOOL bApi )
+{
+ //! auch fuer ScDBFunc::RepeatDB benutzen!
+
+ BOOL bDone = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ USHORT nIndex;
+ if ( pColl && pColl->SearchName( rDBName, nIndex ) )
+ {
+ ScDBData* pDBData = (*pColl)[nIndex];
+
+ ScQueryParam aQueryParam;
+ pDBData->GetQueryParam( aQueryParam );
+ BOOL bQuery = aQueryParam.GetEntry(0).bDoQuery;
+
+ ScSortParam aSortParam;
+ pDBData->GetSortParam( aSortParam );
+ BOOL bSort = aSortParam.bDoSort[0];
+
+ ScSubTotalParam aSubTotalParam;
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ BOOL bSubTotal = aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly;
+
+ if ( bQuery || bSort || bSubTotal )
+ {
+ BOOL bQuerySize = FALSE;
+ ScRange aOldQuery;
+ ScRange aNewQuery;
+ if (bQuery && !aQueryParam.bInplace)
+ {
+ ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, TRUE );
+ if (pDest && pDest->IsDoSize())
+ {
+ pDest->GetArea( aOldQuery );
+ bQuerySize = TRUE;
+ }
+ }
+
+ SCTAB nTab;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pDBData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+
+ //! Undo nur benoetigte Daten ?
+
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ ScRangeName* pUndoRange = NULL;
+ ScDBCollection* pUndoDB = NULL;
+
+ if (bRecord)
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ // column/row state
+ SCCOLROW nOutStartCol, nOutEndCol;
+ SCCOLROW nOutStartRow, nOutEndRow;
+ pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol );
+ pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow );
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nOutStartCol), 0,
+ nTab, static_cast<SCCOL>(nOutEndCol), MAXROW, nTab,
+ IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, static_cast<SCROW>(nOutStartRow),
+ nTab, MAXCOL, static_cast<SCROW>(nOutEndRow), nTab,
+ IDF_NONE, FALSE, pUndoDoc );
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+
+ // Datenbereich sichern - incl. Filter-Ergebnis
+ pDoc->CopyToDocument( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab, IDF_ALL, FALSE, pUndoDoc );
+
+ // alle Formeln wegen Referenzen
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, IDF_FORMULA, FALSE, pUndoDoc );
+
+ // DB- und andere Bereiche
+ ScRangeName* pDocRange = pDoc->GetRangeName();
+ if (pDocRange->GetCount())
+ pUndoRange = new ScRangeName( *pDocRange );
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+ }
+
+ if (bSort && bSubTotal)
+ {
+ // Sortieren ohne SubTotals
+
+ aSubTotalParam.bRemoveOnly = TRUE; // wird unten wieder zurueckgesetzt
+ DoSubTotals( nTab, aSubTotalParam, NULL, FALSE, bApi );
+ }
+
+ if (bSort)
+ {
+ pDBData->GetSortParam( aSortParam ); // Bereich kann sich geaendert haben
+ Sort( nTab, aSortParam, FALSE, FALSE, bApi );
+ }
+ if (bQuery)
+ {
+ pDBData->GetQueryParam( aQueryParam ); // Bereich kann sich geaendert haben
+ ScRange aAdvSource;
+ if (pDBData->GetAdvancedQuerySource(aAdvSource))
+ Query( nTab, aQueryParam, &aAdvSource, FALSE, bApi );
+ else
+ Query( nTab, aQueryParam, NULL, FALSE, bApi );
+
+ // bei nicht-inplace kann die Tabelle umgestellt worden sein
+// if ( !aQueryParam.bInplace && aQueryParam.nDestTab != nTab )
+// SetTabNo( nTab );
+ }
+ if (bSubTotal)
+ {
+ pDBData->GetSubTotalParam( aSubTotalParam ); // Bereich kann sich geaendert haben
+ aSubTotalParam.bRemoveOnly = FALSE;
+ DoSubTotals( nTab, aSubTotalParam, NULL, FALSE, bApi );
+ }
+
+ if (bRecord)
+ {
+ SCTAB nDummyTab;
+ SCCOL nDummyCol;
+ SCROW nDummyRow;
+ SCROW nNewEndRow;
+ pDBData->GetArea( nDummyTab, nDummyCol,nDummyRow, nDummyCol,nNewEndRow );
+
+ const ScRange* pOld = NULL;
+ const ScRange* pNew = NULL;
+ if (bQuerySize)
+ {
+ ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, TRUE );
+ if (pDest)
+ {
+ pDest->GetArea( aNewQuery );
+ pOld = &aOldQuery;
+ pNew = &aNewQuery;
+ }
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoRepeatDB( &rDocShell, nTab,
+ nStartCol, nStartRow, nEndCol, nEndRow,
+ nNewEndRow,
+ //nCurX, nCurY,
+ nStartCol, nStartRow,
+ pUndoDoc, pUndoTab,
+ pUndoRange, pUndoDB,
+ pOld, pNew ) );
+ }
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+ bDone = TRUE;
+ }
+ else if (!bApi) // "Keine Operationen auszufuehren"
+ rDocShell.ErrorMessage(STR_MSSG_REPEATDB_0);
+ }
+
+ return bDone;
+}
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::Sort( SCTAB nTab, const ScSortParam& rSortParam,
+ BOOL bRecord, BOOL bPaint, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ SCTAB nSrcTab = nTab;
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rSortParam.nCol1, rSortParam.nRow1,
+ rSortParam.nCol2, rSortParam.nRow2 );
+ if (!pDBData)
+ {
+ DBG_ERROR( "Sort: keine DBData" );
+ return FALSE;
+ }
+
+ ScDBData* pDestData = NULL;
+ ScRange aOldDest;
+ BOOL bCopy = !rSortParam.bInplace;
+ if ( bCopy && rSortParam.nDestCol == rSortParam.nCol1 &&
+ rSortParam.nDestRow == rSortParam.nRow1 && rSortParam.nDestTab == nTab )
+ bCopy = FALSE;
+ ScSortParam aLocalParam( rSortParam );
+ if ( bCopy )
+ {
+ aLocalParam.MoveToDest();
+ if ( !ValidColRow( aLocalParam.nCol2, aLocalParam.nRow2 ) )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PASTE_FULL);
+ return FALSE;
+ }
+
+ nTab = rSortParam.nDestTab;
+ pDestData = pDoc->GetDBAtCursor( rSortParam.nDestCol, rSortParam.nDestRow,
+ rSortParam.nDestTab, TRUE );
+ if (pDestData)
+ pDestData->GetArea(aOldDest);
+ }
+
+ ScEditableTester aTester( pDoc, nTab, aLocalParam.nCol1,aLocalParam.nRow1,
+ aLocalParam.nCol2,aLocalParam.nRow2 );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ if ( aLocalParam.bIncludePattern && pDoc->HasAttrib(
+ aLocalParam.nCol1, aLocalParam.nRow1, nTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ // Merge-Attribute wuerden beim Sortieren durcheinanderkommen
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_SORT_ERR_MERGED);
+ return FALSE;
+ }
+
+
+ // ausfuehren
+
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ BOOL bRepeatQuery = FALSE; // bestehenden Filter wiederholen?
+ ScQueryParam aQueryParam;
+ pDBData->GetQueryParam( aQueryParam );
+ if ( aQueryParam.GetEntry(0).bDoQuery )
+ bRepeatQuery = TRUE;
+
+ if (bRepeatQuery && bCopy)
+ {
+ if ( aQueryParam.bInplace ||
+ aQueryParam.nDestCol != rSortParam.nDestCol ||
+ aQueryParam.nDestRow != rSortParam.nDestRow ||
+ aQueryParam.nDestTab != rSortParam.nDestTab ) // Query auf selben Zielbereich?
+ bRepeatQuery = FALSE;
+ }
+
+ ScUndoSort* pUndoAction = 0;
+ if ( bRecord )
+ {
+ // Referenzen ausserhalb des Bereichs werden nicht veraendert !
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ // Zeilenhoehen immer (wegen automatischer Anpassung)
+ //! auf ScBlockUndo umstellen
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+
+ /* #i59745# Do not copy note captions to undo document. All existing
+ caption objects will be repositioned while sorting which is tracked
+ in drawing undo. When undo is executed, the old positions will be
+ restored, and the cells with the old notes (which still refer to the
+ existing captions) will be copied back into the source document. */
+ pDoc->CopyToDocument( aLocalParam.nCol1, aLocalParam.nRow1, nTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nTab,
+ IDF_ALL|IDF_NOCAPTIONS, FALSE, pUndoDoc );
+
+ const ScRange* pR = 0;
+ if (pDestData)
+ {
+ /* #i59745# Do not copy note captions from destination range to
+ undo document. All existing caption objects will be removed
+ which is tracked in drawing undo. When undo is executed, the
+ caption objects are reinserted with drawing undo, and the cells
+ with the old notes (which still refer to the existing captions)
+ will be copied back into the source document. */
+ pDoc->CopyToDocument( aOldDest, IDF_ALL|IDF_NOCAPTIONS, FALSE, pUndoDoc );
+ pR = &aOldDest;
+ }
+
+ // Zeilenhoehen immer (wegen automatischer Anpassung)
+ //! auf ScBlockUndo umstellen
+// if (bRepeatQuery)
+ pDoc->CopyToDocument( 0, aLocalParam.nRow1, nTab, MAXCOL, aLocalParam.nRow2, nTab,
+ IDF_NONE, FALSE, pUndoDoc );
+
+ ScDBCollection* pUndoDB = NULL;
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+
+ pUndoAction = new ScUndoSort( &rDocShell, nTab, rSortParam, bRepeatQuery, pUndoDoc, pUndoDB, pR );
+ rDocShell.GetUndoManager()->AddUndoAction( pUndoAction );
+
+ // #i59745# collect all drawing undo actions affecting cell note captions
+ if( pDrawLayer )
+ pDrawLayer->BeginCalcUndo();
+ }
+
+ if ( bCopy )
+ {
+ if (pDestData)
+ pDoc->DeleteAreaTab(aOldDest, IDF_CONTENTS); // Zielbereich vorher loeschen
+
+ ScRange aSource( rSortParam.nCol1,rSortParam.nRow1,nSrcTab,
+ rSortParam.nCol2,rSortParam.nRow2,nSrcTab );
+ ScAddress aDest( rSortParam.nDestCol, rSortParam.nDestRow, rSortParam.nDestTab );
+
+ rDocShell.GetDocFunc().MoveBlock( aSource, aDest, FALSE, FALSE, FALSE, TRUE );
+ }
+
+ // #105780# don't call ScDocument::Sort with an empty SortParam (may be empty here if bCopy is set)
+ if ( aLocalParam.bDoSort[0] )
+ pDoc->Sort( nTab, aLocalParam, bRepeatQuery );
+
+ BOOL bSave = TRUE;
+ if (bCopy)
+ {
+ ScSortParam aOldSortParam;
+ pDBData->GetSortParam( aOldSortParam );
+ if ( aOldSortParam.bDoSort[0] && aOldSortParam.bInplace ) // Inplace-Sortierung gemerkt?
+ {
+ bSave = FALSE;
+ aOldSortParam.nDestCol = rSortParam.nDestCol;
+ aOldSortParam.nDestRow = rSortParam.nDestRow;
+ aOldSortParam.nDestTab = rSortParam.nDestTab;
+ pDBData->SetSortParam( aOldSortParam ); // dann nur DestPos merken
+ }
+ }
+ if (bSave) // Parameter merken
+ {
+ pDBData->SetSortParam( rSortParam );
+ pDBData->SetHeader( rSortParam.bHasHeader ); //! ???
+ pDBData->SetByRow( rSortParam.bByRow ); //! ???
+ }
+
+ if (bCopy) // neuen DB-Bereich merken
+ {
+ // Tabelle umschalten von aussen (View)
+ //! SetCursor ??!?!
+
+ ScRange aDestPos( aLocalParam.nCol1, aLocalParam.nRow1, nTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nTab );
+ ScDBData* pNewData;
+ if (pDestData)
+ pNewData = pDestData; // Bereich vorhanden -> anpassen
+ else // Bereich ab Cursor/Markierung wird angelegt
+ pNewData = rDocShell.GetDBData(aDestPos, SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
+ if (pNewData)
+ {
+ pNewData->SetArea( nTab,
+ aLocalParam.nCol1,aLocalParam.nRow1,
+ aLocalParam.nCol2,aLocalParam.nRow2 );
+ pNewData->SetSortParam( aLocalParam );
+ pNewData->SetHeader( aLocalParam.bHasHeader ); //! ???
+ pNewData->SetByRow( aLocalParam.bByRow );
+ }
+ else
+ {
+ DBG_ERROR("Zielbereich nicht da");
+ }
+ }
+
+ ScRange aDirtyRange( aLocalParam.nCol1, aLocalParam.nRow1, nTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nTab );
+ pDoc->SetDirty( aDirtyRange );
+
+ if (bPaint)
+ {
+ USHORT nPaint = PAINT_GRID;
+ SCCOL nStartX = aLocalParam.nCol1;
+ SCROW nStartY = aLocalParam.nRow1;
+ SCCOL nEndX = aLocalParam.nCol2;
+ SCROW nEndY = aLocalParam.nRow2;
+ if ( bRepeatQuery )
+ {
+ nPaint |= PAINT_LEFT;
+ nStartX = 0;
+ nEndX = MAXCOL;
+ }
+ if (pDestData)
+ {
+ if ( nEndX < aOldDest.aEnd.Col() )
+ nEndX = aOldDest.aEnd.Col();
+ if ( nEndY < aOldDest.aEnd.Row() )
+ nEndY = aOldDest.aEnd.Row();
+ }
+ rDocShell.PostPaint( nStartX, nStartY, nTab, nEndX, nEndY, nTab, nPaint );
+ }
+
+ // AdjustRowHeight( aLocalParam.nRow1, aLocalParam.nRow2, bPaint );
+ rDocShell.AdjustRowHeight( aLocalParam.nRow1, aLocalParam.nRow2, nTab );
+
+ // #i59745# set collected drawing undo actions at sorting undo action
+ if( pUndoAction && pDrawLayer )
+ pUndoAction->SetDrawUndoAction( pDrawLayer->GetCalcUndo() );
+
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
+ const ScRange* pAdvSource, BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rQueryParam.nCol1, rQueryParam.nRow1,
+ rQueryParam.nCol2, rQueryParam.nRow2 );
+ if (!pDBData)
+ {
+ DBG_ERROR( "Query: keine DBData" );
+ return FALSE;
+ }
+
+ // Wechsel von Inplace auf nicht-Inplace, dann erst Inplace aufheben:
+ // (nur, wenn im Dialog "Persistent" ausgewaehlt ist)
+
+ if ( !rQueryParam.bInplace && pDBData->HasQueryParam() && rQueryParam.bDestPers )
+ {
+ ScQueryParam aOldQuery;
+ pDBData->GetQueryParam(aOldQuery);
+ if (aOldQuery.bInplace)
+ {
+ // alte Filterung aufheben
+
+ SCSIZE nEC = aOldQuery.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ aOldQuery.GetEntry(i).bDoQuery = FALSE;
+ aOldQuery.bDuplicate = TRUE;
+ Query( nTab, aOldQuery, NULL, bRecord, bApi );
+ }
+ }
+
+ ScQueryParam aLocalParam( rQueryParam ); // fuer Paint / Zielbereich
+ BOOL bCopy = !rQueryParam.bInplace; // kopiert wird in Table::Query
+ ScDBData* pDestData = NULL; // Bereich, in den kopiert wird
+ BOOL bDoSize = FALSE; // Zielgroesse anpassen (einf./loeschen)
+ SCCOL nFormulaCols = 0; // nur bei bDoSize
+ BOOL bKeepFmt = FALSE;
+ ScRange aOldDest;
+ ScRange aDestTotal;
+ if ( bCopy && rQueryParam.nDestCol == rQueryParam.nCol1 &&
+ rQueryParam.nDestRow == rQueryParam.nRow1 && rQueryParam.nDestTab == nTab )
+ bCopy = FALSE;
+ SCTAB nDestTab = nTab;
+ if ( bCopy )
+ {
+ aLocalParam.MoveToDest();
+ nDestTab = rQueryParam.nDestTab;
+ if ( !ValidColRow( aLocalParam.nCol2, aLocalParam.nRow2 ) )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PASTE_FULL);
+ return FALSE;
+ }
+
+ ScEditableTester aTester( pDoc, nDestTab, aLocalParam.nCol1,aLocalParam.nRow1,
+ aLocalParam.nCol2,aLocalParam.nRow2);
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ pDestData = pDoc->GetDBAtCursor( rQueryParam.nDestCol, rQueryParam.nDestRow,
+ rQueryParam.nDestTab, TRUE );
+ if (pDestData)
+ {
+ pDestData->GetArea( aOldDest );
+ aDestTotal=ScRange( rQueryParam.nDestCol,
+ rQueryParam.nDestRow,
+ nDestTab,
+ rQueryParam.nDestCol + rQueryParam.nCol2 - rQueryParam.nCol1,
+ rQueryParam.nDestRow + rQueryParam.nRow2 - rQueryParam.nRow1,
+ nDestTab );
+
+ bDoSize = pDestData->IsDoSize();
+ // Test, ob Formeln aufgefuellt werden muessen (nFormulaCols):
+ if ( bDoSize && aOldDest.aEnd.Col() == aDestTotal.aEnd.Col() )
+ {
+ SCCOL nTestCol = aOldDest.aEnd.Col() + 1; // neben dem Bereich
+ SCROW nTestRow = rQueryParam.nDestRow +
+ ( aLocalParam.bHasHeader ? 1 : 0 );
+ while ( nTestCol <= MAXCOL &&
+ pDoc->GetCellType(ScAddress( nTestCol, nTestRow, nTab )) == CELLTYPE_FORMULA )
+ ++nTestCol, ++nFormulaCols;
+ }
+
+ bKeepFmt = pDestData->IsKeepFmt();
+ if ( bDoSize && !pDoc->CanFitBlock( aOldDest, aDestTotal ) )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_DOSUBTOTALS_2); // kann keine Zeilen einfuegen
+ return FALSE;
+ }
+ }
+ }
+
+ // ausfuehren
+
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ BOOL bKeepSub = FALSE; // bestehende Teilergebnisse wiederholen?
+ ScSubTotalParam aSubTotalParam;
+ if (rQueryParam.GetEntry(0).bDoQuery) // nicht beim Aufheben
+ {
+ pDBData->GetSubTotalParam( aSubTotalParam ); // Teilergebnisse vorhanden?
+
+ if ( aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly )
+ bKeepSub = TRUE;
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ ScDBCollection* pUndoDB = NULL;
+ const ScRange* pOld = NULL;
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ if (bCopy)
+ {
+ pUndoDoc->InitUndo( pDoc, nDestTab, nDestTab, FALSE, TRUE );
+ pDoc->CopyToDocument( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nDestTab,
+ IDF_ALL, FALSE, pUndoDoc );
+ // Attribute sichern, falls beim Filtern mitkopiert
+
+ if (pDestData)
+ {
+ pDoc->CopyToDocument( aOldDest, IDF_ALL, FALSE, pUndoDoc );
+ pOld = &aOldDest;
+ }
+ }
+ else
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+ pDoc->CopyToDocument( 0, rQueryParam.nRow1, nTab, MAXCOL, rQueryParam.nRow2, nTab,
+ IDF_NONE, FALSE, pUndoDoc );
+ }
+
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+
+ pDoc->BeginDrawUndo();
+ }
+
+ ScDocument* pAttribDoc = NULL;
+ ScRange aAttribRange;
+ if (pDestData) // Zielbereich loeschen
+ {
+ if ( bKeepFmt )
+ {
+ // kleinere der End-Spalten, Header+1 Zeile
+ aAttribRange = aOldDest;
+ if ( aAttribRange.aEnd.Col() > aDestTotal.aEnd.Col() )
+ aAttribRange.aEnd.SetCol( aDestTotal.aEnd.Col() );
+ aAttribRange.aEnd.SetRow( aAttribRange.aStart.Row() +
+ ( aLocalParam.bHasHeader ? 1 : 0 ) );
+
+ // auch fuer aufgefuellte Formeln
+ aAttribRange.aEnd.SetCol( aAttribRange.aEnd.Col() + nFormulaCols );
+
+ pAttribDoc = new ScDocument( SCDOCMODE_UNDO );
+ pAttribDoc->InitUndo( pDoc, nDestTab, nDestTab, FALSE, TRUE );
+ pDoc->CopyToDocument( aAttribRange, IDF_ATTRIB, FALSE, pAttribDoc );
+ }
+
+ if ( bDoSize )
+ pDoc->FitBlock( aOldDest, aDestTotal );
+ else
+ pDoc->DeleteAreaTab(aOldDest, IDF_ALL); // einfach loeschen
+ }
+
+ // Filtern am Dokument ausfuehren
+ SCSIZE nCount = pDoc->Query( nTab, rQueryParam, bKeepSub );
+ if (bCopy)
+ {
+ aLocalParam.nRow2 = aLocalParam.nRow1 + nCount;
+ if (!aLocalParam.bHasHeader && nCount > 0)
+ --aLocalParam.nRow2;
+
+ if ( bDoSize )
+ {
+ // auf wirklichen Ergebnis-Bereich anpassen
+ // (das hier ist immer eine Verkleinerung)
+
+ ScRange aNewDest( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nDestTab );
+ pDoc->FitBlock( aDestTotal, aNewDest, FALSE ); // FALSE - nicht loeschen
+
+ if ( nFormulaCols > 0 )
+ {
+ // Formeln ausfuellen
+ //! Undo (Query und Repeat) !!!
+
+ ScRange aNewForm( aLocalParam.nCol2+1, aLocalParam.nRow1, nDestTab,
+ aLocalParam.nCol2+nFormulaCols, aLocalParam.nRow2, nDestTab );
+ ScRange aOldForm = aNewForm;
+ aOldForm.aEnd.SetRow( aOldDest.aEnd.Row() );
+ pDoc->FitBlock( aOldForm, aNewForm, FALSE );
+
+ ScMarkData aMark;
+ aMark.SelectOneTable(nDestTab);
+ SCROW nFStartY = aLocalParam.nRow1 + ( aLocalParam.bHasHeader ? 1 : 0 );
+ pDoc->Fill( aLocalParam.nCol2+1, nFStartY,
+ aLocalParam.nCol2+nFormulaCols, nFStartY, aMark,
+ aLocalParam.nRow2 - nFStartY,
+ FILL_TO_BOTTOM, FILL_SIMPLE );
+ }
+ }
+
+ if ( pAttribDoc ) // gemerkte Attribute zurueckkopieren
+ {
+ // Header
+ if (aLocalParam.bHasHeader)
+ {
+ ScRange aHdrRange = aAttribRange;
+ aHdrRange.aEnd.SetRow( aHdrRange.aStart.Row() );
+ pAttribDoc->CopyToDocument( aHdrRange, IDF_ATTRIB, FALSE, pDoc );
+ }
+
+ // Daten
+ SCCOL nAttrEndCol = aAttribRange.aEnd.Col();
+ SCROW nAttrRow = aAttribRange.aStart.Row() + ( aLocalParam.bHasHeader ? 1 : 0 );
+ for (SCCOL nCol = aAttribRange.aStart.Col(); nCol<=nAttrEndCol; nCol++)
+ {
+ const ScPatternAttr* pSrcPattern = pAttribDoc->GetPattern(
+ nCol, nAttrRow, nDestTab );
+ DBG_ASSERT(pSrcPattern,"Pattern ist 0");
+ if (pSrcPattern)
+ pDoc->ApplyPatternAreaTab( nCol, nAttrRow, nCol, aLocalParam.nRow2,
+ nDestTab, *pSrcPattern );
+ const ScStyleSheet* pStyle = pSrcPattern->GetStyleSheet();
+ if (pStyle)
+ pDoc->ApplyStyleAreaTab( nCol, nAttrRow, nCol, aLocalParam.nRow2,
+ nDestTab, *pStyle );
+ }
+
+ delete pAttribDoc;
+ }
+ }
+
+ // speichern: Inplace immer, sonst je nach Einstellung
+ // alter Inplace-Filter ist ggf. schon aufgehoben
+
+ BOOL bSave = rQueryParam.bInplace || rQueryParam.bDestPers;
+ if (bSave) // merken
+ {
+ pDBData->SetQueryParam( rQueryParam );
+ pDBData->SetHeader( rQueryParam.bHasHeader ); //! ???
+ pDBData->SetAdvancedQuerySource( pAdvSource ); // after SetQueryParam
+ }
+
+ if (bCopy) // neuen DB-Bereich merken
+ {
+ // selektieren wird hinterher von aussen (dbfunc)
+ // momentan ueber DB-Bereich an der Zielposition, darum muss dort
+ // auf jeden Fall ein Bereich angelegt werden.
+
+ ScDBData* pNewData;
+ if (pDestData)
+ pNewData = pDestData; // Bereich vorhanden -> anpassen (immer!)
+ else // Bereich anlegen
+ pNewData = rDocShell.GetDBData(
+ ScRange( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
+ aLocalParam.nCol2, aLocalParam.nRow2, nDestTab ),
+ SC_DB_MAKE, SC_DBSEL_FORCE_MARK );
+
+ if (pNewData)
+ {
+ pNewData->SetArea( nDestTab, aLocalParam.nCol1, aLocalParam.nRow1,
+ aLocalParam.nCol2, aLocalParam.nRow2 );
+
+ // Query-Param wird am Ziel nicht mehr eingestellt, fuehrt nur zu Verwirrung
+ // und Verwechslung mit dem Query-Param am Quellbereich (#37187#)
+ }
+ else
+ {
+ DBG_ERROR("Zielbereich nicht da");
+ }
+ }
+
+ if (!bCopy)
+ {
+ pDoc->InvalidatePageBreaks(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+ }
+
+ // #i23299# Subtotal functions depend on cell's filtered states.
+ ScRange aDirtyRange(0 , aLocalParam.nRow1, nDestTab, MAXCOL, aLocalParam.nRow2, nDestTab);
+ pDoc->SetSubTotalCellsDirty(aDirtyRange);
+
+ if ( bRecord )
+ {
+ // create undo action after executing, because of drawing layer undo
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoQuery( &rDocShell, nTab, rQueryParam, pUndoDoc, pUndoDB,
+ pOld, bDoSize, pAdvSource ) );
+ }
+
+
+ if (bCopy)
+ {
+ SCCOL nEndX = aLocalParam.nCol2;
+ SCROW nEndY = aLocalParam.nRow2;
+ if (pDestData)
+ {
+ if ( aOldDest.aEnd.Col() > nEndX )
+ nEndX = aOldDest.aEnd.Col();
+ if ( aOldDest.aEnd.Row() > nEndY )
+ nEndY = aOldDest.aEnd.Row();
+ }
+ if (bDoSize)
+ nEndY = MAXROW;
+ rDocShell.PostPaint( aLocalParam.nCol1, aLocalParam.nRow1, nDestTab,
+ nEndX, nEndY, nDestTab, PAINT_GRID );
+ }
+ else
+ rDocShell.PostPaint( 0, rQueryParam.nRow1, nTab, MAXCOL, MAXROW, nTab,
+ PAINT_GRID | PAINT_LEFT );
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam,
+ const ScSortParam* pForceNewSort, BOOL bRecord, BOOL bApi )
+{
+ //! auch fuer ScDBFunc::DoSubTotals benutzen!
+ // dann bleibt aussen:
+ // - neuen Bereich (aus DBData) markieren
+ // - SelectionChanged (?)
+
+ BOOL bDo = !rParam.bRemoveOnly; // FALSE = nur loeschen
+ BOOL bRet = FALSE;
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1,
+ rParam.nCol2, rParam.nRow2 );
+ if (!pDBData)
+ {
+ DBG_ERROR( "SubTotals: keine DBData" );
+ return FALSE;
+ }
+
+ ScEditableTester aTester( pDoc, nTab, 0,rParam.nRow1+1, MAXCOL,MAXROW );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ if (pDoc->HasAttrib( rParam.nCol1, rParam.nRow1+1, nTab,
+ rParam.nCol2, rParam.nRow2, nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0); // nicht in zusammengefasste einfuegen
+ return FALSE;
+ }
+
+ BOOL bOk = TRUE;
+ BOOL bDelete = FALSE;
+ if (rParam.bReplace)
+ if (pDoc->TestRemoveSubTotals( nTab, rParam ))
+ {
+ bDelete = TRUE;
+ bOk = ( MessBox( rDocShell.GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ // "StarCalc" "Daten loeschen?"
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_1 ) ).Execute()
+ == RET_YES );
+ }
+
+ if (bOk)
+ {
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScSubTotalParam aNewParam( rParam ); // Bereichsende wird veraendert
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ ScRangeName* pUndoRange = NULL;
+ ScDBCollection* pUndoDB = NULL;
+ SCTAB nTabCount = 0; // fuer Referenz-Undo
+
+ if (bRecord) // alte Daten sichern
+ {
+ BOOL bOldFilter = bDo && rParam.bDoSort;
+
+ nTabCount = pDoc->GetTableCount();
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ // column/row state
+ SCCOLROW nOutStartCol, nOutEndCol;
+ SCCOLROW nOutStartRow, nOutEndRow;
+ pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol );
+ pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow );
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, bOldFilter );
+
+ // Datenbereich sichern - incl. Filter-Ergebnis
+ pDoc->CopyToDocument( 0,rParam.nRow1+1,nTab, MAXCOL,rParam.nRow2,nTab,
+ IDF_ALL, FALSE, pUndoDoc );
+
+ // alle Formeln wegen Referenzen
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
+ IDF_FORMULA, FALSE, pUndoDoc );
+
+ // DB- und andere Bereiche
+ ScRangeName* pDocRange = pDoc->GetRangeName();
+ if (pDocRange->GetCount())
+ pUndoRange = new ScRangeName( *pDocRange );
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+ }
+
+// pDoc->SetOutlineTable( nTab, NULL );
+ ScOutlineTable* pOut = pDoc->GetOutlineTable( nTab );
+ if (pOut)
+ pOut->GetRowArray()->RemoveAll(); // nur Zeilen-Outlines loeschen
+
+ if (rParam.bReplace)
+ pDoc->RemoveSubTotals( nTab, aNewParam );
+ BOOL bSuccess = TRUE;
+ if (bDo)
+ {
+ // Sortieren
+ if ( rParam.bDoSort || pForceNewSort )
+ {
+ pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+
+ // Teilergebnis-Felder vor die Sortierung setzen
+ // (doppelte werden weggelassen, kann darum auch wieder aufgerufen werden)
+
+ ScSortParam aOldSort;
+ pDBData->GetSortParam( aOldSort );
+ ScSortParam aSortParam( aNewParam, pForceNewSort ? *pForceNewSort : aOldSort );
+ Sort( nTab, aSortParam, FALSE, FALSE, bApi );
+ }
+
+ bSuccess = pDoc->DoSubTotals( nTab, aNewParam );
+ }
+ ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab,
+ aNewParam.nCol2, aNewParam.nRow2, nTab );
+ pDoc->SetDirty( aDirtyRange );
+
+ if (bRecord)
+ {
+// ScDBData* pUndoDBData = pDBData ? new ScDBData( *pDBData ) : NULL;
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoSubTotals( &rDocShell, nTab,
+ rParam, aNewParam.nRow2,
+ pUndoDoc, pUndoTab, // pUndoDBData,
+ pUndoRange, pUndoDB ) );
+ }
+
+ if (!bSuccess)
+ {
+ // "Kann keine Zeilen einfuegen"
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_DOSUBTOTALS_2);
+ }
+
+ // merken
+ pDBData->SetSubTotalParam( aNewParam );
+ pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+ pDoc->CompileDBFormula();
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+ aModificator.SetDocumentModified();
+
+ bRet = bSuccess;
+ }
+ return bRet;
+}
+
+//==================================================================
+
+BOOL lcl_EmptyExcept( ScDocument* pDoc, const ScRange& rRange, const ScRange& rExcept )
+{
+ ScCellIterator aIter( pDoc, rRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if ( !pCell->IsBlank() ) // real content?
+ {
+ if ( !rExcept.In( ScAddress( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ) ) )
+ return FALSE; // cell found
+ }
+ pCell = aIter.GetNext();
+ }
+
+ return TRUE; // nothing found - empty
+}
+
+BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewObj,
+ BOOL bRecord, BOOL bApi, BOOL bAllowMove )
+{
+ ScDocShellModificator aModificator( rDocShell );
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ BOOL bDone = FALSE;
+ BOOL bUndoSelf = FALSE;
+ USHORT nErrId = 0;
+
+ ScDocument* pOldUndoDoc = NULL;
+ ScDocument* pNewUndoDoc = NULL;
+ ScDPObject* pUndoDPObj = NULL;
+ if ( bRecord && pOldObj )
+ pUndoDPObj = new ScDPObject( *pOldObj ); // copy old settings for undo
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ if ( !rDocShell.IsEditable() || pDoc->GetChangeTrack() )
+ {
+ // not recorded -> disallow
+ //! different error messages?
+
+ nErrId = STR_PROTECTIONERR;
+ }
+ if ( pOldObj && !nErrId )
+ {
+ ScRange aOldOut = pOldObj->GetOutRange();
+ ScEditableTester aTester( pDoc, aOldOut );
+ if ( !aTester.IsEditable() )
+ nErrId = aTester.GetMessageId();
+ }
+ if ( pNewObj && !nErrId )
+ {
+ // at least one cell at the output position must be editable
+ // -> check in advance
+ // (start of output range in pNewObj is valid)
+
+ ScRange aNewStart( pNewObj->GetOutRange().aStart );
+ ScEditableTester aTester( pDoc, aNewStart );
+ if ( !aTester.IsEditable() )
+ nErrId = aTester.GetMessageId();
+ }
+
+ ScDPObject* pDestObj = NULL;
+ if ( !nErrId )
+ {
+ if ( pOldObj && !pNewObj )
+ {
+ // delete table
+
+ ScRange aRange = pOldObj->GetOutRange();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ if ( bRecord )
+ {
+ pOldUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pOldUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pOldUndoDoc );
+ }
+
+ pDoc->DeleteAreaTab( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(),
+ nTab, IDF_ALL );
+ pDoc->RemoveFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(),
+ nTab, SC_MF_AUTO );
+
+ pDoc->GetDPCollection()->FreeTable( pOldObj ); // object is deleted here
+
+ rDocShell.PostPaintGridAll(); //! only necessary parts
+ rDocShell.PostPaint( aRange.aStart.Col(), aRange.aStart.Row(), nTab,
+ aRange.aEnd.Col(), aRange.aEnd.Row(), nTab,
+ PAINT_GRID );
+ bDone = TRUE;
+ }
+ else if ( pNewObj )
+ {
+ if ( pOldObj )
+ {
+ if ( bRecord )
+ {
+ ScRange aRange = pOldObj->GetOutRange();
+ SCTAB nTab = aRange.aStart.Tab();
+ pOldUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pOldUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pOldUndoDoc );
+ }
+
+ if ( pNewObj == pOldObj )
+ {
+ // refresh only - no settings modified
+ }
+ else
+ {
+ pNewObj->WriteSourceDataTo( *pOldObj ); // copy source data
+
+ ScDPSaveData* pData = pNewObj->GetSaveData();
+ DBG_ASSERT( pData, "no SaveData from living DPObject" );
+ if ( pData )
+ pOldObj->SetSaveData( *pData ); // copy SaveData
+ }
+
+ pDestObj = pOldObj;
+ pDestObj->SetAllowMove( bAllowMove );
+ }
+ else
+ {
+ // output range must be set at pNewObj
+
+ pDestObj = new ScDPObject( *pNewObj );
+
+ // #i94570# When changing the output position in the dialog, a new table is created
+ // with the settings from the old table, including the name.
+ // So we have to check for duplicate names here (before inserting).
+ if ( pDoc->GetDPCollection()->GetByName(pDestObj->GetName()) )
+ pDestObj->SetName( String() ); // ignore the invalid name, create a new name below
+
+ pDestObj->SetAlive(TRUE);
+ if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
+ {
+ DBG_ERROR("cannot insert DPObject");
+ DELETEZ( pDestObj );
+ }
+ }
+ if ( pDestObj )
+ {
+ // #78541# create new database connection for "refresh"
+ // (and re-read column entry collections)
+ // so all changes take effect
+ if ( pNewObj == pOldObj && pDestObj->IsImportData() )
+ pDestObj->InvalidateSource();
+
+ pDestObj->InvalidateData(); // before getting the new output area
+
+ // make sure the table has a name (not set by dialog)
+ if ( !pDestObj->GetName().Len() )
+ pDestObj->SetName( pDoc->GetDPCollection()->CreateNewName() );
+
+ BOOL bOverflow = FALSE;
+ ScRange aNewOut = pDestObj->GetNewOutputRange( bOverflow );
+
+ //! test for overlap with other data pilot tables
+ if( pOldObj )
+ {
+ const ScSheetSourceDesc* pSheetDesc = pOldObj->GetSheetDesc();
+ if( pSheetDesc && pSheetDesc->aSourceRange.Intersects( aNewOut ) )
+ {
+ ScRange aOldRange = pOldObj->GetOutRange();
+ SCsROW nDiff = aOldRange.aStart.Row()-aNewOut.aStart.Row();
+ aNewOut.aStart.SetRow( aOldRange.aStart.Row() );
+ aNewOut.aEnd.SetRow( aNewOut.aEnd.Row()+nDiff );
+ if( !ValidRow( aNewOut.aStart.Row() ) || !ValidRow( aNewOut.aEnd.Row() ) )
+ bOverflow = TRUE;
+ }
+ }
+
+ if ( bOverflow )
+ {
+ // like with STR_PROTECTIONERR, use undo to reverse everything
+ DBG_ASSERT( bRecord, "DataPilotUpdate: can't undo" );
+ bUndoSelf = TRUE;
+ nErrId = STR_PIVOT_ERROR;
+ }
+ else
+ {
+ ScEditableTester aTester( pDoc, aNewOut );
+ if ( !aTester.IsEditable() )
+ {
+ // destination area isn't editable
+ //! reverse everything done so far, don't proceed
+
+ // quick solution: proceed to end, use undo action
+ // to reverse everything:
+ DBG_ASSERT( bRecord, "DataPilotUpdate: can't undo" );
+ bUndoSelf = TRUE;
+ nErrId = aTester.GetMessageId();
+ }
+ }
+
+ // test if new output area is empty except for old area
+ if ( !bApi )
+ {
+ BOOL bEmpty;
+ if ( pOldObj ) // OutRange of pOldObj (pDestObj) is still old area
+ bEmpty = lcl_EmptyExcept( pDoc, aNewOut, pOldObj->GetOutRange() );
+ else
+ bEmpty = pDoc->IsBlockEmpty( aNewOut.aStart.Tab(),
+ aNewOut.aStart.Col(), aNewOut.aStart.Row(),
+ aNewOut.aEnd.Col(), aNewOut.aEnd.Row() );
+
+ if ( !bEmpty )
+ {
+ QueryBox aBox( rDocShell.GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_PIVOT_NOTEMPTY) );
+ if (aBox.Execute() == RET_NO)
+ {
+ //! like above (not editable), use undo to reverse everything
+ DBG_ASSERT( bRecord, "DataPilotUpdate: can't undo" );
+ bUndoSelf = TRUE;
+ }
+ }
+ }
+
+ if ( bRecord )
+ {
+ SCTAB nTab = aNewOut.aStart.Tab();
+ pNewUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pNewUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( aNewOut, IDF_ALL, FALSE, pNewUndoDoc );
+ }
+
+ pDestObj->Output( aNewOut.aStart );
+
+ rDocShell.PostPaintGridAll(); //! only necessary parts
+ bDone = TRUE;
+ }
+ }
+ // else nothing (no old, no new)
+ }
+
+ if ( bRecord && bDone )
+ {
+ SfxUndoAction* pAction = new ScUndoDataPilot( &rDocShell,
+ pOldUndoDoc, pNewUndoDoc, pUndoDPObj, pDestObj, bAllowMove );
+ pOldUndoDoc = NULL;
+ pNewUndoDoc = NULL; // pointers are used in undo action
+ // pUndoDPObj is copied
+
+ if (bUndoSelf)
+ {
+ // use undo action to restore original state
+ //! prevent setting the document modified? (ScDocShellModificator)
+
+ pAction->Undo();
+ delete pAction;
+ bDone = FALSE;
+ }
+ else
+ rDocShell.GetUndoManager()->AddUndoAction( pAction );
+ }
+
+ delete pOldUndoDoc; // if not used for undo
+ delete pNewUndoDoc;
+ delete pUndoDPObj;
+
+ if (bDone)
+ {
+ // notify API objects
+ if (pDestObj)
+ pDoc->BroadcastUno( ScDataPilotModifiedHint( pDestObj->GetName() ) );
+ aModificator.SetDocumentModified();
+ }
+
+ if ( nErrId && !bApi )
+ rDocShell.ErrorMessage( nErrId );
+
+ return bDone;
+}
+
+//==================================================================
+//
+// Datenbank-Import...
+
+void ScDBDocFunc::UpdateImport( const String& rTarget, const String& rDBName,
+ const String& rTableName, const String& rStatement, BOOL bNative,
+ BYTE nType, const ::com::sun::star::uno::Reference<
+ ::com::sun::star::sdbc::XResultSet >& xResultSet,
+ const SbaSelectionList* pSelection )
+{
+ // Target ist jetzt einfach der Bereichsname
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScDBCollection& rDBColl = *pDoc->GetDBCollection();
+ ScDBData* pData = NULL;
+ ScImportParam aImportParam;
+ BOOL bFound = FALSE;
+ USHORT nCount = rDBColl.GetCount();
+ for (USHORT i=0; i<nCount && !bFound; i++)
+ {
+ pData = rDBColl[i];
+ if (pData->GetName() == rTarget)
+ bFound = TRUE;
+ }
+ if (!bFound)
+ {
+ InfoBox aInfoBox(rDocShell.GetActiveDialogParent(),
+ ScGlobal::GetRscString( STR_TARGETNOTFOUND ) );
+ aInfoBox.Execute();
+ return;
+ }
+
+ SCTAB nTab;
+ SCCOL nDummyCol;
+ SCROW nDummyRow;
+ pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
+ pData->GetImportParam( aImportParam );
+
+ BOOL bSql = ( rStatement.Len() != 0 );
+
+ aImportParam.aDBName = rDBName;
+ aImportParam.bSql = bSql;
+ aImportParam.aStatement = bSql ? rStatement : rTableName;
+ aImportParam.bNative = bNative;
+ aImportParam.nType = nType;
+ aImportParam.bImport = TRUE;
+ BOOL bContinue = DoImport( nTab, aImportParam, xResultSet, pSelection, TRUE );
+
+ // DB-Operationen wiederholen
+
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
+ if (pViewSh)
+ {
+ ScRange aRange;
+ pData->GetArea(aRange);
+ pViewSh->MarkRange(aRange); // selektieren
+
+ if ( bContinue ) // #41905# Fehler beim Import -> Abbruch
+ {
+ // interne Operationen, wenn welche gespeichert
+
+ if ( pData->HasQueryParam() || pData->HasSortParam() || pData->HasSubTotalParam() )
+ pViewSh->RepeatDB();
+
+ // Pivottabellen die den Bereich als Quelldaten haben
+
+ rDocShell.RefreshPivotTables(aRange);
+ }
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/dbdocimp.cxx b/sc/source/ui/docshell/dbdocimp.cxx
new file mode 100644
index 000000000000..b992d595d0ea
--- /dev/null
+++ b/sc/source/ui/docshell/dbdocimp.cxx
@@ -0,0 +1,725 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/types.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/XCompletedExecution.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+
+
+#include "dbdocfun.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+#include "scerrors.hxx"
+#include "dbcolect.hxx"
+#include "markdata.hxx"
+#include "undodat.hxx"
+#include "progress.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "attrib.hxx"
+#include "dbdocutl.hxx"
+#include "editable.hxx"
+#include "hints.hxx"
+#include "chgtrack.hxx"
+
+using namespace com::sun::star;
+
+#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
+#define SC_SERVICE_INTHANDLER "com.sun.star.task.InteractionHandler"
+
+//! move to a header file?
+#define SC_DBPROP_DATASOURCENAME "DataSourceName"
+#define SC_DBPROP_COMMAND "Command"
+#define SC_DBPROP_COMMANDTYPE "CommandType"
+#define SC_DBPROP_SELECTION "Selection"
+#define SC_DBPROP_CURSOR "Cursor"
+
+// static
+void ScDBDocFunc::ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFrame )
+{
+ // called after opening the database beamer
+
+ if ( !pFrame || !rParam.bImport )
+ return;
+
+ uno::Reference<frame::XFrame> xFrame = pFrame->GetFrame().GetFrameInterface();
+ uno::Reference<frame::XDispatchProvider> xDP(xFrame, uno::UNO_QUERY);
+
+ uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
+ rtl::OUString::createFromAscii("_beamer"),
+ frame::FrameSearchFlag::CHILDREN);
+ if (xBeamerFrame.is())
+ {
+ uno::Reference<frame::XController> xController = xBeamerFrame->getController();
+ uno::Reference<view::XSelectionSupplier> xControllerSelection(xController, uno::UNO_QUERY);
+ if (xControllerSelection.is())
+ {
+ sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND :
+ ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY :
+ sdb::CommandType::TABLE );
+
+ ::svx::ODataAccessDescriptor aSelection;
+ aSelection.setDataSource(rtl::OUString( rParam.aDBName ));
+ aSelection[svx::daCommand] <<= rtl::OUString( rParam.aStatement );
+ aSelection[svx::daCommandType] <<= nType;
+
+ xControllerSelection->select(uno::makeAny(aSelection.createPropertyValueSequence()));
+ }
+ else
+ {
+ DBG_ERROR("no selection supplier in the beamer!");
+ }
+ }
+}
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::DoImportUno( const ScAddress& rPos,
+ const uno::Sequence<beans::PropertyValue>& aArgs )
+{
+ BOOL bDone = FALSE;
+
+ ScImportParam aImParam;
+ aImParam.nCol1 = aImParam.nCol2 = rPos.Col();
+ aImParam.nRow1 = aImParam.nRow2 = rPos.Row();
+ aImParam.bImport = TRUE;
+
+ uno::Reference<sdbc::XResultSet> xResSet;
+ uno::Sequence<uno::Any> aSelection;
+
+ rtl::OUString aStrVal;
+ const beans::PropertyValue* pPropArray = aArgs.getConstArray();
+ long nPropCount = aArgs.getLength();
+ long i;
+ for (i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName = rProp.Name;
+
+ if ( aPropName.EqualsAscii( SC_DBPROP_DATASOURCENAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aImParam.aDBName = aStrVal;
+ }
+ else if ( aPropName.EqualsAscii( SC_DBPROP_COMMAND ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aImParam.aStatement = aStrVal;
+ }
+ else if ( aPropName.EqualsAscii( SC_DBPROP_COMMANDTYPE ))
+ {
+ sal_Int32 nType = 0;
+ if ( rProp.Value >>= nType )
+ {
+ aImParam.bSql = ( nType == sdb::CommandType::COMMAND );
+ aImParam.nType = sal::static_int_cast<BYTE>( ( nType == sdb::CommandType::QUERY ) ? ScDbQuery : ScDbTable );
+ // nType is ignored if bSql is set
+ }
+ }
+ else if ( aPropName.EqualsAscii( SC_DBPROP_SELECTION ))
+ {
+ rProp.Value >>= aSelection;
+ }
+ else if ( aPropName.EqualsAscii( SC_DBPROP_CURSOR ))
+ {
+ rProp.Value >>= xResSet;
+ }
+ }
+
+ SbaSelectionList aList;
+ long nSelLen = aSelection.getLength();
+ for (i = 0; i < nSelLen; i++)
+ {
+ sal_Int32 nEntry = 0;
+ if ( aSelection[i] >>= nEntry )
+ aList.Insert( (void*)nEntry, LIST_APPEND );
+ }
+
+ BOOL bAddrInsert = FALSE; //!???
+ if ( bAddrInsert )
+ {
+ bDone = DoImport( rPos.Tab(), aImParam, xResSet, &aList, TRUE, bAddrInsert );
+ }
+ else
+ {
+ // create database range
+ //! merge this with SID_SBA_IMPORT execute in docsh4.cxx
+
+ ScDBData* pDBData = rDocShell.GetDBData( ScRange(rPos), SC_DB_IMPORT, SC_DBSEL_KEEP );
+ DBG_ASSERT(pDBData, "can't create DB data");
+ String sTarget = pDBData->GetName();
+
+ //! change UpdateImport to use only one of rTableName, rStatement
+
+ String aTableName, aStatement;
+ if ( aImParam.bSql )
+ aStatement = aImParam.aStatement;
+ else
+ aTableName = aImParam.aStatement;
+
+ UpdateImport( sTarget, aImParam.aDBName, aTableName, aStatement,
+ aImParam.bNative, aImParam.nType, xResSet, &aList );
+ bDone = TRUE;
+ }
+
+ return bDone;
+}
+
+// -----------------------------------------------------------------
+
+BOOL ScDBDocFunc::DoImport( SCTAB nTab, const ScImportParam& rParam,
+ const uno::Reference< sdbc::XResultSet >& xResultSet,
+ const SbaSelectionList* pSelection, BOOL bRecord, BOOL bAddrInsert )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScChangeTrack *pChangeTrack = NULL;
+ ScRange aChangedRange;
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDBData* pDBData = 0;
+ if ( !bAddrInsert )
+ {
+ pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1,
+ rParam.nCol2, rParam.nRow2 );
+ if (!pDBData)
+ {
+ DBG_ERROR( "DoImport: no DBData" );
+ return FALSE;
+ }
+ }
+
+ Window* pWaitWin = rDocShell.GetActiveDialogParent();
+ if (pWaitWin)
+ pWaitWin->EnterWait();
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ BOOL bApi = FALSE; //! pass as argument
+ BOOL bTruncated = FALSE; // for warning
+ USHORT nErrStringId = 0;
+ String aErrorMessage;
+
+ SCCOL nCol = rParam.nCol1;
+ SCROW nRow = rParam.nRow1;
+ SCCOL nEndCol = nCol; // end of resulting database area
+ SCROW nEndRow = nRow;
+ long i;
+
+ BOOL bDoSelection = FALSE;
+ BOOL bRealSelection = FALSE; // TRUE if not everything is selected
+ ULONG nListPos = 0;
+ ULONG nRowsRead = 0;
+ ULONG nListCount = 0;
+
+ // -1 is special
+ if ( pSelection && pSelection->Count() && (long)pSelection->GetObject(0) != -1L )
+ {
+ bDoSelection = TRUE;
+ nListCount = pSelection->Count();
+ }
+
+ // ImportDoc - also used for Redo
+ ScDocument* pImportDoc = new ScDocument( SCDOCMODE_UNDO );
+ pImportDoc->InitUndo( pDoc, nTab, nTab );
+ ScColumn::DoubleAllocSwitch aAllocSwitch(true);
+
+ //
+ // get data from database into import document
+ //
+
+ try
+ {
+ // progress bar
+ // only text (title is still needed, for the cancel button)
+ ScProgress aProgress( &rDocShell, ScGlobal::GetRscString(STR_UNDO_IMPORTDATA), 0 );
+ USHORT nInserted = 0;
+
+ uno::Reference<sdbc::XRowSet> xRowSet = uno::Reference<sdbc::XRowSet>(
+ xResultSet, uno::UNO_QUERY );
+ sal_Bool bDispose = sal_False;
+ if ( !xRowSet.is() )
+ {
+ bDispose = sal_True;
+ xRowSet = uno::Reference<sdbc::XRowSet>(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ),
+ uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xRowProp.is(), "can't get RowSet" );
+ if ( xRowProp.is() )
+ {
+ //
+ // set source parameters
+ //
+
+ sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND :
+ ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY :
+ sdb::CommandType::TABLE );
+ uno::Any aAny;
+
+ aAny <<= rtl::OUString( rParam.aDBName );
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_DATASOURCENAME), aAny );
+
+ aAny <<= rtl::OUString( rParam.aStatement );
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMAND), aAny );
+
+ aAny <<= nType;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMANDTYPE), aAny );
+
+ uno::Reference<sdb::XCompletedExecution> xExecute( xRowSet, uno::UNO_QUERY );
+ if ( xExecute.is() )
+ {
+ uno::Reference<task::XInteractionHandler> xHandler(
+ comphelper::getProcessServiceFactory()->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_INTHANDLER ) ),
+ uno::UNO_QUERY);
+ xExecute->executeWithCompletion( xHandler );
+ }
+ else
+ xRowSet->execute();
+ }
+ }
+ if ( xRowSet.is() )
+ {
+ //
+ // get column descriptions
+ //
+
+ long nColCount = 0;
+ uno::Reference<sdbc::XResultSetMetaData> xMeta;
+ uno::Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp( xRowSet, uno::UNO_QUERY );
+ if ( xMetaSupp.is() )
+ xMeta = xMetaSupp->getMetaData();
+ if ( xMeta.is() )
+ nColCount = xMeta->getColumnCount(); // this is the number of real columns
+
+ if ( rParam.nCol1 + nColCount - 1 > MAXCOL )
+ {
+ nColCount = 0;
+ //! error message
+ }
+
+ uno::Reference<sdbc::XRow> xRow( xRowSet, uno::UNO_QUERY );
+ if ( nColCount > 0 && xRow.is() )
+ {
+ nEndCol = (SCCOL)( rParam.nCol1 + nColCount - 1 );
+
+ uno::Sequence<sal_Int32> aColTypes( nColCount ); // column types
+ uno::Sequence<sal_Bool> aColCurr( nColCount ); // currency flag is not in types
+ sal_Int32* pTypeArr = aColTypes.getArray();
+ sal_Bool* pCurrArr = aColCurr.getArray();
+ for (i=0; i<nColCount; i++)
+ {
+ pTypeArr[i] = xMeta->getColumnType( i+1 );
+ pCurrArr[i] = xMeta->isCurrency( i+1 );
+ }
+
+ if ( !bAddrInsert ) // read column names
+ {
+ nCol = rParam.nCol1;
+ for (i=0; i<nColCount; i++)
+ {
+ pImportDoc->SetString( nCol, nRow, nTab,
+ xMeta->getColumnLabel( i+1 ) );
+ ++nCol;
+ }
+ ++nRow;
+ }
+
+ BOOL bEnd = FALSE;
+ if ( !bDoSelection )
+ xRowSet->beforeFirst();
+ while ( !bEnd )
+ {
+ // skip rows that are not selected
+ if ( !bDoSelection )
+ {
+ if ( (bEnd = !xRowSet->next()) == FALSE )
+ ++nRowsRead;
+ }
+ else
+ {
+ if (nListPos < nListCount)
+ {
+ ULONG nNextRow = (ULONG) pSelection->GetObject(nListPos);
+ if ( nRowsRead+1 < nNextRow )
+ bRealSelection = TRUE;
+ bEnd = !xRowSet->absolute(nRowsRead = nNextRow);
+ ++nListPos;
+ }
+ else
+ {
+ bRealSelection = xRowSet->next();
+ bEnd = TRUE; // more data available but not used
+ }
+ }
+
+ if ( !bEnd )
+ {
+ if ( ValidRow(nRow) )
+ {
+ nCol = rParam.nCol1;
+ for (i=0; i<nColCount; i++)
+ {
+ ScDatabaseDocUtil::PutData( pImportDoc, nCol, nRow, nTab,
+ xRow, i+1, pTypeArr[i], pCurrArr[i] );
+ ++nCol;
+ }
+ nEndRow = nRow;
+ ++nRow;
+
+ // progress bar
+
+ ++nInserted;
+ if (!(nInserted & 15))
+ {
+ String aPict = ScGlobal::GetRscString( STR_PROGRESS_IMPORT );
+ String aText = aPict.GetToken(0,'#');
+ aText += String::CreateFromInt32( nInserted );
+ aText += aPict.GetToken(1,'#');
+
+ if (!aProgress.SetStateText( 0, aText )) // stopped by user?
+ {
+ bEnd = TRUE;
+ bSuccess = FALSE;
+ nErrStringId = STR_DATABASE_ABORTED;
+ }
+ }
+ }
+ else // past the end of the spreadsheet
+ {
+ bEnd = TRUE; // don't continue
+ bTruncated = TRUE; // warning flag
+ }
+ }
+ }
+
+ bSuccess = TRUE;
+ }
+
+ if ( bDispose )
+ ::comphelper::disposeComponent( xRowSet );
+ }
+ }
+ catch ( sdbc::SQLException& rError )
+ {
+ aErrorMessage = rError.Message;
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR("Unexpected exception in database");
+ }
+
+ pImportDoc->DoColResize( nTab, rParam.nCol1,nEndCol, 0 );
+
+ //
+ // test for cell protection
+ //
+
+ BOOL bKeepFormat = !bAddrInsert && pDBData->IsKeepFmt();
+ BOOL bMoveCells = !bAddrInsert && pDBData->IsDoSize();
+ SCCOL nFormulaCols = 0; // columns to be filled with formulas
+ if (bMoveCells && nEndCol == rParam.nCol2)
+ {
+ // if column count changes, formulas would become invalid anyway
+ // -> only set nFormulaCols for unchanged column count
+
+ SCCOL nTestCol = rParam.nCol2 + 1; // right of the data
+ SCROW nTestRow = rParam.nRow1 + 1; // below the title row
+ while ( nTestCol <= MAXCOL &&
+ pDoc->GetCellType(ScAddress( nTestCol, nTestRow, nTab )) == CELLTYPE_FORMULA )
+ ++nTestCol, ++nFormulaCols;
+ }
+
+ if (bSuccess)
+ {
+ // old and new range editable?
+ ScEditableTester aTester;
+ aTester.TestBlock( pDoc, nTab, rParam.nCol1,rParam.nRow1,rParam.nCol2,rParam.nRow2 );
+ aTester.TestBlock( pDoc, nTab, rParam.nCol1,rParam.nRow1,nEndCol,nEndRow );
+ if ( !aTester.IsEditable() )
+ {
+ nErrStringId = aTester.GetMessageId();
+ bSuccess = FALSE;
+ }
+ else if ( (pChangeTrack = pDoc->GetChangeTrack()) != NULL )
+ aChangedRange = ScRange(rParam.nCol1, rParam.nRow1, nTab,
+ nEndCol+nFormulaCols, nEndRow, nTab );
+ }
+
+ if ( bSuccess && bMoveCells )
+ {
+ ScRange aOld( rParam.nCol1, rParam.nRow1, nTab,
+ rParam.nCol2+nFormulaCols, rParam.nRow2, nTab );
+ ScRange aNew( rParam.nCol1, rParam.nRow1, nTab,
+ nEndCol+nFormulaCols, nEndRow, nTab );
+ if (!pDoc->CanFitBlock( aOld, aNew ))
+ {
+ nErrStringId = STR_MSSG_DOSUBTOTALS_2; // can't insert cells
+ bSuccess = FALSE;
+ }
+ }
+
+ //
+ // copy data from import doc into real document
+ //
+
+ if ( bSuccess )
+ {
+ if (bKeepFormat)
+ {
+ // keep formatting of title and first data row from the document
+ // CopyToDocument also copies styles, Apply... needs separate calls
+
+ SCCOL nMinEndCol = Min( rParam.nCol2, nEndCol ); // not too much
+ nMinEndCol = sal::static_int_cast<SCCOL>( nMinEndCol + nFormulaCols ); // only if column count unchanged
+ pImportDoc->DeleteAreaTab( 0,0, MAXCOL,MAXROW, nTab, IDF_ATTRIB );
+ pDoc->CopyToDocument( rParam.nCol1, rParam.nRow1, nTab,
+ nMinEndCol, rParam.nRow1, nTab,
+ IDF_ATTRIB, FALSE, pImportDoc );
+
+ SCROW nDataStartRow = rParam.nRow1+1;
+ for (SCCOL nCopyCol=rParam.nCol1; nCopyCol<=nMinEndCol; nCopyCol++)
+ {
+ const ScPatternAttr* pSrcPattern = pDoc->GetPattern(
+ nCopyCol, nDataStartRow, nTab );
+ pImportDoc->ApplyPatternAreaTab( nCopyCol, nDataStartRow, nCopyCol, nEndRow,
+ nTab, *pSrcPattern );
+ const ScStyleSheet* pStyle = pSrcPattern->GetStyleSheet();
+ if (pStyle)
+ pImportDoc->ApplyStyleAreaTab( nCopyCol, nDataStartRow, nCopyCol, nEndRow,
+ nTab, *pStyle );
+ }
+ }
+
+ // don't set cell protection attribute if table is protected
+ if (pDoc->IsTabProtected(nTab))
+ {
+ ScPatternAttr aPattern(pImportDoc->GetPool());
+ aPattern.GetItemSet().Put( ScProtectionAttr( FALSE,FALSE,FALSE,FALSE ) );
+ pImportDoc->ApplyPatternAreaTab( 0,0,MAXCOL,MAXROW, nTab, aPattern );
+ }
+
+ //
+ // copy old data for undo
+ //
+
+ SCCOL nUndoEndCol = Max( nEndCol, rParam.nCol2 ); // rParam = old end
+ SCROW nUndoEndRow = Max( nEndRow, rParam.nRow2 );
+
+ ScDocument* pUndoDoc = NULL;
+ ScDBData* pUndoDBData = NULL;
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if ( !bAddrInsert )
+ pUndoDBData = new ScDBData( *pDBData );
+ }
+
+ ScMarkData aNewMark;
+ aNewMark.SelectOneTable( nTab );
+
+ if (bRecord)
+ {
+ // do not touch notes (ScUndoImportData does not support drawing undo)
+ sal_uInt16 nCopyFlags = IDF_ALL & ~IDF_NOTE;
+
+ // nFormulaCols is set only if column count is unchanged
+ pDoc->CopyToDocument( rParam.nCol1, rParam.nRow1, nTab,
+ nEndCol+nFormulaCols, nEndRow, nTab,
+ nCopyFlags, FALSE, pUndoDoc );
+ if ( rParam.nCol2 > nEndCol )
+ pDoc->CopyToDocument( nEndCol+1, rParam.nRow1, nTab,
+ nUndoEndCol, nUndoEndRow, nTab,
+ nCopyFlags, FALSE, pUndoDoc );
+ if ( rParam.nRow2 > nEndRow )
+ pDoc->CopyToDocument( rParam.nCol1, nEndRow+1, nTab,
+ nUndoEndCol+nFormulaCols, nUndoEndRow, nTab,
+ nCopyFlags, FALSE, pUndoDoc );
+ }
+
+ //
+ // move new data
+ //
+
+ if (bMoveCells)
+ {
+ // clear only the range without the formulas,
+ // so the formula title and first row are preserved
+
+ ScRange aDelRange( rParam.nCol1, rParam.nRow1, nTab,
+ rParam.nCol2, rParam.nRow2, nTab );
+ pDoc->DeleteAreaTab( aDelRange, IDF_ALL & ~IDF_NOTE ); // ohne die Formeln
+
+ ScRange aOld( rParam.nCol1, rParam.nRow1, nTab,
+ rParam.nCol2+nFormulaCols, rParam.nRow2, nTab );
+ ScRange aNew( rParam.nCol1, rParam.nRow1, nTab,
+ nEndCol+nFormulaCols, nEndRow, nTab );
+ pDoc->FitBlock( aOld, aNew, FALSE ); // Formeln nicht loeschen
+ }
+ else if ( nEndCol < rParam.nCol2 ) // DeleteArea calls PutInOrder
+ pDoc->DeleteArea( nEndCol+1, rParam.nRow1, rParam.nCol2, rParam.nRow2,
+ aNewMark, IDF_CONTENTS & ~IDF_NOTE );
+
+ // CopyToDocument doesn't remove contents
+ pDoc->DeleteAreaTab( rParam.nCol1, rParam.nRow1, nEndCol, nEndRow, nTab, IDF_CONTENTS & ~IDF_NOTE );
+
+ // #41216# remove each column from ImportDoc after copying to reduce memory usage
+ BOOL bOldAutoCalc = pDoc->GetAutoCalc();
+ pDoc->SetAutoCalc( FALSE ); // outside of the loop
+ for (SCCOL nCopyCol = rParam.nCol1; nCopyCol <= nEndCol; nCopyCol++)
+ {
+ pImportDoc->CopyToDocument( nCopyCol, rParam.nRow1, nTab, nCopyCol, nEndRow, nTab,
+ IDF_ALL, FALSE, pDoc );
+ pImportDoc->DeleteAreaTab( nCopyCol, rParam.nRow1, nCopyCol, nEndRow, nTab, IDF_CONTENTS );
+ pImportDoc->DoColResize( nTab, nCopyCol, nCopyCol, 0 );
+ }
+ pDoc->SetAutoCalc( bOldAutoCalc );
+
+ if (nFormulaCols > 0) // copy formulas
+ {
+ if (bKeepFormat) // formats for formulas
+ pImportDoc->CopyToDocument( nEndCol+1, rParam.nRow1, nTab,
+ nEndCol+nFormulaCols, nEndRow, nTab,
+ IDF_ATTRIB, FALSE, pDoc );
+ // fill formulas
+ ScMarkData aMark;
+ aMark.SelectOneTable(nTab);
+ pDoc->Fill( nEndCol+1, rParam.nRow1+1, nEndCol+nFormulaCols, rParam.nRow1+1,
+ aMark, nEndRow-rParam.nRow1-1, FILL_TO_BOTTOM, FILL_SIMPLE );
+ }
+
+ // if new range is smaller, clear old contents
+
+ if (!bMoveCells) // move has happened above
+ {
+ if ( rParam.nCol2 > nEndCol )
+ pDoc->DeleteArea( nEndCol+1, rParam.nRow1, rParam.nCol2, rParam.nRow2,
+ aNewMark, IDF_CONTENTS );
+ if ( rParam.nRow2 > nEndRow )
+ pDoc->DeleteArea( rParam.nCol1, nEndRow+1, rParam.nCol2, rParam.nRow2,
+ aNewMark, IDF_CONTENTS );
+ }
+
+ if( !bAddrInsert ) // update database range
+ {
+ pDBData->SetImportParam( rParam );
+ pDBData->SetHeader( TRUE );
+ pDBData->SetByRow( TRUE );
+ pDBData->SetArea( nTab, rParam.nCol1,rParam.nRow1, nEndCol,nEndRow );
+ pDBData->SetImportSelection( bRealSelection );
+ pDoc->CompileDBFormula();
+ }
+
+ if (bRecord)
+ {
+ ScDocument* pRedoDoc = pImportDoc;
+ pImportDoc = NULL;
+
+ if (nFormulaCols > 0) // include filled formulas for redo
+ pDoc->CopyToDocument( rParam.nCol1, rParam.nRow1, nTab,
+ nEndCol+nFormulaCols, nEndRow, nTab,
+ IDF_ALL & ~IDF_NOTE, FALSE, pRedoDoc );
+
+ ScDBData* pRedoDBData = pDBData ? new ScDBData( *pDBData ) : NULL;
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoImportData( &rDocShell, nTab,
+ rParam, nUndoEndCol, nUndoEndRow,
+ nFormulaCols,
+ pUndoDoc, pRedoDoc, pUndoDBData, pRedoDBData ) );
+ }
+
+ pDoc->SetDirty();
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+ aModificator.SetDocumentModified();
+
+ ScDBRangeRefreshedHint aHint( rParam );
+ pDoc->BroadcastUno( aHint );
+
+ if (pWaitWin)
+ pWaitWin->LeaveWait();
+
+ if ( bTruncated && !bApi ) // show warning
+ ErrorHandler::HandleError(SCWARN_IMPORT_RANGE_OVERFLOW);
+ }
+ else if ( !bApi )
+ {
+ if (pWaitWin)
+ pWaitWin->LeaveWait();
+
+ if (!aErrorMessage.Len())
+ {
+ if (!nErrStringId)
+ nErrStringId = STR_MSSG_IMPORTDATA_0;
+ aErrorMessage = ScGlobal::GetRscString( nErrStringId );
+ }
+ InfoBox aInfoBox( rDocShell.GetActiveDialogParent(), aErrorMessage );
+ aInfoBox.Execute();
+ }
+
+ delete pImportDoc;
+
+ if (bSuccess && pChangeTrack)
+ pChangeTrack->AppendInsert ( aChangedRange );
+
+ return bSuccess;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
new file mode 100644
index 000000000000..abe1c586d3bb
--- /dev/null
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -0,0 +1,4946 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <editeng/editobj.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/printer.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/waitobj.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/PasswordHelper.hxx>
+
+#include <basic/sbstar.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+
+#include <list>
+
+#include "docfunc.hxx"
+
+#include "sc.hrc"
+
+#include "arealink.hxx"
+#include "attrib.hxx"
+#include "dociter.hxx"
+#include "autoform.hxx"
+#include "cell.hxx"
+#include "cellmergeoption.hxx"
+#include "detdata.hxx"
+#include "detfunc.hxx"
+#include "docpool.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "editutil.hxx"
+#include "globstr.hrc"
+#include "olinetab.hxx"
+#include "patattr.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "refundo.hxx"
+#include "scresid.hxx"
+#include "stlpool.hxx"
+#include "stlsheet.hxx"
+#include "tablink.hxx"
+#include "tabvwsh.hxx"
+#include "uiitems.hxx"
+#include "undoblk.hxx"
+#include "undocell.hxx"
+#include "undodraw.hxx"
+#include "undotab.hxx"
+#include "waitoff.hxx"
+#include "sizedev.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "editable.hxx"
+#include "compiler.hxx"
+#include "scui_def.hxx"
+#include "tabprotection.hxx"
+#include "clipparam.hxx"
+#include "externalrefmgr.hxx"
+
+#include <memory>
+#include <basic/basmgr.hxx>
+#include <boost/scoped_ptr.hpp>
+#include <set>
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Sequence;
+using ::std::vector;
+
+
+// STATIC DATA -----------------------------------------------------------
+
+//========================================================================
+
+IMPL_LINK( ScDocFunc, NotifyDrawUndo, SdrUndoAction*, pUndoAction )
+{
+ // #i101118# if drawing layer collects the undo actions, add it there
+ ScDrawLayer* pDrawLayer = rDocShell.GetDocument()->GetDrawLayer();
+ if( pDrawLayer && pDrawLayer->IsRecording() )
+ pDrawLayer->AddCalcUndo( pUndoAction );
+ else
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDraw( pUndoAction, &rDocShell ) );
+ rDocShell.SetDrawModified();
+
+ // the affected sheet isn't known, so all stream positions are invalidated
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+// Zeile ueber dem Range painten (fuer Linien nach AdjustRowHeight)
+
+void lcl_PaintAbove( ScDocShell& rDocShell, const ScRange& rRange )
+{
+ SCROW nRow = rRange.aStart.Row();
+ if ( nRow > 0 )
+ {
+ SCTAB nTab = rRange.aStart.Tab(); //! alle?
+ --nRow;
+ rDocShell.PostPaint( ScRange(0,nRow,nTab, MAXCOL,nRow,nTab), PAINT_GRID );
+ }
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::AdjustRowHeight( const ScRange& rRange, BOOL bPaint )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if ( pDoc->IsImportingXML() )
+ {
+ // for XML import, all row heights are updated together after importing
+ return FALSE;
+ }
+ if ( !pDoc->IsAdjustHeightEnabled() )
+ {
+ return FALSE;
+ }
+
+ SCTAB nTab = rRange.aStart.Tab();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCROW nEndRow = rRange.aEnd.Row();
+
+ ScSizeDeviceProvider aProv( &rDocShell );
+ Fraction aOne(1,1);
+
+ BOOL bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
+ aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, FALSE );
+
+ if ( bPaint && bChanged )
+ rDocShell.PostPaint( 0, nStartRow, nTab, MAXCOL, MAXROW, nTab,
+ PAINT_GRID | PAINT_LEFT );
+
+ return bChanged;
+}
+
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::DetectiveAddPred(const ScAddress& rPos)
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ rDocShell.MakeDrawLayer();
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ SCCOL nCol = rPos.Col();
+ SCROW nRow = rPos.Row();
+ SCTAB nTab = rPos.Tab();
+
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).ShowPred( nCol, nRow );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (bDone)
+ {
+ ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_ADDPRED );
+ pDoc->AddDetectiveOperation( aOperation );
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ }
+ aModificator.SetDocumentModified();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_REFRESH );
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveDelPred(const ScAddress& rPos)
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (!pModel)
+ return FALSE;
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ SCCOL nCol = rPos.Col();
+ SCROW nRow = rPos.Row();
+ SCTAB nTab = rPos.Tab();
+
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).DeletePred( nCol, nRow );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (bDone)
+ {
+ ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_DELPRED );
+ pDoc->AddDetectiveOperation( aOperation );
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ }
+ aModificator.SetDocumentModified();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_REFRESH );
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveAddSucc(const ScAddress& rPos)
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ rDocShell.MakeDrawLayer();
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ SCCOL nCol = rPos.Col();
+ SCROW nRow = rPos.Row();
+ SCTAB nTab = rPos.Tab();
+
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).ShowSucc( nCol, nRow );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (bDone)
+ {
+ ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_ADDSUCC );
+ pDoc->AddDetectiveOperation( aOperation );
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ }
+ aModificator.SetDocumentModified();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_REFRESH );
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveDelSucc(const ScAddress& rPos)
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (!pModel)
+ return FALSE;
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ SCCOL nCol = rPos.Col();
+ SCROW nRow = rPos.Row();
+ SCTAB nTab = rPos.Tab();
+
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).DeleteSucc( nCol, nRow );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (bDone)
+ {
+ ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_DELSUCC );
+ pDoc->AddDetectiveOperation( aOperation );
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ }
+ aModificator.SetDocumentModified();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_REFRESH );
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveAddError(const ScAddress& rPos)
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ rDocShell.MakeDrawLayer();
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ SCCOL nCol = rPos.Col();
+ SCROW nRow = rPos.Row();
+ SCTAB nTab = rPos.Tab();
+
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).ShowError( nCol, nRow );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (bDone)
+ {
+ ScDetOpData aOperation( ScAddress(nCol,nRow,nTab), SCDETOP_ADDERROR );
+ pDoc->AddDetectiveOperation( aOperation );
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDetective( &rDocShell, pUndo, &aOperation ) );
+ }
+ aModificator.SetDocumentModified();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_REFRESH );
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveMarkInvalid(SCTAB nTab)
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ rDocShell.MakeDrawLayer();
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+
+ Window* pWaitWin = rDocShell.GetActiveDialogParent();
+ if (pWaitWin)
+ pWaitWin->EnterWait();
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bOverflow;
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).MarkInvalid( bOverflow );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (pWaitWin)
+ pWaitWin->LeaveWait();
+ if (bDone)
+ {
+ if (pUndo && bUndo)
+ {
+ pUndo->SetComment( ScGlobal::GetRscString( STR_UNDO_DETINVALID ) );
+ rDocShell.GetUndoManager()->AddUndoAction( pUndo );
+ }
+ aModificator.SetDocumentModified();
+ if ( bOverflow )
+ {
+ InfoBox( NULL,
+ ScGlobal::GetRscString( STR_DETINVALID_OVERFLOW ) ).Execute();
+ }
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveDelAll(SCTAB nTab)
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (!pModel)
+ return FALSE;
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ if (bUndo)
+ pModel->BeginCalcUndo();
+ BOOL bDone = ScDetectiveFunc( pDoc,nTab ).DeleteAll( SC_DET_DETECTIVE );
+ SdrUndoGroup* pUndo = NULL;
+ if (bUndo)
+ pUndo = pModel->GetCalcUndo();
+ if (bDone)
+ {
+ ScDetOpList* pOldList = pDoc->GetDetOpList();
+ ScDetOpList* pUndoList = NULL;
+ if (bUndo)
+ pUndoList = pOldList ? new ScDetOpList(*pOldList) : NULL;
+
+ pDoc->ClearDetectiveOperations();
+
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDetective( &rDocShell, pUndo, NULL, pUndoList ) );
+ }
+ aModificator.SetDocumentModified();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DETECTIVE_REFRESH );
+ }
+ else
+ delete pUndo;
+
+ return bDone;
+}
+
+BOOL ScDocFunc::DetectiveRefresh( BOOL bAutomatic )
+{
+ BOOL bDone = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScDetOpList* pList = pDoc->GetDetOpList();
+ if ( pList && pList->Count() )
+ {
+ rDocShell.MakeDrawLayer();
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (bUndo)
+ pModel->BeginCalcUndo();
+
+ // Loeschen auf allen Tabellen
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ ScDetectiveFunc( pDoc,nTab ).DeleteAll( SC_DET_ARROWS ); // don't remove circles
+
+ // Wiederholen
+
+ USHORT nCount = pList->Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScDetOpData* pData = (*pList)[i];
+ if (pData)
+ {
+ ScAddress aPos = pData->GetPos();
+ ScDetectiveFunc aFunc( pDoc, aPos.Tab() );
+ SCCOL nCol = aPos.Col();
+ SCROW nRow = aPos.Row();
+ switch (pData->GetOperation())
+ {
+ case SCDETOP_ADDSUCC:
+ aFunc.ShowSucc( nCol, nRow );
+ break;
+ case SCDETOP_DELSUCC:
+ aFunc.DeleteSucc( nCol, nRow );
+ break;
+ case SCDETOP_ADDPRED:
+ aFunc.ShowPred( nCol, nRow );
+ break;
+ case SCDETOP_DELPRED:
+ aFunc.DeletePred( nCol, nRow );
+ break;
+ case SCDETOP_ADDERROR:
+ aFunc.ShowError( nCol, nRow );
+ break;
+ default:
+ DBG_ERROR("falsche Op bei DetectiveRefresh");
+ }
+ }
+ }
+
+ if (bUndo)
+ {
+ SdrUndoGroup* pUndo = pModel->GetCalcUndo();
+ if (pUndo)
+ {
+ pUndo->SetComment( ScGlobal::GetRscString( STR_UNDO_DETREFRESH ) );
+ // wenn automatisch, an letzte Aktion anhaengen
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDraw( pUndo, &rDocShell ),
+ bAutomatic );
+ }
+ }
+ rDocShell.SetDrawModified();
+ bDone = TRUE;
+ }
+ return bDone;
+}
+
+static void lcl_collectAllPredOrSuccRanges(
+ const ScRangeList& rSrcRanges, vector<ScSharedTokenRef>& rRefTokens, ScDocShell& rDocShell,
+ bool bPred)
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ vector<ScSharedTokenRef> aRefTokens;
+ ScRangeList aSrcRanges(rSrcRanges);
+ ScRange* p = aSrcRanges.First();
+ if (!p)
+ return;
+ ScDetectiveFunc aDetFunc(pDoc, p->aStart.Tab());
+ ScRangeList aDestRanges;
+ for (; p; p = aSrcRanges.Next())
+ {
+ if (bPred)
+ {
+ aDetFunc.GetAllPreds(
+ p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), aRefTokens);
+ }
+ else
+ {
+ aDetFunc.GetAllSuccs(
+ p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), aRefTokens);
+ }
+ }
+ rRefTokens.swap(aRefTokens);
+}
+
+void ScDocFunc::DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, vector<ScSharedTokenRef>& rRefTokens)
+{
+ lcl_collectAllPredOrSuccRanges(rSrcRanges, rRefTokens, rDocShell, true);
+}
+
+void ScDocFunc::DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, vector<ScSharedTokenRef>& rRefTokens)
+{
+ lcl_collectAllPredOrSuccRanges(rSrcRanges, rRefTokens, rDocShell, false);
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::DeleteContents( const ScMarkData& rMark, USHORT nFlags,
+ BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ DBG_ERROR("ScDocFunc::DeleteContents ohne Markierung");
+ return FALSE;
+ }
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScEditableTester aTester( pDoc, rMark );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ ScRange aMarkRange;
+ BOOL bSimple = FALSE;
+
+ ScMarkData aMultiMark = rMark;
+ aMultiMark.SetMarking(FALSE); // fuer MarkToMulti
+
+ ScDocument* pUndoDoc = NULL;
+ BOOL bMulti = !bSimple && aMultiMark.IsMultiMarked();
+ if (!bSimple)
+ {
+ aMultiMark.MarkToMulti();
+ aMultiMark.GetMultiMarkArea( aMarkRange );
+ }
+ ScRange aExtendedRange(aMarkRange);
+ if (!bSimple)
+ {
+ if ( pDoc->ExtendMerge( aExtendedRange, TRUE ) )
+ bMulti = FALSE;
+ }
+
+ // keine Objekte auf geschuetzten Tabellen
+ BOOL bObjects = FALSE;
+ if ( nFlags & IDF_OBJECTS )
+ {
+ bObjects = TRUE;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (aMultiMark.GetTableSelect(nTab) && pDoc->IsTabProtected(nTab))
+ bObjects = FALSE;
+ }
+
+ USHORT nExtFlags = 0; // extra flags are needed only if attributes are deleted
+ if ( nFlags & IDF_ATTRIB )
+ rDocShell.UpdatePaintExt( nExtFlags, aMarkRange );
+
+ // Reihenfolge:
+ // 1) BeginDrawUndo
+ // 2) Objekte loeschen (DrawUndo wird gefuellt)
+ // 3) Inhalte fuer Undo kopieren und Undo-Aktion anlegen
+ // 4) Inhalte loeschen
+
+ bool bDrawUndo = bObjects || (nFlags & IDF_NOTE);
+ if (bRecord && bDrawUndo)
+ pDoc->BeginDrawUndo();
+
+ if (bObjects)
+ {
+ if (bMulti)
+ pDoc->DeleteObjectsInSelection( aMultiMark );
+ else
+ pDoc->DeleteObjectsInArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),
+ aMultiMark );
+ }
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, aMarkRange.aStart.Tab(), aMarkRange.aEnd.Tab() );
+
+ // bei "Format/Standard" alle Attribute kopieren, weil CopyToDocument
+ // nur mit IDF_HARDATTR zu langsam ist:
+ USHORT nUndoDocFlags = nFlags;
+ if (nFlags & IDF_ATTRIB)
+ nUndoDocFlags |= IDF_ATTRIB;
+ if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute
+ nUndoDocFlags |= IDF_STRING; // -> Zellen werden geaendert
+ if (nFlags & IDF_NOTE)
+ nUndoDocFlags |= IDF_CONTENTS; // #68795# copy all cells with their notes
+ // note captions are handled in drawing undo
+ nUndoDocFlags |= IDF_NOCAPTIONS;
+ pDoc->CopyToDocument( aExtendedRange, nUndoDocFlags, bMulti, pUndoDoc, &aMultiMark );
+ }
+
+//! HideAllCursors(); // falls Zusammenfassung aufgehoben wird
+ if (bSimple)
+ pDoc->DeleteArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),
+ aMultiMark, nFlags );
+ else
+ {
+ pDoc->DeleteSelection( nFlags, aMultiMark );
+// aMultiMark.MarkToSimple();
+ }
+
+ // add undo action after drawing undo is complete (objects and note captions)
+ if( bRecord )
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDeleteContents( &rDocShell, aMultiMark, aExtendedRange,
+ pUndoDoc, bMulti, nFlags, bDrawUndo ) );
+
+ if (!AdjustRowHeight( aExtendedRange ))
+ rDocShell.PostPaint( aExtendedRange, PAINT_GRID, nExtFlags );
+ else if (nExtFlags & SC_PF_LINES)
+ lcl_PaintAbove( rDocShell, aExtendedRange ); // fuer Linien ueber dem Bereich
+
+// rDocShell.UpdateOle(GetViewData()); //! an der View?
+ aModificator.SetDocumentModified();
+//! CellContentChanged();
+//! ShowAllCursors();
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
+ BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScEditableTester aTester( pDoc, rMark );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ ScRange aMarkRange;
+ ScMarkData aMultiMark = rMark;
+ aMultiMark.SetMarking(FALSE); // for MarkToMulti
+ aMultiMark.MarkToMulti();
+ aMultiMark.GetMultiMarkArea( aMarkRange );
+
+ if (bRecord)
+ {
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCTAB nTabCount = pDoc->GetTableCount();
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nStartTab && rMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_CONTENTS, TRUE, pUndoDoc, &aMultiMark );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTransliterate( &rDocShell, aMultiMark, pUndoDoc, nType ) );
+ }
+
+ pDoc->TransliterateText( aMultiMark, nType );
+
+ if (!AdjustRowHeight( aMarkRange ))
+ rDocShell.PostPaint( aMarkRange, PAINT_GRID );
+
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::SetNormalString( const ScAddress& rPos, const String& rText, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ ScEditableTester aTester( pDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ SCTAB* pTabs = NULL;
+ ScBaseCell** ppOldCells = NULL;
+ BOOL* pHasFormat = NULL;
+ ULONG* pOldFormats = NULL;
+ ScBaseCell* pDocCell = pDoc->GetCell( rPos );
+ BOOL bEditDeleted = (pDocCell && pDocCell->GetCellType() == CELLTYPE_EDIT);
+ if (bUndo)
+ {
+ pTabs = new SCTAB[1];
+ pTabs[0] = rPos.Tab();
+ ppOldCells = new ScBaseCell*[1];
+ ppOldCells[0] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0;
+
+ pHasFormat = new BOOL[1];
+ pOldFormats = new ULONG[1];
+ const SfxPoolItem* pItem;
+ const ScPatternAttr* pPattern = pDoc->GetPattern( rPos.Col(),rPos.Row(),rPos.Tab() );
+ if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState(
+ ATTR_VALUE_FORMAT,FALSE,&pItem) )
+ {
+ pHasFormat[0] = TRUE;
+ pOldFormats[0] = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+ else
+ pHasFormat[0] = FALSE;
+ }
+
+ pDoc->SetString( rPos.Col(), rPos.Row(), rPos.Tab(), rText );
+
+ if (bUndo)
+ {
+ // wegen ChangeTracking darf UndoAction erst nach SetString angelegt werden
+ rDocShell.GetUndoManager()->AddUndoAction(new ScUndoEnterData( &rDocShell, rPos.Col(),rPos.Row(),rPos.Tab(), 1,pTabs,
+ ppOldCells, pHasFormat, pOldFormats, rText, NULL ) );
+ }
+
+ if ( bEditDeleted || pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) )
+ AdjustRowHeight( ScRange(rPos) );
+
+ rDocShell.PostPaintCell( rPos );
+ aModificator.SetDocumentModified();
+
+ // #107160# notify input handler here the same way as in PutCell
+ if (bApi)
+ NotifyInputHandler( rPos );
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ BOOL bXMLLoading(pDoc->IsImportingXML());
+
+ // #i925#; it is not neccessary to test whether the cell is editable on loading a XML document
+ if (!bXMLLoading)
+ {
+ ScEditableTester aTester( pDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ pNewCell->Delete();
+ return FALSE;
+ }
+ }
+
+ BOOL bEditCell = ( pNewCell->GetCellType() == CELLTYPE_EDIT );
+ ScBaseCell* pDocCell = pDoc->GetCell( rPos );
+ BOOL bEditDeleted = (pDocCell && pDocCell->GetCellType() == CELLTYPE_EDIT);
+ BOOL bHeight = ( bEditDeleted || bEditCell ||
+ pDoc->HasAttrib( ScRange(rPos), HASATTR_NEEDHEIGHT ) );
+
+ ScBaseCell* pUndoCell = (bUndo && pDocCell) ? pDocCell->CloneWithoutNote( *pDoc, rPos ) : 0;
+ ScBaseCell* pRedoCell = (bUndo && pNewCell) ? pNewCell->CloneWithoutNote( *pDoc, rPos ) : 0;
+
+ pDoc->PutCell( rPos, pNewCell );
+
+ // wegen ChangeTracking darf UndoAction erst nach PutCell angelegt werden
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoPutCell( &rDocShell, rPos, pUndoCell, pRedoCell, bHeight ) );
+ }
+
+ if (bHeight)
+ AdjustRowHeight( ScRange(rPos) );
+
+ if (!bXMLLoading)
+ rDocShell.PostPaintCell( rPos );
+
+ aModificator.SetDocumentModified();
+
+ // #i925#; it is not neccessary to notify on loading a XML document
+ // #103934#; notify editline and cell in edit mode
+ if (bApi && !bXMLLoading)
+ NotifyInputHandler( rPos );
+
+ return TRUE;
+}
+
+void ScDocFunc::NotifyInputHandler( const ScAddress& /* rPos */ )
+{
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh && pViewSh->GetViewData()->GetDocShell() == &rDocShell )
+ {
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if ( pInputHdl )
+ {
+ sal_Bool bIsEditMode(pInputHdl->IsEditMode());
+
+ // set modified if in editmode, because so the string is not set in the InputWindow like in the cell
+ // (the cell shows the same like the InputWindow)
+ if (bIsEditMode)
+ pInputHdl->SetModified();
+ pViewSh->UpdateInputHandler(FALSE, !bIsEditMode);
+ }
+ }
+}
+
+ struct ScMyRememberItem
+ {
+ USHORT nIndex;
+ SfxItemSet aItemSet;
+
+ ScMyRememberItem(const SfxItemSet& rItemSet, USHORT nTempIndex) :
+ nIndex(nTempIndex), aItemSet(rItemSet) {}
+ };
+
+ typedef ::std::list<ScMyRememberItem*> ScMyRememberItemList;
+
+BOOL ScDocFunc::PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine, BOOL bInterpret, BOOL bApi )
+{
+ // PutData ruft PutCell oder SetNormalString
+
+ BOOL bRet = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScEditAttrTester aTester( &rEngine );
+ BOOL bEditCell = aTester.NeedsObject();
+ if ( bEditCell )
+ {
+ // #i61702# With bLoseContent set, the content of rEngine isn't restored
+ // (used in loading XML, where after the removeActionLock call the API obejct's
+ // EditEngine isn't accessed again.
+ sal_Bool bLoseContent = pDoc->IsImportingXML();
+
+ sal_Bool bUpdateMode(rEngine.GetUpdateMode());
+ if (bUpdateMode)
+ rEngine.SetUpdateMode(sal_False);
+
+ ScMyRememberItemList aRememberItems;
+ ScMyRememberItem* pRememberItem = NULL;
+
+ // All paragraph attributes must be removed before calling CreateTextObject,
+ // not only alignment, so the object doesn't contain the cell attributes as
+ // paragraph attributes. Before remove the attributes store they in a list to
+ // set they back to the EditEngine.
+ USHORT nCount = rEngine.GetParagraphCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ const SfxItemSet& rOld = rEngine.GetParaAttribs( i );
+ if ( rOld.Count() )
+ {
+ if ( !bLoseContent )
+ {
+ pRememberItem = new ScMyRememberItem(rEngine.GetParaAttribs(i), i);
+ aRememberItems.push_back(pRememberItem);
+ }
+ rEngine.SetParaAttribs( i, SfxItemSet( *rOld.GetPool(), rOld.GetRanges() ) );
+ }
+ }
+
+ EditTextObject* pNewData = rEngine.CreateTextObject();
+ bRet = PutCell( rPos,
+ new ScEditCell( pNewData, pDoc, rEngine.GetEditTextObjectPool() ),
+ bApi );
+ delete pNewData;
+
+ // Set the paragraph attributes back to the EditEngine.
+ if (!aRememberItems.empty())
+ {
+// ScMyRememberItem* pRememberItem = NULL;
+ ScMyRememberItemList::iterator aItr = aRememberItems.begin();
+ while (aItr != aRememberItems.end())
+ {
+ pRememberItem = *aItr;
+ rEngine.SetParaAttribs(pRememberItem->nIndex, pRememberItem->aItemSet);
+ delete pRememberItem;
+ aItr = aRememberItems.erase(aItr);
+ }
+ }
+
+ // #i61702# if the content isn't accessed, there's no need to set the UpdateMode again
+ if ( bUpdateMode && !bLoseContent )
+ rEngine.SetUpdateMode(sal_True);
+ }
+ else
+ {
+ String aText = rEngine.GetText();
+ if ( bInterpret || !aText.Len() )
+ bRet = SetNormalString( rPos, aText, bApi );
+ else
+ bRet = PutCell( rPos, new ScStringCell( aText ), bApi );
+ }
+
+ if ( bRet && aTester.NeedsCellAttr() )
+ {
+ const SfxItemSet& rEditAttr = aTester.GetAttribs();
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetFromEditItemSet( &rEditAttr );
+ aPattern.DeleteUnchanged( pDoc->GetPattern( rPos.Col(), rPos.Row(), rPos.Tab() ) );
+ aPattern.GetItemSet().ClearItem( ATTR_HOR_JUSTIFY ); // wasn't removed above if no edit object
+ if ( aPattern.GetItemSet().Count() > 0 )
+ {
+ ScMarkData aMark;
+ aMark.SelectTable( rPos.Tab(), TRUE );
+ aMark.SetMarkArea( ScRange( rPos ) );
+ ApplyAttributes( aMark, aPattern, TRUE, bApi );
+ }
+ }
+
+ return bRet;
+}
+
+
+ScTokenArray* lcl_ScDocFunc_CreateTokenArrayXML( const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
+{
+ ScTokenArray* pCode = new ScTokenArray;
+ pCode->AddString( rText );
+ if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && (rFormulaNmsp.Len() > 0) )
+ pCode->AddString( rFormulaNmsp );
+ return pCode;
+}
+
+
+ScBaseCell* ScDocFunc::InterpretEnglishString( const ScAddress& rPos,
+ const String& rText, const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScBaseCell* pNewCell = NULL;
+
+ if ( rText.Len() > 1 && rText.GetChar(0) == '=' )
+ {
+ ScTokenArray* pCode;
+ if ( pDoc->IsImportingXML() )
+ { // temporary formula string as string tokens
+ pCode = lcl_ScDocFunc_CreateTokenArrayXML( rText, rFormulaNmsp, eGrammar );
+ pDoc->IncXMLImportedFormulaCount( rText.Len() );
+ }
+ else
+ {
+ ScCompiler aComp( pDoc, rPos );
+ aComp.SetGrammar(eGrammar);
+ pCode = aComp.CompileString( rText );
+ }
+ pNewCell = new ScFormulaCell( pDoc, rPos, pCode, eGrammar, MM_NONE );
+ delete pCode; // Zell-ctor hat das TokenArray kopiert
+ }
+ else if ( rText.Len() > 1 && rText.GetChar(0) == '\'' )
+ {
+ // for bEnglish, "'" at the beginning is always interpreted as text
+ // marker and stripped
+ pNewCell = ScBaseCell::CreateTextCell( rText.Copy( 1 ), pDoc );
+ }
+ else // (nur) auf englisches Zahlformat testen
+ {
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
+ double fVal;
+ if ( pFormatter->IsNumberFormat( rText, nEnglish, fVal ) )
+ pNewCell = new ScValueCell( fVal );
+ else if ( rText.Len() )
+ pNewCell = ScBaseCell::CreateTextCell( rText, pDoc );
+
+ // das (englische) Zahlformat wird nicht gesetzt
+ //! passendes lokales Format suchen und setzen???
+ }
+
+ return pNewCell;
+}
+
+
+BOOL ScDocFunc::SetCellText( const ScAddress& rPos, const String& rText,
+ BOOL bInterpret, BOOL bEnglish, BOOL bApi,
+ const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
+{
+ // SetCellText ruft PutCell oder SetNormalString
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScBaseCell* pNewCell = NULL;
+ if ( bInterpret )
+ {
+ if ( bEnglish )
+ {
+ ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
+ if (bApi)
+ pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
+
+ // code moved to own method InterpretEnglishString because it is also used in
+ // ScCellRangeObj::setFormulaArray
+
+ pNewCell = InterpretEnglishString( rPos, rText, rFormulaNmsp, eGrammar );
+ }
+ // sonst Null behalten -> SetString mit lokalen Formeln/Zahlformat
+ }
+ else if ( rText.Len() )
+ {
+ OSL_ENSURE( rFormulaNmsp.Len() == 0, "ScDocFunc::SetCellText - formula namespace, but do not interpret?" );
+ pNewCell = ScBaseCell::CreateTextCell( rText, pDoc ); // immer Text
+ }
+
+ if (pNewCell)
+ return PutCell( rPos, pNewCell, bApi );
+ else
+ return SetNormalString( rPos, rText, bApi );
+}
+
+//------------------------------------------------------------------------
+
+bool ScDocFunc::ShowNote( const ScAddress& rPos, bool bShow )
+{
+ ScDocument& rDoc = *rDocShell.GetDocument();
+ ScPostIt* pNote = rDoc.GetNote( rPos );
+ if( !pNote || (bShow == pNote->IsCaptionShown()) ) return false;
+
+ // move the caption to internal or hidden layer and create undo action
+ pNote->ShowCaption( rPos, bShow );
+ if( rDoc.IsUndoEnabled() )
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoShowHideNote( rDocShell, rPos, bShow ) );
+
+ if (rDoc.IsStreamValid(rPos.Tab()))
+ rDoc.SetStreamValid(rPos.Tab(), FALSE);
+
+ rDocShell.SetDocumentModified();
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool ScDocFunc::SetNoteText( const ScAddress& rPos, const String& rText, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScEditableTester aTester( pDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return false;
+ }
+
+ String aNewText = rText;
+ aNewText.ConvertLineEnd(); //! ist das noetig ???
+
+ if( ScPostIt* pNote = (aNewText.Len() > 0) ? pDoc->GetOrCreateNote( rPos ) : pDoc->GetNote( rPos ) )
+ pNote->SetText( rPos, aNewText );
+
+ //! Undo !!!
+
+ if (pDoc->IsStreamValid(rPos.Tab()))
+ pDoc->SetStreamValid(rPos.Tab(), FALSE);
+
+ rDocShell.PostPaintCell( rPos );
+ aModificator.SetDocumentModified();
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+bool ScDocFunc::ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate, BOOL bApi )
+{
+ bool bDone = false;
+
+ ScDocShellModificator aModificator( rDocShell );
+ ScDocument& rDoc = *rDocShell.GetDocument();
+ ScEditableTester aTester( &rDoc, rPos.Tab(), rPos.Col(),rPos.Row(), rPos.Col(),rPos.Row() );
+ if (aTester.IsEditable())
+ {
+ ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+ SfxUndoManager* pUndoMgr = (pDrawLayer && rDoc.IsUndoEnabled()) ? rDocShell.GetUndoManager() : 0;
+
+ ScNoteData aOldData;
+ ScPostIt* pOldNote = rDoc.ReleaseNote( rPos );
+ if( pOldNote )
+ {
+ // ensure existing caption object before draw undo tracking starts
+ pOldNote->GetOrCreateCaption( rPos );
+ // rescue note data for undo
+ aOldData = pOldNote->GetNoteData();
+ }
+
+ // collect drawing undo actions for deleting/inserting caption obejcts
+ if( pUndoMgr )
+ pDrawLayer->BeginCalcUndo();
+
+ // delete the note (creates drawing undo action for the caption object)
+ delete pOldNote;
+
+ // create new note (creates drawing undo action for the new caption object)
+ ScNoteData aNewData;
+ if( ScPostIt* pNewNote = ScNoteUtil::CreateNoteFromString( rDoc, rPos, rNoteText, false, true ) )
+ {
+ if( pAuthor ) pNewNote->SetAuthor( *pAuthor );
+ if( pDate ) pNewNote->SetDate( *pDate );
+ // rescue note data for undo
+ aNewData = pNewNote->GetNoteData();
+ }
+
+ // create the undo action
+ if( pUndoMgr && (aOldData.mpCaption || aNewData.mpCaption) )
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( rDocShell, rPos, aOldData, aNewData, pDrawLayer->GetCalcUndo() ) );
+
+ // repaint cell (to make note marker visible)
+ rDocShell.PostPaintCell( rPos );
+
+ if (rDoc.IsStreamValid(rPos.Tab()))
+ rDoc.SetStreamValid(rPos.Tab(), FALSE);
+
+ aModificator.SetDocumentModified();
+ bDone = true;
+ }
+ else if (!bApi)
+ {
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ }
+
+ return bDone;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern,
+ BOOL bRecord, BOOL bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if ( bRecord && !pDoc->IsUndoEnabled() )
+ bRecord = FALSE;
+
+ BOOL bImportingXML = pDoc->IsImportingXML();
+ // Cell formats can still be set if the range isn't editable only because of matrix formulas.
+ // #i62483# When loading XML, the check can be skipped altogether.
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !bImportingXML && !pDoc->IsSelectionEditable( rMark, &bOnlyNotBecauseOfMatrix )
+ && !bOnlyNotBecauseOfMatrix )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR);
+ return FALSE;
+ }
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ //! Umrandung
+
+ ScRange aMultiRange;
+ BOOL bMulti = rMark.IsMultiMarked();
+ if ( bMulti )
+ rMark.GetMultiMarkArea( aMultiRange );
+ else
+ rMark.GetMarkArea( aMultiRange );
+
+ if ( bRecord )
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, aMultiRange.aStart.Tab(), aMultiRange.aEnd.Tab() );
+ pDoc->CopyToDocument( aMultiRange, IDF_ATTRIB, bMulti, pUndoDoc, &rMark );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoSelectionAttr(
+ &rDocShell, rMark,
+ aMultiRange.aStart.Col(), aMultiRange.aStart.Row(), aMultiRange.aStart.Tab(),
+ aMultiRange.aEnd.Col(), aMultiRange.aEnd.Row(), aMultiRange.aEnd.Tab(),
+ pUndoDoc, bMulti, &rPattern ) );
+ }
+
+ // While loading XML it is not neccessary to ask HasAttrib. It needs too much time.
+ USHORT nExtFlags = 0;
+ if ( !bImportingXML )
+ rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content before the change
+ pDoc->ApplySelectionPattern( rPattern, rMark );
+ if ( !bImportingXML )
+ rDocShell.UpdatePaintExt( nExtFlags, aMultiRange ); // content after the change
+
+ if (!AdjustRowHeight( aMultiRange ))
+ rDocShell.PostPaint( aMultiRange, PAINT_GRID, nExtFlags );
+ else if (nExtFlags & SC_PF_LINES)
+ lcl_PaintAbove( rDocShell, aMultiRange ); // fuer Linien ueber dem Bereich
+
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+
+BOOL ScDocFunc::ApplyStyle( const ScMarkData& rMark, const String& rStyleName,
+ BOOL bRecord, BOOL bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if ( bRecord && !pDoc->IsUndoEnabled() )
+ bRecord = FALSE;
+
+ BOOL bImportingXML = pDoc->IsImportingXML();
+ // Cell formats can still be set if the range isn't editable only because of matrix formulas.
+ // #i62483# When loading XML, the check can be skipped altogether.
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !bImportingXML && !pDoc->IsSelectionEditable( rMark, &bOnlyNotBecauseOfMatrix )
+ && !bOnlyNotBecauseOfMatrix )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR);
+ return FALSE;
+ }
+
+ ScStyleSheet* pStyleSheet = (ScStyleSheet*) pDoc->GetStyleSheetPool()->Find(
+ rStyleName, SFX_STYLE_FAMILY_PARA );
+ if (!pStyleSheet)
+ return FALSE;
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScRange aMultiRange;
+ BOOL bMulti = rMark.IsMultiMarked();
+ if ( bMulti )
+ rMark.GetMultiMarkArea( aMultiRange );
+ else
+ rMark.GetMarkArea( aMultiRange );
+
+ if ( bRecord )
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nStartTab = aMultiRange.aStart.Tab();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nStartTab && rMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange = aMultiRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &rMark );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoSelectionStyle(
+ &rDocShell, rMark, aMultiRange, rStyleName, pUndoDoc ) );
+
+ }
+
+// BOOL bPaintExt = pDoc->HasAttrib( aMultiRange, HASATTR_PAINTEXT );
+// pDoc->ApplySelectionPattern( rPattern, rMark );
+
+ pDoc->ApplySelectionStyle( (ScStyleSheet&)*pStyleSheet, rMark );
+
+// if (!bPaintExt)
+// bPaintExt = pDoc->HasAttrib( aMultiRange, HASATTR_PAINTEXT );
+// USHORT nExtFlags = bPaintExt ? SC_PF_LINES : 0;
+ USHORT nExtFlags = 0;
+ if (!AdjustRowHeight( aMultiRange ))
+ rDocShell.PostPaint( aMultiRange, PAINT_GRID, nExtFlags );
+ else if (nExtFlags & SC_PF_LINES)
+ lcl_PaintAbove( rDocShell, aMultiRange ); // fuer Linien ueber dem Bereich
+
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::InsertCells( const ScRange& rRange, const ScMarkData* pTabMark, InsCellCmd eCmd,
+ BOOL bRecord, BOOL bApi, BOOL bPartOfPaste )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if ( !ValidRow(nStartRow) || !ValidRow(nEndRow) )
+ {
+ DBG_ERROR("invalid row in InsertCells");
+ return FALSE;
+ }
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCCOL nPaintStartX = nStartCol;
+ SCROW nPaintStartY = nStartRow;
+ SCCOL nPaintEndX = nEndCol;
+ SCROW nPaintEndY = nEndRow;
+ USHORT nPaintFlags = PAINT_GRID;
+ BOOL bSuccess;
+ SCTAB i;
+
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell(); //preserve current cursor position
+ SCCOL nCursorCol = 0;
+ SCROW nCursorRow = 0;
+ if( pViewSh )
+ {
+ nCursorCol = pViewSh->GetViewData()->GetCurX();
+ nCursorRow = pViewSh->GetViewData()->GetCurY();
+ }
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ SCTAB nCount = 0;
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( !pDoc->IsScenario(i) )
+ {
+ nCount++;
+ if( nCount == nEndTab+1 )
+ {
+ aMark.SelectTable( i, TRUE );
+ break;
+ }
+ }
+ }
+ }
+
+ ScMarkData aFullMark( aMark ); // including scenario sheets
+ for( i=0; i<nTabCount; i++ )
+ if( aMark.GetTableSelect( i ) )
+ {
+ for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ aFullMark.SelectTable( j, TRUE );
+ }
+
+ SCTAB nSelCount = aMark.GetSelectCount();
+
+ // zugehoerige Szenarien auch anpassen
+ // Test zusammengefasste
+
+ SCCOL nMergeTestStartX = nStartCol;
+ SCROW nMergeTestStartY = nStartRow;
+ SCCOL nMergeTestEndX = nEndCol;
+ SCROW nMergeTestEndY = nEndRow;
+
+ ScRange aExtendMergeRange( rRange );
+
+ if( rRange.aStart == rRange.aEnd && pDoc->HasAttrib(rRange, HASATTR_MERGED) )
+ {
+ pDoc->ExtendMerge( aExtendMergeRange );
+ pDoc->ExtendOverlapped( aExtendMergeRange );
+ nMergeTestEndX = aExtendMergeRange.aEnd.Col();
+ nMergeTestEndY = aExtendMergeRange.aEnd.Row();
+ nPaintEndX = nMergeTestEndX;
+ nPaintEndY = nMergeTestEndY;
+ }
+
+ if ( eCmd == INS_INSROWS )
+ {
+ nMergeTestStartX = 0;
+ nMergeTestEndX = MAXCOL;
+ }
+ if ( eCmd == INS_INSCOLS )
+ {
+ nMergeTestStartY = 0;
+ nMergeTestEndY = MAXROW;
+ }
+ if ( eCmd == INS_CELLSDOWN )
+ nMergeTestEndY = MAXROW;
+ if ( eCmd == INS_CELLSRIGHT )
+ nMergeTestEndX = MAXCOL;
+
+ BOOL bNeedRefresh = FALSE;
+
+ SCCOL nEditTestEndX = (eCmd==INS_INSCOLS) ? MAXCOL : nMergeTestEndX;
+ SCROW nEditTestEndY = (eCmd==INS_INSROWS) ? MAXROW : nMergeTestEndY;
+ ScEditableTester aTester( pDoc, nMergeTestStartX, nMergeTestStartY, nEditTestEndX, nEditTestEndY, aMark );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ WaitObject aWait( rDocShell.GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+
+ ScDocument* pRefUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ if ( bRecord )
+ {
+ pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, FALSE, FALSE );
+
+ // pRefUndoDoc is filled in InsertCol / InsertRow
+
+ pUndoData = new ScRefUndoData( pDoc );
+
+ pDoc->BeginDrawUndo();
+ }
+
+ // #i8302 : we unmerge overwhelming ranges, before insertion all the actions are put in the same ListAction
+ // the patch comes from mloiseleur and maoyg
+ BOOL bInsertMerge = FALSE;
+ std::vector<ScRange> qIncreaseRange;
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_INSERTCELLS );
+ if (bRecord)
+ rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect(i) )
+ {
+ if( pDoc->HasAttrib( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ if (eCmd==INS_CELLSRIGHT)
+ bNeedRefresh = TRUE;
+
+ SCCOL nMergeStartX = nMergeTestStartX;
+ SCROW nMergeStartY = nMergeTestStartY;
+ SCCOL nMergeEndX = nMergeTestEndX;
+ SCROW nMergeEndY = nMergeTestEndY;
+
+ pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
+ pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
+
+ if(( eCmd == INS_CELLSDOWN && ( nMergeStartX != nMergeTestStartX || nMergeEndX != nMergeTestEndX )) ||
+ (eCmd == INS_CELLSRIGHT && ( nMergeStartY != nMergeTestStartY || nMergeEndY != nMergeTestEndY )) )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
+ rDocShell.GetUndoManager()->LeaveListAction();
+ return FALSE;
+ }
+
+ SCCOL nTestCol = -1;
+ SCROW nTestRow1 = -1;
+ SCROW nTestRow2 = -1;
+
+ ScDocAttrIterator aTestIter( pDoc, i, nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY );
+ ScRange aExtendRange( nMergeTestStartX, nMergeTestStartY, i, nMergeTestEndX, nMergeTestEndY, i );
+ const ScPatternAttr* pPattern = NULL;
+ const ScMergeAttr* pMergeFlag = NULL;
+ const ScMergeFlagAttr* pMergeFlagAttr = NULL;
+ while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != NULL )
+ {
+ pMergeFlag = (const ScMergeAttr*) &pPattern->GetItem(ATTR_MERGE);
+ pMergeFlagAttr = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
+ INT16 nNewFlags = pMergeFlagAttr->GetValue() & ( SC_MF_HOR | SC_MF_VER );
+ if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == SC_MF_HOR || nNewFlags == SC_MF_VER )
+ {
+ ScRange aRange( nTestCol, nTestRow1, i );
+ pDoc->ExtendOverlapped(aRange);
+ pDoc->ExtendMerge(aRange, TRUE, TRUE);
+
+ if( nTestRow1 < nTestRow2 && nNewFlags == SC_MF_HOR )
+ {
+ for( SCROW nTestRow = nTestRow1; nTestRow <= nTestRow2; nTestRow++ )
+ {
+ ScRange aTestRange( nTestCol, nTestRow, i );
+ pDoc->ExtendOverlapped( aTestRange );
+ pDoc->ExtendMerge( aTestRange, TRUE, TRUE);
+ ScRange aMergeRange( aTestRange.aStart.Col(),aTestRange.aStart.Row(), i );
+ if( !aExtendRange.In( aMergeRange ) )
+ {
+ qIncreaseRange.push_back( aTestRange );
+ bInsertMerge = TRUE;
+ }
+ }
+ }
+ else
+ {
+ ScRange aMergeRange( aRange.aStart.Col(),aRange.aStart.Row(), i );
+ if( !aExtendRange.In( aMergeRange ) )
+ {
+ qIncreaseRange.push_back( aRange );
+ }
+ bInsertMerge = TRUE;
+ }
+ }
+ }
+
+ if( bInsertMerge )
+ {
+ if( eCmd == INS_INSROWS || eCmd == INS_CELLSDOWN )
+ {
+ nStartRow = aExtendMergeRange.aStart.Row();
+ nEndRow = aExtendMergeRange.aEnd.Row();
+
+ if( eCmd == INS_CELLSDOWN )
+ nEndCol = nMergeTestEndX;
+ else
+ {
+ nStartCol = 0;
+ nEndCol = MAXCOL;
+ }
+ }
+ else if( eCmd == INS_CELLSRIGHT || eCmd == INS_INSCOLS )
+ {
+
+ nStartCol = aExtendMergeRange.aStart.Col();
+ nEndCol = aExtendMergeRange.aEnd.Col();
+ if( eCmd == INS_CELLSRIGHT )
+ {
+ nEndRow = nMergeTestEndY;
+ }
+ else
+ {
+ nStartRow = 0;
+ nEndRow = MAXROW;
+ }
+ }
+
+ if( !qIncreaseRange.empty() )
+ {
+ for( ::std::vector<ScRange>::const_iterator iIter( qIncreaseRange.begin()); iIter != qIncreaseRange.end(); iIter++ )
+ {
+ ScRange aRange( *iIter );
+ if( pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
+ {
+ UnmergeCells( aRange, TRUE, TRUE );
+ }
+ }
+ }
+ }
+ else
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_INSERTCELLS_0);
+ rDocShell.GetUndoManager()->LeaveListAction();
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ switch (eCmd)
+ {
+ case INS_CELLSDOWN:
+ bSuccess = pDoc->InsertRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
+ nPaintEndY = MAXROW;
+ break;
+ case INS_INSROWS:
+ bSuccess = pDoc->InsertRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &aFullMark );
+ nPaintStartX = 0;
+ nPaintEndX = MAXCOL;
+ nPaintEndY = MAXROW;
+ nPaintFlags |= PAINT_LEFT;
+ break;
+ case INS_CELLSRIGHT:
+ bSuccess = pDoc->InsertCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
+ nPaintEndX = MAXCOL;
+ break;
+ case INS_INSCOLS:
+ bSuccess = pDoc->InsertCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &aFullMark );
+ nPaintStartY = 0;
+ nPaintEndY = MAXROW;
+ nPaintEndX = MAXCOL;
+ nPaintFlags |= PAINT_TOP;
+ break;
+ default:
+ DBG_ERROR("Falscher Code beim Einfuegen");
+ bSuccess = FALSE;
+ break;
+ }
+
+ if ( bSuccess )
+ {
+ SCTAB* pTabs = NULL;
+ SCTAB* pScenarios = NULL;
+ SCTAB nUndoPos = 0;
+
+ if ( bRecord )
+ {
+ pTabs = new SCTAB[nSelCount];
+ pScenarios = new SCTAB[nSelCount];
+ nUndoPos = 0;
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ {
+ SCTAB nCount = 0;
+ for( SCTAB j=i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ nCount ++;
+
+ pScenarios[nUndoPos] = nCount;
+ pTabs[nUndoPos] = i;
+ nUndoPos ++;
+ }
+ }
+
+ if( !bInsertMerge )
+ {
+ rDocShell.GetUndoManager()->LeaveListAction();
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertCells(
+ &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),
+ nUndoPos, pTabs, pScenarios, eCmd, pRefUndoDoc, pUndoData, bPartOfPaste ) );
+ }
+
+ // #i8302 : we remerge growing ranges, with the new part inserted
+
+ while( !qIncreaseRange.empty() )
+ {
+ ScRange aRange = qIncreaseRange.back();
+ if( !pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
+ {
+ switch (eCmd)
+ {
+ case INS_CELLSDOWN:
+ case INS_INSROWS:
+ aRange.aEnd.IncRow(static_cast<SCsCOL>(nEndRow-nStartRow+1));
+ break;
+ case INS_CELLSRIGHT:
+ case INS_INSCOLS:
+ aRange.aEnd.IncCol(static_cast<SCsCOL>(nEndCol-nStartCol+1));
+ break;
+ default:
+ break;
+ }
+ ScCellMergeOption aMergeOption(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row() );
+ aMergeOption.maTabs.insert(aRange.aStart.Tab());
+ MergeCells(aMergeOption, FALSE, TRUE, TRUE);
+ }
+ qIncreaseRange.pop_back();
+ }
+
+ if( bInsertMerge )
+ rDocShell.GetUndoManager()->LeaveListAction();
+
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ {
+ if (bNeedRefresh)
+ pDoc->ExtendMerge( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i, TRUE );
+ else
+ pDoc->RefreshAutoFilter( nMergeTestStartX, nMergeTestStartY, nMergeTestEndX, nMergeTestEndY, i );
+
+ if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS )
+ pDoc->UpdatePageBreaks( i );
+
+ USHORT nExtFlags = 0;
+ rDocShell.UpdatePaintExt( nExtFlags, nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i );
+
+ SCTAB nScenarioCount = 0;
+
+ for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ nScenarioCount ++;
+
+ BOOL bAdjusted = ( eCmd == INS_INSROWS ) ? AdjustRowHeight(ScRange(0, nStartRow, i, MAXCOL, nEndRow, i+nScenarioCount )) :
+ AdjustRowHeight(ScRange(0, nPaintStartY, i, MAXCOL, nPaintEndY, i+nScenarioCount ));
+ if (bAdjusted)
+ {
+ // paint only what is not done by AdjustRowHeight
+ if (nPaintFlags & PAINT_TOP)
+ rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, PAINT_TOP );
+ }
+ else
+ rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, nPaintFlags, nExtFlags );
+ }
+ }
+ //aModificator.SetDocumentModified();
+ }
+ else
+ {
+ if( bInsertMerge )
+ {
+ while( !qIncreaseRange.empty() )
+ {
+ ScRange aRange = qIncreaseRange.back();
+ ScCellMergeOption aMergeOption(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row() );
+ MergeCells(aMergeOption, FALSE, TRUE, TRUE);
+ qIncreaseRange.pop_back();
+ }
+
+ if( pViewSh )
+ {
+ pViewSh->MarkRange( rRange, FALSE );
+ pViewSh->SetCursor( nCursorCol, nCursorRow );
+ }
+ }
+
+ rDocShell.GetUndoManager()->LeaveListAction();
+ SfxUndoManager* pMgr = rDocShell.GetUndoManager();
+ pMgr->RemoveLastUndoAction();
+
+ delete pRefUndoDoc;
+ delete pUndoData;
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_INSERT_FULL); // Spalte/Zeile voll
+ }
+
+ aModificator.SetDocumentModified();
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ return bSuccess;
+}
+
+BOOL ScDocFunc::DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark, DelCellCmd eCmd,
+ BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if ( !ValidRow(nStartRow) || !ValidRow(nEndRow) )
+ {
+ DBG_ERROR("invalid row in DeleteCells");
+ return FALSE;
+ }
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCCOL nPaintStartX = nStartCol;
+ SCROW nPaintStartY = nStartRow;
+ SCCOL nPaintEndX = nEndCol;
+ SCROW nPaintEndY = nEndRow;
+ USHORT nPaintFlags = PAINT_GRID;
+ SCTAB i;
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ SCTAB nCount = 0;
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( !pDoc->IsScenario(i) )
+ {
+ nCount++;
+ if( nCount == nEndTab+1 )
+ {
+ aMark.SelectTable( i, TRUE );
+ break;
+ }
+ }
+ }
+ }
+
+ ScMarkData aFullMark( aMark ); // including scenario sheets
+ for( i=0; i<nTabCount; i++ )
+ if( aMark.GetTableSelect( i ) )
+ {
+ for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ aFullMark.SelectTable( j, TRUE );
+ }
+
+ SCTAB nSelCount = aMark.GetSelectCount();
+
+ SCCOL nUndoStartX = nStartCol;
+ SCROW nUndoStartY = nStartRow;
+ SCCOL nUndoEndX = nEndCol;
+ SCROW nUndoEndY = nEndRow;
+
+ ScRange aExtendMergeRange( rRange );
+
+ if( rRange.aStart == rRange.aEnd && pDoc->HasAttrib(rRange, HASATTR_MERGED) )
+ {
+ pDoc->ExtendMerge( aExtendMergeRange );
+ pDoc->ExtendOverlapped( aExtendMergeRange );
+ nUndoEndX = aExtendMergeRange.aEnd.Col();
+ nUndoEndY = aExtendMergeRange.aEnd.Row();
+ nPaintEndX = nUndoEndX;
+ nPaintEndY = nUndoEndY;
+ }
+
+ if (eCmd==DEL_DELROWS)
+ {
+ nUndoStartX = 0;
+ nUndoEndX = MAXCOL;
+ }
+ if (eCmd==DEL_DELCOLS)
+ {
+ nUndoStartY = 0;
+ nUndoEndY = MAXROW;
+ }
+ // Test Zellschutz
+
+ SCCOL nEditTestEndX = nUndoEndX;
+ if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
+ nEditTestEndX = MAXCOL;
+ SCROW nEditTestEndY = nUndoEndY;
+ if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
+ nEditTestEndY = MAXROW;
+ ScEditableTester aTester( pDoc, nUndoStartX, nUndoStartY, nEditTestEndX, nEditTestEndY, aMark );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ // Test zusammengefasste
+
+ SCCOL nMergeTestEndX = (eCmd==DEL_CELLSLEFT) ? MAXCOL : nUndoEndX;
+ SCROW nMergeTestEndY = (eCmd==DEL_CELLSUP) ? MAXROW : nUndoEndY;
+ SCCOL nExtendStartCol = nUndoStartX;
+ SCROW nExtendStartRow = nUndoStartY;
+ BOOL bNeedRefresh = FALSE;
+
+ //Issue 8302 want to be able to insert into the middle of merged cells
+ //the patch comes from maoyg
+ ::std::vector<ScRange> qDecreaseRange;
+ BOOL bDeletingMerge = FALSE;
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_DELETECELLS );
+ if (bRecord)
+ rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect(i) )
+ {
+ if ( pDoc->HasAttrib( nUndoStartX, nUndoStartY, i, nMergeTestEndX, nMergeTestEndY, i, HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ {
+ SCCOL nMergeStartX = nUndoStartX;
+ SCROW nMergeStartY = nUndoStartY;
+ SCCOL nMergeEndX = nMergeTestEndX;
+ SCROW nMergeEndY = nMergeTestEndY;
+
+ pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
+ pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, i );
+ if( ( eCmd == DEL_CELLSUP && ( nMergeStartX != nUndoStartX || nMergeEndX != nMergeTestEndX))||
+ ( eCmd == DEL_CELLSLEFT && ( nMergeStartY != nUndoStartY || nMergeEndY != nMergeTestEndY)))
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
+ rDocShell.GetUndoManager()->LeaveListAction();
+ return FALSE;
+ }
+
+ nExtendStartCol = nMergeStartX;
+ nExtendStartRow = nMergeStartY;
+ SCCOL nTestCol = -1;
+ SCROW nTestRow1 = -1;
+ SCROW nTestRow2 = -1;
+
+ ScDocAttrIterator aTestIter( pDoc, i, nUndoStartX, nUndoStartY, nMergeTestEndX, nMergeTestEndY );
+ ScRange aExtendRange( nUndoStartX, nUndoStartY, i, nMergeTestEndX, nMergeTestEndY, i );
+ const ScPatternAttr* pPattern = NULL;
+ const ScMergeAttr* pMergeFlag = NULL;
+ const ScMergeFlagAttr* pMergeFlagAttr = NULL;
+ while ( ( pPattern = aTestIter.GetNext( nTestCol, nTestRow1, nTestRow2 ) ) != NULL )
+ {
+ pMergeFlag = (const ScMergeAttr*) &pPattern->GetItem( ATTR_MERGE );
+ pMergeFlagAttr = (const ScMergeFlagAttr*) &pPattern->GetItem( ATTR_MERGE_FLAG );
+ INT16 nNewFlags = pMergeFlagAttr->GetValue() & ( SC_MF_HOR | SC_MF_VER );
+ if( ( pMergeFlag && pMergeFlag->IsMerged() ) || nNewFlags == SC_MF_HOR || nNewFlags == SC_MF_VER )
+ {
+ ScRange aRange( nTestCol, nTestRow1, i );
+ pDoc->ExtendOverlapped( aRange );
+ pDoc->ExtendMerge( aRange, TRUE, TRUE );
+
+ if( nTestRow1 < nTestRow2 && nNewFlags == SC_MF_HOR )
+ {
+ for( SCROW nTestRow = nTestRow1; nTestRow <= nTestRow2; nTestRow++ )
+ {
+ ScRange aTestRange( nTestCol, nTestRow, i );
+ pDoc->ExtendOverlapped( aTestRange );
+ pDoc->ExtendMerge( aTestRange, TRUE, TRUE);
+ ScRange aMergeRange( aTestRange.aStart.Col(),aTestRange.aStart.Row(), i );
+ if( !aExtendRange.In( aMergeRange ) )
+ {
+ qDecreaseRange.push_back( aTestRange );
+ bDeletingMerge = TRUE;
+ }
+ }
+ }
+ else
+ {
+ ScRange aMergeRange( aRange.aStart.Col(),aRange.aStart.Row(), i );
+ if( !aExtendRange.In( aMergeRange ) )
+ {
+ qDecreaseRange.push_back( aRange );
+ }
+ bDeletingMerge = TRUE;
+ }
+ }
+ }
+
+ if( bDeletingMerge )
+ {
+
+ if( eCmd == DEL_DELROWS || eCmd == DEL_CELLSUP )
+ {
+ nStartRow = aExtendMergeRange.aStart.Row();
+ nEndRow = aExtendMergeRange.aEnd.Row();
+ bNeedRefresh = TRUE;
+
+ if( eCmd == DEL_CELLSUP )
+ {
+ nEndCol = aExtendMergeRange.aEnd.Col();
+ }
+ else
+ {
+ nStartCol = 0;
+ nEndCol = MAXCOL;
+ }
+ }
+ else if( eCmd == DEL_CELLSLEFT || eCmd == DEL_DELCOLS )
+ {
+
+ nStartCol = aExtendMergeRange.aStart.Col();
+ nEndCol = aExtendMergeRange.aEnd.Col();
+ if( eCmd == DEL_CELLSLEFT )
+ {
+ nEndRow = aExtendMergeRange.aEnd.Row();
+ bNeedRefresh = TRUE;
+ }
+ else
+ {
+ nStartRow = 0;
+ nEndRow = MAXROW;
+ }
+ }
+
+ if( !qDecreaseRange.empty() )
+ {
+ for( ::std::vector<ScRange>::const_iterator iIter( qDecreaseRange.begin()); iIter != qDecreaseRange.end(); iIter++ )
+ {
+ ScRange aRange( *iIter );
+ if( pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
+ {
+ UnmergeCells( aRange, TRUE, TRUE );
+ }
+ }
+ }
+ }
+ else
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_DELETECELLS_0);
+ rDocShell.GetUndoManager()->LeaveListAction();
+ return FALSE;
+ }
+ }
+ }
+ }
+
+ //
+ // ausfuehren
+ //
+
+ WaitObject aWait( rDocShell.GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRefUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ if ( bRecord )
+ {
+ // With the fix for #101329#, UpdateRef always puts cells into pRefUndoDoc at their old position,
+ // so it's no longer necessary to copy more than the deleted range into pUndoDoc.
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, 0, nTabCount-1, (eCmd==DEL_DELCOLS), (eCmd==DEL_DELROWS) );
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ {
+ SCTAB nScenarioCount = 0;
+
+ for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ nScenarioCount ++;
+
+ pDoc->CopyToDocument( nUndoStartX, nUndoStartY, i, nUndoEndX, nUndoEndY, i+nScenarioCount,
+ IDF_ALL | IDF_NOCAPTIONS, FALSE, pUndoDoc );
+ }
+ }
+
+ pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, FALSE, FALSE );
+
+ pUndoData = new ScRefUndoData( pDoc );
+
+ pDoc->BeginDrawUndo();
+ }
+
+ USHORT nExtFlags = 0;
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ rDocShell.UpdatePaintExt( nExtFlags, nStartCol, nStartRow, i, nEndCol, nEndRow, i );
+ }
+
+ BOOL bUndoOutline = FALSE;
+ switch (eCmd)
+ {
+ case DEL_CELLSUP:
+ pDoc->DeleteRow( nStartCol, 0, nEndCol, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, NULL, &aFullMark );
+ nPaintEndY = MAXROW;
+ break;
+ case DEL_DELROWS:
+ pDoc->DeleteRow( 0, 0, MAXCOL, MAXTAB, nStartRow, static_cast<SCSIZE>(nEndRow-nStartRow+1), pRefUndoDoc, &bUndoOutline, &aFullMark );
+ nPaintStartX = 0;
+ nPaintEndX = MAXCOL;
+ nPaintEndY = MAXROW;
+ nPaintFlags |= PAINT_LEFT;
+ break;
+ case DEL_CELLSLEFT:
+ pDoc->DeleteCol( nStartRow, 0, nEndRow, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, NULL, &aFullMark );
+ nPaintEndX = MAXCOL;
+ break;
+ case DEL_DELCOLS:
+ pDoc->DeleteCol( 0, 0, MAXROW, MAXTAB, nStartCol, static_cast<SCSIZE>(nEndCol-nStartCol+1), pRefUndoDoc, &bUndoOutline, &aFullMark );
+ nPaintStartY = 0;
+ nPaintEndY = MAXROW;
+ nPaintEndX = MAXCOL;
+ nPaintFlags |= PAINT_TOP;
+ break;
+ default:
+ DBG_ERROR("Falscher Code beim Loeschen");
+ break;
+ }
+
+ //! Test, ob Outline in Groesse geaendert
+
+ if ( bRecord )
+ {
+ for( i=0; i<nTabCount; i++ )
+ if( aFullMark.GetTableSelect( i ) )
+ pRefUndoDoc->DeleteAreaTab(nUndoStartX,nUndoStartY,nUndoEndX,nUndoEndY, i, IDF_ALL);
+
+ // alle Tabellen anlegen, damit Formeln kopiert werden koennen:
+ pUndoDoc->AddUndoTab( 0, nTabCount-1, FALSE, FALSE );
+
+ // kopieren mit bColRowFlags=FALSE (#54194#)
+ pRefUndoDoc->CopyToDocument(0,0,0,MAXCOL,MAXROW,MAXTAB,IDF_FORMULA,FALSE,pUndoDoc,NULL,FALSE);
+ delete pRefUndoDoc;
+
+ SCTAB* pTabs = new SCTAB[nSelCount];
+ SCTAB* pScenarios = new SCTAB[nSelCount];
+ SCTAB nUndoPos = 0;
+
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ {
+ SCTAB nCount = 0;
+ for( SCTAB j=i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ nCount ++;
+
+ pScenarios[nUndoPos] = nCount;
+ pTabs[nUndoPos] = i;
+ nUndoPos ++;
+ }
+ }
+
+ if( !bDeletingMerge )
+ {
+ rDocShell.GetUndoManager()->LeaveListAction();
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoDeleteCells(
+ &rDocShell, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ),nUndoPos, pTabs, pScenarios,
+ eCmd, pUndoDoc, pUndoData ) );
+ }
+
+ // #i8302 want to be able to insert into the middle of merged cells
+ // the patch comes from maoyg
+
+ while( !qDecreaseRange.empty() )
+ {
+ ScRange aRange = qDecreaseRange.back();
+
+ long nDecreaseRowCount = 0;
+ long nDecreaseColCount = 0;
+ if( eCmd == DEL_CELLSUP || eCmd == DEL_DELROWS )
+ {
+ if( nStartRow >= aRange.aStart.Row() && nStartRow <= aRange.aEnd.Row() && nEndRow>= aRange.aStart.Row() && nEndRow <= aRange.aEnd.Row() )
+ nDecreaseRowCount = nEndRow-nStartRow+1;
+ else if( nStartRow >= aRange.aStart.Row() && nStartRow <= aRange.aEnd.Row() && nEndRow >= aRange.aStart.Row() && nEndRow >= aRange.aEnd.Row() )
+ nDecreaseRowCount = aRange.aEnd.Row()-nStartRow+1;
+ else if( nStartRow >= aRange.aStart.Row() && nStartRow >= aRange.aEnd.Row() && nEndRow>= aRange.aStart.Row() && nEndRow <= aRange.aEnd.Row() )
+ nDecreaseRowCount = aRange.aEnd.Row()-nEndRow+1;
+ }
+ else if( eCmd == DEL_CELLSLEFT || eCmd == DEL_DELCOLS )
+ {
+ if( nStartCol >= aRange.aStart.Col() && nStartCol <= aRange.aEnd.Col() && nEndCol>= aRange.aStart.Col() && nEndCol <= aRange.aEnd.Col() )
+ nDecreaseColCount = nEndCol-nStartCol+1;
+ else if( nStartCol >= aRange.aStart.Col() && nStartCol <= aRange.aEnd.Col() && nEndCol >= aRange.aStart.Col() && nEndCol >= aRange.aEnd.Col() )
+ nDecreaseColCount = aRange.aEnd.Col()-nStartCol+1;
+ else if( nStartCol >= aRange.aStart.Col() && nStartCol >= aRange.aEnd.Col() && nEndCol>= aRange.aStart.Col() && nEndCol <= aRange.aEnd.Col() )
+ nDecreaseColCount = aRange.aEnd.Col()-nEndCol+1;
+ }
+
+ switch (eCmd)
+ {
+ case DEL_CELLSUP:
+ case DEL_DELROWS:
+ aRange.aEnd.SetRow(static_cast<SCsCOL>( aRange.aEnd.Row()-nDecreaseRowCount));
+ break;
+ case DEL_CELLSLEFT:
+ case DEL_DELCOLS:
+ aRange.aEnd.SetCol(static_cast<SCsCOL>( aRange.aEnd.Col()-nDecreaseColCount));
+ break;
+ default:
+ break;
+ }
+
+ if( !pDoc->HasAttrib( aRange, HASATTR_OVERLAPPED | HASATTR_MERGED ) )
+ {
+ ScCellMergeOption aMergeOption(aRange);
+ MergeCells( aMergeOption, FALSE, TRUE, TRUE );
+ }
+ qDecreaseRange.pop_back();
+ }
+
+ if( bDeletingMerge )
+ rDocShell.GetUndoManager()->LeaveListAction();
+
+ if ( bNeedRefresh )
+ {
+ // #i51445# old merge flag attributes must be deleted also for single cells,
+ // not only for whole columns/rows
+
+ if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
+ nMergeTestEndX = MAXCOL;
+ if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
+ nMergeTestEndY = MAXROW;
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( ScMergeFlagAttr() );
+
+ pDoc->ApplyPatternArea( nExtendStartCol, nExtendStartRow, nMergeTestEndX, nMergeTestEndY, aMark, aPattern );
+
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ {
+ SCTAB nScenarioCount = 0;
+
+ for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ nScenarioCount ++;
+
+ ScRange aMergedRange( nExtendStartCol, nExtendStartRow, i, nMergeTestEndX, nMergeTestEndY, i+nScenarioCount );
+ pDoc->ExtendMerge( aMergedRange, TRUE );
+ }
+ }
+ }
+
+ for( i=0; i<nTabCount; i++ )
+ {
+ if( aMark.GetTableSelect( i ) )
+ {
+ if ( eCmd == DEL_DELCOLS || eCmd == DEL_DELROWS )
+ pDoc->UpdatePageBreaks( i );
+
+ rDocShell.UpdatePaintExt( nExtFlags, nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i );
+
+ SCTAB nScenarioCount = 0;
+
+ for( SCTAB j = i+1; j<nTabCount && pDoc->IsScenario(j); j++ )
+ nScenarioCount ++;
+
+ // ganze Zeilen loeschen: nichts anpassen
+ if ( eCmd == DEL_DELROWS || !AdjustRowHeight(ScRange( 0, nPaintStartY, i, MAXCOL, nPaintEndY, i+nScenarioCount )) )
+ rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, nPaintFlags, nExtFlags );
+ else
+ {
+ // paint only what is not done by AdjustRowHeight
+ if (nExtFlags & SC_PF_LINES)
+ lcl_PaintAbove( rDocShell, ScRange( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount) );
+ if (nPaintFlags & PAINT_TOP)
+ rDocShell.PostPaint( nPaintStartX, nPaintStartY, i, nPaintEndX, nPaintEndY, i+nScenarioCount, PAINT_TOP );
+ }
+ }
+ }
+ aModificator.SetDocumentModified();
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
+ BOOL bCut, BOOL bRecord, BOOL bPaint, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ SCCOL nStartCol = rSource.aStart.Col();
+ SCROW nStartRow = rSource.aStart.Row();
+ SCTAB nStartTab = rSource.aStart.Tab();
+ SCCOL nEndCol = rSource.aEnd.Col();
+ SCROW nEndRow = rSource.aEnd.Row();
+ SCTAB nEndTab = rSource.aEnd.Tab();
+ SCCOL nDestCol = rDestPos.Col();
+ SCROW nDestRow = rDestPos.Row();
+ SCTAB nDestTab = rDestPos.Tab();
+
+ if ( !ValidRow(nStartRow) || !ValidRow(nEndRow) || !ValidRow(nDestRow) )
+ {
+ DBG_ERROR("invalid row in MoveBlock");
+ return FALSE;
+ }
+
+ // zugehoerige Szenarien auch anpassen - nur wenn innerhalb einer Tabelle verschoben wird!
+ BOOL bScenariosAdded = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if ( nDestTab == nStartTab && !pDoc->IsScenario(nEndTab) )
+ while ( nEndTab+1 < nTabCount && pDoc->IsScenario(nEndTab+1) )
+ {
+ ++nEndTab;
+ bScenariosAdded = TRUE;
+ }
+
+ SCTAB nSrcTabCount = nEndTab-nStartTab+1;
+ SCTAB nDestEndTab = nDestTab+nSrcTabCount-1;
+ SCTAB nTab;
+
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+
+ ScMarkData aSourceMark;
+ for (nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aSourceMark.SelectTable( nTab, TRUE ); // Source selektieren
+ aSourceMark.SetMarkArea( rSource );
+
+ ScDocShellRef aDragShellRef;
+ if ( pDoc->HasOLEObjectsInArea( rSource ) )
+ {
+ aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately
+ aDragShellRef->DoInitNew(NULL);
+ }
+ ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
+
+ ScClipParam aClipParam(ScRange(nStartCol, nStartRow, 0, nEndCol, nEndRow, 0), bCut);
+ pDoc->CopyToClip(aClipParam, pClipDoc, &aSourceMark, false, bScenariosAdded, true);
+
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ SCCOL nOldEndCol = nEndCol;
+ SCROW nOldEndRow = nEndRow;
+ BOOL bClipOver = FALSE;
+ for (nTab=nStartTab; nTab<=nEndTab; nTab++)
+ {
+ SCCOL nTmpEndCol = nOldEndCol;
+ SCROW nTmpEndRow = nOldEndRow;
+ if (pDoc->ExtendMerge( nStartCol, nStartRow, nTmpEndCol, nTmpEndRow, nTab ))
+ bClipOver = TRUE;
+ if ( nTmpEndCol > nEndCol ) nEndCol = nTmpEndCol;
+ if ( nTmpEndRow > nEndRow ) nEndRow = nTmpEndRow;
+ }
+
+ SCCOL nDestEndCol = nDestCol + ( nOldEndCol-nStartCol );
+ SCROW nDestEndRow = nDestRow + ( nOldEndRow-nStartRow );
+
+ SCCOL nUndoEndCol = nDestCol + ( nEndCol-nStartCol ); // erweitert im Zielblock
+ SCROW nUndoEndRow = nDestRow + ( nEndRow-nStartRow );
+
+ BOOL bIncludeFiltered = bCut;
+ if ( !bIncludeFiltered )
+ {
+ // adjust sizes to include only non-filtered rows
+
+ SCCOL nClipX;
+ SCROW nClipY;
+ pClipDoc->GetClipArea( nClipX, nClipY, FALSE );
+ SCROW nUndoAdd = nUndoEndRow - nDestEndRow;
+ nDestEndRow = nDestRow + nClipY;
+ nUndoEndRow = nDestEndRow + nUndoAdd;
+ }
+
+ if (!ValidCol(nUndoEndCol) || !ValidRow(nUndoEndRow))
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PASTE_FULL);
+ delete pClipDoc;
+ return FALSE;
+ }
+
+ // Test auf Zellschutz
+
+ ScEditableTester aTester;
+ for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
+ aTester.TestBlock( pDoc, nTab, nDestCol,nDestRow, nUndoEndCol,nUndoEndRow );
+ if (bCut)
+ for (nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aTester.TestBlock( pDoc, nTab, nStartCol,nStartRow, nEndCol,nEndRow );
+
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ delete pClipDoc;
+ return FALSE;
+ }
+
+ // Test auf zusammengefasste - beim Verschieben erst nach dem Loeschen
+
+ if (bClipOver && !bCut)
+ if (pDoc->HasAttrib( nDestCol,nDestRow,nDestTab, nUndoEndCol,nUndoEndRow,nDestEndTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ { // "Zusammenfassen nicht verschachteln !"
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
+ delete pClipDoc;
+ return FALSE;
+ }
+
+ // Are there borders in the cells? (for painting)
+
+ USHORT nSourceExt = 0;
+ rDocShell.UpdatePaintExt( nSourceExt, nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab );
+ USHORT nDestExt = 0;
+ rDocShell.UpdatePaintExt( nDestExt, nDestCol,nDestRow,nDestTab, nDestEndCol,nDestEndRow,nDestEndTab );
+
+ //
+ // ausfuehren
+ //
+
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRefUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ if (bRecord)
+ {
+ BOOL bWholeCols = ( nStartRow == 0 && nEndRow == MAXROW );
+ BOOL bWholeRows = ( nStartCol == 0 && nEndCol == MAXCOL );
+ USHORT nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab, bWholeCols, bWholeRows );
+
+ if (bCut)
+ {
+ pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
+ nUndoFlags, FALSE, pUndoDoc );
+ pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, FALSE, FALSE );
+ }
+
+ if ( nDestTab != nStartTab )
+ pUndoDoc->AddUndoTab( nDestTab, nDestEndTab, bWholeCols, bWholeRows );
+ pDoc->CopyToDocument( nDestCol, nDestRow, nDestTab,
+ nDestEndCol, nDestEndRow, nDestEndTab,
+ nUndoFlags, FALSE, pUndoDoc );
+
+ pUndoData = new ScRefUndoData( pDoc );
+
+ pDoc->BeginDrawUndo();
+ }
+
+ BOOL bSourceHeight = FALSE; // Hoehen angepasst?
+ if (bCut)
+ {
+ ScMarkData aDelMark; // only for tables
+ for (nTab=nStartTab; nTab<=nEndTab; nTab++)
+ {
+ pDoc->DeleteAreaTab( nStartCol,nStartRow, nOldEndCol,nOldEndRow, nTab, IDF_ALL );
+ aDelMark.SelectTable( nTab, TRUE );
+ }
+ pDoc->DeleteObjectsInArea( nStartCol,nStartRow, nOldEndCol,nOldEndRow, aDelMark );
+
+ // Test auf zusammengefasste
+
+ if (bClipOver)
+ if (pDoc->HasAttrib( nDestCol,nDestRow,nDestTab,
+ nUndoEndCol,nUndoEndRow,nDestEndTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ {
+ pDoc->CopyFromClip( rSource, aSourceMark, IDF_ALL, pRefUndoDoc, pClipDoc );
+ for (nTab=nStartTab; nTab<=nEndTab; nTab++)
+ {
+ SCCOL nTmpEndCol = nEndCol;
+ SCROW nTmpEndRow = nEndRow;
+ pDoc->ExtendMerge( nStartCol, nStartRow, nTmpEndCol, nTmpEndRow, nTab, TRUE );
+ }
+
+ // Fehlermeldung erst nach dem Wiederherstellen des Inhalts
+ if (!bApi) // "Zusammenfassen nicht verschachteln !"
+ rDocShell.ErrorMessage(STR_MSSG_MOVEBLOCKTO_0);
+
+ delete pUndoDoc;
+ delete pRefUndoDoc;
+ delete pUndoData;
+ delete pClipDoc;
+ return FALSE;
+ }
+
+ bSourceHeight = AdjustRowHeight( rSource, FALSE );
+ }
+
+ ScRange aPasteDest( nDestCol, nDestRow, nDestTab, nDestEndCol, nDestEndRow, nDestEndTab );
+
+ ScMarkData aDestMark;
+ for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
+ aDestMark.SelectTable( nTab, TRUE ); // Destination selektieren
+ aDestMark.SetMarkArea( aPasteDest );
+
+ /* Do not copy cell notes and drawing objects here. While pasting, the
+ function ScDocument::UpdateReference() is called which calls
+ ScDrawLayer::MoveCells() which may move away inserted objects to wrong
+ positions (e.g. if source and destination range overlaps). Cell notes
+ and drawing objects are pasted below after doing all adjusting. */
+ pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_ALL & ~(IDF_NOTE | IDF_OBJECTS),
+ pRefUndoDoc, pClipDoc, TRUE, FALSE, bIncludeFiltered );
+
+ // skipped rows and merged cells don't mix
+ if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
+ UnmergeCells( aPasteDest, FALSE, TRUE );
+
+ VirtualDevice aVirtDev;
+ BOOL bDestHeight = AdjustRowHeight(
+ ScRange( 0,nDestRow,nDestTab, MAXCOL,nDestEndRow,nDestEndTab ),
+ FALSE );
+
+ /* Paste cell notes and drawing objects after adjusting formula references
+ and row heights. There are no cell notes or drawing objects, if the
+ clipdoc does not contain a drawing layer.
+ #i102056# Passing IDF_NOTE only would overwrite cell contents with
+ empty note cells, therefore the special modifier IDF_ADDNOTES is passed
+ here too which changes the behaviour of ScColumn::CopyFromClip() to not
+ touch existing cells. */
+ if ( pClipDoc->GetDrawLayer() )
+ pDoc->CopyFromClip( aPasteDest, aDestMark, IDF_NOTE | IDF_ADDNOTES | IDF_OBJECTS,
+ pRefUndoDoc, pClipDoc, TRUE, FALSE, bIncludeFiltered );
+
+ if (bRecord)
+ {
+ if (pRefUndoDoc)
+ {
+ // alle Tabellen anlegen, damit Formeln kopiert werden koennen:
+ pUndoDoc->AddUndoTab( 0, nTabCount-1, FALSE, FALSE );
+
+ pRefUndoDoc->DeleteArea( nDestCol, nDestRow, nDestEndCol, nDestEndRow, aSourceMark, IDF_ALL );
+ // kopieren mit bColRowFlags=FALSE (#54194#)
+ pRefUndoDoc->CopyToDocument( 0, 0, 0, MAXCOL, MAXROW, MAXTAB,
+ IDF_FORMULA, FALSE, pUndoDoc, NULL, FALSE );
+ delete pRefUndoDoc;
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDragDrop( &rDocShell, ScRange(
+ nStartCol, nStartRow, nStartTab,
+ nOldEndCol, nOldEndRow, nEndTab ),
+ ScAddress( nDestCol, nDestRow, nDestTab ),
+ bCut, pUndoDoc, pUndoData, bScenariosAdded ) );
+ }
+
+ SCCOL nDestPaintEndCol = nDestEndCol;
+ SCROW nDestPaintEndRow = nDestEndRow;
+ for (nTab=nDestTab; nTab<=nDestEndTab; nTab++)
+ {
+ SCCOL nTmpEndCol = nDestEndCol;
+ SCROW nTmpEndRow = nDestEndRow;
+ pDoc->ExtendMerge( nDestCol, nDestRow, nTmpEndCol, nTmpEndRow, nTab, TRUE );
+ if (nTmpEndCol > nDestPaintEndCol) nDestPaintEndCol = nTmpEndCol;
+ if (nTmpEndRow > nDestPaintEndRow) nDestPaintEndRow = nTmpEndRow;
+ }
+
+ if (bCut)
+ for (nTab=nStartTab; nTab<=nEndTab; nTab++)
+ pDoc->RefreshAutoFilter( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
+
+ if (bPaint)
+ {
+ // Zielbereich:
+
+ SCCOL nPaintStartX = nDestCol;
+ SCROW nPaintStartY = nDestRow;
+ SCCOL nPaintEndX = nDestPaintEndCol;
+ SCROW nPaintEndY = nDestPaintEndRow;
+ USHORT nFlags = PAINT_GRID;
+
+ if ( nStartRow==0 && nEndRow==MAXROW ) // Breiten mitkopiert?
+ {
+ nPaintEndX = MAXCOL;
+ nPaintStartY = 0;
+ nPaintEndY = MAXROW;
+ nFlags |= PAINT_TOP;
+ }
+ if ( bDestHeight || ( nStartCol == 0 && nEndCol == MAXCOL ) )
+ {
+ nPaintEndY = MAXROW;
+ nPaintStartX = 0;
+ nPaintEndX = MAXCOL;
+ nFlags |= PAINT_LEFT;
+ }
+ if ( bScenariosAdded )
+ {
+ nPaintStartX = 0;
+ nPaintStartY = 0;
+ nPaintEndX = MAXCOL;
+ nPaintEndY = MAXROW;
+ }
+
+ rDocShell.PostPaint( nPaintStartX,nPaintStartY,nDestTab,
+ nPaintEndX,nPaintEndY,nDestEndTab, nFlags, nSourceExt | nDestExt );
+
+ if ( bCut )
+ {
+ // Quellbereich:
+
+ nPaintStartX = nStartCol;
+ nPaintStartY = nStartRow;
+ nPaintEndX = nEndCol;
+ nPaintEndY = nEndRow;
+ nFlags = PAINT_GRID;
+
+ if ( bSourceHeight )
+ {
+ nPaintEndY = MAXROW;
+ nPaintStartX = 0;
+ nPaintEndX = MAXCOL;
+ nFlags |= PAINT_LEFT;
+ }
+ if ( bScenariosAdded )
+ {
+ nPaintStartX = 0;
+ nPaintStartY = 0;
+ nPaintEndX = MAXCOL;
+ nPaintEndY = MAXROW;
+ }
+
+ rDocShell.PostPaint( nPaintStartX,nPaintStartY,nStartTab,
+ nPaintEndX,nPaintEndY,nEndTab, nFlags, nSourceExt );
+ }
+ }
+
+ aModificator.SetDocumentModified();
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+
+ delete pClipDoc;
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, String& sCodeName )
+{
+ uno::Reference< lang::XMultiServiceFactory> xSF(rDocSh.GetModel(), uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess;
+ uno::Reference< uno::XInterface > xDocModuleApiObject;
+ if ( xSF.is() )
+ {
+ xVBACodeNamedObjectAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY );
+ xDocModuleApiObject.set( xVBACodeNamedObjectAccess->getByName( sCodeName ), uno::UNO_QUERY );
+ }
+ return xDocModuleApiObject;
+
+}
+
+script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule )
+{
+ script::ModuleInfo sModuleInfo;
+ sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
+ sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule );
+ return sModuleInfo;
+}
+
+void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sSource )
+{
+ SFX_APP()->EnterBasicCall();
+ SfxObjectShell& rDocSh = *rDoc.GetDocumentShell();
+ uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
+ DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
+
+ uno::Reference< container::XNameContainer > xLib;
+ if( xLibContainer.is() )
+ {
+ String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() )
+ aLibName = rDocSh.GetBasicManager()->GetName();
+ uno::Any aLibAny = xLibContainer->getByName( aLibName );
+ aLibAny >>= xLib;
+ }
+ if( xLib.is() )
+ {
+ // if the Module with codename exists then find a new name
+ sal_Int32 nNum = 0;
+ String genModuleName;
+ if ( sModuleName.Len() )
+ sModuleName = sModuleName;
+ else
+ {
+ genModuleName = String::CreateFromAscii( "Sheet1" );
+ nNum = 1;
+ }
+ while( xLib->hasByName( genModuleName ) )
+ genModuleName = rtl::OUString::createFromAscii( "Sheet" ) + rtl::OUString::valueOf( ++nNum );
+
+ uno::Any aSourceAny;
+ rtl::OUString sTmpSource = sSource;
+ if ( sTmpSource.getLength() == 0 )
+ sTmpSource = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" ));
+ aSourceAny <<= sTmpSource;
+ uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
+ if ( xVBAModuleInfo.is() )
+ {
+ String sCodeName( genModuleName );
+ rDoc.SetCodeName( nTab, sCodeName );
+ script::ModuleInfo sModuleInfo = lcl_InitModuleInfo( rDocSh, genModuleName );
+ xVBAModuleInfo->insertModuleInfo( genModuleName, sModuleInfo );
+ xLib->insertByName( genModuleName, aSourceAny );
+ }
+
+ }
+ SFX_APP()->LeaveBasicCall();
+}
+
+void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName )
+{
+ SFX_APP()->EnterBasicCall();
+ uno::Reference< script::XLibraryContainer > xLibContainer = rDocSh.GetBasicContainer();
+ DBG_ASSERT( xLibContainer.is(), "No BasicContainer!" );
+
+ uno::Reference< container::XNameContainer > xLib;
+ if( xLibContainer.is() )
+ {
+ String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ if ( rDocSh.GetBasicManager() && rDocSh.GetBasicManager()->GetName().Len() )
+ aLibName = rDocSh.GetBasicManager()->GetName();
+ uno::Any aLibAny = xLibContainer->getByName( aLibName );
+ aLibAny >>= xLib;
+ }
+ if( xLib.is() )
+ {
+ uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY );
+ if( xLib->hasByName( sModuleName ) )
+ xLib->removeByName( sModuleName );
+ if ( xVBAModuleInfo.is() )
+ xVBAModuleInfo->removeModuleInfo( sModuleName );
+
+ }
+ SFX_APP()->LeaveBasicCall();
+}
+
+
+BOOL ScDocFunc::InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi )
+{
+ BOOL bSuccess = FALSE;
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+
+ // Strange loop, also basic is loaded too early ( InsertTable )
+ // is called via the xml import for sheets in described in odf
+ BOOL bInsertDocModule = false;
+
+ if( !rDocShell.GetDocument()->IsImportingXML() )
+ {
+ bInsertDocModule = pDoc ? pDoc->IsInVBAMode() : false;
+ }
+ if ( bInsertDocModule || ( bRecord && !pDoc->IsUndoEnabled() ) )
+ bRecord = FALSE;
+
+ if (bRecord)
+ pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ BOOL bAppend = ( nTab >= nTabCount );
+ if ( bAppend )
+ nTab = nTabCount; // wichtig fuer Undo
+
+ if (pDoc->InsertTab( nTab, rName ))
+ {
+ String sCodeName;
+ if (bRecord)
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( &rDocShell, nTab, bAppend, rName));
+ // Views updaten:
+ // Only insert vba modules if vba mode ( and not currently importing XML )
+ if( bInsertDocModule )
+ {
+ String sSource;
+ VBA_InsertModule( *pDoc, nTab, sCodeName, sSource );
+ }
+ rDocShell.Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab ) );
+
+ rDocShell.PostPaintExtras();
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ bSuccess = TRUE;
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(STR_TABINSERT_ERROR);
+
+ return bSuccess;
+}
+
+BOOL ScDocFunc::DeleteTable( SCTAB nTab, BOOL bRecord, BOOL /* bApi */ )
+{
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : false;
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ if ( bVbaEnabled )
+ bRecord = FALSE;
+ BOOL bWasLinked = pDoc->IsLinked(nTab);
+ ScDocument* pUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nCount = pDoc->GetTableCount();
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE ); // nur nTab mit Flags
+ pUndoDoc->AddUndoTab( 0, nCount-1 ); // alle Tabs fuer Referenzen
+
+ pDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pUndoDoc );
+ String aOldName;
+ pDoc->GetName( nTab, aOldName );
+ pUndoDoc->RenameTab( nTab, aOldName, FALSE );
+ if (bWasLinked)
+ pUndoDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), pDoc->GetLinkDoc(nTab),
+ pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
+ pDoc->GetLinkTab(nTab),
+ pDoc->GetLinkRefreshDelay(nTab) );
+
+ if ( pDoc->IsScenario(nTab) )
+ {
+ pUndoDoc->SetScenario( nTab, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
+ pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
+ BOOL bActive = pDoc->IsActiveScenario( nTab );
+ pUndoDoc->SetActiveScenario( nTab, bActive );
+ }
+ pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) );
+ pUndoDoc->SetTabBgColor( nTab, pDoc->GetTabBgColor(nTab) );
+ pUndoDoc->SetSheetEvents( nTab, pDoc->GetSheetEvents( nTab ) );
+
+ // Drawing-Layer muss sein Undo selbst in der Hand behalten !!!
+ pDoc->BeginDrawUndo(); // DeleteTab erzeugt ein SdrUndoDelPage
+
+ pUndoData = new ScRefUndoData( pDoc );
+ }
+
+ String sCodeName;
+ BOOL bHasCodeName = pDoc->GetCodeName( nTab, sCodeName );
+ if (pDoc->DeleteTab( nTab, pUndoDoc ))
+ {
+ if (bRecord)
+ {
+ SvShorts theTabs;
+ theTabs.Insert(nTab,theTabs.Count());
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDeleteTab( &rDocShell, theTabs, pUndoDoc, pUndoData ));
+ }
+ // Views updaten:
+ if( bVbaEnabled )
+ {
+ if( bHasCodeName )
+ {
+ VBA_DeleteModule( rDocShell, sCodeName );
+ }
+ }
+ rDocShell.Broadcast( ScTablesHint( SC_TAB_DELETED, nTab ) );
+
+ if (bWasLinked)
+ {
+ rDocShell.UpdateLinks(); // Link-Manager updaten
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate(SID_LINKS);
+ }
+
+ rDocShell.PostPaintExtras();
+ aModificator.SetDocumentModified();
+
+ SfxApplication* pSfxApp = SFX_APP(); // Navigator
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+
+ bSuccess = TRUE;
+ }
+ else
+ {
+ delete pUndoDoc;
+ delete pUndoData;
+ }
+ return bSuccess;
+}
+
+BOOL ScDocFunc::SetTableVisible( SCTAB nTab, BOOL bVisible, BOOL bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ if ( pDoc->IsVisible( nTab ) == bVisible )
+ return TRUE; // nichts zu tun - ok
+
+ if ( !pDoc->IsDocEditable() )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR);
+ return FALSE;
+ }
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ if ( !bVisible && !pDoc->IsImportingXML() ) // #i57869# allow hiding in any order for loading
+ {
+ // nicht alle Tabellen ausblenden
+
+ USHORT nVisCount = 0;
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nCount; i++)
+ if (pDoc->IsVisible(i))
+ ++nVisCount;
+
+ if (nVisCount <= 1)
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR); //! eigene Meldung?
+ return FALSE;
+ }
+ }
+
+ pDoc->SetVisible( nTab, bVisible );
+ if (bUndo)
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( &rDocShell, nTab, bVisible ) );
+
+ // Views updaten:
+ if (!bVisible)
+ rDocShell.Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ rDocShell.PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::SetLayoutRTL( SCTAB nTab, BOOL bRTL, BOOL /* bApi */ )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ if ( pDoc->IsLayoutRTL( nTab ) == bRTL )
+ return TRUE; // nothing to do - ok
+
+ //! protection (sheet or document?)
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ pDoc->SetLayoutRTL( nTab, bRTL );
+
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoLayoutRTL( &rDocShell, nTab, bRTL ) );
+ }
+
+ rDocShell.PostPaint( 0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_ALL );
+ aModificator.SetDocumentModified();
+
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_TAB_RTL );
+ pBindings->Invalidate( SID_ATTR_SIZE );
+ }
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ if ( !pDoc->IsDocEditable() )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR);
+ return FALSE;
+ }
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ String sOldName;
+ pDoc->GetName(nTab, sOldName);
+ if (pDoc->RenameTab( nTab, rName ))
+ {
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoRenameTab( &rDocShell, nTab, sOldName, rName));
+ }
+ rDocShell.PostPaintExtras();
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+
+ bSuccess = TRUE;
+ }
+ return bSuccess;
+}
+
+bool ScDocFunc::SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi )
+{
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = false;
+ if ( !pDoc->IsDocEditable() || pDoc->IsTabProtected(nTab) )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Check to see what this string is...
+ return false;
+ }
+
+ Color aOldTabBgColor;
+ aOldTabBgColor = pDoc->GetTabBgColor(nTab);
+
+ bool bSuccess = false;
+ pDoc->SetTabBgColor(nTab, rColor);
+ if ( pDoc->GetTabBgColor(nTab) == rColor)
+ bSuccess = true;
+ if (bSuccess)
+ {
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTabColor( &rDocShell, nTab, aOldTabBgColor, rColor));
+ }
+ rDocShell.PostPaintExtras();
+ ScDocShellModificator aModificator( rDocShell );
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+
+ bSuccess = true;
+ }
+ return bSuccess;
+}
+
+bool ScDocFunc::SetTabBgColor(
+ ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = false;
+
+ if ( !pDoc->IsDocEditable() )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error...
+ return false;
+ }
+
+ USHORT nTab;
+ Color aNewTabBgColor;
+ bool bSuccess = true;
+ size_t nTabProtectCount = 0;
+ size_t nTabListCount = rUndoTabColorList.size();
+ for ( size_t i = 0; i < nTabListCount; ++i )
+ {
+ ScUndoTabColorInfo& rInfo = rUndoTabColorList[i];
+ nTab = rInfo.mnTabId;
+ if ( !pDoc->IsTabProtected(nTab) )
+ {
+ aNewTabBgColor = rInfo.maNewTabBgColor;
+ rInfo.maOldTabBgColor = pDoc->GetTabBgColor(nTab);
+ pDoc->SetTabBgColor(nTab, aNewTabBgColor);
+ if ( pDoc->GetTabBgColor(nTab) != aNewTabBgColor)
+ {
+ bSuccess = false;
+ break;
+ }
+ }
+ else
+ {
+ nTabProtectCount++;
+ }
+ }
+
+ if ( nTabProtectCount == nTabListCount )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR); //TODO Get a better String Error...
+ return false;
+ }
+
+ if (bSuccess)
+ {
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTabColor( &rDocShell, rUndoTabColorList));
+ }
+ rDocShell.PostPaintExtras();
+ ScDocShellModificator aModificator( rDocShell );
+ aModificator.SetDocumentModified();
+ }
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+
+//! SetWidthOrHeight - noch doppelt zu ViewFunc !!!!!!
+//! Probleme:
+//! - Optimale Hoehe fuer Edit-Zellen ist unterschiedlich zwischen Drucker und Bildschirm
+//! - Optimale Breite braucht Selektion, um evtl. nur selektierte Zellen zu beruecksichtigen
+
+USHORT lcl_GetOptimalColWidth( ScDocShell& rDocShell, SCCOL nCol, SCTAB nTab, BOOL bFormula )
+{
+ USHORT nTwips = 0;
+
+ ScSizeDeviceProvider aProv(&rDocShell);
+ OutputDevice* pDev = aProv.GetDevice(); // has pixel MapMode
+ double nPPTX = aProv.GetPPTX();
+ double nPPTY = aProv.GetPPTY();
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ Fraction aOne(1,1);
+ nTwips = pDoc->GetOptimalColWidth( nCol, nTab, pDev, nPPTX, nPPTY, aOne, aOne,
+ bFormula, NULL );
+
+ return nTwips;
+}
+
+BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges, SCTAB nTab,
+ ScSizeMode eMode, USHORT nSizeTwips,
+ BOOL bRecord, BOOL bApi )
+{
+ if (!nRangeCnt)
+ return TRUE;
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if ( bRecord && !pDoc->IsUndoEnabled() )
+ bRecord = FALSE;
+
+ // import into read-only document is possible
+ if ( !pDoc->IsChangeReadOnlyEnabled() && !rDocShell.IsEditable() )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_PROTECTIONERR); //! eigene Meldung?
+ return FALSE;
+ }
+
+ BOOL bSuccess = FALSE;
+ SCCOLROW nStart = pRanges[0];
+ SCCOLROW nEnd = pRanges[2*nRangeCnt-1];
+
+ BOOL bFormula = FALSE;
+ if ( eMode == SC_SIZE_OPTIMAL )
+ {
+ //! Option "Formeln anzeigen" - woher nehmen?
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ SCCOLROW* pUndoRanges = NULL;
+
+ if ( bRecord )
+ {
+ pDoc->BeginDrawUndo(); // Drawing Updates
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ if (bWidth)
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, FALSE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab, static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+ else
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+ pDoc->CopyToDocument( 0, static_cast<SCROW>(nStart), nTab, MAXCOL, static_cast<SCROW>(nEnd), nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+
+ pUndoRanges = new SCCOLROW[ 2*nRangeCnt ];
+ memmove( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) );
+
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ pUndoTab = new ScOutlineTable( *pTable );
+ }
+
+ BOOL bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
+ BOOL bOutline = FALSE;
+
+ pDoc->IncSizeRecalcLevel( nTab ); // nicht fuer jede Spalte einzeln
+ for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nStartNo = *(pRanges++);
+ SCCOLROW nEndNo = *(pRanges++);
+
+ if ( !bWidth ) // Hoehen immer blockweise
+ {
+ if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
+ {
+ BOOL bAll = ( eMode==SC_SIZE_OPTIMAL );
+ if (!bAll)
+ {
+ // fuer alle eingeblendeten CR_MANUALSIZE loeschen,
+ // dann SetOptimalHeight mit bShrink = FALSE
+ for (SCROW nRow=nStartNo; nRow<=nEndNo; nRow++)
+ {
+ BYTE nOld = pDoc->GetRowFlags(nRow,nTab);
+ SCROW nLastRow = -1;
+ bool bHidden = pDoc->RowHidden(nRow, nTab, nLastRow);
+ if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
+ pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
+ }
+ }
+
+ ScSizeDeviceProvider aProv( &rDocShell );
+ Fraction aOne(1,1);
+ pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
+ aProv.GetPPTX(), aProv.GetPPTY(), aOne, aOne, bAll );
+
+ if (bAll)
+ pDoc->ShowRows( nStartNo, nEndNo, nTab, TRUE );
+
+ // Manual-Flag wird bei bAll=TRUE schon in SetOptimalHeight gesetzt
+ // (an bei Extra-Height, sonst aus).
+ }
+ else if ( eMode==SC_SIZE_DIRECT || eMode==SC_SIZE_ORIGINAL )
+ {
+ if (nSizeTwips)
+ {
+ pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
+ pDoc->SetManualHeight( nStartNo, nEndNo, nTab, TRUE ); // height was set manually
+ }
+ if ( eMode != SC_SIZE_ORIGINAL )
+ pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
+ }
+ else if ( eMode==SC_SIZE_SHOW )
+ {
+ pDoc->ShowRows( nStartNo, nEndNo, nTab, TRUE );
+ }
+ }
+ else // Spaltenbreiten
+ {
+ for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
+ {
+ SCCOL nLastCol = -1;
+ if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab, nLastCol) )
+ {
+ USHORT nThisSize = nSizeTwips;
+
+ if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
+ nThisSize = nSizeTwips +
+ lcl_GetOptimalColWidth( rDocShell, nCol, nTab, bFormula );
+ if ( nThisSize )
+ pDoc->SetColWidth( nCol, nTab, nThisSize );
+
+ if ( eMode != SC_SIZE_ORIGINAL )
+ pDoc->ShowCol( nCol, nTab, bShow );
+ }
+ }
+ }
+
+ // adjust outlines
+
+ if ( eMode != SC_SIZE_ORIGINAL )
+ {
+ if (bWidth)
+ bOutline = bOutline || pDoc->UpdateOutlineCol(
+ static_cast<SCCOL>(nStartNo),
+ static_cast<SCCOL>(nEndNo), nTab, bShow );
+ else
+ bOutline = bOutline || pDoc->UpdateOutlineRow(
+ static_cast<SCROW>(nStartNo),
+ static_cast<SCROW>(nEndNo), nTab, bShow );
+ }
+ }
+ pDoc->DecSizeRecalcLevel( nTab ); // nicht fuer jede Spalte einzeln
+
+ if (!bOutline)
+ DELETEZ(pUndoTab);
+
+ if (bRecord)
+ {
+ ScMarkData aMark;
+ aMark.SelectOneTable( nTab );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoWidthOrHeight( &rDocShell, aMark,
+ nStart, nTab, nEnd, nTab,
+ pUndoDoc, nRangeCnt, pUndoRanges,
+ pUndoTab, eMode, nSizeTwips, bWidth ) );
+ }
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ rDocShell.PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_ALL);
+
+ return bSuccess;
+}
+
+
+BOOL ScDocFunc::InsertPageBreak( BOOL bColumn, const ScAddress& rPos,
+ BOOL bRecord, BOOL bSetModified, BOOL /* bApi */ )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ SCTAB nTab = rPos.Tab();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+
+ SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(rPos.Col()) :
+ static_cast<SCCOLROW>(rPos.Row());
+ if (nPos == 0)
+ return FALSE; // erste Spalte / Zeile
+
+ ScBreakType nBreak = bColumn ?
+ pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab) :
+ pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
+ if (nBreak & BREAK_MANUAL)
+ return true;
+
+ if (bRecord)
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, TRUE ) );
+
+ if (bColumn)
+ pDoc->SetColBreak(static_cast<SCCOL>(nPos), nTab, false, true);
+ else
+ pDoc->SetRowBreak(static_cast<SCROW>(nPos), nTab, false, true);
+
+ pDoc->InvalidatePageBreaks(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ if (bColumn)
+ {
+ rDocShell.PostPaint( static_cast<SCCOL>(nPos)-1, 0, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_INS_COLBRK );
+ pBindings->Invalidate( FID_DEL_COLBRK );
+ }
+ }
+ else
+ {
+ rDocShell.PostPaint( 0, static_cast<SCROW>(nPos)-1, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_INS_ROWBRK );
+ pBindings->Invalidate( FID_DEL_ROWBRK );
+ }
+ }
+ if (pBindings)
+ pBindings->Invalidate( FID_DEL_MANUALBREAKS );
+
+ if (bSetModified)
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::RemovePageBreak( BOOL bColumn, const ScAddress& rPos,
+ BOOL bRecord, BOOL bSetModified, BOOL /* bApi */ )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ SCTAB nTab = rPos.Tab();
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+
+ SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(rPos.Col()) :
+ static_cast<SCCOLROW>(rPos.Row());
+
+ ScBreakType nBreak;
+ if (bColumn)
+ nBreak = pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab);
+ else
+ nBreak = pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
+ if ((nBreak & BREAK_MANUAL) == 0)
+ // There is no manual break.
+ return false;
+
+ if (bRecord)
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, FALSE ) );
+
+ if (bColumn)
+ pDoc->RemoveColBreak(static_cast<SCCOL>(nPos), nTab, false, true);
+ else
+ pDoc->RemoveRowBreak(static_cast<SCROW>(nPos), nTab, false, true);
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ if (bColumn)
+ {
+ rDocShell.PostPaint( static_cast<SCCOL>(nPos)-1, 0, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_INS_COLBRK );
+ pBindings->Invalidate( FID_DEL_COLBRK );
+ }
+ }
+ else
+ {
+ rDocShell.PostPaint( 0, nPos-1, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID );
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_INS_ROWBRK );
+ pBindings->Invalidate( FID_DEL_ROWBRK );
+ }
+ }
+ if (pBindings)
+ pBindings->Invalidate( FID_DEL_MANUALBREAKS );
+
+ if (bSetModified)
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+void ScDocFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ pDoc->SetTabProtection(nTab, &rProtect);
+ if (pDoc->IsUndoEnabled())
+ {
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ DBG_ASSERT(pProtect, "ScDocFunc::Unprotect: ScTableProtection pointer is NULL!");
+ if (pProtect)
+ {
+ ::std::auto_ptr<ScTableProtection> p(new ScTableProtection(*pProtect));
+ p->setProtected(true); // just in case ...
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTabProtect(&rDocShell, nTab, p) );
+
+ // ownership of auto_ptr now transferred to ScUndoTabProtect.
+ }
+ }
+
+ rDocShell.PostPaintGridAll();
+ ScDocShellModificator aModificator(rDocShell);
+ aModificator.SetDocumentModified();
+}
+
+BOOL ScDocFunc::Protect( SCTAB nTab, const String& rPassword, BOOL /*bApi*/ )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (nTab == TABLEID_DOC)
+ {
+ // document protection
+ ScDocProtection aProtection;
+ aProtection.setProtected(true);
+ aProtection.setPassword(rPassword);
+ pDoc->SetDocProtection(&aProtection);
+ if (pDoc->IsUndoEnabled())
+ {
+ ScDocProtection* pProtect = pDoc->GetDocProtection();
+ DBG_ASSERT(pProtect, "ScDocFunc::Unprotect: ScDocProtection pointer is NULL!");
+ if (pProtect)
+ {
+ ::std::auto_ptr<ScDocProtection> p(new ScDocProtection(*pProtect));
+ p->setProtected(true); // just in case ...
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDocProtect(&rDocShell, p) );
+ // ownership of auto_ptr is transferred to ScUndoDocProtect.
+ }
+ }
+ }
+ else
+ {
+ // sheet protection
+
+ ScTableProtection aProtection;
+ aProtection.setProtected(true);
+ aProtection.setPassword(rPassword);
+ pDoc->SetTabProtection(nTab, &aProtection);
+ if (pDoc->IsUndoEnabled())
+ {
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ DBG_ASSERT(pProtect, "ScDocFunc::Unprotect: ScTableProtection pointer is NULL!");
+ if (pProtect)
+ {
+ ::std::auto_ptr<ScTableProtection> p(new ScTableProtection(*pProtect));
+ p->setProtected(true); // just in case ...
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTabProtect(&rDocShell, nTab, p) );
+ // ownership of auto_ptr now transferred to ScUndoTabProtect.
+ }
+ }
+ }
+
+ rDocShell.PostPaintGridAll();
+ ScDocShellModificator aModificator( rDocShell );
+ aModificator.SetDocumentModified();
+
+ return true;
+}
+
+BOOL ScDocFunc::Unprotect( SCTAB nTab, const String& rPassword, BOOL bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (nTab == TABLEID_DOC)
+ {
+ // document protection
+
+ ScDocProtection* pDocProtect = pDoc->GetDocProtection();
+ if (!pDocProtect || !pDocProtect->isProtected())
+ // already unprotected (should not happen)!
+ return true;
+
+ // save the protection state before unprotect (for undo).
+ ::std::auto_ptr<ScDocProtection> pProtectCopy(new ScDocProtection(*pDocProtect));
+
+ if (!pDocProtect->verifyPassword(rPassword))
+ {
+ if (!bApi)
+ {
+ InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
+ aBox.Execute();
+ }
+ return false;
+ }
+
+ pDoc->SetDocProtection(NULL);
+ if (pDoc->IsUndoEnabled())
+ {
+ pProtectCopy->setProtected(false);
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDocProtect(&rDocShell, pProtectCopy) );
+ // ownership of auto_ptr now transferred to ScUndoDocProtect.
+ }
+ }
+ else
+ {
+ // sheet protection
+
+ ScTableProtection* pTabProtect = pDoc->GetTabProtection(nTab);
+ if (!pTabProtect || !pTabProtect->isProtected())
+ // already unprotected (should not happen)!
+ return true;
+
+ // save the protection state before unprotect (for undo).
+ ::std::auto_ptr<ScTableProtection> pProtectCopy(new ScTableProtection(*pTabProtect));
+ if (!pTabProtect->verifyPassword(rPassword))
+ {
+ if (!bApi)
+ {
+ InfoBox aBox( rDocShell.GetActiveDialogParent(), String( ScResId( SCSTR_WRONGPASSWORD ) ) );
+ aBox.Execute();
+ }
+ return false;
+ }
+
+ pDoc->SetTabProtection(nTab, NULL);
+ if (pDoc->IsUndoEnabled())
+ {
+ pProtectCopy->setProtected(false);
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTabProtect(&rDocShell, nTab, pProtectCopy) );
+ // ownership of auto_ptr now transferred to ScUndoTabProtect.
+ }
+ }
+
+ rDocShell.PostPaintGridAll();
+ ScDocShellModificator aModificator( rDocShell );
+ aModificator.SetDocumentModified();
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::ClearItems( const ScMarkData& rMark, const USHORT* pWhich, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ ScEditableTester aTester( pDoc, rMark );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ // #i12940# ClearItems is called (from setPropertyToDefault) directly with uno object's cached
+ // MarkData (GetMarkData), so rMark must be changed to multi selection for ClearSelectionItems
+ // here.
+
+ ScRange aMarkRange;
+ ScMarkData aMultiMark = rMark;
+ aMultiMark.SetMarking(FALSE); // for MarkToMulti
+ aMultiMark.MarkToMulti();
+ aMultiMark.GetMultiMarkArea( aMarkRange );
+
+// if (bRecord)
+ if (bUndo)
+ {
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCTAB nEndTab = aMarkRange.aEnd.Tab();
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
+ pDoc->CopyToDocument( aMarkRange, IDF_ATTRIB, TRUE, pUndoDoc, (ScMarkData*)&aMultiMark );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoClearItems( &rDocShell, aMultiMark, pUndoDoc, pWhich ) );
+ }
+
+ pDoc->ClearSelectionItems( pWhich, aMultiMark );
+
+ rDocShell.PostPaint( aMarkRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+ aModificator.SetDocumentModified();
+
+ //! Bindings-Invalidate etc.?
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::ChangeIndent( const ScMarkData& rMark, BOOL bIncrement, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ ScEditableTester aTester( pDoc, rMark );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ ScRange aMarkRange;
+ rMark.GetMultiMarkArea( aMarkRange );
+
+// if (bRecord)
+ if (bUndo)
+ {
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCTAB nTabCount = pDoc->GetTableCount();
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nStartTab && rMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pUndoDoc, (ScMarkData*)&rMark );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoIndent( &rDocShell, rMark, pUndoDoc, bIncrement ) );
+ }
+
+ pDoc->ChangeSelectionIndent( bIncrement, rMark );
+
+ rDocShell.PostPaint( aMarkRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+ aModificator.SetDocumentModified();
+
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( SID_ALIGNLEFT ); // ChangeIndent setzt auf links
+ pBindings->Invalidate( SID_ALIGNRIGHT );
+ pBindings->Invalidate( SID_ALIGNBLOCK );
+ pBindings->Invalidate( SID_ALIGNCENTERHOR );
+ // pseudo slots for Format menu
+ pBindings->Invalidate( SID_ALIGN_ANY_HDEFAULT );
+ pBindings->Invalidate( SID_ALIGN_ANY_LEFT );
+ pBindings->Invalidate( SID_ALIGN_ANY_HCENTER );
+ pBindings->Invalidate( SID_ALIGN_ANY_RIGHT );
+ pBindings->Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+ }
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
+ USHORT nFormatNo, BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aMark.SelectTable( nTab, TRUE );
+ }
+
+ ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat();
+ ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
+ if ( pAutoFormat && nFormatNo < pAutoFormat->GetCount() && aTester.IsEditable() )
+ {
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ BOOL bSize = (*pAutoFormat)[nFormatNo]->GetIncludeWidthHeight();
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScDocument* pUndoDoc = NULL;
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab, bSize, bSize );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nStartTab && aMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i, bSize, bSize );
+
+ ScRange aCopyRange = rRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aStart.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, FALSE, pUndoDoc, &aMark );
+ if (bSize)
+ {
+ pDoc->CopyToDocument( nStartCol,0,0, nEndCol,MAXROW,nTabCount-1,
+ IDF_NONE, FALSE, pUndoDoc, &aMark );
+ pDoc->CopyToDocument( 0,nStartRow,0, MAXCOL,nEndRow,nTabCount-1,
+ IDF_NONE, FALSE, pUndoDoc, &aMark );
+ }
+ pDoc->BeginDrawUndo();
+ }
+
+ pDoc->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo, aMark );
+
+ if (bSize)
+ {
+/* SCCOL nCols[2];
+ nCols[0] = nStartCol;
+ nCols[1] = nEndCol;
+ SCROW nRows[2];
+ nRows[0] = nStartRow;
+ nRows[1] = nEndRow;
+*/
+ SCCOLROW nCols[2] = { nStartCol, nEndCol };
+ SCCOLROW nRows[2] = { nStartRow, nEndRow };
+
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (aMark.GetTableSelect(nTab))
+ {
+ SetWidthOrHeight( TRUE, 1,nCols, nTab, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, FALSE, TRUE);
+ SetWidthOrHeight( FALSE,1,nRows, nTab, SC_SIZE_VISOPT, 0, FALSE, FALSE);
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP );
+ }
+ }
+ else
+ {
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (aMark.GetTableSelect(nTab))
+ {
+ BOOL bAdj = AdjustRowHeight( ScRange(nStartCol, nStartRow, nTab,
+ nEndCol, nEndRow, nTab), FALSE );
+ if (bAdj)
+ rDocShell.PostPaint( 0,nStartRow,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT );
+ else
+ rDocShell.PostPaint( nStartCol, nStartRow, nTab,
+ nEndCol, nEndRow, nTab, PAINT_GRID );
+ }
+ }
+
+ if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFormat( &rDocShell, rRange, pUndoDoc, aMark, bSize, nFormatNo ) );
+ }
+
+ aModificator.SetDocumentModified();
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
+ const ScTokenArray* pTokenArray, const String& rString, BOOL bApi, BOOL bEnglish,
+ const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aMark.SelectTable( nTab, TRUE );
+ }
+
+ ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
+ if ( aTester.IsEditable() )
+ {
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ ScDocument* pUndoDoc = NULL;
+// if (bRecord) // immer
+ if (bUndo)
+ {
+ //! auch bei Undo selektierte Tabellen beruecksichtigen
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
+ pDoc->CopyToDocument( rRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
+ }
+
+ // use TokenArray if given, string (and flags) otherwise
+ if ( pTokenArray )
+ {
+ pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
+ aMark, EMPTY_STRING, pTokenArray, eGrammar);
+ }
+ else if ( pDoc->IsImportingXML() )
+ {
+ ScTokenArray* pCode = lcl_ScDocFunc_CreateTokenArrayXML( rString, rFormulaNmsp, eGrammar );
+ pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
+ aMark, EMPTY_STRING, pCode, eGrammar);
+ delete pCode;
+ pDoc->IncXMLImportedFormulaCount( rString.Len() );
+ }
+ else if (bEnglish)
+ {
+ ScCompiler aComp( pDoc, rRange.aStart);
+ aComp.SetGrammar(eGrammar);
+ ScTokenArray* pCode = aComp.CompileString( rString );
+ pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
+ aMark, EMPTY_STRING, pCode, eGrammar);
+ delete pCode;
+ }
+ else
+ pDoc->InsertMatrixFormula( nStartCol, nStartRow, nEndCol, nEndRow,
+ aMark, rString, NULL, eGrammar);
+
+// if (bRecord) // immer
+ if (bUndo)
+ {
+ //! auch bei Undo selektierte Tabellen beruecksichtigen
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoEnterMatrix( &rDocShell, rRange, pUndoDoc, rString ) );
+ }
+
+ // Err522 beim Paint von DDE-Formeln werden jetzt beim Interpretieren abgefangen
+ rDocShell.PostPaint( nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab, PAINT_GRID );
+ aModificator.SetDocumentModified();
+
+ bSuccess = TRUE;
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
+ const ScTabOpParam& rParam, BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aMark.SelectTable( nTab, TRUE );
+ }
+
+ ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
+ if ( aTester.IsEditable() )
+ {
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+ pDoc->SetDirty( rRange );
+ if ( bRecord )
+ {
+ //! auch bei Undo selektierte Tabellen beruecksichtigen
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
+ pDoc->CopyToDocument( rRange, IDF_ALL & ~IDF_NOTE, FALSE, pUndoDoc );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoTabOp( &rDocShell,
+ nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab, pUndoDoc,
+ rParam.aRefFormulaCell,
+ rParam.aRefFormulaEnd,
+ rParam.aRefRowCell,
+ rParam.aRefColCell,
+ rParam.nMode) );
+ }
+ pDoc->InsertTableOp(rParam, nStartCol, nStartRow, nEndCol, nEndRow, aMark);
+ rDocShell.PostPaintGridAll();
+ aModificator.SetDocumentModified();
+ bSuccess = TRUE;
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+
+inline ScDirection DirFromFillDir( FillDir eDir )
+{
+ if (eDir==FILL_TO_BOTTOM)
+ return DIR_BOTTOM;
+ else if (eDir==FILL_TO_RIGHT)
+ return DIR_RIGHT;
+ else if (eDir==FILL_TO_TOP)
+ return DIR_TOP;
+ else // if (eDir==FILL_TO_LEFT)
+ return DIR_LEFT;
+}
+
+BOOL ScDocFunc::FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
+ FillDir eDir, BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aMark.SelectTable( nTab, TRUE );
+ }
+
+ ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
+ if ( aTester.IsEditable() )
+ {
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ ScRange aSourceArea = rRange;
+ ScRange aDestArea = rRange;
+
+ SCCOLROW nCount = 0;
+ switch (eDir)
+ {
+ case FILL_TO_BOTTOM:
+ nCount = aSourceArea.aEnd.Row()-aSourceArea.aStart.Row();
+ aSourceArea.aEnd.SetRow( aSourceArea.aStart.Row() );
+ break;
+ case FILL_TO_RIGHT:
+ nCount = aSourceArea.aEnd.Col()-aSourceArea.aStart.Col();
+ aSourceArea.aEnd.SetCol( aSourceArea.aStart.Col() );
+ break;
+ case FILL_TO_TOP:
+ nCount = aSourceArea.aEnd.Row()-aSourceArea.aStart.Row();
+ aSourceArea.aStart.SetRow( aSourceArea.aEnd.Row() );
+ break;
+ case FILL_TO_LEFT:
+ nCount = aSourceArea.aEnd.Col()-aSourceArea.aStart.Col();
+ aSourceArea.aStart.SetCol( aSourceArea.aEnd.Col() );
+ break;
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bRecord )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nDestStartTab = aDestArea.aStart.Tab();
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nDestStartTab, nDestStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nDestStartTab && aMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange = aDestArea;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_AUTOFILL, FALSE, pUndoDoc, &aMark );
+ }
+
+ pDoc->Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
+ aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), aMark,
+ nCount, eDir, FILL_SIMPLE );
+ AdjustRowHeight(rRange);
+
+ if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
+ eDir, FILL_SIMPLE, FILL_DAY, MAXDOUBLE, 1.0, 1e307,
+ pDoc->GetRangeName()->GetSharedMaxIndex()+1 ) );
+ }
+
+ rDocShell.PostPaintGridAll();
+// rDocShell.PostPaintDataChanged();
+ aModificator.SetDocumentModified();
+
+ bSuccess = TRUE;
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+
+ return bSuccess;
+}
+
+BOOL ScDocFunc::FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
+ FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
+ double fStart, double fStep, double fMax,
+ BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aMark.SelectTable( nTab, TRUE );
+ }
+
+ ScEditableTester aTester( pDoc, nStartCol,nStartRow, nEndCol,nEndRow, aMark );
+ if ( aTester.IsEditable() )
+ {
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ ScRange aSourceArea = rRange;
+ ScRange aDestArea = rRange;
+
+ SCSIZE nCount = pDoc->GetEmptyLinesInBlock(
+ aSourceArea.aStart.Col(), aSourceArea.aStart.Row(), aSourceArea.aStart.Tab(),
+ aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), aSourceArea.aEnd.Tab(),
+ DirFromFillDir(eDir) );
+
+ // #27665# mindestens eine Zeile/Spalte als Quellbereich behalten:
+ SCSIZE nTotLines = ( eDir == FILL_TO_BOTTOM || eDir == FILL_TO_TOP ) ?
+ static_cast<SCSIZE>( aSourceArea.aEnd.Row() - aSourceArea.aStart.Row() + 1 ) :
+ static_cast<SCSIZE>( aSourceArea.aEnd.Col() - aSourceArea.aStart.Col() + 1 );
+ if ( nCount >= nTotLines )
+ nCount = nTotLines - 1;
+
+ switch (eDir)
+ {
+ case FILL_TO_BOTTOM:
+ aSourceArea.aEnd.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aEnd.Row() - nCount ) );
+ break;
+ case FILL_TO_RIGHT:
+ aSourceArea.aEnd.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aEnd.Col() - nCount ) );
+ break;
+ case FILL_TO_TOP:
+ aSourceArea.aStart.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aStart.Row() + nCount ) );
+ break;
+ case FILL_TO_LEFT:
+ aSourceArea.aStart.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aStart.Col() + nCount ) );
+ break;
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bRecord )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nDestStartTab = aDestArea.aStart.Tab();
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nDestStartTab, nDestStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nDestStartTab && aMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ pDoc->CopyToDocument(
+ aDestArea.aStart.Col(), aDestArea.aStart.Row(), 0,
+ aDestArea.aEnd.Col(), aDestArea.aEnd.Row(), nTabCount-1,
+ IDF_AUTOFILL, FALSE, pUndoDoc, &aMark );
+ }
+
+ if (aDestArea.aStart.Col() <= aDestArea.aEnd.Col() &&
+ aDestArea.aStart.Row() <= aDestArea.aEnd.Row())
+ {
+ if ( fStart != MAXDOUBLE )
+ {
+ SCCOL nValX = (eDir == FILL_TO_LEFT) ? aDestArea.aEnd.Col() : aDestArea.aStart.Col();
+ SCROW nValY = (eDir == FILL_TO_TOP ) ? aDestArea.aEnd.Row() : aDestArea.aStart.Row();
+ SCTAB nTab = aDestArea.aStart.Tab();
+ pDoc->SetValue( nValX, nValY, nTab, fStart );
+ }
+ pDoc->Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
+ aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), aMark,
+ nCount, eDir, eCmd, eDateCmd, fStep, fMax );
+ AdjustRowHeight(rRange);
+
+ rDocShell.PostPaintGridAll();
+// rDocShell.PostPaintDataChanged();
+ aModificator.SetDocumentModified();
+ }
+
+ if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
+ eDir, eCmd, eDateCmd, fStart, fStep, fMax,
+ pDoc->GetRangeName()->GetSharedMaxIndex()+1 ) );
+ }
+
+ bSuccess = TRUE;
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+
+ return bSuccess;
+}
+
+BOOL ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
+ FillDir eDir, ULONG nCount, BOOL bRecord, BOOL bApi )
+{
+ double fStep = 1.0;
+ double fMax = MAXDOUBLE;
+ return FillAuto( rRange, pTabMark, eDir, FILL_AUTO, FILL_DAY, nCount, fStep, fMax, bRecord, bApi );
+}
+
+BOOL ScDocFunc::FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, ULONG nCount, double fStep, double fMax, BOOL bRecord, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScMarkData aMark;
+ if (pTabMark)
+ aMark = *pTabMark;
+ else
+ {
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ aMark.SelectTable( nTab, TRUE );
+ }
+
+ ScRange aSourceArea = rRange;
+ ScRange aDestArea = rRange;
+
+
+ switch (eDir)
+ {
+ case FILL_TO_BOTTOM:
+ aDestArea.aEnd.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aEnd.Row() + nCount ) );
+ break;
+ case FILL_TO_TOP:
+ if (nCount > sal::static_int_cast<ULONG>( aSourceArea.aStart.Row() ))
+ {
+ DBG_ERROR("FillAuto: Row < 0");
+ nCount = aSourceArea.aStart.Row();
+ }
+ aDestArea.aStart.SetRow( sal::static_int_cast<SCROW>( aSourceArea.aStart.Row() - nCount ) );
+ break;
+ case FILL_TO_RIGHT:
+ aDestArea.aEnd.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aEnd.Col() + nCount ) );
+ break;
+ case FILL_TO_LEFT:
+ if (nCount > sal::static_int_cast<ULONG>( aSourceArea.aStart.Col() ))
+ {
+ DBG_ERROR("FillAuto: Col < 0");
+ nCount = aSourceArea.aStart.Col();
+ }
+ aDestArea.aStart.SetCol( sal::static_int_cast<SCCOL>( aSourceArea.aStart.Col() - nCount ) );
+ break;
+ default:
+ DBG_ERROR("Falsche Richtung bei FillAuto");
+ break;
+ }
+
+ // Zellschutz testen
+ //! Quellbereich darf geschuetzt sein !!!
+ //! aber kein Matrixfragment enthalten !!!
+
+ ScEditableTester aTester( pDoc, aDestArea );
+ if ( !aTester.IsEditable() )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ if ( pDoc->HasSelectedBlockMatrixFragment( nStartCol, nStartRow,
+ nEndCol, nEndRow, aMark ) )
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MATRIXFRAGMENTERR);
+ return FALSE;
+ }
+
+ WaitObject aWait( rDocShell.GetActiveDialogParent() );
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bRecord )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nDestStartTab = aDestArea.aStart.Tab();
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nDestStartTab, nDestStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nDestStartTab && aMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ // do not clone note captions in undo document
+ pDoc->CopyToDocument(
+ aDestArea.aStart.Col(), aDestArea.aStart.Row(), 0,
+ aDestArea.aEnd.Col(), aDestArea.aEnd.Row(), nTabCount-1,
+ IDF_AUTOFILL, FALSE, pUndoDoc, &aMark );
+ }
+
+ pDoc->Fill( aSourceArea.aStart.Col(), aSourceArea.aStart.Row(),
+ aSourceArea.aEnd.Col(), aSourceArea.aEnd.Row(), aMark,
+ nCount, eDir, eCmd, eDateCmd, fStep, fMax );
+
+ AdjustRowHeight(aDestArea);
+
+ if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFill( &rDocShell, aDestArea, aSourceArea, pUndoDoc, aMark,
+ eDir, eCmd, eDateCmd, MAXDOUBLE, fStep, fMax,
+ pDoc->GetRangeName()->GetSharedMaxIndex()+1 ) );
+ }
+
+ rDocShell.PostPaintGridAll();
+// rDocShell.PostPaintDataChanged();
+ aModificator.SetDocumentModified();
+
+ rRange = aDestArea; // Zielbereich zurueckgeben (zum Markieren)
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::MergeCells( const ScCellMergeOption& rOption, BOOL bContents, BOOL bRecord, BOOL bApi )
+{
+ using ::std::set;
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ SCCOL nStartCol = rOption.mnStartCol;
+ SCROW nStartRow = rOption.mnStartRow;
+ SCCOL nEndCol = rOption.mnEndCol;
+ SCROW nEndRow = rOption.mnEndRow;
+ if ((nStartCol == nEndCol && nStartRow == nEndRow) || rOption.maTabs.empty())
+ {
+ // Nothing to do. Bail out quick.
+ return TRUE;
+ }
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ set<SCTAB>::const_iterator itrBeg = rOption.maTabs.begin(), itrEnd = rOption.maTabs.end();
+ SCTAB nTab1 = *itrBeg, nTab2 = *rOption.maTabs.rbegin();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ for (set<SCTAB>::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
+ {
+ ScEditableTester aTester( pDoc, *itr, nStartCol, nStartRow, nEndCol, nEndRow );
+ if (!aTester.IsEditable())
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ if ( pDoc->HasAttrib( nStartCol, nStartRow, *itr, nEndCol, nEndRow, *itr,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ // "Zusammenfassen nicht verschachteln !"
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_MERGECELLS_0);
+ return FALSE;
+ }
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ bool bNeedContentsUndo = false;
+ for (set<SCTAB>::const_iterator itr = itrBeg; itr != itrEnd; ++itr)
+ {
+ SCTAB nTab = *itr;
+ bool bNeedContents = bContents &&
+ ( !pDoc->IsBlockEmpty( nTab, nStartCol,nStartRow+1, nStartCol,nEndRow, true ) ||
+ !pDoc->IsBlockEmpty( nTab, nStartCol+1,nStartRow, nEndCol,nEndRow, true ) );
+
+ if (bRecord)
+ {
+ // test if the range contains other notes which also implies that we need an undo document
+ bool bHasNotes = false;
+ for( ScAddress aPos( nStartCol, nStartRow, nTab ); !bHasNotes && (aPos.Col() <= nEndCol); aPos.IncCol() )
+ for( aPos.SetRow( nStartRow ); !bHasNotes && (aPos.Row() <= nEndRow); aPos.IncRow() )
+ bHasNotes = ((aPos.Col() != nStartCol) || (aPos.Row() != nStartRow)) && (pDoc->GetNote( aPos ) != 0);
+
+ if (bNeedContents || bHasNotes || rOption.mbCenter)
+ {
+ if (!pUndoDoc)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo(pDoc, nTab1, nTab2);
+ }
+ // note captions are collected by drawing undo
+ pDoc->CopyToDocument( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
+ IDF_ALL|IDF_NOCAPTIONS, FALSE, pUndoDoc );
+ }
+ if( bHasNotes )
+ pDoc->BeginDrawUndo();
+ }
+
+ if (bNeedContents)
+ pDoc->DoMergeContents( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
+ pDoc->DoMerge( nTab, nStartCol,nStartRow, nEndCol,nEndRow );
+
+ if (rOption.mbCenter)
+ {
+ pDoc->ApplyAttr( nStartCol, nStartRow, nTab, SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
+ pDoc->ApplyAttr( nStartCol, nStartRow, nTab, SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
+ }
+
+ if ( !AdjustRowHeight( ScRange( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab ) ) )
+ rDocShell.PostPaint( nStartCol, nStartRow, nTab,
+ nEndCol, nEndRow, nTab, PAINT_GRID );
+ if (bNeedContents || rOption.mbCenter)
+ {
+ ScRange aRange(nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab);
+ pDoc->SetDirty(aRange);
+ }
+
+ bNeedContentsUndo |= bNeedContents;
+ }
+
+ if (pUndoDoc)
+ {
+ SdrUndoGroup* pDrawUndo = pDoc->GetDrawLayer() ? pDoc->GetDrawLayer()->GetCalcUndo() : NULL;
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoMerge(&rDocShell, rOption, bNeedContentsUndo, pUndoDoc, pDrawUndo) );
+ }
+
+ aModificator.SetDocumentModified();
+
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_MERGE_ON );
+ pBindings->Invalidate( FID_MERGE_OFF );
+ pBindings->Invalidate( FID_MERGE_TOGGLE );
+ }
+
+ return TRUE;
+}
+
+BOOL ScDocFunc::UnmergeCells( const ScRange& rRange, BOOL bRecord, BOOL bApi )
+{
+ ScCellMergeOption aOption(rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row());
+ SCTAB nTab1 = rRange.aStart.Tab(), nTab2 = rRange.aEnd.Tab();
+ for (SCTAB i = nTab1; i <= nTab2; ++i)
+ aOption.maTabs.insert(i);
+
+ return UnmergeCells(aOption, bRecord, bApi);
+}
+
+bool ScDocFunc::UnmergeCells( const ScCellMergeOption& rOption, BOOL bRecord, BOOL bApi )
+{
+ using ::std::set;
+
+ if (rOption.maTabs.empty())
+ // Nothing to unmerge.
+ return true;
+
+ ScDocShellModificator aModificator( rDocShell );
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocument* pUndoDoc = NULL;
+ bool bBeep = false;
+ for (set<SCTAB>::const_iterator itr = rOption.maTabs.begin(), itrEnd = rOption.maTabs.end();
+ itr != itrEnd; ++itr)
+ {
+ SCTAB nTab = *itr;
+ ScRange aRange = rOption.getSingleRange(nTab);
+ if ( !pDoc->HasAttrib(aRange, HASATTR_MERGED) )
+ {
+ bBeep = true;
+ continue;
+ }
+
+ ScRange aExtended = aRange;
+ pDoc->ExtendMerge(aExtended);
+ ScRange aRefresh = aExtended;
+ pDoc->ExtendOverlapped(aRefresh);
+
+ if (bRecord)
+ {
+ if (!pUndoDoc)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo(pDoc, *rOption.maTabs.begin(), *rOption.maTabs.rbegin());
+ }
+ pDoc->CopyToDocument(aExtended, IDF_ATTRIB, FALSE, pUndoDoc);
+ }
+
+ const SfxPoolItem& rDefAttr = pDoc->GetPool()->GetDefaultItem( ATTR_MERGE );
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( rDefAttr );
+ pDoc->ApplyPatternAreaTab( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), nTab,
+ aPattern );
+
+ pDoc->RemoveFlagsTab( aExtended.aStart.Col(), aExtended.aStart.Row(),
+ aExtended.aEnd.Col(), aExtended.aEnd.Row(), nTab,
+ SC_MF_HOR | SC_MF_VER );
+
+ pDoc->ExtendMerge( aRefresh, TRUE, FALSE );
+
+ if ( !AdjustRowHeight( aExtended ) )
+ rDocShell.PostPaint( aExtended, PAINT_GRID );
+ }
+ if (bBeep && !bApi)
+ Sound::Beep();
+
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoRemoveMerge( &rDocShell, rOption, pUndoDoc ) );
+ }
+ aModificator.SetDocumentModified();
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+bool ScDocFunc::ModifyRangeNames( const ScRangeName& rNewRanges )
+{
+ return SetNewRangeNames( new ScRangeName(rNewRanges) );
+}
+
+bool ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc ) // takes ownership of pNewRanges
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+ DBG_ASSERT( pNewRanges, "pNewRanges is 0" );
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ if (bUndo)
+ {
+ ScRangeName* pOld = pDoc->GetRangeName();
+ ScRangeName* pUndoRanges = new ScRangeName(*pOld);
+ ScRangeName* pRedoRanges = new ScRangeName(*pNewRanges);
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoRangeNames( &rDocShell, pUndoRanges, pRedoRanges ) );
+ }
+
+ // #i55926# While loading XML, formula cells only have a single string token,
+ // so CompileNameFormula would never find any name (index) tokens, and would
+ // unnecessarily loop through all cells.
+ BOOL bCompile = ( !pDoc->IsImportingXML() && pDoc->GetNamedRangesLockCount() == 0 );
+
+ if ( bCompile )
+ pDoc->CompileNameFormula( TRUE ); // CreateFormulaString
+ pDoc->SetRangeName( pNewRanges ); // takes ownership
+ if ( bCompile )
+ pDoc->CompileNameFormula( FALSE ); // CompileFormulaString
+
+ if (bModifyDoc)
+ {
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint(SC_HINT_AREAS_CHANGED) );
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------
+
+void ScDocFunc::CreateOneName( ScRangeName& rList,
+ SCCOL nPosX, SCROW nPosY, SCTAB nTab,
+ SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ BOOL& rCancel, BOOL bApi )
+{
+ if (rCancel)
+ return;
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (!pDoc->HasValueData( nPosX, nPosY, nTab ))
+ {
+ String aName;
+ pDoc->GetString( nPosX, nPosY, nTab, aName );
+ ScRangeData::MakeValidName(aName);
+ if (aName.Len())
+ {
+ String aContent;
+ ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format( aContent, SCR_ABS_3D, pDoc );
+
+ BOOL bInsert = FALSE;
+ USHORT nOldPos;
+ if (rList.SearchName( aName, nOldPos )) // vorhanden ?
+ {
+ ScRangeData* pOld = rList[nOldPos];
+ String aOldStr;
+ pOld->GetSymbol( aOldStr );
+ if (aOldStr != aContent)
+ {
+ if (bApi)
+ bInsert = TRUE; // per API nicht nachfragen
+ else
+ {
+ String aTemplate = ScGlobal::GetRscString( STR_CREATENAME_REPLACE );
+
+ String aMessage = aTemplate.GetToken( 0, '#' );
+ aMessage += aName;
+ aMessage += aTemplate.GetToken( 1, '#' );
+
+ short nResult = QueryBox( rDocShell.GetActiveDialogParent(),
+ WinBits(WB_YES_NO_CANCEL | WB_DEF_YES),
+ aMessage ).Execute();
+ if ( nResult == RET_YES )
+ {
+ rList.AtFree(nOldPos);
+ bInsert = TRUE;
+ }
+ else if ( nResult == RET_CANCEL )
+ rCancel = TRUE;
+ }
+ }
+ }
+ else
+ bInsert = TRUE;
+
+ if (bInsert)
+ {
+ ScRangeData* pData = new ScRangeData( pDoc, aName, aContent,
+ ScAddress( nPosX, nPosY, nTab));
+ if (!rList.Insert(pData))
+ {
+ DBG_ERROR("nanu?");
+ delete pData;
+ }
+ }
+ }
+ }
+}
+
+BOOL ScDocFunc::CreateNames( const ScRange& rRange, USHORT nFlags, BOOL bApi )
+{
+ if (!nFlags)
+ return FALSE; // war nix
+
+ ScDocShellModificator aModificator( rDocShell );
+
+ BOOL bDone = FALSE;
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+ DBG_ASSERT(rRange.aEnd.Tab() == nTab, "CreateNames: mehrere Tabellen geht nicht");
+
+ BOOL bValid = TRUE;
+ if ( nFlags & ( NAME_TOP | NAME_BOTTOM ) )
+ if ( nStartRow == nEndRow )
+ bValid = FALSE;
+ if ( nFlags & ( NAME_LEFT | NAME_RIGHT ) )
+ if ( nStartCol == nEndCol )
+ bValid = FALSE;
+
+ if (bValid)
+ {
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScRangeName* pNames = pDoc->GetRangeName();
+ if (!pNames)
+ return FALSE; // soll nicht sein
+ ScRangeName aNewRanges( *pNames );
+
+ BOOL bTop = ( ( nFlags & NAME_TOP ) != 0 );
+ BOOL bLeft = ( ( nFlags & NAME_LEFT ) != 0 );
+ BOOL bBottom = ( ( nFlags & NAME_BOTTOM ) != 0 );
+ BOOL bRight = ( ( nFlags & NAME_RIGHT ) != 0 );
+
+ SCCOL nContX1 = nStartCol;
+ SCROW nContY1 = nStartRow;
+ SCCOL nContX2 = nEndCol;
+ SCROW nContY2 = nEndRow;
+
+ if ( bTop )
+ ++nContY1;
+ if ( bLeft )
+ ++nContX1;
+ if ( bBottom )
+ --nContY2;
+ if ( bRight )
+ --nContX2;
+
+ BOOL bCancel = FALSE;
+ SCCOL i;
+ SCROW j;
+
+ if ( bTop )
+ for (i=nContX1; i<=nContX2; i++)
+ CreateOneName( aNewRanges, i,nStartRow,nTab, i,nContY1,i,nContY2, bCancel, bApi );
+ if ( bLeft )
+ for (j=nContY1; j<=nContY2; j++)
+ CreateOneName( aNewRanges, nStartCol,j,nTab, nContX1,j,nContX2,j, bCancel, bApi );
+ if ( bBottom )
+ for (i=nContX1; i<=nContX2; i++)
+ CreateOneName( aNewRanges, i,nEndRow,nTab, i,nContY1,i,nContY2, bCancel, bApi );
+ if ( bRight )
+ for (j=nContY1; j<=nContY2; j++)
+ CreateOneName( aNewRanges, nEndCol,j,nTab, nContX1,j,nContX2,j, bCancel, bApi );
+
+ if ( bTop && bLeft )
+ CreateOneName( aNewRanges, nStartCol,nStartRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
+ if ( bTop && bRight )
+ CreateOneName( aNewRanges, nEndCol,nStartRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
+ if ( bBottom && bLeft )
+ CreateOneName( aNewRanges, nStartCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
+ if ( bBottom && bRight )
+ CreateOneName( aNewRanges, nEndCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
+
+ bDone = ModifyRangeNames( aNewRanges );
+
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+ }
+
+ return bDone;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::InsertNameList( const ScAddress& rStartPos, BOOL bApi )
+{
+ ScDocShellModificator aModificator( rDocShell );
+
+
+ BOOL bDone = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+ const BOOL bRecord = pDoc->IsUndoEnabled();
+ SCTAB nTab = rStartPos.Tab();
+ ScDocument* pUndoDoc = NULL;
+
+ ScRangeName* pList = pDoc->GetRangeName();
+ USHORT nCount = pList->GetCount();
+ USHORT nValidCount = 0;
+ USHORT i;
+ for (i=0; i<nCount; i++)
+ {
+ ScRangeData* pData = (*pList)[i];
+ if ( !pData->HasType( RT_DATABASE ) && !pData->HasType( RT_SHARED ) )
+ ++nValidCount;
+ }
+
+ if (nValidCount)
+ {
+ SCCOL nStartCol = rStartPos.Col();
+ SCROW nStartRow = rStartPos.Row();
+ SCCOL nEndCol = nStartCol + 1;
+ SCROW nEndRow = nStartRow + static_cast<SCROW>(nValidCount) - 1;
+
+ ScEditableTester aTester( pDoc, nTab, nStartCol,nStartRow, nEndCol,nEndRow );
+ if (aTester.IsEditable())
+ {
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
+ IDF_ALL, FALSE, pUndoDoc );
+
+ pDoc->BeginDrawUndo(); // wegen Hoehenanpassung
+ }
+
+ ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
+ USHORT j = 0;
+ for (i=0; i<nCount; i++)
+ {
+ ScRangeData* pData = (*pList)[i];
+ if ( !pData->HasType( RT_DATABASE ) && !pData->HasType( RT_SHARED ) )
+ ppSortArray[j++] = pData;
+ }
+#ifndef ICC
+ qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ &ScRangeData_QsortNameCompare );
+#else
+ qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ ICCQsortNameCompare );
+#endif
+ String aName;
+ rtl::OUStringBuffer aContent;
+ String aFormula;
+ SCROW nOutRow = nStartRow;
+ for (j=0; j<nValidCount; j++)
+ {
+ ScRangeData* pData = ppSortArray[j];
+ pData->GetName(aName);
+ // relative Referenzen Excel-konform auf die linke Spalte anpassen:
+ pData->UpdateSymbol(aContent, ScAddress( nStartCol, nOutRow, nTab ));
+ aFormula = '=';
+ aFormula += aContent;
+ pDoc->PutCell( nStartCol,nOutRow,nTab, new ScStringCell( aName ) );
+ pDoc->PutCell( nEndCol ,nOutRow,nTab, new ScStringCell( aFormula ) );
+ ++nOutRow;
+ }
+
+ delete [] ppSortArray;
+
+ if (bRecord)
+ {
+ ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
+ IDF_ALL, FALSE, pRedoDoc );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoListNames( &rDocShell,
+ ScRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab ),
+ pUndoDoc, pRedoDoc ) );
+ }
+
+ if (!AdjustRowHeight(ScRange(0,nStartRow,nTab,MAXCOL,nEndRow,nTab)))
+ rDocShell.PostPaint( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab, PAINT_GRID );
+//! rDocShell.UpdateOle(GetViewData());
+ aModificator.SetDocumentModified();
+ bDone = TRUE;
+ }
+ else if (!bApi)
+ rDocShell.ErrorMessage(aTester.GetMessageId());
+ }
+ return bDone;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd, BOOL bApi )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCCOL nStartCol = rOldRange.aStart.Col();
+ SCROW nStartRow = rOldRange.aStart.Row();
+ SCTAB nTab = rOldRange.aStart.Tab();
+
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ BOOL bRet = FALSE;
+
+ String aFormula;
+ pDoc->GetFormula( nStartCol, nStartRow, nTab, aFormula );
+ if ( aFormula.GetChar(0) == '{' && aFormula.GetChar(aFormula.Len()-1) == '}' )
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_RESIZEMATRIX );
+ if (bUndo)
+ rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ aFormula.Erase(0,1);
+ aFormula.Erase(aFormula.Len()-1,1);
+
+ ScMarkData aMark;
+ aMark.SetMarkArea( rOldRange );
+ aMark.SelectTable( nTab, TRUE );
+ ScRange aNewRange( rOldRange.aStart, rNewEnd );
+
+ if ( DeleteContents( aMark, IDF_CONTENTS, TRUE, bApi ) )
+ {
+ // GRAM_PODF_A1 for API compatibility.
+ bRet = EnterMatrix( aNewRange, &aMark, NULL, aFormula, bApi, FALSE, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
+ if (!bRet)
+ {
+ // versuchen, alten Zustand wiederherzustellen
+ EnterMatrix( rOldRange, &aMark, NULL, aFormula, bApi, FALSE, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
+ }
+ }
+
+ if (bUndo)
+ rDocShell.GetUndoManager()->LeaveListAction();
+ }
+
+ return bRet;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ const ScRange& rDestRange, ULONG nRefresh,
+ BOOL bFitBlock, BOOL bApi )
+{
+ //! auch fuer ScViewFunc::InsertAreaLink benutzen!
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+
+ // #i52120# if other area links exist at the same start position,
+ // remove them first (file format specifies only one link definition
+ // for a cell)
+
+ USHORT nLinkCount = pLinkManager->GetLinks().Count();
+ USHORT nRemoved = 0;
+ USHORT nLinkPos = 0;
+ while (nLinkPos<nLinkCount)
+ {
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[nLinkPos];
+ if ( pBase->ISA(ScAreaLink) &&
+ static_cast<ScAreaLink*>(pBase)->GetDestArea().aStart == rDestRange.aStart )
+ {
+ if ( bUndo )
+ {
+ if ( !nRemoved )
+ {
+ // group all remove and the insert action
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_INSERTAREALINK );
+ rDocShell.GetUndoManager()->EnterListAction( aUndo, aUndo );
+ }
+
+ ScAreaLink* pOldArea = static_cast<ScAreaLink*>(pBase);
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoRemoveAreaLink( &rDocShell,
+ pOldArea->GetFile(), pOldArea->GetFilter(), pOldArea->GetOptions(),
+ pOldArea->GetSource(), pOldArea->GetDestArea(), pOldArea->GetRefreshDelay() ) );
+ }
+ pLinkManager->Remove( pBase );
+ nLinkCount = pLinkManager->GetLinks().Count();
+ ++nRemoved;
+ }
+ else
+ ++nLinkPos;
+ }
+
+ String aFilterName = rFilter;
+ String aNewOptions = rOptions;
+ if (!aFilterName.Len())
+ ScDocumentLoader::GetFilterName( rFile, aFilterName, aNewOptions, TRUE, !bApi );
+
+ // remove application prefix from filter name here, so the filter options
+ // aren't reset when the filter name is changed in ScAreaLink::DataChanged
+ ScDocumentLoader::RemoveAppPrefix( aFilterName );
+
+ ScAreaLink* pLink = new ScAreaLink( &rDocShell, rFile, aFilterName,
+ aNewOptions, rSource, rDestRange, nRefresh );
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, rFile, &aFilterName, &rSource );
+
+ // Undo fuer den leeren Link
+
+ if (bUndo)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction( new ScUndoInsertAreaLink( &rDocShell,
+ rFile, aFilterName, aNewOptions,
+ rSource, rDestRange, nRefresh ) );
+ if ( nRemoved )
+ rDocShell.GetUndoManager()->LeaveListAction(); // undo for link update is still separate
+ }
+
+ // Update hat sein eigenes Undo
+
+ pLink->SetDoInsert(bFitBlock); // beim ersten Update ggf. nichts einfuegen
+ pLink->Update(); // kein SetInCreate -> Update ausfuehren
+ pLink->SetDoInsert(TRUE); // Default = TRUE
+
+ SfxBindings* pBindings = rDocShell.GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_LINKS );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
+
+ return TRUE;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
new file mode 100644
index 000000000000..671b261ac644
--- /dev/null
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -0,0 +1,3081 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+// System - Includes -----------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <editeng/svxenum.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/algitem.hxx>
+
+#include <sot/clsids.hxx>
+#include <unotools/securityoptions.hxx>
+#include <tools/stream.hxx>
+#include <tools/string.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/waitobj.hxx>
+#include <svtools/ctrltool.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/PasswordHelper.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dinfdlg.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/evntconf.hxx>
+#include <sfx2/sfx.hrc>
+#include <sfx2/objface.hxx>
+#include <svl/srchitem.hxx>
+#include <unotools/fltrcfg.hxx>
+#include <svl/documentlockfile.hxx>
+#include <svl/sharecontrolfile.hxx>
+#include <unotools/charclass.hxx>
+#include <vcl/virdev.hxx>
+#include "chgtrack.hxx"
+#include "chgviset.hxx"
+#include <sfx2/request.hxx>
+#include <com/sun/star/awt/Key.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/document/UpdateDocMode.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/ui/XModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XAcceleratorConfiguration.hpp>
+#include <basic/sbstar.hxx>
+#include <basic/basmgr.hxx>
+#include <vbahelper/vbaaccesshelper.hxx>
+
+#include "scabstdlg.hxx"
+#include <sot/formats.hxx>
+#define SOT_FORMATSTR_ID_STARCALC_30 SOT_FORMATSTR_ID_STARCALC
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "cell.hxx"
+#include "global.hxx"
+#include "filter.hxx"
+#include "scmod.hxx"
+#include "tabvwsh.hxx"
+#include "docfunc.hxx"
+#include "imoptdlg.hxx"
+#include "impex.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "scerrors.hxx"
+#include "brdcst.hxx"
+#include "stlpool.hxx"
+#include "autostyl.hxx"
+#include "attrib.hxx"
+#include "asciiopt.hxx"
+#include "waitoff.hxx"
+#include "docpool.hxx" // LoadCompleted
+#include "progress.hxx"
+#include "pntlock.hxx"
+#include "collect.hxx"
+#include "docuno.hxx"
+#include "appoptio.hxx"
+#include "detdata.hxx"
+#include "printfun.hxx"
+#include "dociter.hxx"
+#include "cellform.hxx"
+#include "chartlis.hxx"
+#include "hints.hxx"
+#include "xmlwrap.hxx"
+#include "drwlayer.hxx"
+#include "refreshtimer.hxx"
+#include "dbcolect.hxx"
+#include "scextopt.hxx"
+#include "compiler.hxx"
+#include "cfgids.hxx"
+#include "warnpassword.hxx"
+#include "optsolver.hxx"
+#include "sheetdata.hxx"
+#include "tabprotection.hxx"
+#include "docparam.hxx"
+
+#include "docsh.hxx"
+#include "docshimp.hxx"
+#include "sizedev.hxx"
+#include <rtl/logfile.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include "uiitems.hxx"
+#include "cellsuno.hxx"
+
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::boost::shared_ptr;
+using ::std::vector;
+
+// STATIC DATA -----------------------------------------------------------
+
+// Stream-Namen im Storage
+
+const sal_Char __FAR_DATA ScDocShell::pStarCalcDoc[] = STRING_SCSTREAM; // "StarCalcDocument"
+const sal_Char __FAR_DATA ScDocShell::pStyleName[] = "SfxStyleSheets";
+
+// Filter-Namen (wie in sclib.cxx)
+
+static const sal_Char __FAR_DATA pFilterSc50[] = "StarCalc 5.0";
+//static const sal_Char __FAR_DATA pFilterSc50Temp[] = "StarCalc 5.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterSc40[] = "StarCalc 4.0";
+//static const sal_Char __FAR_DATA pFilterSc40Temp[] = "StarCalc 4.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterSc30[] = "StarCalc 3.0";
+//static const sal_Char __FAR_DATA pFilterSc30Temp[] = "StarCalc 3.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterSc10[] = "StarCalc 1.0";
+static const sal_Char __FAR_DATA pFilterXML[] = "StarOffice XML (Calc)";
+static const sal_Char __FAR_DATA pFilterAscii[] = "Text - txt - csv (StarCalc)";
+static const sal_Char __FAR_DATA pFilterLotus[] = "Lotus";
+static const sal_Char __FAR_DATA pFilterQPro6[] = "Quattro Pro 6.0";
+static const sal_Char __FAR_DATA pFilterExcel4[] = "MS Excel 4.0";
+static const sal_Char __FAR_DATA pFilterEx4Temp[] = "MS Excel 4.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcel5[] = "MS Excel 5.0/95";
+static const sal_Char __FAR_DATA pFilterEx5Temp[] = "MS Excel 5.0/95 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcel95[] = "MS Excel 95";
+static const sal_Char __FAR_DATA pFilterEx95Temp[] = "MS Excel 95 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcel97[] = "MS Excel 97";
+static const sal_Char __FAR_DATA pFilterEx97Temp[] = "MS Excel 97 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterDBase[] = "dBase";
+static const sal_Char __FAR_DATA pFilterDif[] = "DIF";
+static const sal_Char __FAR_DATA pFilterSylk[] = "SYLK";
+static const sal_Char __FAR_DATA pFilterHtml[] = "HTML (StarCalc)";
+static const sal_Char __FAR_DATA pFilterHtmlWebQ[] = "calc_HTML_WebQuery";
+static const sal_Char __FAR_DATA pFilterRtf[] = "Rich Text Format (StarCalc)";
+
+//----------------------------------------------------------------------
+
+#define ScDocShell
+#include "scslots.hxx"
+
+
+SFX_IMPL_INTERFACE(ScDocShell,SfxObjectShell, ScResId(SCSTR_DOCSHELL))
+{
+ SFX_CHILDWINDOW_REGISTRATION( SID_HYPERLINK_INSERT );
+}
+
+// GlobalName der aktuellen Version:
+SFX_IMPL_OBJECTFACTORY( ScDocShell, SvGlobalName(SO3_SC_CLASSID), SFXOBJECTSHELL_STD_NORMAL, "scalc" )
+
+TYPEINIT1( ScDocShell, SfxObjectShell ); // SfxInPlaceObject: kein Type-Info ?
+
+//------------------------------------------------------------------
+
+void __EXPORT ScDocShell::FillClass( SvGlobalName* pClassName,
+ sal_uInt32* pFormat,
+ String* /* pAppName */,
+ String* pFullTypeName,
+ String* pShortTypeName,
+ sal_Int32 nFileFormat,
+ sal_Bool bTemplate /* = sal_False */) const
+{
+ if ( nFileFormat == SOFFICE_FILEFORMAT_60 )
+ {
+ *pClassName = SvGlobalName( SO3_SC_CLASSID_60 );
+ *pFormat = SOT_FORMATSTR_ID_STARCALC_60;
+ *pFullTypeName = String( ScResId( SCSTR_LONG_SCDOC_NAME ) );
+ *pShortTypeName = String( ScResId( SCSTR_SHORT_SCDOC_NAME ) );
+ }
+ else if ( nFileFormat == SOFFICE_FILEFORMAT_8 )
+ {
+ *pClassName = SvGlobalName( SO3_SC_CLASSID_60 );
+ *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARCALC_8_TEMPLATE : SOT_FORMATSTR_ID_STARCALC_8;
+ *pFullTypeName = String( RTL_CONSTASCII_USTRINGPARAM("calc8") );
+ *pShortTypeName = String( ScResId( SCSTR_SHORT_SCDOC_NAME ) );
+ }
+ else
+ {
+ DBG_ERROR("wat fuer ne Version?");
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::DoEnterHandler()
+{
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if (pViewSh)
+ if (pViewSh->GetViewData()->GetDocShell() == this)
+ SC_MOD()->InputEnterHandler();
+}
+
+//------------------------------------------------------------------
+
+SCTAB ScDocShell::GetSaveTab()
+{
+ SCTAB nTab = 0;
+ ScTabViewShell* pSh = GetBestViewShell();
+ if (pSh)
+ {
+ const ScMarkData& rMark = pSh->GetViewData()->GetMarkData();
+ for ( nTab = 0; nTab <= MAXTAB; nTab++ ) // erste markierte Tabelle
+ if ( rMark.GetTableSelect( nTab ) )
+ break;
+ }
+ return nTab;
+}
+
+sal_uInt16 ScDocShell::GetHiddenInformationState( sal_uInt16 nStates )
+{
+ // get global state like HIDDENINFORMATION_DOCUMENTVERSIONS
+ sal_uInt16 nState = SfxObjectShell::GetHiddenInformationState( nStates );
+
+ if ( nStates & HIDDENINFORMATION_RECORDEDCHANGES )
+ {
+ if ( aDocument.GetChangeTrack() && aDocument.GetChangeTrack()->GetFirst() )
+ nState |= HIDDENINFORMATION_RECORDEDCHANGES;
+ }
+ if ( nStates & HIDDENINFORMATION_NOTES )
+ {
+ SCTAB nTableCount = aDocument.GetTableCount();
+ SCTAB nTable = 0;
+ sal_Bool bFound(sal_False);
+ while ( nTable < nTableCount && !bFound )
+ {
+ ScCellIterator aCellIter( &aDocument, 0,0, nTable, MAXCOL,MAXROW, nTable );
+ for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bFound; pCell = aCellIter.GetNext() )
+ if (pCell->HasNote())
+ bFound = sal_True;
+ nTable++;
+ }
+
+ if (bFound)
+ nState |= HIDDENINFORMATION_NOTES;
+ }
+
+ return nState;
+}
+
+void ScDocShell::BeforeXMLLoading()
+{
+ aDocument.DisableIdle( TRUE );
+
+ // prevent unnecessary broadcasts and updates
+ DBG_ASSERT(pModificator == NULL, "The Modificator should not exist");
+ pModificator = new ScDocShellModificator( *this );
+
+ aDocument.SetImportingXML( TRUE );
+ aDocument.EnableExecuteLink( false ); // #i101304# to be safe, prevent nested loading from external references
+ aDocument.EnableUndo( FALSE );
+ // prevent unnecessary broadcasts and "half way listeners"
+ aDocument.SetInsertingFromOtherDoc( TRUE );
+
+ if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+ ScColumn::bDoubleAlloc = sal_True;
+}
+
+void ScDocShell::AfterXMLLoading(sal_Bool bRet)
+{
+ if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+ {
+ UpdateLinks();
+ // don't prevent establishing of listeners anymore
+ aDocument.SetInsertingFromOtherDoc( FALSE );
+ if ( bRet )
+ {
+ ScChartListenerCollection* pChartListener = aDocument.GetChartListenerCollection();
+ if (pChartListener)
+ pChartListener->UpdateDirtyCharts();
+
+ // #95582#; set the table names of linked tables to the new path
+ SCTAB nTabCount = aDocument.GetTableCount();
+ for (SCTAB i = 0; i < nTabCount; ++i)
+ {
+ if (aDocument.IsLinked( i ))
+ {
+ String aName;
+ aDocument.GetName(i, aName);
+ String aLinkTabName = aDocument.GetLinkTab(i);
+ xub_StrLen nLinkTabNameLength = aLinkTabName.Len();
+ xub_StrLen nNameLength = aName.Len();
+ if (nLinkTabNameLength < nNameLength)
+ {
+
+ // remove the quottes on begin and end of the docname and restore the escaped quotes
+ const sal_Unicode* pNameBuffer = aName.GetBuffer();
+ if ( *pNameBuffer == '\'' && // all docnames have to have a ' character on the first pos
+ ScGlobal::UnicodeStrChr( pNameBuffer, SC_COMPILER_FILE_TAB_SEP ) )
+ {
+ rtl::OUStringBuffer aDocURLBuffer;
+ BOOL bQuote = TRUE; // Dokumentenname ist immer quoted
+ ++pNameBuffer;
+ while ( bQuote && *pNameBuffer )
+ {
+ if ( *pNameBuffer == '\'' && *(pNameBuffer-1) != '\\' )
+ bQuote = FALSE;
+ else if( !(*pNameBuffer == '\\' && *(pNameBuffer+1) == '\'') )
+ aDocURLBuffer.append(*pNameBuffer); // falls escaped Quote: nur Quote in den Namen
+ ++pNameBuffer;
+ }
+
+
+ if( *pNameBuffer == SC_COMPILER_FILE_TAB_SEP ) // after the last quote of the docname should be the # char
+ {
+ xub_StrLen nIndex = nNameLength - nLinkTabNameLength;
+ INetURLObject aINetURLObject(aDocURLBuffer.makeStringAndClear());
+ if( aName.Equals(aLinkTabName, nIndex, nLinkTabNameLength) &&
+ (aName.GetChar(nIndex - 1) == '#') && // before the table name should be the # char
+ !aINetURLObject.HasError()) // the docname should be a valid URL
+ {
+ aName = ScGlobal::GetDocTabName( aDocument.GetLinkDoc( i ), aDocument.GetLinkTab( i ) );
+ aDocument.RenameTab(i, aName, TRUE, TRUE);
+ }
+ // else; nothing has to happen, because it is a user given name
+ }
+ // else; nothing has to happen, because it is a user given name
+ }
+ // else; nothing has to happen, because it is a user given name
+ }
+ // else; nothing has to happen, because it is a user given name
+ }
+ }
+
+ // #i94570# DataPilot table names have to be unique, or the tables can't be accessed by API.
+ // If no name (or an invalid name, skipped in ScXMLDataPilotTableContext::EndElement) was set, create a new name.
+ ScDPCollection* pDPCollection = aDocument.GetDPCollection();
+ if ( pDPCollection )
+ {
+ USHORT nDPCount = pDPCollection->GetCount();
+ for (USHORT nDP=0; nDP<nDPCount; nDP++)
+ {
+ ScDPObject* pDPObj = (*pDPCollection)[nDP];
+ if ( !pDPObj->GetName().Len() )
+ pDPObj->SetName( pDPCollection->CreateNewName() );
+ }
+ }
+ }
+ ScColumn::bDoubleAlloc = sal_False;
+ }
+ else
+ aDocument.SetInsertingFromOtherDoc( FALSE );
+
+ aDocument.SetImportingXML( FALSE );
+ aDocument.EnableExecuteLink( true );
+ aDocument.EnableUndo( TRUE );
+ bIsEmpty = FALSE;
+
+ if (pModificator)
+ {
+ delete pModificator;
+ pModificator = NULL;
+ }
+ else
+ {
+ DBG_ERROR("The Modificator should exist");
+ }
+
+ aDocument.DisableIdle( FALSE );
+}
+
+namespace {
+
+class LoadMediumGuard
+{
+public:
+ explicit LoadMediumGuard(ScDocument* pDoc) :
+ mpDoc(pDoc)
+ {
+ mpDoc->SetLoadingMedium(true);
+ }
+
+ ~LoadMediumGuard()
+ {
+ mpDoc->SetLoadingMedium(false);
+ }
+private:
+ ScDocument* mpDoc;
+};
+
+}
+
+BOOL ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor )
+{
+ LoadMediumGuard aLoadGuard(&aDocument);
+
+ // MacroCallMode is no longer needed, state is kept in SfxObjectShell now
+
+ // no Seek(0) here - always loading from storage, GetInStream must not be called
+
+ BeforeXMLLoading();
+
+ // #i62677# BeforeXMLLoading is also called from ScXMLImport::startDocument when invoked
+ // from an external component. The XMLFromWrapper flag is only set here, when called
+ // through ScDocShell.
+ aDocument.SetXMLFromWrapper( TRUE );
+
+ ScXMLImportWrapper aImport( aDocument, pLoadMedium, xStor );
+
+ sal_Bool bRet(sal_False);
+ ErrCode nError = ERRCODE_NONE;
+ if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+ bRet = aImport.Import(sal_False, nError);
+ else
+ bRet = aImport.Import(sal_True, nError);
+
+ if ( nError )
+ pLoadMedium->SetError( nError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+
+ aDocument.SetXMLFromWrapper( FALSE );
+ AfterXMLLoading(bRet);
+
+ //! row heights...
+
+ return bRet;
+}
+
+BOOL ScDocShell::SaveXML( SfxMedium* pSaveMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScDocShell::SaveXML" );
+
+ aDocument.DisableIdle( TRUE );
+
+ ScXMLImportWrapper aImport( aDocument, pSaveMedium, xStor );
+ sal_Bool bRet(sal_False);
+ if (GetCreateMode() != SFX_CREATE_MODE_ORGANIZER)
+ bRet = aImport.Export(sal_False);
+ else
+ bRet = aImport.Export(sal_True);
+
+ aDocument.DisableIdle( FALSE );
+
+ return bRet;
+}
+
+BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Load" );
+ LoadMediumGuard aLoadGuard(&aDocument);
+ ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
+
+ // only the latin script language is loaded
+ // -> initialize the others from options (before loading)
+ InitOptions(true);
+
+ GetUndoManager()->Clear();
+
+ BOOL bRet = SfxObjectShell::Load( rMedium );
+ if( bRet )
+ {
+ if (GetMedium())
+ {
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
+ nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
+ }
+
+ {
+ // prepare a valid document for XML filter
+ // (for ConvertFrom, InitNew is called before)
+ aDocument.MakeTable(0);
+ aDocument.GetStyleSheetPool()->CreateStandardStyles();
+ aDocument.UpdStlShtPtrsFrmNms();
+
+ bRet = LoadXML( &rMedium, NULL );
+ }
+ }
+
+ if (!bRet && !rMedium.GetError())
+ rMedium.SetError( SVSTREAM_FILEFORMAT_ERROR, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+
+ if (rMedium.GetError())
+ SetError( rMedium.GetError(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+
+ InitItems();
+ CalcOutputFactor();
+
+ // #73762# invalidate eventually temporary table areas
+ if ( bRet )
+ aDocument.InvalidateTableArea();
+
+ bIsEmpty = FALSE;
+ FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES );
+ return bRet;
+}
+
+void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor();
+ if ( xVbaEvents.is() ) try
+ {
+ using namespace ::com::sun::star::script::vba::VBAEventId;
+ if (rHint.ISA(ScTablesHint) )
+ {
+ const ScTablesHint& rScHint = static_cast< const ScTablesHint& >( rHint );
+ if (rScHint.GetId() == SC_TAB_INSERTED)
+ {
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[0] <<= rScHint.GetTab1();
+ xVbaEvents->processVbaEvent( WORKBOOK_NEWSHEET, aArgs );
+ }
+ }
+ else if ( rHint.ISA( SfxEventHint ) )
+ {
+ ULONG nEventId = static_cast< const SfxEventHint& >( rHint ).GetEventId();
+ switch ( nEventId )
+ {
+ case SFX_EVENT_ACTIVATEDOC:
+ {
+ uno::Sequence< uno::Any > aArgs;
+ xVbaEvents->processVbaEvent( WORKBOOK_ACTIVATE, aArgs );
+ }
+ break;
+ case SFX_EVENT_DEACTIVATEDOC:
+ {
+ uno::Sequence< uno::Any > aArgs;
+ xVbaEvents->processVbaEvent( WORKBOOK_DEACTIVATE, aArgs );
+ }
+ break;
+ case SFX_EVENT_OPENDOC:
+ {
+ uno::Sequence< uno::Any > aArgs;
+ xVbaEvents->processVbaEvent( WORKBOOK_OPEN, aArgs );
+ }
+ break;
+ case SFX_EVENT_SAVEDOCDONE:
+ case SFX_EVENT_SAVEASDOCDONE:
+ case SFX_EVENT_SAVETODOCDONE:
+ {
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= true;
+ xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs );
+ }
+ break;
+ case SFX_EVENT_SAVEASDOCFAILED:
+ case SFX_EVENT_SAVEDOCFAILED:
+ case SFX_EVENT_SAVETODOCFAILED:
+ {
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= false;
+ xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs );
+ }
+ break;
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ if (rHint.ISA(SfxSimpleHint)) // ohne Parameter
+ {
+ ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId();
+ switch ( nSlot )
+ {
+ case SFX_HINT_TITLECHANGED:
+ aDocument.SetName( SfxShell::GetName() );
+ // RegisterNewTargetNames gibts nicht mehr
+ SFX_APP()->Broadcast(SfxSimpleHint( SC_HINT_DOCNAME_CHANGED )); // Navigator
+ break;
+ }
+ }
+ else if (rHint.ISA(SfxStyleSheetHint)) // Vorlagen geaendert
+ NotifyStyle((const SfxStyleSheetHint&) rHint);
+ else if (rHint.ISA(ScAutoStyleHint))
+ {
+ //! direct call for AutoStyles
+
+ // this is called synchronously from ScInterpreter::ScStyle,
+ // modifying the document must be asynchronous
+ // (handled by AddInitial)
+
+ ScAutoStyleHint& rStlHint = (ScAutoStyleHint&)rHint;
+ ScRange aRange = rStlHint.GetRange();
+ String aName1 = rStlHint.GetStyle1();
+ String aName2 = rStlHint.GetStyle2();
+ UINT32 nTimeout = rStlHint.GetTimeout();
+
+ if (!pAutoStyleList)
+ pAutoStyleList = new ScAutoStyleList(this);
+ pAutoStyleList->AddInitial( aRange, aName1, nTimeout, aName2 );
+ }
+ else if ( rHint.ISA( SfxEventHint ) )
+ {
+ ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
+ switch ( nEventId )
+ {
+ case SFX_EVENT_LOADFINISHED:
+ {
+ // the readonly documents should not be opened in shared mode
+ if ( HasSharedXMLFlagSet() && !SC_MOD()->IsInSharedDocLoading() && !IsReadOnly() )
+ {
+ if ( SwitchToShared( sal_True, sal_False ) )
+ {
+ ScViewData* pViewData = GetViewData();
+ ScTabView* pTabView = ( pViewData ? dynamic_cast< ScTabView* >( pViewData->GetView() ) : NULL );
+ if ( pTabView )
+ {
+ pTabView->UpdateLayerLocks();
+ }
+ }
+ else
+ {
+ // switching to shared mode has failed, the document should be opened readonly
+ // TODO/LATER: And error message should be shown here probably
+ SetReadOnlyUI( sal_True );
+ }
+ }
+
+ // VBA specific initialization
+ if( aDocument.IsInVBAMode() ) try
+ {
+ uno::Reference< frame::XModel > xModel( GetModel(), uno::UNO_SET_THROW );
+
+ // create VBAGlobals object if not yet done (this also creates the "ThisExcelDoc" symbol)
+ uno::Reference< lang::XMultiServiceFactory > xFactory( xModel, uno::UNO_QUERY_THROW );
+ xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) );
+
+ // create the VBA document event processor
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= xModel;
+ xVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( this, "com.sun.star.script.vba.VBASpreadsheetEventProcessor" , aArgs ), uno::UNO_QUERY );
+ aDocument.SetVbaEventProcessor( xVbaEvents );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ break;
+ case SFX_EVENT_VIEWCREATED:
+ {
+ if ( IsDocShared() && !SC_MOD()->IsInSharedDocLoading() )
+ {
+ ScAppOptions aAppOptions = SC_MOD()->GetAppOptions();
+ if ( aAppOptions.GetShowSharedDocumentWarning() )
+ {
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ),
+ ScGlobal::GetRscString( STR_SHARED_DOC_WARNING ) );
+ aBox.SetDefaultCheckBoxText();
+ aBox.Execute();
+ BOOL bChecked = aBox.GetCheckBoxState();
+ if ( bChecked )
+ {
+ aAppOptions.SetShowSharedDocumentWarning( !bChecked );
+ SC_MOD()->SetAppOptions( aAppOptions );
+ }
+ }
+ }
+
+ try
+ {
+ uno::Reference< uno::XComponentContext > xContext;
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
+ uno::Reference< beans::XPropertySet > xProp( xServiceManager, uno::UNO_QUERY_THROW );
+ xProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext;
+ if ( xContext.is() )
+ {
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) );
+ if ( xEnum.is() )
+ {
+ while ( xEnum->hasMoreElements() )
+ {
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference< lang::XSingleComponentFactory > xFactory;
+ aAny >>= xFactory;
+ if ( xFactory.is() )
+ {
+ uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::NamedValue > aArgsForJob(1);
+ ScViewData* pViewData = GetViewData();
+ SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL );
+ SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL );
+ SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL );
+ uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 );
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
+ aArgsForJob[0] = beans::NamedValue( ::rtl::OUString::createFromAscii( "SpreadsheetView" ),
+ uno::makeAny( xSpreadsheetView ) );
+ xJob->execute( aArgsForJob );
+ }
+ }
+ }
+ }
+ }
+ catch ( uno::Exception & )
+ {
+ }
+ }
+ break;
+ case SFX_EVENT_SAVEDOC:
+ {
+ if ( IsDocShared() && !SC_MOD()->IsInSharedDocSaving() )
+ {
+ bool bSuccess = false;
+ bool bRetry = true;
+ while ( bRetry )
+ {
+ bRetry = false;
+ uno::Reference< frame::XModel > xModel;
+ try
+ {
+ // load shared file
+ xModel.set( LoadSharedDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
+
+ // check if shared flag is set in shared file
+ bool bShared = false;
+ ScModelObj* pDocObj = ScModelObj::getImplementation( xModel );
+ ScDocShell* pSharedDocShell = ( pDocObj ? dynamic_cast< ScDocShell* >( pDocObj->GetObjectShell() ) : NULL );
+ if ( pSharedDocShell )
+ {
+ bShared = pSharedDocShell->HasSharedXMLFlagSet();
+ }
+
+ // #i87870# check if shared status was disabled and enabled again
+ bool bOwnEntry = false;
+ bool bEntriesNotAccessible = false;
+ try
+ {
+ ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
+ bOwnEntry = aControlFile.HasOwnEntry();
+ }
+ catch ( uno::Exception& )
+ {
+ bEntriesNotAccessible = true;
+ }
+
+ if ( bShared && bOwnEntry )
+ {
+ uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
+
+ if ( xStorable->isReadonly() )
+ {
+ xCloseable->close( sal_True );
+
+ String aUserName( ScGlobal::GetRscString( STR_UNKNOWN_USER ) );
+ bool bNoLockAccess = false;
+ try
+ {
+ ::svt::DocumentLockFile aLockFile( GetSharedFileURL() );
+ uno::Sequence< ::rtl::OUString > aData = aLockFile.GetLockData();
+ if ( aData.getLength() > LOCKFILE_SYSUSERNAME_ID )
+ {
+ if ( aData[LOCKFILE_OOOUSERNAME_ID].getLength() > 0 )
+ {
+ aUserName = aData[LOCKFILE_OOOUSERNAME_ID];
+ }
+ else if ( aData[LOCKFILE_SYSUSERNAME_ID].getLength() > 0 )
+ {
+ aUserName = aData[LOCKFILE_SYSUSERNAME_ID];
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ bNoLockAccess = true;
+ }
+
+ if ( bNoLockAccess )
+ {
+ // TODO/LATER: in future an error regarding impossibility to open file for writing could be shown
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+ }
+ else
+ {
+ String aMessage( ScGlobal::GetRscString( STR_FILE_LOCKED_SAVE_LATER ) );
+ aMessage.SearchAndReplaceAscii( "%1", aUserName );
+
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_RETRY_CANCEL | WB_DEF_RETRY ), aMessage );
+ if ( aBox.Execute() == RET_RETRY )
+ {
+ bRetry = true;
+ }
+ }
+ }
+ else
+ {
+ // merge changes from shared file into temp file
+ bool bSaveToShared = false;
+ if ( pSharedDocShell )
+ {
+ bSaveToShared = MergeSharedDocument( pSharedDocShell );
+ }
+
+ // close shared file
+ xCloseable->close( sal_True );
+
+ // TODO: keep file lock on shared file
+
+ // store to shared file
+ if ( bSaveToShared )
+ {
+ bool bChangedViewSettings = false;
+ ScChangeViewSettings* pChangeViewSet = aDocument.GetChangeViewSettings();
+ if ( pChangeViewSet && pChangeViewSet->ShowChanges() )
+ {
+ pChangeViewSet->SetShowChanges( FALSE );
+ pChangeViewSet->SetShowAccepted( FALSE );
+ aDocument.SetChangeViewSettings( *pChangeViewSet );
+ bChangedViewSettings = true;
+ }
+
+ uno::Reference< frame::XStorable > xStor( GetModel(), uno::UNO_QUERY_THROW );
+ // TODO/LATER: More entries from the MediaDescriptor might be interesting for the merge
+ uno::Sequence< beans::PropertyValue > aValues(1);
+ aValues[0].Name = ::rtl::OUString::createFromAscii( "FilterName" );
+ aValues[0].Value <<= ::rtl::OUString( GetMedium()->GetFilter()->GetFilterName() );
+
+ SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False);
+ if ( pPasswordItem && pPasswordItem->GetValue().Len() )
+ {
+ aValues.realloc( 2 );
+ aValues[1].Name = ::rtl::OUString::createFromAscii( "Password" );
+ aValues[1].Value <<= ::rtl::OUString( pPasswordItem->GetValue() );
+ }
+
+ SC_MOD()->SetInSharedDocSaving( true );
+ xStor->storeToURL( GetSharedFileURL(), aValues );
+ SC_MOD()->SetInSharedDocSaving( false );
+
+ if ( bChangedViewSettings )
+ {
+ pChangeViewSet->SetShowChanges( TRUE );
+ pChangeViewSet->SetShowAccepted( TRUE );
+ aDocument.SetChangeViewSettings( *pChangeViewSet );
+ }
+ }
+
+ bSuccess = true;
+ GetUndoManager()->Clear();
+ }
+ }
+ else
+ {
+ xCloseable->close( sal_True );
+
+ if ( bEntriesNotAccessible )
+ {
+ // TODO/LATER: in future an error regarding impossibility to write to share control file could be shown
+ ErrorHandler::HandleError( ERRCODE_IO_GENERAL );
+ }
+ else
+ {
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ),
+ ScGlobal::GetRscString( STR_DOC_NOLONGERSHARED ) );
+ aBox.Execute();
+
+ SfxBindings* pBindings = GetViewBindings();
+ if ( pBindings )
+ {
+ pBindings->ExecuteSynchron( SID_SAVEASDOC );
+ }
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR( "SFX_EVENT_SAVEDOC: caught exception\n" );
+ SC_MOD()->SetInSharedDocSaving( false );
+
+ try
+ {
+ uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
+ xClose->close( sal_True );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ }
+
+ if ( !bSuccess )
+ SetError( ERRCODE_IO_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); // this error code will produce no error message, but will break the further saving process
+ }
+ if (pSheetSaveData)
+ pSheetSaveData->SetInSupportedSave(true);
+ }
+ break;
+ case SFX_EVENT_SAVEASDOC:
+ case SFX_EVENT_SAVETODOC:
+ // #i108978# If no event is sent before saving, there will also be no "...DONE" event,
+ // and SAVE/SAVEAS can't be distinguished from SAVETO. So stream copying is only enabled
+ // if there is a SAVE/SAVEAS/SAVETO event first.
+ if (pSheetSaveData)
+ pSheetSaveData->SetInSupportedSave(true);
+ break;
+ case SFX_EVENT_SAVEDOCDONE:
+ {
+ if ( IsDocShared() && !SC_MOD()->IsInSharedDocSaving() )
+ {
+ }
+ UseSheetSaveEntries(); // use positions from saved file for next saving
+ if (pSheetSaveData)
+ pSheetSaveData->SetInSupportedSave(false);
+ }
+ break;
+ case SFX_EVENT_SAVEASDOCDONE:
+ // new positions are used after "save" and "save as", but not "save to"
+ UseSheetSaveEntries(); // use positions from saved file for next saving
+ if (pSheetSaveData)
+ pSheetSaveData->SetInSupportedSave(false);
+ break;
+ case SFX_EVENT_SAVETODOCDONE:
+ // only reset the flag, don't use the new positions
+ if (pSheetSaveData)
+ pSheetSaveData->SetInSupportedSave(false);
+ break;
+ default:
+ {
+ }
+ break;
+ }
+ }
+}
+
+ // Inhalte fuer Organizer laden
+
+
+BOOL __EXPORT ScDocShell::LoadFrom( SfxMedium& rMedium )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::LoadFrom" );
+ LoadMediumGuard aLoadGuard(&aDocument);
+ ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
+
+ WaitObject aWait( GetActiveDialogParent() );
+
+ BOOL bRet = FALSE;
+
+ if (GetMedium())
+ {
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
+ nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
+ }
+
+ // until loading/saving only the styles in XML is implemented,
+ // load the whole file
+ bRet = LoadXML( &rMedium, NULL );
+ InitItems();
+
+ SfxObjectShell::LoadFrom( rMedium );
+
+ return bRet;
+}
+
+static void lcl_parseHtmlFilterOption(const OUString& rOption, LanguageType& rLang, bool& rDateConvert)
+{
+ OUStringBuffer aBuf;
+ OUString aTokens[2];
+ sal_Int32 n = rOption.getLength();
+ const sal_Unicode* p = rOption.getStr();
+ sal_Int32 nTokenId = 0;
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ const sal_Unicode c = p[i];
+ if (c == sal_Unicode(' '))
+ {
+ if (aBuf.getLength())
+ aTokens[nTokenId++] = aBuf.makeStringAndClear();
+ }
+ else
+ aBuf.append(c);
+
+ if (nTokenId >= 2)
+ break;
+ }
+
+ if (aBuf.getLength())
+ aTokens[nTokenId] = aBuf.makeStringAndClear();
+
+ rLang = static_cast<LanguageType>(aTokens[0].toInt32());
+ rDateConvert = static_cast<bool>(aTokens[1].toInt32());
+}
+
+BOOL __EXPORT ScDocShell::ConvertFrom( SfxMedium& rMedium )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertFrom" );
+
+ LoadMediumGuard aLoadGuard(&aDocument);
+
+ BOOL bRet = FALSE; // FALSE heisst Benutzerabbruch !!
+ // bei Fehler: Fehler am Stream setzen!!
+
+ ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
+
+ GetUndoManager()->Clear();
+
+ // ob nach dem Import optimale Spaltenbreiten gesetzt werden sollen
+ BOOL bSetColWidths = FALSE;
+ BOOL bSetSimpleTextColWidths = FALSE;
+ ScColWidthParam aColWidthParam[MAXCOLCOUNT];
+ ScRange aColWidthRange;
+ // ob nach dem Import optimale Zeilenhoehen gesetzt werden sollen
+ BOOL bSetRowHeights = FALSE;
+
+ vector<ScDocRowHeightUpdater::TabRanges> aRecalcRowRangesArray;
+
+ aConvFilterName.Erase(); //@ #BugId 54198
+
+ // Alle Filter brauchen die komplette Datei am Stueck (nicht asynchron),
+ // darum vorher per CreateFileStream dafuer sorgen, dass die komplette
+ // Datei uebertragen wird.
+ rMedium.GetPhysicalName(); //! CreateFileStream direkt rufen, wenn verfuegbar
+
+ SFX_ITEMSET_ARG( rMedium.GetItemSet(), pUpdateDocItem, SfxUInt16Item, SID_UPDATEDOCMODE, sal_False);
+ nCanUpdate = pUpdateDocItem ? pUpdateDocItem->GetValue() : com::sun::star::document::UpdateDocMode::NO_UPDATE;
+
+ const SfxFilter* pFilter = rMedium.GetFilter();
+ if (pFilter)
+ {
+ String aFltName = pFilter->GetFilterName();
+
+ aConvFilterName=aFltName; //@ #BugId 54198
+
+ BOOL bCalc3 = ( aFltName.EqualsAscii(pFilterSc30) );
+ BOOL bCalc4 = ( aFltName.EqualsAscii(pFilterSc40) );
+ if (!bCalc3 && !bCalc4)
+ aDocument.SetInsertingFromOtherDoc( TRUE );
+
+ if (aFltName.EqualsAscii(pFilterXML))
+ bRet = LoadXML( &rMedium, NULL );
+ else if (aFltName.EqualsAscii(pFilterSc10))
+ {
+ SvStream* pStream = rMedium.GetInStream();
+ if (pStream)
+ {
+ FltError eError = ScFormatFilter::Get().ScImportStarCalc10( *pStream, &aDocument );
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ else
+ bRet = TRUE;
+ }
+ }
+ else if (aFltName.EqualsAscii(pFilterLotus))
+ {
+ String sItStr;
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ sItStr = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if (sItStr.Len() == 0)
+ {
+ // default for lotus import (from API without options):
+ // IBM_437 encoding
+ sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_437 );
+ }
+
+ ScColumn::bDoubleAlloc = TRUE;
+ FltError eError = ScFormatFilter::Get().ScImportLotus123( rMedium, &aDocument,
+ ScGlobal::GetCharsetValue(sItStr));
+ ScColumn::bDoubleAlloc = FALSE;
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+
+ if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE;
+ bSetColWidths = TRUE;
+ bSetRowHeights = TRUE;
+ }
+ else if ( aFltName.EqualsAscii(pFilterExcel4) || aFltName.EqualsAscii(pFilterExcel5) ||
+ aFltName.EqualsAscii(pFilterExcel95) || aFltName.EqualsAscii(pFilterExcel97) ||
+ aFltName.EqualsAscii(pFilterEx4Temp) || aFltName.EqualsAscii(pFilterEx5Temp) ||
+ aFltName.EqualsAscii(pFilterEx95Temp) || aFltName.EqualsAscii(pFilterEx97Temp) )
+ {
+ EXCIMPFORMAT eFormat = EIF_AUTO;
+ if ( aFltName.EqualsAscii(pFilterExcel4) || aFltName.EqualsAscii(pFilterEx4Temp) )
+ eFormat = EIF_BIFF_LE4;
+ else if ( aFltName.EqualsAscii(pFilterExcel5) || aFltName.EqualsAscii(pFilterExcel95) ||
+ aFltName.EqualsAscii(pFilterEx5Temp) || aFltName.EqualsAscii(pFilterEx95Temp) )
+ eFormat = EIF_BIFF5;
+ else if ( aFltName.EqualsAscii(pFilterExcel97) || aFltName.EqualsAscii(pFilterEx97Temp) )
+ eFormat = EIF_BIFF8;
+
+ MakeDrawLayer(); //! im Filter
+ CalcOutputFactor(); // #93255# prepare update of row height
+ ScColumn::bDoubleAlloc = TRUE;
+ FltError eError = ScFormatFilter::Get().ScImportExcel( rMedium, &aDocument, eFormat );
+ ScColumn::bDoubleAlloc = FALSE;
+ aDocument.UpdateFontCharSet();
+ if ( aDocument.IsChartListenerCollectionNeedsUpdate() )
+ aDocument.UpdateChartListenerCollection(); //! fuer alle Importe?
+
+ // #75299# all graphics objects must have names
+ aDocument.EnsureGraphicNames();
+
+ if (eError == SCWARN_IMPORT_RANGE_OVERFLOW)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ bRet = TRUE;
+ }
+ else if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ else
+ bRet = TRUE;
+
+ // #93255# update of row height done inside of Excel filter to speed up chart import
+// bSetRowHeights = TRUE; // #75357# optimal row heights must be updated
+ }
+ else if (aFltName.EqualsAscii(pFilterAscii))
+ {
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ ScAsciiOptions aOptions;
+ BOOL bOptInit = FALSE;
+
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ aOptions.ReadFromString( ((const SfxStringItem*)pItem)->GetValue() );
+ bOptInit = TRUE;
+ }
+
+ if ( !bOptInit )
+ {
+ // default for ascii import (from API without options):
+ // ISO8859-1/MS_1252 encoding, comma, double quotes
+
+ aOptions.SetCharSet( RTL_TEXTENCODING_MS_1252 );
+ aOptions.SetFieldSeps( (sal_Unicode) ',' );
+ aOptions.SetTextSep( (sal_Unicode) '"' );
+ }
+
+ FltError eError = eERR_OK;
+ BOOL bOverflow = FALSE;
+
+ if( ! rMedium.IsStorage() )
+ {
+ ScImportExport aImpEx( &aDocument );
+ aImpEx.SetExtOptions( aOptions );
+
+ SvStream* pInStream = rMedium.GetInStream();
+ if (pInStream)
+ {
+ pInStream->SetStreamCharSet( aOptions.GetCharSet() );
+ pInStream->Seek( 0 );
+ bRet = aImpEx.ImportStream( *pInStream, rMedium.GetBaseURL() );
+ eError = bRet ? eERR_OK : SCERR_IMPORT_CONNECT;
+ aDocument.StartAllListeners();
+ aDocument.SetDirty();
+ bOverflow = aImpEx.IsOverflow();
+ }
+ else
+ {
+ DBG_ERROR( "No Stream" );
+ }
+ }
+
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ else if ( bOverflow )
+ {
+ if (!GetError())
+ SetError(SCWARN_IMPORT_RANGE_OVERFLOW, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ bSetColWidths = TRUE;
+ bSetSimpleTextColWidths = TRUE;
+ }
+ else if (aFltName.EqualsAscii(pFilterDBase))
+ {
+ String sItStr;
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ sItStr = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if (sItStr.Len() == 0)
+ {
+ // default for dBase import (from API without options):
+ // IBM_850 encoding
+
+ sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
+ }
+
+ ScDocRowHeightUpdater::TabRanges aRecalcRanges(0);
+ ULONG eError = DBaseImport( rMedium.GetPhysicalName(),
+ ScGlobal::GetCharsetValue(sItStr), aColWidthParam, *aRecalcRanges.mpRanges );
+ aRecalcRowRangesArray.push_back(aRecalcRanges);
+
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ bRet = ( eError == SCWARN_IMPORT_RANGE_OVERFLOW );
+ }
+ else
+ bRet = TRUE;
+
+ aColWidthRange.aStart.SetRow( 1 ); // Spaltenheader nicht
+ bSetColWidths = TRUE;
+ bSetSimpleTextColWidths = TRUE;
+ }
+ else if (aFltName.EqualsAscii(pFilterDif))
+ {
+ SvStream* pStream = rMedium.GetInStream();
+ if (pStream)
+ {
+ FltError eError;
+ String sItStr;
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ sItStr = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if (sItStr.Len() == 0)
+ {
+ // default for DIF import (from API without options):
+ // ISO8859-1/MS_1252 encoding
+
+ sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
+ }
+
+ eError = ScFormatFilter::Get().ScImportDif( *pStream, &aDocument, ScAddress(0,0,0),
+ ScGlobal::GetCharsetValue(sItStr));
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+
+ if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE;
+ }
+ bSetColWidths = TRUE;
+ bSetSimpleTextColWidths = TRUE;
+ bSetRowHeights = TRUE;
+ }
+ else if (aFltName.EqualsAscii(pFilterSylk))
+ {
+ FltError eError = SCERR_IMPORT_UNKNOWN;
+ if( !rMedium.IsStorage() )
+ {
+ ScImportExport aImpEx( &aDocument );
+
+ SvStream* pInStream = rMedium.GetInStream();
+ if (pInStream)
+ {
+ pInStream->Seek( 0 );
+ bRet = aImpEx.ImportStream( *pInStream, rMedium.GetBaseURL(), SOT_FORMATSTR_ID_SYLK );
+ eError = bRet ? eERR_OK : SCERR_IMPORT_UNKNOWN;
+ aDocument.StartAllListeners();
+ aDocument.SetDirty();
+ }
+ else
+ {
+ DBG_ERROR( "No Stream" );
+ }
+ }
+
+ if ( eError != eERR_OK && !GetError() )
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ bSetColWidths = TRUE;
+ bSetSimpleTextColWidths = TRUE;
+ bSetRowHeights = TRUE;
+ }
+ else if (aFltName.EqualsAscii(pFilterQPro6))
+ {
+ ScColumn::bDoubleAlloc = TRUE;
+ FltError eError = ScFormatFilter::Get().ScImportQuattroPro( rMedium, &aDocument);
+ ScColumn::bDoubleAlloc = FALSE;
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError( eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE;
+ // TODO: Filter should set column widths. Not doing it here, it may
+ // result in very narrow or wide columns, depending on content.
+ // Setting row heights makes cells with font size attribution or
+ // wrapping enabled look nicer..
+ bSetRowHeights = TRUE;
+ }
+ else if (aFltName.EqualsAscii(pFilterRtf))
+ {
+ FltError eError = SCERR_IMPORT_UNKNOWN;
+ if( !rMedium.IsStorage() )
+ {
+ SvStream* pInStream = rMedium.GetInStream();
+ if (pInStream)
+ {
+ pInStream->Seek( 0 );
+ ScRange aRange;
+ eError = ScFormatFilter::Get().ScImportRTF( *pInStream, rMedium.GetBaseURL(), &aDocument, aRange );
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+
+ if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE;
+ aDocument.StartAllListeners();
+ aDocument.SetDirty();
+ bSetColWidths = TRUE;
+ bSetRowHeights = TRUE;
+ }
+ else
+ {
+ DBG_ERROR( "No Stream" );
+ }
+ }
+
+ if ( eError != eERR_OK && !GetError() )
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ else if (aFltName.EqualsAscii(pFilterHtml) || aFltName.EqualsAscii(pFilterHtmlWebQ))
+ {
+ FltError eError = SCERR_IMPORT_UNKNOWN;
+ BOOL bWebQuery = aFltName.EqualsAscii(pFilterHtmlWebQ);
+ if( !rMedium.IsStorage() )
+ {
+ SvStream* pInStream = rMedium.GetInStream();
+ if (pInStream)
+ {
+ LanguageType eLang = LANGUAGE_SYSTEM;
+ bool bDateConvert = false;
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ String aFilterOption = (static_cast<const SfxStringItem*>(pItem))->GetValue();
+ lcl_parseHtmlFilterOption(aFilterOption, eLang, bDateConvert);
+ }
+
+ pInStream->Seek( 0 );
+ ScRange aRange;
+ // HTML macht eigenes ColWidth/RowHeight
+ CalcOutputFactor();
+ SvNumberFormatter aNumFormatter(aDocument.GetServiceManager(), eLang);
+ eError = ScFormatFilter::Get().ScImportHTML( *pInStream, rMedium.GetBaseURL(), &aDocument, aRange,
+ GetOutputFactor(), !bWebQuery, &aNumFormatter, bDateConvert );
+ if (eError != eERR_OK)
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+
+ if( ( eError & ERRCODE_WARNING_MASK ) == ERRCODE_WARNING_MASK )
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE;
+ aDocument.StartAllListeners();
+ aDocument.SetDirty();
+ }
+ else
+ {
+ DBG_ERROR( "No Stream" );
+ }
+ }
+
+ if ( eError != eERR_OK && !GetError() )
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ else
+ {
+ if (!GetError())
+ SetError(SCERR_IMPORT_NI, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+
+ if (!bCalc3)
+ aDocument.SetInsertingFromOtherDoc( FALSE );
+ }
+ else
+ {
+ DBG_ERROR("Kein Filter bei ConvertFrom");
+ }
+
+ InitItems();
+ CalcOutputFactor();
+ if ( bRet && (bSetColWidths || bSetRowHeights) )
+ { // Spaltenbreiten/Zeilenhoehen anpassen, Basis 100% Zoom
+ Fraction aZoom( 1, 1 );
+ double nPPTX = ScGlobal::nScreenPPTX * (double) aZoom
+ / GetOutputFactor(); // Faktor ist Drucker zu Bildschirm
+ double nPPTY = ScGlobal::nScreenPPTY * (double) aZoom;
+ VirtualDevice aVirtDev;
+ // all sheets (for Excel import)
+ SCTAB nTabCount = aDocument.GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ aDocument.GetCellArea( nTab, nEndCol, nEndRow );
+ aColWidthRange.aEnd.SetCol( nEndCol );
+ aColWidthRange.aEnd.SetRow( nEndRow );
+ ScMarkData aMark;
+ aMark.SetMarkArea( aColWidthRange );
+ aMark.MarkToMulti();
+ // Reihenfolge erst Breite dann Hoehe ist wichtig (vergl. hund.rtf)
+ if ( bSetColWidths )
+ {
+ for ( SCCOL nCol=0; nCol <= nEndCol; nCol++ )
+ {
+ if (!bSetSimpleTextColWidths)
+ aColWidthParam[nCol].mbSimpleText = false;
+
+ USHORT nWidth = aDocument.GetOptimalColWidth(
+ nCol, nTab, &aVirtDev, nPPTX, nPPTY, aZoom, aZoom, FALSE, &aMark,
+ &aColWidthParam[nCol] );
+ aDocument.SetColWidth( nCol, nTab,
+ nWidth + (USHORT)ScGlobal::nLastColWidthExtra );
+ }
+ }
+// if ( bSetRowHeights )
+// {
+// // nExtra must be 0
+// aDocument.SetOptimalHeight( 0, nEndRow, nTab, 0, &aVirtDev,
+// nPPTX, nPPTY, aZoom, aZoom, FALSE );
+// }
+ }
+
+ if (bSetRowHeights)
+ {
+ // Update all rows in all tables.
+ ScSizeDeviceProvider aProv(this);
+ ScDocRowHeightUpdater aUpdater(aDocument, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), NULL);
+ aUpdater.update();
+ }
+ else if (!aRecalcRowRangesArray.empty())
+ {
+ // Update only specified row ranges for better performance.
+ ScSizeDeviceProvider aProv(this);
+ ScDocRowHeightUpdater aUpdater(aDocument, aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), &aRecalcRowRangesArray);
+ aUpdater.update();
+ }
+ }
+ FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES );
+
+
+ // #73762# invalidate eventually temporary table areas
+ if ( bRet )
+ aDocument.InvalidateTableArea();
+
+ bIsEmpty = FALSE;
+
+ return bRet;
+}
+
+
+ScDocShell::PrepareSaveGuard::PrepareSaveGuard( ScDocShell& rDocShell )
+ : mrDocShell( rDocShell)
+{
+ // DoEnterHandler not here (because of AutoSave), is in ExecuteSave.
+
+ ScChartListenerCollection* pCharts = mrDocShell.aDocument.GetChartListenerCollection();
+ if (pCharts)
+ pCharts->UpdateDirtyCharts(); // Charts to be updated.
+ mrDocShell.aDocument.StopTemporaryChartLock();
+ if (mrDocShell.pAutoStyleList)
+ mrDocShell.pAutoStyleList->ExecuteAllNow(); // Execute template timeouts now.
+ if (mrDocShell.aDocument.HasExternalRefManager())
+ {
+ ScExternalRefManager* pRefMgr = mrDocShell.aDocument.GetExternalRefManager();
+ if (pRefMgr && pRefMgr->hasExternalData())
+ {
+ pRefMgr->setAllCacheTableReferencedStati( false);
+ mrDocShell.aDocument.MarkUsedExternalReferences(); // Mark tables of external references to be written.
+ }
+ }
+ if (mrDocShell.GetCreateMode()== SFX_CREATE_MODE_STANDARD)
+ mrDocShell.SfxObjectShell::SetVisArea( Rectangle() ); // "Normally" worked on => no VisArea.
+}
+
+ScDocShell::PrepareSaveGuard::~PrepareSaveGuard()
+{
+ if (mrDocShell.aDocument.HasExternalRefManager())
+ {
+ ScExternalRefManager* pRefMgr = mrDocShell.aDocument.GetExternalRefManager();
+ if (pRefMgr && pRefMgr->hasExternalData())
+ {
+ // Prevent accidental data loss due to lack of knowledge.
+ pRefMgr->setAllCacheTableReferencedStati( true);
+ }
+ }
+}
+
+
+BOOL __EXPORT ScDocShell::Save()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::Save" );
+
+ ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
+
+ PrepareSaveGuard aPrepareGuard( *this);
+
+ // wait cursor is handled with progress bar
+ BOOL bRet = SfxObjectShell::Save();
+ if( bRet )
+ bRet = SaveXML( GetMedium(), NULL );
+ return bRet;
+}
+
+
+BOOL __EXPORT ScDocShell::SaveAs( SfxMedium& rMedium )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::SaveAs" );
+
+#if ENABLE_SHEET_PROTECTION
+ ScTabViewShell* pViewShell = GetBestViewShell();
+ bool bNeedsRehash = ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_SHA1);
+ if (bNeedsRehash)
+ // legacy xls hash double-hashed by SHA1 is also supported.
+ bNeedsRehash = ScPassHashHelper::needsPassHashRegen(aDocument, PASSHASH_XL, PASSHASH_SHA1);
+
+ if (pViewShell && bNeedsRehash)
+ {
+ if (!pViewShell->ExecuteRetypePassDlg(PASSHASH_SHA1))
+ // password re-type cancelled. Don't save the document.
+ return false;
+ }
+#endif
+
+ ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
+
+ PrepareSaveGuard aPrepareGuard( *this);
+
+ // wait cursor is handled with progress bar
+ BOOL bRet = SfxObjectShell::SaveAs( rMedium );
+ if( bRet )
+ bRet = SaveXML( &rMedium, NULL );
+
+ return bRet;
+}
+
+
+BOOL __EXPORT ScDocShell::IsInformationLost()
+{
+/*
+ const SfxFilter *pFilt = GetMedium()->GetFilter();
+ BOOL bRet = pFilt && pFilt->IsAlienFormat() && bNoInformLost;
+ if (bNoInformLost) // nur einmal!!
+ bNoInformLost = FALSE;
+ return bRet;
+*/
+ //!!! bei Gelegenheit ein korrekte eigene Behandlung einbauen
+
+ return SfxObjectShell::IsInformationLost();
+}
+
+
+// Xcl-like column width measured in characters of standard font.
+xub_StrLen lcl_ScDocShell_GetColWidthInChars( USHORT nWidth )
+{
+ // double fColScale = 1.0;
+ double f = nWidth;
+ f *= 1328.0 / 25.0;
+ f += 90.0;
+ f *= 1.0 / 23.0;
+ // f /= fColScale * 256.0;
+ f /= 256.0;
+
+ return xub_StrLen( f );
+}
+
+
+void lcl_ScDocShell_GetFixedWidthString( String& rStr, const ScDocument& rDoc,
+ SCTAB nTab, SCCOL nCol, BOOL bValue, SvxCellHorJustify eHorJust )
+{
+ xub_StrLen nLen = lcl_ScDocShell_GetColWidthInChars(
+ rDoc.GetColWidth( nCol, nTab ) );
+ if ( nLen < rStr.Len() )
+ {
+ if ( bValue )
+ rStr.AssignAscii( "###" );
+ rStr.Erase( nLen );
+ }
+ if ( nLen > rStr.Len() )
+ {
+ if ( bValue && eHorJust == SVX_HOR_JUSTIFY_STANDARD )
+ eHorJust = SVX_HOR_JUSTIFY_RIGHT;
+ switch ( eHorJust )
+ {
+ case SVX_HOR_JUSTIFY_RIGHT:
+ {
+ String aTmp;
+ aTmp.Fill( nLen - rStr.Len() );
+ rStr.Insert( aTmp, 0 );
+ }
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ {
+ xub_StrLen nLen2 = (nLen - rStr.Len()) / 2;
+ String aTmp;
+ aTmp.Fill( nLen2 );
+ rStr.Insert( aTmp, 0 );
+ rStr.Expand( nLen );
+ }
+ break;
+ default:
+ rStr.Expand( nLen );
+ }
+ }
+}
+
+
+void lcl_ScDocShell_WriteEmptyFixedWidthString( SvStream& rStream,
+ const ScDocument& rDoc, SCTAB nTab, SCCOL nCol )
+{
+ String aString;
+ lcl_ScDocShell_GetFixedWidthString( aString, rDoc, nTab, nCol, FALSE,
+ SVX_HOR_JUSTIFY_STANDARD );
+ rStream.WriteUnicodeOrByteText( aString );
+}
+
+
+void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt )
+{
+ sal_Unicode cDelim = rAsciiOpt.nFieldSepCode;
+ sal_Unicode cStrDelim = rAsciiOpt.nTextSepCode;
+ CharSet eCharSet = rAsciiOpt.eCharSet;
+ BOOL bFixedWidth = rAsciiOpt.bFixedWidth;
+ BOOL bSaveAsShown = rAsciiOpt.bSaveAsShown;
+
+ CharSet eOldCharSet = rStream.GetStreamCharSet();
+ rStream.SetStreamCharSet( eCharSet );
+ USHORT nOldNumberFormatInt = rStream.GetNumberFormatInt();
+ ByteString aStrDelimEncoded; // only used if not Unicode
+ UniString aStrDelimDecoded; // only used if context encoding
+ BOOL bContextOrNotAsciiEncoding;
+ if ( eCharSet == RTL_TEXTENCODING_UNICODE )
+ {
+ rStream.StartWritingUnicodeText();
+ bContextOrNotAsciiEncoding = FALSE;
+ }
+ else
+ {
+ aStrDelimEncoded = ByteString( cStrDelim, eCharSet );
+ rtl_TextEncodingInfo aInfo;
+ aInfo.StructSize = sizeof(aInfo);
+ if ( rtl_getTextEncodingInfo( eCharSet, &aInfo ) )
+ {
+ bContextOrNotAsciiEncoding =
+ (((aInfo.Flags & RTL_TEXTENCODING_INFO_CONTEXT) != 0) ||
+ ((aInfo.Flags & RTL_TEXTENCODING_INFO_ASCII) == 0));
+ if ( bContextOrNotAsciiEncoding )
+ aStrDelimDecoded = String( aStrDelimEncoded, eCharSet );
+ }
+ else
+ bContextOrNotAsciiEncoding = FALSE;
+ }
+
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nTab = GetSaveTab();
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ aDocument.GetCellArea( nTab, nEndCol, nEndRow );
+
+ ScProgress aProgress( this, ScGlobal::GetRscString( STR_SAVE_DOC ), nEndRow );
+
+ String aString;
+
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ const ScViewOptions& rOpt = (pViewSh)
+ ? pViewSh->GetViewData()->GetOptions()
+ : aDocument.GetViewOptions();
+ BOOL bShowFormulas = rOpt.GetOption( VOPT_FORMULAS );
+ BOOL bTabProtect = aDocument.IsTabProtected( nTab );
+
+ SCCOL nCol;
+ SCROW nRow;
+ SCCOL nNextCol = nStartCol;
+ SCROW nNextRow = nStartRow;
+ SCCOL nEmptyCol;
+ SCROW nEmptyRow;
+ SvNumberFormatter& rFormatter = *aDocument.GetFormatTable();
+
+ ScHorizontalCellIterator aIter( &aDocument, nTab, nStartCol, nStartRow,
+ nEndCol, nEndRow );
+ ScBaseCell* pCell;
+ while ( ( pCell = aIter.GetNext( nCol, nRow ) ) != NULL )
+ {
+ BOOL bProgress = FALSE; // only upon line change
+ if ( nNextRow < nRow )
+ { // empty rows or/and empty columns up to end of row
+ bProgress = TRUE;
+ for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
+ { // remaining columns of last row
+ if ( bFixedWidth )
+ lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
+ aDocument, nTab, nEmptyCol );
+ else if ( cDelim != 0 )
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ endlub( rStream );
+ nNextRow++;
+ for ( nEmptyRow = nNextRow; nEmptyRow < nRow; nEmptyRow++ )
+ { // completely empty rows
+ for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
+ {
+ if ( bFixedWidth )
+ lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
+ aDocument, nTab, nEmptyCol );
+ else if ( cDelim != 0 )
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ endlub( rStream );
+ }
+ for ( nEmptyCol = nStartCol; nEmptyCol < nCol; nEmptyCol++ )
+ { // empty columns at beginning of row
+ if ( bFixedWidth )
+ lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
+ aDocument, nTab, nEmptyCol );
+ else if ( cDelim != 0 )
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ nNextRow = nRow;
+ }
+ else if ( nNextCol < nCol )
+ { // empty columns in same row
+ for ( nEmptyCol = nNextCol; nEmptyCol < nCol; nEmptyCol++ )
+ { // columns in between
+ if ( bFixedWidth )
+ lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
+ aDocument, nTab, nEmptyCol );
+ else if ( cDelim != 0 )
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ }
+ if ( nCol == nEndCol )
+ {
+ bProgress = TRUE;
+ nNextCol = nStartCol;
+ nNextRow = nRow + 1;
+ }
+ else
+ nNextCol = nCol + 1;
+
+ CellType eType = pCell->GetCellType();
+ if ( bTabProtect )
+ {
+ const ScProtectionAttr* pProtAttr =
+ (const ScProtectionAttr*) aDocument.GetAttr(
+ nCol, nRow, nTab, ATTR_PROTECTION );
+ if ( pProtAttr->GetHideCell() ||
+ ( eType == CELLTYPE_FORMULA && bShowFormulas &&
+ pProtAttr->GetHideFormula() ) )
+ eType = CELLTYPE_NONE; // hide
+ }
+ BOOL bString;
+ switch ( eType )
+ {
+ case CELLTYPE_NOTE:
+ case CELLTYPE_NONE:
+ aString.Erase();
+ bString = FALSE;
+ break;
+ case CELLTYPE_FORMULA :
+ {
+ USHORT nErrCode;
+ if ( bShowFormulas )
+ {
+ ((ScFormulaCell*)pCell)->GetFormula( aString );
+ bString = TRUE;
+ }
+ else if ( ( nErrCode = ((ScFormulaCell*)pCell)->GetErrCode() ) != 0 )
+ {
+ aString = ScGlobal::GetErrorString( nErrCode );
+ bString = TRUE;
+ }
+ else if ( ((ScFormulaCell*)pCell)->IsValue() )
+ {
+ sal_uInt32 nFormat;
+ aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
+ if ( bFixedWidth || bSaveAsShown )
+ {
+ Color* pDummy;
+ ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
+ bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
+ }
+ else
+ {
+ ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
+ bString = FALSE;
+ }
+ }
+ else
+ {
+ if ( bSaveAsShown )
+ {
+ sal_uInt32 nFormat;
+ aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
+ Color* pDummy;
+ ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
+ }
+ else
+ ((ScFormulaCell*)pCell)->GetString( aString );
+ bString = TRUE;
+ }
+ }
+ break;
+ case CELLTYPE_STRING :
+ if ( bSaveAsShown )
+ {
+ sal_uInt32 nFormat;
+ aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
+ Color* pDummy;
+ ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
+ }
+ else
+ ((ScStringCell*)pCell)->GetString( aString );
+ bString = TRUE;
+ break;
+ case CELLTYPE_EDIT :
+ {
+ const EditTextObject* pObj;
+ static_cast<const ScEditCell*>(pCell)->GetData( pObj);
+ EditEngine& rEngine = aDocument.GetEditEngine();
+ rEngine.SetText( *pObj);
+ aString = rEngine.GetText(); // including LF
+ bString = TRUE;
+ }
+ break;
+ case CELLTYPE_VALUE :
+ {
+ sal_uInt32 nFormat;
+ aDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
+ if ( bFixedWidth || bSaveAsShown )
+ {
+ Color* pDummy;
+ ScCellFormat::GetString( pCell, nFormat, aString, &pDummy, rFormatter );
+ bString = bSaveAsShown && rFormatter.IsTextFormat( nFormat);
+ }
+ else
+ {
+ ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter );
+ bString = FALSE;
+ }
+ }
+ break;
+ default:
+ DBG_ERROR( "ScDocShell::AsciiSave: unknown CellType" );
+ aString.Erase();
+ bString = FALSE;
+ }
+
+ if ( bFixedWidth )
+ {
+ SvxCellHorJustify eHorJust = (SvxCellHorJustify)
+ ((const SvxHorJustifyItem*) aDocument.GetAttr( nCol, nRow,
+ nTab, ATTR_HOR_JUSTIFY ))->GetValue();
+ lcl_ScDocShell_GetFixedWidthString( aString, aDocument, nTab, nCol,
+ !bString, eHorJust );
+ rStream.WriteUnicodeOrByteText( aString );
+ }
+ else
+ {
+ if (!bString && cStrDelim != 0 && aString.Len() > 0)
+ {
+ sal_Unicode c = aString.GetChar(0);
+ bString = (c == cStrDelim || c == ' ' ||
+ aString.GetChar( aString.Len()-1) == ' ' ||
+ aString.Search( cStrDelim) != STRING_NOTFOUND);
+ if (!bString && cDelim != 0)
+ bString = (aString.Search( cDelim) != STRING_NOTFOUND);
+ }
+ if ( bString )
+ {
+ if ( cStrDelim != 0 ) //@ BugId 55355
+ {
+ if ( eCharSet == RTL_TEXTENCODING_UNICODE )
+ {
+ xub_StrLen nPos = aString.Search( cStrDelim );
+ while ( nPos != STRING_NOTFOUND )
+ {
+ aString.Insert( cStrDelim, nPos );
+ nPos = aString.Search( cStrDelim, nPos+2 );
+ }
+ rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
+ rStream.WriteUnicodeText( aString );
+ rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
+ }
+ else
+ {
+ // #105549# This is nasty. The Unicode to byte encoding
+ // may convert typographical quotation marks to ASCII
+ // quotation marks, which may interfer with the delimiter,
+ // so we have to escape delimiters after the string has
+ // been encoded. Since this may happen also with UTF-8
+ // encoded typographical quotation marks if such was
+ // specified as a delimiter we have to check for the full
+ // encoded delimiter string, not just one character.
+ // Now for RTL_TEXTENCODING_ISO_2022_... and similar brain
+ // dead encodings where one code point (and especially a
+ // low ASCII value) may represent different characters, we
+ // have to convert forth and back and forth again. Same for
+ // UTF-7 since it is a context sensitive encoding too.
+
+ if ( bContextOrNotAsciiEncoding )
+ {
+ // to byte encoding
+ ByteString aStrEnc( aString, eCharSet );
+ // back to Unicode
+ UniString aStrDec( aStrEnc, eCharSet );
+ // search on re-decoded string
+ xub_StrLen nPos = aStrDec.Search( aStrDelimDecoded );
+ while ( nPos != STRING_NOTFOUND )
+ {
+ aStrDec.Insert( aStrDelimDecoded, nPos );
+ nPos = aStrDec.Search( aStrDelimDecoded,
+ nPos+1+aStrDelimDecoded.Len() );
+ }
+ // write byte re-encoded
+ rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
+ rStream.WriteUnicodeOrByteText( aStrDec, eCharSet );
+ rStream.WriteUniOrByteChar( cStrDelim, eCharSet );
+ }
+ else
+ {
+ ByteString aStrEnc( aString, eCharSet );
+ // search on encoded string
+ xub_StrLen nPos = aStrEnc.Search( aStrDelimEncoded );
+ while ( nPos != STRING_NOTFOUND )
+ {
+ aStrEnc.Insert( aStrDelimEncoded, nPos );
+ nPos = aStrEnc.Search( aStrDelimEncoded,
+ nPos+1+aStrDelimEncoded.Len() );
+ }
+ // write byte encoded
+ rStream.Write( aStrDelimEncoded.GetBuffer(),
+ aStrDelimEncoded.Len() );
+ rStream.Write( aStrEnc.GetBuffer(), aStrEnc.Len() );
+ rStream.Write( aStrDelimEncoded.GetBuffer(),
+ aStrDelimEncoded.Len() );
+ }
+ }
+ }
+ else
+ rStream.WriteUnicodeOrByteText( aString );
+ }
+ else
+ rStream.WriteUnicodeOrByteText( aString );
+ }
+
+ if( nCol < nEndCol )
+ {
+ if(cDelim!=0) //@ BugId 55355
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ else
+ endlub( rStream );
+
+ if ( bProgress )
+ aProgress.SetStateOnPercent( nRow );
+ }
+
+ // write out empty if requested
+ if ( nNextRow <= nEndRow )
+ {
+ for ( nEmptyCol = nNextCol; nEmptyCol < nEndCol; nEmptyCol++ )
+ { // remaining empty columns of last row
+ if ( bFixedWidth )
+ lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
+ aDocument, nTab, nEmptyCol );
+ else if ( cDelim != 0 )
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ endlub( rStream );
+ nNextRow++;
+ }
+ for ( nEmptyRow = nNextRow; nEmptyRow <= nEndRow; nEmptyRow++ )
+ { // entire empty rows
+ for ( nEmptyCol = nStartCol; nEmptyCol < nEndCol; nEmptyCol++ )
+ {
+ if ( bFixedWidth )
+ lcl_ScDocShell_WriteEmptyFixedWidthString( rStream,
+ aDocument, nTab, nEmptyCol );
+ else if ( cDelim != 0 )
+ rStream.WriteUniOrByteChar( cDelim );
+ }
+ endlub( rStream );
+ }
+
+ rStream.SetStreamCharSet( eOldCharSet );
+ rStream.SetNumberFormatInt( nOldNumberFormatInt );
+}
+
+BOOL __EXPORT ScDocShell::ConvertTo( SfxMedium &rMed )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ConvertTo" );
+
+ ScRefreshTimerProtector( aDocument.GetRefreshTimerControlAddress() );
+
+ // #i6500# don't call DoEnterHandler here (doesn't work with AutoSave),
+ // it's already in ExecuteSave (as for Save and SaveAs)
+
+ if (pAutoStyleList)
+ pAutoStyleList->ExecuteAllNow(); // Vorlagen-Timeouts jetzt ausfuehren
+ if (GetCreateMode()== SFX_CREATE_MODE_STANDARD)
+ SfxObjectShell::SetVisArea( Rectangle() ); // normal bearbeitet -> keine VisArea
+
+ DBG_ASSERT( rMed.GetFilter(), "Filter == 0" );
+
+ BOOL bRet = FALSE;
+ String aFltName = rMed.GetFilter()->GetFilterName();
+
+/*
+ if (aFltName.EqualsAscii(pFilterLotus))
+ {
+ SvStream* pStream = rMed.GetOutStream();
+ if (pStream)
+ {
+ FltError eError = ScFormatFilter::Get().ScExportLotus123( *pStream, &aDocument, ExpWK1,
+ CHARSET_IBMPC_437 );
+ bRet = eError == eERR_OK;
+ }
+ }
+ else
+*/
+ if (aFltName.EqualsAscii(pFilterXML))
+ {
+ //TODO/LATER: this shouldn't happen!
+ DBG_ERROR("XML filter in ConvertFrom?!");
+ bRet = SaveXML( &rMed, NULL );
+ }
+ else if (aFltName.EqualsAscii(pFilterExcel5) || aFltName.EqualsAscii(pFilterExcel95) ||
+ aFltName.EqualsAscii(pFilterExcel97) || aFltName.EqualsAscii(pFilterEx5Temp) ||
+ aFltName.EqualsAscii(pFilterEx95Temp) || aFltName.EqualsAscii(pFilterEx97Temp))
+ {
+ WaitObject aWait( GetActiveDialogParent() );
+
+ bool bDoSave = true;
+ if( ScTabViewShell* pViewShell = GetBestViewShell() )
+ {
+ ScExtDocOptions* pExtDocOpt = aDocument.GetExtDocOptions();
+ if( !pExtDocOpt )
+ aDocument.SetExtDocOptions( pExtDocOpt = new ScExtDocOptions );
+ pViewShell->GetViewData()->WriteExtOptions( *pExtDocOpt );
+
+ /* #115980# #i104990# If the imported document contains a medium
+ password, determine if we can save it, otherwise ask the users
+ whether they want to save without it. */
+ if( (rMed.GetFilter()->GetFilterFlags() & SFX_FILTER_ENCRYPTION) == 0 )
+ {
+ SfxItemSet* pItemSet = rMed.GetItemSet();
+ const SfxPoolItem* pItem = 0;
+ if( pItemSet && pItemSet->GetItemState( SID_PASSWORD, sal_True, &pItem ) == SFX_ITEM_SET )
+ {
+ bDoSave = ScWarnPassword::WarningOnPassword( rMed );
+ // #i42858# remove password from medium (warn only one time)
+ if( bDoSave )
+ pItemSet->ClearItem( SID_PASSWORD );
+ }
+ }
+
+#if ENABLE_SHEET_PROTECTION
+ if( bDoSave )
+ {
+ bool bNeedRetypePassDlg = ScPassHashHelper::needsPassHashRegen( aDocument, PASSHASH_XL );
+ bDoSave = !bNeedRetypePassDlg || pViewShell->ExecuteRetypePassDlg( PASSHASH_XL );
+ }
+#endif
+ }
+
+ if( bDoSave )
+ {
+ ExportFormatExcel eFormat = ExpBiff5;
+ if( aFltName.EqualsAscii( pFilterExcel97 ) || aFltName.EqualsAscii( pFilterEx97Temp ) )
+ eFormat = ExpBiff8;
+ FltError eError = ScFormatFilter::Get().ScExportExcel5( rMed, &aDocument, eFormat, RTL_TEXTENCODING_MS_1252 );
+
+ if( eError && !GetError() )
+ SetError( eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+
+ // don't return false for warnings
+ bRet = ((eError & ERRCODE_WARNING_MASK) == ERRCODE_WARNING_MASK) || (eError == eERR_OK);
+ }
+ else
+ {
+ // export aborted, i.e. "Save without password" warning
+ SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+ }
+ else if (aFltName.EqualsAscii(pFilterAscii))
+ {
+ SvStream* pStream = rMed.GetOutStream();
+ if (pStream)
+ {
+ String sItStr;
+ SfxItemSet* pSet = rMed.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ sItStr = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if ( sItStr.Len() == 0 )
+ {
+ // default for ascii export (from API without options):
+ // ISO8859-1/MS_1252 encoding, comma, double quotes
+
+ ScImportOptions aDefOptions( ',', '"', RTL_TEXTENCODING_MS_1252 );
+ sItStr = aDefOptions.BuildString();
+ }
+
+ WaitObject aWait( GetActiveDialogParent() );
+ ScImportOptions aOptions( sItStr );
+ AsciiSave( *pStream, aOptions );
+ bRet = TRUE;
+
+ if (aDocument.GetTableCount() > 1)
+ if (!rMed.GetError())
+ rMed.SetError(SCWARN_EXPORT_ASCII, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ }
+ else if (aFltName.EqualsAscii(pFilterDBase))
+ {
+ String sCharSet;
+ SfxItemSet* pSet = rMed.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ sCharSet = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if (sCharSet.Len() == 0)
+ {
+ // default for dBase export (from API without options):
+ // IBM_850 encoding
+
+ sCharSet = ScGlobal::GetCharsetString( RTL_TEXTENCODING_IBM_850 );
+ }
+
+ WaitObject aWait( GetActiveDialogParent() );
+// HACK damit Sba geoffnetes TempFile ueberschreiben kann
+ rMed.CloseOutStream();
+ BOOL bHasMemo = FALSE;
+
+ ULONG eError = DBaseExport( rMed.GetPhysicalName(),
+ ScGlobal::GetCharsetValue(sCharSet), bHasMemo );
+
+ if ( eError != eERR_OK && (eError & ERRCODE_WARNING_MASK) )
+ {
+//! if ( !rMed.GetError() )
+//! rMed.SetError( eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ eError = eERR_OK;
+ }
+//! else if ( aDocument.GetTableCount() > 1 && !rMed.GetError() )
+//! rMed.SetError( SCWARN_EXPORT_ASCII, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+
+ INetURLObject aTmpFile( rMed.GetPhysicalName(), INET_PROT_FILE );
+ if ( bHasMemo )
+ aTmpFile.setExtension( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("dbt")) );
+ if ( eError != eERR_OK )
+ {
+ if (!GetError())
+ SetError(eError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ if ( bHasMemo && IsDocument( aTmpFile ) )
+ KillFile( aTmpFile );
+ }
+ else
+ {
+ bRet = TRUE;
+ if ( bHasMemo )
+ {
+ SfxStringItem* pNameItem =
+ (SfxStringItem*) rMed.GetItemSet()->GetItem( SID_FILE_NAME );
+ INetURLObject aDbtFile( pNameItem->GetValue(), INET_PROT_FILE );
+ aDbtFile.setExtension( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("dbt")) );
+ if ( IsDocument( aDbtFile ) && !KillFile( aDbtFile ) )
+ bRet = FALSE;
+ if ( bRet && !MoveFile( aTmpFile, aDbtFile ) )
+ bRet = FALSE;
+ if ( !bRet )
+ {
+ KillFile( aTmpFile );
+ if ( !GetError() )
+ SetError( SCERR_EXPORT_DATA, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+ }
+ }
+ }
+ else if (aFltName.EqualsAscii(pFilterDif))
+ {
+ SvStream* pStream = rMed.GetOutStream();
+ if (pStream)
+ {
+ String sItStr;
+ SfxItemSet* pSet = rMed.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET ==
+ pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ {
+ sItStr = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if (sItStr.Len() == 0)
+ {
+ // default for DIF export (from API without options):
+ // ISO8859-1/MS_1252 encoding
+
+ sItStr = ScGlobal::GetCharsetString( RTL_TEXTENCODING_MS_1252 );
+ }
+
+ WaitObject aWait( GetActiveDialogParent() );
+ ScFormatFilter::Get().ScExportDif( *pStream, &aDocument, ScAddress(0,0,0),
+ ScGlobal::GetCharsetValue(sItStr) );
+ bRet = TRUE;
+
+ if (aDocument.GetTableCount() > 1)
+ if (!rMed.GetError())
+ rMed.SetError(SCWARN_EXPORT_ASCII, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ));
+ }
+ }
+ else if (aFltName.EqualsAscii(pFilterSylk))
+ {
+ SvStream* pStream = rMed.GetOutStream();
+ if ( pStream )
+ {
+ WaitObject aWait( GetActiveDialogParent() );
+
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ aDocument.GetCellArea( 0, nEndCol, nEndRow );
+ ScRange aRange( 0,0,0, nEndCol,nEndRow,0 );
+
+ ScImportExport aImExport( &aDocument, aRange );
+ aImExport.SetFormulas( TRUE );
+ bRet = aImExport.ExportStream( *pStream, rMed.GetBaseURL( true ), SOT_FORMATSTR_ID_SYLK );
+ }
+ }
+ else if (aFltName.EqualsAscii(pFilterHtml))
+ {
+ SvStream* pStream = rMed.GetOutStream();
+ if ( pStream )
+ {
+ WaitObject aWait( GetActiveDialogParent() );
+ ScImportExport aImExport( &aDocument );
+ aImExport.SetStreamPath( rMed.GetName() );
+ bRet = aImExport.ExportStream( *pStream, rMed.GetBaseURL( true ), SOT_FORMATSTR_ID_HTML );
+ if ( bRet && aImExport.GetNonConvertibleChars().Len() )
+ SetError( *new StringErrorInfo(
+ SCWARN_EXPORT_NONCONVERTIBLE_CHARS,
+ aImExport.GetNonConvertibleChars(),
+ ERRCODE_BUTTON_OK | ERRCODE_MSG_INFO ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+ }
+ else
+ {
+ if (GetError())
+ SetError(SCERR_IMPORT_NI, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+ return bRet;
+}
+
+
+BOOL __EXPORT ScDocShell::SaveCompleted( const uno::Reference < embed::XStorage >& xStor )
+{
+ return SfxObjectShell::SaveCompleted( xStor );
+}
+
+
+BOOL __EXPORT ScDocShell::DoSaveCompleted( SfxMedium * pNewStor )
+{
+ BOOL bRet = SfxObjectShell::DoSaveCompleted( pNewStor );
+
+ // SC_HINT_DOC_SAVED fuer Wechsel ReadOnly -> Read/Write
+ Broadcast( SfxSimpleHint( SC_HINT_DOC_SAVED ) );
+ return bRet;
+}
+
+
+sal_Bool ScDocShell::QuerySlotExecutable( USHORT nSlotId )
+{
+ // #i112634# ask VBA event handlers whether to save or print the document
+
+ using namespace ::com::sun::star::script::vba;
+
+ sal_Int32 nVbaEventId = VBAEventId::NO_EVENT;
+ uno::Sequence< uno::Any > aArgs;
+ switch( nSlotId )
+ {
+ case SID_SAVEDOC:
+ case SID_SAVEASDOC:
+ nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE;
+ aArgs.realloc( 1 );
+ aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC);
+ break;
+ case SID_PRINTDOC:
+ case SID_PRINTDOCDIRECT:
+ nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT;
+ break;
+ }
+
+ sal_Bool bSlotExecutable = sal_True;
+ if( nVbaEventId != VBAEventId::NO_EVENT ) try
+ {
+ uno::Reference< XVBAEventProcessor > xEventProcessor( aDocument.GetVbaEventProcessor(), uno::UNO_QUERY_THROW );
+ xEventProcessor->processVbaEvent( nVbaEventId, aArgs );
+ }
+ catch( util::VetoException& )
+ {
+ bSlotExecutable = sal_False;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return bSlotExecutable;
+}
+
+
+USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing )
+{
+ if(SC_MOD()->GetCurRefDlgId()>0)
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this );
+ if( pFrame )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin!=NULL) pWin->GrabFocus();
+ }
+ }
+
+ return FALSE;
+ }
+ if ( aDocument.IsInLinkUpdate() || aDocument.IsInInterpreter() )
+ {
+ ErrorMessage(STR_CLOSE_ERROR_LINK);
+ return FALSE;
+ }
+
+ DoEnterHandler();
+
+ // start 'Workbook_BeforeClose' VBA event handler for possible veto
+ if( !IsInPrepareClose() )
+ {
+ try
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW );
+ uno::Sequence< uno::Any > aArgs;
+ xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_BEFORECLOSE, aArgs );
+ }
+ catch( util::VetoException& )
+ {
+ // if event processor throws VetoException, macro has vetoed close
+ return sal_False;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ // end handler code
+
+ USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing );
+ if (nRet == TRUE) // TRUE = schliessen
+ aDocument.DisableIdle(TRUE); // nicht mehr drin rumpfuschen !!!
+
+ return nRet;
+}
+
+void ScDocShell::PrepareReload()
+{
+ SfxObjectShell::PrepareReload(); // tut nichts?
+
+ // Das Disconnect von DDE-Links kann Reschedule ausloesen.
+ // Wenn die DDE-Links erst im Dokument-dtor geloescht werden, kann beim Reload
+ // aus diesem Reschedule das DDE-Link-Update fuer das neue Dokument ausgeloest
+ // werden. Dabei verklemmt sicht dann irgendwas.
+ // -> Beim Reload die DDE-Links des alten Dokuments vorher disconnecten
+
+ aDocument.DisconnectDdeLinks();
+}
+
+
+String ScDocShell::GetOwnFilterName() // static
+{
+ return String::CreateFromAscii(pFilterSc50);
+}
+
+String ScDocShell::GetHtmlFilterName()
+{
+ return String::CreateFromAscii(pFilterHtml);
+}
+
+String ScDocShell::GetWebQueryFilterName() // static
+{
+ return String::CreateFromAscii(pFilterHtmlWebQ);
+}
+
+String ScDocShell::GetAsciiFilterName() // static
+{
+ return String::CreateFromAscii(pFilterAscii);
+}
+
+String ScDocShell::GetLotusFilterName() // static
+{
+ return String::CreateFromAscii(pFilterLotus);
+}
+
+String ScDocShell::GetDBaseFilterName() // static
+{
+ return String::CreateFromAscii(pFilterDBase);
+}
+
+String ScDocShell::GetDifFilterName() // static
+{
+ return String::CreateFromAscii(pFilterDif);
+}
+
+BOOL ScDocShell::HasAutomaticTableName( const String& rFilter ) // static
+{
+ // TRUE for those filters that keep the default table name
+ // (which is language specific)
+
+ return rFilter.EqualsAscii( pFilterAscii )
+ || rFilter.EqualsAscii( pFilterLotus )
+ || rFilter.EqualsAscii( pFilterExcel4 )
+ || rFilter.EqualsAscii( pFilterEx4Temp )
+ || rFilter.EqualsAscii( pFilterDBase )
+ || rFilter.EqualsAscii( pFilterDif )
+ || rFilter.EqualsAscii( pFilterSylk )
+ || rFilter.EqualsAscii( pFilterHtml )
+ || rFilter.EqualsAscii( pFilterRtf );
+}
+
+//==================================================================
+
+#define __SCDOCSHELL_INIT \
+ aDocument ( SCDOCMODE_DOCUMENT, this ), \
+ aDdeTextFmt(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("TEXT"))), \
+ nPrtToScreenFactor( 1.0 ), \
+ pImpl ( new DocShell_Impl ), \
+ bHeaderOn ( TRUE ), \
+ bFooterOn ( TRUE ), \
+ bNoInformLost ( TRUE ), \
+ bIsEmpty ( TRUE ), \
+ bIsInUndo ( FALSE ), \
+ bDocumentModifiedPending( FALSE ), \
+ nDocumentLock ( 0 ), \
+ nCanUpdate (com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG), \
+ bUpdateEnabled ( TRUE ), \
+ pOldAutoDBRange ( NULL ), \
+ pDocHelper ( NULL ), \
+ pAutoStyleList ( NULL ), \
+ pPaintLockData ( NULL ), \
+ pOldJobSetup ( NULL ), \
+ pSolverSaveData ( NULL ), \
+ pSheetSaveData ( NULL ), \
+ pModificator ( NULL )
+
+//------------------------------------------------------------------
+
+ScDocShell::ScDocShell( const ScDocShell& rShell )
+ : SvRefBase(),
+ SotObject(),
+ SfxObjectShell( rShell.GetCreateMode() ),
+ SfxListener(),
+ __SCDOCSHELL_INIT
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" );
+
+ SetPool( &SC_MOD()->GetPool() );
+
+ bIsInplace = rShell.bIsInplace;
+
+ pDocFunc = new ScDocFunc(*this);
+
+ // SetBaseModel needs exception handling
+ ScModelObj::CreateAndSet( this );
+
+ StartListening(*this);
+ SfxStyleSheetPool* pStlPool = aDocument.GetStyleSheetPool();
+ if (pStlPool)
+ StartListening(*pStlPool);
+
+ GetPageOnFromPageStyleSet( NULL, 0, bHeaderOn, bFooterOn );
+ SetHelpId( HID_SCSHELL_DOCSH );
+
+ // InitItems und CalcOutputFactor werden jetzt nach bei Load/ConvertFrom/InitNew gerufen
+}
+
+//------------------------------------------------------------------
+
+ScDocShell::ScDocShell( const sal_uInt64 i_nSfxCreationFlags )
+ : SfxObjectShell( i_nSfxCreationFlags )
+ , __SCDOCSHELL_INIT
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::ScDocShell" );
+
+ SetPool( &SC_MOD()->GetPool() );
+
+ bIsInplace = (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
+ // wird zurueckgesetzt, wenn nicht inplace
+
+ pDocFunc = new ScDocFunc(*this);
+
+ // SetBaseModel needs exception handling
+ ScModelObj::CreateAndSet( this );
+
+ StartListening(*this);
+ SfxStyleSheetPool* pStlPool = aDocument.GetStyleSheetPool();
+ if (pStlPool)
+ StartListening(*pStlPool);
+ SetHelpId( HID_SCSHELL_DOCSH );
+
+ aDocument.GetDBCollection()->SetRefreshHandler(
+ LINK( this, ScDocShell, RefreshDBDataHdl ) );
+
+ // InitItems und CalcOutputFactor werden jetzt nach bei Load/ConvertFrom/InitNew gerufen
+}
+
+//------------------------------------------------------------------
+
+__EXPORT ScDocShell::~ScDocShell()
+{
+ ResetDrawObjectShell(); // #55570# falls der Drawing-Layer noch versucht, darauf zuzugreifen
+
+ SfxStyleSheetPool* pStlPool = aDocument.GetStyleSheetPool();
+ if (pStlPool)
+ EndListening(*pStlPool);
+ EndListening(*this);
+
+ delete pAutoStyleList;
+
+ SfxApplication *pSfxApp = SFX_APP();
+ if ( pSfxApp->GetDdeService() ) // DDE vor Dokument loeschen
+ pSfxApp->RemoveDdeTopic( this );
+
+ delete pDocFunc;
+ delete aDocument.mpUndoManager;
+ aDocument.mpUndoManager = 0;
+ delete pImpl;
+
+ delete pPaintLockData;
+
+ delete pOldJobSetup; // gesetzt nur bei Fehler in StartJob()
+
+ delete pSolverSaveData;
+ delete pSheetSaveData;
+ delete pOldAutoDBRange;
+
+ if (pModificator)
+ {
+ DBG_ERROR("The Modificator should not exist");
+ delete pModificator;
+ }
+}
+
+//------------------------------------------------------------------
+
+SfxUndoManager* __EXPORT ScDocShell::GetUndoManager()
+{
+ return aDocument.GetUndoManager();
+}
+
+void ScDocShell::SetModified( BOOL bModified )
+{
+ if ( SfxObjectShell::IsEnableSetModified() )
+ {
+ SfxObjectShell::SetModified( bModified );
+ Broadcast( SfxSimpleHint( SFX_HINT_DOCCHANGED ) );
+ }
+}
+
+
+void ScDocShell::SetDocumentModified( BOOL bIsModified /* = TRUE */ )
+{
+ // BroadcastUno muss auch mit pPaintLockData sofort passieren
+ //! auch bei SetDrawModified, wenn Drawing angebunden ist
+ //! dann eigener Hint???
+
+ if ( pPaintLockData && bIsModified )
+ {
+ //! BCA_BRDCST_ALWAYS etc. also needed here?
+ aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
+
+ pPaintLockData->SetModified(); // spaeter...
+ return;
+ }
+
+ SetDrawModified( bIsModified );
+
+ if ( bIsModified )
+ {
+ if ( aDocument.IsAutoCalcShellDisabled() )
+ SetDocumentModifiedPending( TRUE );
+ else
+ {
+ SetDocumentModifiedPending( FALSE );
+ aDocument.InvalidateStyleSheetUsage();
+ aDocument.InvalidateTableArea();
+ aDocument.InvalidateLastTableOpParams();
+ aDocument.Broadcast( SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL );
+ if ( aDocument.IsForcedFormulaPending() && aDocument.GetAutoCalc() )
+ aDocument.CalcFormulaTree( TRUE );
+ PostDataChanged();
+
+ // Detective AutoUpdate:
+ // Update if formulas were modified (DetectiveDirty) or the list contains
+ // "Trace Error" entries (#75362# - Trace Error can look completely different
+ // after changes to non-formula cells).
+
+ ScDetOpList* pList = aDocument.GetDetOpList();
+ if ( pList && ( aDocument.IsDetectiveDirty() || pList->HasAddError() ) &&
+ pList->Count() && !IsInUndo() && SC_MOD()->GetAppOptions().GetDetectiveAuto() )
+ {
+ GetDocFunc().DetectiveRefresh(TRUE); // TRUE = caused by automatic update
+ }
+ aDocument.SetDetectiveDirty(FALSE); // always reset, also if not refreshed
+ }
+
+ // #b6697848# notify UNO objects after BCA_BRDCST_ALWAYS etc.
+ aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
+ }
+}
+
+// SetDrawModified - ohne Formel-Update
+// (Drawing muss auch beim normalen SetDocumentModified upgedated werden,
+// z.B. bei Tabelle loeschen etc.)
+
+void ScDocShell::SetDrawModified( BOOL bIsModified /* = TRUE */ )
+{
+ BOOL bUpdate = ( bIsModified != IsModified() );
+
+ SetModified( bIsModified );
+
+ SfxBindings* pBindings = GetViewBindings();
+ if (bUpdate)
+ {
+ if (pBindings)
+ {
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ }
+ }
+
+ if (bIsModified)
+ {
+ if (pBindings)
+ {
+ // #i105960# Undo etc used to be volatile.
+ // They always have to be invalidated, including drawing layer or row height changes
+ // (but not while pPaintLockData is set).
+ pBindings->Invalidate( SID_UNDO );
+ pBindings->Invalidate( SID_REDO );
+ pBindings->Invalidate( SID_REPEAT );
+ }
+
+ if ( aDocument.IsChartListenerCollectionNeedsUpdate() )
+ {
+ aDocument.UpdateChartListenerCollection();
+ SFX_APP()->Broadcast(SfxSimpleHint( SC_HINT_DRAW_CHANGED )); // Navigator
+ }
+ SC_MOD()->AnythingChanged();
+ }
+}
+
+void ScDocShell::SetInUndo(BOOL bSet)
+{
+ bIsInUndo = bSet;
+}
+
+
+void ScDocShell::GetDocStat( ScDocStat& rDocStat )
+{
+ SfxPrinter* pPrinter = GetPrinter();
+
+ aDocument.GetDocStat( rDocStat );
+ rDocStat.nPageCount = 0;
+
+ if ( pPrinter )
+ for ( SCTAB i=0; i<rDocStat.nTableCount; i++ )
+ rDocStat.nPageCount = sal::static_int_cast<USHORT>( rDocStat.nPageCount +
+ (USHORT) ScPrintFunc( this, pPrinter, i ).GetTotalPages() );
+}
+
+
+SfxDocumentInfoDialog* __EXPORT ScDocShell::CreateDocumentInfoDialog(
+ Window *pParent, const SfxItemSet &rSet )
+{
+ SfxDocumentInfoDialog* pDlg = new SfxDocumentInfoDialog( pParent, rSet );
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell,SfxObjectShell::Current());
+
+ //nur mit Statistik, wenn dieses Doc auch angezeigt wird, nicht
+ //aus dem Doc-Manager
+
+ if( pDocSh == this )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ ::CreateTabPage ScDocStatPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_STAT );
+ DBG_ASSERT(ScDocStatPageCreate, "Tabpage create fail!");
+ pDlg->AddTabPage( 42,
+ ScGlobal::GetRscString( STR_DOC_STAT ),
+ ScDocStatPageCreate,
+ NULL);
+ }
+ return pDlg;
+}
+
+Window* ScDocShell::GetActiveDialogParent()
+{
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ return pViewSh->GetDialogParent();
+ else
+ return Application::GetDefDialogParent();
+}
+
+void ScDocShell::SetSolverSaveData( const ScOptSolverSave& rData )
+{
+ delete pSolverSaveData;
+ pSolverSaveData = new ScOptSolverSave( rData );
+}
+
+ScSheetSaveData* ScDocShell::GetSheetSaveData()
+{
+ if (!pSheetSaveData)
+ pSheetSaveData = new ScSheetSaveData;
+
+ return pSheetSaveData;
+}
+
+namespace {
+
+void removeKeysIfExists(Reference<ui::XAcceleratorConfiguration>& xScAccel, const vector<const awt::KeyEvent*>& rKeys)
+{
+ vector<const awt::KeyEvent*>::const_iterator itr = rKeys.begin(), itrEnd = rKeys.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ const awt::KeyEvent* p = *itr;
+ if (!p)
+ continue;
+
+ try
+ {
+ xScAccel->removeKeyEvent(*p);
+ }
+ catch (const container::NoSuchElementException&) {}
+ }
+}
+
+}
+
+void ScDocShell::ResetKeyBindings( ScOptionsUtil::KeyBindingType eType )
+{
+ using namespace ::com::sun::star::ui;
+
+ Reference<XMultiServiceFactory> xServiceManager = ::comphelper::getProcessServiceFactory();
+ if (!xServiceManager.is())
+ return;
+
+ Reference<XModuleUIConfigurationManagerSupplier> xModuleCfgSupplier(
+ xServiceManager->createInstance(
+ OUString::createFromAscii("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")), UNO_QUERY);
+
+ if (!xModuleCfgSupplier.is())
+ return;
+
+ // Grab the Calc configuration.
+ Reference<XUIConfigurationManager> xConfigMgr =
+ xModuleCfgSupplier->getUIConfigurationManager(
+ OUString::createFromAscii("com.sun.star.sheet.SpreadsheetDocument"));
+
+ if (!xConfigMgr.is())
+ return;
+
+ // shortcut manager
+ Reference<XAcceleratorConfiguration> xScAccel(
+ xConfigMgr->getShortCutManager(), UNO_QUERY);
+
+ if (!xScAccel.is())
+ return;
+
+ vector<const awt::KeyEvent*> aKeys;
+ aKeys.reserve(4);
+
+ // Backsapce key
+ awt::KeyEvent aBackspace;
+ aBackspace.KeyCode = awt::Key::BACKSPACE;
+ aBackspace.Modifiers = 0;
+ aKeys.push_back(&aBackspace);
+
+ // Delete key
+ awt::KeyEvent aDelete;
+ aDelete.KeyCode = awt::Key::DELETE;
+ aDelete.Modifiers = 0;
+ aKeys.push_back(&aDelete);
+
+ // Ctrl-D
+ awt::KeyEvent aCtrlD;
+ aCtrlD.KeyCode = awt::Key::D;
+ aCtrlD.Modifiers = awt::KeyModifier::MOD1;
+ aKeys.push_back(&aCtrlD);
+
+ // Ctrl-Shift-D
+ awt::KeyEvent aCtrlShiftD;
+ aCtrlShiftD.KeyCode = awt::Key::D;
+ aCtrlShiftD.Modifiers = awt::KeyModifier::MOD1 | awt::KeyModifier::SHIFT;
+ aKeys.push_back(&aCtrlShiftD);
+
+ // Remove all involved keys first, because swapping commands don't work
+ // well without doing this.
+ removeKeysIfExists(xScAccel, aKeys);
+ xScAccel->store();
+
+ switch (eType)
+ {
+ case ScOptionsUtil::KEY_DEFAULT:
+ xScAccel->setKeyEvent(aDelete, OUString::createFromAscii(".uno:ClearContents"));
+ xScAccel->setKeyEvent(aBackspace, OUString::createFromAscii(".uno:Delete"));
+ xScAccel->setKeyEvent(aCtrlD, OUString::createFromAscii(".uno:FillDown"));
+ xScAccel->setKeyEvent(aCtrlShiftD, OUString::createFromAscii(".uno:DataSelect"));
+ break;
+ case ScOptionsUtil::KEY_OOO_LEGACY:
+ xScAccel->setKeyEvent(aDelete, OUString::createFromAscii(".uno:Delete"));
+ xScAccel->setKeyEvent(aBackspace, OUString::createFromAscii(".uno:ClearContents"));
+ xScAccel->setKeyEvent(aCtrlD, OUString::createFromAscii(".uno:DataSelect"));
+ break;
+ default:
+ ;
+ }
+
+ xScAccel->store();
+}
+
+void ScDocShell::UseSheetSaveEntries()
+{
+ if (pSheetSaveData)
+ {
+ pSheetSaveData->UseSaveEntries(); // use positions from saved file for next saving
+
+ bool bHasEntries = false;
+ SCTAB nTabCount = aDocument.GetTableCount();
+ SCTAB nTab;
+ for (nTab = 0; nTab < nTabCount; ++nTab)
+ if (pSheetSaveData->HasStreamPos(nTab))
+ bHasEntries = true;
+
+ if (!bHasEntries)
+ {
+ // if no positions were set (for example, export to other format),
+ // reset all "valid" flags
+
+ for (nTab = 0; nTab < nTabCount; ++nTab)
+ if (aDocument.IsStreamValid(nTab))
+ aDocument.SetStreamValid(nTab, FALSE);
+ }
+ }
+}
+
+// --- ScDocShellModificator ------------------------------------------
+
+ScDocShellModificator::ScDocShellModificator( ScDocShell& rDS )
+ :
+ rDocShell( rDS ),
+ aProtector( rDS.GetDocument()->GetRefreshTimerControlAddress() )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ bAutoCalcShellDisabled = pDoc->IsAutoCalcShellDisabled();
+ bIdleDisabled = pDoc->IsIdleDisabled();
+ pDoc->SetAutoCalcShellDisabled( TRUE );
+ pDoc->DisableIdle( TRUE );
+}
+
+
+ScDocShellModificator::~ScDocShellModificator()
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ pDoc->SetAutoCalcShellDisabled( bAutoCalcShellDisabled );
+ if ( !bAutoCalcShellDisabled && rDocShell.IsDocumentModifiedPending() )
+ rDocShell.SetDocumentModified(); // last one shuts off the lights
+ pDoc->DisableIdle( bIdleDisabled );
+}
+
+
+void ScDocShellModificator::SetDocumentModified()
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if ( !pDoc->IsImportingXML() )
+ {
+ // AutoCalcShellDisabled temporaer restaurieren
+ BOOL bDisabled = pDoc->IsAutoCalcShellDisabled();
+ pDoc->SetAutoCalcShellDisabled( bAutoCalcShellDisabled );
+ rDocShell.SetDocumentModified();
+ pDoc->SetAutoCalcShellDisabled( bDisabled );
+ }
+ else
+ {
+ // uno broadcast is necessary for api to work
+ // -> must also be done during xml import
+ pDoc->BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
+ }
+}
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+sal_Bool ScDocShell::AcceptStateUpdate() const
+{
+ if( SfxObjectShell::AcceptStateUpdate() )
+ return sal_True;
+
+ if( SC_MOD()->Find1RefWindow( SFX_APP()->GetTopWindow() ) )
+ return sal_True;
+
+ return sal_False;
+}
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+
+bool ScDocShell::IsChangeRecording() const
+{
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ return pChangeTrack != NULL;
+}
+
+
+bool ScDocShell::HasChangeRecordProtection() const
+{
+ bool bRes = false;
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ if (pChangeTrack)
+ bRes = pChangeTrack->IsProtected();
+ return bRes;
+}
+
+
+void ScDocShell::SetChangeRecording( bool bActivate )
+{
+ bool bOldChangeRecording = IsChangeRecording();
+
+ if (bActivate)
+ {
+ aDocument.StartChangeTracking();
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges(TRUE);
+ aDocument.SetChangeViewSettings(aChangeViewSet);
+ }
+ else
+ {
+ aDocument.EndChangeTracking();
+ PostPaintGridAll();
+ }
+
+ if (bOldChangeRecording != IsChangeRecording())
+ {
+ UpdateAcceptChangesDialog();
+ // Slots invalidieren
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
+ pBindings->InvalidateAll(FALSE);
+ }
+}
+
+
+bool ScDocShell::SetProtectionPassword( const String &rNewPassword )
+{
+ bool bRes = false;
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ if (pChangeTrack)
+ {
+ sal_Bool bProtected = pChangeTrack->IsProtected();
+
+ if (rNewPassword.Len())
+ {
+ // when password protection is applied change tracking must always be active
+ SetChangeRecording( true );
+
+ ::com::sun::star::uno::Sequence< sal_Int8 > aProtectionHash;
+ SvPasswordHelper::GetHashPassword( aProtectionHash, rNewPassword );
+ pChangeTrack->SetProtection( aProtectionHash );
+ }
+ else
+ {
+ pChangeTrack->SetProtection( ::com::sun::star::uno::Sequence< sal_Int8 >() );
+ }
+ bRes = true;
+
+ if ( bProtected != pChangeTrack->IsProtected() )
+ {
+ UpdateAcceptChangesDialog();
+ SetDocumentModified();
+ }
+ }
+
+ return bRes;
+}
+
+
+bool ScDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash )
+{
+ bool bRes = false;
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ if (pChangeTrack && pChangeTrack->IsProtected())
+ {
+ rPasswordHash = pChangeTrack->GetProtection();
+ bRes = true;
+ }
+ return bRes;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx
new file mode 100644
index 000000000000..8686cc787c14
--- /dev/null
+++ b/sc/source/ui/docshell/docsh2.cxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <svx/svdpage.hxx>
+
+
+#include <svx/xtable.hxx>
+
+#include "scitems.hxx"
+#include <tools/gen.hxx>
+#include <svtools/ctrltool.hxx>
+#include <editeng/flstitem.hxx>
+#include <svx/drawitem.hxx>
+#include <sfx2/printer.hxx>
+#include <svl/smplhint.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoole2.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/asiancfg.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <editeng/unolingu.hxx>
+#include <rtl/logfile.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/basmgr.hxx>
+#include <sfx2/app.hxx>
+
+// INCLUDE ---------------------------------------------------------------
+/*
+#include <svdrwetc.hxx>
+#include <svdrwobx.hxx>
+#include <sostor.hxx>
+*/
+#include "drwlayer.hxx"
+#include "stlpool.hxx"
+#include "docsh.hxx"
+#include "docshimp.hxx"
+#include "docfunc.hxx"
+#include "sc.hrc"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::InitNew" );
+
+ BOOL bRet = SfxObjectShell::InitNew( xStor );
+
+ aDocument.MakeTable(0);
+ // zusaetzliche Tabellen werden von der ersten View angelegt,
+ // wenn bIsEmpty dann noch TRUE ist
+
+ if( bRet )
+ {
+ Size aSize( (long) ( STD_COL_WIDTH * HMM_PER_TWIPS * OLE_STD_CELLS_X ),
+ (long) ( ScGlobal::nStdRowHeight * HMM_PER_TWIPS * OLE_STD_CELLS_Y ) );
+ // hier muss auch der Start angepasst werden
+ SetVisAreaOrSize( Rectangle( Point(), aSize ), TRUE );
+ }
+
+ aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew
+
+ // InitOptions sets the document languages, must be called before CreateStandardStyles
+ InitOptions(false);
+
+ aDocument.GetStyleSheetPool()->CreateStandardStyles();
+ aDocument.UpdStlShtPtrsFrmNms();
+
+ // SetDocumentModified ist in Load/InitNew nicht mehr erlaubt!
+
+ InitItems();
+ CalcOutputFactor();
+#if 0
+ uno::Any aGlobs;
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[ 0 ] <<= GetModel();
+ aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs );
+ GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
+ // Fake ThisComponent being setup by Activate ( which is a view
+ // related thing ),
+ // a) if another document is opened then in theory ThisComponent
+ // will be reset as before,
+ // b) when this document is 'really' Activated then ThisComponent
+ // again will be set as before
+ // The only wrinkle seems if this document is loaded 'InVisible'
+ // but.. I don't see that this is possible from the vba API
+ // I could be wrong though
+ // There may be implications setting the current component
+ // too early :-/ so I will just manually set the Basic Variables
+ BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
+ if ( pAppMgr )
+ pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
+#endif
+
+ return bRet;
+}
+
+//------------------------------------------------------------------
+
+BOOL ScDocShell::IsEmpty() const
+{
+ return bIsEmpty;
+}
+
+
+void ScDocShell::SetEmpty(BOOL bSet)
+{
+ bIsEmpty = bSet;
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::InitItems()
+{
+ // AllItemSet fuer Controller mit benoetigten Items fuellen:
+
+ // if ( pImpl->pFontList )
+ // delete pImpl->pFontList;
+
+ // Druck-Optionen werden beim Drucken und evtl. in GetPrinter gesetzt
+
+ // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
+ //PutItem( SvxFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST ) );
+ UpdateFontList();
+
+ ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
+ if (pDrawLayer)
+ {
+ PutItem( SvxColorTableItem ( pDrawLayer->GetColorTable(), SID_COLOR_TABLE ) );
+ PutItem( SvxGradientListItem( pDrawLayer->GetGradientList(), SID_GRADIENT_LIST ) );
+ PutItem( SvxHatchListItem ( pDrawLayer->GetHatchList(), SID_HATCH_LIST ) );
+ PutItem( SvxBitmapListItem ( pDrawLayer->GetBitmapList(), SID_BITMAP_LIST ) );
+ PutItem( SvxDashListItem ( pDrawLayer->GetDashList(), SID_DASH_LIST ) );
+ PutItem( SvxLineEndListItem ( pDrawLayer->GetLineEndList(), SID_LINEEND_LIST ) );
+
+ // andere Anpassungen nach dem Anlegen des DrawLayers
+
+ pDrawLayer->SetNotifyUndoActionHdl( LINK( pDocFunc, ScDocFunc, NotifyDrawUndo ) );
+
+ //if (SfxObjectShell::HasSbxObject())
+ pDrawLayer->UpdateBasic(); // DocShell-Basic in DrawPages setzen
+ }
+ else
+ {
+ // always use global color table instead of local copy
+ PutItem( SvxColorTableItem( XColorTable::GetStdColorTable(), SID_COLOR_TABLE ) );
+ }
+
+ if ( !aDocument.GetForbiddenCharacters().is() ||
+ !aDocument.IsValidAsianCompression() || !aDocument.IsValidAsianKerning() )
+ {
+ // get settings from SvxAsianConfig
+ SvxAsianConfig aAsian( sal_False );
+
+ if ( !aDocument.GetForbiddenCharacters().is() )
+ {
+ // set forbidden characters if necessary
+ uno::Sequence<lang::Locale> aLocales = aAsian.GetStartEndCharLocales();
+ if (aLocales.getLength())
+ {
+ rtl::Reference<SvxForbiddenCharactersTable> xForbiddenTable =
+ new SvxForbiddenCharactersTable( aDocument.GetServiceManager() );
+
+ const lang::Locale* pLocales = aLocales.getConstArray();
+ for (sal_Int32 i = 0; i < aLocales.getLength(); i++)
+ {
+ i18n::ForbiddenCharacters aForbidden;
+ aAsian.GetStartEndChars( pLocales[i], aForbidden.beginLine, aForbidden.endLine );
+ LanguageType eLang = SvxLocaleToLanguage(pLocales[i]);
+ //pDoc->SetForbiddenCharacters( eLang, aForbidden );
+
+ xForbiddenTable->SetForbiddenCharacters( eLang, aForbidden );
+ }
+
+ aDocument.SetForbiddenCharacters( xForbiddenTable );
+ }
+ }
+
+ if ( !aDocument.IsValidAsianCompression() )
+ {
+ // set compression mode from configuration if not already set (e.g. XML import)
+ aDocument.SetAsianCompression( sal::static_int_cast<BYTE>( aAsian.GetCharDistanceCompression() ) );
+ }
+
+ if ( !aDocument.IsValidAsianKerning() )
+ {
+ // set asian punctuation kerning from configuration if not already set (e.g. XML import)
+ aDocument.SetAsianKerning( !aAsian.IsKerningWesternTextOnly() ); // reversed
+ }
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::ResetDrawObjectShell()
+{
+ ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
+ if (pDrawLayer)
+ pDrawLayer->SetObjectShell( NULL );
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScDocShell::Activate()
+{
+}
+
+
+void __EXPORT ScDocShell::Deactivate()
+{
+}
+
+//------------------------------------------------------------------
+
+
+ScDrawLayer* ScDocShell::MakeDrawLayer()
+{
+ ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
+ if (!pDrawLayer)
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScDocShell::MakeDrawLayer" );
+
+ aDocument.InitDrawLayer(this);
+ pDrawLayer = aDocument.GetDrawLayer();
+ InitItems(); // incl. Undo und Basic
+ Broadcast( SfxSimpleHint( SC_HINT_DRWLAYER_NEW ) );
+ if (nDocumentLock)
+ pDrawLayer->setLock(TRUE);
+ }
+ return pDrawLayer;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
new file mode 100644
index 000000000000..9af5d7771385
--- /dev/null
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -0,0 +1,1412 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+#include "scitems.hxx"
+#include "rangelst.hxx"
+#include <editeng/flstitem.hxx>
+#include <svx/pageitem.hxx>
+#include <editeng/paperinf.hxx>
+#include <svx/postattr.hxx>
+#include <editeng/sizeitem.hxx>
+#include <unotools/misccfg.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
+#include <svtools/ctrltool.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "docsh.hxx"
+#include "docshimp.hxx"
+#include "scmod.hxx"
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+#include "docpool.hxx"
+#include "stlpool.hxx"
+#include "patattr.hxx"
+#include "uiitems.hxx"
+#include "hints.hxx"
+#include "docoptio.hxx"
+#include "viewopti.hxx"
+#include "pntlock.hxx"
+#include "chgtrack.hxx"
+#include "docfunc.hxx"
+#include "cell.hxx"
+#include "chgviset.hxx"
+#include "progress.hxx"
+#include "redcom.hxx"
+#include "sc.hrc"
+#include "inputopt.hxx"
+#include "drwlayer.hxx"
+#include "inputhdl.hxx"
+#include "conflictsdlg.hxx"
+#include "globstr.hrc"
+
+#if DEBUG_CHANGETRACK
+#include <stdio.h>
+#endif // DEBUG_CHANGETRACK
+
+
+//------------------------------------------------------------------
+
+//
+// Redraw - Benachrichtigungen
+//
+
+
+void ScDocShell::PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos )
+{
+// Broadcast( ScEditViewHint( pEditEngine, rCursorPos ) );
+
+ // Test: nur aktive ViewShell
+
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if (pViewSh && pViewSh->GetViewData()->GetDocShell() == this)
+ {
+ ScEditViewHint aHint( pEditEngine, rCursorPos );
+ pViewSh->Notify( *this, aHint );
+ }
+}
+
+void ScDocShell::PostDataChanged()
+{
+ Broadcast( SfxSimpleHint( FID_DATACHANGED ) );
+ aDocument.ResetChanged( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB) );
+
+ SFX_APP()->Broadcast(SfxSimpleHint( FID_ANYDATACHANGED )); // Navigator
+ //! Navigator direkt benachrichtigen!
+}
+
+void ScDocShell::PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, USHORT nPart,
+ USHORT nExtFlags )
+{
+ if (!ValidCol(nStartCol)) nStartCol = MAXCOL;
+ if (!ValidRow(nStartRow)) nStartRow = MAXROW;
+ if (!ValidCol(nEndCol)) nEndCol = MAXCOL;
+ if (!ValidRow(nEndRow)) nEndRow = MAXROW;
+
+ if ( pPaintLockData )
+ {
+ // #i54081# PAINT_EXTRAS still has to be brodcast because it changes the
+ // current sheet if it's invalid. All other flags added to pPaintLockData.
+ USHORT nLockPart = nPart & ~PAINT_EXTRAS;
+ if ( nLockPart )
+ {
+ //! nExtFlags ???
+ pPaintLockData->AddRange( ScRange( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab ), nLockPart );
+ }
+
+ nPart &= PAINT_EXTRAS; // for broadcasting
+ if ( !nPart )
+ return;
+ }
+
+
+ if (nExtFlags & SC_PF_LINES) // Platz fuer Linien beruecksichtigen
+ {
+ //! Abfrage auf versteckte Spalten/Zeilen!
+ if (nStartCol>0) --nStartCol;
+ if (nEndCol<MAXCOL) ++nEndCol;
+ if (nStartRow>0) --nStartRow;
+ if (nEndRow<MAXROW) ++nEndRow;
+ }
+
+ // um zusammengefasste erweitern
+ if (nExtFlags & SC_PF_TESTMERGE)
+ aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nStartTab );
+
+ if ( nStartCol != 0 || nEndCol != MAXCOL )
+ {
+ // Extend to whole rows if SC_PF_WHOLEROWS is set, or rotated or non-left
+ // aligned cells are contained (see UpdatePaintExt).
+ // Special handling for RTL text (#i9731#) is unnecessary now with full
+ // support of right-aligned text.
+
+ if ( ( nExtFlags & SC_PF_WHOLEROWS ) ||
+ aDocument.HasAttrib( nStartCol,nStartRow,nStartTab,
+ MAXCOL,nEndRow,nEndTab, HASATTR_ROTATE | HASATTR_RIGHTORCENTER ) )
+ {
+ nStartCol = 0;
+ nEndCol = MAXCOL;
+ }
+ }
+
+ Broadcast( ScPaintHint( ScRange( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab ), nPart ) );
+
+ if ( nPart & PAINT_GRID )
+ aDocument.ResetChanged( ScRange(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) );
+}
+
+void ScDocShell::PostPaint( const ScRange& rRange, USHORT nPart, USHORT nExtFlags )
+{
+ PostPaint( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
+ rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab(),
+ nPart, nExtFlags );
+}
+
+void ScDocShell::PostPaintGridAll()
+{
+ PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+}
+
+void ScDocShell::PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, SC_PF_TESTMERGE );
+}
+
+void ScDocShell::PostPaintCell( const ScAddress& rPos )
+{
+ PostPaintCell( rPos.Col(), rPos.Row(), rPos.Tab() );
+}
+
+void ScDocShell::PostPaintExtras()
+{
+ PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS );
+}
+
+void ScDocShell::UpdatePaintExt( USHORT& rExtFlags, const ScRange& rRange )
+{
+ if ( ( rExtFlags & SC_PF_LINES ) == 0 && aDocument.HasAttrib( rRange, HASATTR_PAINTEXT ) )
+ {
+ // If the range contains lines, shadow or conditional formats,
+ // set SC_PF_LINES to include one extra cell in all directions.
+
+ rExtFlags |= SC_PF_LINES;
+ }
+
+ if ( ( rExtFlags & SC_PF_WHOLEROWS ) == 0 &&
+ ( rRange.aStart.Col() != 0 || rRange.aEnd.Col() != MAXCOL ) &&
+ aDocument.HasAttrib( rRange, HASATTR_ROTATE | HASATTR_RIGHTORCENTER ) )
+ {
+ // If the range contains (logically) right- or center-aligned cells,
+ // or rotated cells, set SC_PF_WHOLEROWS to paint the whole rows.
+ // This test isn't needed after the cell changes, because it's also
+ // tested in PostPaint. UpdatePaintExt may later be changed to do this
+ // only if called before the changes.
+
+ rExtFlags |= SC_PF_WHOLEROWS;
+ }
+}
+
+void ScDocShell::UpdatePaintExt( USHORT& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab )
+{
+ UpdatePaintExt( rExtFlags, ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab ) );
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::LockPaint_Impl(BOOL bDoc)
+{
+ if ( !pPaintLockData )
+ pPaintLockData = new ScPaintLockData(0); //! Modus...
+ pPaintLockData->IncLevel(bDoc);
+}
+
+void ScDocShell::UnlockPaint_Impl(BOOL bDoc)
+{
+ if ( pPaintLockData )
+ {
+ if ( pPaintLockData->GetLevel(bDoc) )
+ pPaintLockData->DecLevel(bDoc);
+ if (!pPaintLockData->GetLevel(!bDoc) && !pPaintLockData->GetLevel(bDoc))
+ {
+ // Paint jetzt ausfuehren
+
+ ScPaintLockData* pPaint = pPaintLockData;
+ pPaintLockData = NULL; // nicht weitersammeln
+
+ ScRangeListRef xRangeList = pPaint->GetRangeList();
+ if (xRangeList)
+ {
+ USHORT nParts = pPaint->GetParts();
+ ULONG nCount = xRangeList->Count();
+ for ( ULONG i=0; i<nCount; i++ )
+ {
+ //! nExtFlags ???
+ ScRange aRange = *xRangeList->GetObject(i);
+ PostPaint( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab(),
+ nParts );
+ }
+ }
+
+ if ( pPaint->GetModified() )
+ SetDocumentModified();
+
+ delete pPaint;
+ }
+ }
+ else
+ {
+ DBG_ERROR("UnlockPaint ohne LockPaint");
+ }
+}
+
+void ScDocShell::LockDocument_Impl(USHORT nNew)
+{
+ if (!nDocumentLock)
+ {
+ ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
+ if (pDrawLayer)
+ pDrawLayer->setLock(TRUE);
+ }
+ nDocumentLock = nNew;
+}
+
+void ScDocShell::UnlockDocument_Impl(USHORT nNew)
+{
+ nDocumentLock = nNew;
+ if (!nDocumentLock)
+ {
+ ScDrawLayer* pDrawLayer = aDocument.GetDrawLayer();
+ if (pDrawLayer)
+ pDrawLayer->setLock(FALSE);
+ }
+}
+
+USHORT ScDocShell::GetLockCount() const
+{
+ return nDocumentLock;
+}
+
+void ScDocShell::SetLockCount(USHORT nNew)
+{
+ if (nNew) // setzen
+ {
+ if ( !pPaintLockData )
+ pPaintLockData = new ScPaintLockData(0); //! Modus...
+ pPaintLockData->SetLevel(nNew-1, TRUE);
+ LockDocument_Impl(nNew);
+ }
+ else if (pPaintLockData) // loeschen
+ {
+ pPaintLockData->SetLevel(0, TRUE); // bei Unlock sofort ausfuehren
+ UnlockPaint_Impl(TRUE); // jetzt
+ UnlockDocument_Impl(0);
+ }
+}
+
+void ScDocShell::LockPaint()
+{
+ LockPaint_Impl(FALSE);
+}
+
+void ScDocShell::UnlockPaint()
+{
+ UnlockPaint_Impl(FALSE);
+}
+
+void ScDocShell::LockDocument()
+{
+ LockPaint_Impl(TRUE);
+ LockDocument_Impl(nDocumentLock + 1);
+}
+
+void ScDocShell::UnlockDocument()
+{
+ if (nDocumentLock)
+ {
+ UnlockPaint_Impl(TRUE);
+ UnlockDocument_Impl(nDocumentLock - 1);
+ }
+ else
+ {
+ DBG_ERROR("UnlockDocument without LockDocument");
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::SetInplace( BOOL bInplace )
+{
+ if (bIsInplace != bInplace)
+ {
+ bIsInplace = bInplace;
+ CalcOutputFactor();
+ }
+}
+
+void ScDocShell::CalcOutputFactor()
+{
+ if (bIsInplace)
+ {
+ nPrtToScreenFactor = 1.0; // passt sonst nicht zur inaktiven Darstellung
+ return;
+ }
+
+ BOOL bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
+ if (bTextWysiwyg)
+ {
+ nPrtToScreenFactor = 1.0;
+ return;
+ }
+
+ String aTestString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789" ));
+ long nPrinterWidth = 0;
+ long nWindowWidth = 0;
+ const ScPatternAttr* pPattern = (const ScPatternAttr*)&aDocument.GetPool()->
+ GetDefaultItem(ATTR_PATTERN);
+
+ Font aDefFont;
+ OutputDevice* pRefDev = GetRefDevice();
+ MapMode aOldMode = pRefDev->GetMapMode();
+ Font aOldFont = pRefDev->GetFont();
+
+ pRefDev->SetMapMode(MAP_PIXEL);
+ pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, pRefDev); // font color doesn't matter here
+ pRefDev->SetFont(aDefFont);
+ nPrinterWidth = pRefDev->PixelToLogic( Size( pRefDev->GetTextWidth(aTestString), 0 ), MAP_100TH_MM ).Width();
+ pRefDev->SetFont(aOldFont);
+ pRefDev->SetMapMode(aOldMode);
+
+ VirtualDevice aVirtWindow( *Application::GetDefaultDevice() );
+ aVirtWindow.SetMapMode(MAP_PIXEL);
+ pPattern->GetFont(aDefFont, SC_AUTOCOL_BLACK, &aVirtWindow); // font color doesn't matter here
+ aVirtWindow.SetFont(aDefFont);
+ nWindowWidth = aVirtWindow.GetTextWidth(aTestString);
+ nWindowWidth = (long) ( nWindowWidth / ScGlobal::nScreenPPTX * HMM_PER_TWIPS );
+
+ if (nPrinterWidth && nWindowWidth)
+ nPrtToScreenFactor = nPrinterWidth / (double) nWindowWidth;
+ else
+ {
+ DBG_ERROR("GetTextSize gibt 0 ??");
+ nPrtToScreenFactor = 1.0;
+ }
+}
+
+double ScDocShell::GetOutputFactor() const
+{
+ return nPrtToScreenFactor;
+}
+
+//---------------------------------------------------------------------
+
+void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and Load
+{
+ // Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions
+
+ USHORT nDefLang, nCjkLang, nCtlLang;
+ BOOL bAutoSpell;
+ ScModule::GetSpellSettings( nDefLang, nCjkLang, nCtlLang, bAutoSpell );
+ ScModule* pScMod = SC_MOD();
+
+ ScDocOptions aDocOpt = pScMod->GetDocOptions();
+ ScViewOptions aViewOpt = pScMod->GetViewOptions();
+ aDocOpt.SetAutoSpell( bAutoSpell );
+
+ // zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges
+ aDocOpt.SetYear2000( sal::static_int_cast<USHORT>( ::utl::MiscCfg().GetYear2000() ) );
+
+ if (bForLoading)
+ {
+ // #i112123# No style:decimal-places attribute means automatic decimals, not the configured default,
+ // so it must not be taken from the global options.
+ // Calculation settings are handled separately in ScXMLBodyContext::EndElement.
+ aDocOpt.SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
+ }
+
+ aDocument.SetDocOptions( aDocOpt );
+ aDocument.SetViewOptions( aViewOpt );
+
+ // Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt
+
+ aDocument.SetLanguage( (LanguageType) nDefLang, (LanguageType) nCjkLang, (LanguageType) nCtlLang );
+}
+
+//---------------------------------------------------------------------
+
+Printer* ScDocShell::GetDocumentPrinter() // fuer OLE
+{
+ return aDocument.GetPrinter();
+}
+
+SfxPrinter* ScDocShell::GetPrinter(BOOL bCreateIfNotExist)
+{
+ return aDocument.GetPrinter(bCreateIfNotExist);
+}
+
+void ScDocShell::UpdateFontList()
+{
+ delete pImpl->pFontList;
+ // pImpl->pFontList = new FontList( GetPrinter(), Application::GetDefaultDevice() );
+ pImpl->pFontList = new FontList( GetRefDevice(), NULL, FALSE ); // FALSE or TRUE???
+ SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
+ PutItem( aFontListItem );
+
+ CalcOutputFactor();
+}
+
+OutputDevice* ScDocShell::GetRefDevice()
+{
+ return aDocument.GetRefDevice();
+}
+
+USHORT ScDocShell::SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags )
+{
+ SfxPrinter *pOld = aDocument.GetPrinter( FALSE );
+ if ( pOld && pOld->IsPrinting() )
+ return SFX_PRINTERROR_BUSY;
+
+ if (nDiffFlags & SFX_PRINTER_PRINTER)
+ {
+ if ( aDocument.GetPrinter() != pNewPrinter )
+ {
+ aDocument.SetPrinter( pNewPrinter );
+ aDocument.SetPrintOptions();
+
+ // MT: Use UpdateFontList: Will use Printer fonts only if needed!
+ /*
+ delete pImpl->pFontList;
+ pImpl->pFontList = new FontList( pNewPrinter, Application::GetDefaultDevice() );
+ SvxFontListItem aFontListItem( pImpl->pFontList, SID_ATTR_CHAR_FONTLIST );
+ PutItem( aFontListItem );
+
+ CalcOutputFactor();
+ */
+ if ( SC_MOD()->GetInputOptions().GetTextWysiwyg() )
+ UpdateFontList();
+
+ ScModule* pScMod = SC_MOD();
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst( this );
+ while (pFrame)
+ {
+ SfxViewShell* pSh = pFrame->GetViewShell();
+ if (pSh && pSh->ISA(ScTabViewShell))
+ {
+ ScTabViewShell* pViewSh = (ScTabViewShell*)pSh;
+ ScInputHandler* pInputHdl = pScMod->GetInputHdl(pViewSh);
+ if (pInputHdl)
+ pInputHdl->UpdateRefDevice();
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, this );
+ }
+ }
+ }
+ else if (nDiffFlags & SFX_PRINTER_JOBSETUP)
+ {
+ SfxPrinter* pOldPrinter = aDocument.GetPrinter();
+ if (pOldPrinter)
+ {
+ pOldPrinter->SetJobSetup( pNewPrinter->GetJobSetup() );
+
+ // #i6706# Call SetPrinter with the old printer again, so the drawing layer
+ // RefDevice is set (calling ReformatAllTextObjects and rebuilding charts),
+ // because the JobSetup (printer device settings) may affect text layout.
+ aDocument.SetPrinter( pOldPrinter );
+ CalcOutputFactor(); // also with the new settings
+ }
+ }
+
+ if (nDiffFlags & SFX_PRINTER_OPTIONS)
+ {
+ aDocument.SetPrintOptions(); //! aus neuem Printer ???
+ }
+
+ if (nDiffFlags & (SFX_PRINTER_CHG_ORIENTATION | SFX_PRINTER_CHG_SIZE))
+ {
+ String aStyle = aDocument.GetPageStyle( GetCurTab() );
+ ScStyleSheetPool* pStPl = aDocument.GetStyleSheetPool();
+ SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStPl->Find(aStyle, SFX_STYLE_FAMILY_PAGE);
+ if (pStyleSheet)
+ {
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+
+ if (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION)
+ {
+ const SvxPageItem& rOldItem = (const SvxPageItem&)rSet.Get(ATTR_PAGE);
+ BOOL bWasLand = rOldItem.IsLandscape();
+ BOOL bNewLand = ( pNewPrinter->GetOrientation() == ORIENTATION_LANDSCAPE );
+ if (bNewLand != bWasLand)
+ {
+ SvxPageItem aNewItem( rOldItem );
+ aNewItem.SetLandscape( bNewLand );
+ rSet.Put( aNewItem );
+
+ // Groesse umdrehen
+ Size aOldSize = ((const SvxSizeItem&)rSet.Get(ATTR_PAGE_SIZE)).GetSize();
+ Size aNewSize(aOldSize.Height(),aOldSize.Width());
+ SvxSizeItem aNewSItem(ATTR_PAGE_SIZE,aNewSize);
+ rSet.Put( aNewSItem );
+ }
+ }
+ if (nDiffFlags & SFX_PRINTER_CHG_SIZE)
+ {
+ SvxSizeItem aPaperSizeItem( ATTR_PAGE_SIZE, SvxPaperInfo::GetPaperSize(pNewPrinter) );
+ rSet.Put( aPaperSizeItem );
+ }
+ }
+ }
+
+ PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB,PAINT_ALL);
+
+ return 0;
+}
+
+//---------------------------------------------------------------------
+
+ScChangeAction* ScDocShell::GetChangeAction( const ScAddress& rPos )
+{
+ ScChangeTrack* pTrack = GetDocument()->GetChangeTrack();
+ if (!pTrack)
+ return NULL;
+
+ SCTAB nTab = rPos.Tab();
+
+ const ScChangeAction* pFound = NULL;
+ const ScChangeAction* pFoundContent = NULL;
+ const ScChangeAction* pFoundMove = NULL;
+ long nModified = 0;
+ const ScChangeAction* pAction = pTrack->GetFirst();
+ while (pAction)
+ {
+ ScChangeActionType eType = pAction->GetType();
+ //! ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc )...
+ if ( pAction->IsVisible() && eType != SC_CAT_DELETE_TABS )
+ {
+ const ScBigRange& rBig = pAction->GetBigRange();
+ if ( rBig.aStart.Tab() == nTab )
+ {
+ ScRange aRange = rBig.MakeRange();
+
+ if ( eType == SC_CAT_DELETE_ROWS )
+ aRange.aEnd.SetRow( aRange.aStart.Row() );
+ else if ( eType == SC_CAT_DELETE_COLS )
+ aRange.aEnd.SetCol( aRange.aStart.Col() );
+
+ if ( aRange.In( rPos ) )
+ {
+ pFound = pAction; // der letzte gewinnt
+ switch ( pAction->GetType() )
+ {
+ case SC_CAT_CONTENT :
+ pFoundContent = pAction;
+ break;
+ case SC_CAT_MOVE :
+ pFoundMove = pAction;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ ++nModified;
+ }
+ }
+ if ( pAction->GetType() == SC_CAT_MOVE )
+ {
+ ScRange aRange =
+ ((const ScChangeActionMove*)pAction)->
+ GetFromRange().MakeRange();
+ if ( aRange.In( rPos ) )
+ {
+ pFound = pAction;
+ ++nModified;
+ }
+ }
+ }
+ pAction = pAction->GetNext();
+ }
+
+ return (ScChangeAction*)pFound;
+}
+
+void ScDocShell::SetChangeComment( ScChangeAction* pAction, const String& rComment )
+{
+ if (pAction)
+ {
+ pAction->SetComment( rComment );
+ //! Undo ???
+ SetDocumentModified();
+
+ // Dialog-Notify
+ ScChangeTrack* pTrack = GetDocument()->GetChangeTrack();
+ if (pTrack)
+ {
+ ULONG nNumber = pAction->GetActionNumber();
+ pTrack->NotifyModified( SC_CTM_CHANGE, nNumber, nNumber );
+ }
+ }
+}
+
+void ScDocShell::ExecuteChangeCommentDialog( ScChangeAction* pAction, Window* pParent,BOOL bPrevNext)
+{
+ if (!pAction) return; // ohne Aktion ist nichts..
+
+ String aComment = pAction->GetComment();
+ String aAuthor = pAction->GetUser();
+
+ DateTime aDT = pAction->GetDateTime();
+ String aDate = ScGlobal::pLocaleData->getDate( aDT );
+ aDate += ' ';
+ aDate += ScGlobal::pLocaleData->getTime( aDT, FALSE, FALSE );
+
+ SfxItemSet aSet( GetPool(),
+ SID_ATTR_POSTIT_AUTHOR, SID_ATTR_POSTIT_AUTHOR,
+ SID_ATTR_POSTIT_DATE, SID_ATTR_POSTIT_DATE,
+ SID_ATTR_POSTIT_TEXT, SID_ATTR_POSTIT_TEXT,
+ 0 );
+
+ aSet.Put( SvxPostItTextItem ( aComment, SID_ATTR_POSTIT_TEXT ) );
+ aSet.Put( SvxPostItAuthorItem( aAuthor, SID_ATTR_POSTIT_AUTHOR ) );
+ aSet.Put( SvxPostItDateItem ( aDate, SID_ATTR_POSTIT_DATE ) );
+
+ ScRedComDialog* pDlg = new ScRedComDialog( pParent, aSet,this,pAction,bPrevNext);
+
+ pDlg->Execute();
+
+ delete pDlg;
+}
+
+//---------------------------------------------------------------------
+
+void ScDocShell::CompareDocument( ScDocument& rOtherDoc )
+{
+ ScChangeTrack* pTrack = aDocument.GetChangeTrack();
+ if ( pTrack && pTrack->GetFirst() )
+ {
+ //! Changes vorhanden -> Nachfrage ob geloescht werden soll
+ }
+
+ aDocument.EndChangeTracking();
+ aDocument.StartChangeTracking();
+
+ String aOldUser;
+ pTrack = aDocument.GetChangeTrack();
+ if ( pTrack )
+ {
+ aOldUser = pTrack->GetUser();
+
+ // check if comparing to same document
+
+ String aThisFile;
+ const SfxMedium* pThisMed = GetMedium();
+ if (pThisMed)
+ aThisFile = pThisMed->GetName();
+ String aOtherFile;
+ SfxObjectShell* pOtherSh = rOtherDoc.GetDocumentShell();
+ if (pOtherSh)
+ {
+ const SfxMedium* pOtherMed = pOtherSh->GetMedium();
+ if (pOtherMed)
+ aOtherFile = pOtherMed->GetName();
+ }
+ BOOL bSameDoc = ( aThisFile == aOtherFile && aThisFile.Len() );
+ if ( !bSameDoc )
+ {
+ // create change actions from comparing with the name of the user
+ // who last saved the document
+ // (only if comparing different documents)
+
+ using namespace ::com::sun::star;
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
+ GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps(
+ xDPS->getDocumentProperties());
+ DBG_ASSERT(xDocProps.is(), "no DocumentProperties");
+ String aDocUser = xDocProps->getModifiedBy();
+
+ if ( aDocUser.Len() )
+ pTrack->SetUser( aDocUser );
+ }
+ }
+
+ aDocument.CompareDocument( rOtherDoc );
+
+ pTrack = aDocument.GetChangeTrack();
+ if ( pTrack )
+ pTrack->SetUser( aOldUser );
+
+ PostPaintGridAll();
+ SetDocumentModified();
+}
+
+//---------------------------------------------------------------------
+//
+// Merge (Aenderungen zusammenfuehren)
+//
+//---------------------------------------------------------------------
+
+inline BOOL lcl_Equal( const ScChangeAction* pA, const ScChangeAction* pB, BOOL bIgnore100Sec )
+{
+ return pA && pB &&
+ pA->GetActionNumber() == pB->GetActionNumber() &&
+ pA->GetType() == pB->GetType() &&
+ pA->GetUser() == pB->GetUser() &&
+ (bIgnore100Sec ?
+ pA->GetDateTimeUTC().IsEqualIgnore100Sec( pB->GetDateTimeUTC() ) :
+ pA->GetDateTimeUTC() == pB->GetDateTimeUTC());
+ // State nicht vergleichen, falls eine alte Aenderung akzeptiert wurde
+}
+
+bool lcl_FindAction( ScDocument* pDoc, const ScChangeAction* pAction, ScDocument* pSearchDoc, const ScChangeAction* pFirstSearchAction, const ScChangeAction* pLastSearchAction, BOOL bIgnore100Sec )
+{
+ if ( !pDoc || !pAction || !pSearchDoc || !pFirstSearchAction || !pLastSearchAction )
+ {
+ return false;
+ }
+
+ ULONG nLastSearchAction = pLastSearchAction->GetActionNumber();
+ const ScChangeAction* pA = pFirstSearchAction;
+ while ( pA && pA->GetActionNumber() <= nLastSearchAction )
+ {
+ if ( pAction->GetType() == pA->GetType() &&
+ pAction->GetUser() == pA->GetUser() &&
+ (bIgnore100Sec ?
+ pAction->GetDateTimeUTC().IsEqualIgnore100Sec( pA->GetDateTimeUTC() ) :
+ pAction->GetDateTimeUTC() == pA->GetDateTimeUTC() ) &&
+ pAction->GetBigRange() == pA->GetBigRange() )
+ {
+ String aActionDesc;
+ pAction->GetDescription( aActionDesc, pDoc, TRUE );
+ String aADesc;
+ pA->GetDescription( aADesc, pSearchDoc, TRUE );
+ if ( aActionDesc.Equals( aADesc ) )
+ {
+ DBG_ERROR( "lcl_FindAction(): found equal action!" );
+ return true;
+ }
+ }
+ pA = pA->GetNext();
+ }
+
+ return false;
+}
+
+void ScDocShell::MergeDocument( ScDocument& rOtherDoc, bool bShared, bool bCheckDuplicates, ULONG nOffset, ScChangeActionMergeMap* pMergeMap, bool bInverseMap )
+{
+ ScTabViewShell* pViewSh = GetBestViewShell( FALSE ); //! Funktionen an die DocShell
+ if (!pViewSh)
+ return;
+
+ ScChangeTrack* pSourceTrack = rOtherDoc.GetChangeTrack();
+ if (!pSourceTrack)
+ return; //! nichts zu tun - Fehlermeldung?
+
+ ScChangeTrack* pThisTrack = aDocument.GetChangeTrack();
+ if ( !pThisTrack )
+ { // anschalten
+ aDocument.StartChangeTracking();
+ pThisTrack = aDocument.GetChangeTrack();
+ DBG_ASSERT(pThisTrack,"ChangeTracking nicht angeschaltet?");
+ if ( !bShared )
+ {
+ // #51138# visuelles RedLining einschalten
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges(TRUE);
+ aDocument.SetChangeViewSettings(aChangeViewSet);
+ }
+ }
+
+ // #97286# include 100th seconds in compare?
+ BOOL bIgnore100Sec = !pSourceTrack->IsTime100thSeconds() ||
+ !pThisTrack->IsTime100thSeconds();
+
+ // gemeinsame Ausgangsposition suchen
+ ULONG nFirstNewNumber = 0;
+ const ScChangeAction* pSourceAction = pSourceTrack->GetFirst();
+ const ScChangeAction* pThisAction = pThisTrack->GetFirst();
+ // skip identical actions
+ while ( lcl_Equal( pSourceAction, pThisAction, bIgnore100Sec ) )
+ {
+ nFirstNewNumber = pSourceAction->GetActionNumber() + 1;
+ pSourceAction = pSourceAction->GetNext();
+ pThisAction = pThisAction->GetNext();
+ }
+ // pSourceAction und pThisAction zeigen jetzt auf die ersten "eigenen" Aktionen
+ // Die gemeinsamen Aktionen davor interessieren ueberhaupt nicht
+
+ //! Abfrage, ob die Dokumente vor dem Change-Tracking gleich waren !!!
+
+
+ const ScChangeAction* pFirstMergeAction = pSourceAction;
+ const ScChangeAction* pFirstSearchAction = pThisAction;
+
+ // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
+ const ScChangeAction* pLastSearchAction = pThisTrack->GetLast();
+
+ // MergeChangeData aus den folgenden Aktionen erzeugen
+ ULONG nNewActionCount = 0;
+ const ScChangeAction* pCount = pSourceAction;
+ while ( pCount )
+ {
+ if ( bShared || !ScChangeTrack::MergeIgnore( *pCount, nFirstNewNumber ) )
+ ++nNewActionCount;
+ pCount = pCount->GetNext();
+ }
+ if (!nNewActionCount)
+ return; //! nichts zu tun - Fehlermeldung?
+ // ab hier kein return mehr
+
+ ScProgress aProgress( this,
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("...")),
+ nNewActionCount );
+
+ ULONG nLastMergeAction = pSourceTrack->GetLast()->GetActionNumber();
+ // UpdateReference-Undo, gueltige Referenzen fuer den letzten gemeinsamen Zustand
+ pSourceTrack->MergePrepare( (ScChangeAction*) pFirstMergeAction, bShared );
+
+ // MergeChangeData an alle noch folgenden Aktionen in diesem Dokument anpassen
+ // -> Referenzen gueltig fuer dieses Dokument
+ while ( pThisAction )
+ {
+ // #i87049# [Collaboration] Conflict between delete row and insert content is not merged correctly
+ if ( !bShared || !ScChangeTrack::MergeIgnore( *pThisAction, nFirstNewNumber ) )
+ {
+ ScChangeActionType eType = pThisAction->GetType();
+ switch ( eType )
+ {
+ case SC_CAT_INSERT_COLS :
+ case SC_CAT_INSERT_ROWS :
+ case SC_CAT_INSERT_TABS :
+ pSourceTrack->AppendInsert( pThisAction->GetBigRange().MakeRange() );
+ break;
+ case SC_CAT_DELETE_COLS :
+ case SC_CAT_DELETE_ROWS :
+ case SC_CAT_DELETE_TABS :
+ {
+ const ScChangeActionDel* pDel = (const ScChangeActionDel*) pThisAction;
+ if ( pDel->IsTopDelete() && !pDel->IsTabDeleteCol() )
+ { // deleted Table enthaelt deleted Cols, die nicht
+ ULONG nStart, nEnd;
+ pSourceTrack->AppendDeleteRange(
+ pDel->GetOverAllRange().MakeRange(), NULL, nStart, nEnd );
+ }
+ }
+ break;
+ case SC_CAT_MOVE :
+ {
+ const ScChangeActionMove* pMove = (const ScChangeActionMove*) pThisAction;
+ pSourceTrack->AppendMove( pMove->GetFromRange().MakeRange(),
+ pMove->GetBigRange().MakeRange(), NULL );
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ pThisAction = pThisAction->GetNext();
+ }
+
+ LockPaint(); // #i73877# no repainting after each action
+
+ // MergeChangeData in das aktuelle Dokument uebernehmen
+ BOOL bHasRejected = FALSE;
+ String aOldUser = pThisTrack->GetUser();
+ pThisTrack->SetUseFixDateTime( TRUE );
+ ScMarkData& rMarkData = pViewSh->GetViewData()->GetMarkData();
+ ScMarkData aOldMarkData( rMarkData );
+ pSourceAction = pFirstMergeAction;
+ while ( pSourceAction && pSourceAction->GetActionNumber() <= nLastMergeAction )
+ {
+ bool bMergeAction = false;
+ if ( bShared )
+ {
+ if ( !bCheckDuplicates || !lcl_FindAction( &rOtherDoc, pSourceAction, &aDocument, pFirstSearchAction, pLastSearchAction, bIgnore100Sec ) )
+ {
+ bMergeAction = true;
+ }
+ }
+ else
+ {
+ if ( !ScChangeTrack::MergeIgnore( *pSourceAction, nFirstNewNumber ) )
+ {
+ bMergeAction = true;
+ }
+ }
+
+ if ( bMergeAction )
+ {
+ ScChangeActionType eSourceType = pSourceAction->GetType();
+ if ( !bShared && pSourceAction->IsDeletedIn() )
+ {
+ //! muss hier noch festgestellt werden, ob wirklich in
+ //! _diesem_ Dokument geloescht?
+
+ // liegt in einem Bereich, der in diesem Dokument geloescht wurde
+ // -> wird weggelassen
+ //! ??? Loesch-Aktion rueckgaengig machen ???
+ //! ??? Aktion irgendwo anders speichern ???
+#ifdef DBG_UTIL
+ String aValue;
+ if ( eSourceType == SC_CAT_CONTENT )
+ ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
+ ByteString aError( aValue, gsl_getSystemTextEncoding() );
+ aError += " weggelassen";
+ DBG_ERROR( aError.GetBuffer() );
+#endif
+ }
+ else
+ {
+ //! Datum/Autor/Kommentar der Source-Aktion uebernehmen!
+
+ pThisTrack->SetUser( pSourceAction->GetUser() );
+ pThisTrack->SetFixDateTimeUTC( pSourceAction->GetDateTimeUTC() );
+ ULONG nOldActionMax = pThisTrack->GetActionMax();
+
+ bool bExecute = true;
+ ULONG nReject = pSourceAction->GetRejectAction();
+ if ( nReject )
+ {
+ if ( bShared )
+ {
+ if ( nReject >= nFirstNewNumber )
+ {
+ nReject += nOffset;
+ }
+ ScChangeAction* pOldAction = pThisTrack->GetAction( nReject );
+ if ( pOldAction && pOldAction->IsVirgin() )
+ {
+ pThisTrack->Reject( pOldAction );
+ bHasRejected = TRUE;
+ bExecute = false;
+ }
+ }
+ else
+ {
+ // alte Aktion (aus den gemeinsamen) ablehnen
+ ScChangeAction* pOldAction = pThisTrack->GetAction( nReject );
+ if (pOldAction && pOldAction->GetState() == SC_CAS_VIRGIN)
+ {
+ //! was passiert bei Aktionen, die in diesem Dokument accepted worden sind???
+ //! Fehlermeldung oder was???
+ //! oder Reject-Aenderung normal ausfuehren
+
+ pThisTrack->Reject(pOldAction);
+ bHasRejected = TRUE; // fuer Paint
+ }
+ bExecute = false;
+ }
+ }
+
+ if ( bExecute )
+ {
+ // normal ausfuehren
+ ScRange aSourceRange = pSourceAction->GetBigRange().MakeRange();
+ rMarkData.SelectOneTable( aSourceRange.aStart.Tab() );
+ switch ( eSourceType )
+ {
+ case SC_CAT_CONTENT:
+ {
+ //! Test, ob es ganz unten im Dokument war, dann automatisches
+ //! Zeilen-Einfuegen ???
+
+ DBG_ASSERT( aSourceRange.aStart == aSourceRange.aEnd, "huch?" );
+ ScAddress aPos = aSourceRange.aStart;
+ String aValue;
+ ((const ScChangeActionContent*)pSourceAction)->GetNewString( aValue );
+ BYTE eMatrix = MM_NONE;
+ const ScBaseCell* pCell = ((const ScChangeActionContent*)pSourceAction)->GetNewCell();
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ eMatrix = ((const ScFormulaCell*)pCell)->GetMatrixFlag();
+ switch ( eMatrix )
+ {
+ case MM_NONE :
+ pViewSh->EnterData( aPos.Col(), aPos.Row(), aPos.Tab(), aValue );
+ break;
+ case MM_FORMULA :
+ {
+ SCCOL nCols;
+ SCROW nRows;
+ ((const ScFormulaCell*)pCell)->GetMatColsRows( nCols, nRows );
+ aSourceRange.aEnd.SetCol( aPos.Col() + nCols - 1 );
+ aSourceRange.aEnd.SetRow( aPos.Row() + nRows - 1 );
+ aValue.Erase( 0, 1 );
+ aValue.Erase( aValue.Len()-1, 1 );
+ GetDocFunc().EnterMatrix( aSourceRange,
+ NULL, NULL, aValue, FALSE, FALSE,
+ EMPTY_STRING, formula::FormulaGrammar::GRAM_DEFAULT );
+ }
+ break;
+ case MM_REFERENCE : // do nothing
+ break;
+ case MM_FAKE :
+ DBG_WARNING( "MergeDocument: MatrixFlag MM_FAKE" );
+ pViewSh->EnterData( aPos.Col(), aPos.Row(), aPos.Tab(), aValue );
+ break;
+ default:
+ DBG_ERROR( "MergeDocument: unknown MatrixFlag" );
+ }
+ }
+ break;
+ case SC_CAT_INSERT_TABS :
+ {
+ String aName;
+ aDocument.CreateValidTabName( aName );
+ GetDocFunc().InsertTable( aSourceRange.aStart.Tab(), aName, TRUE, FALSE );
+ }
+ break;
+ case SC_CAT_INSERT_ROWS:
+ GetDocFunc().InsertCells( aSourceRange, NULL, INS_INSROWS, TRUE, FALSE );
+ break;
+ case SC_CAT_INSERT_COLS:
+ GetDocFunc().InsertCells( aSourceRange, NULL, INS_INSCOLS, TRUE, FALSE );
+ break;
+ case SC_CAT_DELETE_TABS :
+ GetDocFunc().DeleteTable( aSourceRange.aStart.Tab(), TRUE, FALSE );
+ break;
+ case SC_CAT_DELETE_ROWS:
+ {
+ const ScChangeActionDel* pDel = (const ScChangeActionDel*) pSourceAction;
+ if ( pDel->IsTopDelete() )
+ {
+ aSourceRange = pDel->GetOverAllRange().MakeRange();
+ GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELROWS, TRUE, FALSE );
+
+ // #i101099# [Collaboration] Changes are not correctly shown
+ if ( bShared )
+ {
+ ScChangeAction* pAct = pThisTrack->GetLast();
+ if ( pAct && pAct->GetType() == eSourceType && pAct->IsDeletedIn() && !pSourceAction->IsDeletedIn() )
+ {
+ pAct->RemoveAllDeletedIn();
+ }
+ }
+ }
+ }
+ break;
+ case SC_CAT_DELETE_COLS:
+ {
+ const ScChangeActionDel* pDel = (const ScChangeActionDel*) pSourceAction;
+ if ( pDel->IsTopDelete() && !pDel->IsTabDeleteCol() )
+ { // deleted Table enthaelt deleted Cols, die nicht
+ aSourceRange = pDel->GetOverAllRange().MakeRange();
+ GetDocFunc().DeleteCells( aSourceRange, NULL, DEL_DELCOLS, TRUE, FALSE );
+ }
+ }
+ break;
+ case SC_CAT_MOVE :
+ {
+ const ScChangeActionMove* pMove = (const ScChangeActionMove*) pSourceAction;
+ ScRange aFromRange( pMove->GetFromRange().MakeRange() );
+ GetDocFunc().MoveBlock( aFromRange,
+ aSourceRange.aStart, TRUE, TRUE, FALSE, FALSE );
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ const String& rComment = pSourceAction->GetComment();
+ if ( rComment.Len() )
+ {
+ ScChangeAction* pAct = pThisTrack->GetLast();
+ if ( pAct && pAct->GetActionNumber() > nOldActionMax )
+ pAct->SetComment( rComment );
+#ifdef DBG_UTIL
+ else
+ DBG_ERROR( "MergeDocument: wohin mit dem Kommentar?!?" );
+#endif
+ }
+
+ // Referenzen anpassen
+ pSourceTrack->MergeOwn( (ScChangeAction*) pSourceAction, nFirstNewNumber, bShared );
+
+ // merge action state
+ if ( bShared && !pSourceAction->IsRejected() )
+ {
+ ScChangeAction* pAct = pThisTrack->GetLast();
+ if ( pAct && pAct->GetActionNumber() > nOldActionMax )
+ {
+ pThisTrack->MergeActionState( pAct, pSourceAction );
+ }
+ }
+
+ // fill merge map
+ if ( bShared && pMergeMap )
+ {
+ ScChangeAction* pAct = pThisTrack->GetLast();
+ if ( pAct && pAct->GetActionNumber() > nOldActionMax )
+ {
+ ULONG nActionMax = pAct->GetActionNumber();
+ ULONG nActionCount = nActionMax - nOldActionMax;
+ ULONG nAction = nActionMax - nActionCount + 1;
+ ULONG nSourceAction = pSourceAction->GetActionNumber() - nActionCount + 1;
+ while ( nAction <= nActionMax )
+ {
+ if ( bInverseMap )
+ {
+ (*pMergeMap)[ nAction++ ] = nSourceAction++;
+ }
+ else
+ {
+ (*pMergeMap)[ nSourceAction++ ] = nAction++;
+ }
+ }
+ }
+ }
+ }
+ aProgress.SetStateCountDown( --nNewActionCount );
+ }
+ pSourceAction = pSourceAction->GetNext();
+ }
+
+ rMarkData = aOldMarkData;
+ pThisTrack->SetUser(aOldUser);
+ pThisTrack->SetUseFixDateTime( FALSE );
+
+ pSourceTrack->Clear(); //! der ist jetzt verhunzt
+
+ if (bHasRejected)
+ PostPaintGridAll(); // Reject() paintet nicht selber
+
+ UnlockPaint();
+}
+
+bool ScDocShell::MergeSharedDocument( ScDocShell* pSharedDocShell )
+{
+ if ( !pSharedDocShell )
+ {
+ return false;
+ }
+
+ ScChangeTrack* pThisTrack = aDocument.GetChangeTrack();
+ if ( !pThisTrack )
+ {
+ return false;
+ }
+
+ ScDocument& rSharedDoc = *( pSharedDocShell->GetDocument() );
+ ScChangeTrack* pSharedTrack = rSharedDoc.GetChangeTrack();
+ if ( !pSharedTrack )
+ {
+ return false;
+ }
+
+#if DEBUG_CHANGETRACK
+ ::rtl::OUString aMessage = ::rtl::OUString::createFromAscii( "\nbefore merge:\n" );
+ aMessage += pThisTrack->ToString();
+ ::rtl::OString aMsg = ::rtl::OUStringToOString( aMessage, RTL_TEXTENCODING_UTF8 );
+ OSL_ENSURE( false, aMsg.getStr() );
+ //fprintf( stdout, "%s ", aMsg.getStr() );
+ //fflush( stdout );
+#endif // DEBUG_CHANGETRACK
+
+ // reset show changes
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges( FALSE );
+ aDocument.SetChangeViewSettings( aChangeViewSet );
+
+ // find first merge action in this document
+ BOOL bIgnore100Sec = !pThisTrack->IsTime100thSeconds() || !pSharedTrack->IsTime100thSeconds();
+ ScChangeAction* pThisAction = pThisTrack->GetFirst();
+ ScChangeAction* pSharedAction = pSharedTrack->GetFirst();
+ while ( lcl_Equal( pThisAction, pSharedAction, bIgnore100Sec ) )
+ {
+ pThisAction = pThisAction->GetNext();
+ pSharedAction = pSharedAction->GetNext();
+ }
+
+ if ( pSharedAction )
+ {
+ if ( pThisAction )
+ {
+ // merge own changes into shared document
+ ULONG nActStartShared = pSharedAction->GetActionNumber();
+ ULONG nActEndShared = pSharedTrack->GetActionMax();
+ ScDocument* pTmpDoc = new ScDocument;
+ for ( sal_Int32 nIndex = 0; nIndex < aDocument.GetTableCount(); ++nIndex )
+ {
+ String sTabName;
+ pTmpDoc->CreateValidTabName( sTabName );
+ pTmpDoc->InsertTab( SC_TAB_APPEND, sTabName );
+ }
+ aDocument.GetChangeTrack()->Clone( pTmpDoc );
+ ScChangeActionMergeMap aOwnInverseMergeMap;
+ pSharedDocShell->MergeDocument( *pTmpDoc, true, true, 0, &aOwnInverseMergeMap, true );
+ delete pTmpDoc;
+ ULONG nActStartOwn = nActEndShared + 1;
+ ULONG nActEndOwn = pSharedTrack->GetActionMax();
+
+ // find conflicts
+ ScConflictsList aConflictsList;
+ ScConflictsFinder aFinder( pSharedTrack, nActStartShared, nActEndShared, nActStartOwn, nActEndOwn, aConflictsList );
+ if ( aFinder.Find() )
+ {
+ ScConflictsListHelper::TransformConflictsList( aConflictsList, NULL, &aOwnInverseMergeMap );
+ bool bLoop = true;
+ while ( bLoop )
+ {
+ bLoop = false;
+ ScConflictsDlg aDlg( GetActiveDialogParent(), GetViewData(), &rSharedDoc, aConflictsList );
+ if ( aDlg.Execute() == RET_CANCEL )
+ {
+ QueryBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
+ ScGlobal::GetRscString( STR_DOC_WILLNOTBESAVED ) );
+ if ( aBox.Execute() == RET_YES )
+ {
+ return false;
+ }
+ else
+ {
+ bLoop = true;
+ }
+ }
+ }
+ }
+
+ // undo own changes in shared document
+ pSharedTrack->Undo( nActStartOwn, nActEndOwn );
+
+ // clone change track for merging into own document
+ pTmpDoc = new ScDocument;
+ for ( sal_Int32 nIndex = 0; nIndex < aDocument.GetTableCount(); ++nIndex )
+ {
+ String sTabName;
+ pTmpDoc->CreateValidTabName( sTabName );
+ pTmpDoc->InsertTab( SC_TAB_APPEND, sTabName );
+ }
+ pThisTrack->Clone( pTmpDoc );
+
+ // undo own changes since last save in own document
+ ULONG nStartShared = pThisAction->GetActionNumber();
+ ScChangeAction* pAction = pThisTrack->GetLast();
+ while ( pAction && pAction->GetActionNumber() >= nStartShared )
+ {
+ pThisTrack->Reject( pAction, true );
+ pAction = pAction->GetPrev();
+ }
+
+ // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
+ pThisTrack->Undo( nStartShared, pThisTrack->GetActionMax(), true );
+
+ // merge shared changes into own document
+ ScChangeActionMergeMap aSharedMergeMap;
+ MergeDocument( rSharedDoc, true, true, 0, &aSharedMergeMap );
+ ULONG nEndShared = pThisTrack->GetActionMax();
+
+ // resolve conflicts for shared non-content actions
+ if ( !aConflictsList.empty() )
+ {
+ ScConflictsListHelper::TransformConflictsList( aConflictsList, &aSharedMergeMap, NULL );
+ ScConflictsResolver aResolver( pThisTrack, aConflictsList );
+ pAction = pThisTrack->GetAction( nEndShared );
+ while ( pAction && pAction->GetActionNumber() >= nStartShared )
+ {
+ aResolver.HandleAction( pAction, true /*bIsSharedAction*/,
+ false /*bHandleContentAction*/, true /*bHandleNonContentAction*/ );
+ pAction = pAction->GetPrev();
+ }
+ }
+ nEndShared = pThisTrack->GetActionMax();
+
+ // only show changes from shared document
+ aChangeViewSet.SetShowChanges( TRUE );
+ aChangeViewSet.SetShowAccepted( TRUE );
+ aChangeViewSet.SetHasActionRange( true );
+ aChangeViewSet.SetTheActionRange( nStartShared, nEndShared );
+ aDocument.SetChangeViewSettings( aChangeViewSet );
+
+ // merge own changes back into own document
+ ULONG nStartOwn = nEndShared + 1;
+ ScChangeActionMergeMap aOwnMergeMap;
+ MergeDocument( *pTmpDoc, true, true, nEndShared - nStartShared + 1, &aOwnMergeMap );
+ delete pTmpDoc;
+ ULONG nEndOwn = pThisTrack->GetActionMax();
+
+ // resolve conflicts for shared content actions and own actions
+ if ( !aConflictsList.empty() )
+ {
+ ScConflictsListHelper::TransformConflictsList( aConflictsList, NULL, &aOwnMergeMap );
+ ScConflictsResolver aResolver( pThisTrack, aConflictsList );
+ pAction = pThisTrack->GetAction( nEndShared );
+ while ( pAction && pAction->GetActionNumber() >= nStartShared )
+ {
+ aResolver.HandleAction( pAction, true /*bIsSharedAction*/,
+ true /*bHandleContentAction*/, false /*bHandleNonContentAction*/ );
+ pAction = pAction->GetPrev();
+ }
+
+ pAction = pThisTrack->GetAction( nEndOwn );
+ while ( pAction && pAction->GetActionNumber() >= nStartOwn )
+ {
+ aResolver.HandleAction( pAction, false /*bIsSharedAction*/,
+ true /*bHandleContentAction*/, true /*bHandleNonContentAction*/ );
+ pAction = pAction->GetPrev();
+ }
+ }
+ nEndOwn = pThisTrack->GetActionMax();
+ }
+ else
+ {
+ // merge shared changes into own document
+ ULONG nStartShared = pThisTrack->GetActionMax() + 1;
+ MergeDocument( rSharedDoc, true, true );
+ ULONG nEndShared = pThisTrack->GetActionMax();
+
+ // only show changes from shared document
+ aChangeViewSet.SetShowChanges( TRUE );
+ aChangeViewSet.SetShowAccepted( TRUE );
+ aChangeViewSet.SetHasActionRange( true );
+ aChangeViewSet.SetTheActionRange( nStartShared, nEndShared );
+ aDocument.SetChangeViewSettings( aChangeViewSet );
+ }
+
+ // update view
+ PostPaintExtras();
+ PostPaintGridAll();
+
+ InfoBox aInfoBox( GetActiveDialogParent(), ScGlobal::GetRscString( STR_DOC_UPDATED ) );
+ aInfoBox.Execute();
+ }
+
+#if DEBUG_CHANGETRACK
+ aMessage = ::rtl::OUString::createFromAscii( "\nafter merge:\n" );
+ aMessage += pThisTrack->ToString();
+ aMsg = ::rtl::OUStringToOString( aMessage, RTL_TEXTENCODING_UTF8 );
+ OSL_ENSURE( false, aMsg.getStr() );
+ //fprintf( stdout, "%s ", aMsg.getStr() );
+ //fflush( stdout );
+#endif // DEBUG_CHANGETRACK
+
+ return ( pThisAction != NULL );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
new file mode 100644
index 000000000000..353fff9043d4
--- /dev/null
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -0,0 +1,2718 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+
+
+using namespace ::com::sun::star;
+
+// INCLUDE ---------------------------------------------------------------
+#if STLPORT_VERSION>=321
+#include <math.h> // prevent conflict between exception and std::exception
+#endif
+
+#include "scitems.hxx"
+#include <sfx2/fcontnr.hxx>
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <svtools/ehdl.hxx>
+#include <basic/sbxcore.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/request.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svx/ofaitem.hxx>
+#include <sot/formats.hxx>
+#include <svtools/printdlg.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+#include <tools/multisel.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/fmview.hxx>
+#include <svx/pageitem.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/fmshell.hxx>
+#include <svtools/xwindowitem.hxx>
+#include <sfx2/passwd.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <sfx2/docinsert.hxx>
+#include <svl/PasswordHelper.hxx>
+#include <svl/documentlockfile.hxx>
+#include <svl/sharecontrolfile.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include "docuno.hxx"
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "docsh.hxx"
+#include "docshimp.hxx"
+#include "docfunc.hxx"
+#include "sc.hrc"
+#include "stlsheet.hxx"
+#include "stlpool.hxx"
+#include "appoptio.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "dbdocfun.hxx"
+#include "printfun.hxx" // DrawToDev
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "attrib.hxx"
+#include "undodat.hxx"
+#include "autostyl.hxx"
+#include "undocell.hxx"
+#include "undotab.hxx"
+#include "inputhdl.hxx"
+#include "dbcolect.hxx"
+#include "servobj.hxx"
+#include "rangenam.hxx"
+#include "scmod.hxx"
+#include "chgviset.hxx"
+#include "reffact.hxx"
+#include "chartlis.hxx"
+#include "waitoff.hxx"
+#include "tablink.hxx" // ScDocumentLoader statics
+#include "drwlayer.hxx"
+#include "docoptio.hxx"
+#include "undostyl.hxx"
+#include "rangeseq.hxx"
+#include "chgtrack.hxx"
+#include "printopt.hxx"
+#include <com/sun/star/document/UpdateDocMode.hpp>
+#include "scresid.hxx"
+#include "scabstdlg.hxx"
+#include "externalrefmgr.hxx"
+#include "sharedocdlg.hxx"
+#include "conditio.hxx"
+#include "sheetevents.hxx"
+
+//------------------------------------------------------------------
+
+#define IS_SHARE_HEADER(set) \
+ ((SfxBoolItem&) \
+ ((SvxSetItem&)(set).Get(ATTR_PAGE_HEADERSET)).GetItemSet(). \
+ Get(ATTR_PAGE_SHARED)).GetValue()
+
+#define IS_SHARE_FOOTER(set) \
+ ((SfxBoolItem&) \
+ ((SvxSetItem&)(set).Get(ATTR_PAGE_FOOTERSET)).GetItemSet(). \
+ Get(ATTR_PAGE_SHARED)).GetValue()
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+#define SC_PREVIEW_SIZE_X 10000
+#define SC_PREVIEW_SIZE_Y 12400
+
+
+//------------------------------------------------------------------
+
+void ScDocShell::Execute( SfxRequest& rReq )
+{
+ // SID_SC_RANGE (Range),
+ // SID_SC_CELLTEXT (CellText),
+ // SID_SC_CELLS (Cells) - removed (old Basic)
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ SfxBindings* pBindings = GetViewBindings();
+ BOOL bUndo (aDocument.IsUndoEnabled());
+
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_SC_SETTEXT:
+ {
+ const SfxPoolItem* pColItem;
+ const SfxPoolItem* pRowItem;
+ const SfxPoolItem* pTabItem;
+ const SfxPoolItem* pTextItem;
+ if( pReqArgs && IS_AVAILABLE( FN_PARAM_1, &pColItem ) &&
+ IS_AVAILABLE( FN_PARAM_2, &pRowItem ) &&
+ IS_AVAILABLE( FN_PARAM_3, &pTabItem ) &&
+ IS_AVAILABLE( SID_SC_SETTEXT, &pTextItem ) )
+ {
+ // Parameter sind 1-based !!!
+ SCCOL nCol = ((SfxInt16Item*)pColItem)->GetValue() - 1;
+ SCROW nRow = ((SfxInt32Item*)pRowItem)->GetValue() - 1;
+ SCTAB nTab = ((SfxInt16Item*)pTabItem)->GetValue() - 1;
+
+ SCTAB nTabCount = aDocument.GetTableCount();
+ if ( ValidCol(nCol) && ValidRow(nRow) && ValidTab(nTab,nTabCount) )
+ {
+ if ( aDocument.IsBlockEditable( nTab, nCol,nRow, nCol, nRow ) )
+ {
+ String aVal = ((const SfxStringItem*)pTextItem)->GetValue();
+ aDocument.SetString( nCol, nRow, nTab, aVal );
+
+ PostPaintCell( nCol, nRow, nTab );
+ SetDocumentModified();
+
+ rReq.Done();
+ break;
+ }
+ else // geschuetzte Zelle
+ {
+ SbxBase::SetError( SbxERR_BAD_PARAMETER ); //! welchen Fehler ?
+ break;
+ }
+ }
+ }
+ SbxBase::SetError( SbxERR_NO_OBJECT );
+ }
+ break;
+
+
+ // SID_SBA_QRY_CHANGETARGET gibts nicht mehr - auch in idl raus
+
+ case SID_SBA_IMPORT:
+ {
+ if (pReqArgs)
+ {
+ const sal_Unicode cSbaSep = 11; // Trennzeichen
+
+ const SfxPoolItem* pItem;
+ String sSbaData, sTarget;
+ if ( pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ sSbaData = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pReqArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET )
+ sTarget = ((const SfxStringItem*)pItem)->GetValue();
+
+ BOOL bIsNewArea = TRUE; // Default TRUE (keine Nachfrage)
+ if ( pReqArgs->GetItemState( FN_PARAM_2, TRUE, &pItem ) == SFX_ITEM_SET )
+ bIsNewArea = ((const SfxBoolItem*)pItem)->GetValue();
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::sdbc::XResultSet > xResultSet;
+ if ( pReqArgs->GetItemState( FN_PARAM_3, FALSE, &pItem ) == SFX_ITEM_SET && pItem )
+ xResultSet.set(((const SfxUsrAnyItem*)pItem)->GetValue(),::com::sun::star::uno::UNO_QUERY);
+
+ String sDBName = sSbaData.GetToken(0,cSbaSep); // Datenbankname
+ String sDBTable = sSbaData.GetToken(1,cSbaSep); // Tabellen- oder Query-Name
+ String sTabFlag = sSbaData.GetToken(2,cSbaSep);
+ String sDBSql = sSbaData.GetToken(3,cSbaSep); // SQL im Klartext
+
+ BYTE nType = ScDbTable; // "0" oder "1"
+ if ( sTabFlag.EqualsAscii("0") ) // "0" = Query, "1" = Table (Default)
+ nType = ScDbQuery;
+
+ SbaSelectionListRef pSelectionList = new SbaSelectionList;
+ xub_StrLen nCount = sSbaData.GetTokenCount(cSbaSep);
+
+ for (xub_StrLen i = 4; i < nCount; i++)
+ {
+ String aSelItem = sSbaData.GetToken(i,cSbaSep);
+ if (aSelItem.Len())
+ {
+ void *pPtr = (void*)aSelItem.ToInt32();
+ pSelectionList->Insert( pPtr, LIST_APPEND );
+ }
+ }
+
+ // bei Bedarf neuen Datenbankbereich anlegen
+ BOOL bMakeArea = FALSE;
+ if (bIsNewArea)
+ {
+ ScDBCollection* pDBColl = aDocument.GetDBCollection();
+ USHORT nDummy;
+ if ( !pDBColl || !pDBColl->SearchName( sTarget, nDummy ) )
+ {
+ ScAddress aPos;
+ if ( aPos.Parse( sTarget, &aDocument, aDocument.GetAddressConvention() ) & SCA_VALID )
+ {
+ bMakeArea = TRUE;
+ if (bUndo)
+ {
+ String aStrImport = ScGlobal::GetRscString( STR_UNDO_IMPORTDATA );
+ GetUndoManager()->EnterListAction( aStrImport, aStrImport );
+ }
+
+ ScDBData* pDBData = GetDBData( ScRange(aPos), SC_DB_IMPORT, SC_DBSEL_KEEP );
+ DBG_ASSERT(pDBData, "kann DB-Daten nicht anlegen");
+ sTarget = pDBData->GetName();
+ }
+ }
+ }
+
+ // nachfragen, bevor alter DB-Bereich ueberschrieben wird
+ BOOL bDo = TRUE;
+ if (!bIsNewArea)
+ {
+ String aTemplate = ScGlobal::GetRscString( STR_IMPORT_REPLACE );
+ String aMessage = aTemplate.GetToken( 0, '#' );
+ aMessage += sTarget;
+ aMessage += aTemplate.GetToken( 1, '#' );
+
+ QueryBox aBox( 0, WinBits(WB_YES_NO | WB_DEF_YES), aMessage );
+ bDo = ( aBox.Execute() == RET_YES );
+ }
+
+ if (bDo)
+ {
+ ScDBDocFunc(*this).UpdateImport( sTarget, sDBName,
+ sDBTable, sDBSql, TRUE, nType, xResultSet,
+ pSelectionList );
+ rReq.Done();
+
+ // UpdateImport aktualisiert auch die internen Operationen
+ }
+ else
+ rReq.Ignore();
+
+ if ( bMakeArea && bUndo)
+ GetUndoManager()->LeaveListAction();
+ }
+ else
+ {
+ DBG_ERROR( "arguments expected" );
+ }
+ }
+ break;
+
+ case SID_CHART_SOURCE:
+ case SID_CHART_ADDSOURCE:
+ if (pReqArgs)
+ {
+ ScDocument* pDoc = GetDocument();
+// BOOL bUndo (pDoc->IsUndoEnabled());
+ const SfxPoolItem* pItem;
+ String aChartName, aRangeName;
+
+ ScRange aSingleRange;
+ ScRangeListRef aRangeListRef;
+ BOOL bMultiRange = FALSE;
+
+ BOOL bColHeaders = TRUE;
+ BOOL bRowHeaders = TRUE;
+ BOOL bColInit = FALSE;
+ BOOL bRowInit = FALSE;
+ BOOL bAddRange = (nSlot == SID_CHART_ADDSOURCE);
+
+ if( IS_AVAILABLE( SID_CHART_NAME, &pItem ) )
+ aChartName = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( SID_CHART_SOURCE, &pItem ) )
+ aRangeName = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ {
+ bColHeaders = ((const SfxBoolItem*)pItem)->GetValue();
+ bColInit = TRUE;
+ }
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ {
+ bRowHeaders = ((const SfxBoolItem*)pItem)->GetValue();
+ bRowInit = TRUE;
+ }
+
+ ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
+ BOOL bValid = ( aSingleRange.ParseAny( aRangeName, pDoc, aDetails ) & SCA_VALID ) != 0;
+ if (!bValid)
+ {
+ aRangeListRef = new ScRangeList;
+ aRangeListRef->Parse( aRangeName, pDoc );
+ if ( aRangeListRef->Count() )
+ {
+ bMultiRange = TRUE;
+ aSingleRange = *aRangeListRef->GetObject(0); // fuer Header
+ bValid = TRUE;
+ }
+ else
+ aRangeListRef.Clear();
+ }
+
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if (pViewSh && bValid && aChartName.Len() != 0 )
+ {
+ Window* pParent = pViewSh->GetDialogParent();
+
+ SCCOL nCol1 = aSingleRange.aStart.Col();
+ SCROW nRow1 = aSingleRange.aStart.Row();
+ SCCOL nCol2 = aSingleRange.aEnd.Col();
+ SCROW nRow2 = aSingleRange.aEnd.Row();
+ SCTAB nTab = aSingleRange.aStart.Tab();
+
+ //! immer oder gar nicht begrenzen ???
+ if (!bMultiRange)
+ aDocument.LimitChartArea( nTab, nCol1,nRow1, nCol2,nRow2 );
+
+ // Dialog fuer Spalten/Zeilenkoepfe
+ BOOL bOk = TRUE;
+ if ( !bAddRange && ( !bColInit || !bRowInit ) )
+ {
+ // Spalten/Zeilenkoepfe testen wie in chartarr
+ if (!bColInit)
+ {
+ for (SCCOL i=nCol1; i<=nCol2 && bColHeaders; i++)
+ if (aDocument.HasValueData( i, nRow1, nTab ))
+ bColHeaders = FALSE;
+ }
+ if (!bRowInit)
+ {
+ for (SCROW i=nRow1; i<=nRow2 && bRowHeaders; i++)
+ if (aDocument.HasValueData( nCol1, i, nTab ))
+ bRowHeaders = FALSE;
+ }
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScColRowLabelDlg* pDlg = pFact->CreateScColRowLabelDlg( pParent, RID_SCDLG_CHARTCOLROW, bRowHeaders, bColHeaders);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ bColHeaders = pDlg->IsRow();
+ bRowHeaders = pDlg->IsCol();
+
+ rReq.AppendItem(SfxBoolItem(FN_PARAM_1, bColHeaders));
+ rReq.AppendItem(SfxBoolItem(FN_PARAM_2, bRowHeaders));
+ }
+ else
+ bOk = FALSE;
+ delete pDlg;
+ }
+
+ if (bOk) // ausfuehren
+ {
+ if (bMultiRange)
+ {
+ if (bUndo)
+ {
+ GetUndoManager()->AddUndoAction(
+ new ScUndoChartData( this, aChartName, aRangeListRef,
+ bColHeaders, bRowHeaders, bAddRange ) );
+ }
+ aDocument.UpdateChartArea( aChartName, aRangeListRef,
+ bColHeaders, bRowHeaders, bAddRange );
+ }
+ else
+ {
+ ScRange aNewRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
+ if (bUndo)
+ {
+ GetUndoManager()->AddUndoAction(
+ new ScUndoChartData( this, aChartName, aNewRange,
+ bColHeaders, bRowHeaders, bAddRange ) );
+ }
+ aDocument.UpdateChartArea( aChartName, aNewRange,
+ bColHeaders, bRowHeaders, bAddRange );
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR("UpdateChartArea: keine ViewShell oder falsche Daten");
+ }
+ rReq.Done();
+ }
+ else
+ {
+ DBG_ERROR("SID_CHART_SOURCE ohne Argumente");
+ }
+ break;
+
+ case FID_AUTO_CALC:
+ {
+ BOOL bNewVal;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, TRUE, &pItem ) )
+ bNewVal = ((const SfxBoolItem*)pItem)->GetValue();
+ else
+ bNewVal = !aDocument.GetAutoCalc(); // Toggle fuer Menue
+ aDocument.SetAutoCalc( bNewVal );
+ SetDocumentModified();
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_AUTO_CALC );
+// pBindings->Invalidate( FID_RECALC ); // jetzt immer enabled
+ }
+ rReq.AppendItem( SfxBoolItem( FID_AUTO_CALC, bNewVal ) );
+ rReq.Done();
+ }
+ break;
+ case FID_RECALC:
+ DoRecalc( rReq.IsAPI() );
+ rReq.Done();
+ break;
+ case FID_HARD_RECALC:
+ DoHardRecalc( rReq.IsAPI() );
+ rReq.Done();
+ break;
+ case SID_UPDATETABLINKS:
+ {
+ ScDocument* pDoc = GetDocument();
+
+ ScLkUpdMode nSet=pDoc->GetLinkMode();
+
+ USHORT nDlgRet=RET_NO;
+ if(nSet==LM_UNKNOWN)
+ {
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+ nSet=aAppOptions.GetLinkMode();
+ }
+
+ if (nCanUpdate == com::sun::star::document::UpdateDocMode::NO_UPDATE)
+ nSet = LM_NEVER;
+ else if (nCanUpdate == com::sun::star::document::UpdateDocMode::QUIET_UPDATE &&
+ nSet == LM_ON_DEMAND)
+ nSet = LM_NEVER;
+ else if (nCanUpdate == com::sun::star::document::UpdateDocMode::FULL_UPDATE)
+ nSet = LM_ALWAYS;
+
+ if(nSet==LM_ON_DEMAND)
+ {
+ QueryBox aBox( GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_RELOAD_TABLES) );
+
+ nDlgRet=aBox.Execute();
+ }
+
+ if (nDlgRet == RET_YES || nSet==LM_ALWAYS)
+ {
+ ReloadTabLinks();
+ aDocument.UpdateExternalRefLinks();
+ aDocument.UpdateDdeLinks();
+ aDocument.UpdateAreaLinks();
+
+ //! Test, ob Fehler
+ rReq.Done();
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_REIMPORT_AFTER_LOAD:
+ {
+ // wird nach dem Laden aufgerufen, wenn DB-Bereiche mit
+ // weggelassenen Daten enthalten sind
+
+ BOOL bDone = FALSE;
+ ScDBCollection* pDBColl = aDocument.GetDBCollection();
+
+ if ((nCanUpdate != com::sun::star::document::UpdateDocMode::NO_UPDATE) &&
+ (nCanUpdate != com::sun::star::document::UpdateDocMode::QUIET_UPDATE))
+ {
+ ScRange aRange;
+ ScTabViewShell* pViewSh = GetBestViewShell();
+ DBG_ASSERT(pViewSh,"SID_REIMPORT_AFTER_LOAD: keine View");
+ if (pViewSh && pDBColl)
+ {
+ QueryBox aBox( GetActiveDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_REIMPORT_AFTER_LOAD) );
+ if (aBox.Execute() == RET_YES)
+ {
+ for (USHORT i=0; i<pDBColl->GetCount(); i++)
+ {
+ ScDBData* pDBData = (*pDBColl)[i];
+ if ( pDBData->IsStripData() &&
+ pDBData->HasImportParam() && !pDBData->HasImportSelection() )
+ {
+ pDBData->GetArea(aRange);
+ pViewSh->MarkRange(aRange);
+
+ // Import und interne Operationen wie SID_REFRESH_DBAREA
+ // (Abfrage auf Import hier nicht noetig)
+
+ ScImportParam aImportParam;
+ pDBData->GetImportParam( aImportParam );
+ BOOL bContinue = pViewSh->ImportData( aImportParam );
+ pDBData->SetImportParam( aImportParam );
+
+ // markieren (Groesse kann sich geaendert haben)
+ pDBData->GetArea(aRange);
+ pViewSh->MarkRange(aRange);
+
+ if ( bContinue ) // #41905# Fehler beim Import -> Abbruch
+ {
+ // interne Operationen, wenn welche gespeichert
+
+ if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
+ pDBData->HasSubTotalParam() )
+ pViewSh->RepeatDB();
+
+ // Pivottabellen die den Bereich als Quelldaten haben
+
+ RefreshPivotTables(aRange);
+ }
+ }
+ }
+ bDone = TRUE;
+ }
+ }
+ }
+
+ if ( !bDone && pDBColl )
+ {
+ // wenn nicht, dann aber die abhaengigen Formeln updaten
+ //! auch fuer einzelne Bereiche, die nicht aktualisiert werden koennen
+
+ aDocument.CalcAll(); //! nur die abhaengigen
+ PostDataChanged();
+ }
+
+ if (bDone)
+ rReq.Done();
+ else
+ rReq.Ignore();
+ }
+ break;
+
+
+ case SID_AUTO_STYLE:
+ DBG_ERROR("use ScAutoStyleHint instead of SID_AUTO_STYLE");
+ break;
+
+ case SID_GET_COLORTABLE:
+ {
+ // passende ColorTable ist per PutItem gesetzt worden
+ SvxColorTableItem* pColItem = (SvxColorTableItem*)GetItem(SID_COLOR_TABLE);
+ XColorTable* pTable = pColItem->GetColorTable();
+ rReq.SetReturnValue(OfaPtrItem(SID_GET_COLORTABLE, pTable));
+ }
+ break;
+
+ case FID_CHG_RECORD:
+ {
+ ScDocument* pDoc = GetDocument();
+ if(pDoc!=NULL)
+ {
+ // get argument (recorded macro)
+ SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FID_CHG_RECORD, sal_False );
+ BOOL bDo = TRUE;
+
+ // xmlsec05/06:
+ // getting real parent window when called from Security-Options TP
+ Window* pParent = NULL;
+ const SfxPoolItem* pParentItem;
+ if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) )
+ pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
+
+ // desired state
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ BOOL bActivateTracking = (pChangeTrack == 0); // toggle
+ if ( pItem )
+ bActivateTracking = pItem->GetValue(); // from argument
+
+ if ( !bActivateTracking )
+ {
+ if ( !pItem )
+ {
+ // no dialog on playing the macro
+ WarningBox aBox( pParent ? pParent : GetActiveDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_NO),
+ ScGlobal::GetRscString( STR_END_REDLINING ) );
+ bDo = ( aBox.Execute() == RET_YES );
+ }
+
+ if ( bDo )
+ {
+ if ( pChangeTrack->IsProtected() )
+ bDo = ExecuteChangeProtectionDialog( NULL );
+ if ( bDo )
+ {
+ pDoc->EndChangeTracking();
+ PostPaintGridAll();
+ }
+ }
+ }
+ else
+ {
+ pDoc->StartChangeTracking();
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges(TRUE);
+ pDoc->SetChangeViewSettings(aChangeViewSet);
+ }
+
+ if ( bDo )
+ {
+ UpdateAcceptChangesDialog();
+
+ // Slots invalidieren
+ if (pBindings)
+ pBindings->InvalidateAll(FALSE);
+ if ( !pItem )
+ rReq.AppendItem( SfxBoolItem( FID_CHG_RECORD, bActivateTracking ) );
+ rReq.Done();
+ }
+ else
+ rReq.Ignore();
+ }
+ }
+ break;
+
+ case SID_CHG_PROTECT :
+ {
+ Window* pParent = NULL;
+ const SfxPoolItem* pParentItem;
+ if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_XWINDOW, FALSE, &pParentItem ) )
+ pParent = ( ( const XWindowItem* ) pParentItem )->GetWindowPtr();
+ if ( ExecuteChangeProtectionDialog( pParent ) )
+ {
+ rReq.Done();
+ SetDocumentModified();
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_DOCUMENT_MERGE:
+ case SID_DOCUMENT_COMPARE:
+ {
+ BOOL bDo = TRUE;
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ if ( pChangeTrack && !pImpl->bIgnoreLostRedliningWarning )
+ {
+ if ( nSlot == SID_DOCUMENT_COMPARE )
+ { //! old changes trace will be lost
+ WarningBox aBox( GetActiveDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_NO),
+ ScGlobal::GetRscString( STR_END_REDLINING ) );
+ if( aBox.Execute() == RET_YES )
+ bDo = ExecuteChangeProtectionDialog( NULL, TRUE );
+ else
+ bDo = FALSE;
+ }
+ else // merge might reject some actions
+ bDo = ExecuteChangeProtectionDialog( NULL, TRUE );
+ }
+ if ( !bDo )
+ {
+ rReq.Ignore();
+ break;
+ }
+ SfxApplication* pApp = SFX_APP();
+ const SfxPoolItem* pItem;
+ SfxMedium* pMed = NULL;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState( SID_FILE_NAME, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA(SfxStringItem) )
+ {
+ String aFileName = ((const SfxStringItem*)pItem)->GetValue();
+
+ String aFilterName;
+ if ( pReqArgs->GetItemState( SID_FILTER_NAME, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA(SfxStringItem) )
+ {
+ aFilterName = ((const SfxStringItem*)pItem)->GetValue();
+ }
+ String aOptions;
+ if ( pReqArgs->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA(SfxStringItem) )
+ {
+ aOptions = ((const SfxStringItem*)pItem)->GetValue();
+ }
+ short nVersion = 0;
+ if ( pReqArgs->GetItemState( SID_VERSION, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA(SfxInt16Item) )
+ {
+ nVersion = ((const SfxInt16Item*)pItem)->GetValue();
+ }
+
+ // kein Filter angegeben -> Detection
+ if ( !aFilterName.Len() )
+ ScDocumentLoader::GetFilterName( aFileName, aFilterName, aOptions, TRUE, FALSE );
+
+ // filter name from dialog contains application prefix,
+ // GetFilter needs name without the prefix.
+ ScDocumentLoader::RemoveAppPrefix( aFilterName );
+
+ const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aFilterName );
+ SfxItemSet* pSet = new SfxAllItemSet( pApp->GetPool() );
+ if ( aOptions.Len() )
+ pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
+ if ( nVersion != 0 )
+ pSet->Put( SfxInt16Item( SID_VERSION, nVersion ) );
+ pMed = new SfxMedium( aFileName, STREAM_STD_READ, FALSE, pFilter, pSet );
+ }
+ else
+ {
+ // start file dialog asynchronous
+ pImpl->bIgnoreLostRedliningWarning = true;
+ delete pImpl->pRequest;
+ pImpl->pRequest = new SfxRequest( rReq );
+ delete pImpl->pDocInserter;
+ pImpl->pDocInserter = new ::sfx2::DocumentInserter(
+ 0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ), 0 );
+ pImpl->pDocInserter->StartExecuteModal( LINK( this, ScDocShell, DialogClosedHdl ) );
+ return ;
+ }
+
+ if ( pMed ) // nun wirklich ausfuehren...
+ {
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+
+ ScDocShell* pOtherDocSh = new ScDocShell;
+ SfxObjectShellRef aDocShTablesRef = pOtherDocSh;
+ pOtherDocSh->DoLoad( pMed );
+ ULONG nErr = pOtherDocSh->GetErrorCode();
+ if (nErr)
+ ErrorHandler::HandleError( nErr ); // auch Warnings
+
+ if ( !pOtherDocSh->GetError() ) // nur Errors
+ {
+ BOOL bHadTrack = ( aDocument.GetChangeTrack() != NULL );
+ ULONG nStart = 0;
+ if ( nSlot == SID_DOCUMENT_MERGE && pChangeTrack )
+ {
+ nStart = pChangeTrack->GetActionMax() + 1;
+ }
+
+ if ( nSlot == SID_DOCUMENT_COMPARE )
+ CompareDocument( *pOtherDocSh->GetDocument() );
+ else
+ MergeDocument( *pOtherDocSh->GetDocument() );
+
+ // show "accept changes" dialog
+ //! get view for this document!
+ if ( !IsDocShared() )
+ {
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm )
+ {
+ pViewFrm->ShowChildWindow( ScAcceptChgDlgWrapper::GetChildWindowId(), TRUE ); //@51669
+ }
+ if ( pBindings )
+ {
+ pBindings->Invalidate( FID_CHG_ACCEPT );
+ }
+ }
+
+ rReq.SetReturnValue( SfxInt32Item( nSlot, 0 ) ); //! ???????
+ rReq.Done();
+
+ if (!bHadTrack) // neu eingeschaltet -> auch anzeigen
+ {
+ ScChangeViewSettings* pOldSet = aDocument.GetChangeViewSettings();
+ if ( !pOldSet || !pOldSet->ShowChanges() )
+ {
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges(TRUE);
+ aDocument.SetChangeViewSettings(aChangeViewSet);
+ }
+ }
+ else if ( nSlot == SID_DOCUMENT_MERGE && IsDocShared() && pChangeTrack )
+ {
+ ULONG nEnd = pChangeTrack->GetActionMax();
+ if ( nEnd >= nStart )
+ {
+ // only show changes from merged document
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges( TRUE );
+ aChangeViewSet.SetShowAccepted( TRUE );
+ aChangeViewSet.SetHasActionRange( true );
+ aChangeViewSet.SetTheActionRange( nStart, nEnd );
+ aDocument.SetChangeViewSettings( aChangeViewSet );
+
+ // update view
+ PostPaintExtras();
+ PostPaintGridAll();
+ }
+ }
+ }
+ pOtherDocSh->DoClose(); // delete passiert mit der Ref
+ }
+ }
+ break;
+
+ case SID_DELETE_SCENARIO:
+ if (pReqArgs)
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ if ( pItem->ISA(SfxStringItem) )
+ {
+ String aName = ((const SfxStringItem*)pItem)->GetValue();
+ SCTAB nTab;
+ if (aDocument.GetTable( aName, nTab ))
+ {
+ // DeleteTable von viewfunc nach docfunc verschieben!
+
+ ScTabViewShell* pSh = GetBestViewShell();
+ if ( pSh )
+ {
+ //! SetTabNo in DeleteTable weglassen?
+ SCTAB nDispTab = pSh->GetViewData()->GetTabNo();
+ pSh->DeleteTable( nTab );
+ pSh->SetTabNo(nDispTab);
+ rReq.Done();
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_EDIT_SCENARIO:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ if ( pItem->ISA(SfxStringItem) )
+ {
+ String aName = ((const SfxStringItem*)pItem)->GetValue();
+ SCTAB nTab;
+ if (aDocument.GetTable( aName, nTab ))
+ {
+ if (aDocument.IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ aDocument.GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ // Determine if the Sheet that the Scenario was created on
+ // is protected. But first we need to find that Sheet.
+ // Rewind back to the actual sheet.
+ SCTAB nActualTab = nTab;
+ do
+ {
+ nActualTab--;
+ }
+ while(aDocument.IsScenario(nActualTab));
+ BOOL bSheetProtected = aDocument.IsTabProtected(nActualTab);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( GetActiveDialogParent(), aName, RID_SCDLG_NEWSCENARIO, TRUE,bSheetProtected);
+ DBG_ASSERT(pNewDlg, "Dialog create fail!");
+ pNewDlg->SetScenarioData( aName, aComment, aColor, nFlags );
+ if ( pNewDlg->Execute() == RET_OK )
+ {
+ pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
+ ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ rReq.Done();
+ }
+ delete pNewDlg;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_ATTR_YEAR2000 :
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ if ( pItem->ISA(SfxUInt16Item) )
+ {
+ UINT16 nY2k = ((SfxUInt16Item*)pItem)->GetValue();
+ // immer an den DocOptions setzen, damit das auch fuer SO50
+ // gespeichert wird (und alle Abfragen bisher auch darauf laufen).
+ // SetDocOptions propagiert das an den NumberFormatter
+ ScDocOptions aDocOpt( aDocument.GetDocOptions() );
+ aDocOpt.SetYear2000( nY2k );
+ aDocument.SetDocOptions( aDocOpt );
+ // die FormShell soll es mitbekommen
+ ScTabViewShell* pSh = GetBestViewShell();
+ if ( pSh )
+ {
+ FmFormShell* pFSh = pSh->GetFormShell();
+ if ( pFSh )
+ pFSh->SetY2KState( nY2k );
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_SHARE_DOC:
+ {
+ ScViewData* pViewData = GetViewData();
+ if ( !pViewData )
+ {
+ rReq.Ignore();
+ break;
+ }
+
+ ScShareDocumentDlg aDlg( GetActiveDialogParent(), pViewData );
+ if ( aDlg.Execute() == RET_OK )
+ {
+ bool bSetShared = aDlg.IsShareDocumentChecked();
+ if ( bSetShared != static_cast< bool >( IsDocShared() ) )
+ {
+ if ( bSetShared )
+ {
+ bool bContinue = true;
+ if ( HasName() )
+ {
+ QueryBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
+ ScGlobal::GetRscString( STR_DOC_WILLBESAVED ) );
+ if ( aBox.Execute() == RET_NO )
+ {
+ bContinue = false;
+ }
+ }
+ if ( bContinue )
+ {
+ EnableSharedSettings( true );
+
+ SC_MOD()->SetInSharedDocSaving( true );
+ if ( !SwitchToShared( sal_True, sal_True ) )
+ {
+ // TODO/LATER: what should be done in case the switch has failed?
+ // for example in case the user has cancelled the saveAs operation
+ }
+
+ SC_MOD()->SetInSharedDocSaving( false );
+
+ InvalidateName();
+ GetUndoManager()->Clear();
+
+ ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
+ if ( pTabView )
+ {
+ pTabView->UpdateLayerLocks();
+ }
+ }
+ }
+ else
+ {
+ uno::Reference< frame::XModel > xModel;
+ try
+ {
+ // load shared file
+ xModel.set( LoadSharedDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< util::XCloseable > xCloseable( xModel, uno::UNO_QUERY_THROW );
+
+ // check if shared flag is set in shared file
+ bool bShared = false;
+ ScModelObj* pDocObj = ScModelObj::getImplementation( xModel );
+ if ( pDocObj )
+ {
+ ScDocShell* pDocShell = dynamic_cast< ScDocShell* >( pDocObj->GetEmbeddedObject() );
+ if ( pDocShell )
+ {
+ bShared = pDocShell->HasSharedXMLFlagSet();
+ }
+ }
+
+ // #i87870# check if shared status was disabled and enabled again
+ bool bOwnEntry = false;
+ try
+ {
+ ::svt::ShareControlFile aControlFile( GetSharedFileURL() );
+ bOwnEntry = aControlFile.HasOwnEntry();
+ }
+ catch ( uno::Exception& )
+ {
+ }
+
+ if ( bShared && bOwnEntry )
+ {
+ uno::Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY_THROW );
+ if ( xStorable->isReadonly() )
+ {
+ xCloseable->close( sal_True );
+
+ String aUserName( ScGlobal::GetRscString( STR_UNKNOWN_USER ) );
+ try
+ {
+ ::svt::DocumentLockFile aLockFile( GetSharedFileURL() );
+ uno::Sequence< ::rtl::OUString > aData = aLockFile.GetLockData();
+ if ( aData.getLength() > LOCKFILE_SYSUSERNAME_ID )
+ {
+ if ( aData[LOCKFILE_OOOUSERNAME_ID].getLength() > 0 )
+ {
+ aUserName = aData[LOCKFILE_OOOUSERNAME_ID];
+ }
+ else if ( aData[LOCKFILE_SYSUSERNAME_ID].getLength() > 0 )
+ {
+ aUserName = aData[LOCKFILE_SYSUSERNAME_ID];
+ }
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ String aMessage( ScGlobal::GetRscString( STR_FILE_LOCKED_TRY_LATER ) );
+ aMessage.SearchAndReplaceAscii( "%1", aUserName );
+
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ), aMessage );
+ aBox.Execute();
+ }
+ else
+ {
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_YES_NO | WB_DEF_YES ),
+ ScGlobal::GetRscString( STR_DOC_DISABLESHARED ) );
+ if ( aBox.Execute() == RET_YES )
+ {
+ xCloseable->close( sal_True );
+
+ if ( !SwitchToShared( sal_False, sal_True ) )
+ {
+ // TODO/LATER: what should be done in case the switch has failed?
+ // for example in case the user has cancelled the saveAs operation
+ }
+
+ EnableSharedSettings( false );
+
+ if ( pBindings )
+ {
+ pBindings->ExecuteSynchron( SID_SAVEDOC );
+ }
+
+ ScTabView* pTabView = dynamic_cast< ScTabView* >( pViewData->GetView() );
+ if ( pTabView )
+ {
+ pTabView->UpdateLayerLocks();
+ }
+ }
+ else
+ {
+ xCloseable->close( sal_True );
+ }
+ }
+ }
+ else
+ {
+ xCloseable->close( sal_True );
+ WarningBox aBox( GetActiveDialogParent(), WinBits( WB_OK ),
+ ScGlobal::GetRscString( STR_DOC_NOLONGERSHARED ) );
+ aBox.Execute();
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR( "SID_SHARE_DOC: caught exception\n" );
+ SC_MOD()->SetInSharedDocSaving( false );
+
+ try
+ {
+ uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
+ xClose->close( sal_True );
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ }
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
+ default:
+ {
+ // kleiner (?) Hack -> forward der Slots an TabViewShell
+ ScTabViewShell* pSh = GetBestViewShell();
+ if ( pSh )
+ pSh->Execute( rReq );
+ else
+ SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT );
+ }
+ }
+}
+
+
+//------------------------------------------------------------------
+
+void UpdateAcceptChangesDialog()
+{
+ // update "accept changes" dialog
+ //! notify all views
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && pViewFrm->HasChildWindow( FID_CHG_ACCEPT ) )
+ {
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow( FID_CHG_ACCEPT );
+ if ( pChild )
+ ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg();
+ }
+}
+
+//------------------------------------------------------------------
+
+BOOL ScDocShell::ExecuteChangeProtectionDialog( Window* _pParent, BOOL bJustQueryIfProtected )
+{
+ BOOL bDone = FALSE;
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ BOOL bProtected = pChangeTrack->IsProtected();
+ if ( bJustQueryIfProtected && !bProtected )
+ return TRUE;
+
+ String aTitle( ScResId( bProtected ? SCSTR_CHG_UNPROTECT : SCSTR_CHG_PROTECT ) );
+ String aText( ScResId( SCSTR_PASSWORD ) );
+ String aPassword;
+
+ SfxPasswordDialog* pDlg = new SfxPasswordDialog(
+ _pParent ? _pParent : GetActiveDialogParent(), &aText );
+ pDlg->SetText( aTitle );
+ pDlg->SetMinLen( 1 );
+ pDlg->SetHelpId( SID_CHG_PROTECT );
+ pDlg->SetEditHelpId( HID_CHG_PROTECT );
+ if ( !bProtected )
+ pDlg->ShowExtras( SHOWEXTRAS_CONFIRM );
+ if ( pDlg->Execute() == RET_OK )
+ aPassword = pDlg->GetPassword();
+ delete pDlg;
+
+ if ( aPassword.Len() )
+ {
+ if ( bProtected )
+ {
+ if ( SvPasswordHelper::CompareHashPassword(pChangeTrack->GetProtection(), aPassword) )
+ {
+ if ( bJustQueryIfProtected )
+ bDone = TRUE;
+ else
+ pChangeTrack->SetProtection(
+ com::sun::star::uno::Sequence< sal_Int8 > (0) );
+ }
+ else
+ {
+ InfoBox aBox( GetActiveDialogParent(),
+ String( ScResId( SCSTR_WRONGPASSWORD ) ) );
+ aBox.Execute();
+ }
+ }
+ else
+ {
+ com::sun::star::uno::Sequence< sal_Int8 > aPass;
+ SvPasswordHelper::GetHashPassword( aPass, aPassword );
+ pChangeTrack->SetProtection( aPass );
+ }
+ if ( bProtected != pChangeTrack->IsProtected() )
+ {
+ UpdateAcceptChangesDialog();
+ bDone = TRUE;
+ }
+ }
+ }
+ else if ( bJustQueryIfProtected )
+ bDone = TRUE;
+ return bDone;
+}
+
+
+//------------------------------------------------------------------
+
+void ScDocShell::DoRecalc( BOOL bApi )
+{
+ BOOL bDone = FALSE;
+ ScTabViewShell* pSh = GetBestViewShell();
+ if ( pSh )
+ {
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl(pSh);
+ if ( pHdl && pHdl->IsInputMode() && pHdl->IsFormulaMode() && !bApi )
+ {
+ pHdl->FormulaPreview(); // Teilergebnis als QuickHelp
+ bDone = TRUE;
+ }
+ else
+ {
+ pSh->UpdateInputLine(); // InputEnterHandler
+ pSh->UpdateInputHandler();
+ }
+ }
+ if (!bDone) // sonst Dokument neu berechnen
+ {
+ WaitObject aWaitObj( GetActiveDialogParent() );
+ aDocument.CalcFormulaTree();
+ if ( pSh )
+ pSh->UpdateCharts(TRUE);
+
+ aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
+
+ // #47939# Wenn es Charts gibt, dann alles painten, damit nicht
+ // PostDataChanged und die Charts nacheinander kommen und Teile
+ // doppelt gepainted werden.
+
+ ScChartListenerCollection* pCharts = aDocument.GetChartListenerCollection();
+ if ( pCharts && pCharts->GetCount() )
+ PostPaintGridAll();
+ else
+ PostDataChanged();
+ }
+}
+
+void ScDocShell::DoHardRecalc( BOOL /* bApi */ )
+{
+ WaitObject aWaitObj( GetActiveDialogParent() );
+ ScTabViewShell* pSh = GetBestViewShell();
+ if ( pSh )
+ {
+ pSh->UpdateInputLine(); // InputEnterHandler
+ pSh->UpdateInputHandler();
+ }
+ aDocument.CalcAll();
+ GetDocFunc().DetectiveRefresh(); // erzeugt eigenes Undo
+ if ( pSh )
+ pSh->UpdateCharts(TRUE);
+
+ // set notification flags for "calculate" event (used in SFX_HINT_DATACHANGED broadcast)
+ // (might check for the presence of any formulas on each sheet)
+ SCTAB nTabCount = aDocument.GetTableCount();
+ SCTAB nTab;
+ if (aDocument.HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true )) // search also for VBA hendler
+ for (nTab=0; nTab<nTabCount; nTab++)
+ aDocument.SetCalcNotification(nTab);
+
+ // CalcAll doesn't broadcast value changes, so SC_HINT_CALCALL is broadcasted globally
+ // in addition to SFX_HINT_DATACHANGED.
+ aDocument.BroadcastUno( SfxSimpleHint( SC_HINT_CALCALL ) );
+ aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
+
+ // use hard recalc also to disable stream-copying of all sheets
+ // (somewhat consistent with charts)
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (aDocument.IsStreamValid(nTab))
+ aDocument.SetStreamValid(nTab, FALSE);
+
+ PostPaintGridAll();
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::DoAutoStyle( const ScRange& rRange, const String& rStyle )
+{
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ ScStyleSheet* pStyleSheet =
+ pStylePool->FindCaseIns( rStyle, SFX_STYLE_FAMILY_PARA );
+ if (!pStyleSheet)
+ pStyleSheet = (ScStyleSheet*)
+ pStylePool->Find( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA );
+ if (pStyleSheet)
+ {
+ DBG_ASSERT(rRange.aStart.Tab() == rRange.aEnd.Tab(),
+ "DoAutoStyle mit mehreren Tabellen");
+ SCTAB nTab = rRange.aStart.Tab();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ aDocument.ApplyStyleAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, *pStyleSheet );
+ aDocument.ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab );
+ PostPaint( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, PAINT_GRID );
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint )
+{
+ USHORT nId = rHint.GetHint();
+ const SfxStyleSheetBase* pStyle = rHint.GetStyleSheet();
+ if (!pStyle)
+ return;
+
+ if ( pStyle->GetFamily() == SFX_STYLE_FAMILY_PAGE )
+ {
+ if ( nId == SFX_STYLESHEET_MODIFIED )
+ {
+ ScDocShellModificator aModificator( *this );
+
+ String aNewName = pStyle->GetName();
+ String aOldName = aNewName;
+ BOOL bExtended = rHint.ISA(SfxStyleSheetHintExtended); // Name geaendert?
+ if (bExtended)
+ aOldName = ((SfxStyleSheetHintExtended&)rHint).GetOldName();
+
+ if ( aNewName != aOldName )
+ aDocument.RenamePageStyleInUse( aOldName, aNewName );
+
+ SCTAB nTabCount = aDocument.GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (aDocument.GetPageStyle(nTab) == aNewName) // schon auf neu angepasst
+ {
+ aDocument.PageStyleModified( nTab, aNewName );
+ ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
+ aPrintFunc.UpdatePages();
+ }
+
+ aModificator.SetDocumentModified();
+
+ if (bExtended)
+ {
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( SID_STATUS_PAGESTYLE );
+ pBindings->Invalidate( SID_STYLE_FAMILY4 );
+ pBindings->Invalidate( FID_RESET_PRINTZOOM );
+ pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ }
+ }
+ }
+ else if ( pStyle->GetFamily() == SFX_STYLE_FAMILY_PARA )
+ {
+ if ( nId == SFX_STYLESHEET_MODIFIED)
+ {
+ String aNewName = pStyle->GetName();
+ String aOldName = aNewName;
+ BOOL bExtended = rHint.ISA(SfxStyleSheetHintExtended);
+ if (bExtended)
+ aOldName = ((SfxStyleSheetHintExtended&)rHint).GetOldName();
+ if ( aNewName != aOldName )
+ {
+ ScConditionalFormatList* pList = aDocument.GetCondFormList();
+ if (pList)
+ pList->RenameCellStyle( aOldName,aNewName );
+ }
+ }
+ }
+
+ // alles andere geht ueber Slots...
+}
+
+// wie in printfun.cxx
+#define ZOOM_MIN 10
+
+void ScDocShell::SetPrintZoom( SCTAB nTab, USHORT nScale, USHORT nPages )
+{
+ BOOL bUndo(aDocument.IsUndoEnabled());
+ String aStyleName = aDocument.GetPageStyle( nTab );
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found" );
+ if ( pStyleSheet )
+ {
+ ScDocShellModificator aModificator( *this );
+
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ if (bUndo)
+ {
+ USHORT nOldScale = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALE)).GetValue();
+ USHORT nOldPages = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
+ GetUndoManager()->AddUndoAction( new ScUndoPrintZoom(
+ this, nTab, nOldScale, nOldPages, nScale, nPages ) );
+ }
+
+ rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
+ rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) );
+
+ ScPrintFunc aPrintFunc( this, GetPrinter(), nTab );
+ aPrintFunc.UpdatePages();
+ aModificator.SetDocumentModified();
+
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( FID_RESET_PRINTZOOM );
+ }
+}
+
+BOOL ScDocShell::AdjustPrintZoom( const ScRange& rRange )
+{
+ BOOL bChange = FALSE;
+ SCTAB nTab = rRange.aStart.Tab();
+
+ String aStyleName = aDocument.GetPageStyle( nTab );
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found" );
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ BOOL bHeaders = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_HEADERS)).GetValue();
+ USHORT nOldScale = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALE)).GetValue();
+ USHORT nOldPages = ((const SfxUInt16Item&)rSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
+ const ScRange* pRepeatCol = aDocument.GetRepeatColRange( nTab );
+ const ScRange* pRepeatRow = aDocument.GetRepeatRowRange( nTab );
+
+ // benoetigte Skalierung fuer Selektion ausrechnen
+
+ USHORT nNewScale = nOldScale;
+
+ long nBlkTwipsX = 0;
+ if (bHeaders)
+ nBlkTwipsX += (long) PRINT_HEADER_WIDTH;
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ if ( pRepeatCol && nStartCol >= pRepeatCol->aStart.Col() )
+ {
+ for (SCCOL i=pRepeatCol->aStart.Col(); i<=pRepeatCol->aEnd.Col(); i++ )
+ nBlkTwipsX += aDocument.GetColWidth( i, nTab );
+ if ( nStartCol <= pRepeatCol->aEnd.Col() )
+ nStartCol = pRepeatCol->aEnd.Col() + 1;
+ }
+ // legacy compilers' own scope for i
+ {
+ for ( SCCOL i=nStartCol; i<=nEndCol; i++ )
+ nBlkTwipsX += aDocument.GetColWidth( i, nTab );
+ }
+
+ long nBlkTwipsY = 0;
+ if (bHeaders)
+ nBlkTwipsY += (long) PRINT_HEADER_HEIGHT;
+ SCROW nStartRow = rRange.aStart.Row();
+ SCROW nEndRow = rRange.aEnd.Row();
+ if ( pRepeatRow && nStartRow >= pRepeatRow->aStart.Row() )
+ {
+ nBlkTwipsY += aDocument.GetRowHeight( pRepeatRow->aStart.Row(),
+ pRepeatRow->aEnd.Row(), nTab );
+ if ( nStartRow <= pRepeatRow->aEnd.Row() )
+ nStartRow = pRepeatRow->aEnd.Row() + 1;
+ }
+ nBlkTwipsY += aDocument.GetRowHeight( nStartRow, nEndRow, nTab );
+
+ Size aPhysPage;
+ long nHdr, nFtr;
+ ScPrintFunc aOldPrFunc( this, GetPrinter(), nTab );
+ aOldPrFunc.GetScaleData( aPhysPage, nHdr, nFtr );
+ nBlkTwipsY += nHdr + nFtr;
+
+ if ( nBlkTwipsX == 0 ) // #100639# hidden columns/rows may lead to 0
+ nBlkTwipsX = 1;
+ if ( nBlkTwipsY == 0 )
+ nBlkTwipsY = 1;
+
+ long nNeeded = Min( aPhysPage.Width() * 100 / nBlkTwipsX,
+ aPhysPage.Height() * 100 / nBlkTwipsY );
+ if ( nNeeded < ZOOM_MIN )
+ nNeeded = ZOOM_MIN; // Begrenzung
+ if ( nNeeded < (long) nNewScale )
+ nNewScale = (USHORT) nNeeded;
+
+ bChange = ( nNewScale != nOldScale || nOldPages != 0 );
+ if ( bChange )
+ SetPrintZoom( nTab, nNewScale, 0 );
+ }
+ return bChange;
+}
+
+void ScDocShell::PageStyleModified( const String& rStyleName, BOOL bApi )
+{
+ ScDocShellModificator aModificator( *this );
+
+ BOOL bWarn = FALSE;
+
+ SCTAB nTabCount = aDocument.GetTableCount();
+ SCTAB nUseTab = MAXTAB+1;
+ for (SCTAB nTab=0; nTab<nTabCount && nUseTab>MAXTAB; nTab++)
+ if ( aDocument.GetPageStyle(nTab) == rStyleName &&
+ ( !bApi || aDocument.GetPageSize(nTab).Width() ) )
+ nUseTab = nTab;
+ // bei bApi nur, wenn Umbrueche schon angezeigt
+
+ if (ValidTab(nUseTab)) // nicht verwendet -> nichts zu tun
+ {
+ ScPrintFunc aPrintFunc( this, GetPrinter(), nUseTab ); //! ohne CountPages auskommen
+ if (!aPrintFunc.UpdatePages()) // setzt Umbrueche auf allen Tabs
+ bWarn = TRUE;
+
+ if (bWarn && !bApi)
+ {
+ ScWaitCursorOff aWaitOff( GetActiveDialogParent() );
+ InfoBox aInfoBox(GetActiveDialogParent(),
+ ScGlobal::GetRscString(STR_PRINT_INVALID_AREA));
+ aInfoBox.Execute();
+ }
+ }
+
+ aModificator.SetDocumentModified();
+
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( FID_RESET_PRINTZOOM );
+ pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+}
+
+void ScDocShell::ExecutePageStyle( SfxViewShell& rCaller,
+ SfxRequest& rReq,
+ SCTAB nCurTab )
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_STATUS_PAGESTYLE: // Click auf StatusBar-Control
+ case SID_FORMATPAGE:
+ {
+ if ( pReqArgs != NULL )
+ {
+ }
+ else if ( pReqArgs == NULL )
+ {
+ BOOL bUndo(aDocument.IsUndoEnabled());
+ String aOldName = aDocument.GetPageStyle( nCurTab );
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet
+ = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
+
+ if ( pStyleSheet )
+ {
+ ScStyleSaveData aOldData;
+ if (bUndo)
+ aOldData.InitFromStyle( pStyleSheet );
+
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScStyleDlg( GetActiveDialogParent(), *pStyleSheet, RID_SCDLG_STYLES_PAGE, RID_SCDLG_STYLES_PAGE );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ WaitObject aWait( GetActiveDialogParent() );
+
+ String aNewName = pStyleSheet->GetName();
+ if ( aNewName != aOldName &&
+ aDocument.RenamePageStyleInUse( aOldName, aNewName ) )
+ {
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( SID_STATUS_PAGESTYLE );
+ pBindings->Invalidate( FID_RESET_PRINTZOOM );
+ }
+ }
+
+ if ( pOutSet )
+ aDocument.ModifyStyleSheet( *pStyleSheet, *pOutSet );
+
+ // merken fuer GetState():
+ GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, bHeaderOn, bFooterOn );
+ rCaller.GetViewFrame()->GetBindings().Invalidate( SID_HFEDIT );
+
+ ScStyleSaveData aNewData;
+ aNewData.InitFromStyle( pStyleSheet );
+ if (bUndo)
+ {
+ GetUndoManager()->AddUndoAction(
+ new ScUndoModifyStyle( this, SFX_STYLE_FAMILY_PAGE,
+ aOldData, aNewData ) );
+ }
+
+ PageStyleModified( aNewName, FALSE );
+ rReq.Done();
+ }
+ delete pDlg;
+
+ rStyleSet.ClearItem( ATTR_PAGE_PAPERTRAY );
+ }
+ }
+ }
+ break;
+
+ case SID_HFEDIT:
+ {
+ if ( pReqArgs != NULL )
+ {
+ }
+ else if ( pReqArgs == NULL )
+ {
+ String aStr( aDocument.GetPageStyle( nCurTab ) );
+
+ ScStyleSheetPool* pStylePool
+ = aDocument.GetStyleSheetPool();
+
+ SfxStyleSheetBase* pStyleSheet
+ = pStylePool->Find( aStr, SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
+
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+
+ SvxPageUsage eUsage =
+ SvxPageUsage( ((const SvxPageItem&)
+ rStyleSet.Get( ATTR_PAGE )).
+ GetPageUsage() );
+ BOOL bShareHeader = IS_SHARE_HEADER(rStyleSet);
+ BOOL bShareFooter = IS_SHARE_FOOTER(rStyleSet);
+ USHORT nResId = 0;
+
+ switch ( eUsage )
+ {
+ case SVX_PAGE_LEFT:
+ case SVX_PAGE_RIGHT:
+ {
+ if ( bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT;
+ else if ( SVX_PAGE_RIGHT == eUsage )
+ {
+ if ( !bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
+ else if ( bHeaderOn && !bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
+ }
+ else
+ {
+ // #69193a# respect "shared" setting
+ if ( !bHeaderOn && bFooterOn )
+ nResId = bShareFooter ?
+ RID_SCDLG_HFEDIT_RIGHTFOOTER :
+ RID_SCDLG_HFEDIT_LEFTFOOTER;
+ else if ( bHeaderOn && !bFooterOn )
+ nResId = bShareHeader ?
+ RID_SCDLG_HFEDIT_RIGHTHEADER :
+ RID_SCDLG_HFEDIT_LEFTHEADER;
+ }
+ }
+ break;
+
+ case SVX_PAGE_MIRROR:
+ case SVX_PAGE_ALL:
+ default:
+ {
+ if ( !bShareHeader && !bShareFooter )
+ {
+ if ( bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_ALL;
+ else if ( !bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_FOOTER;
+ else if ( bHeaderOn && !bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_HEADER;
+ }
+ else if ( bShareHeader && bShareFooter )
+ {
+ if ( bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT;
+ else
+ {
+ if ( !bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
+ else if ( bHeaderOn && !bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
+ }
+ }
+ else if ( !bShareHeader && bShareFooter )
+ {
+ if ( bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_SFTR;
+ else if ( !bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_RIGHTFOOTER;
+ else if ( bHeaderOn && !bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_HEADER;
+ }
+ else if ( bShareHeader && !bShareFooter )
+ {
+ if ( bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_SHDR;
+ else if ( !bHeaderOn && bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_FOOTER;
+ else if ( bHeaderOn && !bFooterOn )
+ nResId = RID_SCDLG_HFEDIT_RIGHTHEADER;
+ }
+ }
+ }
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScHFEditDlg( SfxViewFrame::Current(),
+ GetActiveDialogParent(),
+ rStyleSet,
+ aStr,
+ RID_SCDLG_HFEDIT, nResId);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ if ( pOutSet )
+ aDocument.ModifyStyleSheet( *pStyleSheet, *pOutSet );
+
+ SetDocumentModified();
+ rReq.Done();
+ }
+ delete pDlg;
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+void ScDocShell::GetStatePageStyle( SfxViewShell& /* rCaller */,
+ SfxItemSet& rSet,
+ SCTAB nCurTab )
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch (nWhich)
+ {
+ case SID_STATUS_PAGESTYLE:
+ rSet.Put( SfxStringItem( nWhich, aDocument.GetPageStyle( nCurTab ) ) );
+ break;
+
+ case SID_HFEDIT:
+ {
+ String aStr = aDocument.GetPageStyle( nCurTab );
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStr, SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
+
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+
+ GetPageOnFromPageStyleSet( &rStyleSet, nCurTab, bHeaderOn, bFooterOn );
+
+ if ( !bHeaderOn && !bFooterOn )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void lcl_GetPrintData( ScDocShell* pDocShell /*in*/,
+ ScDocument* pDocument /*in*/, SfxPrinter* pPrinter /*in*/,
+ PrintDialog* pPrintDialog /*in*/, bool bForceSelected /*in*/,
+ ScMarkData* pMarkData /*inout*/, bool& rbHasOptions /*out*/,
+ ScPrintOptions& rOptions /*out*/, bool& rbAllTabs /*out*/,
+ long& rnTotalPages /*out*/, long aPageArr[] /*out*/,
+ MultiSelection& rPageRanges /*out*/, ScRange** ppMarkedRange /*out*/ )
+{
+ // get settings from print options sub-dialog
+ const SfxItemSet& rOptionSet = pPrinter->GetOptions();
+ const SfxPoolItem* pItem;
+ rbHasOptions = ( rOptionSet.GetItemState( SID_SCPRINTOPTIONS, FALSE, &pItem ) == SFX_ITEM_SET );
+ if ( rbHasOptions )
+ {
+ rOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
+ }
+ else
+ {
+ // use configuration
+ rOptions = SC_MOD()->GetPrintOptions();
+ }
+
+ // update all pending row heights with a single progress bar,
+ // instead of a separate progress for each sheet from ScPrintFunc
+ pDocShell->UpdatePendingRowHeights( MAXTAB, true );
+
+ // get number of total pages
+ rnTotalPages = 0;
+ SCTAB nTabCount = pDocument->GetTableCount();
+ for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
+ {
+ ScPrintFunc aPrintFunc( pDocShell, pPrinter, nTab, 0, 0, NULL, &rOptions );
+ long nThisTab = aPrintFunc.GetTotalPages();
+ aPageArr[nTab] = nThisTab;
+ rnTotalPages += nThisTab;
+ }
+
+ rPageRanges.SetTotalRange( Range( 0, RANGE_MAX ) );
+ rPageRanges.Select( Range( 1, rnTotalPages ) );
+
+ rbAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() );
+ if ( bForceSelected )
+ {
+ rbAllTabs = false;
+ }
+
+ if ( ( pPrintDialog && pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_SELECTED_CELLS ) || bForceSelected )
+ {
+ if ( pMarkData && ( pMarkData->IsMarked() || pMarkData->IsMultiMarked() ) )
+ {
+ pMarkData->MarkToMulti();
+ *ppMarkedRange = new ScRange;
+ pMarkData->GetMultiMarkArea( **ppMarkedRange );
+ pMarkData->MarkToSimple();
+ }
+ }
+
+ PrintDialogRange eDlgOption = pPrintDialog ? pPrintDialog->GetCheckedRange() : PRINTDIALOG_ALL;
+ if ( eDlgOption == PRINTDIALOG_RANGE )
+ {
+ rPageRanges = MultiSelection( pPrintDialog->GetRangeText() );
+ }
+
+ // get number of total pages if selection
+ if ( !rbAllTabs )
+ {
+ rnTotalPages = 0;
+ for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
+ {
+ if ( *ppMarkedRange ) // selected range is used instead of print ranges -> page count is different
+ {
+ ScPrintFunc aPrintFunc( pDocShell, pPrinter, nTab, 0, 0, *ppMarkedRange, &rOptions );
+ aPageArr[nTab] = aPrintFunc.GetTotalPages();
+ }
+ if ( !pMarkData || pMarkData->GetTableSelect( nTab ) )
+ {
+ rnTotalPages += aPageArr[nTab];
+ }
+ }
+ if ( eDlgOption == PRINTDIALOG_ALL || bForceSelected )
+ {
+ rPageRanges.Select( Range( 1, rnTotalPages ) );
+ }
+ }
+}
+
+bool ScDocShell::CheckPrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData, bool bForceSelected, bool bIsAPI )
+{
+ SfxPrinter* pPrinter = GetPrinter();
+ if ( !pPrinter )
+ {
+ return false;
+ }
+
+ bool bHasOptions = false;
+ ScPrintOptions aOptions;
+ bool bAllTabs = true;
+ long nTotalPages = 0;
+ long aPageArr[MAXTABCOUNT]; // pages per sheet
+ MultiSelection aPageRanges; // pages to print
+ ScRange* pMarkedRange = NULL;
+
+ lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, bForceSelected,
+ pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages,
+ aPageArr, aPageRanges, &pMarkedRange );
+
+ delete pMarkedRange;
+
+ if ( nTotalPages == 0 )
+ {
+ if ( !bIsAPI )
+ {
+ WarningBox aWarningBox( GetActiveDialogParent(), WinBits( WB_OK ),
+ String( ScResId( STR_PRINT_NOTHING ) ) );
+ aWarningBox.Execute();
+ }
+ return false;
+ }
+
+ return true;
+}
+
+void ScDocShell::PreparePrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData )
+{
+ SfxPrinter* pPrinter = GetPrinter();
+ if ( !pPrinter )
+ {
+ return;
+ }
+
+ delete pOldJobSetup; // gesetzt nur bei Fehler in StartJob()
+ pOldJobSetup = new ScJobSetup( pPrinter ); // Einstellungen merken
+
+ // Einstellungen fuer die erste gedruckte Seite muessen hier (vor StartJob) gesetzt werden
+ //! Selection etc. mit Print() zusammenfassen !!!
+ //! Seiten nur einmal zaehlen
+
+ bool bHasOptions = false;
+ ScPrintOptions aOptions;
+ bool bAllTabs = true;
+ long nTotalPages = 0;
+ long aPageArr[MAXTABCOUNT]; // pages per sheet
+ MultiSelection aPageRanges; // pages to print
+ ScRange* pMarkedRange = NULL;
+
+ lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, false,
+ pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages,
+ aPageArr, aPageRanges, &pMarkedRange );
+
+ BOOL bFound = FALSE; // erste Seite gefunden
+ long nTabStart = 0;
+ SCTAB nTabCount = aDocument.GetTableCount();
+ for ( SCTAB nTab=0; nTab<nTabCount && !bFound; nTab++ )
+ {
+ if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) )
+ {
+ long nNext = nTabStart + aPageArr[nTab];
+ BOOL bSelected = FALSE;
+ for (long nP=nTabStart+1; nP<=nNext; nP++) // 1-basiert
+ if (aPageRanges.IsSelected( nP )) // eine Seite von dieser Tabelle selektiert?
+ bSelected = TRUE;
+
+ if (bSelected)
+ {
+ ScPrintFunc aPrintFunc( this, pPrinter, nTab );
+
+ aPrintFunc.ApplyPrintSettings(); // dann Settings fuer diese Tabelle
+ bFound = TRUE;
+ }
+ nTabStart = nNext;
+ }
+ }
+
+ delete pMarkedRange;
+}
+
+BOOL lcl_HasTransparent( ScDocument* pDoc, SCTAB nTab, const ScRange* pRange )
+{
+ BOOL bFound = FALSE;
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage,"Page ?");
+ if (pPage)
+ {
+ Rectangle aMMRect;
+ if ( pRange )
+ aMMRect = pDoc->GetMMRect( pRange->aStart.Col(), pRange->aStart.Row(),
+ pRange->aEnd.Col(), pRange->aEnd.Row(), nTab );
+
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !bFound)
+ {
+ if (pObject->IsTransparent())
+ {
+ if ( pRange )
+ {
+ Rectangle aObjRect = pObject->GetLogicRect();
+ if ( aObjRect.IsOver( aMMRect ) )
+ bFound = TRUE;
+ }
+ else
+ bFound = TRUE;
+ }
+
+ pObject = aIter.Next();
+ }
+ }
+ }
+
+ return bFound;
+}
+
+void ScDocShell::Print( SfxProgress& rProgress, PrintDialog* pPrintDialog,
+ ScMarkData* pMarkData, Window* pDialogParent, BOOL bForceSelected, BOOL bIsAPI )
+{
+ SfxPrinter* pPrinter = GetPrinter();
+ if ( !pPrinter )
+ {
+ return;
+ }
+
+ bool bHasOptions = false;
+ ScPrintOptions aOptions;
+ bool bAllTabs = true;
+ long nTotalPages = 0;
+ long aPageArr[MAXTABCOUNT]; // pages per sheet
+ MultiSelection aPageRanges; // pages to print
+ ScRange* pMarkedRange = NULL;
+
+ lcl_GetPrintData( this, &aDocument, pPrinter, pPrintDialog, bForceSelected,
+ pMarkData, bHasOptions, aOptions, bAllTabs, nTotalPages,
+ aPageArr, aPageRanges, &pMarkedRange );
+
+ USHORT nCollateCopies = 1;
+ if ( pPrintDialog && pPrintDialog->IsCollateEnabled() && pPrintDialog->IsCollateChecked() )
+ nCollateCopies = pPrintDialog->GetCopyCount();
+
+ // test if printed range contains transparent objects
+
+ BOOL bHasTransp = FALSE;
+ BOOL bAnyPrintRanges = aDocument.HasPrintRange();
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ SCTAB nTabCount = aDocument.GetTableCount();
+ for ( SCTAB nTab=0; nTab<nTabCount && !bHasTransp; nTab++ )
+ {
+ if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) )
+ {
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
+ aDocument.GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
+ if ( pStyleSheet )
+ {
+ const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ if ( ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_CHARTS)).GetValue() == VOBJ_MODE_SHOW ||
+ ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_OBJECTS)).GetValue() == VOBJ_MODE_SHOW ||
+ ((const ScViewObjectModeItem&)rSet.Get(ATTR_PAGE_DRAWINGS)).GetValue() == VOBJ_MODE_SHOW )
+ {
+ if ( pMarkedRange )
+ bHasTransp = bHasTransp || lcl_HasTransparent( &aDocument, nTab, pMarkedRange );
+ else if ( aDocument.GetPrintRangeCount(nTab) )
+ {
+ USHORT nRangeCount = aDocument.GetPrintRangeCount(nTab);
+ for (USHORT i=0; i<nRangeCount; i++)
+ bHasTransp = bHasTransp ||
+ lcl_HasTransparent( &aDocument, nTab, aDocument.GetPrintRange( nTab, i ) );
+ }
+ else if (!bAnyPrintRanges || aDocument.IsPrintEntireSheet(nTab))
+ bHasTransp = bHasTransp || lcl_HasTransparent( &aDocument, nTab, NULL );
+ }
+ }
+ }
+ }
+
+ BOOL bContinue = pPrinter->InitJob( pDialogParent, !bIsAPI && bHasTransp );
+
+ if ( bContinue )
+ {
+ for ( USHORT n=0; n<nCollateCopies; n++ )
+ {
+ long nTabStart = 0;
+ long nDisplayStart = 0;
+ long nAttrPage = 1;
+ long nPrinted = 0;
+
+ for ( SCTAB nTab=0; nTab<nTabCount; nTab++ )
+ {
+ if ( bAllTabs || !pMarkData || pMarkData->GetTableSelect( nTab ) )
+ {
+ FmFormView* pDrawView = NULL;
+ Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX );
+
+ // #114135#
+ ScDrawLayer* pModel = aDocument.GetDrawLayer(); // ist nicht NULL
+
+ if(pModel)
+ {
+ pDrawView = new FmFormView( pModel, pPrinter );
+ pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
+ pDrawView->SetPrintPreview( TRUE );
+ }
+
+ ScPrintFunc aPrintFunc( this, pPrinter, nTab, nAttrPage, nTotalPages, pMarkedRange, &aOptions );
+ aPrintFunc.SetDrawView( pDrawView );
+ nPrinted += aPrintFunc.DoPrint( aPageRanges, nTabStart, nDisplayStart, TRUE, &rProgress, NULL );
+
+ nTabStart += aPageArr[nTab];
+ if ( aDocument.NeedPageResetAfterTab(nTab) )
+ nDisplayStart = 0;
+ else
+ nDisplayStart += aPageArr[nTab];
+ nAttrPage = aPrintFunc.GetFirstPageNo(); // behalten oder aus Vorlage
+
+ delete pDrawView;
+ }
+ }
+
+#if 0
+ if ( n+1 < nCollateCopies &&
+ (pPrinter->GetDuplexMode() == DUPLEX_SHORTEDGE || pPrinter->GetDuplexMode() == DUPLEX_LONGEDGE) &&
+ ( nPrinted % 2 ) == 1 )
+ {
+ // #105584# when several collated copies are printed in duplex mode, and there is
+ // an odd number of pages, print an empty page between copies, so the first page of
+ // the second copy isn't printed on the back of the last page of the first copy.
+ // (same as in Writer ViewShell::Prt)
+
+ // FIXME: needs to be adapted to XRenderable interface
+ pPrinter->StartPage();
+ pPrinter->EndPage();
+ }
+#endif
+ }
+ }
+
+ delete pMarkedRange;
+
+ if (pOldJobSetup)
+ {
+ pPrinter->SetOrientation( pOldJobSetup->eOrientation );
+ pPrinter->SetPaperBin ( pOldJobSetup->nPaperBin );
+ pPrinter->SetPaper ( pOldJobSetup->ePaper );
+
+ if ( PAPER_USER == pOldJobSetup->ePaper )
+ {
+ pPrinter->SetMapMode( pOldJobSetup->aUserMapMode );
+ pPrinter->SetPaperSizeUser( pOldJobSetup->aUserSize );
+ }
+
+ delete pOldJobSetup;
+ pOldJobSetup = NULL;
+ }
+
+ if ( bHasOptions )
+ {
+ // remove PrintOptions from printer ItemSet,
+ // so next time the options from the configuration are used
+
+ SfxItemSet aSet( pPrinter->GetOptions() );
+ aSet.ClearItem( SID_SCPRINTOPTIONS );
+ pPrinter->SetOptions( aSet );
+ }
+
+ PostPaintGridAll(); //! nur wenn geaendert
+}
+
+void ScDocShell::GetState( SfxItemSet &rSet )
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch (nWhich)
+ {
+ case FID_AUTO_CALC:
+ if ( (BOOL) aDocument.GetHardRecalcState() )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem( nWhich, aDocument.GetAutoCalc() ) );
+ break;
+
+ case FID_CHG_RECORD:
+ if ( IsDocShared() )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem( nWhich,
+ aDocument.GetChangeTrack() != NULL ) );
+ break;
+
+ case SID_CHG_PROTECT:
+ {
+ ScChangeTrack* pChangeTrack = aDocument.GetChangeTrack();
+ if ( pChangeTrack && !IsDocShared() )
+ rSet.Put( SfxBoolItem( nWhich,
+ pChangeTrack->IsProtected() ) );
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DOCUMENT_COMPARE:
+ {
+ if ( IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ // Wenn eine Formel editiert wird, muss FID_RECALC auf jeden Fall enabled sein.
+ // Recalc fuer das Doc war mal wegen #29898# disabled, wenn AutoCalc an war,
+ // ist jetzt wegen #41540# aber auch immer enabled.
+// case FID_RECALC:
+// if ( aDocument.GetAutoCalc() )
+// rSet.DisableItem( nWhich );
+// break;
+
+ case SID_TABLES_COUNT:
+ rSet.Put( SfxInt16Item( nWhich, aDocument.GetTableCount() ) );
+ break;
+
+ case SID_ATTR_YEAR2000 :
+ rSet.Put( SfxUInt16Item( nWhich,
+ aDocument.GetDocOptions().GetYear2000() ) );
+ break;
+
+ case SID_SHARE_DOC:
+ {
+ if ( IsReadOnly() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ default:
+ {
+ }
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScDocShell::GetSbxState( SfxItemSet &rSet )
+{
+ // SID_SC_SELECTION (Selection),
+ // SID_SC_ACTIVECELL (ActiveCell),
+ // SID_SC_ACTIVETAB (ActiveTable),
+ // SID_TABLES_GET (Tables),
+ // SID_PIVOT_GET (DataPilotTables) - removed (old Basic)
+
+ //
+ // Wenn hier Slots von der View-Shell executed werden, muss auch der
+ // GetState weitergeleitet werden!
+ //
+
+ ScTabViewShell* pVisibleSh = GetBestViewShell(); // sichtbare View
+ if ( pVisibleSh )
+ pVisibleSh->GetState( rSet );
+}
+
+void __EXPORT ScDocShell::Draw( OutputDevice* pDev, const JobSetup & /* rSetup */, USHORT nAspect )
+{
+// bIsOle = TRUE; // jetzt ueber den CreateMode
+
+ SCTAB nVisTab = aDocument.GetVisibleTab();
+ if (!aDocument.HasTable(nVisTab))
+ return;
+
+ ULONG nOldLayoutMode = pDev->GetLayoutMode();
+ pDev->SetLayoutMode( TEXT_LAYOUT_DEFAULT ); // even if it's the same, to get the metafile action
+
+ if ( nAspect == ASPECT_THUMBNAIL )
+ {
+ Rectangle aBoundRect = GetVisArea( ASPECT_THUMBNAIL );
+ ScViewData aTmpData( this, NULL );
+ aTmpData.SetTabNo(nVisTab);
+ aDocument.SnapVisArea( aBoundRect );
+ aTmpData.SetScreen( aBoundRect );
+ ScPrintFunc::DrawToDev( &aDocument, pDev, 1.0, aBoundRect, &aTmpData, TRUE );
+ }
+ else
+ {
+ Rectangle aBoundRect = SfxObjectShell::GetVisArea();
+ ScViewData aTmpData( this, NULL );
+ aTmpData.SetTabNo(nVisTab);
+ aDocument.SnapVisArea( aBoundRect );
+ aTmpData.SetScreen( aBoundRect );
+ ScPrintFunc::DrawToDev( &aDocument, pDev, 1.0, aBoundRect, &aTmpData, TRUE );
+ }
+
+ pDev->SetLayoutMode( nOldLayoutMode );
+}
+
+Rectangle __EXPORT ScDocShell::GetVisArea( USHORT nAspect ) const
+{
+ SfxObjectCreateMode eShellMode = GetCreateMode();
+ if ( eShellMode == SFX_CREATE_MODE_ORGANIZER )
+ {
+ // ohne Inhalte wissen wir auch nicht, wie gross die Inhalte sind
+ // leeres Rechteck zurueckgeben, das wird dann nach dem Laden berechnet
+ return Rectangle();
+ }
+
+ if( nAspect == ASPECT_THUMBNAIL )
+ {
+// Rectangle aArea( 0,0, 3175,3175 ); // 120x120 Pixel in 1:1
+ Rectangle aArea( 0,0, SC_PREVIEW_SIZE_X,SC_PREVIEW_SIZE_Y );
+ BOOL bNegativePage = aDocument.IsNegativePage( aDocument.GetVisibleTab() );
+ if ( bNegativePage )
+ ScDrawLayer::MirrorRectRTL( aArea );
+ aDocument.SnapVisArea( aArea );
+ return aArea;
+ }
+ else if( nAspect == ASPECT_CONTENT && eShellMode != SFX_CREATE_MODE_EMBEDDED )
+ {
+ // Visarea holen wie nach Load
+
+ SCTAB nVisTab = aDocument.GetVisibleTab();
+ if (!aDocument.HasTable(nVisTab))
+ {
+ nVisTab = 0;
+ ((ScDocShell*)this)->aDocument.SetVisibleTab(nVisTab);
+ }
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ aDocument.GetDataStart( nVisTab, nStartCol, nStartRow );
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ aDocument.GetPrintArea( nVisTab, nEndCol, nEndRow );
+ if (nStartCol>nEndCol)
+ nStartCol = nEndCol;
+ if (nStartRow>nEndRow)
+ nStartRow = nEndRow;
+ Rectangle aNewArea = ((ScDocument&)aDocument)
+ .GetMMRect( nStartCol,nStartRow, nEndCol,nEndRow, nVisTab );
+ //TODO/LATER: different methods for setting VisArea?!
+ ((ScDocShell*)this)->SfxObjectShell::SetVisArea( aNewArea );
+ return aNewArea;
+ }
+ else
+ return SfxObjectShell::GetVisArea( nAspect );
+}
+
+void ScDocShell::GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet,
+ SCTAB nCurTab,
+ BOOL& rbHeader,
+ BOOL& rbFooter )
+{
+ if ( !pStyleSet )
+ {
+ ScStyleSheetPool* pStylePool = aDocument.GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->
+ Find( aDocument.GetPageStyle( nCurTab ),
+ SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
+
+ if ( pStyleSheet )
+ pStyleSet = &pStyleSheet->GetItemSet();
+ else
+ rbHeader = rbFooter = FALSE;
+ }
+
+ DBG_ASSERT( pStyleSet, "PageStyle-Set not found! :-(" );
+
+ //--------------------------------------------------------------------
+
+ const SvxSetItem* pSetItem = NULL;
+ const SfxItemSet* pSet = NULL;
+
+ pSetItem = (const SvxSetItem*) &pStyleSet->Get( ATTR_PAGE_HEADERSET );
+ pSet = &pSetItem->GetItemSet();
+ rbHeader = ((const SfxBoolItem&)pSet->Get(ATTR_PAGE_ON)).GetValue();
+
+ pSetItem = (const SvxSetItem*) &pStyleSet->Get( ATTR_PAGE_FOOTERSET );
+ pSet = &pSetItem->GetItemSet();
+ rbFooter = ((const SfxBoolItem&)pSet->Get(ATTR_PAGE_ON)).GetValue();
+}
+
+long __EXPORT ScDocShell::DdeGetData( const String& rItem,
+ const String& rMimeType,
+ ::com::sun::star::uno::Any & rValue )
+{
+ if( FORMAT_STRING == SotExchange::GetFormatIdFromMimeType( rMimeType ) )
+ {
+ if( rItem.EqualsIgnoreCaseAscii( "Format" ) )
+ {
+ ByteString aFmtByte( aDdeTextFmt, gsl_getSystemTextEncoding() );
+ rValue <<= ::com::sun::star::uno::Sequence< sal_Int8 >(
+ (sal_Int8*)aFmtByte.GetBuffer(),
+ aFmtByte.Len() + 1 );
+ return 1;
+ }
+ ScImportExport aObj( &aDocument, rItem );
+ if ( !aObj.IsRef() )
+ return 0; // ungueltiger Bereich
+
+ if( aDdeTextFmt.GetChar(0) == 'F' )
+ aObj.SetFormulas( TRUE );
+ if( aDdeTextFmt.EqualsAscii( "SYLK" ) ||
+ aDdeTextFmt.EqualsAscii( "FSYLK" ) )
+ {
+ ByteString aData;
+ if( aObj.ExportByteString( aData, gsl_getSystemTextEncoding(),
+ SOT_FORMATSTR_ID_SYLK ) )
+ {
+ rValue <<= ::com::sun::star::uno::Sequence< sal_Int8 >(
+ (sal_Int8*)aData.GetBuffer(),
+ aData.Len() + 1 );
+ return 1;
+ }
+ else
+ return 0;
+ }
+ if( aDdeTextFmt.EqualsAscii( "CSV" ) ||
+ aDdeTextFmt.EqualsAscii( "FCSV" ) )
+ aObj.SetSeparator( ',' );
+ aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) );
+ return aObj.ExportData( rMimeType, rValue ) ? 1 : 0;
+ }
+
+ ScImportExport aObj( &aDocument, rItem );
+ aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, 0, false ) );
+ if( aObj.IsRef() )
+ return aObj.ExportData( rMimeType, rValue ) ? 1 : 0;
+ return 0;
+}
+
+long __EXPORT ScDocShell::DdeSetData( const String& rItem,
+ const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue )
+{
+ if( FORMAT_STRING == SotExchange::GetFormatIdFromMimeType( rMimeType ))
+ {
+ if( rItem.EqualsIgnoreCaseAscii( "Format" ) )
+ {
+ if ( ScByteSequenceToString::GetString( aDdeTextFmt, rValue, gsl_getSystemTextEncoding() ) )
+ {
+ aDdeTextFmt.ToUpperAscii();
+ return 1;
+ }
+ return 0;
+ }
+ ScImportExport aObj( &aDocument, rItem );
+ if( aDdeTextFmt.GetChar(0) == 'F' )
+ aObj.SetFormulas( TRUE );
+ if( aDdeTextFmt.EqualsAscii( "SYLK" ) ||
+ aDdeTextFmt.EqualsAscii( "FSYLK" ) )
+ {
+ String aData;
+ if ( ScByteSequenceToString::GetString( aData, rValue, gsl_getSystemTextEncoding() ) )
+ {
+ return aObj.ImportString( aData, SOT_FORMATSTR_ID_SYLK ) ? 1 : 0;
+ }
+ return 0;
+ }
+ if( aDdeTextFmt.EqualsAscii( "CSV" ) ||
+ aDdeTextFmt.EqualsAscii( "FCSV" ) )
+ aObj.SetSeparator( ',' );
+ return aObj.ImportData( rMimeType, rValue ) ? 1 : 0;
+ }
+ ScImportExport aObj( &aDocument, rItem );
+ if( aObj.IsRef() )
+ return aObj.ImportData( rMimeType, rValue ) ? 1 : 0;
+ return 0;
+}
+
+::sfx2::SvLinkSource* __EXPORT ScDocShell::DdeCreateLinkSource( const String& rItem )
+{
+ // only check for valid item string - range is parsed again in ScServerObject ctor
+
+ // named range?
+ String aPos = rItem;
+ ScRangeName* pRange = aDocument.GetRangeName();
+ if( pRange )
+ {
+ USHORT nPos;
+ if( pRange->SearchName( aPos, nPos ) )
+ {
+ ScRangeData* pData = (*pRange)[ nPos ];
+ if( pData->HasType( RT_REFAREA )
+ || pData->HasType( RT_ABSAREA )
+ || pData->HasType( RT_ABSPOS ) )
+ pData->GetSymbol( aPos ); // continue with the name's contents
+ }
+ }
+
+ // Address in DDE function must be always parsed as CONV_OOO so that it
+ // would always work regardless of current address convension. We do this
+ // because the address item in a DDE entry is *not* normalized when saved
+ // into ODF.
+ ScRange aRange;
+ bool bValid = ( (aRange.Parse(aPos, &aDocument, formula::FormulaGrammar::CONV_OOO ) & SCA_VALID) ||
+ (aRange.aStart.Parse(aPos, &aDocument, formula::FormulaGrammar::CONV_OOO) & SCA_VALID) );
+
+ ScServerObject* pObj = NULL; // NULL = error
+ if ( bValid )
+ pObj = new ScServerObject( this, rItem );
+
+ // GetLinkManager()->InsertServer() is in the ScServerObject ctor
+
+ return pObj;
+}
+
+//------------------------------------------------------------------
+
+ScViewData* ScDocShell::GetViewData()
+{
+ SfxViewShell* pCur = SfxViewShell::Current();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pCur);
+ return pViewSh ? pViewSh->GetViewData() : NULL;
+}
+
+//------------------------------------------------------------------
+
+SCTAB ScDocShell::GetCurTab()
+{
+ //! this must be made non-static and use a ViewShell from this document!
+
+ ScViewData* pViewData = GetViewData();
+
+ return pViewData ? pViewData->GetTabNo() : static_cast<SCTAB>(0);
+}
+
+ScTabViewShell* ScDocShell::GetBestViewShell( BOOL bOnlyVisible )
+{
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ // falsches Doc?
+ if( pViewSh && pViewSh->GetViewData()->GetDocShell() != this )
+ pViewSh = NULL;
+ if( !pViewSh )
+ {
+ // 1. ViewShell suchen
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( this, bOnlyVisible );
+ if( pFrame )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ pViewSh = PTR_CAST(ScTabViewShell,p);
+ }
+ }
+ return pViewSh;
+}
+
+SfxBindings* ScDocShell::GetViewBindings()
+{
+ // used to invalidate slots after changes to this document
+
+ SfxViewShell* pViewSh = GetBestViewShell();
+ if (pViewSh)
+ return &pViewSh->GetViewFrame()->GetBindings();
+ else
+ return NULL;
+}
+
+//------------------------------------------------------------------
+
+ScDocShell* ScDocShell::GetShellByNum( USHORT nDocNo ) // static
+{
+ ScDocShell* pFound = NULL;
+ SfxObjectShell* pShell = SfxObjectShell::GetFirst();
+ USHORT nShellCnt = 0;
+
+ while ( pShell && !pFound )
+ {
+ if ( pShell->Type() == TYPE(ScDocShell) )
+ {
+ if ( nShellCnt == nDocNo )
+ pFound = (ScDocShell*) pShell;
+ else
+ ++nShellCnt;
+ }
+ pShell = SfxObjectShell::GetNext( *pShell );
+ }
+
+ return pFound;
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScDocShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ DBG_ASSERT( _pFileDlg, "ScDocShell::DialogClosedHdl(): no file dialog" );
+ DBG_ASSERT( pImpl->pDocInserter, "ScDocShell::DialogClosedHdl(): no document inserter" );
+
+ if ( ERRCODE_NONE == _pFileDlg->GetError() )
+ {
+ USHORT nSlot = pImpl->pRequest->GetSlot();
+ SfxMedium* pMed = pImpl->pDocInserter->CreateMedium();
+ // #i87094# If a .odt was selected pMed is NULL.
+ if (pMed)
+ {
+ pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, pMed->GetName() ) );
+ if ( SID_DOCUMENT_COMPARE == nSlot )
+ {
+ if ( pMed->GetFilter() )
+ pImpl->pRequest->AppendItem(
+ SfxStringItem( SID_FILTER_NAME, pMed->GetFilter()->GetFilterName() ) );
+ String sOptions = ScDocumentLoader::GetOptions( *pMed );
+ if ( sOptions.Len() > 0 )
+ pImpl->pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
+ }
+ const SfxPoolItem* pItem = NULL;
+ SfxItemSet* pSet = pMed->GetItemSet();
+ if ( pSet &&
+ pSet->GetItemState( SID_VERSION, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA( SfxInt16Item ) )
+ {
+ pImpl->pRequest->AppendItem( *pItem );
+ }
+
+ Execute( *(pImpl->pRequest) );
+ }
+ }
+
+ pImpl->bIgnoreLostRedliningWarning = false;
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+void ScDocShell::EnableSharedSettings( bool bEnable )
+{
+ SetDocumentModified();
+
+ if ( bEnable )
+ {
+ aDocument.EndChangeTracking();
+ aDocument.StartChangeTracking();
+
+ // hide accept or reject changes dialog
+ USHORT nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrame = SfxViewFrame::Current();
+ if ( pViewFrame && pViewFrame->HasChildWindow( nId ) )
+ {
+ pViewFrame->ToggleChildWindow( nId );
+ SfxBindings* pBindings = GetViewBindings();
+ if ( pBindings )
+ {
+ pBindings->Invalidate( FID_CHG_ACCEPT );
+ }
+ }
+ }
+ else
+ {
+ aDocument.EndChangeTracking();
+ }
+
+ ScChangeViewSettings aChangeViewSet;
+ aChangeViewSet.SetShowChanges( FALSE );
+ aDocument.SetChangeViewSettings( aChangeViewSet );
+}
+
+uno::Reference< frame::XModel > ScDocShell::LoadSharedDocument()
+{
+ uno::Reference< frame::XModel > xModel;
+ try
+ {
+ SC_MOD()->SetInSharedDocLoading( true );
+ uno::Reference< lang::XMultiServiceFactory > xFactory(
+ ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XComponentLoader > xLoader(
+ xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
+ uno::UNO_QUERY_THROW );
+ uno::Sequence < beans::PropertyValue > aArgs( 1 );
+ aArgs[0].Name = ::rtl::OUString::createFromAscii( "Hidden" );
+ aArgs[0].Value <<= sal_True;
+
+ if ( GetMedium() )
+ {
+ SFX_ITEMSET_ARG( GetMedium()->GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False);
+ if ( pPasswordItem && pPasswordItem->GetValue().Len() )
+ {
+ aArgs.realloc( 2 );
+ aArgs[1].Name = ::rtl::OUString::createFromAscii( "Password" );
+ aArgs[1].Value <<= ::rtl::OUString( pPasswordItem->GetValue() );
+ }
+ }
+
+ xModel.set(
+ xLoader->loadComponentFromURL( GetSharedFileURL(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0, aArgs ),
+ uno::UNO_QUERY_THROW );
+ SC_MOD()->SetInSharedDocLoading( false );
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR( "ScDocShell::LoadSharedDocument(): caught exception\n" );
+ SC_MOD()->SetInSharedDocLoading( false );
+ try
+ {
+ uno::Reference< util::XCloseable > xClose( xModel, uno::UNO_QUERY_THROW );
+ xClose->close( sal_True );
+ return uno::Reference< frame::XModel >();
+ }
+ catch ( uno::Exception& )
+ {
+ return uno::Reference< frame::XModel >();
+ }
+ }
+ return xModel;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
new file mode 100644
index 000000000000..676c201a3ed1
--- /dev/null
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -0,0 +1,1034 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+
+#include "scitems.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/smplhint.hxx>
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "docsh.hxx"
+#include "global.hxx"
+#include "globstr.hrc"
+#include "undodat.hxx"
+#include "undotab.hxx"
+#include "undoblk.hxx"
+#include "dpobject.hxx"
+#include "dpshttab.hxx"
+#include "dbdocfun.hxx"
+#include "consoli.hxx"
+#include "dbcolect.hxx"
+#include "olinetab.hxx"
+#include "patattr.hxx"
+#include "attrib.hxx"
+#include "docpool.hxx"
+#include "uiitems.hxx"
+#include "sc.hrc"
+#include "waitoff.hxx"
+#include "sizedev.hxx"
+#include <basic/sbstar.hxx>
+#include <basic/basmgr.hxx>
+
+// defined in docfunc.cxx
+void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, String& sModuleName, String& sModuleSource );
+
+// ---------------------------------------------------------------------------
+
+//
+// former viewfunc/dbfunc methods
+//
+
+void ScDocShell::ErrorMessage( USHORT nGlobStrId )
+{
+ //! StopMarking an der (aktiven) View?
+
+ Window* pParent = GetActiveDialogParent();
+ ScWaitCursorOff aWaitOff( pParent );
+ BOOL bFocus = pParent && pParent->HasFocus();
+
+ if(nGlobStrId==STR_PROTECTIONERR)
+ {
+ if(IsReadOnly())
+ {
+ nGlobStrId=STR_READONLYERR;
+ }
+ }
+
+ InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) );
+ aBox.Execute();
+ if (bFocus)
+ pParent->GrabFocus();
+}
+
+BOOL ScDocShell::IsEditable() const
+{
+ // import into read-only document is possible - must be extended if other filters use api
+ // #i108547# MSOOXML filter uses "IsChangeReadOnlyEnabled" property
+
+ return !IsReadOnly() || aDocument.IsImportingXML() || aDocument.IsChangeReadOnlyEnabled();
+}
+
+void ScDocShell::DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW /* nY2 */ )
+{
+ ScDocShellModificator aModificator( *this );
+ aDocument.RemoveFlagsTab( nX1, nY1, nX2, nY1, nTab, SC_MF_AUTO );
+ PostPaint( nX1, nY1, nTab, nX2, nY1, nTab, PAINT_GRID );
+ // No SetDocumentModified, as the unnamed database range might have to be restored later.
+ // The UNO hint is broadcast directly instead, to keep UNO objects in valid state.
+ aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
+}
+
+ScDBData* lcl_GetDBNearCursor( ScDBCollection* pColl, SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ //! nach document/dbcolect verschieben
+
+ if (!pColl)
+ return NULL;
+
+ ScDBData* pNoNameData = NULL;
+ ScDBData* pNearData = NULL;
+ USHORT nCount = pColl->GetCount();
+ String aNoName = ScGlobal::GetRscString( STR_DB_NONAME );
+ SCTAB nAreaTab;
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ ScDBData* pDB = (*pColl)[i];
+ pDB->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ if ( nTab == nAreaTab && nCol+1 >= nStartCol && nCol <= nEndCol+1 &&
+ nRow+1 >= nStartRow && nRow <= nEndRow+1 )
+ {
+ if ( pDB->GetName() == aNoName )
+ pNoNameData = pDB;
+ else if ( nCol < nStartCol || nCol > nEndCol || nRow < nStartRow || nRow > nEndRow )
+ {
+ if (!pNearData)
+ pNearData = pDB; // ersten angrenzenden Bereich merken
+ }
+ else
+ return pDB; // nicht "unbenannt" und Cursor steht wirklich drin
+ }
+ }
+ if (pNearData)
+ return pNearData; // angrenzender, wenn nichts direkt getroffen
+ return pNoNameData; // "unbenannt" nur zurueck, wenn sonst nichts gefunden
+}
+
+ScDBData* ScDocShell::GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel )
+{
+ SCCOL nCol = rMarked.aStart.Col();
+ SCROW nRow = rMarked.aStart.Row();
+ SCTAB nTab = rMarked.aStart.Tab();
+
+ SCCOL nStartCol = nCol;
+ SCROW nStartRow = nRow;
+ SCTAB nStartTab = nTab;
+ SCCOL nEndCol = rMarked.aEnd.Col();
+ SCROW nEndRow = rMarked.aEnd.Row();
+ SCTAB nEndTab = rMarked.aEnd.Tab();
+
+ // Wegen #49655# nicht einfach GetDBAtCursor: Der zusammenhaengende Datenbereich
+ // fuer "unbenannt" (GetDataArea) kann neben dem Cursor legen, also muss auch ein
+ // benannter DB-Bereich dort gesucht werden.
+
+ ScDBData* pData = aDocument.GetDBAtArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ if (!pData)
+ pData = lcl_GetDBNearCursor( aDocument.GetDBCollection(), nCol, nRow, nTab );
+
+ BOOL bSelected = ( eSel == SC_DBSEL_FORCE_MARK ||
+ (rMarked.aStart != rMarked.aEnd && eSel != SC_DBSEL_ROW_DOWN) );
+ bool bOnlyDown = (!bSelected && eSel == SC_DBSEL_ROW_DOWN && rMarked.aStart.Row() == rMarked.aEnd.Row());
+
+ BOOL bUseThis = FALSE;
+ if (pData)
+ {
+ // Bereich nehmen, wenn nichts anderes markiert
+
+ SCTAB nDummy;
+ SCCOL nOldCol1;
+ SCROW nOldRow1;
+ SCCOL nOldCol2;
+ SCROW nOldRow2;
+ pData->GetArea( nDummy, nOldCol1,nOldRow1, nOldCol2,nOldRow2 );
+ BOOL bIsNoName = ( pData->GetName() == ScGlobal::GetRscString( STR_DB_NONAME ) );
+
+ if (!bSelected)
+ {
+ bUseThis = TRUE;
+ if ( bIsNoName && eMode == SC_DB_MAKE )
+ {
+ // If nothing marked or only one row marked, adapt
+ // "unbenannt"/"unnamed" to contiguous area.
+ nStartCol = nCol;
+ nStartRow = nRow;
+ if (bOnlyDown)
+ {
+ nEndCol = rMarked.aEnd.Col();
+ nEndRow = rMarked.aEnd.Row();
+ }
+ else
+ {
+ nEndCol = nStartCol;
+ nEndRow = nStartRow;
+ }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, bOnlyDown );
+ if ( nOldCol1 != nStartCol || nOldCol2 != nEndCol || nOldRow1 != nStartRow )
+ bUseThis = FALSE; // passt gar nicht
+ else if ( nOldRow2 != nEndRow )
+ {
+ // Bereich auf neue End-Zeile erweitern
+ pData->SetArea( nTab, nOldCol1,nOldRow1, nOldCol2,nEndRow );
+ }
+ }
+ }
+ else
+ {
+ if ( nOldCol1 == nStartCol && nOldRow1 == nStartRow &&
+ nOldCol2 == nEndCol && nOldRow2 == nEndRow ) // genau markiert?
+ bUseThis = TRUE;
+ else
+ bUseThis = FALSE; // immer Markierung nehmen (Bug 11964)
+ }
+
+ // fuer Import nie "unbenannt" nehmen
+
+ if ( bUseThis && eMode == SC_DB_IMPORT && bIsNoName )
+ bUseThis = FALSE;
+ }
+
+ if ( bUseThis )
+ {
+ pData->GetArea( nStartTab, nStartCol,nStartRow, nEndCol,nEndRow );
+ nEndTab = nStartTab;
+ }
+ else if ( eMode == SC_DB_OLD )
+ {
+ pData = NULL; // nichts gefunden
+ nStartCol = nEndCol = nCol;
+ nStartRow = nEndRow = nRow;
+ nStartTab = nEndTab = nTab;
+// bMark = FALSE; // nichts zu markieren
+ }
+ else
+ {
+ if ( bSelected )
+ {
+// bMark = FALSE;
+ }
+ else
+ { // zusammenhaengender Bereich
+ nStartCol = nCol;
+ nStartRow = nRow;
+ if (bOnlyDown)
+ {
+ nEndCol = rMarked.aEnd.Col();
+ nEndRow = rMarked.aEnd.Row();
+ }
+ else
+ {
+ nEndCol = nStartCol;
+ nEndRow = nStartRow;
+ }
+ aDocument.GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, bOnlyDown );
+ }
+
+ BOOL bHasHeader = aDocument.HasColHeader( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
+
+ ScDBData* pNoNameData;
+ USHORT nNoNameIndex;
+ ScDBCollection* pColl = aDocument.GetDBCollection();
+ if ( eMode != SC_DB_IMPORT &&
+ pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) )
+ {
+ pNoNameData = (*pColl)[nNoNameIndex];
+
+ if ( !pOldAutoDBRange )
+ {
+ // store the old unnamed database range with its settings for undo
+ // (store at the first change, get the state before all changes)
+ pOldAutoDBRange = new ScDBData( *pNoNameData );
+ }
+
+ SCCOL nOldX1; // alten Bereich sauber wegnehmen
+ SCROW nOldY1; //! (UNDO ???)
+ SCCOL nOldX2;
+ SCROW nOldY2;
+ SCTAB nOldTab;
+ pNoNameData->GetArea( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
+ DBAreaDeleted( nOldTab, nOldX1, nOldY1, nOldX2, nOldY2 );
+
+ pNoNameData->SetSortParam( ScSortParam() ); // Parameter zuruecksetzen
+ pNoNameData->SetQueryParam( ScQueryParam() );
+ pNoNameData->SetSubTotalParam( ScSubTotalParam() );
+
+ pNoNameData->SetArea( nTab, nStartCol,nStartRow, nEndCol,nEndRow ); // neu setzen
+ pNoNameData->SetByRow( TRUE );
+ pNoNameData->SetHeader( bHasHeader );
+ pNoNameData->SetAutoFilter( FALSE );
+ }
+ else
+ {
+ ScDBCollection* pUndoColl = NULL;
+
+ String aNewName;
+ if (eMode==SC_DB_IMPORT)
+ {
+ aDocument.CompileDBFormula( TRUE ); // CreateFormulaString
+ pUndoColl = new ScDBCollection( *pColl ); // Undo fuer Import1-Bereich
+
+ String aImport = ScGlobal::GetRscString( STR_DBNAME_IMPORT );
+ long nCount = 0;
+ USHORT nDummy;
+ do
+ {
+ ++nCount;
+ aNewName = aImport;
+ aNewName += String::CreateFromInt32( nCount );
+ }
+ while (pColl->SearchName( aNewName, nDummy ));
+ }
+ else
+ aNewName = ScGlobal::GetRscString( STR_DB_NONAME );
+ pNoNameData = new ScDBData( aNewName, nTab,
+ nStartCol,nStartRow, nEndCol,nEndRow,
+ TRUE, bHasHeader );
+ pColl->Insert( pNoNameData );
+
+ if ( pUndoColl )
+ {
+ aDocument.CompileDBFormula( FALSE ); // CompileFormulaString
+
+ ScDBCollection* pRedoColl = new ScDBCollection( *pColl );
+ GetUndoManager()->AddUndoAction( new ScUndoDBData( this, pUndoColl, pRedoColl ) );
+ }
+
+ // neuen Bereich am Sba anmelden nicht mehr noetig
+
+ // "Import1" etc am Navigator bekanntmachen
+ if (eMode==SC_DB_IMPORT)
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ }
+ pData = pNoNameData;
+ }
+
+ return pData;
+}
+
+ScDBData* ScDocShell::GetOldAutoDBRange()
+{
+ ScDBData* pRet = pOldAutoDBRange;
+ pOldAutoDBRange = NULL;
+ return pRet; // has to be deleted by caller!
+}
+
+void ScDocShell::CancelAutoDBRange()
+{
+ // called when dialog is cancelled
+ if ( pOldAutoDBRange )
+ {
+ USHORT nNoNameIndex;
+ ScDBCollection* pColl = aDocument.GetDBCollection();
+ if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) )
+ {
+ ScDBData* pNoNameData = (*pColl)[nNoNameIndex];
+
+ SCCOL nRangeX1;
+ SCROW nRangeY1;
+ SCCOL nRangeX2;
+ SCROW nRangeY2;
+ SCTAB nRangeTab;
+ pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+ DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+
+ *pNoNameData = *pOldAutoDBRange; // restore old settings
+
+ if ( pOldAutoDBRange->HasAutoFilter() )
+ {
+ // restore AutoFilter buttons
+ pOldAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+ aDocument.ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
+ PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID );
+ }
+ }
+
+ delete pOldAutoDBRange;
+ pOldAutoDBRange = NULL;
+ }
+}
+
+
+ // Hoehen anpassen
+ //! mit docfunc zusammenfassen
+
+BOOL ScDocShell::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab )
+{
+ ScSizeDeviceProvider aProv(this);
+ Fraction aZoom(1,1);
+ BOOL bChange = aDocument.SetOptimalHeight( nStartRow,nEndRow, nTab, 0, aProv.GetDevice(),
+ aProv.GetPPTX(),aProv.GetPPTY(), aZoom,aZoom, FALSE );
+ if (bChange)
+ PostPaint( 0,nStartRow,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID|PAINT_LEFT );
+
+ return bChange;
+}
+
+void ScDocShell::UpdateAllRowHeights( const ScMarkData* pTabMark )
+{
+ // update automatic row heights
+
+ ScSizeDeviceProvider aProv(this);
+ Fraction aZoom(1,1);
+ aDocument.UpdateAllRowHeights( aProv.GetDevice(), aProv.GetPPTX(), aProv.GetPPTY(), aZoom, aZoom, pTabMark );
+}
+
+void ScDocShell::UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore )
+{
+ BOOL bIsUndoEnabled = aDocument.IsUndoEnabled();
+ aDocument.EnableUndo( FALSE );
+ aDocument.LockStreamValid( true ); // ignore draw page size (but not formula results)
+ if ( bBefore ) // check all sheets up to nUpdateTab
+ {
+ SCTAB nTabCount = aDocument.GetTableCount();
+ if ( nUpdateTab >= nTabCount )
+ nUpdateTab = nTabCount-1; // nUpdateTab is inclusive
+
+ ScMarkData aUpdateSheets;
+ SCTAB nTab;
+ for (nTab=0; nTab<=nUpdateTab; ++nTab)
+ if ( aDocument.IsPendingRowHeights( nTab ) )
+ aUpdateSheets.SelectTable( nTab, TRUE );
+
+ if (aUpdateSheets.GetSelectCount())
+ UpdateAllRowHeights(&aUpdateSheets); // update with a single progress bar
+
+ for (nTab=0; nTab<=nUpdateTab; ++nTab)
+ if ( aUpdateSheets.GetTableSelect( nTab ) )
+ {
+ aDocument.UpdatePageBreaks( nTab );
+ aDocument.SetPendingRowHeights( nTab, FALSE );
+ }
+ }
+ else // only nUpdateTab
+ {
+ if ( aDocument.IsPendingRowHeights( nUpdateTab ) )
+ {
+ AdjustRowHeight( 0, MAXROW, nUpdateTab );
+ aDocument.UpdatePageBreaks( nUpdateTab );
+ aDocument.SetPendingRowHeights( nUpdateTab, FALSE );
+ }
+ }
+ aDocument.LockStreamValid( false );
+ aDocument.EnableUndo( bIsUndoEnabled );
+}
+
+void ScDocShell::RefreshPivotTables( const ScRange& rSource )
+{
+ //! rename to RefreshDataPilotTables?
+
+ ScDPCollection* pColl = aDocument.GetDPCollection();
+ if ( pColl )
+ {
+ // DataPilotUpdate doesn't modify the collection order like PivotUpdate did,
+ // so a simple loop can be used.
+
+ USHORT nCount = pColl->GetCount();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ ScDPObject* pOld = (*pColl)[i];
+ if ( pOld )
+ {
+ const ScSheetSourceDesc* pSheetDesc = pOld->GetSheetDesc();
+ if ( pSheetDesc && pSheetDesc->aSourceRange.Intersects( rSource ) )
+ {
+ ScDPObject* pNew = new ScDPObject( *pOld );
+ ScDBDocFunc aFunc( *this );
+ aFunc.DataPilotUpdate( pOld, pNew, TRUE, FALSE );
+ delete pNew; // DataPilotUpdate copies settings from "new" object
+ }
+ }
+ }
+ }
+}
+
+String lcl_GetAreaName( ScDocument* pDoc, ScArea* pArea )
+{
+ String aName;
+ BOOL bOk = FALSE;
+ ScDBData* pData = pDoc->GetDBAtArea( pArea->nTab, pArea->nColStart, pArea->nRowStart,
+ pArea->nColEnd, pArea->nRowEnd );
+ if (pData)
+ {
+ pData->GetName( aName );
+ if ( aName != ScGlobal::GetRscString( STR_DB_NONAME ) )
+ bOk = TRUE;
+ }
+
+ if (!bOk)
+ pDoc->GetName( pArea->nTab, aName );
+
+ return aName;
+}
+
+void ScDocShell::DoConsolidate( const ScConsolidateParam& rParam, BOOL bRecord )
+{
+ ScConsData aData;
+
+ USHORT nPos;
+ SCCOL nColSize = 0;
+ SCROW nRowSize = 0;
+ BOOL bErr = FALSE;
+ for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
+ {
+ ScArea* pArea = rParam.ppDataAreas[nPos];
+ nColSize = Max( nColSize, SCCOL( pArea->nColEnd - pArea->nColStart + 1 ) );
+ nRowSize = Max( nRowSize, SCROW( pArea->nRowEnd - pArea->nRowStart + 1 ) );
+
+ // Test, ob Quelldaten verschoben wuerden
+ if (rParam.bReferenceData)
+ if (pArea->nTab == rParam.nTab && pArea->nRowEnd >= rParam.nRow)
+ bErr = TRUE;
+ }
+
+ if (bErr)
+ {
+ InfoBox aBox( GetActiveDialogParent(),
+ ScGlobal::GetRscString( STR_CONSOLIDATE_ERR1 ) );
+ aBox.Execute();
+ return;
+ }
+
+ // ausfuehren
+
+ WaitObject aWait( GetActiveDialogParent() );
+ ScDocShellModificator aModificator( *this );
+
+ ScRange aOldDest;
+ ScDBData* pDestData = aDocument.GetDBAtCursor( rParam.nCol, rParam.nRow, rParam.nTab, TRUE );
+ if (pDestData)
+ pDestData->GetArea(aOldDest);
+
+ aData.SetSize( nColSize, nRowSize );
+ aData.SetFlags( rParam.eFunction, rParam.bByCol, rParam.bByRow, rParam.bReferenceData );
+ if ( rParam.bByCol || rParam.bByRow )
+ for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
+ {
+ ScArea* pArea = rParam.ppDataAreas[nPos];
+ aData.AddFields( &aDocument, pArea->nTab, pArea->nColStart, pArea->nRowStart,
+ pArea->nColEnd, pArea->nRowEnd );
+ }
+ aData.DoneFields();
+ for (nPos=0; nPos<rParam.nDataAreaCount; nPos++)
+ {
+ ScArea* pArea = rParam.ppDataAreas[nPos];
+ aData.AddData( &aDocument, pArea->nTab, pArea->nColStart, pArea->nRowStart,
+ pArea->nColEnd, pArea->nRowEnd );
+ aData.AddName( lcl_GetAreaName(&aDocument,pArea) );
+ }
+
+ aData.GetSize( nColSize, nRowSize );
+ if (bRecord && nColSize > 0 && nRowSize > 0)
+ {
+ ScDBData* pUndoData = pDestData ? new ScDBData(*pDestData) : NULL;
+
+ SCTAB nDestTab = rParam.nTab;
+ ScArea aDestArea( rParam.nTab, rParam.nCol, rParam.nRow,
+ rParam.nCol+nColSize-1, rParam.nRow+nRowSize-1 );
+ if (rParam.bByCol) ++aDestArea.nColEnd;
+ if (rParam.bByRow) ++aDestArea.nRowEnd;
+
+ if (rParam.bReferenceData)
+ {
+ SCTAB nTabCount = aDocument.GetTableCount();
+ SCROW nInsertCount = aData.GetInsertCount();
+
+ // alte Outlines
+ ScOutlineTable* pTable = aDocument.GetOutlineTable( nDestTab );
+ ScOutlineTable* pUndoTab = pTable ? new ScOutlineTable( *pTable ) : NULL;
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( &aDocument, 0, nTabCount-1, FALSE, TRUE );
+
+ // Zeilenstatus
+ aDocument.CopyToDocument( 0,0,nDestTab, MAXCOL,MAXROW,nDestTab,
+ IDF_NONE, FALSE, pUndoDoc );
+
+ // alle Formeln
+ aDocument.CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
+ IDF_FORMULA, FALSE, pUndoDoc );
+
+ // komplette Ausgangszeilen
+ aDocument.CopyToDocument( 0,aDestArea.nRowStart,nDestTab,
+ MAXCOL,aDestArea.nRowEnd,nDestTab,
+ IDF_ALL, FALSE, pUndoDoc );
+
+ // alten Ausgabebereich
+ if (pDestData)
+ aDocument.CopyToDocument( aOldDest, IDF_ALL, FALSE, pUndoDoc );
+
+ GetUndoManager()->AddUndoAction(
+ new ScUndoConsolidate( this, aDestArea, rParam, pUndoDoc,
+ TRUE, nInsertCount, pUndoTab, pUndoData ) );
+ }
+ else
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( &aDocument, aDestArea.nTab, aDestArea.nTab );
+
+ aDocument.CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, aDestArea.nTab,
+ aDestArea.nColEnd, aDestArea.nRowEnd, aDestArea.nTab,
+ IDF_ALL, FALSE, pUndoDoc );
+
+ // alten Ausgabebereich
+ if (pDestData)
+ aDocument.CopyToDocument( aOldDest, IDF_ALL, FALSE, pUndoDoc );
+
+ GetUndoManager()->AddUndoAction(
+ new ScUndoConsolidate( this, aDestArea, rParam, pUndoDoc,
+ FALSE, 0, NULL, pUndoData ) );
+ }
+ }
+
+ if (pDestData) // Zielbereich loeschen / anpassen
+ {
+ aDocument.DeleteAreaTab(aOldDest, IDF_CONTENTS);
+ pDestData->SetArea( rParam.nTab, rParam.nCol, rParam.nRow,
+ rParam.nCol + nColSize - 1, rParam.nRow + nRowSize - 1 );
+ pDestData->SetHeader( rParam.bByRow );
+ }
+
+ aData.OutputToDocument( &aDocument, rParam.nCol, rParam.nRow, rParam.nTab );
+
+ SCCOL nPaintStartCol = rParam.nCol;
+ SCROW nPaintStartRow = rParam.nRow;
+ SCCOL nPaintEndCol = nPaintStartCol + nColSize - 1;
+ SCROW nPaintEndRow = nPaintStartRow + nRowSize - 1;
+ USHORT nPaintFlags = PAINT_GRID;
+ if (rParam.bByCol)
+ ++nPaintEndRow;
+ if (rParam.bByRow)
+ ++nPaintEndCol;
+ if (rParam.bReferenceData)
+ {
+ nPaintStartCol = 0;
+ nPaintEndCol = MAXCOL;
+ nPaintEndRow = MAXROW;
+ nPaintFlags |= PAINT_LEFT | PAINT_SIZE;
+ }
+ if (pDestData)
+ {
+ if ( aOldDest.aEnd.Col() > nPaintEndCol )
+ nPaintEndCol = aOldDest.aEnd.Col();
+ if ( aOldDest.aEnd.Row() > nPaintEndRow )
+ nPaintEndRow = aOldDest.aEnd.Row();
+ }
+ PostPaint( nPaintStartCol, nPaintStartRow, rParam.nTab,
+ nPaintEndCol, nPaintEndRow, rParam.nTab, nPaintFlags );
+ aModificator.SetDocumentModified();
+}
+
+void ScDocShell::UseScenario( SCTAB nTab, const String& rName, BOOL bRecord )
+{
+ if (!aDocument.IsScenario(nTab))
+ {
+ SCTAB nTabCount = aDocument.GetTableCount();
+ SCTAB nSrcTab = SCTAB_MAX;
+ SCTAB nEndTab = nTab;
+ String aCompare;
+ while ( nEndTab+1 < nTabCount && aDocument.IsScenario(nEndTab+1) )
+ {
+ ++nEndTab;
+ if (nSrcTab > MAXTAB) // noch auf der Suche nach dem Szenario?
+ {
+ aDocument.GetName( nEndTab, aCompare );
+ if (aCompare == rName)
+ nSrcTab = nEndTab; // gefunden
+ }
+ }
+ if (ValidTab(nSrcTab))
+ {
+ if ( aDocument.TestCopyScenario( nSrcTab, nTab ) ) // Zellschutz testen
+ {
+ ScDocShellModificator aModificator( *this );
+ ScMarkData aScenMark;
+ aDocument.MarkScenario( nSrcTab, nTab, aScenMark );
+ ScRange aMultiRange;
+ aScenMark.GetMultiMarkArea( aMultiRange );
+ SCCOL nStartCol = aMultiRange.aStart.Col();
+ SCROW nStartRow = aMultiRange.aStart.Row();
+ SCCOL nEndCol = aMultiRange.aEnd.Col();
+ SCROW nEndRow = aMultiRange.aEnd.Row();
+
+ if (bRecord)
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( &aDocument, nTab,nEndTab ); // auch alle Szenarien
+ // angezeigte Tabelle:
+ aDocument.CopyToDocument( nStartCol,nStartRow,nTab,
+ nEndCol,nEndRow,nTab, IDF_ALL,TRUE, pUndoDoc, &aScenMark );
+ // Szenarien
+ for (SCTAB i=nTab+1; i<=nEndTab; i++)
+ {
+ pUndoDoc->SetScenario( i, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ aDocument.GetScenarioData( i, aComment, aColor, nScenFlags );
+ pUndoDoc->SetScenarioData( i, aComment, aColor, nScenFlags );
+ BOOL bActive = aDocument.IsActiveScenario( i );
+ pUndoDoc->SetActiveScenario( i, bActive );
+ // Bei Zurueckkopier-Szenarios auch Inhalte
+ if ( nScenFlags & SC_SCENARIO_TWOWAY )
+ aDocument.CopyToDocument( 0,0,i, MAXCOL,MAXROW,i,
+ IDF_ALL,FALSE, pUndoDoc );
+ }
+
+ GetUndoManager()->AddUndoAction(
+ new ScUndoUseScenario( this, aScenMark,
+ ScArea( nTab,nStartCol,nStartRow,nEndCol,nEndRow ),
+ pUndoDoc, rName ) );
+ }
+
+ aDocument.CopyScenario( nSrcTab, nTab );
+ aDocument.SetDirty();
+
+ // alles painten, weil in anderen Bereichen das aktive Szenario
+ // geaendert sein kann
+ //! nur, wenn sichtbare Rahmen vorhanden?
+ PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+ aModificator.SetDocumentModified();
+ }
+ else
+ {
+ InfoBox aBox(GetActiveDialogParent(),
+ ScGlobal::GetRscString( STR_PROTECTIONERR ) );
+ aBox.Execute();
+ }
+ }
+ else
+ {
+ InfoBox aBox(GetActiveDialogParent(),
+ ScGlobal::GetRscString( STR_SCENARIO_NOTFOUND ) );
+ aBox.Execute();
+ }
+ }
+ else
+ {
+ DBG_ERROR( "UseScenario auf Szenario-Blatt" );
+ }
+}
+
+void ScDocShell::ModifyScenario( SCTAB nTab, const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags )
+{
+ // Undo
+ String aOldName;
+ aDocument.GetName( nTab, aOldName );
+ String aOldComment;
+ Color aOldColor;
+ USHORT nOldFlags;
+ aDocument.GetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
+ GetUndoManager()->AddUndoAction(
+ new ScUndoScenarioFlags( this, nTab,
+ aOldName, rName, aOldComment, rComment,
+ aOldColor, rColor, nOldFlags, nFlags ) );
+
+ // ausfuehren
+ ScDocShellModificator aModificator( *this );
+ aDocument.RenameTab( nTab, rName );
+ aDocument.SetScenarioData( nTab, rComment, rColor, nFlags );
+ PostPaintGridAll();
+ aModificator.SetDocumentModified();
+
+ if ( rName != aOldName )
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+
+ SfxBindings* pBindings = GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_SELECT_SCENARIO );
+}
+
+SCTAB ScDocShell::MakeScenario( SCTAB nTab, const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags,
+ ScMarkData& rMark, BOOL bRecord )
+{
+ rMark.MarkToMulti();
+ if (rMark.IsMultiMarked())
+ {
+ SCTAB nNewTab = nTab + 1;
+ while (aDocument.IsScenario(nNewTab))
+ ++nNewTab;
+
+ BOOL bCopyAll = ( (nFlags & SC_SCENARIO_COPYALL) != 0 );
+ const ScMarkData* pCopyMark = NULL;
+ if (!bCopyAll)
+ pCopyMark = &rMark;
+
+ ScDocShellModificator aModificator( *this );
+
+ if (bRecord)
+ aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions
+
+ if (aDocument.CopyTab( nTab, nNewTab, pCopyMark ))
+ {
+ if (bRecord)
+ {
+ GetUndoManager()->AddUndoAction(
+ new ScUndoMakeScenario( this, nTab, nNewTab,
+ rName, rComment, rColor, nFlags, rMark ));
+ }
+
+ aDocument.RenameTab( nNewTab, rName, FALSE ); // ohne Formel-Update
+ aDocument.SetScenario( nNewTab, TRUE );
+ aDocument.SetScenarioData( nNewTab, rComment, rColor, nFlags );
+
+ ScMarkData aDestMark = rMark;
+ aDestMark.SelectOneTable( nNewTab );
+
+ //! auf Filter / Buttons / Merging testen !
+
+ ScPatternAttr aProtPattern( aDocument.GetPool() );
+ aProtPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) );
+ aDocument.ApplyPatternAreaTab( 0,0, MAXCOL,MAXROW, nNewTab, aProtPattern );
+
+ ScPatternAttr aPattern( aDocument.GetPool() );
+ aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
+ aPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) );
+ aDocument.ApplySelectionPattern( aPattern, aDestMark );
+
+ if (!bCopyAll)
+ aDocument.SetVisible( nNewTab, FALSE );
+
+ // dies ist dann das aktive Szenario
+ aDocument.CopyScenario( nNewTab, nTab, TRUE ); // TRUE - nicht aus Szenario kopieren
+
+ if (nFlags & SC_SCENARIO_SHOWFRAME)
+ PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID ); // Rahmen painten
+ PostPaintExtras(); // Tabellenreiter
+ aModificator.SetDocumentModified();
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+
+ return nNewTab;
+ }
+ }
+ return nTab;
+}
+
+ULONG ScDocShell::TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
+ SCTAB nDestPos, BOOL bInsertNew,
+ BOOL bNotifyAndPaint )
+{
+ ScDocument* pSrcDoc = rSrcDocShell.GetDocument();
+
+ ULONG nErrVal = aDocument.TransferTab( pSrcDoc, nSrcPos, nDestPos,
+ bInsertNew ); // no insert
+
+ // TransferTab doesn't copy drawing objects with bInsertNew=FALSE
+ if ( nErrVal > 0 && !bInsertNew)
+ aDocument.TransferDrawPage( pSrcDoc, nSrcPos, nDestPos );
+
+ if(nErrVal>0 && pSrcDoc->IsScenario( nSrcPos ))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+
+ pSrcDoc->GetScenarioData( nSrcPos, aComment,aColor, nFlags);
+ aDocument.SetScenario(nDestPos,TRUE);
+ aDocument.SetScenarioData(nDestPos,aComment,aColor,nFlags);
+ BOOL bActive = pSrcDoc->IsActiveScenario(nSrcPos);
+ aDocument.SetActiveScenario(nDestPos, bActive );
+
+ BOOL bVisible=pSrcDoc->IsVisible(nSrcPos);
+ aDocument.SetVisible(nDestPos,bVisible );
+
+ }
+
+ if ( nErrVal > 0 && pSrcDoc->IsTabProtected( nSrcPos ) )
+ aDocument.SetTabProtection(nDestPos, pSrcDoc->GetTabProtection(nSrcPos));
+ if ( bNotifyAndPaint )
+ {
+ Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestPos ) );
+ PostPaintExtras();
+ PostPaintGridAll();
+ }
+ return nErrVal;
+}
+
+BOOL ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRecord )
+{
+ ScDocShellModificator aModificator( *this );
+
+ // #i92477# be consistent with ScDocFunc::InsertTable: any index past the last sheet means "append"
+ // #i101139# nDestTab must be the target position, not APPEND (for CopyTabProtection etc.)
+ if ( nDestTab >= aDocument.GetTableCount() )
+ nDestTab = aDocument.GetTableCount();
+
+ if (bCopy)
+ {
+ if (bRecord)
+ aDocument.BeginDrawUndo(); // drawing layer must do its own undo actions
+
+ String sSrcCodeName;
+ aDocument.GetCodeName( nSrcTab, sSrcCodeName );
+ if (!aDocument.CopyTab( nSrcTab, nDestTab ))
+ {
+ //! EndDrawUndo?
+ return FALSE;
+ }
+ else
+ {
+ SCTAB nAdjSource = nSrcTab;
+ if ( nDestTab <= nSrcTab )
+ ++nAdjSource; // new position of source table after CopyTab
+
+ if ( aDocument.IsTabProtected( nAdjSource ) )
+ aDocument.CopyTabProtection(nAdjSource, nDestTab);
+
+ if (bRecord)
+ {
+ SvShorts aSrcList;
+ SvShorts aDestList;
+ aSrcList.Insert(nSrcTab,0);
+ aDestList.Insert(nDestTab,0);
+ GetUndoManager()->AddUndoAction(
+ new ScUndoCopyTab( this, aSrcList, aDestList ) );
+ }
+
+ BOOL bVbaEnabled = aDocument.IsInVBAMode();
+ if ( bVbaEnabled )
+ {
+ StarBASIC* pStarBASIC = GetBasic();
+ String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ if ( GetBasicManager()->GetName().Len() > 0 )
+ {
+ aLibName = GetBasicManager()->GetName();
+ pStarBASIC = GetBasicManager()->GetLib( aLibName );
+ }
+ SCTAB nTabToUse = nDestTab;
+ if ( nDestTab == SC_TAB_APPEND )
+ nTabToUse = aDocument.GetMaxTableNumber() - 1;
+ String sCodeName;
+ String sSource;
+ com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = GetBasicContainer();
+ com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib;
+ if( xLibContainer.is() )
+ {
+ com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName );
+ aLibAny >>= xLib;
+ }
+ if( xLib.is() )
+ {
+ rtl::OUString sRTLSource;
+ xLib->getByName( sSrcCodeName ) >>= sRTLSource;
+ sSource = sRTLSource;
+ }
+ VBA_InsertModule( aDocument, nTabToUse, sCodeName, sSource );
+ }
+ }
+ Broadcast( ScTablesHint( SC_TAB_COPIED, nSrcTab, nDestTab ) );
+ }
+ else
+ {
+ if ( aDocument.GetChangeTrack() )
+ return FALSE;
+
+ if ( nSrcTab<nDestTab && nDestTab!=SC_TAB_APPEND )
+ nDestTab--;
+
+ if ( nSrcTab == nDestTab )
+ {
+ //! allow only for api calls?
+ return TRUE; // nothing to do, but valid
+ }
+
+ if (!aDocument.MoveTab( nSrcTab, nDestTab ))
+ return FALSE;
+ else if (bRecord)
+ {
+ SvShorts aSrcList;
+ SvShorts aDestList;
+ aSrcList.Insert(nSrcTab,0);
+ aDestList.Insert(nDestTab,0);
+ GetUndoManager()->AddUndoAction(
+ new ScUndoMoveTab( this, aSrcList, aDestList ) );
+ }
+
+ Broadcast( ScTablesHint( SC_TAB_MOVED, nSrcTab, nDestTab ) );
+ }
+
+ PostPaintGridAll();
+ PostPaintExtras();
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+
+ return TRUE;
+}
+
+
+IMPL_LINK( ScDocShell, RefreshDBDataHdl, ScRefreshTimer*, pRefreshTimer )
+{
+ ScDBDocFunc aFunc(*this);
+
+ BOOL bContinue = TRUE;
+ ScDBData* pDBData = static_cast<ScDBData*>(pRefreshTimer);
+ ScImportParam aImportParam;
+ pDBData->GetImportParam( aImportParam );
+ if (aImportParam.bImport && !pDBData->HasImportSelection())
+ {
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> xResultSet;
+ bContinue = aFunc.DoImport( aRange.aStart.Tab(), aImportParam, xResultSet, NULL, TRUE, FALSE ); //! Api-Flag as parameter
+ // internal operations (sort, query, subtotal) only if no error
+ if (bContinue)
+ {
+ aFunc.RepeatDB( pDBData->GetName(), TRUE, TRUE );
+ RefreshPivotTables(aRange);
+ }
+ }
+
+ return bContinue != 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
new file mode 100644
index 000000000000..e40b2b2d3108
--- /dev/null
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -0,0 +1,542 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+#ifndef PCH
+#include "scitems.hxx"
+
+#include <svx/pageitem.hxx>
+#include <vcl/virdev.hxx>
+#include <sfx2/linkmgr.hxx>
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "docsh.hxx"
+
+#include "stlsheet.hxx"
+#include "stlpool.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "tablink.hxx"
+#include "collect.hxx"
+#include "docoptio.hxx"
+#include "globstr.hrc"
+#include "scmod.hxx"
+
+#include "formula/FormulaCompiler.hxx"
+#include "comphelper/processfactory.hxx"
+#include "vcl/msgbox.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::util::XChangesBatch;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::rtl::OUString;
+
+namespace {
+
+struct ScStylePair
+{
+ SfxStyleSheetBase *pSource;
+ SfxStyleSheetBase *pDest;
+};
+
+inline OUString C2U(const char* s)
+{
+ return OUString::createFromAscii(s);
+}
+
+}
+
+// STATIC DATA -----------------------------------------------------------
+
+//----------------------------------------------------------------------
+
+//
+// Ole
+//
+
+void __EXPORT ScDocShell::SetVisArea( const Rectangle & rVisArea )
+{
+ // with the SnapVisArea call in SetVisAreaOrSize, it's safe to always
+ // use both the size and position of the VisArea
+ SetVisAreaOrSize( rVisArea, TRUE );
+}
+
+void lcl_SetTopRight( Rectangle& rRect, const Point& rPos )
+{
+ Size aSize = rRect.GetSize();
+ rRect.Right() = rPos.X();
+ rRect.Left() = rPos.X() - aSize.Width() + 1;
+ rRect.Top() = rPos.Y();
+ rRect.Bottom() = rPos.Y() + aSize.Height() - 1;
+}
+
+void ScDocShell::SetVisAreaOrSize( const Rectangle& rVisArea, BOOL bModifyStart )
+{
+ BOOL bNegativePage = aDocument.IsNegativePage( aDocument.GetVisibleTab() );
+
+ Rectangle aArea = rVisArea;
+ if (bModifyStart)
+ {
+ // when loading, don't check for negative values, because the sheet orientation
+ // might be set later
+ if ( !aDocument.IsImportingXML() )
+ {
+ if ( ( bNegativePage ? (aArea.Right() > 0) : (aArea.Left() < 0) ) || aArea.Top() < 0 )
+ {
+ // VisArea start position can't be negative.
+ // Move the VisArea, otherwise only the upper left position would
+ // be changed in SnapVisArea, and the size would be wrong.
+
+ Point aNewPos( 0, Max( aArea.Top(), (long) 0 ) );
+ if ( bNegativePage )
+ {
+ aNewPos.X() = Min( aArea.Right(), (long) 0 );
+ lcl_SetTopRight( aArea, aNewPos );
+ }
+ else
+ {
+ aNewPos.X() = Max( aArea.Left(), (long) 0 );
+ aArea.SetPos( aNewPos );
+ }
+ }
+ }
+ }
+ else
+ {
+ Rectangle aOldVisArea = SfxObjectShell::GetVisArea();
+ if ( bNegativePage )
+ lcl_SetTopRight( aArea, aOldVisArea.TopRight() );
+ else
+ aArea.SetPos( aOldVisArea.TopLeft() );
+ }
+
+ // hier Position anpassen!
+
+ // #92248# when loading an ole object, the VisArea is set from the document's
+ // view settings and must be used as-is (document content may not be complete yet).
+ if ( !aDocument.IsImportingXML() )
+ aDocument.SnapVisArea( aArea );
+
+ //TODO/LATER: it's unclear which IPEnv is used here
+ /*
+ SvInPlaceEnvironment* pEnv = GetIPEnv();
+ if (pEnv)
+ {
+ Window* pWin = pEnv->GetEditWin();
+ pEnv->MakeScale( aArea.GetSize(), MAP_100TH_MM,
+ pWin->LogicToPixel( aArea.GetSize() ) );
+ } */
+
+ //TODO/LATER: formerly in SvInplaceObject
+ SfxObjectShell::SetVisArea( aArea );
+
+ if (bIsInplace) // Zoom in der InPlace View einstellen
+ {
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if (pViewSh)
+ {
+ if (pViewSh->GetViewData()->GetDocShell() == this)
+ pViewSh->UpdateOleZoom();
+ }
+ }
+
+ if (aDocument.IsEmbedded())
+ {
+ ScRange aOld;
+ aDocument.GetEmbedded( aOld);
+ aDocument.SetEmbedded( aArea );
+ ScRange aNew;
+ aDocument.GetEmbedded( aNew);
+ if (aOld != aNew)
+ PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB,PAINT_GRID);
+
+ //TODO/LATER: currently not implemented
+ //ViewChanged( ASPECT_CONTENT ); // auch im Container anzeigen
+ }
+}
+
+BOOL ScDocShell::IsOle()
+{
+ return (GetCreateMode() == SFX_CREATE_MODE_EMBEDDED);
+}
+
+void ScDocShell::UpdateOle( const ScViewData* pViewData, BOOL bSnapSize )
+{
+ // wenn's gar nicht Ole ist, kann man sich die Berechnungen sparen
+ // (VisArea wird dann beim Save wieder zurueckgesetzt)
+
+ if (GetCreateMode() == SFX_CREATE_MODE_STANDARD)
+ return;
+
+ DBG_ASSERT(pViewData,"pViewData==0 bei ScDocShell::UpdateOle");
+
+ Rectangle aOldArea = SfxObjectShell::GetVisArea();
+ Rectangle aNewArea = aOldArea;
+
+ BOOL bChange = FALSE;
+ BOOL bEmbedded = aDocument.IsEmbedded();
+ if (bEmbedded)
+ aNewArea = aDocument.GetEmbeddedRect();
+ else
+ {
+ SCTAB nTab = pViewData->GetTabNo();
+ if ( nTab != aDocument.GetVisibleTab() )
+ {
+ aDocument.SetVisibleTab( nTab );
+ bChange = TRUE;
+ }
+
+ BOOL bNegativePage = aDocument.IsNegativePage( nTab );
+ SCCOL nX = pViewData->GetPosX(SC_SPLIT_LEFT);
+ SCROW nY = pViewData->GetPosY(SC_SPLIT_BOTTOM);
+ Rectangle aMMRect = aDocument.GetMMRect( nX,nY, nX,nY, nTab );
+ if (bNegativePage)
+ lcl_SetTopRight( aNewArea, aMMRect.TopRight() );
+ else
+ aNewArea.SetPos( aMMRect.TopLeft() );
+ if (bSnapSize)
+ aDocument.SnapVisArea(aNewArea); // uses the new VisibleTab
+ }
+
+ if (aNewArea != aOldArea)
+ {
+ SetVisAreaOrSize( aNewArea, TRUE ); // hier muss auch der Start angepasst werden
+ bChange = TRUE;
+ }
+}
+
+//
+// Style-Krempel fuer Organizer etc.
+//
+
+SfxStyleSheetBasePool* __EXPORT ScDocShell::GetStyleSheetPool()
+{
+ return (SfxStyleSheetBasePool*)aDocument.GetStyleSheetPool();
+}
+
+
+// nach dem Laden von Vorlagen aus einem anderen Dokment (LoadStyles, Insert)
+// muessen die SetItems (ATTR_PAGE_HEADERSET, ATTR_PAGE_FOOTERSET) auf den richtigen
+// Pool umgesetzt werden, bevor der Quell-Pool geloescht wird.
+
+void lcl_AdjustPool( SfxStyleSheetBasePool* pStylePool )
+{
+ pStylePool->SetSearchMask(SFX_STYLE_FAMILY_PAGE, 0xffff);
+ SfxStyleSheetBase *pStyle = pStylePool->First();
+ while ( pStyle )
+ {
+ SfxItemSet& rStyleSet = pStyle->GetItemSet();
+
+ const SfxPoolItem* pItem;
+ if (rStyleSet.GetItemState(ATTR_PAGE_HEADERSET,FALSE,&pItem) == SFX_ITEM_SET)
+ {
+ SfxItemSet& rSrcSet = ((SvxSetItem*)pItem)->GetItemSet();
+ SfxItemSet* pDestSet = new SfxItemSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
+ pDestSet->Put(rSrcSet);
+ rStyleSet.Put(SvxSetItem(ATTR_PAGE_HEADERSET,pDestSet));
+ }
+ if (rStyleSet.GetItemState(ATTR_PAGE_FOOTERSET,FALSE,&pItem) == SFX_ITEM_SET)
+ {
+ SfxItemSet& rSrcSet = ((SvxSetItem*)pItem)->GetItemSet();
+ SfxItemSet* pDestSet = new SfxItemSet(*rStyleSet.GetPool(),rSrcSet.GetRanges());
+ pDestSet->Put(rSrcSet);
+ rStyleSet.Put(SvxSetItem(ATTR_PAGE_FOOTERSET,pDestSet));
+ }
+
+ pStyle = pStylePool->Next();
+ }
+}
+
+void __EXPORT ScDocShell::LoadStyles( SfxObjectShell &rSource )
+{
+ aDocument.StylesToNames();
+
+ SfxObjectShell::LoadStyles(rSource);
+ lcl_AdjustPool( GetStyleSheetPool() ); // SetItems anpassen
+
+ aDocument.UpdStlShtPtrsFrmNms();
+
+ UpdateAllRowHeights();
+
+ // Paint
+
+ PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID | PAINT_LEFT );
+}
+
+void ScDocShell::LoadStylesArgs( ScDocShell& rSource, BOOL bReplace, BOOL bCellStyles, BOOL bPageStyles )
+{
+ // similar to LoadStyles, but with selectable behavior for XStyleLoader::loadStylesFromURL call
+
+ if ( !bCellStyles && !bPageStyles ) // nothing to do
+ return;
+
+ ScStyleSheetPool* pSourcePool = rSource.GetDocument()->GetStyleSheetPool();
+ ScStyleSheetPool* pDestPool = aDocument.GetStyleSheetPool();
+
+ SfxStyleFamily eFamily = bCellStyles ?
+ ( bPageStyles ? SFX_STYLE_FAMILY_ALL : SFX_STYLE_FAMILY_PARA ) :
+ SFX_STYLE_FAMILY_PAGE;
+ SfxStyleSheetIterator aIter( pSourcePool, eFamily );
+ USHORT nSourceCount = aIter.Count();
+ if ( nSourceCount == 0 )
+ return; // no source styles
+
+ ScStylePair* pStyles = new ScStylePair[ nSourceCount ];
+ USHORT nFound = 0;
+
+ // first create all new styles
+
+ SfxStyleSheetBase* pSourceStyle = aIter.First();
+ while (pSourceStyle)
+ {
+ String aName = pSourceStyle->GetName();
+ SfxStyleSheetBase* pDestStyle = pDestPool->Find( pSourceStyle->GetName(), pSourceStyle->GetFamily() );
+ if ( pDestStyle )
+ {
+ // touch existing styles only if replace flag is set
+ if ( bReplace )
+ {
+ pStyles[nFound].pSource = pSourceStyle;
+ pStyles[nFound].pDest = pDestStyle;
+ ++nFound;
+ }
+ }
+ else
+ {
+ pStyles[nFound].pSource = pSourceStyle;
+ pStyles[nFound].pDest = &pDestPool->Make( aName, pSourceStyle->GetFamily(), pSourceStyle->GetMask() );
+ ++nFound;
+ }
+
+ pSourceStyle = aIter.Next();
+ }
+
+ // then copy contents (after inserting all styles, for parent etc.)
+
+ for ( USHORT i = 0; i < nFound; ++i )
+ {
+ pStyles[i].pDest->GetItemSet().PutExtended(
+ pStyles[i].pSource->GetItemSet(), SFX_ITEM_DONTCARE, SFX_ITEM_DEFAULT);
+ if(pStyles[i].pSource->HasParentSupport())
+ pStyles[i].pDest->SetParent(pStyles[i].pSource->GetParent());
+ // follow is never used
+ }
+
+ lcl_AdjustPool( GetStyleSheetPool() ); // adjust SetItems
+ UpdateAllRowHeights();
+ PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID | PAINT_LEFT ); // Paint
+
+ delete[] pStyles;
+}
+
+
+BOOL __EXPORT ScDocShell::Insert( SfxObjectShell &rSource,
+ USHORT nSourceIdx1, USHORT nSourceIdx2, USHORT nSourceIdx3,
+ USHORT &nIdx1, USHORT &nIdx2, USHORT &nIdx3, USHORT &rIdxDeleted )
+{
+ BOOL bRet = SfxObjectShell::Insert( rSource, nSourceIdx1, nSourceIdx2, nSourceIdx3,
+ nIdx1, nIdx2, nIdx3, rIdxDeleted );
+ if (bRet)
+ lcl_AdjustPool( GetStyleSheetPool() ); // SetItems anpassen
+
+ return bRet;
+}
+
+void ScDocShell::ReconnectDdeLink(SfxObjectShell& rServer)
+{
+ ::sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
+ if (!pLinkManager)
+ return;
+
+ pLinkManager->ReconnectDdeLink(rServer);
+}
+
+void ScDocShell::UpdateLinks()
+{
+ sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
+ ScStrCollection aNames;
+
+ // nicht mehr benutzte Links raus
+
+ USHORT nCount = pLinkManager->GetLinks().Count();
+ for (USHORT k=nCount; k>0; )
+ {
+ --k;
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[k];
+ if (pBase->ISA(ScTableLink))
+ {
+ ScTableLink* pTabLink = (ScTableLink*)pBase;
+ if (pTabLink->IsUsed())
+ {
+ StrData* pData = new StrData(pTabLink->GetFileName());
+ if (!aNames.Insert(pData))
+ delete pData;
+ }
+ else // nicht mehr benutzt -> loeschen
+ {
+ pTabLink->SetAddUndo(TRUE);
+ pLinkManager->Remove(k);
+ }
+ }
+ }
+
+
+ // neue Links eintragen
+
+ SCTAB nTabCount = aDocument.GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (aDocument.IsLinked(i))
+ {
+ String aDocName = aDocument.GetLinkDoc(i);
+ String aFltName = aDocument.GetLinkFlt(i);
+ String aOptions = aDocument.GetLinkOpt(i);
+ ULONG nRefresh = aDocument.GetLinkRefreshDelay(i);
+ BOOL bThere = FALSE;
+ for (SCTAB j=0; j<i && !bThere; j++) // im Dokument mehrfach?
+ if (aDocument.IsLinked(j)
+ && aDocument.GetLinkDoc(j) == aDocName
+ && aDocument.GetLinkFlt(j) == aFltName
+ && aDocument.GetLinkOpt(j) == aOptions)
+ // Ignore refresh delay in compare, it should be the
+ // same for identical links and we don't want dupes
+ // if it ain't.
+ bThere = TRUE;
+
+ if (!bThere) // schon als Filter eingetragen?
+ {
+ StrData* pData = new StrData(aDocName);
+ if (!aNames.Insert(pData))
+ {
+ delete pData;
+ bThere = TRUE;
+ }
+ }
+ if (!bThere)
+ {
+ ScTableLink* pLink = new ScTableLink( this, aDocName, aFltName, aOptions, nRefresh );
+ pLink->SetInCreate( TRUE );
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName );
+ pLink->Update();
+ pLink->SetInCreate( FALSE );
+ }
+ }
+}
+
+BOOL ScDocShell::ReloadTabLinks()
+{
+ sfx2::LinkManager* pLinkManager = aDocument.GetLinkManager();
+
+ BOOL bAny = FALSE;
+ USHORT nCount = pLinkManager->GetLinks().Count();
+ for (USHORT i=0; i<nCount; i++ )
+ {
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
+ if (pBase->ISA(ScTableLink))
+ {
+ ScTableLink* pTabLink = (ScTableLink*)pBase;
+ pTabLink->SetPaint(FALSE); // Paint nur einmal am Ende
+ pTabLink->Update();
+ pTabLink->SetPaint(TRUE);
+ bAny = TRUE;
+ }
+ }
+
+ if ( bAny )
+ {
+ // Paint nur einmal
+ PostPaint( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB),
+ PAINT_GRID | PAINT_TOP | PAINT_LEFT );
+
+ SetDocumentModified();
+ }
+
+ return TRUE; //! Fehler erkennen
+}
+
+void ScDocShell::CheckConfigOptions()
+{
+ if (IsConfigOptionsChecked())
+ // no need to check repeatedly.
+ return;
+
+ OUString aDecSep = ScGlobal::GetpLocaleData()->getNumDecimalSep();
+
+ ScModule* pScMod = SC_MOD();
+ const ScDocOptions& rOpt = pScMod->GetDocOptions();
+ OUString aSepArg = rOpt.GetFormulaSepArg();
+ OUString aSepArrRow = rOpt.GetFormulaSepArrayRow();
+ OUString aSepArrCol = rOpt.GetFormulaSepArrayCol();
+
+ if (aDecSep == aSepArg || aDecSep == aSepArrRow || aDecSep == aSepArrCol)
+ {
+ // One of arg separators conflicts with the current decimal
+ // separator. Reset them to default.
+ ScDocOptions aNew = rOpt;
+ aNew.ResetFormulaSeparators();
+ aDocument.SetDocOptions(aNew);
+ pScMod->SetDocOptions(aNew);
+
+ // Launch a nice warning dialog to let the users know of this change.
+ ScTabViewShell* pViewShell = GetBestViewShell();
+ if (pViewShell)
+ {
+ Window* pParent = pViewShell->GetFrameWin();
+ InfoBox aBox(pParent, ScGlobal::GetRscString(STR_OPTIONS_WARN_SEPARATORS));
+ aBox.Execute();
+ }
+
+ // For now, this is the only option setting that could launch info
+ // dialog. But in the future we may want to implement a nicer
+ // dialog to display a list of warnings in case we have several
+ // pieces of information to display.
+ }
+
+ SetConfigOptionsChecked(true);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh7.cxx b/sc/source/ui/docshell/docsh7.cxx
new file mode 100644
index 000000000000..7aaefa5caccc
--- /dev/null
+++ b/sc/source/ui/docshell/docsh7.cxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------
+
+#include "docsh.hxx"
+
+//------------------------------------------------------------------
+
+void ScDocShell::GetDrawObjState( SfxItemSet & /* rSet */ )
+{
+ // SID_SC_ACTIVEOBJECT (SelectedObject) - removed (old Basic)
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
new file mode 100644
index 000000000000..a9e05e1d43b1
--- /dev/null
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -0,0 +1,1184 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <stdio.h>
+#include <tools/urlobj.hxx>
+#include <svl/converter.hxx>
+#include <svl/zforlist.hxx>
+#include <comphelper/types.hxx>
+#include <ucbhelper/content.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <comphelper/processfactory.hxx>
+#include <svx/txenctab.hxx>
+#include <svx/dbcharsethelper.hxx>
+
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbcx/XAppend.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/sdbcx/XDataDescriptorFactory.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/ucb/NameClash.hpp>
+#include <com/sun/star/ucb/TransferInfo.hpp>
+#include <com/sun/star/ucb/XCommandInfo.hpp>
+
+#include "scerrors.hxx"
+#include "docsh.hxx"
+#include "filter.hxx"
+#include "progress.hxx"
+#include "collect.hxx"
+#include "cell.hxx"
+#include "editutil.hxx"
+#include "cellform.hxx"
+#include "dbdocutl.hxx"
+#include "dociter.hxx"
+#include "globstr.hrc"
+#include "svl/zformat.hxx"
+#include "svl/intitem.hxx"
+#include "patattr.hxx"
+#include "scitems.hxx"
+#include "docpool.hxx"
+#include "segmenttree.hxx"
+#include "docparam.hxx"
+
+#include <vector>
+
+using namespace com::sun::star;
+using ::std::vector;
+
+// -----------------------------------------------------------------------
+
+#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
+#define SC_SERVICE_DRVMAN "com.sun.star.sdbc.DriverManager"
+
+//! move to a header file?
+//#define SC_DBPROP_DATASOURCENAME "DataSourceName"
+#define SC_DBPROP_ACTIVECONNECTION "ActiveConnection"
+#define SC_DBPROP_COMMAND "Command"
+#define SC_DBPROP_COMMANDTYPE "CommandType"
+#define SC_DBPROP_PROPCHANGE_NOTIFY "PropertyChangeNotificationEnabled"
+
+#define SC_DBPROP_NAME "Name"
+#define SC_DBPROP_TYPE "Type"
+#define SC_DBPROP_PRECISION "Precision"
+#define SC_DBPROP_SCALE "Scale"
+
+#define SC_DBPROP_EXTENSION "Extension"
+#define SC_DBPROP_CHARSET "CharSet"
+
+#define SC_ROWCOUNT_ERROR (-1)
+
+namespace
+{
+ ULONG lcl_getDBaseConnection(uno::Reference<sdbc::XDriverManager>& _rDrvMgr,uno::Reference<sdbc::XConnection>& _rConnection,String& _rTabName,const String& rFullFileName,rtl_TextEncoding eCharSet)
+ {
+ INetURLObject aURL;
+ aURL.SetSmartProtocol( INET_PROT_FILE );
+ aURL.SetSmartURL( rFullFileName );
+ _rTabName = aURL.getBase( INetURLObject::LAST_SEGMENT, true,
+ INetURLObject::DECODE_UNAMBIGUOUS );
+ String aExtension = aURL.getExtension();
+ aURL.removeSegment();
+ aURL.removeFinalSlash();
+ String aPath = aURL.GetMainURL(INetURLObject::NO_DECODE);
+ uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
+ if (!xFactory.is()) return SCERR_EXPORT_CONNECT;
+
+ _rDrvMgr.set( xFactory->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_DRVMAN ) ),
+ uno::UNO_QUERY);
+ DBG_ASSERT( _rDrvMgr.is(), "can't get DriverManager" );
+ if (!_rDrvMgr.is()) return SCERR_EXPORT_CONNECT;
+
+ // get connection
+
+ String aConnUrl = String::CreateFromAscii("sdbc:dbase:");
+ aConnUrl += aPath;
+
+ svxform::ODataAccessCharsetHelper aHelper;
+ ::std::vector< rtl_TextEncoding > aEncodings;
+ aHelper.getSupportedTextEncodings( aEncodings );
+ ::std::vector< rtl_TextEncoding >::iterator aIter = ::std::find(aEncodings.begin(),aEncodings.end(),(rtl_TextEncoding) eCharSet);
+ if ( aIter == aEncodings.end() )
+ {
+ DBG_ERRORFILE( "DBaseImport: dbtools::OCharsetMap doesn't know text encoding" );
+ return SCERR_IMPORT_CONNECT;
+ } // if ( aIter == aMap.end() )
+ rtl::OUString aCharSetStr;
+ if ( RTL_TEXTENCODING_DONTKNOW != *aIter )
+ { // it's not the virtual "system charset"
+ const char* pIanaName = rtl_getMimeCharsetFromTextEncoding( *aIter );
+ OSL_ENSURE( pIanaName, "invalid mime name!" );
+ if ( pIanaName )
+ aCharSetStr = ::rtl::OUString::createFromAscii( pIanaName );
+ }
+
+ uno::Sequence<beans::PropertyValue> aProps(2);
+ aProps[0].Name = rtl::OUString::createFromAscii(SC_DBPROP_EXTENSION);
+ aProps[0].Value <<= rtl::OUString( aExtension );
+ aProps[1].Name = rtl::OUString::createFromAscii(SC_DBPROP_CHARSET);
+ aProps[1].Value <<= aCharSetStr;
+
+ _rConnection = _rDrvMgr->getConnectionWithInfo( aConnUrl, aProps );
+ return 0L;
+ }
+}
+// -----------------------------------------------------------------------
+// MoveFile/KillFile/IsDocument: similar to SfxContentHelper
+
+// static
+BOOL ScDocShell::MoveFile( const INetURLObject& rSourceObj, const INetURLObject& rDestObj )
+{
+ sal_Bool bMoveData = sal_True;
+ sal_Bool bRet = sal_True, bKillSource = sal_False;
+ if ( rSourceObj.GetProtocol() != rDestObj.GetProtocol() )
+ {
+ bMoveData = sal_False;
+ bKillSource = sal_True;
+ }
+ String aName = rDestObj.getName();
+ INetURLObject aDestPathObj = rDestObj;
+ aDestPathObj.removeSegment();
+ aDestPathObj.setFinalSlash();
+
+ try
+ {
+ ::ucbhelper::Content aDestPath( aDestPathObj.GetMainURL(INetURLObject::NO_DECODE),
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ uno::Reference< ::com::sun::star::ucb::XCommandInfo > xInfo = aDestPath.getCommands();
+ rtl::OUString aTransferName = rtl::OUString::createFromAscii( "transfer" );
+ if ( xInfo->hasCommandByName( aTransferName ) )
+ {
+ aDestPath.executeCommand( aTransferName, uno::makeAny(
+ ::com::sun::star::ucb::TransferInfo( bMoveData, rSourceObj.GetMainURL(INetURLObject::NO_DECODE), aName,
+ ::com::sun::star::ucb::NameClash::ERROR ) ) );
+ }
+ else
+ {
+ DBG_ERRORFILE( "transfer command not available" );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ // ucb may throw different exceptions on failure now
+ bRet = sal_False;
+ }
+
+ if ( bKillSource )
+ KillFile( rSourceObj );
+
+ return bRet;
+}
+
+
+// static
+BOOL ScDocShell::KillFile( const INetURLObject& rURL )
+{
+ sal_Bool bRet = sal_True;
+ try
+ {
+ ::ucbhelper::Content aCnt( rURL.GetMainURL(INetURLObject::NO_DECODE),
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ aCnt.executeCommand( rtl::OUString::createFromAscii( "delete" ),
+ comphelper::makeBoolAny( sal_True ) );
+ }
+ catch( uno::Exception& )
+ {
+ // ucb may throw different exceptions on failure now
+ bRet = sal_False;
+ }
+
+ return bRet;
+}
+
+// static
+BOOL ScDocShell::IsDocument( const INetURLObject& rURL )
+{
+ sal_Bool bRet = sal_False;
+ try
+ {
+ ::ucbhelper::Content aCnt( rURL.GetMainURL(INetURLObject::NO_DECODE),
+ uno::Reference< ::com::sun::star::ucb::XCommandEnvironment > () );
+ bRet = aCnt.isDocument();
+ }
+ catch( uno::Exception& )
+ {
+ // ucb may throw different exceptions on failure now - warning only
+ DBG_WARNING( "Any other exception" );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------
+
+static void lcl_setScalesToColumns(ScDocument& rDoc, const vector<long>& rScales)
+{
+ SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
+ if (!pFormatter)
+ return;
+
+ SCCOL nColCount = static_cast<SCCOL>(rScales.size());
+ for (SCCOL i = 0; i < nColCount; ++i)
+ {
+ if (rScales[i] < 0)
+ continue;
+
+ sal_uInt32 nOldFormat;
+ rDoc.GetNumberFormat(static_cast<SCCOL>(i), 0, 0, nOldFormat);
+ const SvNumberformat* pOldEntry = pFormatter->GetEntry(nOldFormat);
+ if (!pOldEntry)
+ continue;
+
+ LanguageType eLang = pOldEntry->GetLanguage();
+ BOOL bThousand, bNegRed;
+ USHORT nPrecision, nLeading;
+ pOldEntry->GetFormatSpecialInfo(bThousand, bNegRed, nPrecision, nLeading);
+
+ nPrecision = static_cast<USHORT>(rScales[i]);
+ String aNewPicture;
+ pFormatter->GenerateFormat(aNewPicture, nOldFormat, eLang,
+ bThousand, bNegRed, nPrecision, nLeading);
+
+ sal_uInt32 nNewFormat = pFormatter->GetEntryKey(aNewPicture, eLang);
+ if (nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
+ {
+ xub_StrLen nErrPos = 0;
+ short nNewType = 0;
+ bool bOk = pFormatter->PutEntry(
+ aNewPicture, nErrPos, nNewType, nNewFormat, eLang);
+
+ if (!bOk)
+ continue;
+ }
+
+ ScPatternAttr aNewAttrs( rDoc.GetPool() );
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) );
+ rDoc.ApplyPatternAreaTab(static_cast<SCCOL>(i), 0, static_cast<SCCOL>(i), MAXROW, 0, aNewAttrs);
+ }
+}
+
+ULONG ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet,
+ ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc )
+{
+ ScColumn::DoubleAllocSwitch aAllocSwitch(true);
+
+ ULONG nErr = eERR_OK;
+ long i;
+
+ try
+ {
+ String aTabName;
+ uno::Reference<sdbc::XDriverManager> xDrvMan;
+ uno::Reference<sdbc::XConnection> xConnection;
+ ULONG nRet = lcl_getDBaseConnection(xDrvMan,xConnection,aTabName,rFullFileName,eCharSet);
+ if ( !xConnection.is() || !xDrvMan.is() )
+ return nRet;
+ ::utl::DisposableComponent aConnectionHelper(xConnection);
+
+ long nRowCount = 0;
+ if ( nRowCount < 0 )
+ {
+ DBG_ERROR("can't get row count");
+ nRowCount = 0;
+ }
+
+ ScProgress aProgress( this, ScGlobal::GetRscString( STR_LOAD_DOC ), nRowCount );
+ uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
+ uno::Reference<sdbc::XRowSet> xRowSet( xFactory->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ),
+ uno::UNO_QUERY);
+ ::utl::DisposableComponent aRowSetHelper(xRowSet);
+ uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xRowProp.is(), "can't get RowSet" );
+ if (!xRowProp.is()) return SCERR_IMPORT_CONNECT;
+
+ sal_Int32 nType = sdb::CommandType::TABLE;
+ uno::Any aAny;
+
+ aAny <<= xConnection;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_ACTIVECONNECTION), aAny );
+
+ aAny <<= nType;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMANDTYPE), aAny );
+
+ aAny <<= rtl::OUString( aTabName );
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMAND), aAny );
+
+ aAny <<= sal_False;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_PROPCHANGE_NOTIFY), aAny );
+
+ xRowSet->execute();
+
+ long nColCount = 0;
+ uno::Reference<sdbc::XResultSetMetaData> xMeta;
+ uno::Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp( xRowSet, uno::UNO_QUERY );
+ if ( xMetaSupp.is() )
+ xMeta = xMetaSupp->getMetaData();
+ if ( xMeta.is() )
+ nColCount = xMeta->getColumnCount(); // this is the number of real columns
+
+ if ( nColCount > MAXCOL+1 )
+ {
+ nColCount = MAXCOL+1;
+ nErr = SCWARN_IMPORT_RANGE_OVERFLOW; // warning
+ }
+
+ if ( nColCount > 0 )
+ aDocument.DoColResize( 0, 0, static_cast<SCCOL>(nColCount) - 1,
+ static_cast<SCSIZE>(nRowCount) + 1 );
+
+ uno::Reference<sdbc::XRow> xRow( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xRow.is(), "can't get Row" );
+ if (!xRow.is()) return SCERR_IMPORT_CONNECT;
+
+ // currency flag is not needed for dBase
+ uno::Sequence<sal_Int32> aColTypes( nColCount ); // column types
+ sal_Int32* pTypeArr = aColTypes.getArray();
+ for (i=0; i<nColCount; i++)
+ pTypeArr[i] = xMeta->getColumnType( i+1 );
+
+ // read column names
+ //! add type descriptions
+
+ vector<long> aScales(nColCount, -1);
+ for (i=0; i<nColCount; i++)
+ {
+ String aHeader = xMeta->getColumnLabel( i+1 );
+
+ switch ( pTypeArr[i] )
+ {
+ case sdbc::DataType::BIT:
+ aHeader.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",L" ));
+ break;
+ case sdbc::DataType::DATE:
+ aHeader.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",D" ));
+ break;
+ case sdbc::DataType::LONGVARCHAR:
+ aHeader.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",M" ));
+ break;
+ case sdbc::DataType::VARCHAR:
+ aHeader.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",C," ));
+ aHeader += String::CreateFromInt32( xMeta->getColumnDisplaySize( i+1 ) );
+ break;
+ case sdbc::DataType::DECIMAL:
+ {
+ long nPrec = xMeta->getPrecision( i+1 );
+ long nScale = xMeta->getScale( i+1 );
+ aHeader.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",N," ));
+ aHeader += String::CreateFromInt32(
+ SvDbaseConverter::ConvertPrecisionToDbase(
+ nPrec, nScale ) );
+ aHeader += ',';
+ aHeader += String::CreateFromInt32( nScale );
+ aScales[i] = nScale;
+ }
+ break;
+ }
+
+ aDocument.SetString( static_cast<SCCOL>(i), 0, 0, aHeader );
+ }
+
+ lcl_setScalesToColumns(aDocument, aScales);
+
+ SCROW nRow = 1; // 0 is column titles
+ BOOL bEnd = FALSE;
+ while ( !bEnd && xRowSet->next() )
+ {
+ bool bSimpleRow = true;
+ if ( nRow <= MAXROW )
+ {
+ SCCOL nCol = 0;
+ for (i=0; i<nColCount; i++)
+ {
+ ScDatabaseDocUtil::StrData aStrData;
+ ScDatabaseDocUtil::PutData( &aDocument, nCol, nRow, 0,
+ xRow, i+1, pTypeArr[i], FALSE,
+ &aStrData );
+
+ if (aStrData.mnStrLength > aColWidthParam[nCol].mnMaxTextLen)
+ {
+ aColWidthParam[nCol].mnMaxTextLen = aStrData.mnStrLength;
+ aColWidthParam[nCol].mnMaxTextRow = nRow;
+ }
+
+ if (!aStrData.mbSimpleText)
+ {
+ bSimpleRow = false;
+ aColWidthParam[nCol].mbSimpleText = false;
+ }
+
+ ++nCol;
+ }
+ if (!bSimpleRow)
+ rRowHeightsRecalc.setTrue(nRow, nRow);
+ ++nRow;
+ }
+ else // past the end of the spreadsheet
+ {
+ bEnd = TRUE; // don't continue
+ nErr = SCWARN_IMPORT_RANGE_OVERFLOW; // warning message
+ }
+
+ if ( nRowCount )
+ aProgress.SetStateOnPercent( nRow );
+ }
+ }
+ catch ( sdbc::SQLException& )
+ {
+ nErr = SCERR_IMPORT_CONNECT;
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR("Unexpected exception in database");
+ nErr = ERRCODE_IO_GENERAL;
+ }
+
+ return nErr;
+}
+
+// -----------------------------------------------------------------------
+
+inline sal_Bool IsAsciiDigit( sal_Unicode c )
+{
+ return 0x30 <= c && c <= 0x39;
+}
+
+inline sal_Bool IsAsciiAlpha( sal_Unicode c )
+{
+ return (0x41 <= c && c <= 0x5a) || (0x61 <= c && c <= 0x7a);
+}
+
+void lcl_GetColumnTypes( ScDocShell& rDocShell,
+ const ScRange& rDataRange, BOOL bHasFieldNames,
+ rtl::OUString* pColNames, sal_Int32* pColTypes,
+ sal_Int32* pColLengths, sal_Int32* pColScales,
+ BOOL& bHasMemo, CharSet eCharSet )
+{
+ // updating of column titles didn't work in 5.2 and isn't always wanted
+ // (saving normally shouldn't modify the document)
+ //! read flag from configuration
+ BOOL bUpdateTitles = FALSE;
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SvNumberFormatter* pNumFmt = pDoc->GetFormatTable();
+
+ SCTAB nTab = rDataRange.aStart.Tab();
+ SCCOL nFirstCol = rDataRange.aStart.Col();
+ SCROW nFirstRow = rDataRange.aStart.Row();
+ SCCOL nLastCol = rDataRange.aEnd.Col();
+ SCROW nLastRow = rDataRange.aEnd.Row();
+
+ ScStrCollection aFieldNamesCollection;
+
+ long nField = 0;
+ SCROW nFirstDataRow = ( bHasFieldNames ? nFirstRow + 1 : nFirstRow );
+ for ( SCCOL nCol = nFirstCol; nCol <= nLastCol; nCol++ )
+ {
+ BOOL bTypeDefined = FALSE;
+ BOOL bPrecDefined = FALSE;
+ sal_Int32 nFieldLen = 0;
+ sal_Int32 nPrecision = 0;
+ sal_Int32 nDbType = sdbc::DataType::SQLNULL;
+ String aFieldName, aString;
+
+ // Feldname[,Type[,Width[,Prec]]]
+ // Typ etc.: L; D; C[,W]; N[,W[,P]]
+ if ( bHasFieldNames )
+ {
+ pDoc->GetString( nCol, nFirstRow, nTab, aString );
+ aString.ToUpperAscii();
+ xub_StrLen nToken = aString.GetTokenCount( ',' );
+ if ( nToken > 1 )
+ {
+ aFieldName = aString.GetToken( 0, ',' );
+ aString.EraseAllChars( ' ' );
+ switch ( aString.GetToken( 1, ',' ).GetChar(0) )
+ {
+ case 'L' :
+ nDbType = sdbc::DataType::BIT;
+ nFieldLen = 1;
+ bTypeDefined = TRUE;
+ bPrecDefined = TRUE;
+ break;
+ case 'D' :
+ nDbType = sdbc::DataType::DATE;
+ nFieldLen = 8;
+ bTypeDefined = TRUE;
+ bPrecDefined = TRUE;
+ break;
+ case 'M' :
+ nDbType = sdbc::DataType::LONGVARCHAR;
+ nFieldLen = 10;
+ bTypeDefined = TRUE;
+ bPrecDefined = TRUE;
+ bHasMemo = TRUE;
+ break;
+ case 'C' :
+ nDbType = sdbc::DataType::VARCHAR;
+ bTypeDefined = TRUE;
+ bPrecDefined = TRUE;
+ break;
+ case 'N' :
+ nDbType = sdbc::DataType::DECIMAL;
+ break;
+ }
+ if ( bTypeDefined && !nFieldLen && nToken > 2 )
+ {
+ nFieldLen = aString.GetToken( 2, ',' ).ToInt32();
+ if ( !bPrecDefined && nToken > 3 )
+ {
+ String aTmp( aString.GetToken( 3, ',' ) );
+ if ( CharClass::isAsciiNumeric(aTmp) )
+ {
+ nPrecision = aTmp.ToInt32();
+ bPrecDefined = TRUE;
+ }
+ }
+ }
+ }
+ else
+ aFieldName = aString;
+
+ // Feldnamen pruefen und ggbf. gueltigen Feldnamen erzeugen.
+ // Erstes Zeichen muss Buchstabe sein,
+ // weitere nur alphanumerisch und Unterstrich erlaubt,
+ // "_DBASELOCK" ist reserviert (obsolet weil erstes Zeichen kein Buchstabe),
+ // keine doppelten Namen.
+ if ( !IsAsciiAlpha( aFieldName.GetChar(0) ) )
+ aFieldName.Insert( 'N', 0 );
+ String aTmpStr;
+ sal_Unicode c;
+ for ( const sal_Unicode* p = aFieldName.GetBuffer(); ( c = *p ) != 0; p++ )
+ {
+ if ( IsAsciiAlpha( c ) || IsAsciiDigit( c ) || c == '_' )
+ aTmpStr += c;
+ else
+ aTmpStr += '_';
+ }
+ aFieldName = aTmpStr;
+ if ( aFieldName.Len() > 10 )
+ aFieldName.Erase( 10 );
+ StrData* pStrData = new StrData( aFieldName );
+ if ( !aFieldNamesCollection.Insert( pStrData ) )
+ { // doppelter Feldname, numerisch erweitern
+ USHORT nSub = 1;
+ String aFixPart( aFieldName );
+ do
+ {
+ ++nSub;
+ String aVarPart = String::CreateFromInt32( nSub );
+ if ( aFixPart.Len() + aVarPart.Len() > 10 )
+ aFixPart.Erase( 10 - aVarPart.Len() );
+ aFieldName = aFixPart;
+ aFieldName += aVarPart;
+ pStrData->SetString( aFieldName );
+ } while ( !aFieldNamesCollection.Insert( pStrData ) );
+ }
+ }
+ else
+ {
+ aFieldName = 'N';
+ aFieldName += String::CreateFromInt32(nCol+1);
+ }
+
+ if ( !bTypeDefined )
+ { // Feldtyp
+ ScBaseCell* pCell;
+ pDoc->GetCell( nCol, nFirstDataRow, nTab, pCell );
+ if ( !pCell || pCell->HasStringData() )
+ nDbType = sdbc::DataType::VARCHAR;
+ else
+ {
+ sal_uInt32 nFormat;
+ pDoc->GetNumberFormat( nCol, nFirstDataRow, nTab, nFormat );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA
+ && ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) )
+ {
+ nFormat = ScGlobal::GetStandardFormat(
+ ((ScFormulaCell*)pCell)->GetValue(), *pNumFmt, nFormat,
+ ((ScFormulaCell*)pCell)->GetFormatType() );
+ }
+ switch ( pNumFmt->GetType( nFormat ) )
+ {
+ case NUMBERFORMAT_LOGICAL :
+ nDbType = sdbc::DataType::BIT;
+ nFieldLen = 1;
+ break;
+ case NUMBERFORMAT_DATE :
+ nDbType = sdbc::DataType::DATE;
+ nFieldLen = 8;
+ break;
+ case NUMBERFORMAT_TIME :
+ case NUMBERFORMAT_DATETIME :
+ nDbType = sdbc::DataType::VARCHAR;
+ break;
+ default:
+ nDbType = sdbc::DataType::DECIMAL;
+ }
+ }
+ }
+ BOOL bSdbLenAdjusted = FALSE;
+ BOOL bSdbLenBad = FALSE;
+ // Feldlaenge
+ if ( nDbType == sdbc::DataType::VARCHAR && !nFieldLen )
+ { // maximale Feldbreite bestimmen
+ nFieldLen = pDoc->GetMaxStringLen( nTab, nCol, nFirstDataRow,
+ nLastRow, eCharSet );
+ if ( nFieldLen == 0 )
+ nFieldLen = 1;
+ }
+ else if ( nDbType == sdbc::DataType::DECIMAL )
+ { // maximale Feldbreite und Nachkommastellen bestimmen
+ xub_StrLen nLen;
+ sal_uInt16 nPrec;
+ nLen = pDoc->GetMaxNumberStringLen( nPrec, nTab, nCol,
+ nFirstDataRow, nLastRow );
+ // dBaseIII Limit Nachkommastellen: 15
+ if ( nPrecision > 15 )
+ nPrecision = 15;
+ if ( nPrec > 15 )
+ nPrec = 15;
+ if ( bPrecDefined && nPrecision != nPrec )
+ { // Laenge auf vorgegebene Nachkommastellen anpassen
+ if ( nPrecision )
+ nLen = sal::static_int_cast<xub_StrLen>( nLen + ( nPrecision - nPrec ) );
+ else
+ nLen -= nPrec+1; // auch den . mit raus
+ }
+ if ( nLen > nFieldLen && !bTypeDefined )
+ nFieldLen = nLen;
+ if ( !bPrecDefined )
+ nPrecision = nPrec;
+ if ( nFieldLen == 0 )
+ nFieldLen = 1;
+ else if ( nFieldLen > 19 )
+ nFieldLen = 19; // dBaseIII Limit Feldlaenge numerisch: 19
+ if ( nPrecision && nFieldLen < nPrecision + 2 )
+ nFieldLen = nPrecision + 2; // 0. muss mit reinpassen
+ // 538 MUST: Sdb internal representation adds 2 to the field length!
+ // To give the user what he wants we must substract it here.
+ //! CAVEAT! There is no way to define a numeric field with a length
+ //! of 1 and no decimals!
+ if ( nFieldLen == 1 && nPrecision == 0 )
+ bSdbLenBad = TRUE;
+ nFieldLen = SvDbaseConverter::ConvertPrecisionToOdbc( nFieldLen, nPrecision );
+ bSdbLenAdjusted = TRUE;
+ }
+ if ( nFieldLen > 254 )
+ {
+ if ( nDbType == sdbc::DataType::VARCHAR )
+ { // zu lang fuer normales Textfeld => Memofeld
+ nDbType = sdbc::DataType::LONGVARCHAR;
+ nFieldLen = 10;
+ bHasMemo = TRUE;
+ }
+ else
+ nFieldLen = 254; // dumm gelaufen..
+ }
+
+ pColNames[nField] = aFieldName;
+ pColTypes[nField] = nDbType;
+ pColLengths[nField] = nFieldLen;
+ pColScales[nField] = nPrecision;
+
+ // undo change to field length, reflect reality
+ if ( bSdbLenAdjusted )
+ {
+ nFieldLen = SvDbaseConverter::ConvertPrecisionToDbase( nFieldLen, nPrecision );
+ if ( bSdbLenBad && nFieldLen == 1 )
+ nFieldLen = 2; // THIS is reality
+ }
+ if ( bUpdateTitles )
+ { // Angabe anpassen und ausgeben
+ String aOutString = aFieldName;
+ switch ( nDbType )
+ {
+ case sdbc::DataType::BIT :
+ aOutString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",L" ));
+ break;
+ case sdbc::DataType::DATE :
+ aOutString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",D" ));
+ break;
+ case sdbc::DataType::LONGVARCHAR :
+ aOutString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",M" ));
+ break;
+ case sdbc::DataType::VARCHAR :
+ aOutString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",C," ));
+ aOutString += String::CreateFromInt32( nFieldLen );
+ break;
+ case sdbc::DataType::DECIMAL :
+ aOutString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ",N," ));
+ aOutString += String::CreateFromInt32( nFieldLen );
+ aOutString += ',';
+ aOutString += String::CreateFromInt32( nPrecision );
+ break;
+ }
+ if ( !aOutString.EqualsIgnoreCaseAscii( aString ) )
+ {
+ pDoc->SetString( nCol, nFirstRow, nTab, aOutString );
+ rDocShell.PostPaint( nCol, nFirstRow, nTab, nCol, nFirstRow, nTab, PAINT_GRID );
+ }
+ }
+ ++nField;
+ }
+}
+
+
+inline void lcl_getLongVarCharEditString( String& rString,
+ const ScBaseCell* pCell, ScFieldEditEngine& rEditEngine )
+{
+ rEditEngine.SetText( *((const ScEditCell*)pCell)->GetData() );
+ rString = rEditEngine.GetText( LINEEND_CRLF );
+}
+
+inline void lcl_getLongVarCharString( String& rString, ScBaseCell* pCell,
+ ScDocument& rDocument, SCCOL nCol, SCROW nRow, SCTAB nTab,
+ SvNumberFormatter& rNumFmt )
+{
+ sal_uInt32 nFormat;
+ Color* pColor;
+ rDocument.GetNumberFormat( nCol, nRow, nTab, nFormat );
+ ScCellFormat::GetString( pCell, nFormat, rString, &pColor, rNumFmt );
+}
+
+
+ULONG ScDocShell::DBaseExport( const String& rFullFileName, CharSet eCharSet, BOOL& bHasMemo )
+{
+ // remove the file so the dBase driver doesn't find an invalid file
+ INetURLObject aDeleteObj( rFullFileName, INET_PROT_FILE );
+ KillFile( aDeleteObj );
+
+ ULONG nErr = eERR_OK;
+ uno::Any aAny;
+
+ SCCOL nFirstCol, nLastCol;
+ SCROW nFirstRow, nLastRow;
+ SCTAB nTab = GetSaveTab();
+ aDocument.GetDataStart( nTab, nFirstCol, nFirstRow );
+ aDocument.GetCellArea( nTab, nLastCol, nLastRow );
+ if ( nFirstCol > nLastCol )
+ nFirstCol = nLastCol;
+ if ( nFirstRow > nLastRow )
+ nFirstRow = nLastRow;
+ ScProgress aProgress( this, ScGlobal::GetRscString( STR_SAVE_DOC ),
+ nLastRow - nFirstRow );
+ SvNumberFormatter* pNumFmt = aDocument.GetFormatTable();
+
+ BOOL bHasFieldNames = TRUE;
+ for ( SCCOL nDocCol = nFirstCol; nDocCol <= nLastCol && bHasFieldNames; nDocCol++ )
+ { // nur Strings in erster Zeile => sind Feldnamen
+ if ( !aDocument.HasStringData( nDocCol, nFirstRow, nTab ) )
+ bHasFieldNames = FALSE;
+ }
+
+ long nColCount = nLastCol - nFirstCol + 1;
+ uno::Sequence<rtl::OUString> aColNames( nColCount );
+ uno::Sequence<sal_Int32> aColTypes( nColCount );
+ uno::Sequence<sal_Int32> aColLengths( nColCount );
+ uno::Sequence<sal_Int32> aColScales( nColCount );
+
+ ScRange aDataRange( nFirstCol, nFirstRow, nTab, nLastCol, nLastRow, nTab );
+ lcl_GetColumnTypes( *this, aDataRange, bHasFieldNames,
+ aColNames.getArray(), aColTypes.getArray(),
+ aColLengths.getArray(), aColScales.getArray(),
+ bHasMemo, eCharSet );
+ // also needed for exception catch
+ SCROW nDocRow = 0;
+ ScFieldEditEngine aEditEngine( aDocument.GetEditPool() );
+ String aString;
+ String aTabName;
+
+ try
+ {
+ uno::Reference<sdbc::XDriverManager> xDrvMan;
+ uno::Reference<sdbc::XConnection> xConnection;
+ ULONG nRet = lcl_getDBaseConnection(xDrvMan,xConnection,aTabName,rFullFileName,eCharSet);
+ if ( !xConnection.is() || !xDrvMan.is() )
+ return nRet;
+ ::utl::DisposableComponent aConnectionHelper(xConnection);
+
+ // get dBase driver
+ uno::Reference< sdbc::XDriverAccess> xAccess(xDrvMan,uno::UNO_QUERY);
+ uno::Reference< sdbcx::XDataDefinitionSupplier > xDDSup( xAccess->getDriverByURL( xConnection->getMetaData()->getURL() ), uno::UNO_QUERY );
+ if ( !xDDSup.is() )
+ return SCERR_EXPORT_CONNECT;
+
+ // create table
+ uno::Reference<sdbcx::XTablesSupplier> xTablesSupp =xDDSup->getDataDefinitionByConnection( xConnection );
+ DBG_ASSERT( xTablesSupp.is(), "can't get Data Definition" );
+ if (!xTablesSupp.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<container::XNameAccess> xTables = xTablesSupp->getTables();
+ DBG_ASSERT( xTables.is(), "can't get Tables" );
+ if (!xTables.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<sdbcx::XDataDescriptorFactory> xTablesFact( xTables, uno::UNO_QUERY );
+ DBG_ASSERT( xTablesFact.is(), "can't get tables factory" );
+ if (!xTablesFact.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<sdbcx::XAppend> xTablesAppend( xTables, uno::UNO_QUERY );
+ DBG_ASSERT( xTablesAppend.is(), "can't get tables XAppend" );
+ if (!xTablesAppend.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<beans::XPropertySet> xTableDesc = xTablesFact->createDataDescriptor();
+ DBG_ASSERT( xTableDesc.is(), "can't get table descriptor" );
+ if (!xTableDesc.is()) return SCERR_EXPORT_CONNECT;
+
+ aAny <<= rtl::OUString( aTabName );
+ xTableDesc->setPropertyValue( rtl::OUString::createFromAscii(SC_DBPROP_NAME), aAny );
+
+ // create columns
+
+ uno::Reference<sdbcx::XColumnsSupplier> xColumnsSupp( xTableDesc, uno::UNO_QUERY );
+ DBG_ASSERT( xColumnsSupp.is(), "can't get columns supplier" );
+ if (!xColumnsSupp.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<container::XNameAccess> xColumns = xColumnsSupp->getColumns();
+ DBG_ASSERT( xColumns.is(), "can't get columns" );
+ if (!xColumns.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<sdbcx::XDataDescriptorFactory> xColumnsFact( xColumns, uno::UNO_QUERY );
+ DBG_ASSERT( xColumnsFact.is(), "can't get columns factory" );
+ if (!xColumnsFact.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<sdbcx::XAppend> xColumnsAppend( xColumns, uno::UNO_QUERY );
+ DBG_ASSERT( xColumnsAppend.is(), "can't get columns XAppend" );
+ if (!xColumnsAppend.is()) return SCERR_EXPORT_CONNECT;
+
+ const rtl::OUString* pColNames = aColNames.getConstArray();
+ const sal_Int32* pColTypes = aColTypes.getConstArray();
+ const sal_Int32* pColLengths = aColLengths.getConstArray();
+ const sal_Int32* pColScales = aColScales.getConstArray();
+ long nCol;
+
+ for (nCol=0; nCol<nColCount; nCol++)
+ {
+ uno::Reference<beans::XPropertySet> xColumnDesc = xColumnsFact->createDataDescriptor();
+ DBG_ASSERT( xColumnDesc.is(), "can't get column descriptor" );
+ if (!xColumnDesc.is()) return SCERR_EXPORT_CONNECT;
+
+ aAny <<= pColNames[nCol];
+ xColumnDesc->setPropertyValue( rtl::OUString::createFromAscii(SC_DBPROP_NAME), aAny );
+
+ aAny <<= pColTypes[nCol];
+ xColumnDesc->setPropertyValue( rtl::OUString::createFromAscii(SC_DBPROP_TYPE), aAny );
+
+ aAny <<= pColLengths[nCol];
+ xColumnDesc->setPropertyValue( rtl::OUString::createFromAscii(SC_DBPROP_PRECISION), aAny );
+
+ aAny <<= pColScales[nCol];
+ xColumnDesc->setPropertyValue( rtl::OUString::createFromAscii(SC_DBPROP_SCALE), aAny );
+
+ xColumnsAppend->appendByDescriptor( xColumnDesc );
+ }
+
+ xTablesAppend->appendByDescriptor( xTableDesc );
+
+ // re-open connection
+// xConnection = xDrvMan->getConnectionWithInfo( aConnUrl, aProps );
+// DBG_ASSERT( xConnection.is(), "can't get Connection" );
+// if (!xConnection.is()) return SCERR_EXPORT_CONNECT;
+
+ // get row set for writing
+ uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
+ uno::Reference<sdbc::XRowSet> xRowSet( xFactory->createInstance(
+ rtl::OUString::createFromAscii( SC_SERVICE_ROWSET ) ),
+ uno::UNO_QUERY);
+ ::utl::DisposableComponent aRowSetHelper(xRowSet);
+ uno::Reference<beans::XPropertySet> xRowProp( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xRowProp.is(), "can't get RowSet" );
+ if (!xRowProp.is()) return SCERR_EXPORT_CONNECT;
+
+ aAny <<= xConnection;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_ACTIVECONNECTION), aAny );
+
+ aAny <<= (sal_Int32) sdb::CommandType::TABLE;
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMANDTYPE), aAny );
+
+ aAny <<= rtl::OUString( aTabName );
+ xRowProp->setPropertyValue(
+ rtl::OUString::createFromAscii(SC_DBPROP_COMMAND), aAny );
+
+ xRowSet->execute();
+
+ // write data rows
+
+ uno::Reference<sdbc::XResultSetUpdate> xResultUpdate( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xResultUpdate.is(), "can't get XResultSetUpdate" );
+ if (!xResultUpdate.is()) return SCERR_EXPORT_CONNECT;
+
+ uno::Reference<sdbc::XRowUpdate> xRowUpdate( xRowSet, uno::UNO_QUERY );
+ DBG_ASSERT( xRowUpdate.is(), "can't get XRowUpdate" );
+ if (!xRowUpdate.is()) return SCERR_EXPORT_CONNECT;
+
+ SCROW nFirstDataRow = ( bHasFieldNames ? nFirstRow + 1 : nFirstRow );
+ double fVal;
+
+ for ( nDocRow = nFirstDataRow; nDocRow <= nLastRow; nDocRow++ )
+ {
+ xResultUpdate->moveToInsertRow();
+
+ for (nCol=0; nCol<nColCount; nCol++)
+ {
+ SCCOL nDocCol = sal::static_int_cast<SCCOL>( nFirstCol + nCol );
+
+ switch (pColTypes[nCol])
+ {
+ case sdbc::DataType::LONGVARCHAR:
+ {
+ ScBaseCell* pCell;
+ aDocument.GetCell( nDocCol, nDocRow, nTab, pCell );
+ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
+ {
+ if ( pCell->GetCellType() == CELLTYPE_EDIT )
+ { // #60761# Paragraphs erhalten
+ lcl_getLongVarCharEditString( aString,
+ pCell, aEditEngine);
+ }
+ else
+ {
+ lcl_getLongVarCharString( aString, pCell,
+ aDocument, nDocCol, nDocRow, nTab,
+ *pNumFmt);
+ }
+ xRowUpdate->updateString( nCol+1, aString );
+ }
+ else
+ xRowUpdate->updateNull( nCol+1 );
+ }
+ break;
+
+ case sdbc::DataType::VARCHAR:
+ aDocument.GetString( nDocCol, nDocRow, nTab, aString );
+ xRowUpdate->updateString( nCol+1, aString );
+ if ( nErr == eERR_OK && pColLengths[nCol] < aString.Len() )
+ nErr = SCWARN_EXPORT_DATALOST;
+ break;
+
+ case sdbc::DataType::DATE:
+ {
+ aDocument.GetValue( nDocCol, nDocRow, nTab, fVal );
+ // #39274# zwischen 0 Wert und 0 kein Wert unterscheiden
+ BOOL bIsNull = (fVal == 0.0);
+ if ( bIsNull )
+ bIsNull = !aDocument.HasValueData( nDocCol, nDocRow, nTab );
+ if ( bIsNull )
+ {
+ xRowUpdate->updateNull( nCol+1 );
+ if ( nErr == eERR_OK &&
+ aDocument.HasStringData( nDocCol, nDocRow, nTab ) )
+ nErr = SCWARN_EXPORT_DATALOST;
+ }
+ else
+ {
+ Date aDate = *(pNumFmt->GetNullDate()); // tools date
+ aDate += (long)fVal; //! approxfloor?
+ util::Date aUnoDate( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
+ xRowUpdate->updateDate( nCol+1, aUnoDate );
+ }
+ }
+ break;
+
+ case sdbc::DataType::DECIMAL:
+ case sdbc::DataType::BIT:
+ aDocument.GetValue( nDocCol, nDocRow, nTab, fVal );
+ if ( fVal == 0.0 && nErr == eERR_OK &&
+ aDocument.HasStringData( nDocCol, nDocRow, nTab ) )
+ nErr = SCWARN_EXPORT_DATALOST;
+ if ( pColTypes[nCol] == sdbc::DataType::BIT )
+ xRowUpdate->updateBoolean( nCol+1, ( fVal != 0.0 ) );
+ else
+ xRowUpdate->updateDouble( nCol+1, fVal );
+ break;
+
+ default:
+ DBG_ERROR( "ScDocShell::DBaseExport: unknown FieldType" );
+ if ( nErr == eERR_OK )
+ nErr = SCWARN_EXPORT_DATALOST;
+ aDocument.GetValue( nDocCol, nDocRow, nTab, fVal );
+ xRowUpdate->updateDouble( nCol+1, fVal );
+ }
+ }
+
+ xResultUpdate->insertRow();
+
+ //! error handling and recovery of old
+ //! ScDocShell::SbaSdbExport is still missing!
+
+ if ( !aProgress.SetStateOnPercent( nDocRow - nFirstRow ) )
+ { // UserBreak
+ nErr = SCERR_EXPORT_DATA;
+ break;
+ }
+ }
+
+ comphelper::disposeComponent( xRowSet );
+ comphelper::disposeComponent( xConnection );
+ }
+ catch ( sdbc::SQLException& aException )
+ {
+ sal_Int32 nError = aException.ErrorCode;
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "ScDocShell::DBaseExport: SQLException ErrorCode: %d, SQLState: %s, Message: %s\n",
+ (int)nError, OUStringToOString( aException.SQLState,
+ RTL_TEXTENCODING_UTF8).getStr(), OUStringToOString(
+ aException.Message, RTL_TEXTENCODING_UTF8).getStr());
+#endif
+ if (nError == 22018 || nError == 22001)
+ {
+ // SQL error 22018: Character not in target encoding.
+ // SQL error 22001: String length exceeds field width (after encoding).
+ bool bEncErr = (nError == 22018);
+ bool bIsOctetTextEncoding = rtl_isOctetTextEncoding( eCharSet);
+ DBG_ASSERT( !bEncErr || bIsOctetTextEncoding, "ScDocShell::DBaseExport: encoding error and not an octect textencoding");
+ SCCOL nDocCol = nFirstCol;
+ const sal_Int32* pColTypes = aColTypes.getConstArray();
+ const sal_Int32* pColLengths = aColLengths.getConstArray();
+ ScHorizontalCellIterator aIter( &aDocument, nTab, nFirstCol,
+ nDocRow, nLastCol, nDocRow);
+ ScBaseCell* pCell = NULL;
+ bool bTest = true;
+ while (bTest && ((pCell = aIter.GetNext( nDocCol, nDocRow)) != NULL))
+ {
+ SCCOL nCol = nDocCol - nFirstCol;
+ switch (pColTypes[nCol])
+ {
+ case sdbc::DataType::LONGVARCHAR:
+ {
+ if ( pCell->GetCellType() != CELLTYPE_NOTE )
+ {
+ if ( pCell->GetCellType() == CELLTYPE_EDIT )
+ lcl_getLongVarCharEditString( aString,
+ pCell, aEditEngine);
+ else
+ lcl_getLongVarCharString( aString,
+ pCell, aDocument, nDocCol,
+ nDocRow, nTab, *pNumFmt);
+ }
+ }
+ break;
+
+ case sdbc::DataType::VARCHAR:
+ aDocument.GetString( nDocCol, nDocRow, nTab, aString);
+ break;
+
+ // NOTE: length of DECIMAL fields doesn't need to be
+ // checked here, the database driver adjusts the field
+ // width accordingly.
+
+ default:
+ bTest = false;
+ }
+ if (bTest)
+ {
+ sal_Int32 nLen;
+ if (bIsOctetTextEncoding)
+ {
+ rtl::OUString aOUString( aString);
+ rtl::OString aOString;
+ if (!aOUString.convertToString( &aOString, eCharSet,
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))
+ {
+ bTest = false;
+ bEncErr = true;
+ }
+ nLen = aOString.getLength();
+#if OSL_DEBUG_LEVEL > 1
+ if (!bTest)
+ fprintf( stderr, "ScDocShell::DBaseExport encoding error, string with default replacements: ``%s''\n",
+ OUStringToOString( aOUString, eCharSet).getStr());
+#endif
+ }
+ else
+ nLen = aString.Len() * sizeof(sal_Unicode);
+ if (!bEncErr &&
+ pColTypes[nCol] != sdbc::DataType::LONGVARCHAR &&
+ pColLengths[nCol] < nLen)
+ {
+ bTest = false;
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "ScDocShell::DBaseExport: field width: %d, encoded length: %d\n",
+ (int)pColLengths[nCol], (int)nLen);
+#endif
+ }
+ }
+ else
+ bTest = true;
+ }
+ String sPosition( ScAddress( nDocCol, nDocRow, nTab).GetColRowString());
+ String sEncoding( SvxTextEncodingTable().GetTextString( eCharSet));
+ nErr = *new TwoStringErrorInfo( (bEncErr ? SCERR_EXPORT_ENCODING :
+ SCERR_EXPORT_FIELDWIDTH), sPosition, sEncoding,
+ ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR);
+ }
+ else if ( aException.Message.getLength() )
+ nErr = *new StringErrorInfo( (SCERR_EXPORT_SQLEXCEPTION), aException.Message, ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR);
+ else
+ nErr = SCERR_EXPORT_DATA;
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR("Unexpected exception in database");
+ nErr = ERRCODE_IO_GENERAL;
+ }
+
+ return nErr;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/docshimp.hxx b/sc/source/ui/docshell/docshimp.hxx
new file mode 100644
index 000000000000..492e333d2e89
--- /dev/null
+++ b/sc/source/ui/docshell/docshimp.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_DOCSHELLIMP_HXX
+#define SC_DOCSHELLIMP_HXX
+
+#include <svtools/ctrltool.hxx>
+#include <sfx2/docinsert.hxx>
+#include <sfx2/request.hxx>
+
+struct DocShell_Impl
+{
+ bool bIgnoreLostRedliningWarning;
+ FontList* pFontList;
+ sfx2::DocumentInserter* pDocInserter;
+ SfxRequest* pRequest;
+
+ DocShell_Impl() :
+ bIgnoreLostRedliningWarning( false )
+ , pFontList( NULL )
+ , pDocInserter( NULL )
+ , pRequest( NULL )
+ {}
+
+ ~DocShell_Impl()
+ {
+ delete pFontList;
+ delete pDocInserter;
+ delete pRequest;
+ }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/editable.cxx b/sc/source/ui/docshell/editable.cxx
new file mode 100644
index 000000000000..7ebd9de1d1bd
--- /dev/null
+++ b/sc/source/ui/docshell/editable.cxx
@@ -0,0 +1,164 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "editable.hxx"
+#include "document.hxx"
+#include "viewfunc.hxx"
+#include "globstr.hrc"
+
+//------------------------------------------------------------------
+
+ScEditableTester::ScEditableTester() :
+ bIsEditable( TRUE ),
+ bOnlyMatrix( TRUE )
+{
+}
+
+ScEditableTester::ScEditableTester( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow ) :
+ bIsEditable( TRUE ),
+ bOnlyMatrix( TRUE )
+{
+ TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+}
+
+ScEditableTester::ScEditableTester( ScDocument* pDoc,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ const ScMarkData& rMark ) :
+ bIsEditable( TRUE ),
+ bOnlyMatrix( TRUE )
+{
+ TestSelectedBlock( pDoc, nStartCol, nStartRow, nEndCol, nEndRow, rMark );
+}
+
+ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScRange& rRange ) :
+ bIsEditable( TRUE ),
+ bOnlyMatrix( TRUE )
+{
+ TestRange( pDoc, rRange );
+}
+
+ScEditableTester::ScEditableTester( ScDocument* pDoc, const ScMarkData& rMark ) :
+ bIsEditable( TRUE ),
+ bOnlyMatrix( TRUE )
+{
+ TestSelection( pDoc, rMark );
+}
+
+ScEditableTester::ScEditableTester( ScViewFunc* pView ) :
+ bIsEditable( TRUE ),
+ bOnlyMatrix( TRUE )
+{
+ TestView( pView );
+}
+
+//------------------------------------------------------------------
+
+void ScEditableTester::TestBlock( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
+{
+ if ( bIsEditable || bOnlyMatrix )
+ {
+ BOOL bThisMatrix;
+ if ( !pDoc->IsBlockEditable( nTab, nStartCol, nStartRow, nEndCol, nEndRow, &bThisMatrix ) )
+ {
+ bIsEditable = FALSE;
+ if ( !bThisMatrix )
+ bOnlyMatrix = FALSE;
+ }
+ }
+}
+
+void ScEditableTester::TestSelectedBlock( ScDocument* pDoc,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ const ScMarkData& rMark )
+{
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (rMark.GetTableSelect(nTab))
+ TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+}
+
+void ScEditableTester::TestRange( ScDocument* pDoc, const ScRange& rRange )
+{
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCTAB nStartTab = rRange.aStart.Tab();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nEndTab = rRange.aEnd.Tab();
+ for (SCTAB nTab=nStartTab; nTab<=nEndTab; nTab++)
+ TestBlock( pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+}
+
+void ScEditableTester::TestSelection( ScDocument* pDoc, const ScMarkData& rMark )
+{
+ if ( bIsEditable || bOnlyMatrix )
+ {
+ BOOL bThisMatrix;
+ if ( !pDoc->IsSelectionEditable( rMark, &bThisMatrix ) )
+ {
+ bIsEditable = FALSE;
+ if ( !bThisMatrix )
+ bOnlyMatrix = FALSE;
+ }
+ }
+}
+
+void ScEditableTester::TestView( ScViewFunc* pView )
+{
+ if ( bIsEditable || bOnlyMatrix )
+ {
+ BOOL bThisMatrix;
+ if ( !pView->SelectionEditable( &bThisMatrix ) )
+ {
+ bIsEditable = FALSE;
+ if ( !bThisMatrix )
+ bOnlyMatrix = FALSE;
+ }
+ }
+}
+
+//------------------------------------------------------------------
+
+USHORT ScEditableTester::GetMessageId() const
+{
+ if (bIsEditable)
+ return 0;
+ else if (bOnlyMatrix)
+ return STR_MATRIXFRAGMENTERR;
+ else
+ return STR_PROTECTIONERR;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
new file mode 100644
index 000000000000..c0fc2fbfa215
--- /dev/null
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -0,0 +1,2555 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "externalrefmgr.hxx"
+#include "document.hxx"
+#include "token.hxx"
+#include "tokenarray.hxx"
+#include "address.hxx"
+#include "tablink.hxx"
+#include "docsh.hxx"
+#include "scextopt.hxx"
+#include "rangenam.hxx"
+#include "cell.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+
+#include "sfx2/app.hxx"
+#include "sfx2/docfilt.hxx"
+#include "sfx2/docfile.hxx"
+#include "sfx2/fcontnr.hxx"
+#include "sfx2/sfxsids.hrc"
+#include "sfx2/objsh.hxx"
+#include "svl/broadcast.hxx"
+#include "svl/smplhint.hxx"
+#include "svl/itemset.hxx"
+#include "svl/stritem.hxx"
+#include "svl/urihelper.hxx"
+#include "svl/zformat.hxx"
+#include "sfx2/linkmgr.hxx"
+#include "tools/urlobj.hxx"
+#include "unotools/ucbhelper.hxx"
+
+#include <memory>
+#include <algorithm>
+
+#include <boost/scoped_ptr.hpp>
+
+using ::std::auto_ptr;
+using ::com::sun::star::uno::Any;
+using ::rtl::OUString;
+using ::std::vector;
+using ::std::find;
+using ::std::find_if;
+using ::std::distance;
+using ::std::pair;
+using ::std::list;
+using ::std::unary_function;
+using namespace formula;
+
+#define SRCDOC_LIFE_SPAN 6000 // 1 minute (in 100th of a sec)
+#define SRCDOC_SCAN_INTERVAL 1000*5 // every 5 seconds (in msec)
+
+namespace {
+
+class TabNameSearchPredicate : public unary_function<bool, ScExternalRefCache::TableName>
+{
+public:
+ explicit TabNameSearchPredicate(const String& rSearchName) :
+ maSearchName(ScGlobal::pCharClass->upper(rSearchName))
+ {
+ }
+
+ bool operator()(const ScExternalRefCache::TableName& rTabNameSet) const
+ {
+ // Ok, I'm doing case insensitive search here.
+ return rTabNameSet.maUpperName.Equals(maSearchName);
+ }
+
+private:
+ String maSearchName;
+};
+
+class FindSrcFileByName : public unary_function<ScExternalRefManager::SrcFileData, bool>
+{
+public:
+ FindSrcFileByName(const String& rMatchName) :
+ mrMatchName(rMatchName)
+ {
+ }
+
+ bool operator()(const ScExternalRefManager::SrcFileData& rSrcData) const
+ {
+ return rSrcData.maFileName.Equals(mrMatchName);
+ }
+
+private:
+ const String& mrMatchName;
+};
+
+class NotifyLinkListener : public unary_function<ScExternalRefManager::LinkListener*, void>
+{
+public:
+ NotifyLinkListener(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType) :
+ mnFileId(nFileId), meType(eType) {}
+
+ NotifyLinkListener(const NotifyLinkListener& r) :
+ mnFileId(r.mnFileId), meType(r.meType) {}
+
+ void operator() (ScExternalRefManager::LinkListener* p) const
+ {
+ p->notify(mnFileId, meType);
+ }
+private:
+ sal_uInt16 mnFileId;
+ ScExternalRefManager::LinkUpdateType meType;
+};
+
+struct UpdateFormulaCell : public unary_function<ScFormulaCell*, void>
+{
+ void operator() (ScFormulaCell* pCell) const
+ {
+ // Check to make sure the cell really contains ocExternalRef.
+ // External names, external cell and range references all have a
+ // ocExternalRef token.
+ const ScTokenArray* pCode = pCell->GetCode();
+ if (!pCode->HasExternalRef())
+ return;
+
+ ScTokenArray* pArray = pCell->GetCode();
+ if (pArray)
+ // Clear the error code, or a cell with error won't get re-compiled.
+ pArray->SetCodeError(0);
+
+ pCell->SetCompile(true);
+ pCell->CompileTokenArray();
+ pCell->SetDirty();
+ }
+};
+
+class RemoveFormulaCell : public unary_function<pair<const sal_uInt16, ScExternalRefManager::RefCellSet>, void>
+{
+public:
+ explicit RemoveFormulaCell(ScFormulaCell* p) : mpCell(p) {}
+ void operator() (pair<const sal_uInt16, ScExternalRefManager::RefCellSet>& r) const
+ {
+ r.second.erase(mpCell);
+ }
+private:
+ ScFormulaCell* mpCell;
+};
+
+class ConvertFormulaToStatic : public unary_function<ScFormulaCell*, void>
+{
+public:
+ explicit ConvertFormulaToStatic(ScDocument* pDoc) : mpDoc(pDoc) {}
+ void operator() (ScFormulaCell* pCell) const
+ {
+ ScAddress aPos = pCell->aPos;
+
+ // We don't check for empty cells because empty external cells are
+ // treated as having a value of 0.
+
+ if (pCell->IsValue())
+ {
+ // Turn this into value cell.
+ double fVal = pCell->GetValue();
+ mpDoc->PutCell(aPos, new ScValueCell(fVal));
+ }
+ else
+ {
+ // string cell otherwise.
+ String aVal;
+ pCell->GetString(aVal);
+ mpDoc->PutCell(aPos, new ScStringCell(aVal));
+ }
+ }
+private:
+ ScDocument* mpDoc;
+};
+
+}
+
+// ============================================================================
+
+ScExternalRefCache::Table::Table()
+ : meReferenced( REFERENCED_MARKED )
+ // Prevent accidental data loss due to lack of knowledge.
+{
+}
+
+ScExternalRefCache::Table::~Table()
+{
+}
+
+void ScExternalRefCache::Table::setReferencedFlag( ScExternalRefCache::Table::ReferencedFlag eFlag )
+{
+ meReferenced = eFlag;
+}
+
+void ScExternalRefCache::Table::setReferenced( bool bReferenced )
+{
+ if (meReferenced != REFERENCED_PERMANENT)
+ meReferenced = (bReferenced ? REFERENCED_MARKED : UNREFERENCED);
+}
+
+ScExternalRefCache::Table::ReferencedFlag ScExternalRefCache::Table::getReferencedFlag() const
+{
+ return meReferenced;
+}
+
+bool ScExternalRefCache::Table::isReferenced() const
+{
+ return meReferenced != UNREFERENCED;
+}
+
+void ScExternalRefCache::Table::setCell(SCCOL nCol, SCROW nRow, TokenRef pToken, sal_uInt32 nFmtIndex, bool bSetCacheRange)
+{
+ using ::std::pair;
+ RowsDataType::iterator itrRow = maRows.find(nRow);
+ if (itrRow == maRows.end())
+ {
+ // This row does not exist yet.
+ pair<RowsDataType::iterator, bool> res = maRows.insert(
+ RowsDataType::value_type(nRow, RowDataType()));
+
+ if (!res.second)
+ return;
+
+ itrRow = res.first;
+ }
+
+ // Insert this token into the specified column location. I don't need to
+ // check for existing data. Just overwrite it.
+ RowDataType& rRow = itrRow->second;
+ ScExternalRefCache::Cell aCell;
+ aCell.mxToken = pToken;
+ aCell.mnFmtIndex = nFmtIndex;
+ rRow.insert(RowDataType::value_type(nCol, aCell));
+ if (bSetCacheRange)
+ setCachedCell(nCol, nRow);
+}
+
+ScExternalRefCache::TokenRef ScExternalRefCache::Table::getCell(SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex) const
+{
+ RowsDataType::const_iterator itrTable = maRows.find(nRow);
+ if (itrTable == maRows.end())
+ {
+ // this table doesn't have the specified row.
+ return getEmptyOrNullToken(nCol, nRow);
+ }
+
+ const RowDataType& rRowData = itrTable->second;
+ RowDataType::const_iterator itrRow = rRowData.find(nCol);
+ if (itrRow == rRowData.end())
+ {
+ // this row doesn't have the specified column.
+ return getEmptyOrNullToken(nCol, nRow);
+ }
+
+ const Cell& rCell = itrRow->second;
+ if (pnFmtIndex)
+ *pnFmtIndex = rCell.mnFmtIndex;
+
+ return rCell.mxToken;
+}
+
+bool ScExternalRefCache::Table::hasRow( SCROW nRow ) const
+{
+ RowsDataType::const_iterator itrRow = maRows.find(nRow);
+ return itrRow != maRows.end();
+}
+
+void ScExternalRefCache::Table::getAllRows(vector<SCROW>& rRows, SCROW nLow, SCROW nHigh) const
+{
+ vector<SCROW> aRows;
+ aRows.reserve(maRows.size());
+ RowsDataType::const_iterator itr = maRows.begin(), itrEnd = maRows.end();
+ for (; itr != itrEnd; ++itr)
+ if (nLow <= itr->first && itr->first <= nHigh)
+ aRows.push_back(itr->first);
+
+ // hash map is not ordered, so we need to explicitly sort it.
+ ::std::sort(aRows.begin(), aRows.end());
+ rRows.swap(aRows);
+}
+
+::std::pair< SCROW, SCROW > ScExternalRefCache::Table::getRowRange() const
+{
+ ::std::pair< SCROW, SCROW > aRange( 0, 0 );
+ if( !maRows.empty() )
+ {
+ // iterate over entire container (hash map is not sorted by key)
+ RowsDataType::const_iterator itr = maRows.begin(), itrEnd = maRows.end();
+ aRange.first = itr->first;
+ aRange.second = itr->first + 1;
+ while( ++itr != itrEnd )
+ {
+ if( itr->first < aRange.first )
+ aRange.first = itr->first;
+ else if( itr->first >= aRange.second )
+ aRange.second = itr->first + 1;
+ }
+ }
+ return aRange;
+}
+
+void ScExternalRefCache::Table::getAllCols(SCROW nRow, vector<SCCOL>& rCols, SCCOL nLow, SCCOL nHigh) const
+{
+ RowsDataType::const_iterator itrRow = maRows.find(nRow);
+ if (itrRow == maRows.end())
+ // this table doesn't have the specified row.
+ return;
+
+ const RowDataType& rRowData = itrRow->second;
+ vector<SCCOL> aCols;
+ aCols.reserve(rRowData.size());
+ RowDataType::const_iterator itrCol = rRowData.begin(), itrColEnd = rRowData.end();
+ for (; itrCol != itrColEnd; ++itrCol)
+ if (nLow <= itrCol->first && itrCol->first <= nHigh)
+ aCols.push_back(itrCol->first);
+
+ // hash map is not ordered, so we need to explicitly sort it.
+ ::std::sort(aCols.begin(), aCols.end());
+ rCols.swap(aCols);
+}
+
+::std::pair< SCCOL, SCCOL > ScExternalRefCache::Table::getColRange( SCROW nRow ) const
+{
+ ::std::pair< SCCOL, SCCOL > aRange( 0, 0 );
+
+ RowsDataType::const_iterator itrRow = maRows.find( nRow );
+ if (itrRow == maRows.end())
+ // this table doesn't have the specified row.
+ return aRange;
+
+ const RowDataType& rRowData = itrRow->second;
+ if( !rRowData.empty() )
+ {
+ // iterate over entire container (hash map is not sorted by key)
+ RowDataType::const_iterator itr = rRowData.begin(), itrEnd = rRowData.end();
+ aRange.first = itr->first;
+ aRange.second = itr->first + 1;
+ while( ++itr != itrEnd )
+ {
+ if( itr->first < aRange.first )
+ aRange.first = itr->first;
+ else if( itr->first >= aRange.second )
+ aRange.second = itr->first + 1;
+ }
+ }
+ return aRange;
+}
+
+void ScExternalRefCache::Table::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const
+{
+ RowsDataType::const_iterator itrRow = maRows.begin(), itrRowEnd = maRows.end();
+ for (; itrRow != itrRowEnd; ++itrRow)
+ {
+ const RowDataType& rRowData = itrRow->second;
+ RowDataType::const_iterator itrCol = rRowData.begin(), itrColEnd = rRowData.end();
+ for (; itrCol != itrColEnd; ++itrCol)
+ {
+ const Cell& rCell = itrCol->second;
+ rNumFmts.push_back(rCell.mnFmtIndex);
+ }
+ }
+}
+
+const ScRangeList& ScExternalRefCache::Table::getCachedRanges() const
+{
+ return maCachedRanges;
+}
+
+bool ScExternalRefCache::Table::isRangeCached(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2) const
+{
+ return maCachedRanges.In(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
+}
+
+void ScExternalRefCache::Table::setCachedCell(SCCOL nCol, SCROW nRow)
+{
+ setCachedCellRange(nCol, nRow, nCol, nRow);
+}
+
+void ScExternalRefCache::Table::setCachedCellRange(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2)
+{
+ ScRange aRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
+ if (!maCachedRanges.Count())
+ maCachedRanges.Append(aRange);
+ else
+ maCachedRanges.Join(aRange);
+
+ String aStr;
+ maCachedRanges.Format(aStr, SCA_VALID);
+}
+
+void ScExternalRefCache::Table::setWholeTableCached()
+{
+ setCachedCellRange(0, 0, MAXCOL, MAXROW);
+}
+
+bool ScExternalRefCache::Table::isInCachedRanges(SCCOL nCol, SCROW nRow) const
+{
+ return maCachedRanges.In(ScRange(nCol, nRow, 0, nCol, nRow, 0));
+}
+
+ScExternalRefCache::TokenRef ScExternalRefCache::Table::getEmptyOrNullToken(
+ SCCOL nCol, SCROW nRow) const
+{
+ if (isInCachedRanges(nCol, nRow))
+ {
+ TokenRef p(new ScEmptyCellToken(false, false));
+ return p;
+ }
+ return TokenRef();
+}
+
+// ----------------------------------------------------------------------------
+
+ScExternalRefCache::TableName::TableName(const String& rUpper, const String& rReal) :
+ maUpperName(rUpper), maRealName(rReal)
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScExternalRefCache::CellFormat::CellFormat() :
+ mbIsSet(false), mnType(NUMBERFORMAT_ALL), mnIndex(0)
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScExternalRefCache::ScExternalRefCache()
+{
+}
+ScExternalRefCache::~ScExternalRefCache()
+{
+}
+
+const String* ScExternalRefCache::getRealTableName(sal_uInt16 nFileId, const String& rTabName) const
+{
+ DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ {
+ // specified document is not cached.
+ return NULL;
+ }
+
+ const DocItem& rDoc = itrDoc->second;
+ TableNameIndexMap::const_iterator itrTabId = rDoc.maTableNameIndex.find(
+ ScGlobal::pCharClass->upper(rTabName));
+ if (itrTabId == rDoc.maTableNameIndex.end())
+ {
+ // the specified table is not in cache.
+ return NULL;
+ }
+
+ return &rDoc.maTableNames[itrTabId->second].maRealName;
+}
+
+const String* ScExternalRefCache::getRealRangeName(sal_uInt16 nFileId, const String& rRangeName) const
+{
+ DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ {
+ // specified document is not cached.
+ return NULL;
+ }
+
+ const DocItem& rDoc = itrDoc->second;
+ NamePairMap::const_iterator itr = rDoc.maRealRangeNameMap.find(
+ ScGlobal::pCharClass->upper(rRangeName));
+ if (itr == rDoc.maRealRangeNameMap.end())
+ // range name not found.
+ return NULL;
+
+ return &itr->second;
+}
+
+ScExternalRefCache::TokenRef ScExternalRefCache::getCellData(
+ sal_uInt16 nFileId, const String& rTabName, SCCOL nCol, SCROW nRow, sal_uInt32* pnFmtIndex)
+{
+ DocDataType::const_iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ {
+ // specified document is not cached.
+ return TokenRef();
+ }
+
+ const DocItem& rDoc = itrDoc->second;
+ TableNameIndexMap::const_iterator itrTabId = rDoc.maTableNameIndex.find(
+ ScGlobal::pCharClass->upper(rTabName));
+ if (itrTabId == rDoc.maTableNameIndex.end())
+ {
+ // the specified table is not in cache.
+ return TokenRef();
+ }
+
+ const TableTypeRef& pTableData = rDoc.maTables[itrTabId->second];
+ if (!pTableData.get())
+ {
+ // the table data is not instantiated yet.
+ return TokenRef();
+ }
+
+ return pTableData->getCell(nCol, nRow, pnFmtIndex);
+}
+
+ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
+ sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange)
+{
+ DocDataType::iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ // specified document is not cached.
+ return TokenArrayRef();
+
+ DocItem& rDoc = itrDoc->second;
+
+ TableNameIndexMap::iterator itrTabId = rDoc.maTableNameIndex.find(
+ ScGlobal::pCharClass->upper(rTabName));
+ if (itrTabId == rDoc.maTableNameIndex.end())
+ // the specified table is not in cache.
+ return TokenArrayRef();
+
+ const ScAddress& s = rRange.aStart;
+ const ScAddress& e = rRange.aEnd;
+
+ SCTAB nTab1 = s.Tab(), nTab2 = e.Tab();
+ SCCOL nCol1 = s.Col(), nCol2 = e.Col();
+ SCROW nRow1 = s.Row(), nRow2 = e.Row();
+
+ // Make sure I have all the tables cached.
+ size_t nTabFirstId = itrTabId->second;
+ size_t nTabLastId = nTabFirstId + nTab2 - nTab1;
+ if (nTabLastId >= rDoc.maTables.size())
+ // not all tables are cached.
+ return TokenArrayRef();
+
+ ScRange aCacheRange( nCol1, nRow1, static_cast<SCTAB>(nTabFirstId), nCol2, nRow2, static_cast<SCTAB>(nTabLastId));
+
+ RangeArrayMap::const_iterator itrRange = rDoc.maRangeArrays.find( aCacheRange);
+ if (itrRange != rDoc.maRangeArrays.end())
+ // Cache hit!
+ return itrRange->second;
+
+ ::boost::scoped_ptr<ScRange> pNewRange;
+ TokenArrayRef pArray;
+ bool bFirstTab = true;
+ for (size_t nTab = nTabFirstId; nTab <= nTabLastId; ++nTab)
+ {
+ TableTypeRef pTab = rDoc.maTables[nTab];
+ if (!pTab.get())
+ return TokenArrayRef();
+
+ SCCOL nDataCol1 = nCol1, nDataCol2 = nCol2;
+ SCROW nDataRow1 = nRow1, nDataRow2 = nRow2;
+
+ if (!pTab->isRangeCached(nDataCol1, nDataRow1, nDataCol2, nDataRow2))
+ {
+ // specified range is not entirely within cached ranges.
+ return TokenArrayRef();
+ }
+
+ ScMatrixRef xMat = new ScMatrix(
+ static_cast<SCSIZE>(nDataCol2-nDataCol1+1), static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
+
+#if 0
+ // TODO: Switch to this code block once we have support for sparsely-filled
+ // matrices in ScMatrix.
+
+ // Only fill non-empty cells, for better performance.
+ vector<SCROW> aRows;
+ pTab->getAllRows(aRows, nDataRow1, nDataRow2);
+ for (vector<SCROW>::const_iterator itr = aRows.begin(), itrEnd = aRows.end(); itr != itrEnd; ++itr)
+ {
+ SCROW nRow = *itr;
+ vector<SCCOL> aCols;
+ pTab->getAllCols(nRow, aCols, nDataCol1, nDataCol2);
+ for (vector<SCCOL>::const_iterator itrCol = aCols.begin(), itrColEnd = aCols.end(); itrCol != itrColEnd; ++itrCol)
+ {
+ SCCOL nCol = *itrCol;
+ TokenRef pToken = pTab->getCell(nCol, nRow);
+ if (!pToken)
+ // This should never happen!
+ return TokenArrayRef();
+
+ SCSIZE nC = nCol - nDataCol1, nR = nRow - nDataRow1;
+ switch (pToken->GetType())
+ {
+ case svDouble:
+ xMat->PutDouble(pToken->GetDouble(), nC, nR);
+ break;
+ case svString:
+ xMat->PutString(pToken->GetString(), nC, nR);
+ break;
+ default:
+ ;
+ }
+ }
+ }
+#else
+ vector<SCROW> aRows;
+ pTab->getAllRows(aRows, nDataRow1, nDataRow2);
+ if (aRows.empty())
+ // Cache is empty.
+ return TokenArrayRef();
+ else
+ // Trim the column below the last non-empty row.
+ nDataRow2 = aRows.back();
+
+ // Empty all matrix elements first, and fill only non-empty elements.
+ for (SCROW nRow = nDataRow1; nRow <= nDataRow2; ++nRow)
+ {
+ for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
+ {
+ TokenRef pToken = pTab->getCell(nCol, nRow);
+ SCSIZE nC = nCol - nCol1, nR = nRow - nRow1;
+ if (!pToken)
+ return TokenArrayRef();
+
+ switch (pToken->GetType())
+ {
+ case svDouble:
+ xMat->PutDouble(pToken->GetDouble(), nC, nR);
+ break;
+ case svString:
+ xMat->PutString(pToken->GetString(), nC, nR);
+ break;
+ default:
+ xMat->PutEmpty(nC, nR);
+ }
+ }
+ }
+#endif
+
+ if (!bFirstTab)
+ pArray->AddOpCode(ocSep);
+
+ ScMatrix* pMat2 = xMat;
+ ScMatrixToken aToken(pMat2);
+ if (!pArray)
+ pArray.reset(new ScTokenArray);
+ pArray->AddToken(aToken);
+
+ bFirstTab = false;
+
+ if (!pNewRange)
+ pNewRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
+ else
+ pNewRange->ExtendTo(ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
+ }
+
+ if (pNewRange)
+ rDoc.maRangeArrays.insert( RangeArrayMap::value_type(*pNewRange, pArray));
+ return pArray;
+}
+
+ScExternalRefCache::TokenArrayRef ScExternalRefCache::getRangeNameTokens(sal_uInt16 nFileId, const String& rName)
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return TokenArrayRef();
+
+ RangeNameMap& rMap = pDoc->maRangeNames;
+ RangeNameMap::const_iterator itr = rMap.find(
+ ScGlobal::pCharClass->upper(rName));
+ if (itr == rMap.end())
+ return TokenArrayRef();
+
+ return itr->second;
+}
+
+void ScExternalRefCache::setRangeNameTokens(sal_uInt16 nFileId, const String& rName, TokenArrayRef pArray)
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return;
+
+ String aUpperName = ScGlobal::pCharClass->upper(rName);
+ RangeNameMap& rMap = pDoc->maRangeNames;
+ rMap.insert(RangeNameMap::value_type(aUpperName, pArray));
+ pDoc->maRealRangeNameMap.insert(NamePairMap::value_type(aUpperName, rName));
+}
+
+void ScExternalRefCache::setCellData(sal_uInt16 nFileId, const String& rTabName, SCCOL nCol, SCROW nRow,
+ TokenRef pToken, sal_uInt32 nFmtIndex)
+{
+ if (!isDocInitialized(nFileId))
+ return;
+
+ using ::std::pair;
+ DocItem* pDocItem = getDocItem(nFileId);
+ if (!pDocItem)
+ return;
+
+ DocItem& rDoc = *pDocItem;
+
+ // See if the table by this name already exists.
+ TableNameIndexMap::iterator itrTabName = rDoc.maTableNameIndex.find(
+ ScGlobal::pCharClass->upper(rTabName));
+ if (itrTabName == rDoc.maTableNameIndex.end())
+ // Table not found. Maybe the table name or the file id is wrong ???
+ return;
+
+ TableTypeRef& pTableData = rDoc.maTables[itrTabName->second];
+ if (!pTableData.get())
+ pTableData.reset(new Table);
+
+ pTableData->setCell(nCol, nRow, pToken, nFmtIndex);
+ pTableData->setCachedCell(nCol, nRow);
+}
+
+void ScExternalRefCache::setCellRangeData(sal_uInt16 nFileId, const ScRange& rRange, const vector<SingleRangeData>& rData,
+ TokenArrayRef pArray)
+{
+ using ::std::pair;
+ if (rData.empty() || !isDocInitialized(nFileId))
+ // nothing to cache
+ return;
+
+ // First, get the document item for the given file ID.
+ DocItem* pDocItem = getDocItem(nFileId);
+ if (!pDocItem)
+ return;
+
+ DocItem& rDoc = *pDocItem;
+
+ // Now, find the table position of the first table to cache.
+ const String& rFirstTabName = rData.front().maTableName;
+ TableNameIndexMap::iterator itrTabName = rDoc.maTableNameIndex.find(
+ ScGlobal::pCharClass->upper(rFirstTabName));
+ if (itrTabName == rDoc.maTableNameIndex.end())
+ {
+ // table index not found.
+ return;
+ }
+
+ size_t nTabFirstId = itrTabName->second;
+ SCROW nRow1 = rRange.aStart.Row(), nRow2 = rRange.aEnd.Row();
+ SCCOL nCol1 = rRange.aStart.Col(), nCol2 = rRange.aEnd.Col();
+ vector<SingleRangeData>::const_iterator itrDataBeg = rData.begin(), itrDataEnd = rData.end();
+ for (vector<SingleRangeData>::const_iterator itrData = itrDataBeg; itrData != itrDataEnd; ++itrData)
+ {
+ size_t i = nTabFirstId + ::std::distance(itrDataBeg, itrData);
+ TableTypeRef& pTabData = rDoc.maTables[i];
+ if (!pTabData.get())
+ pTabData.reset(new Table);
+
+ for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
+ {
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+ {
+ SCSIZE nC = nCol - nCol1, nR = nRow - nRow1;
+ TokenRef pToken;
+ const ScMatrixRef& pMat = itrData->mpRangeData;
+ if (pMat->IsEmpty(nC, nR))
+ // Don't cache empty cells.
+ continue;
+
+ if (pMat->IsValue(nC, nR))
+ pToken.reset(new formula::FormulaDoubleToken(pMat->GetDouble(nC, nR)));
+ else if (pMat->IsString(nC, nR))
+ pToken.reset(new formula::FormulaStringToken(pMat->GetString(nC, nR)));
+
+ if (pToken)
+ // Don't mark this cell 'cached' here, for better performance.
+ pTabData->setCell(nCol, nRow, pToken, 0, false);
+ }
+ }
+ // Mark the whole range 'cached'.
+ pTabData->setCachedCellRange(nCol1, nRow1, nCol2, nRow2);
+ }
+
+ size_t nTabLastId = nTabFirstId + rRange.aEnd.Tab() - rRange.aStart.Tab();
+ ScRange aCacheRange( nCol1, nRow1, static_cast<SCTAB>(nTabFirstId), nCol2, nRow2, static_cast<SCTAB>(nTabLastId));
+
+ rDoc.maRangeArrays.insert( RangeArrayMap::value_type( aCacheRange, pArray));
+}
+
+bool ScExternalRefCache::isDocInitialized(sal_uInt16 nFileId)
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return false;
+
+ return pDoc->mbInitFromSource;
+}
+
+static bool lcl_getTableDataIndex(const ScExternalRefCache::TableNameIndexMap& rMap, const String& rName, size_t& rIndex)
+{
+ ScExternalRefCache::TableNameIndexMap::const_iterator itr = rMap.find(rName);
+ if (itr == rMap.end())
+ return false;
+
+ rIndex = itr->second;
+ return true;
+}
+
+void ScExternalRefCache::initializeDoc(sal_uInt16 nFileId, const vector<String>& rTabNames)
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return;
+
+ size_t n = rTabNames.size();
+
+ // table name list - the list must include all table names in the source
+ // document and only to be populated when loading the source document, not
+ // when loading cached data from, say, Excel XCT/CRN records.
+ vector<TableName> aNewTabNames;
+ aNewTabNames.reserve(n);
+ for (vector<String>::const_iterator itr = rTabNames.begin(), itrEnd = rTabNames.end();
+ itr != itrEnd; ++itr)
+ {
+ TableName aNameItem(ScGlobal::pCharClass->upper(*itr), *itr);
+ aNewTabNames.push_back(aNameItem);
+ }
+ pDoc->maTableNames.swap(aNewTabNames);
+
+ // data tables - preserve any existing data that may have been set during
+ // file import.
+ vector<TableTypeRef> aNewTables(n);
+ for (size_t i = 0; i < n; ++i)
+ {
+ size_t nIndex;
+ if (lcl_getTableDataIndex(pDoc->maTableNameIndex, pDoc->maTableNames[i].maUpperName, nIndex))
+ {
+ aNewTables[i] = pDoc->maTables[nIndex];
+ }
+ }
+ pDoc->maTables.swap(aNewTables);
+
+ // name index map
+ TableNameIndexMap aNewNameIndex;
+ for (size_t i = 0; i < n; ++i)
+ aNewNameIndex.insert(TableNameIndexMap::value_type(pDoc->maTableNames[i].maUpperName, i));
+ pDoc->maTableNameIndex.swap(aNewNameIndex);
+
+ pDoc->mbInitFromSource = true;
+}
+
+String ScExternalRefCache::getTableName(sal_uInt16 nFileId, size_t nCacheId) const
+{
+ if( DocItem* pDoc = getDocItem( nFileId ) )
+ if( nCacheId < pDoc->maTableNames.size() )
+ return pDoc->maTableNames[ nCacheId ].maRealName;
+ return EMPTY_STRING;
+}
+
+void ScExternalRefCache::getAllTableNames(sal_uInt16 nFileId, vector<String>& rTabNames) const
+{
+ rTabNames.clear();
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return;
+
+ size_t n = pDoc->maTableNames.size();
+ rTabNames.reserve(n);
+ for (vector<TableName>::const_iterator itr = pDoc->maTableNames.begin(), itrEnd = pDoc->maTableNames.end();
+ itr != itrEnd; ++itr)
+ rTabNames.push_back(itr->maRealName);
+}
+
+SCsTAB ScExternalRefCache::getTabSpan( sal_uInt16 nFileId, const String& rStartTabName, const String& rEndTabName ) const
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return -1;
+
+ vector<TableName>::const_iterator itrBeg = pDoc->maTableNames.begin();
+ vector<TableName>::const_iterator itrEnd = pDoc->maTableNames.end();
+
+ vector<TableName>::const_iterator itrStartTab = ::std::find_if( itrBeg, itrEnd,
+ TabNameSearchPredicate( rStartTabName));
+ if (itrStartTab == itrEnd)
+ return -1;
+
+ vector<TableName>::const_iterator itrEndTab = ::std::find_if( itrBeg, itrEnd,
+ TabNameSearchPredicate( rEndTabName));
+ if (itrEndTab == itrEnd)
+ return 0;
+
+ size_t nStartDist = ::std::distance( itrBeg, itrStartTab);
+ size_t nEndDist = ::std::distance( itrBeg, itrEndTab);
+ return nStartDist <= nEndDist ? static_cast<SCsTAB>(nEndDist - nStartDist + 1) : -static_cast<SCsTAB>(nStartDist - nEndDist + 1);
+}
+
+void ScExternalRefCache::getAllNumberFormats(vector<sal_uInt32>& rNumFmts) const
+{
+ using ::std::sort;
+ using ::std::unique;
+
+ vector<sal_uInt32> aNumFmts;
+ for (DocDataType::const_iterator itrDoc = maDocs.begin(), itrDocEnd = maDocs.end();
+ itrDoc != itrDocEnd; ++itrDoc)
+ {
+ const vector<TableTypeRef>& rTables = itrDoc->second.maTables;
+ for (vector<TableTypeRef>::const_iterator itrTab = rTables.begin(), itrTabEnd = rTables.end();
+ itrTab != itrTabEnd; ++itrTab)
+ {
+ TableTypeRef pTab = *itrTab;
+ if (!pTab)
+ continue;
+
+ pTab->getAllNumberFormats(aNumFmts);
+ }
+ }
+
+ // remove duplicates.
+ sort(aNumFmts.begin(), aNumFmts.end());
+ aNumFmts.erase(unique(aNumFmts.begin(), aNumFmts.end()), aNumFmts.end());
+ rNumFmts.swap(aNumFmts);
+}
+
+bool ScExternalRefCache::hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ return false;
+
+ String aUpperName = ScGlobal::pCharClass->upper(rTabName);
+ vector<TableName>::const_iterator itrBeg = pDoc->maTableNames.begin(), itrEnd = pDoc->maTableNames.end();
+ vector<TableName>::const_iterator itr = ::std::find_if(
+ itrBeg, itrEnd, TabNameSearchPredicate(aUpperName));
+
+ return itr != itrEnd;
+}
+
+size_t ScExternalRefCache::getCacheTableCount(sal_uInt16 nFileId) const
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ return pDoc ? pDoc->maTables.size() : 0;
+}
+
+bool ScExternalRefCache::setCacheDocReferenced( sal_uInt16 nFileId )
+{
+ DocItem* pDocItem = getDocItem(nFileId);
+ if (!pDocItem)
+ return areAllCacheTablesReferenced();
+
+ for (::std::vector<TableTypeRef>::iterator itrTab = pDocItem->maTables.begin();
+ itrTab != pDocItem->maTables.end(); ++itrTab)
+ {
+ if ((*itrTab).get())
+ (*itrTab)->setReferenced( true);
+ }
+ addCacheDocToReferenced( nFileId);
+ return areAllCacheTablesReferenced();
+}
+
+bool ScExternalRefCache::setCacheTableReferenced( sal_uInt16 nFileId, const String& rTabName, size_t nSheets, bool bPermanent )
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (pDoc)
+ {
+ size_t nIndex = 0;
+ String aTabNameUpper = ScGlobal::pCharClass->upper( rTabName);
+ if (lcl_getTableDataIndex( pDoc->maTableNameIndex, aTabNameUpper, nIndex))
+ {
+ size_t nStop = ::std::min( nIndex + nSheets, pDoc->maTables.size());
+ for (size_t i = nIndex; i < nStop; ++i)
+ {
+ TableTypeRef pTab = pDoc->maTables[i];
+ if (pTab.get())
+ {
+ Table::ReferencedFlag eNewFlag = (bPermanent ?
+ Table::REFERENCED_PERMANENT :
+ Table::REFERENCED_MARKED);
+ Table::ReferencedFlag eOldFlag = pTab->getReferencedFlag();
+ if (eOldFlag != Table::REFERENCED_PERMANENT && eNewFlag != eOldFlag)
+ {
+ pTab->setReferencedFlag( eNewFlag);
+ addCacheTableToReferenced( nFileId, i);
+ }
+ }
+ }
+ }
+ }
+ return areAllCacheTablesReferenced();
+}
+
+void ScExternalRefCache::setCacheTableReferencedPermanently( sal_uInt16 nFileId, const String& rTabName, size_t nSheets )
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (pDoc)
+ {
+ size_t nIndex = 0;
+ String aTabNameUpper = ScGlobal::pCharClass->upper( rTabName);
+ if (lcl_getTableDataIndex( pDoc->maTableNameIndex, aTabNameUpper, nIndex))
+ {
+ size_t nStop = ::std::min( nIndex + nSheets, pDoc->maTables.size());
+ for (size_t i = nIndex; i < nStop; ++i)
+ {
+ TableTypeRef pTab = pDoc->maTables[i];
+ if (pTab.get())
+ pTab->setReferencedFlag( Table::REFERENCED_PERMANENT);
+ }
+ }
+ }
+}
+
+void ScExternalRefCache::setAllCacheTableReferencedStati( bool bReferenced )
+{
+ if (bReferenced)
+ {
+ maReferenced.reset(0);
+ for (DocDataType::iterator itrDoc = maDocs.begin(); itrDoc != maDocs.end(); ++itrDoc)
+ {
+ ScExternalRefCache::DocItem& rDocItem = (*itrDoc).second;
+ for (::std::vector<TableTypeRef>::iterator itrTab = rDocItem.maTables.begin();
+ itrTab != rDocItem.maTables.end(); ++itrTab)
+ {
+ if ((*itrTab).get())
+ (*itrTab)->setReferenced( true);
+ }
+ }
+ }
+ else
+ {
+ size_t nDocs = 0;
+ for (DocDataType::const_iterator itrDoc = maDocs.begin(); itrDoc != maDocs.end(); ++itrDoc)
+ {
+ if (nDocs <= (*itrDoc).first)
+ nDocs = (*itrDoc).first + 1;
+ }
+ maReferenced.reset( nDocs);
+
+ for (DocDataType::iterator itrDoc = maDocs.begin(); itrDoc != maDocs.end(); ++itrDoc)
+ {
+ ScExternalRefCache::DocItem& rDocItem = (*itrDoc).second;
+ sal_uInt16 nFileId = (*itrDoc).first;
+ size_t nTables = rDocItem.maTables.size();
+ ReferencedStatus::DocReferenced & rDocReferenced = maReferenced.maDocs[nFileId];
+ // All referenced => non-existing tables evaluate as completed.
+ rDocReferenced.maTables.resize( nTables, true);
+ for (size_t i=0; i < nTables; ++i)
+ {
+ TableTypeRef & xTab = rDocItem.maTables[i];
+ if (xTab.get())
+ {
+ if (xTab->getReferencedFlag() == Table::REFERENCED_PERMANENT)
+ addCacheTableToReferenced( nFileId, i);
+ else
+ {
+ xTab->setReferencedFlag( Table::UNREFERENCED);
+ rDocReferenced.maTables[i] = false;
+ rDocReferenced.mbAllTablesReferenced = false;
+ // An addCacheTableToReferenced() actually may have
+ // resulted in mbAllReferenced been set. Clear it.
+ maReferenced.mbAllReferenced = false;
+ }
+ }
+ }
+ }
+ }
+}
+
+void ScExternalRefCache::addCacheTableToReferenced( sal_uInt16 nFileId, size_t nIndex )
+{
+ if (nFileId >= maReferenced.maDocs.size())
+ return;
+
+ ::std::vector<bool> & rTables = maReferenced.maDocs[nFileId].maTables;
+ size_t nTables = rTables.size();
+ if (nIndex >= nTables)
+ return;
+
+ if (!rTables[nIndex])
+ {
+ rTables[nIndex] = true;
+ size_t i = 0;
+ while (i < nTables && rTables[i])
+ ++i;
+ if (i == nTables)
+ {
+ maReferenced.maDocs[nFileId].mbAllTablesReferenced = true;
+ maReferenced.checkAllDocs();
+ }
+ }
+}
+
+void ScExternalRefCache::addCacheDocToReferenced( sal_uInt16 nFileId )
+{
+ if (nFileId >= maReferenced.maDocs.size())
+ return;
+
+ if (!maReferenced.maDocs[nFileId].mbAllTablesReferenced)
+ {
+ ::std::vector<bool> & rTables = maReferenced.maDocs[nFileId].maTables;
+ size_t nSize = rTables.size();
+ for (size_t i=0; i < nSize; ++i)
+ rTables[i] = true;
+ maReferenced.maDocs[nFileId].mbAllTablesReferenced = true;
+ maReferenced.checkAllDocs();
+ }
+}
+
+bool ScExternalRefCache::areAllCacheTablesReferenced() const
+{
+ return maReferenced.mbAllReferenced;
+}
+
+ScExternalRefCache::ReferencedStatus::ReferencedStatus() :
+ mbAllReferenced(false)
+{
+ reset(0);
+}
+
+ScExternalRefCache::ReferencedStatus::ReferencedStatus( size_t nDocs ) :
+ mbAllReferenced(false)
+{
+ reset( nDocs);
+}
+
+void ScExternalRefCache::ReferencedStatus::reset( size_t nDocs )
+{
+ if (nDocs)
+ {
+ mbAllReferenced = false;
+ DocReferencedVec aRefs( nDocs);
+ maDocs.swap( aRefs);
+ }
+ else
+ {
+ mbAllReferenced = true;
+ DocReferencedVec aRefs;
+ maDocs.swap( aRefs);
+ }
+}
+
+void ScExternalRefCache::ReferencedStatus::checkAllDocs()
+{
+ for (DocReferencedVec::const_iterator itr = maDocs.begin(); itr != maDocs.end(); ++itr)
+ {
+ if (!(*itr).mbAllTablesReferenced)
+ return;
+ }
+ mbAllReferenced = true;
+}
+
+ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
+{
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc || nTabIndex >= pDoc->maTables.size())
+ return TableTypeRef();
+
+ return pDoc->maTables[nTabIndex];
+}
+
+ScExternalRefCache::TableTypeRef ScExternalRefCache::getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex)
+{
+ // In API, the index is transported as cached sheet ID of type sal_Int32 in
+ // sheet::SingleReference.Sheet or sheet::ComplexReference.Reference1.Sheet
+ // in a sheet::FormulaToken, choose a sensible value for N/A. Effectively
+ // being 0xffffffff
+ const size_t nNotAvailable = static_cast<size_t>( static_cast<sal_Int32>( -1));
+
+ DocItem* pDoc = getDocItem(nFileId);
+ if (!pDoc)
+ {
+ if (pnIndex) *pnIndex = nNotAvailable;
+ return TableTypeRef();
+ }
+
+ DocItem& rDoc = *pDoc;
+
+ size_t nIndex;
+ String aTabNameUpper = ScGlobal::pCharClass->upper(rTabName);
+ if (lcl_getTableDataIndex(rDoc.maTableNameIndex, aTabNameUpper, nIndex))
+ {
+ // specified table found.
+ if( pnIndex ) *pnIndex = nIndex;
+ if (bCreateNew && !rDoc.maTables[nIndex])
+ rDoc.maTables[nIndex].reset(new Table);
+
+ return rDoc.maTables[nIndex];
+ }
+
+ if (!bCreateNew)
+ {
+ if (pnIndex) *pnIndex = nNotAvailable;
+ return TableTypeRef();
+ }
+
+ // Specified table doesn't exist yet. Create one.
+ nIndex = rDoc.maTables.size();
+ if( pnIndex ) *pnIndex = nIndex;
+ TableTypeRef pTab(new Table);
+ rDoc.maTables.push_back(pTab);
+ rDoc.maTableNames.push_back(TableName(aTabNameUpper, rTabName));
+ rDoc.maTableNameIndex.insert(
+ TableNameIndexMap::value_type(aTabNameUpper, nIndex));
+ return pTab;
+}
+
+void ScExternalRefCache::clearCache(sal_uInt16 nFileId)
+{
+ maDocs.erase(nFileId);
+}
+
+ScExternalRefCache::DocItem* ScExternalRefCache::getDocItem(sal_uInt16 nFileId) const
+{
+ using ::std::pair;
+ DocDataType::iterator itrDoc = maDocs.find(nFileId);
+ if (itrDoc == maDocs.end())
+ {
+ // specified document is not cached.
+ pair<DocDataType::iterator, bool> res = maDocs.insert(
+ DocDataType::value_type(nFileId, DocItem()));
+
+ if (!res.second)
+ // insertion failed.
+ return NULL;
+
+ itrDoc = res.first;
+ }
+
+ return &itrDoc->second;
+}
+
+// ============================================================================
+
+ScExternalRefLink::ScExternalRefLink(ScDocument* pDoc, sal_uInt16 nFileId, const String& rFilter) :
+ ::sfx2::SvBaseLink(::sfx2::LINKUPDATE_ONCALL, FORMAT_FILE),
+ mnFileId(nFileId),
+ maFilterName(rFilter),
+ mpDoc(pDoc),
+ mbDoRefresh(true)
+{
+}
+
+ScExternalRefLink::~ScExternalRefLink()
+{
+}
+
+void ScExternalRefLink::Closed()
+{
+ ScExternalRefManager* pMgr = mpDoc->GetExternalRefManager();
+ pMgr->breakLink(mnFileId);
+}
+
+void ScExternalRefLink::DataChanged(const String& /*rMimeType*/, const Any& /*rValue*/)
+{
+ if (!mbDoRefresh)
+ return;
+
+ String aFile, aFilter;
+ mpDoc->GetLinkManager()->GetDisplayNames(this, NULL, &aFile, NULL, &aFilter);
+ ScExternalRefManager* pMgr = mpDoc->GetExternalRefManager();
+ const String* pCurFile = pMgr->getExternalFileName(mnFileId);
+ if (!pCurFile)
+ return;
+
+ if (pCurFile->Equals(aFile))
+ {
+ // Refresh the current source document.
+ pMgr->refreshNames(mnFileId);
+ }
+ else
+ {
+ // The source document has changed.
+ ScDocShell* pDocShell = ScDocShell::GetViewData()->GetDocShell();
+ ScDocShellModificator aMod(*pDocShell);
+ pMgr->switchSrcFile(mnFileId, aFile, aFilter);
+ maFilterName = aFilter;
+ aMod.SetDocumentModified();
+ }
+}
+
+void ScExternalRefLink::Edit(Window* pParent, const Link& /*rEndEditHdl*/)
+{
+ SvBaseLink::Edit(pParent, LINK(this, ScExternalRefLink, ExternalRefEndEditHdl));
+}
+
+void ScExternalRefLink::SetDoReferesh(bool b)
+{
+ mbDoRefresh = b;
+}
+
+IMPL_LINK( ScExternalRefLink, ExternalRefEndEditHdl, ::sfx2::SvBaseLink*, EMPTYARG )
+{
+ return 0;
+}
+
+// ============================================================================
+
+static FormulaToken* lcl_convertToToken(ScBaseCell* pCell)
+{
+ if (!pCell || pCell->HasEmptyData())
+ {
+ bool bInherited = (pCell && pCell->GetCellType() == CELLTYPE_FORMULA);
+ return new ScEmptyCellToken( bInherited, false);
+ }
+
+ switch (pCell->GetCellType())
+ {
+ case CELLTYPE_EDIT:
+ {
+ String aStr;
+ static_cast<ScEditCell*>(pCell)->GetString(aStr);
+ return new formula::FormulaStringToken(aStr);
+ }
+ //break;
+ case CELLTYPE_STRING:
+ {
+ String aStr;
+ static_cast<ScStringCell*>(pCell)->GetString(aStr);
+ return new formula::FormulaStringToken(aStr);
+ }
+ //break;
+ case CELLTYPE_VALUE:
+ {
+ double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
+ return new formula::FormulaDoubleToken(fVal);
+ }
+ //break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ USHORT nError = pFCell->GetErrCode();
+ if (nError)
+ return new FormulaErrorToken( nError);
+ else if (pFCell->IsValue())
+ {
+ double fVal = pFCell->GetValue();
+ return new formula::FormulaDoubleToken(fVal);
+ }
+ else
+ {
+ String aStr;
+ pFCell->GetString(aStr);
+ return new formula::FormulaStringToken(aStr);
+ }
+ }
+ //break;
+ default:
+ DBG_ERROR("attempted to convert an unknown cell type.");
+ }
+
+ return NULL;
+}
+
+static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange& rRange,
+ vector<ScExternalRefCache::SingleRangeData>& rCacheData)
+{
+ ScAddress& s = rRange.aStart;
+ ScAddress& e = rRange.aEnd;
+
+ SCTAB nTab1 = s.Tab(), nTab2 = e.Tab();
+ SCCOL nCol1 = s.Col(), nCol2 = e.Col();
+ SCROW nRow1 = s.Row(), nRow2 = e.Row();
+
+ if (nTab2 != nTab1)
+ // For now, we don't support multi-sheet ranges intentionally because
+ // we don't have a way to express them in a single token. In the
+ // future we can introduce a new stack variable type svMatrixList with
+ // a new token type that can store a 3D matrix value and convert a 3D
+ // range to it.
+ return NULL;
+
+ ::boost::scoped_ptr<ScRange> pUsedRange;
+
+ auto_ptr<ScTokenArray> pArray(new ScTokenArray);
+ bool bFirstTab = true;
+ vector<ScExternalRefCache::SingleRangeData>::iterator
+ itrCache = rCacheData.begin(), itrCacheEnd = rCacheData.end();
+
+ for (SCTAB nTab = nTab1; nTab <= nTab2 && itrCache != itrCacheEnd; ++nTab, ++itrCache)
+ {
+ // Only loop within the data area.
+ SCCOL nDataCol1 = nCol1, nDataCol2 = nCol2;
+ SCROW nDataRow1 = nRow1, nDataRow2 = nRow2;
+ if (!pSrcDoc->ShrinkToDataArea(nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2))
+ // no data within specified range.
+ continue;
+
+ if (pUsedRange.get())
+ // Make sure the used area only grows, not shrinks.
+ pUsedRange->ExtendTo(ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
+ else
+ pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
+
+ ScMatrixRef xMat = new ScMatrix(
+ static_cast<SCSIZE>(nDataCol2-nDataCol1+1),
+ static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
+
+ for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
+ {
+ for (SCROW nRow = nDataRow1; nRow <= nDataRow2; ++nRow)
+ {
+ SCSIZE nC = nCol - nCol1, nR = nRow - nRow1;
+ ScBaseCell* pCell;
+ pSrcDoc->GetCell(nCol, nRow, nTab, pCell);
+ if (!pCell || pCell->HasEmptyData())
+ xMat->PutEmpty(nC, nR);
+ else
+ {
+ switch (pCell->GetCellType())
+ {
+ case CELLTYPE_EDIT:
+ {
+ String aStr;
+ static_cast<ScEditCell*>(pCell)->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ break;
+ case CELLTYPE_STRING:
+ {
+ String aStr;
+ static_cast<ScStringCell*>(pCell)->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ break;
+ case CELLTYPE_VALUE:
+ {
+ double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
+ }
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ USHORT nError = pFCell->GetErrCode();
+ if (nError)
+ xMat->PutDouble( CreateDoubleError( nError), nC, nR);
+ else if (pFCell->IsValue())
+ {
+ double fVal = pFCell->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
+ }
+ else
+ {
+ String aStr;
+ pFCell->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ }
+ break;
+ default:
+ DBG_ERROR("attempted to convert an unknown cell type.");
+ }
+ }
+ }
+ }
+ if (!bFirstTab)
+ pArray->AddOpCode(ocSep);
+
+ ScMatrix* pMat2 = xMat;
+ ScMatrixToken aToken(pMat2);
+ pArray->AddToken(aToken);
+
+ itrCache->mpRangeData = xMat;
+
+ bFirstTab = false;
+ }
+
+ if (!pUsedRange.get())
+ return NULL;
+
+ s.SetCol(pUsedRange->aStart.Col());
+ s.SetRow(pUsedRange->aStart.Row());
+ e.SetCol(pUsedRange->aEnd.Col());
+ e.SetRow(pUsedRange->aEnd.Row());
+
+ return pArray.release();
+}
+
+static ScTokenArray* lcl_fillEmptyMatrix(const ScRange& rRange)
+{
+ SCSIZE nC = static_cast<SCSIZE>(rRange.aEnd.Col()-rRange.aStart.Col()+1);
+ SCSIZE nR = static_cast<SCSIZE>(rRange.aEnd.Row()-rRange.aStart.Row()+1);
+ ScMatrixRef xMat = new ScMatrix(nC, nR);
+ for (SCSIZE i = 0; i < nC; ++i)
+ for (SCSIZE j = 0; j < nR; ++j)
+ xMat->PutEmpty(i, j);
+
+ ScMatrix* pMat2 = xMat;
+ ScMatrixToken aToken(pMat2);
+ auto_ptr<ScTokenArray> pArray(new ScTokenArray);
+ pArray->AddToken(aToken);
+ return pArray.release();
+}
+
+ScExternalRefManager::ScExternalRefManager(ScDocument* pDoc) :
+ mpDoc(pDoc),
+ mbInReferenceMarking(false),
+ mbUserInteractionEnabled(true)
+{
+ maSrcDocTimer.SetTimeoutHdl( LINK(this, ScExternalRefManager, TimeOutHdl) );
+ maSrcDocTimer.SetTimeout(SRCDOC_SCAN_INTERVAL);
+}
+
+ScExternalRefManager::~ScExternalRefManager()
+{
+ clear();
+}
+
+String ScExternalRefManager::getCacheTableName(sal_uInt16 nFileId, size_t nTabIndex) const
+{
+ return maRefCache.getTableName(nFileId, nTabIndex);
+}
+
+ScExternalRefCache::TableTypeRef ScExternalRefManager::getCacheTable(sal_uInt16 nFileId, size_t nTabIndex) const
+{
+ return maRefCache.getCacheTable(nFileId, nTabIndex);
+}
+
+ScExternalRefCache::TableTypeRef ScExternalRefManager::getCacheTable(sal_uInt16 nFileId, const String& rTabName, bool bCreateNew, size_t* pnIndex)
+{
+ return maRefCache.getCacheTable(nFileId, rTabName, bCreateNew, pnIndex);
+}
+
+// ============================================================================
+
+ScExternalRefManager::LinkListener::LinkListener()
+{
+}
+
+ScExternalRefManager::LinkListener::~LinkListener()
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScExternalRefManager::ApiGuard::ApiGuard(ScDocument* pDoc) :
+ mpMgr(pDoc->GetExternalRefManager()),
+ mbOldInteractionEnabled(mpMgr->mbUserInteractionEnabled)
+{
+ // We don't want user interaction handled in the API.
+ mpMgr->mbUserInteractionEnabled = false;
+}
+
+ScExternalRefManager::ApiGuard::~ApiGuard()
+{
+ // Restore old value.
+ mpMgr->mbUserInteractionEnabled = mbOldInteractionEnabled;
+}
+
+// ----------------------------------------------------------------------------
+
+void ScExternalRefManager::getAllCachedTableNames(sal_uInt16 nFileId, vector<String>& rTabNames) const
+{
+ maRefCache.getAllTableNames(nFileId, rTabNames);
+}
+
+SCsTAB ScExternalRefManager::getCachedTabSpan( sal_uInt16 nFileId, const String& rStartTabName, const String& rEndTabName ) const
+{
+ return maRefCache.getTabSpan( nFileId, rStartTabName, rEndTabName);
+}
+
+void ScExternalRefManager::getAllCachedNumberFormats(vector<sal_uInt32>& rNumFmts) const
+{
+ maRefCache.getAllNumberFormats(rNumFmts);
+}
+
+bool ScExternalRefManager::hasCacheTable(sal_uInt16 nFileId, const String& rTabName) const
+{
+ return maRefCache.hasCacheTable(nFileId, rTabName);
+}
+
+size_t ScExternalRefManager::getCacheTableCount(sal_uInt16 nFileId) const
+{
+ return maRefCache.getCacheTableCount(nFileId);
+}
+
+sal_uInt16 ScExternalRefManager::getExternalFileCount() const
+{
+ return static_cast< sal_uInt16 >( maSrcFiles.size() );
+}
+
+bool ScExternalRefManager::markUsedByLinkListeners()
+{
+ bool bAllMarked = false;
+ for (LinkListenerMap::const_iterator itr = maLinkListeners.begin();
+ itr != maLinkListeners.end() && !bAllMarked; ++itr)
+ {
+ if (!(*itr).second.empty())
+ bAllMarked = maRefCache.setCacheDocReferenced( (*itr).first);
+ /* TODO: LinkListeners should remember the table they're listening to.
+ * As is, listening to one table will mark all tables of the document
+ * being referenced. */
+ }
+ return bAllMarked;
+}
+
+bool ScExternalRefManager::markUsedExternalRefCells()
+{
+ RefCellMap::iterator itr = maRefCells.begin(), itrEnd = maRefCells.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ RefCellSet::iterator itrCell = itr->second.begin(), itrCellEnd = itr->second.end();
+ for (; itrCell != itrCellEnd; ++itrCell)
+ {
+ ScFormulaCell* pCell = *itrCell;
+ bool bUsed = pCell->MarkUsedExternalReferences();
+ if (bUsed)
+ // Return true when at least one cell references external docs.
+ return true;
+ }
+ }
+ return false;
+}
+
+bool ScExternalRefManager::setCacheTableReferenced( sal_uInt16 nFileId, const String& rTabName, size_t nSheets )
+{
+ return maRefCache.setCacheTableReferenced( nFileId, rTabName, nSheets, false);
+}
+
+void ScExternalRefManager::setCacheTableReferencedPermanently( sal_uInt16 nFileId, const String& rTabName, size_t nSheets )
+{
+ if (isInReferenceMarking())
+ // Do all maintenance work.
+ maRefCache.setCacheTableReferenced( nFileId, rTabName, nSheets, true);
+ else
+ // Set only the permanent flag.
+ maRefCache.setCacheTableReferencedPermanently( nFileId, rTabName, nSheets);
+}
+
+void ScExternalRefManager::setAllCacheTableReferencedStati( bool bReferenced )
+{
+ mbInReferenceMarking = !bReferenced;
+ maRefCache.setAllCacheTableReferencedStati( bReferenced );
+}
+
+void ScExternalRefManager::storeRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScTokenArray& rArray)
+{
+ ScExternalRefCache::TokenArrayRef pArray(rArray.Clone());
+ maRefCache.setRangeNameTokens(nFileId, rName, pArray);
+}
+
+ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefToken(
+ sal_uInt16 nFileId, const String& rTabName, const ScAddress& rCell,
+ const ScAddress* pCurPos, SCTAB* pTab, ScExternalRefCache::CellFormat* pFmt)
+{
+ if (pCurPos)
+ insertRefCell(nFileId, *pCurPos);
+
+ maybeLinkExternalFile(nFileId);
+
+ if (pTab)
+ *pTab = -1;
+
+ if (pFmt)
+ pFmt->mbIsSet = false;
+
+ const ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
+ if (pSrcDoc)
+ {
+ // source document already loaded in memory. Re-use this instance.
+ // We don't even cache data when the document is loaded.
+
+ SCTAB nTab;
+ if (!pSrcDoc->GetTable(rTabName, nTab))
+ {
+ // specified table name doesn't exist in the source document.
+ ScExternalRefCache::TokenRef pToken(new FormulaErrorToken(errNoRef));
+ return pToken;
+ }
+
+ if (pTab)
+ *pTab = nTab;
+
+ return getSingleRefTokenFromSrcDoc(
+ nFileId, pSrcDoc, ScAddress(rCell.Col(),rCell.Row(),nTab), pFmt);
+ }
+
+ // Check if the given table name and the cell position is cached.
+ sal_uInt32 nFmtIndex = 0;
+ ScExternalRefCache::TokenRef pToken = maRefCache.getCellData(
+ nFileId, rTabName, rCell.Col(), rCell.Row(), &nFmtIndex);
+ if (pToken)
+ {
+ // Cache hit !
+ fillCellFormat(nFmtIndex, pFmt);
+ return pToken;
+ }
+
+ // reference not cached. read from the source document.
+ pSrcDoc = getSrcDocument(nFileId);
+ if (!pSrcDoc)
+ {
+ // Source document not reachable. Throw a reference error.
+ pToken.reset(new FormulaErrorToken(errNoRef));
+ return pToken;
+ }
+
+ SCTAB nTab;
+ if (!pSrcDoc->GetTable(rTabName, nTab))
+ {
+ // specified table name doesn't exist in the source document.
+ pToken.reset(new FormulaErrorToken(errNoRef));
+ return pToken;
+ }
+
+ if (pTab)
+ *pTab = nTab;
+
+ SCCOL nDataCol1 = 0, nDataCol2 = MAXCOL;
+ SCROW nDataRow1 = 0, nDataRow2 = MAXROW;
+ pSrcDoc->ShrinkToDataArea(nTab, nDataCol1, nDataRow1, nDataCol2, nDataRow2);
+ if (rCell.Col() < nDataCol1 || nDataCol2 < rCell.Col() || rCell.Row() < nDataRow1 || nDataRow2 < rCell.Row())
+ {
+ // requested cell is outside the data area. Don't even bother caching
+ // this data, but add it to the cached range to prevent accessing the
+ // source document time and time again.
+ ScExternalRefCache::TableTypeRef pCacheTab =
+ maRefCache.getCacheTable(nFileId, rTabName, true, NULL);
+ if (pCacheTab)
+ pCacheTab->setCachedCell(rCell.Col(), rCell.Row());
+
+ pToken.reset(new ScEmptyCellToken(false, false));
+ return pToken;
+ }
+
+ pToken = getSingleRefTokenFromSrcDoc(
+ nFileId, pSrcDoc, ScAddress(rCell.Col(),rCell.Row(),nTab), pFmt);
+
+ // Now, insert the token into cache table but don't cache empty cells.
+ if (pToken->GetType() != formula::svEmptyCell)
+ maRefCache.setCellData(nFileId, rTabName, rCell.Col(), rCell.Row(), pToken, nFmtIndex);
+
+ return pToken;
+}
+
+ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokens(
+ sal_uInt16 nFileId, const String& rTabName, const ScRange& rRange, const ScAddress* pCurPos)
+{
+ if (pCurPos)
+ insertRefCell(nFileId, *pCurPos);
+
+ maybeLinkExternalFile(nFileId);
+
+ ScRange aRange(rRange);
+ const ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
+ if (pSrcDoc)
+ {
+ // Document already loaded.
+ vector<ScExternalRefCache::SingleRangeData> aCacheData;
+ return getDoubleRefTokensFromSrcDoc(pSrcDoc, rTabName, aRange, aCacheData);
+ }
+
+ // Check if the given table name and the cell position is cached.
+ ScExternalRefCache::TokenArrayRef pArray =
+ maRefCache.getCellRangeData(nFileId, rTabName, rRange);
+ if (pArray)
+ // Cache hit !
+ return pArray;
+
+ pSrcDoc = getSrcDocument(nFileId);
+ if (!pSrcDoc)
+ {
+ // Source document is not reachable. Throw a reference error.
+ pArray.reset(new ScTokenArray);
+ pArray->AddToken(FormulaErrorToken(errNoRef));
+ return pArray;
+ }
+
+ vector<ScExternalRefCache::SingleRangeData> aCacheData;
+ pArray = getDoubleRefTokensFromSrcDoc(pSrcDoc, rTabName, aRange, aCacheData);
+
+ if (pArray)
+ // Cache these values.
+ maRefCache.setCellRangeData(nFileId, aRange, aCacheData, pArray);
+ else
+ {
+ // Array is empty. Fill it with an empty matrix of the required size.
+ pArray.reset(lcl_fillEmptyMatrix(rRange));
+
+ // Make sure to set this range 'cached', to prevent unnecessarily
+ // accessing the src document time and time again.
+ ScExternalRefCache::TableTypeRef pCacheTab =
+ maRefCache.getCacheTable(nFileId, rTabName, true, NULL);
+ if (pCacheTab)
+ pCacheTab->setCachedCellRange(
+ rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row());
+ }
+
+ return pArray;
+}
+
+ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokens(sal_uInt16 nFileId, const String& rName, const ScAddress* pCurPos)
+{
+ if (pCurPos)
+ insertRefCell(nFileId, *pCurPos);
+
+ maybeLinkExternalFile(nFileId);
+
+ String aName = rName; // make a copy to have the casing corrected.
+ const ScDocument* pSrcDoc = getInMemorySrcDocument(nFileId);
+ if (pSrcDoc)
+ {
+ // Document already loaded in memory.
+ return getRangeNameTokensFromSrcDoc(nFileId, pSrcDoc, aName);
+ }
+
+ ScExternalRefCache::TokenArrayRef pArray = maRefCache.getRangeNameTokens(nFileId, rName);
+ if (pArray.get())
+ // This range name is cached.
+ return pArray;
+
+ pSrcDoc = getSrcDocument(nFileId);
+ if (!pSrcDoc)
+ // failed to load document from disk.
+ return ScExternalRefCache::TokenArrayRef();
+
+ pArray = getRangeNameTokensFromSrcDoc(nFileId, pSrcDoc, aName);
+
+ if (pArray)
+ // Cache this range name array.
+ maRefCache.setRangeNameTokens(nFileId, aName, pArray);
+
+ return pArray;
+}
+
+void ScExternalRefManager::refreshAllRefCells(sal_uInt16 nFileId)
+{
+ RefCellMap::iterator itrFile = maRefCells.find(nFileId);
+ if (itrFile == maRefCells.end())
+ return;
+
+ RefCellSet& rRefCells = itrFile->second;
+ for_each(rRefCells.begin(), rRefCells.end(), UpdateFormulaCell());
+
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ if (!pViewData)
+ return;
+
+ ScTabViewShell* pVShell = pViewData->GetViewShell();
+ if (!pVShell)
+ return;
+
+ // Repainting the grid also repaints the texts, but is there a better way
+ // to refresh texts?
+ pVShell->Invalidate(FID_REPAINT);
+ pVShell->PaintGrid();
+}
+
+void ScExternalRefManager::insertRefCell(sal_uInt16 nFileId, const ScAddress& rCell)
+{
+ RefCellMap::iterator itr = maRefCells.find(nFileId);
+ if (itr == maRefCells.end())
+ {
+ RefCellSet aRefCells;
+ pair<RefCellMap::iterator, bool> r = maRefCells.insert(
+ RefCellMap::value_type(nFileId, aRefCells));
+ if (!r.second)
+ // insertion failed.
+ return;
+
+ itr = r.first;
+ }
+
+ ScBaseCell* pCell = mpDoc->GetCell(rCell);
+ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA)
+ itr->second.insert(static_cast<ScFormulaCell*>(pCell));
+}
+
+void ScExternalRefManager::fillCellFormat(sal_uInt32 nFmtIndex, ScExternalRefCache::CellFormat* pFmt) const
+{
+ if (!pFmt)
+ return;
+
+ short nFmtType = mpDoc->GetFormatTable()->GetType(nFmtIndex);
+ if (nFmtType != NUMBERFORMAT_UNDEFINED)
+ {
+ pFmt->mbIsSet = true;
+ pFmt->mnIndex = nFmtIndex;
+ pFmt->mnType = nFmtType;
+ }
+}
+
+ScExternalRefCache::TokenRef ScExternalRefManager::getSingleRefTokenFromSrcDoc(
+ sal_uInt16 nFileId, const ScDocument* pSrcDoc, const ScAddress& rCell,
+ ScExternalRefCache::CellFormat* pFmt)
+{
+ // Get the cell from src doc, and convert it into a token.
+ ScBaseCell* pCell = NULL;
+ pSrcDoc->GetCell(rCell.Col(), rCell.Row(), rCell.Tab(), pCell);
+ ScExternalRefCache::TokenRef pToken(lcl_convertToToken(pCell));
+
+ if (!pToken.get())
+ {
+ // Generate an error for unresolvable cells.
+ pToken.reset( new FormulaErrorToken( errNoValue));
+ }
+
+ // Get number format information.
+ sal_uInt32 nFmtIndex = 0;
+ pSrcDoc->GetNumberFormat(rCell.Col(), rCell.Row(), rCell.Tab(), nFmtIndex);
+ nFmtIndex = getMappedNumberFormat(nFileId, nFmtIndex, pSrcDoc);
+ fillCellFormat(nFmtIndex, pFmt);
+ return pToken;
+}
+
+ScExternalRefCache::TokenArrayRef ScExternalRefManager::getDoubleRefTokensFromSrcDoc(
+ const ScDocument* pSrcDoc, const String& rTabName, ScRange& rRange,
+ vector<ScExternalRefCache::SingleRangeData>& rCacheData)
+{
+ ScExternalRefCache::TokenArrayRef pArray;
+ SCTAB nTab1;
+
+ if (!pSrcDoc->GetTable(rTabName, nTab1))
+ {
+ // specified table name doesn't exist in the source document.
+ pArray.reset(new ScTokenArray);
+ pArray->AddToken(FormulaErrorToken(errNoRef));
+ return pArray;
+ }
+
+ ScRange aRange(rRange);
+ SCTAB nTabSpan = aRange.aEnd.Tab() - aRange.aStart.Tab();
+
+ vector<ScExternalRefCache::SingleRangeData> aCacheData;
+ aCacheData.reserve(nTabSpan+1);
+ aCacheData.push_back(ScExternalRefCache::SingleRangeData());
+ aCacheData.back().maTableName = ScGlobal::pCharClass->upper(rTabName);
+
+ for (SCTAB i = 1; i < nTabSpan + 1; ++i)
+ {
+ String aTabName;
+ if (!pSrcDoc->GetName(nTab1 + 1, aTabName))
+ // source document doesn't have any table by the specified name.
+ break;
+
+ aCacheData.push_back(ScExternalRefCache::SingleRangeData());
+ aCacheData.back().maTableName = ScGlobal::pCharClass->upper(aTabName);
+ }
+
+ aRange.aStart.SetTab(nTab1);
+ aRange.aEnd.SetTab(nTab1 + nTabSpan);
+
+ pArray.reset(lcl_convertToTokenArray(pSrcDoc, aRange, aCacheData));
+ rRange = aRange;
+ rCacheData.swap(aCacheData);
+ return pArray;
+}
+
+ScExternalRefCache::TokenArrayRef ScExternalRefManager::getRangeNameTokensFromSrcDoc(
+ sal_uInt16 nFileId, const ScDocument* pSrcDoc, String& rName)
+{
+ ScRangeName* pExtNames = pSrcDoc->GetRangeName();
+ String aUpperName = ScGlobal::pCharClass->upper(rName);
+ USHORT n;
+ bool bRes = pExtNames->SearchNameUpper(aUpperName, n);
+ if (!bRes)
+ return ScExternalRefCache::TokenArrayRef();
+
+ ScRangeData* pRangeData = (*pExtNames)[n];
+ if (!pRangeData)
+ return ScExternalRefCache::TokenArrayRef();
+
+ // Parse all tokens in this external range data, and replace each absolute
+ // reference token with an external reference token, and cache them. Also
+ // register the source document with the link manager if it's a new
+ // source.
+
+ ScExternalRefCache::TokenArrayRef pNew(new ScTokenArray);
+
+ ScTokenArray* pCode = pRangeData->GetCode();
+ for (FormulaToken* pToken = pCode->First(); pToken; pToken = pCode->Next())
+ {
+ bool bTokenAdded = false;
+ switch (pToken->GetType())
+ {
+ case svSingleRef:
+ {
+ const ScSingleRefData& rRef = static_cast<ScToken*>(pToken)->GetSingleRef();
+ String aTabName;
+ pSrcDoc->GetName(rRef.nTab, aTabName);
+ ScExternalSingleRefToken aNewToken(nFileId, aTabName, static_cast<ScToken*>(pToken)->GetSingleRef());
+ pNew->AddToken(aNewToken);
+ bTokenAdded = true;
+ }
+ break;
+ case svDoubleRef:
+ {
+ const ScSingleRefData& rRef = static_cast<ScToken*>(pToken)->GetSingleRef();
+ String aTabName;
+ pSrcDoc->GetName(rRef.nTab, aTabName);
+ ScExternalDoubleRefToken aNewToken(nFileId, aTabName, static_cast<ScToken*>(pToken)->GetDoubleRef());
+ pNew->AddToken(aNewToken);
+ bTokenAdded = true;
+ }
+ break;
+ default:
+ ; // nothing
+ }
+
+ if (!bTokenAdded)
+ pNew->AddToken(*pToken);
+ }
+
+ rName = pRangeData->GetName(); // Get the correctly-cased name.
+ return pNew;
+}
+
+const ScDocument* ScExternalRefManager::getInMemorySrcDocument(sal_uInt16 nFileId)
+{
+ const String* pFileName = getExternalFileName(nFileId);
+ if (!pFileName)
+ return NULL;
+
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(&aType, false));
+ while (pShell)
+ {
+ SfxMedium* pMedium = pShell->GetMedium();
+ if (pMedium)
+ {
+ String aName = pMedium->GetName();
+ // TODO: We should make the case sensitivity platform dependent.
+ if (pFileName->EqualsIgnoreCaseAscii(aName))
+ {
+ // Found !
+ return pShell->GetDocument();
+ }
+ }
+ pShell = static_cast<ScDocShell*>(SfxObjectShell::GetNext(*pShell, &aType, false));
+ }
+ return NULL;
+}
+
+const ScDocument* ScExternalRefManager::getSrcDocument(sal_uInt16 nFileId)
+{
+ if (!mpDoc->IsExecuteLinkEnabled())
+ return NULL;
+
+ DocShellMap::iterator itrEnd = maDocShells.end();
+ DocShellMap::iterator itr = maDocShells.find(nFileId);
+
+ if (itr != itrEnd)
+ {
+ // document already loaded.
+
+ // TODO: Find out a way to access a document that's already open in
+ // memory and re-use that instance, instead of loading it from the
+ // disk again.
+
+ SfxObjectShell* p = itr->second.maShell;
+ itr->second.maLastAccess = Time();
+ return static_cast<ScDocShell*>(p)->GetDocument();
+ }
+
+ const String* pFile = getExternalFileName(nFileId);
+ if (!pFile)
+ // no file name associated with this ID.
+ return NULL;
+
+ String aFilter;
+ SrcShell aSrcDoc;
+ aSrcDoc.maShell = loadSrcDocument(nFileId, aFilter);
+ if (!aSrcDoc.maShell.Is())
+ {
+ // source document could not be loaded.
+ return NULL;
+ }
+
+ if (maDocShells.empty())
+ {
+ // If this is the first source document insertion, start up the timer.
+ maSrcDocTimer.Start();
+ }
+
+ maDocShells.insert(DocShellMap::value_type(nFileId, aSrcDoc));
+ SfxObjectShell* p = aSrcDoc.maShell;
+ ScDocument* pSrcDoc = static_cast<ScDocShell*>(p)->GetDocument();
+
+ SCTAB nTabCount = pSrcDoc->GetTableCount();
+ if (!maRefCache.isDocInitialized(nFileId) && nTabCount)
+ {
+ // Populate the cache with all table names in the source document.
+ vector<String> aTabNames;
+ aTabNames.reserve(nTabCount);
+ for (SCTAB i = 0; i < nTabCount; ++i)
+ {
+ String aName;
+ pSrcDoc->GetName(i, aName);
+ aTabNames.push_back(aName);
+ }
+ maRefCache.initializeDoc(nFileId, aTabNames);
+ }
+ return pSrcDoc;
+}
+
+SfxObjectShellRef ScExternalRefManager::loadSrcDocument(sal_uInt16 nFileId, String& rFilter)
+{
+ const SrcFileData* pFileData = getExternalFileData(nFileId);
+ if (!pFileData)
+ return NULL;
+
+ // Always load the document by using the path created from the relative
+ // path. If the referenced document is not there, simply exit. The
+ // original file name should be used only when the relative path is not
+ // given.
+ String aFile = pFileData->maFileName;
+ maybeCreateRealFileName(nFileId);
+ if (pFileData->maRealFileName.Len())
+ aFile = pFileData->maRealFileName;
+
+ if (!isFileLoadable(aFile))
+ return NULL;
+
+ String aOptions( pFileData->maFilterOptions );
+ ScDocumentLoader::GetFilterName(aFile, rFilter, aOptions, true, false);
+ const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName(rFilter);
+
+ if (!pFileData->maRelativeName.Len())
+ {
+ // Generate a relative file path.
+ INetURLObject aBaseURL(getOwnDocumentName());
+ aBaseURL.insertName(OUString::createFromAscii("content.xml"));
+
+ String aStr = URIHelper::simpleNormalizedMakeRelative(
+ aBaseURL.GetMainURL(INetURLObject::NO_DECODE), aFile);
+
+ setRelativeFileName(nFileId, aStr);
+ }
+
+ SfxItemSet* pSet = new SfxAllItemSet(SFX_APP()->GetPool());
+ if (aOptions.Len())
+ pSet->Put(SfxStringItem(SID_FILE_FILTEROPTIONS, aOptions));
+
+ // make medium hidden to prevent assertion from progress bar
+ pSet->Put( SfxBoolItem( SID_HIDDEN, TRUE ) );
+
+ auto_ptr<SfxMedium> pMedium(new SfxMedium(aFile, STREAM_STD_READ, false, pFilter, pSet));
+ if (pMedium->GetError() != ERRCODE_NONE)
+ return NULL;
+
+ // To load encrypted documents with password, user interaction needs to be enabled.
+ pMedium->UseInteractionHandler(mbUserInteractionEnabled);
+
+ ScDocShell* pNewShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
+ SfxObjectShellRef aRef = pNewShell;
+
+ // increment the recursive link count of the source document.
+ ScExtDocOptions* pExtOpt = mpDoc->GetExtDocOptions();
+ sal_uInt32 nLinkCount = pExtOpt ? pExtOpt->GetDocSettings().mnLinkCnt : 0;
+ ScDocument* pSrcDoc = pNewShell->GetDocument();
+ pSrcDoc->EnableExecuteLink(false); // to prevent circular access of external references.
+ pSrcDoc->EnableUndo(false);
+ pSrcDoc->EnableAdjustHeight(false);
+
+ ScExtDocOptions* pExtOptNew = pSrcDoc->GetExtDocOptions();
+ if (!pExtOptNew)
+ {
+ pExtOptNew = new ScExtDocOptions;
+ pSrcDoc->SetExtDocOptions(pExtOptNew);
+ }
+ pExtOptNew->GetDocSettings().mnLinkCnt = nLinkCount + 1;
+
+ pNewShell->DoLoad(pMedium.release());
+
+ // with UseInteractionHandler, options may be set by dialog during DoLoad
+ String aNew = ScDocumentLoader::GetOptions(*pNewShell->GetMedium());
+ if (aNew.Len() && aNew != aOptions)
+ aOptions = aNew;
+ setFilterData(nFileId, rFilter, aOptions); // update the filter data, including the new options
+
+ return aRef;
+}
+
+bool ScExternalRefManager::isFileLoadable(const String& rFile) const
+{
+ if (!rFile.Len())
+ return false;
+
+ if (isOwnDocument(rFile))
+ return false;
+
+ if (utl::UCBContentHelper::IsFolder(rFile))
+ return false;
+
+ return utl::UCBContentHelper::Exists(rFile);
+}
+
+void ScExternalRefManager::maybeLinkExternalFile(sal_uInt16 nFileId)
+{
+ if (maLinkedDocs.count(nFileId))
+ // file alerady linked, or the link has been broken.
+ return;
+
+ // Source document not linked yet. Link it now.
+ const String* pFileName = getExternalFileName(nFileId);
+ if (!pFileName)
+ return;
+
+ String aFilter, aOptions;
+ ScDocumentLoader::GetFilterName(*pFileName, aFilter, aOptions, true, false);
+ sfx2::LinkManager* pLinkMgr = mpDoc->GetLinkManager();
+ ScExternalRefLink* pLink = new ScExternalRefLink(mpDoc, nFileId, aFilter);
+ DBG_ASSERT(pFileName, "ScExternalRefManager::insertExternalFileLink: file name pointer is NULL");
+ pLinkMgr->InsertFileLink(*pLink, OBJECT_CLIENT_FILE, *pFileName, &aFilter);
+
+ pLink->SetDoReferesh(false);
+ pLink->Update();
+ pLink->SetDoReferesh(true);
+
+ maLinkedDocs.insert(LinkedDocMap::value_type(nFileId, true));
+}
+
+void ScExternalRefManager::SrcFileData::maybeCreateRealFileName(const String& rOwnDocName)
+{
+ if (!maRelativeName.Len())
+ // No relative path given. Nothing to do.
+ return;
+
+ if (maRealFileName.Len())
+ // Real file name already created. Nothing to do.
+ return;
+
+ // Formulate the absolute file path from the relative path.
+ const String& rRelPath = maRelativeName;
+ INetURLObject aBaseURL(rOwnDocName);
+ aBaseURL.insertName(OUString::createFromAscii("content.xml"));
+ bool bWasAbs = false;
+ maRealFileName = aBaseURL.smartRel2Abs(rRelPath, bWasAbs).GetMainURL(INetURLObject::NO_DECODE);
+}
+
+void ScExternalRefManager::maybeCreateRealFileName(sal_uInt16 nFileId)
+{
+ if (nFileId >= maSrcFiles.size())
+ return;
+
+ maSrcFiles[nFileId].maybeCreateRealFileName(getOwnDocumentName());
+}
+
+const String& ScExternalRefManager::getOwnDocumentName() const
+{
+ SfxObjectShell* pShell = mpDoc->GetDocumentShell();
+ if (!pShell)
+ // This should not happen!
+ return EMPTY_STRING;
+
+ SfxMedium* pMed = pShell->GetMedium();
+ if (!pMed)
+ return EMPTY_STRING;
+
+ return pMed->GetName();
+}
+
+bool ScExternalRefManager::isOwnDocument(const String& rFile) const
+{
+ return getOwnDocumentName().Equals(rFile);
+}
+
+void ScExternalRefManager::convertToAbsName(String& rFile) const
+{
+ SfxObjectShell* pDocShell = mpDoc->GetDocumentShell();
+ rFile = ScGlobal::GetAbsDocName(rFile, pDocShell);
+}
+
+sal_uInt16 ScExternalRefManager::getExternalFileId(const String& rFile)
+{
+ vector<SrcFileData>::const_iterator itrBeg = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
+ vector<SrcFileData>::const_iterator itr = find_if(itrBeg, itrEnd, FindSrcFileByName(rFile));
+ if (itr != itrEnd)
+ {
+ size_t nId = distance(itrBeg, itr);
+ return static_cast<sal_uInt16>(nId);
+ }
+
+ SrcFileData aData;
+ aData.maFileName = rFile;
+ maSrcFiles.push_back(aData);
+ return static_cast<sal_uInt16>(maSrcFiles.size() - 1);
+}
+
+const String* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal)
+{
+ if (nFileId >= maSrcFiles.size())
+ return NULL;
+
+ if (bForceOriginal)
+ return &maSrcFiles[nFileId].maFileName;
+
+ maybeCreateRealFileName(nFileId);
+
+ if (maSrcFiles[nFileId].maRealFileName.Len())
+ return &maSrcFiles[nFileId].maRealFileName;
+ else
+ return &maSrcFiles[nFileId].maFileName;
+}
+
+bool ScExternalRefManager::hasExternalFile(sal_uInt16 nFileId) const
+{
+ return nFileId < maSrcFiles.size();
+}
+
+bool ScExternalRefManager::hasExternalFile(const String& rFile) const
+{
+ vector<SrcFileData>::const_iterator itrBeg = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
+ vector<SrcFileData>::const_iterator itr = find_if(itrBeg, itrEnd, FindSrcFileByName(rFile));
+ return itr != itrEnd;
+}
+
+const ScExternalRefManager::SrcFileData* ScExternalRefManager::getExternalFileData(sal_uInt16 nFileId) const
+{
+ if (nFileId >= maSrcFiles.size())
+ return NULL;
+
+ return &maSrcFiles[nFileId];
+}
+
+const String* ScExternalRefManager::getRealTableName(sal_uInt16 nFileId, const String& rTabName) const
+{
+ return maRefCache.getRealTableName(nFileId, rTabName);
+}
+
+const String* ScExternalRefManager::getRealRangeName(sal_uInt16 nFileId, const String& rRangeName) const
+{
+ return maRefCache.getRealRangeName(nFileId, rRangeName);
+}
+
+template<typename MapContainer>
+void lcl_removeByFileId(sal_uInt16 nFileId, MapContainer& rMap)
+{
+ typename MapContainer::iterator itr = rMap.find(nFileId);
+ if (itr != rMap.end())
+ rMap.erase(itr);
+}
+
+void ScExternalRefManager::refreshNames(sal_uInt16 nFileId)
+{
+ maRefCache.clearCache(nFileId);
+ lcl_removeByFileId(nFileId, maDocShells);
+
+ if (maDocShells.empty())
+ maSrcDocTimer.Stop();
+
+ // Update all cells containing names from this source document.
+ refreshAllRefCells(nFileId);
+
+ notifyAllLinkListeners(nFileId, LINK_MODIFIED);
+}
+
+void ScExternalRefManager::breakLink(sal_uInt16 nFileId)
+{
+ // Turn all formula cells referencing this external document into static
+ // cells.
+ RefCellMap::iterator itrRefs = maRefCells.find(nFileId);
+ if (itrRefs != maRefCells.end())
+ {
+ // Make a copy because removing the formula cells below will modify
+ // the original container.
+ RefCellSet aSet = itrRefs->second;
+ for_each(aSet.begin(), aSet.end(), ConvertFormulaToStatic(mpDoc));
+ maRefCells.erase(nFileId);
+ }
+
+ lcl_removeByFileId(nFileId, maDocShells);
+
+ if (maDocShells.empty())
+ maSrcDocTimer.Stop();
+
+ LinkedDocMap::iterator itr = maLinkedDocs.find(nFileId);
+ if (itr != maLinkedDocs.end())
+ itr->second = false;
+
+ notifyAllLinkListeners(nFileId, LINK_BROKEN);
+}
+
+void ScExternalRefManager::switchSrcFile(sal_uInt16 nFileId, const String& rNewFile, const String& rNewFilter)
+{
+ maSrcFiles[nFileId].maFileName = rNewFile;
+ maSrcFiles[nFileId].maRelativeName.Erase();
+ maSrcFiles[nFileId].maRealFileName.Erase();
+ if (!maSrcFiles[nFileId].maFilterName.Equals(rNewFilter))
+ {
+ // Filter type has changed.
+ maSrcFiles[nFileId].maFilterName = rNewFilter;
+ maSrcFiles[nFileId].maFilterOptions.Erase();
+ }
+ refreshNames(nFileId);
+}
+
+void ScExternalRefManager::setRelativeFileName(sal_uInt16 nFileId, const String& rRelUrl)
+{
+ if (nFileId >= maSrcFiles.size())
+ return;
+ maSrcFiles[nFileId].maRelativeName = rRelUrl;
+}
+
+void ScExternalRefManager::setFilterData(sal_uInt16 nFileId, const String& rFilterName, const String& rOptions)
+{
+ if (nFileId >= maSrcFiles.size())
+ return;
+ maSrcFiles[nFileId].maFilterName = rFilterName;
+ maSrcFiles[nFileId].maFilterOptions = rOptions;
+}
+
+void ScExternalRefManager::clear()
+{
+ DocShellMap::iterator itrEnd = maDocShells.end();
+ for (DocShellMap::iterator itr = maDocShells.begin(); itr != itrEnd; ++itr)
+ itr->second.maShell->DoClose();
+
+ maDocShells.clear();
+ maSrcDocTimer.Stop();
+}
+
+bool ScExternalRefManager::hasExternalData() const
+{
+ return !maSrcFiles.empty();
+}
+
+void ScExternalRefManager::resetSrcFileData(const String& rBaseFileUrl)
+{
+ for (vector<SrcFileData>::iterator itr = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
+ itr != itrEnd; ++itr)
+ {
+ // Re-generate relative file name from the absolute file name.
+ String aAbsName = itr->maRealFileName;
+ if (!aAbsName.Len())
+ aAbsName = itr->maFileName;
+
+ itr->maRelativeName = URIHelper::simpleNormalizedMakeRelative(
+ rBaseFileUrl, aAbsName);
+ }
+}
+
+void ScExternalRefManager::removeRefCell(ScFormulaCell* pCell)
+{
+ for_each(maRefCells.begin(), maRefCells.end(), RemoveFormulaCell(pCell));
+}
+
+void ScExternalRefManager::addLinkListener(sal_uInt16 nFileId, LinkListener* pListener)
+{
+ LinkListenerMap::iterator itr = maLinkListeners.find(nFileId);
+ if (itr == maLinkListeners.end())
+ {
+ pair<LinkListenerMap::iterator, bool> r = maLinkListeners.insert(
+ LinkListenerMap::value_type(nFileId, LinkListeners()));
+ if (!r.second)
+ {
+ DBG_ERROR("insertion of new link listener list failed");
+ return;
+ }
+
+ itr = r.first;
+ }
+
+ LinkListeners& rList = itr->second;
+ rList.insert(pListener);
+}
+
+void ScExternalRefManager::removeLinkListener(sal_uInt16 nFileId, LinkListener* pListener)
+{
+ LinkListenerMap::iterator itr = maLinkListeners.find(nFileId);
+ if (itr == maLinkListeners.end())
+ // no listeners for a specified file.
+ return;
+
+ LinkListeners& rList = itr->second;
+ rList.erase(pListener);
+
+ if (rList.empty())
+ // No more listeners for this file. Remove its entry.
+ maLinkListeners.erase(itr);
+}
+
+void ScExternalRefManager::removeLinkListener(LinkListener* pListener)
+{
+ LinkListenerMap::iterator itr = maLinkListeners.begin(), itrEnd = maLinkListeners.end();
+ for (; itr != itrEnd; ++itr)
+ itr->second.erase(pListener);
+}
+
+void ScExternalRefManager::notifyAllLinkListeners(sal_uInt16 nFileId, LinkUpdateType eType)
+{
+ LinkListenerMap::iterator itr = maLinkListeners.find(nFileId);
+ if (itr == maLinkListeners.end())
+ // no listeners for a specified file.
+ return;
+
+ LinkListeners& rList = itr->second;
+ for_each(rList.begin(), rList.end(), NotifyLinkListener(nFileId, eType));
+}
+
+void ScExternalRefManager::purgeStaleSrcDocument(sal_Int32 nTimeOut)
+{
+ DocShellMap aNewDocShells;
+ DocShellMap::iterator itr = maDocShells.begin(), itrEnd = maDocShells.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ // in 100th of a second.
+ sal_Int32 nSinceLastAccess = (Time() - itr->second.maLastAccess).GetTime();
+ if (nSinceLastAccess < nTimeOut)
+ aNewDocShells.insert(*itr);
+ }
+ maDocShells.swap(aNewDocShells);
+
+ if (maDocShells.empty())
+ maSrcDocTimer.Stop();
+}
+
+sal_uInt32 ScExternalRefManager::getMappedNumberFormat(sal_uInt16 nFileId, sal_uInt32 nNumFmt, const ScDocument* pSrcDoc)
+{
+ NumFmtMap::iterator itr = maNumFormatMap.find(nFileId);
+ if (itr == maNumFormatMap.end())
+ {
+ // Number formatter map is not initialized for this external document.
+ pair<NumFmtMap::iterator, bool> r = maNumFormatMap.insert(
+ NumFmtMap::value_type(nFileId, SvNumberFormatterMergeMap()));
+
+ if (!r.second)
+ // insertion failed.
+ return nNumFmt;
+
+ itr = r.first;
+ mpDoc->GetFormatTable()->MergeFormatter( *pSrcDoc->GetFormatTable());
+ SvNumberFormatterMergeMap aMap = mpDoc->GetFormatTable()->ConvertMergeTableToMap();
+ itr->second.swap(aMap);
+ }
+ const SvNumberFormatterMergeMap& rMap = itr->second;
+ SvNumberFormatterMergeMap::const_iterator itrNumFmt = rMap.find(nNumFmt);
+ if (itrNumFmt != rMap.end())
+ // mapped value found.
+ return itrNumFmt->second;
+
+ return nNumFmt;
+}
+
+IMPL_LINK(ScExternalRefManager, TimeOutHdl, AutoTimer*, pTimer)
+{
+ if (pTimer == &maSrcDocTimer)
+ purgeStaleSrcDocument(SRCDOC_LIFE_SPAN);
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/hiranges.cxx b/sc/source/ui/docshell/hiranges.cxx
new file mode 100644
index 000000000000..5716abe19b62
--- /dev/null
+++ b/sc/source/ui/docshell/hiranges.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "hiranges.hxx"
+
+//==================================================================
+
+ScHighlightRanges::ScHighlightRanges()
+{
+}
+
+ScHighlightRanges::~ScHighlightRanges()
+{
+ void* pEntry = aEntries.First();
+ while ( pEntry )
+ {
+ delete (ScHighlightEntry*) aEntries.Remove( pEntry );
+ pEntry = aEntries.Next();
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
new file mode 100644
index 000000000000..3cbf5364b964
--- /dev/null
+++ b/sc/source/ui/docshell/impex.cxx
@@ -0,0 +1,2071 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+class StarBASIC;
+
+
+
+#ifndef PCH
+#include "sc.hrc"
+#define GLOBALOVERFLOW
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <osl/endian.h>
+#include <i18npool/mslangid.hxx>
+#include <tools/list.hxx>
+#include <tools/string.hxx>
+#include <rtl/math.hxx>
+#include <svtools/htmlout.hxx>
+#include <svl/zforlist.hxx>
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+#include <sot/formats.hxx>
+#include <sfx2/mieclip.hxx>
+#include <unotools/charclass.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <unotools/calendarwrapper.hxx>
+#include <com/sun/star/i18n/CalendarFieldIndex.hpp>
+#include <unotools/transliterationwrapper.hxx>
+
+#include "global.hxx"
+#include "scerrors.hxx"
+#include "docsh.hxx"
+#include "undoblk.hxx"
+#include "rangenam.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "filter.hxx"
+#include "asciiopt.hxx"
+#include "cell.hxx"
+#include "docoptio.hxx"
+#include "progress.hxx"
+#include "scitems.hxx"
+#include "editable.hxx"
+#include "compiler.hxx"
+#include "warnbox.hxx"
+
+#include "impex.hxx"
+
+// ause
+#include "editutil.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "stringutil.hxx"
+
+#include "globstr.hrc"
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/module.hxx>
+
+//========================================================================
+
+namespace
+{
+ const String SYLK_LF = String::CreateFromAscii("\x1b :");
+ const String DOUBLE_SEMICOLON = String::CreateFromAscii(";;");
+ const String DOUBLE_DOUBLEQUOTE = String::CreateFromAscii("\"\"");
+}
+
+enum SylkVersion
+{
+ SYLK_SCALC3, // Wrote wrongly quoted strings and unescaped semicolons.
+ SYLK_OOO32, // Correct strings, plus multiline content.
+ SYLK_OWN, // Place our new versions, if any, before this value.
+ SYLK_OTHER // Assume that aliens wrote correct strings.
+};
+
+
+// Gesamtdokument ohne Undo
+
+
+ScImportExport::ScImportExport( ScDocument* p )
+ : pDocSh( PTR_CAST(ScDocShell,p->GetDocumentShell()) ), pDoc( p ),
+ nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+ bFormulas( FALSE ), bIncludeFiltered( TRUE ),
+ bAll( TRUE ), bSingle( TRUE ), bUndo( FALSE ),
+ bOverflow( FALSE ), mbApi( true ), mExportTextOptions()
+{
+ pUndoDoc = NULL;
+ pExtOptions = NULL;
+}
+
+// Insert am Punkt ohne Bereichschecks
+
+
+ScImportExport::ScImportExport( ScDocument* p, const ScAddress& rPt )
+ : pDocSh( PTR_CAST(ScDocShell,p->GetDocumentShell()) ), pDoc( p ),
+ aRange( rPt ),
+ nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+ bFormulas( FALSE ), bIncludeFiltered( TRUE ),
+ bAll( FALSE ), bSingle( TRUE ), bUndo( BOOL( pDocSh != NULL ) ),
+ bOverflow( FALSE ), mbApi( true ), mExportTextOptions()
+{
+ pUndoDoc = NULL;
+ pExtOptions = NULL;
+}
+
+
+// ctor with a range is only used for export
+//! ctor with a string (and bSingle=TRUE) is also used for DdeSetData
+
+ScImportExport::ScImportExport( ScDocument* p, const ScRange& r )
+ : pDocSh( PTR_CAST(ScDocShell,p->GetDocumentShell()) ), pDoc( p ),
+ aRange( r ),
+ nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+ bFormulas( FALSE ), bIncludeFiltered( TRUE ),
+ bAll( FALSE ), bSingle( FALSE ), bUndo( BOOL( pDocSh != NULL ) ),
+ bOverflow( FALSE ), mbApi( true ), mExportTextOptions()
+{
+ pUndoDoc = NULL;
+ pExtOptions = NULL;
+ // Zur Zeit nur in einer Tabelle!
+ aRange.aEnd.SetTab( aRange.aStart.Tab() );
+}
+
+// String auswerten: Entweder Bereich, Punkt oder Gesamtdoc (bei Fehler)
+// Falls eine View existiert, wird die TabNo der View entnommen!
+
+
+ScImportExport::ScImportExport( ScDocument* p, const String& rPos )
+ : pDocSh( PTR_CAST(ScDocShell,p->GetDocumentShell()) ), pDoc( p ),
+ nSizeLimit( 0 ), cSep( '\t' ), cStr( '"' ),
+ bFormulas( FALSE ), bIncludeFiltered( TRUE ),
+ bAll( FALSE ), bSingle( TRUE ), bUndo( BOOL( pDocSh != NULL ) ),
+ bOverflow( FALSE ), mbApi( true ), mExportTextOptions()
+{
+ pUndoDoc = NULL;
+ pExtOptions = NULL;
+
+ SCTAB nTab = ScDocShell::GetCurTab();
+ aRange.aStart.SetTab( nTab );
+ String aPos( rPos );
+ // Benannter Bereich?
+ ScRangeName* pRange = pDoc->GetRangeName();
+ if( pRange )
+ {
+ USHORT nPos;
+ if( pRange->SearchName( aPos, nPos ) )
+ {
+ ScRangeData* pData = (*pRange)[ nPos ];
+ if( pData->HasType( RT_REFAREA )
+ || pData->HasType( RT_ABSAREA )
+ || pData->HasType( RT_ABSPOS ) )
+ pData->GetSymbol( aPos ); // mit dem Inhalt weitertesten
+ }
+ }
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ // Bereich?
+ if( aRange.Parse( aPos, pDoc, eConv ) & SCA_VALID )
+ bSingle = FALSE;
+ // Zelle?
+ else if( aRange.aStart.Parse( aPos, pDoc, eConv ) & SCA_VALID )
+ aRange.aEnd = aRange.aStart;
+ else
+ bAll = TRUE;
+}
+
+
+ScImportExport::~ScImportExport()
+{
+ delete pUndoDoc;
+ delete pExtOptions;
+}
+
+
+void ScImportExport::SetExtOptions( const ScAsciiOptions& rOpt )
+{
+ if ( pExtOptions )
+ *pExtOptions = rOpt;
+ else
+ pExtOptions = new ScAsciiOptions( rOpt );
+
+ // "normale" Optionen uebernehmen
+
+ cSep = rOpt.GetFieldSeps().GetChar(0);
+ cStr = rOpt.GetTextSep();
+}
+
+
+BOOL ScImportExport::IsFormatSupported( ULONG nFormat )
+{
+ return BOOL( nFormat == FORMAT_STRING
+ || nFormat == SOT_FORMATSTR_ID_SYLK
+ || nFormat == SOT_FORMATSTR_ID_LINK
+ || nFormat == SOT_FORMATSTR_ID_HTML
+ || nFormat == SOT_FORMATSTR_ID_HTML_SIMPLE
+ || nFormat == SOT_FORMATSTR_ID_DIF );
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+
+// Vorbereitung fuer Undo: Undo-Dokument erzeugen
+
+
+BOOL ScImportExport::StartPaste()
+{
+ if ( !bAll )
+ {
+ ScEditableTester aTester( pDoc, aRange );
+ if ( !aTester.IsEditable() )
+ {
+ InfoBox aInfoBox(Application::GetDefDialogParent(),
+ ScGlobal::GetRscString( aTester.GetMessageId() ) );
+ aInfoBox.Execute();
+ return FALSE;
+ }
+ }
+ if( bUndo && pDocSh && pDoc->IsUndoEnabled())
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() );
+ pDoc->CopyToDocument( aRange, IDF_ALL | IDF_NOCAPTIONS, FALSE, pUndoDoc );
+ }
+ return TRUE;
+}
+
+// Nachbereitung Insert: Undo/Redo-Aktionen erzeugen, Invalidate/Repaint
+
+
+void ScImportExport::EndPaste()
+{
+ BOOL bHeight = pDocSh && pDocSh->AdjustRowHeight(
+ aRange.aStart.Row(), aRange.aEnd.Row(), aRange.aStart.Tab() );
+
+ if( pUndoDoc && pDoc->IsUndoEnabled() )
+ {
+ ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, aRange.aStart.Tab(), aRange.aEnd.Tab() );
+ pDoc->CopyToDocument( aRange, IDF_ALL | IDF_NOCAPTIONS, FALSE, pRedoDoc );
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( aRange.aStart.Tab() );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoPaste( pDocSh,
+ aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aEnd.Tab(), aDestMark,
+ pUndoDoc, pRedoDoc, IDF_ALL, NULL,NULL,NULL,NULL ) );
+ }
+ pUndoDoc = NULL;
+ if( pDocSh )
+ {
+ if (!bHeight)
+ pDocSh->PostPaint( aRange, PAINT_GRID ); // AdjustRowHeight paintet evtl. selber
+ pDocSh->SetDocumentModified();
+ }
+ ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+ if ( pViewSh )
+ pViewSh->UpdateInputHandler();
+
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+BOOL ScImportExport::ImportData( const String& /* rMimeType */,
+ const ::com::sun::star::uno::Any & /* rValue */ )
+{
+ DBG_ASSERT( !this, "Implementation is missing" );
+ return FALSE;
+}
+
+BOOL ScImportExport::ExportData( const String& rMimeType,
+ ::com::sun::star::uno::Any & rValue )
+{
+ SvMemoryStream aStrm;
+ // mba: no BaseURL for data exchange
+ if( ExportStream( aStrm, String(),
+ SotExchange::GetFormatIdFromMimeType( rMimeType ) ))
+ {
+ aStrm << (BYTE) 0;
+ rValue <<= ::com::sun::star::uno::Sequence< sal_Int8 >(
+ (sal_Int8*)aStrm.GetData(),
+ aStrm.Seek( STREAM_SEEK_TO_END ) );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOL ScImportExport::ImportString( const ::rtl::OUString& rText, ULONG nFmt )
+{
+ switch ( nFmt )
+ {
+ // formats supporting unicode
+ case FORMAT_STRING :
+ {
+ ScImportStringStream aStrm( rText);
+ return ImportStream( aStrm, String(), nFmt );
+ // ImportStream must handle RTL_TEXTENCODING_UNICODE
+ }
+ //break;
+ default:
+ {
+ rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
+ ::rtl::OString aTmp( rText.getStr(), rText.getLength(), eEnc );
+ SvMemoryStream aStrm( (void*)aTmp.getStr(), aTmp.getLength() * sizeof(sal_Char), STREAM_READ );
+ aStrm.SetStreamCharSet( eEnc );
+ SetNoEndianSwap( aStrm ); //! no swapping in memory
+ return ImportStream( aStrm, String(), nFmt );
+ }
+ }
+}
+
+
+BOOL ScImportExport::ExportString( ::rtl::OUString& rText, ULONG nFmt )
+{
+ DBG_ASSERT( nFmt == FORMAT_STRING, "ScImportExport::ExportString: Unicode not supported for other formats than FORMAT_STRING" );
+ if ( nFmt != FORMAT_STRING )
+ {
+ rtl_TextEncoding eEnc = gsl_getSystemTextEncoding();
+ ByteString aTmp;
+ BOOL bOk = ExportByteString( aTmp, eEnc, nFmt );
+ rText = UniString( aTmp, eEnc );
+ return bOk;
+ }
+ // nSizeLimit not needed for OUString
+
+ SvMemoryStream aStrm;
+ aStrm.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
+ SetNoEndianSwap( aStrm ); //! no swapping in memory
+ // mba: no BaseURL for data exc
+ if( ExportStream( aStrm, String(), nFmt ) )
+ {
+ aStrm << (sal_Unicode) 0;
+ aStrm.Seek( STREAM_SEEK_TO_END );
+
+ rText = rtl::OUString( (const sal_Unicode*) aStrm.GetData() );
+ return TRUE;
+ }
+ rText = rtl::OUString();
+ return FALSE;
+
+ // ExportStream must handle RTL_TEXTENCODING_UNICODE
+}
+
+
+BOOL ScImportExport::ExportByteString( ByteString& rText, rtl_TextEncoding eEnc, ULONG nFmt )
+{
+ DBG_ASSERT( eEnc != RTL_TEXTENCODING_UNICODE, "ScImportExport::ExportByteString: Unicode not supported" );
+ if ( eEnc == RTL_TEXTENCODING_UNICODE )
+ eEnc = gsl_getSystemTextEncoding();
+
+ if (!nSizeLimit)
+ nSizeLimit = STRING_MAXLEN;
+
+ SvMemoryStream aStrm;
+ aStrm.SetStreamCharSet( eEnc );
+ SetNoEndianSwap( aStrm ); //! no swapping in memory
+ // mba: no BaseURL for data exchange
+ if( ExportStream( aStrm, String(), nFmt ) )
+ {
+ aStrm << (sal_Char) 0;
+ aStrm.Seek( STREAM_SEEK_TO_END );
+ // Sicherheits-Check:
+ if( aStrm.Tell() <= (ULONG) STRING_MAXLEN )
+ {
+ rText = (const sal_Char*) aStrm.GetData();
+ return TRUE;
+ }
+ }
+ rText.Erase();
+ return FALSE;
+}
+
+
+BOOL ScImportExport::ImportStream( SvStream& rStrm, const String& rBaseURL, ULONG nFmt )
+{
+ if( nFmt == FORMAT_STRING )
+ {
+ if( ExtText2Doc( rStrm ) ) // pExtOptions auswerten
+ return TRUE;
+ }
+ if( nFmt == SOT_FORMATSTR_ID_SYLK )
+ {
+ if( Sylk2Doc( rStrm ) )
+ return TRUE;
+ }
+ if( nFmt == SOT_FORMATSTR_ID_DIF )
+ {
+ if( Dif2Doc( rStrm ) )
+ return TRUE;
+ }
+ if( nFmt == FORMAT_RTF )
+ {
+ if( RTF2Doc( rStrm, rBaseURL ) )
+ return TRUE;
+ }
+ if( nFmt == SOT_FORMATSTR_ID_LINK )
+ return TRUE; // Link-Import?
+ if ( nFmt == SOT_FORMATSTR_ID_HTML )
+ {
+ if( HTML2Doc( rStrm, rBaseURL ) )
+ return TRUE;
+ }
+ if ( nFmt == SOT_FORMATSTR_ID_HTML_SIMPLE )
+ {
+ MSE40HTMLClipFormatObj aMSE40ClpObj; // needed to skip the header data
+ SvStream* pHTML = aMSE40ClpObj.IsValid( rStrm );
+ if ( pHTML && HTML2Doc( *pHTML, rBaseURL ) )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+BOOL ScImportExport::ExportStream( SvStream& rStrm, const String& rBaseURL, ULONG nFmt )
+{
+ if( nFmt == FORMAT_STRING )
+ {
+ if( Doc2Text( rStrm ) )
+ return TRUE;
+ }
+ if( nFmt == SOT_FORMATSTR_ID_SYLK )
+ {
+ if( Doc2Sylk( rStrm ) )
+ return TRUE;
+ }
+ if( nFmt == SOT_FORMATSTR_ID_DIF )
+ {
+ if( Doc2Dif( rStrm ) )
+ return TRUE;
+ }
+ if( nFmt == SOT_FORMATSTR_ID_LINK && !bAll )
+ {
+ String aDocName;
+ if ( pDoc->IsClipboard() )
+ aDocName = ScGlobal::GetClipDocName();
+ else
+ {
+ SfxObjectShell* pShell = pDoc->GetDocumentShell();
+ if (pShell)
+ aDocName = pShell->GetTitle( SFX_TITLE_FULLNAME );
+ }
+
+ DBG_ASSERT( aDocName.Len(), "ClipBoard document has no name! :-/" );
+ if( aDocName.Len() )
+ {
+ String aRefName;
+ USHORT nFlags = SCA_VALID | SCA_TAB_3D;
+ if( bSingle )
+ aRange.aStart.Format( aRefName, nFlags, pDoc, pDoc->GetAddressConvention() );
+ else
+ {
+ if( aRange.aStart.Tab() != aRange.aEnd.Tab() )
+ nFlags |= SCA_TAB2_3D;
+ aRange.Format( aRefName, nFlags, pDoc );
+ }
+ String aAppName = Application::GetAppName();
+
+ WriteUnicodeOrByteString( rStrm, aAppName, TRUE );
+ WriteUnicodeOrByteString( rStrm, aDocName, TRUE );
+ WriteUnicodeOrByteString( rStrm, aRefName, TRUE );
+ if ( rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
+ rStrm << sal_Unicode(0);
+ else
+ rStrm << sal_Char(0);
+ return BOOL( rStrm.GetError() == SVSTREAM_OK );
+ }
+ }
+ if( nFmt == SOT_FORMATSTR_ID_HTML )
+ {
+ if( Doc2HTML( rStrm, rBaseURL ) )
+ return TRUE;
+ }
+ if( nFmt == FORMAT_RTF )
+ {
+ if( Doc2RTF( rStrm ) )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+//static
+void ScImportExport::WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero )
+{
+ rtl_TextEncoding eEnc = rStrm.GetStreamCharSet();
+ if ( eEnc == RTL_TEXTENCODING_UNICODE )
+ {
+ if ( !IsEndianSwap( rStrm ) )
+ rStrm.Write( rString.GetBuffer(), rString.Len() * sizeof(sal_Unicode) );
+ else
+ {
+ const sal_Unicode* p = rString.GetBuffer();
+ const sal_Unicode* const pStop = p + rString.Len();
+ while ( p < pStop )
+ {
+ rStrm << *p;
+ }
+ }
+ if ( bZero )
+ rStrm << sal_Unicode(0);
+ }
+ else
+ {
+ ByteString aByteStr( rString, eEnc );
+ rStrm << aByteStr.GetBuffer();
+ if ( bZero )
+ rStrm << sal_Char(0);
+ }
+}
+
+
+// This function could be replaced by endlub()
+// static
+void ScImportExport::WriteUnicodeOrByteEndl( SvStream& rStrm )
+{
+ if ( rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
+ { // same as endl() but unicode
+ switch ( rStrm.GetLineDelimiter() )
+ {
+ case LINEEND_CR :
+ rStrm << sal_Unicode(_CR);
+ break;
+ case LINEEND_LF :
+ rStrm << sal_Unicode(_LF);
+ break;
+ default:
+ rStrm << sal_Unicode(_CR) << sal_Unicode(_LF);
+ }
+ }
+ else
+ endl( rStrm );
+}
+
+
+enum DoubledQuoteMode
+{
+ DQM_KEEP, // both are taken
+ DQM_ESCAPE, // escaped quote, one is taken, one ignored
+ DQM_CONCAT, // first is end, next is start, both ignored => strings combined
+ DQM_SEPARATE // end one string and begin next
+};
+
+static const sal_Unicode* lcl_ScanString( const sal_Unicode* p, String& rString,
+ sal_Unicode cStr, DoubledQuoteMode eMode )
+{
+ p++; //! jump over opening quote
+ BOOL bCont;
+ do
+ {
+ bCont = FALSE;
+ const sal_Unicode* p0 = p;
+ for( ;; )
+ {
+ if( !*p )
+ break;
+ if( *p == cStr )
+ {
+ if ( *++p != cStr )
+ break;
+ // doubled quote char
+ switch ( eMode )
+ {
+ case DQM_KEEP :
+ p++; // both for us (not breaking for-loop)
+ break;
+ case DQM_ESCAPE :
+ p++; // one for us (breaking for-loop)
+ bCont = TRUE; // and more
+ break;
+ case DQM_CONCAT :
+ if ( p0+1 < p )
+ rString.Append( p0, sal::static_int_cast<xub_StrLen>( (p-1) - p0 ) ); // first part
+ p0 = ++p; // text of next part starts here
+ break;
+ case DQM_SEPARATE :
+ // positioned on next opening quote
+ break;
+ }
+ if ( eMode == DQM_ESCAPE || eMode == DQM_SEPARATE )
+ break;
+ }
+ else
+ p++;
+ }
+ if ( p0 < p )
+ rString.Append( p0, sal::static_int_cast<xub_StrLen>( ((*p || *(p-1) == cStr) ? p-1 : p) - p0 ) );
+ } while ( bCont );
+ return p;
+}
+
+void lcl_UnescapeSylk( String & rString, SylkVersion eVersion )
+{
+ // Older versions didn't escape the semicolon.
+ // Older versions quoted the string and doubled embedded quotes, but not
+ // the semicolons, which was plain wrong.
+ if (eVersion >= SYLK_OOO32)
+ rString.SearchAndReplaceAll( DOUBLE_SEMICOLON, ';' );
+ else
+ rString.SearchAndReplaceAll( DOUBLE_DOUBLEQUOTE, '"' );
+
+ rString.SearchAndReplaceAll( SYLK_LF, _LF );
+}
+
+static const sal_Unicode* lcl_ScanSylkString( const sal_Unicode* p,
+ String& rString, SylkVersion eVersion )
+{
+ const sal_Unicode* pStartQuote = p;
+ const sal_Unicode* pEndQuote = 0;
+ while( *(++p) )
+ {
+ if( *p == '"' )
+ {
+ pEndQuote = p;
+ if (eVersion >= SYLK_OOO32)
+ {
+ if (*(p+1) == ';')
+ {
+ if (*(p+2) == ';')
+ {
+ p += 2; // escaped ';'
+ pEndQuote = 0;
+ }
+ else
+ break; // end field
+ }
+ }
+ else
+ {
+ if (*(p+1) == '"')
+ {
+ ++p; // escaped '"'
+ pEndQuote = 0;
+ }
+ else if (*(p+1) == ';')
+ break; // end field
+ }
+ }
+ }
+ if (!pEndQuote)
+ pEndQuote = p; // Take all data as string.
+ rString.Append( pStartQuote + 1, sal::static_int_cast<xub_StrLen>( pEndQuote - pStartQuote - 1 ) );
+ lcl_UnescapeSylk( rString, eVersion);
+ return p;
+}
+
+static const sal_Unicode* lcl_ScanSylkFormula( const sal_Unicode* p,
+ String& rString, SylkVersion eVersion )
+{
+ const sal_Unicode* pStart = p;
+ if (eVersion >= SYLK_OOO32)
+ {
+ while (*p)
+ {
+ if (*p == ';')
+ {
+ if (*(p+1) == ';')
+ ++p; // escaped ';'
+ else
+ break; // end field
+ }
+ ++p;
+ }
+ rString.Append( pStart, sal::static_int_cast<xub_StrLen>( p - pStart));
+ lcl_UnescapeSylk( rString, eVersion);
+ }
+ else
+ {
+ // Nasty. If in old versions the formula contained a semicolon, it was
+ // quoted and embedded quotes were doubled, but semicolons were not. If
+ // there was no semicolon, it could still contain quotes and doubled
+ // embedded quotes if it was something like ="a""b", which was saved as
+ // E"a""b" as is and has to be preserved, even if older versions
+ // couldn't even load it correctly. However, theoretically another
+ // field might follow and thus the line contain a semicolon again, such
+ // as ...;E"a""b";...
+ bool bQuoted = false;
+ if (*p == '"')
+ {
+ // May be a quoted expression or just a string constant expression
+ // with quotes.
+ while (*(++p))
+ {
+ if (*p == '"')
+ {
+ if (*(p+1) == '"')
+ ++p; // escaped '"'
+ else
+ break; // closing '"', had no ';' yet
+ }
+ else if (*p == ';')
+ {
+ bQuoted = true; // ';' within quoted expression
+ break;
+ }
+ }
+ p = pStart;
+ }
+ if (bQuoted)
+ p = lcl_ScanSylkString( p, rString, eVersion);
+ else
+ {
+ while (*p && *p != ';')
+ ++p;
+ rString.Append( pStart, sal::static_int_cast<xub_StrLen>( p - pStart));
+ }
+ }
+ return p;
+}
+
+static void lcl_DoubleEscapeChar( String& rString, sal_Unicode cStr )
+{
+ xub_StrLen n = 0;
+ while( ( n = rString.Search( cStr, n ) ) != STRING_NOTFOUND )
+ {
+ rString.Insert( cStr, n );
+ n += 2;
+ }
+}
+
+static void lcl_WriteString( SvStream& rStrm, String& rString, sal_Unicode cQuote, sal_Unicode cEsc )
+{
+ if (cEsc)
+ lcl_DoubleEscapeChar( rString, cEsc );
+
+ if (cQuote)
+ {
+ rString.Insert( cQuote, 0 );
+ rString.Append( cQuote );
+ }
+
+ ScImportExport::WriteUnicodeOrByteString( rStrm, rString );
+}
+
+inline void lcl_WriteSimpleString( SvStream& rStrm, const String& rString )
+{
+ ScImportExport::WriteUnicodeOrByteString( rStrm, rString );
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
+
+BOOL ScImportExport::Text2Doc( SvStream& rStrm )
+{
+ BOOL bOk = TRUE;
+
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ ULONG nOldPos = rStrm.Tell();
+ if ( rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
+ rStrm.StartReadingUnicodeText();
+ BOOL bData = BOOL( !bSingle );
+ if( !bSingle)
+ bOk = StartPaste();
+
+ while( bOk )
+ {
+ ByteString aByteLine;
+ String aLine, aCell;
+ SCROW nRow = nStartRow;
+ rStrm.Seek( nOldPos );
+ for( ;; )
+ {
+ rStrm.ReadUniOrByteStringLine( aLine );
+ if( rStrm.IsEof() )
+ break;
+ SCCOL nCol = nStartCol;
+ const sal_Unicode* p = aLine.GetBuffer();
+ while( *p )
+ {
+ aCell.Erase();
+ if( *p == cStr )
+ {
+ p = lcl_ScanString( p, aCell, cStr, DQM_KEEP );
+ while( *p && *p != cSep )
+ p++;
+ if( *p )
+ p++;
+ }
+ else
+ {
+ const sal_Unicode* q = p;
+ while( *p && *p != cSep )
+ p++;
+ aCell.Assign( q, sal::static_int_cast<xub_StrLen>( p - q ) );
+ if( *p )
+ p++;
+ }
+ if (ValidCol(nCol) && ValidRow(nRow) )
+ {
+ if( bSingle )
+ {
+ if (nCol>nEndCol) nEndCol = nCol;
+ if (nRow>nEndRow) nEndRow = nRow;
+ }
+ if( bData && nCol <= nEndCol && nRow <= nEndRow )
+ pDoc->SetString( nCol, nRow, aRange.aStart.Tab(), aCell );
+ }
+ else // zuviele Spalten/Zeilen
+ bOverflow = TRUE; // beim Import Warnung ausgeben
+ ++nCol;
+ }
+ ++nRow;
+ }
+
+ if( !bData )
+ {
+ aRange.aEnd.SetCol( nEndCol );
+ aRange.aEnd.SetRow( nEndRow );
+ bOk = StartPaste();
+ bData = TRUE;
+ }
+ else
+ break;
+ }
+
+ EndPaste();
+ return bOk;
+}
+
+ //
+ // erweiterter Ascii-Import
+ //
+
+
+static bool lcl_PutString(
+ ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rStr, BYTE nColFormat,
+ SvNumberFormatter* pFormatter, bool bDetectNumFormat,
+ ::utl::TransliterationWrapper& rTransliteration, CalendarWrapper& rCalendar,
+ ::utl::TransliterationWrapper* pSecondTransliteration, CalendarWrapper* pSecondCalendar )
+{
+ bool bMultiLine = false;
+ if ( nColFormat == SC_COL_SKIP || !rStr.Len() || !ValidCol(nCol) || !ValidRow(nRow) )
+ return bMultiLine;
+
+ if ( nColFormat == SC_COL_TEXT )
+ {
+ double fDummy;
+ sal_uInt32 nIndex;
+ if (pFormatter->IsNumberFormat(rStr, nIndex, fDummy))
+ {
+ // Set the format of this cell to Text.
+ sal_uInt32 nFormat = pFormatter->GetStandardFormat(NUMBERFORMAT_TEXT);
+ ScPatternAttr aNewAttrs(pDoc->GetPool());
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ rSet.Put( SfxUInt32Item(ATTR_VALUE_FORMAT, nFormat) );
+ pDoc->ApplyPattern(nCol, nRow, nTab, aNewAttrs);
+
+ }
+ pDoc->PutCell( nCol, nRow, nTab, ScBaseCell::CreateTextCell( rStr, pDoc ) );
+ return bMultiLine;
+ }
+
+ if ( nColFormat == SC_COL_ENGLISH )
+ {
+ //! SetString mit Extra-Flag ???
+
+ SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nEnglish = pDocFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
+ double fVal;
+ if ( pDocFormatter->IsNumberFormat( rStr, nEnglish, fVal ) )
+ {
+ // Zahlformat wird nicht auf englisch gesetzt
+ pDoc->SetValue( nCol, nRow, nTab, fVal );
+ return bMultiLine;
+ }
+ // sonst weiter mit SetString
+ }
+ else if ( nColFormat != SC_COL_STANDARD ) // Datumsformate
+ {
+ const USHORT nMaxNumberParts = 7; // Y-M-D h:m:s.t
+ xub_StrLen nLen = rStr.Len();
+ xub_StrLen nStart[nMaxNumberParts];
+ xub_StrLen nEnd[nMaxNumberParts];
+
+ USHORT nDP, nMP, nYP;
+ switch ( nColFormat )
+ {
+ case SC_COL_YMD: nDP = 2; nMP = 1; nYP = 0; break;
+ case SC_COL_MDY: nDP = 1; nMP = 0; nYP = 2; break;
+ case SC_COL_DMY:
+ default: nDP = 0; nMP = 1; nYP = 2; break;
+ }
+
+ USHORT nFound = 0;
+ BOOL bInNum = FALSE;
+ for ( xub_StrLen nPos=0; nPos<nLen && (bInNum ||
+ nFound<nMaxNumberParts); nPos++ )
+ {
+ if (bInNum && nFound == 3 && nColFormat == SC_COL_YMD &&
+ nPos <= nStart[nFound]+2 && rStr.GetChar(nPos) == 'T')
+ bInNum = FALSE; // ISO-8601: YYYY-MM-DDThh:mm...
+ else if ((((!bInNum && nFound==nMP) || (bInNum && nFound==nMP+1))
+ && ScGlobal::pCharClass->isLetterNumeric( rStr, nPos))
+ || ScGlobal::pCharClass->isDigit( rStr, nPos))
+ {
+ if (!bInNum)
+ {
+ bInNum = TRUE;
+ nStart[nFound] = nPos;
+ ++nFound;
+ }
+ nEnd[nFound-1] = nPos;
+ }
+ else
+ bInNum = FALSE;
+ }
+
+ if ( nFound == 1 )
+ {
+ // try to break one number (without separators) into date fields
+
+ xub_StrLen nDateStart = nStart[0];
+ xub_StrLen nDateLen = nEnd[0] + 1 - nDateStart;
+
+ if ( nDateLen >= 5 && nDateLen <= 8 &&
+ ScGlobal::pCharClass->isNumeric( rStr.Copy( nDateStart, nDateLen ) ) )
+ {
+ // 6 digits: 2 each for day, month, year
+ // 8 digits: 4 for year, 2 each for day and month
+ // 5 or 7 digits: first field is shortened by 1
+
+ BOOL bLongYear = ( nDateLen >= 7 );
+ BOOL bShortFirst = ( nDateLen == 5 || nDateLen == 7 );
+
+ USHORT nFieldStart = nDateStart;
+ for (USHORT nPos=0; nPos<3; nPos++)
+ {
+ USHORT nFieldEnd = nFieldStart + 1; // default: 2 digits
+ if ( bLongYear && nPos == nYP )
+ nFieldEnd += 2; // 2 extra digits for long year
+ if ( bShortFirst && nPos == 0 )
+ --nFieldEnd; // first field shortened?
+
+ nStart[nPos] = nFieldStart;
+ nEnd[nPos] = nFieldEnd;
+ nFieldStart = nFieldEnd + 1;
+ }
+ nFound = 3;
+ }
+ }
+
+ if ( nFound >= 3 )
+ {
+ using namespace ::com::sun::star;
+ BOOL bSecondCal = FALSE;
+ USHORT nDay = (USHORT) rStr.Copy( nStart[nDP], nEnd[nDP]+1-nStart[nDP] ).ToInt32();
+ USHORT nYear = (USHORT) rStr.Copy( nStart[nYP], nEnd[nYP]+1-nStart[nYP] ).ToInt32();
+ String aMStr = rStr.Copy( nStart[nMP], nEnd[nMP]+1-nStart[nMP] );
+ sal_Int16 nMonth = (sal_Int16) aMStr.ToInt32();
+ if (!nMonth)
+ {
+ static const String aSeptCorrect( RTL_CONSTASCII_USTRINGPARAM( "SEPT" ) );
+ static const String aSepShortened( RTL_CONSTASCII_USTRINGPARAM( "SEP" ) );
+ uno::Sequence< i18n::CalendarItem > xMonths;
+ sal_Int32 i, nMonthCount;
+ // first test all month names from local international
+ xMonths = rCalendar.getMonths();
+ nMonthCount = xMonths.getLength();
+ for (i=0; i<nMonthCount && !nMonth; i++)
+ {
+ if ( rTransliteration.isEqual( aMStr, xMonths[i].FullName ) ||
+ rTransliteration.isEqual( aMStr, xMonths[i].AbbrevName ) )
+ nMonth = sal::static_int_cast<sal_Int16>( i+1 );
+ else if ( i == 8 && rTransliteration.isEqual( aSeptCorrect,
+ xMonths[i].AbbrevName ) &&
+ rTransliteration.isEqual( aMStr, aSepShortened ) )
+ { // #102136# correct English abbreviation is SEPT,
+ // but data mostly contains SEP only
+ nMonth = sal::static_int_cast<sal_Int16>( i+1 );
+ }
+ }
+ // if none found, then test english month names
+ if ( !nMonth && pSecondCalendar && pSecondTransliteration )
+ {
+ xMonths = pSecondCalendar->getMonths();
+ nMonthCount = xMonths.getLength();
+ for (i=0; i<nMonthCount && !nMonth; i++)
+ {
+ if ( pSecondTransliteration->isEqual( aMStr, xMonths[i].FullName ) ||
+ pSecondTransliteration->isEqual( aMStr, xMonths[i].AbbrevName ) )
+ {
+ nMonth = sal::static_int_cast<sal_Int16>( i+1 );
+ bSecondCal = TRUE;
+ }
+ else if ( i == 8 && pSecondTransliteration->isEqual(
+ aMStr, aSepShortened ) )
+ { // #102136# correct English abbreviation is SEPT,
+ // but data mostly contains SEP only
+ nMonth = sal::static_int_cast<sal_Int16>( i+1 );
+ bSecondCal = TRUE;
+ }
+ }
+ }
+ }
+
+ SvNumberFormatter* pDocFormatter = pDoc->GetFormatTable();
+ if ( nYear < 100 )
+ nYear = pDocFormatter->ExpandTwoDigitYear( nYear );
+
+ CalendarWrapper* pCalendar = (bSecondCal ? pSecondCalendar : &rCalendar);
+ sal_Int16 nNumMonths = pCalendar->getNumberOfMonthsInYear();
+ if ( nDay && nMonth && nDay<=31 && nMonth<=nNumMonths )
+ {
+ --nMonth;
+ pCalendar->setValue( i18n::CalendarFieldIndex::DAY_OF_MONTH, nDay );
+ pCalendar->setValue( i18n::CalendarFieldIndex::MONTH, nMonth );
+ pCalendar->setValue( i18n::CalendarFieldIndex::YEAR, nYear );
+ sal_Int16 nHour, nMinute, nSecond, nMilli;
+ // #i14974# The imported value should have no fractional value, so set the
+ // time fields to zero (ICU calendar instance defaults to current date/time)
+ nHour = nMinute = nSecond = nMilli = 0;
+ if (nFound > 3)
+ nHour = (sal_Int16) rStr.Copy( nStart[3], nEnd[3]+1-nStart[3]).ToInt32();
+ if (nFound > 4)
+ nMinute = (sal_Int16) rStr.Copy( nStart[4], nEnd[4]+1-nStart[4]).ToInt32();
+ if (nFound > 5)
+ nSecond = (sal_Int16) rStr.Copy( nStart[5], nEnd[5]+1-nStart[5]).ToInt32();
+ if (nFound > 6)
+ {
+ sal_Unicode cDec = '.';
+ rtl::OUString aT( &cDec, 1);
+ aT += rStr.Copy( nStart[6], nEnd[6]+1-nStart[6]);
+ rtl_math_ConversionStatus eStatus;
+ double fV = rtl::math::stringToDouble( aT, cDec, 0, &eStatus, 0);
+ if (eStatus == rtl_math_ConversionStatus_Ok)
+ nMilli = (sal_Int16) (1000.0 * fV + 0.5);
+ }
+ pCalendar->setValue( i18n::CalendarFieldIndex::HOUR, nHour );
+ pCalendar->setValue( i18n::CalendarFieldIndex::MINUTE, nMinute );
+ pCalendar->setValue( i18n::CalendarFieldIndex::SECOND, nSecond );
+ pCalendar->setValue( i18n::CalendarFieldIndex::MILLISECOND, nMilli );
+ if ( pCalendar->isValid() )
+ {
+ double fDiff = DateTime(*pDocFormatter->GetNullDate()) -
+ pCalendar->getEpochStart();
+ // #i14974# must use getLocalDateTime to get the same
+ // date values as set above
+ double fDays = pCalendar->getLocalDateTime();
+ fDays -= fDiff;
+
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ LanguageType eDocLang = eLatin; //! which language for date formats?
+
+ short nType = (nFound > 3 ? NUMBERFORMAT_DATETIME : NUMBERFORMAT_DATE);
+ ULONG nFormat = pDocFormatter->GetStandardFormat( nType, eDocLang );
+ // maybe there is a special format including seconds or milliseconds
+ if (nFound > 5)
+ nFormat = pDocFormatter->GetStandardFormat( fDays, nFormat, nType, eDocLang);
+
+ pDoc->PutCell( nCol, nRow, nTab, new ScValueCell(fDays), nFormat, FALSE );
+
+ return bMultiLine; // success
+ }
+ }
+ }
+ }
+
+ // Standard or date not determined -> SetString / EditCell
+ if( rStr.Search( _LF ) == STRING_NOTFOUND )
+ {
+ ScSetStringParam aParam;
+ aParam.mpNumFormatter = pFormatter;
+ aParam.mbDetectNumberFormat = bDetectNumFormat;
+ aParam.mbSetTextCellFormat = true;
+ pDoc->SetString( nCol, nRow, nTab, rStr, &aParam );
+ }
+ else
+ {
+ bMultiLine = true;
+ pDoc->PutCell( nCol, nRow, nTab, new ScEditCell( rStr, pDoc ) );
+ }
+ return bMultiLine;
+}
+
+
+String lcl_GetFixed( const String& rLine, xub_StrLen nStart, xub_StrLen nNext, bool& rbIsQuoted )
+{
+ xub_StrLen nLen = rLine.Len();
+ if (nNext > nLen)
+ nNext = nLen;
+ if ( nNext <= nStart )
+ return EMPTY_STRING;
+
+ const sal_Unicode* pStr = rLine.GetBuffer();
+
+ xub_StrLen nSpace = nNext;
+ while ( nSpace > nStart && pStr[nSpace-1] == ' ' )
+ --nSpace;
+
+ rbIsQuoted = (pStr[nStart] == sal_Unicode('"') && pStr[nSpace-1] == sal_Unicode('"'));
+ if (rbIsQuoted)
+ return rLine.Copy(nStart+1, nSpace-nStart-2);
+ else
+ return rLine.Copy(nStart, nSpace-nStart);
+}
+
+BOOL ScImportExport::ExtText2Doc( SvStream& rStrm )
+{
+ if (!pExtOptions)
+ return Text2Doc( rStrm );
+
+ ULONG nOldPos = rStrm.Tell();
+ rStrm.Seek( STREAM_SEEK_TO_END );
+ ::std::auto_ptr<ScProgress> xProgress( new ScProgress( pDocSh,
+ ScGlobal::GetRscString( STR_LOAD_DOC ), rStrm.Tell() - nOldPos ));
+ rStrm.Seek( nOldPos );
+ if ( rStrm.GetStreamCharSet() == RTL_TEXTENCODING_UNICODE )
+ rStrm.StartReadingUnicodeText();
+
+ ScColumn::DoubleAllocSwitch aAllocSwitch(true);
+
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ BOOL bFixed = pExtOptions->IsFixedLen();
+ const String& rSeps = pExtOptions->GetFieldSeps();
+ const sal_Unicode* pSeps = rSeps.GetBuffer();
+ BOOL bMerge = pExtOptions->IsMergeSeps();
+ USHORT nInfoCount = pExtOptions->GetInfoCount();
+ const xub_StrLen* pColStart = pExtOptions->GetColStart();
+ const BYTE* pColFormat = pExtOptions->GetColFormat();
+ long nSkipLines = pExtOptions->GetStartRow();
+
+ LanguageType eDocLang = pExtOptions->GetLanguage();
+ SvNumberFormatter aNumFormatter(pDoc->GetServiceManager(), eDocLang);
+ bool bDetectNumFormat = pExtOptions->IsDetectSpecialNumber();
+
+ // For date recognition
+ ::utl::TransliterationWrapper aTransliteration(
+ pDoc->GetServiceManager(), SC_TRANSLITERATION_IGNORECASE );
+ aTransliteration.loadModuleIfNeeded( eDocLang );
+ CalendarWrapper aCalendar( pDoc->GetServiceManager() );
+ aCalendar.loadDefaultCalendar(
+ MsLangId::convertLanguageToLocale( eDocLang ) );
+ ::utl::TransliterationWrapper* pEnglishTransliteration = NULL;
+ CalendarWrapper* pEnglishCalendar = NULL;
+ if ( eDocLang != LANGUAGE_ENGLISH_US )
+ {
+ pEnglishTransliteration = new ::utl::TransliterationWrapper (
+ pDoc->GetServiceManager(), SC_TRANSLITERATION_IGNORECASE );
+ aTransliteration.loadModuleIfNeeded( LANGUAGE_ENGLISH_US );
+ pEnglishCalendar = new CalendarWrapper ( pDoc->GetServiceManager() );
+ pEnglishCalendar->loadDefaultCalendar(
+ MsLangId::convertLanguageToLocale( LANGUAGE_ENGLISH_US ) );
+ }
+
+ String aLine, aCell;
+ USHORT i;
+ SCROW nRow = nStartRow;
+
+ while(--nSkipLines>0)
+ {
+ rStrm.ReadCsvLine( aLine, !bFixed, rSeps, cStr); // content is ignored
+ if ( rStrm.IsEof() )
+ break;
+ }
+
+ // Determine range for Undo.
+ // TODO: we don't need this during import of a file to a new sheet or
+ // document, could set bDetermineRange=false then.
+ bool bDetermineRange = true;
+
+ // Row heights don't need to be adjusted on the fly if EndPaste() is called
+ // afterwards, which happens only if bDetermineRange. This variable also
+ // survives the toggle of bDetermineRange down at the end of the do{} loop.
+ bool bRangeIsDetermined = bDetermineRange;
+
+ bool bQuotedAsText = pExtOptions && pExtOptions->IsQuotedAsText();
+
+ ULONG nOriginalStreamPos = rStrm.Tell();
+
+ do
+ {
+ for( ;; )
+ {
+ rStrm.ReadCsvLine( aLine, !bFixed, rSeps, cStr);
+ if ( rStrm.IsEof() )
+ break;
+
+ xub_StrLen nLineLen = aLine.Len();
+ SCCOL nCol = nStartCol;
+ bool bMultiLine = false;
+ if ( bFixed ) // Feste Satzlaenge
+ {
+ // Yes, the check is nCol<=MAXCOL+1, +1 because it is only an
+ // overflow if there is really data following to be put behind
+ // the last column, which doesn't happen if info is
+ // SC_COL_SKIP.
+ for ( i=0; i<nInfoCount && nCol <= MAXCOL+1; i++ )
+ {
+ BYTE nFmt = pColFormat[i];
+ if (nFmt != SC_COL_SKIP) // sonst auch nCol nicht hochzaehlen
+ {
+ if (nCol > MAXCOL)
+ bOverflow = TRUE; // display warning on import
+ else if (!bDetermineRange)
+ {
+ xub_StrLen nStart = pColStart[i];
+ xub_StrLen nNext = ( i+1 < nInfoCount ) ? pColStart[i+1] : nLineLen;
+ bool bIsQuoted = false;
+ aCell = lcl_GetFixed( aLine, nStart, nNext, bIsQuoted );
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ pDoc, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, aTransliteration, aCalendar,
+ pEnglishTransliteration, pEnglishCalendar);
+ }
+ ++nCol;
+ }
+ }
+ }
+ else // Nach Trennzeichen suchen
+ {
+ SCCOL nSourceCol = 0;
+ USHORT nInfoStart = 0;
+ const sal_Unicode* p = aLine.GetBuffer();
+ // Yes, the check is nCol<=MAXCOL+1, +1 because it is only an
+ // overflow if there is really data following to be put behind
+ // the last column, which doesn't happen if info is
+ // SC_COL_SKIP.
+ while (*p && nCol <= MAXCOL+1)
+ {
+ bool bIsQuoted = false;
+ p = ScImportExport::ScanNextFieldFromString( p, aCell, cStr, pSeps, bMerge, bIsQuoted );
+
+ BYTE nFmt = SC_COL_STANDARD;
+ for ( i=nInfoStart; i<nInfoCount; i++ )
+ {
+ if ( pColStart[i] == nSourceCol + 1 ) // pColStart ist 1-basiert
+ {
+ nFmt = pColFormat[i];
+ nInfoStart = i + 1; // ColInfos sind in Reihenfolge
+ break; // for
+ }
+ }
+ if ( nFmt != SC_COL_SKIP )
+ {
+ if (nCol > MAXCOL)
+ bOverflow = TRUE; // display warning on import
+ else if (!bDetermineRange)
+ {
+ if (bIsQuoted && bQuotedAsText)
+ nFmt = SC_COL_TEXT;
+
+ bMultiLine |= lcl_PutString(
+ pDoc, nCol, nRow, nTab, aCell, nFmt,
+ &aNumFormatter, bDetectNumFormat, aTransliteration,
+ aCalendar, pEnglishTransliteration, pEnglishCalendar);
+ }
+ ++nCol;
+ }
+
+ ++nSourceCol;
+ }
+ }
+ if (nEndCol < nCol)
+ nEndCol = nCol; //! points to the next free or even MAXCOL+2
+
+ if (!bDetermineRange)
+ {
+ if (bMultiLine && !bRangeIsDetermined && pDocSh)
+ pDocSh->AdjustRowHeight( nRow, nRow, nTab);
+ xProgress->SetStateOnPercent( rStrm.Tell() - nOldPos );
+ }
+ ++nRow;
+ if ( nRow > MAXROW )
+ {
+ bOverflow = TRUE; // display warning on import
+ break; // for
+ }
+ }
+ // so far nRow/nEndCol pointed to the next free
+ if (nRow > nStartRow)
+ --nRow;
+ if (nEndCol > nStartCol)
+ nEndCol = ::std::min( static_cast<SCCOL>(nEndCol - 1), MAXCOL);
+
+ if (bDetermineRange)
+ {
+ aRange.aEnd.SetCol( nEndCol );
+ aRange.aEnd.SetRow( nRow );
+
+ if ( !mbApi && nStartCol != nEndCol &&
+ !pDoc->IsBlockEmpty( nTab, nStartCol + 1, nStartRow, nEndCol, nRow ) )
+ {
+ ScReplaceWarnBox aBox( pDocSh->GetActiveDialogParent() );
+ if ( aBox.Execute() != RET_YES )
+ {
+ delete pEnglishTransliteration;
+ delete pEnglishCalendar;
+ return FALSE;
+ }
+ }
+
+ rStrm.Seek( nOriginalStreamPos );
+ nRow = nStartRow;
+ if (!StartPaste())
+ {
+ EndPaste();
+ return FALSE;
+ }
+ }
+
+ bDetermineRange = !bDetermineRange; // toggle
+ } while (!bDetermineRange);
+
+ pDoc->DoColResize( nTab, nStartCol, nEndCol, 0 );
+
+ delete pEnglishTransliteration;
+ delete pEnglishCalendar;
+
+ xProgress.reset(); // make room for AdjustRowHeight progress
+ if (bRangeIsDetermined)
+ EndPaste();
+
+ return TRUE;
+}
+
+
+// static
+const sal_Unicode* ScImportExport::ScanNextFieldFromString( const sal_Unicode* p,
+ String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted )
+{
+ rbIsQuoted = false;
+ rField.Erase();
+ if ( *p == cStr ) // String in Anfuehrungszeichen
+ {
+ rbIsQuoted = true;
+ const sal_Unicode* p1;
+ p1 = p = lcl_ScanString( p, rField, cStr, DQM_ESCAPE );
+ while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
+ p++;
+ // Append remaining unquoted and undelimited data (dirty, dirty) to
+ // this field.
+ if (p > p1)
+ rField.Append( p1, sal::static_int_cast<xub_StrLen>( p - p1 ) );
+ if( *p )
+ p++;
+ }
+ else // bis zum Trennzeichen
+ {
+ const sal_Unicode* p0 = p;
+ while ( *p && !ScGlobal::UnicodeStrChr( pSeps, *p ) )
+ p++;
+ rField.Append( p0, sal::static_int_cast<xub_StrLen>( p - p0 ) );
+ if( *p )
+ p++;
+ }
+ if ( bMergeSeps ) // folgende Trennzeichen ueberspringen
+ {
+ while ( *p && ScGlobal::UnicodeStrChr( pSeps, *p ) )
+ p++;
+ }
+ return p;
+}
+
+ //
+ //
+ //
+
+
+BOOL ScImportExport::Doc2Text( SvStream& rStrm )
+{
+ SCCOL nCol;
+ SCROW nRow;
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ String aCell;
+ bool bConvertLF = (GetSystemLineEnd() != LINEEND_LF);
+
+ for (nRow = nStartRow; nRow <= nEndRow; nRow++)
+ {
+ if (bIncludeFiltered || !pDoc->RowFiltered( nRow, aRange.aStart.Tab() ))
+ {
+ for (nCol = nStartCol; nCol <= nEndCol; nCol++)
+ {
+ CellType eType;
+ pDoc->GetCellType( nCol, nRow, aRange.aStart.Tab(), eType );
+ switch (eType)
+ {
+ case CELLTYPE_FORMULA:
+ {
+ if (bFormulas)
+ {
+ pDoc->GetFormula( nCol, nRow, aRange.aStart.Tab(), aCell, TRUE );
+ if( aCell.Search( cSep ) != STRING_NOTFOUND )
+ lcl_WriteString( rStrm, aCell, cStr, cStr );
+ else
+ lcl_WriteSimpleString( rStrm, aCell );
+ }
+ else
+ {
+ pDoc->GetString( nCol, nRow, aRange.aStart.Tab(), aCell );
+
+ bool bMultiLineText = ( aCell.Search( _LF ) != STRING_NOTFOUND );
+ if( bMultiLineText )
+ {
+ if( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSpace )
+ aCell.SearchAndReplaceAll( _LF, ' ' );
+ else if ( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSystem && bConvertLF )
+ aCell.ConvertLineEnd();
+ }
+
+ if( mExportTextOptions.mcSeparatorConvertTo && cSep )
+ aCell.SearchAndReplaceAll( cSep, mExportTextOptions.mcSeparatorConvertTo );
+
+ if( mExportTextOptions.mbAddQuotes && ( aCell.Search( cSep ) != STRING_NOTFOUND ) )
+ lcl_WriteString( rStrm, aCell, cStr, cStr );
+ else
+ lcl_WriteSimpleString( rStrm, aCell );
+ }
+ }
+ break;
+ case CELLTYPE_VALUE:
+ {
+ pDoc->GetString( nCol, nRow, aRange.aStart.Tab(), aCell );
+ lcl_WriteSimpleString( rStrm, aCell );
+ }
+ break;
+ case CELLTYPE_NOTE:
+ case CELLTYPE_NONE:
+ break;
+ default:
+ {
+ pDoc->GetString( nCol, nRow, aRange.aStart.Tab(), aCell );
+
+ bool bMultiLineText = ( aCell.Search( _LF ) != STRING_NOTFOUND );
+ if( bMultiLineText )
+ {
+ if( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSpace )
+ aCell.SearchAndReplaceAll( _LF, ' ' );
+ else if ( mExportTextOptions.meNewlineConversion == ScExportTextOptions::ToSystem && bConvertLF )
+ aCell.ConvertLineEnd();
+ }
+
+ if( mExportTextOptions.mcSeparatorConvertTo && cSep )
+ aCell.SearchAndReplaceAll( cSep, mExportTextOptions.mcSeparatorConvertTo );
+
+ if( mExportTextOptions.mbAddQuotes && ( aCell.Search( cSep ) != STRING_NOTFOUND ) )
+ lcl_WriteString( rStrm, aCell, cStr, cStr );
+ else
+ lcl_WriteSimpleString( rStrm, aCell );
+ }
+ }
+ if( nCol < nEndCol )
+ lcl_WriteSimpleString( rStrm, String(cSep) );
+ }
+// if( nRow < nEndRow )
+ WriteUnicodeOrByteEndl( rStrm );
+ if( rStrm.GetError() != SVSTREAM_OK )
+ break;
+ if( nSizeLimit && rStrm.Tell() > nSizeLimit )
+ break;
+ }
+ }
+
+ return BOOL( rStrm.GetError() == SVSTREAM_OK );
+}
+
+
+BOOL ScImportExport::Sylk2Doc( SvStream& rStrm )
+{
+ BOOL bOk = TRUE;
+ BOOL bMyDoc = FALSE;
+ SylkVersion eVersion = SYLK_OTHER;
+
+ // US-English separators for StringToDouble
+ sal_Unicode cDecSep = '.';
+ sal_Unicode cGrpSep = ',';
+
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ ULONG nOldPos = rStrm.Tell();
+ BOOL bData = BOOL( !bSingle );
+ SvULongs aFormats;
+
+ if( !bSingle)
+ bOk = StartPaste();
+
+ while( bOk )
+ {
+ String aLine;
+ String aText;
+ ByteString aByteLine;
+ SCCOL nCol = nStartCol;
+ SCROW nRow = nStartRow;
+ SCCOL nRefCol = 1;
+ SCROW nRefRow = 1;
+ rStrm.Seek( nOldPos );
+ for( ;; )
+ {
+ //! allow unicode
+ rStrm.ReadLine( aByteLine );
+ aLine = String( aByteLine, rStrm.GetStreamCharSet() );
+ if( rStrm.IsEof() )
+ break;
+ const sal_Unicode* p = aLine.GetBuffer();
+ sal_Unicode cTag = *p++;
+ if( cTag == 'C' ) // Content
+ {
+ if( *p++ != ';' )
+ return FALSE;
+ while( *p )
+ {
+ sal_Unicode ch = *p++;
+ ch = ScGlobal::ToUpperAlpha( ch );
+ switch( ch )
+ {
+ case 'X':
+ nCol = static_cast<SCCOL>(String( p ).ToInt32()) + nStartCol - 1;
+ break;
+ case 'Y':
+ nRow = String( p ).ToInt32() + nStartRow - 1;
+ break;
+ case 'C':
+ nRefCol = static_cast<SCCOL>(String( p ).ToInt32()) + nStartCol - 1;
+ break;
+ case 'R':
+ nRefRow = String( p ).ToInt32() + nStartRow - 1;
+ break;
+ case 'K':
+ {
+ if( !bSingle &&
+ ( nCol < nStartCol || nCol > nEndCol
+ || nRow < nStartRow || nRow > nEndRow
+ || nCol > MAXCOL || nRow > MAXROW ) )
+ break;
+ if( !bData )
+ {
+ if( nRow > nEndRow )
+ nEndRow = nRow;
+ if( nCol > nEndCol )
+ nEndCol = nCol;
+ break;
+ }
+ BOOL bText;
+ if( *p == '"' )
+ {
+ bText = TRUE;
+ aText.Erase();
+ p = lcl_ScanSylkString( p, aText, eVersion);
+ }
+ else
+ bText = FALSE;
+ const sal_Unicode* q = p;
+ while( *q && *q != ';' )
+ q++;
+ if ( !(*q == ';' && *(q+1) == 'I') )
+ { // don't ignore value
+ if( bText )
+ {
+ pDoc->PutCell( nCol, nRow, aRange.aStart.Tab(),
+ ScBaseCell::CreateTextCell( aText, pDoc),
+ (BOOL) TRUE);
+ }
+ else
+ {
+ double fVal = rtl_math_uStringToDouble( p,
+ aLine.GetBuffer() + aLine.Len(),
+ cDecSep, cGrpSep, NULL, NULL );
+ pDoc->SetValue( nCol, nRow, aRange.aStart.Tab(), fVal );
+ }
+ }
+ }
+ break;
+ case 'E':
+ case 'M':
+ {
+ if ( ch == 'M' )
+ {
+ if ( nRefCol < nCol )
+ nRefCol = nCol;
+ if ( nRefRow < nRow )
+ nRefRow = nRow;
+ if ( !bData )
+ {
+ if( nRefRow > nEndRow )
+ nEndRow = nRefRow;
+ if( nRefCol > nEndCol )
+ nEndCol = nRefCol;
+ }
+ }
+ if( !bMyDoc || !bData )
+ break;
+ aText = '=';
+ p = lcl_ScanSylkFormula( p, aText, eVersion);
+ ScAddress aPos( nCol, nRow, aRange.aStart.Tab() );
+ /* FIXME: do we want GRAM_ODFF_A1 instead? At the
+ * end it probably should be GRAM_ODFF_R1C1, since
+ * R1C1 is what Excel writes in SYLK. */
+ const formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_PODF_A1;
+ ScCompiler aComp( pDoc, aPos);
+ aComp.SetGrammar(eGrammar);
+ ScTokenArray* pCode = aComp.CompileString( aText );
+ if ( ch == 'M' )
+ {
+ ScMarkData aMark;
+ aMark.SelectTable( aPos.Tab(), TRUE );
+ pDoc->InsertMatrixFormula( nCol, nRow, nRefCol,
+ nRefRow, aMark, EMPTY_STRING, pCode );
+ }
+ else
+ {
+ ScFormulaCell* pFCell = new ScFormulaCell(
+ pDoc, aPos, pCode, eGrammar, MM_NONE);
+ pDoc->PutCell( aPos, pFCell );
+ }
+ delete pCode; // ctor/InsertMatrixFormula did copy TokenArray
+ }
+ break;
+ }
+ while( *p && *p != ';' )
+ p++;
+ if( *p )
+ p++;
+ }
+ }
+ else if( cTag == 'F' ) // Format
+ {
+ if( *p++ != ';' )
+ return FALSE;
+ sal_Int32 nFormat = -1;
+ while( *p )
+ {
+ sal_Unicode ch = *p++;
+ ch = ScGlobal::ToUpperAlpha( ch );
+ switch( ch )
+ {
+ case 'X':
+ nCol = static_cast<SCCOL>(String( p ).ToInt32()) + nStartCol - 1;
+ break;
+ case 'Y':
+ nRow = String( p ).ToInt32() + nStartRow - 1;
+ break;
+ case 'P' :
+ if ( bData )
+ {
+ // F;P<n> sets format code of P;P<code> at
+ // current position, or at ;X;Y if specified.
+ // Note that ;X;Y may appear after ;P
+ const sal_Unicode* p0 = p;
+ while( *p && *p != ';' )
+ p++;
+ String aNumber( p0, sal::static_int_cast<xub_StrLen>( p - p0 ) );
+ nFormat = aNumber.ToInt32();
+ }
+ break;
+ }
+ while( *p && *p != ';' )
+ p++;
+ if( *p )
+ p++;
+ }
+ if ( !bData )
+ {
+ if( nRow > nEndRow )
+ nEndRow = nRow;
+ if( nCol > nEndCol )
+ nEndCol = nCol;
+ }
+ if ( 0 <= nFormat && nFormat < aFormats.Count() )
+ {
+ ULONG nKey = aFormats[(USHORT)nFormat];
+ pDoc->ApplyAttr( nCol, nRow, aRange.aStart.Tab(),
+ SfxUInt32Item( ATTR_VALUE_FORMAT, nKey ) );
+ }
+ }
+ else if( cTag == 'P' )
+ {
+ if ( bData && *p == ';' && *(p+1) == 'P' )
+ {
+ String aCode( p+2 );
+ // unescape doubled semicolons
+ xub_StrLen nPos = 0;
+ String aSemicolon( RTL_CONSTASCII_USTRINGPARAM(";;"));
+ while ( (nPos = aCode.Search( aSemicolon, nPos )) != STRING_NOTFOUND )
+ aCode.Erase( nPos++, 1 );
+ // get rid of Xcl escape characters
+ nPos = 0;
+ while ( (nPos = aCode.Search( sal_Unicode(0x1b), nPos )) != STRING_NOTFOUND )
+ aCode.Erase( nPos, 1 );
+ xub_StrLen nCheckPos;
+ short nType;
+ sal_uInt32 nKey;
+ pDoc->GetFormatTable()->PutandConvertEntry(
+ aCode, nCheckPos, nType, nKey, LANGUAGE_ENGLISH_US,
+ ScGlobal::eLnge );
+ if ( nCheckPos )
+ nKey = 0;
+ aFormats.Insert( nKey, aFormats.Count() );
+ }
+ }
+ else if( cTag == 'I' && *p == 'D' )
+ {
+ aLine.Erase( 0, 4 );
+ if (aLine.EqualsAscii( "CALCOOO32" ))
+ eVersion = SYLK_OOO32;
+ else if (aLine.EqualsAscii( "SCALC3" ))
+ eVersion = SYLK_SCALC3;
+ bMyDoc = (eVersion <= SYLK_OWN);
+ }
+ else if( cTag == 'E' ) // Ende
+ break;
+ }
+ if( !bData )
+ {
+ aRange.aEnd.SetCol( nEndCol );
+ aRange.aEnd.SetRow( nEndRow );
+ bOk = StartPaste();
+ bData = TRUE;
+ }
+ else
+ break;
+ }
+
+ EndPaste();
+ return bOk;
+}
+
+
+BOOL ScImportExport::Doc2Sylk( SvStream& rStrm )
+{
+ SCCOL nCol;
+ SCROW nRow;
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ String aCellStr;
+ String aValStr;
+ lcl_WriteSimpleString( rStrm,
+ String( RTL_CONSTASCII_USTRINGPARAM( "ID;PCALCOOO32")));
+ WriteUnicodeOrByteEndl( rStrm );
+
+ for (nRow = nStartRow; nRow <= nEndRow; nRow++)
+ {
+ for (nCol = nStartCol; nCol <= nEndCol; nCol++)
+ {
+ String aBufStr;
+ double nVal;
+ BOOL bForm = FALSE;
+ SCROW r = nRow - nStartRow + 1;
+ SCCOL c = nCol - nStartCol + 1;
+ ScBaseCell* pCell;
+ pDoc->GetCell( nCol, nRow, aRange.aStart.Tab(), pCell );
+ CellType eType = (pCell ? pCell->GetCellType() : CELLTYPE_NONE);
+ switch( eType )
+ {
+ case CELLTYPE_FORMULA:
+ bForm = bFormulas;
+ if( pDoc->HasValueData( nCol, nRow, aRange.aStart.Tab()) )
+ goto hasvalue;
+ else
+ goto hasstring;
+
+ case CELLTYPE_VALUE:
+ hasvalue:
+ pDoc->GetValue( nCol, nRow, aRange.aStart.Tab(), nVal );
+
+ aValStr = ::rtl::math::doubleToUString( nVal,
+ rtl_math_StringFormat_Automatic,
+ rtl_math_DecimalPlaces_Max, '.', TRUE );
+
+ aBufStr.AssignAscii(RTL_CONSTASCII_STRINGPARAM( "C;X" ));
+ aBufStr += String::CreateFromInt32( c );
+ aBufStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ";Y" ));
+ aBufStr += String::CreateFromInt32( r );
+ aBufStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ";K" ));
+ aBufStr += aValStr;
+ lcl_WriteSimpleString( rStrm, aBufStr );
+ goto checkformula;
+
+ case CELLTYPE_STRING:
+ case CELLTYPE_EDIT:
+ hasstring:
+ pDoc->GetString( nCol, nRow, aRange.aStart.Tab(), aCellStr );
+ aCellStr.SearchAndReplaceAll( _LF, SYLK_LF );
+
+ aBufStr.AssignAscii(RTL_CONSTASCII_STRINGPARAM( "C;X" ));
+ aBufStr += String::CreateFromInt32( c );
+ aBufStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ";Y" ));
+ aBufStr += String::CreateFromInt32( r );
+ aBufStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ";K" ));
+ lcl_WriteSimpleString( rStrm, aBufStr );
+ lcl_WriteString( rStrm, aCellStr, '"', ';' );
+
+ checkformula:
+ if( bForm )
+ {
+ const ScFormulaCell* pFCell =
+ static_cast<const ScFormulaCell*>(pCell);
+ switch ( pFCell->GetMatrixFlag() )
+ {
+ case MM_REFERENCE :
+ aCellStr.Erase();
+ break;
+ default:
+ pFCell->GetFormula( aCellStr,formula::FormulaGrammar::GRAM_PODF_A1);
+ /* FIXME: do we want GRAM_ODFF_A1 instead? At
+ * the end it probably should be
+ * GRAM_ODFF_R1C1, since R1C1 is what Excel
+ * writes in SYLK. */
+ }
+ if ( pFCell->GetMatrixFlag() != MM_NONE &&
+ aCellStr.Len() > 2 &&
+ aCellStr.GetChar(0) == '{' &&
+ aCellStr.GetChar(aCellStr.Len()-1) == '}' )
+ { // cut off matrix {} characters
+ aCellStr.Erase(aCellStr.Len()-1,1);
+ aCellStr.Erase(0,1);
+ }
+ if ( aCellStr.GetChar(0) == '=' )
+ aCellStr.Erase(0,1);
+ String aPrefix;
+ switch ( pFCell->GetMatrixFlag() )
+ {
+ case MM_FORMULA :
+ { // diff expression with 'M' M$-extension
+ SCCOL nC;
+ SCROW nR;
+ pFCell->GetMatColsRows( nC, nR );
+ nC += c - 1;
+ nR += r - 1;
+ aPrefix.AssignAscii( RTL_CONSTASCII_STRINGPARAM( ";R" ) );
+ aPrefix += String::CreateFromInt32( nR );
+ aPrefix.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ";C" ) );
+ aPrefix += String::CreateFromInt32( nC );
+ aPrefix.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ";M" ) );
+ }
+ break;
+ case MM_REFERENCE :
+ { // diff expression with 'I' M$-extension
+ ScAddress aPos;
+ pFCell->GetMatrixOrigin( aPos );
+ aPrefix.AssignAscii( RTL_CONSTASCII_STRINGPARAM( ";I;R" ) );
+ aPrefix += String::CreateFromInt32( aPos.Row() - nStartRow + 1 );
+ aPrefix.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ";C" ) );
+ aPrefix += String::CreateFromInt32( aPos.Col() - nStartCol + 1 );
+ }
+ break;
+ default:
+ // formula Expression
+ aPrefix.AssignAscii( RTL_CONSTASCII_STRINGPARAM( ";E" ) );
+ }
+ lcl_WriteSimpleString( rStrm, aPrefix );
+ if ( aCellStr.Len() )
+ lcl_WriteString( rStrm, aCellStr, 0, ';' );
+ }
+ WriteUnicodeOrByteEndl( rStrm );
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ }
+ lcl_WriteSimpleString( rStrm, String( 'E' ) );
+ WriteUnicodeOrByteEndl( rStrm );
+ return BOOL( rStrm.GetError() == SVSTREAM_OK );
+}
+
+
+BOOL ScImportExport::Doc2HTML( SvStream& rStrm, const String& rBaseURL )
+{
+ // CharSet is ignored in ScExportHTML, read from Load/Save HTML options
+ ScFormatFilter::Get().ScExportHTML( rStrm, rBaseURL, pDoc, aRange, RTL_TEXTENCODING_DONTKNOW, bAll,
+ aStreamPath, aNonConvertibleChars );
+ return BOOL( rStrm.GetError() == SVSTREAM_OK );
+}
+
+BOOL ScImportExport::Doc2RTF( SvStream& rStrm )
+{
+ // CharSet is ignored in ScExportRTF
+ ScFormatFilter::Get().ScExportRTF( rStrm, pDoc, aRange, RTL_TEXTENCODING_DONTKNOW );
+ return BOOL( rStrm.GetError() == SVSTREAM_OK );
+}
+
+
+BOOL ScImportExport::Doc2Dif( SvStream& rStrm )
+{
+ // for DIF in the clipboard, IBM_850 is always used
+ ScFormatFilter::Get().ScExportDif( rStrm, pDoc, aRange, RTL_TEXTENCODING_IBM_850 );
+ return TRUE;
+}
+
+
+BOOL ScImportExport::Dif2Doc( SvStream& rStrm )
+{
+ SCTAB nTab = aRange.aStart.Tab();
+ ScDocument* pImportDoc = new ScDocument( SCDOCMODE_UNDO );
+ pImportDoc->InitUndo( pDoc, nTab, nTab );
+
+ // for DIF in the clipboard, IBM_850 is always used
+ ScFormatFilter::Get().ScImportDif( rStrm, pImportDoc, aRange.aStart, RTL_TEXTENCODING_IBM_850 );
+
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pImportDoc->GetCellArea( nTab, nEndCol, nEndRow );
+ // #131247# if there are no cells in the imported content, nEndCol/nEndRow may be before the start
+ if ( nEndCol < aRange.aStart.Col() )
+ nEndCol = aRange.aStart.Col();
+ if ( nEndRow < aRange.aStart.Row() )
+ nEndRow = aRange.aStart.Row();
+ aRange.aEnd = ScAddress( nEndCol, nEndRow, nTab );
+
+ BOOL bOk = StartPaste();
+ if (bOk)
+ {
+ USHORT nFlags = IDF_ALL & ~IDF_STYLES;
+ pDoc->DeleteAreaTab( aRange, nFlags );
+ pImportDoc->CopyToDocument( aRange, nFlags, FALSE, pDoc );
+ EndPaste();
+ }
+
+ delete pImportDoc;
+
+ return bOk;
+}
+
+
+BOOL ScImportExport::RTF2Doc( SvStream& rStrm, const String& rBaseURL )
+{
+ ScEEAbsImport *pImp = ScFormatFilter::Get().CreateRTFImport( pDoc, aRange );
+ if (!pImp)
+ return false;
+ pImp->Read( rStrm, rBaseURL );
+ aRange = pImp->GetRange();
+
+ BOOL bOk = StartPaste();
+ if (bOk)
+ {
+ USHORT nFlags = IDF_ALL & ~IDF_STYLES;
+ pDoc->DeleteAreaTab( aRange, nFlags );
+ pImp->WriteToDocument();
+ EndPaste();
+ }
+ delete pImp;
+ return bOk;
+}
+
+
+BOOL ScImportExport::HTML2Doc( SvStream& rStrm, const String& rBaseURL )
+{
+ ScEEAbsImport *pImp = ScFormatFilter::Get().CreateHTMLImport( pDoc, rBaseURL, aRange, TRUE);
+ if (!pImp)
+ return false;
+ pImp->Read( rStrm, rBaseURL );
+ aRange = pImp->GetRange();
+
+ BOOL bOk = StartPaste();
+ if (bOk)
+ {
+ // ScHTMLImport may call ScDocument::InitDrawLayer, resulting in
+ // a Draw Layer but no Draw View -> create Draw Layer and View here
+ if (pDocSh)
+ pDocSh->MakeDrawLayer();
+
+ USHORT nFlags = IDF_ALL & ~IDF_STYLES;
+ pDoc->DeleteAreaTab( aRange, nFlags );
+ pImp->WriteToDocument();
+ EndPaste();
+ }
+ delete pImp;
+ return bOk;
+}
+
+#define RETURN_ERROR { return eERR_INTERN; }
+class ScFormatFilterMissing : public ScFormatFilterPlugin {
+ public:
+ ScFormatFilterMissing()
+ {
+ OSL_ASSERT ("Missing file filters");
+ }
+ virtual FltError ScImportLotus123( SfxMedium&, ScDocument*, CharSet ) RETURN_ERROR
+ virtual FltError ScImportQuattroPro( SfxMedium &, ScDocument * ) RETURN_ERROR
+ virtual FltError ScImportExcel( SfxMedium&, ScDocument*, const EXCIMPFORMAT ) RETURN_ERROR
+ virtual FltError ScImportStarCalc10( SvStream&, ScDocument* ) RETURN_ERROR
+ virtual FltError ScImportDif( SvStream&, ScDocument*, const ScAddress&,
+ const CharSet, UINT32 ) RETURN_ERROR
+ virtual FltError ScImportRTF( SvStream&, const String&, ScDocument*, ScRange& ) RETURN_ERROR
+ virtual FltError ScImportHTML( SvStream&, const String&, ScDocument*, ScRange&, double, BOOL, SvNumberFormatter*, bool ) RETURN_ERROR
+
+ virtual ScEEAbsImport *CreateRTFImport( ScDocument*, const ScRange& ) { return NULL; }
+ virtual ScEEAbsImport *CreateHTMLImport( ScDocument*, const String&, const ScRange&, BOOL ) { return NULL; }
+ virtual String GetHTMLRangeNameList( ScDocument*, const String& ) { return String(); }
+
+#if ENABLE_LOTUS123_EXPORT
+ virtual FltError ScExportLotus123( SvStream&, ScDocument*, ExportFormatLotus, CharSet ) RETURN_ERROR
+#endif
+ virtual FltError ScExportExcel5( SfxMedium&, ScDocument*, ExportFormatExcel, CharSet ) RETURN_ERROR
+ virtual FltError ScExportDif( SvStream&, ScDocument*, const ScAddress&, const CharSet, UINT32 ) RETURN_ERROR
+ virtual FltError ScExportDif( SvStream&, ScDocument*, const ScRange&, const CharSet, UINT32 ) RETURN_ERROR
+ virtual FltError ScExportHTML( SvStream&, const String&, ScDocument*, const ScRange&, const CharSet, BOOL,
+ const String&, String& ) RETURN_ERROR
+ virtual FltError ScExportRTF( SvStream&, ScDocument*, const ScRange&, const CharSet ) RETURN_ERROR
+};
+
+extern "C" { static void SAL_CALL thisModule() {} }
+typedef ScFormatFilterPlugin * (*FilterFn)(void);
+ScFormatFilterPlugin &ScFormatFilter::Get()
+{
+ static ScFormatFilterPlugin *plugin;
+
+ if (plugin != NULL)
+ return *plugin;
+
+ static ::osl::Module aModule;
+ if ( aModule.loadRelative( &thisModule,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SVLIBRARY( "scfilt" ) ) ) ) )
+ {
+ oslGenericFunction fn = aModule.getFunctionSymbol( ::rtl::OUString::createFromAscii( "ScFilterCreate" ) );
+ if (fn != NULL)
+ plugin = reinterpret_cast<FilterFn>(fn)();
+ }
+ if (plugin == NULL)
+ plugin = new ScFormatFilterMissing();
+
+ return *plugin;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/macromgr.cxx b/sc/source/ui/docshell/macromgr.cxx
new file mode 100644
index 000000000000..f8c4102f98c9
--- /dev/null
+++ b/sc/source/ui/docshell/macromgr.cxx
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: document.hxx,v $
+ * $Revision: 1.115.36.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "macromgr.hxx"
+#include "document.hxx"
+
+#include "basic/basmgr.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "sfx2/objsh.hxx"
+#include "cell.hxx"
+#include <com/sun/star/container/XContainer.hpp>
+
+#include <list>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Reference;
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+using ::std::hash_map;
+using ::std::list;
+using ::std::for_each;
+using ::std::pair;
+
+// ============================================================================
+
+/**
+ * A simple container to keep track of cells that depend on basic modules
+ * changes. We don't check for duplicates at insertion time; instead, we
+ * remove duplicates at query time.
+ */
+class ScUserMacroDepTracker
+{
+public:
+ void addCell(const OUString& rModuleName, ScFormulaCell* pCell)
+ {
+ ModuleCellMap::iterator itr = maCells.find(rModuleName);
+ if (itr == maCells.end())
+ {
+ pair<ModuleCellMap::iterator, bool> r = maCells.insert(
+ ModuleCellMap::value_type(rModuleName, list<ScFormulaCell*>()));
+
+ if (!r.second)
+ // insertion failed.
+ return;
+
+ itr = r.first;
+ }
+ itr->second.push_back(pCell);
+ }
+
+ void removeCell(ScFormulaCell* pCell)
+ {
+ ModuleCellMap::iterator itr = maCells.begin(), itrEnd = maCells.end();
+ for (; itr != itrEnd; ++itr)
+ itr->second.remove(pCell);
+ }
+
+ void getCellsByModule(const OUString& rModuleName, list<ScFormulaCell*>& rCells)
+ {
+ ModuleCellMap::iterator itr = maCells.find(rModuleName);
+ if (itr == maCells.end())
+ return;
+
+ list<ScFormulaCell*>& rCellList = itr->second;
+
+ // Remove duplicates.
+ rCellList.sort();
+ rCellList.unique();
+ // exception safe copy
+ list<ScFormulaCell*> temp(rCellList);
+ rCells.swap(temp);
+ }
+
+private:
+ typedef hash_map<OUString, list<ScFormulaCell*>, OUStringHash> ModuleCellMap;
+ ModuleCellMap maCells;
+};
+
+
+// ============================================================================
+
+ScMacroManager::ScMacroManager(ScDocument* pDoc) :
+ mpDepTracker(new ScUserMacroDepTracker),
+ mpDoc(pDoc)
+{
+}
+
+ScMacroManager::~ScMacroManager()
+{
+}
+
+typedef ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener > ContainerListenerHelper;
+
+class VBAProjectListener : public ContainerListenerHelper
+{
+ ScMacroManager* mpMacroMgr;
+public:
+ VBAProjectListener( ScMacroManager* pMacroMgr ) : mpMacroMgr( pMacroMgr ) {}
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& /*Source*/ ) throw(RuntimeException) {}
+
+ // XContainerListener
+ virtual void SAL_CALL elementInserted( const container::ContainerEvent& /*Event*/ ) throw(RuntimeException){}
+ virtual void SAL_CALL elementReplaced( const container::ContainerEvent& Event ) throw(RuntimeException)
+ {
+ rtl::OUString sModuleName;
+ Event.Accessor >>= sModuleName;
+ OSL_TRACE("VBAProjectListener::elementReplaced(%s)", rtl::OUStringToOString( sModuleName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ mpMacroMgr->InitUserFuncData();
+ mpMacroMgr->BroadcastModuleUpdate(sModuleName);
+ }
+ virtual void SAL_CALL elementRemoved( const container::ContainerEvent& /*Event*/ ) throw(RuntimeException){}
+
+};
+
+void ScMacroManager::InitUserFuncData()
+{
+ // Clear hash_map
+ mhFuncToVolatile.clear();
+ String sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") );
+
+ Reference< container::XContainer > xModuleContainer;
+ SfxObjectShell* pShell = mpDoc->GetDocumentShell();
+ if ( pShell && pShell->GetBasicManager()->GetName().Len() > 0 )
+ sProjectName = pShell->GetBasicManager()->GetName();
+ try
+ {
+ Reference< script::XLibraryContainer > xLibraries( pShell->GetBasicContainer(), uno::UNO_QUERY_THROW );
+ xModuleContainer.set( xLibraries->getByName( sProjectName ), uno::UNO_QUERY_THROW );
+
+ if ( xModuleContainer.is() )
+ {
+ // remove old listener ( if there was one )
+ if ( mxContainerListener.is() )
+ xModuleContainer->removeContainerListener( mxContainerListener );
+ // Create listener
+ mxContainerListener = new VBAProjectListener( this );
+ xModuleContainer->addContainerListener( mxContainerListener );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+void ScMacroManager::SetUserFuncVolatile( const OUString& sName, bool isVolatile )
+{
+ mhFuncToVolatile[ sName ] = isVolatile;
+}
+
+bool ScMacroManager::GetUserFuncVolatile( const OUString& sName )
+{
+ NameBoolMap::iterator it = mhFuncToVolatile.find( sName );
+ if ( it == mhFuncToVolatile.end() )
+ return false;
+ return it->second;
+}
+
+void ScMacroManager::AddDependentCell(const OUString& aModuleName, ScFormulaCell* pCell)
+{
+ mpDepTracker->addCell(aModuleName, pCell);
+}
+
+void ScMacroManager::RemoveDependentCell(ScFormulaCell* pCell)
+{
+ mpDepTracker->removeCell(pCell);
+}
+
+void ScMacroManager::BroadcastModuleUpdate(const OUString& aModuleName)
+{
+ list<ScFormulaCell*> aCells;
+ mpDepTracker->getCellsByModule(aModuleName, aCells);
+ list<ScFormulaCell*>::iterator itr = aCells.begin(), itrEnd = aCells.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScFormulaCell* pCell = *itr;
+ mpDoc->PutInFormulaTree(pCell); // for F9 recalc
+
+ // for recalc on cell value change. If the cell is not volatile, the
+ // cell stops listening right away after it gets re-interpreted.
+ mpDoc->StartListeningArea(BCA_LISTEN_ALWAYS, pCell);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/makefile.mk b/sc/source/ui/docshell/makefile.mk
new file mode 100644
index 000000000000..6776a0b7efdd
--- /dev/null
+++ b/sc/source/ui/docshell/makefile.mk
@@ -0,0 +1,141 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=docshell
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ docsh.cxx \
+ docsh2.cxx \
+ docsh3.cxx \
+ docsh4.cxx \
+ docsh5.cxx \
+ docsh6.cxx \
+ docsh7.cxx \
+ docsh8.cxx \
+ externalrefmgr.cxx \
+ tablink.cxx \
+ arealink.cxx \
+ dbdocfun.cxx \
+ dbdocimp.cxx \
+ impex.cxx \
+ docfunc.cxx \
+ olinefun.cxx \
+ servobj.cxx \
+ tpstat.cxx \
+ autostyl.cxx \
+ pagedata.cxx \
+ hiranges.cxx \
+ pntlock.cxx \
+ sizedev.cxx \
+ editable.cxx
+
+
+SLOFILES = \
+ $(SLO)$/docsh.obj \
+ $(SLO)$/docsh2.obj \
+ $(SLO)$/docsh3.obj \
+ $(SLO)$/docsh4.obj \
+ $(SLO)$/docsh5.obj \
+ $(SLO)$/docsh6.obj \
+ $(SLO)$/docsh7.obj \
+ $(SLO)$/docsh8.obj \
+ $(SLO)$/externalrefmgr.obj \
+ $(SLO)$/tablink.obj \
+ $(SLO)$/arealink.obj \
+ $(SLO)$/dbdocfun.obj \
+ $(SLO)$/dbdocimp.obj \
+ $(SLO)$/impex.obj \
+ $(SLO)$/docfunc.obj \
+ $(SLO)$/olinefun.obj \
+ $(SLO)$/servobj.obj \
+ $(SLO)$/tpstat.obj \
+ $(SLO)$/autostyl.obj \
+ $(SLO)$/pagedata.obj \
+ $(SLO)$/hiranges.obj \
+ $(SLO)$/pntlock.obj \
+ $(SLO)$/sizedev.obj \
+ $(SLO)$/editable.obj \
+ $(SLO)$/macromgr.obj
+
+
+EXCEPTIONSFILES= \
+ $(SLO)$/docsh.obj \
+ $(SLO)$/docsh3.obj \
+ $(SLO)$/docsh4.obj \
+ $(SLO)$/docsh6.obj \
+ $(SLO)$/docsh8.obj \
+ $(SLO)$/externalrefmgr.obj \
+ $(SLO)$/dbdocimp.obj \
+ $(SLO)$/docfunc.obj \
+ $(SLO)$/macromgr.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = tpstat.src
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/docsh.obj \
+ $(SLO)$/docsh2.obj \
+ $(SLO)$/docsh3.obj \
+ $(SLO)$/docsh4.obj \
+ $(SLO)$/docsh5.obj \
+ $(SLO)$/docsh6.obj \
+ $(SLO)$/docsh7.obj \
+ $(SLO)$/docsh8.obj \
+ $(SLO)$/externalrefmgr.obj \
+ $(SLO)$/tablink.obj \
+ $(SLO)$/arealink.obj \
+ $(SLO)$/dbdocfun.obj \
+ $(SLO)$/dbdocimp.obj \
+ $(SLO)$/impex.obj \
+ $(SLO)$/docfunc.obj \
+ $(SLO)$/olinefun.obj \
+ $(SLO)$/servobj.obj \
+ $(SLO)$/autostyl.obj \
+ $(SLO)$/pagedata.obj \
+ $(SLO)$/hiranges.obj \
+ $(SLO)$/pntlock.obj \
+ $(SLO)$/sizedev.obj \
+ $(SLO)$/editable.obj \
+ $(SLO)$/macromgr.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx
new file mode 100644
index 000000000000..866a23453ffe
--- /dev/null
+++ b/sc/source/ui/docshell/olinefun.cxx
@@ -0,0 +1,799 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/sound.hxx>
+#include <sfx2/bindings.hxx>
+
+#include "olinefun.hxx"
+
+#include "docsh.hxx"
+#include "olinetab.hxx"
+#include "undodat.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+
+
+//========================================================================
+
+void lcl_InvalidateOutliner( SfxBindings* pBindings )
+{
+ if ( pBindings )
+ {
+ pBindings->Invalidate( SID_OUTLINE_SHOW );
+ pBindings->Invalidate( SID_OUTLINE_HIDE );
+ pBindings->Invalidate( SID_OUTLINE_REMOVE );
+
+ pBindings->Invalidate( SID_STATUS_SUM ); // wegen ein-/ausblenden
+ pBindings->Invalidate( SID_ATTR_SIZE );
+ }
+}
+
+//------------------------------------------------------------------------
+
+//! PaintWidthHeight zur DocShell verschieben?
+
+void lcl_PaintWidthHeight( ScDocShell& rDocShell, SCTAB nTab,
+ BOOL bColumns, SCCOLROW nStart, SCCOLROW nEnd )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ USHORT nParts = PAINT_GRID;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = MAXCOL; // fuer Test auf Merge
+ SCROW nEndRow = MAXROW;
+ if ( bColumns )
+ {
+ nParts |= PAINT_TOP;
+ nStartCol = static_cast<SCCOL>(nStart);
+ nEndCol = static_cast<SCCOL>(nEnd);
+ }
+ else
+ {
+ nParts |= PAINT_LEFT;
+ nStartRow = nStart;
+ nEndRow = nEnd;
+ }
+ if (pDoc->HasAttrib( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ {
+ nStartCol = 0;
+ nStartRow = 0;
+ }
+ rDocShell.PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScOutlineDocFunc::MakeOutline( const ScRange& rRange, BOOL bColumns, BOOL bRecord, BOOL bApi )
+{
+ BOOL bSuccess = FALSE;
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab, TRUE );
+ ScOutlineTable* pUndoTab = NULL;
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ if (bRecord)
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
+
+ BOOL bRes;
+ BOOL bSize = FALSE;
+ if ( bColumns )
+ bRes = pArray->Insert( nStartCol, nEndCol, bSize );
+ else
+ bRes = pArray->Insert( nStartRow, nEndRow, bSize );
+
+ if ( bRes )
+ {
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoMakeOutline( &rDocShell,
+ nStartCol,nStartRow,nTab,nEndCol,nEndRow,nTab,
+ pUndoTab, bColumns, TRUE ) );
+ }
+
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ USHORT nParts = 0; // Datenbereich nicht geaendert
+ if ( bColumns )
+ nParts |= PAINT_TOP;
+ else
+ nParts |= PAINT_LEFT;
+ if ( bSize )
+ nParts |= PAINT_SIZE;
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
+ rDocShell.SetDocumentModified();
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+ bSuccess = TRUE;
+ }
+ else
+ {
+ if (!bApi)
+ rDocShell.ErrorMessage(STR_MSSG_MAKEOUTLINE_0); // "Gruppierung nicht moeglich"
+ delete pUndoTab;
+ }
+
+ return bSuccess;
+}
+
+BOOL ScOutlineDocFunc::RemoveOutline( const ScRange& rRange, BOOL bColumns, BOOL bRecord, BOOL bApi )
+{
+ BOOL bDone = FALSE;
+
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ ScOutlineTable* pUndoTab = NULL;
+ if (bRecord)
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
+
+ BOOL bRes;
+ BOOL bSize = FALSE;
+ if ( bColumns )
+ bRes = pArray->Remove( nStartCol, nEndCol, bSize );
+ else
+ bRes = pArray->Remove( nStartRow, nEndRow, bSize );
+
+ if ( bRes )
+ {
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoMakeOutline( &rDocShell,
+ nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
+ pUndoTab, bColumns, FALSE ) );
+ }
+
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ USHORT nParts = 0; // Datenbereich nicht geaendert
+ if ( bColumns )
+ nParts |= PAINT_TOP;
+ else
+ nParts |= PAINT_LEFT;
+ if ( bSize )
+ nParts |= PAINT_SIZE;
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
+ rDocShell.SetDocumentModified();
+ bDone = TRUE;
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+
+ // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
+ }
+ else
+ delete pUndoTab;
+ }
+
+ if (!bDone && !bApi)
+ rDocShell.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0); // "Aufheben nicht moeglich"
+
+ return bDone;
+}
+
+BOOL ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab, BOOL bRecord, BOOL bApi )
+{
+ BOOL bSuccess = FALSE;
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ if (bRecord)
+ {
+ SCCOLROW nCol1, nCol2, nRow1, nRow2;
+ pTable->GetColArray()->GetRange( nCol1, nCol2 );
+ pTable->GetRowArray()->GetRange( nRow1, nRow2 );
+ SCCOL nStartCol = static_cast<SCCOL>(nCol1);
+ SCROW nStartRow = nRow1;
+ SCCOL nEndCol = static_cast<SCCOL>(nCol2);
+ SCROW nEndRow = nRow2;
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+
+ ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoRemoveAllOutlines( &rDocShell,
+ nStartCol, nStartRow, nTab,
+ nEndCol, nEndRow, nTab,
+ pUndoDoc, pUndoTab ) );
+ }
+
+ SelectLevel( nTab, TRUE, pTable->GetColArray()->GetDepth(), FALSE, FALSE, bApi );
+ SelectLevel( nTab, FALSE, pTable->GetRowArray()->GetDepth(), FALSE, FALSE, bApi );
+ pDoc->SetOutlineTable( nTab, NULL );
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+ rDocShell.SetDocumentModified();
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+ bSuccess = TRUE;
+ }
+ else if (!bApi)
+ Sound::Beep();
+
+ return bSuccess;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScOutlineDocFunc::AutoOutline( const ScRange& rRange, BOOL bRecord, BOOL bApi )
+{
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+
+ if ( pTable )
+ {
+ if ( bRecord )
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ SCCOLROW nCol1, nCol2, nRow1, nRow2;
+ pTable->GetColArray()->GetRange( nCol1, nCol2 );
+ pTable->GetRowArray()->GetRange( nRow1, nRow2 );
+ SCCOL nOutStartCol = static_cast<SCCOL>(nCol1);;
+ SCROW nOutStartRow = nRow1;
+ SCCOL nOutEndCol = static_cast<SCCOL>(nCol2);;
+ SCROW nOutEndRow = nRow2;
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( nOutStartCol, 0, nTab, nOutEndCol, MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+
+ // einblenden
+ SelectLevel( nTab, TRUE, pTable->GetColArray()->GetDepth(), FALSE, FALSE, bApi );
+ SelectLevel( nTab, FALSE, pTable->GetRowArray()->GetDepth(), FALSE, FALSE, bApi );
+ pDoc->SetOutlineTable( nTab, NULL );
+ }
+
+ pDoc->DoAutoOutline( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
+
+ if (bRecord)
+ {
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoAutoOutline( &rDocShell,
+ nStartCol, nStartRow, nTab,
+ nEndCol, nEndRow, nTab,
+ pUndoDoc, pUndoTab ) );
+ }
+
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+ rDocShell.SetDocumentModified();
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScOutlineDocFunc::SelectLevel( SCTAB nTab, BOOL bColumns, USHORT nLevel,
+ BOOL bRecord, BOOL bPaint, BOOL /* bApi */ )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab ); // ist schon da
+ if (!pTable)
+ return FALSE;
+ ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
+ if (!pArray)
+ return FALSE;
+
+ SCCOLROW nStart, nEnd;
+ pArray->GetRange( nStart, nEnd );
+
+ if ( bRecord )
+ {
+ ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ if (bColumns)
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, FALSE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, FALSE,
+ pUndoDoc );
+ }
+ else
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+ pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoOutlineLevel( &rDocShell,
+ nStart, nEnd, nTab, //! start und end berechnen
+ pUndoDoc, pUndoTab,
+ bColumns, nLevel ) );
+ }
+
+ pDoc->InitializeNoteCaptions(nTab);
+ ScSubOutlineIterator aIter( pArray ); // alle Eintraege
+ ScOutlineEntry* pEntry;
+ while ((pEntry=aIter.GetNext()) != NULL)
+ {
+ USHORT nThisLevel = aIter.LastLevel();
+ BOOL bShow = (nThisLevel < nLevel);
+ if (bShow) // einblenden
+ {
+ pEntry->SetHidden( FALSE );
+ pEntry->SetVisible( TRUE );
+ }
+ else if ( nThisLevel == nLevel ) // ausblenden
+ {
+ pEntry->SetHidden( TRUE );
+ pEntry->SetVisible( TRUE );
+ }
+ else // verdeckt
+ {
+ pEntry->SetVisible( FALSE );
+ }
+
+ SCCOLROW nThisStart = pEntry->GetStart();
+ SCCOLROW nThisEnd = pEntry->GetEnd();
+ for (SCCOLROW i=nThisStart; i<=nThisEnd; i++)
+ {
+ if ( bColumns )
+ pDoc->ShowCol( static_cast<SCCOL>(i), nTab, bShow );
+ else
+ if ( !bShow || !pDoc->RowFiltered( i,nTab ) )
+ pDoc->ShowRow( i, nTab, bShow );
+ }
+ }
+
+ pDoc->SetDrawPageSize(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+
+ if (bPaint)
+ lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
+
+ rDocShell.SetDocumentModified();
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, BOOL bRecord, BOOL bApi )
+{
+ BOOL bDone = FALSE;
+
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+
+ if (pTable)
+ {
+ ScOutlineArray* pArray;
+ ScOutlineEntry* pEntry;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ SCCOLROW nMin;
+ SCCOLROW nMax;
+ SCCOLROW i;
+
+ if ( bRecord )
+ {
+ ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoOutlineBlock( &rDocShell,
+ nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
+ pUndoDoc, pUndoTab, TRUE ) );
+ }
+
+ // Spalten
+
+ nMin=MAXCOL;
+ nMax=0;
+ pArray = pTable->GetColArray();
+ ScSubOutlineIterator aColIter( pArray );
+ while ((pEntry=aColIter.GetNext()) != NULL)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( nStart>=nStartCol && nEnd<=nEndCol )
+ {
+ pEntry->SetHidden( FALSE );
+ pEntry->SetVisible( TRUE );
+ if (nStart<nMin) nMin=nStart;
+ if (nEnd>nMax) nMax=nEnd;
+ }
+ }
+ for ( i=nMin; i<=nMax; i++ )
+ pDoc->ShowCol( static_cast<SCCOL>(i), nTab, TRUE );
+
+ // Zeilen
+
+ nMin=MAXROW;
+ nMax=0;
+ pArray = pTable->GetRowArray();
+ ScSubOutlineIterator aRowIter( pArray );
+ pDoc->InitializeNoteCaptions(nTab);
+ while ((pEntry=aRowIter.GetNext()) != NULL)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( nStart>=nStartRow && nEnd<=nEndRow )
+ {
+ pEntry->SetHidden( FALSE );
+ pEntry->SetVisible( TRUE );
+ if (nStart<nMin) nMin=nStart;
+ if (nEnd>nMax) nMax=nEnd;
+ }
+ }
+ for ( i=nMin; i<=nMax; i++ )
+ if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden
+ pDoc->ShowRow( i, nTab, TRUE );
+
+ pDoc->SetDrawPageSize(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
+ rDocShell.SetDocumentModified();
+ bDone = TRUE;
+
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+ }
+
+ if (!bDone && !bApi)
+ Sound::Beep();
+
+ return bDone;
+}
+
+BOOL ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, BOOL bRecord, BOOL bApi )
+{
+ BOOL bDone = FALSE;
+
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+
+ if (pTable)
+ {
+ ScOutlineEntry* pEntry;
+ USHORT nColLevel;
+ USHORT nRowLevel;
+ USHORT nCount;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ USHORT i;
+
+ SCCOLROW nEffStartCol = nStartCol;
+ SCCOLROW nEffEndCol = nEndCol;
+ ScOutlineArray* pColArray = pTable->GetColArray();
+ pColArray->FindTouchedLevel( nStartCol, nEndCol, nColLevel );
+ pColArray->ExtendBlock( nColLevel, nEffStartCol, nEffEndCol );
+ SCCOLROW nEffStartRow = nStartRow;
+ SCCOLROW nEffEndRow = nEndRow;
+ ScOutlineArray* pRowArray = pTable->GetRowArray();
+ pRowArray->FindTouchedLevel( nStartRow, nEndRow, nRowLevel );
+ pRowArray->ExtendBlock( nRowLevel, nEffStartRow, nEffEndRow );
+
+ if ( bRecord )
+ {
+ ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nEffStartCol), 0, nTab,
+ static_cast<SCCOL>(nEffEndCol), MAXROW, nTab, IDF_NONE,
+ FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nEffStartRow, nTab, MAXCOL, nEffEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoOutlineBlock( &rDocShell,
+ nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
+ pUndoDoc, pUndoTab, FALSE ) );
+ }
+
+ // Spalten
+
+ nCount = pColArray->GetCount(nColLevel);
+ for ( i=0; i<nCount; i++ )
+ {
+ pEntry = pColArray->GetEntry(nColLevel,i);
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+
+ if ( static_cast<SCCOLROW>(nStartCol)<=nEnd && static_cast<SCCOLROW>(nEndCol)>=nStart )
+ HideOutline( nTab, TRUE, nColLevel, i, FALSE, FALSE, bApi );
+ }
+
+ // Zeilen
+
+ nCount = pRowArray->GetCount(nRowLevel);
+ for ( i=0; i<nCount; i++ )
+ {
+ pEntry = pRowArray->GetEntry(nRowLevel,i);
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+
+ if ( nStartRow<=nEnd && nEndRow>=nStart )
+ HideOutline( nTab, FALSE, nRowLevel, i, FALSE, FALSE, bApi );
+ }
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
+
+ rDocShell.SetDocumentModified();
+ bDone = TRUE;
+
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+ }
+
+ if (!bDone && !bApi)
+ Sound::Beep();
+
+ return bDone;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScOutlineDocFunc::ShowOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, USHORT nEntry,
+ BOOL bRecord, BOOL bPaint, BOOL /* bApi */ )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
+ ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntry );
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ if ( bRecord )
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ if (bColumns)
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, FALSE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, FALSE,
+ pUndoDoc );
+ }
+ else
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+ pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDoOutline( &rDocShell,
+ nStart, nEnd, nTab, pUndoDoc, //! start und end berechnen
+ bColumns, nLevel, nEntry, TRUE ) );
+ }
+
+//! HideCursor();
+
+ pDoc->InitializeNoteCaptions(nTab);
+ pEntry->SetHidden(FALSE);
+ SCCOLROW i;
+ for ( i = nStart; i <= nEnd; i++ )
+ {
+ if ( bColumns )
+ pDoc->ShowCol( static_cast<SCCOL>(i), nTab, TRUE );
+ else
+ if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden
+ pDoc->ShowRow( i, nTab, TRUE );
+ }
+
+ ScSubOutlineIterator aIter( pArray, nLevel, nEntry );
+ while ((pEntry=aIter.GetNext()) != NULL)
+ {
+ if ( pEntry->IsHidden() )
+ {
+ SCCOLROW nSubStart = pEntry->GetStart();
+ SCCOLROW nSubEnd = pEntry->GetEnd();
+ for ( i = nSubStart; i <= nSubEnd; i++ )
+ {
+ if ( bColumns )
+ pDoc->ShowCol( static_cast<SCCOL>(i), nTab, FALSE );
+ else
+ pDoc->ShowRow( i, nTab, FALSE );
+ }
+ }
+ }
+
+ pArray->SetVisibleBelow( nLevel, nEntry, TRUE, TRUE );
+
+ pDoc->SetDrawPageSize(nTab);
+ pDoc->InvalidatePageBreaks(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+
+ if (bPaint)
+ lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
+
+//! ShowCursor();
+ rDocShell.SetDocumentModified();
+
+//! if (bPaint)
+//! UpdateScrollBars();
+
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+
+ return TRUE; //! immer ???
+}
+
+BOOL ScOutlineDocFunc::HideOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, USHORT nEntry,
+ BOOL bRecord, BOOL bPaint, BOOL /* bApi */ )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
+ ScOutlineEntry* pEntry = pArray->GetEntry( nLevel, nEntry );
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ if ( bRecord )
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ if (bColumns)
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, FALSE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, FALSE,
+ pUndoDoc );
+ }
+ else
+ {
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+ pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoDoOutline( &rDocShell,
+ nStart, nEnd, nTab, pUndoDoc,
+ bColumns, nLevel, nEntry, FALSE ) );
+ }
+
+//! HideCursor();
+
+ pDoc->InitializeNoteCaptions(nTab);
+ pEntry->SetHidden(TRUE);
+ SCCOLROW i;
+ for ( i = nStart; i <= nEnd; i++ )
+ {
+ if ( bColumns )
+ pDoc->ShowCol( static_cast<SCCOL>(i), nTab, FALSE );
+ else
+ pDoc->ShowRow( i, nTab, FALSE );
+ }
+
+ pArray->SetVisibleBelow( nLevel, nEntry, FALSE );
+
+ pDoc->SetDrawPageSize(nTab);
+ pDoc->InvalidatePageBreaks(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+
+ if (bPaint)
+ lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
+
+//! ShowCursor();
+ rDocShell.SetDocumentModified();
+
+//! if (bPaint)
+//! UpdateScrollBars();
+
+ lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
+
+ return TRUE; //! immer ???
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/pagedata.cxx b/sc/source/ui/docshell/pagedata.cxx
new file mode 100644
index 000000000000..6bd7ea083203
--- /dev/null
+++ b/sc/source/ui/docshell/pagedata.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <string.h>
+#include <tools/debug.hxx>
+
+
+#include "pagedata.hxx"
+
+//============================================================================
+
+ScPrintRangeData::ScPrintRangeData()
+{
+ nPagesX = nPagesY = 0;
+ pPageEndX = NULL;
+ pPageEndY = NULL;
+ bTopDown = bAutomatic = TRUE;
+ nFirstPage = 1;
+}
+
+ScPrintRangeData::~ScPrintRangeData()
+{
+ delete[] pPageEndX;
+ delete[] pPageEndY;
+}
+
+void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData )
+{
+ delete[] pPageEndX;
+ if ( nCount )
+ {
+ pPageEndX = new SCCOL[nCount];
+ memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) );
+ }
+ else
+ pPageEndX = NULL;
+ nPagesX = nCount;
+}
+
+void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData )
+{
+ delete[] pPageEndY;
+ if ( nCount )
+ {
+ pPageEndY = new SCROW[nCount];
+ memcpy( pPageEndY, pData, nCount * sizeof(SCROW) );
+ }
+ else
+ pPageEndY = NULL;
+ nPagesY = nCount;
+}
+
+//============================================================================
+
+ScPageBreakData::ScPageBreakData(size_t nMax)
+{
+ nUsed = 0;
+ if (nMax)
+ pData = new ScPrintRangeData[nMax];
+ else
+ pData = NULL;
+ nAlloc = nMax;
+}
+
+ScPageBreakData::~ScPageBreakData()
+{
+ delete[] pData;
+}
+
+ScPrintRangeData& ScPageBreakData::GetData(size_t nPos)
+{
+ DBG_ASSERT(nPos < nAlloc, "ScPageBreakData::GetData bumm");
+
+ if ( nPos >= nUsed )
+ {
+ DBG_ASSERT(nPos == nUsed, "ScPageBreakData::GetData falsche Reihenfolge");
+ nUsed = nPos+1;
+ }
+
+ return pData[nPos];
+}
+
+BOOL ScPageBreakData::IsEqual( const ScPageBreakData& rOther ) const
+{
+ if ( nUsed != rOther.nUsed )
+ return FALSE;
+
+ for (USHORT i=0; i<nUsed; i++)
+ if ( pData[i].GetPrintRange() != rOther.pData[i].GetPrintRange() )
+ return FALSE;
+
+ //! ScPrintRangeData komplett vergleichen ??
+
+ return TRUE;
+}
+
+void ScPageBreakData::AddPages()
+{
+ if ( nUsed > 1 )
+ {
+ long nPage = pData[0].GetFirstPage();
+ for (USHORT i=0; sal::static_int_cast<size_t>(i+1)<nUsed; i++)
+ {
+ nPage += ((long)pData[i].GetPagesX())*pData[i].GetPagesY();
+ pData[i+1].SetFirstPage( nPage );
+ }
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/pntlock.cxx b/sc/source/ui/docshell/pntlock.cxx
new file mode 100644
index 000000000000..0b71453b39d7
--- /dev/null
+++ b/sc/source/ui/docshell/pntlock.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "pntlock.hxx"
+
+//------------------------------------------------------------------------
+
+ScPaintLockData::ScPaintLockData(USHORT nNewMode) :
+ nMode( nNewMode ),
+ nLevel( 0 ),
+ nDocLevel( 0 ),
+ nParts( 0 ),
+ bModified( FALSE )
+{
+}
+
+ScPaintLockData::~ScPaintLockData()
+{
+}
+
+void ScPaintLockData::AddRange( const ScRange& rRange, USHORT nP )
+{
+ if (!xRangeList.Is())
+ xRangeList = new ScRangeList;
+
+ xRangeList->Join( rRange );
+ nParts |= nP;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/servobj.cxx b/sc/source/ui/docshell/servobj.cxx
new file mode 100644
index 000000000000..7aecfb6d0b08
--- /dev/null
+++ b/sc/source/ui/docshell/servobj.cxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+// System - Includes -----------------------------------------------------
+
+
+
+#include <sot/formats.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/linkmgr.hxx>
+#include "servobj.hxx"
+#include "docsh.hxx"
+#include "impex.hxx"
+#include "brdcst.hxx"
+#include "rangenam.hxx"
+#include "sc.hrc" // SC_HINT_AREAS_CHANGED
+
+using namespace formula;
+
+// -----------------------------------------------------------------------
+
+BOOL lcl_FillRangeFromName( ScRange& rRange, ScDocShell* pDocSh, const String& rName )
+{
+ if (pDocSh)
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScRangeName* pNames = pDoc->GetRangeName();
+ if (pNames)
+ {
+ USHORT nPos;
+ if( pNames->SearchName( rName, nPos ) )
+ {
+ ScRangeData* pData = (*pNames)[ nPos ];
+ if ( pData->IsValidReference( rRange ) )
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+ScServerObjectSvtListenerForwarder::ScServerObjectSvtListenerForwarder(
+ ScServerObject* pObjP)
+ : pObj(pObjP)
+{
+}
+
+ScServerObjectSvtListenerForwarder::~ScServerObjectSvtListenerForwarder()
+{
+ //! do NOT access pObj
+}
+
+void ScServerObjectSvtListenerForwarder::Notify( SvtBroadcaster& /* rBC */, const SfxHint& rHint)
+{
+ pObj->Notify( aBroadcaster, rHint);
+}
+
+ScServerObject::ScServerObject( ScDocShell* pShell, const String& rItem ) :
+ aForwarder( this ),
+ pDocSh( pShell ),
+ bRefreshListener( FALSE )
+{
+ // parse item string
+
+ if ( lcl_FillRangeFromName( aRange, pDocSh, rItem ) )
+ {
+ aItemStr = rItem; // must be parsed again on ref update
+ }
+ else
+ {
+ // parse ref
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = pDocSh->GetCurTab();
+ aRange.aStart.SetTab( nTab );
+
+ // For DDE link, we always must parse references using OOO A1 convention.
+
+ if ( aRange.Parse( rItem, pDoc, FormulaGrammar::CONV_OOO ) & SCA_VALID )
+ {
+ // area reference
+ }
+ else if ( aRange.aStart.Parse( rItem, pDoc, FormulaGrammar::CONV_OOO ) & SCA_VALID )
+ {
+ // cell reference
+ aRange.aEnd = aRange.aStart;
+ }
+ else
+ {
+ DBG_ERROR("ScServerObject: invalid item");
+ }
+ }
+
+ pDocSh->GetDocument()->GetLinkManager()->InsertServer( this );
+ pDocSh->GetDocument()->StartListeningArea( aRange, &aForwarder );
+
+ StartListening(*pDocSh); // um mitzubekommen, wenn die DocShell geloescht wird
+ StartListening(*SFX_APP()); // for SC_HINT_AREAS_CHANGED
+}
+
+__EXPORT ScServerObject::~ScServerObject()
+{
+ Clear();
+}
+
+void ScServerObject::Clear()
+{
+ if (pDocSh)
+ {
+ ScDocShell* pTemp = pDocSh;
+ pDocSh = NULL;
+
+ pTemp->GetDocument()->EndListeningArea( aRange, &aForwarder );
+ pTemp->GetDocument()->GetLinkManager()->RemoveServer( this );
+ EndListening(*pTemp);
+ EndListening(*SFX_APP());
+ }
+}
+
+void ScServerObject::EndListeningAll()
+{
+ aForwarder.EndListeningAll();
+ SfxListener::EndListeningAll();
+}
+
+BOOL __EXPORT ScServerObject::GetData(
+ ::com::sun::star::uno::Any & rData /*out param*/,
+ const String & rMimeType, BOOL /* bSynchron */ )
+{
+ if (!pDocSh)
+ return FALSE;
+
+ // named ranges may have changed -> update aRange
+ if ( aItemStr.Len() )
+ {
+ ScRange aNew;
+ if ( lcl_FillRangeFromName( aNew, pDocSh, aItemStr ) && aNew != aRange )
+ {
+ aRange = aNew;
+ bRefreshListener = TRUE;
+ }
+ }
+
+ if ( bRefreshListener )
+ {
+ // refresh the listeners now (this is called from a timer)
+
+ EndListeningAll();
+ pDocSh->GetDocument()->StartListeningArea( aRange, &aForwarder );
+ StartListening(*pDocSh);
+ StartListening(*SFX_APP());
+ bRefreshListener = FALSE;
+ }
+
+ String aDdeTextFmt = pDocSh->GetDdeTextFmt();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ if( FORMAT_STRING == SotExchange::GetFormatIdFromMimeType( rMimeType ))
+ {
+ ScImportExport aObj( pDoc, aRange );
+ if( aDdeTextFmt.GetChar(0) == 'F' )
+ aObj.SetFormulas( TRUE );
+ if( aDdeTextFmt.EqualsAscii( "SYLK" ) ||
+ aDdeTextFmt.EqualsAscii( "FSYLK" ) )
+ {
+ ByteString aByteData;
+ if( aObj.ExportByteString( aByteData, gsl_getSystemTextEncoding(), SOT_FORMATSTR_ID_SYLK ) )
+ {
+ rData <<= ::com::sun::star::uno::Sequence< sal_Int8 >(
+ (sal_Int8*)aByteData.GetBuffer(),
+ aByteData.Len() + 1 );
+ return 1;
+ }
+ return 0;
+ }
+ if( aDdeTextFmt.EqualsAscii( "CSV" ) ||
+ aDdeTextFmt.EqualsAscii( "FCSV" ) )
+ aObj.SetSeparator( ',' );
+ aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, ' ', false ) );
+ return aObj.ExportData( rMimeType, rData ) ? 1 : 0;
+ }
+
+ ScImportExport aObj( pDoc, aRange );
+ aObj.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::ToSpace, ' ', false ) );
+ if( aObj.IsRef() )
+ return aObj.ExportData( rMimeType, rData ) ? 1 : 0;
+ return 0;
+}
+
+void __EXPORT ScServerObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ BOOL bDataChanged = FALSE;
+
+ // DocShell can't be tested via type info, because SFX_HINT_DYING comes from the dtor
+ if ( &rBC == pDocSh )
+ {
+ // from DocShell, only SFX_HINT_DYING is interesting
+ if ( rHint.ISA(SfxSimpleHint) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocSh = NULL;
+ EndListening(*SFX_APP());
+ // don't access DocShell anymore for EndListening etc.
+ }
+ }
+ else if (rBC.ISA(SfxApplication))
+ {
+ if ( aItemStr.Len() && rHint.ISA(SfxSimpleHint) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SC_HINT_AREAS_CHANGED )
+ {
+ // check if named range was modified
+ ScRange aNew;
+ if ( lcl_FillRangeFromName( aNew, pDocSh, aItemStr ) && aNew != aRange )
+ bDataChanged = TRUE;
+ }
+ }
+ else
+ {
+ // must be from Area broadcasters
+
+ const ScHint* pScHint = PTR_CAST( ScHint, &rHint );
+ if( pScHint && (pScHint->GetId() & (SC_HINT_DATACHANGED | SC_HINT_DYING)) )
+ bDataChanged = TRUE;
+ else if (rHint.ISA(ScAreaChangedHint)) // position of broadcaster changed
+ {
+ ScRange aNewRange = ((const ScAreaChangedHint&)rHint).GetRange();
+ if ( aRange != aNewRange )
+ {
+ bRefreshListener = TRUE;
+ bDataChanged = TRUE;
+ }
+ }
+ else if (rHint.ISA(SfxSimpleHint))
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if (nId == SFX_HINT_DYING)
+ {
+ // If the range is being deleted, listening must be restarted
+ // after the deletion is complete (done in GetData)
+ bRefreshListener = TRUE;
+ bDataChanged = TRUE;
+ }
+ }
+ }
+
+ if ( bDataChanged && HasDataLinks() )
+ SvLinkSource::NotifyDataChanged();
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/sizedev.cxx b/sc/source/ui/docshell/sizedev.cxx
new file mode 100644
index 000000000000..e2452affd6f0
--- /dev/null
+++ b/sc/source/ui/docshell/sizedev.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <sfx2/printer.hxx>
+#include <vcl/virdev.hxx>
+
+#include "sizedev.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "inputopt.hxx"
+
+//------------------------------------------------------------------
+
+ScSizeDeviceProvider::ScSizeDeviceProvider( ScDocShell* pDocSh )
+{
+ BOOL bTextWysiwyg = SC_MOD()->GetInputOptions().GetTextWysiwyg();
+ if ( bTextWysiwyg )
+ {
+ pDevice = pDocSh->GetPrinter();
+ bOwner = FALSE;
+
+ aOldMapMode = pDevice->GetMapMode();
+ pDevice->SetMapMode( MAP_PIXEL ); // GetNeededSize needs pixel MapMode
+ // printer has right DigitLanguage already
+ }
+ else
+ {
+ pDevice = new VirtualDevice;
+ pDevice->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
+ bOwner = TRUE;
+ }
+
+ Point aLogic = pDevice->LogicToPixel( Point(1000,1000), MAP_TWIP );
+ nPPTX = aLogic.X() / 1000.0;
+ nPPTY = aLogic.Y() / 1000.0;
+
+ if ( !bTextWysiwyg )
+ nPPTX /= pDocSh->GetOutputFactor();
+}
+
+ScSizeDeviceProvider::~ScSizeDeviceProvider()
+{
+ if (bOwner)
+ delete pDevice;
+ else
+ pDevice->SetMapMode( aOldMapMode );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
new file mode 100644
index 000000000000..65f3119009bc
--- /dev/null
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -0,0 +1,623 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#ifdef _MSC_VER
+#pragma optimize("",off)
+#endif
+
+//------------------------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------
+
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/app.hxx>
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/transliterationwrapper.hxx>
+
+#include "tablink.hxx"
+
+#include "scextopt.hxx"
+#include "table.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+#include "undoblk.hxx"
+#include "undotab.hxx"
+#include "global.hxx"
+#include "hints.hxx"
+#include "cell.hxx"
+#include "dociter.hxx"
+#include "formula/opcode.hxx"
+
+struct TableLink_Impl
+{
+ ScDocShell* m_pDocSh;
+ Window* m_pOldParent;
+ Link m_aEndEditLink;
+
+ TableLink_Impl() : m_pDocSh( NULL ), m_pOldParent( NULL ) {}
+};
+
+TYPEINIT1(ScTableLink, ::sfx2::SvBaseLink);
+
+//------------------------------------------------------------------------
+
+ScTableLink::ScTableLink(ScDocShell* pDocSh, const String& rFile,
+ const String& rFilter, const String& rOpt,
+ ULONG nRefresh ):
+ ::sfx2::SvBaseLink(sfx2::LINKUPDATE_ONCALL,FORMAT_FILE),
+ ScRefreshTimer( nRefresh ),
+ pImpl( new TableLink_Impl ),
+ aFileName(rFile),
+ aFilterName(rFilter),
+ aOptions(rOpt),
+ bInCreate( FALSE ),
+ bInEdit( FALSE ),
+ bAddUndo( TRUE ),
+ bDoPaint( TRUE )
+{
+ pImpl->m_pDocSh = pDocSh;
+}
+
+ScTableLink::ScTableLink(SfxObjectShell* pShell, const String& rFile,
+ const String& rFilter, const String& rOpt,
+ ULONG nRefresh ):
+ ::sfx2::SvBaseLink(sfx2::LINKUPDATE_ONCALL,FORMAT_FILE),
+ ScRefreshTimer( nRefresh ),
+ pImpl( new TableLink_Impl ),
+ aFileName(rFile),
+ aFilterName(rFilter),
+ aOptions(rOpt),
+ bInCreate( FALSE ),
+ bInEdit( FALSE ),
+ bAddUndo( TRUE ),
+ bDoPaint( TRUE )
+{
+ pImpl->m_pDocSh = static_cast< ScDocShell* >( pShell );
+ SetRefreshHandler( LINK( this, ScTableLink, RefreshHdl ) );
+ SetRefreshControl( pImpl->m_pDocSh->GetDocument()->GetRefreshTimerControlAddress() );
+}
+
+__EXPORT ScTableLink::~ScTableLink()
+{
+ // Verbindung aufheben
+
+ StopRefreshTimer();
+ String aEmpty;
+ ScDocument* pDoc = pImpl->m_pDocSh->GetDocument();
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nCount; nTab++)
+ if (pDoc->IsLinked(nTab) && pDoc->GetLinkDoc(nTab)==aFileName)
+ pDoc->SetLink( nTab, SC_LINK_NONE, aEmpty, aEmpty, aEmpty, aEmpty, 0 );
+ delete pImpl;
+}
+
+void __EXPORT ScTableLink::Edit( Window* pParent, const Link& rEndEditHdl )
+{
+ // DefModalDialogParent setzen, weil evtl. aus der DocShell beim ConvertFrom
+ // ein Optionen-Dialog kommt...
+
+ pImpl->m_aEndEditLink = rEndEditHdl;
+ pImpl->m_pOldParent = Application::GetDefDialogParent();
+ if (pParent)
+ Application::SetDefDialogParent(pParent);
+
+ bInEdit = TRUE;
+ SvBaseLink::Edit( pParent, LINK( this, ScTableLink, TableEndEditHdl ) );
+}
+
+void __EXPORT ScTableLink::DataChanged( const String&,
+ const ::com::sun::star::uno::Any& )
+{
+ sfx2::LinkManager* pLinkManager=pImpl->m_pDocSh->GetDocument()->GetLinkManager();
+ if (pLinkManager!=NULL)
+ {
+ String aFile;
+ String aFilter;
+ pLinkManager->GetDisplayNames( this,0,&aFile,NULL,&aFilter);
+
+ // the file dialog returns the filter name with the application prefix
+ // -> remove prefix
+ ScDocumentLoader::RemoveAppPrefix( aFilter );
+
+ if (!bInCreate)
+ Refresh( aFile, aFilter, NULL, GetRefreshDelay() ); // don't load twice
+ }
+}
+
+void __EXPORT ScTableLink::Closed()
+{
+ // Verknuepfung loeschen: Undo
+ ScDocument* pDoc = pImpl->m_pDocSh->GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ if (bAddUndo && bUndo)
+ {
+ pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRemoveLink( pImpl->m_pDocSh, aFileName ) );
+
+ bAddUndo = FALSE; // nur einmal
+ }
+
+ // Verbindung wird im dtor aufgehoben
+
+ SvBaseLink::Closed();
+}
+
+BOOL ScTableLink::IsUsed() const
+{
+ return pImpl->m_pDocSh->GetDocument()->HasLink( aFileName, aFilterName, aOptions );
+}
+
+BOOL ScTableLink::Refresh(const String& rNewFile, const String& rNewFilter,
+ const String* pNewOptions, ULONG nNewRefresh )
+{
+ // Dokument laden
+
+ if (!rNewFile.Len() || !rNewFilter.Len())
+ return FALSE;
+
+ String aNewUrl( ScGlobal::GetAbsDocName( rNewFile, pImpl->m_pDocSh ) );
+ BOOL bNewUrlName = (aNewUrl != aFileName);
+
+ const SfxFilter* pFilter = pImpl->m_pDocSh->GetFactory().GetFilterContainer()->GetFilter4FilterName(rNewFilter);
+ if (!pFilter)
+ return FALSE;
+
+ ScDocument* pDoc = pImpl->m_pDocSh->GetDocument();
+ pDoc->SetInLinkUpdate( TRUE );
+
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ // wenn neuer Filter ausgewaehlt wurde, Optionen vergessen
+ if ( rNewFilter != aFilterName )
+ aOptions.Erase();
+ if ( pNewOptions ) // Optionen hart angegeben?
+ aOptions = *pNewOptions;
+
+ // ItemSet immer anlegen, damit die DocShell die Optionen setzen kann
+ SfxItemSet* pSet = new SfxAllItemSet( SFX_APP()->GetPool() );
+ if ( aOptions.Len() )
+ pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, aOptions ) );
+
+ SfxMedium* pMed = new SfxMedium(aNewUrl, STREAM_STD_READ, FALSE, pFilter, pSet);
+
+ if ( bInEdit ) // only if using the edit dialog,
+ pMed->UseInteractionHandler( TRUE ); // enable the filter options dialog
+
+ ScDocShell* pSrcShell = new ScDocShell(SFX_CREATE_MODE_INTERNAL);
+ SfxObjectShellRef aRef = pSrcShell;
+ pSrcShell->DoLoad(pMed);
+
+ // Optionen koennten gesetzt worden sein
+ String aNewOpt = ScDocumentLoader::GetOptions(*pMed);
+ if (!aNewOpt.Len())
+ aNewOpt = aOptions;
+
+ // Undo...
+
+ ScDocument* pUndoDoc = NULL;
+ BOOL bFirst = TRUE;
+ if (bAddUndo && bUndo)
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+
+ // Tabellen kopieren
+
+ ScDocShellModificator aModificator( *pImpl->m_pDocSh );
+
+ BOOL bNotFound = FALSE;
+ ScDocument* pSrcDoc = pSrcShell->GetDocument();
+
+ // #74835# from text filters that don't set the table name,
+ // use the one table regardless of link table name
+ BOOL bAutoTab = (pSrcDoc->GetTableCount() == 1) &&
+ ScDocShell::HasAutomaticTableName( rNewFilter );
+
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nCount; nTab++)
+ {
+ BYTE nMode = pDoc->GetLinkMode(nTab);
+ if (nMode && pDoc->GetLinkDoc(nTab)==aFileName)
+ {
+ String aTabName = pDoc->GetLinkTab(nTab);
+
+ // Undo
+
+ if (bAddUndo && bUndo)
+ {
+ if (bFirst)
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ else
+ pUndoDoc->AddUndoTab( nTab, nTab, TRUE, TRUE );
+ bFirst = FALSE;
+ ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
+ pDoc->CopyToDocument(aRange, IDF_ALL, FALSE, pUndoDoc);
+ pUndoDoc->TransferDrawPage( pDoc, nTab, nTab );
+ pUndoDoc->SetLink( nTab, nMode, aFileName, aFilterName,
+ aOptions, aTabName, GetRefreshDelay() );
+ }
+
+ // Tabellenname einer ExtDocRef anpassen
+
+ if ( bNewUrlName && nMode == SC_LINK_VALUE )
+ {
+ String aName;
+ pDoc->GetName( nTab, aName );
+ if ( ScGlobal::GetpTransliteration()->isEqual(
+ ScGlobal::GetDocTabName( aFileName, aTabName ), aName ) )
+ {
+ pDoc->RenameTab( nTab,
+ ScGlobal::GetDocTabName( aNewUrl, aTabName ),
+ FALSE, TRUE ); // kein RefUpdate, kein ValidTabName
+ }
+ }
+
+ // kopieren
+
+ SCTAB nSrcTab = 0;
+ bool bFound = false;
+ /* #i71497# check if external document is loaded successfully,
+ otherwise we may find the empty default sheet "Sheet1" in
+ pSrcDoc, even if the document does not exist. */
+ if( pMed->GetError() == 0 )
+ {
+ // no sheet name -> use first sheet
+ if ( aTabName.Len() && !bAutoTab )
+ bFound = pSrcDoc->GetTable( aTabName, nSrcTab );
+ else
+ bFound = true;
+ }
+
+ if (bFound)
+ pDoc->TransferTab( pSrcDoc, nSrcTab, nTab, FALSE, // nicht neu einfuegen
+ (nMode == SC_LINK_VALUE) ); // nur Werte?
+ else
+ {
+ pDoc->DeleteAreaTab( 0,0,MAXCOL,MAXROW, nTab, IDF_ALL );
+
+ bool bShowError = true;
+ if ( nMode == SC_LINK_VALUE )
+ {
+ // #139464# Value link (used with external references in formulas):
+ // Look for formulas that reference the sheet, and put errors in the referenced cells.
+
+ ScRangeList aErrorCells; // cells on the linked sheets that need error values
+
+ ScCellIterator aCellIter( pDoc, 0,0,0, MAXCOL,MAXROW,MAXTAB ); // all sheets
+ ScBaseCell* pCell = aCellIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+
+ ScDetectiveRefIter aRefIter( pFCell );
+ ScRange aRefRange;
+ while ( aRefIter.GetNextRef( aRefRange ) )
+ {
+ if ( aRefRange.aStart.Tab() <= nTab && aRefRange.aEnd.Tab() >= nTab )
+ {
+ // use first cell of range references (don't fill potentially large ranges)
+
+ aErrorCells.Join( ScRange( aRefRange.aStart ) );
+ }
+ }
+ }
+ pCell = aCellIter.GetNext();
+ }
+
+ ULONG nRanges = aErrorCells.Count();
+ if ( nRanges ) // found any?
+ {
+ ScTokenArray aTokenArr;
+ aTokenArr.AddOpCode( ocNotAvail );
+ aTokenArr.AddOpCode( ocOpen );
+ aTokenArr.AddOpCode( ocClose );
+ aTokenArr.AddOpCode( ocStop );
+
+ for (ULONG nPos=0; nPos<nRanges; nPos++)
+ {
+ const ScRange* pRange = aErrorCells.GetObject(nPos);
+ SCCOL nStartCol = pRange->aStart.Col();
+ SCROW nStartRow = pRange->aStart.Row();
+ SCCOL nEndCol = pRange->aEnd.Col();
+ SCROW nEndRow = pRange->aEnd.Row();
+ for (SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
+ for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
+ {
+ ScAddress aDestPos( nCol, nRow, nTab );
+ ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aDestPos, &aTokenArr );
+ pDoc->PutCell( aDestPos, pNewCell );
+ }
+ }
+
+ bShowError = false;
+ }
+ // if no references were found, insert error message (don't leave the sheet empty)
+ }
+
+ if ( bShowError )
+ {
+ // Normal link or no references: put error message on sheet.
+
+ pDoc->SetString( 0,0,nTab, ScGlobal::GetRscString(STR_LINKERROR) );
+ pDoc->SetString( 0,1,nTab, ScGlobal::GetRscString(STR_LINKERRORFILE) );
+ pDoc->SetString( 1,1,nTab, aNewUrl );
+ pDoc->SetString( 0,2,nTab, ScGlobal::GetRscString(STR_LINKERRORTAB) );
+ pDoc->SetString( 1,2,nTab, aTabName );
+ }
+
+ bNotFound = TRUE;
+ }
+
+ if ( bNewUrlName || rNewFilter != aFilterName ||
+ aNewOpt != aOptions || pNewOptions ||
+ nNewRefresh != GetRefreshDelay() )
+ pDoc->SetLink( nTab, nMode, aNewUrl, rNewFilter, aNewOpt,
+ aTabName, nNewRefresh );
+ }
+ }
+
+ // neue Einstellungen merken
+
+ if ( bNewUrlName )
+ aFileName = aNewUrl;
+ if ( rNewFilter != aFilterName )
+ aFilterName = rNewFilter;
+ if ( aNewOpt != aOptions )
+ aOptions = aNewOpt;
+
+ // aufraeumen
+
+// pSrcShell->DoClose();
+ aRef->DoClose();
+
+ // Undo
+
+ if (bAddUndo && bUndo)
+ pImpl->m_pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRefreshLink( pImpl->m_pDocSh, pUndoDoc ) );
+
+ // Paint (koennen mehrere Tabellen sein)
+
+ if (bDoPaint)
+ {
+ pImpl->m_pDocSh->PostPaint( ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB),
+ PAINT_GRID | PAINT_TOP | PAINT_LEFT );
+ aModificator.SetDocumentModified();
+ }
+
+ if (bNotFound)
+ {
+ //! Fehler ausgeben ?
+ }
+
+ pDoc->SetInLinkUpdate( FALSE );
+
+ // notify Uno objects (for XRefreshListener)
+ //! also notify Uno objects if file name was changed!
+ ScLinkRefreshedHint aHint;
+ aHint.SetSheetLink( aFileName );
+ pDoc->BroadcastUno( aHint );
+
+ return TRUE;
+}
+
+IMPL_LINK( ScTableLink, RefreshHdl, ScTableLink*, EMPTYARG )
+{
+ long nRes = Refresh( aFileName, aFilterName, NULL, GetRefreshDelay() ) != 0;
+ return nRes;
+}
+
+IMPL_LINK( ScTableLink, TableEndEditHdl, ::sfx2::SvBaseLink*, pLink )
+{
+ if ( pImpl->m_aEndEditLink.IsSet() )
+ pImpl->m_aEndEditLink.Call( pLink );
+ bInEdit = FALSE;
+ Application::SetDefDialogParent( pImpl->m_pOldParent );
+ return 0;
+}
+
+// === ScDocumentLoader ==================================================
+
+String ScDocumentLoader::GetOptions( SfxMedium& rMedium ) // static
+{
+ SfxItemSet* pSet = rMedium.GetItemSet();
+ const SfxPoolItem* pItem;
+ if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_FILE_FILTEROPTIONS, TRUE, &pItem ) )
+ return ((const SfxStringItem*)pItem)->GetValue();
+
+ return EMPTY_STRING;
+}
+
+BOOL ScDocumentLoader::GetFilterName( const String& rFileName,
+ String& rFilter, String& rOptions,
+ BOOL bWithContent, BOOL bWithInteraction ) // static
+{
+ TypeId aScType = TYPE(ScDocShell);
+ SfxObjectShell* pDocSh = SfxObjectShell::GetFirst( &aScType );
+ while ( pDocSh )
+ {
+ if ( pDocSh->HasName() )
+ {
+ SfxMedium* pMed = pDocSh->GetMedium();
+ if ( rFileName == pMed->GetName() )
+ {
+ rFilter = pMed->GetFilter()->GetFilterName();
+ rOptions = GetOptions(*pMed);
+ return TRUE;
+ }
+ }
+ pDocSh = SfxObjectShell::GetNext( *pDocSh, &aScType );
+ }
+
+ INetURLObject aUrl( rFileName );
+ INetProtocol eProt = aUrl.GetProtocol();
+ if ( eProt == INET_PROT_NOT_VALID ) // invalid URL?
+ return FALSE; // abort without creating a medium
+
+ // Filter-Detection
+
+ const SfxFilter* pSfxFilter = NULL;
+ SfxMedium* pMedium = new SfxMedium( rFileName, STREAM_STD_READ, FALSE );
+ if ( pMedium->GetError() == ERRCODE_NONE )
+ {
+ if ( bWithInteraction )
+ pMedium->UseInteractionHandler(TRUE); // #i73992# no longer called from GuessFilter
+
+ SfxFilterMatcher aMatcher( String::CreateFromAscii("scalc") );
+ if( bWithContent )
+ aMatcher.GuessFilter( *pMedium, &pSfxFilter );
+ else
+ aMatcher.GuessFilterIgnoringContent( *pMedium, &pSfxFilter );
+ }
+
+ BOOL bOK = FALSE;
+ if ( pMedium->GetError() == ERRCODE_NONE )
+ {
+ if ( pSfxFilter )
+ rFilter = pSfxFilter->GetFilterName();
+ else
+ rFilter = ScDocShell::GetOwnFilterName(); // sonst Calc-Datei
+ bOK = (rFilter.Len()>0);
+ }
+
+ delete pMedium;
+ return bOK;
+}
+
+void ScDocumentLoader::RemoveAppPrefix( String& rFilterName ) // static
+{
+ String aAppPrefix = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( STRING_SCAPP ));
+ aAppPrefix.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ xub_StrLen nPreLen = aAppPrefix.Len();
+ if ( rFilterName.Copy(0,nPreLen) == aAppPrefix )
+ rFilterName.Erase(0,nPreLen);
+}
+
+ScDocumentLoader::ScDocumentLoader( const String& rFileName,
+ String& rFilterName, String& rOptions,
+ UINT32 nRekCnt, BOOL bWithInteraction ) :
+ pDocShell(0),
+ pMedium(0)
+{
+ if ( !rFilterName.Len() )
+ GetFilterName( rFileName, rFilterName, rOptions, TRUE, bWithInteraction );
+
+ const SfxFilter* pFilter = ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( rFilterName );
+
+ // ItemSet immer anlegen, damit die DocShell die Optionen setzen kann
+ SfxItemSet* pSet = new SfxAllItemSet( SFX_APP()->GetPool() );
+ if ( rOptions.Len() )
+ pSet->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, rOptions ) );
+
+ pMedium = new SfxMedium( rFileName, STREAM_STD_READ, FALSE, pFilter, pSet );
+ if ( pMedium->GetError() != ERRCODE_NONE )
+ return ;
+
+ if ( bWithInteraction )
+ pMedium->UseInteractionHandler( TRUE ); // to enable the filter options dialog
+
+ pDocShell = new ScDocShell( SFX_CREATE_MODE_INTERNAL );
+ aRef = pDocShell;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if( pDoc )
+ {
+ ScExtDocOptions* pExtDocOpt = pDoc->GetExtDocOptions();
+ if( !pExtDocOpt )
+ {
+ pExtDocOpt = new ScExtDocOptions;
+ pDoc->SetExtDocOptions( pExtDocOpt );
+ }
+ pExtDocOpt->GetDocSettings().mnLinkCnt = nRekCnt;
+ }
+
+ pDocShell->DoLoad( pMedium );
+
+ String aNew = GetOptions(*pMedium); // Optionen werden beim Laden per Dialog gesetzt
+ if (aNew.Len() && aNew != rOptions)
+ rOptions = aNew;
+}
+
+ScDocumentLoader::~ScDocumentLoader()
+{
+/* if ( pDocShell )
+ pDocShell->DoClose();
+*/
+ if ( aRef.Is() )
+ aRef->DoClose();
+ else if ( pMedium )
+ delete pMedium;
+}
+
+void ScDocumentLoader::ReleaseDocRef()
+{
+ if ( aRef.Is() )
+ {
+ // release reference without calling DoClose - caller must
+ // have another reference to the doc and call DoClose later
+
+ pDocShell = NULL;
+ pMedium = NULL;
+ aRef.Clear();
+ }
+}
+
+ScDocument* ScDocumentLoader::GetDocument()
+{
+ return pDocShell ? pDocShell->GetDocument() : 0;
+}
+
+BOOL ScDocumentLoader::IsError() const
+{
+ if ( pDocShell && pMedium )
+ return pMedium->GetError() != ERRCODE_NONE;
+ else
+ return TRUE;
+}
+
+String ScDocumentLoader::GetTitle() const
+{
+ if ( pDocShell )
+ return pDocShell->GetTitle();
+ else
+ return EMPTY_STRING;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/tpstat.cxx b/sc/source/ui/docshell/tpstat.cxx
new file mode 100644
index 000000000000..640c0a9b6e8b
--- /dev/null
+++ b/sc/source/ui/docshell/tpstat.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "tpstat.hrc"
+
+#include "tpstat.hxx"
+
+
+//========================================================================
+// Dokumentinfo-Tabpage:
+//========================================================================
+
+SfxTabPage* __EXPORT ScDocStatPage::Create( Window *pParent, const SfxItemSet& rSet )
+{
+ return new ScDocStatPage( pParent, rSet );
+}
+
+//------------------------------------------------------------------------
+
+ScDocStatPage::ScDocStatPage( Window *pParent, const SfxItemSet& rSet )
+ : SfxTabPage( pParent, ScResId(RID_SCPAGE_STAT), rSet ),
+ aFlInfo ( this, ScResId( FL_INFO ) ),
+ aFtTablesLbl ( this, ScResId( FT_TABLES_LBL ) ),
+ aFtTables ( this, ScResId( FT_TABLES ) ),
+ aFtCellsLbl ( this, ScResId( FT_CELLS_LBL ) ),
+ aFtCells ( this, ScResId( FT_CELLS ) ),
+ aFtPagesLbl ( this, ScResId( FT_PAGES_LBL ) ),
+ aFtPages ( this, ScResId( FT_PAGES ) )
+{
+ ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+ ScDocStat aDocStat;
+
+ if ( pDocSh )
+ pDocSh->GetDocStat( aDocStat );
+
+ String aInfo = aFlInfo.GetText();
+ aInfo += aDocStat.aDocName;
+ aFlInfo .SetText( aInfo );
+ aFtTables .SetText( String::CreateFromInt32( aDocStat.nTableCount ) );
+ aFtCells .SetText( String::CreateFromInt32( aDocStat.nCellCount ) );
+ aFtPages .SetText( String::CreateFromInt32( aDocStat.nPageCount ) );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScDocStatPage::~ScDocStatPage()
+{
+}
+
+//------------------------------------------------------------------------
+
+BOOL __EXPORT ScDocStatPage::FillItemSet( SfxItemSet& /* rSet */ )
+{
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScDocStatPage::Reset( const SfxItemSet& /* rSet */ )
+{
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/docshell/tpstat.hrc b/sc/source/ui/docshell/tpstat.hrc
new file mode 100644
index 000000000000..67cbea380f9b
--- /dev/null
+++ b/sc/source/ui/docshell/tpstat.hrc
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+
+#define FT_TABLES 1
+#define FT_TABLES_LBL 2
+#define FT_CELLS 3
+#define FT_CELLS_LBL 4
+#define FT_PAGES 5
+#define FT_PAGES_LBL 6
+
+#define FL_INFO 1
diff --git a/sc/source/ui/docshell/tpstat.src b/sc/source/ui/docshell/tpstat.src
new file mode 100644
index 000000000000..b5e338ddc6a8
--- /dev/null
+++ b/sc/source/ui/docshell/tpstat.src
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "tpstat.hrc"
+TabPage RID_SCPAGE_STAT
+{
+ // HelpID = HID_DOC_STAT;
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedText FT_TABLES_LBL
+ {
+ Pos = MAP_APPFONT ( 12 , 17 ) ;
+ Size = MAP_APPFONT ( 90 , 8 ) ;
+ Text [ en-US ] = "Number of sheets:" ;
+ Left = TRUE ;
+ };
+ FixedText FT_TABLES
+ {
+ Pos = MAP_APPFONT ( 108 , 17 ) ;
+ Size = MAP_APPFONT ( 27 , 8 ) ;
+ Left = TRUE ;
+ };
+ FixedText FT_CELLS_LBL
+ {
+ Pos = MAP_APPFONT ( 12 , 29 ) ;
+ Size = MAP_APPFONT ( 90 , 8 ) ;
+ Text [ en-US ] = "Number of cells:" ;
+ Left = TRUE ;
+ };
+ FixedText FT_CELLS
+ {
+ Pos = MAP_APPFONT ( 108 , 29 ) ;
+ Size = MAP_APPFONT ( 27 , 8 ) ;
+ Left = TRUE ;
+ };
+ FixedText FT_PAGES_LBL
+ {
+ Pos = MAP_APPFONT ( 12 , 41 ) ;
+ Size = MAP_APPFONT ( 90 , 8 ) ;
+ Text [ en-US ] = "Number of pages:" ;
+ Left = TRUE ;
+ };
+ FixedText FT_PAGES
+ {
+ Pos = MAP_APPFONT ( 108 , 41 ) ;
+ Size = MAP_APPFONT ( 27 , 8 ) ;
+ Left = TRUE ;
+ };
+ FixedLine FL_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Document: " ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
new file mode 100644
index 000000000000..ce71b1b920c4
--- /dev/null
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+#include <editeng/eeitem.hxx>
+#include <svx/fontwork.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/tabarea.hxx>
+#include <svx/tabline.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "chartsh.hxx"
+#include "drwlayer.hxx"
+#include "sc.hrc"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "drawview.hxx"
+#include "scresid.hxx"
+#include <svx/svdobj.hxx>
+
+#define ScChartShell
+#include "scslots.hxx"
+
+
+SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ ScResId(RID_DRAW_OBJECTBAR) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) );
+ //SFX_OBJECTMENU_REGISTRATION( SID_OBJECTMENU0, ScResId(RID_OBJECTMENU_DRAW) );
+}
+
+TYPEINIT1( ScChartShell, ScDrawShell );
+
+ScChartShell::ScChartShell(ScViewData* pData) :
+ ScDrawShell(pData)
+{
+ SetHelpId(HID_SCSHELL_CHARTSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ChartObject")));
+}
+
+ScChartShell::~ScChartShell()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
new file mode 100644
index 000000000000..8b7e21d2f08a
--- /dev/null
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -0,0 +1,485 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include "scitems.hxx"
+
+#include <editeng/eeitem.hxx>
+#include <svx/fontwork.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/tabarea.hxx>
+#include <svx/tabline.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "drawsh.hxx"
+#include "drwlayer.hxx"
+#include "sc.hrc"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "drawview.hxx"
+#include "scresid.hxx"
+#include <svx/svdobj.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/drawitem.hxx>
+#include <svx/xtable.hxx>
+
+#define ScDrawShell
+#include "scslots.hxx"
+
+#include "userdat.hxx"
+#include <sfx2/objsh.hxx>
+#include <svl/macitem.hxx>
+#include <sfx2/evntconf.hxx>
+#include <sfx2/viewsh.hxx>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+
+//------------------------------------------------------------------
+
+TYPEINIT1( ScDrawShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScDrawShell, SfxShell, ScResId(SCSTR_DRAWSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ ScResId(RID_DRAW_OBJECTBAR) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAW) );
+ SFX_CHILDWINDOW_REGISTRATION( SvxFontWorkChildWindow::GetChildWindowId() );
+}
+
+
+// abschalten der nicht erwuenschten Acceleratoren:
+
+void ScDrawShell::StateDisableItems( SfxItemSet &rSet )
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void lcl_setModified( SfxObjectShell* pShell )
+{
+ if ( pShell )
+ {
+ com::sun::star::uno::Reference< com::sun::star::util::XModifiable > xModif( pShell->GetModel(), com::sun::star::uno::UNO_QUERY );
+ if ( xModif.is() )
+ xModif->setModified( sal_True );
+ }
+}
+
+void ScDrawShell::ExecDrawAttr( SfxRequest& rReq )
+{
+ USHORT nSlot = rReq.GetSlot();
+ Window* pWin = pViewData->GetActiveWin();
+// SfxViewFrame* pViewFrame = SfxViewShell::Current()->GetViewFrame(); //!!! koennte knallen
+ ScDrawView* pView = pViewData->GetScDrawView();
+ SdrModel* pDoc = pViewData->GetDocument()->GetDrawLayer();
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+ SdrObject* pSingleSelectedObj = NULL;
+ if ( nMarkCount > 0 )
+ pSingleSelectedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ switch ( nSlot )
+ {
+ case SID_ASSIGNMACRO:
+ {
+ if ( pSingleSelectedObj )
+ ExecuteMacroAssign( pSingleSelectedObj, pWin );
+ }
+ break;
+
+ case SID_TEXT_STANDARD: // Harte Textattributierung loeschen
+ {
+ SfxItemSet aEmptyAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END);
+ pView->SetAttributes(aEmptyAttr, TRUE);
+ }
+ break;
+
+ case SID_ATTR_LINE_STYLE:
+ case SID_ATTR_LINEEND_STYLE:
+ case SID_ATTR_LINE_DASH:
+ case SID_ATTR_LINE_WIDTH:
+ case SID_ATTR_LINE_COLOR:
+ case SID_ATTR_FILL_STYLE:
+ case SID_ATTR_FILL_COLOR:
+ case SID_ATTR_FILL_GRADIENT:
+ case SID_ATTR_FILL_HATCH:
+ case SID_ATTR_FILL_BITMAP:
+
+ // #i25616#
+ case SID_ATTR_FILL_SHADOW:
+ {
+ // Wenn ToolBar vertikal :
+ if ( !rReq.GetArgs() )
+ {
+ switch ( nSlot )
+ {
+ case SID_ATTR_LINE_STYLE:
+ case SID_ATTR_LINE_DASH:
+ case SID_ATTR_LINE_WIDTH:
+ case SID_ATTR_LINE_COLOR:
+ ExecuteLineDlg( rReq );
+ break;
+
+ case SID_ATTR_FILL_STYLE:
+ case SID_ATTR_FILL_COLOR:
+ case SID_ATTR_FILL_GRADIENT:
+ case SID_ATTR_FILL_HATCH:
+ case SID_ATTR_FILL_BITMAP:
+
+ // #i25616#
+ case SID_ATTR_FILL_SHADOW:
+
+ ExecuteAreaDlg( rReq );
+ break;
+
+ default:
+ break;
+ }
+
+ //=====
+ return;
+ //=====
+ }
+
+ if( pView->AreObjectsMarked() )
+ pView->SetAttrToMarked( *rReq.GetArgs(), FALSE );
+ else
+ pView->SetDefaultAttr( *rReq.GetArgs(), FALSE);
+ pView->InvalidateAttribs();
+ }
+ break;
+
+ case SID_ATTRIBUTES_LINE:
+ ExecuteLineDlg( rReq );
+ break;
+
+ case SID_ATTRIBUTES_AREA:
+ ExecuteAreaDlg( rReq );
+ break;
+
+ case SID_DRAWTEXT_ATTR_DLG:
+ ExecuteTextAttrDlg( rReq );
+ break;
+
+ case SID_DRAW_HLINK_EDIT:
+ if ( pSingleSelectedObj )
+ pViewData->GetDispatcher().Execute( SID_HYPERLINK_DIALOG );
+ break;
+
+ case SID_DRAW_HLINK_DELETE:
+ if ( pSingleSelectedObj )
+ SetHlinkForObject( pSingleSelectedObj, rtl::OUString() );
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ if ( nMarkCount == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if ( pObj->IsGroupObject() )
+ {
+ SdrPageView* pPV = 0;
+ SdrObject* pHit = 0;
+ if ( pView->PickObj( pWin->PixelToLogic( pViewData->GetMousePosPixel() ), pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
+ pObj = pHit;
+ }
+
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
+ if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
+ ScGlobal::OpenURL( pInfo->GetHlink(), String::EmptyString() );
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM:
+ {
+ if ( pView->AreObjectsMarked() )
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if( !pArgs )
+ {
+ // const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( rMarkList.GetMark(0) != 0 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if( pObj->GetObjIdentifier() == OBJ_CAPTION )
+ {
+ // --------- Itemset fuer Caption --------
+ SfxItemSet aNewAttr(pDoc->GetItemPool());
+ pView->GetAttributes(aNewAttr);
+ // --------- Itemset fuer Groesse und Position --------
+ SfxItemSet aNewGeoAttr(pView->GetGeoAttrFromMarked());
+
+ //SvxCaptionTabDialog* pDlg = new SvxCaptionTabDialog(pWin, pView);
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ SfxAbstractTabDialog *pDlg = pFact->CreateCaptionDialog( pWin, pView );
+
+ const USHORT* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() );
+ SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange );
+ aCombSet.Put( aNewAttr );
+ aCombSet.Put( aNewGeoAttr );
+ pDlg->SetInputSet( &aCombSet );
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ rReq.Done(*(pDlg->GetOutputItemSet()));
+ pView->SetAttributes(*pDlg->GetOutputItemSet());
+ pView->SetGeoAttrToMarked(*pDlg->GetOutputItemSet());
+ }
+
+ delete pDlg;
+ }
+ }
+ else
+ {
+ SfxItemSet aNewAttr(pView->GetGeoAttrFromMarked());
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ SfxAbstractTabDialog* pDlg = pFact->CreateSvxTransformTabDialog( pWin, &aNewAttr,pView );
+ DBG_ASSERT(pDlg, "Dialog creation failed!");
+ if (pDlg->Execute() == RET_OK)
+ {
+ rReq.Done(*(pDlg->GetOutputItemSet()));
+ pView->SetGeoAttrToMarked(*pDlg->GetOutputItemSet());
+ }
+ delete pDlg;
+ }
+ }
+ }
+
+
+ }
+ else
+ pView->SetGeoAttrToMarked( *pArgs );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+void ScDrawShell::ExecuteMacroAssign( SdrObject* pObj, Window* pWin )
+{
+ SvxMacroItem aItem ( SFX_APP()->GetPool().GetWhich( SID_ATTR_MACROITEM ) );
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE );
+ if ( pInfo->GetMacro().getLength() > 0 )
+ {
+ SvxMacroTableDtor aTab;
+ String sMacro( pInfo->GetMacro() );
+ aTab.Insert( SFX_EVENT_MOUSECLICK_OBJECT, new SvxMacro( sMacro, String() ) );
+ aItem.SetMacroTable( aTab );
+ }
+
+ // create empty itemset for macro-dlg
+ SfxItemSet* pItemSet = new SfxItemSet(SFX_APP()->GetPool(), SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 );
+ pItemSet->Put ( aItem, SID_ATTR_MACROITEM );
+
+ SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
+ aNamesItem.AddEvent( ScResId(RID_SCSTR_ONCLICK), String(), SFX_EVENT_MOUSECLICK_OBJECT );
+ pItemSet->Put( aNamesItem, SID_EVENTCONFIG );
+
+ com::sun::star::uno::Reference < com::sun::star::frame::XFrame > xFrame;
+ if (GetViewShell())
+ xFrame = GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface();
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pWin, *pItemSet, xFrame, SID_EVENTCONFIG );
+ if ( pMacroDlg && pMacroDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet();
+ const SfxPoolItem* pItem;
+ if( SFX_ITEM_SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, FALSE, &pItem ))
+ {
+ rtl::OUString sMacro;
+ SvxMacro* pMacro = ((SvxMacroItem*)pItem)->GetMacroTable().Get( SFX_EVENT_MOUSECLICK_OBJECT );
+ if ( pMacro )
+ sMacro = pMacro->GetMacName();
+
+ if ( pObj->IsGroupObject() )
+ {
+ SdrObjList* pOL = pObj->GetSubList();
+ ULONG nObj = pOL->GetObjCount();
+ for ( ULONG index=0; index<nObj; ++index )
+ {
+ pInfo = ScDrawLayer::GetMacroInfo( pOL->GetObj(index), TRUE );
+ pInfo->SetMacro( sMacro );
+ }
+ }
+ else
+ pInfo->SetMacro( sMacro );
+ lcl_setModified( GetObjectShell() );
+ }
+ }
+
+ delete pMacroDlg;
+ delete pItemSet;
+}
+
+void ScDrawShell::ExecuteLineDlg( SfxRequest& rReq, USHORT nTabPage )
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+ BOOL bHasMarked = pView->AreObjectsMarked();
+ const SdrObject* pObj = NULL;
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ SfxItemSet aNewAttr( pView->GetDefaultAttr() );
+ if( bHasMarked )
+ pView->MergeAttrFromMarked( aNewAttr, FALSE );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
+ SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( pViewData->GetDialogParent(),
+ &aNewAttr,
+ pViewData->GetDocument()->GetDrawLayer(),
+ pObj,
+ bHasMarked);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ if ( nTabPage != 0xffff )
+ pDlg->SetCurPageId( nTabPage );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ if( bHasMarked )
+ pView->SetAttrToMarked( *pDlg->GetOutputItemSet(), FALSE );
+ else
+ pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), FALSE );
+
+ pView->InvalidateAttribs();
+ rReq.Done();
+ }
+
+ delete pDlg;
+}
+
+void ScDrawShell::ExecuteAreaDlg( SfxRequest& rReq, USHORT nTabPage )
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+ BOOL bHasMarked = pView->AreObjectsMarked();
+
+ SfxItemSet aNewAttr( pView->GetDefaultAttr() );
+ if( bHasMarked )
+ pView->MergeAttrFromMarked( aNewAttr, FALSE );
+
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
+ AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( pViewData->GetDialogParent(),
+ &aNewAttr,
+ pViewData->GetDocument()->GetDrawLayer(),
+ pView);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+
+ // #i74099# by default, the dialog deletes the current color table if a different one is loaded
+ // (see SwDrawShell::ExecDrawDlg)
+ const SvxColorTableItem* pColorItem =
+ static_cast<const SvxColorTableItem*>( pViewData->GetSfxDocShell()->GetItem(SID_COLOR_TABLE) );
+ if (pColorItem->GetColorTable() == XColorTable::GetStdColorTable())
+ pDlg->DontDeleteColorTable();
+
+ if ( nTabPage != 0xffff )
+ pDlg->SetCurPageId( nTabPage );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ if( bHasMarked )
+ pView->SetAttrToMarked( *pDlg->GetOutputItemSet(), FALSE );
+ else
+ pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), FALSE );
+
+ pView->InvalidateAttribs();
+ rReq.Done();
+ }
+
+ delete pDlg;
+}
+
+void ScDrawShell::ExecuteTextAttrDlg( SfxRequest& rReq, USHORT /* nTabPage */ )
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+ BOOL bHasMarked = pView->AreObjectsMarked();
+ SfxItemSet aNewAttr ( pView->GetDefaultAttr() );
+
+ if( bHasMarked )
+ pView->MergeAttrFromMarked( aNewAttr, FALSE );
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aNewAttr, pView );
+
+ USHORT nResult = pDlg->Execute();
+
+ if ( RET_OK == nResult )
+ {
+ if ( bHasMarked )
+ pView->SetAttributes( *pDlg->GetOutputItemSet() );
+ else
+ pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), FALSE );
+
+ pView->InvalidateAttribs();
+ rReq.Done();
+ }
+ delete( pDlg );
+}
+
+void ScDrawShell::SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk )
+{
+ if ( pObj )
+ {
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE );
+ pInfo->SetHlink( rHlnk );
+ lcl_setModified( GetObjectShell() );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx
new file mode 100644
index 000000000000..b32bc7a432d3
--- /dev/null
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -0,0 +1,397 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+#include <com/sun/star/embed/EmbedMisc.hpp>
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/xdef.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+
+#include "drawsh.hxx"
+#include "drawview.hxx"
+#include "viewdata.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include <svx/svdoole2.hxx>
+#include <svx/svdocapt.hxx>
+
+USHORT ScGetFontWorkId(); // in drtxtob
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+ScDrawShell::ScDrawShell( ScViewData* pData ) :
+ SfxShell(pData->GetViewShell()),
+ pViewData( pData )
+{
+ SetPool( &pViewData->GetScDrawView()->GetModel()->GetItemPool() );
+ SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId( HID_SCSHELL_DRAWSH );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Drawing")));
+}
+
+ScDrawShell::~ScDrawShell()
+{
+}
+
+void ScDrawShell::GetState( SfxItemSet& rSet ) // Zustaende / Toggles
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+ SdrDragMode eMode = pView->GetDragMode();
+
+ rSet.Put( SfxBoolItem( SID_OBJECT_ROTATE, eMode == SDRDRAG_ROTATE ) );
+ rSet.Put( SfxBoolItem( SID_OBJECT_MIRROR, eMode == SDRDRAG_MIRROR ) );
+ rSet.Put( SfxBoolItem( SID_BEZIER_EDIT, !pView->IsFrameDragSingles() ) );
+
+ USHORT nFWId = ScGetFontWorkId();
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ rSet.Put(SfxBoolItem(SID_FONTWORK, pViewFrm->HasChildWindow(nFWId)));
+
+ // Notes always default to Page anchor.
+ bool bDisableAnchor = false;
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+ if ( nMarkCount == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( ScDrawLayer::IsNoteCaption( pObj ) )
+ {
+ bDisableAnchor = true;
+ rSet.DisableItem( SID_ANCHOR_PAGE );
+ rSet.DisableItem( SID_ANCHOR_CELL );
+ }
+ }
+
+ if ( !bDisableAnchor )
+ {
+ switch( pView->GetAnchor() )
+ {
+ case SCA_PAGE:
+ rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, TRUE ) );
+ rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, FALSE ) );
+ break;
+
+ case SCA_CELL:
+ rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, FALSE ) );
+ rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, TRUE ) );
+ break;
+
+ default:
+ rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, FALSE ) );
+ rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, FALSE ) );
+ break;
+ }
+ }
+}
+
+void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // Funktionen disablen
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+
+ // #111711# call IsMirrorAllowed first to make sure ForcePossibilities (and thus CheckMarked)
+ // is called before GetMarkCount, so the nMarkCount value is valid for the rest of this method.
+ if (!pView->IsMirrorAllowed(TRUE,TRUE))
+ {
+ rSet.DisableItem( SID_MIRROR_HORIZONTAL );
+ rSet.DisableItem( SID_MIRROR_VERTICAL );
+ }
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount <= 1 || !pView->IsGroupPossible() )
+ rSet.DisableItem( SID_GROUP );
+ if ( nMarkCount == 0 || !pView->IsUnGroupPossible() )
+ rSet.DisableItem( SID_UNGROUP );
+ if ( nMarkCount != 1 || !pView->IsGroupEnterPossible() )
+ rSet.DisableItem( SID_ENTER_GROUP );
+ if ( !pView->IsGroupEntered() )
+ rSet.DisableItem( SID_LEAVE_GROUP );
+
+ if ( nMarkCount <= 1 ) // nichts oder nur ein Objekt selektiert
+ {
+ // Ausrichtung
+ rSet.DisableItem( SID_OBJECT_ALIGN_LEFT ); // keine Ausrichtung an der Seite
+ rSet.DisableItem( SID_OBJECT_ALIGN_CENTER );
+ rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_UP );
+ rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE );
+ rSet.DisableItem( SID_OBJECT_ALIGN_DOWN );
+
+ // pseudo slots for Format menu
+ rSet.DisableItem( SID_ALIGN_ANY_LEFT );
+ rSet.DisableItem( SID_ALIGN_ANY_HCENTER );
+ rSet.DisableItem( SID_ALIGN_ANY_RIGHT );
+ rSet.DisableItem( SID_ALIGN_ANY_TOP );
+ rSet.DisableItem( SID_ALIGN_ANY_VCENTER );
+ rSet.DisableItem( SID_ALIGN_ANY_BOTTOM );
+ }
+
+ // do not change layer of form controls
+ // #158385# #i83729# do not change layer of cell notes (on internal layer)
+ if ( !nMarkCount || pView->HasMarkedControl() || pView->HasMarkedInternal() )
+ {
+ rSet.DisableItem( SID_OBJECT_HEAVEN );
+ rSet.DisableItem( SID_OBJECT_HELL );
+ }
+ else
+ {
+ if(AreAllObjectsOnLayer(SC_LAYER_FRONT,rMarkList))
+ {
+ rSet.DisableItem( SID_OBJECT_HEAVEN );
+ }
+ else if(AreAllObjectsOnLayer(SC_LAYER_BACK,rMarkList))
+ {
+ rSet.DisableItem( SID_OBJECT_HELL );
+ }
+ }
+
+ BOOL bCanRename = FALSE;
+ if ( nMarkCount > 1 )
+ {
+ // no hypelink options for a selected group
+ rSet.DisableItem( SID_DRAW_HLINK_EDIT );
+ rSet.DisableItem( SID_DRAW_HLINK_DELETE );
+ rSet.DisableItem( SID_OPEN_HYPERLINK );
+ }
+ else if ( nMarkCount == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
+ if ( !pInfo || (pInfo->GetHlink().getLength() == 0) )
+ {
+ rSet.DisableItem( SID_DRAW_HLINK_DELETE );
+ rSet.DisableItem( SID_OPEN_HYPERLINK );
+ }
+ SdrLayerID nLayerID = pObj->GetLayer();
+ if ( nLayerID != SC_LAYER_INTERN )
+ bCanRename = TRUE; // #i51351# anything except internal objects can be renamed
+
+ // #91929#; don't show original size entry if not possible
+ UINT16 nObjType = pObj->GetObjIdentifier();
+ if ( nObjType == OBJ_OLE2 )
+ {
+ SdrOle2Obj* pOleObj = static_cast<SdrOle2Obj*>(rMarkList.GetMark( 0 )->GetMarkedSdrObj());
+ if (pOleObj->GetObjRef().is() &&
+ ((pOleObj->GetObjRef()->getStatus( pOleObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) ) )
+ //TODO/LATER: why different slots in Draw and Calc?
+ rSet.DisableItem(SID_ORIGINALSIZE);
+ }
+ else if ( nObjType == OBJ_CAPTION )
+ {
+ if ( nLayerID == SC_LAYER_INTERN )
+ {
+ // SdrCaptionObj() Notes cannot be cut/copy in isolation from
+ // their cells.
+ rSet.DisableItem( SID_CUT );
+ rSet.DisableItem( SID_COPY );
+ // Notes always default to Page anchor.
+ rSet.DisableItem( SID_ANCHOR_TOGGLE );
+ }
+ }
+ }
+ if ( !bCanRename )
+ {
+ // #i68101#
+ rSet.DisableItem( SID_RENAME_OBJECT );
+ rSet.DisableItem( SID_TITLE_DESCRIPTION_OBJECT );
+ }
+
+ if ( !nMarkCount ) // nichts selektiert
+ {
+ // Anordnung
+ rSet.DisableItem( SID_FRAME_UP );
+ rSet.DisableItem( SID_FRAME_DOWN );
+ rSet.DisableItem( SID_FRAME_TO_TOP );
+ rSet.DisableItem( SID_FRAME_TO_BOTTOM );
+ // Clipboard / loeschen
+ rSet.DisableItem( SID_DELETE );
+ rSet.DisableItem( SID_DELETE_CONTENTS );
+ rSet.DisableItem( SID_CUT );
+ rSet.DisableItem( SID_COPY );
+ // sonstiges
+ rSet.DisableItem( SID_ANCHOR_TOGGLE );
+ rSet.DisableItem( SID_ORIGINALSIZE );
+ rSet.DisableItem( SID_ATTR_TRANSFORM );
+ }
+
+ if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
+ {
+ SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
+ pView->GetAttributes( aAttrs );
+ if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
+ {
+ BOOL bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
+ rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
+ }
+ }
+
+ svx::ExtrusionBar::getState( pView, rSet );
+ svx::FontworkBar::getState( pView, rSet );
+}
+
+//
+// Attribute fuer Drawing-Objekte
+//
+
+void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet )
+{
+ Point aMousePos = pViewData->GetMousePosPixel();
+ Window* pWindow = pViewData->GetActiveWin();
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ Point aPos = pWindow->PixelToLogic(aMousePos);
+ BOOL bHasMarked = pDrView->AreObjectsMarked();
+
+ if( bHasMarked )
+ {
+ rSet.Put( pDrView->GetAttrFromMarked(FALSE) );
+
+ // Wenn die View selektierte Objekte besitzt, muessen entspr. Items
+ // von SFX_ITEM_DEFAULT (_ON) auf SFX_ITEM_DISABLED geaendert werden
+
+ SfxWhichIter aIter( rSet, XATTR_LINE_FIRST, XATTR_FILL_LAST );
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ if( SFX_ITEM_DEFAULT == rSet.GetItemState( nWhich ) )
+ rSet.DisableItem( nWhich );
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+ else
+ rSet.Put( pDrView->GetDefaultAttr() );
+
+ SdrPageView* pPV = pDrView->GetSdrPageView();
+ if ( pPV )
+ {
+ // #i52073# when a sheet with an active OLE object is deleted,
+ // the slot state is queried without an active page view
+
+ // Items for position and size (see ScGridWindow::UpdateStatusPosSize, #108137#)
+
+ // #i34458# The SvxSizeItem in SID_TABLE_CELL is no longer needed by
+ // SvxPosSizeStatusBarControl, it's enough to have it in SID_ATTR_SIZE.
+
+ BOOL bActionItem = FALSE;
+ if ( pDrView->IsAction() ) // action rectangle
+ {
+ Rectangle aRect;
+ pDrView->TakeActionRect( aRect );
+ if ( !aRect.IsEmpty() )
+ {
+ pPV->LogicToPagePos(aRect);
+ rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
+ Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) );
+ bActionItem = TRUE;
+ }
+ }
+ if ( !bActionItem )
+ {
+ if ( pDrView->AreObjectsMarked() ) // selected objects
+ {
+ Rectangle aRect = pDrView->GetAllMarkedRect();
+ pPV->LogicToPagePos(aRect);
+ rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
+ Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) );
+ }
+ else // mouse position
+ {
+ // aPos is initialized above
+ pPV->LogicToPagePos(aPos);
+ rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) );
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
+ }
+ }
+ }
+}
+
+void ScDrawShell::GetAttrFuncState(SfxItemSet &rSet)
+{
+ // Dialoge fuer Draw-Attribute disablen, wenn noetig
+
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ SfxItemSet aViewSet = pDrView->GetAttrFromMarked(FALSE);
+
+ if ( aViewSet.GetItemState( XATTR_LINESTYLE ) == SFX_ITEM_DEFAULT )
+ {
+ rSet.DisableItem( SID_ATTRIBUTES_LINE );
+ rSet.DisableItem( SID_ATTR_LINEEND_STYLE ); // Tbx-Controller
+ }
+
+ if ( aViewSet.GetItemState( XATTR_FILLSTYLE ) == SFX_ITEM_DEFAULT )
+ rSet.DisableItem( SID_ATTRIBUTES_AREA );
+}
+
+BOOL ScDrawShell::AreAllObjectsOnLayer(USHORT nLayerNo,const SdrMarkList& rMark)
+{
+ BOOL bResult=TRUE;
+ ULONG nCount = rMark.GetMarkCount();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
+ if ( !pObj->ISA(SdrUnoObj) )
+ {
+ if(nLayerNo!=pObj->GetLayer())
+ {
+ bResult=FALSE;
+ break;
+ }
+ }
+ }
+ return bResult;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drawsh4.cxx b/sc/source/ui/drawfunc/drawsh4.cxx
new file mode 100644
index 000000000000..863a079e7ce6
--- /dev/null
+++ b/sc/source/ui/drawfunc/drawsh4.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/drawitem.hxx>
+#include <svx/fontwork.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/xdef.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "drawsh.hxx"
+#include "drawview.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+
+
+//------------------------------------------------------------------
+
+void ScDrawShell::GetFormTextState(SfxItemSet& rSet)
+{
+ const SdrObject* pObj = NULL;
+ SvxFontWorkDialog* pDlg = NULL;
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ if ( pViewFrm->HasChildWindow(nId) )
+ pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
+ !((SdrTextObj*) pObj)->HasText() )
+ {
+ if ( pDlg )
+ pDlg->SetActive(FALSE);
+
+ rSet.DisableItem(XATTR_FORMTXTSTYLE);
+ rSet.DisableItem(XATTR_FORMTXTADJUST);
+ rSet.DisableItem(XATTR_FORMTXTDISTANCE);
+ rSet.DisableItem(XATTR_FORMTXTSTART);
+ rSet.DisableItem(XATTR_FORMTXTMIRROR);
+ rSet.DisableItem(XATTR_FORMTXTSTDFORM);
+ rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
+ rSet.DisableItem(XATTR_FORMTXTOUTLINE);
+ rSet.DisableItem(XATTR_FORMTXTSHADOW);
+ rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
+ rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
+ rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
+ }
+ else
+ {
+ if ( pDlg )
+ {
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+
+ if ( pDocSh )
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+ XColorTable* pColorTable = NULL;
+
+ if ( pItem )
+ pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
+
+ pDlg->SetActive();
+
+ if ( pColorTable )
+ pDlg->SetColorTable( pColorTable );
+ else
+ { DBG_ERROR( "ColorList not found :-/" ); }
+ }
+ }
+ SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
+ pDrView->GetAttributes(aViewAttr);
+ rSet.Set(aViewAttr);
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx
new file mode 100644
index 000000000000..23c29521698c
--- /dev/null
+++ b/sc/source/ui/drawfunc/drawsh5.cxx
@@ -0,0 +1,756 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/fmglob.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svx/fontwork.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/xdef.hxx>
+#include <svx/xftsfit.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <sfx2/docfile.hxx>
+
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+
+#include "drawsh.hxx"
+#include "drawview.hxx"
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "undotab.hxx"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include "postit.hxx"
+
+#include "sc.hrc"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+
+ // Hyperlink
+
+ SvxHyperlinkItem aHLinkItem;
+
+ if ( nMarkCount == 1 ) // URL-Button markiert ?
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
+ if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
+ {
+ aHLinkItem.SetURL( pInfo->GetHlink() );
+ aHLinkItem.SetInsertMode(HLINK_FIELD);
+ }
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj);
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
+ DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
+ if( !xControlModel.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
+
+ rtl::OUString sPropButtonType = rtl::OUString::createFromAscii( "ButtonType" );
+ rtl::OUString sPropTargetURL = rtl::OUString::createFromAscii( "TargetURL" );
+ rtl::OUString sPropTargetFrame = rtl::OUString::createFromAscii( "TargetFrame" );
+ rtl::OUString sPropLabel = rtl::OUString::createFromAscii( "Label" );
+
+ if(xInfo->hasPropertyByName( sPropButtonType ))
+ {
+ uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType );
+ form::FormButtonType eTmp;
+ if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL )
+ {
+ rtl::OUString sTmp;
+ // Label
+ if(xInfo->hasPropertyByName( sPropLabel ))
+ {
+ aAny = xPropSet->getPropertyValue( sPropLabel );
+ if ( (aAny >>= sTmp) && sTmp.getLength() )
+ {
+ aHLinkItem.SetName(sTmp);
+ }
+ }
+ // URL
+ if(xInfo->hasPropertyByName( sPropTargetURL ))
+ {
+ aAny = xPropSet->getPropertyValue( sPropTargetURL );
+ if ( (aAny >>= sTmp) && sTmp.getLength() )
+ {
+ aHLinkItem.SetURL(sTmp);
+ }
+ }
+ // Target
+ if(xInfo->hasPropertyByName( sPropTargetFrame ))
+ {
+ aAny = xPropSet->getPropertyValue( sPropTargetFrame );
+ if ( (aAny >>= sTmp) && sTmp.getLength() )
+ {
+ aHLinkItem.SetTargetFrame(sTmp);
+ }
+ }
+ aHLinkItem.SetInsertMode(HLINK_BUTTON);
+ }
+ }
+ }
+ }
+
+ rSet.Put(aHLinkItem);
+}
+
+void ScDrawShell::ExecuteHLink( SfxRequest& rReq )
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_HYPERLINK_SETLINK:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
+ const String& rName = pHyper->GetName();
+ const String& rURL = pHyper->GetURL();
+ const String& rTarget = pHyper->GetTargetFrame();
+ SvxLinkInsertMode eMode = pHyper->GetInsertMode();
+
+ BOOL bDone = FALSE;
+ if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON )
+ {
+ ScDrawView* pView = pViewData->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if ( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj );
+ if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor())
+ {
+ uno::Reference<awt::XControlModel> xControlModel =
+ pUnoCtrl->GetUnoControlModel();
+ DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
+ if( !xControlModel.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo();
+
+ rtl::OUString sPropTargetURL =
+ rtl::OUString::createFromAscii( "TargetURL" );
+
+ // Darf man eine URL an dem Objekt setzen?
+ if (xInfo->hasPropertyByName( sPropTargetURL ))
+ {
+ // Ja!
+
+ rtl::OUString sPropButtonType =
+ rtl::OUString::createFromAscii( "ButtonType" );
+ rtl::OUString sPropTargetFrame =
+ rtl::OUString::createFromAscii( "TargetFrame" );
+ rtl::OUString sPropLabel =
+ rtl::OUString::createFromAscii( "Label" );
+
+ uno::Any aAny;
+ if ( xInfo->hasPropertyByName( sPropLabel ) )
+ {
+ aAny <<= rtl::OUString(rName);
+ xPropSet->setPropertyValue( sPropLabel, aAny );
+ }
+
+ ::rtl::OUString aTmp = INetURLObject::GetAbsURL( pViewData->GetDocShell()->GetMedium()->GetBaseURL(), rURL );
+ aAny <<= aTmp;
+ xPropSet->setPropertyValue( sPropTargetURL, aAny );
+
+ if( rTarget.Len() && xInfo->hasPropertyByName( sPropTargetFrame ) )
+ {
+ aAny <<= rtl::OUString(rTarget);
+ xPropSet->setPropertyValue( sPropTargetFrame, aAny );
+ }
+
+ if ( xInfo->hasPropertyByName( sPropButtonType ) )
+ {
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ aAny <<= eButtonType;
+ xPropSet->setPropertyValue( sPropButtonType, aAny );
+ }
+
+ //! Undo ???
+ pViewData->GetDocShell()->SetDocumentModified();
+ bDone = TRUE;
+ }
+ }
+ else
+ {
+ SetHlinkForObject( pObj, rURL );
+ bDone = TRUE;
+ }
+ }
+ }
+
+ if (!bDone)
+ pViewData->GetViewShell()->
+ InsertURL( rName, rURL, rTarget, (USHORT) eMode );
+
+ // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
+ }
+ }
+ break;
+ default:
+ DBG_ERROR("falscher Slot");
+ }
+}
+
+USHORT ScGetFontWorkId(); // wegen CLOOKs - in drtxtob2
+
+//------------------------------------------------------------------
+
+//
+// Funktionen auf Drawing-Objekten
+//
+
+void ScDrawShell::ExecDrawFunc( SfxRequest& rReq )
+{
+ SfxBindings& rBindings = pViewData->GetBindings();
+ ScTabView* pTabView = pViewData->GetView();
+ ScDrawView* pView = pTabView->GetScDrawView();
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ USHORT nSlotId = rReq.GetSlot();
+
+ //!!!
+ // wer weiss, wie lange das funktioniert? (->vom Abreisscontrol funktioniert es)
+ //
+ if (nSlotId == SID_OBJECT_ALIGN && pArgs)
+ nSlotId = SID_OBJECT_ALIGN + ((SfxEnumItem&)pArgs->Get(SID_OBJECT_ALIGN)).GetValue() + 1;
+
+ switch (nSlotId)
+ {
+ case SID_OBJECT_HEAVEN:
+ pView->SetMarkedToLayer( SC_LAYER_FRONT );
+ rBindings.Invalidate(SID_OBJECT_HEAVEN);
+ rBindings.Invalidate(SID_OBJECT_HELL);
+ break;
+ case SID_OBJECT_HELL:
+ pView->SetMarkedToLayer( SC_LAYER_BACK );
+ rBindings.Invalidate(SID_OBJECT_HEAVEN);
+ rBindings.Invalidate(SID_OBJECT_HELL);
+ // leave draw shell if nothing selected (layer may be locked)
+ if ( pView->GetMarkedObjectList().GetMarkCount() == 0 )
+ pViewData->GetViewShell()->SetDrawShell( FALSE );
+ break;
+
+ case SID_FRAME_TO_TOP:
+ pView->PutMarkedToTop();
+ break;
+ case SID_FRAME_TO_BOTTOM:
+ pView->PutMarkedToBtm();
+ break;
+ case SID_FRAME_UP:
+ pView->MovMarkedToTop();
+ break;
+ case SID_FRAME_DOWN:
+ pView->MovMarkedToBtm();
+ break;
+
+ case SID_GROUP:
+ pView->GroupMarked();
+ break;
+ case SID_UNGROUP:
+ pView->UnGroupMarked();
+ break;
+ case SID_ENTER_GROUP:
+ pView->EnterMarkedGroup();
+ break;
+ case SID_LEAVE_GROUP:
+ pView->LeaveOneGroup();
+ break;
+
+ case SID_MIRROR_HORIZONTAL:
+ pView->MirrorAllMarkedHorizontal();
+ break;
+ case SID_MIRROR_VERTICAL:
+ pView->MirrorAllMarkedVertical();
+ break;
+
+ case SID_OBJECT_ALIGN_LEFT:
+ case SID_ALIGN_ANY_LEFT:
+ if (pView->IsAlignPossible())
+ pView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
+ break;
+ case SID_OBJECT_ALIGN_CENTER:
+ case SID_ALIGN_ANY_HCENTER:
+ if (pView->IsAlignPossible())
+ pView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
+ break;
+ case SID_OBJECT_ALIGN_RIGHT:
+ case SID_ALIGN_ANY_RIGHT:
+ if (pView->IsAlignPossible())
+ pView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
+ break;
+ case SID_OBJECT_ALIGN_UP:
+ case SID_ALIGN_ANY_TOP:
+ if (pView->IsAlignPossible())
+ pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
+ break;
+ case SID_OBJECT_ALIGN_MIDDLE:
+ case SID_ALIGN_ANY_VCENTER:
+ if (pView->IsAlignPossible())
+ pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
+ break;
+ case SID_OBJECT_ALIGN_DOWN:
+ case SID_ALIGN_ANY_BOTTOM:
+ if (pView->IsAlignPossible())
+ pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
+ break;
+
+ case SID_DELETE:
+ case SID_DELETE_CONTENTS:
+ pView->DeleteMarked();
+ if (!pTabView->IsDrawSelMode())
+ pViewData->GetViewShell()->SetDrawShell( FALSE );
+ break;
+
+ case SID_CUT:
+ pView->DoCut();
+ if (!pTabView->IsDrawSelMode())
+ pViewData->GetViewShell()->SetDrawShell( FALSE );
+ break;
+
+ case SID_COPY:
+ pView->DoCopy();
+ break;
+
+ case SID_PASTE:
+ DBG_ERROR( "SdrView::PasteClipboard not supported anymore" );
+ // pView->PasteClipboard( pWin );
+ break;
+
+ case SID_SELECTALL:
+ pView->MarkAll();
+ break;
+
+ case SID_ANCHOR_PAGE:
+ pView->SetAnchor( SCA_PAGE );
+ rBindings.Invalidate( SID_ANCHOR_PAGE );
+ rBindings.Invalidate( SID_ANCHOR_CELL );
+ break;
+
+ case SID_ANCHOR_CELL:
+ pView->SetAnchor( SCA_CELL );
+ rBindings.Invalidate( SID_ANCHOR_PAGE );
+ rBindings.Invalidate( SID_ANCHOR_CELL );
+ break;
+
+ case SID_ANCHOR_TOGGLE:
+ {
+ switch( pView->GetAnchor() )
+ {
+ case SCA_CELL:
+ pView->SetAnchor( SCA_PAGE );
+ break;
+ default:
+ pView->SetAnchor( SCA_CELL );
+ break;
+ }
+ }
+ rBindings.Invalidate( SID_ANCHOR_PAGE );
+ rBindings.Invalidate( SID_ANCHOR_CELL );
+ break;
+
+ case SID_OBJECT_ROTATE:
+ {
+ SdrDragMode eMode;
+ if (pView->GetDragMode() == SDRDRAG_ROTATE)
+ eMode = SDRDRAG_MOVE;
+ else
+ eMode = SDRDRAG_ROTATE;
+ pView->SetDragMode( eMode );
+ rBindings.Invalidate( SID_OBJECT_ROTATE );
+ rBindings.Invalidate( SID_OBJECT_MIRROR );
+ if (eMode == SDRDRAG_ROTATE && !pView->IsFrameDragSingles())
+ {
+ pView->SetFrameDragSingles( TRUE );
+ rBindings.Invalidate( SID_BEZIER_EDIT );
+ }
+ }
+ break;
+ case SID_OBJECT_MIRROR:
+ {
+ SdrDragMode eMode;
+ if (pView->GetDragMode() == SDRDRAG_MIRROR)
+ eMode = SDRDRAG_MOVE;
+ else
+ eMode = SDRDRAG_MIRROR;
+ pView->SetDragMode( eMode );
+ rBindings.Invalidate( SID_OBJECT_ROTATE );
+ rBindings.Invalidate( SID_OBJECT_MIRROR );
+ if (eMode == SDRDRAG_MIRROR && !pView->IsFrameDragSingles())
+ {
+ pView->SetFrameDragSingles( TRUE );
+ rBindings.Invalidate( SID_BEZIER_EDIT );
+ }
+ }
+ break;
+ case SID_BEZIER_EDIT:
+ {
+ BOOL bOld = pView->IsFrameDragSingles();
+ pView->SetFrameDragSingles( !bOld );
+ rBindings.Invalidate( SID_BEZIER_EDIT );
+ if (bOld && pView->GetDragMode() != SDRDRAG_MOVE)
+ {
+ pView->SetDragMode( SDRDRAG_MOVE );
+ rBindings.Invalidate( SID_OBJECT_ROTATE );
+ rBindings.Invalidate( SID_OBJECT_MIRROR );
+ }
+ }
+ break;
+
+ case SID_FONTWORK:
+ {
+ USHORT nId = ScGetFontWorkId();
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+
+ if ( rReq.GetArgs() )
+ pViewFrm->SetChildWindow( nId,
+ ((const SfxBoolItem&)
+ (rReq.GetArgs()->Get(SID_FONTWORK))).
+ GetValue() );
+ else
+ pViewFrm->ToggleChildWindow( nId );
+
+ rBindings.Invalidate( SID_FONTWORK );
+ rReq.Done();
+ }
+ break;
+
+ case SID_ORIGINALSIZE:
+ pView->SetMarkedOriginalSize();
+ break;
+
+ case SID_ENABLE_HYPHENATION:
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, FALSE);
+ if( pItem )
+ {
+ SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ BOOL bValue = ( (const SfxBoolItem*) pItem)->GetValue();
+ aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
+ pView->SetAttributes( aSet );
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_RENAME_OBJECT:
+ {
+ if(1L == pView->GetMarkedObjectCount())
+ {
+ // #i68101#
+ SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
+ OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
+
+ if(SC_LAYER_INTERN != pSelected->GetLayer())
+ {
+ String aName(pSelected->GetName());
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl));
+
+ if(RET_OK == pDlg->Execute())
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ pDlg->GetName(aName);
+
+ if(aName != pSelected->GetName())
+ {
+ // handle name change
+ const sal_uInt16 nObjType(pSelected->GetObjIdentifier());
+
+ if(OBJ_GRAF == nObjType && 0L == aName.Len())
+ {
+ // graphics objects must have names
+ // (all graphics are supposed to be in the navigator)
+ ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
+
+ if(pModel)
+ {
+ aName = pModel->GetNewGraphicName();
+ }
+ }
+
+ // An undo action for renaming is missing in svdraw (99363).
+ // For OLE objects (which can be identified using the persist name),
+ // ScUndoRenameObject can be used until there is a common action for all objects.
+ if(OBJ_OLE2 == nObjType)
+ {
+ const String aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName();
+
+ if(aPersistName.Len())
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName));
+ }
+ }
+
+ // set new name
+ pSelected->SetName(aName);
+ }
+
+ // ChartListenerCollectionNeedsUpdate is needed for Navigator update
+ pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( TRUE );
+ pDocSh->SetDrawModified();
+ }
+
+ delete pDlg;
+ }
+ }
+ break;
+ }
+
+ // #i68101#
+ case SID_TITLE_DESCRIPTION_OBJECT:
+ {
+ if(1L == pView->GetMarkedObjectCount())
+ {
+ SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L);
+ OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)");
+
+ if(SC_LAYER_INTERN != pSelected->GetLayer())
+ {
+ String aTitle(pSelected->GetTitle());
+ String aDescription(pSelected->GetDescription());
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if(RET_OK == pDlg->Execute())
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ // handle Title and Description
+ pDlg->GetTitle(aTitle);
+ pDlg->GetDescription(aDescription);
+ pSelected->SetTitle(aTitle);
+ pSelected->SetDescription(aDescription);
+
+ // ChartListenerCollectionNeedsUpdate is needed for Navigator update
+ pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( TRUE );
+ pDocSh->SetDrawModified();
+ }
+
+ delete pDlg;
+ }
+ }
+ break;
+ }
+
+ case SID_EXTRUSION_TOOGLE:
+ case SID_EXTRUSION_TILT_DOWN:
+ case SID_EXTRUSION_TILT_UP:
+ case SID_EXTRUSION_TILT_LEFT:
+ case SID_EXTRUSION_TILT_RIGHT:
+ case SID_EXTRUSION_3D_COLOR:
+ case SID_EXTRUSION_DEPTH:
+ case SID_EXTRUSION_DIRECTION:
+ case SID_EXTRUSION_PROJECTION:
+ case SID_EXTRUSION_LIGHTING_DIRECTION:
+ case SID_EXTRUSION_LIGHTING_INTENSITY:
+ case SID_EXTRUSION_SURFACE:
+ case SID_EXTRUSION_DEPTH_FLOATER:
+ case SID_EXTRUSION_DIRECTION_FLOATER:
+ case SID_EXTRUSION_LIGHTING_FLOATER:
+ case SID_EXTRUSION_SURFACE_FLOATER:
+ case SID_EXTRUSION_DEPTH_DIALOG:
+ svx::ExtrusionBar::execute( pView, rReq, rBindings );
+ rReq.Ignore ();
+ break;
+
+ case SID_FONTWORK_SHAPE:
+ case SID_FONTWORK_SHAPE_TYPE:
+ case SID_FONTWORK_ALIGNMENT:
+ case SID_FONTWORK_SAME_LETTER_HEIGHTS:
+ case SID_FONTWORK_CHARACTER_SPACING:
+ case SID_FONTWORK_KERN_CHARACTER_PAIRS:
+ case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
+ case SID_FONTWORK_ALIGNMENT_FLOATER:
+ case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
+ svx::FontworkBar::execute( pView, rReq, rBindings );
+ rReq.Ignore ();
+ break;
+
+ default:
+ break;
+ }
+}
+
+IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
+{
+ String aName;
+
+ if( pDialog )
+ pDialog->GetName( aName );
+
+ ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer();
+ if ( aName.Len() && pModel )
+ {
+ SCTAB nDummyTab;
+ if ( pModel->GetNamedObject( aName, 0, nDummyTab ) )
+ {
+ // existing object found -> name invalid
+ return 0;
+ }
+ }
+
+ return 1; // name is valid
+}
+
+//------------------------------------------------------------------
+
+void ScDrawShell::ExecFormText(SfxRequest& rReq)
+{
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
+ {
+ const SfxItemSet& rSet = *rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if ( pDrView->IsTextEdit() )
+ pDrView->ScEndTextEdit();
+
+ if ( SFX_ITEM_SET ==
+ rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem)
+ && XFTFORM_NONE !=
+ ((const XFormTextStdFormItem*) pItem)->GetValue() )
+ {
+
+ USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)
+ (pViewFrm->
+ GetChildWindow(nId)->GetWindow());
+
+ pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
+ rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
+ ((const XFormTextStdFormItem*) pItem)->
+ GetValue());
+ }
+ else
+ pDrView->SetAttributes(rSet);
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq )
+{
+ ScViewFunc* pView = pViewData->GetView();
+ if ( pView->HasPaintBrush() )
+ {
+ // cancel paintbrush mode
+ pView->ResetBrushDocument();
+ }
+ else
+ {
+ BOOL bLock = FALSE;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 1 )
+ bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
+
+ ScDrawView* pDrawView = pViewData->GetScDrawView();
+ if ( pDrawView && pDrawView->AreObjectsMarked() )
+ {
+ BOOL bOnlyHardAttr = TRUE;
+ SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) );
+ pView->SetDrawBrushSet( pItemSet, bLock );
+ }
+ }
+}
+
+void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet )
+{
+ ScDrawView* pDrawView = pViewData->GetScDrawView();
+ BOOL bSelection = pDrawView && pDrawView->AreObjectsMarked();
+ BOOL bHasPaintBrush = pViewData->GetView()->HasPaintBrush();
+
+ if ( !bHasPaintBrush && !bSelection )
+ rSet.DisableItem( SID_FORMATPAINTBRUSH );
+ else
+ rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) );
+}
+
+ScDrawView* ScDrawShell::GetDrawView()
+{
+ return pViewData->GetView()->GetScDrawView();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drformsh.cxx b/sc/source/ui/drawfunc/drformsh.cxx
new file mode 100644
index 000000000000..f28699b73016
--- /dev/null
+++ b/sc/source/ui/drawfunc/drformsh.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <editeng/eeitem.hxx>
+#include <svx/fontwork.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/tabarea.hxx>
+#include <svx/tabline.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "drformsh.hxx"
+#include "drwlayer.hxx"
+#include "sc.hrc"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "drawview.hxx"
+#include "scresid.hxx"
+#include <svx/svdobj.hxx>
+
+#define ScDrawFormShell
+#include "scslots.hxx"
+
+
+SFX_IMPL_INTERFACE(ScDrawFormShell, ScDrawShell, ScResId(SCSTR_DRAWFORMSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ ScResId(RID_OBJECTBAR_FORMAT) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWFORM) );
+}
+
+TYPEINIT1( ScDrawFormShell, ScDrawShell );
+
+ScDrawFormShell::ScDrawFormShell(ScViewData* pData) :
+ ScDrawShell(pData)
+{
+ SetHelpId(HID_SCSHELL_DRAWFORMSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawForm")));
+}
+
+ScDrawFormShell::~ScDrawFormShell()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drformsh.src b/sc/source/ui/drawfunc/drformsh.src
new file mode 100644
index 000000000000..75100da513a2
--- /dev/null
+++ b/sc/source/ui/drawfunc/drformsh.src
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+#include "submenu.hrc"
+#include <svx/globlmn.hrc>
+ //
+ // Defines -------------------------------------------------------------------------------
+ //
+#define MN_LAYER\
+ ToolBoxItem\
+ {\
+ Identifier = SID_FRAME_TO_TOP ; \
+ HelpID = SID_FRAME_TO_TOP ; \
+ };\
+ ToolBoxItem\
+ {\
+ Identifier = SID_FRAME_TO_BOTTOM ; \
+ HelpID = SID_FRAME_TO_BOTTOM ; \
+ };
+
+#define MN_RENAME_OBJECT \
+ MenuItem\
+ {\
+ Identifier = SID_RENAME_OBJECT ; \
+ HelpId = SID_RENAME_OBJECT ; \
+ Text [ en-US ] = "Name...";\
+ };
+
+// #i68101#
+#define MN_TITLE_DESCRIPTION_OBJECT \
+ MenuItem\
+ {\
+ Identifier = SID_TITLE_DESCRIPTION_OBJECT; \
+ HelpId = SID_TITLE_DESCRIPTION_OBJECT; \
+ Text [ en-US ] = "Description...";\
+ };
+
+#define MN_ARRANGESUB \
+ MenuItem\
+ {\
+ Identifier = SUBMENU_OBJARRANGE ; \
+ HelpID = HID_SCMENU_OBJARRANGE ; \
+ Text [ en-US ] = "~Arrange" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ ITEM_FORMAT_FRAME_TO_TOP\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_FRAME_UP ; \
+ HelpId = SID_FRAME_UP ; \
+ /* ### ACHTUNG: Neuer Text in Resource? W~eiter nach vorn : Weiter nach vorn */\
+ Text [ en-US ] = "Bring ~Forward" ; \
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_FRAME_DOWN ; \
+ HelpId = SID_FRAME_DOWN ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Weiter ~nach hinten : Weiter nach hinten */\
+ Text [ en-US ] = "Send Back~ward" ; \
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_FRAME_TO_BOTTOM\
+ };\
+ MenuItem { Separator = TRUE ; }; \
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_HEAVEN\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_HELL\
+ };\
+ };\
+ };\
+ };
+
+#define MN_ANCHORSUB \
+ MenuItem\
+ {\
+ Identifier = SUBMENU_ANCHOR ; \
+ HelpID = HID_SCMENU_ANCHOR ; \
+ Text [ en-US ] = "An~chor" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ RadioCheck = TRUE ; \
+ Identifier = SID_ANCHOR_PAGE ; \
+ HelpId = SID_ANCHOR_PAGE ; \
+ Text [ en-US ] = "To P~age" ; \
+ };\
+ MenuItem\
+ {\
+ RadioCheck = TRUE ; \
+ Identifier = SID_ANCHOR_CELL ; \
+ HelpId = SID_ANCHOR_CELL ; \
+ Text [ en-US ] = "To ~Cell" ; \
+ };\
+ };\
+ };\
+ };
+
+#define MN_ALIGNSUB \
+ MenuItem\
+ {\
+ Identifier = SID_OBJECT_ALIGN ; \
+ HelpId = SID_OBJECT_ALIGN ; \
+ Text [ en-US ] = "A~lignment" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_LEFT\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_CENTER\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_RIGHT\
+ };\
+ MenuItem\
+ {\
+ Separator = TRUE ; \
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_UP\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_MIDDLE\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_DOWN\
+ };\
+ };\
+ };\
+ };
+
+
+ // Popup-Menues ---------------------------------------------------------------------
+ //
+String RID_POPUP_DRAWFORM
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Popup-Menü für Zeichenobjekte : Popup-Men³ f³r Zeichenobjekte */
+ Text [ en-US ] = "Popup menu for form objects";
+};
+ //
+ // Popup-Menue fuer (Uno-) Controls
+ //
+Menu RID_POPUP_DRAWFORM
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem { ITEM_FORM_CONTROL_PROPERTIES };
+ MenuItem { ITEM_FORM_PROPERTIES };
+ MenuItem { ITEM_REPLACE_CONTROL };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx
new file mode 100644
index 000000000000..e4d02ed69752
--- /dev/null
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -0,0 +1,1076 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//-------------------------------------------------------------------------
+
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+
+#include "scitems.hxx"
+
+#include <editeng/adjitem.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svtools/transfer.hxx>
+#include <svl/whiter.hxx>
+#include <svl/languageoptions.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "drtxtob.hxx"
+#include "fudraw.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "drawview.hxx"
+#include "viewutil.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+
+#define ScDrawTextObjectBar
+#include "scslots.hxx"
+
+
+using namespace ::com::sun::star;
+
+
+SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ ScResId(RID_TEXT_TOOLBOX) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) );
+ SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() );
+}
+
+TYPEINIT1( ScDrawTextObjectBar, SfxShell );
+
+
+
+// abschalten der nicht erwuenschten Acceleratoren:
+
+void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet )
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) :
+ SfxShell(pData->GetViewShell()),
+ pViewData(pData),
+ pClipEvtLstnr(NULL),
+ bPastePossible(FALSE)
+{
+ SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() );
+
+ // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt...
+ SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+
+ SetHelpId( HID_SCSHELL_DRTXTOB );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawText")));
+}
+
+__EXPORT ScDrawTextObjectBar::~ScDrawTextObjectBar()
+{
+ if ( pClipEvtLstnr )
+ {
+ pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), FALSE );
+
+ // #122057# The listener may just now be waiting for the SolarMutex and call the link
+ // afterwards, in spite of RemoveListener. So the link has to be reset, too.
+ pClipEvtLstnr->ClearCallbackLink();
+
+ pClipEvtLstnr->release();
+ }
+}
+
+//========================================================================
+//
+// Funktionen
+//
+//========================================================================
+
+void __EXPORT ScDrawTextObjectBar::Execute( SfxRequest &rReq )
+{
+ ScDrawView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ Outliner* pOutliner = pView->GetTextEditOutliner();
+
+ if (!pOutView || !pOutliner)
+ {
+ ExecuteGlobal( rReq ); // auf ganze Objekte
+ return;
+ }
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_COPY:
+ pOutView->Copy();
+ break;
+
+ case SID_CUT:
+ pOutView->Cut();
+ break;
+
+ case SID_PASTE:
+ pOutView->PasteSpecial();
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ ULONG nFormat = 0;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+
+ if ( nFormat )
+ {
+ if (nFormat == SOT_FORMAT_STRING)
+ pOutView->Paste();
+ else
+ pOutView->PasteSpecial();
+ }
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ ExecutePasteContents( rReq );
+ break;
+
+ case SID_SELECTALL:
+ {
+ ULONG nCount = pOutliner->GetParagraphCount();
+ ESelection aSel( 0,0,(USHORT)nCount,0 );
+ pOutView->SetSelection( aSel );
+ }
+ break;
+
+ case SID_CHARMAP:
+ {
+ const SvxFontItem& rItem = (const SvxFontItem&)
+ pOutView->GetAttribs().Get(EE_CHAR_FONTINFO);
+
+ String aString;
+ SvxFontItem aNewItem( EE_CHAR_FONTINFO );
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem);
+
+ if ( pItem )
+ {
+ aString = ((const SfxStringItem*)pItem)->GetValue();
+ const SfxPoolItem* pFtItem = NULL;
+ pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem);
+ const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
+ if ( pFontItem )
+ {
+ String aFontName(pFontItem->GetValue());
+ Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
+ aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
+ aFont.GetStyleName(), aFont.GetPitch(),
+ aFont.GetCharSet(), ATTR_FONT );
+ }
+ else
+ aNewItem = rItem;
+ }
+ else
+ ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
+
+ if ( aString.Len() )
+ {
+ SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
+ aSet.Put( aNewItem );
+ // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
+ pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() );
+ pOutView->InsertText(aString);
+ }
+
+ Invalidate( SID_ATTR_CHAR_FONT );
+ }
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
+ const String& rName = pHyper->GetName();
+ const String& rURL = pHyper->GetURL();
+ const String& rTarget = pHyper->GetTargetFrame();
+ SvxLinkInsertMode eMode = pHyper->GetInsertMode();
+
+ BOOL bDone = FALSE;
+ if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) )
+ {
+ const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField && pField->ISA(SvxURLField) )
+ {
+ // altes Feld selektieren
+
+ ESelection aSel = pOutView->GetSelection();
+ aSel.Adjust();
+ aSel.nEndPara = aSel.nStartPara;
+ aSel.nEndPos = aSel.nStartPos + 1;
+ pOutView->SetSelection( aSel );
+ }
+ }
+
+ // neues Feld einfuegen
+
+ SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
+ aURLField.SetTargetFrame( rTarget );
+ SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
+ pOutView->InsertField( aURLItem );
+
+ // select new field
+
+ ESelection aSel = pOutView->GetSelection();
+ if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
+ {
+ // Cursor is behind the inserted field -> extend selection to the left
+
+ --aSel.nStartPos;
+ pOutView->SetSelection( aSel );
+ }
+
+ bDone = TRUE;
+ }
+
+ if (!bDone)
+ ExecuteGlobal( rReq ); // normal an der View
+
+ // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!!
+ }
+ }
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ {
+ if ( pOutView )
+ {
+ const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
+ if ( pFieldItem )
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if( pField && pField->ISA( SvxURLField ) )
+ {
+ const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
+ ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_ENABLE_HYPHENATION:
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ pView->ScEndTextEdit(); // end text edit before switching direction
+ ExecuteGlobal( rReq );
+ // restore consistent state between shells and functions:
+ pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ break;
+
+ case SID_THES:
+ {
+ String aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (aReplaceText.Len() > 0)
+ ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText );
+ }
+ break;
+
+ case SID_THESAURUS:
+ {
+ pOutView->StartThesaurus();
+ }
+ break;
+
+ }
+}
+
+void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet )
+{
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ BOOL bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK);
+ BOOL bDisableFontWork = FALSE;
+
+ if (IsNoteEdit())
+ {
+ // #i21255# notes now support rich text formatting (#i74140# but not fontwork)
+ bDisableFontWork = TRUE;
+ }
+
+ if ( bDisableFontWork )
+ rSet.DisableItem( SID_FONTWORK );
+ else
+ rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork));
+
+ if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN )
+ {
+ SvxHyperlinkItem aHLinkItem;
+ SdrView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ if ( pOutView )
+ {
+ BOOL bField = FALSE;
+ const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField && pField->ISA(SvxURLField) )
+ {
+ const SvxURLField* pURLField = (const SvxURLField*) pField;
+ aHLinkItem.SetName( pURLField->GetRepresentation() );
+ aHLinkItem.SetURL( pURLField->GetURL() );
+ aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
+ bField = TRUE;
+ }
+ }
+ if (!bField)
+ {
+ // use selected text as name for urls
+ String sReturn = pOutView->GetSelected();
+ sReturn.Erase(255);
+ sReturn.EraseTrailingChars();
+ aHLinkItem.SetName(sReturn);
+ }
+ }
+ rSet.Put(aHLinkItem);
+ }
+
+ if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN )
+ {
+ SdrView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ bool bEnable = false;
+ if ( pOutView )
+ {
+ const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
+ if ( pFieldItem )
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ bEnable = pField && pField->ISA( SvxURLField );
+ }
+ }
+ if( !bEnable )
+ rSet.DisableItem( SID_OPEN_HYPERLINK );
+ }
+
+ if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH );
+ if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH );
+ if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA );
+ if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA );
+
+ if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN )
+ {
+ SdrView* pView = pViewData->GetScDrawView();
+ SfxItemSet aAttrs( pView->GetModel()->GetItemPool() );
+ pView->GetAttributes( aAttrs );
+ if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
+ {
+ BOOL bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
+ rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) );
+ }
+ }
+
+ if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN ||
+ rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN )
+ {
+ SdrView * pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+
+ String aStatusVal;
+ LanguageType nLang = LANGUAGE_NONE;
+ bool bIsLookUpWord = false;
+ if ( pOutView )
+ {
+ EditView& rEditView = pOutView->GetEditView();
+ bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
+ }
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable thesaurus main menu and context menu entry if there is nothing to look up
+ BOOL bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
+ if (!bIsLookUpWord || !bCanDoThesaurus)
+ rSet.DisableItem( SID_THES );
+ if (!bCanDoThesaurus)
+ rSet.DisableItem( SID_THESAURUS );
+ }
+}
+
+IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet )
+{
+ SdrView* pView = pViewData->GetScDrawView();
+ if ( !pView->GetTextEditOutlinerView() )
+ {
+ GetGlobalClipState( rSet );
+ return;
+ }
+
+ if ( !pClipEvtLstnr )
+ {
+ // create listener
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
+ Window* pWin = pViewData->GetActiveWin();
+ pClipEvtLstnr->AddRemoveListener( pWin, TRUE );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+ bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_PASTE:
+ case SID_PASTE_SPECIAL:
+ if( !bPastePossible )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ if ( bPastePossible )
+ {
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+
+ if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
+ if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
+
+ rSet.Put( aFormats );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//========================================================================
+//
+// Attribute
+//
+//========================================================================
+
+void __EXPORT ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq )
+{
+ // Unterstreichung
+
+ SdrView* pView = pViewData->GetScDrawView();
+
+ USHORT nSlot = rReq.GetSlot();
+
+ SfxItemSet aSet( pView->GetDefaultAttr() );
+
+ SfxItemSet aViewAttr(pView->GetModel()->GetItemPool());
+ pView->GetAttributes(aViewAttr);
+
+ // Unterstreichung
+ FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr.
+ Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ FontUnderline eNew = eOld;
+ switch (nSlot)
+ {
+ case SID_ULINE_VAL_NONE:
+ eNew = UNDERLINE_NONE;
+ break;
+ case SID_ULINE_VAL_SINGLE:
+ eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_DOUBLE:
+ eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
+ break;
+ case SID_ULINE_VAL_DOTTED:
+ eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
+ break;
+ default:
+ break;
+ }
+ aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
+
+ pView->SetAttributes( aSet );
+ rReq.Done();
+ pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
+}
+
+void lcl_RemoveFields( OutlinerView& rOutView )
+{
+ //! Outliner should have RemoveFields with a selection
+
+ Outliner* pOutliner = rOutView.GetOutliner();
+ if (!pOutliner) return;
+
+ ESelection aOldSel = rOutView.GetSelection();
+ ESelection aSel = aOldSel;
+ aSel.Adjust();
+ xub_StrLen nNewEnd = aSel.nEndPos;
+
+ BOOL bUpdate = pOutliner->GetUpdateMode();
+ BOOL bChanged = FALSE;
+
+ //! GetPortions and GetAttribs should be const!
+ EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
+
+ ULONG nParCount = pOutliner->GetParagraphCount();
+ for (ULONG nPar=0; nPar<nParCount; nPar++)
+ if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara )
+ {
+ SvUShorts aPortions;
+ rEditEng.GetPortions( (USHORT)nPar, aPortions );
+ //! GetPortions should use xub_StrLen instead of USHORT
+
+ for ( USHORT nPos = aPortions.Count(); nPos; )
+ {
+ --nPos;
+ USHORT nEnd = aPortions.GetObject( nPos );
+ USHORT nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
+ // fields are single characters
+ if ( nEnd == nStart+1 &&
+ ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) &&
+ ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) )
+ {
+ ESelection aFieldSel( (USHORT)nPar, nStart, (USHORT)nPar, nEnd );
+ SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel );
+ if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON )
+ {
+ if (!bChanged)
+ {
+ if (bUpdate)
+ pOutliner->SetUpdateMode( FALSE );
+ String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
+ pOutliner->GetUndoManager().EnterListAction( aName, aName );
+ bChanged = TRUE;
+ }
+
+ String aFieldText = rEditEng.GetText( aFieldSel );
+ pOutliner->QuickInsertText( aFieldText, aFieldSel );
+ if ( nPar == aSel.nEndPara )
+ {
+ nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() );
+ --nNewEnd;
+ }
+ }
+ }
+ }
+ }
+
+ if (bUpdate && bChanged)
+ {
+ pOutliner->GetUndoManager().LeaveListAction();
+ pOutliner->SetUpdateMode( TRUE );
+ }
+
+ if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted
+ aOldSel.nEndPos = nNewEnd;
+ else
+ aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards
+ rOutView.SetSelection( aOldSel );
+}
+
+void __EXPORT ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
+{
+ SdrView* pView = pViewData->GetScDrawView();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ BOOL bArgsInReq = ( pArgs != NULL );
+ if ( !bArgsInReq )
+ {
+ SfxItemSet aEditAttr(pView->GetModel()->GetItemPool());
+ pView->GetAttributes(aEditAttr);
+ SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() );
+ BOOL bDone = TRUE;
+
+ switch ( nSlot )
+ {
+ case SID_TEXT_STANDARD: // Harte Textattributierung loeschen
+ {
+ OutlinerView* pOutView = pView->IsTextEdit() ?
+ pView->GetTextEditOutlinerView() : NULL;
+ if ( pOutView )
+ pOutView->Paint( Rectangle() );
+
+ SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END );
+ pView->SetAttributes( aEmptyAttr, TRUE );
+
+ if ( pOutView )
+ {
+ lcl_RemoveFields( *pOutView );
+ pOutView->ShowCursor();
+ }
+
+ rReq.Done( aEmptyAttr );
+ pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
+ bDone = FALSE; // bereits hier passiert
+ }
+ break;
+
+ case SID_CHAR_DLG: // Dialog-Button
+ case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ bDone = ExecuteCharDlg( aEditAttr, aNewAttr );
+ break;
+
+ case SID_PARA_DLG:
+ bDone = ExecuteParaDlg( aEditAttr, aNewAttr );
+ break;
+
+ case SID_ATTR_CHAR_WEIGHT:
+ aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) );
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) );
+ break;
+
+ case SID_ATTR_CHAR_UNDERLINE:
+ aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) );
+ break;
+
+ case SID_ATTR_CHAR_OVERLINE:
+ aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) );
+ break;
+
+ case SID_ATTR_CHAR_CONTOUR:
+ aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) );
+ break;
+
+ case SID_ATTR_CHAR_SHADOWED:
+ aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) );
+ break;
+
+ case SID_ATTR_CHAR_STRIKEOUT:
+ aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) );
+ break;
+
+ case SID_ALIGNLEFT:
+ case SID_ALIGN_ANY_LEFT:
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ break;
+
+ case SID_ALIGNCENTERHOR:
+ case SID_ALIGN_ANY_HCENTER:
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
+ break;
+
+ case SID_ALIGNRIGHT:
+ case SID_ALIGN_ANY_RIGHT:
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ break;
+
+ case SID_ALIGNBLOCK:
+ case SID_ALIGN_ANY_JUSTIFIED:
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
+ break;
+
+ case SID_ATTR_PARA_LINESPACE_10:
+ {
+ SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 100 );
+ aNewAttr.Put( aItem );
+ }
+ break;
+
+ case SID_ATTR_PARA_LINESPACE_15:
+ {
+ SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 150 );
+ aNewAttr.Put( aItem );
+ }
+ break;
+
+ case SID_ATTR_PARA_LINESPACE_20:
+ {
+ SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 200 );
+ aNewAttr.Put( aItem );
+ }
+ break;
+
+ case SID_SET_SUPER_SCRIPT:
+ {
+ SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
+ SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
+ aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
+
+ if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
+ aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
+ else
+ aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
+ aNewAttr.Put( aItem );
+ }
+ break;
+ case SID_SET_SUB_SCRIPT:
+ {
+ SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT);
+ SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
+ aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
+
+ if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
+ aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
+ else
+ aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
+ aNewAttr.Put( aItem );
+ }
+ break;
+
+ case SID_DRAWTEXT_ATTR_DLG:
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView );
+
+ bDone = ( RET_OK == pDlg->Execute() );
+
+ if ( bDone )
+ aNewAttr.Put( *pDlg->GetOutputItemSet() );
+
+ delete pDlg;
+ }
+ break;
+ }
+
+ if ( bDone ) // wurden Attribute geaendert?
+ {
+ rReq.Done( aNewAttr );
+ pArgs = rReq.GetArgs();
+ }
+ }
+
+ if ( pArgs )
+ {
+ if ( bArgsInReq &&
+ ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
+ nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) )
+ {
+ // font items from toolbox controller have to be applied for the right script type
+
+ // #i78017 establish the same behaviour as in Writer
+ USHORT nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ nScript = pView->GetScriptType();
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ USHORT nWhich = rPool.GetWhich( nSlot );
+ aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
+
+ pView->SetAttributes( aSetItem.GetItemSet() );
+ }
+ else
+ {
+ // use args directly
+
+ pView->SetAttributes( *pArgs );
+ }
+ pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
+ }
+}
+
+void __EXPORT ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet )
+{
+ if ( IsNoteEdit() )
+ {
+ // issue 21255 - Notes now support rich text formatting.
+ }
+
+ SvtLanguageOptions aLangOpt;
+ BOOL bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
+ BOOL bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
+
+ SdrView* pView = pViewData->GetScDrawView();
+ SfxItemSet aAttrSet(pView->GetModel()->GetItemPool());
+ pView->GetAttributes(aAttrSet);
+
+ // direkte Attribute
+
+ rDestSet.Put( aAttrSet );
+
+ // choose font info according to selection script type
+
+ USHORT nScript = pView->GetScriptType();
+
+ // #i55929# input-language-dependent script type (depends on input language if nothing selected)
+ USHORT nInputScript = nScript;
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ if (pOutView && !pOutView->GetSelection().HasRange())
+ {
+ LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
+ if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ }
+
+ // #i55929# according to spec, nInputScript is used for font and font height only
+ if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript );
+ if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript );
+ if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript );
+ if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript );
+
+ // Ausrichtung
+
+ SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust();
+ switch( eAdj )
+ {
+ case SVX_ADJUST_LEFT:
+ rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, TRUE ) );
+ break;
+ case SVX_ADJUST_CENTER:
+ rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, TRUE ) );
+ break;
+ case SVX_ADJUST_RIGHT:
+ rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, TRUE ) );
+ break;
+ case SVX_ADJUST_BLOCK:
+ rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, TRUE ) );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ // pseudo slots for Format menu
+ rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) );
+ rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) );
+ rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) );
+ rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) );
+
+ // Zeilenabstand
+
+ USHORT nLineSpace = (USHORT)
+ ((const SvxLineSpacingItem&)aAttrSet.
+ Get( EE_PARA_SBL )).GetPropLineSpace();
+ switch( nLineSpace )
+ {
+ case 100:
+ rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, TRUE ) );
+ break;
+ case 150:
+ rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, TRUE ) );
+ break;
+ case 200:
+ rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, TRUE ) );
+ break;
+ }
+
+ // hoch-/tiefgestellt
+
+ SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&)
+ aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
+ if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
+ rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, TRUE ) );
+ else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
+ rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, TRUE ) );
+
+ // Unterstreichung
+
+ SfxItemState eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, TRUE );
+ if ( eState == SFX_ITEM_DONTCARE )
+ {
+ rDestSet.InvalidateItem( SID_ULINE_VAL_NONE );
+ rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
+ rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
+ rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
+ }
+ else
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ USHORT nId = SID_ULINE_VAL_NONE;
+ switch (eUnderline)
+ {
+ case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
+ case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
+ case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
+ default:
+ break;
+ }
+ rDestSet.Put( SfxBoolItem( nId, TRUE ) );
+ }
+
+ // horizontal / vertical
+
+ BOOL bLeftToRight = TRUE;
+
+ SdrOutliner* pOutl = pView->GetTextEditOutliner();
+ if( pOutl )
+ {
+ if( pOutl->IsVertical() )
+ bLeftToRight = FALSE;
+ }
+ else
+ bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
+
+ if ( bDisableVerticalText )
+ {
+ rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ }
+ else
+ {
+ rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
+ rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
+ }
+
+ // left-to-right or right-to-left
+
+ if ( !bLeftToRight || bDisableCTLFont )
+ {
+ // disabled if vertical
+ rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE )
+ {
+ rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ else
+ {
+ SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
+ aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue();
+ if ( eAttrDir == FRMDIR_ENVIRONMENT )
+ {
+ // get "environment" direction from page style
+ if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L )
+ eAttrDir = FRMDIR_HORI_RIGHT_TOP;
+ else
+ eAttrDir = FRMDIR_HORI_LEFT_TOP;
+ }
+ rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) );
+ rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) );
+ }
+}
+
+void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq )
+{
+ sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
+ if ( nType )
+ {
+ ScDrawView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ if ( pOutView )
+ {
+ // change selected text in object
+ pOutView->TransliterateText( nType );
+ }
+ else
+ {
+ //! apply to whole objects?
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drtxtob1.cxx b/sc/source/ui/drawfunc/drtxtob1.cxx
new file mode 100644
index 000000000000..f018c7885213
--- /dev/null
+++ b/sc/source/ui/drawfunc/drtxtob1.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <editeng/brkitem.hxx>
+#include <editeng/hyznitem.hxx>
+#include <editeng/orphitem.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/spltitem.hxx>
+#include <editeng/widwitem.hxx>
+#include <sot/exchange.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/transfer.hxx>
+
+#include "sc.hrc"
+#include "drtxtob.hxx"
+#include "drawview.hxx"
+#include "viewdata.hxx"
+#include "scresid.hxx"
+
+#include "scabstdlg.hxx"
+//------------------------------------------------------------------------
+
+BOOL ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& rArgs,
+ SfxItemSet& rOutSet )
+{
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &rArgs,
+ pViewData->GetSfxDocShell(),RID_SCDLG_CHAR );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ BOOL bRet = ( pDlg->Execute() == RET_OK );
+
+ if ( bRet )
+ {
+ const SfxItemSet* pNewAttrs = pDlg->GetOutputItemSet();
+ if ( pNewAttrs )
+ rOutSet.Put( *pNewAttrs );
+ }
+ delete pDlg;
+
+ return bRet;
+}
+
+BOOL ScDrawTextObjectBar::ExecuteParaDlg( const SfxItemSet& rArgs,
+ SfxItemSet& rOutSet )
+{
+ SfxItemPool* pArgPool = rArgs.GetPool();
+ SfxItemSet aNewAttr( *pArgPool,
+ EE_ITEMS_START, EE_ITEMS_END,
+ SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE,
+ SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_PAGEBREAK,
+ SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT,
+ SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS,
+ SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS,
+ 0 );
+ aNewAttr.Put( rArgs );
+
+ // Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen.
+ // Muss natuerlich noch geaendert werden
+ // aNewAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) );
+
+ aNewAttr.Put( SvxHyphenZoneItem( sal_False, SID_ATTR_PARA_HYPHENZONE ) );
+ aNewAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, SID_ATTR_PARA_PAGEBREAK ) );
+ aNewAttr.Put( SvxFmtSplitItem( sal_True, SID_ATTR_PARA_SPLIT) );
+ aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) );
+ aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScParagraphDlg( pViewData->GetDialogParent(), &aNewAttr, RID_SCDLG_PARAGRAPH);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ BOOL bRet = ( pDlg->Execute() == RET_OK );
+
+ if ( bRet )
+ {
+ const SfxItemSet* pNewAttrs = pDlg->GetOutputItemSet();
+ if ( pNewAttrs )
+ rOutSet.Put( *pNewAttrs );
+ }
+ delete pDlg;
+
+ return bRet;
+}
+
+void ScDrawTextObjectBar::ExecutePasteContents( SfxRequest & /* rReq */ )
+{
+ SdrView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
+
+ pDlg->Insert( SOT_FORMAT_STRING, EMPTY_STRING );
+ pDlg->Insert( SOT_FORMAT_RTF, EMPTY_STRING );
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+
+ ULONG nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
+
+ //! test if outliner view is still valid
+
+ if (nFormat > 0)
+ {
+ if (nFormat == SOT_FORMAT_STRING)
+ pOutView->Paste();
+ else
+ pOutView->PasteSpecial();
+ }
+ delete pDlg;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/drtxtob2.cxx b/sc/source/ui/drawfunc/drtxtob2.cxx
new file mode 100644
index 000000000000..2934b4f779cd
--- /dev/null
+++ b/sc/source/ui/drawfunc/drtxtob2.cxx
@@ -0,0 +1,301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include <editeng/adjitem.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/fontwork.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/xtextit.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sot/formats.hxx>
+#include <svl/whiter.hxx>
+
+#include "sc.hrc"
+#include "drtxtob.hxx"
+#include "viewdata.hxx"
+#include "drawview.hxx"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "docsh.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "drwlayer.hxx"
+
+//------------------------------------------------------------------------
+
+USHORT ScGetFontWorkId()
+{
+ return SvxFontWorkChildWindow::GetChildWindowId();
+}
+
+BOOL ScDrawTextObjectBar::IsNoteEdit()
+{
+ return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() );
+}
+
+// wenn kein Text editiert wird, Funktionen wie in drawsh
+
+void __EXPORT ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq )
+{
+ ScTabView* pTabView = pViewData->GetView();
+ ScDrawView* pView = pTabView->GetScDrawView();
+
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_COPY:
+ pView->DoCopy();
+ break;
+
+ case SID_CUT:
+ pView->DoCut();
+ if (!pTabView->IsDrawSelMode())
+ pViewData->GetViewShell()->SetDrawShell( FALSE );
+ break;
+
+ case SID_PASTE:
+ case SID_PASTE_SPECIAL:
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ case SID_HYPERLINK_SETLINK:
+ {
+ // cell methods are at cell shell, which is not available if
+ // ScDrawTextObjectBar is active
+ //! move paste etc. to view shell?
+ }
+ break;
+
+ case SID_SELECTALL:
+ pView->MarkAll();
+ break;
+
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ {
+ SfxItemSet aAttr( pView->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 );
+ aAttr.Put( SvxWritingModeItem(
+ nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
+ com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL,
+ SDRATTR_TEXTDIRECTION ) );
+ pView->SetAttributes( aAttr );
+ pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled
+ rReq.Done( aAttr );
+ }
+ break;
+
+ case SID_ENABLE_HYPHENATION:
+ {
+ SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, FALSE);
+ if( pItem )
+ {
+ SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ BOOL bValue = ( (const SfxBoolItem*) pItem)->GetValue();
+ aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
+ pView->SetAttributes( aSet );
+ }
+ rReq.Done();
+ }
+ break;
+ }
+}
+
+void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet )
+{
+ // cell methods are at cell shell, which is not available if
+ // ScDrawTextObjectBar is active -> disable everything
+ //! move paste etc. to view shell?
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void __EXPORT ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq )
+{
+ ScTabView* pTabView = pViewData->GetView();
+ ScDrawView* pView = pTabView->GetScDrawView();
+
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_FONTWORK:
+ {
+ USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+
+ if ( rReq.GetArgs() )
+ pViewFrm->SetChildWindow( nId,
+ ((const SfxBoolItem&)
+ (rReq.GetArgs()->Get(SID_FONTWORK))).
+ GetValue() );
+ else
+ pViewFrm->ToggleChildWindow( nId );
+
+ pViewFrm->GetBindings().Invalidate( SID_FONTWORK );
+ rReq.Done();
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ SfxItemSet aAttr( pView->GetModel()->GetItemPool(),
+ EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR,
+ EE_PARA_JUST, EE_PARA_JUST,
+ 0 );
+ BOOL bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT );
+ aAttr.Put( SvxFrameDirectionItem(
+ bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP,
+ EE_PARA_WRITINGDIR ) );
+ aAttr.Put( SvxAdjustItem(
+ bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT,
+ EE_PARA_JUST ) );
+ pView->SetAttributes( aAttr );
+ pViewData->GetScDrawView()->InvalidateDrawTextAttrs();
+ rReq.Done(); //! Done(aAttr) ?
+
+ }
+ break;
+ }
+}
+
+void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq)
+{
+ ScTabView* pTabView = pViewData->GetView();
+ ScDrawView* pDrView = pTabView->GetScDrawView();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() )
+ {
+ const SfxItemSet& rSet = *rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if ( pDrView->IsTextEdit() )
+ pDrView->ScEndTextEdit();
+
+ if ( SFX_ITEM_SET ==
+ rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem)
+ && XFTFORM_NONE !=
+ ((const XFormTextStdFormItem*) pItem)->GetValue() )
+ {
+
+ USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)
+ (pViewFrm->
+ GetChildWindow(nId)->GetWindow());
+
+ pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(),
+ rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
+ ((const XFormTextStdFormItem*) pItem)->
+ GetValue());
+ }
+ else
+ pDrView->SetAttributes(rSet);
+ }
+}
+
+void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet)
+{
+ const SdrObject* pObj = NULL;
+ SvxFontWorkDialog* pDlg = NULL;
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ USHORT nId = SvxFontWorkChildWindow::GetChildWindowId();
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ if ( pViewFrm->HasChildWindow(nId) )
+ pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow());
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
+ !((SdrTextObj*) pObj)->HasText() )
+ {
+ if ( pDlg )
+ pDlg->SetActive(FALSE);
+
+ rSet.DisableItem(XATTR_FORMTXTSTYLE);
+ rSet.DisableItem(XATTR_FORMTXTADJUST);
+ rSet.DisableItem(XATTR_FORMTXTDISTANCE);
+ rSet.DisableItem(XATTR_FORMTXTSTART);
+ rSet.DisableItem(XATTR_FORMTXTMIRROR);
+ rSet.DisableItem(XATTR_FORMTXTSTDFORM);
+ rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
+ rSet.DisableItem(XATTR_FORMTXTOUTLINE);
+ rSet.DisableItem(XATTR_FORMTXTSHADOW);
+ rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
+ rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
+ rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
+ }
+ else
+ {
+ if ( pDlg )
+ {
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+
+ if ( pDocSh )
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+ XColorTable* pColorTable = NULL;
+
+ if ( pItem )
+ pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
+
+ pDlg->SetActive();
+
+ if ( pColorTable )
+ pDlg->SetColorTable( pColorTable );
+ else
+ { DBG_ERROR( "ColorList not found :-/" ); }
+ }
+ }
+ SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool());
+ pDrView->GetAttributes(aViewAttr);
+ rSet.Set(aViewAttr);
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuconarc.cxx b/sc/source/ui/drawfunc/fuconarc.cxx
new file mode 100644
index 000000000000..5cdbd551bbdf
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuconarc.cxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "fuconarc.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "drawview.hxx"
+
+// #98185# Create default drawing objects via keyboard
+#include <svx/svdocirc.hxx>
+#include <svx/sxciaitm.hxx>
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuConstArc::FuConstArc( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq )
+ : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq )
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuConstArc::~FuConstArc()
+{
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstArc::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuConstruct::MouseButtonDown( rMEvt );
+
+ if ( rMEvt.IsLeft() && !pView->IsAction() )
+ {
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pWindow->CaptureMouse();
+ pView->BegCreateObj( aPnt );
+ bReturn = TRUE;
+ }
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstArc::MouseMove( const MouseEvent& rMEvt )
+{
+ return FuConstruct::MouseMove(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstArc::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FALSE;
+
+ if ( pView->IsCreateObj() && rMEvt.IsLeft() )
+ {
+ // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->EndCreateObj( SDRCREATE_NEXTPOINT );
+ bReturn = TRUE;
+ }
+/*
+ else if ( pView->IsCreateObj() && rMEvt.IsRight() )
+ {
+ // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->EndCreateObj( SDRCREATE_FORCEEND );
+ bReturn = TRUE;
+ }
+*/
+ return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstArc::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FuConstruct::KeyInput(rKEvt);
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuConstArc::Activate()
+{
+ SdrObjKind aObjKind;
+
+ switch (aSfxRequest.GetSlot() )
+ {
+ case SID_DRAW_ARC:
+ aNewPointer = Pointer( POINTER_DRAW_ARC );
+ aObjKind = OBJ_CARC;
+ break;
+
+ case SID_DRAW_PIE:
+ aNewPointer = Pointer( POINTER_DRAW_PIE );
+ aObjKind = OBJ_SECT;
+ break;
+
+ case SID_DRAW_CIRCLECUT:
+ aNewPointer = Pointer( POINTER_DRAW_CIRCLECUT );
+ aObjKind = OBJ_CCUT;
+ break;
+
+ default:
+ aNewPointer = Pointer( POINTER_CROSS );
+ aObjKind = OBJ_CARC;
+ break;
+ }
+
+ pView->SetCurrentObj( sal::static_int_cast<UINT16>( aObjKind ) );
+
+ aOldPointer = pWindow->GetPointer();
+ pViewShell->SetActivePointer( aNewPointer );
+
+ FuDraw::Activate();
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuConstArc::Deactivate()
+{
+ FuDraw::Deactivate();
+ pViewShell->SetActivePointer( aOldPointer );
+}
+
+// #98185# Create default drawing objects via keyboard
+SdrObject* FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
+{
+ // case SID_DRAW_ARC:
+ // case SID_DRAW_PIE:
+ // case SID_DRAW_CIRCLECUT:
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
+ 0L, pDrDoc);
+
+ if(pObj)
+ {
+ if(pObj->ISA(SdrCircObj))
+ {
+ Rectangle aRect(rRectangle);
+
+ if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID)
+ {
+ // force quadratic
+ ImpForceQuadratic(aRect);
+ }
+
+ pObj->SetLogicRect(aRect);
+
+ SfxItemSet aAttr(pDrDoc->GetItemPool());
+ aAttr.Put(SdrCircStartAngleItem(9000));
+ aAttr.Put(SdrCircEndAngleItem(0));
+
+ pObj->SetMergedItemSet(aAttr);
+ }
+ else
+ {
+ DBG_ERROR("Object is NO circle object");
+ }
+ }
+
+ return pObj;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuconcustomshape.cxx b/sc/source/ui/drawfunc/fuconcustomshape.cxx
new file mode 100644
index 000000000000..98d0f0266c97
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuconcustomshape.cxx
@@ -0,0 +1,291 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "fuconcustomshape.hxx"
+#include <editeng/svxenum.hxx>
+#include <svx/gallery.hxx>
+#include <sfx2/request.hxx>
+#include <svx/fmmodel.hxx>
+#include <svl/itempool.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdoashp.hxx>
+#include <editeng/eeitem.hxx>
+#include <svx/sdtagitm.hxx>
+#include "fuconuno.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "drawview.hxx"
+#include <editeng/adjitem.hxx>
+
+#include <math.h>
+
+//------------------------------------------------------------------------
+
+FuConstCustomShape::FuConstCustomShape( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, SdrModel* pDoc, SfxRequest& rReq )
+ : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq )
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() );
+ aCustomShape = rItm.GetValue();
+ }
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuConstCustomShape::~FuConstCustomShape()
+{
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt);
+ if ( rMEvt.IsLeft() && !pView->IsAction() )
+ {
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pWindow->CaptureMouse();
+ pView->BegCreateObj(aPnt);
+
+ SdrObject* pObj = pView->GetCreateObj();
+ if ( pObj )
+ {
+ SetAttributes( pObj );
+ sal_Bool bForceFillStyle = sal_True;
+ sal_Bool bForceNoFillStyle = sal_False;
+ if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() )
+ {
+ bForceFillStyle = sal_False;
+ bForceNoFillStyle = sal_True;
+ }
+ if ( bForceNoFillStyle )
+ pObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) );
+ }
+
+ bReturn = TRUE;
+ }
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstCustomShape::MouseMove(const MouseEvent& rMEvt)
+{
+ return FuConstruct::MouseMove(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FALSE;
+
+ if ( pView->IsCreateObj() && rMEvt.IsLeft() )
+ {
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->EndCreateObj(SDRCREATE_FORCEEND);
+ bReturn = TRUE;
+ }
+ return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstCustomShape::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FuConstruct::KeyInput(rKEvt);
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuConstCustomShape::Activate()
+{
+ pView->SetCurrentObj( OBJ_CUSTOMSHAPE, SdrInventor );
+
+ aNewPointer = Pointer( POINTER_DRAW_RECT );
+ aOldPointer = pWindow->GetPointer();
+ pViewShell->SetActivePointer( aNewPointer );
+
+ SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS);
+ if (pLayer)
+ pView->SetActiveLayer( pLayer->GetName() );
+
+ FuConstruct::Activate();
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuConstCustomShape::Deactivate()
+{
+ FuConstruct::Deactivate();
+
+ SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT);
+ if (pLayer)
+ pView->SetActiveLayer( pLayer->GetName() );
+
+ pViewShell->SetActivePointer( aOldPointer );
+}
+
+// #98185# Create default drawing objects via keyboard
+SdrObject* FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle)
+{
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
+ 0L, pDrDoc);
+ if( pObj )
+ {
+ Rectangle aRectangle( rRectangle );
+ SetAttributes( pObj );
+ if ( SdrObjCustomShape::doConstructOrthogonal( aCustomShape ) )
+ ImpForceQuadratic( aRectangle );
+ pObj->SetLogicRect( aRectangle );
+ }
+ return pObj;
+}
+
+/*************************************************************************
+|*
+|* applying attributes
+|*
+\************************************************************************/
+
+void FuConstCustomShape::SetAttributes( SdrObject* pObj )
+{
+ sal_Bool bAttributesAppliedFromGallery = sal_False;
+
+ if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) )
+ {
+ std::vector< rtl::OUString > aObjList;
+ if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) )
+ {
+ sal_uInt16 i;
+ for ( i = 0; i < aObjList.size(); i++ )
+ {
+ if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) )
+ {
+ FmFormModel aFormModel;
+ SfxItemPool& rPool = aFormModel.GetItemPool();
+ rPool.FreezeIdRanges();
+ if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) )
+ {
+ const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 );
+ if( pSourceObj )
+ {
+ const SfxItemSet& rSource = pSourceObj->GetMergedItemSet();
+ SfxItemSet aDest( pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj
+ SDRATTR_START, SDRATTR_SHADOW_LAST,
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST,
+ SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION,
+ // Graphic Attributes
+ SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST,
+ // 3d Properties
+ SDRATTR_3D_FIRST, SDRATTR_3D_LAST,
+ // CustomShape properties
+ SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST,
+ // range from SdrTextObj
+ EE_ITEMS_START, EE_ITEMS_END,
+ // end
+ 0, 0);
+ aDest.Set( rSource );
+ pObj->SetMergedItemSet( aDest );
+ sal_Int32 nAngle = pSourceObj->GetRotateAngle();
+ if ( nAngle )
+ {
+ double a = nAngle * F_PI18000;
+ pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) );
+ }
+ bAttributesAppliedFromGallery = sal_True;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ if ( !bAttributesAppliedFromGallery )
+ {
+ pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, 0 ) );
+ pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) );
+ pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
+ pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) );
+ ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape );
+ }
+}
+
+// #i33136#
+bool FuConstCustomShape::doConstructOrthogonal() const
+{
+ return SdrObjCustomShape::doConstructOrthogonal(aCustomShape);
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuconpol.cxx b/sc/source/ui/drawfunc/fuconpol.cxx
new file mode 100644
index 000000000000..321e34770aa6
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuconpol.cxx
@@ -0,0 +1,358 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "fuconpol.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "drawview.hxx"
+
+// #98185# Create default drawing objects via keyboard
+#include <svx/svdopath.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+
+// Pixelabstand zum Schliessen von Freihand-Zeichnungen
+#ifndef CLOSE_PIXDIST
+#define CLOSE_PIXDIST 5
+#endif
+
+//------------------------------------------------------------------------
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuConstPolygon::FuConstPolygon(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq)
+ : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuConstPolygon::~FuConstPolygon()
+{
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstPolygon::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt);
+
+ SdrViewEvent aVEvt;
+ (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+ if (aVEvt.eEvent == SDREVENT_BEGTEXTEDIT)
+ {
+ // Texteingabe hier nicht zulassen
+ aVEvt.eEvent = SDREVENT_BEGDRAGOBJ;
+ pView->EnableExtendedMouseEventDispatcher(FALSE);
+ }
+ else
+ {
+ pView->EnableExtendedMouseEventDispatcher(TRUE);
+ }
+
+ if ( pView->MouseButtonDown(rMEvt, pWindow) )
+ bReturn = TRUE;
+
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstPolygon::MouseMove(const MouseEvent& rMEvt)
+{
+ pView->MouseMove(rMEvt, pWindow);
+ BOOL bReturn = FuConstruct::MouseMove(rMEvt);
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstPolygon::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FALSE;
+ BOOL bSimple = FALSE;
+
+ SdrViewEvent aVEvt;
+ (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt);
+
+ pView->MouseButtonUp(rMEvt, pWindow);
+
+ if (aVEvt.eEvent == SDREVENT_ENDCREATE)
+ {
+ bReturn = TRUE;
+ bSimple = TRUE; // Doppelklick nicht weiterreichen
+ }
+
+ BOOL bParent;
+ if (bSimple)
+ bParent = FuConstruct::SimpleMouseButtonUp(rMEvt);
+ else
+ bParent = FuConstruct::MouseButtonUp(rMEvt);
+
+ return (bParent || bReturn);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstPolygon::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FuConstruct::KeyInput(rKEvt);
+
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuConstPolygon::Activate()
+{
+ pView->EnableExtendedMouseEventDispatcher(TRUE);
+
+ SdrObjKind eKind;
+
+ switch (GetSlotID())
+ {
+ case SID_DRAW_POLYGON_NOFILL:
+ case SID_DRAW_XPOLYGON_NOFILL:
+ {
+ eKind = OBJ_PLIN;
+ }
+ break;
+
+ case SID_DRAW_POLYGON:
+ case SID_DRAW_XPOLYGON:
+ {
+ eKind = OBJ_POLY;
+ }
+ break;
+
+ case SID_DRAW_BEZIER_NOFILL:
+ {
+ eKind = OBJ_PATHLINE;
+ }
+ break;
+
+ case SID_DRAW_BEZIER_FILL:
+ {
+ eKind = OBJ_PATHFILL;
+ }
+ break;
+
+ case SID_DRAW_FREELINE_NOFILL:
+ {
+ eKind = OBJ_FREELINE;
+ }
+ break;
+
+ case SID_DRAW_FREELINE:
+ {
+ eKind = OBJ_FREEFILL;
+ }
+ break;
+
+ default:
+ {
+ eKind = OBJ_PATHLINE;
+ }
+ break;
+ }
+
+ pView->SetCurrentObj(sal::static_int_cast<UINT16>(eKind));
+
+ pView->SetEditMode(SDREDITMODE_CREATE);
+
+ FuConstruct::Activate();
+
+ aNewPointer = Pointer( POINTER_DRAW_POLYGON );
+ aOldPointer = pWindow->GetPointer();
+ pViewShell->SetActivePointer( aNewPointer );
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuConstPolygon::Deactivate()
+{
+ pView->SetEditMode(SDREDITMODE_EDIT);
+
+ pView->EnableExtendedMouseEventDispatcher(FALSE);
+
+ FuConstruct::Deactivate();
+
+ pViewShell->SetActivePointer( aOldPointer );
+}
+
+// #98185# Create default drawing objects via keyboard
+SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
+{
+ // case SID_DRAW_POLYGON:
+ // case SID_DRAW_POLYGON_NOFILL:
+ // case SID_DRAW_BEZIER_NOFILL:
+ // case SID_DRAW_FREELINE_NOFILL:
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
+ 0L, pDrDoc);
+
+ if(pObj)
+ {
+ if(pObj->ISA(SdrPathObj))
+ {
+ basegfx::B2DPolyPolygon aPoly;
+
+ switch(nID)
+ {
+ case SID_DRAW_BEZIER_NOFILL:
+ {
+ basegfx::B2DPolygon aInnerPoly;
+
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
+
+ const basegfx::B2DPoint aCenterBottom(rRectangle.Center().X(), rRectangle.Bottom());
+ aInnerPoly.appendBezierSegment(
+ aCenterBottom,
+ aCenterBottom,
+ basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
+
+ const basegfx::B2DPoint aCenterTop(rRectangle.Center().X(), rRectangle.Top());
+ aInnerPoly.appendBezierSegment(
+ aCenterTop,
+ aCenterTop,
+ basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
+
+ aPoly.append(aInnerPoly);
+ break;
+ }
+ case SID_DRAW_FREELINE_NOFILL:
+ {
+ basegfx::B2DPolygon aInnerPoly;
+
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
+
+ aInnerPoly.appendBezierSegment(
+ basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()),
+ basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Top()),
+ basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y()));
+
+ aInnerPoly.appendBezierSegment(
+ basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()),
+ basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()),
+ basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top()));
+
+ aPoly.append(aInnerPoly);
+ break;
+ }
+ case SID_DRAW_POLYGON:
+ case SID_DRAW_POLYGON_NOFILL:
+ {
+ basegfx::B2DPolygon aInnerPoly;
+ const sal_Int32 nWdt(rRectangle.GetWidth());
+ const sal_Int32 nHgt(rRectangle.GetHeight());
+
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom()));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 30) / 100, rRectangle.Top() + (nHgt * 70) / 100));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top() + (nHgt * 15) / 100));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 65) / 100, rRectangle.Top()));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + nWdt, rRectangle.Top() + (nHgt * 30) / 100));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 50) / 100));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 75) / 100));
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Bottom(), rRectangle.Right()));
+
+ if(SID_DRAW_POLYGON_NOFILL == nID)
+ {
+ aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()));
+ }
+ else
+ {
+ aInnerPoly.setClosed(true);
+ }
+
+ aPoly.append(aInnerPoly);
+ break;
+ }
+ }
+
+ ((SdrPathObj*)pObj)->SetPathPoly(aPoly);
+ }
+ else
+ {
+ DBG_ERROR("Object is NO path object");
+ }
+
+ pObj->SetLogicRect(rRectangle);
+ }
+
+ return pObj;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuconrec.cxx b/sc/source/ui/drawfunc/fuconrec.cxx
new file mode 100644
index 000000000000..e736c2fe09af
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuconrec.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "fuconrec.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "drawview.hxx"
+
+#include <editeng/outlobj.hxx>
+// #98185# Create default drawing objects via keyboard
+#include <svx/svdopath.hxx>
+#include <svx/svdocapt.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/point/b2dpoint.hxx>
+
+#include "scresid.hxx"
+
+//------------------------------------------------------------------------
+
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuConstRectangle::FuConstRectangle(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq)
+ : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuConstRectangle::~FuConstRectangle()
+{
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstRectangle::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt);
+
+ if ( rMEvt.IsLeft() && !pView->IsAction() )
+ {
+ Point aPos( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ pWindow->CaptureMouse();
+
+ if ( pView->GetCurrentObjIdentifier() == OBJ_CAPTION )
+ {
+ Size aCaptionSize ( 2268, 1134 ); // 4x2cm
+
+ bReturn = pView->BegCreateCaptionObj( aPos, aCaptionSize );
+
+ // wie stellt man den Font ein, mit dem geschrieben wird
+ }
+ else
+ bReturn = pView->BegCreateObj(aPos);
+ }
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstRectangle::MouseMove(const MouseEvent& rMEvt)
+{
+ return FuConstruct::MouseMove(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstRectangle::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FALSE;
+
+ if ( pView->IsCreateObj() && rMEvt.IsLeft() )
+ {
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->EndCreateObj(SDRCREATE_FORCEEND);
+
+ if (aSfxRequest.GetSlot() == SID_DRAW_CAPTION_VERTICAL)
+ {
+ // set vertical flag for caption object
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMark(0))
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ // create OutlinerParaObject now so it can be set to vertical
+ if ( pObj->ISA(SdrTextObj) )
+ ((SdrTextObj*)pObj)->ForceOutlinerParaObject();
+ OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
+ if( pOPO && !pOPO->IsVertical() )
+ pOPO->SetVertical( TRUE );
+ }
+ }
+
+ bReturn = TRUE;
+ }
+ return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstRectangle::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FuConstruct::KeyInput(rKEvt);
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuConstRectangle::Activate()
+{
+ SdrObjKind aObjKind;
+
+ switch (aSfxRequest.GetSlot() )
+ {
+ case SID_DRAW_LINE:
+ aNewPointer = Pointer( POINTER_DRAW_LINE );
+ aObjKind = OBJ_LINE;
+ break;
+
+ case SID_DRAW_RECT:
+ aNewPointer = Pointer( POINTER_DRAW_RECT );
+ aObjKind = OBJ_RECT;
+ break;
+
+ case SID_DRAW_ELLIPSE:
+ aNewPointer = Pointer( POINTER_DRAW_ELLIPSE );
+ aObjKind = OBJ_CIRC;
+ break;
+
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ aNewPointer = Pointer( POINTER_DRAW_CAPTION );
+ aObjKind = OBJ_CAPTION;
+ break;
+
+ default:
+ aNewPointer = Pointer( POINTER_CROSS );
+ aObjKind = OBJ_RECT;
+ break;
+ }
+
+ pView->SetCurrentObj(sal::static_int_cast<UINT16>(aObjKind));
+
+ aOldPointer = pWindow->GetPointer();
+ pViewShell->SetActivePointer( aNewPointer );
+
+ FuConstruct::Activate();
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuConstRectangle::Deactivate()
+{
+ FuConstruct::Deactivate();
+ pViewShell->SetActivePointer( aOldPointer );
+}
+
+// #98185# Create default drawing objects via keyboard
+SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
+{
+ // case SID_DRAW_LINE:
+ // case SID_DRAW_RECT:
+ // case SID_DRAW_ELLIPSE:
+ // case SID_DRAW_CAPTION:
+ // case SID_DRAW_CAPTION_VERTICAL:
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
+ 0L, pDrDoc);
+
+ if(pObj)
+ {
+ Rectangle aRect(rRectangle);
+ Point aStart = aRect.TopLeft();
+ Point aEnd = aRect.BottomRight();
+
+ switch(nID)
+ {
+ case SID_DRAW_LINE:
+ {
+ if(pObj->ISA(SdrPathObj))
+ {
+ sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
+ basegfx::B2DPolygon aPoly;
+ aPoly.append(basegfx::B2DPoint(aStart.X(), nYMiddle));
+ aPoly.append(basegfx::B2DPoint(aEnd.X(), nYMiddle));
+ ((SdrPathObj*)pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aPoly));
+ }
+ else
+ {
+ DBG_ERROR("Object is NO line object");
+ }
+
+ break;
+ }
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ {
+ if(pObj->ISA(SdrCaptionObj))
+ {
+ sal_Bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
+
+ ((SdrTextObj*)pObj)->SetVerticalWriting(bIsVertical);
+
+ if(bIsVertical)
+ {
+ SfxItemSet aSet(pObj->GetMergedItemSet());
+ aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
+ aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
+ pObj->SetMergedItemSet(aSet);
+ }
+
+ // #105815# don't set default text, start edit mode instead
+ // (Edit mode is started in ScTabViewShell::ExecDraw, because
+ // it must be handled by FuText)
+ // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
+ // ((SdrCaptionObj*)pObj)->SetText(aText);
+
+ ((SdrCaptionObj*)pObj)->SetLogicRect(aRect);
+ ((SdrCaptionObj*)pObj)->SetTailPos(
+ aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
+ }
+ else
+ {
+ DBG_ERROR("Object is NO caption object");
+ }
+
+ break;
+ }
+
+ default:
+ {
+ pObj->SetLogicRect(aRect);
+
+ break;
+ }
+ }
+
+ SfxItemSet aAttr(pDrDoc->GetItemPool());
+ pObj->SetMergedItemSet(aAttr);
+ }
+
+ return pObj;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuconstr.cxx b/sc/source/ui/drawfunc/fuconstr.cxx
new file mode 100644
index 000000000000..f640711dfb43
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuconstr.cxx
@@ -0,0 +1,337 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <editeng/outliner.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdouno.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include "fuconstr.hxx"
+#include "fudraw.hxx"
+#include "tabvwsh.hxx"
+#include "futext.hxx"
+#include "sc.hrc"
+#include "drawview.hxx"
+
+// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
+//! fusel,fuconstr,futext - zusammenfassen!
+#define SC_MAXDRAGMOVE 3
+
+//------------------------------------------------------------------------
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuConstruct::FuConstruct(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq) :
+ FuDraw(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuConstruct::~FuConstruct()
+{
+}
+
+BYTE FuConstruct::Command(const CommandEvent& rCEvt)
+{
+ // special code for non-VCL OS2/UNX removed
+
+ return FuDraw::Command( rCEvt );
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstruct::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuDraw::MouseButtonDown(rMEvt);
+
+ if ( pView->IsAction() )
+ {
+ if ( rMEvt.IsRight() )
+ pView->BckAction();
+ return TRUE;
+ }
+
+ aDragTimer.Start();
+
+ aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+
+ if ( rMEvt.IsLeft() )
+ {
+ pWindow->CaptureMouse();
+
+ SdrHdl* pHdl = pView->PickHandle(aMDPos);
+
+ if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
+ {
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, 1);
+ bReturn = TRUE;
+ }
+ else if ( pView->AreObjectsMarked() )
+ {
+ pView->UnmarkAll();
+ bReturn = TRUE;
+ }
+ }
+
+ bIsInDragMode = FALSE;
+
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstruct::MouseMove(const MouseEvent& rMEvt)
+{
+ FuDraw::MouseMove(rMEvt);
+
+ if (aDragTimer.IsActive() )
+ {
+ Point aOldPixel = pWindow->LogicToPixel( aMDPos );
+ Point aNewPixel = rMEvt.GetPosPixel();
+ if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
+ Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
+ aDragTimer.Stop();
+ }
+
+ Point aPix(rMEvt.GetPosPixel());
+ Point aPnt( pWindow->PixelToLogic(aPix) );
+
+ if ( pView->IsAction() )
+ {
+ ForceScroll(aPix);
+ pView->MovAction(aPnt);
+ }
+ else
+ {
+ SdrHdl* pHdl=pView->PickHandle(aPnt);
+
+ if ( pHdl != NULL )
+ {
+ pViewShell->SetActivePointer(pHdl->GetPointer());
+ }
+ else if ( pView->IsMarkedHit(aPnt) )
+ {
+ pViewShell->SetActivePointer(Pointer(POINTER_MOVE));
+ }
+ else
+ {
+ pViewShell->SetActivePointer( aNewPointer );
+ }
+ }
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstruct::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = SimpleMouseButtonUp( rMEvt );
+
+ // Doppelklick auf Textobjekt? (->fusel)
+
+ USHORT nClicks = rMEvt.GetClicks();
+ if ( nClicks == 2 && rMEvt.IsLeft() )
+ {
+ if ( pView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ // #49458# bei Uno-Controls nicht in Textmodus
+ if ( pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) )
+ {
+ OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
+ BOOL bVertical = ( pOPO && pOPO->IsVertical() );
+ USHORT nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
+
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(nTextSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+
+ // jetzt den erzeugten FuText holen und in den EditModus setzen
+ FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
+ if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // hat keine RTTI
+ {
+ FuText* pText = (FuText*)pPoor;
+ Point aMousePixel = rMEvt.GetPosPixel();
+ pText->SetInEditMode( pObj, &aMousePixel );
+ }
+ bReturn = TRUE;
+ }
+ }
+ }
+ }
+
+ FuDraw::MouseButtonUp(rMEvt);
+
+ return bReturn;
+}
+
+// SimpleMouseButtonUp - ohne Test auf Doppelklick
+
+BOOL FuConstruct::SimpleMouseButtonUp(const MouseEvent& rMEvt)
+{
+ BOOL bReturn = TRUE;
+
+ if (aDragTimer.IsActive() )
+ {
+ aDragTimer.Stop();
+ }
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( pView->IsDragObj() )
+ pView->EndDragObj( rMEvt.IsMod1() );
+
+ else if ( pView->IsMarkObj() )
+ pView->EndMarkObj();
+
+ else bReturn = FALSE;
+
+ if ( !pView->IsAction() )
+ {
+ pWindow->ReleaseMouse();
+
+ if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
+ {
+ pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1());
+
+ SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
+ if ( pView->AreObjectsMarked() )
+ rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ else
+ rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ }
+ }
+
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstruct::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FALSE;
+
+ switch ( rKEvt.GetKeyCode().GetCode() )
+ {
+ case KEY_ESCAPE:
+ if ( pView->IsAction() )
+ {
+ pView->BrkAction();
+ pWindow->ReleaseMouse();
+ bReturn = TRUE;
+ }
+ else // Zeichenmodus beenden
+ {
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ }
+ break;
+
+ case KEY_DELETE:
+ pView->DeleteMarked();
+ bReturn = TRUE;
+ break;
+ }
+
+ if ( !bReturn )
+ {
+ bReturn = FuDraw::KeyInput(rKEvt);
+ }
+
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuConstruct::Activate()
+{
+ FuDraw::Activate();
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuConstruct::Deactivate()
+{
+ FuDraw::Deactivate();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuconuno.cxx b/sc/source/ui/drawfunc/fuconuno.cxx
new file mode 100644
index 000000000000..75aaa6a3a965
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuconuno.cxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "fuconuno.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "drawview.hxx"
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuConstUnoControl::FuConstUnoControl(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq)
+ : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+ SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, FALSE );
+ SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, FALSE );
+ if( pInventorItem )
+ nInventor = pInventorItem->GetValue();
+ if( pIdentifierItem )
+ nIdentifier = pIdentifierItem->GetValue();
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuConstUnoControl::~FuConstUnoControl()
+{
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt);
+
+ if ( rMEvt.IsLeft() && !pView->IsAction() )
+ {
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pWindow->CaptureMouse();
+ pView->BegCreateObj(aPnt);
+ bReturn = TRUE;
+ }
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstUnoControl::MouseMove(const MouseEvent& rMEvt)
+{
+ return FuConstruct::MouseMove(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FALSE;
+
+ if ( pView->IsCreateObj() && rMEvt.IsLeft() )
+ {
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+ pView->EndCreateObj(SDRCREATE_FORCEEND);
+ bReturn = TRUE;
+ }
+ return (FuConstruct::MouseButtonUp(rMEvt) || bReturn);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuConstUnoControl::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FuConstruct::KeyInput(rKEvt);
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuConstUnoControl::Activate()
+{
+ pView->SetCurrentObj( nIdentifier, nInventor );
+
+ aNewPointer = Pointer( POINTER_DRAW_RECT );
+ aOldPointer = pWindow->GetPointer();
+ pViewShell->SetActivePointer( aNewPointer );
+
+ SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS);
+ if (pLayer)
+ pView->SetActiveLayer( pLayer->GetName() );
+
+ FuConstruct::Activate();
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuConstUnoControl::Deactivate()
+{
+ FuConstruct::Deactivate();
+
+ SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT);
+ if (pLayer)
+ pView->SetActiveLayer( pLayer->GetName() );
+
+ pViewShell->SetActivePointer( aOldPointer );
+}
+
+// #98185# Create default drawing objects via keyboard
+SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle)
+{
+ // case SID_FM_CREATE_CONTROL:
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
+ 0L, pDrDoc);
+
+ if(pObj)
+ {
+ pObj->SetLogicRect(rRectangle);
+ }
+
+ return pObj;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx
new file mode 100644
index 000000000000..a96a16206421
--- /dev/null
+++ b/sc/source/ui/drawfunc/fudraw.cxx
@@ -0,0 +1,862 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------------
+
+#include <editeng/editeng.hxx> // EditEngine::IsSimpleCharInput
+#include <editeng/outlobj.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "sc.hrc"
+#include "fudraw.hxx"
+#include "futext.hxx"
+#include "tabvwsh.hxx"
+#include "drwlayer.hxx"
+#include "scresid.hxx"
+#include "userdat.hxx"
+#include "docsh.hxx"
+#include "postit.hxx"
+#include "globstr.hrc"
+#include "drawview.hxx"
+
+/*************************************************************************
+|*
+|* Basisklasse fuer alle Drawmodul-spezifischen Funktionen
+|*
+\************************************************************************/
+
+FuDraw::FuDraw(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq) :
+ FuPoor (pViewSh, pWin, pViewP, pDoc, rReq),
+ aNewPointer ( POINTER_ARROW ),
+ aOldPointer ( POINTER_ARROW )
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuDraw::~FuDraw()
+{
+}
+
+/*************************************************************************
+|*
+|* Modifier-Tasten auswerten
+|*
+\************************************************************************/
+
+void FuDraw::DoModifiers(const MouseEvent& rMEvt)
+{
+ // Shift = Ortho und AngleSnap
+ // Control = Snap (Toggle)
+ // Alt = zentrisch
+
+ BOOL bShift = rMEvt.IsShift();
+// BOOL bCtrl = rMEvt.IsMod1();
+ BOOL bAlt = rMEvt.IsMod2();
+
+// ScViewData* pViewData = pViewShell->GetViewData();
+// const ScViewOptions& rOpt = pViewData->GetOptions();
+// const ScGridOptions& rGrid = rOpt.GetGridOptions();
+// BOOL bGridOpt = rGrid.GetUseGridSnap();
+
+ BOOL bOrtho = bShift;
+ BOOL bAngleSnap = bShift;
+// BOOL bGridSnap = ( bGridOpt != bCtrl ); // andere Snap's nicht unterstuetzt
+ BOOL bCenter = bAlt;
+
+ // #i33136#
+ if(doConstructOrthogonal())
+ {
+ bOrtho = !bShift;
+ }
+
+ if (pView->IsOrtho() != bOrtho)
+ pView->SetOrtho(bOrtho);
+ if (pView->IsAngleSnapEnabled() != bAngleSnap)
+ pView->SetAngleSnapEnabled(bAngleSnap);
+
+/* Control fuer Snap beisst sich beim Verschieben mit "kopieren" !!!
+
+ if (pView->IsGridSnap() != bGridSnap)
+ pView->SetGridSnap(bGridSnap);
+ if (pView->IsSnapEnabled() != bGridSnap)
+ pView->SetSnapEnabled(bGridSnap);
+*/
+ if (pView->IsCreate1stPointAsCenter() != bCenter)
+ pView->SetCreate1stPointAsCenter(bCenter);
+ if (pView->IsResizeAtCenter() != bCenter)
+ pView->SetResizeAtCenter(bCenter);
+
+}
+
+void FuDraw::ResetModifiers()
+{
+ ScViewData* pViewData = pViewShell->GetViewData();
+ const ScViewOptions& rOpt = pViewData->GetOptions();
+ const ScGridOptions& rGrid = rOpt.GetGridOptions();
+ BOOL bGridOpt = rGrid.GetUseGridSnap();
+
+ if (pView->IsOrtho())
+ pView->SetOrtho(FALSE);
+ if (pView->IsAngleSnapEnabled())
+ pView->SetAngleSnapEnabled(FALSE);
+
+ if (pView->IsGridSnap() != bGridOpt)
+ pView->SetGridSnap(bGridOpt);
+ if (pView->IsSnapEnabled() != bGridOpt)
+ pView->SetSnapEnabled(bGridOpt);
+
+ if (pView->IsCreate1stPointAsCenter())
+ pView->SetCreate1stPointAsCenter(FALSE);
+ if (pView->IsResizeAtCenter())
+ pView->SetResizeAtCenter(FALSE);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuDraw::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ DoModifiers( rMEvt );
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuDraw::MouseMove(const MouseEvent& rMEvt)
+{
+ // #106438# evaluate modifiers only if in a drawing layer action
+ // (don't interfere with keyboard shortcut handling)
+ if (pView->IsAction())
+ DoModifiers( rMEvt );
+
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuDraw::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ ResetModifiers();
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell* pViewShell, const KeyEvent* pInitialKey )
+{
+ BOOL bReturn = FALSE;
+ if ( pObj && pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) )
+ {
+ // start text edit - like FuSelection::MouseButtonUp,
+ // but with bCursorToEnd instead of mouse position
+
+ OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
+ BOOL bVertical = ( pOPO && pOPO->IsVertical() );
+ USHORT nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
+
+ // don't switch shells if text shell is already active
+ FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
+ if ( !pPoor || pPoor->GetSlotID() != nTextSlotId )
+ {
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
+ }
+
+ // get the resulting FuText and set in edit mode
+ pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
+ if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // no RTTI
+ {
+ FuText* pText = (FuText*)pPoor;
+ pText->SetInEditMode( pObj, NULL, TRUE, pInitialKey );
+ //! set cursor to end of text
+ }
+ bReturn = TRUE;
+ }
+ return bReturn;
+}
+
+BOOL __EXPORT FuDraw::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FALSE;
+ ScViewData& rViewData = *pViewShell->GetViewData();
+
+ switch ( rKEvt.GetKeyCode().GetCode() )
+ {
+ case KEY_ESCAPE:
+
+ /* 18.12.95: TextShell beibehalten nicht mehr gewuenscht...
+ *
+ * if ( pView->IsAction() )
+ * {
+ * pView->BrkAction();
+ * pWindow->ReleaseMouse();
+ * bReturn = TRUE;
+ * }
+ * else if ( pView->IsTextEdit() )
+ * {
+ * pView->EndTextEdit();
+ * pView->SetCreateMode();
+ * pViewShell->GetScDrawView()->InvalidateDrawTextAttrs();
+ * bReturn = TRUE;
+ * }
+ * else
+ */
+
+ if ( pViewShell->IsDrawTextShell() || aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
+ {
+ // in normale Draw-Shell, wenn Objekt selektiert, sonst Zeichnen aus
+ rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ bReturn = TRUE;
+ }
+ else if ( pViewShell->IsDrawSelMode() )
+ {
+ pView->UnmarkAll();
+ rViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ bReturn = TRUE;
+ }
+ else if ( pView->AreObjectsMarked() )
+ {
+ // #97016# III
+ SdrHdlList& rHdlList = const_cast< SdrHdlList& >( pView->GetHdlList() );
+ if( rHdlList.GetFocusHdl() )
+ rHdlList.ResetFocusHdl();
+ else
+ pView->UnmarkAll();
+
+ // Beim Bezier-Editieren ist jetzt wieder das Objekt selektiert
+ if (!pView->AreObjectsMarked())
+ pViewShell->SetDrawShell( FALSE );
+
+ bReturn = TRUE;
+ }
+ break;
+
+ case KEY_DELETE: //! ueber Accelerator
+ pView->DeleteMarked();
+ bReturn = TRUE;
+ break;
+
+ case KEY_RETURN:
+ {
+ if( rKEvt.GetKeyCode().GetModifier() == 0 )
+ {
+ // #98256# activate OLE object on RETURN for selected object
+ // #98198# put selected text object in edit mode
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
+ {
+ BOOL bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( pObj && pObj->ISA( SdrOle2Obj ) && !bOle )
+ {
+ //HMHpView->HideMarkHdl();
+ pViewShell->ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 );
+
+ // consumed
+ bReturn = TRUE;
+ }
+ else if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) ) // start text edit for suitable object
+ bReturn = TRUE;
+ }
+ }
+ }
+ break;
+
+ case KEY_F2:
+ {
+ if( rKEvt.GetKeyCode().GetModifier() == 0 )
+ {
+ // #98198# put selected text object in edit mode
+ // (this is not SID_SETINPUTMODE, but F2 hardcoded, like in Writer)
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) ) // start text edit for suitable object
+ bReturn = TRUE;
+ }
+ }
+ }
+ break;
+
+ // #97016#
+ case KEY_TAB:
+ {
+ // in calc do NOT start draw object selection using TAB/SHIFT-TAB when
+ // there is not yet a object selected
+ if(pView->AreObjectsMarked())
+ {
+ KeyCode aCode = rKEvt.GetKeyCode();
+
+ if ( !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ // changeover to the next object
+ if(!pView->MarkNextObj( !aCode.IsShift() ))
+ {
+ // #97016# No next object: go over open end and
+ // get first from the other side
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(!aCode.IsShift());
+ }
+
+ // #97016# II
+ if(pView->AreObjectsMarked())
+ pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
+
+ bReturn = TRUE;
+ }
+
+ // #98994# handle Mod1 and Mod2 to get travelling running on different systems
+ if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
+ {
+ // #97016# II do something with a selected handle?
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ sal_Bool bForward(!rKEvt.GetKeyCode().IsShift());
+
+ ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward);
+
+ // guarantee visibility of focused handle
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(pHdl)
+ {
+ Point aHdlPosition(pHdl->GetPos());
+ Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200));
+ pView->MakeVisible(aVisRect, *pWindow);
+ }
+
+ // consumed
+ bReturn = TRUE;
+ }
+ }
+ }
+ break;
+
+ // #97016#
+ case KEY_END:
+ {
+ // in calc do NOT select the last draw object when
+ // there is not yet a object selected
+ if(pView->AreObjectsMarked())
+ {
+ KeyCode aCode = rKEvt.GetKeyCode();
+
+ if ( aCode.IsMod1() )
+ {
+ // #97016# mark last object
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(FALSE);
+
+ // #97016# II
+ if(pView->AreObjectsMarked())
+ pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
+
+ bReturn = TRUE;
+ }
+ }
+ }
+ break;
+
+ // #97016#
+ case KEY_HOME:
+ {
+ // in calc do NOT select the first draw object when
+ // there is not yet a object selected
+ if(pView->AreObjectsMarked())
+ {
+ KeyCode aCode = rKEvt.GetKeyCode();
+
+ if ( aCode.IsMod1() )
+ {
+ // #97016# mark first object
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(TRUE);
+
+ // #97016# II
+ if(pView->AreObjectsMarked())
+ pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
+
+ bReturn = TRUE;
+ }
+ }
+ }
+ break;
+
+ // #97016#
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ {
+ // in calc do cursor travelling of draw objects only when
+ // there is a object selected yet
+ if(pView->AreObjectsMarked())
+ {
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if(rMarkList.GetMarkCount() == 1)
+ {
+ // disable cursor travelling on note objects as the tail connector position
+ // must not move.
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( ScDrawLayer::IsNoteCaption( pObj ) )
+ break;
+ }
+
+ long nX = 0;
+ long nY = 0;
+ USHORT nCode = rKEvt.GetKeyCode().GetCode();
+
+ if (nCode == KEY_UP)
+ {
+ // Scroll nach oben
+ nX = 0;
+ nY =-1;
+ }
+ else if (nCode == KEY_DOWN)
+ {
+ // Scroll nach unten
+ nX = 0;
+ nY = 1;
+ }
+ else if (nCode == KEY_LEFT)
+ {
+ // Scroll nach links
+ nX =-1;
+ nY = 0;
+ }
+ else if (nCode == KEY_RIGHT)
+ {
+ // Scroll nach rechts
+ nX = 1;
+ nY = 0;
+ }
+
+ BOOL bReadOnly = rViewData.GetDocShell()->IsReadOnly();
+
+ if(!rKEvt.GetKeyCode().IsMod1() && !bReadOnly)
+ {
+ if(rKEvt.GetKeyCode().IsMod2())
+ {
+ // #97016# move in 1 pixel distance
+ Size aLogicSizeOnePixel = (pWindow) ? pWindow->PixelToLogic(Size(1,1)) : Size(100, 100);
+ nX *= aLogicSizeOnePixel.Width();
+ nY *= aLogicSizeOnePixel.Height();
+ }
+ else
+ {
+ // old, fixed move distance
+ nX *= 100;
+ nY *= 100;
+ }
+
+ // is there a movement to do?
+ if(0 != nX || 0 != nY)
+ {
+ // #97016# II
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(0L == pHdl)
+ {
+ // #107086# only take action when move is allowed
+ if(pView->IsMoveAllowed())
+ {
+ // #90129# restrict movement to WorkArea
+ const Rectangle& rWorkArea = pView->GetWorkArea();
+
+ if(!rWorkArea.IsEmpty())
+ {
+ Rectangle aMarkRect(pView->GetMarkedObjRect());
+ aMarkRect.Move(nX, nY);
+
+ if(!aMarkRect.IsInside(rWorkArea))
+ {
+ if(aMarkRect.Left() < rWorkArea.Left())
+ {
+ nX += rWorkArea.Left() - aMarkRect.Left();
+ }
+
+ if(aMarkRect.Right() > rWorkArea.Right())
+ {
+ nX -= aMarkRect.Right() - rWorkArea.Right();
+ }
+
+ if(aMarkRect.Top() < rWorkArea.Top())
+ {
+ nY += rWorkArea.Top() - aMarkRect.Top();
+ }
+
+ if(aMarkRect.Bottom() > rWorkArea.Bottom())
+ {
+ nY -= aMarkRect.Bottom() - rWorkArea.Bottom();
+ }
+ }
+ }
+
+ // now move the selected draw objects
+ pView->MoveAllMarked(Size(nX, nY));
+
+ // #97016# II
+ pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow);
+
+ bReturn = TRUE;
+ }
+ }
+ else
+ {
+ // move handle with index nHandleIndex
+ if(pHdl && (nX || nY))
+ {
+ // now move the Handle (nX, nY)
+ Point aStartPoint(pHdl->GetPos());
+ Point aEndPoint(pHdl->GetPos() + Point(nX, nY));
+ const SdrDragStat& rDragStat = pView->GetDragStat();
+
+ // start dragging
+ pView->BegDragObj(aStartPoint, 0, pHdl, 0);
+
+ if(pView->IsDragObj())
+ {
+ bool bWasNoSnap = rDragStat.IsNoSnap();
+ BOOL bWasSnapEnabled = pView->IsSnapEnabled();
+
+ // switch snapping off
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(TRUE);
+ if(bWasSnapEnabled)
+ pView->SetSnapEnabled(FALSE);
+
+ pView->MovAction(aEndPoint);
+ pView->EndDragObj();
+
+ // restore snap
+ if(!bWasNoSnap)
+ ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap);
+ if(bWasSnapEnabled)
+ pView->SetSnapEnabled(bWasSnapEnabled);
+ }
+
+ // make moved handle visible
+ Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200));
+ pView->MakeVisible(aVisRect, *pWindow);
+
+ bReturn = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ // #97016#
+ case KEY_SPACE:
+ {
+ // in calc do only something when draw objects are selected
+ if(pView->AreObjectsMarked())
+ {
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ SdrHdl* pHdl = rHdlList.GetFocusHdl();
+
+ if(pHdl)
+ {
+ if(pHdl->GetKind() == HDL_POLY)
+ {
+ // rescue ID of point with focus
+ sal_uInt32 nPol(pHdl->GetPolyNum());
+ sal_uInt32 nPnt(pHdl->GetPointNum());
+
+ if(pView->IsPointMarked(*pHdl))
+ {
+ if(rKEvt.GetKeyCode().IsShift())
+ {
+ pView->UnmarkPoint(*pHdl);
+ }
+ }
+ else
+ {
+ if(!rKEvt.GetKeyCode().IsShift())
+ {
+ pView->UnmarkAllPoints();
+ }
+
+ pView->MarkPoint(*pHdl);
+ }
+
+ if(0L == rHdlList.GetFocusHdl())
+ {
+ // restore point with focus
+ SdrHdl* pNewOne = 0L;
+
+ for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++)
+ {
+ SdrHdl* pAct = rHdlList.GetHdl(a);
+
+ if(pAct
+ && pAct->GetKind() == HDL_POLY
+ && pAct->GetPolyNum() == nPol
+ && pAct->GetPointNum() == nPnt)
+ {
+ pNewOne = pAct;
+ }
+ }
+
+ if(pNewOne)
+ {
+ ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne);
+ }
+ }
+
+ bReturn = TRUE;
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ if (!bReturn)
+ {
+ bReturn = FuPoor::KeyInput(rKEvt);
+ }
+
+ if (!bReturn)
+ {
+ // #98198# allow direct typing into a selected text object
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() && EditEngine::IsSimpleCharInput(rKEvt) )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ // start text edit for suitable object, pass key event to OutlinerView
+ if ( lcl_KeyEditMode( pObj, pViewShell, &rKEvt ) )
+ bReturn = TRUE;
+ }
+ }
+
+ return (bReturn);
+}
+
+// #97016# II
+void FuDraw::SelectionHasChanged()
+{
+ const SdrHdlList& rHdlList = pView->GetHdlList();
+ ((SdrHdlList&)rHdlList).ResetFocusHdl();
+}
+
+/*************************************************************************
+|*
+|* Vor dem Scrollen Selektionsdarstellung ausblenden
+|*
+\************************************************************************/
+
+void FuDraw::ScrollStart()
+{
+// HideShownXor in Gridwin
+}
+
+/*************************************************************************
+|*
+|* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
+|*
+\************************************************************************/
+
+void FuDraw::ScrollEnd()
+{
+// ShowShownXor in Gridwin
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuDraw::Activate()
+{
+ FuPoor::Activate();
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuDraw::Deactivate()
+{
+ FuPoor::Deactivate();
+}
+
+/*************************************************************************
+|*
+|* Maus-Pointer umschalten
+|*
+\************************************************************************/
+
+BOOL lcl_UrlHit( SdrView* pView, const Point& rPosPixel, Window* pWindow )
+{
+ SdrViewEvent aVEvt;
+ MouseEvent aMEvt( rPosPixel, 1, 0, MOUSE_LEFT );
+ SdrHitKind eHit = pView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
+
+ if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
+ {
+ if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) && ScDrawLayer::GetHitIMapObject(
+ aVEvt.pObj, pWindow->PixelToLogic(rPosPixel), *pWindow ) )
+ return TRUE;
+
+ if ( aVEvt.eEvent == SDREVENT_EXECUTEURL )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void FuDraw::ForcePointer(const MouseEvent* pMEvt)
+{
+ if ( !pView->IsAction() )
+ {
+ Point aPosPixel = pWindow->GetPointerPosPixel();
+ BOOL bAlt = pMEvt && pMEvt->IsMod2();
+ Point aPnt = pWindow->PixelToLogic( aPosPixel );
+ SdrHdl* pHdl = pView->PickHandle(aPnt);
+ SdrObject* pObj;
+ SdrPageView* pPV;
+
+ ScMacroInfo* pInfo = 0;
+ if ( pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
+ {
+ if ( pObj->IsGroupObject() )
+ {
+ SdrObject* pHit = 0;
+ if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
+ pObj = pHit;
+ }
+ pInfo = ScDrawLayer::GetMacroInfo( pObj );
+ }
+
+ if ( pView->IsTextEdit() )
+ {
+ pViewShell->SetActivePointer(Pointer(POINTER_TEXT)); // kann nicht sein ?
+ }
+ else if ( pHdl )
+ {
+ pViewShell->SetActivePointer(
+ pView->GetPreferedPointer( aPnt, pWindow ) );
+ }
+ else if ( pView->IsMarkedHit(aPnt) )
+ {
+ pViewShell->SetActivePointer( Pointer(POINTER_MOVE) );
+ }
+ else if ( !bAlt && ( !pMEvt || !pMEvt->GetButtons() )
+ && lcl_UrlHit( pView, aPosPixel, pWindow ) )
+ {
+ // kann mit ALT unterdrueckt werden
+ pWindow->SetPointer( Pointer( POINTER_REFHAND ) ); // Text-URL / ImageMap
+ }
+ else if ( !bAlt && pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
+ {
+ // kann mit ALT unterdrueckt werden
+ SdrObjMacroHitRec aHitRec; //! muss da noch irgendwas gesetzt werden ????
+ pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) );
+ }
+ else if ( !bAlt && pInfo && ((pInfo->GetMacro().getLength() > 0) || (pInfo->GetHlink().getLength() > 0)) )
+ pWindow->SetPointer( Pointer( POINTER_REFHAND ) );
+ else if ( IsDetectiveHit( aPnt ) )
+ pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) );
+ else
+ pViewShell->SetActivePointer( aNewPointer ); //! in Gridwin?
+ }
+}
+
+BOOL FuDraw::IsSizingOrMovingNote( const MouseEvent& rMEvt ) const
+{
+ BOOL bIsSizingOrMoving = FALSE;
+ if ( rMEvt.IsLeft() )
+ {
+ const SdrMarkList& rNoteMarkList = pView->GetMarkedObjectList();
+ if(rNoteMarkList.GetMarkCount() == 1)
+ {
+ SdrObject* pObj = rNoteMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if ( ScDrawLayer::IsNoteCaption( pObj ) )
+ {
+ Point aMPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+ bIsSizingOrMoving =
+ pView->PickHandle( aMPos ) || // handles to resize the note
+ pView->IsTextEditFrameHit( aMPos ); // frame for moving the note
+ }
+ }
+ }
+ return bIsSizingOrMoving;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx
new file mode 100644
index 000000000000..26dc67b1b81e
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuins1.cxx
@@ -0,0 +1,436 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <sfx2/opengrf.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/linkwarn.hxx>
+#include <svtools/filter.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/miscopt.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/urlobj.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <vcl/svapp.hxx>
+
+#include "fuinsert.hxx"
+#include "tabvwsh.hxx"
+#include "drwlayer.hxx"
+#include "drawview.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "progress.hxx"
+#include "sc.hrc"
+
+
+
+////========================================================================
+//// class ImportProgress
+////
+//// Bemerkung:
+//// Diese Klasse stellt lediglich den Handler fuer den ImportProgress des
+//// Grafikfilters bereit.
+////========================================================================
+//
+//class ImportProgress
+//{
+//public:
+// ImportProgress( GraphicFilter& rFilter );
+// ~ImportProgress();
+//
+// DECL_LINK( Update, GraphicFilter* );
+//
+//private:
+// ScProgress aProgress;
+//};
+//
+////------------------------------------------------------------------------
+//
+//ImportProgress::ImportProgress( GraphicFilter& rFilter )
+// : aProgress( NULL, // SfxViewFrame*, NULL == alle Docs locken
+// String( ScResId(STR_INSERTGRAPHIC) ),
+// 100 )
+//{
+// rFilter.SetUpdatePercentHdl( LINK( this, ImportProgress, Update) );
+//}
+//
+////------------------------------------------------------------------------
+//
+//__EXPORT ImportProgress::~ImportProgress()
+//{
+// aProgress.SetState( 100 );
+//}
+//
+////------------------------------------------------------------------------
+//
+//IMPL_LINK( ImportProgress, Update, GraphicFilter*, pGraphicFilter )
+//{
+// aProgress.SetState( pGraphicFilter->GetPercent() );
+// return 0;
+//}
+
+
+//------------------------------------------------------------------------
+
+void SC_DLLPUBLIC ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage )
+{
+ if ( !rPage.Width() || !rPage.Height() )
+ return;
+
+ Size aPageSize = rPage;
+ BOOL bNegative = aPageSize.Width() < 0;
+ if ( bNegative )
+ {
+ // make everything positive temporarily
+ aPageSize.Width() = -aPageSize.Width();
+ rPos.X() = -rPos.X() - rSize.Width();
+ }
+
+ if ( rSize.Width() > aPageSize.Width() || rSize.Height() > aPageSize.Height() )
+ {
+ double fX = aPageSize.Width() / (double) rSize.Width();
+ double fY = aPageSize.Height() / (double) rSize.Height();
+
+ if ( fX < fY )
+ {
+ rSize.Width() = aPageSize.Width();
+ rSize.Height() = (long) ( rSize.Height() * fX );
+ }
+ else
+ {
+ rSize.Height() = aPageSize.Height();
+ rSize.Width() = (long) ( rSize.Width() * fY );
+ }
+
+ if (!rSize.Width())
+ rSize.Width() = 1;
+ if (!rSize.Height())
+ rSize.Height() = 1;
+ }
+
+ if ( rPos.X() + rSize.Width() > aPageSize.Width() )
+ rPos.X() = aPageSize.Width() - rSize.Width();
+ if ( rPos.Y() + rSize.Height() > aPageSize.Height() )
+ rPos.Y() = aPageSize.Height() - rSize.Height();
+
+ if ( bNegative )
+ rPos.X() = -rPos.X() - rSize.Width(); // back to real position
+}
+
+//------------------------------------------------------------------------
+
+void lcl_InsertGraphic( const Graphic& rGraphic,
+ const String& rFileName, const String& rFilterName, BOOL bAsLink, BOOL bApi,
+ ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView )
+{
+ // #74778# set the size so the graphic has its original pixel size
+ // at 100% view scale (as in SetMarkedOriginalSize),
+ // instead of respecting the current view scale
+
+ ScDrawView* pDrawView = pViewSh->GetScDrawView();
+ MapMode aSourceMap = rGraphic.GetPrefMapMode();
+ MapMode aDestMap( MAP_100TH_MM );
+ if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView )
+ {
+ Fraction aScaleX, aScaleY;
+ pDrawView->CalcNormScale( aScaleX, aScaleY );
+ aDestMap.SetScaleX(aScaleX);
+ aDestMap.SetScaleY(aScaleY);
+ }
+ Size aLogicSize = pWindow->LogicToLogic(
+ rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
+
+ // Limit size
+
+ SdrPageView* pPV = pView->GetSdrPageView();
+ SdrPage* pPage = pPV->GetPage();
+ Point aInsertPos = pViewSh->GetInsertPos();
+
+ ScViewData* pData = pViewSh->GetViewData();
+ if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
+ aInsertPos.X() -= aLogicSize.Width(); // move position to left edge
+
+ ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() );
+
+ Rectangle aRect ( aInsertPos, aLogicSize );
+
+ SdrGrafObj* pObj = new SdrGrafObj( rGraphic, aRect );
+
+ // #118522# calling SetGraphicLink here doesn't work
+
+ // #49961# Path is no longer used as name for the graphics object
+
+ ScDrawLayer* pLayer = (ScDrawLayer*) pView->GetModel();
+ String aName = pLayer->GetNewGraphicName(); // "Grafik x"
+ pObj->SetName(aName);
+
+ // don't select if from (dispatch) API, to allow subsequent cell operations
+ ULONG nInsOptions = bApi ? SDRINSERT_DONTMARK : 0;
+ pView->InsertObjectAtView( pObj, *pPV, nInsOptions );
+
+ // #118522# SetGraphicLink has to be used after inserting the object,
+ // otherwise an empty graphic is swapped in and the contact stuff crashes.
+ // See #i37444#.
+ if ( bAsLink )
+ pObj->SetGraphicLink( rFileName, rFilterName );
+}
+
+//------------------------------------------------------------------------
+
+void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi,
+ ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView,
+ const Size& rPrefSize )
+{
+ SdrPageView* pPV = pView->GetSdrPageView();
+ SdrPage* pPage = pPV->GetPage();
+ ScViewData* pData = pViewSh->GetViewData();
+ Point aInsertPos( pViewSh->GetInsertPos() );
+ Size aSize;
+
+ if( rPrefSize.Width() && rPrefSize.Height() )
+ {
+ if( pWindow )
+ aSize = pWindow->PixelToLogic( rPrefSize, MAP_100TH_MM );
+ else
+ aSize = Application::GetDefaultDevice()->PixelToLogic( rPrefSize, MAP_100TH_MM );
+ }
+ else
+ aSize = Size( 5000, 5000 );
+
+ ScLimitSizeOnDrawPage( aSize, aInsertPos, pPage->GetSize() );
+
+ if( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
+ aInsertPos.X() -= aSize.Width();
+
+ SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) );
+
+ pObj->setURL( rMediaURL );
+ pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 );
+}
+
+/*************************************************************************
+|*
+|* FuInsertGraphic::Konstruktor
+|*
+\************************************************************************/
+
+#ifdef _MSC_VER
+#pragma optimize("",off)
+#endif
+
+FuInsertGraphic::FuInsertGraphic( ScTabViewShell* pViewSh,
+ Window* pWin,
+ ScDrawView* pViewP,
+ SdrModel* pDoc,
+ SfxRequest& rReq )
+ : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState( SID_INSERT_GRAPHIC, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ String aFileName = ((const SfxStringItem*)pItem)->GetValue();
+
+ String aFilterName;
+ if ( pReqArgs->GetItemState( FN_PARAM_FILTER, TRUE, &pItem ) == SFX_ITEM_SET )
+ aFilterName = ((const SfxStringItem*)pItem)->GetValue();
+
+ BOOL bAsLink = FALSE;
+ if ( pReqArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET )
+ bAsLink = ((const SfxBoolItem*)pItem)->GetValue();
+
+ Graphic aGraphic;
+ int nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, GraphicFilter::GetGraphicFilter() );
+ if ( nError == GRFILTER_OK )
+ {
+ lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, TRUE, pViewSh, pWindow, pView );
+ }
+ }
+ else
+ {
+ SvxOpenGraphicDialog aDlg(ScResId(STR_INSERTGRAPHIC));
+
+ if( aDlg.Execute() == GRFILTER_OK )
+ {
+ Graphic aGraphic;
+ int nError = aDlg.GetGraphic(aGraphic);
+ if( nError == GRFILTER_OK )
+ {
+ String aFileName = aDlg.GetPath();
+ String aFilterName = aDlg.GetCurrentFilter();
+ BOOL bAsLink = aDlg.IsAsLink();
+
+ // really store as link only?
+ if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() )
+ {
+ SvxLinkWarningDialog aWarnDlg(pWin,aFileName);
+ if( aWarnDlg.Execute() != RET_OK )
+ bAsLink = sal_False; // don't store as link
+ }
+
+ lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, FALSE, pViewSh, pWindow, pView );
+
+ // append items for recording
+ rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) );
+ rReq.Done();
+ }
+ else
+ {
+ // error is handled in SvxOpenGraphicDialog::GetGraphic
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* FuInsertGraphic::Destruktor
+|*
+\************************************************************************/
+
+FuInsertGraphic::~FuInsertGraphic()
+{
+}
+
+/*************************************************************************
+|*
+|* FuInsertGraphic::Function aktivieren
+|*
+\************************************************************************/
+
+void FuInsertGraphic::Activate()
+{
+ FuPoor::Activate();
+}
+
+/*************************************************************************
+|*
+|* FuInsertGraphic::Function deaktivieren
+|*
+\************************************************************************/
+
+void FuInsertGraphic::Deactivate()
+{
+ FuPoor::Deactivate();
+}
+
+/*************************************************************************
+|*
+|* FuInsertMedia::Konstruktor
+|*
+\************************************************************************/
+
+FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh,
+ Window* pWin,
+ ScDrawView* pViewP,
+ SdrModel* pDoc,
+ SfxRequest& rReq ) :
+ FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+ ::rtl::OUString aURL;
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ bool bAPI = false;
+
+ if( pReqArgs )
+ {
+ const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
+
+ if( pStringItem )
+ {
+ aURL = pStringItem->GetValue();
+ bAPI = aURL.getLength();
+ }
+ }
+
+ if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) )
+ {
+ Size aPrefSize;
+
+ if( pWin )
+ pWin->EnterWait();
+
+ if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
+ {
+ if( pWin )
+ pWin->LeaveWait();
+
+ if( !bAPI )
+ ::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
+ }
+ else
+ {
+ lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize );
+
+ if( pWin )
+ pWin->LeaveWait();
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* FuInsertMedia::Destruktor
+|*
+\************************************************************************/
+
+FuInsertMedia::~FuInsertMedia()
+{
+}
+
+/*************************************************************************
+|*
+|* FuInsertMedia::Function aktivieren
+|*
+\************************************************************************/
+
+void FuInsertMedia::Activate()
+{
+ FuPoor::Activate();
+}
+
+/*************************************************************************
+|*
+|* FuInsertMedia::Function deaktivieren
+|*
+\************************************************************************/
+
+void FuInsertMedia::Deactivate()
+{
+ FuPoor::Deactivate();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
new file mode 100644
index 000000000000..4629e560a8d2
--- /dev/null
+++ b/sc/source/ui/drawfunc/fuins2.cxx
@@ -0,0 +1,851 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+//------------------------------------------------------------------------
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <sot/exchange.hxx>
+#include <svl/globalnameitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/stritem.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/pfiledlg.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/urihelper.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svtools/insdlg.hxx>
+#include <svtools/soerr.hxx>
+#include <svx/svxdlg.hxx>
+#include <sot/clsids.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+
+
+// BM/IHA --
+#include <cppuhelper/component_context.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/chart2/data/XDataProvider.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <cppuhelper/bootstrap.hxx>
+
+using namespace ::com::sun::star;
+// BM/IHA --
+
+// erAck
+#include "chart2uno.hxx"
+// erAck
+
+#include "fuinsert.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "chartarr.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "undotab.hxx"
+#include "chartlis.hxx"
+#include "uiitems.hxx"
+#include "globstr.hrc"
+#include "drawview.hxx"
+
+extern SdrObject* pSkipPaintObj; // output.cxx - dieses Objekt nicht zeichnen
+
+//------------------------------------------------------------------------
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+void lcl_ChartInit( const uno::Reference < embed::XEmbeddedObject >& xObj, ScViewData* pViewData,
+ const rtl::OUString& rRangeParam )
+{
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ ScDocument* pScDoc = pDocShell->GetDocument();
+
+ rtl::OUString aRangeString( rRangeParam );
+ if ( !aRangeString.getLength() )
+ {
+ SCCOL nCol1 = 0;
+ SCROW nRow1 = 0;
+ SCTAB nTab1 = 0;
+ SCCOL nCol2 = 0;
+ SCROW nRow2 = 0;
+ SCTAB nTab2 = 0;
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+ if ( !rMark.IsMarked() )
+ pViewData->GetView()->MarkDataArea( TRUE );
+
+ if ( pViewData->GetSimpleArea( nCol1,nRow1,nTab1, nCol2,nRow2,nTab2 ) == SC_MARK_SIMPLE )
+ {
+ PutInOrder( nCol1, nCol2 );
+ PutInOrder( nRow1, nRow2 );
+ if ( nCol2>nCol1 || nRow2>nRow1 )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ pDoc->LimitChartArea( nTab1, nCol1,nRow1, nCol2,nRow2 );
+
+ String aStr;
+ ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ aRange.Format( aStr, SCR_ABS_3D, pScDoc );
+ aRangeString = aStr;
+ }
+ }
+ }
+
+ if ( aRangeString.getLength() )
+ {
+ // connect to Calc data (if no range string, leave chart alone, with its own data)
+
+ uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
+ uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
+ if( xCompSupp.is())
+ xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+ OSL_ASSERT( xReceiver.is());
+ if( xReceiver.is() )
+ {
+ uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( pScDoc );
+ xReceiver->attachDataProvider( xDataProvider );
+
+ uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pDocShell->GetModel(), uno::UNO_QUERY );
+ xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
+
+ // Same behavior as with old chart: Always assume data series in columns
+ chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+ bool bHasCategories = false;
+ bool bFirstCellAsLabel = false;
+
+ // use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version)
+ ScRangeListRef aRangeListRef( new ScRangeList );
+ aRangeListRef->Parse( aRangeString, pScDoc );
+ if ( aRangeListRef->Count() )
+ {
+ pScDoc->LimitChartIfAll( aRangeListRef ); // limit whole columns/rows to used area
+
+ // update string from modified ranges. The ranges must be in the current formula syntax.
+ String aTmpStr;
+ aRangeListRef->Format( aTmpStr, SCR_ABS_3D, pScDoc, pScDoc->GetAddressConvention() );
+ aRangeString = aTmpStr;
+
+ ScChartPositioner aChartPositioner( pScDoc, aRangeListRef );
+ const ScChartPositionMap* pPositionMap( aChartPositioner.GetPositionMap() );
+ if( pPositionMap )
+ {
+ SCSIZE nRowCount = pPositionMap->GetRowCount();
+ if( 1==nRowCount )
+ eDataRowSource = chart::ChartDataRowSource_ROWS;
+ }
+ if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS )
+ {
+ bHasCategories = aChartPositioner.HasRowHeaders();
+ bFirstCellAsLabel = aChartPositioner.HasColHeaders();
+ }
+ else // in case the default is changed
+ {
+ bHasCategories = aChartPositioner.HasColHeaders();
+ bFirstCellAsLabel = aChartPositioner.HasRowHeaders();
+ }
+ }
+
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ aArgs[0] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
+ uno::makeAny( aRangeString ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("HasCategories"), -1,
+ uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
+ uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[3] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("DataRowSource"), -1,
+ uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE );
+ xReceiver->setArguments( aArgs );
+
+ // don't create chart listener here (range may be modified in chart dialog)
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* FuInsertOLE::Konstruktor
+|*
+\************************************************************************/
+
+FuInsertOLE::FuInsertOLE(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq)
+ : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+
+ //! hier DLL's initalisieren, damit die Factories existieren?
+
+ uno::Reference < embed::XEmbeddedObject > xObj;
+ uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+ BOOL bIsFromFile = FALSE;
+ ::rtl::OUString aName;
+
+ sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
+ ::rtl::OUString aIconMediaType;
+ uno::Reference< io::XInputStream > xIconMetaFile;
+
+
+ USHORT nSlot = rReq.GetSlot();
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False );
+ if ( nSlot == SID_INSERT_OBJECT && pNameItem )
+ {
+ SvGlobalName aClassName = pNameItem->GetValue();
+ xObj = pViewShell->GetViewFrame()->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
+ }
+ else if ( nSlot == SID_INSERT_SMATH )
+ {
+ if ( SvtModuleOptions().IsMath() )
+ {
+ nSlot = SID_INSERT_OBJECT;
+ xObj = pViewShell->GetViewFrame()->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SM_CLASSID_60 ).GetByteSequence(), aName );
+ rReq.AppendItem( SfxGlobalNameItem( SID_INSERT_OBJECT, SvGlobalName( SO3_SM_CLASSID_60 ) ) );
+ }
+ }
+ else
+ {
+ SvObjectServerList aServerLst;
+ switch ( nSlot )
+ {
+ case SID_INSERT_OBJECT :
+ aServerLst.FillInsertObjects();
+ aServerLst.Remove( ScDocShell::Factory().GetClassId() ); // Starcalc nicht anzeigen
+ //TODO/LATER: currently no inserting of ClassId into SfxRequest!
+ case SID_INSERT_PLUGIN :
+ case SID_INSERT_APPLET :
+ case SID_INSERT_FLOATINGFRAME :
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractInsertObjectDialog* pDlg =
+ pFact->CreateInsertObjectDialog( pViewShell->GetWindow(), nSlot,
+ xStorage, &aServerLst );
+ if ( pDlg )
+ {
+ pDlg->Execute();
+ xObj = pDlg->GetObject();
+
+ xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
+ if ( xIconMetaFile.is() )
+ nAspect = embed::Aspects::MSOLE_ICON;
+
+ if ( xObj.is() )
+ pViewSh->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
+ // damit DrawShell eingeschaltet wird (Objekt aktivieren ist unnoetig):
+ bIsFromFile = !pDlg->IsCreateNew();
+ DELETEZ( pDlg );
+ }
+
+ break;
+ }
+ case SID_INSERT_SOUND :
+ case SID_INSERT_VIDEO :
+ {
+ // create special filedialog for plugins
+ SvxPluginFileDlg aPluginFileDialog(pWin, nSlot);
+
+ // open filedlg
+ if ( ERRCODE_NONE == aPluginFileDialog.Execute() )
+ {
+ // get URL
+ INetURLObject aURL;
+ aURL.SetSmartProtocol( INET_PROT_FILE );
+ if ( aURL.SetURL( aPluginFileDialog.GetPath() ) )
+ {
+ // create a plugin object
+ ::rtl::OUString aObjName;
+ SvGlobalName aClassId( SO3_PLUGIN_CLASSID );
+ comphelper::EmbeddedObjectContainer aCnt( xStorage );
+ xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aObjName );
+ if ( xObj.is() && svt::EmbeddedObjectRef::TryRunningState( xObj ) )
+ {
+ // set properties from dialog
+ uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xSet.is() )
+ {
+ xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
+ uno::makeAny( ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
+ }
+ }
+ }
+ else
+ {
+ DBG_ERROR("Invalid URL!");
+ //! error message
+ //! can this happen???
+ }
+ }
+ }
+ }
+ }
+
+ // SvInsertObjectDialog (alles in einem Dialog) wird nicht mehr benutzt
+ if (xObj.is())
+ {
+ pView->UnmarkAll();
+
+ try
+ {
+ ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
+ Size aSize;
+ MapMode aMap100( MAP_100TH_MM );
+ MapUnit aMapUnit = MAP_100TH_MM;
+
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ {
+ aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType );
+ aSize = aObjRef.GetSize( &aMap100 );
+ }
+ else
+ {
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( nAspect );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ // the default size will be set later
+ }
+
+ aSize = Size( aSz.Width, aSz.Height );
+
+ aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+ if (aSize.Height() == 0 || aSize.Width() == 0)
+ {
+ // Rechteck mit ausgewogenem Kantenverhaeltnis
+ aSize.Width() = 5000;
+ aSize.Height() = 5000;
+ Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aMapUnit );
+ aSz.Width = aTmp.Width();
+ aSz.Height = aTmp.Height();
+ xObj->setVisualAreaSize( nAspect, aSz );
+
+ // re-convert aSize to 1/100th mm to avoid rounding errors in comparison below
+ aSize = Window::LogicToLogic( aTmp,
+ MapMode( aMapUnit ), aMap100 );
+ }
+ else
+ aSize = Window::LogicToLogic( aSize,
+ MapMode( aMapUnit ), aMap100 );
+ }
+
+ // Chart initialisieren ?
+ if ( SvtModuleOptions().IsChart() && SotExchange::IsChart( SvGlobalName( xObj->getClassID() ) ) )
+ lcl_ChartInit( xObj, pViewSh->GetViewData(), rtl::OUString() );
+
+ ScViewData* pData = pViewSh->GetViewData();
+
+ Point aPnt = pViewSh->GetInsertPos();
+ if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) )
+ aPnt.X() -= aSize.Width(); // move position to left edge
+ Rectangle aRect (aPnt, aSize);
+ SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect);
+
+ // Dieses Objekt nicht vor dem Aktivieren zeichnen
+ // (in MarkListHasChanged kommt ein Update)
+ if (!bIsFromFile)
+ pSkipPaintObj = pObj;
+
+ SdrPageView* pPV = pView->GetSdrPageView();
+ pView->InsertObjectAtView(pObj, *pPV);
+
+ if ( nAspect != embed::Aspects::MSOLE_ICON )
+ {
+ // #73279# Math objects change their object size during InsertObject.
+ // New size must be set in SdrObject, or a wrong scale will be set at
+ // ActivateObject.
+
+ try
+ {
+ awt::Size aSz = xObj->getVisualAreaSize( nAspect );
+
+ Size aNewSize( aSz.Width, aSz.Height );
+ aNewSize = OutputDevice::LogicToLogic( aNewSize, aMapUnit, MAP_100TH_MM );
+
+ if ( aNewSize != aSize )
+ {
+ aRect.SetSize( aNewSize );
+ pObj->SetLogicRect( aRect );
+ }
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {}
+ }
+
+ if ( !rReq.IsAPI() )
+ {
+ // XXX Activate aus Makro ist toedlich !!! ???
+ if (bIsFromFile)
+ {
+ // #45012# Objekt ist selektiert, also Draw-Shell aktivieren
+ pViewShell->SetDrawShell( TRUE );
+ }
+ else
+ {
+ pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW );
+ pSkipPaintObj = NULL;
+ }
+ }
+
+ rReq.Done();
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ASSERT( "May need error handling here!\n" );
+ }
+ }
+ else
+ rReq.Ignore();
+}
+
+/*************************************************************************
+|*
+|* FuInsertOLE::Destruktor
+|*
+\************************************************************************/
+
+FuInsertOLE::~FuInsertOLE()
+{
+}
+
+/*************************************************************************
+|*
+|* FuInsertOLE::Function aktivieren
+|*
+\************************************************************************/
+
+void FuInsertOLE::Activate()
+{
+ FuPoor::Activate();
+}
+
+/*************************************************************************
+|*
+|* FuInsertOLE::Function deaktivieren
+|*
+\************************************************************************/
+
+void FuInsertOLE::Deactivate()
+{
+ FuPoor::Deactivate();
+}
+
+/*************************************************************************
+|*
+|* FuInsertChart::Konstruktor
+|*
+\************************************************************************/
+
+FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq)
+ : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq)
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+
+ if( SvtModuleOptions().IsChart() )
+ {
+ // ----------------------------------------
+ // BM/IHA --
+
+ // get range
+ ::rtl::OUString aRangeString;
+ ScRange aPositionRange; // cell range for chart positioning
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FN_PARAM_5, &pItem ) )
+ aRangeString = ::rtl::OUString( ((const SfxStringItem*)pItem)->GetValue());
+
+ aPositionRange = pViewSh->GetViewData()->GetCurPos();
+ }
+ else
+ {
+ ScMarkData& rMark = pViewSh->GetViewData()->GetMarkData();
+ bool bAutomaticMark = false;
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ pViewSh->GetViewData()->GetView()->MarkDataArea( TRUE );
+ bAutomaticMark = true;
+ }
+
+ ScMarkData aMultiMark( rMark );
+ aMultiMark.MarkToMulti();
+
+ ScRangeList aRanges;
+ aMultiMark.FillRangeListWithMarks( &aRanges, FALSE );
+ String aStr;
+ ScDocument* pDocument = pViewSh->GetViewData()->GetDocument();
+ aRanges.Format( aStr, SCR_ABS_3D, pDocument, pDocument->GetAddressConvention() );
+ aRangeString = aStr;
+
+ // get "total" range for positioning
+ ULONG nCount = aRanges.Count();
+ if ( nCount > 0 )
+ {
+ aPositionRange = *aRanges.GetObject(0);
+ for (ULONG i=1; i<nCount; i++)
+ aPositionRange.ExtendTo( *aRanges.GetObject(i) );
+ }
+
+ if(bAutomaticMark)
+ pViewSh->GetViewData()->GetView()->Unmark();
+ }
+
+ // ----------------------------------------
+ // adapted old code
+ pView->UnmarkAll();
+
+ ::rtl::OUString aName;
+ const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
+
+ uno::Reference < embed::XEmbeddedObject > xObj =
+ pViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID_60 ).GetByteSequence(), aName );
+
+ uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver;
+ uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
+ if( xCompSupp.is())
+ xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+
+ // lock the model to suppress any internal updates
+ uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY );
+ if( xChartModel.is() )
+ xChartModel->lockControllers();
+
+ ScRangeListRef aDummy;
+ Rectangle aMarkDest;
+ SCTAB nMarkTab;
+ BOOL bDrawRect = pViewShell->GetChartArea( aDummy, aMarkDest, nMarkTab );
+
+ // Objekt-Groesse
+ awt::Size aSz = xObj->getVisualAreaSize( nAspect );
+ Size aSize( aSz.Width, aSz.Height );
+
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+
+ BOOL bSizeCh = FALSE;
+ if (bDrawRect && !aMarkDest.IsEmpty())
+ {
+ aSize = aMarkDest.GetSize();
+ bSizeCh = TRUE;
+ }
+ if (aSize.Height() <= 0 || aSize.Width() <= 0)
+ {
+ aSize.Width() = 5000;
+ aSize.Height() = 5000;
+ bSizeCh = TRUE;
+ }
+ if (bSizeCh)
+ {
+ aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) );
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( nAspect, aSz );
+ }
+
+ ScViewData* pData = pViewSh->GetViewData();
+ ScDocShell* pScDocSh = pData->GetDocShell();
+ ScDocument* pScDoc = pScDocSh->GetDocument();
+ BOOL bUndo (pScDoc->IsUndoEnabled());
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ UINT16 nToTable = 0;
+
+ if( IS_AVAILABLE( FN_PARAM_4, &pItem ) )
+ {
+ if ( pItem->ISA( SfxUInt16Item ) )
+ nToTable = ((const SfxUInt16Item*)pItem)->GetValue();
+ else if ( pItem->ISA( SfxBoolItem ) )
+ {
+ // #46033# in der idl fuer Basic steht FN_PARAM_4 als SfxBoolItem
+ // -> wenn gesetzt, neue Tabelle, sonst aktuelle Tabelle
+
+ if ( ((const SfxBoolItem*)pItem)->GetValue() )
+ nToTable = static_cast<UINT16>(pScDoc->GetTableCount());
+ else
+ nToTable = static_cast<UINT16>(pData->GetTabNo());
+ }
+ }
+ else
+ {
+ if (bDrawRect)
+ nToTable = static_cast<UINT16>(nMarkTab);
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_4, nToTable ) );
+ }
+
+ // auf neue Tabelle ausgeben?
+ if ( nToTable == pScDoc->GetTableCount() )
+ {
+ // dann los...
+ String aTabName;
+ SCTAB nNewTab = pScDoc->GetTableCount();
+
+ pScDoc->CreateValidTabName( aTabName );
+
+ if ( pScDoc->InsertTab( nNewTab, aTabName ) )
+ {
+ BOOL bAppend = TRUE;
+
+ if (bUndo)
+ {
+ pScDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( pScDocSh, nNewTab,
+ bAppend, aTabName ) );
+ }
+
+ pScDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ) );
+ pViewSh->SetTabNo( nNewTab, TRUE );
+ pScDocSh->PostPaintExtras(); //! erst hinterher ???
+ }
+ else
+ {
+ DBG_ERROR( "Could not create new table :-/" );
+ }
+ }
+ else if ( nToTable != pData->GetTabNo() )
+ {
+ pViewSh->SetTabNo( nToTable, TRUE );
+ }
+ }
+
+ lcl_ChartInit( xObj, pData, aRangeString ); // set source range, auto-detect column/row headers
+
+ // Objekt-Position
+
+ Point aStart;
+ if ( bDrawRect )
+ aStart = aMarkDest.TopLeft(); // marked by hand
+ else
+ {
+ // get chart position (from window size and data range)
+ aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange );
+ }
+
+ Rectangle aRect (aStart, aSize);
+ SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect);
+
+ // Dieses Objekt nicht vor dem Aktivieren zeichnen
+ // (in MarkListHasChanged kommt ein Update)
+ pSkipPaintObj = pObj;
+
+ SdrPageView* pPV = pView->GetSdrPageView();
+
+// pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immidiate redraw and asks the chart for a visual representation
+
+ // use the page instead of the view to insert, so no undo action is created yet
+ SdrPage* pInsPage = pPV->GetPage();
+ pInsPage->InsertObject( pObj );
+ pView->UnmarkAllObj();
+ pView->MarkObj( pObj, pPV );
+ bool bAddUndo = true; // add undo action later, unless the dialog is canceled
+
+ if (rReq.IsAPI())
+ {
+ if( xChartModel.is() )
+ xChartModel->unlockControllers();
+ }
+ else
+ {
+ //the controller will be unlocked by the dialog when the dialog is told to do so
+
+ // only activate object if not called via API (e.g. macro)
+ pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW );
+
+ //open wizard
+ //@todo get context from calc if that has one
+ uno::Reference< uno::XComponentContext > xContext(
+ ::cppu::defaultBootstrap_InitialComponentContext() );
+ if(xContext.is())
+ {
+ uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
+ if(xMCF.is())
+ {
+ uno::Reference< ui::dialogs::XExecutableDialog > xDialog(
+ xMCF->createInstanceWithContext(
+ rtl::OUString::createFromAscii("com.sun.star.comp.chart2.WizardDialog")
+ , xContext), uno::UNO_QUERY);
+ uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY );
+ if( xChartModel.is() && xInit.is() )
+ {
+ uno::Reference< awt::XWindow > xDialogParentWindow(0);
+ // initialize dialog
+ uno::Sequence<uno::Any> aSeq(2);
+ uno::Any* pArray = aSeq.getArray();
+ beans::PropertyValue aParam1;
+ aParam1.Name = rtl::OUString::createFromAscii("ParentWindow");
+ aParam1.Value <<= uno::makeAny(xDialogParentWindow);
+ beans::PropertyValue aParam2;
+ aParam2.Name = rtl::OUString::createFromAscii("ChartModel");
+ aParam2.Value <<= uno::makeAny(xChartModel);
+ pArray[0] <<= uno::makeAny(aParam1);
+ pArray[1] <<= uno::makeAny(aParam2);
+ xInit->initialize( aSeq );
+
+ // try to set the dialog's position so it doesn't hide the chart
+ uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY );
+ if ( xDialogProps.is() )
+ {
+ try
+ {
+ //get dialog size:
+ awt::Size aDialogAWTSize;
+ if( xDialogProps->getPropertyValue( ::rtl::OUString::createFromAscii("Size") )
+ >>= aDialogAWTSize )
+ {
+ Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height );
+ if ( aDialogSize.Width() > 0 && aDialogSize.Height() > 0 )
+ {
+ //calculate and set new position
+ Point aDialogPos = pViewShell->GetChartDialogPos( aDialogSize, aRect );
+ xDialogProps->setPropertyValue( ::rtl::OUString::createFromAscii("Position"),
+ uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) );
+ }
+ }
+ //tell the dialog to unlock controller
+ xDialogProps->setPropertyValue( ::rtl::OUString::createFromAscii("UnlockControllersOnExecute"),
+ uno::makeAny( sal_True ) );
+
+ }
+ catch( uno::Exception& )
+ {
+ OSL_ASSERT( "Chart wizard couldn't be positioned automatically\n" );
+ }
+ }
+
+ sal_Int16 nDialogRet = xDialog->execute();
+ if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL )
+ {
+ // leave OLE inplace mode and unmark
+ OSL_ASSERT( pViewShell );
+ OSL_ASSERT( pView );
+ pViewShell->DeactivateOle();
+ pView->UnmarkAll();
+
+ // old page view pointer is invalid after switching sheets
+ pPV = pView->GetSdrPageView();
+
+ // remove the chart
+ OSL_ASSERT( pPV );
+ SdrPage * pPage( pPV->GetPage());
+ OSL_ASSERT( pPage );
+ OSL_ASSERT( pObj );
+ if( pPage )
+ pPage->RemoveObject( pObj->GetOrdNum());
+
+ bAddUndo = false; // don't create the undo action for inserting
+
+ // leave the draw shell
+ pViewShell->SetDrawShell( FALSE );
+ }
+ else
+ {
+ OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK );
+ //@todo maybe move chart to different table
+ }
+ }
+ uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY );
+ if( xComponent.is())
+ xComponent->dispose();
+ }
+ }
+ }
+
+ if ( bAddUndo )
+ {
+ // add undo action the same way as in SdrEditView::InsertObjectAtView
+ // (using UndoActionHdl etc.)
+ pView->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+ }
+
+ // BM/IHA --
+ }
+}
+
+/*************************************************************************
+|*
+|* FuInsertChart::Destruktor
+|*
+\************************************************************************/
+
+FuInsertChart::~FuInsertChart()
+{
+}
+
+/*************************************************************************
+|*
+|* FuInsertChart::Function aktivieren
+|*
+\************************************************************************/
+
+void FuInsertChart::Activate()
+{
+ FuPoor::Activate();
+}
+
+/*************************************************************************
+|*
+|* FuInsertChart::Function deaktivieren
+|*
+\************************************************************************/
+
+void FuInsertChart::Deactivate()
+{
+ FuPoor::Deactivate();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fumark.cxx b/sc/source/ui/drawfunc/fumark.cxx
new file mode 100644
index 000000000000..837894551d06
--- /dev/null
+++ b/sc/source/ui/drawfunc/fumark.cxx
@@ -0,0 +1,292 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "fumark.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "scmod.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "drawview.hxx"
+
+//------------------------------------------------------------------
+
+/*************************************************************************
+|*
+|* Funktion zum Aufziehen eines Rechtecks
+|*
+\************************************************************************/
+
+FuMarkRect::FuMarkRect(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq) :
+ FuPoor(pViewSh, pWin, pViewP, pDoc, rReq),
+ bVisible(FALSE),
+ bStartDrag(FALSE)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuMarkRect::~FuMarkRect()
+{
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL FuMarkRect::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ pWindow->CaptureMouse();
+ pView->UnmarkAll(); // der Einheitlichkeit halber und wegen #50558#
+ bStartDrag = TRUE;
+
+ aBeginPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+ aZoomRect = Rectangle( aBeginPos, Size() );
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL FuMarkRect::MouseMove(const MouseEvent& rMEvt)
+{
+ if ( bStartDrag )
+ {
+ if ( bVisible )
+ pViewShell->DrawMarkRect(aZoomRect);
+ Point aPixPos= rMEvt.GetPosPixel();
+ ForceScroll(aPixPos);
+
+ Point aEndPos = pWindow->PixelToLogic(aPixPos);
+ Rectangle aRect(aBeginPos, aEndPos);
+ aZoomRect = aRect;
+ aZoomRect.Justify();
+ pViewShell->DrawMarkRect(aZoomRect);
+ bVisible = TRUE;
+ }
+
+ ForcePointer(&rMEvt);
+
+ return bStartDrag;
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL FuMarkRect::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ if ( bVisible )
+ {
+ // Hide ZoomRect
+ pViewShell->DrawMarkRect(aZoomRect);
+ bVisible = FALSE;
+ }
+
+ Size aZoomSizePixel = pWindow->LogicToPixel(aZoomRect).GetSize();
+
+ USHORT nMinMove = pView->GetMinMoveDistancePixel();
+ if ( aZoomSizePixel.Width() < nMinMove || aZoomSizePixel.Height() < nMinMove )
+ {
+ // Klick auf der Stelle
+
+ aZoomRect.SetSize(Size()); // dann ganz leer
+ }
+
+ bStartDrag = FALSE;
+ pWindow->ReleaseMouse();
+
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
+
+ // Daten an der View merken
+
+ pViewShell->SetChartArea( aSourceRange, aZoomRect );
+
+ // Chart-Dialog starten:
+
+// USHORT nId = ScChartDlgWrapper::GetChildWindowId();
+// SfxChildWindow* pWnd = pViewShell->GetViewFrame()->GetChildWindow( nId );
+// SC_MOD()->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* Command-event
+|*
+\************************************************************************/
+
+BYTE FuMarkRect::Command(const CommandEvent& rCEvt)
+{
+ if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
+ {
+ // #29877# nicht anfangen, auf der Tabelle rumzudraggen,
+ // aber Maus-Status nicht zuruecksetzen
+ return SC_CMD_IGNORE;
+ }
+ else
+ return FuPoor::Command(rCEvt);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL FuMarkRect::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FALSE;
+
+ switch ( rKEvt.GetKeyCode().GetCode() )
+ {
+ case KEY_ESCAPE:
+ // beenden
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ bReturn = TRUE;
+ break;
+ }
+
+ if (!bReturn)
+ {
+ bReturn = FuPoor::KeyInput(rKEvt);
+ }
+
+ return (bReturn);
+}
+
+/*************************************************************************
+|*
+|* Vor dem Scrollen Selektionsdarstellung ausblenden
+|*
+\************************************************************************/
+
+void FuMarkRect::ScrollStart()
+{
+}
+
+/*************************************************************************
+|*
+|* Nach dem Scrollen Selektionsdarstellung wieder anzeigen
+|*
+\************************************************************************/
+
+void FuMarkRect::ScrollEnd()
+{
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuMarkRect::Activate()
+{
+ FuPoor::Activate();
+
+ // Markierung merken, bevor evtl. Tabelle umgeschaltet wird
+
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+ if ( !rMark.IsMultiMarked() && !rMark.IsMarked() )
+ pViewShell->MarkDataArea( TRUE );
+
+ pViewData->GetMultiArea( aSourceRange ); // Mehrfachselektion erlaubt
+
+// pViewShell->Unmark();
+
+ ForcePointer(NULL);
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuMarkRect::Deactivate()
+{
+ FuPoor::Deactivate();
+
+ if (bVisible)
+ {
+ // Hide ZoomRect
+ pViewShell->DrawMarkRect(aZoomRect);
+ bVisible = FALSE;
+ bStartDrag = FALSE;
+ }
+}
+
+/*************************************************************************
+|*
+|* Maus-Pointer umschalten
+|*
+\************************************************************************/
+
+void FuMarkRect::ForcePointer(const MouseEvent* /* pMEvt */)
+{
+ pViewShell->SetActivePointer( Pointer( POINTER_CHART ) );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fupoor.cxx b/sc/source/ui/drawfunc/fupoor.cxx
new file mode 100644
index 000000000000..fa4c089f643a
--- /dev/null
+++ b/sc/source/ui/drawfunc/fupoor.cxx
@@ -0,0 +1,388 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <editeng/outliner.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpagv.hxx>
+
+#include "fupoor.hxx"
+#include "tabvwsh.hxx"
+#include "drawview.hxx"
+#include "detfunc.hxx"
+#include "document.hxx"
+#include <vcl/svapp.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuPoor::FuPoor(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq) :
+ pView(pViewP),
+ pViewShell(pViewSh),
+ pWindow(pWin),
+ pDrDoc(pDoc),
+ aSfxRequest(rReq),
+ pDialog(NULL),
+ bIsInDragMode(FALSE),
+ // #95491# remember MouseButton state
+ mnCode(0)
+{
+ aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) );
+ aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL);
+
+ aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) );
+ aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuPoor::~FuPoor()
+{
+ aDragTimer.Stop();
+ aScrollTimer.Stop();
+
+ if (pDialog)
+ delete pDialog;
+}
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuPoor::Activate()
+{
+ if (pDialog)
+ {
+ pDialog->Show();
+ }
+}
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuPoor::Deactivate()
+{
+ aDragTimer.Stop();
+ aScrollTimer.Stop();
+
+ if (pDialog)
+ {
+ pDialog->Hide();
+ }
+}
+
+/*************************************************************************
+|*
+|* Scrollen bei Erreichen des Fensterrandes; wird von
+|* MouseMove aufgerufen
+|*
+\************************************************************************/
+
+void FuPoor::ForceScroll(const Point& aPixPos)
+{
+ aScrollTimer.Stop();
+
+ Size aSize = pWindow->GetSizePixel();
+ SCsCOL dx = 0;
+ SCsROW dy = 0;
+
+ if ( aPixPos.X() <= 0 ) dx = -1;
+ if ( aPixPos.X() >= aSize.Width() ) dx = 1;
+ if ( aPixPos.Y() <= 0 ) dy = -1;
+ if ( aPixPos.Y() >= aSize.Height() ) dy = 1;
+
+ ScViewData* pViewData = pViewShell->GetViewData();
+ if ( pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() ) )
+ dx = -dx;
+
+ ScSplitPos eWhich = pViewData->GetActivePart();
+ if ( dx > 0 && pViewData->GetHSplitMode() == SC_SPLIT_FIX && WhichH(eWhich) == SC_SPLIT_LEFT )
+ {
+ pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
+ SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
+ dx = 0;
+ }
+ if ( dy > 0 && pViewData->GetVSplitMode() == SC_SPLIT_FIX && WhichV(eWhich) == SC_SPLIT_TOP )
+ {
+ pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ?
+ SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
+ dy = 0;
+ }
+
+ if ( dx != 0 || dy != 0 )
+ {
+ ScrollStart(); // Scrollaktion in abgeleiteter Klasse
+ pViewShell->ScrollLines(2*dx, 4*dy);
+ ScrollEnd();
+ aScrollTimer.Start();
+ }
+}
+
+/*************************************************************************
+|*
+|* Timer-Handler fuer Fensterscrolling
+|*
+\************************************************************************/
+
+IMPL_LINK_INLINE_START( FuPoor, ScrollHdl, Timer *, EMPTYARG )
+{
+ Point aPosPixel = pWindow->GetPointerPosPixel();
+
+ // #95491# use remembered MouseButton state to create correct
+ // MouseEvents for this artifical MouseMove.
+ MouseMove(MouseEvent(aPosPixel, 1, 0, GetMouseButtonCode()));
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( FuPoor, ScrollHdl, Timer *, pTimer )
+
+// #95491# moved from inline to *.cxx
+BOOL FuPoor::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ return FALSE;
+}
+
+// #95491# moved from inline to *.cxx
+BOOL FuPoor::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ return FALSE;
+}
+
+/*************************************************************************
+|*
+|* String in Applikations-Statuszeile ausgeben
+|*
+\************************************************************************/
+
+// WriteStatus gibt's nicht mehr
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL FuPoor::KeyInput(const KeyEvent& /* rKEvt */)
+{
+ BOOL bReturn = FALSE;
+
+ return(bReturn);
+}
+
+BYTE FuPoor::Command(const CommandEvent& rCEvt)
+{
+ if ( COMMAND_STARTDRAG == rCEvt.GetCommand() )
+ {
+ //!!! sollte Joe eigentlich machen:
+ // nur, wenn im Outliner was selektiert ist, darf
+ // Command TRUE zurueckliefern:
+
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+
+ if ( pOutView )
+ return pOutView->HasSelection() ? pView->Command(rCEvt,pWindow) : SC_CMD_NONE;
+ else
+ return pView->Command(rCEvt,pWindow);
+ }
+ else
+ return pView->Command(rCEvt,pWindow);
+}
+
+/*************************************************************************
+|*
+|* Cut object to clipboard
+|*
+\************************************************************************/
+
+void FuPoor::DoCut()
+{
+ if (pView)
+ {
+//! pView->DoCut(pWindow);
+ }
+}
+
+/*************************************************************************
+|*
+|* Copy object to clipboard
+|*
+\************************************************************************/
+
+void FuPoor::DoCopy()
+{
+ if (pView)
+ {
+//! pView->DoCopy(pWindow);
+ }
+}
+
+/*************************************************************************
+|*
+|* Paste object from clipboard
+|*
+\************************************************************************/
+
+void FuPoor::DoPaste()
+{
+ if (pView)
+ {
+//! pView->DoPaste(pWindow);
+ }
+}
+
+/*************************************************************************
+|*
+|* Timer-Handler fuer Drag&Drop
+|*
+\************************************************************************/
+
+IMPL_LINK( FuPoor, DragTimerHdl, Timer *, EMPTYARG )
+{
+ // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer
+ // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei
+ // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der
+ // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft
+ // dann um die Dauer des Drag&Drop zu spaet ab.
+ // Darum Drag&Drop aus eigenem Event:
+
+ Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) );
+ return 0;
+}
+
+IMPL_LINK( FuPoor, DragHdl, void *, EMPTYARG )
+{
+ SdrHdl* pHdl = pView->PickHandle(aMDPos);
+
+ if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) )
+ {
+ pWindow->ReleaseMouse();
+ bIsInDragMode = TRUE;
+
+// pView->BeginDrag(pWindow, aMDPos);
+ pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos);
+ }
+ return 0;
+}
+
+// Detektiv-Linie
+
+BOOL FuPoor::IsDetectiveHit( const Point& rLogicPos )
+{
+ SdrPageView* pPV = pView->GetSdrPageView();
+ if (!pPV)
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !bFound)
+ {
+ if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
+ {
+ USHORT nHitLog = (USHORT) pWindow->PixelToLogic(
+ Size(pView->GetHitTolerancePixel(),0)).Width();
+ if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false))
+ {
+ bFound = TRUE;
+ }
+ }
+
+ pObject = aIter.Next();
+ }
+ return bFound;
+}
+
+void FuPoor::StopDragTimer()
+{
+ if (aDragTimer.IsActive() )
+ aDragTimer.Stop();
+}
+
+/*************************************************************************
+|*
+|* #98185# Create default drawing objects via keyboard
+|*
+\************************************************************************/
+
+SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */)
+{
+ // empty base implementation
+ return 0L;
+}
+
+void FuPoor::ImpForceQuadratic(Rectangle& rRect)
+{
+ if(rRect.GetWidth() > rRect.GetHeight())
+ {
+ rRect = Rectangle(
+ Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()),
+ Size(rRect.GetHeight(), rRect.GetHeight()));
+ }
+ else
+ {
+ rRect = Rectangle(
+ Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)),
+ Size(rRect.GetWidth(), rRect.GetWidth()));
+ }
+}
+
+// #i33136#
+bool FuPoor::doConstructOrthogonal() const
+{
+ return false;
+}
+
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx
new file mode 100644
index 000000000000..a7a08487fadf
--- /dev/null
+++ b/sc/source/ui/drawfunc/fusel.cxx
@@ -0,0 +1,657 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <com/sun/star/embed/EmbedStates.hpp>
+
+#include <editeng/eeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdotext.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/imapobj.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdpagv.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdocapt.hxx>
+#include <sfx2/app.hxx>
+
+#include "fusel.hxx"
+#include "sc.hrc"
+#include "fudraw.hxx"
+#include "futext.hxx"
+#include "drawview.hxx"
+#include "tabvwsh.hxx"
+#include "drawpage.hxx"
+#include "globstr.hrc"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include "scmod.hxx"
+
+// -----------------------------------------------------------------------
+
+// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
+//! fusel,fuconstr,futext - zusammenfassen!
+#define SC_MAXDRAGMOVE 3
+
+// -----------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+using namespace com::sun::star;
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+FuSelection::FuSelection(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq ) :
+ FuDraw(pViewSh, pWin, pViewP, pDoc, rReq),
+ bVCAction(FALSE)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuSelection::~FuSelection()
+{
+}
+
+BYTE FuSelection::Command(const CommandEvent& rCEvt)
+{
+ // special code for non-VCL OS2/UNX removed
+
+ return FuDraw::Command( rCEvt );
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuSelection::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+ const bool bSelectionOnly = rMEvt.IsRight();
+ if ( pView->IsAction() )
+ {
+ if ( bSelectionOnly )
+ pView->BckAction();
+ return TRUE;
+ }
+
+ bVCAction = FALSE;
+ bIsInDragMode = FALSE; // irgendwo muss es ja zurueckgesetzt werden (#50033#)
+
+ BOOL bReturn = FuDraw::MouseButtonDown(rMEvt);
+
+ aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+
+ if ( rMEvt.IsLeft() )
+ {
+ SdrHdl* pHdl = pView->PickHandle(aMDPos);
+ SdrObject* pObj;
+ SdrPageView* pPV;
+
+ if ( pHdl!=NULL || pView->IsMarkedHit(aMDPos) )
+ {
+ // Determine if this is the tail of a SdrCaptionObj i.e.
+ // we need to disable the drag option on the tail of a note
+ // object. Also, disable the ability to use the circular
+ // drag of a note object.
+ bool bDrag = false;
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
+ {
+ // move using the valid caption handles for note text box.
+ if(pHdl && (pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC))
+ bDrag = true;
+ // move the complete note box.
+ else if(!pHdl)
+ bDrag = true;
+ }
+ else
+ bDrag = true; // different object
+ }
+ else
+ bDrag = true; // several objects
+
+ if ( bDrag )
+ {
+ aDragTimer.Start();
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
+ bReturn = TRUE;
+ }
+ }
+ else
+ {
+ BOOL bAlt = rMEvt.IsMod2();
+ if ( !bAlt && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
+ {
+ pView->BegMacroObj(aMDPos, pObj, pPV, pWindow);
+ bReturn = TRUE;
+ }
+ else
+ {
+ String sURL, sTarget;
+ if ( !bAlt && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER))
+ {
+ // Support for imported Excel docs
+ // Excel is of course not consistent and allows
+ // a hyperlink to be assigned for an object group
+ // and even though the hyperlink is exported in the Escher layer
+ // its never used, when dealing with a group object the link
+ // associated with the clicked object is used only
+
+ // additionally you can also select a macro in Excel for a grouped
+ // objects and this results in the macro being set for the elements
+ // in the group and no macro is exported for the group
+
+ // if a macro and hlink are defined favour the hlink
+
+ // If a group object has no hyperlink use the hyperlink of the
+ // object clicked
+
+ if ( pObj->IsGroupObject() )
+ {
+ SdrObject* pHit = NULL;
+ if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
+ pObj = pHit;
+ }
+
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE );
+ // For interoperability favour links over macros if both are defined
+ if ( pInfo->GetHlink().getLength() > 0 )
+ {
+ OSL_TRACE("** Got URL");
+ sURL = pInfo->GetHlink();
+ }
+ else if ( pInfo->GetMacro().getLength() > 0 )
+ {
+ SfxObjectShell* pObjSh = SfxObjectShell::Current();
+ if ( pObjSh && SfxApplication::IsXScriptURL( pInfo->GetMacro() ) )
+ {
+ uno::Reference< beans::XPropertySet > xProps( pObj->getUnoShape(), uno::UNO_QUERY );
+ uno::Any aCaller;
+ if ( xProps.is() )
+ {
+ try
+ {
+ aCaller = xProps->getPropertyValue( rtl::OUString::createFromAscii("Name") );
+ }
+ catch( uno::Exception& ) {}
+ }
+ uno::Any aRet;
+ uno::Sequence< sal_Int16 > aOutArgsIndex;
+ uno::Sequence< uno::Any > aOutArgs;
+ uno::Sequence< uno::Any >* pInArgs =
+ new uno::Sequence< uno::Any >(0);
+ pObjSh->CallXScript( pInfo->GetMacro(),
+ *pInArgs, aRet, aOutArgsIndex, aOutArgs, true, &aCaller );
+ pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() );
+ return TRUE; // kein CaptureMouse etc.
+ }
+ }
+ }
+
+ // URL / ImageMap
+
+ SdrViewEvent aVEvt;
+ if ( !bAlt &&
+ pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt ) != SDRHIT_NONE &&
+ aVEvt.pObj != NULL )
+ {
+ if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) ) // ImageMap
+ {
+ const IMapObject* pIMapObj =
+ ScDrawLayer::GetHitIMapObject( aVEvt.pObj, aMDPos, *pWindow );
+ if ( pIMapObj && pIMapObj->GetURL().Len() )
+ {
+ sURL = pIMapObj->GetURL();
+ sTarget = pIMapObj->GetTarget();
+ }
+ }
+ if ( aVEvt.eEvent == SDREVENT_EXECUTEURL && aVEvt.pURLField ) // URL
+ {
+ sURL = aVEvt.pURLField->GetURL();
+ sTarget = aVEvt.pURLField->GetTargetFrame();
+ }
+ }
+
+ // open hyperlink, if found at object or in object's text
+ if ( sURL.Len() > 0 )
+ {
+ ScGlobal::OpenURL( sURL, sTarget );
+ pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() );
+ return TRUE; // kein CaptureMouse etc.
+ }
+
+ // Is another object being edited in this view?
+ // (Editing is ended in MarkListHasChanged - test before UnmarkAll)
+ SfxInPlaceClient* pClient = pViewShell->GetIPClient();
+ BOOL bWasOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
+
+ // Markieren
+
+ // do not allow multiselection with note caption
+ bool bCaptionClicked = IsNoteCaptionClicked( aMDPos );
+ if ( !rMEvt.IsShift() || bCaptionClicked || IsNoteCaptionMarked() )
+ pView->UnmarkAll();
+
+ /* Unlock internal layer, if a note caption is clicked. The
+ layer will be relocked in ScDrawView::MarkListHasChanged(). */
+ if( bCaptionClicked )
+ pView->UnlockInternalLayer();
+
+ // try to select the clicked object
+ if ( pView->MarkObj( aMDPos, -2, FALSE, rMEvt.IsMod1() ) )
+ {
+ //*********************************************************
+ //Objekt verschieben
+ //********************************************************
+ if (pView->IsMarkedHit(aMDPos))
+ {
+ // #95834# Don't start drag timer if inplace editing of an OLE object
+ // was just ended with this mouse click - the view will be moved
+ // (different tool bars) and the object that was clicked on would
+ // be moved unintentionally.
+ if ( !bWasOleActive )
+ aDragTimer.Start();
+
+ pHdl=pView->PickHandle(aMDPos);
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
+ bReturn = TRUE;
+ }
+ else // Objekt am Rand getroffen
+ if (pViewShell->IsDrawSelMode())
+ bReturn = TRUE;
+ }
+ else
+ {
+ // nichts getroffen
+
+ if (pViewShell->IsDrawSelMode())
+ {
+ //*********************************************************
+ //Objekt selektieren
+ //********************************************************
+ pView->BegMarkObj(aMDPos);
+ bReturn = TRUE;
+ }
+ }
+ }
+ }
+
+ }
+
+ if (!bIsInDragMode)
+ {
+ if (!bVCAction) // VC rufen selber CaptureMouse
+ pWindow->CaptureMouse();
+ ForcePointer(&rMEvt);
+ }
+
+ return bReturn;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuSelection::MouseMove(const MouseEvent& rMEvt)
+{
+ BOOL bReturn = FuDraw::MouseMove(rMEvt);
+
+ if (aDragTimer.IsActive() )
+ {
+ Point aOldPixel = pWindow->LogicToPixel( aMDPos );
+ Point aNewPixel = rMEvt.GetPosPixel();
+ if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
+ Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
+ aDragTimer.Stop();
+ }
+
+ if ( pView->IsAction() )
+ {
+ Point aPix(rMEvt.GetPosPixel());
+ Point aPnt(pWindow->PixelToLogic(aPix));
+
+ ForceScroll(aPix);
+ pView->MovAction(aPnt);
+ bReturn = TRUE;
+ }
+
+ // Ein VCControl ist aktiv
+ // Event an den Manager weiterleiten
+ if( bVCAction )
+ {
+ // GetSbxForm gibts nicht mehr - Basic-Controls sind tot
+ //SdrPageView* pPgView = pView->GetPageViewByIndex(0);
+ //ScDrawPage* pPage = (ScDrawPage*)pPgView->GetPage();
+ //VCSbxForm* pForm = (VCSbxForm*)(SbxObject*)(pPage->GetSbxForm());
+ //((VCManager*)(pForm->GetVCContainer()))->
+ // MouseMove( pWindow, rMEvt );
+ bReturn = TRUE;
+ }
+
+ ForcePointer(&rMEvt);
+
+ return (bReturn);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FuDraw::MouseButtonUp(rMEvt);
+// BOOL bOle = pViewShell->GetViewData()->IsOle();
+ BOOL bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace();
+
+ if (aDragTimer.IsActive() )
+ {
+ aDragTimer.Stop();
+ }
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( rMEvt.IsLeft() )
+ {
+ if ( pView->IsDragObj() )
+ {
+ /******************************************************************
+ * Objekt wurde verschoben
+ ******************************************************************/
+ pView->EndDragObj( rMEvt.IsMod1() );
+ pView->ForceMarkedToAnotherPage();
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
+ FuText* pText = static_cast<FuText*>(pPoor);
+ pText->StopDragMode(pObj );
+ }
+ bReturn = TRUE;
+ }
+ else if (pView->IsAction() )
+ {
+ // unlock internal layer to include note captions
+ pView->UnlockInternalLayer();
+ pView->EndAction();
+ if ( pView->AreObjectsMarked() )
+ {
+ bReturn = TRUE;
+
+ /* if multi-selection contains a note caption object, remove
+ all other objects from selection. */
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ ULONG nCount = rMarkList.GetMarkCount();
+ if( nCount > 1 )
+ {
+ bool bFound = false;
+ for( ULONG nIdx = 0; !bFound && (nIdx < nCount); ++nIdx )
+ {
+ SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj();
+ bFound = ScDrawLayer::IsNoteCaption( pObj );
+ if( bFound )
+ {
+ pView->UnMarkAll();
+ pView->MarkObj( pObj, pView->GetSdrPageView() );
+ }
+ }
+ }
+ }
+ }
+ }
+
+/*
+ if ( pView->IsObjEdit() )
+ {
+ BOOL bShowCursor = TRUE;
+//! pOutlinerView = pView->GetOutlinerView(pWindow, bShowCursor);
+ bReturn = TRUE;
+ }
+*/
+ /**************************************************************************
+ * Ggf. OLE-Objekt beruecksichtigen
+ **************************************************************************/
+ SfxInPlaceClient* pIPClient = pViewShell->GetIPClient();
+
+ if (pIPClient)
+ {
+ ScModule* pScMod = SC_MOD();
+ bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
+
+ if ( pIPClient->IsObjectInPlaceActive() && !bUnoRefDialog )
+ pIPClient->DeactivateObject();
+ }
+
+ USHORT nClicks = rMEvt.GetClicks();
+ if ( nClicks == 2 && rMEvt.IsLeft() )
+ {
+ if ( pView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ // #43984# aktivieren nur, wenn die Maus auch (noch) ueber dem
+ // selektierten Objekt steht
+
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
+ if ( eHit != SDRHIT_NONE && aVEvt.pObj == pObj )
+ {
+ UINT16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ //
+ // OLE: aktivieren
+ //
+
+ if (nSdrObjKind == OBJ_OLE2)
+ {
+ if (!bOle)
+ {
+ if (((SdrOle2Obj*) pObj)->GetObjRef().is())
+ {
+ //HMHpView->HideMarkHdl();
+ pViewShell->ActivateObject( (SdrOle2Obj*) pObj, 0 );
+ }
+ }
+ }
+
+ //
+ // Edit text
+ // #49458# not in UNO controls
+ // #i32352# not in media objects
+ //
+ else if ( pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) && !pObj->ISA(SdrMediaObj) )
+ {
+ OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
+ BOOL bVertical = ( pOPO && pOPO->IsVertical() );
+ USHORT nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT;
+
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
+
+ // jetzt den erzeugten FuText holen und in den EditModus setzen
+ FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
+ if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // hat keine RTTI
+ {
+ FuText* pText = (FuText*)pPoor;
+ Point aMousePixel = rMEvt.GetPosPixel();
+ pText->SetInEditMode( pObj, &aMousePixel );
+ }
+ bReturn = TRUE;
+ }
+ }
+ }
+ }
+ else if ( TestDetective( pView->GetSdrPageView(), aPnt ) )
+ bReturn = TRUE;
+ }
+
+ // Ein VCControl ist aktiv
+ // Event an den Manager weiterleiten
+ if( bVCAction )
+ {
+ // GetSbxForm gibts nicht mehr - Basic-Controls sind tot
+ //SdrPageView* pPgView = pView->GetPageViewByIndex(0);
+ //ScDrawPage* pPage = (ScDrawPage*)pPgView->GetPage();
+ //VCSbxForm* pForm = (VCSbxForm*)(SbxObject*)(pPage->GetSbxForm());
+ //((VCManager*)(pForm->GetVCContainer()))->
+ // MouseButtonUp( pWindow, rMEvt );
+ //HMHpView->ShowMarkHdl();
+ bVCAction = FALSE;
+ bReturn = TRUE;
+ }
+
+ ForcePointer(&rMEvt);
+
+ pWindow->ReleaseMouse();
+
+ // Command-Handler fuer Kontext-Menue kommt erst nach MouseButtonUp,
+ // darum hier die harte IsLeft-Abfrage
+ if ( !bReturn && rMEvt.IsLeft() )
+ if (pViewShell->IsDrawSelMode())
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+
+ return (bReturn);
+}
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL FuSelection::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FALSE;
+
+ if (!bReturn)
+ {
+ bReturn = FuDraw::KeyInput(rKEvt);
+ }
+
+ return(bReturn);
+}
+
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuSelection::Activate()
+{
+/*
+ SdrDragMode eMode;
+ switch (aSfxRequest.GetSlot() )
+ {
+ case SID_OBJECT_SELECT:
+ eMode = SDRDRAG_MOVE;
+ break;
+ case SID_OBJECT_ROTATE:
+ eMode = SDRDRAG_ROTATE;
+ break;
+ case SID_OBJECT_MIRROR:
+ eMode = SDRDRAG_MIRROR;
+ break;
+ }
+ pView->SetDragMode(eMode);
+*/
+ FuDraw::Activate();
+}
+
+
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuSelection::Deactivate()
+{
+ /**************************************************************************
+ * Hide Cursor
+ **************************************************************************/
+// BOOL bShowCursor = FALSE;
+//! pOutlinerView = pView->GetOutlinerView(pWindow, bShowCursor);
+
+// pView->SetDragMode(SDRDRAG_MOVE);
+ FuDraw::Deactivate();
+}
+
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/fusel2.cxx b/sc/source/ui/drawfunc/fusel2.cxx
new file mode 100644
index 000000000000..cfa421c97230
--- /dev/null
+++ b/sc/source/ui/drawfunc/fusel2.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svditer.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpagv.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/outliner.hxx>
+
+#include "fusel.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "detfunc.hxx"
+#include "futext.hxx"
+#include "sc.hrc"
+#include "attrib.hxx"
+#include "scitems.hxx"
+#include "userdat.hxx"
+#include "drwlayer.hxx"
+#include "docsh.hxx"
+#include "drawview.hxx"
+#include <svx/sdrhittesthelper.hxx>
+
+// -----------------------------------------------------------------------
+
+inline long Diff( const Point& rP1, const Point& rP2 )
+{
+ long nX = rP1.X() - rP2.X();
+ if (nX<0) nX = -nX;
+ long nY = rP1.Y() - rP2.Y();
+ if (nY<0) nY = -nY;
+ return nX+nY;
+}
+
+BOOL FuSelection::TestDetective( SdrPageView* pPV, const Point& rPos )
+{
+ if (!pPV)
+ return FALSE;
+
+ BOOL bFound = FALSE;
+ SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !bFound)
+ {
+ if (ScDetectiveFunc::IsNonAlienArrow( pObject ))
+ {
+ USHORT nHitLog = (USHORT) pWindow->PixelToLogic(
+ Size(pView->GetHitTolerancePixel(),0)).Width();
+ if (SdrObjectPrimitiveHit(*pObject, rPos, nHitLog, *pPV, 0, false))
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScSplitPos ePos = pViewShell->FindWindow( pWindow );
+ Point aLineStart = pObject->GetPoint(0);
+ Point aLineEnd = pObject->GetPoint(1);
+ Point aPixel = pWindow->LogicToPixel( aLineStart );
+ SCsCOL nStartCol;
+ SCsROW nStartRow;
+ pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), ePos, nStartCol, nStartRow );
+ aPixel = pWindow->LogicToPixel( aLineEnd );
+ SCsCOL nEndCol;
+ SCsROW nEndRow;
+ pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), ePos, nEndCol, nEndRow );
+ SCsCOL nCurX = (SCsCOL) pViewData->GetCurX();
+ SCsROW nCurY = (SCsROW) pViewData->GetCurY();
+ BOOL bStart = ( Diff( rPos,aLineStart ) > Diff( rPos,aLineEnd ) );
+ if ( nCurX == nStartCol && nCurY == nStartRow )
+ bStart = FALSE;
+ else if ( nCurX == nEndCol && nCurY == nEndRow )
+ bStart = TRUE;
+
+ SCsCOL nDifX;
+ SCsROW nDifY;
+ if ( bStart )
+ {
+ nDifX = nStartCol - nCurX;
+ nDifY = nStartRow - nCurY;
+ }
+ else
+ {
+ nDifX = nEndCol - nCurX;
+ nDifY = nEndRow - nCurY;
+ }
+ pViewShell->MoveCursorRel( nDifX, nDifY, SC_FOLLOW_JUMP, FALSE );
+
+ bFound = TRUE;
+ }
+ }
+
+ pObject = aIter.Next();
+ }
+ return bFound;
+}
+
+bool FuSelection::IsNoteCaptionMarked() const
+{
+ if( pView )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ return ScDrawLayer::IsNoteCaption( pObj );
+ }
+ }
+ return false;
+}
+
+bool FuSelection::IsNoteCaptionClicked( const Point& rPos ) const
+{
+ SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0;
+ if( pPageView )
+ {
+ const ScViewData& rViewData = *pViewShell->GetViewData();
+ ScDocument& rDoc = *rViewData.GetDocument();
+ SCTAB nTab = rViewData.GetTabNo();
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ bool bProtectDoc = rDoc.IsTabProtected( nTab ) || (pDocSh && pDocSh->IsReadOnly());
+
+ // search the last object (on top) in the object list
+ SdrObjListIter aIter( *pPageView->GetObjList(), IM_DEEPNOGROUPS, TRUE );
+ for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
+ {
+ if( pObj->GetLogicRect().IsInside( rPos ) )
+ {
+ if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, nTab ) )
+ {
+ const ScAddress& rNotePos = pCaptData->maStart;
+ // skip caption objects of notes in protected cells
+ const ScProtectionAttr* pProtAttr = static_cast< const ScProtectionAttr* >( rDoc.GetAttr( rNotePos.Col(), rNotePos.Row(), nTab, ATTR_PROTECTION ) );
+ bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell();
+ if( !bProtectAttr || !bProtectDoc )
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+void FuSelection::ActivateNoteHandles(SdrObject* pObject)
+{
+ if( pView && ScDrawLayer::IsNoteCaption( pObject ) )
+ {
+ // Leave the internal layer unlocked - relock in ScDrawView::MarkListHasChanged()
+ pView->UnlockInternalLayer();
+ pView->MarkObj( pObject, pView->GetSdrPageView() );
+ }
+}
+
+//==================================================================
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx
new file mode 100644
index 000000000000..72f2f011e5d2
--- /dev/null
+++ b/sc/source/ui/drawfunc/futext.cxx
@@ -0,0 +1,884 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <svx/svddef.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/sdtaaitm.hxx>
+#include <svx/sdtacitm.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/svdocapt.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/eeitem.hxx>
+#include <svl/itemset.hxx>
+
+#include "futext.hxx"
+#include "drwlayer.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "drawview.hxx"
+
+// #98185# Create default drawing objects via keyboard
+#include "scresid.hxx"
+
+// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten
+//! fusel,fuconstr,futext - zusammenfassen!
+#define SC_MAXDRAGMOVE 3
+
+//------------------------------------------------------------------
+
+void lcl_InvalidateAttribs( SfxBindings& rBindings )
+{
+ rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+ rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
+ rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ rBindings.Invalidate( SID_ALIGNLEFT );
+ rBindings.Invalidate( SID_ALIGNCENTERHOR );
+ rBindings.Invalidate( SID_ALIGNRIGHT );
+ rBindings.Invalidate( SID_ALIGNBLOCK );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
+ rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
+ rBindings.Invalidate( SID_SET_SUB_SCRIPT );
+ rBindings.Invalidate( SID_HYPERLINK_GETLINK );
+ rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ // pseudo slots for Format menu
+ rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
+ rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
+ rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+}
+
+void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj )
+{
+ // use hyphenator only if hyphenation attribute is set
+ if ( pObj && ((const SfxBoolItem&)pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) {
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() );
+ rOutliner.SetHyphenator( xHyphenator );
+ }
+}
+
+/*************************************************************************
+|*
+|* Basisklasse fuer Textfunktionen
+|*
+\************************************************************************/
+
+FuText::FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP,
+ SdrModel* pDoc, SfxRequest& rReq) :
+ FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq),
+ pTextObj(NULL)
+{
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+FuText::~FuText()
+{
+// StopEditMode(); // in Deactivate !
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuText::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ if ( pView->MouseButtonDown(rMEvt, pWindow) )
+ return (TRUE); // Event von der SdrView ausgewertet
+
+ if ( pView->IsTextEdit() )
+ {
+ if( !IsSizingOrMovingNote(rMEvt) )
+ StopEditMode(); // Danebengeklickt, Ende mit Edit
+ pView->SetCreateMode();
+ }
+
+ aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() );
+
+ if ( rMEvt.IsLeft() )
+ {
+ SdrHdl* pHdl = pView->PickHandle(aMDPos);
+
+ ULONG nHdlNum = pView->GetHdlNum(pHdl);
+
+ if (pHdl != NULL)
+ {
+ if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl))
+ {
+ BOOL bPointMarked=pView->IsPointMarked(*pHdl);
+
+ if ( rMEvt.IsShift() )
+ {
+ if (!bPointMarked)
+ {
+ pView->MarkPoint(*pHdl);
+ }
+ else
+ {
+ pView->UnmarkPoint(*pHdl);
+ }
+ }
+ else
+ {
+ if (!bPointMarked)
+ {
+ pView->UnmarkAllPoints();
+ pView->MarkPoint(*pHdl);
+ }
+ }
+ pHdl=pView->GetHdl(nHdlNum);
+ }
+ }
+
+ SdrObject* pObj;
+ SdrPageView* pPV;
+
+ if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) )
+ {
+ if (pHdl == NULL &&
+// pView->TakeTextEditObject(aMDPos, pObj, pPV) )
+ pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT) )
+ {
+ SdrOutliner* pO = MakeOutliner();
+ lcl_UpdateHyphenator( *pO, pObj );
+
+ // vertical flag:
+ // deduced from slot ids only if text object has no content
+
+ USHORT nSlotID = aSfxRequest.GetSlot();
+ BOOL bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
+ OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
+ if ( pOPO )
+ bVertical = pOPO->IsVertical(); // content wins
+ pO->SetVertical( bVertical );
+
+ //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
+ if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
+ {
+ // EditEngine-UndoManager anmelden
+ pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
+
+ OutlinerView* pOLV = pView->GetTextEditOutlinerView();
+ if ( pOLV->MouseButtonDown(rMEvt) )
+ return (TRUE); // Event an den Outliner
+ }
+ }
+ else
+ {
+ // disable tail & circular move for caption objects.
+ bool bDrag = false;
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( ScDrawLayer::IsNoteCaption( pMarkedObj ) )
+ {
+ if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)
+ bDrag = true;
+ }
+ else
+ bDrag = true; // different object
+ }
+ else
+ bDrag = true; // several objects
+
+ if ( bDrag )
+ {
+ aDragTimer.Start();
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
+ }
+ }
+ }
+ else
+ {
+ BOOL bMacro = FALSE;
+
+// if (bMacro && pView->TakeMacroObject(aMDPos,pObj,pPV))
+ if (bMacro && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) )
+
+ {
+ pView->BegMacroObj(aMDPos,pObj,pPV,pWindow);
+ }
+ else
+ {
+ if (pView->IsEditMode())
+ {
+ BOOL bPointMode=pView->HasMarkablePoints();
+
+ if (!rMEvt.IsShift())
+ {
+ if (bPointMode)
+ {
+ pView->UnmarkAllPoints();
+ }
+ else
+ {
+ pView->UnmarkAll();
+ }
+
+ pView->SetDragMode(SDRDRAG_MOVE);
+ SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_OBJECT_ROTATE );
+ rBindings.Invalidate( SID_OBJECT_MIRROR );
+ pHdl=pView->GetHdl(nHdlNum);
+ }
+
+ if ( pView->MarkObj(aMDPos, -2, FALSE, rMEvt.IsMod1()) )
+ {
+ aDragTimer.Start();
+
+ pHdl=pView->PickHandle(aMDPos);
+
+ if (pHdl!=NULL)
+ {
+ pView->MarkPoint(*pHdl);
+ pHdl=pView->GetHdl(nHdlNum);
+ }
+
+ pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl);
+ }
+ else
+ {
+ if (bPointMode)
+ {
+ pView->BegMarkPoints(aMDPos);
+ }
+ else
+ {
+ pView->BegMarkObj(aMDPos);
+ }
+ }
+ }
+ else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT )
+ {
+ // Notizen editieren -> keine neuen Textobjekte erzeugen,
+ // stattdessen Textmodus verlassen
+
+ pViewShell->GetViewData()->GetDispatcher().
+ Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ }
+ else
+ {
+ /**********************************************************
+ * Objekt erzeugen
+ **********************************************************/
+ pView->BegCreateObj(aMDPos, (OutputDevice*) NULL);
+ }
+ }
+ }
+ }
+
+
+ if (!bIsInDragMode)
+ {
+ pWindow->CaptureMouse();
+// ForcePointer(&rMEvt);
+ lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
+ }
+
+ pViewShell->SetActivePointer(pView->GetPreferedPointer(
+ pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
+
+// return (bReturn);
+ return TRUE;
+}
+
+/*************************************************************************
+|*
+|* MouseMove-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuText::MouseMove(const MouseEvent& rMEvt)
+{
+ BOOL bReturn = FALSE;
+
+// pViewShell->SetActivePointer(aNewPointer);
+
+ pViewShell->SetActivePointer(pView->GetPreferedPointer(
+ pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow ));
+
+ if (aDragTimer.IsActive() )
+ {
+ Point aOldPixel = pWindow->LogicToPixel( aMDPos );
+ Point aNewPixel = rMEvt.GetPosPixel();
+ if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE ||
+ Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE )
+ aDragTimer.Stop();
+ }
+
+ if ( pView->MouseMove(rMEvt, pWindow) )
+ return (TRUE); // Event von der SdrView ausgewertet
+
+ if ( pView->IsAction() )
+ {
+/* aNewPointer = Pointer(POINTER_TEXT);
+ pViewShell->SetActivePointer(aNewPointer);
+*/
+ Point aPix(rMEvt.GetPosPixel());
+ Point aPnt(pWindow->PixelToLogic(aPix));
+
+ ForceScroll(aPix);
+ pView->MovAction(aPnt);
+ }
+
+// ForcePointer(&rMEvt);
+
+ return (bReturn);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-event
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuText::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ // #95491# remember button state for creation of own MouseEvents
+ SetMouseButtonCode(rMEvt.GetButtons());
+
+ BOOL bReturn = FALSE;
+
+ if (aDragTimer.IsActive() )
+ {
+ aDragTimer.Stop();
+ }
+
+ lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
+
+ Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
+
+ if ( pView->MouseButtonUp(rMEvt, pWindow) )
+ return (TRUE); // Event von der SdrView ausgewertet
+
+ if ( pView->IsDragObj() )
+ {
+ pView->EndDragObj( rMEvt.IsShift() );
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr();
+ FuText* pText = static_cast<FuText*>(pPoor);
+ pText->StopDragMode(pObj );
+ }
+ pView->ForceMarkedToAnotherPage();
+ }
+ else if ( pView->IsCreateObj() )
+ {
+ if (rMEvt.IsLeft())
+ {
+ pView->EndCreateObj(SDRCREATE_FORCEEND);
+ if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE)
+ {
+ // Lauftext-Objekt erzeugen?
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMark(0))
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ // die fuer das Scrollen benoetigten Attribute setzen
+ SfxItemSet aItemSet( pDrDoc->GetItemPool(),
+ SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
+
+ aItemSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
+ aItemSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
+ aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
+ aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
+ aItemSet.Put( SdrTextAniCountItem( 1 ) );
+ aItemSet.Put( SdrTextAniAmountItem(
+ (INT16)pWindow->PixelToLogic(Size(2,1)).Width()) );
+ pObj->SetMergedItemSetAndBroadcast(aItemSet);
+ }
+ }
+
+ // #93382# init object different when vertical writing
+ sal_uInt16 nSlotID(aSfxRequest.GetSlot());
+ BOOL bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID);
+ if(bVertical)
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if(rMarkList.GetMark(0))
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if(pObj && pObj->ISA(SdrTextObj))
+ {
+ SdrTextObj* pText = (SdrTextObj*)pObj;
+ SfxItemSet aSet(pDrDoc->GetItemPool());
+
+ pText->SetVerticalWriting(TRUE);
+
+ aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
+ aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
+ aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
+ aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
+
+ pText->SetMergedItemSet(aSet);
+ }
+ }
+ }
+
+ SetInEditMode();
+
+ // Modus verlassen bei einzelnem Klick
+ // (-> fuconstr)
+
+ if ( !pView->AreObjectsMarked() )
+ {
+ pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1());
+
+ SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
+ if ( pView->AreObjectsMarked() )
+ rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ else
+ rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ }
+ }
+ }
+ else if ( pView->IsAction() )
+ {
+ pView->EndAction();
+ }
+ else if( !pView->IsAction() )
+ {
+ pWindow->ReleaseMouse();
+
+ if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 )
+ {
+ pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1());
+
+ SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher();
+ if ( pView->AreObjectsMarked() )
+ rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ else
+ rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+ }
+ }
+
+ return (bReturn);
+}
+
+/*************************************************************************
+|*
+|* Maus-Pointer umschalten
+|*
+\************************************************************************/
+
+void FuText::ForcePointer(const MouseEvent* /* pMEvt */)
+{
+ pViewShell->SetActivePointer( aNewPointer );
+
+/*
+ if ( !pView->IsAction() )
+ {
+ Point aPnt(pWindow->PixelToLogic( pWindow->ScreenToOutputPixel(
+ Pointer::GetPosPixel() ) ) );
+ SdrHdl* pHdl=pView->HitHandle(aPnt, *pWindow);
+
+ if (pHdl!=NULL)
+ {
+ pViewShell->SetActivePointer(pHdl->GetPointer() );
+ }
+ else
+ {
+ SdrObject* pObj;
+ SdrPageView* pPV;
+
+ if ( pView->IsMarkedHit(aPnt) )
+ {
+ if ( pView->TakeTextEditObject(aPnt, pObj, pPV) )
+ {
+ pViewShell->SetActivePointer(Pointer(POINTER_TEXT));
+ }
+ else
+ {
+ pViewShell->SetActivePointer(Pointer(POINTER_MOVE));
+ }
+ }
+ else
+ {
+// if ( pView->TakeMacroObject(aPnt, pObj, pPV) )
+ if ( pView->PickObj(aPnt, pObj, pPV, SDRSEARCH_PICKMACRO) )
+ {
+ pViewShell->SetActivePointer( pObj->GetMacroPointer() );
+ }
+ else
+ {
+ pViewShell->SetActivePointer( aNewPointer );
+ }
+ }
+ }
+ }
+*/
+}
+
+
+
+/*************************************************************************
+|*
+|* Tastaturereignisse bearbeiten
+|*
+|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
+|* FALSE.
+|*
+\************************************************************************/
+
+BOOL __EXPORT FuText::KeyInput(const KeyEvent& rKEvt)
+{
+ BOOL bReturn = FALSE;
+
+ if ( pView->KeyInput(rKEvt, pWindow) )
+ {
+ bReturn = TRUE;
+ lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() );
+ }
+ else
+ {
+ bReturn = FuDraw::KeyInput(rKEvt);
+ }
+
+ return (bReturn);
+}
+
+
+
+/*************************************************************************
+|*
+|* Function aktivieren
+|*
+\************************************************************************/
+
+void FuText::Activate()
+{
+ pView->SetDragMode(SDRDRAG_MOVE);
+ SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_OBJECT_ROTATE );
+ rBindings.Invalidate( SID_OBJECT_MIRROR );
+
+// Sofort in den Edit Mode setzen
+// SetInEditMode();
+
+// if (!pTextObj)
+ {
+ /**********************************************************************
+ * Kein Textobjekt im EditMode, daher CreateMode setzen
+ **********************************************************************/
+ USHORT nObj = OBJ_TEXT;
+
+/* UINT16 nIdent;
+ UINT32 nInvent;
+ pView->TakeCurrentObj(nIdent, nInvent);
+*/
+ pView->SetCurrentObj(nObj);
+
+ pView->SetCreateMode();
+ }
+
+ aNewPointer = Pointer(POINTER_TEXT);
+// aNewPointer = Pointer(POINTER_CROSS); //! ???
+
+ aOldPointer = pWindow->GetPointer();
+ pViewShell->SetActivePointer( aNewPointer );
+
+ FuConstruct::Activate();
+}
+
+
+/*************************************************************************
+|*
+|* Function deaktivieren
+|*
+\************************************************************************/
+
+void FuText::Deactivate()
+{
+ FuConstruct::Deactivate();
+ pViewShell->SetActivePointer( aOldPointer );
+ StopEditMode();
+}
+
+
+/*************************************************************************
+|*
+|* Selektion hat sich geaendert
+|*
+\************************************************************************/
+
+void FuText::SelectionHasChanged()
+{
+ pView->SetDragMode(SDRDRAG_MOVE);
+ SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_OBJECT_ROTATE );
+ rBindings.Invalidate( SID_OBJECT_MIRROR );
+
+ pTextObj = NULL;
+
+ if ( pView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ UINT16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ if (nSdrObjKind == OBJ_TEXT ||
+ nSdrObjKind == OBJ_TITLETEXT ||
+ nSdrObjKind == OBJ_OUTLINETEXT /* ||
+ pObj->ISA(SdrTextObj) */ )
+ {
+ pTextObj = (SdrTextObj*) pObj;
+ }
+ }
+ }
+
+ if (!pTextObj)
+ {
+ /**********************************************************************
+ * Kein Textobjekt im EditMode, daher CreateMode setzen
+ **********************************************************************/
+ USHORT nObj = OBJ_TEXT;
+ UINT16 nIdent;
+ UINT32 nInvent;
+ pView->TakeCurrentObj(nIdent, nInvent);
+
+// if (! pView->IsEditMode() )
+// {
+// if (nIdent == OBJ_TEXT)
+// {
+// nObj = OBJ_TEXT;
+// }
+// else if (nIdent == OBJ_OUTLINETEXT)
+// {
+// nObj = OBJ_OUTLINETEXT;
+// }
+// else if (nIdent == OBJ_TITLETEXT)
+// {
+// nObj = OBJ_TITLETEXT;
+// }
+// }
+
+ pView->SetCurrentObj(nObj);
+
+ pView->SetCreateMode();
+ }
+}
+
+/*************************************************************************
+|*
+|* Objekt in Edit-Mode setzen
+|*
+\************************************************************************/
+
+void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel,
+ BOOL bCursorToEnd, const KeyEvent* pInitialKey)
+{
+ /* It is possible to pass a special (unselected) object in pObj, e.g. the
+ caption object of a cell note. If pObj is 0, then the selected object
+ is used. The layer will be relocked in FuText::StopEditMode(). */
+ if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) )
+ pView->UnlockInternalLayer();
+
+ if ( !pObj && pView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ pObj = pMark->GetMarkedSdrObj();
+ }
+ }
+
+ pTextObj = NULL;
+
+ if ( pObj )
+ {
+ UINT16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ if (nSdrObjKind == OBJ_TEXT ||
+ nSdrObjKind == OBJ_TITLETEXT ||
+ nSdrObjKind == OBJ_OUTLINETEXT ||
+ pObj->ISA(SdrTextObj))
+ {
+ SdrPageView* pPV = pView->GetSdrPageView();
+ Rectangle aRect = pObj->GetLogicRect();
+ Point aPnt = aRect.Center();
+
+ if ( pObj->HasTextEdit() )
+ {
+ SdrOutliner* pO = MakeOutliner();
+ lcl_UpdateHyphenator( *pO, pObj );
+
+ // vertical flag:
+ // deduced from slot ids only if text object has no content
+
+ USHORT nSlotID = aSfxRequest.GetSlot();
+ BOOL bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL );
+ OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject();
+ if ( pOPO )
+ bVertical = pOPO->IsVertical(); // content wins
+ pO->SetVertical( bVertical );
+
+ //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!?
+ if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) )
+ {
+ // EditEngine-UndoManager anmelden
+ pViewShell->SetDrawTextUndo( &pO->GetUndoManager() );
+
+ pTextObj = (SdrTextObj*) pObj;
+ pView->SetEditMode();
+
+ // set text cursor to click position or to end,
+ // pass initial key event to outliner view
+ if ( pMousePixel || bCursorToEnd || pInitialKey )
+ {
+ OutlinerView* pOLV = pView->GetTextEditOutlinerView();
+ if (pOLV)
+ {
+ if ( pMousePixel )
+ {
+ MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
+ pOLV->MouseButtonDown(aEditEvt);
+ pOLV->MouseButtonUp(aEditEvt);
+ }
+ else if ( bCursorToEnd )
+ {
+ ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
+ pOLV->SetSelection(aNewSelection);
+ }
+
+ if ( pInitialKey )
+ pOLV->PostKeyEvent( *pInitialKey );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+// #98185# Create default drawing objects via keyboard
+SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle)
+{
+ // case SID_DRAW_TEXT:
+ // case SID_DRAW_TEXT_VERTICAL:
+ // case SID_DRAW_TEXT_MARQUEE:
+ // case SID_DRAW_NOTEEDIT:
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(
+ pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(),
+ 0L, pDrDoc);
+
+ if(pObj)
+ {
+ if(pObj->ISA(SdrTextObj))
+ {
+ SdrTextObj* pText = (SdrTextObj*)pObj;
+ pText->SetLogicRect(rRectangle);
+
+ // #105815# don't set default text, start edit mode instead
+ // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT));
+ // pText->SetText(aText);
+
+ sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID);
+ sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID);
+
+ pText->SetVerticalWriting(bVertical);
+
+ if(bVertical)
+ {
+ SfxItemSet aSet(pDrDoc->GetItemPool());
+
+ aSet.Put(SdrTextAutoGrowWidthItem(TRUE));
+ aSet.Put(SdrTextAutoGrowHeightItem(FALSE));
+ aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP));
+ aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
+
+ pText->SetMergedItemSet(aSet);
+ }
+
+ if(bMarquee)
+ {
+ SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST);
+
+ aSet.Put( SdrTextAutoGrowWidthItem( FALSE ) );
+ aSet.Put( SdrTextAutoGrowHeightItem( FALSE ) );
+ aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) );
+ aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) );
+ aSet.Put( SdrTextAniCountItem( 1 ) );
+ aSet.Put( SdrTextAniAmountItem( (INT16)pWindow->PixelToLogic(Size(2,1)).Width()) );
+
+ pObj->SetMergedItemSetAndBroadcast(aSet);
+ }
+
+ SetInEditMode( pObj ); // #105815# start edit mode
+ }
+ else
+ {
+ DBG_ERROR("Object is NO text object");
+ }
+ }
+
+ return pObj;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/futext2.cxx b/sc/source/ui/drawfunc/futext2.cxx
new file mode 100644
index 000000000000..0fd5c747ff6c
--- /dev/null
+++ b/sc/source/ui/drawfunc/futext2.cxx
@@ -0,0 +1,309 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------------
+
+// TOOLS
+#define _BIGINT_HXX
+#define _SFXMULTISEL_HXX
+#define _STACK_HXX
+#define _QUEUE_HXX
+#define _DYNARR_HXX
+#define _TREELIST_HXX
+#define _CACHESTR_HXX
+#define _NEW_HXX
+//#define _SHL_HXX
+//#define _LINK_HXX
+//#define _ERRCODE_HXX
+//#define _GEN_HXX
+//#define _FRACT_HXX
+//#define _STRING_HXX
+//#define _MTF_HXX
+//#define _CONTNR_HXX
+//#define _LIST_HXX
+//#define _TABLE_HXX
+#define _DYNARY_HXX
+//#define _UNQIDX_HXX
+#define _SVMEMPOOL_HXX
+//#define _UNQID_HXX
+//#define _DEBUG_HXX
+//#define _DATE_HXX
+//#define _TIME_HXX
+//#define _DATETIME_HXX
+//#define _INTN_HXX
+//#define _WLDCRD_HXX
+//#define _FSYS_HXX
+//#define _STREAM_HXX
+#define _CACHESTR_HXX
+#define _SV_MULTISEL_HXX
+
+//SV
+//#define _CLIP_HXX ***
+#define _CONFIG_HXX
+#define _CURSOR_HXX
+#define _FONTDLG_HXX
+#define _PRVWIN_HXX
+//#define _COLOR_HXX
+//#define _PAL_HXX
+//#define _BITMAP_HXX
+//#define _GDIOBJ_HXX
+//#define _POINTR_HXX
+//#define _ICON_HXX
+//#define _IMAGE_HXX
+//#define _KEYCOD_HXX
+//#define _EVENT_HXX
+#define _HELP_HXX
+//#define _APP_HXX
+//#define _MDIAPP_HXX
+//#define _TIMER_HXX
+//#define _METRIC_HXX
+//#define _REGION_HXX
+//#define _OUTDEV_HXX
+//#define _SYSTEM_HXX
+//#define _VIRDEV_HXX
+//#define _JOBSET_HXX
+//#define _PRINT_HXX
+//#define _WINDOW_HXX
+//#define _SYSWIN_HXX
+//#define _WRKWIN_HXX
+#define _MDIWIN_HXX
+//#define _FLOATWIN_HXX
+//#define _DOCKWIN_HXX
+//#define _CTRL_HXX
+//#define _SCRBAR_HXX
+//#define _BUTTON_HXX
+//#define _IMAGEBTN_HXX
+//#define _FIXED_HXX
+//#define _GROUP_HXX
+//#define _EDIT_HXX
+//#define _COMBOBOX_HXX
+//#define _LSTBOX_HXX
+//#define _SELENG_HXX ***
+//#define _SPLIT_HXX
+#define _SPIN_HXX
+//#define _FIELD_HXX
+//#define _MOREBTN_HXX ***
+//#define _TOOLBOX_HXX
+#define _STATUS_HXX
+#define _SVTCTRL3_HXX
+//#define _DIALOG_HXX
+//#define _MSGBOX_HXX
+//#define _SYSDLG_HXX
+//#define _FILDLG_HXX ***
+//#define _PRNDLG_HXX
+#define _COLDLG_HXX
+//#define _TABDLG_HXX
+//#define _MENU_HXX ***
+//#define _GDIMTF_HXX
+//#define _POLY_HXX
+//#define _ACCEL_HXX
+//#define _GRAPH_HXX
+#define _SOUND_HXX
+
+#if defined WIN
+#define _MENUBTN_HXX
+#endif
+
+//svtools
+#define _SCRWIN_HXX
+#define _RULER_HXX
+//#define _TABBAR_HXX
+//#define _VALUESET_HXX
+#define _STDMENU_HXX
+//#define _STDCTRL_HXX
+//#define _CTRLBOX_HXX
+#define _CTRLTOOL_HXX
+#define _EXTATTR_HXX
+#define _FRM3D_HXX
+#define _EXTATTR_HXX
+
+//SVTOOLS
+//#define _SVTREELIST_HXX
+#define _FILTER_HXX
+//#define _SVLBOXITM_HXX
+//#define _SVTREEBOX_HXX
+#define _SVICNVW_HXX
+#define _SVTABBX_HXX
+
+//sfxcore.hxx
+//#define _SFXINIMGR_HXX
+//#define _SFXCFGITEM_HXX
+//#define _SFX_PRINTER_HXX
+#define _SFXGENLINK_HXX
+#define _SFXHINTPOST_HXX
+#define _SFXDOCINF_HXX
+#define _SFXLINKHDL_HXX
+//#define _SFX_PROGRESS_HXX
+
+//sfxsh.hxx
+//#define _SFX_SHELL_HXX
+//#define _SFXAPP_HXX
+//#define _SFXDISPATCH_HXX
+//#define _SFXMSG_HXX
+//#define _SFXOBJFACE_HXX
+//#define _SFXREQUEST_HXX
+#define _SFXMACRO_HXX
+
+// SFX
+//#define _SFXAPPWIN_HXX
+#define _SFX_SAVEOPT_HXX
+//#define _SFX_CHILDWIN_HXX
+//#define _SFXCTRLITEM_HXX
+#define _SFXPRNMON_HXX
+#define _INTRO_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSGPOOL_HXX
+#define _SFXFILEDLG_HXX
+#define _PASSWD_HXX
+#define _SFXTBXCTRL_HXX
+#define _SFXSTBITEM_HXX
+#define _SFXMNUITEM_HXX
+#define _SFXIMGMGR_HXX
+#define _SFXTBXMGR_HXX
+#define _SFXSTBMGR_HXX
+#define _SFX_MINFITEM_HXX
+#define _SFXEVENT_HXX
+
+//sfxdoc.hxx
+//#define _SFX_OBJSH_HXX
+//#define _SFX_CLIENTSH_HXX
+//#define _SFXDOCINF_HXX
+//#define _SFX_OBJFAC_HXX
+#define _SFX_DOCFILT_HXX
+//#define _SFXDOCFILE_HXX
+//define _VIEWFAC_HXX
+//#define _SFXVIEWFRM_HXX
+//#define _SFXVIEWSH_HXX
+//#define _MDIFRM_HXX
+#define _SFX_IPFRM_HXX
+//#define _SFX_INTERNO_HXX
+
+//sfxdlg.hxx
+//#define _SFXTABDLG_HXX
+//#define _BASEDLGS_HXX
+#define _SFX_DINFDLG_HXX
+#define _SFXDINFEDT_HXX
+#define _SFX_MGETEMPL_HXX
+#define _SFX_TPLPITEM_HXX
+//#define _SFX_STYLEDLG_HXX
+#define _NEWSTYLE_HXX
+//#define _SFXDOCTEMPL_HXX
+//#define _SFXDOCTDLG_HXX
+//#define _SFX_TEMPLDLG_HXX
+//#define _SFXNEW_HXX
+#define _SFXDOCMAN_HXX
+//#define _SFXDOCKWIN_HXX **
+
+//sfxitems.hxx
+#define _SFX_WHMAP_HXX
+//#define _ARGS_HXX ***
+//#define _SFXPOOLITEM_HXX
+//#define _SFXINTITEM_HXX
+//#define _SFXENUMITEM_HXX
+#define _SFXFLAGITEM_HXX
+//#define _SFXSTRITEM_HXX
+#define _SFXPTITEM_HXX
+#define _SFXRECTITEM_HXX
+//#define _SFXITEMPOOL_HXX
+//#define _SFXITEMSET_HXX
+#define _SFXITEMITER_HXX
+#define _SFX_WHITER_HXX
+#define _SFXPOOLCACH_HXX
+//#define _AEITEM_HXX
+#define _SFXRNGITEM_HXX
+//#define _SFXSLSTITM_HXX
+//#define _SFXSTYLE_HXX
+
+//xout.hxx
+//#define _XENUM_HXX
+//#define _XPOLY_HXX
+//#define _XATTR_HXX
+//#define _XOUTX_HXX
+//#define _XPOOL_HXX
+//#define _XTABLE_HXX
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+//#define _SDR_NOOBJECTS
+//#define _SDR_NOVIEWS
+
+//#define SI_NOITEMS
+//#define SI_NODRW
+#define _SI_NOSBXCONTROLS
+#define _VCATTR_HXX
+#define _VCONT_HXX
+//#define _VCSBX_HXX ***
+#define _SI_NOOTHERFORMS
+#define _VCTRLS_HXX
+//#define _VCDRWOBJ_HXX ***
+#define _SI_NOCONTROL
+#define _SETBRW_HXX
+#define _VCBRW_HXX
+#define _SI_NOSBXCONTROLS
+#define _SIDLL_HXX
+
+//------------------------------------------------------------------------
+
+#include <svx/svdmodel.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdetc.hxx>
+
+#include "futext.hxx"
+#include "tabvwsh.hxx"
+
+//------------------------------------------------------------------------
+
+SdrOutliner* FuText::MakeOutliner()
+{
+ ScViewData* pViewData = pViewShell->GetViewData();
+ SdrOutliner* pOutl = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, pDrDoc);
+
+ pViewData->UpdateOutlinerFlags(*pOutl);
+
+ // Die EditEngine benutzt beim RTF Export (Clipboard / Drag&Drop)
+ // den MapMode des RefDevices, um die Fontgroesse zu setzen
+
+ // #i10426# The ref device isn't set to the EditEngine before SdrBeginTextEdit now,
+ // so the device must be taken from the model here.
+ OutputDevice* pRef = pDrDoc->GetRefDevice();
+ if (pRef && pRef != pWindow)
+ pRef->SetMapMode( MapMode(MAP_100TH_MM) );
+
+ return pOutl;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx
new file mode 100644
index 000000000000..5ec884ee5f21
--- /dev/null
+++ b/sc/source/ui/drawfunc/futext3.cxx
@@ -0,0 +1,200 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <editeng/editeng.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdview.hxx>
+#include <editeng/editobj.hxx>
+#include <vcl/cursor.hxx>
+#include <sfx2/objsh.hxx>
+#include <editeng/writingmodeitem.hxx>
+
+#include "global.hxx"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include "tabvwsh.hxx" // oder GetDocument irgendwo
+#include "document.hxx"
+#include "editutil.hxx"
+#include "futext.hxx"
+#include "docsh.hxx"
+#include "postit.hxx"
+#include "globstr.hrc"
+#include "attrib.hxx"
+#include "scitems.hxx"
+#include "drawview.hxx"
+#include "undocell.hxx"
+
+// ------------------------------------------------------------------------------------
+// Editieren von Notiz-Legendenobjekten muss immer ueber StopEditMode beendet werden,
+// damit die Aenderungen ins Dokument uebernommen werden!
+// (Fontwork-Execute in drawsh und drtxtob passiert nicht fuer Legendenobjekte)
+// bTextDirection=TRUE means that this function is called from SID_TEXTDIRECTION_XXX(drtxtob.cxx).
+// ------------------------------------------------------------------------------------
+
+void FuText::StopEditMode(BOOL /*bTextDirection*/)
+{
+ SdrObject* pObject = pView->GetTextEditObject();
+ if( !pObject ) return;
+
+ // relock the internal layer that has been unlocked in FuText::SetInEditMode()
+ if ( pObject->GetLayer() == SC_LAYER_INTERN )
+ pView->LockInternalLayer();
+
+ ScViewData& rViewData = *pViewShell->GetViewData();
+ ScDocument& rDoc = *rViewData.GetDocument();
+ ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
+ DBG_ASSERT( pDrawLayer && (pDrawLayer == pDrDoc), "FuText::StopEditMode - missing or different drawing layers" );
+
+ ScAddress aNotePos;
+ ScPostIt* pNote = 0;
+ if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, rViewData.GetTabNo() ) )
+ {
+ aNotePos = pCaptData->maStart;
+ pNote = rDoc.GetNote( aNotePos );
+ DBG_ASSERT( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" );
+ }
+
+ ScDocShell* pDocShell = rViewData.GetDocShell();
+ SfxUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? pDocShell->GetUndoManager() : 0;
+ bool bNewNote = false;
+ if( pNote && pUndoMgr )
+ {
+ /* Put all undo actions already collected (e.g. create caption object)
+ and all following undo actions (text changed) together into a ListAction. */
+ String aUndoStr = ScGlobal::GetRscString( STR_UNDO_EDITNOTE );
+ pUndoMgr->EnterListAction( aUndoStr, aUndoStr );
+ if( SdrUndoGroup* pCalcUndo = pDrawLayer->GetCalcUndo() )
+ {
+ /* Note has been created before editing, if first undo action is
+ an insert action. Needed below to decide whether to drop the
+ undo if editing a new note has been cancelled. */
+ bNewNote = (pCalcUndo->GetActionCount() > 0) && pCalcUndo->GetAction( 0 )->ISA( SdrUndoNewObj );
+ // create a "insert note" undo action if needed
+ if( bNewNote )
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo ) );
+ else
+ pUndoMgr->AddUndoAction( pCalcUndo );
+ }
+ }
+
+ if( pNote )
+ rDoc.LockStreamValid(true); // only the affected sheet is invalidated below
+
+ /* SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing
+ object, if it does not contain text and has invisible border and fill.
+ This must not happen for note caption objects. They will be removed
+ below together with the cell note if the text is empty (independent of
+ border and area formatting). It is possible to prevent automatic
+ deletion by passing sal_True to this function. The return value changes
+ from SDRENDTEXTEDIT_DELETED to SDRENDTEXTEDIT_SHOULDBEDELETED in this
+ case. */
+ /*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != 0 );
+
+ // or ScEndTextEdit (with drawview.hxx)
+ pViewShell->SetDrawTextUndo( 0 );
+
+ Cursor* pCur = pWindow->GetCursor();
+ if( pCur && pCur->IsVisible() )
+ pCur->Hide();
+
+ if( pNote )
+ {
+ // hide the caption object if it is in hidden state
+ pNote->ShowCaptionTemp( aNotePos, false );
+
+ // update author and date
+ pNote->AutoStamp();
+
+ /* If the entire text has been cleared, the cell note and its caption
+ object have to be removed. */
+ SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >( pObject );
+ bool bDeleteNote = !pTextObject || !pTextObject->HasText();
+ if( bDeleteNote )
+ {
+ if( pUndoMgr )
+ {
+ // collect the "remove object" drawing undo action created by DeleteNote()
+ pDrawLayer->BeginCalcUndo();
+ // rescue note data before deletion
+ ScNoteData aNoteData( pNote->GetNoteData() );
+ // delete note from document (removes caption, but does not delete it)
+ rDoc.DeleteNote( aNotePos );
+ // create undo action for removed note
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
+ }
+ else
+ {
+ rDoc.DeleteNote( aNotePos );
+ }
+ // ScDocument::DeleteNote has deleted the note that pNote points to
+ pNote = 0;
+ }
+
+ // finalize the undo list action
+ if( pUndoMgr )
+ {
+ pUndoMgr->LeaveListAction();
+
+ /* #i94039# Update the default name "Edit Note" of the undo action
+ if the note has been created before editing or is deleted due
+ to deleted text. If the note has been created *and* is deleted,
+ the last undo action can be removed completely. Note: The
+ function LeaveListAction() removes the last action by itself,
+ if it is empty (when result is SDRENDTEXTEDIT_UNCHANGED). */
+ if( bNewNote && bDeleteNote )
+ {
+ pUndoMgr->RemoveLastUndoAction();
+ }
+ else if( bNewNote || bDeleteNote )
+ {
+ SfxListUndoAction* pAction = dynamic_cast< SfxListUndoAction* >( pUndoMgr->GetUndoAction() );
+ DBG_ASSERT( pAction, "FuText::StopEditMode - list undo action expected" );
+ if( pAction )
+ pAction->SetComment( ScGlobal::GetRscString( bNewNote ? STR_UNDO_INSERTNOTE : STR_UNDO_DELETENOTE ) );
+ }
+ }
+
+ // invalidate stream positions only for the affected sheet
+ rDoc.LockStreamValid(false);
+ if (rDoc.IsStreamValid(aNotePos.Tab()))
+ rDoc.SetStreamValid(aNotePos.Tab(), FALSE);
+ }
+}
+
+// Called following an EndDragObj() to update the new note rectangle position
+void FuText::StopDragMode(SdrObject* /*pObject*/)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx
new file mode 100644
index 000000000000..40cd4d0fd520
--- /dev/null
+++ b/sc/source/ui/drawfunc/graphsh.cxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/grfflt.hxx>
+#include <svx/grafctrl.hxx>
+
+#include "graphsh.hxx"
+#include "sc.hrc"
+#include "viewdata.hxx"
+#include "drawview.hxx"
+#include "scresid.hxx"
+
+#define ScGraphicShell
+#include "scslots.hxx"
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+
+SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ ScResId(RID_GRAPHIC_OBJECTBAR) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_GRAPHIC) );
+}
+
+TYPEINIT1( ScGraphicShell, ScDrawShell );
+
+ScGraphicShell::ScGraphicShell(ScViewData* pData) :
+ ScDrawShell(pData)
+{
+ SetHelpId(HID_SCSHELL_GRAPHIC);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GraphicObject")));
+}
+
+ScGraphicShell::~ScGraphicShell()
+{
+}
+
+void ScGraphicShell::GetAttrState( SfxItemSet& rSet )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+
+ if( pView )
+ SvxGrafAttrHelper::GetGrafAttrState( rSet, *pView );
+}
+
+void ScGraphicShell::Execute( SfxRequest& rReq )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+
+ if( pView )
+ {
+ SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *pView );
+ Invalidate();
+ }
+}
+
+void ScGraphicShell::GetFilterState( SfxItemSet& rSet )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ BOOL bEnable = FALSE;
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
+ bEnable = TRUE;
+ }
+
+ if( !bEnable )
+ SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
+}
+
+void ScGraphicShell::ExecuteFilter( SfxRequest& rReq )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
+ {
+ GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
+
+ if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
+ SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if( pPageView )
+ {
+ SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
+ String aStr( pView->GetDescriptionOfMarkedObjects() );
+
+ aStr.Append( sal_Unicode(' ') );
+ aStr.Append( String( ScResId( SCSTR_UNDO_GRAFFILTER ) ) );
+ pView->BegUndo( aStr );
+ pFilteredObj->SetGraphicObject( aFilterObj );
+ pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
+ pView->EndUndo();
+ }
+ }
+ }
+ }
+
+ Invalidate();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/makefile.mk b/sc/source/ui/drawfunc/makefile.mk
new file mode 100644
index 000000000000..cf69944d3a1a
--- /dev/null
+++ b/sc/source/ui/drawfunc/makefile.mk
@@ -0,0 +1,87 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=drawfunc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ objdraw.src\
+ drformsh.src
+
+SLOFILES = \
+ $(SLO)$/fupoor.obj \
+ $(SLO)$/fumark.obj \
+ $(SLO)$/fudraw.obj \
+ $(SLO)$/fusel.obj \
+ $(SLO)$/fusel2.obj \
+ $(SLO)$/fuconstr.obj \
+ $(SLO)$/fuconrec.obj \
+ $(SLO)$/fuconarc.obj \
+ $(SLO)$/fuconuno.obj \
+ $(SLO)$/fuconpol.obj \
+ $(SLO)$/fuconcustomshape.obj \
+ $(SLO)$/fuins1.obj \
+ $(SLO)$/fuins2.obj \
+ $(SLO)$/futext.obj \
+ $(SLO)$/futext2.obj \
+ $(SLO)$/futext3.obj \
+ $(SLO)$/drawsh.obj \
+ $(SLO)$/drawsh2.obj \
+ $(SLO)$/drawsh4.obj \
+ $(SLO)$/drawsh5.obj \
+ $(SLO)$/drtxtob.obj \
+ $(SLO)$/drtxtob1.obj \
+ $(SLO)$/drtxtob2.obj \
+ $(SLO)$/drformsh.obj \
+ $(SLO)$/oleobjsh.obj \
+ $(SLO)$/chartsh.obj \
+ $(SLO)$/graphsh.obj \
+ $(SLO)$/mediash.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/fusel.obj \
+ $(SLO)$/fuins2.obj \
+ $(SLO)$/graphsh.obj \
+ $(SLO)$/mediash.obj
+
+NOOPTFILES=\
+ $(SLO)$/fusel.obj
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/drawfunc/mediash.cxx b/sc/source/ui/drawfunc/mediash.cxx
new file mode 100644
index 000000000000..ec1e4ae41e38
--- /dev/null
+++ b/sc/source/ui/drawfunc/mediash.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <avmedia/mediaitem.hxx>
+#include <svl/whiter.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+
+#include "mediash.hxx"
+#include "sc.hrc"
+#include "viewdata.hxx"
+#include "drawview.hxx"
+#include "scresid.hxx"
+
+#define ScMediaShell
+#include "scslots.hxx"
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+
+SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, ScResId(RID_MEDIA_OBJECTBAR) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_MEDIA) );
+}
+
+TYPEINIT1( ScMediaShell, ScDrawShell );
+
+ScMediaShell::ScMediaShell(ScViewData* pData) :
+ ScDrawShell(pData)
+{
+ SetHelpId(HID_SCSHELL_MEDIA);
+ SetName( String( ScResId( SCSTR_MEDIASHELL ) ) );
+}
+
+ScMediaShell::~ScMediaShell()
+{
+}
+
+void ScMediaShell::GetMediaState( SfxItemSet& rSet )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+
+ if( pView )
+ {
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+
+ while( nWhich )
+ {
+ if( SID_AVMEDIA_TOOLBOX == nWhich )
+ {
+ SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
+ bool bDisable = true;
+
+ if( 1 == pMarkList->GetMarkCount() )
+ {
+ SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrMediaObj ) )
+ {
+ ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
+
+ static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
+ rSet.Put( aItem );
+ bDisable = false;
+ }
+ }
+
+ if( bDisable )
+ rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
+
+ delete pMarkList;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+ }
+}
+
+void ScMediaShell::ExecuteMedia( SfxRequest& rReq )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+
+ if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, FALSE, &pItem ) ) )
+ pItem = NULL;
+
+ if( pItem )
+ {
+ SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() );
+
+ if( 1 == pMarkList->GetMarkCount() )
+ {
+ SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrMediaObj ) )
+ {
+ static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
+ static_cast< const ::avmedia::MediaItem& >( *pItem ) );
+ }
+
+ delete pMarkList;
+ }
+ }
+ }
+
+ Invalidate();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src
new file mode 100644
index 000000000000..9fb1b969f060
--- /dev/null
+++ b/sc/source/ui/drawfunc/objdraw.src
@@ -0,0 +1,1541 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+#include "submenu.hrc"
+#include <svx/globlmn.hrc>
+ //
+ // Defines -------------------------------------------------------------------------------
+ //
+#define MN_RESET\
+ MenuItem\
+ {\
+ Identifier = SID_TEXT_STANDARD ; \
+ HelpID = SID_TEXT_STANDARD ; \
+ Text [ en-US ] = "~Default" ; \
+ Text [ x-comment ] = " ";\
+ };
+
+ // Font (SID_ATTR_CHAR_FONT) und Groesse (SID_ATTR_CHAR_FONTHEIGHT) duerfen nicht im
+ // Formatmenue auftauchen, weil die Controller im ExeEnv sonst im Container angelegt werden
+#define MN_TEXT_ATTR\
+ MenuItem\
+ {\
+ Identifier = RID_MN_FORMAT_STYLE ; \
+ HelpID = RID_MN_FORMAT_STYLE ; \
+ Text [ en-US ] = "~Style" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_WEIGHT\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_POSTURE\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_OVERLINE\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_UNDERLINE\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_STRIKEOUT\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_SHADOWED\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_ATTR_CHAR_CONTOUR\
+ };\
+ MenuItem\
+ {\
+ Separator = TRUE ; \
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_SET_SUPER_SCRIPT ; \
+ HelpID = SID_SET_SUPER_SCRIPT ; \
+ Text [ en-US ] = "~Superscript" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_SET_SUB_SCRIPT ; \
+ HelpID = SID_SET_SUB_SCRIPT ; \
+ Text [ en-US ] = "S~ubscript" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ Identifier = RID_MN_FORMAT_ALGN ; \
+ HelpID = RID_MN_FORMAT_ALGN ; \
+ Text [ en-US ] = "~Alignment" ; \
+ RadioCheck = TRUE ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ Identifier = SID_ALIGNLEFT ; \
+ HelpID = SID_ATTR_PARA_ADJUST_LEFT ; \
+ RadioCheck = TRUE ; \
+ Text [ en-US ] = "~Left" ;\
+ Text [ x-comment ] = " "; \
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_ALIGNRIGHT ; \
+ HelpID = SID_ATTR_PARA_ADJUST_RIGHT ; \
+ RadioCheck = TRUE ; \
+ Text [ en-US ] = "~Right" ;\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_ALIGNCENTERHOR ; \
+ HelpID = SID_ATTR_PARA_ADJUST_CENTER ; \
+ RadioCheck = TRUE ; \
+ Text [ en-US ] = "~Centered" ;\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_ALIGNBLOCK ; \
+ HelpID = SID_ATTR_PARA_ADJUST_BLOCK ; \
+ RadioCheck = TRUE ; \
+ Text [ en-US ] = "~Justified" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ Identifier = RID_MN_FORMAT_LINESPACE ; \
+ HelpID = RID_MN_FORMAT_LINESPACE ; \
+ Text [ en-US ] = "~Line Spacing" ; \
+ _MenuItemFlags = MIB_RADIOCHECK ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ ITEM_FORMAT_PARA_LINESPACE_10\
+ RadioCheck = TRUE ; \
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_PARA_LINESPACE_15\
+ RadioCheck = TRUE ; \
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_PARA_LINESPACE_20\
+ RadioCheck = TRUE ; \
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_DRWTXT \
+ MenuItem\
+ {\
+ ITEM_FORMAT_CHAR_DLG\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_PARA_DLG\
+ };
+
+#define MN_EDITLNK \
+ MenuItem\
+ {\
+ Identifier = SID_DRAW_HLINK_EDIT ; \
+ HelpID = SID_DRAW_HLINK_EDIT ; \
+ Text [ en-US ] = "~Hyperlink..." ; \
+ };
+
+#define MN_DELLNK \
+ MenuItem\
+ {\
+ Identifier = SID_DRAW_HLINK_DELETE ; \
+ HelpID = SID_DRAW_HLINK_DELETE ; \
+ Text [ en-US ] = "~Remove Hyperlink" ; \
+ };
+
+#define MN_DRWTXTATTR \
+ MenuItem\
+ {\
+ Identifier = SID_DRAWTEXT_ATTR_DLG ; \
+ HelpID = SID_DRAWTEXT_ATTR_DLG ; \
+ Text [ en-US ] = "Te~xt..." ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Textattribute für die selektierten Textobjekte festlegen : Textattribute f³r die selektierten Textobjekte festlegen */\
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_ASSIGNMACRO \
+ MenuItem\
+ {\
+ Identifier = SID_ASSIGNMACRO ; \
+ HelpID = SID_ASSIGNMACRO ; \
+ Text [ en-US ] = "Assig~n Macro..." ; \
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_ORIGINALSIZE \
+ MenuItem\
+ {\
+ Identifier = SID_ORIGINALSIZE ; \
+ HelpId = SID_ORIGINALSIZE ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Originalgröße : Originalgr÷˜e */\
+ Text [ en-US ] = "~Original Size" ; \
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_RENAME_OBJECT \
+ MenuItem\
+ {\
+ Identifier = SID_RENAME_OBJECT ; \
+ HelpId = SID_RENAME_OBJECT ; \
+ Text [ en-US ] = "Name...";\
+ };
+
+// #i68101#
+#define MN_TITLE_DESCRIPTION_OBJECT \
+ MenuItem\
+ {\
+ Identifier = SID_TITLE_DESCRIPTION_OBJECT; \
+ HelpId = SID_TITLE_DESCRIPTION_OBJECT; \
+ Text [ en-US ] = "Description...";\
+ };
+
+#define MN_MIRRORSUB \
+ MenuItem\
+ {\
+ Identifier = SUBMENU_OBJMIRROR ; \
+ HelpID = HID_SCMENU_OBJMIRROR ; \
+ Text [ en-US ] = "~Flip" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ Identifier = SID_MIRROR_VERTICAL ; \
+ HelpId = SID_MIRROR_VERTICAL ; \
+ Text [ en-US ] = "~Vertically" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_MIRROR_HORIZONTAL ; \
+ HelpId = SID_MIRROR_HORIZONTAL ; \
+ Text [ en-US ] = "~Horizontal" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_ARRANGESUB \
+ MenuItem\
+ {\
+ Identifier = SUBMENU_OBJARRANGE ; \
+ HelpID = HID_SCMENU_OBJARRANGE ; \
+ Text [ en-US ] = "~Arrange" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ ITEM_FORMAT_FRAME_TO_TOP\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_FRAME_UP ; \
+ HelpId = SID_FRAME_UP ; \
+ /* ### ACHTUNG: Neuer Text in Resource? W~eiter nach vorn : Weiter nach vorn */\
+ Text [ en-US ] = "Bring ~Forward" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_FRAME_DOWN ; \
+ HelpId = SID_FRAME_DOWN ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Weiter ~nach hinten : Weiter nach hinten */\
+ Text [ en-US ] = "Send Back~ward" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_FRAME_TO_BOTTOM\
+ };\
+ MenuItem { Separator = TRUE ; }; \
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_HEAVEN\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_HELL\
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_ANCHORSUB \
+ MenuItem\
+ {\
+ Identifier = SUBMENU_ANCHOR ; \
+ HelpID = HID_SCMENU_ANCHOR ; \
+ Text [ en-US ] = "An~chor" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ RadioCheck = TRUE ; \
+ Identifier = SID_ANCHOR_PAGE ; \
+ HelpId = SID_ANCHOR_PAGE ; \
+ Text [ en-US ] = "To P~age" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ MenuItem\
+ {\
+ RadioCheck = TRUE ; \
+ Identifier = SID_ANCHOR_CELL ; \
+ HelpId = SID_ANCHOR_CELL ; \
+ Text [ en-US ] = "To ~Cell" ; \
+ Text [ x-comment ] = " ";\
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };
+
+#define MN_ALIGNSUB \
+ MenuItem\
+ {\
+ Identifier = SID_OBJECT_ALIGN ; \
+ HelpId = SID_OBJECT_ALIGN ; \
+ Text [ en-US ] = "A~lignment" ; \
+ SubMenu = Menu\
+ {\
+ ItemList = \
+ {\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_LEFT\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_CENTER\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_RIGHT\
+ };\
+ MenuItem\
+ {\
+ Separator = TRUE ; \
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_UP\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_MIDDLE\
+ };\
+ MenuItem\
+ {\
+ ITEM_FORMAT_OBJECT_ALIGN_DOWN\
+ };\
+ };\
+ };\
+ Text [ x-comment ] = " ";\
+ };
+
+ //
+ // ------------------------------------------------------------------------------
+ //
+ //
+ // Objekt-Leisten
+ //
+String RID_DRAW_OBJECTBAR
+{
+ Text [ en-US ] = "Drawing Object Bar" ;
+ Text [ x-comment ] = " ";
+};
+ToolBox RID_DRAW_OBJECTBAR
+{
+ HelpId = HID_SC_TOOLBOX_DRAW ;
+ Dockable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Customize = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ LineSpacing = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ MenuStrings = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_BEZIER_EDIT ;
+ HelpID = SID_BEZIER_EDIT ;
+
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ // Linien
+ ToolBoxItem
+ {
+ Identifier = SID_ATTRIBUTES_LINE ;
+ HelpId = SID_ATTRIBUTES_LINE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_LINEEND_STYLE ;
+ HelpID = SID_ATTR_LINEEND_STYLE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_LINE_STYLE ;
+ HelpId = SID_ATTR_LINE_STYLE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_LINE_WIDTH ;
+ HelpId = SID_ATTR_LINE_WIDTH ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_LINE_COLOR ;
+ HelpId = SID_ATTR_LINE_COLOR ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTRIBUTES_AREA ;
+ HelpId = SID_ATTRIBUTES_AREA ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_FILL_STYLE ;
+ HelpId = SID_ATTR_FILL_STYLE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ // Rest
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ROTATE ;
+ HelpId = SID_OBJECT_ROTATE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ANCHOR_TOGGLE ;
+ HelpId = SID_ANCHOR_TOGGLE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_FRAME_TO_TOP ;
+ HelpId = SID_FRAME_TO_TOP ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_FRAME_TO_BOTTOM ;
+ HelpId = SID_FRAME_TO_BOTTOM ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_HEAVEN ;
+ HelpID = SID_OBJECT_HEAVEN ;
+
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_HELL ;
+ HelpID = SID_OBJECT_HELL ;
+
+ };
+
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+
+ ToolBoxItem
+ {
+ Identifier = SID_GRID_VISIBLE;
+ HelpID = SID_GRID_VISIBLE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRID_USE;
+ HelpID = SID_GRID_USE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_HELPLINES_MOVE;
+ HelpID = SID_HELPLINES_MOVE;
+ Hide = TRUE;
+ };
+
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN ;
+ HelpId = SID_OBJECT_ALIGN ;
+ };
+ };
+ Scroll = TRUE ;
+};
+ //
+ // Text-Toolbox
+ //
+String RID_TEXT_TOOLBOX
+{
+ Text [ en-US ] = "Text Object Bar" ;
+ Text [ x-comment ] = " ";
+};
+ToolBox RID_TEXT_TOOLBOX
+{
+ HelpId = HID_SC_TOOLBOX_DRTEXT ;
+ LineSpacing = TRUE ;
+ Dockable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Scroll = TRUE ;
+ Customize = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 0 , 0 ) ;
+ Align = BOXALIGN_TOP ;
+ MenuStrings = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_FONT ;
+ HelpId = SID_ATTR_CHAR_FONT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_FONTHEIGHT ;
+ HelpId = SID_ATTR_CHAR_FONTHEIGHT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_WEIGHT ;
+ HelpId = SID_ATTR_CHAR_WEIGHT ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_POSTURE ;
+ HelpId = SID_ATTR_CHAR_POSTURE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_UNDERLINE ;
+ HelpId = SID_ATTR_CHAR_UNDERLINE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ULINE_VAL_DOUBLE;
+ HelpId = SID_ULINE_VAL_DOUBLE;
+ AutoCheck = TRUE ;
+ Hide=TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_COLOR ;
+ HelpId = SID_ATTR_CHAR_COLOR ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_10 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_10 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_15 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_15 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_20 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_20 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNLEFT ;
+ HelpId = SID_ATTR_PARA_ADJUST_LEFT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNCENTERHOR ;
+ HelpId = SID_ATTR_PARA_ADJUST_CENTER ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNRIGHT ;
+ HelpId = SID_ATTR_PARA_ADJUST_RIGHT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNBLOCK ;
+ HelpId = SID_ATTR_PARA_ADJUST_BLOCK ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ HelpID = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ RadioCheck = TRUE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ HelpID = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ RadioCheck = TRUE;
+ Hide = TRUE;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_SET_SUPER_SCRIPT ;
+ HelpID = SID_SET_SUPER_SCRIPT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_SET_SUB_SCRIPT ;
+ HelpID = SID_SET_SUB_SCRIPT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ;
+ HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ;
+ HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_CHAR_DLG ;
+ HelpID = SID_CHAR_DLG ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_PARA_DLG ;
+ HelpID = SID_PARA_DLG ;
+ };
+ };
+ ItemList[ ar ] =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_FONT ;
+ HelpId = SID_ATTR_CHAR_FONT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_FONTHEIGHT ;
+ HelpId = SID_ATTR_CHAR_FONTHEIGHT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_WEIGHT ;
+ HelpId = SID_ATTR_CHAR_WEIGHT ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_POSTURE ;
+ HelpId = SID_ATTR_CHAR_POSTURE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_UNDERLINE ;
+ HelpId = SID_ATTR_CHAR_UNDERLINE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ULINE_VAL_DOUBLE;
+ HelpId = SID_ULINE_VAL_DOUBLE;
+ AutoCheck = TRUE ;
+ Hide=TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_COLOR ;
+ HelpId = SID_ATTR_CHAR_COLOR ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_10 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_10 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_15 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_15 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_20 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_20 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNRIGHT ;
+ HelpId = SID_ATTR_PARA_ADJUST_RIGHT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNCENTERHOR ;
+ HelpId = SID_ATTR_PARA_ADJUST_CENTER ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNLEFT ;
+ HelpId = SID_ATTR_PARA_ADJUST_LEFT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNBLOCK ;
+ HelpId = SID_ATTR_PARA_ADJUST_BLOCK ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ HelpID = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ RadioCheck = TRUE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ HelpID = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ RadioCheck = TRUE;
+ Hide = TRUE;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_SET_SUPER_SCRIPT ;
+ HelpID = SID_SET_SUPER_SCRIPT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_SET_SUB_SCRIPT ;
+ HelpID = SID_SET_SUB_SCRIPT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ;
+ HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ;
+ HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_CHAR_DLG ;
+ HelpID = SID_CHAR_DLG ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_PARA_DLG ;
+ HelpID = SID_PARA_DLG ;
+ };
+ };
+ ItemList[ he ] =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_FONT ;
+ HelpId = SID_ATTR_CHAR_FONT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_FONTHEIGHT ;
+ HelpId = SID_ATTR_CHAR_FONTHEIGHT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_WEIGHT ;
+ HelpId = SID_ATTR_CHAR_WEIGHT ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_POSTURE ;
+ HelpId = SID_ATTR_CHAR_POSTURE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_UNDERLINE ;
+ HelpId = SID_ATTR_CHAR_UNDERLINE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ULINE_VAL_DOUBLE;
+ HelpId = SID_ULINE_VAL_DOUBLE;
+ AutoCheck = TRUE ;
+ Hide=TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_CHAR_COLOR ;
+ HelpId = SID_ATTR_CHAR_COLOR ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_10 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_10 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_15 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_15 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LINESPACE_20 ;
+ HelpId = SID_ATTR_PARA_LINESPACE_20 ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNRIGHT ;
+ HelpId = SID_ATTR_PARA_ADJUST_RIGHT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNCENTERHOR ;
+ HelpId = SID_ATTR_PARA_ADJUST_CENTER ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNLEFT ;
+ HelpId = SID_ATTR_PARA_ADJUST_LEFT ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ALIGNBLOCK ;
+ HelpId = SID_ATTR_PARA_ADJUST_BLOCK ;
+ RadioCheck = TRUE ;
+ AutoCheck = TRUE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ HelpID = SID_ATTR_PARA_RIGHT_TO_LEFT;
+ RadioCheck = TRUE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ HelpID = SID_ATTR_PARA_LEFT_TO_RIGHT;
+ RadioCheck = TRUE;
+ Hide = TRUE;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_SET_SUPER_SCRIPT ;
+ HelpID = SID_SET_SUPER_SCRIPT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_SET_SUB_SCRIPT ;
+ HelpID = SID_SET_SUB_SCRIPT ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ;
+ HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ;
+ HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_CHAR_DLG ;
+ HelpID = SID_CHAR_DLG ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_PARA_DLG ;
+ HelpID = SID_PARA_DLG ;
+ };
+ };
+};
+ //
+ // Graphics toolbox
+ //
+String RID_GRAPHIC_OBJECTBAR
+{
+ Text [ en-US ] = "Graphics Object Bar";
+};
+ToolBox RID_GRAPHIC_OBJECTBAR
+{
+ HelpId = HID_SC_TOOLBOX_GRAPHIC ;
+ LineSpacing = TRUE ;
+ Dockable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Scroll = TRUE ;
+ Customize = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 0 , 0 ) ;
+ Align = BOXALIGN_TOP ;
+ MenuStrings = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_GRFFILTER;
+ HelpID = SID_GRFFILTER;
+ DropDown = TRUE ;
+ Checkable = FALSE ;
+ RadioCheck = FALSE ;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_MODE;
+ HelpID = SID_ATTR_GRAF_MODE;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_RED;
+ HelpID = SID_ATTR_GRAF_RED;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_GREEN;
+ HelpID = SID_ATTR_GRAF_GREEN;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_BLUE;
+ HelpID = SID_ATTR_GRAF_BLUE;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_LUMINANCE;
+ HelpID = SID_ATTR_GRAF_LUMINANCE;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_CONTRAST;
+ HelpID = SID_ATTR_GRAF_CONTRAST;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_GAMMA;
+ HelpID = SID_ATTR_GRAF_GAMMA;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_TRANSPARENCE;
+ HelpID = SID_ATTR_GRAF_TRANSPARENCE;
+ };
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+
+ // #i25616#
+ ToolBoxItem
+ {
+ Identifier = SID_ATTRIBUTES_LINE;
+ HelpID = SID_ATTRIBUTES_LINE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTRIBUTES_AREA;
+ HelpID = SID_ATTRIBUTES_AREA;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_FILL_SHADOW;
+ HelpID = SID_ATTR_FILL_SHADOW;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+
+ ToolBoxItem
+ {
+ Identifier = SID_ATTR_GRAF_CROP;
+ HelpID = SID_ATTR_GRAF_CROP;
+ };
+
+ // copied from the "normal" drawing toolbar:
+
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_ANCHOR_TOGGLE ;
+ HelpId = SID_ANCHOR_TOGGLE ;
+ };
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_FRAME_TO_TOP ;
+ HelpId = SID_FRAME_TO_TOP ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_FRAME_TO_BOTTOM ;
+ HelpId = SID_FRAME_TO_BOTTOM ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_HEAVEN ;
+ HelpID = SID_OBJECT_HEAVEN ;
+
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_HELL ;
+ HelpID = SID_OBJECT_HELL ;
+
+ };
+
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+
+ ToolBoxItem
+ {
+ Identifier = SID_GRID_VISIBLE;
+ HelpID = SID_GRID_VISIBLE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_GRID_USE;
+ HelpID = SID_GRID_USE;
+ Hide = TRUE;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_HELPLINES_MOVE;
+ HelpID = SID_HELPLINES_MOVE;
+ Hide = TRUE;
+ };
+
+ //---------------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; };
+ //---------------------------------------------
+ ToolBoxItem
+ {
+ Identifier = SID_OBJECT_ALIGN ;
+ HelpId = SID_OBJECT_ALIGN ;
+ };
+ };
+};
+ //
+ // Popup-Menues ---------------------------------------------------------------------
+ //
+String RID_POPUP_DRAW
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Popup-Menü für Zeichenobjekte : Popup-Men³ f³r Zeichenobjekte */
+ Text [ en-US ] = "Pop-up menu for drawing objects" ;
+ Text [ x-comment ] = " ";
+};
+ //
+ // Popup-Menue fuer (allgemeine) Zeichenobjekte
+ //
+Menu RID_POPUP_DRAW
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTRIBUTES_LINE };
+ MenuItem { ITEM_FORMAT_ATTRIBUTES_AREA };
+ MN_DRWTXTATTR // Text...
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_MIRRORSUB
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ MN_ASSIGNMACRO
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ ITEM_FORMAT_BEZIER_EDIT
+ RadioCheck = FALSE ;
+ AutoCheck = TRUE ;
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_FONTWORK
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_EDITLNK
+ MN_DELLNK
+ MenuItem { ITEM_OPEN_HYPERLINK };
+ };
+};
+
+ //
+ // Popup-Menue fuer (Uno-) Controls
+ //
+
+Menu RID_POPUP_CONTROL
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem { ITEM_FORM_CONTROL_PROPERTIES };
+ MenuItem { ITEM_FORM_PROPERTIES };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ };
+};
+
+ //
+ // Grafik
+ //
+
+Menu RID_POPUP_GRAPHIC
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTRIBUTES_LINE }; // #i25616#
+ MenuItem { ITEM_FORMAT_ATTRIBUTES_AREA }; // #i25616#
+ MN_DRWTXTATTR
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+ MN_ORIGINALSIZE
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_MIRRORSUB
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ MN_ASSIGNMACRO
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_EDITLNK
+ MN_DELLNK
+ MenuItem { ITEM_OPEN_HYPERLINK };
+ };
+};
+
+ //
+ // Media
+ //
+
+Menu RID_POPUP_MEDIA
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_MIRRORSUB
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ };
+};
+
+ToolBox RID_MEDIA_OBJECTBAR
+{
+ //HelpId = HID_SC_TOOLBOX_MEDIA ;
+ LineSpacing = TRUE ;
+ Dockable = TRUE ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Scroll = TRUE ;
+ Customize = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 0 , 0 ) ;
+ Align = BOXALIGN_TOP ;
+ MenuStrings = TRUE ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_AVMEDIA_TOOLBOX;
+ HelpID = SID_AVMEDIA_TOOLBOX;
+ DropDown = FALSE ;
+ Checkable = FALSE ;
+ RadioCheck = FALSE ;
+ };
+ };
+};
+
+ //
+ // Ole-Objekt
+ //
+
+Menu RID_POPUP_OLE
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+ MN_ORIGINALSIZE
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ };
+};
+
+ //
+ // Charts
+ //
+
+Menu RID_POPUP_CHART
+{
+ ItemList =
+ {
+ MenuItem { ITEM_FORMAT_ATTR_TRANSFORM };
+ MN_ORIGINALSIZE
+
+ //-#i68101#----------------------
+ MenuItem { Separator = TRUE ; };
+ MN_TITLE_DESCRIPTION_OBJECT
+ MN_RENAME_OBJECT
+ //-#i68101#----------------------
+
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MN_ARRANGESUB
+ MN_ALIGNSUB
+ MN_ANCHORSUB
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ ITEM_GROUP_MENU
+ };
+};
+
+ //
+ // PopUpDraw Text
+ //
+
+String RID_POPUP_DRAWTEXT
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Popup-Menü für Text-Objekte : Popup-Men³ f³r Text-Objekte */
+ Text [ en-US ] = "Pop-up menu for text objects" ;
+ Text [ x-comment ] = " ";
+};
+
+Menu RID_POPUP_DRAWTEXT
+{
+ ItemList =
+ {
+ MN_RESET
+ MenuItem { Separator = TRUE ; };
+ MN_DRWTXTATTR
+ MenuItem { Separator = TRUE ; };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONTHEIGHT
+ };
+ // Stil, Ausrichtung, Zeilenabstand
+ MN_TEXT_ATTR
+ MenuItem { Separator = TRUE ; };
+ // Zeichen, Absatz
+ MN_DRWTXT
+ MenuItem { Separator = TRUE ; };
+ MenuItem
+ {
+ ITEM_OPEN_HYPERLINK
+ };
+ };
+};
+
diff --git a/sc/source/ui/drawfunc/oleobjsh.cxx b/sc/source/ui/drawfunc/oleobjsh.cxx
new file mode 100644
index 000000000000..a7d344c25f5b
--- /dev/null
+++ b/sc/source/ui/drawfunc/oleobjsh.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <editeng/eeitem.hxx>
+#include <svx/fontwork.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/tabarea.hxx>
+#include <svx/tabline.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "oleobjsh.hxx"
+#include "drwlayer.hxx"
+#include "sc.hrc"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "drawview.hxx"
+#include "scresid.hxx"
+#include <svx/svdobj.hxx>
+
+#define ScOleObjectShell
+#include "scslots.hxx"
+
+
+SFX_IMPL_INTERFACE(ScOleObjectShell, ScDrawShell, ScResId(SCSTR_OLEOBJECTSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
+ ScResId(RID_DRAW_OBJECTBAR) );
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_OLE) );
+}
+
+TYPEINIT1( ScOleObjectShell, ScDrawShell );
+
+ScOleObjectShell::ScOleObjectShell(ScViewData* pData) :
+ ScDrawShell(pData)
+{
+ SetHelpId(HID_SCSHELL_OLEOBEJCTSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("OleObject")));
+}
+
+ScOleObjectShell::~ScOleObjectShell()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
new file mode 100644
index 000000000000..2e0f67e37b01
--- /dev/null
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -0,0 +1,1184 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <editeng/editview.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include "sc.hrc"
+#include "global.hxx" // ScAddress
+#include "scresid.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "appoptio.hxx"
+#include "compiler.hxx"
+
+#include "dwfunctr.hrc"
+#include "dwfunctr.hxx"
+
+// -----------------------------------------------------------------------
+
+#define ARG_SEPERATOR String("; ")
+SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX )
+
+/*************************************************************************
+#* Member: ScFunctionChildWindow Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionChildWindow
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionChildWindow
+#* Ableitung vom SfxChildWindow als "Behaelter" fuer
+#* Funktions- Fenster in Clac
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( pParentP, nId )
+{
+ ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this,
+ pParentP, ScResId( FID_FUNCTION_BOX ) );
+ pWindow = pWin;
+
+ eChildAlignment = SFX_ALIGN_RIGHT;
+
+ pWin->Initialize( pInfo );
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionDockWin
+#*
+#* Input: Sfx- Verknuepfungen, Fenster, Resource
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP,
+ SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) :
+
+ SfxDockingWindow( pBindingsP, pCW, pParent, rResId ),
+ aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT),
+ aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ),
+ aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ),
+ aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ),
+ aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ),
+ aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ),
+ aOldSize (0,0)
+{
+ FreeResource();
+ InitLRUList();
+ SetStyle(GetStyle()|WB_CLIPCHILDREN);
+
+ aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl));
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+ aFiFuncDesc.SetUpdateMode(TRUE);
+ pAllFuncList=&aFuncList;
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ nArgs=0;
+ nDockMode=0;
+ bSizeFlag=FALSE;
+ aCatBox.SetDropDownLineCount(9);
+ Font aFont=aFiFuncDesc.GetFont();
+ aFont.SetColor(Color(COL_BLACK));
+ aFiFuncDesc.SetFont(aFont);
+ aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent?
+//? SetBackground();
+
+ Link aLink=LINK( this, ScFunctionDockWin, SelHdl);
+ aCatBox.SetSelectHdl(aLink);
+ aFuncList.SetSelectHdl(aLink);
+ aDDFuncList.SetSelectHdl(aLink);
+
+ Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl);
+ aFuncList.SetDoubleClickHdl(a2Link);
+ aDDFuncList.SetSelectHdl(aLink);
+ aInsertButton.SetClickHdl(a2Link);
+
+ Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl);
+ aPrivatSplit.SetCtrModifiedHdl(a3Link);
+ StartListening( *pBindingsP, TRUE );
+
+ Point aTopLeft=aCatBox.GetPosPixel();
+ //String aString=aCatBox.GetEntry( 0)+String("www");
+ String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ aCatBox.SelectEntryPos(0);
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+ SelHdl(&aCatBox);
+ bInit=TRUE;
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Destruktor der Klasse ScFunctionDockWin
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionDockWin::~ScFunctionDockWin()
+{
+ EndListening( GetBindings() );
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::InitLRUList()
+{
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX );
+ USHORT* pLRUListIds = rAppOpt.GetLRUFuncList();
+
+ USHORT i;
+ for ( i=0; i<LRU_MAX; i++ )
+ aLRUList[i] = NULL;
+
+ if ( pLRUListIds )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+ for ( i=0; i<nLRUFuncCount; i++ )
+ aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] );
+ }
+
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+
+ if(nSelPos == 0)
+ UpdateFunctionList();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:10.12.99
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateLRUList()
+{
+ if (pFuncDesc && pFuncDesc->nFIndex!=0)
+ {
+ ScModule* pScMod = SC_MOD();
+ pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex);
+ }
+}
+
+
+/*************************************************************************
+#* Member: SetSize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetSize()
+{
+ USHORT nSelEntry=0;
+ SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment();
+ short nNewDockMode;
+ switch(aChildAlign)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+
+ nNewDockMode=1;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aFuncList.GetSelectEntryPos();
+ aFuncList.Clear();
+ aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel());
+ aDDFuncList.Enable();
+ aDDFuncList.Show();
+ aPrivatSplit.Disable();
+ aPrivatSplit.Hide();
+ aFuncList.Disable();
+ aFuncList.Hide();
+ pAllFuncList=&aDDFuncList;
+ SelHdl(&aCatBox);
+ aDDFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+
+ default: nNewDockMode=0;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aDDFuncList.GetSelectEntryPos();
+ aDDFuncList.Clear();
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ aPrivatSplit.Enable();
+ aPrivatSplit.Show();
+ aFuncList.Enable();
+ aFuncList.Show();
+ pAllFuncList=&aFuncList;
+ SelHdl(&aCatBox);
+ aFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+ }
+
+ if(nDockMode==0)
+ {
+ SetLeftRightSize();
+ }
+ else
+ {
+ SetTopBottonSize();
+ }
+}
+/*************************************************************************
+#* Member: SetLeftRightSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einstellen,
+#* wenn Links oder Rechts angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetLeftRightSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ //@ SetUpdateMode( FALSE);
+
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+
+ Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() );
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+
+
+ if(aOldSize.Width()!=aNewSize.Width())
+ SetMyWidthLeRi(aNewSize);
+
+ if(aOldSize.Height()!=aNewSize.Height())
+ SetMyHeightLeRi(aNewSize);
+
+ aOldSize=aNewSize;
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+
+}
+/*************************************************************************
+#* Member: SetTopBottonSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#* wenn oben oder unten angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetTopBottonSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ SetMyWidthToBo(aNewSize);
+ SetMyHeightToBo(aNewSize);
+
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+}
+
+/*************************************************************************
+#* Member: SetMyWidthLeRi Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen,wenn Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X();
+ aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X();
+ aFDSize.Width()=aFLSize.Width();
+ aSplitterSize.Width()=aFLSize.Width();
+
+ aCatBox.SetSizePixel(aCDSize);
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetSizePixel(aSplitterSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen bei Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ long nTxtHeight = aFuncList.GetTextHeight();
+
+ short nY=(short)(3*nTxtHeight+
+ aFuncList.GetPosPixel().Y()+aSplitterSize.Height());
+
+ aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4;
+ if(nY>aFDTopLeft.Y())
+ {
+ aFDSize.Height()-=nY-aFDTopLeft.Y();
+ aFDTopLeft.Y()=nY;
+ }
+ aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1;
+ aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1;
+
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetPosPixel(aSplitterTopLeft);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetMyWidthToBo Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aDdFLSize=aDDFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aDdFLTopLeft=aDDFuncList.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X();
+ aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X();
+
+ aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X();
+
+ aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X();
+
+ aDDFuncList.SetPosPixel(aDdFLTopLeft);
+ aDDFuncList.SetSizePixel(aDdFLSize);
+ aCatBox.SetSizePixel(aCDSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+ Point aCBTopLeft=aCatBox.GetPosPixel();
+ aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y();
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetDescription Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Erklaerungstext fuer die Funktion einstellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetDescription()
+{
+ aFiFuncDesc.SetText( EMPTY_STRING );
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pDesc->initArgumentInfo(); // full argument info is needed
+
+ String aString=pAllFuncList->GetSelectEntry();
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" ));
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ }
+
+ aString+=pDesc->GetParamList();
+
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" ));
+ }
+ else
+ {
+ aString += '\n';
+ }
+
+ aString+=*(pDesc->pFuncDesc);
+
+ aFiFuncDesc.SetText(aString);
+ aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT);
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+
+ }
+ }
+
+/*************************************************************************
+#* Member: Resizing Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize )
+{
+ if((ULONG)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth;
+ if((ULONG)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight;
+
+}
+
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScFunctionDockWin::Close()
+{
+ SfxBoolItem aItem( FID_FUNCTION_BOX, FALSE );
+
+ GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aItem, 0L );
+
+ SfxDockingWindow::Close();
+
+ return( TRUE );
+}
+
+
+/*************************************************************************
+#* Member: CheckAlignment Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberprueft den Andockmodus und stellt die
+#* Groessen dementsprechend ein.
+#*
+#* Input: Das neue Alignment
+#*
+#* Output: Das uebergebene Alignment
+#*
+#************************************************************************/
+SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */,
+ SfxChildAlignment aChildAlign)
+{
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ if(!bInit)
+ {
+ eSfxOldAlignment=eSfxNewAlignment;
+ eSfxNewAlignment=aChildAlign;
+ }
+ else
+ {
+ bInit=FALSE;
+ eSfxOldAlignment=aChildAlign;
+ eSfxNewAlignment=aChildAlign;
+ }
+
+ switch(eSfxOldAlignment)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+ nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+
+ 10*aTxtSize.Width()+
+ aFuncList.GetPosPixel().X();*/
+ nMinHeight=0;
+
+ break;
+
+ case SFX_ALIGN_NOALIGNMENT:
+
+ aString = aCatBox.GetEntry(0);
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www"));
+ aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString),
+ aFiFuncDesc.GetTextHeight() );
+
+ default: Point aTopLeft=aCatBox.GetPosPixel();
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ //aCatBox.SelectEntryPos(0);
+
+ break;
+ }
+
+ return aChildAlign;
+}
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aenderungen erkennen
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ )
+{
+// const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
+ /*
+ if ( pPoolItemHint
+ && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) )
+ {
+ // Die Liste der Farben hat sich geaendert
+ pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable();
+ FillValueSet();
+ }
+ */
+}
+
+
+/*************************************************************************
+#* Member: Resize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resize()
+{
+ if ( !IsFloatingMode() ||
+ !GetFloatingWindow()->IsRollUp() )
+ {
+ Size aQSize=GetOutputSizePixel();
+ Resizing( aQSize);
+ SetSize();
+ }
+ SfxDockingWindow::Resize();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateFunctionList()
+{
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+ USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ ? (nSelPos-1) : 0;
+
+ pAllFuncList->Clear();
+ pAllFuncList->SetUpdateMode( FALSE );
+
+ if ( nSelPos > 0 )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+
+ const ScFuncDesc* pDesc = pFuncMgr->First( nCategory );
+ while ( pDesc )
+ {
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ pDesc = pFuncMgr->Next();
+ }
+ }
+ else // LRU-Liste
+ {
+ for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ )
+ {
+ const ScFuncDesc* pDesc = aLRUList[i];
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ }
+ }
+
+
+ //------------------------------------------------------
+ pAllFuncList->SetUpdateMode( TRUE );
+
+ if ( pAllFuncList->GetEntryCount() > 0 )
+ {
+ pAllFuncList->Enable();
+ pAllFuncList->SelectEntryPos( 0 );
+ }
+ else
+ {
+ pAllFuncList->Disable();
+ }
+}
+
+/*************************************************************************
+#* Member: DoEnter Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen
+#* nach betaetigen der Uebernehmen- Schaltflaeche
+#* oder einem Doppelklick in die Funktionsliste.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::DoEnter(BOOL /* bOk */) //@@ ???
+{
+ String aFirstArgStr;
+ String aParaStr;
+ String aArgStr;
+ String aString=pAllFuncList->GetSelectEntry();
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+ nArgs=0;
+
+ if(aString.Len()>0)
+ {
+
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh);
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if(!pScMod->IsEditMode())
+ {
+ pScMod->SetInputMode(SC_INPUT_TABLE);
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ if (pHdl)
+ pHdl->ClearText();
+ }
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pFuncDesc=pDesc;
+ UpdateLRUList();
+ nArgs = pDesc->nArgCount;
+ if(nArgs>0)
+ {
+ // NOTE: Theoretically the first parameter could have the
+ // suppress flag as well, but practically it doesn't.
+ aFirstArgStr = *(pDesc->ppDefArgNames[0]);
+ aFirstArgStr.EraseLeadingAndTrailingChars();
+ aFirstArgStr.SearchAndReplaceAll(' ', '_');
+ aArgStr = aFirstArgStr;
+ if ( nArgs != VAR_ARGS )
+ { // no VarArgs or Fix plus VarArgs, but not VarArgs only
+ String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " ));
+ USHORT nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 );
+ for ( USHORT nArg = 1;
+ nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ )
+ {
+ if (!pDesc->pDefArgFlags[nArg].bSuppress)
+ {
+ aArgStr += aArgSep;
+ String sTmp(*(pDesc->ppDefArgNames[nArg]));
+ sTmp.EraseLeadingAndTrailingChars();
+ sTmp.SearchAndReplaceAll(' ', '_');
+ aArgStr += sTmp;
+ }
+ }
+ }
+ }
+ }
+ if (pHdl)
+ {
+ if(pHdl->GetEditString().Len()==0)
+ {
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ }
+ EditView *pEdView=pHdl->GetActiveView();
+ if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen
+ {
+ if(nArgs>0)
+ {
+ pHdl->InsertFunction(aString);
+ pEdView->InsertText(aArgStr,TRUE);
+ ESelection aESel=pEdView->GetSelection();
+ aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len();
+ pEdView->SetSelection(aESel);
+ pHdl->DataChanged();
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+ pEdView->InsertText(aString,FALSE);
+ pHdl->DataChanged();
+ }
+ }
+ }
+ InitLRUList();
+ }
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+
+
+}
+
+
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb )
+{
+ if ( pLb == &aCatBox)
+ {
+ UpdateFunctionList();
+ SetDescription();
+ }
+
+ if ( pLb == &aFuncList||pLb == &aDDFuncList)
+ {
+ SetDescription();
+ }
+
+
+ //SetSize();
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl )
+{
+ if ((ImageButton *)pCtrl == &aInsertButton ||
+ (ListBox *)pCtrl == &aFuncList)
+ {
+ DoEnter(TRUE); // Uebernimmt die Eingabe
+ }
+ //...
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SetSplitHdl Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung des Split- Controls werden die
+#* einzelnen Controls an die neue Groesse angepasst.
+#*
+#* Input: Zeiger auf Control
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl )
+{
+ if (pCtrl == &aPrivatSplit)
+ {
+ short nDeltaY=aPrivatSplit.GetDeltaY();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aFLSize.Height()+=nDeltaY;
+ aFDSize.Height()-=nDeltaY;
+ aFDTopLeft.Y()+=nDeltaY;
+ aFuncList.SetSizePixel(aFLSize);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+ /*
+ aFuncList.Invalidate();
+ aFuncList.Update();
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+ */
+ }
+ //...
+
+ return 0;
+}
+
+void ScFunctionDockWin::ToggleFloatingMode()
+{
+ aSplitterInitPos = Point();
+ SfxDockingWindow::ToggleFloatingMode();
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+
+ aOldSize.Height()=0;
+ aOldSize.Width()=0;
+ aTimer.Start();
+}
+
+IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG )
+{
+ CheckAlignment(eSfxOldAlignment,eSfxNewAlignment);
+ SetSize();
+ return 0;
+}
+
+void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo)
+{
+ String aStr;
+ if(pInfo!=NULL)
+ {
+ if ( pInfo->aExtraString.Len() )
+ {
+ xub_StrLen nPos = pInfo->aExtraString.Search(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:")));
+
+ // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
+ // er nicht vorhanden ist, liegt eine "altere Version vor
+ if ( nPos != STRING_NOTFOUND )
+ {
+ xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
+ if ( n1 != STRING_NOTFOUND )
+ {
+ xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
+ if ( n2 != STRING_NOTFOUND )
+ {
+ // Alignment-String herausschneiden
+ aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
+ pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
+ aStr.Erase(0, n1-nPos+1);
+ }
+ }
+ }
+ }
+ }
+ SfxDockingWindow::Initialize(pInfo);
+
+ if ( aStr.Len())
+ {
+ aSplitterInitPos=aPrivatSplit.GetPosPixel();
+ aSplitterInitPos.Y()=(USHORT) aStr.ToInt32();
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ USHORT nSelPos=sal::static_int_cast<USHORT>( aStr.ToInt32() );
+ aCatBox.SelectEntryPos(nSelPos);
+ SelHdl(&aCatBox);
+
+ // if the window has already been shown (from SfxDockingWindow::Initialize if docked),
+ // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW
+
+ UseSplitterInitPos();
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxDockingWindow::FillInfo(rInfo);
+ Point aPoint=aPrivatSplit.GetPosPixel();
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" ));
+ rInfo.aExtraString += String::CreateFromInt32(aPoint.Y());
+ rInfo.aExtraString += ';';
+ rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos());
+ rInfo.aExtraString += ')';
+}
+
+void ScFunctionDockWin::UseSplitterInitPos()
+{
+ if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() )
+ {
+ aPrivatSplit.MoveSplitTo(aSplitterInitPos);
+ aSplitterInitPos = Point(); // use only once
+ }
+}
+
+void ScFunctionDockWin::StateChanged( StateChangedType nStateChange )
+{
+ SfxDockingWindow::StateChanged( nStateChange );
+
+ if (nStateChange == STATE_CHANGE_INITSHOW)
+ {
+ UseSplitterInitPos(); // set initial splitter position if necessary
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/formdlg/dwfunctr.hrc b/sc/source/ui/formdlg/dwfunctr.hrc
new file mode 100644
index 000000000000..5daaa8a0a9a8
--- /dev/null
+++ b/sc/source/ui/formdlg/dwfunctr.hrc
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define CB_CAT 1
+#define LB_FUNC 2
+#define DDLB_FUNC 3
+#define IMB_INSERT 1
+#define FI_FUNCDESC 1
+#define FT_SPLIT 2
+
+
+// ********************************************************************** EOF
+
diff --git a/sc/source/ui/formdlg/dwfunctr.src b/sc/source/ui/formdlg/dwfunctr.src
new file mode 100644
index 000000000000..2f07ff5d1e30
--- /dev/null
+++ b/sc/source/ui/formdlg/dwfunctr.src
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+ // include ---------------------------------------------------------------
+#include "sc.hrc"
+#include "dwfunctr.hrc"
+ // pragma ----------------------------------------------------------------
+
+ // RID_SVXDLG_CALCFUNC --------------------------------------------------
+DockingWindow FID_FUNCTION_BOX
+{
+ Border = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+ Size = MAP_APPFONT ( 130 , 160 ) ;
+ HelpId = HID_FUNCTION_BOX ;
+ ListBox CB_CAT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 4 ) ;
+ Size = MAP_APPFONT ( 56 , 80 ) ;
+ DropDown = TRUE ;
+ AutoSize = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Last Used" ; Default ; > ;
+ < "All" ; Default ; > ;
+ < "Database" ; Default ; > ;
+ < "Date&Time" ; Default ; > ;
+ < "Financial" ; Default ; > ;
+ < "Information" ; Default ; > ;
+ < "Logical" ; Default ; > ;
+ < "Mathematical" ; Default ; > ;
+ < "Array" ; Default ; > ;
+ < "Statistical" ; Default ; > ;
+ < "Spreadsheet" ; Default ; > ;
+ < "Text" ; Default ; > ;
+ < "Add-in" ; Default ; > ;
+ };
+ };
+ ListBox DDLB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 103 , 4 ) ;
+ Size = MAP_APPFONT ( 56 , 80 ) ;
+ Hide = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ ListBox LB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 19 ) ;
+ Size = MAP_APPFONT ( 72 , 90 ) ;
+ TabStop = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ FixedText FI_FUNCDESC
+ {
+ WordBreak = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 115 ) ;
+ Size = MAP_APPFONT ( 72 , 40 ) ;
+ };
+ Control FT_SPLIT
+ {
+ Pos = MAP_APPFONT ( 3 , 110 ) ;
+ Size = MAP_APPFONT ( 72 , 3 ) ;
+ };
+ ImageButton IMB_INSERT
+ {
+ Pos = MAP_APPFONT ( 3 , 4 ) ;
+ Size = MAP_APPFONT ( 13 , 13 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "fx.bmp" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+ };
+ DefButton = TRUE ;
+ QuickHelpText [ en-US ] = "Insert Function into calculation sheet" ;
+ };
+ Text [ en-US ] = "Functions" ;
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/formdlg/formdata.cxx b/sc/source/ui/formdlg/formdata.cxx
new file mode 100644
index 000000000000..90bb97cd7f2b
--- /dev/null
+++ b/sc/source/ui/formdlg/formdata.cxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <tools/debug.hxx>
+
+#include "formdata.hxx"
+
+//============================================================================
+
+ScFormEditData::ScFormEditData() : formula::FormEditData()
+{
+ Reset();
+}
+
+ScFormEditData::~ScFormEditData()
+{
+}
+
+ScFormEditData::ScFormEditData( const ScFormEditData& r ) : formula::FormEditData(r)
+{
+ *this = r;
+}
+// -----------------------------------------------------------------------------
+void ScFormEditData::SaveValues()
+{
+ ScFormEditData* pTemp = new ScFormEditData(*this);
+
+ Reset();
+ pParent = pTemp;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/formdlg/formdlgs.src b/sc/source/ui/formdlg/formdlgs.src
new file mode 100644
index 000000000000..3b76875e4e82
--- /dev/null
+++ b/sc/source/ui/formdlg/formdlgs.src
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+ //---------------------------------------------------------------------------
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
new file mode 100644
index 000000000000..ed9a2681ce45
--- /dev/null
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -0,0 +1,684 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/svtreebx.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mnemonic.hxx>
+#include <unotools/charclass.hxx>
+#include <tools/urlobj.hxx>
+#include <formula/formulahelper.hxx>
+#include <formula/IFunctionDescription.hxx>
+
+#include "tokenuno.hxx"
+#include "formula.hxx"
+#include "formdata.hxx"
+#include "globstr.hrc"
+#include "scresid.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "appoptio.hxx"
+#include "docsh.hxx"
+#include "funcdesc.hxx"
+#include "formula/token.hxx"
+#include "tokenarray.hxx"
+#include "sc.hrc"
+#include "servuno.hxx"
+#include "unonames.hxx"
+#include "externalrefmgr.hxx"
+
+#include <com/sun/star/table/CellAddress.hpp>
+
+//============================================================================
+using namespace formula;
+using namespace com::sun::star;
+
+ScDocument* ScFormulaDlg::pDoc = NULL;
+ScAddress ScFormulaDlg::aCursorPos;
+
+
+
+// --------------------------------------------------------------------------
+// Initialisierung / gemeinsame Funktionen fuer Dialog
+// --------------------------------------------------------------------------
+
+ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
+ Window* pParent, ScViewData* pViewData,formula::IFunctionManager* _pFunctionMgr )
+ : formula::FormulaDlg( pB, pCW, pParent, true,true,true,this, _pFunctionMgr,this)
+ , m_aHelper(this,pB)
+{
+ m_aHelper.SetWindow(this);
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputEnterHandler();
+ ScTabViewShell* pScViewShell = NULL;
+
+ // title has to be from the view that opened the dialog,
+ // even if it's not the current view
+
+ SfxObjectShell* pParentDoc = NULL;
+ if ( pB )
+ {
+ SfxDispatcher* pMyDisp = pB->GetDispatcher();
+ if (pMyDisp)
+ {
+ SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
+ if (pMyViewFrm)
+ {
+ pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() );
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+ pParentDoc = pMyViewFrm->GetObjectShell();
+ }
+ }
+ }
+ //if ( !pParentDoc && pScViewShell ) // use current only if above fails
+ // pParentDoc = pScViewShell->GetObjectShell();
+ //if ( pParentDoc )
+ // aDocName = pParentDoc->GetTitle();
+
+ if ( pDoc == NULL )
+ pDoc = pViewData->GetDocument();
+ m_xParser.set(ScServiceProvider::MakeInstance(SC_SERVICE_FORMULAPARS,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet> xSet(m_xParser,uno::UNO_QUERY);
+ xSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COMPILEFAP)),uno::makeAny(sal_True));
+
+ m_xOpCodeMapper.set(ScServiceProvider::MakeInstance(SC_SERVICE_OPCODEMAPPER,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY);
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
+
+ DBG_ASSERT( pInputHdl, "Missing input handler :-/" );
+
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+
+ m_aHelper.enableInput( FALSE );
+ m_aHelper.EnableSpreadsheets();
+ m_aHelper.Init();
+ m_aHelper.SetDispatcherLock( TRUE );
+
+ notifyChange();
+ fill();
+
+ ScFormEditData* pData = pScMod->GetFormEditData();
+ if (!pData)
+ {
+ //Nun wird es Zeit den Inputhandler festzulegen
+ pScMod->SetRefInputHdl(pScMod->GetInputHdl());
+
+ pDoc = pViewData->GetDocument();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ aCursorPos = ScAddress( nCol, nRow, nTab );
+
+ pScMod->InitFormEditData(); // neu anlegen
+ pData = pScMod->GetFormEditData();
+ pData->SetInputHandler(pScMod->GetInputHdl());
+ pData->SetDocShell(pViewData->GetDocShell());
+
+ DBG_ASSERT(pData,"FormEditData ist nicht da");
+
+ formula::FormulaDlgMode eMode = FORMULA_FORMDLG_FORMULA; // Default...
+
+ // Formel vorhanden? Dann editieren
+
+ String aFormula;
+ pDoc->GetFormula( nCol, nRow, nTab, aFormula );
+ BOOL bEdit = ( aFormula.Len() > 1 );
+ BOOL bMatrix = FALSE;
+ if ( bEdit )
+ {
+ bMatrix = CheckMatrix(aFormula);
+
+ xub_StrLen nFStart = 0;
+ xub_StrLen nFEnd = 0;
+ if ( GetFormulaHelper().GetNextFunc( aFormula, FALSE, nFStart, &nFEnd) )
+ {
+ pScMod->InputReplaceSelection( aFormula );
+ pScMod->InputSetSelection( nFStart, nFEnd );
+ xub_StrLen PrivStart, PrivEnd;
+ pScMod->InputGetSelection( PrivStart, PrivEnd);
+
+ eMode = SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,TRUE,TRUE);
+ pData->SetFStart( nFStart );
+ }
+ else
+ bEdit = FALSE;
+ }
+
+ if ( !bEdit )
+ {
+ String aNewFormula = '=';
+ if ( aFormula.Len() > 0 && aFormula.GetChar(0) == '=' )
+ aNewFormula=aFormula;
+
+ pScMod->InputReplaceSelection( aNewFormula );
+ pScMod->InputSetSelection( 1, aNewFormula.Len()+1 );
+ xub_StrLen PrivStart, PrivEnd;
+ pScMod->InputGetSelection( PrivStart, PrivEnd);
+ SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,FALSE,FALSE);
+
+ pData->SetFStart( 1 ); // hinter dem "="
+ }
+
+ pData->SetMode( (USHORT) eMode );
+ String rStrExp = GetMeText();
+
+ pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp );
+
+ Update(rStrExp);
+ } // if (!pData)
+
+}
+
+void ScFormulaDlg::notifyChange()
+{
+ ScModule* pScMod = SC_MOD();
+
+ ScInputHandler* pInputHdl = pScMod->GetInputHdl();
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+}
+// -----------------------------------------------------------------------------
+void ScFormulaDlg::fill()
+{
+ ScModule* pScMod = SC_MOD();
+ ScFormEditData* pData = pScMod->GetFormEditData();
+ notifyChange();
+ String rStrExp;
+ if (pData)
+ {
+ // Daten schon vorhanden -> Zustand wiederherstellen (nach Umschalten)
+ // pDoc und aCursorPos nicht neu initialisieren
+ //pDoc = pViewData->GetDocument();
+ if(IsInputHdl(pData->GetInputHandler()))
+ {
+ pScMod->SetRefInputHdl(pData->GetInputHandler());
+ }
+ else
+ {
+ PtrTabViewShell pTabViewShell;
+ ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell);
+
+ if ( pInputHdl == NULL ) //DocShell hat keinen InputHandler mehr,
+ { //hat der Anwender halt Pech gehabt.
+ disableOk();
+ pInputHdl = pScMod->GetInputHdl();
+ }
+ else
+ {
+ pInputHdl->SetRefViewShell(pTabViewShell);
+ }
+ pScMod->SetRefInputHdl(pInputHdl);
+ pData->SetInputHandler(pInputHdl);
+ }
+
+ String aOldFormulaTmp(pScMod->InputGetFormulaStr());
+ pScMod->InputSetSelection( 0, aOldFormulaTmp.Len());
+
+ rStrExp=pData->GetUndoStr();
+ pScMod->InputReplaceSelection(rStrExp);
+
+ SetMeText(rStrExp);
+
+ pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp );
+
+ Update();
+ // Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde!
+ pScMod->SetRefInputHdl(NULL);
+ }
+}
+
+__EXPORT ScFormulaDlg::~ScFormulaDlg()
+{
+ ScModule* pScMod = SC_MOD();
+ ScFormEditData* pData = pScMod->GetFormEditData();
+
+ if (pData) // wird nicht ueber Close zerstoert;
+ {
+ //Referenz Inputhandler zuruecksetzen
+ pScMod->SetRefInputHdl(NULL);
+ } // if (pData) // wird nicht ueber Close zerstoert;
+
+ delete pCell;
+}
+
+BOOL ScFormulaDlg::IsInputHdl(ScInputHandler* pHdl)
+{
+ BOOL bAlive = FALSE;
+
+ // gehoert der InputHandler zu irgendeiner ViewShell ?
+
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh && !bAlive )
+ {
+ if (((ScTabViewShell*)pSh)->GetInputHandler() == pHdl)
+ bAlive = TRUE;
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+
+ return bAlive;
+
+}
+
+ScInputHandler* ScFormulaDlg::GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh)
+{
+ ScInputHandler* pHdl=NULL;
+
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame && pHdl==NULL)
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ pHdl=pViewSh->GetInputHandler();
+ if(ppViewSh!=NULL) *ppViewSh=pViewSh;
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+
+ return pHdl;
+}
+
+
+BOOL __EXPORT ScFormulaDlg::Close()
+{
+ DoEnter(FALSE);
+ return TRUE;
+}
+
+// --------------------------------------------------------------------------
+// Funktionen fuer rechte Seite
+// --------------------------------------------------------------------------
+bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult )
+{
+ BOOL bResult = TRUE;
+
+ ::std::auto_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
+
+ // #35521# HACK! um bei ColRowNames kein #REF! zu bekommen,
+ // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
+ // eingefuegt wird, bei der Einzeldarstellung aber als
+ // single-Zellbezug interpretiert wird
+ BOOL bColRowName = pCell->HasColRowName();
+ if ( bColRowName )
+ {
+ // ColRowName im RPN-Code?
+ if ( pCell->GetCode()->GetCodeLen() <= 1 )
+ { // ==1: einzelner ist als Parameter immer Bereich
+ // ==0: es waere vielleicht einer, wenn..
+ String aBraced( '(' );
+ aBraced += rStrExp;
+ aBraced += ')';
+ pFCell.reset( new ScFormulaCell( pDoc, aCursorPos, aBraced ) );
+ }
+ else
+ bColRowName = FALSE;
+ }
+
+ USHORT nErrCode = pFCell->GetErrCode();
+ if ( nErrCode == 0 )
+ {
+ SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
+ Color* pColor;
+ if ( pFCell->IsValue() )
+ {
+ double n = pFCell->GetValue();
+ ULONG nFormat = aFormatter.GetStandardFormat( n, 0,
+ pFCell->GetFormatType(), ScGlobal::eLnge );
+ aFormatter.GetOutputString( n, nFormat,
+ rStrResult, &pColor );
+ }
+ else
+ {
+ String aStr;
+
+ pFCell->GetString( aStr );
+ ULONG nFormat = aFormatter.GetStandardFormat(
+ pFCell->GetFormatType(), ScGlobal::eLnge);
+ aFormatter.GetOutputString( aStr, nFormat,
+ rStrResult, &pColor );
+ }
+
+ ScRange aTestRange;
+ if ( bColRowName || (aTestRange.Parse(rStrExp) & SCA_VALID) )
+ rStrResult.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." ));
+ // Bereich
+ }
+ else
+ rStrResult += ScGlobal::GetErrorString(nErrCode);
+
+ if(!isUserMatrix() && pFCell->GetMatrixFlag())
+ {
+ CheckMatrix();
+ }
+
+ return bResult;
+}
+
+
+
+// virtuelle Methoden von ScAnyRefDlg:
+void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ pEdit->SetSelection(Selection(0, SELECTION_MAX));
+ ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton );
+ m_aHelper.RefInputStart( aPair.second, aPair.first);
+ RefInputStartAfter( aPair.second, aPair.first );
+}
+void ScFormulaDlg::RefInputDone( BOOL bForced )
+{
+ m_aHelper.RefInputDone( bForced );
+ RefInputDoneAfter( bForced );
+}
+
+void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
+{
+ const IFunctionDescription* pFunc = getCurrentFunctionDescription();
+ if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
+ {
+ Selection theSel;
+ BOOL bRefNull = UpdateParaWin(theSel);
+
+ if ( rRef.aStart != rRef.aEnd && bRefNull )
+ {
+ RefInputStart(GetActiveEdit());
+ }
+
+ String aRefStr;
+ BOOL bOtherDoc = ( pRefDoc != pDoc && pRefDoc->GetDocumentShell()->HasName() );
+ if ( bOtherDoc )
+ {
+ // Referenz auf anderes Dokument - wie inputhdl.cxx
+
+ DBG_ASSERT(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
+
+ String aTmp;
+ rRef.Format( aTmp, SCA_VALID|SCA_TAB_3D, pRefDoc ); // immer 3d
+
+ SfxObjectShell* pObjSh = pRefDoc->GetDocumentShell();
+
+ // #i75893# convert escaped URL of the document to something user friendly
+// String aFileName = pObjSh->GetMedium()->GetName();
+ String aFileName = pObjSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+
+ aRefStr = '\'';
+ aRefStr += aFileName;
+ aRefStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "'#" ));
+ aRefStr += aTmp;
+ }
+ else
+ {
+ // We can't use ScRange::Format here because in R1C1 mode we need
+ // to display the reference position relative to the cursor
+ // position.
+ ScTokenArray aArray;
+ ScComplexRefData aRefData;
+ aRefData.InitRangeRel(rRef, aCursorPos);
+ bool bSingle = aRefData.Ref1 == aRefData.Ref2;
+ if (aCursorPos.Tab() != rRef.aStart.Tab())
+ aRefData.Ref1.SetFlag3D(true);
+ if (bSingle)
+ aArray.AddSingleReference(aRefData.Ref1);
+ else
+ aArray.AddDoubleReference(aRefData);
+ ScCompiler aComp(pDoc, aCursorPos, aArray);
+ aComp.SetGrammar(pDoc->GetGrammar());
+ ::rtl::OUStringBuffer aBuf;
+ aComp.CreateStringFromTokenArray(aBuf);
+ aRefStr = aBuf.makeStringAndClear();
+ }
+
+ UpdateParaWin(theSel,aRefStr);
+ }
+}
+
+BOOL ScFormulaDlg::IsRefInputMode() const
+{
+ const IFunctionDescription* pDesc = getCurrentFunctionDescription();
+ BOOL bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (pDoc!=NULL);
+ return bRef;
+}
+
+BOOL ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const
+{
+ // not allowed: different from this doc, and no name
+ // pDocSh is always a ScDocShell
+ if ( pDocSh && ((ScDocShell*)pDocSh)->GetDocument() != pDoc && !pDocSh->HasName() )
+ return FALSE;
+
+ return TRUE; // everything else is allowed
+}
+
+void ScFormulaDlg::SetActive()
+{
+ const IFunctionDescription* pFunc = getCurrentFunctionDescription();
+ if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
+ {
+ RefInputDone();
+ SetEdSelection();
+ }
+}
+
+void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP)
+{
+ if (pFuncDescP && pFuncDescP->nFIndex!=0)
+ {
+ ScModule* pScMod = SC_MOD();
+ pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex);
+ }
+}
+
+void ScFormulaDlg::doClose(BOOL /*_bOk*/)
+{
+ m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
+}
+void ScFormulaDlg::insertEntryToLRUList(const formula::IFunctionDescription* _pDesc)
+{
+ const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
+ SaveLRUEntry(pDesc);
+}
+void ScFormulaDlg::showReference(const String& _sFormula)
+{
+ ShowReference(_sFormula);
+}
+void ScFormulaDlg::ShowReference(const String& _sFormula)
+{
+ m_aHelper.ShowReference(_sFormula);
+}
+void ScFormulaDlg::HideReference( BOOL bDoneRefMode )
+{
+ m_aHelper.HideReference(bDoneRefMode);
+}
+void ScFormulaDlg::ViewShellChanged( ScTabViewShell* pScViewShell )
+{
+ m_aHelper.ViewShellChanged( pScViewShell );
+}
+void ScFormulaDlg::AddRefEntry( )
+{
+
+}
+BOOL ScFormulaDlg::IsTableLocked( ) const
+{
+ // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
+ return FALSE;
+}
+void ScFormulaDlg::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton)
+{
+ m_aHelper.ToggleCollapsed(pEdit,pButton);
+}
+void ScFormulaDlg::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton)
+{
+ m_aHelper.ReleaseFocus(pEdit,pButton);
+}
+void ScFormulaDlg::dispatch(BOOL _bOK,BOOL _bMartixChecked)
+{
+ SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK );
+ SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMartixChecked );
+ SfxStringItem aStrItem( SCITEM_STRING, getCurrentFormula() );
+
+ // Wenn durch Dokument-Umschalterei die Eingabezeile weg war/ist,
+ // ist der String leer. Dann nicht die alte Formel loeschen.
+ if ( !aStrItem.GetValue().Len() )
+ aRetItem.SetValue( FALSE ); // FALSE = Cancel
+
+ m_aHelper.SetDispatcherLock( FALSE ); // Modal-Modus ausschalten
+
+ clear();
+
+ GetBindings().GetDispatcher()->Execute( SID_INS_FUNCTION,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aRetItem, &aStrItem, &aMatItem, 0L );
+}
+void ScFormulaDlg::setDispatcherLock( BOOL bLock )
+{
+ m_aHelper.SetDispatcherLock( bLock );
+}
+void ScFormulaDlg::setReferenceInput(const formula::FormEditData* _pData)
+{
+ ScModule* pScMod = SC_MOD();
+ ScFormEditData* pData = const_cast<ScFormEditData*>(dynamic_cast<const ScFormEditData*>(_pData));
+ pScMod->SetRefInputHdl(pData->GetInputHandler());
+}
+void ScFormulaDlg::deleteFormData()
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->ClearFormEditData(); // pData wird ungueltig!
+}
+void ScFormulaDlg::clear()
+{
+ pDoc = NULL;
+
+ //Referenz Inputhandler zuruecksetzen
+ ScModule* pScMod = SC_MOD();
+ pScMod->SetRefInputHdl(NULL);
+
+ // Enable() der Eingabezeile erzwingen:
+ ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ if ( pScViewShell )
+ pScViewShell->UpdateInputHandler();
+}
+void ScFormulaDlg::switchBack()
+{
+ ScModule* pScMod = SC_MOD();
+ // auf das Dokument zurueckschalten
+ // (noetig, weil ein fremdes oben sein kann - #34222#)
+ ScInputHandler* pHdl = pScMod->GetInputHdl();
+ if ( pHdl )
+ {
+ pHdl->ViewShellGone(NULL); // -> aktive View neu holen
+ pHdl->ShowRefFrame();
+ }
+
+ // aktuelle Tabelle ggF. restaurieren (wg. Maus-RefInput)
+ ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ if ( pScViewShell )
+ {
+ ScViewData* pVD=pScViewShell->GetViewData();
+ SCTAB nExecTab = aCursorPos.Tab();
+ if ( nExecTab != pVD->GetTabNo() )
+ pScViewShell->SetTabNo( nExecTab );
+
+ SCROW nRow=aCursorPos.Row();
+ SCCOL nCol=aCursorPos.Col();
+
+ if(pVD->GetCurX()!=nCol || pVD->GetCurY()!=nRow)
+ pScViewShell->SetCursor(nCol,nRow);
+ }
+}
+formula::FormEditData* ScFormulaDlg::getFormEditData() const
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->GetFormEditData();
+}
+void ScFormulaDlg::setCurrentFormula(const String& _sReplacement)
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputReplaceSelection(_sReplacement);
+}
+void ScFormulaDlg::setSelection(xub_StrLen _nStart,xub_StrLen _nEnd)
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputSetSelection( _nStart, _nEnd );
+}
+void ScFormulaDlg::getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputGetSelection( _nStart, _nEnd );
+}
+String ScFormulaDlg::getCurrentFormula() const
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->InputGetFormulaStr();
+}
+formula::IFunctionManager* ScFormulaDlg::getFunctionManager()
+{
+ return ScGlobal::GetStarCalcFunctionMgr();
+}
+uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
+{
+ return m_xParser;
+}
+uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
+{
+ return m_xOpCodeMapper;
+}
+
+table::CellAddress ScFormulaDlg::getReferencePosition() const
+{
+ return table::CellAddress(aCursorPos.Tab(),aCursorPos.Col(),aCursorPos.Row());
+}
+
+::std::auto_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
+{
+ ::std::auto_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray());
+ pArray->Fill( _aTokenList, pDoc->GetExternalRefManager());
+ return pArray;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/formdlg/makefile.mk b/sc/source/ui/formdlg/makefile.mk
new file mode 100644
index 000000000000..2574ca48f348
--- /dev/null
+++ b/sc/source/ui/formdlg/makefile.mk
@@ -0,0 +1,53 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=formdlgs
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/formula.obj \
+ $(SLO)$/formdata.obj \
+ $(SLO)$/privsplt.obj \
+ $(SLO)$/dwfunctr.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ dwfunctr.src
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/formdlg/privsplt.cxx b/sc/source/ui/formdlg/privsplt.cxx
new file mode 100644
index 000000000000..e8b09550b96d
--- /dev/null
+++ b/sc/source/ui/formdlg/privsplt.cxx
@@ -0,0 +1,424 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "privsplt.hxx"
+
+/*************************************************************************
+#* Member: ScPrivatSplit Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: MD_Test
+#*
+#* Funktion: Konstruktor der Klasse ScPrivatSplit
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScPrivatSplit::ScPrivatSplit( Window* pParent, const ResId& rResId,
+ SC_SPLIT_DIRECTION eSplit):
+ Control( pParent, rResId )
+{
+ Point aPos=GetPosPixel();
+ nOldX=(short)aPos.X();
+ nOldY=(short)aPos.Y();
+ nNewX=(short)aPos.X();
+ nNewY=(short)aPos.Y();
+ eScSplit=eSplit;
+ aXMovingRange.Min()=nNewX;
+ aXMovingRange.Max()=nNewX;
+ aYMovingRange.Min()=nNewY;
+ aYMovingRange.Max()=nNewY;
+
+ aWinPointer=GetPointer();
+
+ aMovingFlag=FALSE;
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ aWinPointer=Pointer(POINTER_HSPLIT);
+ }
+ else
+ {
+ aWinPointer=Pointer(POINTER_VSPLIT);
+ }
+ SetPointer(aWinPointer);
+}
+
+
+/*************************************************************************
+#* Member: MouseButtonDown Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
+#* werden alle Mauseingaben an dieses Control weitergeleitet.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aPos=LogicToPixel(rMEvt.GetPosPixel());
+
+ nOldX=(short)aPos.X();
+ nOldY=(short)aPos.Y();
+
+ CaptureMouse();
+}
+
+/*************************************************************************
+#* Member: MouseButtonUp Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Ende einer Benutzeraktion mit der Maus. Es werden
+#* die aktuelle Maus- Koordinaten ermittelt und fuer
+#* die Verschiebung des Fensters verwendet.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ ReleaseMouse();
+
+ Point aPos=LogicToPixel(rMEvt.GetPosPixel());
+ Point a2Pos=GetPosPixel();
+ Point a3Pos=a2Pos;
+
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ nNewX=(short)aPos.X();
+ nDeltaX=nNewX-nOldX;
+ a2Pos.X()+=nDeltaX;
+ if(a2Pos.X()<aXMovingRange.Min())
+ {
+ nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Min();
+ }
+ else if(a2Pos.X()>aXMovingRange.Max())
+ {
+ nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Max();
+ }
+ }
+ else
+ {
+ nNewY=(short)aPos.Y();
+ nDeltaY=nNewY-nOldY;
+ a2Pos.Y()+=nDeltaY;
+ if(a2Pos.Y()<aYMovingRange.Min())
+ {
+ nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Min();
+ }
+ else if(a2Pos.Y()>aYMovingRange.Max())
+ {
+ nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Max();
+ }
+ }
+ SetPosPixel(a2Pos);
+ Invalidate();
+ Update();
+ CtrModified();
+}
+
+/*************************************************************************
+#* Member: MouseMove Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Reagiert kontinuierlich auf Mausbewegungen. Es werden
+#* die aktuelle Maus- Koordinaten ermittelt und fuer
+#* die Verschiebung des Fensters verwendet.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
+{
+ Point aPos=LogicToPixel(rMEvt.GetPosPixel());
+ Point a2Pos=GetPosPixel();
+ Point a3Pos=a2Pos;
+ if(rMEvt.IsLeft())
+ {
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ nNewX=(short)aPos.X();
+ nDeltaX=nNewX-nOldX;
+ a2Pos.X()+=nDeltaX;
+
+ if(a2Pos.X()<aXMovingRange.Min())
+ {
+ nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Min();
+ }
+ else if(a2Pos.X()>aXMovingRange.Max())
+ {
+ nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Max();
+ }
+ }
+ else
+ {
+ nNewY=(short)aPos.Y();
+ nDeltaY=nNewY-nOldY;
+ a2Pos.Y()+=nDeltaY;
+ if(a2Pos.Y()<aYMovingRange.Min())
+ {
+ nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Min();
+ }
+ else if(a2Pos.Y()>aYMovingRange.Max())
+ {
+ nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Max();
+ }
+ }
+
+ SetPosPixel(a2Pos);
+
+ CtrModified();
+ Invalidate();
+ Update();
+ }
+}
+
+/*************************************************************************
+#* Member: SetYRange Datum:14.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Setzt den Range fuer die Y- Verschiebung
+#*
+#* Input: neuer Bereich
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ScPrivatSplit::SetYRange(Range cRgeY)
+{
+ aYMovingRange=cRgeY;
+}
+
+
+
+/*************************************************************************
+#* Member: GetDeltaY Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Liefert die relative x-Verschiebung zurueck
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+short ScPrivatSplit::GetDeltaX()
+{
+ return nDeltaX;
+}
+
+/*************************************************************************
+#* Member: GetDeltaY Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Liefert die relative y-Verschiebung zurueck
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+short ScPrivatSplit::GetDeltaY()
+{
+ return nDeltaY;
+}
+
+/*************************************************************************
+#* Member: CtrModified Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Teilt einem installierten Handler mit, dass
+#* eine Veraenderung eingetreten ist.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ScPrivatSplit::CtrModified()
+{
+ aCtrModifiedLink.Call( this );
+}
+
+void ScPrivatSplit::MoveSplitTo(Point aPos)
+{
+ Point a2Pos=GetPosPixel();
+ nOldX=(short)a2Pos.X();
+ nOldY=(short)a2Pos.Y();
+ Point a3Pos=a2Pos;
+
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ nNewX=(short)aPos.X();
+ nDeltaX=nNewX-nOldX;
+ a2Pos.X()+=nDeltaX;
+ if(a2Pos.X()<aXMovingRange.Min())
+ {
+ nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Min();
+ }
+ else if(a2Pos.X()>aXMovingRange.Max())
+ {
+ nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Max();
+ }
+ }
+ else
+ {
+ nNewY=(short)aPos.Y();
+ nDeltaY=nNewY-nOldY;
+ a2Pos.Y()+=nDeltaY;
+ if(a2Pos.Y()<aYMovingRange.Min())
+ {
+ nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Min();
+ }
+ else if(a2Pos.Y()>aYMovingRange.Max())
+ {
+ nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Max();
+ }
+ }
+ SetPosPixel(a2Pos);
+ Invalidate();
+ Update();
+ CtrModified();
+}
+
+
+void ScPrivatSplit::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ SetBackground( rStyleSettings.GetFaceColor());
+ }
+ if ( IsBackground() )
+ {
+ SetFillColor( GetBackground().GetColor() );
+ SetBackground();
+ }
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void ScPrivatSplit::StateChanged( StateChangedType nType )
+{
+ if ( (nType == STATE_CHANGE_ZOOM) ||
+ (nType == STATE_CHANGE_CONTROLFONT) )
+ {
+ ImplInitSettings( TRUE, FALSE, FALSE );
+ Invalidate();
+ }
+ if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
+ {
+ ImplInitSettings( FALSE, TRUE, FALSE );
+ Invalidate();
+ }
+ else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ {
+ ImplInitSettings( FALSE, FALSE, TRUE );
+ Invalidate();
+ }
+
+ Control::StateChanged( nType );
+}
+
+// -----------------------------------------------------------------------
+
+void ScPrivatSplit::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( TRUE, TRUE, TRUE );
+ Invalidate();
+ }
+ else
+ Window::DataChanged( rDCEvt );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibilityHints.hxx b/sc/source/ui/inc/AccessibilityHints.hxx
new file mode 100644
index 000000000000..6f6de13430d3
--- /dev/null
+++ b/sc/source/ui/inc/AccessibilityHints.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_ACCESSIBILITYHINTS_HXX
+#define SC_ACCESSIBILITYHINTS_HXX
+
+#include "viewdata.hxx"
+#include <com/sun/star/uno/XInterface.hpp>
+#include <svl/smplhint.hxx>
+#include <svl/hint.hxx>
+
+#define SC_HINT_ACC_SIMPLE_START SFX_HINT_USER00
+#define SC_HINT_ACC_TABLECHANGED SC_HINT_ACC_SIMPLE_START + 1
+#define SC_HINT_ACC_CURSORCHANGED SC_HINT_ACC_SIMPLE_START + 2
+#define SC_HINT_ACC_VISAREACHANGED SC_HINT_ACC_SIMPLE_START + 3
+#define SC_HINT_ACC_ENTEREDITMODE SC_HINT_ACC_SIMPLE_START + 4
+#define SC_HINT_ACC_LEAVEEDITMODE SC_HINT_ACC_SIMPLE_START + 5
+#define SC_HINT_ACC_MAKEDRAWLAYER SC_HINT_ACC_SIMPLE_START + 6
+#define SC_HINT_ACC_WINDOWRESIZED SC_HINT_ACC_SIMPLE_START + 7
+
+class ScAccWinFocusLostHint : public SfxHint
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ xOldAccessible;
+public:
+ TYPEINFO();
+ ScAccWinFocusLostHint(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xOld );
+ ~ScAccWinFocusLostHint();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ GetOldAccessible() const { return xOldAccessible; }
+};
+
+class ScAccWinFocusGotHint : public SfxHint
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ xNewAccessible;
+public:
+ TYPEINFO();
+ ScAccWinFocusGotHint(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xNew );
+ ~ScAccWinFocusGotHint();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ GetNewAccessible() const { return xNewAccessible; }
+};
+
+class ScAccGridWinFocusLostHint : public ScAccWinFocusLostHint
+{
+ ScSplitPos eOldGridWin;
+public:
+ TYPEINFO();
+ ScAccGridWinFocusLostHint( ScSplitPos eOldGridWin,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xOld );
+ ~ScAccGridWinFocusLostHint();
+
+ ScSplitPos GetOldGridWin() const { return eOldGridWin; }
+};
+
+class ScAccGridWinFocusGotHint : public ScAccWinFocusGotHint
+{
+ ScSplitPos eNewGridWin;
+public:
+ TYPEINFO();
+ ScAccGridWinFocusGotHint( ScSplitPos eNewGridWin,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& xNew );
+ ~ScAccGridWinFocusGotHint();
+
+ ScSplitPos GetNewGridWin() const { return eNewGridWin; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleCell.hxx b/sc/source/ui/inc/AccessibleCell.hxx
new file mode 100644
index 000000000000..e40636a2660a
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleCell.hxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLECELL_HXX
+#define _SC_ACCESSIBLECELL_HXX
+
+#include "AccessibleCellBase.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
+#include <unotools/accessiblerelationsethelper.hxx>
+#include <editeng/AccessibleStaticTextBase.hxx>
+#include <comphelper/uno3.hxx>
+
+class ScTabViewShell;
+class ScAccessibleDocument;
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleCell</code> service.
+*/
+class ScAccessibleCell
+ : public ScAccessibleCellBase,
+ public accessibility::AccessibleStaticTextBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleCell(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScTabViewShell* pViewShell,
+ ScAddress& rCellAddress,
+ sal_Int32 nIndex,
+ ScSplitPos eSplitPos,
+ ScAccessibleDocument* pAccDoc);
+
+ virtual void Init();
+
+ using ScAccessibleCellBase::disposing;
+ virtual void SAL_CALL disposing();
+
+protected:
+ virtual ~ScAccessibleCell();
+
+ using ScAccessibleCellBase::IsDefunc;
+
+public:
+ ///===== XInterface =====================================================
+
+ DECLARE_XINTERFACE()
+
+ ///===== XTypeProvider ===================================================
+
+ DECLARE_XTYPEPROVIDER()
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ // is overloaded to calculate this on demand
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ // is overloaded to calculate this on demand
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
+ getAccessibleRelationSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a list of all supported services.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScTabViewShell* mpViewShell;
+ ScAccessibleDocument* mpAccDoc;
+
+ ScSplitPos meSplitPos;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ virtual sal_Bool IsEditable(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ sal_Bool IsOpaque(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ sal_Bool IsSelected();
+
+ ScDocument* GetDocument(ScTabViewShell* mpViewShell);
+
+ ::std::auto_ptr< SvxEditSource > CreateEditSource(ScTabViewShell* pViewShell, ScAddress aCell, ScSplitPos eSplitPos);
+
+ void FillDependends(utl::AccessibleRelationSetHelper* pRelationSet);
+ void FillPrecedents(utl::AccessibleRelationSetHelper* pRelationSet);
+ void AddRelation(const ScAddress& rCell,
+ const sal_uInt16 aRelationType,
+ ::utl::AccessibleRelationSetHelper* pRelationSet);
+ void AddRelation(const ScRange& rRange,
+ const sal_uInt16 aRelationType,
+ ::utl::AccessibleRelationSetHelper* pRelationSet);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleCellBase.hxx b/sc/source/ui/inc/AccessibleCellBase.hxx
new file mode 100644
index 000000000000..1edbe7f1b878
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleCellBase.hxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLECELLBASE_HXX
+#define _SC_ACCESSIBLECELLBASE_HXX
+
+#include "AccessibleContextBase.hxx"
+#include "global.hxx"
+#include "address.hxx"
+#include <com/sun/star/accessibility/XAccessibleValue.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+class ScTabViewShell;
+
+typedef cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleValue>
+ ScAccessibleCellBaseImpl;
+
+class ScAccessibleCellBase
+ : public ScAccessibleContextBase,
+ public ScAccessibleCellBaseImpl
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleCellBase(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScDocument* pDoc,
+ const ScAddress& rCellAddress,
+ sal_Int32 nIndex);
+protected:
+ virtual ~ScAccessibleCellBase();
+public:
+
+ ///===== XInterface =====================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw ();
+
+ virtual void SAL_CALL release() throw ();
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual sal_Bool SAL_CALL isVisible( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return this objects index among the parents children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleIndexInParent(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ ///===== XAccessibleValue ================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getCurrentValue( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ setCurrentValue( const ::com::sun::star::uno::Any& aNumber )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getMaximumValue( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Any SAL_CALL
+ getMinimumValue( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /// returns the possible types
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ ScAddress maCellAddress;
+
+ ScDocument* mpDoc;
+
+ sal_Int32 mnIndex;
+
+private:
+ virtual sal_Bool IsEditable(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleContextBase.hxx b/sc/source/ui/inc/AccessibleContextBase.hxx
new file mode 100644
index 000000000000..8db6137b2147
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleContextBase.hxx
@@ -0,0 +1,345 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLECONTEXTBASE_HXX
+#define _SC_ACCESSIBLECONTEXTBASE_HXX
+
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <com/sun/star/accessibility/XAccessibleComponent.hpp>
+#include <com/sun/star/accessibility/XAccessibleContext.hpp>
+#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
+#include <com/sun/star/accessibility/IllegalAccessibleComponentStateException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/uno/Reference.hxx>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <osl/mutex.hxx>
+#include <cppuhelper/interfacecontainer.h>
+
+
+#include <svl/lstner.hxx>
+#include <cppuhelper/compbase5.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/servicehelper.hxx>
+#include <comphelper/broadcasthelper.hxx>
+
+class Rectangle;
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleContext</code> service.
+*/
+
+typedef cppu::WeakAggComponentImplHelper5<
+ ::com::sun::star::accessibility::XAccessible,
+ ::com::sun::star::accessibility::XAccessibleComponent,
+ ::com::sun::star::accessibility::XAccessibleContext,
+ ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
+ ::com::sun::star::lang::XServiceInfo
+ > ScAccessibleContextBaseWeakImpl;
+
+typedef cppu::ImplHelper1<
+ ::com::sun::star::accessibility::XAccessibleEventListener
+ > ScAccessibleContextBaseImplEvent;
+
+class ScAccessibleContextBase
+ : public comphelper::OBaseMutex,
+ public ScAccessibleContextBaseWeakImpl,
+ public ScAccessibleContextBaseImplEvent,
+ public SfxListener
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleContextBase(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ const sal_Int16 aRole);
+
+ virtual void Init();
+ virtual void SAL_CALL disposing();
+protected:
+ virtual ~ScAccessibleContextBase(void);
+public:
+ using WeakAggComponentImplHelperBase::addEventListener;
+ using WeakAggComponentImplHelperBase::removeEventListener;
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XInterface =====================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw ();
+
+ virtual void SAL_CALL release() throw ();
+
+ ///===== XAccessible =====================================================
+
+ /// Return the XAccessibleContext.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL
+ getAccessibleContext(void) throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual sal_Bool SAL_CALL containsPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocation( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isShowing( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isVisible( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return a reference to the parent.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleParent(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return this objects index among the parents children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleIndexInParent(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return this object's role.
+ virtual sal_Int16 SAL_CALL
+ getAccessibleRole(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return NULL to indicate that an empty relation set.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
+ getAccessibleRelationSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Return the parents locale or throw exception if this object has no
+ parent yet/anymore.
+ */
+ virtual ::com::sun::star::lang::Locale SAL_CALL
+ getLocale(void)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::accessibility::IllegalAccessibleComponentStateException);
+
+ ///===== XAccessibleEventBroadcaster =====================================
+
+ /** Add listener that is informed of future changes of name,
+ description and so on events.
+ */
+ virtual void SAL_CALL
+ addEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException);
+
+ // Remove an existing event listener.
+ virtual void SAL_CALL
+ removeEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleEventListener ========================================
+
+ virtual void SAL_CALL
+ disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ notifyEvent(
+ const ::com::sun::star::accessibility::AccessibleEventObject& aEvent )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Return whether the specified service is supported by this class.
+ */
+ virtual sal_Bool SAL_CALL
+ supportsService(const ::rtl::OUString& sServiceName)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a list of all supported services. In this case that is just
+ the AccessibleContext and Accessible service.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /// returns the possible types
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ /// Calls all Listener to tell they the change.
+ void
+ CommitChange(const com::sun::star::accessibility::AccessibleEventObject& rEvent) const;
+
+ /// change the name and call the listener to tell they the change
+ void
+ ChangeName();
+
+protected:
+ /// Calls all FocusListener to tell they that the focus is gained.
+ void CommitFocusGained() const;
+
+ /// Calls all FocusListener to tell they that the focus is lost.
+ void CommitFocusLost() const;
+
+ sal_Bool IsDefunc() const { return rBHelper.bDisposed; }
+
+ virtual void IsObjectValid() const
+ throw (::com::sun::star::lang::DisposedException);
+
+ /// Use this method to set initial Name without notification
+ void SetName(const rtl::OUString& rName) { msName = rName; }
+ /// Use this method to set initial Description without notification
+ void SetDescription(const rtl::OUString& rDesc) { msDescription = rDesc; }
+
+ /// Reference to the parent object.
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible> mxParent;
+
+private:
+ /** Description of this object. This is not a constant because it can
+ be set from the outside. Furthermore, it changes according the the
+ draw page's display mode.
+ */
+ ::rtl::OUString msDescription;
+
+ /** Name of this object. It changes according the the draw page's
+ display mode.
+ */
+ ::rtl::OUString msName;
+
+ /// client id in the AccessibleEventNotifier queue
+ sal_uInt32 mnClientId;
+
+ /** This is the role of this object.
+ */
+ sal_Int16 maRole;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleCsvControl.hxx b/sc/source/ui/inc/AccessibleCsvControl.hxx
new file mode 100644
index 000000000000..f4eb41dd3c9a
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleCsvControl.hxx
@@ -0,0 +1,668 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_ACCESSIBLECSVCONTROL_HXX
+#define _SC_ACCESSIBLECSVCONTROL_HXX
+
+#include <com/sun/star/accessibility/XAccessibleText.hpp>
+#include <com/sun/star/accessibility/XAccessibleTable.hpp>
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <tools/gen.hxx>
+#include <tools/string.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <editeng/AccessibleStaticTextBase.hxx>
+#include <comphelper/uno3.hxx>
+#include "AccessibleContextBase.hxx"
+
+
+// ============================================================================
+
+class ScCsvControl;
+namespace utl { class AccessibleStateSetHelper; }
+
+/** Accessible base class used for CSV controls. */
+class ScAccessibleCsvControl : public ScAccessibleContextBase
+{
+protected:
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > XAccessibleRef;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleRelationSet > XAccessibleRelationSetRef;
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet > XAccessibleStateSetRef;
+
+ typedef ::com::sun::star::awt::Point AwtPoint;
+ typedef ::com::sun::star::awt::Size AwtSize;
+ typedef ::com::sun::star::awt::Rectangle AwtRectangle;
+
+private:
+ ScCsvControl* mpControl; /// Pointer to the VCL control.
+
+public:
+ explicit ScAccessibleCsvControl(
+ const XAccessibleRef& rxParent,
+ ScCsvControl& rControl,
+ sal_uInt16 nRole );
+ virtual ~ScAccessibleCsvControl();
+
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ // XAccessibleComponent ---------------------------------------------------
+
+ /** Returns the child at the specified point (cell returns NULL). */
+ virtual XAccessibleRef SAL_CALL getAccessibleAtPoint( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the control is visible. */
+ virtual sal_Bool SAL_CALL isVisible() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Sets the focus to this control. */
+ virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException );
+
+ // events -----------------------------------------------------------------
+public:
+ /** Sends a GetFocus or LoseFocus event to all listeners. */
+ virtual void SendFocusEvent( bool bFocused );
+ /** Sends a caret changed event to all listeners. */
+ virtual void SendCaretEvent();
+ /** Sends a visible area changed event to all listeners. */
+ virtual void SendVisibleEvent();
+ /** Sends a selection changed event to all listeners. */
+ virtual void SendSelectionEvent();
+ /** Sends a table model changed event for changed cell contents to all listeners. */
+ virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows );
+ /** Sends a table model changed event for an inserted column to all listeners. */
+ virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+ /** Sends a table model changed event for a removed column to all listeners. */
+ virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+
+ // helpers ----------------------------------------------------------------
+protected:
+ /** Returns this object's current bounding box relative to the desktop. */
+ virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's current bounding box relative to the parent object. */
+ virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Creates a new UUID in rSeq, if it is empty. Locks mutex internally. */
+ void getUuid( ::com::sun::star::uno::Sequence< sal_Int8 >& rSeq );
+
+ /** Returns whether the object is alive. Must be called with locked mutex. */
+ inline bool implIsAlive() const { return !rBHelper.bDisposed && !rBHelper.bInDispose && mpControl; }
+ /** Throws an exception, if the object is disposed/disposing or any pointer
+ is missing. Should be used with locked mutex! */
+ void ensureAlive() const throw( ::com::sun::star::lang::DisposedException );
+
+ /** Returns the VCL control. Assumes a living object. */
+ ScCsvControl& implGetControl() const;
+
+ /** Returns the first child of rxParentObj, which has the role nRole. */
+ XAccessibleRef implGetChildByRole( const XAccessibleRef& rxParentObj, sal_uInt16 nRole )
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Creates a StateSetHelper and fills it with DEFUNC, OPAQUE, ENABLED, SHOWING and VISIBLE. */
+ ::utl::AccessibleStateSetHelper* implCreateStateSet();
+
+ /** Disposes the object. This is a helper called from destructors only. */
+ void implDispose();
+
+ /** Converts the control-relative position to an absolute screen position. */
+ Point implGetAbsPos( const Point& rPos ) const;
+};
+
+
+// ============================================================================
+
+class ScCsvRuler;
+
+typedef ::cppu::ImplHelper1<
+ ::com::sun::star::accessibility::XAccessibleText >
+ ScAccessibleCsvRulerImpl;
+
+/** Accessible class representing the CSV ruler control. */
+class ScAccessibleCsvRuler : public ScAccessibleCsvControl, public ScAccessibleCsvRulerImpl
+{
+protected:
+ typedef ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > PropertyValueSeq;
+
+private:
+ ::rtl::OUStringBuffer maBuffer; /// Contains the text representation of the ruler.
+
+public:
+ explicit ScAccessibleCsvRuler( ScCsvRuler& rRuler );
+ virtual ~ScAccessibleCsvRuler();
+
+ // XAccessibleComponent -----------------------------------------------------
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext -----------------------------------------------------
+
+ /** Returns the child count (the ruler does not have children). */
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception (the ruler does not have childern). */
+ virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the relation to the grid control. */
+ virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the current set of states. */
+ virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleText --------------------------------------------------------
+
+ /** Return the position of the caret. */
+ virtual sal_Int32 SAL_CALL getCaretPosition() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Sets the position of the caret. */
+ virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified character. */
+ virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the attributes of the specified character. */
+ virtual PropertyValueSeq SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aRequestedAttributes )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the screen coordinates of the specified character. */
+ virtual AwtRectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the count of characters. */
+ virtual sal_Int32 SAL_CALL getCharacterCount() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the character index at the specified coordinate (object's coordinate system). */
+ virtual sal_Int32 SAL_CALL getIndexAtPoint( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected text (ruler returns empty string). */
+ virtual ::rtl::OUString SAL_CALL getSelectedText() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the start index of the selection (ruler returns -1). */
+ virtual sal_Int32 SAL_CALL getSelectionStart() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the end index of the selection (ruler returns -1). */
+ virtual sal_Int32 SAL_CALL getSelectionEnd() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Selects a part of the text (ruler does nothing). */
+ virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the entire text. */
+ virtual ::rtl::OUString SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified range [Start,End) of the text. */
+ virtual ::rtl::OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified text portion. */
+ virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ /** Copies the specified text range into the clipboard (ruler does nothing). */
+ virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ // XInterface -------------------------------------------------------------
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire() throw();
+
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo -----------------------------------------------------------
+
+ /** Returns an identifier for the implementation of this object. */
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider ----------------------------------------------------------
+
+ /** Returns a sequence with all supported interface types. */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns an implementation ID. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // events -----------------------------------------------------------------
+public:
+ /** Sends a caret changed event to all listeners. */
+ virtual void SendCaretEvent();
+
+ // helpers ----------------------------------------------------------------
+private:
+ /** Returns this object's name. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's description. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception, if the specified character position is invalid (outside 0..len-1). */
+ void ensureValidIndex( sal_Int32 nIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+ /** Throws an exception, if the specified character position is invalid (outside 0..len). */
+ void ensureValidIndexWithEnd( sal_Int32 nIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+ /** Throws an exception, if the specified character range [Start,End) is invalid.
+ @descr If Start>End, swaps Start and End before checking. */
+ void ensureValidRange( sal_Int32& rnStartIndex, sal_Int32& rnEndIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** Returns the VCL ruler control. Assumes a living object. */
+ ScCsvRuler& implGetRuler() const;
+
+ /** Builds the entire string buffer. */
+ void constructStringBuffer() throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns the character count of the text. */
+ sal_Int32 implGetTextLength() const;
+
+ /** Returns true, if the character at the specified index has a split. */
+ bool implHasSplit( sal_Int32 nApiPos );
+
+ /** Returns the first character index with equal formatting as at nApiPos. */
+ sal_Int32 implGetFirstEqualFormatted( sal_Int32 nApiPos );
+ /** Returns the last character index with equal formatting as at nApiPos. */
+ sal_Int32 implGetLastEqualFormatted( sal_Int32 nApiPos );
+};
+
+
+// ============================================================================
+
+class ScCsvGrid;
+
+typedef ::cppu::ImplHelper2<
+ ::com::sun::star::accessibility::XAccessibleTable,
+ ::com::sun::star::accessibility::XAccessibleSelection >
+ ScAccessibleCsvGridImpl;
+
+/** Accessible class representing the CSV grid control. */
+class ScAccessibleCsvGrid : public ScAccessibleCsvControl, public ScAccessibleCsvGridImpl
+{
+protected:
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleTable > XAccessibleTableRef;
+
+public:
+ explicit ScAccessibleCsvGrid( ScCsvGrid& rGrid );
+ virtual ~ScAccessibleCsvGrid();
+
+ // XAccessibleComponent ---------------------------------------------------
+
+ /** Returns the cell at the specified point. */
+ virtual XAccessibleRef SAL_CALL getAccessibleAtPoint( const AwtPoint& rPoint )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext -----------------------------------------------------
+
+ /** Returns the child count (count of cells in the table). */
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified child cell. */
+ virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the relation to the ruler control. */
+ virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the current set of states. */
+ virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleTable -------------------------------------------------------
+
+ /** Returns the number of rows in the table. */
+ virtual sal_Int32 SAL_CALL getAccessibleRowCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the number of columns in the table. */
+ virtual sal_Int32 SAL_CALL getAccessibleColumnCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the description of the specified row in the table. */
+ virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the description text of the specified column in the table. */
+ virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the number of rows occupied at a specified row and column.
+ @descr Returns always 1 (Merged cells not supported). */
+ virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the number of rows occupied at a specified row and column.
+ @descr Returns always 1 (Merged cells not supported). */
+ virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the row headers as an AccessibleTable. */
+ virtual XAccessibleTableRef SAL_CALL getAccessibleRowHeaders()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the column headers as an AccessibleTable. */
+ virtual XAccessibleTableRef SAL_CALL getAccessibleColumnHeaders()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected rows as a sequence. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the selected columns as a sequence. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the specified row is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the specified column is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the accessible cell object at the specified position. */
+ virtual XAccessibleRef SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the caption object of the table. */
+ virtual XAccessibleRef SAL_CALL getAccessibleCaption()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the summary description object of the table. */
+ virtual XAccessibleRef SAL_CALL getAccessibleSummary()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the cell at a specified position is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the child index of the cell at the specified position. */
+ virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the row index of the specified child. */
+ virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the column index of the specified child. */
+ virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ // XAccessibleSelection ---------------------------------------------------
+
+ /** Selects the specified child (selects the entire column or the entire table). */
+ virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns true, if the specified child is selected. */
+ virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Deselects all cells. */
+ virtual void SAL_CALL clearAccessibleSelection()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Selects all cells. */
+ virtual void SAL_CALL selectAllAccessibleChildren()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the count of selected children. */
+ virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the child with the specified index in all selected children. */
+ virtual XAccessibleRef SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Deselects the child with the specified index in all selected children. */
+ virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ // XInterface -------------------------------------------------------------
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL acquire() throw();
+
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo -----------------------------------------------------------
+
+ /** Returns an identifier for the implementation of this object. */
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTypeProvider ----------------------------------------------------------
+
+ /** Returns a sequence with all supported interface types. */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns an implementation ID. */
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // events -----------------------------------------------------------------
+public:
+ /** Sends a GetFocus or LoseFocus event to all listeners. */
+ virtual void SendFocusEvent( bool bFocused );
+ /** Sends a table model changed event for changed cell contents to all listeners. */
+ virtual void SendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows );
+ /** Sends a table model changed event for an inserted column to all listeners. */
+ virtual void SendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+ /** Sends a table model changed event for a removed column to all listeners. */
+ virtual void SendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+
+ // helpers ----------------------------------------------------------------
+private:
+ /** Returns this object's name. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's description. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Throws an exception, if nIndex is not a valid child index. */
+ void ensureValidIndex( sal_Int32 nIndex ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+ /** Throws an exception, if the specified position is invalid. */
+ void ensureValidPosition( sal_Int32 nRow, sal_Int32 nColumn ) const
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException );
+
+ /** Returns the VCL grid control. Assumes a living object. */
+ ScCsvGrid& implGetGrid() const;
+
+ /** Returns true, if the specified column (including header) is selected. */
+ bool implIsColumnSelected( sal_Int32 nColumn ) const;
+ /** Selects the specified column (including header). */
+ void implSelectColumn( sal_Int32 nColumn, bool bSelect );
+
+ /** Returns the count of visible rows in the table (including header). */
+ sal_Int32 implGetRowCount() const;
+ /** Returns the total column count in the table (including header). */
+ sal_Int32 implGetColumnCount() const;
+ /** Returns the count of selected columns in the table. */
+ sal_Int32 implGetSelColumnCount() const;
+ /** Returns the total cell count in the table (including header). */
+ inline sal_Int32 implGetCellCount() const { return implGetRowCount() * implGetColumnCount(); }
+
+ /** Returns the row index from cell index (including header). */
+ inline sal_Int32 implGetRow( sal_Int32 nIndex ) const { return nIndex / implGetColumnCount(); }
+ /** Returns the column index from cell index (including header). */
+ inline sal_Int32 implGetColumn( sal_Int32 nIndex ) const { return nIndex % implGetColumnCount(); }
+ /** Returns the absolute column index of the nSelColumn-th selected column. */
+ sal_Int32 implGetSelColumn( sal_Int32 nSelColumn ) const;
+ /** Returns the child index from cell position (including header). */
+ inline sal_Int32 implGetIndex( sal_Int32 nRow, sal_Int32 nColumn ) const { return nRow * implGetColumnCount() + nColumn; }
+
+ /** Returns the contents of the specified cell (including header). Indexes must be valid. */
+ String implGetCellText( sal_Int32 nRow, sal_Int32 nColumn ) const;
+ /** Creates a new accessible object of the specified cell. Indexes must be valid. */
+ ScAccessibleCsvControl* implCreateCellObj( sal_Int32 nRow, sal_Int32 nColumn ) const;
+};
+
+
+// ============================================================================
+
+/** Accessible class representing a cell of the CSV grid control. */
+class ScAccessibleCsvCell : public ScAccessibleCsvControl, public accessibility::AccessibleStaticTextBase
+{
+protected:
+ typedef ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue > PropertyValueSeq;
+ typedef ::std::auto_ptr< SvxEditSource > SvxEditSourcePtr;
+
+private:
+ String maCellText; /// The text contents of this cell.
+ sal_Int32 mnLine; /// The grid line index (core index).
+ sal_uInt32 mnColumn; /// The grid column index (core index).
+ sal_Int32 mnIndex; /// The index of the cell in the table.
+
+public:
+ explicit ScAccessibleCsvCell(
+ ScCsvGrid& rGrid,
+ const String& rCellText,
+ sal_Int32 nRow, sal_Int32 nColumn );
+ virtual ~ScAccessibleCsvCell();
+
+ using ScAccessibleCsvControl::disposing;
+ virtual void SAL_CALL disposing();
+
+ // XAccessibleComponent ---------------------------------------------------
+
+ /** Sets the focus to the column of this cell. */
+ virtual void SAL_CALL grabFocus() throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XAccessibleContext -----------------------------------------------------
+
+ /** Returns the child count. */
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the specified child. */
+ virtual XAccessibleRef SAL_CALL getAccessibleChild( sal_Int32 nIndex )
+ throw( ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the index of this cell in the table. */
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the relation to the ruler control. */
+ virtual XAccessibleRelationSetRef SAL_CALL getAccessibleRelationSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the current set of states. */
+ virtual XAccessibleStateSetRef SAL_CALL getAccessibleStateSet()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XInterface -------------------------------------------------------------
+
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider ----------------------------------------------------------
+
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo -----------------------------------------------------------
+
+ /** Returns an identifier for the implementation of this object. */
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // helpers ----------------------------------------------------------------
+protected:
+ /** Returns this object's current bounding box relative to the desktop. */
+ virtual Rectangle GetBoundingBoxOnScreen() const throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's current bounding box relative to the parent object. */
+ virtual Rectangle GetBoundingBox() const throw( ::com::sun::star::uno::RuntimeException );
+
+private:
+ /** Returns this object's name. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleName()
+ throw( ::com::sun::star::uno::RuntimeException );
+ /** Returns this object's description. */
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription()
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ /** Returns the VCL grid control. Assumes a living object. */
+ ScCsvGrid& implGetGrid() const;
+ /** Returns the pixel position of the cell (rel. to parent), regardless of visibility. */
+ Point implGetRealPos() const;
+ /** Returns the width of the character count */
+ sal_uInt32 implCalcPixelWidth(sal_uInt32 nChars) const;
+ /** Returns the pixel size of the cell, regardless of visibility. */
+ Size implGetRealSize() const;
+ /** Returns the bounding box of the cell relative in the table. */
+ Rectangle implGetBoundingBox() const;
+
+ /** Creates the edit source the text helper needs. */
+ ::std::auto_ptr< SvxEditSource > implCreateEditSource();
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleDataPilotControl.hxx b/sc/source/ui/inc/AccessibleDataPilotControl.hxx
new file mode 100644
index 000000000000..1b6578c41e16
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleDataPilotControl.hxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEDATAPILOTCONTROL_HXX
+#define _SC_ACCESSIBLEDATAPILOTCONTROL_HXX
+
+#include "AccessibleContextBase.hxx"
+
+class ScDPFieldWindow;
+class ScAccessibleDataPilotButton;
+
+class ScAccessibleDataPilotControl
+ : public ScAccessibleContextBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleDataPilotControl(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScDPFieldWindow* pDPFieldWindow);
+
+ virtual void Init();
+
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ void AddField(sal_Int32 nNewIndex);
+ void RemoveField(sal_Int32 nOldIndex);
+ void FieldFocusChange(sal_Int32 nOldIndex, sal_Int32 nNewIndex);
+ void FieldNameChange(sal_Int32 nIndex);
+ void GotFocus();
+ void LostFocus();
+protected:
+ virtual ~ScAccessibleDataPilotControl(void);
+public:
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL isVisible( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void) throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScDPFieldWindow* mpDPFieldWindow;
+ struct AccessibleWeak
+ {
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > xWeakAcc;
+ ScAccessibleDataPilotButton* pAcc;
+ AccessibleWeak() : pAcc(NULL) {}
+ };
+ ::std::vector< AccessibleWeak > maChildren;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleDocument.hxx b/sc/source/ui/inc/AccessibleDocument.hxx
new file mode 100644
index 000000000000..7facaf856d6f
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleDocument.hxx
@@ -0,0 +1,331 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEDOCUMENT_HXX
+#define _SC_ACCESSIBLEDOCUMENT_HXX
+
+#include "AccessibleDocumentBase.hxx"
+#include "viewdata.hxx"
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <svx/IAccessibleViewForwarder.hxx>
+
+class ScTabViewShell;
+class ScAccessibleSpreadsheet;
+class ScChildrenShapes;
+class ScAccessibleEditObject;
+
+namespace accessibility
+{
+ class AccessibleShape;
+}
+namespace utl
+{
+ class AccessibleRelationSetHelper;
+}
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleContext</code> service.
+*/
+
+typedef cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessibleSelection,
+ ::com::sun::star::view::XSelectionChangeListener >
+ ScAccessibleDocumentImpl;
+
+class ScAccessibleDocument
+ : public ScAccessibleDocumentBase,
+ public ScAccessibleDocumentImpl,
+ public accessibility::IAccessibleViewForwarder
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleDocument(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScTabViewShell* pViewShell,
+ ScSplitPos eSplitPos);
+
+ virtual void Init();
+
+
+ DECL_LINK( WindowChildEventListener, VclSimpleEvent* );
+protected:
+ virtual ~ScAccessibleDocument(void);
+
+ using ScAccessibleDocumentBase::IsDefunc;
+
+public:
+
+ virtual void SAL_CALL disposing();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XInterface =====================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw ();
+
+ virtual void SAL_CALL release() throw ();
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleSelection ===========================================
+
+ virtual void SAL_CALL
+ selectAccessibleChild( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ clearAccessibleSelection( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ selectAllAccessibleChildren( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL
+ getSelectedAccessibleChildCount( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ deselectAccessibleChild( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ ///===== XSelectionListener =============================================
+
+ virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ===================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a list of all supported services.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /// returns the possible types
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== IAccessibleViewForwarder ========================================
+
+ /** This method informs you about the state of the forwarder. Do not
+ use it when the returned value is <false/>.
+
+ @return
+ Return <true/> if the view forwarder is valid and <false/> else.
+ */
+ virtual sal_Bool IsValid (void) const;
+
+ /** Returns the area of the underlying document that is visible in the
+ * corresponding window.
+
+ @return
+ The rectangle of the visible part of the document. The values
+ are, contrary to the base class, in internal coordinates.
+ */
+ virtual Rectangle GetVisibleArea() const;
+
+ /** Transform the specified point from internal coordinates to an
+ absolute screen position.
+
+ @param rPoint
+ Point in internal coordinates.
+
+ @return
+ The same point but in screen coordinates relative to the upper
+ left corner of the (current) screen.
+ */
+ virtual Point LogicToPixel (const Point& rPoint) const;
+
+ /** Transform the specified size from internal coordinates to a screen
+ * oriented pixel size.
+
+ @param rSize
+ Size in internal coordinates.
+
+ @return
+ The same size but in screen coordinates.
+ */
+ virtual Size LogicToPixel (const Size& rSize) const;
+
+ /** Transform the specified point from absolute screen coordinates to
+ internal coordinates.
+
+ @param rPoint
+ Point in screen coordinates relative to the upper left corner of
+ the (current) screen.
+
+ @return
+ The same point but in internal coordinates.
+ */
+ virtual Point PixelToLogic (const Point& rPoint) const;
+
+ /** Transform the specified size from screen coordinates to internal
+ coordinates.
+
+ @param rSize
+ Size in screen coordinates.
+
+ @return
+ The same size but in internal coordinates.
+ */
+ virtual Size PixelToLogic (const Size& rSize) const;
+
+ ///======== internal =====================================================
+
+ utl::AccessibleRelationSetHelper* GetRelationSet(const ScAddress* pAddress) const;
+
+ ::com::sun::star::uno::Reference
+ < ::com::sun::star::accessibility::XAccessible >
+ GetAccessibleSpreadsheet();
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScTabViewShell* mpViewShell;
+ ScSplitPos meSplitPos;
+ ScAccessibleSpreadsheet* mpAccessibleSpreadsheet;
+ ScChildrenShapes* mpChildrenShapes;
+ ScAccessibleEditObject* mpTempAccEdit;
+ com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> mxTempAcc;
+ Rectangle maVisArea;
+ sal_Bool mbCompleteSheetSelected;
+
+public:
+ SCTAB getVisibleTable() const; // use it in ScChildrenShapes
+
+private:
+ void FreeAccessibleSpreadsheet();
+
+ sal_Bool IsTableSelected() const;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ sal_Bool IsEditable(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ void AddChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
+ void RemoveChild(const com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>& xAcc, sal_Bool bFireEvent);
+
+ rtl::OUString GetCurrentCellName() const;
+ rtl::OUString GetCurrentCellDescription() const;
+
+ Rectangle GetVisibleArea_Impl() const;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleDocumentBase.hxx b/sc/source/ui/inc/AccessibleDocumentBase.hxx
new file mode 100644
index 000000000000..5a5ebdb191b1
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleDocumentBase.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEDOCUMENTBASE_HXX
+#define _SC_ACCESSIBLEDOCUMENTBASE_HXX
+
+#include "AccessibleContextBase.hxx"
+
+class ScAccessibleDocumentBase
+ : public ScAccessibleContextBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleDocumentBase(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent);
+protected:
+ virtual ~ScAccessibleDocumentBase (void);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx b/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx
new file mode 100644
index 000000000000..058d92c238a8
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleDocumentPagePreview.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX
+#define _SC_ACCESSIBLEDOCUMENTPAGEPREVIEW_HXX
+
+#include "AccessibleDocumentBase.hxx"
+
+class ScPreviewShell;
+class ScNotesChilds;
+class ScShapeChilds;
+class ScAccessiblePreviewTable;
+class ScAccessiblePageHeader;
+
+class ScAccessibleDocumentPagePreview
+ : public ScAccessibleDocumentBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleDocumentPagePreview(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell );
+protected:
+ virtual ~ScAccessibleDocumentPagePreview(void);
+
+ using ScAccessibleDocumentBase::IsDefunc;
+
+public:
+ using ScAccessibleContextBase::disposing;
+
+ virtual void SAL_CALL disposing();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a list of all supported services.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== internal ========================================================
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+public: // needed in ScShapeChilds
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScPreviewShell* mpViewShell;
+ ScNotesChilds* mpNotesChilds;
+ ScShapeChilds* mpShapeChilds;
+ ScAccessiblePreviewTable* mpTable;
+ ScAccessiblePageHeader* mpHeader;
+ ScAccessiblePageHeader* mpFooter;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ ScNotesChilds* GetNotesChilds();
+ ScShapeChilds* GetShapeChilds();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleEditObject.hxx b/sc/source/ui/inc/AccessibleEditObject.hxx
new file mode 100644
index 000000000000..690dea145b62
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleEditObject.hxx
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEEDITOBJECT_HXX
+#define _SC_ACCESSIBLEEDITOBJECT_HXX
+
+#include "AccessibleContextBase.hxx"
+
+namespace accessibility
+{
+ class AccessibleTextHelper;
+}
+class EditView;
+class Window;
+
+enum EditObjectType
+{
+ CellInEditMode,
+ EditLine,
+ EditControl
+};
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleCell</code> service.
+*/
+class ScAccessibleEditObject
+ : public ScAccessibleContextBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleEditObject(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ EditView* pEditView, Window* pWin, const rtl::OUString& rName,
+ const rtl::OUString& rDescription, EditObjectType eObjectType);
+
+protected:
+ virtual ~ScAccessibleEditObject();
+
+ using ScAccessibleContextBase::IsDefunc;
+
+public:
+ using ScAccessibleContextBase::addEventListener;
+ using ScAccessibleContextBase::removeEventListener;
+ using ScAccessibleContextBase::disposing;
+
+ virtual void SAL_CALL disposing();
+
+ virtual void LostFocus();
+
+ virtual void GotFocus();
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ // is overloaded to calculate this on demand
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ // is overloaded to calculate this on demand
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ ///===== XAccessibleEventBroadcaster =====================================
+
+ /** Add listener that is informed of future changes of name,
+ description and so on events.
+ */
+ virtual void SAL_CALL
+ addEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException);
+
+ // Remove an existing event listener.
+ virtual void SAL_CALL
+ removeEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ accessibility::AccessibleTextHelper* mpTextHelper;
+ EditView* mpEditView;
+ Window* mpWindow;
+ EditObjectType meObjectType;
+ sal_Bool mbHasFocus;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ void CreateTextHelper();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessiblePageHeader.hxx b/sc/source/ui/inc/AccessiblePageHeader.hxx
new file mode 100644
index 000000000000..acacbc933745
--- /dev/null
+++ b/sc/source/ui/inc/AccessiblePageHeader.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEPAGEHEADER_HXX
+#define _SC_ACCESSIBLEPAGEHEADER_HXX
+
+#include "AccessibleContextBase.hxx"
+#include <editeng/svxenum.hxx>
+
+class ScPreviewShell;
+class EditTextObject;
+class ScAccessiblePageHeaderArea;
+class ScPreviewShell;
+
+class ScAccessiblePageHeader : public ScAccessibleContextBase
+{
+public:
+ ScAccessiblePageHeader( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell, sal_Bool bHeader, sal_Int32 nIndex );
+
+protected:
+ virtual ~ScAccessiblePageHeader();
+
+ using ScAccessibleContextBase::IsDefunc;
+
+public:
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ //===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ //===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleContext ==============================================
+
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 i )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
+ getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ //===== internal ========================================================
+ void SetCurrentIndexInParent(sal_Int32 nNew) { mnIndex = nNew; }
+
+protected:
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL createAccessibleName(void) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual Rectangle GetBoundingBoxOnScreen(void) const throw(::com::sun::star::uno::RuntimeException);
+ virtual Rectangle GetBoundingBox(void) const throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScPreviewShell* mpViewShell;
+ sal_Int32 mnIndex;
+ sal_Bool mbHeader;
+ typedef std::vector< ScAccessiblePageHeaderArea* > ScHFAreas;
+ ScHFAreas maAreas;
+ sal_Int32 mnChildCount;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ void AddChild(const EditTextObject* pArea, sal_uInt32 nIndex, SvxAdjust eAdjust);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessiblePageHeaderArea.hxx b/sc/source/ui/inc/AccessiblePageHeaderArea.hxx
new file mode 100644
index 000000000000..c0c3758549d9
--- /dev/null
+++ b/sc/source/ui/inc/AccessiblePageHeaderArea.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEPAGEHEADERAREA_HXX
+#define _SC_ACCESSIBLEPAGEHEADERAREA_HXX
+
+#include "AccessibleContextBase.hxx"
+#include <editeng/svxenum.hxx>
+
+class EditTextObject;
+namespace accessibility
+{
+ class AccessibleTextHelper;
+}
+class ScPreviewShell;
+
+class ScAccessiblePageHeaderArea
+ : public ScAccessibleContextBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessiblePageHeaderArea(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell,
+ const EditTextObject* pEditObj,
+ sal_Bool bHeader,
+ SvxAdjust eAdjust);
+protected:
+ virtual ~ScAccessiblePageHeaderArea (void);
+public:
+ const EditTextObject* GetEditTextObject() const { return mpEditObj; }
+
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ // is overloaded to calculate this on demand
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ // is overloaded to calculate this on demand
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a list of all supported services. In this case that is just
+ the AccessibleContext and Accessible service.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL createAccessibleName(void) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual Rectangle GetBoundingBoxOnScreen(void) const throw(::com::sun::star::uno::RuntimeException);
+ virtual Rectangle GetBoundingBox(void) const throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ EditTextObject* mpEditObj;
+ accessibility::AccessibleTextHelper* mpTextHelper;
+ ScPreviewShell* mpViewShell;
+ sal_Bool mbHeader;
+ SvxAdjust meAdjust;
+
+ void CreateTextHelper();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessiblePreviewCell.hxx b/sc/source/ui/inc/AccessiblePreviewCell.hxx
new file mode 100644
index 000000000000..e4509a64754f
--- /dev/null
+++ b/sc/source/ui/inc/AccessiblePreviewCell.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEPREVIEWCELL_HXX
+#define _SC_ACCESSIBLEPREVIEWCELL_HXX
+
+#include "AccessibleCellBase.hxx"
+
+class ScPreviewShell;
+
+namespace accessibility
+{
+ class AccessibleTextHelper;
+}
+
+class ScAccessiblePreviewCell : public ScAccessibleCellBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessiblePreviewCell(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell, /* const */ ScAddress& rCellAddress, sal_Int32 nIndex );
+
+protected:
+ virtual ~ScAccessiblePreviewCell();
+
+ using ScAccessibleCellBase::IsDefunc;
+
+public:
+ using ScAccessibleCellBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ //===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleContext ==============================================
+
+ // overloaded to calculate this on demand
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 i )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
+ getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual Rectangle GetBoundingBoxOnScreen(void) const throw(::com::sun::star::uno::RuntimeException);
+ virtual Rectangle GetBoundingBox(void) const throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScPreviewShell* mpViewShell;
+
+ accessibility::AccessibleTextHelper* mpTextHelper;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ virtual sal_Bool IsEditable(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ sal_Bool IsOpaque(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ void CreateTextHelper();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx b/sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx
new file mode 100644
index 000000000000..5f013ac62aed
--- /dev/null
+++ b/sc/source/ui/inc/AccessiblePreviewHeaderCell.hxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEPREVIEWHEADERCELL_HXX
+#define _SC_ACCESSIBLEPREVIEWHEADERCELL_HXX
+
+#include "AccessibleContextBase.hxx"
+#include <com/sun/star/accessibility/XAccessibleValue.hpp>
+#include <tools/gen.hxx>
+#include "global.hxx"
+#include "address.hxx"
+#include <cppuhelper/implbase1.hxx>
+
+class ScPreviewShell;
+class ScPreviewTableInfo;
+namespace accessibility {
+ class AccessibleTextHelper;
+}
+
+typedef cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleValue>
+ ScAccessiblePreviewHeaderCellImpl;
+
+class ScAccessiblePreviewHeaderCell :
+ public ScAccessibleContextBase,
+ public ScAccessiblePreviewHeaderCellImpl
+{
+public:
+ ScAccessiblePreviewHeaderCell( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell,
+ const ScAddress& rCellPos, sal_Bool bIsColHdr, sal_Bool bIsRowHdr,
+ sal_Int32 nIndex );
+
+protected:
+ virtual ~ScAccessiblePreviewHeaderCell();
+
+ using ScAccessibleContextBase::IsDefunc;
+
+public:
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ //===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XInterface =====================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw ();
+
+ virtual void SAL_CALL release() throw ();
+
+ //===== XAccessibleValue ================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getCurrentValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL setCurrentValue( const ::com::sun::star::uno::Any& aNumber )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getMaximumValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getMinimumValue() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleContext ==============================================
+
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 i )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
+ getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL createAccessibleName(void) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual Rectangle GetBoundingBoxOnScreen(void) const throw(::com::sun::star::uno::RuntimeException);
+ virtual Rectangle GetBoundingBox(void) const throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScPreviewShell* mpViewShell;
+ accessibility::AccessibleTextHelper* mpTextHelper;
+ sal_Int32 mnIndex;
+ ScAddress maCellPos;
+ sal_Bool mbColumnHeader;
+ sal_Bool mbRowHeader;
+ mutable ScPreviewTableInfo* mpTableInfo;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ void CreateTextHelper();
+ void FillTableInfo() const;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessiblePreviewTable.hxx b/sc/source/ui/inc/AccessiblePreviewTable.hxx
new file mode 100644
index 000000000000..31c55d9bb383
--- /dev/null
+++ b/sc/source/ui/inc/AccessiblePreviewTable.hxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLEPREVIEWTABLE_HXX
+#define _SC_ACCESSIBLEPREVIEWTABLE_HXX
+
+#include "AccessibleContextBase.hxx"
+#include <com/sun/star/accessibility/XAccessibleTable.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+class ScPreviewShell;
+class ScPreviewTableInfo;
+
+typedef cppu::ImplHelper1< ::com::sun::star::accessibility::XAccessibleTable>
+ ScAccessiblePreviewTableImpl;
+
+class ScAccessiblePreviewTable :
+ public ScAccessibleContextBase,
+ public ScAccessiblePreviewTableImpl
+{
+public:
+ ScAccessiblePreviewTable( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScPreviewShell* pViewShell, sal_Int32 nIndex );
+
+protected:
+ virtual ~ScAccessiblePreviewTable();
+
+ using ScAccessibleContextBase::IsDefunc;
+
+public:
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ //===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XInterface =====================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw ();
+
+ virtual void SAL_CALL release() throw ();
+
+ //===== XAccessibleTable ================================================
+
+ virtual sal_Int32 SAL_CALL getAccessibleRowCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleColumnCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
+ getAccessibleRowHeaders() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
+ getAccessibleColumnHeaders() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleCaption() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleSummary() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XAccessibleContext ==============================================
+
+ virtual sal_Int32 SAL_CALL getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleChild( sal_Int32 i )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL
+ getAccessibleStateSet() throw (::com::sun::star::uno::RuntimeException);
+
+ //===== XServiceInfo ====================================================
+
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ //===== XTypeProvider ===================================================
+
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ //===== internal ========================================================
+ void SetCurrentIndexInParent(sal_Int32 nNew) { mnIndex = nNew; }
+
+protected:
+ virtual ::rtl::OUString SAL_CALL createAccessibleDescription(void) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL createAccessibleName(void) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual Rectangle GetBoundingBoxOnScreen(void) const throw(::com::sun::star::uno::RuntimeException);
+ virtual Rectangle GetBoundingBox(void) const throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScPreviewShell* mpViewShell;
+ sal_Int32 mnIndex;
+ mutable ScPreviewTableInfo* mpTableInfo;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+
+ void FillTableInfo() const;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleSpreadsheet.hxx b/sc/source/ui/inc/AccessibleSpreadsheet.hxx
new file mode 100644
index 000000000000..307d9b282db3
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleSpreadsheet.hxx
@@ -0,0 +1,292 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLESPREADSHEET_HXX
+#define _SC_ACCESSIBLESPREADSHEET_HXX
+
+#include "AccessibleTableBase.hxx"
+#include "viewdata.hxx"
+
+#include <vector>
+
+class ScMyAddress : public ScAddress
+{
+public:
+ ScMyAddress() : ScAddress() {}
+ ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
+ ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
+
+ sal_Bool operator< ( const ScMyAddress& rAddress ) const
+ {
+ if( Row() != rAddress.Row() )
+ return (Row() < rAddress.Row());
+ else
+ return (Col() < rAddress.Col());
+ }
+};
+
+class ScTabViewShell;
+class ScAccessibleDocument;
+class ScAccessibleCell;
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleTable</code> service.
+*/
+class ScAccessibleSpreadsheet
+ : public ScAccessibleTableBase
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleSpreadsheet(
+ ScAccessibleDocument* pAccDoc,
+ ScTabViewShell* pViewShell,
+ SCTAB nTab,
+ ScSplitPos eSplitPos);
+protected:
+ ScAccessibleSpreadsheet(
+ ScAccessibleSpreadsheet& rParent,
+ const ScRange& rRange );
+
+ virtual ~ScAccessibleSpreadsheet();
+
+ void ConstructScAccessibleSpreadsheet(
+ ScAccessibleDocument* pAccDoc,
+ ScTabViewShell* pViewShell,
+ SCTAB nTab,
+ ScSplitPos eSplitPos);
+
+ using ScAccessibleTableBase::IsDefunc;
+
+public:
+ using ScAccessibleTableBase::addEventListener;
+ using ScAccessibleTableBase::disposing;
+
+ virtual void SAL_CALL disposing();
+
+ void CompleteSelectionChanged(sal_Bool bNewState);
+
+ virtual void LostFocus();
+
+ virtual void GotFocus();
+
+ void BoundingBoxChanged();
+
+ void VisAreaChanged();
+
+ ///===== SfxListener =====================================================
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ///===== XAccessibleTable ================================================
+
+ /// Returns the row headers as an AccessibleTable.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
+ getAccessibleRowHeaders( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the column headers as an AccessibleTable.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
+ getAccessibleColumnHeaders( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the selected rows in a table.
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
+ getSelectedAccessibleRows( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the selected columns in a table.
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
+ getSelectedAccessibleColumns( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns a boolean value indicating whether the specified row is selected.
+ virtual sal_Bool SAL_CALL
+ isAccessibleRowSelected( sal_Int32 nRow )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns a boolean value indicating whether the specified column is selected.
+ virtual sal_Bool SAL_CALL
+ isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the Accessible at a specified row and column in the table.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ ScAccessibleCell* GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
+
+ /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
+ virtual sal_Bool SAL_CALL
+ isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ ///===== XAccessibleComponent ============================================
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ SAL_CALL getAccessibleAtPoint(
+ const ::com::sun::star::awt::Point& rPoint )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL grabFocus( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getForeground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL getBackground( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleContext ==============================================
+
+ /// Return NULL to indicate that an empty relation set.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
+ getAccessibleRelationSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the set of current states.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleSelection ===========================================
+
+ virtual void SAL_CALL
+ selectAccessibleChild( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ clearAccessibleSelection( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ selectAllAccessibleChildren( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL
+ getSelectedAccessibleChildCount( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ deselectAccessibleChild( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ====================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a list of all supported services.
+ */
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
+ getSupportedServiceNames(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleEventBroadcaster =====================================
+
+ /** Add listener that is informed of future changes of name,
+ description and so on events.
+ */
+ virtual void SAL_CALL
+ addEventListener(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
+ throw (com::sun::star::uno::RuntimeException);
+
+protected:
+ /// Return the object's current bounding box relative to the desktop.
+ virtual Rectangle GetBoundingBoxOnScreen(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current bounding box relative to the parent object.
+ virtual Rectangle GetBoundingBox(void) const
+ throw (::com::sun::star::uno::RuntimeException);
+private:
+ ScTabViewShell* mpViewShell;
+ ScRangeList* mpMarkedRanges;
+ std::vector<ScMyAddress>* mpSortedMarkedCells;
+ ScAccessibleDocument* mpAccDoc;
+ ScAccessibleCell* mpAccCell;
+ Rectangle maVisCells;
+ ScSplitPos meSplitPos;
+ ScAddress maActiveCell;
+ SCTAB mnTab;
+ sal_Bool mbIsSpreadsheet;
+ sal_Bool mbHasSelection;
+ sal_Bool mbDelIns;
+ sal_Bool mbIsFocusSend;
+
+ sal_Bool IsDefunc(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ sal_Bool IsEditable(
+ const com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
+ sal_Bool IsFocused();
+ sal_Bool IsCompleteSheetSelected();
+
+ void SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect);
+ void CreateSortedMarkedCells();
+ void AddMarkedRange(const ScRange& rRange);
+
+ ScDocument* GetDocument(ScTabViewShell* pViewShell);
+ Rectangle GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
+ Rectangle GetVisCells(const Rectangle& rVisArea);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleTableBase.hxx b/sc/source/ui/inc/AccessibleTableBase.hxx
new file mode 100644
index 000000000000..4728443783ec
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleTableBase.hxx
@@ -0,0 +1,301 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _SC_ACCESSIBLETABLEBASE_HXX
+#define _SC_ACCESSIBLETABLEBASE_HXX
+
+#include "AccessibleContextBase.hxx"
+#include "global.hxx"
+#include "address.hxx"
+#include <com/sun/star/accessibility/XAccessibleTable.hpp>
+#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+class ScTabViewShell;
+
+/** @descr
+ This base class provides an implementation of the
+ <code>AccessibleTable</code> service.
+*/
+
+typedef cppu::ImplHelper2< ::com::sun::star::accessibility::XAccessibleTable,
+ ::com::sun::star::accessibility::XAccessibleSelection>
+ ScAccessibleTableBaseImpl;
+
+class ScAccessibleTableBase :
+ public ScAccessibleContextBase,
+ public ScAccessibleTableBaseImpl
+{
+public:
+ //===== internal ========================================================
+ ScAccessibleTableBase(
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>& rxParent,
+ ScDocument* pDoc,
+ const ScRange& rRange);
+protected:
+ virtual ~ScAccessibleTableBase();
+public:
+
+ using ScAccessibleContextBase::disposing;
+ virtual void SAL_CALL disposing();
+
+ ///===== XInterface =====================================================
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ ::com::sun::star::uno::Type const & rType )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL acquire() throw ();
+
+ virtual void SAL_CALL release() throw ();
+
+ ///===== XAccessibleTable ================================================
+
+ /// Returns the number of rows in the table.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleRowCount( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the number of columns in the table.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleColumnCount( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the description of the specified row in the table.
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleRowDescription( sal_Int32 nRow )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the description text of the specified column in the table.
+ virtual ::rtl::OUString SAL_CALL
+ getAccessibleColumnDescription( sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /** Returns the number of rows occupied by the Accessible at a specified row and column in the table.
+ Returns 1 if it is only a cell and the number of rows the cell is merged if the cell is a merged cell.
+ */
+ virtual sal_Int32 SAL_CALL
+ getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /** Returns the number of columns occupied by the Accessible at a specified row and column in the table.
+ Returns 1 if it is only a cell and the number of columns the cell is merged if the cell is a merged cell.
+ */
+ virtual sal_Int32 SAL_CALL
+ getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the row headers as an AccessibleTable.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
+ getAccessibleRowHeaders( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the column headers as an AccessibleTable.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
+ getAccessibleColumnHeaders( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the selected rows in a table.
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
+ getSelectedAccessibleRows( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the selected columns in a table.
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
+ getSelectedAccessibleColumns( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns a boolean value indicating whether the specified row is selected.
+ virtual sal_Bool SAL_CALL
+ isAccessibleRowSelected( sal_Int32 nRow )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns a boolean value indicating whether the specified column is selected.
+ virtual sal_Bool SAL_CALL
+ isAccessibleColumnSelected( sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the Accessible at a specified row and column in the table.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the caption for the table.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleCaption( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns the summary description of the table.
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getAccessibleSummary( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
+ virtual sal_Bool SAL_CALL
+ isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ ///===== XAccessibleExtendedTable ========================================
+
+ /// Returns the index of the cell on the given position.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the row number of an index in the table.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleRow( sal_Int32 nChildIndex )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ /// Returns the column number of an index in the table.
+ virtual sal_Int32 SAL_CALL
+ getAccessibleColumn( sal_Int32 nChildIndex )
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+ //===== XAccessibleContext ==============================================
+
+ /// Return the number of currently visible children.
+ // is overloaded to calculate this on demand
+ virtual sal_Int32 SAL_CALL
+ getAccessibleChildCount(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the specified child or NULL if index is invalid.
+ // is overloaded to calculate this on demand
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL
+ getAccessibleChild(sal_Int32 nIndex)
+ throw (::com::sun::star::uno::RuntimeException,
+ ::com::sun::star::lang::IndexOutOfBoundsException);
+
+protected:
+ /// Return this object's description.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleDescription(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the object's current name.
+ virtual ::rtl::OUString SAL_CALL
+ createAccessibleName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ /// Return NULL to indicate that an empty relation set.
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
+ getAccessibleRelationSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /// Return the set of current states.
+ // perhaps sometimes to be implemented
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
+ getAccessibleStateSet(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XAccessibleSelection ===========================================
+
+ virtual void SAL_CALL
+ selectAccessibleChild( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL
+ isAccessibleChildSelected( sal_Int32 nChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ clearAccessibleSelection( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ selectAllAccessibleChildren( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL
+ getSelectedAccessibleChildCount( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > SAL_CALL
+ getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL
+ deselectAccessibleChild( sal_Int32 nSelectedChildIndex )
+ throw (::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::uno::RuntimeException);
+
+ ///===== XServiceInfo ===================================================
+
+ /** Returns an identifier for the implementation of this object.
+ */
+ virtual ::rtl::OUString SAL_CALL
+ getImplementationName(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ ///===== XTypeProvider ===================================================
+
+ /// returns the possible types
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL
+ getTypes()
+ throw (::com::sun::star::uno::RuntimeException);
+
+ /** Returns a implementation id.
+ */
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
+ getImplementationId(void)
+ throw (::com::sun::star::uno::RuntimeException);
+
+protected:
+ /// contains the range of the table, because it could be a subrange of the complete table
+ ScRange maRange;
+
+ ScDocument* mpDoc;
+
+ void CommitTableModelChange(sal_Int32 nStartRow, sal_Int32 nStartCol, sal_Int32 nEndRow, sal_Int32 nEndCol, sal_uInt16 nId);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/AccessibleText.hxx b/sc/source/ui/inc/AccessibleText.hxx
new file mode 100644
index 000000000000..9c0f327c89e3
--- /dev/null
+++ b/sc/source/ui/inc/AccessibleText.hxx
@@ -0,0 +1,360 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SC_ACCESSIBLETEXT_HXX
+#define _SC_ACCESSIBLETEXT_HXX
+
+#include "textuno.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+#include <editeng/svxenum.hxx>
+
+#include <memory>
+
+class ScDocShell;
+class ScViewForwarder;
+class ScEditObjectViewForwarder;
+class ScPreviewViewForwarder;
+class ScEditViewForwarder;
+class ScPreviewShell;
+class EditTextObject;
+class ScCsvViewForwarder;
+class ScAccessibleCell;
+
+
+// ============================================================================
+
+class ScAccessibleTextData : public SfxListener
+{
+public:
+ ScAccessibleTextData() {}
+ virtual ~ScAccessibleTextData() {}
+
+ virtual ScAccessibleTextData* Clone() const = 0;
+
+ virtual void Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ ) {}
+
+ virtual SvxTextForwarder* GetTextForwarder() = 0;
+ virtual SvxViewForwarder* GetViewForwarder() = 0;
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate ) = 0;
+ virtual SfxBroadcaster& GetBroadcaster() const { return maBroadcaster; }
+
+ virtual void UpdateData() = 0;
+ virtual void SetDoUpdate(sal_Bool bValue) = 0;
+ virtual sal_Bool IsDirty() const = 0;
+
+private:
+ mutable SfxBroadcaster maBroadcaster;
+
+ // prevent the using of this method of the base class
+ ScSharedCellEditSource* GetOriginalSource() { return NULL; }
+};
+
+
+// ============================================================================
+
+class ScAccessibleCellBaseTextData : public ScAccessibleTextData,
+ public ScCellTextData
+{
+public:
+ ScAccessibleCellBaseTextData(ScDocShell* pDocShellP,
+ const ScAddress& rP)
+ : ScCellTextData(pDocShellP, rP) {}
+ virtual ~ScAccessibleCellBaseTextData() {}
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { ScCellTextData::Notify(rBC, rHint); }
+
+ virtual void UpdateData() { ScCellTextData::UpdateData(); }
+ virtual void SetDoUpdate(sal_Bool bValue) { ScCellTextData::SetDoUpdate(bValue); }
+ virtual sal_Bool IsDirty() const { return ScCellTextData::IsDirty(); }
+};
+
+
+// ============================================================================
+
+// ScAccessibleCellTextData: shared data between sub objects of a accessible cell text object
+
+class ScAccessibleCellTextData : public ScAccessibleCellBaseTextData
+{
+public:
+ ScAccessibleCellTextData(ScTabViewShell* pViewShell,
+ const ScAddress& rP, ScSplitPos eSplitPos, ScAccessibleCell* pAccCell);
+ virtual ~ScAccessibleCellTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
+
+ DECL_LINK( NotifyHdl, EENotify* );
+protected:
+ virtual void GetCellText(const ScAddress& rCellPos, String& rText);
+private:
+ ScViewForwarder* mpViewForwarder;
+ ScEditViewForwarder* mpEditViewForwarder;
+ ScTabViewShell* mpViewShell;
+ ScSplitPos meSplitPos;
+ sal_Bool mbViewEditEngine;
+ ScAccessibleCell* mpAccessibleCell;
+
+ // prevent the using of this method of the base class
+ ScSharedCellEditSource* GetOriginalSource() { return NULL; }
+
+ using ScAccessibleCellBaseTextData::GetDocShell;
+ ScDocShell* GetDocShell(ScTabViewShell* pViewShell);
+};
+
+
+// ============================================================================
+
+class ScAccessibleEditObjectTextData : public ScAccessibleTextData
+{
+public:
+ ScAccessibleEditObjectTextData(EditView* pEditView, Window* pWin);
+ virtual ~ScAccessibleEditObjectTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
+
+ virtual void UpdateData() { }
+ virtual void SetDoUpdate(sal_Bool /* bValue */) { }
+ virtual sal_Bool IsDirty() const { return sal_False; }
+
+ DECL_LINK( NotifyHdl, EENotify* );
+protected:
+ ScEditObjectViewForwarder* mpViewForwarder;
+ ScEditViewForwarder* mpEditViewForwarder;
+ EditView* mpEditView;
+ EditEngine* mpEditEngine;
+ SvxEditEngineForwarder* mpForwarder;
+ Window* mpWindow;
+};
+
+
+// ============================================================================
+
+class ScAccessibleEditLineTextData : public ScAccessibleEditObjectTextData
+{
+public:
+ ScAccessibleEditLineTextData(EditView* pEditView, Window* pWin);
+ virtual ~ScAccessibleEditLineTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
+
+ void Dispose();
+ void TextChanged();
+ void StartEdit();
+ void EndEdit();
+private:
+ void ResetEditMode();
+
+ sal_Bool mbEditEngineCreated;
+};
+
+
+// ============================================================================
+
+class ScAccessiblePreviewCellTextData : public ScAccessibleCellBaseTextData
+{
+public:
+ ScAccessiblePreviewCellTextData(ScPreviewShell* pViewShell,
+ const ScAddress& rP);
+ virtual ~ScAccessiblePreviewCellTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
+
+private:
+ ScPreviewViewForwarder* mpViewForwarder;
+ ScPreviewShell* mpViewShell;
+
+ // prevent the using of this method of the base class
+ ScSharedCellEditSource* GetOriginalSource() { return NULL; }
+
+ using ScAccessibleCellBaseTextData::GetDocShell;
+ ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
+};
+
+
+// ============================================================================
+
+class ScAccessiblePreviewHeaderCellTextData : public ScAccessibleCellBaseTextData
+{
+public:
+ ScAccessiblePreviewHeaderCellTextData(ScPreviewShell* pViewShell,
+ const String& rText, const ScAddress& rP, sal_Bool bColHeader, sal_Bool bRowHeader);
+ virtual ~ScAccessiblePreviewHeaderCellTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
+
+private:
+ ScPreviewViewForwarder* mpViewForwarder;
+ ScPreviewShell* mpViewShell;
+ String maText;
+ sal_Bool mbColHeader;
+ sal_Bool mbRowHeader;
+
+ // prevent the using of this method of the base class
+ ScSharedCellEditSource* GetOriginalSource() { return NULL; }
+
+ using ScAccessibleCellBaseTextData::GetDocShell;
+ ScDocShell* GetDocShell(ScPreviewShell* pViewShell);
+};
+
+
+// ============================================================================
+
+class ScAccessibleHeaderTextData : public ScAccessibleTextData
+{
+public:
+ ScAccessibleHeaderTextData(ScPreviewShell* pViewShell,
+ const EditTextObject* pEditObj, sal_Bool bHeader, SvxAdjust eAdjust);
+ virtual ~ScAccessibleHeaderTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
+
+ virtual void UpdateData() { }
+ virtual void SetDoUpdate(sal_Bool /* bValue */) { }
+ virtual sal_Bool IsDirty() const { return sal_False; }
+private:
+ ScPreviewViewForwarder* mpViewForwarder;
+ ScPreviewShell* mpViewShell;
+ ScEditEngineDefaulter* mpEditEngine;
+ SvxEditEngineForwarder* mpForwarder;
+ ScDocShell* mpDocSh;
+ const EditTextObject* mpEditObj;
+ sal_Bool mbHeader;
+ sal_Bool mbDataValid;
+ SvxAdjust meAdjust;
+};
+
+
+// ============================================================================
+
+class ScAccessibleNoteTextData : public ScAccessibleTextData
+{
+public:
+ ScAccessibleNoteTextData(ScPreviewShell* pViewShell,
+ const String& sText, const ScAddress& aCellPos, sal_Bool bMarkNote);
+ virtual ~ScAccessibleNoteTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool /* bCreate */ ) { return NULL; }
+
+ virtual void UpdateData() { }
+ virtual void SetDoUpdate(sal_Bool /* bValue */) { }
+ virtual sal_Bool IsDirty() const { return sal_False; }
+private:
+ ScPreviewViewForwarder* mpViewForwarder;
+ ScPreviewShell* mpViewShell;
+ ScEditEngineDefaulter* mpEditEngine;
+ SvxEditEngineForwarder* mpForwarder;
+ ScDocShell* mpDocSh;
+ String msText;
+ ScAddress maCellPos;
+ sal_Bool mbMarkNote;
+ sal_Bool mbDataValid;
+};
+
+
+// ============================================================================
+
+class ScAccessibleCsvTextData : public ScAccessibleTextData
+{
+private:
+ typedef ::std::auto_ptr< SvxTextForwarder > TextForwarderPtr;
+ typedef ::std::auto_ptr< ScCsvViewForwarder > ViewForwarderPtr;
+
+ Window* mpWindow;
+ EditEngine* mpEditEngine;
+ TextForwarderPtr mpTextForwarder;
+ ViewForwarderPtr mpViewForwarder;
+ String maCellText;
+ Rectangle maBoundBox;
+ Size maCellSize;
+
+public:
+ explicit ScAccessibleCsvTextData(
+ Window* pWindow,
+ EditEngine* pEditEngine,
+ const String& rCellText,
+ const Rectangle& rBoundBox,
+ const Size& rCellSize );
+ virtual ~ScAccessibleCsvTextData();
+
+ virtual ScAccessibleTextData* Clone() const;
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SvxTextForwarder* GetTextForwarder();
+ virtual SvxViewForwarder* GetViewForwarder();
+ virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate );
+
+ virtual void UpdateData() {}
+ virtual void SetDoUpdate( sal_Bool /* bValue */ ) {}
+ virtual sal_Bool IsDirty() const { return sal_False; }
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/ChartRangeSelectionListener.hxx b/sc/source/ui/inc/ChartRangeSelectionListener.hxx
new file mode 100644
index 000000000000..807cba46a98e
--- /dev/null
+++ b/sc/source/ui/inc/ChartRangeSelectionListener.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_CHARTRANGESELECTIONLISTENER_HXX
+#define SC_CHARTRANGESELECTIONLISTENER_HXX
+
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <com/sun/star/view/XSelectionChangeListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+class ScTabViewShell;
+
+typedef ::cppu::WeakComponentImplHelper2<
+ ::com::sun::star::view::XSelectionChangeListener,
+ ::com::sun::star::lang::XServiceInfo >
+ ScChartRangeSelectionListener_Base;
+
+class ScChartRangeSelectionListener :
+ public comphelper::OBaseMutex,
+ public ScChartRangeSelectionListener_Base
+{
+public:
+ explicit ScChartRangeSelectionListener( ScTabViewShell * pViewShell );
+ virtual ~ScChartRangeSelectionListener();
+
+protected:
+ // ____ XSelectionChangeListener ____
+ virtual void SAL_CALL selectionChanged(
+ const ::com::sun::star::lang::EventObject& aEvent )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ XEventListener (base of XSelectionChangeListener) ____
+ virtual void SAL_CALL disposing(
+ const ::com::sun::star::lang::EventObject& Source )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // ____ WeakComponentImplHelperBase ____
+ // is called when dispose() is called at this component
+ virtual void SAL_CALL disposing();
+
+ // ____ XServiceInfo ____
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(
+ const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ ScTabViewShell * m_pViewShell;
+};
+
+// SC_CHARTRANGESELECTIONLISTENER_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/DrawModelBroadcaster.hxx b/sc/source/ui/inc/DrawModelBroadcaster.hxx
new file mode 100644
index 000000000000..22e6ca85ce46
--- /dev/null
+++ b/sc/source/ui/inc/DrawModelBroadcaster.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SC_DRAWMODELBROADCASTER_HXX
+#define _SC_DRAWMODELBROADCASTER_HXX
+
+
+#include <svl/lstner.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+
+class SdrModel;
+
+class ScDrawModelBroadcaster : public SfxListener,
+ public ::cppu::WeakImplHelper1< com::sun::star::document::XEventBroadcaster >
+{
+ mutable ::osl::Mutex maListenerMutex;
+ ::cppu::OInterfaceContainerHelper maEventListeners;
+ SdrModel *mpDrawModel;
+
+public:
+
+ ScDrawModelBroadcaster( SdrModel *pDrawModel );
+ virtual ~ScDrawModelBroadcaster();
+
+ virtual void SAL_CALL addEventListener( const com::sun::star::uno::Reference< com::sun::star::document::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< com::sun::star::document::XEventListener >& xListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/IAnyRefDialog.hxx b/sc/source/ui/inc/IAnyRefDialog.hxx
new file mode 100644
index 000000000000..7a40593d8e51
--- /dev/null
+++ b/sc/source/ui/inc/IAnyRefDialog.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_IANYREFDIALOG_HXX_INCLUDED
+#define SC_IANYREFDIALOG_HXX_INCLUDED
+
+#include <formula/IControlReferenceHandler.hxx>
+
+class ScRange;
+class ScDocument;
+class ScTabViewShell;
+class SfxObjectShell;
+namespace formula
+{
+ class RefEdit;
+ class RefButton;
+}
+class SAL_NO_VTABLE IAnyRefDialog : public formula::IControlReferenceHandler
+{
+public:
+ virtual ~IAnyRefDialog(){}
+
+ //virtual void ShowReference(const String& _sRef) = 0;
+ //virtual void HideReference( BOOL bDoneRefMode = TRUE ) = 0;
+ //virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) = 0;
+ //virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) = 0;
+
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
+ virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL ) = 0;
+ virtual void RefInputDone( BOOL bForced = FALSE ) = 0;
+ virtual BOOL IsTableLocked() const = 0;
+ virtual BOOL IsRefInputMode() const = 0;
+
+ virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const = 0;
+ virtual void AddRefEntry() = 0;
+ virtual void SetActive() = 0;
+ virtual void ViewShellChanged( ScTabViewShell* pScViewShell ) = 0;
+};
+
+#endif // SC_IANYREFDIALOG_HXX_INCLUDED
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/ScDevChart.hxx b/sc/source/ui/inc/ScDevChart.hxx
new file mode 100644
index 000000000000..cb2c7c42c127
--- /dev/null
+++ b/sc/source/ui/inc/ScDevChart.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INCLUDED_DEVCHARTCONFIG_HXX
+#define INCLUDED_DEVCHARTCONFIG_HXX
+
+#include <unotools/configitem.hxx>
+
+namespace ScDevChart
+{
+
+class DevChartConfigItem : public ::utl::ConfigItem
+{
+public:
+ DevChartConfigItem() :
+ ConfigItem( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Office.Common/Internal" )),
+ CONFIG_MODE_IMMEDIATE_UPDATE )
+ {}
+
+ bool UseDevelopmentChart();
+};
+
+bool DevChartConfigItem::UseDevelopmentChart()
+{
+ bool bResult = false;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( 1 );
+ aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DevelopmentChart" ));
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > aResult( GetProperties( aNames ));
+
+ OSL_ASSERT( aResult.getLength());
+ aResult[0] >>= bResult;
+
+ return bResult;
+}
+
+/** States whether the new chart implementation or the old one should be used.
+ If <TRUE/> is returned the newly developed chart (chart2) should be used.
+ If <FALSE/> is returned, the old chart (sch) should be used.
+
+ Config-Item: Office.Common/Internal:DevelopmentChart
+
+ This function (the complete header) is only for a transitional period. It
+ will be deprecated after the new chart is definitely integrated into the
+ product.
+ */
+bool UseDevChart()
+{
+// static DevChartConfigItem aCfgItem;
+// return aCfgItem.UseDevelopmentChart();
+
+ // ignore configuration
+ //@todo: get rid of this class
+ return true;
+}
+
+} // namespace ScDevChart
+
+// INCLUDED_DEVCHARTCONFIG_HXX
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/acredlin.hrc b/sc/source/ui/inc/acredlin.hrc
new file mode 100644
index 000000000000..468c57333780
--- /dev/null
+++ b/sc/source/ui/inc/acredlin.hrc
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_CHANGES
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 5
+//
+#define CTR_REDLINING 10
+#define TP_FILTER 11
+#define TP_VIEW 12
+
+
+#define FT_ASSIGN 14
+#define ED_ASSIGN 15
+#define RB_ASSIGN 16
+
+
+#define STR_INSERT_COLS 20
+#define STR_INSERT_ROWS 21
+#define STR_INSERT_TABS 22
+#define STR_DELETE_COLS 23
+#define STR_DELETE_ROWS 24
+#define STR_DELETE_TABS 25
+#define STR_MOVE 26
+#define STR_CONTENT 27
+#define STR_REJECT 28
+#define STR_ACCEPTED 29
+#define STR_REJECTED 30
+#define STR_NO_ENTRY 31
+#define STR_CONTENT_WITH_CHILD 32
+#define STR_CHILD_CONTENT 33
+#define STR_CHILD_ORGCONTENT 34
+#define STR_EMPTY 35
+// Bitmaps
+#define BMP_STR_CLOSE 41
+#define BMP_STR_OPEN 42
+#define BMP_STR_END 43
+#define BMP_STR_ERROR 44
+
+#define SC_CHANGES_COMMENT 49
+#define SC_SUB_SORT 50
+#define SC_SORT_ACTION 51
+#define SC_SORT_POSITION 52
+#define SC_SORT_AUTHOR 53
+#define SC_SORT_DATE 54
+#define SC_SORT_COMMENT 55
+
+//
+
diff --git a/sc/source/ui/inc/acredlin.hxx b/sc/source/ui/inc/acredlin.hxx
new file mode 100644
index 000000000000..94e557453fd3
--- /dev/null
+++ b/sc/source/ui/inc/acredlin.hxx
@@ -0,0 +1,257 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_ACREDLIN_HXX
+#define SC_ACREDLIN_HXX
+
+#include <vcl/morebtn.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/headbar.hxx>
+#include <svtools/svtabbx.hxx>
+
+
+#include "rangenam.hxx"
+#include "anyrefdg.hxx"
+#include <vcl/lstbox.hxx>
+
+#include <svx/ctredlin.hxx>
+#include <svx/simptabl.hxx>
+
+#ifndef _SVARRAY_HXX
+#define _SVARRAY_HXX
+#include <svl/svarray.hxx>
+#endif
+#include "chgtrack.hxx"
+#include "chgviset.hxx"
+#include <vcl/timer.hxx>
+
+class ScViewData;
+class ScDocument;
+
+#define FLT_DATE_BEFORE 0
+#define FLT_DATE_SINCE 1
+#define FLT_DATE_EQUAL 2
+#define FLT_DATE_NOTEQUAL 3
+#define FLT_DATE_BETWEEN 4
+#define FLT_DATE_SAVE 5
+
+
+class ScViewEntryPtr
+{
+private:
+ String* pAction;
+ String* pPos;
+ String* pAuthor;
+ String* pDate;
+ String* pComment;
+ void* pData;
+
+public:
+
+ String* GetpAction() {return pAction; }
+ String* GetpPos() {return pPos; }
+ String* GetpAuthor() {return pAuthor; }
+ String* GetpDate() {return pDate; }
+ String* GetpComment() {return pComment;}
+ void* GetpData() {return pData; }
+
+ void SetpAction (String* pString) {pAction= pString;}
+ void SetpPos (String* pString) {pPos = pString;}
+ void SetpAuthor (String* pString) {pAuthor= pString;}
+ void SetpDate (String* pString) {pDate = pString;}
+ void SetpComment(String* pString) {pComment=pString;}
+ void SetpData (void* pdata) {pData =pdata;}
+};
+
+class ScViewEntryPtrList
+{
+ ScViewEntryPtrList* pNext;
+ ScViewEntryPtrList* pLast;
+
+ ScViewEntryPtr* pData;
+};
+
+
+class ScRedlinData : public RedlinData
+{
+public:
+
+ ScRedlinData();
+ ~ScRedlinData();
+ SCTAB nTable;
+ SCCOL nCol;
+ SCROW nRow;
+ ULONG nActionNo;
+ ULONG nInfo;
+ BOOL bIsRejectable;
+ BOOL bIsAcceptable;
+};
+
+typedef long LExpNum;
+
+//@ Expand-Entrys nicht eindeutig, daher gestrichen
+//DECLARE_TABLE( ScChgTrackExps, LExpNum)
+//==================================================================
+
+class ScAcceptChgDlg : public SfxModelessDialog
+{
+private:
+
+ Timer aSelectionTimer;
+ Timer aReOpenTimer;
+ SvxAcceptChgCtr aAcceptChgCtr;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ ScRangeName aLocalRangeName;
+ Selection theCurSel;
+ SvxTPFilter* pTPFilter;
+ SvxTPView* pTPView;
+ SvxRedlinTable* pTheView; // PB 2006/02/02 #i48648 now SvHeaderTabListBox
+ Size MinSize;
+ ScRangeList aRangeList;
+ ScChangeViewSettings aChangeViewSet;
+ String aStrInsertCols;
+ String aStrInsertRows;
+ String aStrInsertTabs;
+ String aStrDeleteCols;
+ String aStrDeleteRows;
+ String aStrDeleteTabs;
+ String aStrMove;
+ String aStrContent;
+ String aStrReject;
+ String aUnknown;
+ String aStrAllAccepted;
+ String aStrAllRejected;
+ String aStrNoEntry;
+ String aStrContentWithChild;
+ String aStrChildContent;
+ String aStrChildOrgContent;
+ String aStrEmpty;
+ ULONG nAcceptCount;
+ ULONG nRejectCount;
+ BOOL bAcceptEnableFlag;
+ BOOL bRejectEnableFlag;
+ BOOL bNeedsUpdate;
+ BOOL bIgnoreMsg;
+ BOOL bNoSelection;
+ BOOL bHasFilterEntry;
+ BOOL bUseColor;
+ //ScChgTrackExps aExpandArray;
+
+ void Init();
+ void InitFilter();
+
+ DECL_LINK( FilterHandle, SvxTPFilter* );
+ DECL_LINK( RefHandle, SvxTPFilter* );
+ DECL_LINK( FilterModified, SvxTPFilter* );
+ DECL_LINK( MinSizeHandle, SvxAcceptChgCtr*);
+ DECL_LINK( RejectHandle, SvxTPView*);
+ DECL_LINK( AcceptHandle, SvxTPView*);
+ DECL_LINK( RejectAllHandle, SvxTPView*);
+ DECL_LINK( AcceptAllHandle, SvxTPView*);
+ DECL_LINK( ExpandingHandle, SvxRedlinTable*);
+ DECL_LINK( SelectHandle, SvxRedlinTable*);
+ DECL_LINK( RefInfoHandle, String*);
+
+ DECL_LINK( UpdateSelectionHdl, Timer*);
+ DECL_LINK( ChgTrackModHdl, ScChangeTrack*);
+ DECL_LINK( CommandHdl, Control*);
+ DECL_LINK( ReOpenTimerHdl, Timer*);
+ DECL_LINK( ColCompareHdl, SvSortData*);
+
+
+
+protected:
+
+ virtual void Resize();
+ virtual BOOL Close();
+
+ void RejectFiltered();
+ void AcceptFiltered();
+
+ BOOL IsValidAction(const ScChangeAction* pScChangeAction);
+
+ String* MakeTypeString(ScChangeActionType eType);
+
+ SvLBoxEntry* InsertChangeAction(const ScChangeAction* pScChangeAction,ScChangeActionState eState,
+ SvLBoxEntry* pParent=NULL,BOOL bDelMaster=FALSE,
+ BOOL bDisabled=FALSE,ULONG nPos=LIST_APPEND);
+
+ SvLBoxEntry* InsertFilteredAction(const ScChangeAction* pScChangeAction,ScChangeActionState eState,
+ SvLBoxEntry* pParent=NULL,BOOL bDelMaster=FALSE,
+ BOOL bDisabled=FALSE,ULONG nPos=LIST_APPEND);
+
+
+ SvLBoxEntry* InsertChangeActionContent(const ScChangeActionContent* pScChangeAction,
+ SvLBoxEntry* pParent,ULONG nSpecial);
+
+ void GetDependents( const ScChangeAction* pScChangeAction,
+ ScChangeActionTable& aActionTable,
+ SvLBoxEntry* pEntry);
+
+ BOOL InsertContentChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent);
+
+ BOOL InsertAcceptedORejected(SvLBoxEntry* pParent);
+
+ BOOL InsertDeletedChilds(const ScChangeAction *pChangeAction, ScChangeActionTable* pActionTable,
+ SvLBoxEntry* pParent);
+
+ BOOL InsertChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent);
+
+ void AppendChanges(ScChangeTrack* pChanges,ULONG nStartAction, ULONG nEndAction,
+ ULONG nPos=LIST_APPEND);
+
+ void RemoveEntrys(ULONG nStartAction,ULONG nEndAction);
+ void UpdateEntrys(ScChangeTrack* pChgTrack, ULONG nStartAction,ULONG nEndAction);
+
+ void UpdateView();
+ void ClearView();
+
+ BOOL Expand(ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction,
+ SvLBoxEntry* pEntry, BOOL bFilter=FALSE);
+
+public:
+ ScAcceptChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData);
+
+ ~ScAcceptChgDlg();
+
+ void ReInit(ScViewData* ptrViewData);
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ void Initialize (SfxChildWinInfo* pInfo);
+ virtual void FillInfo(SfxChildWinInfo&) const;
+
+};
+
+
+#endif // SC_NAMEDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/anyrefdg.hxx b/sc/source/ui/inc/anyrefdg.hxx
new file mode 100644
index 000000000000..9695abbe6b37
--- /dev/null
+++ b/sc/source/ui/inc/anyrefdg.hxx
@@ -0,0 +1,277 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_ANYREFDG_HXX
+#define SC_ANYREFDG_HXX
+
+#include <vcl/imagebtn.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/accel.hxx>
+#include <sfx2/basedlgs.hxx>
+#include "address.hxx"
+#include "cell.hxx"
+#include "compiler.hxx"
+#include "formula/funcutl.hxx"
+#include "IAnyRefDialog.hxx"
+#include "scresid.hxx"
+#include <memory>
+
+class SfxObjectShell;
+class ScRange;
+class ScDocument;
+class ScTabViewShell;
+//The class of ScAnyRefDlg is rewritten by PengYunQuan for Validity Cell Range Picker
+//class ScAnyRefDlg;
+class ScRefHandler;
+class ScRangeList;
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+class SfxShell;
+#include "scmod.hxx"
+
+typedef formula::RefButton ScRefButton;
+typedef formula::RefEdit ScRefEdit;
+//-->Added by PengYunQuan for Validity Cell Range Picker
+class ScFormulaReferenceHelper
+{
+ IAnyRefDialog* m_pDlg;
+ ::std::auto_ptr<ScFormulaCell> pRefCell;
+ ::std::auto_ptr<ScCompiler> pRefComp;
+ formula::RefEdit* pRefEdit; // aktives Eingabefeld
+ formula::RefButton* pRefBtn; // Button dazu
+ Window* m_pWindow;
+ SfxBindings* m_pBindings;
+ ::std::auto_ptr<Accelerator>
+ pAccel; // fuer Enter/Escape
+ BOOL* pHiddenMarks; // Merkfeld fuer versteckte Controls
+ SCTAB nRefTab; // used for ShowReference
+
+ String sOldDialogText; // Originaltitel des Dialogfensters
+ Size aOldDialogSize; // Originalgroesse Dialogfenster
+ Point aOldEditPos; // Originalposition des Eingabefeldes
+ Size aOldEditSize; // Originalgroesse des Eingabefeldes
+ Point aOldButtonPos; // Originalpositiuon des Buttons
+
+ BOOL bEnableColorRef;
+ BOOL bHighLightRef;
+ BOOL bAccInserted;
+
+ DECL_LINK( AccelSelectHdl, Accelerator* );
+
+public:
+ ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings);
+ ~ScFormulaReferenceHelper();
+
+ void ShowSimpleReference( const XubString& rStr );
+ void ShowFormulaReference( const XubString& rStr );
+ bool ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
+ void Init();
+
+ void ShowReference( const XubString& rStr );
+ void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ void HideReference( BOOL bDoneRefMode = TRUE );
+ void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ void RefInputDone( BOOL bForced = FALSE );
+ void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+
+ inline void SetWindow(Window* _pWindow) { m_pWindow = _pWindow; }
+ BOOL DoClose( USHORT nId );
+ void SetDispatcherLock( BOOL bLock );
+ void EnableSpreadsheets( BOOL bFlag = TRUE, BOOL bChilds = TRUE );
+ void ViewShellChanged( ScTabViewShell* pScViewShell );
+
+ static void enableInput(BOOL _bInput);
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+protected:
+ Window * GetWindow(){ return m_pWindow; }
+public:
+ bool CanInputStart( const ScRefEdit *pEdit ){ return !!pEdit; }
+ bool CanInputDone( BOOL bForced ){ return pRefEdit && (bForced || !pRefBtn); }
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+};
+//============================================================================
+
+//The class of ScAnyRefDlg is rewritten by PengYunQuan for Validity Cell Range Picker
+class SC_DLLPUBLIC ScRefHandler : //public SfxModelessDialog,
+ public IAnyRefDialog
+{
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+ Window & m_rWindow;
+ bool m_bInRefMode;
+public:
+ operator Window *(){ return &m_rWindow; }
+ Window * operator ->() { return static_cast<Window *>(*this); }
+ template<class,bool> friend class ScRefHdlrImplBase;
+//-->Added by PengYunQuan for Validity Cell Range Picker
+ friend class formula::RefButton;
+ friend class formula::RefEdit;
+
+private:
+ ScFormulaReferenceHelper
+ m_aHelper;
+ SfxBindings* pMyBindings;
+
+ Window* pActiveWin;
+ Timer aTimer;
+ String aDocName; // document on which the dialog was opened
+
+ DECL_LINK( UpdateFocusHdl, Timer* );
+
+
+protected:
+ virtual BOOL DoClose( USHORT nId );
+
+ void SetDispatcherLock( BOOL bLock );
+
+ //Overwrite TWindow will implemented by ScRefHdlrImplBase
+ //virtual long PreNotify( NotifyEvent& rNEvt );
+
+ virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ virtual void RefInputDone( BOOL bForced = FALSE );
+ void ShowSimpleReference( const XubString& rStr );
+ void ShowFormulaReference( const XubString& rStr );
+
+ bool ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc );
+
+public:
+ ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
+ Window* pParent, USHORT nResId*/, bool bBindRef );
+ virtual ~ScRefHandler();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) = 0;
+ virtual void AddRefEntry();
+
+ virtual BOOL IsRefInputMode() const;
+ virtual BOOL IsTableLocked() const;
+ virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const;
+
+ virtual void ShowReference( const XubString& rStr );
+ virtual void HideReference( BOOL bDoneRefMode = TRUE );
+
+ virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+
+ virtual void ViewShellChanged( ScTabViewShell* pScViewShell );
+ void SwitchToDocument();
+ //SfxBindings& GetBindings();
+
+ virtual void SetActive() = 0;
+// virtual BOOL Close();
+ //Overwrite TWindow will implemented by ScRefHdlrImplBase
+ //virtual void StateChanged( StateChangedType nStateChange );
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+public:
+ bool EnterRefMode();
+ bool LeaveRefMode();
+ inline bool CanInputStart( const ScRefEdit *pEdit );
+ inline bool CanInputDone( BOOL bForced );
+//-->Added by PengYunQuan for Validity Cell Range Picker
+};
+
+
+//============================================================================
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+template< class TWindow, bool bBindRef = true >
+class ScRefHdlrImplBase:public TWindow, public ScRefHandler
+{
+public:
+ //Overwrite TWindow
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void StateChanged( StateChangedType nStateChange );
+
+private:
+ template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
+ ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
+ TParentWindow* pParent, TResId nResId);
+
+ template<class TParentWindow, class TResId, class TArg>
+ ScRefHdlrImplBase( TParentWindow* pParent, TResId nResId, const TArg &rArg, SfxBindings *pB = NULL );
+
+ ~ScRefHdlrImplBase();
+
+ template<class, class, bool> friend struct ScRefHdlrImpl;
+};
+
+template<class TWindow, bool bBindRef>
+template<class TBindings, class TChildWindow, class TParentWindow, class TResId>
+ScRefHdlrImplBase<TWindow, bBindRef>::ScRefHdlrImplBase( TBindings* pB, TChildWindow* pCW,
+ TParentWindow* pParent, TResId nResId):TWindow(pB, pCW, pParent, ScResId(static_cast<USHORT>( nResId ) ) ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
+
+template<class TWindow, bool bBindRef >
+template<class TParentWindow, class TResId, class TArg>
+ScRefHdlrImplBase<TWindow,bBindRef>::ScRefHdlrImplBase( TParentWindow* pParent, TResId nResIdP, const TArg &rArg, SfxBindings *pB /*= NULL*/ )
+:TWindow( pParent, ScResId(static_cast<USHORT>( nResIdP )), rArg ), ScRefHandler( *static_cast<TWindow*>(this), pB, bBindRef ){}
+
+template<class TWindow, bool bBindRef >
+ScRefHdlrImplBase<TWindow,bBindRef>::~ScRefHdlrImplBase(){}
+
+//============================================================================
+template<class TDerived, class TBase, bool bBindRef = true>
+struct ScRefHdlrImpl: ScRefHdlrImplBase<TBase, bBindRef >
+{
+ enum { UNKNOWN_SLOTID = 0U, SLOTID = UNKNOWN_SLOTID };
+
+ template<class T1, class T2, class T3, class T4>
+ ScRefHdlrImpl( const T1 & rt1, const T2 & rt2, const T3 & rt3, const T4 & rt4 ):ScRefHdlrImplBase<TBase, bBindRef >(rt1, rt2, rt3, rt4 )
+ {
+ SC_MOD()->RegisterRefWindow( static_cast<USHORT>( static_cast<TDerived*>(this)->SLOTID ), this );
+ }
+
+ ~ScRefHdlrImpl()
+ {
+ SC_MOD()->UnregisterRefWindow( static_cast<USHORT>( static_cast<TDerived*>(this)->SLOTID ), this );
+ }
+};
+//============================================================================
+struct ScAnyRefDlg : ::ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>
+{
+ template<class T1, class T2, class T3, class T4>
+ ScAnyRefDlg( const T1 & rt1, const T2 & rt2, const T3 & rt3, const T4 & rt4 ):ScRefHdlrImpl< ScAnyRefDlg, SfxModelessDialog>(rt1, rt2, rt3, rt4){}
+};
+//============================================================================
+
+inline bool ScRefHandler::CanInputStart( const ScRefEdit *pEdit )
+{
+ return m_aHelper.CanInputStart( pEdit );
+}
+
+inline bool ScRefHandler::CanInputDone( BOOL bForced )
+{
+ return m_aHelper.CanInputDone( bForced );
+}
+
+template <> SC_DLLPUBLIC void ScRefHdlrImplBase<SfxModelessDialog,true>::StateChanged( StateChangedType nStateChange );
+template <> SC_DLLPUBLIC long ScRefHdlrImplBase<SfxModelessDialog,true>::PreNotify( NotifyEvent& rNEvt );
+#include <sfx2/tabdlg.hxx>
+template <> SC_DLLPUBLIC void ScRefHdlrImplBase<SfxTabDialog,false>::StateChanged( StateChangedType nStateChange );
+template <> SC_DLLPUBLIC long ScRefHdlrImplBase<SfxTabDialog,false>::PreNotify( NotifyEvent& rNEvt );
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#endif // SC_ANYREFDG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/areasave.hxx b/sc/source/ui/inc/areasave.hxx
new file mode 100644
index 000000000000..ae566e01c0a9
--- /dev/null
+++ b/sc/source/ui/inc/areasave.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_AREASAVE_HXX
+#define SC_AREASAVE_HXX
+
+#include "collect.hxx"
+#include "global.hxx"
+#include "address.hxx"
+
+class ScDocument;
+class ScAreaLink;
+
+
+class ScAreaLinkSaver : public ScDataObject
+{
+private:
+ String aFileName;
+ String aFilterName;
+ String aOptions;
+ String aSourceArea;
+ ScRange aDestArea;
+ ULONG nRefresh;
+
+public:
+ ScAreaLinkSaver( const ScAreaLink& rSource );
+ ScAreaLinkSaver( const ScAreaLinkSaver& rCopy );
+ virtual ~ScAreaLinkSaver();
+
+ virtual ScDataObject* Clone() const;
+
+ BOOL IsEqual( const ScAreaLink& rCompare ) const;
+ BOOL IsEqualSource( const ScAreaLink& rCompare ) const;
+
+ void WriteToLink( ScAreaLink& rLink ) const;
+ void InsertNewLink( ScDocument* pDoc ) const;
+};
+
+
+class ScAreaLinkSaveCollection : public ScCollection
+{
+public:
+ ScAreaLinkSaveCollection();
+ ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& rCopy );
+ virtual ~ScAreaLinkSaveCollection();
+
+ virtual ScDataObject* Clone() const;
+
+ ScAreaLinkSaver* operator[](USHORT nIndex) const {return (ScAreaLinkSaver*)At(nIndex);}
+
+ BOOL IsEqual( const ScDocument* pDoc ) const;
+ void Restore( ScDocument* pDoc ) const;
+
+ // returns NULL if empty
+ static ScAreaLinkSaveCollection* CreateFromDoc( const ScDocument* pDoc );
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/areasdlg.hxx b/sc/source/ui/inc/areasdlg.hxx
new file mode 100644
index 000000000000..8f59accfe44f
--- /dev/null
+++ b/sc/source/ui/inc/areasdlg.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_AREASDLG_HXX
+#define SC_AREASDLG_HXX
+
+#include "address.hxx"
+
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+#include <anyrefdg.hxx>
+
+class ScDocument;
+class ScViewData;
+class ScRangeUtil;
+class ScRangeItem;
+
+
+//============================================================================
+
+class ScPrintAreasDlg : public ScAnyRefDlg
+{
+public:
+ ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent );
+ ~ScPrintAreasDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual void AddRefEntry();
+
+ virtual BOOL IsTableLocked() const;
+
+ virtual void SetActive();
+ virtual void Deactivate();
+ virtual BOOL Close();
+
+private:
+ ListBox aLbPrintArea;
+ FixedLine aFlPrintArea;
+ formula::RefEdit aEdPrintArea;
+ formula::RefButton aRbPrintArea;
+
+ ListBox aLbRepeatRow;
+ FixedLine aFlRepeatRow;
+ formula::RefEdit aEdRepeatRow;
+ formula::RefButton aRbRepeatRow;
+
+ ListBox aLbRepeatCol;
+ FixedLine aFlRepeatCol;
+ formula::RefEdit aEdRepeatCol;
+ formula::RefButton aRbRepeatCol;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ BOOL bDlgLostFocus;
+ formula::RefEdit* pRefInputEdit;
+ ScDocument* pDoc;
+ ScViewData* pViewData;
+ SCTAB nCurTab;
+
+#ifdef _AREASDLG_CXX
+private:
+ void Impl_Reset();
+ BOOL Impl_CheckRefStrings();
+ void Impl_FillLists();
+ BOOL Impl_GetItem( Edit* pEd, SfxStringItem& rItem );
+
+ // Handler:
+ DECL_LINK( Impl_SelectHdl, ListBox* );
+ DECL_LINK( Impl_ModifyHdl, formula::RefEdit* );
+ DECL_LINK( Impl_BtnHdl, PushButton* );
+ DECL_LINK( Impl_GetFocusHdl, Control* );
+#endif
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
new file mode 100644
index 000000000000..a65a2c6edd18
--- /dev/null
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef SC_ASCIIOPT_HXX
+#define SC_ASCIIOPT_HXX
+
+#include <tools/string.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/field.hxx>
+#include <tools/stream.hxx>
+#include <svx/txencbox.hxx>
+#include "csvtablebox.hxx"
+#include "i18npool/lang.h"
+
+// ============================================================================
+
+class SC_DLLPUBLIC ScAsciiOptions
+{
+private:
+ BOOL bFixedLen;
+ String aFieldSeps;
+ BOOL bMergeFieldSeps;
+ bool bQuotedFieldAsText;
+ bool bDetectSpecialNumber;
+ sal_Unicode cTextSep;
+ CharSet eCharSet;
+ LanguageType eLang;
+ BOOL bCharSetSystem;
+ long nStartRow;
+ USHORT nInfoCount;
+ xub_StrLen* pColStart; //! TODO replace with vector
+ BYTE* pColFormat; //! TODO replace with vector
+
+public:
+ ScAsciiOptions();
+ ScAsciiOptions(const ScAsciiOptions& rOpt);
+ ~ScAsciiOptions();
+
+ static const sal_Unicode cDefaultTextSep = '"';
+
+ ScAsciiOptions& operator=( const ScAsciiOptions& rCpy );
+
+ BOOL operator==( const ScAsciiOptions& rCmp ) const;
+
+ void ReadFromString( const String& rString );
+ String WriteToString() const;
+
+ void InterpretColumnList( const String& rString );
+
+ CharSet GetCharSet() const { return eCharSet; }
+ BOOL GetCharSetSystem() const { return bCharSetSystem; }
+ const String& GetFieldSeps() const { return aFieldSeps; }
+ BOOL IsMergeSeps() const { return bMergeFieldSeps; }
+ bool IsQuotedAsText() const { return bQuotedFieldAsText; }
+ bool IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
+ sal_Unicode GetTextSep() const { return cTextSep; }
+ BOOL IsFixedLen() const { return bFixedLen; }
+ USHORT GetInfoCount() const { return nInfoCount; }
+ const xub_StrLen* GetColStart() const { return pColStart; }
+ const BYTE* GetColFormat() const { return pColFormat; }
+ long GetStartRow() const { return nStartRow; }
+ LanguageType GetLanguage() const { return eLang; }
+
+ void SetCharSet( CharSet eNew ) { eCharSet = eNew; }
+ void SetCharSetSystem( BOOL bSet ) { bCharSetSystem = bSet; }
+ void SetFixedLen( BOOL bSet ) { bFixedLen = bSet; }
+ void SetFieldSeps( const String& rStr ) { aFieldSeps = rStr; }
+ void SetMergeSeps( BOOL bSet ) { bMergeFieldSeps = bSet; }
+ void SetQuotedAsText(bool bSet) { bQuotedFieldAsText = bSet; }
+ void SetDetectSpecialNumber(bool bSet) { bDetectSpecialNumber = bSet; }
+ void SetTextSep( sal_Unicode c ) { cTextSep = c; }
+ void SetStartRow( long nRow) { nStartRow= nRow; }
+ void SetLanguage(LanguageType e) { eLang = e; }
+
+ void SetColInfo( USHORT nCount, const xub_StrLen* pStart, const BYTE* pFormat );
+ void SetColumnInfo( const ScCsvExpDataVec& rDataVec );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/attrdlg.hrc b/sc/source/ui/inc/attrdlg.hrc
new file mode 100644
index 000000000000..5a2cb3af502c
--- /dev/null
+++ b/sc/source/ui/inc/attrdlg.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> SC_DLG_ATTR
+
+#define TP_NUMBER 1
+#define TP_FONT 2
+#define TP_ALIGNMENT 3
+#define TP_BORDER 4
+#define TP_BACKGROUND 5
+#define TP_PROTECTION 6
+#define TP_FONTEFF 7
+#define TP_ASIAN 8
+
+//================================================
+// Zellschutz-TabPage:
+
+#define BTN_PROTECTED 1
+#define BTN_HIDE_FORMULAR 2
+#define BTN_HIDE_ALL 3
+#define FT_HINT 4
+#define FL_PROTECTION 5
+#define BTN_HIDE_PRINT 6
+#define FT_HINT2 7
+#define FL_PRINT 8
+
+
diff --git a/sc/source/ui/inc/attrdlg.hxx b/sc/source/ui/inc/attrdlg.hxx
new file mode 100644
index 000000000000..10870234fb1b
--- /dev/null
+++ b/sc/source/ui/inc/attrdlg.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_ATTRDLG_HXX
+#define SC_ATTRDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+class Window;
+class SfxViewFrame;
+class SfxItemSet;
+
+#ifndef LAYOUT_SFX_TABDIALOG_BROKEN
+#define LAYOUT_SFX_TABDIALOG_BROKEN 1
+#endif /* !LAYOUT_SFX_TABDIALOG_BROKEN */
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <sfx2/layout.hxx>
+#include <layout/layout-pre.hxx>
+#endif
+
+//==================================================================
+
+class ScAttrDlg : public SfxTabDialog
+{
+public:
+ ScAttrDlg( SfxViewFrame* pFrame,
+ Window* pParent,
+ const SfxItemSet* pCellAttrs );
+ ~ScAttrDlg();
+
+protected:
+ virtual void PageCreated( USHORT nPageId, SfxTabPage& rTabPage );
+
+private:
+ DECL_LINK( OkHandler, void* ); // fuer DoppelClick-Beenden in TabPages
+};
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <layout/layout-post.hxx>
+#endif
+
+#endif // SC_ATTRDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/auditsh.hxx b/sc/source/ui/inc/auditsh.hxx
new file mode 100644
index 000000000000..2d5e9adb23cb
--- /dev/null
+++ b/sc/source/ui/inc/auditsh.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_AUDITSH_HXX
+#define SC_AUDITSH_HXX
+
+#include <sfx2/shell.hxx>
+#include <sfx2/module.hxx>
+
+#include "shellids.hxx"
+
+class ScViewData;
+
+class ScAuditingShell : public SfxShell
+{
+private:
+ ScViewData* pViewData;
+ USHORT nFunction;
+
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_AUDITING_SHELL)
+
+ ScAuditingShell(ScViewData* pData);
+ ~ScAuditingShell();
+
+ void Execute(SfxRequest& rReq);
+ void GetState(SfxItemSet& rSet);
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/autofmt.hxx b/sc/source/ui/inc/autofmt.hxx
new file mode 100644
index 000000000000..786c0fcadf2e
--- /dev/null
+++ b/sc/source/ui/inc/autofmt.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_AUTOFMT_HXX
+#define SC_AUTOFMT_HXX
+
+#include <vcl/virdev.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/morebtn.hxx>
+#include <vcl/dialog.hxx>
+#include <svtools/scriptedtext.hxx>
+#include <svx/framelinkarray.hxx>
+#include "scdllapi.h"
+
+//------------------------------------------------------------------------
+
+class ScAutoFormat;
+class ScAutoFormatData;
+class SvxBoxItem;
+class SvxLineItem;
+class ScAutoFmtPreview; // s.u.
+class SvNumberFormatter;
+class ScDocument;
+
+//------------------------------------------------------------------------
+
+enum AutoFmtLine { TOP_LINE, BOTTOM_LINE, LEFT_LINE, RIGHT_LINE };
+
+//========================================================================
+
+class SC_DLLPUBLIC ScAutoFmtPreview : public Window
+{
+public:
+ ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc );
+ ~ScAutoFmtPreview();
+
+ void NotifyChange( ScAutoFormatData* pNewData );
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+
+private:
+ ScAutoFormatData* pCurData;
+ VirtualDevice aVD;
+ SvtScriptedTextHelper aScriptedText;
+ ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator > xBreakIter;
+ BOOL bFitWidth;
+ svx::frame::Array maArray; /// Implementation to draw the frame borders.
+ bool mbRTL;
+ Size aPrvSize;
+ long mnLabelColWidth;
+ long mnDataColWidth1;
+ long mnDataColWidth2;
+ long mnRowHeight;
+ const String aStrJan;
+ const String aStrFeb;
+ const String aStrMar;
+ const String aStrNorth;
+ const String aStrMid;
+ const String aStrSouth;
+ const String aStrSum;
+ SvNumberFormatter* pNumFmt;
+ //-------------------------------------------
+ SC_DLLPRIVATE void Init ();
+ SC_DLLPRIVATE void DoPaint ( const Rectangle& rRect );
+ SC_DLLPRIVATE void CalcCellArray ( BOOL bFitWidth );
+ SC_DLLPRIVATE void CalcLineMap ();
+ SC_DLLPRIVATE void PaintCells ();
+
+/* Usage of type size_t instead of SCCOL/SCROW is correct here - used in
+ conjunction with class svx::frame::Array (svx/framelinkarray.hxx), which
+ expects size_t coordinates. */
+
+ SC_DLLPRIVATE USHORT GetFormatIndex( size_t nCol, size_t nRow ) const;
+ SC_DLLPRIVATE const SvxBoxItem& GetBoxItem( size_t nCol, size_t nRow ) const;
+ SC_DLLPRIVATE const SvxLineItem& GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const;
+
+ SC_DLLPRIVATE void DrawString( size_t nCol, size_t nRow );
+ SC_DLLPRIVATE void DrawStrings();
+ SC_DLLPRIVATE void DrawBackground();
+
+ SC_DLLPRIVATE void MakeFonts ( USHORT nIndex,
+ Font& rFont,
+ Font& rCJKFont,
+ Font& rCTLFont );
+
+ SC_DLLPRIVATE String MakeNumberString( String cellString, BOOL bAddDec );
+ SC_DLLPRIVATE void DrawFrameLine ( const SvxBorderLine& rLineD,
+ Point from,
+ Point to,
+ BOOL bHorizontal,
+ const SvxBorderLine& rLineLT,
+ const SvxBorderLine& rLineL,
+ const SvxBorderLine& rLineLB,
+ const SvxBorderLine& rLineRT,
+ const SvxBorderLine& rLineR,
+ const SvxBorderLine& rLineRB );
+ SC_DLLPRIVATE void CheckPriority ( USHORT nCurLine,
+ AutoFmtLine eLine,
+ SvxBorderLine& rLine );
+ SC_DLLPRIVATE void GetLines ( USHORT nIndex, AutoFmtLine eLine,
+ SvxBorderLine& rLineD,
+ SvxBorderLine& rLineLT,
+ SvxBorderLine& rLineL,
+ SvxBorderLine& rLineLB,
+ SvxBorderLine& rLineRT,
+ SvxBorderLine& rLineR,
+ SvxBorderLine& rLineRB );
+};
+
+#endif // SC_AUTOFMT_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/autostyl.hxx b/sc/source/ui/inc/autostyl.hxx
new file mode 100644
index 000000000000..38345d1cbb5b
--- /dev/null
+++ b/sc/source/ui/inc/autostyl.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_AUTOSTYL_HXX
+#define SC_AUTOSTYL_HXX
+
+#include <vcl/timer.hxx>
+#include <tools/list.hxx>
+#include <tools/string.hxx>
+
+class ScDocShell;
+class ScRange;
+
+class ScAutoStyleList
+{
+private:
+ ScDocShell* pDocSh;
+ Timer aTimer;
+ Timer aInitTimer;
+ ULONG nTimerStart;
+ List aEntries;
+ List aInitials;
+
+ void ExecuteEntries();
+ void AdjustEntries(ULONG nDiff);
+ void StartTimer(ULONG nNow);
+ DECL_LINK( TimerHdl, Timer* );
+ DECL_LINK( InitHdl, Timer* );
+
+public:
+ ScAutoStyleList(ScDocShell* pShell);
+ ~ScAutoStyleList();
+
+ void AddInitial( const ScRange& rRange, const String& rStyle1,
+ ULONG nTimeout, const String& rStyle2 );
+ void AddEntry( ULONG nTimeout, const ScRange& rRange, const String& rStyle );
+
+ void ExecuteAllNow();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/cbutton.hxx b/sc/source/ui/inc/cbutton.hxx
new file mode 100644
index 000000000000..bdfd0b9de257
--- /dev/null
+++ b/sc/source/ui/inc/cbutton.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+//------------------------------------------------------------------
+
+#ifndef SC_CBUTTON_HXX
+#define SC_CBUTTON_HXX
+
+#include <tools/gen.hxx>
+#include <tools/color.hxx>
+
+class OutputDevice;
+
+
+//==================================================================
+
+class ScDDComboBoxButton
+{
+public:
+ ScDDComboBoxButton( OutputDevice* pOutputDevice );
+ ~ScDDComboBoxButton();
+
+ void SetOutputDevice( OutputDevice* pOutputDevice );
+
+ void Draw( const Point& rAt,
+ const Size& rSize,
+ BOOL bState,
+ BOOL bBtnIn = FALSE );
+
+ void Draw( const Point& rAt,
+ BOOL bState,
+ BOOL bBtnIn = FALSE )
+ { Draw( rAt, aBtnSize, bState, bBtnIn ); }
+
+ void Draw( BOOL bState,
+ BOOL bBtnIn = FALSE )
+ { Draw( aBtnPos, aBtnSize, bState, bBtnIn ); }
+
+ void SetOptSizePixel();
+
+ void SetPosPixel( const Point& rNewPos ) { aBtnPos = rNewPos; }
+ Point GetPosPixel() const { return aBtnPos; }
+
+ void SetSizePixel( const Size& rNewSize ) { aBtnSize = rNewSize; }
+ Size GetSizePixel() const { return aBtnSize; }
+
+private:
+ void ImpDrawArrow( const Rectangle& rRect,
+ BOOL bState );
+
+protected:
+ OutputDevice* pOut;
+ Point aBtnPos;
+ Size aBtnSize;
+};
+
+
+#endif // SC_CBUTTON_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/cellmergeoption.hxx b/sc/source/ui/inc/cellmergeoption.hxx
new file mode 100644
index 000000000000..ad5fe34d41ca
--- /dev/null
+++ b/sc/source/ui/inc/cellmergeoption.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * [ Kohei Yoshida <kyoshida@novell.com> ]
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef SC_CELLMERGEOPTION_HXX
+#define SC_CELLMERGEOPTION_HXX
+
+#include "address.hxx"
+
+#include <set>
+
+class ScRange;
+
+struct ScCellMergeOption
+{
+ ::std::set<SCTAB> maTabs;
+ SCCOL mnStartCol;
+ SCROW mnStartRow;
+ SCCOL mnEndCol;
+ SCROW mnEndRow;
+ bool mbCenter;
+
+ explicit ScCellMergeOption();
+ explicit ScCellMergeOption(const ScRange& rRange);
+ explicit ScCellMergeOption(SCCOL nStartCol, SCROW nStartRow,
+ SCCOL nEndCol, SCROW nEndRow,
+ bool bCenter = false);
+ explicit ScCellMergeOption(const ScCellMergeOption& r);
+
+ ScRange getSingleRange(SCTAB nTab) const;
+ ScRange getFirstSingleRange() const;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/cellsh.hxx b/sc/source/ui/inc/cellsh.hxx
new file mode 100644
index 000000000000..7405692d95be
--- /dev/null
+++ b/sc/source/ui/inc/cellsh.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CELLSH_HXX
+#define SC_CELLSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+#include <tools/link.hxx>
+#include "formatsh.hxx"
+#include "address.hxx"
+
+class SvxClipboardFmtItem;
+class TransferableDataHelper;
+class TransferableClipboardListener;
+class AbstractScLinkedAreaDlg;
+class ScTabViewShell;
+
+struct CellShell_Impl
+{
+ TransferableClipboardListener* m_pClipEvtLstnr;
+ AbstractScLinkedAreaDlg* m_pLinkedDlg;
+ SfxRequest* m_pRequest;
+
+ CellShell_Impl() :
+ m_pClipEvtLstnr( NULL ),
+ m_pLinkedDlg( NULL ),
+ m_pRequest( NULL ) {}
+};
+
+class ScCellShell: public ScFormatShell
+{
+private:
+ CellShell_Impl* pImpl;
+ BOOL bPastePossible;
+
+ void GetPossibleClipboardFormats( SvxClipboardFmtItem& rFormats );
+ void ExecuteExternalSource(
+ const String& _rFile, const String& _rFilter, const String& _rOptions,
+ const String& _rSource, ULONG _nRefresh, SfxRequest& _rRequest );
+
+ DECL_LINK( ClipboardChanged, TransferableDataHelper* );
+ DECL_LINK( DialogClosed, AbstractScLinkedAreaDlg* );
+
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_CELL_SHELL)
+
+ ScCellShell(ScViewData* pData);
+ virtual ~ScCellShell();
+
+ void Execute(SfxRequest &);
+ void GetState(SfxItemSet &);
+
+ void ExecuteEdit( SfxRequest& rReq );
+ void ExecuteTrans( SfxRequest& rReq );
+
+ void GetBlockState( SfxItemSet& rSet );
+ void GetCellState( SfxItemSet& rSet );
+
+ void ExecuteDB( SfxRequest& rReq );
+ void GetDBState( SfxItemSet& rSet );
+
+ void ExecImageMap(SfxRequest& rReq); // ImageMap
+ void GetImageMapState(SfxItemSet& rSet);
+
+ void GetClipState( SfxItemSet& rSet );
+ void GetHLinkState( SfxItemSet& rSet );
+
+ void ExecuteCursor( SfxRequest& rReq );
+ void ExecuteCursorSel( SfxRequest& rReq );
+ void ExecutePage( SfxRequest& rReq );
+ void ExecutePageSel( SfxRequest& rReq );
+ void ExecuteMove( SfxRequest& rReq );
+ void GetStateCursor( SfxItemSet& rSet );
+
+ static void PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/chartsh.hxx b/sc/source/ui/inc/chartsh.hxx
new file mode 100644
index 000000000000..5ede144c3c9f
--- /dev/null
+++ b/sc/source/ui/inc/chartsh.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CHARTSH_HXX
+#define CHARTSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+
+class ScViewData;
+
+#include "drawsh.hxx"
+
+class ScChartShell: public ScDrawShell
+{
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_CHART_SHELL)
+
+ ScChartShell(ScViewData* pData);
+ virtual ~ScChartShell();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/client.hxx b/sc/source/ui/inc/client.hxx
new file mode 100644
index 000000000000..da5f7db3b2f6
--- /dev/null
+++ b/sc/source/ui/inc/client.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CLIENT_HXX
+#define SC_CLIENT_HXX
+
+#include <sfx2/ipclient.hxx>
+
+class ScDocument;
+class ScTabViewShell;
+class SdrOle2Obj;
+class SdrGrafObj;
+class SdrModel;
+
+class ScClient : public SfxInPlaceClient
+{
+private:
+ SdrModel* pModel;
+ SdrGrafObj* pGrafEdit;
+
+ virtual void ObjectAreaChanged();
+ virtual void RequestNewObjectArea( Rectangle& );
+ virtual void ViewChanged();
+ virtual void MakeVisible();
+
+public:
+ ScClient( ScTabViewShell* pViewShell, Window* pDraw, SdrModel* pSdrModel, SdrOle2Obj* pObj );
+ virtual ~ScClient();
+
+ SdrGrafObj* GetGrafEdit() const { return pGrafEdit; }
+ void SetGrafEdit(SdrGrafObj* pNew) { pGrafEdit = pNew; }
+ SdrOle2Obj* GetDrawObj();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/colrowba.hxx b/sc/source/ui/inc/colrowba.hxx
new file mode 100644
index 000000000000..b46bccbaffc8
--- /dev/null
+++ b/sc/source/ui/inc/colrowba.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_COLROWBAR_HXX
+#define SC_COLROWBAR_HXX
+
+#include "hdrcont.hxx"
+#include "viewdata.hxx"
+
+class ScHeaderFunctionSet;
+class ScHeaderSelectionEngine;
+
+// ---------------------------------------------------------------------------
+
+
+class ScColBar : public ScHeaderControl
+{
+ ScViewData* pViewData;
+ ScHSplitPos eWhich;
+ ScHeaderFunctionSet* pFuncSet;
+ ScHeaderSelectionEngine* pSelEngine;
+
+public:
+ ScColBar( Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos,
+ ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng );
+ ~ScColBar();
+
+ virtual SCCOLROW GetPos();
+ virtual USHORT GetEntrySize( SCCOLROW nEntryNo );
+ virtual String GetEntryText( SCCOLROW nEntryNo );
+
+ virtual BOOL IsLayoutRTL(); // only for columns
+
+ virtual void SetEntrySize( SCCOLROW nPos, USHORT nNewSize );
+ virtual void HideEntries( SCCOLROW nStart, SCCOLROW nEnd );
+
+ virtual void SetMarking( BOOL bSet );
+ virtual void SelectWindow();
+ virtual BOOL IsDisabled();
+ virtual BOOL ResizeAllowed();
+
+ virtual void DrawInvert( long nDragPos );
+
+ virtual String GetDragHelp( long nVal );
+
+ BOOL UseNumericHeader() const;
+};
+
+
+class ScRowBar : public ScHeaderControl
+{
+ ScViewData* pViewData;
+ ScVSplitPos eWhich;
+ ScHeaderFunctionSet* pFuncSet;
+ ScHeaderSelectionEngine* pSelEngine;
+
+public:
+ ScRowBar( Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos,
+ ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng );
+ ~ScRowBar();
+
+ virtual SCCOLROW GetPos();
+ virtual USHORT GetEntrySize( SCCOLROW nEntryNo );
+ virtual String GetEntryText( SCCOLROW nEntryNo );
+
+ virtual BOOL IsMirrored(); // only for columns
+ virtual SCROW GetHiddenCount( SCROW nEntryNo ); // only for columns
+
+ virtual void SetEntrySize( SCCOLROW nPos, USHORT nNewSize );
+ virtual void HideEntries( SCCOLROW nStart, SCCOLROW nEnd );
+
+ virtual void SetMarking( BOOL bSet );
+ virtual void SelectWindow();
+ virtual BOOL IsDisabled();
+ virtual BOOL ResizeAllowed();
+
+ virtual void DrawInvert( long nDragPos );
+
+ virtual String GetDragHelp( long nVal );
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condfrmt.hrc b/sc/source/ui/inc/condfrmt.hrc
new file mode 100644
index 000000000000..67d587cf8ec9
--- /dev/null
+++ b/sc/source/ui/inc/condfrmt.hrc
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // ->RID_SCDLG_SOLVER
+
+#define CBX_COND1 1
+#define LB_COND1_1 2
+#define LB_COND1_2 3
+#define EDT_COND1_1 4
+#define RB_COND1_1 5
+#define FT_COND1_AND 6
+#define EDT_COND1_2 7
+#define RB_COND1_2 8
+#define FT_COND1_TEMPLATE 9
+#define LB_COND1_TEMPLATE 10
+
+#define CBX_COND2 11
+#define LB_COND2_1 12
+#define LB_COND2_2 13
+#define EDT_COND2_1 14
+#define RB_COND2_1 15
+#define FT_COND2_AND 16
+#define EDT_COND2_2 17
+#define RB_COND2_2 18
+#define FT_COND2_TEMPLATE 19
+#define LB_COND2_TEMPLATE 20
+
+#define CBX_COND3 21
+#define LB_COND3_1 22
+#define LB_COND3_2 23
+#define EDT_COND3_1 24
+#define RB_COND3_1 25
+#define FT_COND3_AND 26
+#define EDT_COND3_2 27
+#define RB_COND3_2 28
+#define FT_COND3_TEMPLATE 29
+#define LB_COND3_TEMPLATE 30
+
+#define FL_SEP1 41
+#define FL_SEP2 42
+
+#define BTN_OK 31
+#define BTN_CANCEL 32
+#define BTN_HELP 33
+
+#define BTN_COND1_NEW 34
+#define BTN_COND2_NEW 35
+#define BTN_COND3_NEW 36
+
diff --git a/sc/source/ui/inc/condfrmt.hxx b/sc/source/ui/inc/condfrmt.hxx
new file mode 100644
index 000000000000..9b9d4ec980ed
--- /dev/null
+++ b/sc/source/ui/inc/condfrmt.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef SC_CONDFRMT_HXX_
+#define SC_CONDFRMT_HXX_
+
+#include "anyrefdg.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+
+class ScDocument;
+class ScConditionalFormat;
+
+
+//============================================================================
+// class ScConditionalFormat
+//
+// Dialog zum Festlegen von bedingten Formaten
+
+class ScConditionalFormatDlg : public ScAnyRefDlg
+{
+public:
+ ScConditionalFormatDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pCurDoc,
+ const ScConditionalFormat* pCurrentFormat );
+ ~ScConditionalFormatDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual void AddRefEntry();
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+ virtual BOOL Close();
+
+private:
+ CheckBox aCbxCond1;
+ ListBox aLbCond11;
+ ListBox aLbCond12;
+ formula::RefEdit aEdtCond11;
+ formula::RefButton aRbCond11;
+ FixedText aFtCond1And;
+ formula::RefEdit aEdtCond12;
+ formula::RefButton aRbCond12;
+ FixedText aFtCond1Template;
+ ListBox aLbCond1Template;
+ PushButton aBtnNew1;
+ FixedLine aFlSep1;
+
+ CheckBox aCbxCond2;
+ ListBox aLbCond21;
+ ListBox aLbCond22;
+ formula::RefEdit aEdtCond21;
+ formula::RefButton aRbCond21;
+ FixedText aFtCond2And;
+ formula::RefEdit aEdtCond22;
+ formula::RefButton aRbCond22;
+ FixedText aFtCond2Template;
+ ListBox aLbCond2Template;
+ PushButton aBtnNew2;
+ FixedLine aFlSep2;
+
+ CheckBox aCbxCond3;
+ ListBox aLbCond31;
+ ListBox aLbCond32;
+ formula::RefEdit aEdtCond31;
+ formula::RefButton aRbCond31;
+ FixedText aFtCond3And;
+ formula::RefEdit aEdtCond32;
+ formula::RefButton aRbCond32;
+ FixedText aFtCond3Template;
+ ListBox aLbCond3Template;
+ PushButton aBtnNew3;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Point aCond1Pos1;
+ Point aCond1Pos2;
+ Point aRBtn1Pos1;
+ Point aRBtn1Pos2;
+ Size aCond1Size1;
+ Size aCond1Size2;
+ Size aCond1Size3;
+
+ Point aCond2Pos1;
+ Point aCond2Pos2;
+ Point aRBtn2Pos1;
+ Point aRBtn2Pos2;
+ Size aCond2Size1;
+ Size aCond2Size2;
+ Size aCond2Size3;
+
+ Point aCond3Pos1;
+ Point aCond3Pos2;
+ Point aRBtn3Pos1;
+ Point aRBtn3Pos2;
+ Size aCond3Size1;
+ Size aCond3Size2;
+ Size aCond3Size3;
+
+ formula::RefEdit* pEdActive;
+ BOOL bDlgLostFocus;
+ ScDocument* pDoc;
+
+#ifdef _CONDFRMT_CXX
+ void GetConditionalFormat( ScConditionalFormat& rCndFmt );
+
+ DECL_LINK( ClickCond1Hdl, void * );
+ DECL_LINK( ChangeCond11Hdl, void * );
+ DECL_LINK( ChangeCond12Hdl, void * );
+
+ DECL_LINK( ClickCond2Hdl, void * );
+ DECL_LINK( ChangeCond21Hdl, void * );
+ DECL_LINK( ChangeCond22Hdl, void * );
+
+ DECL_LINK( ClickCond3Hdl, void * );
+ DECL_LINK( ChangeCond31Hdl, void * );
+ DECL_LINK( ChangeCond32Hdl, void * );
+
+ DECL_LINK( GetFocusHdl, Control* );
+ DECL_LINK( LoseFocusHdl, Control* );
+ DECL_LINK( BtnHdl, PushButton* );
+ DECL_LINK( NewBtnHdl, PushButton* );
+#endif // _CONDFRMT_CXX
+};
+
+#endif // SC_CONDFRMT_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/conflictsdlg.hrc b/sc/source/ui/inc/conflictsdlg.hrc
new file mode 100644
index 000000000000..cfd864d5ec0a
--- /dev/null
+++ b/sc/source/ui/inc/conflictsdlg.hrc
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc>
+
+#define FT_CONFLICTS 1
+#define LB_CONFLICTS 2
+#define BTN_KEEPMINE 3
+#define BTN_KEEPOTHER 4
+#define FL_CONFLICTS 5
+#define BTN_KEEPALLMINE 6
+#define BTN_KEEPALLOTHERS 7
+#define BTN_CANCEL 8
+#define BTN_HELP 9
+
+#define STR_TITLE_CONFLICT 1
+#define STR_TITLE_AUTHOR 2
+#define STR_TITLE_DATE 3
+#define STR_UNKNOWN_USER 4
diff --git a/sc/source/ui/inc/conflictsdlg.hxx b/sc/source/ui/inc/conflictsdlg.hxx
new file mode 100644
index 000000000000..86e11e232c63
--- /dev/null
+++ b/sc/source/ui/inc/conflictsdlg.hxx
@@ -0,0 +1,215 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CONFLICTSDLG_HXX
+#define SC_CONFLICTSDLG_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <svx/ctredlin.hxx>
+
+#include "chgtrack.hxx"
+#include "docsh.hxx"
+
+class ScViewData;
+
+
+//=============================================================================
+
+enum ScConflictAction
+{
+ SC_CONFLICT_ACTION_NONE,
+ SC_CONFLICT_ACTION_KEEP_MINE,
+ SC_CONFLICT_ACTION_KEEP_OTHER
+};
+
+typedef ::std::vector< ULONG > ScChangeActionList;
+
+
+//=============================================================================
+// struct ScConflictsListEntry
+//=============================================================================
+
+struct ScConflictsListEntry
+{
+ ScConflictAction meConflictAction;
+ ScChangeActionList maSharedActions;
+ ScChangeActionList maOwnActions;
+
+ bool HasSharedAction( ULONG nSharedAction ) const;
+ bool HasOwnAction( ULONG nOwnAction ) const;
+};
+
+
+//=============================================================================
+
+typedef ::std::vector< ScConflictsListEntry > ScConflictsList;
+
+
+//=============================================================================
+// class ScConflictsListHelper
+//=============================================================================
+
+class ScConflictsListHelper
+{
+private:
+ static void Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap );
+
+public:
+ static bool HasOwnAction( ScConflictsList& rConflictsList, ULONG nOwnAction );
+
+ static ScConflictsListEntry* GetSharedActionEntry( ScConflictsList& rConflictsList, ULONG nSharedAction );
+ static ScConflictsListEntry* GetOwnActionEntry( ScConflictsList& rConflictsList, ULONG nOwnAction );
+
+ static void TransformConflictsList( ScConflictsList& rConflictsList,
+ ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap );
+};
+
+
+//=============================================================================
+// class ScConflictsFinder
+//=============================================================================
+
+class ScConflictsFinder
+{
+private:
+ ScChangeTrack* mpTrack;
+ ULONG mnStartShared;
+ ULONG mnEndShared;
+ ULONG mnStartOwn;
+ ULONG mnEndOwn;
+ ScConflictsList& mrConflictsList;
+
+ static bool DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
+ ScConflictsListEntry* GetIntersectingEntry( const ScChangeAction* pAction ) const;
+ ScConflictsListEntry* GetEntry( ULONG nSharedAction, const ScChangeActionList& rOwnActions );
+
+public:
+ ScConflictsFinder( ScChangeTrack* pTrack, ULONG nStartShared, ULONG nEndShared,
+ ULONG nStartOwn, ULONG nEndOwn, ScConflictsList& rConflictsList );
+ virtual ~ScConflictsFinder();
+
+ bool Find();
+};
+
+
+//=============================================================================
+// class ScConflictsResolver
+//=============================================================================
+
+class ScConflictsResolver
+{
+private:
+ ScChangeTrack* mpTrack;
+ ScConflictsList& mrConflictsList;
+
+public:
+ ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList );
+ virtual ~ScConflictsResolver();
+
+ void HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
+ bool bHandleContentAction, bool bHandleNonContentAction );
+};
+
+
+//=============================================================================
+// class ScConflictsListBox
+//=============================================================================
+
+class ScConflictsListBox: public SvxRedlinTable
+{
+private:
+
+public:
+ ScConflictsListBox( Window* pParent, const ResId& rResId );
+ ~ScConflictsListBox();
+};
+
+//=============================================================================
+// class ScConflictsDlg
+//=============================================================================
+
+class ScConflictsDlg : public ModalDialog
+{
+private:
+ FixedText maFtConflicts;
+ ScConflictsListBox maLbConflicts;
+ PushButton maBtnKeepMine;
+ PushButton maBtnKeepOther;
+ FixedLine maFlConflicts;
+ PushButton maBtnKeepAllMine;
+ PushButton maBtnKeepAllOthers;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ String maStrTitleConflict;
+ String maStrTitleAuthor;
+ String maStrTitleDate;
+ String maStrUnknownUser;
+
+ ScViewData* mpViewData;
+ ScDocument* mpOwnDoc;
+ ScChangeTrack* mpOwnTrack;
+ ScDocument* mpSharedDoc;
+ ScChangeTrack* mpSharedTrack;
+ ScConflictsList& mrConflictsList;
+ Size maDialogSize;
+
+ Timer maSelectionTimer;
+ bool mbInSelectHdl;
+ bool mbInDeselectHdl;
+
+ String GetConflictString( const ScConflictsListEntry& rConflictEntry );
+ String GetActionString( const ScChangeAction* pAction, ScDocument* pDoc );
+ void HandleListBoxSelection( bool bSelectHandle );
+
+ void SetConflictAction( SvLBoxEntry* pRootEntry, ScConflictAction eConflictAction );
+ void KeepHandler( bool bMine );
+ void KeepAllHandler( bool bMine );
+
+ DECL_LINK( SelectHandle, SvxRedlinTable* );
+ DECL_LINK( DeselectHandle, SvxRedlinTable* );
+ DECL_LINK( UpdateSelectionHdl, Timer* );
+ DECL_LINK( KeepMineHandle, void* );
+ DECL_LINK( KeepOtherHandle, void* );
+ DECL_LINK( KeepAllMineHandle, void* );
+ DECL_LINK( KeepAllOthersHandle, void* );
+
+public:
+ ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList );
+ ~ScConflictsDlg();
+
+ virtual void Resize();
+ void UpdateView();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/consdlg.hxx b/sc/source/ui/inc/consdlg.hxx
new file mode 100644
index 000000000000..128b8b23f82b
--- /dev/null
+++ b/sc/source/ui/inc/consdlg.hxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CONSDLG_HXX
+#define SC_CONSDLG_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <vcl/morebtn.hxx>
+#include "global.hxx"
+#include "anyrefdg.hxx"
+
+class ScViewData;
+class ScDocument;
+class ScRangeUtil;
+class ScAreaData;
+
+
+//============================================================================
+
+class ScConsolidateDlg : public ScAnyRefDlg
+{
+public:
+ ScConsolidateDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScConsolidateDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+
+ virtual BOOL IsRefInputMode() const { return TRUE; }
+ virtual void SetActive();
+
+ virtual BOOL Close();
+
+protected:
+ virtual void Deactivate();
+
+private:
+ FixedText aFtFunc;
+ ListBox aLbFunc;
+
+ FixedText aFtConsAreas;
+ MultiListBox aLbConsAreas;
+
+ ListBox aLbDataArea;
+ FixedText aFtDataArea;
+ formula::RefEdit aEdDataArea;
+ formula::RefButton aRbDataArea;
+
+ ListBox aLbDestArea;
+ FixedText aFtDestArea;
+ formula::RefEdit aEdDestArea;
+ formula::RefButton aRbDestArea;
+
+ FixedLine aFlConsBy;
+ CheckBox aBtnByRow;
+ CheckBox aBtnByCol;
+
+ FixedLine aFlSep;
+ FixedLine aFlOptions;
+ CheckBox aBtnRefs;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ PushButton aBtnAdd;
+ PushButton aBtnRemove;
+ MoreButton aBtnMore;
+
+ String aStrUndefined;
+
+ ScConsolidateParam theConsData;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ ScRangeUtil* pRangeUtil;
+ ScAreaData* pAreaData;
+ USHORT nAreaDataCount;
+ USHORT nWhichCons;
+
+ formula::RefEdit* pRefInputEdit;
+ BOOL bDlgLostFocus;
+
+#ifdef _CONSDLG_CXX
+private:
+ void Init ();
+ void FillAreaLists ();
+ BOOL VerifyEdit ( formula::RefEdit* pEd );
+
+ DECL_LINK( OkHdl, void* );
+ DECL_LINK( ClickHdl, PushButton* );
+ DECL_LINK( GetFocusHdl, Control* );
+ DECL_LINK( ModifyHdl, formula::RefEdit* );
+ DECL_LINK( SelectHdl, ListBox* );
+
+ ScSubTotalFunc LbPosToFunc( USHORT nPos );
+ USHORT FuncToLbPos( ScSubTotalFunc eFunc );
+#endif // _CONSDLG_CXX
+};
+
+
+
+#endif // SC_CONSDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/content.hxx b/sc/source/ui/inc/content.hxx
new file mode 100644
index 000000000000..15ef650afa59
--- /dev/null
+++ b/sc/source/ui/inc/content.hxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CONTENT_HXX
+#define SC_CONTENT_HXX
+
+#include <svtools/svtreebx.hxx>
+#include "global.hxx"
+#include "address.hxx"
+#include <tools/solar.h>
+
+class ScNavigatorDlg;
+class ScNavigatorSettings;
+class ScDocument;
+class ScDocShell;
+class ScAreaLink;
+
+#define SC_CONTENT_ROOT 0
+#define SC_CONTENT_TABLE 1
+#define SC_CONTENT_RANGENAME 2
+#define SC_CONTENT_DBAREA 3
+#define SC_CONTENT_GRAPHIC 4
+#define SC_CONTENT_OLEOBJECT 5
+#define SC_CONTENT_NOTE 6
+#define SC_CONTENT_AREALINK 7
+#define SC_CONTENT_DRAWING 8
+#define SC_CONTENT_COUNT 9
+
+const ULONG SC_CONTENT_NOCHILD = ~0UL;
+
+//
+// TreeListBox fuer Inhalte
+//
+
+class ScContentTree : public SvTreeListBox
+{
+ ScNavigatorDlg* pParentWindow;
+ ImageList aEntryImages;
+ ImageList aHCEntryImages;
+ SvLBoxEntry* pRootNodes[SC_CONTENT_COUNT];
+ USHORT nRootType; // als Root eingestellt
+ String aManualDoc; // im Navigator umgeschaltet (Title)
+ BOOL bHiddenDoc; // verstecktes aktiv?
+ String aHiddenName; // URL zum Laden
+ String aHiddenTitle; // fuer Anzeige
+ ScDocument* pHiddenDocument; // temporaer
+
+ USHORT pPosList[SC_CONTENT_COUNT]; // fuer die Reihenfolge
+
+ static BOOL bIsInDrag; // static, falls der Navigator im ExecuteDrag geloescht wird
+
+ ScDocShell* GetManualOrCurrent();
+
+ void InitRoot(USHORT nType);
+ void ClearType(USHORT nType);
+ void ClearAll();
+ void InsertContent( USHORT nType, const String& rValue );
+ void GetDrawNames( USHORT nType );
+
+ void GetTableNames();
+ void GetAreaNames();
+ void GetDbNames();
+ void GetLinkNames();
+ void GetGraphicNames();
+ void GetOleNames();
+ void GetDrawingNames();
+ void GetNoteStrings();
+
+ static bool IsPartOfType( USHORT nContentType, USHORT nObjIdentifier );
+
+ BOOL DrawNamesChanged( USHORT nType );
+ BOOL NoteStringsChanged();
+
+ ScAddress GetNotePos( ULONG nIndex );
+ const ScAreaLink* GetLink( ULONG nIndex );
+
+ /** Returns the indexes of the specified listbox entry.
+ @param rnRootIndex Root index of specified entry is returned.
+ @param rnChildIndex Index of the entry inside its root is returned (or SC_CONTENT_NOCHILD if entry is root).
+ @param pEntry The entry to examine. */
+ void GetEntryIndexes( USHORT& rnRootIndex, ULONG& rnChildIndex, SvLBoxEntry* pEntry ) const;
+
+ /** Returns the child index of the specified listbox entry.
+ @param pEntry The entry to examine or NULL for the selected entry.
+ @return Index of the entry inside its root or SC_CONTENT_NOCHILD if entry is root. */
+ ULONG GetChildIndex( SvLBoxEntry* pEntry ) const;
+
+ void DoDrag();
+
+ ScDocument* GetSourceDocument();
+
+ DECL_LINK( ContentDoubleClickHdl, ScContentTree* );
+ DECL_STATIC_LINK( ScContentTree, ExecDragHdl, void* );
+
+protected:
+// virtual BOOL Drop( const DropEvent& rEvt );
+// virtual BOOL QueryDrop( DropEvent& rEvt );
+
+ using SvTreeListBox::ExecuteDrop;
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+ virtual void DragFinished( sal_Int8 nAction );
+
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+public:
+ ScContentTree( Window* pParent, const ResId& rResId );
+ ~ScContentTree();
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+ void InitWindowBits( BOOL bButtons );
+
+ void Refresh( USHORT nType = 0 );
+
+ void ToggleRoot();
+ void SetRootType( USHORT nNew );
+ USHORT GetRootType() const { return nRootType; }
+
+ void ActiveDocChanged();
+ void ResetManualDoc();
+ void SetManualDoc(const String& rName);
+ BOOL LoadFile(const String& rUrl);
+ void SelectDoc(const String& rName);
+
+ const String& GetHiddenTitle() const { return aHiddenTitle; }
+
+ /** Applies the navigator settings to the listbox. */
+ void ApplySettings();
+ /** Stores the current listbox state in the navigator settings. */
+ void StoreSettings() const;
+
+ static BOOL IsInDrag() { return bIsInDrag; }
+};
+
+
+
+
+#endif // SC_NAVIPI_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/corodlg.hxx b/sc/source/ui/inc/corodlg.hxx
new file mode 100644
index 000000000000..33eb9c883d28
--- /dev/null
+++ b/sc/source/ui/inc/corodlg.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CORODLG_HXX
+#define SC_CORODLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+
+#include "sc.hrc"
+#include "scresid.hxx"
+
+//------------------------------------------------------------------------
+
+class ScColRowLabelDlg : public ModalDialog
+{
+public:
+ ScColRowLabelDlg( Window* pParent,
+ BOOL bCol = FALSE,
+ BOOL bRow = FALSE )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_CHARTCOLROW ) ),
+ aFlColRow ( this, ScResId(6) ),
+ aBtnRow ( this, ScResId(2) ),
+ aBtnCol ( this, ScResId(1) ),
+ aBtnOk ( this, ScResId(3) ),
+ aBtnCancel ( this, ScResId(4) ),
+ aBtnHelp ( this, ScResId(5) )
+ {
+ FreeResource();
+ aBtnCol.Check( bCol );
+ aBtnRow.Check( bRow );
+ }
+
+ BOOL IsCol() { return aBtnCol.IsChecked(); }
+ BOOL IsRow() { return aBtnRow.IsChecked(); }
+
+private:
+ FixedLine aFlColRow;
+ CheckBox aBtnRow;
+ CheckBox aBtnCol;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+};
+
+
+#endif
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/crdlg.hxx b/sc/source/ui/inc/crdlg.hxx
new file mode 100644
index 000000000000..00ce4422ebae
--- /dev/null
+++ b/sc/source/ui/inc/crdlg.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CRDLG_HXX
+#define SC_CRDLG_HXX
+
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+#include "scui_def.hxx"
+
+//------------------------------------------------------------------------
+
+class ScColOrRowDlg : public ModalDialog
+{
+public:
+ ScColOrRowDlg( Window* pParent,
+ const String& rStrTitle,
+ const String& rStrLabel,
+ BOOL bColDefault = TRUE );
+ ~ScColOrRowDlg();
+
+private:
+ FixedLine aFlFrame;
+ RadioButton aBtnRows;
+ RadioButton aBtnCols;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ DECL_LINK( OkHdl, OKButton * );
+};
+
+
+#endif
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/crnrdlg.hrc b/sc/source/ui/inc/crnrdlg.hrc
new file mode 100644
index 000000000000..8e8de3fe32bd
--- /dev/null
+++ b/sc/source/ui/inc/crnrdlg.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_COLROWNAMERANGES
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_ADD 3
+#define BTN_REMOVE 4
+#define BTN_HELP 5
+//
+#define LB_RANGE 11
+//
+#define FL_ASSIGN 12
+#define ED_AREA 13
+#define RB_AREA 14
+#define BTN_COLHEAD 15
+#define BTN_ROWHEAD 16
+#define ED_DATA 17
+#define RB_DATA 18
+#define FT_DATA_LABEL 19
+//
diff --git a/sc/source/ui/inc/crnrdlg.hxx b/sc/source/ui/inc/crnrdlg.hxx
new file mode 100644
index 000000000000..f09d05ed4c66
--- /dev/null
+++ b/sc/source/ui/inc/crnrdlg.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CRNRDLG_HXX
+#define SC_CRNRDLG_HXX
+
+#include "anyrefdg.hxx"
+#include "rangelst.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <hash_map>
+
+class ScViewData;
+class ScDocument;
+
+
+//============================================================================
+
+class ScColRowNameRangesDlg : public ScAnyRefDlg
+{
+public:
+ ScColRowNameRangesDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData );
+ ~ScColRowNameRangesDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+ virtual BOOL Close();
+
+private:
+ FixedLine aFlAssign;
+ ListBox aLbRange;
+
+ formula::RefEdit aEdAssign;
+ formula::RefButton aRbAssign;
+ RadioButton aBtnColHead;
+ RadioButton aBtnRowHead;
+ FixedText aFtAssign2;
+ formula::RefEdit aEdAssign2;
+ formula::RefButton aRbAssign2;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ PushButton aBtnAdd;
+ PushButton aBtnRemove;
+
+ ScRange theCurArea;
+ ScRange theCurData;
+
+ ScRangePairListRef xColNameRanges;
+ ScRangePairListRef xRowNameRanges;
+
+ typedef ::std::hash_map< String, ScRange, ScStringHashCode, ::std::equal_to<String> > NameRangeMap;
+ NameRangeMap aRangeMap;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ formula::RefEdit* pEdActive;
+ BOOL bDlgLostFocus;
+
+#ifdef _CRNRDLG_CXX
+private:
+ void Init ();
+ void UpdateNames ();
+ void UpdateRangeData ( const ScRange& rRange, BOOL bColName );
+ void SetColRowData( const ScRange& rLabelRange,BOOL bRef=FALSE);
+ void AdjustColRowData( const ScRange& rDataRange,BOOL bRef=FALSE);
+ DECL_LINK( CancelBtnHdl, void * );
+ DECL_LINK( OkBtnHdl, void * );
+ DECL_LINK( AddBtnHdl, void * );
+ DECL_LINK( RemoveBtnHdl, void * );
+ DECL_LINK( Range1SelectHdl, void * );
+ DECL_LINK( Range1DataModifyHdl, void * );
+ DECL_LINK( ColClickHdl, void * );
+ DECL_LINK( RowClickHdl, void * );
+ DECL_LINK( Range2DataModifyHdl, void * );
+ DECL_LINK( GetFocusHdl, Control* );
+ DECL_LINK( LoseFocusHdl, Control* );
+#endif
+};
+
+
+
+#endif // SC_CRNRDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/csvcontrol.hxx b/sc/source/ui/inc/csvcontrol.hxx
new file mode 100644
index 000000000000..e8fc6e51cd10
--- /dev/null
+++ b/sc/source/ui/inc/csvcontrol.hxx
@@ -0,0 +1,434 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_CSVCONTROL_HXX
+#define _SC_CSVCONTROL_HXX
+
+#include <vcl/ctrl.hxx>
+#include "scdllapi.h"
+#include "global.hxx"
+#include "address.hxx"
+#include "csvsplits.hxx"
+#include <com/sun/star/uno/Reference.hxx>
+
+
+class ScAccessibleCsvControl;
+namespace com { namespace sun { namespace star { namespace accessibility {
+ class XAccessible;
+} } } }
+
+
+// ============================================================================
+
+/** Minimum character count for a column in separators mode. */
+const sal_Int32 CSV_MINCOLWIDTH = 8;
+/** Maximum length of a cell string. */
+const xub_StrLen CSV_MAXSTRLEN = 0x7FFF;
+/** Transparency for header color of selected columns. */
+const sal_uInt16 CSV_HDR_TRANSPARENCY = 85;
+/** Minimum distance to border for auto scroll. */
+const sal_Int32 CSV_SCROLL_DIST = 3;
+
+//! TODO make string array dynamic
+const sal_Int32 CSV_PREVIEW_LINES = 32; // maximum count of preview lines
+/** Maximum count of columns. */
+const sal_Int32 CSV_MAXCOLCOUNT = MAXCOLCOUNT;
+
+/** Default column data type. */
+const sal_Int32 CSV_TYPE_DEFAULT = 0;
+/** Multi selection with different types. */
+const sal_Int32 CSV_TYPE_MULTI = -1;
+/** No column selected. */
+const sal_Int32 CSV_TYPE_NOSELECTION = -2;
+
+// External used column types.
+const sal_uInt8 SC_COL_STANDARD = 1;
+const sal_uInt8 SC_COL_TEXT = 2;
+const sal_uInt8 SC_COL_MDY = 3;
+const sal_uInt8 SC_COL_DMY = 4;
+const sal_uInt8 SC_COL_YMD = 5;
+const sal_uInt8 SC_COL_SKIP = 9;
+const sal_uInt8 SC_COL_ENGLISH = 10;
+
+
+// ============================================================================
+
+/** Exported data of a column (data used in the dialog). */
+struct ScCsvExpData
+{
+ xub_StrLen mnIndex; /// Index of a column.
+ sal_uInt8 mnType; /// External type of the column.
+
+ inline ScCsvExpData() : mnIndex( 0 ), mnType( SC_COL_STANDARD ) {}
+ inline ScCsvExpData( xub_StrLen nIndex, sal_uInt8 nType ) :
+ mnIndex( nIndex ), mnType( nType ) {}
+};
+
+typedef ::std::vector< ScCsvExpData > ScCsvExpDataVec;
+
+
+// ============================================================================
+
+/** Specifies which element should be used to perform an action. */
+enum ScMoveMode
+{
+ MOVE_NONE, /// No action.
+ MOVE_FIRST, /// First element in current context.
+ MOVE_LAST, /// Last element in current context.
+ MOVE_PREV, /// Predecessor of current element in current context.
+ MOVE_NEXT, /// Successor of current element in current context.
+ MOVE_PREVPAGE, /// Previous page relative to current context.
+ MOVE_NEXTPAGE /// Next page relative to current context.
+};
+
+
+// ============================================================================
+
+/** Flags for comparison of old and new control layout data. */
+typedef sal_uInt32 ScCsvDiff;
+
+const ScCsvDiff CSV_DIFF_EQUAL = 0x00000000;
+const ScCsvDiff CSV_DIFF_POSCOUNT = 0x00000001;
+const ScCsvDiff CSV_DIFF_POSOFFSET = 0x00000002;
+const ScCsvDiff CSV_DIFF_HDRWIDTH = 0x00000004;
+const ScCsvDiff CSV_DIFF_CHARWIDTH = 0x00000008;
+const ScCsvDiff CSV_DIFF_LINECOUNT = 0x00000010;
+const ScCsvDiff CSV_DIFF_LINEOFFSET = 0x00000020;
+const ScCsvDiff CSV_DIFF_HDRHEIGHT = 0x00000040;
+const ScCsvDiff CSV_DIFF_LINEHEIGHT = 0x00000080;
+const ScCsvDiff CSV_DIFF_RULERCURSOR = 0x00000100;
+const ScCsvDiff CSV_DIFF_GRIDCURSOR = 0x00000200;
+
+const ScCsvDiff CSV_DIFF_HORIZONTAL = CSV_DIFF_POSCOUNT | CSV_DIFF_POSOFFSET | CSV_DIFF_HDRWIDTH | CSV_DIFF_CHARWIDTH;
+const ScCsvDiff CSV_DIFF_VERTICAL = CSV_DIFF_LINECOUNT | CSV_DIFF_LINEOFFSET | CSV_DIFF_HDRHEIGHT | CSV_DIFF_LINEHEIGHT;
+const ScCsvDiff CSV_DIFF_CURSOR = CSV_DIFF_RULERCURSOR | CSV_DIFF_GRIDCURSOR;
+
+
+// ----------------------------------------------------------------------------
+
+/** A structure containing all layout data valid for both ruler and data grid
+ (i.e. scroll position or column width). */
+struct ScCsvLayoutData
+{
+ // horizontal settings
+ sal_Int32 mnPosCount; /// Number of positions.
+ sal_Int32 mnPosOffset; /// Horizontal scroll offset.
+
+ sal_Int32 mnWinWidth; /// Width of ruler and data grid.
+ sal_Int32 mnHdrWidth; /// Width of the header column.
+ sal_Int32 mnCharWidth; /// Pixel width of one character.
+
+ // vertical settings
+ sal_Int32 mnLineCount; /// Number of data lines.
+ sal_Int32 mnLineOffset; /// Index of first visible line (0-based).
+
+ sal_Int32 mnWinHeight; /// Height of entire data grid (incl. header).
+ sal_Int32 mnHdrHeight; /// Height of the header line.
+ sal_Int32 mnLineHeight; /// Height of a data line.
+
+ // cursor settings
+ sal_Int32 mnPosCursor; /// Position of ruler cursor.
+ sal_Int32 mnColCursor; /// Position of grid column cursor.
+
+ mutable sal_Int32 mnNoRepaint; /// >0 = no repaint.
+ bool mbAppRTL; /// true = application in RTL mode.
+
+ explicit ScCsvLayoutData();
+
+ /** Returns differences to rData.
+ @descr For each difference the appropriate bit is set in the returned value. */
+ ScCsvDiff GetDiff( const ScCsvLayoutData& rData ) const;
+};
+
+inline bool operator==( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 )
+{
+ return rData1.GetDiff( rData2 ) == CSV_DIFF_EQUAL;
+}
+
+inline bool operator!=( const ScCsvLayoutData& rData1, const ScCsvLayoutData& rData2 )
+{
+ return !(rData1 == rData2);
+}
+
+
+// ============================================================================
+
+/** Enumeration of possible commands to change any settings of the CSV controls.
+ @descr Controls have to send commands instead of changing their settings directly.
+ This helps to keep the different controls consistent to each other.
+ A command can contain 0 to 2 sal_Int32 parameters. In the description of each
+ command the required parameters are swown in brackets. [-] means no parameter. */
+enum ScCsvCmdType
+{
+ // misc
+ CSVCMD_NONE, /// No command. [-]
+ CSVCMD_REPAINT, /// Repaint all controls. [-]
+
+ // modify horizontal dimensions
+ CSVCMD_SETPOSCOUNT, /// Change position/column count. [character count]
+ CSVCMD_SETPOSOFFSET, /// Change position offset (scroll pos). [position]
+ CSVCMD_SETHDRWIDTH, /// Change width of the header column. [width in pixel]
+ CSVCMD_SETCHARWIDTH, /// Change character pixel width. [width in pixel]
+
+ // modify vertical dimensions
+ CSVCMD_SETLINECOUNT, /// Change number of data lines. [line count]
+ CSVCMD_SETLINEOFFSET, /// Change first visible line. [line index]
+ CSVCMD_SETHDRHEIGHT, /// Change height of top header line. [height in pixel]
+ CSVCMD_SETLINEHEIGHT, /// Change data line pixel height. [height in pixel}
+
+ // cursors/positions
+ CSVCMD_MOVERULERCURSOR, /// Move ruler cursor to new position. [position]
+ CSVCMD_MOVEGRIDCURSOR, /// Move data grid cursor to new column. [position]
+ CSVCMD_MAKEPOSVISIBLE, /// Move to make passed position visible (for mouse tracking). [position]
+
+ // table contents
+ CSVCMD_NEWCELLTEXTS, /// Recalculate splits and cell texts. [-]
+ CSVCMD_UPDATECELLTEXTS, /// Update cell texts with current split settings. [-]
+ CSVCMD_SETCOLUMNTYPE, /// Change data type of selected columns. [column type]
+ CSVCMD_EXPORTCOLUMNTYPE, /// Send selected column type to external controls. [-]
+ CSVCMD_SETFIRSTIMPORTLINE, /// Set number of first imported line. [line index]
+
+ // splits
+ CSVCMD_INSERTSPLIT, /// Insert a split. [position]
+ CSVCMD_REMOVESPLIT, /// Remove a split. [position]
+ CSVCMD_TOGGLESPLIT, /// Inserts or removes a split. [position]
+ CSVCMD_MOVESPLIT, /// Move a split. [old position, new position]
+ CSVCMD_REMOVEALLSPLITS /// Remove all splits. [-]
+};
+
+
+// ----------------------------------------------------------------------------
+
+/** Data for a CSV control command. The stored position data is aways character based,
+ it's never a column index (required for internal consistency). */
+class ScCsvCmd
+{
+private:
+ ScCsvCmdType meType; /// The command.
+ sal_Int32 mnParam1; /// First parameter.
+ sal_Int32 mnParam2; /// Second parameter.
+
+public:
+ inline explicit ScCsvCmd() : meType( CSVCMD_NONE ),
+ mnParam1( CSV_POS_INVALID ), mnParam2( CSV_POS_INVALID ) {}
+
+ inline void Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 );
+
+ inline ScCsvCmdType GetType() const { return meType; }
+ inline sal_Int32 GetParam1() const { return mnParam1; }
+ inline sal_Int32 GetParam2() const { return mnParam2; }
+};
+
+inline void ScCsvCmd::Set( ScCsvCmdType eType, sal_Int32 nParam1, sal_Int32 nParam2 )
+{
+ meType = eType; mnParam1 = nParam1; mnParam2 = nParam2;
+}
+
+
+// ============================================================================
+
+/** Base class for the CSV ruler and the data grid control. Implements command handling. */
+class SC_DLLPUBLIC ScCsvControl : public Control
+{
+protected:
+ typedef ::std::vector< String > StringVec;
+ typedef ::std::vector< StringVec > StringVecVec;
+
+ typedef ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > XAccessibleRef;
+
+private:
+ Link maCmdHdl; /// External command handler.
+ ScCsvCmd maCmd; /// Data of last command.
+ const ScCsvLayoutData& mrData; /// Shared layout data.
+
+ XAccessibleRef mxAccessible; /// The accessible object of the control.
+ ScAccessibleCsvControl* mpAccessible; /// Pointer to the accessible implementation object.
+ bool mbValidGfx; /// Content of virtual devices valid?
+
+ // ------------------------------------------------------------------------
+public:
+ explicit ScCsvControl( ScCsvControl& rParent );
+ explicit ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, WinBits nStyle = 0 );
+ explicit ScCsvControl( Window* pParent, const ScCsvLayoutData& rData, const ResId& rResId );
+ virtual ~ScCsvControl();
+
+ // event handling ---------------------------------------------------------
+
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ /** Sends a GetFocus or LoseFocus event to the accessibility object. */
+ void AccSendFocusEvent( bool bFocused );
+ /** Sends a caret changed event to the accessibility object. */
+ void AccSendCaretEvent();
+ /** Sends a visible area changed event to the accessibility object. */
+ void AccSendVisibleEvent();
+ /** Sends a selection changed event to the accessibility object. */
+ void AccSendSelectionEvent();
+ /** Sends a table model changed event for changed cell contents to the accessibility object. */
+ void AccSendTableUpdateEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn, bool bAllRows = true );
+ /** Sends a table model changed event for an inserted column to the accessibility object. */
+ void AccSendInsertColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+ /** Sends a table model changed event for a removed column to the accessibility object. */
+ void AccSendRemoveColumnEvent( sal_uInt32 nFirstColumn, sal_uInt32 nLastColumn );
+
+ // repaint helpers --------------------------------------------------------
+
+ /** Sets the graphic invalid (next Redraw() will not use cached graphic). */
+ inline void InvalidateGfx() { mbValidGfx = false; }
+ /** Sets the graphic valid (next Redraw() will use cached graphic). */
+ inline void ValidateGfx() { mbValidGfx = true; }
+ /** Returns true, if cached graphic is valid. */
+ inline bool IsValidGfx() const { return mbValidGfx; }
+
+ /** Repaints all controls.
+ @param bInvalidate true = invalidates graphics of this control (not all). */
+ void Repaint( bool bInvalidate = false );
+ /** Increases no-repaint counter (controls do not repaint until the last EnableRepaint()). */
+ void DisableRepaint();
+ /** Decreases no-repaint counter and repaints if counter reaches 0.
+ @param bInvalidate true = invalidates graphics of this control (not all). */
+ void EnableRepaint( bool bInvalidate = false );
+ /** Returns true, if controls will not repaint. */
+ inline bool IsNoRepaint() const { return mrData.mnNoRepaint > 0; }
+
+ // command handling -------------------------------------------------------
+
+ /** Sets a new command handler. */
+ inline void SetCmdHdl( const Link& rHdl ) { maCmdHdl = rHdl; }
+ /** Returns the current command handler. */
+ inline const Link& GetCmdHdl() const { return maCmdHdl; }
+ /** Returns data of the last command. */
+ inline const ScCsvCmd& GetCmd() const { return maCmd; }
+
+ /** Executes a command by calling command handler. */
+ void Execute(
+ ScCsvCmdType eType,
+ sal_Int32 nParam1 = CSV_POS_INVALID,
+ sal_Int32 nParam2 = CSV_POS_INVALID );
+
+ // layout helpers ---------------------------------------------------------
+
+ /** Returns a reference to the current layout data. */
+ inline const ScCsvLayoutData& GetLayoutData() const { return mrData; }
+ /** Returns true, if the Right-to-Left layout mode is active. */
+ inline bool IsRTL() const { return mrData.mbAppRTL; }
+
+ /** Returns the number of available positions. */
+ inline sal_Int32 GetPosCount() const { return mrData.mnPosCount; }
+ /** Returns the number of visible positions. */
+ sal_Int32 GetVisPosCount() const;
+ /** Returns the first visible position. */
+ inline sal_Int32 GetFirstVisPos() const { return mrData.mnPosOffset; }
+ /** Returns the last visible position. */
+ inline sal_Int32 GetLastVisPos() const { return GetFirstVisPos() + GetVisPosCount(); }
+ /** Returns highest possible position for first visible character. */
+ sal_Int32 GetMaxPosOffset() const;
+
+ /** Returns true, if it is allowed to set a split at nPos. */
+ bool IsValidSplitPos( sal_Int32 nPos ) const;
+ /** Returns true, if nPos is an allowed AND visible split position. */
+ bool IsVisibleSplitPos( sal_Int32 nPos ) const;
+
+ /** Returns the width of the header column. */
+ inline sal_Int32 GetHdrWidth() const { return mrData.mnHdrWidth; }
+ /** Returns the width of one character column. */
+ inline sal_Int32 GetCharWidth() const { return mrData.mnCharWidth; }
+ /** Returns the start position of the header column. */
+ sal_Int32 GetHdrX() const;
+ /** Returns the X position of the first pixel of the data area. */
+ sal_Int32 GetFirstX() const;
+ /** Returns the X position of the last pixel of the data area. */
+ sal_Int32 GetLastX() const;
+ /** Returns output X coordinate of the specified position. */
+ sal_Int32 GetX( sal_Int32 nPos ) const;
+ /** Returns position from output coordinate. */
+ sal_Int32 GetPosFromX( sal_Int32 nX ) const;
+
+ /** Returns the number of data lines. */
+ inline sal_Int32 GetLineCount() const { return mrData.mnLineCount; }
+ /** Returns the number of visible lines (including partly visible bottom line). */
+ sal_Int32 GetVisLineCount() const;
+ /** Returns index of first visible line. */
+ inline sal_Int32 GetFirstVisLine() const { return mrData.mnLineOffset; }
+ /** Returns index of last visible line. */
+ sal_Int32 GetLastVisLine() const;
+ /** Returns highest possible index for first line. */
+ sal_Int32 GetMaxLineOffset() const;
+
+ /** Returns true, if nLine is a valid line index. */
+ bool IsValidLine( sal_Int32 nLine ) const;
+ /** Returns true, if nLine is a valid and visible line index. */
+ bool IsVisibleLine( sal_Int32 nLine ) const;
+
+ /** Returns the height of the header line. */
+ inline sal_Int32 GetHdrHeight() const { return mrData.mnHdrHeight; }
+ /** Returns the height of one line. */
+ inline sal_Int32 GetLineHeight() const { return mrData.mnLineHeight; }
+ /** Returns output Y coordinate of the specified line. */
+ sal_Int32 GetY( sal_Int32 nLine ) const;
+ /** Returns line index from output coordinate. */
+ sal_Int32 GetLineFromY( sal_Int32 nY ) const;
+
+ /** Returns the ruler cursor position. */
+ inline sal_Int32 GetRulerCursorPos() const { return mrData.mnPosCursor; }
+ /** Returns the data grid cursor position (not column index!). */
+ inline sal_Int32 GetGridCursorPos() const { return mrData.mnColCursor; }
+
+ // static helpers ---------------------------------------------------------
+
+ /** Inverts a rectangle in the specified output device. */
+ static void ImplInvertRect( OutputDevice& rOutDev, const Rectangle& rRect );
+
+ /** Returns direction code for the keys LEFT, RIGHT, HOME, END.
+ @param bHomeEnd false = ignore HOME and END key. */
+ static ScMoveMode GetHorzDirection( sal_uInt16 nCode, bool bHomeEnd );
+ /** Returns direction code for the keys UP, DOWN, HOME, END, PAGE UP, PAGE DOWN.
+ @param bHomeEnd false = ignore HOME and END key. */
+ static ScMoveMode GetVertDirection( sal_uInt16 nCode, bool bHomeEnd );
+
+ // accessibility ----------------------------------------------------------
+public:
+ /** Creates and returns the accessible object of this control. Do not overwrite in
+ derived classes, use ImplCreateAccessible() instead. */
+ virtual XAccessibleRef CreateAccessible();
+
+protected:
+ /** Derived classes create a new accessible object here. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible() = 0;
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/csvgrid.hxx b/sc/source/ui/inc/csvgrid.hxx
new file mode 100644
index 000000000000..7b6e8d76e4bf
--- /dev/null
+++ b/sc/source/ui/inc/csvgrid.hxx
@@ -0,0 +1,360 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_CSVGRID_HXX
+#define _SC_CSVGRID_HXX
+
+#include <vcl/virdev.hxx>
+#include <vcl/menu.hxx>
+#include <unotools/options.hxx>
+
+#include <vector>
+#include <memory>
+#include "scdllapi.h"
+#include "csvcontrol.hxx"
+#include "csvsplits.hxx"
+
+
+// ----------------------------------------------------------------------------
+
+namespace svtools { class ColorConfig; }
+class EditEngine;
+class ScEditEngineDefaulter;
+class ScAsciiOptions;
+class ScAccessibleCsvControl;
+
+
+// ============================================================================
+
+const sal_uInt8 CSV_COLFLAG_NONE = 0x00; /// Nothing set.
+const sal_uInt8 CSV_COLFLAG_SELECT = 0x01; /// Column is selected.
+
+const sal_uInt32 CSV_COLUMN_INVALID = CSV_VEC_NOTFOUND;
+
+
+// ----------------------------------------------------------------------------
+
+/** This struct contains the state of one table column. */
+struct ScCsvColState
+{
+ sal_Int32 mnType; /// Data type.
+ sal_uInt8 mnFlags; /// Flags (i.e. selection state).
+
+ inline explicit ScCsvColState(
+ sal_Int32 nType = CSV_TYPE_DEFAULT,
+ sal_uInt8 nFlags = CSV_COLFLAG_NONE ) :
+ mnType( nType ), mnFlags( nFlags ) {}
+
+ inline bool IsSelected() const;
+ inline void Select( bool bSel );
+};
+
+inline bool ScCsvColState::IsSelected() const
+{
+ return (mnFlags & CSV_COLFLAG_SELECT) != 0;
+}
+
+inline void ScCsvColState::Select( bool bSel )
+{
+ if( bSel ) mnFlags |= CSV_COLFLAG_SELECT; else mnFlags &= ~CSV_COLFLAG_SELECT;
+}
+
+
+// ----------------------------------------------------------------------------
+
+typedef ::std::vector< ScCsvColState > ScCsvColStateVec;
+
+
+// ============================================================================
+
+/** A data grid control for the CSV import dialog. The design of this control
+ simulates a Calc spreadsheet with row and column headers. */
+class SC_DLLPUBLIC ScCsvGrid : public ScCsvControl, public utl::ConfigurationListener
+{
+private:
+ typedef ::std::auto_ptr< ScEditEngineDefaulter > ScEditEnginePtr;
+
+ VirtualDevice maBackgrDev; /// Grid background, headers, cell texts.
+ VirtualDevice maGridDev; /// Data grid with selection and cursor.
+ PopupMenu maPopup; /// Popup menu for column types.
+
+ ::svtools::ColorConfig& mrColorConfig; /// Application color configuration.
+ Color maBackColor; /// Cell background color.
+ Color maGridColor; /// Table grid color.
+ Color maGridPBColor; /// Grid color for "first imported line" delimiter.
+ Color maAppBackColor; /// Background color for unused area.
+ Color maTextColor; /// Text color for data area.
+ Color maHeaderBackColor; /// Background color for headers.
+ Color maHeaderGridColor; /// Grid color for headers.
+ Color maHeaderTextColor; /// Text color for headers.
+ Color maSelectColor; /// Header color of selected columns.
+
+ ScEditEnginePtr mpEditEngine; /// For drawing cell texts.
+ Font maHeaderFont; /// Font for column and row headers.
+ Font maMonoFont; /// Monospace font for data cells.
+ Size maWinSize; /// Size of the control.
+ Size maEdEngSize; /// Paper size for edit engine.
+
+ ScCsvSplits maSplits; /// Vector with split positions.
+ ScCsvColStateVec maColStates; /// State of each column.
+ StringVec maTypeNames; /// UI names of data types.
+ StringVecVec maTexts; /// 2D-vector for cell texts.
+
+ sal_Int32 mnFirstImpLine; /// First imported line (0-based).
+ sal_uInt32 mnRecentSelCol; /// Index of most recently selected column.
+ sal_uInt32 mnMTCurrCol; /// Current column of mouse tracking.
+ bool mbMTSelecting; /// Mouse tracking: true = select, false = deselect.
+
+ // ------------------------------------------------------------------------
+public:
+ explicit ScCsvGrid( ScCsvControl& rParent );
+ virtual ~ScCsvGrid();
+
+ // common grid handling ---------------------------------------------------
+public:
+ /** Updates layout data dependent from the control's state. */
+ void UpdateLayoutData();
+ /** Updates X coordinate of first visible position dependent from line numbers. */
+ void UpdateOffsetX();
+ /** Apply current layout data to the grid control. */
+ void ApplyLayout( const ScCsvLayoutData& rOldData );
+ /** Sets the number of the first imported line (for visual feedback). nLine is 0-based! */
+ void SetFirstImportedLine( sal_Int32 nLine );
+
+ /** Finds a column position nearest to nPos which does not cause scrolling the visible area. */
+ sal_Int32 GetNoScrollCol( sal_Int32 nPos ) const;
+
+private:
+ /** Reads colors from system settings. */
+ SC_DLLPRIVATE void InitColors();
+ /** Initializes all font settings. */
+ SC_DLLPRIVATE void InitFonts();
+ /** Initializes all data dependent from the control's size. */
+ SC_DLLPRIVATE void InitSizeData();
+
+ // split handling ---------------------------------------------------------
+public:
+ /** Inserts a split. */
+ void InsertSplit( sal_Int32 nPos );
+ /** Removes a split. */
+ void RemoveSplit( sal_Int32 nPos );
+ /** Inserts a new or removes an existing split. */
+ void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos );
+ /** Removes all splits. */
+ void RemoveAllSplits();
+ /** Removes all splits and inserts the splits from rSplits. */
+ void SetSplits( const ScCsvSplits& rSplits );
+
+private:
+ /** Inserts a split and adjusts column data. */
+ SC_DLLPRIVATE bool ImplInsertSplit( sal_Int32 nPos );
+ /** Removes a split and adjusts column data. */
+ SC_DLLPRIVATE bool ImplRemoveSplit( sal_Int32 nPos );
+ /** Clears the split array and re-inserts boundary splits. */
+ SC_DLLPRIVATE void ImplClearSplits();
+
+ // columns/column types ---------------------------------------------------
+public:
+ /** Returns the number of columns. */
+ inline sal_uInt32 GetColumnCount() const { return maColStates.size(); }
+ /** Returns the index of the first visible column. */
+ sal_uInt32 GetFirstVisColumn() const;
+ /** Returns the index of the last visible column. */
+ sal_uInt32 GetLastVisColumn() const;
+
+ /** Returns true, if nColIndex points to an existing column. */
+ bool IsValidColumn( sal_uInt32 nColIndex ) const;
+ /** Returns true, if column with index nColIndex is (at least partly) visible. */
+ bool IsVisibleColumn( sal_uInt32 nColIndex ) const;
+
+ /** Returns X coordinate of the specified column. */
+ sal_Int32 GetColumnX( sal_uInt32 nColIndex ) const;
+ /** Returns column index from output coordinate. */
+ sal_uInt32 GetColumnFromX( sal_Int32 nX ) const;
+
+ /** Returns start position of the column with the specified index. */
+ inline sal_Int32 GetColumnPos( sal_uInt32 nColIndex ) const { return maSplits[ nColIndex ]; }
+ /** Returns column index from position. A split counts to its following column. */
+ sal_uInt32 GetColumnFromPos( sal_Int32 nPos ) const;
+ /** Returns the character width of the column with the specified index. */
+ sal_Int32 GetColumnWidth( sal_uInt32 nColIndex ) const;
+
+ /** Returns the vector with the states of all columns. */
+ inline const ScCsvColStateVec& GetColumnStates() const { return maColStates; }
+ /** Sets all column states to the values in the passed vector. */
+ void SetColumnStates( const ScCsvColStateVec& rColStates );
+ /** Returns the data type of the selected columns. */
+ sal_Int32 GetSelColumnType() const;
+ /** Changes the data type of all selected columns. */
+ void SetSelColumnType( sal_Int32 nType );
+ /** Sets new UI data type names. */
+ void SetTypeNames( const StringVec& rTypeNames );
+ /** Returns the UI type name of the specified column. */
+ const String& GetColumnTypeName( sal_uInt32 nColIndex ) const;
+
+ /** Fills the options object with column data for separators mode. */
+ void FillColumnDataSep( ScAsciiOptions& rOptions ) const;
+ /** Fills the options object with column data for fixed width mode. */
+ void FillColumnDataFix( ScAsciiOptions& rOptions ) const;
+
+private:
+ /** Returns the data type of the specified column. */
+ SC_DLLPRIVATE sal_Int32 GetColumnType( sal_uInt32 nColIndex ) const;
+ /** Returns the data type of the specified column. */
+ SC_DLLPRIVATE void SetColumnType( sal_uInt32 nColIndex, sal_Int32 nColType );
+
+ /** Scrolls data grid vertically. */
+ SC_DLLPRIVATE void ScrollVertRel( ScMoveMode eDir );
+ /** Executes the data type popup menu. */
+ SC_DLLPRIVATE void ExecutePopup( const Point& rPos );
+
+ // selection handling -----------------------------------------------------
+public:
+ /** Returns true, if the specified column is selected. */
+ bool IsSelected( sal_uInt32 nColIndex ) const;
+ /** Returns index of the first selected column. */
+ sal_uInt32 GetFirstSelected() const;
+ /** Returns index of the first selected column really after nFromIndex. */
+ sal_uInt32 GetNextSelected( sal_uInt32 nFromIndex ) const;
+ /** Returns true, if at least one column is selected. */
+ inline bool HasSelection() const { return GetFirstSelected() != CSV_COLUMN_INVALID; }
+
+ /** Selects or deselects the specified column. */
+ void Select( sal_uInt32 nColIndex, bool bSelect = true );
+ /** Toggles selection of the specified column. */
+ void ToggleSelect( sal_uInt32 nColIndex );
+ /** Selects or deselects the specified column range. */
+ void SelectRange( sal_uInt32 nColIndex1, sal_uInt32 nColIndex2, bool bSelect = true );
+ /** Selects or deselects all columns. */
+ void SelectAll( bool bSelect = true );
+
+ /** Returns index of the focused column. */
+ inline sal_uInt32 GetFocusColumn() const { return GetColumnFromPos( GetGridCursorPos() ); }
+
+private:
+ /** Moves column cursor to a new position. */
+ SC_DLLPRIVATE void MoveCursor( sal_uInt32 nColIndex );
+ /** Moves column cursor to the given direction. */
+ SC_DLLPRIVATE void MoveCursorRel( ScMoveMode eDir );
+
+ /** Clears the entire selection without notify. */
+ SC_DLLPRIVATE void ImplClearSelection();
+
+ /** Executes selection action for a specific column. */
+ SC_DLLPRIVATE void DoSelectAction( sal_uInt32 nColIndex, sal_uInt16 nModifier );
+
+ // cell contents ----------------------------------------------------------
+public:
+ /** Fills all cells of a line with the passed text (separators mode). */
+ void ImplSetTextLineSep(
+ sal_Int32 nLine, const String& rTextLine,
+ const String& rSepChars, sal_Unicode cTextSep, bool bMergeSep );
+ /** Fills all cells of a line with the passed text (fixed width mode). */
+ void ImplSetTextLineFix( sal_Int32 nLine, const String& rTextLine );
+
+ /** Returns the text of the specified cell. */
+ const String& GetCellText( sal_uInt32 nColIndex, sal_Int32 nLine ) const;
+
+ // event handling ---------------------------------------------------------
+protected:
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual void ConfigurationChanged( ::utl::ConfigurationBroadcaster*, sal_uInt32 );
+
+ // painting ---------------------------------------------------------------
+protected:
+ virtual void Paint( const Rectangle& );
+
+public:
+ /** Redraws the entire data grid. */
+ void ImplRedraw();
+ /** Returns a pointer to the used edit engine. */
+ EditEngine* GetEditEngine();
+
+private:
+ /** Returns the width of the control. */
+ inline sal_Int32 GetWidth() const { return maWinSize.Width(); }
+ /** Returns the height of the control. */
+ inline sal_Int32 GetHeight() const { return maWinSize.Height(); }
+
+ /** Sets a clip region in the specified output device for the specified column. */
+ SC_DLLPRIVATE void ImplSetColumnClipRegion( OutputDevice& rOutDev, sal_uInt32 nColIndex );
+ /** Draws the header of the specified column to the specified output device. */
+ SC_DLLPRIVATE void ImplDrawColumnHeader( OutputDevice& rOutDev, sal_uInt32 nColIndex, Color aFillColor );
+
+ /** Draws the text at the specified position to maBackgrDev. */
+ SC_DLLPRIVATE void ImplDrawCellText( const Point& rPos, const String& rText );
+ /** Draws the "first imported line" separator to maBackgrDev (or erases, if bSet is false). */
+ SC_DLLPRIVATE void ImplDrawFirstLineSep( bool bSet );
+ /** Draws the column with index nColIndex to maBackgrDev. */
+ SC_DLLPRIVATE void ImplDrawColumnBackgr( sal_uInt32 nColIndex );
+ /** Draws the row headers column to maBackgrDev. */
+ SC_DLLPRIVATE void ImplDrawRowHeaders();
+ /** Draws all columns and the row headers column to maBackgrDev. */
+ SC_DLLPRIVATE void ImplDrawBackgrDev();
+
+ /** Draws the column with index nColIndex with its selection state to maGridDev. */
+ SC_DLLPRIVATE void ImplDrawColumnSelection( sal_uInt32 nColIndex );
+ /** Draws all columns with selection and cursor to maGridDev. */
+ SC_DLLPRIVATE void ImplDrawGridDev();
+
+ /** Redraws the entire column (background and selection). */
+ SC_DLLPRIVATE void ImplDrawColumn( sal_uInt32 nColIndex );
+
+ /** Optimized drawing: Scrolls horizontally and redraws only missing parts. */
+ SC_DLLPRIVATE void ImplDrawHorzScrolled( sal_Int32 nOldPos );
+
+ /** Inverts the cursor bar at the specified position in maGridDev. */
+ SC_DLLPRIVATE void ImplInvertCursor( sal_Int32 nPos );
+
+ /** Draws directly tracking rectangle to the column with the specified index. */
+ SC_DLLPRIVATE void ImplDrawTrackingRect( sal_uInt32 nColIndex );
+
+ // accessibility ----------------------------------------------------------
+protected:
+ /** Creates a new accessible object. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible();
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/csvruler.hxx b/sc/source/ui/inc/csvruler.hxx
new file mode 100644
index 000000000000..0ffd095ede86
--- /dev/null
+++ b/sc/source/ui/inc/csvruler.hxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_CSVRULER_HXX
+#define _SC_CSVRULER_HXX
+
+#include <vcl/virdev.hxx>
+#include "csvcontrol.hxx"
+#include "csvsplits.hxx"
+#include "scdllapi.h"
+
+class ScAccessibleCsvControl;
+
+
+// ============================================================================
+
+/** A ruler control for the CSV import dialog. Supports setting and moving
+ splits (which divide lines of data into several columns). */
+class SC_DLLPUBLIC ScCsvRuler : public ScCsvControl
+{
+private:
+ VirtualDevice maBackgrDev; /// Ruler background, scaling.
+ VirtualDevice maRulerDev; /// Ruler with splits and cursor.
+
+ Color maBackColor; /// Background color.
+ Color maActiveColor; /// Color for active part of ruler.
+ Color maTextColor; /// Text and scale color.
+ Color maSplitColor; /// Split area color.
+
+ ScCsvSplits maSplits; /// Vector with split positions.
+ ScCsvSplits maOldSplits; /// Old state for cancellation.
+
+ sal_Int32 mnPosCursorLast; /// Last valid position of cursor.
+ sal_Int32 mnPosMTStart; /// Start position of mouse tracking.
+ sal_Int32 mnPosMTCurr; /// Current position of mouse tracking.
+ bool mbPosMTMoved; /// Tracking: Anytime moved to another position?
+
+ Size maWinSize; /// Size of the control.
+ Rectangle maActiveRect; /// The active area of the ruler.
+ sal_Int32 mnSplitSize; /// Size of a split circle.
+
+ // ------------------------------------------------------------------------
+public:
+ explicit ScCsvRuler( ScCsvControl& rParent );
+ ~ScCsvRuler();
+
+ // common ruler handling --------------------------------------------------
+public:
+ using Window::SetPosSizePixel;
+ /** Sets position and size of the ruler. The height is calculated internally. */
+ virtual void SetPosSizePixel(
+ long nX, long nY,
+ long nWidth, long nHeight,
+ USHORT nFlags = WINDOW_POSSIZE_ALL );
+
+ /** Apply current layout data to the ruler. */
+ void ApplyLayout( const ScCsvLayoutData& rOldData );
+
+private:
+ /** Reads colors from system settings. */
+ SC_DLLPRIVATE void InitColors();
+ /** Initializes all data dependent from the control's size. */
+ SC_DLLPRIVATE void InitSizeData();
+
+ /** Moves cursor to a new position.
+ @param bScroll TRUE = The method may scroll the ruler. */
+ SC_DLLPRIVATE void MoveCursor( sal_Int32 nPos, bool bScroll = true );
+ /** Moves cursor to the given direction. */
+ SC_DLLPRIVATE void MoveCursorRel( ScMoveMode eDir );
+ /** Sets cursor to an existing split, according to eDir. */
+ SC_DLLPRIVATE void MoveCursorToSplit( ScMoveMode eDir );
+ /** Scrolls data grid vertically. */
+ SC_DLLPRIVATE void ScrollVertRel( ScMoveMode eDir );
+
+ // split handling ---------------------------------------------------------
+public:
+ /** Returns the split array. */
+ inline const ScCsvSplits& GetSplits() const { return maSplits; }
+ /** Returns the number of splits. */
+ inline sal_uInt32 GetSplitCount() const
+ { return maSplits.Count(); }
+ /** Returns the position of the specified split. */
+ inline sal_Int32 GetSplitPos( sal_uInt32 nIndex ) const
+ { return maSplits[ nIndex ]; }
+ /** Finds a position nearest to nPos which does not cause scrolling the visible area. */
+ sal_Int32 GetNoScrollPos( sal_Int32 nPos ) const;
+
+ /** Returns true if at position nPos is a split. */
+ inline bool HasSplit( sal_Int32 nPos ) const { return maSplits.HasSplit( nPos ); }
+ /** Inserts a split. */
+ void InsertSplit( sal_Int32 nPos );
+ /** Removes a split. */
+ void RemoveSplit( sal_Int32 nPos );
+ /** Moves a split from nPos to nNewPos. */
+ void MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos );
+ /** Removes all splits of the ruler. */
+ void RemoveAllSplits();
+
+private:
+ /** Finds next position without a split. */
+ SC_DLLPRIVATE sal_Int32 FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
+
+ /** Moves split and cursor to nNewPos and commits event. */
+ SC_DLLPRIVATE void MoveCurrSplit( sal_Int32 nNewPos );
+ /** Moves split and cursor to the given direction and commits event. */
+ SC_DLLPRIVATE void MoveCurrSplitRel( ScMoveMode eDir );
+
+ // event handling ---------------------------------------------------------
+protected:
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+private:
+ /** Starts tracking at the specified position. */
+ SC_DLLPRIVATE void StartMouseTracking( sal_Int32 nPos );
+ /** Moves tracking to a new position. */
+ SC_DLLPRIVATE void MoveMouseTracking( sal_Int32 nPos );
+ /** Applies tracking action for the current tracking position.
+ @param bApply TRUE = apply action, FALSE = cancel action. */
+ SC_DLLPRIVATE void EndMouseTracking( bool bApply );
+
+ // painting ---------------------------------------------------------------
+protected:
+ virtual void Paint( const Rectangle& );
+
+public:
+ /** Redraws the entire ruler. */
+ void ImplRedraw();
+
+private:
+ /** Returns the width of the control. */
+ inline sal_Int32 GetWidth() const { return maWinSize.Width(); }
+ /** Returns the height of the control. */
+ inline sal_Int32 GetHeight() const { return maWinSize.Height(); }
+
+ /** Draws the background and active area to maBackgrDev (only the given X range). */
+ SC_DLLPRIVATE void ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth );
+ /** Draws the entire ruler background with scaling to maBackgrDev. */
+ SC_DLLPRIVATE void ImplDrawBackgrDev();
+
+ /** Draws a split to maRulerDev. */
+ SC_DLLPRIVATE void ImplDrawSplit( sal_Int32 nPos );
+ /** Erases a split from maRulerDev. */
+ SC_DLLPRIVATE void ImplEraseSplit( sal_Int32 nPos );
+ /** Draws the ruler background, all splits and the cursor to maRulerDev. */
+ SC_DLLPRIVATE void ImplDrawRulerDev();
+
+ /** Inverts the cursor bar at the specified position in maRulerDev. */
+ SC_DLLPRIVATE void ImplInvertCursor( sal_Int32 nPos );
+ /** Draws directly tracking rectangle to the column with the specified index. */
+ SC_DLLPRIVATE void ImplDrawTrackingRect();
+
+ /** Sets arrow or horizontal split pointer. */
+ SC_DLLPRIVATE void ImplSetMousePointer( sal_Int32 nPos );
+
+ // accessibility ----------------------------------------------------------
+protected:
+ /** Creates a new accessible object. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible();
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/csvsplits.hxx b/sc/source/ui/inc/csvsplits.hxx
new file mode 100644
index 000000000000..7c7c48ea9db5
--- /dev/null
+++ b/sc/source/ui/inc/csvsplits.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_CSVSPLITS_HXX
+#define _SC_CSVSPLITS_HXX
+
+#include <sal/types.h>
+
+#include <vector>
+
+
+// ============================================================================
+
+/** Constant for an invalid vector index. */
+const sal_uInt32 CSV_VEC_NOTFOUND = SAL_MAX_UINT32;
+/** Constant for an invalid ruler position. */
+const sal_Int32 CSV_POS_INVALID = -1;
+
+
+// ----------------------------------------------------------------------------
+
+/** A vector of column splits that supports inserting, removing and moving splits. */
+class ScCsvSplits
+{
+private:
+ typedef ::std::vector< sal_Int32 > ScSplitVector;
+ typedef ScSplitVector::iterator iterator;
+ typedef ScSplitVector::const_iterator const_iterator;
+
+ ScSplitVector maVec; /// The split containter.
+
+public:
+ // *** access by position *** ---------------------------------------------
+
+ /** Inserts a new split at position nPos into the vector.
+ @return true = split inserted (nPos was valid and empty). */
+ bool Insert( sal_Int32 nPos );
+ /** Removes a split by position.
+ @return true = split found and removed. */
+ bool Remove( sal_Int32 nPos );
+ /** Removes a range of splits in the given position range. */
+ void RemoveRange( sal_Int32 nPosStart, sal_Int32 nPosEnd );
+ /** Removes all elements from the vector. */
+ void Clear();
+
+ /** Returns true if at position nPos is a split. */
+ bool HasSplit( sal_Int32 nPos ) const;
+
+ // *** access by index *** ------------------------------------------------
+
+ /** Searches for a split at position nPos.
+ @return the vector index of the split. */
+ sal_uInt32 GetIndex( sal_Int32 nPos ) const;
+ /** Returns index of the first split greater than or equal to nPos. */
+ sal_uInt32 LowerBound( sal_Int32 nPos ) const;
+ /** Returns index of the last split less than or equal to nPos. */
+ sal_uInt32 UpperBound( sal_Int32 nPos ) const;
+
+ /** Returns the number of splits. */
+ inline sal_uInt32 Count() const
+ { return maVec.size(); }
+ /** Returns the position of the specified split. */
+ sal_Int32 GetPos( sal_uInt32 nIndex ) const;
+ /** Returns the position of the specified split. */
+ inline sal_Int32 operator[]( sal_uInt32 nIndex ) const
+ { return GetPos( nIndex ); }
+
+private:
+ /** Returns the vector index of an iterator. */
+ sal_uInt32 GetIterIndex( const_iterator aIter ) const;
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/csvtablebox.hxx b/sc/source/ui/inc/csvtablebox.hxx
new file mode 100644
index 000000000000..b944bef0c909
--- /dev/null
+++ b/sc/source/ui/inc/csvtablebox.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef _SC_CSVTABLEBOX_HXX
+#define _SC_CSVTABLEBOX_HXX
+
+#include <vcl/ctrl.hxx>
+#include <vcl/scrbar.hxx>
+#include "scdllapi.h"
+#include "csvcontrol.hxx"
+#include "csvruler.hxx"
+#include "csvgrid.hxx"
+
+
+class ListBox;
+class ScAsciiOptions;
+
+
+/* ============================================================================
+Position: Positions between the characters (the dots in the ruler).
+Character: The characters (the range from one position to the next).
+Split: Positions which contain a split to divide characters into groups (columns).
+Column: The range between two splits.
+============================================================================ */
+
+/** The control in the CSV import dialog that contains a ruler and a data grid
+ to visualize and modify the current import settings. */
+class SC_DLLPUBLIC ScCsvTableBox : public ScCsvControl
+{
+private:
+ ScCsvLayoutData maData; /// Current layout data of the controls.
+
+ ScCsvRuler maRuler; /// The ruler for fixed width mode.
+ ScCsvGrid maGrid; /// Calc-like data table for fixed width mode.
+ ScrollBar maHScroll; /// Horizontal scroll bar.
+ ScrollBar maVScroll; /// Vertical scroll bar.
+ ScrollBarBox maScrollBox; /// For the bottom right edge.
+
+ Link maUpdateTextHdl; /// Updates all cell texts.
+ Link maColTypeHdl; /// Handler for exporting the column type.
+
+ ScCsvColStateVec maFixColStates; /// Column states in fixed width mode.
+ ScCsvColStateVec maSepColStates; /// Column states in separators mode.
+
+ sal_Int32 mnFixedWidth; /// Cached total width for fixed width mode.
+
+ bool mbFixedMode; /// false = Separators, true = Fixed width.
+
+ // ------------------------------------------------------------------------
+public:
+ explicit ScCsvTableBox( Window* pParent, const ResId& rResId );
+
+ // common table box handling ----------------------------------------------
+public:
+ /** Sets the control to separators mode. */
+ void SetSeparatorsMode();
+ /** Sets the control to fixed width mode. */
+ void SetFixedWidthMode();
+
+private:
+ /** Initialisation on construction. */
+ SC_DLLPRIVATE void Init();
+ /** Initializes the children controls (pos/size, scroll bars, ...). */
+ SC_DLLPRIVATE void InitControls();
+ /** Initializes size and position data of horizontal scrollbar. */
+ SC_DLLPRIVATE void InitHScrollBar();
+ /** Initializes size and position data of vertical scrollbar. */
+ SC_DLLPRIVATE void InitVScrollBar();
+
+ /** Calculates and sets valid position offset nearest to nPos. */
+ SC_DLLPRIVATE inline void ImplSetPosOffset( sal_Int32 nPos )
+ { maData.mnPosOffset = Max( Min( nPos, GetMaxPosOffset() ), sal_Int32( 0 ) ); }
+ /** Calculates and sets valid line offset nearest to nLine. */
+ SC_DLLPRIVATE inline void ImplSetLineOffset( sal_Int32 nLine )
+ { maData.mnLineOffset = Max( Min( nLine, GetMaxLineOffset() ), sal_Int32( 0 ) ); }
+ /** Moves controls (not cursors!) so that nPos becomes visible. */
+ SC_DLLPRIVATE void MakePosVisible( sal_Int32 nPos );
+
+ // cell contents ----------------------------------------------------------
+public:
+ /** Fills all cells of all lines with the passed texts (Unicode strings). */
+ void SetUniStrings(
+ const String* pTextLines, const String& rSepChars,
+ sal_Unicode cTextSep, bool bMergeSep );
+
+ // column settings --------------------------------------------------------
+public:
+ /** Reads UI strings for data types from the list box. */
+ void InitTypes( const ListBox& rListBox );
+ /** Returns the data type of the selected columns. */
+ inline sal_Int32 GetSelColumnType() const { return maGrid.GetSelColumnType(); }
+
+ /** Fills the options object with current column data. */
+ void FillColumnData( ScAsciiOptions& rOptions ) const;
+
+ // event handling ---------------------------------------------------------
+public:
+ /** Sets a new handler for "update cell texts" requests. */
+ inline void SetUpdateTextHdl( const Link& rHdl ) { maUpdateTextHdl = rHdl; }
+ /** Returns the handler for "update cell texts" requests. */
+ inline const Link& GetUpdateTextHdl() const { return maUpdateTextHdl; }
+ /** Sets a new handler for "column selection changed" events. */
+ inline void SetColTypeHdl( const Link& rHdl ) { maColTypeHdl = rHdl; }
+ /** Returns the handler for "column selection changed" events. */
+ inline const Link& GetColTypeHdl() const { return maColTypeHdl; }
+
+protected:
+ virtual void Resize();
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+private:
+ SC_DLLPRIVATE DECL_LINK( CsvCmdHdl, ScCsvControl* );
+ SC_DLLPRIVATE DECL_LINK( ScrollHdl, ScrollBar* );
+ SC_DLLPRIVATE DECL_LINK( ScrollEndHdl, ScrollBar* );
+
+ // accessibility ----------------------------------------------------------
+public:
+ /** Creates and returns the accessible object of this control. */
+ virtual XAccessibleRef CreateAccessible();
+
+protected:
+ /** Creates a new accessible object. */
+ virtual ScAccessibleCsvControl* ImplCreateAccessible();
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dapidata.hxx b/sc/source/ui/inc/dapidata.hxx
new file mode 100644
index 000000000000..5da8703ed08a
--- /dev/null
+++ b/sc/source/ui/inc/dapidata.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DAPIDATA_HXX
+#define SC_DAPIDATA_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+
+//------------------------------------------------------------------------
+
+struct ScImportSourceDesc;
+
+
+class ScDataPilotDatabaseDlg : public ModalDialog
+{
+private:
+ FixedLine aFlFrame;
+ FixedText aFtDatabase;
+ ListBox aLbDatabase;
+ FixedText aFtObject;
+ ComboBox aCbObject;
+ FixedText aFtType;
+ ListBox aLbType;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ void FillObjects();
+
+ DECL_LINK( SelectHdl, ListBox* );
+
+public:
+ ScDataPilotDatabaseDlg( Window* pParent );
+ ~ScDataPilotDatabaseDlg();
+
+ void GetValues( ScImportSourceDesc& rDesc );
+};
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dapitype.hxx b/sc/source/ui/inc/dapitype.hxx
new file mode 100644
index 000000000000..5d483cb560e9
--- /dev/null
+++ b/sc/source/ui/inc/dapitype.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DAPITYPE_HXX
+#define SC_DAPITYPE_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+//------------------------------------------------------------------------
+
+class ScDataPilotSourceTypeDlg : public ModalDialog
+{
+private:
+ FixedLine aFlFrame;
+ RadioButton aBtnSelection;
+ RadioButton aBtnDatabase;
+ RadioButton aBtnExternal;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+public:
+ ScDataPilotSourceTypeDlg( Window* pParent, BOOL bEnableExternal );
+ ~ScDataPilotSourceTypeDlg();
+
+ BOOL IsDatabase() const;
+ BOOL IsExternal() const;
+};
+
+
+class ScDataPilotServiceDlg : public ModalDialog
+{
+private:
+ FixedLine aFlFrame;
+ FixedText aFtService;
+ ListBox aLbService;
+ FixedText aFtSource;
+ Edit aEdSource;
+ FixedText aFtName;
+ Edit aEdName;
+ FixedText aFtUser;
+ Edit aEdUser;
+ FixedText aFtPasswd;
+ Edit aEdPasswd;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+public:
+ ScDataPilotServiceDlg( Window* pParent,
+ const com::sun::star::uno::Sequence<rtl::OUString>& rServices );
+ ~ScDataPilotServiceDlg();
+
+ String GetServiceName() const;
+ String GetParSource() const;
+ String GetParName() const;
+ String GetParUser() const;
+ String GetParPass() const;
+};
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/datafdlg.hrc b/sc/source/ui/inc/datafdlg.hrc
new file mode 100644
index 000000000000..b32e0a9a267f
--- /dev/null
+++ b/sc/source/ui/inc/datafdlg.hrc
@@ -0,0 +1,42 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Amelia Wang <amwang@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "sc.hrc" // -> RID_SCDLG_DATAFORM
+
+//dataform
+#define BTN_DATAFORM_NEW 1001
+#define BTN_DATAFORM_DELETE 1002
+#define BTN_DATAFORM_RESTORE 1003
+#define BTN_DATAFORM_LAST 1004
+#define BTN_DATAFORM_NEXT 1005
+#define BTN_DATAFORM_CLOSE 1007
+#define WND_DATAFORM_SCROLLBAR 1008
+#define LAB_DATAFORM_RECORDNO 1009
+
+#define FT_DATAFORM_FIXEDTEXT1 2001
+#define ED_DATAFORM_EDIT1 2002
+
+#define STR_NEW_RECORD 2003
diff --git a/sc/source/ui/inc/datafdlg.hxx b/sc/source/ui/inc/datafdlg.hxx
new file mode 100644
index 000000000000..46cdd9a3e2c5
--- /dev/null
+++ b/sc/source/ui/inc/datafdlg.hxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Amelia Wang <amwang@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef SC_DATAFDLG_HXX
+#define SC_DATAFDLG_HXX
+
+
+#ifndef _SV_DIALOG_HXX //autogen
+#include <vcl/dialog.hxx>
+#endif
+
+#ifndef _SV_BUTTON_HXX //autogen
+#include <vcl/imagebtn.hxx>
+#endif
+
+#ifndef _SV_FIXED_HXX //autogen
+#include <vcl/fixed.hxx>
+#endif
+
+
+#include "global.hxx"
+
+#include <tabvwsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+#define MAX_DATAFORM_COLS 256
+#define MAX_DATAFORM_ROWS 32000
+#define CTRL_HEIGHT 22
+#define FIXED_WIDTH 60
+#define EDIT_WIDTH 140
+#define FIXED_LEFT 12
+#define EDIT_LEFT 78
+#define LINE_HEIGHT 30
+
+//zhangyun
+class ScDataFormDlg : public ModalDialog
+{
+private:
+
+ PushButton aBtnNew;
+ PushButton aBtnDelete;
+ PushButton aBtnRestore;
+ PushButton aBtnLast;
+ PushButton aBtnNext;
+ PushButton aBtnClose;
+ ScrollBar aSlider;
+ FixedText aFixedText;
+ //FixedText aFixedText1;
+ //Edit aEdit1;
+
+ ScTabViewShell* pTabViewShell;
+ ScDocument* pDoc;
+ sal_uInt16 aColLength;
+ SCROW aCurrentRow;
+ SCCOL nStartCol;
+ SCCOL nEndCol;
+ SCROW nStartRow;
+ SCROW nEndRow;
+ SCTAB nTab;
+ BOOL bNoSelection;
+
+ FixedText** pFixedTexts;
+ Edit** pEdits;
+
+public:
+ ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShell);
+ ~ScDataFormDlg();
+
+ void FillCtrls(SCROW nCurrentRow);
+private:
+
+ void SetButtonState();
+
+ // Handler:
+ DECL_LINK( Impl_NewHdl, PushButton* );
+ DECL_LINK( Impl_LastHdl, PushButton* );
+ DECL_LINK( Impl_NextHdl, PushButton* );
+
+ DECL_LINK( Impl_RestoreHdl, PushButton* );
+ DECL_LINK( Impl_DeleteHdl, PushButton* );
+ DECL_LINK( Impl_CloseHdl, PushButton* );
+
+ DECL_LINK( Impl_ScrollHdl, ScrollBar* );
+ DECL_LINK( Impl_DataModifyHdl, Edit* );
+};
+#endif // SC_DATAFDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx
new file mode 100644
index 000000000000..97cc632e37ef
--- /dev/null
+++ b/sc/source/ui/inc/dbdocfun.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DBDOCFUN_HXX
+#define SC_DBDOCFUN_HXX
+
+#include "address.hxx"
+#include <tools/solar.h>
+#include <com/sun/star/uno/Sequence.hxx>
+
+class String;
+
+struct ScImportParam;
+struct ScQueryParam;
+struct ScSortParam;
+struct ScSubTotalParam;
+
+class SfxViewFrame;
+class SbaSelectionList;
+class ScDBData;
+class ScDocShell;
+class ScAddress;
+class ScRange;
+class ScDPObject;
+
+namespace com { namespace sun { namespace star {
+ namespace beans {
+ struct PropertyValue;
+ }
+ namespace sdbc {
+ class XResultSet;
+ }
+} } }
+
+// ---------------------------------------------------------------------------
+// -----------------------------------------------------------------
+class SbaSelectionList: public List , public SvRefBase
+{
+public:
+ SbaSelectionList():
+ List(CONTAINER_MAXBLOCKSIZE,100,100){}
+};
+
+SV_DECL_IMPL_REF(SbaSelectionList)
+
+
+class ScDBDocFunc
+{
+friend class ScDBFunc;
+
+private:
+ ScDocShell& rDocShell;
+
+public:
+ ScDBDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {}
+ ~ScDBDocFunc() {}
+
+ void UpdateImport( const String& rTarget, const String& rDBName,
+ const String& rTableName, const String& rStatement,
+ BOOL bNative, BYTE nType,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::sdbc::XResultSet >& xResultSet,
+ const SbaSelectionList* pSelection );
+
+ BOOL DoImport( SCTAB nTab, const ScImportParam& rParam,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::sdbc::XResultSet >& xResultSet,
+ const SbaSelectionList* pSelection, BOOL bRecord,
+ BOOL bAddrInsert = FALSE );
+
+ BOOL DoImportUno( const ScAddress& rPos,
+ const com::sun::star::uno::Sequence<
+ com::sun::star::beans::PropertyValue>& aArgs );
+
+ static void ShowInBeamer( const ScImportParam& rParam, SfxViewFrame* pFrame );
+
+ BOOL Sort( SCTAB nTab, const ScSortParam& rSortParam,
+ BOOL bRecord, BOOL bPaint, BOOL bApi );
+
+ SC_DLLPUBLIC BOOL Query( SCTAB nTab, const ScQueryParam& rQueryParam,
+ const ScRange* pAdvSource, BOOL bRecord, BOOL bApi );
+
+ BOOL DoSubTotals( SCTAB nTab, const ScSubTotalParam& rParam,
+ const ScSortParam* pForceNewSort,
+ BOOL bRecord, BOOL bApi );
+
+ BOOL AddDBRange( const String& rName, const ScRange& rRange, BOOL bApi );
+ BOOL DeleteDBRange( const String& rName, BOOL bApi );
+ BOOL RenameDBRange( const String& rOld, const String& rNew, BOOL bApi );
+ BOOL ModifyDBData( const ScDBData& rNewData, BOOL bApi ); // Name unveraendert
+
+ BOOL RepeatDB( const String& rDBName, BOOL bRecord, BOOL bApi );
+
+ BOOL DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewObj,
+ BOOL bRecord, BOOL bApi, BOOL bAllowMove = FALSE );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
new file mode 100644
index 000000000000..5054f1fa10c7
--- /dev/null
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DBFUNC_HXX
+#define SC_DBFUNC_HXX
+
+#include "viewfunc.hxx"
+
+namespace com { namespace sun { namespace star { namespace sheet {
+ struct DataPilotFieldFilter;
+}}}}
+
+struct ScSortParam;
+struct ScQueryParam;
+class ScDBData;
+class ScDBCollection;
+class ScDPObject;
+class ScDPSaveData;
+class ScStrCollection;
+struct ScDPNumGroupInfo;
+
+// ---------------------------------------------------------------------------
+
+class ScDBFunc : public ScViewFunc
+{
+private:
+ void GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension );
+
+public:
+ ScDBFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
+ virtual ~ScDBFunc();
+
+ // nur UISort wiederholt bei Bedarf die Teilergebnisse
+
+ void UISort( const ScSortParam& rSortParam,
+ BOOL bRecord = TRUE );
+
+ void Sort( const ScSortParam& rSortParam,
+ BOOL bRecord = TRUE, BOOL bPaint = TRUE );
+ SC_DLLPUBLIC void Query( const ScQueryParam& rQueryParam,
+ const ScRange* pAdvSource, BOOL bRecord );
+ void DoSubTotals( const ScSubTotalParam& rParam, BOOL bRecord = TRUE,
+ const ScSortParam* pForceNewSort = NULL );
+
+ void ToggleAutoFilter();
+ void HideAutoFilter();
+
+ void RepeatDB( BOOL bRecord = TRUE );
+
+ BOOL ImportData( const ScImportParam& rParam, BOOL bRecord = TRUE );
+
+ void GotoDBArea( const String& rDBName );
+
+ // DB-Bereich vom Cursor
+ ScDBData* GetDBData( BOOL bMarkArea = TRUE, ScGetDBMode eMode = SC_DB_MAKE, ScGetDBSelection eSel = SC_DBSEL_KEEP, bool bShrinkToData = false, bool bExpandRows = false );
+
+ void NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList );
+
+ void Consolidate( const ScConsolidateParam& rParam, BOOL bRecord = TRUE );
+
+ bool MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, BOOL bNewTable,
+ const ScDPObject& rSource, BOOL bApi = FALSE );
+ void DeletePivotTable();
+ // Wang Xu Ming -- 2009-6-17
+ // DataPilot Migration
+ ULONG RecalcPivotTable();
+ // End Comments
+ BOOL HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
+ BOOL HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo );
+ void GroupDataPilot();
+ void DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nParts );
+ void NumGroupDataPilot( const ScDPNumGroupInfo& rInfo );
+ void UngroupDataPilot();
+ void DataPilotInput( const ScAddress& rPos, const String& rString );
+
+ bool DataPilotSort( const ScAddress& rPos, bool bAscending, sal_uInt16* pUserListId = NULL );
+ BOOL DataPilotMove( const ScRange& rSource, const ScAddress& rDest );
+
+ BOOL HasSelectionForDrillDown( USHORT& rOrientation );
+ void SetDataPilotDetails( BOOL bShow, const String* pNewDimensionName = NULL );
+
+ void ShowDataPilotSourceData( ScDPObject& rDPObj,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::DataPilotFieldFilter >& rFilters );
+
+ void MakeOutline( BOOL bColumns, BOOL bRecord = TRUE );
+ void RemoveOutline( BOOL bColumns, BOOL bRecord = TRUE );
+ void RemoveAllOutlines( BOOL bRecord = TRUE );
+ void TestRemoveOutline( BOOL& rCol, BOOL& rRow );
+
+ void AutoOutline( BOOL bRecord = TRUE );
+
+ void SelectLevel( BOOL bColumns, USHORT nLevel,
+ BOOL bRecord = TRUE, BOOL bPaint = TRUE );
+ void ShowOutline( BOOL bColumns, USHORT nLevel, USHORT nEntry,
+ BOOL bRecord = TRUE, BOOL bPaint = TRUE );
+ void HideOutline( BOOL bColumns, USHORT nLevel, USHORT nEntry,
+ BOOL bRecord = TRUE, BOOL bPaint = TRUE );
+
+ void ShowMarkedOutlines( BOOL bRecord = TRUE );
+ void HideMarkedOutlines( BOOL bRecord = TRUE );
+ BOOL OutlinePossible(BOOL bHide);
+
+ void UpdateCharts(BOOL bAllCharts = FALSE); // Default: am Cursor
+
+ static USHORT DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, BOOL bAllCharts );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dbnamdlg.hrc b/sc/source/ui/inc/dbnamdlg.hrc
new file mode 100644
index 000000000000..8062656a10c5
--- /dev/null
+++ b/sc/source/ui/inc/dbnamdlg.hrc
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_DBNAMES
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_ADD 3
+#define BTN_REMOVE 4
+#define BTN_HELP 5
+#define FL_NAME 10
+#define ED_NAME 11
+#define FL_ASSIGN 12
+#define ED_DBAREA 13
+#define RB_DBAREA 14
+#define FL_OPTIONS 20
+#define BTN_HEADER 21
+#define BTN_SIZE 22
+#define BTN_FORMAT 23
+#define BTN_STRIPDATA 24
+#define FT_SOURCE 25
+#define FT_OPERATIONS 26
+#define STR_ADD 30
+#define STR_MODIFY 31
+#define STR_DB_INVALID 32
+#define BTN_MORE 33
+
diff --git a/sc/source/ui/inc/dbnamdlg.hxx b/sc/source/ui/inc/dbnamdlg.hxx
new file mode 100644
index 000000000000..816a4e5c2b8b
--- /dev/null
+++ b/sc/source/ui/inc/dbnamdlg.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DBNAMDLG_HXX
+#define SC_DBNAMDLG_HXX
+
+#include <vcl/combobox.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/morebtn.hxx>
+#include "anyrefdg.hxx"
+#include "dbcolect.hxx"
+#include "expftext.hxx"
+
+class ScViewData;
+class ScDocument;
+
+
+//============================================================================
+
+class ScDbNameDlg : public ScAnyRefDlg
+{
+public:
+ ScDbNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData );
+ ~ScDbNameDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+ virtual BOOL Close();
+
+private:
+ FixedLine aFlName;
+ ComboBox aEdName;
+
+ FixedLine aFlAssign;
+ formula::RefEdit aEdAssign;
+ formula::RefButton aRbAssign;
+
+ FixedLine aFlOptions;
+ CheckBox aBtnHeader;
+ CheckBox aBtnDoSize;
+ CheckBox aBtnKeepFmt;
+ CheckBox aBtnStripData;
+ ScExpandedFixedText aFTSource; //@18.09.97 erweiterter FixedText
+ FixedText aFTOperations;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ PushButton aBtnAdd;
+ PushButton aBtnRemove;
+ MoreButton aBtnMore;
+
+ BOOL bSaved;
+
+
+ const String aStrAdd; // "Hinzufuegen"
+ const String aStrModify; // "Aendern"
+ const String aStrNoName; // "unbenannt"
+ const String aStrInvalid;
+
+ String aStrSource;
+ String aStrOperations;
+
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ BOOL bRefInputMode;
+ ScAddress::Details aAddrDetails;
+
+ ScDBCollection aLocalDbCol;
+ ScRange theCurArea;
+ List aRemoveList;
+
+#ifdef _DBNAMDLG_CXX
+private:
+ void Init();
+ void UpdateNames();
+ void UpdateDBData( const String& rStrName );
+ void SetInfoStrings( const ScDBData* pDBData );
+
+ DECL_LINK( CancelBtnHdl, void * );
+ DECL_LINK( OkBtnHdl, void * );
+ DECL_LINK( AddBtnHdl, void * );
+ DECL_LINK( RemoveBtnHdl, void * );
+ DECL_LINK( NameModifyHdl, void * );
+ DECL_LINK( AssModifyHdl, void * );
+#endif
+};
+
+
+
+#endif // SC_DBNAMDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/delcldlg.hxx b/sc/source/ui/inc/delcldlg.hxx
new file mode 100644
index 000000000000..1bb78c3ec283
--- /dev/null
+++ b/sc/source/ui/inc/delcldlg.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DELCLDLG_HXX
+#define SC_DELCLDLG_HXX
+
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+
+
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+
+class ScDeleteCellDlg : public ModalDialog
+{
+private:
+ FixedLine aFlFrame;
+ RadioButton aBtnCellsUp;
+ RadioButton aBtnCellsLeft;
+ RadioButton aBtnDelRows;
+ RadioButton aBtnDelCols;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+
+public:
+ ScDeleteCellDlg( Window* pParent, BOOL bDisallowCellMove = FALSE );
+ ~ScDeleteCellDlg();
+
+ DelCellCmd GetDelCellCmd() const;
+};
+
+
+#endif // SC_DELCLDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/delcodlg.hxx b/sc/source/ui/inc/delcodlg.hxx
new file mode 100644
index 000000000000..3180cb3cea48
--- /dev/null
+++ b/sc/source/ui/inc/delcodlg.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DELCODLG_HXX
+#define SC_DELCODLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/imagebtn.hxx>
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+
+class ScDeleteContentsDlg : public ModalDialog
+{
+private:
+ FixedLine aFlFrame;
+ CheckBox aBtnDelAll;
+ CheckBox aBtnDelStrings;
+ CheckBox aBtnDelNumbers;
+ CheckBox aBtnDelDateTime;
+ CheckBox aBtnDelFormulas;
+ CheckBox aBtnDelNotes;
+ CheckBox aBtnDelAttrs;
+ CheckBox aBtnDelObjects;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ BOOL bObjectsDisabled;
+
+ static BOOL bPreviousAllCheck;
+ static USHORT nPreviousChecks;
+
+ void DisableChecks( BOOL bDelAllChecked = TRUE );
+ DECL_LINK( DelAllHdl, void * );
+
+public:
+ ScDeleteContentsDlg( Window* pParent,
+ USHORT nCheckDefaults = 0 );
+ ~ScDeleteContentsDlg();
+ void DisableObjects();
+
+ USHORT GetDelContentsCmdBits() const;
+};
+
+
+#endif // SC_DELCODLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
new file mode 100644
index 000000000000..422a716c3add
--- /dev/null
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -0,0 +1,199 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DOCFUNC_HXX
+#define SC_DOCFUNC_HXX
+
+#include <tools/link.hxx>
+#include "global.hxx"
+#include "formula/grammar.hxx"
+#include "tabbgcolor.hxx"
+#include "token.hxx"
+
+#include <vector>
+
+class ScEditEngineDefaulter;
+class SdrUndoAction;
+class ScAddress;
+class ScDocShell;
+class ScMarkData;
+class ScPatternAttr;
+class ScRange;
+class ScRangeList;
+class ScRangeName;
+class ScBaseCell;
+class ScTokenArray;
+struct ScTabOpParam;
+class ScTableProtection;
+struct ScCellMergeOption;
+
+// ---------------------------------------------------------------------------
+
+class ScDocFunc
+{
+private:
+ ScDocShell& rDocShell;
+
+ BOOL AdjustRowHeight( const ScRange& rRange, BOOL bPaint = TRUE );
+ void CreateOneName( ScRangeName& rList,
+ SCCOL nPosX, SCROW nPosY, SCTAB nTab,
+ SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ BOOL& rCancel, BOOL bApi );
+ void NotifyInputHandler( const ScAddress& rPos );
+
+public:
+ ScDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {}
+ ~ScDocFunc() {}
+
+ DECL_LINK( NotifyDrawUndo, SdrUndoAction* );
+
+ BOOL DetectiveAddPred(const ScAddress& rPos);
+ BOOL DetectiveDelPred(const ScAddress& rPos);
+ BOOL DetectiveAddSucc(const ScAddress& rPos);
+ BOOL DetectiveDelSucc(const ScAddress& rPos);
+ BOOL DetectiveAddError(const ScAddress& rPos);
+ BOOL DetectiveMarkInvalid(SCTAB nTab);
+ BOOL DetectiveDelAll(SCTAB nTab);
+ BOOL DetectiveRefresh(BOOL bAutomatic = FALSE);
+ void DetectiveCollectAllPreds(const ScRangeList& rSrcRanges, ::std::vector<ScSharedTokenRef>& rRefTokens);
+ void DetectiveCollectAllSuccs(const ScRangeList& rSrcRanges, ::std::vector<ScSharedTokenRef>& rRefTokens);
+
+ BOOL DeleteContents( const ScMarkData& rMark, USHORT nFlags,
+ BOOL bRecord, BOOL bApi );
+
+ BOOL TransliterateText( const ScMarkData& rMark, sal_Int32 nType,
+ BOOL bRecord, BOOL bApi );
+
+ BOOL SetNormalString( const ScAddress& rPos, const String& rText, BOOL bApi );
+ BOOL PutCell( const ScAddress& rPos, ScBaseCell* pNewCell, BOOL bApi );
+ BOOL PutData( const ScAddress& rPos, ScEditEngineDefaulter& rEngine,
+ BOOL bInterpret, BOOL bApi );
+ BOOL SetCellText( const ScAddress& rPos, const String& rText,
+ BOOL bInterpret, BOOL bEnglish, BOOL bApi,
+ const String& rFormulaNmsp,
+ const formula::FormulaGrammar::Grammar eGrammar );
+
+ // creates a new cell for use with PutCell
+ ScBaseCell* InterpretEnglishString( const ScAddress& rPos, const String& rText,
+ const String& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar );
+
+ bool ShowNote( const ScAddress& rPos, bool bShow = true );
+ inline bool HideNote( const ScAddress& rPos ) { return ShowNote( rPos, false ); }
+
+ bool SetNoteText( const ScAddress& rPos, const String& rNoteText, BOOL bApi );
+ bool ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate, BOOL bApi );
+
+ BOOL ApplyAttributes( const ScMarkData& rMark, const ScPatternAttr& rPattern,
+ BOOL bRecord, BOOL bApi );
+ BOOL ApplyStyle( const ScMarkData& rMark, const String& rStyleName,
+ BOOL bRecord, BOOL bApi );
+
+ BOOL InsertCells( const ScRange& rRange,const ScMarkData* pTabMark,
+ InsCellCmd eCmd, BOOL bRecord, BOOL bApi,
+ BOOL bPartOfPaste = FALSE );
+ BOOL DeleteCells( const ScRange& rRange, const ScMarkData* pTabMark,
+ DelCellCmd eCmd, BOOL bRecord, BOOL bApi );
+
+ BOOL MoveBlock( const ScRange& rSource, const ScAddress& rDestPos,
+ BOOL bCut, BOOL bRecord, BOOL bPaint, BOOL bApi );
+
+ BOOL InsertTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi );
+ BOOL RenameTable( SCTAB nTab, const String& rName, BOOL bRecord, BOOL bApi );
+ BOOL DeleteTable( SCTAB nTab, BOOL bRecord, BOOL bApi );
+
+ bool SetTabBgColor( SCTAB nTab, const Color& rColor, bool bRecord, bool bApi );
+ bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoTabColorList, bool bRecord, bool bApi );
+
+ BOOL SetTableVisible( SCTAB nTab, BOOL bVisible, BOOL bApi );
+
+ BOOL SetLayoutRTL( SCTAB nTab, BOOL bRTL, BOOL bApi );
+
+ SC_DLLPUBLIC BOOL SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
+ SCTAB nTab, ScSizeMode eMode, USHORT nSizeTwips,
+ BOOL bRecord, BOOL bApi );
+
+ BOOL InsertPageBreak( BOOL bColumn, const ScAddress& rPos,
+ BOOL bRecord, BOOL bSetModified, BOOL bApi );
+ BOOL RemovePageBreak( BOOL bColumn, const ScAddress& rPos,
+ BOOL bRecord, BOOL bSetModified, BOOL bApi );
+
+ void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
+
+ BOOL Protect( SCTAB nTab, const String& rPassword, BOOL bApi );
+ BOOL Unprotect( SCTAB nTab, const String& rPassword, BOOL bApi );
+
+ BOOL ClearItems( const ScMarkData& rMark, const USHORT* pWhich, BOOL bApi );
+ BOOL ChangeIndent( const ScMarkData& rMark, BOOL bIncrement, BOOL bApi );
+ BOOL AutoFormat( const ScRange& rRange, const ScMarkData* pTabMark,
+ USHORT nFormatNo, BOOL bRecord, BOOL bApi );
+
+ BOOL EnterMatrix( const ScRange& rRange, const ScMarkData* pTabMark,
+ const ScTokenArray* pTokenArray,
+ const String& rString, BOOL bApi, BOOL bEnglish,
+ const String& rFormulaNmsp,
+ const formula::FormulaGrammar::Grammar );
+
+ BOOL TabOp( const ScRange& rRange, const ScMarkData* pTabMark,
+ const ScTabOpParam& rParam, BOOL bRecord, BOOL bApi );
+
+ BOOL FillSimple( const ScRange& rRange, const ScMarkData* pTabMark,
+ FillDir eDir, BOOL bRecord, BOOL bApi );
+ BOOL FillSeries( const ScRange& rRange, const ScMarkData* pTabMark,
+ FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
+ double fStart, double fStep, double fMax,
+ BOOL bRecord, BOOL bApi );
+ // FillAuto: rRange wird von Source-Range auf Dest-Range angepasst
+ SC_DLLPUBLIC BOOL FillAuto( ScRange& rRange, const ScMarkData* pTabMark, FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd, ULONG nCount, double fStep, double fMax, BOOL bRecord, BOOL bApi );
+
+ BOOL FillAuto( ScRange& rRange, const ScMarkData* pTabMark,
+ FillDir eDir, ULONG nCount, BOOL bRecord, BOOL bApi );
+
+ BOOL ResizeMatrix( const ScRange& rOldRange, const ScAddress& rNewEnd, BOOL bApi );
+
+ BOOL MergeCells( const ScCellMergeOption& rOption, BOOL bContents,
+ BOOL bRecord, BOOL bApi );
+ BOOL UnmergeCells( const ScRange& rRange, BOOL bRecord, BOOL bApi );
+ bool UnmergeCells( const ScCellMergeOption& rOption, BOOL bRecord, BOOL bApi );
+
+ bool SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc = true ); // takes ownership of pNewRanges
+ bool ModifyRangeNames( const ScRangeName& rNewRanges );
+
+ BOOL CreateNames( const ScRange& rRange, USHORT nFlags, BOOL bApi );
+ BOOL InsertNameList( const ScAddress& rStartPos, BOOL bApi );
+
+ BOOL InsertAreaLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ const ScRange& rDestRange, ULONG nRefresh,
+ BOOL bFitBlock, BOOL bApi );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
new file mode 100644
index 000000000000..bf29914feb1d
--- /dev/null
+++ b/sc/source/ui/inc/docsh.hxx
@@ -0,0 +1,483 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DOCSHELL_HXX
+#define SC_DOCSHELL_HXX
+
+
+#include <sfx2/objsh.hxx>
+
+#include <sfx2/docfac.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include "scdllapi.h"
+#include "scdll.hxx"
+#include "document.hxx"
+#include "shellids.hxx"
+#include "refreshtimer.hxx"
+#include "optutil.hxx"
+
+#include <hash_map>
+#include <cppuhelper/implbase1.hxx>
+
+class ScEditEngineDefaulter;
+class FontList;
+class PrintDialog;
+class SfxStyleSheetBasePool;
+class SfxStyleSheetHint;
+struct ChartSelectionInfo;
+class INetURLObject;
+
+class ScPaintItem;
+class ScViewData;
+class ScDocFunc;
+class ScDrawLayer;
+class ScTabViewShell;
+class ScSbxDocHelper;
+class ScAutoStyleList;
+class ScRange;
+class ScMarkData;
+class ScPaintLockData;
+class ScJobSetup;
+class ScChangeAction;
+class VirtualDevice;
+class ScImportOptions;
+class ScDocShellModificator;
+class ScOptSolverSave;
+class ScSheetSaveData;
+class ScFlatBoolRowSegments;
+struct ScColWidthParam;
+
+namespace sfx2 { class FileDialogHelper; }
+struct DocShell_Impl;
+
+typedef ::std::hash_map< ULONG, ULONG > ScChangeActionMergeMap;
+
+//==================================================================
+
+//enum ScDBFormat { SC_FORMAT_SDF, SC_FORMAT_DBF };
+
+ // Extra-Flags fuer Repaint
+#define SC_PF_LINES 1
+#define SC_PF_TESTMERGE 2
+#define SC_PF_WHOLEROWS 4
+
+class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener
+{
+ static const sal_Char __FAR_DATA pStarCalcDoc[];
+ static const sal_Char __FAR_DATA pStyleName[];
+
+ ScDocument aDocument;
+
+ String aDdeTextFmt;
+ String aConvFilterName; //@ #BugId 54198
+
+ double nPrtToScreenFactor;
+//! FontList* pFontList;
+ DocShell_Impl* pImpl;
+ ScDocFunc* pDocFunc;
+
+ //SfxObjectCreateMode eShellMode;
+
+ BOOL bIsInplace; // wird von der View gesetzt
+ BOOL bHeaderOn;
+ BOOL bFooterOn;
+ BOOL bNoInformLost;
+ BOOL bIsEmpty;
+ BOOL bIsInUndo;
+ BOOL bDocumentModifiedPending;
+ USHORT nDocumentLock;
+ sal_Int16 nCanUpdate; // stores the UpdateDocMode from loading a document till update links
+ BOOL bUpdateEnabled;
+
+ ScDBData* pOldAutoDBRange;
+
+ ScSbxDocHelper* pDocHelper;
+
+ ScAutoStyleList* pAutoStyleList;
+ ScPaintLockData* pPaintLockData;
+ ScJobSetup* pOldJobSetup;
+ ScOptSolverSave* pSolverSaveData;
+ ScSheetSaveData* pSheetSaveData;
+
+ ScDocShellModificator* pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading)
+
+ SC_DLLPRIVATE void InitItems();
+ SC_DLLPRIVATE void DoEnterHandler();
+ SC_DLLPRIVATE void InitOptions(bool bForLoading);
+ SC_DLLPRIVATE void ResetDrawObjectShell();
+
+ // SUNWS needs a forward declared friend, otherwise types and members
+ // of the outer class are not accessible.
+ class PrepareSaveGuard;
+ friend class ScDocShell::PrepareSaveGuard;
+ /** Do things that need to be done before saving to our own format and
+ necessary clean ups in dtor. */
+ class PrepareSaveGuard
+ {
+ public:
+ explicit PrepareSaveGuard( ScDocShell & rDocShell );
+ ~PrepareSaveGuard();
+ private:
+ ScDocShell & mrDocShell;
+ };
+
+ SC_DLLPRIVATE BOOL LoadXML( SfxMedium* pMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& );
+ SC_DLLPRIVATE BOOL SaveXML( SfxMedium* pMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& );
+ SC_DLLPRIVATE SCTAB GetSaveTab();
+
+ SC_DLLPRIVATE ULONG DBaseImport( const String& rFullFileName, CharSet eCharSet,
+ ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc );
+ SC_DLLPRIVATE ULONG DBaseExport( const String& rFullFileName, CharSet eCharSet,
+ BOOL& bHasMemo );
+
+ SC_DLLPRIVATE static BOOL MoveFile( const INetURLObject& rSource, const INetURLObject& rDest );
+ SC_DLLPRIVATE static BOOL KillFile( const INetURLObject& rURL );
+ SC_DLLPRIVATE static BOOL IsDocument( const INetURLObject& rURL );
+
+ SC_DLLPRIVATE void LockPaint_Impl(BOOL bDoc);
+ SC_DLLPRIVATE void UnlockPaint_Impl(BOOL bDoc);
+ SC_DLLPRIVATE void LockDocument_Impl(USHORT nNew);
+ SC_DLLPRIVATE void UnlockDocument_Impl(USHORT nNew);
+
+ SC_DLLPRIVATE void EnableSharedSettings( bool bEnable );
+ SC_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > LoadSharedDocument();
+
+ SC_DLLPRIVATE void UseSheetSaveEntries();
+
+protected:
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+public:
+ TYPEINFO();
+
+ SFX_DECL_INTERFACE(SCID_DOC_SHELL)
+ SFX_DECL_OBJECTFACTORY();
+
+ ScDocShell( const ScDocShell& rDocShell );
+ ScDocShell( const sal_uInt64 i_nSfxCreationFlags = SFXMODEL_EMBEDDED_OBJECT );
+ ~ScDocShell();
+
+ using SotObject::GetInterface;
+ using SfxShell::Activate; // with BOOL bMDI
+ using SfxShell::Deactivate; // with BOOL bMDI
+ using SfxObjectShell::Print; // print styles
+
+ virtual void Activate();
+ virtual void Deactivate();
+
+ virtual SfxUndoManager* GetUndoManager();
+
+ virtual void FillClass( SvGlobalName * pClassName,
+ sal_uInt32 * pFormat,
+ String * pAppName,
+ String * pFullTypeName,
+ String * pShortTypeName,
+ sal_Int32 nFileFormat,
+ sal_Bool bTemplate = sal_False ) const;
+
+ virtual BOOL InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& );
+ virtual BOOL Load( SfxMedium& rMedium );
+ virtual BOOL LoadFrom( SfxMedium& rMedium );
+ virtual BOOL ConvertFrom( SfxMedium &rMedium );
+ virtual BOOL Save();
+ virtual BOOL SaveAs( SfxMedium& rMedium );
+ virtual BOOL ConvertTo( SfxMedium &rMedium );
+ virtual USHORT PrepareClose( BOOL bUI = TRUE, BOOL bForBrowsing = FALSE );
+ virtual void PrepareReload();
+ virtual BOOL IsInformationLost();
+ virtual void LoadStyles( SfxObjectShell &rSource );
+ virtual BOOL Insert( SfxObjectShell &rSource,
+ USHORT nSourceIdx1, USHORT nSourceIdx2, USHORT nSourceIdx3,
+ USHORT &nIdx1, USHORT &nIdx2, USHORT &nIdx3, USHORT &rIdxDeleted );
+
+ virtual BOOL SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ); // SfxInPlaceObject
+ virtual BOOL DoSaveCompleted( SfxMedium * pNewStor); // SfxObjectShell
+ virtual sal_Bool QuerySlotExecutable( USHORT nSlotId );
+
+ virtual void Draw( OutputDevice *, const JobSetup & rSetup,
+ USHORT nAspect = ASPECT_CONTENT );
+
+ virtual void SetVisArea( const Rectangle & rVisArea );
+
+ using SfxObjectShell::GetVisArea;
+ virtual Rectangle GetVisArea( USHORT nAspect ) const;
+
+ virtual Printer* GetDocumentPrinter();
+
+ virtual void SetModified( BOOL = TRUE );
+
+ void SetVisAreaOrSize( const Rectangle& rVisArea, BOOL bModifyStart );
+
+ virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog( Window *pParent,
+ const SfxItemSet &rSet );
+
+ void GetDocStat( ScDocStat& rDocStat );
+
+ ScDocument* GetDocument() { return &aDocument; }
+ ScDocFunc& GetDocFunc() { return *pDocFunc; }
+
+ SfxPrinter* GetPrinter( BOOL bCreateIfNotExist = TRUE );
+ USHORT SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL );
+
+ void UpdateFontList();
+
+ String CreateObjectName( const String& rPrefix );
+
+ ScDrawLayer* MakeDrawLayer();
+
+ void AsciiSave( SvStream& rStream, const ScImportOptions& rOpt );
+
+ void GetSbxState( SfxItemSet &rSet );
+ void GetDrawObjState( SfxItemSet &rSet );
+
+ void Execute( SfxRequest& rReq );
+ void GetState( SfxItemSet &rSet );
+ void ExecutePageStyle ( SfxViewShell& rCaller, SfxRequest& rReq, SCTAB nCurTab );
+ void GetStatePageStyle( SfxViewShell& rCaller, SfxItemSet& rSet, SCTAB nCurTab );
+
+ void CompareDocument( ScDocument& rOtherDoc );
+ void MergeDocument( ScDocument& rOtherDoc, bool bShared = false, bool bCheckDuplicates = false, ULONG nOffset = 0, ScChangeActionMergeMap* pMergeMap = NULL, bool bInverseMap = false );
+ bool MergeSharedDocument( ScDocShell* pSharedDocShell );
+
+ ScChangeAction* GetChangeAction( const ScAddress& rPos );
+ void SetChangeComment( ScChangeAction* pAction, const String& rComment );
+ void ExecuteChangeCommentDialog( ScChangeAction* pAction, Window* pParent,BOOL bPrevNext=TRUE );
+ /// Protect/unprotect ChangeTrack and return <TRUE/> if
+ /// protection was successfully changed.
+ /// If bJustQueryIfProtected==TRUE protection is not
+ /// changed and <TRUE/> is returned if not protected or
+ /// password was entered correctly.
+ BOOL ExecuteChangeProtectionDialog( Window* _pParent, BOOL bJustQueryIfProtected = FALSE );
+
+ void SetPrintZoom( SCTAB nTab, USHORT nScale, USHORT nPages );
+ BOOL AdjustPrintZoom( const ScRange& rRange );
+
+ void LoadStylesArgs( ScDocShell& rSource, BOOL bReplace, BOOL bCellStyles, BOOL bPageStyles );
+
+ void PageStyleModified( const String& rStyleName, BOOL bApi );
+
+ void NotifyStyle( const SfxStyleSheetHint& rHint );
+ void DoAutoStyle( const ScRange& rRange, const String& rStyle );
+
+ Window* GetActiveDialogParent();
+ void ErrorMessage( USHORT nGlobStrId );
+ BOOL IsEditable() const;
+
+ BOOL AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab );
+ void UpdateAllRowHeights( const ScMarkData* pTabMark = NULL );
+ void UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore = false );
+
+ void RefreshPivotTables( const ScRange& rSource );
+ void DoConsolidate( const ScConsolidateParam& rParam, BOOL bRecord = TRUE );
+ void UseScenario( SCTAB nTab, const String& rName, BOOL bRecord = TRUE );
+ SCTAB MakeScenario( SCTAB nTab, const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags,
+ ScMarkData& rMark, BOOL bRecord = TRUE );
+ void ModifyScenario( SCTAB nTab, const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags );
+ ULONG TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
+ SCTAB nDestPos, BOOL bInsertNew,
+ BOOL bNotifyAndPaint );
+
+ BOOL MoveTable( SCTAB nSrcTab, SCTAB nDestTab, BOOL bCopy, BOOL bRecord );
+
+ void DoRecalc( BOOL bApi );
+ void DoHardRecalc( BOOL bApi );
+
+ bool CheckPrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData,
+ bool bForceSelected, bool bIsAPI );
+ void PreparePrint( PrintDialog* pPrintDialog, ScMarkData* pMarkData );
+ void Print( SfxProgress& rProgress, PrintDialog* pPrintDialog,
+ ScMarkData* pMarkData, Window* pDialogParent,
+ BOOL bForceSelected, BOOL bIsAPI );
+
+ void UpdateOle( const ScViewData* pViewData, BOOL bSnapSize = FALSE );
+ BOOL IsOle();
+
+ void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
+ ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
+ ScDBData* GetOldAutoDBRange(); // has to be deleted by caller!
+ void CancelAutoDBRange(); // called when dialog is cancelled
+
+ virtual void ReconnectDdeLink(SfxObjectShell& rServer);
+ void UpdateLinks(); // Link-Eintraege aktuallisieren
+ BOOL ReloadTabLinks(); // Links ausfuehren (Inhalt aktualisieren)
+
+ virtual void CheckConfigOptions();
+
+ void PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos );
+
+ void PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, USHORT nPart,
+ USHORT nExtFlags = 0 );
+ void PostPaint( const ScRange& rRange, USHORT nPart, USHORT nExtFlags = 0 );
+
+ void PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ void PostPaintCell( const ScAddress& rPos );
+ void PostPaintGridAll();
+ void PostPaintExtras();
+
+ void PostDataChanged();
+
+ void UpdatePaintExt( USHORT& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
+ SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
+ void UpdatePaintExt( USHORT& rExtFlags, const ScRange& rRange );
+
+ void SetDocumentModified( BOOL bIsModified = TRUE );
+ void SetDrawModified( BOOL bIsModified = TRUE );
+
+ void LockPaint();
+ void UnlockPaint();
+ USHORT GetLockCount() const;
+ void SetLockCount(USHORT nNew);
+
+ void LockDocument();
+ void UnlockDocument();
+
+ DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
+
+ virtual SfxStyleSheetBasePool* GetStyleSheetPool();
+
+ void SetInplace( BOOL bInplace );
+ BOOL IsEmpty() const;
+ void SetEmpty(BOOL bSet);
+
+ BOOL IsInUndo() const { return bIsInUndo; }
+ void SetInUndo(BOOL bSet);
+
+ void CalcOutputFactor();
+ double GetOutputFactor() const;
+ void GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet,
+ SCTAB nCurTab,
+ BOOL& rbHeader,
+ BOOL& rbFooter );
+
+ virtual long DdeGetData( const String& rItem, const String& rMimeType,
+ ::com::sun::star::uno::Any & rValue );
+ virtual long DdeSetData( const String& rItem, const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue );
+ virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
+
+ const String& GetDdeTextFmt() const { return aDdeTextFmt; }
+
+ SfxBindings* GetViewBindings();
+
+ ScTabViewShell* GetBestViewShell( BOOL bOnlyVisible = TRUE );
+ ScSbxDocHelper* GetDocHelperObject() { return pDocHelper; }
+
+ void SetDocumentModifiedPending( BOOL bVal )
+ { bDocumentModifiedPending = bVal; }
+ BOOL IsDocumentModifiedPending() const
+ { return bDocumentModifiedPending; }
+
+ BOOL IsUpdateEnabled() const
+ { return bUpdateEnabled; }
+ void SetUpdateEnabled(BOOL bValue)
+ { bUpdateEnabled = bValue; }
+
+ OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
+
+ static ScViewData* GetViewData();
+ static SCTAB GetCurTab();
+
+ static ScDocShell* GetShellByNum( USHORT nDocNo );
+ static String GetOwnFilterName();
+ static String GetHtmlFilterName();
+ static String GetWebQueryFilterName();
+ static String GetAsciiFilterName();
+ static String GetLotusFilterName();
+ static String GetDBaseFilterName();
+ static String GetDifFilterName();
+ static BOOL HasAutomaticTableName( const String& rFilter );
+
+ DECL_LINK( RefreshDBDataHdl, ScRefreshTimer* );
+
+ void BeforeXMLLoading();
+ void AfterXMLLoading(sal_Bool bRet);
+
+ virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
+
+ const ScOptSolverSave* GetSolverSaveData() const { return pSolverSaveData; } // may be null
+ void SetSolverSaveData( const ScOptSolverSave& rData );
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ sal_Bool AcceptStateUpdate() const;
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+ ScSheetSaveData* GetSheetSaveData();
+
+ void ResetKeyBindings( ScOptionsUtil::KeyBindingType eType );
+
+ // passwword protection for Calc (derived from SfxObjectShell)
+ // see also: FID_CHG_RECORD, SID_CHG_PROTECT
+ virtual bool IsChangeRecording() const;
+ virtual bool HasChangeRecordProtection() const;
+ virtual void SetChangeRecording( bool bActivate );
+ virtual bool SetProtectionPassword( const String &rPassword );
+ virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
+};
+
+
+void UpdateAcceptChangesDialog();
+
+
+SO2_DECL_REF(ScDocShell)
+SO2_IMPL_REF(ScDocShell)
+
+
+// Vor Modifizierungen des Dokuments anlegen und danach zerstoeren.
+// Merkt sich im Ctor AutoCalcShellDisabled und IdleDisabled, schaltet sie ab
+// und stellt sie im Dtor wieder her, AutoCalcShellDisabled ggbf. auch vor
+// einem ScDocShell SetDocumentModified.
+// SetDocumentModified hierdran aufrufen statt an der ScDocShell.
+// Im Dtor wird wenn ScDocShell bDocumentModifiedPending gesetzt ist und
+// bAutoCalcShellDisabled nicht gesetzt ist ein SetDocumentModified gerufen.
+class SC_DLLPUBLIC ScDocShellModificator
+{
+ ScDocShell& rDocShell;
+ ScRefreshTimerProtector aProtector;
+ BOOL bAutoCalcShellDisabled;
+ BOOL bIdleDisabled;
+
+ // not implemented
+ ScDocShellModificator( const ScDocShellModificator& );
+ ScDocShellModificator& operator=( const ScDocShellModificator& );
+
+public:
+ ScDocShellModificator( ScDocShell& );
+ ~ScDocShellModificator();
+ void SetDocumentModified();
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dpcontrol.hrc b/sc/source/ui/inc/dpcontrol.hrc
new file mode 100644
index 000000000000..9cea30e99d4f
--- /dev/null
+++ b/sc/source/ui/inc/dpcontrol.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __DPCONTROL_HRC__
+#define __DPCONTROL_HRC__
+
+#include <sc.hrc>
+
+#define STR_MENU_SORT_ASC 1
+#define STR_MENU_SORT_DESC 2
+#define STR_MENU_SORT_CUSTOM 3
+#define STR_BTN_TOGGLE_ALL 4
+#define STR_BTN_SELECT_CURRENT 5
+#define STR_BTN_UNSELECT_CURRENT 6
+
+#endif
diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx
new file mode 100644
index 000000000000..912f05058916
--- /dev/null
+++ b/sc/source/ui/inc/dpcontrol.hxx
@@ -0,0 +1,366 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DPCONTROL_HXX
+#define SC_DPCONTROL_HXX
+
+#include "rtl/ustring.hxx"
+#include "tools/gen.hxx"
+#include "tools/fract.hxx"
+#include "vcl/popupmenuwindow.hxx"
+#include "vcl/button.hxx"
+#include "vcl/scrbar.hxx"
+#include "vcl/timer.hxx"
+#include "svx/checklbx.hxx"
+
+#include <boost/shared_ptr.hpp>
+#include <memory>
+#include <hash_map>
+
+namespace com { namespace sun { namespace star {
+
+ namespace accessibility {
+ class XAccessible;
+ }
+
+}}}
+
+class OutputDevice;
+class Point;
+class Size;
+class StyleSettings;
+class Window;
+class ScDocument;
+class ScAccessibleFilterMenu;
+
+/**
+ * This class takes care of physically drawing field button controls inside
+ * data pilot tables.
+ */
+class ScDPFieldButton
+{
+public:
+ ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL,
+ ScDocument* pDoc = NULL);
+ ~ScDPFieldButton();
+
+ void setText(const ::rtl::OUString& rText);
+ void setBoundingBox(const Point& rPos, const Size& rSize, bool bLayoutRTL);
+ void setDrawBaseButton(bool b);
+ void setDrawPopupButton(bool b);
+ void setHasHiddenMember(bool b);
+ void setPopupPressed(bool b);
+ void setPopupLeft(bool b);
+ void draw();
+
+ void getPopupBoundingBox(Point& rPos, Size& rSize) const;
+
+private:
+ void drawPopupButton();
+
+private:
+ Point maPos;
+ Size maSize;
+ ::rtl::OUString maText;
+ Fraction maZoomX;
+ Fraction maZoomY;
+ ScDocument* mpDoc;
+ OutputDevice* mpOutDev;
+ const StyleSettings* mpStyle;
+ bool mbBaseButton;
+ bool mbPopupButton;
+ bool mbHasHiddenMember;
+ bool mbPopupPressed;
+ bool mbPopupLeft;
+};
+
+// ============================================================================
+
+class ScMenuFloatingWindow : public PopupMenuFloatingWindow
+{
+public:
+ static size_t MENU_NOT_SELECTED;
+ /**
+ * Action to perform when an event takes place. Create a sub-class of
+ * this to implement the desired action.
+ */
+ class Action
+ {
+ public:
+ virtual void execute() = 0;
+ };
+
+ explicit ScMenuFloatingWindow(Window* pParent, ScDocument* pDoc, USHORT nMenuStackLevel = 0);
+ virtual ~ScMenuFloatingWindow();
+
+ virtual void MouseMove(const MouseEvent& rMEvt);
+ virtual void MouseButtonDown(const MouseEvent& rMEvt);
+ virtual void MouseButtonUp(const MouseEvent& rMEvt);
+ virtual void KeyInput(const KeyEvent& rKEvt);
+ virtual void Paint(const Rectangle& rRect);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ void addMenuItem(const ::rtl::OUString& rText, bool bEnabled, Action* pAction);
+ ScMenuFloatingWindow* addSubMenuItem(const ::rtl::OUString& rText, bool bEnabled);
+ void setSelectedMenuItem(size_t nPos, bool bSubMenuTimer, bool bEnsureSubMenu);
+ void selectMenuItem(size_t nPos, bool bSelected, bool bSubMenuTimer);
+ void clearSelectedMenuItem();
+ ScMenuFloatingWindow* getSubMenuWindow(size_t nPos) const;
+ bool isMenuItemSelected(size_t nPos) const;
+ size_t getSelectedMenuItem() const;
+
+ void setName(const ::rtl::OUString& rName);
+ const ::rtl::OUString& getName() const;
+
+ void executeMenuItem(size_t nPos);
+ void getMenuItemPosSize(size_t nPos, Point& rPos, Size& rSize) const;
+ ScMenuFloatingWindow* getParentMenuWindow() const;
+
+protected:
+
+ void drawMenuItem(size_t nPos);
+ void drawAllMenuItems();
+ const Font& getLabelFont() const;
+
+ void queueLaunchSubMenu(size_t nPos, ScMenuFloatingWindow* pMenu);
+ void queueCloseSubMenu();
+ void launchSubMenu(bool bSetMenuPos);
+ void endSubMenu(ScMenuFloatingWindow* pSubMenu);
+
+ void fillMenuItemsToAccessible(ScAccessibleFilterMenu* pAccMenu) const;
+
+ ScDocument* getDoc();
+
+protected:
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible > mxAccessible;
+
+private:
+ struct SubMenuItemData;
+ void handleMenuTimeout(SubMenuItemData* pTimer);
+
+ void resizeToFitMenuItems();
+ void highlightMenuItem(size_t nPos, bool bSelected);
+
+ size_t getEnclosingMenuItem(const Point& rPos) const;
+ size_t getSubMenuPos(ScMenuFloatingWindow* pSubMenu);
+
+ /**
+ * Fire a menu highlight event since the accessibility framework needs
+ * this to track focus on menu items.
+ */
+ void fireMenuHighlightedEvent();
+
+ /**
+ * Make sure that the specified submenu is permanently up, the submenu
+ * close timer is not active, and the correct menu item associated with
+ * the submenu is highlighted.
+ */
+ void setSubMenuFocused(ScMenuFloatingWindow* pSubMenu);
+
+ /**
+ * When a menu item of an invisible submenu is selected, we need to make
+ * sure that all its parent menu(s) are visible, with the right menu item
+ * highlighted in each of the parents. Calling this method ensures it.
+ */
+ void ensureSubMenuVisible(ScMenuFloatingWindow* pSubMenu);
+
+ /**
+ * Dismiss any visible child submenus when a menu item of a parent menu is
+ * selected.
+ */
+ void ensureSubMenuNotVisible();
+
+ /**
+ * Dismiss all visible popup menus and set focus back to the application
+ * window. This method is called e.g. when a menu action is fired.
+ */
+ void terminateAllPopupMenus();
+
+ DECL_LINK( PopupEndHdl, void* );
+
+private:
+
+ struct MenuItemData
+ {
+ ::rtl::OUString maText;
+ bool mbEnabled;
+
+ ::boost::shared_ptr<Action> mpAction;
+ ::boost::shared_ptr<ScMenuFloatingWindow> mpSubMenuWin;
+
+ MenuItemData();
+ };
+
+ ::std::vector<MenuItemData> maMenuItems;
+
+ struct SubMenuItemData
+ {
+ Timer maTimer;
+ ScMenuFloatingWindow* mpSubMenu;
+ size_t mnMenuPos;
+
+ DECL_LINK( TimeoutHdl, void* );
+
+ SubMenuItemData(ScMenuFloatingWindow* pParent);
+ void reset();
+
+ private:
+ ScMenuFloatingWindow* mpParent;
+ };
+ SubMenuItemData maOpenTimer;
+ SubMenuItemData maCloseTimer;
+
+ Font maLabelFont;
+
+ // Name of this menu window, taken from the menu item of the parent window
+ // that launches it (if this is a sub menu). If this is a top-level menu
+ // window, then this name can be anything.
+ ::rtl::OUString maName;
+
+ size_t mnSelectedMenu;
+ size_t mnClickedMenu;
+
+ ScDocument* mpDoc;
+
+ ScMenuFloatingWindow* mpParentMenu;
+ ScMenuFloatingWindow* mpActiveSubMenu;
+};
+
+// ============================================================================
+
+/**
+ * This class implements a popup window for field button, for quick access
+ * of hide-item list, and possibly more stuff related to field options.
+ */
+class ScDPFieldPopupWindow : public ScMenuFloatingWindow
+{
+public:
+ /**
+ * Extended data that the client code may need to store. Create a
+ * sub-class of this and store data there.
+ */
+ struct ExtendedData {};
+
+ explicit ScDPFieldPopupWindow(Window* pParent, ScDocument* pDoc);
+ virtual ~ScDPFieldPopupWindow();
+
+ virtual void MouseMove(const MouseEvent& rMEvt);
+ virtual long Notify(NotifyEvent& rNEvt);
+ virtual void Paint(const Rectangle& rRect);
+ virtual Window* GetPreferredKeyInputWindow();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ void setMemberSize(size_t n);
+ void addMember(const ::rtl::OUString& rName, bool bVisible);
+ void initMembers();
+
+ const Size& getWindowSize() const;
+
+ void getResult(::std::hash_map< ::rtl::OUString, bool, ::rtl::OUStringHash>& rResult);
+ void close(bool bOK);
+
+ /**
+ * Set auxiliary data that the client code might need. Note that this
+ * popup window class manages its life time; no explicit deletion of the
+ * instance is needed in the client code.
+ */
+ void setExtendedData(ExtendedData* p);
+
+ /**
+ * Get the store auxiliary data, or NULL if no such data is stored.
+ */
+ ExtendedData* getExtendedData();
+
+ void setOKAction(Action* p);
+
+private:
+ struct Member
+ {
+ ::rtl::OUString maName;
+ bool mbVisible;
+
+ Member();
+ };
+
+ class CancelButton : public ::CancelButton
+ {
+ public:
+ CancelButton(ScDPFieldPopupWindow* pParent);
+
+ virtual void Click();
+
+ private:
+ ScDPFieldPopupWindow* mpParent;
+ };
+
+ enum SectionType {
+ WHOLE, // entire window
+ LISTBOX_AREA_OUTER, // box enclosing the check box items.
+ LISTBOX_AREA_INNER, // box enclosing the check box items.
+ SINGLE_BTN_AREA, // box enclosing the single-action buttons.
+ CHECK_TOGGLE_ALL, // check box for toggling all items.
+ BTN_SINGLE_SELECT,
+ BTN_SINGLE_UNSELECT,
+ BTN_OK, // OK button
+ BTN_CANCEL, // Cancel button
+ };
+ void getSectionPosSize(Point& rPos, Size& rSize, SectionType eType) const;
+
+ void setAllMemberState(bool bSet);
+ void selectCurrentMemberOnly(bool bSet);
+ void cycleFocus(bool bReverse = false);
+
+ DECL_LINK( ButtonHdl, Button* );
+ DECL_LINK( TriStateHdl, TriStateBox* );
+ DECL_LINK( CheckHdl, SvTreeListBox* );
+
+private:
+ SvxCheckListBox maChecks;
+
+ TriStateBox maChkToggleAll;
+ ImageButton maBtnSelectSingle;
+ ImageButton maBtnUnselectSingle;
+
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+
+ ::std::vector<Window*> maTabStopCtrls;
+ size_t mnCurTabStop;
+
+ ::std::vector<Member> maMembers;
+ ::std::auto_ptr<ExtendedData> mpExtendedData;
+ ::std::auto_ptr<Action> mpOKAction;
+
+ const Size maWndSize; /// hard-coded window size.
+ TriState mePrevToggleAllState;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dpgroupdlg.hxx b/sc/source/ui/inc/dpgroupdlg.hxx
new file mode 100644
index 000000000000..75c98fa6cd88
--- /dev/null
+++ b/sc/source/ui/inc/dpgroupdlg.hxx
@@ -0,0 +1,168 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DPGROUPDLG_HXX
+#define SC_DPGROUPDLG_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <svx/checklbx.hxx>
+#include "editfield.hxx"
+#include "dpgroup.hxx"
+
+// ============================================================================
+
+class ScDPGroupEditHelper
+{
+public:
+ explicit ScDPGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan,
+ Edit& rEdValue );
+
+ bool IsAuto() const;
+ double GetValue() const;
+ void SetValue( bool bAuto, double fValue );
+
+private:
+ virtual bool ImplGetValue( double& rfValue ) const = 0;
+ virtual void ImplSetValue( double fValue ) = 0;
+
+ DECL_LINK( ClickHdl, RadioButton* );
+
+private:
+ RadioButton& mrRbAuto;
+ RadioButton& mrRbMan;
+ Edit& mrEdValue;
+};
+
+// ----------------------------------------------------------------------------
+
+class ScDPNumGroupEditHelper : public ScDPGroupEditHelper
+{
+public:
+ explicit ScDPNumGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan,
+ ScDoubleField& rEdValue );
+
+private:
+ virtual bool ImplGetValue( double& rfValue ) const;
+ virtual void ImplSetValue( double fValue );
+
+private:
+ ScDoubleField& mrEdValue;
+};
+
+// ----------------------------------------------------------------------------
+
+class ScDPDateGroupEditHelper : public ScDPGroupEditHelper
+{
+public:
+ explicit ScDPDateGroupEditHelper(
+ RadioButton& rRbAuto, RadioButton& rRbMan,
+ DateField& rEdValue, const Date& rNullDate );
+
+private:
+ virtual bool ImplGetValue( double& rfValue ) const;
+ virtual void ImplSetValue( double fValue );
+
+private:
+ DateField& mrEdValue;
+ Date maNullDate;
+};
+
+// ============================================================================
+// ============================================================================
+
+class ScDPNumGroupDlg : public ModalDialog
+{
+public:
+ explicit ScDPNumGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo );
+
+ ScDPNumGroupInfo GetGroupInfo() const;
+
+private:
+ FixedLine maFlStart;
+ RadioButton maRbAutoStart;
+ RadioButton maRbManStart;
+ ScDoubleField maEdStart;
+ FixedLine maFlEnd;
+ RadioButton maRbAutoEnd;
+ RadioButton maRbManEnd;
+ ScDoubleField maEdEnd;
+ FixedLine maFlBy;
+ ScDoubleField maEdBy;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+ ScDPNumGroupEditHelper maStartHelper;
+ ScDPNumGroupEditHelper maEndHelper;
+};
+
+// ============================================================================
+
+class ScDPDateGroupDlg : public ModalDialog
+{
+public:
+ explicit ScDPDateGroupDlg( Window* pParent, const ScDPNumGroupInfo& rInfo,
+ sal_Int32 nDatePart, const Date& rNullDate );
+
+ ScDPNumGroupInfo GetGroupInfo() const;
+ sal_Int32 GetDatePart() const;
+
+private:
+ DECL_LINK( ClickHdl, RadioButton* );
+ DECL_LINK( CheckHdl, SvxCheckListBox* );
+
+private:
+ FixedLine maFlStart;
+ RadioButton maRbAutoStart;
+ RadioButton maRbManStart;
+ DateField maEdStart;
+ FixedLine maFlEnd;
+ RadioButton maRbAutoEnd;
+ RadioButton maRbManEnd;
+ DateField maEdEnd;
+ FixedLine maFlBy;
+ RadioButton maRbNumDays;
+ RadioButton maRbUnits;
+ NumericField maEdNumDays;
+ SvxCheckListBox maLbUnits;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+ ScDPDateGroupEditHelper maStartHelper;
+ ScDPDateGroupEditHelper maEndHelper;
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/drawsh.hxx b/sc/source/ui/inc/drawsh.hxx
new file mode 100644
index 000000000000..39db423f44dd
--- /dev/null
+++ b/sc/source/ui/inc/drawsh.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DRAWSH_HXX
+#define SC_DRAWSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+#include <tools/link.hxx>
+
+class AbstractSvxNameDialog;
+class ScViewData;
+class ScDrawView;
+
+class ScDrawShell : public SfxShell
+{
+ ScViewData* pViewData;
+
+ DECL_LINK( NameObjectHdl, AbstractSvxNameDialog* );
+
+ void SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk );
+
+protected:
+ ScViewData* GetViewData() { return pViewData; }
+
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_DRAW_SHELL)
+
+ ScDrawShell(ScViewData* pData);
+ ~ScDrawShell();
+
+ void StateDisableItems( SfxItemSet &rSet );
+
+ void ExecDrawAttr(SfxRequest& rReq);
+ void GetDrawAttrState(SfxItemSet &rSet);
+ void GetAttrFuncState(SfxItemSet &rSet);
+
+ void ExecDrawFunc(SfxRequest& rReq);
+ void GetDrawFuncState(SfxItemSet &rSet);
+ void GetState(SfxItemSet &rSet);
+
+ void ExecFormText(SfxRequest& rReq); // StarFontWork
+ void GetFormTextState(SfxItemSet& rSet);
+
+ void ExecuteHLink(SfxRequest& rReq); // Hyperlink
+ void GetHLinkState(SfxItemSet& rSet);
+
+ void ExecFormatPaintbrush(SfxRequest& rReq);
+ void StateFormatPaintbrush(SfxItemSet& rSet);
+
+ void ExecuteMacroAssign( SdrObject* pObj, Window* pWin );
+ void ExecuteLineDlg( SfxRequest& rReq, USHORT nTabPage = 0xffff );
+ void ExecuteAreaDlg( SfxRequest& rReq, USHORT nTabPage = 0xffff );
+ void ExecuteTextAttrDlg( SfxRequest& rReq, USHORT nTabPage = 0xffff );
+
+ ScDrawView* GetDrawView();
+
+ BOOL AreAllObjectsOnLayer(USHORT nLayerNo,const SdrMarkList& rMark);
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/drawutil.hxx b/sc/source/ui/inc/drawutil.hxx
new file mode 100644
index 000000000000..88c49d77bc8e
--- /dev/null
+++ b/sc/source/ui/inc/drawutil.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DRAWUTIL_HXX
+#define SC_DRAWUTIL_HXX
+
+#include "address.hxx"
+#include <tools/solar.h>
+
+class Fraction;
+class OutputDevice;
+class ScDocument;
+
+class ScDrawUtil
+{
+public:
+ static void CalcScale( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ OutputDevice* pDev, const Fraction& rZoomX, const Fraction& rZoomY,
+ double nPPTX, double nPPTY,
+ Fraction& rScaleX, Fraction& rScaleY );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/drawview.hxx b/sc/source/ui/inc/drawview.hxx
new file mode 100644
index 000000000000..5a18babbb0fa
--- /dev/null
+++ b/sc/source/ui/inc/drawview.hxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DRAWVIEW_HXX
+#define SC_DRAWVIEW_HXX
+
+#include <svx/fmview.hxx>
+
+#include "global.hxx"
+
+namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
+
+class ScDocument;
+class ScViewData;
+class ScDrawObjData;
+
+class ScDrawView: public FmFormView
+{
+ ScViewData* pViewData;
+ OutputDevice* pDev; //! noetig ?
+ ScDocument* pDoc;
+ SCTAB nTab;
+ Fraction aScaleX; // Faktor fuer Drawing-MapMode
+ Fraction aScaleY;
+ SdrDropMarkerOverlay* pDropMarker;
+ SdrObject* pDropMarkObj;
+ BOOL bInConstruct;
+ //HMHBOOL bDisableHdl;
+
+ void Construct();
+ void UpdateBrowser();
+
+protected:
+ virtual void ModelHasChanged();
+
+ // add custom handles (used by other apps, e.g. AnchorPos)
+ virtual void AddCustomHdl();
+
+ void ImplClearCalcDropMarker();
+
+public:
+ ScDrawView( OutputDevice* pOut, ScViewData* pData );
+ virtual ~ScDrawView();
+
+ virtual void MarkListHasChanged();
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual void DoConnect(SdrOle2Obj* pOleObj);
+
+ virtual void MakeVisible( const Rectangle& rRect, Window& rWin );
+
+ virtual void DeleteMarked();
+
+ void DrawMarks( OutputDevice* pOut ) const;
+
+ void MarkDropObj( SdrObject* pObj );
+
+ //HMHBOOL IsDisableHdl() const { return bDisableHdl; }
+
+ void SetMarkedToLayer( BYTE nLayerNo );
+
+ void InvalidateAttribs();
+ void InvalidateDrawTextAttrs();
+
+ BOOL BeginDrag( Window* pWindow, const Point& rStartPos );
+ void DoCut();
+ void DoCopy();
+
+ void GetScale( Fraction& rFractX, Fraction& rFractY ) const;
+ void RecalcScale();
+ void UpdateWorkArea();
+ SCTAB GetTab() const { return nTab; }
+
+ void CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const;
+
+ void SetAnchor( ScAnchorType );
+ ScAnchorType GetAnchor() const;
+
+ void VCAddWin( Window* pWin );
+ void VCRemoveWin( Window* pWin );
+
+ void UpdateIMap( SdrObject* pObj );
+
+ USHORT GetPopupMenuId();
+ void UpdateUserViewOptions();
+
+ void SetMarkedOriginalSize();
+
+ BOOL SelectObject( const String& rName );
+ bool HasMarkedControl() const;
+ bool HasMarkedInternal() const;
+
+ bool InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions=0);
+
+ /** Returns the selected object, if it is the caption object of a cell note.
+ @param ppCaptData (out-param) If not null, returns the pointer to the caption object data. */
+ SdrObject* GetMarkedNoteCaption( ScDrawObjData** ppCaptData = 0 );
+
+ /** Locks/unlocks the specified layer in the draw page.
+ Unlocked layer is required to be able to edit the contained objects. */
+ void LockCalcLayer( SdrLayerID nLayer, bool bLock = true );
+ /** Unlocks the specified layer in the draw page. */
+ inline void UnlockCalcLayer( SdrLayerID nLayer ) { LockCalcLayer( nLayer, false ); }
+
+ /** Locks/unlocks the background layer that contains background objects.
+ Unlocked layer is required to be able to edit the objects. */
+ inline void LockBackgroundLayer( bool bLock = true ) { LockCalcLayer( SC_LAYER_BACK, bLock ); }
+ /** Unlocks the background layer that contains background objects. */
+ inline void UnlockBackgroundLayer() { LockBackgroundLayer( false ); }
+
+ /** Locks/unlocks the internal layer that contains caption objects of cell notes.
+ Unlocked layer is required to be able to edit the contained objects. */
+ inline void LockInternalLayer( bool bLock = true ) { LockCalcLayer( SC_LAYER_INTERN, bLock ); }
+ /** Unlocks the internal layer that contains caption objects of cell notes. */
+ inline void UnlockInternalLayer() { LockInternalLayer( false ); }
+
+ SdrEndTextEditKind ScEndTextEdit(); // ruft SetDrawTextUndo(0)
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > CopyToTransferable();
+};
+
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/drformsh.hxx b/sc/source/ui/inc/drformsh.hxx
new file mode 100644
index 000000000000..de53dc2a74e6
--- /dev/null
+++ b/sc/source/ui/inc/drformsh.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef DRFORMSH_HXX
+#define DRFORMSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+
+class ScViewData;
+
+
+#include "drawsh.hxx"
+
+class ScDrawFormShell: public ScDrawShell
+{
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_FORM_SHELL)
+
+ ScDrawFormShell(ScViewData* pData);
+ virtual ~ScDrawFormShell();
+
+// void Execute(SfxRequest &);
+// void GetState(SfxItemSet &);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/drtxtob.hxx b/sc/source/ui/inc/drtxtob.hxx
new file mode 100644
index 000000000000..49d0b3badddd
--- /dev/null
+++ b/sc/source/ui/inc/drtxtob.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DRTXTOB_HXX
+#define SC_DRTXTOB_HXX
+
+#ifndef _SFX_HXX
+#endif
+
+#include <sfx2/shell.hxx>
+#include <sfx2/module.hxx>
+#include <tools/link.hxx>
+
+#include "shellids.hxx"
+
+USHORT ScGetFontWorkId(); // statt SvxFontWorkChildWindow::GetChildWindowId()
+
+class ScViewData;
+class TransferableDataHelper;
+class TransferableClipboardListener;
+
+class ScDrawTextObjectBar : public SfxShell
+{
+ ScViewData* pViewData;
+ TransferableClipboardListener* pClipEvtLstnr;
+ BOOL bPastePossible;
+
+ DECL_LINK( ClipboardChanged, TransferableDataHelper* );
+
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_DRAW_TEXT_SHELL)
+
+ ScDrawTextObjectBar(ScViewData* pData);
+ ~ScDrawTextObjectBar();
+
+ void StateDisableItems( SfxItemSet &rSet );
+
+ void Execute( SfxRequest &rReq );
+ void ExecuteTrans( SfxRequest& rReq );
+ void GetState( SfxItemSet& rSet );
+ void GetClipState( SfxItemSet& rSet );
+
+ void ExecuteAttr( SfxRequest &rReq );
+ void GetAttrState( SfxItemSet& rSet );
+ void ExecuteToggle( SfxRequest &rReq );
+
+ BOOL ExecuteCharDlg( const SfxItemSet& rArgs, SfxItemSet& rOutSet );
+ BOOL ExecuteParaDlg( const SfxItemSet& rArgs, SfxItemSet& rOutSet );
+
+ void ExecuteExtra( SfxRequest &rReq );
+ void ExecFormText(SfxRequest& rReq); // StarFontWork
+ void GetFormTextState(SfxItemSet& rSet);
+
+private:
+ void ExecuteGlobal( SfxRequest &rReq ); // von Execute gerufen fuer ganze Objekte
+ void GetGlobalClipState( SfxItemSet& rSet );
+ void ExecutePasteContents( SfxRequest &rReq );
+ BOOL IsNoteEdit();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/drwtrans.hxx b/sc/source/ui/inc/drwtrans.hxx
new file mode 100644
index 000000000000..4e9088c4e4be
--- /dev/null
+++ b/sc/source/ui/inc/drwtrans.hxx
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DRWTRANS_HXX
+#define SC_DRWTRANS_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <svtools/transfer.hxx>
+
+#include <sfx2/objsh.hxx>
+#include "global.hxx"
+
+
+class SdrModel;
+class ScDocShell;
+class INetBookmark;
+class SdrObject;
+class SdrView;
+class ScDrawView;
+class SdrOle2Obj;
+
+class ScDrawTransferObj : public TransferableHelper
+{
+private:
+ SdrModel* pModel;
+ TransferableDataHelper aOleData;
+ TransferableObjectDescriptor aObjDesc;
+//REMOVE SvEmbeddedObjectRef aDocShellRef;
+//REMOVE SvEmbeddedObjectRef aDrawPersistRef;
+ SfxObjectShellRef aDocShellRef;
+ SfxObjectShellRef aDrawPersistRef;
+
+ // extracted from model in ctor:
+ Size aSrcSize;
+ INetBookmark* pBookmark;
+ BOOL bGraphic;
+ BOOL bGrIsBit;
+ BOOL bOleObj;
+ // source information for drag&drop:
+ // (view is needed to handle drawing obejcts)
+ SdrView* pDragSourceView;
+ USHORT nDragSourceFlags;
+ BOOL bDragWasInternal;
+
+ sal_uInt32 nSourceDocID;
+
+
+ void InitDocShell();
+//REMOVE SvInPlaceObjectRef GetSingleObject();
+ SdrOle2Obj* GetSingleObject();
+
+public:
+ ScDrawTransferObj( SdrModel* pClipModel, ScDocShell* pContainerShell,
+ const TransferableObjectDescriptor& rDesc );
+ virtual ~ScDrawTransferObj();
+
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
+ const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void ObjectReleased();
+ virtual void DragFinished( sal_Int8 nDropAction );
+
+ SdrModel* GetModel() { return pModel; }
+
+ void SetDrawPersist( const SfxObjectShellRef& rRef );
+ void SetDragSource( ScDrawView* pView );
+ void SetDragSourceObj( SdrObject* pObj, SCTAB nTab );
+ void SetDragSourceFlags( USHORT nFlags );
+ void SetDragWasInternal();
+
+ SdrView* GetDragSourceView() { return pDragSourceView; }
+ USHORT GetDragSourceFlags() const { return nDragSourceFlags; }
+
+ void SetSourceDocID( sal_uInt32 nVal )
+ { nSourceDocID = nVal; }
+ sal_uInt32 GetSourceDocID() const { return nSourceDocID; }
+
+ static ScDrawTransferObj* GetOwnClipboard( Window* pUIWin );
+ virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException );
+ static const com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/dwfunctr.hxx b/sc/source/ui/inc/dwfunctr.hxx
new file mode 100644
index 000000000000..6522e335854e
--- /dev/null
+++ b/sc/source/ui/inc/dwfunctr.hxx
@@ -0,0 +1,154 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SC_DWFUNCTR_HXX
+#define _SC_DWFUNCTR_HXX
+
+#include <sfx2/childwin.hxx>
+#include <sfx2/dockwin.hxx>
+#include <svl/lstner.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/imagebtn.hxx>
+
+#include <vcl/combobox.hxx>
+#include "anyrefdg.hxx"
+#include "global.hxx" // ScAddress
+#include "privsplt.hxx"
+#include "funcdesc.hxx"
+
+#ifndef LRU_MAX
+#define LRU_MAX 10
+#endif
+/*************************************************************************
+|*
+|* Ableitung vom SfxChildWindow als "Behaelter" fuer Controller
+|*
+\************************************************************************/
+
+class ScFunctionChildWindow : public SfxChildWindow
+{
+ public:
+ ScFunctionChildWindow( Window*, USHORT, SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW(ScFunctionChildWindow);
+};
+
+/*************************************************************************
+|*
+|* ScFuncDockWin
+|*
+\************************************************************************/
+
+class ScFunctionDockWin : public SfxDockingWindow, public SfxListener
+{
+
+private:
+ Timer aTimer;
+ ScPrivatSplit aPrivatSplit;
+ ListBox aCatBox;
+ ListBox aFuncList;
+ ListBox aDDFuncList;
+ ListBox* pAllFuncList;
+
+ SfxChildAlignment eSfxNewAlignment;
+ SfxChildAlignment eSfxOldAlignment;
+ ImageButton aInsertButton;
+ FixedText aFiFuncDesc;
+ USHORT nLeftSlot;
+ USHORT nRightSlot;
+ ULONG nMinWidth;
+ ULONG nMinHeight;
+ Size aOldSize;
+ BOOL bSizeFlag;
+ BOOL bInit;
+ short nDockMode;
+ Point aSplitterInitPos;
+ const ScFuncDesc* pFuncDesc;
+ USHORT nArgs;
+ String** pArgArr;
+
+
+ const ScFuncDesc* aLRUList[LRU_MAX];
+
+ void UpdateFunctionList();
+ void UpdateLRUList();
+ void DoEnter(BOOL bOk); //@@ ???
+ void SetDescription();
+ void SetLeftRightSize();
+ void SetTopBottonSize();
+ void SetMyWidthLeRi(Size &aNewSize);
+ void SetMyHeightLeRi(Size &aNewSize);
+ void SetMyWidthToBo(Size &aNewSize);
+ void SetMyHeightToBo(Size &aNewSize);
+ void UseSplitterInitPos();
+
+ DECL_LINK( SetSelectionHdl, void* );
+ DECL_LINK( SelHdl, ListBox* );
+ DECL_LINK(SetSplitHdl,ScPrivatSplit*);
+ DECL_LINK( TimerHdl, Timer*);
+
+protected:
+
+ virtual BOOL Close();
+ virtual void Resize();
+ virtual void Resizing( Size& rSize );
+ virtual void SetSize();
+ virtual void ToggleFloatingMode();
+ virtual void StateChanged( StateChangedType nStateChange );
+
+
+ virtual SfxChildAlignment CheckAlignment(SfxChildAlignment,
+ SfxChildAlignment eAlign);
+
+public:
+ ScFunctionDockWin( SfxBindings* pBindings,
+ SfxChildWindow *pCW,
+ Window* pParent,
+ const ResId& rResId );
+
+ ~ScFunctionDockWin();
+
+ using SfxDockingWindow::Notify;
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ void SetSlotIDs( USHORT nLeft, USHORT nRight )
+ { nLeftSlot = nLeft; nRightSlot = nRight; }
+
+ void InitLRUList();
+
+ void Initialize (SfxChildWinInfo* pInfo);
+ virtual void FillInfo(SfxChildWinInfo&) const;
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/editable.hxx b/sc/source/ui/inc/editable.hxx
new file mode 100644
index 000000000000..d09a9bc54322
--- /dev/null
+++ b/sc/source/ui/inc/editable.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_EDITABLE_HXX
+#define SC_EDITABLE_HXX
+
+#include "address.hxx"
+#include <tools/solar.h>
+
+class ScDocument;
+class ScViewFunc;
+class ScMarkData;
+class ScRange;
+
+
+class ScEditableTester
+{
+ BOOL bIsEditable;
+ BOOL bOnlyMatrix;
+
+public:
+ // no test in ctor
+ ScEditableTester();
+
+ // calls TestBlock
+ ScEditableTester( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
+
+ // calls TestSelectedBlock
+ ScEditableTester( ScDocument* pDoc,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ const ScMarkData& rMark );
+
+ // calls TestRange
+ ScEditableTester( ScDocument* pDoc, const ScRange& rRange );
+
+ // calls TestSelection
+ ScEditableTester( ScDocument* pDoc, const ScMarkData& rMark );
+
+ // calls TestView
+ ScEditableTester( ScViewFunc* pView );
+
+ ~ScEditableTester() {}
+
+ // Several calls to the Test... methods check if *all* of the ranges
+ // are editable. For several independent checks, Reset() has to be used.
+ void TestBlock( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
+ void TestSelectedBlock( ScDocument* pDoc,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ const ScMarkData& rMark );
+ void TestRange( ScDocument* pDoc, const ScRange& rRange );
+ void TestSelection( ScDocument* pDoc, const ScMarkData& rMark );
+ void TestView( ScViewFunc* pView );
+
+ BOOL IsEditable() const { return bIsEditable; }
+ BOOL IsFormatEditable() const { return bIsEditable || bOnlyMatrix; }
+ USHORT GetMessageId() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/editfield.hxx b/sc/source/ui/inc/editfield.hxx
new file mode 100644
index 000000000000..f48fb48eaaed
--- /dev/null
+++ b/sc/source/ui/inc/editfield.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_EDITFIELD_HXX
+#define SC_EDITFIELD_HXX
+
+#include <vcl/field.hxx>
+
+// ============================================================================
+
+/** An edit control that contains a double precision floating-point value. */
+class ScDoubleField : public Edit
+{
+public:
+ explicit ScDoubleField( Window* pParent, const ResId& rResId );
+
+ bool GetValue( double& rfValue ) const;
+ void SetValue( double fValue,
+ sal_Int32 nDecPlaces = 12,
+ bool bEraseTrailingDecZeros = true );
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/editsh.hxx b/sc/source/ui/inc/editsh.hxx
new file mode 100644
index 000000000000..a90967cb3804
--- /dev/null
+++ b/sc/source/ui/inc/editsh.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_EDITSH_HXX
+#define SC_EDITSH_HXX
+
+#include <sfx2/shell.hxx>
+#include <sfx2/module.hxx>
+#include <tools/link.hxx>
+
+#include "shellids.hxx"
+#include <editeng/editview.hxx>
+
+class EditView;
+class ScViewData;
+class ScInputHandler;
+class SvxURLField;
+class TransferableDataHelper;
+class TransferableClipboardListener;
+
+class ScEditShell : public SfxShell
+{
+private:
+ EditView* pEditView;
+ ScViewData* pViewData;
+ TransferableClipboardListener* pClipEvtLstnr;
+ BOOL bPastePossible;
+ BOOL bIsInsertMode;
+
+ const SvxURLField* GetURLField();
+ ScInputHandler* GetMyInputHdl();
+
+ DECL_LINK( ClipboardChanged, TransferableDataHelper* );
+
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_EDIT_SHELL)
+
+ ScEditShell(EditView* pView, ScViewData* pData);
+ ~ScEditShell();
+
+ void SetEditView(EditView* pView);
+ EditView* GetEditView() {return pEditView;}
+
+ void Execute(SfxRequest& rReq);
+ void ExecuteTrans(SfxRequest& rReq);
+ void GetState(SfxItemSet &rSet);
+ void GetClipState(SfxItemSet& rSet);
+
+ void ExecuteAttr(SfxRequest& rReq);
+ void GetAttrState(SfxItemSet &rSet);
+
+ void ExecuteUndo(SfxRequest& rReq);
+ void GetUndoState(SfxItemSet &rSet);
+
+ String GetSelectionText( BOOL bWholeWord );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/expftext.hxx b/sc/source/ui/inc/expftext.hxx
new file mode 100644
index 000000000000..2fec3026780b
--- /dev/null
+++ b/sc/source/ui/inc/expftext.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SC_EXPFTEXT_HXX
+#define _SC_EXPFTEXT_HXX
+
+#include <vcl/fixed.hxx>
+#include "scdllapi.h"
+
+class SC_DLLPUBLIC ScExpandedFixedText: public FixedText
+{
+ protected:
+
+ void RequestHelp( const HelpEvent& rHEvt );
+
+ public:
+ ScExpandedFixedText( Window* pWindow, const ResId& rResId);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fieldwnd.hxx b/sc/source/ui/inc/fieldwnd.hxx
new file mode 100644
index 000000000000..bcad1a4d2e4c
--- /dev/null
+++ b/sc/source/ui/inc/fieldwnd.hxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FIELDWND_HXX
+#define SC_FIELDWND_HXX
+
+#include <vector>
+#include "address.hxx"
+#include <vcl/ctrl.hxx>
+#include <vcl/fixed.hxx>
+#include <cppuhelper/weakref.hxx>
+
+#define PAGE_SIZE 16 // count of visible fields for scrollbar
+#define LINE_SIZE 8 // count of fields per column for scrollbar
+#define MAX_FIELDS 8 // maximum count of fields for row/col/data area
+#define MAX_PAGEFIELDS 10 // maximum count of fields for page area
+
+#define OWIDTH PivotGlobal::nObjWidth
+#define OHEIGHT PivotGlobal::nObjHeight
+#define SSPACE PivotGlobal::nSelSpace
+
+class ScDPLayoutDlg;
+class ScAccessibleDataPilotControl;
+
+//===================================================================
+
+/** Type of content area. */
+enum ScDPFieldType
+{
+ TYPE_PAGE, /// Area for all page fields.
+ TYPE_ROW, /// Area for all row fields.
+ TYPE_COL, /// Area for all column fields.
+ TYPE_DATA, /// Area for all data fields.
+ TYPE_SELECT /// Selection area with all fields.
+};
+
+//-------------------------------------------------------------------
+
+/** Represents a field area in the DataPilot layout dialog. */
+class ScDPFieldWindow : public Control
+{
+private:
+ typedef ::std::pair< String, bool > FieldString; // true = text fits into button
+
+ String aName; /// name of the control, used in Accessibility
+ ScDPLayoutDlg* pDlg; /// Parent dialog.
+ Rectangle aWndRect; /// Area rectangle in pixels.
+ FixedText* pFtCaption; /// FixedText containing the name of the control.
+ Point aTextPos; /// Position of the caption text.
+ std::vector< FieldString > aFieldArr; /// String array of the field names and flags, if text fits into button.
+ ScDPFieldType eType; /// Type of this area.
+ Color aFaceColor; /// Color for dialog background.
+ Color aWinColor; /// Color for window background.
+ Color aTextColor; /// Color for text in buttons.
+ Color aWinTextColor; /// Color for text in field windows.
+ size_t nFieldSize; /// Maximum count of fields.
+ size_t nFieldSelected; /// Currently selected field.
+
+ com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > xAccessible;
+ ScAccessibleDataPilotControl* pAccessible;
+
+ /** Initilize the object. */
+ void Init();
+
+ /** Reads all needed style settings. */
+ void GetStyleSettings();
+
+ /** Draws the background. */
+ void DrawBackground( OutputDevice& rDev );
+ /** Draws a field into the specified rectangle. */
+ void DrawField(
+ OutputDevice& rDev,
+ const Rectangle& rRect,
+ FieldString& rText,
+ bool bFocus );
+
+ /** @return TRUE, if the field index is inside of the control area. */
+ bool IsValidIndex( size_t nIndex ) const;
+ /** @return TRUE, if the field with the given index exists. */
+ bool IsExistingIndex( size_t nIndex ) const;
+ /** @return TRUE, if the field with the given index exists and the text is
+ too long for the button control. */
+ bool IsShortenedText( size_t nIndex ) const;
+ /** @return The new selection index after moving to the given direction. */
+ size_t CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const;
+
+ /** Sets selection to the field with index nIndex. */
+ void SetSelection( size_t nIndex );
+ /** Sets selection to first field. */
+ void SetSelectionHome();
+ /** Sets selection to last field. */
+ void SetSelectionEnd();
+ /** Sets selection to new position relative to current. */
+ void MoveSelection( USHORT nKeyCode, SCsCOL nDX, SCsROW nDY );
+
+ /** Moves the selected field to nDestIndex. */
+ void MoveField( size_t nDestIndex );
+ /** Moves the selected field to the given direction. */
+ void MoveFieldRel( SCsCOL nDX, SCsROW nDY );
+
+ /** Updates the tab stop style bits. */
+ void UpdateStyle();
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+public:
+ ScDPFieldWindow(
+ ScDPLayoutDlg* pDialog,
+ const ResId& rResId,
+ ScDPFieldType eFieldType,
+ FixedText* pFtFieldCaption );
+ ScDPFieldWindow(
+ ScDPLayoutDlg* pDialog,
+ const ResId& rResId,
+ ScDPFieldType eFieldType,
+ const String& aName );
+ virtual ~ScDPFieldWindow();
+
+ /** Reads the FixedText's text with mnemonic and hides the FixedText. */
+ void UseMnemonic();
+
+ /** Draws the complete control. */
+ void Redraw();
+
+ /** @return The pixel position of a field (without bound check). */
+ Point GetFieldPosition( size_t nIndex ) const;
+ /** @return The pixel size of a field. */
+ Size GetFieldSize() const;
+
+ /** @return The index of the selected field. */
+ inline bool IsEmpty() const { return aFieldArr.empty(); }
+ /** @return The index of the selected field. */
+ inline size_t GetSelectedField() const { return nFieldSelected; }
+ /** @return The pixel position of the last possible field. */
+ Point GetLastPosition() const;
+
+ /** @return The count of existing fields. */
+ inline size_t GetFieldCount() const { return aFieldArr.size(); }
+ /** Inserts a field to the specified index. */
+ void AddField( const String& rText, size_t nNewIndex );
+ /** Removes a field from the specified index. */
+ void DelField( size_t nDelIndex );
+ /** Removes all fields. */
+ void ClearFields();
+ /** Changes the text on an existing field. */
+ void SetFieldText( const String& rText, size_t nIndex );
+ /** Returns the text of an existing field. */
+ const String& GetFieldText( size_t nIndex ) const;
+
+ /** Inserts a field using the specified pixel position.
+ @param rPos The coordinates to insert the field.
+ @param rnIndex The new index of the field is returned here.
+ @return TRUE, if the field has been created. */
+ bool AddField( const String& rText, const Point& rPos, size_t& rnIndex );
+ /** Calculates the field index at a specific pixel position.
+ @param rnIndex The index of the field is returned here.
+ @return TRUE, if the index value is valid. */
+ bool GetFieldIndex( const Point& rPos, size_t& rnIndex ) const;
+ /** Calculates a field index at a specific pixel position. Returns in every
+ case the index of an existing field.
+ @param rnIndex The index of the field is returned here.
+ @return TRUE, if the index value is valid. */
+ void GetExistingIndex( const Point& rPos, size_t& rnIndex );
+
+ /** Notifies this control that the offset of the first field has been changed.
+ The control has to adjust the selection to keep the same field selected
+ on scrolling with scrollbar. */
+ void ModifySelectionOffset( long nOffsetDiff );
+ /** Selects the next field. Called i.e. after moving a field from SELECT area. */
+ void SelectNext();
+
+ /** @return The name of the control without shortcut. */
+ inline String GetName() const { return aName; }
+
+ /** @return The description of the control which is used for the accessibility objects. */
+ String GetDescription() const;
+
+ /** Grabs focus and sets new selection. */
+ void GrabFocusWithSel( size_t nIndex );
+
+ /** @return The type of the FieldWindow. */
+ inline ScDPFieldType GetType() const { return eType; }
+};
+
+//===================================================================
+
+#endif // SC_FIELDWND_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/filldlg.hxx b/sc/source/ui/inc/filldlg.hxx
new file mode 100644
index 000000000000..e32a17659029
--- /dev/null
+++ b/sc/source/ui/inc/filldlg.hxx
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FILLDLG_HXX
+#define SC_FILLDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include "global.hxx"
+
+class ScDocument;
+
+//----------------------------------------------------------------------------
+
+#include "scui_def.hxx"
+//============================================================================
+
+class ScFillSeriesDlg : public ModalDialog
+{
+public:
+ ScFillSeriesDlg( Window* pParent,
+ ScDocument& rDocument,
+ FillDir eFillDir,
+ FillCmd eFillCmd,
+ FillDateCmd eFillDateCmd,
+ String aStartStr,
+ double fStep,
+ double fMax,
+ USHORT nPossDir );
+ ~ScFillSeriesDlg();
+
+ FillDir GetFillDir() const { return theFillDir; }
+ FillCmd GetFillCmd() const { return theFillCmd; }
+ FillDateCmd GetFillDateCmd() const { return theFillDateCmd; }
+ double GetStart() const { return fStartVal; }
+ double GetStep() const { return fIncrement; }
+ double GetMax() const { return fEndVal; }
+
+ String GetStartStr() const { return aEdStartVal.GetText(); }
+
+ void SetEdStartValEnabled(BOOL bFlag=FALSE);
+
+private:
+ FixedLine aFlDirection;
+ RadioButton aBtnDown;
+ RadioButton aBtnRight;
+ RadioButton aBtnUp;
+ RadioButton aBtnLeft;
+
+ FixedLine aFlSep1;
+ FixedLine aFlType;
+ RadioButton aBtnArithmetic;
+ RadioButton aBtnGeometric;
+ RadioButton aBtnDate;
+ RadioButton aBtnAutoFill;
+
+ FixedLine aFlSep2;
+ FixedLine aFlTimeUnit;
+ RadioButton aBtnDay;
+ RadioButton aBtnDayOfWeek;
+ RadioButton aBtnMonth;
+ RadioButton aBtnYear;
+
+ BOOL bStartValFlag;
+ FixedText aFtStartVal;
+ Edit aEdStartVal;
+ String aStartStrVal;
+
+ FixedText aFtEndVal;
+ Edit aEdEndVal;
+
+ FixedText aFtIncrement;
+ Edit aEdIncrement;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ const String errMsgInvalidVal;
+
+ //----------------------------------------------------------
+
+ ScDocument& rDoc;
+ FillDir theFillDir;
+ FillCmd theFillCmd;
+ FillDateCmd theFillDateCmd;
+ double fStartVal;
+ double fIncrement;
+ double fEndVal;
+
+#ifdef _FILLDLG_CXX
+private:
+ void Init( USHORT nPossDir );
+ BOOL CheckStartVal();
+ BOOL CheckIncrementVal();
+ BOOL CheckEndVal();
+
+ DECL_LINK( OKHdl, void * );
+ DECL_LINK( DisableHdl, Button * );
+#endif
+};
+
+
+
+#endif // SC_FILLDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx
new file mode 100644
index 000000000000..1088de59fa00
--- /dev/null
+++ b/sc/source/ui/inc/filtdlg.hxx
@@ -0,0 +1,263 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FILTDLG_HXX
+#define SC_FILTDLG_HXX
+
+#include <vcl/morebtn.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/stdctrl.hxx>
+#include "global.hxx" // -> ScQueryParam
+#include "address.hxx"
+#include "anyrefdg.hxx"
+
+
+//----------------------------------------------------------------------------
+
+class ScFilterOptionsMgr;
+class ScRangeData;
+class ScViewData;
+class ScDocument;
+class ScQueryItem;
+class TypedScStrCollection;
+
+//==================================================================
+// Gemeinsame Resource-Objekte:
+
+#define _COMMON_FILTER_RSCOBJS \
+ CheckBox aBtnCase; \
+ CheckBox aBtnRegExp; \
+ CheckBox aBtnHeader; \
+ CheckBox aBtnUnique; \
+ CheckBox aBtnCopyResult; \
+ ListBox aLbCopyArea; \
+ formula::RefEdit aEdCopyArea; \
+ formula::RefButton aRbCopyArea; \
+ CheckBox aBtnDestPers; \
+ FixedText aFtDbAreaLabel; \
+ FixedInfo aFtDbArea; \
+ const String aStrUndefined; \
+ const String aStrNoName; \
+ const String aStrNone;
+
+
+#define _INIT_COMMON_FILTER_RSCOBJS \
+ aBtnCase ( this, ScResId( BTN_CASE ) ), \
+ aBtnRegExp ( this, ScResId( BTN_REGEXP ) ), \
+ aBtnHeader ( this, ScResId( BTN_HEADER ) ), \
+ aBtnUnique ( this, ScResId( BTN_UNIQUE ) ), \
+ aBtnCopyResult ( this, ScResId( BTN_COPY_RESULT ) ), \
+ aLbCopyArea ( this, ScResId( LB_COPY_AREA ) ), \
+ aEdCopyArea ( this, this, ScResId( ED_COPY_AREA ) ), \
+ aRbCopyArea ( this, ScResId( RB_COPY_AREA ), &aEdCopyArea, this ), \
+ aBtnDestPers ( this, ScResId( BTN_DEST_PERS ) ), \
+ aFtDbAreaLabel ( this, ScResId( FT_DBAREA_LABEL ) ), \
+ aFtDbArea ( this, ScResId( FT_DBAREA ) ), \
+ aStrUndefined ( ScResId( SCSTR_UNDEFINED ) ), \
+ aStrNoName ( ScGlobal::GetRscString(STR_DB_NONAME) ), \
+ aStrNone ( ScResId( SCSTR_NONE ) ),
+
+
+//============================================================================
+class ScFilterDlg : public ScAnyRefDlg
+{
+public:
+ ScFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScFilterDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+
+ virtual BOOL Close();
+ void SliderMoved();
+ USHORT GetSliderPos();
+ void RefreshEditRow( USHORT nOffset );
+
+private:
+ FixedLine aFlCriteria;
+ //----------------------------
+ ListBox aLbConnect1;
+ ListBox aLbField1;
+ ListBox aLbCond1;
+ ComboBox aEdVal1;
+ //----------------------------
+ ListBox aLbConnect2;
+ ListBox aLbField2;
+ ListBox aLbCond2;
+ ComboBox aEdVal2;
+ //----------------------------
+ ListBox aLbConnect3;
+ ListBox aLbField3;
+ ListBox aLbCond3;
+ ComboBox aEdVal3;
+ //----------------------------
+ ListBox aLbConnect4;
+ ListBox aLbField4;
+ ListBox aLbCond4;
+ ComboBox aEdVal4;
+ //----------------------------
+ FixedText aFtConnect;
+ FixedText aFtField;
+ FixedText aFtCond;
+ FixedText aFtVal;
+ FixedLine aFlSeparator;
+
+ ScrollBar aScrollBar;
+
+ FixedLine aFlOptions;
+ MoreButton aBtnMore;
+ HelpButton aBtnHelp;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+
+ _COMMON_FILTER_RSCOBJS
+
+ const String aStrEmpty;
+ const String aStrNotEmpty;
+ const String aStrRow;
+ const String aStrColumn;
+
+ ScFilterOptionsMgr* pOptionsMgr;
+
+ const USHORT nWhichQuery;
+ const ScQueryParam theQueryData;
+ ScQueryItem* pOutItem;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ SCTAB nSrcTab;
+
+ ComboBox* aValueEdArr[4];
+ ListBox* aFieldLbArr[4];
+ ListBox* aCondLbArr[4];
+ ListBox* aConnLbArr[4];
+ bool mbHasDates[MAXQUERY];
+ BOOL bRefreshExceptQuery[MAXQUERY];
+ USHORT nFieldCount;
+ BOOL bRefInputMode;
+
+ TypedScStrCollection* pEntryLists[MAXCOLCOUNT];
+ USHORT nHeaderPos[MAXCOLCOUNT];
+
+ // Hack: RefInput-Kontrolle
+ Timer* pTimer;
+
+#ifdef _FILTDLG_CXX
+private:
+ void Init ( const SfxItemSet& rArgSet );
+ void FillFieldLists ();
+ void FillAreaList ();
+ void UpdateValueList ( USHORT nList );
+ void UpdateHdrInValueList( USHORT nList );
+ void ClearValueList ( USHORT nList );
+ USHORT GetFieldSelPos ( SCCOL nField );
+ ScQueryItem* GetOutputItem ();
+
+ // Handler:
+ DECL_LINK( LbSelectHdl, ListBox* );
+ DECL_LINK( ValModifyHdl, ComboBox* );
+ DECL_LINK( CheckBoxHdl, CheckBox* );
+ DECL_LINK( EndDlgHdl, Button* );
+ DECL_LINK( MoreClickHdl, MoreButton* );
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+ // Hack: RefInput-Kontrolle
+ DECL_LINK( TimeOutHdl, Timer* );
+#endif
+};
+
+
+//============================================================================
+class ScSpecialFilterDlg : public ScAnyRefDlg
+{
+public:
+ ScSpecialFilterDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScSpecialFilterDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+
+ virtual BOOL Close();
+
+private:
+ ListBox aLbFilterArea;
+ FixedText aFtFilterArea;
+ formula::RefEdit aEdFilterArea;
+ formula::RefButton aRbFilterArea;
+
+ FixedLine aFlOptions;
+
+ _COMMON_FILTER_RSCOBJS
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ MoreButton aBtnMore;
+
+ ScFilterOptionsMgr* pOptionsMgr;
+
+ const USHORT nWhichQuery;
+ const ScQueryParam theQueryData;
+ ScQueryItem* pOutItem;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+
+ formula::RefEdit* pRefInputEdit;
+ BOOL bRefInputMode;
+
+ // Hack: RefInput-Kontrolle
+ Timer* pTimer;
+
+#ifdef _SFILTDLG_CXX
+private:
+ void Init( const SfxItemSet& rArgSet );
+ ScQueryItem* GetOutputItem( const ScQueryParam& rParam,
+ const ScRange& rSource );
+
+ // Handler
+ DECL_LINK( FilterAreaSelHdl, ListBox* );
+ DECL_LINK( FilterAreaModHdl, formula::RefEdit* );
+ DECL_LINK( EndDlgHdl, Button* );
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+ // Hack: RefInput-Kontrolle
+ DECL_LINK( TimeOutHdl, Timer* );
+#endif
+};
+
+
+
+#endif // SC_FILTDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/filter.hrc b/sc/source/ui/inc/filter.hrc
new file mode 100644
index 000000000000..9d708c9799c5
--- /dev/null
+++ b/sc/source/ui/inc/filter.hrc
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc" // -> RID_SCDLG_FILTER
+ // -> RID_SCDLG_SPEC_FILTER
+ // -> RID_SCDLG_PIVOTFILTER
+
+// allgemein
+
+#define BTN_OK 1
+#define BTN_CANCEL 1
+#define BTN_HELP 1
+#define BTN_MORE 1
+
+#define BTN_UNIQUE 1
+#define BTN_CASE 2
+#define BTN_REGEXP 3
+#define BTN_HEADER 4
+#define BTN_COPY_RESULT 5
+#define LB_COPY_AREA 6
+#define ED_COPY_AREA 7
+#define RB_COPY_AREA 8
+#define FL_OPTIONS 9
+#define FT_DBAREA_LABEL 10
+#define FT_DBAREA 11
+#define BTN_DEST_PERS 12
+
+// Filter:
+#define FT_OP 20
+#define FT_FIELD 21
+#define FT_COND 22
+#define FT_VAL 23
+#define LB_FIELD1 24
+#define LB_FIELD2 25
+#define LB_FIELD3 26
+#define LB_OP1 27
+#define LB_OP2 28
+#define LB_COND1 29
+#define LB_COND2 30
+#define LB_COND3 31
+#define ED_VAL1 32
+#define ED_VAL2 33
+#define ED_VAL3 34
+#define FL_CRITERIA 35
+#define FL_SEPARATOR 36
+#define LB_OP3 37
+#define LB_FIELD4 38
+#define LB_COND4 39
+#define ED_VAL4 40
+#define LB_SCROLL 41
+#define LB_OP4 42
+
+// Spezialfilter
+
+#define FT_CRITERIA_AREA 50
+#define LB_CRITERIA_AREA 51
+#define ED_CRITERIA_AREA 52
+#define RB_CRITERIA_AREA 53
+
diff --git a/sc/source/ui/inc/foptmgr.hxx b/sc/source/ui/inc/foptmgr.hxx
new file mode 100644
index 000000000000..55387daa5763
--- /dev/null
+++ b/sc/source/ui/inc/foptmgr.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FOPTMGR_HXX
+#define SC_FOPTMGR_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+
+//----------------------------------------------------------------------------
+
+class FixedInfo;
+namespace formula
+{
+ class RefButton;
+}
+class MoreButton;
+class Dialog;
+struct ScQueryParam;
+class ScDocument;
+class ScViewData;
+
+//----------------------------------------------------------------------------
+
+class ScFilterOptionsMgr
+{
+public:
+ ScFilterOptionsMgr( Dialog* ptrDlg,
+ ScViewData* ptrViewData,
+ const ScQueryParam& refQueryData,
+ MoreButton& refBtnMore,
+ CheckBox& refBtnCase,
+ CheckBox& refBtnRegExp,
+ CheckBox& refBtnHeader,
+ CheckBox& refBtnUnique,
+ CheckBox& refBtnCopyResult,
+ CheckBox& refBtnDestPers,
+ ListBox& refLbCopyArea,
+ Edit& refEdCopyArea,
+ formula::RefButton& refRbCopyArea,
+ FixedText& refFtDbAreaLabel,
+ FixedInfo& refFtDbArea,
+ FixedLine& refFlOptions,
+ const String& refStrNoName,
+ const String& refStrUndefined );
+ ~ScFilterOptionsMgr();
+
+ BOOL VerifyPosStr ( const String& rPosStr ) const;
+
+private:
+ Dialog* pDlg;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+
+ MoreButton& rBtnMore;
+ CheckBox& rBtnCase;
+ CheckBox& rBtnRegExp;
+ CheckBox& rBtnHeader;
+ CheckBox& rBtnUnique;
+ CheckBox& rBtnCopyResult;
+ CheckBox& rBtnDestPers;
+ ListBox& rLbCopyPos;
+ Edit& rEdCopyPos;
+ formula::RefButton& rRbCopyPos;
+ FixedText& rFtDbAreaLabel;
+ FixedInfo& rFtDbArea;
+ FixedLine& rFlOptions;
+
+ const String& rStrNoName;
+ const String& rStrUndefined;
+
+ const ScQueryParam& rQueryData;
+
+#ifdef _FOPTMGR_CXX
+private:
+ void Init();
+
+ // Handler:
+ DECL_LINK( EdPosModifyHdl, Edit* );
+ DECL_LINK( LbPosSelHdl, ListBox* );
+ DECL_LINK( BtnCopyResultHdl, CheckBox* );
+#endif
+};
+
+
+
+#endif // SC_FOPTMGR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/formatsh.hxx b/sc/source/ui/inc/formatsh.hxx
new file mode 100644
index 000000000000..890e25158dfd
--- /dev/null
+++ b/sc/source/ui/inc/formatsh.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FORMATSH_HXX
+#define SC_FORMATSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+
+class ScViewData;
+
+class ScFormatShell: public SfxShell
+{
+ ScViewData* pViewData;
+
+protected:
+
+ ScViewData* GetViewData(){return pViewData;}
+ const ScViewData* GetViewData() const {return pViewData;}
+
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_FORMAT_SHELL)
+
+ ScFormatShell(ScViewData* pData);
+ virtual ~ScFormatShell();
+
+ void ExecuteNumFormat( SfxRequest& rReq );
+ void GetNumFormatState( SfxItemSet& rSet );
+
+ void ExecuteAttr( SfxRequest& rReq );
+ void GetAttrState( SfxItemSet& rSet );
+
+ void ExecuteAlignment( SfxRequest& rReq );
+
+ void ExecuteTextAttr( SfxRequest& rReq );
+ void GetTextAttrState( SfxItemSet& rSet );
+
+ void GetAlignState( SfxItemSet& rSet );
+ void GetBorderState( SfxItemSet& rSet );
+
+ void ExecuteStyle( SfxRequest& rReq );
+ void GetStyleState( SfxItemSet& rSet );
+
+ void ExecuteTextDirection( SfxRequest& rReq );
+ void GetTextDirectionState( SfxItemSet& rSet );
+
+ void ExecFormatPaintbrush( SfxRequest& rReq );
+ void StateFormatPaintbrush( SfxItemSet& rSet );
+
+private:
+ short GetCurrentNumberFormatType();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/formdata.hxx b/sc/source/ui/inc/formdata.hxx
new file mode 100644
index 000000000000..f5abbf80bccb
--- /dev/null
+++ b/sc/source/ui/inc/formdata.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FORMDATA_HXX
+#define SC_FORMDATA_HXX
+
+#include <tools/string.hxx>
+#include <tools/gen.hxx>
+#include <formula/formdata.hxx>
+class ScInputHandler;
+class ScDocShell;
+
+//============================================================================
+
+class ScFormEditData : public formula::FormEditData
+{
+public:
+ ScFormEditData();
+ virtual ~ScFormEditData();
+
+ ScInputHandler* GetInputHandler() { return pInputHandler;}
+ ScDocShell* GetDocShell() { return pScDocShell;}
+
+ void SetInputHandler(ScInputHandler* pHdl) { pInputHandler=pHdl;}
+ void SetDocShell(ScDocShell* pSds) { pScDocShell=pSds;}
+
+
+ virtual void SaveValues();
+
+private:
+ ScFormEditData( const ScFormEditData& );
+// const ScFormEditData& operator=( const ScFormEditData& r );
+
+
+ ScInputHandler* pInputHandler;
+ ScDocShell* pScDocShell;
+};
+
+
+
+#endif // SC_CRNRDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/formula.hxx b/sc/source/ui/inc/formula.hxx
new file mode 100644
index 000000000000..168c07bccb90
--- /dev/null
+++ b/sc/source/ui/inc/formula.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FORMULA_HXX
+#define SC_FORMULA_HXX
+
+#include "anyrefdg.hxx"
+#include "global.hxx" // ScAddress
+#include <svtools/stdctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/tabpage.hxx>
+
+#ifndef _SVSTDARR_STRINGS
+
+#define _SVSTDARR_STRINGS
+#include <svl/svstdarr.hxx>
+
+#endif
+#include "compiler.hxx"
+#include "cell.hxx"
+
+#include "formula/formula.hxx"
+#include "IAnyRefDialog.hxx"
+#include "anyrefdg.hxx"
+#include <formula/IFunctionDescription.hxx>
+
+class ScViewData;
+class ScDocument;
+class ScFuncDesc;
+class ScInputHandler;
+class ScDocShell;
+class SvLBoxEntry;
+
+//============================================================================
+typedef ScTabViewShell* PtrTabViewShell;
+//============================================================================
+
+class ScFormulaDlg : public formula::FormulaDlg,
+ public IAnyRefDialog,
+ public formula::IFormulaEditorHelper
+{
+ ScFormulaReferenceHelper m_aHelper;
+ ScFormulaCell* pCell;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> m_xParser;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> m_xOpCodeMapper;
+
+ static ScDocument* pDoc;
+ static ScAddress aCursorPos;
+public:
+ ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
+ Window* pParent, ScViewData* pViewData ,formula::IFunctionManager* _pFunctionMgr);
+ ~ScFormulaDlg();
+
+ // IFormulaEditorHelper
+ virtual void notifyChange();
+ virtual void fill();
+ virtual bool calculateValue(const String& _sExpression,String& _rResult);
+ virtual void doClose(BOOL _bOk);
+ virtual void insertEntryToLRUList(const formula::IFunctionDescription* pDesc);
+ virtual void showReference(const String& _sFormula);
+ virtual void dispatch(BOOL _bOK,BOOL _bMartixChecked);
+ virtual void setDispatcherLock( BOOL bLock );
+ virtual void setReferenceInput(const formula::FormEditData* _pData);
+ virtual void deleteFormData();
+ virtual void clear();
+ virtual void switchBack();
+ virtual formula::FormEditData* getFormEditData() const;
+ virtual void setCurrentFormula(const String& _sReplacement);
+ virtual void setSelection(xub_StrLen _nStart,xub_StrLen _nEnd);
+ virtual void getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const;
+ virtual String getCurrentFormula() const;
+
+ virtual formula::IFunctionManager* getFunctionManager();
+ virtual ::std::auto_ptr<formula::FormulaTokenArray> convertToTokenArray(const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::FormulaToken >& _aTokenList);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaParser> getFormulaParser() const;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XFormulaOpCodeMapper> getFormulaOpCodeMapper() const;
+ virtual ::com::sun::star::table::CellAddress getReferencePosition() const;
+
+ virtual BOOL Close();
+
+ // sc::IAnyRefDialog
+ virtual void ShowReference(const String& _sRef);
+ virtual void HideReference( BOOL bDoneRefMode = TRUE );
+ virtual void SetReference( const ScRange& rRef, ScDocument* pD );
+
+ virtual void ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ virtual void ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ virtual void RefInputDone( BOOL bForced = FALSE );
+ virtual BOOL IsTableLocked() const;
+ virtual BOOL IsRefInputMode() const;
+
+ virtual BOOL IsDocAllowed( SfxObjectShell* pDocSh ) const;
+ virtual void AddRefEntry();
+ virtual void SetActive();
+ virtual void ViewShellChanged( ScTabViewShell* pScViewShell );
+protected:
+
+ virtual void RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton = NULL );
+ ULONG FindFocusWin(Window *pWin);
+ void SaveLRUEntry(const ScFuncDesc* pFuncDesc);
+ void HighlightFunctionParas(const String& aFormula);
+
+ BOOL IsInputHdl(ScInputHandler* pHdl);
+ ScInputHandler* GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh);
+};
+
+
+
+#endif // SC_CRNRDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconarc.hxx b/sc/source/ui/inc/fuconarc.hxx
new file mode 100644
index 000000000000..40ebb26b241a
--- /dev/null
+++ b/sc/source/ui/inc/fuconarc.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUCONARC_HXX
+#define SC_FUCONARC_HXX
+
+#include "fuconstr.hxx"
+
+/*************************************************************************
+|*
+|* Rechteck zeichnen
+|*
+\************************************************************************/
+
+class FuConstArc : public FuConstruct
+{
+ public:
+ FuConstArc( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuConstArc();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
+};
+
+
+
+#endif // _SD_FUCONARC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconcustomshape.hxx b/sc/source/ui/inc/fuconcustomshape.hxx
new file mode 100644
index 000000000000..e01242eae2b2
--- /dev/null
+++ b/sc/source/ui/inc/fuconcustomshape.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUCONCUSTOMSHAPE_HXX
+#define SC_FUCONCUSTOMSHAPE_HXX
+
+#include "fuconstr.hxx"
+
+class FuConstCustomShape : public FuConstruct
+{
+ rtl::OUString aCustomShape;
+
+ void SetAttributes( SdrObject* pObj );
+
+public:
+ FuConstCustomShape(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuConstCustomShape();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject( const sal_uInt16 nID, const Rectangle& rRectangle );
+
+ // #i33136#
+ virtual bool doConstructOrthogonal() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconpol.hxx b/sc/source/ui/inc/fuconpol.hxx
new file mode 100644
index 000000000000..95ad7b6af87a
--- /dev/null
+++ b/sc/source/ui/inc/fuconpol.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUCONPOL_HXX
+#define SC_FUCONPOL_HXX
+
+#include "fuconstr.hxx"
+
+/*************************************************************************
+|*
+|* Basisklasse fuer alle Funktionen
+|*
+\************************************************************************/
+
+class FuConstPolygon : public FuConstruct
+{
+ Point aLastPos;
+
+ public:
+ FuConstPolygon(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuConstPolygon();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
+};
+
+
+#endif // _FUCONPOL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconrec.hxx b/sc/source/ui/inc/fuconrec.hxx
new file mode 100644
index 000000000000..724cf4fd6550
--- /dev/null
+++ b/sc/source/ui/inc/fuconrec.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUCONREC_HXX
+#define SC_FUCONREC_HXX
+
+#include "fuconstr.hxx"
+
+/*************************************************************************
+|*
+|* Rechteck zeichnen
+|*
+\************************************************************************/
+
+class FuConstRectangle : public FuConstruct
+{
+ public:
+ FuConstRectangle(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuConstRectangle();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
+};
+
+
+
+#endif // _SD_FUCONREC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconstr.hxx b/sc/source/ui/inc/fuconstr.hxx
new file mode 100644
index 000000000000..bda74eec7753
--- /dev/null
+++ b/sc/source/ui/inc/fuconstr.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUCONSTR_HXX
+#define SC_FUCONSTR_HXX
+
+#include "fudraw.hxx"
+
+
+/************************************************************************/
+
+#define MIN_FREEHAND_DISTANCE 10
+
+
+/*************************************************************************
+|*
+|* Rechteck zeichnen
+|*
+\************************************************************************/
+
+class FuConstruct : public FuDraw
+{
+ public:
+ FuConstruct(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuConstruct();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+ virtual BYTE Command(const CommandEvent& rCEvt);
+
+ BOOL SimpleMouseButtonUp(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+};
+
+
+
+#endif // _SD_FUCONSTR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuconuno.hxx b/sc/source/ui/inc/fuconuno.hxx
new file mode 100644
index 000000000000..bc68a5825eb2
--- /dev/null
+++ b/sc/source/ui/inc/fuconuno.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUCONUNO_HXX
+#define SC_FUCONUNO_HXX
+
+#include "fuconstr.hxx"
+
+
+/*************************************************************************
+|*
+|* Control zeichnen
+|*
+\************************************************************************/
+
+class FuConstUnoControl : public FuConstruct
+{
+protected:
+ UINT32 nInventor;
+ UINT16 nIdentifier;
+
+public:
+ FuConstUnoControl(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuConstUnoControl();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
+};
+
+
+
+#endif // _SD_FUCONCTL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fudraw.hxx b/sc/source/ui/inc/fudraw.hxx
new file mode 100644
index 000000000000..7ab6415cef42
--- /dev/null
+++ b/sc/source/ui/inc/fudraw.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUDRAW_HXX
+#define SC_FUDRAW_HXX
+
+#include "fupoor.hxx"
+#include <vcl/pointr.hxx>
+
+/*************************************************************************
+|*
+|* Basisklasse fuer alle Drawmodul-spezifischen Funktionen
+|*
+\************************************************************************/
+
+class FuDraw : public FuPoor
+{
+ protected:
+ Pointer aNewPointer;
+ Pointer aOldPointer;
+
+ public:
+ FuDraw(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuDraw();
+
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+
+ virtual void ScrollStart();
+ virtual void ScrollEnd();
+
+ virtual void Activate();
+ virtual void Deactivate();
+
+ virtual void ForcePointer(const MouseEvent* pMEvt);
+
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ // #97016# II
+ virtual void SelectionHasChanged();
+
+ BOOL IsSizingOrMovingNote( const MouseEvent& rMEvt ) const;
+
+ private:
+ void DoModifiers(const MouseEvent& rMEvt);
+ void ResetModifiers();
+};
+
+
+
+#endif // _SD_FUDRAW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuedipo.hxx b/sc/source/ui/inc/fuedipo.hxx
new file mode 100644
index 000000000000..8e3bed4150b6
--- /dev/null
+++ b/sc/source/ui/inc/fuedipo.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUEDIPO_HXX
+#define SC_FUEDIPO_HXX
+
+#include "fudraw.hxx"
+
+
+/*************************************************************************
+|*
+|* Basisklasse fuer alle Funktionen
+|*
+\************************************************************************/
+
+class FuEditPoints : public FuDraw
+{
+ public:
+ FuEditPoints(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuEditPoints();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+};
+
+
+
+#endif // _SD_FUEDIPO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fuinsert.hxx b/sc/source/ui/inc/fuinsert.hxx
new file mode 100644
index 000000000000..009096a5d4e2
--- /dev/null
+++ b/sc/source/ui/inc/fuinsert.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef SC_FUINSERT_HXX
+#define SC_FUINSERT_HXX
+
+#include "fupoor.hxx"
+
+class FuInsertGraphic : public FuPoor
+{
+ public:
+ FuInsertGraphic( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuInsertGraphic();
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+};
+
+/************************************************************************/
+
+class FuInsertOLE : public FuPoor
+{
+ public:
+ FuInsertOLE( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuInsertOLE();
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+};
+
+/************************************************************************/
+
+class FuInsertChart : public FuPoor
+{
+ public:
+ FuInsertChart( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuInsertChart();
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+};
+
+/************************************************************************/
+
+class FuInsertMedia : public FuPoor
+{
+ public:
+ FuInsertMedia( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuInsertMedia();
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+};
+
+#endif // _SD_FUINSERT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fumark.hxx b/sc/source/ui/inc/fumark.hxx
new file mode 100644
index 000000000000..25b2ec84def5
--- /dev/null
+++ b/sc/source/ui/inc/fumark.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUMARK_HXX
+#define SC_FUMARK_HXX
+
+#include "fupoor.hxx"
+#include "rangelst.hxx" // ScRangeListRef
+
+
+/*************************************************************************
+|*
+|* Funktion zum Aufziehen eines Rechtecks
+|*
+\************************************************************************/
+
+class FuMarkRect : public FuPoor
+{
+ protected:
+ Point aBeginPos;
+ Rectangle aZoomRect;
+ BOOL bVisible;
+ BOOL bStartDrag;
+ ScRangeListRef aSourceRange;
+
+ public:
+ FuMarkRect(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuMarkRect();
+
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+
+ virtual void ScrollStart();
+ virtual void ScrollEnd();
+
+ virtual void Activate();
+ virtual void Deactivate();
+
+ virtual void ForcePointer(const MouseEvent* pMEvt);
+
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+ virtual BYTE Command(const CommandEvent& rCEvt);
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/funcpage.hxx b/sc/source/ui/inc/funcpage.hxx
new file mode 100644
index 000000000000..45198a31a3a2
--- /dev/null
+++ b/sc/source/ui/inc/funcpage.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUNCPAGE_HXX
+#define SC_FUNCPAGE_HXX
+
+#include "funcutl.hxx"
+#include "global.hxx" // ScAddress
+#include <svtools/stdctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/tabpage.hxx>
+
+#ifndef _SVSTDARR_STRINGS
+
+#define _SVSTDARR_STRINGS
+#include <svl/svstdarr.hxx>
+
+#endif
+#include <vcl/tabctrl.hxx>
+#include "parawin.hxx"
+#include <svtools/svtreebx.hxx>
+#include "compiler.hxx"
+#include "cell.hxx"
+
+
+class ScViewData;
+class ScFuncName_Impl;
+class ScDocument;
+class ScFuncDesc;
+
+//============================================================================
+
+#define LRU_MAX 10
+
+//============================================================================
+class ScListBox : public ListBox
+{
+protected:
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+public:
+ ScListBox( Window* pParent, const ResId& rResId );
+};
+
+
+
+
+//============================================================================
+class ScFuncPage : public TabPage
+{
+private:
+
+ Link aDoubleClickLink;
+ Link aSelectionLink;
+ FixedText aFtCategory;
+ ListBox aLbCategory;
+ FixedText aFtFunction;
+ ScListBox aLbFunction;
+ ImageButton aIBFunction;
+
+ const ScFuncDesc* aLRUList[LRU_MAX];
+
+
+ DECL_LINK( SelHdl, ListBox* );
+ DECL_LINK( DblClkHdl, ListBox* );
+
+protected:
+
+ void UpdateFunctionList();
+ void InitLRUList();
+
+
+public:
+
+ ScFuncPage( Window* pParent);
+
+ void SetCategory(USHORT nCat);
+ void SetFunction(USHORT nFunc);
+ void SetFocus();
+ USHORT GetCategory();
+ USHORT GetFunction();
+ USHORT GetFunctionEntryCount();
+
+ USHORT GetFuncPos(const ScFuncDesc*);
+ const ScFuncDesc* GetFuncDesc( USHORT nPos ) const;
+ String GetSelFunctionName() const;
+
+ void SetDoubleClickHdl( const Link& rLink ) { aDoubleClickLink = rLink; }
+ const Link& GetDoubleClickHdl() const { return aDoubleClickLink; }
+
+ void SetSelectHdl( const Link& rLink ) { aSelectionLink = rLink; }
+ const Link& GetSelectHdl() const { return aSelectionLink; }
+
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/funcutl.hxx b/sc/source/ui/inc/funcutl.hxx
new file mode 100644
index 000000000000..76c168ccabae
--- /dev/null
+++ b/sc/source/ui/inc/funcutl.hxx
@@ -0,0 +1,197 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUNCUTL_HXX
+#define SC_FUNCUTL_HXX
+
+#include <vcl/scrbar.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit.hxx>
+#include "anyrefdg.hxx" // formula::RefButton
+
+
+//============================================================================
+// class ValWnd
+
+class ValWnd : public Window
+{
+public:
+ ValWnd( Window* pParent, const ResId& rId );
+
+ void SetValue( const String& rStrVal );
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+
+private:
+ String aStrValue;
+ Rectangle aRectOut;
+};
+
+
+//============================================================================
+// class ScEditBox
+
+class ScEditBox : public Control
+{
+private:
+
+ MultiLineEdit* pMEdit;
+ Link aSelChangedLink;
+ Selection aOldSel;
+ BOOL bMouseFlag;
+ DECL_LINK( ChangedHdl, ScEditBox* );
+
+protected:
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void SelectionChanged();
+ virtual void Resize();
+ virtual void GetFocus();
+
+
+public:
+ ScEditBox( Window* pParent, const ResId& rResId );
+
+ ~ScEditBox();
+
+ MultiLineEdit* GetEdit() {return pMEdit;}
+
+ void SetSelChangedHdl( const Link& rLink ) { aSelChangedLink = rLink; }
+ const Link& GetSelChangedHdl() const { return aSelChangedLink; }
+
+ void UpdateOldSel();
+};
+
+
+
+//============================================================================
+// class ArgEdit
+
+class ArgEdit : public formula::RefEdit
+{
+public:
+ ArgEdit( Window* pParent, const ResId& rResId );
+
+ void Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit,
+ ScrollBar& rArgSlider, USHORT nArgCount );
+
+protected:
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+private:
+ ArgEdit* pEdPrev;
+ ArgEdit* pEdNext;
+ ScrollBar* pSlider;
+ USHORT nArgs;
+};
+
+
+//============================================================================
+// class ArgInput
+
+class ArgInput
+{
+private:
+
+ Link aFxClickLink;
+ Link aRefClickLink;
+ Link aFxFocusLink;
+ Link aRefFocusLink;
+ Link aEdFocusLink;
+ Link aEdModifyLink;
+
+ FixedText* pFtArg;
+ ImageButton* pBtnFx;
+ ArgEdit* pEdArg;
+ formula::RefButton* pRefBtn;
+
+ DECL_LINK( FxBtnClickHdl, ImageButton* );
+ DECL_LINK( RefBtnClickHdl,formula::RefButton* );
+ DECL_LINK( FxBtnFocusHdl, ImageButton* );
+ DECL_LINK( RefBtnFocusHdl,formula::RefButton* );
+ DECL_LINK( EdFocusHdl, ArgEdit* );
+ DECL_LINK( EdModifyHdl,ArgEdit* );
+
+protected:
+
+ virtual void FxClick();
+ virtual void RefClick();
+ virtual void FxFocus();
+ virtual void RefFocus();
+ virtual void EdFocus();
+ virtual void EdModify();
+
+public:
+
+ ArgInput();
+
+ void InitArgInput ( FixedText* pftArg,
+ ImageButton* pbtnFx,
+ ArgEdit* pedArg,
+ formula::RefButton* prefBtn);
+
+ void SetArgName(const String &aArg);
+ String GetArgName();
+ void SetArgNameFont(const Font&);
+
+ void SetArgVal(const String &aVal);
+ String GetArgVal();
+
+ void SetArgSelection (const Selection& rSel );
+
+ ArgEdit* GetArgEdPtr() {return pEdArg;}
+
+
+ void SetFxClickHdl( const Link& rLink ) { aFxClickLink = rLink; }
+ const Link& GetFxClickHdl() const { return aFxClickLink; }
+
+ void SetRefClickHdl( const Link& rLink ) { aRefClickLink = rLink; }
+ const Link& GetRefClickHdl() const { return aRefClickLink; }
+
+ void SetFxFocusHdl( const Link& rLink ) { aFxFocusLink = rLink; }
+ const Link& GetFxFocusHdl() const { return aFxFocusLink; }
+
+ void SetRefFocusHdl( const Link& rLink ) { aRefFocusLink = rLink; }
+ const Link& GetRefFocusHdl() const { return aRefFocusLink; }
+
+ void SetEdFocusHdl( const Link& rLink ) { aEdFocusLink = rLink; }
+ const Link& GetEdFocusHdl() const { return aEdFocusLink; }
+
+ void SetEdModifyHdl( const Link& rLink ) { aEdModifyLink = rLink; }
+ const Link& GetEdModifyHdl() const { return aEdModifyLink; }
+
+ void Hide();
+ void Show();
+
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fupoor.hxx b/sc/source/ui/inc/fupoor.hxx
new file mode 100644
index 000000000000..a0939828e67c
--- /dev/null
+++ b/sc/source/ui/inc/fupoor.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SC_FUPOOR_HXX
+#define _SC_FUPOOR_HXX
+
+#include <vcl/event.hxx>
+#include <vcl/timer.hxx>
+#include <sfx2/request.hxx>
+
+class ScDrawView;
+class ScTabViewShell;
+class Window;
+class SdrModel;
+class Dialog;
+
+// #98185# Create default drawing objects via keyboard
+class SdrObject;
+
+// Return-Werte fuer Command
+#define SC_CMD_NONE 0
+#define SC_CMD_USED 1
+#define SC_CMD_IGNORE 2
+
+/*************************************************************************
+|*
+|* Basisklasse fuer alle Funktionen
+|*
+\************************************************************************/
+
+class FuPoor
+{
+protected:
+ ScDrawView* pView;
+ ScTabViewShell* pViewShell;
+ Window* pWindow;
+ SdrModel* pDrDoc;
+
+ SfxRequest aSfxRequest;
+ Dialog* pDialog;
+
+ Timer aScrollTimer; // fuer Autoscrolling
+ DECL_LINK( ScrollHdl, Timer * );
+ void ForceScroll(const Point& aPixPos);
+
+ Timer aDragTimer; // fuer Drag&Drop
+ DECL_LINK( DragTimerHdl, Timer * );
+ DECL_LINK( DragHdl, void * );
+ BOOL bIsInDragMode;
+ Point aMDPos; // Position von MouseButtonDown
+
+ // #95491# member to hold state of the mouse buttons for creation
+ // of own MouseEvents (like in ScrollHdl)
+private:
+ sal_uInt16 mnCode;
+
+public:
+ FuPoor(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+ virtual ~FuPoor();
+
+ // #95491# see member
+ void SetMouseButtonCode(sal_uInt16 nNew) { if(nNew != mnCode) mnCode = nNew; }
+ sal_uInt16 GetMouseButtonCode() const { return mnCode; }
+
+ virtual void Paint(const Rectangle&, Window*) {}
+
+ virtual void DoCut();
+ virtual void DoCopy();
+ virtual void DoPaste();
+
+ // Mouse- & Key-Events; Returnwert=TRUE: Event wurde bearbeitet
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent&) { return FALSE; }
+
+ // #95491# moved from inline to *.cxx
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt); // { return FALSE; }
+
+ // #95491# moved from inline to *.cxx
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt); // { return FALSE; }
+
+ virtual BYTE Command(const CommandEvent& rCEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ virtual void ScrollStart() {} // diese Funktionen werden von
+ virtual void ScrollEnd() {} // ForceScroll aufgerufen
+
+ void SetWindow(Window* pWin) { pWindow = pWin; }
+
+ USHORT GetSlotID() const { return( aSfxRequest.GetSlot() ); }
+
+ BOOL IsDetectiveHit( const Point& rLogicPos );
+
+ void StopDragTimer();
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
+
+protected:
+ void ImpForceQuadratic(Rectangle& rRect);
+
+public:
+ // #i33136#
+ virtual bool doConstructOrthogonal() const;
+};
+
+
+
+#endif // _SD_FUPOOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fusel.hxx b/sc/source/ui/inc/fusel.hxx
new file mode 100644
index 000000000000..993275a39207
--- /dev/null
+++ b/sc/source/ui/inc/fusel.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUSEL_HXX
+#define SC_FUSEL_HXX
+
+#ifndef _SV_HXX
+#endif
+
+#include "fudraw.hxx"
+
+//class Outliner;
+//class OutlinerView;
+class SdrPageView;
+
+
+/*************************************************************************
+|*
+|* Basisklasse fuer alle Funktionen
+|*
+\************************************************************************/
+
+class FuSelection : public FuDraw
+{
+public:
+ FuSelection(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq );
+
+ virtual ~FuSelection();
+ // Mouse- & Key-Events
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+ virtual BYTE Command(const CommandEvent& rCEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ void ActivateNoteHandles(SdrObject* pObj);
+
+protected:
+// Outliner* pOutliner;
+// OutlinerView* pOutlinerView;
+ BOOL bVCAction;
+
+private:
+ BOOL TestDetective( SdrPageView* pPV, const Point& rPos ); // -> fusel2
+
+ bool IsNoteCaptionMarked() const;
+ bool IsNoteCaptionClicked( const Point& rPos ) const;
+};
+
+
+
+#endif // _SD_FUSEL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/futext.hxx b/sc/source/ui/inc/futext.hxx
new file mode 100644
index 000000000000..273ba41cb41c
--- /dev/null
+++ b/sc/source/ui/inc/futext.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_FUTEXT_HXX
+#define SC_FUTEXT_HXX
+
+#include "fuconstr.hxx"
+
+class SdrObject;
+class SdrTextObj;
+class SdrOutliner;
+
+/*************************************************************************
+|*
+|* Basisklasse fuer Textfunktionen
+|*
+\************************************************************************/
+class FuText : public FuConstruct
+{
+protected:
+// USHORT nOldObjectBar;
+ SdrTextObj* pTextObj;
+
+public:
+ FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pView,
+ SdrModel* pDoc, SfxRequest& rReq);
+
+ virtual ~FuText();
+
+ virtual BOOL KeyInput(const KeyEvent& rKEvt);
+ virtual BOOL MouseMove(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonUp(const MouseEvent& rMEvt);
+ virtual BOOL MouseButtonDown(const MouseEvent& rMEvt);
+
+ virtual void Activate(); // Function aktivieren
+ virtual void Deactivate(); // Function deaktivieren
+
+ virtual void ForcePointer(const MouseEvent* pMEvt);
+
+ virtual void SelectionHasChanged();
+
+ void SetInEditMode( SdrObject* pObj = NULL, const Point* pMousePixel = NULL,
+ BOOL bCursorToEnd = FALSE, const KeyEvent* pInitialKey = NULL );
+ void StopEditMode(BOOL bTextDirection = FALSE);
+ void StopDragMode(SdrObject* pObject);
+
+ // #98185# Create default drawing objects via keyboard
+ virtual SdrObject* CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle);
+
+private:
+ SdrOutliner* MakeOutliner();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/graphsh.hxx b/sc/source/ui/inc/graphsh.hxx
new file mode 100644
index 000000000000..76899f235cba
--- /dev/null
+++ b/sc/source/ui/inc/graphsh.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef GRAPHSH_HXX
+#define GRAPHSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+
+class ScViewData;
+
+#include "drawsh.hxx"
+
+class ScGraphicShell: public ScDrawShell
+{
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_GRAPHIC_SHELL)
+
+ ScGraphicShell(ScViewData* pData);
+ virtual ~ScGraphicShell();
+
+ void Execute(SfxRequest& rReq);
+ void GetAttrState(SfxItemSet &rSet);
+
+ void ExecuteFilter(SfxRequest& rReq);
+ void GetFilterState(SfxItemSet &rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/gridmerg.hxx b/sc/source/ui/inc/gridmerg.hxx
new file mode 100644
index 000000000000..bc95f05abce0
--- /dev/null
+++ b/sc/source/ui/inc/gridmerg.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_GRIDMERG_HXX
+#define SC_GRIDMERG_HXX
+
+#include <tools/solar.h>
+
+class OutputDevice;
+
+class ScGridMerger
+{
+private:
+ OutputDevice* pDev;
+ long nOneX;
+ long nOneY;
+ long nFixStart;
+ long nFixEnd;
+ long nVarStart;
+ long nVarDiff;
+ long nCount;
+ BOOL bVertical;
+ BOOL bOptimize;
+
+ void AddLine( long nStart, long nEnd, long nPos );
+
+public:
+ ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY );
+ ~ScGridMerger();
+
+ void AddHorLine( long nX1, long nX2, long nY );
+ void AddVerLine( long nX, long nY1, long nY2 );
+ void Flush();
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
new file mode 100644
index 000000000000..4bd6cede84ef
--- /dev/null
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -0,0 +1,430 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_GRIDWIN_HXX
+#define SC_GRIDWIN_HXX
+
+#include <tools/string.hxx>
+#include <svtools/transfer.hxx>
+#include "viewutil.hxx"
+#include "viewdata.hxx"
+#include "cbutton.hxx"
+#include <svx/sdr/overlay/overlayobject.hxx>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+
+#include <vector>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+// ---------------------------------------------------------------------------
+
+struct ScTableInfo;
+class ScViewSelectionEngine;
+class ScDPObject;
+class ScDPFieldPopupWindow;
+class ScDPFieldButton;
+class ScOutputData;
+class ScFilterListBox;
+class AutoFilterPopup;
+class SdrObject;
+class SdrEditView;
+class ScNoteMarker;
+class FloatingWindow;
+class SdrHdlList;
+class ScTransferObj;
+struct SpellCallbackInfo;
+
+ // Maus-Status (nMouseStatus)
+
+#define SC_GM_NONE 0
+#define SC_GM_TABDOWN 1
+#define SC_GM_DBLDOWN 2
+#define SC_GM_FILTER 3
+#define SC_GM_IGNORE 4
+#define SC_GM_WATERUNDO 5
+#define SC_GM_URLDOWN 6
+
+ // Page-Drag-Modus
+
+#define SC_PD_NONE 0
+#define SC_PD_RANGE_L 1
+#define SC_PD_RANGE_R 2
+#define SC_PD_RANGE_T 4
+#define SC_PD_RANGE_B 8
+#define SC_PD_RANGE_TL (SC_PD_RANGE_T|SC_PD_RANGE_L)
+#define SC_PD_RANGE_TR (SC_PD_RANGE_T|SC_PD_RANGE_R)
+#define SC_PD_RANGE_BL (SC_PD_RANGE_B|SC_PD_RANGE_L)
+#define SC_PD_RANGE_BR (SC_PD_RANGE_B|SC_PD_RANGE_R)
+#define SC_PD_BREAK_H 16
+#define SC_PD_BREAK_V 32
+
+
+class ScHideTextCursor
+{
+private:
+ ScViewData* pViewData;
+ ScSplitPos eWhich;
+
+public:
+ ScHideTextCursor( ScViewData* pData, ScSplitPos eW );
+ ~ScHideTextCursor();
+};
+
+// ---------------------------------------------------------------------------
+// predefines
+namespace sdr { namespace overlay { class OverlayObjectList; }}
+
+class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHelper
+{
+ // ScFilterListBox wird immer fuer Auswahlliste benutzt
+ friend class ScFilterListBox;
+
+private:
+ // #114409#
+ ::sdr::overlay::OverlayObjectList* mpOOCursors;
+ ::sdr::overlay::OverlayObjectList* mpOOSelection;
+ ::sdr::overlay::OverlayObjectList* mpOOSelectionBorder;
+ ::sdr::overlay::OverlayObjectList* mpOOAutoFill;
+ ::sdr::overlay::OverlayObjectList* mpOODragRect;
+ ::sdr::overlay::OverlayObjectList* mpOOHeader;
+ ::sdr::overlay::OverlayObjectList* mpOOShrink;
+
+ ::boost::shared_ptr<Rectangle> mpAutoFillRect;
+
+ /**
+ * Stores current visible column and row ranges, used to avoid expensive
+ * operations on objects that are outside visible area.
+ */
+ struct VisibleRange
+ {
+ SCCOL mnCol1;
+ SCCOL mnCol2;
+ SCROW mnRow1;
+ SCROW mnRow2;
+
+ VisibleRange();
+
+ bool isInside(SCCOL nCol, SCROW nRow) const;
+ };
+ VisibleRange maVisibleRange;
+
+private:
+ ScViewData* pViewData;
+ ScSplitPos eWhich;
+ ScHSplitPos eHWhich;
+ ScVSplitPos eVWhich;
+
+ ScNoteMarker* pNoteMarker;
+
+ ScFilterListBox* pFilterBox;
+ FloatingWindow* pFilterFloat;
+ ::std::auto_ptr<ScDPFieldPopupWindow> mpDPFieldPopup;
+ ::std::auto_ptr<ScDPFieldButton> mpFilterButton;
+
+ USHORT nCursorHideCount;
+
+ BOOL bMarking;
+
+ USHORT nButtonDown;
+ BOOL bEEMouse; // Edit-Engine hat Maus
+ BYTE nMouseStatus;
+ BYTE nNestedButtonState; // track nested button up/down calls
+
+ BOOL bDPMouse; // DataPilot-D&D (neue Pivottabellen)
+ long nDPField;
+ ScDPObject* pDragDPObj; //! name?
+
+ BOOL bRFMouse; // RangeFinder-Drag
+ BOOL bRFSize;
+ USHORT nRFIndex;
+ SCsCOL nRFAddX;
+ SCsROW nRFAddY;
+
+ USHORT nPagebreakMouse; // Pagebreak-Modus Drag
+ SCCOLROW nPagebreakBreak;
+ SCCOLROW nPagebreakPrev;
+ ScRange aPagebreakSource;
+ ScRange aPagebreakDrag;
+ BOOL bPagebreakDrawn;
+
+ BYTE nPageScript;
+
+ long nLastClickX;
+ long nLastClickY;
+
+ BOOL bDragRect;
+ SCCOL nDragStartX;
+ SCROW nDragStartY;
+ SCCOL nDragEndX;
+ SCROW nDragEndY;
+ InsCellCmd meDragInsertMode;
+
+ USHORT nCurrentPointer;
+
+ BOOL bIsInScroll;
+ BOOL bIsInPaint;
+
+ ScDDComboBoxButton aComboButton;
+
+ Point aCurMousePos;
+
+ USHORT nPaintCount;
+ Rectangle aRepaintPixel;
+ BOOL bNeedsRepaint;
+
+ BOOL bAutoMarkVisible;
+ ScAddress aAutoMarkPos;
+
+ BOOL bListValButton;
+ ScAddress aListValPos;
+
+ Rectangle aInvertRect;
+
+ DECL_LINK( PopupModeEndHdl, FloatingWindow* );
+ DECL_LINK( PopupSpellingHdl, SpellCallbackInfo* );
+
+ BOOL TestMouse( const MouseEvent& rMEvt, BOOL bAction );
+
+ BOOL DoPageFieldSelection( SCCOL nCol, SCROW nRow );
+ bool DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
+ void DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt );
+
+ void DPMouseMove( const MouseEvent& rMEvt );
+ void DPMouseButtonUp( const MouseEvent& rMEvt );
+ void DPTestMouse( const MouseEvent& rMEvt, BOOL bMove );
+
+ /**
+ * Check if the mouse click is on a field popup button.
+ *
+ * @return bool true if the field popup menu has been launched and no
+ * further mouse event handling is necessary, false otherwise.
+ */
+ bool DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj);
+ void DPLaunchFieldPopupMenu(
+ const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj);
+
+ void RFMouseMove( const MouseEvent& rMEvt, BOOL bUp );
+
+ void PagebreakMove( const MouseEvent& rMEvt, BOOL bUp );
+
+ void UpdateDragRect( BOOL bShowRange, const Rectangle& rPosRect );
+
+ BOOL IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab );
+ void ExecFilter( ULONG nSel, SCCOL nCol, SCROW nRow,
+ const String& aValue, bool bCheckForDates );
+ void FilterSelect( ULONG nSel );
+
+ void ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr );
+
+ void ExecPageFieldSelect( SCCOL nCol, SCROW nRow, BOOL bHasSelection, const String& rStr );
+
+ BOOL HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange );
+
+ BOOL DropScroll( const Point& rMousePos );
+
+ sal_Int8 AcceptPrivateDrop( const AcceptDropEvent& rEvt );
+ sal_Int8 ExecutePrivateDrop( const ExecuteDropEvent& rEvt );
+ sal_Int8 DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
+ const Point& rLogicPos, sal_Int8 nDndAction );
+
+ void HandleMouseButtonDown( const MouseEvent& rMEvt );
+
+ BOOL DrawMouseButtonDown(const MouseEvent& rMEvt);
+ BOOL DrawMouseButtonUp(const MouseEvent& rMEvt);
+ BOOL DrawMouseMove(const MouseEvent& rMEvt);
+ BOOL DrawKeyInput(const KeyEvent& rKEvt);
+ BOOL DrawCommand(const CommandEvent& rCEvt);
+ BOOL DrawHasMarkedObj();
+ void DrawEndAction();
+ void DrawMarkDropObj( SdrObject* pObj );
+ SdrObject* GetEditObject();
+ BOOL IsMyModel(SdrEditView* pSdrView);
+ //void DrawStartTimer();
+
+ void DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, ULONG nLayer );
+ void DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev );
+ //BOOL DrawBeforeScroll();
+ void DrawAfterScroll(/*BOOL bVal*/);
+ //void DrawMarks();
+ //BOOL NeedDrawMarks();
+ void DrawComboButton( const Point& rCellPos,
+ long nCellSizeX,
+ long nCellSizeY,
+ BOOL bArrowState,
+ BOOL bBtnIn = FALSE );
+ Rectangle GetListValButtonRect( const ScAddress& rButtonPos );
+
+ void DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev );
+
+ BOOL GetEditUrl( const Point& rPos,
+ String* pName=0, String* pUrl=0, String* pTarget=0 );
+ BOOL GetEditUrlOrError( BOOL bSpellErr, const Point& rPos,
+ String* pName=0, String* pUrl=0, String* pTarget=0 );
+
+ BOOL HitRangeFinder( const Point& rMouse, BOOL& rCorner, USHORT* pIndex = NULL,
+ SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL );
+
+ USHORT HitPageBreak( const Point& rMouse, ScRange* pSource = NULL,
+ SCCOLROW* pBreak = NULL, SCCOLROW* pPrev = NULL );
+
+ void PasteSelection( const Point& rPosPixel );
+
+ void SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY );
+
+ void GetSelectionRects( ::std::vector< Rectangle >& rPixelRects );
+
+protected:
+ using Window::Resize;
+ virtual void Resize( const Size& rSize );
+ virtual void PrePaint();
+ virtual void Paint( const Rectangle& rRect );
+ virtual void KeyInput(const KeyEvent& rKEvt);
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual void RequestHelp( const HelpEvent& rEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+public:
+ ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos );
+ ~ScGridWindow();
+
+ // #i70788# flush and get overlay
+ ::sdr::overlay::OverlayManager* getOverlayManager();
+ void flushOverlayManager();
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ void FakeButtonUp();
+
+ Point GetMousePosPixel() const;
+ void UpdateStatusPosSize();
+
+ void ClickExtern();
+
+ void SetPointer( const Pointer& rPointer );
+
+ void MoveMouseStatus( ScGridWindow &rDestWin );
+
+ void ScrollPixel( long nDifX, long nDifY );
+ void UpdateEditViewPos();
+
+ void UpdateFormulas();
+
+ void DoAutoFilterMenue( SCCOL nCol, SCROW nRow, BOOL bDataSelect );
+ void DoScenarioMenue( const ScRange& rScenRange );
+
+ void LaunchPageFieldMenu( SCCOL nCol, SCROW nRow );
+ void LaunchDPFieldMenu( SCCOL nCol, SCROW nRow );
+
+ ::com::sun::star::sheet::DataPilotFieldOrientation GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const;
+
+ void DrawButtons( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ ScTableInfo& rTabInfo, OutputDevice* pContentDev );
+
+ using Window::Draw;
+ void Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ ScUpdateMode eMode = SC_UPDATE_ALL );
+
+ void InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ BOOL bTestMerge = FALSE, BOOL bRepeat = FALSE );
+
+ void CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress);
+
+ void HideCursor();
+ void ShowCursor();
+ void DrawCursor();
+ void DrawAutoFillMark();
+ void UpdateAutoFillMark(BOOL bMarked, const ScRange& rMarkRange);
+
+ void UpdateListValPos( BOOL bVisible, const ScAddress& rPos );
+
+ BOOL ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, BOOL bKeyboard );
+ void HideNoteMarker();
+
+ MapMode GetDrawMapMode( BOOL bForce = FALSE );
+
+ void ContinueDrag();
+
+ void StopMarking();
+ void UpdateInputContext();
+
+ void CheckInverted() { if (nPaintCount) bNeedsRepaint = TRUE; }
+
+ void DoInvertRect( const Rectangle& rPixel );
+
+ void CheckNeedsRepaint();
+
+ void UpdateDPFromFieldPopupMenu();
+ void UpdateVisibleRange();
+
+ // #114409#
+ void CursorChanged();
+ void DrawLayerCreated();
+
+ void DeleteCopySourceOverlay();
+ void UpdateCopySourceOverlay();
+ void DeleteCursorOverlay();
+ void UpdateCursorOverlay();
+ void DeleteSelectionOverlay();
+ void UpdateSelectionOverlay();
+ void DeleteAutoFillOverlay();
+ void UpdateAutoFillOverlay();
+ void DeleteDragRectOverlay();
+ void UpdateDragRectOverlay();
+ void DeleteHeaderOverlay();
+ void UpdateHeaderOverlay();
+ void DeleteShrinkOverlay();
+ void UpdateShrinkOverlay();
+ void UpdateAllOverlays();
+
+protected:
+ // #114409#
+ void ImpCreateOverlayObjects();
+ void ImpDestroyOverlayObjects();
+
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/groupdlg.hxx b/sc/source/ui/inc/groupdlg.hxx
new file mode 100644
index 000000000000..f77b827c0ad8
--- /dev/null
+++ b/sc/source/ui/inc/groupdlg.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_GROUPDLG_HXX
+#define SC_GROUPDLG_HXX
+
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+
+//------------------------------------------------------------------------
+
+class ScGroupDlg : public ModalDialog
+{
+public:
+ ScGroupDlg( Window* pParent,
+ USHORT nResId,
+ BOOL bUnGroup = FALSE,
+ BOOL bRows = TRUE );
+ ~ScGroupDlg();
+
+ BOOL GetColsChecked() const;
+
+private:
+ FixedLine aFlFrame;
+ RadioButton aBtnRows;
+ RadioButton aBtnCols;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+};
+
+
+#endif // SC_STRINDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/hdrcont.hxx b/sc/source/ui/inc/hdrcont.hxx
new file mode 100644
index 000000000000..10eb08c92496
--- /dev/null
+++ b/sc/source/ui/inc/hdrcont.hxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_HDRCONT_HXX
+#define SC_HDRCONT_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/seleng.hxx>
+#include "address.hxx"
+
+// ---------------------------------------------------------------------------
+
+
+#define HDR_HORIZONTAL 0
+#define HDR_VERTICAL 1
+
+#define HDR_SIZE_OPTIMUM 0xFFFF
+
+
+ // Groesse des Sliders
+#define HDR_SLIDERSIZE 2
+
+class ScHeaderControl : public Window
+{
+private:
+ SelectionEngine* pSelEngine;
+ Font aNormFont;
+ Font aBoldFont;
+ BOOL bBoldSet;
+
+ USHORT nFlags;
+ BOOL bVertical; // Vertikal = Zeilenheader
+
+ long nWidth;
+ long nSmallWidth;
+ long nBigWidth;
+
+ SCCOLROW nSize;
+
+ SCCOLROW nMarkStart;
+ SCCOLROW nMarkEnd;
+ BOOL bMarkRange;
+
+ BOOL bDragging; // Groessen aendern
+ SCCOLROW nDragNo;
+ long nDragStart;
+ long nDragPos;
+ BOOL bDragMoved;
+
+ BOOL bIgnoreMove;
+
+ long GetScrPos( SCCOLROW nEntryNo );
+ SCCOLROW GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder );
+ bool IsSelectionAllowed(SCCOLROW nPos) const;
+ void ShowDragHelp();
+
+ void DoPaint( SCCOLROW nStart, SCCOLROW nEnd );
+
+ void DrawShadedRect( long nStart, long nEnd, const Color& rBaseColor );
+
+protected:
+ // von Window ueberladen
+
+ virtual void Paint( const Rectangle& rRect );
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+
+ // neue Methoden
+
+ virtual SCCOLROW GetPos() = 0; // aktuelle Position (Scrolling)
+ virtual USHORT GetEntrySize( SCCOLROW nEntryNo ) = 0; // Breite / Hoehe (Pixel)
+ virtual String GetEntryText( SCCOLROW nEntryNo ) = 0;
+
+ virtual SCCOLROW GetHiddenCount( SCCOLROW nEntryNo );
+ virtual BOOL IsLayoutRTL();
+ virtual BOOL IsMirrored();
+
+ virtual void SetEntrySize( SCCOLROW nPos, USHORT nNewWidth ) = 0;
+ virtual void HideEntries( SCCOLROW nStart, SCCOLROW nEnd ) = 0;
+
+ virtual void SetMarking( BOOL bSet );
+ virtual void SelectWindow();
+ virtual BOOL IsDisabled();
+ virtual BOOL ResizeAllowed();
+ virtual String GetDragHelp( long nVal );
+
+ virtual void DrawInvert( long nDragPos );
+ virtual void Command( const CommandEvent& rCEvt );
+
+public:
+ ScHeaderControl( Window* pParent, SelectionEngine* pSelectionEngine,
+ SCCOLROW nNewSize, USHORT nNewFlags );
+ ~ScHeaderControl();
+
+ void SetIgnoreMove(BOOL bSet) { bIgnoreMove = bSet; }
+
+ void StopMarking();
+
+ void SetMark( BOOL bNewSet, SCCOLROW nNewStart, SCCOLROW nNewEnd );
+
+ long GetWidth() const { return nWidth; }
+ long GetSmallWidth() const { return nSmallWidth; }
+ long GetBigWidth() const { return nBigWidth; }
+ void SetWidth( long nNew );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/hfedtdlg.hxx b/sc/source/ui/inc/hfedtdlg.hxx
new file mode 100644
index 000000000000..b4eb019a85db
--- /dev/null
+++ b/sc/source/ui/inc/hfedtdlg.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_HFEDTDLG_HXX
+#define SC_HFEDTDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <svx/pageitem.hxx>
+
+
+#include "sc.hrc"
+
+
+//==================================================================
+
+class ScHFEditDlg : public SfxTabDialog
+{
+ SvxNumType eNumType;
+public:
+ ScHFEditDlg( SfxViewFrame* pFrame,
+ Window* pParent,
+ const SfxItemSet& rCoreSet,
+ const String& rPageStyle,
+ USHORT nResId = RID_SCDLG_HFEDIT );
+
+ ~ScHFEditDlg();
+
+ virtual void PageCreated( USHORT nId, SfxTabPage& rPage );
+};
+
+
+#endif // SC_HFEDTDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/highred.hrc b/sc/source/ui/inc/highred.hrc
new file mode 100644
index 000000000000..726c9a870fb8
--- /dev/null
+++ b/sc/source/ui/inc/highred.hrc
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_CHANGES
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 5
+
+#define CB_HIGHLIGHT_ACCEPT 6
+#define CB_HIGHLIGHT_REJECT 7
+
+//
+#define FL_FILTER 10
+#define TP_FILTER 11
+#define TP_VIEW 12
+#define CB_HIGHLIGHT 13
+
+#define FT_ASSIGN 14
+#define ED_ASSIGN 15
+#define RB_ASSIGN 16
+
+
+
+
+
+
+
+#define STR_INSERT_COLS 20
+#define STR_INSERT_ROWS 21
+#define STR_INSERT_TABS 22
+#define STR_DELETE_COLS 23
+#define STR_DELETE_ROWS 24
+#define STR_DELETE_TABS 25
+#define STR_MOVE 26
+#define STR_CONTENT 27
+#define STR_REJECT 28
+
+// Bitmaps
+#define BMP_STR_CLOSE 31
+#define BMP_STR_OPEN 32
+#define BMP_STR_END 33
+#define BMP_STR_ERROR 34
+
+
+//
+
diff --git a/sc/source/ui/inc/highred.hxx b/sc/source/ui/inc/highred.hxx
new file mode 100644
index 000000000000..48192bb6db36
--- /dev/null
+++ b/sc/source/ui/inc/highred.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_HIGHRED_HXX
+#define SC_HIGHRED_HXX
+
+#include <vcl/morebtn.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/headbar.hxx>
+#include <svtools/svtabbx.hxx>
+
+
+#include "rangenam.hxx"
+#include "anyrefdg.hxx"
+
+#include <vcl/morebtn.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <svx/ctredlin.hxx>
+#include <svx/simptabl.hxx>
+#include "chgtrack.hxx"
+#include "chgviset.hxx"
+
+class ScViewData;
+class ScDocument;
+
+#ifndef FLT_DATE_BEFORE
+#define FLT_DATE_BEFORE 0
+#define FLT_DATE_SINCE 1
+#define FLT_DATE_EQUAL 2
+#define FLT_DATE_NOTEQUAL 3
+#define FLT_DATE_BETWEEN 4
+#define FLT_DATE_SAVE 5
+#endif
+
+//==================================================================
+
+class ScHighlightChgDlg : public ScAnyRefDlg
+{
+private:
+
+ CheckBox aHighlightBox;
+ FixedLine aFlFilter;
+ SvxTPFilter aFilterCtr;
+ CheckBox aCbAccept;
+ CheckBox aCbReject;
+
+ OKButton aOkButton;
+ CancelButton aCancelButton;
+ HelpButton aHelpButton;
+
+ formula::RefEdit aEdAssign;
+ formula::RefButton aRbAssign;
+
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ ScRangeName aLocalRangeName;
+ Selection theCurSel;
+ Size MinSize;
+ ScRangeList aRangeList;
+ ScChangeViewSettings aChangeViewSet;
+
+ void Init();
+
+ DECL_LINK( RefHandle, SvxTPFilter* );
+ DECL_LINK(HighLightHandle, CheckBox*);
+ DECL_LINK(OKBtnHdl, PushButton*);
+
+
+protected:
+
+ virtual void RefInputDone( BOOL bForced = FALSE );
+
+public:
+ ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData);
+
+ ~ScHighlightChgDlg();
+
+ virtual void SetActive();
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual BOOL Close();
+ virtual BOOL IsRefInputMode() const;
+
+};
+
+
+#endif // SC_NAMEDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/hintwin.hxx b/sc/source/ui/inc/hintwin.hxx
new file mode 100644
index 000000000000..ab514a95d9dc
--- /dev/null
+++ b/sc/source/ui/inc/hintwin.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_HINTWIN_HXX
+#define SC_HINTWIN_HXX
+
+#include <vcl/window.hxx>
+
+class ScHintWindow : public Window
+{
+private:
+ String aTitle;
+ String aMessage;
+ Point aTextStart;
+ long nTextHeight;
+ Font aTextFont;
+ Font aHeadFont;
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+
+public:
+ ScHintWindow( Window* pParent, const String& rTit, const String& rMsg );
+ ~ScHintWindow();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/hiranges.hxx b/sc/source/ui/inc/hiranges.hxx
new file mode 100644
index 000000000000..84c70d1a52a8
--- /dev/null
+++ b/sc/source/ui/inc/hiranges.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_HIRANGES_HXX
+#define SC_HIRANGES_HXX
+
+#include <tools/color.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+//==================================================================
+
+struct ScHighlightEntry
+{
+ ScRange aRef;
+ Color aColor;
+
+ ScHighlightEntry( const ScRange& rR, const Color& rC ) :
+ aRef(rR), aColor(rC) {}
+};
+
+class ScHighlightRanges
+{
+ List aEntries;
+
+public:
+ ScHighlightRanges();
+ ~ScHighlightRanges();
+
+ ULONG Count() const { return aEntries.Count(); }
+ void Insert( ScHighlightEntry* pNew ) { aEntries.Insert(pNew, LIST_APPEND); }
+ ScHighlightEntry* GetObject( ULONG nIndex ) const
+ { return (ScHighlightEntry*)aEntries.GetObject(nIndex); }
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/imoptdlg.hxx b/sc/source/ui/inc/imoptdlg.hxx
new file mode 100644
index 000000000000..576409598f9d
--- /dev/null
+++ b/sc/source/ui/inc/imoptdlg.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_IMOPTDLG_HXX
+#define SC_IMOPTDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/imagebtn.hxx>
+#include <svx/txencbox.hxx>
+#include "scdllapi.h"
+#include "global.hxx"
+
+//===================================================================
+
+class SC_DLLPUBLIC ScImportOptions
+{
+public:
+ ScImportOptions()
+ : nFieldSepCode(0), nTextSepCode(0),
+ eCharSet(RTL_TEXTENCODING_DONTKNOW), bFixedWidth(FALSE),
+ bSaveAsShown(FALSE)
+ {}
+ ScImportOptions( const String& rStr );
+
+ ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, const String& rStr )
+ : nFieldSepCode(nFieldSep), nTextSepCode(nTextSep), aStrFont(rStr),
+ bFixedWidth(FALSE), bSaveAsShown(FALSE)
+ { eCharSet = ScGlobal::GetCharsetValue(aStrFont); }
+
+ ScImportOptions( sal_Unicode nFieldSep, sal_Unicode nTextSep, rtl_TextEncoding nEnc )
+ : nFieldSepCode(nFieldSep), nTextSepCode(nTextSep),
+ bFixedWidth(FALSE), bSaveAsShown(FALSE)
+ { SetTextEncoding( nEnc ); }
+
+ ScImportOptions( const ScImportOptions& rCpy )
+ : nFieldSepCode (rCpy.nFieldSepCode),
+ nTextSepCode (rCpy.nTextSepCode),
+ aStrFont (rCpy.aStrFont),
+ eCharSet (rCpy.eCharSet),
+ bFixedWidth (rCpy.bFixedWidth),
+ bSaveAsShown (rCpy.bSaveAsShown)
+ {}
+
+ ScImportOptions& operator=( const ScImportOptions& rCpy )
+ {
+ nFieldSepCode = rCpy.nFieldSepCode;
+ nTextSepCode = rCpy.nTextSepCode;
+ aStrFont = rCpy.aStrFont;
+ eCharSet = rCpy.eCharSet;
+ bFixedWidth = rCpy.bFixedWidth;
+ bSaveAsShown = rCpy.bSaveAsShown;
+ return *this;
+ }
+
+ BOOL operator==( const ScImportOptions& rCmp )
+ {
+ return
+ nFieldSepCode == rCmp.nFieldSepCode
+ && nTextSepCode == rCmp.nTextSepCode
+ && eCharSet == rCmp.eCharSet
+ && aStrFont == rCmp.aStrFont
+ && bFixedWidth == rCmp.bFixedWidth
+ && bSaveAsShown == rCmp.bSaveAsShown;
+ }
+ String BuildString() const;
+
+ void SetTextEncoding( rtl_TextEncoding nEnc );
+
+ sal_Unicode nFieldSepCode;
+ sal_Unicode nTextSepCode;
+ String aStrFont;
+ CharSet eCharSet;
+ BOOL bFixedWidth;
+ BOOL bSaveAsShown;
+};
+
+
+#endif // SC_IMOPTDLG_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/impex.hxx b/sc/source/ui/inc/impex.hxx
new file mode 100644
index 000000000000..63452795bbec
--- /dev/null
+++ b/sc/source/ui/inc/impex.hxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_IMPEX_HXX
+#define SC_IMPEX_HXX
+
+#include <osl/endian.h>
+#include <sot/exchange.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+class ScDocShell;
+class ScDocument;
+class SvStream;
+class SfxMedium;
+class ScAsciiOptions;
+
+struct ScExportTextOptions
+{
+ enum NewlineConversion { ToSystem, ToSpace, None };
+ ScExportTextOptions( NewlineConversion eNewlineConversion = ToSystem, sal_Unicode cSeparatorConvertTo = 0, bool bAddQuotes = false ) :
+ meNewlineConversion( eNewlineConversion ), mcSeparatorConvertTo( cSeparatorConvertTo ), mbAddQuotes( bAddQuotes ) {}
+
+ NewlineConversion meNewlineConversion;
+ sal_Unicode mcSeparatorConvertTo; // Convert separator to this character
+ bool mbAddQuotes;
+};
+
+class SC_DLLPUBLIC ScImportExport
+{
+ ScDocShell* pDocSh;
+ ScDocument* pDoc;
+ ScDocument* pUndoDoc;
+ ScRange aRange;
+ String aStreamPath;
+ String aNonConvertibleChars;
+ ULONG nSizeLimit;
+ sal_Unicode cSep; // Separator
+ sal_Unicode cStr; // String Delimiter
+ BOOL bFormulas; // Formeln im Text?
+ BOOL bIncludeFiltered; // include filtered rows? (default true)
+ BOOL bAll; // keine Selektion
+ BOOL bSingle; // Einfachselektion
+ BOOL bUndo; // Mit Undo?
+ BOOL bOverflow; // zuviele Zeilen/Spalten
+ bool mbApi;
+ ScExportTextOptions mExportTextOptions;
+
+ ScAsciiOptions* pExtOptions; // erweiterte Optionen
+
+ BOOL StartPaste(); // Protect-Check, Undo einrichten
+ void EndPaste(); // Undo/Redo-Aktionen, Repaint
+ BOOL Doc2Text( SvStream& );
+ BOOL Text2Doc( SvStream& );
+ BOOL Doc2Sylk( SvStream& );
+ BOOL Sylk2Doc( SvStream& );
+ BOOL Doc2HTML( SvStream&, const String& );
+ BOOL Doc2RTF( SvStream& );
+ BOOL Doc2Dif( SvStream& );
+ BOOL Dif2Doc( SvStream& );
+ BOOL ExtText2Doc( SvStream& ); // mit pExtOptions
+ BOOL RTF2Doc( SvStream&, const String& rBaseURL );
+ BOOL HTML2Doc( SvStream&, const String& rBaseURL );
+
+public:
+ ScImportExport( ScDocument* ); // Gesamtdokument
+ ScImportExport( ScDocument*, const String& ); // Bereichs/Zellangabe
+ ScImportExport( ScDocument*, const ScAddress& );
+ ScImportExport( ScDocument*, const ScRange& );
+ ~ScImportExport();
+
+ void SetExtOptions( const ScAsciiOptions& rOpt );
+
+ BOOL IsDoubleRef() const { return BOOL( !( bAll || bSingle ) ); }
+ BOOL IsSingleRef() const { return bSingle; }
+ BOOL IsNoRef() const { return bAll; }
+ BOOL IsRef() const { return BOOL( !bAll ); }
+
+ const ScRange& GetRange() const { return aRange; }
+
+ BOOL IsUndo() const { return bUndo; }
+ void SetUndo( BOOL b ) { bUndo = b; }
+
+ static BOOL IsFormatSupported( ULONG nFormat );
+ static const sal_Unicode* ScanNextFieldFromString( const sal_Unicode* p,
+ String& rField, sal_Unicode cStr, const sal_Unicode* pSeps, bool bMergeSeps, bool& rbIsQuoted );
+ static void WriteUnicodeOrByteString( SvStream& rStrm, const String& rString, BOOL bZero = FALSE );
+ static void WriteUnicodeOrByteEndl( SvStream& rStrm );
+ static inline BOOL IsEndianSwap( const SvStream& rStrm );
+
+ //! only if stream is only used in own (!) memory
+ static inline void SetNoEndianSwap( SvStream& rStrm );
+
+ sal_Unicode GetSeparator() const { return cSep; }
+ void SetSeparator( sal_Unicode c ) { cSep = c; }
+ sal_Unicode GetDelimiter() const { return cStr; }
+ void SetDelimiter( sal_Unicode c ) { cStr = c; }
+ BOOL IsFormulas() const { return bFormulas; }
+ void SetFormulas( BOOL b ) { bFormulas = b; }
+ BOOL IsIncludeFiltered() const { return bIncludeFiltered; }
+ void SetIncludeFiltered( BOOL b ) { bIncludeFiltered = b; }
+
+ void SetSizeLimit( ULONG nNew ) { nSizeLimit = nNew; } // momentan nur fuer Ascii
+
+ void SetStreamPath( const String& rPath ) { aStreamPath = rPath; }
+ const String& GetStreamPath() const { return aStreamPath; }
+
+ BOOL ImportString( const ::rtl::OUString&, ULONG=FORMAT_STRING );
+ BOOL ExportString( ::rtl::OUString&, ULONG=FORMAT_STRING );
+ BOOL ExportByteString( ByteString&, rtl_TextEncoding, ULONG=FORMAT_STRING );
+
+ BOOL ImportStream( SvStream&, const String& rBaseURL, ULONG=FORMAT_STRING );
+ BOOL ExportStream( SvStream&, const String& rBaseURL, ULONG=FORMAT_STRING );
+
+ BOOL ImportData( const String& rMimeType,
+ const ::com::sun::star::uno::Any & rValue );
+ BOOL ExportData( const String& rMimeType,
+ ::com::sun::star::uno::Any & rValue );
+
+ BOOL IsOverflow() const { return bOverflow; } // nach dem Importieren
+
+ const String& GetNonConvertibleChars() const { return aNonConvertibleChars; }
+
+ bool IsApi() const { return mbApi; }
+ void SetApi( bool bApi ) { mbApi = bApi; }
+ const ScExportTextOptions& GetExportTextOptions() { return mExportTextOptions; }
+ void SetExportTextOptions( const ScExportTextOptions& options ) { mExportTextOptions = options; }
+};
+
+
+// static
+inline BOOL ScImportExport::IsEndianSwap( const SvStream& rStrm )
+{
+#ifdef OSL_BIGENDIAN
+ return rStrm.GetNumberFormatInt() != NUMBERFORMAT_INT_BIGENDIAN;
+#else
+ return rStrm.GetNumberFormatInt() != NUMBERFORMAT_INT_LITTLEENDIAN;
+#endif
+}
+
+// static
+inline void ScImportExport::SetNoEndianSwap( SvStream& rStrm )
+{
+#ifdef OSL_BIGENDIAN
+ rStrm.SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
+#else
+ rStrm.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+#endif
+}
+
+
+// Helper class for importing clipboard strings as streams.
+class ScImportStringStream : public SvMemoryStream
+{
+public:
+ ScImportStringStream( const ::rtl::OUString rStr )
+ : SvMemoryStream( (void*)rStr.getStr(),
+ rStr.getLength() * sizeof(sal_Unicode), STREAM_READ)
+ {
+ SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
+ SetEndianSwap( FALSE );
+ }
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/inputhdl.hxx b/sc/source/ui/inc/inputhdl.hxx
new file mode 100644
index 000000000000..d3a30b018bbe
--- /dev/null
+++ b/sc/source/ui/inc/inputhdl.hxx
@@ -0,0 +1,302 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_INPUTHDL_HXX
+#define SC_INPUTHDL_HXX
+
+#include "global.hxx"
+#include "address.hxx"
+#include <tools/fract.hxx>
+#include <tools/gen.hxx>
+#include <editeng/svxenum.hxx>
+
+class ScDocument;
+class ScTabView;
+class ScTabViewShell;
+class ScInputWindow;
+class ScPatternAttr;
+class EditEngine;
+class ScEditEngineDefaulter;
+class EditView;
+class EditTextObject;
+class ScInputHdlState;
+class TypedScStrCollection;
+class ScRangeFindList;
+class Timer;
+class KeyEvent;
+class CommandEvent;
+
+struct ESelection;
+
+//========================================================================
+// ScInputHandler
+//========================================================================
+
+class ScInputHandler
+{
+private:
+ ScInputWindow* pInputWin;
+
+ ScEditEngineDefaulter* pEngine; // editierte Daten in der Tabelle
+ EditView* pTableView; // aktive EditView dazu
+ EditView* pTopView; // EditView in der Eingabezeile
+
+ TypedScStrCollection* pColumnData;
+ TypedScStrCollection* pFormulaData;
+ TypedScStrCollection* pFormulaDataPara;
+ Window* pTipVisibleParent;
+ ULONG nTipVisible;
+ Window* pTipVisibleSecParent;
+ ULONG nTipVisibleSec;
+ String aManualTip;
+ String aAutoSearch;
+ USHORT nAutoPos;
+ BOOL bUseTab; // Blaettern moeglich
+
+ BOOL bTextValid; // Text noch nicht in Edit-Engine
+ String aCurrentText;
+
+ String aFormText; // fuer Funktions-Autopilot
+ xub_StrLen nFormSelStart; // Selektion fuer Funktions-Autopilot
+ xub_StrLen nFormSelEnd;
+
+ USHORT nAutoPar; // autom.parentheses than can be overwritten
+
+ ScAddress aCursorPos;
+ ScInputMode eMode;
+ BOOL bModified;
+ BOOL bSelIsRef;
+ BOOL bFormulaMode;
+ BOOL bInRangeUpdate;
+ BOOL bParenthesisShown;
+ BOOL bCreatingFuncView;
+ BOOL bInEnterHandler;
+ BOOL bCommandErrorShown;
+ BOOL bInOwnChange;
+
+ BOOL bProtected;
+ BOOL bCellHasPercentFormat;
+ ULONG nValidation;
+ SvxCellHorJustify eAttrAdjust;
+
+ Fraction aScaleX; // fuer Ref-MapMode
+ Fraction aScaleY;
+
+ ScTabViewShell* pRefViewSh;
+ ScTabViewShell* pActiveViewSh;
+
+ const ScPatternAttr* pLastPattern;
+ SfxItemSet* pEditDefaults;
+ BOOL bLastIsSymbol;
+
+ ScInputHdlState* pLastState;
+ Timer* pDelayTimer;
+
+ ScRangeFindList* pRangeFindList;
+
+ static BOOL bAutoComplete; // aus App-Optionen
+ static BOOL bOptLoaded;
+
+#ifdef _INPUTHDL_CXX
+private:
+ void UpdateActiveView();
+ void SyncViews( EditView* pSourceView = NULL );
+ /**
+ * @param cTyped typed character. If 0, look at existing document content
+ * for text or number.
+ * @param bInputActivated true if the cell input mode is activated (via
+ * F2), false otherwise.
+ * @return true if the new edit mode has been started.
+ */
+ bool StartTable( sal_Unicode cTyped, bool bFromCommand, bool bInputActivated );
+ void RemoveSelection();
+ void UpdateFormulaMode();
+ void InvalidateAttribs();
+ void ImplCreateEditEngine();
+ DECL_LINK( DelayTimer, Timer* );
+ void GetColData();
+ void UseColData();
+ void NextAutoEntry( BOOL bBack );
+ void UpdateAdjust( sal_Unicode cTyped );
+ void GetFormulaData();
+ void UseFormulaData();
+ void NextFormulaEntry( BOOL bBack );
+ void PasteFunctionData();
+ void PasteManualTip();
+ EditView* GetFuncEditView();
+ void RemoveAdjust();
+ void RemoveRangeFinder();
+ void DeleteRangeFinder();
+ void UpdateParenthesis();
+ void UpdateAutoCorrFlag();
+ void ResetAutoPar();
+ void AutoParAdded();
+ BOOL CursorAtClosingPar();
+ void SkipClosingPar();
+ DECL_LINK( ModifyHdl, void* );
+ DECL_LINK( ShowHideTipVisibleParentListener, VclWindowEvent* );
+ DECL_LINK( ShowHideTipVisibleSecParentListener, VclWindowEvent* );
+#endif
+
+public:
+ ScInputHandler();
+ virtual ~ScInputHandler();
+
+ void SetMode( ScInputMode eNewMode );
+ BOOL IsInputMode() const { return (eMode != SC_INPUT_NONE); }
+ BOOL IsEditMode() const { return (eMode != SC_INPUT_NONE &&
+ eMode != SC_INPUT_TYPE); }
+ BOOL IsTopMode() const { return (eMode == SC_INPUT_TOP); }
+
+ const String& GetEditString();
+ const String& GetFormString() const { return aFormText; }
+
+ BOOL GetTextAndFields( ScEditEngineDefaulter& rDestEngine );
+
+ BOOL KeyInput( const KeyEvent& rKEvt, BOOL bStartEdit = FALSE );
+ void EnterHandler( BYTE nBlockMode = 0 );
+ void CancelHandler();
+ void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ void AddRefEntry();
+
+ BOOL InputCommand( const CommandEvent& rCEvt, BOOL bForce );
+
+ void InsertFunction( const String& rFuncName, BOOL bAddPar = TRUE );
+ void ClearText();
+
+ void InputSelection( EditView* pView );
+ void InputChanged( EditView* pView, BOOL bFromNotify = FALSE );
+
+ void ViewShellGone(ScTabViewShell* pViewSh);
+ void SetRefViewShell(ScTabViewShell* pRefVsh) {pRefViewSh=pRefVsh;}
+
+ void NotifyChange( const ScInputHdlState* pState, BOOL bForce = FALSE,
+ ScTabViewShell* pSourceSh = NULL,
+ BOOL bStopEditing = TRUE);
+ void UpdateCellAdjust( SvxCellHorJustify eJust );
+
+ void ResetDelayTimer(); //BugId 54702
+
+ void HideTip();
+ void HideTipBelow();
+ void ShowTipCursor();
+ void ShowTip( const String& rText ); // am Cursor
+ void ShowTipBelow( const String& rText );
+
+ void SetRefScale( const Fraction& rX, const Fraction& rY );
+ void UpdateRefDevice();
+
+ EditView* GetActiveView();
+ EditView* GetTableView() { return pTableView; }
+ EditView* GetTopView() { return pTopView; }
+
+ BOOL DataChanging( sal_Unicode cTyped = 0, BOOL bFromCommand = FALSE );
+ void DataChanged( BOOL bFromTopNotify = FALSE );
+
+ BOOL TakesReturn() const { return ( nTipVisible != 0 ); }
+
+ void SetModified() { bModified = TRUE; }
+
+ BOOL GetSelIsRef() const { return bSelIsRef; }
+ void SetSelIsRef(BOOL bSet) { bSelIsRef = bSet; }
+
+ void ShowRefFrame();
+
+ ScRangeFindList* GetRangeFindList() { return pRangeFindList; }
+
+ void UpdateRange( USHORT nIndex, const ScRange& rNew );
+
+ // Kommunikation mit Funktionsautopilot
+ void InputGetSelection ( xub_StrLen& rStart, xub_StrLen& rEnd );
+ void InputSetSelection ( xub_StrLen nStart, xub_StrLen nEnd );
+ void InputReplaceSelection ( const String& rStr );
+ String InputGetFormulaStr ();
+
+ BOOL IsFormulaMode() const { return bFormulaMode; }
+ ScInputWindow* GetInputWindow() { return pInputWin; }
+ void SetInputWindow( ScInputWindow* pNew ) { pInputWin = pNew; }
+ void StopInputWinEngine( BOOL bAll );
+
+ BOOL IsInEnterHandler() const { return bInEnterHandler; }
+ BOOL IsInOwnChange() const { return bInOwnChange; }
+
+ BOOL IsModalMode( SfxObjectShell* pDocSh );
+
+ void ForgetLastPattern();
+
+ void UpdateSpellSettings( BOOL bFromStartTab = FALSE );
+
+ void FormulaPreview();
+
+ Size GetTextSize(); // in 1/100mm
+
+ // eigentlich private, fuer SID_INPUT_SUM public
+ void InitRangeFinder( const String& rFormula );
+
+ static void SetAutoComplete(BOOL bSet) { bAutoComplete = bSet; }
+};
+
+//========================================================================
+// ScInputHdlState
+//========================================================================
+class ScInputHdlState
+{
+ friend class ScInputHandler;
+
+public:
+ ScInputHdlState( const ScAddress& rCurPos,
+ const ScAddress& rStartPos,
+ const ScAddress& rEndPos,
+ const String& rString,
+ const EditTextObject* pData );
+ ScInputHdlState( const ScInputHdlState& rCpy );
+ ~ScInputHdlState();
+
+ ScInputHdlState& operator= ( const ScInputHdlState& r );
+ int operator==( const ScInputHdlState& r ) const;
+ int operator!=( const ScInputHdlState& r ) const
+ { return !operator==( r ); }
+
+ const ScAddress& GetPos() const { return aCursorPos; }
+ const ScAddress& GetStartPos() const { return aStartPos; }
+ const ScAddress& GetEndPos() const { return aEndPos; }
+ const String& GetString() const { return aString; }
+ const EditTextObject* GetEditData() const { return pEditData; }
+
+private:
+ ScAddress aCursorPos;
+ ScAddress aStartPos;
+ ScAddress aEndPos;
+ String aString;
+ EditTextObject* pEditData;
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/inputwin.hxx b/sc/source/ui/inc/inputwin.hxx
new file mode 100644
index 000000000000..5d7dcf781696
--- /dev/null
+++ b/sc/source/ui/inc/inputwin.hxx
@@ -0,0 +1,228 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_INPUTWIN_HXX
+#define SC_INPUTWIN_HXX
+
+#include <vector>
+#include <vcl/toolbox.hxx>
+#include <sfx2/childwin.hxx>
+#include <svl/lstner.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/window.hxx>
+#include <svtools/transfer.hxx>
+
+class ScEditEngineDefaulter;
+class EditView;
+struct ESelection;
+class ScInputHandler;
+class ScAccessibleEditLineTextData;
+struct EENotify;
+class ScRangeList;
+
+//========================================================================
+
+class ScTextWnd : public Window, public DragSourceHelper // edit window
+{
+public:
+ ScTextWnd( Window* pParent );
+ virtual ~ScTextWnd();
+
+ void SetTextString( const String& rString );
+ const String& GetTextString() const;
+
+ BOOL IsInputActive();
+ EditView* GetEditView();
+
+ // fuer FunktionsAutopiloten
+ void MakeDialogEditView();
+
+ void StartEditEngine();
+ void StopEditEngine( BOOL bAll );
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ void SetFormulaMode( BOOL bSet );
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ void InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+ void RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData );
+
+ DECL_LINK( NotifyHdl, EENotify* );
+
+protected:
+ virtual void Paint( const Rectangle& rRec );
+ virtual void Resize();
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void KeyInput(const KeyEvent& rKEvt);
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ virtual String GetText() const;
+
+private:
+ void ImplInitSettings();
+ void UpdateAutoCorrFlag();
+
+private:
+ typedef ::std::vector< ScAccessibleEditLineTextData* > AccTextDataVector;
+
+ String aString;
+ Font aTextFont;
+ ScEditEngineDefaulter* pEditEngine; // erst bei Bedarf angelegt
+ EditView* pEditView;
+ AccTextDataVector maAccTextDatas; // #i105267# text datas may be cloned, remember all copies
+ BOOL bIsRTL;
+ BOOL bIsInsertMode;
+ BOOL bFormulaMode;
+
+ // #102710#; this flag should be true if a key input or a command is handled
+ // it prevents the call of InputChanged in the ModifyHandler of the EditEngine
+ BOOL bInputMode;
+};
+
+//========================================================================
+
+class ScPosWnd : public ComboBox, public SfxListener // Positionsanzeige
+{
+private:
+ String aPosStr;
+ Accelerator* pAccel;
+ ULONG nTipVisible;
+ BOOL bFormulaMode;
+ BOOL bTopHadFocus;
+
+public:
+ ScPosWnd( Window* pParent );
+ virtual ~ScPosWnd();
+
+ void SetPos( const String& rPosStr ); // angezeigter Text
+ void SetFormulaMode( BOOL bSet );
+
+protected:
+ virtual void Select();
+ virtual void Modify();
+
+ virtual long Notify( NotifyEvent& rNEvt );
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+private:
+ void FillRangeNames();
+ void FillFunctions();
+ void DoEnter();
+ void HideTip();
+
+ void ReleaseFocus_Impl();
+};
+
+//========================================================================
+
+class ScInputWindow : public ToolBox // Parent-Toolbox
+{
+public:
+ ScInputWindow( Window* pParent, SfxBindings* pBind );
+ virtual ~ScInputWindow();
+
+ virtual void Resize();
+ virtual void Select();
+
+ void SetFuncString( const String& rString, BOOL bDoEdit = TRUE );
+ void SetPosString( const String& rStr );
+ void SetTextString( const String& rString );
+
+ void SetOkCancelMode();
+ void SetSumAssignMode();
+ void EnableButtons( BOOL bEnable = TRUE );
+
+ void SetFormulaMode( BOOL bSet );
+
+ BOOL IsInputActive();
+ EditView* GetEditView();
+
+ void TextGrabFocus();
+ void TextInvalidate();
+ void SwitchToTextWin();
+
+ void PosGrabFocus();
+
+ // Fuer FunktionsAutopiloten
+ void MakeDialogEditView();
+
+ void StopEditEngine( BOOL bAll );
+
+ void SetInputHandler( ScInputHandler* pNew );
+
+ ScInputHandler* GetInputHandler(){ return pInputHdl;}
+
+ void StateChanged( StateChangedType nType );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+
+protected:
+ virtual void SetText( const String& rString );
+ virtual String GetText() const;
+
+ sal_Bool UseSubTotal( ScRangeList* pRangeList ) const;
+
+private:
+ ScPosWnd aWndPos;
+ ScTextWnd aTextWindow;
+ ScInputHandler* pInputHdl;
+ SfxBindings* pBindings;
+ String aTextOk;
+ String aTextCancel;
+ String aTextSum;
+ String aTextEqual;
+ BOOL bIsOkCancelMode;
+};
+
+//==================================================================
+
+class ScInputWindowWrapper : public SfxChildWindow
+{
+public:
+ ScInputWindowWrapper( Window* pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOW(ScInputWindowWrapper);
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/inscldlg.hxx b/sc/source/ui/inc/inscldlg.hxx
new file mode 100644
index 000000000000..cadebb76358f
--- /dev/null
+++ b/sc/source/ui/inc/inscldlg.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_INSCLDLG_HXX
+#define SC_INSCLDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+
+
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+
+class ScInsertCellDlg : public ModalDialog
+{
+private:
+ FixedLine aFlFrame;
+ RadioButton aBtnCellsDown;
+ RadioButton aBtnCellsRight;
+ RadioButton aBtnInsRows;
+ RadioButton aBtnInsCols;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+public:
+ ScInsertCellDlg( Window* pParent,BOOL bDisallowCellMove = FALSE );
+ ~ScInsertCellDlg();
+
+ InsCellCmd GetInsCellCmd() const;
+};
+
+
+#endif // SC_INSCLDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/inscodlg.hxx b/sc/source/ui/inc/inscodlg.hxx
new file mode 100644
index 000000000000..877e36330c66
--- /dev/null
+++ b/sc/source/ui/inc/inscodlg.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_INSCODLG_HXX
+#define SC_INSCODLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+#include "scui_def.hxx"
+
+class ScInsertContentsDlg : public ModalDialog
+{
+public:
+ ScInsertContentsDlg( Window* pParent,
+ USHORT nCheckDefaults = 0,
+ const String* pStrTitle = NULL );
+ ~ScInsertContentsDlg();
+
+ USHORT GetInsContentsCmdBits() const;
+ USHORT GetFormulaCmdBits() const;
+ BOOL IsSkipEmptyCells() const {return aBtnSkipEmptyCells.IsChecked();}
+ BOOL IsTranspose() const {return aBtnTranspose.IsChecked();}
+ BOOL IsLink() const {return aBtnLink.IsChecked();}
+ InsCellCmd GetMoveMode();
+
+ void SetOtherDoc( BOOL bSet );
+ void SetFillMode( BOOL bSet );
+ void SetChangeTrack( BOOL bSet );
+ void SetCellShiftDisabled( int nDisable );
+
+private:
+ FixedLine aFlFrame;
+ CheckBox aBtnInsAll;
+ CheckBox aBtnInsStrings;
+ CheckBox aBtnInsNumbers;
+ CheckBox aBtnInsDateTime;
+ CheckBox aBtnInsFormulas;
+ CheckBox aBtnInsNotes;
+ CheckBox aBtnInsAttrs;
+ CheckBox aBtnInsObjects;
+
+ FixedLine aFlSep1;
+ FixedLine aFlOptions;
+ CheckBox aBtnSkipEmptyCells;
+ CheckBox aBtnTranspose;
+ CheckBox aBtnLink;
+
+ FixedLine aFlOperation;
+ RadioButton aRbNoOp;
+ RadioButton aRbAdd;
+ RadioButton aRbSub;
+ RadioButton aRbMul;
+ RadioButton aRbDiv;
+
+ FixedLine aFlSep2;
+ FixedLine aFlMove;
+ RadioButton aRbMoveNone;
+ RadioButton aRbMoveDown;
+ RadioButton aRbMoveRight;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ BOOL bOtherDoc;
+ BOOL bFillMode;
+ BOOL bChangeTrack;
+ BOOL bMoveDownDisabled;
+ BOOL bMoveRightDisabled;
+
+ static BOOL bPreviousAllCheck;
+ static USHORT nPreviousChecks;
+ static USHORT nPreviousChecks2;
+ static USHORT nPreviousFormulaChecks;
+ static USHORT nPreviousMoveMode; // enum InsCellCmd
+
+ void DisableChecks( BOOL bInsAllChecked = TRUE );
+ void TestModes();
+
+ // Handler
+ DECL_LINK( InsAllHdl, void* );
+ DECL_LINK( LinkBtnHdl, void* );
+};
+
+
+#endif // SC_INSCODLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/instbdlg.hrc b/sc/source/ui/inc/instbdlg.hrc
new file mode 100644
index 000000000000..1b3388761029
--- /dev/null
+++ b/sc/source/ui/inc/instbdlg.hrc
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc> // -> RID_SCDLG_INSERT_TABLE
+
+//#define RID_SCDLG_INSERT_TABLE 300
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_POSITION 10
+#define RB_BEFORE 11
+#define RB_BEHIND 12
+
+#define FL_TABLE 20
+#define RB_NEW 21
+#define FT_COUNT 22
+#define NF_COUNT 23
+#define FT_NAME 24
+#define ED_TABNAME 25
+#define RB_FROMFILE 26
+#define LB_TABLES 27
+#define BTN_BROWSE 28
+#define CB_LINK 29
+#define FT_PATH 30
+
+
diff --git a/sc/source/ui/inc/instbdlg.hxx b/sc/source/ui/inc/instbdlg.hxx
new file mode 100644
index 000000000000..7fedbcc88d19
--- /dev/null
+++ b/sc/source/ui/inc/instbdlg.hxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_INSTBDLG_HXX
+#define SC_INSTBDLG_HXX
+
+#include "address.hxx"
+
+#include <vcl/button.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/dialog.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <vcl/field.hxx>
+#include "expftext.hxx"
+
+#include <layout/layout.hxx>
+#include <layout/layout-pre.hxx>
+
+class ScViewData;
+class ScDocument;
+class ScDocShell;
+
+namespace sfx2 { class DocumentInserter; }
+namespace sfx2 { class FileDialogHelper; }
+
+//------------------------------------------------------------------------
+
+class ScInsertTableDlg : public ModalDialog
+{
+public:
+ ScInsertTableDlg( Window* pParent, ScViewData& rViewData, SCTAB nTabCount, bool bFromFile );
+ ~ScInsertTableDlg();
+
+ virtual short Execute(); // ueberladen, um Dialog-Parent zu setzen
+
+ BOOL GetTablesFromFile() { return aBtnFromFile.IsChecked(); }
+ BOOL GetTablesAsLink() { return aBtnLink.IsChecked(); }
+
+ const String* GetFirstTable( USHORT* pN = NULL );
+ const String* GetNextTable( USHORT* pN = NULL );
+ ScDocShell* GetDocShellTables() { return pDocShTables; }
+ BOOL IsTableBefore() { return aBtnBefore.IsChecked(); }
+ SCTAB GetTableCount() { return nTableCount;}
+
+private:
+ RadioButton aBtnBefore;
+ RadioButton aBtnBehind;
+ FixedLine aFlPos;
+ RadioButton aBtnNew;
+ RadioButton aBtnFromFile;
+ FixedText aFtCount;
+ NumericField aNfCount;
+ FixedText aFtName;
+ Edit aEdName;
+ MultiListBox aLbTables;
+ ScExpandedFixedText aFtPath;
+ PushButton aBtnBrowse;
+ CheckBox aBtnLink;
+ FixedLine aFlTable;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ Timer aBrowseTimer;
+ ScViewData& rViewData;
+ ScDocument& rDoc;
+ ScDocShell* pDocShTables;
+ sfx2::DocumentInserter* pDocInserter;
+ SfxObjectShellRef aDocShTablesRef;
+
+ bool bMustClose;
+ USHORT nSelTabIndex; // fuer GetFirstTable() / GetNextTable()
+ String aStrCurSelTable;
+ SCTAB nTableCount;
+
+#ifdef SC_INSTBDLG_CXX
+ void Init_Impl( bool bFromFile );
+ void SetNewTable_Impl();
+ void SetFromTo_Impl();
+ void FillTables_Impl( ScDocument* pSrcDoc );
+ void DoEnable_Impl();
+
+ DECL_LINK( BrowseHdl_Impl, PushButton* );
+ DECL_LINK( ChoiceHdl_Impl, RadioButton* );
+ DECL_LINK( SelectHdl_Impl, MultiListBox* );
+ DECL_LINK( CountHdl_Impl, NumericField* );
+ DECL_LINK( DoEnterHdl, PushButton* );
+ DECL_LINK( BrowseTimeoutHdl, Timer* );
+ DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
+#endif
+};
+
+#include <layout/layout-post.hxx>
+
+#endif // SC_INSTBDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/invmerge.hxx b/sc/source/ui/inc/invmerge.hxx
new file mode 100644
index 000000000000..893e4145ce7a
--- /dev/null
+++ b/sc/source/ui/inc/invmerge.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_INVMERGE_HXX
+#define SC_INVMERGE_HXX
+
+#include <tools/gen.hxx>
+
+#include <vector>
+
+class Window;
+
+class ScInvertMerger
+{
+private:
+ Window* pWin;
+ ::std::vector< Rectangle >* pRects;
+ Rectangle aTotalRect;
+ Rectangle aLineRect;
+
+ void FlushLine();
+ void FlushTotal();
+
+public:
+ ScInvertMerger( Window* pWindow );
+ ScInvertMerger( ::std::vector< Rectangle >* pRectangles );
+ ~ScInvertMerger();
+
+ void AddRect( const Rectangle& rRect );
+ void Flush();
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/lbseldlg.hxx b/sc/source/ui/inc/lbseldlg.hxx
new file mode 100644
index 000000000000..17fa0b0ca05e
--- /dev/null
+++ b/sc/source/ui/inc/lbseldlg.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_LBSELDLG_HXX
+#define SC_LBSELDLG_HXX
+
+
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <vcl/button.hxx>
+
+
+#include <vcl/dialog.hxx>
+
+//------------------------------------------------------------------------
+
+class ScSelEntryDlg : public ModalDialog
+{
+private:
+ FixedLine aFlLbTitle;
+ ListBox aLb;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ DECL_LINK( DblClkHdl, void * );
+
+public:
+ ScSelEntryDlg( Window* pParent,
+ USHORT nResId,
+ const String& aTitle,
+ const String& aLbTitle,
+ List& aEntryList );
+ ~ScSelEntryDlg();
+
+ String GetSelectEntry() const;
+};
+
+
+#endif // SC_LBSELDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/linkarea.hrc b/sc/source/ui/inc/linkarea.hrc
new file mode 100644
index 000000000000..f0e9ae7120f2
--- /dev/null
+++ b/sc/source/ui/inc/linkarea.hrc
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc>
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+#define FL_LOCATION 4
+#define CB_URL 5
+#define BTN_BROWSE 6
+#define FT_HINT 7
+#define FT_RANGES 8
+#define LB_RANGES 9
+#define BTN_RELOAD 10
+#define NF_DELAY 11
+#define FT_SECONDS 12
+
diff --git a/sc/source/ui/inc/linkarea.hxx b/sc/source/ui/inc/linkarea.hxx
new file mode 100644
index 000000000000..4c287372be5e
--- /dev/null
+++ b/sc/source/ui/inc/linkarea.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_LINKAREA_HXX
+#define SC_LINKAREA_HXX
+
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svtools/inettbc.hxx>
+
+//REMOVE #ifndef SO2_DECL_SVEMBEDDEDOBJECT_DEFINED
+//REMOVE #define SO2_DECL_SVEMBEDDEDOBJECT_DEFINED
+//REMOVE SO2_DECL_REF(SvEmbeddedObject)
+//REMOVE #endif
+
+namespace sfx2 { class DocumentInserter; }
+namespace sfx2 { class FileDialogHelper; }
+
+class ScDocShell;
+
+//------------------------------------------------------------------------
+
+class ScLinkedAreaDlg : public ModalDialog
+{
+private:
+ FixedLine aFlLocation;
+ SvtURLBox aCbUrl;
+ PushButton aBtnBrowse;
+ FixedInfo aTxtHint;
+ FixedText aFtRanges;
+ MultiListBox aLbRanges;
+ CheckBox aBtnReload;
+ NumericField aNfDelay;
+ FixedText aFtSeconds;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ ScDocShell* pSourceShell;
+ sfx2::DocumentInserter* pDocInserter;
+
+ SfxObjectShellRef aSourceRef;
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > xSourceObject;
+
+ DECL_LINK( FileHdl, ComboBox* );
+ DECL_LINK( BrowseHdl, PushButton* );
+ DECL_LINK( RangeHdl, MultiListBox* );
+ DECL_LINK( ReloadHdl, CheckBox* );
+ DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
+
+ void UpdateSourceRanges();
+ void UpdateEnable();
+ void LoadDocument( const String& rFile, const String& rFilter,
+ const String& rOptions );
+
+public:
+ ScLinkedAreaDlg( Window* pParent );
+ ~ScLinkedAreaDlg();
+
+ void InitFromOldLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ ULONG nRefresh );
+
+ virtual short Execute(); // overwritten to set dialog parent
+
+ String GetURL();
+ String GetFilter(); // may be empty
+ String GetOptions(); // filter options
+ String GetSource(); // separated by ";"
+ ULONG GetRefresh(); // 0 if disabled
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/lnktrans.hxx b/sc/source/ui/inc/lnktrans.hxx
new file mode 100644
index 000000000000..0f345bea6541
--- /dev/null
+++ b/sc/source/ui/inc/lnktrans.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_LNKTRANS_HXX
+#define SC_LNKTRANS_HXX
+
+#include <svtools/transfer.hxx>
+
+
+class ScLinkTransferObj : public TransferableHelper
+{
+private:
+ String aLinkURL;
+ String aLinkText;
+
+public:
+ ScLinkTransferObj();
+ virtual ~ScLinkTransferObj();
+
+ void SetLinkURL( const String& rURL, const String& rText );
+
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void ObjectReleased();
+ virtual void DragFinished( sal_Int8 nDropAction );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/makefile.mk b/sc/source/ui/inc/makefile.mk
new file mode 100644
index 000000000000..1b35ca49549d
--- /dev/null
+++ b/sc/source/ui/inc/makefile.mk
@@ -0,0 +1,26 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
diff --git a/sc/source/ui/inc/mediash.hxx b/sc/source/ui/inc/mediash.hxx
new file mode 100644
index 000000000000..2bdffb9a7c7b
--- /dev/null
+++ b/sc/source/ui/inc/mediash.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef MEDIASH_HXX
+#define MEDIASH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+
+class ScViewData;
+
+#include "drawsh.hxx"
+
+class ScMediaShell: public ScDrawShell
+{
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_MEDIA_SHELL)
+
+ ScMediaShell(ScViewData* pData);
+ virtual ~ScMediaShell();
+
+ void ExecuteMedia(SfxRequest& rReq);
+ void GetMediaState(SfxItemSet &rSet);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc
new file mode 100644
index 000000000000..160c7b026ec1
--- /dev/null
+++ b/sc/source/ui/inc/miscdlgs.hrc
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_DELCELL
+ // -> RID_SCDLG_INSCELL
+ // -> RID_SCDLG_DELCONT
+ // -> RID_SCDLG_INSCONT
+ // -> RID_SCDLG_MOVETAB
+ // -> RID_SCDLG_STRINPUT
+ // -> RID_SCDLG_MTRINPUT
+ // -> RID_SCDLG_SELENTRY
+ // -> RID_SCDLG_FILLSERIES
+ // -> RID_SCDLG_AUTOFORMAT
+
+// Fuer den DesignEditor:
+/*
+#define RID_SCDLG_DELCELL 1256
+#define RID_SCDLG_INSCELL 1257
+#define RID_SCDLG_DELCONT 1258
+#define RID_SCDLG_INSCONT 1259
+#define RID_SCDLG_MOVETAB 1260
+#define RID_SCDLG_STRINPUT 1261
+#define RID_SCDLG_MTRINPUT 1262
+#define RID_SCDLG_SELENTRY 1263
+#define RID_SCDLG_FILLSERIES 1264
+#define RID_SCDLG_AUTOFORMAT 1255
+*/
+
+// allgemein
+#define BTN_OK 100
+#define BTN_CANCEL 102
+#define BTN_HELP 103
+#define BTN_MORE 104
+#define BTN_ADD 105
+#define BTN_REMOVE 106
+#define FT_LABEL 110
+#define FL_FRAME 112
+#define STR_BTN_CLOSE 200
+
+// Zellen loeschen/einfuegen Dialog
+#define BTN_CELLSUP 10
+#define BTN_CELLSDOWN 11
+#define BTN_CELLSRIGHT 12
+#define BTN_CELLSLEFT 13
+#define BTN_DELROWS 14
+#define BTN_DELCOLS 15
+#define BTN_INSROWS 16
+#define BTN_INSCOLS 17
+
+// Inhalte loeschen/einfuegen Dialog
+#define BTN_DELALL 10
+#define BTN_DELSTRINGS 11
+#define BTN_DELNUMBERS 12
+#define BTN_DELDATETIME 13
+#define BTN_DELFORMULAS 14
+#define BTN_DELATTRS 15
+#define BTN_DELNOTES 16
+#define BTN_DELOBJECTS 17
+#define BTN_INSALL 20
+#define BTN_INSSTRINGS 21
+#define BTN_INSNUMBERS 22
+#define BTN_INSDATETIME 23
+#define BTN_INSFORMULAS 24
+#define BTN_INSATTRS 25
+#define BTN_INSNOTES 26
+#define BTN_OP_NOOP 27
+#define BTN_OP_ADD 28
+#define BTN_OP_SUB 29
+#define BTN_OP_MUL 30
+#define BTN_OP_DIV 31
+#define FL_OPERATION 32
+#define BTN_SKIP_EMPTY 33
+#define BTN_TRANSPOSE 34
+#define BTN_LINK 35
+#define FL_OPTIONS 36
+#define BTN_MV_NONE 37
+#define BTN_MV_DOWN 38
+#define BTN_MV_RIGHT 39
+#define FL_MOVE 40
+#define BTN_INSOBJECTS 41
+#define FL_SEP1 51
+#define FL_SEP2 52
+
+// Tabelle einfuegen/loeschen
+#define FT_DEST 1
+#define LB_DEST 2
+#define FT_INSERT 3
+#define LB_INSERT 4
+#define BTN_COPY 5
+#define STR_NEWDOC 6
+
+// Eingabe eines Strings
+#define ED_INPUT 10
+
+// Eingabe einer Metrik
+#define ED_VALUE 1
+#define BTN_DEFVAL 1
+
+// Auswahl aus einer (String-)ListBox
+#define FL_ENTRYLIST 10
+#define LB_ENTRYLIST 11
+
+// Reihen fuellen
+#define FL_DIRECTION 1
+#define BTN_LEFT 2
+#define BTN_RIGHT 3
+#define BTN_TOP 4
+#define BTN_BOTTOM 5
+#define FL_SEP11 10
+#define FL_TYPE 11
+#define BTN_ARITHMETIC 12
+#define BTN_GEOMETRIC 13
+#define BTN_DATE 14
+#define BTN_AUTOFILL 15
+#define FL_SEP12 20
+#define FL_TIME_UNIT 21
+#define BTN_DAY 22
+#define BTN_DAY_OF_WEEK 23
+#define BTN_MONTH 24
+#define BTN_YEAR 25
+#define FT_INCREMENT 30
+#define ED_INCREMENT 39
+#define FT_END_VALUE 40
+#define ED_END_VALUES 49
+#define STR_VALERR 50
+#define FT_START_VALUE 51
+#define ED_START_VALUES 52
+
+// Autoformat
+#define LB_FORMAT 1
+#define FL_FORMAT 9
+#define WND_PREVIEW 19
+#define BTN_NUMFORMAT 20
+#define BTN_BORDER 21
+#define BTN_FONT 23
+#define BTN_PATTERN 24
+#define BTN_ALIGNMENT 25
+#define BTN_ADJUST 26
+#define BTN_RENAME 27
+#define FL_FORMATTING 29
+#define STR_ADD_TITLE 100
+#define STR_ADD_LABEL 101
+#define STR_DEL_TITLE 102
+#define STR_DEL_MSG 103
+#define STR_RENAME_TITLE 104
+ // Autoformat-Preview:
+#define STR_JAN 121
+#define STR_FEB 122
+#define STR_MAR 123
+#define STR_NORTH 124
+#define STR_MID 125
+#define STR_SOUTH 126
+#define STR_SUM 127
+
+// Gruppierung setzen/aufheben:
+#define BTN_GROUP_COLS 1
+#define BTN_GROUP_ROWS 3
+#define STR_GROUP 1
+#define STR_UNGROUP 2
+
+// Tab Bg Color
+#define TAB_BG_COLOR_CT_BORDER 1
+#define TAB_BG_COLOR_SET_BGDCOLOR 2
+
diff --git a/sc/source/ui/inc/msgpool.hxx b/sc/source/ui/inc/msgpool.hxx
new file mode 100644
index 000000000000..6ae9cf8c828d
--- /dev/null
+++ b/sc/source/ui/inc/msgpool.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_MSGPOOL_HXX
+#define SC_MSGPOOL_HXX
+
+#include "scitems.hxx"
+#include <svl/srchitem.hxx>
+
+
+#include <svl/itempool.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+
+#include "uiitems.hxx"
+
+
+//------------------------------------------------------------------------
+
+class ScDocumentPool;
+
+//------------------------------------------------------------------------
+
+class ScMessagePool: public SfxItemPool
+{
+ SfxStringItem aGlobalStringItem;
+ SvxSearchItem aGlobalSearchItem;
+ ScSortItem aGlobalSortItem;
+ ScQueryItem aGlobalQueryItem;
+ ScSubTotalItem aGlobalSubTotalItem;
+ ScConsolidateItem aGlobalConsolidateItem;
+ ScPivotItem aGlobalPivotItem;
+ ScSolveItem aGlobalSolveItem;
+ ScUserListItem aGlobalUserListItem;
+
+ SfxBoolItem aPrintWarnItem;
+
+ SfxPoolItem** ppPoolDefaults;
+ ScDocumentPool* pDocPool;
+
+public:
+ ScMessagePool();
+protected:
+ virtual ~ScMessagePool();
+public:
+
+ virtual SfxMapUnit GetMetric( USHORT nWhich ) const;
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/mtrindlg.hxx b/sc/source/ui/inc/mtrindlg.hxx
new file mode 100644
index 000000000000..f86b368bc4ea
--- /dev/null
+++ b/sc/source/ui/inc/mtrindlg.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_MTRINDLG_HXX
+#define SC_MTRINDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/field.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+
+
+//------------------------------------------------------------------------
+
+class ScMetricInputDlg : public ModalDialog
+{
+public:
+ ScMetricInputDlg( Window* pParent,
+ USHORT nResId, // Ableitung fuer jeden Dialog!
+ long nCurrent,
+ long nDefault,
+ FieldUnit eFUnit = FUNIT_MM,
+ USHORT nDecimals = 2,
+ long nMaximum = 1000,
+ long nMinimum = 0,
+ long nFirst = 1,
+ long nLast = 100 );
+ ~ScMetricInputDlg();
+
+ long GetInputValue( FieldUnit eUnit = FUNIT_TWIP ) const;
+
+private:
+ FixedText aFtEditTitle;
+ MetricField aEdValue;
+ CheckBox aBtnDefVal;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ long nDefaultValue;
+ long nCurrentValue;
+
+ void CalcPositions();
+ DECL_LINK( SetDefValHdl, CheckBox * );
+ DECL_LINK( ModifyHdl, MetricField * );
+};
+
+#endif // SC_MTRINDLG_HXX
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/mvtabdlg.hxx b/sc/source/ui/inc/mvtabdlg.hxx
new file mode 100644
index 000000000000..1260737512a5
--- /dev/null
+++ b/sc/source/ui/inc/mvtabdlg.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_MVTABDLG_HXX
+#define SC_MVTABDLG_HXX
+
+
+#include "address.hxx"
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+
+#include <layout/layout.hxx>
+#include <layout/layout-pre.hxx>
+
+//------------------------------------------------------------------------
+
+class ScMoveTableDlg : public ModalDialog
+{
+public:
+ ScMoveTableDlg( Window* pParent );
+ ~ScMoveTableDlg();
+
+ USHORT GetSelectedDocument () const;
+ SCTAB GetSelectedTable () const;
+ BOOL GetCopyTable () const;
+ void SetCopyTable (BOOL bFlag=TRUE);
+ void EnableCopyTable (BOOL bFlag=TRUE);
+
+private:
+ FixedText aFtDoc;
+ ListBox aLbDoc;
+ FixedText aFtTable;
+ ListBox aLbTable;
+ CheckBox aBtnCopy;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ USHORT nDocument;
+ SCTAB nTable;
+ BOOL bCopyTable;
+ //--------------------------------------
+ void Init ();
+ void InitDocListBox ();
+ DECL_LINK( OkHdl, void * );
+ DECL_LINK( SelHdl, ListBox * );
+};
+
+#include <layout/layout-post.hxx>
+
+#endif // SC_MVTABDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/namecrea.hxx b/sc/source/ui/inc/namecrea.hxx
new file mode 100644
index 000000000000..0719f68adade
--- /dev/null
+++ b/sc/source/ui/inc/namecrea.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NAMECREA_HXX
+#define SC_NAMECREA_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+#include "scui_def.hxx"
+
+class ScNameCreateDlg : public ModalDialog
+{
+protected:
+ FixedLine aFixedLine;
+ CheckBox aTopBox;
+ CheckBox aLeftBox;
+ CheckBox aBottomBox;
+ CheckBox aRightBox;
+ OKButton aOKButton;
+ CancelButton aCancelButton;
+ HelpButton aHelpButton;
+public:
+ ScNameCreateDlg( Window * pParent, USHORT nFlags );
+
+ USHORT GetFlags() const;
+};
+
+
+#endif //SC_NAMECREA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/namedlg.hrc b/sc/source/ui/inc/namedlg.hrc
new file mode 100644
index 000000000000..5381df425e90
--- /dev/null
+++ b/sc/source/ui/inc/namedlg.hrc
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_NAMES
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_ADD 3
+#define BTN_REMOVE 4
+#define BTN_HELP 5
+#define BTN_MORE 6
+//
+#define FL_NAME 11
+#define ED_NAME 12
+#define FL_ASSIGN 13
+#define ED_ASSIGN 15
+#define RB_ASSIGN 16
+//
+#define STR_ADD 21
+#define STR_MODIFY 22
+#define STR_INVALIDSYMBOL 23
+//
+#define BTN_CRITERIA 31
+#define BTN_PRINTAREA 32
+#define BTN_COLHEADER 33
+#define BTN_ROWHEADER 34
+#define FL_TYPE 35
+
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
new file mode 100644
index 000000000000..4ae250bec005
--- /dev/null
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NAMEDLG_HXX
+#define SC_NAMEDLG_HXX
+
+#include <vcl/morebtn.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+#include "rangenam.hxx"
+#include "anyrefdg.hxx"
+
+class ScViewData;
+class ScDocument;
+
+
+//==================================================================
+
+class ScNameDlg : public ScAnyRefDlg
+{
+private:
+ FixedLine aFlName;
+ ComboBox aEdName;
+
+ FixedLine aFlAssign;
+ formula::RefEdit aEdAssign;
+ formula::RefButton aRbAssign;
+
+ FixedLine aFlType;
+ CheckBox aBtnPrintArea;
+ CheckBox aBtnColHeader;
+ CheckBox aBtnCriteria;
+ CheckBox aBtnRowHeader;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ PushButton aBtnAdd;
+ PushButton aBtnRemove;
+ MoreButton aBtnMore;
+ BOOL bSaved;
+
+ const String aStrAdd; // "Hinzufuegen"
+ const String aStrModify; // "Aendern"
+ const String errMsgInvalidSym;
+
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ ScRangeName aLocalRangeName;
+ const ScAddress theCursorPos;
+ Selection theCurSel;
+
+#ifdef _NAMEDLG_CXX
+private:
+ void Init();
+ void UpdateChecks();
+ void UpdateNames();
+ void CalcCurTableAssign( String& aAssign, USHORT nPos );
+
+ // Handler:
+ DECL_LINK( OkBtnHdl, void * );
+ DECL_LINK( CancelBtnHdl, void * );
+ DECL_LINK( AddBtnHdl, void * );
+ DECL_LINK( RemoveBtnHdl, void * );
+ DECL_LINK( EdModifyHdl, Edit * );
+ DECL_LINK( NameSelectHdl, void * );
+ DECL_LINK( AssignGetFocusHdl, void * );
+#endif
+
+protected:
+
+ virtual void RefInputDone( BOOL bForced = FALSE );
+
+
+public:
+ ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData,
+ const ScAddress& aCursorPos );
+ ~ScNameDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual BOOL IsRefInputMode() const;
+
+ virtual void SetActive();
+ virtual BOOL Close();
+
+};
+
+
+
+#endif // SC_NAMEDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/namepast.hxx b/sc/source/ui/inc/namepast.hxx
new file mode 100644
index 000000000000..b006b4146307
--- /dev/null
+++ b/sc/source/ui/inc/namepast.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NAMEPAST_HXX
+#define SC_NAMEPAST_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+#include "scui_def.hxx"
+class ScRangeName;
+
+class ScNamePasteDlg : public ModalDialog
+{
+ DECL_LINK( ButtonHdl, Button * );
+ DECL_LINK( ListSelHdl, ListBox * );
+ DECL_LINK( ListDblClickHdl, ListBox * );
+
+protected:
+ FixedText aLabelText;
+ ListBox aNameList;
+ OKButton aOKButton;
+ CancelButton aCancelButton;
+ HelpButton aHelpButton;
+ PushButton aInsListButton;
+public:
+ ScNamePasteDlg( Window * pParent, const ScRangeName* pList, BOOL bInsList=TRUE );
+
+ String GetSelectedName() const;
+};
+
+
+#endif //SC_NAMEPAST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/navcitem.hxx b/sc/source/ui/inc/navcitem.hxx
new file mode 100644
index 000000000000..366511e484d0
--- /dev/null
+++ b/sc/source/ui/inc/navcitem.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NAVCITEM_HXX
+#define SC_NAVCITEM_HXX
+
+
+#include <sfx2/ctrlitem.hxx>
+
+
+//==================================================================
+
+class ScNavigatorDlg;
+
+class ScNavigatorControllerItem : public SfxControllerItem
+{
+public:
+ ScNavigatorControllerItem( USHORT nId,
+ ScNavigatorDlg& rDlg,
+ SfxBindings& rBindings );
+protected:
+ virtual void StateChanged( USHORT nSID, SfxItemState eState,
+ const SfxPoolItem* pItem );
+
+private:
+ ScNavigatorDlg& rNavigatorDlg;
+};
+
+
+#endif // SC_NAVCITEM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/navipi.hxx b/sc/source/ui/inc/navipi.hxx
new file mode 100644
index 000000000000..4eaad27040c2
--- /dev/null
+++ b/sc/source/ui/inc/navipi.hxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NAVIPI_HXX
+#define SC_NAVIPI_HXX
+
+#include <vector>
+#include <vcl/toolbox.hxx>
+#include <vcl/field.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svl/poolitem.hxx>
+#include <svl/lstner.hxx>
+#include <sfx2/childwin.hxx>
+#include "content.hxx"
+#include <svtools/svmedit.hxx>
+
+
+class ScTabViewShell;
+class ScViewData;
+class ScArea;
+class ScScenarioWindow;
+class ScNavigatorControllerItem;
+class ScNavigatorDialogWrapper;
+class ScNavigatorDlg;
+class ScNavigatorSettings;
+class ScRange;
+
+//========================================================================
+
+#define SC_DROPMODE_URL 0
+#define SC_DROPMODE_LINK 1
+#define SC_DROPMODE_COPY 2
+
+enum NavListMode { NAV_LMODE_NONE = 0x4000,
+ NAV_LMODE_AREAS = 0x2000,
+ NAV_LMODE_DBAREAS = 0x1000,
+ NAV_LMODE_DOCS = 0x800,
+ NAV_LMODE_SCENARIOS = 0x400 };
+
+//========================================================================
+// class ScScenarioListBox -----------------------------------------------
+//========================================================================
+
+class ScScenarioListBox : public ListBox
+{
+public:
+ explicit ScScenarioListBox( ScScenarioWindow& rParent );
+ virtual ~ScScenarioListBox();
+
+ void UpdateEntries( List* pNewEntryList );
+
+protected:
+ virtual void Select();
+ virtual void DoubleClick();
+ virtual long Notify( NotifyEvent& rNEvt );
+
+private:
+ struct ScenarioEntry
+ {
+ String maName;
+ String maComment;
+ bool mbProtected;
+
+ inline explicit ScenarioEntry() : mbProtected( false ) {}
+ };
+ typedef ::std::vector< ScenarioEntry > ScenarioList;
+
+private:
+ const ScenarioEntry* GetSelectedEntry() const;
+
+ void ExecuteScenarioSlot( USHORT nSlotId );
+ void SelectScenario();
+ void EditScenario();
+ void DeleteScenario( bool bQueryBox );
+
+private:
+ ScScenarioWindow& mrParent;
+ ScenarioList maEntries;
+};
+
+//========================================================================
+// class ScScenarioWindow ------------------------------------------------
+//========================================================================
+class ScScenarioWindow : public Window
+{
+public:
+ ScScenarioWindow( Window* pParent,const String& aQH_List,const String& aQH_Comment);
+ ~ScScenarioWindow();
+
+ void NotifyState( const SfxPoolItem* pState );
+ void SetComment( const String& rComment )
+ { aEdComment.SetText( rComment ); }
+
+ void SetSizePixel( const Size& rNewSize );
+
+protected:
+
+ virtual void Paint( const Rectangle& rRec );
+
+private:
+ ScScenarioListBox aLbScenario;
+ MultiLineEdit aEdComment;
+};
+
+//==================================================================
+// class ColumnEdit
+//==================================================================
+class ColumnEdit : public SpinField
+{
+public:
+ ColumnEdit( ScNavigatorDlg* pParent, const ResId& rResId );
+ ~ColumnEdit();
+
+ SCCOL GetCol() { return nCol; }
+ void SetCol( SCCOL nColNo );
+
+protected:
+ virtual long Notify( NotifyEvent& rNEvt );
+ virtual void LoseFocus();
+ virtual void Up();
+ virtual void Down();
+ virtual void First();
+ virtual void Last();
+
+private:
+ ScNavigatorDlg& rDlg;
+ SCCOL nCol;
+ USHORT nKeyGroup;
+
+ void EvalText ();
+ void ExecuteCol ();
+ SCCOL AlphaToNum ( String& rStr );
+ SCCOL NumStrToAlpha ( String& rStr );
+ SCCOL NumToAlpha ( SCCOL nColNo, String& rStr );
+};
+
+
+//==================================================================
+// class RowEdit
+//==================================================================
+class RowEdit : public NumericField
+{
+public:
+ RowEdit( ScNavigatorDlg* pParent, const ResId& rResId );
+ ~RowEdit();
+
+ SCROW GetRow() { return (SCROW)GetValue(); }
+ void SetRow( SCROW nRow ){ SetValue( nRow ); }
+
+protected:
+ virtual long Notify( NotifyEvent& rNEvt );
+ virtual void LoseFocus();
+
+private:
+ ScNavigatorDlg& rDlg;
+
+ void ExecuteRow();
+};
+
+
+//==================================================================
+// class ScDocListBox
+//==================================================================
+class ScDocListBox : public ListBox
+{
+public:
+ ScDocListBox( ScNavigatorDlg* pParent, const ResId& rResId );
+ ~ScDocListBox();
+
+protected:
+ virtual void Select();
+
+private:
+ ScNavigatorDlg& rDlg;
+};
+
+
+//==================================================================
+// class CommandToolBox
+//==================================================================
+class CommandToolBox : public ToolBox
+{
+public:
+ CommandToolBox( ScNavigatorDlg* pParent, const ResId& rResId );
+ ~CommandToolBox();
+
+ void Select( USHORT nId );
+ void UpdateButtons();
+ void InitImageList();
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ DECL_LINK( ToolBoxDropdownClickHdl, ToolBox* );
+
+protected:
+ virtual void Select();
+ virtual void Click();
+
+private:
+ ScNavigatorDlg& rDlg;
+};
+
+//==================================================================
+// class ScNavigatorDlg
+//==================================================================
+
+class ScNavigatorDlg : public Window, public SfxListener
+{
+friend class ScNavigatorControllerItem;
+friend class ScNavigatorDialogWrapper;
+friend class ColumnEdit;
+friend class RowEdit;
+friend class ScDocListBox;
+friend class CommandToolBox;
+friend class ScContentTree;
+
+private:
+ SfxBindings& rBindings; // must be first member
+
+ ImageList aCmdImageList; // must be before aTbxCmd
+ ImageList aCmdImageListH;
+ FixedInfo aFtCol;
+ ColumnEdit aEdCol;
+ FixedInfo aFtRow;
+ RowEdit aEdRow;
+ CommandToolBox aTbxCmd;
+ ScContentTree aLbEntries;
+ ScScenarioWindow aWndScenarios;
+ ScDocListBox aLbDocuments;
+
+ Timer aContentTimer;
+
+ String aTitleBase;
+ String aStrDragMode;
+ String aStrDisplay;
+ String aStrActive;
+ String aStrNotActive;
+ String aStrHidden;
+ String aStrActiveWin;
+
+ SfxChildWindowContext* pContextWin;
+ Size aInitSize;
+ ScArea* pMarkArea;
+ ScViewData* pViewData;
+
+ long nBorderOffset;
+ long nListModeHeight;
+ long nInitListHeight;
+ NavListMode eListMode;
+ USHORT nDropMode;
+ SCCOL nCurCol;
+ SCROW nCurRow;
+ SCTAB nCurTab;
+ BOOL bFirstBig;
+
+ ScNavigatorControllerItem** ppBoundItems;
+
+ DECL_LINK( TimeHdl, Timer* );
+
+ void DoResize();
+
+ SfxBindings& GetBindings()
+ { return rBindings; }
+
+ void SetCurrentCell( SCCOL nCol, SCROW Row );
+ void SetCurrentCellStr( const String rName );
+ void SetCurrentTable( SCTAB nTab );
+ void SetCurrentTableStr( const String rName );
+ void SetCurrentObject( const String rName );
+ void SetCurrentDoc( const String& rDocName );
+
+ ScTabViewShell* GetTabViewShell() const;
+ ScNavigatorSettings* GetNavigatorSettings();
+ BOOL GetViewData();
+
+ void UpdateColumn ( const SCCOL* pCol = NULL );
+ void UpdateRow ( const SCROW* pRow = NULL );
+ void UpdateTable ( const SCTAB* pTab = NULL );
+ void UpdateAll ();
+
+ void GetDocNames(const String* pSelEntry = NULL);
+
+ void SetListMode ( NavListMode eMode, BOOL bSetSize = TRUE );
+ void ShowList ( BOOL bShow, BOOL bSetSize );
+ void ShowScenarios ( BOOL bShow, BOOL bSetSize );
+
+ void SetDropMode(USHORT nNew);
+ USHORT GetDropMode() const { return nDropMode; }
+
+ const String& GetStrDragMode() const { return aStrDragMode; }
+ const String& GetStrDisplay() const { return aStrDisplay; }
+
+ void CheckDataArea ();
+ void MarkDataArea ();
+ void UnmarkDataArea ();
+ void StartOfDataArea ();
+ void EndOfDataArea ();
+
+ static void ReleaseFocus();
+
+protected:
+ virtual void Resize();
+ virtual void Paint( const Rectangle& rRec );
+ virtual void Resizing( Size& rSize );
+
+public:
+ ScNavigatorDlg( SfxBindings* pB, SfxChildWindowContext* pCW, Window* pParent );
+ ~ScNavigatorDlg();
+
+ using Window::Notify;
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ void CursorPosChanged();
+
+ virtual SfxChildAlignment
+ CheckAlignment(SfxChildAlignment,SfxChildAlignment);
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+};
+
+//==================================================================
+
+class ScNavigatorDialogWrapper: public SfxChildWindowContext
+{
+public:
+ ScNavigatorDialogWrapper( Window* pParent,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo );
+
+ SFX_DECL_CHILDWINDOWCONTEXT(ScNavigatorDialogWrapper)
+
+ virtual void Resizing( Size& rSize );
+
+private:
+ ScNavigatorDlg* pNavigator;
+};
+
+
+
+#endif // SC_NAVIPI_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/navsett.hxx b/sc/source/ui/inc/navsett.hxx
new file mode 100644
index 000000000000..1b9fff2bbfa8
--- /dev/null
+++ b/sc/source/ui/inc/navsett.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NAVSETT_HXX
+#define SC_NAVSETT_HXX
+
+#include <tools/solar.h>
+
+#include <vector>
+
+/** Contains settings of the navigator listbox. This includes the expand state
+ of each listbox entry and the index of the selected entry and sub entry. */
+class ScNavigatorSettings
+{
+private:
+ ::std::vector< BOOL > maExpandedVec; /// Array of Booleans for expand state.
+ USHORT mnRootSelected; /// Index of selected root entry.
+ ULONG mnChildSelected; /// Index of selected child entry.
+
+public:
+ ScNavigatorSettings();
+
+ inline void SetExpanded( USHORT nIndex, BOOL bExpand ) { maExpandedVec[ nIndex ] = bExpand; }
+ inline BOOL IsExpanded( USHORT nIndex ) const { return maExpandedVec[ nIndex ]; }
+
+ inline void SetRootSelected( USHORT nIndex ) { mnRootSelected = nIndex; }
+ inline USHORT GetRootSelected() const { return mnRootSelected; }
+
+ inline void SetChildSelected( ULONG nIndex ) { mnChildSelected = nIndex; }
+ inline ULONG GetChildSelected() const { return mnChildSelected; }
+};
+
+
+#endif // SC_NAVSETT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/notemark.hxx b/sc/source/ui/inc/notemark.hxx
new file mode 100644
index 000000000000..11eb7c152f22
--- /dev/null
+++ b/sc/source/ui/inc/notemark.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_NOTEMARK_HXX
+#define SC_NOTEMARK_HXX
+
+#include <vcl/mapmod.hxx>
+#include <vcl/timer.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+class SdrModel;
+class SdrObject;
+
+class ScNoteMarker
+{
+private:
+ Window* pWindow;
+ Window* pRightWin;
+ Window* pBottomWin;
+ Window* pDiagWin;
+ ScDocument* pDoc;
+ ScAddress aDocPos;
+ String aUserText;
+ Rectangle aVisRect;
+ Timer aTimer;
+ MapMode aMapMode;
+ BOOL bLeft;
+ BOOL bByKeyboard;
+
+ Rectangle aRect;
+ SdrModel* pModel;
+ SdrObject* pObject;
+ BOOL bVisible;
+
+ DECL_LINK( TimeHdl, Timer* );
+
+public:
+ ScNoteMarker( Window* pWin, Window* pRight, Window* pBottom, Window* pDiagonal,
+ ScDocument* pD, ScAddress aPos, const String& rUser,
+ const MapMode& rMap, BOOL bLeftEdge, BOOL bForce, BOOL bKeyboard );
+ ~ScNoteMarker();
+
+ void Draw();
+ void InvalidateWin();
+
+ ScAddress GetDocPos() const { return aDocPos; }
+ BOOL IsByKeyboard() const { return bByKeyboard; }
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/oleobjsh.hxx b/sc/source/ui/inc/oleobjsh.hxx
new file mode 100644
index 000000000000..214c320b3024
--- /dev/null
+++ b/sc/source/ui/inc/oleobjsh.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef OLEOBJSH_HXX
+#define OLEOBJSH_HXX
+
+#include <sfx2/shell.hxx>
+#include "shellids.hxx"
+#include <sfx2/module.hxx>
+#include <svx/svdmark.hxx>
+
+class ScViewData;
+
+#include "drawsh.hxx"
+
+class ScOleObjectShell: public ScDrawShell
+{
+public:
+
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_OLEOBJECT_SHELL)
+
+ ScOleObjectShell(ScViewData* pData);
+ virtual ~ScOleObjectShell();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/olinefun.hxx b/sc/source/ui/inc/olinefun.hxx
new file mode 100644
index 000000000000..3f9db1cc88ed
--- /dev/null
+++ b/sc/source/ui/inc/olinefun.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_OLINEFUN_HXX
+#define SC_OLINEFUN_HXX
+
+#include "global.hxx"
+
+class ScDocShell;
+class ScRange;
+
+
+// ---------------------------------------------------------------------------
+
+class ScOutlineDocFunc
+{
+private:
+ ScDocShell& rDocShell;
+
+public:
+ ScOutlineDocFunc( ScDocShell& rDocSh ): rDocShell(rDocSh) {}
+ ~ScOutlineDocFunc() {}
+
+ BOOL MakeOutline( const ScRange& rRange, BOOL bColumns, BOOL bRecord, BOOL bApi );
+ BOOL RemoveOutline( const ScRange& rRange, BOOL bColumns, BOOL bRecord, BOOL bApi );
+ BOOL RemoveAllOutlines( SCTAB nTab, BOOL bRecord, BOOL bApi );
+ BOOL AutoOutline( const ScRange& rRange, BOOL bRecord, BOOL bApi );
+
+ BOOL SelectLevel( SCTAB nTab, BOOL bColumns, USHORT nLevel,
+ BOOL bRecord, BOOL bPaint, BOOL bApi );
+
+ BOOL ShowMarkedOutlines( const ScRange& rRange, BOOL bRecord, BOOL bApi );
+ BOOL HideMarkedOutlines( const ScRange& rRange, BOOL bRecord, BOOL bApi );
+
+ BOOL ShowOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, USHORT nEntry,
+ BOOL bRecord, BOOL bPaint, BOOL bApi );
+ BOOL HideOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, USHORT nEntry,
+ BOOL bRecord, BOOL bPaint, BOOL bApi );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/olinewin.hxx b/sc/source/ui/inc/olinewin.hxx
new file mode 100644
index 000000000000..abe893a94d61
--- /dev/null
+++ b/sc/source/ui/inc/olinewin.hxx
@@ -0,0 +1,246 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_OLINEWIN_HXX
+#define SC_OLINEWIN_HXX
+
+#include "viewdata.hxx"
+
+class ScOutlineEntry;
+class ScOutlineArray;
+class ScOutlineTable;
+
+
+// ============================================================================
+
+enum ScOutlineMode { SC_OUTLINE_HOR, SC_OUTLINE_VER };
+
+
+// ----------------------------------------------------------------------------
+
+/** The window left of or above the spreadsheet containing the outline groups
+ and controls to expand/collapse them. */
+class ScOutlineWindow : public Window
+{
+private:
+ ScViewData& mrViewData; /// View data containing the document.
+ ScSplitPos meWhich; /// Which area in split window.
+ bool mbHoriz; /// true = Horizontal orientation.
+ bool mbMirrorEntries; /// true = mirror the order of entries (including header)
+ bool mbMirrorLevels; /// true = mirror the order of levels, including the border
+
+ ImageList* mpSymbols; /// Symbols for buttons.
+ Color maLineColor; /// Line color for expanded groups.
+ long mnHeaderSize; /// Size of the header area in entry direction.
+ long mnHeaderPos; /// Position of the header area in entry direction.
+ long mnMainFirstPos; /// First position of main area in entry direction.
+ long mnMainLastPos; /// Last position of main area in entry direction.
+
+ size_t mnMTLevel; /// Mouse tracking: Level of active button.
+ size_t mnMTEntry; /// Mouse tracking: Entry index of active button.
+ bool mbMTActive; /// Mouse tracking active?
+ bool mbMTPressed; /// Mouse tracking: Button currently drawed pressed?
+
+ Rectangle maFocusRect; /// Focus rectangle on screen.
+ size_t mnFocusLevel; /// Level of focused button.
+ size_t mnFocusEntry; /// Entry index of focused button.
+ bool mbDontDrawFocus; /// Do not redraw focus in next Paint().
+
+public:
+ ScOutlineWindow(
+ Window* pParent,
+ ScOutlineMode eMode,
+ ScViewData* pViewData,
+ ScSplitPos eWhich );
+ virtual ~ScOutlineWindow();
+
+ /** Sets the size of the header area (width/height dep. on window type). */
+ void SetHeaderSize( long nNewSize );
+ /** Returns the width/height the window needs to show all levels. */
+ long GetDepthSize() const;
+
+ /** Scrolls the window content by the specified amount of pixels. */
+ void ScrollPixel( long nDiff );
+
+ using Window::ShowFocus;
+
+private:
+ /** Initializes color and image settings. */
+ void InitSettings();
+
+ /** Returns the calc document. */
+ inline ScDocument& GetDoc() const { return *mrViewData.GetDocument(); }
+ /** Returns the current sheet index. */
+ inline SCTAB GetTab() const { return mrViewData.GetTabNo(); }
+ /** Returns the outline array of the corresponding document. */
+ const ScOutlineArray* GetOutlineArray() const;
+ /** Returns the specified outline entry. */
+ const ScOutlineEntry* GetOutlineEntry( size_t nLevel, size_t nEntry ) const;
+
+ /** Returns true, if the column/row is hidden. */
+ bool IsHidden( SCCOLROW nColRowIndex ) const;
+ /** Returns true, if the column/row is filtered. */
+ bool IsFiltered( SCCOLROW nColRowIndex ) const;
+ /** Returns true, if all columns/rows before nColRowIndex are hidden. */
+ bool IsFirstVisible( SCCOLROW nColRowIndex ) const;
+ /** Returns the currently visible column/row range. */
+ void GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const;
+
+ /** Returns the point in the window of the specified position. */
+ Point GetPoint( long nLevelPos, long nEntryPos ) const;
+ /** Returns the rectangle in the window of the specified position. */
+ Rectangle GetRectangle(
+ long nLevelStart, long nEntryStart,
+ long nLevelEnd, long nEntryEnd ) const;
+
+ /** Returns the window size for the level coordinate. */
+ long GetOutputSizeLevel() const;
+ /** Returns the window size for the entry coordinate. */
+ long GetOutputSizeEntry() const;
+
+ /** Returns the count of levels of the outline array. 0 means no outlines. */
+ size_t GetLevelCount() const;
+ /** Returns the pixel position of the specified level. */
+ long GetLevelPos( size_t nLevel ) const;
+ /** Returns the level of the passed pixel position. */
+ size_t GetLevelFromPos( long nLevelPos ) const;
+
+ /** Returns the start coordinate of the specified column/row in the window. */
+ long GetColRowPos( SCCOLROW nColRowIndex ) const;
+ /** Returns the entry position of header images. */
+ long GetHeaderEntryPos() const;
+ /** Calculates the coordinates the outline entry takes in the window.
+ @return false = no part of the group is visible (outside window or collapsed by parent group). */
+ bool GetEntryPos(
+ size_t nLevel, size_t nEntry,
+ long& rnStartPos, long& rnEndPos, long& rnImagePos ) const;
+ /** Calculates the absolute position of the image of the specified outline entry.
+ @param nLevel The level of the entry.
+ @param nEntry The entry index or SC_OL_HEADERENTRY for the header image.
+ @return false = image is not visible. */
+ bool GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const;
+ /** Returns true, if the button of the specified entry is visible in the window. */
+ bool IsButtonVisible( size_t nLevel, size_t nEntry ) const;
+
+ /** Returns true, if rPos is inside of a button or over the line of an expanded
+ group. The outline entry data is stored in the passed variables. */
+ bool ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const;
+ /** Returns true, if rPos is inside of a button.
+ The button data is stored in the passed variables. */
+ bool ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
+ /** Returns true, if rPos is over the line of an expanded group.
+ The outline entry data is stored in the passed variables. */
+ bool LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const;
+
+ /** Performs an action with the specified item.
+ @param nLevel The level of the entry.
+ @param nEntry The entry index or SC_OL_HEADERENTRY for the header entry. */
+ void DoFunction( size_t nLevel, size_t nEntry ) const;
+ /** Expands the specified entry (does nothing with header entries). */
+ void DoExpand( size_t nLevel, size_t nEntry ) const;
+ /** Collapses the specified entry (does nothing with header entries). */
+ void DoCollapse( size_t nLevel, size_t nEntry ) const;
+
+ /** Returns true, if the focused button is visible in the window. */
+ bool IsFocusButtonVisible() const;
+
+ /** Calculates index of next/previous focus button in the current level (no paint).
+ @param bFindVisible true = repeats until a visible button has been found.
+ @return true = focus wrapped from end to start or vice versa. */
+ bool ImplMoveFocusByEntry( bool bForward, bool bFindVisible );
+ /** Calculates position of focus button in next/previous level (no paint).
+ @return true = focus wrapped from end to start or vice versa. */
+ bool ImplMoveFocusByLevel( bool bForward );
+ /** Calculates position of focus button in tab order.
+ @param bFindVisible true = repeats until a visible button has been found.
+ @return true = focus wrapped from end to start or vice versa. */
+ bool ImplMoveFocusByTabOrder( bool bForward, bool bFindVisible );
+
+ /** If the focused entry is invisible, tries to move to visible position. */
+ void ImplMoveFocusToVisible( bool bForward );
+
+ /** Focuses next/previous button in the current level. */
+ void MoveFocusByEntry( bool bForward );
+ /** Focuses button in next/previous level. */
+ void MoveFocusByLevel( bool bForward );
+ /** Focuses next/previous button in tab order. */
+ void MoveFocusByTabOrder( bool bForward );
+
+ /** Starts mouse tracking after click on a button. */
+ void StartMouseTracking( size_t nLevel, size_t nEntry );
+ /** Returns whether mouse tracking mode is active. */
+ inline bool IsMouseTracking() const { return mbMTActive; }
+ /** Ends mouse tracking. */
+ void EndMouseTracking();
+
+ /** Sets a clip region for the window area without header. */
+ void SetEntryAreaClipRegion();
+ /** Converts coordinates to real window points and draws the line. */
+ void DrawLineRel(
+ long nLevelStart, long nEntryStart,
+ long nLevelEnd, long nEntryEnd );
+ /** Converts coordinates to real window points and draws the rectangle. */
+ void DrawRectRel(
+ long nLevelStart, long nEntryStart,
+ long nLevelEnd, long nEntryEnd );
+ /** Draws the specified image unpressed. */
+ void DrawImageRel( long nLevelPos, long nEntryPos, USHORT nId );
+ /** Draws a pressed or unpressed border. */
+ void DrawBorderRel( size_t nLevel, size_t nEntry, bool bPressed );
+
+ /** Draws the focus rectangle into the focused button. */
+ void ShowFocus();
+ /** Erases the focus rectangle from the focused button. */
+ void HideFocus();
+
+ /** Scrolls the specified range of the window in entry-relative direction. */
+ void ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd );
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+public:
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/opredlin.hrc b/sc/source/ui/inc/opredlin.hrc
new file mode 100644
index 000000000000..212ee87878bf
--- /dev/null
+++ b/sc/source/ui/inc/opredlin.hrc
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc" // -> RID_SCPAGE_OPREDLINE
+
+#define FT_CONTENT 1
+#define FT_REMOVE 2
+#define FT_INSERT 3
+#define FT_MOVE 4
+#define GB_COLORCHGS 1
+#define CLB_CONTENT 1
+#define CLB_REMOVE 2
+#define CLB_INSERT 3
+#define CLB_MOVE 4
+#define STR_AUTHOR 1
diff --git a/sc/source/ui/inc/opredlin.hxx b/sc/source/ui/inc/opredlin.hxx
new file mode 100644
index 000000000000..b1bf9107c5bf
--- /dev/null
+++ b/sc/source/ui/inc/opredlin.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SC_OPREDLIN_HXX
+#define _SC_OPREDLIN_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/group.hxx>
+
+#include <vcl/button.hxx>
+
+#include <vcl/lstbox.hxx>
+
+#include <vcl/field.hxx>
+
+#include <vcl/fixed.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <svx/fntctrl.hxx>
+#include <svx/strarray.hxx>
+
+/*-----------------------------------------------------------------------
+ Beschreibung: Redlining-Optionen
+ -----------------------------------------------------------------------*/
+
+class ScRedlineOptionsTabPage : public SfxTabPage
+{
+ FixedText aContentFT;
+ ColorListBox aContentColorLB;
+ FixedText aRemoveFT;
+ ColorListBox aRemoveColorLB;
+ FixedText aInsertFT;
+ ColorListBox aInsertColorLB;
+ FixedText aMoveFT;
+ ColorListBox aMoveColorLB;
+ FixedLine aChangedGB;
+ String aAuthorStr;
+ DECL_LINK( ColorHdl, ColorListBox *pColorLB );
+
+
+public:
+
+ ScRedlineOptionsTabPage( Window* pParent, const SfxItemSet& rSet );
+ ~ScRedlineOptionsTabPage();
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rAttrSet );
+
+ virtual BOOL FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/optdlg.hrc b/sc/source/ui/inc/optdlg.hrc
new file mode 100644
index 000000000000..d409ad32ed24
--- /dev/null
+++ b/sc/source/ui/inc/optdlg.hrc
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+
+#define TP_GENERAL 1
+#define TP_SAVE 2
+#define TP_PATH 3
+#define TP_SPELL 4
+#define TP_VIEW 5
+#define TP_CALC 6
+#define TP_USERLISTS 7
+#define TP_PRINT 8
+#define TP_COLORS 9
+#define TP_GRID 10
+#define TP_CONTENT 11
+#define TP_LAYOUT 12
+#define TP_INPUT 13
+#define TP_CHANGES 14
+#define TP_FORMULA 15
+
+// TP_CALC:
+#define BTN_ITERATE 1
+#define FT_STEPS 2
+#define FT_EPS 3
+#define ED_STEPS 4
+#define ED_EPS 5
+#define GB_ZREFS 6
+#define ED_PREC 7
+#define FT_PREC 8
+#define BTN_DATESTD 9
+#define BTN_DATESC10 10
+#define BTN_DATE1904 11
+#define FT_VALUE 13
+#define GB_DATE 14
+#define BTN_CASE 15
+#define FT_CASE 16
+#define BTN_CALC 17
+#define BTN_MATCH 18
+#define BTN_LOOKUP 19
+#define BTN_REGEX 20
+#define BTN_GENERAL_PREC 21
+
+// TP_VIEW:
+#define BTN_VSCROLL 1
+#define BTN_HSCROLL 2
+#define BTN_REGISTER 3
+#define BTN_OUTLINER 4
+#define BTN_HEADERFOOTER 5
+#define BTN_GRID 6
+#define BTN_SYNTAX 7
+#define LB_GRIDCOLOR 9
+#define GB_ELEMENTS 10
+#define BTN_HELPLINES 11
+
+#define BTN_FORMULAS 20
+#define BTN_NULLVALS 21
+#define BTN_NOTES 22
+#define GB_CONTENTS 23
+
+
+// TP_USERLISTS:
+#define FT_LISTS 1
+#define LB_LISTS 1
+#define FT_ENTRIES 2
+#define ED_ENTRIES 2
+#define FT_COPYFROM 3
+#define ED_COPYFROM 3
+#define BTN_NEW 1
+#define BTN_ADD 2
+#define BTN_REMOVE 3
+#define BTN_COPY 4
+#define STR_QUERYREMOVE 5
+#define STR_DISMISS 6
+#define STR_COPYLIST 7
+#define STR_COPYFROM 8
+#define STR_COPYERR 9
+
+// TP_PRINT:
+#define FL_PAGES 1
+#define BTN_SKIPEMPTYPAGES 2
+#define FL_SHEETS 2
+#define BTN_SELECTEDSHEETS 4
+
+// TP_LCONTENT
+
+#define GB_DISPLAY 20
+#define CB_FORMULA 21
+#define CB_NIL 22
+#define CB_ANNOT 23
+#define CB_VALUE 24
+#define CB_ANCHOR 25
+#define GB_OBJECT 26
+#define FT_OBJGRF 27
+#define LB_OBJGRF 28
+#define FT_DIAGRAM 29
+#define LB_DIAGRAM 30
+#define FT_DRAW 31
+#define LB_DRAW 32
+#define CB_CLIP 33
+#define GB_ZOOM 34
+#define CB_SYNCZOOM 35
+
+// TP_LAYOUT
+#define GB_LINK 1
+#define RB_ALWAYS 2
+#define RB_REQUEST 3
+#define RB_NEVER 4
+#define CB_DOCONLY 5
+#define CB_MERGE_PARA_DIST 6
+#define GB_COMPAT 7
+#define CB_AUTO_UPDATE_FIELDS 8
+#define CB_AUTO_UPDATE_CHARTS 9
+#define FT_UPDATE_LINKS 10
+
+#define GB_WINDOW 50
+#define CB_ROWCOLHEADER 51
+#define CB_HSCROLL 52
+#define CB_VSCROLL 53
+#define CB_TBLREG 54
+#define CB_OUTLINE 55
+#define GB_LINES 56
+#define CB_GRID 57
+#define FT_COLOR 58
+#define LB_COLOR 59
+#define CB_GUIDELINE 60
+#define GB_UNIT 61
+#define LB_UNIT 62
+#define ST_UNIT 63
+#define GB_TAB 64
+#define MF_TAB 65
+#define CB_PAGEBREAKS 66
+#define CB_HANDLES 67
+#define CB_BIGHANDLES 68
+#define FT_TAB 69
+#define FT_UNIT 70
+#define FL_SEPARATOR1 71
+#define FL_SEPARATOR2 72
+#define FL_SEPARATOR 73
+#define FL_H_SEPARATOR 74
+// TP_INPUT
+
+#define GB_OPTIONS 70
+#define CB_ALIGN 71
+#define LB_ALIGN 72
+#define CB_EDITMODE 73
+#define CB_FORMAT 74
+#define CB_RFIND 75
+#define CB_EXPREF 76
+#define CB_MARKHDR 77
+#define CB_TEXTFMT 78
+#define CB_REPLWARN 79
+
+
+// TP_FORMULA
+#define FL_FORMULA_OPTIONS 80
+#define FT_FORMULA_SYNTAX 81
+#define LB_FORMULA_SYNTAX 82
+#define CB_ENGLISH_FUNC_NAME 83
+#define FL_FORMULA_SEPS 84
+#define FT_FORMULA_SEP_ARG 85
+#define ED_FORMULA_SEP_ARG 86
+#define FT_FORMULA_SEP_ARRAY_R 87
+#define ED_FORMULA_SEP_ARRAY_R 88
+#define FT_FORMULA_SEP_ARRAY_C 89
+#define ED_FORMULA_SEP_ARRAY_C 90
+#define BTN_FORMULA_SEP_RESET 91
+
+// TP_COMPATIBILITY
+#define FL_KEY_BINDINGS 1
+#define FT_KEY_BINDINGS 2
+#define LB_KEY_BINDINGS 3
diff --git a/sc/source/ui/inc/optload.hrc b/sc/source/ui/inc/optload.hrc
new file mode 100644
index 000000000000..e43e10284da7
--- /dev/null
+++ b/sc/source/ui/inc/optload.hrc
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc" // -> RID_SCPAGE_OPREDLINE
+
+#define GB_LINK 1
+#define RB_ALWAYS 2
+#define RB_REQUEST 3
+#define RB_NEVER 4
+#define CB_DOCONLY 5
+#define CB_MERGE_PARA_DIST 6
+#define GB_COMPAT 7
+#define CB_AUTO_UPDATE_FIELDS 8
+#define CB_AUTO_UPDATE_CHARTS 9
+#define FT_UPDATE_LINKS 10
+
+
diff --git a/sc/source/ui/inc/optload.hxx b/sc/source/ui/inc/optload.hxx
new file mode 100644
index 000000000000..1a0584eedf3f
--- /dev/null
+++ b/sc/source/ui/inc/optload.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _OPTLOAD_HXX
+#define _OPTLOAD_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+#include <vcl/group.hxx>
+#include <vcl/fixed.hxx>
+
+class ScDocument;
+
+class ScLoadOptPage : public SfxTabPage
+{
+private:
+ FixedText aLinkFT;
+ RadioButton aAlwaysRB;
+ RadioButton aRequestRB;
+ RadioButton aNeverRB;
+ CheckBox aDocOnlyCB;
+ GroupBox aLinkGB;
+ ScDocument *pDoc;
+
+ DECL_LINK( UpdateHdl, CheckBox* );
+
+public:
+ ScLoadOptPage( Window* pParent,
+ const SfxItemSet& rSet );
+ ~ScLoadOptPage();
+
+ static SfxTabPage* Create( Window* pParent,
+ const SfxItemSet& rAttrSet);
+
+ void SetDocument(ScDocument*);
+
+ virtual BOOL FillItemSet( SfxItemSet& rSet );
+ virtual void Reset( const SfxItemSet& rSet );
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/optsolver.hrc b/sc/source/ui/inc/optsolver.hrc
new file mode 100644
index 000000000000..88051bacdc64
--- /dev/null
+++ b/sc/source/ui/inc/optsolver.hrc
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+#define ED_OBJECTIVECELL 1
+#define ED_TARGET 2
+#define ED_VARIABLECELLS 3
+#define ED_LEFT1 4
+#define ED_LEFT2 5
+#define ED_LEFT3 6
+#define ED_LEFT4 7
+#define ED_RIGHT1 8
+#define ED_RIGHT2 9
+#define ED_RIGHT3 10
+#define ED_RIGHT4 11
+
+#define FT_OBJECTIVECELL 1
+#define FT_DIRECTION 2
+#define FT_VARIABLECELLS 3
+#define FT_CELLREF 4
+#define FT_OPERATOR 5
+#define FT_CONSTRAINT 6
+
+#define FT_PROGRESS 7
+#define FT_TIMELIMIT 8
+#define FT_NOSOLUTION 9
+#define FT_ERRORTEXT 10
+#define FT_SUCCESS 11
+#define FT_RESULT 12
+#define FT_QUESTION 13
+
+#define FL_CONDITIONS 1
+#define FL_BUTTONS 2
+
+#define IB_OBJECTIVECELL 1
+#define IB_TARGET 2
+#define IB_VARIABLECELLS 3
+#define IB_LEFT1 4
+#define IB_LEFT2 5
+#define IB_LEFT3 6
+#define IB_LEFT4 7
+#define IB_RIGHT1 8
+#define IB_RIGHT2 9
+#define IB_RIGHT3 10
+#define IB_RIGHT4 11
+#define IB_DELETE1 12
+#define IB_DELETE2 13
+#define IB_DELETE3 14
+#define IB_DELETE4 15
+
+#define LB_OP1 1
+#define LB_OP2 2
+#define LB_OP3 3
+#define LB_OP4 4
+
+#define RB_MAX 1
+#define RB_MIN 2
+#define RB_VALUE 3
+
+#define SB_SCROLL 1
+
+#define BTN_OPTIONS 1
+#define BTN_HELP 2
+#define BTN_CLOSE 3
+#define BTN_SOLVE 4
+#define BTN_OK 5
+#define BTN_CANCEL 6
+
+#define IMG_DEL_H 1
+
+#define STR_INVALIDINPUT 1
+#define STR_INVALIDCONDITION 2
+
diff --git a/sc/source/ui/inc/optsolver.hxx b/sc/source/ui/inc/optsolver.hxx
new file mode 100644
index 000000000000..d599b5a213b1
--- /dev/null
+++ b/sc/source/ui/inc/optsolver.hxx
@@ -0,0 +1,266 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_OPTSOLVER_HXX
+#define SC_OPTSOLVER_HXX
+
+#include "global.hxx"
+#include "address.hxx"
+#include "anyrefdg.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <vector>
+
+namespace com { namespace sun { namespace star {
+ namespace beans { struct PropertyValue; }
+} } }
+
+//============================================================================
+
+class ScCursorRefEdit : public formula::RefEdit
+{
+ Link maCursorUpLink;
+ Link maCursorDownLink;
+
+public:
+ ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId );
+ void SetCursorLinks( const Link& rUp, const Link& rDown );
+
+protected:
+ virtual void KeyInput( const KeyEvent& rKEvt );
+};
+
+
+/// The dialog's content for a row, not yet parsed
+struct ScOptConditionRow
+{
+ String aLeftStr;
+ USHORT nOperator;
+ String aRightStr;
+
+ ScOptConditionRow() : nOperator(0) {}
+ bool IsDefault() const { return aLeftStr.Len() == 0 && aRightStr.Len() == 0 && nOperator == 0; }
+};
+
+/// All settings from the dialog, saved with the DocShell for the next call
+class ScOptSolverSave
+{
+ String maObjective;
+ BOOL mbMax;
+ BOOL mbMin;
+ BOOL mbValue;
+ String maTarget;
+ String maVariable;
+ std::vector<ScOptConditionRow> maConditions;
+ String maEngine;
+ com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maProperties;
+
+public:
+ ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue,
+ const String& rTarget, const String& rVariable,
+ const std::vector<ScOptConditionRow>& rConditions,
+ const String& rEngine,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProperties );
+
+ const String& GetObjective() const { return maObjective; }
+ BOOL GetMax() const { return mbMax; }
+ BOOL GetMin() const { return mbMin; }
+ BOOL GetValue() const { return mbValue; }
+ const String& GetTarget() const { return maTarget; }
+ const String& GetVariable() const { return maVariable; }
+ const std::vector<ScOptConditionRow>& GetConditions() const { return maConditions; }
+ const String& GetEngine() const { return maEngine; }
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& GetProperties() const
+ { return maProperties; }
+};
+
+class ScOptSolverDlg : public ScAnyRefDlg
+{
+public:
+ ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocShell* pDocSh, ScAddress aCursorPos );
+ ~ScOptSolverDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+ virtual BOOL Close();
+
+private:
+ FixedText maFtObjectiveCell;
+ formula::RefEdit maEdObjectiveCell;
+ formula::RefButton maRBObjectiveCell;
+
+ FixedText maFtDirection;
+ RadioButton maRbMax;
+ RadioButton maRbMin;
+ RadioButton maRbValue;
+ formula::RefEdit maEdTargetValue;
+ formula::RefButton maRBTargetValue;
+
+ FixedText maFtVariableCells;
+ formula::RefEdit maEdVariableCells;
+ formula::RefButton maRBVariableCells;
+
+ FixedLine maFlConditions;
+
+ FixedText maFtCellRef; // labels are together with controls for the first row
+ ScCursorRefEdit maEdLeft1;
+ formula::RefButton maRBLeft1;
+ FixedText maFtOperator;
+ ListBox maLbOp1;
+ FixedText maFtConstraint;
+ ScCursorRefEdit maEdRight1;
+ formula::RefButton maRBRight1;
+ ImageButton maBtnDel1;
+
+ ScCursorRefEdit maEdLeft2;
+ formula::RefButton maRBLeft2;
+ ListBox maLbOp2;
+ ScCursorRefEdit maEdRight2;
+ formula::RefButton maRBRight2;
+ ImageButton maBtnDel2;
+
+ ScCursorRefEdit maEdLeft3;
+ formula::RefButton maRBLeft3;
+ ListBox maLbOp3;
+ ScCursorRefEdit maEdRight3;
+ formula::RefButton maRBRight3;
+ ImageButton maBtnDel3;
+
+ ScCursorRefEdit maEdLeft4;
+ formula::RefButton maRBLeft4;
+ ListBox maLbOp4;
+ ScCursorRefEdit maEdRight4;
+ formula::RefButton maRBRight4;
+ ImageButton maBtnDel4;
+
+ ScrollBar maScrollBar;
+
+ FixedLine maFlButtons;
+
+ PushButton maBtnOpt;
+ HelpButton maBtnHelp;
+ CancelButton maBtnCancel;
+ PushButton maBtnSolve;
+
+ String maInputError;
+ String maConditionError;
+
+ ScDocShell* mpDocShell;
+ ScDocument* mpDoc;
+ const SCTAB mnCurTab;
+ formula::RefEdit* mpEdActive;
+ bool mbDlgLostFocus;
+
+ static const sal_uInt16 EDIT_ROW_COUNT = 4;
+ ScCursorRefEdit* mpLeftEdit[EDIT_ROW_COUNT];
+ formula::RefButton* mpLeftButton[EDIT_ROW_COUNT];
+ ScCursorRefEdit* mpRightEdit[EDIT_ROW_COUNT];
+ formula::RefButton* mpRightButton[EDIT_ROW_COUNT];
+ ListBox* mpOperator[EDIT_ROW_COUNT];
+ ImageButton* mpDelButton[EDIT_ROW_COUNT];
+
+ std::vector<ScOptConditionRow> maConditions;
+ long nScrollPos;
+
+ com::sun::star::uno::Sequence<rtl::OUString> maImplNames;
+ com::sun::star::uno::Sequence<rtl::OUString> maDescriptions;
+ String maEngine;
+ com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maProperties;
+
+ void Init(const ScAddress& rCursorPos);
+ bool CallSolver();
+ void ReadConditions();
+ void ShowConditions();
+ void EnableButtons();
+ bool ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange );
+ bool FindTimeout( sal_Int32& rTimeout );
+ void ShowError( bool bCondition, formula::RefEdit* pFocus );
+
+ DECL_LINK( BtnHdl, PushButton* );
+ DECL_LINK( DelBtnHdl, PushButton* );
+ DECL_LINK( GetFocusHdl, Control* );
+ DECL_LINK( LoseFocusHdl, Control* );
+ DECL_LINK( ScrollHdl, ScrollBar* );
+ DECL_LINK( CursorUpHdl, ScCursorRefEdit* );
+ DECL_LINK( CursorDownHdl, ScCursorRefEdit* );
+ DECL_LINK( CondModifyHdl, Edit* );
+ DECL_LINK( TargetModifyHdl, Edit* );
+ DECL_LINK( SelectHdl, ListBox* );
+};
+
+
+class ScSolverProgressDialog : public ModelessDialog
+{
+ FixedText maFtProgress;
+ FixedText maFtTime;
+ FixedLine maFlButtons;
+ OKButton maBtnOk;
+
+public:
+ ScSolverProgressDialog( Window* pParent );
+ ~ScSolverProgressDialog();
+
+ void HideTimeLimit();
+ void SetTimeLimit( sal_Int32 nSeconds );
+};
+
+class ScSolverNoSolutionDialog : public ModalDialog
+{
+ FixedText maFtNoSolution;
+ FixedText maFtErrorText;
+ FixedLine maFlButtons;
+ OKButton maBtnOk;
+
+public:
+ ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText );
+ ~ScSolverNoSolutionDialog();
+};
+
+class ScSolverSuccessDialog : public ModalDialog
+{
+ FixedText maFtSuccess;
+ FixedText maFtResult;
+ FixedText maFtQuestion;
+ FixedLine maFlButtons;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+
+public:
+ ScSolverSuccessDialog( Window* pParent, const String& rSolution );
+ ~ScSolverSuccessDialog();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/output.hxx b/sc/source/ui/inc/output.hxx
new file mode 100644
index 000000000000..ab60aad6f94e
--- /dev/null
+++ b/sc/source/ui/inc/output.hxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_OUTPUT_HXX
+#define SC_OUTPUT_HXX
+
+#include "address.hxx"
+#include <tools/list.hxx>
+#include <tools/color.hxx>
+#include <tools/fract.hxx>
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+
+class Rectangle;
+class Font;
+class OutputDevice;
+class Window;
+class EditEngine;
+class ScDocument;
+class ScBaseCell;
+class ScPatternAttr;
+class SvxMarginItem;
+class SdrObject;
+class SdrOle2Obj;
+struct RowInfo;
+struct ScTableInfo;
+class ScTabViewShell;
+class ScPageBreakData;
+class FmFormView;
+
+// #i74769# SdrPaintWindow predefine
+class SdrPaintWindow;
+
+// ---------------------------------------------------------------------------
+
+#define SC_SCENARIO_HSPACE 60
+#define SC_SCENARIO_VSPACE 50
+
+// ---------------------------------------------------------------------------
+
+#define SC_OBJECTS_NONE 0
+#define SC_OBJECTS_DRAWING 1
+#define SC_OBJECTS_OLE 2
+#define SC_OBJECTS_CHARTS 4
+#define SC_OBJECTS_ALL ( SC_OBJECTS_DRAWING | SC_OBJECTS_OLE | SC_OBJECTS_CHARTS )
+
+enum ScOutputType { OUTTYPE_WINDOW, OUTTYPE_PRINTER };
+
+class ScOutputData
+{
+friend class ScDrawStringsVars;
+private:
+ struct OutputAreaParam
+ {
+ Rectangle maAlignRect;
+ Rectangle maClipRect;
+ long mnColWidth;
+ bool mbLeftClip;
+ bool mbRightClip;
+ };
+
+ OutputDevice* pDev; // Device
+ OutputDevice* pRefDevice; // printer if used for preview
+ OutputDevice* pFmtDevice; // reference for text formatting
+ ScTableInfo& mrTabInfo;
+ RowInfo* pRowInfo; // Info-Block
+ SCSIZE nArrCount; // belegte Zeilen im Info-Block
+ ScDocument* pDoc; // Dokument
+ SCTAB nTab; // Tabelle
+ long nScrX; // Ausgabe Startpos. (Pixel)
+ long nScrY;
+ long nScrW; // Ausgabe Groesse (Pixel)
+ long nScrH;
+ long nMirrorW; // Visible output width for mirroring (default: nScrW)
+ SCCOL nX1; // Start-/Endkoordinaten
+ SCROW nY1; // ( incl. versteckte )
+ SCCOL nX2;
+ SCROW nY2;
+ SCCOL nVisX1; // Start-/Endkoordinaten
+ SCROW nVisY1; // ( sichtbarer Bereich )
+ SCCOL nVisX2;
+ SCROW nVisY2;
+ ScOutputType eType; // Bildschirm/Drucker ...
+ double nPPTX; // Pixel per Twips
+ double nPPTY;
+// USHORT nZoom; // Zoom-Faktor (Prozent) - fuer GetFont
+ Fraction aZoomX;
+ Fraction aZoomY;
+
+ SdrObject* pEditObj; // beim Painten auslassen
+
+ ScTabViewShell* pViewShell; // zum Connecten von sichtbaren Plug-Ins
+
+ // #114135#
+ FmFormView* pDrawView; // SdrView to paint to
+
+ BOOL bEditMode; // InPlace editierte Zelle - nicht ausgeben
+ SCCOL nEditCol;
+ SCROW nEditRow;
+
+ BOOL bMetaFile; // Ausgabe auf Metafile (nicht in Pixeln!)
+ BOOL bSingleGrid; // beim Gitter bChanged auswerten
+
+ BOOL bPagebreakMode; // Seitenumbruch-Vorschau
+ BOOL bSolidBackground; // weiss statt transparent
+
+ BOOL bUseStyleColor;
+ BOOL bForceAutoColor;
+
+ BOOL bSyntaxMode; // Syntax-Highlighting
+ Color* pValueColor;
+ Color* pTextColor;
+ Color* pFormulaColor;
+
+ Color aGridColor;
+
+ BOOL bShowNullValues;
+ BOOL bShowFormulas;
+ BOOL bShowSpellErrors; // Spell-Errors in EditObjekten anzeigen
+ BOOL bMarkClipped;
+
+ BOOL bSnapPixel;
+
+ BOOL bAnyRotated; // intern
+ BOOL bAnyClipped; // intern
+ BOOL bTabProtected;
+ BYTE nTabTextDirection; // EEHorizontalTextDirection values
+ BOOL bLayoutRTL;
+
+ // #i74769# use SdrPaintWindow direct, remember it during BeginDrawLayers/EndDrawLayers
+ SdrPaintWindow* mpTargetPaintWindow;
+
+ // private methods
+
+ BOOL GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
+ SCCOL& rOverX, SCROW& rOverY, BOOL bVisRowChanged );
+ BOOL IsEmptyCellText( RowInfo* pThisRowInfo, SCCOL nX, SCROW nY );
+ void GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell*& rpCell );
+
+ BOOL IsAvailable( SCCOL nX, SCROW nY );
+
+ void GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY,
+ SCCOL nCellX, SCROW nCellY, long nNeeded,
+ const ScPatternAttr& rPattern,
+ USHORT nHorJustify, bool bCellIsValue,
+ bool bBreak, bool bOverwrite,
+ OutputAreaParam& rParam );
+
+ void ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect,
+ long nLeftM, long nTopM, long nRightM, long nBottomM,
+ BOOL bWidth, USHORT nOrient, long nAttrRotate, BOOL bPixelToLogic,
+ long& rEngineWidth, long& rEngineHeight, long& rNeededPixel,
+ bool& rLeftClip, bool& rRightClip );
+
+ void SetSyntaxColor( Font* pFont, ScBaseCell* pCell );
+ void SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell );
+
+ double GetStretch();
+
+ void DrawRotatedFrame( const Color* pForceColor ); // pixel
+
+public:
+ ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
+ ScTableInfo& rTabInfo, ScDocument* pNewDoc,
+ SCTAB nNewTab, long nNewScrX, long nNewScrY,
+ SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
+ double nPixelPerTwipsX, double nPixelPerTwipsY,
+ const Fraction* pZoomX = NULL,
+ const Fraction* pZoomY = NULL );
+
+ ~ScOutputData();
+
+ void SetContentDevice( OutputDevice* pContentDev );
+
+ void SetRefDevice( OutputDevice* pRDev ) { pRefDevice = pFmtDevice = pRDev; }
+ void SetFmtDevice( OutputDevice* pRDev ) { pFmtDevice = pRDev; }
+ void SetEditObject( SdrObject* pObj ) { pEditObj = pObj; }
+ void SetViewShell( ScTabViewShell* pSh ) { pViewShell = pSh; }
+
+ // #114135#
+ void SetDrawView( FmFormView* pNew ) { pDrawView = pNew; }
+
+ void SetSolidBackground( BOOL bSet ) { bSolidBackground = bSet; }
+ void SetUseStyleColor( BOOL bSet ) { bUseStyleColor = bSet; }
+
+ void SetEditCell( SCCOL nCol, SCROW nRow );
+ void SetSyntaxMode( BOOL bNewMode );
+ void SetMetaFileMode( BOOL bNewMode );
+ void SetSingleGrid( BOOL bNewMode );
+ void SetGridColor( const Color& rColor );
+ void SetMarkClipped( BOOL bSet );
+ void SetShowNullValues ( BOOL bSet = TRUE );
+ void SetShowFormulas ( BOOL bSet = TRUE );
+ void SetShowSpellErrors( BOOL bSet = TRUE );
+ void SetMirrorWidth( long nNew );
+ long GetScrW() const { return nScrW; }
+ long GetScrH() const { return nScrH; }
+
+ void SetSnapPixel( BOOL bSet = TRUE );
+
+ void DrawGrid( BOOL bGrid, BOOL bPage );
+ void DrawStrings( BOOL bPixelToLogic = FALSE );
+ void DrawDocumentBackground();
+ void DrawBackground();
+ void DrawShadow();
+ void DrawExtraShadow(BOOL bLeft, BOOL bTop, BOOL bRight, BOOL bBottom);
+ void DrawFrame();
+
+ // with logic MapMode set!
+ void DrawEdit(BOOL bPixelToLogic);
+
+ void FindRotated();
+ void DrawRotated(BOOL bPixelToLogic); // logisch
+
+ void DrawClear();
+
+ // #i72502# printer only command set
+ Point PrePrintDrawingLayer(long nLogStX, long nLogStY );
+ void PostPrintDrawingLayer(const Point& rMMOffset); // #i74768# need offset for FormLayer
+ void PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset);
+
+ // nur Bildschirm:
+ void DrawingSingle(const sal_uInt16 nLayer);
+ void DrawSelectiveObjects(const sal_uInt16 nLayer);
+
+ BOOL SetChangedClip(); // FALSE = nix
+ PolyPolygon GetChangedArea();
+
+ void FindChanged();
+ void SetPagebreakMode( ScPageBreakData* pPageData );
+#ifdef OLD_SELECTION_PAINT
+ void DrawMark( Window* pWin );
+#endif
+ void DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
+ SCCOL nRefEndX, SCROW nRefEndY,
+ const Color& rColor, BOOL bHandle );
+ void DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
+ SCCOL nRefEndX, SCROW nRefEndY,
+ const Color& rColor, USHORT nType );
+ void DrawChangeTrack();
+ void DrawClipMarks();
+
+ void DrawNoteMarks();
+ void AddPDFNotes();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/overlayobject.hxx b/sc/source/ui/inc/overlayobject.hxx
new file mode 100644
index 000000000000..175fcd16dafb
--- /dev/null
+++ b/sc/source/ui/inc/overlayobject.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: gridwin.hxx,v $
+ * $Revision: 1.30 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __SC_OVERLAYOBJECT_HXX__
+#define __SC_OVERLAYOBJECT_HXX__
+
+#include "svx/sdr/overlay/overlayobject.hxx"
+
+class OutputDevice;
+class Window;
+
+class ScOverlayDashedBorder : public ::sdr::overlay::OverlayObject
+{
+public:
+ ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor, Window* pWin);
+ virtual ~ScOverlayDashedBorder();
+
+ virtual void Trigger(sal_uInt32 nTime);
+
+ virtual void stripeDefinitionHasChanged();
+
+protected:
+ virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence();
+
+private:
+ ::basegfx::B2DRange maRange;
+ Window* mpParent;
+ bool mbToggle;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pagedata.hxx b/sc/source/ui/inc/pagedata.hxx
new file mode 100644
index 000000000000..674bb38bc581
--- /dev/null
+++ b/sc/source/ui/inc/pagedata.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PAGEDATA_HXX
+#define SC_PAGEDATA_HXX
+
+#include "global.hxx"
+#include "address.hxx"
+
+class ScDocShell;
+
+//============================================================================
+
+class ScPrintRangeData
+{
+private:
+ ScRange aPrintRange;
+ size_t nPagesX;
+ SCCOL* pPageEndX;
+ size_t nPagesY;
+ SCROW* pPageEndY;
+ long nFirstPage;
+ BOOL bTopDown;
+ BOOL bAutomatic;
+
+public:
+ ScPrintRangeData();
+ ~ScPrintRangeData();
+
+ void SetPrintRange( const ScRange& rNew ) { aPrintRange = rNew; }
+ const ScRange& GetPrintRange() const { return aPrintRange; }
+
+ void SetPagesX( size_t nCount, const SCCOL* pEnd );
+ void SetPagesY( size_t nCount, const SCROW* pEnd );
+
+ size_t GetPagesX() const { return nPagesX; }
+ const SCCOL* GetPageEndX() const { return pPageEndX; }
+ size_t GetPagesY() const { return nPagesY; }
+ const SCROW* GetPageEndY() const { return pPageEndY; }
+
+ void SetFirstPage( long nNew ) { nFirstPage = nNew; }
+ long GetFirstPage() const { return nFirstPage; }
+ void SetTopDown( BOOL bSet ) { bTopDown = bSet; }
+ BOOL IsTopDown() const { return bTopDown; }
+ void SetAutomatic( BOOL bSet ) { bAutomatic = bSet; }
+ BOOL IsAutomatic() const { return bAutomatic; }
+};
+
+class ScPageBreakData
+{
+private:
+ size_t nAlloc;
+ size_t nUsed;
+ ScPrintRangeData* pData; // Array
+
+public:
+ ScPageBreakData(size_t nMax);
+ ~ScPageBreakData();
+
+ size_t GetCount() const { return nUsed; }
+ ScPrintRangeData& GetData(size_t i);
+
+ BOOL IsEqual( const ScPageBreakData& rOther ) const;
+
+ void AddPages();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/parawin.hxx b/sc/source/ui/inc/parawin.hxx
new file mode 100644
index 000000000000..5272fb819c7f
--- /dev/null
+++ b/sc/source/ui/inc/parawin.hxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PARAWIN_HXX
+#define SC_PARAWIN_HXX
+
+#include "funcutl.hxx"
+#include "global.hxx" // ScAddress
+#include <svtools/stdctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/tabpage.hxx>
+
+#ifndef _SVSTDARR_STRINGS
+
+#define _SVSTDARR_STRINGS
+#include <svl/svstdarr.hxx>
+
+#endif
+#include <vcl/tabctrl.hxx>
+
+#include <vector>
+
+class ScFuncDesc;
+
+//============================================================================
+#define NOT_FOUND 0xffff
+//============================================================================
+
+class ScParaWin : public TabPage
+{
+private:
+
+ Link aScrollLink;
+ Link aFxLink;
+ Link aArgModifiedLink;
+
+ ::std::vector<USHORT> aVisibleArgMapping;
+ const ScFuncDesc* pFuncDesc;
+ ScAnyRefDlg* pMyParent;
+ USHORT nArgs; // unsuppressed arguments
+ Font aFntBold;
+ Font aFntLight;
+
+ FixedInfo aFtEditDesc;
+ FixedText aFtArgName;
+ FixedInfo aFtArgDesc;
+
+ ImageButton aBtnFx1;
+ FixedText aFtArg1;
+ ArgEdit aEdArg1;
+ formula::RefButton aRefBtn1;
+ ImageButton aBtnFx2;
+ FixedText aFtArg2;
+ ArgEdit aEdArg2;
+ formula::RefButton aRefBtn2;
+ ImageButton aBtnFx3;
+ FixedText aFtArg3;
+ ArgEdit aEdArg3;
+ formula::RefButton aRefBtn3;
+ ImageButton aBtnFx4;
+ FixedText aFtArg4;
+ ArgEdit aEdArg4;
+ formula::RefButton aRefBtn4;
+ ScrollBar aSlider;
+ BOOL bRefMode;
+
+ USHORT nEdFocus;
+ USHORT nActiveLine;
+
+ ArgInput aArgInput[4];
+ String aDefaultString;
+ SvStrings aParaArray;
+ DECL_LINK( ScrollHdl, ScrollBar* );
+ DECL_LINK( ModifyHdl, ArgInput* );
+ DECL_LINK( GetEdFocusHdl, ArgInput* );
+ DECL_LINK( GetFxFocusHdl, ArgInput* );
+ DECL_LINK( GetFxHdl, ArgInput* );
+
+protected:
+
+ virtual void SliderMoved();
+ virtual void ArgumentModified();
+ virtual void FxClick();
+
+ void InitArgInput( USHORT nPos, FixedText& rFtArg, ImageButton& rBtnFx,
+ ArgEdit& rEdArg, formula::RefButton& rRefBtn);
+
+ void DelParaArray();
+ void SetArgumentDesc(const String& aText);
+ void SetArgumentText(const String& aText);
+
+
+ void SetArgName (USHORT no,const String &aArg);
+ void SetArgNameFont (USHORT no,const Font&);
+ void SetArgVal (USHORT no,const String &aArg);
+
+ void HideParaLine(USHORT no);
+ void ShowParaLine(USHORT no);
+ void UpdateArgDesc( USHORT nArg );
+ void UpdateArgInput( USHORT nOffset, USHORT i );
+
+public:
+ ScParaWin(ScAnyRefDlg* pParent,Point aPos);
+ ~ScParaWin();
+
+ void SetFunctionDesc(const ScFuncDesc* pFDesc);
+ void SetArgumentOffset(USHORT nOffset);
+ void SetEditDesc(const String& aText);
+ void UpdateParas();
+ void ClearAll();
+
+ BOOL IsRefMode() {return bRefMode;}
+ void SetRefMode(BOOL bFlag) {bRefMode=bFlag;}
+
+ USHORT GetActiveLine();
+ void SetActiveLine(USHORT no);
+ formula::RefEdit* GetActiveEdit();
+ String GetActiveArgName();
+
+ String GetArgument(USHORT no);
+ void SetArgument(USHORT no, const String& aString);
+ void SetArgumentFonts(const Font&aBoldFont,const Font&aLightFont);
+
+ void SetEdFocus(USHORT nEditLine); //Sichtbare Editzeilen
+ USHORT GetSliderPos();
+ void SetSliderPos(USHORT nSliderPos);
+
+ void SetScrollHdl( const Link& rLink ) { aScrollLink = rLink; }
+ const Link& GetScrollHdl() const { return aScrollLink; }
+
+ void SetArgModifiedHdl( const Link& rLink ) { aArgModifiedLink = rLink; }
+ const Link& GetArgModifiedHdl() const { return aArgModifiedLink; }
+
+ void SetFxHdl( const Link& rLink ) { aFxLink = rLink; }
+ const Link& GetFxHdl() const { return aFxLink; }
+};
+
+
+
+
+
+#endif // SC_PARAWIN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pfiltdlg.hxx b/sc/source/ui/inc/pfiltdlg.hxx
new file mode 100644
index 000000000000..5baf841dae7e
--- /dev/null
+++ b/sc/source/ui/inc/pfiltdlg.hxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PFILTDLG_HXX
+#define SC_PFILTDLG_HXX
+
+#ifndef _SV_HXX
+#endif
+
+#include <vcl/morebtn.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include "address.hxx"
+#include "queryparam.hxx"
+
+//------------------------------------------------------------------
+
+class ScViewData;
+class ScDocument;
+class ScQueryItem;
+class TypedScStrCollection;
+
+//==================================================================
+
+class ScPivotFilterDlg : public ModalDialog
+{
+public:
+ ScPivotFilterDlg( Window* pParent,
+ const SfxItemSet& rArgSet, SCTAB nSourceTab );
+ ~ScPivotFilterDlg();
+
+ const ScQueryItem& GetOutputItem();
+
+private:
+ FixedLine aFlCriteria;
+ //----------------------------
+ ListBox aLbField1;
+ ListBox aLbCond1;
+ ComboBox aEdVal1;
+ //----------------------------
+ ListBox aLbConnect1;
+ ListBox aLbField2;
+ ListBox aLbCond2;
+ ComboBox aEdVal2;
+ //----------------------------
+ ListBox aLbConnect2;
+ ListBox aLbField3;
+ ListBox aLbCond3;
+ ComboBox aEdVal3;
+ //----------------------------
+ FixedText aFtConnect;
+ FixedText aFtField;
+ FixedText aFtCond;
+ FixedText aFtVal;
+
+ FixedLine aFlOptions;
+ CheckBox aBtnCase;
+ CheckBox aBtnRegExp;
+ CheckBox aBtnUnique;
+ FixedText aFtDbAreaLabel;
+ FixedInfo aFtDbArea;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ MoreButton aBtnMore;
+ const String aStrUndefined;
+ const String aStrNoName;
+ const String aStrNone;
+ const String aStrEmpty;
+ const String aStrNotEmpty;
+ const String aStrRow;
+ const String aStrColumn;
+
+ const USHORT nWhichQuery;
+ const ScQueryParam theQueryData;
+ ScQueryItem* pOutItem;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ SCTAB nSrcTab;
+
+ USHORT nFieldCount;
+ ComboBox* aValueEdArr[3];
+ ListBox* aFieldLbArr[3];
+ ListBox* aCondLbArr[3];
+
+ TypedScStrCollection* pEntryLists[MAXCOLCOUNT];
+
+#ifdef _PFILTDLG_CXX
+private:
+ void Init ( const SfxItemSet& rArgSet );
+ void FillFieldLists ();
+ void UpdateValueList ( USHORT nList );
+ void ClearValueList ( USHORT nList );
+ USHORT GetFieldSelPos ( SCCOL nField );
+
+ // Handler:
+ DECL_LINK( LbSelectHdl, ListBox* );
+ DECL_LINK( ValModifyHdl, ComboBox* );
+ DECL_LINK( CheckBoxHdl, CheckBox* );
+#endif
+};
+
+
+#endif // SC_PFILTDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
new file mode 100644
index 000000000000..d5694773c7ef
--- /dev/null
+++ b/sc/source/ui/inc/pfuncache.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PFUNCACHE_HXX
+#define SC_PFUNCACHE_HXX
+
+#include <vector>
+#include <tools/gen.hxx>
+#include "rangelst.hxx"
+#include "printopt.hxx"
+
+class ScDocShell;
+class ScMarkData;
+
+
+/** Possible types of selection for print functions */
+
+enum ScPrintSelectionMode
+{
+ SC_PRINTSEL_INVALID,
+ SC_PRINTSEL_DOCUMENT,
+ SC_PRINTSEL_CURSOR,
+ SC_PRINTSEL_RANGE,
+ SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
+};
+
+
+/** Stores the selection in the ScPrintFuncCache so it is only used
+ for the same selection again. */
+
+class ScPrintSelectionStatus
+{
+ ScPrintSelectionMode eMode;
+ ScRangeList aRanges;
+ ScPrintOptions aOptions;
+
+public:
+ ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID) {}
+ ~ScPrintSelectionStatus() {}
+
+ void SetMode(ScPrintSelectionMode eNew) { eMode = eNew; }
+ void SetRanges(const ScRangeList& rNew) { aRanges = rNew; }
+ void SetOptions(const ScPrintOptions& rNew) { aOptions = rNew; }
+
+ BOOL operator==(const ScPrintSelectionStatus& rOther) const
+ { return eMode == rOther.eMode && aRanges == rOther.aRanges && aOptions == rOther.aOptions; }
+
+ ScPrintSelectionMode GetMode() const { return eMode; }
+ const ScPrintOptions& GetOptions() const { return aOptions; }
+};
+
+
+/** The range that is printed on a page (excluding repeated columns/rows),
+ and its position on the page, used to find hyperlink targets. */
+
+struct ScPrintPageLocation
+{
+ long nPage;
+ ScRange aCellRange;
+ Rectangle aRectangle; // pixels
+
+ ScPrintPageLocation() :
+ nPage(-1) {} // default: invalid
+
+ ScPrintPageLocation( long nP, const ScRange& rRange, const Rectangle& rRect ) :
+ nPage(nP), aCellRange(rRange), aRectangle(rRect) {}
+};
+
+
+/** Stores the data for printing that is needed from several sheets,
+ so it doesn't have to be calculated for rendering each page. */
+
+class ScPrintFuncCache
+{
+ ScPrintSelectionStatus aSelection;
+ ScDocShell* pDocSh;
+ long nTotalPages;
+ long nPages[MAXTABCOUNT];
+ long nFirstAttr[MAXTABCOUNT];
+ std::vector<ScPrintPageLocation> aLocations;
+ bool bLocInitialized;
+
+public:
+ ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
+ const ScPrintSelectionStatus& rStatus );
+ ~ScPrintFuncCache();
+
+ BOOL IsSameSelection( const ScPrintSelectionStatus& rStatus ) const;
+
+ void InitLocations( const ScMarkData& rMark, OutputDevice* pDev );
+ bool FindLocation( const ScAddress& rCell, ScPrintPageLocation& rLocation ) const;
+
+ long GetPageCount() const { return nTotalPages; }
+ long GetFirstAttr( SCTAB nTab ) const { return nFirstAttr[nTab]; }
+ SCTAB GetTabForPage( long nPage ) const;
+ long GetTabStart( SCTAB nTab ) const;
+ long GetDisplayStart( SCTAB nTab ) const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pgbrksh.hxx b/sc/source/ui/inc/pgbrksh.hxx
new file mode 100644
index 000000000000..ca9bc3d67853
--- /dev/null
+++ b/sc/source/ui/inc/pgbrksh.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PGBRKSH_HXX
+#define SC_PGBRKSH_HXX
+
+#include <sfx2/module.hxx>
+#include <sfx2/shell.hxx>
+
+#include "shellids.hxx"
+
+class ScTabViewShell;
+
+class ScPageBreakShell : public SfxShell
+{
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_PAGEBREAK_SHELL)
+
+ ScPageBreakShell( ScTabViewShell* pView );
+ ~ScPageBreakShell();
+
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pivotsh.hxx b/sc/source/ui/inc/pivotsh.hxx
new file mode 100644
index 000000000000..d5a2d4ed8476
--- /dev/null
+++ b/sc/source/ui/inc/pivotsh.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PIVOTSH_HXX
+#define SC_PIVOTSH_HXX
+
+#include <sfx2/module.hxx>
+#include <sfx2/shell.hxx>
+
+#include "shellids.hxx"
+
+class ScTabViewShell;
+class ScDPObject;
+
+class ScPivotShell : public SfxShell
+{
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_PIVOT_SHELL)
+
+ ScPivotShell( ScTabViewShell* pView );
+ ~ScPivotShell();
+
+ void Execute ( SfxRequest& rReq );
+ void GetState( SfxItemSet& rSet );
+
+private:
+ ScTabViewShell* pViewShell;
+
+ ScDPObject* GetCurrDPObject();
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pntlock.hxx b/sc/source/ui/inc/pntlock.hxx
new file mode 100644
index 000000000000..18c090e8dde5
--- /dev/null
+++ b/sc/source/ui/inc/pntlock.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PNTLOCK_HXX
+#define SC_PNTLOCK_HXX
+
+#include "rangelst.hxx"
+
+class ScPaintLockData
+{
+private:
+ ScRangeListRef xRangeList;
+ USHORT nMode;
+ USHORT nLevel;
+ USHORT nDocLevel;
+ USHORT nParts;
+ BOOL bModified;
+
+public:
+ ScPaintLockData(USHORT nNewMode);
+ ~ScPaintLockData();
+
+ void AddRange( const ScRange& rRange, USHORT nP );
+
+ void SetModified() { bModified = TRUE; }
+ void IncLevel(sal_Bool bDoc)
+ { if (bDoc) ++nDocLevel; else ++nLevel; }
+ void DecLevel(sal_Bool bDoc)
+ { if (bDoc) --nDocLevel; else --nLevel; }
+
+ const ScRangeListRef& GetRangeList() const { return xRangeList; }
+ USHORT GetParts() const { return nParts; }
+ USHORT GetLevel(sal_Bool bDoc) const
+ { return bDoc ? nDocLevel : nLevel; }
+ BOOL GetModified() const { return bModified; }
+
+ // fuer Wiederherstellen nach Reset
+ void SetLevel(USHORT nNew, sal_Bool bDoc)
+ { if (bDoc) nDocLevel = nNew; else nLevel = nNew; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/popmenu.hxx b/sc/source/ui/inc/popmenu.hxx
new file mode 100644
index 000000000000..72db6f61f98a
--- /dev/null
+++ b/sc/source/ui/inc/popmenu.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_POPMENU_HXX
+#define SC_POPMENU_HXX
+
+#include <vcl/menu.hxx>
+#include "scdllapi.h"
+
+class SC_DLLPUBLIC ScPopupMenu : public PopupMenu
+{
+private:
+ USHORT nSel;
+ BOOL bHit;
+protected:
+ virtual void Select();
+public:
+ ScPopupMenu() : nSel(0),bHit(FALSE) {}
+ ScPopupMenu(const ResId& rRes) : PopupMenu(rRes),nSel(0),bHit(FALSE) {}
+ USHORT GetSelected() const { return nSel; }
+ BOOL WasHit() const { return bHit; }
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/preview.hxx b/sc/source/ui/inc/preview.hxx
new file mode 100644
index 000000000000..648fd47e10f3
--- /dev/null
+++ b/sc/source/ui/inc/preview.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_PREVIEW_HXX
+#define SC_PREVIEW_HXX
+
+
+#include <vcl/window.hxx>
+#include "printfun.hxx" // ScPrintState
+
+class ScDocShell;
+class ScPreviewShell;
+class FmFormView;
+
+class ScPreview : public Window
+{
+private:
+ // eingestellt:
+ long nPageNo; // Seite im Dokument
+ USHORT nZoom; // eingestellter Zoom
+ Point aOffset; // positiv
+
+ // berechnet:
+ BOOL bValid; // folgende Werte gueltig
+ SCTAB nTabCount;
+ SCTAB nTabsTested; // fuer wieviele Tabellen ist nPages gueltig?
+ long nPages[MAXTABCOUNT];
+ long nFirstAttr[MAXTABCOUNT];
+ SCTAB nTab; // Tabelle
+ long nTabPage; // Seite von Tabelle
+ long nTabStart; // erste Seite der Tabelle (wirklich)
+ long nDisplayStart; // dito, relativ zum Anfang der Zaehlung
+ Date aDate;
+ Time aTime;
+ long nTotalPages;
+ Size aPageSize; // fuer GetOptimalZoom
+ BOOL bStateValid;
+ BOOL bLocationValid;
+ ScPrintState aState;
+ ScPreviewLocationData* pLocationData; // stores table layout for accessibility API
+ FmFormView* pDrawView;
+
+ SCTAB nCurTab;
+
+ // intern:
+ BOOL bInPaint;
+ BOOL bInGetState;
+ ScDocShell* pDocShell;
+ ScPreviewShell* pViewShell;
+
+ BOOL bLeftRulerMove;
+ BOOL bRightRulerMove;
+ BOOL bTopRulerMove;
+ BOOL bBottomRulerMove;
+ BOOL bHeaderRulerMove;
+ BOOL bFooterRulerMove;
+
+ BOOL bLeftRulerChange;
+ BOOL bRightRulerChange;
+ BOOL bTopRulerChange;
+ BOOL bBottomRulerChange;
+ BOOL bHeaderRulerChange;
+ BOOL bFooterRulerChange;
+ BOOL bPageMargin;
+ BOOL bColRulerMove;
+ ScRange aPageArea;
+ long nRight[ MAXCOL+1 ];
+ long nLeftPosition;
+ long mnScale;
+ SCCOL nColNumberButttonDown;
+ Point aButtonDownChangePoint;
+ Point aButtonDownPt;
+ Point aButtonUpPt;
+ long nHeaderHeight;
+ long nFooterHeight;
+
+ void TestLastPage();
+ void CalcPages( SCTAB nToWhichTab );
+ void RecalcPages();
+ void UpdateDrawView();
+ void DoPrint( ScPreviewLocationData* pFillLocation );
+
+ void InvalidateLocationData( ULONG nId );
+
+ using Window::SetZoom;
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+public:
+ ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh );
+ ~ScPreview();
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ void DataChanged(BOOL bNewTime = FALSE); // statt Invalidate rufen
+ void DoInvalidate();
+
+ void SetXOffset( long nX );
+ void SetYOffset( long nY );
+ void SetZoom(USHORT nNewZoom);
+ void SetPageNo( long nPage );
+
+ BOOL GetPageMargins()const { return bPageMargin; }
+ void SetPageMargins( BOOL bVal ) { bPageMargin = bVal; }
+ void DrawInvert( long nDragPos, USHORT nFlags );
+ void DragMove( long nDragMovePos, USHORT nFlags );
+
+
+ const ScPreviewLocationData& GetLocationData();
+
+ String GetPosString();
+
+ long GetPageNo() const { return nPageNo; }
+ USHORT GetZoom() const { return nZoom; }
+ Point GetOffset() const { return aOffset; }
+
+ SCTAB GetTab() { if (!bValid) { CalcPages(0); RecalcPages(); } return nTab; }
+ long GetTotalPages() { if (!bValid) { CalcPages(0); RecalcPages(); } return nTotalPages; }
+
+ BOOL AllTested() const { return bValid && nTabsTested >= nTabCount; }
+
+ USHORT GetOptimalZoom(BOOL bWidthOnly);
+ long GetFirstPage(SCTAB nTab);
+
+ void CalcAll() { CalcPages(MAXTAB); }
+ void SetInGetState(BOOL bSet) { bInGetState = bSet; }
+
+ DECL_STATIC_LINK( ScPreview, InvalidateHdl, void* );
+ static void StaticInvalidate();
+
+ FmFormView* GetDrawView() { return pDrawView; }
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/prevloc.hxx b/sc/source/ui/inc/prevloc.hxx
new file mode 100644
index 000000000000..9dc2782de1da
--- /dev/null
+++ b/sc/source/ui/inc/prevloc.hxx
@@ -0,0 +1,159 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PREVLOC_HXX
+#define SC_PREVLOC_HXX
+
+#include "address.hxx"
+#include <tools/list.hxx>
+#include <vcl/mapmod.hxx>
+#include <sal/types.h>
+
+
+#define SC_PREVIEW_MAXRANGES 4
+#define SC_PREVIEW_RANGE_EDGE 0
+#define SC_PREVIEW_RANGE_REPCOL 1
+#define SC_PREVIEW_RANGE_REPROW 2
+#define SC_PREVIEW_RANGE_TAB 3
+
+class OutputDevice;
+class String;
+class Point;
+class Rectangle;
+class ScAddress;
+class ScRange;
+class ScDocument;
+
+struct ScPreviewColRowInfo
+{
+ BOOL bIsHeader;
+ SCCOLROW nDocIndex;
+ long nPixelStart;
+ long nPixelEnd;
+
+ void Set( BOOL bHeader, SCCOLROW nIndex, long nStart, long nEnd )
+ {
+ bIsHeader = bHeader;
+ nDocIndex = nIndex;
+ nPixelStart = nStart;
+ nPixelEnd = nEnd;
+ }
+};
+
+class ScPreviewTableInfo
+{
+ SCTAB nTab;
+ SCCOL nCols;
+ SCROW nRows;
+ ScPreviewColRowInfo* pColInfo;
+ ScPreviewColRowInfo* pRowInfo;
+
+public:
+ ScPreviewTableInfo();
+ ~ScPreviewTableInfo();
+
+ SCTAB GetTab() const { return nTab; }
+ SCCOL GetCols() const { return nCols; }
+ SCROW GetRows() const { return nRows; }
+ const ScPreviewColRowInfo* GetColInfo() const { return pColInfo; }
+ const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo; }
+
+ void SetTab( SCTAB nNewTab );
+ void SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
+ void SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
+ void LimitToArea( const Rectangle& rPixelArea );
+};
+
+
+class ScPreviewLocationData
+{
+ OutputDevice* pWindow;
+ ScDocument* pDoc;
+ MapMode aCellMapMode;
+ MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES];
+ Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES];
+ sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES];
+ USHORT nDrawRanges;
+ SCTAB nPrintTab;
+ List aEntries;
+
+ Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
+
+public:
+ ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
+ ~ScPreviewLocationData();
+
+ void SetCellMapMode( const MapMode& rMapMode );
+ void SetPrintTab( SCTAB nNew );
+ void Clear();
+ void AddCellRange( const Rectangle& rRect, const ScRange& rRange, BOOL bRepCol, BOOL bRepRow,
+ const MapMode& rDrawMap );
+ void AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, BOOL bRepCol );
+ void AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, BOOL bRepRow );
+ void AddHeaderFooter( const Rectangle& rRect, BOOL bHeader, BOOL bLeft );
+ void AddNoteMark( const Rectangle& rRect, const ScAddress& rPos );
+ void AddNoteText( const Rectangle& rRect, const ScAddress& rPos );
+
+ SCTAB GetPrintTab() const { return nPrintTab; }
+
+ // Get info on visible columns/rows in the visible area
+ void GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
+
+ USHORT GetDrawRanges() const { return nDrawRanges; }
+ void GetDrawRange( USHORT nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
+
+ BOOL GetHeaderPosition( Rectangle& rHeaderRect ) const;
+ BOOL GetFooterPosition( Rectangle& rFooterRect ) const;
+ BOOL IsHeaderLeft() const;
+ BOOL IsFooterLeft() const;
+
+ long GetNoteCountInRange( const Rectangle& rVisiblePixel, BOOL bNoteMarks ) const;
+ BOOL GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, BOOL bNoteMarks,
+ ScAddress& rCellPos, Rectangle& rNoteRect ) const;
+ Rectangle GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, BOOL bNoteMarks,
+ const ScAddress& aCellPos) const;
+
+ // Check if any cells (including column/row headers) are in the visible area
+ BOOL HasCellsInRange( const Rectangle& rVisiblePixel ) const;
+
+ BOOL GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
+
+ // returns the rectangle where the EditEngine draws the text of a Header Cell
+ // if bColHeader is true it returns the rectangle of the header of the column in rCellPos
+ // otherwise of the header of the row in rCellPos
+ Rectangle GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const;
+ Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
+
+ // Query the range and rectangle of the main (non-repeat) cell range.
+ // Returns FALSE if not contained.
+ BOOL GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/prevwsh.hxx b/sc/source/ui/inc/prevwsh.hxx
new file mode 100644
index 000000000000..944ada80a46c
--- /dev/null
+++ b/sc/source/ui/inc/prevwsh.hxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PREVWSH_HXX
+#define SC_PREVWSH_HXX
+
+class ScrollBar;
+
+#include "address.hxx"
+#include <sfx2/viewfac.hxx>
+#include <sfx2/viewsh.hxx>
+#include <svx/zoomitem.hxx>
+
+#include "shellids.hxx"
+
+class ScDocument;
+class ScDocShell;
+class ScPreview;
+struct ScHeaderFieldData;
+class ScPreviewLocationData;
+class CommandEvent;
+
+//==================================================================
+
+
+class ScPreviewShell: public SfxViewShell
+{
+ ScDocShell* pDocShell;
+
+ ScPreview* pPreview; // Ausgabe-Fenster
+ ScrollBar* pHorScroll;
+ ScrollBar* pVerScroll;
+ Window* pCorner;
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSourceData; // ViewData
+ BYTE nSourceDesignMode; // form design mode from TabView
+ SvxZoomType eZoom;
+ long nMaxVertPos;
+
+ SfxBroadcaster* pAccessibilityBroadcaster;
+
+private:
+ void Construct( Window* pParent );
+ DECL_LINK(ScrollHandler, ScrollBar* );
+ void DoScroll( USHORT nMode );
+
+protected:
+ virtual void Activate(BOOL bMDI);
+ virtual void Deactivate(BOOL bMDI);
+
+ virtual void AdjustPosSizePixel( const Point &rPos, const Size &rSize );
+
+ virtual void InnerResizePixel( const Point &rOfs, const Size &rSize );
+ virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
+
+ virtual Size GetOptimalSizePixel() const;
+
+ virtual String GetDescription() const;
+
+ virtual void WriteUserData(String &, BOOL bBrowse = FALSE);
+ virtual void ReadUserData(const String &, BOOL bBrowse = FALSE);
+
+ virtual void WriteUserDataSequence (::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
+ virtual void ReadUserDataSequence (const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
+
+public:
+ TYPEINFO();
+
+ SFX_DECL_INTERFACE(SCID_PREVIEW_SHELL)
+ SFX_DECL_VIEWFACTORY(ScPreviewShell);
+
+ ScPreviewShell( SfxViewFrame* pViewFrame,
+ SfxViewShell* pOldSh );
+
+ virtual ~ScPreviewShell();
+
+ void InitStartTable(SCTAB nTab);
+
+ void UpdateScrollBars();
+ BOOL ScrollCommand( const CommandEvent& rCEvt );
+
+ void Execute( SfxRequest& rReq );
+ void GetState( SfxItemSet& rSet );
+
+ void FillFieldData( ScHeaderFieldData& rData );
+
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >
+ GetSourceData() const { return aSourceData; }
+ BYTE GetSourceDesignMode() const { return nSourceDesignMode; }
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE );
+ virtual USHORT SetPrinter( SfxPrinter* pNewPrinter, USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsAPI=false );
+ virtual PrintDialog* CreatePrintDialog( Window* pParent );
+ virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions );
+ virtual void PreparePrint( PrintDialog* pPrintDialog = NULL );
+ virtual ErrCode DoPrint( SfxPrinter *pPrinter, PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI );
+ virtual USHORT Print( SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pPrintDialog = NULL );
+
+ void AddAccessibilityObject( SfxListener& rObject );
+ void RemoveAccessibilityObject( SfxListener& rObject );
+ void BroadcastAccessibility( const SfxHint &rHint );
+ BOOL HasAccessibilityObjects();
+
+ const ScPreviewLocationData& GetLocationData();
+ ScDocument* GetDocument();
+ ScPreview* GetPreview() { return pPreview; }
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
new file mode 100644
index 000000000000..31c467e8ac02
--- /dev/null
+++ b/sc/source/ui/inc/printfun.hxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PRINTFUN_HXX
+#define SC_PRINTFUN_HXX
+
+
+#include "pagepar.hxx"
+#include "editutil.hxx"
+
+#include <vcl/print.hxx>
+
+class SfxPrinter;
+class SfxProgress;
+class ScDocShell;
+class ScDocument;
+class ScViewData;
+class SfxItemSet;
+class ScPageHFItem;
+class EditTextObject;
+class MultiSelection;
+class ScHeaderEditEngine;
+class ScPageBreakData;
+class ScPreviewLocationData;
+class ScPrintOptions;
+class SvxBoxItem;
+class SvxBrushItem;
+class SvxShadowItem;
+class FmFormView;
+
+#define RANGENO_NORANGE USHRT_MAX
+
+#define PRINT_HEADER_WIDTH (1.0 * TWIPS_PER_CM)
+#define PRINT_HEADER_HEIGHT (12.8 * TWIPS_PER_POINT)
+#define PRINT_HEADER_FONTHEIGHT 200
+
+
+ // Einstellungen fuer Kopf-/Fusszeilen
+struct ScPrintHFParam
+{
+ BOOL bEnable;
+ BOOL bDynamic;
+ BOOL bShared;
+ long nHeight; // insgesamt (Hoehe+Abstand+Rahmen)
+ long nManHeight; // eingestellte Groesse (Min. bei dynamisch)
+ USHORT nDistance;
+ USHORT nLeft; // Raender
+ USHORT nRight;
+ const ScPageHFItem* pLeft;
+ const ScPageHFItem* pRight;
+ const SvxBoxItem* pBorder;
+ const SvxBrushItem* pBack;
+ const SvxShadowItem* pShadow;
+};
+
+
+// "Ersatz" fuer SV-JobSetup:
+
+class ScJobSetup
+{
+public:
+ ScJobSetup( SfxPrinter* pPrinter );
+
+ Size aUserSize;
+ MapMode aUserMapMode;
+ Paper ePaper;
+ Orientation eOrientation;
+ USHORT nPaperBin;
+};
+
+struct ScPrintState // Variablen aus ScPrintFunc retten
+{
+ SCTAB nPrintTab;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ USHORT nZoom;
+ size_t nPagesX;
+ size_t nPagesY;
+ long nTabPages;
+ long nTotalPages;
+ long nPageStart;
+ long nDocPages;
+};
+
+class ScPageRowEntry
+{
+private:
+ SCROW nStartRow;
+ SCROW nEndRow;
+ size_t nPagesX;
+ BOOL* pHidden;
+ //! Anzahl wirklich sichtbarer cachen???
+
+public:
+ ScPageRowEntry() { nStartRow = nEndRow = 0; nPagesX = 0; pHidden = NULL; }
+ ~ScPageRowEntry() { delete[] pHidden; }
+
+ ScPageRowEntry(const ScPageRowEntry& r);
+ const ScPageRowEntry& operator=(const ScPageRowEntry& r);
+
+ SCROW GetStartRow() const { return nStartRow; }
+ SCROW GetEndRow() const { return nEndRow; }
+ size_t GetPagesX() const { return nPagesX; }
+ void SetStartRow(SCROW n) { nStartRow = n; }
+ void SetEndRow(SCROW n) { nEndRow = n; }
+
+ void SetPagesX(size_t nNew);
+ void SetHidden(size_t nX);
+ BOOL IsHidden(size_t nX) const;
+
+ size_t CountVisible() const;
+};
+
+class ScPrintFunc
+{
+private:
+ ScDocShell* pDocShell;
+ ScDocument* pDoc;
+ SfxPrinter* pPrinter;
+ OutputDevice* pDev;
+ FmFormView* pDrawView;
+
+ MapMode aOldPrinterMode; // MapMode vor dem Aufruf
+
+ Point aSrcOffset; // Papier-1/100 mm
+ Point aOffset; // mit Faktor aus Seitenformat skaliert
+ USHORT nManualZoom; // Zoom in Preview (Prozent)
+ BOOL bClearWin; // Ausgabe vorher loeschen
+ BOOL bUseStyleColor;
+ BOOL bIsRender;
+
+ SCTAB nPrintTab;
+ long nPageStart; // Offset fuer erste Seite
+ long nDocPages; // Seiten im Dokument
+
+ const ScRange* pUserArea; // Selektion, wenn im Dialog eingestellt
+
+ const SfxItemSet* pParamSet; // eingestellte Vorlage
+ BOOL bState; // aus State-struct erzeugt
+
+ // Parameter aus Vorlage:
+ USHORT nLeftMargin;
+ USHORT nTopMargin;
+ USHORT nRightMargin;
+ USHORT nBottomMargin;
+ BOOL bCenterHor;
+ BOOL bCenterVer;
+ BOOL bLandscape;
+ BOOL bSourceRangeValid;
+
+ USHORT nPageUsage;
+ Size aPageSize; // Drucker-Twips
+ const SvxBoxItem* pBorderItem;
+ const SvxBrushItem* pBackgroundItem;
+ const SvxShadowItem* pShadowItem;
+
+ ScRange aLastSourceRange;
+ ScPrintHFParam aHdr;
+ ScPrintHFParam aFtr;
+ ScPageTableParam aTableParam;
+ ScPageAreaParam aAreaParam;
+
+ // berechnete Werte:
+ USHORT nZoom;
+ BOOL bPrintCurrentTable;
+ BOOL bMultiArea;
+ long nTabPages;
+ long nTotalPages;
+
+ Rectangle aPageRect; // Dokument-Twips
+
+ MapMode aLogicMode; // in DoPrint gesetzt
+ MapMode aOffsetMode;
+ MapMode aTwipMode;
+ double nScaleX;
+ double nScaleY;
+
+ SCCOL nRepeatStartCol;
+ SCCOL nRepeatEndCol;
+ SCROW nRepeatStartRow;
+ SCROW nRepeatEndRow;
+
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+
+ SCCOL* pPageEndX; // Seitenaufteilung
+ SCROW* pPageEndY;
+ ScPageRowEntry* pPageRows;
+ size_t nPagesX;
+ size_t nPagesY;
+ size_t nTotalY;
+
+ ScHeaderEditEngine* pEditEngine;
+ SfxItemSet* pEditDefaults;
+
+ ScHeaderFieldData aFieldData;
+
+ List aNotePosList; // Reihenfolge der Notizen
+
+ ScPageBreakData* pPageData; // zum Eintragen der Umbrueche etc.
+
+public:
+ ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
+ long nPage = 0, long nDocP = 0,
+ const ScRange* pArea = NULL,
+ const ScPrintOptions* pOptions = NULL,
+ ScPageBreakData* pData = NULL );
+
+ // ctors for device other than printer - for preview and pdf:
+
+ ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
+ long nPage = 0, long nDocP = 0,
+ const ScRange* pArea = NULL,
+ const ScPrintOptions* pOptions = NULL );
+
+ ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
+ const ScPrintState& rState,
+ const ScPrintOptions* pOptions );
+
+ ScPrintFunc( ScDocShell* pShell, Window* pWindow, SCTAB nTab,
+ long nPage = 0, long nDocP = 0,
+ const ScRange* pArea = NULL,
+ const ScPrintOptions* pOptions = NULL );
+
+ ScPrintFunc( ScDocShell* pShell, Window* pWindow,
+ const ScPrintState& rState,
+ const ScPrintOptions* pOptions );
+ ~ScPrintFunc();
+
+ static void DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double nPrintFactor,
+ const Rectangle& rBound, ScViewData* pViewData, BOOL bMetaFile );
+
+ void SetDrawView( FmFormView* pNew );
+
+ void SetOffset( const Point& rOfs );
+ void SetManualZoom( USHORT nNewZoom );
+ void SetDateTime( const Date& rDate, const Time& rTime );
+
+ void SetClearFlag( BOOL bFlag );
+ void SetUseStyleColor( BOOL bFlag );
+ void SetRenderFlag( BOOL bFlag );
+
+ void SetExclusivelyDrawOleAndDrawObjects();//for printing selected objects without surrounding cell contents
+
+ BOOL UpdatePages();
+
+ void ApplyPrintSettings(); // aus DoPrint() schon gerufen
+ long DoPrint( const MultiSelection& rPageRanges,
+ /*long nStartPage, long nDisplayStart, BOOL bDoPrint,
+ SfxProgress* pProgress, ScPreviewLocationData* pLocationData );*/
+ long nStartPage, long nDisplayStart, BOOL bDoPrint = TRUE,
+ SfxProgress* pProgress = NULL, ScPreviewLocationData* pLocationData = NULL);
+
+ // Werte abfragen - sofort
+
+ Size GetPageSize() const { return aPageSize; }
+ Size GetDataSize() const;
+ void GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr );
+ long GetFirstPageNo() const { return aTableParam.nFirstPageNo; }
+
+ // letzte Werte abfragen - nach DoPrint !!!
+
+ double GetScaleX() const { return nScaleX; }
+ double GetScaleY() const { return nScaleY; }
+ long GetTotalPages() const { return nTotalPages; }
+ USHORT GetZoom() const { return nZoom; }
+
+ void ResetBreaks( SCTAB nTab );
+
+ void GetPrintState( ScPrintState& rState );
+ BOOL GetLastSourceRange( ScRange& rRange ) const;
+ USHORT GetLeftMargin() const{return nLeftMargin;}
+ USHORT GetRightMargin() const{return nRightMargin;}
+ USHORT GetTopMargin() const{return nTopMargin;}
+ USHORT GetBottomMargin() const{return nBottomMargin;}
+ void SetLeftMargin(USHORT nRulerLeftDistance){ nLeftMargin = nRulerLeftDistance; }
+ void SetRightMargin(USHORT nRulerRightDistance){ nRightMargin = nRulerRightDistance; }
+ void SetTopMargin(USHORT nRulerTopDistance){ nTopMargin = nRulerTopDistance; }
+ void SetBottomMargin(USHORT nRulerBottomDistance){ nBottomMargin = nRulerBottomDistance; }
+ ScPrintHFParam GetHeader(){return aHdr;}
+ ScPrintHFParam GetFooter(){return aFtr;}
+
+private:
+ void Construct( const ScPrintOptions* pOptions );
+ void InitParam( const ScPrintOptions* pOptions );
+ void CalcZoom( USHORT nRangeNo );
+ void CalcPages();
+ long CountPages();
+ long CountNotePages();
+
+ BOOL AdjustPrintArea( BOOL bNew );
+
+ Size GetDocPageSize();
+
+ long TextHeight( const EditTextObject* pObject );
+ void MakeEditEngine();
+ void UpdateHFHeight( ScPrintHFParam& rParam );
+
+ void InitModes();
+
+ BOOL IsLeft( long nPageNo );
+ BOOL IsMirror( long nPageNo );
+ void ReplaceFields( long nPageNo ); // aendert Text in pEditEngine
+ void MakeTableString(); // setzt aTableStr
+
+ void PrintPage( long nPageNo,
+ SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ BOOL bDoPrint, ScPreviewLocationData* pLocationData );
+ void PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ long nScrX, long nScrY,
+ BOOL bShLeft, BOOL bShTop, BOOL bShRight, BOOL bShBottom );
+ void LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ long nScrX, long nScrY, BOOL bRepCol, BOOL bRepRow,
+ ScPreviewLocationData& rLocationData );
+ void PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY );
+ void PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY );
+ void LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
+ BOOL bRepCol, ScPreviewLocationData& rLocationData );
+ void LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
+ BOOL bRepRow, ScPreviewLocationData& rLocationData );
+ void PrintHF( long nPageNo, BOOL bHeader, long nStartY,
+ BOOL bDoPrint, ScPreviewLocationData* pLocationData );
+
+ long PrintNotes( long nPageNo, long nNoteStart, BOOL bDoPrint, ScPreviewLocationData* pLocationData );
+ long DoNotes( long nNoteStart, BOOL bDoPrint, ScPreviewLocationData* pLocationData );
+
+ void DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
+ const SvxBoxItem* pBorderData,
+ const SvxBrushItem* pBackground,
+ const SvxShadowItem* pShadow );
+
+ void FillPageData();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/privsplt.hxx b/sc/source/ui/inc/privsplt.hxx
new file mode 100644
index 000000000000..282b02beb139
--- /dev/null
+++ b/sc/source/ui/inc/privsplt.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PRIVSPLT_HXX
+#define SC_PRIVSPLT_HXX
+
+#include <vcl/ctrl.hxx>
+
+enum SC_SPLIT_DIRECTION {SC_SPLIT_HORZ,SC_SPLIT_VERT };
+
+class ScPrivatSplit : public Control
+{
+ private:
+
+ Link aCtrModifiedLink;
+ BOOL aMovingFlag;
+ Pointer aWinPointer;
+ SC_SPLIT_DIRECTION eScSplit;
+ short nOldX;
+ short nOldY;
+ short nNewX;
+ short nNewY;
+ short nMinPos;
+ short nMaxPos;
+ Range aXMovingRange;
+ Range aYMovingRange;
+ short nDeltaX;
+ short nDeltaY;
+
+ using Control::ImplInitSettings;
+ void ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground );
+
+
+
+ protected:
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt);
+
+ public:
+
+ ScPrivatSplit( Window* pWindow, const ResId& rResId,
+ SC_SPLIT_DIRECTION eScSplit);
+
+ virtual short GetDeltaX();
+ virtual short GetDeltaY();
+
+ virtual void CtrModified();
+
+ void SetYRange(Range cRgeY);
+
+ void MoveSplitTo(Point aPos);
+
+ virtual void StateChanged( StateChangedType nType );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+
+ void SetCtrModifiedHdl( const Link& rLink ) { aCtrModifiedLink = rLink; }
+ const Link& GetCtrModifiedHdl() const { return aCtrModifiedLink; }
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/protectiondlg.hrc b/sc/source/ui/inc/protectiondlg.hrc
new file mode 100644
index 000000000000..7bee7725a617
--- /dev/null
+++ b/sc/source/ui/inc/protectiondlg.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc>
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define BTN_PROTECT 4
+#define FT_PASSWORD1 5
+#define ED_PASSWORD1 6
+#define FT_PASSWORD2 7
+#define ED_PASSWORD2 8
+#define FL_OPTIONS 9
+#define FT_OPTIONS 10
+#define CLB_OPTIONS 11
+
+#define ST_SELECT_LOCKED_CELLS 50
+#define ST_SELECT_UNLOCKED_CELLS 51
diff --git a/sc/source/ui/inc/protectiondlg.hxx b/sc/source/ui/inc/protectiondlg.hxx
new file mode 100644
index 000000000000..44419bc4bf9b
--- /dev/null
+++ b/sc/source/ui/inc/protectiondlg.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UI_PROTECTION_DLG_HXX
+#define SC_UI_PROTECTION_DLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <svx/checklbx.hxx>
+
+class Window;
+class ScTableProtection;
+
+class ScTableProtectionDlg : public ModalDialog
+{
+public:
+ explicit ScTableProtectionDlg(Window* pParent);
+ virtual ~ScTableProtectionDlg();
+
+ virtual short Execute();
+
+ void SetDialogData(const ScTableProtection& rData);
+
+ void WriteData(ScTableProtection& rData) const;
+
+private:
+ ScTableProtectionDlg(); // disabled
+
+ void Init();
+
+ void EnableOptionalWidgets(bool bEnable = true);
+
+ CheckBox maBtnProtect;
+
+ FixedText maPassword1Text;
+ Edit maPassword1Edit;
+ FixedText maPassword2Text;
+ Edit maPassword2Edit;
+
+ FixedLine maOptionsLine;
+ FixedText maOptionsText;
+ SvxCheckListBox maOptionsListBox;
+
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ String maSelectLockedCells;
+ String maSelectUnlockedCells;
+
+ DECL_LINK( OKHdl, OKButton* );
+ DECL_LINK( CheckBoxHdl, CheckBox* );
+ DECL_LINK( PasswordModifyHdl, Edit* );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pvfundlg.hxx b/sc/source/ui/inc/pvfundlg.hxx
new file mode 100644
index 000000000000..c85eb1b6829c
--- /dev/null
+++ b/sc/source/ui/inc/pvfundlg.hxx
@@ -0,0 +1,254 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PVFUNDLG_HXX
+#define SC_PVFUNDLG_HXX
+
+#include <com/sun/star/sheet/DataPilotFieldReference.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortInfo.hpp>
+
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/morebtn.hxx>
+#include <vcl/field.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svx/checklbx.hxx>
+#include <sfx2/itemconnect.hxx>
+#include "pivot.hxx"
+
+#include <hash_map>
+
+// ============================================================================
+
+typedef sfx::ListBoxWrapper< sal_Int32 > ScDPListBoxWrapper;
+
+class ScDPObject;
+
+// ============================================================================
+
+class ScDPFunctionListBox : public MultiListBox
+{
+public:
+ explicit ScDPFunctionListBox( Window* pParent, const ResId& rResId );
+
+ void SetSelection( USHORT nFuncMask );
+ USHORT GetSelection() const;
+
+private:
+ void FillFunctionNames();
+};
+
+// ============================================================================
+
+class ScDPFunctionDlg : public ModalDialog
+{
+ typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > NameMapType;
+public:
+ explicit ScDPFunctionDlg( Window* pParent, const ScDPLabelDataVec& rLabelVec,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData );
+
+ USHORT GetFuncMask() const;
+ ::com::sun::star::sheet::DataPilotFieldReference GetFieldRef() const;
+
+private:
+ void Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData );
+
+ const ::rtl::OUString& GetBaseFieldName(const ::rtl::OUString& rLayoutName) const;
+ const ::rtl::OUString& GetBaseItemName(const ::rtl::OUString& rLayoutName) const;
+
+ /** Searches for a listbox entry, starts search at specified position. */
+ sal_uInt16 FindBaseItemPos( const String& rEntry, USHORT nStartPos ) const;
+
+ DECL_LINK( SelectHdl, ListBox* );
+ DECL_LINK( DblClickHdl, MultiListBox* );
+
+private:
+ FixedLine maFlFunc;
+ ScDPFunctionListBox maLbFunc;
+ FixedText maFtNameLabel;
+ FixedInfo maFtName;
+ FixedLine maFlDisplay;
+ FixedText maFtType;
+ ListBox maLbType;
+ FixedText maFtBaseField;
+ ListBox maLbBaseField;
+ FixedText maFtBaseItem;
+ ListBox maLbBaseItem;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+ MoreButton maBtnMore;
+
+ NameMapType maBaseFieldNameMap; // cache for base field display -> original name.
+ NameMapType maBaseItemNameMap; // cache for base item display -> original name.
+
+ ScDPListBoxWrapper maLbTypeWrp; /// Wrapper for direct usage of API constants.
+
+ const ScDPLabelDataVec& mrLabelVec; /// Data of all labels.
+ bool mbEmptyItem; /// true = Empty base item in listbox.
+};
+
+// ============================================================================
+
+class ScDPSubtotalDlg : public ModalDialog
+{
+public:
+ explicit ScDPSubtotalDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData,
+ const ScDPNameVec& rDataFields, bool bEnableLayout );
+
+ USHORT GetFuncMask() const;
+
+ void FillLabelData( ScDPLabelData& rLabelData ) const;
+
+private:
+ void Init( const ScDPLabelData& rLabelData, const ScDPFuncData& rFuncData );
+
+ DECL_LINK( DblClickHdl, MultiListBox* );
+ DECL_LINK( RadioClickHdl, RadioButton* );
+ DECL_LINK( ClickHdl, PushButton* );
+
+private:
+ FixedLine maFlSubt;
+ RadioButton maRbNone;
+ RadioButton maRbAuto;
+ RadioButton maRbUser;
+ ScDPFunctionListBox maLbFunc;
+ FixedText maFtNameLabel;
+ FixedInfo maFtName;
+ CheckBox maCbShowAll;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+ PushButton maBtnOptions;
+
+ ScDPObject& mrDPObj; /// The DataPilot object (for member names).
+ const ScDPNameVec& mrDataFields; /// The list of all data field names.
+
+ ScDPLabelData maLabelData; /// Cache for sub dialog.
+ bool mbEnableLayout; /// true = Enable Layout mode controls.
+};
+
+// ============================================================================
+
+class ScDPSubtotalOptDlg : public ModalDialog
+{
+public:
+ explicit ScDPSubtotalOptDlg( Window* pParent, ScDPObject& rDPObj,
+ const ScDPLabelData& rLabelData, const ScDPNameVec& rDataFields,
+ bool bEnableLayout );
+
+ void FillLabelData( ScDPLabelData& rLabelData ) const;
+
+private:
+ void Init( const ScDPNameVec& rDataFields, bool bEnableLayout );
+ void InitHideListBox();
+
+ const ::rtl::OUString& GetFieldName(const ::rtl::OUString& rLayoutName) const;
+
+ /** Searches for a listbox entry, starts search at specified position. */
+ sal_uInt16 FindListBoxEntry( const ListBox& rLBox, const String& rEntry, USHORT nStartPos ) const;
+
+ DECL_LINK( RadioClickHdl, RadioButton* );
+ DECL_LINK( CheckHdl, CheckBox* );
+ DECL_LINK( SelectHdl, ListBox* );
+
+private:
+ FixedLine maFlSortBy;
+ ListBox maLbSortBy;
+ RadioButton maRbSortAsc;
+ RadioButton maRbSortDesc;
+ RadioButton maRbSortMan;
+ FixedLine maFlLayout;
+ FixedText maFtLayout;
+ ListBox maLbLayout;
+ CheckBox maCbLayoutEmpty;
+ FixedLine maFlAutoShow;
+ CheckBox maCbShow;
+ NumericField maNfShow;
+ FixedText maFtShow;
+ FixedText maFtShowFrom;
+ ListBox maLbShowFrom;
+ FixedText maFtShowUsing;
+ ListBox maLbShowUsing;
+ FixedLine maFlHide;
+ SvxCheckListBox maLbHide;
+ FixedText maFtHierarchy;
+ ListBox maLbHierarchy;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ ScDPListBoxWrapper maLbLayoutWrp; /// Wrapper for direct usage of API constants.
+ ScDPListBoxWrapper maLbShowFromWrp; /// Wrapper for direct usage of API constants.
+
+ ScDPObject& mrDPObj; /// The DataPilot object (for member names).
+ ScDPLabelData maLabelData; /// Cache for members data.
+
+ typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > NameMapType;
+ NameMapType maDataFieldNameMap; /// Cache for displayed name to field name mapping.
+};
+
+// ============================================================================
+
+class ScDPShowDetailDlg : public ModalDialog
+{
+public:
+ explicit ScDPShowDetailDlg( Window* pParent, ScDPObject& rDPObj, USHORT nOrient );
+
+ virtual short Execute();
+
+ /**
+ * @return String internal name of the selected field. Note that this may
+ * be different from the name displayed in the dialog if the field
+ * has a layout name.
+ */
+ String GetDimensionName() const;
+
+private:
+ DECL_LINK( DblClickHdl, ListBox* );
+
+private:
+ FixedText maFtDims;
+ ListBox maLbDims;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ typedef ::std::hash_map<String, long, ScStringHashCode> DimNameIndexMap;
+ DimNameIndexMap maNameIndexMap;
+ ScDPObject& mrDPObj;
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/pvlaydlg.hxx b/sc/source/ui/inc/pvlaydlg.hxx
new file mode 100644
index 000000000000..56516139aa2a
--- /dev/null
+++ b/sc/source/ui/inc/pvlaydlg.hxx
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_PVLAYDLG_HXX
+#define SC_PVLAYDLG_HXX
+
+#include <vector>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+#include <vcl/lstbox.hxx>
+#include <vcl/scrbar.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/morebtn.hxx>
+#include "pivot.hxx"
+#include "anyrefdg.hxx"
+#include "fieldwnd.hxx"
+#include "formula/funcutl.hxx"
+
+/*==========================================================================*\
+
+ Eine Instanz der Klasse ScPivotLayoutDlg ist ein (semi-)modaler
+ Dialog, in dem mit der Maus Felder mit Spaltenueberschriften den
+ drei Pivot-Kategorien "Spalte", "Zeile" und "Daten" zugeordnet
+ werden koennen.
+
+ Der Dialog erhaelt in der Struktur LabelData Informationen ueber
+ diese Ueberschriften (Name, Art (Zahl/String) und Funktionsmaske).
+ Weiterhin werden drei PivotFeld-Arrays uebergeben, mit denen die
+ drei Kategorie-Fenster initialisiert werden. Ein Kategorie-Fenster
+ wird durch eine Instanz der Klasse FieldWindow dargestellt. Ein
+ solches Fenster ist fuer die Darstellung der Datenstrukturen am
+ Schirm zustaendig. Es meldet Mausaktionen an den Dialog weiter und
+ bietet entsprechende Methoden zur Veraenderung der Darstellung.
+ Der Dialog sorgt fuer den Abgleich der interenen Datenstrukturen mit
+ der Bildschirmdarstellung. Ein weiteres FieldWindow (Select) bietet
+ alle Tabellenueberschriften zur Auswahl an, ist also "read-only".
+
+\*==========================================================================*/
+
+//============================================================================
+
+class ScViewData;
+class ScDocument;
+class ScRangeData;
+struct ScDPFuncData;
+class ScDPObject;
+
+//============================================================================
+
+#define FUNC_COUNT 11
+
+class ScDPLayoutDlg : public ScAnyRefDlg
+{
+public:
+ ScDPLayoutDlg(
+ SfxBindings* pB,
+ SfxChildWindow* pCW,
+ Window* pParent,
+ const ScDPObject& rDPObject,
+ bool bNewOutput );
+ virtual ~ScDPLayoutDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual BOOL IsRefInputMode() const { return bRefInputMode; }
+ virtual void SetActive();
+ virtual BOOL Close();
+ virtual void StateChanged( StateChangedType nStateChange );
+
+ void NotifyDoubleClick ( ScDPFieldType eType, size_t nFieldIndex );
+ PointerStyle NotifyMouseButtonDown( ScDPFieldType eType, size_t nFieldIndex );
+ void NotifyMouseButtonUp ( const Point& rAt );
+ PointerStyle NotifyMouseMove ( const Point& rAt );
+ void NotifyFieldFocus ( ScDPFieldType eType, BOOL bGotFocus );
+ void NotifyMoveField ( ScDPFieldType eToType );
+ void NotifyRemoveField ( ScDPFieldType eType, size_t nFieldIndex );
+ BOOL NotifyMoveSlider ( USHORT nKeyCode ); // return TRUE, if position changed
+
+protected:
+ virtual void Deactivate();
+
+private:
+ typedef boost::shared_ptr< ScDPFuncData > ScDPFuncDataRef;
+ typedef std::vector< ScDPFuncDataRef > ScDPFuncDataVec;
+ typedef std::auto_ptr< ScDPObject > ScDPObjectPtr;
+
+ FixedLine aFlLayout;
+ FixedText aFtPage;
+ ScDPFieldWindow aWndPage;
+ FixedText aFtCol;
+ ScDPFieldWindow aWndCol;
+ FixedText aFtRow;
+ ScDPFieldWindow aWndRow;
+ FixedText aFtData;
+ ScDPFieldWindow aWndData;
+ ScDPFieldWindow aWndSelect;
+ ScrollBar aSlider;
+ FixedInfo aFtInfo;
+
+ FixedLine aFlAreas;
+
+ // DP source selection
+ FixedText aFtInArea;
+ ::formula::RefEdit aEdInPos;
+ ::formula::RefButton aRbInPos;
+
+ // DP output location
+ ListBox aLbOutPos;
+ FixedText aFtOutArea;
+ formula::RefEdit aEdOutPos;
+ formula::RefButton aRbOutPos;
+
+ CheckBox aBtnIgnEmptyRows;
+ CheckBox aBtnDetectCat;
+ CheckBox aBtnTotalCol;
+ CheckBox aBtnTotalRow;
+ CheckBox aBtnFilter;
+ CheckBox aBtnDrillDown;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ PushButton aBtnRemove;
+ PushButton aBtnOptions;
+ MoreButton aBtnMore;
+
+ const String aStrUndefined;
+ const String aStrNewTable;
+ std::vector< String > aFuncNameArr;
+
+ ScDPFieldType eDnDFromType;
+ size_t nDnDFromIndex;
+ BOOL bIsDrag;
+
+ ::formula::RefEdit* pEditActive;
+
+ Rectangle aRectPage;
+ Rectangle aRectRow;
+ Rectangle aRectCol;
+ Rectangle aRectData;
+ Rectangle aRectSelect;
+
+ ScDPLabelDataVec aLabelDataArr; // (nCol, Feldname, Zahl/Text)
+
+ ScDPFieldType eLastActiveType; /// Type of last active area.
+ size_t nOffset; /// Offset of first field in TYPE_SELECT area.
+
+ ScDPFuncDataVec aSelectArr;
+ ScDPFuncDataVec aPageArr;
+ ScDPFuncDataVec aColArr;
+ ScDPFuncDataVec aRowArr;
+ ScDPFuncDataVec aDataArr;
+
+ ScDPObjectPtr xDlgDPObject;
+ ScRange aOldRange;
+ ScPivotParam thePivotData;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ BOOL bRefInputMode;
+
+private:
+ ScDPFieldWindow& GetFieldWindow ( ScDPFieldType eType );
+ void Init (bool bNewOutput);
+ void InitWndSelect ( const ::std::vector<ScDPLabelDataRef>& rLabels );
+ void InitWnd ( PivotField* pArr, long nCount, ScDPFieldType eType );
+ void InitFocus ();
+ void InitFields ();
+ void CalcWndSizes ();
+ Point DlgPos2WndPos ( const Point& rPt, Window& rWnd );
+ ScDPLabelData* GetLabelData ( SCsCOL nCol, size_t* pPos = NULL );
+ String GetLabelString ( SCsCOL nCol );
+ bool IsOrientationAllowed( SCsCOL nCol, ScDPFieldType eType );
+ String GetFuncString ( USHORT& rFuncMask, BOOL bIsValue = TRUE );
+ BOOL Contains ( ScDPFuncDataVec* pArr, SCsCOL nCol, size_t& nAt );
+ void Remove ( ScDPFuncDataVec* pArr, size_t nAt );
+ void Insert ( ScDPFuncDataVec* pArr, const ScDPFuncData& rFData, size_t nAt );
+
+ void AddField ( size_t nFromIndex,
+ ScDPFieldType eToType, const Point& rAtPos );
+ void MoveField ( ScDPFieldType eFromType, size_t nFromIndex,
+ ScDPFieldType eToType, const Point& rAtPos );
+ void RemoveField ( ScDPFieldType eRemType, size_t nRemIndex );
+
+ BOOL GetPivotArrays ( PivotField* pPageArr,
+ PivotField* pColArr,
+ PivotField* pRowArr,
+ PivotField* pDataArr,
+ USHORT& rPageCount,
+ USHORT& rColCount,
+ USHORT& rRowCount,
+ USHORT& rDataCount );
+
+ void UpdateSrcRange();
+
+ // Handler
+ DECL_LINK( ClickHdl, PushButton * );
+ DECL_LINK( ScrollHdl, ScrollBar * );
+ DECL_LINK( SelAreaHdl, ListBox * );
+ DECL_LINK( MoreClickHdl, MoreButton * );
+ DECL_LINK( EdModifyHdl, Edit * );
+ DECL_LINK( EdInModifyHdl, Edit * );
+ DECL_LINK( OkHdl, OKButton * );
+ DECL_LINK( CancelHdl, CancelButton * );
+ DECL_LINK( GetFocusHdl, Control* );
+};
+
+
+
+#endif // SC_PVLAYDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/redcom.hxx b/sc/source/ui/inc/redcom.hxx
new file mode 100644
index 000000000000..5cc3e8400092
--- /dev/null
+++ b/sc/source/ui/inc/redcom.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_REDCOM_HXX
+#define SC_REDCOM_HXX
+
+#include "chgtrack.hxx"
+
+class ScDocShell;
+class AbstractSvxPostItDialog;
+
+class ScRedComDialog
+{
+private:
+
+ ScChangeAction *pChangeAction;
+ ScDocShell *pDocShell;
+ String aComment;
+ AbstractSvxPostItDialog* pDlg;
+
+ DECL_LINK( PrevHdl, AbstractSvxPostItDialog* );
+ DECL_LINK( NextHdl, AbstractSvxPostItDialog* );
+
+protected:
+
+ void ReInit(ScChangeAction *);
+ void SelectCell();
+
+ ScChangeAction *FindPrev(ScChangeAction *pAction);
+ ScChangeAction *FindNext(ScChangeAction *pAction);
+
+public:
+
+ ScRedComDialog( Window* pParent, const SfxItemSet& rCoreSet,
+ ScDocShell *,ScChangeAction *,BOOL bPrevNext = FALSE);
+ ~ScRedComDialog();
+
+ short Execute();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/reffact.hxx b/sc/source/ui/inc/reffact.hxx
new file mode 100644
index 000000000000..cc0960306482
--- /dev/null
+++ b/sc/source/ui/inc/reffact.hxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_REFFACT_HXX
+#define SC_REFFACT_HXX
+
+#include <sfx2/childwin.hxx>
+
+#include "dbfunc.hxx"
+
+#define DECL_WRAPPER(Class) \
+ class Class : public SfxChildWindow \
+ { \
+ public: \
+ Class( Window*, USHORT, SfxBindings*, SfxChildWinInfo* ); \
+ SFX_DECL_CHILDWINDOW(Class); \
+ };
+
+
+//==================================================================
+
+DECL_WRAPPER(ScNameDlgWrapper)
+DECL_WRAPPER(ScSolverDlgWrapper)
+DECL_WRAPPER(ScOptSolverDlgWrapper)
+DECL_WRAPPER(ScPivotLayoutWrapper)
+DECL_WRAPPER(ScTabOpDlgWrapper)
+DECL_WRAPPER(ScFilterDlgWrapper)
+DECL_WRAPPER(ScSpecialFilterDlgWrapper)
+DECL_WRAPPER(ScDbNameDlgWrapper)
+DECL_WRAPPER(ScConsolidateDlgWrapper)
+DECL_WRAPPER(ScPrintAreasDlgWrapper)
+DECL_WRAPPER(ScCondFormatDlgWrapper)
+DECL_WRAPPER(ScColRowNameRangesDlgWrapper)
+DECL_WRAPPER(ScFormulaDlgWrapper)
+DECL_WRAPPER(ScHighlightChgDlgWrapper)
+
+/*!!! dafuer muss der Funktionsautopilot noch umgebaut werden
+DECL_WRAPPER(ScFunctionDlgWrapper)
+DECL_WRAPPER(ScEditFunctionDlgWrapper)
+DECL_WRAPPER(ScArgumentDlgWrapper)
+*/
+
+class ScAcceptChgDlgWrapper: public SfxChildWindow
+{
+ public:
+ ScAcceptChgDlgWrapper( Window*,
+ USHORT,
+ SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW(Class);
+
+ virtual void ReInitDlg();
+};
+
+class ScSimpleRefDlgWrapper: public SfxChildWindow
+{
+ public:
+ ScSimpleRefDlgWrapper( Window*,
+ USHORT,
+ SfxBindings*,
+ SfxChildWinInfo* );
+
+ SFX_DECL_CHILDWINDOW(Class);
+
+ static void SetDefaultPosSize(Point aPos, Size aSize, BOOL bSet=TRUE);
+ virtual String GetRefString();
+ virtual void SetRefString(const String& rStr);
+ void SetCloseHdl( const Link& rLink );
+ void SetUnoLinks( const Link& rDone, const Link& rAbort,
+ const Link& rChange );
+ void SetFlags( BOOL bCloseOnButtonUp, BOOL bSingleCell, BOOL bMultiSelection );
+ static void SetAutoReOpen(BOOL bFlag);
+
+ void StartRefInput();
+};
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+class SC_DLLPUBLIC ScValidityRefChildWin : public SfxChildWindow
+{
+ bool m_bVisibleLock:1;
+ bool m_bFreeWindowLock:1;
+ Window * m_pSavedWndParent;
+public:
+ ScValidityRefChildWin( Window*, USHORT, SfxBindings*, SfxChildWinInfo* );
+ SFX_DECL_CHILDWINDOW(ScValidityRefChildWin);
+ ~ScValidityRefChildWin();
+ bool LockVisible( bool bLock ){ bool bVis = m_bVisibleLock; m_bVisibleLock = bLock; return bVis; }
+ bool LockFreeWindow( bool bLock ){ bool bFreeWindow = m_bFreeWindowLock; m_bFreeWindowLock = bLock; return bFreeWindow; }
+ void Hide(){ if( !m_bVisibleLock) SfxChildWindow::Hide(); }
+ void Show( USHORT nFlags ){ if( !m_bVisibleLock ) SfxChildWindow::Show( nFlags ); }
+};
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+//==================================================================
+
+
+#endif // SC_REFFACT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/refundo.hxx b/sc/source/ui/inc/refundo.hxx
new file mode 100644
index 000000000000..7603e7d9e8b4
--- /dev/null
+++ b/sc/source/ui/inc/refundo.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_REFUNDO_HXX
+#define SC_REFUNDO_HXX
+
+#include <tools/solar.h>
+
+class ScDocument;
+class ScDBCollection;
+class ScRangeName;
+class ScPrintRangeSaver;
+class ScDPCollection;
+class ScChartCollection;
+class ScConditionalFormatList;
+class ScDetOpList;
+class ScChartListenerCollection;
+class ScAreaLinkSaveCollection;
+class ScUnoRefList;
+
+class ScRefUndoData
+{
+private:
+ ScDBCollection* pDBCollection;
+ ScRangeName* pRangeName;
+ ScPrintRangeSaver* pPrintRanges;
+ ScDPCollection* pDPCollection;
+ ScConditionalFormatList* pCondFormList;
+ ScDetOpList* pDetOpList;
+ ScChartListenerCollection* pChartListenerCollection;
+ ScAreaLinkSaveCollection* pAreaLinks;
+ ScUnoRefList* pUnoRefs;
+
+public:
+ ScRefUndoData( const ScDocument* pDoc );
+ ~ScRefUndoData();
+
+ void DeleteUnchanged( const ScDocument* pDoc );
+ void DoUndo( ScDocument* pDoc, BOOL bUndoRefFirst );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/retypepassdlg.hrc b/sc/source/ui/inc/retypepassdlg.hrc
new file mode 100644
index 000000000000..76f7a1231613
--- /dev/null
+++ b/sc/source/ui/inc/retypepassdlg.hrc
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc>
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FT_DESC 10
+#define FL_DOCUMENT 11
+#define FT_DOCSTATUS 12
+#define BTN_RETYPE_DOC 13
+
+#define FL_SHEET 112
+
+#define FT_SHEETNAME1 113
+#define FT_SHEETSTATUS1 114
+#define BTN_RETYPE_SHEET1 115
+
+#define FT_SHEETNAME2 116
+#define FT_SHEETSTATUS2 117
+#define BTN_RETYPE_SHEET2 118
+
+#define FT_SHEETNAME3 119
+#define FT_SHEETSTATUS3 120
+#define BTN_RETYPE_SHEET3 121
+
+#define FT_SHEETNAME4 122
+#define FT_SHEETSTATUS4 123
+#define BTN_RETYPE_SHEET4 124
+
+#define SB_SCROLL 190
+
+#define STR_NOT_PROTECTED 200
+#define STR_NOT_PASS_PROTECTED 201
+#define STR_HASH_BAD 202
+#define STR_HASH_GOOD 203
+#define STR_HASH_REGENERATED 204
+
+#define FT_PASSWORD1 301
+#define ED_PASSWORD1 302
+#define FT_PASSWORD2 303
+#define ED_PASSWORD2 304
+#define BTN_MATCH_OLD_PASSWORD 305
+#define BTN_RETYPE_PASSWORD 306
+#define BTN_REMOVE_PASSWORD 307
diff --git a/sc/source/ui/inc/retypepassdlg.hxx b/sc/source/ui/inc/retypepassdlg.hxx
new file mode 100644
index 000000000000..11e7b81ca10c
--- /dev/null
+++ b/sc/source/ui/inc/retypepassdlg.hxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UI_RETYPEPASS_DLG_HXX
+#define SC_UI_RETYPEPASS_DLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/scrbar.hxx>
+#include <svx/checklbx.hxx>
+#include <svtools/stdctrl.hxx>
+
+#include "tabprotection.hxx"
+
+#include <boost/shared_ptr.hpp>
+
+class Window;
+class ScDocProtection;
+class ScTableProtection;
+class ScDocument;
+
+class ScRetypePassDlg : public ModalDialog
+{
+public:
+ typedef ::boost::shared_ptr<ScDocProtection> DocProtectionPtr;
+ typedef ::boost::shared_ptr<ScTableProtection> TabProtectionPtr;
+
+ explicit ScRetypePassDlg(Window* pParent);
+ virtual ~ScRetypePassDlg();
+
+ virtual short Execute();
+
+ void SetDataFromDocument(const ScDocument& rDoc);
+ void SetDesiredHash(ScPasswordHash eHash);
+
+ /** Write the new set of password data to the document instance to
+ overwrite the current ones. */
+ void WriteNewDataToDocument(ScDocument& rDoc) const;
+
+private:
+ ScRetypePassDlg(); // disabled
+
+ void Init();
+ void PopulateDialog();
+ void SetDocData();
+ void SetTableData(size_t nRowPos, SCTAB nTab);
+ void ResetTableRows();
+
+ /** Check the status of all hash values to see if it's okay to enable
+ the OK button. */
+ void CheckHashStatus();
+
+private:
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ FixedInfo maTextDescription;
+
+ FixedLine maLineDocument;
+ FixedText maTextDocStatus;
+ PushButton maBtnRetypeDoc;
+
+ FixedLine maLineSheet;
+ FixedText maTextSheetName1;
+ FixedText maTextSheetStatus1;
+ PushButton maBtnRetypeSheet1;
+
+ FixedText maTextSheetName2;
+ FixedText maTextSheetStatus2;
+ PushButton maBtnRetypeSheet2;
+
+ FixedText maTextSheetName3;
+ FixedText maTextSheetStatus3;
+ PushButton maBtnRetypeSheet3;
+
+ FixedText maTextSheetName4;
+ FixedText maTextSheetStatus4;
+ PushButton maBtnRetypeSheet4;
+
+ ScrollBar maScrollBar;
+
+ String maTextNotProtected;
+ String maTextNotPassProtected;
+ String maTextHashBad;
+ String maTextHashGood;
+ String maTextHashRegen;
+
+ DECL_LINK( OKHdl, OKButton* );
+ DECL_LINK( RetypeBtnHdl, PushButton* );
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+ struct TableItem
+ {
+ String maName;
+ TabProtectionPtr mpProtect;
+ };
+ ::std::vector<TableItem> maTableItems;
+
+ DocProtectionPtr mpDocItem;
+ size_t mnCurScrollPos;
+ ScPasswordHash meDesiredHash;
+};
+
+// ============================================================================
+
+class ScRetypePassInputDlg : public ModalDialog
+{
+public:
+ explicit ScRetypePassInputDlg(Window* pParent, ScPassHashProtectable* pProtected);
+ virtual ~ScRetypePassInputDlg();
+
+ virtual short Execute();
+
+ bool IsRemovePassword() const;
+ String GetNewPassword() const;
+
+private:
+ ScRetypePassInputDlg(); // disabled
+
+ void Init();
+ void CheckPasswordInput();
+
+private:
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ RadioButton maBtnRetypePassword;
+
+ FixedText maPassword1Text;
+ Edit maPassword1Edit;
+ FixedText maPassword2Text;
+ Edit maPassword2Edit;
+
+ CheckBox maBtnMatchOldPass;
+
+ RadioButton maBtnRemovePassword;
+
+ DECL_LINK( OKHdl, OKButton* );
+ DECL_LINK( RadioBtnHdl, RadioButton* );
+ DECL_LINK( CheckBoxHdl, CheckBox* );
+ DECL_LINK( PasswordModifyHdl, Edit* );
+
+ ScPassHashProtectable* mpProtected;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/rfindlst.hxx b/sc/source/ui/inc/rfindlst.hxx
new file mode 100644
index 000000000000..1175d931861e
--- /dev/null
+++ b/sc/source/ui/inc/rfindlst.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_RFINDLST_HXX
+#define SC_RFINDLST_HXX
+
+#include <tools/color.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+//==================================================================
+
+struct ScRangeFindData
+{
+ ScRange aRef;
+ USHORT nFlags;
+ xub_StrLen nSelStart;
+ xub_StrLen nSelEnd;
+
+ ScRangeFindData( const ScRange& rR, USHORT nF, xub_StrLen nS, xub_StrLen nE ) :
+ aRef(rR), nFlags(nF), nSelStart(nS), nSelEnd(nE) {}
+};
+
+class ScRangeFindList
+{
+ List aEntries;
+ String aDocName;
+ BOOL bHidden;
+
+public:
+ ScRangeFindList(const String& rName);
+ ~ScRangeFindList();
+
+ ULONG Count() const { return aEntries.Count(); }
+ void Insert( ScRangeFindData* pNew ) { aEntries.Insert(pNew, LIST_APPEND); }
+ ScRangeFindData* GetObject( ULONG nIndex ) const
+ { return (ScRangeFindData*)aEntries.GetObject(nIndex); }
+
+ void SetHidden( BOOL bSet ) { bHidden = bSet; }
+
+ const String& GetDocName() const { return aDocName; }
+ BOOL IsHidden() const { return bHidden; }
+
+ static ColorData GetColorName( USHORT nIndex );
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scendlg.hxx b/sc/source/ui/inc/scendlg.hxx
new file mode 100644
index 000000000000..031ab3470f64
--- /dev/null
+++ b/sc/source/ui/inc/scendlg.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SCENDLG_HXX
+#define SC_SCENDLG_HXX
+
+
+#include <vcl/dialog.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/imagebtn.hxx>
+#include <svtools/svmedit.hxx>
+#include <svtools/ctrlbox.hxx>
+
+//===================================================================
+
+class ScNewScenarioDlg : public ModalDialog
+{
+public:
+ ScNewScenarioDlg( Window* pParent, const String& rName, BOOL bEdit = FALSE, BOOL bSheetProtected = FALSE );
+ ~ScNewScenarioDlg();
+
+ void SetScenarioData( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags );
+
+ void GetScenarioData( String& rName, String& rComment,
+ Color& rColor, USHORT& rFlags ) const;
+
+private:
+ FixedLine aFlName;
+ Edit aEdName;
+ FixedLine aFlComment;
+ MultiLineEdit aEdComment;
+ FixedLine aFlOptions;
+ CheckBox aCbShowFrame;
+ ColorListBox aLbColor;
+ //CheckBox aCbPrintFrame;
+ CheckBox aCbTwoWay;
+ //CheckBox aCbAttrib;
+ //CheckBox aCbValue;
+ CheckBox aCbCopyAll;
+ CheckBox aCbProtect;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ const String aDefScenarioName;
+ BOOL bIsEdit;
+
+ DECL_LINK( OkHdl, OKButton * );
+ DECL_LINK( EnableHdl, CheckBox * );
+};
+
+
+#endif // SC_SCENDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scui_def.hxx b/sc/source/ui/inc/scui_def.hxx
new file mode 100644
index 000000000000..8fe583383ea3
--- /dev/null
+++ b/sc/source/ui/inc/scui_def.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SCUI_DEF_HXX
+#define SCUI_DEF_HXX
+
+#define SCRET_COLS 0x42
+#define SCRET_ROWS 0x43
+
+#define FDS_OPT_NONE 0 // from filldlg.hxx
+#define FDS_OPT_HORZ 1 // from filldlg.hxx
+#define FDS_OPT_VERT 2 // from filldlg.hxx
+
+#define INS_CONT_NOEMPTY 0x0100 //from inscodlg.hxx
+#define INS_CONT_TRANS 0x0200 //from inscodlg.hxx
+#define INS_CONT_LINK 0x0400 //from inscodlg.hxx
+
+#define SC_CELL_SHIFT_DISABLE_DOWN 0x01 //from inscodlg.hxx
+#define SC_CELL_SHIFT_DISABLE_RIGHT 0x02 //from inscodlg.hxx
+
+#define NAME_TOP 1 //from namecrea.hxx
+#define NAME_LEFT 2 //from namecrea.hxx
+#define NAME_BOTTOM 4 //from namecrea.hxx
+#define NAME_RIGHT 8 //from namecrea.hxx
+
+#define BTN_PASTE_NAME 100 // from namepast.hxx
+#define BTN_PASTE_LIST 101 // from namepast.hxx
+
+#define BTN_EXTEND_RANGE 150
+#define BTN_CURRENT_SELECTION 151
+#define SCRET_REMOVE 0x42 //from subtdlg.hxx
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scuiasciiopt.hxx b/sc/source/ui/inc/scuiasciiopt.hxx
new file mode 100644
index 000000000000..9b113ddd5968
--- /dev/null
+++ b/sc/source/ui/inc/scuiasciiopt.hxx
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ============================================================================
+
+#ifndef SCUI_ASCIIOPT_HXX
+#define SCUI_ASCIIOPT_HXX
+
+
+#include "asciiopt.hxx"
+#include "svx/langbox.hxx"
+
+// ============================================================================
+
+class ScImportAsciiDlg : public ModalDialog
+{
+ SvStream* mpDatStream;
+ ULONG mnStreamPos;
+ ULONG* mpRowPosArray;
+ ULONG mnRowPosCount;
+
+ String maPreviewLine[ CSV_PREVIEW_LINES ];
+
+ FixedLine aFlFieldOpt;
+ FixedText aFtCharSet;
+ SvxTextEncodingBox aLbCharSet;
+ FixedText aFtCustomLang;
+ SvxLanguageBox aLbCustomLang;
+
+ FixedText aFtRow;
+ NumericField aNfRow;
+
+ FixedLine aFlSepOpt;
+ RadioButton aRbFixed;
+ RadioButton aRbSeparated;
+
+ CheckBox aCkbTab;
+ CheckBox aCkbSemicolon;
+ CheckBox aCkbComma;
+ CheckBox aCkbSpace;
+ CheckBox aCkbOther;
+ Edit aEdOther;
+ CheckBox aCkbAsOnce;
+
+ FixedLine aFlOtherOpt;
+
+ FixedText aFtTextSep;
+ ComboBox aCbTextSep;
+
+ CheckBox aCkbQuotedAsText;
+ CheckBox aCkbDetectNumber;
+
+ FixedLine aFlWidth;
+ FixedText aFtType;
+ ListBox aLbType;
+
+ ScCsvTableBox maTableBox;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ String aCharSetUser;
+ String aColumnUser;
+ String aFldSepList;
+ String aTextSepList;
+ String maFieldSeparators; // selected field separators
+ sal_Unicode mcTextSep;
+ String maStrTextToColumns;
+
+ CharSet meCharSet; /// Selected char set.
+ bool mbCharSetSystem; /// Is System char set selected?
+ bool mbFileImport; /// Is this dialog involked for csv file import ?
+
+public:
+ ScImportAsciiDlg(
+ Window* pParent, String aDatName,
+ SvStream* pInStream, sal_Unicode cSep = '\t' );
+ ~ScImportAsciiDlg();
+
+ void GetOptions( ScAsciiOptions& rOpt );
+ void SetTextToColumnsMode();
+ void SaveParameters();
+
+private:
+ /** Sets the selected char set data to meCharSet and mbCharSetSystem. */
+ void SetSelectedCharSet();
+ /** Returns all separator characters in a string. */
+ String GetSeparators() const;
+
+ /** Enables or disables all separator checkboxes and edit fields. */
+ void SetupSeparatorCtrls();
+
+
+ bool GetLine( ULONG nLine, String &rText );
+ void UpdateVertical();
+ inline bool Seek( ULONG nPos ); // synced to and from mnStreamPos
+
+ DECL_LINK( CharSetHdl, SvxTextEncodingBox* );
+ DECL_LINK( FirstRowHdl, NumericField* );
+ DECL_LINK( RbSepFixHdl, RadioButton* );
+ DECL_LINK( SeparatorHdl, Control* );
+ DECL_LINK( LbColTypeHdl, ListBox* );
+ DECL_LINK( UpdateTextHdl, ScCsvTableBox* );
+ DECL_LINK( ColTypeHdl, ScCsvTableBox* );
+};
+
+
+inline bool ScImportAsciiDlg::Seek(ULONG nPos)
+{
+ bool bSuccess = true;
+ if (nPos != mnStreamPos && mpDatStream)
+ {
+ if (mpDatStream->Seek( nPos ) != nPos)
+ bSuccess = false;
+ else
+ mnStreamPos = nPos;
+ }
+ return bSuccess;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scuiautofmt.hxx b/sc/source/ui/inc/scuiautofmt.hxx
new file mode 100644
index 000000000000..f0bbc720d128
--- /dev/null
+++ b/sc/source/ui/inc/scuiautofmt.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SCUI_AUTOFMT_HXX
+#define SCUI_AUTOFMT_HXX
+#include "autofmt.hxx"
+
+class ScAutoFormatDlg : public ModalDialog
+{
+public:
+ ScAutoFormatDlg( Window* pParent,
+ ScAutoFormat* pAutoFormat,
+ const ScAutoFormatData* pSelFormatData,
+ ScDocument* pDoc );
+ ~ScAutoFormatDlg();
+
+ USHORT GetIndex() const { return nIndex; }
+ String GetCurrFormatName();
+
+private:
+ FixedLine aFlFormat;
+ ListBox aLbFormat;
+ ScAutoFmtPreview* pWndPreview;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ PushButton aBtnAdd;
+ PushButton aBtnRemove;
+ MoreButton aBtnMore;
+ FixedLine aFlFormatting;
+ CheckBox aBtnNumFormat;
+ CheckBox aBtnBorder;
+ CheckBox aBtnFont;
+ CheckBox aBtnPattern;
+ CheckBox aBtnAlignment;
+ CheckBox aBtnAdjust;
+ PushButton aBtnRename;
+ String aStrTitle;
+ String aStrLabel;
+ String aStrClose;
+ String aStrDelTitle;
+ String aStrDelMsg;
+ String aStrRename;
+
+ //------------------------
+ ScAutoFormat* pFormat;
+ const ScAutoFormatData* pSelFmtData;
+ USHORT nIndex;
+ BOOL bCoreDataChanged;
+ BOOL bFmtInserted;
+
+ void Init ();
+ void UpdateChecks ();
+ //------------------------
+ DECL_LINK( CheckHdl, Button * );
+ DECL_LINK( AddHdl, void * );
+ DECL_LINK( RemoveHdl, void * );
+ DECL_LINK( SelFmtHdl, void * );
+ DECL_LINK( CloseHdl, PushButton * );
+ DECL_LINK( DblClkHdl, void * );
+ DECL_LINK( RenameHdl, void *);
+
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scuiimoptdlg.hxx b/sc/source/ui/inc/scuiimoptdlg.hxx
new file mode 100644
index 000000000000..3013e8385e21
--- /dev/null
+++ b/sc/source/ui/inc/scuiimoptdlg.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SCUI_IMOPTDLG_HXX
+#define SCUI_IMOPTDLG_HXX
+
+#include "imoptdlg.hxx"
+
+//===================================================================
+
+
+class ScDelimiterTable;
+
+class ScImportOptionsDlg : public ModalDialog
+{
+public:
+ ScImportOptionsDlg( Window* pParent,
+ BOOL bAscii = TRUE,
+ const ScImportOptions* pOptions = NULL,
+ const String* pStrTitle = NULL,
+ BOOL bMultiByte = FALSE,
+ BOOL bOnlyDbtoolsEncodings = FALSE,
+ BOOL bImport = TRUE );
+
+ ~ScImportOptionsDlg();
+
+ void GetImportOptions( ScImportOptions& rOptions ) const;
+
+private:
+ FixedLine aFlFieldOpt;
+ FixedText aFtFont;
+ SvxTextEncodingBox aLbFont;
+ FixedText aFtFieldSep;
+ ComboBox aEdFieldSep;
+ FixedText aFtTextSep;
+ ComboBox aEdTextSep;
+ CheckBox aCbFixed;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ CheckBox aCbShown;
+
+ ScDelimiterTable* pFieldSepTab;
+ ScDelimiterTable* pTextSepTab;
+
+private:
+ USHORT GetCodeFromCombo( const ComboBox& rEd ) const;
+
+ DECL_LINK( FixedWidthHdl, CheckBox* );
+ DECL_LINK( DoubleClickHdl, ListBox* );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/scuitphfedit.hxx b/sc/source/ui/inc/scuitphfedit.hxx
new file mode 100644
index 000000000000..e70e1384b488
--- /dev/null
+++ b/sc/source/ui/inc/scuitphfedit.hxx
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SCUI_TPHFEDIT_HXX
+#define SCUI_TPHFEDIT_HXX
+
+#include "tphfedit.hxx"
+
+//===================================================================
+enum ScHFEntryId
+{
+ eNoneEntry ,
+ ePageEntry ,
+ ePagesEntry ,
+ eSheetEntry ,
+ eConfidentialEntry ,
+ eFileNamePageEntry ,
+ eExtFileNameEntry ,
+ ePageSheetEntry ,
+ ePageFileNameEntry ,
+ ePageExtFileNameEntry ,
+ eUserNameEntry ,
+ eCreatedByEntry ,
+ eEntryCount
+};
+
+class ScHeaderEditEngine;
+class ScPatternAttr;
+class EditView;
+class EditTextObject;
+class SvxFieldItem;
+class ScAccessibleEditObject;
+
+
+class ScHFEditPage : public SfxTabPage
+{
+public:
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreSet );
+ virtual void Reset ( const SfxItemSet& rCoreSet );
+
+ void SetNumType(SvxNumType eNumType);
+ void ClearTextAreas();
+
+protected:
+ ScHFEditPage( Window* pParent,
+ USHORT nResId,
+ const SfxItemSet& rCoreSet,
+ USHORT nWhich, bool bHeader );
+ virtual ~ScHFEditPage();
+
+private:
+ FixedText aFtLeft;
+ ScEditWindow aWndLeft;
+ FixedText aFtCenter;
+ ScEditWindow aWndCenter;
+ FixedText aFtRight;
+ ScEditWindow aWndRight;
+ FixedText maFtDefinedHF;
+ ListBox maLbDefined;
+ FixedText maFtCustomHF;
+ ImageButton aBtnText;
+ ScExtIButton aBtnFile;
+ ImageButton aBtnTable;
+ ImageButton aBtnPage;
+ ImageButton aBtnLastPage;
+ ImageButton aBtnDate;
+ ImageButton aBtnTime;
+ FixedLine aFlInfo;
+ FixedInfo aFtInfo;
+ ScPopupMenu aPopUpFile;
+
+ USHORT nWhich;
+ String aCmdArr[6];
+
+private:
+#ifdef _TPHFEDIT_CXX
+ void FillCmdArr();
+ void InitPreDefinedList();
+ void ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling = false);
+ void InsertToDefinedList();
+ void RemoveFromDefinedList();
+ void SetSelectDefinedList();
+ bool IsPageEntry(EditEngine*pEngine, EditTextObject* pTextObj);
+ bool IsDateEntry(EditTextObject* pTextObj);
+ bool IsExtFileNameEntry(EditTextObject* pTextObj);
+ DECL_LINK( ListHdl_Impl, ListBox* );
+ DECL_LINK( ClickHdl, ImageButton* );
+ DECL_LINK( MenuHdl, ScExtIButton* );
+#endif
+};
+
+//===================================================================
+
+class ScRightHeaderEditPage : public ScHFEditPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges();
+
+private:
+ ScRightHeaderEditPage( Window* pParent, const SfxItemSet& rSet );
+};
+
+//===================================================================
+
+class ScLeftHeaderEditPage : public ScHFEditPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges();
+
+private:
+ ScLeftHeaderEditPage( Window* pParent, const SfxItemSet& rSet );
+};
+
+//===================================================================
+
+class ScRightFooterEditPage : public ScHFEditPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges();
+
+private:
+ ScRightFooterEditPage( Window* pParent, const SfxItemSet& rSet );
+};
+
+//===================================================================
+
+class ScLeftFooterEditPage : public ScHFEditPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges();
+
+private:
+ ScLeftFooterEditPage( Window* pParent, const SfxItemSet& rSet );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/select.hxx b/sc/source/ui/inc/select.hxx
new file mode 100644
index 000000000000..b920c6373833
--- /dev/null
+++ b/sc/source/ui/inc/select.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SELECT_HXX
+#define SC_SELECT_HXX
+
+#include <vcl/seleng.hxx>
+
+#include "viewdata.hxx" // ScSplitPos
+
+// ---------------------------------------------------------------------------
+
+class ScTabView;
+class ScViewData;
+
+
+class ScViewSelectionEngine : public SelectionEngine
+{
+private:
+ ScSplitPos eWhich;
+public:
+ ScViewSelectionEngine( Window* pWindow, ScTabView* pView,
+ ScSplitPos eSplitPos );
+
+ ScSplitPos GetWhich() const { return eWhich; }
+ void SetWhich(ScSplitPos eNew) { eWhich = eNew; }
+};
+
+
+class ScViewFunctionSet : public FunctionSet // View (Gridwin / Tastatur)
+{
+private:
+ ScViewData* pViewData;
+ ScViewSelectionEngine* pEngine;
+
+ BOOL bAnchor;
+ BOOL bStarted;
+ ScAddress aAnchorPos;
+
+ ScSplitPos GetWhich();
+
+public:
+ ScViewFunctionSet( ScViewData* pNewViewData );
+
+ void SetSelectionEngine( ScViewSelectionEngine* pSelEngine );
+
+ void SetAnchor( SCCOL nPosX, SCROW nPosY );
+ void SetAnchorFlag( BOOL bSet );
+
+ virtual void BeginDrag();
+ virtual void CreateAnchor();
+ virtual void DestroyAnchor();
+ virtual BOOL SetCursorAtPoint( const Point& rPointPixel, BOOL bDontSelectAtCursor = FALSE );
+ virtual BOOL IsSelectionAtPoint( const Point& rPointPixel );
+ virtual void DeselectAtPoint( const Point& rPointPixel );
+ virtual void DeselectAll();
+
+ BOOL SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScroll );
+};
+
+
+// ---------------------------------------------------------------------------
+
+
+class ScHeaderFunctionSet : public FunctionSet // Spalten- / Zeilenkoepfe
+{
+private:
+ ScViewData* pViewData;
+ BOOL bColumn; // Col- / Rowbar
+ ScSplitPos eWhich;
+
+ BOOL bAnchor;
+ SCCOLROW nCursorPos;
+
+public:
+ ScHeaderFunctionSet( ScViewData* pNewViewData );
+
+ void SetColumn( BOOL bSet );
+ void SetWhich( ScSplitPos eNew );
+
+ virtual void BeginDrag();
+ virtual void CreateAnchor();
+ virtual void DestroyAnchor();
+ virtual BOOL SetCursorAtPoint( const Point& rPointPixel, BOOL bDontSelectAtCursor = FALSE );
+ virtual BOOL IsSelectionAtPoint( const Point& rPointPixel );
+ virtual void DeselectAtPoint( const Point& rPointPixel );
+ virtual void DeselectAll();
+
+ void SetAnchorFlag(BOOL bSet) { bAnchor = bSet; }
+};
+
+
+class ScHeaderSelectionEngine : public SelectionEngine
+{
+public:
+ ScHeaderSelectionEngine( Window* pWindow, ScHeaderFunctionSet* pFuncSet );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/selectionstate.hxx b/sc/source/ui/inc/selectionstate.hxx
new file mode 100644
index 000000000000..7b1addb8eb84
--- /dev/null
+++ b/sc/source/ui/inc/selectionstate.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SELECTIONSTATE_HXX
+#define SC_SELECTIONSTATE_HXX
+
+#include <editeng/editdata.hxx>
+#include "rangelst.hxx"
+
+// ============================================================================
+
+/** Enumerates all possible types of selections in a Calc document. */
+enum ScSelectionType
+{
+ SC_SELECTTYPE_NONE, /// No selection, simple cell cursor.
+ SC_SELECTTYPE_SHEET, /// Single cell, cell range, or multi range selection.
+ SC_SELECTTYPE_EDITCELL, /// Cell in edit mode (with or without selection).
+ SC_SELECTTYPE_DRAWING, /// One or more drawing objects.
+ SC_SELECTTYPE_EDITDRAW /// Edit mode in drawing object (with or without selection).
+};
+
+// ----------------------------------------------------------------------------
+
+class ScViewData;
+
+/** Contains all available data about any possible selection in a Calc document. */
+class ScSelectionState
+{
+public:
+ explicit ScSelectionState( ScViewData& rViewData );
+
+ /** Returns the type of the selection this object contains. */
+ inline ScSelectionType GetSelectionType() const { return meType; }
+
+ /** Returns the position of the cell cursor. */
+ inline const ScAddress& GetCellCursor() const { return maCursor; }
+ /** Returns a range list containing all selected cell ranges. */
+ inline const ScRangeList& GetSheetSelection() const { return maSheetSel; }
+ /** Returns the edit engine selection. */
+ inline const ESelection& GetEditSelection() const { return maEditSel; }
+
+private:
+ ScSelectionType meType; /// Type of the selection.
+ ScAddress maCursor; /// Cell cursor position.
+ ScRangeList maSheetSel; /// Sheet selection.
+ ESelection maEditSel; /// Selection in edit mode.
+};
+
+bool operator==( const ScSelectionState& rL, const ScSelectionState& rR );
+inline bool operator!=( const ScSelectionState& rL, const ScSelectionState& rR ) { return !(rL == rR); }
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/seltrans.hxx b/sc/source/ui/inc/seltrans.hxx
new file mode 100644
index 000000000000..2ca51d96dfc7
--- /dev/null
+++ b/sc/source/ui/inc/seltrans.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SELTRANS_HXX
+#define SC_SELTRANS_HXX
+
+#include <svtools/transfer.hxx>
+
+class ScTabView;
+class ScTransferObj;
+class ScDrawTransferObj;
+
+enum ScSelectionTransferMode
+{
+ SC_SELTRANS_INVALID,
+ SC_SELTRANS_CELL,
+ SC_SELTRANS_CELLS,
+ SC_SELTRANS_DRAW_BITMAP,
+ SC_SELTRANS_DRAW_GRAPHIC,
+ SC_SELTRANS_DRAW_BOOKMARK,
+ SC_SELTRANS_DRAW_OLE,
+ SC_SELTRANS_DRAW_OTHER
+};
+
+class ScSelectionTransferObj : public TransferableHelper
+{
+private:
+ ScTabView* pView;
+ ScSelectionTransferMode eMode;
+ ScTransferObj* pCellData;
+ ScDrawTransferObj* pDrawData;
+
+ ScSelectionTransferObj( ScTabView* pSource, ScSelectionTransferMode eNewMode );
+ void CreateCellData();
+ void CreateDrawData();
+
+public:
+ // creates an object if the view has a valid selection,
+ // returns NULL otherwise
+ static ScSelectionTransferObj* CreateFromView( ScTabView* pSource );
+
+ virtual ~ScSelectionTransferObj();
+
+ void ForgetView();
+ BOOL StillValid();
+ ScTabView* GetView() const { return pView; }
+
+ ScTransferObj* GetCellData();
+ ScDrawTransferObj* GetDrawData();
+
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void ObjectReleased();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/servobj.hxx b/sc/source/ui/inc/servobj.hxx
new file mode 100644
index 000000000000..9080aed8d7e2
--- /dev/null
+++ b/sc/source/ui/inc/servobj.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SERVOBJ_HXX
+#define SC_SERVOBJ_HXX
+
+#include <svl/lstner.hxx>
+#include <svl/listener.hxx>
+#include <sfx2/linksrc.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+class ScDocShell;
+class ScServerObject;
+
+class ScServerObjectSvtListenerForwarder : public SvtListener
+{
+ ScServerObject* pObj;
+ SfxBroadcaster aBroadcaster;
+public:
+ ScServerObjectSvtListenerForwarder( ScServerObject* pObjP);
+ virtual ~ScServerObjectSvtListenerForwarder();
+ virtual void Notify( SvtBroadcaster& rBC, const SfxHint& rHint);
+};
+
+class ScServerObject : public ::sfx2::SvLinkSource, public SfxListener
+{
+private:
+ ScServerObjectSvtListenerForwarder aForwarder;
+ ScDocShell* pDocSh;
+ ScRange aRange;
+ String aItemStr;
+ BOOL bRefreshListener;
+
+ void Clear();
+
+public:
+ ScServerObject( ScDocShell* pShell, const String& rItem );
+ virtual ~ScServerObject();
+
+ virtual BOOL GetData( ::com::sun::star::uno::Any & rData /*out param*/,
+ const String & rMimeType,
+ BOOL bSynchron = FALSE );
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ void EndListeningAll();
+};
+
+//SO2_DECL_REF( ScServerObject )
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/sharedocdlg.hrc b/sc/source/ui/inc/sharedocdlg.hrc
new file mode 100644
index 000000000000..adf2ed06a31c
--- /dev/null
+++ b/sc/source/ui/inc/sharedocdlg.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc>
+
+#define CB_SHARE 1
+#define FT_WARNING 2
+#define FL_USERS 3
+#define FT_USERS 4
+#define LB_USERS 5
+#define FL_END 6
+#define BTN_HELP 7
+#define BTN_OK 8
+#define BTN_CANCEL 9
+
+#define STR_TITLE_NAME 1
+#define STR_TITLE_ACCESSED 2
+#define STR_NO_USER_DATA 3
+#define STR_UNKNOWN_USER 4
+#define STR_EXCLUSIVE_ACCESS 5
diff --git a/sc/source/ui/inc/sharedocdlg.hxx b/sc/source/ui/inc/sharedocdlg.hxx
new file mode 100644
index 000000000000..47ac9ceac897
--- /dev/null
+++ b/sc/source/ui/inc/sharedocdlg.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SHAREDOCDLG_HXX
+#define SC_SHAREDOCDLG_HXX
+
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <svx/simptabl.hxx>
+
+class ScViewData;
+class ScDocShell;
+
+
+//=============================================================================
+// class ScShareDocumentDlg
+//=============================================================================
+
+class ScShareDocumentDlg : public ModalDialog
+{
+private:
+ CheckBox maCbShare;
+ FixedText maFtWarning;
+ FixedLine maFlUsers;
+ FixedText maFtUsers;
+ SvxSimpleTable maLbUsers;
+ FixedLine maFlEnd;
+ HelpButton maBtnHelp;
+ OKButton maBtnOK;
+ CancelButton maBtnCancel;
+
+ String maStrTitleName;
+ String maStrTitleAccessed;
+ String maStrNoUserData;
+ String maStrUnkownUser;
+ String maStrExclusiveAccess;
+
+ ScViewData* mpViewData;
+ ScDocShell* mpDocShell;
+
+ DECL_LINK( ToggleHandle, void* );
+
+public:
+ ScShareDocumentDlg( Window* pParent, ScViewData* pViewData );
+ ~ScShareDocumentDlg();
+
+ bool IsShareDocumentChecked() const;
+ void UpdateView();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/shtabdlg.hxx b/sc/source/ui/inc/shtabdlg.hxx
new file mode 100644
index 000000000000..5734c661e966
--- /dev/null
+++ b/sc/source/ui/inc/shtabdlg.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SHTABDLG_HXX
+#define SC_SHTABDLG_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <svtools/tooltiplbox.hxx>
+#include <vcl/dialog.hxx>
+
+//------------------------------------------------------------------------
+
+class ScShowTabDlg : public ModalDialog
+{
+private:
+ ::svtools::ToolTipMultiListBox aLb;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ FixedText aFtLbTitle;
+
+ DECL_LINK( DblClkHdl, void * );
+
+public:
+ ScShowTabDlg( Window* pParent );
+ ~ScShowTabDlg();
+
+ /** Sets dialog title, fixed text for listbox and help IDs. */
+ void SetDescription(
+ const String& rTitle, const String& rFixedText,
+ ULONG nDlgHelpId, ULONG nLbHelpId );
+
+ /** Inserts a string into the ListBox. */
+ void Insert( const String& rString, BOOL bSelected );
+
+ USHORT GetSelectEntryCount() const;
+ String GetSelectEntry(USHORT nPos) const;
+ USHORT GetSelectEntryPos(USHORT nPos) const;
+};
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/simpref.hrc b/sc/source/ui/inc/simpref.hrc
new file mode 100644
index 000000000000..058abc26475d
--- /dev/null
+++ b/sc/source/ui/inc/simpref.hrc
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> RID_SCDLG_SIMPLEREF
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_ADD 3
+#define BTN_HELP 4
+#define FT_ASSIGN 10
+#define ED_ASSIGN 11
+#define RB_ASSIGN 12
+
diff --git a/sc/source/ui/inc/simpref.hxx b/sc/source/ui/inc/simpref.hxx
new file mode 100644
index 000000000000..34d1165ca689
--- /dev/null
+++ b/sc/source/ui/inc/simpref.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SIMPREF_HXX
+#define SC_SIMPREF_HXX
+
+#include <vcl/group.hxx>
+
+#include <vcl/combobox.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <vcl/morebtn.hxx>
+#include "anyrefdg.hxx"
+#include "dbcolect.hxx"
+#include "expftext.hxx"
+
+class ScViewData;
+class ScDocument;
+
+
+//============================================================================
+
+class ScSimpleRefDlg: public ScAnyRefDlg
+{
+private:
+ Link aCloseHdl;
+ Link aDoneHdl;
+ Link aAbortedHdl;
+ Link aChangeHdl;
+
+ FixedText aFtAssign;
+ formula::RefEdit aEdAssign;
+ formula::RefButton aRbAssign;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ BOOL bRefInputMode;
+
+ ScRange theCurArea;
+ BOOL bCloseFlag;
+ BOOL bAutoReOpen;
+ BOOL bCloseOnButtonUp;
+ BOOL bSingleCell;
+ BOOL bMultiSelection;
+
+ void Init();
+
+ DECL_LINK( CancelBtnHdl, void * );
+ DECL_LINK( OkBtnHdl, void * );
+
+
+protected:
+
+ virtual void RefInputDone( BOOL bForced = FALSE );
+
+public:
+ ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData );
+ ~ScSimpleRefDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+ virtual BOOL Close();
+
+ void StartRefInput();
+
+ virtual String GetRefString() const;
+ virtual void SetRefString(const String &rStr);
+ virtual void FillInfo(SfxChildWinInfo&) const;
+
+ void SetCloseHdl( const Link& rLink );
+ void SetUnoLinks( const Link& rDone, const Link& rAbort,
+ const Link& rChange );
+
+ void SetFlags( BOOL bSetCloseOnButtonUp, BOOL bSetSingleCell, BOOL bSetMultiSelection );
+
+ void SetAutoReOpen(BOOL bFlag) {bAutoReOpen=bFlag;}
+};
+
+
+
+#endif // SC_DBNAMDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/sizedev.hxx b/sc/source/ui/inc/sizedev.hxx
new file mode 100644
index 000000000000..5beff55c99f7
--- /dev/null
+++ b/sc/source/ui/inc/sizedev.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SIZEDEV_HXX
+#define SC_SIZEDEV_HXX
+
+#include <vcl/mapmod.hxx>
+
+class OutputDevice;
+class ScDocShell;
+
+class ScSizeDeviceProvider
+{
+ OutputDevice* pDevice;
+ BOOL bOwner;
+ double nPPTX;
+ double nPPTY;
+ MapMode aOldMapMode;
+
+public:
+ ScSizeDeviceProvider( ScDocShell* pDocSh );
+ ~ScSizeDeviceProvider();
+
+ OutputDevice* GetDevice() const { return pDevice; }
+ double GetPPTX() const { return nPPTX; }
+ double GetPPTY() const { return nPPTY; }
+ BOOL IsPrinter() const { return !bOwner; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/solveroptions.hrc b/sc/source/ui/inc/solveroptions.hrc
new file mode 100644
index 000000000000..0cf4e05617c3
--- /dev/null
+++ b/sc/source/ui/inc/solveroptions.hrc
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+#define FT_ENGINE 1
+#define FT_SETTINGS 2
+#define FT_OPTIONNAME 3
+
+#define LB_ENGINE 1
+#define LB_SETTINGS 2
+
+#define FL_BUTTONS 1
+
+#define BTN_EDIT 1
+#define BTN_HELP 2
+#define BTN_OK 3
+#define BTN_CANCEL 4
+
+#define NF_VALUE 1
+
+#define ED_VALUE 1
+
diff --git a/sc/source/ui/inc/solveroptions.hxx b/sc/source/ui/inc/solveroptions.hxx
new file mode 100644
index 000000000000..7a44c1cac6c2
--- /dev/null
+++ b/sc/source/ui/inc/solveroptions.hxx
@@ -0,0 +1,123 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SOLVEROPTIONS_HXX
+#define SC_SOLVEROPTIONS_HXX
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <svx/checklbx.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace beans { struct PropertyValue; }
+} } }
+
+
+
+class ScSolverOptionsDialog : public ModalDialog
+{
+ FixedText maFtEngine;
+ ListBox maLbEngine;
+ FixedText maFtSettings;
+ SvxCheckListBox maLbSettings;
+ PushButton maBtnEdit;
+ FixedLine maFlButtons;
+ HelpButton maBtnHelp;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+
+ SvLBoxButtonData* mpCheckButtonData;
+ com::sun::star::uno::Sequence<rtl::OUString> maImplNames;
+ com::sun::star::uno::Sequence<rtl::OUString> maDescriptions;
+ String maEngine;
+ com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maProperties;
+
+ DECL_LINK( EngineSelectHdl, ListBox* );
+ DECL_LINK( SettingsSelHdl, SvxCheckListBox* );
+ DECL_LINK( SettingsDoubleClickHdl, SvTreeListBox* );
+ DECL_LINK( ButtonHdl, PushButton* );
+
+ void ReadFromComponent();
+ void FillListBox();
+ void EditOption();
+
+public:
+ ScSolverOptionsDialog( Window* pParent,
+ const com::sun::star::uno::Sequence<rtl::OUString>& rImplNames,
+ const com::sun::star::uno::Sequence<rtl::OUString>& rDescriptions,
+ const String& rEngine,
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProperties );
+ ~ScSolverOptionsDialog();
+
+ const String& GetEngine() const;
+ const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& GetProperties();
+};
+
+
+class ScSolverIntegerDialog : public ModalDialog
+{
+ FixedText maFtName;
+ NumericField maNfValue;
+ FixedLine maFlButtons;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+
+public:
+ ScSolverIntegerDialog( Window * pParent );
+ ~ScSolverIntegerDialog();
+
+ void SetOptionName( const String& rName );
+ void SetValue( sal_Int32 nValue );
+ sal_Int32 GetValue() const;
+};
+
+class ScSolverValueDialog : public ModalDialog
+{
+ FixedText maFtName;
+ Edit maEdValue;
+ FixedLine maFlButtons;
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+
+public:
+ ScSolverValueDialog( Window * pParent );
+ ~ScSolverValueDialog();
+
+ void SetOptionName( const String& rName );
+ void SetValue( double fValue );
+ double GetValue() const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/solverutil.hxx b/sc/source/ui/inc/solverutil.hxx
new file mode 100644
index 000000000000..ff2c332391c3
--- /dev/null
+++ b/sc/source/ui/inc/solverutil.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SOLVERUTIL_HXX
+#define SC_SOLVERUTIL_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace beans { struct PropertyValue; }
+ namespace sheet { class XSolver; }
+} } }
+
+
+class ScSolverUtil
+{
+public:
+ static void GetImplementations( com::sun::star::uno::Sequence<rtl::OUString>& rImplNames,
+ com::sun::star::uno::Sequence<rtl::OUString>& rDescriptions );
+ static com::sun::star::uno::Reference<com::sun::star::sheet::XSolver> GetSolver( const rtl::OUString& rImplName );
+ static com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> GetDefaults( const rtl::OUString& rImplName );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/solvrdlg.hrc b/sc/source/ui/inc/solvrdlg.hrc
new file mode 100644
index 000000000000..a04fa5aafb22
--- /dev/null
+++ b/sc/source/ui/inc/solvrdlg.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // ->RID_SCDLG_SOLVER
+
+#define ED_FORMULACELL 1
+#define ED_TARGETVAL 2
+#define ED_VARCELL 3
+#define FT_FORMULACELL 1
+#define FT_TARGETVAL 2
+#define FT_VARCELL 3
+#define RB_FORMULACELL 1
+#define RB_VARCELL 2
+#define FL_VARIABLES 1
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 1
+#define STR_INVALIDVAL 1
+#define STR_INVALIDVAR 2
+#define STR_INVALIDFORM 3
+#define STR_NOFORMULA 4
+
diff --git a/sc/source/ui/inc/solvrdlg.hxx b/sc/source/ui/inc/solvrdlg.hxx
new file mode 100644
index 000000000000..6a00a2027dc8
--- /dev/null
+++ b/sc/source/ui/inc/solvrdlg.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SOLVRDLG_HXX
+#define SC_SOLVRDLG_HXX
+
+#include "global.hxx"
+#include "address.hxx"
+#include "anyrefdg.hxx"
+
+
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+
+//----------------------------------------------------------------------------
+
+enum ScSolverErr
+ {
+ SOLVERR_NOFORMULA,
+ SOLVERR_INVALID_FORMULA,
+ SOLVERR_INVALID_VARIABLE,
+ SOLVERR_INVALID_TARGETVALUE
+ };
+
+
+//============================================================================
+
+class ScSolverDlg : public ScAnyRefDlg
+{
+public:
+ ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ ScAddress aCursorPos );
+ ~ScSolverDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual BOOL IsRefInputMode() const;
+ virtual void SetActive();
+ virtual BOOL Close();
+
+private:
+ FixedLine aFlVariables;
+ FixedText aFtFormulaCell;
+ formula::RefEdit aEdFormulaCell;
+ formula::RefButton aRBFormulaCell;
+
+ FixedText aFtTargetVal;
+ Edit aEdTargetVal;
+
+ FixedText aFtVariableCell;
+ formula::RefEdit aEdVariableCell;
+ formula::RefButton aRBVariableCell;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ ScAddress theFormulaCell;
+ ScAddress theVariableCell;
+ String theTargetValStr;
+
+ ScDocument* pDoc;
+ const SCTAB nCurTab;
+ formula::RefEdit* pEdActive;
+ BOOL bDlgLostFocus;
+ const String errMsgInvalidVar;
+ const String errMsgInvalidForm;
+ const String errMsgNoFormula;
+ const String errMsgInvalidVal;
+
+
+#ifdef _SOLVRDLG_CXX
+ void Init();
+ BOOL CheckTargetValue( String& rStrVal );
+ void RaiseError( ScSolverErr eError );
+
+ DECL_LINK( BtnHdl, PushButton* );
+ DECL_LINK( GetFocusHdl, Control* );
+ DECL_LINK( LoseFocusHdl, Control* );
+#endif // _SOLVERDLG_CXX
+};
+
+#endif // SC_SOLVRDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/sortdlg.hrc b/sc/source/ui/inc/sortdlg.hrc
new file mode 100644
index 000000000000..2e55f447778e
--- /dev/null
+++ b/sc/source/ui/inc/sortdlg.hrc
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "sc.hrc" // -> RID_SCDLG_SORT
+ // -> RID_SCPAGE_SORT_FIELDS
+ // -> RID_SCPAGE_SORT_OPTIONS
+ // -> RID_SCDLG_SORT_WARNING
+ // -> SCSTR_NONAME
+ // -> SCSTR_UNDEFINED
+ // -> SCSTR_FIELD
+
+/*
+#define RID_SCDLG_SORT 256
+#define RID_SCPAGE_SORT_FIELDS 257
+#define RID_SCPAGE_SORT_OPTIONS 258
+#define RID_SCDLG_SORT_WARNING
+*/
+
+#define TP_FIELDS 1
+#define TP_OPTIONS 2
+
+// TP_SORT_FIELDS:
+#define FL_SORT1 1
+#define FL_SORT2 2
+#define FL_SORT3 3
+#define LB_SORT1 4
+#define LB_SORT2 5
+#define LB_SORT3 6
+#define BTN_UP1 7
+#define BTN_UP2 8
+#define BTN_UP3 9
+#define BTN_DOWN1 10
+#define BTN_DOWN2 11
+#define BTN_DOWN3 12
+
+// TP_SORT_OPTIONS:
+#define FL_DIRECTION 1
+#define LB_SORT_USER 2
+#define LB_OUTAREA 3
+#define ED_OUTAREA 4
+//#define FT_AREA_LABEL 5
+//#define FT_AREA 6
+#define BTN_SORT_USER 7
+#define BTN_CASESENSITIVE 8
+#define BTN_LABEL 9
+#define BTN_FORMATS 10
+#define BTN_COPYRESULT 11
+#define BTN_TOP_DOWN 12
+#define BTN_LEFT_RIGHT 13
+#define STR_COL_LABEL 14
+#define STR_ROW_LABEL 15
+#define FT_LANGUAGE 16
+#define LB_LANGUAGE 17
+#define FT_ALGORITHM 18
+#define LB_ALGORITHM 19
+#define BTN_NATURALSORT 20
+
+//#define RID_SCDLG_SORT_WARNING
+#define FT_TEXT 1
+#define FT_TIP 2
+#define BTN_EXTSORT 3
+#define BTN_CURSORT 4
+#define BTN_CANCEL 5
+
+
+
diff --git a/sc/source/ui/inc/sortdlg.hxx b/sc/source/ui/inc/sortdlg.hxx
new file mode 100644
index 000000000000..66a43fd4e53b
--- /dev/null
+++ b/sc/source/ui/inc/sortdlg.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SORTDLG_HXX
+#define SC_SORTDLG_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/button.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include "scui_def.hxx"
+
+#ifndef LAYOUT_SFX_TABDIALOG_BROKEN
+#define LAYOUT_SFX_TABDIALOG_BROKEN 1
+#endif /* !LAYOUT_SFX_TABDIALOG_BROKEN */
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <sfx2/layout.hxx>
+#include <layout/layout-pre.hxx>
+#endif
+
+class ScSortDlg : public SfxTabDialog
+{
+public:
+ ScSortDlg( Window* pParent,
+ const SfxItemSet* pArgSet );
+ ~ScSortDlg();
+
+ void SetHeaders( BOOL bHeaders );
+ void SetByRows ( BOOL bByRows );
+ BOOL GetHeaders() const;
+ BOOL GetByRows () const;
+
+
+private:
+ BOOL bIsHeaders;
+ BOOL bIsByRows;
+};
+
+inline void ScSortDlg::SetHeaders( BOOL bHeaders ) { bIsHeaders = bHeaders; }
+inline void ScSortDlg::SetByRows ( BOOL bByRows ) { bIsByRows = bByRows; }
+inline BOOL ScSortDlg::GetHeaders() const { return bIsHeaders; }
+inline BOOL ScSortDlg::GetByRows () const { return bIsByRows; }
+
+class ScSortWarningDlg : public ModalDialog
+{
+public:
+ ScSortWarningDlg( Window* pParent, const String& rExtendText,const String& rCurrentText );
+ ~ScSortWarningDlg();
+ DECL_LINK( BtnHdl, PushButton* );
+private:
+ FixedText aFtText;
+ FixedText aFtTip;
+ PushButton aBtnExtSort;
+ PushButton aBtnCurSort;
+ CancelButton aBtnCancel;
+};
+
+#if !LAYOUT_SFX_TABDIALOG_BROKEN
+#include <layout/layout-post.hxx>
+#endif
+
+#endif // SC_SORTDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/spelldialog.hxx b/sc/source/ui/inc/spelldialog.hxx
new file mode 100644
index 000000000000..5a423bc66c87
--- /dev/null
+++ b/sc/source/ui/inc/spelldialog.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SPELLDIALOG_HXX
+#define SC_SPELLDIALOG_HXX
+
+#include <memory>
+#include <svx/SpellDialogChildWindow.hxx>
+
+// ============================================================================
+
+class ScConversionEngineBase;
+class ScSelectionState;
+class ScTabViewShell;
+class ScViewData;
+class ScDocShell;
+class ScDocument;
+
+/** Specialized spell check dialog child window for Calc.
+
+ This derivation of the ::svx::SpellDialogChildWindow base class provides
+ Calc specific implementations of the virtual functions GetNextWrongSentence()
+ and ApplyChangedSentence().
+ */
+class ScSpellDialogChildWindow : public ::svx::SpellDialogChildWindow
+{
+public:
+ SFX_DECL_CHILDWINDOW( ScSpellDialogChildWindow );
+
+ explicit ScSpellDialogChildWindow( Window* pParent, USHORT nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo );
+ virtual ~ScSpellDialogChildWindow();
+
+ /** This method makes the one from the base class public so that
+ it can be called from the view shell when one is created.
+ */
+ virtual void InvalidateSpellDialog();
+
+protected:
+ /** Iterate over the sentences in all text shapes and stop at the
+ next sentence with spelling errors. While doing so the view
+ mode may be changed and text shapes are set into edit mode.
+ */
+ virtual ::svx::SpellPortions GetNextWrongSentence( bool bRecheck );
+
+ /** This method is responsible for merging corrections made in the
+ spelling dialog back into the document.
+ */
+ virtual void ApplyChangedSentence( const ::svx::SpellPortions& rChanged, bool bRecheck );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+private:
+ void Reset();
+ void Init();
+
+ bool IsSelectionChanged();
+
+private:
+ typedef ::std::auto_ptr< ScConversionEngineBase > ScConvEnginePtr;
+ typedef ::std::auto_ptr< ScDocument > ScDocumentPtr;
+ typedef ::std::auto_ptr< ScSelectionState > ScSelectionStatePtr;
+
+ ScConvEnginePtr mxEngine;
+ ScDocumentPtr mxUndoDoc;
+ ScDocumentPtr mxRedoDoc;
+ ScSelectionStatePtr mxOldSel; /// Old selection state for comparison.
+ ScTabViewShell* mpViewShell;
+ ScViewData* mpViewData;
+ ScDocShell* mpDocShell;
+ ScDocument* mpDoc;
+ bool mbNeedNextObj;
+ bool mbOldIdleDisabled;
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/spelleng.hxx b/sc/source/ui/inc/spelleng.hxx
new file mode 100644
index 000000000000..6c77586f3500
--- /dev/null
+++ b/sc/source/ui/inc/spelleng.hxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_SPELLENG_HXX
+#define SC_SPELLENG_HXX
+
+#include "editutil.hxx"
+#include "selectionstate.hxx"
+#include "spellparam.hxx"
+
+class ScViewData;
+class ScDocShell;
+class ScDocument;
+class SfxItemPool;
+
+// ============================================================================
+
+/** Base class for special type of edit engines, i.e. for spell checker and text conversion. */
+class ScConversionEngineBase : public ScEditEngineDefaulter
+{
+public:
+ explicit ScConversionEngineBase(
+ SfxItemPool* pEnginePool, ScViewData& rViewData,
+ ScDocument* pUndoDoc, ScDocument* pRedoDoc );
+
+ virtual ~ScConversionEngineBase();
+
+ /** Derived classes implement to convert all cells in the selection or sheet. */
+ virtual void ConvertAll( EditView& rEditView ) = 0;
+
+ /** Returns true, if at least one cell has been modified. */
+ inline bool IsAnyModified() const { return mbIsAnyModified; }
+ /** Returns true, if the entire document/selection has been finished. */
+ inline bool IsFinished() const { return mbFinished; }
+
+protected:
+ /** Implementation of cell iteration. Finds a cell that needs conversion.
+ @return true = Current cell needs conversion (i.e. spelling error found). */
+ bool FindNextConversionCell();
+ /** Restores the initial cursor position. */
+ void RestoreCursorPos();
+
+ /** Derived classes return, if the current text needs conversion (i.e. spelling error found).
+ @return true = Current edit text needs conversion. */
+ virtual bool NeedsConversion() = 0;
+
+ /** Derived classes may show a query box that asks whether to restart at top of the sheet.
+ @descr Default here is no dialog and restart always.
+ @return true = Restart at top, false = Stop the conversion. */
+ virtual bool ShowTableWrapDialog();
+ /** Derived classes may show a message box stating that the conversion is finished.
+ @descr Default here is no dialog. */
+ virtual void ShowFinishDialog();
+
+private:
+ /** Fills the edit engine from a document cell. */
+ void FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
+
+protected: // for usage in derived classes
+ ScViewData& mrViewData;
+ ScDocShell& mrDocShell;
+ ScDocument& mrDoc;
+
+private:
+ ScSelectionState maSelState; /// Selection data of the document.
+ ScDocument* mpUndoDoc; /// Document stores all old cells for UNDO action.
+ ScDocument* mpRedoDoc; /// Document stores all new cells for REDO action.
+ LanguageType meCurrLang; /// Current cell language.
+ SCCOL mnStartCol; /// Initial column index.
+ SCROW mnStartRow; /// Initial row index.
+ SCTAB mnStartTab; /// Initial sheet index.
+ SCCOL mnCurrCol; /// Current column index.
+ SCROW mnCurrRow; /// Current row index.
+ bool mbIsAnyModified; /// true = At least one cell has been changed.
+ bool mbInitialState; /// true = Not searched for a cell yet.
+ bool mbWrappedInTable; /// true = Already restarted at top of the sheet.
+ bool mbFinished; /// true = Entire document/selection finished.
+};
+
+// ============================================================================
+
+/** Edit engine for spell checking. */
+class ScSpellingEngine : public ScConversionEngineBase
+{
+public:
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellChecker1 > XSpellCheckerRef;
+
+ explicit ScSpellingEngine(
+ SfxItemPool* pEnginePool,
+ ScViewData& rViewData,
+ ScDocument* pUndoDoc,
+ ScDocument* pRedoDoc,
+ XSpellCheckerRef xSpeller );
+
+ /** Checks spelling of all cells in the selection or sheet. */
+ virtual void ConvertAll( EditView& rEditView );
+
+protected:
+ /** Callback from edit engine to check the next cell. */
+ virtual BOOL SpellNextDocument();
+
+ /** Returns true, if the current text contains a spelling error. */
+ virtual bool NeedsConversion();
+
+ /** Show a query box that asks whether to restart at top of the sheet.
+ @return true = Restart at top, false = Stop the conversion. */
+ virtual bool ShowTableWrapDialog();
+ /** Show a message box stating that spell checking is finished. */
+ virtual void ShowFinishDialog();
+
+private:
+ /** Returns the spelling dialog if it is open. */
+ Window* GetDialogParent();
+};
+
+// ============================================================================
+
+/** Edit engine for text conversion. */
+class ScTextConversionEngine : public ScConversionEngineBase
+{
+public:
+ explicit ScTextConversionEngine(
+ SfxItemPool* pEnginePool,
+ ScViewData& rViewData,
+ const ScConversionParam& rConvParam,
+ ScDocument* pUndoDoc,
+ ScDocument* pRedoDoc );
+
+ /** Converts all cells in the selection or sheet according to set language. */
+ virtual void ConvertAll( EditView& rEditView );
+
+protected:
+ /** Callback from edit engine to convert the next cell. */
+ virtual BOOL ConvertNextDocument();
+
+ /** Returns true, if the current text contains text to convert. */
+ virtual bool NeedsConversion();
+
+private:
+ ScConversionParam maConvParam; /// Conversion parameters.
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/spellparam.hxx b/sc/source/ui/inc/spellparam.hxx
new file mode 100644
index 000000000000..ab780866b240
--- /dev/null
+++ b/sc/source/ui/inc/spellparam.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_SPELLPARAM_HXX
+#define SC_SPELLPARAM_HXX
+
+#include <vcl/font.hxx>
+
+// ============================================================================
+
+/** Specifiers for sheet conversion (functions iterating over the sheet and modifying cells). */
+enum ScConversionType
+{
+ SC_CONVERSION_SPELLCHECK, /// Spell checker.
+ SC_CONVERSION_HANGULHANJA, /// Hangul-Hanja converter.
+ SC_CONVERSION_CHINESE_TRANSL /// Chinese simplified/traditional converter.
+};
+
+// ---------------------------------------------------------------------------
+
+/** Parameters for conversion. */
+class ScConversionParam
+{
+public:
+ /** Constructs an empty parameter struct with the passed conversion type. */
+ explicit ScConversionParam( ScConversionType eConvType );
+
+ /** Constructs parameter struct for text conversion without changing the language. */
+ explicit ScConversionParam(
+ ScConversionType eConvType,
+ LanguageType eLang,
+ sal_Int32 nOptions,
+ bool bIsInteractive );
+
+ /** Constructs parameter struct for text conversion with language change. */
+ explicit ScConversionParam(
+ ScConversionType eConvType,
+ LanguageType eSourceLang,
+ LanguageType eTargetLang,
+ const Font& rTargetFont,
+ sal_Int32 nOptions,
+ bool bIsInteractive );
+
+ inline ScConversionType GetType() const { return meConvType; }
+ inline LanguageType GetSourceLang() const { return meSourceLang; }
+ inline LanguageType GetTargetLang() const { return meTargetLang; }
+ inline const Font* GetTargetFont() const { return mbUseTargetFont ? &maTargetFont : 0; }
+ inline sal_Int32 GetOptions() const { return mnOptions; }
+ inline bool IsInteractive() const { return mbIsInteractive; }
+
+private:
+ ScConversionType meConvType; /// Type of the conversion.
+ LanguageType meSourceLang; /// Source language for conversion.
+ LanguageType meTargetLang; /// Target language for conversion.
+ Font maTargetFont; /// Target font to be used if language has to be changed.
+ sal_Int32 mnOptions; /// Conversion options.
+ bool mbUseTargetFont; /// True = Use maTargetFont to change font during conversion.
+ bool mbIsInteractive; /// True = Text conversion has (specific) dialog that may be raised.
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/strindlg.hxx b/sc/source/ui/inc/strindlg.hxx
new file mode 100644
index 000000000000..70700987998f
--- /dev/null
+++ b/sc/source/ui/inc/strindlg.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_STRINDLG_HXX
+#define SC_STRINDLG_HXX
+
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/edit.hxx>
+
+#include <layout/layout.hxx>
+#include <layout/layout-pre.hxx>
+
+//------------------------------------------------------------------------
+
+class ScStringInputDlg : public ModalDialog
+{
+public:
+ ScStringInputDlg( Window* pParent,
+ const String& rTitle,
+ const String& rEditTitle,
+ const String& rDefault,
+ ULONG nHelpId );
+ ~ScStringInputDlg();
+
+ void GetInputString( String& rString ) const;
+
+private:
+ FixedText aFtEditTitle;
+ Edit aEdInput;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+};
+
+#include <layout/layout-post.hxx>
+
+#endif // SC_STRINDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/styledlg.hrc b/sc/source/ui/inc/styledlg.hrc
new file mode 100644
index 000000000000..6ce7ef4ac422
--- /dev/null
+++ b/sc/source/ui/inc/styledlg.hrc
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define TP_NUMBER 2
+#define TP_FONT 3
+#define TP_ALIGNMENT 4
+#define TP_BORDER 5
+#define TP_BACKGROUND 6
+#define TP_PROTECTION 7
+#define TP_PAGE_STD 8
+#define TP_PAGE_HEADER 9
+#define TP_PAGE_FOOTER 10
+#define TP_TABLE 11
+#define TP_FONTEFF 12
+#define TP_ASIAN 13
+
diff --git a/sc/source/ui/inc/styledlg.hxx b/sc/source/ui/inc/styledlg.hxx
new file mode 100644
index 000000000000..09a6ff191db3
--- /dev/null
+++ b/sc/source/ui/inc/styledlg.hxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_STYLEDLG_HXX
+#define SC_STYLEDLG_HXX
+
+#ifndef _SFX_HXX
+#endif
+
+#include <sfx2/styledlg.hxx>
+
+//==================================================================
+
+class SfxStyleSheetBase;
+
+class ScStyleDlg : public SfxStyleDialog
+{
+public:
+ ScStyleDlg( Window* pParent,
+ SfxStyleSheetBase& rStyleBase,
+ USHORT nRscId );
+ ~ScStyleDlg();
+
+protected:
+ virtual void PageCreated( USHORT nPageId, SfxTabPage& rTabPage );
+ virtual const SfxItemSet* GetRefreshedSet();
+
+private:
+ USHORT nDlgRsc;
+};
+
+
+#endif // SC_STYLEDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/submenu.hrc b/sc/source/ui/inc/submenu.hrc
new file mode 100644
index 000000000000..1a77b40842f7
--- /dev/null
+++ b/sc/source/ui/inc/submenu.hrc
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// IDs fuer Untermenues
+
+// 1 ist nicht erlaubt ????
+#define SUBMENU_EDIT 2
+#define SUBMENU_FILL 3
+#define SUBMENU_DELBREAK 4
+#define SUBMENU_VIEW 5
+#define SUBMENU_INSERT 6
+#define SUBMENU_INSBREAK 7
+#define SUBMENU_NAME 8
+#define SUBMENU_INSOBJ 9
+#define SUBMENU_DATA 10
+#define SUBMENU_FILTER 11
+#define SUBMENU_OUTLINE 12
+#define SUBMENU_PIVOT 13
+#define SUBMENU_EXTRA 14
+#define SUBMENU_AUDIT 15
+#define SUBMENU_PROTECT 16
+#define SUBMENU_ROW 17
+#define SUBMENU_COL 18
+#define SUBMENU_TAB 19
+#define SUBMENU_MERGE 20
+#define SUBMENU_AREA 21
+#define SUBMENU_MIRROR 22
+#define SUBMENU_OBJARRANGE 23
+#define SUBMENU_ANCHOR 24
+#define SUBMENU_POPARRANGE 25
+#define SUBMENU_OLEARRANGE 26
+#define SUBMENU_MAIL 27
+#define SUBMENU_OPTIONS 28
+#define SUBMENU_TOOLBARS 29
+#define SUBMENU_GRAPHIC 30
+#define SUBMENU_SPELLING 31
+#define SUBMENU_CELLCONT 32
+#define SUBMENU_OBJMIRROR 33
+#define SUBMENU_OBJALIGN 34
+#define SUBMENU_OBJANCHOR 35
+#define SUBMENU_SENDTO 36
+#define SUBMENU_CHANGES 37
+#define SUBMENU_EDIT_TABLE 38
+#define MN_TEMPLATES 39
diff --git a/sc/source/ui/inc/subtdlg.hrc b/sc/source/ui/inc/subtdlg.hrc
new file mode 100644
index 000000000000..9970491e5df3
--- /dev/null
+++ b/sc/source/ui/inc/subtdlg.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+/*
+#define RID_SCDLG_SUBTOTALS 256
+#define RID_SCPAGE_SUBT_GROUP 256
+#define RID_SCPAGE_SUBT_OPTIONS 257
+*/
+
+// TabDialog
+#define BTN_REMOVE 1
+#define PAGE_GROUP1 2
+#define PAGE_GROUP2 3
+#define PAGE_GROUP3 4
+#define PAGE_OPTIONS 5
+
+// Gruppen TabPages
+#define FT_GROUP 10
+#define LB_GROUP 11
+#define FT_COLUMNS 12
+#define WND_COLUMNS 13
+#define LB_FUNCTIONS 14
+#define FT_FUNCTIONS 15
+
+// Optionen TabPage
+#define FL_GROUP 20
+#define BTN_PAGEBREAK 21
+#define BTN_CASE 22
+#define BTN_SORT 23
+
+#define FL_SORT 30
+#define BTN_ASCENDING 31
+#define BTN_DESCENDING 32
+#define BTN_FORMATS 33
+#define BTN_USERDEF 34
+#define LB_USERDEF 35
+
+
diff --git a/sc/source/ui/inc/subtdlg.hxx b/sc/source/ui/inc/subtdlg.hxx
new file mode 100644
index 000000000000..614889066c09
--- /dev/null
+++ b/sc/source/ui/inc/subtdlg.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_SUBTDLG_HXX
+#define SC_SUBTDLG_HXX
+
+#ifndef _SFX_HXX
+#endif
+
+#include <sfx2/tabdlg.hxx>
+
+#include "scui_def.hxx"
+
+//==================================================================
+
+class ScSubTotalDlg : public SfxTabDialog
+{
+public:
+ ScSubTotalDlg( Window* pParent,
+ const SfxItemSet* pArgSet );
+private:
+ PushButton aBtnRemove;
+ DECL_LINK( RemoveHdl, PushButton * );
+};
+
+
+#endif // SC_SUBTDLG_HXX
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx
new file mode 100644
index 000000000000..ec8b6f66a7a7
--- /dev/null
+++ b/sc/source/ui/inc/tabbgcolordlg.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tabbgcolordlg.hxx,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABBGCOLORDLG_HXX
+#define SC_TABBGCOLORDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/imagebtn.hxx>
+#include <svtools/valueset.hxx>
+
+//------------------------------------------------------------------------
+
+class ScTabBgColorDlg : public ModalDialog
+{
+public:
+ ScTabBgColorDlg( Window* pParent,
+ const String& rTitle,
+ const String& rTabBgColorNoColorText,
+ const Color& rDefaultColor,
+ ULONG nHelpId );
+ ~ScTabBgColorDlg();
+
+ void GetSelectedColor( Color& rColor ) const;
+
+private:
+ class ScTabBgColorValueSet : public ValueSet
+ {
+ public:
+ ScTabBgColorValueSet(Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg);
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ private:
+ ScTabBgColorDlg* aTabBgColorDlg;
+ };
+
+ Control aBorderWin;
+ ScTabBgColorValueSet aTabBgColorSet;
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+ Color aTabBgColor;
+ const String aTabBgColorNoColorText;
+ ULONG mnHelpId;
+
+ void FillColorValueSets_Impl();
+
+ DECL_LINK( TabBgColorDblClickHdl_Impl, ValueSet* );
+ DECL_LINK( TabBgColorOKHdl_Impl, OKButton* pBtn );
+};
+
+#endif // SC_TABBGCOLORDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabcont.hxx b/sc/source/ui/inc/tabcont.hxx
new file mode 100644
index 000000000000..18c583f441b3
--- /dev/null
+++ b/sc/source/ui/inc/tabcont.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABCONT_HXX
+#define SC_TABCONT_HXX
+
+#include "address.hxx"
+#include <svtools/tabbar.hxx>
+#include <svtools/transfer.hxx>
+
+
+class ScViewData;
+
+// ---------------------------------------------------------------------------
+
+// initial size
+#define SC_TABBAR_DEFWIDTH 270
+
+
+class ScTabControl : public TabBar, public DropTargetHelper, public DragSourceHelper
+{
+private:
+ ScViewData* pViewData;
+ USHORT nMouseClickPageId; /// Last page ID after mouse button down/up
+ USHORT nSelPageIdByMouse; /// Selected page ID, if selected with mouse
+ BOOL bErrorShown;
+
+ void DoDrag( const Region& rRegion );
+
+ USHORT GetMaxId() const;
+ SCTAB GetPrivatDropPos(const Point& rPos );
+
+protected:
+ virtual void Select();
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+
+ virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
+ virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
+
+ virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel );
+
+ virtual long StartRenaming();
+ virtual long AllowRenaming();
+ virtual void EndRenaming();
+ virtual void Mirror();
+
+public:
+ ScTabControl( Window* pParent, ScViewData* pData );
+ ~ScTabControl();
+
+ using TabBar::StartDrag;
+
+ void UpdateInputContext();
+ void UpdateStatus();
+ void ActivateView(BOOL bActivate);
+
+ void SetSheetLayoutRTL( BOOL bSheetRTL );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabopdlg.hrc b/sc/source/ui/inc/tabopdlg.hrc
new file mode 100644
index 000000000000..a2d3b7633cf9
--- /dev/null
+++ b/sc/source/ui/inc/tabopdlg.hrc
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // ->RID_SCDLG_TABOP
+
+#define ED_FORMULARANGE 1
+#define ED_ROWCELL 2
+#define ED_COLCELL 3
+#define FT_FORMULARANGE 1
+#define FT_ROWCELL 2
+#define FT_COLCELL 3
+#define RB_FORMULARANGE 1
+#define RB_ROWCELL 2
+#define RB_COLCELL 3
+#define FL_VARIABLES 1
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 1
+#define STR_NOFORMULA 1
+#define STR_NOCOLROW 2
+#define STR_WRONGFORMULA 3
+#define STR_WRONGROWCOL 4
+#define STR_NOCOLFORMULA 5
+#define STR_NOROWFORMULA 6
+
+
diff --git a/sc/source/ui/inc/tabopdlg.hxx b/sc/source/ui/inc/tabopdlg.hxx
new file mode 100644
index 000000000000..0c8a666f5490
--- /dev/null
+++ b/sc/source/ui/inc/tabopdlg.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABOPDLG_HXX
+#define SC_TABOPDLG_HXX
+
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include "global.hxx"
+#include "address.hxx"
+#include "anyrefdg.hxx"
+
+
+//------------------------------------------------------------------------
+
+enum ScTabOpErr
+{
+ TABOPERR_NOFORMULA = 1,
+ TABOPERR_NOCOLROW,
+ TABOPERR_WRONGFORMULA,
+ TABOPERR_WRONGROW,
+ TABOPERR_NOCOLFORMULA,
+ TABOPERR_WRONGCOL,
+ TABOPERR_NOROWFORMULA
+};
+
+//========================================================================
+
+class ScTabOpDlg : public ScAnyRefDlg
+{
+public:
+ ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ const ScRefAddress& rCursorPos );
+ ~ScTabOpDlg();
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc );
+ virtual BOOL IsRefInputMode() const { return TRUE; }
+ virtual void SetActive();
+
+ virtual BOOL Close();
+
+private:
+ FixedLine aFlVariables;
+ FixedText aFtFormulaRange;
+ formula::RefEdit aEdFormulaRange;
+ formula::RefButton aRBFormulaRange;
+
+ FixedText aFtRowCell;
+ formula::RefEdit aEdRowCell;
+ formula::RefButton aRBRowCell;
+
+ FixedText aFtColCell;
+ formula::RefEdit aEdColCell;
+ formula::RefButton aRBColCell;
+
+ OKButton aBtnOk;
+ CancelButton aBtnCancel;
+ HelpButton aBtnHelp;
+
+ ScRefAddress theFormulaCell;
+ ScRefAddress theFormulaEnd;
+ ScRefAddress theRowCell;
+ ScRefAddress theColCell;
+
+ ScDocument* pDoc;
+ const SCTAB nCurTab;
+ formula::RefEdit* pEdActive;
+ BOOL bDlgLostFocus;
+ const String errMsgNoFormula;
+ const String errMsgNoColRow;
+ const String errMsgWrongFormula;
+ const String errMsgWrongRowCol;
+ const String errMsgNoColFormula;
+ const String errMsgNoRowFormula;
+
+#ifdef _TABOPDLG_CXX
+ void Init();
+ void RaiseError( ScTabOpErr eError );
+
+ DECL_LINK( BtnHdl, PushButton* );
+ DECL_LINK( GetFocusHdl, Control* );
+ DECL_LINK( LoseFocusHdl, Control* );
+#endif // _TABOPDLG_CXX
+};
+
+#endif // SC_TABOPDLG_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabpages.hxx b/sc/source/ui/inc/tabpages.hxx
new file mode 100644
index 000000000000..8075370709dc
--- /dev/null
+++ b/sc/source/ui/inc/tabpages.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABPAGES_HXX
+#define SC_TABPAGES_HXX
+
+#include <vcl/group.hxx>
+#include <svtools/stdctrl.hxx>
+#include <sfx2/tabdlg.hxx>
+
+//========================================================================
+
+class ScTabPageProtection : public SfxTabPage
+{
+public:
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rAttrSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreAttrs );
+ virtual void Reset ( const SfxItemSet& );
+
+protected:
+ using SfxTabPage::DeactivatePage;
+ virtual int DeactivatePage ( SfxItemSet* pSet = NULL );
+
+private:
+ ScTabPageProtection( Window* pParent,
+ const SfxItemSet& rCoreAttrs );
+ ~ScTabPageProtection();
+
+private:
+ FixedLine aFlProtect;
+ TriStateBox aBtnHideCell;
+ TriStateBox aBtnProtect;
+ TriStateBox aBtnHideFormula;
+ FixedInfo aTxtHint;
+
+ FixedLine aFlPrint;
+ TriStateBox aBtnHidePrint;
+ FixedInfo aTxtHint2;
+
+ // aktueller Status:
+ BOOL bTriEnabled; // wenn vorher Dont-Care
+ BOOL bDontCare; // alles auf TriState
+ BOOL bProtect; // einzelne Einstellungen ueber TriState sichern
+ BOOL bHideForm;
+ BOOL bHideCell;
+ BOOL bHidePrint;
+
+ // Handler:
+ DECL_LINK( ButtonClickHdl, TriStateBox* pBox );
+ void UpdateButtons();
+};
+
+
+
+#endif // SC_TABPAGES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabpopsh.hxx b/sc/source/ui/inc/tabpopsh.hxx
new file mode 100644
index 000000000000..241a68d6bfb8
--- /dev/null
+++ b/sc/source/ui/inc/tabpopsh.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABPOPSH_HXX
+#define SC_TABPOPSH_HXX
+
+#include <sfx2/module.hxx>
+#include <sfx2/shell.hxx>
+
+#include "shellids.hxx"
+
+class ScTabPopShell : public SfxShell
+{
+public:
+ TYPEINFO();
+ SFX_DECL_INTERFACE(SCID_TABPOP_SHELL);
+
+ ScTabPopShell(SfxItemPool& rItemPool);
+ ~ScTabPopShell();
+
+ void DummyExec( SfxRequest& rReq );
+ void DummyState( SfxItemSet& rSet );
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabsplit.hxx b/sc/source/ui/inc/tabsplit.hxx
new file mode 100644
index 000000000000..52a5b7559ebe
--- /dev/null
+++ b/sc/source/ui/inc/tabsplit.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABSPLIT_HXX
+#define SC_TABSPLIT_HXX
+
+
+#include <vcl/split.hxx>
+
+class ScViewData;
+
+class ScTabSplitter : public Splitter
+{
+private:
+ ScViewData* pViewData;
+ BOOL bFixed;
+
+protected:
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+ virtual void Splitting( Point& rSplitPos );
+
+public:
+ ScTabSplitter( Window* pParent, WinBits nWinStyle,
+ ScViewData* pData );
+ ~ScTabSplitter();
+
+ void SetFixed(BOOL bSet);
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
new file mode 100644
index 000000000000..e459c93398f0
--- /dev/null
+++ b/sc/source/ui/inc/tabview.hxx
@@ -0,0 +1,529 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_TABVIEW_HXX
+#define SC_TABVIEW_HXX
+
+#include <vcl/scrbar.hxx>
+
+//REMOVE #ifndef SO2_DECL_SVINPLACECLIENT_DEFINED
+//REMOVE #define SO2_DECL_SVINPLACECLIENT_DEFINED
+//REMOVE SO2_DECL_REF(SvInPlaceClient)
+//REMOVE #endif
+
+#include <sfx2/ipclient.hxx>
+
+#include "viewutil.hxx"
+#include "select.hxx"
+
+class ScEditEngineDefaulter;
+class ScGridWindow;
+class ScOutlineWindow;
+class ScRowBar;
+class ScColBar;
+class ScTabControl;
+class ScTabViewShell;
+class SfxPrinter;
+class ScDrawView;
+class SvBorder;
+class FuPoor;
+class Splitter;
+class ScTabSplitter;
+class SdrView;
+class SdrObject;
+class ScHintWindow;
+class ScPageBreakData;
+class ScHighlightRanges;
+struct ChartSelectionInfo;
+class SdrHdlList;
+
+namespace com { namespace sun { namespace star {
+namespace chart2 { namespace data {
+ struct HighlightedRange;
+}}}}}
+
+#define SPLIT_HANDLE_SIZE 3
+#define SC_FORCEMODE_NONE 0xff
+
+// ---------------------------------------------------------------------------
+// Hilfs - Fenster
+
+class ScCornerButton : public Window
+{
+private:
+ ScViewData* pViewData;
+ BOOL bAdd;
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+ virtual void Resize();
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+public:
+ ScCornerButton( Window* pParent, ScViewData* pData, BOOL bAdditional );
+ ~ScCornerButton();
+
+ virtual void StateChanged( StateChangedType nType );
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+};
+
+
+// ---------------------------------------------------------------------------
+
+class ScTabView
+{
+private:
+ Window* pFrameWin; // als erstes !!!
+ ScViewData aViewData; // muss ganz vorne stehen !
+
+ ScViewSelectionEngine* pSelEngine;
+ ScViewFunctionSet aFunctionSet;
+
+ ScHeaderSelectionEngine* pHdrSelEng;
+ ScHeaderFunctionSet aHdrFunc;
+
+ SfxInPlaceClient* pIPClient;
+
+ ScDrawView* pDrawView;
+
+ Size aFrameSize; // wie bei DoResize uebergeben
+ Point aBorderPos;
+
+ BOOL bDrawSelMode; // nur Zeichenobjekte selektieren ?
+
+ FuPoor* pDrawActual;
+ FuPoor* pDrawOld;
+
+ ScGridWindow* pGridWin[4];
+ ScColBar* pColBar[2];
+ ScRowBar* pRowBar[2];
+ ScOutlineWindow* pColOutline[2];
+ ScOutlineWindow* pRowOutline[2];
+ ScTabSplitter* pHSplitter;
+ ScTabSplitter* pVSplitter;
+ ScTabControl* pTabControl;
+ ScrollBar aVScrollTop;
+ ScrollBar aVScrollBottom; // anfangs sichtbar
+ ScrollBar aHScrollLeft; // anfangs sichtbar
+ ScrollBar aHScrollRight;
+ ScCornerButton aCornerButton;
+ ScCornerButton aTopButton;
+ ScrollBarBox aScrollBarBox;
+
+ ScHintWindow* pInputHintWindow; // Eingabemeldung bei Gueltigkeit
+
+ ScPageBreakData* pPageBreakData; // fuer Seitenumbruch-Modus
+ ScHighlightRanges* pHighlightRanges;
+
+ ScDocument* pBrushDocument; // cell formats for format paint brush
+ SfxItemSet* pDrawBrushSet; // drawing object attributes for paint brush
+ BOOL bLockPaintBrush; // keep for more than one use?
+
+ Timer aScrollTimer;
+ ScGridWindow* pTimerWindow;
+ MouseEvent aTimerMEvt;
+
+ ULONG nTipVisible;
+
+ BOOL bDragging; // fuer Scrollbars
+ long nPrevDragPos;
+
+ BOOL bIsBlockMode; // Block markieren
+ BOOL bBlockNeg; // wird Markierung aufgehoben?
+ BOOL bBlockCols; // werden ganze Spalten markiert?
+ BOOL bBlockRows; // werden ganze Zeilen markiert?
+
+ SCCOL nBlockStartX;
+ SCCOL nBlockStartXOrig;
+ SCCOL nBlockEndX;
+
+ SCROW nBlockStartY;
+ SCROW nBlockStartYOrig;
+ SCROW nBlockEndY;
+
+ SCTAB nBlockStartZ;
+ SCTAB nBlockEndZ;
+
+ SCCOL nOldCurX;
+ SCROW nOldCurY;
+
+ double mfPendingTabBarWidth; // Tab bar width relative to frame window width.
+
+ BOOL bMinimized;
+ BOOL bInUpdateHeader;
+ BOOL bInActivatePart;
+ BOOL bInZoomUpdate;
+ BOOL bMoveIsShift;
+
+ void Init();
+
+ void DoAddWin( ScGridWindow* pWin );
+
+ void InitScrollBar( ScrollBar& rScrollBar, long nMaxVal );
+ DECL_LINK( ScrollHdl, ScrollBar* );
+ DECL_LINK( EndScrollHdl, ScrollBar* );
+
+ DECL_LINK( SplitHdl, Splitter* );
+ void DoHSplit(long nSplitPos);
+ void DoVSplit(long nSplitPos);
+
+ DECL_LINK( TimerHdl, Timer* );
+
+ void UpdateVarZoom();
+
+ static void SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, BOOL bLayoutRTL );
+ static long GetScrollBarPos( ScrollBar& rScroll, BOOL bLayoutRTL );
+
+ void GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY);
+ void GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode);
+
+ void SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX);
+ void SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY);
+
+protected:
+ void UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
+ const SCROW* pPosY = NULL );
+
+ void HideTip();
+ void ShowRefTip();
+
+ void ZoomChanged();
+ void UpdateShow();
+ void UpdateVisibleRange();
+ void GetBorderSize( SvBorder& rBorder, const Size& rSize );
+
+ void ResetDrawDragMode();
+ BOOL IsDrawTextEdit() const;
+ void DrawEnableAnim(BOOL bSet);
+ //HMHvoid DrawShowMarkHdl(BOOL bShow);
+
+ void MakeDrawView( BYTE nForceDesignMode = SC_FORCEMODE_NONE );
+
+ void HideNoteMarker();
+
+ void UpdateIMap( SdrObject* pObj );
+
+public:
+ ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
+ ~ScTabView();
+
+ void MakeDrawLayer();
+
+ void HideListBox();
+
+ BOOL HasHintWindow() const { return pInputHintWindow != NULL; }
+ void RemoveHintWindow();
+ void TestHintWindow();
+
+
+ DECL_LINK( TabBarResize, void* );
+ /** Sets an absolute tab bar width (in pixels). */
+ void SetTabBarWidth( long nNewWidth );
+ /** Sets a relative tab bar width.
+ @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */
+ void SetRelTabBarWidth( double fRelTabBarWidth );
+ /** Sets a relative tab bar width. Tab bar is resized again in next DoResize().
+ @param fRelTabBarWidth Tab bar width relative to frame window width (0.0 ... 1.0). */
+ void SetPendingRelTabBarWidth( double fRelTabBarWidth );
+ /** Returns the current tab bar width in pixels. */
+ long GetTabBarWidth() const;
+ /** Returns the current tab bar width relative to the frame window width (0.0 ... 1.0). */
+ double GetRelTabBarWidth() const;
+ /** Returns the pending tab bar width relative to the frame window width (0.0 ... 1.0). */
+ double GetPendingRelTabBarWidth() const;
+
+ void DoResize( const Point& rOffset, const Size& rSize, BOOL bInner = FALSE );
+ void RepeatResize( BOOL bUpdateFix = TRUE );
+ void UpdateFixPos();
+ Point GetGridOffset() const;
+
+ BOOL IsDrawSelMode() const { return bDrawSelMode; }
+ void SetDrawSelMode(BOOL bNew) { bDrawSelMode = bNew; }
+
+ void SetDrawFuncPtr(FuPoor* pFuncPtr) { pDrawActual = pFuncPtr; }
+ void SetDrawFuncOldPtr(FuPoor* pFuncPtr) { pDrawOld = pFuncPtr; }
+ FuPoor* GetDrawFuncPtr() { return pDrawActual; }
+ FuPoor* GetDrawFuncOldPtr() { return pDrawOld; }
+
+ void DrawDeselectAll();
+ void DrawMarkListHasChanged();
+ void UpdateAnchorHandles();
+
+ ScPageBreakData* GetPageBreakData() { return pPageBreakData; }
+ ScHighlightRanges* GetHighlightRanges() { return pHighlightRanges; }
+
+ void UpdatePageBreakData( BOOL bForcePaint = FALSE );
+
+ void DrawMarkRect( const Rectangle& rRect );
+
+ ScViewData* GetViewData() { return &aViewData; }
+ const ScViewData* GetViewData() const { return &aViewData; }
+
+ ScViewFunctionSet* GetFunctionSet() { return &aFunctionSet; }
+ ScViewSelectionEngine* GetSelEngine() { return pSelEngine; }
+
+ BOOL SelMouseButtonDown( const MouseEvent& rMEvt );
+
+ ScDrawView* GetScDrawView() { return pDrawView; }
+ SdrView* GetSdrView(); // gegen CLOKs
+
+ BOOL IsMinimized() const { return bMinimized; }
+
+ void TabChanged();
+ void SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll );
+ SC_DLLPUBLIC void RefreshZoom();
+ void SetPagebreakMode( BOOL bSet );
+
+ void UpdateLayerLocks();
+
+ void UpdateDrawTextOutliner();
+ void DigitLanguageChanged();
+
+ void UpdateInputLine();
+
+ void InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eType,
+ BOOL bPaint = TRUE );
+ void DoneRefMode( BOOL bContinue = FALSE );
+ void UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ );
+ void StopRefMode();
+
+ void StopMarking();
+ void FakeButtonUp( ScSplitPos eWhich );
+
+ Window* GetActiveWin();
+ Window* GetWindowByPos( ScSplitPos ePos );
+
+ ScSplitPos FindWindow( Window* pWindow ) const;
+
+ void SetActivePointer( const Pointer& rPointer );
+
+ void ActiveGrabFocus();
+
+ void ClickCursor( SCCOL nPosX, SCROW nPosY, BOOL bControl );
+
+ SC_DLLPUBLIC void SetCursor( SCCOL nPosX, SCROW nPosY, BOOL bNew = FALSE );
+
+ SC_DLLPUBLIC void CellContentChanged();
+ void SelectionChanged();
+ void CursorPosChanged();
+ void UpdateInputContext();
+
+ void CheckSelectionTransfer();
+
+ void InvertHorizontal( ScVSplitPos eWhich, long nDragPos );
+ void InvertVertical( ScHSplitPos eWhich, long nDragPos );
+
+ Point GetInsertPos();
+
+ Point GetChartInsertPos( const Size& rSize, const ScRange& rCellRange );
+ Point GetChartDialogPos( const Size& rDialogSize, const Rectangle& rLogicChart );
+
+ void UpdateAutoFillMark();
+
+ void HideCursor(); // nur aktiver Teil
+ void ShowCursor();
+ void HideAllCursors();
+ void ShowAllCursors();
+
+ void AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
+ const ScSplitPos* pWhich = NULL );
+
+ SvxZoomType GetZoomType() const;
+ void SetZoomType( SvxZoomType eNew, BOOL bAll );
+ USHORT CalcZoom( SvxZoomType eType, USHORT nOldZoom );
+
+// void CalcZoom( SvxZoomType eType, USHORT& rZoom, SCCOL& rCol, SCROW& rRow );
+
+ sal_Bool HasPageFieldDataAtCursor() const;
+ void StartDataSelect();
+
+ // MoveCursorAbs - absolut
+ // MoveCursorRel - einzelne Zellen
+ // MoveCursorPage - Bildschirmseite
+ // MoveCursorArea - Datenblock
+ // MoveCursorEnd - links oben / benutzter Bereich
+
+ SC_DLLPUBLIC void MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
+ BOOL bShift, BOOL bControl,
+ BOOL bKeepOld = FALSE, BOOL bKeepSel = FALSE );
+ void MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ BOOL bShift, BOOL bKeepSel = FALSE );
+ void MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ BOOL bShift, BOOL bKeepSel = FALSE );
+ void MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ BOOL bShift, BOOL bKeepSel = FALSE );
+ void MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ BOOL bShift, BOOL bKeepSel = FALSE );
+ void MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift );
+
+ void MoveCursorEnter( BOOL bShift ); // Shift fuer Richtung (kein Markieren)
+
+ BOOL MoveCursorKeyInput( const KeyEvent& rKeyEvent );
+
+ void FindNextUnprot( BOOL bShift, BOOL bInSelection = TRUE );
+
+ SC_DLLPUBLIC void SetTabNo( SCTAB nTab, BOOL bNew = FALSE, BOOL bExtendSelection = FALSE );
+ void SelectNextTab( short nDir, BOOL bExtendSelection = FALSE );
+
+ void ActivateView( BOOL bActivate, BOOL bFirst );
+ void ActivatePart( ScSplitPos eWhich );
+ BOOL IsInActivatePart() const { return bInActivatePart; }
+
+ void SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt );
+ void ResetTimer();
+
+ void ScrollX( long nDeltaX, ScHSplitPos eWhich, BOOL bUpdBars = TRUE );
+ void ScrollY( long nDeltaY, ScVSplitPos eWhich, BOOL bUpdBars = TRUE );
+ SC_DLLPUBLIC void ScrollLines( long nDeltaX, long nDeltaY ); // aktives
+
+ BOOL ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos );
+
+ void ScrollToObject( SdrObject* pDrawObj );
+ void MakeVisible( const Rectangle& rHMMRect );
+
+ // Zeichnen
+
+ void InvertBlockMark(SCCOL nBlockStartX, SCROW nBlockStartY,
+ SCCOL nBlockEndX, SCROW nBlockEndY);
+
+ void PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ ScUpdateMode eMode = SC_UPDATE_ALL );
+
+ void PaintGrid();
+
+ void PaintTopArea( SCCOL nStartCol, SCCOL nEndCol );
+ void PaintTop();
+
+ void PaintLeftArea( SCROW nStartRow, SCROW nEndRow );
+ void PaintLeft();
+
+ BOOL PaintExtras();
+
+ void RecalcPPT();
+
+ void CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress);
+
+ void UpdateCopySourceOverlay();
+ void UpdateSelectionOverlay();
+ void UpdateShrinkOverlay();
+ void UpdateAllOverlays();
+
+ void UpdateFormulas();
+ void InterpretVisible();
+ void CheckNeedsRepaint();
+
+ void PaintRangeFinder( long nNumber = -1 );
+ void AddHighlightRange( const ScRange& rRange, const Color& rColor );
+ void ClearHighlightRanges();
+
+ void DoChartSelection( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::chart2::data::HighlightedRange > & rHilightRanges );
+
+ long GetGridWidth( ScHSplitPos eWhich );
+ long GetGridHeight( ScVSplitPos eWhich );
+
+ void UpdateScrollBars();
+ void SetNewVisArea();
+
+ void InvalidateAttribs();
+
+ void MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow );
+ void KillEditView( BOOL bNoPaint );
+ void UpdateEditView();
+
+
+ // Bloecke
+
+ void SelectAll( BOOL bContinue = FALSE );
+ void SelectAllTables();
+ void DeselectAllTables();
+
+ void MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
+ BOOL bCols = FALSE, BOOL bRows = FALSE, BOOL bCellSelection = FALSE );
+ void InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
+ BOOL bTestNeg = FALSE,
+ BOOL bCols = FALSE, BOOL bRows = FALSE );
+ void InitOwnBlockMode();
+ void DoneBlockMode( BOOL bContinue = FALSE );
+
+ BOOL IsBlockMode() const { return bIsBlockMode; }
+
+ void ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode);
+ void ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY);
+ void ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY);
+
+ void MarkColumns();
+ void MarkRows();
+ void MarkDataArea( BOOL bIncludeCursor = TRUE );
+ void MarkMatrixFormula();
+ void Unmark();
+
+ void MarkRange( const ScRange& rRange, BOOL bSetCursor = TRUE, BOOL bContinue = FALSE );
+
+ BOOL IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
+
+ void PaintMarks( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
+ void PaintBlock( BOOL bReset = FALSE );
+
+ void SetMarkData( const ScMarkData& rNew );
+ void MarkDataChanged();
+
+ void LockModifiers( USHORT nModifiers );
+ USHORT GetLockedModifiers() const;
+ void ViewOptionsHasChanged( BOOL bHScrollChanged,
+ BOOL bGraphicsChanged = FALSE);
+
+ Point GetMousePosPixel();
+
+ void SnapSplitPos( Point& rScreenPosPixel );
+ void FreezeSplitters( BOOL bFreeze );
+ void RemoveSplit();
+ void SplitAtCursor();
+ void SplitAtPixel( const Point& rPixel, BOOL bHor, BOOL bVer );
+ void InvalidateSplit();
+
+ void ErrorMessage( USHORT nGlobStrId );
+ Window* GetParentOrChild( USHORT nChildId );
+
+ void EnableRefInput(BOOL bFlag=TRUE);
+
+ Window* GetFrameWin() const { return pFrameWin; }
+
+ BOOL HasPaintBrush() const { return pBrushDocument || pDrawBrushSet; }
+ ScDocument* GetBrushDocument() const { return pBrushDocument; }
+ SfxItemSet* GetDrawBrushSet() const { return pDrawBrushSet; }
+ BOOL IsPaintBrushLocked() const { return bLockPaintBrush; }
+ void SetBrushDocument( ScDocument* pNew, BOOL bLock );
+ void SetDrawBrushSet( SfxItemSet* pNew, BOOL bLock );
+ void ResetBrushDocument();
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
new file mode 100644
index 000000000000..1834959121c6
--- /dev/null
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -0,0 +1,431 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TABVWSH_HXX
+#define SC_TABVWSH_HXX
+
+#include <svtools/htmlcfg.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/viewfac.hxx>
+#include <editeng/svxenum.hxx>
+#include "scdllapi.h"
+#include "dbfunc.hxx" // -> tabview
+#include "target.hxx"
+#include "rangelst.hxx" // ScRangeListRef
+#include "shellids.hxx"
+#include "tabprotection.hxx" // for ScPasswordHash
+
+class FmFormShell;
+class SbxObject;
+class SdrOle2Obj;
+class SfxBindings;
+class SfxChildWindow;
+class SfxModelessDialog;
+class SvxBorderLine;
+class SvxBoxObjectRef;
+class SvxNumberInfoItem;
+struct SfxChildWinInfo;
+
+class ScArea;
+class ScAuditingShell;
+class ScDrawShell;
+class ScDrawTextObjectBar;
+class ScEditShell;
+class ScInputHandler;
+class ScPivotShell;
+class ScDrawFormShell;
+class ScCellShell;
+class ScOleObjectShell;
+class ScGraphicShell;
+class ScMediaShell;
+class ScChartShell;
+class ScPageBreakShell;
+class ScDPObject;
+class ScNavigatorSettings;
+
+struct ScHeaderFieldData;
+
+namespace com { namespace sun { namespace star { namespace frame {
+ class XDispatchProviderInterceptor;
+} } } }
+
+namespace svx {
+ class ExtrusionBar;
+ class FontworkBar;
+}
+
+enum ObjectSelectionType
+{
+ OST_NONE,
+ OST_Cell,
+ OST_Editing,
+ OST_DrawText,
+ OST_Drawing,
+ OST_DrawForm,
+ OST_Pivot,
+ OST_Auditing,
+ OST_OleObject,
+ OST_Chart,
+ OST_Graphic,
+ OST_Media
+};
+
+//==================================================================
+
+
+class ScTabViewShell: public SfxViewShell, public ScDBFunc
+{
+private:
+ static USHORT nInsertCtrlState;
+ static USHORT nInsCellsCtrlState;
+ static USHORT nInsObjCtrlState;
+
+ SvxHtmlOptions aHTMLOpt;
+ ObjectSelectionType eCurOST;
+ USHORT nDrawSfxId;
+ USHORT nCtrlSfxId;
+ USHORT nFormSfxId;
+ String sDrawCustom; // current custom shape type
+ ScDrawShell* pDrawShell;
+ ScDrawTextObjectBar* pDrawTextShell;
+ ScEditShell* pEditShell;
+ ScPivotShell* pPivotShell;
+ ScAuditingShell* pAuditingShell;
+ ScDrawFormShell* pDrawFormShell;
+ ScCellShell* pCellShell;
+ ScOleObjectShell* pOleObjectShell;
+ ScChartShell* pChartShell;
+ ScGraphicShell* pGraphicShell;
+ ScMediaShell* pMediaShell;
+ ScPageBreakShell* pPageBreakShell;
+ svx::ExtrusionBar* pExtrusionBarShell;
+ svx::FontworkBar* pFontworkBarShell;
+
+ FmFormShell* pFormShell;
+
+ ScInputHandler* pInputHandler; // fuer OLE-Eingabezeile
+
+ SvxBorderLine* pCurFrameLine;
+
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::frame::XDispatchProviderInterceptor >
+ xDisProvInterceptor;
+
+ Point aWinPos;
+
+ ScTabViewTarget aTarget;
+ ScArea* pPivotSource;
+ ScDPObject* pDialogDPObject;
+
+ ScNavigatorSettings* pNavSettings;
+
+ // used in first Activate
+ BOOL bFirstActivate;
+
+ BOOL bActiveDrawSh;
+ BOOL bActiveDrawTextSh;
+ BOOL bActivePivotSh;
+ BOOL bActiveAuditingSh;
+ BOOL bActiveDrawFormSh;
+ BOOL bActiveOleObjectSh;
+ BOOL bActiveChartSh;
+ BOOL bActiveGraphicSh;
+ BOOL bActiveMediaSh;
+ BOOL bActiveEditSh;
+
+ BOOL bFormShellAtTop; // does the FormShell need to be on top?
+
+
+ BOOL bDontSwitch; // EditShell nicht abschalten
+ BOOL bInFormatDialog; // fuer GetSelectionText
+ BOOL bPrintSelected; // for result of SvxPrtQryBox
+
+ BOOL bReadOnly; // um Status-Aenderungen zu erkennen
+
+ SbxObject* pScSbxObject;
+
+ BOOL bChartAreaValid; // wenn Chart aufgezogen wird
+ String aEditChartName;
+ ScRangeListRef aChartSource;
+ Rectangle aChartPos;
+ SCTAB nChartDestTab;
+ USHORT nCurRefDlgId;
+
+ SfxBroadcaster* pAccessibilityBroadcaster;
+
+ static const int MASTERENUMCOMMANDS = 6;
+ String aCurrShapeEnumCommand[ MASTERENUMCOMMANDS ];
+
+private:
+ void Construct( BYTE nForceDesignMode = SC_FORCEMODE_NONE );
+
+ SfxShell* GetMySubShell() const;
+
+ void DoReadUserData( const String& rData );
+ void DoReadUserDataSequence( const ::com::sun::star::uno::Sequence<
+ ::com::sun::star::beans::PropertyValue >& rSettings );
+
+ DECL_LINK( SimpleRefClose, String* );
+ DECL_LINK( SimpleRefDone, String* );
+ DECL_LINK( SimpleRefAborted, String* );
+ DECL_LINK( SimpleRefChange, String* );
+ DECL_LINK( FormControlActivated, FmFormShell* );
+ DECL_LINK( HtmlOptionsHdl, void * );
+
+protected:
+ virtual void Activate(BOOL bMDI);
+ virtual void Deactivate(BOOL bMDI);
+ virtual USHORT PrepareClose( BOOL bUI = TRUE, BOOL bForBrowsing = FALSE );
+
+ virtual void ShowCursor(bool bOn);
+
+ virtual void Move(); // Benachrichtigung
+
+ virtual void AdjustPosSizePixel( const Point &rPos, const Size &rSize ); // alt
+
+ virtual void InnerResizePixel( const Point &rOfs, const Size &rSize ); // neu
+ virtual void OuterResizePixel( const Point &rOfs, const Size &rSize );
+ virtual void SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY );
+
+ virtual void QueryObjAreaPixel( Rectangle& rRect ) const;
+
+ virtual Size GetOptimalSizePixel() const;
+
+ virtual String GetSelectionText( BOOL bWholeWord );
+ virtual BOOL HasSelection( BOOL bText ) const;
+ virtual String GetDescription() const;
+
+ virtual void WriteUserData(String &, BOOL bBrowse = FALSE);
+ virtual void ReadUserData(const String &, BOOL bBrowse = FALSE);
+ virtual void WriteUserDataSequence (::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
+ virtual void ReadUserDataSequence (const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse = sal_False );
+
+ virtual void UIDeactivated( SfxInPlaceClient* pClient );
+
+ virtual bool KeyInput( const KeyEvent &rKeyEvent );
+ virtual SdrView* GetDrawView() const;
+
+public:
+ TYPEINFO_VISIBILITY(SC_DLLPUBLIC);
+
+ SFX_DECL_INTERFACE(SCID_TABVIEW_SHELL)
+ SFX_DECL_VIEWFACTORY(ScTabViewShell);
+
+
+ // -> Clone-Methode fuer Factory
+
+ // aus einer allgemeinen Shell konstruieren und
+ // soviel wie moeglich uebernehmen (SliderPos etc.):
+
+ ScTabViewShell( SfxViewFrame* pViewFrame,
+ SfxViewShell* pOldSh );
+
+ virtual ~ScTabViewShell();
+
+ SC_DLLPUBLIC Window* GetDialogParent();
+
+ bool IsRefInputMode() const;
+ void ExecuteInputDirect();
+
+ ScInputHandler* GetInputHandler() const;
+ void UpdateInputHandler( BOOL bForce = FALSE, BOOL bStopEditing = TRUE );
+ void UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust );
+ BOOL TabKeyInput(const KeyEvent& rKEvt);
+ BOOL SfxKeyInput(const KeyEvent& rKEvt);
+
+ void SetActive();
+
+ SvxBorderLine* GetDefaultFrameLine() const { return pCurFrameLine; }
+ void SetDefaultFrameLine(const SvxBorderLine* pLine );
+
+ SC_DLLPUBLIC void Execute( SfxRequest& rReq );
+ SC_DLLPUBLIC void GetState( SfxItemSet& rSet );
+
+ void ExecuteTable( SfxRequest& rReq );
+ void GetStateTable( SfxItemSet& rSet );
+
+ void WindowChanged();
+ void ExecDraw(SfxRequest&);
+ void ExecDrawIns(SfxRequest& rReq);
+ void GetDrawState(SfxItemSet &rSet);
+ void GetDrawInsState(SfxItemSet &rSet);
+ void ExecGallery(SfxRequest& rReq); // StarGallery
+ void GetGalleryState(SfxItemSet& rSet);
+
+ void ExecChildWin(SfxRequest& rReq);
+ void GetChildWinState( SfxItemSet& rSet );
+
+ void ExecImageMap( SfxRequest& rReq );
+ void GetImageMapState( SfxItemSet& rSet );
+
+ void ExecTbx( SfxRequest& rReq );
+ void GetTbxState( SfxItemSet& rSet );
+
+ void ExecuteSave( SfxRequest& rReq );
+ void GetSaveState( SfxItemSet& rSet );
+ void ExecSearch( SfxRequest& rReq );
+
+ SC_DLLPUBLIC void ExecuteUndo(SfxRequest& rReq);
+ void GetUndoState(SfxItemSet &rSet);
+
+ void ExecuteSbx( SfxRequest& rReq );
+ void GetSbxState( SfxItemSet& rSet );
+
+ void ExecuteObject(SfxRequest& rReq);
+ void GetObjectState(SfxItemSet &rSet);
+
+ void ExecDrawOpt(SfxRequest& rReq);
+ void GetDrawOptState(SfxItemSet &rSet);
+
+
+ void SetDrawShell( BOOL bActive );
+ void SetDrawTextShell( BOOL bActive );
+
+ void SetPivotShell( BOOL bActive );
+ ScArea* GetPivotSource(){return pPivotSource;}
+ void SetPivotSource(ScArea* pSrc){pPivotSource=pSrc;}
+ void SetDialogDPObject( const ScDPObject* pObj );
+ const ScDPObject* GetDialogDPObject() const { return pDialogDPObject; }
+
+ BOOL GetDontSwitch(){return bDontSwitch;}
+ void SetDontSwitch(BOOL bFlag){bDontSwitch=bFlag;}
+
+
+ void SetAuditShell( BOOL bActive );
+ void SetDrawFormShell( BOOL bActive );
+ void SetEditShell(EditView* pView, BOOL bActive );
+ void SetOleObjectShell( BOOL bActive );
+ void SetChartShell( BOOL bActive );
+ void SetGraphicShell( BOOL bActive );
+ void SetMediaShell( BOOL bActive );
+
+
+ void SetDrawShellOrSub();
+ void SetCurSubShell( ObjectSelectionType eOST, BOOL bForce = FALSE );
+
+ void SetFormShellAtTop( BOOL bSet );
+
+ ObjectSelectionType GetCurObjectSelectionType();
+
+ virtual ErrCode DoVerb(long nVerb);
+
+
+ void StopEditShell();
+ BOOL IsDrawTextShell() const;
+ BOOL IsAuditShell() const;
+
+ void SetDrawTextUndo( SfxUndoManager* pUndoMgr );
+
+ void FillFieldData( ScHeaderFieldData& rData );
+
+ void SetChartArea( const ScRangeListRef& rSource, const Rectangle& rDest );
+ BOOL GetChartArea( ScRangeListRef& rSource, Rectangle& rDest, SCTAB& rTab ) const;
+
+ void SetEditChartName(const String& aStr){aEditChartName=aStr;}
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
+ ScNavigatorSettings* GetNavigatorSettings();
+
+ // Drucken:
+ virtual SfxPrinter* GetPrinter( BOOL bCreate = FALSE );
+ virtual USHORT SetPrinter( SfxPrinter* pNewPrinter,
+ USHORT nDiffFlags = SFX_PRINTER_ALL, bool bIsApi=false );
+
+ virtual PrintDialog* CreatePrintDialog( Window* pParent );
+ virtual SfxTabPage* CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions );
+ virtual void PreparePrint( PrintDialog* pPrintDialog = NULL );
+ virtual ErrCode DoPrint( SfxPrinter *pPrinter,
+ PrintDialog *pPrintDialog,
+ BOOL bSilent, BOOL bIsAPI );
+ virtual USHORT Print( SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pPrintDialog = NULL );
+
+ void ConnectObject( SdrOle2Obj* pObj );
+ BOOL ActivateObject( SdrOle2Obj* pObj, long nVerb );
+
+ void DeactivateOle();
+
+ SC_DLLPUBLIC static ScTabViewShell* GetActiveViewShell();
+ SfxModelessDialog* CreateRefDialog( SfxBindings* pB, SfxChildWindow* pCW,
+ SfxChildWinInfo* pInfo,
+ Window* pParent, USHORT nSlotId );
+
+ void UpdateOleZoom();
+ inline SbxObject* GetScSbxObject() const
+ { return pScSbxObject; }
+ inline void SetScSbxObject( SbxObject* pOb )
+ { pScSbxObject = pOb; }
+
+ FmFormShell* GetFormShell() const { return pFormShell; }
+
+ void InsertURL( const String& rName, const String& rURL, const String& rTarget,
+ USHORT nMode );
+ void InsertURLButton( const String& rName, const String& rURL, const String& rTarget,
+ const Point* pInsPos = NULL );
+ void InsertURLField( const String& rName, const String& rURL, const String& rTarget );
+
+ BOOL SelectObject( const String& rName );
+
+ void SetInFormatDialog(BOOL bFlag) {bInFormatDialog=bFlag;}
+ BOOL IsInFormatDialog() {return bInFormatDialog;}
+
+ void ForceMove() { Move(); }
+
+ void MakeNumberInfoItem ( ScDocument* pDoc,
+ ScViewData* pViewData,
+ SvxNumberInfoItem** ppItem );
+
+ void UpdateNumberFormatter ( ScDocument* pDoc,
+ const SvxNumberInfoItem& rInfoItem );
+
+ void ExecuteCellFormatDlg ( SfxRequest& rReq, USHORT nTabPage = 0xffff );
+
+ BOOL GetFunction( String& rFuncStr, sal_uInt16 nErrCode = 0 );
+
+ void StartSimpleRefDialog( const String& rTitle, const String& rInitVal,
+ BOOL bCloseOnButtonUp, BOOL bSingleCell, BOOL bMultiSelection );
+ void StopSimpleRefDialog();
+
+ void SetCurRefDlgId( USHORT nNew );
+
+ void AddAccessibilityObject( SfxListener& rObject );
+ void RemoveAccessibilityObject( SfxListener& rObject );
+ void BroadcastAccessibility( const SfxHint &rHint );
+ BOOL HasAccessibilityObjects();
+
+ bool ExecuteRetypePassDlg(ScPasswordHash eDesiredHash);
+
+ using ScTabView::ShowCursor;
+};
+
+//==================================================================
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/target.hxx b/sc/source/ui/inc/target.hxx
new file mode 100644
index 000000000000..0c0fa423a4e9
--- /dev/null
+++ b/sc/source/ui/inc/target.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TARGET_HXX
+#define SC_TARGET_HXX
+
+#include <svl/undo.hxx>
+
+class ScTabViewShell;
+
+class ScTabViewTarget : public SfxRepeatTarget
+{
+private:
+ ScTabViewShell* pViewShell;
+
+public:
+ TYPEINFO();
+
+ ScTabViewTarget( ScTabViewShell* pShell ) : pViewShell( pShell ) {}
+ virtual ~ScTabViewTarget();
+
+ ScTabViewShell* GetViewShell() const { return pViewShell; }
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tbinsert.hrc b/sc/source/ui/inc/tbinsert.hrc
new file mode 100644
index 000000000000..b80e6fb5863b
--- /dev/null
+++ b/sc/source/ui/inc/tbinsert.hrc
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#define RID_TOOLBOX_INSERT 1
+#define RID_TOOLBOX_INSCELLS 2
+#define RID_TOOLBOX_INSOBJ 3
+
+
diff --git a/sc/source/ui/inc/tbinsert.hxx b/sc/source/ui/inc/tbinsert.hxx
new file mode 100644
index 000000000000..0a0ec8296719
--- /dev/null
+++ b/sc/source/ui/inc/tbinsert.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TBINSERT_HXX
+#define SC_TBINSERT_HXX
+
+#include <sfx2/tbxctrl.hxx>
+
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
+
+class ScTbxInsertCtrl : public SfxToolBoxControl
+{
+ USHORT nLastSlotId;
+
+ using SfxToolBoxControl::Select;
+ virtual void Select( BOOL bMod1 = FALSE );
+
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+
+ ScTbxInsertCtrl( USHORT nSlotId, USHORT nId, ToolBox& rBox );
+ ~ScTbxInsertCtrl();
+
+ virtual SfxPopupWindowType GetPopupWindowType() const;
+ virtual SfxPopupWindow* CreatePopupWindow();
+ virtual void StateChanged( USHORT nSID,
+ SfxItemState eState,
+ const SfxPoolItem* pState );
+};
+
+//----------------------------------------------------------------------------
+//
+//----------------------------------------------------------------------------
+/*
+class ScTbxInsertPopup : public SfxPopupWindow
+{
+ SfxToolBoxManager aTbx;
+ ResId aRIdWinTemp;
+ ResId aRIdTbxTemp;
+
+ Link aTbxClickHdl;
+
+ DECL_LINK( TbxSelectHdl, ToolBox* );
+ DECL_LINK( TbxClickHdl, ToolBox* );
+
+protected:
+ virtual void PopupModeEnd();
+
+public:
+ ScTbxInsertPopup( USHORT nId, WindowAlign eAlign,
+ const ResId& rRIdWin, const ResId& rRIdTbx,
+ SfxBindings& rBindings );
+ ~ScTbxInsertPopup();
+
+ virtual SfxPopupWindow* Clone() const;
+ void StartSelection();
+};
+*/
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tbzoomsliderctrl.hxx b/sc/source/ui/inc/tbzoomsliderctrl.hxx
new file mode 100644
index 000000000000..af7572b997f4
--- /dev/null
+++ b/sc/source/ui/inc/tbzoomsliderctrl.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+#ifndef _SC_ZOOMSLIDERTBCONTRL_HXX
+#define _SC_ZOOMSLIDERTBCONTRL_HXX
+
+#include <vcl/window.hxx>
+#include <svl/poolitem.hxx>
+#include <sfx2/tbxctrl.hxx>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <svx/zoomslideritem.hxx>
+
+
+//class ScZoomSliderControl define
+class ScZoomSliderControl: public SfxToolBoxControl
+{
+public:
+ SFX_DECL_TOOLBOX_CONTROL();
+ ScZoomSliderControl( USHORT nSlotId, USHORT nId, ToolBox& rTbx );
+ ~ScZoomSliderControl();
+
+ virtual void StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState );
+ virtual Window* CreateItemWindow( Window *pParent );
+};
+
+//========================================================================
+// class ScZoomSliderWnd define---------------------------------------
+//========================================================================
+class ScZoomSliderWnd: public Window
+{
+private:
+ struct ScZoomSliderWnd_Impl;
+ ScZoomSliderWnd_Impl* mpImpl;
+ Size aLogicalSize;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+
+ USHORT Offset2Zoom( long nOffset ) const;
+ long Zoom2Offset( USHORT nZoom ) const;
+ void DoPaint( const Rectangle& rRect );
+
+public:
+ ScZoomSliderWnd( Window* pParent, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame , USHORT nCurrentZoom );
+ ~ScZoomSliderWnd();
+ void UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem );
+
+protected:
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void Paint( const Rectangle& rRect );
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/textdlgs.hxx b/sc/source/ui/inc/textdlgs.hxx
new file mode 100644
index 000000000000..79e93fa67261
--- /dev/null
+++ b/sc/source/ui/inc/textdlgs.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TEXTDLGS_HXX
+#define SC_TEXTDLGS_HXX
+
+#include <sfx2/tabdlg.hxx>
+
+class SfxObjectShell;
+
+//
+// Zeichen-Tab-Dialog
+//
+
+class ScCharDlg : public SfxTabDialog
+{
+private:
+ const SfxItemSet& rOutAttrs;
+ const SfxObjectShell& rDocShell;
+
+ virtual void PageCreated( USHORT nId, SfxTabPage &rPage );
+
+public:
+ ScCharDlg( Window* pParent, const SfxItemSet* pAttr,
+ const SfxObjectShell* pDocShell );
+ ~ScCharDlg() {}
+};
+
+//
+// Absatz-Tab-Dialog
+//
+
+class ScParagraphDlg : public SfxTabDialog
+{
+private:
+ const SfxItemSet& rOutAttrs;
+
+ virtual void PageCreated( USHORT nId, SfxTabPage &rPage );
+
+public:
+ ScParagraphDlg( Window* pParent, const SfxItemSet* pAttr );
+ ~ScParagraphDlg() {}
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/textimportoptions.hrc b/sc/source/ui/inc/textimportoptions.hrc
new file mode 100644
index 000000000000..eb981c1c4dc7
--- /dev/null
+++ b/sc/source/ui/inc/textimportoptions.hrc
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: retypepassdlg.src,v $
+ * $Revision: 1.1.2.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <sc.hrc>
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
+#define FL_CHOOSE_LANG 4
+#define RB_AUTOMATIC 5
+#define RB_CUSTOM 6
+#define LB_CUSTOM_LANG 7
+#define FL_OPTION 8
+#define BTN_CONVERT_DATE 9
diff --git a/sc/source/ui/inc/textimportoptions.hxx b/sc/source/ui/inc/textimportoptions.hxx
new file mode 100644
index 000000000000..84091358b531
--- /dev/null
+++ b/sc/source/ui/inc/textimportoptions.hxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: langbox.hxx,v $
+ * $Revision: 1.4.242.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UI_IMPORTOPTIONS_HXX
+#define SC_UI_IMPORTOPTIONS_HXX
+
+#include "vcl/dialog.hxx"
+#include "vcl/button.hxx"
+#include "vcl/fixed.hxx"
+#include "i18npool/lang.h"
+#include "svx/langbox.hxx"
+
+class ScTextImportOptionsDlg : public ModalDialog
+{
+public:
+ ScTextImportOptionsDlg(Window* pParent);
+ virtual ~ScTextImportOptionsDlg();
+
+ virtual short Execute();
+
+ LanguageType getLanguageType() const;
+ bool isDateConversionSet() const;
+
+private:
+ void init();
+
+private:
+ OKButton maBtnOk;
+ CancelButton maBtnCancel;
+ HelpButton maBtnHelp;
+
+ FixedLine maFlChooseLang;
+
+ RadioButton maRbAutomatic;
+ RadioButton maRbCustom;
+
+ SvxLanguageBox maLbCustomLang;
+
+ FixedLine maFlOption;
+
+ CheckBox maBtnConvertDate;
+
+ DECL_LINK( OKHdl, OKButton* );
+
+ DECL_LINK( RadioHdl, RadioButton* );
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpcalc.hxx b/sc/source/ui/inc/tpcalc.hxx
new file mode 100644
index 000000000000..796b6fba3913
--- /dev/null
+++ b/sc/source/ui/inc/tpcalc.hxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPCALC_HXX
+#define SC_TPCALC_HXX
+
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+#include <vcl/group.hxx>
+#include <svtools/stdctrl.hxx>
+#include "editfield.hxx"
+
+//===================================================================
+
+class ScDocOptions;
+
+class ScTpCalcOptions : public SfxTabPage
+{
+public:
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreSet );
+ virtual void Reset ( const SfxItemSet& rCoreSet );
+ using SfxTabPage::DeactivatePage;
+ virtual int DeactivatePage ( SfxItemSet* pSet = NULL );
+
+private:
+ ScTpCalcOptions( Window* pParent,
+ const SfxItemSet& rCoreSet );
+ ~ScTpCalcOptions();
+
+private:
+ FixedLine aGbZRefs;
+ CheckBox aBtnIterate;
+ FixedText aFtSteps;
+ NumericField aEdSteps;
+ FixedText aFtEps;
+ ScDoubleField aEdEps;
+
+ FixedLine aSeparatorFL;
+ FixedLine aGbDate;
+ RadioButton aBtnDateStd;
+ RadioButton aBtnDateSc10;
+ RadioButton aBtnDate1904;
+
+ FixedLine aHSeparatorFL;
+ CheckBox aBtnCase;
+ CheckBox aBtnCalc;
+ CheckBox aBtnMatch;
+ CheckBox aBtnRegex;
+ CheckBox aBtnLookUp;
+ CheckBox aBtnGeneralPrec;
+
+ FixedText aFtPrec;
+ NumericField aEdPrec;
+
+ ScDocOptions* pOldOptions;
+ ScDocOptions* pLocalOptions;
+ USHORT nWhichCalc;
+
+#ifdef _TPCALC_CXX
+private:
+ void Init();
+
+ //------------------------------------
+ // Handler:
+ DECL_LINK( RadioClickHdl, RadioButton* );
+ DECL_LINK( CheckClickHdl, CheckBox* );
+
+#endif
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpcompatibility.hxx b/sc/source/ui/inc/tpcompatibility.hxx
new file mode 100644
index 000000000000..b7f25a3d36c7
--- /dev/null
+++ b/sc/source/ui/inc/tpcompatibility.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyrigt 2010 Novell, Inc.
+ *
+ * LibreOffice - a multi-platform office productivity suite
+ *
+ * This file is part of LibreOffice.
+ *
+ * LibreOffice is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * LibreOffice is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with LibreOffice. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __SC_TPCOMPATIBILITY_HXX__
+#define __SC_TPCOMPATIBILITY_HXX__
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <boost/shared_ptr.hpp>
+
+class ScDocOptions;
+
+class ScTpCompatOptions : public SfxTabPage
+{
+public:
+ static SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreAttrs);
+
+ virtual BOOL FillItemSet(SfxItemSet& rCoreAttrs);
+ virtual void Reset(const SfxItemSet& rCoreAttrs);
+ virtual int DeactivatePage(SfxItemSet* pSet = NULL);
+
+private:
+ explicit ScTpCompatOptions(Window* pParent, const SfxItemSet& rCoreAttrs);
+ virtual ~ScTpCompatOptions();
+
+private:
+ FixedLine maFlKeyBindings;
+ FixedText maFtKeyBindings;
+ ListBox maLbKeyBindings;
+
+ ::boost::shared_ptr<ScDocOptions> mpOldOptions;
+ ::boost::shared_ptr<ScDocOptions> mpNewOptions;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
new file mode 100644
index 000000000000..b7553c0dc051
--- /dev/null
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyrigt 2010 Novell, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tpcalc.hxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPFORMULA_HXX
+#define SC_TPFORMULA_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/button.hxx>
+
+#include <memory>
+
+class ScDocOptions;
+class SfxItemSet;
+class Window;
+
+class ScTpFormulaOptions : public SfxTabPage
+{
+public:
+ static SfxTabPage* Create (Window* pParent, const SfxItemSet& rCoreSet);
+
+// static USHORT* GetRanges();
+ virtual BOOL FillItemSet(SfxItemSet& rCoreSet);
+ virtual void Reset( const SfxItemSet& rCoreSet );
+ virtual int DeactivatePage(SfxItemSet* pSet = NULL);
+
+private:
+ explicit ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreSet);
+ virtual ~ScTpFormulaOptions();
+
+ void Init();
+ void ResetSeparators();
+ void OnFocusSeparatorInput(Edit* pEdit);
+
+ bool IsValidSeparator(const ::rtl::OUString& rSep) const;
+ bool IsValidSeparatorSet() const;
+
+ DECL_LINK( ButtonHdl, PushButton* );
+ DECL_LINK( SepModifyHdl, Edit* );
+ DECL_LINK( SepEditOnFocusHdl, Edit* );
+
+private:
+ FixedLine maFlFormulaOpt;
+ FixedText maFtFormulaSyntax;
+ ListBox maLbFormulaSyntax;
+ CheckBox maCbEnglishFuncName;
+
+ FixedLine maFlFormulaSeps;
+ FixedText maFtSepFuncArg;
+ Edit maEdSepFuncArg;
+ FixedText maFtSepArrayCol;
+ Edit maEdSepArrayCol;
+ FixedText maFtSepArrayRow;
+ Edit maEdSepArrayRow;
+ PushButton maBtnSepReset;
+
+ ::std::auto_ptr<ScDocOptions> mpOldOptions;
+ ::std::auto_ptr<ScDocOptions> mpNewOptions;
+
+ /** Stores old separator value of currently focused separator edit box.
+ This value is used to revert undesired value change. */
+ ::rtl::OUString maOldSepValue;
+
+ sal_Unicode mnDecSep;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tphf.hxx b/sc/source/ui/inc/tphf.hxx
new file mode 100644
index 000000000000..7b1c5419572b
--- /dev/null
+++ b/sc/source/ui/inc/tphf.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPHF_HXX
+#define SC_TPHF_HXX
+
+
+#include <svx/hdft2.hxx>
+
+class ScStyleDlg;
+
+//========================================================================
+
+class ScHFPage : public SvxHFPage
+{
+public:
+ virtual ~ScHFPage();
+
+ virtual void Reset( const SfxItemSet& rSet );
+ virtual BOOL FillItemSet( SfxItemSet& rOutSet );
+
+ void SetPageStyle( const String& rName ) { aStrPageStyle = rName; }
+ void SetStyleDlg ( const ScStyleDlg* pDlg ) { pStyleDlg = pDlg; }
+
+protected:
+ ScHFPage( Window* pParent,
+ USHORT nResId,
+ const SfxItemSet& rSet,
+ USHORT nSetId );
+
+// using SvxHFPage::ActivatePage;
+// using SvxHFPage::DeactivatePage;
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+ virtual void ActivatePage( const SfxItemSet& rSet );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+private:
+ PushButton aBtnEdit;
+ SfxItemSet aDataSet;
+ String aStrPageStyle;
+ USHORT nPageUsage;
+ const ScStyleDlg* pStyleDlg;
+
+#ifdef _TPHF_CXX
+private:
+ DECL_LINK( BtnHdl, PushButton* );
+ DECL_LINK( HFEditHdl, void* );
+ DECL_LINK( TurnOnHdl, CheckBox* );
+#endif
+};
+
+//========================================================================
+
+class ScHeaderPage : public ScHFPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rSet );
+ static USHORT* GetRanges();
+
+private:
+ ScHeaderPage( Window* pParent, const SfxItemSet& rSet );
+};
+
+//========================================================================
+
+class ScFooterPage : public ScHFPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rSet );
+ static USHORT* GetRanges();
+
+private:
+ ScFooterPage( Window* pParent, const SfxItemSet& rSet );
+};
+
+
+#endif // SC_TPHF_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tphfedit.hxx b/sc/source/ui/inc/tphfedit.hxx
new file mode 100644
index 000000000000..00154cfa89f0
--- /dev/null
+++ b/sc/source/ui/inc/tphfedit.hxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPHFEDIT_HXX
+#define SC_TPHFEDIT_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <svx/pageitem.hxx>
+#include <svtools/stdctrl.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/virdev.hxx>
+#include "scdllapi.h"
+#include "scitems.hxx" // wegen enum SvxNumType
+#include "popmenu.hxx"
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include <cppuhelper/weakref.hxx>
+
+//===================================================================
+
+class ScHeaderEditEngine;
+class ScPatternAttr;
+class EditView;
+class EditTextObject;
+class SvxFieldItem;
+class ScAccessibleEditObject;
+class ScEditWindow;
+
+SC_DLLPUBLIC ScEditWindow* GetScEditWindow ();
+
+enum ScEditWindowLocation
+{
+ Left,
+ Center,
+ Right
+};
+
+class SC_DLLPUBLIC ScEditWindow : public Control
+{
+public:
+ ScEditWindow( Window* pParent, const ResId& rResId, ScEditWindowLocation eLoc );
+ ~ScEditWindow();
+
+ using Control::SetFont;
+ void SetFont( const ScPatternAttr& rPattern );
+ using Control::SetText;
+ void SetText( const EditTextObject& rTextObject );
+ EditTextObject* CreateTextObject();
+ void SetCharAttriutes();
+
+ void InsertField( const SvxFieldItem& rFld );
+
+ void SetNumType(SvxNumType eNumType);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
+
+ inline ScHeaderEditEngine* GetEditEngine() const {return pEdEngine;}
+protected:
+ virtual void Paint( const Rectangle& rRec );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void Command( const CommandEvent& rCEvt );
+ virtual void GetFocus();
+ virtual void LoseFocus();
+
+private:
+ ScHeaderEditEngine* pEdEngine;
+ EditView* pEdView;
+ ScEditWindowLocation eLocation;
+ bool mbRTL;
+
+ com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessible > xAcc;
+ ScAccessibleEditObject* pAcc;
+};
+
+//===================================================================
+class SC_DLLPUBLIC ScExtIButton : public ImageButton
+{
+private:
+
+ Timer aTimer;
+ ScPopupMenu* pPopupMenu;
+ Link aMLink;
+ USHORT nSelected;
+
+ SC_DLLPRIVATE DECL_LINK( TimerHdl, Timer*);
+
+protected:
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt);
+ virtual void Click();
+
+ virtual void StartPopup();
+
+public:
+
+ ScExtIButton(Window* pParent, const ResId& rResId );
+
+ void SetPopupMenu(ScPopupMenu* pPopUp);
+
+ USHORT GetSelected();
+
+ void SetMenuHdl( const Link& rLink ) { aMLink = rLink; }
+ const Link& GetMenuHdl() const { return aMLink; }
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+};
+
+#endif // SC_TPHFEDIT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpprint.hxx b/sc/source/ui/inc/tpprint.hxx
new file mode 100644
index 000000000000..2e60d9018be9
--- /dev/null
+++ b/sc/source/ui/inc/tpprint.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPPRINT_HXX
+#define SC_TPPRINT_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+
+//===================================================================
+
+class ScTpPrintOptions : public SfxTabPage
+{
+ FixedLine aPagesFL;
+ CheckBox aSkipEmptyPagesCB;
+ FixedLine aSheetsFL;
+ CheckBox aSelectedSheetsCB;
+
+ ScTpPrintOptions( Window* pParent, const SfxItemSet& rCoreSet );
+ ~ScTpPrintOptions();
+
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges();
+ virtual BOOL FillItemSet( SfxItemSet& rCoreSet );
+ virtual void Reset( const SfxItemSet& rCoreSet );
+ using SfxTabPage::DeactivatePage;
+ virtual int DeactivatePage( SfxItemSet* pSet = NULL );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
new file mode 100644
index 000000000000..fff158322a13
--- /dev/null
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -0,0 +1,225 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPSORT_HXX
+#define SC_TPSORT_HXX
+
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/stdctrl.hxx>
+#include <svx/langbox.hxx>
+
+
+#include "global.hxx"
+#include "address.hxx"
+
+//------------------------------------------------------------------------
+
+// +1 because one field is reserved for the "- undefined -" entry
+#define SC_MAXFIELDS MAXCOLCOUNT+1
+
+class ScViewData;
+class ScSortDlg;
+struct ScSortParam;
+
+//========================================================================
+// Kriterien (Sort Criteria)
+
+class ScTabPageSortFields : public SfxTabPage
+{
+public:
+ ScTabPageSortFields( Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScTabPageSortFields();
+
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rArgSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+
+protected:
+// fuer Datenaustausch (sollte noch umgestellt werden!)
+// virtual void ActivatePage ( const SfxItemSet& rSet );
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+ virtual void ActivatePage ();
+ virtual int DeactivatePage ( SfxItemSet* pSet = 0);
+
+private:
+ FixedLine aFlSort1;
+ ListBox aLbSort1;
+ RadioButton aBtnUp1;
+ RadioButton aBtnDown1;
+
+ FixedLine aFlSort2;
+ ListBox aLbSort2;
+ RadioButton aBtnUp2;
+ RadioButton aBtnDown2;
+
+ FixedLine aFlSort3;
+ ListBox aLbSort3;
+ RadioButton aBtnUp3;
+ RadioButton aBtnDown3;
+
+ String aStrUndefined;
+ String aStrColumn;
+ String aStrRow;
+
+ const USHORT nWhichSort;
+ ScSortDlg* pDlg;
+ ScViewData* pViewData;
+ const ScSortParam& rSortData;
+ SCCOLROW nFieldArr[SC_MAXFIELDS];
+ USHORT nFieldCount;
+ SCCOL nFirstCol;
+ SCROW nFirstRow;
+ BOOL bHasHeader;
+ BOOL bSortByRows;
+
+ ListBox* aSortLbArr[3];
+ RadioButton* aDirBtnArr[3][2];
+ FixedLine* aFlArr[3];
+
+#ifdef _TPSORT_CXX
+private:
+ void Init ();
+ void DisableField ( USHORT nField );
+ void EnableField ( USHORT nField );
+ void FillFieldLists ();
+ USHORT GetFieldSelPos ( SCCOLROW nField );
+
+ // Handler ------------------------
+ DECL_LINK( SelectHdl, ListBox * );
+#endif
+};
+
+//========================================================================
+// Sortieroptionen (Sort Options)
+
+class ScDocument;
+class ScRangeData;
+class CollatorRessource;
+class CollatorWrapper;
+
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#include <sfx2/layout.hxx>
+#include <layout/layout-pre.hxx>
+#else /* !ENABLE_LAYOUT_EXPERIMENTAL */
+#define LocalizedString String
+#endif /* !ENABLE_LAYOUT_EXPERIMENTAL */
+
+class ScTabPageSortOptions : public SfxTabPage
+{
+public:
+ ScTabPageSortOptions( Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScTabPageSortOptions();
+
+#undef SfxTabPage
+#define SfxTabPage ::SfxTabPage
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rArgSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+
+protected:
+// fuer Datenaustausch (sollte noch umgestellt werden!)
+// virtual void ActivatePage ( const SfxItemSet& rSet );
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+ virtual void ActivatePage ();
+ virtual int DeactivatePage ( SfxItemSet* pSet = 0);
+
+private:
+
+ CheckBox aBtnCase;
+ CheckBox aBtnHeader;
+ CheckBox aBtnFormats;
+ CheckBox aBtnNaturalSort;
+
+ CheckBox aBtnCopyResult;
+ ListBox aLbOutPos;
+ Edit aEdOutPos;
+
+ CheckBox aBtnSortUser;
+ ListBox aLbSortUser;
+
+ FixedText aFtLanguage;
+ SvxLanguageBox aLbLanguage;
+ FixedText aFtAlgorithm;
+ ListBox aLbAlgorithm;
+
+ FixedLine aLineDirection;
+ RadioButton aBtnTopDown;
+ RadioButton aBtnLeftRight;
+
+// FixedText aFtAreaLabel;
+// FixedInfo aFtArea;
+ LocalizedString aStrRowLabel;
+ LocalizedString aStrColLabel;
+ LocalizedString aStrUndefined;
+ String aStrNoName;
+ String aStrAreaLabel;
+
+ const USHORT nWhichSort;
+ const ScSortParam& rSortData;
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ ScSortDlg* pDlg;
+ ScAddress theOutPos;
+
+ CollatorRessource* pColRes;
+ CollatorWrapper* pColWrap;
+
+#ifdef _TPSORT_CXX
+private:
+ void Init ();
+ void FillUserSortListBox ();
+ void FillOutPosList ();
+
+ // Handler ------------------------
+ DECL_LINK( EnableHdl, CheckBox * );
+ DECL_LINK( SelOutPosHdl, ListBox * );
+ void EdOutPosModHdl ( Edit* pEd );
+ DECL_LINK( SortDirHdl, RadioButton * );
+ DECL_LINK( FillAlgorHdl, void * );
+#endif
+};
+
+#if ENABLE_LAYOUT_EXPERIMENTAL
+#include <layout/layout-post.hxx>
+#endif /* ENABLE_LAYOUT_EXPERIMENTAL */
+
+#endif // SC_TPSORT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpstat.hxx b/sc/source/ui/inc/tpstat.hxx
new file mode 100644
index 000000000000..10fa3998b8e9
--- /dev/null
+++ b/sc/source/ui/inc/tpstat.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPSTAT_HXX
+#define SC_TPSTAT_HXX
+
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/stdctrl.hxx>
+
+
+
+//========================================================================
+
+class ScDocStatPage: public SfxTabPage
+{
+public:
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rSet );
+
+private:
+ ScDocStatPage( Window *pParent, const SfxItemSet& rSet );
+ ~ScDocStatPage();
+
+protected:
+ virtual BOOL FillItemSet( SfxItemSet& rSet );
+ virtual void Reset ( const SfxItemSet& rSet );
+
+private:
+ FixedLine aFlInfo;
+ FixedText aFtTablesLbl;
+ FixedInfo aFtTables;
+ FixedText aFtCellsLbl;
+ FixedInfo aFtCells;
+ FixedText aFtPagesLbl;
+ FixedInfo aFtPages;
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpsubt.hxx b/sc/source/ui/inc/tpsubt.hxx
new file mode 100644
index 000000000000..99efeb57b694
--- /dev/null
+++ b/sc/source/ui/inc/tpsubt.hxx
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPSUBT_HXX
+#define SC_TPSUBT_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <svx/checklbx.hxx>
+#include <vcl/fixed.hxx>
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+
+// +1 because one field is reserved for the "- none -" entry
+#define SC_MAXFIELDS MAXCOLCOUNT+1
+
+class ScViewData;
+class ScDocument;
+
+//========================================================================
+// Gruppenseiten: Basisklasse
+
+class ScTpSubTotalGroup : public SfxTabPage
+{
+protected:
+ ScTpSubTotalGroup( Window* pParent, USHORT nResId,
+ const SfxItemSet& rArgSet );
+
+public:
+ virtual ~ScTpSubTotalGroup();
+
+ static USHORT* GetRanges ();
+ BOOL DoReset ( USHORT nGroupNo,
+ const SfxItemSet& rArgSet );
+ BOOL DoFillItemSet ( USHORT nGroupNo,
+ SfxItemSet& rArgSet );
+protected:
+ FixedText aFtGroup;
+ ListBox aLbGroup;
+ FixedText aFtColumns;
+ SvxCheckListBox aLbColumns;
+ FixedText aFtFunctions;
+ ListBox aLbFunctions;
+ const String aStrNone;
+ const String aStrColumn;
+
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+
+ const USHORT nWhichSubTotals;
+ const ScSubTotalParam& rSubTotalData;
+ SCCOL nFieldArr[SC_MAXFIELDS];
+ const USHORT nFieldCount;
+
+private:
+ void Init ();
+ void FillListBoxes ();
+ ScSubTotalFunc LbPosToFunc ( USHORT nPos );
+ USHORT FuncToLbPos ( ScSubTotalFunc eFunc );
+ USHORT GetFieldSelPos ( SCCOL nField );
+
+ // Handler ------------------------
+ DECL_LINK( SelectHdl, ListBox * );
+ DECL_LINK( CheckHdl, ListBox * );
+};
+
+//------------------------------------------------------------------------
+
+class ScTpSubTotalGroup1 : public ScTpSubTotalGroup
+{
+protected:
+ ScTpSubTotalGroup1( Window* pParent,
+ const SfxItemSet& rArgSet );
+
+public:
+ virtual ~ScTpSubTotalGroup1();
+
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rArgSet );
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+};
+
+//------------------------------------------------------------------------
+
+class ScTpSubTotalGroup2 : public ScTpSubTotalGroup
+{
+protected:
+ ScTpSubTotalGroup2( Window* pParent,
+ const SfxItemSet& rArgSet );
+
+public:
+ virtual ~ScTpSubTotalGroup2();
+
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rArgSet );
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+};
+
+//------------------------------------------------------------------------
+
+class ScTpSubTotalGroup3 : public ScTpSubTotalGroup
+{
+protected:
+ ScTpSubTotalGroup3( Window* pParent,
+ const SfxItemSet& rArgSet );
+
+public:
+ virtual ~ScTpSubTotalGroup3();
+
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rArgSet );
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+};
+
+//========================================================================
+// Optionen:
+
+class ScTpSubTotalOptions : public SfxTabPage
+{
+protected:
+ ScTpSubTotalOptions( Window* pParent,
+ const SfxItemSet& rArgSet );
+
+public:
+ virtual ~ScTpSubTotalOptions();
+
+ static USHORT* GetRanges ();
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rArgSet );
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+
+private:
+ FixedLine aFlGroup;
+ CheckBox aBtnPagebreak;
+ CheckBox aBtnCase;
+ CheckBox aBtnSort;
+ FixedLine aFlSort;
+ RadioButton aBtnAscending;
+ RadioButton aBtnDescending;
+ CheckBox aBtnFormats;
+ CheckBox aBtnUserDef;
+ ListBox aLbUserDef;
+
+ ScViewData* pViewData;
+ ScDocument* pDoc;
+ const USHORT nWhichSubTotals;
+ const ScSubTotalParam& rSubTotalData;
+
+private:
+ void Init ();
+ void FillUserSortListBox ();
+
+ // Handler ------------------------
+ DECL_LINK( CheckHdl, CheckBox * );
+};
+
+
+
+#endif // SC_TPSORT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tptable.hxx b/sc/source/ui/inc/tptable.hxx
new file mode 100644
index 000000000000..d891050ddf34
--- /dev/null
+++ b/sc/source/ui/inc/tptable.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPTABLE_HXX
+#define SC_TPTABLE_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+
+//===================================================================
+
+/** A vcl/NumericField that additionally supports empty text.
+ @descr Value 0 is set as empty text, and empty text is returned as 0. */
+class EmptyNumericField : public NumericField
+{
+public:
+ inline explicit EmptyNumericField( Window* pParent, WinBits nWinStyle ) :
+ NumericField( pParent, nWinStyle ) {}
+ inline explicit EmptyNumericField( Window* pParent, const ResId& rResId ) :
+ NumericField( pParent, rResId ) {}
+
+ virtual void Modify();
+ virtual void SetValue( sal_Int64 nValue );
+ virtual sal_Int64 GetValue() const;
+};
+
+//===================================================================
+
+class ScTablePage : public SfxTabPage
+{
+public:
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rCoreSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreSet );
+ virtual void Reset ( const SfxItemSet& rCoreSet );
+ using SfxTabPage::DeactivatePage;
+ virtual int DeactivatePage ( SfxItemSet* pSet = NULL );
+ virtual void DataChanged ( const DataChangedEvent& rDCEvt );
+
+private:
+ ScTablePage( Window* pParent, const SfxItemSet& rCoreSet );
+ virtual ~ScTablePage();
+
+ void ShowImage();
+
+private:
+ FixedLine aFlPageDir;
+ RadioButton aBtnTopDown;
+ RadioButton aBtnLeftRight;
+ FixedImage aBmpPageDir;
+ Image aImgLeftRight;
+ Image aImgTopDown;
+ Image aImgLeftRightHC;
+ Image aImgTopDownHC;
+ CheckBox aBtnPageNo;
+ NumericField aEdPageNo;
+
+ FixedLine aFlPrint;
+ CheckBox aBtnHeaders;
+ CheckBox aBtnGrid;
+ CheckBox aBtnNotes;
+ CheckBox aBtnObjects;
+ CheckBox aBtnCharts;
+ CheckBox aBtnDrawings;
+ CheckBox aBtnFormulas;
+ CheckBox aBtnNullVals;
+
+ FixedLine aFlScale;
+ FixedText aFtScaleMode;
+ ListBox aLbScaleMode;
+ FixedText aFtScaleAll;
+ MetricField aEdScaleAll;
+ FixedText aFtScalePageWidth;
+ EmptyNumericField aEdScalePageWidth;
+ FixedText aFtScalePageHeight;
+ EmptyNumericField aEdScalePageHeight;
+ FixedText aFtScalePageNum;
+ NumericField aEdScalePageNum;
+
+private:
+ //------------------------------------
+ // Handler:
+ DECL_LINK( PageDirHdl, RadioButton* );
+ DECL_LINK( PageNoHdl, CheckBox* );
+ DECL_LINK( ScaleHdl, ListBox* );
+};
+
+#endif // SC_TPTABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpusrlst.hxx b/sc/source/ui/inc/tpusrlst.hxx
new file mode 100644
index 000000000000..998b88706ec3
--- /dev/null
+++ b/sc/source/ui/inc/tpusrlst.hxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPUSRLST_HXX
+#define SC_TPUSRLST_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/svmedit.hxx>
+
+//========================================================================
+// Benutzerdefinierte Listen:
+
+class ScUserList;
+class ScDocument;
+class ScViewData;
+class ScRangeUtil;
+
+class ScTpUserLists : public SfxTabPage
+{
+public:
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rAttrSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreAttrs );
+ virtual void Reset ( const SfxItemSet& rCoreAttrs );
+ using SfxTabPage::DeactivatePage;
+ virtual int DeactivatePage ( SfxItemSet* pSet = NULL );
+
+private:
+ ScTpUserLists( Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScTpUserLists();
+
+private:
+ FixedText aFtLists;
+ ListBox aLbLists;
+ FixedText aFtEntries;
+ MultiLineEdit aEdEntries;
+ FixedText aFtCopyFrom;
+ Edit aEdCopyFrom;
+ PushButton aBtnNew;
+ PushButton aBtnAdd;
+ PushButton aBtnRemove;
+ PushButton aBtnCopy;
+
+ const String aStrQueryRemove;
+ const String aStrNew;
+ const String aStrCancel;
+ const String aStrAdd;
+ const String aStrModify;
+ const String aStrCopyList;
+ const String aStrCopyFrom;
+ const String aStrCopyErr;
+
+ const USHORT nWhichUserLists;
+ ScUserList* pUserLists;
+
+ ScDocument* pDoc;
+ ScViewData* pViewData;
+ ScRangeUtil* pRangeUtil;
+ String aStrSelectedArea;
+
+ BOOL bModifyMode;
+ BOOL bCancelMode;
+ BOOL bCopyDone;
+ USHORT nCancelPos;
+
+#ifdef _TPUSRLST_CXX
+private:
+ void Init ();
+ USHORT UpdateUserListBox ();
+ void UpdateEntries ( USHORT nList );
+ void MakeListStr ( String& rListStr );
+ void AddNewList ( const String& rEntriesStr );
+ void RemoveList ( USHORT nList );
+ void ModifyList ( USHORT nSelList,
+ const String& rEntriesStr );
+ void CopyListFromArea ( const ScRefAddress& rStartPos,
+ const ScRefAddress& rEndPos );
+
+ // Handler:
+ DECL_LINK( LbSelectHdl, ListBox* );
+ DECL_LINK( BtnClickHdl, PushButton* );
+ DECL_LINK( EdEntriesModHdl, MultiLineEdit* );
+#endif
+};
+
+
+
+#endif // SC_TPUSRLST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/tpview.hxx b/sc/source/ui/inc/tpview.hxx
new file mode 100644
index 000000000000..b56989eff4a9
--- /dev/null
+++ b/sc/source/ui/inc/tpview.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TPVIEW_HXX
+#define SC_TPVIEW_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/field.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <svx/strarray.hxx>
+
+//========================================================================
+// View-Optionen:
+
+class ScViewOptions;
+
+//========================================================================
+// TabPage Inhalte
+
+class ScTpContentOptions : public SfxTabPage
+{
+ FixedLine aLinesGB;
+ CheckBox aGridCB;
+ FixedText aColorFT;
+ ColorListBox aColorLB;
+ CheckBox aBreakCB;
+ CheckBox aGuideLineCB;
+ CheckBox aHandleCB;
+ CheckBox aBigHandleCB;
+
+ FixedLine aSeparator1FL;
+
+ FixedLine aDisplayGB;
+ CheckBox aFormulaCB;
+ CheckBox aNilCB;
+ CheckBox aAnnotCB;
+ CheckBox aValueCB;
+ CheckBox aAnchorCB;
+ CheckBox aClipMarkCB;
+ CheckBox aRangeFindCB;
+
+ FixedLine aObjectGB;
+ FixedText aObjGrfFT;
+ ListBox aObjGrfLB;
+ FixedText aDiagramFT;
+ ListBox aDiagramLB;
+ FixedText aDrawFT;
+ ListBox aDrawLB;
+
+ FixedLine aZoomGB;
+ CheckBox aSyncZoomCB;
+
+ FixedLine aSeparator2FL;
+
+ FixedLine aWindowGB;
+ CheckBox aRowColHeaderCB;
+ CheckBox aHScrollCB;
+ CheckBox aVScrollCB;
+ CheckBox aTblRegCB;
+ CheckBox aOutlineCB;
+
+ ScViewOptions* pLocalOptions;
+
+ void InitGridOpt();
+ DECL_LINK( GridHdl, CheckBox* );
+ DECL_LINK( SelLbObjHdl, ListBox* );
+ DECL_LINK( CBHdl, CheckBox* );
+
+ ScTpContentOptions( Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScTpContentOptions();
+
+public:
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rCoreSet );
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreSet );
+ virtual void Reset ( const SfxItemSet& rCoreSet );
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+ virtual void ActivatePage( const SfxItemSet& );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+
+};
+
+//========================================================================
+// TabPage Layout
+class ScDocument;
+class ScTpLayoutOptions : public SfxTabPage
+{
+ FixedLine aUnitGB;
+ FixedText aUnitFT;
+ ListBox aUnitLB;
+ FixedText aTabFT;
+ MetricField aTabMF;
+
+ FixedLine aSeparatorFL;
+ FixedLine aLinkGB;
+ FixedText aLinkFT;
+ RadioButton aAlwaysRB;
+ RadioButton aRequestRB;
+ RadioButton aNeverRB;
+
+ FixedLine aOptionsGB;
+ CheckBox aAlignCB;
+ ListBox aAlignLB;
+ CheckBox aEditModeCB;
+ CheckBox aFormatCB;
+ CheckBox aExpRefCB;
+ CheckBox aMarkHdrCB;
+ CheckBox aTextFmtCB;
+ CheckBox aReplWarnCB;
+
+ SvxStringArray aUnitArr;
+
+ DECL_LINK( CBHdl, CheckBox* );
+
+ DECL_LINK(MetricHdl, ListBox*);
+ DECL_LINK( AlignHdl, CheckBox* );
+
+ ScDocument *pDoc;
+
+ DECL_LINK( UpdateHdl, CheckBox* );
+
+ ScTpLayoutOptions( Window* pParent,
+ const SfxItemSet& rArgSet );
+ ~ScTpLayoutOptions();
+
+public:
+ static SfxTabPage* Create ( Window* pParent,
+ const SfxItemSet& rCoreSet );
+ virtual BOOL FillItemSet ( SfxItemSet& rCoreSet );
+ virtual void Reset ( const SfxItemSet& rCoreSet );
+ using SfxTabPage::ActivatePage;
+ using SfxTabPage::DeactivatePage;
+ virtual void ActivatePage( const SfxItemSet& );
+ virtual int DeactivatePage( SfxItemSet* pSet = 0 );
+
+ void SetDocument(ScDocument* pPtr){pDoc = pPtr;}
+
+};
+//========================================================================
+
+#endif // SC_TPUSRLST_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/transobj.hxx b/sc/source/ui/inc/transobj.hxx
new file mode 100644
index 000000000000..4e0f9c96a82b
--- /dev/null
+++ b/sc/source/ui/inc/transobj.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_TRANSOBJ_HXX
+#define SC_TRANSOBJ_HXX
+
+#include <svtools/transfer.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+class ScDocShell;
+class ScMarkData;
+class SfxObjectShell;
+
+namespace com { namespace sun { namespace star {
+ namespace sheet {
+ class XSheetCellRanges;
+ }
+}}}
+
+#include <sfx2/objsh.hxx>
+
+class ScTransferObj : public TransferableHelper
+{
+private:
+ ScDocument* pDoc;
+ ScRange aBlock;
+ SCROW nNonFiltered; // non-filtered rows
+ TransferableDataHelper aOleData;
+ TransferableObjectDescriptor aObjDesc;
+//REMOVE SvEmbeddedObjectRef aDocShellRef;
+//REMOVE SvEmbeddedObjectRef aDrawPersistRef;
+ SfxObjectShellRef aDocShellRef;
+ SfxObjectShellRef aDrawPersistRef;
+ com::sun::star::uno::Reference<com::sun::star::sheet::XSheetCellRanges> xDragSourceRanges;
+ SCCOL nDragHandleX;
+ SCROW nDragHandleY;
+ SCTAB nVisibleTab;
+ USHORT nDragSourceFlags;
+ BOOL bDragWasInternal;
+ BOOL bUsedForLink;
+ bool bHasFiltered; // if has filtered rows
+
+ void InitDocShell();
+ static void StripRefs( ScDocument* pDoc, SCCOL nStartX, SCROW nStartY,
+ SCCOL nEndX, SCROW nEndY,
+ ScDocument* pDestDoc=0,
+ SCCOL nSubX=0, SCROW nSubY=0 );
+ static void PaintToDev( OutputDevice* pDev, ScDocument* pDoc, double nPrintFactor,
+ const ScRange& rBlock, BOOL bMetaFile );
+ static void GetAreaSize( ScDocument* pDoc, SCTAB nTab1, SCTAB nTab2, SCROW& nRow, SCCOL& nCol );
+
+public:
+ ScTransferObj( ScDocument* pClipDoc, const TransferableObjectDescriptor& rDesc );
+ virtual ~ScTransferObj();
+
+ virtual void AddSupportedFormats();
+ virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual sal_Bool WriteObject( SotStorageStreamRef& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId,
+ const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+ virtual void ObjectReleased();
+ virtual void DragFinished( sal_Int8 nDropAction );
+
+ ScDocument* GetDocument() { return pDoc; } // owned by ScTransferObj
+ const ScRange& GetRange() const { return aBlock; }
+ SCROW GetNonFilteredRows() const { return nNonFiltered; }
+ SCCOL GetDragHandleX() const { return nDragHandleX; }
+ SCROW GetDragHandleY() const { return nDragHandleY; }
+ SCTAB GetVisibleTab() const { return nVisibleTab; }
+ USHORT GetDragSourceFlags() const { return nDragSourceFlags; }
+ bool HasFilteredRows() const { return bHasFiltered; }
+ ScDocShell* GetSourceDocShell();
+ ScDocument* GetSourceDocument();
+ ScMarkData GetSourceMarkData();
+
+ void SetDrawPersist( const SfxObjectShellRef& rRef );
+ void SetDragHandlePos( SCCOL nX, SCROW nY );
+ void SetVisibleTab( SCTAB nNew );
+ void SetDragSource( ScDocShell* pSourceShell, const ScMarkData& rMark );
+ void SetDragSourceFlags( USHORT nFlags );
+ void SetDragWasInternal();
+
+ static SC_DLLPUBLIC ScTransferObj* GetOwnClipboard( Window* pUIWin );
+
+ static SfxObjectShell* SetDrawClipDoc( BOOL bAnyOle ); // update ScGlobal::pDrawClipDocShellRef
+ virtual sal_Int64 SAL_CALL getSomething( const com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( com::sun::star::uno::RuntimeException );
+ static const com::sun::star::uno::Sequence< sal_Int8 >& getUnoTunnelId();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/ui_pch.hxx b/sc/source/ui/inc/ui_pch.hxx
new file mode 100644
index 000000000000..c2d363f49917
--- /dev/null
+++ b/sc/source/ui/inc/ui_pch.hxx
@@ -0,0 +1,329 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// ItemID-Defines etc. muessen immer ganz vorne stehen
+
+#include "scitems.hxx"
+
+#define _ZFORLIST_DECLARE_TABLE
+
+#define _PRINTFUN_CXX
+#define _INPUTHDL_CXX
+
+#include <tools/solar.h>
+#include <tools/string.hxx>
+#include <svl/solar.hrc>
+#include <tools/rtti.hxx>
+#include <string.h>
+#include <tools/contnr.hxx>
+#include <vcl/sv.h>
+#include <tools/ref.hxx>
+#include <tools/list.hxx>
+#include <tools/link.hxx>
+#include <i18npool/lang.h>
+#include <sfx2/sfx.hrc>
+#include <svl/memberid.hrc>
+#include <sfx2/sfxsids.hrc>
+#include <svl/cntwids.hrc>
+#include <tools/resid.hxx>
+#include <tools/rc.hxx>
+#include <tools/resmgr.hxx>
+#include <tools/gen.hxx>
+#include <tools/fract.hxx>
+#include <tools/date.hxx>
+#include <tools/time.hxx>
+#include <vcl/keycod.hxx>
+#include <vcl/keycodes.hxx>
+#include <tools/globname.hxx>
+#include <tools/color.hxx>
+#include <vcl/region.hxx>
+#include <vcl/mapmod.hxx>
+#include <vcl/bitmap.hxx>
+#include <sot/sotref.hxx>
+#include <svx/svxids.hrc>
+#include <vcl/vclenum.hxx>
+#include <sot/object.hxx>
+#include <sot/sotdata.hxx>
+#include <sot/factory.hxx>
+#include <tools/ownlist.hxx>
+#include <vcl/font.hxx>
+#include <vcl/wall.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/accel.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/pointr.hxx>
+#include <vcl/ptrstyle.hxx>
+#include <vcl/wintypes.hxx>
+#include <vcl/event.hxx>
+#include <limits.h>
+#include <tools/errinf.hxx>
+#include <tools/errcode.hxx>
+#include <tools/stream.hxx>
+#include <vcl/color.hxx>
+#include <vcl/window.hxx>
+#include <global.hxx>
+#include <vcl/syswin.hxx>
+#include <tools/debug.hxx>
+#include <svl/svarray.hxx>
+#include <vcl/ctrl.hxx>
+#include <svl/hint.hxx>
+#include <svl/poolitem.hxx>
+#include <vcl/image.hxx>
+#include <vcl/timer.hxx>
+#include <tools/unqidx.hxx>
+#include <vcl/symbol.hxx>
+#include <vcl/fixed.hxx>
+#include <svl/brdcst.hxx>
+#include <vcl/timer.hxx>
+#include <sc.hrc>
+#include <stdarg.h>
+#include <svx/dialogs.hrc>
+#include <basic/sbxdef.hxx>
+#include <svl/lstner.hxx>
+#include <sfx2/shell.hxx>
+#include <vcl/window.hxx>
+#include <vcl/group.hxx>
+#include <tools/unqid.hxx>
+#include <tools/table.hxx>
+#include <svl/itemset.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <rangelst.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/combobox.h>
+#include <tools/shl.hxx>
+#include <vcl/field.hxx>
+#include <vcl/spinfld.hxx>
+#include <vcl/combobox.hxx>
+#include <tools/pstm.hxx>
+#include <svl/eitem.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/tabdlg.hxx>
+#include <vcl/tabdlg.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/tabctrl.hxx>
+#include <shellids.hxx>
+#include <vcl/event.hxx>
+#include <svl/intitem.hxx>
+#include <svtools/confitem.hxx>
+#include <markdata.hxx>
+#include <svx/optgrid.hxx>
+#include <vcl/apptypes.hxx>
+#include <viewopti.hxx>
+#include <viewdata.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/clientsh.hxx>
+#include <document.hxx>
+#include <vcl/prntypes.hxx>
+#include <table.hxx>
+#include <column.hxx>
+#include <markarr.hxx>
+#include <vcl/mapmod.hxx>
+#include <svl/undo.hxx>
+#include <vcl/seleng.hxx>
+#include <rsc/rscsfx.hxx>
+#include <svx/zoomitem.hxx>
+#include <vcl/scrbar.hxx>
+#include <viewutil.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/datetime.hxx>
+#include <tabview.hxx>
+#include <select.hxx>
+#include <sfx2/imgdef.hxx>
+#include <viewfunc.hxx>
+#include <sfx2/module.hxx>
+#include <dbfunc.hxx>
+#include <vcl/accel.hxx>
+#include <svl/smplhint.hxx>
+#include <sfx2/viewfac.hxx>
+#include <sot/storage.hxx>
+#include <sfx2/objsh.hxx>
+#include <target.hxx>
+#include <tabvwsh.hxx>
+#include <svl/inethist.hxx>
+#include <svl/inetdef.hxx>
+#include <sfx2/sfxdefs.hxx>
+#include <svtools/compat.hxx>
+#include <svl/inetmsg.hxx>
+#include <sfx2/app.hxx>
+#include <tools/urlobj.hxx>
+#include <scdll.hxx>
+#include <sfx2/msg.hxx>
+#include <svl/ownlist.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/frame.hxx>
+#include <scresid.hxx>
+#include <sfx2/ipfrm.hxx>
+#include <docsh.hxx>
+#include <vcl/wintypes.hxx>
+#include <sfx2/docfac.hxx>
+#include <scitems.hxx>
+#include <vcl/virdev.hxx>
+#include <globstr.hrc>
+#include <tcov.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/lstbox.h>
+#include <sfx2/minarray.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/pointr.hxx>
+#include <vcl/prntypes.hxx>
+#include <vcl/jobset.hxx>
+#include <svx/svdtypes.hxx>
+#include <vcl/btndlg.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/svstdarr.hxx>
+#include <vcl/edit.hxx>
+#include <svl/stritem.hxx>
+#include <collect.hxx>
+#include <svx/svdsob.hxx>
+#include <vcl/imagebtn.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdglue.hxx>
+#include <svx/svdlayer.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/svdmrkv.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/svdhdl.hxx>
+#include <svx/svdsnpv.hxx>
+#include <svx/svdpntv.hxx>
+#include <svx/svddrag.hxx>
+#include <svx/svdhlpln.hxx>
+#include <scmod.hxx>
+#include <sfx2/request.hxx>
+#include <vcl/field.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdcrtv.hxx>
+#include <vcl/print.hxx>
+#include <vcl/floatwin.hxx>
+#include <vcl/wrkwin.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/chalign.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/bitmapex.hxx>
+#include <vcl/animate.hxx>
+#include <vcl/graph.h>
+#include <editeng/editdata.hxx>
+#include <svtools/stdctrl.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <conditio.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/print.hxx>
+#include <uiitems.hxx>
+#include <svx/svdmodel.hxx>
+#include <vcl/gdiobj.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/pageitem.hxx>
+#include <anyrefdg.hxx>
+#include <basic/sbxcore.hxx>
+#include <vcl/ctrl.hxx>
+#include <svx/xenum.hxx>
+#include <dbcolect.hxx>
+#include <sot/exchange.hxx>
+#include <math.h>
+#include <vcl/wrkwin.hxx>
+#include <basic/sbxvar.hxx>
+#include <vcl/image.hxx>
+#include <svx/xdef.hxx>
+#include <drwlayer.hxx>
+#include <editutil.hxx>
+#include <svx/xit.hxx>
+#include <svx/xcolit.hxx>
+#include <attrib.hxx>
+#include <patattr.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xflasit.hxx>
+#include <svx/xlnasit.hxx>
+#include <svx/svdattr.hxx>
+#include <svx/sdangitm.hxx>
+#include <svx/sderitm.hxx>
+#include <svx/sdmetitm.hxx>
+#include <svx/svddef.hxx>
+#include <svx/sdooitm.hxx>
+#include <svx/sdprcitm.hxx>
+#include <svx/sdshcitm.hxx>
+#include <svx/sdshitm.hxx>
+#include <svx/sdshtitm.hxx>
+#include <svx/sdsxyitm.hxx>
+#include <svx/sdtaaitm.hxx>
+#include <svx/sdtacitm.hxx>
+#include <svx/sdtaditm.hxx>
+#include <svx/sdtagitm.hxx>
+#include <svx/sdtaiitm.hxx>
+#include <svx/sdynitm.hxx>
+#include <svx/sdtaitm.hxx>
+#include <svx/sdtakitm.hxx>
+#include <svx/sdtayitm.hxx>
+#include <svx/sdtcfitm.hxx>
+#include <svx/sdtditm.hxx>
+#include <svx/sdtfsitm.hxx>
+#include <svx/sdtmfitm.hxx>
+#include <tools/poly.hxx>
+#include <vcl/gdimtf.hxx>
+#include <cell.hxx>
+#include <stddef.h>
+#include <tools/mempool.hxx>
+#include <svl/style.hrc>
+#include <drawview.hxx>
+#include <svx/view3d.hxx>
+#include <svx/def3d.hxx>
+#include <vcl/floatwin.hxx>
+#include <basic/sbxobj.hxx>
+#include <editeng/svxenum.hxx>
+#include <svx/xtextit0.hxx>
+#include <svx/svdtrans.hxx>
+#include <svl/style.hxx>
+#include <reffact.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdoattr.hxx>
+#include <tools/wldcrd.hxx>
+#include <rangenam.hxx>
+#include <undobase.hxx>
+#include <vcl/dockwin.hxx>
+#include <vcl/virdev.hxx>
+#include <rangeutl.hxx>
+#include <vcl/toolbox.hxx>
+#include <fupoor.hxx>
+#include <docpool.hxx>
+#include <vcl/button.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/svdorect.hxx>
+#include <svl/whiter.hxx>
+#include <stlpool.hxx>
+#include <editeng/eeitem.hxx>
+#include <inputhdl.hxx>
+#include <svx/svdpage.hxx>
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/uiitems.hxx b/sc/source/ui/inc/uiitems.hxx
new file mode 100644
index 000000000000..a06398ce54a8
--- /dev/null
+++ b/sc/source/ui/inc/uiitems.hxx
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UIITEMS_HXX
+#define SC_UIITEMS_HXX
+
+#include "scdllapi.h"
+#include "conditio.hxx"
+#include "sortparam.hxx"
+#include "queryparam.hxx"
+#include "paramisc.hxx"
+#include <svl/poolitem.hxx>
+
+class ScEditEngineDefaulter;
+class EditTextObject;
+class ScViewData;
+class ScDPSaveData;
+
+// ---------------------------------------------------------------------------
+
+// Items
+
+class ScInputStatusItem : public SfxPoolItem
+{
+ ScAddress aCursorPos;
+ ScAddress aStartPos;
+ ScAddress aEndPos;
+ String aString;
+ EditTextObject* pEditData;
+
+public:
+ TYPEINFO();
+
+ ScInputStatusItem( USHORT nWhich,
+ const ScAddress& rCurPos,
+ const ScAddress& rStartPos,
+ const ScAddress& rEndPos,
+ const String& rString,
+ const EditTextObject* pData );
+ ScInputStatusItem( const ScInputStatusItem& rItem );
+ ~ScInputStatusItem();
+
+ virtual String GetValueText() const;
+
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ const ScAddress& GetPos() const { return aCursorPos; }
+ const ScAddress& GetStartPos() const { return aStartPos; }
+ const ScAddress& GetEndPos() const { return aEndPos; }
+ SCTAB GetTab() const { return aCursorPos.Tab(); }
+ SCCOL GetCol() const { return aCursorPos.Col(); }
+ SCROW GetRow() const { return aCursorPos.Row(); }
+ SCCOL GetStartCol() const { return aStartPos.Col(); }
+ SCROW GetStartRow() const { return aStartPos.Row(); }
+ SCCOL GetEndCol() const { return aEndPos.Col(); }
+ SCROW GetEndRow() const { return aEndPos.Row(); }
+
+ const String& GetString() const { return aString; }
+ const EditTextObject* GetEditData() const { return pEditData; }
+};
+
+
+#define SC_TAB_INSERTED 1
+#define SC_TAB_DELETED 2
+#define SC_TAB_MOVED 3
+#define SC_TAB_COPIED 4
+#define SC_TAB_HIDDEN 5
+
+class ScTablesHint : public SfxHint
+{
+ USHORT nId;
+ SCTAB nTab1;
+ SCTAB nTab2;
+
+public:
+ TYPEINFO();
+ ScTablesHint(USHORT nNewId, SCTAB nTable1, SCTAB nTable2=0);
+ ~ScTablesHint();
+
+ USHORT GetId() const { return nId; }
+ SCTAB GetTab1() const { return nTab1; }
+ SCTAB GetTab2() const { return nTab2; }
+};
+
+class ScEditViewHint : public SfxHint
+{
+ ScEditEngineDefaulter* pEditEngine;
+ ScAddress aCursorPos;
+
+public:
+ TYPEINFO();
+ ScEditViewHint( ScEditEngineDefaulter* pEngine, const ScAddress& rCurPos );
+ ~ScEditViewHint();
+
+ SCCOL GetCol() const { return aCursorPos.Col(); }
+ SCROW GetRow() const { return aCursorPos.Row(); }
+ SCTAB GetTab() const { return aCursorPos.Tab(); }
+ ScEditEngineDefaulter* GetEngine() const { return pEditEngine; }
+
+private:
+ ScEditViewHint(); // disabled
+};
+
+class ScIndexHint : public SfxHint
+{
+ USHORT nId;
+ USHORT nIndex;
+
+public:
+ TYPEINFO();
+ ScIndexHint(USHORT nNewId, USHORT nIdx);
+ ~ScIndexHint();
+
+ USHORT GetId() const { return nId; }
+ USHORT GetIndex() const { return nIndex; }
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Sortierdialog:
+
+class SC_DLLPUBLIC ScSortItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScSortItem( USHORT nWhich,
+ ScViewData* ptrViewData,
+ const ScSortParam* pSortData );
+ ScSortItem( USHORT nWhich,
+ const ScSortParam* pSortData );
+ ScSortItem( const ScSortItem& rItem );
+ ~ScSortItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberUd ) const;
+
+ ScViewData* GetViewData () const { return pViewData; }
+ const ScSortParam& GetSortData () const { return theSortData; }
+
+private:
+ ScViewData* pViewData;
+ ScSortParam theSortData;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Filterdialog:
+
+class SC_DLLPUBLIC ScQueryItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScQueryItem( USHORT nWhich,
+ ScViewData* ptrViewData,
+ const ScQueryParam* pQueryData );
+ ScQueryItem( USHORT nWhich,
+ const ScQueryParam* pQueryData );
+ ScQueryItem( const ScQueryItem& rItem );
+ ~ScQueryItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ ScViewData* GetViewData () const { return pViewData; }
+ const ScQueryParam& GetQueryData() const { return theQueryData; }
+
+ BOOL GetAdvancedQuerySource(ScRange& rSource) const;
+ void SetAdvancedQuerySource(const ScRange* pSource);
+
+private:
+ ScViewData* pViewData;
+ ScQueryParam theQueryData;
+ BOOL bIsAdvanced;
+ ScRange aAdvSource;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Zwischenergebnisdialog:
+
+class SC_DLLPUBLIC ScSubTotalItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScSubTotalItem( USHORT nWhich,
+ ScViewData* ptrViewData,
+ const ScSubTotalParam* pSubTotalData );
+ ScSubTotalItem( USHORT nWhich,
+ const ScSubTotalParam* pSubTotalData );
+ ScSubTotalItem( const ScSubTotalItem& rItem );
+ ~ScSubTotalItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+ virtual bool QueryValue( com::sun::star::uno::Any& rVal, BYTE nMemberUd ) const;
+
+ ScViewData* GetViewData () const { return pViewData; }
+ const ScSubTotalParam& GetSubTotalData() const { return theSubTotalData; }
+
+private:
+ ScViewData* pViewData;
+ ScSubTotalParam theSubTotalData;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer die Benutzerlisten-TabPage:
+
+class SC_DLLPUBLIC ScUserListItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScUserListItem( USHORT nWhich );
+ ScUserListItem( const ScUserListItem& rItem );
+ ~ScUserListItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ void SetUserList ( const ScUserList& rUserList );
+ ScUserList* GetUserList () const { return pUserList; }
+
+private:
+ ScUserList* pUserList;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer die Konsolidieren-Dialog
+
+class ScConsolidateItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScConsolidateItem( USHORT nWhich,
+ const ScConsolidateParam* pParam );
+ ScConsolidateItem( const ScConsolidateItem& rItem );
+ ~ScConsolidateItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ const ScConsolidateParam& GetData() const { return theConsData; }
+
+private:
+ ScConsolidateParam theConsData;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Pivot-Dialog
+
+class ScPivotItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScPivotItem( USHORT nWhich, const ScDPSaveData* pData,
+ const ScRange* pRange, BOOL bNew );
+ ScPivotItem( const ScPivotItem& rItem );
+ ~ScPivotItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ const ScDPSaveData& GetData() const { return *pSaveData; }
+ const ScRange& GetDestRange() const { return aDestRange; }
+ BOOL IsNewSheet() const { return bNewSheet; }
+
+private:
+ ScDPSaveData* pSaveData;
+ ScRange aDestRange;
+ BOOL bNewSheet;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Solver-Dialog
+
+class ScSolveItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScSolveItem( USHORT nWhich,
+ const ScSolveParam* pParam );
+ ScSolveItem( const ScSolveItem& rItem );
+ ~ScSolveItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ const ScSolveParam& GetData() const { return theSolveData; }
+
+private:
+ ScSolveParam theSolveData;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Mehrfachoperationen-Dialog
+
+class ScTabOpItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScTabOpItem( USHORT nWhich,
+ const ScTabOpParam* pParam );
+ ScTabOpItem( const ScTabOpItem& rItem );
+ ~ScTabOpItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ const ScTabOpParam& GetData() const { return theTabOpData; }
+
+private:
+ ScTabOpParam theTabOpData;
+};
+
+//----------------------------------------------------------------------------
+// Parameter-Item fuer den Dialog bedingte Formatierung
+
+class ScCondFrmtItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+ ScCondFrmtItem( USHORT nWhich,
+//! const ScConditionalFormat* pCondFrmt );
+ const ScConditionalFormat& rCondFrmt );
+ ScCondFrmtItem( const ScCondFrmtItem& rItem );
+ ~ScCondFrmtItem();
+
+ virtual String GetValueText() const;
+ virtual int operator==( const SfxPoolItem& ) const;
+ virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
+
+ const ScConditionalFormat& GetData() const { return theCondFrmtData; }
+
+private:
+ ScConditionalFormat theCondFrmtData;
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undobase.hxx b/sc/source/ui/inc/undobase.hxx
new file mode 100644
index 000000000000..d00f1fba00d1
--- /dev/null
+++ b/sc/source/ui/inc/undobase.hxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDOBASE_HXX
+#define SC_UNDOBASE_HXX
+
+#include <svl/undo.hxx>
+#include "global.hxx"
+#include "address.hxx"
+
+class ScDocument;
+class ScDocShell;
+class SdrUndoAction;
+class ScRefUndoData;
+class ScDBData;
+
+//----------------------------------------------------------------------------
+
+class ScSimpleUndo: public SfxUndoAction
+{
+public:
+ TYPEINFO();
+ ScSimpleUndo( ScDocShell* pDocSh );
+ virtual ~ScSimpleUndo();
+
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+
+protected:
+ ScDocShell* pDocShell;
+ SfxUndoAction* pDetectiveUndo;
+
+ void BeginUndo();
+ void EndUndo();
+ void BeginRedo();
+ void EndRedo();
+
+ static void ShowTable( SCTAB nTab );
+ static void ShowTable( const ScRange& rRange );
+};
+
+//----------------------------------------------------------------------------
+
+enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
+
+class ScBlockUndo: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
+ ScBlockUndoMode eBlockMode );
+ virtual ~ScBlockUndo();
+
+protected:
+ ScRange aBlockRange;
+ SdrUndoAction* pDrawUndo;
+ ScBlockUndoMode eMode;
+
+ void BeginUndo();
+ void EndUndo();
+// void BeginRedo();
+ void EndRedo();
+
+ BOOL AdjustHeight();
+ void ShowBlock();
+};
+
+//----------------------------------------------------------------------------
+
+// for functions that act on a database range - takes care of the unnamed database range
+// (collected separately, before the undo action, for showing dialogs etc.)
+
+class ScDBFuncUndo: public ScSimpleUndo
+{
+ ScDBData* pAutoDBRange;
+ ScRange aOriginalRange;
+ SdrUndoAction* mpDrawUndo;
+
+public:
+ TYPEINFO();
+ ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo = 0 );
+ virtual ~ScDBFuncUndo();
+
+ void SetDrawUndoAction( SdrUndoAction* pDrawUndo );
+
+ void BeginUndo();
+ void EndUndo();
+ void BeginRedo();
+ void EndRedo();
+};
+
+//----------------------------------------------------------------------------
+
+enum ScMoveUndoMode { SC_UNDO_REFFIRST, SC_UNDO_REFLAST };
+
+class ScMoveUndo: public ScSimpleUndo // mit Referenzen
+{
+public:
+ TYPEINFO();
+ ScMoveUndo( ScDocShell* pDocSh,
+ ScDocument* pRefDoc, ScRefUndoData* pRefData,
+ ScMoveUndoMode eRefMode );
+ virtual ~ScMoveUndo();
+
+protected:
+ SdrUndoAction* pDrawUndo;
+ ScDocument* pRefUndoDoc;
+ ScRefUndoData* pRefUndoData;
+ ScMoveUndoMode eMode;
+
+ void BeginUndo();
+ void EndUndo();
+// void BeginRedo();
+// void EndRedo();
+
+private:
+ void UndoRef();
+};
+
+//----------------------------------------------------------------------------
+
+class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
+{
+ SfxUndoAction* pWrappedUndo;
+
+public:
+ TYPEINFO();
+ ScUndoWrapper( SfxUndoAction* pUndo );
+ virtual ~ScUndoWrapper();
+
+ SfxUndoAction* GetWrappedUndo() { return pWrappedUndo; }
+ void ForgetWrappedUndo();
+
+ virtual BOOL IsLinked();
+ virtual void SetLinked( BOOL bIsLinked );
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+ virtual String GetComment() const;
+ virtual String GetRepeatComment(SfxRepeatTarget&) const;
+ virtual USHORT GetId() const;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
new file mode 100644
index 000000000000..b07fb0172b1e
--- /dev/null
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -0,0 +1,999 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_UNDOBLK_HXX
+#define SC_UNDOBLK_HXX
+
+#include "undobase.hxx"
+#include "markdata.hxx"
+#include "viewutil.hxx"
+#include "spellparam.hxx"
+#include "cellmergeoption.hxx"
+
+#include "cell.hxx"
+
+#include <boost/shared_ptr.hpp>
+
+class ScDocShell;
+class ScBaseCell;
+class ScDocument;
+class ScOutlineTable;
+class ScRangeName;
+class ScRangeList;
+class ScDBCollection;
+class ScPatternAttr;
+class SvxBoxItem;
+class SvxBoxInfoItem;
+class SvxSearchItem;
+class SdrUndoAction;
+
+//----------------------------------------------------------------------------
+
+class ScUndoInsertCells: public ScMoveUndo
+{
+public:
+ TYPEINFO();
+ ScUndoInsertCells( ScDocShell* pNewDocShell,
+ const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
+ InsCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData,
+ BOOL bNewPartOfPaste );
+ virtual ~ScUndoInsertCells();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat( SfxRepeatTarget& rTarget );
+ virtual BOOL CanRepeat( SfxRepeatTarget& rTarget ) const;
+
+ virtual String GetComment() const;
+
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+
+private:
+ ScRange aEffRange;
+ SCTAB nCount;
+ SCTAB* pTabs;
+ SCTAB* pScenarios;
+ ULONG nEndChangeAction;
+ InsCellCmd eCmd;
+ BOOL bPartOfPaste;
+ SfxUndoAction* pPasteUndo;
+
+ void DoChange ( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+class ScUndoDeleteCells: public ScMoveUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDeleteCells( ScDocShell* pNewDocShell,
+ const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
+ DelCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData );
+ virtual ~ScUndoDeleteCells();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRange aEffRange;
+ SCTAB nCount;
+ SCTAB* pTabs;
+ SCTAB* pScenarios;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ DelCellCmd eCmd;
+
+ void DoChange ( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+class ScUndoDeleteMulti: public ScMoveUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDeleteMulti( ScDocShell* pNewDocShell,
+ BOOL bNewRows, BOOL bNeedsRefresh, SCTAB nNewTab,
+ const SCCOLROW* pRng, SCCOLROW nRngCnt,
+ ScDocument* pUndoDocument, ScRefUndoData* pRefData );
+ virtual ~ScUndoDeleteMulti();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ BOOL bRows;
+ BOOL bRefresh;
+ SCTAB nTab;
+ SCCOLROW* pRanges;
+ SCCOLROW nRangeCnt;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+
+ void DoChange() const;
+ void SetChangeTrack();
+};
+
+
+class ScUndoCut: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoCut( ScDocShell* pNewDocShell,
+ ScRange aRange, // adjusted for merged cells
+ ScAddress aOldEnd, // end position without adjustment
+ const ScMarkData& rMark, // selected sheets
+ ScDocument* pNewUndoDoc );
+ virtual ~ScUndoCut();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ ScRange aExtendedRange;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+
+ void DoChange( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+struct ScUndoPasteOptions
+{
+ USHORT nFunction;
+ BOOL bSkipEmpty;
+ BOOL bTranspose;
+ BOOL bAsLink;
+ InsCellCmd eMoveMode;
+
+ ScUndoPasteOptions() :
+ nFunction( PASTE_NOFUNC ),
+ bSkipEmpty( FALSE ),
+ bTranspose( FALSE ),
+ bAsLink( FALSE ),
+ eMoveMode( INS_NONE )
+ {}
+};
+
+class ScUndoPaste: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoPaste( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ USHORT nNewFlags,
+ ScRefUndoData* pRefData, void* pFill1, void* pFill2, void* pFill3,
+ BOOL bRedoIsFilled = TRUE,
+ const ScUndoPasteOptions* pOptions = NULL );
+ virtual ~ScUndoPaste();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+ USHORT nFlags;
+ ScRefUndoData* pRefUndoData;
+ ScRefUndoData* pRefRedoData;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ BOOL bRedoFilled;
+ ScUndoPasteOptions aPasteOptions;
+
+ void DoChange( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+class ScUndoDragDrop: public ScMoveUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDragDrop( ScDocShell* pNewDocShell,
+ const ScRange& rRange, ScAddress aNewDestPos, BOOL bNewCut,
+ ScDocument* pUndoDocument, ScRefUndoData* pRefData,
+ BOOL bScenario );
+ virtual ~ScUndoDragDrop();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRange aSrcRange;
+ ScRange aDestRange;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ BOOL bCut;
+ BOOL bKeepScenarioFlags;
+
+ void PaintArea( ScRange aRange, USHORT nExtFlags ) const;
+ void DoUndo( ScRange aRange ) const;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoDeleteContents: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDeleteContents( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ const ScRange& rRange,
+ ScDocument* pNewUndoDoc, BOOL bNewMulti,
+ USHORT nNewFlags, BOOL bObjects );
+ virtual ~ScUndoDeleteContents();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRange aRange;
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc; // Blockmarkierung und geloeschte Daten
+ SdrUndoAction* pDrawUndo; // geloeschte Objekte
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ USHORT nFlags;
+ BOOL bMulti; // Mehrfachselektion
+
+ void DoChange( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+class ScUndoFillTable: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoFillTable( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, BOOL bNewMulti, SCTAB nSrc,
+ USHORT nFlg, USHORT nFunc, BOOL bSkip, BOOL bLink );
+ virtual ~ScUndoFillTable();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRange aRange;
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc; // Blockmarkierung und geloeschte Daten
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ USHORT nFlags;
+ USHORT nFunction;
+ SCTAB nSrcTab;
+ BOOL bMulti; // Mehrfachselektion
+ BOOL bSkipEmpty;
+ BOOL bAsLink;
+
+ void DoChange( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+class ScUndoSelectionAttr: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoSelectionAttr( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, BOOL bNewMulti,
+ const ScPatternAttr* pNewApply,
+ const SvxBoxItem* pNewOuter = NULL,
+ const SvxBoxInfoItem* pNewInner = NULL );
+ virtual ~ScUndoSelectionAttr();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+ ScEditDataArray* GetDataArray();
+private:
+ ScMarkData aMarkData;
+ ScRange aRange;
+ ScEditDataArray aDataArray;
+ ScDocument* pUndoDoc;
+ BOOL bMulti;
+ ScPatternAttr* pApplyPattern;
+ SvxBoxItem* pLineOuter;
+ SvxBoxInfoItem* pLineInner;
+
+ void DoChange( const BOOL bUndo );
+ void ChangeEditData( const bool bUndo );
+};
+
+
+class ScUndoWidthOrHeight: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOLROW nNewStart, SCTAB nNewStartTab,
+ SCCOLROW nNewEnd, SCTAB nNewEndTab,
+ ScDocument* pNewUndoDoc,
+ SCCOLROW nNewCnt, SCCOLROW* pNewRanges,
+ ScOutlineTable* pNewUndoTab,
+ ScSizeMode eNewMode, USHORT nNewSizeTwips,
+ BOOL bNewWidth );
+ virtual ~ScUndoWidthOrHeight();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ SCTAB nStartTab;
+ SCTAB nEndTab;
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTab;
+ SCCOLROW nRangeCnt;
+ SCCOLROW* pRanges;
+ USHORT nNewSize;
+ BOOL bWidth;
+ ScSizeMode eMode;
+ SdrUndoAction* pDrawUndo;
+};
+
+
+class ScUndoAutoFill: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoAutoFill( ScDocShell* pNewDocShell,
+ const ScRange& rRange, const ScRange& rSourceArea,
+ ScDocument* pNewUndoDoc, const ScMarkData& rMark,
+ FillDir eNewFillDir,
+ FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd,
+ double fNewStartValue, double fNewStepValue, double fNewMaxValue,
+ USHORT nMaxShIndex );
+ virtual ~ScUndoAutoFill();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRange aSource;
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ FillDir eFillDir;
+ FillCmd eFillCmd;
+ FillDateCmd eFillDateCmd;
+ double fStartValue;
+ double fStepValue;
+ double fMaxValue;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ USHORT nMaxSharedIndex;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoMerge: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
+ bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo);
+ virtual ~ScUndoMerge();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScCellMergeOption maOption;
+ bool mbMergeContents; // Merge contents in Redo().
+ ScDocument* mpUndoDoc; // wenn Daten zusammengefasst
+ SdrUndoAction* mpDrawUndo;
+
+ void DoChange( bool bUndo ) const;
+};
+
+
+class ScUndoAutoFormat: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoAutoFormat( ScDocShell* pNewDocShell,
+ const ScRange& rRange, ScDocument* pNewUndoDoc,
+ const ScMarkData& rMark,
+ BOOL bNewSize, USHORT nNewFormatNo );
+ virtual ~ScUndoAutoFormat();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pUndoDoc; // geloeschte Daten
+ ScMarkData aMarkData;
+ BOOL bSize;
+ USHORT nFormatNo;
+};
+
+
+class ScUndoReplace: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoReplace( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
+ const String& rNewUndoStr, ScDocument* pNewUndoDoc,
+ const SvxSearchItem* pItem );
+ virtual ~ScUndoReplace();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aCursorPos;
+ ScMarkData aMarkData;
+ String aUndoStr; // Daten bei Einfachmarkierung
+ ScDocument* pUndoDoc; // Blockmarkierung und geloeschte Daten
+ SvxSearchItem* pSearchItem;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoTabOp: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoTabOp( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc,
+ const ScRefAddress& rFormulaCell,
+ const ScRefAddress& rFormulaEnd,
+ const ScRefAddress& rRowCell,
+ const ScRefAddress& rColCell,
+ BYTE nMode );
+ virtual ~ScUndoTabOp();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRange aRange;
+ ScDocument* pUndoDoc; // geloeschte Daten
+ ScRefAddress theFormulaCell;
+ ScRefAddress theFormulaEnd;
+ ScRefAddress theRowCell;
+ ScRefAddress theColCell;
+ BYTE nMode;
+};
+
+
+class ScUndoConversion : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+
+ ScUndoConversion(
+ ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocument* pNewUndoDoc,
+ SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocument* pNewRedoDoc,
+ const ScConversionParam& rConvParam );
+ virtual ~ScUndoConversion();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScAddress aCursorPos;
+ ScDocument* pUndoDoc; // Blockmarkierung und geloeschte Daten
+ ScAddress aNewCursorPos;
+ ScDocument* pRedoDoc; // Blockmarkierung und neue Daten
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ ScConversionParam maConvParam; /// Conversion type and parameters.
+
+ void DoChange( ScDocument* pRefDoc, const ScAddress& rCursorPos );
+ void SetChangeTrack();
+};
+
+class ScUndoRefConversion: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRefConversion( ScDocShell* pNewDocShell,
+ const ScRange& aMarkRange, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, BOOL bNewMulti, USHORT nNewFlag);
+ virtual ~ScUndoRefConversion();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+ ScRange aRange;
+ BOOL bMulti;
+ USHORT nFlags;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+
+ void DoChange( ScDocument* pRefDoc);
+ void SetChangeTrack();
+};
+
+class ScUndoListNames: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoListNames( ScDocShell* pNewDocShell,
+ const ScRange& rRange,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc );
+ virtual ~ScUndoListNames();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+
+ void DoChange( ScDocument* pSrcDoc ) const;
+};
+
+
+class ScUndoUseScenario: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoUseScenario( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ const ScArea& rDestArea, ScDocument* pNewUndoDoc,
+ const String& rNewName );
+ virtual ~ScUndoUseScenario();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pUndoDoc;
+ ScRange aRange;
+ ScMarkData aMarkData;
+ String aName;
+};
+
+
+class ScUndoSelectionStyle: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoSelectionStyle( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ const ScRange& rRange,
+ const String& rName,
+ ScDocument* pNewUndoDoc );
+ virtual ~ScUndoSelectionStyle();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+ virtual USHORT GetId() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ String aStyleName;
+ ScRange aRange;
+
+ void DoChange( const BOOL bUndo );
+};
+
+
+class ScUndoRefreshLink: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRefreshLink( ScDocShell* pNewDocShell,
+ ScDocument* pNewUndoDoc );
+ virtual ~ScUndoRefreshLink();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+};
+
+
+class ScUndoEnterMatrix: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoEnterMatrix( ScDocShell* pNewDocShell,
+ const ScRange& rArea,
+ ScDocument* pNewUndoDoc,
+ const String& rForm );
+ virtual ~ScUndoEnterMatrix();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pUndoDoc;
+ String aFormula;
+ formula::FormulaGrammar::AddressConvention eConv;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoInsertAreaLink : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoInsertAreaLink( ScDocShell* pShell,
+ const String& rDoc,
+ const String& rFlt, const String& rOpt,
+ const String& rArea, const ScRange& rDestRange,
+ ULONG nRefreshDelay );
+ virtual ~ScUndoInsertAreaLink();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aDocName;
+ String aFltName;
+ String aOptions;
+ String aAreaName;
+ ScRange aRange;
+ ULONG nRefreshDelay;
+};
+
+
+class ScUndoRemoveAreaLink : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRemoveAreaLink( ScDocShell* pShell,
+ const String& rDoc,
+ const String& rFlt, const String& rOpt,
+ const String& rArea, const ScRange& rDestRange,
+ ULONG nRefreshDelay );
+ virtual ~ScUndoRemoveAreaLink();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aDocName;
+ String aFltName;
+ String aOptions;
+ String aAreaName;
+ ScRange aRange;
+ ULONG nRefreshDelay;
+};
+
+
+class ScUndoUpdateAreaLink : public ScSimpleUndo //! auch BlockUndo umstellen?
+{
+public:
+ TYPEINFO();
+ ScUndoUpdateAreaLink( ScDocShell* pShell,
+ const String& rOldD,
+ const String& rOldF, const String& rOldO,
+ const String& rOldA, const ScRange& rOldR,
+ ULONG nOldRD,
+ const String& rNewD,
+ const String& rNewF, const String& rNewO,
+ const String& rNewA, const ScRange& rNewR,
+ ULONG nNewRD,
+ ScDocument* pUndo, ScDocument* pRedo,
+ BOOL bDoInsert );
+ virtual ~ScUndoUpdateAreaLink();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aOldDoc;
+ String aOldFlt;
+ String aOldOpt;
+ String aOldArea;
+ ScRange aOldRange;
+ String aNewDoc;
+ String aNewFlt;
+ String aNewOpt;
+ String aNewArea;
+ ScRange aNewRange;
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+ ULONG nOldRefresh;
+ ULONG nNewRefresh;
+ BOOL bWithInsert;
+
+ void DoChange( const BOOL bUndo ) const;
+};
+
+
+class ScUndoIndent: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoIndent( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, BOOL bIncrement );
+ virtual ~ScUndoIndent();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ BOOL bIsIncrement;
+};
+
+
+class ScUndoTransliterate: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoTransliterate( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, sal_Int32 nType );
+ virtual ~ScUndoTransliterate();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ sal_Int32 nTransliterationType;
+};
+
+
+class ScUndoClearItems: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, const USHORT* pW );
+ virtual ~ScUndoClearItems();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ USHORT* pWhich;
+};
+
+
+class ScUndoRemoveBreaks: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRemoveBreaks( ScDocShell* pNewDocShell,
+ SCTAB nNewTab, ScDocument* pNewUndoDoc );
+ virtual ~ScUndoRemoveBreaks();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ ScDocument* pUndoDoc;
+};
+
+
+class ScUndoRemoveMerge: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRemoveMerge( ScDocShell* pNewDocShell,
+ const ScCellMergeOption& rOption,
+ ScDocument* pNewUndoDoc );
+ virtual ~ScUndoRemoveMerge();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ void SetCurTab();
+
+ ScCellMergeOption maOption;
+ ScDocument* pUndoDoc;
+};
+
+
+class ScUndoBorder: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoBorder( ScDocShell* pNewDocShell,
+ const ScRangeList& rRangeList,
+ ScDocument* pNewUndoDoc,
+ const SvxBoxItem& rNewOuter,
+ const SvxBoxInfoItem& rNewInner );
+ virtual ~ScUndoBorder();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pUndoDoc;
+ ScRangeList* pRanges;
+ SvxBoxItem* pOuter;
+ SvxBoxInfoItem* pInner;
+};
+
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undocell.hxx b/sc/source/ui/inc/undocell.hxx
new file mode 100644
index 000000000000..0d00af997d74
--- /dev/null
+++ b/sc/source/ui/inc/undocell.hxx
@@ -0,0 +1,377 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDOCELL_HXX
+#define SC_UNDOCELL_HXX
+
+#include "undobase.hxx"
+#include "postit.hxx"
+
+#include <boost/shared_ptr.hpp>
+
+class ScDocShell;
+class ScBaseCell;
+class ScPatternAttr;
+class EditTextObject;
+class SdrUndoAction;
+class ScDetOpList;
+class ScDetOpData;
+class ScRangeName;
+
+//----------------------------------------------------------------------------
+
+class ScUndoCursorAttr: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoCursorAttr( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
+ const ScPatternAttr* pApplyPat, BOOL bAutomatic );
+ virtual ~ScUndoCursorAttr();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+ /** once the objects are passed to this class, their life-cycle is
+ managed by this class; the calling function must pass new'ed
+ objects to this method. */
+ void SetEditData( EditTextObject* pOld, EditTextObject* pNew );
+
+private:
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ ScPatternAttr* pOldPattern;
+ ScPatternAttr* pNewPattern;
+ ScPatternAttr* pApplyPattern;
+ ::boost::shared_ptr<EditTextObject> pOldEditData;
+ ::boost::shared_ptr<EditTextObject> pNewEditData;
+ BOOL bIsAutomatic;
+
+ void DoChange( const ScPatternAttr* pWhichPattern, const ::boost::shared_ptr<EditTextObject>& pEditData ) const;
+};
+
+
+class ScUndoEnterData: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoEnterData( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ SCTAB nNewCount, SCTAB* pNewTabs,
+ ScBaseCell** ppOldData, BOOL* pHasForm, ULONG* pOldForm,
+ const String& rNewStr, EditTextObject* pObj = NULL );
+ virtual ~ScUndoEnterData();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aNewString;
+ SCTAB* pTabs;
+ ScBaseCell** ppOldCells;
+ BOOL* pHasFormat;
+ ULONG* pOldFormats;
+ EditTextObject* pNewEditData;
+ ULONG nEndChangeAction;
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ SCTAB nCount; // markierte Tabellen
+
+ void DoChange() const;
+ void SetChangeTrack();
+};
+
+
+class ScUndoEnterValue: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoEnterValue( ScDocShell* pNewDocShell,
+ const ScAddress& rNewPos,
+ ScBaseCell* pUndoCell, double nVal, BOOL bHeight );
+ virtual ~ScUndoEnterValue();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aPos;
+ ScBaseCell* pOldCell;
+ double nValue;
+ ULONG nEndChangeAction;
+ BOOL bNeedHeight;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoPutCell: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoPutCell( ScDocShell* pNewDocShell,
+ const ScAddress& rNewPos,
+ ScBaseCell* pUndoCell, ScBaseCell* pRedoCell, BOOL bHeight );
+ virtual ~ScUndoPutCell();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aPos;
+ ScBaseCell* pOldCell;
+ ScBaseCell* pEnteredCell;
+ ULONG nEndChangeAction;
+ BOOL bNeedHeight;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoPageBreak: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoPageBreak( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ BOOL bNewColumn, BOOL bNewInsert );
+ virtual ~ScUndoPageBreak();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ BOOL bColumn; // Spalten- oder Zeilenumbruch
+ BOOL bInsert; // Einfuegen oder Loeschen
+
+ void DoChange( BOOL bInsert ) const;
+};
+
+class ScUndoPrintZoom: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoPrintZoom( ScDocShell* pNewDocShell, SCTAB nT,
+ USHORT nOS, USHORT nOP, USHORT nNS, USHORT nNP );
+ virtual ~ScUndoPrintZoom();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ USHORT nOldScale;
+ USHORT nOldPages;
+ USHORT nNewScale;
+ USHORT nNewPages;
+
+ void DoChange( BOOL bUndo );
+};
+
+class ScUndoThesaurus: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoThesaurus( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ const String& rNewUndoStr, const EditTextObject* pUndoTObj,
+ const String& rNewRedoStr, const EditTextObject* pRedoTObj);
+ virtual ~ScUndoThesaurus();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ String aUndoStr; // Daten bei StringZelle
+ EditTextObject* pUndoTObject; // bei EditZelle
+ String aRedoStr;
+ EditTextObject* pRedoTObject;
+ ULONG nEndChangeAction;
+
+ void DoChange( BOOL bUndo, const String& rStr,
+ const EditTextObject* pTObj );
+ void SetChangeTrack( ScBaseCell* pOldCell );
+};
+
+// ============================================================================
+
+/** Undo action for inserting, removing, and replacing a cell note. */
+class ScUndoReplaceNote : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+
+ /** Constructs an undo action for inserting or removing a cell note. */
+ ScUndoReplaceNote(
+ ScDocShell& rDocShell,
+ const ScAddress& rPos,
+ const ScNoteData& rNoteData,
+ bool bInsert,
+ SdrUndoAction* pDrawUndo );
+
+ /** Constructs an undo action for replacing a cell note with another. */
+ ScUndoReplaceNote(
+ ScDocShell& rDocShell,
+ const ScAddress& rPos,
+ const ScNoteData& rOldData,
+ const ScNoteData& rNewData,
+ SdrUndoAction* pDrawUndo );
+
+ virtual ~ScUndoReplaceNote();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat( SfxRepeatTarget& rTarget );
+ virtual BOOL CanRepeat( SfxRepeatTarget& rTarget ) const;
+
+ virtual String GetComment() const;
+
+private:
+ void DoInsertNote( const ScNoteData& rNoteData );
+ void DoRemoveNote( const ScNoteData& rNoteData );
+
+private:
+ ScAddress maPos;
+ ScNoteData maOldData;
+ ScNoteData maNewData;
+ SdrUndoAction* mpDrawUndo;
+};
+
+// ============================================================================
+
+/** Undo action for showing or hiding a cell note caption. */
+class ScUndoShowHideNote : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow );
+ virtual ~ScUndoShowHideNote();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat( SfxRepeatTarget& rTarget );
+ virtual BOOL CanRepeat( SfxRepeatTarget& rTarget ) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress maPos;
+ bool mbShown;
+};
+
+// ============================================================================
+
+class ScUndoDetective: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDetective( ScDocShell* pNewDocShell,
+ SdrUndoAction* pDraw, const ScDetOpData* pOperation,
+ ScDetOpList* pUndoList = NULL );
+ virtual ~ScUndoDetective();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ BOOL bIsDelete;
+ ScDetOpList* pOldList;
+ USHORT nAction;
+ ScAddress aPos;
+ SdrUndoAction* pDrawUndo;
+};
+
+
+class ScUndoRangeNames: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRangeNames( ScDocShell* pNewDocShell,
+ ScRangeName* pOld, ScRangeName* pNew );
+ virtual ~ScUndoRangeNames();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScRangeName* pOldRanges;
+ ScRangeName* pNewRanges;
+
+ void DoChange( BOOL bUndo );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undodat.hxx b/sc/source/ui/inc/undodat.hxx
new file mode 100644
index 000000000000..5f76bccb5fae
--- /dev/null
+++ b/sc/source/ui/inc/undodat.hxx
@@ -0,0 +1,540 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDODAT_HXX
+#define SC_UNDODAT_HXX
+
+#include "undobase.hxx"
+#include "rangeutl.hxx" // ScArea
+#include "rangelst.hxx" // ScRangeListRef
+#include "markdata.hxx"
+#include "sortparam.hxx"
+#include "queryparam.hxx"
+#include "pivot.hxx"
+
+class ScDocShell;
+class ScDocument;
+class ScOutlineTable;
+class ScRangeName;
+class ScDBData;
+class ScDBCollection;
+class ScDPObject;
+class SdrUndoAction;
+
+//----------------------------------------------------------------------------
+
+class ScUndoDoOutline: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDoOutline( ScDocShell* pNewDocShell,
+ SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
+ ScDocument* pNewUndoDoc, BOOL bNewColumns,
+ USHORT nNewLevel, USHORT nNewEntry, BOOL bNewShow );
+ virtual ~ScUndoDoOutline();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ SCTAB nTab;
+ ScDocument* pUndoDoc;
+ BOOL bColumns;
+ USHORT nLevel;
+ USHORT nEntry;
+ BOOL bShow;
+};
+
+
+class ScUndoMakeOutline: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoMakeOutline( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScOutlineTable* pNewUndoTab,
+ BOOL bNewColumns, BOOL bNewMake );
+ virtual ~ScUndoMakeOutline();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aBlockStart;
+ ScAddress aBlockEnd;
+ ScOutlineTable* pUndoTable;
+ BOOL bColumns;
+ BOOL bMake;
+};
+
+
+class ScUndoOutlineLevel: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoOutlineLevel( ScDocShell* pNewDocShell,
+ SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ BOOL bNewColumns, USHORT nNewLevel );
+ virtual ~ScUndoOutlineLevel();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ SCTAB nTab;
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTable;
+ BOOL bColumns;
+ USHORT nLevel;
+};
+
+
+class ScUndoOutlineBlock: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoOutlineBlock( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ BOOL bNewShow );
+ virtual ~ScUndoOutlineBlock();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aBlockStart;
+ ScAddress aBlockEnd;
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTable;
+ BOOL bShow;
+};
+
+
+class ScUndoRemoveAllOutlines: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab );
+ virtual ~ScUndoRemoveAllOutlines();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aBlockStart;
+ ScAddress aBlockEnd;
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTable;
+};
+
+
+class ScUndoAutoOutline: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoAutoOutline( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab );
+ virtual ~ScUndoAutoOutline();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aBlockStart;
+ ScAddress aBlockEnd;
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTable;
+};
+
+
+class ScUndoSubTotals: public ScDBFuncUndo
+{
+public:
+ TYPEINFO();
+ ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScSubTotalParam& rNewParam, SCROW nNewEndY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+// ScDBData* pNewData,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB );
+ virtual ~ScUndoSubTotals();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ ScSubTotalParam aParam; // Original uebergebener Parameter
+ SCROW nNewEndRow; // Ergebnis-Groesse
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTable;
+// ScDBData* pUndoDBData;
+ ScRangeName* pUndoRange;
+ ScDBCollection* pUndoDB;
+};
+
+
+class ScUndoSort: public ScDBFuncUndo
+{
+public:
+ TYPEINFO();
+ ScUndoSort( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScSortParam& rParam,
+ BOOL bQuery, ScDocument* pNewUndoDoc,
+ ScDBCollection* pNewUndoDB, const ScRange* pDest = NULL );
+ virtual ~ScUndoSort();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ ScSortParam aSortParam;
+ BOOL bRepeatQuery;
+ ScDocument* pUndoDoc;
+ ScDBCollection* pUndoDB; // wegen Quell- und Zielbereich
+ BOOL bDestArea;
+ ScRange aDestRange;
+};
+
+
+class ScUndoQuery: public ScDBFuncUndo
+{
+public:
+ TYPEINFO();
+ ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScQueryParam& rParam, ScDocument* pNewUndoDoc,
+ ScDBCollection* pNewUndoDB, const ScRange* pOld,
+ BOOL bSize, const ScRange* pAdvSrc );
+ virtual ~ScUndoQuery();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SdrUndoAction* pDrawUndo;
+ SCTAB nTab;
+ ScQueryParam aQueryParam;
+ ScDocument* pUndoDoc;
+ ScDBCollection* pUndoDB; // wegen Quell- und Zielbereich
+ ScRange aOldDest;
+ ScRange aAdvSource;
+ BOOL bIsAdvanced;
+ BOOL bDestArea;
+ BOOL bDoSize;
+};
+
+
+class ScUndoAutoFilter: public ScDBFuncUndo
+{
+private:
+ String aDBName;
+ BOOL bFilterSet;
+
+ void DoChange( BOOL bUndo );
+
+public:
+ TYPEINFO();
+ ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange,
+ const String& rName, BOOL bSet );
+ virtual ~ScUndoAutoFilter();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+};
+
+
+class ScUndoDBData: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDBData( ScDocShell* pNewDocShell,
+ ScDBCollection* pNewUndoColl, ScDBCollection* pNewRedoColl );
+ virtual ~ScUndoDBData();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDBCollection* pUndoColl;
+ ScDBCollection* pRedoColl;
+};
+
+
+class ScUndoImportData: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY,
+ SCCOL nNewFormula,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ ScDBData* pNewUndoData, ScDBData* pNewRedoData );
+ virtual ~ScUndoImportData();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ ScImportParam aImportParam;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+ ScDBData* pUndoDBData;
+ ScDBData* pRedoDBData;
+ SCCOL nFormulaCols;
+ BOOL bRedoFilled;
+};
+
+
+class ScUndoRepeatDB: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
+ SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB,
+ const ScRange* pOldQ, const ScRange* pNewQ );
+ virtual ~ScUndoRepeatDB();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScAddress aBlockStart;
+ ScAddress aBlockEnd;
+ SCROW nNewEndRow;
+ ScAddress aCursorPos;
+ ScDocument* pUndoDoc;
+ ScOutlineTable* pUndoTable;
+ ScRangeName* pUndoRange;
+ ScDBCollection* pUndoDB;
+ ScRange aOldQuery;
+ ScRange aNewQuery;
+ BOOL bQuerySize;
+};
+
+
+class ScUndoDataPilot: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDataPilot( ScDocShell* pNewDocShell,
+ ScDocument* pOldDoc, ScDocument* pNewDoc,
+ const ScDPObject* pOldObj, const ScDPObject* pNewObj,
+ BOOL bMove );
+ virtual ~ScUndoDataPilot();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScDocument* pOldUndoDoc;
+ ScDocument* pNewUndoDoc;
+ ScDPObject* pOldDPObject;
+ ScDPObject* pNewDPObject;
+ BOOL bAllowMove;
+};
+
+
+class ScUndoConsolidate: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoConsolidate( ScDocShell* pNewDocShell,
+ const ScArea& rArea, const ScConsolidateParam& rPar,
+ ScDocument* pNewUndoDoc, BOOL bReference,
+ SCROW nInsCount, ScOutlineTable* pTab,
+ ScDBData* pData );
+ virtual ~ScUndoConsolidate();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScArea aDestArea;
+ ScDocument* pUndoDoc;
+ ScConsolidateParam aParam;
+ BOOL bInsRef;
+ SCSIZE nInsertCount;
+ ScOutlineTable* pUndoTab;
+ ScDBData* pUndoData;
+};
+
+
+class ScUndoChartData: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoChartData( ScDocShell* pNewDocShell,
+ const String& rName, const ScRange& rNew,
+ BOOL bColHdr, BOOL bRowHdr, BOOL bAdd );
+ ScUndoChartData( ScDocShell* pNewDocShell,
+ const String& rName, const ScRangeListRef& rNew,
+ BOOL bColHdr, BOOL bRowHdr, BOOL bAdd );
+ virtual ~ScUndoChartData();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aChartName;
+ ScRangeListRef aOldRangeListRef;
+ BOOL bOldColHeaders;
+ BOOL bOldRowHeaders;
+// ScRange aNewRange;
+ ScRangeListRef aNewRangeListRef;
+ BOOL bNewColHeaders;
+ BOOL bNewRowHeaders;
+ BOOL bAddRange;
+
+ void Init();
+};
+
+// amelia
+class ScUndoDataForm: public ScBlockUndo
+{
+public:
+ TYPEINFO();
+ ScUndoDataForm( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ USHORT nNewFlags,
+ ScRefUndoData* pRefData, void* pFill1, void* pFill2, void* pFill3,
+ BOOL bRedoIsFilled = TRUE
+ );
+ virtual ~ScUndoDataForm();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ScMarkData aMarkData;
+ ScDocument* pUndoDoc;
+ ScDocument* pRedoDoc;
+ USHORT nFlags;
+ ScRefUndoData* pRefUndoData;
+ ScRefUndoData* pRefRedoData;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ BOOL bRedoFilled;
+
+ void DoChange( const BOOL bUndo );
+ void SetChangeTrack();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undodraw.hxx b/sc/source/ui/inc/undodraw.hxx
new file mode 100644
index 000000000000..7a7015442e68
--- /dev/null
+++ b/sc/source/ui/inc/undodraw.hxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDODRAW_HXX
+#define SC_UNDODRAW_HXX
+
+#include <svl/undo.hxx>
+
+class ScDocShell;
+
+class ScUndoDraw: public SfxUndoAction
+{
+ SfxUndoAction* pDrawUndo;
+ ScDocShell* pDocShell;
+
+public:
+ TYPEINFO();
+ ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh );
+ virtual ~ScUndoDraw();
+
+ SfxUndoAction* GetDrawUndo() { return pDrawUndo; }
+ void ForgetDrawUndo();
+
+ virtual BOOL IsLinked();
+ virtual void SetLinked( BOOL bIsLinked );
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+ virtual BOOL Merge( SfxUndoAction *pNextAction );
+ virtual String GetComment() const;
+ virtual String GetRepeatComment(SfxRepeatTarget&) const;
+ virtual USHORT GetId() const;
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undoolk.hxx b/sc/source/ui/inc/undoolk.hxx
new file mode 100644
index 000000000000..373c72266873
--- /dev/null
+++ b/sc/source/ui/inc/undoolk.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDOOLK_HXX
+#define SC_UNDOOLK_HXX
+
+#include <tools/solar.h>
+
+class SdrUndoAction;
+class ScDocument;
+
+SdrUndoAction* GetSdrUndoAction ( ScDocument* pDoc );
+void DoSdrUndoAction ( SdrUndoAction* pUndoAction, ScDocument* pDoc );
+void RedoSdrUndoAction ( SdrUndoAction* pUndoAction );
+void DeleteSdrUndoAction ( SdrUndoAction* pUndoAction );
+void EnableDrawAdjust ( ScDocument* pDoc, BOOL bEnable );
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undostyl.hxx b/sc/source/ui/inc/undostyl.hxx
new file mode 100644
index 000000000000..d247c86642f8
--- /dev/null
+++ b/sc/source/ui/inc/undostyl.hxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDOSTYL_HXX
+#define SC_UNDOSTYL_HXX
+
+#include <rsc/rscsfx.hxx>
+#include "undobase.hxx"
+
+class ScDocShell;
+class SfxStyleSheetBase;
+
+//----------------------------------------------------------------------------
+
+class ScStyleSaveData
+{
+private:
+ String aName;
+ String aParent;
+ SfxItemSet* pItems;
+
+public:
+ ScStyleSaveData();
+ ScStyleSaveData( const ScStyleSaveData& rOther );
+ ~ScStyleSaveData();
+ ScStyleSaveData& operator=( const ScStyleSaveData& rOther );
+
+ void InitFromStyle( const SfxStyleSheetBase* pSource );
+
+ const String& GetName() const { return aName; }
+ const String& GetParent() const { return aParent; }
+ const SfxItemSet* GetItems() const { return pItems; }
+};
+
+class ScUndoModifyStyle: public ScSimpleUndo
+{
+private:
+ SfxStyleFamily eFamily;
+ ScStyleSaveData aOldData;
+ ScStyleSaveData aNewData;
+
+ static void DoChange( ScDocShell* pDocSh,
+ const String& rName, SfxStyleFamily eStyleFamily,
+ const ScStyleSaveData& rData );
+
+public:
+ TYPEINFO();
+ ScUndoModifyStyle( ScDocShell* pDocSh,
+ SfxStyleFamily eFam,
+ const ScStyleSaveData& rOld,
+ const ScStyleSaveData& rNew );
+ virtual ~ScUndoModifyStyle();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+};
+
+class ScUndoApplyPageStyle: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoApplyPageStyle( ScDocShell* pDocSh, const String& rNewStyle );
+ virtual ~ScUndoApplyPageStyle();
+
+ void AddSheetAction( SCTAB nTab, const String& rOld );
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ struct ApplyStyleEntry
+ {
+ SCTAB mnTab;
+ String maOldStyle;
+ explicit ApplyStyleEntry( SCTAB nTab, const String& rOldStyle );
+ };
+ typedef ::std::vector< ApplyStyleEntry > ApplyStyleVec;
+
+ ApplyStyleVec maEntries;
+ String maNewStyle;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undotab.hxx b/sc/source/ui/inc/undotab.hxx
new file mode 100644
index 000000000000..d725386f36dd
--- /dev/null
+++ b/sc/source/ui/inc/undotab.hxx
@@ -0,0 +1,523 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDOTAB_HXX
+#define SC_UNDOTAB_HXX
+
+#include "undobase.hxx"
+#include "markdata.hxx"
+#include "formula/grammar.hxx"
+#include <tools/color.hxx>
+#include "tabbgcolor.hxx"
+
+#ifndef _SVSTDARR_SHORTS
+
+#define _SVSTDARR_SHORTS
+#include <svl/svstdarr.hxx>
+
+#endif
+
+#ifndef _SVSTDARR_STRINGS
+
+#define _SVSTDARR_STRINGS
+#include <svl/svstdarr.hxx>
+
+#endif
+
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <memory>
+
+class ScDocShell;
+class ScDocument;
+class SdrUndoAction;
+class ScPrintRangeSaver;
+class SdrObject;
+class ScDocProtection;
+class ScTableProtection;
+
+//----------------------------------------------------------------------------
+
+class ScUndoInsertTab : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoInsertTab(
+ ScDocShell* pNewDocShell,
+ SCTAB nTabNum,
+ BOOL bApp,
+ const String& rNewName);
+ virtual ~ScUndoInsertTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String sNewName;
+ SdrUndoAction* pDrawUndo;
+ ULONG nEndChangeAction;
+ SCTAB nTab;
+ BOOL bAppend;
+
+ void SetChangeTrack();
+};
+
+class ScUndoInsertTables : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoInsertTables(
+ ScDocShell* pNewDocShell,
+ SCTAB nTabNum,
+ BOOL bApp,
+ SvStrings *pNewNameList);
+ virtual ~ScUndoInsertTables();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+
+ SdrUndoAction* pDrawUndo;
+ SvStrings* pNameList;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+ SCTAB nTab;
+ BOOL bAppend;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoDeleteTab: public ScMoveUndo // Draw vom Move fuer geloeschte Tabelle
+{
+public:
+ TYPEINFO();
+ ScUndoDeleteTab(
+ ScDocShell* pNewDocShell,
+ const SvShorts &theTabs, //SCTAB nNewTab,
+ ScDocument* pUndoDocument,
+ ScRefUndoData* pRefData );
+ virtual ~ScUndoDeleteTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SvShorts theTabs;
+ ULONG nStartChangeAction;
+ ULONG nEndChangeAction;
+
+ void SetChangeTrack();
+};
+
+
+class ScUndoRenameTab: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRenameTab(
+ ScDocShell* pNewDocShell,
+ SCTAB nT,
+ const String& rOldName,
+ const String& rNewName);
+ virtual ~ScUndoRenameTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ String sOldName;
+ String sNewName;
+
+ void DoChange( SCTAB nTab, const String& rName ) const;
+};
+
+
+class ScUndoMoveTab: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoMoveTab( ScDocShell* pNewDocShell,
+ const SvShorts &aOldTab,
+ const SvShorts &aNewTab);
+ virtual ~ScUndoMoveTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SvShorts theOldTabs;
+ SvShorts theNewTabs;
+
+ void DoChange( BOOL bUndo ) const;
+};
+
+
+class ScUndoCopyTab: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoCopyTab(ScDocShell* pNewDocShell,
+ const SvShorts &aOldTab,
+ const SvShorts &aNewTab);
+
+ virtual ~ScUndoCopyTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SdrUndoAction* pDrawUndo;
+ SvShorts theOldTabs;
+ SvShorts theNewTabs;
+
+ void DoChange() const;
+};
+
+class ScUndoTabColor: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoTabColor(
+ ScDocShell* pNewDocShell,
+ SCTAB nT,
+ const Color& aOTabBgColor,
+ const Color& aNTabBgColor);
+ ScUndoTabColor(
+ ScDocShell* pNewDocShell,
+ const ScUndoTabColorInfo::List& rUndoTabColorList);
+ virtual ~ScUndoTabColor();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+virtual String GetComment() const;
+
+private:
+ ScUndoTabColorInfo::List aTabColorList;
+ bool bIsMultipleUndo;
+
+ void DoChange(bool bUndoType) const;
+};
+
+class ScUndoMakeScenario: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoMakeScenario(
+ ScDocShell* pNewDocShell,
+ SCTAB nSrc, SCTAB nDest,
+ const String& rN, const String& rC,
+ const Color& rCol, USHORT nF,
+ const ScMarkData& rMark );
+ virtual ~ScUndoMakeScenario();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nSrcTab;
+ SCTAB nDestTab;
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ ScMarkData aMarkData;
+ SdrUndoAction* pDrawUndo;
+};
+
+
+class ScUndoImportTab : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoImportTab(
+ ScDocShell* pShell,
+ SCTAB nNewTab, SCTAB nNewCount,
+ BOOL bNewLink );
+ virtual ~ScUndoImportTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ SCTAB nCount;
+ BOOL bLink;
+ ScDocument* pRedoDoc;
+ SdrUndoAction* pDrawUndo;
+
+ void DoChange() const;
+};
+
+
+class ScUndoRemoveLink : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRemoveLink( // vor dem Loeschen aufrufen!
+ ScDocShell* pShell,
+ const String& rDoc );
+ virtual ~ScUndoRemoveLink();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aDocName;
+ String aFltName;
+ String aOptions;
+ ULONG nRefreshDelay;
+ USHORT nCount;
+ SCTAB* pTabs;
+ BYTE* pModes;
+ String* pTabNames;
+
+ void DoChange( BOOL bLink ) const;
+};
+
+
+class ScUndoShowHideTab : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoShowHideTab(
+ ScDocShell* pShell,
+ SCTAB nNewTab, BOOL bNewShow );
+ virtual ~ScUndoShowHideTab();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ BOOL bShow;
+
+ void DoChange( BOOL bShow ) const;
+};
+
+// ============================================================================
+
+/** This class implements undo & redo of document protect & unprotect
+ operations. */
+class ScUndoDocProtect : public ScSimpleUndo
+{
+public:
+ ScUndoDocProtect(ScDocShell* pShell, ::std::auto_ptr<ScDocProtection> pProtectSettings);
+ virtual ~ScUndoDocProtect();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ ::std::auto_ptr<ScDocProtection> mpProtectSettings;
+
+ void DoProtect(bool bProtect);
+};
+
+// ============================================================================
+
+/** This class implements undo & redo of both protect and unprotect of
+ sheet. */
+class ScUndoTabProtect : public ScSimpleUndo
+{
+public:
+ ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab,
+ ::std::auto_ptr<ScTableProtection> pProtectSettings);
+ virtual ~ScUndoTabProtect();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB mnTab;
+ ::std::auto_ptr<ScTableProtection> mpProtectSettings;
+
+ void DoProtect(bool bProtect);
+};
+
+
+class ScUndoPrintRange : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
+ ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew );
+ virtual ~ScUndoPrintRange();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ ScPrintRangeSaver* pOldRanges;
+ ScPrintRangeSaver* pNewRanges;
+
+ void DoChange( BOOL bUndo );
+};
+
+
+class ScUndoScenarioFlags: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoScenarioFlags(
+ ScDocShell* pNewDocShell, SCTAB nT,
+ const String& rON, const String& rNN,
+ const String& rOC, const String& rNC,
+ const Color& rOCol, const Color& rNCol,
+ USHORT nOF, USHORT nNF );
+
+ virtual ~ScUndoScenarioFlags();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ String aOldName;
+ String aNewName;
+ String aOldComment;
+ String aNewComment;
+ Color aOldColor;
+ Color aNewColor;
+ USHORT nOldFlags;
+ USHORT nNewFlags;
+};
+
+
+class ScUndoRenameObject: public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoRenameObject(
+ ScDocShell* pNewDocShell, const String& rPN,
+ const String& rON, const String& rNN );
+
+ virtual ~ScUndoRenameObject();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ String aPersistName; // to find object (works only for OLE objects)
+ String aOldName;
+ String aNewName;
+
+ SdrObject* GetObject();
+};
+
+
+class ScUndoLayoutRTL : public ScSimpleUndo
+{
+public:
+ TYPEINFO();
+ ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, BOOL bNewRTL );
+ virtual ~ScUndoLayoutRTL();
+
+ virtual void Undo();
+ virtual void Redo();
+ virtual void Repeat(SfxRepeatTarget& rTarget);
+ virtual BOOL CanRepeat(SfxRepeatTarget& rTarget) const;
+
+ virtual String GetComment() const;
+
+private:
+ SCTAB nTab;
+ BOOL bRTL;
+
+ void DoChange( BOOL bNew );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/undoutil.hxx b/sc/source/ui/inc/undoutil.hxx
new file mode 100644
index 000000000000..c963d6010d1e
--- /dev/null
+++ b/sc/source/ui/inc/undoutil.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_UNDOUTIL_HXX
+#define SC_UNDOUTIL_HXX
+
+#include "address.hxx"
+#include <tools/solar.h>
+
+class ScRange;
+class ScDocShell;
+class ScDBData;
+class ScDocument;
+
+//----------------------------------------------------------------------------
+
+class ScUndoUtil
+{
+public:
+ // Block markieren (unsichtbar, muss repainted werden)
+ static void MarkSimpleBlock( ScDocShell* pDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ );
+ static void MarkSimpleBlock( ScDocShell* pDocShell,
+ const ScAddress& rBlockStart,
+ const ScAddress& rBlockEnd );
+ static void MarkSimpleBlock( ScDocShell* pDocShell,
+ const ScRange& rRange );
+
+ // Bereich +1 painten
+ static void PaintMore( ScDocShell* pDocShell,
+ const ScRange& rRange );
+
+ // DB-Bereich im Dokument suchen ("unbenannt" oder nach Bereich)
+ // legt neu an, wenn nicht gefunden
+ static ScDBData* GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab,
+ SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/validate.hrc b/sc/source/ui/inc/validate.hrc
new file mode 100644
index 000000000000..0af2a1481a52
--- /dev/null
+++ b/sc/source/ui/inc/validate.hrc
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define TP_VALIDATION_VALUES 696
+#define TP_VALIDATION_INPUTHELP 697
+#define TP_VALIDATION_ERROR 698
+#define TAB_DLG_VALIDATION 699
+
+#define FT_ALLOW 1
+#define LB_ALLOW 2
+#define TSB_ALLOW_BLANKS 3
+#define FT_VALUE 4
+#define LB_VALUE 5
+#define FT_MIN 6
+#define EDT_MIN 7
+#define FT_MAX 8
+#define EDT_MAX 9
+
+#define FL_CONTENT 10
+
+#define TSB_HELP 11
+#define FT_TITLE 12
+#define EDT_TITLE 13
+#define FT_INPUTHELP 14
+#define EDT_INPUTHELP 15
+
+#define TSB_SHOW 21
+#define FT_ACTION 22
+#define FT_ERROR 23
+#define LB_ACTION 24
+#define EDT_ERROR 25
+#define BTN_SEARCH 26
+
+#define CB_SHOWLIST 27
+#define CB_SORTLIST 28
+#define EDT_LIST 29
+#define FT_SOURCEHINT 30
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#define RB_VALIDITY_REF 88
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+/* Position indexes for "Allow" list box.
+ They do not map directly to ScValidationMode and can safely be modified to
+ change the order of the list box entries. */
+#define SC_VALIDDLG_ALLOW_ANY 0
+#define SC_VALIDDLG_ALLOW_WHOLE 1
+#define SC_VALIDDLG_ALLOW_DECIMAL 2
+#define SC_VALIDDLG_ALLOW_DATE 3
+#define SC_VALIDDLG_ALLOW_TIME 4
+#define SC_VALIDDLG_ALLOW_RANGE 5
+#define SC_VALIDDLG_ALLOW_LIST 6
+#define SC_VALIDDLG_ALLOW_TEXTLEN 7
+
+/* Position indexes for "Data" list box.
+ They do not map directly to ScConditionMode and can safely be modified to
+ change the order of the list box entries. */
+#define SC_VALIDDLG_DATA_EQUAL 0
+#define SC_VALIDDLG_DATA_LESS 1
+#define SC_VALIDDLG_DATA_GREATER 2
+#define SC_VALIDDLG_DATA_EQLESS 3
+#define SC_VALIDDLG_DATA_EQGREATER 4
+#define SC_VALIDDLG_DATA_NOTEQUAL 5
+#define SC_VALIDDLG_DATA_BETWEEN 6
+#define SC_VALIDDLG_DATA_NOTBETWEEN 7
+
diff --git a/sc/source/ui/inc/validate.hxx b/sc/source/ui/inc/validate.hxx
new file mode 100644
index 000000000000..19dd63b84df4
--- /dev/null
+++ b/sc/source/ui/inc/validate.hxx
@@ -0,0 +1,349 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VALIDATE_HXX
+#define SC_VALIDATE_HXX
+
+#include <sfx2/tabdlg.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <svtools/svmedit.hxx>
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#include "anyrefdg.hxx"
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+// ============================================================================
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+struct ScRefHandlerCaller{
+ virtual ~ScRefHandlerCaller(){}
+};
+class ScRefHandlerHelper
+{
+protected:
+ ScRefHandlerCaller *m_pHandler;
+ void (ScRefHandlerCaller::*m_pSetReferenceHdl)( const ScRange& , ScDocument* );
+ void (ScRefHandlerCaller::*m_pSetActiveHdl)();
+ void (ScRefHandlerCaller::*m_pRefInputStartPreHdl)( ScRefEdit* pEdit, ScRefButton* pButton );
+ void (ScRefHandlerCaller::*m_pRefInputStartPostHdl)( ScRefEdit* pEdit, ScRefButton* pButton );
+ void (ScRefHandlerCaller::*m_pRefInputDonePreHdl)();
+ void (ScRefHandlerCaller::*m_pRefInputDonePostHdl)();
+
+public:
+ typedef void (ScRefHandlerCaller::*PFUNCSETREFHDLTYPE)( const ScRange& , ScDocument* );
+ typedef void (ScRefHandlerCaller::*PCOMMONHDLTYPE)();
+ typedef void (ScRefHandlerCaller::*PINPUTSTARTDLTYPE)( ScRefEdit* pEdit, ScRefButton* pButton );
+
+ PFUNCSETREFHDLTYPE SetSetRefHdl( PFUNCSETREFHDLTYPE pNewHdl )
+ {
+ PFUNCSETREFHDLTYPE pOldHdl = m_pSetReferenceHdl;
+ m_pSetReferenceHdl = pNewHdl;
+ return pOldHdl;
+ }
+
+ PCOMMONHDLTYPE SetSetActHdl( PCOMMONHDLTYPE pNewHdl )
+ {
+ PCOMMONHDLTYPE pOldHdl = m_pSetActiveHdl;
+ m_pSetActiveHdl = pNewHdl;
+ return pOldHdl;
+ }
+
+ ScRefHandlerCaller *SetHandler( ScRefHandlerCaller *pNewHandler )
+ {
+ ScRefHandlerCaller *pOldHandler = m_pHandler;
+ m_pHandler = pNewHandler;
+ return pOldHandler;
+ }
+ void SetRefInputStartPreHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPreHdl = pNewHdl; }
+ void SetRefInputDonePostHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePostHdl = pNewHdl; }
+ void SetRefInputStartPostHdl( PINPUTSTARTDLTYPE pNewHdl ){ m_pRefInputStartPostHdl = pNewHdl; }
+ void SetRefInputDonePreHdl( void (ScRefHandlerCaller::*pNewHdl)() ){ m_pRefInputDonePreHdl = pNewHdl; }
+
+ ScRefHandlerHelper():m_pHandler(NULL), m_pSetReferenceHdl( NULL ), m_pSetActiveHdl(NULL), m_pRefInputStartPreHdl( NULL ), m_pRefInputStartPostHdl( NULL ), m_pRefInputDonePreHdl( NULL ), m_pRefInputDonePostHdl( NULL ){}
+};
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+/** The "Validity" tab dialog. */
+//<!--Modified by PengYunQuan for Validity Cell Range Picker
+//class ScValidationDlg : public SfxTabDialog
+class ScValidationDlg :public ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false>, public ScRefHandlerHelper
+//-->Modified by PengYunQuan for Validity Cell Range Picker
+{
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ typedef ScRefHdlrImpl<ScValidationDlg, SfxTabDialog, false> ScValidationDlgBase;
+
+ //Start_Moddify by liliang 03/26/2008 SODC_13677_2
+ DECL_LINK( OkHdl, Button * );
+ //End_Moddify by liliang 03/26/2008 SODC_13677_2
+ bool m_bOwnRefHdlr:1;
+
+ ScTabViewShell *m_pTabVwSh;
+ bool m_bRefInputting:1;
+ bool EnterRefStatus();
+ bool LeaveRefStatus();
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+public:
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet );
+ explicit ScValidationDlg( Window* pParent, const SfxItemSet* pArgSet, ScTabViewShell * pTabViewSh, SfxBindings *pB = NULL );
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ virtual ~ScValidationDlg();
+ inline static ScValidationDlg * Find1AliveObject( Window *pAncestor );
+ bool IsAlive();
+ inline ScTabViewShell * GetTabViewShell();
+
+ bool SetupRefDlg();
+ bool RemoveRefDlg( BOOL bRestoreModal = TRUE );
+
+ virtual void SetModal( BOOL bModal ){ ScValidationDlgBase::SetModalInputMode( bModal ); }
+
+ virtual void SetReference( const ScRange& rRef, ScDocument* pDoc )
+ {
+ if ( m_pHandler && m_pSetReferenceHdl )
+ (m_pHandler->*m_pSetReferenceHdl)( rRef, pDoc );
+ }
+
+ virtual void SetActive()
+ {
+ if ( m_pHandler && m_pSetActiveHdl )
+ (m_pHandler->*m_pSetActiveHdl)();
+ }
+
+ void CloseRefDialog()
+ {
+ DBG_ASSERT( false, "should not execute here!!!when the edit kill focus, should remove refhandler.\r\n" );
+
+ if ( IsInExecute() )
+ EndDialog( FALSE );
+ else if ( GetStyle() & WB_CLOSEABLE )
+ Close();
+ }
+
+ bool IsRefInputting(){ return m_bRefInputting; }
+
+ virtual void RefInputStart( ScRefEdit* pEdit, ScRefButton* pButton = NULL )
+ {
+ if( !CanInputStart( pEdit ) )
+ return;
+
+ if ( m_pHandler && m_pRefInputStartPreHdl )
+ (m_pHandler->*m_pRefInputStartPreHdl)( pEdit, pButton );
+ m_bRefInputting = true;
+ ScValidationDlgBase::RefInputStart( pEdit, pButton );
+ if ( m_pHandler && m_pRefInputStartPostHdl )
+ (m_pHandler->*m_pRefInputStartPostHdl)( pEdit, pButton );
+ }
+
+ virtual void RefInputDone( BOOL bForced = FALSE )
+ {
+ if( !CanInputDone( bForced ) )
+ return;
+
+ if ( m_pHandler && m_pRefInputDonePreHdl )
+ (m_pHandler->*m_pRefInputDonePreHdl)();
+
+ ScValidationDlgBase::RefInputDone( bForced );
+ m_bRefInputting = false;
+
+ if ( m_pHandler && m_pRefInputDonePostHdl )
+ (m_pHandler->*m_pRefInputDonePostHdl)();
+ }
+
+ BOOL IsChildFocus();
+
+ enum { SLOTID = SID_VALIDITY_REFERENCE };
+
+ BOOL Close();
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+};
+
+
+// ============================================================================
+
+/** The tab page "Criteria" from the Validation dialog. */
+//<!--Modified by PengYunQuan for Validity Cell Range Picker
+//class ScTPValidationValue : public SfxTabPage
+class ScTPValidationValue : public ScRefHandlerCaller, public SfxTabPage
+//-->Modified by PengYunQuan for Validity Cell Range Picker
+{
+public:
+ explicit ScTPValidationValue( Window* pParent, const SfxItemSet& rArgSet );
+ virtual ~ScTPValidationValue();
+
+ static SfxTabPage* Create( Window* pParent, const SfxItemSet& rArgSet );
+ static USHORT* GetRanges();
+
+ virtual BOOL FillItemSet( SfxItemSet& rArgSet );
+ virtual void Reset( const SfxItemSet& rArgSet );
+
+private:
+ void Init();
+
+ String GetFirstFormula() const;
+ String GetSecondFormula() const;
+
+ void SetFirstFormula( const String& rFmlaStr );
+ void SetSecondFormula( const String& rFmlaStr );
+
+ DECL_LINK( SelectHdl, ListBox* );
+ DECL_LINK( CheckHdl, CheckBox* );
+
+ FixedText maFtAllow;
+ ListBox maLbAllow;
+ CheckBox maCbAllow; /// Allow blank cells.
+ CheckBox maCbShow; /// Show selection list in cell.
+ CheckBox maCbSort; /// Sort selection list in cell.
+ FixedText maFtValue;
+ ListBox maLbValue;
+ FixedText maFtMin;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Edit maEdMin;
+ ScRefEdit maEdMin;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ MultiLineEdit maEdList; /// Entries for explicit list
+ FixedText maFtMax;
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //Edit maEdMax;
+ ScRefEdit maEdMax;
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ FixedText maFtHint; /// Hint text for cell range validity.
+
+ String maStrMin;
+ String maStrMax;
+ String maStrValue;
+ String maStrRange;
+ String maStrList;
+ sal_Unicode mcFmlaSep; /// List separator in formulas.
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ DECL_LINK( EditSetFocusHdl, Edit *);
+ DECL_LINK( KillFocusHdl, Window *);
+ void OnClick( Button *pBtn );
+ ScRefEdit *m_pRefEdit;
+ class ScRefButtonEx:public ::ScRefButton
+ {
+ void Click();
+ public:
+ ScRefButtonEx( Window* pParent, const ResId& rResId, ScRefEdit* pEdit = NULL, ScRefHandler *pRefHdlr = NULL ): ::ScRefButton( pParent, rResId, pEdit, pRefHdlr ){}
+ }m_btnRef;
+ friend class ScRefButtonEx;
+ void SetReferenceHdl( const ScRange& , ScDocument* );
+ void SetActiveHdl();
+ void RefInputStartPreHdl( ScRefEdit* pEdit, ScRefButton* pButton );
+ void RefInputDonePreHdl();
+ void RefInputDonePostHdl();
+ ScValidationDlg * GetValidationDlg();
+
+ //TYPEINFO();
+ void TidyListBoxes();
+public:
+ USHORT GetAllowEntryPos();
+ String GetMinText();
+ void SetupRefDlg();
+ void RemoveRefDlg();
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+};
+
+
+//==================================================================
+
+class ScTPValidationHelp : public SfxTabPage
+{
+private:
+ TriStateBox aTsbHelp;
+ FixedLine aFlContent;
+ FixedText aFtTitle;
+ Edit aEdtTitle;
+ FixedText aFtInputHelp;
+ MultiLineEdit aEdInputHelp;
+
+ const SfxItemSet& mrArgSet;
+
+ void Init();
+
+ // Handler ------------------------
+ // DECL_LINK( SelectHdl, ListBox * );
+
+public:
+ ScTPValidationHelp( Window* pParent, const SfxItemSet& rArgSet );
+ ~ScTPValidationHelp();
+
+ static SfxTabPage* Create ( Window* pParent, const SfxItemSet& rArgSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+};
+
+//==================================================================
+
+class ScTPValidationError : public SfxTabPage
+{
+private:
+ TriStateBox aTsbShow;
+ FixedLine aFlContent;
+ FixedText aFtAction;
+ ListBox aLbAction;
+ PushButton aBtnSearch;
+ FixedText aFtTitle;
+ Edit aEdtTitle;
+ FixedText aFtError;
+ MultiLineEdit aEdError;
+
+ const SfxItemSet& mrArgSet;
+
+ void Init();
+
+ // Handler ------------------------
+ DECL_LINK( SelectActionHdl, ListBox * );
+ DECL_LINK( ClickSearchHdl, PushButton * );
+
+public:
+ ScTPValidationError( Window* pParent, const SfxItemSet& rArgSet );
+ ~ScTPValidationError();
+
+ static SfxTabPage* Create ( Window* pParent, const SfxItemSet& rArgSet );
+ static USHORT* GetRanges ();
+ virtual BOOL FillItemSet ( SfxItemSet& rArgSet );
+ virtual void Reset ( const SfxItemSet& rArgSet );
+};
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+inline ScTabViewShell *ScValidationDlg::GetTabViewShell()
+{
+ return m_pTabVwSh;
+}
+
+inline ScValidationDlg * ScValidationDlg::Find1AliveObject( Window *pAncestor )
+{
+ return static_cast<ScValidationDlg *>( SC_MOD()->Find1RefWindow( SLOTID, pAncestor ) );
+}
+//-->Added by PengYunQuan for Validity Cell Range Picker
+#endif // SC_VALIDATE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
new file mode 100644
index 000000000000..bd3893afb3d4
--- /dev/null
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -0,0 +1,570 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VIEWDATA_HXX
+#define SC_VIEWDATA_HXX
+
+#include <svx/zoomitem.hxx>
+#include "scdllapi.h"
+#include "viewopti.hxx"
+#include "markdata.hxx"
+
+
+// ---------------------------------------------------------------------------
+
+#define SC_SLIDER_SIZE 2
+#define SC_SMALL3DSHADOW COL_BLACK
+#define SC_SIZE_NONE 65535
+const SCCOL SC_TABSTART_NONE = SCCOL_MAX;
+
+#define SC_FILL_NONE 0
+#define SC_FILL_FILL 1
+#define SC_FILL_EMBED_LT 2
+#define SC_FILL_EMBED_RB 3
+#define SC_FILL_MATRIX 4
+
+enum ScSplitMode { SC_SPLIT_NONE = 0, SC_SPLIT_NORMAL, SC_SPLIT_FIX };
+
+enum ScSplitPos { SC_SPLIT_TOPLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_BOTTOMRIGHT };
+enum ScHSplitPos { SC_SPLIT_LEFT, SC_SPLIT_RIGHT };
+enum ScVSplitPos { SC_SPLIT_TOP, SC_SPLIT_BOTTOM };
+
+inline ScHSplitPos WhichH( ScSplitPos ePos );
+inline ScVSplitPos WhichV( ScSplitPos ePos );
+inline ScSplitPos Which( ScHSplitPos eHPos );
+inline ScSplitPos Which( ScVSplitPos eVPos );
+
+// Bildschirmverhalten bei Cursorbewegungen:
+enum ScFollowMode { SC_FOLLOW_NONE, SC_FOLLOW_LINE, SC_FOLLOW_FIX, SC_FOLLOW_JUMP };
+
+// Mausmodi um Bereiche zu selektieren
+enum ScRefType { SC_REFTYPE_NONE, SC_REFTYPE_REF, SC_REFTYPE_FILL,
+ SC_REFTYPE_EMBED_LT, SC_REFTYPE_EMBED_RB };
+
+/** States GetSimpleArea() returns for the underlying selection marks, so the
+ caller can react if the result is not of type SC_MARK_SIMPLE. */
+enum ScMarkType
+{
+ SC_MARK_NONE = 0, // Not returned by GetSimpleArea(), used internally.
+ // Nothing marked always results in the
+ // current cursor position being selected and a simple mark.
+ SC_MARK_SIMPLE = 1, // Simple rectangular area marked, no filtered rows.
+ SC_MARK_FILTERED = 2, // At least one mark contains filtered rows.
+ SC_MARK_SIMPLE_FILTERED = // Simple rectangular area marked containing filtered rows.
+ SC_MARK_SIMPLE |
+ SC_MARK_FILTERED, // 3
+ SC_MARK_MULTI = 4 // Multiple selection marks.
+ /* TODO: if filtered multi-selection was implemented, this would be the value to use. */
+#if 0
+ ,
+ SC_MARK_MULTI_FILTERED = // Multiple selection marks containing filtered rows.
+ SC_MARK_MULTI |
+ SC_MARK_FILTERED // 6
+#endif
+};
+
+enum ScPasteFlags
+{
+ SC_PASTE_NONE = 0, // No flags specified
+ SC_PASTE_MODE = 1, // Enable paste-mode
+ SC_PASTE_BORDER = 2, // Show a border around the source cells
+};
+
+class ScDocShell;
+class ScDocument;
+class ScDBFunc;
+class ScTabViewShell;
+class ScDrawView;
+class ScEditEngineDefaulter;
+class EditView;
+class EditStatus;
+class Outliner;
+class Window;
+class SfxObjectShell;
+class SfxBindings;
+class SfxDispatcher;
+class ScPatternAttr;
+class ScRangeListRef;
+class ScExtDocOptions;
+class ScViewData;
+
+//--------------------------------------------------------------------------
+
+class ScViewDataTable // Daten pro Tabelle
+{
+friend class ScViewData;
+private:
+ SvxZoomType eZoomType; // selected zoom type (normal view)
+ Fraction aZoomX; // selected zoom X
+ Fraction aZoomY; // selected zoom Y (displayed)
+ Fraction aPageZoomX; // zoom in page break preview mode
+ Fraction aPageZoomY;
+
+ long nTPosX[2]; // MapMode - Offset (Twips)
+ long nTPosY[2];
+ long nMPosX[2]; // MapMode - Offset (1/100 mm)
+ long nMPosY[2];
+ long nPixPosX[2]; // Offset in Pixeln
+ long nPixPosY[2];
+ long nHSplitPos;
+ long nVSplitPos;
+
+ ScSplitMode eHSplitMode;
+ ScSplitMode eVSplitMode;
+ ScSplitPos eWhichActive;
+
+ SCCOL nFixPosX; // Zellposition des Splitters beim Fixieren
+ SCROW nFixPosY;
+
+ SCCOL nCurX;
+ SCROW nCurY;
+ SCCOL nOldCurX;
+ SCROW nOldCurY;
+ SCCOL nPosX[2];
+ SCROW nPosY[2];
+
+ bool bShowGrid; // per-sheet show grid-lines option.
+
+ BOOL bOldCurValid; // "virtuelle" Cursorpos. bei zusammengefassten
+
+ ScViewDataTable();
+ ~ScViewDataTable();
+
+ void WriteUserDataSequence(
+ com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings,
+ const ScViewData& rViewData, SCTAB nTab );
+
+ void ReadUserDataSequence(
+ const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings,
+ ScViewData& rViewData, SCTAB nTab, bool& rHasZoom);
+};
+
+// ---------------------------------------------------------------------------
+
+class SC_DLLPUBLIC ScViewData
+{
+private:
+ double nPPTX, nPPTY; // Scaling-Faktoren
+
+ ScViewDataTable* pTabData[MAXTABCOUNT];
+ ScViewDataTable* pThisTab; // Daten der angezeigten Tabelle
+ ScDocShell* pDocShell;
+ ScDocument* pDoc;
+ ScDBFunc* pView;
+ ScTabViewShell* pViewShell;
+ EditView* pEditView[4]; // gehoert dem Fenster
+ ScViewOptions* pOptions;
+ EditView* pSpellingView;
+
+ ScMarkData aMarkData;
+
+ long nEditMargin;
+
+ Size aScenButSize; // Groesse eines Szenario-Buttons
+
+ Size aScrSize;
+ MapMode aLogicMode; // skalierter 1/100mm-MapMode
+
+ SvxZoomType eDefZoomType; // default zoom and type for missing TabData
+ Fraction aDefZoomX;
+ Fraction aDefZoomY;
+ Fraction aDefPageZoomX; // zoom in page break preview mode
+ Fraction aDefPageZoomY;
+
+ ScRefType eRefType;
+
+ SCTAB nTabNo; // angezeigte Tabelle
+ SCTAB nRefTabNo; // Tabelle auf die sich RefInput bezieht
+ SCCOL nRefStartX;
+ SCROW nRefStartY;
+ SCTAB nRefStartZ;
+ SCCOL nRefEndX;
+ SCROW nRefEndY;
+ SCTAB nRefEndZ;
+ SCCOL nFillStartX; // Fill-Cursor
+ SCROW nFillStartY;
+ SCCOL nFillEndX;
+ SCROW nFillEndY;
+ SCCOL nEditCol; // Position dazu
+ SCROW nEditRow;
+ SCCOL nEditStartCol;
+ SCCOL nEditEndCol; // Ende der Edit-View
+ SCROW nEditEndRow;
+ SCCOL nTabStartCol; // fuer Enter nach Tab
+ ScRange aDelRange; // fuer AutoFill-Loeschen
+
+ ScPasteFlags nPasteFlags;
+
+ ScSplitPos eEditActivePart; // the part that was active when edit mode was started
+ BOOL bEditActive[4]; // aktiv?
+ BOOL bActive; // aktives Fenster ?
+ BOOL bIsRefMode; // Referenzeingabe
+ BOOL bDelMarkValid; // nur gueltig bei SC_REFTYPE_FILL
+ BYTE nFillMode; // Modus
+ BOOL bPagebreak; // Seitenumbruch-Vorschaumodus
+
+ BOOL bSelCtrlMouseClick; // special selection handling for ctrl-mouse-click
+
+ SC_DLLPRIVATE DECL_LINK (EmptyEditHdl, EditStatus*);
+ SC_DLLPRIVATE DECL_LINK (EditEngineHdl, EditStatus*);
+
+ SC_DLLPRIVATE void CalcPPT();
+ SC_DLLPRIVATE void CreateTabData( SCTAB nNewTab );
+ SC_DLLPRIVATE void CreateTabData( std::vector< SCTAB >& rvTabs );
+ SC_DLLPRIVATE void CreateSelectedTabData();
+
+public:
+ ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh );
+ ScViewData( const ScViewData& rViewData );
+ ~ScViewData();
+
+ void InitData( ScDocument* pDocument );
+
+ ScDocShell* GetDocShell() const { return pDocShell; }
+ ScDBFunc* GetView() const { return pView; }
+ ScTabViewShell* GetViewShell() const { return pViewShell; }
+
+ SfxObjectShell* GetSfxDocShell() const;
+ SfxBindings& GetBindings(); // from ViewShell's ViewFrame
+ SfxDispatcher& GetDispatcher(); // from ViewShell's ViewFrame
+
+ ScMarkData& GetMarkData() { return aMarkData; }
+ const ScMarkData& GetMarkData() const { return aMarkData; }
+
+ Window* GetDialogParent(); // von tabvwsh weitergeleitet
+ Window* GetActiveWin(); // von View
+ ScDrawView* GetScDrawView(); // von View
+ BOOL IsMinimized(); // von View
+
+ void UpdateInputHandler( BOOL bForce = FALSE, BOOL bStopEditing = TRUE );
+
+ void WriteUserData(String& rData);
+ void ReadUserData(const String& rData);
+ void WriteExtOptions( ScExtDocOptions& rOpt ) const;
+ void ReadExtOptions( const ScExtDocOptions& rOpt );
+ void WriteUserDataSequence(com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings);
+ void ReadUserDataSequence(const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings);
+
+ ScDocument* GetDocument() const;
+
+ void SetViewShell( ScTabViewShell* pViewSh );
+
+ BOOL IsActive() const { return bActive; }
+ void Activate(BOOL bActivate) { bActive = bActivate; }
+
+ void UpdateThis();
+
+ void InsertTab( SCTAB nTab );
+ void DeleteTab( SCTAB nTab );
+ void CopyTab( SCTAB nSrcTab, SCTAB nDestTab );
+ void MoveTab( SCTAB nSrcTab, SCTAB nDestTab );
+
+ SCTAB GetRefTabNo() const { return nRefTabNo; }
+ void SetRefTabNo( SCTAB nNewTab ) { nRefTabNo = nNewTab; }
+
+ SCTAB GetTabNo() const { return nTabNo; }
+ ScSplitPos GetActivePart() const { return pThisTab->eWhichActive; }
+ SCCOL GetPosX( ScHSplitPos eWhich ) const { return pThisTab->nPosX[eWhich]; }
+ SCROW GetPosY( ScVSplitPos eWhich ) const { return pThisTab->nPosY[eWhich]; }
+ SCCOL GetCurX() const { return pThisTab->nCurX; }
+ SCROW GetCurY() const { return pThisTab->nCurY; }
+ BOOL HasOldCursor() const { return pThisTab->bOldCurValid; }
+ SCCOL GetOldCurX() const;
+ SCROW GetOldCurY() const;
+ ScSplitMode GetHSplitMode() const { return pThisTab->eHSplitMode; }
+ ScSplitMode GetVSplitMode() const { return pThisTab->eVSplitMode; }
+ long GetHSplitPos() const { return pThisTab->nHSplitPos; }
+ long GetVSplitPos() const { return pThisTab->nVSplitPos; }
+ SCCOL GetFixPosX() const { return pThisTab->nFixPosX; }
+ SCROW GetFixPosY() const { return pThisTab->nFixPosY; }
+ BOOL IsPagebreakMode() const { return bPagebreak; }
+ bool IsPasteMode() const { return nPasteFlags & SC_PASTE_MODE; }
+ bool ShowPasteSource() const { return nPasteFlags & SC_PASTE_BORDER; }
+
+ void SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX );
+ void SetPosY( ScVSplitPos eWhich, SCROW nNewPosY );
+ void SetCurX( SCCOL nNewCurX ) { pThisTab->nCurX = nNewCurX; }
+ void SetCurY( SCROW nNewCurY ) { pThisTab->nCurY = nNewCurY; }
+ void SetOldCursor( SCCOL nNewX, SCROW nNewY );
+ void ResetOldCursor();
+ void SetHSplitMode( ScSplitMode eMode ) { pThisTab->eHSplitMode = eMode; }
+ void SetVSplitMode( ScSplitMode eMode ) { pThisTab->eVSplitMode = eMode; }
+ void SetHSplitPos( long nPos ) { pThisTab->nHSplitPos = nPos; }
+ void SetVSplitPos( long nPos ) { pThisTab->nVSplitPos = nPos; }
+ void SetFixPosX( SCCOL nPos ) { pThisTab->nFixPosX = nPos; }
+ void SetFixPosY( SCROW nPos ) { pThisTab->nFixPosY = nPos; }
+ void SetPagebreakMode( BOOL bSet );
+ void SetPasteMode ( ScPasteFlags nFlags ) { nPasteFlags = nFlags; }
+
+ void SetZoomType( SvxZoomType eNew, BOOL bAll );
+ void SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs );
+ void SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs );
+ void SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll );
+ void RefreshZoom();
+
+ void SetSelCtrlMouseClick( BOOL bTmp ) { bSelCtrlMouseClick = bTmp; }
+
+ SvxZoomType GetZoomType() const { return pThisTab->eZoomType; }
+ const Fraction& GetZoomX() const { return bPagebreak ? pThisTab->aPageZoomX : pThisTab->aZoomX; }
+ const Fraction& GetZoomY() const { return bPagebreak ? pThisTab->aPageZoomY : pThisTab->aZoomY; }
+
+ void SetShowGrid( bool bShow );
+ bool GetShowGrid() const { return pThisTab->bShowGrid; }
+
+ const MapMode& GetLogicMode( ScSplitPos eWhich );
+ const MapMode& GetLogicMode(); // Offset 0
+
+ long GetTPosX( ScHSplitPos eWhich ) const { return pThisTab->nTPosX[eWhich]; }
+ long GetTPosY( ScVSplitPos eWhich ) const { return pThisTab->nTPosY[eWhich]; }
+
+ double GetPPTX() const { return nPPTX; }
+ double GetPPTY() const { return nPPTY; }
+
+ ScMarkType GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
+ SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const;
+ ScMarkType GetSimpleArea( ScRange& rRange ) const;
+ /// May modify rNewMark using MarkToSimple().
+ ScMarkType GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const;
+ void GetMultiArea( ScRangeListRef& rRange ) const;
+
+ BOOL SimpleColMarked();
+ BOOL SimpleRowMarked();
+
+ BOOL IsMultiMarked();
+
+ void SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow );
+ void SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ BYTE nMode );
+ void GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
+ SCCOL& rEndCol, SCROW& rEndRow );
+ void ResetFillMode();
+ BOOL IsAnyFillMode() { return nFillMode != SC_FILL_NONE; }
+ BOOL IsFillMode() { return nFillMode == SC_FILL_FILL; }
+ BYTE GetFillMode() { return nFillMode; }
+
+ // TRUE: Zelle ist zusammengefasst
+ BOOL GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix );
+ BOOL GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
+ SCsCOL& rPosX, SCsROW& rPosY,
+ BOOL bTestMerge = TRUE, BOOL bRepair = FALSE,
+ BOOL bNextIfLarge = TRUE );
+ void GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
+ SCsCOL nPosX, SCsROW nPosY, BOOL& rLeft, BOOL& rTop );
+
+ BOOL IsRefMode() const { return bIsRefMode; }
+ ScRefType GetRefType() const { return eRefType; }
+ SCCOL GetRefStartX() const { return nRefStartX; }
+ SCROW GetRefStartY() const { return nRefStartY; }
+ SCTAB GetRefStartZ() const { return nRefStartZ; }
+ SCCOL GetRefEndX() const { return nRefEndX; }
+ SCROW GetRefEndY() const { return nRefEndY; }
+ SCTAB GetRefEndZ() const { return nRefEndZ; }
+
+ void SetRefMode( BOOL bNewMode, ScRefType eNewType )
+ { bIsRefMode = bNewMode; eRefType = eNewType; }
+
+ void SetRefStart( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
+ { nRefStartX = nNewX; nRefStartY = nNewY; nRefStartZ = nNewZ; }
+ void SetRefEnd( SCCOL nNewX, SCROW nNewY, SCTAB nNewZ )
+ { nRefEndX = nNewX; nRefEndY = nNewY; nRefEndZ = nNewZ; }
+
+ void ResetDelMark() { bDelMarkValid = FALSE; }
+ void SetDelMark( const ScRange& rRange )
+ { aDelRange = rRange; bDelMarkValid = TRUE; }
+
+ BOOL GetDelMark( ScRange& rRange ) const
+ { rRange = aDelRange; return bDelMarkValid; }
+
+ inline void GetMoveCursor( SCCOL& rCurX, SCROW& rCurY );
+
+ const ScViewOptions& GetOptions() const { return *pOptions; }
+ void SetOptions( const ScViewOptions& rOpt );
+
+ BOOL IsGridMode () const { return pOptions->GetOption( VOPT_GRID ); }
+ void SetGridMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_GRID, bNewMode ); }
+ BOOL IsSyntaxMode () const { return pOptions->GetOption( VOPT_SYNTAX ); }
+ void SetSyntaxMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_SYNTAX, bNewMode ); }
+ BOOL IsHeaderMode () const { return pOptions->GetOption( VOPT_HEADER ); }
+ void SetHeaderMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_HEADER, bNewMode ); }
+ BOOL IsTabMode () const { return pOptions->GetOption( VOPT_TABCONTROLS ); }
+ void SetTabMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_TABCONTROLS, bNewMode ); }
+ BOOL IsVScrollMode () const { return pOptions->GetOption( VOPT_VSCROLL ); }
+ void SetVScrollMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_VSCROLL, bNewMode ); }
+ BOOL IsHScrollMode () const { return pOptions->GetOption( VOPT_HSCROLL ); }
+ void SetHScrollMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_HSCROLL, bNewMode ); }
+ BOOL IsOutlineMode () const { return pOptions->GetOption( VOPT_OUTLINER ); }
+ void SetOutlineMode ( BOOL bNewMode ) { pOptions->SetOption( VOPT_OUTLINER, bNewMode ); }
+
+ void KillEditView();
+ void ResetEditView();
+ void SetEditEngine( ScSplitPos eWhich,
+ ScEditEngineDefaulter* pNewEngine,
+ Window* pWin, SCCOL nNewX, SCROW nNewY );
+ void GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow );
+ BOOL HasEditView( ScSplitPos eWhich ) const
+ { return pEditView[eWhich] && bEditActive[eWhich]; }
+ EditView* GetEditView( ScSplitPos eWhich ) const
+ { return pEditView[eWhich]; }
+
+ void EditGrowX();
+ void EditGrowY( BOOL bInitial = FALSE );
+
+ ScSplitPos GetEditActivePart() const { return eEditActivePart; }
+ SCCOL GetEditViewCol() const { return nEditCol; }
+ SCROW GetEditViewRow() const { return nEditRow; }
+ SCCOL GetEditStartCol() const { return nEditStartCol; }
+ SCROW GetEditStartRow() const { return nEditRow; } // never editing above the cell
+ SCCOL GetEditEndCol() const { return nEditEndCol; }
+ SCROW GetEditEndRow() const { return nEditEndRow; }
+
+ Rectangle GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY, Window* pWin,
+ const ScPatternAttr* pPattern, BOOL bForceToTop );
+
+ void SetTabNo( SCTAB nNewTab );
+ void SetActivePart( ScSplitPos eNewActive );
+
+ Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
+ BOOL bAllowNeg = FALSE ) const;
+ Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const;
+ Point GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const;
+
+ SCCOL CellsAtX( SCsCOL nPosX, SCsCOL nDir, ScHSplitPos eWhichX, USHORT nScrSizeY = SC_SIZE_NONE ) const;
+ SCROW CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHORT nScrSizeX = SC_SIZE_NONE ) const;
+
+ SCCOL VisibleCellsX( ScHSplitPos eWhichX ) const; // angezeigte komplette Zellen
+ SCROW VisibleCellsY( ScVSplitPos eWhichY ) const;
+ SCCOL PrevCellsX( ScHSplitPos eWhichX ) const; // Zellen auf der vorgehenden Seite
+ SCROW PrevCellsY( ScVSplitPos eWhichY ) const;
+
+ BOOL IsOle();
+ void SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 );
+ void SetScreen( const Rectangle& rVisArea );
+ void SetScreenPos( const Point& rVisAreaStart );
+
+ void UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY );
+
+ Size GetScrSize() const { return aScrSize; }
+
+ void RecalcPixPos();
+ Point GetPixPos( ScSplitPos eWhich ) const
+ { return Point( pThisTab->nPixPosX[WhichH(eWhich)],
+ pThisTab->nPixPosY[WhichV(eWhich)] ); }
+ void SetSpellingView( EditView* pSpView) { pSpellingView = pSpView; }
+ EditView* GetSpellingView() const { return pSpellingView; }
+
+ void UpdateOutlinerFlags( Outliner& rOutl ) const;
+
+ Point GetMousePosPixel();
+
+ BOOL UpdateFixX(SCTAB nTab = MAXTAB+1);
+ BOOL UpdateFixY(SCTAB nTab = MAXTAB+1);
+
+ SCCOL GetTabStartCol() const { return nTabStartCol; }
+ void SetTabStartCol(SCCOL nNew) { nTabStartCol = nNew; }
+
+ ScAddress GetCurPos() const;
+
+ const Size& GetScenButSize() const { return aScenButSize; }
+ void SetScenButSize(const Size& rNew) { aScenButSize = rNew; }
+
+ BOOL IsSelCtrlMouseClick() { return bSelCtrlMouseClick; }
+
+ static inline long ToPixel( USHORT nTwips, double nFactor );
+
+ /** while (rScrY <= nEndPixels && rPosY <= nEndRow) add pixels of row
+ heights converted with nPPTY to rScrY, optimized for row height
+ segments. Upon return rPosY is the last row evaluated <= nEndRow, rScrY
+ may be > nEndPixels!
+ */
+ static void AddPixelsWhile( long & rScrY, long nEndPixels,
+ SCROW & rPosY, SCROW nEndRow, double nPPTY,
+ const ScDocument * pDoc, SCTAB nTabNo );
+
+ /** while (rScrY <= nEndPixels && rPosY >= nStartRow) add pixels of row
+ heights converted with nPPTY to rScrY, optimized for row height
+ segments. Upon return rPosY is the last row evaluated >= nStartRow,
+ rScrY may be > nEndPixels!
+ */
+ static void AddPixelsWhileBackward( long & rScrY, long nEndPixels,
+ SCROW & rPosY, SCROW nStartRow, double nPPTY,
+ const ScDocument * pDoc, SCTAB nTabNo );
+};
+
+
+// ---------------------------------------------------------------------------
+
+inline long ScViewData::ToPixel( USHORT nTwips, double nFactor )
+{
+ long nRet = (long)( nTwips * nFactor );
+ if ( !nRet && nTwips )
+ nRet = 1;
+ return nRet;
+}
+
+inline void ScViewData::GetMoveCursor( SCCOL& rCurX, SCROW& rCurY )
+{
+ if ( bIsRefMode )
+ {
+ rCurX = nRefEndX;
+ rCurY = nRefEndY;
+ }
+ else
+ {
+ rCurX = GetCurX();
+ rCurY = GetCurY();
+ }
+}
+
+inline ScHSplitPos WhichH( ScSplitPos ePos )
+{
+ return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_BOTTOMLEFT) ?
+ SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
+}
+
+inline ScVSplitPos WhichV( ScSplitPos ePos )
+{
+ return (ePos==SC_SPLIT_TOPLEFT || ePos==SC_SPLIT_TOPRIGHT) ?
+ SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
+}
+
+inline ScSplitPos Which( ScHSplitPos eHPos )
+{
+ return (eHPos==SC_SPLIT_LEFT) ?
+ SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+}
+
+inline ScSplitPos Which( ScVSplitPos eVPos )
+{
+ return (eVPos==SC_SPLIT_TOP) ?
+ SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
+}
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
new file mode 100644
index 000000000000..0cacc543308d
--- /dev/null
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -0,0 +1,381 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VIEWFUNC_HXX
+#define SC_VIEWFUNC_HXX
+
+#include "tabview.hxx"
+
+#include "tabbgcolor.hxx"
+
+#ifndef _SVSTDARR_SHORTS
+#define _SVSTDARR_SHORTS
+#include <svl/svstdarr.hxx>
+
+#endif
+
+#ifndef _SVSTDARR_STRINGS
+
+#define _SVSTDARR_STRINGS
+#include <svl/svstdarr.hxx>
+
+#endif
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+
+class ScPatternAttr;
+class ScAutoFormatData;
+class SvxSearchItem;
+class SfxItemSet;
+class SvxBorderLine;
+class SvxBoxItem;
+class SvxBoxInfoItem;
+class SfxStyleSheet;
+class SfxPoolItem;
+class EditTextObject;
+struct ScSolveParam;
+struct ScTabOpParam;
+class ScPostIt;
+class ScConditionalFormat;
+class ScValidationData;
+class ScConversionParam;
+class SdrModel;
+class Graphic;
+class Exchange;
+class ScRangeList;
+class SvxHyperlinkItem;
+class ScTransferObj;
+class ScTableProtection;
+
+namespace com { namespace sun { namespace star { namespace datatransfer { class XTransferable; } } } }
+
+//==================================================================
+
+class ScViewFunc : public ScTabView
+{
+private:
+ ScAddress aFormatSource; // fuer automatisches Erweitern von Formatierung
+ ScRange aFormatArea;
+ BOOL bFormatValid;
+
+public:
+ ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
+ ~ScViewFunc();
+
+ const ScPatternAttr* GetSelectionPattern ();
+ void GetSelectionFrame ( SvxBoxItem& rLineOuter,
+ SvxBoxInfoItem& rLineInner );
+
+ BYTE GetSelectionScriptType();
+
+ BOOL GetAutoSumArea(ScRangeList& rRangeList);
+ void EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr);
+ bool AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue );
+ String GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr );
+
+ void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
+ BOOL bRecord = TRUE, const EditTextObject* pData = NULL );
+ void EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue );
+ void EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextObject* pData,
+ BOOL bRecord = TRUE, BOOL bTestSimple = FALSE );
+
+ void EnterMatrix( const String& rString );
+ void EnterBlock( const String& rString, const EditTextObject* pData );
+
+ void EnterDataAtCursor( const String& rString ); //! nicht benutzt ?
+
+ SC_DLLPUBLIC void CutToClip( ScDocument* pClipDoc = NULL, BOOL bIncludeObjects = FALSE );
+ SC_DLLPUBLIC BOOL CopyToClip( ScDocument* pClipDoc = NULL, BOOL bCut = FALSE, BOOL bApi = FALSE,
+ BOOL bIncludeObjects = FALSE, BOOL bStopEdit = TRUE );
+ SC_DLLPUBLIC BOOL CopyToClip( ScDocument* pClipDoc, const ScRange& rRange, BOOL bCut = FALSE,
+ BOOL bApi = FALSE, BOOL bIncludeObjects = FALSE, BOOL bStopEdit = TRUE );
+ ScTransferObj* CopyToTransferable();
+ SC_DLLPUBLIC BOOL PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
+ USHORT nFunction = PASTE_NOFUNC, BOOL bSkipEmpty = FALSE,
+ BOOL bTranspose = FALSE, BOOL bAsLink = FALSE,
+ InsCellCmd eMoveMode = INS_NONE,
+ USHORT nUndoExtraFlags = IDF_NONE,
+ BOOL bAllowDialogs = FALSE );
+
+ void FillTab( USHORT nFlags, USHORT nFunction, BOOL bSkipEmpty, BOOL bAsLink );
+
+ SC_DLLPUBLIC void PasteFromSystem();
+ SC_DLLPUBLIC BOOL PasteFromSystem( ULONG nFormatId, BOOL bApi = FALSE );
+ void PasteFromTransferable( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
+
+ void PasteDraw();
+ void PasteDraw( const Point& rLogicPos, SdrModel* pModel,
+ BOOL bGroup = FALSE, BOOL bSameDocClipboard = FALSE );
+
+ BOOL PasteOnDrawObject( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
+ SdrObject* pHitObj, BOOL bLink );
+
+ BOOL PasteDataFormat( ULONG nFormatId,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
+ SCCOL nPosX, SCROW nPosY, Point* pLogicPos = NULL,
+ BOOL bLink = FALSE, BOOL bAllowDialogs = FALSE );
+
+ BOOL PasteFile( const Point&, const String&, BOOL bLink=FALSE );
+ BOOL PasteObject( const Point&, const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >&, const Size* = NULL, const Graphic* = NULL, const ::rtl::OUString& = ::rtl::OUString(), sal_Int64 nAspect = ::com::sun::star::embed::Aspects::MSOLE_CONTENT );
+ BOOL PasteBitmap( const Point&, const Bitmap& );
+ BOOL PasteMetaFile( const Point&, const GDIMetaFile& );
+ BOOL PasteGraphic( const Point& rPos, const Graphic& rGraphic,
+ const String& rFile, const String& rFilter );
+ BOOL PasteBookmark( ULONG nFormatId,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
+ SCCOL nPosX, SCROW nPosY );
+ BOOL PasteDDE( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
+
+ BOOL ApplyGraphicToObject( SdrObject* pObject, const Graphic& rGraphic );
+
+ void InsertBookmark( const String& rDescription, const String& rURL,
+ SCCOL nPosX, SCROW nPosY, const String* pTarget = NULL,
+ BOOL bTryReplace = FALSE );
+ BOOL HasBookmarkAtCursor( SvxHyperlinkItem* pContent );
+
+ long DropRequestHdl( Exchange* pExchange );
+ BOOL MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
+ BOOL bCut, BOOL bRecord, BOOL bPaint, BOOL bApi );
+
+ BOOL LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, BOOL bApi );
+
+ void CreateNames( USHORT nFlags );
+ USHORT GetCreateNameFlags();
+ void InsertNameList();
+ BOOL InsertName( const String& rName, const String& rSymbol,
+ const String& rType );
+
+ void ApplyAttributes( const SfxItemSet* pDialogSet, const SfxItemSet* pOldSet,
+ BOOL bRecord = TRUE );
+ void ApplyAttr( const SfxPoolItem& rAttrItem );
+ void ApplySelectionPattern( const ScPatternAttr& rAttr,
+ BOOL bRecord = TRUE,
+ BOOL bCursorOnly = FALSE );
+ void ApplyPatternLines( const ScPatternAttr& rAttr,
+ const SvxBoxItem* pNewOuter,
+ const SvxBoxInfoItem* pNewInner, BOOL bRecord = TRUE );
+
+ void ApplyUserItemSet( const SfxItemSet& rItemSet );
+
+ const SfxStyleSheet* GetStyleSheetFromMarked();
+ void SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet,
+ BOOL bRecord = TRUE );
+ void RemoveStyleSheetInUse( SfxStyleSheet* pStyleSheet );
+ void UpdateStyleSheetInUse( SfxStyleSheet* pStyleSheet );
+
+ void SetNumberFormat( short nFormatType, ULONG nAdd = 0 );
+ void SetNumFmtByStr( const String& rCode );
+ void ChangeNumFmtDecimals( BOOL bIncrement );
+
+ void SetConditionalFormat( const ScConditionalFormat& rNew );
+ void SetValidation( const ScValidationData& rNew );
+
+ void ChangeIndent( BOOL bIncrement );
+
+ void ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect );
+
+ void Protect( SCTAB nTab, const String& rPassword );
+ BOOL Unprotect( SCTAB nTab, const String& rPassword );
+
+ void DeleteCells( DelCellCmd eCmd, BOOL bRecord = TRUE );
+ BOOL InsertCells( InsCellCmd eCmd, BOOL bRecord = TRUE, BOOL bPartOfPaste = FALSE );
+ void DeleteMulti( BOOL bRows, BOOL bRecord = TRUE );
+
+ void DeleteContents( USHORT nFlags, BOOL bRecord = TRUE );
+
+ void SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
+ ScSizeMode eMode, USHORT nSizeTwips,
+ BOOL bRecord = TRUE, BOOL bPaint = TRUE,
+ ScMarkData* pMarkData = NULL );
+ void SetMarkedWidthOrHeight( BOOL bWidth, ScSizeMode eMode, USHORT nSizeTwips,
+ BOOL bRecord = TRUE, BOOL bPaint = TRUE );
+ void ShowMarkedColumns( BOOL bShow, BOOL bRecord = TRUE );
+ void ShowMarkedRows( BOOL bShow, BOOL bRecord = TRUE );
+
+ BOOL AdjustBlockHeight( BOOL bPaint = TRUE, ScMarkData* pMarkData = NULL );
+ BOOL AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, BOOL bPaint = TRUE );
+
+ void ModifyCellSize( ScDirection eDir, BOOL bOptimal );
+
+ SC_DLLPUBLIC void InsertPageBreak( BOOL bColumn, BOOL bRecord = TRUE,
+ const ScAddress* pPos = NULL,
+ BOOL bSetModified = TRUE );
+ SC_DLLPUBLIC void DeletePageBreak( BOOL bColumn, BOOL bRecord = TRUE,
+ const ScAddress* pPos = NULL,
+ BOOL bSetModified = TRUE );
+
+ void RemoveManualBreaks();
+
+ void SetPrintZoom(USHORT nScale, USHORT nPages);
+ void AdjustPrintZoom();
+
+ BOOL TestMergeCells();
+ BOOL TestRemoveMerge();
+
+ BOOL MergeCells( BOOL bApi, BOOL& rDoContents, BOOL bRecord = TRUE, BOOL bCenter = FALSE );
+ BOOL RemoveMerge( BOOL bRecord = TRUE );
+
+ void FillSimple( FillDir eDir, BOOL bRecord = TRUE );
+ void FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
+ double fStart, double fStep, double fMax, BOOL bRecord = TRUE );
+ void FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
+ SCCOL nEndCol, SCROW nEndRow, ULONG nCount, BOOL bRecord = TRUE );
+ void FillCrossDblClick();
+
+ void TransliterateText( sal_Int32 nType );
+
+ ScAutoFormatData* CreateAutoFormatData();
+ void AutoFormat( USHORT nFormatNo, BOOL bRecord = TRUE );
+
+ void SearchAndReplace( const SvxSearchItem* pSearchItem,
+ BOOL bAddUndo, BOOL bIsApi );
+
+ void Solve( const ScSolveParam& rParam );
+ void TabOp( const ScTabOpParam& rParam, BOOL bRecord = TRUE );
+
+ BOOL InsertTable( const String& rName, SCTAB nTabNr, BOOL bRecord = TRUE );
+ BOOL InsertTables(SvStrings *pNames, SCTAB nTab, SCTAB nCount, BOOL bRecord = TRUE);
+
+
+ BOOL AppendTable( const String& rName, BOOL bRecord = TRUE );
+
+ BOOL DeleteTable( SCTAB nTabNr, BOOL bRecord = TRUE );
+ BOOL DeleteTables(const SvShorts &TheTabs, BOOL bRecord = TRUE );
+
+ BOOL RenameTable( const String& rName, SCTAB nTabNr );
+ void MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy );
+ void ImportTables( ScDocShell* pSrcShell,
+ SCTAB nCount, const SCTAB* pSrcTabs,
+ BOOL bLink,SCTAB nTab);
+
+ bool SetTabBgColor( const Color& rColor, SCTAB nTabNr );
+ bool SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList );
+
+ void InsertTableLink( const String& rFile,
+ const String& rFilter, const String& rOptions,
+ const String& rTabName );
+ void InsertAreaLink( const String& rFile,
+ const String& rFilter, const String& rOptions,
+ const String& rSource, ULONG nRefresh );
+
+ void ShowTable( const String& rName );
+ void HideTable( SCTAB nTabNr );
+
+ void MakeScenario( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags );
+ void ExtendScenario();
+ void UseScenario( const String& rName );
+
+ void InsertSpecialChar( const String& rStr, const Font& rFont );
+
+ void InsertDummyObject();
+ void InsertOleObject();
+
+ void InsertDraw();
+
+ void SetSelectionFrameLines( const SvxBorderLine* pLine,
+ BOOL bColorOnly );
+
+ void SetNoteText( const ScAddress& rPos, const String& rNoteText );
+ void ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate );
+ void DoRefConversion( BOOL bRecord = TRUE );
+
+ void DoHangulHanjaConversion( BOOL bRecord = TRUE );
+ void DoThesaurus( BOOL bRecord = TRUE );
+
+ /** Generic implementation of sheet conversion functions. */
+ void DoSheetConversion( const ScConversionParam& rParam, BOOL bRecord = TRUE );
+
+ void SetPrintRanges( BOOL bEntireSheet,
+ const String* pPrint,
+ const String* pRepCol, const String* pRepRow,
+ BOOL bAddPrint );
+
+ void DetectiveAddPred();
+ void DetectiveDelPred();
+ void DetectiveAddSucc();
+ void DetectiveDelSucc();
+ void DetectiveAddError();
+ void DetectiveMarkInvalid();
+ void DetectiveDelAll();
+ void DetectiveRefresh();
+ void DetectiveMarkPred();
+ void DetectiveMarkSucc();
+
+ void InsertCurrentTime(short nCellFmt, const ::rtl::OUString& rUndoStr);
+
+ void ShowNote( bool bShow = true );
+ inline void HideNote() { ShowNote( false ); }
+ void EditNote();
+
+ void ForgetFormatArea() { bFormatValid = FALSE; }
+ BOOL SelectionEditable( BOOL* pOnlyNotBecauseOfMatrix = NULL );
+
+ // Amelia Wang
+ SC_DLLPUBLIC void DataFormPutData( SCROW nCurrentRow ,
+ SCROW nStartRow , SCCOL nStartCol ,
+ SCROW nEndRow , SCCOL nEndCol ,
+ Edit** pEdits ,
+ sal_uInt16 aColLength );
+
+ // interne Hilfsfunktionen
+protected:
+ void UpdateLineAttrs( SvxBorderLine& rLine,
+ const SvxBorderLine* pDestLine,
+ const SvxBorderLine* pSrcLine,
+ BOOL bColor );
+
+
+private:
+ void PasteRTF( SCCOL nCol, SCROW nStartRow,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable );
+ bool PasteMultiRangesFromClip( sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
+ bool bSkipEmpty, bool bTranspos, bool bAsLink, bool bAllowDialogs,
+ InsCellCmd eMoveMode, sal_uInt16 nCondFlags, sal_uInt16 nUndoFlags );
+ void PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& rMark);
+
+ USHORT GetOptimalColWidth( SCCOL nCol, SCTAB nTab, BOOL bFormula );
+
+ void StartFormatArea();
+ BOOL TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, BOOL bAttrChanged );
+ void DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
+ BOOL bAttrChanged, BOOL bAddUndo );
+
+ void MarkAndJumpToRanges(const ScRangeList& rRanges);
+};
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/viewutil.hxx b/sc/source/ui/inc/viewutil.hxx
new file mode 100644
index 000000000000..70603d016d0d
--- /dev/null
+++ b/sc/source/ui/inc/viewutil.hxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VIEWUTIL_HXX
+#define SC_VIEWUTIL_HXX
+
+#include "address.hxx"
+#include <tools/solar.h>
+#include <sal/types.h>
+
+class String;
+class SfxItemSet;
+class SfxBindings;
+class SvxFontItem;
+class SfxViewShell;
+class SfxViewFrame;
+
+class ScChangeAction;
+class ScChangeViewSettings;
+class ScDocument;
+class ScAddress;
+class ScRange;
+class ScMarkData;
+
+enum ScUpdateMode { SC_UPDATE_ALL, SC_UPDATE_CHANGED, SC_UPDATE_MARKS };
+
+// ---------------------------------------------------------------------------
+
+class ScViewUtil // static Methoden
+{
+public:
+ static BOOL ExecuteCharMap( const SvxFontItem& rOldFont,
+ SfxViewFrame& rFrame,
+ SvxFontItem& rNewFont,
+ String& rString );
+
+ static BOOL IsActionShown( const ScChangeAction& rAction,
+ const ScChangeViewSettings& rSettings,
+ ScDocument& rDocument );
+
+ static void PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet,
+ USHORT nWhichId, USHORT nScript );
+
+ static USHORT GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos );
+
+ static sal_Int32 GetTransliterationType( USHORT nSlotID );
+
+ static bool HasFiltered( const ScRange& rRange, ScDocument* pDoc );
+ /** Fit a range to cover nRows number of unfiltered rows.
+ @return <TRUE/> if the resulting range covers nRows unfiltered rows. */
+ static bool FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows );
+ static void UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc );
+
+ static void HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, USHORT nSlotId );
+
+ /** Returns true, if the passed view shell is in full screen mode. */
+ static bool IsFullScreen( SfxViewShell& rViewShell );
+ /** Enters or leaves full screen mode at the passed view shell. */
+ static void SetFullScreen( SfxViewShell& rViewShell, bool bSet );
+};
+
+// ---------------------------------------------------------------------------
+
+class ScUpdateRect
+{
+private:
+ SCCOL nOldStartX;
+ SCROW nOldStartY;
+ SCCOL nOldEndX;
+ SCROW nOldEndY;
+ SCCOL nNewStartX;
+ SCROW nNewStartY;
+ SCCOL nNewEndX;
+ SCROW nNewEndY;
+ SCCOL nContX1;
+ SCROW nContY1;
+ SCCOL nContX2;
+ SCROW nContY2;
+public:
+ ScUpdateRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
+ void SetNew( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
+ BOOL GetDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
+#ifdef OLD_SELECTION_PAINT
+ BOOL GetXorDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, BOOL& rCont );
+ void GetContDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
+#endif
+};
+
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/warnbox.hxx b/sc/source/ui/inc/warnbox.hxx
new file mode 100644
index 000000000000..525d883b69c4
--- /dev/null
+++ b/sc/source/ui/inc/warnbox.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_WARNBOX_HXX
+#define SC_WARNBOX_HXX
+
+#include <vcl/msgbox.hxx>
+
+
+// ============================================================================
+
+/** Message box with warning image and "Do not show again" checkbox. */
+class ScCbWarningBox : public WarningBox
+{
+public:
+ /** @param rMsgStr Resource ID for the message text.
+ @param bDefYes true = "Yes" focused, false = "No" focused. */
+ ScCbWarningBox( Window* pParent, const String& rMsgStr, bool bDefYes = true );
+
+ /** Opens dialog if IsDialogEnabled() returns true.
+ @descr If after executing the dialog the checkbox "Do not show again" is set,
+ the method DisableDialog() will be called. */
+ virtual sal_Int16 Execute();
+
+ /** Called before executing the dialog. If this method returns false, the dialog will not be opened. */
+ virtual bool IsDialogEnabled();
+ /** Called, when dialog is exited and the option "Do not show again" is set. */
+ virtual void DisableDialog();
+};
+
+
+// ----------------------------------------------------------------------------
+
+/** Warning box for "Replace cell contents?". */
+class ScReplaceWarnBox : public ScCbWarningBox
+{
+public:
+ ScReplaceWarnBox( Window* pParent );
+
+ /** Reads the configuration key "ReplaceCellsWarning". */
+ virtual bool IsDialogEnabled();
+ /** Sets the configuration key "ReplaceCellsWarning" to false. */
+ virtual void DisableDialog();
+};
+
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
new file mode 100644
index 000000000000..a5e94745f2e6
--- /dev/null
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -0,0 +1,2137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+#include <svl/undo.hxx>
+#include <unotools/textsearch.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "acredlin.hxx"
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "acredlin.hrc"
+#include "simpref.hxx"
+#include "scmod.hxx"
+#include "popmenu.hxx"
+#include "tabvwsh.hxx"
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+inline void EnableDisable( Window& rWin, BOOL bEnable )
+{
+ if (bEnable)
+ rWin.Enable();
+ else
+ rWin.Disable();
+}
+
+#define RD_SPECIAL_NONE 0
+#define RD_SPECIAL_CONTENT 1
+#define RD_SPECIAL_VISCONTENT 2
+
+//============================================================================
+// class ScRedlinData
+//----------------------------------------------------------------------------
+
+ScRedlinData::ScRedlinData()
+ :RedlinData()
+{
+ nInfo=RD_SPECIAL_NONE;
+ nActionNo=0;
+ pData=NULL;
+ bDisabled=FALSE;
+ bIsRejectable=FALSE;
+ bIsAcceptable=FALSE;
+ nTable=SCTAB_MAX;
+ nCol=SCCOL_MAX;
+ nRow=SCROW_MAX;
+}
+
+ScRedlinData::~ScRedlinData()
+{
+ nInfo=RD_SPECIAL_NONE;
+ nActionNo=0;
+ pData=NULL;
+ bDisabled=FALSE;
+ bIsRejectable=FALSE;
+ bIsAcceptable=FALSE;
+}
+
+
+//============================================================================
+// class ScAcceptChgDlg
+//----------------------------------------------------------------------------
+ScAcceptChgDlg::ScAcceptChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData)
+
+ : SfxModelessDialog( pB, pCW, pParent, ScResId(RID_SCDLG_CHANGES) ),
+ //
+ aAcceptChgCtr ( this, ScResId( CTR_REDLINING ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) ),
+ //
+ aStrInsertCols ( ScResId( STR_INSERT_COLS)),
+ aStrInsertRows ( ScResId( STR_INSERT_ROWS)),
+ aStrInsertTabs ( ScResId( STR_INSERT_TABS)),
+ aStrDeleteCols ( ScResId( STR_DELETE_COLS)),
+ aStrDeleteRows ( ScResId( STR_DELETE_ROWS)),
+ aStrDeleteTabs ( ScResId( STR_DELETE_TABS)),
+ aStrMove ( ScResId( STR_MOVE )),
+ aStrContent ( ScResId( STR_CONTENT )),
+ aStrReject ( ScResId( STR_REJECT )),
+ aStrAllAccepted ( ScResId( STR_ACCEPTED )),
+ aStrAllRejected ( ScResId( STR_REJECTED )),
+ aStrNoEntry ( ScResId( STR_NO_ENTRY )),
+ aStrContentWithChild ( ScResId( STR_CONTENT_WITH_CHILD)),
+ aStrChildContent ( ScResId( STR_CHILD_CONTENT)),
+ aStrChildOrgContent ( ScResId( STR_CHILD_ORGCONTENT)),
+ aStrEmpty ( ScResId( STR_EMPTY ))
+{
+ FreeResource();
+// bScAcceptChgDlgIsDead=FALSE;
+ bNoSelection=FALSE;
+ bNeedsUpdate=FALSE;
+ bIgnoreMsg=FALSE;
+ nAcceptCount=0;
+ nRejectCount=0;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+ bHasFilterEntry=FALSE;
+ bUseColor=FALSE;
+ aReOpenTimer.SetTimeout(50);
+ aReOpenTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, ReOpenTimerHdl ));
+
+ // dialog is now only hidden, not deleted, on switching views,
+ // so there's no need to restore settings when reopening
+
+ MinSize=aAcceptChgCtr.GetMinSizePixel();
+ MinSize.Height()+=2;
+ MinSize.Width()+=2;
+ SetMinOutputSizePixel(MinSize);
+ aUnknown.AssignAscii(RTL_CONSTASCII_STRINGPARAM("Unknown"));
+
+ pTPFilter=aAcceptChgCtr.GetFilterPage();
+ pTPView=aAcceptChgCtr.GetViewPage();
+ pTheView=pTPView->GetTableControl();
+ aSelectionTimer.SetTimeout(100);
+ aSelectionTimer.SetTimeoutHdl(LINK( this, ScAcceptChgDlg, UpdateSelectionHdl ));
+
+ pTPFilter->SetReadyHdl(LINK( this, ScAcceptChgDlg, FilterHandle ));
+ pTPFilter->SetRefHdl(LINK( this, ScAcceptChgDlg, RefHandle ));
+ pTPFilter->SetModifyHdl(LINK( this, ScAcceptChgDlg, FilterModified));
+ pTPFilter->HideRange(FALSE);
+ pTPView->InsertCalcHeader();
+ pTPView->SetRejectClickHdl( LINK( this, ScAcceptChgDlg,RejectHandle));
+ pTPView->SetAcceptClickHdl( LINK(this, ScAcceptChgDlg, AcceptHandle));
+ pTPView->SetRejectAllClickHdl( LINK( this, ScAcceptChgDlg,RejectAllHandle));
+ pTPView->SetAcceptAllClickHdl( LINK(this, ScAcceptChgDlg, AcceptAllHandle));
+ pTheView->SetCalcView();
+ pTheView->SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN|WB_HASBUTTONS|WB_HASBUTTONSATROOT|WB_HSCROLL);
+ pTheView->SetExpandingHdl( LINK(this, ScAcceptChgDlg, ExpandingHandle));
+ pTheView->SetSelectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
+ pTheView->SetDeselectHdl( LINK(this, ScAcceptChgDlg, SelectHandle));
+ pTheView->SetCommandHdl( LINK(this, ScAcceptChgDlg, CommandHdl));
+ pTheView->SetColCompareHdl( LINK(this, ScAcceptChgDlg,ColCompareHdl));
+ pTheView->SetSelectionMode(MULTIPLE_SELECTION);
+ pTheView->SetHighlightRange(1);
+
+ Init();
+
+ aAcceptChgCtr.SetMinSizeHdl( LINK( this, ScAcceptChgDlg, MinSizeHandle ));
+
+ UpdateView();
+ SvLBoxEntry* pEntry=pTheView->First();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+}
+ScAcceptChgDlg::~ScAcceptChgDlg()
+{
+// bScAcceptChgDlgIsDead=TRUE;
+ ClearView();
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pChanges!=NULL)
+ {
+ Link aLink;
+ pChanges->SetModifiedLink(aLink);
+ }
+}
+
+void ScAcceptChgDlg::ReInit(ScViewData* ptrViewData)
+{
+ pViewData=ptrViewData;
+ if(pViewData!=NULL)
+ {
+ pDoc=ptrViewData->GetDocument();
+ }
+ else
+ {
+ pDoc=NULL;
+ }
+
+ bNoSelection=FALSE;
+ bNeedsUpdate=FALSE;
+ bIgnoreMsg=FALSE;
+ nAcceptCount=0;
+ nRejectCount=0;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+
+ // #91781# don't call Init here (switching between views), just set link below
+ // (dialog is just hidden, not deleted anymore, when switching views)
+ ClearView();
+ UpdateView();
+
+ if ( pDoc )
+ {
+ ScChangeTrack* pChanges = pDoc->GetChangeTrack();
+ if ( pChanges )
+ pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg, ChgTrackModHdl ) );
+ }
+}
+
+void __EXPORT ScAcceptChgDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pChanges!=NULL)
+ {
+ pChanges->SetModifiedLink( LINK( this, ScAcceptChgDlg,ChgTrackModHdl));
+ aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
+ pTPFilter->ClearAuthors();
+ ScStrCollection aUserColl=pChanges->GetUserCollection();
+ for(USHORT i=0;i<aUserColl.GetCount();i++)
+ pTPFilter->InsertAuthor(aUserColl[i]->GetString());
+ }
+
+ ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
+ if ( pViewSettings!=NULL )
+ aChangeViewSet = *pViewSettings;
+ // adjust TimeField for filter tabpage
+ aChangeViewSet.AdjustDateMode( *pDoc );
+
+ pTPFilter->CheckDate(aChangeViewSet.HasDate());
+ pTPFilter->SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
+ pTPFilter->SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
+ pTPFilter->SetLastDate(aChangeViewSet.GetTheLastDateTime());
+ pTPFilter->SetLastTime(aChangeViewSet.GetTheLastDateTime());
+ pTPFilter->SetDateMode((USHORT)aChangeViewSet.GetTheDateMode());
+ pTPFilter->CheckComment(aChangeViewSet.HasComment());
+ pTPFilter->SetComment(aChangeViewSet.GetTheComment());
+
+ pTPFilter->CheckAuthor(aChangeViewSet.HasAuthor());
+ String aString=aChangeViewSet.GetTheAuthorToShow();
+ if(aString.Len()!=0)
+ {
+ pTPFilter->SelectAuthor(aString);
+ if(pTPFilter->GetSelectedAuthor()!=aString)
+ {
+ pTPFilter->InsertAuthor(aString);
+ pTPFilter->SelectAuthor(aString);
+ }
+ }
+ else
+ {
+ pTPFilter->SelectedAuthorPos(0);
+ }
+
+ pTPFilter->CheckRange(aChangeViewSet.HasRange());
+
+ ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
+ aRangeList=aChangeViewSet.GetTheRangeList();
+
+ if(pRangeEntry!=NULL)
+ {
+ String aRefStr;
+ pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
+ pTPFilter->SetRange(aRefStr);
+ }
+
+ Point aPoint(1,1);
+ aAcceptChgCtr.SetPosPixel(aPoint);
+ InitFilter();
+}
+
+
+
+void ScAcceptChgDlg::ClearView()
+{
+ nAcceptCount=0;
+ nRejectCount=0;
+ pTheView->SetUpdateMode(FALSE);
+
+ pTheView->Clear();
+ pTheView->SetUpdateMode(TRUE);
+}
+
+String* ScAcceptChgDlg::MakeTypeString(ScChangeActionType eType)
+{
+ String* pStr;
+
+ switch(eType)
+ {
+
+ case SC_CAT_INSERT_COLS: pStr=&aStrInsertCols;break;
+
+ case SC_CAT_INSERT_ROWS: pStr=&aStrInsertRows;break;
+
+ case SC_CAT_INSERT_TABS: pStr=&aStrInsertTabs;break;
+
+ case SC_CAT_DELETE_COLS: pStr=&aStrDeleteCols;break;
+
+ case SC_CAT_DELETE_ROWS: pStr=&aStrDeleteRows;break;
+
+ case SC_CAT_DELETE_TABS: pStr=&aStrDeleteTabs;break;
+
+ case SC_CAT_MOVE: pStr=&aStrMove;break;
+
+ case SC_CAT_CONTENT: pStr=&aStrContent;break;
+
+ case SC_CAT_REJECT: pStr=&aStrReject;break;
+
+ default: pStr=&aUnknown;break;
+ }
+ return pStr;
+}
+
+
+BOOL ScAcceptChgDlg::IsValidAction(const ScChangeAction* pScChangeAction)
+{
+ if(pScChangeAction==NULL) return FALSE;
+
+ BOOL bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ ScChangeActionType eType=pScChangeAction->GetType();
+ String aString;
+ String aDesc;
+
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+
+ if(eType==SC_CAT_CONTENT)
+ {
+ if(!pScChangeAction->IsDialogParent())
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
+ }
+ }
+ else
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+ }
+
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime,&aComment))
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+
+ if(pRangeEntry!=NULL)
+ {
+ bFlag=TRUE;
+ }
+ }
+ else
+ {
+ bFlag=TRUE;
+ }
+ }
+
+ return bFlag;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertChangeAction(const ScChangeAction* pScChangeAction,
+ ScChangeActionState /* eState */, SvLBoxEntry* pParent,
+ BOOL bDelMaster,BOOL bDisabled,ULONG nPos)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ SvLBoxEntry* pEntry=NULL;
+
+ BOOL bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ String aRefStr;
+ ScChangeActionType eType=pScChangeAction->GetType();
+ String aString;
+ String aDesc;
+
+ ScRedlinData* pNewData=new ScRedlinData;
+ pNewData->pData=(void *)pScChangeAction;
+ pNewData->nActionNo=pScChangeAction->GetActionNumber();
+ pNewData->bIsAcceptable=pScChangeAction->IsClickable();
+ pNewData->bIsRejectable=pScChangeAction->IsRejectable();
+ pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
+ pNewData->aDateTime=aDateTime;
+ pNewData->nRow = aRef.aStart.Row();
+ pNewData->nCol = aRef.aStart.Col();
+ pNewData->nTable= aRef.aStart.Tab();
+
+ if(eType==SC_CAT_CONTENT)
+ {
+ if(pScChangeAction->IsDialogParent())
+ {
+ aString=aStrContentWithChild;
+ pNewData->nInfo=RD_SPECIAL_VISCONTENT;
+ pNewData->bIsRejectable=FALSE;
+ pNewData->bIsAcceptable=FALSE;
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+ pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
+ }
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+
+ if(bDelMaster)
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,TRUE);
+ pNewData->bDisabled=TRUE;
+ pNewData->bIsRejectable=FALSE;
+ }
+ else
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+
+ }
+
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
+ aString+=aRefStr;
+ aString+='\t';
+
+ BOOL bIsGenerated;
+
+ if(!pChanges->IsGenerated(pScChangeAction->GetActionNumber()))
+ {
+ aString+=aUser;
+ aString+='\t';
+
+ aString+=ScGlobal::pLocaleData->getDate(aDateTime);
+ aString+=' ';
+ aString+=ScGlobal::pLocaleData->getTime(aDateTime);
+ aString+='\t';
+ bIsGenerated=FALSE;
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ bIsGenerated=TRUE;
+ }
+
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+
+ aString+=aComment;
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime)|| bIsGenerated)
+ {
+ if(pTheView->IsValidComment(&aComment))
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+ //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
+ if(pRangeEntry!=NULL)
+ {
+ bHasFilterEntry=TRUE;
+ bFlag=TRUE;
+ }
+ }
+ else if(!bIsGenerated)
+ {
+ bHasFilterEntry=TRUE;
+ bFlag=TRUE;
+ }
+ }
+ }
+
+ if(!bFlag&& bUseColor&& pParent==NULL)
+ {
+ pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent,nPos);
+ }
+ else if(bFlag&& bUseColor&& pParent!=NULL)
+ {
+ pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_GREEN),pParent,nPos);
+ SvLBoxEntry* pExpEntry=pParent;
+
+ while(pExpEntry!=NULL && !pTheView->IsExpanded(pExpEntry))
+ {
+ SvLBoxEntry* pTmpEntry=pTheView->GetParent(pExpEntry);
+
+ if(pTmpEntry!=NULL) pTheView->Expand(pExpEntry);
+
+ pExpEntry=pTmpEntry;
+ }
+ }
+ else
+ {
+ pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
+ }
+ return pEntry;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertFilteredAction(const ScChangeAction* pScChangeAction,
+ ScChangeActionState eState,SvLBoxEntry* pParent,
+ BOOL bDelMaster,BOOL bDisabled,ULONG nPos)
+{
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ BOOL bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
+
+ SvLBoxEntry* pEntry=NULL;
+
+ int bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+ //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
+ if(pRangeEntry!=NULL &&
+ pScChangeAction->GetState()==eState)
+ {
+ bFlag=TRUE;
+ }
+ }
+ else if(pScChangeAction->GetState()==eState && !bIsGenerated)
+ {
+ bFlag=TRUE;
+ }
+ }
+
+ if(bFlag)
+ {
+
+ String aRefStr;
+ ScChangeActionType eType=pScChangeAction->GetType();
+ String aString;
+ String aDesc;
+
+
+ ScRedlinData* pNewData=new ScRedlinData;
+ pNewData->pData=(void *)pScChangeAction;
+ pNewData->nActionNo=pScChangeAction->GetActionNumber();
+ pNewData->bIsAcceptable=pScChangeAction->IsClickable();
+ pNewData->bIsRejectable=pScChangeAction->IsRejectable();
+ pNewData->bDisabled=!pNewData->bIsAcceptable | bDisabled;
+ pNewData->aDateTime=aDateTime;
+ pNewData->nRow = aRef.aStart.Row();
+ pNewData->nCol = aRef.aStart.Col();
+ pNewData->nTable= aRef.aStart.Tab();
+
+ if(eType==SC_CAT_CONTENT)
+ {
+ if(pScChangeAction->IsDialogParent())
+ {
+ aString=aStrContentWithChild;
+ pNewData->nInfo=RD_SPECIAL_VISCONTENT;
+ pNewData->bIsRejectable=FALSE;
+ pNewData->bIsAcceptable=FALSE;
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+ pScChangeAction->GetDescription( aDesc, pDoc, TRUE);
+ }
+ }
+ else
+ {
+ aString=*MakeTypeString(eType);
+
+ if(bDelMaster)
+ {
+ pScChangeAction->GetDescription( aDesc, pDoc,TRUE);
+ pNewData->bDisabled=TRUE;
+ pNewData->bIsRejectable=FALSE;
+ }
+ else
+ pScChangeAction->GetDescription( aDesc, pDoc,!pScChangeAction->IsMasterDelete());
+
+ }
+
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
+ aString+=aRefStr;
+ aString+='\t';
+
+ if(!bIsGenerated)
+ {
+ aString+=aUser;
+ aString+='\t';
+ aString+=ScGlobal::pLocaleData->getDate(aDateTime);
+ aString+=' ';
+ aString+=ScGlobal::pLocaleData->getTime(aDateTime);
+ aString+='\t';
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ }
+
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+ if(pTheView->IsValidComment(&aComment))
+ {
+ aString+=aComment;
+ pEntry=pTheView->InsertEntry(aString,pNewData,pParent,nPos);
+ }
+ else
+ delete pNewData;
+ }
+ return pEntry;
+}
+
+SvLBoxEntry* ScAcceptChgDlg::InsertChangeActionContent(const ScChangeActionContent* pScChangeAction,
+ SvLBoxEntry* pParent, ULONG nSpecial)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ SvLBoxEntry* pEntry=NULL;
+
+ if(pScChangeAction==NULL || pChanges==NULL) return NULL;
+
+ BOOL bIsGenerated=pChanges->IsGenerated(pScChangeAction->GetActionNumber());
+
+ BOOL bFlag=FALSE;
+
+ ScRange aRef=pScChangeAction->GetBigRange().MakeRange();
+ String aUser=pScChangeAction->GetUser();
+ DateTime aDateTime=pScChangeAction->GetDateTime();
+
+ if(pTheView->IsValidEntry(&aUser,&aDateTime)||bIsGenerated)
+ {
+ if(pTPFilter->IsRange())
+ {
+ ScRange* pRangeEntry=aRangeList.First();
+
+ while(pRangeEntry!=NULL)
+ {
+ if(pRangeEntry->Intersects(aRef)) break;
+ pRangeEntry=aRangeList.Next();
+ }
+ //SC_CAS_VIRGIN,SC_CAS_ACCEPTED,SC_CAS_REJECTED
+ if(pRangeEntry!=NULL)
+ {
+ bFlag=TRUE;
+ }
+ }
+ else if(!bIsGenerated)
+ bFlag=TRUE;
+ }
+
+ String aRefStr;
+ String aString;
+ String a2String;
+ String aDesc;
+
+ if(nSpecial==RD_SPECIAL_CONTENT)
+ {
+ pScChangeAction->GetOldString(a2String);
+ if(a2String.Len()==0) a2String=aStrEmpty;
+
+ //aString+="\'";
+ aString+=a2String;
+ //aString+="\'";
+
+ aDesc=aStrChildOrgContent;
+ aDesc.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ }
+ else
+ {
+ pScChangeAction->GetNewString(a2String);
+ if(a2String.Len()==0)
+ {
+ a2String=aStrEmpty;
+ aString+=a2String;
+ }
+ else
+ {
+ aString+='\'';
+ aString+=a2String;
+ aString+='\'';
+ a2String=aString;
+ }
+ aDesc=aStrChildContent;
+
+ }
+
+ aDesc+=a2String;
+ aString+='\t';
+ pScChangeAction->GetRefString(aRefStr, pDoc, TRUE);
+ aString+=aRefStr;
+ aString+='\t';
+
+ if(!bIsGenerated)
+ {
+ aString+=aUser;
+ aString+='\t';
+
+ aString+=ScGlobal::pLocaleData->getDate(aDateTime);
+ aString+=' ';
+ aString+=ScGlobal::pLocaleData->getTime(aDateTime);
+ aString+='\t';
+ }
+ else
+ {
+ aString+='\t';
+ aString+='\t';
+ }
+ String aComment=pScChangeAction->GetComment();
+ aComment.EraseAllChars('\n');
+
+ if(aDesc.Len()>0)
+ {
+ aComment.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aComment+=aDesc;
+ aComment+=')';
+ }
+
+ aString+=aComment;
+
+ ScRedlinData* pNewData=new ScRedlinData;
+ pNewData->nInfo=nSpecial;
+ pNewData->pData=(void *)pScChangeAction;
+ pNewData->nActionNo=pScChangeAction->GetActionNumber();
+ pNewData->bIsAcceptable=pScChangeAction->IsClickable();
+ pNewData->bIsRejectable=FALSE;
+ pNewData->bDisabled=!pNewData->bIsAcceptable;
+ pNewData->aDateTime=aDateTime;
+ pNewData->nRow = aRef.aStart.Row();
+ pNewData->nCol = aRef.aStart.Col();
+ pNewData->nTable= aRef.aStart.Tab();
+
+ if(pTheView->IsValidComment(&aComment) && bFlag)
+ {
+ bHasFilterEntry=TRUE;
+ pEntry=pTheView->InsertEntry(aString,pNewData,pParent);
+ }
+ else
+ pEntry=pTheView->InsertEntry(aString,pNewData,Color(COL_LIGHTBLUE),pParent);
+ return pEntry;
+}
+
+long ScAcceptChgDlg::PreNotify( NotifyEvent& rNEvt )
+{
+ if(rNEvt.GetType()==EVENT_GETFOCUS && bNeedsUpdate)
+ {
+ ClearView();
+ UpdateView();
+ bNoSelection=FALSE;
+ }
+
+ return SfxModelessDialog::PreNotify(rNEvt);
+}
+
+
+void ScAcceptChgDlg::UpdateView()
+{
+ bNeedsUpdate=FALSE;
+ DateTime aDateTime;
+ SvLBoxEntry* pParent=NULL;
+ ScChangeTrack* pChanges=NULL;
+ const ScChangeAction* pScChangeAction=NULL;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+ SetPointer(Pointer(POINTER_WAIT));
+ pTheView->SetUpdateMode(FALSE);
+ BOOL bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment();
+
+ bUseColor=bFilterFlag;
+
+ if(pDoc!=NULL)
+ {
+ pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ pScChangeAction=pChanges->GetFirst();
+ }
+ }
+ ScChangeActionTable ActionTable;
+ BOOL bTheFlag=FALSE;
+
+ while(pScChangeAction!=NULL)
+ {
+ bHasFilterEntry=FALSE;
+ switch(pScChangeAction->GetState())
+ {
+ case SC_CAS_VIRGIN:
+
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(pScChangeAction->IsDialogParent())
+ pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
+ else
+ pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
+ }
+ else
+ pParent=NULL;
+
+ bTheFlag=TRUE;
+ break;
+
+ case SC_CAS_ACCEPTED:
+ pParent=NULL;
+ nAcceptCount++;
+ break;
+
+ case SC_CAS_REJECTED:
+ pParent=NULL;
+ nRejectCount++;
+ break;
+ }
+
+ if(pParent!=NULL && pScChangeAction->IsDialogParent())
+ {
+ if(!bFilterFlag)
+ {
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ else
+ {
+ BOOL bTestFlag=bHasFilterEntry;
+ bHasFilterEntry=FALSE;
+ if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
+ pTheView->RemoveEntry(pParent);
+ }
+ }
+
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+
+ if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
+ bTheFlag=FALSE;
+
+ pTPView->EnableAccept(bTheFlag);
+ pTPView->EnableAcceptAll(bTheFlag);
+ pTPView->EnableReject(bTheFlag);
+ pTPView->EnableRejectAll(bTheFlag);
+
+ if(nAcceptCount>0)
+ {
+ pParent=pTheView->InsertEntry(
+ aStrAllAccepted, static_cast< RedlinData * >(NULL),
+ static_cast< SvLBoxEntry * >(NULL));
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ if(nRejectCount>0)
+ {
+ pParent=pTheView->InsertEntry(
+ aStrAllRejected, static_cast< RedlinData * >(NULL),
+ static_cast< SvLBoxEntry * >(NULL));
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ pTheView->SetUpdateMode(TRUE);
+ SetPointer(Pointer(POINTER_ARROW));
+ SvLBoxEntry* pEntry=pTheView->First();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+}
+
+//----------------------------------------------------------------------------
+BOOL ScAcceptChgDlg::Close()
+{
+ return SfxModelessDialog::Close();
+}
+
+void ScAcceptChgDlg::Resize()
+{
+ SfxModelessDialog::Resize();
+ Size aOutSize=GetOutputSizePixel();
+ aAcceptChgCtr.SetSizePixel(aOutSize);
+}
+
+IMPL_LINK( ScAcceptChgDlg, MinSizeHandle, SvxAcceptChgCtr*, pCtr )
+{
+ if(pCtr==&aAcceptChgCtr)
+ {
+ if(!IsRollUp())
+ SetOutputSizePixel(MinSize);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RefHandle, SvxTPFilter*, EMPTYARG )
+{
+ USHORT nId =ScSimpleRefDlgWrapper::GetChildWindowId();
+
+ ScSimpleRefDlgWrapper::SetDefaultPosSize(GetPosPixel(),GetSizePixel(),TRUE);
+
+ SC_MOD()->SetRefDialog( nId, TRUE );
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ ScSimpleRefDlgWrapper* pWnd =(ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+
+ if(pWnd!=NULL)
+ {
+// bSimpleRefDlgStarted=TRUE;
+ USHORT nAcceptId=ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->ShowChildWindow(nAcceptId,FALSE);
+ pWnd->SetCloseHdl(LINK( this, ScAcceptChgDlg,RefInfoHandle));
+ pWnd->SetRefString(pTPFilter->GetRange());
+ pWnd->SetAutoReOpen(FALSE);
+ Window* pWin=pWnd->GetWindow();
+ pWin->SetPosSizePixel(GetPosPixel(),GetSizePixel());
+ Hide();
+ pWin->SetText(GetText());
+ pWnd->StartRefInput();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RefInfoHandle, String*, pResult)
+{
+ USHORT nId;
+
+// bSimpleRefDlgStarted=FALSE;
+ ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE);
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ if(pResult!=NULL)
+ {
+ pTPFilter->SetRange(*pResult);
+ FilterHandle(pTPFilter);
+
+ nId = ScSimpleRefDlgWrapper::GetChildWindowId();
+ ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+
+ if(pWnd!=NULL)
+ {
+ Window* pWin=pWnd->GetWindow();
+ Size aWinSize=pWin->GetSizePixel();
+ aWinSize.Width()=GetSizePixel().Width();
+ SetPosSizePixel(pWin->GetPosPixel(),aWinSize);
+ Invalidate();
+ }
+ nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->ShowChildWindow( nId, TRUE );
+ }
+ else
+ {
+ nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ pViewFrm->SetChildWindow( nId, FALSE );
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef )
+{
+ if(pRef!=NULL)
+ {
+ ClearView();
+ aRangeList.Clear();
+ aRangeList.Parse(pTPFilter->GetRange(),pDoc);
+ UpdateView();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, RejectHandle, SvxTPView*, pRef )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ bIgnoreMsg=TRUE;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pRef!=NULL)
+ {
+ SvLBoxEntry* pEntry=pTheView->FirstSelected();
+ while(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ if(pScChangeAction->GetType()==SC_CAT_INSERT_TABS)
+ {
+ pViewData->SetTabNo(0);
+ }
+ pChanges->Reject(pScChangeAction);
+ }
+ pEntry = pTheView->NextSelected(pEntry);
+ }
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->GetUndoManager()->Clear();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ SetPointer(Pointer(POINTER_ARROW));
+
+ bIgnoreMsg=FALSE;
+ return 0;
+}
+IMPL_LINK( ScAcceptChgDlg, AcceptHandle, SvxTPView*, pRef )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ bIgnoreMsg=TRUE;
+ if(pRef!=NULL)
+ {
+ SvLBoxEntry* pEntry=pTheView->FirstSelected();
+ while(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+ if(pScChangeAction->GetType()==SC_CAT_CONTENT)
+ {
+ if(pEntryData->nInfo==RD_SPECIAL_CONTENT)
+ {
+ pChanges->SelectContent(pScChangeAction,TRUE);
+ }
+ else
+ {
+ pChanges->SelectContent(pScChangeAction);
+ }
+ }
+ else
+ pChanges->Accept(pScChangeAction);
+ }
+ pEntry = pTheView->NextSelected(pEntry);
+ }
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ bIgnoreMsg=FALSE;
+
+ return 0;
+}
+
+void ScAcceptChgDlg::RejectFiltered()
+{
+ if(pDoc==NULL) return;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ const ScChangeAction* pScChangeAction=NULL;
+
+ if(pChanges!=NULL)
+ {
+ pScChangeAction=pChanges->GetLast();
+ }
+
+ while(pScChangeAction!=NULL)
+ {
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(IsValidAction(pScChangeAction))
+ {
+ pChanges->Reject((ScChangeAction*)pScChangeAction);
+ }
+ }
+ pScChangeAction=pScChangeAction->GetPrev();
+ }
+}
+void ScAcceptChgDlg::AcceptFiltered()
+{
+ if(pDoc==NULL) return;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ const ScChangeAction* pScChangeAction=NULL;
+
+ if(pChanges!=NULL)
+ {
+ pScChangeAction=pChanges->GetLast();
+ }
+
+ while(pScChangeAction!=NULL)
+ {
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(IsValidAction(pScChangeAction))
+ {
+ pChanges->Accept((ScChangeAction*)pScChangeAction);
+ }
+ }
+ pScChangeAction=pScChangeAction->GetPrev();
+ }
+}
+
+IMPL_LINK( ScAcceptChgDlg, RejectAllHandle, SvxTPView*, EMPTYARG )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+ bIgnoreMsg=TRUE;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
+ {
+ RejectFiltered();
+ }
+ else
+ {
+ pChanges->RejectAll();
+ }
+ pViewData->SetTabNo(0);
+
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->GetUndoManager()->Clear();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ SetPointer(Pointer(POINTER_ARROW));
+
+ bIgnoreMsg=FALSE;
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, AcceptAllHandle, SvxTPView*, EMPTYARG )
+{
+ SetPointer(Pointer(POINTER_WAIT));
+
+ bIgnoreMsg=TRUE;
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ if(pTPFilter->IsDate()||pTPFilter->IsAuthor()||pTPFilter->IsRange()||pTPFilter->IsComment())
+ {
+ AcceptFiltered();
+ }
+ else
+ {
+ pChanges->AcceptAll();
+ }
+ ScDocShell* pDocSh=pViewData->GetDocShell();
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->SetDocumentModified();
+ ClearView();
+ UpdateView();
+ }
+ bIgnoreMsg=FALSE;
+ SetPointer(Pointer(POINTER_ARROW));
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if(!bNoSelection)
+ {
+ aSelectionTimer.Start();
+ }
+ bNoSelection=FALSE;
+ return 0;
+}
+
+void ScAcceptChgDlg::GetDependents( const ScChangeAction* pScChangeAction,
+ ScChangeActionTable& aActionTable,
+ SvLBoxEntry* pEntry)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ SvLBoxEntry* pParent=pTheView->GetParent(pEntry);
+ if(pParent!=NULL)
+ {
+ ScRedlinData *pParentData=(ScRedlinData *)(pParent->GetUserData());
+ ScChangeAction* pParentAction=(ScChangeAction*) pParentData->pData;
+ if(pParentAction!=pScChangeAction)
+ {
+ pChanges->GetDependents((ScChangeAction*) pScChangeAction,
+ aActionTable,pScChangeAction->IsMasterDelete());
+ }
+ else
+ {
+ pChanges->GetDependents((ScChangeAction*) pScChangeAction,
+ aActionTable);
+ }
+ }
+ else
+ {
+ pChanges->GetDependents((ScChangeAction*) pScChangeAction,
+ aActionTable,pScChangeAction->IsMasterDelete());
+ }
+}
+
+BOOL ScAcceptChgDlg::InsertContentChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ BOOL bTheTestFlag=TRUE;
+ ScRedlinData *pEntryData=(ScRedlinData *)(pParent->GetUserData());
+ const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
+ BOOL bParentInserted = FALSE;
+ // If the parent is a MatrixOrigin then place it in the right order before
+ // the MatrixReferences. Also if it is the first content change at this
+ // position don't insert the first dependent MatrixReference as the special
+ // content (original value) but insert the predecessor of the MatrixOrigin
+ // itself instead.
+ if ( pScChangeAction->GetType() == SC_CAT_CONTENT &&
+ ((const ScChangeActionContent*)pScChangeAction)->IsMatrixOrigin() )
+ {
+ pActionTable->Insert( pScChangeAction->GetActionNumber(),
+ (ScChangeAction*) pScChangeAction );
+ bParentInserted = TRUE;
+ }
+ SvLBoxEntry* pEntry=NULL;
+
+ const ScChangeActionContent* pCChild=(const ScChangeActionContent*)pActionTable->First();
+ while(pCChild!=NULL)
+ {
+ if( pCChild->GetState()==SC_CAS_VIRGIN )
+ break;
+ pCChild=(const ScChangeActionContent*)pActionTable->Next();
+ }
+
+ if(pCChild==NULL) return TRUE;
+
+ SvLBoxEntry* pOriginal=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_CONTENT);
+ if(pOriginal!=NULL)
+ {
+ bTheTestFlag=FALSE;
+ ScRedlinData *pParentData=(ScRedlinData *)(pOriginal->GetUserData());
+ pParentData->pData=(void *)pScChangeAction;
+ pParentData->nActionNo=pScChangeAction->GetActionNumber();
+ pParentData->bIsAcceptable=pScChangeAction->IsRejectable(); // select old value
+ pParentData->bIsRejectable=FALSE;
+ pParentData->bDisabled=FALSE;
+ }
+ while(pCChild!=NULL)
+ {
+ if(pCChild->GetState()==SC_CAS_VIRGIN)
+ {
+ pEntry=InsertChangeActionContent(pCChild,pParent,RD_SPECIAL_NONE);
+
+ if(pEntry!=NULL)
+ bTheTestFlag=FALSE;
+ }
+ pCChild=(const ScChangeActionContent*)pActionTable->Next();
+ }
+
+ if ( !bParentInserted )
+ {
+ pEntry=InsertChangeActionContent((const ScChangeActionContent*)
+ pScChangeAction,pParent,RD_SPECIAL_NONE);
+
+ if(pEntry!=NULL)
+ {
+ bTheTestFlag=FALSE;
+ ScRedlinData *pParentData=(ScRedlinData *)(pEntry->GetUserData());
+ pParentData->pData=(void *)pScChangeAction;
+ pParentData->nActionNo=pScChangeAction->GetActionNumber();
+ pParentData->bIsAcceptable=pScChangeAction->IsClickable();
+ pParentData->bIsRejectable=FALSE;
+ pParentData->bDisabled=FALSE;
+ }
+ }
+
+ return bTheTestFlag;
+
+}
+
+BOOL ScAcceptChgDlg::InsertAcceptedORejected(SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ BOOL bTheTestFlag=TRUE;
+
+ ScChangeActionState eState = SC_CAS_VIRGIN;
+ String aString=pTheView->GetEntryText( pParent);
+ String a2String=aString.Copy(0,aStrAllAccepted.Len());
+ if(a2String==aStrAllAccepted)
+ {
+ eState=SC_CAS_ACCEPTED;
+ }
+ else
+ {
+ a2String=aString.Copy(0,aStrAllRejected.Len());
+ if(a2String==aStrAllRejected)
+ {
+ eState=SC_CAS_REJECTED;
+ }
+ }
+
+ ScChangeAction* pScChangeAction=pChanges->GetFirst();
+ while(pScChangeAction!=NULL)
+ {
+ if(pScChangeAction->GetState()==eState &&
+ InsertFilteredAction(pScChangeAction,eState,pParent)!=NULL)
+ bTheTestFlag=FALSE;
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+ return bTheTestFlag;
+}
+
+BOOL ScAcceptChgDlg::InsertChilds(ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ BOOL bTheTestFlag=TRUE;
+ SvLBoxEntry* pEntry=NULL;
+ const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
+ while(pChild!=NULL)
+ {
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,FALSE,TRUE);
+
+ if(pEntry!=NULL)
+ {
+ bTheTestFlag=FALSE;
+
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ pEntryData->bIsRejectable=FALSE;
+ pEntryData->bIsAcceptable=FALSE;
+ pEntryData->bDisabled=TRUE;
+
+ if(pChild->IsDialogParent())
+ {
+
+ //pEntry->EnableChildsOnDemand(TRUE);
+ Expand(pChanges,pChild,pEntry);
+ }
+ }
+ pChild=pActionTable->Next();
+ }
+ return bTheTestFlag;
+}
+BOOL ScAcceptChgDlg::InsertDeletedChilds(const ScChangeAction* pScChangeAction,
+ ScChangeActionTable* pActionTable,SvLBoxEntry* pParent)
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ BOOL bTheTestFlag=TRUE;
+ SvLBoxEntry* pEntry=NULL;
+ ScChangeActionTable aDelActionTable;
+ const ScChangeAction* pChild=(const ScChangeAction*)pActionTable->First();
+
+ while(pChild!=NULL)
+ {
+
+ if(pScChangeAction!=pChild)
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,FALSE,TRUE);
+ else
+ pEntry=InsertChangeAction(pChild,SC_CAS_VIRGIN,pParent,TRUE,TRUE);
+
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ pEntryData->bIsRejectable=FALSE;
+ pEntryData->bIsAcceptable=FALSE;
+ pEntryData->bDisabled=TRUE;
+
+ bTheTestFlag=FALSE;
+ if ( pChild->IsDialogParent() )
+ {
+ Expand(pChanges,pChild,pEntry);
+ /*
+ pChanges->GetDependents((ScChangeAction*) pChild,aDelActionTable);
+ if(aDelActionTable.First()!=NULL)
+ {
+ pEntry->EnableChildsOnDemand(TRUE);
+ }
+ aDelActionTable.Clear();
+ */
+ }
+ }
+ pChild=pActionTable->Next();
+ }
+ return bTheTestFlag;
+}
+
+BOOL ScAcceptChgDlg::Expand(ScChangeTrack* pChanges,const ScChangeAction* pScChangeAction,
+ SvLBoxEntry* pEntry,BOOL bFilter)
+{
+ BOOL bTheTestFlag=TRUE;
+
+ if(pChanges!=NULL &&pEntry!=NULL &&pScChangeAction!=NULL)
+ {
+ ScChangeActionTable aActionTable;
+
+ GetDependents( pScChangeAction,aActionTable,pEntry);
+
+ switch(pScChangeAction->GetType())
+ {
+ case SC_CAT_CONTENT:
+ {
+ InsertContentChilds(&aActionTable,pEntry);
+ bTheTestFlag=!bHasFilterEntry;
+ break;
+ }
+ case SC_CAT_DELETE_COLS:
+ case SC_CAT_DELETE_ROWS:
+ case SC_CAT_DELETE_TABS:
+ {
+ InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
+ bTheTestFlag=!bHasFilterEntry;
+ break;
+ }
+ default:
+ {
+ if(!bFilter)
+ bTheTestFlag=InsertChilds(&aActionTable,pEntry);
+ break;
+ }
+ }
+ aActionTable.Clear();
+ }
+ return bTheTestFlag;
+}
+
+IMPL_LINK( ScAcceptChgDlg, ExpandingHandle, SvxRedlinTable*, pTable )
+{
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ ScChangeAction* pScChangeAction=NULL;
+ SetPointer(Pointer(POINTER_WAIT));
+ if(pTable!=NULL && pChanges!=NULL)
+ {
+ ScChangeActionTable aActionTable;
+ SvLBoxEntry* pEntry=pTheView->GetHdlEntry();
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ pScChangeAction=(ScChangeAction*) pEntryData->pData;
+ }
+
+ if(pEntry->HasChildsOnDemand())
+ {
+ BOOL bTheTestFlag=TRUE;
+ pEntry->EnableChildsOnDemand(FALSE);
+ pTheView->RemoveEntry(pTheView->FirstChild(pEntry));
+
+ if(pEntryData!=NULL)
+ {
+ pScChangeAction=(ScChangeAction*) pEntryData->pData;
+
+ GetDependents( pScChangeAction,aActionTable,pEntry);
+
+ switch(pScChangeAction->GetType())
+ {
+ case SC_CAT_CONTENT:
+ {
+ bTheTestFlag=InsertContentChilds(&aActionTable,pEntry);
+ break;
+ }
+ case SC_CAT_DELETE_COLS:
+ case SC_CAT_DELETE_ROWS:
+ case SC_CAT_DELETE_TABS:
+ {
+ bTheTestFlag=InsertDeletedChilds(pScChangeAction,&aActionTable,pEntry);
+ break;
+ }
+ default:
+ {
+ bTheTestFlag=InsertChilds(&aActionTable,pEntry);
+ break;
+ }
+ }
+ aActionTable.Clear();
+
+ }
+ else
+ {
+ bTheTestFlag=InsertAcceptedORejected(pEntry);
+ }
+ if(bTheTestFlag) pTheView->InsertEntry(aStrNoEntry,NULL,Color(COL_GRAY),pEntry);
+ }
+
+ }
+ }
+ SetPointer(Pointer(POINTER_ARROW));
+ return (ULONG) TRUE;
+}
+
+
+void ScAcceptChgDlg::AppendChanges(ScChangeTrack* pChanges,ULONG nStartAction,
+ ULONG nEndAction, ULONG /* nPos */)
+{
+ if(pChanges!=NULL)
+ {
+ DateTime aDateTime;
+ SvLBoxEntry* pParent=NULL;
+ const ScChangeAction* pScChangeAction=NULL;
+ bAcceptEnableFlag=TRUE;
+ bRejectEnableFlag=TRUE;
+ SetPointer(Pointer(POINTER_WAIT));
+ pTheView->SetUpdateMode(FALSE);
+
+ ScChangeActionTable ActionTable;
+ BOOL bTheFlag=FALSE;
+
+ BOOL bFilterFlag=pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment();
+
+ bUseColor=bFilterFlag;
+
+ for(ULONG i=nStartAction;i<=nEndAction;i++)
+ {
+ pScChangeAction=pChanges->GetAction(i);
+ if(pScChangeAction==NULL) continue;
+
+
+ switch(pScChangeAction->GetState())
+ {
+ case SC_CAS_VIRGIN:
+
+ if(pScChangeAction->IsDialogRoot())
+ {
+ if(pScChangeAction->IsDialogParent())
+ pParent=InsertChangeAction(pScChangeAction,SC_CAS_VIRGIN);
+ else
+ pParent=InsertFilteredAction(pScChangeAction,SC_CAS_VIRGIN);
+ }
+ else
+ pParent=NULL;
+
+ bTheFlag=TRUE;
+ break;
+
+ case SC_CAS_ACCEPTED:
+ pParent=NULL;
+ nAcceptCount++;
+ break;
+
+ case SC_CAS_REJECTED:
+ pParent=NULL;
+ nRejectCount++;
+ break;
+ }
+
+ if(pParent!=NULL && pScChangeAction->IsDialogParent())
+ {
+ if(!bFilterFlag)
+ {
+ pParent->EnableChildsOnDemand(TRUE);
+ }
+ else
+ {
+ BOOL bTestFlag=bHasFilterEntry;
+ bHasFilterEntry=FALSE;
+ if(Expand(pChanges,pScChangeAction,pParent,!bTestFlag)&&!bTestFlag)
+ pTheView->RemoveEntry(pParent);
+ }
+ }
+
+ pScChangeAction=pScChangeAction->GetNext();
+ }
+
+ if( bTheFlag && (!pDoc->IsDocEditable() || pChanges->IsProtected()) )
+ bTheFlag=FALSE;
+
+ pTPView->EnableAccept(bTheFlag);
+ pTPView->EnableAcceptAll(bTheFlag);
+ pTPView->EnableReject(bTheFlag);
+ pTPView->EnableRejectAll(bTheFlag);
+
+ pTheView->SetUpdateMode(TRUE);
+ SetPointer(Pointer(POINTER_ARROW));
+ }
+}
+
+void ScAcceptChgDlg::RemoveEntrys(ULONG nStartAction,ULONG nEndAction)
+{
+
+ pTheView->SetUpdateMode(FALSE);
+
+ SvLBoxEntry* pEntry=pTheView->GetCurEntry();
+
+ ScRedlinData *pEntryData=NULL;
+
+ if(pEntry!=NULL)
+ pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+
+ ULONG nAction=0;
+ if(pEntryData!=NULL)
+ {
+ nAction=pEntryData->nActionNo;
+ }
+
+ if(nAction>=nStartAction && nAction<=nEndAction)
+ {
+ pTheView->SetCurEntry(pTheView->GetModel()->GetEntry(0));
+ }
+
+ BOOL bRemove=FALSE;
+
+ // MUST do it backwards, don't delete parents before children and GPF
+ pEntry=pTheView->Last();
+ while(pEntry!=NULL)
+ {
+ bRemove=FALSE;
+ pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ nAction=pEntryData->nActionNo;
+
+ if(nStartAction<=nAction && nAction<=nEndAction) bRemove=TRUE;
+
+
+ }
+ SvLBoxEntry* pPrevEntry = pTheView->Prev(pEntry);
+
+ if(bRemove)
+ {
+ //delete pEntryData;
+ pTheView->RemoveEntry(pEntry);
+ }
+ pEntry=pPrevEntry;
+ }
+ pTheView->SetUpdateMode(TRUE);
+
+}
+
+void ScAcceptChgDlg::UpdateEntrys(ScChangeTrack* pChgTrack, ULONG nStartAction,ULONG nEndAction)
+{
+ pTheView->SetUpdateMode(FALSE);
+
+ ULONG nPos=LIST_APPEND;
+
+ BOOL bRemove=FALSE;
+
+ SvLBoxEntry* pEntry=pTheView->First();
+ SvLBoxEntry* pNextEntry = (pEntry ? pTheView->NextSibling(pEntry) : NULL);
+ SvLBoxEntry* pLastEntry=NULL;
+ while(pEntry!=NULL)
+ {
+ bRemove=FALSE;
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ ULONG nAction=pScChangeAction->GetActionNumber();
+
+ if(nStartAction<=nAction && nAction<=nEndAction) bRemove=TRUE;
+ }
+
+ if(bRemove)
+ {
+ nPos=pEntry->GetChildListPos();
+ pTheView->RemoveEntry(pEntry);
+
+ if(pLastEntry==NULL) pLastEntry=pTheView->First();
+ if(pLastEntry!=NULL)
+ {
+ pNextEntry=pTheView->Next(pLastEntry);
+
+ if(pNextEntry==NULL)
+ {
+ pNextEntry=pLastEntry;
+ pLastEntry=NULL;
+ }
+ }
+ else
+ pNextEntry=NULL;
+
+ }
+ else
+ {
+ pLastEntry = pEntry;
+ pNextEntry = pTheView->Next(pEntry);
+ }
+ pEntry=pNextEntry;
+ }
+
+ if(nStartAction==nEndAction)
+ AppendChanges(pChgTrack,nStartAction,nEndAction,nPos);
+ else
+ AppendChanges(pChgTrack,nStartAction,nEndAction);
+
+ pTheView->SetUpdateMode(TRUE);
+
+}
+
+IMPL_LINK( ScAcceptChgDlg, ChgTrackModHdl, ScChangeTrack*, pChgTrack)
+{
+// if(bScAcceptChgDlgIsDead) return 0;
+
+ ScChangeTrackMsgQueue& aMsgQueue= pChgTrack->GetMsgQueue();
+
+ ScChangeTrackMsgInfo* pTrackInfo=aMsgQueue.Get();
+ ULONG nStartAction;
+ ULONG nEndAction;
+
+ while(pTrackInfo!=NULL)
+ {
+ nStartAction=pTrackInfo->nStartAction;
+ nEndAction=pTrackInfo->nEndAction;
+
+ if(!bIgnoreMsg)
+ {
+ bNoSelection=TRUE;
+
+ switch(pTrackInfo->eMsgType)
+ {
+ case SC_CTM_APPEND: AppendChanges(pChgTrack,nStartAction,nEndAction);
+ break;
+ case SC_CTM_REMOVE: RemoveEntrys(nStartAction,nEndAction);
+ break;
+ case SC_CTM_PARENT:
+ case SC_CTM_CHANGE: //bNeedsUpdate=TRUE;
+ UpdateEntrys(pChgTrack,nStartAction,nEndAction);
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ delete pTrackInfo;
+ pTrackInfo=aMsgQueue.Get();
+ }
+
+ return 0;
+}
+IMPL_LINK( ScAcceptChgDlg, ReOpenTimerHdl, Timer*, EMPTYARG )
+{
+ ScSimpleRefDlgWrapper::SetAutoReOpen(TRUE);
+ aAcceptChgCtr.ShowFilterPage();
+ RefHandle(NULL);
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
+{
+ ScTabView* pTabView = pViewData->GetView();
+
+ BOOL bAcceptFlag = TRUE;
+ BOOL bRejectFlag = TRUE;
+ BOOL bContMark = FALSE;
+
+ pTabView->DoneBlockMode(); // clears old marking
+ SvLBoxEntry* pEntry = pTheView->FirstSelected();
+ while( pEntry )
+ {
+ ScRedlinData* pEntryData = (ScRedlinData*) pEntry->GetUserData();
+ if( pEntryData )
+ {
+ bRejectFlag &= pEntryData->bIsRejectable;
+ bAcceptFlag &= pEntryData->bIsAcceptable;
+
+ const ScChangeAction* pScChangeAction = (ScChangeAction*) pEntryData->pData;
+ if( pScChangeAction && (pScChangeAction->GetType() != SC_CAT_DELETE_TABS) &&
+ (!pEntryData->bDisabled || pScChangeAction->IsVisible()) )
+ {
+ const ScBigRange& rBigRange = pScChangeAction->GetBigRange();
+ if( rBigRange.IsValid( pDoc ) && IsActive() )
+ {
+ BOOL bSetCursor = !pTheView->NextSelected( pEntry );
+ pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
+ bContMark = TRUE;
+ }
+ }
+ }
+ else
+ {
+ bAcceptFlag = FALSE;
+ bRejectFlag = FALSE;
+ }
+ bAcceptEnableFlag = bAcceptFlag;
+ bRejectEnableFlag = bRejectFlag;
+
+ pEntry = pTheView->NextSelected( pEntry );
+ }
+
+ ScChangeTrack* pChanges = pDoc->GetChangeTrack();
+ BOOL bEnable = pDoc->IsDocEditable() && pChanges && !pChanges->IsProtected();
+ pTPView->EnableAccept( bAcceptFlag && bEnable );
+ pTPView->EnableReject( bRejectFlag && bEnable );
+
+ return 0;
+}
+
+IMPL_LINK( ScAcceptChgDlg, CommandHdl, Control*, EMPTYARG )
+{
+
+ const CommandEvent aCEvt(pTheView->GetCommandEvent());
+
+ if(aCEvt.GetCommand()==COMMAND_CONTEXTMENU)
+ {
+ ScPopupMenu aPopup(ScResId(RID_POPUP_CHANGES));
+
+ aPopup.SetMenuFlags(MENU_FLAG_HIDEDISABLEDENTRIES);
+
+ SvLBoxEntry* pEntry=pTheView->GetCurEntry();
+ if(pEntry!=NULL)
+ {
+ pTheView->Select(pEntry);
+ }
+ else
+ {
+ aPopup.Deactivate();
+ }
+
+ USHORT nSortedCol= pTheView->GetSortedCol();
+
+ if(nSortedCol!=0xFFFF)
+ {
+ USHORT nItemId=nSortedCol+SC_SUB_SORT+1;
+
+ aPopup.CheckItem(nItemId);
+
+ PopupMenu *pSubMenu = aPopup.GetPopupMenu(SC_SUB_SORT);
+ if (pSubMenu)
+ {
+ pSubMenu->CheckItem(nItemId);
+ }
+ }
+
+ aPopup.EnableItem(SC_CHANGES_COMMENT,FALSE);
+
+ if(pDoc->IsDocEditable() && pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+ if(pScChangeAction!=NULL && !pTheView->GetParent(pEntry))
+ aPopup.EnableItem(SC_CHANGES_COMMENT);
+ }
+ }
+
+ USHORT nCommand=aPopup.Execute( this, GetPointerPosPixel() );
+
+
+ if(nCommand)
+ {
+ if(nCommand==SC_CHANGES_COMMENT)
+ {
+ if(pEntry!=NULL)
+ {
+ ScRedlinData *pEntryData=(ScRedlinData *)(pEntry->GetUserData());
+ if(pEntryData!=NULL)
+ {
+ ScChangeAction* pScChangeAction=
+ (ScChangeAction*) pEntryData->pData;
+
+ pViewData->GetDocShell()->ExecuteChangeCommentDialog( pScChangeAction, this,FALSE);
+ }
+ }
+ }
+ else
+ {
+ BOOL bSortDir=pTheView->GetSortDirection();
+ USHORT nDialogCol=nCommand-SC_SUB_SORT-1;
+ if(nSortedCol==nDialogCol) bSortDir=!bSortDir;
+ pTheView->SortByCol(nDialogCol,bSortDir);
+ /*
+ SC_SUB_SORT
+ SC_SORT_ACTION
+ SC_SORT_POSITION
+ SC_SORT_AUTHOR
+ SC_SORT_DATE
+ SC_SORT_COMMENT
+ */
+ }
+ }
+ }
+ return 0;
+}
+
+void ScAcceptChgDlg::Initialize(SfxChildWinInfo *pInfo)
+{
+ String aStr;
+ if(pInfo!=NULL)
+ {
+ if ( pInfo->aExtraString.Len() )
+ {
+ xub_StrLen nPos = pInfo->aExtraString.Search(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("AcceptChgDat:")));
+
+ // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
+ // er nicht vorhanden ist, liegt eine "altere Version vor
+ if ( nPos != STRING_NOTFOUND )
+ {
+ xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
+ if ( n1 != STRING_NOTFOUND )
+ {
+ xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
+ if ( n2 != STRING_NOTFOUND )
+ {
+ // Alignment-String herausschneiden
+ aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
+ pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
+ aStr.Erase(0, n1-nPos+1);
+ }
+ }
+ }
+ }
+ }
+ SfxModelessDialog::Initialize(pInfo);
+
+ if ( aStr.Len())
+ {
+ USHORT nCount=(USHORT)aStr.ToInt32();
+
+ for(USHORT i=0;i<nCount;i++)
+ {
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ pTheView->SetTab(i,(USHORT)aStr.ToInt32(),MAP_PIXEL);
+ }
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScAcceptChgDlg::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxModelessDialog::FillInfo(rInfo);
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "AcceptChgDat:(" ));
+
+ USHORT nCount=pTheView->TabCount();
+
+ rInfo.aExtraString += String::CreateFromInt32(nCount);
+ rInfo.aExtraString += ';';
+ for(USHORT i=0;i<nCount;i++)
+ {
+ rInfo.aExtraString += String::CreateFromInt32(pTheView->GetTab(i));
+ rInfo.aExtraString += ';';
+ }
+ rInfo.aExtraString += ')';
+}
+
+void ScAcceptChgDlg::InitFilter()
+{
+ if(pTPFilter->IsDate()||pTPFilter->IsRange()||
+ pTPFilter->IsAuthor()||pTPFilter->IsComment())
+ {
+ pTheView->SetFilterDate(pTPFilter->IsDate());
+ pTheView->SetDateTimeMode(pTPFilter->GetDateMode());
+ pTheView->SetFirstDate(pTPFilter->GetFirstDate());
+ pTheView->SetLastDate(pTPFilter->GetLastDate());
+ pTheView->SetFirstTime(pTPFilter->GetFirstTime());
+ pTheView->SetLastTime(pTPFilter->GetLastTime());
+ pTheView->SetFilterAuthor(pTPFilter->IsAuthor());
+ pTheView->SetAuthor(pTPFilter->GetSelectedAuthor());
+
+ pTheView->SetFilterComment(pTPFilter->IsComment());
+
+ utl::SearchParam aSearchParam( pTPFilter->GetComment(),
+ utl::SearchParam::SRCH_REGEXP,FALSE,FALSE,FALSE );
+
+ pTheView->SetCommentParams(&aSearchParam);
+
+ pTheView->UpdateFilterTest();
+ }
+}
+
+IMPL_LINK( ScAcceptChgDlg, FilterModified, SvxTPFilter*, EMPTYARG )
+{
+ return 0;
+}
+
+#define CALC_DATE 3
+#define CALC_POS 1
+
+IMPL_LINK( ScAcceptChgDlg, ColCompareHdl, SvSortData*, pSortData )
+{
+ StringCompare eCompare=COMPARE_EQUAL;
+ SCCOL nSortCol= static_cast<SCCOL>(pTheView->GetSortedCol());
+
+ if(pSortData)
+ {
+ SvLBoxEntry* pLeft = (SvLBoxEntry*)(pSortData->pLeft );
+ SvLBoxEntry* pRight = (SvLBoxEntry*)(pSortData->pRight );
+
+ if(CALC_DATE==nSortCol)
+ {
+ RedlinData *pLeftData=(RedlinData *)(pLeft->GetUserData());
+ RedlinData *pRightData=(RedlinData *)(pRight->GetUserData());
+
+ if(pLeftData!=NULL && pRightData!=NULL)
+ {
+ if(pLeftData->aDateTime < pRightData->aDateTime)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->aDateTime > pRightData->aDateTime)
+ {
+ eCompare=COMPARE_GREATER;
+ }
+ return eCompare;
+ }
+ }
+ else if(CALC_POS==nSortCol)
+ {
+ ScRedlinData *pLeftData=(ScRedlinData *)(pLeft->GetUserData());
+ ScRedlinData *pRightData=(ScRedlinData *)(pRight->GetUserData());
+
+ if(pLeftData!=NULL && pRightData!=NULL)
+ {
+ eCompare=COMPARE_GREATER;
+
+ if(pLeftData->nTable < pRightData->nTable)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->nTable == pRightData->nTable)
+ {
+ if(pLeftData->nRow < pRightData->nRow)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->nRow == pRightData->nRow)
+ {
+ if(pLeftData->nCol < pRightData->nCol)
+ {
+ eCompare=COMPARE_LESS;
+ }
+ else if(pLeftData->nCol == pRightData->nCol)
+ {
+ eCompare=COMPARE_EQUAL;
+ }
+ }
+ }
+
+ return eCompare;
+ }
+ }
+
+ SvLBoxItem* pLeftItem = pTheView->GetEntryAtPos( pLeft, static_cast<sal_uInt16>(nSortCol));
+ SvLBoxItem* pRightItem = pTheView->GetEntryAtPos( pRight, static_cast<sal_uInt16>(nSortCol));
+
+ if(pLeftItem != NULL && pRightItem != NULL)
+ {
+ USHORT nLeftKind=pLeftItem->IsA();
+ USHORT nRightKind=pRightItem->IsA();
+
+ if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
+ nLeftKind == SV_ITEM_ID_LBOXSTRING )
+ {
+ eCompare= (StringCompare) ScGlobal::GetCaseCollator()->compareString(
+ ((SvLBoxString*)pLeftItem)->GetText(),
+ ((SvLBoxString*)pRightItem)->GetText());
+
+ if(eCompare==COMPARE_EQUAL) eCompare=COMPARE_LESS;
+ }
+ }
+
+
+ }
+ return eCompare;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/acredlin.src b/sc/source/ui/miscdlgs/acredlin.src
new file mode 100644
index 000000000000..dab2c5d91d2f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/acredlin.src
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "acredlin.hrc"
+ModelessDialog RID_SCDLG_CHANGES
+{
+ OutputSize = TRUE ;
+ HelpId = FID_CHG_ACCEPT ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 282 , 142 ) ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ // Dieser Dialog hat einen Cancel-Button !
+ Control CTR_REDLINING
+ {
+ HelpId = HID_SC_REDLIN_CTR ;
+ Pos = MAP_APPFONT ( 2 , 2 ) ;
+ Size = MAP_APPFONT ( 270 , 105 ) ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 271 , 105 ) ;
+ Size = MAP_APPFONT ( 1 , 1 ) ;
+ TabStop = FALSE ;
+ };
+ FixedText FT_ASSIGN
+ {
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 105 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Range" ;
+ };
+ Edit ED_ASSIGN
+ {
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 118 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Minimize/Maximize" ;
+ };
+ String STR_INSERT_COLS
+ {
+ Text [ en-US ] = "Column inserted" ;
+ };
+ String STR_INSERT_ROWS
+ {
+ Text [ en-US ] = "Row inserted " ;
+ };
+ String STR_INSERT_TABS
+ {
+ Text [ en-US ] = "Sheet inserted " ;
+ };
+ String STR_DELETE_COLS
+ {
+ Text [ en-US ] = "Column deleted" ;
+ };
+ String STR_DELETE_ROWS
+ {
+ Text [ en-US ] = "Row deleted" ;
+ };
+ String STR_DELETE_TABS
+ {
+ Text [ en-US ] = "Sheet deleted" ;
+ };
+ String STR_MOVE
+ {
+ Text [ en-US ] = "Range moved" ;
+ };
+ String STR_CONTENT
+ {
+ Text [ en-US ] = "Changed contents" ;
+ };
+ String STR_CONTENT_WITH_CHILD
+ {
+ Text [ en-US ] = "Changed contents" ;
+ };
+ String STR_CHILD_CONTENT
+ {
+ Text [ en-US ] = "Changed to " ;
+ };
+ String STR_CHILD_ORGCONTENT
+ {
+ Text [ en-US ] = "Original" ;
+ };
+ String STR_REJECT
+ {
+ Text [ en-US ] = "Changes rejected" ;
+ };
+ String STR_ACCEPTED
+ {
+ Text [ en-US ] = "Accepted" ;
+ };
+ String STR_REJECTED
+ {
+ Text [ en-US ] = "Rejected" ;
+ };
+ String STR_NO_ENTRY
+ {
+ Text [ en-US ] = "No Entry" ;
+ };
+ String STR_EMPTY
+ {
+ Text [ en-US ] = "<empty>" ;
+ };
+ Bitmap BMP_STR_CLOSE
+ {
+ File = "dir-clos.bmp" ;
+ };
+ Bitmap BMP_STR_OPEN
+ {
+ File = "dir-open.bmp" ;
+ };
+ Bitmap BMP_STR_END
+ {
+ File = "basobj2.bmp" ;
+ };
+ Bitmap BMP_STR_ERROR
+ {
+ File = "basbrk.bmp" ;
+ };
+ Text [ en-US ] = "Accept or Reject Changes" ;
+};
+Menu RID_POPUP_CHANGES
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SC_CHANGES_COMMENT ;
+ HelpId = HID_SC_CHANGES_COMMENT ;
+ Text [ en-US ] = "Edit Comment..." ;
+
+ };
+ MenuItem
+ {
+ Identifier = SC_SUB_SORT ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SC_SORT_ACTION ;
+ HelpID = HID_SC_SORT_ACTION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Action" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_POSITION ;
+ HelpID = HID_SORT_POSITION ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Position" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_AUTHOR ;
+ HelpID = HID_SC_SORT_AUTHOR ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Author" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_DATE ;
+ HelpID = HID_SC_SORT_DATE ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Date" ;
+ };
+ MenuItem
+ {
+ Identifier = SC_SORT_COMMENT ;
+ HelpID = HID_SC_SORT_COMMENT ;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Description" ;
+ };
+ };
+ };
+ Text [ en-US ] = "Sorting" ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
new file mode 100644
index 000000000000..09d4a4d50b52
--- /dev/null
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -0,0 +1,1013 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/viewsh.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/mnemonic.hxx>
+#include <tools/shl.hxx>
+#include <svtools/taskbar.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+
+#define ANYREFDG_CXX
+#include "anyrefdg.hxx"
+#undef ANYREFDG_CXX
+
+#include "sc.hrc"
+#include "inputhdl.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "inputwin.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "rfindlst.hxx"
+#include "compiler.hxx"
+#include "cell.hxx"
+#include "global.hxx"
+#include "inputopt.hxx"
+#include "rangeutl.hxx"
+
+
+ScFormulaReferenceHelper::ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings)
+ : m_pDlg(_pDlg)
+ , pRefEdit (NULL)
+ , m_pWindow(NULL)
+ , m_pBindings(_pBindings)
+ , pAccel( NULL )
+ , pHiddenMarks(NULL)
+ , nRefTab(0)
+ , bHighLightRef( FALSE )
+ , bAccInserted( FALSE )
+{
+ ScInputOptions aInputOption=SC_MOD()->GetInputOptions();
+ bEnableColorRef=aInputOption.GetRangeFinder();
+}
+// -----------------------------------------------------------------------------
+ScFormulaReferenceHelper::~ScFormulaReferenceHelper()
+{
+ if (bAccInserted)
+ Application::RemoveAccel( pAccel.get() );
+
+ // common cleanup for ScAnyRefDlg and ScFormulaDlg is done here
+
+ HideReference();
+ enableInput( TRUE );
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if ( pInputHdl )
+ pInputHdl->ResetDelayTimer(); // stop the timer for disabling the input line
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::enableInput( BOOL bEnable )
+{
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ // #71577# enable everything except InPlace, including bean frames
+ if ( !pFrame->GetFrame().IsInPlace() )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin)
+ {
+ Window *pParent=pWin->GetParent();
+ if(pParent)
+ {
+ pParent->EnableInput(bEnable,TRUE /* FALSE */);
+ if(TRUE /*bChilds*/)
+ pViewSh->EnableRefInput(bEnable);
+ }
+ }
+ }
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ShowSimpleReference( const XubString& rStr )
+{
+ if( /*!pRefEdit &&*/ bEnableColorRef )
+ {
+ bHighLightRef=TRUE;
+ ScViewData* pViewData=ScDocShell::GetViewData();
+ if ( pViewData )
+ {
+ ScDocument* pDoc=pViewData->GetDocument();
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+
+ ScRangeList aRangeList;
+
+ pTabViewShell->DoneRefMode( FALSE );
+ pTabViewShell->ClearHighlightRanges();
+
+ if( ParseWithNames( aRangeList, rStr, pDoc ) )
+ {
+ ScRange* pRangeEntry = aRangeList.First();
+
+ USHORT nIndex=0;
+ while(pRangeEntry != NULL)
+ {
+ ColorData aColName = ScRangeFindList::GetColorName(nIndex++);
+ pTabViewShell->AddHighlightRange(*pRangeEntry, aColName);
+
+ pRangeEntry = aRangeList.Next();
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
+{
+ bool bError = false;
+ rRanges.RemoveAll();
+
+ ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
+ ScRangeUtil aRangeUtil;
+ xub_StrLen nTokenCnt = rStr.GetTokenCount();
+ for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken )
+ {
+ ScRange aRange;
+ String aRangeStr( rStr.GetToken( nToken ) );
+
+ USHORT nFlags = aRange.ParseAny( aRangeStr, pDoc, aDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ aRange.aStart.SetTab( nRefTab );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ aRange.aEnd.SetTab( aRange.aStart.Tab() );
+ rRanges.Append( aRange );
+ }
+ else if ( aRangeUtil.MakeRangeFromName( aRangeStr, pDoc, nRefTab, aRange, RUTL_NAMES, aDetails ) )
+ rRanges.Append( aRange );
+ else
+ bError = true;
+ }
+
+ return !bError;
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ShowFormulaReference( const XubString& rStr )
+{
+ if( /*!pRefEdit &&*/ bEnableColorRef)
+ {
+ bHighLightRef=TRUE;
+ ScViewData* pViewData=ScDocShell::GetViewData();
+ if ( pViewData && pRefComp.get() )
+ {
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScAddress aPos( nCol, nRow, nTab );
+
+ ScTokenArray* pScTokA=pRefComp->CompileString(rStr);
+ //pRefComp->CompileTokenArray();
+
+ if(pTabViewShell!=NULL && pScTokA!=NULL)
+ {
+ pTabViewShell->DoneRefMode( FALSE );
+ pTabViewShell->ClearHighlightRanges();
+
+ pScTokA->Reset();
+ const ScToken* pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
+
+ USHORT nIndex=0;
+
+ while(pToken!=NULL)
+ {
+ BOOL bDoubleRef=(pToken->GetType()==formula::svDoubleRef);
+
+
+ if(pToken->GetType()==formula::svSingleRef || bDoubleRef)
+ {
+ ScRange aRange;
+ if(bDoubleRef)
+ {
+ ScComplexRefData aRef( pToken->GetDoubleRef() );
+ aRef.CalcAbsIfRel( aPos );
+ aRange.aStart.Set( aRef.Ref1.nCol, aRef.Ref1.nRow, aRef.Ref1.nTab );
+ aRange.aEnd.Set( aRef.Ref2.nCol, aRef.Ref2.nRow, aRef.Ref2.nTab );
+ }
+ else
+ {
+ ScSingleRefData aRef( pToken->GetSingleRef() );
+ aRef.CalcAbsIfRel( aPos );
+ aRange.aStart.Set( aRef.nCol, aRef.nRow, aRef.nTab );
+ aRange.aEnd = aRange.aStart;
+ }
+ ColorData aColName=ScRangeFindList::GetColorName(nIndex++);
+ pTabViewShell->AddHighlightRange(aRange, aColName);
+ }
+
+ pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
+ }
+ }
+ if(pScTokA!=NULL) delete pScTokA;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::HideReference( BOOL bDoneRefMode )
+{
+ ScViewData* pViewData=ScDocShell::GetViewData();
+
+ if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef)
+ {
+ ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
+
+ if(pTabViewShell!=NULL)
+ {
+ // bDoneRefMode is FALSE when called from before SetReference.
+ // In that case, RefMode was just started and must not be ended now.
+
+ if ( bDoneRefMode )
+ pTabViewShell->DoneRefMode( FALSE );
+ pTabViewShell->ClearHighlightRanges();
+ }
+ bHighLightRef=FALSE;
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ShowReference( const XubString& rStr )
+{
+ if( /*!pRefEdit &&*/ bEnableColorRef )
+ {
+ if( rStr.Search('(')!=STRING_NOTFOUND ||
+ rStr.Search('+')!=STRING_NOTFOUND ||
+ rStr.Search('*')!=STRING_NOTFOUND ||
+ rStr.Search('-')!=STRING_NOTFOUND ||
+ rStr.Search('/')!=STRING_NOTFOUND ||
+ rStr.Search('&')!=STRING_NOTFOUND ||
+ rStr.Search('<')!=STRING_NOTFOUND ||
+ rStr.Search('>')!=STRING_NOTFOUND ||
+ rStr.Search('=')!=STRING_NOTFOUND ||
+ rStr.Search('^')!=STRING_NOTFOUND)
+ {
+ ShowFormulaReference(rStr);
+ }
+ else
+ {
+ ShowSimpleReference(rStr);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ if( !pRefEdit && pEdit )
+ {
+ m_pDlg->RefInputStart( pEdit, pButton );
+// if( pRefEdit )
+// pRefEdit->SilentGrabFocus();
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if( pViewShell )
+ {
+ pViewShell->ActiveGrabFocus();
+ if( pRefEdit )
+ {
+ const ScViewData* pViewData = pViewShell->GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScRangeList aRangeList;
+ if( ParseWithNames( aRangeList, pRefEdit->GetText(), pDoc ) )
+ {
+ const ScRange* pRange = aRangeList.GetObject( 0 );
+ if( pRange )
+ {
+ pViewShell->SetTabNo( pRange->aStart.Tab() );
+ pViewShell->MoveCursorAbs( pRange->aStart.Col(),
+ pRange->aStart.Row(), SC_FOLLOW_JUMP, FALSE, FALSE );
+ pViewShell->MoveCursorAbs( pRange->aEnd.Col(),
+ pRange->aEnd.Row(), SC_FOLLOW_JUMP, TRUE, FALSE );
+ m_pDlg->SetReference( *pRange, pDoc );
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::Init()
+{
+ ScViewData* pViewData=ScDocShell::GetViewData(); //! use pScViewShell?
+ if ( pViewData )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScAddress aCursorPos( nCol, nRow, nTab );
+
+ String rStrExp;
+ pRefCell.reset( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
+ pRefComp.reset( new ScCompiler( pDoc, aCursorPos) );
+ pRefComp->SetGrammar( pDoc->GetGrammar() );
+ pRefComp->SetCompileForFAP(TRUE);
+
+ nRefTab = nTab;
+ } // if ( pViewData )
+}
+// -----------------------------------------------------------------------------
+IMPL_LINK( ScFormulaReferenceHelper, AccelSelectHdl, Accelerator *, pSelAccel )
+{
+ if ( !pSelAccel )
+ return 0;
+
+ switch ( pSelAccel->GetCurKeyCode().GetCode() )
+ {
+ case KEY_RETURN:
+ case KEY_ESCAPE:
+ if( pRefEdit )
+ pRefEdit->GrabFocus();
+ m_pDlg->RefInputDone( TRUE );
+ break;
+ }
+ return TRUE;
+}
+//----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::RefInputDone( BOOL bForced )
+{
+ //<!--Modified by PengYunQuan for Validity Cell Range Picker
+ //if (pRefEdit && (bForced || !pRefBtn))
+ if ( CanInputDone( bForced ) )//if (pRefEdit && (bForced || !pRefBtn))
+ //-->Modified by PengYunQuan for Validity Cell Range Picker
+ {
+ if (bAccInserted) // Accelerator wieder abschalten
+ {
+ Application::RemoveAccel( pAccel.get() );
+ bAccInserted = FALSE;
+ }
+
+ // Fenstertitel anpassen
+ m_pWindow->SetText(sOldDialogText);
+
+ // Fenster wieder gross
+ m_pWindow->SetOutputSizePixel(aOldDialogSize);
+
+ // pEditCell an alte Position
+ pRefEdit->SetPosSizePixel(aOldEditPos, aOldEditSize);
+
+ // set button position and image
+ if( pRefBtn )
+ {
+ pRefBtn->SetPosPixel( aOldButtonPos );
+ pRefBtn->SetStartImage();
+ }
+
+ // Alle anderen: Show();
+ USHORT nChildren = m_pWindow->GetChildCount();
+ for ( USHORT i = 0; i < nChildren; i++ )
+ if (pHiddenMarks[i])
+ {
+ m_pWindow->GetChild(i)->GetWindow( WINDOW_CLIENT )->Show();
+ }
+ delete [] pHiddenMarks;
+
+ pRefEdit = NULL;
+ pRefBtn = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ if (!pRefEdit)
+ {
+ pRefEdit = pEdit;
+ pRefBtn = pButton;
+
+ // Neuen Fenstertitel basteln
+ String sNewDialogText;
+ sOldDialogText = m_pWindow->GetText();
+ sNewDialogText = sOldDialogText;
+ sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+
+ // Alle Elemente ausser EditCell und Button verstecken
+ USHORT nChildren = m_pWindow->GetChildCount();
+ pHiddenMarks = new BOOL [nChildren];
+ for (USHORT i = 0; i < nChildren; i++)
+ {
+ pHiddenMarks[i] = FALSE;
+ Window* pWin = m_pWindow->GetChild(i);
+ pWin = pWin->GetWindow( WINDOW_CLIENT );
+ if (pWin == (Window*)pRefEdit)
+ {
+ sNewDialogText += m_pWindow->GetChild(i-1)->GetWindow( WINDOW_CLIENT )->GetText();
+ }
+ else if (pWin == (Window*)pRefBtn)
+ ; // do nothing
+ else if (pWin->IsVisible())
+ {
+ pHiddenMarks[i] = TRUE;
+ pWin->Hide();
+ }
+ }
+
+ // Alte Daten merken
+ aOldDialogSize = m_pWindow->GetOutputSizePixel();
+ aOldEditPos = pRefEdit->GetPosPixel();
+ aOldEditSize = pRefEdit->GetSizePixel();
+ if (pRefBtn)
+ aOldButtonPos = pRefBtn->GetPosPixel();
+
+ // Edit-Feld verschieben und anpassen
+ Size aNewDlgSize(aOldDialogSize.Width(), aOldEditSize.Height());
+ Size aNewEditSize(aNewDlgSize);
+ long nOffset = 0;
+ if (pRefBtn)
+ {
+ aNewEditSize.Width() -= pRefBtn->GetSizePixel().Width();
+ aNewEditSize.Width() -= aOldButtonPos.X() - (aOldEditPos.X()+aOldEditSize.Width());
+
+ long nHeight = pRefBtn->GetSizePixel().Height();
+ if ( nHeight > aOldEditSize.Height() )
+ {
+ aNewDlgSize.Height() = nHeight;
+ nOffset = (nHeight-aOldEditSize.Height()) / 2;
+ }
+ aNewEditSize.Width() -= nOffset;
+ }
+ pRefEdit->SetPosSizePixel(Point(nOffset, nOffset), aNewEditSize);
+
+ // set button position and image
+ if( pRefBtn )
+ {
+ pRefBtn->SetPosPixel( Point( aOldDialogSize.Width() - pRefBtn->GetSizePixel().Width(), 0 ) );
+ pRefBtn->SetEndImage();
+ }
+
+ // Fenster verkleinern
+ m_pWindow->SetOutputSizePixel(aNewDlgSize);
+
+ // Fenstertitel anpassen
+ m_pWindow->SetText( MnemonicGenerator::EraseAllMnemonicChars( sNewDialogText ) );
+
+// if ( pButton ) // ueber den Button: Enter und Escape abfangen
+// {
+ if (!pAccel.get())
+ {
+ pAccel.reset( new Accelerator );
+ pAccel->InsertItem( 1, KeyCode( KEY_RETURN ) );
+ pAccel->InsertItem( 2, KeyCode( KEY_ESCAPE ) );
+ pAccel->SetSelectHdl( LINK( this, ScFormulaReferenceHelper, AccelSelectHdl ) );
+ }
+ Application::InsertAccel( pAccel.get() );
+ bAccInserted = TRUE;
+// }
+ }
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ if( pEdit )
+ {
+ if( pRefEdit == pEdit ) // is this the active ref edit field?
+ {
+ pRefEdit->GrabFocus(); // before RefInputDone()
+ m_pDlg->RefInputDone( TRUE ); // finish ref input
+ }
+ else
+ {
+ m_pDlg->RefInputDone( TRUE ); // another active ref edit?
+ m_pDlg->RefInputStart( pEdit, pButton ); // start ref input
+ // pRefEdit might differ from pEdit after RefInputStart() (i.e. ScFormulaDlg)
+ if( pRefEdit )
+ pRefEdit->GrabFocus();
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+BOOL ScFormulaReferenceHelper::DoClose( USHORT nId )
+{
+ SfxApplication* pSfxApp = SFX_APP();
+
+ SetDispatcherLock( FALSE ); //! here and in dtor ?
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if ( pViewFrm && pViewFrm->HasChildWindow(FID_INPUTLINE_STATUS) )
+ {
+ // Die Eingabezeile wird per ToolBox::Disable disabled, muss darum auch
+ // per ToolBox::Enable wieder aktiviert werden (vor dem Enable des AppWindow),
+ // damit die Buttons auch wieder enabled gezeichnet werden.
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_INPUTLINE_STATUS);
+ if (pChild)
+ {
+ ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow();
+ pWin->Enable();
+ }
+ }
+
+ // find parent view frame to close dialog
+ SfxViewFrame* pMyViewFrm = NULL;
+ if ( m_pBindings )
+ {
+ SfxDispatcher* pMyDisp = m_pBindings->GetDispatcher();
+ if (pMyDisp)
+ pMyViewFrm = pMyDisp->GetFrame();
+ }
+ SC_MOD()->SetRefDialog( nId, FALSE, pMyViewFrm );
+
+ pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
+
+ ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ if ( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+
+ return TRUE;
+}
+void ScFormulaReferenceHelper::SetDispatcherLock( BOOL bLock )
+{
+ // lock / unlock only the dispatchers of Calc documents
+
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ SfxDispatcher* pDisp = pFrame->GetDispatcher();
+ if (pDisp)
+ pDisp->Lock( bLock );
+
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+
+ // if a new view is created while the dialog is open,
+ // that view's dispatcher is locked when trying to create the dialog
+ // for that view (ScTabViewShell::CreateRefDialog)
+}
+// -----------------------------------------------------------------------------
+void ScFormulaReferenceHelper::ViewShellChanged(ScTabViewShell* /* pScViewShell */)
+{
+ enableInput( FALSE );
+
+ EnableSpreadsheets();
+}
+void ScFormulaReferenceHelper::EnableSpreadsheets(BOOL bFlag, BOOL bChilds)
+{
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ // #71577# enable everything except InPlace, including bean frames
+ if ( !pFrame->GetFrame().IsInPlace() )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin)
+ {
+ Window *pParent=pWin->GetParent();
+ if(pParent)
+ {
+ pParent->EnableInput(bFlag,FALSE);
+ if(bChilds)
+ pViewSh->EnableRefInput(bFlag);
+ }
+ }
+ }
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+}
+
+//----------------------------------------------------------------------------
+
+
+
+void lcl_InvalidateWindows()
+{
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ while( pDocShell )
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame )
+ {
+ // #71577# enable everything except InPlace, including bean frames
+ if ( !pFrame->GetFrame().IsInPlace() )
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ Window *pWin=pViewSh->GetWindow();
+ if(pWin)
+ {
+ Window *pParent=pWin->GetParent();
+ if(pParent)
+ pParent->Invalidate();
+ }
+ }
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+ pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
+ }
+}
+//----------------------------------------------------------------------------
+
+void lcl_HideAllReferences()
+{
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh )
+ {
+ ((ScTabViewShell*)pSh)->ClearHighlightRanges();
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+}
+
+//============================================================================
+//The class of ScAnyRefDlg is rewritten by PengYunQuan for Validity Cell Range Picker
+// class ScRefHandler
+//----------------------------------------------------------------------------
+
+ScRefHandler::ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
+ Window* pParent, USHORT nResId*/, bool bBindRef )
+ : //SfxModelessDialog ( pB, pCW, pParent, ScResId( nResId ) ),
+ m_rWindow( rWindow ),
+ m_bInRefMode( false ),
+ m_aHelper(this,pB),
+ pMyBindings( pB ),
+ pActiveWin(NULL)
+{
+ m_aHelper.SetWindow(/*this*/&m_rWindow);
+ if(m_rWindow.GetHelpId()==0) //Hack, da im SfxModelessDialog die HelpId
+ m_rWindow.SetHelpId(m_rWindow.GetUniqueId()); //fuer einen ModelessDialog entfernt und
+ //in eine UniqueId gewandelt wird, machen
+ //wir das an dieser Stelle rueckgaengig.
+ aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, ScRefHandler, UpdateFocusHdl));
+
+ if( bBindRef ) EnterRefMode();
+}
+
+bool ScRefHandler::EnterRefMode()
+{
+ if( m_bInRefMode ) return false;
+
+ SC_MOD()->InputEnterHandler();
+// ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScTabViewShell* pScViewShell = NULL;
+
+ // title has to be from the view that opened the dialog,
+ // even if it's not the current view
+
+ SfxObjectShell* pParentDoc = NULL;
+ if ( pMyBindings )
+ {
+ SfxDispatcher* pMyDisp = pMyBindings->GetDispatcher();
+ if (pMyDisp)
+ {
+ SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
+ if (pMyViewFrm)
+ {
+ pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() );
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+ pParentDoc = pMyViewFrm->GetObjectShell();
+ }
+ }
+ }
+ if ( !pParentDoc && pScViewShell ) // use current only if above fails
+ pParentDoc = pScViewShell->GetObjectShell();
+ if ( pParentDoc )
+ aDocName = pParentDoc->GetTitle();
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
+
+ DBG_ASSERT( pInputHdl, "Missing input handler :-/" );
+
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+
+ m_aHelper.enableInput( FALSE );
+
+ m_aHelper.EnableSpreadsheets();
+
+ m_aHelper.Init();
+
+ m_aHelper.SetDispatcherLock( TRUE );
+ //@Test
+ //SFX_APPWINDOW->Disable(TRUE); //@BugID 54702
+
+ return m_bInRefMode = true;
+}
+
+//----------------------------------------------------------------------------
+
+ScRefHandler::~ScRefHandler()
+{
+ LeaveRefMode();
+}
+
+bool ScRefHandler::LeaveRefMode()
+{
+ if( !m_bInRefMode ) return false;
+
+ lcl_HideAllReferences();
+
+ if( Dialog *pDlg = dynamic_cast<Dialog*>( static_cast<Window*>(*this) ) )
+ pDlg->SetModalInputMode(FALSE);
+ SetDispatcherLock( FALSE ); //! here and in DoClose ?
+
+ ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+
+ //SFX_APPWINDOW->Enable(TRUE,TRUE);
+ lcl_InvalidateWindows();
+
+ m_bInRefMode = false;
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+//SfxBindings& ScRefHandler::GetBindings()
+//{
+// //! SfxModelessDialog should allow access to pBindings pointer
+//
+// return *pMyBindings;
+//}
+
+//----------------------------------------------------------------------------
+
+void ScRefHandler::SwitchToDocument()
+{
+ ScTabViewShell* pCurrent = ScTabViewShell::GetActiveViewShell();
+ if (pCurrent)
+ {
+ SfxObjectShell* pObjSh = pCurrent->GetObjectShell();
+ if ( pObjSh && pObjSh->GetTitle() == aDocName )
+ {
+ // right document already visible -> nothing to do
+ return;
+ }
+ }
+
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh )
+ {
+ SfxObjectShell* pObjSh = pSh->GetObjectShell();
+ if ( pObjSh && pObjSh->GetTitle() == aDocName )
+ {
+ // switch to first TabViewShell for document
+ ((ScTabViewShell*)pSh)->SetActive();
+ return;
+ }
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScRefHandler::IsDocAllowed(SfxObjectShell* pDocSh) const // pDocSh may be 0
+{
+ // default: allow only same document (overridden in function dialog)
+ String aCmpName;
+ if ( pDocSh )
+ aCmpName = pDocSh->GetTitle();
+
+ // if aDocName isn't initialized, allow
+ return ( aDocName.Len() == 0 || aDocName == aCmpName );
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScRefHandler::IsRefInputMode() const
+{
+ return m_rWindow.IsVisible(); // nur wer sichtbar ist kann auch Referenzen bekommen
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScRefHandler::DoClose( USHORT nId )
+{
+ m_aHelper.DoClose(nId);
+ return TRUE;
+}
+
+void ScRefHandler::SetDispatcherLock( BOOL bLock )
+{
+ m_aHelper.SetDispatcherLock( bLock );
+}
+
+//----------------------------------------------------------------------------
+
+void ScRefHandler::ViewShellChanged(ScTabViewShell* pScViewShell )
+{
+ m_aHelper.ViewShellChanged(pScViewShell);
+}
+
+//----------------------------------------------------------------------------
+
+void ScRefHandler::AddRefEntry()
+{
+ // wenn nicht ueberladen, gibt es keine Mehrfach-Referenzen
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScRefHandler::IsTableLocked() const
+{
+ // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
+
+ return FALSE;
+}
+
+//----------------------------------------------------------------------------
+//
+// RefInputStart/Done: Zoom-In (AutoHide) auf einzelnes Feld
+// (per Button oder Bewegung)
+//
+//----------------------------------------------------------------------------
+
+void ScRefHandler::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ m_aHelper.RefInputStart( pEdit, pButton );
+}
+
+
+void ScRefHandler::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ m_aHelper.ToggleCollapsed( pEdit, pButton );
+}
+
+//The two following function is commentted out by PengYunQuan for Validity Cell Range Picker
+//long ScAnyRefDlg::PreNotify( NotifyEvent& rNEvt )
+//{
+// USHORT nSwitch=rNEvt.GetType();
+// if(nSwitch==EVENT_GETFOCUS)
+// {
+// pActiveWin=rNEvt.GetWindow();
+// }
+// return SfxModelessDialog::PreNotify(rNEvt);
+//}
+//
+//void ScAnyRefDlg::StateChanged( StateChangedType nStateChange )
+//{
+// SfxModelessDialog::StateChanged( nStateChange );
+//
+// if(nStateChange == STATE_CHANGE_VISIBLE)
+// {
+// if(IsVisible())
+// {
+// m_aHelper.enableInput( FALSE );
+// m_aHelper.EnableSpreadsheets();
+// m_aHelper.SetDispatcherLock( TRUE );
+// aTimer.Start();
+// }
+// else
+// {
+// m_aHelper.enableInput( TRUE );
+// m_aHelper.SetDispatcherLock( FALSE ); //! here and in DoClose ?
+// }
+// }
+//}
+
+#if defined( _MSC_VER )
+#define INTRODUCE_TEMPLATE
+#else
+#define INTRODUCE_TEMPLATE template <>
+#endif
+
+#define IMPL_TWINDOW_PRENOTIFY( TWindow,bBindRef ) \
+INTRODUCE_TEMPLATE long ScRefHdlrImplBase<TWindow,bBindRef>::PreNotify( NotifyEvent& rNEvt )\
+{\
+ if( bBindRef || m_bInRefMode )\
+ {\
+ USHORT nSwitch=rNEvt.GetType();\
+ if(nSwitch==EVENT_GETFOCUS)\
+ {\
+ pActiveWin=rNEvt.GetWindow();\
+ }\
+ }\
+ return TWindow::PreNotify(rNEvt);\
+}
+
+#define IMPL_TWINDOW_STATECHANGED( TWindow,bBindRef ) \
+INTRODUCE_TEMPLATE void ScRefHdlrImplBase<TWindow,bBindRef>::StateChanged( StateChangedType nStateChange )\
+{\
+ TWindow::StateChanged( nStateChange );\
+\
+ if( !bBindRef && !m_bInRefMode ) return;\
+ \
+ if(nStateChange == STATE_CHANGE_VISIBLE)\
+ {\
+ if(m_rWindow.IsVisible())\
+ {\
+ m_aHelper.enableInput( FALSE );\
+ m_aHelper.EnableSpreadsheets();\
+ m_aHelper.SetDispatcherLock( TRUE );\
+ aTimer.Start();\
+ }\
+ else\
+ {\
+ m_aHelper.enableInput( TRUE );\
+ m_aHelper.SetDispatcherLock( FALSE ); /*//! here and in DoClose ?*/\
+ }\
+ }\
+}
+
+IMPL_TWINDOW_PRENOTIFY( SfxModelessDialog, true )
+IMPL_TWINDOW_PRENOTIFY( SfxTabDialog, false )
+IMPL_TWINDOW_STATECHANGED( SfxModelessDialog, true )
+IMPL_TWINDOW_STATECHANGED( SfxTabDialog, false )
+
+IMPL_LINK( ScRefHandler, UpdateFocusHdl, Timer*, EMPTYARG )
+{
+ if (pActiveWin)
+ {
+ pActiveWin->GrabFocus();
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+bool ScRefHandler::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
+{
+ return m_aHelper.ParseWithNames( rRanges, rStr, pDoc );
+}
+// -----------------------------------------------------------------------------
+void ScRefHandler::HideReference( BOOL bDoneRefMode )
+{
+ m_aHelper.HideReference( bDoneRefMode );
+}
+// -----------------------------------------------------------------------------
+void ScRefHandler::ShowReference( const XubString& rStr )
+{
+ m_aHelper.ShowReference( rStr );
+}
+// -----------------------------------------------------------------------------
+void ScRefHandler::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ m_aHelper.ReleaseFocus( pEdit,pButton );
+}
+//----------------------------------------------------------------------------
+void ScRefHandler::RefInputDone( BOOL bForced )
+{
+ m_aHelper.RefInputDone( bForced );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/autofmt.cxx b/sc/source/ui/miscdlgs/autofmt.cxx
new file mode 100644
index 000000000000..12a332fd02f9
--- /dev/null
+++ b/sc/source/ui/miscdlgs/autofmt.cxx
@@ -0,0 +1,569 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "attrib.hxx"
+#include "zforauto.hxx"
+#include "scitems.hxx"
+#include "global.hxx"
+#include "globstr.hrc"
+#include "autoform.hxx"
+#include "miscdlgs.hrc"
+#include "autofmt.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+
+#define FRAME_OFFSET 4
+
+
+//========================================================================
+// ScAutoFmtPreview
+
+ScAutoFmtPreview::ScAutoFmtPreview( Window* pParent, const ResId& rRes, ScDocument* pDoc ) :
+ Window ( pParent, rRes ),
+ pCurData ( NULL ),
+ aVD ( *this ),
+ aScriptedText ( aVD ),
+ xBreakIter ( pDoc->GetBreakIterator() ),
+ bFitWidth ( FALSE ),
+ mbRTL ( false ),
+ aPrvSize ( GetSizePixel().Width() - 6, GetSizePixel().Height() - 30 ),
+ mnLabelColWidth ( (aPrvSize.Width() - 4) / 4 - 12 ),
+ mnDataColWidth1 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 3 ),
+ mnDataColWidth2 ( (aPrvSize.Width() - 4 - 2 * mnLabelColWidth) / 4 ),
+ mnRowHeight ( (aPrvSize.Height() - 4) / 5 ),
+ aStrJan ( ScResId( STR_JAN ) ),
+ aStrFeb ( ScResId( STR_FEB ) ),
+ aStrMar ( ScResId( STR_MAR ) ),
+ aStrNorth ( ScResId( STR_NORTH ) ),
+ aStrMid ( ScResId( STR_MID ) ),
+ aStrSouth ( ScResId( STR_SOUTH ) ),
+ aStrSum ( ScResId( STR_SUM ) ),
+ pNumFmt ( new SvNumberFormatter( ::comphelper::getProcessServiceFactory(), ScGlobal::eLnge ) )
+{
+ Init();
+}
+
+//------------------------------------------------------------------------
+
+ScAutoFmtPreview::~ScAutoFmtPreview()
+{
+ delete pNumFmt;
+}
+
+//------------------------------------------------------------------------
+
+void lcl_SetFontProperties(
+ Font& rFont,
+ const SvxFontItem& rFontItem,
+ const SvxWeightItem& rWeightItem,
+ const SvxPostureItem& rPostureItem )
+{
+ rFont.SetFamily ( rFontItem.GetFamily() );
+ rFont.SetName ( rFontItem.GetFamilyName() );
+ rFont.SetStyleName ( rFontItem.GetStyleName() );
+ rFont.SetCharSet ( rFontItem.GetCharSet() );
+ rFont.SetPitch ( rFontItem.GetPitch() );
+ rFont.SetWeight ( (FontWeight)rWeightItem.GetValue() );
+ rFont.SetItalic ( (FontItalic)rPostureItem.GetValue() );
+}
+
+void ScAutoFmtPreview::MakeFonts( USHORT nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont )
+{
+ if ( pCurData )
+ {
+ rFont = rCJKFont = rCTLFont = GetFont();
+ Size aFontSize( rFont.GetSize().Width(), 10 );
+
+ const SvxFontItem* pFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_FONT );
+ const SvxWeightItem* pWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_FONT_WEIGHT );
+ const SvxPostureItem* pPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_FONT_POSTURE );
+ const SvxFontItem* pCJKFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT );
+ const SvxWeightItem* pCJKWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT_WEIGHT );
+ const SvxPostureItem* pCJKPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_CJK_FONT_POSTURE );
+ const SvxFontItem* pCTLFontItem = (const SvxFontItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT );
+ const SvxWeightItem* pCTLWeightItem = (const SvxWeightItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT_WEIGHT );
+ const SvxPostureItem* pCTLPostureItem = (const SvxPostureItem*) pCurData->GetItem( nIndex, ATTR_CTL_FONT_POSTURE );
+ const SvxUnderlineItem* pUnderlineItem = (const SvxUnderlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_UNDERLINE );
+ const SvxOverlineItem* pOverlineItem = (const SvxOverlineItem*) pCurData->GetItem( nIndex, ATTR_FONT_OVERLINE );
+ const SvxCrossedOutItem* pCrossedOutItem = (const SvxCrossedOutItem*)pCurData->GetItem( nIndex, ATTR_FONT_CROSSEDOUT );
+ const SvxContourItem* pContourItem = (const SvxContourItem*) pCurData->GetItem( nIndex, ATTR_FONT_CONTOUR );
+ const SvxShadowedItem* pShadowedItem = (const SvxShadowedItem*) pCurData->GetItem( nIndex, ATTR_FONT_SHADOWED );
+ const SvxColorItem* pColorItem = (const SvxColorItem*) pCurData->GetItem( nIndex, ATTR_FONT_COLOR );
+
+ lcl_SetFontProperties( rFont, *pFontItem, *pWeightItem, *pPostureItem );
+ lcl_SetFontProperties( rCJKFont, *pCJKFontItem, *pCJKWeightItem, *pCJKPostureItem );
+ lcl_SetFontProperties( rCTLFont, *pCTLFontItem, *pCTLWeightItem, *pCTLPostureItem );
+
+ Color aColor( pColorItem->GetValue() );
+ if( aColor.GetColor() == COL_TRANSPARENT )
+ aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
+
+#define SETONALLFONTS( MethodName, Value ) \
+rFont.MethodName( Value ); rCJKFont.MethodName( Value ); rCTLFont.MethodName( Value );
+
+ SETONALLFONTS( SetUnderline, (FontUnderline)pUnderlineItem->GetValue() )
+ SETONALLFONTS( SetOverline, (FontUnderline)pOverlineItem->GetValue() )
+ SETONALLFONTS( SetStrikeout, (FontStrikeout)pCrossedOutItem->GetValue() )
+ SETONALLFONTS( SetOutline, pContourItem->GetValue() )
+ SETONALLFONTS( SetShadow, pShadowedItem->GetValue() )
+ SETONALLFONTS( SetColor, aColor )
+ SETONALLFONTS( SetSize, aFontSize )
+ SETONALLFONTS( SetTransparent, TRUE )
+
+#undef SETONALLFONTS
+ }
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScAutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
+{
+ static const USHORT pnFmtMap[] =
+ {
+ 0, 1, 2, 1, 3,
+ 4, 5, 6, 5, 7,
+ 8, 9, 10, 9, 11,
+ 4, 5, 6, 5, 7,
+ 12, 13, 14, 13, 15
+ };
+ return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
+}
+
+const SvxBoxItem& ScAutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
+{
+ DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetBoxItem - no format data found" );
+ return *static_cast< const SvxBoxItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BORDER ) );
+}
+
+const SvxLineItem& ScAutoFmtPreview::GetDiagItem( size_t nCol, size_t nRow, bool bTLBR ) const
+{
+ DBG_ASSERT( pCurData, "ScAutoFmtPreview::GetDiagItem - no format data found" );
+ return *static_cast< const SvxLineItem* >( pCurData->GetItem( GetFormatIndex( nCol, nRow ), bTLBR ? ATTR_BORDER_TLBR : ATTR_BORDER_BLTR ) );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DrawString( size_t nCol, size_t nRow )
+{
+ if ( pCurData )
+ {
+ //------------------------
+ // Ausgabe des Zelltextes:
+ //------------------------
+
+ String cellString;
+ BOOL bNumFormat = pCurData->GetIncludeValueFormat();
+ ULONG nNum;
+ double nVal;
+ Color* pDummy = NULL;
+ USHORT nIndex = static_cast< USHORT >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
+
+ switch( nIndex )
+ {
+ case 1: cellString = aStrJan; break;
+ case 2: cellString = aStrFeb; break;
+ case 3: cellString = aStrMar; break;
+ case 5: cellString = aStrNorth; break;
+ case 10: cellString = aStrMid; break;
+ case 15: cellString = aStrSouth; break;
+ case 4:
+ case 20: cellString = aStrSum; break;
+
+ case 6:
+ case 8:
+ case 16:
+ case 18: nVal = nIndex;
+ nNum = 5;
+ goto mknum;
+ case 17:
+ case 7: nVal = nIndex;
+ nNum = 6;
+ goto mknum;
+ case 11:
+ case 12:
+ case 13: nVal = nIndex;
+ nNum = 12 == nIndex ? 10 : 9;
+ goto mknum;
+
+ case 9: nVal = 21; nNum = 7; goto mknum;
+ case 14: nVal = 36; nNum = 11; goto mknum;
+ case 19: nVal = 51; nNum = 7; goto mknum;
+ case 21: nVal = 33; nNum = 13; goto mknum;
+ case 22: nVal = 36; nNum = 14; goto mknum;
+ case 23: nVal = 39; nNum = 13; goto mknum;
+ case 24: nVal = 108; nNum = 15;
+ mknum:
+ if( bNumFormat )
+ {
+ ScNumFormatAbbrev& rNumFormat = (ScNumFormatAbbrev&)pCurData->GetNumFormat( (USHORT) nNum );
+ nNum = rNumFormat.GetFormatIndex( *pNumFmt );
+ }
+ else
+ nNum = 0;
+ pNumFmt->GetOutputString( nVal, nNum, cellString, &pDummy );
+ break;
+ }
+
+ if ( cellString.Len() > 0 )
+ {
+ Size aStrSize;
+ USHORT nFmtIndex = GetFormatIndex( nCol, nRow );
+ Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
+ Point aPos = cellRect.TopLeft();
+ USHORT nRightX = 0;
+ BOOL bJustify = pCurData->GetIncludeJustify();
+ SvxHorJustifyItem aHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD, ATTR_HOR_JUSTIFY );
+ SvxCellHorJustify eJustification;
+
+ //-------------
+ // Ausrichtung:
+ //-------------
+ eJustification = mbRTL ? SVX_HOR_JUSTIFY_RIGHT : bJustify ?
+ (SvxCellHorJustify)(((const SvxHorJustifyItem*)pCurData->GetItem( nFmtIndex, ATTR_HOR_JUSTIFY ))->GetValue()) :
+ SVX_HOR_JUSTIFY_STANDARD;
+
+ if ( pCurData->GetIncludeFont() )
+ {
+ Font aFont, aCJKFont, aCTLFont;
+ Size theMaxStrSize;
+
+ MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
+
+ theMaxStrSize = cellRect.GetSize();
+ theMaxStrSize.Width() -= FRAME_OFFSET;
+ theMaxStrSize.Height() -= FRAME_OFFSET;
+
+ aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
+ aScriptedText.SetText( cellString, xBreakIter );
+ aStrSize = aScriptedText.GetTextSize();
+
+ if ( theMaxStrSize.Height() < aStrSize.Height() )
+ {
+ // wenn der String in diesem Font nicht
+ // in die Zelle passt, wird wieder der
+ // Standard-Font genommen:
+ aScriptedText.SetDefaultFont();
+ aStrSize = aScriptedText.GetTextSize();
+ }
+ while ( ( theMaxStrSize.Width() <= aStrSize.Width() )
+ && ( cellString.Len() > 1 ) )
+ {
+ if( eJustification == SVX_HOR_JUSTIFY_RIGHT )
+ cellString.Erase( 0, 1 );
+ else
+ cellString.Erase( cellString.Len() - 1 );
+
+ aScriptedText.SetText( cellString, xBreakIter );
+ aStrSize = aScriptedText.GetTextSize();
+ }
+ }
+ else
+ {
+ aScriptedText.SetDefaultFont();
+ aScriptedText.SetText( cellString, xBreakIter );
+ aStrSize = aScriptedText.GetTextSize();
+ }
+
+ nRightX = (USHORT)( cellRect.GetWidth()
+ - aStrSize.Width()
+ - FRAME_OFFSET );
+
+ //-----------------------------
+ // vertikal (immer zentrieren):
+ //-----------------------------
+ aPos.Y() += (mnRowHeight - (USHORT)aStrSize.Height()) / 2;
+
+ //-----------
+ // horizontal
+ //-----------
+ if ( eJustification != SVX_HOR_JUSTIFY_STANDARD )
+ {
+ USHORT nHorPos = (USHORT)
+ ((cellRect.GetWidth()-aStrSize.Width())/2);
+
+ switch ( eJustification )
+ {
+ case SVX_HOR_JUSTIFY_LEFT:
+ aPos.X() += FRAME_OFFSET;
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ aPos.X() += nRightX;
+ break;
+ case SVX_HOR_JUSTIFY_BLOCK:
+ case SVX_HOR_JUSTIFY_REPEAT:
+ case SVX_HOR_JUSTIFY_CENTER:
+ aPos.X() += nHorPos;
+ break;
+ case SVX_HOR_JUSTIFY_STANDARD:
+ default:
+ // Standard wird hier nicht behandelt
+ break;
+ }
+ }
+ else
+ {
+ //---------------------
+ // Standardausrichtung:
+ //---------------------
+ if ( (nCol == 0) || (nRow == 0) )
+ {
+ // Text-Label links oder Summe linksbuendig
+ aPos.X() += FRAME_OFFSET;
+ }
+ else
+ {
+ // Zahlen/Datum rechtsbuendig
+ aPos.X() += nRightX;
+ }
+ }
+
+ //-------------------------------
+ aScriptedText.DrawText( aPos );
+ //-------------------------------
+ }
+ }
+}
+
+#undef FRAME_OFFSET
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DrawStrings()
+{
+ for( size_t nRow = 0; nRow < 5; ++nRow )
+ for( size_t nCol = 0; nCol < 5; ++nCol )
+ DrawString( nCol, nRow );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DrawBackground()
+{
+ if( pCurData )
+ {
+ for( size_t nRow = 0; nRow < 5; ++nRow )
+ {
+ for( size_t nCol = 0; nCol < 5; ++nCol )
+ {
+ const SvxBrushItem* pItem = static_cast< const SvxBrushItem* >(
+ pCurData->GetItem( GetFormatIndex( nCol, nRow ), ATTR_BACKGROUND ) );
+
+ aVD.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
+ aVD.SetLineColor();
+ aVD.SetFillColor( pItem->GetColor() );
+ aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
+ aVD.Pop();
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::PaintCells()
+{
+ if ( pCurData )
+ {
+ // 1) background
+ if ( pCurData->GetIncludeBackground() )
+ DrawBackground();
+
+ // 2) values
+ DrawStrings();
+
+ // 3) border
+ if ( pCurData->GetIncludeFrame() )
+ maArray.DrawArray( aVD );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::Init()
+{
+ SetBorderStyle( WINDOW_BORDER_MONO );
+ maArray.Initialize( 5, 5 );
+ maArray.SetUseDiagDoubleClipping( false );
+ CalcCellArray( FALSE );
+ CalcLineMap();
+
+ TypeId aType(TYPE(ScDocShell));
+ ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = dynamic_cast< ScTabViewShell* >( p );
+ ScViewData* pViewData = pViewSh->GetViewData();
+ SCTAB nCurrentTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+ mbRTL = pDoc->IsLayoutRTL( nCurrentTab );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::CalcCellArray( BOOL bFitWidthP )
+{
+ maArray.SetXOffset( 2 );
+ maArray.SetAllColWidths( bFitWidthP ? mnDataColWidth2 : mnDataColWidth1 );
+ maArray.SetColWidth( 0, mnLabelColWidth );
+ maArray.SetColWidth( 4, mnLabelColWidth );
+
+ maArray.SetYOffset( 2 );
+ maArray.SetAllRowHeights( mnRowHeight );
+
+ aPrvSize.Width() = maArray.GetWidth() + 4;
+ aPrvSize.Height() = maArray.GetHeight() + 4;
+}
+
+//------------------------------------------------------------------------
+
+inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const SvxBorderLine* pBorder )
+{
+ rStyle.Set( pBorder, 1.0 / TWIPS_PER_POINT, 5 );
+}
+
+void ScAutoFmtPreview::CalcLineMap()
+{
+ if ( pCurData )
+ {
+ for( size_t nRow = 0; nRow < 5; ++nRow )
+ {
+ for( size_t nCol = 0; nCol < 5; ++nCol )
+ {
+ svx::frame::Style aStyle;
+
+ const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
+ lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
+ maArray.SetCellStyleLeft( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, rItem.GetRight() );
+ maArray.SetCellStyleRight( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, rItem.GetTop() );
+ maArray.SetCellStyleTop( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
+ maArray.SetCellStyleBottom( nCol, nRow, aStyle );
+
+ lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
+ maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
+ lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
+ maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::NotifyChange( ScAutoFormatData* pNewData )
+{
+ if ( pNewData != pCurData )
+ {
+ pCurData = pNewData;
+ bFitWidth = pNewData->GetIncludeWidthHeight();
+ CalcCellArray( bFitWidth );
+ CalcLineMap();
+ }
+ else if ( bFitWidth != pNewData->GetIncludeWidthHeight() )
+ {
+ bFitWidth = !bFitWidth;
+ CalcCellArray( bFitWidth );
+ }
+
+ DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::DoPaint( const Rectangle& /* rRect */ )
+{
+ sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ if( GetSettings().GetStyleSettings().GetHighContrastMode() )
+ aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+
+ Size aWndSize( GetSizePixel() );
+ Font aFont( aVD.GetFont() );
+ Color aBackCol( GetSettings().GetStyleSettings().GetWindowColor() );
+ Point aTmpPoint;
+ Rectangle aRect( aTmpPoint, aWndSize );
+
+ aFont.SetTransparent( TRUE );
+ aVD.SetFont( aFont );
+ aVD.SetLineColor();
+ aVD.SetFillColor( aBackCol );
+ aVD.SetOutputSize( aWndSize );
+ aVD.DrawRect( aRect );
+
+ PaintCells();
+ SetLineColor();
+ SetFillColor( aBackCol );
+ DrawRect( aRect );
+
+ Point aPos( (aWndSize.Width() - aPrvSize.Width()) / 2, (aWndSize.Height() - aPrvSize.Height()) / 2 );
+ if (Application::GetSettings().GetLayoutRTL())
+ aPos.X() = -aPos.X();
+ DrawOutDev( aPos, aWndSize, Point(), aWndSize, aVD );
+
+ aVD.SetDrawMode( nOldDrawMode );
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFmtPreview::Paint( const Rectangle& rRect )
+{
+ DoPaint( rRect );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx
new file mode 100644
index 000000000000..6e5880a5cf06
--- /dev/null
+++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx
@@ -0,0 +1,861 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//-----------------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "conflictsdlg.hxx"
+#include "conflictsdlg.hrc"
+#include "scresid.hxx"
+#include "viewdata.hxx"
+#include "dbfunc.hxx"
+
+
+//=============================================================================
+// struct ScConflictsListEntry
+//=============================================================================
+
+bool ScConflictsListEntry::HasSharedAction( ULONG nSharedAction ) const
+{
+ ScChangeActionList::const_iterator aEnd = maSharedActions.end();
+ for ( ScChangeActionList::const_iterator aItr = maSharedActions.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( *aItr == nSharedAction )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool ScConflictsListEntry::HasOwnAction( ULONG nOwnAction ) const
+{
+ ScChangeActionList::const_iterator aEnd = maOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItr = maOwnActions.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( *aItr == nOwnAction )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+//=============================================================================
+// class ScConflictsListHelper
+//=============================================================================
+
+bool ScConflictsListHelper::HasOwnAction( ScConflictsList& rConflictsList, ULONG nOwnAction )
+{
+ ScConflictsList::const_iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::const_iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( aItr->HasOwnAction( nOwnAction ) )
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+ScConflictsListEntry* ScConflictsListHelper::GetSharedActionEntry( ScConflictsList& rConflictsList, ULONG nSharedAction )
+{
+ ScConflictsList::iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( aItr->HasSharedAction( nSharedAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+
+ return NULL;
+}
+
+ScConflictsListEntry* ScConflictsListHelper::GetOwnActionEntry( ScConflictsList& rConflictsList, ULONG nOwnAction )
+{
+ ScConflictsList::iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( aItr->HasOwnAction( nOwnAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+
+ return NULL;
+}
+
+void ScConflictsListHelper::Transform_Impl( ScChangeActionList& rActionList, ScChangeActionMergeMap* pMergeMap )
+{
+ if ( !pMergeMap )
+ {
+ return;
+ }
+
+ for ( ScChangeActionList::iterator aItr = rActionList.begin(); aItr != rActionList.end(); )
+ {
+ ScChangeActionMergeMap::iterator aItrMap = pMergeMap->find( *aItr );
+ if ( aItrMap != pMergeMap->end() )
+ {
+ *aItr = aItrMap->second;
+ aItr++;
+ }
+ else
+ {
+ aItr = rActionList.erase( aItr );
+ DBG_ERROR( "ScConflictsListHelper::Transform_Impl: erased action from conflicts list!" );
+ }
+ }
+}
+
+void ScConflictsListHelper::TransformConflictsList( ScConflictsList& rConflictsList,
+ ScChangeActionMergeMap* pSharedMap, ScChangeActionMergeMap* pOwnMap )
+{
+ ScConflictsList::iterator aEnd = rConflictsList.end();
+ for ( ScConflictsList::iterator aItr = rConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( pSharedMap )
+ {
+ ScConflictsListHelper::Transform_Impl( aItr->maSharedActions, pSharedMap );
+ }
+
+ if ( pOwnMap )
+ {
+ ScConflictsListHelper::Transform_Impl( aItr->maOwnActions, pOwnMap );
+ }
+ }
+}
+
+
+//=============================================================================
+// class ScConflictsFinder
+//=============================================================================
+
+ScConflictsFinder::ScConflictsFinder( ScChangeTrack* pTrack, ULONG nStartShared, ULONG nEndShared,
+ ULONG nStartOwn, ULONG nEndOwn, ScConflictsList& rConflictsList )
+ :mpTrack( pTrack )
+ ,mnStartShared( nStartShared )
+ ,mnEndShared( nEndShared )
+ ,mnStartOwn( nStartOwn )
+ ,mnEndOwn( nEndOwn )
+ ,mrConflictsList( rConflictsList )
+{
+}
+
+ScConflictsFinder::~ScConflictsFinder()
+{
+}
+
+bool ScConflictsFinder::DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 )
+{
+ if ( pAction1 && pAction2 && pAction1->GetBigRange().Intersects( pAction2->GetBigRange() ) )
+ {
+ return true;
+ }
+ return false;
+}
+
+ScConflictsListEntry* ScConflictsFinder::GetIntersectingEntry( const ScChangeAction* pAction ) const
+{
+ ScConflictsList::iterator aEnd = mrConflictsList.end();
+ for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEnd; ++aItr )
+ {
+ ScChangeActionList::const_iterator aEndShared = aItr->maSharedActions.end();
+ for ( ScChangeActionList::const_iterator aItrShared = aItr->maSharedActions.begin(); aItrShared != aEndShared; ++aItrShared )
+ {
+ if ( DoActionsIntersect( mpTrack->GetAction( *aItrShared ), pAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+
+ ScChangeActionList::const_iterator aEndOwn = aItr->maOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItrOwn = aItr->maOwnActions.begin(); aItrOwn != aEndOwn; ++aItrOwn )
+ {
+ if ( DoActionsIntersect( mpTrack->GetAction( *aItrOwn ), pAction ) )
+ {
+ return &(*aItr);
+ }
+ }
+ }
+
+ return NULL;
+}
+
+ScConflictsListEntry* ScConflictsFinder::GetEntry( ULONG nSharedAction, const ScChangeActionList& rOwnActions )
+{
+ // try to get a list entry which already contains the shared action
+ ScConflictsListEntry* pEntry = ScConflictsListHelper::GetSharedActionEntry( mrConflictsList, nSharedAction );
+ if ( pEntry )
+ {
+ return pEntry;
+ }
+
+ // try to get a list entry for which the shared action intersects with any
+ // other action of this entry
+ pEntry = GetIntersectingEntry( mpTrack->GetAction( nSharedAction ) );
+ if ( pEntry )
+ {
+ pEntry->maSharedActions.push_back( nSharedAction );
+ return pEntry;
+ }
+
+ // try to get a list entry for which any of the own actions intersects with
+ // any other action of this entry
+ ScChangeActionList::const_iterator aEnd = rOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItr = rOwnActions.begin(); aItr != aEnd; ++aItr )
+ {
+ pEntry = GetIntersectingEntry( mpTrack->GetAction( *aItr ) );
+ if ( pEntry )
+ {
+ pEntry->maSharedActions.push_back( nSharedAction );
+ return pEntry;
+ }
+ }
+
+ // if no entry was found, create a new one
+ ScConflictsListEntry aEntry;
+ aEntry.meConflictAction = SC_CONFLICT_ACTION_NONE;
+ aEntry.maSharedActions.push_back( nSharedAction );
+ mrConflictsList.push_back( aEntry );
+ return &(mrConflictsList.back());
+}
+
+bool ScConflictsFinder::Find()
+{
+ if ( !mpTrack )
+ {
+ return false;
+ }
+
+ bool bReturn = false;
+ ScChangeAction* pSharedAction = mpTrack->GetAction( mnStartShared );
+ while ( pSharedAction && pSharedAction->GetActionNumber() <= mnEndShared )
+ {
+ ScChangeActionList aOwnActions;
+ ScChangeAction* pOwnAction = mpTrack->GetAction( mnStartOwn );
+ while ( pOwnAction && pOwnAction->GetActionNumber() <= mnEndOwn )
+ {
+ if ( DoActionsIntersect( pSharedAction, pOwnAction ) )
+ {
+ aOwnActions.push_back( pOwnAction->GetActionNumber() );
+ }
+ pOwnAction = pOwnAction->GetNext();
+ }
+
+ if ( aOwnActions.size() )
+ {
+ ScConflictsListEntry* pEntry = GetEntry( pSharedAction->GetActionNumber(), aOwnActions );;
+ ScChangeActionList::iterator aEnd = aOwnActions.end();
+ for ( ScChangeActionList::iterator aItr = aOwnActions.begin(); aItr != aEnd; ++aItr )
+ {
+ if ( pEntry && !ScConflictsListHelper::HasOwnAction( mrConflictsList, *aItr ) )
+ {
+ pEntry->maOwnActions.push_back( *aItr );
+ }
+ }
+ bReturn = true;
+ }
+
+ pSharedAction = pSharedAction->GetNext();
+ }
+
+ return bReturn;
+}
+
+//=============================================================================
+// class ScConflictsResolver
+//=============================================================================
+
+ScConflictsResolver::ScConflictsResolver( ScChangeTrack* pTrack, ScConflictsList& rConflictsList )
+ :mpTrack ( pTrack )
+ ,mrConflictsList ( rConflictsList )
+{
+ DBG_ASSERT( mpTrack, "ScConflictsResolver CTOR: mpTrack is null!" );
+}
+
+ScConflictsResolver::~ScConflictsResolver()
+{
+}
+
+void ScConflictsResolver::HandleAction( ScChangeAction* pAction, bool bIsSharedAction,
+ bool bHandleContentAction, bool bHandleNonContentAction )
+{
+ if ( !mpTrack || !pAction )
+ {
+ return;
+ }
+
+ if ( bIsSharedAction )
+ {
+ ScConflictsListEntry* pConflictEntry = ScConflictsListHelper::GetSharedActionEntry(
+ mrConflictsList, pAction->GetActionNumber() );
+ if ( pConflictEntry )
+ {
+ ScConflictAction eConflictAction = pConflictEntry->meConflictAction;
+ if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_MINE )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ }
+ else if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_OTHER )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ // do nothing
+ //mpTrack->SelectContent( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ // do nothing
+ //mpTrack->Accept( pAction );
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ ScConflictsListEntry* pConflictEntry = ScConflictsListHelper::GetOwnActionEntry(
+ mrConflictsList, pAction->GetActionNumber() );
+ if ( pConflictEntry )
+ {
+ ScConflictAction eConflictAction = pConflictEntry->meConflictAction;
+ if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_MINE )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ // do nothing
+ //mpTrack->SelectContent( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ // do nothing
+ //mpTrack->Accept( pAction );
+ }
+ }
+ }
+ else if ( eConflictAction == SC_CONFLICT_ACTION_KEEP_OTHER )
+ {
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ if ( bHandleContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ else
+ {
+ if ( bHandleNonContentAction )
+ {
+ mpTrack->Reject( pAction );
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//=============================================================================
+// class ScConflictsListBox
+//=============================================================================
+
+ScConflictsListBox::ScConflictsListBox( Window* pParent, const ResId& rResId )
+ :SvxRedlinTable( pParent, rResId )
+{
+}
+
+ScConflictsListBox::~ScConflictsListBox()
+{
+}
+
+//=============================================================================
+// class ScConflictsDlg
+//=============================================================================
+
+ScConflictsDlg::ScConflictsDlg( Window* pParent, ScViewData* pViewData, ScDocument* pSharedDoc, ScConflictsList& rConflictsList )
+ :ModalDialog( pParent, ScResId( RID_SCDLG_CONFLICTS ) )
+ ,maFtConflicts ( this, ScResId( FT_CONFLICTS ) )
+ ,maLbConflicts ( this, ScResId( LB_CONFLICTS ) )
+ ,maBtnKeepMine ( this, ScResId( BTN_KEEPMINE ) )
+ ,maBtnKeepOther ( this, ScResId( BTN_KEEPOTHER ) )
+ ,maFlConflicts ( this, ScResId( FL_CONFLICTS ) )
+ ,maBtnKeepAllMine ( this, ScResId( BTN_KEEPALLMINE ) )
+ ,maBtnKeepAllOthers ( this, ScResId( BTN_KEEPALLOTHERS ) )
+ ,maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+ ,maBtnHelp ( this, ScResId( BTN_HELP ) )
+ ,maStrTitleConflict ( ScResId( STR_TITLE_CONFLICT ) )
+ ,maStrTitleAuthor ( ScResId( STR_TITLE_AUTHOR ) )
+ ,maStrTitleDate ( ScResId( STR_TITLE_DATE ) )
+ ,maStrUnknownUser ( ScResId( STR_UNKNOWN_USER ) )
+ ,mpViewData ( pViewData )
+ ,mpOwnDoc ( NULL )
+ ,mpOwnTrack ( NULL )
+ ,mpSharedDoc ( pSharedDoc )
+ ,mpSharedTrack ( NULL )
+ ,mrConflictsList ( rConflictsList )
+ ,maDialogSize ( GetSizePixel() )
+ ,mbInSelectHdl ( false )
+ ,mbInDeselectHdl ( false )
+{
+ DBG_ASSERT( mpViewData, "ScConflictsDlg CTOR: mpViewData is null!" );
+ mpOwnDoc = ( mpViewData ? mpViewData->GetDocument() : NULL );
+ DBG_ASSERT( mpOwnDoc, "ScConflictsDlg CTOR: mpOwnDoc is null!" );
+ mpOwnTrack = ( mpOwnDoc ? mpOwnDoc->GetChangeTrack() : NULL );
+ DBG_ASSERT( mpOwnTrack, "ScConflictsDlg CTOR: mpOwnTrack is null!" );
+ DBG_ASSERT( mpSharedDoc, "ScConflictsDlg CTOR: mpSharedDoc is null!" );
+ mpSharedTrack = ( mpSharedDoc ? mpSharedDoc->GetChangeTrack() : NULL );
+ DBG_ASSERT( mpSharedTrack, "ScConflictsDlg CTOR: mpSharedTrack is null!" );
+
+ FreeResource();
+
+ SetMinOutputSizePixel( maDialogSize );
+
+ long nTabs[] = { 3, 10, 216, 266 };
+ maLbConflicts.SetTabs( nTabs );
+
+ String aTab( sal_Unicode( '\t' ) );
+ String aHeader( maStrTitleConflict );
+ aHeader += aTab;
+ aHeader += maStrTitleAuthor;
+ aHeader += aTab;
+ aHeader += maStrTitleDate;
+ maLbConflicts.InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
+
+ maLbConflicts.SetWindowBits( WB_HASLINES | WB_CLIPCHILDREN | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL );
+ maLbConflicts.SetSelectionMode( MULTIPLE_SELECTION );
+ maLbConflicts.SetHighlightRange();
+
+ maSelectionTimer.SetTimeout( 100 );
+ maSelectionTimer.SetTimeoutHdl( LINK( this, ScConflictsDlg, UpdateSelectionHdl ) );
+
+ maLbConflicts.SetSelectHdl( LINK( this, ScConflictsDlg, SelectHandle ) );
+ maLbConflicts.SetDeselectHdl( LINK( this, ScConflictsDlg, DeselectHandle ) );
+
+ maBtnKeepMine.SetClickHdl( LINK( this, ScConflictsDlg, KeepMineHandle ) );
+ maBtnKeepOther.SetClickHdl( LINK( this, ScConflictsDlg, KeepOtherHandle ) );
+ maBtnKeepAllMine.SetClickHdl( LINK( this, ScConflictsDlg, KeepAllMineHandle ) );
+ maBtnKeepAllOthers.SetClickHdl( LINK( this, ScConflictsDlg, KeepAllOthersHandle ) );
+
+ UpdateView();
+
+ SvLBoxEntry* pEntry = maLbConflicts.First();
+ if ( pEntry != NULL )
+ {
+ maLbConflicts.Select( pEntry );
+ }
+}
+
+ScConflictsDlg::~ScConflictsDlg()
+{
+}
+
+String ScConflictsDlg::GetConflictString( const ScConflictsListEntry& rConflictEntry )
+{
+ String aString;
+ if ( mpOwnTrack )
+ {
+ const ScChangeAction* pAction = mpOwnTrack->GetAction( rConflictEntry.maOwnActions[ 0 ] );
+ if ( pAction && mpOwnDoc )
+ {
+ SCTAB nTab = pAction->GetBigRange().MakeRange().aStart.Tab();
+ mpOwnDoc->GetName( nTab, aString );
+ }
+ }
+ return aString;
+}
+
+String ScConflictsDlg::GetActionString( const ScChangeAction* pAction, ScDocument* pDoc )
+{
+ String aString;
+
+ DBG_ASSERT( pAction, "ScConflictsDlg::GetActionString(): pAction is null!" );
+ DBG_ASSERT( pDoc, "ScConflictsDlg::GetActionString(): pDoc is null!" );
+ if ( pAction && pDoc )
+ {
+ String aDesc;
+ pAction->GetDescription( aDesc, pDoc, TRUE, false );
+ aString += aDesc;
+ aString += '\t';
+
+ String aUser = pAction->GetUser();
+ aUser.EraseLeadingAndTrailingChars();
+ if ( aUser.Len() == 0 )
+ {
+ aUser = maStrUnknownUser;
+ }
+ aString += aUser;
+ aString += '\t';
+
+ DateTime aDateTime = pAction->GetDateTime();
+ aString += ScGlobal::pLocaleData->getDate( aDateTime );
+ aString += ' ';
+ aString += ScGlobal::pLocaleData->getTime( aDateTime, FALSE );
+ aString += '\t';
+ }
+
+ return aString;
+}
+
+void ScConflictsDlg::HandleListBoxSelection( bool bSelectHandle )
+{
+ SvLBoxEntry* pSelEntry = maLbConflicts.GetCurEntry();
+ if ( !pSelEntry )
+ {
+ pSelEntry = maLbConflicts.FirstSelected();
+ }
+ if ( !pSelEntry )
+ {
+ return;
+ }
+
+ SvLBoxEntry* pRootEntry = maLbConflicts.GetRootLevelParent( pSelEntry );
+ if ( pRootEntry )
+ {
+ if ( bSelectHandle )
+ {
+ maLbConflicts.SelectAll( FALSE );
+ }
+ if ( !maLbConflicts.IsSelected( pRootEntry ) )
+ {
+ maLbConflicts.Select( pRootEntry );
+ }
+ SvLBoxEntry* pEntry = maLbConflicts.FirstChild( pRootEntry );
+ while ( pEntry )
+ {
+ if ( !maLbConflicts.IsSelected( pEntry ) )
+ {
+ maLbConflicts.Select( pEntry );
+ }
+ pEntry = maLbConflicts.NextSibling( pEntry );
+ }
+ }
+}
+
+IMPL_LINK( ScConflictsDlg, SelectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if ( mbInSelectHdl || mbInDeselectHdl )
+ {
+ return 0;
+ }
+
+ mbInSelectHdl = true;
+ HandleListBoxSelection( true );
+ maSelectionTimer.Start();
+ mbInSelectHdl = false;
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, DeselectHandle, SvxRedlinTable*, EMPTYARG )
+{
+ if ( mbInDeselectHdl || mbInSelectHdl )
+ {
+ return 0;
+ }
+
+ mbInDeselectHdl = true;
+ HandleListBoxSelection( false );
+ mbInDeselectHdl = false;
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, UpdateSelectionHdl, Timer*, EMPTYARG )
+{
+ if ( !mpViewData || !mpOwnDoc )
+ {
+ return 0;
+ }
+
+ ScTabView* pTabView = mpViewData->GetView();
+ pTabView->DoneBlockMode();
+ BOOL bContMark = FALSE;
+ SvLBoxEntry* pEntry = maLbConflicts.FirstSelected();
+ while ( pEntry )
+ {
+ if ( pEntry != maLbConflicts.GetRootLevelParent( pEntry ) )
+ {
+ RedlinData* pUserData = static_cast< RedlinData* >( pEntry->GetUserData() );
+ if ( pUserData )
+ {
+ ScChangeAction* pAction = static_cast< ScChangeAction* >( pUserData->pData );
+ if ( pAction && ( pAction->GetType() != SC_CAT_DELETE_TABS ) &&
+ ( pAction->IsClickable() || pAction->IsVisible() ) )
+ {
+ const ScBigRange& rBigRange = ( static_cast< const ScChangeAction* >( pAction ) )->GetBigRange();
+ if ( rBigRange.IsValid( mpOwnDoc ) )
+ {
+ BOOL bSetCursor = !maLbConflicts.NextSelected( pEntry );
+ pTabView->MarkRange( rBigRange.MakeRange(), bSetCursor, bContMark );
+ bContMark = TRUE;
+ }
+ }
+ }
+ }
+ pEntry = maLbConflicts.NextSelected( pEntry );
+ }
+
+ return 0;
+}
+
+void ScConflictsDlg::SetConflictAction( SvLBoxEntry* pRootEntry, ScConflictAction eConflictAction )
+{
+ RedlinData* pUserData = static_cast< RedlinData* >( pRootEntry ? pRootEntry->GetUserData() : NULL );
+ ScConflictsListEntry* pConflictEntry = static_cast< ScConflictsListEntry* >( pUserData ? pUserData->pData : NULL );
+ if ( pConflictEntry )
+ {
+ pConflictEntry->meConflictAction = eConflictAction;
+ }
+}
+
+void ScConflictsDlg::KeepHandler( bool bMine )
+{
+ SvLBoxEntry* pEntry = maLbConflicts.FirstSelected();
+ SvLBoxEntry* pRootEntry = ( pEntry ? maLbConflicts.GetRootLevelParent( pEntry ) : NULL );
+ if ( !pRootEntry )
+ {
+ return;
+ }
+ SetPointer( Pointer( POINTER_WAIT ) );
+ ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER );
+ SetConflictAction( pRootEntry, eConflictAction );
+ maLbConflicts.RemoveEntry( pRootEntry );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ if ( maLbConflicts.GetEntryCount() == 0 )
+ {
+ EndDialog( RET_OK );
+ }
+}
+
+void ScConflictsDlg::KeepAllHandler( bool bMine )
+{
+ SvLBoxEntry* pEntry = maLbConflicts.First();
+ SvLBoxEntry* pRootEntry = ( pEntry ? maLbConflicts.GetRootLevelParent( pEntry ) : NULL );
+ if ( !pRootEntry )
+ {
+ return;
+ }
+ SetPointer( Pointer( POINTER_WAIT ) );
+ ScConflictAction eConflictAction = ( bMine ? SC_CONFLICT_ACTION_KEEP_MINE : SC_CONFLICT_ACTION_KEEP_OTHER );
+ while ( pRootEntry )
+ {
+ SetConflictAction( pRootEntry, eConflictAction );
+ pRootEntry = maLbConflicts.NextSibling( pRootEntry );
+ }
+ maLbConflicts.SetUpdateMode( FALSE );
+ maLbConflicts.Clear();
+ maLbConflicts.SetUpdateMode( TRUE );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ EndDialog( RET_OK );
+}
+
+IMPL_LINK( ScConflictsDlg, KeepMineHandle, void*, EMPTYARG )
+{
+ KeepHandler( true );
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, KeepOtherHandle, void*, EMPTYARG )
+{
+ KeepHandler( false );
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, KeepAllMineHandle, void*, EMPTYARG )
+{
+ KeepAllHandler( true );
+
+ return 0;
+}
+
+IMPL_LINK( ScConflictsDlg, KeepAllOthersHandle, void*, EMPTYARG )
+{
+ KeepAllHandler( false );
+
+ return 0;
+}
+
+void lcl_MoveControlX( Window& rWindow, long nDelta )
+{
+ Point aPos( rWindow.GetPosPixel() );
+ aPos.X() += nDelta;
+ rWindow.SetPosPixel( aPos );
+}
+
+void lcl_MoveControlY( Window& rWindow, long nDelta )
+{
+ Point aPos( rWindow.GetPosPixel() );
+ aPos.Y() += nDelta;
+ rWindow.SetPosPixel( aPos );
+}
+
+void lcl_ChangeControlWidth( Window& rWindow, long nDelta )
+{
+ Size aSize( rWindow.GetSizePixel() );
+ aSize.Width() += nDelta;
+ rWindow.SetSizePixel( aSize );
+}
+
+void lcl_ChangeControlHeight( Window& rWindow, long nDelta )
+{
+ Size aSize( rWindow.GetSizePixel() );
+ aSize.Height() += nDelta;
+ rWindow.SetSizePixel( aSize );
+}
+
+void ScConflictsDlg::Resize()
+{
+ Size aSize( GetSizePixel() );
+ long nDeltaWidth = aSize.Width() - maDialogSize.Width();
+ long nDeltaHeight = aSize.Height() - maDialogSize.Height();
+ maDialogSize = aSize;
+
+ lcl_ChangeControlWidth( maFtConflicts, nDeltaWidth );
+
+ lcl_ChangeControlWidth( maLbConflicts, nDeltaWidth );
+ lcl_ChangeControlHeight( maLbConflicts, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnKeepMine, nDeltaWidth / 2 );
+ lcl_MoveControlY( maBtnKeepMine, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnKeepOther, nDeltaWidth / 2 );
+ lcl_MoveControlY( maBtnKeepOther, nDeltaHeight );
+
+ lcl_MoveControlY( maFlConflicts, nDeltaHeight );
+ lcl_ChangeControlWidth( maFlConflicts, nDeltaWidth );
+
+ lcl_MoveControlX( maBtnKeepAllMine, nDeltaWidth );
+ lcl_MoveControlY( maBtnKeepAllMine, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnKeepAllOthers, nDeltaWidth );
+ lcl_MoveControlY( maBtnKeepAllOthers, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnCancel, nDeltaWidth );
+ lcl_MoveControlY( maBtnCancel, nDeltaHeight );
+
+ lcl_MoveControlX( maBtnHelp, nDeltaWidth );
+ lcl_MoveControlY( maBtnHelp, nDeltaHeight );
+}
+
+void ScConflictsDlg::UpdateView()
+{
+ ScConflictsList::iterator aEndItr = mrConflictsList.end();
+ for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEndItr; ++aItr )
+ {
+ ScConflictsListEntry* pConflictEntry = &(*aItr);
+ if ( pConflictEntry && pConflictEntry->meConflictAction == SC_CONFLICT_ACTION_NONE )
+ {
+ RedlinData* pRootUserData = new RedlinData();
+ pRootUserData->pData = static_cast< void* >( pConflictEntry );
+ SvLBoxEntry* pRootEntry = maLbConflicts.InsertEntry( GetConflictString( *aItr ), pRootUserData );
+
+ ScChangeActionList::const_iterator aEndShared = aItr->maSharedActions.end();
+ for ( ScChangeActionList::const_iterator aItrShared = aItr->maSharedActions.begin(); aItrShared != aEndShared; ++aItrShared )
+ {
+ ScChangeAction* pAction = mpSharedTrack->GetAction( *aItrShared );
+ if ( pAction )
+ {
+ // only display shared top content entries
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ ScChangeActionContent* pNextContent = ( dynamic_cast< ScChangeActionContent* >( pAction ) )->GetNextContent();
+ if ( pNextContent && aItr->HasSharedAction( pNextContent->GetActionNumber() ) )
+ {
+ continue;
+ }
+ }
+
+ String aString( GetActionString( pAction, mpSharedDoc ) );
+ maLbConflicts.InsertEntry( aString, static_cast< RedlinData* >( NULL ), pRootEntry );
+ }
+ }
+
+ ScChangeActionList::const_iterator aEndOwn = aItr->maOwnActions.end();
+ for ( ScChangeActionList::const_iterator aItrOwn = aItr->maOwnActions.begin(); aItrOwn != aEndOwn; ++aItrOwn )
+ {
+ ScChangeAction* pAction = mpOwnTrack->GetAction( *aItrOwn );
+ if ( pAction )
+ {
+ // only display own top content entries
+ if ( pAction->GetType() == SC_CAT_CONTENT )
+ {
+ ScChangeActionContent* pNextContent = ( dynamic_cast< ScChangeActionContent* >( pAction ) )->GetNextContent();
+ if ( pNextContent && aItr->HasOwnAction( pNextContent->GetActionNumber() ) )
+ {
+ continue;
+ }
+ }
+
+ String aString( GetActionString( pAction, mpOwnDoc ) );
+ RedlinData* pUserData = new RedlinData();
+ pUserData->pData = static_cast< void* >( pAction );
+ maLbConflicts.InsertEntry( aString, pUserData, pRootEntry );
+ }
+ }
+
+ maLbConflicts.Expand( pRootEntry );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.src b/sc/source/ui/miscdlgs/conflictsdlg.src
new file mode 100644
index 000000000000..dad8abb48780
--- /dev/null
+++ b/sc/source/ui/miscdlgs/conflictsdlg.src
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "conflictsdlg.hrc"
+
+ModalDialog RID_SCDLG_CONFLICTS
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SCDLG_CONFLICTS ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 338 , 192 ) ;
+ Text [ en-US ] = "Resolve Conflicts" ;
+ Moveable = TRUE ;
+ Sizeable = TRUE ;
+ Closeable = TRUE ;
+ FixedText FT_CONFLICTS
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 326 , 26 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "There are conflicting changes in this shared spreadsheet. Conflicts must be resolved before saving the spreadsheet. Keep either own or other changes." ;
+ };
+ Control LB_CONFLICTS
+ {
+ Pos = MAP_APPFONT ( 6 , 34 ) ;
+ Size = MAP_APPFONT ( 326 , 104 ) ;
+ Border = TRUE ;
+ };
+ PushButton BTN_KEEPMINE
+ {
+ Pos = MAP_APPFONT ( 72 , 145 ) ;
+ Size = MAP_APPFONT ( 76 , 14 ) ;
+ Text [ en-US ] = "Keep ~Mine" ;
+ };
+ PushButton BTN_KEEPOTHER
+ {
+ Pos = MAP_APPFONT ( 190 , 145 ) ;
+ Size = MAP_APPFONT ( 76 , 14 ) ;
+ Text [ en-US ] = "Keep ~Other" ;
+ };
+ FixedLine FL_CONFLICTS
+ {
+ Pos = MAP_APPFONT ( 1 , 162 ) ;
+ Size = MAP_APPFONT ( 338 , 8 ) ;
+ };
+ PushButton BTN_KEEPALLMINE
+ {
+ Pos = MAP_APPFONT ( 6 , 172 ) ;
+ Size = MAP_APPFONT ( 104 , 14 ) ;
+ Text [ en-US ] = "~Keep All Mine" ;
+ };
+ PushButton BTN_KEEPALLOTHERS
+ {
+ Pos = MAP_APPFONT ( 116 , 172 ) ;
+ Size = MAP_APPFONT ( 104 , 14 ) ;
+ Text [ en-US ] = "Keep ~All Others" ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 226 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 282 , 172 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_TITLE_CONFLICT
+ {
+ Text [ en-US ] = "Conflict" ;
+ };
+ String STR_TITLE_AUTHOR
+ {
+ Text [ en-US ] = "Author" ;
+ };
+ String STR_TITLE_DATE
+ {
+ Text [ en-US ] = "Date" ;
+ };
+ String STR_UNKNOWN_USER
+ {
+ Text [ en-US ] = "Unknown User" ;
+ };
+};
+
diff --git a/sc/source/ui/miscdlgs/crdlg.cxx b/sc/source/ui/miscdlgs/crdlg.cxx
new file mode 100644
index 000000000000..f9413dda2068
--- /dev/null
+++ b/sc/source/ui/miscdlgs/crdlg.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "crdlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScColOrRowDlg::ScColOrRowDlg( Window* pParent,
+ const String& rStrTitle,
+ const String& rStrLabel,
+ BOOL bColDefault )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_COLORROW ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnRows ( this, ScResId( BTN_GROUP_ROWS ) ),
+ aBtnCols ( this, ScResId( BTN_GROUP_COLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ SetText( rStrTitle );
+ aFlFrame.SetText( rStrLabel );
+
+ if ( bColDefault )
+ aBtnCols.Check();
+ else
+ aBtnRows.Check();
+
+ aBtnOk.SetClickHdl( LINK( this, ScColOrRowDlg, OkHdl ) );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScColOrRowDlg::~ScColOrRowDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScColOrRowDlg, OkHdl, OKButton *, EMPTYARG )
+{
+ EndDialog( aBtnCols.IsChecked() ? SCRET_COLS : SCRET_ROWS );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScColOrRowDlg, OkHdl, OKButton *, EMPTYARG )
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
new file mode 100644
index 000000000000..0ba1bf1cbe5c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -0,0 +1,1175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "crnrdlg.hrc"
+#include "docsh.hxx"
+
+#define _CRNRDLG_CXX
+#include "crnrdlg.hxx"
+#undef _CRNRDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+//============================================================================
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+const ULONG nEntryDataCol = 0;
+const ULONG nEntryDataRow = 1;
+const ULONG nEntryDataDelim = 2;
+
+
+//============================================================================
+// class ScColRowNameRangesDlg
+
+
+/*************************************************************************
+#* Member: ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Konstruktor der Klasse ScColRowNameRangesDlg.
+#* Initialisieren der Klassen- Mitglieder,
+#* Uebernahme der Range- Angaben und Aufruf
+#* der eigentlichen Initialisierungsroutine
+#*
+#* Input: Sfx- Verknuepfungen
+#* Parent- Window
+#* SCViewData
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScColRowNameRangesDlg::ScColRowNameRangesDlg( SfxBindings* pB,
+ SfxChildWindow* pCW,
+ Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_COLROWNAMERANGES ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aLbRange ( this, ScResId( LB_RANGE ) ),
+
+ aEdAssign ( this, this, ScResId( ED_AREA ) ),
+ aRbAssign ( this, ScResId( RB_AREA ), &aEdAssign, this ),
+ aBtnColHead ( this, ScResId( BTN_COLHEAD ) ),
+ aBtnRowHead ( this, ScResId( BTN_ROWHEAD ) ),
+ aFtAssign2 ( this, ScResId( FT_DATA_LABEL ) ),
+ aEdAssign2 ( this, this, ScResId( ED_DATA ) ),
+ aRbAssign2 ( this, ScResId( RB_DATA ), &aEdAssign2, this ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE )
+{
+ xColNameRanges = pDoc->GetColNameRanges()->Clone();
+ xRowNameRanges = pDoc->GetRowNameRanges()->Clone();
+ Init();
+ FreeResource();
+}
+
+
+/*************************************************************************
+#* Member: ~ScColRowNameRangesDlg Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Destruktor der Klasse
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScColRowNameRangesDlg::~ScColRowNameRangesDlg()
+{
+}
+
+
+/*************************************************************************
+#* Member: Init Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Initialisierungs- Routine:
+#* Umlenken der Event- Handler und einstellen der
+#* Startparameter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::Init()
+{
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCTAB nStartTab = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ SCTAB nEndTab = 0;
+
+ aBtnOk.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RemoveBtnHdl ) );
+ aLbRange.SetSelectHdl ( LINK( this, ScColRowNameRangesDlg, Range1SelectHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range1DataModifyHdl ) );
+ aBtnColHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, ColClickHdl ) );
+ aBtnRowHead.SetClickHdl ( LINK( this, ScColRowNameRangesDlg, RowClickHdl ) );
+ aEdAssign2.SetModifyHdl ( LINK( this, ScColRowNameRangesDlg, Range2DataModifyHdl ) );
+
+ Link aLink = LINK( this, ScColRowNameRangesDlg, GetFocusHdl );
+ aEdAssign.SetGetFocusHdl( aLink );
+ aRbAssign.SetGetFocusHdl( aLink );
+ aEdAssign2.SetGetFocusHdl( aLink );
+ aRbAssign2.SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScColRowNameRangesDlg, LoseFocusHdl );
+ aEdAssign.SetLoseFocusHdl( aLink );
+ aRbAssign.SetLoseFocusHdl( aLink );
+ aEdAssign2.SetLoseFocusHdl( aLink );
+ aRbAssign2.SetLoseFocusHdl( aLink );
+
+ pEdActive = &aEdAssign;
+
+ UpdateNames();
+
+ if ( pViewData && pDoc )
+ {
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+ SetColRowData( ScRange( ScAddress( nStartCol, nStartRow, nStartTab ),
+ ScAddress( nEndCol, nEndRow, nEndTab ) ) );
+ }
+ else
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aLbRange.SetBorderStyle( WINDOW_BORDER_MONO );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign.Enable();
+ aEdAssign.GrabFocus();
+ aRbAssign.Enable();
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable(); // Ref-Feld hat Focus
+
+ Range1SelectHdl( 0 );
+}
+
+
+/*************************************************************************
+#* Member: SetColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* auf default Werte setzen und beide Referenz-Edit-Felder
+#* fuellen.
+#*
+#* Input: Einstellbereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetColRowData( const ScRange& rLabelRange,BOOL bRef)
+{
+ theCurData = theCurArea = rLabelRange;
+ BOOL bValid = TRUE;
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( (static_cast<SCCOLROW>(nCol2 - nCol1) >= nRow2 - nRow1) || (nCol1 == 0 && nCol2 == MAXCOL) )
+ { // Spaltenkoepfe und Grenzfall gesamte Tabelle
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( nRow2 == MAXROW )
+ {
+ if ( nRow1 == 0 )
+ bValid = FALSE; // Grenzfall gesamte Tabelle
+ else
+ { // Head unten, Data oben
+ theCurData.aStart.SetRow( 0 );
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ }
+ }
+ else
+ { // Head oben, Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ theCurData.aEnd.SetRow( MAXROW );
+ }
+ }
+ else
+ { // Zeilenkoepfe
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( nCol2 == MAXCOL )
+ { // Head rechts, Data links
+ theCurData.aStart.SetCol( 0 );
+ theCurData.aEnd.SetCol( nCol2 - 1 );
+ }
+ else
+ { // Head links, Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ theCurData.aEnd.SetCol( MAXCOL );
+ }
+ }
+ if ( bValid )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign.SetRefString( aStr );
+ else
+ aEdAssign.SetText( aStr );
+
+ aEdAssign.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ theCurData = theCurArea = ScRange();
+
+ if(bRef)
+ {
+ aEdAssign.SetRefString( EMPTY_STRING );
+ aEdAssign2.SetRefString( EMPTY_STRING );
+ }
+ else
+ {
+ aEdAssign.SetText( EMPTY_STRING );
+ aEdAssign2.SetText( EMPTY_STRING );
+ }
+
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: AdjustColRowData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: zugehoerigen Datenbereich eines Beschriftungsbereiches
+#* anpassen und Data-Referenz-Edit-Feld fuellen.
+#*
+#* Input: Bereich fuer Labels
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::AdjustColRowData( const ScRange& rDataRange,BOOL bRef)
+{
+ theCurData = rDataRange;
+ if ( aBtnColHead.IsChecked() )
+ { // Datenbereich gleiche Spalten wie Koepfe
+ theCurData.aStart.SetCol( theCurArea.aStart.Col() );
+ theCurData.aEnd.SetCol( theCurArea.aEnd.Col() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCROW nRow1 = theCurArea.aStart.Row();
+ SCROW nRow2 = theCurArea.aEnd.Row();
+ if ( nRow1 > 0
+ && (theCurData.aEnd.Row() < nRow2 || nRow2 == MAXROW) )
+ { // Data oben
+ theCurData.aEnd.SetRow( nRow1 - 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aStart.SetRow( theCurData.aEnd.Row() );
+ }
+ else
+ { // Data unten
+ theCurData.aStart.SetRow( nRow2 + 1 );
+ if ( theCurData.aStart.Row() > theCurData.aEnd.Row() )
+ theCurData.aEnd.SetRow( theCurData.aStart.Row() );
+ }
+ }
+ }
+ else
+ { // Datenbereich gleiche Zeilen wie Koepfe
+ theCurData.aStart.SetRow( theCurArea.aStart.Row() );
+ theCurData.aEnd.SetRow( theCurArea.aEnd.Row() );
+ if ( theCurData.Intersects( theCurArea ) )
+ {
+ SCCOL nCol1 = theCurArea.aStart.Col();
+ SCCOL nCol2 = theCurArea.aEnd.Col();
+ if ( nCol1 > 0
+ && (theCurData.aEnd.Col() < nCol2 || nCol2 == MAXCOL) )
+ { // Data links
+ theCurData.aEnd.SetCol( nCol1 - 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aStart.SetCol( theCurData.aEnd.Col() );
+ }
+ else
+ { // Data rechts
+ theCurData.aStart.SetCol( nCol2 + 1 );
+ if ( theCurData.aStart.Col() > theCurData.aEnd.Col() )
+ theCurData.aEnd.SetCol( theCurData.aStart.Col() );
+ }
+ }
+ }
+ String aStr;
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+
+ if(bRef)
+ aEdAssign2.SetRefString( aStr );
+ else
+ aEdAssign2.SetText( aStr );
+
+ aEdAssign2.SetSelection( Selection( SELECTION_MAX, SELECTION_MAX ) );
+}
+
+
+/*************************************************************************
+#* Member: SetReference Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Uebergabe eines mit der Maus selektierten Tabellen-
+#* bereiches, der dann als neue Selektion im Referenz-
+#* Fenster angezeigt wird.
+#*
+#* Input: Bereich fuer Labels
+#* Dokumentklasse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pEdActive );
+
+ String aRefStr;
+ if ( pEdActive == &aEdAssign )
+ SetColRowData( rRef, TRUE );
+ else
+ AdjustColRowData( rRef, TRUE );
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+}
+
+
+/*************************************************************************
+#* Member: Close Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScColRowNameRangesDlg::Close()
+{
+ return DoClose( ScColRowNameRangesDlgWrapper::GetChildWindowId() );
+}
+
+
+/*************************************************************************
+#* Member: SetActive Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktivieren des Fensters
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ if( pEdActive == &aEdAssign )
+ Range1DataModifyHdl( 0 );
+ else if( pEdActive == &aEdAssign2 )
+ Range2DataModifyHdl( 0 );
+
+ RefInputDone();
+}
+
+
+/*************************************************************************
+#* Member: UpdateNames Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Namen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateNames()
+{
+ aLbRange.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ aLbRange.Clear();
+ aRangeMap.clear();
+ aEdAssign.SetText( EMPTY_STRING );
+
+ ULONG nCount, j;
+ USHORT nPos; //@008 Hilfsvariable q eingefuegt
+
+ SCCOL nCol1; //@008 04.09.97
+ SCROW nRow1; //Erweiterung fuer Bereichsnamen
+ SCTAB nTab1;
+ SCCOL nCol2;
+ SCROW nRow2;
+ SCTAB nTab2;
+ String rString;
+ String strShow;
+ const ScAddress::Details aDetails(pDoc->GetAddressConvention());
+
+ String aString;
+ String strDelim = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " --- " ));
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_COLUMN );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xColNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xColNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Hole Bereichsparameter aus Dok
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCCOL q=nCol1+3;
+ if(q>nCol2) q=nCol2;
+ //@008 Baue String zusammen
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow +=rString;
+ for(SCCOL i=nCol1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(i, nRow1, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nCol2) // Zu lang? Ergaenzen um ",..."
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ //@008 String einfuegen in Listbox
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataCol );
+ }
+ delete [] ppSortArray;
+ }
+ aString = strDelim;
+ aString += ScGlobal::GetRscString( STR_ROW );
+ aString += strDelim;
+ nPos = aLbRange.InsertEntry( aString );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataDelim );
+ if ( (nCount = xRowNameRanges->Count()) > 0 )
+ {
+ ScRangePair** ppSortArray = xRowNameRanges->CreateNameSortedArray(
+ nCount, pDoc );
+ for ( j=0; j < nCount; j++ )
+ {
+ const ScRange aRange(ppSortArray[j]->GetRange(0));
+ aRange.Format( aString, SCR_ABS_3D, pDoc, aDetails );
+
+ //@008 Ab hier baue String fuer Zeilen
+ ppSortArray[j]->GetRange(0).GetVars( nCol1, nRow1, nTab1,
+ nCol2, nRow2, nTab2 );
+ SCROW q=nRow1+3;
+ if(q>nRow2) q=nRow2;
+ strShow.AssignAscii(RTL_CONSTASCII_STRINGPARAM(" ["));
+ if(pDoc!=NULL)
+ {
+ pDoc->GetString(nCol1, nRow1, nTab1,rString);
+ strShow += rString;
+ for(SCROW i=nRow1+1;i<=q;i++)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ pDoc->GetString(nCol1, i, nTab1,rString);
+ strShow += rString;
+ }
+ }
+ if(q<nRow2)
+ {
+ strShow.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", ..."));
+ }
+ strShow += ']';
+
+ String aInsStr = aString;
+ aInsStr += strShow;
+ nPos = aLbRange.InsertEntry( aInsStr );
+ aRangeMap.insert( NameRangeMap::value_type(aInsStr, aRange) );
+ aLbRange.SetEntryData( nPos, (void*)nEntryDataRow );
+ }
+ delete [] ppSortArray;
+ }
+ //-----------------------------------------------------------
+ aLbRange.SetUpdateMode( TRUE );
+ aLbRange.Invalidate();
+}
+
+
+/*************************************************************************
+#* Member: UpdateRangeData Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Aktualisieren der Bereichsdaten
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScColRowNameRangesDlg::UpdateRangeData( const ScRange& rRange, BOOL bColName )
+{
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+
+ if ( bFound )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ String aStr;
+ theCurArea = rRange;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign.SetText( aStr );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ aBtnColHead.Check( bColName );
+ aBtnRowHead.Check( !bColName );
+ theCurData = pPair->GetRange(1);
+ theCurData.Format( aStr, SCR_ABS_3D, pDoc, eConv );
+ aEdAssign2.SetText( aStr );
+ }
+ else
+ {
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ }
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+}
+
+
+/*************************************************************************
+#* Member: IsRefInputMode Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Abfragefunktion fuer Referenz- Input- Mode.
+#*
+#* Input: Bereichs-String
+#* Flag fuer Spalten
+#*
+#* Output: true, wenn Referenz- Input- Mode
+#*
+#************************************************************************/
+
+BOOL ScColRowNameRangesDlg::IsRefInputMode() const
+{
+ return (pEdActive != NULL);
+}
+
+//------------------------------------------------------------------------
+// Handler:
+// ========
+
+/*************************************************************************
+#* Handler: OkBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn der OK- Button gedrueckt wurde.
+#* Hinzufuegen- Button ausloesen, und die neu einge-
+#* stellten Bereiche ans Dokument uebergeben.
+#* Fensterschliessen- Anweisung ausloesen.
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ AddBtnHdl( 0 );
+
+ // die RangeLists den Refs am Doc zuweisen
+ pDoc->GetColNameRangesRef() = xColNameRanges;
+ pDoc->GetRowNameRangesRef() = xRowNameRanges;
+ // geaenderte Datenbereiche muessen sich auswirken
+ pDoc->CompileColRowNameFormula();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+
+ Close();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: CancelBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Fensterschliessen- Anweisung ausloesen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK_INLINE_START( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScColRowNameRangesDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+/*************************************************************************
+#* Handler: AddBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Hinzufuegen- Buttons, werden
+#* die Bereichsangaben eingestellt und in der
+#* Listbox dargestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ String aNewData( aEdAssign2.GetText() );
+
+ if ( aNewArea.Len() > 0 && aNewData.Len() > 0 )
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ ScRange aRange1, aRange2;
+ BOOL bOk1;
+ if ( (bOk1 = ((aRange1.ParseAny( aNewArea, pDoc, eConv ) & SCA_VALID) == SCA_VALID)) != FALSE
+ && ((aRange2.ParseAny( aNewData, pDoc, eConv ) & SCA_VALID) == SCA_VALID) )
+ {
+ theCurArea = aRange1;
+ AdjustColRowData( aRange2 );
+ ScRangePair* pPair;
+ if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xColNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != NULL )
+ {
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+ }
+ if ( aBtnColHead.IsChecked() )
+ xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+ else
+ xRowNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
+
+ UpdateNames();
+
+ aEdAssign.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ theCurArea = ScRange();
+ theCurData = theCurArea;
+ Range1SelectHdl( 0 );
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDTABNAME) );
+ if ( !bOk1 )
+ aEdAssign.GrabFocus();
+ else
+ aEdAssign2.GrabFocus();
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RemoveBtnHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Nach betaetigen des Loeschen- Buttons, wird
+#* die markierte Bereichsangabe geloescht.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ String aRangeStr = aLbRange.GetSelectEntry();
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if (itr == aRangeMap.end())
+ return 0;
+ const ScRange& rRange = itr->second;
+
+ ScRangePair* pPair = NULL;
+ BOOL bFound = FALSE;
+ if ( bColName && (pPair = xColNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ else if ( !bColName && (pPair = xRowNameRanges->Find( rRange )) != NULL )
+ bFound = TRUE;
+ if ( bFound )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aRangeStr;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES == QUERYBOX(aMsg) )
+ {
+ if ( bColName )
+ xColNameRanges->Remove( pPair );
+ else
+ xRowNameRanges->Remove( pPair );
+ delete pPair;
+
+ UpdateNames();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ if ( nSelectPos >= nCnt )
+ {
+ if ( nCnt )
+ nSelectPos = nCnt - 1;
+ else
+ nSelectPos = 0;
+ }
+ aLbRange.SelectEntryPos( nSelectPos );
+ if ( nSelectPos &&
+ (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ aLbRange.SelectEntryPos( --nSelectPos ); // ---Zeile---
+
+ aLbRange.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aEdAssign.SetText( EMPTY_STRING );
+ theCurArea = theCurData = ScRange();
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ aEdAssign2.SetText( EMPTY_STRING );
+ Range1SelectHdl( 0 );
+ }
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1SelectHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wenn Zeile in Listbox ausgewaehlt wird,
+#* werden die Eingabefelder entsprechend
+#* eingestellt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1SelectHdl, void *, EMPTYARG )
+{
+ USHORT nSelectPos = aLbRange.GetSelectEntryPos();
+ USHORT nCnt = aLbRange.GetEntryCount();
+ USHORT nMoves = 0;
+ while ( nSelectPos < nCnt
+ && (ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataDelim )
+ { // skip Delimiter
+ ++nMoves;
+ aLbRange.SelectEntryPos( ++nSelectPos );
+ }
+ String aRangeStr = aLbRange.GetSelectEntry();
+ if ( nMoves )
+ {
+ if ( nSelectPos > 1 && nSelectPos >= nCnt )
+ { // am Ende nicht auf dem " --- Zeile --- " Delimiter stehenbleiben
+ // wenn davor Eintraege existieren
+ nSelectPos = nCnt - 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ else if ( nSelectPos > 2 && nSelectPos < nCnt && aRangeStr.Len()
+ && aRangeStr == aEdAssign.GetText() )
+ { // nach oben wandern statt nach unten auf die vorherige Position
+ nSelectPos -= 2;
+ aLbRange.SelectEntryPos( nSelectPos );
+ aRangeStr = aLbRange.GetSelectEntry();
+ }
+ }
+ NameRangeMap::const_iterator itr = aRangeMap.find(aRangeStr);
+ if ( itr != aRangeMap.end() )
+ {
+ BOOL bColName =
+ ((ULONG)aLbRange.GetEntryData( nSelectPos ) == nEntryDataCol);
+ UpdateRangeData( itr->second, bColName );
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ if ( aEdAssign.GetText().Len() > 0 )
+ {
+ if ( aEdAssign2.GetText().Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ aEdAssign.GrabFocus();
+ }
+
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range1DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Label-
+#* Bereich geaendert wurde.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range1DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewArea( aEdAssign.GetText() );
+ BOOL bValid = FALSE;
+ if ( aNewArea.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewArea, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ SetColRowData( aRange );
+ bValid = TRUE;
+ }
+ }
+ if ( bValid )
+ {
+ aBtnAdd.Enable();
+ aBtnColHead.Enable();
+ aBtnRowHead.Enable();
+ aEdAssign2.Enable();
+ aRbAssign2.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnColHead.Disable();
+ aBtnRowHead.Disable();
+ aEdAssign2.Disable();
+ aRbAssign2.Disable();
+ }
+ aBtnRemove.Disable();
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: Range2DataModifyHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Wird ausgeloest, wenn in der Tabelle, der Daten-
+#* Bereich geaendert wurde
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, Range2DataModifyHdl, void *, EMPTYARG )
+{
+ String aNewData( aEdAssign2.GetText() );
+ if ( aNewData.Len() > 0 )
+ {
+ ScRange aRange;
+ if ( (aRange.ParseAny( aNewData, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID) == SCA_VALID )
+ {
+ AdjustColRowData( aRange );
+ aBtnAdd.Enable();
+ }
+ else
+ aBtnAdd.Disable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: ColClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Spalten wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, ColClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnColHead.GetSavedValue() )
+ {
+ aBtnColHead.Check( TRUE );
+ aBtnRowHead.Check( FALSE );
+ if ( theCurArea.aStart.Row() == 0 && theCurArea.aEnd.Row() == MAXROW )
+ {
+ theCurArea.aEnd.SetRow( MAXROW - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetRow( Min( (long)(theCurArea.aEnd.Row() + 1), (long)MAXROW ) );
+ aRange.aEnd.SetRow( MAXROW );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+/*************************************************************************
+#* Handler: RowClickHdl Datum:04.09.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScColRowNameRangesDlg
+#*
+#* Funktion: Radiobutton fuer Zeilen wurde betaetigt,
+#* die entsprechenden Einstellungen werden
+#* vorgenommen
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScColRowNameRangesDlg, RowClickHdl, void *, EMPTYARG )
+{
+ if ( !aBtnRowHead.GetSavedValue() )
+ {
+ aBtnRowHead.Check( TRUE );
+ aBtnColHead.Check( FALSE );
+ if ( theCurArea.aStart.Col() == 0 && theCurArea.aEnd.Col() == MAXCOL )
+ {
+ theCurArea.aEnd.SetCol( MAXCOL - 1 );
+ String aStr;
+ theCurArea.Format( aStr, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ aEdAssign.SetText( aStr );
+ }
+ ScRange aRange( theCurData );
+ aRange.aStart.SetCol( static_cast<SCCOL>(Min( (long)(theCurArea.aEnd.Col() + 1), (long)MAXCOL )) );
+ aRange.aEnd.SetCol( MAXCOL );
+ AdjustColRowData( aRange );
+ }
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdAssign) || (pCtrl == (Control*)&aRbAssign) )
+ pEdActive = &aEdAssign;
+ else if( (pCtrl == (Control*)&aEdAssign2) || (pCtrl == (Control*)&aRbAssign2) )
+ pEdActive = &aEdAssign2;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+
+IMPL_LINK( ScColRowNameRangesDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/datafdlg.cxx b/sc/source/ui/miscdlgs/datafdlg.cxx
new file mode 100644
index 000000000000..3e859e9676a5
--- /dev/null
+++ b/sc/source/ui/miscdlgs/datafdlg.cxx
@@ -0,0 +1,425 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Amelia Wang <amwang@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------
+
+#include "datafdlg.hxx"
+#include "scresid.hxx"
+#include "datafdlg.hrc"
+#include "viewdata.hxx"
+//#include "document.hxx"
+#include "docsh.hxx"
+#include "refundo.hxx"
+#include "undodat.hxx"
+
+#include "rtl/ustrbuf.hxx"
+
+#define HDL(hdl) LINK( this, ScDataFormDlg, hdl )
+
+using ::rtl::OUStringBuffer;
+
+//zhangyun
+ScDataFormDlg::ScDataFormDlg( Window* pParent, ScTabViewShell* pTabViewShellOri) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DATAFORM ) ),
+ //
+ aBtnNew ( this, ScResId( BTN_DATAFORM_NEW ) ),
+ aBtnDelete ( this, ScResId( BTN_DATAFORM_DELETE ) ),
+ aBtnRestore ( this, ScResId( BTN_DATAFORM_RESTORE ) ),
+ aBtnLast ( this, ScResId( BTN_DATAFORM_LAST ) ),
+ aBtnNext ( this, ScResId( BTN_DATAFORM_NEXT ) ),
+ aBtnClose ( this, ScResId( BTN_DATAFORM_CLOSE ) ),
+ aSlider ( this, ScResId( WND_DATAFORM_SCROLLBAR ) ),
+ aFixedText ( this, ScResId( LAB_DATAFORM_RECORDNO ) )
+{
+ pTabViewShell = pTabViewShellOri;
+ FreeResource();
+ //read header form current document, and add new controls
+ DBG_ASSERT( pTabViewShell, "pTabViewShell is NULL! :-/" );
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+
+ pDoc = pViewData->GetDocument();
+ if (pDoc)
+ {
+ ScRange aRange;
+ pViewData->GetSimpleArea( aRange );
+ ScAddress aStart = aRange.aStart;
+ ScAddress aEnd = aRange.aEnd;
+
+ nStartCol = aStart.Col();
+ nEndCol = aEnd.Col();
+ nStartRow = aStart.Row();
+ nEndRow = aEnd.Row();
+
+ nTab = pViewData->GetTabNo();
+ //if there is no selection
+ if ((nStartCol == nEndCol) && (nStartRow == nEndRow))
+ bNoSelection = TRUE;
+
+ if (bNoSelection)
+ {
+ //find last not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ nEndCol++;
+ pDoc->GetString( nEndCol, nStartRow, nTab, aColName );
+ int nColWidth = pDoc->GetColWidth( nEndCol, nTab );
+ if ( aColName.Len() == 0 && nColWidth)
+ {
+ nEndCol--;
+ break;
+ }
+ }
+
+ //find first not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ if (nStartCol <= 0)
+ break;
+ nStartCol--;
+
+ pDoc->GetString( nStartCol, nStartRow, nTab, aColName );
+ int nColWidth = pDoc->GetColWidth( nEndCol, nTab );
+ if ( aColName.Len() == 0 && nColWidth)
+ {
+ nStartCol++;
+ break;
+ }
+ }
+
+ //skip leading hide column
+ for (int i=1;i<=MAX_DATAFORM_COLS;i++)
+ {
+ String aColName;
+ int nColWidth = pDoc->GetColWidth( nStartCol, nTab );
+ if (nColWidth)
+ break;
+ nStartCol++;
+ }
+
+ if (nEndCol < nStartCol)
+ nEndCol = nStartCol;
+
+ //find last not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_ROWS;i++)
+ {
+ String aColName;
+ nEndRow++;
+ pDoc->GetString( nStartCol, nEndRow, nTab, aColName );
+ if ( aColName.Len() == 0 )
+ {
+ nEndRow--;
+ break;
+ }
+ }
+
+ //find first not blank cell in row
+ for (int i=1;i<=MAX_DATAFORM_ROWS;i++)
+ {
+ String aColName;
+ if (nStartRow <= 0)
+ break;
+ nStartRow--;
+
+ pDoc->GetString( nStartCol, nStartRow, nTab, aColName );
+ if ( aColName.Len() == 0 )
+ {
+ nStartRow++;
+ break;
+ }
+ }
+
+ if (nEndRow < nStartRow)
+ nEndRow = nStartRow;
+ }
+
+ aCurrentRow = nStartRow + 1;
+
+ String aFieldName;
+
+ int nTop = 12;
+
+ Size nFixedSize(FIXED_WIDTH, CTRL_HEIGHT );
+ Size nEditSize(EDIT_WIDTH, CTRL_HEIGHT );
+
+ //pFtArray = new FixedText(this);
+ aColLength = nEndCol - nStartCol + 1;
+
+ //new the controls
+ pFixedTexts = new FixedText*[aColLength];
+ pEdits = new Edit*[aColLength];
+
+ for(sal_uInt16 nIndex = 0; nIndex < aColLength; nIndex++)
+ {
+ pDoc->GetString( nIndex + nStartCol, nStartRow, nTab, aFieldName );
+ int nColWidth = pDoc->GetColWidth( nIndex + nStartCol, nTab );
+ if (nColWidth)
+ {
+ pFixedTexts[nIndex] = new FixedText(this);
+ pEdits[nIndex] = new Edit(this, WB_BORDER);
+
+ pFixedTexts[nIndex]->SetSizePixel(nFixedSize);
+ pEdits[nIndex]->SetSizePixel(nEditSize);
+ pFixedTexts[nIndex]->SetPosPixel(Point(FIXED_LEFT, nTop));
+ pEdits[nIndex]->SetPosPixel(Point(EDIT_LEFT, nTop));
+ //pFixedTexts[nIndex]->SetText(String::CreateFromAscii("W4W-Filter Nr. "));
+ pFixedTexts[nIndex]->SetText(aFieldName);
+ pFixedTexts[nIndex]->Show();
+ pEdits[nIndex]->Show();
+
+ nTop += LINE_HEIGHT;
+ }
+ else
+ {
+ pFixedTexts[nIndex] = NULL;
+ pEdits[nIndex] = NULL;
+ }
+ pEdits[nIndex]->SetModifyHdl( HDL(Impl_DataModifyHdl) );
+ }
+
+ Size nDialogSize = this->GetSizePixel();
+ if (nTop > nDialogSize.Height())
+ {
+ nDialogSize.setHeight(nTop);
+ this->SetSizePixel(nDialogSize);
+ }
+ Size nScrollSize = aSlider.GetSizePixel();
+ nScrollSize.setHeight(nDialogSize.Height()-20);
+ aSlider.SetSizePixel(nScrollSize);
+ }
+
+ FillCtrls(aCurrentRow);
+
+ aSlider.SetPageSize( 10 );
+ aSlider.SetVisibleSize( 1 );
+ aSlider.SetLineSize( 1 );
+ aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
+ aSlider.Show();
+
+ aBtnNew.SetClickHdl ( HDL(Impl_NewHdl) );
+ aBtnLast.SetClickHdl ( HDL(Impl_LastHdl) );
+ aBtnNext.SetClickHdl ( HDL(Impl_NextHdl) );
+
+ aBtnRestore.SetClickHdl ( HDL(Impl_RestoreHdl) );
+ aBtnDelete.SetClickHdl ( HDL(Impl_DeleteHdl) );
+ aBtnClose.SetClickHdl ( HDL(Impl_CloseHdl) );
+
+ aSlider.SetEndScrollHdl( HDL( Impl_ScrollHdl ) );
+
+ SetButtonState();
+
+ //end
+ //FreeResource();
+}
+
+ScDataFormDlg::~ScDataFormDlg()
+{
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ delete pEdits[i];
+ if (pFixedTexts[i])
+ delete pFixedTexts[i];
+ }
+ if (pEdits)
+ delete pEdits;
+ if (pFixedTexts)
+ delete pFixedTexts;
+}
+
+void ScDataFormDlg::FillCtrls(SCROW /*nCurrentRow*/)
+{
+ //ScViewData* pViewData = pTabViewShell->GetViewData();
+
+ String aFieldName;
+ for (sal_uInt16 i = 0; i < aColLength; ++i)
+ {
+ if (pEdits[i])
+ {
+ if (aCurrentRow<=nEndRow)
+ {
+ pDoc->GetString( i + nStartCol, aCurrentRow, nTab, aFieldName );
+ pEdits[i]->SetText(aFieldName);
+ }
+ else
+ pEdits[i]->SetText(String());
+ }
+ }
+
+ if (aCurrentRow <= nEndRow)
+ {
+ OUStringBuffer aBuf;
+ aBuf.append(static_cast<sal_Int32>(aCurrentRow - nStartRow));
+ aBuf.appendAscii(" / ");
+ aBuf.append(static_cast<sal_Int32>(nEndRow - nStartRow));
+ aFixedText.SetText(aBuf.makeStringAndClear());
+ }
+ else
+ aFixedText.SetText(String(ScResId(STR_NEW_RECORD)));
+
+ aSlider.SetThumbPos(aCurrentRow-nStartRow-1);
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_DataModifyHdl, Edit*, pEdit)
+{
+ if ( pEdit->IsModified() )
+ aBtnRestore.Enable( TRUE );
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_NewHdl, PushButton*, EMPTYARG )
+{
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if ( pDoc )
+ {
+ sal_Bool bHasData = sal_False;
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ if (pEdits[i])
+ if ( pEdits[i]->GetText().Len() != 0 )
+ {
+ bHasData = sal_True;
+ break;
+ }
+
+ if ( bHasData )
+ {
+ pTabViewShell->DataFormPutData( aCurrentRow , nStartRow , nStartCol , nEndRow , nEndCol , pEdits , aColLength );
+ aCurrentRow++;
+ if (aCurrentRow >= nEndRow + 2)
+ {
+ nEndRow ++ ;
+ aSlider.SetRange( Range( 0, nEndRow - nStartRow + 1) );
+ }
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaintGridAll();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_LastHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ if ( aCurrentRow > nStartRow +1 )
+ aCurrentRow--;
+
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_NextHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ if ( aCurrentRow <= nEndRow)
+ aCurrentRow++;
+
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_RestoreHdl, PushButton*, EMPTYARG )
+{
+ if (pDoc)
+ {
+ FillCtrls(aCurrentRow);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_DeleteHdl, PushButton*, EMPTYARG )
+{
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if (pDoc)
+ {
+ ScRange aRange(nStartCol, aCurrentRow, nTab, nEndCol, aCurrentRow, nTab);
+ pDoc->DeleteRow(aRange);
+ nEndRow--;
+
+ SetButtonState();
+ pDocSh->GetUndoManager()->Clear();
+
+ FillCtrls(aCurrentRow);
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaintGridAll();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_CloseHdl, PushButton*, EMPTYARG )
+{
+ EndDialog( );
+ return 0;
+}
+
+IMPL_LINK( ScDataFormDlg, Impl_ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ long nOffset = aSlider.GetThumbPos();
+ aCurrentRow = nStartRow + nOffset + 1;
+ SetButtonState();
+ FillCtrls(aCurrentRow);
+ return 0;
+}
+
+void ScDataFormDlg::SetButtonState()
+{
+ if ( aCurrentRow > nEndRow )
+ {
+ aBtnDelete.Enable( FALSE );
+ aBtnLast.Enable( TRUE );
+ aBtnNext.Enable( FALSE );
+ }
+ else
+ {
+ aBtnDelete.Enable( TRUE );
+ aBtnNext.Enable( TRUE );
+ }
+ if ( 1 == aCurrentRow )
+ aBtnLast.Enable( FALSE );
+
+ aBtnRestore.Enable( FALSE );
+ if ( pEdits )
+ pEdits[0]->GrabFocus();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/delcldlg.cxx b/sc/source/ui/miscdlgs/delcldlg.cxx
new file mode 100644
index 000000000000..6ece4b648d64
--- /dev/null
+++ b/sc/source/ui/miscdlgs/delcldlg.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "delcldlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+static BYTE nDelItemChecked=0;
+
+//==================================================================
+
+ScDeleteCellDlg::ScDeleteCellDlg( Window* pParent, BOOL bDisallowCellMove ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DELCELL ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnCellsUp ( this, ScResId( BTN_CELLSUP ) ),
+ aBtnCellsLeft ( this, ScResId( BTN_CELLSLEFT ) ),
+ aBtnDelRows ( this, ScResId( BTN_DELROWS ) ),
+ aBtnDelCols ( this, ScResId( BTN_DELCOLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+
+ if (bDisallowCellMove)
+ {
+ aBtnCellsUp.Disable();
+ aBtnCellsLeft.Disable();
+
+ switch(nDelItemChecked)
+ {
+ case 2: aBtnDelRows.Check();break;
+ case 3: aBtnDelCols.Check();break;
+ default:aBtnDelRows.Check();break;
+ }
+ }
+ else
+ {
+ switch(nDelItemChecked)
+ {
+ case 0: aBtnCellsUp.Check();break;
+ case 1: aBtnCellsLeft.Check();break;
+ case 2: aBtnDelRows.Check();break;
+ case 3: aBtnDelCols.Check();break;
+ }
+ }
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+DelCellCmd ScDeleteCellDlg::GetDelCellCmd() const
+{
+ DelCellCmd nReturn = DEL_NONE;
+
+ if ( aBtnCellsUp.IsChecked() )
+ {
+ nDelItemChecked=0;
+ nReturn = DEL_CELLSUP;
+ }
+ else if ( aBtnCellsLeft.IsChecked() )
+ {
+ nDelItemChecked=1;
+ nReturn = DEL_CELLSLEFT;
+ }
+ else if ( aBtnDelRows.IsChecked() )
+ {
+ nDelItemChecked=2;
+ nReturn = DEL_DELROWS;
+ }
+ else if ( aBtnDelCols.IsChecked() )
+ {
+ nDelItemChecked=3;
+ nReturn = DEL_DELCOLS;
+ }
+
+ return nReturn;
+}
+
+__EXPORT ScDeleteCellDlg::~ScDeleteCellDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/delcodlg.cxx b/sc/source/ui/miscdlgs/delcodlg.cxx
new file mode 100644
index 000000000000..c98721eb4aff
--- /dev/null
+++ b/sc/source/ui/miscdlgs/delcodlg.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "delcodlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+BOOL ScDeleteContentsDlg::bPreviousAllCheck = FALSE;
+USHORT ScDeleteContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
+ IDF_NOTE | IDF_FORMULA |
+ IDF_VALUE);
+
+//-----------------------------------------------------------------------
+
+ScDeleteContentsDlg::ScDeleteContentsDlg( Window* pParent,
+ USHORT nCheckDefaults ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_DELCONT ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnDelAll ( this, ScResId( BTN_DELALL ) ),
+ aBtnDelStrings ( this, ScResId( BTN_DELSTRINGS ) ),
+ aBtnDelNumbers ( this, ScResId( BTN_DELNUMBERS ) ),
+ aBtnDelDateTime ( this, ScResId( BTN_DELDATETIME ) ),
+ aBtnDelFormulas ( this, ScResId( BTN_DELFORMULAS ) ),
+ aBtnDelNotes ( this, ScResId( BTN_DELNOTES ) ),
+ aBtnDelAttrs ( this, ScResId( BTN_DELATTRS ) ),
+ aBtnDelObjects ( this, ScResId( BTN_DELOBJECTS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ bObjectsDisabled( FALSE )
+{
+ if ( nCheckDefaults != 0 )
+ {
+ ScDeleteContentsDlg::nPreviousChecks = nCheckDefaults;
+ ScDeleteContentsDlg::bPreviousAllCheck = FALSE;
+ }
+
+ aBtnDelAll.Check ( ScDeleteContentsDlg::bPreviousAllCheck );
+ aBtnDelStrings.Check ( IS_SET( IDF_STRING,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelNumbers.Check ( IS_SET( IDF_VALUE,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelDateTime.Check( IS_SET( IDF_DATETIME,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelFormulas.Check( IS_SET( IDF_FORMULA,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelNotes.Check ( IS_SET( IDF_NOTE,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelAttrs.Check ( IS_SET( IDF_ATTRIB,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+ aBtnDelObjects.Check ( IS_SET( IDF_OBJECTS,
+ ScDeleteContentsDlg::nPreviousChecks ) );
+
+ DisableChecks( aBtnDelAll.IsChecked() );
+
+ aBtnDelAll.SetClickHdl( LINK( this, ScDeleteContentsDlg, DelAllHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScDeleteContentsDlg::GetDelContentsCmdBits() const
+{
+ ScDeleteContentsDlg::nPreviousChecks = 0;
+
+ if ( aBtnDelStrings.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks = IDF_STRING;
+ if ( aBtnDelNumbers.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_VALUE;
+ if ( aBtnDelDateTime.IsChecked())
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_DATETIME;
+ if ( aBtnDelFormulas.IsChecked())
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_FORMULA;
+ if ( aBtnDelNotes.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_NOTE;
+ if ( aBtnDelAttrs.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_ATTRIB;
+ if ( aBtnDelObjects.IsChecked() )
+ ScDeleteContentsDlg::nPreviousChecks |= IDF_OBJECTS;
+
+ ScDeleteContentsDlg::bPreviousAllCheck = aBtnDelAll.IsChecked();
+
+ return ( (ScDeleteContentsDlg::bPreviousAllCheck)
+ ? IDF_ALL
+ : ScDeleteContentsDlg::nPreviousChecks );
+}
+
+//------------------------------------------------------------------------
+
+void ScDeleteContentsDlg::DisableChecks( BOOL bDelAllChecked )
+{
+ if ( bDelAllChecked )
+ {
+ aBtnDelStrings.Disable();
+ aBtnDelNumbers.Disable();
+ aBtnDelDateTime.Disable();
+ aBtnDelFormulas.Disable();
+ aBtnDelNotes.Disable();
+ aBtnDelAttrs.Disable();
+ aBtnDelObjects.Disable();
+ }
+ else
+ {
+ aBtnDelStrings.Enable();
+ aBtnDelNumbers.Enable();
+ aBtnDelDateTime.Enable();
+ aBtnDelFormulas.Enable();
+ aBtnDelNotes.Enable();
+ aBtnDelAttrs.Enable();
+ if (bObjectsDisabled)
+ aBtnDelObjects.Disable();
+ else
+ aBtnDelObjects.Enable();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScDeleteContentsDlg::DisableObjects()
+{
+ bObjectsDisabled = TRUE;
+ aBtnDelObjects.Check(FALSE);
+ aBtnDelObjects.Disable();
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
+{
+ DisableChecks( aBtnDelAll.IsChecked() );
+
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScDeleteContentsDlg, DelAllHdl, void *, EMPTYARG )
+
+__EXPORT ScDeleteContentsDlg::~ScDeleteContentsDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/filldlg.cxx b/sc/source/ui/miscdlgs/filldlg.cxx
new file mode 100644
index 000000000000..aa70e7cfb7ba
--- /dev/null
+++ b/sc/source/ui/miscdlgs/filldlg.cxx
@@ -0,0 +1,377 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//----------------------------------------------------------------------------
+
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <limits.h>
+
+#include "scresid.hxx"
+#include "document.hxx"
+#include "miscdlgs.hrc"
+
+#define _FILLDLG_CXX
+#include "filldlg.hxx"
+#undef _FILLDLG_CXX
+
+
+
+//============================================================================
+// class ScFillSeriesDlg
+
+//----------------------------------------------------------------------------
+
+ScFillSeriesDlg::ScFillSeriesDlg( Window* pParent,
+ ScDocument& rDocument,
+ FillDir eFillDir,
+ FillCmd eFillCmd,
+ FillDateCmd eFillDateCmd,
+ String aStartStr,
+ double fStep,
+ double fMax,
+ USHORT nPossDir )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_FILLSERIES ) ),
+
+ aFlDirection ( this, ScResId( FL_DIRECTION ) ),
+ aBtnDown ( this, ScResId( BTN_BOTTOM ) ),
+ aBtnRight ( this, ScResId( BTN_RIGHT ) ),
+ aBtnUp ( this, ScResId( BTN_TOP ) ),
+ aBtnLeft ( this, ScResId( BTN_LEFT ) ),
+ aFlSep1 ( this, ScResId( FL_SEP1 ) ),
+ aFlType ( this, ScResId( FL_TYPE ) ),
+ aBtnArithmetic ( this, ScResId( BTN_ARITHMETIC ) ),
+ aBtnGeometric ( this, ScResId( BTN_GEOMETRIC ) ),
+ aBtnDate ( this, ScResId( BTN_DATE ) ),
+ aBtnAutoFill ( this, ScResId( BTN_AUTOFILL ) ),
+ aFlSep2 ( this, ScResId( FL_SEP2 ) ),
+ aFlTimeUnit ( this, ScResId( FL_TIME_UNIT ) ),
+ aBtnDay ( this, ScResId( BTN_DAY ) ),
+ aBtnDayOfWeek ( this, ScResId( BTN_DAY_OF_WEEK ) ),
+ aBtnMonth ( this, ScResId( BTN_MONTH ) ),
+ aBtnYear ( this, ScResId( BTN_YEAR ) ),
+
+ aFtStartVal ( this, ScResId( FT_START_VALUE ) ),
+ aEdStartVal ( this, ScResId( ED_START_VALUES ) ),
+ aStartStrVal ( aStartStr),
+ aFtEndVal ( this, ScResId( FT_END_VALUE ) ),
+ aEdEndVal ( this, ScResId( ED_END_VALUES ) ),
+ aFtIncrement ( this, ScResId( FT_INCREMENT ) ),
+ aEdIncrement ( this, ScResId( ED_INCREMENT ) ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ errMsgInvalidVal( ScResId( STR_VALERR ) ),
+ rDoc ( rDocument ),
+ theFillDir ( eFillDir ),
+ theFillCmd ( eFillCmd ),
+ theFillDateCmd ( eFillDateCmd ),
+ fIncrement ( fStep ),
+ fEndVal ( fMax )
+{
+ Init( nPossDir );
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScFillSeriesDlg::~ScFillSeriesDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ScFillSeriesDlg::SetEdStartValEnabled(BOOL bFlag)
+{
+ bStartValFlag=bFlag;
+ if(bFlag)
+ {
+ aFtStartVal.Enable();
+ aEdStartVal.Enable();
+ }
+ else
+ {
+ aFtStartVal.Disable();
+ aEdStartVal.Disable();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScFillSeriesDlg::Init( USHORT nPossDir )
+{
+ aBtnOk.SetClickHdl ( LINK( this, ScFillSeriesDlg, OKHdl ) );
+ aBtnArithmetic.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+ aBtnGeometric.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+ aBtnDate.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+ aBtnAutoFill.SetClickHdl ( LINK( this, ScFillSeriesDlg, DisableHdl ) );
+
+ if( nPossDir == FDS_OPT_NONE )
+ {
+ aBtnLeft.Disable();
+ aBtnRight.Disable();
+ aBtnDown.Disable();
+ aBtnUp.Disable();
+ }
+
+ if( nPossDir == FDS_OPT_HORZ )
+ {
+ aBtnDown.Disable();
+ aBtnUp.Disable();
+ }
+
+ if( nPossDir == FDS_OPT_VERT )
+ {
+ aBtnLeft.Disable();
+ aBtnRight.Disable();
+ }
+
+ switch ( theFillDir )
+ {
+ case FILL_TO_LEFT: aBtnLeft.Check(); break;
+ case FILL_TO_RIGHT: aBtnRight.Check(); break;
+ case FILL_TO_BOTTOM: aBtnDown.Check(); break;
+ case FILL_TO_TOP: aBtnUp.Check(); break;
+ default:
+ break;
+ }
+
+ switch ( theFillCmd )
+ {
+ case FILL_LINEAR:
+ aBtnArithmetic.Check();
+ DisableHdl( &aBtnArithmetic );
+ break;
+ case FILL_GROWTH:
+ aBtnGeometric.Check();
+ DisableHdl( &aBtnGeometric );
+ break;
+ case FILL_DATE:
+ aBtnDate.Check();
+ DisableHdl( &aBtnDate );
+ break;
+ case FILL_AUTO:
+ aBtnAutoFill.Check();
+ DisableHdl( &aBtnAutoFill );
+ break;
+ default:
+ break;
+ }
+
+ switch ( theFillDateCmd )
+ {
+ case FILL_DAY: aBtnDay.Check(); break;
+ case FILL_WEEKDAY: aBtnDayOfWeek.Check(); break;
+ case FILL_MONTH: aBtnMonth.Check(); break;
+ case FILL_YEAR: aBtnYear.Check(); break;
+ default:
+ break;
+ }
+
+ fStartVal = MAXDOUBLE;
+ /*
+ String aStartTxt;
+ if ( fStartVal != MAXDOUBLE )
+ rDoc.GetFormatTable()->GetInputLineString( fStartVal, 0, aStartTxt );
+ aEdStartVal.SetText( aStartTxt );
+ */
+
+ aEdStartVal.SetText( aStartStrVal);
+
+ String aIncrTxt;
+ rDoc.GetFormatTable()->GetInputLineString( fIncrement, 0, aIncrTxt );
+ aEdIncrement.SetText( aIncrTxt );
+
+ String aEndTxt;
+ if ( fEndVal != MAXDOUBLE )
+ rDoc.GetFormatTable()->GetInputLineString( fEndVal, 0, aEndTxt );
+ aEdEndVal.SetText( aEndTxt );
+
+ bStartValFlag=FALSE;
+
+ aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
+ aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFillSeriesDlg::CheckStartVal()
+{
+ BOOL bValOk = FALSE;
+ sal_uInt32 nKey = 0;
+ String aStr( aEdStartVal.GetText() );
+
+ if ( aStr.Len() == 0 || aBtnAutoFill.IsChecked())
+ {
+ fStartVal = MAXDOUBLE;
+ bValOk = TRUE;
+ }
+ else
+ bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fStartVal );
+
+ return bValOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFillSeriesDlg::CheckIncrementVal()
+{
+ sal_uInt32 nKey = 0;
+ String aStr( aEdIncrement.GetText() );
+
+ return rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fIncrement );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScFillSeriesDlg::CheckEndVal()
+{
+ BOOL bValOk = FALSE;
+ sal_uInt32 nKey = 0;
+ String aStr( aEdEndVal.GetText() );
+
+ if ( aStr.Len() == 0 )
+ {
+ fEndVal = (fIncrement < 0) ? -MAXDOUBLE : MAXDOUBLE;
+ bValOk = TRUE;
+ }
+ else
+ bValOk = rDoc.GetFormatTable()->IsNumberFormat( aStr, nKey, fEndVal );
+
+ return bValOk;
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFillSeriesDlg, DisableHdl, Button *, pBtn )
+{
+ if ( pBtn == &aBtnDate )
+ {
+ aBtnDay.Enable();
+ aBtnDayOfWeek.Enable();
+ aBtnMonth.Enable();
+ aBtnYear.Enable();
+ aFlTimeUnit.Enable();
+ }
+ else
+ {
+ aBtnDay.Disable();
+ aBtnDayOfWeek.Disable();
+ aBtnMonth.Disable();
+ aBtnYear.Disable();
+ aFlTimeUnit.Disable();
+ }
+
+ if ( pBtn != &aBtnAutoFill )
+ {
+ aFtIncrement.Enable();
+ aEdIncrement.Enable();
+ aFtEndVal.Enable();
+ aEdEndVal.Enable();
+ }
+ else
+ {
+ aFtIncrement.Disable();
+ aEdIncrement.Disable();
+ aFtEndVal.Disable();
+ aEdEndVal.Disable();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScFillSeriesDlg, OKHdl, void *, EMPTYARG )
+{
+ if ( aBtnLeft.IsChecked() ) theFillDir = FILL_TO_LEFT;
+ else if ( aBtnRight.IsChecked() ) theFillDir = FILL_TO_RIGHT;
+ else if ( aBtnDown.IsChecked() ) theFillDir = FILL_TO_BOTTOM;
+ else if ( aBtnUp.IsChecked() ) theFillDir = FILL_TO_TOP;
+
+ if ( aBtnArithmetic.IsChecked() ) theFillCmd = FILL_LINEAR;
+ else if ( aBtnGeometric.IsChecked() ) theFillCmd = FILL_GROWTH;
+ else if ( aBtnDate.IsChecked() ) theFillCmd = FILL_DATE;
+ else if ( aBtnAutoFill.IsChecked() ) theFillCmd = FILL_AUTO;
+
+ if ( aBtnDay.IsChecked() ) theFillDateCmd = FILL_DAY;
+ else if ( aBtnDayOfWeek.IsChecked() ) theFillDateCmd = FILL_WEEKDAY;
+ else if ( aBtnMonth.IsChecked() ) theFillDateCmd = FILL_MONTH;
+ else if ( aBtnYear.IsChecked() ) theFillDateCmd = FILL_YEAR;
+
+ BOOL bAllOk = TRUE;
+ Edit* pEdWrong = NULL;
+ if ( !CheckStartVal() )
+ {
+ bAllOk = FALSE;
+ pEdWrong = &aEdStartVal;
+ }
+ else if ( !CheckIncrementVal() )
+ {
+ bAllOk = FALSE;
+ pEdWrong = &aEdIncrement;
+ }
+ else if ( !CheckEndVal() )
+ {
+ bAllOk = FALSE;
+ pEdWrong = &aEdEndVal;
+ }
+ if ( bAllOk )
+ EndDialog( RET_OK );
+ else
+ {
+ ErrorBox( this,
+ WinBits( WB_OK | WB_DEF_OK ),
+ errMsgInvalidVal
+ ).Execute();
+ pEdWrong->GrabFocus();
+ }
+
+ return 0;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/groupdlg.cxx b/sc/source/ui/miscdlgs/groupdlg.cxx
new file mode 100644
index 000000000000..63bf0053b58c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/groupdlg.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "groupdlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScGroupDlg::ScGroupDlg( Window* pParent,
+ USHORT nResId,
+ BOOL bUngroup,
+ BOOL bRows ) :
+ ModalDialog ( pParent, ScResId( nResId ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnRows ( this, ScResId( BTN_GROUP_ROWS ) ),
+ aBtnCols ( this, ScResId( BTN_GROUP_COLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ aFlFrame.SetText( String( ScResId(bUngroup ? STR_UNGROUP : STR_GROUP) ) );
+
+ if ( bRows )
+ aBtnRows.Check();
+ else
+ aBtnCols.Check();
+
+ //-------------
+ FreeResource();
+ aBtnRows.GrabFocus();
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScGroupDlg::GetColsChecked() const
+{
+ return aBtnCols.IsChecked();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScGroupDlg::~ScGroupDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/highred.cxx b/sc/source/ui/miscdlgs/highred.cxx
new file mode 100644
index 000000000000..aab3a2188c00
--- /dev/null
+++ b/sc/source/ui/miscdlgs/highred.cxx
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "highred.hrc"
+
+#include "highred.hxx"
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+inline void EnableDisable( Window& rWin, BOOL bEnable )
+{
+ if (bEnable)
+ rWin.Enable();
+ else
+ rWin.Disable();
+}
+
+//============================================================================
+// class ScHighlightChgDlg
+
+//----------------------------------------------------------------------------
+ScHighlightChgDlg::ScHighlightChgDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData)
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_HIGHLIGHT_CHANGES ),
+ //
+ aHighlightBox ( this, ScResId( CB_HIGHLIGHT)),
+ aFlFilter ( this, ScResId( FL_FILTER)),
+ aFilterCtr ( this),
+ aCbAccept ( this, ScResId( CB_HIGHLIGHT_ACCEPT)),
+ aCbReject ( this, ScResId( CB_HIGHLIGHT_REJECT)),
+ aOkButton ( this, ScResId( BTN_OK ) ),
+ aCancelButton ( this, ScResId( BTN_CANCEL ) ),
+ aHelpButton ( this, ScResId( BTN_HELP ) ),
+ aEdAssign ( this, this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) )
+{
+ FreeResource();
+
+ Point aFlFilterPt( aFlFilter.GetPosPixel() );
+ aFlFilterPt.Y() += aFlFilter.GetSizePixel().Height();
+ aFilterCtr.SetPosPixel( aFlFilterPt );
+ MinSize=aFilterCtr.GetSizePixel();
+ MinSize.Height()+=2;
+ MinSize.Width()+=2;
+ aOkButton.SetClickHdl(LINK( this, ScHighlightChgDlg, OKBtnHdl));
+ aHighlightBox.SetClickHdl(LINK( this, ScHighlightChgDlg, HighLightHandle ));
+ aFilterCtr.SetRefHdl(LINK( this, ScHighlightChgDlg, RefHandle ));
+ aFilterCtr.HideRange(FALSE);
+ aFilterCtr.Show();
+ SetDispatcherLock( TRUE );
+ //SFX_APPWINDOW->Disable(FALSE);
+
+ Init();
+
+}
+ScHighlightChgDlg::~ScHighlightChgDlg()
+{
+ SetDispatcherLock( FALSE );
+ //SFX_APPWINDOW->Enable();
+}
+
+void __EXPORT ScHighlightChgDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+ if(pChanges!=NULL)
+ {
+ aChangeViewSet.SetTheAuthorToShow(pChanges->GetUser());
+ aFilterCtr.ClearAuthors();
+ ScStrCollection aUserColl=pChanges->GetUserCollection();
+ for(USHORT i=0;i<aUserColl.GetCount();i++)
+ aFilterCtr.InsertAuthor(aUserColl[i]->GetString());
+ }
+
+
+ ScChangeViewSettings* pViewSettings=pDoc->GetChangeViewSettings();
+
+ if(pViewSettings!=NULL)
+ aChangeViewSet=*pViewSettings;
+ aHighlightBox.Check(aChangeViewSet.ShowChanges());
+ aFilterCtr.CheckDate(aChangeViewSet.HasDate());
+ aFilterCtr.SetFirstDate(aChangeViewSet.GetTheFirstDateTime());
+ aFilterCtr.SetFirstTime(aChangeViewSet.GetTheFirstDateTime());
+ aFilterCtr.SetLastDate(aChangeViewSet.GetTheLastDateTime());
+ aFilterCtr.SetLastTime(aChangeViewSet.GetTheLastDateTime());
+ aFilterCtr.SetDateMode((USHORT)aChangeViewSet.GetTheDateMode());
+ aFilterCtr.CheckAuthor(aChangeViewSet.HasAuthor());
+ aFilterCtr.CheckComment(aChangeViewSet.HasComment());
+ aFilterCtr.SetComment(aChangeViewSet.GetTheComment());
+
+ aCbAccept.Check(aChangeViewSet.IsShowAccepted());
+ aCbReject.Check(aChangeViewSet.IsShowRejected());
+
+ String aString=aChangeViewSet.GetTheAuthorToShow();
+ if(aString.Len()!=0)
+ {
+ aFilterCtr.SelectAuthor(aString);
+ }
+ else
+ {
+ aFilterCtr.SelectedAuthorPos(0);
+ }
+
+ aFilterCtr.CheckRange(aChangeViewSet.HasRange());
+ ScRange* pRangeEntry=aChangeViewSet.GetTheRangeList().GetObject(0);
+
+
+ if(pRangeEntry!=NULL)
+ {
+ String aRefStr;
+ pRangeEntry->Format( aRefStr, ABS_DREF3D, pDoc );
+ aFilterCtr.SetRange(aRefStr);
+ }
+ aFilterCtr.Enable(TRUE,TRUE);
+ HighLightHandle(&aHighlightBox);
+}
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+void ScHighlightChgDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsVisible() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(&aEdAssign);
+ String aRefStr;
+ rRef.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
+ aEdAssign.SetRefString( aRefStr );
+ aFilterCtr.SetRange(aRefStr);
+ }
+}
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScHighlightChgDlg::Close()
+{
+ return DoClose( ScHighlightChgDlgWrapper::GetChildWindowId() );
+}
+
+void ScHighlightChgDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ if(bForced || !aRbAssign.IsVisible())
+ {
+ aFilterCtr.SetRange(aEdAssign.GetText());
+ aFilterCtr.SetFocusToRange();
+ aEdAssign.Hide();
+ aRbAssign.Hide();
+ }
+}
+
+void ScHighlightChgDlg::SetActive()
+{
+ /*
+ if(pTPFilter!=NULL)
+ {
+ aAcceptChgCtr.GetFilterPage()->SetFocusToRange();
+ aEdAssign.Hide();
+ aRbAssign.Hide();
+ SFX_APPWINDOW->Enable();
+ SetDispatcherLock( FALSE );
+ }
+ //RefInputDone();
+ */
+}
+
+BOOL ScHighlightChgDlg::IsRefInputMode() const
+{
+ return aEdAssign.IsVisible();
+}
+
+IMPL_LINK( ScHighlightChgDlg, HighLightHandle, CheckBox*, pCb )
+{
+ if(pCb!=NULL)
+ {
+ if(aHighlightBox.IsChecked())
+ {
+ aFilterCtr.Enable(TRUE,TRUE);
+ aCbAccept.Enable();
+ aCbReject.Enable();
+ }
+ else
+ {
+ aFilterCtr.Disable(TRUE);
+ aCbAccept.Disable();
+ aCbReject.Disable();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScHighlightChgDlg, RefHandle, SvxTPFilter*, pRef )
+{
+ if(pRef!=NULL)
+ {
+ SetDispatcherLock( TRUE );
+ //SFX_APPWINDOW->Disable(FALSE);
+ aEdAssign.Show();
+ aRbAssign.Show();
+ aEdAssign.SetText(aFilterCtr.GetRange());
+ ScAnyRefDlg::RefInputStart(&aEdAssign,&aRbAssign);
+ }
+ return 0;
+}
+
+IMPL_LINK( ScHighlightChgDlg, OKBtnHdl, PushButton*, pOKBtn )
+{
+ if ( pOKBtn == &aOkButton)
+ {
+ aChangeViewSet.SetShowChanges(aHighlightBox.IsChecked());
+ aChangeViewSet.SetHasDate(aFilterCtr.IsDate());
+ ScChgsDateMode eMode = (ScChgsDateMode) aFilterCtr.GetDateMode();
+ aChangeViewSet.SetTheDateMode( eMode );
+ Date aFirstDate( aFilterCtr.GetFirstDate() );
+ Time aFirstTime( aFilterCtr.GetFirstTime() );
+ Date aLastDate( aFilterCtr.GetLastDate() );
+ Time aLastTime( aFilterCtr.GetLastTime() );
+ aChangeViewSet.SetTheFirstDateTime( DateTime( aFirstDate, aFirstTime ) );
+ aChangeViewSet.SetTheLastDateTime( DateTime( aLastDate, aLastTime ) );
+ aChangeViewSet.SetHasAuthor(aFilterCtr.IsAuthor());
+ aChangeViewSet.SetTheAuthorToShow(aFilterCtr.GetSelectedAuthor());
+ aChangeViewSet.SetHasRange(aFilterCtr.IsRange());
+ aChangeViewSet.SetShowAccepted(aCbAccept.IsChecked());
+ aChangeViewSet.SetShowRejected(aCbReject.IsChecked());
+ aChangeViewSet.SetHasComment(aFilterCtr.IsComment());
+ aChangeViewSet.SetTheComment(aFilterCtr.GetComment());
+ ScRangeList aLocalRangeList;
+ aLocalRangeList.Parse(aFilterCtr.GetRange(), pDoc);
+ aChangeViewSet.SetTheRangeList(aLocalRangeList);
+ aChangeViewSet.AdjustDateMode( *pDoc );
+ pDoc->SetChangeViewSettings(aChangeViewSet);
+ pViewData->GetDocShell()->PostPaintGridAll();
+ Close();
+ }
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/highred.src b/sc/source/ui/miscdlgs/highred.src
new file mode 100644
index 000000000000..ce6409347168
--- /dev/null
+++ b/sc/source/ui/miscdlgs/highred.src
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "highred.hrc"
+ModelessDialog RID_SCDLG_HIGHLIGHT_CHANGES
+{
+ OutputSize = TRUE ;
+ HelpId = FID_CHG_ACCEPT ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 318 , 148 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ // Dieser Dialog hat einen Cancel-Button !
+ CheckBox CB_HIGHLIGHT
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 150 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Show changes in spreadsheet" ;
+ };
+ FixedLine FL_FILTER
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 255 , 8 ) ;
+ Text [ en-US ] = "Filter settings";
+ };
+ CheckBox CB_HIGHLIGHT_ACCEPT
+ {
+ Pos = MAP_APPFONT ( 12 , 118 ) ;
+ Size = MAP_APPFONT ( 246 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show ~accepted changes" ;
+ };
+ CheckBox CB_HIGHLIGHT_REJECT
+ {
+ Pos = MAP_APPFONT ( 12 , 132 ) ;
+ Size = MAP_APPFONT ( 246 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Show ~rejected changes" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 267 , 6 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 267 , 23 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 267 , 43 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Edit ED_ASSIGN
+ {
+ Hide = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 118 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Minimize/Maximize" ;
+ };
+ Text [ en-US ] = "Show Changes" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/inscldlg.cxx b/sc/source/ui/miscdlgs/inscldlg.cxx
new file mode 100644
index 000000000000..99d92f08a106
--- /dev/null
+++ b/sc/source/ui/miscdlgs/inscldlg.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "inscldlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+static BYTE nInsItemChecked=0;
+
+//==================================================================
+
+ScInsertCellDlg::ScInsertCellDlg( Window* pParent,BOOL bDisallowCellMove) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_INSCELL ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnCellsDown ( this, ScResId( BTN_CELLSDOWN ) ),
+ aBtnCellsRight ( this, ScResId( BTN_CELLSRIGHT ) ),
+ aBtnInsRows ( this, ScResId( BTN_INSROWS ) ),
+ aBtnInsCols ( this, ScResId( BTN_INSCOLS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ if (bDisallowCellMove)
+ {
+ aBtnCellsDown.Disable();
+ aBtnCellsRight.Disable();
+ aBtnInsRows.Check();
+
+ switch(nInsItemChecked)
+ {
+ case 2: aBtnInsRows .Check();break;
+ case 3: aBtnInsCols .Check();break;
+ default:aBtnInsRows .Check();break;
+ }
+ }
+ else
+ {
+ switch(nInsItemChecked)
+ {
+ case 0: aBtnCellsDown .Check();break;
+ case 1: aBtnCellsRight.Check();break;
+ case 2: aBtnInsRows .Check();break;
+ case 3: aBtnInsCols .Check();break;
+ }
+ }
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+InsCellCmd ScInsertCellDlg::GetInsCellCmd() const
+{
+ InsCellCmd nReturn = INS_NONE;
+
+ if ( aBtnCellsDown.IsChecked() )
+ {
+ nInsItemChecked=0;
+ nReturn = INS_CELLSDOWN;
+ }
+ else if ( aBtnCellsRight.IsChecked())
+ {
+ nInsItemChecked=1;
+ nReturn = INS_CELLSRIGHT;
+ }
+ else if ( aBtnInsRows.IsChecked() )
+ {
+ nInsItemChecked=2;
+ nReturn = INS_INSROWS;
+ }
+ else if ( aBtnInsCols.IsChecked() )
+ {
+ nInsItemChecked=3;
+ nReturn = INS_INSCOLS;
+ }
+
+ return nReturn;
+}
+
+__EXPORT ScInsertCellDlg::~ScInsertCellDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/inscodlg.cxx b/sc/source/ui/miscdlgs/inscodlg.cxx
new file mode 100644
index 000000000000..b96ccb1346a6
--- /dev/null
+++ b/sc/source/ui/miscdlgs/inscodlg.cxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "inscodlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+BOOL ScInsertContentsDlg::bPreviousAllCheck = TRUE;
+USHORT ScInsertContentsDlg::nPreviousChecks = (IDF_DATETIME | IDF_STRING |
+ IDF_NOTE | IDF_FORMULA |
+ IDF_ATTRIB | IDF_OBJECTS);
+USHORT ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
+USHORT ScInsertContentsDlg::nPreviousChecks2 = 0;
+USHORT ScInsertContentsDlg::nPreviousMoveMode = INS_NONE; // enum InsCellCmd
+
+//-----------------------------------------------------------------------
+
+ScInsertContentsDlg::ScInsertContentsDlg( Window* pParent,
+ USHORT nCheckDefaults,
+ const String* pStrTitle )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_INSCONT ) ),
+ //
+ aFlFrame ( this, ScResId( FL_FRAME ) ),
+ aBtnInsAll ( this, ScResId( BTN_INSALL ) ),
+ aBtnInsStrings ( this, ScResId( BTN_INSSTRINGS ) ),
+ aBtnInsNumbers ( this, ScResId( BTN_INSNUMBERS ) ),
+ aBtnInsDateTime ( this, ScResId( BTN_INSDATETIME ) ),
+ aBtnInsFormulas ( this, ScResId( BTN_INSFORMULAS ) ),
+ aBtnInsNotes ( this, ScResId( BTN_INSNOTES ) ),
+ aBtnInsAttrs ( this, ScResId( BTN_INSATTRS ) ),
+ aBtnInsObjects ( this, ScResId( BTN_INSOBJECTS ) ),
+ aFlSep1 ( this, ScResId( FL_SEP1 ) ),
+ aFlOptions ( this, ScResId( FL_OPTIONS ) ),
+ aBtnSkipEmptyCells( this, ScResId(BTN_SKIP_EMPTY ) ),
+ aBtnTranspose ( this, ScResId( BTN_TRANSPOSE ) ),
+ aBtnLink ( this, ScResId( BTN_LINK ) ),
+ aFlOperation ( this, ScResId( FL_OPERATION ) ),
+ aRbNoOp ( this, ScResId( BTN_OP_NOOP ) ),
+ aRbAdd ( this, ScResId( BTN_OP_ADD ) ),
+ aRbSub ( this, ScResId( BTN_OP_SUB ) ),
+ aRbMul ( this, ScResId( BTN_OP_MUL ) ),
+ aRbDiv ( this, ScResId( BTN_OP_DIV ) ),
+ aFlSep2 ( this, ScResId( FL_SEP2 ) ),
+ aFlMove ( this, ScResId( FL_MOVE ) ),
+ aRbMoveNone ( this, ScResId( BTN_MV_NONE ) ),
+ aRbMoveDown ( this, ScResId( BTN_MV_DOWN ) ),
+ aRbMoveRight ( this, ScResId( BTN_MV_RIGHT ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ bOtherDoc ( FALSE ),
+ bFillMode ( FALSE ),
+ bChangeTrack ( FALSE ),
+ bMoveDownDisabled( FALSE ),
+ bMoveRightDisabled( FALSE )
+{
+ if ( pStrTitle )
+ SetText( *pStrTitle );
+
+ if ( nCheckDefaults != 0 )
+ {
+ ScInsertContentsDlg::nPreviousChecks = nCheckDefaults;
+ ScInsertContentsDlg::bPreviousAllCheck = FALSE;
+ ScInsertContentsDlg::nPreviousChecks2 = 0;
+ }
+
+ aBtnInsAll.Check ( ScInsertContentsDlg::bPreviousAllCheck );
+ aBtnInsStrings.Check ( IS_SET( IDF_STRING,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsNumbers.Check ( IS_SET( IDF_VALUE,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsDateTime.Check( IS_SET( IDF_DATETIME,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsFormulas.Check( IS_SET( IDF_FORMULA,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsNotes.Check ( IS_SET( IDF_NOTE,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsAttrs.Check ( IS_SET( IDF_ATTRIB,
+ ScInsertContentsDlg::nPreviousChecks ) );
+ aBtnInsObjects.Check ( IS_SET( IDF_OBJECTS,
+ ScInsertContentsDlg::nPreviousChecks ) );
+
+ switch( ScInsertContentsDlg::nPreviousFormulaChecks )
+ {
+ case PASTE_NOFUNC: aRbNoOp.Check(TRUE); break;
+ case PASTE_ADD: aRbAdd.Check(TRUE); break;
+ case PASTE_SUB: aRbSub.Check(TRUE); break;
+ case PASTE_MUL: aRbMul.Check(TRUE); break;
+ case PASTE_DIV: aRbDiv.Check(TRUE); break;
+ }
+
+ switch( ScInsertContentsDlg::nPreviousMoveMode )
+ {
+ case INS_NONE: aRbMoveNone.Check(TRUE); break;
+ case INS_CELLSDOWN: aRbMoveDown.Check(TRUE); break;
+ case INS_CELLSRIGHT: aRbMoveRight.Check(TRUE); break;
+ }
+
+ aBtnSkipEmptyCells.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_NOEMPTY ) != 0);
+ aBtnTranspose.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_TRANS ) != 0);
+ aBtnLink.Check( ( ScInsertContentsDlg::nPreviousChecks2 & INS_CONT_LINK ) != 0);
+
+ DisableChecks( aBtnInsAll.IsChecked() );
+
+ aFlSep1.SetStyle( aFlSep1.GetStyle() | WB_VERT );
+ aFlSep2.SetStyle( aFlSep2.GetStyle() | WB_VERT );
+
+ aBtnInsAll.SetClickHdl( LINK( this, ScInsertContentsDlg, InsAllHdl ) );
+ aBtnLink.SetClickHdl( LINK( this, ScInsertContentsDlg, LinkBtnHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScInsertContentsDlg::GetInsContentsCmdBits() const
+{
+ ScInsertContentsDlg::nPreviousChecks = 0;
+
+ if ( aBtnInsStrings.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks = IDF_STRING;
+ if ( aBtnInsNumbers.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_VALUE;
+ if ( aBtnInsDateTime.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks |= IDF_DATETIME;
+ if ( aBtnInsFormulas.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks |= IDF_FORMULA;
+ if ( aBtnInsNotes.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_NOTE;
+ if ( aBtnInsAttrs.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_ATTRIB;
+ if ( aBtnInsObjects.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks |= IDF_OBJECTS;
+
+ ScInsertContentsDlg::bPreviousAllCheck = aBtnInsAll.IsChecked();
+
+ return ( (ScInsertContentsDlg::bPreviousAllCheck)
+ ? IDF_ALL
+ : ScInsertContentsDlg::nPreviousChecks );
+}
+
+//------------------------------------------------------------------------
+
+InsCellCmd ScInsertContentsDlg::GetMoveMode()
+{
+ if ( aRbMoveDown.IsChecked() )
+ return INS_CELLSDOWN;
+ if ( aRbMoveRight.IsChecked() )
+ return INS_CELLSRIGHT;
+
+ return INS_NONE;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertContentsDlg::DisableChecks( BOOL bInsAllChecked )
+{
+ if ( bInsAllChecked )
+ {
+ aBtnInsStrings.Disable();
+ aBtnInsNumbers.Disable();
+ aBtnInsDateTime.Disable();
+ aBtnInsFormulas.Disable();
+ aBtnInsNotes.Disable();
+ aBtnInsAttrs.Disable();
+ aBtnInsObjects.Disable();
+ }
+ else
+ {
+ aBtnInsStrings.Enable();
+ aBtnInsNumbers.Enable();
+ aBtnInsDateTime.Enable();
+ aBtnInsFormulas.Enable();
+ aBtnInsNotes.Enable();
+ aBtnInsAttrs.Enable();
+
+ // "Objects" is disabled for "Fill Tables"
+ if ( bFillMode )
+ aBtnInsObjects.Disable();
+ else
+ aBtnInsObjects.Enable();
+ }
+}
+
+// Link in anderes Dokument -> alles andere disabled
+
+void ScInsertContentsDlg::TestModes()
+{
+ if ( bOtherDoc && aBtnLink.IsChecked() )
+ {
+ aBtnSkipEmptyCells.Disable();
+ aBtnTranspose.Disable();
+ aRbNoOp.Disable();
+ aRbAdd.Disable();
+ aRbSub.Disable();
+ aRbMul.Disable();
+ aRbDiv.Disable();
+ aFlOperation.Disable();
+
+ aRbMoveNone.Disable();
+ aRbMoveDown.Disable();
+ aRbMoveRight.Disable();
+ aFlMove.Disable();
+
+ aFlFrame.Disable();
+ aBtnInsAll.Disable();
+ DisableChecks(TRUE);
+ }
+ else
+ {
+ aBtnSkipEmptyCells.Enable();
+ aBtnTranspose.Enable(!bFillMode);
+ aRbNoOp.Enable();
+ aRbAdd.Enable();
+ aRbSub.Enable();
+ aRbMul.Enable();
+ aRbDiv.Enable();
+ aFlOperation.Enable();
+
+ aRbMoveNone.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
+ aRbMoveDown.Enable(!bFillMode && !bChangeTrack && !bMoveDownDisabled);
+ aRbMoveRight.Enable(!bFillMode && !bChangeTrack && !bMoveRightDisabled);
+ aFlMove.Enable(!bFillMode && !bChangeTrack && !(bMoveDownDisabled && bMoveRightDisabled));
+
+ aFlFrame.Enable();
+ aBtnInsAll.Enable();
+ DisableChecks( aBtnInsAll.IsChecked() );
+ }
+}
+
+void ScInsertContentsDlg::SetOtherDoc( BOOL bSet )
+{
+ if ( bSet != bOtherDoc )
+ {
+ bOtherDoc = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+void ScInsertContentsDlg::SetFillMode( BOOL bSet )
+{
+ if ( bSet != bFillMode )
+ {
+ bFillMode = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+void ScInsertContentsDlg::SetChangeTrack( BOOL bSet )
+{
+ if ( bSet != bChangeTrack )
+ {
+ bChangeTrack = bSet;
+ TestModes();
+ if ( bSet )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+void ScInsertContentsDlg::SetCellShiftDisabled( int nDisable )
+{
+ BOOL bDown = ((nDisable & SC_CELL_SHIFT_DISABLE_DOWN) != 0);
+ BOOL bRight = ((nDisable & SC_CELL_SHIFT_DISABLE_RIGHT) != 0);
+ if ( bDown != bMoveDownDisabled || bRight != bMoveRightDisabled )
+ {
+ bMoveDownDisabled = bDown;
+ bMoveRightDisabled = bRight;
+ TestModes();
+ if ( bMoveDownDisabled && aRbMoveDown.IsChecked() )
+ aRbMoveNone.Check(TRUE);
+ if ( bMoveRightDisabled && aRbMoveRight.IsChecked() )
+ aRbMoveNone.Check(TRUE);
+ }
+}
+
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertContentsDlg, InsAllHdl, void*, EMPTYARG )
+{
+ DisableChecks( aBtnInsAll.IsChecked() );
+
+ return 0;
+}
+
+IMPL_LINK( ScInsertContentsDlg, LinkBtnHdl, void*, EMPTYARG )
+{
+ TestModes();
+
+ return 0;
+}
+
+__EXPORT ScInsertContentsDlg::~ScInsertContentsDlg()
+{
+ ScInsertContentsDlg::nPreviousChecks2 = 0;
+ if(aBtnSkipEmptyCells.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_NOEMPTY;
+ if( aBtnTranspose.IsChecked())
+ ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_TRANS;
+ if( aBtnLink.IsChecked() )
+ ScInsertContentsDlg::nPreviousChecks2 |= INS_CONT_LINK;
+
+ if (!bFillMode) // im FillMode ist None gecheckt und alle 3 disabled
+ {
+ if ( aRbMoveNone.IsChecked() )
+ ScInsertContentsDlg::nPreviousMoveMode = INS_NONE;
+ else if ( aRbMoveDown.IsChecked() )
+ ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSDOWN;
+ else if ( aRbMoveRight.IsChecked() )
+ ScInsertContentsDlg::nPreviousMoveMode = INS_CELLSRIGHT;
+ }
+}
+
+USHORT ScInsertContentsDlg::GetFormulaCmdBits() const
+{
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_NOFUNC;
+ if(aRbAdd.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_ADD;
+ else if(aRbSub.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_SUB;
+ else if(aRbMul.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_MUL;
+ else if(aRbDiv.IsChecked())
+ ScInsertContentsDlg::nPreviousFormulaChecks = PASTE_DIV;
+ // Bits fuer Checkboxen ausblenden
+ return ScInsertContentsDlg::nPreviousFormulaChecks;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/instbdlg.cxx b/sc/source/ui/miscdlgs/instbdlg.cxx
new file mode 100644
index 000000000000..5ee5e824e072
--- /dev/null
+++ b/sc/source/ui/miscdlgs/instbdlg.cxx
@@ -0,0 +1,435 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docinsert.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "global.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+#include "scresid.hxx"
+#include "instbdlg.hrc"
+#include "globstr.hrc"
+
+#define SC_INSTBDLG_CXX
+#include "instbdlg.hxx"
+
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef ModalDialog
+#define ModalDialog( parent, id ) Dialog( parent, "insert-sheet.xml", id )
+#undef ErrorBox
+#define ErrorBox( this, bits, message ) ErrorBox (LAYOUT_THIS_WINDOW (this), bits, message)
+#endif /* ENABLE_LAYOUT */
+
+//==================================================================
+
+ScInsertTableDlg::ScInsertTableDlg( Window* pParent, ScViewData& rData, SCTAB nTabCount, bool bFromFile )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_INSERT_TABLE ) ),
+ //
+ aBtnBefore ( this, ScResId( RB_BEFORE ) ),
+ aBtnBehind ( this, ScResId( RB_BEHIND ) ),
+ aFlPos ( this, ScResId( FL_POSITION ) ),
+ aBtnNew ( this, ScResId( RB_NEW ) ),
+ aBtnFromFile ( this, ScResId( RB_FROMFILE ) ),
+ aFtCount ( this, ScResId( FT_COUNT ) ),
+ aNfCount ( this, ScResId( NF_COUNT ) ),
+ aFtName ( this, ScResId( FT_NAME ) ),
+ aEdName ( this, ScResId( ED_TABNAME ) ),
+ aLbTables ( this, ScResId( LB_TABLES ) ),
+ aFtPath ( this, ScResId( FT_PATH ) ),
+ aBtnBrowse ( this, ScResId( BTN_BROWSE ) ),
+ aBtnLink ( this, ScResId( CB_LINK ) ),
+ aFlTable ( this, ScResId( FL_TABLE ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ rViewData ( rData ),
+ rDoc ( *rData.GetDocument() ),
+ pDocShTables ( NULL ),
+ pDocInserter ( NULL ),
+ bMustClose ( false ),
+ nSelTabIndex ( 0 ),
+ nTableCount (nTabCount)
+{
+#if ENABLE_LAYOUT
+ SetHelpId (SID_INSERT_TABLE);
+ aFtPath.SetText (EMPTY_STRING);
+#endif /* ENABLE_LAYOUT */
+ Init_Impl( bFromFile );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScInsertTableDlg::~ScInsertTableDlg()
+{
+ if (pDocShTables)
+ pDocShTables->DoClose();
+ delete pDocInserter;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::Init_Impl( bool bFromFile )
+{
+ aBtnBrowse .SetClickHdl( LINK( this, ScInsertTableDlg, BrowseHdl_Impl ) );
+ aBtnNew .SetClickHdl( LINK( this, ScInsertTableDlg, ChoiceHdl_Impl ) );
+ aBtnFromFile .SetClickHdl( LINK( this, ScInsertTableDlg, ChoiceHdl_Impl ) );
+ aLbTables .SetSelectHdl( LINK( this, ScInsertTableDlg, SelectHdl_Impl ) );
+ aNfCount .SetModifyHdl( LINK( this, ScInsertTableDlg, CountHdl_Impl));
+ aBtnOk .SetClickHdl( LINK( this, ScInsertTableDlg, DoEnterHdl ));
+ aBtnBefore.Check();
+
+ aNfCount.SetText( String::CreateFromInt32(nTableCount) );
+ aNfCount.SetMax( MAXTAB - rDoc.GetTableCount() + 1 );
+
+ if(nTableCount==1)
+ {
+ String aName;
+ rDoc.CreateValidTabName( aName );
+ aEdName.SetText( aName );
+ }
+ else
+ {
+ String aName=aFlTable.GetText();
+ aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM("..."));
+ aEdName.SetText( aName );
+ aFtName.Disable();
+ aEdName.Disable();
+ }
+
+ bool bShared = ( rViewData.GetDocShell() ? rViewData.GetDocShell()->IsDocShared() : false );
+
+ if ( !bFromFile || bShared )
+ {
+ aBtnNew.Check();
+ SetNewTable_Impl();
+ if ( bShared )
+ {
+ aBtnFromFile.Disable();
+ }
+ }
+ else
+ {
+ aBtnFromFile.Check();
+ SetFromTo_Impl();
+
+ aBrowseTimer.SetTimeoutHdl( LINK( this, ScInsertTableDlg, BrowseTimeoutHdl ) );
+ aBrowseTimer.SetTimeout( 200 );
+ }
+}
+
+//------------------------------------------------------------------------
+
+#if ENABLE_LAYOUT
+#undef ModalDialog
+#define ModalDialog Dialog
+#endif /* ENABLE_LAYOUT */
+
+short __EXPORT ScInsertTableDlg::Execute()
+{
+ // set Parent of DocumentInserter and Doc-Manager
+ Window* pOldDefParent = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( LAYOUT_THIS_WINDOW (this) );
+
+ if ( aBtnFromFile.IsChecked() )
+ aBrowseTimer.Start();
+
+ short nRet = ModalDialog::Execute();
+ Application::SetDefDialogParent( pOldDefParent );
+ return nRet;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::SetNewTable_Impl()
+{
+ if (aBtnNew.IsChecked() )
+ {
+ aNfCount .Enable();
+ aFtCount .Enable();
+ aLbTables .Disable();
+ aFtPath .Disable();
+ aBtnBrowse .Disable();
+ aBtnLink .Disable();
+
+ if(nTableCount==1)
+ {
+ aEdName.Enable();
+ aFtName.Enable();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::SetFromTo_Impl()
+{
+ if (aBtnFromFile.IsChecked() )
+ {
+ aEdName .Disable();
+ aFtName .Disable();
+ aFtCount .Disable();
+ aNfCount .Disable();
+ aLbTables .Enable();
+ aFtPath .Enable();
+ aBtnBrowse .Enable();
+ aBtnLink .Enable();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::FillTables_Impl( ScDocument* pSrcDoc )
+{
+ aLbTables.SetUpdateMode( FALSE );
+ aLbTables.Clear();
+
+ if ( pSrcDoc )
+ {
+ SCTAB nCount = pSrcDoc->GetTableCount();
+ String aName;
+
+ for ( SCTAB i=0; i<nCount; i++ )
+ {
+ pSrcDoc->GetName( i, aName );
+ aLbTables.InsertEntry( aName );
+ }
+ }
+
+ aLbTables.SetUpdateMode( TRUE );
+
+ if(aLbTables.GetEntryCount()==1)
+ aLbTables.SelectEntryPos(0);
+}
+
+//------------------------------------------------------------------------
+
+const String* ScInsertTableDlg::GetFirstTable( USHORT* pN )
+{
+ const String* pStr = NULL;
+
+ if ( aBtnNew.IsChecked() )
+ {
+ aStrCurSelTable = aEdName.GetText();
+ pStr = &aStrCurSelTable;
+ }
+ else if ( nSelTabIndex < aLbTables.GetSelectEntryCount() )
+ {
+ aStrCurSelTable = aLbTables.GetSelectEntry( 0 );
+ pStr = &aStrCurSelTable;
+ if ( pN )
+ *pN = aLbTables.GetSelectEntryPos( 0 );
+ nSelTabIndex = 1;
+ }
+
+ return pStr;
+}
+
+//------------------------------------------------------------------------
+
+const String* ScInsertTableDlg::GetNextTable( USHORT* pN )
+{
+ const String* pStr = NULL;
+
+ if ( !aBtnNew.IsChecked() && nSelTabIndex < aLbTables.GetSelectEntryCount() )
+ {
+ aStrCurSelTable = aLbTables.GetSelectEntry( nSelTabIndex );
+ pStr = &aStrCurSelTable;
+ if ( pN )
+ *pN = aLbTables.GetSelectEntryPos( nSelTabIndex );
+ nSelTabIndex++;
+ }
+
+ return pStr;
+}
+
+
+//------------------------------------------------------------------------
+// Handler:
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertTableDlg, CountHdl_Impl, NumericField*, EMPTYARG )
+{
+ nTableCount = static_cast<SCTAB>(aNfCount.GetValue());
+ if ( nTableCount==1)
+ {
+ String aName;
+ rDoc.CreateValidTabName( aName );
+ aEdName.SetText( aName );
+ aFtName.Enable();
+ aEdName.Enable();
+ }
+ else
+ {
+ String aName=aFlTable.GetText();
+ aName.AppendAscii(RTL_CONSTASCII_STRINGPARAM("..."));
+ aEdName.SetText( aName );
+ aFtName.Disable();
+ aEdName.Disable();
+ }
+
+ DoEnable_Impl();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( ScInsertTableDlg, ChoiceHdl_Impl, RadioButton*, EMPTYARG )
+{
+ if ( aBtnNew.IsChecked() )
+ SetNewTable_Impl();
+ else
+ SetFromTo_Impl();
+
+ DoEnable_Impl();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertTableDlg, BrowseHdl_Impl, PushButton*, EMPTYARG )
+{
+ if ( pDocInserter )
+ delete pDocInserter;
+ pDocInserter = new ::sfx2::DocumentInserter(
+ 0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ) );
+ pDocInserter->StartExecuteModal( LINK( this, ScInsertTableDlg, DialogClosedHdl ) );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScInsertTableDlg, SelectHdl_Impl, MultiListBox*, EMPTYARG )
+{
+ DoEnable_Impl();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+void ScInsertTableDlg::DoEnable_Impl()
+{
+ if ( aBtnNew.IsChecked() || ( pDocShTables && aLbTables.GetSelectEntryCount() ) )
+ aBtnOk.Enable();
+ else
+ aBtnOk.Disable();
+}
+
+IMPL_LINK( ScInsertTableDlg, DoEnterHdl, PushButton*, EMPTYARG )
+{
+ if(nTableCount > 1 || rDoc.ValidTabName(aEdName.GetText()))
+ {
+ EndDialog(RET_OK);
+ }
+ else
+ {
+ String aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME ) );
+ (void)ErrorBox( this,WinBits( WB_OK | WB_DEF_OK ),aErrMsg).Execute();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScInsertTableDlg, BrowseTimeoutHdl, Timer*, EMPTYARG )
+{
+ bMustClose = true;
+ BrowseHdl_Impl( &aBtnBrowse );
+ return 0;
+}
+
+IMPL_LINK( ScInsertTableDlg, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ if ( ERRCODE_NONE == _pFileDlg->GetError() )
+ {
+ SfxMedium* pMed = pDocInserter->CreateMedium();
+ if ( pMed )
+ {
+ // ERRCTX_SFX_OPENDOC -> "Fehler beim Laden des Dokumentes"
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+
+ if ( pDocShTables )
+ pDocShTables->DoClose(); // delete passiert beim Zuweisen auf die Ref
+
+ pMed->UseInteractionHandler( TRUE ); // to enable the filter options dialog
+
+ pDocShTables = new ScDocShell;
+ aDocShTablesRef = pDocShTables;
+
+ Pointer aOldPtr( GetPointer() );
+ SetPointer( Pointer( POINTER_WAIT ) );
+ pDocShTables->DoLoad( pMed );
+ SetPointer( aOldPtr );
+
+ ULONG nErr = pDocShTables->GetErrorCode();
+ if ( nErr )
+ ErrorHandler::HandleError( nErr ); // auch Warnings
+
+ if ( !pDocShTables->GetError() ) // nur Errors
+ {
+ FillTables_Impl( pDocShTables->GetDocument() );
+ aFtPath.SetText( pDocShTables->GetTitle( SFX_TITLE_FULLNAME ) );
+ }
+ else
+ {
+ pDocShTables->DoClose();
+ aDocShTablesRef.Clear();
+ pDocShTables = NULL;
+
+ FillTables_Impl( NULL );
+ aFtPath.SetText( EMPTY_STRING );
+ }
+ }
+
+ DoEnable_Impl();
+ }
+ else if ( bMustClose )
+ // execute slot FID_INS_TABLE_EXT and cancel file dialog
+ EndDialog( RET_CANCEL );
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/instbdlg.src b/sc/source/ui/miscdlgs/instbdlg.src
new file mode 100644
index 000000000000..375dfc24fa4a
--- /dev/null
+++ b/sc/source/ui/miscdlgs/instbdlg.src
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "instbdlg.hrc"
+ModalDialog RID_SCDLG_INSERT_TABLE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 274 , 190 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Tabelle einfügen : Tabelle einf³gen */
+ Text [ en-US ] = "Insert Sheet" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 218 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 218 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 218 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine FL_POSITION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 206 , 8 ) ;
+ Text [ en-US ] = "Position" ;
+ };
+ RadioButton RB_BEFORE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "B~efore current sheet" ;
+ };
+ RadioButton RB_BEHIND
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~After current sheet" ;
+ };
+ FixedLine FL_TABLE
+ {
+ Pos = MAP_APPFONT ( 6 , 44 ) ;
+ Size = MAP_APPFONT ( 206 , 8 ) ;
+ Text [ en-US ] = "Sheet" ;
+ };
+ RadioButton RB_NEW
+ {
+ Pos = MAP_APPFONT ( 12 , 55 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ Text [ en-US ] = "~New sheet" ;
+ };
+ FixedText FT_COUNT
+ {
+ Pos = MAP_APPFONT ( 20 , 68 ) ;
+ Size = MAP_APPFONT ( 52 , 8 ) ;
+ Text [ en-US ] = "N~o. of sheets" ;
+ };
+ NumericField NF_COUNT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 66 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 1 ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 256 ;
+ };
+ FixedText FT_NAME
+ {
+ Pos = MAP_APPFONT ( 20 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Na~me";
+ };
+ Edit ED_TABNAME
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 82 ) ;
+ Size = MAP_APPFONT ( 137 , 12 ) ;
+ };
+ RadioButton RB_FROMFILE
+ {
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 197 , 10 ) ;
+ Text [ en-US ] = "~From file" ;
+ };
+ MultiListBox LB_TABLES
+ {
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 113 ) ;
+ Size = MAP_APPFONT ( 123 , 59 ) ;
+ AutoHScroll = TRUE ;
+ };
+ PushButton BTN_BROWSE
+ {
+ Pos = MAP_APPFONT ( 149 , 113 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "~Browse..." ;
+ };
+ CheckBox CB_LINK
+ {
+ Pos = MAP_APPFONT ( 149 , 131 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ver~knüpfen : Ver~kn³pfen */
+ Text [ en-US ] = "Lin~k" ;
+ };
+ FixedText FT_PATH
+ {
+ Pos = MAP_APPFONT ( 20 , 176 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/miscdlgs/lbseldlg.cxx b/sc/source/ui/miscdlgs/lbseldlg.cxx
new file mode 100644
index 000000000000..f2a9a73c7538
--- /dev/null
+++ b/sc/source/ui/miscdlgs/lbseldlg.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "lbseldlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScSelEntryDlg::ScSelEntryDlg( Window* pParent,
+ USHORT nResId,
+ const String& aTitle,
+ const String& aLbTitle,
+ List& aEntryList ) :
+ ModalDialog ( pParent, ScResId( nResId ) ),
+ //
+ aFlLbTitle ( this, ScResId( FL_ENTRYLIST ) ),
+ aLb ( this, ScResId( LB_ENTRYLIST ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ SetText( aTitle );
+ aFlLbTitle.SetText( aLbTitle );
+ aLb.Clear();
+ aLb.SetDoubleClickHdl( LINK( this, ScSelEntryDlg, DblClkHdl ) );
+
+ void* pListEntry = aEntryList.First();
+ while ( pListEntry )
+ {
+ aLb.InsertEntry( *((String*)pListEntry ) );
+ pListEntry = aEntryList.Next();
+ }
+
+ if ( aLb.GetEntryCount() > 0 )
+ aLb.SelectEntryPos( 0 );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+String ScSelEntryDlg::GetSelectEntry() const
+{
+ return aLb.GetSelectEntry();
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScSelEntryDlg, DblClkHdl, void *, EMPTYARG )
+{
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScSelEntryDlg, DblClkHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+__EXPORT ScSelEntryDlg::~ScSelEntryDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/linkarea.cxx b/sc/source/ui/miscdlgs/linkarea.cxx
new file mode 100644
index 000000000000..f6aea5799417
--- /dev/null
+++ b/sc/source/ui/miscdlgs/linkarea.cxx
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docinsert.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <vcl/waitobj.hxx>
+
+#include "linkarea.hxx"
+#include "linkarea.hrc"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "rangeutl.hxx"
+#include "docsh.hxx"
+#include "tablink.hxx"
+
+//==================================================================
+
+ScLinkedAreaDlg::ScLinkedAreaDlg( Window* pParent ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_LINKAREA ) ),
+ //
+ aFlLocation ( this, ScResId( FL_LOCATION ) ),
+ aCbUrl ( this, ScResId( CB_URL ) ),
+ aBtnBrowse ( this, ScResId( BTN_BROWSE ) ),
+ aTxtHint ( this, ScResId( FT_HINT ) ),
+ aFtRanges ( this, ScResId( FT_RANGES ) ),
+ aLbRanges ( this, ScResId( LB_RANGES ) ),
+ aBtnReload ( this, ScResId( BTN_RELOAD ) ),
+ aNfDelay ( this, ScResId( NF_DELAY ) ),
+ aFtSeconds ( this, ScResId( FT_SECONDS ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ pSourceShell( NULL ),
+ pDocInserter( NULL )
+
+{
+ FreeResource();
+
+ aCbUrl.SetHelpId( HID_SCDLG_LINKAREAURL ); // SvtURLBox ctor always sets SID_OPENURL
+ aCbUrl.SetSelectHdl( LINK( this, ScLinkedAreaDlg, FileHdl ) );
+ aBtnBrowse.SetClickHdl( LINK( this, ScLinkedAreaDlg, BrowseHdl ) );
+ aLbRanges.SetSelectHdl( LINK( this, ScLinkedAreaDlg, RangeHdl ) );
+ aBtnReload.SetClickHdl( LINK( this, ScLinkedAreaDlg, ReloadHdl ) );
+ UpdateEnable();
+}
+
+ScLinkedAreaDlg::~ScLinkedAreaDlg()
+{
+ // pSourceShell is deleted by aSourceRef
+}
+
+short ScLinkedAreaDlg::Execute()
+{
+ // set parent for file dialog or filter options
+
+ Window* pOldDefParent = Application::GetDefDialogParent();
+ Application::SetDefDialogParent( this );
+
+ short nRet = ModalDialog::Execute();
+
+ Application::SetDefDialogParent( pOldDefParent );
+
+ return nRet;
+}
+
+#define FILTERNAME_HTML "HTML (StarCalc)"
+#define FILTERNAME_QUERY "calc_HTML_WebQuery"
+
+IMPL_LINK( ScLinkedAreaDlg, BrowseHdl, PushButton*, EMPTYARG )
+{
+ if ( !pDocInserter )
+ pDocInserter = new sfx2::DocumentInserter(
+ 0, String::CreateFromAscii( ScDocShell::Factory().GetShortName() ) );
+ pDocInserter->StartExecuteModal( LINK( this, ScLinkedAreaDlg, DialogClosedHdl ) );
+ return 0;
+}
+
+IMPL_LINK( ScLinkedAreaDlg, FileHdl, ComboBox*, EMPTYARG )
+{
+ String aEntered = aCbUrl.GetURL();
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ if ( pMed->GetName() == aEntered )
+ {
+ // already loaded - nothing to do
+ return 0;
+ }
+ }
+
+ String aFilter;
+ String aOptions;
+ // get filter name by looking at the file content (bWithContent = TRUE)
+ // Break operation if any error occured inside.
+ if (!ScDocumentLoader::GetFilterName( aEntered, aFilter, aOptions, TRUE, TRUE ))
+ return 0;
+
+ // #i53241# replace HTML filter with DataQuery filter
+ if( aFilter.EqualsAscii( FILTERNAME_HTML ) )
+ aFilter.AssignAscii( FILTERNAME_QUERY );
+
+ LoadDocument( aEntered, aFilter, aOptions );
+
+ UpdateSourceRanges();
+ UpdateEnable();
+ return 0;
+}
+
+void ScLinkedAreaDlg::LoadDocument( const String& rFile, const String& rFilter, const String& rOptions )
+{
+ if ( pSourceShell )
+ {
+ // unload old document
+ pSourceShell->DoClose();
+ pSourceShell = NULL;
+ aSourceRef.Clear();
+ }
+
+ if ( rFile.Len() )
+ {
+ WaitObject aWait( this );
+
+ String aNewFilter = rFilter;
+ String aNewOptions = rOptions;
+
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, rFile );
+
+ ScDocumentLoader aLoader( rFile, aNewFilter, aNewOptions, 0, TRUE ); // with interaction
+ pSourceShell = aLoader.GetDocShell();
+ if ( pSourceShell )
+ {
+ ULONG nErr = pSourceShell->GetErrorCode();
+ if (nErr)
+ ErrorHandler::HandleError( nErr ); // including warnings
+
+ aSourceRef = pSourceShell;
+ aLoader.ReleaseDocRef(); // don't call DoClose in DocLoader dtor
+ }
+ }
+}
+
+void ScLinkedAreaDlg::InitFromOldLink( const String& rFile, const String& rFilter,
+ const String& rOptions, const String& rSource,
+ ULONG nRefresh )
+{
+ LoadDocument( rFile, rFilter, rOptions );
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ aCbUrl.SetText( pMed->GetName() );
+ }
+ else
+ aCbUrl.SetText( EMPTY_STRING );
+
+ UpdateSourceRanges();
+
+ xub_StrLen nRangeCount = rSource.GetTokenCount();
+ for ( xub_StrLen i=0; i<nRangeCount; i++ )
+ {
+ String aRange = rSource.GetToken(i);
+ aLbRanges.SelectEntry( aRange );
+ }
+
+ BOOL bDoRefresh = ( nRefresh != 0 );
+ aBtnReload.Check( bDoRefresh );
+ if (bDoRefresh)
+ aNfDelay.SetValue( nRefresh );
+
+ UpdateEnable();
+}
+
+IMPL_LINK( ScLinkedAreaDlg, RangeHdl, MultiListBox*, EMPTYARG )
+{
+ UpdateEnable();
+ return 0;
+}
+
+IMPL_LINK( ScLinkedAreaDlg, ReloadHdl, CheckBox*, EMPTYARG )
+{
+ UpdateEnable();
+ return 0;
+}
+
+IMPL_LINK( ScLinkedAreaDlg, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg )
+{
+ if ( _pFileDlg->GetError() != ERRCODE_NONE )
+ return 0;
+
+ SfxMedium* pMed = pDocInserter->CreateMedium();
+ if ( pMed )
+ {
+ WaitObject aWait( this );
+
+ // #92296# replace HTML filter with DataQuery filter
+ const String aHTMLFilterName( RTL_CONSTASCII_USTRINGPARAM( FILTERNAME_HTML ) );
+ const String aWebQFilterName( RTL_CONSTASCII_USTRINGPARAM( FILTERNAME_QUERY ) );
+
+ const SfxFilter* pFilter = pMed->GetFilter();
+ if( pFilter && (pFilter->GetFilterName() == aHTMLFilterName) )
+ {
+ const SfxFilter* pNewFilter =
+ ScDocShell::Factory().GetFilterContainer()->GetFilter4FilterName( aWebQFilterName );
+ if( pNewFilter )
+ pMed->SetFilter( pNewFilter );
+ }
+
+ // ERRCTX_SFX_OPENDOC -> "Fehler beim Laden des Dokumentes"
+ SfxErrorContext aEc( ERRCTX_SFX_OPENDOC, pMed->GetName() );
+
+ if (pSourceShell)
+ pSourceShell->DoClose(); // deleted when assigning aSourceRef
+
+ pMed->UseInteractionHandler( TRUE ); // to enable the filter options dialog
+
+ pSourceShell = new ScDocShell;
+ aSourceRef = pSourceShell;
+ pSourceShell->DoLoad( pMed );
+
+ ULONG nErr = pSourceShell->GetErrorCode();
+ if (nErr)
+ ErrorHandler::HandleError( nErr ); // including warnings
+
+ if ( !pSourceShell->GetError() ) // only errors
+ {
+ //aCbUrl.SetText( pSourceShell->GetTitle( SFX_TITLE_FULLNAME ) );
+ aCbUrl.SetText( pMed->GetName() );
+ }
+ else
+ {
+ pSourceShell->DoClose();
+ pSourceShell = NULL;
+ aSourceRef.Clear();
+
+ aCbUrl.SetText( EMPTY_STRING );
+ }
+ }
+
+ UpdateSourceRanges();
+ UpdateEnable();
+ return 0;
+}
+
+#undef FILTERNAME_HTML
+#undef FILTERNAME_QUERY
+
+void ScLinkedAreaDlg::UpdateSourceRanges()
+{
+ aLbRanges.SetUpdateMode( FALSE );
+
+ aLbRanges.Clear();
+ if ( pSourceShell )
+ {
+ ScAreaNameIterator aIter( pSourceShell->GetDocument() );
+ ScRange aDummy;
+ String aName;
+ while ( aIter.Next( aName, aDummy ) )
+ aLbRanges.InsertEntry( aName );
+ }
+
+ aLbRanges.SetUpdateMode( TRUE );
+
+ if ( aLbRanges.GetEntryCount() == 1 )
+ aLbRanges.SelectEntryPos(0);
+}
+
+void ScLinkedAreaDlg::UpdateEnable()
+{
+ BOOL bEnable = ( pSourceShell && aLbRanges.GetSelectEntryCount() );
+ aBtnOk.Enable( bEnable );
+
+ BOOL bReload = aBtnReload.IsChecked();
+ aNfDelay.Enable( bReload );
+ aFtSeconds.Enable( bReload );
+}
+
+String ScLinkedAreaDlg::GetURL()
+{
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ return pMed->GetName();
+ }
+ return EMPTY_STRING;
+}
+
+String ScLinkedAreaDlg::GetFilter()
+{
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ return pMed->GetFilter()->GetFilterName();
+ }
+ return EMPTY_STRING;
+}
+
+String ScLinkedAreaDlg::GetOptions()
+{
+ if (pSourceShell)
+ {
+ SfxMedium* pMed = pSourceShell->GetMedium();
+ return ScDocumentLoader::GetOptions( *pMed );
+ }
+ return EMPTY_STRING;
+}
+
+String ScLinkedAreaDlg::GetSource()
+{
+ String aSource;
+ USHORT nCount = aLbRanges.GetSelectEntryCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if (i > 0)
+ aSource.Append( (sal_Unicode) ';' );
+ aSource.Append( aLbRanges.GetSelectEntry( i ) );
+ }
+ return aSource;
+}
+
+ULONG ScLinkedAreaDlg::GetRefresh()
+{
+ if ( aBtnReload.IsChecked() )
+ return sal::static_int_cast<ULONG>( aNfDelay.GetValue() );
+ else
+ return 0; // disabled
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/linkarea.src b/sc/source/ui/miscdlgs/linkarea.src
new file mode 100644
index 000000000000..ec5e3d4b868d
--- /dev/null
+++ b/sc/source/ui/miscdlgs/linkarea.src
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "linkarea.hrc"
+
+ModalDialog RID_SCDLG_LINKAREA
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Size = MAP_APPFONT ( 274 , 190 ) ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 218 , 8 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 218 , 25 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 218 , 49 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine FL_LOCATION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 204 , 8 ) ;
+ Text [ en-US ] = "URL of ~external data source";
+ };
+ ComboBox CB_URL
+ {
+ Pos = MAP_APPFONT ( 12 , 15 ) ;
+ Size = MAP_APPFONT ( 174 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ PushButton BTN_BROWSE
+ {
+ Pos = MAP_APPFONT ( 190 , 14 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text = "~..." ;
+ };
+ FixedText FT_HINT
+ {
+ Pos = MAP_APPFONT ( 12 , 31 ) ;
+ Size = MAP_APPFONT ( 192 , 26 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "(Enter the URL of the source document in the local file system or Internet here.)";
+ };
+ FixedText FT_RANGES
+ {
+ Pos = MAP_APPFONT ( 6 , 62 ) ;
+ Size = MAP_APPFONT ( 198 , 8 ) ;
+ Text [ en-US ] = "~Available tables/ranges";
+ };
+ MultiListBox LB_RANGES
+ {
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 74 ) ;
+ Size = MAP_APPFONT ( 192 , 80 ) ;
+ AutoHScroll = TRUE ;
+ };
+ CheckBox BTN_RELOAD
+ {
+ Pos = MAP_APPFONT ( 12 , 168 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Update every";
+ };
+ NumericField NF_DELAY
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 113 , 166 ) ;
+ Size = MAP_APPFONT ( 32 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 99999 ;
+ Value = 60 ;
+ };
+ FixedText FT_SECONDS
+ {
+ Pos = MAP_APPFONT ( 149 , 168 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Text [ en-US ] = "seconds";
+ };
+ Text [ en-US ] = "External Data";
+};
+
diff --git a/sc/source/ui/miscdlgs/makefile.mk b/sc/source/ui/miscdlgs/makefile.mk
new file mode 100644
index 000000000000..115fc3aebe57
--- /dev/null
+++ b/sc/source/ui/miscdlgs/makefile.mk
@@ -0,0 +1,126 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=miscdlgs
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/datafdlg.obj \
+ $(SLO)$/delcldlg.obj \
+ $(SLO)$/inscldlg.obj \
+ $(SLO)$/delcodlg.obj \
+ $(SLO)$/inscodlg.obj \
+ $(SLO)$/strindlg.obj \
+ $(SLO)$/tabbgcolordlg.obj \
+ $(SLO)$/mtrindlg.obj \
+ $(SLO)$/lbseldlg.obj \
+ $(SLO)$/filldlg.obj \
+ $(SLO)$/autofmt.obj \
+ $(SLO)$/solvrdlg.obj \
+ $(SLO)$/optsolver.obj \
+ $(SLO)$/solveroptions.obj \
+ $(SLO)$/solverutil.obj \
+ $(SLO)$/mvtabdlg.obj \
+ $(SLO)$/groupdlg.obj \
+ $(SLO)$/tabopdlg.obj \
+ $(SLO)$/crdlg.obj \
+ $(SLO)$/namecrea.obj \
+ $(SLO)$/namepast.obj \
+ $(SLO)$/textdlgs.obj \
+ $(SLO)$/anyrefdg.obj \
+ $(SLO)$/crnrdlg.obj \
+ $(SLO)$/shtabdlg.obj \
+ $(SLO)$/instbdlg.obj \
+ $(SLO)$/acredlin.obj \
+ $(SLO)$/highred.obj \
+ $(SLO)$/simpref.obj \
+ $(SLO)$/redcom.obj \
+ $(SLO)$/linkarea.obj \
+ $(SLO)$/warnbox.obj \
+ $(SLO)$/scuiautofmt.obj \
+ $(SLO)$/conflictsdlg.obj \
+ $(SLO)$/sharedocdlg.obj \
+ $(SLO)$/protectiondlg.obj \
+ $(SLO)$/retypepassdlg.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/acredlin.obj \
+ $(SLO)$/conflictsdlg.obj \
+ $(SLO)$/sharedocdlg.obj \
+ $(SLO)$/optsolver.obj \
+ $(SLO)$/solveroptions.obj \
+ $(SLO)$/crnrdlg.obj \
+ $(SLO)$/solverutil.obj \
+ $(SLO)$/protectiondlg.obj \
+ $(SLO)$/retypepassdlg.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ instbdlg.src \
+ acredlin.src \
+ highred.src \
+ linkarea.src \
+ conflictsdlg.src \
+ sharedocdlg.src \
+ protectiondlg.src \
+ retypepassdlg.src
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/autofmt.obj \
+ $(SLO)$/solvrdlg.obj \
+ $(SLO)$/optsolver.obj \
+ $(SLO)$/solveroptions.obj \
+ $(SLO)$/solverutil.obj \
+ $(SLO)$/tabopdlg.obj \
+ $(SLO)$/anyrefdg.obj \
+ $(SLO)$/crnrdlg.obj \
+ $(SLO)$/acredlin.obj \
+ $(SLO)$/highred.obj \
+ $(SLO)$/simpref.obj \
+ $(SLO)$/redcom.obj \
+ $(SLO)$/warnbox.obj \
+ $(SLO)$/conflictsdlg.obj \
+ $(SLO)$/sharedocdlg.obj \
+ $(SLO)$/protectiondlg.obj \
+ $(SLO)$/retypepassdlg.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/miscdlgs/mtrindlg.cxx b/sc/source/ui/miscdlgs/mtrindlg.cxx
new file mode 100644
index 000000000000..510f5785fe83
--- /dev/null
+++ b/sc/source/ui/miscdlgs/mtrindlg.cxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "mtrindlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScMetricInputDlg::ScMetricInputDlg( Window* pParent,
+ USHORT nResId,
+ long nCurrent,
+ long nDefault,
+ FieldUnit eFUnit,
+ USHORT nDecimals,
+ long nMaximum,
+ long nMinimum,
+ long nFirst,
+ long nLast )
+
+ : ModalDialog ( pParent, ScResId( nResId ) ),
+ //
+ aFtEditTitle ( this, ScResId( FT_LABEL ) ),
+ aEdValue ( this, ScResId( ED_VALUE ) ),
+ aBtnDefVal ( this, ScResId( BTN_DEFVAL ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ //SetText( rTitle );
+ //
+ //aFtEditTitle.SetText( rEditTitle );
+ CalcPositions();
+ aBtnDefVal.SetClickHdl ( LINK( this, ScMetricInputDlg, SetDefValHdl ) );
+ aEdValue. SetModifyHdl( LINK( this, ScMetricInputDlg, ModifyHdl ) );
+
+ aEdValue.SetUnit ( eFUnit );
+ aEdValue.SetDecimalDigits ( nDecimals );
+ aEdValue.SetMax ( aEdValue.Normalize( nMaximum ), FUNIT_TWIP );
+ aEdValue.SetMin ( aEdValue.Normalize( nMinimum ), FUNIT_TWIP );
+ aEdValue.SetLast ( aEdValue.Normalize( nLast ), FUNIT_TWIP );
+ aEdValue.SetFirst ( aEdValue.Normalize( nFirst ), FUNIT_TWIP );
+ aEdValue.SetSpinSize ( aEdValue.Normalize( 1 ) / 10 );
+ aEdValue.SetValue ( aEdValue.Normalize( nDefault ), FUNIT_TWIP );
+ nDefaultValue = sal::static_int_cast<long>( aEdValue.GetValue() );
+ aEdValue.SetValue ( aEdValue.Normalize( nCurrent ), FUNIT_TWIP );
+ nCurrentValue = sal::static_int_cast<long>( aEdValue.GetValue() );
+ aBtnDefVal.Check( nCurrentValue == nDefaultValue );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScMetricInputDlg::~ScMetricInputDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+long ScMetricInputDlg::GetInputValue( FieldUnit eUnit ) const
+{
+/*
+ mit Nachkommastellen:
+
+ double nVal = aEdValue.GetValue( eUnit );
+ USHORT nDecs = aEdValue.GetDecimalDigits();
+ double nFactor = 0.0;
+
+ // static long ImpPower10( USHORT nDecs )
+ {
+ nFactor = 1.0;
+
+ for ( USHORT i=0; i < nDecs; i++ )
+ nFactor *= 10.0;
+ }
+
+ return nVal / nFactor;
+*/
+ // erstmal Nachkommastellen abschneiden - nich so doll...
+
+ return sal::static_int_cast<long>( aEdValue.Denormalize( aEdValue.GetValue( eUnit ) ) );
+}
+
+//------------------------------------------------------------------------
+
+void ScMetricInputDlg::CalcPositions()
+{
+ MapMode oldMode = GetMapMode();
+ SetMapMode( MAP_APPFONT );
+
+ Size aDlgSize = GetOutputSizePixel();
+ Size aFtSize = aFtEditTitle.GetSizePixel();
+ Point aNewPos;
+
+ aFtSize.Width() = aFtEditTitle.GetTextWidth(aFtEditTitle.GetText());
+ // #95990# add mnemonic char width to fixed text width
+ aFtSize.Width() += aFtEditTitle.GetTextWidth(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("(W)")));
+ aFtEditTitle.SetSizePixel( aFtSize );
+
+ aNewPos.Y() = aEdValue.GetPosPixel().Y();
+ aNewPos.X() = aFtEditTitle.GetPosPixel().X();
+ aNewPos.X() += aFtEditTitle.GetSizePixel().Width();
+ aNewPos.X() += LogicToPixel( Point(3,0) ).X();
+ aEdValue.SetPosPixel( aNewPos );
+
+ aNewPos.Y() = aBtnDefVal.GetPosPixel().Y();
+ aBtnDefVal.SetPosPixel( aNewPos );
+
+ aNewPos.Y() = aBtnOk.GetPosPixel().Y();
+ aNewPos.X() += aEdValue.GetSizePixel().Width();
+ aNewPos.X() += LogicToPixel( Point(6,0) ).X();
+ aBtnOk.SetPosPixel( aNewPos );
+ aNewPos.Y() = aBtnCancel.GetPosPixel().Y();
+ aBtnCancel.SetPosPixel( aNewPos );
+ aNewPos.Y() = aBtnHelp.GetPosPixel().Y();
+ aBtnHelp.SetPosPixel( aNewPos );
+
+ aNewPos.X() += aBtnOk.GetSizePixel().Width();
+ aNewPos.X() += LogicToPixel( Point(6,0) ).X();
+ aDlgSize.Width() = aNewPos.X();
+ SetOutputSizePixel( aDlgSize );
+
+ SetMapMode( oldMode );
+}
+
+//------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScMetricInputDlg, SetDefValHdl, CheckBox *, EMPTYARG )
+{
+ if ( aBtnDefVal.IsChecked() )
+ {
+ nCurrentValue = sal::static_int_cast<long>( aEdValue.GetValue() );
+ aEdValue.SetValue( nDefaultValue );
+ }
+ else
+ aEdValue.SetValue( nCurrentValue );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScMetricInputDlg, ModifyHdl, MetricField *, EMPTYARG )
+{
+ aBtnDefVal.Check( nDefaultValue == aEdValue.GetValue() );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScMetricInputDlg, ModifyHdl, MetricField *, EMPTYARG )
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/mvtabdlg.cxx b/sc/source/ui/miscdlgs/mvtabdlg.cxx
new file mode 100644
index 000000000000..a000b1dfd10c
--- /dev/null
+++ b/sc/source/ui/miscdlgs/mvtabdlg.cxx
@@ -0,0 +1,207 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "mvtabdlg.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "miscdlgs.hrc"
+#include "global.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef ModalDialog
+#define ModalDialog( parent, id ) Dialog( parent, "move-copy-sheet.xml", id )
+#endif /* ENABLE_LAYOUT */
+
+//==================================================================
+
+ScMoveTableDlg::ScMoveTableDlg( Window* pParent )
+
+ : ModalDialog ( pParent, ScResId( RID_SCDLG_MOVETAB ) ),
+ //
+ aFtDoc ( this, ScResId( FT_DEST ) ),
+ aLbDoc ( this, ScResId( LB_DEST ) ),
+ aFtTable ( this, ScResId( FT_INSERT ) ),
+ aLbTable ( this, ScResId( LB_INSERT ) ),
+ aBtnCopy ( this, ScResId( BTN_COPY ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ nDocument ( 0 ),
+ nTable ( 0 ),
+ bCopyTable ( FALSE )
+{
+#if ENABLE_LAYOUT
+#undef ScResId
+ SetHelpId (FID_TAB_MOVE);
+#endif /* ENABLE_LAYOUT */
+ Init();
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScMoveTableDlg::~ScMoveTableDlg()
+{
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScMoveTableDlg::GetSelectedDocument () const { return nDocument; }
+
+SCTAB ScMoveTableDlg::GetSelectedTable () const { return nTable; }
+
+BOOL ScMoveTableDlg::GetCopyTable () const { return bCopyTable; }
+
+void ScMoveTableDlg::SetCopyTable(BOOL bFlag)
+{
+ aBtnCopy.Check(bFlag);
+}
+void ScMoveTableDlg::EnableCopyTable(BOOL bFlag)
+{
+ if(bFlag)
+ aBtnCopy.Enable();
+ else
+ aBtnCopy.Disable();
+}
+
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScMoveTableDlg::Init()
+{
+ aBtnOk.SetClickHdl ( LINK( this, ScMoveTableDlg, OkHdl ) );
+ aLbDoc.SetSelectHdl ( LINK( this, ScMoveTableDlg, SelHdl ) );
+ aBtnCopy.Check( FALSE );
+ InitDocListBox();
+ SelHdl( &aLbDoc );
+}
+
+//------------------------------------------------------------------------
+
+void ScMoveTableDlg::InitDocListBox()
+{
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ ScDocShell* pScSh = NULL;
+ USHORT nSelPos = 0;
+ USHORT i = 0;
+
+ aLbDoc.Clear();
+ aLbDoc.SetUpdateMode( FALSE );
+
+ while ( pSh )
+ {
+ pScSh = PTR_CAST( ScDocShell, pSh );
+
+ if ( pScSh )
+ {
+ if ( pScSh == SfxObjectShell::Current() )
+ nSelPos = i;
+
+ aLbDoc.InsertEntry( pScSh->GetTitle(), i );
+ aLbDoc.SetEntryData( i, (void*)pScSh->GetDocument() );
+
+ i++;
+ }
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+
+ aLbDoc.SetUpdateMode( TRUE );
+ aLbDoc.InsertEntry( String( ScResId( STR_NEWDOC ) ) );
+ aLbDoc.SelectEntryPos( nSelPos );
+}
+
+
+//------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScMoveTableDlg, OkHdl, void *, EMPTYARG )
+{
+ USHORT nDocSel = aLbDoc.GetSelectEntryPos();
+ USHORT nDocLast = aLbDoc.GetEntryCount()-1;
+ USHORT nTabSel = aLbTable.GetSelectEntryPos();
+ USHORT nTabLast = aLbTable.GetEntryCount()-1;
+
+ nDocument = (nDocSel != nDocLast) ? nDocSel : SC_DOC_NEW;
+ nTable = (nTabSel != nTabLast) ? static_cast<SCTAB>(nTabSel) : SC_TAB_APPEND;
+ bCopyTable = aBtnCopy.IsChecked();
+ EndDialog( RET_OK );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScMoveTableDlg, SelHdl, ListBox *, pLb )
+{
+ if ( pLb == &aLbDoc )
+ {
+ ScDocument* pDoc = (ScDocument*)
+ aLbDoc.GetEntryData( aLbDoc.GetSelectEntryPos() );
+ SCTAB nLast = 0;
+ String aName;
+
+ aLbTable.Clear();
+ aLbTable.SetUpdateMode( FALSE );
+ if ( pDoc )
+ {
+ nLast = pDoc->GetTableCount()-1;
+ for ( SCTAB i=0; i<=nLast; i++ )
+ {
+ pDoc->GetName( i, aName );
+ aLbTable.InsertEntry( aName, static_cast<sal_uInt16>(i) );
+ }
+ }
+ aLbTable.InsertEntry( ScGlobal::GetRscString(STR_MOVE_TO_END) );
+ aLbTable.SetUpdateMode( TRUE );
+ aLbTable.SelectEntryPos( 0 );
+ }
+
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/namecrea.cxx b/sc/source/ui/miscdlgs/namecrea.cxx
new file mode 100644
index 000000000000..67e22dae7b1a
--- /dev/null
+++ b/sc/source/ui/miscdlgs/namecrea.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "namecrea.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScNameCreateDlg::ScNameCreateDlg( Window * pParent, USHORT nFlags )
+ : ModalDialog( pParent, ScResId(RID_SCDLG_NAMES_CREATE) ),
+ aFixedLine ( this, ScResId( FL_FRAME ) ),
+ aTopBox ( this, ScResId( BTN_TOP ) ),
+ aLeftBox ( this, ScResId( BTN_LEFT ) ),
+ aBottomBox ( this, ScResId( BTN_BOTTOM ) ),
+ aRightBox ( this, ScResId( BTN_RIGHT ) ),
+ aOKButton ( this, ScResId( BTN_OK ) ),
+ aCancelButton ( this, ScResId( BTN_CANCEL ) ),
+ aHelpButton ( this, ScResId( BTN_HELP ) )
+{
+ aTopBox.Check ( (nFlags & NAME_TOP) ? TRUE : FALSE );
+ aLeftBox.Check ( (nFlags & NAME_LEFT) ? TRUE : FALSE );
+ aBottomBox.Check( (nFlags & NAME_BOTTOM)? TRUE : FALSE );
+ aRightBox.Check ( (nFlags & NAME_RIGHT) ? TRUE : FALSE );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------
+
+USHORT ScNameCreateDlg::GetFlags() const
+{
+ USHORT nResult = 0;
+
+ nResult |= aTopBox.IsChecked() ? NAME_TOP: 0 ;
+ nResult |= aLeftBox.IsChecked() ? NAME_LEFT: 0 ;
+ nResult |= aBottomBox.IsChecked() ? NAME_BOTTOM: 0 ;
+ nResult |= aRightBox.IsChecked() ? NAME_RIGHT: 0 ;
+
+ return nResult;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/namepast.cxx b/sc/source/ui/miscdlgs/namepast.cxx
new file mode 100644
index 000000000000..543f3bd27005
--- /dev/null
+++ b/sc/source/ui/miscdlgs/namepast.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "namepast.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+#include "rangenam.hxx"
+
+
+//==================================================================
+
+ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, BOOL bInsList )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ),
+ aLabelText ( this, ScResId( FT_LABEL ) ),
+ aNameList ( this, ScResId( LB_ENTRYLIST ) ),
+ aOKButton ( this, ScResId( BTN_OK ) ),
+ aCancelButton ( this, ScResId( BTN_CANCEL ) ),
+ aHelpButton ( this, ScResId( BTN_HELP ) ),
+ aInsListButton ( this, ScResId( BTN_ADD ) )
+{
+ if( ! bInsList )
+ aInsListButton.Disable();
+
+ aInsListButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) );
+ aOKButton.SetClickHdl( LINK( this,ScNamePasteDlg,ButtonHdl) );
+ aNameList.SetSelectHdl( LINK( this,ScNamePasteDlg,ListSelHdl) );
+ aNameList.SetDoubleClickHdl( LINK( this,ScNamePasteDlg,ListDblClickHdl) );
+
+ USHORT nCnt = pList->GetCount();
+ String aText;
+
+ for( USHORT i=0 ; i<nCnt ; i++ )
+ {
+ ScRangeData* pData = (*pList)[ i ];
+
+ if( pData )
+ {
+ if ( !pData->HasType( RT_DATABASE )
+ && !pData->HasType( RT_SHARED ) )
+ {
+ pData->GetName( aText );
+ aNameList.InsertEntry( aText );
+ }
+ }
+ }
+
+ ListSelHdl( &aNameList );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
+{
+ if( pButton == &aInsListButton )
+ {
+ EndDialog( BTN_PASTE_LIST );
+ }
+ else if( pButton == &aOKButton )
+ {
+ EndDialog( BTN_PASTE_NAME );
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScNamePasteDlg, ListSelHdl, ListBox *, pListBox )
+{
+ if( pListBox == &aNameList )
+ {
+ if( aNameList.GetSelectEntryCount() )
+ aOKButton.Enable();
+ else
+ aOKButton.Disable();
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox )
+{
+ if( pListBox == &aNameList )
+ {
+ ButtonHdl( &aOKButton );
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNamePasteDlg, ListDblClickHdl, ListBox *, pListBox )
+
+//------------------------------------------------------------------
+
+String ScNamePasteDlg::GetSelectedName() const
+{
+ return aNameList.GetSelectEntry();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
new file mode 100644
index 000000000000..9dd2e84550ce
--- /dev/null
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -0,0 +1,1068 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "cell.hxx"
+#include "rangeutl.hxx"
+#include "scresid.hxx"
+#include "convuno.hxx"
+#include "unonames.hxx"
+#include "solveroptions.hxx"
+#include "solverutil.hxx"
+#include "optsolver.hrc"
+
+#include "optsolver.hxx"
+
+#include <com/sun/star/sheet/Solver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+
+using namespace com::sun::star;
+
+//----------------------------------------------------------------------------
+
+ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent )
+ : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ),
+ maFtProgress ( this, ScResId( FT_PROGRESS ) ),
+ maFtTime ( this, ScResId( FT_TIMELIMIT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maBtnOk.Enable(FALSE);
+ FreeResource();
+}
+
+ScSolverProgressDialog::~ScSolverProgressDialog()
+{
+}
+
+void ScSolverProgressDialog::HideTimeLimit()
+{
+ maFtTime.Hide();
+}
+
+void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
+{
+ String aOld = maFtTime.GetText();
+ String aNew = aOld.GetToken(0,'#');
+ aNew += String::CreateFromInt32( nSeconds );
+ aNew += aOld.GetToken(1,'#');
+ maFtTime.SetText( aNew );
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ),
+ maFtNoSolution ( this, ScResId( FT_NOSOLUTION ) ),
+ maFtErrorText ( this, ScResId( FT_ERRORTEXT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) )
+{
+ maFtErrorText.SetText( rErrorText );
+ FreeResource();
+}
+
+ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ),
+ maFtSuccess ( this, ScResId( FT_SUCCESS ) ),
+ maFtResult ( this, ScResId( FT_RESULT ) ),
+ maFtQuestion ( this, ScResId( FT_QUESTION ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ String aMessage = maFtResult.GetText();
+ aMessage.Append( (sal_Char) ' ' );
+ aMessage.Append( rSolution );
+ maFtResult.SetText( aMessage );
+ FreeResource();
+}
+
+ScSolverSuccessDialog::~ScSolverSuccessDialog()
+{
+}
+
+//----------------------------------------------------------------------------
+
+ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) :
+ formula::RefEdit( pParent, pParent, rResId )
+{
+}
+
+void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown )
+{
+ maCursorUpLink = rUp;
+ maCursorDownLink = rDown;
+}
+
+void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+ bool bUp = (aCode.GetCode() == KEY_UP);
+ bool bDown = (aCode.GetCode() == KEY_DOWN);
+ if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) )
+ {
+ if ( bUp )
+ maCursorUpLink.Call( this );
+ else
+ maCursorDownLink.Call( this );
+ }
+ else
+ formula::RefEdit::KeyInput( rKEvt );
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverSave::ScOptSolverSave( const String& rObjective, BOOL bMax, BOOL bMin, BOOL bValue,
+ const String& rTarget, const String& rVariable,
+ const std::vector<ScOptConditionRow>& rConditions,
+ const String& rEngine,
+ const uno::Sequence<beans::PropertyValue>& rProperties ) :
+ maObjective( rObjective ),
+ mbMax( bMax ),
+ mbMin( bMin ),
+ mbValue( bValue ),
+ maTarget( rTarget ),
+ maVariable( rVariable ),
+ maConditions( rConditions ),
+ maEngine( rEngine ),
+ maProperties( rProperties )
+{
+}
+
+//============================================================================
+// class ScOptSolverDlg
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocShell* pDocSh, ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ),
+ //
+ maFtObjectiveCell ( this, ScResId( FT_OBJECTIVECELL ) ),
+ maEdObjectiveCell ( this, this, ScResId( ED_OBJECTIVECELL ) ),
+ maRBObjectiveCell ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell, this ),
+ maFtDirection ( this, ScResId( FT_DIRECTION ) ),
+ maRbMax ( this, ScResId( RB_MAX ) ),
+ maRbMin ( this, ScResId( RB_MIN ) ),
+ maRbValue ( this, ScResId( RB_VALUE ) ),
+ maEdTargetValue ( this, this, ScResId( ED_TARGET ) ),
+ maRBTargetValue ( this, ScResId( IB_TARGET ), &maEdTargetValue, this ),
+ maFtVariableCells ( this, ScResId( FT_VARIABLECELLS ) ),
+ maEdVariableCells ( this, this, ScResId( ED_VARIABLECELLS ) ),
+ maRBVariableCells ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells, this),
+ maFlConditions ( this, ScResId( FL_CONDITIONS ) ),
+ maFtCellRef ( this, ScResId( FT_CELLREF ) ),
+ maEdLeft1 ( this, ScResId( ED_LEFT1 ) ),
+ maRBLeft1 ( this, ScResId( IB_LEFT1 ), &maEdLeft1, this ),
+ maFtOperator ( this, ScResId( FT_OPERATOR ) ),
+ maLbOp1 ( this, ScResId( LB_OP1 ) ),
+ maFtConstraint ( this, ScResId( FT_CONSTRAINT ) ),
+ maEdRight1 ( this, ScResId( ED_RIGHT1 ) ),
+ maRBRight1 ( this, ScResId( IB_RIGHT1 ), &maEdRight1, this ),
+ maBtnDel1 ( this, ScResId( IB_DELETE1 ) ),
+ maEdLeft2 ( this, ScResId( ED_LEFT2 ) ),
+ maRBLeft2 ( this, ScResId( IB_LEFT2 ), &maEdLeft2, this ),
+ maLbOp2 ( this, ScResId( LB_OP2 ) ),
+ maEdRight2 ( this, ScResId( ED_RIGHT2 ) ),
+ maRBRight2 ( this, ScResId( IB_RIGHT2 ), &maEdRight2, this ),
+ maBtnDel2 ( this, ScResId( IB_DELETE2 ) ),
+ maEdLeft3 ( this, ScResId( ED_LEFT3 ) ),
+ maRBLeft3 ( this, ScResId( IB_LEFT3 ), &maEdLeft3, this ),
+ maLbOp3 ( this, ScResId( LB_OP3 ) ),
+ maEdRight3 ( this, ScResId( ED_RIGHT3 ) ),
+ maRBRight3 ( this, ScResId( IB_RIGHT3 ), &maEdRight3, this ),
+ maBtnDel3 ( this, ScResId( IB_DELETE3 ) ),
+ maEdLeft4 ( this, ScResId( ED_LEFT4 ) ),
+ maRBLeft4 ( this, ScResId( IB_LEFT4 ), &maEdLeft4, this ),
+ maLbOp4 ( this, ScResId( LB_OP4 ) ),
+ maEdRight4 ( this, ScResId( ED_RIGHT4 ) ),
+ maRBRight4 ( this, ScResId( IB_RIGHT4 ), &maEdRight4, this ),
+ maBtnDel4 ( this, ScResId( IB_DELETE4 ) ),
+ maScrollBar ( this, ScResId( SB_SCROLL ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOpt ( this, ScResId( BTN_OPTIONS ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnCancel ( this, ScResId( BTN_CLOSE ) ),
+ maBtnSolve ( this, ScResId( BTN_SOLVE ) ),
+ maInputError ( ScResId( STR_INVALIDINPUT ) ),
+ maConditionError ( ScResId( STR_INVALIDCONDITION ) ),
+ //
+ mpDocShell ( pDocSh ),
+ mpDoc ( pDocSh->GetDocument() ),
+ mnCurTab ( aCursorPos.Tab() ),
+ mpEdActive ( NULL ),
+ mbDlgLostFocus ( false ),
+ nScrollPos ( 0 )
+{
+ mpLeftEdit[0] = &maEdLeft1;
+ mpLeftButton[0] = &maRBLeft1;
+ mpRightEdit[0] = &maEdRight1;
+ mpRightButton[0] = &maRBRight1;
+ mpOperator[0] = &maLbOp1;
+ mpDelButton[0] = &maBtnDel1;
+
+ mpLeftEdit[1] = &maEdLeft2;
+ mpLeftButton[1] = &maRBLeft2;
+ mpRightEdit[1] = &maEdRight2;
+ mpRightButton[1] = &maRBRight2;
+ mpOperator[1] = &maLbOp2;
+ mpDelButton[1] = &maBtnDel2;
+
+ mpLeftEdit[2] = &maEdLeft3;
+ mpLeftButton[2] = &maRBLeft3;
+ mpRightEdit[2] = &maEdRight3;
+ mpRightButton[2] = &maRBRight3;
+ mpOperator[2] = &maLbOp3;
+ mpDelButton[2] = &maBtnDel3;
+
+ mpLeftEdit[3] = &maEdLeft4;
+ mpLeftButton[3] = &maRBLeft4;
+ mpRightEdit[3] = &maEdRight4;
+ mpRightButton[3] = &maRBRight4;
+ mpOperator[3] = &maLbOp4;
+ mpDelButton[3] = &maBtnDel4;
+
+ Init( aCursorPos );
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+ScOptSolverDlg::~ScOptSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
+{
+ // Get the "Delete Rows" commandimagelist images from sfx instead of
+ // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged)
+
+ rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
+ aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) );
+ uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
+ Image aDelNm = ::GetImage( xFrame, aSlotURL, FALSE, FALSE );
+ Image aDelHC = ::GetImage( xFrame, aSlotURL, FALSE, TRUE ); // high contrast
+
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpDelButton[nRow]->SetModeImage( aDelNm, BMP_COLOR_NORMAL );
+ mpDelButton[nRow]->SetModeImage( aDelHC, BMP_COLOR_HIGHCONTRAST );
+ }
+
+ maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+ maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl );
+ maEdObjectiveCell.SetGetFocusHdl( aLink );
+ maRBObjectiveCell.SetGetFocusHdl( aLink );
+ maEdTargetValue.SetGetFocusHdl( aLink );
+ maRBTargetValue.SetGetFocusHdl( aLink );
+ maEdVariableCells.SetGetFocusHdl( aLink );
+ maRBVariableCells.SetGetFocusHdl( aLink );
+ maRbValue.SetGetFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetGetFocusHdl( aLink );
+ mpLeftButton[nRow]->SetGetFocusHdl( aLink );
+ mpRightEdit[nRow]->SetGetFocusHdl( aLink );
+ mpRightButton[nRow]->SetGetFocusHdl( aLink );
+ mpOperator[nRow]->SetGetFocusHdl( aLink );
+ }
+
+ aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl );
+ maEdObjectiveCell.SetLoseFocusHdl( aLink );
+ maRBObjectiveCell.SetLoseFocusHdl( aLink );
+ maEdTargetValue. SetLoseFocusHdl( aLink );
+ maRBTargetValue. SetLoseFocusHdl( aLink );
+ maEdVariableCells.SetLoseFocusHdl( aLink );
+ maRBVariableCells.SetLoseFocusHdl( aLink );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpLeftButton[nRow]->SetLoseFocusHdl( aLink );
+ mpRightEdit[nRow]->SetLoseFocusHdl( aLink );
+ mpRightButton[nRow]->SetLoseFocusHdl( aLink );
+ }
+
+ Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl );
+ Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl );
+ Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl );
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
+ mpLeftEdit[nRow]->SetModifyHdl( aCondModify );
+ mpRightEdit[nRow]->SetModifyHdl( aCondModify );
+ mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) );
+ mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) );
+ }
+ maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) );
+
+ maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+ maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
+
+ maScrollBar.SetPageSize( EDIT_ROW_COUNT );
+ maScrollBar.SetVisibleSize( EDIT_ROW_COUNT );
+ maScrollBar.SetLineSize( 1 );
+ // Range is set in ShowConditions
+
+ // get available solver implementations
+ //! sort by descriptions?
+ ScSolverUtil::GetImplementations( maImplNames, maDescriptions );
+ sal_Int32 nImplCount = maImplNames.getLength();
+
+ const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData();
+ if ( pOldData )
+ {
+ maEdObjectiveCell.SetRefString( pOldData->GetObjective() );
+ maRbMax.Check( pOldData->GetMax() );
+ maRbMin.Check( pOldData->GetMin() );
+ maRbValue.Check( pOldData->GetValue() );
+ maEdTargetValue.SetRefString( pOldData->GetTarget() );
+ maEdVariableCells.SetRefString( pOldData->GetVariable() );
+ maConditions = pOldData->GetConditions();
+ maEngine = pOldData->GetEngine();
+ maProperties = pOldData->GetProperties();
+ }
+ else
+ {
+ maRbMax.Check();
+ String aCursorStr;
+ if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) )
+ rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() );
+ maEdObjectiveCell.SetRefString( aCursorStr );
+ if ( nImplCount > 0 )
+ maEngine = maImplNames[0]; // use first implementation
+ }
+ ShowConditions();
+
+ maEdObjectiveCell.GrabFocus();
+ mpEdActive = &maEdObjectiveCell;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ReadConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+ aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText();
+ aRowEntry.aRightStr = mpRightEdit[nRow]->GetText();
+ aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos();
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() )
+ maConditions.resize( nVecPos + 1 );
+
+ if ( nVecPos < (long)maConditions.size() )
+ maConditions[nVecPos] = aRowEntry;
+
+ // remove default entries at the end
+ size_t nSize = maConditions.size();
+ while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() )
+ --nSize;
+ maConditions.resize( nSize );
+ }
+}
+
+void ScOptSolverDlg::ShowConditions()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ ScOptConditionRow aRowEntry;
+
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ aRowEntry = maConditions[nVecPos];
+
+ mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr );
+ mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr );
+ mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator );
+ }
+
+ // allow to scroll one page behind the visible or stored rows
+ long nVisible = nScrollPos + EDIT_ROW_COUNT;
+ long nMax = std::max( nVisible, (long) maConditions.size() );
+ maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) );
+ maScrollBar.SetThumbPos( nScrollPos );
+
+ EnableButtons();
+}
+
+void ScOptSolverDlg::EnableButtons()
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ long nVecPos = nScrollPos + nRow;
+ mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::Close()
+{
+ return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetActive()
+{
+ if ( mbDlgLostFocus )
+ {
+ mbDlgLostFocus = false;
+ if( mpEdActive )
+ mpEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( mpEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(mpEdActive);
+
+ // "target"/"value": single cell
+ bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue );
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ ScRange aNewRef( rRef );
+ if ( bSingle )
+ aNewRef.aEnd = aAdr;
+
+ String aName;
+ if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) ) // named range: show name
+ aStr = aName;
+ else // format cell/range reference
+ {
+ USHORT nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D;
+ if ( bSingle )
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ else
+ rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() );
+ }
+
+ // variable cells can be several ranges, so only the selection is replaced
+ if ( mpEdActive == &maEdVariableCells )
+ {
+ String aVal = mpEdActive->GetText();
+ Selection aSel = mpEdActive->GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ mpEdActive->SetRefString( aVal );
+ mpEdActive->SetSelection( aNewSel );
+ }
+ else
+ mpEdActive->SetRefString( aStr );
+
+ ReadConditions();
+ EnableButtons();
+
+ // select "Value of" if a ref is input into "target" edit
+ if ( mpEdActive == &maEdTargetValue )
+ maRbValue.Check();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScOptSolverDlg::IsRefInputMode() const
+{
+ return mpEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
+ {
+ bool bSolve = ( pBtn == &maBtnSolve );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+
+ bool bClose = true;
+ if ( bSolve )
+ bClose = CallSolver();
+
+ if ( bClose )
+ {
+ // Close: write dialog settings to DocShell for subsequent calls
+ ReadConditions();
+ ScOptSolverSave aSave(
+ maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(),
+ maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties );
+ mpDocShell->SetSolverSaveData( aSave );
+ Close();
+ }
+ else
+ {
+ // no solution -> dialog is kept open
+ SetDispatcherLock( TRUE );
+ }
+ }
+ else if ( pBtn == &maBtnOpt )
+ {
+ //! move options dialog to UI lib?
+ ScSolverOptionsDialog* pOptDlg =
+ new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties );
+ if ( pOptDlg->Execute() == RET_OK )
+ {
+ maEngine = pOptDlg->GetEngine();
+ maProperties = pOptDlg->GetProperties();
+ }
+ delete pOptDlg;
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ mpEdActive = NULL;
+
+ if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell )
+ pEdit = mpEdActive = &maEdObjectiveCell;
+ else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue )
+ pEdit = mpEdActive = &maEdTargetValue;
+ else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells )
+ pEdit = mpEdActive = &maEdVariableCells;
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ {
+ if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] )
+ pEdit = mpEdActive = mpLeftEdit[nRow];
+ else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] )
+ pEdit = mpEdActive = mpRightEdit[nRow];
+ else if( pCtrl == mpOperator[nRow] ) // focus on "operator" list box
+ mpEdActive = mpRightEdit[nRow]; // use right edit for ref input, but don't change selection
+ }
+ if( pCtrl == &maRbValue ) // focus on "Value of" radio button
+ mpEdActive = &maEdTargetValue; // use value edit for ref input, but don't change selection
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ mbDlgLostFocus = !IsActive();
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn )
+{
+ for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
+ if( pBtn == mpDelButton[nRow] )
+ {
+ BOOL bHadFocus = pBtn->HasFocus();
+
+ ReadConditions();
+ long nVecPos = nScrollPos + nRow;
+ if ( nVecPos < (long)maConditions.size() )
+ {
+ maConditions.erase( maConditions.begin() + nVecPos );
+ ShowConditions();
+
+ if ( bHadFocus && !pBtn->IsEnabled() )
+ {
+ // If the button is disabled, focus would normally move to the next control,
+ // (left edit of the next row). Move it to left edit of this row instead.
+
+ mpEdActive = mpLeftEdit[nRow];
+ mpEdActive->GrabFocus();
+ }
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScOptSolverDlg, TargetModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the target edit:
+ // select "Value of" if something is input into the edit
+ if ( maEdTargetValue.GetText().Len() )
+ maRbValue.Check();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CondModifyHdl, Edit*, EMPTYARG )
+{
+ // modify handler for the condition edits, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, SelectHdl, ListBox*, EMPTYARG )
+{
+ // select handler for operator list boxes, just to enable/disable "delete" buttons
+ ReadConditions();
+ EnableButtons();
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ ReadConditions();
+ nScrollPos = maScrollBar.GetThumbPos();
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] )
+ {
+ if ( nScrollPos > 0 )
+ {
+ ReadConditions();
+ --nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow ) // second row or below: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow-1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow-1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit )
+{
+ if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] )
+ {
+ //! limit scroll position?
+ ReadConditions();
+ ++nScrollPos;
+ ShowConditions();
+ if( mpEdActive )
+ mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ else
+ {
+ formula::RefEdit* pFocus = NULL;
+ for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow ) // before last row: move focus
+ {
+ if ( pEdit == mpLeftEdit[nRow] )
+ pFocus = mpLeftEdit[nRow+1];
+ else if ( pEdit == mpRightEdit[nRow] )
+ pFocus = mpRightEdit[nRow+1];
+ }
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+void ScOptSolverDlg::ShowError( bool bCondition, formula::RefEdit* pFocus )
+{
+ String aMessage = bCondition ? maConditionError : maInputError;
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute();
+ if (pFocus)
+ {
+ mpEdActive = pFocus;
+ pFocus->GrabFocus();
+ }
+}
+
+//----------------------------------------------------------------------------
+
+bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange )
+{
+ ScRangeUtil aRangeUtil;
+ ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0);
+ USHORT nFlags = rRange.ParseAny( rInput, mpDoc, aDetails );
+ if ( nFlags & SCA_VALID )
+ {
+ if ( (nFlags & SCA_TAB_3D) == 0 )
+ rRange.aStart.SetTab( mnCurTab );
+ if ( (nFlags & SCA_TAB2_3D) == 0 )
+ rRange.aEnd.SetTab( rRange.aStart.Tab() );
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+ }
+ else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) )
+ return ( bAllowRange || rRange.aStart == rRange.aEnd );
+
+ return false; // not recognized
+}
+
+bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout )
+{
+ bool bFound = false;
+
+ if ( !maProperties.getLength() )
+ maProperties = ScSolverUtil::GetDefaults( maEngine ); // get property defaults from component
+
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ if ( rValue.Name.equalsAscii( SC_UNONAME_TIMEOUT ) )
+ bFound = ( rValue.Value >>= rTimeout );
+ }
+ return bFound;
+}
+
+bool ScOptSolverDlg::CallSolver() // return true -> close dialog after calling
+{
+ // show progress dialog
+
+ ScSolverProgressDialog aProgress( this );
+ sal_Int32 nTimeout = 0;
+ if ( FindTimeout( nTimeout ) )
+ aProgress.SetTimeLimit( nTimeout );
+ else
+ aProgress.HideTimeLimit();
+ aProgress.Show();
+ aProgress.Update();
+ aProgress.Sync();
+ // try to make sure the progress dialog is painted before continuing
+ Application::Reschedule(true);
+
+ // collect solver parameters
+
+ ReadConditions();
+
+ uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY );
+
+ ScRange aObjRange;
+ if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) )
+ {
+ ShowError( false, &maEdObjectiveCell );
+ return false;
+ }
+ table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() );
+
+ // "changing cells" can be several ranges
+ ScRangeList aVarRanges;
+ if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) )
+ {
+ ShowError( false, &maEdVariableCells );
+ return false;
+ }
+ uno::Sequence<table::CellAddress> aVariables;
+ sal_Int32 nVarPos = 0;
+ ULONG nRangeCount = aVarRanges.Count();
+ for (ULONG nRangePos=0; nRangePos<nRangeCount; ++nRangePos)
+ {
+ ScRange aRange(*aVarRanges.GetObject(nRangePos));
+ aRange.Justify();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
+ ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
+ aVariables.realloc( nVarPos + nAdd );
+
+ for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
+ }
+
+ uno::Sequence<sheet::SolverConstraint> aConstraints;
+ sal_Int32 nConstrPos = 0;
+ for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin();
+ aConstrIter != maConditions.end(); ++aConstrIter )
+ {
+ if ( aConstrIter->aLeftStr.Len() )
+ {
+ sheet::SolverConstraint aConstraint;
+ // order of list box entries must match enum values
+ aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator);
+
+ ScRange aLeftRange;
+ if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+
+ bool bIsRange = false;
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) )
+ {
+ if ( aRightRange.aStart == aRightRange.aEnd )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() &&
+ aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() )
+ bIsRange = true; // same size as "left" range, resolve into single cells
+ else
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER &&
+ aConstraint.Operator != sheet::SolverConstraintOperator_BINARY )
+ {
+ ShowError( true, NULL );
+ return false;
+ }
+ }
+
+ // resolve into single cells
+
+ sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) *
+ ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 );
+ aConstraints.realloc( nConstrPos + nAdd );
+
+ for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow)
+ for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol)
+ {
+ aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow );
+ if ( bIsRange )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ),
+ aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) );
+
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+ }
+ }
+
+ sal_Bool bMaximize = maRbMax.IsChecked();
+ if ( maRbValue.IsChecked() )
+ {
+ // handle "value of" with an additional constraint (and then minimize)
+
+ sheet::SolverConstraint aConstraint;
+ aConstraint.Left = aObjective;
+ aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;
+
+ String aValStr = maEdTargetValue.GetText();
+ ScRange aRightRange;
+ if ( ParseRef( aRightRange, aValStr, false ) )
+ aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
+ aRightRange.aStart.Col(), aRightRange.aStart.Row() );
+ else
+ {
+ sal_uInt32 nFormat = 0; //! explicit language?
+ double fValue = 0.0;
+ if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
+ aConstraint.Right <<= fValue;
+ else
+ {
+ ShowError( false, &maEdTargetValue );
+ return false;
+ }
+ }
+
+ aConstraints.realloc( nConstrPos + 1 );
+ aConstraints[nConstrPos++] = aConstraint;
+ }
+
+ // copy old document values
+
+ sal_Int32 nVarCount = aVariables.getLength();
+ uno::Sequence<double> aOldValues;
+ aOldValues.realloc( nVarCount );
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aOldValues[nVarPos] = mpDoc->GetValue( aCellPos );
+ }
+
+ // create and initialize solver
+
+ uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine );
+ DBG_ASSERT( xSolver.is(), "can't get solver component" );
+ if ( !xSolver.is() )
+ return false;
+
+ xSolver->setDocument( xDocument );
+ xSolver->setObjective( aObjective );
+ xSolver->setVariables( aVariables );
+ xSolver->setConstraints( aConstraints );
+ xSolver->setMaximize( bMaximize );
+
+ // set options
+ uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
+ if ( xOptProp.is() )
+ {
+ sal_Int32 nPropCount = maProperties.getLength();
+ for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp)
+ {
+ const beans::PropertyValue& rValue = maProperties[nProp];
+ try
+ {
+ xOptProp->setPropertyValue( rValue.Name, rValue.Value );
+ }
+ catch ( uno::Exception & )
+ {
+ DBG_ERRORFILE("Exception in solver option property");
+ }
+ }
+ }
+
+ xSolver->solve();
+ sal_Bool bSuccess = xSolver->getSuccess();
+
+ aProgress.Hide();
+ bool bClose = false;
+ bool bRestore = true; // restore old values unless a solution is accepted
+ if ( bSuccess )
+ {
+ // put solution into document so it is visible when asking
+ uno::Sequence<double> aSolution = xSolver->getSolution();
+ if ( aSolution.getLength() == nVarCount )
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+ //! else error?
+
+ // take formatted result from document (result value from component is ignored)
+ String aResultStr;
+ mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr );
+ ScSolverSuccessDialog aDialog( this, aResultStr );
+ if ( aDialog.Execute() == RET_OK )
+ {
+ // keep results and close dialog
+ bRestore = false;
+ bClose = true;
+ }
+ }
+ else
+ {
+ rtl::OUString aError;
+ uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
+ if ( xDesc.is() )
+ aError = xDesc->getStatusDescription(); // error description from component
+ ScSolverNoSolutionDialog aDialog( this, aError );
+ aDialog.Execute();
+ }
+
+ if ( bRestore ) // restore old values
+ {
+ mpDocShell->LockPaint();
+ ScDocFunc aFunc(*mpDocShell);
+ for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
+ {
+ ScAddress aCellPos;
+ ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
+ aFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), TRUE );
+ }
+ mpDocShell->UnlockPaint();
+ }
+
+ return bClose;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/protectiondlg.cxx b/sc/source/ui/miscdlgs/protectiondlg.cxx
new file mode 100644
index 000000000000..87185fdc75e2
--- /dev/null
+++ b/sc/source/ui/miscdlgs/protectiondlg.cxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "protectiondlg.hxx"
+#include "protectiondlg.hrc"
+#include "scresid.hxx"
+#include "tabprotection.hxx"
+
+#include <sal/macros.h>
+#include <vcl/msgbox.hxx>
+
+
+// The order must match that of the list box.
+static const ScTableProtection::Option aOptions[] = {
+ ScTableProtection::SELECT_LOCKED_CELLS,
+ ScTableProtection::SELECT_UNLOCKED_CELLS,
+};
+static const USHORT nOptionCount = SAL_N_ELEMENTS(aOptions);
+
+
+ScTableProtectionDlg::ScTableProtectionDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_TABPROTECTION)),
+
+ maBtnProtect (this, ScResId(BTN_PROTECT)),
+ maPassword1Text (this, ScResId(FT_PASSWORD1)),
+ maPassword1Edit (this, ScResId(ED_PASSWORD1)),
+ maPassword2Text (this, ScResId(FT_PASSWORD2)),
+ maPassword2Edit (this, ScResId(ED_PASSWORD2)),
+ maOptionsLine (this, ScResId(FL_OPTIONS)),
+ maOptionsText (this, ScResId(FT_OPTIONS)),
+ maOptionsListBox(this, ScResId(CLB_OPTIONS)),
+
+ maBtnOk (this, ScResId(BTN_OK)),
+ maBtnCancel (this, ScResId(BTN_CANCEL)),
+ maBtnHelp (this, ScResId(BTN_HELP)),
+
+ maSelectLockedCells(ScResId(ST_SELECT_LOCKED_CELLS)),
+ maSelectUnlockedCells(ScResId(ST_SELECT_UNLOCKED_CELLS))
+{
+ Init();
+ FreeResource();
+}
+
+ScTableProtectionDlg::~ScTableProtectionDlg()
+{
+}
+
+short ScTableProtectionDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+void ScTableProtectionDlg::SetDialogData(const ScTableProtection& rData)
+{
+ for (USHORT i = 0; i < nOptionCount; ++i)
+ maOptionsListBox.CheckEntryPos(i, rData.isOptionEnabled(aOptions[i]));
+}
+
+void ScTableProtectionDlg::WriteData(ScTableProtection& rData) const
+{
+ rData.setProtected(maBtnProtect.IsChecked());
+
+ // We assume that the two password texts match.
+ rData.setPassword(maPassword1Edit.GetText());
+
+ for (USHORT i = 0; i < nOptionCount; ++i)
+ rData.setOption(aOptions[i], maOptionsListBox.IsChecked(i));
+}
+
+void ScTableProtectionDlg::Init()
+{
+ Link aLink = LINK( this, ScTableProtectionDlg, CheckBoxHdl );
+ maBtnProtect.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScTableProtectionDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScTableProtectionDlg, PasswordModifyHdl );
+ maPassword1Edit.SetModifyHdl(aLink);
+ maPassword2Edit.SetModifyHdl(aLink);
+
+ maOptionsListBox.SetUpdateMode(false);
+ maOptionsListBox.Clear();
+
+ maOptionsListBox.InsertEntry(maSelectLockedCells);
+ maOptionsListBox.InsertEntry(maSelectUnlockedCells);
+
+ maOptionsListBox.CheckEntryPos(0, true);
+ maOptionsListBox.CheckEntryPos(1, true);
+
+ maOptionsListBox.SetUpdateMode(true);
+
+ // Set the default state of the dialog.
+ maBtnProtect.Check(true);
+ maPassword1Edit.GrabFocus();
+}
+
+void ScTableProtectionDlg::EnableOptionalWidgets(bool bEnable)
+{
+ maPassword1Text.Enable(bEnable);
+ maPassword1Edit.Enable(bEnable);
+ maPassword2Text.Enable(bEnable);
+ maPassword2Edit.Enable(bEnable);
+ maOptionsLine.Enable(bEnable);
+ maOptionsText.Enable(bEnable);
+
+ maOptionsListBox.Enable(bEnable);
+ maOptionsListBox.Invalidate();
+}
+
+IMPL_LINK( ScTableProtectionDlg, CheckBoxHdl, CheckBox*, pBtn )
+{
+ if (pBtn == &maBtnProtect)
+ {
+ bool bChecked = maBtnProtect.IsChecked();
+ EnableOptionalWidgets(bChecked);
+ maBtnOk.Enable(bChecked);
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScTableProtectionDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScTableProtectionDlg, PasswordModifyHdl, Edit*, EMPTYARG )
+{
+ String aPass1 = maPassword1Edit.GetText();
+ String aPass2 = maPassword2Edit.GetText();
+ maBtnOk.Enable(aPass1.Equals(aPass2));
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/protectiondlg.src b/sc/source/ui/miscdlgs/protectiondlg.src
new file mode 100644
index 000000000000..34ad4063de57
--- /dev/null
+++ b/sc/source/ui/miscdlgs/protectiondlg.src
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "protectiondlg.hrc"
+
+ModalDialog RID_SCDLG_TABPROTECTION
+{
+ Text [ en-US ] = "Protect Sheet" ;
+ Size = MAP_APPFONT ( 220 , 135 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 164 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 164 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 164 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+
+ CheckBox BTN_PROTECT
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 150 , 10 );
+
+ Text [ en-US ] = "P~rotect this sheet and the contents of locked cells" ;
+ };
+
+ FixedText FT_PASSWORD1
+ {
+ Pos = MAP_APPFONT ( 11, 23 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Password" ;
+ };
+
+ Edit ED_PASSWORD1
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 56, 22 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ FixedText FT_PASSWORD2
+ {
+ Pos = MAP_APPFONT ( 11, 40 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Confirm" ;
+ };
+
+ Edit ED_PASSWORD2
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 56, 39 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6, 60 );
+ Size = MAP_APPFONT ( 150, 8 );
+
+ Text [ en-US ] = "Options";
+ };
+
+ FixedText FT_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 11, 74 );
+ Size = MAP_APPFONT ( 140, 8 );
+
+ Text [ en-US ] = "Allow all users of this sheet to:";
+ };
+
+ Control CLB_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 11, 85 );
+ Size = MAP_APPFONT ( 140, 40 );
+ Border = TRUE ;
+ TabStop = TRUE ;
+ };
+
+ String ST_SELECT_LOCKED_CELLS
+ {
+ Text [ en-US ] = "Select locked cells";
+ };
+
+ String ST_SELECT_UNLOCKED_CELLS
+ {
+ Text [ en-US ] = "Select unlocked cells";
+ };
+};
diff --git a/sc/source/ui/miscdlgs/redcom.cxx b/sc/source/ui/miscdlgs/redcom.cxx
new file mode 100644
index 000000000000..82e2578a5c65
--- /dev/null
+++ b/sc/source/ui/miscdlgs/redcom.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <vcl/msgbox.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "redcom.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+//------------------------------------------------------------------------
+
+ScRedComDialog::ScRedComDialog( Window* pParent, const SfxItemSet& rCoreSet,
+ ScDocShell *pShell,ScChangeAction *pAction,BOOL bPrevNext)
+{
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg = pFact->CreateSvxPostItDialog( pParent, rCoreSet, bPrevNext, TRUE );
+ DBG_ASSERT(pDlg, "Dialog creation failed!");
+ pDocShell=pShell;
+ pDlg->DontChangeAuthor();
+ pDlg->HideAuthor();
+
+ pDlg->SetPrevHdl(LINK( this, ScRedComDialog, PrevHdl));
+ pDlg->SetNextHdl(LINK( this, ScRedComDialog, NextHdl));
+
+ ReInit(pAction);
+ }
+}
+
+ScRedComDialog::~ScRedComDialog()
+{
+ delete pDlg;
+}
+
+ScChangeAction *ScRedComDialog::FindPrev(ScChangeAction *pAction)
+{
+ if(pAction!=NULL && pDocShell !=NULL)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
+
+ pAction=pAction->GetPrev();
+
+ while(pAction!=NULL)
+ {
+ if( pAction->GetState()==SC_CAS_VIRGIN &&
+ pAction->IsDialogRoot() &&
+ ScViewUtil::IsActionShown(*pAction,*pSettings,*pDoc)) break;
+
+ pAction=pAction->GetPrev();
+ }
+ }
+ return pAction;
+}
+
+ScChangeAction *ScRedComDialog::FindNext(ScChangeAction *pAction)
+{
+ if(pAction!=NULL && pDocShell !=NULL)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
+
+ pAction=pAction->GetNext();
+
+ while(pAction!=NULL)
+ {
+ if( pAction->GetState()==SC_CAS_VIRGIN &&
+ pAction->IsDialogRoot() &&
+ ScViewUtil::IsActionShown(*pAction,*pSettings,*pDoc)) break;
+
+ pAction=pAction->GetNext();
+ }
+ }
+ return pAction;
+}
+
+void ScRedComDialog::ReInit(ScChangeAction *pAction)
+{
+ pChangeAction=pAction;
+ if(pChangeAction!=NULL && pDocShell !=NULL)
+ {
+ String aTitle;
+ pChangeAction->GetDescription( aTitle, pDocShell->GetDocument());
+ pDlg->SetText(aTitle);
+ aComment=pChangeAction->GetComment();
+
+ BOOL bNext=FindNext(pChangeAction)!=NULL;
+ BOOL bPrev=FindPrev(pChangeAction)!=NULL;
+ pDlg->EnableTravel(bNext,bPrev);
+
+ String aAuthor = pChangeAction->GetUser();
+
+ DateTime aDT = pChangeAction->GetDateTime();
+ String aDate = ScGlobal::pLocaleData->getDate( aDT );
+ aDate += ' ';
+ aDate += ScGlobal::pLocaleData->getTime( aDT, FALSE, FALSE );
+
+ pDlg->ShowLastAuthor(aAuthor, aDate);
+ pDlg->SetNote(aComment);
+ }
+}
+
+short ScRedComDialog::Execute()
+{
+ short nRet=pDlg->Execute();
+
+ if(nRet== RET_OK )
+ {
+ if ( pDocShell!=NULL && pDlg->GetNote() != aComment )
+ pDocShell->SetChangeComment( pChangeAction, pDlg->GetNote());
+ }
+
+ return nRet;
+}
+
+void ScRedComDialog::SelectCell()
+{
+ if(pChangeAction!=NULL)
+ {
+ const ScChangeAction* pAction=pChangeAction;
+ const ScBigRange& rRange = pAction->GetBigRange();
+
+ if(rRange.IsValid(pDocShell->GetDocument()))
+ {
+ ScViewData* pViewData=pDocShell->GetViewData();
+ ScRange aRef=rRange.MakeRange();
+ ScTabView* pTabView=pViewData->GetView();
+ pTabView->MarkRange(aRef);
+ }
+ }
+}
+
+IMPL_LINK(ScRedComDialog, PrevHdl, AbstractSvxPostItDialog*, pDlgP )
+{
+ if (pDocShell!=NULL && pDlgP->GetNote() != aComment )
+ pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
+
+ ReInit(FindPrev(pChangeAction));
+ SelectCell();
+
+ return 0;
+}
+
+IMPL_LINK(ScRedComDialog, NextHdl, AbstractSvxPostItDialog*, pDlgP )
+{
+ if ( pDocShell!=NULL && pDlgP->GetNote() != aComment )
+ pDocShell->SetChangeComment( pChangeAction, pDlgP->GetNote());
+
+ ReInit(FindNext(pChangeAction));
+ SelectCell();
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.cxx b/sc/source/ui/miscdlgs/retypepassdlg.cxx
new file mode 100644
index 000000000000..36aaa92ef0f2
--- /dev/null
+++ b/sc/source/ui/miscdlgs/retypepassdlg.cxx
@@ -0,0 +1,547 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "retypepassdlg.hxx"
+#include "retypepassdlg.hrc"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "tabprotection.hxx"
+
+#include <stdio.h>
+
+#include <vcl/msgbox.hxx>
+
+ScRetypePassDlg::ScRetypePassDlg(Window* pParent) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_RETYPEPASS)),
+
+ maBtnOk (this, ScResId(BTN_OK)),
+ maBtnCancel (this, ScResId(BTN_CANCEL)),
+ maBtnHelp (this, ScResId(BTN_HELP)),
+
+ maTextDescription(this, ScResId(FT_DESC)),
+ maLineDocument(this, ScResId(FL_DOCUMENT)),
+ maTextDocStatus(this, ScResId(FT_DOCSTATUS)),
+ maBtnRetypeDoc(this, ScResId(BTN_RETYPE_DOC)),
+
+ maLineSheet(this, ScResId(FL_SHEET)),
+ maTextSheetName1(this, ScResId(FT_SHEETNAME1)),
+ maTextSheetStatus1(this, ScResId(FT_SHEETSTATUS1)),
+ maBtnRetypeSheet1(this, ScResId(BTN_RETYPE_SHEET1)),
+
+ maTextSheetName2(this, ScResId(FT_SHEETNAME2)),
+ maTextSheetStatus2(this, ScResId(FT_SHEETSTATUS2)),
+ maBtnRetypeSheet2(this, ScResId(BTN_RETYPE_SHEET2)),
+
+ maTextSheetName3(this, ScResId(FT_SHEETNAME3)),
+ maTextSheetStatus3(this, ScResId(FT_SHEETSTATUS3)),
+ maBtnRetypeSheet3(this, ScResId(BTN_RETYPE_SHEET3)),
+
+ maTextSheetName4(this, ScResId(FT_SHEETNAME4)),
+ maTextSheetStatus4(this, ScResId(FT_SHEETSTATUS4)),
+ maBtnRetypeSheet4(this, ScResId(BTN_RETYPE_SHEET4)),
+
+ maScrollBar (this, ScResId(SB_SCROLL)),
+
+ maTextNotProtected(ScResId(STR_NOT_PROTECTED)),
+ maTextNotPassProtected(ScResId(STR_NOT_PASS_PROTECTED)),
+ maTextHashBad(ScResId(STR_HASH_BAD)),
+ maTextHashGood(ScResId(STR_HASH_GOOD)),
+ maTextHashRegen(ScResId(STR_HASH_REGENERATED)),
+
+ mpDocItem(static_cast<ScDocProtection*>(NULL)),
+ mnCurScrollPos(0),
+ meDesiredHash(PASSHASH_SHA1)
+{
+ Init();
+}
+
+ScRetypePassDlg::~ScRetypePassDlg()
+{
+}
+
+short ScRetypePassDlg::Execute()
+{
+ PopulateDialog();
+ CheckHashStatus();
+ return ModalDialog::Execute();
+}
+
+void ScRetypePassDlg::SetDataFromDocument(const ScDocument& rDoc)
+{
+ const ScDocProtection* pDocProtect = rDoc.GetDocProtection();
+ if (pDocProtect && pDocProtect->isProtected())
+ mpDocItem.reset(new ScDocProtection(*pDocProtect));
+
+ SCTAB nTabCount = rDoc.GetTableCount();
+ maTableItems.reserve(nTabCount);
+ for (SCTAB i = 0; i < nTabCount; ++i)
+ {
+ TableItem aTabItem;
+ rDoc.GetName(i, aTabItem.maName);
+
+ const ScTableProtection* pTabProtect = rDoc.GetTabProtection(i);
+ if (pTabProtect && pTabProtect->isProtected())
+ aTabItem.mpProtect.reset(new ScTableProtection(*pTabProtect));
+
+ maTableItems.push_back(aTabItem);
+ }
+}
+
+void ScRetypePassDlg::SetDesiredHash(ScPasswordHash eHash)
+{
+ meDesiredHash = eHash;
+}
+
+void ScRetypePassDlg::WriteNewDataToDocument(ScDocument& rDoc) const
+{
+ if (mpDocItem.get())
+ rDoc.SetDocProtection(mpDocItem.get());
+
+ size_t nTabCount = static_cast<size_t>(rDoc.GetTableCount());
+ size_t n = maTableItems.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ if (i >= nTabCount)
+ break;
+
+ ScTableProtection* pTabProtect = maTableItems[i].mpProtect.get();
+ if (pTabProtect)
+ rDoc.SetTabProtection(static_cast<SCTAB>(i), pTabProtect);
+ }
+}
+
+void ScRetypePassDlg::Init()
+{
+ Link aLink = LINK( this, ScRetypePassDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScRetypePassDlg, RetypeBtnHdl );
+ maBtnRetypeDoc.SetClickHdl(aLink);
+ maBtnRetypeSheet1.SetClickHdl(aLink);
+ maBtnRetypeSheet2.SetClickHdl(aLink);
+ maBtnRetypeSheet3.SetClickHdl(aLink);
+ maBtnRetypeSheet4.SetClickHdl(aLink);
+
+ maTextDocStatus.SetText(maTextNotProtected);
+ maTextSheetStatus1.SetText(maTextNotProtected);
+ maTextSheetStatus2.SetText(maTextNotProtected);
+ maTextSheetStatus3.SetText(maTextNotProtected);
+ maTextSheetStatus4.SetText(maTextNotProtected);
+ maBtnRetypeDoc.Disable();
+
+ // Make all sheet rows invisible.
+
+ maTextSheetName1.Show(false);
+ maTextSheetStatus1.Show(false);
+ maBtnRetypeSheet1.Show(false);
+ maBtnRetypeSheet1.Disable();
+
+ maTextSheetName2.Show(false);
+ maTextSheetStatus2.Show(false);
+ maBtnRetypeSheet2.Show(false);
+ maBtnRetypeSheet2.Disable();
+
+ maTextSheetName3.Show(false);
+ maTextSheetStatus3.Show(false);
+ maBtnRetypeSheet3.Show(false);
+ maBtnRetypeSheet3.Disable();
+
+ maTextSheetName4.Show(false);
+ maTextSheetStatus4.Show(false);
+ maBtnRetypeSheet4.Show(false);
+ maBtnRetypeSheet4.Disable();
+
+ maScrollBar.Show(false);
+
+ maScrollBar.SetEndScrollHdl( LINK( this, ScRetypePassDlg, ScrollHdl ) );
+ maScrollBar.SetScrollHdl( LINK( this, ScRetypePassDlg, ScrollHdl ) );
+
+ maScrollBar.SetPageSize(4);
+ maScrollBar.SetVisibleSize(4);
+ maScrollBar.SetLineSize(1);
+}
+
+void ScRetypePassDlg::PopulateDialog()
+{
+ // Document protection first.
+ SetDocData();
+
+ // Sheet protection next. We're only interested in the first 4 sheets
+ // (or less).
+ size_t n = maTableItems.size();
+ for (size_t i = 0; i < n && i < 4; ++i)
+ SetTableData(i, static_cast< SCTAB >( i ));
+
+ if (n > 4)
+ {
+ maScrollBar.Show(true);
+ maScrollBar.SetRange(Range(0, n));
+ }
+}
+
+void ScRetypePassDlg::SetDocData()
+{
+ bool bBtnEnabled = false;
+ if (mpDocItem.get() && mpDocItem->isProtected())
+ {
+ if (mpDocItem->isPasswordEmpty())
+ maTextDocStatus.SetText(maTextNotPassProtected);
+ else if (mpDocItem->hasPasswordHash(meDesiredHash))
+ maTextDocStatus.SetText(maTextHashGood);
+ else
+ {
+ // incompatible hash
+ maTextDocStatus.SetText(maTextHashBad);
+ bBtnEnabled = true;
+ }
+ }
+ maBtnRetypeDoc.Enable(bBtnEnabled);
+}
+
+void ScRetypePassDlg::SetTableData(size_t nRowPos, SCTAB nTab)
+{
+ if (nRowPos >= 4)
+ return;
+
+ FixedText* pName = NULL;
+ FixedText* pStatus = NULL;
+ PushButton* pBtn = NULL;
+ switch (nRowPos)
+ {
+ case 0:
+ pName = &maTextSheetName1;
+ pStatus = &maTextSheetStatus1;
+ pBtn = &maBtnRetypeSheet1;
+ break;
+ case 1:
+ pName = &maTextSheetName2;
+ pStatus = &maTextSheetStatus2;
+ pBtn = &maBtnRetypeSheet2;
+ break;
+ case 2:
+ pName = &maTextSheetName3;
+ pStatus = &maTextSheetStatus3;
+ pBtn = &maBtnRetypeSheet3;
+ break;
+ case 3:
+ pName = &maTextSheetName4;
+ pStatus = &maTextSheetStatus4;
+ pBtn = &maBtnRetypeSheet4;
+ break;
+ default:
+ return;
+ }
+
+ bool bBtnEnabled = false;
+ pName->SetText(maTableItems[nTab].maName);
+ pName->Show(true);
+ const ScTableProtection* pTabProtect = maTableItems[nTab].mpProtect.get();
+ if (pTabProtect && pTabProtect->isProtected())
+ {
+ if (pTabProtect->isPasswordEmpty())
+ pStatus->SetText(maTextNotPassProtected);
+ else if (pTabProtect->hasPasswordHash(meDesiredHash))
+ pStatus->SetText(maTextHashGood);
+ else
+ {
+ // incompatible hash
+ pStatus->SetText(maTextHashBad);
+ bBtnEnabled = true;
+ }
+ }
+ else
+ pStatus->SetText(maTextNotProtected);
+
+ pStatus->Show(true);
+ pBtn->Show(true);
+ pBtn->Enable(bBtnEnabled);
+}
+
+void ScRetypePassDlg::ResetTableRows()
+{
+ long nScrollPos = maScrollBar.GetThumbPos();
+ mnCurScrollPos = nScrollPos < 0 ? 0 : nScrollPos;
+ size_t nRowCount = maTableItems.size() - nScrollPos;
+ for (size_t i = 0; i < nRowCount; ++i)
+ SetTableData(i, static_cast< SCTAB >( i + nScrollPos ));
+}
+
+bool lcl_IsInGoodStatus(ScPassHashProtectable* pProtected, ScPasswordHash eDesiredHash)
+{
+ if (!pProtected || !pProtected->isProtected())
+ // Not protected.
+ return true;
+
+ if (pProtected->isPasswordEmpty())
+ return true;
+
+ if (pProtected->hasPasswordHash(eDesiredHash))
+ return true;
+
+ return false;
+}
+
+void ScRetypePassDlg::CheckHashStatus()
+{
+ do
+ {
+ if (!lcl_IsInGoodStatus(mpDocItem.get(), meDesiredHash))
+ break;
+
+ bool bStatusGood = true;
+ size_t nTabCount = maTableItems.size();
+ for (size_t i = 0; i < nTabCount && bStatusGood; ++i)
+ {
+ if (!lcl_IsInGoodStatus(maTableItems[i].mpProtect.get(), meDesiredHash))
+ bStatusGood = false;
+ }
+ if (!bStatusGood)
+ break;
+
+ maBtnOk.Enable();
+ return;
+ }
+ while (false);
+
+ maBtnOk.Disable();
+}
+
+IMPL_LINK( ScRetypePassDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassDlg, RetypeBtnHdl, PushButton*, pBtn )
+{
+ ScPassHashProtectable* pProtected = NULL;
+ if (pBtn == &maBtnRetypeDoc)
+ {
+ // document protection.
+ pProtected = mpDocItem.get();
+ }
+ else
+ {
+ // sheet protection.
+ size_t nTabPos = mnCurScrollPos;
+ if (pBtn == &maBtnRetypeSheet2)
+ nTabPos += 1;
+ else if (pBtn == &maBtnRetypeSheet3)
+ nTabPos += 2;
+ else if (pBtn == &maBtnRetypeSheet4)
+ nTabPos += 3;
+ else if (pBtn != &maBtnRetypeSheet1)
+ // This should never happen !
+ return 0;
+
+ if (nTabPos >= maTableItems.size())
+ // Likewise, this should never happen !
+ return 0;
+
+ pProtected = maTableItems[nTabPos].mpProtect.get();
+ }
+
+ if (!pProtected)
+ // What the ... !?
+ return 0;
+
+ ScRetypePassInputDlg aDlg(this, pProtected);
+ if (aDlg.Execute() == RET_OK)
+ {
+ // OK is pressed. Update the protected item.
+ if (aDlg.IsRemovePassword())
+ {
+ // Remove password from this item.
+ pProtected->setPassword(String());
+ }
+ else
+ {
+ // Set a new password.
+ String aNewPass = aDlg.GetNewPassword();
+ pProtected->setPassword(aNewPass);
+ }
+
+ SetDocData();
+ ResetTableRows();
+ CheckHashStatus();
+ }
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassDlg, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ ResetTableRows();
+ return 0;
+}
+
+// ============================================================================
+
+ScRetypePassInputDlg::ScRetypePassInputDlg(Window* pParent, ScPassHashProtectable* pProtected) :
+ ModalDialog(pParent, ScResId(RID_SCDLG_RETYPEPASS_INPUT)),
+
+ maBtnOk (this, ScResId(BTN_OK)),
+ maBtnCancel (this, ScResId(BTN_CANCEL)),
+ maBtnHelp (this, ScResId(BTN_HELP)),
+
+ maBtnRetypePassword(this, ScResId(BTN_RETYPE_PASSWORD)),
+
+ maPassword1Text (this, ScResId(FT_PASSWORD1)),
+ maPassword1Edit (this, ScResId(ED_PASSWORD1)),
+ maPassword2Text (this, ScResId(FT_PASSWORD2)),
+ maPassword2Edit (this, ScResId(ED_PASSWORD2)),
+ maBtnMatchOldPass(this, ScResId(BTN_MATCH_OLD_PASSWORD)),
+
+ maBtnRemovePassword(this, ScResId(BTN_REMOVE_PASSWORD)),
+
+ mpProtected(pProtected)
+{
+ Init();
+}
+
+ScRetypePassInputDlg::~ScRetypePassInputDlg()
+{
+}
+
+short ScRetypePassInputDlg::Execute()
+{
+ return ModalDialog::Execute();
+}
+
+bool ScRetypePassInputDlg::IsRemovePassword() const
+{
+ return maBtnRemovePassword.IsChecked();
+}
+
+String ScRetypePassInputDlg::GetNewPassword() const
+{
+ return maPassword1Edit.GetText();
+}
+
+void ScRetypePassInputDlg::Init()
+{
+ Link aLink = LINK( this, ScRetypePassInputDlg, OKHdl );
+ maBtnOk.SetClickHdl(aLink);
+ aLink = LINK( this, ScRetypePassInputDlg, RadioBtnHdl );
+ maBtnRetypePassword.SetClickHdl(aLink);
+ maBtnRemovePassword.SetClickHdl(aLink);
+ aLink = LINK( this, ScRetypePassInputDlg, CheckBoxHdl );
+ maBtnMatchOldPass.SetClickHdl(aLink);
+ aLink = LINK( this, ScRetypePassInputDlg, PasswordModifyHdl );
+ maPassword1Edit.SetModifyHdl(aLink);
+ maPassword2Edit.SetModifyHdl(aLink);
+
+ maBtnOk.Disable();
+ maBtnRetypePassword.Check(true);
+ maBtnMatchOldPass.Check(true);
+ maPassword1Edit.GrabFocus();
+}
+
+void ScRetypePassInputDlg::CheckPasswordInput()
+{
+ String aPass1 = maPassword1Edit.GetText();
+ String aPass2 = maPassword2Edit.GetText();
+
+ if (!aPass1.Len() || !aPass2.Len())
+ {
+ // Empty password is not allowed.
+ maBtnOk.Disable();
+ return;
+ }
+
+ if (!aPass1.Equals(aPass2))
+ {
+ // The two passwords differ.
+ maBtnOk.Disable();
+ return;
+ }
+
+ if (!maBtnMatchOldPass.IsChecked())
+ {
+ maBtnOk.Enable();
+ return;
+ }
+
+ if (!mpProtected)
+ {
+ // This should never happen!
+ maBtnOk.Disable();
+ return;
+ }
+
+ bool bPassGood = mpProtected->verifyPassword(aPass1);
+ maBtnOk.Enable(bPassGood);
+}
+
+IMPL_LINK( ScRetypePassInputDlg, OKHdl, OKButton*, EMPTYARG )
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassInputDlg, RadioBtnHdl, RadioButton*, pBtn )
+{
+ if (pBtn == &maBtnRetypePassword)
+ {
+ maBtnRemovePassword.Check(false);
+ maPassword1Text.Enable();
+ maPassword1Edit.Enable();
+ maPassword2Text.Enable();
+ maPassword2Edit.Enable();
+ maBtnMatchOldPass.Enable();
+ CheckPasswordInput();
+ }
+ else if (pBtn == &maBtnRemovePassword)
+ {
+ maBtnRetypePassword.Check(false);
+ maPassword1Text.Disable();
+ maPassword1Edit.Disable();
+ maPassword2Text.Disable();
+ maPassword2Edit.Disable();
+ maBtnMatchOldPass.Disable();
+ maBtnOk.Enable();
+ }
+
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassInputDlg, CheckBoxHdl, CheckBox*, EMPTYARG )
+{
+ CheckPasswordInput();
+ return 0;
+}
+
+IMPL_LINK( ScRetypePassInputDlg, PasswordModifyHdl, Edit*, EMPTYARG )
+{
+ CheckPasswordInput();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/retypepassdlg.src b/sc/source/ui/miscdlgs/retypepassdlg.src
new file mode 100644
index 000000000000..20cb3976a328
--- /dev/null
+++ b/sc/source/ui/miscdlgs/retypepassdlg.src
@@ -0,0 +1,313 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "retypepassdlg.hrc"
+
+
+ModalDialog RID_SCDLG_RETYPEPASS
+{
+ Text [ en-US ] = "Re-type Password" ;
+ Size = MAP_APPFONT ( 260 , 165 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 204, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 204, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 204, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ FixedText FT_DESC
+ {
+ Pos = MAP_APPFONT ( 6, 6 ) ;
+ Size = MAP_APPFONT ( 190, 36 );
+
+ WordBreak = TRUE ;
+
+ Text [ en-US ] = "The document you are about to export has one or more protected items with password that cannot be exported. Please re-type your password to be able to export your document." ;
+ };
+
+ FixedLine FL_DOCUMENT
+ {
+ Pos = MAP_APPFONT ( 6, 48 );
+ Size = MAP_APPFONT ( 190, 8 );
+
+ Text [ en-US ] = "Document protection" ;
+ };
+
+ FixedText FT_DOCSTATUS
+ {
+ Pos = MAP_APPFONT ( 10, 62 );
+ Size = MAP_APPFONT ( 140, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_DOC
+ {
+ Pos = MAP_APPFONT ( 158, 59 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedLine FL_SHEET
+ {
+ Pos = MAP_APPFONT ( 6, 83 );
+ Size = MAP_APPFONT ( 190, 8 );
+
+ Text [ en-US ] = "Sheet protection" ;
+ };
+
+ FixedText FT_SHEETNAME1
+ {
+ Pos = MAP_APPFONT ( 10, 97 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet1 has a really long name" ;
+ };
+
+ FixedText FT_SHEETSTATUS1
+ {
+ Pos = MAP_APPFONT ( 82, 97 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET1
+ {
+ Pos = MAP_APPFONT ( 158, 94 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedText FT_SHEETNAME2
+ {
+ Pos = MAP_APPFONT ( 10, 113 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet2" ;
+ };
+
+ FixedText FT_SHEETSTATUS2
+ {
+ Pos = MAP_APPFONT ( 82, 113 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET2
+ {
+ Pos = MAP_APPFONT ( 158, 110 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedText FT_SHEETNAME3
+ {
+ Pos = MAP_APPFONT ( 10, 129 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet3" ;
+ };
+
+ FixedText FT_SHEETSTATUS3
+ {
+ Pos = MAP_APPFONT ( 82, 129 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET3
+ {
+ Pos = MAP_APPFONT ( 158, 126 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ FixedText FT_SHEETNAME4
+ {
+ Pos = MAP_APPFONT ( 10, 145 );
+ Size = MAP_APPFONT ( 68, 8 );
+
+ Text [ en-US ] = "Sheet4" ;
+ };
+
+ FixedText FT_SHEETSTATUS4
+ {
+ Pos = MAP_APPFONT ( 82, 145 );
+ Size = MAP_APPFONT ( 72, 8 );
+
+ Text [ en-US ] = "Status unknown" ;
+ };
+
+ PushButton BTN_RETYPE_SHEET4
+ {
+ Pos = MAP_APPFONT ( 158, 142 );
+ Size = MAP_APPFONT ( 30, 14 );
+
+ Text [ en-US ] = "Re-type" ;
+ };
+
+ ScrollBar SB_SCROLL
+ {
+ Pos = MAP_APPFONT ( 190, 94 ) ;
+ Size = MAP_APPFONT ( 8, 61 ) ;
+ VScroll = TRUE ;
+ };
+
+ String STR_NOT_PROTECTED
+ {
+ Text [ en-US ] = "Not protected" ;
+ };
+
+ String STR_NOT_PASS_PROTECTED
+ {
+ Text [ en-US ] = "Not password-protected" ;
+ };
+
+ String STR_HASH_BAD
+ {
+ Text [ en-US ] = "Hash incompatible" ;
+ };
+
+ String STR_HASH_GOOD
+ {
+ Text [ en-US ] = "Hash compatible" ;
+ };
+
+ String STR_HASH_REGENERATED
+ {
+ Text [ en-US ] = "Hash re-generated" ;
+ };
+};
+
+// ----------------------------------------------------------------------------
+
+ModalDialog RID_SCDLG_RETYPEPASS_INPUT
+{
+ Text [ en-US ] = "Re-type Password" ;
+ Size = MAP_APPFONT ( 230 , 110 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 174, 6 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ DefButton = TRUE ;
+ };
+
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 174, 23 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 174, 43 ) ;
+ Size = MAP_APPFONT ( 50, 14 ) ;
+ };
+
+ RadioButton BTN_RETYPE_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 11, 10 );
+ Size = MAP_APPFONT ( 150, 10 );
+
+ Text [ en-US ] = "Re-type password" ;
+ };
+
+ FixedText FT_PASSWORD1
+ {
+ Pos = MAP_APPFONT ( 20, 30 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Password" ;
+ };
+
+ Edit ED_PASSWORD1
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 65, 29 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ FixedText FT_PASSWORD2
+ {
+ Pos = MAP_APPFONT ( 20, 45 );
+ Size = MAP_APPFONT ( 42, 10 );
+
+ Text [ en-US ] = "~Confirm" ;
+ };
+
+ Edit ED_PASSWORD2
+ {
+ Border = TRUE;
+ PassWord = TRUE;
+ Pos = MAP_APPFONT ( 65, 44 );
+ Size = MAP_APPFONT ( 75, 12 );
+ };
+
+ CheckBox BTN_MATCH_OLD_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 20, 65 );
+ Size = MAP_APPFONT ( 150, 10 );
+
+ Text [ en-US ] = "New password must match the original password." ;
+ };
+
+ RadioButton BTN_REMOVE_PASSWORD
+ {
+ Pos = MAP_APPFONT ( 11, 90 );
+ Size = MAP_APPFONT ( 150, 10 );
+
+ Text [ en-US ] = "Remove password from this protected item." ;
+ };
+};
+
+
diff --git a/sc/source/ui/miscdlgs/scuiautofmt.cxx b/sc/source/ui/miscdlgs/scuiautofmt.cxx
new file mode 100644
index 000000000000..25e97a456af2
--- /dev/null
+++ b/sc/source/ui/miscdlgs/scuiautofmt.cxx
@@ -0,0 +1,479 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "attrib.hxx"
+#include "zforauto.hxx"
+#include "scitems.hxx"
+#include "global.hxx"
+#include "globstr.hrc"
+#include "autoform.hxx"
+#include "strindlg.hxx"
+#include "miscdlgs.hrc"
+#include "scuiautofmt.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+
+//========================================================================
+// AutoFormat-Dialog:
+
+ScAutoFormatDlg::ScAutoFormatDlg( Window* pParent,
+ ScAutoFormat* pAutoFormat,
+ const ScAutoFormatData* pSelFormatData,
+ ScDocument* pDoc ) :
+
+ ModalDialog ( pParent, ScResId( RID_SCDLG_AUTOFORMAT ) ),
+ //
+ aFlFormat ( this, ScResId( FL_FORMAT ) ),
+ aLbFormat ( this, ScResId( LB_FORMAT ) ),
+ pWndPreview ( new ScAutoFmtPreview( this, ScResId( WND_PREVIEW ), pDoc ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ aFlFormatting ( this, ScResId( FL_FORMATTING ) ),
+ aBtnNumFormat ( this, ScResId( BTN_NUMFORMAT ) ),
+ aBtnBorder ( this, ScResId( BTN_BORDER ) ),
+ aBtnFont ( this, ScResId( BTN_FONT ) ),
+ aBtnPattern ( this, ScResId( BTN_PATTERN ) ),
+ aBtnAlignment ( this, ScResId( BTN_ALIGNMENT ) ),
+ aBtnAdjust ( this, ScResId( BTN_ADJUST ) ),
+ aBtnRename ( this, ScResId( BTN_RENAME ) ),
+ aStrTitle ( ScResId( STR_ADD_TITLE ) ),
+ aStrLabel ( ScResId( STR_ADD_LABEL ) ),
+ aStrClose ( ScResId( STR_BTN_CLOSE ) ),
+ aStrDelTitle ( ScResId( STR_DEL_TITLE ) ),
+ aStrDelMsg ( ScResId( STR_DEL_MSG ) ) ,
+ aStrRename ( ScResId( STR_RENAME_TITLE ) ),
+ //
+ pFormat ( pAutoFormat ),
+ pSelFmtData ( pSelFormatData ),
+ nIndex ( 0 ),
+ bCoreDataChanged( FALSE ),
+ bFmtInserted ( FALSE )
+{
+ Init();
+ pWndPreview->NotifyChange( (*pFormat)[0] );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScAutoFormatDlg::~ScAutoFormatDlg()
+{
+ delete pWndPreview;
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFormatDlg::Init()
+{
+ USHORT nCount;
+ String aEntry;
+
+ aLbFormat .SetSelectHdl( LINK( this, ScAutoFormatDlg, SelFmtHdl ) );
+ aBtnNumFormat.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnBorder .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnFont .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnPattern .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnAlignment.SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnAdjust .SetClickHdl ( LINK( this, ScAutoFormatDlg, CheckHdl ) );
+ aBtnAdd .SetClickHdl ( LINK( this, ScAutoFormatDlg, AddHdl ) );
+ aBtnRemove .SetClickHdl ( LINK( this, ScAutoFormatDlg, RemoveHdl ) );
+ aBtnOk .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
+ aBtnCancel .SetClickHdl ( LINK( this, ScAutoFormatDlg, CloseHdl ) );
+ aBtnRename .SetClickHdl ( LINK( this, ScAutoFormatDlg, RenameHdl ) );
+ aLbFormat .SetDoubleClickHdl( LINK( this, ScAutoFormatDlg, DblClkHdl ) );
+
+ aBtnMore.AddWindow( &aBtnRename );
+ aBtnMore.AddWindow( &aBtnNumFormat );
+ aBtnMore.AddWindow( &aBtnBorder );
+ aBtnMore.AddWindow( &aBtnFont );
+ aBtnMore.AddWindow( &aBtnPattern );
+ aBtnMore.AddWindow( &aBtnAlignment );
+ aBtnMore.AddWindow( &aBtnAdjust );
+ aBtnMore.AddWindow( &aFlFormatting );
+
+ nCount = pFormat->GetCount();
+
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ ((*pFormat)[i])->GetName( aEntry );
+ aLbFormat.InsertEntry( aEntry );
+ }
+
+ if ( nCount == 1 )
+ aBtnRemove.Disable();
+
+ aLbFormat.SelectEntryPos( 0 );
+ aBtnRename.Disable();
+ aBtnRemove.Disable();
+
+ nIndex = 0;
+ UpdateChecks();
+
+ if ( !pSelFmtData )
+ {
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ bFmtInserted = TRUE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAutoFormatDlg::UpdateChecks()
+{
+ ScAutoFormatData* pData = (*pFormat)[nIndex];
+
+ aBtnNumFormat.Check( pData->GetIncludeValueFormat() );
+ aBtnBorder .Check( pData->GetIncludeFrame() );
+ aBtnFont .Check( pData->GetIncludeFont() );
+ aBtnPattern .Check( pData->GetIncludeBackground() );
+ aBtnAlignment.Check( pData->GetIncludeJustify() );
+ aBtnAdjust .Check( pData->GetIncludeWidthHeight() );
+}
+
+//------------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScAutoFormatDlg, CloseHdl, PushButton *, pBtn )
+{
+ if ( pBtn == &aBtnOk || pBtn == &aBtnCancel )
+ {
+ if ( bCoreDataChanged )
+ ScGlobal::GetAutoFormat()->Save();
+
+ EndDialog( (pBtn == &aBtnOk) ? RET_OK : RET_CANCEL );
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
+{
+ if ( bCoreDataChanged )
+ ScGlobal::GetAutoFormat()->Save();
+
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScAutoFormatDlg, DblClkHdl, void *, EMPTYARG )
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, CheckHdl, Button *, pBtn )
+{
+ ScAutoFormatData* pData = (*pFormat)[nIndex];
+ BOOL bCheck = ((CheckBox*)pBtn)->IsChecked();
+
+ if ( pBtn == &aBtnNumFormat )
+ pData->SetIncludeValueFormat( bCheck );
+ else if ( pBtn == &aBtnBorder )
+ pData->SetIncludeFrame( bCheck );
+ else if ( pBtn == &aBtnFont )
+ pData->SetIncludeFont( bCheck );
+ else if ( pBtn == &aBtnPattern )
+ pData->SetIncludeBackground( bCheck );
+ else if ( pBtn == &aBtnAlignment )
+ pData->SetIncludeJustify( bCheck );
+ else if ( pBtn == &aBtnAdjust )
+ pData->SetIncludeWidthHeight( bCheck );
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+ pWndPreview->NotifyChange( pData );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, AddHdl, void *, EMPTYARG )
+{
+ if ( !bFmtInserted && pSelFmtData )
+ {
+ String aStrStandard( ScResId(STR_STANDARD) );
+ String aFormatName;
+ ScStringInputDlg* pDlg;
+ BOOL bOk = FALSE;
+
+ while ( !bOk )
+ {
+ pDlg = new ScStringInputDlg( this,
+ aStrTitle,
+ aStrLabel,
+ aFormatName,
+ HID_SC_ADD_AUTOFMT );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ pDlg->GetInputString( aFormatName );
+
+ if ( (aFormatName.Len() > 0) && (aFormatName != aStrStandard) )
+ {
+ ScAutoFormatData* pNewData
+ = new ScAutoFormatData( *pSelFmtData );
+
+ pNewData->SetName( aFormatName );
+ bFmtInserted = pFormat->Insert( pNewData );
+
+ if ( bFmtInserted )
+ {
+ USHORT nAt = pFormat->IndexOf( pNewData );
+
+ aLbFormat.InsertEntry( aFormatName, nAt );
+ aLbFormat.SelectEntry( aFormatName );
+ aBtnAdd.Disable();
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+ SelFmtHdl( 0 );
+ bOk = TRUE;
+ }
+ else
+ delete pNewData;
+
+ }
+
+ if ( !bFmtInserted )
+ {
+ USHORT nRet = ErrorBox( this,
+ WinBits( WB_OK_CANCEL | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_INVALID_AFNAME)
+ ).Execute();
+
+ bOk = ( nRet == RET_CANCEL );
+ }
+ }
+ else
+ bOk = TRUE;
+
+ delete pDlg;
+ }
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
+{
+ if ( (nIndex > 0) && (aLbFormat.GetEntryCount() > 0) )
+ {
+ String aMsg( aStrDelMsg.GetToken( 0, '#' ) );
+
+ aMsg += aLbFormat.GetSelectEntry();
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES ==
+ QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
+ {
+ aLbFormat.RemoveEntry( nIndex );
+ aLbFormat.SelectEntryPos( nIndex-1 );
+
+ if ( nIndex-1 == 0 )
+ aBtnRemove.Disable();
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+ pFormat->AtFree( nIndex ); // in der Core loeschen
+ nIndex--;
+
+ SelFmtHdl( 0 );
+ }
+ }
+
+ SelFmtHdl( 0 );
+
+ return 0;
+}
+
+IMPL_LINK( ScAutoFormatDlg, RenameHdl, void *, EMPTYARG )
+{
+ BOOL bOk = FALSE;
+ while( !bOk )
+ {
+
+ String aFormatName=aLbFormat.GetSelectEntry();
+ String aEntry;
+
+ ScStringInputDlg* pDlg = new ScStringInputDlg( this,
+ aStrRename,
+ aStrLabel,
+ aFormatName,
+ HID_SC_REN_AFMT_DLG );
+ if( pDlg->Execute() == RET_OK )
+ {
+ BOOL bFmtRenamed = FALSE;
+ pDlg->GetInputString( aFormatName );
+ USHORT n;
+
+ if ( aFormatName.Len() > 0 )
+ {
+ for( n = 0; n < pFormat->GetCount(); ++n )
+ {
+ (*pFormat)[n]->GetName(aEntry);
+ if ( aEntry== aFormatName)
+ break;
+ }
+ if( n >= pFormat->GetCount() )
+ {
+ // Format mit dem Namen noch nicht vorhanden, also
+ // umbenennen
+
+ aLbFormat.RemoveEntry(nIndex );
+ ScAutoFormatData* p=(*pFormat)[ nIndex ];
+ ScAutoFormatData* pNewData
+ = new ScAutoFormatData(*p);
+
+ pFormat->AtFree( nIndex );
+
+ pNewData->SetName( aFormatName );
+
+ pFormat->Insert( pNewData);
+
+ USHORT nCount = pFormat->GetCount();
+
+ aLbFormat.SetUpdateMode(FALSE);
+ aLbFormat.Clear();
+ for ( USHORT i = 0; i < nCount; i++ )
+ {
+ ((*pFormat)[i])->GetName( aEntry );
+ aLbFormat.InsertEntry( aEntry );
+ }
+
+ aLbFormat.SetUpdateMode( TRUE);
+ aLbFormat.SelectEntry( aFormatName);
+
+ if ( !bCoreDataChanged )
+ {
+ aBtnCancel.SetText( aStrClose );
+ bCoreDataChanged = TRUE;
+ }
+
+
+ SelFmtHdl( 0 );
+ bOk = TRUE;
+ bFmtRenamed = TRUE;
+ }
+ }
+ if( !bFmtRenamed )
+ {
+ bOk = RET_CANCEL == ErrorBox( this,
+ WinBits( WB_OK_CANCEL | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_INVALID_AFNAME)
+ ).Execute();
+ }
+ }
+ else
+ bOk = TRUE;
+ delete pDlg;
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
+{
+ nIndex = aLbFormat.GetSelectEntryPos();
+ UpdateChecks();
+
+ if ( nIndex == 0 )
+ {
+ aBtnRename.Disable();
+ aBtnRemove.Disable();
+ }
+ else
+ {
+ aBtnRename.Enable();
+ aBtnRemove.Enable();
+ }
+
+ pWndPreview->NotifyChange( (*pFormat)[nIndex] );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT ScAutoFormatDlg::GetCurrFormatName()
+{
+ String aResult;
+
+ ((*pFormat)[nIndex])->GetName( aResult );
+
+ return aResult;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.cxx b/sc/source/ui/miscdlgs/sharedocdlg.cxx
new file mode 100644
index 000000000000..7cf5ee1b840f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/sharedocdlg.cxx
@@ -0,0 +1,238 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//-----------------------------------------------------------------------------
+
+#include <osl/security.hxx>
+#include <svl/sharecontrolfile.hxx>
+#include <unotools/useroptions.hxx>
+
+#include <docsh.hxx>
+
+#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <com/sun/star/document/XDocumentProperties.hpp>
+
+
+#include "sharedocdlg.hxx"
+#include "sharedocdlg.hrc"
+#include "scresid.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+
+
+using namespace ::com::sun::star;
+
+
+//=============================================================================
+// class ScShareDocumentDlg
+//=============================================================================
+
+ScShareDocumentDlg::ScShareDocumentDlg( Window* pParent, ScViewData* pViewData )
+ :ModalDialog( pParent, ScResId( RID_SCDLG_SHAREDOCUMENT ) )
+ ,maCbShare ( this, ScResId( CB_SHARE ) )
+ ,maFtWarning ( this, ScResId( FT_WARNING ) )
+ ,maFlUsers ( this, ScResId( FL_USERS ) )
+ ,maFtUsers ( this, ScResId( FT_USERS ) )
+ ,maLbUsers ( this, ScResId( LB_USERS ) )
+ ,maFlEnd ( this, ScResId( FL_END ) )
+ ,maBtnHelp ( this, ScResId( BTN_HELP ) )
+ ,maBtnOK ( this, ScResId( BTN_OK ) )
+ ,maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+ ,maStrTitleName ( ScResId( STR_TITLE_NAME ) )
+ ,maStrTitleAccessed ( ScResId( STR_TITLE_ACCESSED ) )
+ ,maStrNoUserData ( ScResId( STR_NO_USER_DATA ) )
+ ,maStrUnkownUser ( ScResId( STR_UNKNOWN_USER ) )
+ ,maStrExclusiveAccess ( ScResId( STR_EXCLUSIVE_ACCESS ) )
+ ,mpViewData ( pViewData )
+ ,mpDocShell ( NULL )
+{
+ DBG_ASSERT( mpViewData, "ScShareDocumentDlg CTOR: mpViewData is null!" );
+ mpDocShell = ( mpViewData ? mpViewData->GetDocShell() : NULL );
+ DBG_ASSERT( mpDocShell, "ScShareDocumentDlg CTOR: mpDocShell is null!" );
+
+ FreeResource();
+
+ bool bIsDocShared = ( mpDocShell ? mpDocShell->IsDocShared() : false );
+ maCbShare.Check( bIsDocShared );
+ maCbShare.SetToggleHdl( LINK( this, ScShareDocumentDlg, ToggleHandle ) );
+ maFtWarning.Enable( bIsDocShared );
+
+ long nTabs[] = { 2, 10, 128 };
+ maLbUsers.SetTabs( nTabs );
+
+ String aHeader( maStrTitleName );
+ aHeader += '\t';
+ aHeader += maStrTitleAccessed;
+ maLbUsers.InsertHeaderEntry( aHeader, HEADERBAR_APPEND, HIB_LEFT | HIB_LEFTIMAGE | HIB_VCENTER );
+ maLbUsers.SetSelectionMode( NO_SELECTION );
+
+ UpdateView();
+}
+
+ScShareDocumentDlg::~ScShareDocumentDlg()
+{
+}
+
+IMPL_LINK( ScShareDocumentDlg, ToggleHandle, void*, EMPTYARG )
+{
+ maFtWarning.Enable( maCbShare.IsChecked() );
+
+ return 0;
+}
+
+bool ScShareDocumentDlg::IsShareDocumentChecked() const
+{
+ return maCbShare.IsChecked();
+}
+
+void ScShareDocumentDlg::UpdateView()
+{
+ if ( !mpDocShell )
+ {
+ return;
+ }
+
+ if ( mpDocShell->IsDocShared() )
+ {
+ try
+ {
+ ::svt::ShareControlFile aControlFile( mpDocShell->GetSharedFileURL() );
+ uno::Sequence< uno::Sequence< ::rtl::OUString > > aUsersData = aControlFile.GetUsersData();
+ const uno::Sequence< ::rtl::OUString >* pUsersData = aUsersData.getConstArray();
+ sal_Int32 nLength = aUsersData.getLength();
+
+ if ( nLength > 0 )
+ {
+ sal_Int32 nUnknownUser = 1;
+
+ for ( sal_Int32 i = 0; i < nLength; ++i )
+ {
+ if ( pUsersData[i].getLength() > SHARED_EDITTIME_ID )
+ {
+ String aUser;
+ if ( pUsersData[i][SHARED_OOOUSERNAME_ID].getLength() )
+ {
+ aUser = pUsersData[i][SHARED_OOOUSERNAME_ID];
+ }
+ else if ( pUsersData[i][SHARED_SYSUSERNAME_ID].getLength() )
+ {
+ aUser = pUsersData[i][SHARED_SYSUSERNAME_ID];
+ }
+ else
+ {
+ aUser = maStrUnkownUser;
+ aUser += ' ';
+ aUser += String::CreateFromInt32( nUnknownUser++ );
+ }
+
+ // parse the edit time string of the format "DD.MM.YYYY hh:mm"
+ ::rtl::OUString aDateTimeStr = pUsersData[i][SHARED_EDITTIME_ID];
+ sal_Int32 nIndex = 0;
+ ::rtl::OUString aDateStr = aDateTimeStr.getToken( 0, ' ', nIndex );
+ ::rtl::OUString aTimeStr = aDateTimeStr.getToken( 0, ' ', nIndex );
+ nIndex = 0;
+ USHORT nDay = sal::static_int_cast< USHORT >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ USHORT nMonth = sal::static_int_cast< USHORT >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ USHORT nYear = sal::static_int_cast< USHORT >( aDateStr.getToken( 0, '.', nIndex ).toInt32() );
+ nIndex = 0;
+ USHORT nHours = sal::static_int_cast< USHORT >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() );
+ USHORT nMinutes = sal::static_int_cast< USHORT >( aTimeStr.getToken( 0, ':', nIndex ).toInt32() );
+ Date aDate( nDay, nMonth, nYear );
+ Time aTime( nHours, nMinutes );
+ DateTime aDateTime( aDate, aTime );
+
+ String aString( aUser );
+ aString += '\t';
+ aString += ScGlobal::pLocaleData->getDate( aDateTime );
+ aString += ' ';
+ aString += ScGlobal::pLocaleData->getTime( aDateTime, FALSE );
+
+ maLbUsers.InsertEntry( aString, NULL );
+ }
+ }
+ }
+ else
+ {
+ maLbUsers.InsertEntry( maStrNoUserData, NULL );
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DBG_ERROR( "ScShareDocumentDlg::UpdateView(): caught exception\n" );
+ maLbUsers.Clear();
+ maLbUsers.InsertEntry( maStrNoUserData, NULL );
+ }
+ }
+ else
+ {
+ // get OOO user name
+ SvtUserOptions aUserOpt;
+ String aUser = aUserOpt.GetFirstName();
+ if ( aUser.Len() > 0 )
+ {
+ aUser += ' ';
+ }
+ aUser += String(aUserOpt.GetLastName());
+ if ( aUser.Len() == 0 )
+ {
+ // get sys user name
+ ::rtl::OUString aUserName;
+ ::osl::Security aSecurity;
+ aSecurity.getUserName( aUserName );
+ aUser = aUserName;
+ }
+ if ( aUser.Len() == 0 )
+ {
+ // unknown user name
+ aUser = maStrUnkownUser;
+ }
+ aUser += ' ';
+ aUser += maStrExclusiveAccess;
+ String aString( aUser );
+ aString += '\t';
+
+ uno::Reference<document::XDocumentPropertiesSupplier> xDPS(mpDocShell->GetModel(), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties();
+
+ util::DateTime uDT(xDocProps->getModificationDate());
+ Date d(uDT.Day, uDT.Month, uDT.Year);
+ Time t(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
+ DateTime aDateTime(d,t);
+
+ aString += ScGlobal::pLocaleData->getDate( aDateTime );
+ aString += ' ';
+ aString += ScGlobal::pLocaleData->getTime( aDateTime, FALSE );
+
+ maLbUsers.InsertEntry( aString, NULL );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/sharedocdlg.src b/sc/source/ui/miscdlgs/sharedocdlg.src
new file mode 100644
index 000000000000..13361b216ea5
--- /dev/null
+++ b/sc/source/ui/miscdlgs/sharedocdlg.src
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sharedocdlg.hrc"
+
+ModalDialog RID_SCDLG_SHAREDOCUMENT
+{
+ OutputSize = TRUE ;
+ HelpId = SID_SHARE_DOC ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 204 , 186 ) ;
+ Text [ en-US ] = "Share Document" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ CheckBox CB_SHARE
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "Share this spreadsheet with other users" ;
+ };
+ FixedText FT_WARNING
+ {
+ Pos = MAP_APPFONT ( 15 , 18 ) ;
+ Size = MAP_APPFONT ( 183 , 48 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Note: Changes to formatting attributes like fonts, colors, and number formats will not be saved and some functionalities like editing charts and drawing objects are not available in shared mode. Turn off shared mode to get exclusive access needed for those changes and functionalities." ;
+ };
+ FixedLine FL_USERS
+ {
+ Pos = MAP_APPFONT ( 6 , 66 ) ;
+ Size = MAP_APPFONT ( 192 , 4 ) ;
+ };
+ FixedText FT_USERS
+ {
+ Pos = MAP_APPFONT ( 6 , 72 ) ;
+ Size = MAP_APPFONT ( 192 , 8 ) ;
+ Text [ en-US ] = "Users currently accessing this spreadsheet" ;
+ };
+ Control LB_USERS
+ {
+ Pos = MAP_APPFONT ( 6 , 82 ) ;
+ Size = MAP_APPFONT ( 192 , 72 ) ;
+ Border = TRUE ;
+ };
+ FixedLine FL_END
+ {
+ Pos = MAP_APPFONT ( 1 , 156 ) ;
+ Size = MAP_APPFONT ( 204 , 8 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 6 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 92 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 148 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_TITLE_NAME
+ {
+ Text [ en-US ] = "Name" ;
+ };
+ String STR_TITLE_ACCESSED
+ {
+ Text [ en-US ] = "Accessed" ;
+ };
+ String STR_NO_USER_DATA
+ {
+ Text [ en-US ] = "No user data available." ;
+ };
+ String STR_UNKNOWN_USER
+ {
+ Text [ en-US ] = "Unknown User" ;
+ };
+ String STR_EXCLUSIVE_ACCESS
+ {
+ Text [ en-US ] = "(exclusive access)" ;
+ };
+};
diff --git a/sc/source/ui/miscdlgs/shtabdlg.cxx b/sc/source/ui/miscdlgs/shtabdlg.cxx
new file mode 100644
index 000000000000..230920bf71a9
--- /dev/null
+++ b/sc/source/ui/miscdlgs/shtabdlg.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "shtabdlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+
+//==================================================================
+
+ScShowTabDlg::ScShowTabDlg( Window* pParent ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_SHOW_TAB ) ),
+ aLb ( this, ScResId( LB_ENTRYLIST ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aFtLbTitle ( this, ScResId( FT_LABEL ) )
+{
+ aLb.Clear();
+ aLb.SetDoubleClickHdl( LINK( this, ScShowTabDlg, DblClkHdl ) );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScShowTabDlg::SetDescription(
+ const String& rTitle, const String& rFixedText,
+ ULONG nDlgHelpId, ULONG nLbHelpId )
+{
+ SetText( rTitle );
+ aFtLbTitle.SetText( rFixedText );
+ SetHelpId( nDlgHelpId );
+ aLb.SetHelpId( nLbHelpId );
+}
+
+void ScShowTabDlg::Insert( const String& rString, BOOL bSelected )
+{
+ aLb.InsertEntry( rString );
+ if( bSelected )
+ aLb.SelectEntryPos( aLb.GetEntryCount() - 1 );
+}
+
+//------------------------------------------------------------------------
+
+USHORT ScShowTabDlg::GetSelectEntryCount() const
+{
+ return aLb.GetSelectEntryCount();
+}
+
+String ScShowTabDlg::GetSelectEntry(USHORT nPos) const
+{
+ return aLb.GetSelectEntry(nPos);
+}
+
+USHORT ScShowTabDlg::GetSelectEntryPos(USHORT nPos) const
+{
+ return aLb.GetSelectEntryPos(nPos);
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScShowTabDlg, DblClkHdl, void *, EMPTYARG )
+{
+ EndDialog( RET_OK );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScShowTabDlg, DblClkHdl, void *, EMPTYARG )
+
+__EXPORT ScShowTabDlg::~ScShowTabDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/simpref.cxx b/sc/source/ui/miscdlgs/simpref.cxx
new file mode 100644
index 000000000000..2a8186f05866
--- /dev/null
+++ b/sc/source/ui/miscdlgs/simpref.cxx
@@ -0,0 +1,259 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "simpref.hrc"
+#include "rangenam.hxx" // IsNameValid
+#include "simpref.hxx"
+#include "scmod.hxx"
+
+//============================================================================
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+//----------------------------------------------------------------------------
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute()
+#define QUERYBOX(m) QueryBox(this,WinBits(WB_YES_NO|WB_DEF_YES),m).Execute()
+
+//============================================================================
+// class ScSimpleRefDlg
+
+//----------------------------------------------------------------------------
+ScSimpleRefDlg::ScSimpleRefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SIMPLEREF ),
+ //
+ aFtAssign ( this, ScResId( FT_ASSIGN ) ),
+ aEdAssign ( this, this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ bRefInputMode ( FALSE ),
+ bAutoReOpen ( TRUE ),
+ bCloseOnButtonUp( FALSE ),
+ bSingleCell ( FALSE ),
+ bMultiSelection ( FALSE )
+{
+ // damit die Strings in der Resource bei den FixedTexten bleiben koennen:
+ Init();
+ FreeResource();
+ SetDispatcherLock( TRUE ); // Modal-Modus einschalten
+}
+
+//----------------------------------------------------------------------------
+__EXPORT ScSimpleRefDlg::~ScSimpleRefDlg()
+{
+ SetDispatcherLock( FALSE ); // Modal-Modus einschalten
+}
+
+//----------------------------------------------------------------------------
+void ScSimpleRefDlg::FillInfo(SfxChildWinInfo& rWinInfo) const
+{
+ ScAnyRefDlg::FillInfo(rWinInfo);
+ rWinInfo.bVisible=bAutoReOpen;
+}
+
+//----------------------------------------------------------------------------
+void ScSimpleRefDlg::SetRefString(const String &rStr)
+{
+ aEdAssign.SetText(rStr);
+}
+
+//----------------------------------------------------------------------------
+void ScSimpleRefDlg::Init()
+{
+ aBtnOk.SetClickHdl ( LINK( this, ScSimpleRefDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScSimpleRefDlg, CancelBtnHdl ) );
+ bCloseFlag=FALSE;
+}
+
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Fenster angezeigt wird.
+void ScSimpleRefDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( &aEdAssign );
+
+ theCurArea = rRef;
+ String aRefStr;
+ if ( bSingleCell )
+ {
+ ScAddress aAdr = rRef.aStart;
+ aAdr.Format( aRefStr, SCA_ABS_3D, pDocP, pDocP->GetAddressConvention() );
+ }
+ else
+ theCurArea.Format( aRefStr, ABS_DREF3D, pDocP, pDocP->GetAddressConvention() );
+
+ if ( bMultiSelection )
+ {
+ String aVal = aEdAssign.GetText();
+ Selection aSel = aEdAssign.GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aRefStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aRefStr.Len() );
+ aEdAssign.SetRefString( aVal );
+ aEdAssign.SetSelection( aNewSel );
+ }
+ else
+ aEdAssign.SetRefString( aRefStr );
+
+ aChangeHdl.Call( &aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScSimpleRefDlg::Close()
+{
+ CancelBtnHdl(&aBtnCancel);
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+void ScSimpleRefDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+
+ // kein NameModifyHdl, weil sonst Bereiche nicht geaendert werden koennen
+ // (nach dem Aufziehen der Referenz wuerde der alte Inhalt wieder angezeigt)
+ // (der ausgewaehlte DB-Name hat sich auch nicht veraendert)
+
+ RefInputDone();
+}
+//------------------------------------------------------------------------
+BOOL ScSimpleRefDlg::IsRefInputMode() const
+{
+ return TRUE;
+}
+
+String ScSimpleRefDlg::GetRefString() const
+{
+ return aEdAssign.GetText();
+}
+
+void ScSimpleRefDlg::SetCloseHdl( const Link& rLink )
+{
+ aCloseHdl=rLink;
+}
+
+void ScSimpleRefDlg::SetUnoLinks( const Link& rDone, const Link& rAbort,
+ const Link& rChange )
+{
+ aDoneHdl = rDone;
+ aAbortedHdl = rAbort;
+ aChangeHdl = rChange;
+}
+
+void ScSimpleRefDlg::SetFlags( BOOL bSetCloseOnButtonUp, BOOL bSetSingleCell, BOOL bSetMultiSelection )
+{
+ bCloseOnButtonUp = bSetCloseOnButtonUp;
+ bSingleCell = bSetSingleCell;
+ bMultiSelection = bSetMultiSelection;
+}
+
+void ScSimpleRefDlg::StartRefInput()
+{
+ if ( bMultiSelection )
+ {
+ // initially select the whole string, so it gets replaced by default
+ aEdAssign.SetSelection( Selection( 0, aEdAssign.GetText().Len() ) );
+ }
+
+ aRbAssign.DoRef();
+ bCloseFlag=TRUE;
+}
+
+void ScSimpleRefDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ if ( (bForced || bCloseOnButtonUp) && bCloseFlag )
+ OkBtnHdl(&aBtnOk);
+}
+//------------------------------------------------------------------------
+// Handler:
+// ========
+IMPL_LINK( ScSimpleRefDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ bAutoReOpen=FALSE;
+ String aResult=aEdAssign.GetText();
+ aCloseHdl.Call(&aResult);
+ Link aUnoLink = aDoneHdl; // stack var because this is deleted in DoClose
+ DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
+ aUnoLink.Call( &aResult );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+IMPL_LINK( ScSimpleRefDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ bAutoReOpen=FALSE;
+ String aResult=aEdAssign.GetText();
+ aCloseHdl.Call(NULL);
+ Link aUnoLink = aAbortedHdl; // stack var because this is deleted in DoClose
+ DoClose( ScSimpleRefDlgWrapper::GetChildWindowId() );
+ aUnoLink.Call( &aResult );
+ return 0;
+}
+
+
+
+//------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/solveroptions.cxx b/sc/source/ui/miscdlgs/solveroptions.cxx
new file mode 100644
index 000000000000..05ccd3553ef5
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solveroptions.cxx
@@ -0,0 +1,494 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "solveroptions.hxx"
+#include "solveroptions.hrc"
+#include "scresid.hxx"
+#include "global.hxx"
+#include "miscuno.hxx"
+#include "solverutil.hxx"
+
+#include <rtl/math.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/collatorwrapper.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include <algorithm>
+
+#include <com/sun/star/sheet/Solver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+using namespace com::sun::star;
+
+//==================================================================
+
+/// Helper for sorting properties
+struct ScSolverOptionsEntry
+{
+ sal_Int32 nPosition;
+ rtl::OUString aDescription;
+
+ ScSolverOptionsEntry() : nPosition(0) {}
+
+ bool operator< (const ScSolverOptionsEntry& rOther) const
+ {
+ return ( ScGlobal::GetCollator()->compareString( aDescription, rOther.aDescription ) == COMPARE_LESS );
+ }
+};
+
+//------------------------------------------------------------------
+
+class ScSolverOptionsString : public SvLBoxString
+{
+ bool mbIsDouble;
+ double mfDoubleValue;
+ sal_Int32 mnIntValue;
+
+public:
+ ScSolverOptionsString( SvLBoxEntry* pEntry, USHORT nFlags, const String& rStr ) :
+ SvLBoxString( pEntry, nFlags, rStr ),
+ mbIsDouble( false ),
+ mfDoubleValue( 0.0 ),
+ mnIntValue( 0 ) {}
+
+ bool IsDouble() const { return mbIsDouble; }
+ double GetDoubleValue() const { return mfDoubleValue; }
+ sal_Int32 GetIntValue() const { return mnIntValue; }
+
+ void SetDoubleValue( double fNew ) { mbIsDouble = true; mfDoubleValue = fNew; }
+ void SetIntValue( sal_Int32 nNew ) { mbIsDouble = false; mnIntValue = nNew; }
+
+ virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags, SvLBoxEntry* pEntry );
+};
+
+void ScSolverOptionsString::Paint( const Point& rPos, SvLBox& rDev, USHORT, SvLBoxEntry* /* pEntry */ )
+{
+ //! move position? (SvxLinguTabPage: aPos.X() += 20)
+ String aNormalStr( GetText() );
+ aNormalStr.Append( (sal_Unicode) ':' );
+ rDev.DrawText( rPos, aNormalStr );
+
+ Point aNewPos( rPos );
+ aNewPos.X() += rDev.GetTextWidth( aNormalStr );
+ Font aOldFont( rDev.GetFont() );
+ Font aFont( aOldFont );
+ aFont.SetWeight( WEIGHT_BOLD );
+
+ String sTxt( ' ' );
+ if ( mbIsDouble )
+ sTxt += (String)rtl::math::doubleToUString( mfDoubleValue,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::GetpLocaleData()->getNumDecimalSep().GetChar(0), true );
+ else
+ sTxt += String::CreateFromInt32( mnIntValue );
+ rDev.SetFont( aFont );
+ rDev.DrawText( aNewPos, sTxt );
+
+ rDev.SetFont( aOldFont );
+}
+
+//------------------------------------------------------------------
+
+ScSolverOptionsDialog::ScSolverOptionsDialog( Window* pParent,
+ const uno::Sequence<rtl::OUString>& rImplNames,
+ const uno::Sequence<rtl::OUString>& rDescriptions,
+ const String& rEngine,
+ const uno::Sequence<beans::PropertyValue>& rProperties )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVEROPTIONS ) ),
+ maFtEngine ( this, ScResId( FT_ENGINE ) ),
+ maLbEngine ( this, ScResId( LB_ENGINE ) ),
+ maFtSettings ( this, ScResId( FT_SETTINGS ) ),
+ maLbSettings ( this, ScResId( LB_SETTINGS ) ),
+ maBtnEdit ( this, ScResId( BTN_EDIT ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnHelp ( this, ScResId( BTN_HELP ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ mpCheckButtonData( NULL ),
+ maImplNames( rImplNames ),
+ maDescriptions( rDescriptions ),
+ maEngine( rEngine ),
+ maProperties( rProperties )
+{
+ maLbEngine.SetSelectHdl( LINK( this, ScSolverOptionsDialog, EngineSelectHdl ) );
+
+ maBtnEdit.SetClickHdl( LINK( this, ScSolverOptionsDialog, ButtonHdl ) );
+
+ maLbSettings.SetWindowBits( WB_CLIPCHILDREN|WB_FORCE_MAKEVISIBLE );
+ maLbSettings.SetHelpId( HID_SC_SOLVEROPTIONS_LB );
+ maLbSettings.SetHighlightRange();
+
+ maLbSettings.SetSelectHdl( LINK( this, ScSolverOptionsDialog, SettingsSelHdl ) );
+ maLbSettings.SetDoubleClickHdl( LINK( this, ScSolverOptionsDialog, SettingsDoubleClickHdl ) );
+
+ sal_Int32 nSelect = -1;
+ sal_Int32 nImplCount = maImplNames.getLength();
+ for (sal_Int32 nImpl=0; nImpl<nImplCount; ++nImpl)
+ {
+ String aImplName( maImplNames[nImpl] );
+ String aDescription( maDescriptions[nImpl] ); // user-visible descriptions in list box
+ maLbEngine.InsertEntry( aDescription );
+ if ( aImplName == maEngine )
+ nSelect = nImpl;
+ }
+ if ( nSelect < 0 ) // no (valid) engine given
+ {
+ if ( nImplCount > 0 )
+ {
+ maEngine = maImplNames[0]; // use first implementation
+ nSelect = 0;
+ }
+ else
+ maEngine.Erase();
+ maProperties.realloc(0); // don't use options from different engine
+ }
+ if ( nSelect >= 0 ) // select in list box
+ maLbEngine.SelectEntryPos( static_cast<USHORT>(nSelect) );
+
+ if ( !maProperties.getLength() )
+ ReadFromComponent(); // fill maProperties from component (using maEngine)
+ FillListBox(); // using maProperties
+
+ FreeResource();
+}
+
+ScSolverOptionsDialog::~ScSolverOptionsDialog()
+{
+ delete mpCheckButtonData;
+}
+
+const String& ScSolverOptionsDialog::GetEngine() const
+{
+ return maEngine; // already updated in selection handler
+}
+
+const uno::Sequence<beans::PropertyValue>& ScSolverOptionsDialog::GetProperties()
+{
+ // update maProperties from list box content
+ // order of entries in list box and maProperties is the same
+ sal_Int32 nEntryCount = maProperties.getLength();
+ SvLBoxTreeList* pModel = maLbSettings.GetModel();
+ if ( nEntryCount == (sal_Int32)pModel->GetEntryCount() )
+ {
+ for (sal_Int32 nEntryPos=0; nEntryPos<nEntryCount; ++nEntryPos)
+ {
+ uno::Any& rValue = maProperties[nEntryPos].Value;
+ SvLBoxEntry* pEntry = pModel->GetEntry(nEntryPos);
+
+ bool bHasData = false;
+ USHORT nItemCount = pEntry->ItemCount();
+ for (USHORT nItemPos=0; nItemPos<nItemCount && !bHasData; ++nItemPos)
+ {
+ SvLBoxItem* pItem = pEntry->GetItem( nItemPos );
+ ScSolverOptionsString* pStringItem = dynamic_cast<ScSolverOptionsString*>(pItem);
+ if ( pStringItem )
+ {
+ if ( pStringItem->IsDouble() )
+ rValue <<= pStringItem->GetDoubleValue();
+ else
+ rValue <<= pStringItem->GetIntValue();
+ bHasData = true;
+ }
+ }
+ if ( !bHasData )
+ ScUnoHelpFunctions::SetBoolInAny( rValue,
+ maLbSettings.GetCheckButtonState( pEntry ) == SV_BUTTON_CHECKED );
+ }
+ }
+ else
+ {
+ DBG_ERRORFILE( "wrong count" );
+ }
+
+ return maProperties;
+}
+
+void ScSolverOptionsDialog::FillListBox()
+{
+ // get property descriptions, sort by them
+
+ uno::Reference<sheet::XSolverDescription> xDesc( ScSolverUtil::GetSolver( maEngine ), uno::UNO_QUERY );
+ sal_Int32 nCount = maProperties.getLength();
+ std::vector<ScSolverOptionsEntry> aDescriptions( nCount );
+ for (sal_Int32 nPos=0; nPos<nCount; nPos++)
+ {
+ rtl::OUString aPropName( maProperties[nPos].Name );
+ rtl::OUString aVisName;
+ if ( xDesc.is() )
+ aVisName = xDesc->getPropertyDescription( aPropName );
+ if ( !aVisName.getLength() )
+ aVisName = aPropName;
+ aDescriptions[nPos].nPosition = nPos;
+ aDescriptions[nPos].aDescription = aVisName;
+ }
+ std::sort( aDescriptions.begin(), aDescriptions.end() );
+
+ // also update maProperties to the order of descriptions
+
+ uno::Sequence<beans::PropertyValue> aNewSeq;
+ aNewSeq.realloc( nCount );
+ for (sal_Int32 nPos=0; nPos<nCount; nPos++)
+ aNewSeq[nPos] = maProperties[ aDescriptions[nPos].nPosition ];
+ maProperties = aNewSeq;
+
+ // fill the list box
+
+ maLbSettings.SetUpdateMode(FALSE);
+ maLbSettings.Clear();
+
+ String sEmpty;
+ if (!mpCheckButtonData)
+ mpCheckButtonData = new SvLBoxButtonData( &maLbSettings );
+
+ SvLBoxTreeList* pModel = maLbSettings.GetModel();
+ SvLBoxEntry* pEntry = NULL;
+
+ for (sal_Int32 nPos=0; nPos<nCount; nPos++)
+ {
+ rtl::OUString aVisName = aDescriptions[nPos].aDescription;
+
+ uno::Any aValue = maProperties[nPos].Value;
+ uno::TypeClass eClass = aValue.getValueTypeClass();
+ if ( eClass == uno::TypeClass_BOOLEAN )
+ {
+ // check box entry
+ pEntry = new SvLBoxEntry;
+ SvLBoxButton* pButton = new SvLBoxButton( pEntry, SvLBoxButtonKind_enabledCheckbox, 0, mpCheckButtonData );
+ if ( ScUnoHelpFunctions::GetBoolFromAny( aValue ) )
+ pButton->SetStateChecked();
+ else
+ pButton->SetStateUnchecked();
+ pEntry->AddItem( pButton );
+ pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );
+ pEntry->AddItem( new SvLBoxString( pEntry, 0, aVisName ) );
+ }
+ else
+ {
+ // value entry
+ pEntry = new SvLBoxEntry;
+ pEntry->AddItem( new SvLBoxString( pEntry, 0, sEmpty ) ); // empty column
+ pEntry->AddItem( new SvLBoxContextBmp( pEntry, 0, Image(), Image(), 0 ) );
+ ScSolverOptionsString* pItem = new ScSolverOptionsString( pEntry, 0, aVisName );
+ if ( eClass == uno::TypeClass_DOUBLE )
+ {
+ double fDoubleValue = 0.0;
+ if ( aValue >>= fDoubleValue )
+ pItem->SetDoubleValue( fDoubleValue );
+ }
+ else
+ {
+ sal_Int32 nIntValue = 0;
+ if ( aValue >>= nIntValue )
+ pItem->SetIntValue( nIntValue );
+ }
+ pEntry->AddItem( pItem );
+ }
+ pModel->Insert( pEntry );
+ }
+
+ maLbSettings.SetUpdateMode(TRUE);
+}
+
+void ScSolverOptionsDialog::ReadFromComponent()
+{
+ maProperties = ScSolverUtil::GetDefaults( maEngine );
+}
+
+void ScSolverOptionsDialog::EditOption()
+{
+ SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
+ if (pEntry)
+ {
+ USHORT nItemCount = pEntry->ItemCount();
+ for (USHORT nPos=0; nPos<nItemCount; ++nPos)
+ {
+ SvLBoxItem* pItem = pEntry->GetItem( nPos );
+ ScSolverOptionsString* pStringItem = dynamic_cast<ScSolverOptionsString*>(pItem);
+ if ( pStringItem )
+ {
+ if ( pStringItem->IsDouble() )
+ {
+ ScSolverValueDialog aValDialog( this );
+ aValDialog.SetOptionName( pStringItem->GetText() );
+ aValDialog.SetValue( pStringItem->GetDoubleValue() );
+ if ( aValDialog.Execute() == RET_OK )
+ {
+ pStringItem->SetDoubleValue( aValDialog.GetValue() );
+ maLbSettings.InvalidateEntry( pEntry );
+ }
+ }
+ else
+ {
+ ScSolverIntegerDialog aIntDialog( this );
+ aIntDialog.SetOptionName( pStringItem->GetText() );
+ aIntDialog.SetValue( pStringItem->GetIntValue() );
+ if ( aIntDialog.Execute() == RET_OK )
+ {
+ pStringItem->SetIntValue( aIntDialog.GetValue() );
+ maLbSettings.InvalidateEntry( pEntry );
+ }
+ }
+ }
+ }
+ }
+}
+
+IMPL_LINK( ScSolverOptionsDialog, ButtonHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &maBtnEdit )
+ EditOption();
+
+ return 0;
+}
+
+IMPL_LINK( ScSolverOptionsDialog, SettingsDoubleClickHdl, SvTreeListBox*, EMPTYARG )
+{
+ EditOption();
+ return 0;
+}
+
+IMPL_LINK( ScSolverOptionsDialog, EngineSelectHdl, ListBox*, EMPTYARG )
+{
+ USHORT nSelectPos = maLbEngine.GetSelectEntryPos();
+ if ( nSelectPos < maImplNames.getLength() )
+ {
+ String aNewEngine( maImplNames[nSelectPos] );
+ if ( aNewEngine != maEngine )
+ {
+ maEngine = aNewEngine;
+ ReadFromComponent(); // fill maProperties from component (using maEngine)
+ FillListBox(); // using maProperties
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScSolverOptionsDialog, SettingsSelHdl, SvxCheckListBox*, EMPTYARG )
+{
+ BOOL bCheckbox = FALSE;
+
+ SvLBoxEntry* pEntry = maLbSettings.GetCurEntry();
+ if (pEntry)
+ {
+ SvLBoxItem* pItem = pEntry->GetFirstItem(SV_ITEM_ID_LBOXBUTTON);
+ if ( pItem && pItem->IsA() == SV_ITEM_ID_LBOXBUTTON )
+ bCheckbox = TRUE;
+ }
+
+ maBtnEdit.Enable( !bCheckbox );
+
+ return 0;
+}
+
+//------------------------------------------------------------------
+
+ScSolverIntegerDialog::ScSolverIntegerDialog( Window * pParent )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_INTEGER ) ),
+ maFtName ( this, ScResId( FT_OPTIONNAME ) ),
+ maNfValue ( this, ScResId( NF_VALUE ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ FreeResource();
+}
+
+ScSolverIntegerDialog::~ScSolverIntegerDialog()
+{
+}
+
+void ScSolverIntegerDialog::SetOptionName( const String& rName )
+{
+ maFtName.SetText( rName );
+}
+
+void ScSolverIntegerDialog::SetValue( sal_Int32 nValue )
+{
+ maNfValue.SetValue( nValue );
+}
+
+sal_Int32 ScSolverIntegerDialog::GetValue() const
+{
+ sal_Int64 nValue = maNfValue.GetValue();
+ if ( nValue < SAL_MIN_INT32 )
+ return SAL_MIN_INT32;
+ if ( nValue > SAL_MAX_INT32 )
+ return SAL_MAX_INT32;
+ return (sal_Int32) nValue;
+}
+
+//------------------------------------------------------------------
+
+ScSolverValueDialog::ScSolverValueDialog( Window * pParent )
+ : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_DOUBLE ) ),
+ maFtName ( this, ScResId( FT_OPTIONNAME ) ),
+ maEdValue ( this, ScResId( ED_VALUE ) ),
+ maFlButtons ( this, ScResId( FL_BUTTONS ) ),
+ maBtnOk ( this, ScResId( BTN_OK ) ),
+ maBtnCancel ( this, ScResId( BTN_CANCEL ) )
+{
+ FreeResource();
+}
+
+ScSolverValueDialog::~ScSolverValueDialog()
+{
+}
+
+void ScSolverValueDialog::SetOptionName( const String& rName )
+{
+ maFtName.SetText( rName );
+}
+
+void ScSolverValueDialog::SetValue( double fValue )
+{
+ maEdValue.SetText( rtl::math::doubleToUString( fValue,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::GetpLocaleData()->getNumDecimalSep().GetChar(0), true ) );
+}
+
+double ScSolverValueDialog::GetValue() const
+{
+ String aInput = maEdValue.GetText();
+
+ const LocaleDataWrapper* pLocaleData = ScGlobal::GetpLocaleData();
+ rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
+ double fValue = rtl::math::stringToDouble( aInput,
+ pLocaleData->getNumDecimalSep().GetChar(0),
+ pLocaleData->getNumThousandSep().GetChar(0),
+ &eStatus, NULL );
+ return fValue;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/solverutil.cxx b/sc/source/ui/miscdlgs/solverutil.cxx
new file mode 100644
index 000000000000..f216864932ab
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solverutil.cxx
@@ -0,0 +1,231 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "solverutil.hxx"
+
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sheet/XSolver.hpp>
+#include <com/sun/star/sheet/XSolverDescription.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+#define SCSOLVER_SERVICE "com.sun.star.sheet.Solver"
+
+uno::Reference<sheet::XSolver> lcl_CreateSolver( const uno::Reference<uno::XInterface>& xIntFac,
+ const uno::Reference<uno::XComponentContext>& xCtx )
+{
+ uno::Reference<sheet::XSolver> xSolver;
+
+ uno::Reference<lang::XSingleComponentFactory> xCFac( xIntFac, uno::UNO_QUERY );
+ uno::Reference<lang::XSingleServiceFactory> xFac( xIntFac, uno::UNO_QUERY );
+ if ( xCFac.is() )
+ {
+ try
+ {
+ uno::Reference<uno::XInterface> xInterface = xCFac->createInstanceWithContext(xCtx);
+ xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY );
+ }
+ catch(uno::Exception&)
+ {
+ }
+ }
+ if ( !xSolver.is() && xFac.is() )
+ {
+ try
+ {
+ uno::Reference<uno::XInterface> xInterface = xFac->createInstance();
+ xSolver = uno::Reference<sheet::XSolver>( xInterface, uno::UNO_QUERY );
+ }
+ catch(uno::Exception&)
+ {
+ }
+ }
+
+ return xSolver;
+}
+
+// static
+void ScSolverUtil::GetImplementations( uno::Sequence<rtl::OUString>& rImplNames,
+ uno::Sequence<rtl::OUString>& rDescriptions )
+{
+ rImplNames.realloc(0); // clear
+ rDescriptions.realloc(0);
+ sal_Int32 nCount = 0;
+
+ uno::Reference<uno::XComponentContext> xCtx;
+ uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory();
+ uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
+ try
+ {
+ xPropset->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xCtx;
+ }
+ catch ( uno::Exception & )
+ {
+ }
+
+ uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY );
+ if ( xCtx.is() && xEnAc.is() )
+ {
+ uno::Reference<container::XEnumeration> xEnum =
+ xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCSOLVER_SERVICE)) );
+ if ( xEnum.is() )
+ {
+ while ( xEnum->hasMoreElements() )
+ {
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference<uno::XInterface> xIntFac;
+ aAny >>= xIntFac;
+ if ( xIntFac.is() )
+ {
+ uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY );
+ if ( xInfo.is() )
+ {
+ rtl::OUString sName = xInfo->getImplementationName();
+ rtl::OUString sDescription;
+
+ uno::Reference<sheet::XSolver> xSolver = lcl_CreateSolver( xIntFac, xCtx );
+ uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
+ if ( xDesc.is() )
+ sDescription = xDesc->getComponentDescription();
+
+ if ( !sDescription.getLength() )
+ sDescription = sName; // use implementation name if no description available
+
+ rImplNames.realloc( nCount+1 );
+ rImplNames[nCount] = sName;
+ rDescriptions.realloc( nCount+1 );
+ rDescriptions[nCount] = sDescription;
+ ++nCount;
+ }
+ }
+ }
+ }
+ }
+}
+
+// static
+uno::Reference<sheet::XSolver> ScSolverUtil::GetSolver( const rtl::OUString& rImplName )
+{
+ uno::Reference<sheet::XSolver> xSolver;
+
+ uno::Reference<uno::XComponentContext> xCtx;
+ uno::Reference<lang::XMultiServiceFactory> xMSF = comphelper::getProcessServiceFactory();
+ uno::Reference<beans::XPropertySet> xPropset(xMSF, uno::UNO_QUERY);
+ try
+ {
+ xPropset->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xCtx;
+ }
+ catch ( uno::Exception & )
+ {
+ }
+
+ uno::Reference<container::XContentEnumerationAccess> xEnAc( xMSF, uno::UNO_QUERY );
+ if ( xCtx.is() && xEnAc.is() )
+ {
+ uno::Reference<container::XEnumeration> xEnum =
+ xEnAc->createContentEnumeration( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SCSOLVER_SERVICE)) );
+ if ( xEnum.is() )
+ {
+ while ( xEnum->hasMoreElements() && !xSolver.is() )
+ {
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference<uno::XInterface> xIntFac;
+ aAny >>= xIntFac;
+ if ( xIntFac.is() )
+ {
+ uno::Reference<lang::XServiceInfo> xInfo( xIntFac, uno::UNO_QUERY );
+ if ( xInfo.is() )
+ {
+ rtl::OUString sName = xInfo->getImplementationName();
+ if ( sName == rImplName )
+ xSolver = lcl_CreateSolver( xIntFac, xCtx );
+ }
+ }
+ }
+ }
+ }
+
+ OSL_ENSURE( xSolver.is(), "can't get solver" );
+ return xSolver;
+}
+
+// static
+uno::Sequence<beans::PropertyValue> ScSolverUtil::GetDefaults( const rtl::OUString& rImplName )
+{
+ uno::Sequence<beans::PropertyValue> aDefaults;
+
+ uno::Reference<sheet::XSolver> xSolver = GetSolver( rImplName );
+ uno::Reference<beans::XPropertySet> xPropSet( xSolver, uno::UNO_QUERY );
+ if ( !xPropSet.is() )
+ {
+ // no XPropertySet - no options
+ return aDefaults;
+ }
+
+ // fill maProperties
+
+ uno::Reference<beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo();
+ OSL_ENSURE( xInfo.is(), "can't get property set info" );
+ if ( !xInfo.is() )
+ return aDefaults;
+
+ uno::Sequence<beans::Property> aPropSeq = xInfo->getProperties();
+ const sal_Int32 nSize = aPropSeq.getLength();
+ aDefaults.realloc(nSize);
+ sal_Int32 nValid = 0;
+ for (sal_Int32 nPos=0; nPos<nSize; ++nPos)
+ {
+ const beans::Property& rProp = aPropSeq[nPos];
+ uno::Any aValue = xPropSet->getPropertyValue( rProp.Name );
+ uno::TypeClass eClass = aValue.getValueTypeClass();
+ // only use properties of supported types
+ if ( eClass == uno::TypeClass_BOOLEAN || eClass == uno::TypeClass_LONG || eClass == uno::TypeClass_DOUBLE )
+ aDefaults[nValid++] = beans::PropertyValue( rProp.Name, -1, aValue, beans::PropertyState_DIRECT_VALUE );
+ }
+ aDefaults.realloc(nValid);
+
+ //! get user-visible names, sort by them
+
+ return aDefaults;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/solvrdlg.cxx b/sc/source/ui/miscdlgs/solvrdlg.cxx
new file mode 100644
index 000000000000..e718ba7be498
--- /dev/null
+++ b/sc/source/ui/miscdlgs/solvrdlg.cxx
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "rangelst.hxx"
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "solvrdlg.hrc"
+
+#define _SOLVRDLG_CXX
+#include "solvrdlg.hxx"
+#undef _SOLVERDLG_CXX
+
+
+#define ERRORBOX(s) ErrorBox( this, WinBits( WB_OK | WB_DEF_OK), s ).Execute()
+
+
+//============================================================================
+// class ScSolverDlg
+//----------------------------------------------------------------------------
+
+ScSolverDlg::ScSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ ScAddress aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_SOLVER ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaCell ( this, ScResId( FT_FORMULACELL ) ),
+ aEdFormulaCell ( this, this, ScResId( ED_FORMULACELL ) ),
+ aRBFormulaCell ( this, ScResId( RB_FORMULACELL ), &aEdFormulaCell, this ),
+ aFtTargetVal ( this, ScResId( FT_TARGETVAL ) ),
+ aEdTargetVal ( this, ScResId( ED_TARGETVAL ) ),
+ aFtVariableCell ( this, ScResId( FT_VARCELL ) ),
+ aEdVariableCell ( this, this, ScResId( ED_VARCELL ) ),
+ aRBVariableCell ( this, ScResId( RB_VARCELL ), &aEdVariableCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( aCursorPos ),
+ theVariableCell ( aCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( aCursorPos.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgInvalidVar ( ScResId( STR_INVALIDVAR ) ),
+ errMsgInvalidForm ( ScResId( STR_INVALIDFORM ) ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgInvalidVal ( ScResId( STR_INVALIDVAL ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScSolverDlg::~ScSolverDlg()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScSolverDlg::Init()
+{
+ String aStr;
+
+ aBtnOk. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScSolverDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScSolverDlg, GetFocusHdl );
+ aEdFormulaCell. SetGetFocusHdl ( aLink );
+ aRBFormulaCell. SetGetFocusHdl ( aLink );
+ aEdVariableCell.SetGetFocusHdl ( aLink );
+ aRBVariableCell.SetGetFocusHdl ( aLink );
+ aEdTargetVal. SetGetFocusHdl ( aLink );
+
+ aLink = LINK( this, ScSolverDlg, LoseFocusHdl );
+ aEdFormulaCell. SetLoseFocusHdl ( aLink );
+ aRBFormulaCell. SetLoseFocusHdl ( aLink );
+ aEdVariableCell.SetLoseFocusHdl ( aLink );
+ aRBVariableCell.SetLoseFocusHdl ( aLink );
+
+ theFormulaCell.Format( aStr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
+
+ aEdFormulaCell.SetText( aStr );
+ aEdFormulaCell.GrabFocus();
+ pEdActive = &aEdFormulaCell;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::Close()
+{
+ return DoClose( ScSolverDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ {
+ GrabFocus();
+ }
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if( pEdActive )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ ScAddress aAdr = rRef.aStart;
+ USHORT nFmt = ( aAdr.Tab() == nCurTab )
+ ? SCA_ABS
+ : SCA_ABS_3D;
+
+ aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
+ pEdActive->SetRefString( aStr );
+
+ if ( pEdActive == &aEdFormulaCell )
+ theFormulaCell = aAdr;
+ else if ( pEdActive == &aEdVariableCell )
+ theVariableCell = aAdr;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScSolverDlg::RaiseError( ScSolverErr eError )
+{
+ switch ( eError )
+ {
+ case SOLVERR_NOFORMULA:
+ ERRORBOX( errMsgNoFormula );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_FORMULA:
+ ERRORBOX( errMsgInvalidForm );
+ aEdFormulaCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_VARIABLE:
+ ERRORBOX( errMsgInvalidVar );
+ aEdVariableCell.GrabFocus();
+ break;
+
+ case SOLVERR_INVALID_TARGETVALUE:
+ ERRORBOX( errMsgInvalidVal );
+ aEdTargetVal.GrabFocus();
+ break;
+ }
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScSolverDlg::IsRefInputMode() const
+{
+ return pEdActive != NULL;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScSolverDlg::CheckTargetValue( String& rStrVal )
+{
+ sal_uInt32 n1 = 0;
+ double n2;
+
+ return pDoc->GetFormatTable()->IsNumberFormat( rStrVal, n1, n2 );
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScSolverDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ theTargetValStr = aEdTargetVal.GetText();
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. verweist die Formel-Koordinate wirklich auf eine Formelzelle?
+ // 3. wurde ein korrekter Zielwert eingegeben
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ USHORT nRes1 = theFormulaCell .Parse( aEdFormulaCell.GetText(), pDoc, eConv );
+ USHORT nRes2 = theVariableCell.Parse( aEdVariableCell.GetText(), pDoc, eConv );
+
+ if ( SCA_VALID == ( nRes1 & SCA_VALID ) )
+ {
+ if ( SCA_VALID == ( nRes2 & SCA_VALID ) )
+ {
+ if ( CheckTargetValue( theTargetValStr ) )
+ {
+ CellType eType;
+ pDoc->GetCellType( theFormulaCell.Col(),
+ theFormulaCell.Row(),
+ theFormulaCell.Tab(),
+ eType );
+
+ if ( CELLTYPE_FORMULA == eType )
+ {
+ ScSolveParam aOutParam( theFormulaCell,
+ theVariableCell,
+ theTargetValStr );
+ ScSolveItem aOutItem( SCITEM_SOLVEDATA, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_SOLVE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ else RaiseError( SOLVERR_NOFORMULA );
+ }
+ else RaiseError( SOLVERR_INVALID_TARGETVALUE );
+ }
+ else RaiseError( SOLVERR_INVALID_VARIABLE );
+ }
+ else RaiseError( SOLVERR_INVALID_FORMULA );
+ }
+ else if ( pBtn == &aBtnCancel )
+ {
+ Close();
+ }
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, GetFocusHdl, Control*, pCtrl )
+{
+ Edit* pEdit = NULL;
+ pEdActive = NULL;
+
+ if( (pCtrl == (Control*)&aEdFormulaCell) || (pCtrl == (Control*)&aRBFormulaCell) )
+ pEdit = pEdActive = &aEdFormulaCell;
+ else if( (pCtrl == (Control*)&aEdVariableCell) || (pCtrl == (Control*)&aRBVariableCell) )
+ pEdit = pEdActive = &aEdVariableCell;
+ else if( pCtrl == (Control*)&aEdTargetVal )
+ pEdit = &aEdTargetVal;
+
+ if( pEdit )
+ pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScSolverDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/strindlg.cxx b/sc/source/ui/miscdlgs/strindlg.cxx
new file mode 100644
index 000000000000..c35b4e9d6ce1
--- /dev/null
+++ b/sc/source/ui/miscdlgs/strindlg.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <tools/debug.hxx>
+
+#include "strindlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+#include <layout/layout-pre.hxx>
+
+#if ENABLE_LAYOUT
+#undef ScResId
+#define ScResId(x) #x
+#undef ModalDialog
+#define ModalDialog( parent, id ) Dialog( parent, "string-input.xml", id )
+#endif /* ENABLE_LAYOUT */
+
+//==================================================================
+
+ScStringInputDlg::ScStringInputDlg( Window* pParent,
+ const String& rTitle,
+ const String& rEditTitle,
+ const String& rDefault,
+ ULONG nHelpId ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_STRINPUT ) ),
+ //
+ aFtEditTitle ( this, ScResId( FT_LABEL ) ),
+ aEdInput ( this, ScResId( ED_INPUT ) ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) )
+{
+ SetHelpId( nHelpId );
+ SetText( rTitle );
+ aFtEditTitle.SetText( rEditTitle );
+ aEdInput.SetText( rDefault );
+ aEdInput.SetSelection(Selection(SELECTION_MIN, SELECTION_MAX));
+
+ // HelpId for Edit different for different uses
+
+ if ( nHelpId == FID_TAB_APPEND )
+ aEdInput.SetHelpId( HID_SC_APPEND_NAME );
+ else if ( nHelpId == FID_TAB_RENAME )
+ aEdInput.SetHelpId( HID_SC_RENAME_NAME );
+ else if ( nHelpId == HID_SC_ADD_AUTOFMT )
+ aEdInput.SetHelpId( HID_SC_AUTOFMT_NAME );
+ else if ( nHelpId == HID_SC_REN_AFMT_DLG )
+ aEdInput.SetHelpId( HID_SC_REN_AFMT_NAME );
+ else if ( nHelpId == SID_RENAME_OBJECT )
+ aEdInput.SetHelpId( HID_SC_RENAME_OBJECT );
+ // #i68101#
+ else if ( nHelpId == SID_TITLE_DESCRIPTION_OBJECT )
+ aEdInput.SetHelpId( HID_SC_TITLE_DESCRIPTION_OBJECT );
+ else
+ DBG_ERRORFILE( "unknown ID" );
+
+ //-------------
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScStringInputDlg::GetInputString( String& rString ) const
+{
+ rString = aEdInput.GetText();
+}
+
+__EXPORT ScStringInputDlg::~ScStringInputDlg()
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
new file mode 100644
index 000000000000..e99c8d98ecfe
--- /dev/null
+++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tabbgcolordlg.cxx,v $
+ * $Revision: 1.0 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+//------------------------------------------------------------------
+
+#include "tabbgcolordlg.hxx"
+#include "scresid.hxx"
+#include "miscdlgs.hrc"
+
+#include <tools/debug.hxx>
+#include <tools/color.hxx>
+#include <sfx2/objsh.hxx>
+#include <svx/xtable.hxx>
+#include <svx/drawitem.hxx>
+#include <unotools/pathoptions.hxx>
+#include <tools/resid.hxx>
+#include <editeng/editrids.hrc>
+#include <editeng/eerdll.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+//==================================================================
+
+#define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)
+
+ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent,
+ const String& rTitle,
+ const String& rTabBgColorNoColorText,
+ const Color& rDefaultColor,
+ ULONG nHelpId ) :
+ ModalDialog ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ),
+ aBorderWin ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ),
+ aTabBgColorSet ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aTabBgColor ( rDefaultColor ),
+ aTabBgColorNoColorText ( rTabBgColorNoColorText ),
+ mnHelpId ( nHelpId )
+
+{
+ SetHelpId( nHelpId );
+ this->SetText( rTitle );
+ this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);
+
+ FillColorValueSets_Impl();
+ aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) );
+ aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) );
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const
+{
+ rColor = this->aTabBgColor;
+}
+
+ScTabBgColorDlg::~ScTabBgColorDlg()
+{
+}
+
+void ScTabBgColorDlg::FillColorValueSets_Impl()
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SfxPoolItem* pItem = NULL;
+ XColorTable* pColorTable = NULL;
+ ::boost::scoped_ptr<XColorTable> pOwnColorTable; // locally instantiated in case the doc shell doesn't have one.
+
+ const Size aSize15x15 = Size( 15, 15 );
+ const Size aSize10x10 = Size( 10, 10 );
+ const Size aSize5x5 = Size( 5, 5 );
+ USHORT nSelectedItem = 0;
+
+ DBG_ASSERT( pDocSh, "DocShell not found!" );
+
+ if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) )
+ pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+ if ( !pColorTable )
+ {
+ pOwnColorTable.reset(new XColorTable(SvtPathOptions().GetPalettePath()));
+ pColorTable = pOwnColorTable.get();
+ }
+ if ( pColorTable )
+ {
+ sal_uInt16 i = 0;
+ long nCount = pColorTable->Count();
+ XColorEntry* pEntry = NULL;
+ Color aColWhite( COL_WHITE );
+ String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) );
+ WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
+ aTabBgColorSet.SetText( aTabBgColorNoColorText );
+ aTabBgColorSet.SetStyle( nBits );
+ for ( i = 0; i < nCount; i++ )
+ {
+ pEntry = pColorTable->GetColor(i);
+ aTabBgColorSet.InsertItem( i + 1, pEntry->GetColor(), pEntry->GetName() );
+ if (pEntry->GetColor() == aTabBgColor)
+ nSelectedItem = (i + 1);
+ }
+
+ while ( i < 80 )
+ {
+ aTabBgColorSet.InsertItem( i + 1, aColWhite, aStrWhite );
+ i++;
+ }
+
+ if ( nCount > 80 )
+ {
+ aTabBgColorSet.SetStyle( nBits | WB_VSCROLL );
+ }
+ }
+ aTabBgColorSet.SetColCount( 10 );
+ aTabBgColorSet.SetLineCount( 10 );
+ aTabBgColorSet.CalcWindowSizePixel( aSize15x15 );
+ aTabBgColorSet.Format();
+ aTabBgColorSet.SelectItem(nSelectedItem);
+ aTabBgColorSet.Resize();
+}
+
+IMPL_LINK( ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, ValueSet*, EMPTYARG )
+/*
+ Handler, called when color selection is changed
+*/
+{
+ USHORT nItemId = aTabBgColorSet.GetSelectItemId();
+ Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColor = aColor;
+ EndDialog( TRUE );
+ return 0;
+}
+
+IMPL_LINK( ScTabBgColorDlg, TabBgColorOKHdl_Impl, OKButton*, EMPTYARG )
+{
+
+// Handler, called when the OK button is pushed
+
+ USHORT nItemId = aTabBgColorSet.GetSelectItemId();
+ Color aColor = nItemId ? ( aTabBgColorSet.GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColor = aColor;
+ EndDialog( TRUE );
+ return 0;
+}
+
+ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet( Control* pParent, const ResId& rResId, ScTabBgColorDlg* pTabBgColorDlg ) :
+ ValueSet(pParent, rResId)
+{
+ aTabBgColorDlg = pTabBgColorDlg;
+}
+
+void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
+{
+ switch ( rKEvt.GetKeyCode().GetCode() )
+ {
+ case KEY_SPACE:
+ case KEY_RETURN:
+ {
+ USHORT nItemId = GetSelectItemId();
+ const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
+ aTabBgColorDlg->aTabBgColor = aColor;
+ aTabBgColorDlg->EndDialog(TRUE);
+ }
+ break;
+ }
+ ValueSet::KeyInput(rKEvt);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/tabopdlg.cxx b/sc/source/ui/miscdlgs/tabopdlg.cxx
new file mode 100644
index 000000000000..7fe01494a49f
--- /dev/null
+++ b/sc/source/ui/miscdlgs/tabopdlg.cxx
@@ -0,0 +1,373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "uiitems.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "reffact.hxx"
+#include "tabopdlg.hrc"
+
+#define _TABOPDLG_CXX
+#include "tabopdlg.hxx"
+
+
+//============================================================================
+// class ScTabOpDlg
+//----------------------------------------------------------------------------
+
+ScTabOpDlg::ScTabOpDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScDocument* pDocument,
+ const ScRefAddress& rCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_TABOP ),
+ //
+ aFlVariables ( this, ScResId( FL_VARIABLES ) ),
+ aFtFormulaRange ( this, ScResId( FT_FORMULARANGE ) ),
+ aEdFormulaRange ( this, this, ScResId( ED_FORMULARANGE ) ),
+ aRBFormulaRange ( this, ScResId( RB_FORMULARANGE ), &aEdFormulaRange, this ),
+ aFtRowCell ( this, ScResId( FT_ROWCELL ) ),
+ aEdRowCell ( this, this, ScResId( ED_ROWCELL ) ),
+ aRBRowCell ( this, ScResId( RB_ROWCELL ), &aEdRowCell, this ),
+ aFtColCell ( this, ScResId( FT_COLCELL ) ),
+ aEdColCell ( this, this, ScResId( ED_COLCELL ) ),
+ aRBColCell ( this, ScResId( RB_COLCELL ), &aEdColCell, this ),
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ theFormulaCell ( rCursorPos ),
+ pDoc ( pDocument ),
+ nCurTab ( theFormulaCell.Tab() ),
+ pEdActive ( NULL ),
+ bDlgLostFocus ( FALSE ),
+ errMsgNoFormula ( ScResId( STR_NOFORMULA ) ),
+ errMsgNoColRow ( ScResId( STR_NOCOLROW ) ),
+ errMsgWrongFormula ( ScResId( STR_WRONGFORMULA ) ),
+ errMsgWrongRowCol ( ScResId( STR_WRONGROWCOL ) ),
+ errMsgNoColFormula ( ScResId( STR_NOCOLFORMULA ) ),
+ errMsgNoRowFormula ( ScResId( STR_NOROWFORMULA ) )
+{
+ Init();
+ FreeResource();
+}
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScTabOpDlg::~ScTabOpDlg()
+{
+ Hide();
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScTabOpDlg::Init()
+{
+ aBtnOk. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+ aBtnCancel. SetClickHdl ( LINK( this, ScTabOpDlg, BtnHdl ) );
+
+ Link aLink = LINK( this, ScTabOpDlg, GetFocusHdl );
+ aEdFormulaRange.SetGetFocusHdl( aLink );
+ aRBFormulaRange.SetGetFocusHdl( aLink );
+ aEdRowCell. SetGetFocusHdl( aLink );
+ aRBRowCell. SetGetFocusHdl( aLink );
+ aEdColCell. SetGetFocusHdl( aLink );
+ aRBColCell. SetGetFocusHdl( aLink );
+
+ aLink = LINK( this, ScTabOpDlg, LoseFocusHdl );
+ aEdFormulaRange.SetLoseFocusHdl( aLink );
+ aRBFormulaRange.SetLoseFocusHdl( aLink );
+ aEdRowCell. SetLoseFocusHdl( aLink );
+ aRBRowCell. SetLoseFocusHdl( aLink );
+ aEdColCell. SetLoseFocusHdl( aLink );
+ aRBColCell. SetLoseFocusHdl( aLink );
+
+ aEdFormulaRange.GrabFocus();
+ pEdActive = &aEdFormulaRange;
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScTabOpDlg::Close()
+{
+ return DoClose( ScTabOpDlgWrapper::GetChildWindowId() );
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+ if( pEdActive )
+ pEdActive->GrabFocus();
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( pEdActive )
+ {
+ ScAddress::Details aDetails(pDocP->GetAddressConvention(), 0, 0);
+
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(pEdActive);
+
+ String aStr;
+ USHORT nFmt = ( rRef.aStart.Tab() == nCurTab )
+ ? SCR_ABS
+ : SCR_ABS_3D;
+
+ if ( pEdActive == &aEdFormulaRange )
+ {
+ theFormulaCell.Set( rRef.aStart, false, false, false);
+ theFormulaEnd.Set( rRef.aEnd, false, false, false);
+ rRef.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdRowCell )
+ {
+ theRowCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+ else if ( pEdActive == &aEdColCell )
+ {
+ theColCell.Set( rRef.aStart, false, false, false);
+ rRef.aStart.Format( aStr, nFmt, pDocP, aDetails );
+ }
+
+ pEdActive->SetRefString( aStr );
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScTabOpDlg::RaiseError( ScTabOpErr eError )
+{
+ const String* pMsg = &errMsgNoFormula;
+ Edit* pEd = &aEdFormulaRange;
+
+ switch ( eError )
+ {
+ case TABOPERR_NOFORMULA:
+ pMsg = &errMsgNoFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_NOCOLROW:
+ pMsg = &errMsgNoColRow;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_WRONGFORMULA:
+ pMsg = &errMsgWrongFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGROW:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdRowCell;
+ break;
+
+ case TABOPERR_NOCOLFORMULA:
+ pMsg = &errMsgNoColFormula;
+ pEd = &aEdFormulaRange;
+ break;
+
+ case TABOPERR_WRONGCOL:
+ pMsg = &errMsgWrongRowCol;
+ pEd = &aEdColCell;
+ break;
+
+ case TABOPERR_NOROWFORMULA:
+ pMsg = &errMsgNoRowFormula;
+ pEd = &aEdFormulaRange;
+ break;
+ }
+
+ ErrorBox( this, WinBits( WB_OK_CANCEL | WB_DEF_OK), *pMsg ).Execute();
+ pEd->GrabFocus();
+}
+
+//----------------------------------------------------------------------------
+
+BOOL lcl_Parse( const String& rString, ScDocument* pDoc, SCTAB nCurTab,
+ ScRefAddress& rStart, ScRefAddress& rEnd )
+{
+ BOOL bRet = FALSE;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if ( rString.Search(':') != STRING_NOTFOUND )
+ bRet = ConvertDoubleRef( pDoc, rString, nCurTab, rStart, rEnd, eConv );
+ else
+ {
+ bRet = ConvertSingleRef( pDoc, rString, nCurTab, rStart, eConv );
+ rEnd = rStart;
+ }
+ return bRet;
+}
+
+//----------------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTabOpDlg, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnOk )
+ {
+ BYTE nMode = 3;
+ USHORT nError = 0;
+
+ // Zu ueberpruefen:
+ // 1. enthalten die Strings korrekte Tabellenkoordinaten/def.Namen?
+ // 2. IstFormelRang Zeile bei leerer Zeile bzw. Spalte bei leerer Spalte
+ // bzw. Einfachreferenz bei beidem?
+ // 3. Ist mindestens Zeile oder Spalte und Formel voll?
+
+ if (aEdFormulaRange.GetText().Len() == 0)
+ nError = TABOPERR_NOFORMULA;
+ else if (aEdRowCell.GetText().Len() == 0 &&
+ aEdColCell.GetText().Len() == 0)
+ nError = TABOPERR_NOCOLROW;
+ else if ( !lcl_Parse( aEdFormulaRange.GetText(), pDoc, nCurTab,
+ theFormulaCell, theFormulaEnd ) )
+ nError = TABOPERR_WRONGFORMULA;
+ else
+ {
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if (aEdRowCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdRowCell.GetText(), nCurTab,
+ theRowCell, eConv ))
+ nError = TABOPERR_WRONGROW;
+ else
+ {
+ if (aEdColCell.GetText().Len() == 0 &&
+ theFormulaCell.Col() != theFormulaEnd.Col())
+ nError = TABOPERR_NOCOLFORMULA;
+ else
+ nMode = 1;
+ }
+ }
+ if (aEdColCell.GetText().Len() > 0)
+ {
+ if (!ConvertSingleRef( pDoc, aEdColCell.GetText(), nCurTab,
+ theColCell, eConv ))
+ nError = TABOPERR_WRONGCOL;
+ else
+ {
+ if (nMode == 1) // beides
+ {
+ nMode = 2;
+ ConvertSingleRef( pDoc, aEdFormulaRange.GetText(), nCurTab,
+ theFormulaCell, eConv );
+ }
+ else if (theFormulaCell.Row() != theFormulaEnd.Row())
+ nError = TABOPERR_NOROWFORMULA;
+ else
+ nMode = 0;
+ }
+ }
+ }
+
+ if (nError)
+ RaiseError( (ScTabOpErr) nError );
+ else
+ {
+ ScTabOpParam aOutParam( theFormulaCell,
+ theFormulaEnd,
+ theRowCell,
+ theColCell,
+ nMode );
+ ScTabOpItem aOutItem( SID_TABOP, &aOutParam );
+
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_TABOP,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aOutItem, 0L, 0L );
+ Close();
+ }
+ }
+ else if ( pBtn == &aBtnCancel )
+ Close();
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, GetFocusHdl, Control*, pCtrl )
+{
+ if( (pCtrl == (Control*)&aEdFormulaRange) || (pCtrl == (Control*)&aRBFormulaRange) )
+ pEdActive = &aEdFormulaRange;
+ else if( (pCtrl == (Control*)&aEdRowCell) || (pCtrl == (Control*)&aRBRowCell) )
+ pEdActive = &aEdRowCell;
+ else if( (pCtrl == (Control*)&aEdColCell) || (pCtrl == (Control*)&aRBColCell) )
+ pEdActive = &aEdColCell;
+ else
+ pEdActive = NULL;
+
+ if( pEdActive )
+ pEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
+
+ return 0;
+}
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScTabOpDlg, LoseFocusHdl, Control*, EMPTYARG )
+{
+ bDlgLostFocus = !IsActive();
+ return 0;
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/textdlgs.cxx b/sc/source/ui/miscdlgs/textdlgs.cxx
new file mode 100644
index 000000000000..a6747798efdb
--- /dev/null
+++ b/sc/source/ui/miscdlgs/textdlgs.cxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+// ohne precompiled Headers uebersetzen !!!
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svxids.hrc>
+
+#include <editeng/flstitem.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include "textdlgs.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include <svx/svxids.hrc>
+#include <svl/intitem.hxx>
+#include <svx/flagsdef.hxx>
+// -----------------------------------------------------------------------
+
+ScCharDlg::ScCharDlg( Window* pParent, const SfxItemSet* pAttr,
+ const SfxObjectShell* pDocShell ) :
+ SfxTabDialog ( pParent, ScResId( RID_SCDLG_CHAR ), pAttr ),
+ rOutAttrs ( *pAttr ),
+ rDocShell ( *pDocShell )
+{
+ FreeResource();
+
+ AddTabPage( RID_SVXPAGE_CHAR_NAME );
+ AddTabPage( RID_SVXPAGE_CHAR_EFFECTS );
+ AddTabPage( RID_SVXPAGE_CHAR_POSITION );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScCharDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
+{
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch( nId )
+ {
+ case RID_SVXPAGE_CHAR_NAME:
+ {
+ SvxFontListItem aItem(*( (const SvxFontListItem*)
+ ( rDocShell.GetItem( SID_ATTR_CHAR_FONTLIST) ) ) );
+
+ aSet.Put (SvxFontListItem( aItem.GetFontList(), SID_ATTR_CHAR_FONTLIST));
+ rPage.PageCreated(aSet);
+ }
+ break;
+
+ case RID_SVXPAGE_CHAR_EFFECTS:
+ aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP));
+ rPage.PageCreated(aSet);
+ break;
+
+ default:
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+ScParagraphDlg::ScParagraphDlg( Window* pParent, const SfxItemSet* pAttr ) :
+ SfxTabDialog ( pParent, ScResId( RID_SCDLG_PARAGRAPH ), pAttr ),
+ rOutAttrs ( *pAttr )
+{
+ FreeResource();
+
+ SvtCJKOptions aCJKOptions;
+
+ AddTabPage( RID_SVXPAGE_STD_PARAGRAPH );
+ AddTabPage( RID_SVXPAGE_ALIGN_PARAGRAPH );
+ if ( aCJKOptions.IsAsianTypographyEnabled() )
+ AddTabPage( RID_SVXPAGE_PARA_ASIAN);
+ else
+ RemoveTabPage( RID_SVXPAGE_PARA_ASIAN );
+ AddTabPage( RID_SVXPAGE_TABULATOR );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScParagraphDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
+{
+ switch( nId )
+ {
+ case RID_SVXPAGE_TABULATOR:
+ {
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ aSet.Put(SfxUInt16Item(SID_SVXTABULATORTABPAGE_CONTROLFLAGS,(TABTYPE_ALL &~TABTYPE_LEFT) |
+ (TABFILL_ALL &~TABFILL_NONE) ));
+ rPage.PageCreated(aSet);
+ }
+ break;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/miscdlgs/warnbox.cxx b/sc/source/ui/miscdlgs/warnbox.cxx
new file mode 100644
index 000000000000..4aeef5746004
--- /dev/null
+++ b/sc/source/ui/miscdlgs/warnbox.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "warnbox.hxx"
+
+#include "scmod.hxx"
+#include "inputopt.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+
+
+// ============================================================================
+
+ScCbWarningBox::ScCbWarningBox( Window* pParent, const String& rMsgStr, bool bDefYes ) :
+ WarningBox( pParent, WB_YES_NO | (bDefYes ? WB_DEF_YES : WB_DEF_NO), rMsgStr )
+{
+ SetDefaultCheckBoxText();
+}
+
+sal_Int16 ScCbWarningBox::Execute()
+{
+ sal_Int16 nRet = (GetStyle() & WB_DEF_YES) ? RET_YES : RET_NO;
+ if( IsDialogEnabled() )
+ {
+ nRet = WarningBox::Execute();
+ if( GetCheckBoxState() )
+ DisableDialog();
+ }
+ return nRet;
+}
+
+bool ScCbWarningBox::IsDialogEnabled()
+{
+ return true;
+}
+
+void ScCbWarningBox::DisableDialog()
+{
+}
+
+
+// ----------------------------------------------------------------------------
+
+ScReplaceWarnBox::ScReplaceWarnBox( Window* pParent ) :
+ ScCbWarningBox( pParent, String( ScResId( STR_REPLCELLSWARN ) ), true )
+{
+ SetHelpId( HID_SC_REPLCELLSWARN );
+}
+
+bool ScReplaceWarnBox::IsDialogEnabled()
+{
+ return SC_MOD()->GetInputOptions().GetReplaceCellsWarn() == TRUE;
+}
+
+void ScReplaceWarnBox::DisableDialog()
+{
+ ScModule* pScMod = SC_MOD();
+ ScInputOptions aInputOpt( pScMod->GetInputOptions() );
+ aInputOpt.SetReplaceCellsWarn( FALSE );
+ pScMod->SetInputOptions( aInputOpt );
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/namedlg/makefile.mk b/sc/source/ui/namedlg/makefile.mk
new file mode 100644
index 000000000000..7bc7b2653b6a
--- /dev/null
+++ b/sc/source/ui/namedlg/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=namedlg
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ namedlg.cxx
+
+SLOFILES = \
+ $(SLO)$/namedlg.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
new file mode 100644
index 000000000000..6130f1ccc09a
--- /dev/null
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -0,0 +1,651 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes ---------------------------------------------------------
+
+
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "global.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "docfunc.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "namedlg.hrc"
+
+#define _NAMEDLG_CXX
+#include "namedlg.hxx"
+#undef _NAMEDLG_CXX
+#include <vcl/msgbox.hxx>
+
+
+
+// defines -------------------------------------------------------------------
+
+#define ABS_SREF SCA_VALID \
+ | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB_ABSOLUTE
+#define ABS_DREF ABS_SREF \
+ | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE | SCA_TAB2_ABSOLUTE
+#define ABS_SREF3D ABS_SREF | SCA_TAB_3D
+#define ABS_DREF3D ABS_DREF | SCA_TAB_3D
+
+
+//============================================================================
+// Hilfsklasse: Merken der aktuellen Bereichsoptionen,
+// wenn ein Name in der ComboBox gefunden wird.
+
+struct SaveData
+{
+ SaveData()
+ : bCriteria(FALSE),bPrintArea(FALSE),
+ bColHeader(FALSE),bRowHeader(FALSE),
+ bDirty(FALSE) {}
+
+ void Clear()
+ {
+ aStrSymbol.Erase();
+ bCriteria = bPrintArea =
+ bColHeader = bRowHeader = FALSE;
+ bDirty = TRUE;
+ }
+
+ String aStrSymbol;
+ BOOL bCriteria:1;
+ BOOL bPrintArea:1;
+ BOOL bColHeader:1;
+ BOOL bRowHeader:1;
+ BOOL bDirty:1;
+};
+
+static SaveData* pSaveObj = NULL;
+
+#define SAVE_DATA() \
+ pSaveObj->aStrSymbol = aEdAssign.GetText(); \
+ pSaveObj->bCriteria = aBtnCriteria.IsChecked(); \
+ pSaveObj->bPrintArea = aBtnPrintArea.IsChecked(); \
+ pSaveObj->bColHeader = aBtnColHeader.IsChecked(); \
+ pSaveObj->bRowHeader = aBtnRowHeader.IsChecked(); \
+ pSaveObj->bDirty = TRUE;
+
+#define RESTORE_DATA() \
+ if ( pSaveObj->bDirty ) \
+ { \
+ aEdAssign.SetText( pSaveObj->aStrSymbol ); \
+ aBtnCriteria.Check( pSaveObj->bCriteria ); \
+ aBtnPrintArea.Check( pSaveObj->bPrintArea ); \
+ aBtnColHeader.Check( pSaveObj->bColHeader ); \
+ aBtnRowHeader.Check( pSaveObj->bRowHeader ); \
+ pSaveObj->bDirty = FALSE; \
+ }
+
+#define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
+
+
+//============================================================================
+// class ScNameDlg
+
+//----------------------------------------------------------------------------
+
+ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
+ ScViewData* ptrViewData,
+ const ScAddress& aCursorPos )
+
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ),
+ //
+ aFlName ( this, ScResId( FL_NAME ) ),
+ aEdName ( this, ScResId( ED_NAME ) ),
+ //
+ aFlAssign ( this, ScResId( FL_ASSIGN ) ),
+ aEdAssign ( this, this, ScResId( ED_ASSIGN ) ),
+ aRbAssign ( this, ScResId( RB_ASSIGN ), &aEdAssign, this ),
+ //
+ aFlType ( this, ScResId( FL_TYPE ) ),
+ aBtnPrintArea ( this, ScResId( BTN_PRINTAREA ) ),
+ aBtnColHeader ( this, ScResId( BTN_COLHEADER ) ),
+ aBtnCriteria ( this, ScResId( BTN_CRITERIA ) ),
+ aBtnRowHeader ( this, ScResId( BTN_ROWHEADER ) ),
+ //
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnMore ( this, ScResId( BTN_MORE ) ),
+ //
+ bSaved (FALSE),
+ aStrAdd ( ScResId( STR_ADD ) ),
+ aStrModify ( ScResId( STR_MODIFY ) ),
+ errMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
+ //
+ pViewData ( ptrViewData ),
+ pDoc ( ptrViewData->GetDocument() ),
+ aLocalRangeName ( *(pDoc->GetRangeName()) ),
+ theCursorPos ( aCursorPos ) // zum Berechnen der Referenzen
+{
+ pSaveObj = new SaveData;
+ Init();
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScNameDlg::~ScNameDlg()
+{
+ DELETEZ( pSaveObj );
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::Init()
+{
+ String aAreaStr;
+ ScRange aRange;
+
+ DBG_ASSERT( pViewData && pDoc, "ViewData oder Document nicht gefunden!" );
+
+ aBtnOk.SetClickHdl ( LINK( this, ScNameDlg, OkBtnHdl ) );
+ aBtnCancel.SetClickHdl ( LINK( this, ScNameDlg, CancelBtnHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScNameDlg, AddBtnHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
+ aEdAssign.SetGetFocusHdl( LINK( this, ScNameDlg, AssignGetFocusHdl ) );
+ aEdAssign.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
+ aEdName.SetModifyHdl ( LINK( this, ScNameDlg, EdModifyHdl ) );
+ aEdName.SetSelectHdl ( LINK( this, ScNameDlg, NameSelectHdl ) );
+
+ aBtnCriteria .Hide();
+ aBtnPrintArea.Hide();
+ aBtnColHeader.Hide();
+ aBtnRowHeader.Hide();
+
+ aBtnMore.AddWindow( &aFlType );
+ aBtnMore.AddWindow( &aBtnCriteria );
+ aBtnMore.AddWindow( &aBtnPrintArea );
+ aBtnMore.AddWindow( &aBtnColHeader );
+ aBtnMore.AddWindow( &aBtnRowHeader );
+
+ UpdateNames();
+
+ pViewData->GetSimpleArea( aRange );
+ aRange.Format( aAreaStr, ABS_DREF3D, pDoc,
+ ScAddress::Details(pDoc->GetAddressConvention(), 0, 0) );
+
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aEdAssign.GrabFocus();
+ aEdAssign.SetText( aAreaStr );
+ aEdAssign.SetSelection( theCurSel );
+ aEdName.GrabFocus();
+
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ if ( aEdName.GetEntryCount() > 0 )
+ aBtnAdd.SetText( aStrAdd );
+ UpdateChecks();
+ EdModifyHdl( 0 );
+
+ bSaved=TRUE;
+ SAVE_DATA()
+
+ //@BugID 54702
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+}
+
+//----------------------------------------------------------------------------
+BOOL ScNameDlg::IsRefInputMode() const
+{
+ return aEdAssign.IsEnabled();
+}
+
+void ScNameDlg::RefInputDone( BOOL bForced)
+{
+ ScAnyRefDlg::RefInputDone(bForced);
+ EdModifyHdl(&aEdAssign);
+}
+//----------------------------------------------------------------------------
+// Uebergabe eines mit der Maus selektierten Tabellenbereiches, der dann als
+// neue Selektion im Referenz-Edit angezeigt wird.
+
+
+void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
+{
+ if ( aEdAssign.IsEnabled() )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart(&aEdAssign);
+ String aRefStr;
+ rRef.Format( aRefStr, ABS_DREF3D, pDocP,
+ ScAddress::Details(pDocP->GetAddressConvention(), 0, 0) );
+ aEdAssign.SetRefString( aRefStr );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+BOOL __EXPORT ScNameDlg::Close()
+{
+ return DoClose( ScNameDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScNameDlg::SetActive()
+{
+ aEdAssign.GrabFocus();
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::UpdateChecks()
+{
+ USHORT nCurPos=0;
+
+ if(aLocalRangeName.SearchName( aEdName.GetText(), nCurPos))
+ {
+ ScRangeData* pData=(ScRangeData*)(aLocalRangeName.At( nCurPos ));
+ aBtnCriteria .Check( pData->HasType( RT_CRITERIA ) );
+ aBtnPrintArea.Check( pData->HasType( RT_PRINTAREA ) );
+ aBtnColHeader.Check( pData->HasType( RT_COLHEADER ) );
+ aBtnRowHeader.Check( pData->HasType( RT_ROWHEADER ) );
+ }
+
+ // Falls Edit-Feld leer ist: Typ-CheckBoxen deaktivieren:
+
+ if ( aEdName.GetText().Len() != 0 )
+ {
+ if ( !aFlType.IsEnabled() )
+ {
+ aFlType .Enable();
+ aBtnCriteria .Enable();
+ aBtnPrintArea.Enable();
+ aBtnColHeader.Enable();
+ aBtnRowHeader.Enable();
+ aFlAssign .Enable();
+ aEdAssign .Enable();
+ aRbAssign .Enable();
+ }
+ }
+ else if ( aFlType.IsEnabled() )
+ {
+ aFlType .Disable();
+ aBtnCriteria .Disable();
+ aBtnPrintArea.Disable();
+ aBtnColHeader.Disable();
+ aBtnRowHeader.Disable();
+ aFlAssign .Disable();
+ aEdAssign .Disable();
+ aRbAssign .Disable();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::UpdateNames()
+{
+ USHORT nRangeCount = aLocalRangeName.GetCount();
+
+ aEdName.SetUpdateMode( FALSE );
+ //-----------------------------------------------------------
+ USHORT nNamePos = aEdName.GetTopEntry();
+ aEdName.Clear();
+
+ aEdAssign.SetText( EMPTY_STRING );
+
+ if ( nRangeCount > 0 )
+ {
+ ScRangeData* pRangeData = NULL;
+ String aString;
+
+ for ( USHORT i=0; i<nRangeCount; i++ )
+ {
+ pRangeData = (ScRangeData*)(aLocalRangeName.At( i ));
+ if ( pRangeData )
+ {
+ if ( !pRangeData->HasType( RT_DATABASE )
+ && !pRangeData->HasType( RT_SHARED ) )
+ {
+ pRangeData->GetName( aString );
+ aEdName.InsertEntry( aString );
+ }
+ }
+ }
+ }
+ else
+ {
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ //-----------------------------------------------------------
+ aEdName.SetUpdateMode( TRUE );
+ aEdName.SetTopEntry(nNamePos);
+ aEdName.Invalidate();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScNameDlg::CalcCurTableAssign( String& aAssign, USHORT nCurPos )
+{
+ ScRangeData* pRangeData = (ScRangeData*)(aLocalRangeName.At( nCurPos ));
+
+ if ( pRangeData )
+ {
+ rtl::OUStringBuffer sBuffer;
+ pRangeData->UpdateSymbol( sBuffer, theCursorPos );
+ aAssign = sBuffer;
+ }
+ else
+ {
+ aAssign.Erase();
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+// ========
+
+IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
+{
+ if ( aBtnAdd.IsEnabled() )
+ AddBtnHdl( 0 );
+
+ if ( !aBtnAdd.IsEnabled() && !aBtnRemove.IsEnabled() )
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.ModifyRangeNames( aLocalRangeName );
+ Close();
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
+{
+ Close();
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNameDlg, CancelBtnHdl, void *, EMPTYARG )
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, AddBtnHdl, void *, EMPTYARG )
+{
+ BOOL bAdded = FALSE;
+ String aNewEntry = aEdName.GetText();
+ USHORT nNamePos = aEdName.GetTopEntry();
+ aNewEntry.EraseLeadingChars( ' ' );
+ aNewEntry.EraseTrailingChars( ' ' );
+
+ if ( aNewEntry.Len() > 0 )
+ {
+ if ( ScRangeData::IsNameValid( aNewEntry, pDoc ) )
+ {
+ if ( pDoc )
+ {
+ ScRangeData* pNewEntry = NULL;
+ RangeType nType = RT_NAME;
+ USHORT nFoundAt = 0;
+ String theSymbol = aEdAssign.GetText();
+ String aStrPos;
+ String aStrArea;
+
+ pNewEntry = new ScRangeData( pDoc,
+ aNewEntry,
+ theSymbol,
+ theCursorPos,
+ nType );
+ if (pNewEntry)
+ {
+ nType = nType
+ | (aBtnRowHeader .IsChecked() ? RT_ROWHEADER : RangeType(0))
+ | (aBtnColHeader .IsChecked() ? RT_COLHEADER : RangeType(0))
+ | (aBtnPrintArea .IsChecked() ? RT_PRINTAREA : RangeType(0))
+ | (aBtnCriteria .IsChecked() ? RT_CRITERIA : RangeType(0));
+ pNewEntry->AddType(nType);
+ }
+
+ // theSymbol gueltig?
+ // (= konnte theSymbol im ScRangeData-Ctor
+ // in ein Token-Array uebersetzt werden?)
+ if ( 0 == pNewEntry->GetErrCode() )
+ {
+ // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
+ if ( aLocalRangeName.SearchName( aNewEntry, nFoundAt ) )
+ { // alten Index uebernehmen
+ pNewEntry->SetIndex(
+ ((ScRangeData*)(aLocalRangeName.At(nFoundAt)))->GetIndex() );
+ aLocalRangeName.AtFree( nFoundAt );
+ }
+ else
+ pSaveObj->Clear();
+
+ if ( !aLocalRangeName.Insert( pNewEntry ) )
+ delete pNewEntry;
+
+ UpdateNames();
+ bSaved=FALSE;
+ RESTORE_DATA()
+ aEdName.SetText(EMPTY_STRING);
+ aEdName.GrabFocus();
+ UpdateChecks();
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+
+ bAdded = TRUE;
+ }
+ else // theSymbol ungueltig
+ {
+ delete pNewEntry;
+ ERRORBOX( errMsgInvalidSym );
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aEdAssign.GrabFocus();
+ }
+ }
+ }
+ else
+ {
+ ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME) );
+ aEdName.SetSelection( Selection( 0, SELECTION_MAX ) );
+ aEdName.GrabFocus();
+ }
+ }
+
+ aEdName.SetTopEntry(nNamePos);
+ return bAdded;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, RemoveBtnHdl, void *, EMPTYARG )
+{
+ USHORT nRemoveAt = 0;
+ const String aStrEntry = aEdName.GetText();
+
+ if ( aLocalRangeName.SearchName( aStrEntry, nRemoveAt ) )
+ {
+ String aStrDelMsg = ScGlobal::GetRscString( STR_QUERY_DELENTRY );
+ String aMsg = aStrDelMsg.GetToken( 0, '#' );
+
+ aMsg += aStrEntry;
+ aMsg += aStrDelMsg.GetToken( 1, '#' );
+
+ if ( RET_YES ==
+ QueryBox( this, WinBits( WB_YES_NO | WB_DEF_YES ), aMsg ).Execute() )
+ {
+ aLocalRangeName.AtFree( nRemoveAt );
+ UpdateNames();
+ UpdateChecks();
+ bSaved=FALSE;
+ RESTORE_DATA()
+ theCurSel = Selection( 0, SELECTION_MAX );
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ }
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, NameSelectHdl, void *, EMPTYARG )
+{
+ USHORT nAtPos;
+
+ if ( aLocalRangeName.SearchName( aEdName.GetText(), nAtPos ) )
+ {
+ String aSymbol;
+ ScRangeData* pData = (ScRangeData*)(aLocalRangeName.At( nAtPos ));
+
+ if ( pData )
+ {
+ pData->GetSymbol( aSymbol );
+ CalcCurTableAssign( aSymbol, nAtPos );
+ aEdAssign.SetText( aSymbol );
+ aBtnAdd.SetText( aStrModify );
+ theCurSel = Selection( 0, SELECTION_MAX );
+ }
+ }
+ UpdateChecks();
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScNameDlg, EdModifyHdl, Edit *, pEd )
+{
+ String theName = aEdName.GetText();
+ String theSymbol = aEdAssign.GetText();
+ BOOL bNameFound = (COMBOBOX_ENTRY_NOTFOUND
+ != aEdName.GetEntryPos( theName ));
+
+ if ( pEd == &aEdName )
+ {
+ if ( theName.Len() == 0 )
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ aFlAssign.Disable();
+ aEdAssign.Disable();
+ aRbAssign.Disable();
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Disable(FALSE); //! allgemeine Methode im ScAnyRefDlg
+ }
+ else
+ {
+ if ( bNameFound )
+ {
+ if ( aBtnAdd.GetText() != aStrModify )
+ aBtnAdd.SetText( aStrModify );
+
+ aBtnRemove.Enable();
+
+ if(!bSaved)
+ {
+ bSaved=TRUE;
+ SAVE_DATA()
+ }
+ NameSelectHdl( 0 );
+ }
+ else
+ {
+ if ( aBtnAdd.GetText() != aStrAdd )
+ aBtnAdd.SetText( aStrAdd );
+ aBtnRemove.Disable();
+
+ bSaved=FALSE;
+ RESTORE_DATA()
+ }
+ theSymbol = aEdAssign.GetText();
+
+ if ( theSymbol.Len() > 0 )
+ aBtnAdd.Enable();
+ else
+ aBtnAdd.Disable();
+
+ aFlAssign.Enable();
+ aEdAssign.Enable();
+ aRbAssign.Enable();
+ //@BugID 54702 raus mit dem Sch.
+ //SFX_APPWINDOW->Enable();
+ }
+ UpdateChecks();
+ theCurSel = Selection( 0, SELECTION_MAX );
+ }
+ else if ( pEd == &aEdAssign )
+ {
+ if ( (theName.Len()>0) && (theSymbol.Len()>0) )
+ {
+ aBtnAdd.Enable();
+ if ( bNameFound )
+ aBtnRemove.Enable();
+ }
+ else
+ {
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ }
+ }
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
+{
+ EdModifyHdl( &aEdAssign );
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScNameDlg, AssignGetFocusHdl, void *, EMPTYARG )
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
new file mode 100644
index 000000000000..bf78fc2428e0
--- /dev/null
+++ b/sc/source/ui/navipi/content.cxx
@@ -0,0 +1,1517 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svditer.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdxcgv.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/help.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/urlbmk.hxx>
+#include <stdlib.h>
+
+#include "content.hxx"
+#include "navipi.hxx"
+#include "global.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "rangenam.hxx"
+#include "dbcolect.hxx"
+#include "tablink.hxx" // fuer Loader
+#include "popmenu.hxx"
+#include "drwlayer.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "lnktrans.hxx"
+#include "cell.hxx"
+#include "dociter.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "navipi.hrc"
+#include "arealink.hxx"
+#include "navicfg.hxx"
+#include "navsett.hxx"
+#include "postit.hxx"
+#include "clipparam.hxx"
+
+using namespace com::sun::star;
+
+// Reihenfolge der Kategorien im Navigator -------------------------------------
+
+static USHORT pTypeList[SC_CONTENT_COUNT] =
+{
+ SC_CONTENT_ROOT, // ROOT (0) muss vorne stehen
+ SC_CONTENT_TABLE,
+ SC_CONTENT_RANGENAME,
+ SC_CONTENT_DBAREA,
+ SC_CONTENT_AREALINK,
+ SC_CONTENT_GRAPHIC,
+ SC_CONTENT_OLEOBJECT,
+ SC_CONTENT_NOTE,
+ SC_CONTENT_DRAWING
+};
+
+BOOL ScContentTree::bIsInDrag = FALSE;
+
+
+ScDocShell* ScContentTree::GetManualOrCurrent()
+{
+ ScDocShell* pSh = NULL;
+ if ( aManualDoc.Len() )
+ {
+ TypeId aScType = TYPE(ScDocShell);
+ SfxObjectShell* pObjSh = SfxObjectShell::GetFirst( &aScType );
+ while ( pObjSh && !pSh )
+ {
+ if ( pObjSh->GetTitle() == aManualDoc )
+ pSh = PTR_CAST( ScDocShell, pObjSh );
+ pObjSh = SfxObjectShell::GetNext( *pObjSh, &aScType );
+ }
+ }
+ else
+ {
+ // Current nur, wenn keine manuell eingestellt ist
+ // (damit erkannt wird, wenn das Dokument nicht mehr existiert)
+
+ SfxViewShell* pViewSh = SfxViewShell::Current();
+ if ( pViewSh )
+ {
+ SfxObjectShell* pObjSh = pViewSh->GetViewFrame()->GetObjectShell();
+ pSh = PTR_CAST( ScDocShell, pObjSh );
+ }
+ }
+
+ return pSh;
+}
+
+//
+// ScContentTree
+//
+
+ScContentTree::ScContentTree( Window* pParent, const ResId& rResId ) :
+ SvTreeListBox ( pParent, rResId ),
+ aEntryImages ( ScResId( RID_IMAGELIST_NAVCONT ) ),
+ aHCEntryImages ( ScResId( RID_IMAGELIST_H_NAVCONT ) ),
+ nRootType ( SC_CONTENT_ROOT ),
+ bHiddenDoc ( FALSE ),
+ pHiddenDocument ( NULL )
+{
+ USHORT i;
+ for (i=0; i<SC_CONTENT_COUNT; i++)
+ pPosList[pTypeList[i]] = i; // invers zum suchen
+
+ pParentWindow = (ScNavigatorDlg*)pParent;
+
+ pRootNodes[0] = NULL;
+ for (i=1; i<SC_CONTENT_COUNT; i++)
+ InitRoot(i);
+
+ SetNodeDefaultImages();
+
+ SetDoubleClickHdl( LINK( this, ScContentTree, ContentDoubleClickHdl ) );
+}
+
+ScContentTree::~ScContentTree()
+{
+}
+
+void ScContentTree::InitRoot( USHORT nType )
+{
+ if ( !nType )
+ return;
+
+ if ( nRootType && nRootType != nType ) // ausgeblendet ?
+ {
+ pRootNodes[nType] = NULL;
+ return;
+ }
+
+ const Image& rImage = aEntryImages.GetImage( nType );
+ String aName( ScResId( SCSTR_CONTENT_ROOT + nType ) );
+ // wieder an die richtige Position:
+ USHORT nPos = nRootType ? 0 : pPosList[nType]-1;
+ SvLBoxEntry* pNew = InsertEntry( aName, rImage, rImage, NULL, FALSE, nPos );
+
+ const Image& rHCImage = aHCEntryImages.GetImage( nType );
+ SetExpandedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
+ SetCollapsedEntryBmp( pNew, rHCImage, BMP_COLOR_HIGHCONTRAST );
+
+ pRootNodes[nType] = pNew;
+}
+
+void ScContentTree::ClearAll()
+{
+ Clear();
+ for (USHORT i=1; i<SC_CONTENT_COUNT; i++)
+ InitRoot(i);
+}
+
+void ScContentTree::ClearType(USHORT nType)
+{
+ if (!nType)
+ ClearAll();
+ else
+ {
+ SvLBoxEntry* pParent = pRootNodes[nType];
+ if ( !pParent || GetChildCount(pParent) ) // nicht, wenn ohne Children schon da
+ {
+ if (pParent)
+ GetModel()->Remove( pParent ); // mit allen Children
+ InitRoot( nType ); // ggf. neu eintragen
+ }
+ }
+}
+
+void ScContentTree::InsertContent( USHORT nType, const String& rValue )
+{
+ if (nType >= SC_CONTENT_COUNT)
+ {
+ DBG_ERROR("ScContentTree::InsertContent mit falschem Typ");
+ return;
+ }
+
+ SvLBoxEntry* pParent = pRootNodes[nType];
+ if (pParent)
+ InsertEntry( rValue, pParent );
+ else
+ {
+ DBG_ERROR("InsertContent ohne Parent");
+ }
+}
+
+void ScContentTree::GetEntryIndexes( USHORT& rnRootIndex, ULONG& rnChildIndex, SvLBoxEntry* pEntry ) const
+{
+ rnRootIndex = SC_CONTENT_ROOT;
+ rnChildIndex = SC_CONTENT_NOCHILD;
+
+ if( !pEntry )
+ return;
+
+ SvLBoxEntry* pParent = GetParent( pEntry );
+ bool bFound = false;
+ for( USHORT nRoot = 1; !bFound && (nRoot < SC_CONTENT_COUNT); ++nRoot )
+ {
+ if( pEntry == pRootNodes[ nRoot ] )
+ {
+ rnRootIndex = nRoot;
+ rnChildIndex = ~0UL;
+ bFound = true;
+ }
+ else if( pParent && (pParent == pRootNodes[ nRoot ]) )
+ {
+ rnRootIndex = nRoot;
+
+ // search the entry in all child entries of the parent
+ ULONG nEntry = 0;
+ SvLBoxEntry* pIterEntry = FirstChild( pParent );
+ while( !bFound && pIterEntry )
+ {
+ if ( pEntry == pIterEntry )
+ {
+ rnChildIndex = nEntry;
+ bFound = true; // exit the while loop
+ }
+ pIterEntry = NextSibling( pIterEntry );
+ ++nEntry;
+ }
+
+ bFound = true; // exit the for loop
+ }
+ }
+}
+
+ULONG ScContentTree::GetChildIndex( SvLBoxEntry* pEntry ) const
+{
+ USHORT nRoot;
+ ULONG nChild;
+ GetEntryIndexes( nRoot, nChild, pEntry );
+ return nChild;
+}
+
+String lcl_GetDBAreaRange( ScDocument* pDoc, const String& rDBName )
+{
+ String aRet;
+ if (pDoc)
+ {
+ ScDBCollection* pDbNames = pDoc->GetDBCollection();
+ USHORT nCount = pDbNames->GetCount();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ ScDBData* pData = (*pDbNames)[i];
+ if ( pData->GetName() == rDBName )
+ {
+ ScRange aRange;
+ pData->GetArea(aRange);
+ aRange.Format( aRet, SCR_ABS_3D, pDoc );
+ break;
+ }
+ }
+ }
+ return aRet;
+}
+
+IMPL_LINK( ScContentTree, ContentDoubleClickHdl, ScContentTree *, EMPTYARG )
+{
+ USHORT nType;
+ ULONG nChild;
+ SvLBoxEntry* pEntry = GetCurEntry();
+ GetEntryIndexes( nType, nChild, pEntry );
+
+ if( pEntry && (nType != SC_CONTENT_ROOT) && (nChild != SC_CONTENT_NOCHILD) )
+ {
+ if ( bHiddenDoc )
+ return 0; //! spaeter...
+
+ String aText( GetEntryText( pEntry ) );
+
+ if ( aManualDoc.Len() )
+ pParentWindow->SetCurrentDoc( aManualDoc );
+
+ switch( nType )
+ {
+ case SC_CONTENT_TABLE:
+ pParentWindow->SetCurrentTableStr( aText );
+ break;
+
+ case SC_CONTENT_RANGENAME:
+ pParentWindow->SetCurrentCellStr( aText );
+ break;
+
+ case SC_CONTENT_DBAREA:
+ {
+ // #47905# Wenn gleiche Bereichs- und DB-Namen existieren, wird
+ // bei SID_CURRENTCELL der Bereichsname genommen.
+ // DB-Bereiche darum direkt ueber die Adresse anspringen.
+
+ String aRangeStr = lcl_GetDBAreaRange( GetSourceDocument(), aText );
+ if (aRangeStr.Len())
+ pParentWindow->SetCurrentCellStr( aRangeStr );
+ }
+ break;
+
+ case SC_CONTENT_OLEOBJECT:
+ case SC_CONTENT_GRAPHIC:
+ case SC_CONTENT_DRAWING:
+ pParentWindow->SetCurrentObject( aText );
+ break;
+
+ case SC_CONTENT_NOTE:
+ {
+ ScAddress aPos = GetNotePos( nChild );
+ pParentWindow->SetCurrentTable( aPos.Tab() );
+ pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
+ }
+ break;
+
+ case SC_CONTENT_AREALINK:
+ {
+ const ScAreaLink* pLink = GetLink( nChild );
+ if( pLink )
+ {
+ ScRange aRange = pLink->GetDestArea();
+ String aRangeStr;
+ ScDocument* pSrcDoc = GetSourceDocument();
+ aRange.Format( aRangeStr, SCR_ABS_3D, pSrcDoc, pSrcDoc->GetAddressConvention() );
+ pParentWindow->SetCurrentCellStr( aRangeStr );
+ }
+ }
+ break;
+ }
+
+ ScNavigatorDlg::ReleaseFocus(); // set focus into document
+ }
+
+ return 0;
+}
+
+void ScContentTree::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ SvTreeListBox::MouseButtonDown( rMEvt );
+ StoreSettings();
+}
+
+void ScContentTree::KeyInput( const KeyEvent& rKEvt )
+{
+ BOOL bUsed = FALSE;
+
+ const KeyCode aCode = rKEvt.GetKeyCode();
+ if (aCode.GetCode() == KEY_RETURN)
+ {
+ switch (aCode.GetModifier())
+ {
+ case KEY_MOD1:
+ ToggleRoot(); // toggle root mode (as in Writer)
+ bUsed = TRUE;
+ break;
+ case 0:
+ {
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if( pEntry )
+ {
+ USHORT nType;
+ ULONG nChild;
+ GetEntryIndexes( nType, nChild, pEntry );
+
+ if( (nType != SC_CONTENT_ROOT) && (nChild == SC_CONTENT_NOCHILD) )
+ {
+ String aText( GetEntryText( pEntry ) );
+ if ( IsExpanded( pEntry ) )
+ Collapse( pEntry );
+ else
+ Expand( pEntry );
+ }
+ else
+ ContentDoubleClickHdl(0); // select content as if double clicked
+ }
+
+ bUsed = TRUE;
+ }
+ break;
+ }
+ }
+ StoreSettings();
+
+ if( !bUsed )
+ SvTreeListBox::KeyInput(rKEvt);
+}
+
+//BOOL __EXPORT ScContentTree::Drop( const DropEvent& rEvt )
+//{
+// return pParentWindow->Drop(rEvt); // Drop auf Navigator
+//}
+
+//BOOL __EXPORT ScContentTree::QueryDrop( DropEvent& rEvt )
+//{
+// return pParentWindow->QueryDrop(rEvt); // Drop auf Navigator
+//}
+
+sal_Int8 ScContentTree::AcceptDrop( const AcceptDropEvent& /* rEvt */ )
+{
+ return DND_ACTION_NONE;
+}
+
+sal_Int8 ScContentTree::ExecuteDrop( const ExecuteDropEvent& /* rEvt */ )
+{
+ return DND_ACTION_NONE;
+}
+
+void ScContentTree::StartDrag( sal_Int8 /* nAction */, const Point& /* rPosPixel */ )
+{
+ DoDrag();
+}
+
+void ScContentTree::DragFinished( sal_Int8 /* nAction */ )
+{
+}
+
+void __EXPORT ScContentTree::Command( const CommandEvent& rCEvt )
+{
+ BOOL bDone = FALSE;
+
+ switch ( rCEvt.GetCommand() )
+ {
+ case COMMAND_STARTDRAG:
+ // Aus dem ExecuteDrag heraus kann der Navigator geloescht werden
+ // (beim Umschalten auf einen anderen Dokument-Typ), das wuerde aber
+ // den StarView MouseMove-Handler, der Command() aufruft, umbringen.
+ // Deshalb Drag&Drop asynchron:
+
+// DoDrag();
+
+ Application::PostUserEvent( STATIC_LINK( this, ScContentTree, ExecDragHdl ) );
+
+ bDone = TRUE;
+ break;
+
+ case COMMAND_CONTEXTMENU:
+ {
+ // Drag-Drop Modus
+
+ PopupMenu aPop;
+ ScPopupMenu aDropMenu( ScResId( RID_POPUP_DROPMODE ) );
+ aDropMenu.CheckItem( RID_DROPMODE_URL + pParentWindow->GetDropMode() );
+ aPop.InsertItem( 1, pParentWindow->GetStrDragMode() );
+ aPop.SetPopupMenu( 1, &aDropMenu );
+
+ // angezeigtes Dokument
+
+ ScPopupMenu aDocMenu;
+ aDocMenu.SetMenuFlags( aDocMenu.GetMenuFlags() | MENU_FLAG_NOAUTOMNEMONICS );
+ USHORT i=0;
+ USHORT nPos=0;
+ // geladene Dokumente
+ ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ while ( pSh )
+ {
+ if ( pSh->ISA(ScDocShell) )
+ {
+ String aName = pSh->GetTitle();
+ String aEntry = aName;
+ if ( pSh == pCurrentSh )
+ aEntry += pParentWindow->aStrActive;
+ else
+ aEntry += pParentWindow->aStrNotActive;
+ aDocMenu.InsertItem( ++i, aEntry );
+ if ( !bHiddenDoc && aName == aManualDoc )
+ nPos = i;
+ }
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+ // "aktives Fenster"
+ aDocMenu.InsertItem( ++i, pParentWindow->aStrActiveWin );
+ if (!bHiddenDoc && !aManualDoc.Len())
+ nPos = i;
+ // verstecktes Dokument
+ if ( aHiddenTitle.Len() )
+ {
+ String aEntry = aHiddenTitle;
+ aEntry += pParentWindow->aStrHidden;
+ aDocMenu.InsertItem( ++i, aEntry );
+ if (bHiddenDoc)
+ nPos = i;
+ }
+ aDocMenu.CheckItem( nPos );
+ aPop.InsertItem( 2, pParentWindow->GetStrDisplay() );
+ aPop.SetPopupMenu( 2, &aDocMenu );
+
+ // ausfuehren
+
+ aPop.Execute( this, rCEvt.GetMousePosPixel() );
+
+ if ( aDropMenu.WasHit() ) // Drag-Drop Modus
+ {
+ USHORT nId = aDropMenu.GetSelected();
+ if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
+ pParentWindow->SetDropMode( nId - RID_DROPMODE_URL );
+ }
+ else if ( aDocMenu.WasHit() ) // angezeigtes Dokument
+ {
+ USHORT nId = aDocMenu.GetSelected();
+ String aName = aDocMenu.GetItemText(nId);
+ SelectDoc( aName );
+ }
+ }
+ break;
+ }
+
+ if (!bDone)
+ SvTreeListBox::Command(rCEvt);
+}
+
+void __EXPORT ScContentTree::RequestHelp( const HelpEvent& rHEvt )
+{
+ BOOL bDone = FALSE;
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
+ SvLBoxEntry* pEntry = GetEntry( aPos );
+ if ( pEntry )
+ {
+ BOOL bRet = FALSE;
+ String aHelpText;
+ SvLBoxEntry* pParent = GetParent(pEntry);
+ if ( !pParent ) // Top-Level ?
+ {
+ aHelpText = String::CreateFromInt32( GetChildCount(pEntry) );
+ aHelpText += ' ';
+ aHelpText += GetEntryText(pEntry);
+ bRet = TRUE;
+ }
+ else if ( pParent == pRootNodes[SC_CONTENT_NOTE] )
+ {
+ aHelpText = GetEntryText(pEntry); // Notizen als Help-Text
+ bRet = TRUE;
+ }
+ else if ( pParent == pRootNodes[SC_CONTENT_AREALINK] )
+ {
+ ULONG nIndex = GetChildIndex(pEntry);
+ if( nIndex != SC_CONTENT_NOCHILD )
+ {
+ const ScAreaLink* pLink = GetLink(nIndex);
+ if (pLink)
+ {
+ aHelpText = pLink->GetFile(); // Source-Datei als Help-Text
+ bRet = TRUE;
+ }
+ }
+ }
+
+ if (bRet)
+ {
+ SvLBoxTab* pTab;
+ SvLBoxString* pItem = (SvLBoxString*)(GetItem( pEntry, aPos.X(), &pTab ));
+ if( pItem )
+ {
+ aPos = GetEntryPosition( pEntry );
+ aPos.X() = GetTabPos( pEntry, pTab );
+ aPos = OutputToScreenPixel(aPos);
+ Size aSize( pItem->GetSize( this, pEntry ) );
+
+ Rectangle aItemRect( aPos, aSize );
+ Help::ShowQuickHelp( this, aItemRect, aHelpText );
+ bDone = TRUE;
+ }
+ }
+ }
+ }
+ if (!bDone)
+ Window::RequestHelp( rHEvt );
+}
+
+ScDocument* ScContentTree::GetSourceDocument()
+{
+ if (bHiddenDoc)
+ return pHiddenDocument;
+ else
+ {
+ ScDocShell* pSh = GetManualOrCurrent();
+ if (pSh)
+ return pSh->GetDocument();
+
+ }
+ return NULL;
+}
+
+void ScContentTree::Refresh( USHORT nType )
+{
+ if ( bHiddenDoc && !pHiddenDocument )
+ return; // anderes Dokument angezeigt
+
+ // wenn sich nichts geaendert hat, gleich abbrechen (gegen Geflacker)
+
+ if ( nType == SC_CONTENT_NOTE )
+ if (!NoteStringsChanged())
+ return;
+ if ( nType == SC_CONTENT_GRAPHIC )
+ if (!DrawNamesChanged(SC_CONTENT_GRAPHIC))
+ return;
+ if ( nType == SC_CONTENT_OLEOBJECT )
+ if (!DrawNamesChanged(SC_CONTENT_OLEOBJECT))
+ return;
+ if ( nType == SC_CONTENT_DRAWING )
+ if (!DrawNamesChanged(SC_CONTENT_DRAWING))
+ return;
+
+ SetUpdateMode(FALSE);
+
+ ClearType( nType );
+
+ if ( !nType || nType == SC_CONTENT_TABLE )
+ GetTableNames();
+ if ( !nType || nType == SC_CONTENT_RANGENAME )
+ GetAreaNames();
+ if ( !nType || nType == SC_CONTENT_DBAREA )
+ GetDbNames();
+ if ( !nType || nType == SC_CONTENT_GRAPHIC )
+ GetGraphicNames();
+ if ( !nType || nType == SC_CONTENT_OLEOBJECT )
+ GetOleNames();
+ if ( !nType || nType == SC_CONTENT_DRAWING )
+ GetDrawingNames();
+ if ( !nType || nType == SC_CONTENT_NOTE )
+ GetNoteStrings();
+ if ( !nType || nType == SC_CONTENT_AREALINK )
+ GetLinkNames();
+
+ ApplySettings();
+ SetUpdateMode(TRUE);
+}
+
+void ScContentTree::GetTableNames()
+{
+ if ( nRootType && nRootType != SC_CONTENT_TABLE ) // ausgeblendet ?
+ return;
+
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ String aName;
+ SCTAB nCount = pDoc->GetTableCount();
+ for ( SCTAB i=0; i<nCount; i++ )
+ {
+ pDoc->GetName( i, aName );
+ InsertContent( SC_CONTENT_TABLE, aName );
+ }
+}
+
+void ScContentTree::GetAreaNames()
+{
+ if ( nRootType && nRootType != SC_CONTENT_RANGENAME ) // ausgeblendet ?
+ return;
+
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ USHORT nCount = pRangeNames->GetCount();
+ if ( nCount > 0 )
+ {
+ USHORT nValidCount = 0;
+ ScRange aDummy;
+ USHORT i;
+ for ( i=0; i<nCount; i++ )
+ {
+ ScRangeData* pData = (*pRangeNames)[i];
+ if (pData->IsValidReference(aDummy))
+ nValidCount++;
+ }
+ if ( nValidCount )
+ {
+ ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
+ USHORT j;
+ for ( i=0, j=0; i<nCount; i++ )
+ {
+ ScRangeData* pData = (*pRangeNames)[i];
+ if (pData->IsValidReference(aDummy))
+ ppSortArray[j++] = pData;
+ }
+#ifndef ICC
+ qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ &ScRangeData_QsortNameCompare );
+#else
+ qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
+ ICCQsortNameCompare );
+#endif
+ for ( j=0; j<nValidCount; j++ )
+ InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
+ delete [] ppSortArray;
+ }
+ }
+}
+
+void ScContentTree::GetDbNames()
+{
+ if ( nRootType && nRootType != SC_CONTENT_DBAREA ) // ausgeblendet ?
+ return;
+
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ ScDBCollection* pDbNames = pDoc->GetDBCollection();
+ USHORT nCount = pDbNames->GetCount();
+ if ( nCount > 0 )
+ {
+ String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) );
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ ScDBData* pData = (*pDbNames)[i];
+ String aStrName = pData->GetName();
+ if ( aStrName != aStrNoName )
+ InsertContent( SC_CONTENT_DBAREA, aStrName );
+ }
+ }
+}
+
+bool ScContentTree::IsPartOfType( USHORT nContentType, USHORT nObjIdentifier ) // static
+{
+ bool bRet = false;
+ switch ( nContentType )
+ {
+ case SC_CONTENT_GRAPHIC:
+ bRet = ( nObjIdentifier == OBJ_GRAF );
+ break;
+ case SC_CONTENT_OLEOBJECT:
+ bRet = ( nObjIdentifier == OBJ_OLE2 );
+ break;
+ case SC_CONTENT_DRAWING:
+ bRet = ( nObjIdentifier != OBJ_GRAF && nObjIdentifier != OBJ_OLE2 ); // everything else
+ break;
+ default:
+ DBG_ERROR("unknown content type");
+ }
+ return bRet;
+}
+
+void ScContentTree::GetDrawNames( USHORT nType )
+{
+ if ( nRootType && nRootType != nType ) // ausgeblendet ?
+ return;
+
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ // iterate in flat mode for groups
+ SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
+
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ SfxObjectShell* pShell = pDoc->GetDocumentShell();
+ if (pDrawLayer && pShell)
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage,"Page ?");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, eIter );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
+ {
+ String aName = ScDrawLayer::GetVisibleName( pObject );
+ if (aName.Len())
+ InsertContent( nType, aName );
+ }
+
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+}
+
+void ScContentTree::GetGraphicNames()
+{
+ GetDrawNames( SC_CONTENT_GRAPHIC );
+}
+
+void ScContentTree::GetOleNames()
+{
+ GetDrawNames( SC_CONTENT_OLEOBJECT );
+}
+
+void ScContentTree::GetDrawingNames()
+{
+ GetDrawNames( SC_CONTENT_DRAWING );
+}
+
+void ScContentTree::GetLinkNames()
+{
+ if ( nRootType && nRootType != SC_CONTENT_AREALINK ) // ausgeblendet ?
+ return;
+
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
+ const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
+ USHORT nCount = rLinks.Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if (pBase->ISA(ScAreaLink))
+ InsertContent( SC_CONTENT_AREALINK, ((ScAreaLink*)pBase)->GetSource() );
+
+ // in der Liste die Namen der Quellbereiche
+ }
+}
+
+const ScAreaLink* ScContentTree::GetLink( ULONG nIndex )
+{
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return NULL;
+
+ ULONG nFound = 0;
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ DBG_ASSERT(pLinkManager, "kein LinkManager am Dokument?");
+ const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
+ USHORT nCount = rLinks.Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if (pBase->ISA(ScAreaLink))
+ {
+ if (nFound == nIndex)
+ return (const ScAreaLink*) pBase;
+ ++nFound;
+ }
+ }
+
+ DBG_ERROR("Link nicht gefunden");
+ return NULL;
+}
+
+String lcl_NoteString( const ScPostIt& rNote )
+{
+ String aText = rNote.GetText();
+ xub_StrLen nAt;
+ while ( (nAt = aText.Search( '\n' )) != STRING_NOTFOUND )
+ aText.SetChar( nAt, ' ' );
+ return aText;
+}
+
+void ScContentTree::GetNoteStrings()
+{
+ if ( nRootType && nRootType != SC_CONTENT_NOTE ) // ausgeblendet ?
+ return;
+
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return;
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
+ for( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
+ if( const ScPostIt* pNote = pCell->GetNote() )
+ InsertContent( SC_CONTENT_NOTE, lcl_NoteString( *pNote ) );
+ }
+}
+
+ScAddress ScContentTree::GetNotePos( ULONG nIndex )
+{
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return ScAddress();
+
+ ULONG nFound = 0;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if( pCell->HasNote() )
+ {
+ if (nFound == nIndex)
+ return ScAddress( aIter.GetCol(), aIter.GetRow(), nTab ); // gefunden
+ ++nFound;
+ }
+ pCell = aIter.GetNext();
+ }
+ }
+
+ DBG_ERROR("Notiz nicht gefunden");
+ return ScAddress();
+}
+
+BOOL ScContentTree::NoteStringsChanged()
+{
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return FALSE;
+
+ SvLBoxEntry* pParent = pRootNodes[SC_CONTENT_NOTE];
+ if (!pParent)
+ return FALSE;
+
+ SvLBoxEntry* pEntry = FirstChild( pParent );
+
+ BOOL bEqual = TRUE;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
+ {
+ ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell && bEqual)
+ {
+ if( const ScPostIt* pNote = pCell->GetNote() )
+ {
+ if ( !pEntry )
+ bEqual = FALSE;
+ else
+ {
+ if ( lcl_NoteString( *pNote ) != GetEntryText(pEntry) )
+ bEqual = FALSE;
+
+ pEntry = NextSibling( pEntry );
+ }
+ }
+ pCell = aIter.GetNext();
+ }
+ }
+
+ if ( pEntry )
+ bEqual = FALSE; // kommt noch was
+
+ return !bEqual;
+}
+
+BOOL ScContentTree::DrawNamesChanged( USHORT nType )
+{
+ ScDocument* pDoc = GetSourceDocument();
+ if (!pDoc)
+ return FALSE;
+
+ SvLBoxEntry* pParent = pRootNodes[nType];
+ if (!pParent)
+ return FALSE;
+
+ SvLBoxEntry* pEntry = FirstChild( pParent );
+
+ // iterate in flat mode for groups
+ SdrIterMode eIter = ( nType == SC_CONTENT_DRAWING ) ? IM_FLAT : IM_DEEPNOGROUPS;
+
+ BOOL bEqual = TRUE;
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ SfxObjectShell* pShell = pDoc->GetDocumentShell();
+ if (pDrawLayer && pShell)
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount && bEqual; nTab++)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage,"Page ?");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, eIter );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && bEqual)
+ {
+ if ( IsPartOfType( nType, pObject->GetObjIdentifier() ) )
+ {
+ if ( !pEntry )
+ bEqual = FALSE;
+ else
+ {
+ if ( ScDrawLayer::GetVisibleName( pObject ) != GetEntryText(pEntry) )
+ bEqual = FALSE;
+
+ pEntry = NextSibling( pEntry );
+ }
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+
+ if ( pEntry )
+ bEqual = FALSE; // kommt noch was
+
+ return !bEqual;
+}
+
+BOOL lcl_GetRange( ScDocument* pDoc, USHORT nType, const String& rName, ScRange& rRange )
+{
+ BOOL bFound = FALSE;
+ USHORT nPos;
+
+ if ( nType == SC_CONTENT_RANGENAME )
+ {
+ ScRangeName* pList = pDoc->GetRangeName();
+ if (pList)
+ if (pList->SearchName( rName, nPos ))
+ if ( (*pList)[nPos]->IsValidReference( rRange ) )
+ bFound = TRUE;
+ }
+ else if ( nType == SC_CONTENT_DBAREA )
+ {
+ ScDBCollection* pList = pDoc->GetDBCollection();
+ if (pList)
+ if (pList->SearchName( rName, nPos ))
+ {
+ SCTAB nTab;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ (*pList)[nPos]->GetArea(nTab,nCol1,nRow1,nCol2,nRow2);
+ rRange = ScRange( nCol1,nRow1,nTab, nCol2,nRow2,nTab );
+ bFound = TRUE;
+ }
+ }
+
+ return bFound;
+}
+
+void lcl_DoDragObject( ScDocShell* pSrcShell, const String& rName, USHORT nType, Window* pWin )
+{
+ ScDocument* pSrcDoc = pSrcShell->GetDocument();
+ ScDrawLayer* pModel = pSrcDoc->GetDrawLayer();
+ if (pModel)
+ {
+ BOOL bOle = ( nType == SC_CONTENT_OLEOBJECT );
+ BOOL bGraf = ( nType == SC_CONTENT_GRAPHIC );
+ USHORT nDrawId = sal::static_int_cast<USHORT>( bOle ? OBJ_OLE2 : ( bGraf ? OBJ_GRAF : OBJ_GRUP ) );
+ SCTAB nTab = 0;
+ SdrObject* pObject = pModel->GetNamedObject( rName, nDrawId, nTab );
+ if (pObject)
+ {
+ SdrView aEditView( pModel );
+ aEditView.ShowSdrPage(aEditView.GetModel()->GetPage(nTab));
+ SdrPageView* pPV = aEditView.GetSdrPageView();
+ aEditView.MarkObj(pObject, pPV);
+
+ SdrModel* pDragModel = aEditView.GetAllMarkedModel();
+
+ TransferableObjectDescriptor aObjDesc;
+ pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pDragModel, pSrcShell, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ pTransferObj->SetDragSourceObj( pObject, nTab );
+ pTransferObj->SetDragSourceFlags( SC_DROP_NAVIGATOR );
+
+ SC_MOD()->SetDragObject( NULL, pTransferObj );
+ pWin->ReleaseMouse();
+ pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+ }
+ }
+}
+
+void lcl_DoDragCells( ScDocShell* pSrcShell, const ScRange& rRange, USHORT nFlags, Window* pWin )
+{
+ ScMarkData aMark;
+ aMark.SelectTable( rRange.aStart.Tab(), TRUE );
+ aMark.SetMarkArea( rRange );
+
+ ScDocument* pSrcDoc = pSrcShell->GetDocument();
+ if ( !pSrcDoc->HasSelectedBlockMatrixFragment( rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row(),
+ aMark ) )
+ {
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScClipParam aClipParam(rRange, false);
+ pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aMark);
+ // pClipDoc->ExtendMerge( rRange, TRUE );
+
+ TransferableObjectDescriptor aObjDesc;
+ pSrcShell->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pSrcShell->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScTransferObj ctor
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ pTransferObj->SetDragSource( pSrcShell, aMark );
+ pTransferObj->SetDragSourceFlags( nFlags );
+
+ SC_MOD()->SetDragObject( pTransferObj, NULL ); // for internal D&D
+ pWin->ReleaseMouse();
+ pTransferObj->StartDrag( pWin, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+ }
+}
+
+void ScContentTree::DoDrag()
+{
+ ScDocumentLoader* pDocLoader = NULL;
+ bIsInDrag = TRUE;
+
+ ScModule* pScMod = SC_MOD();
+
+ USHORT nType;
+ ULONG nChild;
+ SvLBoxEntry* pEntry = GetCurEntry();
+ GetEntryIndexes( nType, nChild, pEntry );
+
+ if( pEntry &&
+ (nChild != SC_CONTENT_NOCHILD) &&
+ (nType != SC_CONTENT_ROOT) &&
+ (nType != SC_CONTENT_NOTE) &&
+ (nType != SC_CONTENT_AREALINK) )
+ {
+ String aText( GetEntryText( pEntry ) );
+
+ ScDocument* pLocalDoc = NULL; // fuer URL-Drop
+ String aDocName;
+ if (bHiddenDoc)
+ aDocName = aHiddenName;
+ else
+ {
+ ScDocShell* pDocSh = GetManualOrCurrent();
+ if (pDocSh)
+ {
+ if (pDocSh->HasName())
+ aDocName = pDocSh->GetMedium()->GetName();
+ else
+ pLocalDoc = pDocSh->GetDocument(); // Drop nur in dieses Dokument
+ }
+ }
+
+ BOOL bDoLinkTrans = FALSE; // use ScLinkTransferObj
+ String aLinkURL; // for ScLinkTransferObj
+ String aLinkText;
+
+ USHORT nDropMode = pParentWindow->GetDropMode();
+ switch ( nDropMode )
+ {
+ case SC_DROPMODE_URL:
+ {
+ String aUrl = aDocName;
+ aUrl += '#';
+ aUrl += aText;
+
+ pScMod->SetDragJump( pLocalDoc, aUrl, aText );
+
+ if (aDocName.Len())
+ {
+ // provide URL to outside only if the document has a name
+ // (without name, only internal D&D via SetDragJump)
+
+ aLinkURL = aUrl;
+ aLinkText = aText;
+ }
+ bDoLinkTrans = TRUE;
+ }
+ break;
+ case SC_DROPMODE_LINK:
+ {
+ if ( aDocName.Len() ) // link only to named documents
+ {
+ // for internal D&D, set flag to insert a link
+
+ switch ( nType )
+ {
+ case SC_CONTENT_TABLE:
+ pScMod->SetDragLink( aDocName, aText, EMPTY_STRING );
+ bDoLinkTrans = TRUE;
+ break;
+ case SC_CONTENT_RANGENAME:
+ case SC_CONTENT_DBAREA:
+ pScMod->SetDragLink( aDocName, EMPTY_STRING, aText );
+ bDoLinkTrans = TRUE;
+ break;
+
+ // other types cannot be linked
+ }
+ }
+ }
+ break;
+ case SC_DROPMODE_COPY:
+ {
+ ScDocShell* pSrcShell = NULL;
+ if ( bHiddenDoc )
+ {
+ String aFilter, aOptions;
+ pDocLoader = new ScDocumentLoader( aHiddenName, aFilter, aOptions );
+ if (!pDocLoader->IsError())
+ pSrcShell = pDocLoader->GetDocShell();
+ }
+ else
+ pSrcShell = GetManualOrCurrent();
+
+ if ( pSrcShell )
+ {
+ ScDocument* pSrcDoc = pSrcShell->GetDocument();
+ if ( nType == SC_CONTENT_RANGENAME || nType == SC_CONTENT_DBAREA )
+ {
+ ScRange aRange;
+ if ( lcl_GetRange( pSrcDoc, nType, aText, aRange ) )
+ {
+ lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR, this );
+ }
+ }
+ else if ( nType == SC_CONTENT_TABLE )
+ {
+ SCTAB nTab;
+ if ( pSrcDoc->GetTable( aText, nTab ) )
+ {
+ ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab );
+ lcl_DoDragCells( pSrcShell, aRange, SC_DROP_NAVIGATOR | SC_DROP_TABLE, this );
+ }
+ }
+ else if ( nType == SC_CONTENT_GRAPHIC || nType == SC_CONTENT_OLEOBJECT ||
+ nType == SC_CONTENT_DRAWING )
+ {
+ lcl_DoDragObject( pSrcShell, aText, nType, this );
+
+ // in ExecuteDrag kann der Navigator geloescht worden sein
+ // -> nicht mehr auf Member zugreifen !!!
+ }
+ }
+ }
+ break;
+ }
+
+ if (bDoLinkTrans)
+ {
+ ScLinkTransferObj* pTransferObj = new ScLinkTransferObj;
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( aLinkURL.Len() )
+ pTransferObj->SetLinkURL( aLinkURL, aLinkText );
+
+ // SetDragJump / SetDragLink has been done above
+
+ ReleaseMouse();
+ pTransferObj->StartDrag( this, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+ }
+ }
+
+ bIsInDrag = FALSE; // static Member
+
+ delete pDocLoader; // falls Dokument zum Draggen geladen wurde
+}
+
+IMPL_STATIC_LINK(ScContentTree, ExecDragHdl, void*, EMPTYARG)
+{
+ // als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der
+ // Navigator geloescht werden darf
+
+ pThis->DoDrag();
+ return 0;
+}
+
+BOOL ScContentTree::LoadFile( const String& rUrl )
+{
+ String aDocName = rUrl;
+ xub_StrLen nPos = aDocName.Search('#');
+ if ( nPos != STRING_NOTFOUND )
+ aDocName.Erase(nPos); // nur der Name, ohne #...
+
+ BOOL bReturn = FALSE;
+ String aFilter, aOptions;
+ ScDocumentLoader aLoader( aDocName, aFilter, aOptions );
+ if ( !aLoader.IsError() )
+ {
+ bHiddenDoc = TRUE;
+ aHiddenName = aDocName;
+ aHiddenTitle = aLoader.GetTitle();
+ pHiddenDocument = aLoader.GetDocument();
+
+ Refresh(); // Inhalte aus geladenem Dokument holen
+
+ pHiddenDocument = NULL;
+// AdjustTitle();
+
+ pParentWindow->GetDocNames( &aHiddenTitle ); // Liste fuellen
+ }
+ else
+ Sound::Beep(); // Fehler beim Laden
+
+ // Dokument wird im dtor von ScDocumentLoader wieder geschlossen
+
+ return bReturn;
+}
+
+void ScContentTree::InitWindowBits( BOOL bButtons )
+{
+ WinBits nFlags = WB_CLIPCHILDREN|WB_HSCROLL;
+ if (bButtons)
+ nFlags |= WB_HASBUTTONS|WB_HASBUTTONSATROOT;
+
+ SetWindowBits( nFlags );
+}
+
+void ScContentTree::SetRootType( USHORT nNew )
+{
+ if ( nNew != nRootType )
+ {
+ nRootType = nNew;
+ InitWindowBits( nNew == 0 );
+ Refresh();
+
+ ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
+ rCfg.SetRootType( nRootType );
+ }
+}
+
+void ScContentTree::ToggleRoot() // nach Selektion
+{
+ USHORT nNew = SC_CONTENT_ROOT;
+ if ( nRootType == SC_CONTENT_ROOT )
+ {
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if (pEntry)
+ {
+ SvLBoxEntry* pParent = GetParent(pEntry);
+ for (USHORT i=1; i<SC_CONTENT_COUNT; i++)
+ if ( pEntry == pRootNodes[i] || pParent == pRootNodes[i] )
+ nNew = i;
+ }
+ }
+
+ SetRootType( nNew );
+}
+
+void ScContentTree::ResetManualDoc()
+{
+ aManualDoc.Erase();
+ bHiddenDoc = FALSE;
+
+ ActiveDocChanged();
+}
+
+void ScContentTree::ActiveDocChanged()
+{
+ if ( !bHiddenDoc && !aManualDoc.Len() )
+ Refresh(); // Inhalte nur wenn automatisch
+
+ // Listbox muss immer geupdated werden, wegen aktiv-Flag
+
+ String aCurrent;
+ if ( bHiddenDoc )
+ aCurrent = aHiddenTitle;
+ else
+ {
+ ScDocShell* pSh = GetManualOrCurrent();
+ if (pSh)
+ aCurrent = pSh->GetTitle();
+ else
+ {
+ // eingestelltes Dokument existiert nicht mehr
+
+ aManualDoc.Erase(); // wieder automatisch
+ Refresh();
+ pSh = GetManualOrCurrent(); // sollte jetzt aktives sein
+ if (pSh)
+ aCurrent = pSh->GetTitle();
+ }
+ }
+ pParentWindow->GetDocNames( &aCurrent ); // selektieren
+}
+
+void ScContentTree::SetManualDoc(const String& rName)
+{
+ aManualDoc = rName;
+ if (!bHiddenDoc)
+ {
+ Refresh();
+ pParentWindow->GetDocNames( &aManualDoc ); // selektieren
+ }
+}
+
+void ScContentTree::SelectDoc(const String& rName) // rName wie im Menue/Listbox angezeigt
+{
+ if ( rName == pParentWindow->aStrActiveWin )
+ {
+ ResetManualDoc();
+ return;
+ }
+
+ // "aktiv" oder "inaktiv" weglassen
+
+ String aRealName = rName;
+ xub_StrLen nLen = rName.Len();
+ xub_StrLen nActiveStart = nLen - pParentWindow->aStrActive.Len();
+ if ( rName.Copy( nActiveStart ) == pParentWindow->aStrActive )
+ aRealName = rName.Copy( 0, nActiveStart );
+ xub_StrLen nNotActiveStart = nLen - pParentWindow->aStrNotActive.Len();
+ if ( rName.Copy( nNotActiveStart ) == pParentWindow->aStrNotActive )
+ aRealName = rName.Copy( 0, nNotActiveStart );
+
+ //
+
+ BOOL bLoaded = FALSE;
+
+ // ist es ein normal geladenes Doc ?
+
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ while ( pSh && !bLoaded )
+ {
+ if ( pSh->ISA(ScDocShell) )
+ if ( pSh->GetTitle() == aRealName )
+ bLoaded = TRUE;
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+
+ if (bLoaded)
+ {
+ bHiddenDoc = FALSE;
+ SetManualDoc(aRealName);
+ }
+ else if (aHiddenTitle.Len()) // verstecktes ausgewaehlt
+ {
+ if (!bHiddenDoc)
+ LoadFile(aHiddenName);
+ }
+ else
+ {
+ DBG_ERROR("SelectDoc: nicht gefunden");
+ }
+}
+
+void ScContentTree::ApplySettings()
+{
+ const ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
+ if( pSettings )
+ {
+ USHORT nRootSel = pSettings->GetRootSelected();
+ ULONG nChildSel = pSettings->GetChildSelected();
+
+ for( USHORT nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
+ {
+ if( pRootNodes[ nEntry ] )
+ {
+ // expand
+ BOOL bExp = pSettings->IsExpanded( nEntry );
+ if( bExp != IsExpanded( pRootNodes[ nEntry ] ) )
+ {
+ if( bExp )
+ Expand( pRootNodes[ nEntry ] );
+ else
+ Collapse( pRootNodes[ nEntry ] );
+ }
+
+ // select
+ if( nRootSel == nEntry )
+ {
+ SvLBoxEntry* pEntry = NULL;
+ if( bExp && (nChildSel != SC_CONTENT_NOCHILD) )
+ pEntry = GetEntry( pRootNodes[ nEntry ], nChildSel );
+ Select( pEntry ? pEntry : pRootNodes[ nEntry ] );
+ }
+ }
+ }
+ }
+}
+
+void ScContentTree::StoreSettings() const
+{
+ ScNavigatorSettings* pSettings = pParentWindow->GetNavigatorSettings();
+ if( pSettings )
+ {
+ for( USHORT nEntry = 1; nEntry < SC_CONTENT_COUNT; ++nEntry )
+ {
+ BOOL bExp = pRootNodes[ nEntry ] && IsExpanded( pRootNodes[ nEntry ] );
+ pSettings->SetExpanded( nEntry, bExp );
+ }
+ USHORT nRoot;
+ ULONG nChild;
+ GetEntryIndexes( nRoot, nChild, GetCurEntry() );
+ pSettings->SetRootSelected( nRoot );
+ pSettings->SetChildSelected( nChild );
+ }
+}
+
+
+//
+//------------------------------------------------------------------------
+//
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/navipi/makefile.mk b/sc/source/ui/navipi/makefile.mk
new file mode 100644
index 000000000000..992aefcd4f45
--- /dev/null
+++ b/sc/source/ui/navipi/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=navipi
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/navipi.obj \
+ $(SLO)$/navcitem.obj \
+ $(SLO)$/scenwnd.obj \
+ $(SLO)$/content.obj
+
+EXCEPTIONSFILES = \
+ $(SLO)$/scenwnd.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = navipi.src
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/navipi/navcitem.cxx b/sc/source/ui/navipi/navcitem.cxx
new file mode 100644
index 000000000000..d531e6baf44d
--- /dev/null
+++ b/sc/source/ui/navipi/navcitem.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+
+#include "navcitem.hxx"
+#include "global.hxx"
+#include "navipi.hxx"
+#include "sc.hrc" // -> Item-IDs
+
+// STATIC DATA -----------------------------------------------------------
+
+
+//------------------------------------------------------------------------
+
+ScNavigatorControllerItem::ScNavigatorControllerItem( USHORT nIdP,
+ ScNavigatorDlg& rDlg,
+ SfxBindings& rBindings )
+ : SfxControllerItem ( nIdP, rBindings ),
+ rNavigatorDlg ( rDlg )
+{
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScNavigatorControllerItem::StateChanged( USHORT /* nSID */, SfxItemState /* eState */,
+ const SfxPoolItem* pItem )
+{
+ switch( GetId() )
+ {
+ case SID_CURRENTCELL:
+ if ( pItem )
+ {
+// const SfxPointItem* pCellPosItem = PTR_CAST(SfxPointItem, pItem);
+ const SfxStringItem* pCellPosItem = PTR_CAST(SfxStringItem, pItem);
+
+ DBG_ASSERT( pCellPosItem, "SfxStringItem expected!" );
+
+ if ( pCellPosItem )
+ {
+ String aAddress( pCellPosItem->GetValue() );
+ ScAddress aScAddress;
+ aScAddress.Parse( aAddress );
+
+ SCCOL nCol = aScAddress.Col()+1;
+ SCROW nRow = aScAddress.Row()+1;
+
+// SCCOL nCol = (USHORT)pCellPosItem->GetValue().X()+1;
+// SCROW nRow = (USHORT)pCellPosItem->GetValue().Y()+1;
+
+ rNavigatorDlg.UpdateColumn( &nCol );
+ rNavigatorDlg.UpdateRow ( &nRow );
+ rNavigatorDlg.CursorPosChanged();
+ }
+ }
+ break;
+
+ case SID_CURRENTTAB:
+ if ( pItem )
+ {
+ const SfxUInt16Item* pTabItem = PTR_CAST(SfxUInt16Item, pItem);
+
+ DBG_ASSERT( pTabItem, "SfxUInt16Item expected!" );
+
+ // Tabelle fuer Basic ist 1-basiert
+ if ( pTabItem && pTabItem->GetValue() )
+ {
+ SCTAB nTab = pTabItem->GetValue() - 1;
+
+ rNavigatorDlg.UpdateTable( &nTab );
+ rNavigatorDlg.UpdateColumn();
+ rNavigatorDlg.UpdateRow();
+ rNavigatorDlg.CursorPosChanged();
+ }
+ }
+ break;
+
+ case SID_CURRENTDOC:
+ //
+ // gar nix mehr, wird ueber SFX_HINT_DOCCHANGED erledigt
+ //
+ break;
+
+
+ case SID_SELECT_SCENARIO:
+ rNavigatorDlg.aWndScenarios.NotifyState( pItem );
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/navipi/navipi.cxx b/sc/source/ui/navipi/navipi.cxx
new file mode 100644
index 000000000000..06b0ece7d5c6
--- /dev/null
+++ b/sc/source/ui/navipi/navipi.cxx
@@ -0,0 +1,1508 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include <rangelst.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/imgmgr.hxx>
+#include <sfx2/navigat.hxx>
+#include <svl/stritem.hxx>
+#include <svl/urlbmk.hxx>
+#include <vcl/sound.hxx>
+#include <unotools/charclass.hxx>
+#include <stdlib.h>
+
+#include "viewdata.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "popmenu.hxx"
+#include "scresid.hxx"
+#include "scmod.hxx"
+#include "navicfg.hxx"
+#include "navcitem.hxx"
+#include "navipi.hrc"
+#include "navipi.hxx"
+#include "navsett.hxx"
+
+// Timeout, um Notizen zu suchen
+#define SC_CONTENT_TIMEOUT 1000
+
+// Toleranz, wieviel ueber der eingeklappten Groesse noch klein ist
+#define SCNAV_MINTOL 5
+
+// maximum values for UI
+#define SCNAV_MAXCOL (MAXCOLCOUNT)
+// macro is sufficient since only used in ctor
+#define SCNAV_COLDIGITS (static_cast<xub_StrLen>( floor( log10( static_cast<double>(SCNAV_MAXCOL)))) + 1) // 1...256...18278
+// precomputed constant because it is used in every change of spin button field
+static const xub_StrLen SCNAV_COLLETTERS = ::ScColToAlpha(SCNAV_MAXCOL).Len(); // A...IV...ZZZ
+
+#define SCNAV_MAXROW (MAXROWCOUNT)
+
+//------------------------------------------------------------------------
+
+// static
+void ScNavigatorDlg::ReleaseFocus()
+{
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+}
+
+//==================================================================
+// class ColumnEdit
+//==================================================================
+
+ColumnEdit::ColumnEdit( ScNavigatorDlg* pParent, const ResId& rResId )
+ : SpinField ( pParent, rResId ),
+ rDlg ( *pParent ),
+ nCol ( 0 ),
+ nKeyGroup ( KEYGROUP_ALPHA )
+{
+ SetMaxTextLen( SCNAV_COLDIGITS ); // 1...256...18278 or A...IV...ZZZ
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ColumnEdit::~ColumnEdit()
+{
+}
+
+//------------------------------------------------------------------------
+
+long __EXPORT ColumnEdit::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = SpinField::Notify( rNEvt );
+
+ USHORT nType = rNEvt.GetType();
+ if ( nType == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ KeyCode aCode = pKEvt->GetKeyCode();
+
+ if ( !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ //! Eingabeueberpruefung (nur Zahlen oder nur Buchstaben, max 2 bzw 3 Stellen)
+ //! war vor VCL per nicht weitergeleitetem KeyInput
+ //! dafuer was neues ausdenken!!!
+
+ if ( aCode.GetCode() == KEY_RETURN )
+ {
+ ScNavigatorDlg::ReleaseFocus();
+ ExecuteCol();
+ nHandled = 1;
+ }
+ }
+ }
+ else if ( nType == EVENT_LOSEFOCUS ) // LoseFocus wird bei VCL nicht gerufen
+ EvalText(); // nCol setzen
+
+ return nHandled;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ColumnEdit::LoseFocus()
+{
+ EvalText();
+}
+
+
+//------------------------------------------------------------------------
+
+void __EXPORT ColumnEdit::Up()
+{
+ nCol++;
+
+#ifdef OS2
+ if ( nCol > SCNAV_MAXCOL )
+ nCol = 1;
+#endif
+
+ if ( nCol <= SCNAV_MAXCOL )
+ SetCol( nCol );
+ else
+ nCol--;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ColumnEdit::Down()
+{
+ if ( nCol>1 )
+ SetCol( nCol-1 );
+#ifdef OS2
+ else
+ SetCol( SCNAV_MAXCOL );
+#endif
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ColumnEdit::First()
+{
+ nCol = 1;
+ SetText( 'A' );
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ColumnEdit::Last()
+{
+ String aStr;
+ nCol = NumToAlpha( SCNAV_MAXCOL, aStr );
+ SetText( aStr );
+}
+
+
+//------------------------------------------------------------------------
+
+void ColumnEdit::EvalText()
+{
+ String aStrCol = GetText();
+
+ if ( aStrCol.Len() > 0 )
+ {
+ // nKeyGroup wird bei VCL mangels KeyInput nicht mehr gesetzt
+
+ if ( CharClass::isAsciiNumeric(aStrCol) )
+ nCol = NumStrToAlpha( aStrCol );
+ else
+ nCol = AlphaToNum( aStrCol );
+ }
+ else
+ nCol = 0;
+
+ SetText( aStrCol );
+ nKeyGroup = KEYGROUP_ALPHA;
+}
+
+//------------------------------------------------------------------------
+
+void ColumnEdit::ExecuteCol()
+{
+ SCROW nRow = rDlg.aEdRow.GetRow();
+
+ EvalText(); // setzt nCol
+
+ if ( (nCol > 0) && (nRow > 0) )
+ rDlg.SetCurrentCell( nCol-1, nRow-1 );
+}
+
+//------------------------------------------------------------------------
+
+void ColumnEdit::SetCol( SCCOL nColNo )
+{
+ String aStr;
+
+ if ( nColNo == 0 )
+ {
+ nCol = 0;
+ SetText( aStr );
+ }
+ else
+ {
+ nColNo = NumToAlpha( nColNo, aStr );
+ nCol = nColNo;
+ SetText( aStr );
+ }
+}
+
+//------------------------------------------------------------------------
+
+SCCOL ColumnEdit::AlphaToNum( String& rStr )
+{
+ SCCOL nColumn = 0;
+
+ if ( CharClass::isAsciiAlpha( rStr) )
+ {
+ rStr.ToUpperAscii();
+
+ if (::AlphaToCol( nColumn, rStr))
+ ++nColumn;
+
+ if ( (rStr.Len() > SCNAV_COLLETTERS) || (nColumn > SCNAV_MAXCOL) )
+ {
+ nColumn = SCNAV_MAXCOL;
+ NumToAlpha( nColumn, rStr );
+ }
+ }
+ else
+ rStr.Erase();
+
+ return nColumn;
+}
+
+//------------------------------------------------------------------------
+
+SCCOL ColumnEdit::NumStrToAlpha( String& rStr )
+{
+ SCCOL nColumn = 0;
+
+ if ( CharClass::isAsciiNumeric(rStr) )
+ nColumn = NumToAlpha( (SCCOL)rStr.ToInt32(), rStr );
+ else
+ rStr.Erase();
+
+ return nColumn;
+}
+
+//------------------------------------------------------------------------
+
+SCCOL ColumnEdit::NumToAlpha( SCCOL nColNo, String& rStr )
+{
+ if ( nColNo > SCNAV_MAXCOL )
+ nColNo = SCNAV_MAXCOL;
+ else if ( nColNo < 1 )
+ nColNo = 1;
+
+ ::ScColToAlpha( rStr, nColNo - 1);
+
+ return nColNo;
+}
+
+//==================================================================
+// class RowEdit
+//==================================================================
+
+RowEdit::RowEdit( ScNavigatorDlg* pParent, const ResId& rResId )
+ : NumericField( pParent, rResId ),
+ rDlg ( *pParent )
+{
+ SetMax( SCNAV_MAXROW);
+ SetLast( SCNAV_MAXROW);
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT RowEdit::~RowEdit()
+{
+}
+
+//------------------------------------------------------------------------
+
+long __EXPORT RowEdit::Notify( NotifyEvent& rNEvt )
+{
+ long nHandled = NumericField::Notify( rNEvt );
+
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ KeyCode aCode = pKEvt->GetKeyCode();
+ if ( aCode.GetCode() == KEY_RETURN && !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ ScNavigatorDlg::ReleaseFocus();
+ ExecuteRow();
+ nHandled = 1;
+ }
+ }
+
+ return nHandled;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT RowEdit::LoseFocus()
+{
+}
+
+//------------------------------------------------------------------------
+
+void RowEdit::ExecuteRow()
+{
+ SCCOL nCol = rDlg.aEdCol.GetCol();
+ SCROW nRow = (SCROW)GetValue();
+
+ if ( (nCol > 0) && (nRow > 0) )
+ rDlg.SetCurrentCell( nCol-1, nRow-1 );
+}
+
+//==================================================================
+// class ScDocListBox
+//==================================================================
+
+ScDocListBox::ScDocListBox( ScNavigatorDlg* pParent, const ResId& rResId )
+ : ListBox ( pParent, rResId ),
+ rDlg ( *pParent )
+{
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScDocListBox::~ScDocListBox()
+{
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScDocListBox::Select()
+{
+ ScNavigatorDlg::ReleaseFocus();
+
+ String aDocName = GetSelectEntry();
+ rDlg.aLbEntries.SelectDoc( aDocName );
+}
+
+//==================================================================
+// class CommandToolBox
+//==================================================================
+
+CommandToolBox::CommandToolBox( ScNavigatorDlg* pParent, const ResId& rResId )
+ : ToolBox ( pParent, rResId ),
+ rDlg ( *pParent )
+{
+ InitImageList(); // ImageList members of ScNavigatorDlg must be initialized before!
+
+ SetSizePixel( CalcWindowSizePixel() );
+ SetDropdownClickHdl( LINK(this, CommandToolBox, ToolBoxDropdownClickHdl) );
+ SetItemBits( IID_DROPMODE, GetItemBits( IID_DROPMODE ) | TIB_DROPDOWNONLY );
+// EnableItem( IID_UP, FALSE );
+// EnableItem( IID_DOWN, FALSE );
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT CommandToolBox::~CommandToolBox()
+{
+}
+
+//------------------------------------------------------------------------
+
+void CommandToolBox::Select( USHORT nSelId )
+{
+ // Modus umschalten ?
+
+ if ( nSelId == IID_ZOOMOUT || nSelId == IID_SCENARIOS )
+ {
+ NavListMode eOldMode = rDlg.eListMode;
+ NavListMode eNewMode = eOldMode;
+
+ if ( nSelId == IID_SCENARIOS ) // auf Szenario
+ {
+ if ( eOldMode == NAV_LMODE_SCENARIOS )
+ eNewMode = NAV_LMODE_AREAS;
+ else
+ eNewMode = NAV_LMODE_SCENARIOS;
+ }
+ else // ein/aus
+ {
+ if ( eOldMode == NAV_LMODE_NONE )
+ eNewMode = NAV_LMODE_AREAS;
+ else
+ eNewMode = NAV_LMODE_NONE;
+ }
+ rDlg.SetListMode( eNewMode );
+ UpdateButtons();
+ }
+ else
+ switch ( nSelId )
+ {
+ case IID_DATA:
+ rDlg.MarkDataArea();
+ break;
+ case IID_UP:
+ rDlg.StartOfDataArea();
+ break;
+ case IID_DOWN:
+ rDlg.EndOfDataArea();
+ break;
+ // IID_DROPMODE ist in Click
+ case IID_CHANGEROOT:
+ rDlg.aLbEntries.ToggleRoot();
+ UpdateButtons();
+ break;
+ }
+}
+
+void __EXPORT CommandToolBox::Select()
+{
+ Select( GetCurItemId() );
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT CommandToolBox::Click()
+{
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( CommandToolBox, ToolBoxDropdownClickHdl, ToolBox*, EMPTYARG )
+{
+ // Das Popupmenue fuer den Dropmodus muss im Click (Button Down)
+ // statt im Select (Button Up) aufgerufen werden.
+
+ if ( GetCurItemId() == IID_DROPMODE )
+ {
+ ScPopupMenu aPop( ScResId( RID_POPUP_DROPMODE ) );
+ aPop.CheckItem( RID_DROPMODE_URL + rDlg.GetDropMode() );
+ aPop.Execute( this, GetItemRect(IID_DROPMODE), POPUPMENU_EXECUTE_DOWN );
+ USHORT nId = aPop.GetSelected();
+
+ EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage)
+
+ if ( nId >= RID_DROPMODE_URL && nId <= RID_DROPMODE_COPY )
+ rDlg.SetDropMode( nId - RID_DROPMODE_URL );
+
+ // #49956# den gehighlighteten Button aufheben
+ Point aPoint;
+ MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
+ MouseMove( aLeave );
+ }
+
+ return 1;
+}
+
+//------------------------------------------------------------------------
+
+void CommandToolBox::UpdateButtons()
+{
+ NavListMode eMode = rDlg.eListMode;
+ CheckItem( IID_SCENARIOS, eMode == NAV_LMODE_SCENARIOS );
+ CheckItem( IID_ZOOMOUT, eMode != NAV_LMODE_NONE );
+
+ // Umschalten-Button:
+ if ( eMode == NAV_LMODE_SCENARIOS || eMode == NAV_LMODE_NONE )
+ {
+ EnableItem( IID_CHANGEROOT, FALSE );
+ CheckItem( IID_CHANGEROOT, FALSE );
+ }
+ else
+ {
+ EnableItem( IID_CHANGEROOT, TRUE );
+ BOOL bRootSet = rDlg.aLbEntries.GetRootType() != SC_CONTENT_ROOT;
+ CheckItem( IID_CHANGEROOT, bRootSet );
+ }
+
+ BOOL bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ USHORT nImageId = 0;
+ switch ( rDlg.nDropMode )
+ {
+ case SC_DROPMODE_URL: nImageId = bHC ? RID_IMG_H_DROP_URL : RID_IMG_DROP_URL; break;
+ case SC_DROPMODE_LINK: nImageId = bHC ? RID_IMG_H_DROP_LINK : RID_IMG_DROP_LINK; break;
+ case SC_DROPMODE_COPY: nImageId = bHC ? RID_IMG_H_DROP_COPY : RID_IMG_DROP_COPY; break;
+ }
+ SetItemImage( IID_DROPMODE, Image(ScResId(nImageId)) );
+}
+
+void CommandToolBox::InitImageList()
+{
+ BOOL bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ ImageList& rImgLst = bHC ? rDlg.aCmdImageListH : rDlg.aCmdImageList;
+
+ USHORT nCount = GetItemCount();
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ USHORT nId = GetItemId(i);
+ SetItemImage( nId, rImgLst.GetImage( nId ) );
+ }
+}
+
+void CommandToolBox::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ // update item images
+
+ InitImageList();
+ UpdateButtons(); // drop mode
+ }
+
+ ToolBox::DataChanged( rDCEvt );
+}
+
+//==================================================================
+// class ScNavigatorSettings
+//==================================================================
+
+ScNavigatorSettings::ScNavigatorSettings() :
+ maExpandedVec( SC_CONTENT_COUNT, FALSE ),
+ mnRootSelected( SC_CONTENT_ROOT ),
+ mnChildSelected( SC_CONTENT_NOCHILD )
+{
+}
+
+//==================================================================
+// class ScNavigatorDlgWrapper
+//==================================================================
+
+SFX_IMPL_CHILDWINDOWCONTEXT( ScNavigatorDialogWrapper, SID_NAVIGATOR )
+
+#define IS_MODE(bit)(((nFlags)&(bit))==(bit))
+
+ScNavigatorDialogWrapper::ScNavigatorDialogWrapper(
+ Window* pParent,
+ USHORT nId,
+ SfxBindings* pBind,
+ SfxChildWinInfo* /* pInfo */ ) :
+ SfxChildWindowContext( nId )
+{
+ pNavigator = new ScNavigatorDlg( pBind, this, pParent );
+ SetWindow( pNavigator );
+
+ // Einstellungen muessen anderswo gemerkt werden,
+ // pInfo geht uns (ausser der Groesse) nichts mehr an
+
+ Size aInfoSize = pParent->GetOutputSizePixel(); // von aussen vorgegebene Groesse
+ Size aNavSize = pNavigator->GetOutputSizePixel(); // Default-Groesse
+
+ aNavSize.Width() = Max( aInfoSize.Width(), aNavSize.Width() );
+ aNavSize.Height() = Max( aInfoSize.Height(), aNavSize.Height() );
+ pNavigator->nListModeHeight = Max( aNavSize.Height(), pNavigator->nListModeHeight );
+
+ // Die Groesse kann in einem anderen Modul geaendert worden sein,
+ // deshalb muessen in Abhaengigkeit von der momentanen Groesse die
+ // Inhalte eingeblendet werden oder nicht
+
+ BOOL bSmall = ( aInfoSize.Height() <= pNavigator->aInitSize.Height() + SCNAV_MINTOL );
+ NavListMode eNavMode = NAV_LMODE_NONE;
+ if (!bSmall)
+ {
+ // wenn Szenario aktiv war, wieder einschalten
+
+ ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
+ NavListMode eLastMode = (NavListMode) rCfg.GetListMode();
+ if ( eLastMode == NAV_LMODE_SCENARIOS )
+ eNavMode = NAV_LMODE_SCENARIOS;
+ else
+ eNavMode = NAV_LMODE_AREAS;
+ }
+
+ // Die Groesse des Floats nicht neu setzen (FALSE bei SetListMode), damit der
+ // Navigator nicht aufgeklappt wird, wenn er minimiert war (#38872#).
+
+ pNavigator->SetListMode( eNavMode, FALSE ); // FALSE: Groesse des Float nicht setzen
+
+ USHORT nCmdId;
+ switch (eNavMode)
+ {
+ case NAV_LMODE_DOCS: nCmdId = IID_DOCS; break;
+ case NAV_LMODE_AREAS: nCmdId = IID_AREAS; break;
+ case NAV_LMODE_DBAREAS: nCmdId = IID_DBAREAS; break;
+ case NAV_LMODE_SCENARIOS: nCmdId = IID_SCENARIOS; break;
+ default: nCmdId = 0;
+ }
+ if (nCmdId)
+ {
+ pNavigator->aTbxCmd.CheckItem( nCmdId );
+ pNavigator->DoResize();
+ }
+
+ pNavigator->bFirstBig = ( nCmdId == 0 ); // dann spaeter
+
+/*???
+ FloatingWindow* pFloat = GetFloatingWindow();
+ if ( pFloat )
+ pFloat->SetMinOutputSizePixel( pNavigator->GetMinOutputSizePixel() );
+*/
+
+//!? pNavigator->Show();
+}
+
+void __EXPORT ScNavigatorDialogWrapper::Resizing( Size& rSize )
+{
+ ((ScNavigatorDlg*)GetWindow())->Resizing(rSize);
+}
+
+//========================================================================
+// class ScNavigatorPI
+//========================================================================
+
+#define CTRL_ITEMS 4
+
+#define REGISTER_SLOT(i,id) \
+ ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
+
+ScNavigatorDlg::ScNavigatorDlg( SfxBindings* pB, SfxChildWindowContext* pCW, Window* pParent ) :
+ Window( pParent, ScResId(RID_SCDLG_NAVIGATOR) ),
+ rBindings ( *pB ), // is used in CommandToolBox ctor
+ aCmdImageList( ScResId( IL_CMD ) ),
+ aCmdImageListH( ScResId( ILH_CMD ) ),
+ aFtCol ( this, ScResId( FT_COL ) ),
+ aEdCol ( this, ScResId( ED_COL ) ),
+ aFtRow ( this, ScResId( FT_ROW ) ),
+ aEdRow ( this, ScResId( ED_ROW ) ),
+ aTbxCmd ( this, ScResId( TBX_CMD ) ),
+ aLbEntries ( this, ScResId( LB_ENTRIES ) ),
+ aWndScenarios( this,ScResId( STR_QHLP_SCEN_LISTBOX), ScResId(STR_QHLP_SCEN_COMMENT)),
+ aLbDocuments( this, ScResId( LB_DOCUMENTS ) ),
+ aStrDragMode ( ScResId( STR_DRAGMODE ) ),
+ aStrDisplay ( ScResId( STR_DISPLAY ) ),
+ aStrActiveWin( ScResId( STR_ACTIVEWIN ) ),
+ pContextWin ( pCW ),
+ pMarkArea ( NULL ),
+ pViewData ( NULL ),
+ nListModeHeight( 0 ),
+ nInitListHeight( 0 ),
+ eListMode ( NAV_LMODE_NONE ),
+ nDropMode ( SC_DROPMODE_URL ),
+ nCurCol ( 0 ),
+ nCurRow ( 0 ),
+ nCurTab ( 0 ),
+ bFirstBig ( FALSE )
+{
+ ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
+ nDropMode = rCfg.GetDragMode();
+ // eListMode wird von aussen gesetzt, Root weiter unten
+
+ aLbDocuments.SetDropDownLineCount(9);
+ String aOpen = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aStrActive = aOpen;
+ aStrActive += String( ScResId( STR_ACTIVE ) );
+ aStrActive += ')'; // " (aktiv)"
+ aStrNotActive = aOpen;
+ aStrNotActive += String( ScResId( STR_NOTACTIVE ) );
+ aStrNotActive += ')'; // " (inaktiv)"
+ aStrHidden = aOpen;
+ aStrHidden += String( ScResId( STR_HIDDEN ) );
+ aStrHidden += ')'; // " (versteckt)"
+
+ aTitleBase = GetText();
+
+ long nListboxYPos = aTbxCmd.GetPosPixel().Y() + aTbxCmd.GetSizePixel().Height() + 4;
+ aLbEntries.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y);
+
+ nBorderOffset = aLbEntries.GetPosPixel().X();
+
+ aInitSize.Width() = aTbxCmd.GetPosPixel().X()
+ + aTbxCmd.GetSizePixel().Width()
+ + nBorderOffset;
+ aInitSize.Height() = aLbEntries.GetPosPixel().Y();
+
+ nInitListHeight = aLbEntries.GetSizePixel().Height();
+ nListModeHeight = aInitSize.Height()
+ + nInitListHeight;
+
+ // kein Resize, eh der ganze Kontext-Kram initialisiert ist!
+// SetOutputSizePixel( aInitSize ); //???
+/*! FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
+ if ( pFloat)
+ pFloat->SetMinOutputSizePixel( aInitSize );
+*/
+ ppBoundItems = new ScNavigatorControllerItem* [CTRL_ITEMS];
+
+ rBindings.ENTERREGISTRATIONS();
+ //-----------------------------
+ REGISTER_SLOT( 0, SID_CURRENTCELL );
+ REGISTER_SLOT( 1, SID_CURRENTTAB );
+ REGISTER_SLOT( 2, SID_CURRENTDOC );
+ REGISTER_SLOT( 3, SID_SELECT_SCENARIO );
+ //-----------------------------
+ rBindings.LEAVEREGISTRATIONS();
+
+ StartListening( *(SFX_APP()) );
+ StartListening( rBindings );
+
+ aLbDocuments.Hide(); // bei NAV_LMODE_NONE gibts die nicht
+
+ aLbEntries.InitWindowBits(TRUE);
+
+ aLbEntries.SetSpaceBetweenEntries(0);
+ aLbEntries.SetSelectionMode( SINGLE_SELECTION );
+ aLbEntries.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE |
+ SV_DRAGDROP_CTRL_COPY |
+ SV_DRAGDROP_ENABLE_TOP );
+
+ // war eine Kategorie als Root ausgewaehlt?
+ USHORT nLastRoot = rCfg.GetRootType();
+ if ( nLastRoot )
+ aLbEntries.SetRootType( nLastRoot );
+
+ aLbEntries.Refresh();
+ GetDocNames();
+
+ aTbxCmd.UpdateButtons();
+
+ UpdateColumn();
+ UpdateRow();
+ UpdateTable();
+ aLbEntries.Hide();
+ aWndScenarios.Hide();
+ aWndScenarios.SetPosPixel( aLbEntries.GetPosPixel() );
+
+ aContentTimer.SetTimeoutHdl( LINK( this, ScNavigatorDlg, TimeHdl ) );
+ aContentTimer.SetTimeout( SC_CONTENT_TIMEOUT );
+
+ FreeResource();
+}
+
+//------------------------------------------------------------------------
+
+__EXPORT ScNavigatorDlg::~ScNavigatorDlg()
+{
+ aContentTimer.Stop();
+
+ USHORT i;
+ for ( i=0; i<CTRL_ITEMS; i++ )
+ delete ppBoundItems[i];
+
+ delete [] ppBoundItems;
+ delete pMarkArea;
+
+ EndListening( *(SFX_APP()) );
+ EndListening( rBindings );
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScNavigatorDlg::Resizing( Size& rNewSize ) // Size = Outputsize?
+{
+ FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
+ if ( pFloat )
+ {
+ Size aMinOut = pFloat->GetMinOutputSizePixel();
+
+ if ( rNewSize.Width() < aMinOut.Width() )
+ rNewSize.Width() = aMinOut.Width();
+
+ if ( eListMode == NAV_LMODE_NONE )
+ rNewSize.Height() = aInitSize.Height();
+ else
+ {
+ if ( rNewSize.Height() < aMinOut.Height() )
+ rNewSize.Height() = aMinOut.Height();
+ }
+ }
+// else
+// SfxDockingWindow::Resizing(rNewSize);
+}
+
+
+
+void ScNavigatorDlg::Paint( const Rectangle& rRec )
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ Color aBgColor = rStyleSettings.GetFaceColor();
+ Wallpaper aBack( aBgColor );
+
+ SetBackground( aBack );
+ aFtCol.SetBackground( aBack );
+ aFtRow.SetBackground( aBack );
+
+ Window::Paint( rRec );
+}
+
+void ScNavigatorDlg::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ // toolbox images are exchanged in CommandToolBox::DataChanged
+ Invalidate();
+ }
+
+ Window::DataChanged( rDCEvt );
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScNavigatorDlg::Resize()
+{
+ DoResize();
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::DoResize()
+{
+ Size aNewSize = GetOutputSizePixel();
+ long nTotalHeight = aNewSize.Height();
+
+ // #41403# bei angedocktem Navigator wird das Fenster evtl. erst klein erzeugt,
+ // dann kommt ein Resize auf die wirkliche Groesse -> dann Inhalte einschalten
+
+ BOOL bSmall = ( nTotalHeight <= aInitSize.Height() + SCNAV_MINTOL );
+ if ( !bSmall && bFirstBig )
+ {
+ // Inhalte laut Config wieder einschalten
+
+ bFirstBig = FALSE;
+ NavListMode eNavMode = NAV_LMODE_AREAS;
+ ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
+ NavListMode eLastMode = (NavListMode) rCfg.GetListMode();
+ if ( eLastMode == NAV_LMODE_SCENARIOS )
+ eNavMode = NAV_LMODE_SCENARIOS;
+ SetListMode( eNavMode, FALSE ); // FALSE: Groesse des Float nicht setzen
+ }
+
+ // auch wenn die Inhalte nicht sichtbar sind, die Groessen anpassen,
+ // damit die Breite stimmt
+
+ //@@ 03.11.97 changes begin
+ Point aEntryPos = aLbEntries.GetPosPixel();
+ Point aListPos = aLbDocuments.GetPosPixel();
+ aNewSize.Width() -= 2*nBorderOffset;
+ Size aDocSize = aLbDocuments.GetSizePixel();
+ aDocSize.Width() = aNewSize.Width();
+
+ if(!bSmall)
+ {
+
+ long nListHeight = aLbDocuments.GetSizePixel().Height();
+ aNewSize.Height() -= ( aEntryPos.Y() + nListHeight + 2*nBorderOffset );
+ if(aNewSize.Height()<0) aNewSize.Height()=0;
+
+ aListPos.Y() = aEntryPos.Y() + aNewSize.Height() + nBorderOffset;
+
+ if(aListPos.Y() > aLbEntries.GetPosPixel().Y())
+ aLbDocuments.SetPosPixel( aListPos );
+
+ }
+ aLbEntries.SetSizePixel( aNewSize );
+ aWndScenarios.SetSizePixel( aNewSize );
+ aLbDocuments.SetSizePixel( aDocSize );
+
+ //@@ 03.11.97 end
+
+ BOOL bListMode = (eListMode != NAV_LMODE_NONE);
+ FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
+ if ( pFloat && bListMode )
+ nListModeHeight = nTotalHeight;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScNavigatorDlg::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA(SfxSimpleHint) )
+ {
+ ULONG nHintId = ((SfxSimpleHint&)rHint).GetId();
+
+ if ( nHintId == SC_HINT_DOCNAME_CHANGED )
+ {
+ aLbEntries.ActiveDocChanged();
+ }
+ else if ( NAV_LMODE_NONE == eListMode )
+ {
+ // Tabellen hier nicht mehr
+ }
+ else
+ {
+ switch ( nHintId )
+ {
+ case SC_HINT_TABLES_CHANGED:
+ aLbEntries.Refresh( SC_CONTENT_TABLE );
+ break;
+
+ case SC_HINT_DBAREAS_CHANGED:
+ aLbEntries.Refresh( SC_CONTENT_DBAREA );
+ break;
+
+ case SC_HINT_AREAS_CHANGED:
+ aLbEntries.Refresh( SC_CONTENT_RANGENAME );
+ break;
+
+ case SC_HINT_DRAW_CHANGED:
+ aLbEntries.Refresh( SC_CONTENT_GRAPHIC );
+ aLbEntries.Refresh( SC_CONTENT_OLEOBJECT );
+ aLbEntries.Refresh( SC_CONTENT_DRAWING );
+ break;
+
+ case SC_HINT_AREALINKS_CHANGED:
+ aLbEntries.Refresh( SC_CONTENT_AREALINK );
+ break;
+
+ // SFX_HINT_DOCCHANGED kommt nicht nur bei Dokument-Wechsel
+
+ case SC_HINT_NAVIGATOR_UPDATEALL:
+ UpdateAll();
+ break;
+
+ case FID_DATACHANGED:
+ case FID_ANYDATACHANGED:
+ aContentTimer.Start(); // Notizen nicht sofort suchen
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ else if ( rHint.ISA(SfxEventHint) )
+ {
+ ULONG nEventId = ((SfxEventHint&)rHint).GetEventId();
+ if ( nEventId == SFX_EVENT_ACTIVATEDOC )
+ {
+ aLbEntries.ActiveDocChanged();
+ UpdateAll();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScNavigatorDlg, TimeHdl, Timer*, pTimer )
+{
+ if ( pTimer != &aContentTimer )
+ return 0;
+
+ aLbEntries.Refresh( SC_CONTENT_NOTE );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::SetDropMode(USHORT nNew)
+{
+ nDropMode = nNew;
+ aTbxCmd.UpdateButtons();
+
+ ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
+ rCfg.SetDragMode(nDropMode);
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::CursorPosChanged()
+{
+ //! Eintraege selektieren ???
+
+// if ( GetDBAtCursor( aStrDbName ) )
+// if ( GetAreaAtCursor( aStrAreaName ) )
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo )
+{
+ if ( (nColNo+1 != nCurCol) || (nRowNo+1 != nCurRow) )
+ {
+ // SID_CURRENTCELL == Item #0 Cache leeren, damit das Setzen der
+ // aktuellen Zelle auch in zusammengefassten Bereichen funktioniert.
+ ppBoundItems[0]->ClearCache();
+
+ ScAddress aScAddress( nColNo, nRowNo, 0 );
+ String aAddr;
+ aScAddress.Format( aAddr, SCA_ABS );
+
+ BOOL bUnmark = FALSE;
+ if ( GetViewData() )
+ bUnmark = !pViewData->GetMarkData().IsCellMarked( nColNo, nRowNo );
+
+ SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
+ SfxBoolItem aUnmarkItem( FN_PARAM_1, bUnmark ); // ggf. Selektion aufheben
+
+ rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aPosItem, &aUnmarkItem, 0L );
+ }
+}
+
+void ScNavigatorDlg::SetCurrentCellStr( const String rName )
+{
+ ppBoundItems[0]->ClearCache();
+ SfxStringItem aNameItem( SID_CURRENTCELL, rName );
+
+ rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aNameItem, 0L );
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::SetCurrentTable( SCTAB nTabNo )
+{
+ if ( nTabNo != nCurTab )
+ {
+ // Tabelle fuer Basic ist 1-basiert
+ SfxUInt16Item aTabItem( SID_CURRENTTAB, static_cast<sal_uInt16>(nTabNo) + 1 );
+ rBindings.GetDispatcher()->Execute( SID_CURRENTTAB,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aTabItem, 0L );
+ }
+}
+
+void ScNavigatorDlg::SetCurrentTableStr( const String rName )
+{
+ if (!GetViewData()) return;
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nCount = pDoc->GetTableCount();
+ String aTabName;
+
+ for ( SCTAB i=0; i<nCount; i++ )
+ {
+ pDoc->GetName( i, aTabName );
+ if ( aTabName == rName )
+ {
+ SetCurrentTable( i );
+ return;
+ }
+ }
+
+ Sound::Beep(); // Tabelle nicht gefunden
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::SetCurrentObject( const String rName )
+{
+ SfxStringItem aNameItem( SID_CURRENTOBJECT, rName );
+ rBindings.GetDispatcher()->Execute( SID_CURRENTOBJECT,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aNameItem, 0L );
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::SetCurrentDoc( const String& rDocName ) // aktivieren
+{
+ SfxStringItem aDocItem( SID_CURRENTDOC, rDocName );
+ rBindings.GetDispatcher()->Execute( SID_CURRENTDOC,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aDocItem, 0L );
+}
+
+//------------------------------------------------------------------------
+
+ScTabViewShell* ScNavigatorDlg::GetTabViewShell() const
+{
+ return PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+}
+
+//------------------------------------------------------------------------
+
+ScNavigatorSettings* ScNavigatorDlg::GetNavigatorSettings()
+{
+ // #95791# Don't store the settings pointer here, because the settings belong to
+ // the view, and the view may be closed while the navigator is open (reload).
+ // If the pointer is cached here again later for performance reasons, it has to
+ // be forgotten when the view is closed.
+
+ ScTabViewShell* pViewSh = GetTabViewShell();
+ return pViewSh ? pViewSh->GetNavigatorSettings() : NULL;
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScNavigatorDlg::GetViewData()
+{
+ ScTabViewShell* pViewSh = GetTabViewShell();
+ pViewData = pViewSh ? pViewSh->GetViewData() : NULL;
+
+ return ( pViewData != NULL );
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::UpdateColumn( const SCCOL* pCol )
+{
+ if ( pCol )
+ nCurCol = *pCol;
+ else if ( GetViewData() )
+ nCurCol = pViewData->GetCurX() + 1;
+
+ aEdCol.SetCol( nCurCol );
+ CheckDataArea();
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::UpdateRow( const SCROW* pRow )
+{
+ if ( pRow )
+ nCurRow = *pRow;
+ else if ( GetViewData() )
+ nCurRow = pViewData->GetCurY() + 1;
+
+ aEdRow.SetRow( nCurRow );
+ CheckDataArea();
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::UpdateTable( const SCTAB* pTab )
+{
+ if ( pTab )
+ nCurTab = *pTab;
+ else if ( GetViewData() )
+ nCurTab = pViewData->GetTabNo();
+
+// aLbTables.SetTab( nCurTab );
+ CheckDataArea();
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::UpdateAll()
+{
+ switch ( eListMode )
+ {
+ case NAV_LMODE_DOCS:
+ case NAV_LMODE_DBAREAS:
+ case NAV_LMODE_AREAS:
+ aLbEntries.Refresh();
+ break;
+
+ case NAV_LMODE_NONE:
+ //! ???
+ break;
+
+ default:
+ break;
+ }
+
+ aContentTimer.Stop(); // dann nicht nochmal
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::SetListMode( NavListMode eMode, BOOL bSetSize )
+{
+ if ( eMode != eListMode )
+ {
+ if ( eMode != NAV_LMODE_NONE )
+ bFirstBig = FALSE; // nicht mehr automatisch umschalten
+
+ eListMode = eMode;
+
+ switch ( eMode )
+ {
+ case NAV_LMODE_NONE:
+ ShowList( FALSE, bSetSize );
+ break;
+
+ case NAV_LMODE_AREAS:
+ case NAV_LMODE_DBAREAS:
+ case NAV_LMODE_DOCS:
+ aLbEntries.Refresh();
+ ShowList( TRUE, bSetSize );
+ break;
+
+ case NAV_LMODE_SCENARIOS:
+ ShowScenarios( TRUE, bSetSize );
+ break;
+ }
+
+ aTbxCmd.UpdateButtons();
+
+ if ( eMode != NAV_LMODE_NONE )
+ {
+ ScNavipiCfg& rCfg = SC_MOD()->GetNavipiCfg();
+ rCfg.SetListMode( (USHORT) eMode );
+ }
+ }
+
+ if ( pMarkArea )
+ UnmarkDataArea();
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::ShowList( BOOL bShow, BOOL bSetSize )
+{
+ FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
+ Size aSize = GetParent()->GetOutputSizePixel();
+
+ if ( bShow )
+ {
+ Size aMinSize = aInitSize;
+
+ aMinSize.Height() += nInitListHeight;
+ if ( pFloat )
+ pFloat->SetMinOutputSizePixel( aMinSize );
+ aSize.Height() = nListModeHeight;
+ aLbEntries.Show();
+ aLbDocuments.Show();
+ }
+ else
+ {
+ if ( pFloat )
+ {
+ pFloat->SetMinOutputSizePixel( aInitSize );
+ nListModeHeight = aSize.Height();
+ }
+ aSize.Height() = aInitSize.Height();
+ aLbEntries.Hide();
+ aLbDocuments.Hide();
+ }
+ aWndScenarios.Hide();
+
+ if ( pFloat )
+ {
+ if ( bSetSize )
+ pFloat->SetOutputSizePixel( aSize );
+ }
+ else
+ {
+ SfxNavigator* pNav = (SfxNavigator*)GetParent();
+ Size aFloating = pNav->GetFloatingSize();
+ aFloating.Height() = aSize.Height();
+ pNav->SetFloatingSize( aFloating );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::ShowScenarios( BOOL bShow, BOOL bSetSize )
+{
+ FloatingWindow* pFloat = pContextWin->GetFloatingWindow();
+ Size aSize = GetParent()->GetOutputSizePixel();
+
+ if ( bShow )
+ {
+ Size aMinSize = aInitSize;
+ aMinSize.Height() += nInitListHeight;
+ if ( pFloat )
+ pFloat->SetMinOutputSizePixel( aMinSize );
+ aSize.Height() = nListModeHeight;
+
+ rBindings.Invalidate( SID_SELECT_SCENARIO );
+ rBindings.Update( SID_SELECT_SCENARIO );
+
+ aWndScenarios.Show();
+ aLbDocuments.Show();
+ }
+ else
+ {
+ if ( pFloat )
+ {
+ pFloat->SetMinOutputSizePixel( aInitSize );
+ nListModeHeight = aSize.Height();
+ }
+ aSize.Height() = aInitSize.Height();
+ aWndScenarios.Hide();
+ aLbDocuments.Hide();
+ }
+ aLbEntries.Hide();
+
+ if ( pFloat )
+ {
+ if ( bSetSize )
+ pFloat->SetOutputSizePixel( aSize );
+ }
+ else
+ {
+ SfxNavigator* pNav = (SfxNavigator*)GetParent();
+ Size aFloating = pNav->GetFloatingSize();
+ aFloating.Height() = aSize.Height();
+ pNav->SetFloatingSize( aFloating );
+ }
+}
+
+
+//------------------------------------------------------------------------
+//
+// Dokumente fuer Dropdown-Listbox
+//
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::GetDocNames( const String* pManualSel )
+{
+ aLbDocuments.Clear();
+ aLbDocuments.SetUpdateMode( FALSE );
+
+ ScDocShell* pCurrentSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+
+ String aSelEntry;
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ while ( pSh )
+ {
+ if ( pSh->ISA(ScDocShell) )
+ {
+ String aName = pSh->GetTitle();
+ String aEntry = aName;
+ if (pSh == pCurrentSh)
+ aEntry += aStrActive;
+ else
+ aEntry += aStrNotActive;
+ aLbDocuments.InsertEntry( aEntry );
+
+ if ( pManualSel ? ( aName == *pManualSel )
+ : ( pSh == pCurrentSh ) )
+ aSelEntry = aEntry; // kompletter Eintrag zum Selektieren
+ }
+
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+
+ aLbDocuments.InsertEntry( aStrActiveWin );
+
+ String aHidden = aLbEntries.GetHiddenTitle();
+ if (aHidden.Len())
+ {
+ String aEntry = aHidden;
+ aEntry += aStrHidden;
+ aLbDocuments.InsertEntry( aEntry );
+
+ if ( pManualSel && aHidden == *pManualSel )
+ aSelEntry = aEntry;
+ }
+
+ aLbDocuments.SetUpdateMode( TRUE );
+
+ aLbDocuments.SelectEntry( aSelEntry );
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::MarkDataArea()
+{
+ ScTabViewShell* pViewSh = GetTabViewShell();
+
+ if ( pViewSh )
+ {
+ if ( !pMarkArea )
+ pMarkArea = new ScArea;
+
+ pViewSh->MarkDataArea();
+ ScRange aMarkRange;
+ pViewSh->GetViewData()->GetMarkData().GetMarkArea(aMarkRange);
+ pMarkArea->nColStart = aMarkRange.aStart.Col();
+ pMarkArea->nRowStart = aMarkRange.aStart.Row();
+ pMarkArea->nColEnd = aMarkRange.aEnd.Col();
+ pMarkArea->nRowEnd = aMarkRange.aEnd.Row();
+ pMarkArea->nTab = aMarkRange.aStart.Tab();
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::UnmarkDataArea()
+{
+ ScTabViewShell* pViewSh = GetTabViewShell();
+
+ if ( pViewSh )
+ {
+ pViewSh->Unmark();
+ DELETEZ( pMarkArea );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::CheckDataArea()
+{
+ if ( aTbxCmd.IsItemChecked( IID_DATA ) && pMarkArea )
+ {
+ if ( nCurTab != pMarkArea->nTab
+ || nCurCol < pMarkArea->nColStart+1
+ || nCurCol > pMarkArea->nColEnd+1
+ || nCurRow < pMarkArea->nRowStart+1
+ || nCurRow > pMarkArea->nRowEnd+1 )
+ {
+ aTbxCmd.SetItemState( IID_DATA, TriState(STATE_CHECK) );
+ aTbxCmd.Select( IID_DATA );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::StartOfDataArea()
+{
+ // pMarkArea auswerten ???
+
+ if ( GetViewData() )
+ {
+ ScMarkData& rMark = pViewData->GetMarkData();
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+
+ SCCOL nCol = aMarkRange.aStart.Col();
+ SCROW nRow = aMarkRange.aStart.Row();
+
+ if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
+ SetCurrentCell( nCol, nRow );
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScNavigatorDlg::EndOfDataArea()
+{
+ // pMarkArea auswerten ???
+
+ if ( GetViewData() )
+ {
+ ScMarkData& rMark = pViewData->GetMarkData();
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+
+ SCCOL nCol = aMarkRange.aEnd.Col();
+ SCROW nRow = aMarkRange.aEnd.Row();
+
+ if ( (nCol+1 != aEdCol.GetCol()) || (nRow+1 != aEdRow.GetRow()) )
+ SetCurrentCell( nCol, nRow );
+ }
+}
+
+//------------------------------------------------------------------------
+
+SfxChildAlignment __EXPORT ScNavigatorDlg::CheckAlignment(
+ SfxChildAlignment eActAlign, SfxChildAlignment eAlign )
+{
+ SfxChildAlignment eRetAlign;
+
+ //! kein Andocken, wenn Listbox nicht da ???
+
+ switch (eAlign)
+ {
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_HIGHESTBOTTOM:
+ eRetAlign = eActAlign; // nicht erlaubt
+ break;
+
+ case SFX_ALIGN_LEFT:
+ case SFX_ALIGN_RIGHT:
+ case SFX_ALIGN_FIRSTLEFT:
+ case SFX_ALIGN_LASTLEFT:
+ case SFX_ALIGN_FIRSTRIGHT:
+ case SFX_ALIGN_LASTRIGHT:
+ eRetAlign = eAlign; // erlaubt
+ break;
+
+ default:
+ eRetAlign = eAlign;
+ break;
+ }
+ return eRetAlign;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/navipi/navipi.hrc b/sc/source/ui/navipi/navipi.hrc
new file mode 100644
index 000000000000..2ae1121e448d
--- /dev/null
+++ b/sc/source/ui/navipi/navipi.hrc
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+
+//#define RID_SCDLG_NAVIGATOR 256
+
+#define FT_ROW 1
+#define ED_ROW 2
+#define FT_COL 3
+#define ED_COL 4
+#define LB_DOCUMENTS 5
+#define LB_ENTRIES 6
+#define TBX_CMD 7
+#define STR_DRAGMODE 8
+#define STR_DISPLAY 9
+#define STR_ACTIVE 10
+#define STR_NOTACTIVE 11
+#define STR_HIDDEN 12
+#define STR_ACTIVEWIN 13
+//#define IMG_ENTRIES 14
+#define STR_QHLP_SCEN_LISTBOX 15
+#define STR_QHLP_SCEN_COMMENT 16
+#define IL_CMD 17
+#define ILH_CMD 18
+
+
+
+#define IID_AREAS 1
+#define IID_DBAREAS 2
+#define IID_DATA 3
+#define IID_DOCS 4
+#define IID_UP 5
+#define IID_DOWN 6
+#define IID_SCENARIOS 7
+#define IID_DROPMODE 9
+#define IID_CHANGEROOT 10
+#define IID_ZOOMOUT 11
+
+
diff --git a/sc/source/ui/navipi/navipi.src b/sc/source/ui/navipi/navipi.src
new file mode 100644
index 000000000000..a2ef5b4f6e69
--- /dev/null
+++ b/sc/source/ui/navipi/navipi.src
@@ -0,0 +1,414 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "navipi.hrc"
+
+#define SC_NAVI_CMD_IDLIST \
+ IdList = \
+ { \
+ IID_DATA ; \
+ IID_UP ; \
+ IID_DOWN ; \
+ IID_SCENARIOS ; \
+ IID_DROPMODE ; \
+ IID_CHANGEROOT ; \
+ IID_ZOOMOUT ; \
+ }; \
+ IdCount = { 8 ; };
+
+// SC_CONTENT_...
+#define SC_NAVI_CONT_IDLIST \
+ IdList = \
+ { \
+ 1 ; \
+ 2 ; \
+ 3 ; \
+ 4 ; \
+ 5 ; \
+ 6 ; \
+ 7 ; \
+ 8 ; \
+ }; \
+ IdCount = { 8 ; };
+
+Window RID_SCDLG_NAVIGATOR
+{
+ SVLook = TRUE ;
+ HelpId = HID_SC_NAVIGATOR ;
+ //? Pos = MAP_APPFONT( 0, 0 );
+ Size = MAP_APPFONT ( 115 , 116 ) ;
+ OutputSize = TRUE ;
+ DialogControl = TRUE ;
+ Hide = TRUE ;
+ Text [ en-US ] = "Navigator" ;
+ // Closeable = TRUE ;
+ // Moveable = TRUE ;
+ // Zoomable = TRUE ;
+ // Sizeable = TRUE ;
+ // EnableResizing = TRUE ;
+ // HideWhenDeactivate = TRUE ;
+ // Border = TRUE ;
+ // Dockable = TRUE ;
+ FixedText FT_ROW
+ {
+ // Pos = MAP_APPFONT( 2, 20 );
+ Pos = MAP_APPFONT ( 2 , 19 ) ;
+ // an kleinere Toolbox-Bitmaps angepasst
+ Size = MAP_APPFONT ( 19 , 10 ) ;
+ Text [ en-US ] = "Row" ;
+ };
+ NumericField ED_ROW
+ {
+ HelpId = HID_SC_NAVIPI_ROW ;
+ Border = TRUE ;
+ // Pos = MAP_APPFONT( 31, 19 );
+ Pos = MAP_APPFONT ( 31 , 18 ) ;
+ // an kleinere Toolbox-Bitmaps angepasst
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ Right = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 1 ;
+ Minimum = 1 ;
+ First = 1 ;
+ QuickHelpText [ en-US ] = "Row" ;
+ };
+ FixedText FT_COL
+ {
+ Pos = MAP_APPFONT ( 2 , 5 ) ;
+ Size = MAP_APPFONT ( 23 , 10 ) ;
+ Text [ en-US ] = "Column" ;
+ };
+ SpinField ED_COL
+ {
+ HelpId = HID_SC_NAVIPI_COL ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 31 , 4 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ Right = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ QuickHelpText [ en-US ] = "Column" ;
+ };
+ Control LB_ENTRIES
+ {
+ // "Control" braucht immer eigene HelpId
+ HelpId = HID_SC_NAVIPI_ENTRIES ;
+ Border = TRUE ;
+ // Pos = MAP_APPFONT( 2, 52 );
+ Pos = MAP_APPFONT ( 2 , 35 ) ;
+ Size = MAP_APPFONT ( 110 , 100 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_DOCUMENTS
+ {
+ HelpId = HID_SC_NAVIPI_DOC ;
+ Border = TRUE ;
+ // Pos = MAP_APPFONT( 2, 35 );
+ Pos = MAP_APPFONT ( 2 , 89 ) ;
+ Size = MAP_APPFONT ( 82 , 50 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ QuickHelpText [ en-US ] = "Document" ;
+ };
+ ImageList IL_CMD
+ {
+ Prefix = "na";
+ MaskColor = STD_MASKCOLOR ;
+ SC_NAVI_CMD_IDLIST
+ };
+ ImageList ILH_CMD
+ {
+ Prefix = "nah";
+ MaskColor = SC_HC_MASKCOLOR ;
+ SC_NAVI_CMD_IDLIST
+ };
+ ToolBox TBX_CMD
+ {
+ Pos = MAP_APPFONT ( 66 , 3 ) ;
+ HelpId = HID_SC_NAVIPI_TOOLBOX ;
+ SVLook = TRUE ;
+ Border = FALSE ;
+ LineCount = 2 ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = IID_DATA ;
+ HelpId = HID_SC_NAVIPI_DATA ;
+ Text [ en-US ] = "Data Range" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = IID_UP ;
+ HelpId = HID_SC_NAVIPI_UP ;
+ Text [ en-US ] = "Start" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = IID_DOWN ;
+ HelpId = HID_SC_NAVIPI_DOWN ;
+ Text [ en-US ] = "End" ;
+ };
+ //--------------------------------------------
+ // ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR; };
+ //--------------------------------------------
+ //----------------------------------------
+ ToolBoxItem { Type = TOOLBOXITEM_BREAK ; };
+ //----------------------------------------
+ ToolBoxItem
+ {
+ Identifier = IID_ZOOMOUT ;
+ HelpId = HID_SC_NAVIPI_ZOOM ;
+ Text [ en-US ] = "Contents" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = IID_CHANGEROOT ;
+ HelpId = HID_SC_NAVIPI_ROOT ;
+ Text [ en-US ] = "Toggle" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = IID_SCENARIOS ;
+ HelpId = HID_SC_NAVIPI_SCEN ;
+ Text [ en-US ] = "Scenarios" ;
+ };
+ ToolBoxItem
+ {
+ Identifier = IID_DROPMODE ;
+ HelpId = HID_SC_NAVIPI_DROP ;
+ DropDown = TRUE ;
+ Text [ en-US ] = "Drag Mode" ;
+ };
+ };
+ };
+ String STR_DRAGMODE
+ {
+ Text [ en-US ] = "Drag Mode" ;
+ };
+ String STR_DISPLAY
+ {
+ Text [ en-US ] = "Display" ;
+ };
+ String STR_ACTIVE
+ {
+ Text [ en-US ] = "active" ;
+ };
+ String STR_NOTACTIVE
+ {
+ Text [ en-US ] = "inactive" ;
+ };
+ String STR_HIDDEN
+ {
+ Text [ en-US ] = "hidden" ;
+ };
+ String STR_ACTIVEWIN
+ {
+ Text [ en-US ] = "Active Window" ;
+ };
+
+ String STR_QHLP_SCEN_LISTBOX
+ {
+ Text [ en-US ] = "Scenario Name";
+ };
+
+ String STR_QHLP_SCEN_COMMENT
+ {
+ Text [ en-US ] = "Comment";
+ };
+
+};
+
+
+ImageList RID_IMAGELIST_NAVCONT
+{
+ Prefix = "nc";
+ MaskColor = STD_MASKCOLOR ;
+ SC_NAVI_CONT_IDLIST
+};
+ImageList RID_IMAGELIST_H_NAVCONT
+{
+ Prefix = "nch";
+ MaskColor = SC_HC_MASKCOLOR ;
+ SC_NAVI_CONT_IDLIST
+};
+
+Image RID_IMG_DROP_URL
+{
+ ImageBitmap = Bitmap { File = "dropurl.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+};
+Image RID_IMG_DROP_LINK
+{
+ ImageBitmap = Bitmap { File = "droplink.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+};
+Image RID_IMG_DROP_COPY
+{
+ ImageBitmap = Bitmap { File = "dropcopy.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+};
+Image RID_IMG_H_DROP_URL
+{
+ ImageBitmap = Bitmap { File = "dropurl_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR ;
+};
+Image RID_IMG_H_DROP_LINK
+{
+ ImageBitmap = Bitmap { File = "droplink_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR ;
+};
+Image RID_IMG_H_DROP_COPY
+{
+ ImageBitmap = Bitmap { File = "dropcopy_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR ;
+};
+
+// content description strings are also used in ScLinkTargetsObj
+
+String SCSTR_CONTENT_ROOT
+{
+ Text [ en-US ] = "Contents" ;
+};
+String SCSTR_CONTENT_TABLE
+{
+ Text [ en-US ] = "Sheets" ;
+};
+String SCSTR_CONTENT_RANGENAME
+{
+ Text [ en-US ] = "Range names" ;
+};
+String SCSTR_CONTENT_DBAREA
+{
+ Text [ en-US ] = "Database Ranges" ;
+};
+String SCSTR_CONTENT_GRAPHIC
+{
+ Text [ en-US ] = "Graphics" ;
+};
+String SCSTR_CONTENT_OLEOBJECT
+{
+ Text [ en-US ] = "OLE objects" ;
+};
+String SCSTR_CONTENT_NOTE
+{
+ Text [ en-US ] = "Comments" ;
+};
+String SCSTR_CONTENT_AREALINK
+{
+ Text [ en-US ] = "Linked areas" ;
+};
+String SCSTR_CONTENT_DRAWING
+{
+ Text [ en-US ] = "Drawing objects";
+};
+ // PopupMenu -------------------------------------------------------------
+Menu RID_POPUP_DROPMODE
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = RID_DROPMODE_URL ;
+ HelpId = HID_SC_DROPMODE_URL ;
+ Text [ en-US ] = "Insert as Hyperlink" ;
+ };
+ MenuItem
+ {
+ Identifier = RID_DROPMODE_LINK ;
+ HelpId = HID_SC_DROPMODE_LINK ;
+ Text [ en-US ] = "Insert as Link" ;
+ };
+ MenuItem
+ {
+ Identifier = RID_DROPMODE_COPY ;
+ HelpId = HID_SC_DROPMODE_COPY ;
+ Text [ en-US ] = "Insert as Copy" ;
+ };
+ };
+};
+Menu RID_POPUP_NAVIPI_SCENARIO
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = RID_NAVIPI_SCENARIO_DELETE ;
+ HelpId = HID_SC_SCENARIO_DELETE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ MenuItem
+ {
+ Identifier = RID_NAVIPI_SCENARIO_EDIT ;
+ HelpId = HID_SC_SCENARIO_EDIT ;
+ Text [ en-US ] = "Properties..." ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/navipi/scenwnd.cxx b/sc/source/ui/navipi/scenwnd.cxx
new file mode 100644
index 000000000000..01ce358a2adf
--- /dev/null
+++ b/sc/source/ui/navipi/scenwnd.cxx
@@ -0,0 +1,311 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/slstitm.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include "navipi.hxx"
+#include "popmenu.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+
+//========================================================================
+// class ScScenarioWindow ------------------------------------------------
+//========================================================================
+
+ScScenarioListBox::ScScenarioListBox( ScScenarioWindow& rParent ) :
+ ListBox( &rParent, WB_BORDER | WB_TABSTOP ),
+ mrParent( rParent )
+{
+ Font aFont( GetFont() );
+ aFont.SetTransparent( TRUE );
+ aFont.SetWeight( WEIGHT_LIGHT );
+ SetFont( aFont );
+}
+
+ScScenarioListBox::~ScScenarioListBox()
+{
+}
+
+void ScScenarioListBox::UpdateEntries( List* pNewEntryList )
+{
+ Clear();
+ maEntries.clear();
+
+ if( !pNewEntryList )
+ return;
+
+ switch( pNewEntryList->Count() )
+ {
+ case 0:
+ // no scenarios in current sheet
+ mrParent.SetComment( EMPTY_STRING );
+ break;
+
+ case 1:
+ // sheet is a scenario container, comment only
+ mrParent.SetComment( *static_cast< String* >( pNewEntryList->First() ) );
+ break;
+
+ default:
+ {
+ // sheet contains scenarios
+ DBG_ASSERT( pNewEntryList->Count() % 3 == 0, "ScScenarioListBox::UpdateEntries - wrong list size" );
+ SetUpdateMode( FALSE );
+ String* pEntry = static_cast< String* >( pNewEntryList->First() );
+ while( pEntry )
+ {
+ ScenarioEntry aEntry;
+
+ // first entry of a triple is the scenario name
+ aEntry.maName = *pEntry;
+ // second entry of a triple is the scenario comment
+ if( (pEntry = static_cast< String* >( pNewEntryList->Next() )) != 0 )
+ aEntry.maComment = *pEntry;
+ // third entry of a triple is the protection ("0" = not protected, "1" = protected)
+ if( (pEntry = static_cast< String* >( pNewEntryList->Next() )) != 0 )
+ aEntry.mbProtected = (pEntry->Len() > 0) && (pEntry->GetChar( 0 ) != '0');
+
+ maEntries.push_back( aEntry );
+ InsertEntry( aEntry.maName, LISTBOX_APPEND );
+ pEntry = static_cast< String* >( pNewEntryList->Next() );
+ }
+ SetUpdateMode( TRUE );
+ SetNoSelection();
+ mrParent.SetComment( EMPTY_STRING );
+ }
+ }
+}
+
+void ScScenarioListBox::Select()
+{
+ if( const ScenarioEntry* pEntry = GetSelectedEntry() )
+ mrParent.SetComment( pEntry->maComment );
+}
+
+void ScScenarioListBox::DoubleClick()
+{
+ SelectScenario();
+}
+
+long ScScenarioListBox::Notify( NotifyEvent& rNEvt )
+{
+ bool bHandled = false;
+
+ if( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ KeyCode aCode = rNEvt.GetKeyEvent()->GetKeyCode();
+ switch( aCode.GetCode() )
+ {
+ case KEY_RETURN:
+ SelectScenario();
+ bHandled = true;
+ break;
+ case KEY_DELETE:
+ DeleteScenario( true );
+ bHandled = true;
+ break;
+ }
+ }
+ else if ( rNEvt.GetType() == EVENT_COMMAND && GetSelectEntryCount() )
+ {
+ const CommandEvent* pCEvt = rNEvt.GetCommandEvent();
+ if ( pCEvt && pCEvt->GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ if( const ScenarioEntry* pEntry = GetSelectedEntry() )
+ {
+ if( !pEntry->mbProtected )
+ {
+ ScPopupMenu aPopup( ScResId( RID_POPUP_NAVIPI_SCENARIO ) );
+ aPopup.Execute( this, pCEvt->GetMousePosPixel() );
+ if (aPopup.WasHit())
+ {
+ switch( aPopup.GetSelected() )
+ {
+ case RID_NAVIPI_SCENARIO_DELETE:
+ DeleteScenario( true );
+ break;
+ case RID_NAVIPI_SCENARIO_EDIT:
+ EditScenario();
+ break;
+ }
+ }
+ }
+ }
+ bHandled = true;
+ }
+ }
+
+ return bHandled ? 1 : ListBox::Notify( rNEvt );
+}
+
+const ScScenarioListBox::ScenarioEntry* ScScenarioListBox::GetSelectedEntry() const
+{
+ size_t nPos = GetSelectEntryPos();
+ return (nPos < maEntries.size()) ? &maEntries[ nPos ] : 0;
+}
+
+void ScScenarioListBox::ExecuteScenarioSlot( USHORT nSlotId )
+{
+ if( SfxViewFrame* pViewFrm = SfxViewFrame::Current() )
+ {
+ SfxStringItem aStringItem( nSlotId, GetSelectEntry() );
+ pViewFrm->GetDispatcher()->Execute( nSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aStringItem, 0L, 0L );
+ }
+}
+
+void ScScenarioListBox::SelectScenario()
+{
+ if( GetSelectEntryCount() > 0 )
+ ExecuteScenarioSlot( SID_SELECT_SCENARIO );
+}
+
+void ScScenarioListBox::EditScenario()
+{
+ if( GetSelectEntryCount() > 0 )
+ ExecuteScenarioSlot( SID_EDIT_SCENARIO );
+}
+
+void ScScenarioListBox::DeleteScenario( bool bQueryBox )
+{
+ if( GetSelectEntryCount() > 0 )
+ if( !bQueryBox || (::QueryBox( 0, WinBits( WB_YES_NO | WB_DEF_YES ), ScGlobal::GetRscString( STR_QUERY_DELSCENARIO ) ).Execute() == RET_YES) )
+ ExecuteScenarioSlot( SID_DELETE_SCENARIO );
+}
+
+//========================================================================
+// class ScScenarioWindow ------------------------------------------------
+//========================================================================
+
+ScScenarioWindow::ScScenarioWindow( Window* pParent,const String& aQH_List,
+ const String& aQH_Comment)
+ : Window ( pParent, WB_TABSTOP | WB_DIALOGCONTROL ),
+ aLbScenario ( *this ),
+ aEdComment ( this, WB_BORDER | WB_LEFT | WB_READONLY | WB_VSCROLL | WB_TABSTOP )
+{
+ Font aFont( GetFont() );
+ aFont.SetTransparent( TRUE );
+ aFont.SetWeight( WEIGHT_LIGHT );
+ aEdComment.SetFont( aFont );
+ aEdComment.SetMaxTextLen( 512 );
+ aLbScenario.SetPosPixel( Point(0,0) );
+ aLbScenario.SetHelpId(HID_SC_SCENWIN_TOP);
+ aEdComment.SetHelpId(HID_SC_SCENWIN_BOTTOM);
+ aLbScenario.Show();
+ aEdComment.Show();
+
+ aLbScenario.SetQuickHelpText(aQH_List);
+ aEdComment.SetQuickHelpText(aQH_Comment);
+ aEdComment.SetBackground( Color( COL_LIGHTGRAY ) );
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ {
+ SfxBindings& rBindings = pViewFrm->GetBindings();
+ rBindings.Invalidate( SID_SELECT_SCENARIO );
+ rBindings.Update( SID_SELECT_SCENARIO );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+ScScenarioWindow::~ScScenarioWindow()
+{
+}
+
+void ScScenarioWindow::Paint( const Rectangle& rRec )
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ Color aBgColor = rStyleSettings.GetFaceColor();
+
+ SetBackground( aBgColor );
+
+ Window::Paint( rRec );
+}
+
+// -----------------------------------------------------------------------
+
+void ScScenarioWindow::NotifyState( const SfxPoolItem* pState )
+{
+ if( pState )
+ {
+ aLbScenario.Enable();
+
+ if ( pState->ISA(SfxStringItem) )
+ {
+ String aNewEntry( ((const SfxStringItem*)pState)->GetValue() );
+
+ if ( aNewEntry.Len() > 0 )
+ aLbScenario.SelectEntry( aNewEntry );
+ else
+ aLbScenario.SetNoSelection();
+ }
+ else if ( pState->ISA(SfxStringListItem) )
+ {
+ aLbScenario.UpdateEntries( ((SfxStringListItem*)pState)->GetList() );
+ }
+ }
+ else
+ {
+ aLbScenario.Disable();
+ aLbScenario.SetNoSelection();
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScScenarioWindow::SetSizePixel( const Size& rNewSize )
+{
+ Size aSize( rNewSize );
+ long nHeight = aSize.Height() / 2;
+
+ Window::SetSizePixel( aSize );
+
+ aSize.Height() = nHeight;
+ aLbScenario.SetSizePixel( aSize );
+
+ aSize.Height() -= 4;
+ aEdComment.SetPosSizePixel( Point( 0, nHeight+4 ), aSize );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/makefile.mk b/sc/source/ui/optdlg/makefile.mk
new file mode 100644
index 000000000000..9c816f56f7b8
--- /dev/null
+++ b/sc/source/ui/optdlg/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=optdlg
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ tpusrlst.cxx \
+ tpview.cxx \
+ tpcalc.cxx \
+ tpformula.cxx \
+ tpprint.cxx \
+ opredlin.cxx
+
+EXCEPTIONSFILES= \
+ $(SLO)$/tpcompatibility.obj
+
+SLOFILES = \
+ $(SLO)$/tpusrlst.obj \
+ $(SLO)$/tpview.obj \
+ $(SLO)$/tpcalc.obj \
+ $(SLO)$/tpformula.obj \
+ $(SLO)$/tpcompatibility.obj \
+ $(SLO)$/tpprint.obj \
+ $(SLO)$/opredlin.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/tpcompatibility.obj \
+
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/optdlg/opredlin.cxx b/sc/source/ui/optdlg/opredlin.cxx
new file mode 100644
index 000000000000..cbaf73110cc5
--- /dev/null
+++ b/sc/source/ui/optdlg/opredlin.cxx
@@ -0,0 +1,291 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <svx/dlgutil.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/xtable.hxx>
+
+#include "appoptio.hxx"
+#include "scmod.hxx"
+#include "scitems.hxx"
+#include "tpview.hxx"
+#include "global.hxx"
+#include "viewopti.hxx"
+#include "tabvwsh.hxx"
+#include "uiitems.hxx"
+#include "scresid.hxx"
+#include "docsh.hxx"
+#include "sc.hrc" // -> Slot-IDs
+#include "optdlg.hrc"
+#include "globstr.hrc"
+
+#include "opredlin.hxx"
+#include "opredlin.hrc"
+
+//------------------------------------------------------------------
+
+ScRedlineOptionsTabPage::ScRedlineOptionsTabPage( Window* pParent,
+ const SfxItemSet& rSet )
+ : SfxTabPage(pParent, ScResId(RID_SCPAGE_OPREDLINE), rSet),
+ aContentFT ( this, ScResId(FT_CONTENT )),
+ aContentColorLB ( this, ScResId(CLB_CONTENT )),
+ aRemoveFT ( this, ScResId(FT_REMOVE )),
+ aRemoveColorLB ( this, ScResId(CLB_REMOVE )),
+ aInsertFT ( this, ScResId(FT_INSERT )),
+ aInsertColorLB ( this, ScResId(CLB_INSERT )),
+ aMoveFT ( this, ScResId(FT_MOVE )),
+ aMoveColorLB ( this, ScResId(CLB_MOVE )),
+ aChangedGB ( this, ScResId(GB_COLORCHGS)),
+ aAuthorStr (ScResId(STR_AUTHOR))
+{
+ FreeResource();
+
+ Link aLk = LINK(this, ScRedlineOptionsTabPage, ColorHdl);
+ aContentColorLB.SetSelectHdl( aLk );
+ aMoveColorLB.SetSelectHdl( aLk );
+ aInsertColorLB.SetSelectHdl( aLk );
+ aRemoveColorLB.SetSelectHdl( aLk );
+}
+
+/*-----------------------------------------------------------------------
+ Beschreibung:
+ -----------------------------------------------------------------------*/
+
+__EXPORT ScRedlineOptionsTabPage::~ScRedlineOptionsTabPage()
+{
+}
+
+/*-----------------------------------------------------------------------
+ Beschreibung:
+ -----------------------------------------------------------------------*/
+
+SfxTabPage* __EXPORT ScRedlineOptionsTabPage::Create( Window* pParent, const SfxItemSet& rSet )
+{
+ return new ScRedlineOptionsTabPage( pParent, rSet );
+}
+
+/*-----------------------------------------------------------------------
+ Beschreibung:
+ -----------------------------------------------------------------------*/
+
+BOOL __EXPORT ScRedlineOptionsTabPage::FillItemSet( SfxItemSet& /* rSet */ )
+{
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+
+ ULONG nNew=0;
+ USHORT nPos=0;
+
+ nPos = aContentColorLB.GetSelectEntryPos();
+ if (nPos != LISTBOX_ENTRY_NOTFOUND)
+ {
+ nPos = aContentColorLB.GetSelectEntryPos();
+ if (nPos!=0)
+ nNew= aContentColorLB.GetEntryColor(nPos).GetColor();
+ else
+ nNew= COL_TRANSPARENT;
+
+ aAppOptions.SetTrackContentColor(nNew);
+
+ }
+ nPos = aMoveColorLB.GetSelectEntryPos();
+ if (nPos != LISTBOX_ENTRY_NOTFOUND)
+ {
+ nPos = aMoveColorLB.GetSelectEntryPos();
+ if (nPos!=0)
+ nNew= aMoveColorLB.GetEntryColor(nPos).GetColor();
+ else
+ nNew= COL_TRANSPARENT;
+
+ aAppOptions.SetTrackMoveColor(nNew);
+
+ }
+ nPos = aInsertColorLB.GetSelectEntryPos();
+ if (nPos != LISTBOX_ENTRY_NOTFOUND)
+ {
+ nPos = aInsertColorLB.GetSelectEntryPos();
+ if (nPos!=0)
+ nNew= aInsertColorLB.GetEntryColor(nPos).GetColor();
+ else
+ nNew= COL_TRANSPARENT;
+
+ aAppOptions.SetTrackInsertColor(nNew);
+
+ }
+ nPos = aRemoveColorLB.GetSelectEntryPos();
+ if (nPos != LISTBOX_ENTRY_NOTFOUND)
+ {
+ nPos = aRemoveColorLB.GetSelectEntryPos();
+ if (nPos!=0)
+ nNew= aRemoveColorLB.GetEntryColor(nPos).GetColor();
+ else
+ nNew= COL_TRANSPARENT;
+
+ aAppOptions.SetTrackDeleteColor(nNew);
+
+ }
+
+ SC_MOD()->SetAppOptions(aAppOptions);
+
+ // Repaint (wenn alles ueber Items laufen wuerde, wie es sich gehoert,
+ // waere das nicht noetig...)
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
+ if (pDocSh)
+ pDocSh->PostPaintGridAll();
+
+ return FALSE;
+}
+
+/*-----------------------------------------------------------------------
+ Beschreibung:
+ -----------------------------------------------------------------------*/
+
+void __EXPORT ScRedlineOptionsTabPage::Reset( const SfxItemSet& /* rSet */ )
+{
+
+ XColorTable* pColorTbl = XColorTable::GetStdColorTable();
+ aContentColorLB.InsertEntry(aAuthorStr);
+ aMoveColorLB.InsertEntry(aAuthorStr);
+ aInsertColorLB.InsertEntry(aAuthorStr);
+ aRemoveColorLB.InsertEntry(aAuthorStr);
+
+ aContentColorLB.SetUpdateMode( FALSE);
+ aMoveColorLB.SetUpdateMode( FALSE);
+ aInsertColorLB.SetUpdateMode( FALSE);
+ aRemoveColorLB.SetUpdateMode( FALSE);
+
+ for( USHORT i = 0; i < pColorTbl->Count(); ++i )
+ {
+ XColorEntry* pEntry = pColorTbl->GetColor( i );
+ Color aColor = pEntry->GetColor();
+ String sName = pEntry->GetName();
+
+ aContentColorLB.InsertEntry( aColor, sName );
+ aMoveColorLB.InsertEntry( aColor, sName );
+ aInsertColorLB.InsertEntry( aColor, sName );
+ aRemoveColorLB.InsertEntry( aColor, sName );
+ }
+ aContentColorLB.SetUpdateMode( TRUE );
+ aMoveColorLB.SetUpdateMode( TRUE );
+ aInsertColorLB.SetUpdateMode( TRUE );
+ aRemoveColorLB.SetUpdateMode( TRUE );
+
+
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+
+ ULONG nColor = aAppOptions.GetTrackContentColor();
+ if (nColor == COL_TRANSPARENT)
+ aContentColorLB.SelectEntryPos(0);
+ else
+ aContentColorLB.SelectEntry(Color(nColor));
+
+ nColor = aAppOptions.GetTrackMoveColor();
+ if (nColor == COL_TRANSPARENT)
+ aMoveColorLB.SelectEntryPos(0);
+ else
+ aMoveColorLB.SelectEntry(Color(nColor));
+
+
+ nColor = aAppOptions.GetTrackInsertColor();
+ if (nColor == COL_TRANSPARENT)
+ aInsertColorLB.SelectEntryPos(0);
+ else
+ aInsertColorLB.SelectEntry(Color(nColor));
+
+
+ nColor = aAppOptions.GetTrackDeleteColor();
+ if (nColor == COL_TRANSPARENT)
+ aRemoveColorLB.SelectEntryPos(0);
+ else
+ aRemoveColorLB.SelectEntry(Color(nColor));
+
+}
+
+
+IMPL_LINK( ScRedlineOptionsTabPage, ColorHdl, ColorListBox *, EMPTYARG )
+{
+/*
+ SvxFontPrevWindow *pPrev;
+ ListBox *pLB;
+
+ if (pColorLB == &aInsertColorLB)
+ {
+ pPrev = &aInsertPreviewWN;
+ pLB = &aInsertLB;
+ }
+ else
+ {
+ pPrev = &aDeletedPreviewWN;
+ pLB = &aDeletedLB;
+ }
+
+ SvxFont& rFont = pPrev->GetFont();
+ USHORT nPos = pLB->GetSelectEntryPos();
+ if (nPos == LISTBOX_ENTRY_NOTFOUND)
+ nPos = 0;
+
+ CharAttr *pAttr = (CharAttr *)pLB->GetEntryData(nPos);
+
+ if (pAttr->nItemId == SID_ATTR_BRUSH)
+ {
+ rFont.SetColor(Color(COL_BLACK));
+ nPos = pColorLB->GetSelectEntryPos();
+ if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
+ {
+ Brush aBrush(Color(pColorLB->GetSelectEntryColor()));
+ pPrev->SetBrush(aBrush);
+ }
+ else
+ {
+ Brush aBrush(Color(COL_LIGHTGRAY));
+ pPrev->SetBrush(aBrush);
+ }
+ }
+ else
+ {
+ nPos = pColorLB->GetSelectEntryPos();
+ if (nPos && nPos != LISTBOX_ENTRY_NOTFOUND)
+ rFont.SetColor(pColorLB->GetEntryColor(nPos));
+ else
+ rFont.SetColor(Color(COL_RED));
+ }
+
+ pPrev->Invalidate();
+*/
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpcalc.cxx b/sc/source/ui/optdlg/tpcalc.cxx
new file mode 100644
index 000000000000..cf8f19720300
--- /dev/null
+++ b/sc/source/ui/optdlg/tpcalc.cxx
@@ -0,0 +1,307 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <vcl/msgbox.hxx>
+
+#include "global.hxx"
+#include "globstr.hrc"
+#include "uiitems.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "docoptio.hxx"
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot-IDs
+#include "optdlg.hrc"
+
+#define _TPCALC_CXX
+#include "tpcalc.hxx"
+#undef _TPCALC_CXX
+
+#include <math.h>
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pCalcOptRanges[] =
+{
+ SID_SCDOCOPTIONS,
+ SID_SCDOCOPTIONS,
+ 0
+};
+
+//========================================================================
+
+ScTpCalcOptions::ScTpCalcOptions( Window* pParent,
+ const SfxItemSet& rCoreAttrs )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_CALC ),
+ rCoreAttrs ),
+
+ aGbZRefs ( this, ScResId( GB_ZREFS ) ),
+ aBtnIterate ( this, ScResId( BTN_ITERATE ) ),
+ aFtSteps ( this, ScResId( FT_STEPS ) ),
+ aEdSteps ( this, ScResId( ED_STEPS ) ),
+ aFtEps ( this, ScResId( FT_EPS ) ),
+ aEdEps ( this, ScResId( ED_EPS ) ),
+ aSeparatorFL ( this, ScResId( FL_SEPARATOR ) ),
+ aGbDate ( this, ScResId( GB_DATE ) ),
+ aBtnDateStd ( this, ScResId( BTN_DATESTD ) ),
+ aBtnDateSc10 ( this, ScResId( BTN_DATESC10 ) ),
+ aBtnDate1904 ( this, ScResId( BTN_DATE1904 ) ),
+ aHSeparatorFL ( this, ScResId( FL_H_SEPARATOR ) ),
+ aBtnCase ( this, ScResId( BTN_CASE ) ),
+ aBtnCalc ( this, ScResId( BTN_CALC ) ),
+ aBtnMatch ( this, ScResId( BTN_MATCH ) ),
+ aBtnRegex ( this, ScResId( BTN_REGEX ) ),
+ aBtnLookUp ( this, ScResId( BTN_LOOKUP ) ),
+ aBtnGeneralPrec ( this, ScResId( BTN_GENERAL_PREC ) ),
+ aFtPrec ( this, ScResId( FT_PREC ) ),
+ aEdPrec ( this, ScResId( ED_PREC ) ),
+ pOldOptions ( new ScDocOptions(
+ ((const ScTpCalcItem&)rCoreAttrs.Get(
+ GetWhich( SID_SCDOCOPTIONS ))).
+ GetDocOptions() ) ),
+ pLocalOptions ( new ScDocOptions ),
+ nWhichCalc ( GetWhich( SID_SCDOCOPTIONS ) )
+{
+ aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT );
+ Init();
+ FreeResource();
+ SetExchangeSupport();
+}
+
+//-----------------------------------------------------------------------
+
+__EXPORT ScTpCalcOptions::~ScTpCalcOptions()
+{
+ delete pOldOptions;
+ delete pLocalOptions;
+}
+
+//-----------------------------------------------------------------------
+
+void ScTpCalcOptions::Init()
+{
+ aBtnIterate .SetClickHdl( LINK( this, ScTpCalcOptions, CheckClickHdl ) );
+ aBtnGeneralPrec.SetClickHdl( LINK(this, ScTpCalcOptions, CheckClickHdl) );
+ aBtnDateStd .SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+ aBtnDateSc10.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+ aBtnDate1904.SetClickHdl( LINK( this, ScTpCalcOptions, RadioClickHdl ) );
+}
+
+//-----------------------------------------------------------------------
+
+USHORT* __EXPORT ScTpCalcOptions::GetRanges()
+{
+ return pCalcOptRanges;
+}
+
+//-----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpCalcOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
+{
+ return ( new ScTpCalcOptions( pParent, rAttrSet ) );
+}
+
+//-----------------------------------------------------------------------
+
+void __EXPORT ScTpCalcOptions::Reset( const SfxItemSet& /* rCoreAttrs */ )
+{
+ USHORT d,m,y;
+
+ *pLocalOptions = *pOldOptions;
+
+ aBtnCase .Check( !pLocalOptions->IsIgnoreCase() );
+ aBtnCalc .Check( pLocalOptions->IsCalcAsShown() );
+ aBtnMatch .Check( pLocalOptions->IsMatchWholeCell() );
+ aBtnRegex .Check( pLocalOptions->IsFormulaRegexEnabled() );
+ aBtnLookUp .Check( pLocalOptions->IsLookUpColRowNames() );
+ aBtnIterate.Check( pLocalOptions->IsIter() );
+ aEdSteps .SetValue( pLocalOptions->GetIterCount() );
+ aEdEps .SetValue( pLocalOptions->GetIterEps(), 6 );
+
+ pLocalOptions->GetDate( d, m, y );
+
+ switch ( y )
+ {
+ case 1899:
+ aBtnDateStd.Check();
+ break;
+ case 1900:
+ aBtnDateSc10.Check();
+ break;
+ case 1904:
+ aBtnDate1904.Check();
+ break;
+ }
+
+ sal_uInt16 nPrec = pLocalOptions->GetStdPrecision();
+ if (nPrec == SvNumberFormatter::UNLIMITED_PRECISION)
+ {
+ aFtPrec.Disable();
+ aEdPrec.Disable();
+ aBtnGeneralPrec.Check(false);
+ }
+ else
+ {
+ aBtnGeneralPrec.Check();
+ aFtPrec.Enable();
+ aEdPrec.Enable();
+ aEdPrec.SetValue(nPrec);
+ }
+
+ CheckClickHdl( &aBtnIterate );
+}
+
+
+//-----------------------------------------------------------------------
+
+BOOL __EXPORT ScTpCalcOptions::FillItemSet( SfxItemSet& rCoreAttrs )
+{
+ // alle weiteren Optionen werden in den Handlern aktualisiert
+ pLocalOptions->SetIterCount( (USHORT)aEdSteps.GetValue() );
+ pLocalOptions->SetIgnoreCase( !aBtnCase.IsChecked() );
+ pLocalOptions->SetCalcAsShown( aBtnCalc.IsChecked() );
+ pLocalOptions->SetMatchWholeCell( aBtnMatch.IsChecked() );
+ pLocalOptions->SetFormulaRegexEnabled( aBtnRegex.IsChecked() );
+ pLocalOptions->SetLookUpColRowNames( aBtnLookUp.IsChecked() );
+
+ if (aBtnGeneralPrec.IsChecked())
+ pLocalOptions->SetStdPrecision(
+ static_cast<sal_uInt16>(aEdPrec.GetValue()) );
+ else
+ pLocalOptions->SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
+
+ if ( *pLocalOptions != *pOldOptions )
+ {
+ rCoreAttrs.Put( ScTpCalcItem( nWhichCalc, *pLocalOptions ) );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+int __EXPORT ScTpCalcOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ int nReturn = KEEP_PAGE;
+
+ double fEps;
+ if( aEdEps.GetValue( fEps ) && (fEps > 0.0) )
+ {
+ pLocalOptions->SetIterEps( fEps );
+ nReturn = LEAVE_PAGE;
+ }
+
+ if ( nReturn == KEEP_PAGE )
+ {
+ ErrorBox( this,
+ WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_INVALID_EPS )
+ ).Execute();
+
+ aEdEps.GrabFocus();
+ }
+ else if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return nReturn;
+}
+
+//-----------------------------------------------------------------------
+// Handler:
+
+IMPL_LINK( ScTpCalcOptions, RadioClickHdl, RadioButton*, pBtn )
+{
+ if ( pBtn == &aBtnDateStd )
+ {
+ pLocalOptions->SetDate( 30, 12, 1899 );
+ }
+ else if ( pBtn == &aBtnDateSc10 )
+ {
+ pLocalOptions->SetDate( 1, 1, 1900 );
+ }
+ else if ( pBtn == &aBtnDate1904 )
+ {
+ pLocalOptions->SetDate( 1, 1, 1904 );
+ }
+
+ return 0;
+}
+
+//-----------------------------------------------------------------------
+
+IMPL_LINK( ScTpCalcOptions, CheckClickHdl, CheckBox*, pBtn )
+{
+ if (pBtn == &aBtnGeneralPrec)
+ {
+ if (pBtn->IsChecked())
+ {
+ aEdPrec.Enable();
+ aFtPrec.Enable();
+ }
+ else
+ {
+ aEdPrec.Disable();
+ aFtPrec.Disable();
+ }
+ }
+ else if (pBtn == &aBtnIterate)
+ {
+ if ( pBtn->IsChecked() )
+ {
+ pLocalOptions->SetIter( TRUE );
+ aFtSteps.Enable(); aEdSteps.Enable();
+ aFtEps .Enable(); aEdEps .Enable();
+ }
+ else
+ {
+ pLocalOptions->SetIter( FALSE );
+ aFtSteps.Disable(); aEdSteps.Disable();
+ aFtEps .Disable(); aEdEps .Disable();
+ }
+ }
+
+ return 0;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpcompatibility.cxx b/sc/source/ui/optdlg/tpcompatibility.cxx
new file mode 100644
index 000000000000..7b69ecf744ee
--- /dev/null
+++ b/sc/source/ui/optdlg/tpcompatibility.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyrigt 2010 Novell, Inc.
+ *
+ * LibreOffice - a multi-platform office productivity suite
+ *
+ * This file is part of LibreOffice.
+ *
+ * LibreOffice is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * LibreOffice is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with LibreOffice. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include "tpcompatibility.hxx"
+#include "optdlg.hrc"
+#include "scresid.hxx"
+#include "docoptio.hxx"
+
+ScTpCompatOptions::ScTpCompatOptions(Window *pParent, const SfxItemSet &rCoreAttrs) :
+ SfxTabPage(pParent, ScResId(RID_SCPAGE_COMPATIBILITY), rCoreAttrs),
+ maFlKeyBindings(this, ScResId(FL_KEY_BINDINGS)),
+ maFtKeyBindings(this, ScResId(FT_KEY_BINDINGS)),
+ maLbKeyBindings(this, ScResId(LB_KEY_BINDINGS))
+{
+ FreeResource();
+
+ const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
+ rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
+ mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+ mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+}
+
+ScTpCompatOptions::~ScTpCompatOptions()
+{
+}
+
+SfxTabPage* ScTpCompatOptions::Create(Window *pParent, const SfxItemSet &rCoreAttrs)
+{
+ return new ScTpCompatOptions(pParent, rCoreAttrs);
+}
+
+BOOL ScTpCompatOptions::FillItemSet(SfxItemSet &rCoreAttrs)
+{
+ ScOptionsUtil::KeyBindingType eKeyB = ScOptionsUtil::KEY_DEFAULT;
+ switch (maLbKeyBindings.GetSelectEntryPos())
+ {
+ case 0:
+ eKeyB = ScOptionsUtil::KEY_DEFAULT;
+ break;
+ case 1:
+ eKeyB = ScOptionsUtil::KEY_OOO_LEGACY;
+ break;
+ default:
+ ;
+ }
+ mpNewOptions->SetKeyBindingType(eKeyB);
+
+ if (*mpNewOptions != *mpOldOptions)
+ {
+ rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
+ return true;
+ }
+ else
+ return false;
+}
+
+void ScTpCompatOptions::Reset(const SfxItemSet &/*rCoreAttrs*/)
+{
+ ScOptionsUtil::KeyBindingType eKeyB = mpOldOptions->GetKeyBindingType();
+ switch (eKeyB)
+ {
+ case ScOptionsUtil::KEY_DEFAULT:
+ maLbKeyBindings.SelectEntryPos(0);
+ break;
+ case ScOptionsUtil::KEY_OOO_LEGACY:
+ maLbKeyBindings.SelectEntryPos(1);
+ break;
+ default:
+ ;
+ }
+}
+
+int ScTpCompatOptions::DeactivatePage(SfxItemSet* /*pSet*/)
+{
+ return KEEP_PAGE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
new file mode 100644
index 000000000000..8d7dd7daff95
--- /dev/null
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -0,0 +1,294 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyrigt 2010 Novell, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tpcalc.hxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "tpformula.hxx"
+#include "optdlg.hrc"
+#include "scresid.hxx"
+#include "formula/grammar.hxx"
+#include "docoptio.hxx"
+#include "global.hxx"
+
+#include <unotools/localedatawrapper.hxx>
+
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/i18n/LocaleDataItem.hpp>
+
+using ::rtl::OUString;
+using ::com::sun::star::lang::Locale;
+using ::com::sun::star::i18n::LocaleDataItem;
+
+ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreAttrs) :
+ SfxTabPage(pParent, ScResId(RID_SCPAGE_FORMULA), rCoreAttrs),
+
+ maFlFormulaOpt(this, ScResId(FL_FORMULA_OPTIONS)),
+ maFtFormulaSyntax(this, ScResId(FT_FORMULA_SYNTAX)),
+ maLbFormulaSyntax(this, ScResId(LB_FORMULA_SYNTAX)),
+ maCbEnglishFuncName(this, ScResId(CB_ENGLISH_FUNC_NAME)),
+ maFlFormulaSeps(this, ScResId(FL_FORMULA_SEPS)),
+ maFtSepFuncArg(this, ScResId(FT_FORMULA_SEP_ARG)),
+ maEdSepFuncArg(this, ScResId(ED_FORMULA_SEP_ARG)),
+ maFtSepArrayCol(this, ScResId(FT_FORMULA_SEP_ARRAY_C)),
+ maEdSepArrayCol(this, ScResId(ED_FORMULA_SEP_ARRAY_C)),
+ maFtSepArrayRow(this, ScResId(FT_FORMULA_SEP_ARRAY_R)),
+ maEdSepArrayRow(this, ScResId(ED_FORMULA_SEP_ARRAY_R)),
+ maBtnSepReset(this, ScResId(BTN_FORMULA_SEP_RESET)),
+
+ mpOldOptions(NULL),
+ mpNewOptions(NULL),
+ mnDecSep(0)
+{
+ FreeResource();
+
+ const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
+ rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
+ mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+ mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
+
+ Init();
+}
+
+ScTpFormulaOptions::~ScTpFormulaOptions()
+{
+}
+
+void ScTpFormulaOptions::Init()
+{
+ Link aLink = LINK( this, ScTpFormulaOptions, ButtonHdl );
+ maBtnSepReset.SetClickHdl(aLink);
+
+ aLink = LINK( this, ScTpFormulaOptions, SepModifyHdl );
+ maEdSepFuncArg.SetModifyHdl(aLink);
+ maEdSepArrayCol.SetModifyHdl(aLink);
+ maEdSepArrayRow.SetModifyHdl(aLink);
+
+ aLink = LINK( this, ScTpFormulaOptions, SepEditOnFocusHdl );
+ maEdSepFuncArg.SetGetFocusHdl(aLink);
+ maEdSepArrayCol.SetGetFocusHdl(aLink);
+ maEdSepArrayRow.SetGetFocusHdl(aLink);
+
+ // Get the decimal separator for current locale.
+ String aSep = mpOldOptions->GetLocaleDataWrapper().getNumDecimalSep();
+ mnDecSep = aSep.Len() ? aSep.GetChar(0) : sal_Unicode('.');
+}
+
+void ScTpFormulaOptions::ResetSeparators()
+{
+ ScDocOptions aOpt;
+ maEdSepFuncArg.SetText(aOpt.GetFormulaSepArg());
+ maEdSepArrayCol.SetText(aOpt.GetFormulaSepArrayCol());
+ maEdSepArrayRow.SetText(aOpt.GetFormulaSepArrayRow());
+}
+
+void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit)
+{
+ if (!pEdit)
+ return;
+
+ // Make sure the entire text is selected.
+ xub_StrLen nLen = pEdit->GetText().Len();
+ Selection aSel(0, nLen);
+ pEdit->SetSelection(aSel);
+ maOldSepValue = pEdit->GetText();
+}
+
+bool ScTpFormulaOptions::IsValidSeparator(const OUString& rSep) const
+{
+ if (rSep.getLength() != 1)
+ // Must be one-character long.
+ return false;
+
+ if (rSep.compareToAscii("a") >= 0 && rSep.compareToAscii("z") <= 0)
+ return false;
+
+ if (rSep.compareToAscii("A") >= 0 && rSep.compareToAscii("Z") <= 0)
+ return false;
+
+ sal_Unicode c = rSep.getStr()[0];
+ switch (c)
+ {
+ case '+':
+ case '-':
+ case '/':
+ case '*':
+ case '<':
+ case '>':
+ case '[':
+ case ']':
+ case '(':
+ case ')':
+ case '"':
+ case '\'':
+ // Disallowed characters. Anything else we want to disallow ?
+ return false;
+ }
+
+ if (c == mnDecSep)
+ // decimal separator is not allowed.
+ return false;
+
+ return true;
+}
+
+bool ScTpFormulaOptions::IsValidSeparatorSet() const
+{
+ // Make sure the column and row separators are different.
+ String aColStr = maEdSepArrayCol.GetText();
+ String aRowStr = maEdSepArrayRow.GetText();
+ if (aColStr == aRowStr)
+ return false;
+
+ return true;
+}
+
+IMPL_LINK( ScTpFormulaOptions, ButtonHdl, PushButton*, pBtn )
+{
+ if (pBtn == &maBtnSepReset)
+ ResetSeparators();
+
+ return 0;
+}
+
+IMPL_LINK( ScTpFormulaOptions, SepModifyHdl, Edit*, pEdit )
+{
+ if (!pEdit)
+ return 0;
+
+ String aStr = pEdit->GetText();
+ if (aStr.Len() > 1)
+ {
+ // In case the string is more than one character long, only grab the
+ // first character.
+ aStr = aStr.Copy(0, 1);
+ pEdit->SetText(aStr);
+ }
+
+ if ((!IsValidSeparator(aStr) || !IsValidSeparatorSet()) && maOldSepValue.getLength())
+ // Invalid separator. Restore the old value.
+ pEdit->SetText(maOldSepValue);
+
+ OnFocusSeparatorInput(pEdit);
+ return 0;
+}
+
+IMPL_LINK( ScTpFormulaOptions, SepEditOnFocusHdl, Edit*, pEdit )
+{
+ OnFocusSeparatorInput(pEdit);
+ return 0;
+}
+
+// static
+SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& rCoreSet)
+{
+ return new ScTpFormulaOptions(pParent, rCoreSet);
+}
+
+BOOL ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
+{
+ ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
+ switch (maLbFormulaSyntax.GetSelectEntryPos())
+ {
+ case 0:
+ eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
+ break;
+ case 1:
+ eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
+ break;
+ case 2:
+ eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+ break;
+ }
+
+ mpNewOptions->SetFormulaSyntax(eGram);
+ mpNewOptions->SetUseEnglishFuncName(maCbEnglishFuncName.IsChecked());
+ mpNewOptions->SetFormulaSepArg(maEdSepFuncArg.GetText());
+ mpNewOptions->SetFormulaSepArrayCol(maEdSepArrayCol.GetText());
+ mpNewOptions->SetFormulaSepArrayRow(maEdSepArrayRow.GetText());
+
+ if (*mpNewOptions != *mpOldOptions)
+ {
+ rCoreSet.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
+ return true;
+ }
+ else
+ return false;
+}
+
+void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
+{
+ ::formula::FormulaGrammar::Grammar eGram = mpNewOptions->GetFormulaSyntax();
+ switch (eGram)
+ {
+ case ::formula::FormulaGrammar::GRAM_NATIVE:
+ maLbFormulaSyntax.SelectEntryPos(0);
+ break;
+ case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1:
+ maLbFormulaSyntax.SelectEntryPos(1);
+ break;
+ case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:
+ maLbFormulaSyntax.SelectEntryPos(2);
+ break;
+ default:
+ maLbFormulaSyntax.SelectEntryPos(0);
+ }
+
+ maCbEnglishFuncName.Check(mpNewOptions->GetUseEnglishFuncName());
+
+ OUString aSep = mpNewOptions->GetFormulaSepArg();
+ OUString aSepArrayRow = mpNewOptions->GetFormulaSepArrayRow();
+ OUString aSepArrayCol = mpNewOptions->GetFormulaSepArrayCol();
+
+ if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1)
+ {
+ // Each separator must be one character long.
+ maEdSepFuncArg.SetText(aSep);
+ maEdSepArrayCol.SetText(aSepArrayCol);
+ maEdSepArrayRow.SetText(aSepArrayRow);
+ }
+ else
+ ResetSeparators();
+}
+
+int ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)
+{
+ // What's this method for ?
+ return KEEP_PAGE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpprint.cxx b/sc/source/ui/optdlg/tpprint.cxx
new file mode 100644
index 000000000000..41476b7f03cb
--- /dev/null
+++ b/sc/source/ui/optdlg/tpprint.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+#include <svl/eitem.hxx>
+
+#include "tpprint.hxx"
+#include "printopt.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "optdlg.hrc"
+
+// -----------------------------------------------------------------------
+
+static USHORT pPrintOptRanges[] =
+{
+ SID_SCPRINTOPTIONS,
+ SID_SCPRINTOPTIONS,
+ 0
+};
+
+// -----------------------------------------------------------------------
+
+ScTpPrintOptions::ScTpPrintOptions( Window* pParent,
+ const SfxItemSet& rCoreAttrs )
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_PRINT ),
+ rCoreAttrs ),
+ aPagesFL ( this, ScResId( FL_PAGES ) ),
+ aSkipEmptyPagesCB( this, ScResId( BTN_SKIPEMPTYPAGES ) ),
+ aSheetsFL ( this, ScResId( FL_SHEETS ) ),
+ aSelectedSheetsCB( this, ScResId( BTN_SELECTEDSHEETS ) )
+{
+ FreeResource();
+}
+
+ScTpPrintOptions::~ScTpPrintOptions()
+{
+}
+
+USHORT* ScTpPrintOptions::GetRanges()
+{
+ return pPrintOptRanges;
+}
+
+SfxTabPage* ScTpPrintOptions::Create( Window* pParent, const SfxItemSet& rAttrSet )
+{
+ return new ScTpPrintOptions( pParent, rAttrSet );
+}
+
+int ScTpPrintOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return LEAVE_PAGE;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpPrintOptions::Reset( const SfxItemSet& rCoreSet )
+{
+ ScPrintOptions aOptions;
+
+ const SfxPoolItem* pItem;
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCPRINTOPTIONS, FALSE , &pItem))
+ aOptions = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
+ else
+ {
+ // when called from print dialog and no options set, use configuration
+ aOptions = SC_MOD()->GetPrintOptions();
+ }
+
+ if ( SFX_ITEM_SET == rCoreSet.GetItemState( SID_PRINT_SELECTEDSHEET, FALSE , &pItem ) )
+ {
+ BOOL bChecked = ( (const SfxBoolItem*)pItem )->GetValue();
+ aSelectedSheetsCB.Check( bChecked );
+ }
+ else
+ {
+ aSelectedSheetsCB.Check( !aOptions.GetAllSheets() );
+ }
+
+ aSkipEmptyPagesCB.Check( aOptions.GetSkipEmpty() );
+ aSkipEmptyPagesCB.SaveValue();
+ aSelectedSheetsCB.SaveValue();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScTpPrintOptions::FillItemSet( SfxItemSet& rCoreAttrs )
+{
+ rCoreAttrs.ClearItem( SID_PRINT_SELECTEDSHEET );
+
+ bool bSkipEmptyChanged = ( aSkipEmptyPagesCB.GetSavedValue() != aSkipEmptyPagesCB.IsChecked() );
+ bool bSelectedSheetsChanged = ( aSelectedSheetsCB.GetSavedValue() != aSelectedSheetsCB.IsChecked() );
+
+ if ( bSkipEmptyChanged || bSelectedSheetsChanged )
+ {
+ ScPrintOptions aOpt;
+ aOpt.SetSkipEmpty( aSkipEmptyPagesCB.IsChecked() );
+ aOpt.SetAllSheets( !aSelectedSheetsCB.IsChecked() );
+ rCoreAttrs.Put( ScTpPrintItem( SID_SCPRINTOPTIONS, aOpt ) );
+ if ( bSelectedSheetsChanged )
+ {
+ rCoreAttrs.Put( SfxBoolItem( SID_PRINT_SELECTEDSHEET, aSelectedSheetsCB.IsChecked() ) );
+ }
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpusrlst.cxx b/sc/source/ui/optdlg/tpusrlst.cxx
new file mode 100644
index 000000000000..2f3253bfa8ee
--- /dev/null
+++ b/sc/source/ui/optdlg/tpusrlst.cxx
@@ -0,0 +1,829 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include <vcl/msgbox.hxx>
+
+#include "global.hxx"
+#include "document.hxx"
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+#include "uiitems.hxx"
+#include "userlist.hxx"
+#include "rangeutl.hxx"
+#include "crdlg.hxx"
+#include "scresid.hxx"
+#include "sc.hrc" // -> Slot-IDs
+#include "optdlg.hrc"
+#include "globstr.hrc"
+
+#define _TPUSRLST_CXX
+#include "tpusrlst.hxx"
+#undef _TPUSRLST_CXX
+
+// STATIC DATA -----------------------------------------------------------
+
+#define CR (sal_Unicode)13
+#define LF (sal_Unicode)10
+
+static USHORT pUserListsRanges[] =
+{
+ SID_SCUSERLISTS,
+ SID_SCUSERLISTS,
+ 0
+};
+
+static const sal_Unicode cDelimiter = ',';
+
+
+//========================================================================
+// Benutzerdefinierte Listen:
+
+
+ScTpUserLists::ScTpUserLists( Window* pParent,
+ const SfxItemSet& rCoreAttrs )
+
+ : SfxTabPage ( pParent,
+ ScResId( RID_SCPAGE_USERLISTS ),
+ rCoreAttrs ),
+ aFtLists ( this, ScResId( FT_LISTS ) ),
+ aLbLists ( this, ScResId( LB_LISTS ) ),
+ aFtEntries ( this, ScResId( FT_ENTRIES ) ),
+ aEdEntries ( this, ScResId( ED_ENTRIES ) ),
+ aFtCopyFrom ( this, ScResId( FT_COPYFROM ) ),
+ aEdCopyFrom ( this, ScResId( ED_COPYFROM ) ),
+ aBtnNew ( this, ScResId( BTN_NEW ) ),
+ aBtnAdd ( this, ScResId( BTN_ADD ) ),
+ aBtnRemove ( this, ScResId( BTN_REMOVE ) ),
+ aBtnCopy ( this, ScResId( BTN_COPY ) ),
+ aStrQueryRemove ( ScResId( STR_QUERYREMOVE ) ),
+ aStrNew ( aBtnNew.GetText() ),
+ aStrCancel ( ScResId( STR_DISMISS ) ),
+ aStrAdd ( ScResId( SCSTR_ADD ) ),
+ aStrModify ( ScResId( SCSTR_MODIFY ) ),
+ aStrCopyList ( ScResId( STR_COPYLIST ) ),
+ aStrCopyFrom ( ScResId( STR_COPYFROM ) ),
+ aStrCopyErr ( ScResId( STR_COPYERR ) ),
+ //
+ nWhichUserLists ( GetWhich( SID_SCUSERLISTS ) ),
+ pUserLists ( NULL ),
+ pDoc ( NULL ),
+ pViewData ( NULL ),
+ pRangeUtil ( new ScRangeUtil ),
+ bModifyMode ( FALSE ),
+ bCancelMode ( FALSE ),
+ bCopyDone ( FALSE ),
+ nCancelPos ( 0 )
+{
+ SetExchangeSupport();
+ Init();
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScTpUserLists::~ScTpUserLists()
+{
+ delete pUserLists;
+ delete pRangeUtil;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::Init()
+{
+ SfxViewShell* pSh = SfxViewShell::Current();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, pSh);
+
+ aLbLists.SetSelectHdl ( LINK( this, ScTpUserLists, LbSelectHdl ) );
+ aBtnNew.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ aBtnNew.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ aBtnAdd.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ aBtnRemove.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ aEdEntries.SetModifyHdl ( LINK( this, ScTpUserLists, EdEntriesModHdl ) );
+
+
+ if ( pViewSh )
+ {
+ SCTAB nStartTab = 0;
+ SCTAB nEndTab = 0;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+
+ pViewData = pViewSh->GetViewData();
+ pDoc = pViewData->GetDocument();
+
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ PutInOrder( nStartCol, nEndCol );
+ PutInOrder( nStartRow, nEndRow );
+ PutInOrder( nStartTab, nEndTab );
+
+ ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab
+ ).Format( aStrSelectedArea, SCR_ABS_3D, pDoc );
+
+ aBtnCopy.SetClickHdl ( LINK( this, ScTpUserLists, BtnClickHdl ) );
+ aBtnCopy.Enable();
+ }
+ else
+ {
+ aBtnCopy.Disable();
+ aFtCopyFrom.Disable();
+ aEdCopyFrom.Disable();
+ }
+
+// aLbLists.GrabFocus();
+}
+
+// -----------------------------------------------------------------------
+
+USHORT* __EXPORT ScTpUserLists::GetRanges()
+{
+ return pUserListsRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScTpUserLists::Create( Window* pParent, const SfxItemSet& rAttrSet )
+{
+ return ( new ScTpUserLists( pParent, rAttrSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTpUserLists::Reset( const SfxItemSet& rCoreAttrs )
+{
+ const ScUserListItem& rUserListItem = (const ScUserListItem&)
+ rCoreAttrs.Get( nWhichUserLists );
+ const ScUserList* pCoreList = rUserListItem.GetUserList();
+
+ DBG_ASSERT( pCoreList, "UserList not found :-/" );
+
+ if ( pCoreList )
+ {
+ if ( !pUserLists )
+ pUserLists = new ScUserList( *pCoreList );
+ else
+ *pUserLists = *pCoreList;
+
+ if ( UpdateUserListBox() > 0 )
+ {
+ aLbLists.SelectEntryPos( 0 );
+ UpdateEntries( 0 );
+ }
+ }
+ else if ( !pUserLists )
+ pUserLists = new ScUserList;
+
+ aEdCopyFrom.SetText( aStrSelectedArea );
+
+ if ( aLbLists.GetEntryCount() == 0 )
+ {
+ aFtLists .Disable();
+ aLbLists .Disable();
+ aFtEntries .Disable();
+ aEdEntries .Disable();
+ aBtnRemove .Disable();
+ }
+
+ aBtnNew.SetText( aStrNew );
+ aBtnAdd.SetText( aStrAdd );
+ aBtnAdd.Disable();
+
+ if ( !bCopyDone && pViewData )
+ {
+ aFtCopyFrom .Enable();
+ aEdCopyFrom .Enable();
+ aBtnCopy .Enable();
+ }
+
+// aLbLists.GrabFocus();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScTpUserLists::FillItemSet( SfxItemSet& rCoreAttrs )
+{
+ // Modifikationen noch nicht uebernommen?
+ // -> Click auf Add-Button simulieren
+
+ if ( bModifyMode || bCancelMode )
+ BtnClickHdl( &aBtnAdd );
+
+ const ScUserListItem& rUserListItem = (const ScUserListItem&)
+ GetItemSet().Get( nWhichUserLists );
+
+ ScUserList* pCoreList = rUserListItem.GetUserList();
+ BOOL bDataModified = FALSE;
+
+ if ( (pUserLists == NULL) && (pCoreList == NULL) )
+ {
+ bDataModified = FALSE;
+ }
+ else if ( pUserLists != NULL )
+ {
+ if ( pCoreList != NULL )
+ bDataModified = (*pUserLists != *pCoreList);
+ else
+ bDataModified = TRUE;
+ }
+
+ if ( bDataModified )
+ {
+ ScUserListItem aULItem( nWhichUserLists );
+
+ if ( pUserLists )
+ aULItem.SetUserList( *pUserLists );
+
+ rCoreAttrs.Put( aULItem );
+ }
+
+ return bDataModified;
+}
+
+// -----------------------------------------------------------------------
+
+int __EXPORT ScTpUserLists::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return LEAVE_PAGE;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT ScTpUserLists::UpdateUserListBox()
+{
+ aLbLists.Clear();
+
+ if ( !pUserLists ) return 0;
+
+ //----------------------------------------------------------
+
+ USHORT nCount = pUserLists->GetCount();
+ String aEntry;
+
+ if ( nCount > 0 )
+ {
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ aEntry = (*pUserLists)[i]->GetString();
+ DBG_ASSERT( aEntry.Len() > 0, "Empty UserList-entry :-/" );
+ aLbLists.InsertEntry( aEntry );
+ }
+ }
+
+ return nCount;
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::UpdateEntries( USHORT nList )
+{
+ if ( !pUserLists ) return;
+
+ //----------------------------------------------------------
+
+ if ( nList < pUserLists->GetCount() )
+ {
+ ScUserListData* pList = (*pUserLists)[nList];
+ USHORT nSubCount = pList->GetSubCount();
+ String aEntryListStr;
+
+ for ( USHORT i=0; i<nSubCount; i++ )
+ {
+ if ( i!=0 )
+ aEntryListStr += CR;
+ aEntryListStr += pList->GetSubStr( i );
+ }
+
+ aEntryListStr.ConvertLineEnd();
+ aEdEntries.SetText( aEntryListStr );
+ }
+ else
+ {
+ DBG_ERROR( "Invalid ListIndex :-/" );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::MakeListStr( String& rListStr )
+{
+ String aInputStr(rListStr);
+ String aStr;
+
+ xub_StrLen nLen = aStr.Len();
+ xub_StrLen c = 0;
+
+ aInputStr.ConvertLineEnd( LINEEND_LF );
+ //aStr.EraseAllChars( ' ' );
+
+ xub_StrLen nToken=rListStr.GetTokenCount(LF);
+
+ for(xub_StrLen i=0;i<nToken;i++)
+ {
+ String aString=rListStr.GetToken(i,LF);
+ aString.EraseLeadingChars(' ');
+ aString.EraseTrailingChars(' ');
+ aStr+=aString;
+ aStr+=cDelimiter;
+ }
+
+ /*
+ // '\n' durch cDelimiter ersetzen:
+ for ( c=0;
+ (c < nLen) && (nFound != STRING_NOTFOUND);
+ c++ )
+ {
+ nFound = aStr.Search( LF, nFound );
+ if ( nFound != STRING_NOTFOUND )
+ aStr[nFound] = cDelimiter;
+ }
+ */
+
+ aStr.EraseLeadingChars( cDelimiter );
+ aStr.EraseTrailingChars( cDelimiter );
+ nLen = aStr.Len();
+
+ rListStr.Erase();
+
+ // Alle Doppelten cDelimiter entfernen:
+ c=0;
+ while ( c < nLen )
+ {
+ rListStr += aStr.GetChar(c);
+ c++;
+
+ if ( aStr.GetChar(c) == cDelimiter )
+ {
+ rListStr += aStr.GetChar(c);
+
+ while ( (aStr.GetChar(c) == cDelimiter) && (c < nLen) )
+ c++;
+ }
+ }
+
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::AddNewList( const String& rEntriesStr )
+{
+ String theEntriesStr( rEntriesStr );
+
+ if ( !pUserLists )
+ pUserLists = new ScUserList;
+
+ MakeListStr( theEntriesStr );
+
+ if ( !pUserLists->Insert( new ScUserListData( theEntriesStr ) ) )
+ {
+ DBG_ERROR( "Entry could not be inserted :-/" );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::CopyListFromArea( const ScRefAddress& rStartPos,
+ const ScRefAddress& rEndPos )
+{
+ if ( bCopyDone ) return;
+
+ //----------------------------------------------------------
+
+ SCTAB nTab = rStartPos.Tab();
+ SCCOL nStartCol = rStartPos.Col();
+ SCROW nStartRow = rStartPos.Row();
+ SCCOL nEndCol = rEndPos.Col();
+ SCROW nEndRow = rEndPos.Row();
+ USHORT nCellDir = SCRET_COLS;
+ BOOL bValueIgnored = FALSE;
+
+ if ( (nStartCol != nEndCol) && (nStartRow != nEndRow) )
+ {
+ nCellDir = ScColOrRowDlg( this, aStrCopyList, aStrCopyFrom ).Execute();
+ }
+ else if ( nStartCol != nEndCol )
+ nCellDir = SCRET_ROWS;
+ else
+ nCellDir = SCRET_COLS;
+
+ if ( nCellDir != RET_CANCEL )
+ {
+ String aStrList;
+ String aStrField;
+
+ if ( nCellDir == SCRET_COLS )
+ {
+ for ( SCCOL col=nStartCol; col<=nEndCol; col++ )
+ {
+ for ( SCROW row=nStartRow; row<=nEndRow; row++ )
+ {
+ if ( pDoc->HasStringData( col, row, nTab ) )
+ {
+ pDoc->GetString( col, row, nTab, aStrField );
+
+ if ( aStrField.Len() > 0 )
+ {
+ aStrList += aStrField;
+ aStrList += '\n';
+ }
+ }
+ else
+ bValueIgnored = TRUE;
+ }
+ if ( aStrList.Len() > 0 )
+ AddNewList( aStrList );
+ aStrList.Erase();
+ }
+ }
+ else
+ {
+ for ( SCROW row=nStartRow; row<=nEndRow; row++ )
+ {
+ for ( SCCOL col=nStartCol; col<=nEndCol; col++ )
+ {
+ if ( pDoc->HasStringData( col, row, nTab ) )
+ {
+ pDoc->GetString( col, row, nTab, aStrField );
+
+ if ( aStrField.Len() > 0 )
+ {
+ aStrList += aStrField;
+ aStrList += '\n';
+ }
+ }
+ else
+ bValueIgnored = TRUE;
+ }
+ if ( aStrList.Len() > 0 )
+ AddNewList( aStrList );
+ aStrList.Erase();
+ }
+ }
+
+ if ( bValueIgnored )
+ {
+ InfoBox( this, aStrCopyErr ).Execute();
+ }
+ }
+
+ //----------------------------------------------------------
+
+ bCopyDone = TRUE;
+
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::ModifyList( USHORT nSelList,
+ const String& rEntriesStr )
+{
+ if ( !pUserLists ) return;
+
+ //----------------------------------------------------------
+
+ String theEntriesStr( rEntriesStr );
+
+ MakeListStr( theEntriesStr );
+
+ (*pUserLists)[nSelList]->SetString( theEntriesStr );
+}
+
+// -----------------------------------------------------------------------
+
+void ScTpUserLists::RemoveList( USHORT nList )
+{
+ if ( pUserLists ) pUserLists->AtFree( nList );
+}
+
+//-----------------------------------------------------------------------
+// Handler:
+//---------
+
+IMPL_LINK( ScTpUserLists, LbSelectHdl, ListBox*, pLb )
+{
+ if ( pLb == &aLbLists )
+ {
+ USHORT nSelPos = aLbLists.GetSelectEntryPos();
+ if ( nSelPos != LISTBOX_ENTRY_NOTFOUND )
+ {
+ if ( !aFtEntries.IsEnabled() ) aFtEntries.Enable();
+ if ( !aEdEntries.IsEnabled() ) aEdEntries.Enable();
+ if ( !aBtnRemove.IsEnabled() ) aBtnRemove.Enable();
+ if ( aBtnAdd.IsEnabled() ) aBtnAdd.Disable();
+
+ UpdateEntries( nSelPos );
+ }
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTpUserLists, BtnClickHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnNew )
+ {
+ if ( !bCancelMode )
+ {
+ nCancelPos = ( aLbLists.GetEntryCount() > 0 )
+ ? aLbLists.GetSelectEntryPos()
+ : 0;
+ aLbLists.SetNoSelection();
+ aFtLists.Disable();
+ aLbLists.Disable();
+ aFtEntries.Enable();
+ aEdEntries.Enable();
+ aEdEntries.SetText( EMPTY_STRING );
+ aEdEntries.GrabFocus();
+ aBtnAdd.Disable();
+ aBtnRemove.Disable();
+ //-----------------------------
+ if ( aBtnCopy.IsEnabled() )
+ {
+ aBtnCopy.Disable();
+ aFtCopyFrom.Disable();
+ aEdCopyFrom.Disable();
+ }
+ aBtnNew.SetText( aStrCancel );
+ bCancelMode = TRUE;
+ }
+ else // if ( bCancelMode )
+ {
+ if ( aLbLists.GetEntryCount() > 0 )
+ {
+ aLbLists.SelectEntryPos( nCancelPos );
+ LbSelectHdl( &aLbLists );
+ aFtLists.Enable();
+ aLbLists.Enable();
+ }
+ else
+ {
+ aFtEntries.Disable();
+ aEdEntries.Disable();
+ aEdEntries.SetText( EMPTY_STRING );
+ aBtnRemove.Disable();
+ }
+ aBtnAdd.Disable();
+ //-----------------------------
+ if ( pViewData && !bCopyDone )
+ {
+ aBtnCopy.Enable();
+ aFtCopyFrom.Enable();
+ aEdCopyFrom.Enable();
+ }
+ aBtnNew.SetText( aStrNew );
+ bCancelMode = FALSE;
+ bModifyMode = FALSE;
+ }
+ }
+ else if ( pBtn == &aBtnAdd )
+ {
+ String theEntriesStr( aEdEntries.GetText() );
+
+ if ( !bModifyMode )
+ {
+ if ( theEntriesStr.Len() > 0 )
+ {
+ AddNewList( theEntriesStr );
+ UpdateUserListBox();
+ aLbLists.SelectEntryPos( aLbLists.GetEntryCount()-1 );
+ LbSelectHdl( &aLbLists );
+ aFtLists.Enable();
+ aLbLists.Enable();
+ }
+ else
+ {
+ if ( aLbLists.GetEntryCount() > 0 )
+ {
+ aLbLists.SelectEntryPos( nCancelPos );
+ LbSelectHdl( &aLbLists );
+ aLbLists.Enable();
+ aLbLists.Enable();
+ }
+ }
+
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ aBtnNew.SetText( aStrNew );
+ bCancelMode = FALSE;
+ }
+ else // if ( bModifyMode )
+ {
+ USHORT nSelList = aLbLists.GetSelectEntryPos();
+
+ DBG_ASSERT( nSelList != LISTBOX_ENTRY_NOTFOUND, "Modify without List :-/" );
+
+ if ( theEntriesStr.Len() > 0 )
+ {
+ ModifyList( nSelList, theEntriesStr );
+ UpdateUserListBox();
+ aLbLists.SelectEntryPos( nSelList );
+ }
+ else
+ {
+ aLbLists.SelectEntryPos( 0 );
+ LbSelectHdl( &aLbLists );
+ }
+
+ aBtnNew.SetText( aStrNew ); bCancelMode = FALSE;
+ aBtnAdd.SetText( aStrAdd ); bModifyMode = FALSE;
+ aBtnAdd.Disable();
+ aBtnRemove.Enable();
+ aFtLists.Enable();
+ aLbLists.Enable();
+ }
+
+ if ( pViewData && !bCopyDone )
+ {
+ aBtnCopy.Enable();
+ aFtCopyFrom.Enable();
+ aEdCopyFrom.Enable();
+ }
+ }
+ else if ( pBtn == &aBtnRemove )
+ {
+ if ( aLbLists.GetEntryCount() > 0 )
+ {
+ USHORT nRemovePos = aLbLists.GetSelectEntryPos();
+ String aMsg ( aStrQueryRemove.GetToken( 0, '#' ) );
+
+ aMsg += aLbLists.GetEntry( nRemovePos );
+ aMsg += aStrQueryRemove.GetToken( 1, '#' );
+
+
+ if ( RET_YES == QueryBox( this,
+ WinBits( WB_YES_NO | WB_DEF_YES ),
+ aMsg
+ ).Execute() )
+ {
+ RemoveList( nRemovePos );
+ UpdateUserListBox();
+
+ if ( aLbLists.GetEntryCount() > 0 )
+ {
+ aLbLists.SelectEntryPos(
+ ( nRemovePos >= aLbLists.GetEntryCount() )
+ ? aLbLists.GetEntryCount()-1
+ : nRemovePos );
+ LbSelectHdl( &aLbLists );
+ }
+ else
+ {
+ aFtLists.Disable();
+ aLbLists.Disable();
+ aFtEntries.Disable();
+ aEdEntries.Disable();
+ aEdEntries.SetText( EMPTY_STRING );
+ aBtnRemove.Disable();
+ }
+ }
+
+ if ( pViewData && !bCopyDone && !aBtnCopy.IsEnabled() )
+ {
+ aBtnCopy.Enable();
+ aFtCopyFrom.Enable();
+ aEdCopyFrom.Enable();
+ }
+ }
+ }
+ else if ( pViewData && (pBtn == &aBtnCopy) )
+ {
+ if ( bCopyDone )
+ return 0;
+
+ //-----------------------------------------------------------
+
+ ScRefAddress theStartPos;
+ ScRefAddress theEndPos;
+ String theAreaStr( aEdCopyFrom.GetText() );
+ BOOL bAreaOk = FALSE;
+
+ if ( theAreaStr.Len() > 0 )
+ {
+ bAreaOk = pRangeUtil->IsAbsArea( theAreaStr,
+ pDoc,
+ pViewData->GetTabNo(),
+ &theAreaStr,
+ &theStartPos,
+ &theEndPos,
+ pDoc->GetAddressConvention() );
+ if ( !bAreaOk )
+ {
+ bAreaOk = pRangeUtil->IsAbsPos( theAreaStr,
+ pDoc,
+ pViewData->GetTabNo(),
+ &theAreaStr,
+ &theStartPos,
+ pDoc->GetAddressConvention() );
+ theEndPos = theStartPos;
+ }
+ }
+
+ if ( bAreaOk )
+ {
+ CopyListFromArea( theStartPos, theEndPos );
+ UpdateUserListBox();
+ aLbLists.SelectEntryPos( aLbLists.GetEntryCount()-1 );
+ LbSelectHdl( &aLbLists );
+ aEdCopyFrom .SetText( theAreaStr );
+ aEdCopyFrom .Disable();
+ aBtnCopy .Disable();
+ aFtCopyFrom .Disable();
+ }
+ else
+ {
+ ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_INVALID_TABREF )
+ ).Execute();
+ aEdCopyFrom.GrabFocus();
+ aEdCopyFrom.SetSelection( Selection( 0, SELECTION_MAX ) );
+ }
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ScTpUserLists, EdEntriesModHdl, MultiLineEdit*, pEd )
+{
+ if ( pEd != &aEdEntries )
+ return 0;
+
+ //-----------------------------------------------------------
+
+ if ( aBtnCopy.IsEnabled() )
+ {
+ aBtnCopy .Disable();
+ aFtCopyFrom .Disable();
+ aEdCopyFrom .Disable();
+ }
+
+ if ( aEdEntries.GetText().Len() > 0 )
+ {
+ if ( !bCancelMode && !bModifyMode )
+ {
+ aBtnNew.SetText( aStrCancel ); bCancelMode = TRUE;
+ aBtnAdd.SetText( aStrModify ); bModifyMode = TRUE;
+ aBtnAdd.Enable();
+ aBtnRemove.Disable();
+ aFtLists.Disable();
+ aLbLists.Disable();
+ }
+ else // if ( bCancelMode || bModifyMode )
+ {
+ if ( !aBtnAdd.IsEnabled() ) aBtnAdd.Enable();
+ }
+ }
+ else
+ {
+ if ( aBtnAdd.IsEnabled() ) aBtnAdd.Disable();
+ }
+
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/tpview.cxx b/sc/source/ui/optdlg/tpview.cxx
new file mode 100644
index 000000000000..b46efdba1b69
--- /dev/null
+++ b/sc/source/ui/optdlg/tpview.cxx
@@ -0,0 +1,747 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include "tpview.hxx"
+#include "global.hxx"
+#include "viewopti.hxx"
+#include "tabvwsh.hxx"
+#include "uiitems.hxx"
+#include "scresid.hxx"
+#include "docsh.hxx"
+#include "sc.hrc" // -> Slot-IDs
+#include "optdlg.hrc"
+#include "globstr.hrc"
+#include <appoptio.hxx>
+#include <scmod.hxx>
+#include <svx/dlgutil.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/xtable.hxx>
+
+
+// STATIC DATA -----------------------------------------------------------
+
+
+
+/*-----------------11.01.97 10.52-------------------
+ Optionen Inhalte
+--------------------------------------------------*/
+
+ScTpContentOptions::ScTpContentOptions( Window* pParent,
+ const SfxItemSet& rArgSet ) :
+ SfxTabPage(pParent, ScResId( RID_SCPAGE_CONTENT ), rArgSet),
+
+ aLinesGB( this, ScResId(GB_LINES )),
+ aGridCB( this, ScResId(CB_GRID )),
+ aColorFT( this, ScResId(FT_COLOR )),
+ aColorLB( this, ScResId(LB_COLOR )),
+ aBreakCB( this, ScResId(CB_PAGEBREAKS )),
+ aGuideLineCB( this, ScResId(CB_GUIDELINE )),
+ aHandleCB( this, ScResId(CB_HANDLES )),
+ aBigHandleCB( this, ScResId(CB_BIGHANDLES )),
+
+ aSeparator1FL (this, ScResId(FL_SEPARATOR1 )),
+ aDisplayGB( this, ScResId(GB_DISPLAY)),
+ aFormulaCB( this, ScResId(CB_FORMULA)),
+ aNilCB( this, ScResId(CB_NIL )),
+ aAnnotCB( this, ScResId(CB_ANNOT )),
+ aValueCB( this, ScResId(CB_VALUE )),
+ aAnchorCB( this, ScResId(CB_ANCHOR )),
+ aClipMarkCB( this, ScResId(CB_CLIP )),
+ aRangeFindCB( this, ScResId( CB_RFIND )),
+
+ aObjectGB( this, ScResId(GB_OBJECT )),
+ aObjGrfFT( this, ScResId(FT_OBJGRF )),
+ aObjGrfLB( this, ScResId(LB_OBJGRF )),
+ aDiagramFT( this, ScResId(FT_DIAGRAM)),
+ aDiagramLB( this, ScResId(LB_DIAGRAM)),
+ aDrawFT( this, ScResId(FT_DRAW )),
+ aDrawLB( this, ScResId(LB_DRAW )),
+
+ aZoomGB( this, ScResId(GB_ZOOM) ),
+ aSyncZoomCB( this, ScResId(CB_SYNCZOOM) ),
+
+ aSeparator2FL (this, ScResId(FL_SEPARATOR2)),
+ aWindowGB( this, ScResId(GB_WINDOW )),
+ aRowColHeaderCB(this, ScResId(CB_ROWCOLHEADER )),
+ aHScrollCB( this, ScResId(CB_HSCROLL )),
+ aVScrollCB( this, ScResId(CB_VSCROLL )),
+ aTblRegCB( this, ScResId(CB_TBLREG )),
+ aOutlineCB( this, ScResId(CB_OUTLINE )),
+ pLocalOptions(0)
+{
+ FreeResource();
+ aSeparator1FL.SetStyle( aSeparator1FL.GetStyle() | WB_VERT );
+ aSeparator2FL.SetStyle( aSeparator2FL.GetStyle() | WB_VERT );
+ SetExchangeSupport();
+ Link aSelObjHdl(LINK( this, ScTpContentOptions, SelLbObjHdl ) );
+ aObjGrfLB. SetSelectHdl(aSelObjHdl);
+ aDiagramLB. SetSelectHdl(aSelObjHdl);
+ aDrawLB. SetSelectHdl(aSelObjHdl);
+
+ Link aCBHdl(LINK( this, ScTpContentOptions, CBHdl ) );
+ aFormulaCB .SetClickHdl(aCBHdl);
+ aNilCB .SetClickHdl(aCBHdl);
+ aAnnotCB .SetClickHdl(aCBHdl);
+ aValueCB .SetClickHdl(aCBHdl);
+ aAnchorCB .SetClickHdl(aCBHdl);
+ aClipMarkCB .SetClickHdl(aCBHdl);
+
+ aVScrollCB .SetClickHdl(aCBHdl);
+ aHScrollCB .SetClickHdl(aCBHdl);
+ aTblRegCB .SetClickHdl(aCBHdl);
+ aOutlineCB .SetClickHdl(aCBHdl);
+ aBreakCB .SetClickHdl(aCBHdl);
+ aGuideLineCB.SetClickHdl(aCBHdl);
+ aHandleCB .SetClickHdl(aCBHdl);
+ aBigHandleCB.SetClickHdl(aCBHdl);
+ aRowColHeaderCB.SetClickHdl(aCBHdl);
+
+ aGridCB .SetClickHdl( LINK( this, ScTpContentOptions, GridHdl ) );
+}
+/*-----------------11.01.97 10.52-------------------
+
+--------------------------------------------------*/
+
+ScTpContentOptions::~ScTpContentOptions()
+{
+ delete pLocalOptions;
+}
+/*-----------------11.01.97 10.52-------------------
+
+--------------------------------------------------*/
+
+SfxTabPage* ScTpContentOptions::Create( Window* pParent,
+ const SfxItemSet& rCoreSet )
+{
+ return new ScTpContentOptions(pParent, rCoreSet);
+}
+/*-----------------11.01.97 10.52-------------------
+
+--------------------------------------------------*/
+BOOL ScTpContentOptions::FillItemSet( SfxItemSet& rCoreSet )
+{
+ BOOL bRet = FALSE;
+ if( aFormulaCB .GetSavedValue() != aFormulaCB .IsChecked() ||
+ aNilCB .GetSavedValue() != aNilCB .IsChecked() ||
+ aAnnotCB .GetSavedValue() != aAnnotCB .IsChecked() ||
+ aValueCB .GetSavedValue() != aValueCB .IsChecked() ||
+ aAnchorCB .GetSavedValue() != aAnchorCB .IsChecked() ||
+ aClipMarkCB .GetSavedValue() != aClipMarkCB .IsChecked() ||
+ aObjGrfLB .GetSavedValue() != aObjGrfLB .GetSelectEntryPos() ||
+ aDiagramLB .GetSavedValue() != aDiagramLB .GetSelectEntryPos() ||
+ aDrawLB .GetSavedValue() != aDrawLB .GetSelectEntryPos() ||
+ aGridCB .GetSavedValue() != aGridCB.IsChecked() ||
+ aRowColHeaderCB .GetSavedValue() != aRowColHeaderCB.IsChecked() ||
+ aHScrollCB .GetSavedValue() != aHScrollCB .IsChecked() ||
+ aVScrollCB .GetSavedValue() != aVScrollCB .IsChecked() ||
+ aTblRegCB .GetSavedValue() != aTblRegCB .IsChecked() ||
+ aOutlineCB .GetSavedValue() != aOutlineCB .IsChecked() ||
+ aColorLB .GetSavedValue() != aColorLB .GetSelectEntryPos() ||
+ aBreakCB .GetSavedValue() != aBreakCB .IsChecked() ||
+ aGuideLineCB .GetSavedValue() != aGuideLineCB .IsChecked() ||
+ aHandleCB .GetSavedValue() != aHandleCB .IsChecked() ||
+ aBigHandleCB .GetSavedValue() != aBigHandleCB .IsChecked())
+ {
+ pLocalOptions->SetGridColor( aColorLB.GetSelectEntryColor(),
+ aColorLB.GetSelectEntry() );
+ rCoreSet.Put(ScTpViewItem(SID_SCVIEWOPTIONS, *pLocalOptions));
+ bRet = TRUE;
+ }
+ if(aRangeFindCB.GetSavedValue() != aRangeFindCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_RANGEFINDER, aRangeFindCB.IsChecked()));
+ bRet = TRUE;
+ }
+ if(aSyncZoomCB.GetSavedValue() != aSyncZoomCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_OPT_SYNCZOOM, aSyncZoomCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+
+ return bRet;
+}
+/*-----------------11.01.97 10.53-------------------
+
+--------------------------------------------------*/
+
+void ScTpContentOptions::Reset( const SfxItemSet& rCoreSet )
+{
+ const SfxPoolItem* pItem;
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCVIEWOPTIONS, FALSE , &pItem))
+ pLocalOptions = new ScViewOptions(
+ ((const ScTpViewItem*)pItem)->GetViewOptions() );
+ else
+ pLocalOptions = new ScViewOptions;
+ aFormulaCB .Check(pLocalOptions->GetOption(VOPT_FORMULAS));
+ aNilCB .Check(pLocalOptions->GetOption(VOPT_NULLVALS));
+ aAnnotCB .Check(pLocalOptions->GetOption(VOPT_NOTES));
+ aValueCB .Check(pLocalOptions->GetOption(VOPT_SYNTAX));
+ aAnchorCB .Check(pLocalOptions->GetOption(VOPT_ANCHOR));
+ aClipMarkCB .Check(pLocalOptions->GetOption(VOPT_CLIPMARKS));
+
+ aObjGrfLB .SelectEntryPos( (USHORT)pLocalOptions->GetObjMode(VOBJ_TYPE_OLE) );
+ aDiagramLB .SelectEntryPos( (USHORT)pLocalOptions->GetObjMode(VOBJ_TYPE_CHART) );
+ aDrawLB .SelectEntryPos( (USHORT)pLocalOptions->GetObjMode(VOBJ_TYPE_DRAW) );
+
+ aRowColHeaderCB.Check( pLocalOptions->GetOption(VOPT_HEADER) );
+ aHScrollCB .Check( pLocalOptions->GetOption(VOPT_HSCROLL) );
+ aVScrollCB .Check( pLocalOptions->GetOption(VOPT_VSCROLL) );
+ aTblRegCB .Check( pLocalOptions->GetOption(VOPT_TABCONTROLS) );
+ aOutlineCB .Check( pLocalOptions->GetOption(VOPT_OUTLINER) );
+
+ InitGridOpt();
+
+ aBreakCB.Check( pLocalOptions->GetOption(VOPT_PAGEBREAKS) );
+ aGuideLineCB.Check( pLocalOptions->GetOption(VOPT_HELPLINES) );
+ aHandleCB.Check( !pLocalOptions->GetOption(VOPT_SOLIDHANDLES) ); // inverted
+ aBigHandleCB.Check( pLocalOptions->GetOption(VOPT_BIGHANDLES) );
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_RANGEFINDER, FALSE, &pItem))
+ aRangeFindCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_OPT_SYNCZOOM, FALSE, &pItem))
+ aSyncZoomCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+ aRangeFindCB.SaveValue();
+ aSyncZoomCB.SaveValue();
+
+ aFormulaCB .SaveValue();
+ aNilCB .SaveValue();
+ aAnnotCB .SaveValue();
+ aValueCB .SaveValue();
+ aAnchorCB .SaveValue();
+ aClipMarkCB .SaveValue();
+ aObjGrfLB .SaveValue();
+ aDiagramLB .SaveValue();
+ aDrawLB .SaveValue();
+ aRowColHeaderCB .SaveValue();
+ aHScrollCB .SaveValue();
+ aVScrollCB .SaveValue();
+ aTblRegCB .SaveValue();
+ aOutlineCB .SaveValue();
+ aGridCB .SaveValue();
+ aColorLB .SaveValue();
+ aBreakCB .SaveValue();
+ aGuideLineCB .SaveValue();
+ aHandleCB .SaveValue();
+ aBigHandleCB .SaveValue();
+}
+/*-----------------11.01.97 12.45-------------------
+
+--------------------------------------------------*/
+
+void ScTpContentOptions::ActivatePage( const SfxItemSet& rSet)
+{
+ const SfxPoolItem* pItem;
+ if(SFX_ITEM_SET == rSet.GetItemState(SID_SCVIEWOPTIONS, FALSE , &pItem))
+ *pLocalOptions = ((const ScTpViewItem*)pItem)->GetViewOptions();
+}
+/*-----------------11.01.97 12.45-------------------
+
+--------------------------------------------------*/
+
+int ScTpContentOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ if(pSetP)
+ FillItemSet(*pSetP);
+ return SfxTabPage::LEAVE_PAGE;
+}
+/*-----------------11.01.97 13.43-------------------
+
+--------------------------------------------------*/
+
+IMPL_LINK( ScTpContentOptions, SelLbObjHdl, ListBox*, pLb )
+{
+ USHORT nSelPos = pLb->GetSelectEntryPos();
+ ScVObjMode eMode = ScVObjMode(nSelPos);
+ ScVObjType eType = VOBJ_TYPE_OLE;
+
+ if ( pLb == &aDiagramLB )
+ eType = VOBJ_TYPE_CHART;
+ else if ( pLb == &aDrawLB )
+ eType = VOBJ_TYPE_DRAW;
+
+ pLocalOptions->SetObjMode( eType, eMode );
+
+ return 0;
+}
+
+/*-----------------11.01.97 14.25-------------------
+
+--------------------------------------------------*/
+
+IMPL_LINK( ScTpContentOptions, CBHdl, CheckBox*, pBtn )
+{
+ ScViewOption eOption = VOPT_FORMULAS;
+ BOOL bChecked = pBtn->IsChecked();
+
+ if ( &aFormulaCB == pBtn ) eOption = VOPT_FORMULAS;
+ else if ( &aNilCB == pBtn ) eOption = VOPT_NULLVALS;
+ else if ( &aAnnotCB == pBtn ) eOption = VOPT_NOTES;
+ else if ( &aValueCB == pBtn ) eOption = VOPT_SYNTAX;
+ else if ( &aAnchorCB == pBtn ) eOption = VOPT_ANCHOR;
+ else if ( &aClipMarkCB == pBtn ) eOption = VOPT_CLIPMARKS;
+ else if ( &aVScrollCB == pBtn ) eOption = VOPT_VSCROLL;
+ else if ( &aHScrollCB == pBtn ) eOption = VOPT_HSCROLL;
+ else if ( &aTblRegCB == pBtn ) eOption = VOPT_TABCONTROLS;
+ else if ( &aOutlineCB == pBtn ) eOption = VOPT_OUTLINER;
+ else if ( &aBreakCB == pBtn ) eOption = VOPT_PAGEBREAKS;
+ else if ( &aGuideLineCB == pBtn ) eOption = VOPT_HELPLINES;
+ else if ( &aHandleCB == pBtn ) eOption = VOPT_SOLIDHANDLES;
+ else if ( &aBigHandleCB == pBtn ) eOption = VOPT_BIGHANDLES;
+ else if ( &aRowColHeaderCB == pBtn ) eOption = VOPT_HEADER;
+
+ // VOPT_SOLIDHANDLES is inverted (CheckBox is "simple handles")
+ if ( eOption == VOPT_SOLIDHANDLES )
+ pLocalOptions->SetOption( eOption, !bChecked );
+ else
+ pLocalOptions->SetOption( eOption, bChecked );
+
+
+ return 0;
+}
+/*-----------------11.01.97 13.13-------------------
+
+--------------------------------------------------*/
+
+void ScTpContentOptions::InitGridOpt()
+{
+ BOOL bGrid = pLocalOptions->GetOption( VOPT_GRID );
+
+ aGridCB.Check( bGrid );
+
+ if ( bGrid )
+ aColorFT.Enable(), aColorLB.Enable();
+ else
+ aColorFT.Disable(), aColorLB.Disable();
+
+ if ( aColorLB.GetEntryCount() == 0 )
+ {
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ // hier koennte auch eine andere DocShell kommen!
+ pDocSh = PTR_CAST(ScDocShell, pDocSh);
+
+ XColorTable* pColorTable = NULL;
+
+ if ( pDocSh )
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+
+ if ( pItem )
+ pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable();
+ }
+ else
+ pColorTable = XColorTable::GetStdColorTable();
+
+ if ( !pColorTable )
+ return;
+
+ //------------------------------------------------------
+
+ aColorLB.SetUpdateMode( FALSE );
+
+ // Eintraege aus der Colortable
+
+ long nCount = pColorTable->Count();
+ for ( long n=0; n<nCount; n++ )
+ {
+ XColorEntry* pEntry = pColorTable->GetColor(n);
+ aColorLB.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+
+ // Standard-Gitterfarbe
+
+ Color aStdCol( SC_STD_GRIDCOLOR ); // wie Default in ScViewOptions
+ if ( LISTBOX_ENTRY_NOTFOUND ==
+ aColorLB.GetEntryPos( aStdCol ) )
+ aColorLB.InsertEntry( aStdCol, ScGlobal::GetRscString( STR_GRIDCOLOR ) );
+
+ aColorLB.SetUpdateMode( TRUE );
+
+ Invalidate();
+ }
+
+ // #79720# also select grid color entry on subsequent calls
+
+ String aName;
+ Color aCol = pLocalOptions->GetGridColor( &aName );
+ USHORT nSelPos = aColorLB.GetEntryPos( aCol );
+
+ if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ aColorLB.SelectEntryPos( nSelPos );
+ else
+ aColorLB.SelectEntryPos( aColorLB.InsertEntry( aCol, aName ) );
+}
+/*-----------------11.01.97 13.40-------------------
+
+--------------------------------------------------*/
+
+IMPL_LINK( ScTpContentOptions, GridHdl, CheckBox*, pBox )
+{
+ BOOL bChecked = pBox->IsChecked();
+ aColorFT.Enable(bChecked);
+ aColorLB.Enable(bChecked);
+ pLocalOptions->SetOption( VOPT_GRID, bChecked );
+ return 0;
+}
+/*-----------------11.01.97 10.53-------------------
+
+--------------------------------------------------*/
+
+ScTpLayoutOptions::ScTpLayoutOptions( Window* pParent,
+ const SfxItemSet& rArgSet ) :
+ SfxTabPage(pParent, ScResId( RID_SCPAGE_LAYOUT ), rArgSet),
+ aUnitGB( this, ScResId(GB_UNIT )),
+ aUnitFT( this, ScResId(FT_UNIT )),
+ aUnitLB( this, ScResId(LB_UNIT )),
+ aTabFT( this, ScResId( FT_TAB )),
+ aTabMF( this, ScResId( MF_TAB )),
+ aSeparatorFL( this, ScResId( FL_SEPARATOR )),
+ aLinkGB (this, ScResId(GB_LINK )),
+ aLinkFT(this, ScResId(FT_UPDATE_LINKS )),
+ aAlwaysRB (this, ScResId(RB_ALWAYS )),
+ aRequestRB (this, ScResId(RB_REQUEST )),
+ aNeverRB (this, ScResId(RB_NEVER )),
+
+ aOptionsGB( this, ScResId( GB_OPTIONS )),
+ aAlignCB ( this, ScResId( CB_ALIGN )),
+ aAlignLB ( this, ScResId( LB_ALIGN )),
+ aEditModeCB( this, ScResId( CB_EDITMODE )),
+ aFormatCB( this, ScResId( CB_FORMAT )),
+ aExpRefCB( this, ScResId( CB_EXPREF )),
+ aMarkHdrCB( this, ScResId( CB_MARKHDR )),
+ aTextFmtCB( this, ScResId( CB_TEXTFMT )),
+ aReplWarnCB( this, ScResId( CB_REPLWARN )),
+ aUnitArr( ScResId(ST_UNIT )),
+ pDoc(NULL)
+{
+ FreeResource();
+ aSeparatorFL.SetStyle( aSeparatorFL.GetStyle() | WB_VERT );
+ SetExchangeSupport();
+
+ aUnitLB. SetSelectHdl( LINK( this, ScTpLayoutOptions, MetricHdl ) );
+
+ aAlignCB.SetClickHdl(LINK(this, ScTpLayoutOptions, AlignHdl));
+
+
+ for ( USHORT i = 0; i < aUnitArr.Count(); ++i )
+ {
+ String sMetric = aUnitArr.GetStringByPos( i );
+ FieldUnit eFUnit = (FieldUnit)aUnitArr.GetValue( i );
+
+ switch ( eFUnit )
+ {
+ case FUNIT_MM:
+ case FUNIT_CM:
+ case FUNIT_POINT:
+ case FUNIT_PICA:
+ case FUNIT_INCH:
+ {
+ // nur diese Metriken benutzen
+ USHORT nPos = aUnitLB.InsertEntry( sMetric );
+ aUnitLB.SetEntryData( nPos, (void*)(long)eFUnit );
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+
+}
+/*-----------------11.01.97 10.53-------------------
+
+--------------------------------------------------*/
+
+ScTpLayoutOptions::~ScTpLayoutOptions()
+{
+}
+/*-----------------11.01.97 10.53-------------------
+
+--------------------------------------------------*/
+
+SfxTabPage* ScTpLayoutOptions::Create( Window* pParent,
+ const SfxItemSet& rCoreSet )
+{
+ ScTpLayoutOptions* pNew = new ScTpLayoutOptions(pParent, rCoreSet);
+ ScDocShell* pDocSh = PTR_CAST(ScDocShell,SfxObjectShell::Current());
+
+ if(pDocSh!=NULL)
+ pNew->SetDocument(pDocSh->GetDocument());
+ return pNew;
+}
+/*-----------------11.01.97 10.53-------------------
+
+--------------------------------------------------*/
+
+BOOL ScTpLayoutOptions::FillItemSet( SfxItemSet& rCoreSet )
+{
+ BOOL bRet = TRUE;
+ const USHORT nMPos = aUnitLB.GetSelectEntryPos();
+ if ( nMPos != aUnitLB.GetSavedValue() )
+ {
+ USHORT nFieldUnit = (USHORT)(long)aUnitLB.GetEntryData( nMPos );
+ rCoreSet.Put( SfxUInt16Item( SID_ATTR_METRIC,
+ (UINT16)nFieldUnit ) );
+ bRet = TRUE;
+ }
+
+ if(aTabMF.GetText() != aTabMF.GetSavedValue())
+ {
+ rCoreSet.Put(SfxUInt16Item(SID_ATTR_DEFTABSTOP,
+ sal::static_int_cast<UINT16>( aTabMF.Denormalize(aTabMF.GetValue(FUNIT_TWIP)) )));
+ bRet = TRUE;
+ }
+
+ ScLkUpdMode nSet=LM_ALWAYS;
+
+ if(aRequestRB.IsChecked())
+ {
+ nSet=LM_ON_DEMAND;
+ }
+ else if(aNeverRB.IsChecked())
+ {
+ nSet=LM_NEVER;
+ }
+
+ if(aRequestRB.IsChecked() != aRequestRB.GetSavedValue() ||
+ aNeverRB.IsChecked() != aNeverRB.GetSavedValue() )
+ {
+ if(pDoc)
+ pDoc->SetLinkMode(nSet);
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+ aAppOptions.SetLinkMode(nSet );
+ SC_MOD()->SetAppOptions(aAppOptions);
+ bRet = TRUE;
+ }
+ if(aAlignCB.GetSavedValue() != aAlignCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_SELECTION, aAlignCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+ if(aAlignLB.GetSavedValue() != aAlignLB.GetSelectEntryPos())
+ {
+ rCoreSet.Put(SfxUInt16Item(SID_SC_INPUT_SELECTIONPOS, aAlignLB.GetSelectEntryPos()));
+ bRet = TRUE;
+ }
+
+ if(aEditModeCB.GetSavedValue() != aEditModeCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_EDITMODE, aEditModeCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+ if(aFormatCB.GetSavedValue() != aFormatCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_FMT_EXPAND, aFormatCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+
+ if(aExpRefCB.GetSavedValue() != aExpRefCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_REF_EXPAND, aExpRefCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+ if(aMarkHdrCB.GetSavedValue() != aMarkHdrCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_MARK_HEADER, aMarkHdrCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+ if(aTextFmtCB.GetSavedValue() != aTextFmtCB.IsChecked())
+ {
+ rCoreSet.Put(SfxBoolItem(SID_SC_INPUT_TEXTWYSIWYG, aTextFmtCB.IsChecked()));
+ bRet = TRUE;
+ }
+
+ if( aReplWarnCB.GetSavedValue() != aReplWarnCB.IsChecked() )
+ {
+ rCoreSet.Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN, aReplWarnCB.IsChecked() ) );
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+/*-----------------11.01.97 10.53-------------------
+
+--------------------------------------------------*/
+
+void ScTpLayoutOptions::Reset( const SfxItemSet& rCoreSet )
+{
+ aUnitLB.SetNoSelection();
+ if ( rCoreSet.GetItemState( SID_ATTR_METRIC ) >= SFX_ITEM_AVAILABLE )
+ {
+ const SfxUInt16Item& rItem = (SfxUInt16Item&)rCoreSet.Get( SID_ATTR_METRIC );
+ FieldUnit eFieldUnit = (FieldUnit)rItem.GetValue();
+
+ for ( USHORT i = 0; i < aUnitLB.GetEntryCount(); ++i )
+ {
+ if ( (FieldUnit)(long)aUnitLB.GetEntryData( i ) == eFieldUnit )
+ {
+ aUnitLB.SelectEntryPos( i );
+ break;
+ }
+ }
+ ::SetFieldUnit(aTabMF, eFieldUnit);
+ }
+ aUnitLB.SaveValue();
+
+ const SfxPoolItem* pItem;
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_ATTR_DEFTABSTOP, FALSE, &pItem))
+ aTabMF.SetValue(aTabMF.Normalize(((SfxUInt16Item*)pItem)->GetValue()), FUNIT_TWIP);
+ aTabMF.SaveValue();
+
+ aUnitLB .SaveValue();
+ aTabMF .SaveValue();
+
+ ScLkUpdMode nSet=LM_UNKNOWN;
+
+ if(pDoc!=NULL)
+ {
+ nSet=pDoc->GetLinkMode();
+ }
+
+ if(nSet==LM_UNKNOWN)
+ {
+ ScAppOptions aAppOptions=SC_MOD()->GetAppOptions();
+ nSet=aAppOptions.GetLinkMode();
+ }
+
+ switch(nSet)
+ {
+ case LM_ALWAYS: aAlwaysRB. Check(); break;
+ case LM_NEVER: aNeverRB. Check(); break;
+ case LM_ON_DEMAND: aRequestRB. Check(); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTION, FALSE, &pItem))
+ aAlignCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_SELECTIONPOS, FALSE, &pItem))
+ aAlignLB.SelectEntryPos(((const SfxUInt16Item*)pItem)->GetValue());
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_EDITMODE, FALSE, &pItem))
+ aEditModeCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_FMT_EXPAND, FALSE, &pItem))
+ aFormatCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_REF_EXPAND, FALSE, &pItem))
+ aExpRefCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_MARK_HEADER, FALSE, &pItem))
+ aMarkHdrCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+ if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SC_INPUT_TEXTWYSIWYG, FALSE, &pItem))
+ aTextFmtCB.Check(((const SfxBoolItem*)pItem)->GetValue());
+
+ if( SFX_ITEM_SET == rCoreSet.GetItemState( SID_SC_INPUT_REPLCELLSWARN, FALSE, &pItem ) )
+ aReplWarnCB.Check( ( (const SfxBoolItem*)pItem)->GetValue() );
+
+ aAlignCB .SaveValue();
+ aAlignLB .SaveValue();
+ aEditModeCB .SaveValue();
+ aFormatCB .SaveValue();
+
+ aExpRefCB .SaveValue();
+ aMarkHdrCB .SaveValue();
+ aTextFmtCB .SaveValue();
+ aReplWarnCB .SaveValue();
+ AlignHdl(&aAlignCB);
+
+ aAlwaysRB.SaveValue();
+ aNeverRB.SaveValue();
+ aRequestRB.SaveValue();
+}
+
+/*-----------------11.01.97 12.46-------------------
+
+--------------------------------------------------*/
+
+void ScTpLayoutOptions::ActivatePage( const SfxItemSet& /* rCoreSet */ )
+{
+}
+/*-----------------11.01.97 12.46-------------------
+
+--------------------------------------------------*/
+
+int ScTpLayoutOptions::DeactivatePage( SfxItemSet* pSetP )
+{
+ if(pSetP)
+ FillItemSet(*pSetP);
+ return SfxTabPage::LEAVE_PAGE;
+}
+
+
+/*-----------------13.01.97 14.44-------------------
+ Metric des Deftabstops umschalten
+--------------------------------------------------*/
+
+IMPL_LINK(ScTpLayoutOptions, MetricHdl, ListBox*, EMPTYARG)
+{
+ const USHORT nMPos = aUnitLB.GetSelectEntryPos();
+ if(nMPos != USHRT_MAX)
+ {
+ FieldUnit eFieldUnit = (FieldUnit)(long)aUnitLB.GetEntryData( nMPos );
+ sal_Int64 nVal =
+ aTabMF.Denormalize( aTabMF.GetValue( FUNIT_TWIP ) );
+ ::SetFieldUnit( aTabMF, eFieldUnit );
+ aTabMF.SetValue( aTabMF.Normalize( nVal ), FUNIT_TWIP );
+ }
+
+ return 0;
+}
+/*-----------------11.01.97 15.30-------------------
+
+--------------------------------------------------*/
+IMPL_LINK( ScTpLayoutOptions, AlignHdl, CheckBox*, pBox )
+{
+ aAlignLB.Enable(pBox->IsChecked());
+ return 0;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/pagedlg/areasdlg.cxx b/sc/source/ui/pagedlg/areasdlg.cxx
new file mode 100644
index 000000000000..5ff14b2779ae
--- /dev/null
+++ b/sc/source/ui/pagedlg/areasdlg.cxx
@@ -0,0 +1,909 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+#include <rangelst.hxx>
+
+#include <sfx2/dispatch.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/charclass.hxx>
+#include <stdlib.h>
+
+#define _AREASDLG_CXX
+#include "areasdlg.hxx"
+#undef _AREASDLG_CXX
+
+#include "scresid.hxx"
+#include "rangenam.hxx"
+#include "reffact.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+#include "pagedlg.hrc"
+#include "compiler.hxx"
+
+// STATIC DATA ---------------------------------------------------------------
+
+// List box positions for print range (PR)
+const USHORT SC_AREASDLG_PR_NONE = 0;
+const USHORT SC_AREASDLG_PR_ENTIRE = 1;
+const USHORT SC_AREASDLG_PR_USER = 2;
+const USHORT SC_AREASDLG_PR_SELECT = 3;
+const USHORT SC_AREASDLG_PR_OFFSET = 4;
+
+// List box positions for repeat ranges (RR)
+const USHORT SC_AREASDLG_RR_NONE = 0;
+const USHORT SC_AREASDLG_RR_USER = 1;
+const USHORT SC_AREASDLG_RR_OFFSET = 2;
+
+//============================================================================
+
+#define HDL(hdl) LINK( this, ScPrintAreasDlg, hdl )
+#define ERRORBOX(nId) ErrorBox( this, WinBits(WB_OK|WB_DEF_OK), \
+ ScGlobal::GetRscString( nId ) ).Execute()
+#define SWAP(x1,x2) { int n=x1; x1=x2; x2=n; }
+
+// globale Funktionen (->am Ende der Datei):
+
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange );
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr );
+
+#if 0
+// this method is useful when debugging address flags.
+static void printAddressFlags(USHORT nFlag)
+{
+ if ((nFlag & SCA_COL_ABSOLUTE ) == SCA_COL_ABSOLUTE ) printf("SCA_COL_ABSOLUTE \n");
+ if ((nFlag & SCA_ROW_ABSOLUTE ) == SCA_ROW_ABSOLUTE ) printf("SCA_ROW_ABSOLUTE \n");
+ if ((nFlag & SCA_TAB_ABSOLUTE ) == SCA_TAB_ABSOLUTE ) printf("SCA_TAB_ABSOLUTE \n");
+ if ((nFlag & SCA_TAB_3D ) == SCA_TAB_3D ) printf("SCA_TAB_3D \n");
+ if ((nFlag & SCA_COL2_ABSOLUTE ) == SCA_COL2_ABSOLUTE ) printf("SCA_COL2_ABSOLUTE\n");
+ if ((nFlag & SCA_ROW2_ABSOLUTE ) == SCA_ROW2_ABSOLUTE ) printf("SCA_ROW2_ABSOLUTE\n");
+ if ((nFlag & SCA_TAB2_ABSOLUTE ) == SCA_TAB2_ABSOLUTE ) printf("SCA_TAB2_ABSOLUTE\n");
+ if ((nFlag & SCA_TAB2_3D ) == SCA_TAB2_3D ) printf("SCA_TAB2_3D \n");
+ if ((nFlag & SCA_VALID_ROW ) == SCA_VALID_ROW ) printf("SCA_VALID_ROW \n");
+ if ((nFlag & SCA_VALID_COL ) == SCA_VALID_COL ) printf("SCA_VALID_COL \n");
+ if ((nFlag & SCA_VALID_TAB ) == SCA_VALID_TAB ) printf("SCA_VALID_TAB \n");
+ if ((nFlag & SCA_FORCE_DOC ) == SCA_FORCE_DOC ) printf("SCA_FORCE_DOC \n");
+ if ((nFlag & SCA_VALID_ROW2 ) == SCA_VALID_ROW2 ) printf("SCA_VALID_ROW2 \n");
+ if ((nFlag & SCA_VALID_COL2 ) == SCA_VALID_COL2 ) printf("SCA_VALID_COL2 \n");
+ if ((nFlag & SCA_VALID_TAB2 ) == SCA_VALID_TAB2 ) printf("SCA_VALID_TAB2 \n");
+ if ((nFlag & SCA_VALID ) == SCA_VALID ) printf("SCA_VALID \n");
+ if ((nFlag & SCA_ABS ) == SCA_ABS ) printf("SCA_ABS \n");
+ if ((nFlag & SCR_ABS ) == SCR_ABS ) printf("SCR_ABS \n");
+ if ((nFlag & SCA_ABS_3D ) == SCA_ABS_3D ) printf("SCA_ABS_3D \n");
+ if ((nFlag & SCR_ABS_3D ) == SCR_ABS_3D ) printf("SCR_ABS_3D \n");
+}
+#endif
+
+//============================================================================
+// class ScPrintAreasDlg
+
+//----------------------------------------------------------------------------
+
+ScPrintAreasDlg::ScPrintAreasDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent )
+ : ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_AREAS),
+ //
+ aLbPrintArea ( this, ScResId( LB_PRINTAREA ) ),
+ aFlPrintArea ( this, ScResId( FL_PRINTAREA ) ),
+ aEdPrintArea ( this, this, ScResId( ED_PRINTAREA ) ),
+ aRbPrintArea ( this, ScResId( RB_PRINTAREA ), &aEdPrintArea, this ),
+ //
+ aLbRepeatRow ( this, ScResId( LB_REPEATROW ) ),
+ aFlRepeatRow ( this, ScResId( FL_REPEATROW ) ),
+ aEdRepeatRow ( this, this, ScResId( ED_REPEATROW ) ),
+ aRbRepeatRow ( this, ScResId( RB_REPEATROW ), &aEdRepeatRow, this ),
+ //
+ aLbRepeatCol ( this, ScResId( LB_REPEATCOL ) ),
+ aFlRepeatCol ( this, ScResId( FL_REPEATCOL ) ),
+ aEdRepeatCol ( this, this, ScResId( ED_REPEATCOL ) ),
+ aRbRepeatCol ( this, ScResId( RB_REPEATCOL ), &aEdRepeatCol, this ),
+ //
+ aBtnOk ( this, ScResId( BTN_OK ) ),
+ aBtnCancel ( this, ScResId( BTN_CANCEL ) ),
+ aBtnHelp ( this, ScResId( BTN_HELP ) ),
+ //
+ bDlgLostFocus ( FALSE ),
+ pRefInputEdit ( &aEdPrintArea ),
+ pDoc ( NULL ),
+ pViewData ( NULL ),
+ nCurTab ( 0 )
+{
+ ScTabViewShell* pScViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ ScDocShell* pScDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
+
+ DBG_ASSERT( pScDocSh, "Current DocumentShell not found :-(" );
+
+ pDoc = pScDocSh->GetDocument();
+
+ if ( pScViewSh )
+ {
+ pViewData = pScViewSh->GetViewData();
+ nCurTab = pViewData->GetTabNo();
+ }
+
+ Impl_Reset();
+
+ //@BugID 54702 Enablen/Disablen nur noch in Basisklasse
+ //SFX_APPWINDOW->Enable();
+
+ FreeResource();
+}
+
+
+//----------------------------------------------------------------------------
+
+ScPrintAreasDlg::~ScPrintAreasDlg()
+{
+ // Extra-Data an ListBox-Entries abraeumen
+ ListBox* pLb[3] = { &aLbPrintArea, &aLbRepeatRow, &aLbRepeatCol };
+
+ for ( USHORT i=0; i<3; i++ )
+ {
+ USHORT nCount = pLb[i]->GetEntryCount();
+ for ( USHORT j=0; j<nCount; j++ )
+ delete (String*)pLb[i]->GetEntryData(j);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Close()
+{
+ return DoClose( ScPrintAreasDlgWrapper::GetChildWindowId() );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::IsTableLocked() const
+{
+ // Druckbereiche gelten pro Tabelle, darum macht es keinen Sinn,
+ // bei der Eingabe die Tabelle umzuschalten
+
+ return TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::SetReference( const ScRange& rRef, ScDocument* /* pDoc */ )
+{
+ if ( pRefInputEdit )
+ {
+ if ( rRef.aStart != rRef.aEnd )
+ RefInputStart( pRefInputEdit );
+
+ String aStr;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( &aEdPrintArea == pRefInputEdit )
+ {
+ rRef.Format( aStr, SCR_ABS, pDoc, eConv );
+
+// aEdPrintArea.ReplaceSelected( aStr );
+
+ String aVal = aEdPrintArea.GetText();
+ Selection aSel = aEdPrintArea.GetSelection();
+ aSel.Justify();
+ aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
+ aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
+ Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
+ aEdPrintArea.SetRefString( aVal );
+ aEdPrintArea.SetSelection( aNewSel );
+ }
+ else
+ {
+ BOOL bRow = ( &aEdRepeatRow == pRefInputEdit );
+ lcl_GetRepeatRangeString(&rRef, pDoc, bRow, aStr);
+ pRefInputEdit->SetRefString( aStr );
+ }
+ }
+
+ Impl_ModifyHdl( pRefInputEdit );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::AddRefEntry()
+{
+ if ( pRefInputEdit == &aEdPrintArea )
+ {
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ String aVal = aEdPrintArea.GetText();
+ aVal += sep;
+ aEdPrintArea.SetText(aVal);
+
+ xub_StrLen nLen = aVal.Len();
+ aEdPrintArea.SetSelection( Selection( nLen, nLen ) );
+
+ Impl_ModifyHdl( &aEdPrintArea );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Deactivate()
+{
+ bDlgLostFocus = TRUE;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::SetActive()
+{
+ if ( bDlgLostFocus )
+ {
+ bDlgLostFocus = FALSE;
+
+ if ( pRefInputEdit )
+ {
+ pRefInputEdit->GrabFocus();
+ Impl_ModifyHdl( pRefInputEdit );
+ }
+ }
+ else
+ GrabFocus();
+
+ RefInputDone();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Impl_Reset()
+{
+ String aStrRange;
+ const ScRange* pRepeatColRange = pDoc->GetRepeatColRange( nCurTab );
+ const ScRange* pRepeatRowRange = pDoc->GetRepeatRowRange( nCurTab );
+
+ aEdPrintArea.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdRepeatRow.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdRepeatCol.SetModifyHdl ( HDL(Impl_ModifyHdl) );
+ aEdPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aEdRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aEdRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbPrintArea.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbRepeatRow.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbRepeatCol.SetGetFocusHdl( HDL(Impl_GetFocusHdl) );
+ aLbPrintArea.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aLbRepeatRow.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aLbRepeatCol.SetSelectHdl ( HDL(Impl_SelectHdl) );
+ aBtnOk .SetClickHdl ( HDL(Impl_BtnHdl) );
+ aBtnCancel .SetClickHdl ( HDL(Impl_BtnHdl) );
+
+ Impl_FillLists();
+
+ //-------------------------
+ // Druckbereich
+ //-------------------------
+ aStrRange.Erase();
+ String aOne;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ USHORT nRangeCount = pDoc->GetPrintRangeCount( nCurTab );
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ const ScRange* pPrintRange = pDoc->GetPrintRange( nCurTab, i );
+ if (pPrintRange)
+ {
+ if ( aStrRange.Len() )
+ aStrRange += sep;
+ pPrintRange->Format( aOne, SCR_ABS, pDoc, eConv );
+ aStrRange += aOne;
+ }
+ }
+ aEdPrintArea.SetText( aStrRange );
+
+ //-------------------------------
+ // Wiederholungszeile
+ //-------------------------------
+ lcl_GetRepeatRangeString(pRepeatRowRange, pDoc, true, aStrRange);
+ aEdRepeatRow.SetText( aStrRange );
+
+ //--------------------------------
+ // Wiederholungsspalte
+ //--------------------------------
+ lcl_GetRepeatRangeString(pRepeatColRange, pDoc, false, aStrRange);
+ aEdRepeatCol.SetText( aStrRange );
+
+ Impl_ModifyHdl( &aEdPrintArea );
+ Impl_ModifyHdl( &aEdRepeatRow );
+ Impl_ModifyHdl( &aEdRepeatCol );
+ if( pDoc->IsPrintEntireSheet( nCurTab ) )
+ aLbPrintArea.SelectEntryPos( SC_AREASDLG_PR_ENTIRE );
+
+ aEdPrintArea.SaveValue(); // fuer FillItemSet() merken:
+ aEdRepeatRow.SaveValue();
+ aEdRepeatCol.SaveValue();
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Impl_GetItem( Edit* pEd, SfxStringItem& rItem )
+{
+ String aRangeStr = pEd->GetText();
+ BOOL bDataChanged = (pEd->GetSavedValue() != aRangeStr);
+
+ if ( (aRangeStr.Len() > 0) && &aEdPrintArea != pEd )
+ {
+ ScRange aRange;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ lcl_CheckRepeatString(aRangeStr, pDoc, &aEdRepeatRow == pEd, &aRange);
+ aRange.Format(aRangeStr, SCR_ABS, pDoc, eConv);
+ }
+
+ rItem.SetValue( aRangeStr );
+
+ return bDataChanged;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScPrintAreasDlg::Impl_CheckRefStrings()
+{
+ BOOL bOk = FALSE;
+ String aStrPrintArea = aEdPrintArea.GetText();
+ String aStrRepeatRow = aEdRepeatRow.GetText();
+ String aStrRepeatCol = aEdRepeatCol.GetText();
+
+ BOOL bPrintAreaOk = TRUE;
+ if ( aStrPrintArea.Len() )
+ {
+ const USHORT nValidAddr = SCA_VALID | SCA_VALID_ROW | SCA_VALID_COL;
+ const USHORT nValidRange = nValidAddr | SCA_VALID_ROW2 | SCA_VALID_COL2;
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ // const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
+
+ ScAddress aAddr;
+ ScRange aRange;
+ xub_StrLen nSepCount = aStrPrintArea.GetTokenCount(sep);
+ for ( xub_StrLen i = 0; i < nSepCount && bPrintAreaOk; ++i )
+ {
+ String aOne = aStrPrintArea.GetToken(i, sep);
+ USHORT nResult = aRange.Parse( aOne, pDoc, eConv );
+ if ((nResult & nValidRange) != nValidRange)
+ {
+ USHORT nAddrResult = aAddr.Parse( aOne, pDoc, eConv );
+ if ((nAddrResult & nValidAddr) != nValidAddr)
+ bPrintAreaOk = FALSE;
+ }
+ }
+ }
+
+ BOOL bRepeatRowOk = (aStrRepeatRow.Len() == 0);
+ if ( !bRepeatRowOk )
+ bRepeatRowOk = lcl_CheckRepeatString(aStrRepeatRow, pDoc, true, NULL);
+
+ BOOL bRepeatColOk = (aStrRepeatCol.Len() == 0);
+ if ( !bRepeatColOk )
+ bRepeatColOk = lcl_CheckRepeatString(aStrRepeatCol, pDoc, false, NULL);
+
+ // Fehlermeldungen
+
+ bOk = (bPrintAreaOk && bRepeatRowOk && bRepeatColOk);
+
+ if ( !bOk )
+ {
+ Edit* pEd = NULL;
+
+ if ( !bPrintAreaOk ) pEd = &aEdPrintArea;
+ else if ( !bRepeatRowOk ) pEd = &aEdRepeatRow;
+ else if ( !bRepeatColOk ) pEd = &aEdRepeatCol;
+
+ ERRORBOX( STR_INVALID_TABREF );
+ pEd->GrabFocus();
+ }
+
+ return bOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScPrintAreasDlg::Impl_FillLists()
+{
+ //------------------------------------------------------
+ // Selektion holen und String in PrintArea-ListBox merken
+ //------------------------------------------------------
+ ScRange aRange;
+ String aStrRange;
+ BOOL bSimple = TRUE;
+
+ if ( pViewData )
+ bSimple = (pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE);
+
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+
+ if ( bSimple )
+ aRange.Format( aStrRange, SCR_ABS, pDoc, eConv );
+ else
+ {
+ ScRangeListRef aList( new ScRangeList );
+ pViewData->GetMarkData().FillRangeListWithMarks( aList, FALSE );
+ aList->Format( aStrRange, SCR_ABS, pDoc, eConv );
+ }
+
+ aLbPrintArea.SetEntryData( SC_AREASDLG_PR_SELECT, new String( aStrRange ) );
+
+ //------------------------------------------------------
+ // Ranges holen und in ListBoxen merken
+ //------------------------------------------------------
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+
+ if ( nCount > 0 )
+ {
+ String aName;
+ String aSymbol;
+// ScRange aRange;
+ ScRangeData* pData = NULL;
+
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ pData = (ScRangeData*)(pRangeNames->At( i ));
+ if ( pData )
+ {
+ if ( pData->HasType( RT_ABSAREA )
+ || pData->HasType( RT_REFAREA )
+ || pData->HasType( RT_ABSPOS ) )
+ {
+ pData->GetName( aName );
+ pData->GetSymbol( aSymbol );
+ if ( aRange.ParseAny( aSymbol, pDoc, eConv ) & SCA_VALID )
+ {
+ if ( pData->HasType( RT_PRINTAREA ) )
+ {
+ aRange.Format( aSymbol, SCR_ABS, pDoc, eConv );
+ aLbPrintArea.SetEntryData(
+ aLbPrintArea.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+
+ if ( pData->HasType( RT_ROWHEADER ) )
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, true, aSymbol);
+ aLbRepeatRow.SetEntryData(
+ aLbRepeatRow.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+
+ if ( pData->HasType( RT_COLHEADER ) )
+ {
+ lcl_GetRepeatRangeString(&aRange, pDoc, false, aSymbol);
+ aLbRepeatCol.SetEntryData(
+ aLbRepeatCol.InsertEntry( aName ),
+ new String( aSymbol ) );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Handler:
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_BtnHdl, PushButton*, pBtn )
+{
+ if ( &aBtnOk == pBtn )
+ {
+ if ( Impl_CheckRefStrings() )
+ {
+ BOOL bDataChanged = FALSE;
+ String aStr;
+ SfxStringItem aPrintArea( SID_CHANGE_PRINTAREA, aStr );
+ SfxStringItem aRepeatRow( FN_PARAM_2, aStr );
+ SfxStringItem aRepeatCol( FN_PARAM_3, aStr );
+
+ //-------------------------
+ // Druckbereich veraendert?
+ //-------------------------
+
+ // first try the list box, if "Entite sheet" is selected
+ BOOL bEntireSheet = (aLbPrintArea.GetSelectEntryPos() == SC_AREASDLG_PR_ENTIRE);
+ SfxBoolItem aEntireSheet( FN_PARAM_4, bEntireSheet );
+
+ bDataChanged = bEntireSheet != pDoc->IsPrintEntireSheet( nCurTab );
+ if( !bEntireSheet )
+ {
+ // if new list box selection is not "Entire sheet", get the edit field contents
+ bDataChanged |= Impl_GetItem( &aEdPrintArea, aPrintArea );
+ }
+
+ //-------------------------------
+ // Wiederholungszeile veraendert?
+ //-------------------------------
+ bDataChanged |= Impl_GetItem( &aEdRepeatRow, aRepeatRow );
+
+ //--------------------------------
+ // Wiederholungsspalte veraendert?
+ //--------------------------------
+ bDataChanged |= Impl_GetItem( &aEdRepeatCol, aRepeatCol );
+
+ if ( bDataChanged )
+ {
+ SetDispatcherLock( FALSE );
+ SwitchToDocument();
+ GetBindings().GetDispatcher()->Execute( SID_CHANGE_PRINTAREA,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aPrintArea, &aRepeatRow, &aRepeatCol, &aEntireSheet, 0L );
+ }
+
+ Close();
+ }
+ }
+ else if ( &aBtnCancel == pBtn )
+ Close();
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_GetFocusHdl, Control*, pCtr )
+{
+ if ( pCtr ==(Control *) &aEdPrintArea ||
+ pCtr ==(Control *) &aEdRepeatRow ||
+ pCtr ==(Control *) &aEdRepeatCol)
+ {
+ pRefInputEdit = (formula::RefEdit*) pCtr;
+ }
+ else if ( pCtr ==(Control *) &aLbPrintArea)
+ {
+ pRefInputEdit = &aEdPrintArea;
+ }
+ else if ( pCtr ==(Control *) &aLbRepeatRow)
+ {
+ pRefInputEdit = &aEdRepeatRow;
+ }
+ else if ( pCtr ==(Control *) &aLbRepeatCol)
+ {
+ pRefInputEdit = &aEdRepeatCol;
+ }
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_SelectHdl, ListBox*, pLb )
+{
+ USHORT nSelPos = pLb->GetSelectEntryPos();
+ Edit* pEd = NULL;
+
+ // list box positions of specific entries, default to "repeat row/column" list boxes
+ USHORT nAllSheetPos = SC_AREASDLG_RR_NONE;
+ USHORT nUserDefPos = SC_AREASDLG_RR_USER;
+ USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
+
+ // find edit field for list box, and list box positions
+ if( pLb == &aLbPrintArea )
+ {
+ pEd = &aEdPrintArea;
+ nAllSheetPos = SC_AREASDLG_PR_ENTIRE;
+ nUserDefPos = SC_AREASDLG_PR_USER;
+ nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
+ }
+ else if( pLb == &aLbRepeatCol )
+ pEd = &aEdRepeatCol;
+ else if( pLb == &aLbRepeatRow )
+ pEd = &aEdRepeatRow;
+ else
+ return 0;
+
+ // fill edit field according to list box selection
+ if( (nSelPos == 0) || (nSelPos == nAllSheetPos) )
+ pEd->SetText( EMPTY_STRING );
+ else if( nSelPos == nUserDefPos && !pLb->IsTravelSelect() && pEd->GetText().Len() == 0 )
+ pLb->SelectEntryPos( 0 );
+ else if( nSelPos >= nFirstCustomPos )
+ pEd->SetText( *static_cast< String* >( pLb->GetEntryData( nSelPos ) ) );
+
+ return 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+IMPL_LINK( ScPrintAreasDlg, Impl_ModifyHdl, formula::RefEdit*, pEd )
+{
+ ListBox* pLb = NULL;
+
+ // list box positions of specific entries, default to "repeat row/column" list boxes
+ USHORT nUserDefPos = SC_AREASDLG_RR_USER;
+ USHORT nFirstCustomPos = SC_AREASDLG_RR_OFFSET;
+
+ if( pEd == &aEdPrintArea )
+ {
+ pLb = &aLbPrintArea;
+ nUserDefPos = SC_AREASDLG_PR_USER;
+ nFirstCustomPos = SC_AREASDLG_PR_SELECT; // "Selection" and following
+ }
+ else if( pEd == &aEdRepeatCol )
+ pLb = &aLbRepeatCol;
+ else if( pEd == &aEdRepeatRow )
+ pLb = &aLbRepeatRow;
+ else
+ return 0;
+
+ // set list box selection according to edit field
+ USHORT nEntryCount = pLb->GetEntryCount();
+ String aStrEd( pEd->GetText() );
+ String aEdUpper = aStrEd;
+ aEdUpper.ToUpperAscii();
+
+ if ( (nEntryCount > nFirstCustomPos) && aStrEd.Len() > 0 )
+ {
+ BOOL bFound = FALSE;
+ String* pSymbol = NULL;
+ USHORT i;
+
+ for ( i=nFirstCustomPos; i<nEntryCount && !bFound; i++ )
+ {
+ pSymbol = (String*)pLb->GetEntryData( i );
+ bFound = ( (*pSymbol == aStrEd) || (*pSymbol == aEdUpper) );
+ }
+
+ pLb->SelectEntryPos( bFound ? i-1 : nUserDefPos );
+ }
+ else
+ pLb->SelectEntryPos( aStrEd.Len() ? nUserDefPos : 0 );
+
+ return 0;
+}
+
+
+//============================================================================
+// globale Funktionen:
+
+// ----------------------------------------------------------------------------
+
+// TODO: It might make sense to move these functions to address.?xx. -kohei
+
+bool lcl_CheckOne_OOO( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ // Zulaessige Syntax fuer rStr:
+ // Row: [$]1-MAXTAB
+ // Col: [$]A-IV
+
+ String aStr = rStr;
+ xub_StrLen nLen = aStr.Len();
+ SCCOLROW nNum = 0;
+ BOOL bStrOk = ( nLen > 0 ) && ( bIsRow ? ( nLen < 6 ) : ( nLen < 4 ) );
+
+ if ( bStrOk )
+ {
+ if ( '$' == aStr.GetChar(0) )
+ aStr.Erase( 0, 1 );
+
+ if ( bIsRow )
+ {
+ bStrOk = CharClass::isAsciiNumeric(aStr);
+
+ if ( bStrOk )
+ {
+ sal_Int32 n = aStr.ToInt32();
+
+ if ( ( bStrOk = (n > 0) && ( n <= MAXROWCOUNT ) ) != FALSE )
+ nNum = static_cast<SCCOLROW>(n - 1);
+ }
+ }
+ else
+ {
+ SCCOL nCol = 0;
+ bStrOk = ::AlphaToCol( nCol, aStr);
+ nNum = nCol;
+ }
+ }
+
+ if ( bStrOk )
+ rVal = nNum;
+
+ return bStrOk;
+}
+
+bool lcl_CheckOne_XL_A1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ // XL A1 style is identical to OOO one for print range formats.
+ return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
+}
+
+bool lcl_CheckOne_XL_R1C1( const String& rStr, bool bIsRow, SCCOLROW& rVal )
+{
+ xub_StrLen nLen = rStr.Len();
+ if (nLen <= 1)
+ // There must be at least two characters.
+ return false;
+
+ const sal_Unicode preUpper = bIsRow ? 'R' : 'C';
+ const sal_Unicode preLower = bIsRow ? 'r' : 'c';
+ if (rStr.GetChar(0) != preUpper && rStr.GetChar(0) != preLower)
+ return false;
+
+ String aNumStr = rStr.Copy(1);
+ if (!CharClass::isAsciiNumeric(aNumStr))
+ return false;
+
+ sal_Int32 nNum = aNumStr.ToInt32();
+
+ if (nNum <= 0)
+ return false;
+
+ if ((bIsRow && nNum > MAXROWCOUNT) || (!bIsRow && nNum > MAXCOLCOUNT))
+ return false;
+
+ rVal = static_cast<SCCOLROW>(nNum-1);
+ return true;
+}
+
+bool lcl_CheckRepeatOne( const String& rStr, formula::FormulaGrammar::AddressConvention eConv, bool bIsRow, SCCOLROW& rVal )
+{
+ switch (eConv)
+ {
+ case formula::FormulaGrammar::CONV_OOO:
+ return lcl_CheckOne_OOO(rStr, bIsRow, rVal);
+ case formula::FormulaGrammar::CONV_XL_A1:
+ return lcl_CheckOne_XL_A1(rStr, bIsRow, rVal);
+ case formula::FormulaGrammar::CONV_XL_R1C1:
+ return lcl_CheckOne_XL_R1C1(rStr, bIsRow, rVal);
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return false;
+}
+
+bool lcl_CheckRepeatString( const String& rStr, ScDocument* pDoc, bool bIsRow, ScRange* pRange )
+{
+ // Row: [valid row] rsep [valid row]
+ // Col: [valid col] rsep [valid col]
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const sal_Unicode rsep = ScCompiler::GetNativeSymbol(ocRange).GetChar(0);
+
+ if (pRange)
+ {
+ // initialize the range value.
+ pRange->aStart.SetCol(0);
+ pRange->aStart.SetRow(0);
+ pRange->aEnd.SetCol(0);
+ pRange->aEnd.SetRow(0);
+ }
+
+ String aBuf;
+ SCCOLROW nVal = 0;
+ xub_StrLen nLen = rStr.Len();
+ bool bEndPos = false;
+ for (xub_StrLen i = 0; i < nLen; ++i)
+ {
+ const sal_Unicode c = rStr.GetChar(i);
+ if (c == rsep)
+ {
+ if (bEndPos)
+ // We aren't supposed to have more than one range separator.
+ return false;
+
+ // range separator
+ if (aBuf.Len() == 0)
+ return false;
+
+ bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
+ if (!bRes)
+ return false;
+
+ if (pRange)
+ {
+ if (bIsRow)
+ {
+ pRange->aStart.SetRow(static_cast<SCROW>(nVal));
+ pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
+ }
+ else
+ {
+ pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
+ pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
+ }
+ }
+
+ aBuf.Erase();
+ bEndPos = true;
+ }
+ else
+ aBuf.Append(c);
+ }
+
+ if (aBuf.Len() > 0)
+ {
+ bool bRes = lcl_CheckRepeatOne(aBuf, eConv, bIsRow, nVal);
+ if (!bRes)
+ return false;
+
+ if (pRange)
+ {
+ if (bIsRow)
+ {
+ if (!bEndPos)
+ pRange->aStart.SetRow(static_cast<SCROW>(nVal));
+ pRange->aEnd.SetRow(static_cast<SCROW>(nVal));
+ }
+ else
+ {
+ if (!bEndPos)
+ pRange->aStart.SetCol(static_cast<SCCOL>(nVal));
+ pRange->aEnd.SetCol(static_cast<SCCOL>(nVal));
+ }
+ }
+ }
+
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+
+void lcl_GetRepeatRangeString( const ScRange* pRange, ScDocument* pDoc, bool bIsRow, String& rStr )
+{
+ rStr.Erase();
+ if (!pRange)
+ return;
+
+ const formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ const ScAddress& rStart = pRange->aStart;
+ const ScAddress& rEnd = pRange->aEnd;
+
+ const USHORT nFmt = bIsRow ? (SCA_VALID_ROW | SCA_ROW_ABSOLUTE) : (SCA_VALID_COL | SCA_COL_ABSOLUTE);
+ String aTmpStr;
+ rStart.Format(aTmpStr, nFmt, pDoc, eConv);
+ rStr += aTmpStr;
+ if ((bIsRow && rStart.Row() != rEnd.Row()) || (!bIsRow && rStart.Col() != rEnd.Col()))
+ {
+ rStr += ScCompiler::GetNativeSymbol(ocRange);
+ rEnd.Format(aTmpStr, nFmt, pDoc, eConv);
+ rStr += aTmpStr;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/pagedlg/hfedtdlg.cxx b/sc/source/ui/pagedlg/hfedtdlg.cxx
new file mode 100644
index 000000000000..d2409e34c258
--- /dev/null
+++ b/sc/source/ui/pagedlg/hfedtdlg.cxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svl/eitem.hxx>
+
+#include "hfedtdlg.hxx"
+#include "global.hxx"
+#include "globstr.hrc"
+#include "scresid.hxx"
+#include "hfedtdlg.hrc"
+#include "scuitphfedit.hxx"
+//------------------------------------------------------------------
+
+// macros from docsh4.cxx
+//! use SIDs?
+
+#define IS_SHARE_HEADER(set) \
+ ((SfxBoolItem&) \
+ ((SvxSetItem&)(set).Get(ATTR_PAGE_HEADERSET)).GetItemSet(). \
+ Get(ATTR_PAGE_SHARED)).GetValue()
+
+#define IS_SHARE_FOOTER(set) \
+ ((SfxBoolItem&) \
+ ((SvxSetItem&)(set).Get(ATTR_PAGE_FOOTERSET)).GetItemSet(). \
+ Get(ATTR_PAGE_SHARED)).GetValue()
+
+//==================================================================
+
+ScHFEditDlg::ScHFEditDlg( SfxViewFrame* pFrameP,
+ Window* pParent,
+ const SfxItemSet& rCoreSet,
+ const String& rPageStyle,
+ USHORT nResIdP )
+ : SfxTabDialog( pFrameP, pParent, ScResId( nResIdP ), &rCoreSet )
+{
+ eNumType = ((const SvxPageItem&)rCoreSet.Get(ATTR_PAGE)).GetNumType();
+
+ String aTmp = GetText();
+
+ aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aTmp += ScGlobal::GetRscString( STR_PAGESTYLE );
+ aTmp.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ aTmp += rPageStyle;
+ aTmp += ')';
+ SetText( aTmp );
+
+ switch ( nResIdP )
+ {
+ case RID_SCDLG_HFED_HEADER:
+ case RID_SCDLG_HFEDIT_HEADER:
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFED_FOOTER:
+ case RID_SCDLG_HFEDIT_FOOTER:
+ AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
+ AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_LEFTHEADER:
+ AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_RIGHTHEADER:
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_LEFTFOOTER:
+ AddTabPage( 1, ScLeftFooterEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_RIGHTFOOTER:
+ AddTabPage( 1, ScRightFooterEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_SHDR:
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
+ AddTabPage( 3, ScLeftFooterEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_SFTR:
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
+ AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
+ break;
+
+ case RID_SCDLG_HFEDIT_ALL:
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ AddTabPage( 2, ScLeftHeaderEditPage::Create, NULL );
+ AddTabPage( 3, ScRightFooterEditPage::Create, NULL );
+ AddTabPage( 4, ScLeftFooterEditPage::Create, NULL );
+ break;
+
+ default:
+ case RID_SCDLG_HFEDIT:
+ {
+ const SvxPageItem& rPageItem = (const SvxPageItem&)
+ rCoreSet.Get(
+ rCoreSet.GetPool()->GetWhich(SID_ATTR_PAGE) );
+
+ BOOL bRightPage = ( SVX_PAGE_LEFT !=
+ SvxPageUsage(rPageItem.GetPageUsage()) );
+
+ if ( bRightPage )
+ {
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
+ }
+ else
+ {
+ // #69193a# respect "shared" setting
+
+ BOOL bShareHeader = IS_SHARE_HEADER(rCoreSet);
+ if ( bShareHeader )
+ AddTabPage( 1, ScRightHeaderEditPage::Create, NULL );
+ else
+ AddTabPage( 1, ScLeftHeaderEditPage::Create, NULL );
+
+ BOOL bShareFooter = IS_SHARE_FOOTER(rCoreSet);
+ if ( bShareFooter )
+ AddTabPage( 2, ScRightFooterEditPage::Create, NULL );
+ else
+ AddTabPage( 2, ScLeftFooterEditPage::Create, NULL );
+ }
+ }
+ break;
+ }
+
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScHFEditDlg::~ScHFEditDlg()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScHFEditDlg::PageCreated( USHORT /* nId */, SfxTabPage& rPage )
+{
+ // kann ja nur ne ScHFEditPage sein...
+
+ ((ScHFEditPage&)rPage).SetNumType(eNumType);
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/pagedlg/hfedtdlg.hrc b/sc/source/ui/pagedlg/hfedtdlg.hrc
new file mode 100644
index 000000000000..a8a32da3446f
--- /dev/null
+++ b/sc/source/ui/pagedlg/hfedtdlg.hrc
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+
+//#define RID_SCPAGE_HFEDIT 256
+//#define RID_SCDLG_HFEDIT 256
+
+#define FT_LEFT 1
+#define FT_CENTER 2
+#define FT_RIGHT 3
+#define FT_INFO 4
+#define WND_LEFT 1
+#define WND_CENTER 2
+#define WND_RIGHT 3
+#define BTN_TEXT 1
+#define BTN_PAGE 2
+#define BTN_PAGES 3
+#define BTN_DATE 4
+#define BTN_TIME 5
+#define BTN_FILE 6
+#define BTN_TABLE 7
+
+#define RID_POPUP_FCOMMAND 10
+#define FILE_COMMAND_TITEL 11
+#define FILE_COMMAND_FILENAME 12
+#define FILE_COMMAND_PATH 13
+
+#define FL_INFO 14
+
+#define IMG_TEXT_H 21
+#define IMG_PAGE_H 22
+#define IMG_PAGES_H 23
+#define IMG_DATE_H 24
+#define IMG_TIME_H 25
+#define IMG_FILE_H 26
+#define IMG_TABLE_H 27
+#define FT_HF_DEFINED 28
+#define LB_DEFINED 29
+#define FT_HF_CUSTOM 30
diff --git a/sc/source/ui/pagedlg/hfedtdlg.src b/sc/source/ui/pagedlg/hfedtdlg.src
new file mode 100644
index 000000000000..749303ce7164
--- /dev/null
+++ b/sc/source/ui/pagedlg/hfedtdlg.src
@@ -0,0 +1,829 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/* StarView ressource file */
+#include "hfedtdlg.hrc"
+#define HFEDIT_DLGTITLE \
+ Text [ en-US ] = "Headers/Footers" ; \
+
+#define HEADER \
+ Text [ en-US ] = "Header" ; \
+
+#define FOOTER \
+ Text [ en-US ] = "Footer" ; \
+
+#define HEADER_RIGHT \
+ Text [ en-US ] = "Header (right)" ; \
+
+#define HEADER_LEFT \
+ Text [ en-US ] = "Header (left)" ; \
+
+#define FOOTER_RIGHT \
+ Text [ en-US ] = "Footer (right)" ; \
+
+#define FOOTER_LEFT \
+ Text [ en-US ] = "Footer (left)" ; \
+
+ //------------------------------------------------------------------------
+ // Bearbeiten vom Seitendialog aus aufgerufen
+ //------------------------------------------------------------------------
+TabDialog RID_SCDLG_HFED_HEADER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Text [ en-US ] = "Headers" ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER_RIGHT
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ HEADER_LEFT
+ PageResID = HID_SCPAGE_HFED_HL ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFED_FOOTER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Text [ en-US ] = "Footers" ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ FOOTER_RIGHT
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ FOOTER_LEFT
+ PageResID = HID_SCPAGE_HFED_FL ;
+ };
+ };
+ };
+};
+ //------------------------------------------------------------------------
+ // Bearbeiten/Kopf-Fusszeile:
+ //------------------------------------------------------------------------
+TabDialog RID_SCDLG_HFEDIT_ALL
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER_RIGHT
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ HEADER_LEFT
+ PageResID = HID_SCPAGE_HFED_HL ;
+ };
+ PageItem
+ {
+ Identifier = 3 ;
+ FOOTER_RIGHT
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ PageItem
+ {
+ Identifier = 4 ;
+ FOOTER_LEFT
+ PageResID = HID_SCPAGE_HFED_FL ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_SHDR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ FOOTER_RIGHT
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ PageItem
+ {
+ Identifier = 3 ;
+ FOOTER_LEFT
+ PageResID = HID_SCPAGE_HFED_FL ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_SFTR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER_RIGHT
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ HEADER_LEFT
+ PageResID = HID_SCPAGE_HFED_HL ;
+ };
+ PageItem
+ {
+ Identifier = 3 ;
+ FOOTER
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ FOOTER
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_HEADER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER_RIGHT
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ HEADER_LEFT
+ PageResID = HID_SCPAGE_HFED_HL ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_FOOTER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ FOOTER_RIGHT
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ PageItem
+ {
+ Identifier = 2 ;
+ FOOTER_LEFT
+ PageResID = HID_SCPAGE_HFED_FL ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_RIGHTHEADER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER_RIGHT
+ PageResID = HID_SCPAGE_HFED_HR ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_LEFTHEADER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ HEADER_LEFT
+ PageResID = HID_SCPAGE_HFED_HL ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_RIGHTFOOTER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ FOOTER_RIGHT
+ PageResID = HID_SCPAGE_HFED_FR ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_HFEDIT_LEFTFOOTER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 270 , 140 ) ;
+ Moveable = TRUE ;
+ // Closeable = TRUE;
+ HFEDIT_DLGTITLE
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = 1 ;
+ FOOTER_LEFT
+ PageResID = HID_SCPAGE_HFED_FL ;
+ };
+ };
+ };
+};
+ //------------------------------------------------------------------------
+ // ScTpHFEdit
+ //------------------------------------------------------------------------
+TabPage RID_HFBASE
+{
+ Hide = TRUE ;
+ HelpId = HID_SCPAGE_HFEDIT ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedText FT_LEFT
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "~Left area" ;
+ };
+ /* "Control" braucht eigene HelpId, darum in der Ableitung:
+ Control WND_LEFT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+*/
+ FixedText FT_CENTER
+ {
+ Pos = MAP_APPFONT ( 90 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "~Center area" ;
+ };
+ /* "Control" braucht eigene HelpId, darum in der Ableitung:
+ Control WND_CENTER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+*/
+ FixedText FT_RIGHT
+ {
+ Pos = MAP_APPFONT ( 174 , 6 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "R~ight area" ;
+ };
+ /* "Control" braucht eigene HelpId, darum in der Ableitung:
+ Control WND_RIGHT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+*/
+ FixedText FT_HF_DEFINED
+ {
+ Pos = MAP_APPFONT ( 12 , 102 ) ;
+ Size = MAP_APPFONT ( 76 , 10 ) ;
+ Text [ en-US ] = "Hea~der" ;
+ };
+
+ /* #i84123# list box needs own help id, which is set in the derived tab pages
+ ListBox LB_DEFINED
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 100 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ DropDown = TRUE ;
+ TabStop = TRUE ;
+ };
+ */
+
+ FixedText FT_HF_CUSTOM
+ {
+ Pos = MAP_APPFONT ( 12 , 124 ) ;
+ Size = MAP_APPFONT ( 76 , 10 ) ;
+ Text [ en-US ] = "Custom header" ;
+ };
+
+ ImageButton BTN_TEXT
+ {
+ HelpId = HID_SC_HF_TEXT ;
+ Pos = MAP_APPFONT ( 90 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Text Attributes" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "text.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+ };
+ };
+ Image IMG_TEXT_H
+ {
+ ImageBitmap = Bitmap { File = "text_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ ImageButton BTN_FILE
+ {
+ HelpId = HID_SC_HF_FILE ;
+ Pos = MAP_APPFONT ( 113 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Title" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "file.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+ };
+ };
+ Image IMG_FILE_H
+ {
+ ImageBitmap = Bitmap { File = "file_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+
+ Menu RID_POPUP_FCOMMAND
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = FILE_COMMAND_TITEL ;
+ HelpID = HID_FCOMMAND_TITEL ;
+ Text [ en-US ] = "Title";
+ };
+ MenuItem
+ {
+ Identifier = FILE_COMMAND_FILENAME;
+ HelpID = HID_FCOMMAND_FILENAME;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "File Name";
+ };
+ MenuItem
+ {
+ Identifier = FILE_COMMAND_PATH;
+ HelpID = HID_FCOMMAND_PATH;
+ RadioCheck = TRUE ;
+ Text [ en-US ] = "Path/File Name";
+ };
+ };
+ };
+
+ ImageButton BTN_TABLE
+ {
+ HelpId = HID_SC_HF_TABLE ;
+ Pos = MAP_APPFONT ( 130 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Sheet Name" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "table.bmp" ; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ };
+ Image IMG_TABLE_H
+ {
+ ImageBitmap = Bitmap { File = "table_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ ImageButton BTN_PAGE
+ {
+ HelpId = HID_SC_HF_PAGE ;
+ Pos = MAP_APPFONT ( 150 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Page" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "page.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+ };
+ };
+ Image IMG_PAGE_H
+ {
+ ImageBitmap = Bitmap { File = "page_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ ImageButton BTN_PAGES
+ {
+ HelpId = HID_SC_HF_PAGES ;
+ Pos = MAP_APPFONT ( 167 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Pages" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "pages.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+ };
+ };
+ Image IMG_PAGES_H
+ {
+ ImageBitmap = Bitmap { File = "pages_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ ImageButton BTN_DATE
+ {
+ HelpId = HID_SC_HF_DATE ;
+ Pos = MAP_APPFONT ( 187 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Date" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "date.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+ };
+ };
+ Image IMG_DATE_H
+ {
+ ImageBitmap = Bitmap { File = "date_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ ImageButton BTN_TIME
+ {
+ HelpId = HID_SC_HF_TIME ;
+ Pos = MAP_APPFONT ( 204 , 122 ) ;
+ Size = MAP_APPFONT ( 15 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Time" ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap { File = "time.bmp" ; };
+ MaskColor = STD_MASKCOLOR ;
+ };
+ };
+ Image IMG_TIME_H
+ {
+ ImageBitmap = Bitmap { File = "time_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ FixedText FT_INFO
+ {
+ Pos = MAP_APPFONT ( 12 , 155 ) ;
+ Size = MAP_APPFONT ( 240 , 24 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Use the buttons to change the font or insert field commands such as date, time, etc." ;
+ };
+ FixedLine FL_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 144 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Note" ;
+ };
+};
+ // Kombinationen: Header/Footer links/rechts
+ // die Eingabefenster jeweils mit eigener ID, sonst aus RID_HFBASE kopiert
+TabPage RID_SCPAGE_HFED_HL < RID_HFBASE
+{
+ Hide = TRUE ;
+ HelpId = HID_SCPAGE_HFED_HL ;
+ Control WND_LEFT
+ {
+ HelpId = HID_SC_HF_HLL ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_CENTER
+ {
+ HelpId = HID_SC_HF_HLC ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_RIGHT
+ {
+ HelpId = HID_SC_HF_HLR ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_DEFINED
+ {
+ HelpId = HID_SC_HF_HL_DEFINED ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 100 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ DropDown = TRUE ;
+ TabStop = TRUE ;
+ };
+};
+TabPage RID_SCPAGE_HFED_HR < RID_HFBASE
+{
+ Hide = TRUE ;
+ HelpId = HID_SCPAGE_HFED_HR ;
+ Control WND_LEFT
+ {
+ HelpId = HID_SC_HF_HRL ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_CENTER
+ {
+ HelpId = HID_SC_HF_HRC ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_RIGHT
+ {
+ HelpId = HID_SC_HF_HRR ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_DEFINED
+ {
+ HelpId = HID_SC_HF_HR_DEFINED ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 100 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ DropDown = TRUE ;
+ TabStop = TRUE ;
+ };
+};
+TabPage RID_SCPAGE_HFED_FL < RID_HFBASE
+{
+ Hide = TRUE ;
+ HelpId = HID_SCPAGE_HFED_FL ;
+ Control WND_LEFT
+ {
+ HelpId = HID_SC_HF_FLL ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_CENTER
+ {
+ HelpId = HID_SC_HF_FLC ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_RIGHT
+ {
+ HelpId = HID_SC_HF_FLR ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_DEFINED
+ {
+ HelpId = HID_SC_HF_FL_DEFINED ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 100 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ DropDown = TRUE ;
+ TabStop = TRUE ;
+ };
+};
+TabPage RID_SCPAGE_HFED_FR < RID_HFBASE
+{
+ Hide = TRUE ;
+ HelpId = HID_SCPAGE_HFED_FR ;
+ Control WND_LEFT
+ {
+ HelpId = HID_SC_HF_FRL ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_CENTER
+ {
+ HelpId = HID_SC_HF_FRC ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ Control WND_RIGHT
+ {
+ HelpId = HID_SC_HF_FRR ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 174 , 18 ) ;
+ Size = MAP_APPFONT ( 80 , 72 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_DEFINED
+ {
+ HelpId = HID_SC_HF_FR_DEFINED ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 90 , 100 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ DropDown = TRUE ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/sc/source/ui/pagedlg/makefile.mk b/sc/source/ui/pagedlg/makefile.mk
new file mode 100644
index 000000000000..93224ec7cb58
--- /dev/null
+++ b/sc/source/ui/pagedlg/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=pagedlg
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ areasdlg.cxx \
+ hfedtdlg.cxx \
+ tptable.cxx \
+ tphf.cxx \
+ tphfedit.cxx
+
+
+
+SLOFILES = \
+ $(SLO)$/areasdlg.obj \
+ $(SLO)$/hfedtdlg.obj \
+ $(SLO)$/tptable.obj \
+ $(SLO)$/tphf.obj \
+ $(SLO)$/tphfedit.obj \
+ $(SLO)$/scuitphfedit.obj
+
+
+SRS1NAME=$(TARGET)
+SRC1FILES = pagedlg.src \
+ hfedtdlg.src \
+ tphf.src
+
+LIB1TARGET = $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO)$/areasdlg.obj \
+ $(SLO)$/tphfedit.obj
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/pagedlg/pagedlg.hrc b/sc/source/ui/pagedlg/pagedlg.hrc
new file mode 100644
index 000000000000..6a995b1679d4
--- /dev/null
+++ b/sc/source/ui/pagedlg/pagedlg.hrc
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "sc.hrc" // -> RID_SCDLG_PAGE
+ // -> RID_SCPAGE_TABLE
+ // -> RID_SCPAGE_AREAS
+
+#define TP_PAGE_STD 1
+#define TP_PAGE_HEADER 2
+#define TP_PAGE_FOOTER 3
+#define TP_PAGE_TABLE 4
+#define TP_PAGE_AREAS 5
+
+//================================================
+// TabPage: Tabelle
+
+#define BTN_GRID 10
+#define BTN_HEADER 11
+#define BTN_NOTES 12
+#define BTN_CHARTS 13
+#define BTN_OBJECTS 14
+#define BTN_DRAWINGS 15
+#define BTN_FORMULAS 16
+#define BTN_NULLVALS 17
+#define FL_PRINT 19
+
+#define BTN_TOPDOWN 20
+#define BTN_LEFTRIGHT 21
+#define BMP_PAGEDIR 22
+#define IMG_LEFTRIGHT 23
+#define IMG_TOPDOWN 24
+#define BTN_PAGENO 25
+#define ED_PAGENO 26
+#define FL_PAGEDIR 29
+
+#define FT_SCALEMODE 30
+#define LB_SCALEMODE 31
+#define ED_SCALEALL 32
+#define ED_SCALEPAGENUM 34
+#define ED_SCALEPAGEWIDTH 35
+#define ED_SCALEPAGEHEIGHT 36
+#define FL_SCALE 39
+
+#define FT_SCALEFACTOR 51
+#define FT_SCALEPAGEWIDTH 52
+#define FT_SCALEPAGEHEIGHT 53
+#define FT_SCALEPAGENUM 54
+
+#define IMG_LEFTRIGHT_H 41
+#define IMG_TOPDOWN_H 42
+
+// List box entries "Scaling mode"
+#define SC_TPTABLE_SCALE_PERCENT 0
+#define SC_TPTABLE_SCALE_TO 1
+#define SC_TPTABLE_SCALE_TO_PAGES 2
+
+//================================================
+// Dialog: Druckbereiche
+
+#define FL_PRINTAREA 10
+#define ED_PRINTAREA 11
+#define RB_PRINTAREA 12
+#define LB_PRINTAREA 13
+
+#define FL_REPEATROW 20
+#define ED_REPEATROW 21
+#define RB_REPEATROW 22
+#define LB_REPEATROW 23
+
+#define FL_REPEATCOL 30
+#define ED_REPEATCOL 31
+#define RB_REPEATCOL 32
+#define LB_REPEATCOL 33
+
+#define BTN_OK 1
+#define BTN_CANCEL 2
+#define BTN_HELP 3
+
diff --git a/sc/source/ui/pagedlg/pagedlg.src b/sc/source/ui/pagedlg/pagedlg.src
new file mode 100644
index 000000000000..a4e51bff0792
--- /dev/null
+++ b/sc/source/ui/pagedlg/pagedlg.src
@@ -0,0 +1,416 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "pagedlg.hrc"
+ModelessDialog RID_SCDLG_AREAS
+{
+ HelpId = HID_SCPAGE_AREAS ;
+ Size = MAP_APPFONT ( 316 , 90 ) ;
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ //Closeable = TRUE; // Dieser Dialog hat einen Cancel-Button !
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Edit Print Ranges" ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 260 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 260 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 260 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ FixedLine FL_PRINTAREA
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Print range" ;
+ };
+ ListBox LB_PRINTAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 90 , 60 ) ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "- none -" ; Default ; > ;
+ < "- entire sheet -" ; Default ; > ;
+ < "- user defined -" ; Default ; > ;
+ < "- selection -" ; Default ; > ;
+ };
+ };
+ Edit ED_PRINTAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 14 ) ;
+ Size = MAP_APPFONT ( 131 , 12 ) ;
+ };
+ ImageButton RB_PRINTAREA
+ {
+ Pos = MAP_APPFONT ( 239 , 13 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_REPEATROW
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Rows to repeat" ;
+ };
+ ListBox LB_REPEATROW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 43 ) ;
+ Size = MAP_APPFONT ( 90 , 60 ) ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "- none -" ; Default ; > ;
+ < "- user defined -" ; Default ; > ;
+ };
+ };
+ Edit ED_REPEATROW
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 43 ) ;
+ Size = MAP_APPFONT ( 131 , 12 ) ;
+ };
+ ImageButton RB_REPEATROW
+ {
+ Pos = MAP_APPFONT ( 239 , 42 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_REPEATCOL
+ {
+ Pos = MAP_APPFONT ( 6 , 61 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Columns to repeat" ;
+ };
+ ListBox LB_REPEATCOL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 72 ) ;
+ Size = MAP_APPFONT ( 90 , 60 ) ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "- none -" ; Default ; > ;
+ < "- user defined -" ; Default ; > ;
+ };
+ };
+ Edit ED_REPEATCOL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 72 ) ;
+ Size = MAP_APPFONT ( 131 , 12 ) ;
+ };
+ ImageButton RB_REPEATCOL
+ {
+ Pos = MAP_APPFONT ( 239 , 71 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+};
+TabPage RID_SCPAGE_TABLE
+{
+ Hide = TRUE ;
+ HelpId = HID_SCPAGE_TABLE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ CheckBox BTN_HEADER
+ {
+ Pos = MAP_APPFONT ( 12 , 73 ) ;
+ Size = MAP_APPFONT ( 142 , 10 ) ;
+ Text [ en-US ] = "~Column and row headers" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_GRID
+ {
+ Pos = MAP_APPFONT ( 12 , 87 ) ;
+ Size = MAP_APPFONT ( 142 , 10 ) ;
+ Text [ en-US ] = "~Grid" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_NOTES
+ {
+ Pos = MAP_APPFONT ( 12 , 101 ) ;
+ Size = MAP_APPFONT ( 142 , 10 ) ;
+ Text [ en-US ] = "~Comments" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_OBJECTS
+ {
+ Pos = MAP_APPFONT ( 12 , 115 ) ;
+ Size = MAP_APPFONT ( 142 , 10 ) ;
+ Text [ en-US ] = "~Objects/graphics" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_CHARTS
+ {
+ Pos = MAP_APPFONT ( 160 , 73 ) ;
+ Size = MAP_APPFONT ( 91 , 10 ) ;
+ Text [ en-US ] = "Ch~arts" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DRAWINGS
+ {
+ Pos = MAP_APPFONT ( 160 , 87 ) ;
+ Size = MAP_APPFONT ( 91 , 10 ) ;
+ Text [ en-US ] = "~Drawing objects" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_FORMULAS
+ {
+ Pos = MAP_APPFONT ( 160 , 101 ) ;
+ Size = MAP_APPFONT ( 91 , 10 ) ;
+ Text [ en-US ] = "~Formulas" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_NULLVALS
+ {
+ Pos = MAP_APPFONT ( 160 , 115 ) ;
+ Size = MAP_APPFONT ( 91 , 10 ) ;
+ Text [ en-US ] = "Zero ~values" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_PRINT
+ {
+ Pos = MAP_APPFONT ( 6 , 62 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Print" ;
+ };
+ RadioButton BTN_TOPDOWN
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 142 , 10 ) ;
+ Text [ en-US ] = "~Top to bottom, then right" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_LEFTRIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 142 , 10 ) ;
+ Text [ en-US ] = "~Left to right, then down" ;
+ TabStop = TRUE ;
+ };
+ FixedImage BMP_PAGEDIR
+ {
+ Pos = MAP_APPFONT ( 160 , 14 ) ;
+ Size = MAP_APPFONT ( 25 , 25 ) ;
+ };
+ Image IMG_LEFTRIGHT
+ {
+ ImageBitmap = Bitmap { File = "lftrgt.bmp" ; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image IMG_LEFTRIGHT_H
+ {
+ ImageBitmap = Bitmap { File = "lftrgt_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ Image IMG_TOPDOWN
+ {
+ ImageBitmap = Bitmap { File = "topdown.bmp" ; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image IMG_TOPDOWN_H
+ {
+ ImageBitmap = Bitmap { File = "topdown_h.bmp" ; };
+ MaskColor = SC_HC_MASKCOLOR;
+ };
+ CheckBox BTN_PAGENO
+ {
+ Pos = MAP_APPFONT ( 12 , 46 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "First ~page number" ;
+ TabStop = TRUE ;
+ };
+ NumericField ED_PAGENO
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 106 , 44 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Minimum = 1 ;
+ Maximum = 9999 ;
+ SpinSize = 1 ;
+ Repeat = TRUE ;
+ };
+ FixedLine FL_PAGEDIR
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Page order" ;
+ };
+ FixedText FT_SCALEMODE
+ {
+ Pos = MAP_APPFONT( 12, 144 );
+ Size = MAP_APPFONT( 124, 8 );
+ Text [ en-US ] = "Scaling ~mode";
+ };
+ ListBox LB_SCALEMODE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT( 12, 155 );
+ Size = MAP_APPFONT( 124, 60 );
+ DropDown = TRUE;
+ StringList [ en-US ] =
+ {
+ < "Reduce/enlarge printout"; SC_TPTABLE_SCALE_PERCENT; >;
+ < "Fit print range(s) to width/height"; SC_TPTABLE_SCALE_TO; >;
+ < "Fit print range(s) on number of pages"; SC_TPTABLE_SCALE_TO_PAGES; >;
+ };
+ };
+ MetricField ED_SCALEALL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 155 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 10 ;
+ Maximum = 400 ;
+ First = 15 ;
+ Last = 200 ;
+ SpinSize = 1 ;
+ Unit = FUNIT_CUSTOM ;
+ CustomUnitText = "%" ;
+ };
+ NumericField ED_SCALEPAGEWIDTH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 144 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 1000 ;
+ SpinSize = 1 ;
+ };
+ NumericField ED_SCALEPAGEHEIGHT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 160 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 1000 ;
+ SpinSize = 1 ;
+ };
+ NumericField ED_SCALEPAGENUM
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 218 , 155 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Minimum = 1 ;
+ Maximum = 1000 ;
+ SpinSize = 1 ;
+ };
+ FixedText FT_SCALEFACTOR
+ {
+ Pos = MAP_APPFONT( 148, 157 );
+ Size = MAP_APPFONT( 68 , 8 );
+ Hide = TRUE;
+ Text [ en-US ] = "~Scaling factor";
+ };
+ FixedText FT_SCALEPAGEWIDTH
+ {
+ Pos = MAP_APPFONT( 148, 146 );
+ Size = MAP_APPFONT( 68 , 8 );
+ Hide = TRUE;
+ Text [ en-US ] = "~Width in pages";
+ };
+ FixedText FT_SCALEPAGEHEIGHT
+ {
+ Pos = MAP_APPFONT( 148, 162 );
+ Size = MAP_APPFONT( 68 , 8 );
+ Hide = TRUE;
+ Text [ en-US ] = "H~eight in pages";
+ };
+ FixedText FT_SCALEPAGENUM
+ {
+ Pos = MAP_APPFONT( 148, 157 );
+ Size = MAP_APPFONT( 68, 8 );
+ Hide = TRUE;
+ Text [ en-US ] = "N~umber of pages";
+ };
+ FixedLine FL_SCALE
+ {
+ Pos = MAP_APPFONT ( 6 , 131 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Scale" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/pagedlg/scuitphfedit.cxx b/sc/source/ui/pagedlg/scuitphfedit.cxx
new file mode 100644
index 000000000000..05ee8962247b
--- /dev/null
+++ b/sc/source/ui/pagedlg/scuitphfedit.cxx
@@ -0,0 +1,1002 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#define _TPHFEDIT_CXX
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <editeng/editobj.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/flditem.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/objsh.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/useroptions.hxx>
+#define _SVSTDARR_USHORTS
+#include <svl/svstdarr.hxx>
+
+#include "editutil.hxx"
+#include "global.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "prevwsh.hxx"
+#include "hfedtdlg.hrc"
+#include "textdlgs.hxx"
+#include "AccessibleEditObject.hxx"
+
+#include "scuitphfedit.hxx"
+#include <memory> // header file for auto_ptr
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pPageRightHeaderRanges[] = { SID_SCATTR_PAGE_HEADERRIGHT,
+ SID_SCATTR_PAGE_HEADERRIGHT,
+ 0 };
+
+static USHORT pPageRightFooterRanges[] = { SID_SCATTR_PAGE_FOOTERRIGHT,
+ SID_SCATTR_PAGE_FOOTERRIGHT,
+ 0 };
+
+static USHORT pPageLeftHeaderRanges[] = { SID_SCATTR_PAGE_HEADERLEFT,
+ SID_SCATTR_PAGE_HEADERLEFT,
+ 0 };
+
+static USHORT pPageLeftFooterRanges[] = { SID_SCATTR_PAGE_FOOTERLEFT,
+ SID_SCATTR_PAGE_FOOTERLEFT,
+ 0 };
+
+
+static ScEditWindow* pActiveEdWnd = NULL;
+
+
+//========================================================================
+// class ScHFEditPage
+//
+
+ScHFEditPage::ScHFEditPage( Window* pParent,
+ USHORT nResId,
+ const SfxItemSet& rCoreAttrs,
+ USHORT nWhichId,
+ bool bHeader )
+
+ : SfxTabPage ( pParent, ScResId( nResId ), rCoreAttrs ),
+
+ aFtLeft ( this, ScResId( FT_LEFT ) ),
+ aWndLeft ( this, ScResId( WND_LEFT ), Left ),
+ aFtCenter ( this, ScResId( FT_CENTER ) ),
+ aWndCenter ( this, ScResId( WND_CENTER ), Center ),
+ aFtRight ( this, ScResId( FT_RIGHT ) ),
+ aWndRight ( this, ScResId( WND_RIGHT ), Right ),
+ maFtDefinedHF ( this, ScResId( FT_HF_DEFINED ) ),
+ maLbDefined ( this, ScResId( LB_DEFINED ) ),
+ maFtCustomHF ( this, ScResId( FT_HF_CUSTOM ) ),
+ aBtnText ( this, ScResId( BTN_TEXT ) ),
+ aBtnFile ( this, ScResId( BTN_FILE ) ),
+ aBtnTable ( this, ScResId( BTN_TABLE ) ),
+ aBtnPage ( this, ScResId( BTN_PAGE ) ),
+ aBtnLastPage ( this, ScResId( BTN_PAGES ) ),
+ aBtnDate ( this, ScResId( BTN_DATE ) ),
+ aBtnTime ( this, ScResId( BTN_TIME ) ),
+ aFlInfo ( this, ScResId( FL_INFO ) ),
+ aFtInfo ( this, ScResId( FT_INFO ) ),
+ aPopUpFile ( ScResId( RID_POPUP_FCOMMAND) ),
+ nWhich ( nWhichId )
+{
+ //! use default style from current document?
+ //! if font color is used, header/footer background color must be set
+
+ ScPatternAttr aPatAttr( rCoreAttrs.GetPool() );
+
+
+ aBtnFile.SetPopupMenu(&aPopUpFile);
+
+ maLbDefined.SetSelectHdl( LINK( this, ScHFEditPage, ListHdl_Impl ) );
+ aBtnFile.SetMenuHdl( LINK( this, ScHFEditPage, MenuHdl ) );
+ aBtnText .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+ aBtnPage .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+ aBtnLastPage.SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+ aBtnDate .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+ aBtnTime .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+ aBtnFile .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+ aBtnTable .SetClickHdl( LINK( this, ScHFEditPage, ClickHdl ) );
+
+ aBtnText .SetModeImage( Image( ScResId( IMG_TEXT_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aBtnFile .SetModeImage( Image( ScResId( IMG_FILE_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aBtnTable .SetModeImage( Image( ScResId( IMG_TABLE_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aBtnPage .SetModeImage( Image( ScResId( IMG_PAGE_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aBtnLastPage.SetModeImage( Image( ScResId( IMG_PAGES_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aBtnDate .SetModeImage( Image( ScResId( IMG_DATE_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aBtnTime .SetModeImage( Image( ScResId( IMG_TIME_H ) ), BMP_COLOR_HIGHCONTRAST );
+
+ if(!bHeader)
+ {
+ maFtDefinedHF.SetText(ScGlobal::GetRscString( STR_FOOTER ));
+ maFtCustomHF.SetText(ScGlobal::GetRscString( STR_HF_CUSTOM_FOOTER ));
+ }
+ if( Application::GetSettings().GetLayoutRTL() )
+ {
+ Point pt1 = aWndLeft.GetPosPixel();
+ Point pt2 = aWndRight.GetPosPixel();
+ aWndLeft.SetPosPixel(pt2);
+ aWndRight.SetPosPixel(pt1);
+
+ pt1 = aFtLeft.GetPosPixel();
+ pt2 = aFtRight.GetPosPixel();
+ aFtLeft.SetPosPixel(pt2);
+ aFtRight.SetPosPixel(pt1);
+ }
+ aWndLeft. SetFont( aPatAttr );
+ aWndCenter. SetFont( aPatAttr );
+ aWndRight. SetFont( aPatAttr );
+
+ FillCmdArr();
+
+ aWndLeft.GrabFocus();
+
+ InitPreDefinedList();
+
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScHFEditPage::~ScHFEditPage()
+{
+}
+
+void ScHFEditPage::SetNumType(SvxNumType eNumType)
+{
+ aWndLeft.SetNumType(eNumType);
+ aWndCenter.SetNumType(eNumType);
+ aWndRight.SetNumType(eNumType);
+}
+
+// -----------------------------------------------------------------------
+
+#define IS_AVAILABLE(w)(rCoreSet.GetItemState( (w) ) >= SFX_ITEM_AVAILABLE)
+
+void __EXPORT ScHFEditPage::Reset( const SfxItemSet& rCoreSet )
+{
+ if ( IS_AVAILABLE( nWhich ) )
+ {
+ const ScPageHFItem& rItem = (const ScPageHFItem&)(rCoreSet.Get( nWhich ));
+
+ if( const EditTextObject* pLeft = rItem.GetLeftArea() )
+ aWndLeft.SetText( *pLeft );
+ if( const EditTextObject* pCenter = rItem.GetCenterArea() )
+ aWndCenter.SetText( *pCenter );
+ if( const EditTextObject* pRight = rItem.GetRightArea() )
+ aWndRight.SetText( *pRight );
+
+ SetSelectDefinedList();
+ }
+}
+
+#undef IS_AVAILABLE
+
+// -----------------------------------------------------------------------
+
+BOOL __EXPORT ScHFEditPage::FillItemSet( SfxItemSet& rCoreSet )
+{
+ ScPageHFItem aItem( nWhich );
+ EditTextObject* pLeft = aWndLeft .CreateTextObject();
+ EditTextObject* pCenter = aWndCenter.CreateTextObject();
+ EditTextObject* pRight = aWndRight .CreateTextObject();
+
+ aItem.SetLeftArea ( *pLeft );
+ aItem.SetCenterArea( *pCenter );
+ aItem.SetRightArea ( *pRight );
+ delete pLeft;
+ delete pCenter;
+ delete pRight;
+
+ rCoreSet.Put( aItem );
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+#define SET_CMD(i,id) \
+ aCmd = aDel; \
+ aCmd += ScGlobal::GetRscString( id ); \
+ aCmd += aDel; \
+ aCmdArr[i] = aCmd;
+
+// -----------------------------------------------------------------------
+
+void ScHFEditPage::FillCmdArr()
+{
+ String aDel( ScGlobal::GetRscString( STR_HFCMD_DELIMITER ) );
+ String aCmd;
+
+ SET_CMD( 0, STR_HFCMD_PAGE )
+ SET_CMD( 1, STR_HFCMD_PAGES )
+ SET_CMD( 2, STR_HFCMD_DATE )
+ SET_CMD( 3, STR_HFCMD_TIME )
+ SET_CMD( 4, STR_HFCMD_FILE )
+ SET_CMD( 5, STR_HFCMD_TABLE )
+}
+
+#undef SET_CMD
+
+void ScHFEditPage::InitPreDefinedList()
+{
+ SvtUserOptions aUserOpt;
+
+ Color* pTxtColour = NULL;
+ Color* pFldColour = NULL;
+
+ // Get the all field values at the outset.
+ String aPageFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
+ String aSheetFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
+ String aFileFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
+ String aExtFileFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxExtFileField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
+ String aDateFieldValue(aWndLeft.GetEditEngine()->CalcFieldValue(SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD), 0,0, pTxtColour, pFldColour));
+
+ maLbDefined.Clear();
+
+ maLbDefined.InsertEntry( ScGlobal::GetRscString( STR_HF_NONE_IN_BRACKETS ));
+
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aPageEntry += aPageFieldValue;
+ maLbDefined.InsertEntry(aPageEntry);
+
+ String aPageOfEntry(aPageEntry);
+ aPageOfEntry += ' ';
+ aPageOfEntry += ScGlobal::GetRscString( STR_HF_OF_QUESTION );
+ maLbDefined.InsertEntry( aPageOfEntry);
+
+ maLbDefined.InsertEntry(aSheetFieldValue);
+
+ String aConfidentialEntry(aUserOpt.GetCompany());
+ aConfidentialEntry += ' ';
+ aConfidentialEntry += ScGlobal::GetRscString( STR_HF_CONFIDENTIAL );
+ aConfidentialEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aConfidentialEntry += aDateFieldValue;
+ aConfidentialEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aConfidentialEntry += aPageEntry;
+ maLbDefined.InsertEntry( aConfidentialEntry);
+
+ String aFileNamePageEntry(aFileFieldValue);
+ aFileNamePageEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aFileNamePageEntry += aPageEntry;
+ maLbDefined.InsertEntry( aFileNamePageEntry);
+
+ maLbDefined.InsertEntry( aExtFileFieldValue);
+
+ String aPageSheetNameEntry(aPageEntry);
+ aPageSheetNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aPageSheetNameEntry += aSheetFieldValue;
+ maLbDefined.InsertEntry( aPageSheetNameEntry);
+
+ String aPageFileNameEntry(aPageEntry);
+ aPageFileNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aPageFileNameEntry += aFileFieldValue;
+ maLbDefined.InsertEntry( aPageFileNameEntry);
+
+ String aPagePathNameEntry(aPageEntry);
+ aPagePathNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aPagePathNameEntry += aExtFileFieldValue;
+ maLbDefined.InsertEntry( aPagePathNameEntry);
+
+ String aUserNameEntry(aUserOpt.GetFirstName());
+ aUserNameEntry += ' ';
+ aUserNameEntry += (String)aUserOpt.GetLastName();
+ aUserNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aUserNameEntry += aPageEntry;
+ aUserNameEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aUserNameEntry += aDateFieldValue;
+ maLbDefined.InsertEntry( aUserNameEntry);
+
+ String aCreatedByEntry(ScGlobal::GetRscString( STR_HF_CREATED_BY ) );
+ aCreatedByEntry += ' ';
+ aCreatedByEntry += (String)aUserOpt.GetFirstName();
+ aCreatedByEntry += ' ';
+ aCreatedByEntry += (String)aUserOpt.GetLastName();
+ aCreatedByEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aCreatedByEntry += aDateFieldValue;
+ aCreatedByEntry.AppendAscii(RTL_CONSTASCII_STRINGPARAM(", "));
+ aCreatedByEntry += aPageEntry;
+ maLbDefined.InsertEntry( aCreatedByEntry);
+}
+
+void ScHFEditPage::InsertToDefinedList()
+{
+ USHORT nCount = maLbDefined.GetEntryCount();
+ if(nCount == eEntryCount)
+ {
+ String aCustomizedEntry(ScGlobal::GetRscString( STR_HF_CUSTOMIZED ) );
+ maLbDefined.InsertEntry( aCustomizedEntry);
+ maLbDefined.SelectEntryPos(eEntryCount);
+ }
+}
+
+void ScHFEditPage::RemoveFromDefinedList()
+{
+ USHORT nCount = maLbDefined.GetEntryCount();
+ if(nCount > eEntryCount )
+ maLbDefined.RemoveEntry( nCount-1);
+}
+
+// determine if the header/footer exists in our predefined list and set select to it.
+void ScHFEditPage::SetSelectDefinedList()
+{
+ SvtUserOptions aUserOpt;
+
+ // default to customized
+ ScHFEntryId eSelectEntry = eEntryCount;
+
+ ::std::auto_ptr< EditTextObject > pLeftObj;
+ ::std::auto_ptr< EditTextObject > pCenterObj;
+ ::std::auto_ptr< EditTextObject > pRightObj;
+
+ XubString aLeftEntry;
+ XubString aCenterEntry;
+ XubString aRightEntry;
+
+ pLeftObj.reset(aWndLeft.GetEditEngine()->CreateTextObject());
+ pCenterObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
+ pRightObj.reset(aWndRight.GetEditEngine()->CreateTextObject());
+
+ bool bFound = false;
+
+ USHORT i;
+ USHORT nCount = maLbDefined.GetEntryCount();
+ for(i = 0; i < nCount && !bFound; i++)
+ {
+ switch(static_cast<ScHFEntryId>(i))
+ {
+ case eNoneEntry:
+ {
+ aLeftEntry = pLeftObj->GetText(0);
+ aCenterEntry = pCenterObj->GetText(0);
+ aRightEntry = pRightObj->GetText(0);
+ if(aLeftEntry == EMPTY_STRING && aCenterEntry == EMPTY_STRING
+ && aRightEntry == EMPTY_STRING)
+ {
+ eSelectEntry = eNoneEntry;
+ bFound = true;
+ }
+ }
+ break;
+
+ case ePageEntry:
+ {
+ aLeftEntry = pLeftObj->GetText(0);
+ aRightEntry = pRightObj->GetText(0);
+ if(aLeftEntry == EMPTY_STRING && aRightEntry == EMPTY_STRING)
+ {
+ if(IsPageEntry(aWndCenter.GetEditEngine(), pCenterObj.get()))
+ {
+ eSelectEntry = ePageEntry;
+ bFound = true;
+ }
+ }
+ }
+ break;
+
+
+ //TODO
+ case ePagesEntry:
+ {
+ }
+ break;
+
+ case eSheetEntry:
+ {
+ aLeftEntry = pLeftObj->GetText(0);
+ aRightEntry = pRightObj->GetText(0);
+ if(aLeftEntry == EMPTY_STRING && aRightEntry == EMPTY_STRING)
+ {
+ if(pCenterObj->IsFieldObject())
+ {
+ const SvxFieldItem* pFieldItem = pCenterObj->GetField();
+ if(pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if(pField && pField->ISA(SvxTableField))
+ {
+ eSelectEntry = eSheetEntry;
+ bFound = true;
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case eConfidentialEntry:
+ {
+ if(IsDateEntry(pCenterObj.get()) && IsPageEntry(aWndRight.GetEditEngine(), pRightObj.get()))
+ {
+ String aConfidentialEntry(aUserOpt.GetCompany());
+ aConfidentialEntry += ' ';
+ aConfidentialEntry += ScGlobal::GetRscString( STR_HF_CONFIDENTIAL );
+ if(aConfidentialEntry == aWndLeft.GetEditEngine()->GetText(0))
+ {
+ eSelectEntry = eConfidentialEntry;
+ bFound = true;
+ }
+ }
+ }
+ break;
+
+ //TODO
+ case eFileNamePageEntry:
+ {
+ }
+ break;
+
+ case eExtFileNameEntry:
+ {
+ aLeftEntry = pLeftObj->GetText(0);
+ aRightEntry = pRightObj->GetText(0);
+ if(IsExtFileNameEntry(pCenterObj.get()) && aLeftEntry == EMPTY_STRING
+ && aRightEntry == EMPTY_STRING)
+ {
+ eSelectEntry = eExtFileNameEntry;
+ bFound = true;
+ }
+ }
+ break;
+
+ //TODO
+ case ePageSheetEntry:
+ {
+ }
+ break;
+
+ //TODO
+ case ePageFileNameEntry:
+ {
+ }
+ break;
+
+ case ePageExtFileNameEntry:
+ {
+ aLeftEntry = pLeftObj->GetText(0);
+ if(IsPageEntry(aWndCenter.GetEditEngine(), pCenterObj.get()) &&
+ IsExtFileNameEntry(pRightObj.get()) && aLeftEntry == EMPTY_STRING)
+ {
+ eSelectEntry = ePageExtFileNameEntry;
+ bFound = true;
+ }
+ }
+ break;
+
+ case eUserNameEntry:
+ {
+ if(IsDateEntry(pRightObj.get()) && IsPageEntry(aWndCenter.GetEditEngine(), pCenterObj.get()))
+ {
+ String aUserNameEntry(aUserOpt.GetFirstName());
+ aUserNameEntry += ' ';
+ aUserNameEntry += (String)aUserOpt.GetLastName();
+ if(aUserNameEntry == aWndLeft.GetEditEngine()->GetText(0))
+ {
+ eSelectEntry = eUserNameEntry;
+ bFound = true;
+ }
+ }
+ }
+ break;
+
+ case eCreatedByEntry:
+ {
+ if(IsDateEntry(pCenterObj.get()) && IsPageEntry(aWndRight.GetEditEngine(), pRightObj.get()))
+ {
+ String aCreatedByEntry(ScGlobal::GetRscString( STR_HF_CREATED_BY ) );
+ aCreatedByEntry += ' ';
+ aCreatedByEntry += (String)aUserOpt.GetFirstName();
+ aCreatedByEntry += ' ';
+ aCreatedByEntry += (String)aUserOpt.GetLastName();
+ if(aCreatedByEntry == aWndLeft.GetEditEngine()->GetText(0))
+ {
+ eSelectEntry = eCreatedByEntry;
+ bFound = true;
+ }
+ }
+ }
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+
+ if(eSelectEntry == eEntryCount)
+ InsertToDefinedList();
+
+ maLbDefined.SelectEntryPos( sal::static_int_cast<USHORT>( eSelectEntry ) );
+}
+
+bool ScHFEditPage::IsPageEntry(EditEngine*pEngine, EditTextObject* pTextObj)
+{
+ if(!pEngine && !pTextObj)
+ return false;
+
+ bool bReturn = false;
+
+ if(!pTextObj->IsFieldObject())
+ {
+ SvUShorts aPosList;
+ pEngine->GetPortions(0,aPosList);
+ if(aPosList.Count() == 2)
+ {
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ ESelection aSel(0,0,0,0);
+ aSel.nEndPos = aPageEntry.Len();
+ if(aPageEntry == pEngine->GetText(aSel))
+ {
+ aSel.nStartPos = aSel.nEndPos;
+ aSel.nEndPos++;
+ ::std::auto_ptr< EditTextObject > pPageObj;
+ pPageObj.reset(pEngine->CreateTextObject(aSel));
+ if(pPageObj.get() && pPageObj->IsFieldObject() )
+ {
+ const SvxFieldItem* pFieldItem = pPageObj->GetField();
+ if(pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if(pField && pField->ISA(SvxPageField))
+ bReturn = true;
+ }
+ }
+ }
+ }
+ }
+ return bReturn;
+}
+
+bool ScHFEditPage::IsDateEntry(EditTextObject* pTextObj)
+{
+ if(!pTextObj)
+ return false;
+
+ bool bReturn = false;
+ if(pTextObj->IsFieldObject())
+ {
+ const SvxFieldItem* pFieldItem = pTextObj->GetField();
+ if(pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if(pField && pField->ISA(SvxDateField))
+ bReturn = true;
+ }
+ }
+ return bReturn;
+}
+
+bool ScHFEditPage::IsExtFileNameEntry(EditTextObject* pTextObj)
+{
+ if(!pTextObj)
+ return false;
+ bool bReturn = false;
+ if(pTextObj->IsFieldObject())
+ {
+ const SvxFieldItem* pFieldItem = pTextObj->GetField();
+ if(pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if(pField && pField->ISA(SvxExtFileField))
+ bReturn = true;
+ }
+ }
+ return bReturn;
+}
+
+void ScHFEditPage::ProcessDefinedListSel(ScHFEntryId eSel, bool bTravelling)
+{
+ SvtUserOptions aUserOpt;
+ ::std::auto_ptr< EditTextObject > pTextObj;
+
+ switch(eSel)
+ {
+ case eNoneEntry:
+ ClearTextAreas();
+ if(!bTravelling)
+ aWndLeft.GrabFocus();
+ break;
+
+ case ePageEntry:
+ {
+ ClearTextAreas();
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->SetText(aPageEntry);
+ aWndCenter.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ }
+ break;
+
+ case ePagesEntry:
+ {
+ ClearTextAreas();
+ ESelection aSel(0,0,0,0);
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->SetText(aPageEntry);
+ aSel.nEndPos = aPageEntry.Len();
+ aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ ++aSel.nEndPos;
+ String aPageOfEntry = ' ';
+ aPageOfEntry += ScGlobal::GetRscString( STR_HF_OF );
+ aPageOfEntry += ' ';
+ aWndCenter.GetEditEngine()->QuickInsertText(aPageOfEntry,ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageOfEntry.Len() );
+ aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
+ aWndCenter.SetText(*pTextObj);
+ XubString aEntry(pTextObj.get()->GetText(0));
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ }
+ break;
+
+ case eSheetEntry:
+ ClearTextAreas();
+ aWndCenter.InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) );
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ break;
+
+ case eConfidentialEntry:
+ {
+ ClearTextAreas();
+ String aConfidentialEntry(aUserOpt.GetCompany());
+ aConfidentialEntry += ' ';
+ aConfidentialEntry += ScGlobal::GetRscString( STR_HF_CONFIDENTIAL );
+ aWndLeft.GetEditEngine()->SetText(aConfidentialEntry);
+ aWndCenter.InsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndRight.GetEditEngine()->SetText(aPageEntry);
+ aWndRight.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
+ if(!bTravelling)
+ aWndRight.GrabFocus();
+ }
+ break;
+
+ case eFileNamePageEntry:
+ {
+ ClearTextAreas();
+ ESelection aSel(0,0,0,0);
+ aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ), aSel );
+ ++aSel.nEndPos;
+ String aPageEntry(RTL_CONSTASCII_STRINGPARAM(", "));
+ aPageEntry += ScGlobal::GetRscString( STR_PAGE ) ;
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->QuickInsertText(aPageEntry, ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ aSel.nStartPos = aSel.nEndPos;
+ aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aPageEntry.Len() );
+ aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara,aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
+ aWndCenter.SetText(*pTextObj);
+ XubString aEntry2(pTextObj.get()->GetText(0));
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ }
+ break;
+
+ case eExtFileNameEntry:
+ ClearTextAreas();
+ aWndCenter.InsertField( SvxFieldItem( SvxExtFileField(
+ EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ break;
+
+ case ePageSheetEntry:
+ {
+ ClearTextAreas();
+ ESelection aSel(0,0,0,0);
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->SetText(aPageEntry);
+ aSel.nEndPos = aPageEntry.Len();
+ aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ ++aSel.nEndPos;
+ String aCommaSpace(RTL_CONSTASCII_STRINGPARAM(", "));
+ aWndCenter.GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.Len() );
+ aWndCenter.GetEditEngine()->QuickInsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
+ aWndCenter.SetText(*pTextObj);
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ }
+ break;
+
+ case ePageFileNameEntry:
+ {
+ ClearTextAreas();
+ ESelection aSel(0,0,0,0);
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->SetText(aPageEntry);
+ aSel.nEndPos = aPageEntry.Len();
+ aWndCenter.GetEditEngine()->QuickInsertField(SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ ++aSel.nEndPos;
+ String aCommaSpace(RTL_CONSTASCII_STRINGPARAM(", "));
+ aWndCenter.GetEditEngine()->QuickInsertText(aCommaSpace,ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ aSel.nEndPos = sal::static_int_cast<xub_StrLen>( aSel.nEndPos + aCommaSpace.Len() );
+ aWndCenter.GetEditEngine()->QuickInsertField( SvxFieldItem(SvxFileField(), EE_FEATURE_FIELD), ESelection(aSel.nEndPara, aSel.nEndPos, aSel.nEndPara, aSel.nEndPos));
+ pTextObj.reset(aWndCenter.GetEditEngine()->CreateTextObject());
+ aWndCenter.SetText(*pTextObj);
+ if(!bTravelling)
+ aWndCenter.GrabFocus();
+ }
+ break;
+
+ case ePageExtFileNameEntry:
+ {
+ ClearTextAreas();
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->SetText(aPageEntry);
+ aWndCenter.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
+ aWndRight.InsertField( SvxFieldItem( SvxExtFileField(
+ EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
+ if(!bTravelling)
+ aWndRight.GrabFocus();
+ }
+ break;
+
+ case eUserNameEntry:
+ {
+ ClearTextAreas();
+ String aUserNameEntry(aUserOpt.GetFirstName());
+ aUserNameEntry += ' ';
+ aUserNameEntry += (String)aUserOpt.GetLastName();
+ aWndLeft.GetEditEngine()->SetText(aUserNameEntry);
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndCenter.GetEditEngine()->SetText(aPageEntry);
+ aWndCenter.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
+ aWndRight.InsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
+ if(!bTravelling)
+ aWndRight.GrabFocus();
+ }
+ break;
+
+ case eCreatedByEntry:
+ {
+ ClearTextAreas();
+ String aCreatedByEntry(ScGlobal::GetRscString( STR_HF_CREATED_BY ) );
+ aCreatedByEntry += ' ';
+ aCreatedByEntry += (String)aUserOpt.GetFirstName();
+ aCreatedByEntry += ' ';
+ aCreatedByEntry += (String)aUserOpt.GetLastName();
+ aWndLeft.GetEditEngine()->SetText(aCreatedByEntry);
+ aWndCenter.InsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
+ String aPageEntry(ScGlobal::GetRscString( STR_PAGE ) );
+ aPageEntry += ' ';
+ aWndRight.GetEditEngine()->SetText(aPageEntry);
+ aWndRight.InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
+ if(!bTravelling)
+ aWndRight.GrabFocus();
+ }
+ break;
+
+ default :
+ break;
+ }
+}
+
+void ScHFEditPage::ClearTextAreas()
+{
+ aWndLeft.GetEditEngine()->SetText(EMPTY_STRING);
+ aWndLeft.Invalidate();
+ aWndCenter.GetEditEngine()->SetText(EMPTY_STRING);
+ aWndCenter.Invalidate();
+ aWndRight.GetEditEngine()->SetText(EMPTY_STRING);
+ aWndRight.Invalidate();
+}
+
+//-----------------------------------------------------------------------
+// Handler:
+//-----------------------------------------------------------------------
+
+IMPL_LINK( ScHFEditPage, ListHdl_Impl, ListBox*, pList )
+{
+ if ( pList && pList == &maLbDefined )
+ {
+ ScHFEntryId eSel = static_cast<ScHFEntryId>(maLbDefined.GetSelectEntryPos());
+ if(!maLbDefined.IsTravelSelect())
+ {
+ ProcessDefinedListSel(eSel);
+
+ // check if we need to remove the customized entry.
+ if(eSel < eEntryCount)
+ RemoveFromDefinedList();
+ }
+ else
+ {
+ ProcessDefinedListSel(eSel, true);
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( ScHFEditPage, ClickHdl, ImageButton*, pBtn )
+{
+ pActiveEdWnd = ::GetScEditWindow();
+ if ( !pActiveEdWnd )
+ return 0;
+
+ if ( pBtn == &aBtnText )
+ {
+ pActiveEdWnd->SetCharAttriutes();
+ }
+ else
+ {
+ if ( pBtn == &aBtnPage )
+ pActiveEdWnd->InsertField( SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD) );
+ else if ( pBtn == &aBtnLastPage )
+ pActiveEdWnd->InsertField( SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD) );
+ else if ( pBtn == &aBtnDate )
+ pActiveEdWnd->InsertField( SvxFieldItem(SvxDateField(Date(),SVXDATETYPE_VAR), EE_FEATURE_FIELD) );
+ else if ( pBtn == &aBtnTime )
+ pActiveEdWnd->InsertField( SvxFieldItem(SvxTimeField(), EE_FEATURE_FIELD) );
+ else if ( pBtn == &aBtnFile )
+ {
+ pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) );
+ }
+ else if ( pBtn == &aBtnTable )
+ pActiveEdWnd->InsertField( SvxFieldItem(SvxTableField(), EE_FEATURE_FIELD) );
+ }
+ InsertToDefinedList();
+ pActiveEdWnd->GrabFocus();
+
+ return 0;
+}
+
+IMPL_LINK( ScHFEditPage, MenuHdl, ScExtIButton*, pBtn )
+{
+ pActiveEdWnd = ::GetScEditWindow();
+ if ( !pActiveEdWnd )
+ return 0;
+
+ if(pBtn!=NULL)
+ {
+ switch(pBtn->GetSelected())
+ {
+ case FILE_COMMAND_TITEL:
+ pActiveEdWnd->InsertField( SvxFieldItem( SvxFileField(), EE_FEATURE_FIELD ) );
+ break;
+ case FILE_COMMAND_FILENAME:
+ pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
+ EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_NAME_EXT ), EE_FEATURE_FIELD ) );
+ break;
+ case FILE_COMMAND_PATH:
+ pActiveEdWnd->InsertField( SvxFieldItem( SvxExtFileField(
+ EMPTY_STRING, SVXFILETYPE_VAR, SVXFILEFORMAT_FULLPATH ), EE_FEATURE_FIELD ) );
+ break;
+ }
+ }
+ return 0;
+}
+
+//========================================================================
+// class ScRightHeaderEditPage
+//========================================================================
+
+ScRightHeaderEditPage::ScRightHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
+ : ScHFEditPage( pParent, RID_SCPAGE_HFED_HR, rCoreSet,
+ rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERRIGHT ), true )
+ {}
+
+// -----------------------------------------------------------------------
+
+USHORT* __EXPORT ScRightHeaderEditPage::GetRanges()
+ { return pPageRightHeaderRanges; }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScRightHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+ { return ( new ScRightHeaderEditPage( pParent, rCoreSet ) ); };
+
+
+//========================================================================
+// class ScLeftHeaderEditPage
+//========================================================================
+
+ScLeftHeaderEditPage::ScLeftHeaderEditPage( Window* pParent, const SfxItemSet& rCoreSet )
+ : ScHFEditPage( pParent, RID_SCPAGE_HFED_HL, rCoreSet,
+ rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_HEADERLEFT ), true )
+ {}
+
+// -----------------------------------------------------------------------
+
+USHORT* __EXPORT ScLeftHeaderEditPage::GetRanges()
+ { return pPageLeftHeaderRanges; }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScLeftHeaderEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+ { return ( new ScLeftHeaderEditPage( pParent, rCoreSet ) ); };
+
+//========================================================================
+// class ScRightFooterEditPage
+//========================================================================
+
+ScRightFooterEditPage::ScRightFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
+ : ScHFEditPage( pParent, RID_SCPAGE_HFED_FR, rCoreSet,
+ rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERRIGHT ), false )
+ {}
+
+// -----------------------------------------------------------------------
+
+USHORT* __EXPORT ScRightFooterEditPage::GetRanges()
+ { return pPageRightFooterRanges; }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScRightFooterEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+ { return ( new ScRightFooterEditPage( pParent, rCoreSet ) ); };
+
+//========================================================================
+// class ScLeftFooterEditPage
+//========================================================================
+
+ScLeftFooterEditPage::ScLeftFooterEditPage( Window* pParent, const SfxItemSet& rCoreSet )
+ : ScHFEditPage( pParent, RID_SCPAGE_HFED_FL, rCoreSet,
+ rCoreSet.GetPool()->GetWhich(SID_SCATTR_PAGE_FOOTERLEFT ), false )
+ {}
+
+// -----------------------------------------------------------------------
+
+USHORT* __EXPORT ScLeftFooterEditPage::GetRanges()
+ { return pPageLeftFooterRanges; }
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScLeftFooterEditPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+ { return ( new ScLeftFooterEditPage( pParent, rCoreSet ) ); };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/pagedlg/tphf.cxx b/sc/source/ui/pagedlg/tphf.cxx
new file mode 100644
index 000000000000..f673a7a3a344
--- /dev/null
+++ b/sc/source/ui/pagedlg/tphf.cxx
@@ -0,0 +1,332 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#define _TPHF_CXX
+#include "scitems.hxx"
+#include <sfx2/basedlgs.hxx>
+#include <svl/style.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "tphf.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "hfedtdlg.hxx"
+#include "styledlg.hxx"
+#include "scresid.hxx"
+#include "scuitphfedit.hxx"
+#undef _TPHF_CXX
+
+
+
+//==================================================================
+// class ScHFPage
+//==================================================================
+
+ScHFPage::ScHFPage( Window* pParent, USHORT nResId,
+ const SfxItemSet& rSet, USHORT nSetId )
+
+ : SvxHFPage ( pParent, nResId, rSet, nSetId ),
+ aBtnEdit ( this, ScResId( RID_SCBTN_HFEDIT ) ),
+ aDataSet ( *rSet.GetPool(),
+ ATTR_PAGE_HEADERLEFT, ATTR_PAGE_FOOTERRIGHT,
+ ATTR_PAGE, ATTR_PAGE, 0 ),
+ nPageUsage ( (USHORT)SVX_PAGE_ALL ),
+ pStyleDlg ( NULL )
+{
+ SetExchangeSupport();
+
+ SfxViewShell* pSh = SfxViewShell::Current();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,pSh);
+ Point aPos( aBackgroundBtn.GetPosPixel() );
+
+ // aBackgroundBtn position not changed anymore
+
+ aPos.X() += aBackgroundBtn.GetSizePixel().Width();
+ aPos.X() += LogicToPixel( Size(3,0), MAP_APPFONT ).Width();
+ aBtnEdit.SetPosPixel( aPos );
+ aBtnEdit.Show();
+
+ aDataSet.Put( rSet );
+
+ if ( pViewSh )
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ aStrPageStyle = pDoc->GetPageStyle( pViewData->GetTabNo() );
+ }
+
+ aBtnEdit.SetClickHdl ( LINK( this, ScHFPage, BtnHdl ) );
+ aTurnOnBox.SetClickHdl ( LINK( this, ScHFPage, TurnOnHdl ) );
+
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ aBtnEdit.SetHelpId( HID_SC_HEADER_EDIT );
+ else
+ aBtnEdit.SetHelpId( HID_SC_FOOTER_EDIT );
+}
+
+//------------------------------------------------------------------
+
+__EXPORT ScHFPage::~ScHFPage()
+{
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScHFPage::Reset( const SfxItemSet& rSet )
+{
+ SvxHFPage::Reset( rSet );
+ TurnOnHdl( 0 );
+}
+
+//------------------------------------------------------------------
+
+BOOL __EXPORT ScHFPage::FillItemSet( SfxItemSet& rOutSet )
+{
+ BOOL bResult = SvxHFPage::FillItemSet( rOutSet );
+
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ {
+ rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERLEFT ) );
+ rOutSet.Put( aDataSet.Get( ATTR_PAGE_HEADERRIGHT ) );
+ }
+ else
+ {
+ rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERLEFT ) );
+ rOutSet.Put( aDataSet.Get( ATTR_PAGE_FOOTERRIGHT ) );
+ }
+
+ return bResult;
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScHFPage::ActivatePage( const SfxItemSet& rSet )
+{
+ USHORT nPageWhich = GetWhich( SID_ATTR_PAGE );
+ const SvxPageItem& rPageItem = (const SvxPageItem&)
+ rSet.Get(nPageWhich);
+
+ nPageUsage = rPageItem.GetPageUsage();
+
+ if ( pStyleDlg )
+ aStrPageStyle = pStyleDlg->GetStyleSheet().GetName();
+
+ aDataSet.Put( rSet.Get(ATTR_PAGE) );
+
+ SvxHFPage::ActivatePage( rSet );
+}
+
+//------------------------------------------------------------------
+
+int __EXPORT ScHFPage::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( LEAVE_PAGE == SvxHFPage::DeactivatePage( pSetP ) )
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return LEAVE_PAGE;
+}
+
+//------------------------------------------------------------------
+
+void ScHFPage::ActivatePage()
+{
+}
+
+void ScHFPage::DeactivatePage()
+{
+}
+
+//------------------------------------------------------------------
+// Handler:
+//------------------------------------------------------------------
+
+IMPL_LINK( ScHFPage, TurnOnHdl, CheckBox*, EMPTYARG )
+{
+ SvxHFPage::TurnOnHdl( &aTurnOnBox );
+
+ if ( aTurnOnBox.IsChecked() )
+ aBtnEdit.Enable();
+ else
+ aBtnEdit.Disable();
+
+ return 0;
+}
+
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScHFPage, BtnHdl, PushButton*, EMPTYARG )
+{
+ // Wenn der Bearbeiten-Dialog direkt aus dem Click-Handler des Buttons
+ // aufgerufen wird, funktioniert im Bearbeiten-Dialog unter OS/2 das
+ // GrabFocus nicht (Bug #41805#).
+ // Mit dem neuen StarView sollte dieser Workaround wieder raus koennen!
+
+ Application::PostUserEvent( LINK( this, ScHFPage, HFEditHdl ) );
+ return 0;
+}
+
+IMPL_LINK( ScHFPage, HFEditHdl, void*, EMPTYARG )
+{
+ SfxViewShell* pViewSh = SfxViewShell::Current();
+
+ if ( !pViewSh )
+ {
+ DBG_ERROR( "Current ViewShell not found." );
+ return 0;
+ }
+
+ if ( aCntSharedBox.IsEnabled()
+ && !aCntSharedBox.IsChecked() )
+ {
+ USHORT nResId = ( nId == SID_ATTR_PAGE_HEADERSET )
+ ? RID_SCDLG_HFED_HEADER
+ : RID_SCDLG_HFED_FOOTER;
+
+ ScHFEditDlg* pDlg
+ = new ScHFEditDlg( pViewSh->GetViewFrame(), this,
+ aDataSet, aStrPageStyle, nResId );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ aDataSet.Put( *pDlg->GetOutputItemSet() );
+ }
+
+ delete pDlg;
+ }
+ else
+ {
+ String aText;
+ SfxSingleTabDialog* pDlg = new SfxSingleTabDialog( this, aDataSet, 42 );
+ BOOL bRightPage = aCntSharedBox.IsChecked()
+ || ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) );
+
+ if ( nId == SID_ATTR_PAGE_HEADERSET )
+ {
+ aText = ScGlobal::GetRscString( STR_PAGEHEADER );
+ if ( bRightPage )
+ pDlg->SetTabPage( ScRightHeaderEditPage::Create( pDlg, aDataSet ) );
+ else
+ pDlg->SetTabPage( ScLeftHeaderEditPage::Create( pDlg, aDataSet ) );
+ }
+ else
+ {
+ aText = ScGlobal::GetRscString( STR_PAGEFOOTER );
+ if ( bRightPage )
+ pDlg->SetTabPage( ScRightFooterEditPage::Create( pDlg, aDataSet ) );
+ else
+ pDlg->SetTabPage( ScLeftFooterEditPage::Create( pDlg, aDataSet ) );
+ }
+
+ SvxNumType eNumType = ((const SvxPageItem&)aDataSet.Get(ATTR_PAGE)).GetNumType();
+ ((ScHFEditPage*)pDlg->GetTabPage())->SetNumType(eNumType);
+
+ aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aText += ScGlobal::GetRscString( STR_PAGESTYLE );
+ aText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ aText += aStrPageStyle;
+ aText += ')';
+
+ pDlg->SetText( aText );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ aDataSet.Put( *pDlg->GetOutputItemSet() );
+ }
+
+ delete pDlg;
+ }
+
+ return 0;
+}
+
+//==================================================================
+// class ScHeaderPage
+//==================================================================
+
+ScHeaderPage::ScHeaderPage( Window* pParent, const SfxItemSet& rSet )
+ : ScHFPage( pParent, RID_SVXPAGE_HEADER, rSet, SID_ATTR_PAGE_HEADERSET )
+{
+}
+
+//------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScHeaderPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+{
+ return ( new ScHeaderPage( pParent, rCoreSet ) );
+}
+
+//------------------------------------------------------------------
+
+USHORT* __EXPORT ScHeaderPage::GetRanges()
+{
+ return SvxHeaderPage::GetRanges();
+}
+
+//==================================================================
+// class ScFooterPage
+//==================================================================
+
+ScFooterPage::ScFooterPage( Window* pParent, const SfxItemSet& rSet )
+ : ScHFPage( pParent, RID_SVXPAGE_FOOTER, rSet, SID_ATTR_PAGE_FOOTERSET )
+{
+}
+
+//------------------------------------------------------------------
+
+SfxTabPage* __EXPORT ScFooterPage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+{
+ return ( new ScFooterPage( pParent, rCoreSet ) );
+}
+
+//------------------------------------------------------------------
+
+USHORT* __EXPORT ScFooterPage::GetRanges()
+{
+ return SvxHeaderPage::GetRanges();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/pagedlg/tphf.src b/sc/source/ui/pagedlg/tphf.src
new file mode 100644
index 000000000000..7970a0367019
--- /dev/null
+++ b/sc/source/ui/pagedlg/tphf.src
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+PushButton RID_SCBTN_HFEDIT
+{
+ TabStop = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Edit..." ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
new file mode 100644
index 000000000000..e6ec74161ab1
--- /dev/null
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -0,0 +1,567 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#define _TPHFEDIT_CXX
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <editeng/editobj.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/adjitem.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/objsh.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+#include "tphfedit.hxx"
+#include "editutil.hxx"
+#include "global.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "prevwsh.hxx"
+#include "hfedtdlg.hrc"
+#include "AccessibleEditObject.hxx"
+
+#include "scabstdlg.hxx"
+
+
+// STATIC DATA -----------------------------------------------------------
+static ScEditWindow* pActiveEdWnd = NULL;
+
+ScEditWindow* GetScEditWindow ()
+{
+ return pActiveEdWnd;
+}
+
+//========================================================================
+
+void lcl_GetFieldData( ScHeaderFieldData& rData )
+{
+ SfxViewShell* pShell = SfxViewShell::Current();
+ if (pShell)
+ {
+ if (pShell->ISA(ScTabViewShell))
+ ((ScTabViewShell*)pShell)->FillFieldData(rData);
+ else if (pShell->ISA(ScPreviewShell))
+ ((ScPreviewShell*)pShell)->FillFieldData(rData);
+ }
+}
+
+//========================================================================
+// class ScEditWindow
+//========================================================================
+
+ScEditWindow::ScEditWindow( Window* pParent, const ResId& rResId, ScEditWindowLocation eLoc )
+ : Control( pParent, rResId ),
+ eLocation(eLoc),
+ pAcc(NULL)
+{
+ EnableRTL(FALSE);
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ Color aBgColor = rStyleSettings.GetWindowColor();
+
+ SetMapMode( MAP_TWIP );
+ SetPointer( POINTER_TEXT );
+ SetBackground( aBgColor );
+
+ Size aSize( GetOutputSize() );
+ aSize.Height() *= 4;
+
+ pEdEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), TRUE );
+ pEdEngine->SetPaperSize( aSize );
+ pEdEngine->SetRefDevice( this );
+
+ ScHeaderFieldData aData;
+ lcl_GetFieldData( aData );
+
+ // Feldbefehle:
+ pEdEngine->SetData( aData );
+ pEdEngine->SetControlWord( pEdEngine->GetControlWord() | EE_CNTRL_MARKFIELDS );
+ mbRTL = ScGlobal::IsSystemRTL();
+ if (mbRTL)
+ pEdEngine->SetDefaultHorizontalTextDirection(EE_HTEXTDIR_R2L);
+
+ pEdView = new EditView( pEdEngine, this );
+ pEdView->SetOutputArea( Rectangle( Point(0,0), GetOutputSize() ) );
+
+ pEdView->SetBackgroundColor( aBgColor );
+ pEdEngine->InsertView( pEdView );
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScEditWindow::~ScEditWindow()
+{
+ // delete Accessible object before deleting EditEngine and EditView
+ if (pAcc)
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTemp = xAcc;
+ if (xTemp.is())
+ pAcc->dispose();
+ }
+ delete pEdEngine;
+ delete pEdView;
+}
+
+// -----------------------------------------------------------------------
+
+void ScEditWindow::SetNumType(SvxNumType eNumType)
+{
+ pEdEngine->SetNumType(eNumType);
+ pEdEngine->UpdateFields();
+}
+
+// -----------------------------------------------------------------------
+
+EditTextObject* __EXPORT ScEditWindow::CreateTextObject()
+{
+ // wegen #38841# die Absatzattribute zuruecksetzen
+ // (GetAttribs beim Format-Dialog-Aufruf gibt immer gesetzte Items zurueck)
+
+ const SfxItemSet& rEmpty = pEdEngine->GetEmptyItemSet();
+ USHORT nParCnt = pEdEngine->GetParagraphCount();
+ for (USHORT i=0; i<nParCnt; i++)
+ pEdEngine->SetParaAttribs( i, rEmpty );
+
+ return pEdEngine->CreateTextObject();
+}
+
+// -----------------------------------------------------------------------
+
+void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
+{
+ SfxItemSet* pSet = new SfxItemSet( pEdEngine->GetEmptyItemSet() );
+ rPattern.FillEditItemSet( pSet );
+ // FillEditItemSet adjusts font height to 1/100th mm,
+ // but for header/footer twips is needed, as in the PatternAttr:
+ pSet->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
+ pSet->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
+ pSet->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+ if (mbRTL)
+ pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ pEdEngine->SetDefaults( pSet );
+}
+
+// -----------------------------------------------------------------------
+
+void ScEditWindow::SetText( const EditTextObject& rTextObject )
+{
+ pEdEngine->SetText( rTextObject );
+}
+
+// -----------------------------------------------------------------------
+
+void ScEditWindow::InsertField( const SvxFieldItem& rFld )
+{
+ pEdView->InsertField( rFld );
+}
+
+// -----------------------------------------------------------------------
+
+void ScEditWindow::SetCharAttriutes()
+{
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+
+ SfxViewShell* pViewSh = SfxViewShell::Current();
+
+ ScTabViewShell* pTabViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+
+
+ DBG_ASSERT( pDocSh, "Current DocShell not found" );
+ DBG_ASSERT( pViewSh, "Current ViewShell not found" );
+
+ if ( pDocSh && pViewSh )
+ {
+ if(pTabViewSh!=NULL) pTabViewSh->SetInFormatDialog(TRUE);
+
+ SfxItemSet aSet( pEdView->GetAttribs() );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( GetParent(), &aSet,
+ pDocSh,RID_SCDLG_CHAR );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetText( ScGlobal::GetRscString( STR_TEXTATTRS ) );
+ if ( pDlg->Execute() == RET_OK )
+ {
+ aSet.ClearItem();
+ aSet.Put( *pDlg->GetOutputItemSet() );
+ pEdView->SetAttribs( aSet );
+ }
+
+ if(pTabViewSh!=NULL) pTabViewSh->SetInFormatDialog(FALSE);
+ delete pDlg;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScEditWindow::Paint( const Rectangle& rRec )
+{
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ Color aBgColor = rStyleSettings.GetWindowColor();
+
+ pEdView->SetBackgroundColor( aBgColor );
+
+ SetBackground( aBgColor );
+
+ Control::Paint( rRec );
+
+ pEdView->Paint( rRec );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScEditWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ pEdView->MouseMove( rMEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScEditWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( !HasFocus() )
+ GrabFocus();
+
+ pEdView->MouseButtonDown( rMEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScEditWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ pEdView->MouseButtonUp( rMEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScEditWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ USHORT nKey = rKEvt.GetKeyCode().GetModifier()
+ + rKEvt.GetKeyCode().GetCode();
+
+ if ( nKey == KEY_TAB || nKey == KEY_TAB + KEY_SHIFT )
+ {
+ Control::KeyInput( rKEvt );
+ }
+ else if ( !pEdView->PostKeyEvent( rKEvt ) )
+ {
+ Control::KeyInput( rKEvt );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void ScEditWindow::Command( const CommandEvent& rCEvt )
+{
+ pEdView->Command( rCEvt );
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScEditWindow::GetFocus()
+{
+ pActiveEdWnd = this;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTemp = xAcc;
+ if (xTemp.is() && pAcc)
+ {
+ pAcc->GotFocus();
+ }
+ else
+ pAcc = NULL;
+}
+
+void __EXPORT ScEditWindow::LoseFocus()
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xTemp = xAcc;
+ if (xTemp.is() && pAcc)
+ {
+ pAcc->LostFocus();
+ }
+ else
+ pAcc = NULL;
+}
+
+// -----------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScEditWindow::CreateAccessible()
+{
+ String sName;
+ String sDescription(GetHelpText());
+ switch (eLocation)
+ {
+ case Left:
+ {
+ sName = String(ScResId(STR_ACC_LEFTAREA_NAME));
+// sDescription = String(ScResId(STR_ACC_LEFTAREA_DESCR));
+ }
+ break;
+ case Center:
+ {
+ sName = String(ScResId(STR_ACC_CENTERAREA_NAME));
+// sDescription = String(ScResId(STR_ACC_CENTERAREA_DESCR));
+ }
+ break;
+ case Right:
+ {
+ sName = String(ScResId(STR_ACC_RIGHTAREA_NAME));
+// sDescription = String(ScResId(STR_ACC_RIGHTAREA_DESCR));
+ }
+ break;
+ }
+ pAcc = new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), pEdView, this,
+ rtl::OUString(sName), rtl::OUString(sDescription), EditControl);
+ ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible = pAcc;
+ xAcc = xAccessible;
+ return pAcc;
+}
+
+/*
+class ScExtIButton : public ImageButton
+{
+private:
+
+ Timer aTimer;
+ ScPopupMenu* pPopupMenu;
+
+ DECL_LINK( TimerHdl, Timer*);
+
+ void DrawArrow();
+
+protected:
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt);
+
+ virtual void StartPopup();
+
+public:
+
+ ScExtIButton(Window* pParent, const ResId& rResId );
+
+ void SetPopupMenu(ScPopupMenu* pPopUp);
+
+ USHORT GetSelected();
+
+ void SetMenuHdl( const Link& rLink ) { aFxLink = rLink; }
+ const Link& GetMenuHdl() const { return aFxLink; }
+
+}
+*/
+ScExtIButton::ScExtIButton(Window* pParent, const ResId& rResId )
+: ImageButton(pParent,rResId),
+ pPopupMenu(NULL)
+{
+ nSelected=0;
+ aTimer.SetTimeout(600);
+ SetDropDown( TRUE);
+
+// DrawArrow();
+}
+
+void ScExtIButton::SetPopupMenu(ScPopupMenu* pPopUp)
+{
+ pPopupMenu=pPopUp;
+}
+
+USHORT ScExtIButton::GetSelected()
+{
+ return nSelected;
+}
+
+void ScExtIButton::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if(!aTimer.IsActive())
+ {
+ aTimer.Start();
+ aTimer.SetTimeoutHdl(LINK( this, ScExtIButton, TimerHdl));
+ }
+
+ ImageButton::MouseButtonDown(rMEvt );
+}
+void ScExtIButton::MouseButtonUp( const MouseEvent& rMEvt)
+{
+ aTimer.Stop();
+ aTimer.SetTimeoutHdl(Link());
+ ImageButton::MouseButtonUp(rMEvt );
+}
+
+void ScExtIButton::Click()
+{
+ aTimer.Stop();
+ aTimer.SetTimeoutHdl(Link());
+ ImageButton::Click();
+}
+
+void ScExtIButton::StartPopup()
+{
+ nSelected=0;
+
+ if(pPopupMenu!=NULL)
+ {
+ SetPressed( TRUE );
+ EndSelection();
+ Point aPoint(0,0);
+ aPoint.Y()=GetOutputSizePixel().Height();
+
+ nSelected=pPopupMenu->Execute( this, aPoint );
+
+ if(nSelected)
+ {
+ aMLink.Call(this);
+ }
+ SetPressed( FALSE);
+ }
+}
+
+long ScExtIButton::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nSwitch=rNEvt.GetType();
+ if(nSwitch==EVENT_MOUSEBUTTONUP)
+ {
+ MouseButtonUp(*rNEvt.GetMouseEvent());
+ }
+
+ return ImageButton::PreNotify(rNEvt );
+}
+
+IMPL_LINK( ScExtIButton, TimerHdl, Timer*, EMPTYARG )
+{
+ StartPopup();
+ return 0;
+}
+
+/*
+static void ImplDrawToolArrow( ToolBox* pBox, long nX, long nY, BOOL bBlack,
+ BOOL bLeft = FALSE, BOOL bTop = FALSE )
+{
+ Color aOldFillColor = pBox->GetFillColor();
+ WindowAlign eAlign = pBox->meAlign;
+ if ( bLeft )
+ eAlign = WINDOWALIGN_RIGHT;
+ else if ( bTop )
+ eAlign = WINDOWALIGN_BOTTOM;
+
+ switch ( eAlign )
+ {
+ case WINDOWALIGN_LEFT:
+ if ( bBlack )
+ pBox->SetFillColor( Color( COL_BLACK ) );
+ pBox->DrawRect( Rectangle( nX+0, nY+0, nX+0, nY+6 ) );
+ pBox->DrawRect( Rectangle( nX+1, nY+1, nX+1, nY+5 ) );
+ pBox->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
+ pBox->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+ if ( bBlack )
+ {
+ pBox->SetFillColor( aOldFillColor );
+ pBox->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
+ pBox->DrawRect( Rectangle( nX+2, nY+3, nX+2, nY+3 ) );
+ }
+ break;
+ case WINDOWALIGN_TOP:
+ if ( bBlack )
+ pBox->SetFillColor( Color( COL_BLACK ) );
+ pBox->DrawRect( Rectangle( nX+0, nY+0, nX+6, nY+0 ) );
+ pBox->DrawRect( Rectangle( nX+1, nY+1, nX+5, nY+1 ) );
+ pBox->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
+ pBox->DrawRect( Rectangle( nX+3, nY+3, nX+3, nY+3 ) );
+ if ( bBlack )
+ {
+ pBox->SetFillColor( aOldFillColor );
+ pBox->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
+ pBox->DrawRect( Rectangle( nX+3, nY+2, nX+3, nY+2 ) );
+ }
+ break;
+ case WINDOWALIGN_RIGHT:
+ if ( bBlack )
+ pBox->SetFillColor( Color( COL_BLACK ) );
+ pBox->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+6 ) );
+ pBox->DrawRect( Rectangle( nX+2, nY+1, nX+2, nY+5 ) );
+ pBox->DrawRect( Rectangle( nX+1, nY+2, nX+1, nY+4 ) );
+ pBox->DrawRect( Rectangle( nX+0, nY+3, nX+0, nY+3 ) );
+ if ( bBlack )
+ {
+ pBox->SetFillColor( aOldFillColor );
+ pBox->DrawRect( Rectangle( nX+2, nY+2, nX+2, nY+4 ) );
+ pBox->DrawRect( Rectangle( nX+1, nY+3, nX+1, nY+3 ) );
+ }
+ break;
+ case WINDOWALIGN_BOTTOM:
+ if ( bBlack )
+ pBox->SetFillColor( Color( COL_BLACK ) );
+ pBox->DrawRect( Rectangle( nX+0, nY+3, nX+6, nY+3 ) );
+ pBox->DrawRect( Rectangle( nX+1, nY+2, nX+5, nY+2 ) );
+ pBox->DrawRect( Rectangle( nX+2, nY+1, nX+4, nY+1 ) );
+ pBox->DrawRect( Rectangle( nX+3, nY+0, nX+3, nY+0 ) );
+ if ( bBlack )
+ {
+ pBox->SetFillColor( aOldFillColor );
+ pBox->DrawRect( Rectangle( nX+2, nY+2, nX+4, nY+2 ) );
+ pBox->DrawRect( Rectangle( nX+3, nY+1, nX+3, nY+1 ) );
+ }
+ break;
+ }
+}
+Down
+ - Timer starten
+
+Click
+ - Timer abbrechen
+
+Timer
+ if ( ??? )
+ {
+ - SetPressed( TRUE );
+ - EndSelection();
+ - Menu anzeigen
+ - SetPressed( FALSE );
+ }
+
+
+*/
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/pagedlg/tptable.cxx b/sc/source/ui/pagedlg/tptable.cxx
new file mode 100644
index 000000000000..2590601443cd
--- /dev/null
+++ b/sc/source/ui/pagedlg/tptable.cxx
@@ -0,0 +1,572 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+
+#include "tptable.hxx"
+#include "global.hxx"
+#include "attrib.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "pagedlg.hrc"
+
+// =======================================================================
+
+void EmptyNumericField::Modify()
+{
+ if( GetText().Len() )
+ NumericField::Modify();
+ else
+ SetEmptyFieldValue();
+}
+
+void EmptyNumericField::SetValue( sal_Int64 nValue )
+{
+ if( nValue == 0 )
+ SetEmptyFieldValue();
+ else
+ NumericField::SetValue( nValue );
+}
+
+sal_Int64 EmptyNumericField::GetValue() const
+{
+ return IsEmptyFieldValue() ? 0 : NumericField::GetValue();
+}
+
+// =======================================================================
+
+// STATIC DATA -----------------------------------------------------------
+
+static USHORT pPageTableRanges[] =
+{
+ ATTR_PAGE_NOTES, ATTR_PAGE_FIRSTPAGENO,
+ 0
+};
+
+BOOL lcl_PutVObjModeItem( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ const CheckBox& rBtn );
+
+BOOL lcl_PutScaleItem( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ const ListBox& rListBox,
+ USHORT nLBEntry,
+ const SpinField& rEd,
+ UINT16 nValue );
+
+BOOL lcl_PutScaleItem2( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ const ListBox& rListBox,
+ USHORT nLBEntry,
+ const NumericField& rEd1,
+ const NumericField& rEd2 );
+
+BOOL lcl_PutBoolItem( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ BOOL bIsChecked,
+ BOOL bSavedValue );
+
+//------------------------------------------------------------------------
+
+#define PAGENO_HDL LINK(this,ScTablePage,PageNoHdl)
+#define PAGEDIR_HDL LINK(this,ScTablePage,PageDirHdl)
+#define SCALE_HDL LINK(this,ScTablePage,ScaleHdl)
+
+#define WAS_DEFAULT(w,s) (SFX_ITEM_DEFAULT==(s).GetItemState((w),TRUE))
+#define GET_BOOL(sid,set) ((const SfxBoolItem&)((set).Get(GetWhich((sid))))).GetValue()
+#define GET_USHORT(sid,set) (USHORT)((const SfxUInt16Item&)((set).Get(GetWhich((sid))))).GetValue()
+#define GET_SHOW(sid,set) ( ScVObjMode( ((const ScViewObjectModeItem&)((set).Get(GetWhich((sid))))).GetValue() ) \
+ == VOBJ_MODE_SHOW )
+
+//========================================================================
+
+ScTablePage::ScTablePage( Window* pParent, const SfxItemSet& rCoreAttrs ) :
+
+ SfxTabPage( pParent, ScResId( RID_SCPAGE_TABLE ), rCoreAttrs ),
+
+ aFlPageDir ( this, ScResId( FL_PAGEDIR ) ),
+ aBtnTopDown ( this, ScResId( BTN_TOPDOWN ) ),
+ aBtnLeftRight ( this, ScResId( BTN_LEFTRIGHT ) ),
+ aBmpPageDir ( this, ScResId( BMP_PAGEDIR ) ),
+ aImgLeftRight ( ScResId( IMG_LEFTRIGHT ) ),
+ aImgTopDown ( ScResId( IMG_TOPDOWN ) ),
+ aImgLeftRightHC ( ScResId( IMG_LEFTRIGHT_H ) ),
+ aImgTopDownHC ( ScResId( IMG_TOPDOWN_H ) ),
+ aBtnPageNo ( this, ScResId( BTN_PAGENO ) ),
+ aEdPageNo ( this, ScResId( ED_PAGENO ) ),
+ aFlPrint ( this, ScResId( FL_PRINT ) ),
+ aBtnHeaders ( this, ScResId( BTN_HEADER ) ),
+ aBtnGrid ( this, ScResId( BTN_GRID ) ),
+ aBtnNotes ( this, ScResId( BTN_NOTES ) ),
+ aBtnObjects ( this, ScResId( BTN_OBJECTS ) ),
+ aBtnCharts ( this, ScResId( BTN_CHARTS ) ),
+ aBtnDrawings ( this, ScResId( BTN_DRAWINGS ) ),
+ aBtnFormulas ( this, ScResId( BTN_FORMULAS ) ),
+ aBtnNullVals ( this, ScResId( BTN_NULLVALS ) ),
+ aFlScale ( this, ScResId( FL_SCALE ) ),
+ aFtScaleMode ( this, ScResId( FT_SCALEMODE ) ),
+ aLbScaleMode ( this, ScResId( LB_SCALEMODE ) ),
+ aFtScaleAll ( this, ScResId( FT_SCALEFACTOR ) ),
+ aEdScaleAll ( this, ScResId( ED_SCALEALL ) ),
+ aFtScalePageWidth ( this, ScResId( FT_SCALEPAGEWIDTH ) ),
+ aEdScalePageWidth ( this, ScResId( ED_SCALEPAGEWIDTH ) ),
+ aFtScalePageHeight ( this, ScResId( FT_SCALEPAGEHEIGHT ) ),
+ aEdScalePageHeight ( this, ScResId( ED_SCALEPAGEHEIGHT ) ),
+ aFtScalePageNum ( this, ScResId( FT_SCALEPAGENUM ) ),
+ aEdScalePageNum ( this, ScResId( ED_SCALEPAGENUM ) )
+{
+ SetExchangeSupport();
+ aBtnPageNo.SetClickHdl( PAGENO_HDL );
+ aBtnTopDown.SetClickHdl( PAGEDIR_HDL );
+ aBtnLeftRight.SetClickHdl( PAGEDIR_HDL );
+ aLbScaleMode.SetSelectHdl( SCALE_HDL );
+
+ Size aBmpSize = Image( ScResId( IMG_LEFTRIGHT ) ).GetSizePixel();
+ aBmpPageDir.SetOutputSizePixel( aBmpSize );
+
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+void ScTablePage::ShowImage()
+{
+ bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode();
+ bool bLeftRight = aBtnLeftRight.IsChecked();
+ aBmpPageDir.SetImage( bHC ?
+ (bLeftRight ? aImgLeftRightHC : aImgTopDownHC) :
+ (bLeftRight ? aImgLeftRight : aImgTopDown) );
+}
+
+// -----------------------------------------------------------------------
+
+ScTablePage::~ScTablePage()
+{
+}
+
+//------------------------------------------------------------------------
+
+USHORT* ScTablePage::GetRanges()
+{
+ return pPageTableRanges;
+}
+
+// -----------------------------------------------------------------------
+
+SfxTabPage* ScTablePage::Create( Window* pParent, const SfxItemSet& rCoreSet )
+{
+ return ( new ScTablePage( pParent, rCoreSet ) );
+}
+
+// -----------------------------------------------------------------------
+
+void ScTablePage::Reset( const SfxItemSet& rCoreSet )
+{
+ BOOL bTopDown = GET_BOOL( SID_SCATTR_PAGE_TOPDOWN, rCoreSet );
+ USHORT nWhich = 0;
+
+ //-----------
+ // BOOL-Flags
+ //-----------
+ aBtnNotes .Check( GET_BOOL(SID_SCATTR_PAGE_NOTES,rCoreSet) );
+ aBtnGrid .Check( GET_BOOL(SID_SCATTR_PAGE_GRID,rCoreSet) );
+ aBtnHeaders .Check( GET_BOOL(SID_SCATTR_PAGE_HEADERS,rCoreSet) );
+ aBtnFormulas .Check( GET_BOOL(SID_SCATTR_PAGE_FORMULAS,rCoreSet) );
+ aBtnNullVals .Check( GET_BOOL(SID_SCATTR_PAGE_NULLVALS,rCoreSet) );
+ aBtnTopDown .Check( bTopDown );
+ aBtnLeftRight .Check( !bTopDown );
+
+ //------------------
+ // Erste Druckseite:
+ //------------------
+ USHORT nPage = GET_USHORT(SID_SCATTR_PAGE_FIRSTPAGENO,rCoreSet);
+ aBtnPageNo.Check( nPage != 0 );
+ aEdPageNo.SetValue( (nPage != 0) ? nPage : 1 );
+ PageNoHdl( NULL );
+
+ //-------------------
+ // Objektdarstellung:
+ //-------------------
+ aBtnCharts .Check( GET_SHOW( SID_SCATTR_PAGE_CHARTS, rCoreSet ) );
+ aBtnObjects .Check( GET_SHOW( SID_SCATTR_PAGE_OBJECTS, rCoreSet ) );
+ aBtnDrawings .Check( GET_SHOW( SID_SCATTR_PAGE_DRAWINGS, rCoreSet ) );
+
+ //------------
+ // Skalierung:
+ //------------
+
+ nWhich = GetWhich(SID_SCATTR_PAGE_SCALE);
+ if ( rCoreSet.GetItemState( nWhich, TRUE ) >= SFX_ITEM_AVAILABLE )
+ {
+ USHORT nScale = ((const SfxUInt16Item&)rCoreSet.Get(nWhich)).GetValue();
+ if( nScale > 0 )
+ aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_PERCENT );
+ aEdScaleAll.SetValue( (nScale > 0) ? nScale : 100 );
+ }
+
+ nWhich = GetWhich(SID_SCATTR_PAGE_SCALETO);
+ if ( rCoreSet.GetItemState( nWhich, TRUE ) >= SFX_ITEM_AVAILABLE )
+ {
+ const ScPageScaleToItem& rItem = static_cast< const ScPageScaleToItem& >( rCoreSet.Get( nWhich ) );
+ USHORT nWidth = rItem.GetWidth();
+ USHORT nHeight = rItem.GetHeight();
+
+ /* width==0 and height==0 is invalid state, used as "not selected".
+ Dialog shows width=height=1 then. */
+ bool bValid = nWidth || nHeight;
+ if( bValid )
+ aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_TO );
+ aEdScalePageWidth.SetValue( bValid ? nWidth : 1 );
+ aEdScalePageHeight.SetValue( bValid ? nHeight : 1 );
+ }
+
+ nWhich = GetWhich(SID_SCATTR_PAGE_SCALETOPAGES);
+ if ( rCoreSet.GetItemState( nWhich, TRUE ) >= SFX_ITEM_AVAILABLE )
+ {
+ USHORT nPages = ((const SfxUInt16Item&)rCoreSet.Get(nWhich)).GetValue();
+ if( nPages > 0 )
+ aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_TO_PAGES );
+ aEdScalePageNum.SetValue( (nPages > 0) ? nPages : 1 );
+ }
+
+ if( aLbScaleMode.GetSelectEntryCount() == 0 )
+ {
+ // fall back to 100%
+ DBG_ERRORFILE( "ScTablePage::Reset - missing scaling item" );
+ aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_PERCENT );
+ aEdScaleAll.SetValue( 100 );
+ }
+
+ PageDirHdl( NULL );
+ ScaleHdl( NULL );
+
+ // merken fuer FillItemSet
+ aBtnFormulas .SaveValue();
+ aBtnNullVals .SaveValue();
+ aBtnNotes .SaveValue();
+ aBtnGrid .SaveValue();
+ aBtnHeaders .SaveValue();
+ aBtnTopDown .SaveValue();
+ aBtnLeftRight .SaveValue();
+ aLbScaleMode .SaveValue();
+ aBtnCharts .SaveValue();
+ aBtnObjects .SaveValue();
+ aBtnDrawings .SaveValue();
+ aBtnPageNo .SaveValue();
+ aEdPageNo .SaveValue();
+ aEdScaleAll .SaveValue();
+ aEdScalePageWidth.SaveValue();
+ aEdScalePageHeight.SaveValue();
+ aEdScalePageNum .SaveValue();
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScTablePage::FillItemSet( SfxItemSet& rCoreSet )
+{
+ const SfxItemSet& rOldSet = GetItemSet();
+ USHORT nWhichPageNo = GetWhich(SID_SCATTR_PAGE_FIRSTPAGENO);
+ BOOL bDataChanged = FALSE;
+
+ //-----------
+ // BOOL-Flags
+ //-----------
+
+ bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_NOTES),
+ rCoreSet, rOldSet,
+ aBtnNotes.IsChecked(),
+ aBtnNotes.GetSavedValue() != STATE_NOCHECK );
+
+ bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_GRID),
+ rCoreSet, rOldSet,
+ aBtnGrid.IsChecked(),
+ aBtnGrid.GetSavedValue() != STATE_NOCHECK );
+
+ bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_HEADERS),
+ rCoreSet, rOldSet,
+ aBtnHeaders.IsChecked(),
+ aBtnHeaders.GetSavedValue() != STATE_NOCHECK );
+
+ bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_TOPDOWN),
+ rCoreSet, rOldSet,
+ aBtnTopDown.IsChecked(),
+ aBtnTopDown.GetSavedValue() );
+
+ bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_FORMULAS),
+ rCoreSet, rOldSet,
+ aBtnFormulas.IsChecked(),
+ aBtnFormulas.GetSavedValue() != STATE_NOCHECK );
+
+ bDataChanged |= lcl_PutBoolItem( GetWhich(SID_SCATTR_PAGE_NULLVALS),
+ rCoreSet, rOldSet,
+ aBtnNullVals.IsChecked(),
+ aBtnNullVals.GetSavedValue() != STATE_NOCHECK );
+
+ //------------------
+ // Erste Druckseite:
+ //------------------
+ BOOL bUseValue = aBtnPageNo.IsChecked();
+
+ if ( WAS_DEFAULT(nWhichPageNo,rOldSet)
+ && ( (!bUseValue && bUseValue == aBtnPageNo.GetSavedValue())
+ || ( bUseValue && bUseValue == aBtnPageNo.GetSavedValue()
+ && aEdPageNo.GetText() == aEdPageNo.GetSavedValue() ) ) )
+ {
+ rCoreSet.ClearItem( nWhichPageNo );
+ }
+ else
+ {
+ UINT16 nPage = (UINT16)( aBtnPageNo.IsChecked()
+ ? aEdPageNo.GetValue()
+ : 0 );
+
+ rCoreSet.Put( SfxUInt16Item( nWhichPageNo, nPage ) );
+ bDataChanged = TRUE;
+ }
+
+ //-------------------
+ // Objektdarstellung:
+ //-------------------
+
+ bDataChanged |= lcl_PutVObjModeItem( GetWhich(SID_SCATTR_PAGE_CHARTS),
+ rCoreSet, rOldSet, aBtnCharts );
+
+ bDataChanged |= lcl_PutVObjModeItem( GetWhich(SID_SCATTR_PAGE_OBJECTS),
+ rCoreSet, rOldSet, aBtnObjects );
+
+ bDataChanged |= lcl_PutVObjModeItem( GetWhich(SID_SCATTR_PAGE_DRAWINGS),
+ rCoreSet, rOldSet, aBtnDrawings );
+
+ //------------
+ // Skalierung:
+ //------------
+
+ if( !aEdScalePageWidth.GetValue() && !aEdScalePageHeight.GetValue() )
+ {
+ aLbScaleMode.SelectEntryPos( SC_TPTABLE_SCALE_PERCENT );
+ aEdScaleAll.SetValue( 100 );
+ }
+
+ bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALE),
+ rCoreSet, rOldSet,
+ aLbScaleMode, SC_TPTABLE_SCALE_PERCENT,
+ aEdScaleAll, (UINT16)aEdScaleAll.GetValue() );
+
+ bDataChanged |= lcl_PutScaleItem2( GetWhich(SID_SCATTR_PAGE_SCALETO),
+ rCoreSet, rOldSet,
+ aLbScaleMode, SC_TPTABLE_SCALE_TO,
+ aEdScalePageWidth, aEdScalePageHeight );
+
+ bDataChanged |= lcl_PutScaleItem( GetWhich(SID_SCATTR_PAGE_SCALETOPAGES),
+ rCoreSet, rOldSet,
+ aLbScaleMode, SC_TPTABLE_SCALE_TO_PAGES,
+ aEdScalePageNum, (UINT16)aEdScalePageNum.GetValue() );
+
+ return bDataChanged;
+}
+
+//------------------------------------------------------------------------
+
+int ScTablePage::DeactivatePage( SfxItemSet* pSetP )
+{
+ if ( pSetP )
+ FillItemSet( *pSetP );
+
+ return LEAVE_PAGE;
+}
+
+//------------------------------------------------------------------------
+
+void ScTablePage::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ShowImage();
+ SfxTabPage::DataChanged( rDCEvt );
+}
+
+//------------------------------------------------------------------------
+// Handler:
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScTablePage, PageDirHdl, RadioButton*, EMPTYARG )
+{
+ ShowImage();
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScTablePage, PageNoHdl, CheckBox*, pBtn )
+{
+ if ( aBtnPageNo.IsChecked() )
+ {
+ aEdPageNo.Enable();
+ if ( pBtn )
+ aEdPageNo.GrabFocus();
+ }
+ else
+ aEdPageNo.Disable();
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+IMPL_LINK( ScTablePage, ScaleHdl, ListBox*, EMPTYARG )
+{
+ // controls for "Reduce/enlarge"
+ bool bPercent = (aLbScaleMode.GetSelectEntryPos() == SC_TPTABLE_SCALE_PERCENT);
+ aFtScaleAll.Show( bPercent );
+ aEdScaleAll.Show( bPercent );
+
+ // controls for "Scale to width/height"
+ bool bScaleTo = (aLbScaleMode.GetSelectEntryPos() == SC_TPTABLE_SCALE_TO);
+ aFtScalePageWidth.Show( bScaleTo );
+ aEdScalePageWidth.Show( bScaleTo );
+ aFtScalePageHeight.Show( bScaleTo );
+ aEdScalePageHeight.Show( bScaleTo );
+
+ // controls for "Scale to pages"
+ bool bScalePages = (aLbScaleMode.GetSelectEntryPos() == SC_TPTABLE_SCALE_TO_PAGES);
+ aFtScalePageNum.Show( bScalePages );
+ aEdScalePageNum.Show( bScalePages );
+
+ return 0;
+}
+
+//========================================================================
+// Hilfsfunktionen fuer FillItemSet:
+//========================================================================
+
+BOOL lcl_PutBoolItem( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ BOOL bIsChecked,
+ BOOL bSavedValue )
+{
+ BOOL bDataChanged = ( bSavedValue == bIsChecked
+ && WAS_DEFAULT(nWhich,rOldSet) );
+
+ if ( bDataChanged )
+ rCoreSet.ClearItem(nWhich);
+ else
+ rCoreSet.Put( SfxBoolItem( nWhich, bIsChecked ) );
+
+ return bDataChanged;
+}
+
+//------------------------------------------------------------------------
+
+BOOL lcl_PutVObjModeItem( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ const CheckBox& rBtn )
+{
+ BOOL bIsChecked = rBtn.IsChecked();
+ BOOL bDataChanged = ( rBtn.GetSavedValue() == bIsChecked
+ && WAS_DEFAULT(nWhich,rOldSet) );
+
+ if ( bDataChanged )
+ rCoreSet.ClearItem( nWhich );
+
+ else
+ rCoreSet.Put( ScViewObjectModeItem( nWhich, bIsChecked
+ ? VOBJ_MODE_SHOW
+ : VOBJ_MODE_HIDE ) );
+ return bDataChanged;
+}
+
+//------------------------------------------------------------------------
+
+BOOL lcl_PutScaleItem( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ const ListBox& rListBox,
+ USHORT nLBEntry,
+ const SpinField& rEd,
+ UINT16 nValue )
+{
+ BOOL bIsSel = (rListBox.GetSelectEntryPos() == nLBEntry);
+ BOOL bDataChanged = (rListBox.GetSavedValue() != nLBEntry) ||
+ (rEd.GetSavedValue() != rEd.GetText()) ||
+ !WAS_DEFAULT( nWhich, rOldSet );
+
+ if( bDataChanged )
+ rCoreSet.Put( SfxUInt16Item( nWhich, bIsSel ? nValue : 0 ) );
+ else
+ rCoreSet.ClearItem( nWhich );
+
+ return bDataChanged;
+}
+
+
+BOOL lcl_PutScaleItem2( USHORT nWhich,
+ SfxItemSet& rCoreSet,
+ const SfxItemSet& rOldSet,
+ const ListBox& rListBox,
+ USHORT nLBEntry,
+ const NumericField& rEd1,
+ const NumericField& rEd2 )
+{
+ UINT16 nValue1 = (UINT16)rEd1.GetValue();
+ UINT16 nValue2 = (UINT16)rEd2.GetValue();
+ BOOL bIsSel = (rListBox.GetSelectEntryPos() == nLBEntry);
+ BOOL bDataChanged = (rListBox.GetSavedValue() != nLBEntry) ||
+ (rEd1.GetSavedValue() != rEd1.GetText()) ||
+ (rEd2.GetSavedValue() != rEd2.GetText()) ||
+ !WAS_DEFAULT( nWhich, rOldSet );
+
+ if( bDataChanged )
+ {
+ ScPageScaleToItem aItem;
+ if( bIsSel )
+ aItem.Set( nValue1, nValue2 );
+ rCoreSet.Put( aItem );
+ }
+ else
+ rCoreSet.ClearItem( nWhich );
+
+ return bDataChanged;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/attrdlg.src b/sc/source/ui/src/attrdlg.src
new file mode 100644
index 000000000000..14a53e12f123
--- /dev/null
+++ b/sc/source/ui/src/attrdlg.src
@@ -0,0 +1,203 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <svx/dialogs.hrc>
+#include "attrdlg.hrc"
+
+ //================================================
+ // Attributdialog:
+
+TabDialog RID_SCDLG_ATTR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 280 , 165 ) ;
+ Text [ en-US ] = "Format Cells" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 23 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_NUMBER ;
+ PageResID = 256 ;
+ Text [ en-US ] = "Numbers" ;
+ };
+ PageItem
+ {
+ Identifier = TP_FONT ;
+ PageResID = 257 ;
+ Text [ en-US ] = "Font" ;
+ };
+ PageItem
+ {
+ Identifier = TP_FONTEFF ;
+ PageResID = 262 ;
+ Text [ en-US ] = "Font Effects";
+ };
+ PageItem
+ {
+ Identifier = TP_ALIGNMENT ;
+ PageResID = 258 ;
+ Text [ en-US ] = "Alignment" ;
+ };
+ PageItem
+ {
+ Identifier = TP_ASIAN ;
+ PageResID = 263 ;
+ Text [ en-US ] = "Asian Typography";
+ };
+ PageItem
+ {
+ Identifier = TP_BORDER ;
+ PageResID = 259 ;
+ Text [ en-US ] = "Borders" ;
+ };
+ PageItem
+ {
+ Identifier = TP_BACKGROUND ;
+ PageResID = 260 ;
+ Text [ en-US ] = "Background" ;
+ };
+ PageItem
+ {
+ Identifier = TP_PROTECTION ;
+ PageResID = 261 ;
+ Text [ en-US ] = "Cell Protection" ;
+ };
+ };
+ };
+};
+
+ //================================================
+ // Zellschutz-TabPage:
+
+TabPage RID_SCPAGE_PROTECTION
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_SCPAGE_PROTECTION ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ TriStateBox BTN_PROTECTED
+ {
+ Pos = MAP_APPFONT ( 22 , 28 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "~Protected" ;
+ TabStop = TRUE ;
+ };
+ TriStateBox BTN_HIDE_FORMULAR
+ {
+ Pos = MAP_APPFONT ( 22 , 42 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "Hide ~formula" ;
+ TabStop = TRUE ;
+ };
+ TriStateBox BTN_HIDE_ALL
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "Hide ~all" ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_HINT
+ {
+ Pos = MAP_APPFONT ( 114 , 14 ) ;
+ Size = MAP_APPFONT ( 137 , 56 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Cell protection is only effective after the current sheet has been protected. \n\nSelect 'Protect Document' from the 'Tools' menu, and specify 'Sheet'." ;
+ };
+ FixedLine FL_PROTECTION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Protection" ;
+ };
+ TriStateBox BTN_HIDE_PRINT
+ {
+ Pos = MAP_APPFONT ( 12 , 87 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "Hide ~when printing" ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_HINT2
+ {
+ Pos = MAP_APPFONT ( 114 , 87 ) ;
+ Size = MAP_APPFONT ( 137 , 24 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "The cells selected will be omitted when printing." ;
+ };
+ FixedLine FL_PRINT
+ {
+ Pos = MAP_APPFONT ( 6 , 76 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Print" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/autofmt.src b/sc/source/ui/src/autofmt.src
new file mode 100644
index 000000000000..7f0c156a1f9a
--- /dev/null
+++ b/sc/source/ui/src/autofmt.src
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "miscdlgs.hrc"
+
+ModalDialog RID_SCDLG_AUTOFORMAT
+{
+ OutputSize = TRUE ;
+ HelpId = SID_AUTOFORMAT ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 312 , 121 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? AutoFormat : Autoformat */
+ /* ### ACHTUNG: Neuer Text in Resource? AutoFormat : Autoformat */
+ Text [ en-US ] = "AutoFormat" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ ListBox LB_FORMAT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 70 , 101 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FORMAT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 244 , 8 ) ;
+ Text [ en-US ] = "F~ormat" ;
+ };
+ Window WND_PREVIEW
+ {
+ Pos = MAP_APPFONT ( 88 , 14 ) ;
+ Size = MAP_APPFONT ( 159 , 101 ) ;
+ Border = TRUE ;
+ };
+ CheckBox BTN_ADJUST
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 172 , 146 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Breite/Höhe anpassen : ~Breite/H÷he anpassen */
+ Text [ en-US ] = "A~utoFit width and height" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_BORDER
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 146 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "~Borders" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_FONT
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 132 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "F~ont" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_PATTERN
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 93 , 146 ) ;
+ Size = MAP_APPFONT ( 73 , 10 ) ;
+ Text [ en-US ] = "~Pattern" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_ALIGNMENT
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 172 , 132 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "Alignmen~t" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_NUMFORMAT
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 132 ) ;
+ Size = MAP_APPFONT ( 75 , 10 ) ;
+ Text [ en-US ] = "~Number format" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FORMATTING
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 121 ) ;
+ Size = MAP_APPFONT ( 244 , 8 ) ;
+ Text [ en-US ] = "Formatting" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 256 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 256 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 256 , 101 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 48 ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 256 , 63 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Einfügen... : ~Einf³gen... */
+ Text [ en-US ] = "~Add..." ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 256 , 81 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen : ~L÷schen */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+
+ PushButton BTN_RENAME
+ {
+ Pos = MAP_APPFONT ( 256 , 123 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ HelpId=HID_SC_RENAME_AUTOFMT;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Rename" ;
+ };
+
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 256 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_ADD_TITLE
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? AutoFormat hinzufügen : Autoformat hinzufügen */
+ /* ### ACHTUNG: Neuer Text in Resource? AutoFormat hinzufügen : Autoformat hinzufügen */
+ /* ### ACHTUNG: Neuer Text in Resource? AutoFormat hinzufügen : AutoFormat hinzuf³gen */
+ Text [ en-US ] = "Add AutoFormat" ;
+ };
+
+ String STR_RENAME_TITLE
+ {
+ Text [ en-US ] = "Rename AutoFormat" ;
+ };
+
+ String STR_ADD_LABEL
+ {
+ Text [ en-US ] = "Name" ;
+ };
+ String STR_DEL_TITLE
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? AutoFormat löschen : AutoFormat l÷schen */
+ Text [ en-US ] = "Delete AutoFormat" ;
+ };
+ String STR_DEL_MSG
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Wollen Sie das AutoFormat # wirklich löschen? : Wollen Sie das AutoFormat # wirklich l÷schen? */
+ Text [ en-US ] = "Do you really want to delete the # AutoFomat?" ;
+ };
+ String STR_BTN_CLOSE
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Schlie~ßen : Schlie~˜en */
+ Text [ en-US ] = "~Close" ;
+ };
+ String STR_JAN
+ {
+ Text [ en-US ] = "Jan" ;
+ };
+ String STR_FEB
+ {
+ Text [ en-US ] = "Feb" ;
+ };
+ String STR_MAR
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Mär : Mõr */
+ Text [ en-US ] = "Mar" ;
+ };
+ String STR_NORTH
+ {
+ Text [ en-US ] = "North" ;
+ };
+ String STR_MID
+ {
+ Text [ en-US ] = "Mid" ;
+ };
+ String STR_SOUTH
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Süd : S³d */
+ Text [ en-US ] = "South" ;
+ };
+ String STR_SUM
+ {
+ Text [ en-US ] = "Total" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/condfrmt.src b/sc/source/ui/src/condfrmt.src
new file mode 100644
index 000000000000..18b08117cfe6
--- /dev/null
+++ b/sc/source/ui/src/condfrmt.src
@@ -0,0 +1,398 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "condfrmt.hrc"
+ModelessDialog RID_SCDLG_CONDFORMAT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 316 , 161 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ HelpId = HID_SCDLG_CONDFORMAT ;
+ Hide = TRUE ;
+ CheckBox CBX_COND1
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition ~1" ;
+ };
+ ListBox LB_COND1_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 48 , 40 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Cell value is" ; Default ; > ;
+ < "Formula is" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND1_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 19 ) ;
+ Size = MAP_APPFONT ( 62 , 88 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "equal to" ; Default ; > ;
+ < "less than" ; Default ; > ;
+ < "greater than" ; Default ; > ;
+ < "less than or equal to" ; Default ; > ;
+ < "greater than or equal to" ; Default ; > ;
+ < "not equal to" ; Default ; > ;
+ < "between" ; Default ; > ;
+ < "not between" ; Default ; > ;
+ };
+ };
+ Edit EDT_COND1_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 19 ) ;
+ Size = MAP_APPFONT ( 41 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COND1_1
+ {
+ Pos = MAP_APPFONT ( 167 , 18 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COND1_AND
+ {
+ Pos = MAP_APPFONT ( 181 , 21 ) ;
+ Size = MAP_APPFONT ( 16 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "and" ;
+ };
+ Edit EDT_COND1_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 199 , 19 ) ;
+ Size = MAP_APPFONT ( 41 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COND1_2
+ {
+ Pos = MAP_APPFONT ( 242 , 18 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COND1_TEMPLATE
+ {
+ Pos = MAP_APPFONT ( 6 , 37 ) ;
+ Size = MAP_APPFONT ( 46 , 8 ) ;
+ Right = TRUE ;
+ Text [ en-US ] = "~Cell Style" ;
+ };
+ ListBox LB_COND1_TEMPLATE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 35 ) ;
+ Size = MAP_APPFONT ( 62 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+ PushButton BTN_COND1_NEW
+ {
+ Pos = MAP_APPFONT ( 124 , 34 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~New Style..." ;
+ };
+ FixedLine FL_SEP1
+ {
+ Pos = MAP_APPFONT ( 6 , 51 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ CheckBox CBX_COND2
+ {
+ Pos = MAP_APPFONT ( 6 , 60 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition ~2" ;
+ };
+ ListBox LB_COND2_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 73 ) ;
+ Size = MAP_APPFONT ( 48 , 40 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Cell value is" ; Default ; > ;
+ < "Formula is" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND2_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 73 ) ;
+ Size = MAP_APPFONT ( 62 , 88 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "equal to" ; Default ; > ;
+ < "less than" ; Default ; > ;
+ < "greater than" ; Default ; > ;
+ < "less than or equal to" ; Default ; > ;
+ < "greater than or equal to" ; Default ; > ;
+ < "not equal to" ; Default ; > ;
+ < "between" ; Default ; > ;
+ < "not between" ; Default ; > ;
+ };
+ };
+ Edit EDT_COND2_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 73 ) ;
+ Size = MAP_APPFONT ( 41 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COND2_1
+ {
+ Pos = MAP_APPFONT ( 167 , 72 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COND2_AND
+ {
+ Pos = MAP_APPFONT ( 181 , 75 ) ;
+ Size = MAP_APPFONT ( 16 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "and" ;
+ };
+ Edit EDT_COND2_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 199 , 73 ) ;
+ Size = MAP_APPFONT ( 41 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COND2_2
+ {
+ Pos = MAP_APPFONT ( 242 , 72 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COND2_TEMPLATE
+ {
+ Pos = MAP_APPFONT ( 6 , 91 ) ;
+ Size = MAP_APPFONT ( 46 , 8 ) ;
+ Right = TRUE ;
+ Text [ en-US ] = "C~ell Style" ;
+ };
+ ListBox LB_COND2_TEMPLATE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 89 ) ;
+ Size = MAP_APPFONT ( 62 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+ PushButton BTN_COND2_NEW
+ {
+ Pos = MAP_APPFONT ( 124 , 88 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Ne~w Style..." ;
+ };
+ FixedLine FL_SEP2
+ {
+ Pos = MAP_APPFONT ( 6 , 105 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ CheckBox CBX_COND3
+ {
+ Pos = MAP_APPFONT ( 6 , 114 ) ;
+ Size = MAP_APPFONT ( 248 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Condition ~3" ;
+ };
+ ListBox LB_COND3_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 127 ) ;
+ Size = MAP_APPFONT ( 48 , 40 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Cell value is" ; Default ; > ;
+ < "Formula is" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND3_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 127 ) ;
+ Size = MAP_APPFONT ( 62 , 88 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "equal to" ; Default ; > ;
+ < "less than" ; Default ; > ;
+ < "greater than" ; Default ; > ;
+ < "less than or equal to" ; Default ; > ;
+ < "greater than or equal to" ; Default ; > ;
+ < "not equal to" ; Default ; > ;
+ < "between" ; Default ; > ;
+ < "not between" ; Default ; > ;
+ };
+ };
+ Edit EDT_COND3_1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 124 , 127 ) ;
+ Size = MAP_APPFONT ( 41 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COND3_1
+ {
+ Pos = MAP_APPFONT ( 167 , 126 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COND3_AND
+ {
+ Pos = MAP_APPFONT ( 181 , 129 ) ;
+ Size = MAP_APPFONT ( 16 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "and" ;
+ };
+ Edit EDT_COND3_2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 199 , 127 ) ;
+ Size = MAP_APPFONT ( 41 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COND3_2
+ {
+ Pos = MAP_APPFONT ( 242 , 126 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COND3_TEMPLATE
+ {
+ Pos = MAP_APPFONT ( 6 , 145 ) ;
+ Size = MAP_APPFONT ( 46 , 8 ) ;
+ Right = TRUE ;
+ Text [ en-US ] = "Ce~ll Style" ;
+ };
+ ListBox LB_COND3_TEMPLATE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 143 ) ;
+ Size = MAP_APPFONT ( 62 , 80 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+ PushButton BTN_COND3_NEW
+ {
+ Pos = MAP_APPFONT ( 124 , 142 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "New ~Style..." ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 260 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 260 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 260 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Conditional Formatting" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/crnrdlg.src b/sc/source/ui/src/crnrdlg.src
new file mode 100644
index 000000000000..f4811bd63cb8
--- /dev/null
+++ b/sc/source/ui/src/crnrdlg.src
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "crnrdlg.hrc"
+ModelessDialog RID_SCDLG_COLROWNAMERANGES
+{
+ OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 256 , 181 ) ;
+ HelpId = HID_COLROWNAMERANGES ;
+ Moveable = TRUE ;
+ // Closeable = TRUE; // Dieser Dialog hat einen Cancel-Button !
+ FixedLine FL_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 188 , 8 ) ;
+ Text [ en-US ] = "Range" ;
+ };
+ ListBox LB_RANGE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 179 , 85 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ Border = TRUE ;
+ };
+ Edit ED_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 105 ) ;
+ Size = MAP_APPFONT ( 165 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_AREA
+ {
+ Pos = MAP_APPFONT ( 179 , 104 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ RadioButton BTN_COLHEAD
+ {
+ Pos = MAP_APPFONT ( 20 , 121 ) ;
+ Size = MAP_APPFONT ( 171 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Contains ~column labels" ;
+ };
+ RadioButton BTN_ROWHEAD
+ {
+ Pos = MAP_APPFONT ( 20 , 135 ) ;
+ Size = MAP_APPFONT ( 171 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Contains ~row labels" ;
+ };
+ FixedText FT_DATA_LABEL
+ {
+ Pos = MAP_APPFONT ( 12 , 151 ) ;
+ Size = MAP_APPFONT ( 179 , 8 ) ;
+ Text [ en-US ] = "For ~data range" ;
+ };
+ Edit ED_DATA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 162 ) ;
+ Size = MAP_APPFONT ( 165 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_DATA
+ {
+ Pos = MAP_APPFONT ( 179 , 161 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 200 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 200 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 200 , 104 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Add" ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 200 , 122 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 200 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Define Label Range" ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/datafdlg.src b/sc/source/ui/src/datafdlg.src
new file mode 100644
index 000000000000..1cb3578f4546
--- /dev/null
+++ b/sc/source/ui/src/datafdlg.src
@@ -0,0 +1,99 @@
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Amelia Wang <amwang@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "datafdlg.hrc"
+
+//zhangyun, dataform
+ModalDialog RID_SCDLG_DATAFORM
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 191 , 180 ) ;
+ Text [ en-US ] = "Data Form" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ FixedText LAB_DATAFORM_RECORDNO
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ Text [ en-US ] = "/" ;
+ };
+ PushButton BTN_DATAFORM_NEW
+ {
+ Pos = MAP_APPFONT ( 135 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "New" ;
+ };
+ PushButton BTN_DATAFORM_DELETE
+ {
+ Pos = MAP_APPFONT ( 135 , 40 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Delete" ;
+ };
+ PushButton BTN_DATAFORM_RESTORE
+ {
+ Pos = MAP_APPFONT ( 135 , 57 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Restore" ;
+ };
+ PushButton BTN_DATAFORM_LAST
+ {
+ Pos = MAP_APPFONT ( 135 , 82 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Last Record" ;
+ };
+ PushButton BTN_DATAFORM_NEXT
+ {
+ Pos = MAP_APPFONT ( 135 , 99 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Next Record" ;
+ };
+ PushButton BTN_DATAFORM_CLOSE
+ {
+ Pos = MAP_APPFONT ( 135 , 116 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Close" ;
+ };
+ ScrollBar WND_DATAFORM_SCROLLBAR
+ {
+ Pos = MAP_APPFONT ( 124 , 6 ) ;
+ Size = MAP_APPFONT ( 8 , 135 ) ;
+ HScroll = FALSE ;
+ TabStop = FALSE ;
+ };
+ String STR_NEW_RECORD
+ {
+ Text [ en-US ] = "New Record" ;
+ };
+};
+//end
diff --git a/sc/source/ui/src/dbnamdlg.src b/sc/source/ui/src/dbnamdlg.src
new file mode 100644
index 000000000000..c5ff35bc42d6
--- /dev/null
+++ b/sc/source/ui/src/dbnamdlg.src
@@ -0,0 +1,198 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "dbnamdlg.hrc"
+ModelessDialog RID_SCDLG_DBNAMES
+{
+ OutputSize = TRUE ;
+ HelpId = SID_DEFINE_DBNAME ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 222 , 142 ) ;
+ Text [ en-US ] = "Define Database Range" ;
+ Moveable = TRUE ;
+ // Closeable = TRUE; // Dieser Dialog hat einen Cancel-Button !
+ FixedLine FL_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "Na~me" ;
+ };
+ ComboBox ED_NAME
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 145 , 92 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ };
+ FixedLine FL_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 6 , 112 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "~Range" ;
+ };
+ Edit ED_DBAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 123 ) ;
+ Size = MAP_APPFONT ( 131 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_DBAREA
+ {
+ Pos = MAP_APPFONT ( 145 , 122 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 142 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ CheckBox BTN_HEADER
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 153 ) ;
+ Size = MAP_APPFONT ( 145 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Co~ntains column labels" ;
+ };
+ CheckBox BTN_SIZE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 167 ) ;
+ Size = MAP_APPFONT ( 145 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Insert or delete ~cells" ;
+ };
+ CheckBox BTN_FORMAT
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 181 ) ;
+ Size = MAP_APPFONT ( 145 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Keep ~formatting" ;
+ };
+ CheckBox BTN_STRIPDATA
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 195 ) ;
+ Size = MAP_APPFONT ( 145 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Don't save ~imported data" ;
+ };
+ FixedText FT_SOURCE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 209 ) ;
+ Size = MAP_APPFONT ( 145 , 8 ) ;
+ Text [ en-US ] = "Source:" ;
+ };
+ FixedText FT_OPERATIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 221 ) ;
+ Size = MAP_APPFONT ( 145 , 8 ) ;
+ Text [ en-US ] = "Operations:" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 166 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 166 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 166 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Add" ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 166 , 92 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 166 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 166 , 122 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 93 ;
+ };
+ String STR_ADD
+ {
+ Text [ en-US ] = "~Add" ;
+ };
+ String STR_MODIFY
+ {
+ Text [ en-US ] = "M~odify" ;
+ };
+ String STR_DB_INVALID
+ {
+ Text [ en-US ] = "Invalid range" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/filter.src b/sc/source/ui/src/filter.src
new file mode 100644
index 000000000000..a1338638682a
--- /dev/null
+++ b/sc/source/ui/src/filter.src
@@ -0,0 +1,820 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "filter.hrc"
+ModelessDialog RID_SCDLG_FILTER
+{
+ OutputSize = TRUE ;
+ HelpId = SID_FILTER ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 279 , 121 ) ;
+ Text [ en-US ] = "Standard Filter" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_OP
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 44 , 8 ) ;
+ Text [ en-US ] = "Operator" ;
+ };
+ FixedText FT_FIELD
+ {
+ Pos = MAP_APPFONT ( 58 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Field name" ;
+ };
+ FixedText FT_COND
+ {
+ Pos = MAP_APPFONT ( 122 , 14 ) ;
+ Size = MAP_APPFONT ( 47 , 8 ) ;
+ Text [ en-US ] = "Condition" ;
+ };
+ FixedText FT_VAL
+ {
+ Pos = MAP_APPFONT ( 201 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Value" ;
+ };
+ ListBox LB_OP1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 25 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_OP2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 41 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_OP3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 57 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_OP4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 73 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_FIELD1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_FIELD2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_FIELD3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_FIELD4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 73 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_COND1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 25 ) ;
+ Size = MAP_APPFONT ( 75 , 145 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ stringlist [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ < "Largest" ; Default ; > ;
+ < "Smallest" ; Default ; > ;
+ < "Largest %" ; Default ; > ;
+ < "Smallest %" ; Default ; > ;
+ < "Contains" ; Default ; > ;
+ < "Does not contain" ; Default ; > ;
+ < "Begins with" ; Default ; > ;
+ < "Does not begin with" ; Default ; > ;
+ < "Ends with" ; Default ; > ;
+ < "Does not end with" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 41 ) ;
+ Size = MAP_APPFONT ( 75 , 145 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ stringlist [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ < "Largest" ; Default ; > ;
+ < "Smallest" ; Default ; > ;
+ < "Largest %" ; Default ; > ;
+ < "Smallest %" ; Default ; > ;
+ < "Contains" ; Default ; > ;
+ < "Does not contain" ; Default ; > ;
+ < "Begins with" ; Default ; > ;
+ < "Does not begin with" ; Default ; > ;
+ < "Ends with" ; Default ; > ;
+ < "Does not end with" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 57 ) ;
+ Size = MAP_APPFONT ( 75 , 145 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ stringlist [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ < "Largest" ; Default ; > ;
+ < "Smallest" ; Default ; > ;
+ < "Largest %" ; Default ; > ;
+ < "Smallest %" ; Default ; > ;
+ < "Contains" ; Default ; > ;
+ < "Does not contain" ; Default ; > ;
+ < "Begins with" ; Default ; > ;
+ < "Does not begin with" ; Default ; > ;
+ < "Ends with" ; Default ; > ;
+ < "Does not end with" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 73 ) ;
+ Size = MAP_APPFONT ( 75 , 145 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ stringlist [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ < "Largest" ; Default ; > ;
+ < "Smallest" ; Default ; > ;
+ < "Largest %" ; Default ; > ;
+ < "Smallest %" ; Default ; > ;
+ < "Contains" ; Default ; > ;
+ < "Does not contain" ; Default ; > ;
+ < "Begins with" ; Default ; > ;
+ < "Does not begin with" ; Default ; > ;
+ < "Ends with" ; Default ; > ;
+ < "Does not end with" ; Default ; > ;
+ };
+ };
+ ComboBox ED_VAL1
+ {
+ Pos = MAP_APPFONT ( 201 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ComboBox ED_VAL2
+ {
+ Pos = MAP_APPFONT ( 201 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ComboBox ED_VAL3
+ {
+ Pos = MAP_APPFONT ( 201 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ComboBox ED_VAL4
+ {
+ Pos = MAP_APPFONT ( 201 , 73 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ScrollBar LB_SCROLL
+ {
+ Pos = MAP_APPFONT ( 265, 25 ) ;
+ Size = MAP_APPFONT ( 8 , 60 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ };
+
+ FixedLine FL_CRITERIA
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 267 , 8 ) ;
+ Text [ en-US ] = "Filter criteria";
+ };
+ CheckBox BTN_CASE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 130 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Case ~sensitive" ;
+ };
+ CheckBox BTN_REGEXP
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 130 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Regular ~expression" ;
+ };
+ CheckBox BTN_HEADER
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 144 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Range contains ~column labels" ;
+ };
+ CheckBox BTN_UNIQUE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 144 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~No duplication" ;
+ };
+ CheckBox BTN_COPY_RESULT
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 158 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Copy ~results to..." ;
+ };
+ CheckBox BTN_DEST_PERS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 158 ) ;
+ Size = MAP_APPFONT ( 94 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Keep filter criteria" ;
+ };
+ ListBox LB_COPY_AREA
+ {
+ Border = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 21 , 170 ) ;
+ Size = MAP_APPFONT ( 110 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ Edit ED_COPY_AREA
+ {
+ Border = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 136 , 170 ) ;
+ Size = MAP_APPFONT ( 110 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COPY_AREA
+ {
+ Pos = MAP_APPFONT ( 248 , 169 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 118 ) ;
+ Size = MAP_APPFONT ( 267 , 8 ) ;
+ };
+ FixedText FT_DBAREA
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 66 , 188 ) ;
+ Size = MAP_APPFONT ( 167 , 8 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "dummy" ;
+ };
+ FixedText FT_DBAREA_LABEL
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 188 ) ;
+ Size = MAP_APPFONT ( 58 , 8 ) ;
+ Text [ en-US ] = "Data range:" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 169 , 101 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 223 , 101 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 62 , 101 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 6 , 101 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 81 ;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 0 , 91 ) ;
+ Size = MAP_APPFONT ( 279 , 6 ) ;
+ };
+};
+ //============================================================================
+ModelessDialog RID_SCDLG_SPEC_FILTER
+{
+ OutputSize = TRUE ;
+ HelpId = SID_SPECIAL_FILTER ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 278 , 83 ) ;
+ Text [ en-US ] = "Advanced Filter" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_CRITERIA_AREA
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 210 , 8 ) ;
+ Text [ en-US ] = "Read ~filter criteria from" ;
+ };
+ ListBox LB_CRITERIA_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 90 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ Edit ED_CRITERIA_AREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 14 ) ;
+ Size = MAP_APPFONT ( 99 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_CRITERIA_AREA
+ {
+ Pos = MAP_APPFONT ( 201 , 13 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ CheckBox BTN_CASE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 43 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Case sensitive" ;
+ };
+ CheckBox BTN_REGEXP
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 43 ) ;
+ Size = MAP_APPFONT ( 74 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Regular ~expressions" ;
+ };
+ CheckBox BTN_HEADER
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 57 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Range c~ontains column labels" ;
+ };
+ CheckBox BTN_UNIQUE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 57 ) ;
+ Size = MAP_APPFONT ( 74 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~No duplication" ;
+ };
+ CheckBox BTN_COPY_RESULT
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 71 ) ;
+ Size = MAP_APPFONT ( 128 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Co~py results to" ;
+ };
+ CheckBox BTN_DEST_PERS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 142 , 71 ) ;
+ Size = MAP_APPFONT ( 74 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Keep filter criteria" ;
+ };
+ ListBox LB_COPY_AREA
+ {
+ Border = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 83 ) ;
+ Size = MAP_APPFONT ( 76 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ Edit ED_COPY_AREA
+ {
+ Border = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 100 , 83 ) ;
+ Size = MAP_APPFONT ( 99 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_COPY_AREA
+ {
+ Pos = MAP_APPFONT ( 201 , 82 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 210 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ FixedText FT_DBAREA
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 101 ) ;
+ Size = MAP_APPFONT ( 155 , 8 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "dummy" ;
+ };
+ FixedText FT_DBAREA_LABEL
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 101 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Data range:" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 222 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 222 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 222 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 223 , 63 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 32 ;
+ };
+};
+ //============================================================================
+ModalDialog RID_SCDLG_PIVOTFILTER
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_PIVOTFILTER ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 298 , 83 ) ;
+ Text [ en-US ] = "Filter" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_OP
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 40 , 8 ) ;
+ Text [ en-US ] = "Operator" ;
+ };
+ FixedText FT_FIELD
+ {
+ Pos = MAP_APPFONT ( 58 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Field name" ;
+ };
+ FixedText FT_COND
+ {
+ Pos = MAP_APPFONT ( 122 , 14 ) ;
+ Size = MAP_APPFONT ( 47 , 8 ) ;
+ Text [ en-US ] = "Condition" ;
+ };
+ FixedText FT_VAL
+ {
+ Pos = MAP_APPFONT ( 173 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Value" ;
+ };
+ ListBox LB_OP1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 41 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_OP2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 57 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "AND" ; Default ; > ;
+ < "OR" ; Default ; > ;
+ };
+ };
+ ListBox LB_FIELD1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_FIELD2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_FIELD3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 58 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox LB_COND1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 25 ) ;
+ Size = MAP_APPFONT ( 47 , 65 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 41 ) ;
+ Size = MAP_APPFONT ( 47 , 65 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ };
+ };
+ ListBox LB_COND3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 122 , 57 ) ;
+ Size = MAP_APPFONT ( 47 , 65 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "=" ; Default ; > ;
+ < "<" ; Default ; > ;
+ < ">" ; Default ; > ;
+ < "<=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "<>" ; Default ; > ;
+ };
+ };
+ ComboBox ED_VAL1
+ {
+ Pos = MAP_APPFONT ( 173 , 25 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ComboBox ED_VAL2
+ {
+ Pos = MAP_APPFONT ( 173 , 41 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ComboBox ED_VAL3
+ {
+ Pos = MAP_APPFONT ( 173 , 57 ) ;
+ Size = MAP_APPFONT ( 60 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedLine FL_CRITERIA
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 230 , 8 ) ;
+ Text [ en-US ] = "Filter criteria";
+ };
+ CheckBox BTN_CASE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 86 ) ;
+ Size = MAP_APPFONT ( 221 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Case sensitive" ;
+ };
+ CheckBox BTN_REGEXP
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 221 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Regular expression" ;
+ };
+ CheckBox BTN_UNIQUE
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 114 ) ;
+ Size = MAP_APPFONT ( 221 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~No duplication" ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 75 ) ;
+ Size = MAP_APPFONT ( 230 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ FixedText FT_DBAREA
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 130 ) ;
+ Size = MAP_APPFONT ( 166 , 8 ) ;
+ Left = TRUE ;
+ Text [ en-US ] = "dummy" ;
+ };
+ FixedText FT_DBAREA_LABEL
+ {
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 130 ) ;
+ Size = MAP_APPFONT ( 58 , 8 ) ;
+ Text [ en-US ] = "Data range:" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 242 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 242 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 242 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 242 , 63 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 61 ;
+ };
+};
+
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
new file mode 100644
index 000000000000..a3fd6d5b7116
--- /dev/null
+++ b/sc/source/ui/src/globstr.src
@@ -0,0 +1,1829 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "globstr.hrc"
+#include "sc.hrc"
+
+
+
+Resource RID_GLOBSTR
+{
+ String STR_UNDO_INSERTCELLS
+ {
+ Text [ en-US ] = "Insert" ;
+ };
+ String STR_UNDO_DELETECELLS
+ {
+ Text [ en-US ] = "Delete" ;
+ };
+ String STR_UNDO_CUT
+ {
+ Text [ en-US ] = "Cut" ;
+ };
+ String STR_UNDO_PASTE
+ {
+ Text [ en-US ] = "Insert" ;
+ };
+ String STR_UNDO_DRAGDROP
+ {
+ Text [ en-US ] = "Drag and Drop" ;
+ };
+ String STR_UNDO_MOVE
+ {
+ Text [ en-US ] = "Move" ;
+ };
+ String STR_UNDO_COPY
+ {
+ Text [ en-US ] = "Copy" ;
+ };
+ String STR_UNDO_DELETECONTENTS
+ {
+ Text [ en-US ] = "Delete" ;
+ };
+ String STR_UNDO_SELATTR
+ {
+ Text [ en-US ] = "Attributes" ;
+ };
+ String STR_UNDO_SELATTRLINES
+ {
+ Text [ en-US ] = "Attributes/Lines" ;
+ };
+ String STR_UNDO_COLWIDTH
+ {
+ Text [ en-US ] = "Column Width" ;
+ };
+ String STR_UNDO_OPTCOLWIDTH
+ {
+ Text [ en-US ] = "Optimal Column Width" ;
+ };
+ String STR_UNDO_ROWHEIGHT
+ {
+ Text [ en-US ] = "Row height" ;
+ };
+ String STR_UNDO_OPTROWHEIGHT
+ {
+ Text [ en-US ] = "Optimal Row Height" ;
+ };
+ String STR_UNDO_AUTOFILL
+ {
+ Text [ en-US ] = "Fill" ;
+ };
+ String STR_UNDO_MERGE
+ {
+ Text [ en-US ] = "Merge" ;
+ };
+ String STR_UNDO_REMERGE
+ {
+ Text [ en-US ] = "Split" ;
+ };
+ String STR_UNDO_AUTOFORMAT
+ {
+ Text [ en-US ] = "AutoFormat" ;
+ };
+ String STR_UNDO_REPLACE
+ {
+ Text [ en-US ] = "Replace" ;
+ };
+ String STR_UNDO_CURSORATTR
+ {
+ Text [ en-US ] = "Attributes" ;
+ };
+ String STR_UNDO_ENTERDATA
+ {
+ Text [ en-US ] = "Input" ;
+ };
+ String STR_UNDO_INSCOLBREAK
+ {
+ Text [ en-US ] = "Insert Column Break" ;
+ };
+ String STR_UNDO_DELCOLBREAK
+ {
+ Text [ en-US ] = "Delete column break" ;
+ };
+ String STR_UNDO_INSROWBREAK
+ {
+ Text [ en-US ] = "Insert Row Break" ;
+ };
+ String STR_UNDO_DELROWBREAK
+ {
+ Text [ en-US ] = "Delete row break" ;
+ };
+ String STR_UNDO_DOOUTLINE
+ {
+ Text [ en-US ] = "View Details" ;
+ };
+ String STR_UNDO_REDOOUTLINE
+ {
+ Text [ en-US ] = "Hide details" ;
+ };
+ String STR_UNDO_MAKEOUTLINE
+ {
+ Text [ en-US ] = "Group" ;
+ };
+ String STR_UNDO_REMAKEOUTLINE
+ {
+ Text [ en-US ] = "Ungroup" ;
+ };
+ String STR_UNDO_OUTLINELEVEL
+ {
+ Text [ en-US ] = "Select outline level" ;
+ };
+ String STR_UNDO_DOOUTLINEBLK
+ {
+ Text [ en-US ] = "View Details" ;
+ };
+ String STR_UNDO_REDOOUTLINEBLK
+ {
+ Text [ en-US ] = "Hide details" ;
+ };
+ String STR_UNDO_REMOVEALLOTLNS
+ {
+ Text [ en-US ] = "Clear Outline" ;
+ };
+ String STR_UNDO_AUTOOUTLINE
+ {
+ Text [ en-US ] = "AutoOutline" ;
+ };
+ String STR_UNDO_SUBTOTALS
+ {
+ Text [ en-US ] = "Subtotals" ;
+ };
+ String STR_UNDO_SORT
+ {
+ Text [ en-US ] = "Sort" ;
+ };
+ String STR_UNDO_QUERY
+ {
+ Text [ en-US ] = "Filter" ;
+ };
+ String STR_UNDO_DBDATA
+ {
+ Text [ en-US ] = "Change Database Range" ;
+ };
+ String STR_UNDO_IMPORTDATA
+ {
+ Text [ en-US ] = "Importing" ;
+ };
+ String STR_UNDO_REPEATDB
+ {
+ Text [ en-US ] = "Refresh range" ;
+ };
+ String STR_UNDO_GRAFEDIT
+ {
+ Text [ en-US ] = "Edit graphics" ;
+ };
+ String STR_UNDO_LISTNAMES
+ {
+ Text [ en-US ] = "List names" ;
+ };
+ String STR_UNDO_PIVOT_NEW
+ {
+ Text [ en-US ] = "Create DataPilot Table" ;
+ };
+ String STR_UNDO_PIVOT_MODIFY
+ {
+ Text [ en-US ] = "Edit DataPilot Table" ;
+ };
+ String STR_UNDO_PIVOT_DELETE
+ {
+ Text [ en-US ] = "Delete DataPilot Table" ;
+ };
+ String STR_UNDO_CONSOLIDATE
+ {
+ Text [ en-US ] = "Consolidate" ;
+ };
+ String STR_UNDO_USESCENARIO
+ {
+ Text [ en-US ] = "Use scenario" ;
+ };
+ String STR_UNDO_MAKESCENARIO
+ {
+ Text [ en-US ] = "Create scenario" ;
+ };
+ String STR_UNDO_EDITSCENARIO
+ {
+ Text [ en-US ] = "Edit scenario" ;
+ };
+ String STR_UNDO_APPLYCELLSTYLE
+ {
+ Text [ en-US ] = "Apply Cell Style" ;
+ };
+ String STR_UNDO_EDITCELLSTYLE
+ {
+ Text [ en-US ] = "Edit Cell Style";
+ };
+ String STR_UNDO_APPLYPAGESTYLE
+ {
+ Text [ en-US ] = "Apply Page Style";
+ };
+ String STR_UNDO_EDITPAGESTYLE
+ {
+ Text [ en-US ] = "Edit Page Style";
+ };
+ String STR_UNDO_DETADDPRED
+ {
+ Text [ en-US ] = "Trace Precedents" ;
+ };
+ String STR_UNDO_DETDELPRED
+ {
+ Text [ en-US ] = "Remove Precedent" ;
+ };
+ String STR_UNDO_DETADDSUCC
+ {
+ Text [ en-US ] = "Trace Dependents" ;
+ };
+ String STR_UNDO_DETDELSUCC
+ {
+ Text [ en-US ] = "Remove Dependent" ;
+ };
+ String STR_UNDO_DETADDERROR
+ {
+ Text [ en-US ] = "Trace Error" ;
+ };
+ String STR_UNDO_DETDELALL
+ {
+ Text [ en-US ] = "Remove all Traces" ;
+ };
+ String STR_UNDO_DETINVALID
+ {
+ Text [ en-US ] = "Mark invalid data" ;
+ };
+ String STR_UNDO_DETREFRESH
+ {
+ Text [ en-US ] = "Refresh Traces" ;
+ };
+ String STR_UNDO_CHARTDATA
+ {
+ Text [ en-US ] = "Modify chart data range" ;
+ };
+ String STR_UNDO_ORIGINALSIZE
+ {
+ Text [ en-US ] = "Original Size" ;
+ };
+ String STR_UNDO_UPDATELINK
+ {
+ Text [ en-US ] = "Update Link" ;
+ };
+ String STR_UNDO_REMOVELINK
+ {
+ Text [ en-US ] = "Unlink" ;
+ };
+ String STR_UNDO_INSERTAREALINK
+ {
+ Text [ en-US ] = "Insert Link" ;
+ };
+ String STR_UNDO_ENTERMATRIX
+ {
+ Text [ en-US ] = "Insert Array Formula" ;
+ };
+ String STR_UNDO_INSERTNOTE
+ {
+ Text [ en-US ] = "Insert Comment" ;
+ };
+ String STR_UNDO_DELETENOTE
+ {
+ Text [ en-US ] = "Delete Comment" ;
+ };
+ String STR_UNDO_SHOWNOTE
+ {
+ Text [ en-US ] = "Show Comment" ;
+ };
+ String STR_UNDO_HIDENOTE
+ {
+ Text [ en-US ] = "Hide Comment" ;
+ };
+ String STR_UNDO_EDITNOTE
+ {
+ Text [ en-US ] = "Edit Comment" ;
+ };
+ String STR_UNDO_DEC_INDENT
+ {
+ Text [ en-US ] = "Decrease Indent" ;
+ };
+ String STR_UNDO_INC_INDENT
+ {
+ Text [ en-US ] = "Increase Indent" ;
+ };
+ String STR_UNDO_PROTECT_TAB
+ {
+ Text [ en-US ] = "Protect sheet" ;
+ };
+ String STR_UNDO_UNPROTECT_TAB
+ {
+ Text [ en-US ] = "Unprotect sheet" ;
+ };
+ String STR_UNDO_PROTECT_DOC
+ {
+ Text [ en-US ] = "Protect document" ;
+ };
+ String STR_UNDO_UNPROTECT_DOC
+ {
+ Text [ en-US ] = "Unprotect document" ;
+ };
+ String STR_UNDO_PRINTRANGES
+ {
+ Text [ en-US ] = "Print range" ;
+ };
+ String STR_UNDO_REMOVEBREAKS
+ {
+ Text [ en-US ] = "Delete Page Breaks" ;
+ };
+ String STR_UNDO_PRINTSCALE
+ {
+ Text [ en-US ] = "Change Scale" ;
+ };
+ String STR_UNDO_DRAG_BREAK
+ {
+ Text [ en-US ] = "Move Page Break" ;
+ };
+ String STR_UNDO_RANGENAMES
+ {
+ Text [ en-US ] = "Edit range names" ;
+ };
+ String STR_UNDO_TRANSLITERATE
+ {
+ Text [ en-US ] = "Case/Characters";
+ };
+ String STR_DB_NONAME
+ {
+ Text [ en-US ] = "unnamed" ;
+ };
+ String STR_DBNAME_IMPORT
+ {
+ Text [ en-US ] = "Import" ;
+ };
+ String STR_MSSG_DOSUBTOTALS_0
+ {
+ Text [ en-US ] = "%PRODUCTNAME Calc" ;
+ };
+ String STR_MSSG_DOSUBTOTALS_1
+ {
+ Text [ en-US ] = "Delete data?" ;
+ };
+ String STR_MSSG_DOSUBTOTALS_2
+ {
+ Text [ en-US ] = "Unable to insert rows" ;
+ };
+ String STR_MSSG_REPEATDB_0
+ {
+ Text [ en-US ] = "No operations to execute" ;
+ };
+ String STR_MSSG_MAKEAUTOFILTER_0
+ {
+ Text [ en-US ] = "The range does not contain column headers.\nDo you want the first line to be used as column header?" ;
+ };
+ String STR_MSSG_IMPORTDATA_0
+ {
+ Text [ en-US ] = "Error while importing data!" ;
+ };
+ String STR_DATABASE_NOTFOUND
+ {
+ Text [ en-US ] = "The database '#' could not be opened." ;
+ };
+ String STR_QUERY_NOTFOUND
+ {
+ Text [ en-US ] = "The query '#' could not be opened." ;
+ };
+ String STR_DATABASE_ABORTED
+ {
+ Text [ en-US ] = "Database import terminated." ;
+ };
+ String STR_PROGRESS_IMPORT
+ {
+ Text [ en-US ] = "# records imported..." ;
+ };
+ String STR_MSSG_MAKEOUTLINE_0
+ {
+ Text [ en-US ] = "Grouping not possible" ;
+ };
+ String STR_MSSG_REMOVEOUTLINE_0
+ {
+ Text [ en-US ] = "Ungrouping not possible" ;
+ };
+ String STR_MSSG_PASTEFROMCLIP_0
+ {
+ Text [ en-US ] = "Insert into multiple selection not possible" ;
+ };
+ String STR_MSSG_PASTEFROMCLIP_1
+ {
+ Text [ en-US ] = "Cell merge not possible if cells already merged!" ;
+ };
+ String STR_MSSG_MOVEBLOCKTO_0
+ {
+ Text [ en-US ] = "Cell merge not possible if cells already merged!" ;
+ };
+ String STR_MSSG_INSERTCELLS_0
+ {
+ Text [ en-US ] = "Inserting into merged ranges not possible" ;
+ };
+ String STR_MSSG_DELETECELLS_0
+ {
+ Text [ en-US ] = "Deleting in merged ranges not possible" ;
+ };
+ String STR_MSSG_MERGECELLS_0
+ {
+ Text [ en-US ] = "Cell merge not possible if cells already merged" ;
+ };
+ String STR_SORT_ERR_MERGED
+ {
+ Text [ en-US ] = "Ranges containing merged cells can only be sorted without formats." ;
+ };
+ String STR_MSSG_SEARCHANDREPLACE_0
+ {
+ Text [ en-US ] = "Search key not found." ;
+ };
+ String STR_MSSG_SOLVE_0
+ {
+ Text [ en-US ] = "Goal Seek successful.\n" ;
+ };
+ String STR_MSSG_SOLVE_1
+ {
+ Text [ en-US ] = "Insert result (" ;
+ };
+ String STR_MSSG_SOLVE_2
+ {
+ Text [ en-US ] = ") into current cell?" ;
+ };
+ String STR_MSSG_SOLVE_3
+ {
+ Text [ en-US ] = "Goal Seek not successful.\n" ;
+ };
+ String STR_MSSG_SOLVE_4
+ {
+ Text [ en-US ] = "No exact value found. \n" ;
+ };
+ String STR_MSSG_SOLVE_5
+ {
+ Text [ en-US ] = "Insert closest value (" ;
+ };
+ String STR_MSSG_SOLVE_6
+ {
+ Text [ en-US ] = ")?" ;
+ };
+ String STR_TABLE_GESAMTERGEBNIS
+ {
+ Text [ en-US ] = "Grand Total" ;
+ };
+ String STR_TABLE_ERGEBNIS
+ {
+ Text [ en-US ] = "Result" ;
+ };
+ String STR_UNDO_SPELLING
+ {
+ Text [ en-US ] = "Spellcheck" ;
+ };
+ String STR_TABLE_UND
+ {
+ Text [ en-US ] = "AND" ;
+ };
+ String STR_TABLE_ODER
+ {
+ Text [ en-US ] = "OR" ;
+ };
+ String STR_TABLE_DEF
+ {
+ Text [ en-US ] = "Sheet" ;
+ };
+ String STR_MOVE_TO_END
+ {
+ Text [ en-US ] = "- move to end position -" ;
+ };
+ String STR_BOX_YNI
+ {
+ Text [ en-US ] = "Not implemented in this build." ;
+ };
+ String STR_NO_REF_TABLE
+ {
+ Text [ en-US ] = "#REF!" ;
+ };
+ String STR_PIVOT_INVALID_DBAREA
+ {
+ Text [ en-US ] = "The data range must contain at least one row." ;
+ };
+ String STR_PIVOT_NODATA
+ {
+ Text [ en-US ] = "The DataPilot table must contain at least one entry." ;
+ };
+ String STR_PIVOT_MOVENOTALLOWED
+ {
+ Text [ en-US ] = "The data range can not be deleted." ;
+ };
+ String STR_PIVOT_ERROR
+ {
+ Text [ en-US ] = "Error creating the Data Pilot Table." ;
+ };
+ String STR_PIVOT_OVERLAP
+ {
+ Text [ en-US ] = "DataPilot tables can not overlap." ;
+ };
+ String STR_PIVOT_NOTEMPTY
+ {
+ Text [ en-US ] = "The destination range is not empty. Overwrite existing contents?" ;
+ };
+ String STR_DATAPILOT_SUBTOTAL
+ {
+ Text [ en-US ] = "The source range contains subtotals which may distort the results. Use it anyway?";
+ };
+ String STR_PIVOT_PROGRESS
+ {
+ Text [ en-US ] = "Create DataPilot Table" ;
+ };
+ String STR_PIVOT_TOTAL
+ {
+ Text [ en-US ] = "Total" ;
+ };
+ String STR_PIVOT_DATA
+ {
+ Text [ en-US ] = "Data" ;
+ };
+ String STR_PIVOTFUNC_SUM
+ {
+ Text [ en-US ] = "SUM" ;
+ };
+ String STR_PIVOTFUNC_COUNT
+ {
+ Text [ en-US ] = "COUNT" ;
+ };
+ String STR_PIVOTFUNC_AVG
+ {
+ Text [ en-US ] = "AVERAGE" ;
+ };
+ String STR_PIVOTFUNC_MAX
+ {
+ Text [ en-US ] = "MAX" ;
+ };
+ String STR_PIVOTFUNC_MIN
+ {
+ Text [ en-US ] = "MIN" ;
+ };
+ String STR_PIVOTFUNC_PROD
+ {
+ Text [ en-US ] = "PRODUCT" ;
+ };
+ String STR_PIVOTFUNC_COUNT2
+ {
+ Text [ en-US ] = "COUNTA" ;
+ };
+ String STR_PIVOTFUNC_STDDEV
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String STR_PIVOTFUNC_STDDEV2
+ {
+ Text [ en-US ] = "STDEVP" ;
+ };
+ String STR_PIVOTFUNC_VAR
+ {
+ Text [ en-US ] = "VAR" ;
+ };
+ String STR_PIVOTFUNC_VAR2
+ {
+ Text [ en-US ] = "VARP" ;
+ };
+ String STR_TABLE
+ {
+ Text [ en-US ] = "Sheet" ;
+ };
+ String STR_COLUMN
+ {
+ Text [ en-US ] = "Column" ;
+ };
+ String STR_ROW
+ {
+ Text [ en-US ] = "Row" ;
+ };
+ String STR_PAGE
+ {
+ Text [ en-US ] = "Page" ;
+ };
+ String STR_PGNUM
+ {
+ Text [ en-US ] = "Page %1" ;
+ };
+ String STR_LOAD_DOC
+ {
+ Text [ en-US ] = "Load document" ;
+ };
+ String STR_SAVE_DOC
+ {
+ Text [ en-US ] = "Save document" ;
+ };
+ String STR_ERR_INVALID_TABREF
+ {
+ Text [ en-US ] = "<unknown table reference>" ;
+ };
+ String STR_AREA_ALREADY_INSERTED
+ {
+ Text [ en-US ] = "This range has already been inserted." ;
+ };
+ String STR_INVALID_TABREF
+ {
+ Text [ en-US ] = "Invalid sheet reference." ;
+ };
+ String STR_INVALID_QUERYAREA
+ {
+ Text [ en-US ] = "This range does not contain a valid query." ;
+ };
+ String STR_REIMPORT_EMPTY
+ {
+ Text [ en-US ] = "This range does not contain imported data." ;
+ };
+ String STR_NOMULTISELECT
+ {
+ Text [ en-US ] = "This function cannot be used with multiple selections." ;
+ };
+ String STR_FILL_SERIES_PROGRESS
+ {
+ Text [ en-US ] = "Fill Row..." ;
+ };
+ String STR_UNKNOWN_FILTER
+ {
+ Text [ en-US ] = "Unknown filter: " ;
+ };
+ String STR_UNDO_THESAURUS
+ {
+ Text [ en-US ] = "Thesaurus" ;
+ };
+ String STR_FILL_TAB
+ {
+ Text [ en-US ] = "Fill Sheets" ;
+ };
+ String STR_UPDATE_SCENARIO
+ {
+ Text [ en-US ] = "Add selected ranges to current scenario?" ;
+ };
+ String STR_ERR_NEWSCENARIO
+ {
+ Text [ en-US ] = "The scenario ranges must be selected in order to be able to create a new scenario." ;
+ };
+ String STR_NOAREASELECTED
+ {
+ Text [ en-US ] = "A range has not been selected." ;
+ };
+ String STR_NEWTABNAMENOTUNIQUE
+ {
+ Text [ en-US ] = "This name already exists." ;
+ };
+ String STR_INVALIDTABNAME
+ {
+ Text [ en-US ] = "Invalid sheet name." ;
+ };
+ String STR_SCENARIO
+ {
+ Text [ en-US ] = "Scenario" ;
+ };
+ String STR_PIVOT_TABLE
+ {
+ Text [ en-US ] = "DataPilot" ;
+ };
+ // Text strings for captions of subtotal functions.
+ String STR_FUN_TEXT_SUM
+ {
+ Text [ en-US ] = "Sum" ;
+ };
+ String STR_FUN_TEXT_COUNT
+ {
+ Text [ en-US ] = "Count" ;
+ };
+ String STR_FUN_TEXT_COUNT2
+ {
+ Text [ en-US ] = "CountA" ;
+ };
+ String STR_FUN_TEXT_AVG
+ {
+ Text [ en-US ] = "Average" ;
+ };
+ String STR_FUN_TEXT_MAX
+ {
+ Text [ en-US ] = "Max" ;
+ };
+ String STR_FUN_TEXT_MIN
+ {
+ Text [ en-US ] = "Min" ;
+ };
+ String STR_FUN_TEXT_PRODUCT
+ {
+ Text [ en-US ] = "Product" ;
+ };
+ String STR_FUN_TEXT_STDDEV
+ {
+ Text [ en-US ] = "StDev" ;
+ };
+ String STR_FUN_TEXT_VAR
+ {
+ Text [ en-US ] = "Var" ;
+ };
+ String STR_NOCHARTATCURSOR
+ {
+ Text [ en-US ] = "No chart found at this position." ;
+ };
+ String STR_PIVOT_NOTFOUND
+ {
+ Text [ en-US ] = "No DataPilot table found at this position." ;
+ };
+ String STR_EMPTYDATA
+ {
+ Text [ en-US ] = "(empty)" ;
+ };
+ String STR_PRINT_INVALID_AREA
+ {
+ Text [ en-US ] = "Invalid print range" ;
+ };
+ String STR_PAGESTYLE
+ {
+ Text [ en-US ] = "Page Style" ;
+ };
+ String STR_HEADER
+ {
+ Text [ en-US ] = "Header" ;
+ };
+ String STR_FOOTER
+ {
+ Text [ en-US ] = "Footer" ;
+ };
+ String STR_TEXTATTRS
+ {
+ Text [ en-US ] = "Text Attributes" ;
+ };
+ String STR_HFCMD_DELIMITER
+ {
+ Text [ en-US ] = "\\" ;
+ };
+ String STR_HFCMD_PAGE
+ {
+ Text [ en-US ] = "PAGE" ;
+ };
+ String STR_HFCMD_PAGES
+ {
+ Text [ en-US ] = "PAGES" ;
+ };
+ String STR_HFCMD_DATE
+ {
+ Text [ en-US ] = "DATE" ;
+ };
+ String STR_HFCMD_TIME
+ {
+ Text [ en-US ] = "TIME" ;
+ };
+ String STR_HFCMD_FILE
+ {
+ Text [ en-US ] = "FILE" ;
+ };
+ String STR_HFCMD_TABLE
+ {
+ Text [ en-US ] = "SHEET" ;
+ };
+ String STR_PROTECTIONERR
+ {
+ Text [ en-US ] = "Protected cells can not be modified." ;
+ };
+ String STR_READONLYERR
+ {
+ Text [ en-US ] = "Document opened in read-only mode.";
+ };
+ String STR_MATRIXFRAGMENTERR
+ {
+ Text [ en-US ] = "You cannot change only part of an array." ;
+ };
+ String STR_PAGEHEADER
+ {
+ Text [ en-US ] = "Header" ;
+ };
+ String STR_PAGEFOOTER
+ {
+ Text [ en-US ] = "Footer" ;
+ };
+
+ /* BEGIN error constants and error strings. */
+
+ String STR_ERROR_STR
+ {
+ Text [ en-US ] = "Err:" ;
+ };
+ /* BEGIN defined ERROR.TYPE() values. */
+ /* ERROR.TYPE( #NULL! ) == 1 */
+ String STR_LONG_ERR_NULL
+ {
+ Text [ en-US ] = "Error: Ranges do not intersect" ;
+ };
+ /* ERROR.TYPE( #DIV/0! ) == 2 */
+ String STR_LONG_ERR_DIV_ZERO
+ {
+ Text [ en-US ] = "Error: Division by zero" ;
+ };
+ /* ERROR.TYPE( #VALUE! ) == 3 */
+ String STR_LONG_ERR_NO_VALUE
+ {
+ Text [ en-US ] = "Error: Wrong data type" ;
+ };
+ /* ERROR.TYPE( #REF! ) == 4 */
+ String STR_LONG_ERR_NO_REF
+ {
+ Text [ en-US ] = "Error: Not a valid reference" ;
+ };
+ /* ERROR.TYPE( #NAME! ) == 5 */
+ String STR_LONG_ERR_NO_NAME
+ {
+ Text [ en-US ] = "Error: Invalid name" ;
+ };
+ /* ERROR.TYPE( #NUM! ) == 6 */
+ String STR_LONG_ERR_ILL_FPO
+ {
+ Text [ en-US ] = "Error: Invalid numeric value" ;
+ };
+ /* ERROR.TYPE( #N/A ) == 7 */
+ String STR_LONG_ERR_NV
+ {
+ Text [ en-US ] = "Error: Value not available" ;
+ };
+ /* END defined ERROR.TYPE() values. */
+ String STR_NO_ADDIN
+ {
+ Text [ en-US ] = "#ADDIN?" ;
+ };
+ String STR_LONG_ERR_NO_ADDIN
+ {
+ Text [ en-US ] = "Error: Add-in not found" ;
+ };
+ String STR_NO_MACRO
+ {
+ Text [ en-US ] = "#MACRO?" ;
+ };
+ String STR_LONG_ERR_NO_MACRO
+ {
+ Text [ en-US ] = "Error: Macro not found" ;
+ };
+ String STR_LONG_ERR_SYNTAX
+ {
+ Text [ en-US ] = "Internal syntactical error" ;
+ };
+ String STR_LONG_ERR_ILL_ARG
+ {
+ Text [ en-US ] = "Error: Invalid argument" ;
+ };
+ String STR_LONG_ERR_ILL_PAR
+ {
+ Text [ en-US ] = "Error in parameter list" ;
+ };
+ String STR_LONG_ERR_ILL_CHAR
+ {
+ Text [ en-US ] = "Error: Invalid character" ;
+ };
+ String STR_LONG_ERR_ILL_SEP
+ {
+ Text [ en-US ] = "Error: Invalid semicolon" ;
+ };
+ String STR_LONG_ERR_PAIR
+ {
+ Text [ en-US ] = "Error: in bracketing" ;
+ };
+ String STR_LONG_ERR_OP_EXP
+ {
+ Text [ en-US ] = "Error: Operator missing" ;
+ };
+ String STR_LONG_ERR_VAR_EXP
+ {
+ Text [ en-US ] = "Error: Variable missing" ;
+ };
+ String STR_LONG_ERR_CODE_OVF
+ {
+ Text [ en-US ] = "Error: Formula overflow" ;
+ };
+ String STR_LONG_ERR_STR_OVF
+ {
+ Text [ en-US ] = "Error: String overflow" ;
+ };
+ String STR_LONG_ERR_STACK_OVF
+ {
+ Text [ en-US ] = "Error: Internal overflow" ;
+ };
+ String STR_LONG_ERR_CIRC_REF
+ {
+ Text [ en-US ] = "Error: Circular reference" ;
+ };
+ String STR_LONG_ERR_NO_CONV
+ {
+ Text [ en-US ] = "Error: Calculation does not converge" ;
+ };
+
+ /* END error constants and error strings. */
+
+ String STR_GRIDCOLOR
+ {
+ Text [ en-US ] = "Grid color" ;
+ };
+ String STR_MERGE_NOTEMPTY
+ {
+ Text [ en-US ] = "Should the contents of the hidden cells be moved into the first cell?" ;
+ };
+ String STR_CELL_FILTER
+ {
+ Text [ en-US ] = "Filter" ;
+ };
+ String STR_TARGETNOTFOUND
+ {
+ Text [ en-US ] = "The target database range does not exist." ;
+ };
+ String STR_INVALID_EPS
+ {
+ Text [ en-US ] = "Invalid increment" ;
+ };
+ String STR_TABLE_OP
+ {
+ Text [ en-US ] = "MULTIPLE.OPERATIONS" ;
+ };
+ String STR_UNDO_TABOP
+ {
+ Text [ en-US ] = "Multiple operations" ;
+ };
+ String STR_INVALID_AFNAME
+ {
+ Text [ en-US ] = "You have entered an invalid name.\nAutoFormat could not be created. \nTry again using a different name." ;
+ };
+ String STR_AREA
+ {
+ Text [ en-US ] = "Range" ;
+ };
+ String STR_YES
+ {
+ Text [ en-US ] = "Yes" ;
+ };
+ String STR_NO
+ {
+ Text [ en-US ] = "No" ;
+ };
+ String STR_PROTECTION
+ {
+ Text [ en-US ] = "Protection" ;
+ };
+ String STR_FORMULAS
+ {
+ Text [ en-US ] = "Formulas" ;
+ };
+ String STR_HIDE
+ {
+ Text [ en-US ] = "Hide" ;
+ };
+ String STR_PRINT
+ {
+ Text [ en-US ] = "Print" ;
+ };
+ String STR_INVALID_AFAREA
+ {
+ Text [ en-US ] = "To apply an AutoFormat,\na table range of at least\n3x3 cells must be selected." ;
+ };
+ String STR_CASCADE
+ {
+ Text [ en-US ] = "(nested)" ;
+ };
+ String STR_OPTIONAL
+ {
+ Text [ en-US ] = "(optional)" ;
+ };
+ String STR_REQUIRED
+ {
+ Text [ en-US ] = "(required)" ;
+ };
+ String STR_INVALID
+ {
+ Text [ en-US ] = "invalid" ;
+ };
+ String STR_EDITFUNCTION
+ {
+ Text [ en-US ] = "Edit Function" ;
+ };
+ String STR_NOTES
+ {
+ Text [ en-US ] = "Comments" ;
+ };
+ String STR_QUERY_DELTAB
+ {
+ Text [ en-US ] = "Are you sure you want to delete the selected sheet(s)?" ;
+ };
+ String STR_QUERY_DELSCENARIO
+ {
+ Text [ en-US ] = "Are you sure you want to delete the selected scenario?" ;
+ };
+ String STR_EXPORT_ASCII_WARNING
+ {
+ Text [ en-US ] = "Thesaurus is not available" ;
+ };
+ String STR_IMPORT_ERROR
+ {
+ Text [ en-US ] = "Spellcheck not available" ;
+ };
+ String STR_IMPORT_ASCII
+ {
+ Text [ en-US ] = "Import text files" ;
+ };
+ String STR_EXPORT_ASCII
+ {
+ Text [ en-US ] = "Export of text files" ;
+ };
+ String STR_IMPORT_LOTUS
+ {
+ Text [ en-US ] = "Import Lotus files" ;
+ };
+ String STR_IMPORT_DBF
+ {
+ Text [ en-US ] = "Import DBase files" ;
+ };
+ String STR_EXPORT_DBF
+ {
+ Text [ en-US ] = "DBase export";
+ };
+ String STR_EXPORT_DIF
+ {
+ Text [ en-US ] = "Dif Export" ;
+ };
+ String STR_IMPORT_DIF
+ {
+ Text [ en-US ] = "Dif Import" ;
+ };
+ String STR_STYLENAME_STANDARD
+ {
+ Text [ en-US ] = "Default" ;
+ };
+ String STR_STYLENAME_RESULT
+ {
+ Text [ en-US ] = "Result" ;
+ };
+ String STR_STYLENAME_RESULT1
+ {
+ Text [ en-US ] = "Result2" ;
+ };
+ String STR_STYLENAME_HEADLINE
+ {
+ Text [ en-US ] = "Heading" ;
+ };
+ String STR_STYLENAME_HEADLINE1
+ {
+ Text [ en-US ] = "Heading1" ;
+ };
+ String STR_STYLENAME_REPORT
+ {
+ Text [ en-US ] = "Report" ;
+ };
+ String STR_STYLENAME_REPORT1
+ {
+ Text [ en-US ] = "Report1" ;
+ };
+ String STR_IMPORT_EXCEL_WARNING
+ {
+ Text [ en-US ] = "is not available for spellchecking\nPlease check your installation and install \nthe desired language if necessary" ;
+ };
+ String STR_THESAURUS_NO_STRING
+ {
+ Text [ en-US ] = "Thesaurus can only be used in text cells!" ;
+ };
+ String STR_SPELLING_BEGIN_TAB
+ {
+ Text [ en-US ] = "Should the spellcheck be continued at the beginning of the current sheet?" ;
+ };
+ String STR_SPELLING_NO_LANG
+ {
+ Text [ en-US ] = "is not available for the thesaurus.\nPlease check your installation and install \nthe desired language if necessary" ;
+ };
+ String STR_SPELLING_STOP_OK
+ {
+ Text [ en-US ] = "The spellcheck of this sheet has been completed." ;
+ };
+ String STR_NOLANGERR
+ {
+ Text [ en-US ] = "No language set" ;
+ };
+ String STR_UNDO_INSERT_TAB
+ {
+ Text [ en-US ] = "Insert Sheet" ;
+ };
+ String STR_UNDO_DELETE_TAB
+ {
+ Text [ en-US ] = "Delete Sheets" ;
+ };
+ String STR_UNDO_RENAME_TAB
+ {
+ Text [ en-US ] = "Rename Sheet" ;
+ };
+ String STR_UNDO_SET_TAB_BG_COLOR
+ {
+ Text [ en-US ] = "Color Tab" ;
+ };
+ String STR_UNDO_SET_MULTI_TAB_BG_COLOR
+ {
+ Text [ en-US ] = "Color Tabs" ;
+ };
+ String STR_UNDO_MOVE_TAB
+ {
+ Text [ en-US ] = "Move Sheets" ;
+ };
+ String STR_UNDO_COPY_TAB
+ {
+ Text [ en-US ] = "Copy Sheet" ;
+ };
+ String STR_UNDO_APPEND_TAB
+ {
+ Text [ en-US ] = "Append sheet" ;
+ };
+ String STR_UNDO_SHOWTAB
+ {
+ Text [ en-US ] = "Show Sheet" ;
+ };
+ String STR_UNDO_HIDETAB
+ {
+ Text [ en-US ] = "Hide sheet" ;
+ };
+ String STR_UNDO_TAB_RTL
+ {
+ Text [ en-US ] = "Flip sheet" ;
+ };
+ String STR_UNDO_TAB_R1C1
+ {
+ Text [ en-US ] = "Toggle the use of R1C1 notation" ;
+ };
+ String STR_CHART_MAINTITLE
+ {
+ Text [ en-US ] = "Main Title" ;
+ };
+ String STR_CHART_SUBTITLE
+ {
+ Text [ en-US ] = "Subtitle" ;
+ };
+ String STR_CHART_XTITLE
+ {
+ Text [ en-US ] = "X axis title" ;
+ };
+ String STR_CHART_YTITLE
+ {
+ Text [ en-US ] = "Y axis title" ;
+ };
+ String STR_CHART_ZTITLE
+ {
+ Text [ en-US ] = "Z axis title" ;
+ };
+ String STR_ABSREFLOST
+ {
+ Text [ en-US ] = "The new table contains absolute references to other tables which may be incorrect!" ;
+ };
+ String STR_NAMECONFLICT
+ {
+ Text [ en-US ] = "Due to identical names, an existing range name in the destination document has been altered!" ;
+ };
+ String STR_ERR_AUTOFILTER
+ {
+ Text [ en-US ] = "AutoFilter not possible" ;
+ };
+ String STR_MSSG_SEARCHANDREPLACE_1
+ {
+ Text [ en-US ] = "%PRODUCTNAME Calc has searched to the beginning of the sheet. Do you want to continue at the end?" ;
+ };
+ String STR_MSSG_SEARCHANDREPLACE_2
+ {
+ Text [ en-US ] = "%PRODUCTNAME Calc has searched to the end of the sheet. Do you want to continue at the beginning?" ;
+ };
+ String STR_MSSG_SEARCHANDREPLACE_3
+ {
+ Text [ en-US ] = "Find & Replace" ;
+ };
+ String STR_MSSG_SEARCHANDREPLACE_4
+ {
+ Text [ en-US ] = "%PRODUCTNAME Calc has searched to the beginning of the document. Do you want to continue at the end?" ;
+ };
+ String STR_MSSG_SEARCHANDREPLACE_5
+ {
+ Text [ en-US ] = "%PRODUCTNAME Calc has searched to the end of the document. Do you want to continue at the beginning?" ;
+ };
+ String STR_CREATENAME_REPLACE
+ {
+ Text [ en-US ] = "Replace existing definition of #?" ;
+ };
+ String STR_CREATENAME_MARKERR
+ {
+ Text [ en-US ] = "Invalid selection for range names" ;
+ };
+ String STR_CONSOLIDATE_ERR1
+ {
+ Text [ en-US ] = "References can not be inserted above the source data." ;
+ };
+ String STR_SCENARIO_NOTFOUND
+ {
+ Text [ en-US ] = "Scenario not found" ;
+ };
+ String STR_QUERY_DELENTRY
+ {
+ Text [ en-US ] = "Do you really want to delete the entry #?" ;
+ };
+ String STR_VOBJ_OBJECT
+ {
+ Text [ en-US ] = "Objects/graphics" ;
+ };
+ String STR_VOBJ_CHART
+ {
+ Text [ en-US ] = "Charts" ;
+ };
+ String STR_VOBJ_DRAWINGS
+ {
+ Text [ en-US ] = "Drawing Objects" ;
+ };
+ String STR_VOBJ_MODE_SHOW
+ {
+ Text [ en-US ] = "Show" ;
+ };
+ String STR_VOBJ_MODE_HIDE
+ {
+ Text [ en-US ] = "Hide" ;
+ };
+ String STR_SCATTR_PAGE_TOPDOWN
+ {
+ Text [ en-US ] = "Top to bottom" ;
+ };
+ String STR_SCATTR_PAGE_LEFTRIGHT
+ {
+ Text [ en-US ] = "Left-to-right" ;
+ };
+ String STR_SCATTR_PAGE_NOTES
+ {
+ Text [ en-US ] = "Comments" ;
+ };
+ String STR_SCATTR_PAGE_GRID
+ {
+ Text [ en-US ] = "Grid" ;
+ };
+ String STR_SCATTR_PAGE_HEADERS
+ {
+ Text [ en-US ] = "Row & Column Headers" ;
+ };
+ String STR_SCATTR_PAGE_FORMULAS
+ {
+ Text [ en-US ] = "Formulas" ;
+ };
+ String STR_SCATTR_PAGE_NULLVALS
+ {
+ Text [ en-US ] = "Zero Values" ;
+ };
+ String STR_SCATTR_PAGE_PRINTDIR
+ {
+ Text [ en-US ] = "Print direction" ;
+ };
+ String STR_SCATTR_PAGE_FIRSTPAGENO
+ {
+ Text [ en-US ] = "First page number" ;
+ };
+ String STR_SCATTR_PAGE_SCALE
+ {
+ Text [ en-US ] = "Reduce/enlarge printout" ;
+ };
+ String STR_SCATTR_PAGE_SCALETOPAGES
+ {
+ Text [ en-US ] = "Fit print range(s) on number of pages" ;
+ };
+ String STR_SCATTR_PAGE_SCALETO
+ {
+ Text [ en-US ] = "Fit print range(s) to width/height" ;
+ };
+ String STR_SCATTR_PAGE_SCALE_WIDTH
+ {
+ Text [ en-US ] = "Width" ;
+ };
+ String STR_SCATTR_PAGE_SCALE_HEIGHT
+ {
+ Text [ en-US ] = "Height" ;
+ };
+ String STR_SCATTR_PAGE_SCALE_PAGES
+ {
+ Text [ en-US ] = "%1 page(s)" ;
+ };
+ String STR_SCATTR_PAGE_SCALE_AUTO
+ {
+ Text [ en-US ] = "automatic" ;
+ };
+ String STR_DOC_STAT
+ {
+ Text [ en-US ] = "Statistics" ;
+ };
+ String STR_LINKERROR
+ {
+ Text [ en-US ] = "The link could not be updated." ;
+ };
+ String STR_LINKERRORFILE
+ {
+ Text [ en-US ] = "File:" ;
+ };
+ String STR_LINKERRORTAB
+ {
+ Text [ en-US ] = "Sheet:" ;
+ };
+ String STR_OVERVIEW
+ {
+ Text [ en-US ] = "Overview" ;
+ };
+ String STR_DOC_INFO
+ {
+ Text [ en-US ] = "Doc.Information" ;
+ };
+ String STR_DOC_CREATED
+ {
+ Text [ en-US ] = "Created" ;
+ };
+ String STR_DOC_MODIFIED
+ {
+ Text [ en-US ] = "Modified" ;
+ };
+ String STR_DOC_PRINTED
+ {
+ Text [ en-US ] = "Printed" ;
+ };
+ String STR_DOC_THEME
+ {
+ Text [ en-US ] = "Subject" ;
+ };
+ String STR_DOC_KEYWORDS
+ {
+ Text [ en-US ] = "Key words" ;
+ };
+ String STR_DOC_COMMENT
+ {
+ Text [ en-US ] = "Comments" ;
+ };
+ String STR_BY
+ {
+ Text [ en-US ] = "by" ;
+ };
+ String STR_ON
+ {
+ Text [ en-US ] = "on" ;
+ };
+ String STR_RELOAD_TABLES
+ {
+ Text [ en-US ] = "This file contains links to other files.\nShould they be updated?" ;
+ };
+ String STR_REIMPORT_AFTER_LOAD
+ {
+ Text [ en-US ] = "This file contains queries. The results of these queries were not saved.\nDo you want these queries to be repeated?" ;
+ };
+ String STR_FILTER_TOOMANY
+ {
+ Text [ en-US ] = "Too many conditions" ;
+ };
+ String STR_INSERT_FULL
+ {
+ Text [ en-US ] = "Filled cells cannot be shifted\nbeyond the sheet." ;
+ };
+ String STR_TABINSERT_ERROR
+ {
+ Text [ en-US ] = "The table could not be inserted." ;
+ };
+ String STR_TABREMOVE_ERROR
+ {
+ Text [ en-US ] = "The sheets could not be deleted." ;
+ };
+ String STR_PASTE_ERROR
+ {
+ Text [ en-US ] = "The contents of the clipboard could not be pasted." ;
+ };
+ String STR_PASTE_FULL
+ {
+ Text [ en-US ] = "There is not enough space on the sheet to insert here." ;
+ };
+ String STR_PASTE_BIGGER
+ {
+ Text [ en-US ] = "The content of the clipboard is bigger than the range selected.\nDo you want to insert it anyway?";
+ };
+ String STR_ERR_NOREF
+ {
+ Text [ en-US ] = "No references found." ;
+ };
+ String STR_ERR_LINKOVERLAP
+ {
+ Text [ en-US ] = "Source and destination must not overlap." ;
+ };
+ String STR_GRAPHICNAME
+ {
+ Text [ en-US ] = "Graphics" ;
+ };
+ String STR_INVALIDNAME
+ {
+ Text [ en-US ] = "Invalid name." ;
+ };
+ String STR_VALID_MACRONOTFOUND
+ {
+ Text [ en-US ] = "Selected macro not found." ;
+ };
+ String STR_VALID_DEFERROR
+ {
+ Text [ en-US ] = "Invalid value." ;
+ };
+ String STR_PROGRESS_CALCULATING
+ {
+ Text [ en-US ] = "calculating" ;
+ };
+ String STR_PROGRESS_SORTING
+ {
+ Text [ en-US ] = "sorting" ;
+ };
+ String STR_PROGRESS_HEIGHTING
+ {
+ Text [ en-US ] = "Adapt row height" ;
+ };
+ String STR_PROGRESS_COMPARING
+ {
+ Text [ en-US ] = "Compare #" ;
+ };
+ String STR_DETINVALID_OVERFLOW
+ {
+ Text [ en-US ] = "The maximum number of invalid cells has been exceeded.\nNot all invalid cells have been marked." ;
+ };
+ String STR_QUICKHELP_DELETE
+ {
+ Text [ en-US ] = "Delete contents" ;
+ };
+ String STR_QUICKHELP_REF
+ {
+ Text [ en-US ] = "%1 R x %2 C" ;
+ };
+ String STR_FUNCTIONLIST_MORE
+ {
+ Text [ en-US ] = "More..." ;
+ };
+ String STR_ERR_INVALID_AREA
+ {
+ Text [ en-US ] = "Invalid range" ;
+ };
+ // Templates for data pilot tables.
+ String STR_PIVOT_STYLE_INNER
+ {
+ Text [ en-US ] = "DataPilot Value" ;
+ };
+ String STR_PIVOT_STYLE_RESULT
+ {
+ Text [ en-US ] = "DataPilot Result" ;
+ };
+ String STR_PIVOT_STYLE_CATEGORY
+ {
+ Text [ en-US ] = "DataPilot Category" ;
+ };
+ String STR_PIVOT_STYLE_TITLE
+ {
+ Text [ en-US ] = "DataPilot Title" ;
+ };
+ String STR_PIVOT_STYLE_FIELDNAME
+ {
+ Text [ en-US ] = "DataPilot Field" ;
+ };
+ String STR_PIVOT_STYLE_TOP
+ {
+ Text [ en-US ] = "DataPilot Corner" ;
+ };
+ String STR_OPERATION_FILTER
+ {
+ Text [ en-US ] = "Filter" ;
+ };
+ String STR_OPERATION_SORT
+ {
+ Text [ en-US ] = "Sort" ;
+ };
+ String STR_OPERATION_SUBTOTAL
+ {
+ Text [ en-US ] = "Subtotals" ;
+ };
+ String STR_OPERATION_NONE
+ {
+ Text [ en-US ] = "None" ;
+ };
+ String STR_IMPORT_REPLACE
+ {
+ Text [ en-US ] = "Do you want to replace the contents of #?" ;
+ };
+ String STR_TIP_WIDTH
+ {
+ Text [ en-US ] = "Width:" ;
+ };
+ String STR_TIP_HEIGHT
+ {
+ Text [ en-US ] = "Height:" ;
+ };
+ String STR_TIP_HIDE
+ {
+ Text [ en-US ] = "Hide" ;
+ };
+ String STR_ERR_INSERTOBJ
+ {
+ Text [ en-US ] = "The object could not be inserted." ;
+ };
+ String STR_CHANGED_BLANK
+ {
+ Text [ en-US ] = "<empty>" ;
+ };
+ String STR_CHANGED_CELL
+ {
+ Text [ en-US ] = "Cell #1 changed from '#2' to '#3'" ;
+ };
+ String STR_CHANGED_INSERT
+ {
+ Text [ en-US ] = "#1 inserted" ;
+ };
+ String STR_CHANGED_DELETE
+ {
+ Text [ en-US ] = "#1deleted" ;
+ };
+ String STR_CHANGED_MOVE
+ {
+ Text [ en-US ] = "Range moved from #1 to #2" ;
+ };
+ String STR_END_REDLINING_TITLE
+ {
+ Text [ en-US ] = "Exit Recording" ;
+ };
+ String STR_END_REDLINING
+ {
+ Text [ en-US ] = "This action will exit the change recording mode.\nAny information about changes will be lost.\n\nExit change recording mode?\n\n" ;
+ };
+ String STR_CLOSE_ERROR_LINK
+ {
+ Text [ en-US ] = "The document can not be closed while a link is being updated." ;
+ };
+ String STR_UNDO_RESIZEMATRIX
+ {
+ Text [ en-US ] = "Adapt array area";
+ };
+ String STR_TIP_RESIZEMATRIX
+ {
+ Text [ en-US ] = "Array formula %1 R x %2 C";
+ };
+ String STR_MACRO_WARNING
+ {
+ Text [ en-US ] = "This document contains macro function calls.\nDo you want to run them?";
+ };
+
+ String STR_UNDO_HANGULHANJA
+ {
+ Text [ en-US ] = "Hangul/Hanja Conversion";
+ };
+
+ String STR_NAME_INPUT_CELL
+ {
+ Text [ en-US ] = "Select Cell";
+ };
+ String STR_NAME_INPUT_RANGE
+ {
+ Text [ en-US ] = "Select Range";
+ };
+ String STR_NAME_INPUT_DBRANGE
+ {
+ Text [ en-US ] = "Select Database Range";
+ };
+ String STR_NAME_INPUT_ROW
+ {
+ Text [ en-US ] = "Go To Row";
+ };
+ String STR_NAME_INPUT_SHEET
+ {
+ Text [ en-US ] = "Go To Sheet";
+ };
+ String STR_NAME_INPUT_DEFINE
+ {
+ Text [ en-US ] = "Define Name for Range";
+ };
+ String STR_NAME_ERROR_SELECTION
+ {
+ Text [ en-US ] = "The selection needs to be rectangular in order to name it.";
+ };
+ String STR_NAME_ERROR_NAME
+ {
+ Text [ en-US ] = "You must enter a valid reference or type a valid name for the selected range.";
+ };
+
+ String STR_CHANGED_MOVE_REJECTION_WARNING
+ {
+ Text[ en-US ] = "WARNING: This action may have resulted in unintended changes to cell references in formulas.";
+ };
+
+ String STR_CHANGED_DELETE_REJECTION_WARNING
+ {
+ Text[ en-US ] = "WARNING: This action may have resulted in references to the deleted area not being restored.";
+ };
+
+ String STR_HF_NONE_IN_BRACKETS
+ {
+ Text [ en-US ] = "(none)";
+ };
+
+ String STR_HF_OF
+ {
+ Text [ en-US ] = "of";
+ };
+
+ String STR_HF_OF_QUESTION
+ {
+ Text [ en-US ] = "of ?";
+ };
+
+ String STR_HF_CREATED_BY
+ {
+ Text [ en-US ] = "Created by";
+ };
+
+ String STR_HF_CONFIDENTIAL
+ {
+ Text [ en-US ] = "Confidential";
+ };
+
+ String STR_HF_CUSTOMIZED
+ {
+ Text [ en-US ] = "Customized";
+ };
+
+ String STR_HF_CUSTOM_FOOTER
+ {
+ Text [ en-US ] = "Custom footer";
+ };
+
+ String STR_UNDO_CHINESE_TRANSLATION
+ {
+ Text [ en-US ] = "Chinese conversion";
+ };
+
+ String STR_ERR_DATAPILOT_INPUT
+ {
+ Text[ en-US ] = "You cannot change this part of the DataPilot table.";
+ };
+
+ String STR_RECALC_MANUAL
+ {
+ Text [ en-US ] = "Manual";
+ };
+ String STR_RECALC_AUTO
+ {
+ Text [ en-US ] = "Automatic";
+ };
+ String STR_ERR_LONG_NESTED_ARRAY
+ {
+ Text [ en-US ] = "Nested arrays are not supported." ;
+ };
+ String STR_UNDO_TEXTTOCOLUMNS
+ {
+ Text [ en-US ] = "Text to Columns";
+ };
+ String STR_DOC_UPDATED
+ {
+ Text [ en-US ] = "Your spreadsheet has been updated with changes saved by other users.";
+ };
+ String STR_DOC_WILLBESAVED
+ {
+ Text [ en-US ] = "The spreadsheet must be saved now to activate sharing mode.\n\nDo you want to continue?";
+ };
+ String STR_DOC_WILLNOTBESAVED
+ {
+ Text [ en-US ] = "Already resolved merge conflicts will be lost and your changes to the shared spreadsheet will not be saved.\n\nDo you want to continue?";
+ };
+ String STR_DOC_DISABLESHARED
+ {
+ Text [ en-US ] = "Disabling shared mode of a spreadsheet hinders all other users of the shared spreadsheet to merge back their work.\n\nDo you want to continue?";
+ };
+ String STR_DOC_NOLONGERSHARED
+ {
+ Text [ en-US ] = "This spreadsheet is no longer in shared mode.\n\nSave your spreadsheet to a separate file and merge your changes to the shared spreadsheet manually.";
+ };
+ String STR_SHARED_DOC_WARNING
+ {
+ Text [ en-US ] = "The spreadsheet is in shared mode. This allows multiple users to access and edit the spreadsheet at the same time.\n\nChanges to formatting attributes like fonts, colors, and number formats will not be saved and some functionalities like editing charts and drawing objects are not available in shared mode. Turn off shared mode to get exclusive access needed for those changes and functionalities.";
+ };
+ String STR_FILE_LOCKED_TRY_LATER
+ {
+ Text [ en-US ] = "The shared spreadsheet file is locked due to a merge in progress by user: '%1'\n\nSharing mode of a locked file cannot be disabled. Try again later.";
+ };
+ String STR_FILE_LOCKED_SAVE_LATER
+ {
+ Text [ en-US ] = "The shared spreadsheet file is locked due to a merge in progress by user: '%1'\n\nTry again later to save your changes.";
+ };
+ String STR_UNKNOWN_USER
+ {
+ Text [ en-US ] = "Unknown User";
+ };
+
+ String STR_SHAPE_AUTOSHAPE
+ {
+ Text [ en-US ] = "AutoShape";
+ };
+
+ String STR_SHAPE_RECTANGLE
+ {
+ Text [ en-US ] = "Rectangle";
+ };
+
+ String STR_SHAPE_LINE
+ {
+ Text [ en-US ] = "Line";
+ };
+
+ String STR_SHAPE_OVAL
+ {
+ Text [ en-US ] = "Oval";
+ };
+
+ String STR_SHAPE_TEXTBOX
+ {
+ Text [ en-US ] = "Text Box";
+ };
+
+ String STR_FORM_BUTTON
+ {
+ Text [ en-US ] = "Button";
+ };
+
+ String STR_FORM_CHECKBOX
+ {
+ Text [ en-US ] = "Check Box";
+ };
+
+ String STR_FORM_OPTIONBUTTON
+ {
+ Text [ en-US ] = "Option Button";
+ };
+
+ String STR_FORM_LABEL
+ {
+ Text [ en-US ] = "Label";
+ };
+
+ String STR_FORM_LISTBOX
+ {
+ Text [ en-US ] = "List Box";
+ };
+
+ String STR_FORM_GROUPBOX
+ {
+ Text [ en-US ] = "Group Box";
+ };
+
+ String STR_FORM_DROPDOWN
+ {
+ Text [ en-US ] = "Drop Down";
+ };
+
+ String STR_FORM_SPINNER
+ {
+ Text [ en-US ] = "Spinner";
+ };
+
+ String STR_FORM_SCROLLBAR
+ {
+ Text [ en-US ] = "Scroll Bar";
+ };
+
+ String STR_STYLE_FAMILY_CELL
+ {
+ Text [ en-US ] = "Cell Styles";
+ };
+ String STR_STYLE_FAMILY_PAGE
+ {
+ Text [ en-US ] = "Page Styles";
+ };
+ String STR_ERR_DATAPILOTSOURCE
+ {
+ Text [ en-US ] = "DataPilot source data is invalid.";
+ };
+ String STR_PIVOT_FIRSTROWEMPTYERR
+ {
+ Text [ en-US ] = "The field name cannot be empty. Check the first row of data source to make sure there are no empty cells." ;
+ };
+ String STR_PIVOT_ONLYONEROWERR
+ {
+ Text [ en-US ] = "DataPilot table needs at least two rows of data to create or refresh." ;
+ };
+ String STR_OPTIONS_WARN_SEPARATORS
+ {
+ Text [ en-US ] = "Because the current formula separator settings conflict with the locale, the formula separators have been reset to their default values.";
+ };
+ String STR_UNDO_INSERT_CURRENT_DATE
+ {
+ Text [ en-US ] = "Insert Current Date";
+ };
+ String STR_UNDO_INSERT_CURRENT_TIME
+ {
+ Text [ en-US ] = "Insert Current Time";
+ };
+};
+
diff --git a/sc/source/ui/src/hdrcont.src b/sc/source/ui/src/hdrcont.src
new file mode 100644
index 000000000000..da3f5b6e1412
--- /dev/null
+++ b/sc/source/ui/src/hdrcont.src
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc"
+
+
+
+#define PART1 \
+ MenuItem\
+ {\
+ Identifier = FID_CELL_FORMAT ; \
+ HelpId = FID_CELL_FORMAT ; \
+ Text [ en-US ] = "~Format Cells..." ; \
+ };
+
+
+#define PART2 \
+ MenuItem\
+ {\
+ Identifier = SID_CUT ; \
+ HelpId = SID_CUT ; \
+ Text [ en-US ] = "Cu~t" ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Die Selektion in die Zwischenablage kopieren und löschen : Die Selektion in die Zwischenablage kopieren und l÷schen */\
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_COPY ; \
+ HelpId = SID_COPY ; \
+ Text [ en-US ] = "~Copy" ; \
+ };\
+ MenuItem\
+ {\
+ Identifier = SID_PASTE ; \
+ HelpId = SID_PASTE ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Einfügen : Einf³gen */\
+ Text [ en-US ] = "~Paste" ; \
+ /* ### ACHTUNG: Neuer Text in Resource? Den Inhalt der Zwischenablage einfügen : Den Inhalt der Zwischenablage einf³gen */\
+ };
+
+ //-------------------------------------------------------------------------------
+
+Menu RID_POPUP_ROWHEADER
+{
+ ItemList =
+ {
+ PART1
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_ROW_HEIGHT ;
+ HelpId = FID_ROW_HEIGHT ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zeilenhöhe... : Zeilenh÷he... */
+ Text [ en-US ] = "Row Hei~ght..." ;
+ };
+ MenuItem
+ {
+ Identifier = FID_ROW_OPT_HEIGHT ;
+ HelpId = FID_ROW_OPT_HEIGHT ;
+ /* ### ACHTUNG: Neuer Text in Resource? Optimale Zeilenhöhe... : Optimale Zeilenh÷he... */
+ Text [ en-US ] = "Optimal ~Row Height..." ;
+ /* ### ACHTUNG: Neuer Text in Resource? Optimale Zeilenhöhe einstellen : Optimale Zeilenh÷he einstellen */
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_INS_ROW ;
+ HelpId = FID_INS_ROW ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zeilen einfügen : Zeilen einf³gen */
+ Text [ en-US ] = "~Insert Rows" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ganze Zeilen einfügen : Ganze Zeilen einf³gen */
+ };
+ MenuItem
+ {
+ Identifier = SID_DEL_ROWS ;
+ HelpId = SID_DEL_ROWS ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zeilen löschen : Zeilen l÷schen */
+ Text [ en-US ] = "~Delete Rows" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ganze Zeilen löschen : Ganze Zeilen l÷schen */
+ };
+ MenuItem
+ {
+ Identifier = SID_DELETE ;
+ HelpId = SID_DELETE ;
+ /* ### ACHTUNG: Neuer Text in Resource? Inhalte l~öschen... : Inhalte l~÷schen... */
+ Text [ en-US ] = "De~lete Contents..." ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ausgewählte Inhalte löschen (Formeln, Formate etc.) : Ausgewõhlte Inhalte l÷schen (Formeln, Formate etc.) */
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_ROW_HIDE ;
+ HelpId = FID_ROW_HIDE ;
+ Text [ en-US ] = "~Hide" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_ROW_SHOW ;
+ HelpId = FID_ROW_SHOW ;
+ Text [ en-US ] = "~Show" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ PART2
+ MenuItem
+ {
+ Identifier = SID_PASTE_SPECIAL ;
+ HelpId = SID_PASTE_SPECIAL ;
+ Text [ en-US ] = "P~aste Special..." ;
+ };
+ };
+};
+
+ //-------------------------------------------------------------------
+
+Menu RID_POPUP_COLHEADER
+{
+ ItemList =
+ {
+ PART1
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_COL_WIDTH ;
+ HelpId = FID_COL_WIDTH ;
+ Text [ en-US ] = "Col~umn Width..." ;
+ /* ### ACHTUNG: Neuer Text in Resource? Spaltenbreite ändern : Spaltenbreite õndern */
+ };
+ MenuItem
+ {
+ Identifier = FID_COL_OPT_WIDTH ;
+ HelpId = FID_COL_OPT_WIDTH ;
+ Text [ en-US ] = "O~ptimal Column Width..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_INS_COLUMN ;
+ HelpId = FID_INS_COLUMN ;
+ /* ### ACHTUNG: Neuer Text in Resource? Spalten einfügen : Spalten einf³gen */
+ Text [ en-US ] = "~Insert Columns" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ganze Spalten einfügen : Ganze Spalten einf³gen */
+ };
+ MenuItem
+ {
+ Identifier = SID_DEL_COLS ;
+ HelpId = SID_DEL_COLS ;
+ /* ### ACHTUNG: Neuer Text in Resource? Spalten löschen : Spalten l÷schen */
+ Text [ en-US ] = "~Delete Columns" ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ganze Spalten löschen : Ganze Spalten l÷schen */
+ };
+ MenuItem
+ {
+ Identifier = SID_DELETE ;
+ HelpId = SID_DELETE ;
+ /* ### ACHTUNG: Neuer Text in Resource? Inhalte l~öschen... : Inhalte l~÷schen... */
+ Text [ en-US ] = "D~elete Contents..." ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ausgewählte Inhalte löschen (Formeln, Formate etc.) : Ausgewõhlte Inhalte l÷schen (Formeln, Formate etc.) */
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_COL_HIDE ;
+ HelpId = FID_COL_HIDE ;
+ Text [ en-US ] = "~Hide" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_COL_SHOW ;
+ HelpId = FID_COL_SHOW ;
+ Text [ en-US ] = "~Show" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ PART2
+ MenuItem
+ {
+ Identifier = SID_PASTE_SPECIAL ;
+ HelpId = SID_PASTE_SPECIAL ;
+ Text [ en-US ] = "Paste ~Special..." ;
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/makefile.mk b/sc/source/ui/src/makefile.mk
new file mode 100644
index 000000000000..e1974edab4c1
--- /dev/null
+++ b/sc/source/ui/src/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=ui
+
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ sc.src \
+ pseudo.src \
+ popup.src \
+ toolbox.src \
+ scstring.src \
+ attrdlg.src \
+ sortdlg.src \
+ filter.src \
+ namedlg.src \
+ dbnamdlg.src \
+ subtdlg.src \
+ miscdlgs.src \
+ datafdlg.src \
+ autofmt.src \
+ solvrdlg.src \
+ optsolver.src \
+ solveroptions.src \
+ tabopdlg.src \
+ hdrcont.src \
+ globstr.src \
+ optdlg.src \
+ scerrors.src \
+ textdlgs.src \
+ scfuncs.src \
+ crnrdlg.src \
+ condfrmt.src \
+ opredlin.src \
+ simpref.src
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+$(SRS)$/ui.srs: $(SOLARINCDIR)$/svx$/globlmn.hrc
+
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
new file mode 100644
index 000000000000..8f2dc9c2f0e3
--- /dev/null
+++ b/sc/source/ui/src/miscdlgs.src
@@ -0,0 +1,1463 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "miscdlgs.hrc"
+
+ModalDialog RID_SCDLG_DELCELL
+{
+ OutputSize = TRUE ;
+ HelpId = FID_DELETE_CELL ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 191 , 70 ) ;
+ Text [ en-US ] = "Delete Cells" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 135 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 135 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 135 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DELCOLS
+ {
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Delete entire ~column(s)" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DELROWS
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Delete entire ~row(s)" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_CELLSLEFT
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Shift cells ~left" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_CELLSUP
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Shift cells ~up" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 123 , 8 ) ;
+ Text [ en-US ] = "Selection" ;
+ };
+};
+ModalDialog RID_SCDLG_INSCELL
+{
+ OutputSize = TRUE ;
+ HelpId = FID_INS_CELL ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 191 , 70 ) ;
+ Text [ en-US ] = "Insert Cells" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 135 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 135 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 135 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_INSCOLS
+ {
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Entire ~column" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_INSROWS
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Entire ro~w" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_CELLSRIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Shift cells ~right" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_CELLSDOWN
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "Shift cells ~down" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 123 , 8 ) ;
+ Text [ en-US ] = "Selection" ;
+ };
+};
+
+ModalDialog RID_SCDLG_DELCONT
+{
+ OutputSize = TRUE ;
+ HelpId = SID_DELETE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 161 , 130 ) ;
+ Text [ en-US ] = "Delete Contents" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 105 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 105 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 105 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELALL
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Delete ~all" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELSTRINGS
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Text" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELNUMBERS
+ {
+ Pos = MAP_APPFONT ( 12 , 44 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Numbers" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELDATETIME
+ {
+ Pos = MAP_APPFONT ( 12 , 58 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Date & time" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELFORMULAS
+ {
+ Pos = MAP_APPFONT ( 12 , 72 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Formulas" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELATTRS
+ {
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "For~mats" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELNOTES
+ {
+ Pos = MAP_APPFONT ( 12 , 86 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Comments" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_DELOBJECTS
+ {
+ Pos = MAP_APPFONT ( 12 , 114 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Objects" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Text [ en-US ] = "Selection" ;
+ };
+};
+
+
+ModalDialog RID_SCDLG_INSCONT
+{
+ OutputSize = TRUE ;
+ HelpId = FID_INS_CELL_CONTENTS ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 260 , 187 ) ;
+ Text [ en-US ] = "Paste Special" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 204 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 204 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 204 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSALL
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Paste all" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSSTRINGS
+ {
+ Pos = MAP_APPFONT ( 12 , 30 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "Te~xt" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSNUMBERS
+ {
+ Pos = MAP_APPFONT ( 12 , 44 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Numbers" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSDATETIME
+ {
+ Pos = MAP_APPFONT ( 12 , 58 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Date & time" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSFORMULAS
+ {
+ Pos = MAP_APPFONT ( 12 , 72 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Formulas" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSATTRS
+ {
+ Pos = MAP_APPFONT ( 12 , 100 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "For~mats" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSOBJECTS
+ {
+ Pos = MAP_APPFONT ( 12 , 114 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Objects" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_INSNOTES
+ {
+ Pos = MAP_APPFONT ( 12 , 86 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Comments" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Text [ en-US ] = "Selection" ;
+ };
+ RadioButton BTN_OP_NOOP
+ {
+ Pos = MAP_APPFONT ( 111 , 14 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Non~e" ;
+ };
+ RadioButton BTN_OP_ADD
+ {
+ Pos = MAP_APPFONT ( 111 , 30 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Add" ;
+ };
+ RadioButton BTN_OP_SUB
+ {
+ Pos = MAP_APPFONT ( 111 , 44 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Subtract" ;
+ };
+ RadioButton BTN_OP_MUL
+ {
+ Pos = MAP_APPFONT ( 111 , 58 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Multipl~y" ;
+ };
+ RadioButton BTN_OP_DIV
+ {
+ Pos = MAP_APPFONT ( 111 , 72 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Di~vide" ;
+ };
+ FixedLine FL_OPERATION
+ {
+ Pos = MAP_APPFONT ( 105 , 3 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Text [ en-US ] = "Operations" ;
+ };
+ CheckBox BTN_SKIP_EMPTY
+ {
+ Pos = MAP_APPFONT ( 12 , 141 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "S~kip empty cells" ;
+ };
+ CheckBox BTN_TRANSPOSE
+ {
+ Pos = MAP_APPFONT ( 12 , 155 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Transpose" ;
+ };
+ CheckBox BTN_LINK
+ {
+ Pos = MAP_APPFONT ( 12 , 169 ) ;
+ Size = MAP_APPFONT ( 84 , 10 ) ;
+ Text [ en-US ] = "~Link" ;
+ };
+ FixedLine FL_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 130 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Text [ en-US ] = "Options" ;
+ };
+ RadioButton BTN_MV_NONE
+ {
+ Pos = MAP_APPFONT ( 111 , 141 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Don't sh~ift" ;
+ };
+ RadioButton BTN_MV_DOWN
+ {
+ Pos = MAP_APPFONT ( 111 , 155 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "Do~wn" ;
+ };
+ RadioButton BTN_MV_RIGHT
+ {
+ Pos = MAP_APPFONT ( 111 , 169 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ Text [ en-US ] = "~Right" ;
+ };
+ FixedLine FL_MOVE
+ {
+ Pos = MAP_APPFONT ( 105 , 130 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Text [ en-US ] = "Shift cells" ;
+ };
+ FixedLine FL_SEP1
+ {
+ Pos = MAP_APPFONT( 102 , 14 ) ;
+ Size = MAP_APPFONT( 1 , 96 ) ;
+ };
+ FixedLine FL_SEP2
+ {
+ Pos = MAP_APPFONT( 102 , 127 ) ;
+ Size = MAP_APPFONT( 1 , 38 ) ;
+ };
+};
+ModalDialog RID_SCDLG_MOVETAB
+{
+ OutputSize = TRUE ;
+ HelpId = FID_TAB_MOVE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 130 ) ;
+ Text [ en-US ] = "Move/Copy Sheet" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 112 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 112 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 112 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_DEST
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ Text [ en-US ] = "To ~document" ;
+ };
+ ListBox LB_DEST
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 100 , 60 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_INSERT
+ {
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ Text [ en-US ] = "~Insert before" ;
+ };
+ ListBox LB_INSERT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 46 ) ;
+ Size = MAP_APPFONT ( 100 , 62 ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_COPY
+ {
+ Pos = MAP_APPFONT ( 6 , 114 ) ;
+ Size = MAP_APPFONT ( 100 , 10 ) ;
+ Text [ en-US ] = "~Copy" ;
+ TabStop = TRUE ;
+ };
+ String STR_NEWDOC
+ {
+ Text [ en-US ] = "- new document -" ;
+ };
+};
+ModalDialog RID_SCDLG_STRINPUT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 178 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 122 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 122 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 122 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Edit ED_INPUT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 17 ) ;
+ Size = MAP_APPFONT ( 110 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 110 , 8 ) ;
+ };
+};
+ModalDialog RID_SCDLG_TAB_BG_COLOR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 118 , 167 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Control TAB_BG_COLOR_CT_BORDER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 1 , 1 ) ; //12, 32
+ Size = MAP_APPFONT ( 116+2 , 145+2 ) ;
+ DialogControl = TRUE;
+ };
+ Control TAB_BG_COLOR_SET_BGDCOLOR
+ {
+ // * HelpId = HID_BACKGROUND_CTL_BGDCOLORSET ;
+ Hide = FALSE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 116 , 145 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 82 , 151 ) ;
+ Size = MAP_APPFONT ( 35 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = FALSE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 45 , 151 ) ;
+ Size = MAP_APPFONT ( 35 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 2 , 151 ) ;
+ Size = MAP_APPFONT ( 35 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = FALSE ;
+ };
+};
+/*
+ModalDialog RID_SCDLG_TAB_BG_COLOR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 180 , 150 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Control TAB_BG_COLOR_CT_BORDER
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 1 , 1 ) ; //12, 32
+ Size = MAP_APPFONT ( 116+2 , 145+2 ) ;
+ DialogControl = TRUE;
+ };
+ Control TAB_BG_COLOR_SET_BGDCOLOR
+ {
+ // * HelpId = HID_BACKGROUND_CTL_BGDCOLORSET ;
+ Hide = FALSE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 116 , 145 ) ;
+ TabStop = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 125 , 50 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 125 , 67 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = FALSE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 125 , 84 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = FALSE ;
+ };
+};
+*/
+/*
+ModalDialog RID_SCDLG_MTRINPUT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 190 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 136 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 136 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ };
+ MetricField ED_VALUE
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ HelpId = HID_SC_MTRIN_VAL ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ };
+ CheckBox BTN_DEFVAL
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 24 ) ;
+ Size = MAP_APPFONT ( 58 , 10 ) ;
+ Text [ en-US ] = "~Default value" ;
+ };
+};
+*/
+
+ModalDialog RID_SCDLG_COL_MAN
+{
+ Text [ en-US ] = "Column Width" ;
+
+ HelpId = FID_COL_WIDTH ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 190 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 136 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 136 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "Width" ;
+ };
+ MetricField ED_VALUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 6 ) ;
+ Size = MAP_APPFONT ( 70 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ };
+ CheckBox BTN_DEFVAL
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 24 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Default value" ;
+ };
+};
+
+ModalDialog RID_SCDLG_COL_OPT
+{
+ Text [ en-US ] = "Optimal Column Width" ;
+
+ HelpId = FID_COL_OPT_WIDTH ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 190 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 136 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 136 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "Add" ;
+ };
+ MetricField ED_VALUE
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 6 ) ;
+ Size = MAP_APPFONT ( 70 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ };
+ CheckBox BTN_DEFVAL
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 24 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Default value" ;
+ };
+};
+
+ModalDialog RID_SCDLG_ROW_MAN
+{
+ Text [ en-US ] = "Row Height" ;
+
+ HelpId = FID_ROW_HEIGHT ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 190 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 136 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 136 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "Height" ;
+ };
+ MetricField ED_VALUE
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 6 ) ;
+ Size = MAP_APPFONT ( 70 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ };
+ CheckBox BTN_DEFVAL
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 24 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Default value" ;
+ };
+};
+
+ModalDialog RID_SCDLG_ROW_OPT
+{
+ Text [ en-US ] = "Optimal Row Height" ;
+
+ HelpId = FID_ROW_OPT_HEIGHT ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 190 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 136 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 136 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 136 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "Add" ;
+ };
+ MetricField ED_VALUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 6 ) ;
+ Size = MAP_APPFONT ( 70 , 12 ) ;
+ TabStop = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ };
+ CheckBox BTN_DEFVAL
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 24 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Default value" ;
+ };
+};
+
+
+ // RID_SCDLG_SELENTRY als Basis fuer RID_SCDLG_SELECTDB und RID_SCDLG_SHOW_TAB
+ // gibt es nicht mehr, weil die beiden jetzt unterschiedlich sind
+
+ModalDialog RID_SCDLG_SELECTDB
+{
+ HelpId = SID_SELECT_DB ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 100 ) ;
+ Text [ en-US ] = "Select" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 112 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 112 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 112 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_ENTRYLIST
+ {
+ // HelpID aus Zeiten, als noch abgeleitet wurde
+ HelpId = HID_SC_SELENTRY_LIST ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 91 , 80 ) ;
+ TabStop = TRUE ;
+ Sort = TRUE ;
+ };
+ FixedLine FL_ENTRYLIST
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 100 , 8 ) ;
+ };
+};
+
+ModalDialog RID_SCDLG_SHOW_TAB
+{
+ HelpId = FID_TABLE_SHOW ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 100 ) ;
+ Text [ en-US ] = "Show Sheet" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 112 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 112 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 112 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ MultiListBox LB_ENTRYLIST
+ {
+ SimpleMode = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 19 ) ;
+ Size = MAP_APPFONT ( 100 , 75 ) ;
+ TabStop = TRUE ;
+ Sort = FALSE ;
+ };
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 90 , 10 ) ;
+ Text [ en-US ] = "Hidden sheets" ;
+ };
+};
+
+
+ModalDialog RID_SCDLG_FILLSERIES
+{
+ OutputSize = TRUE ;
+ HelpId = FID_FILL_SERIES ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 290 , 122 ) ;
+ Text [ en-US ] = "Fill Series" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ RadioButton BTN_DAY
+ {
+ Pos = MAP_APPFONT ( 159 , 14 ) ;
+ Size = MAP_APPFONT ( 66 , 10 ) ;
+ Text [ en-US ] = "Da~y" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DAY_OF_WEEK
+ {
+ Pos = MAP_APPFONT ( 159 , 28 ) ;
+ Size = MAP_APPFONT ( 66 , 10 ) ;
+ Text [ en-US ] = "~Weekday" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_MONTH
+ {
+ Pos = MAP_APPFONT ( 159 , 42 ) ;
+ Size = MAP_APPFONT ( 66 , 10 ) ;
+ Text [ en-US ] = "~Month" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_YEAR
+ {
+ Pos = MAP_APPFONT ( 159 , 56 ) ;
+ Size = MAP_APPFONT ( 66 , 10 ) ;
+ Text [ en-US ] = "Y~ear" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_TIME_UNIT
+ {
+ Pos = MAP_APPFONT ( 153 , 3 ) ;
+ Size = MAP_APPFONT ( 75 , 8 ) ;
+ Text [ en-US ] = "Time unit" ;
+ };
+ RadioButton BTN_RIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 51 , 10 ) ;
+ Text [ en-US ] = "~Right" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_LEFT
+ {
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 51 , 10 ) ;
+ Text [ en-US ] = "~Left" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_TOP
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 51 , 10 ) ;
+ Text [ en-US ] = "~Up" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_BOTTOM
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 51 , 10 ) ;
+ Text [ en-US ] = "~Down" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_DIRECTION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Direction" ;
+ };
+ RadioButton BTN_ARITHMETIC
+ {
+ Pos = MAP_APPFONT ( 78 , 14 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ Text [ en-US ] = "Li~near" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_GEOMETRIC
+ {
+ Pos = MAP_APPFONT ( 78 , 28 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ Text [ en-US ] = "~Growth" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DATE
+ {
+ Pos = MAP_APPFONT ( 78 , 42 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ Text [ en-US ] = "Da~te" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_AUTOFILL
+ {
+ Pos = MAP_APPFONT ( 78 , 56 ) ;
+ Size = MAP_APPFONT ( 69 , 10 ) ;
+ Text [ en-US ] = "~AutoFill" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_TYPE
+ {
+ Pos = MAP_APPFONT ( 72 , 3 ) ;
+ Size = MAP_APPFONT ( 75 , 8 ) ;
+ Text [ en-US ] = "Series type" ;
+ };
+ FixedLine FL_SEP1
+ {
+ Pos = MAP_APPFONT( 69 , 14 ) ;
+ Size = MAP_APPFONT ( 1 , 52 ) ;
+ };
+ FixedLine FL_SEP2
+ {
+ Pos = MAP_APPFONT( 150 , 14 ) ;
+ Size = MAP_APPFONT ( 1 , 52 ) ;
+ };
+ FixedText FT_START_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 74 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "~Start value" ;
+ };
+ Edit ED_START_VALUES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 55 , 72 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_END_VALUE
+ {
+ Pos = MAP_APPFONT ( 6 , 90 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "End ~value" ;
+ };
+ Edit ED_END_VALUES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 55 , 88 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_INCREMENT
+ {
+ Pos = MAP_APPFONT ( 6 , 106 ) ;
+ Size = MAP_APPFONT ( 45 , 8 ) ;
+ Text [ en-US ] = "In~crement" ;
+ };
+ Edit ED_INCREMENT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 55 , 104 ) ;
+ Size = MAP_APPFONT ( 58 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_VALERR
+ {
+ Text [ en-US ] = "Invalid value" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 234 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 234 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 234 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+#define TXT_COLS \
+ Text [ en-US ] = "~Columns" ; \
+
+
+#define TXT_ROWS \
+ Text [ en-US ] = "~Rows" ; \
+
+
+ModalDialog RID_SCDLG_GROUP
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 148 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 92 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 92 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 92 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_GROUP_ROWS
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ HelpId = HID_SC_GROUP_ROWS ;
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ TXT_ROWS
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_GROUP_COLS
+ {
+ // HelpID, weil die generierten aus den Ableitungen nicht in die hid.lst kommen
+ HelpId = HID_SC_GROUP_COLS ;
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ TXT_COLS
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ Text = "Aktivieren für" ;
+ };
+ String STR_GROUP
+ {
+ Text [ en-US ] = "Include" ;
+ };
+ String STR_UNGROUP
+ {
+ Text [ en-US ] = "Deactivate for" ;
+ };
+ Text [ en-US ] = "Group" ;
+};
+
+ // Ableitungen
+ModalDialog RID_SCDLG_GRP_MAKE < RID_SCDLG_GROUP { HelpId = SID_OUTLINE_MAKE ; };
+ModalDialog RID_SCDLG_GRP_KILL < RID_SCDLG_GROUP { HelpId = SID_OUTLINE_REMOVE ; };
+
+ // RID_SCDLG_COLORROW wird nur in der Optionen-Sortierlisten-Seite benutzt
+
+ModalDialog RID_SCDLG_COLORROW
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 148 , 63 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 92 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 92 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 92 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_GROUP_ROWS
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ TXT_ROWS
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_GROUP_COLS
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 71 , 10 ) ;
+ TXT_COLS
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 80 , 8 ) ;
+ };
+};
+
+ModalDialog RID_SCDLG_NAMES_CREATE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ HelpID = FID_USE_NAME ;
+ Size = MAP_APPFONT ( 174 , 72 ) ;
+ Moveable = TRUE ;
+ CheckBox BTN_TOP
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 93 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Top row" ;
+ };
+ CheckBox BTN_LEFT
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 93 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Left column" ;
+ };
+ CheckBox BTN_BOTTOM
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 93 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Bottom row" ;
+ };
+ CheckBox BTN_RIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 93 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Right column" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 116 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 116 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 116 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 104 , 8 ) ;
+ Text [ en-US ] = "Create names from" ;
+ };
+ Text [ en-US ] = "Create Names" ;
+};
+
+ModalDialog RID_SCDLG_NAMES_PASTE
+{
+ OutputSize = TRUE ;
+ HelpId = FID_INSERT_NAME ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 228 , 85 ) ;
+ Moveable = TRUE ;
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 156 , 10 ) ;
+ Text [ en-US ] = "Insert name" ;
+ };
+ ListBox LB_ENTRYLIST
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 160 , 65 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ Sort = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 172 , 4 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 172 , 21 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 172 , 41 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 172 , 66 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Insert ~All" ;
+ };
+ Text [ en-US ] = "Insert Name" ;
+};
+
+ModalDialog RID_SCDLG_CHARTCOLROW
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 191 , 63 ) ;
+ Moveable = TRUE ;
+ CheckBox 1
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "First ~column as label" ;
+ };
+ CheckBox 2
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 114 , 10 ) ;
+ Text [ en-US ] = "First ~row as label" ;
+ };
+ FixedLine 6
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 123 , 8 ) ;
+ Text [ en-US ] = "Labels" ;
+ };
+ OKButton 3
+ {
+ Pos = MAP_APPFONT ( 135 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton 4
+ {
+ Pos = MAP_APPFONT ( 135 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton 5
+ {
+ Pos = MAP_APPFONT ( 135 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ Text [ en-US ] = "Change Source Data Range" ;
+};
+
+
+
diff --git a/sc/source/ui/src/namedlg.src b/sc/source/ui/src/namedlg.src
new file mode 100644
index 000000000000..51ad9f1d4f78
--- /dev/null
+++ b/sc/source/ui/src/namedlg.src
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "namedlg.hrc"
+ModelessDialog RID_SCDLG_NAMES
+{
+ OutputSize = TRUE ;
+ HelpId = FID_DEFINE_NAME ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 222 , 142 ) ;
+ Text [ en-US ] = "Define Names" ;
+ Moveable = TRUE ;
+ // Closeable = TRUE; // Dieser Dialog hat einen Cancel-Button !
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 166 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 166 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 166 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 166 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Hinzu~fügen : Hinzu~f³gen */
+ Text [ en-US ] = "~Add" ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 166 , 92 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen : ~L÷schen */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_NAME
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "Name" ;
+ };
+ ComboBox ED_NAME
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 145 , 92 ) ;
+ TabStop = TRUE ;
+ VScroll = TRUE ;
+ Sort = TRUE ;
+ };
+ FixedLine FL_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 6 , 112 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "Assigned to" ;
+ };
+ Edit ED_ASSIGN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 123 ) ;
+ Size = MAP_APPFONT ( 131 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 145 , 122 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ MoreButton BTN_MORE
+ {
+ Pos = MAP_APPFONT ( 166 , 122 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ MapUnit = MAP_APPFONT ;
+ Delta = 41 ;
+ };
+ FixedLine FL_TYPE
+ {
+ Pos = MAP_APPFONT ( 6 , 142 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "Area type" ;
+ };
+ CheckBox BTN_PRINTAREA
+ {
+ Pos = MAP_APPFONT ( 12 , 153 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "~Print range" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_CRITERIA
+ {
+ Pos = MAP_APPFONT ( 12 , 167 ) ;
+ Size = MAP_APPFONT ( 60 , 10 ) ;
+ Text [ en-US ] = "~Filter" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_ROWHEADER
+ {
+ Pos = MAP_APPFONT ( 75 , 167 ) ;
+ Size = MAP_APPFONT ( 82 , 10 ) ;
+ Text [ en-US ] = "Repeat ~row" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_COLHEADER
+ {
+ Pos = MAP_APPFONT ( 75 , 153 ) ;
+ Size = MAP_APPFONT ( 82 , 10 ) ;
+ Text [ en-US ] = "Repeat ~column" ;
+ TabStop = TRUE ;
+ };
+ String STR_ADD
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Hinzu~fügen : Hinzu~f³gen */
+ Text [ en-US ] = "~Add" ;
+ };
+ String STR_MODIFY
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? ~Ändern : ~Žndern */
+ Text [ en-US ] = "Mod~ify" ;
+ };
+ String STR_INVALIDSYMBOL
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Ungültiger Ausdruck : Ung³ltiger Ausdruck */
+ Text [ en-US ] = "Invalid expression" ;
+ };
+};
diff --git a/sc/source/ui/src/opredlin.src b/sc/source/ui/src/opredlin.src
new file mode 100644
index 000000000000..34813be0f786
--- /dev/null
+++ b/sc/source/ui/src/opredlin.src
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "opredlin.hrc"
+TabPage RID_SCPAGE_OPREDLINE
+{
+ HelpId = HID_SCPAGE_OPREDLINE ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedText FT_CONTENT
+ {
+ HelpID = 1 ;
+ Pos = MAP_APPFONT ( 12 , 15 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "Chan~ges" ;
+ };
+ FixedText FT_REMOVE
+ {
+ Pos = MAP_APPFONT ( 12 , 31 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Deletions" ;
+ };
+ FixedText FT_INSERT
+ {
+ Pos = MAP_APPFONT ( 12 , 47 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Insertions" ;
+ };
+ FixedText FT_MOVE
+ {
+ Pos = MAP_APPFONT ( 12 , 63 ) ;
+ Size = MAP_APPFONT ( 70 , 10 ) ;
+ Text [ en-US ] = "~Moved entries" ;
+ };
+ FixedLine GB_COLORCHGS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Colors for changes" ;
+ };
+ ListBox CLB_CONTENT
+ {
+ Pos = MAP_APPFONT ( 90 , 14 ) ;
+ Size = MAP_APPFONT ( 120 , 86 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox CLB_REMOVE
+ {
+ Pos = MAP_APPFONT ( 90 , 30 ) ;
+ Size = MAP_APPFONT ( 120 , 86 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox CLB_INSERT
+ {
+ Pos = MAP_APPFONT ( 90 , 46 ) ;
+ Size = MAP_APPFONT ( 120 , 86 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ ListBox CLB_MOVE
+ {
+ Pos = MAP_APPFONT ( 90 , 62 ) ;
+ Size = MAP_APPFONT ( 120 , 86 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ String STR_AUTHOR
+ {
+ Text [ en-US ] = "By author" ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/optdlg.src b/sc/source/ui/src/optdlg.src
new file mode 100644
index 000000000000..3f13db0bd8c4
--- /dev/null
+++ b/sc/source/ui/src/optdlg.src
@@ -0,0 +1,865 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "optdlg.hrc"
+
+/**************************************************************************/
+/* */
+/* */
+/* */
+/**************************************************************************/
+
+TabPage RID_SCPAGE_CALC
+{
+ HelpId = HID_SCPAGE_CALC ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ CheckBox BTN_ITERATE
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Iterations" ;
+ };
+ FixedText FT_STEPS
+ {
+ Pos = MAP_APPFONT ( 20 , 28 ) ;
+ Size = MAP_APPFONT ( 58 , 8 ) ;
+ Text [ en-US ] = "~Steps" ;
+ };
+ FixedText FT_EPS
+ {
+ Pos = MAP_APPFONT ( 20 , 42 ) ;
+ Size = MAP_APPFONT ( 58 , 16 ) ;
+ Text [ en-US ] = "~Minimum Change" ;
+ WordBreak = TRUE ;
+ };
+ NumericField ED_STEPS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 82 , 26 ) ;
+ Size = MAP_APPFONT ( 42 , 12 ) ;
+ TabStop = TRUE ;
+ Minimum = 1 ;
+ Maximum = 1000 ;
+ Left = TRUE ;
+ };
+ Edit ED_EPS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 82 , 42 ) ;
+ Size = MAP_APPFONT ( 42 , 12 ) ;
+ };
+ FixedLine GB_ZREFS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Iterative references" ;
+ };
+ RadioButton BTN_DATESTD
+ {
+ Pos = MAP_APPFONT ( 139 , 14 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "12/30/1899 (defa~ult)" ;
+ QuickHelpText [ en-US ] = "Value 0 corresponds to 12/30/1899" ;
+ };
+ RadioButton BTN_DATESC10
+ {
+ Pos = MAP_APPFONT ( 139 , 28 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? 01.01.1900 ( Star~Calc 1.0 ) : StarCa~lc 1.0 */
+ Text [ en-US ] = "01/01/1900 (Star~Calc 1.0)" ;
+ QuickHelpText [ en-US ] = "Value 0 corresponds to 01/01/1900" ;
+ };
+ RadioButton BTN_DATE1904
+ {
+ Pos = MAP_APPFONT ( 139 , 42 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~01.01.1904 : ~1904 */
+ Text [ en-US ] = "~01/01/1904" ;
+ QuickHelpText [ en-US ] = "0 corresponds to 01/01/1904" ;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 130 , 14 ) ;
+ Size = MAP_APPFONT ( 1 , 44 ) ;
+ };
+ FixedLine GB_DATE
+ {
+ Pos = MAP_APPFONT ( 133 , 3 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Date" ;
+ };
+ FixedLine FL_H_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 6 , 64 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ };
+ CheckBox BTN_CASE
+ {
+ Pos = MAP_APPFONT ( 12 , 77 ) ;
+ Size = MAP_APPFONT ( 130 , 10 ) ;
+ Text [ en-US ] = "Case se~nsitive" ;
+ };
+ CheckBox BTN_CALC
+ {
+ Pos = MAP_APPFONT ( 12 , 91 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Precision as shown" ;
+ };
+ CheckBox BTN_MATCH
+ {
+ Pos = MAP_APPFONT ( 12 , 105 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Search criteria = and <> must apply to ~whole cells" ;
+ };
+ CheckBox BTN_REGEX
+ {
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Enable regular expressions in formulas" ;
+ };
+ CheckBox BTN_LOOKUP
+ {
+ Pos = MAP_APPFONT ( 12 , 133 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Automatically find column and row labels " ;
+ };
+ CheckBox BTN_GENERAL_PREC
+ {
+ Pos = MAP_APPFONT ( 12 , 147 ) ;
+ Size = MAP_APPFONT ( 148 , 10 ) ;
+ Text [ en-US ] = "Limit decimals for general number format" ;
+ };
+ FixedText FT_PREC
+ {
+ Pos = MAP_APPFONT ( 138 , 148 ) ;
+ Size = MAP_APPFONT ( 84 , 8 ) ;
+ Text [ en-US ] = "~Decimal places" ;
+ Right = TRUE ;
+ };
+ NumericField ED_PREC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 226 , 146 ) ;
+ Size = MAP_APPFONT ( 25 , 12 ) ;
+ Maximum = 20 ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ };
+};
+
+/**************************************************************************/
+/* */
+/* */
+/* */
+/**************************************************************************/
+
+TabPage RID_SCPAGE_FORMULA
+{
+ HelpId = HID_SCPAGE_FORMULA ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+
+ FixedLine FL_FORMULA_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Formula options";
+ };
+
+ FixedText FT_FORMULA_SYNTAX
+ {
+ Pos = MAP_APPFONT ( 21, 16 ) ;
+ Size = MAP_APPFONT ( 80, 8 ) ;
+ Text [ en-US ] = "Formula ~syntax" ;
+ };
+
+ ListBox LB_FORMULA_SYNTAX
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 85, 14 ) ;
+ Size = MAP_APPFONT ( 60, 46 ) ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Calc A1" ; Default ; > ;
+ < "Excel A1" ; Default ; > ;
+ < "Excel R1C1" ; Default ; > ;
+ };
+ };
+
+ CheckBox CB_ENGLISH_FUNC_NAME
+ {
+ Pos = MAP_APPFONT ( 12, 31 ) ;
+ Size = MAP_APPFONT ( 120, 8 ) ;
+ Text [ en-US ] = "Use English function names" ;
+ };
+
+ FixedLine FL_FORMULA_SEPS
+ {
+ Pos = MAP_APPFONT ( 6 , 46 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Separators";
+ };
+
+ FixedText FT_FORMULA_SEP_ARG
+ {
+ Pos = MAP_APPFONT ( 21, 59 );
+ Size = MAP_APPFONT ( 60, 8 );
+ Text [ en-US ] = "~Function";
+ };
+
+ Edit ED_FORMULA_SEP_ARG
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 75, 57 );
+ Size = MAP_APPFONT ( 10, 12 );
+ };
+
+ FixedText FT_FORMULA_SEP_ARRAY_C
+ {
+ Pos = MAP_APPFONT ( 21, 77 );
+ Size = MAP_APPFONT ( 60, 8 );
+ Text [ en-US ] = "Array co~lumn";
+ };
+
+ Edit ED_FORMULA_SEP_ARRAY_C
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 75, 75 );
+ Size = MAP_APPFONT ( 10, 12 );
+ };
+
+ FixedText FT_FORMULA_SEP_ARRAY_R
+ {
+ Pos = MAP_APPFONT ( 21, 95 );
+ Size = MAP_APPFONT ( 60, 8 );
+ Text [ en-US ] = "Array ~row";
+ };
+
+ Edit ED_FORMULA_SEP_ARRAY_R
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 75, 93 );
+ Size = MAP_APPFONT ( 10, 12 );
+ };
+
+ PushButton BTN_FORMULA_SEP_RESET
+ {
+ Pos = MAP_APPFONT ( 21, 113 );
+ Size = MAP_APPFONT ( 40, 14 );
+ Text [ en-US ] = "Rese~t";
+ };
+};
+
+TabPage RID_SCPAGE_COMPATIBILITY
+{
+ HelpId = HID_SCPAGE_COMPATIBILITY ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+
+ FixedLine FL_KEY_BINDINGS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Key bindings";
+ };
+
+ FixedText FT_KEY_BINDINGS
+ {
+ Pos = MAP_APPFONT ( 12, 16 ) ;
+ Size = MAP_APPFONT ( 165, 24 ) ;
+ Wordbreak = TRUE;
+ Text [ en-US ] = "Select desired ~key binding type. Changing the key binding type may overwrite some of the existing key bindings." ;
+ };
+
+ ListBox LB_KEY_BINDINGS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 179, 20 ) ;
+ Size = MAP_APPFONT ( 75, 46 ) ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Default" ; Default ; > ;
+ < "OpenOffice.org legacy" ; Default ; > ;
+ };
+ };
+};
+
+/**************************************************************************/
+/* */
+/* */
+/* */
+/**************************************************************************/
+
+TabPage RID_SCPAGE_USERLISTS
+{
+ HelpId = HID_SCPAGE_USERLISTS ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedText FT_LISTS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ Text [ en-US ] = "~Lists" ;
+ };
+ ListBox LB_LISTS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 15 ) ;
+ Size = MAP_APPFONT ( 93 , 148 ) ;
+ };
+ FixedText FT_ENTRIES
+ {
+ Pos = MAP_APPFONT ( 105 , 3 ) ;
+ Size = MAP_APPFONT ( 93 , 8 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Ein~träge : Ein~trõge */
+ Text [ en-US ] = "~Entries" ;
+ };
+ MultiLineEdit ED_ENTRIES
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 105 , 15 ) ;
+ Size = MAP_APPFONT ( 93 , 148 ) ;
+ VScroll = TRUE ;
+ IgnoreTab = TRUE ;
+ };
+ Edit ED_COPYFROM
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 70 , 167 ) ;
+ Size = MAP_APPFONT ( 128 , 12 ) ;
+ };
+ FixedText FT_COPYFROM
+ {
+ Pos = MAP_APPFONT ( 6 , 168 ) ;
+ Size = MAP_APPFONT ( 62 , 8 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Liste kopieren ~aus : Liste kopieren aus */
+ Text [ en-US ] = "Copy list ~from" ;
+ };
+ PushButton BTN_NEW
+ {
+ Pos = MAP_APPFONT ( 204 , 15 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~New" ;
+ };
+ PushButton BTN_ADD
+ {
+ Pos = MAP_APPFONT ( 204 , 36 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Hinzufügen : ~Hinzuf³gen */
+ Text [ en-US ] = "~Add" ;
+ Disable = TRUE ;
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 204 , 54 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen : ~L÷schen */
+ Text [ en-US ] = "~Delete" ;
+ };
+ PushButton BTN_COPY
+ {
+ Pos = MAP_APPFONT ( 204 , 166 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "~Copy" ;
+ };
+ String STR_DISMISS
+ {
+ Text [ en-US ] = "~Discard" ;
+ };
+ String STR_QUERYREMOVE
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Soll der Eintrag\n#\ngelöscht werden? : Soll der Eintrag\n#\ngel÷scht werden? */
+ Text [ en-US ] = "Should the entry\n#\nbe deleted?" ;
+ };
+ String STR_COPYLIST
+ {
+ Text [ en-US ] = "Copy List" ;
+ };
+ String STR_COPYFROM
+ {
+ Text [ en-US ] = "List from" ;
+ };
+ String STR_COPYERR
+ {
+ Text [ en-US ] = "Cells without text have been ignored." ;
+ };
+};
+
+/**************************************************************************/
+/* */
+/* */
+/* */
+/**************************************************************************/
+
+TabPage RID_SCPAGE_CONTENT
+{
+ HelpId = HID_SCPAGE_CONTENT ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedLine GB_LINES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Visual aids";
+ };
+ CheckBox CB_GRID
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Grid lines" ;
+ };
+ FixedText FT_COLOR
+ {
+ Pos = MAP_APPFONT ( 21 , 28 ) ;
+ Size = MAP_APPFONT ( 31 , 8 ) ;
+ Text [ en-US ] = "~Color" ;
+ };
+ ListBox LB_COLOR
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 54 , 26 ) ;
+ Size = MAP_APPFONT ( 70 , 86 ) ;
+ DropDown = TRUE ;
+ DDExtraWidth = TRUE ;
+ };
+ CheckBox CB_PAGEBREAKS
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Page breaks" ;
+ };
+ CheckBox CB_GUIDELINE
+ {
+ Pos = MAP_APPFONT ( 12 , 56 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Guides ~while moving";
+ };
+ CheckBox CB_HANDLES
+ {
+ Pos = MAP_APPFONT ( 12 , 70 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Simple handles";
+ };
+ CheckBox CB_BIGHANDLES
+ {
+ Pos = MAP_APPFONT ( 12 , 84 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Large handles";
+ };
+ FixedLine FL_SEPARATOR1
+ {
+ Pos = MAP_APPFONT ( 130 , 14 ) ;
+ Size = MAP_APPFONT ( 1 , 88 ) ;
+ };
+ FixedLine GB_DISPLAY
+ {
+ Pos = MAP_APPFONT ( 133 , 3 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Display" ;
+ };
+ CheckBox CB_FORMULA
+ {
+ Pos = MAP_APPFONT ( 139 , 14 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Formulas" ;
+ };
+ CheckBox CB_NIL
+ {
+ Pos = MAP_APPFONT ( 139 , 27 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Zero val~ues" ;
+ };
+ CheckBox CB_ANNOT
+ {
+ Pos = MAP_APPFONT ( 139 , 40 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Comment indicator" ;
+ };
+ CheckBox CB_VALUE
+ {
+ Pos = MAP_APPFONT ( 139 , 53 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Value h~ighlighting" ;
+ };
+ CheckBox CB_ANCHOR
+ {
+ Pos = MAP_APPFONT ( 139 , 66 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Anchor" ;
+ };
+ CheckBox CB_CLIP
+ {
+ Pos = MAP_APPFONT ( 139 , 79 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Te~xt overflow" ;
+ };
+ CheckBox CB_RFIND
+ {
+ Pos = MAP_APPFONT ( 139 , 92 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Show references in color" ;
+ };
+ FixedLine GB_OBJECT
+ {
+ Pos = MAP_APPFONT ( 6 , 100 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Objects" ;
+ };
+ FixedText FT_OBJGRF
+ {
+ Pos = MAP_APPFONT ( 12 , 113 ) ;
+ Size = MAP_APPFONT ( 68 , 8 ) ;
+ Text [ en-US ] = "Ob~jects/Graphics" ;
+ };
+ ListBox LB_OBJGRF
+ {
+ Pos = MAP_APPFONT ( 84 , 111 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ Border = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Show" ; Default ; > ;
+ < "Hide" ; Default ; > ;
+ };
+ };
+ FixedText FT_DIAGRAM
+ {
+ Pos = MAP_APPFONT ( 12 , 129 ) ;
+ Size = MAP_APPFONT ( 68 , 8 ) ;
+ Text [ en-US ] = "Cha~rts" ;
+ };
+ ListBox LB_DIAGRAM
+ {
+ Pos = MAP_APPFONT ( 84 , 127 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ Border = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Show" ; Default ; > ;
+ < "Hide" ; Default ; > ;
+ };
+
+ };
+ FixedText FT_DRAW
+ {
+ Pos = MAP_APPFONT ( 12 , 145 ) ;
+ Size = MAP_APPFONT ( 68 , 8 ) ;
+ Text [ en-US ] = "~Drawing objects" ;
+ };
+ ListBox LB_DRAW
+ {
+ Pos = MAP_APPFONT ( 84 , 143 ) ;
+ Size = MAP_APPFONT ( 40 , 46 ) ;
+ Border = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Show" ; Default ; > ;
+ < "Hide" ; Default ; > ;
+ };
+
+ };
+ FixedLine GB_ZOOM
+ {
+ Pos = MAP_APPFONT ( 6 , 160 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Zoom";
+ };
+ CheckBox CB_SYNCZOOM
+ {
+ Pos = MAP_APPFONT ( 12 , 171 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "S~ynchronize sheets" ;
+ };
+ FixedLine FL_SEPARATOR2
+ {
+ Pos = MAP_APPFONT ( 130 , 119 ) ;
+ Size = MAP_APPFONT ( 1 , 62 ) ;
+ };
+ FixedLine GB_WINDOW
+ {
+ Pos = MAP_APPFONT ( 133 , 108 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Window" ;
+ };
+ CheckBox CB_ROWCOLHEADER
+ {
+ Pos = MAP_APPFONT ( 139 , 119 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Colu~mn/row headers" ;
+ };
+ CheckBox CB_HSCROLL
+ {
+ Pos = MAP_APPFONT ( 139 , 132 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Hori~zontal scroll bar" ;
+ };
+ CheckBox CB_VSCROLL
+ {
+ Pos = MAP_APPFONT ( 139 , 145 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Vertical scroll bar" ;
+ };
+ CheckBox CB_TBLREG
+ {
+ Pos = MAP_APPFONT ( 139 , 158 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "Sh~eet tabs" ;
+ };
+ CheckBox CB_OUTLINE
+ {
+ Pos = MAP_APPFONT ( 139 , 171 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ Text [ en-US ] = "~Outline symbols" ;
+ };
+};
+
+/**************************************************************************/
+/* */
+/* */
+/* */
+/**************************************************************************/
+
+
+TabPage RID_SCPAGE_LAYOUT
+{
+ HelpId = HID_SCPAGE_LAYOUT ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedLine GB_UNIT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 115 , 8 ) ;
+ Text [ en-US ] = "Metrics";
+ };
+ FixedText FT_UNIT
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Measurement ~unit";
+ };
+ ListBox LB_UNIT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 14 ) ;
+ Size = MAP_APPFONT ( 46 , 52 ) ;
+ DropDown = TRUE ;
+ };
+ StringArray ST_UNIT
+ {
+ ItemList [ en-US ] =
+ {
+ < "Millimeter" ; FUNIT_MM ; > ;
+ < "Centimeter" ; FUNIT_CM ; > ;
+ < "Meter" ; FUNIT_M ; > ;
+ < "Kilometer" ; FUNIT_KM ; > ;
+ < "Inch" ; FUNIT_INCH ; > ;
+ < "Foot" ; FUNIT_FOOT ; > ;
+ < "Miles" ; FUNIT_MILE ; > ;
+ < "Pica" ; FUNIT_PICA ; > ;
+ < "Point" ; FUNIT_POINT ; > ;
+ };
+ };
+ FixedText FT_TAB
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "~Tab stops";
+ };
+ MetricField MF_TAB
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 72 , 30 ) ;
+ Size = MAP_APPFONT ( 46 , 12 ) ;
+ Left = TRUE ;
+ Repeat = TRUE ;
+ Spin = TRUE ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_CM ;
+ SpinSize = 10 ;
+ Minimum = 50 ;
+ Maximum = 9999 ;
+ First = 50 ;
+ Last = 2000 ;
+ };
+ FixedLine FL_SEPARATOR
+ {
+ Pos = MAP_APPFONT ( 124 , 14 ) ;
+ Size = MAP_APPFONT ( 1 , 49 ) ;
+ };
+ FixedLine GB_LINK
+ {
+ Pos = MAP_APPFONT ( 127 , 3 ) ;
+ Size = MAP_APPFONT ( 127 , 8 ) ;
+ Text [ en-US ] = "Updating";
+ };
+ FixedText FT_UPDATE_LINKS
+ {
+ Pos = MAP_APPFONT ( 133 , 14 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Update links when opening";
+ };
+ RadioButton RB_ALWAYS
+ {
+ Pos = MAP_APPFONT ( 139 , 25 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Always";
+ };
+ RadioButton RB_REQUEST
+ {
+ Pos = MAP_APPFONT ( 139 , 39 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~On request";
+ };
+ RadioButton RB_NEVER
+ {
+ Pos = MAP_APPFONT ( 139 , 53 ) ;
+ Size = MAP_APPFONT ( 112 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Never";
+ };
+ FixedLine GB_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 69 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Input settings";
+ };
+ CheckBox CB_ALIGN
+ {
+ Pos = MAP_APPFONT ( 12 , 82 ) ;
+ Size = MAP_APPFONT ( 175 , 10 ) ;
+ Text [ en-US ] = "Press Enter to ~move selection" ;
+ };
+ ListBox LB_ALIGN
+ {
+ Pos = MAP_APPFONT ( 191 , 80 ) ;
+ Size = MAP_APPFONT ( 60 , 60 ) ;
+ Border = TRUE ;
+ DropDown = TRUE ;
+ // Reihenfolge der Strings wie enum ScDirection
+ StringList [ en-US ] =
+ {
+ < "Down" ; Default ; > ;
+ < "Right" ; Default ; > ;
+ < "Up" ; Default ; > ;
+ < "Left" ; Default ; > ;
+ };
+ };
+ CheckBox CB_EDITMODE
+ {
+ Pos = MAP_APPFONT ( 12 , 96 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Press Enter to switch to ~edit mode" ;
+ };
+ CheckBox CB_FORMAT
+ {
+ Pos = MAP_APPFONT ( 12 , 110 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Expand ~formatting" ;
+ };
+ CheckBox CB_EXPREF
+ {
+ Pos = MAP_APPFONT ( 12 , 124 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Expand ~references when new columns/rows are inserted" ;
+ };
+ CheckBox CB_MARKHDR
+ {
+ Pos = MAP_APPFONT ( 12 , 138 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Highlight sele~ction in column/row headers" ;
+ };
+ CheckBox CB_TEXTFMT
+ {
+ Pos = MAP_APPFONT ( 12 , 152 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Use printer metrics for text formatting";
+ };
+ CheckBox CB_REPLWARN
+ {
+ Pos = MAP_APPFONT ( 12 , 166 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Show overwrite ~warning when pasting data";
+ };
+};
+
+/**************************************************************************/
+/* */
+/* */
+/* */
+/**************************************************************************/
+
+TabPage RID_SCPAGE_PRINT
+{
+ HelpId = HID_SCPAGE_PRINT ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ FixedLine FL_PAGES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Pages";
+ };
+ CheckBox BTN_SKIPEMPTYPAGES
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Suppress output of empty pages";
+ };
+ FixedLine FL_SHEETS
+ {
+ Pos = MAP_APPFONT ( 6 , 30 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Sheets";
+ };
+ CheckBox BTN_SELECTEDSHEETS
+ {
+ Pos = MAP_APPFONT ( 12 , 41 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Print only selected sheets";
+ };
+};
diff --git a/sc/source/ui/src/optsolver.src b/sc/source/ui/src/optsolver.src
new file mode 100644
index 000000000000..28ca5ae9afec
--- /dev/null
+++ b/sc/source/ui/src/optsolver.src
@@ -0,0 +1,540 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "optsolver.hrc"
+
+ModelessDialog RID_SCDLG_OPTSOLVER
+{
+ OutputSize = TRUE ;
+ HelpId = SID_OPENDLG_OPTSOLVER ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 230 , 210 ) ;
+ Text [ en-US ] = "Solver" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+
+ FixedText FT_OBJECTIVECELL
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Text [ en-US ] = "Target cell" ;
+ };
+ Edit ED_OBJECTIVECELL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 67 , 6 ) ;
+ Size = MAP_APPFONT ( 130 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_OBJECTIVECELL
+ {
+ Pos = MAP_APPFONT ( 199 , 5 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+
+ FixedText FT_DIRECTION
+ {
+ Pos = MAP_APPFONT ( 6 , 24 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Text [ en-US ] = "Optimize result to" ;
+ };
+ RadioButton RB_MAX
+ {
+ Pos = MAP_APPFONT ( 67 , 24 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ Text [ en-US ] = "Maximum" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_MIN
+ {
+ Pos = MAP_APPFONT ( 67 , 38 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ Text [ en-US ] = "Minimum" ;
+ TabStop = TRUE ;
+ };
+ RadioButton RB_VALUE
+ {
+ Pos = MAP_APPFONT ( 67 , 52 ) ;
+ Size = MAP_APPFONT ( 59 , 10 ) ;
+ Text [ en-US ] = "Value of" ;
+ TabStop = TRUE ;
+ };
+ Edit ED_TARGET
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 128 , 50 ) ;
+ Size = MAP_APPFONT ( 69 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_TARGET
+ {
+ Pos = MAP_APPFONT ( 199 , 49 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+
+ FixedText FT_VARIABLECELLS
+ {
+ Pos = MAP_APPFONT ( 6 , 68 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Text [ en-US ] = "By changing cells" ;
+ };
+ Edit ED_VARIABLECELLS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 67 , 66 ) ;
+ Size = MAP_APPFONT ( 130 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_VARIABLECELLS
+ {
+ Pos = MAP_APPFONT ( 199 , 65 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+
+ FixedLine FL_CONDITIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 88 ) ;
+ Size = MAP_APPFONT ( 221 , 8 ) ;
+ Text [ en-US ] = "Limiting conditions" ;
+ };
+
+ FixedText FT_CELLREF
+ {
+ Pos = MAP_APPFONT ( 12 , 102 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ Text [ en-US ] = "Cell reference" ;
+ };
+ FixedText FT_OPERATOR
+ {
+ Pos = MAP_APPFONT ( 84 , 102 ) ;
+ Size = MAP_APPFONT ( 38 , 8 ) ;
+ Text [ en-US ] = "Operator" ;
+ };
+ FixedText FT_CONSTRAINT
+ {
+ Pos = MAP_APPFONT ( 128 , 102 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ Text [ en-US ] = "Value" ;
+ };
+
+ Edit ED_LEFT1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 114 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_LEFT1
+ {
+ Pos = MAP_APPFONT ( 67 , 113 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ListBox LB_OP1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 84 , 114 ) ;
+ Size = MAP_APPFONT ( 38 , 56 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "<=" ; Default ; > ;
+ < "=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "Integer" ; Default ; > ;
+ < "Binary" ; Default ; > ;
+ };
+ };
+ Edit ED_RIGHT1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 128 , 114 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_RIGHT1
+ {
+ Pos = MAP_APPFONT ( 183 , 113 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ImageButton IB_DELETE1
+ {
+ Pos = MAP_APPFONT ( 199 , 113 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Remove" ;
+ // image is set dynamically
+ };
+
+ Edit ED_LEFT2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 129 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_LEFT2
+ {
+ Pos = MAP_APPFONT ( 67 , 128 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ListBox LB_OP2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 84 , 129 ) ;
+ Size = MAP_APPFONT ( 38 , 56 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "<=" ; Default ; > ;
+ < "=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "Integer" ; Default ; > ;
+ < "Binary" ; Default ; > ;
+ };
+ };
+ Edit ED_RIGHT2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 128 , 129 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_RIGHT2
+ {
+ Pos = MAP_APPFONT ( 183 , 128 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ImageButton IB_DELETE2
+ {
+ Pos = MAP_APPFONT ( 199 , 128 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Remove" ;
+ // image is set dynamically
+ };
+
+ Edit ED_LEFT3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 144 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_LEFT3
+ {
+ Pos = MAP_APPFONT ( 67 , 143 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ListBox LB_OP3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 84 , 144 ) ;
+ Size = MAP_APPFONT ( 38 , 56 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "<=" ; Default ; > ;
+ < "=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "Integer" ; Default ; > ;
+ < "Binary" ; Default ; > ;
+ };
+ };
+ Edit ED_RIGHT3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 128 , 144 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_RIGHT3
+ {
+ Pos = MAP_APPFONT ( 183 , 143 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ImageButton IB_DELETE3
+ {
+ Pos = MAP_APPFONT ( 199 , 143 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Remove" ;
+ // image is set dynamically
+ };
+
+ Edit ED_LEFT4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 159 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_LEFT4
+ {
+ Pos = MAP_APPFONT ( 67 , 158 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ListBox LB_OP4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 84 , 159 ) ;
+ Size = MAP_APPFONT ( 38 , 56 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "<=" ; Default ; > ;
+ < "=" ; Default ; > ;
+ < ">=" ; Default ; > ;
+ < "Integer" ; Default ; > ;
+ < "Binary" ; Default ; > ;
+ };
+ };
+ Edit ED_RIGHT4
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 128 , 159 ) ;
+ Size = MAP_APPFONT ( 53 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton IB_RIGHT4
+ {
+ Pos = MAP_APPFONT ( 183 , 158 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ ImageButton IB_DELETE4
+ {
+ Pos = MAP_APPFONT ( 199 , 158 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = TRUE ;
+ QuickHelpText [ en-US ] = "Remove" ;
+ // image is set dynamically
+ };
+
+ ScrollBar SB_SCROLL
+ {
+ Pos = MAP_APPFONT ( 216, 113 ) ;
+ Size = MAP_APPFONT ( 8 , 59 ) ;
+ VScroll = TRUE ;
+ };
+
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 179 ) ;
+ Size = MAP_APPFONT ( 230 , 8 ) ;
+ };
+
+ PushButton BTN_OPTIONS
+ {
+ Pos = MAP_APPFONT ( 6 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Options..." ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 62 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CLOSE
+ {
+ Pos = MAP_APPFONT ( 118 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Close" ;
+ };
+ PushButton BTN_SOLVE
+ {
+ Pos = MAP_APPFONT ( 174 , 190 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Solve" ;
+ DefButton = TRUE ;
+ };
+
+ // IMG_DEL_H not used - image is set dynamically
+
+ String STR_INVALIDINPUT
+ {
+ Text [ en-US ] = "Invalid input." ;
+ };
+ String STR_INVALIDCONDITION
+ {
+ Text [ en-US ] = "Invalid condition." ;
+ };
+};
+
+
+ModelessDialog RID_SCDLG_SOLVER_PROGRESS
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_SOLVER_PROGRESS ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 118 , 72 ) ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_PROGRESS
+ {
+ Pos = MAP_APPFONT ( 6 , 11 ) ;
+ Size = MAP_APPFONT ( 106 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "Solving in progress..." ;
+ };
+ FixedText FT_TIMELIMIT
+ {
+ Pos = MAP_APPFONT ( 6 , 25 ) ;
+ Size = MAP_APPFONT ( 106 , 8 ) ;
+ Center = TRUE ;
+ Text [ en-US ] = "(time limit # seconds)" ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 41 ) ;
+ Size = MAP_APPFONT ( 118 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 34 , 52 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ Text [ en-US ] = "Solving..." ;
+};
+
+
+ModalDialog RID_SCDLG_SOLVER_NOSOLUTION
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_SOLVER_NOSOLUTION ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 118 , 72 ) ;
+ Moveable = TRUE ;
+ FixedText FT_NOSOLUTION
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 106 , 8 ) ;
+ Text [ en-US ] = "No solution was found." ;
+ };
+ FixedText FT_ERRORTEXT
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 106 , 16 ) ;
+ WordBreak = TRUE ;
+ // text is dynamic
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 41 ) ;
+ Size = MAP_APPFONT ( 118 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 34 , 52 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ Text [ en-US ] = "No Solution" ;
+};
+
+
+ModalDialog RID_SCDLG_SOLVER_SUCCESS
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_SOLVER_SUCCESS ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 138 , 89 ) ;
+ Moveable = TRUE ;
+ FixedText FT_SUCCESS
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 126 , 8 ) ;
+ Text [ en-US ] = "Solving successfully finished." ;
+ };
+ FixedText FT_RESULT
+ {
+ Pos = MAP_APPFONT ( 6 , 22 ) ;
+ Size = MAP_APPFONT ( 126 , 8 ) ;
+ Text [ en-US ] = "Result:" ;
+ };
+ FixedText FT_QUESTION
+ {
+ Pos = MAP_APPFONT ( 6 , 36 ) ;
+ Size = MAP_APPFONT ( 126 , 16 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Do you want to keep the result or do you want to restore previous values?" ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 58 ) ;
+ Size = MAP_APPFONT ( 138 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "Keep Result" ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 72 , 69 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Restore Previous" ;
+ };
+ Text [ en-US ] = "Solving Result" ;
+};
+
diff --git a/sc/source/ui/src/popup.src b/sc/source/ui/src/popup.src
new file mode 100644
index 000000000000..a4f96b4e8969
--- /dev/null
+++ b/sc/source/ui/src/popup.src
@@ -0,0 +1,544 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> #include <sfx.hrc>
+#include <svx/globlmn.hrc>
+
+
+ // Popup-Menues ----------------------------------------------------------------
+
+String RID_POPUP_CELLS
+{
+ Text [ en-US ] = "Cell pop-up menu" ;
+};
+
+Menu RID_POPUP_CELLS
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_CELL_FORMAT_RESET ;
+ HelpId = SID_CELL_FORMAT_RESET ;
+ Text [ en-US ] = "~Default Formatting" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_CELL_FORMAT ;
+ HelpId = FID_CELL_FORMAT ;
+ Text [ en-US ] = "~Format Cells..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_INS_CELL ;
+ HelpId = FID_INS_CELL ;
+ Text [ en-US ] = "~Insert..." ;
+ };
+ MenuItem
+ {
+ Identifier = FID_DELETE_CELL ;
+ HelpId = FID_DELETE_CELL ;
+ Text [ en-US ] = "De~lete..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DELETE ;
+ HelpId = SID_DELETE ;
+ Text [ en-US ] = "Delete C~ontents..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = SID_INSERT_POSTIT ;
+ HelpId = SID_INSERT_POSTIT ;
+ Text [ en-US ] = "Insert Co~mment" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DELETE_NOTE ;
+ HelpId = SID_DELETE_NOTE ;
+ Text [ en-US ] = "D~elete Comment" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_NOTE_VISIBLE ;
+ HelpId = FID_NOTE_VISIBLE ;
+ Text [ en-US ] = "Sho~w Comment" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+
+ MenuItem
+ {
+ Identifier = SID_CUT ;
+ HelpId = SID_CUT ;
+ Text [ en-US ] = "Cu~t" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_COPY ;
+ HelpId = SID_COPY ;
+ Text [ en-US ] = "~Copy" ;
+ };
+
+ MenuItem
+ {
+ Identifier = SID_PASTE ;
+ HelpID = SID_PASTE ;
+ Text [ en-US ] = "~Paste" ;
+ };
+
+ MenuItem
+ {
+ Identifier = SID_PASTE_SPECIAL ;
+ HelpId = SID_PASTE_SPECIAL ;
+ Text [ en-US ] = "P~aste Special..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = SID_DATA_SELECT ;
+ HelpId = SID_DATA_SELECT ;
+ Text [ en-US ] = "~Selection List..." ;
+ };
+ };
+};
+
+String RID_POPUP_TAB
+{
+ Text [ en-US ] = "Sheet bar pop-up menu" ;
+};
+
+Menu RID_POPUP_TAB
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = FID_INS_TABLE ;
+ HelpId = FID_INS_TABLE ;
+ Text [ en-US ] = "~Insert Sheet..." ;
+ };
+ MenuItem
+ {
+ Identifier = FID_DELETE_TABLE ;
+ HelpId = FID_DELETE_TABLE ;
+ Text [ en-US ] = "~Delete Sheet..." ;
+ };
+ MenuItem
+ {
+ Identifier = FID_TAB_MENU_RENAME ;
+ HelpId = FID_TAB_MENU_RENAME ;
+ Text [ en-US ] = "~Rename Sheet..." ;
+ };
+ MenuItem
+ {
+ Identifier = FID_TAB_MOVE ;
+ HelpId = FID_TAB_MOVE ;
+ Text [ en-US ] = "~Move/Copy Sheet..." ;
+ };
+ MenuItem
+ {
+ Identifier = FID_TAB_SELECTALL ;
+ HelpId = FID_TAB_SELECTALL ;
+ Text [ en-US ] = "Select All S~heets" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_TAB_DESELECTALL ;
+ HelpId = FID_TAB_DESELECTALL ;
+ Text [ en-US ] = "D~eselect All Sheets" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_TAB_RTL ;
+ HelpId = FID_TAB_RTL ;
+ Text [ en-US ] = "S~heet Right-To-Left" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_TAB_EVENTS ;
+ HelpId = FID_TAB_EVENTS ;
+ Text [ en-US ] = "Sheet E~vents..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_TAB_MENU_SET_TAB_BG_COLOR ;
+ HelpId = FID_TAB_MENU_SET_TAB_BG_COLOR ;
+ Text [ en-US ] = "~Tab Color..." ;
+ };
+ };
+};
+
+String RID_POPUP_PIVOT
+{
+ Text [ en-US ] = "DataPilot pop-up menu" ;
+};
+
+Menu RID_POPUP_PIVOT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_OPENDLG_PIVOTTABLE ;
+ HelpId = SID_OPENDLG_PIVOTTABLE ;
+ Text [ en-US ] = "~Start..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_PIVOT_RECALC ;
+ HelpId = SID_PIVOT_RECALC ;
+ Text [ en-US ] = "~Refresh" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DP_FILTER ;
+ HelpId = SID_DP_FILTER ;
+ Text [ en-US ] = "~Filter..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_PIVOT_KILL ;
+ HelpId = SID_PIVOT_KILL ;
+ Text [ en-US ] = "~Delete" ;
+ };
+ };
+};
+
+String RID_POPUP_PREVIEW
+{
+ Text [ en-US ] = "Page Preview pop-up menu" ;
+};
+
+Menu RID_POPUP_PREVIEW
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_PREVIEW_PREVIOUS ;
+ HelpId = SID_PREVIEW_PREVIOUS ;
+ Text [ en-US ] = "~Previous Page" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_PREVIEW_NEXT ;
+ HelpId = SID_PREVIEW_NEXT ;
+ Text [ en-US ] = "~Next Page" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FORMATPAGE ;
+ HelpId = SID_FORMATPAGE ;
+ Text [ en-US ] = "Pa~ge Layout..." ;
+ };
+ MenuItem
+ {
+ Identifier = SID_CLOSEWIN ;
+ HelpId = SID_CLOSEWIN ;
+ Text [ en-US ] = "~Close" ;
+ };
+ MenuItem { Separator = TRUE; };
+ MenuItem
+ {
+ Identifier = SID_PREVIEW_CLOSE ;
+ HelpId = SID_PRINTPREVIEW ;
+ Text [ en-US ] = "Close Pre~view" ;
+ };
+ };
+};
+
+
+String RID_POPUP_EDIT
+{
+ Text [ en-US ] = "Text Input pop-up menu" ;
+};
+
+Menu RID_POPUP_EDIT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_CELL_FORMAT_RESET ;
+ HelpId = SID_CELL_FORMAT_RESET ;
+ Text [ en-US ] = "~Default" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem // Menu-Controller
+ // Menu-Controller
+ // Menu-Controller
+ // Menu-Controller
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONT
+ };
+ MenuItem // Menu-Controller
+ // Menu-Controller
+ // Menu-Controller
+ // Menu-Controller
+ {
+ ITEM_FORMAT_ATTR_CHAR_FONTHEIGHT
+ };
+ MenuItem
+ {
+ Text [ en-US ] = "Style" ;
+ Identifier = RID_MN_FORMAT_STYLE ;
+ HelpID = RID_MN_FORMAT_STYLE ;
+ SubMenu = Menu
+ {
+ ItemList =
+ {
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_WEIGHT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_POSTURE
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_OVERLINE
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_UNDERLINE
+ };
+ MenuItem
+ {
+ Identifier = SID_ULINE_VAL_DOUBLE ;
+ HelpID = SID_ULINE_VAL_DOUBLE ;
+ Text [ en-US ] = "Do~uble Underline" ;
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_STRIKEOUT
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_SHADOWED
+ };
+ MenuItem
+ {
+ ITEM_FORMAT_ATTR_CHAR_CONTOUR
+ };
+ MenuItem
+ {
+ Separator = TRUE ;
+ };
+ MenuItem
+ {
+ Identifier = SID_SET_SUPER_SCRIPT ;
+ HelpID = SID_SET_SUPER_SCRIPT ;
+ Text [ en-US ] = "Su~perscript" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_SET_SUB_SCRIPT ;
+ HelpID = SID_SET_SUB_SCRIPT ;
+ Text [ en-US ] = "Su~bscript" ;
+ };
+ };
+ };
+ Text [ en-US ] = "St~yle";
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ ITEM_FORMAT_CHAR_DLG
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ ITEM_OPEN_HYPERLINK
+ };
+ };
+};
+
+String RID_POPUP_AUDIT
+{
+ Text [ en-US ] = "Detective Fill Mode pop-up menu" ;
+};
+
+Menu RID_POPUP_AUDIT
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_FILL_ADD_PRED ;
+ HelpId = SID_FILL_ADD_PRED ;
+ Text [ en-US ] = "Trace ~Precedent" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FILL_DEL_PRED ;
+ HelpId = SID_FILL_DEL_PRED ;
+ Text [ en-US ] = "~Remove Precedent" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FILL_ADD_SUCC ;
+ HelpId = SID_FILL_ADD_SUCC ;
+ Text [ en-US ] = "~Trace Dependent" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FILL_DEL_SUCC ;
+ HelpId = SID_FILL_DEL_SUCC ;
+ Text [ en-US ] = "Remove Dependent" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DETECTIVE_DEL_ALL ;
+ HelpId = SID_DETECTIVE_DEL_ALL ;
+ Text [ en-US ] = "Remove ~All Traces" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_FILL_NONE ;
+ HelpId = SID_FILL_NONE ;
+ Text [ en-US ] = "Exit Fill Mode" ;
+ };
+ };
+};
+
+String RID_POPUP_PAGEBREAK
+{
+ Text [ en-US ] = "Page Break Preview pop-up menu" ;
+};
+
+Menu RID_POPUP_PAGEBREAK
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = SID_CELL_FORMAT_RESET ;
+ HelpId = SID_CELL_FORMAT_RESET ;
+ Text [ en-US ] = "~Default" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_CELL_FORMAT ;
+ HelpId = FID_CELL_FORMAT ;
+ Text [ en-US ] = "~Format Cells..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_INS_ROWBRK ;
+ HelpId = FID_INS_ROWBRK ;
+ Text [ en-US ] = "Insert ~Row Break" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_INS_COLBRK ;
+ HelpId = FID_INS_COLBRK ;
+ Text [ en-US ] = "Insert ~Column Break" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_DEL_MANUALBREAKS ;
+ HelpId = FID_DEL_MANUALBREAKS ;
+ Text [ en-US ] = "Delete All Manual Breaks" ;
+ };
+ MenuItem
+ {
+ Identifier = FID_RESET_PRINTZOOM ;
+ HelpId = FID_RESET_PRINTZOOM ;
+ Text [ en-US ] = "Reset Scale" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = SID_DEFINE_PRINTAREA ;
+ HelpId = SID_DEFINE_PRINTAREA ;
+ Text [ en-US ] = "Define Print Range" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_ADD_PRINTAREA ;
+ HelpId = SID_ADD_PRINTAREA ;
+ Text [ en-US ] = "Add Print Range" ;
+ };
+ MenuItem
+ {
+ Identifier = SID_DELETE_PRINTAREA ;
+ HelpId = SID_DELETE_PRINTAREA ;
+ Text [ en-US ] = "Undo Print Range" ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = SID_FORMATPAGE ;
+ HelpId = SID_FORMATPAGE ;
+ Text [ en-US ] = "Page Format..." ;
+ };
+ //------------------------------
+ MenuItem { Separator = TRUE ; };
+ //------------------------------
+ MenuItem
+ {
+ Identifier = FID_NOTE_VISIBLE ;
+ HelpId = FID_NOTE_VISIBLE ;
+ Text [ en-US ] = "Sho~w Comment" ;
+ };
+ };
+};
+
+
diff --git a/sc/source/ui/src/pseudo.src b/sc/source/ui/src/pseudo.src
new file mode 100644
index 000000000000..589520ee1eb5
--- /dev/null
+++ b/sc/source/ui/src/pseudo.src
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#include <svx/svxids.hrc>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/sc.src b/sc/source/ui/src/sc.src
new file mode 100644
index 000000000000..4fa37b2dab91
--- /dev/null
+++ b/sc/source/ui/src/sc.src
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> #include <sfx.hrc>
+
+
+
+// App-Titel------------------------------------------------------
+
+String RID_APPTITLE
+{
+ /* ### ACHTUNG: Neuer Text in Resource? StarCalc 4.0 : StarCalc 3.1 */
+ Text [ en-US ] = "%PRODUCTNAME Calc" ;
+};
+
+ // About-Dialog --------------------------------------------------------------
+
+ // Icons & Bitmaps: ----------------------------------------------------------
+
+
+
+ // ???
+String 30001 { Text = "Dummy1" ; };
+String 30002 { Text = "Dummy2" ; };
+String 30006 { Text = "Dummy3" ; };
diff --git a/sc/source/ui/src/scerrors.src b/sc/source/ui/src/scerrors.src
new file mode 100644
index 000000000000..e28dde2f9b8c
--- /dev/null
+++ b/sc/source/ui/src/scerrors.src
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define __RSC
+#include "scerrors.hxx"
+#include "sc.hrc"
+
+Resource RID_ERRHDLSC
+{
+ //------------------------------------------------------------
+ // ERRORS -----------------------------------------------------
+ //------------------------------------------------------------
+ String SCERR_IMPORT_CONNECT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Impossible to connect to the file." ;
+ };
+ String SCERR_IMPORT_OPEN & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "File could not be opened." ;
+ };
+ String SCERR_IMPORT_UNKNOWN & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "An unknown error has occurred." ;
+ };
+ String SCERR_IMPORT_OUTOFMEM & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Not enough memory while importing." ;
+ };
+ String SCERR_IMPORT_UNKNOWN_WK & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Unknown Lotus1-2-3 file format." ;
+ };
+ String SCERR_IMPORT_FORMAT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Error in file structure while importing." ;
+ };
+ String SCERR_IMPORT_NI & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "There is no filter available for this file type." ;
+ };
+ String SCERR_IMPORT_UNKNOWN_BIFF & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Unknown or unsupported Excel file format." ;
+ };
+ String SCERR_IMPORT_NI_BIFF & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Excel file format not yet implemented." ;
+ };
+ String SCERR_IMPORT_FILEPASSWD & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "This file is password-protected." ;
+ };
+ String SCERR_IMPORT_INTERNAL & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Internal import error." ;
+ };
+ String SCERR_IMPORT_8K_LIMIT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The file contains data after row 8192 and therefore can not be read." ;
+ };
+ String SCERR_IMPORT_FILE_ROWCOL & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Format error discovered in the file in sub-document $(ARG1) at $(ARG2)(row,col).";
+ };
+ String SCERR_IMPORT_FORMAT_ROWCOL & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "File format error found at $(ARG1)(row,col)." ;
+ };
+
+ // Export ----------------------------------------------------
+ String SCERR_EXPORT_CONNECT & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Connection to the file could not be established." ;
+ };
+ String SCERR_EXPORT_DATA & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Data could not be written." ;
+ };
+ String SCERR_EXPORT_SQLEXCEPTION & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "$(ARG1)" ;
+ };
+ String SCERR_EXPORT_ENCODING & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Cell $(ARG1) contains characters that are not representable in the selected target character set \"$(ARG2)\"." ;
+ };
+ String SCERR_EXPORT_FIELDWIDTH & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Cell $(ARG1) contains a string that is longer in the selected target character set \"$(ARG2)\" than the given field width." ;
+ };
+ //------------------------------------------------------------
+ // WARNINGS ---------------------------------------------------
+ //------------------------------------------------------------
+ String SCWARN_EXPORT_ASCII & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Only the active sheet was saved." ;
+ };
+ String SCWARN_IMPORT_RANGE_OVERFLOW & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The maximum number of rows has been exceeded. Excess rows were not imported!" ;
+ };
+ String SCWARN_IMPORT_ROW_OVERFLOW & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The data could not be loaded completely because the maximum number of rows per sheet was exceeded." ;
+ };
+ String SCWARN_IMPORT_COLUMN_OVERFLOW & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The data could not be loaded completely because the maximum number of columns per sheet was exceeded." ;
+ };
+ String SCWARN_IMPORT_SHEET_OVERFLOW & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Some sheets could not be loaded because the maximum number of sheets was exceeded." ;
+ };
+ String SCWARN_IMPORT_OPEN_FM3 & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Corresponding FM3-File could not be opened." ;
+ };
+ String SCWARN_IMPORT_WRONG_FM3 & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Error in file structure of corresponding FM3-File." ;
+ };
+ String SCWARN_CORE_HARD_RECALC & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Document too complex for automatic calculation. Press F9 to recalculate." ;
+ };
+ String SCWARN_EXPORT_MAXROW & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The document contains more rows than supported in the selected format.\nAdditional rows were not saved." ;
+ };
+ String SCWARN_IMPORT_INFOLOST & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The document contains information not recognized by this program version.\nResaving the document will delete this information!" ;
+ };
+ String SCWARN_EXPORT_DATALOST & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Not all cell contents could be saved in the specified format." ;
+ };
+ String SCWARN_EXPORT_NONCONVERTIBLE_CHARS & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "The following characters could not be converted to the selected character set\nand were written as &#1234; surrogates:\n\n$(ARG1)";
+ };
+ String SCWARN_IMPORT_FILE_ROWCOL & ERRCODE_RES_MASK
+ {
+ Text [ en-US ] = "Format error discovered in the file in sub-document $(ARG1) at $(ARG2)(row,col).";
+ };
+};
+
diff --git a/sc/source/ui/src/scfuncs.src b/sc/source/ui/src/scfuncs.src
new file mode 100644
index 000000000000..610c1f4b782b
--- /dev/null
+++ b/sc/source/ui/src/scfuncs.src
@@ -0,0 +1,9043 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* Resource file for the function wizard / autopilot.
+ *
+ * All descriptions of functions are collected within the resources
+ * RID_SC_FUNCTION_DESCRIPTIONS1 respectively RID_SC_FUNCTION_DESCRIPTIONS2,
+ * two blocks because otherwise we had a 64kb overflow.
+ *
+ * For every function there is a sub resource with the number of the OpCode of
+ * the function.
+ *
+ * In this sub resource, with index 1 the description of the function is
+ * given, after that follows an
+ *
+ * ExtraData block with:
+ *
+ * Boolean flag whether function is suppressed. Usually 0. This may be
+ * used to add UI string resources before UI freeze if implementation
+ * isn't ready yet without displaying them in the function wizard,
+ * most recent used list and other UI elements. Also not available via
+ * API then.
+ *
+ * Function group (text, math, ...), one of ID_FUNCTION_GRP_...
+ *
+ * Help ID, U2S(HID_FUNC_...)
+ *
+ * Number of parameters. VAR_ARGS if variable number, or
+ * VAR_ARGS+number if number of fixed parameters and variable
+ * arguments following.
+ *
+ * For every parameter:
+ *
+ * Boolean flag whether the parameter is optional.
+ *
+ * Number of suppressed parameters. Usually 0. Same meaning and
+ * mechanism as the flag for the entire function above.
+ *
+ * For every suppressed parameter:
+ *
+ * The parameter number, offset starting with 0. Variable
+ * arguments can't be suppressed!
+ *
+ *
+ * ExtraData block followed by two string resources for each parameter,
+ * first the type or name of the parameter, second a description of the
+ * parameter.
+ */
+
+// Hack:
+#define U2S(x) ((x)-HID_START)
+// Macro U2S: unsigned to signed
+// is needed because the resource compiler only knows signed short int in
+// ExtraData, but the HID_XXX are unsigned and exceed 32k. Code reading the
+// resource entries must consider this and undo the conversion.
+
+#include "scfuncs.hrc" // ID_FUNCTION_GRP_XXX, HID_FUNC_XXX
+#include "formula/compiler.hrc" // SC_OPCODE_XXX
+
+Resource RID_SC_FUNCTION_DESCRIPTIONS1
+{
+ // -=*# Resource for function DBANZAHL #*=-
+ Resource SC_OPCODE_DB_COUNT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Counts the cells of a data range whose contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBANZAHL );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBANZAHL2 #*=-
+ Resource SC_OPCODE_DB_COUNT_2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Counts all non-blank cells of a data range where the content corresponds to the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBANZAHL2 );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBMITTELWERT #*=-
+ Resource SC_OPCODE_DB_AVERAGE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the average value of all the cells of a data range whose contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBMITTELWERT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBAUSZUG #*=-
+ Resource SC_OPCODE_DB_GET
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Defines the contents of the cell of a data range which matches the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBAUSZUG );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBMAX #*=-
+ Resource SC_OPCODE_DB_MAX
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the maximum value from all of the cells of a data range which correspond to the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBMAX );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBMIN #*=-
+ Resource SC_OPCODE_DB_MIN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the minimum of all cells of a data range where the contents correspond to the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBMIN );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBPRODUKT #*=-
+ Resource SC_OPCODE_DB_PRODUCT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Multiplies all cells of a data range where the contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBPRODUKT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBSTDABW #*=-
+ Resource SC_OPCODE_DB_STD_DEV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the standard deviation of all cells in a data range whose contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBSTDABW );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBSTDABWN #*=-
+ Resource SC_OPCODE_DB_STD_DEV_P
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the standard deviation with regards to the population of all cells of a data range matching the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBSTDABWN );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBSUMME #*=-
+ Resource SC_OPCODE_DB_SUM
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Adds all the cells of a data range where the contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBSUMME );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBVARIANZ #*=-
+ Resource SC_OPCODE_DB_VAR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the variance of all the cells in a data range where the contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBVARIANZ );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DBVARIANZEN #*=-
+ Resource SC_OPCODE_DB_VAR_P
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines variance of a population based on all cells in a data range where contents match the search criteria." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATABASE;
+ U2S( HID_FUNC_DBVARIANZEN );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Database" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells containing data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Database field" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates which database field (column) is to be used for the search criteria." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Search criteria" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Defines the cell range containing the search criteria." ;
+ };
+ };
+ // -=*# Resource for function DATUM #*=-
+ Resource SC_OPCODE_GET_DATE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Provides an internal number for the date given." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_DATUM );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "year" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "An integer between 1583 and 9956 or 0 and 99 (19xx or 20xx depending on the defined option)." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "month" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "An integer between 1 and 12 representing the month." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "day" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "An integer between 1 and 31 representing the day of the month." ;
+ };
+ };
+ // -=*# Resource for function DATWERT #*=-
+ Resource SC_OPCODE_GET_DATE_VALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns an internal number for a text having a possible date format." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_DATWERT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A text enclosed in quotation marks which returns a date in a %PRODUCTNAME date format." ;
+ };
+ };
+ // -=*# Resource for function TAG #*=-
+ Resource SC_OPCODE_GET_DAY
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sequential date of the month as an integer (1-31) in relation to the date value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_TAG );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The internal number for the date." ;
+ };
+ };
+ // -=*# Resource for function TAGE360 #*=-
+ Resource SC_OPCODE_GET_DIFF_DATE_360
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the number of days between two dates based on a 360-day year." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_TAGE360 );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Date_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The start date for calculating the difference in days." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Date_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The end date for calculating the difference in days." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Method used to form differences: Type = 0 denotes US method (NASD), Type = 1 denotes the European method." ;
+ };
+ };
+ // -=*# Resource for function STUNDE #*=-
+ Resource SC_OPCODE_GET_HOUR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the sequential number of the hour of the day (0-23) for the time value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_STUNDE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Internal time value" ;
+ };
+ };
+ // -=*# Resource for function MINUTE #*=-
+ Resource SC_OPCODE_GET_MIN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the sequential number for the minute of the hour (0-59) for the time value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_MINUTE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Internal time value." ;
+ };
+ };
+ // -=*# Resource for function MONAT #*=-
+ Resource SC_OPCODE_GET_MONTH
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the sequential number of a month of the year (1-12) for the date value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_MONAT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The internal number of the date." ;
+ };
+ };
+ // -=*# Resource for function JETZT #*=-
+ Resource SC_OPCODE_GET_ACT_TIME
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the current time of the computer." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_JETZT );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function SEKUNDE #*=-
+ Resource SC_OPCODE_GET_SEC
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the sequential number of the second of a minute (0-59) for the time value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_SEKUNDE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The internal time value." ;
+ };
+ };
+ // -=*# Resource for function ZEIT #*=-
+ Resource SC_OPCODE_GET_TIME
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines a time value from the details for hour, minute and second." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_ZEIT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "hour" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The integer for the hour." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "minute" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The integer for the minute." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "second" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The integer for the second." ;
+ };
+ };
+ // -=*# Resource for function ZEITWERT #*=-
+ Resource SC_OPCODE_GET_TIME_VALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a sequential number for a text shown in a possible time entry format." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_ZEITWERT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A text enclosed in quotation marks which returns a time in a %PRODUCTNAME time format." ;
+ };
+ };
+ // -=*# Resource for function HEUTE #*=-
+ Resource SC_OPCODE_GET_ACT_DATE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines the current date of the computer." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_HEUTE );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function WOCHENTAG #*=-
+ Resource SC_OPCODE_GET_DAY_OF_WEEK
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the day of the week for the date value as an integer (1-7)." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_WOCHENTAG );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The internal number for the date." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Fixes the beginning of the week and the type of calculation to be used." ;
+ };
+ };
+ // -=*# Resource for function JAHR #*=-
+ Resource SC_OPCODE_GET_YEAR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the year of a date value as an integer." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_JAHR );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Internal number of the date." ;
+ };
+ };
+ // -=*# Resource for function TAGE #*=-
+ Resource SC_OPCODE_GET_DIFF_DATE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the number of days between two dates." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_TAGE );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Date_2" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The end date for calculating the difference in days." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Date_1" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The start date for calculating the difference in days." ;
+ };
+ };
+ // -=*# Resource for function KALENDERWOCHE #*=-
+ Resource SC_OPCODE_WEEK
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the calendar week corresponding to the given date." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_KALENDERWOCHE );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The internal number of the date." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mode" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Indicates the first day of the week (1 = Sunday, other values = Monday)." ;
+ };
+ };
+ // -=*# Resource for function OSTERSONNTAG #*=-
+ Resource SC_OPCODE_EASTERSUNDAY
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the date of Easter Sunday in a given year.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_DATETIME;
+ U2S( HID_FUNC_OSTERSONNTAG );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "year";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "An integer between 1583 and 9956, or 0 and 99 (19xx or 20xx depending on the option set).";
+ };
+ };
+ // -=*# Resource for function BW #*=-
+ Resource SC_OPCODE_BW
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Present value. Calculates the present value of an investment." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_BW );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest for the period given." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The payment period. The total number of periods in which the annuity is paid." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "PMT" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Regular payments. The constant amount of annuity that is paid in each period." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Future value. The value (final value) to be attained after the last payment." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function ZW #*=-
+ Resource SC_OPCODE_ZW
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Future value. Returns the future value of an investment based on regular payments and a constant interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_ZW );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "PMT" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Regular payments. The constant annuity to be paid in each period." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "PV" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Present value. The current value of a series of payments" ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function ZZR #*=-
+ Resource SC_OPCODE_ZZR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Payment period. Calculates the number of payment periods for an investment based on regular payments and a constant interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_ZZR );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "PMT" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Regular payments. The constant annuity to be paid in each period." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "PV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Present value. The current value of a series of payments" ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Future value. The value (end value) to be attained after the final payment." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function RMZ #*=-
+ Resource SC_OPCODE_RMZ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Regular payments. Returns the periodic payment of an annuity, based on regular payments and a fixed periodic interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_RMZ );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "PV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Present value. The current value of a series of payments" ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Future value. The value (end value) to be attained after the final payment." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function ZINS #*=-
+ Resource SC_OPCODE_ZINS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the constant interest rate of an investment with regular payments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_ZINS );
+ 6; 0; 0; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "PMT" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Regular payments. The constant annuity to be paid in each period." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "PV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Present value. The current value of a series of payments" ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Future value. The value (end value) to be attained after the final payment." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [ en-US ] = "Guess" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "Guess. The estimate of the interest rate for the iterative calculating method." ;
+ };
+ };
+ // -=*# Resource for function ZINSZ #*=-
+ Resource SC_OPCODE_ZINS_Z
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Compounded interest. Calculates the interest payment on the principal for an investment with regular payments and a constant interest rate for a given period." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_ZINSZ );
+ 6; 0; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Period" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Periods. The periods for which the compounded interest is to be calculated. P = 1 denotes for the first period, P = NPER for the last one." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "pv" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Present value. The current value of a series of payments" ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Future value. The value (end value) to be attained after the final payment." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function KAPZ #*=-
+ Resource SC_OPCODE_KAPZ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Repayment. Calculates the repayment amount for a period for an investment whereby the payments are at regular intervals and the interest rate constant." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_KAPZ );
+ 6; 0; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The interest rate per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Period" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Period. The period for which the repayments are to be calculated. Per = 1 denotes for the first period, P = NPER for the last" ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "PV" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The present value. The present value or the amount the annuity is currently worth." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Future value. The value (end value) attained after the last payment has been made." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function KUMKAPITAL #*=-
+ Resource SC_OPCODE_KUM_KAP_Z
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Cumulative Capital. Calculates the total amount of the repayment share in a period for an investment with constant interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_KUMKAPITAL );
+ 6; 0; 0; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "PV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The present value. The present value or the amount the annuity is currently worth." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "S" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The start period. The first period to be taken into account. A = 1 denotes the very first period." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "E" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "End period. The last period to be taken into account." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function KUMZINSZ #*=-
+ Resource SC_OPCODE_KUM_ZINS_Z
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Cumulative compounded interest. Calculates the total amount of the interest share in a period for an investment with a constant interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_KUMZINSZ );
+ 6; 0; 0; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of interest per period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "NPER" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Payment period. The total number of periods in which the annuity (pension) is paid." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "pv" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The present value. The present value or the amount the annuity is currently worth." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "S" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The start period. The first period to be taken into account. A = 1 denotes the very first period." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "E" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "The end period. The last period to be taken into account." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "Type = 1 denotes due at the beginning of the period, = 0 at the end." ;
+ };
+ };
+ // -=*# Resource for function DIA #*=-
+ Resource SC_OPCODE_DIA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the arithmetically declining value of an asset (depreciation) for a specified period." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_DIA );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Cost" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Acquisition costs. The initial cost of the asset." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Salvage" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Salvage: The remaining value of the asset at the end of its life." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Life" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Useful life. The number of periods in the useful life of the asset." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Period" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Period. The depreciation period which must have the same time unit as average useful life." ;
+ };
+ };
+ // -=*# Resource for function LIA #*=-
+ Resource SC_OPCODE_LIA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the linear depreciation per period." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_LIA );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Cost" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Acquisition cost. The initial cost of an asset." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Salvage" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Salvage: The remaining value of the asset at the end of its life." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Life" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Useful life. The number of periods in the useful life of the asset." ;
+ };
+ };
+ // -=*# Resource for function GDA #*=-
+ Resource SC_OPCODE_GDA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the depreciation of an asset for a specific period using the double-declining balance method or declining balance factor." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_GDA );
+ 5; 0; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Cost" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Acquisition costs. The initial cost of the asset." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Salvage" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Salvage: The remaining value of the asset at the end of its life." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Life" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Useful life. The number of periods in the useful life of the asset." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Period" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Period. The depreciation period in the same time unit as the average useful life entry." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "Factor" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Factor. The factor for balance decline. F = 2 means a double declining balance factor" ;
+ };
+ };
+ // -=*# Resource for function GDA2 #*=-
+ Resource SC_OPCODE_GDA_2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the real depreciation of an asset for a specified period using the fixed-declining balance method." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_GDA2 );
+ 5; 0; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Cost" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Acquisition costs: The initial cost of the asset." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Salvage" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Salvage: The remaining value of the asset at the end of its life." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Life" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Useful life. The number of periods in the useful life of the asset." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Period" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Periods: The period for which the depreciation is calculated. The time unit used for period must be the same as that for the useful life." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "month" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "Months: The number of months in the first year of depreciation." ;
+ };
+ };
+ // -=*# Resource for function VDB #*=-
+ Resource SC_OPCODE_VBD
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Variable declining balance. Returns the declining balance depreciation for a particular period." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_VDB );
+ 7; 0; 0; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Cost" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Cost. The initial cost of the asset." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Salvage" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Salvage. The salvage value of an asset at the end of its useful life." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Life" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Useful life. The number of periods in the useful life of the asset." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "S" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Start. The first period for depreciation in the same time unit as the useful life." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "end" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "End. The last period of the depreciation using the same time unit as for the useful life." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [ en-US ] = "Factor" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "Factor. The factor for the reduction of the depreciation. F = 2 denotes double rate depreciation." ;
+ };
+ String 14 // Name of Parameter 7
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 15 // Description of Parameter 7
+ {
+ Text [ en-US ] = "Do not alter. Type = 1 denotes switch to linear depreciation, type = 0 do not switch." ;
+ };
+ };
+ // -=*# Resource for function EFFEKTIV #*=-
+ Resource SC_OPCODE_EFFEKTIV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the annual net interest rate for a nominal interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_EFFEKTIV );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "NOM" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Nominal Interest" ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "P" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Periods. The number of interest payments per year." ;
+ };
+ };
+ // -=*# Resource for function NOMINAL #*=-
+ Resource SC_OPCODE_NOMINAL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the yearly nominal interest rate as an effective interest rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_NOMINAL );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "effect_rate" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The effective interest rate" ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "npery" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Periods. The number of interest payment per year." ;
+ };
+ };
+ // -=*# Resource for function NBW #*=-
+ Resource SC_OPCODE_NBW
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Net present value. Calculates the net present value of an investment based on a series of periodic payments and a discount rate." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_NBW );
+ VAR_ARGS+1; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "RATE" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The rate of discount for one period." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "value " ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Value 1, value 2,... are 1 to 30 arguments representing payments and income." ;
+ };
+ };
+ // -=*# Resource for function IKV #*=-
+ Resource SC_OPCODE_IKV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the actuarial rate of interest of an investment excluding costs or profits." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_IKV );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Values" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "An array or reference to cells whose contents correspond to the payments. " ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Guess" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Guess. An estimated value of the rate of return to be used for the iteration calculation." ;
+ };
+ };
+ // -=*# Resource for function QIKV/MIRR #*=-
+ Resource SC_OPCODE_MIRR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the modified internal rate of return for a series of investments.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_QIKV );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Values";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "An array or reference to cells whose contents correspond to the payments.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "investment";
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Interest rate for investments (the negative values in the array).";
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "reinvest_rate";
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "interest rate for reinvestments (the positive values in the array).";
+ };
+ };
+ // -=*# Resource for function ISPMT #*=-
+ Resource SC_OPCODE_ISPMT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the amount of interest for constant amortization rates.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_ISPMT );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "rate";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Interest rate for a single amortization rate.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Period";
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Number of amortization periods for the calculation of the interest.";
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "total_periods";
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Sum total of amortization periods.";
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "invest";
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Amount of the investment.";
+ };
+ };
+ // -=*# Resource for function LAUFZEIT #*=-
+ Resource SC_OPCODE_LAUFZ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Duration. Calculates the number of periods required by an investment to attain the desired value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_LAUFZEIT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "RATE" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The constant rate of interest." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "pv" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The present value. The current value of the investment." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The future value of the investment." ;
+ };
+ };
+ // -=*# Resource for function ZGZ #*=-
+ Resource SC_OPCODE_ZGZ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Interest. Calculates the interest rate which represents the rate of return from an investment." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_FINANZ;
+ U2S( HID_FUNC_ZGZ );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "P" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number of periods used in the calculation." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "pv" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Present value. The current value of the investment." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "FV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The future value of the investment." ;
+ };
+ };
+ // -=*# Resource for function ISTBEZUG #*=-
+ Resource SC_OPCODE_IS_REF
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value is a reference." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTBEZUG );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTFEHL #*=-
+ Resource SC_OPCODE_IS_ERR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if the value is an error value not equal to #N/A." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTFEHL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTFEHLER #*=-
+ Resource SC_OPCODE_IS_ERROR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if the value is an error value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTFEHLER );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTLEER #*=-
+ Resource SC_OPCODE_IS_EMPTY
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value refers to an empty cell." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTLEER );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTLOG #*=-
+ Resource SC_OPCODE_IS_LOGICAL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if the value carries a logical number format." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTLOG );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTNV #*=-
+ Resource SC_OPCODE_IS_NV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value equals #N/A." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTNV );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTKTEXT #*=-
+ Resource SC_OPCODE_IS_NON_STRING
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if the value is not text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTKTEXT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTTEXT #*=-
+ Resource SC_OPCODE_IS_STRING
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value is text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTTEXT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTZAHL #*=-
+ Resource SC_OPCODE_IS_VALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value is a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTZAHL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTFORMEL #*=-
+ Resource SC_OPCODE_IS_FORMULA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if the cell is a formula cell." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ISTFORMEL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The cell to be checked." ;
+ };
+ };
+ // -=*# Resource for function FORMEL #*=-
+ Resource SC_OPCODE_FORMULA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the formula of a formula cell.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_FORMEL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Reference";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The formula cell.";
+ };
+ };
+ // -=*# Resource for function N #*=-
+ Resource SC_OPCODE_N
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a value to a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_N );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be interpreted as a number." ;
+ };
+ };
+ // -=*# Resource for function NV #*=-
+ Resource SC_OPCODE_NO_VALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Not available. Returns the error value #N/A." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_NV );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function TYP #*=-
+ Resource SC_OPCODE_TYPE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Defines the data type of a value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_TYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the data type is to be determined." ;
+ };
+ };
+ // -=*# Resource for function CELL/ZELLE #*=-
+ Resource SC_OPCODE_CELL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines information about address, formatting or contents of a cell.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_ZELLE );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "info_type";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "String that specifies the type of information.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Reference";
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The position of the cell you want to examine.";
+ };
+ };
+ // -=*# Resource for function AKTUELL #*=-
+ Resource SC_OPCODE_CURRENT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the current value of the formula at the present location. " ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_AKTUELL );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function FALSCH #*=-
+ Resource SC_OPCODE_FALSE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Defines the logical value as FALSE." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_FALSCH );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function NICHT #*=-
+ Resource SC_OPCODE_NOT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Reverses the value of the argument." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_NICHT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Logical value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "An expression that can be either TRUE or FALSE." ;
+ };
+ };
+ // -=*# Resource for function WAHR #*=-
+ Resource SC_OPCODE_TRUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the logical value TRUE." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_WAHR );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function WENN #*=-
+ Resource SC_OPCODE_IF
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Specifies a logical test to be performed." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_WENN );
+ 3; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Test" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Any value or expression which can be either TRUE or FALSE." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Then_value" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The result of the function if the logical test returns a TRUE." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Otherwise_value" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The result of the function if the logical test returns FALSE." ;
+ };
+ };
+ // -=*# Resource for function ODER #*=-
+ Resource SC_OPCODE_OR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if an argument is TRUE." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_ODER );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Logical value " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Logical value 1, logical value 2,... are 1 to 30 conditions to be tested and which return either TRUE or FALSE." ;
+ };
+ };
+ // -=*# Resource for function UND #*=-
+ Resource SC_OPCODE_AND
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if all arguments are TRUE." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_LOGIC;
+ U2S( HID_FUNC_UND );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Logical value " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Logical value 1, logical value 2;...are 1 to 30 conditions to be tested and each returns either TRUE or FALSE." ;
+ };
+ };
+ // -=*# Resource for function ABS #*=-
+ Resource SC_OPCODE_ABS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Absolute value of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ABS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number whose absolute value is to be returned." ;
+ };
+ };
+ // -=*# Resource for function POTENZ #*=-
+ Resource SC_OPCODE_POWER
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a^b, base a raised to the power of exponent b." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_POTENZ );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Base" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The base a of the power a^b." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Exponent" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The exponent b of the power a^b." ;
+ };
+ };
+ // -=*# Resource for function ANZAHLLEEREZELLEN #*=-
+ Resource SC_OPCODE_COUNT_EMPTY_CELLS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Counts the blank cells in a specified range." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ANZAHLLEEREZELLEN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "range" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range in which empty cells are to be counted." ;
+ };
+ };
+ // -=*# Resource for function PI #*=-
+ Resource SC_OPCODE_PI
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the value of the number Pi." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_PI );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function SUMME #*=-
+ Resource SC_OPCODE_SUM
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sum of all arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_SUMME );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 arguments whose total is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function QUADRATESUMME #*=-
+ Resource SC_OPCODE_SUM_SQ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sum of the squares of the arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_QUADRATESUMME );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2,... are 1 to 30 arguments for which the sum of the squares is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function PRODUKT #*=-
+ Resource SC_OPCODE_PRODUCT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Multiplies the arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_PRODUKT );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 arguments to be multiplied and a result returned." ;
+ };
+ };
+ // -=*# Resource for function SUMMEWENN #*=-
+ Resource SC_OPCODE_SUM_IF
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Totals the arguments that meet the conditions." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_SUMMEWENN );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "range" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range to be evaluated by the criteria given." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "criteria" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The cell range in which the search criteria are given." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "sum_range" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The range from which the values are to be totalled." ;
+ };
+ };
+ // -=*# Resource for function ZÄHLENWENN #*=-
+ Resource SC_OPCODE_COUNT_IF
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Counts the arguments which meet the set conditions." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ZAEHLENWENN );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "range" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The range of cells on which the criteria are to be applied." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "criteria" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The cell range in which the search criteria are given." ;
+ };
+ };
+ // -=*# Resource for function WURZEL #*=-
+ Resource SC_OPCODE_SQRT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the square root of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_WURZEL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A positive value for which the square root is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function ZUFALLSZAHL #*=-
+ Resource SC_OPCODE_RANDOM
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a random number between 0 and 1." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ZUFALLSZAHL );
+ 0;
+ 0;
+ };
+ };
+ // -=*# Resource for function ISTGERADE #*=-
+ Resource SC_OPCODE_IS_EVEN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value is an even integer." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ISTGERADE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function ISTUNGERADE #*=-
+ Resource SC_OPCODE_IS_ODD
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns TRUE if value is an odd integer." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ISTUNGERADE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be tested." ;
+ };
+ };
+ // -=*# Resource for function KOMBINATIONEN #*=-
+ Resource SC_OPCODE_KOMBIN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the number of combinations for elements without repetition." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_KOMBINATIONEN );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The total number of elements." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "number_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of elements selected." ;
+ };
+ };
+ // -=*# Resource for function KOMBINATIONEN2 #*=-
+ Resource SC_OPCODE_KOMBIN_2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the number of combinations of elements including repetition." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_KOMBINATIONEN2 );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The total number of elements." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "number_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of elements selected." ;
+ };
+ };
+ // -=*# Resource for function ARCCOS #*=-
+ Resource SC_OPCODE_ARC_COS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the arccosine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCCOS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value between -1 and 1 for which the arccosine is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCSIN #*=-
+ Resource SC_OPCODE_ARC_SIN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the arcsine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCSIN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value between -1 and 1 for which the arcsine is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCCOSHYP #*=-
+ Resource SC_OPCODE_ARC_COS_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse hyperbolic cosine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCOSHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value greater than or equal to 1 for which the hyperbolic cosine is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCSINHYP #*=-
+ Resource SC_OPCODE_ARC_SIN_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse hyperbolic sine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARSINHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the inverse hyperbolic sine is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCCOT #*=-
+ Resource SC_OPCODE_ARC_COT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse cotangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCCOT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the inverse cotangent is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCTAN #*=-
+ Resource SC_OPCODE_ARC_TAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the arctangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCTAN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the arctangent is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCCOTHYP #*=-
+ Resource SC_OPCODE_ARC_COT_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse hyperbolic cotangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCOTHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value smaller than -1 or greater than 1 for which the inverse hyperbolic cotangent is to be returned." ;
+ };
+ };
+ // -=*# Resource for function ARCTANHYP #*=-
+ Resource SC_OPCODE_ARC_TAN_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse hyperbolic tangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARTANHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value between -1 and 1 for which the inverse hyperbolic tangent is to be returned." ;
+ };
+ };
+ // -=*# Resource for function COS #*=-
+ Resource SC_OPCODE_COS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the cosine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_COS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The angle in the radians for which the cosine is to be returned." ;
+ };
+ };
+ // -=*# Resource for function SIN #*=-
+ Resource SC_OPCODE_SIN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_SIN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The angle in radians for which the sine is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function COT #*=-
+ Resource SC_OPCODE_COT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the cotangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_COT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The angle in radians whose cotangent value is to be returned." ;
+ };
+ };
+ // -=*# Resource for function TAN #*=-
+ Resource SC_OPCODE_TAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the tangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_TAN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The angle in radians for which the tangent is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function COSHYP #*=-
+ Resource SC_OPCODE_COS_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the hyperbolic cosine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_COSHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the hyperbolic cosine is to be returned." ;
+ };
+ };
+ // -=*# Resource for function SINHYP #*=-
+ Resource SC_OPCODE_SIN_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the hyperbolic sine of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_SINHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the hyperbolic sine is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function COTHYP #*=-
+ Resource SC_OPCODE_COT_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the hyperbolic cotangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_COTHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value not equal to 0 for which the hyperbolic cotangent is to be returned." ;
+ };
+ };
+ // -=*# Resource for function TANHYP #*=-
+ Resource SC_OPCODE_TAN_HYP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the hyperbolic tangent of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_TANHYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the hyperbolic tangent is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function ARCTAN2 #*=-
+ Resource SC_OPCODE_ARC_TAN_2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the arctangent for the specified coordinates." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ARCTAN2 );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number_x" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for the x coordinate." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "number_y" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The value for the y coordinate." ;
+ };
+ };
+ // -=*# Resource for function DEG #*=-
+ Resource SC_OPCODE_DEG
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a radian to degrees" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_DEG );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The angle in a radian" ;
+ };
+ };
+ // -=*# Resource for function RAD #*=-
+ Resource SC_OPCODE_RAD
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts degrees to radians" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_RAD );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The angle in degrees." ;
+ };
+ };
+ // -=*# Resource for function EXP #*=-
+ Resource SC_OPCODE_EXP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the exponent for basis e." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_EXP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The exponent applied to base e." ;
+ };
+ };
+ // -=*# Resource for function LOG #*=-
+ Resource SC_OPCODE_LOG
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the logarithm to any specified base." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_LOG );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value greater than 0 for which the logarithm is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Base" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The base of the logarithm. If omitted, the base is regarded as 10." ;
+ };
+ };
+ // -=*# Resource for function LN #*=-
+ Resource SC_OPCODE_LN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the natural logarithm of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_LN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value greater than 0 for which the natural logarithm is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function LOG10 #*=-
+ Resource SC_OPCODE_LOG10
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the base-10 logarithm of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_LOG10 );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "A value greater than 0 for which the logarithm is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function FAKULTÄT #*=-
+ Resource SC_OPCODE_FACT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the factorial of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_FAKULTAET );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number for which the factorial is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function REST #*=-
+ Resource SC_OPCODE_MOD
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the remainder of a division." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_REST );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Dividend" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be divided." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Divisor" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number by which the dividend is divided." ;
+ };
+ };
+ // -=*# Resource for function VORZEICHEN #*=-
+ Resource SC_OPCODE_PLUS_MINUS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the algebraic sign of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_VORZEICHEN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number for which the algebraic sign is to be determined." ;
+ };
+ };
+ // -=*# Resource for function TEILERGEBNIS #*=-
+ Resource SC_OPCODE_SUB_TOTAL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates subtotals in a spreadsheet." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_TEILERGEBNIS );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Function" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Function index. Is an index of the possible functions Total, Max, ..." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "range " ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The cells of the range which are to be taken into account." ;
+ };
+ };
+ // -=*# Resource for function GANZZAHL #*=-
+ Resource SC_OPCODE_INT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a number down to the nearest integer." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_GANZZAHL );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded down." ;
+ };
+ };
+ // -=*# Resource for function KÃœRZEN #*=-
+ Resource SC_OPCODE_TRUNC
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Truncates the decimal places of a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_KUERZEN );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be truncated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "count" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of places after the decimal point that are not to be truncated." ;
+ };
+ };
+ // -=*# Resource for function RUNDEN #*=-
+ Resource SC_OPCODE_ROUND
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a number to a predefined accuracy." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_RUNDEN );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "count" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of places to which a number is to be rounded." ;
+ };
+ };
+ // -=*# Resource for function AUFRUNDEN #*=-
+ Resource SC_OPCODE_ROUND_UP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a number up to the predefined accuracy." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_AUFRUNDEN );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded up." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "count" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of places to which a number is to be rounded." ;
+ };
+ };
+ // -=*# Resource for function ABRUNDEN #*=-
+ Resource SC_OPCODE_ROUND_DOWN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a number down to a predefined accuracy." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_ABRUNDEN );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded down." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "count" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of places down to which a number is to be rounded." ;
+ };
+ };
+ // -=*# Resource for function GERADE #*=-
+ Resource SC_OPCODE_EVEN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a positive number up and negative number down to the nearest even integer.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_GERADE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded up." ;
+ };
+ };
+ // -=*# Resource for function UNGERADE #*=-
+ Resource SC_OPCODE_ODD
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a positive number up and negative number down to the nearest odd integer.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_UNGERADE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded up." ;
+ };
+ };
+ // -=*# Resource for function OBERGRENZE #*=-
+ Resource SC_OPCODE_CEIL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds a number up to the nearest multiple of significance." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_OBERGRENZE );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded up." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Significance" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number to whose multiple the value is rounded." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Mode" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "If given and not equal to zero then rounded up according to amount when a negative number and significance." ;
+ };
+ };
+ // -=*# Resource for function UNTERGRENZE #*=-
+ Resource SC_OPCODE_FLOOR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Rounds number down to the nearest multiple of significance." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_UNTERGRENZE );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be rounded down." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Significance" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number to whose multiple the value is to be rounded down." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Mode" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "If given and not equal to zero then rounded down according to amount when a negative number and significance." ;
+ };
+ };
+ // -=*# Resource for function GGT #*=-
+ Resource SC_OPCODE_GGT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Greatest Common Divisor" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_GGT );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Integer " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Integer 1; integer 2,... are integers for which the greatest common divisor is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function KGV #*=-
+ Resource SC_OPCODE_KGV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Lowest common multiple" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_KGV );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Integer " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Integer 1; integer 2,... are integers whose smallest common multiple is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function MTRANS #*=-
+ Resource SC_OPCODE_MAT_TRANS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Array transposition. Exchanges the rows and columns of an array." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_MTRANS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array in which the rows and columns have been transposed." ;
+ };
+ };
+ // -=*# Resource for function MMULT #*=-
+ Resource SC_OPCODE_MAT_MULT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Array multiplication. Returns the product of two arrays." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_MMULT );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first array for the array product." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second array having the same number of rows as the first array has columns." ;
+ };
+ };
+ // -=*# Resource for function MDET #*=-
+ Resource SC_OPCODE_MAT_DET
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the array determinant." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_MDET );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array for which the determinant is to be determined." ;
+ };
+ };
+ // -=*# Resource for function MINV #*=-
+ Resource SC_OPCODE_MAT_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse of an array." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_MINV );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array to be inverted." ;
+ };
+ };
+ // -=*# Resource for function EINHEITSMATRIX #*=-
+ Resource SC_OPCODE_MATRIX_UNIT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the unitary square array of a certain size." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_EINHEITSMATRIX );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Dimensions" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The size of the unitary array." ;
+ };
+ };
+ // -=*# Resource for function SUMMENPRODUKT #*=-
+ Resource SC_OPCODE_SUM_PRODUCT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "(Inner products) Returns the sum of the products of array arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_SUMMENPRODUKT );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Array " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Array 1, array 2, ... are up to 30 arrays whose arguments are to be multiplied." ;
+ };
+ };
+ // -=*# Resource for function SUMMEX2MY2 #*=-
+ Resource SC_OPCODE_SUM_X2MY2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sum of the difference of squares of two arrays." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_SUMMEX2MY2 );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array_x" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "First array where the square of the arguments are totalled." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "array_y" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Second array where the square of the arguments is to be subtracted." ;
+ };
+ };
+ // -=*# Resource for function SUMMEX2PY2 #*=-
+ Resource SC_OPCODE_SUM_X2DY2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the total of the square sum of two arrays." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_SUMMEX2PY2 );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array_x" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "First array where the square of the arguments are totalled." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "array_y" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Second array where the square of the arguments is to be totalled." ;
+ };
+ };
+ // -=*# Resource for function SUMMEXMY2 #*=-
+ Resource SC_OPCODE_SUM_XMY2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sum of squares of differences of two arrays." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_SUMMEXMY2 );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array_x" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "First array for forming argument differences." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "array_y" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Second array for forming the argument differences." ;
+ };
+ };
+};
+
+Resource RID_SC_FUNCTION_DESCRIPTIONS2
+{
+ // -=*# Resource for function HÄUFIGKEIT #*=-
+ Resource SC_OPCODE_FREQUENCY
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a frequency distribution as a vertical array." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_HAEUFIGKEIT );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "classes" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The array for forming classes." ;
+ };
+ };
+ // -=*# Resource for function RGP #*=-
+ Resource SC_OPCODE_RGP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates parameters of the linear regression as an array." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_RGP );
+ 4; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Linear_type" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "If type = 0 the linears will be calculated through the zero point, or else moved linears." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "stats" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If parameter = 0 then only the regression coefficient will be calculated, otherwise other values as well." ;
+ };
+ };
+ // -=*# Resource for function RKP #*=-
+ Resource SC_OPCODE_RKP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the parameters of the exponential regression curve as an array." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_RKP );
+ 4; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Function_type" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "If type = 0 then the functions will be calculated in the form of y=m^x, or also functions y=b*m^x." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "stats" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If parameter = 0 then only the regression coefficient will be calculated, otherwise other values as well." ;
+ };
+ };
+ // -=*# Resource for function TREND #*=-
+ Resource SC_OPCODE_TREND
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates points along a regression line." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_TREND );
+ 4; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array as the basis for the regression." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "new data_X" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The array of X data for recalculating the values." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Linear_type" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If type = 0 the linears will be calculated through the zero point, or else moved linears." ;
+ };
+ };
+ // -=*# Resource for function VARIATION #*=-
+ Resource SC_OPCODE_GROWTH
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates points on the exponential regression function." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATRIX;
+ U2S( HID_FUNC_VARIATION );
+ 4; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array as the basis for the regression." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "new_data_X" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The array of X data for recalculating the values." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Function_type" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If type = 0 then the functions will be calculated in the form of y=m^x, or also functions y=b*m^x." ;
+ };
+ };
+ // -=*# Resource for function ANZAHL #*=-
+ Resource SC_OPCODE_COUNT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Counts how many numbers are in the list of arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_ANZAHL );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1, value 2, ... are 1 to 30 arguments containing different data types but where only numbers are counted." ;
+ };
+ };
+ // -=*# Resource for function ANZAHL2 #*=-
+ Resource SC_OPCODE_COUNT_2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Counts how many values are in the list of arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_ANZAHL2 );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1, value 2, ... are 1 to 30 arguments representing the values to be counted." ;
+ };
+ };
+ // -=*# Resource for function MAX #*=-
+ Resource SC_OPCODE_MAX
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the maximum value in a list of arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MAX );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments for which the largest number is to be determined." ;
+ };
+ };
+ // -=*# Resource for function MAXA #*=-
+ Resource SC_OPCODE_MAX_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the maximum value in a list of arguments. Text is evaluated as Zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MAXA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1, value 2, are 1 to 30 arguments whose largest value is to be determined.";
+ };
+ };
+ // -=*# Resource for function MIN #*=-
+ Resource SC_OPCODE_MIN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the minimum value in a list of arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MIN );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments for which the smallest number is to be determined." ;
+ };
+ };
+ // -=*# Resource for function MINA #*=-
+ Resource SC_OPCODE_MIN_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the smallest value in a list of arguments. Text is evaluated as zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MINA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1; value 2;... are 1 to 30 arguments whose smallest number is to be determined.";
+ };
+ };
+ // -=*# Resource for function VARIANZ #*=-
+ Resource SC_OPCODE_VAR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the variance based on a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_VARIANZ );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample of a population." ;
+ };
+ };
+ // -=*# Resource for function VARIANZ #*=-
+ Resource SC_OPCODE_VAR_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the variance based on a sample. Text is evaluated as zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_VARIANZA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1; value 2; ... are 1 to 30 arguments representing a sample taken from a basic total population.";
+ };
+ };
+ // -=*# Resource for function VARIANZEN #*=-
+ Resource SC_OPCODE_VAR_P
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates variance based on the entire population." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_VARIANZEN );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which represent a population." ;
+ };
+ };
+ // -=*# Resource for function VARIANZENA #*=-
+ Resource SC_OPCODE_VAR_P_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the variance based on the entire population. Text is evaluated as zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_VARIANZENA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1; value 2;... are 1 to 30 arguments representing a population.";
+ };
+ };
+ // -=*# Resource for function STABW #*=-
+ Resource SC_OPCODE_ST_DEV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the standard deviation based on a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STABW );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample of a population." ;
+ };
+ };
+ // -=*# Resource for function STABWA #*=-
+ Resource SC_OPCODE_ST_DEV_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the standard deviation based on a sample. Text is evaluated as zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STABWA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1; value 2; ... are 1 to 30 arguments representing a sample taken from a basic total population.";
+ };
+ };
+ // -=*# Resource for function STABWN #*=-
+ Resource SC_OPCODE_ST_DEV_P
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the standard deviation based on the entire population." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STABWN );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample of a population." ;
+ };
+ };
+ // -=*# Resource for function STABWNA #*=-
+ Resource SC_OPCODE_ST_DEV_P_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the standard deviation based on the entire population. Text is evaluated as zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STABWNA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1; value 2;... are 1 to 30 arguments corresponding to a population.";
+ };
+ };
+ // -=*# Resource for function MITTELWERT #*=-
+ Resource SC_OPCODE_AVERAGE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the average of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MITTELWERT );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2;...are 1 to 30 numeric arguments representing a population sample." ;
+ };
+ };
+ // -=*# Resource for function MITTELWERTA #*=-
+ Resource SC_OPCODE_AVERAGE_A
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the average value for a sample. Text is evaluated as zero.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MITTELWERTA );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value ";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value 1; value 2; ... are 1 to 30 arguments representing a sample taken from a basic total population.";
+ };
+ };
+ // -=*# Resource for function SUMQUADABW #*=-
+ Resource SC_OPCODE_DEV_SQ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the sum of squares of deviations from the sample mean value" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_SUMQUADABW );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample." ;
+ };
+ };
+ // -=*# Resource for function MITTELABW #*=-
+ Resource SC_OPCODE_AVE_DEV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the average of the absolute deviations of a sample from the mean." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MITTELABW );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2;...are 1 to 30 numerical arguments representing a sample." ;
+ };
+ };
+ // -=*# Resource for function SCHIEFE #*=-
+ Resource SC_OPCODE_SCHIEFE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the skewness of a distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_SCHIEFE );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments portraying a sample of the distribution." ;
+ };
+ };
+ // -=*# Resource for function KURT #*=-
+ Resource SC_OPCODE_KURT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the kurtosis of a distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KURT );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments, representing a sample of the distribution." ;
+ };
+ };
+ // -=*# Resource for function GEOMITTEL #*=-
+ Resource SC_OPCODE_GEO_MEAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the geometric mean of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GEOMITTEL );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample." ;
+ };
+ };
+ // -=*# Resource for function HARMITTEL #*=-
+ Resource SC_OPCODE_HAR_MEAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the harmonic mean of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_HARMITTEL );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample." ;
+ };
+ };
+ // -=*# Resource for function MODALWERT #*=-
+ Resource SC_OPCODE_MODAL_VALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the most common value in a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MODALWERT );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample." ;
+ };
+ };
+ // -=*# Resource for function MEDIAN #*=-
+ Resource SC_OPCODE_MEDIAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the median of a given sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_MEDIAN );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Number 1, number 2, ... are 1 to 30 numerical arguments which portray a sample." ;
+ };
+ };
+ // -=*# Resource for function QUANTIL #*=-
+ Resource SC_OPCODE_PERCENTILE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the alpha quantile of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_QUANTIL );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The percentage rate of the quantile between 0 and 1." ;
+ };
+ };
+ // -=*# Resource for function QUARTILE #*=-
+ Resource SC_OPCODE_QUARTILE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the quartile of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_QUARTILE );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The type of the quartile (0 = MIN, 1 = 25%, 2 = 50 %, 3 = 75 %, 4 =MAX)." ;
+ };
+ };
+ // -=*# Resource for function KGRÖSSTE #*=-
+ Resource SC_OPCODE_LARGE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the k-th largest value of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KGROESSTE );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Rank_c" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The ranking of the value." ;
+ };
+ };
+ // -=*# Resource for function KKLEINSTE #*=-
+ Resource SC_OPCODE_SMALL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the k-th smallest value of a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KKLEINSTE );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Rank_c" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The ranking of the value." ;
+ };
+ };
+ // -=*# Resource for function QUANTILSRANG #*=-
+ Resource SC_OPCODE_PERCENT_RANK
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the percentage rank of a value in a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_QUANTILSRANG );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The value for which percentage ranking is to be determined." ;
+ };
+ };
+ // -=*# Resource for function RANG #*=-
+ Resource SC_OPCODE_RANK
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the ranking of a value in a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_RANG );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the rank is to be determined." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Data" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Sequence order: 0 or omitted means descending, any other value than 0 means ascending." ;
+ };
+ };
+ // -=*# Resource for function GESTUTZTMITTEL #*=-
+ Resource SC_OPCODE_TRIM_MEAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the mean of a sample without including the marginal values." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GESTUTZTMITTEL );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array of the data in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The percentage of marginal data that is not to be taken into account." ;
+ };
+ };
+ // -=*# Resource for function WAHRSCHBEREICH #*=-
+ Resource SC_OPCODE_PROB
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the discreet probability of an interval." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_WAHRSCHBEREICH );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The sample data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "probability" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The array of the associated probabilities." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Start" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The start of the value interval whose probabilities is to be totalled." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "End" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The end of the value interval where the probabilities are to be totalled." ;
+ };
+ };
+ // -=*# Resource for function B #*=-
+ Resource SC_OPCODE_B
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the probability of a trial result using binomial distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_B );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "trials" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number of trials." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "SP" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The individual probability of a trial result." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "T_1" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Lower limit for the number of trials." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "T_2" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Upper limit for the number of trials." ;
+ };
+ };
+ // -=*# Resource for function PHI #*=-
+ Resource SC_OPCODE_PHI
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the distribution function for a standard normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_PHI );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the standard normal distribution is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function GAUSS #*=-
+ Resource SC_OPCODE_GAUSS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the integral values of the standard normal cumulative distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GAUSS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the integral value of the standard normal distribution is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function FISHER #*=-
+ Resource SC_OPCODE_FISHER
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the Fisher transformation." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_FISHER );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be transformed (-1 < VALUE < 1)." ;
+ };
+ };
+ // -=*# Resource for function FISHERINV #*=-
+ Resource SC_OPCODE_FISHER_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the inverse of the Fisher transformation." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_FISHERINV );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value that is to be transformed back." ;
+ };
+ };
+ // -=*# Resource for function BINOMVERT #*=-
+ Resource SC_OPCODE_BINOM_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the binomial distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_BINOMVERT );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "X" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number of successes in a series of trials." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "trials" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The total number of trials." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "SP" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The success probability of a trial." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "C" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Cumulated. C=0 calculates the individual probability, C=1 the cumulated probability." ;
+ };
+ };
+ // -=*# Resource for function NEGBINOMVERT #*=-
+ Resource SC_OPCODE_NEG_BINOM_VERT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the negative binomial distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_NEGBINOMVERT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "X" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number of failures in the trial range." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "R" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of successes in the trial sequence." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "SP" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The success probability of a trial." ;
+ };
+ };
+ // -=*# Resource for function KRITBINOM #*=-
+ Resource SC_OPCODE_KRIT_BINOM
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Border arguments of the binomial distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KRITBINOM );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "trials" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The total number of trials." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "SP" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The success probability of a trial." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The border probability that is attained or exceeded." ;
+ };
+ };
+ // -=*# Resource for function POISSON #*=-
+ Resource SC_OPCODE_POISSON_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the Poisson distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_POISSON );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the Poisson distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mean" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Mean. The mean value of the Poisson distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Cumulative" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function." ;
+ };
+ };
+ // -=*# Resource for function NORMVERT #*=-
+ Resource SC_OPCODE_NORM_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_NORMVERT );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the normal distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Mean" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The mean value. The mean value of the normal distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Standard deviation. The standard deviation of the normal distribution." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "C" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function." ;
+ };
+ };
+ // -=*# Resource for function NORMINV #*=-
+ Resource SC_OPCODE_NORM_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_NORMINV );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse normal distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mean" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The mean value. The mean value of the normal distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Standard deviation. The standard deviation of the normal distribution." ;
+ };
+ };
+ // -=*# Resource for function STANDNORMVERT #*=-
+ Resource SC_OPCODE_STD_NORM_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "The values of the standard normal cumulative distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STANDNORMVERT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the standard normal distribution is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function STANDNORMINV #*=-
+ Resource SC_OPCODE_S_NORM_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse standard normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STANDNORMINV );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse standard normal distribution is to be calculated." ;
+ };
+ };
+ // -=*# Resource for function LOGNORMVERT #*=-
+ Resource SC_OPCODE_LOG_NORM_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the log normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_LOGNORMVERT );
+ 4; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the log normal distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mean" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The mean value of the log normal distribution. It is set to 0 if omitted." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The standard deviation of the log normal distribution. It is set to 1 if omitted." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US] = "Cumulative";
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US] = "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function." ;
+ };
+ };
+ // -=*# Resource for function LOGINV #*=-
+ Resource SC_OPCODE_LOG_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse of the lognormal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_LOGINV );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse log normal distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mean" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Mean value. The mean value of the log normal distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Standard deviation. The standard deviation of the log normal distribution." ;
+ };
+ };
+ // -=*# Resource for function EXPONVERT #*=-
+ Resource SC_OPCODE_EXP_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the exponential distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_EXPONVERT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to which the exponential distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "lambda" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The parameters of the exponential distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "C" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Cumulated. C=0 calculates the density function, C=1 the distribution." ;
+ };
+ };
+ // -=*# Resource for function GAMMAVERT #*=-
+ Resource SC_OPCODE_GAMMA_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the value of the probability density function or the cumulative distribution function for the Gamma distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GAMMAVERT );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the gamma distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The Alpha parameter of the Gamma distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "beta" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The Beta parameter of the Gamma distribution." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Cumulative" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function." ;
+ };
+ };
+ // -=*# Resource for function GAMMAINV #*=-
+ Resource SC_OPCODE_GAMMA_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse gamma distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GAMMAINV );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse gamma distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The Alpha (shape) parameter of the Gamma distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "beta" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The Beta (scale) parameter of the Gamma distribution." ;
+ };
+ };
+ // -=*# Resource for function GAMMALN #*=-
+ Resource SC_OPCODE_GAMMA_LN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the natural logarithm of the gamma function." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GAMMALN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the natural logarithm of the gamma function is to be calculated." ;
+ };
+ };
+
+ // -=*# Resource for function GAMMA #*=-
+ Resource SC_OPCODE_GAMMA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the value of the Gamma function." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GAMMA );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the Gamma function is to be calculated." ;
+ };
+ };
+
+ // -=*# Resource for function BETAVERT #*=-
+ Resource SC_OPCODE_BETA_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the beta distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_BETAVERT );
+ 6; 0; 0; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the beta distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The Alpha parameter of the Beta distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "beta" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The Beta parameter of the Beta distribution." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Start" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The starting value for the value interval of the distribution." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "End" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "The final value for the value interval of the distribution." ;
+ };
+ String 12 // Name of Parameter 6
+ {
+ Text [en-US ] = "Cumulative" ;
+ };
+ String 13 // Description of Parameter 6
+ {
+ Text [ en-US ] = "0 or FALSE for probability density function, any other value or TRUE or omitted for cumulative distribution function.";
+ };
+ };
+ // -=*# Resource for function BETAINV #*=-
+ Resource SC_OPCODE_BETA_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse beta distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_BETAINV );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse beta distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The Alpha parameter of the Beta distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "beta" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The Beta parameter of the Beta distribution." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Start" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The starting value for the value interval of the distribution." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "End" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "The final value for the value interval of the distribution." ;
+ };
+ };
+ // -=*# Resource for function WEIBULL #*=-
+ Resource SC_OPCODE_WEIBULL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the values of the Weibull distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_WEIBULL );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the Weibull distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Alpha" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The Alpha parameter of the Weibull distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "beta" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The Beta parameter of the Weibull distribution." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "C" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Cumulated. C=0 calculates the density function, C=1 the distribution." ;
+ };
+ };
+ // -=*# Resource for function HYPGEOMVERT #*=-
+ Resource SC_OPCODE_HYP_GEOM_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the hypergeometric distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_HYPGEOMVERT );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "X" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number of successes in the sample." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "n_sample" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The size of the sample." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "successes" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The number of successes in the population." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "n_population" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The population size." ;
+ };
+ };
+ // -=*# Resource for function TVERT #*=-
+ Resource SC_OPCODE_T_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the t-distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_TVERT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the T distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "degrees_freedom" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom of the T distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "mode" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Mode = 1 calculates the one-tailed test, 2 = two-tailed distribution." ;
+ };
+ };
+ // -=*# Resource for function TINV #*=-
+ Resource SC_OPCODE_T_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse t-distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_TINV );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse T distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "degrees_freedom" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom of the T distribution." ;
+ };
+ };
+ // -=*# Resource for function FVERT #*=-
+ Resource SC_OPCODE_F_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the F probability distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_FVERT );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the F distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "degrees_freedom_1" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom in the numerator of the F distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "degrees_freedom_2" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The degrees of freedom in the denominator of the F distribution." ;
+ };
+ };
+ // -=*# Resource for function FINV #*=-
+ Resource SC_OPCODE_F_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse F distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_FINV );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse F distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "degrees_freedom_1" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom in the numerator of the F distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "degrees_freedom_2" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The degrees of freedom in the denominator of the F distribution." ;
+ };
+ };
+ // -=*# Resource for function CHIVERT #*=-
+ Resource SC_OPCODE_CHI_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the right-tail probability of the chi-square distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CHIVERT );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the chi square distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "degrees_freedom" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom of the chi square distribution." ;
+ };
+ };
+
+ // -=*# Resource for function CHISQDIST #*=-
+ Resource SC_OPCODE_CHISQ_DIST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns left-tail probability of the cumulative distribution function or values of the probability density function of the chi-square distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CHISQDIST );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value for which the probability density function or cumulative distribution function is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Degrees of Freedom" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom of the chi-square distribution." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Cumulative" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "0 or FALSE calculates the probability density function. Any other value or TRUE or omitted calculates the cumulative distribution function." ;
+ };
+ };
+
+
+ // -=*# Resource for function CHIINV #*=-
+ Resource SC_OPCODE_CHI_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse of CHIDIST(x; DegreesOfFreedom)." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CHIINV );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse chi square distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "degrees_freedom" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom of the chi square distribution." ;
+ };
+ };
+
+ // -=*# Resource for function CHISQINV #*=-
+ Resource SC_OPCODE_CHISQ_INV
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Values of the inverse of CHISQDIST(x;DegreesOfFreedom;TRUE())." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CHISQINV );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Probability" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The probability value for which the inverse of the chi square distribution is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Degrees of Freedom" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The degrees of freedom of the chi square distribution." ;
+ };
+ };
+
+ // -=*# Resource for function STANDARDISIERUNG #*=-
+ Resource SC_OPCODE_STANDARD
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a random variable to a normalized value." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STANDARDISIERUNG );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be standardized." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mean" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The mean value used for moving." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The standard deviation used for scaling." ;
+ };
+ };
+ // -=*# Resource for function VARIATIONEN #*=-
+ Resource SC_OPCODE_VARIATIONEN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the number of permutations for a given number of elements without repetition." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_VARIATIONEN );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Count_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The total number of elements." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Count_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The selection number taken from the elements." ;
+ };
+ };
+ // -=*# Resource for function VARIATIONEN2 #*=-
+ Resource SC_OPCODE_VARIATIONEN_2
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the number of permutations for a given number of objects (repetition allowed)." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_VARIATIONEN2 );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Count_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The total number of elements." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Count_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The selection number taken from the elements." ;
+ };
+ };
+ // -=*# Resource for function KONFIDENZ #*=-
+ Resource SC_OPCODE_CONFIDENCE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a (1 alpha) confidence interval for a normal distribution." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KONFIDENZ );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "alpha" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The level of the confidence interval." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "STDEV" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The standard deviation of the population." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "size" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The size of the population." ;
+ };
+ };
+ // -=*# Resource for function GTEST #*=-
+ Resource SC_OPCODE_Z_TEST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the probability of observing a z-statistic greater than the one computed based on a sample." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_GTEST );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The given sample, drawn from a normally distributed population." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "mu" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The known mean of the population." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "sigma" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The known standard deviation of the population. If omitted, the standard deviation of the given sample is used." ;
+ };
+ };
+ // -=*# Resource for function CHITEST #*=-
+ Resource SC_OPCODE_CHI_TEST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the chi square independence test." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_CHITEST );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Data_B" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The observed data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_E" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The expected data array." ;
+ };
+ };
+ // -=*# Resource for function FTEST #*=-
+ Resource SC_OPCODE_F_TEST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the F test." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_FTEST );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first record array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second record array." ;
+ };
+ };
+ // -=*# Resource for function TTEST #*=-
+ Resource SC_OPCODE_T_TEST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the T test." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_TTEST );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first record array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second record array." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "mode" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Mode specifies the number of distribution tails to return. 1= one-tailed, 2 = two-tailed distribution" ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The type of the T test." ;
+ };
+ };
+ // -=*# Resource for function BESTIMMTHEITSMASS #*=-
+ Resource SC_OPCODE_RSQ
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the square of the Pearson product moment correlation coefficient." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_BESTIMMTHEITSMASS );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ };
+ // -=*# Resource for function ACHSENABSCHNITT #*=-
+ Resource SC_OPCODE_INTERCEPT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the intercept of the linear regression line and the Y axis." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_ACHSENABSCHNITT );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ };
+ // -=*# Resource for function STEIGUNG #*=-
+ Resource SC_OPCODE_SLOPE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the slope of the linear regression line." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STEIGUNG );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ };
+ // -=*# Resource for function STFEHLERYX #*=-
+ Resource SC_OPCODE_STEYX
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the standard error of the linear regression." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_STFEHLERYX );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ };
+ // -=*# Resource for function PEARSON #*=-
+ Resource SC_OPCODE_PEARSON
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the Pearson product moment correlation coefficient." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_PEARSON );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Data_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first record array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Data_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second record array." ;
+ };
+ };
+ // -=*# Resource for function KORREL #*=-
+ Resource SC_OPCODE_CORREL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the correlation coefficient." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KORREL );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Data_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first record array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Data_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second record array." ;
+ };
+ };
+ // -=*# Resource for function KOVAR #*=-
+ Resource SC_OPCODE_COVAR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the covariance." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_KOVAR );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Data_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first record array." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Data_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second record array." ;
+ };
+ };
+ // -=*# Resource for function SCHÄTZER #*=-
+ Resource SC_OPCODE_FORECAST
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a value along a linear regression" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_STATISTIC;
+ U2S( HID_FUNC_SCHAETZER );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The X value for which the Y value on the regression linear is to be calculated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "data_Y" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The Y data array." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "data_X" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The X data array." ;
+ };
+ };
+ // -=*# Resource for function ADRESSE #*=-
+ Resource SC_OPCODE_ADDRESS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the reference to a cell as text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_ADRESSE );
+ 5; 0; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "row" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The row number of the cell." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "column" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The column number of the cell." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "ABS" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Specifies whether absolute or relative referencing is to be used." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "A1" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The reference style: 0 or FALSE means R1C1 style, any other value or omitted means A1 style." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "sheet" ;
+ Text [ x-comment ] = "previously to OOo3.0 this was String resource RID_SC_FUNCTION_DESCRIPTIONS2.SC_OPCODE_ADDRESS 8" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "The spreadsheet name of the cell reference." ;
+ Text [ x-comment ] = "previously to OOo3.0 this was String resource RID_SC_FUNCTION_DESCRIPTIONS2.SC_OPCODE_ADDRESS 9" ;
+ };
+ };
+ // -=*# Resource for function BEREICHE #*=-
+ Resource SC_OPCODE_AREAS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the number of individual ranges that belong to a (multiple) range." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_BEREICHE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference to a (multiple) range." ;
+ };
+ };
+ // -=*# Resource for function WAHL #*=-
+ Resource SC_OPCODE_CHOSE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Selects a value from a list of up to 30 value arguments." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_WAHL );
+ VAR_ARGS+1; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Index" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The index of the value (1..30) selected." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "value " ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Value 1, value 2,... The list of arguments from which a value is chosen." ;
+ };
+ };
+ // -=*# Resource for function SPALTE #*=-
+ Resource SC_OPCODE_COLUMN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the internal column number of a reference." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_SPALTE );
+ 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference to a cell or a range." ;
+ };
+ };
+ // -=*# Resource for function ZEILE #*=-
+ Resource SC_OPCODE_ROW
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Defines the internal row number of a reference." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_ZEILE );
+ 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference to a cell or a range." ;
+ };
+ };
+ // -=*# Resource for function TABELLE #*=-
+ Resource SC_OPCODE_TABLE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the internal sheet number of a reference or a string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_TABELLE );
+ 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference to a cell or a range or the character string of a sheet name." ;
+ };
+ };
+ // -=*# Resource for function SPALTEN #*=-
+ Resource SC_OPCODE_COLUMNS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the number of columns in an array or reference." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_SPALTEN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array (reference) for which the number of columns is to be determined." ;
+ };
+ };
+ // -=*# Resource for function ZEILEN #*=-
+ Resource SC_OPCODE_ROWS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the number of rows in a reference or array." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_ZEILEN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The array (reference) for which the number of rows is to be determined." ;
+ };
+ };
+ // -=*# Resource for function TABELLEN #*=-
+ Resource SC_OPCODE_TABLES
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the number of sheets of a given reference. If no parameter has been entered, the total number of sheets in the document is returned." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_TABELLEN );
+ 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference to a cell or a range." ;
+ };
+ };
+ // -=*# Resource for function WVERWEIS #*=-
+ Resource SC_OPCODE_H_LOOKUP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Horizontal search and reference to the cells located below." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_WVERWEIS );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "search_criteria" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be found in the first row." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The array or the range for the reference." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Index" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The row index in the array." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "sorted" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If the value is TRUE or not given, the search row of the array must be sorted in ascending order." ;
+ };
+ };
+ // -=*# Resource for function SVERWEIS #*=-
+ Resource SC_OPCODE_V_LOOKUP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Vertical search and reference to indicated cells." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_SVERWEIS );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Search criterion" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be found in the first column." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "array" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The array or range for referencing." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Index" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Column index number in the array." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "sort order" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If the value is TRUE or not given, the search column of the array must be sorted in ascending order." ;
+ };
+ };
+ // -=*# Resource for function INDEX #*=-
+ Resource SC_OPCODE_INDEX
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a reference to a cell from a defined range." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_INDEX );
+ 4; 0; 1; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference to a (multiple) range." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "row" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The row in the range." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "column" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The column in the range." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "range" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The index of the subrange if referring to a multiple range." ;
+ };
+ };
+ // -=*# Resource for function INDIREKT #*=-
+ Resource SC_OPCODE_INDIRECT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the contents of a cell that is referenced in text form." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_INDIREKT );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "ref " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The cell whose contents are to be evaluated is to be referenced in text form (e.g. \"A1\")." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "A1" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The reference style: 0 or FALSE means R1C1 style, any other value or omitted means A1 style." ;
+ };
+ };
+ // -=*# Resource for function VERWEIS #*=-
+ Resource SC_OPCODE_LOOKUP
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Determines a value in a vector by comparison to values in another vector." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_VERWEIS );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Search criterion" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be used for comparison." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Search vector" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The vector (row or column) in which to search." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "result_vector" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The vector (row or range) from which the value is to be determined." ;
+ };
+ };
+ // -=*# Resource for function VERGLEICH #*=-
+ Resource SC_OPCODE_MATCH
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Defines a position in a array after comparing values." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_VERGLEICH );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Search criterion" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be used for comparison." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "lookup_array" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The array (range) in which the search is made." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Type" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Type can take the value 1, 0 or -1 and determines the criteria are to be used for comparison purposes." ;
+ };
+ };
+ // -=*# Resource for function VERSCHIEBUNG #*=-
+ Resource SC_OPCODE_OFFSET
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a reference which has been moved in relation to the starting point." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_VERSCHIEBUNG );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference (cell) from which to base the movement." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "rows" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of rows to be moved either up or down." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "columns" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The number of columns that are to be moved to the left or to the right." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "height" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The number of rows of the moved reference." ;
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "width" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "The number of columns in the moved reference." ;
+ };
+ };
+ // -=*# Resource for function FEHLERTYP #*=-
+ Resource SC_OPCODE_ERROR_TYPE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a number corresponding to an error type" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_FEHLERTYP );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "reference" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The reference (cell) in which the error occurred." ;
+ };
+ };
+ // -=*# Resource for function VORLAGE #*=-
+ Resource SC_OPCODE_STYLE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Applies a Style to the formula cell." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_VORLAGE );
+ 3; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Style" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The name of the Style to be applied." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Time" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The time (in seconds) that the Style is to remain valid." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Style2" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The Style to be applied after time expires." ;
+ };
+ };
+ // -=*# Resource for function DDE #*=-
+ Resource SC_OPCODE_DDE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Result of a DDE link." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_DDE );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "server" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The name of the server application." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "File" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The name of the file." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "range" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The range from which data is to be taken." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "mode" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Defines how data is to be converted to numbers." ;
+ };
+ };
+ // -=*# Resource for function HYPERLINK #*=-
+ Resource SC_OPCODE_HYPERLINK
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Hyperlink." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_HYPERLINK );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "URL " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "URL";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "CellText " ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Cell Text";
+ };
+ };
+ // -=*# Resource for function GETPIVOTDATA #*=-
+ Resource SC_OPCODE_GET_PIVOT_DATA
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Extracts value(s) from a DataPilot table.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TABLE;
+ U2S( HID_FUNC_GETPIVOTDATA );
+ VAR_ARGS+2; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Data Field";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The name of the data pilot field to extract.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "DataPilot";
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "A reference to a cell or range in the DataPilot table.";
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Field Name / Item";
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Field name/value pair to filter the target data.";
+ };
+ };
+ // -=*# Resource for function BAHTTEXT #*=-
+ Resource SC_OPCODE_BAHTTEXT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a number to text (Baht)." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_BAHTTEXT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to convert.";
+ };
+ };
+ // -=*# Resource for function JIS #*=-
+ Resource SC_OPCODE_JIS
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts half-width ASCII and katakana characters to full-width." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_JIS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to convert.";
+ };
+ };
+ // -=*# Resource for function ASC #*=-
+ Resource SC_OPCODE_ASC
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts full-width ASCII and katakana characters to half-width." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_ASC );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to convert.";
+ };
+ };
+ // -=*# Resource for function CODE #*=-
+ Resource SC_OPCODE_CODE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a numeric code for the first character in a text string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_CODE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "This is the text for which the code of the first character is to be found." ;
+ };
+ };
+ // -=*# Resource for function DM #*=-
+ Resource SC_OPCODE_CURRENCY
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a number to text in currency format." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_DM );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Value is a number, a reference to a cell containing a number or a formula that results in a number." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "decimals" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Decimal places. Denotes the number of digits to the right of the decimal point." ;
+ };
+ };
+ // -=*# Resource for function ZEICHEN #*=-
+ Resource SC_OPCODE_CHAR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a code number into a character or letter." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_ZEICHEN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The code value for the character." ;
+ };
+ };
+ // -=*# Resource for function SÄUBERN #*=-
+ Resource SC_OPCODE_CLEAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Removes all nonprintable characters from text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_SAEUBERN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text from which nonprintable characters are to be removed." ;
+ };
+ };
+ // -=*# Resource for function VERKETTEN #*=-
+ Resource SC_OPCODE_CONCAT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Combines several text items into one." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_VERKETTEN );
+ VAR_ARGS; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text " ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "Text for the concatentation." ;
+ };
+ };
+ // -=*# Resource for function IDENTISCH #*=-
+ Resource SC_OPCODE_EXACT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Specifies whether two texts are identical." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_IDENTISCH );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text_1" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The first text to be used for comparing texts." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "text_2" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The second text for comparing texts." ;
+ };
+ };
+ // -=*# Resource for function FINDEN #*=-
+ Resource SC_OPCODE_FIND
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Looks for a string of text within another (case sensitive)" ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_FINDEN );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "find_text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to be found." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The text in which a search is to be made." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "position" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The position in the text from which the search starts." ;
+ };
+ };
+ // -=*# Resource for function SUCHEN #*=-
+ Resource SC_OPCODE_SEARCH
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Looks for one text value within another (not case-sensitive)." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_SUCHEN );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "find_text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to be found." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The text in which a search is to be made." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "position" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The position in the text where the search is started." ;
+ };
+ };
+ // -=*# Resource for function GLÄTTEN #*=-
+ Resource SC_OPCODE_TRIM
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Removes extra spaces from text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_GLAETTEN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which extra spaces between words are to be deleted." ;
+ };
+ };
+ // -=*# Resource for function GROSS2 #*=-
+ Resource SC_OPCODE_PROPPER
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Capitalizes the first letter in all words." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_GROSS2 );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which the beginning of words are to be replaced by capital letters." ;
+ };
+ };
+ // -=*# Resource for function GROSS #*=-
+ Resource SC_OPCODE_UPPER
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts text to uppercase." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_GROSS );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which lower case letters are to be converted to capitals." ;
+ };
+ };
+ // -=*# Resource for function KLEIN #*=-
+ Resource SC_OPCODE_LOWER
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts text to lowercase." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_KLEIN );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which capitals are converted to lower case letters." ;
+ };
+ };
+ // -=*# Resource for function WERT #*=-
+ Resource SC_OPCODE_VALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts text to a number." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_WERT );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to be converted to a number." ;
+ };
+ };
+ // -=*# Resource for function TEXT #*=-
+ Resource SC_OPCODE_TEXT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a number to text according to a given format." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_TEXT );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The numeric value to be converted." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Format" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The text that describes the format." ;
+ };
+ };
+ // -=*# Resource for function T #*=-
+ Resource SC_OPCODE_T
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a value if it is text, otherwise an empty string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_T );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be checked and returned if it is text." ;
+ };
+ };
+ // -=*# Resource for function ERSETZEN #*=-
+ Resource SC_OPCODE_REPLACE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Replaces characters within a text string with a different text string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_ERSETZEN );
+ 4; 0; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which some characters are to be replaced." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "position" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The character position from which text is to be replaced." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "length" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The number of characters to be replaced." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "new text" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "The text to be inserted." ;
+ };
+ };
+ // -=*# Resource for function FEST #*=-
+ Resource SC_OPCODE_FIXED
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Formats a number with a fixed number of places after the decimal point and thousands separator." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_FEST );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be formatted." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Decimals" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Decimal places. The number of fixed decimal places that are to be displayed." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "No thousands separators" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "No thousands separator. True value, if existing and TRUE (unequal to 0), no thousands separators are set." ;
+ };
+ };
+ // -=*# Resource for function LÄNGE #*=-
+ Resource SC_OPCODE_LEN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates length of a text string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_LAENGE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which the length is to be determined." ;
+ };
+ };
+ // -=*# Resource for function LINKS #*=-
+ Resource SC_OPCODE_LEFT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the first character or characters of a text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_LINKS );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text where the initial partial words are to be determined." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of characters for the start text." ;
+ };
+ };
+ // -=*# Resource for function RECHTS #*=-
+ Resource SC_OPCODE_RIGHT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the last character or characters of a text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_RECHTS );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which the end partial words are to be determined." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of characters for the end text." ;
+ };
+ };
+ // -=*# Resource for function TEIL #*=-
+ Resource SC_OPCODE_MID
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns a partial text string of a text." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_TEIL );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which partial words are to be determined." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "start" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The position from which the part word is to be determined." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The number of characters for the text." ;
+ };
+ };
+ // -=*# Resource for function WIEDERHOLEN #*=-
+ Resource SC_OPCODE_REPT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Repeats text a given number of times." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_WIEDERHOLEN );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to be repeated." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The number of times the text is to be repeated." ;
+ };
+ };
+ // -=*# Resource for function WECHSELN #*=-
+ Resource SC_OPCODE_SUBSTITUTE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Substitutes new text for old text in a string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_WECHSELN );
+ 4; 0; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text in which partial words are to be replaced." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "search_text" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The partial string to be (repeatedly) replaced." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "new text" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "The text which is to replace the text string." ;
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "occurrence" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "Which occurrence of the old text is to be replaced." ;
+ };
+ };
+ // -=*# Resource for function BASIS #*=-
+ Resource SC_OPCODE_BASE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a positive integer to text from a number system to the base defined." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_BASIS );
+ 3; 0; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be converted." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "radix" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The base number for conversion must be in the range 2 - 36." ;
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "Minimum length" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "If the text is shorter than the specified length, zeros are added to the left of the string." ;
+ };
+ };
+ // -=*# Resource for function DEZIMAL #*=-
+ Resource SC_OPCODE_DECIMAL
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a text of a specified number system to a positive integer in the base given." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_DEZIMAL );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to be converted." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "radix" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The base number for conversion must be in the range 2 - 36." ;
+ };
+ };
+ // -=*# Resource for function CONVERT #*=-
+ Resource SC_OPCODE_CONVERT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a value according to a conversion table in the configuration (calc.xcu).";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_UMRECHNEN );
+ 3; 0; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be converted.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Unit from which something is converted, case-sensitive.";
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "Unit into which something is converted, case-sensitive.";
+ };
+ };
+ // -=*# Resource for function ROEMISCH #*=-
+ Resource SC_OPCODE_ROMAN
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a number to a Roman numeral.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_ROEMISCH );
+ 2; 0; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Number";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The number to be converted to a Roman numeral must be in the 0 - 3999 range.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "Mode";
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "The more this value increases, the more the Roman numeral is simplified. The value must be in the 0 - 4 range.";
+ };
+ };
+ // -=*# Resource for function ARABISCH #*=-
+ Resource SC_OPCODE_ARABIC
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Calculates the value of a Roman numeral.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_ARABISCH );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "Text";
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text that represents a Roman numeral.";
+ };
+ };
+ Resource SC_OPCODE_INFO
+ {
+ String 1
+ {
+ Text [ en-US ] = "Returns information about the environment.";
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_INFO;
+ U2S( HID_FUNC_INFO );
+ 1; 0;
+ 0;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Text";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Can be \"osversion\", \"system\", \"release\", \"numfile\", and \"recalc\".";
+ };
+ };
+ Resource SC_OPCODE_UNICODE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Returns the numeric code for the first Unicode character in a text string." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_UNICODE );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "This is the text for which the code of the first character is to be found." ;
+ };
+ };
+ Resource SC_OPCODE_UNICHAR
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a code number into a Unicode character or letter." ;
+ };
+ ExtraData =
+ {
+ 0;
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_UNICHAR );
+ 1; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "number" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The code value for the character." ;
+ };
+ };
+ Resource SC_OPCODE_EUROCONVERT
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts a value from one to another Euro currency.";
+ };
+ ExtraData =
+ {
+ 0; // DOING
+ ID_FUNCTION_GRP_MATH;
+ U2S( HID_FUNC_EUROCONVERT );
+ 5; 0; 0; 0; 1; 1;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "value" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The value to be converted.";
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "from_currency" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "ISO 4217 code of the currency from which is converted, case-sensitive.";
+ };
+ String 6 // Name of Parameter 3
+ {
+ Text [ en-US ] = "to_currency" ;
+ };
+ String 7 // Description of Parameter 3
+ {
+ Text [ en-US ] = "ISO 4217 code of the currency into which is converted, case-sensitive.";
+ };
+ String 8 // Name of Parameter 4
+ {
+ Text [ en-US ] = "full_precision" ;
+ };
+ String 9 // Description of Parameter 4
+ {
+ Text [ en-US ] = "If omitted or 0 or FALSE, the result is rounded to the decimals of to_currency. Else the result is not rounded.";
+ };
+ String 10 // Name of Parameter 5
+ {
+ Text [ en-US ] = "triangulation_precision" ;
+ };
+ String 11 // Description of Parameter 5
+ {
+ Text [ en-US ] = "If given and >=3, the intermediate result of a triangular conversion is rounded to that precision. If omitted, the result is not rounded.";
+ Text [ x-comment ] = "This description uses almost all available space in the dialog, make sure translations fit in size." ;
+ };
+ };
+ Resource SC_OPCODE_NUMBERVALUE
+ {
+ String 1 // Description
+ {
+ Text [ en-US ] = "Converts text to a number, in a locale-independent way." ;
+ };
+ ExtraData =
+ {
+ 1; // TODO: implementation and unsuppress
+ ID_FUNCTION_GRP_TEXT;
+ U2S( HID_FUNC_NUMBERVALUE );
+ 2; 0; 0;
+ 0;
+ };
+ String 2 // Name of Parameter 1
+ {
+ Text [ en-US ] = "text" ;
+ };
+ String 3 // Description of Parameter 1
+ {
+ Text [ en-US ] = "The text to be converted to a number." ;
+ };
+ String 4 // Name of Parameter 2
+ {
+ Text [ en-US ] = "decimal_point" ;
+ };
+ String 5 // Description of Parameter 2
+ {
+ Text [ en-US ] = "Defines the character used as the decimal point." ;
+ };
+ };
+};
+
+#if defined(U2S)
+#undef U2S
+#endif
diff --git a/sc/source/ui/src/scstring.src b/sc/source/ui/src/scstring.src
new file mode 100644
index 000000000000..f7c44c1fcd95
--- /dev/null
+++ b/sc/source/ui/src/scstring.src
@@ -0,0 +1,771 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sc.hrc" // -> #include <sfx.hrc>
+
+ // Strings fuer Interface-Namen ------------------------------------------
+
+String SCSTR_APPLICATION
+{
+ Text [ en-US ] = "%PRODUCTNAME Calc 6.0";
+};
+String SCSTR_50_APPLICATION
+{
+ Text [ en-US ] = "StarCalc 5.0" ;
+};
+String SCSTR_40_APPLICATION
+{
+ Text [ en-US ] = "StarCalc 4.0" ;
+};
+String SCSTR_30_APPLICATION
+{
+ Text [ en-US ] = "StarCalc 3.0" ;
+};
+String SCSTR_LONG_SCDOC_NAME
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION Spreadsheet";
+};
+String SCSTR_50_LONG_DOCNAME
+{
+ Text [ en-US ] = "%PRODUCTNAME 5.0 Spreadsheet" ;
+};
+String SCSTR_40_LONG_DOCNAME
+{
+ Text [ en-US ] = "%PRODUCTNAME 4.0 Spreadsheet" ;
+};
+String SCSTR_30_LONG_DOCNAME
+{
+ Text [ en-US ] = "StarCalc 3.0 Spreadsheet" ;
+};
+String SCSTR_SHORT_SCDOC_NAME
+{
+ Text [ en-US ] = "Spreadsheet" ;
+};
+String SCSTR_HUMAN_SCDOC_NAME
+{
+ Text [ en-US ] = "Spreadsheet" ;
+};
+
+String SCSTR_DOCSHELL
+{
+ Text [ en-US ] = "Sheet" ;
+};
+
+String SCSTR_TABVIEWSHELL
+{
+ Text [ en-US ] = "Cells" ;
+};
+
+String SCSTR_CELLSHELL
+{
+ Text [ en-US ] = "Functions for Cells";
+};
+
+String SCSTR_FORMATSHELL
+{
+ Text [ en-US ] = "Formats for Cells";
+};
+
+
+String SCSTR_DRAWSHELL
+{
+ Text [ en-US ] = "Graphics objects" ;
+};
+
+String SCSTR_DRAWTEXTSHELL
+{
+ Text [ en-US ] = "Text objects" ;
+};
+
+String SCSTR_DRAWFORMSHELL
+{
+ Text [ en-US ] = "Form objects";
+};
+
+String SCSTR_CHARTSHELL
+{
+ Text [ en-US ] = "Chart objects";
+};
+
+String SCSTR_OLEOBJECTSHELL
+{
+ Text [ en-US ] = "OLE objects";
+};
+
+String SCSTR_GRAPHICSHELL
+{
+ Text [ en-US ] = "Graphics";
+};
+String SCSTR_PAGEBREAKSHELL
+{
+ Text [ en-US ] = "Pagebreak";
+};
+
+String SCSTR_EDITSHELL
+{
+ Text [ en-US ] = "Text editing" ;
+};
+
+String SCSTR_PREVIEWSHELL
+{
+ Text [ en-US ] = "Print Preview" ;
+};
+
+String SCSTR_PIVOTSHELL
+{
+ Text [ en-US ] = "Data Pilot Tables" ;
+};
+
+String SCSTR_AUDITSHELL
+{
+ Text [ en-US ] = "Detective Fill Mode" ;
+};
+
+ // -----------------------------------------------------------------------
+
+String STR_ROWHEIGHT
+{
+ Text [ en-US ] = "Height" ;
+};
+String STR_OPT_ROWHEIGHT
+{
+ Text [ en-US ] = "Add" ;
+};
+String STR_ROWHEIGHT_TITLE
+{
+ Text [ en-US ] = "Row Height" ;
+};
+String STR_OPT_ROWHEIGHT_TITLE
+{
+ Text [ en-US ] = "Optimal Row Height" ;
+};
+String STR_COLWIDTH
+{
+ Text [ en-US ] = "Width" ;
+};
+String STR_OPT_COLWIDTH
+{
+ Text [ en-US ] = "Add" ;
+};
+String STR_COLWIDTH_TITLE
+{
+ Text [ en-US ] = "Column Width" ;
+};
+String STR_OPT_COLWIDTH_TITLE
+{
+ Text [ en-US ] = "Optimal Column Width" ;
+};
+String SCSTR_UNDEFINED
+{
+ Text [ en-US ] = "- undefined -" ;
+};
+String SCSTR_NONE
+{
+ Text [ en-US ] = "- none -" ;
+};
+String SCSTR_EMPTY
+{
+ Text [ en-US ] = "- empty -" ;
+};
+String SCSTR_NOTEMPTY
+{
+ Text [ en-US ] = "- not empty -" ;
+};
+String SCSTR_NEWTABLE
+{
+ Text [ en-US ] = "- new sheet -" ;
+};
+String SCSTR_ALL
+{
+ Text [ en-US ] = "- all -" ;
+};
+String SCSTR_STDFILTER
+{
+ Text [ en-US ] = "Standard Filter..." ;
+};
+String SCSTR_TOP10FILTER
+{
+ Text [ en-US ] = "Top 10" ;
+};
+String SCSTR_NONAME
+{
+ Text [ en-US ] = "unnamed" ;
+};
+String SCSTR_COLUMN
+{
+ Text [ en-US ] = "Column" ;
+};
+String SCSTR_ROW
+{
+ Text [ en-US ] = "Row" ;
+};
+String SCSTR_NEW
+{
+ Text [ en-US ] = "~New" ;
+};
+String SCSTR_ADD
+{
+ Text [ en-US ] = "~Add" ;
+};
+String SCSTR_REMOVE
+{
+ Text [ en-US ] = "~Delete" ;
+};
+String SCSTR_CANCEL
+{
+ Text [ en-US ] = "Cance~l" ;
+};
+String SCSTR_MODIFY
+{
+ Text [ en-US ] = "Modif~y" ;
+};
+
+
+String SCSTR_SHOWTABLE
+{
+ Text [ en-US ] = "Show Sheet" ;
+};
+String SCSTR_HIDDENTABLES
+{
+ Text [ en-US ] = "Hidden Sheets" ;
+};
+String SCSTR_SELECTDB
+{
+ Text [ en-US ] = "Select Database Range" ;
+};
+String SCSTR_AREAS
+{
+ Text [ en-US ] = "Ranges" ;
+};
+String SCSTR_TABLE
+{
+ Text [ en-US ] = "Sheet" ;
+};
+String SCSTR_NAME
+{
+ Text [ en-US ] = "Name" ;
+};
+String SCSTR_INSTABLE
+{
+ Text [ en-US ] = "Insert Sheet" ;
+};
+String SCSTR_APDTABLE
+{
+ Text [ en-US ] = "Append Sheet" ;
+};
+String SCSTR_RENAMETAB
+{
+ Text [ en-US ] = "Rename Sheet" ;
+};
+String SCSTR_SET_TAB_BG_COLOR
+{
+ Text [ en-US ] = "Tab Color" ;
+};
+String SCSTR_NO_TAB_BG_COLOR
+{
+ Text [ en-US ] = "Default" ;
+};
+String SCSTR_RENAMEOBJECT
+{
+ Text [ en-US ] = "Name Object";
+};
+String STR_INSERTGRAPHIC
+{
+ Text [ en-US ] = "Insert Picture" ;
+};
+
+ // Attribute
+
+String SCSTR_HOR_JUSTIFY_LEFT
+{
+ Text [ en-US ] = "Align left" ;
+};
+String SCSTR_HOR_JUSTIFY_CENTER
+{
+ Text [ en-US ] = "Centered horizontally" ;
+};
+String SCSTR_HOR_JUSTIFY_RIGHT
+{
+ Text [ en-US ] = "Align right" ;
+};
+String SCSTR_HOR_JUSTIFY_BLOCK
+{
+ Text [ en-US ] = "Justify" ;
+};
+String SCSTR_HOR_JUSTIFY_REPEAT
+{
+ Text [ en-US ] = "Repeat alignment" ;
+};
+String SCSTR_HOR_JUSTIFY_STANDARD
+{
+ Text [ en-US ] = "Horizontal alignment default" ;
+};
+String SCSTR_VER_JUSTIFY_TOP
+{
+ Text [ en-US ] = "Align to top" ;
+};
+String SCSTR_VER_JUSTIFY_CENTER
+{
+ Text [ en-US ] = "Centered vertically" ;
+};
+String SCSTR_VER_JUSTIFY_BOTTOM
+{
+ Text [ en-US ] = "Align to bottom" ;
+};
+String SCSTR_VER_JUSTIFY_STANDARD
+{
+ Text [ en-US ] = "Vertical alignment default" ;
+};
+String SCSTR_ORIENTATION_TOPBOTTOM
+{
+ Text [ en-US ] = "Top to bottom" ;
+};
+String SCSTR_ORIENTATION_BOTTOMTOP
+{
+ Text [ en-US ] = "Bottom to Top" ;
+};
+String SCSTR_ORIENTATION_STANDARD
+{
+ Text [ en-US ] = "Default orientation" ;
+};
+
+String SCSTR_PROTECTDOC
+{
+ Text [ en-US ] = "Protect Document" ;
+};
+String SCSTR_UNPROTECTDOC
+{
+ Text [ en-US ] = "Unprotect document" ;
+};
+String SCSTR_PROTECTTAB
+{
+ Text [ en-US ] = "Protect Sheet" ;
+};
+String SCSTR_UNPROTECTTAB
+{
+ Text [ en-US ] = "Unprotect sheet" ;
+};
+String SCSTR_CHG_PROTECT
+{
+ Text [ en-US ] = "Protect Records" ;
+};
+String SCSTR_CHG_UNPROTECT
+{
+ Text [ en-US ] = "Unprotect Records" ;
+};
+String SCSTR_PASSWORD
+{
+ Text [ en-US ] = "Password:" ;
+};
+String SCSTR_PASSWORDOPT
+{
+ Text [ en-US ] = "Password (optional):" ;
+};
+
+String SCSTR_WRONGPASSWORD
+{
+ Text [ en-US ] = "Incorrect Password" ;
+};
+
+String SCSTR_END
+{
+ Text [ en-US ] = "~End" ;
+};
+
+String SCSTR_STAT_PRINT
+{
+ Text [ en-US ] = "Printing..." ;
+};
+
+String SCSTR_UNKNOWN
+{
+ Text [ en-US ] = "Unknown" ;
+};
+
+String SCSTR_CHAR_ATTRS
+{
+ Text [ en-US ] = "Font Attributes" ;
+};
+
+
+String SCSTR_CLPBRD_CLEAR
+{
+ Text [ en-US ] = "You have a large amount of data saved in the clipboard.\nDo you want the clipboard contents to be available in other applications?" ;
+};
+
+String SCSTR_CFG_APP
+{
+ Text [ en-US ] = "System Options" ;
+};
+
+String SCSTR_CFG_DOC
+{
+ Text [ en-US ] = "Document Options" ;
+};
+
+String SCSTR_CFG_VIEW
+{
+ Text [ en-US ] = "View Options" ;
+};
+
+String SCSTR_CFG_INPUT
+{
+ Text [ en-US ] = "Input Options" ;
+};
+
+String SCSTR_CFG_SPELLCHECK
+{
+ Text [ en-US ] = "Spelling Options" ;
+};
+
+String SCSTR_CFG_PRINT
+{
+ Text [ en-US ] = "Print Options" ;
+};
+
+String SCSTR_CFG_NAVIPI
+{
+ Text [ en-US ] = "Navigator Settings" ;
+};
+
+String SCSTR_VALID_MINIMUM
+{
+ Text [ en-US ] = "~Minimum" ;
+};
+String SCSTR_VALID_MAXIMUM
+{
+ Text [ en-US ] = "~Maximum" ;
+};
+String SCSTR_VALID_VALUE
+{
+ Text [ en-US ] = "~Value" ;
+};
+String SCSTR_VALID_RANGE
+{
+ Text [ en-US ] = "~Source" ;
+};
+String SCSTR_VALID_LIST
+{
+ Text [ en-US ] = "~Entries" ;
+};
+
+ // fuer Dialoge:
+
+String SCSTR_CHARSET_USER
+{
+ Text [ en-US ] = "System" ;
+};
+
+String SCSTR_COLUMN_USER
+{
+ Text [ en-US ] = "Standard;Text;Date (DMY);Date (MDY);Date (YMD);US English;Hide" ;
+};
+
+String SCSTR_FIELDSEP
+{
+ Text [ en-US ] = ",\t44\t;\t59\t:\t58\t{Tab}\t9\t{space}\t32 " ;
+};
+
+String SCSTR_TEXTSEP
+{
+ Text = "\"\t34\t'\t39" ;
+};
+
+String SCSTR_FORMULA_AUTOCORRECTION
+{
+ Text [ en-US ] = "%PRODUCTNAME Calc found an error in the formula entered.\nDo you want to accept the correction proposed below?\n\n" ;
+};
+
+//! the graphics filter error strings should be moved to svx or offapp!
+
+String SCSTR_GRFILTER_OPENERROR
+{
+ Text [ en-US ] = "Graphics file can not be opened" ;
+};
+String SCSTR_GRFILTER_IOERROR
+{
+ Text [ en-US ] = "Graphics file can not be read" ;
+};
+String SCSTR_GRFILTER_FORMATERROR
+{
+ Text [ en-US ] = "Unknown graphic format" ;
+};
+String SCSTR_GRFILTER_VERSIONERROR
+{
+ Text [ en-US ] = "This graphic file version is not supported" ;
+};
+String SCSTR_GRFILTER_FILTERERROR
+{
+ Text [ en-US ] = "Graphics filter not found" ;
+};
+String SCSTR_GRFILTER_TOOBIG
+{
+ Text [ en-US ] = "Not enough memory available to insert graphics." ;
+};
+String SCSTR_UNDO_GRAFFILTER
+{
+ Text [ en-US ] = "Graphics Filter" ;
+};
+
+// #98185#
+String STR_CAPTION_DEFAULT_TEXT
+{
+ Text [ en-US ] = "Text" ;
+};
+
+// Select tables dialog title
+String STR_DLG_SELECTTABLES_TITLE
+{
+ Text [ en-US ] = "Select Sheets";
+};
+
+// Select tables dialog listbox
+String STR_DLG_SELECTTABLES_LBNAME
+{
+ Text [ en-US ] = "~Selected sheets";
+};
+
+String STR_REPLCELLSWARN
+{
+ Text [ en-US ] = "You are pasting data into cells that already contain data.\nDo you really want to overwrite the existing data?";
+};
+
+String STR_PRINT_NOTHING
+{
+ Text [ en-US ] = "There is nothing to print. The selected print range or sheet is empty.";
+};
+
+String SCSTR_ALLFILTER
+{
+ Text [ en-US ] = "All";
+};
+
+String STR_ACC_CSVRULER_NAME
+{
+ Text [ en-US ] = "Ruler";
+};
+
+String STR_ACC_CSVRULER_DESCR
+{
+ Text [ en-US ] = "This ruler manages objects at fixed positions.";
+};
+
+String STR_ACC_CSVGRID_NAME
+{
+ Text [ en-US ] = "Preview";
+};
+
+String STR_ACC_CSVGRID_DESCR
+{
+ Text [ en-US ] = "This sheet shows how the data will be arranged in the document.";
+};
+
+String STR_ACC_DOC_NAME
+{
+ Text [ en-US ] = "Document view";
+};
+
+String STR_ACC_DOC_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_TABLE_NAME
+{
+ Text [ en-US ] = "Sheet %1";
+};
+
+String STR_ACC_TABLE_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_CELL_NAME
+{
+ Text [ en-US ] = "Cell %1";
+};
+
+String STR_ACC_CELL_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_PREVIEWDOC_NAME
+{
+ Text [ en-US ] = "Page preview";
+};
+
+String STR_ACC_PREVIEWDOC_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_HEADERCELL_NAME
+{
+ Text = "";
+};
+
+String STR_ACC_HEADERCELL_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_LEFTAREA_NAME
+{
+ Text [ en-US ] = "Left area";
+};
+
+String STR_ACC_LEFTAREA_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_CENTERAREA_NAME
+{
+ Text [ en-US ] = "Center area";
+};
+
+String STR_ACC_CENTERAREA_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_RIGHTAREA_NAME
+{
+ Text [ en-US ] = "Right area";
+};
+
+String STR_ACC_RIGHTAREA_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_HEADER_NAME
+{
+ Text [ en-US ] = "Header of page %1";
+};
+
+String STR_ACC_HEADER_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_FOOTER_NAME
+{
+ Text [ en-US ] = "Footer of page %1";
+};
+
+String STR_ACC_FOOTER_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_EDITLINE_NAME
+{
+ Text [ en-US ] = "Input line";
+};
+
+String STR_ACC_EDITLINE_DESCR
+{
+ Text [ en-US ] = "This is where you enter or edit text, numbers and formulas.";
+};
+
+String STR_ACC_EDITCELL_NAME
+{
+ Text [ en-US ] = "Cell %1";
+};
+
+String STR_ACC_EDITCELL_DESCR
+{
+ Text = "";
+};
+
+String STR_ACC_DATAPILOT_ROW_DESCR
+{
+ Text [ en-US ] = "Fields that you drop here will be displayed as rows in the final DataPilot table.";
+};
+
+String STR_ACC_DATAPILOT_COL_DESCR
+{
+ Text [ en-US ] = "Fields that you drop here will be displayed as columns in the final DataPilot table.";
+};
+
+String STR_ACC_DATAPILOT_DATA_DESCR
+{
+ Text [ en-US ] = "Fields that you drop here will be used for calculations in the final DataPilot table.";
+};
+
+String STR_ACC_DATAPILOT_SEL_DESCR
+{
+ Text [ en-US ] = "Lists the fields that you can drag to one of the other three areas.";
+};
+
+String SCSTR_MEDIASHELL
+{
+ Text [ en-US ] = "Media Playback";
+};
+
+String RID_SCSTR_ONCLICK
+{
+ Text [ en-US ] = "Mouse button pressed";
+};
+
+String SCSTR_MOREBTN_MOREOPTIONS
+{
+ Text [ en-US ] = "More ~Options";
+};
+
+String SCSTR_MOREBTN_FEWEROPTIONS
+{
+ Text [ en-US ] = "Fewer ~Options";
+};
+
+StringArray SCSTR_PRINT_OPTIONS
+{
+ ItemList [en-US] =
+ {
+ < "Pages"; >;
+ < "~Include output of empty pages"; >;
+ < "If checked empty pages that have no cell contents or draw objects are not printed."; >;
+ < "Sheets"; >;
+ < "Print ~only selected sheets"; >;
+ < "If checked only contents from selected sheets are printed, even if you specify a wider range in the Format - Print Ranges dialog. Content from sheets that are not selected will not be printed."; >;
+ < "Print content"; >;
+ < "~All sheets"; >;
+ < "The printout will be created from all sheets in the document."; >;
+ < "~Selected sheets"; >;
+ < "The printout will be created only from the currently selected sheets."; >;
+ < "Selected cells"; >;
+ < "The printout will be created only from the currently selected cells."; >;
+ < "Thereof print"; >;
+ < "All ~pages"; >;
+ < "Print all pages of the printable content."; >;
+ < "Pa~ges"; >;
+ < "Print only some pages of the printable content."; >;
+ < "%PRODUCTNAME %s"; >;
+ };
+};
+
diff --git a/sc/source/ui/src/scwarngs.src b/sc/source/ui/src/scwarngs.src
new file mode 100644
index 000000000000..64184e9e41e5
--- /dev/null
+++ b/sc/source/ui/src/scwarngs.src
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define __RSC
+#include "scwarngs.hxx"
+#include "sc.hrc"
+
+
+
+#define SH_MAX 0x7fff
+
+Resource RID_WRNHDLSC
+{
+ String ERRCODE_SC_EXPORT_WRN_ASCII & SH_MAX
+ {
+ Text [ en-US ] = "Only the active sheet could be saved." ;
+ };
+ String ERRCODE_SC_IMPORT_WRN_RNGOVRFLW & SH_MAX
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Die Maximalanzahl von Zeilen wurde überschritten. überzählige Zeilen wurden nicht mitimportiert! : Die Maximalanzahl von Zeilen wurde ³berschritten. ³berzõhlige Zeilen wurden nicht mitimportiert! */
+ Text [ en-US ] = "The number of rows exceeded the maximum. Additional rows were not imported!" ;
+ };
+ /*
+ String ERRCODE_SC_ & SH_MAX
+ {
+ Text = "";
+ };
+*/
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/simpref.src b/sc/source/ui/src/simpref.src
new file mode 100644
index 000000000000..d0bf767f4f50
--- /dev/null
+++ b/sc/source/ui/src/simpref.src
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "simpref.hrc"
+ModelessDialog RID_SCDLG_SIMPLEREF
+{
+ OutputSize = TRUE ;
+ //HelpId = SID_DEFINE_DBNAME ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 222 , 60 ) ;
+ Text = "Bereich festlegen" ;
+ Moveable = TRUE ;
+ // Closeable = TRUE; // Dieser Dialog hat einen Cancel-Button !
+ FixedText FT_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 6 , 6 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ Text [ en-US ] = "Area" ;
+ };
+ Edit ED_ASSIGN
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 48 , 6 ) ;
+ Size = MAP_APPFONT ( 90 , 12 ) ;
+ TabStop = TRUE ;
+ // Text = "<Tabellenbereich>" ;
+ };
+ ImageButton RB_ASSIGN
+ {
+ Pos = MAP_APPFONT ( 142 , 5 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 166 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 166 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 166 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/solveroptions.src b/sc/source/ui/src/solveroptions.src
new file mode 100644
index 000000000000..12e02f690e2a
--- /dev/null
+++ b/sc/source/ui/src/solveroptions.src
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "solveroptions.hrc"
+
+ModalDialog RID_SCDLG_SOLVEROPTIONS
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_SOLVEROPTIONS ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 218 , 156 ) ;
+ Moveable = TRUE ;
+ FixedText FT_ENGINE
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 59 , 8 ) ;
+ Text [ en-US ] = "Solver engine" ;
+ };
+ ListBox LB_ENGINE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 67 , 6 ) ;
+ Size = MAP_APPFONT ( 145 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_SETTINGS
+ {
+ Pos = MAP_APPFONT ( 6 , 24 ) ;
+ Size = MAP_APPFONT ( 156 , 8 ) ;
+ Text [ en-US ] = "Settings:" ;
+ };
+ Control LB_SETTINGS
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 35 ) ;
+ Size = MAP_APPFONT ( 206 , 67 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_EDIT
+ {
+ Pos = MAP_APPFONT ( 6 , 108 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Edit..." ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 125 ) ;
+ Size = MAP_APPFONT ( 218 , 8 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 6 , 136 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 106 , 136 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 162 , 136 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Options" ;
+};
+
+
+ModalDialog RID_SCDLG_SOLVER_INTEGER
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_SOLVER_INTEGER ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 118 , 76 ) ;
+ Moveable = TRUE ;
+ FixedText FT_OPTIONNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 106 , 16 ) ;
+ WordBreak = TRUE ;
+ // text is dynamic
+ };
+ NumericField NF_VALUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 30 , 12 ) ;
+ TabStop = TRUE ;
+ Spin = TRUE ;
+ SpinSize = 1 ;
+ Repeat = TRUE ;
+ Minimum = -2147483648 ;
+ Maximum = 2147483647 ;
+ First = 0 ;
+ Last = 100 ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 45 ) ;
+ Size = MAP_APPFONT ( 118 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 62 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Edit Setting" ;
+};
+
+ModalDialog RID_SCDLG_SOLVER_DOUBLE
+{
+ OutputSize = TRUE ;
+ HelpId = HID_SC_SOLVER_DOUBLE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 118 , 76 ) ;
+ Moveable = TRUE ;
+ FixedText FT_OPTIONNAME
+ {
+ Pos = MAP_APPFONT ( 6 , 8 ) ;
+ Size = MAP_APPFONT ( 106 , 16 ) ;
+ WordBreak = TRUE ;
+ // text is dynamic
+ };
+ Edit ED_VALUE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 27 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_BUTTONS
+ {
+ Pos = MAP_APPFONT ( 0 , 45 ) ;
+ Size = MAP_APPFONT ( 118 , 8 ) ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 6 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 62 , 56 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Edit Setting" ;
+};
+
diff --git a/sc/source/ui/src/solvrdlg.src b/sc/source/ui/src/solvrdlg.src
new file mode 100644
index 000000000000..c067a6db14c6
--- /dev/null
+++ b/sc/source/ui/src/solvrdlg.src
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "solvrdlg.hrc"
+ModelessDialog RID_SCDLG_SOLVER
+{
+ OutputSize = TRUE ;
+ HelpId = SID_OPENDLG_SOLVE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 222 , 64 ) ;
+ Text [ en-US ] = "Goal Seek" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_FORMULACELL
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "~Formula cell" ;
+ };
+ Edit ED_FORMULACELL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 64 , 14 ) ;
+ Size = MAP_APPFONT ( 79 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_FORMULACELL
+ {
+ Pos = MAP_APPFONT ( 145 , 13 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_TARGETVAL
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Target ~value" ;
+ };
+ Edit ED_TARGETVAL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 64 , 30 ) ;
+ Size = MAP_APPFONT ( 93 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_VARCELL
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Variable ~cell" ;
+ };
+ Edit ED_VARCELL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 64 , 46 ) ;
+ Size = MAP_APPFONT ( 79 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ ImageButton RB_VARCELL
+ {
+ Pos = MAP_APPFONT ( 145 , 45 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_VARIABLES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 154 , 8 ) ;
+ Text [ en-US ] = "Default settings" ;
+ };
+ OKButton BTN_OK
+ {
+ DefButton = TRUE ;
+ Pos = MAP_APPFONT ( 166 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 166 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 166 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_INVALIDVAL
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Unzulässiger Zielwert! : Unzulõssiger Zielwert! */
+ Text [ en-US ] = "Invalid target value." ;
+ };
+ String STR_INVALIDVAR
+ {
+ Text [ en-US ] = "Undefined name for variable cell." ;
+ };
+ String STR_INVALIDFORM
+ {
+ Text [ en-US ] = "Undefined name as formula cell." ;
+ };
+ String STR_NOFORMULA
+ {
+ /* ### ACHTUNG: Neuer Text in Resource? Zelle muß eine Formel enthalten! : Zelle mu˜ eine Formel enthalten! */
+ Text [ en-US ] = "Cell must contain a formula." ;
+ };
+};
diff --git a/sc/source/ui/src/sortdlg.src b/sc/source/ui/src/sortdlg.src
new file mode 100644
index 000000000000..4090bbaa4554
--- /dev/null
+++ b/sc/source/ui/src/sortdlg.src
@@ -0,0 +1,361 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "sortdlg.hrc"
+TabPage RID_SCPAGE_SORT_FIELDS
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_SCPAGE_SORT_FIELDS ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ ListBox LB_SORT1
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 19 ) ;
+ Size = MAP_APPFONT ( 154 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ RadioButton BTN_UP1
+ {
+ Pos = MAP_APPFONT ( 172 , 14 ) ;
+ Size = MAP_APPFONT ( 79 , 10 ) ;
+ Text [ en-US ] = "~Ascending" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DOWN1
+ {
+ Pos = MAP_APPFONT ( 172 , 28 ) ;
+ Size = MAP_APPFONT ( 79 , 10 ) ;
+ Text [ en-US ] = "~Descending" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_SORT1
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Sort ~by" ;
+ };
+ ListBox LB_SORT2
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 60 ) ;
+ Size = MAP_APPFONT ( 154 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ RadioButton BTN_UP2
+ {
+ Pos = MAP_APPFONT ( 172 , 55 ) ;
+ Size = MAP_APPFONT ( 79 , 10 ) ;
+ Text [ en-US ] = "A~scending" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DOWN2
+ {
+ Pos = MAP_APPFONT ( 172 , 69 ) ;
+ Size = MAP_APPFONT ( 79 , 10 ) ;
+ Text [ en-US ] = "D~escending" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_SORT2
+ {
+ Pos = MAP_APPFONT ( 6 , 44 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Then b~y" ;
+ };
+ ListBox LB_SORT3
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 101 ) ;
+ Size = MAP_APPFONT ( 154 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ RadioButton BTN_UP3
+ {
+ Pos = MAP_APPFONT ( 172 , 96 ) ;
+ Size = MAP_APPFONT ( 79 , 10 ) ;
+ Text [ en-US ] = "As~cending" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DOWN3
+ {
+ Pos = MAP_APPFONT ( 172 , 110 ) ;
+ Size = MAP_APPFONT ( 79 , 10 ) ;
+ Text [ en-US ] = "Desce~nding" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_SORT3
+ {
+ Pos = MAP_APPFONT ( 6 , 85 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "T~hen by" ;
+ };
+};
+TabPage RID_SCPAGE_SORT_OPTIONS
+{
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpId = HID_SCPAGE_SORT_OPTIONS ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ CheckBox BTN_CASESENSITIVE
+ {
+ Pos = MAP_APPFONT ( 12 , 6 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ en-US ] = "Case ~sensitive" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_LABEL
+ {
+ Pos = MAP_APPFONT ( 12 , 20 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ TabStop = TRUE ;
+ };
+ String STR_COL_LABEL
+ {
+ Text [ en-US ] = "Range contains column la~bels" ;
+ };
+ String STR_ROW_LABEL
+ {
+ Text [ en-US ] = "Range contains ~row labels" ;
+ };
+ CheckBox BTN_FORMATS
+ {
+ Pos = MAP_APPFONT ( 12 , 34 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ en-US ] = "Include ~formats" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_NATURALSORT
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ de ] = "Enable ~natural sort" ;
+ Text [ en-US ] = "Enable ~natural sort" ;
+ Text [ cs ] = "Aktivovat přirozené třídění" ;
+ Text [ sk ] = "Aktivovať prirodzené triedenie" ;
+ TabStop = TRUE ;
+ Text [ x-comment ] = " " ;
+ };
+ CheckBox BTN_COPYRESULT
+ {
+ Pos = MAP_APPFONT ( 12 , 62 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ en-US ] = "~Copy sort results to:" ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_OUTAREA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 73 ) ;
+ Size = MAP_APPFONT ( 93 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ Edit ED_OUTAREA
+ {
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 119 , 73 ) ;
+ Size = MAP_APPFONT ( 132 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_SORT_USER
+ {
+ Pos = MAP_APPFONT ( 12 , 89 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ en-US ] = "Custom sort ~order" ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_SORT_USER
+ {
+ Disable = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 100 ) ;
+ Size = MAP_APPFONT ( 231 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_LANGUAGE
+ {
+ Pos = MAP_APPFONT ( 12 , 118 ) ;
+ Size = MAP_APPFONT ( 101 , 8 ) ;
+ Text [ en-US ] = "~Language";
+ };
+ ListBox LB_LANGUAGE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 12 , 129 ) ;
+ Size = MAP_APPFONT ( 101 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ Sort = TRUE ;
+ };
+ FixedText FT_ALGORITHM
+ {
+ Pos = MAP_APPFONT ( 119 , 118 ) ;
+ Size = MAP_APPFONT ( 132 , 8 ) ;
+ Text [ en-US ] = "O~ptions";
+ };
+ ListBox LB_ALGORITHM
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 119 , 129 ) ;
+ Size = MAP_APPFONT ( 132 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedLine FL_DIRECTION
+ {
+ Pos = MAP_APPFONT ( 6 , 147 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Direction" ;
+ };
+ RadioButton BTN_TOP_DOWN
+ {
+ Pos = MAP_APPFONT ( 12 , 158 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ en-US ] = "~Top to bottom (sort rows)" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_LEFT_RIGHT
+ {
+ Pos = MAP_APPFONT ( 12 , 172 ) ;
+ Size = MAP_APPFONT ( 242 , 10 ) ;
+ Text [ en-US ] = "L~eft to right (sort columns)" ;
+ TabStop = TRUE ;
+ };
+/*
+ FixedText FT_AREA_LABEL
+ {
+ Pos = MAP_APPFONT ( 6 , 171 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Data area:" ;
+ };
+*/
+};
+TabDialog RID_SCDLG_SORT
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 220 , 175 ) ;
+ Text [ en-US ] = "Sort" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 210 , 170 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_FIELDS ;
+ PageResID = TP_FIELDS ;
+ Text [ en-US ] = "Sort Criteria" ;
+ };
+ PageItem
+ {
+ Identifier = TP_OPTIONS ;
+ PageResID = TP_OPTIONS ;
+ Text [ en-US ] = "Options" ;
+ };
+ };
+ };
+ OKButton 1
+ {
+ Pos = MAP_APPFONT ( 3 , 157 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT ( 49 , 157 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton 1
+ {
+ Pos = MAP_APPFONT ( 137 , 157 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton 1
+ {
+ Pos = MAP_APPFONT ( 94 , 157 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ TabStop = TRUE ;
+ };
+};
+
+ModalDialog RID_SCDLG_SORT_WARNING
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 180 , 91 ) ;
+ Text [ en-US ] = "Sort Range" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_TEXT
+ {
+ Pos = MAP_APPFONT ( 8 , 3 ) ;
+ Size = MAP_APPFONT ( 170 , 33 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "The cells next to the current selection also contain data. Do you want to extend the sort range to %1, or sort the currently selected range, %2?";
+ };
+ FixedText FT_TIP
+ {
+ Pos = MAP_APPFONT ( 8 , 55 ) ;
+ Size = MAP_APPFONT ( 170 , 33 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Tip: The sort range can be detected automatically. Place the cell cursor inside a list and execute sort. The whole range of neighboring non-empty cells will then be sorted.";
+ };
+ PushButton BTN_EXTSORT
+ {
+ Pos = MAP_APPFONT ( 6 , 39 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ Text [ en-US ] = "Extend selection";
+ };
+ PushButton BTN_CURSORT
+ {
+ Pos = MAP_APPFONT ( 70 , 39 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Current selection";
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 134 , 39 ) ;
+ Size = MAP_APPFONT ( 40 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/sc/source/ui/src/subtdlg.src b/sc/source/ui/src/subtdlg.src
new file mode 100644
index 000000000000..b97b6c8383c5
--- /dev/null
+++ b/sc/source/ui/src/subtdlg.src
@@ -0,0 +1,291 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "subtdlg.hrc"
+
+TabPage RID_SCPAGE_SUBT_OPTIONS
+{
+ HelpId = HID_SCPAGE_SUBT_OPTIONS ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Hide = TRUE ;
+ FixedLine FL_GROUP
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Groups";
+ };
+ CheckBox BTN_PAGEBREAK
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Page break between groups" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_CASE
+ {
+ Pos = MAP_APPFONT ( 12 , 28 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Groß-/Kleinschreibung beachten : ~Gro˜-/Kleinschreibung beachten */
+ Text [ en-US ] = "~Case sensitive" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_SORT
+ {
+ Pos = MAP_APPFONT ( 12 , 42 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "Pre-~sort area according to groups" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_FORMATS
+ {
+ Pos = MAP_APPFONT ( 12 , 101 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Formate einschließen : ~Formate einschlie˜en */
+ Text [ en-US ] = "I~nclude formats" ;
+ TabStop = TRUE ;
+ };
+ CheckBox BTN_USERDEF
+ {
+ Pos = MAP_APPFONT ( 12 , 115 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "C~ustom sort order" ;
+ TabStop = TRUE ;
+ };
+ ListBox LB_USERDEF
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 127 ) ;
+ Size = MAP_APPFONT ( 231 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ RadioButton BTN_ASCENDING
+ {
+ Pos = MAP_APPFONT ( 12 , 69 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "~Ascending" ;
+ TabStop = TRUE ;
+ };
+ RadioButton BTN_DESCENDING
+ {
+ Pos = MAP_APPFONT ( 12 , 83 ) ;
+ Size = MAP_APPFONT ( 239 , 10 ) ;
+ Text [ en-US ] = "D~escending" ;
+ TabStop = TRUE ;
+ };
+ FixedLine FL_SORT
+ {
+ Pos = MAP_APPFONT ( 6 , 58 ) ;
+ Size = MAP_APPFONT ( 248 , 8 ) ;
+ Text [ en-US ] = "Sort" ;
+ };
+};
+
+
+TabPage RID_SUBTBASE
+{
+ // Die Elemente haben hart vergebene Hilfe-IDs, weil automatisch generierte
+ // aus den Ableitungen nicht in der HID-Liste auftauchen wuerden
+ HelpId = HID_SCPAGE_SUBT_GROUP ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Hide = TRUE ;
+ FixedText FT_GROUP
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "~Group by" ;
+ };
+ ListBox LB_GROUP
+ {
+ HelpId = HID_SC_SUBT_GROUP ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 121 , 90 ) ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_COLUMNS
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Teilergebnisse berechnen für : ~Teilergebnisse berechnen f³r */
+ Text [ en-US ] = "~Calculate subtotals for" ;
+ };
+ Control WND_COLUMNS
+ {
+ HelpId = HID_SC_SUBT_COLS ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 43 ) ;
+ Size = MAP_APPFONT ( 121 , 136 ) ;
+ TabStop = TRUE ;
+ };
+ FixedText FT_FUNCTIONS
+ {
+ Pos = MAP_APPFONT ( 133 , 32 ) ;
+ Size = MAP_APPFONT ( 121 , 8 ) ;
+ Text [ en-US ] = "Use ~function" ;
+ };
+ ListBox LB_FUNCTIONS
+ {
+ HelpId = HID_SC_SUBT_FUNC ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 133 , 43 ) ;
+ Size = MAP_APPFONT ( 121 , 136 ) ;
+ TabStop = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Sum" ; Default ; > ;
+ < "Count" ; Default ; > ;
+ < "Average" ; Default ; > ;
+ < "Max" ; Default ; > ;
+ < "Min" ; Default ; > ;
+ < "Product" ; Default ; > ;
+ < "Count (numbers only)" ; Default ; > ;
+ < "StDev (Sample)" ; Default ; > ;
+ < "StDevP (Population)" ; Default ; > ;
+ < "Var (Sample)" ; Default ; > ;
+ < "VarP (Population)" ; Default ; > ;
+ };
+ };
+};
+
+ // "Control" braucht immer eigene HelpId - ansonsten aus RID_SUBTBASE kopiert
+
+TabPage RID_SCPAGE_SUBT_GROUP1 < RID_SUBTBASE
+{
+ HelpId = HID_SCPAGE_SUBT_GROUP1 ;
+};
+TabPage RID_SCPAGE_SUBT_GROUP2 < RID_SUBTBASE
+{
+ HelpId = HID_SCPAGE_SUBT_GROUP2 ;
+};
+TabPage RID_SCPAGE_SUBT_GROUP3 < RID_SUBTBASE
+{
+ HelpId = HID_SCPAGE_SUBT_GROUP3 ;
+};
+
+TabDialog RID_SCDLG_SUBTOTALS
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 294 , 176 ) ;
+ Text [ en-US ] = "Subtotals" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( 240 , 150 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = PAGE_GROUP1 ;
+ Text [ en-US ] = "1st Group" ;
+ };
+ PageItem
+ {
+ Identifier = PAGE_GROUP2 ;
+ Text [ en-US ] = "2nd Group" ;
+ };
+ PageItem
+ {
+ Identifier = PAGE_GROUP3 ;
+ Text [ en-US ] = "3rd Group" ;
+ };
+ PageItem
+ {
+ Identifier = PAGE_OPTIONS ;
+ Text [ en-US ] = "Options" ;
+ };
+ };
+ };
+ PushButton BTN_REMOVE
+ {
+ Pos = MAP_APPFONT ( 143 , 160 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? ~Löschen : ~L÷schen */
+ Text [ en-US ] = "~Delete" ;
+ TabStop = TRUE ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/tabopdlg.src b/sc/source/ui/src/tabopdlg.src
new file mode 100644
index 000000000000..6df01004931e
--- /dev/null
+++ b/sc/source/ui/src/tabopdlg.src
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "tabopdlg.hrc"
+ModelessDialog RID_SCDLG_TABOP
+{
+ OutputSize = TRUE ;
+ HelpId = SID_OPENDLG_TABOP ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 240 , 64 ) ;
+ Text [ en-US ] = "Multiple operations" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ FixedText FT_FORMULARANGE
+ {
+ Pos = MAP_APPFONT ( 12 , 16 ) ;
+ Size = MAP_APPFONT ( 68 , 8 ) ;
+ Text [ en-US ] = "~Formulas" ;
+ };
+ Edit ED_FORMULARANGE
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 82 , 14 ) ;
+ Size = MAP_APPFONT ( 79 , 12 ) ;
+ };
+ ImageButton RB_FORMULARANGE
+ {
+ Pos = MAP_APPFONT ( 163 , 13 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_ROWCELL
+ {
+ Pos = MAP_APPFONT ( 12 , 32 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ Text [ en-US ] = "~Row input cell" ;
+ };
+ Edit ED_ROWCELL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 82 , 30 ) ;
+ Size = MAP_APPFONT ( 79 , 12 ) ;
+ };
+ ImageButton RB_ROWCELL
+ {
+ Pos = MAP_APPFONT ( 163 , 29 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedText FT_COLCELL
+ {
+ Pos = MAP_APPFONT ( 12 , 48 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ Text [ en-US ] = "~Column input cell" ;
+ };
+ Edit ED_COLCELL
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 82 , 46 ) ;
+ Size = MAP_APPFONT ( 79 , 12 ) ;
+ };
+ ImageButton RB_COLCELL
+ {
+ Pos = MAP_APPFONT ( 163 , 45 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Shrink" ;
+ };
+ FixedLine FL_VARIABLES
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 172 , 8 ) ;
+ Text [ en-US ] = "Default settings" ;
+ };
+ OKButton BTN_OK
+ {
+ Pos = MAP_APPFONT ( 184 , 6 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ DefButton = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 184 , 23 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 184 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String STR_NOFORMULA
+ {
+ Text [ en-US ] = "No formula specified." ;
+ };
+ String STR_NOCOLROW
+ {
+ Text [ en-US ] = "Neither row or column specified." ;
+ };
+ String STR_WRONGFORMULA
+ {
+ Text [ en-US ] = "Undefined name or range." ;
+ };
+ String STR_WRONGROWCOL
+ {
+ Text [ en-US ] = "Undefined name or wrong cell reference." ;
+ };
+ String STR_NOCOLFORMULA
+ {
+ Text [ en-US ] = "Formulas don't form a column." ;
+ };
+ String STR_NOROWFORMULA
+ {
+ Text [ en-US ] = "Formulas don't form a row." ;
+ };
+};
diff --git a/sc/source/ui/src/textdlgs.src b/sc/source/ui/src/textdlgs.src
new file mode 100644
index 000000000000..447b174e1aec
--- /dev/null
+++ b/sc/source/ui/src/textdlgs.src
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+
+#include <svx/dialogs.hrc>
+#include "sc.hrc"
+
+TabDialog RID_SCDLG_CHAR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Text [ en-US ] = "Character" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_NAME ;
+ Text [ en-US ] = "Font";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_EFFECTS ;
+ Text [ en-US ] = "Font Effects";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_CHAR_POSITION ;
+ Text [ en-US ] = "Font Position";
+ };
+ };
+ };
+ OKButton 1
+ {
+ Pos = MAP_APPFONT ( 6 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT ( 60 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton 1
+ {
+ Pos = MAP_APPFONT ( 114 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton 1
+ {
+ Pos = MAP_APPFONT ( 169 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zurück : Zur³ck */
+ Text [ en-US ] = "Back" ;
+ TabStop = TRUE ;
+ };
+};
+
+TabDialog RID_SCDLG_PARAGRAPH
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Text [ en-US ] = "Paragraph" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_STD_PARAGRAPH ;
+ /* ### ACHTUNG: Neuer Text in Resource? Einzüge und Abstände : Einz³ge und Abstõnde */
+ Text [ en-US ] = "Indents & Spacing" ;
+ PageResID = RID_SVXPAGE_STD_PARAGRAPH ;
+ };
+ /*
+ PageItem {
+ Identifier = RID_SVXPAGE_EXT_PARAGRAPH;
+ Text [ en-US ] = "Paragraph (Extensions)";
+ PageResID = RID_SVXPAGE_EXT_PARAGRAPH;
+ };
+*/
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_ALIGN_PARAGRAPH ;
+ PageResID = RID_SVXPAGE_ALIGN_PARAGRAPH ;
+ Text [ en-US ] = "Alignment" ;
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_PARA_ASIAN ;
+ Text [ en-US ] = "Asian Typography";
+ };
+ PageItem
+ {
+ Identifier = RID_SVXPAGE_TABULATOR ;
+ Text [ en-US ] = "Tab" ;
+ PageResID = RID_SVXPAGE_TABULATOR ;
+ };
+ };
+ };
+ OKButton 1
+ {
+ Pos = MAP_APPFONT ( 6 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT ( 60 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ HelpButton 1
+ {
+ Pos = MAP_APPFONT ( 114 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton 1
+ {
+ Pos = MAP_APPFONT ( 169 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zurück : Zur³ck */
+ Text [ en-US ] = "Back" ;
+ TabStop = TRUE ;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/src/toolbox.src b/sc/source/ui/src/toolbox.src
new file mode 100644
index 000000000000..85fb80bfcc5f
--- /dev/null
+++ b/sc/source/ui/src/toolbox.src
@@ -0,0 +1,299 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc" // -> #include <sfx.hrc>
+#include <svx/globlmn.hrc>
+#include "tbinsert.hrc" // Sub-IDs
+
+
+ // ToolBoxen: ----------------------------------------------------------------
+
+/*
+ * ToolBox mit Eingabezeile: HelpStrings fuer Knoepfe und Fenster:
+ */
+
+#define ITEM_TOOLBAR_SORT_ASCENDING \
+ Identifier = SID_SORT_ASCENDING ; \
+ HelpId = SID_SORT_ASCENDING ;
+
+#define ITEM_TOOLBAR_SORT_DESCENDING \
+ Identifier = SID_SORT_DESCENDING ; \
+ HelpId = SID_SORT_DESCENDING ;
+
+#define ITEM_TOOLBAR_INSERT_FRAME \
+ Identifier = SID_INSERT_FRAME ; \
+ HelpId = SID_INSERT_FRAME ;
+
+
+#define ITEM_TOOLBAR_INSERT_GRAPHIC \
+ Identifier = SID_INSERT_GRAPHIC ; \
+ HelpId = SID_INSERT_GRAPHIC ;
+
+#define ITEM_TOOLBAR_AUTO_FILTER \
+ Identifier = SID_AUTO_FILTER ; \
+ HelpId = SID_AUTO_FILTER ;
+
+
+#define ITEM_TOOLBAR_OUTLINE_MAKE \
+ Identifier = SID_OUTLINE_MAKE ; \
+ HelpId = SID_OUTLINE_MAKE ;
+
+
+#define ITEM_TOOLBAR_OUTLINE_REMOVE \
+ Identifier = SID_OUTLINE_REMOVE ; \
+ HelpId = SID_OUTLINE_REMOVE ;
+
+#define ITEM_TOOLBAR_DRAW_CHART \
+ Identifier = SID_INSERT_DIAGRAM ; \
+ HelpId = SID_DRAW_CHART ;
+
+#define ITEM_TOOLBAR_SPELLING \
+ Identifier = SID_SPELL_DIALOG ; \
+ HelpId = SID_SPELL_DIALOG ;
+
+#define ITEM_TOOLBAR_THESAURUS \
+ Identifier = SID_THESAURUS ; \
+ HelpId = SID_THESAURUS ;
+
+#define ITEM_TOOLBAR_FILTER \
+ Identifier = SID_FILTER ; \
+ HelpId = SID_FILTER ;
+
+#define ITEM_TOOLBAR_SPECIAL_FILTER \
+ Identifier = SID_SPECIAL_FILTER;\
+ HelpId = SID_SPECIAL_FILTER ;
+
+String SCSTR_QHELP_POSWND
+{
+ Text [ en-US ] = "Name Box" ;
+};
+
+String SCSTR_QHELP_INPUTWND
+{
+ Text [ en-US ] = "Input line" ;
+};
+
+String SCSTR_QHELP_BTNCALC
+{
+ Text [ en-US ] = "Function Wizard" ;
+};
+
+String SCSTR_QHELP_BTNOK
+{
+ /* ### ACHTUNG: Neuer Text in Resource? Übernehmen : šbernehmen */
+ Text [ en-US ] = "Accept" ;
+};
+
+String SCSTR_QHELP_BTNCANCEL
+{
+ Text [ en-US ] = "Cancel" ;
+};
+
+String SCSTR_QHELP_BTNSUM
+{
+ Text [ en-US ] = "Sum" ;
+};
+
+String SCSTR_QHELP_BTNEQUAL
+{
+ Text [ en-US ] = "Function" ;
+};
+
+ // --------------------------------------------------------------------
+ // PopUp's fuer Werkzeugleiste
+ // --------------------------------------------------------------------
+
+FloatingWindow RID_TBXCTL_INSERT
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpID = RID_TBXCTL_INSERT ;
+ /* ### ACHTUNG: Neuer Text in Resource? Einfügen : Einf³gen */
+ Text [ en-US ] = "Insert" ;
+
+ ToolBox RID_TOOLBOX_INSERT
+ {
+ MenuStrings = TRUE ;
+ SVLook = TRUE ;
+ HelpID = RID_TOOLBOX_INSERT ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = SID_INSERT_GRAPHIC ;
+ HelpID = SID_INSERT_GRAPHIC ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_CHARMAP ;
+ HelpId = SID_CHARMAP ;
+ };
+ };
+ };
+};
+
+FloatingWindow RID_TBXCTL_INSCELLS
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ HelpID = RID_TBXCTL_INSCELLS ;
+ /* ### ACHTUNG: Neuer Text in Resource? Zellen einfügen : Zellen einf³gen */
+ Text [ en-US ] = "Insert Cells" ;
+
+ ToolBox RID_TOOLBOX_INSCELLS
+ {
+ MenuStrings = TRUE ;
+ SVLook = TRUE ;
+ HelpID = RID_TOOLBOX_INSCELLS ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = FID_INS_CELLSDOWN ;
+ HelpId = FID_INS_CELLSDOWN ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FID_INS_CELLSRIGHT ;
+ HelpId = FID_INS_CELLSRIGHT ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FID_INS_ROW ;
+ HelpId = FID_INS_ROW ;
+ };
+ ToolBoxItem
+ {
+ Identifier = FID_INS_COLUMN ;
+ HelpId = FID_INS_COLUMN ;
+ };
+ };
+ };
+};
+
+FloatingWindow RID_TBXCTL_INSOBJ
+{
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE;
+ HelpID = RID_TBXCTL_INSOBJ ;
+ /* ### ACHTUNG: Neuer Text in Resource? Objekt einfügen : Objekt einf³gen */
+ Text [ en-US ] = "Insert Object" ;
+ ToolBox RID_TOOLBOX_INSOBJ
+ {
+ MenuStrings = TRUE ;
+ SVLook = TRUE ;
+ HelpID = RID_TOOLBOX_INSOBJ ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ // mit Aufziehen des Zielbereichs
+ ITEM_TOOLBAR_DRAW_CHART
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_INSERT_SMATH ;
+ HelpId = SID_INSERT_SMATH ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_INSERT_FLOATINGFRAME ;
+ HelpID = SID_INSERT_FLOATINGFRAME ;
+ };
+ ToolBoxItem
+ {
+ Identifier = SID_INSERT_OBJECT ;
+ HelpId = SID_INSERT_OBJECT ;
+ };
+#ifdef SOLAR_PLUGIN
+ ToolBoxItem
+ {
+ Identifier = SID_INSERT_PLUGIN ;
+ HelpId = SID_INSERT_PLUGIN ;
+ };
+#endif
+#ifdef SOLAR_JAVA
+ ToolBoxItem
+ {
+ Identifier = SID_INSERT_APPLET ;
+ HelpId = SID_INSERT_APPLET ;
+ };
+#endif
+ };
+ };
+};
+
+// Don't use this image list for normal toolbar images. We have now our commandimagelist
+// folder in default_images. This list is now only used for special toolboxes that are
+// used in floating windows.
+
+#define DEFAULT_IDLIST \
+ IdList = { \
+ /* Eingabezeile */ \
+ SID_INPUT_FUNCTION; /* 20047 */ \
+ SID_INPUT_SUM; /* 20048 */ \
+ SID_INPUT_EQUAL; /* 20049 */ \
+ SID_INPUT_CANCEL; \
+ SID_INPUT_OK; \
+ }; \
+ IdCount = { \
+ 5; \
+ };
+
+ImageList RID_DEFAULTIMAGELIST_SC
+{
+ Prefix = "sc";
+ MaskColor = STD_MASKCOLOR ;
+ DEFAULT_IDLIST
+};
+
+ImageList RID_DEFAULTIMAGELIST_LC
+{
+ Prefix = "lc";
+ MaskColor = STD_MASKCOLOR ;
+ DEFAULT_IDLIST
+};
+
+ImageList RID_DEFAULTIMAGELIST_SCH
+{
+ Prefix = "sch";
+ MaskColor = SC_HC_MASKCOLOR ;
+ DEFAULT_IDLIST
+};
+
+ImageList RID_DEFAULTIMAGELIST_LCH
+{
+ Prefix = "lch";
+ MaskColor = SC_HC_MASKCOLOR ;
+ DEFAULT_IDLIST
+};
diff --git a/sc/source/ui/styleui/makefile.mk b/sc/source/ui/styleui/makefile.mk
new file mode 100644
index 000000000000..ccbd2e14f34c
--- /dev/null
+++ b/sc/source/ui/styleui/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=styleui
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ styledlg.cxx
+
+SLOFILES = \
+ $(SLO)$/styledlg.obj \
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ scstyles.src \
+ styledlg.src
+
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/styleui/scstyles.src b/sc/source/ui/styleui/scstyles.src
new file mode 100644
index 000000000000..8c057d65f70a
--- /dev/null
+++ b/sc/source/ui/styleui/scstyles.src
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+#include <svl/style.hrc>
+#define IMPL_FAMILY(family,filter) \
+ StyleFamily = family; \
+ FilterList = { filter }
+
+ //------------------------------------------------------------------------
+SfxStyleFamilies DLG_STYLE_DESIGNER
+{
+ StyleFamilyList =
+ {
+ SfxStyleFamilyItem
+ {
+ IMPL_FAMILY ( SFX_STYLE_FAMILY_PARA ,
+ < STR_STYLE_FILTER_ALL ; SFXSTYLEBIT_ALL ; > ;
+ < STR_STYLE_FILTER_USED ; SFXSTYLEBIT_USED ; > ;
+ < STR_STYLE_FILTER_USERDEF ; SFXSTYLEBIT_USERDEF ; > ; ) ;
+ Text [ en-US ] = "Cell Styles" ;
+};
+ SfxStyleFamilyItem
+ {
+ IMPL_FAMILY ( SFX_STYLE_FAMILY_PAGE ,
+ < STR_STYLE_FILTER_ALL ; SFXSTYLEBIT_ALL ; > ;
+ < STR_STYLE_FILTER_USERDEF ; SFXSTYLEBIT_USERDEF ; > ; ) ;
+ Text [ en-US ] = "Page Styles" ;
+};
+ };
+
+ // style family images are now taken from an ImageList
+ // (for each family, there's one entry in the IdList)
+ ImageList 1 // == BMP_COLOR_NORMAL + 1
+ {
+ Prefix = "sf";
+ MaskColor = STD_MASKCOLOR ;
+ IdList = { 1; 2; };
+};
+ ImageList 2 // == BMP_COLOR_HIGHCONTRAST + 1
+ {
+ Prefix = "sfh";
+ MaskColor = SC_HC_MASKCOLOR ;
+ IdList = { 1; 2; };
+};
+};
diff --git a/sc/source/ui/styleui/styledlg.cxx b/sc/source/ui/styleui/styledlg.cxx
new file mode 100644
index 000000000000..ae9d2e98c350
--- /dev/null
+++ b/sc/source/ui/styleui/styledlg.cxx
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#undef SC_DLLIMPLEMENTATION
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/numinf.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/style.hxx>
+#include <svl/cjkoptions.hxx>
+
+#include "styledlg.hxx"
+#include "tabpages.hxx" // Zellvorlagen
+#include "tphf.hxx" // Seitenvorlage: Kopf-/Fusszeilen
+#include "tptable.hxx" // Seitenvorlage: Tabelle
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "styledlg.hrc"
+#include <svx/svxdlg.hxx>
+#include <svx/svxids.hrc>
+#include <svx/dialogs.hrc>
+#include <svl/intitem.hxx>
+#include <editeng/flstitem.hxx>
+#include <svl/aeitem.hxx>
+#include <svx/flagsdef.hxx>
+//==================================================================
+
+ScStyleDlg::ScStyleDlg( Window* pParent,
+ SfxStyleSheetBase& rStyleBase,
+ USHORT nRscId )
+
+ : SfxStyleDialog ( pParent,
+ ScResId( nRscId ),
+ rStyleBase,
+ FALSE ),
+ nDlgRsc ( nRscId )
+{
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ switch ( nRscId )
+ {
+ case RID_SCDLG_STYLES_PAR: // Zellformatvorlagen
+ {
+ SvtCJKOptions aCJKOptions;
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_NUMBER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_NUMBERFORMAT ) );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_FONT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_NAME ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_NAME ) );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_FONTEFF, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_CHAR_EFFECTS ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_CHAR_EFFECTS ) );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT( pFact->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_ALIGNMENT, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_ALIGNMENT ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_ALIGNMENT ) );
+ if ( aCJKOptions.IsAsianTypographyEnabled() )
+ {
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_ASIAN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_PARA_ASIAN), pFact->GetTabPageRangesFunc(RID_SVXPAGE_PARA_ASIAN) );
+ }
+ else
+ RemoveTabPage( TP_ASIAN );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
+ AddTabPage( TP_PROTECTION, &ScTabPageProtection::Create, &ScTabPageProtection::GetRanges );
+ }
+ break;
+
+ case RID_SCDLG_STYLES_PAGE: // Seitenvorlagen
+ {
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_PAGE_STD, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_PAGE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_PAGE ) );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BORDER ) );
+ DBG_ASSERT(pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageCreatorFunc fail!");
+ DBG_ASSERT(pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ), "GetTabPageRangesFunc fail!");
+ AddTabPage( TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_BACKGROUND ) );
+ AddTabPage( TP_PAGE_HEADER, &ScHeaderPage::Create, &ScHeaderPage::GetRanges );
+ AddTabPage( TP_PAGE_FOOTER, &ScFooterPage::Create, &ScFooterPage::GetRanges );
+ AddTabPage( TP_TABLE, &ScTablePage::Create, &ScTablePage::GetRanges );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "Family not supported" );
+ }
+
+ //--------------------------------------------------------------------
+ FreeResource();
+}
+
+// -----------------------------------------------------------------------
+
+__EXPORT ScStyleDlg::~ScStyleDlg()
+{
+}
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScStyleDlg::PageCreated( USHORT nPageId, SfxTabPage& rTabPage )
+{
+ if ( nDlgRsc == RID_SCDLG_STYLES_PAR )
+ {
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch ( nPageId )
+ {
+ case TP_NUMBER:
+ {
+ const SfxPoolItem* pInfoItem
+ = pDocSh->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+
+ DBG_ASSERT( pInfoItem, "NumberInfoItem nicht gefunden!" );
+
+ aSet.Put (SvxNumberInfoItem( (const SvxNumberInfoItem&)*pInfoItem ) );
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ case TP_FONT:
+ {
+ const SfxPoolItem* pInfoItem
+ = pDocSh->GetItem( SID_ATTR_CHAR_FONTLIST );
+
+ DBG_ASSERT( pInfoItem, "FontListItem nicht gefunden!" );
+
+ aSet.Put (SvxFontListItem(((const SvxFontListItem&)*pInfoItem).GetFontList(), SID_ATTR_CHAR_FONTLIST));
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if ( nDlgRsc == RID_SCDLG_STYLES_PAGE )
+ {
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ switch ( nPageId )
+ {
+ case TP_PAGE_STD:
+ aSet.Put (SfxAllEnumItem((const USHORT)SID_ENUM_PAGE_MODE, SVX_PAGE_MODE_CENTER));
+ rTabPage.PageCreated(aSet);
+ break;
+
+ case TP_PAGE_HEADER:
+ case TP_PAGE_FOOTER:
+ ((ScHFPage&)rTabPage).SetStyleDlg( this );
+ ((ScHFPage&)rTabPage).SetPageStyle( GetStyleSheet().GetName() );
+ ((ScHFPage&)rTabPage).DisableDeleteQueryBox();
+ break;
+ case TP_BACKGROUND:
+ if( nDlgRsc == RID_SCDLG_STYLES_PAGE)
+ {
+ aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, SVX_SHOW_SELECTOR));
+ rTabPage.PageCreated(aSet);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------
+
+const SfxItemSet* __EXPORT ScStyleDlg::GetRefreshedSet()
+{
+ SfxItemSet* pItemSet = GetInputSetImpl();
+ pItemSet->ClearItem();
+ pItemSet->SetParent( GetStyleSheet().GetItemSet().GetParent() );
+ return pItemSet;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/styleui/styledlg.src b/sc/source/ui/styleui/styledlg.src
new file mode 100644
index 000000000000..be1f7d3457fd
--- /dev/null
+++ b/sc/source/ui/styleui/styledlg.src
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "sc.hrc"
+#include "styledlg.hrc" // -> TP_xxx
+TabDialog RID_SCDLG_STYLES_PAR
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 289 , 176 ) ;
+ Text [ en-US ] = "Cell Style" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 3 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_NUMBER ;
+ Text [ en-US ] = "Numbers" ;
+ };
+ PageItem
+ {
+ Identifier = TP_FONT ;
+ /* ### ACHTUNG: Neuer Text in Resource? Schrift : Zeichen */
+ Text [ en-US ] = "Font" ;
+ };
+ PageItem
+ {
+ Identifier = TP_FONTEFF ;
+ Text [ en-US ] = "Font Effects";
+ };
+ PageItem
+ {
+ Identifier = TP_ALIGNMENT ;
+ Text [ en-US ] = "Alignment" ;
+ };
+ PageItem
+ {
+ Identifier = TP_ASIAN ;
+ Text [ en-US ] = "Asian Typography";
+ };
+ PageItem
+ {
+ Identifier = TP_BORDER ;
+ Text [ en-US ] = "Borders" ;
+ };
+ PageItem
+ {
+ Identifier = TP_BACKGROUND ;
+ Text [ en-US ] = "Background" ;
+ };
+ PageItem
+ {
+ Identifier = TP_PROTECTION ;
+ Text [ en-US ] = "Cell Protection" ;
+ };
+ };
+ };
+};
+TabDialog RID_SCDLG_STYLES_PAGE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 280 , 165 ) ;
+ Text [ en-US ] = "Page Style" ;
+ Moveable = TRUE ;
+ Closeable = FALSE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 6 ) ;
+ Size = MAP_APPFONT ( 260 , 135 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_PAGE_STD ;
+ Text [ en-US ] = "Page" ;
+ };
+ PageItem
+ {
+ Identifier = TP_BORDER ;
+ Text [ en-US ] = "Borders" ;
+ };
+ PageItem
+ {
+ Identifier = TP_BACKGROUND ;
+ Text [ en-US ] = "Background" ;
+ };
+ PageItem
+ {
+ Identifier = TP_PAGE_HEADER ;
+ Text [ en-US ] = "Header" ;
+ };
+ PageItem
+ {
+ Identifier = TP_PAGE_FOOTER ;
+ Text [ en-US ] = "Footer" ;
+ };
+ PageItem
+ {
+ Identifier = TP_TABLE ;
+ Text [ en-US ] = "Sheet" ;
+ };
+ };
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/styleui/template.cur b/sc/source/ui/styleui/template.cur
new file mode 100644
index 000000000000..0fb6a1f5d0a9
--- /dev/null
+++ b/sc/source/ui/styleui/template.cur
Binary files differ
diff --git a/sc/source/ui/undo/areasave.cxx b/sc/source/ui/undo/areasave.cxx
new file mode 100644
index 000000000000..54d09946bab3
--- /dev/null
+++ b/sc/source/ui/undo/areasave.cxx
@@ -0,0 +1,232 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// -----------------------------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/linkmgr.hxx>
+#include <tools/debug.hxx>
+
+#include "areasave.hxx"
+#include "arealink.hxx"
+#include "document.hxx"
+
+// -----------------------------------------------------------------------
+
+ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLink& rSource ) :
+ aFileName ( rSource.GetFile() ),
+ aFilterName ( rSource.GetFilter() ),
+ aOptions ( rSource.GetOptions() ),
+ aSourceArea ( rSource.GetSource() ),
+ aDestArea ( rSource.GetDestArea() ),
+ nRefresh ( rSource.GetRefreshDelay() ) // seconds
+{
+}
+
+ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLinkSaver& rCopy ) :
+ ScDataObject(),
+ aFileName ( rCopy.aFileName ),
+ aFilterName ( rCopy.aFilterName ),
+ aOptions ( rCopy.aOptions ),
+ aSourceArea ( rCopy.aSourceArea ),
+ aDestArea ( rCopy.aDestArea ),
+ nRefresh ( rCopy.nRefresh )
+{
+}
+
+ScAreaLinkSaver::~ScAreaLinkSaver()
+{
+}
+
+ScDataObject* ScAreaLinkSaver::Clone() const
+{
+ return new ScAreaLinkSaver( *this );
+}
+
+BOOL ScAreaLinkSaver::IsEqualSource( const ScAreaLink& rCompare ) const
+{
+ return ( aFileName == rCompare.GetFile() &&
+ aFilterName == rCompare.GetFilter() &&
+ aOptions == rCompare.GetOptions() &&
+ aSourceArea == rCompare.GetSource() &&
+ nRefresh == rCompare.GetRefreshDelay() );
+}
+
+BOOL ScAreaLinkSaver::IsEqual( const ScAreaLink& rCompare ) const
+{
+ return ( IsEqualSource( rCompare ) &&
+ aDestArea == rCompare.GetDestArea() );
+}
+
+void ScAreaLinkSaver::WriteToLink( ScAreaLink& rLink ) const
+{
+ rLink.SetDestArea( aDestArea );
+}
+
+void ScAreaLinkSaver::InsertNewLink( ScDocument* pDoc ) const
+{
+ // (see ScUndoRemoveAreaLink::Undo)
+
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+
+ if ( pLinkManager && pObjSh )
+ {
+ ScAreaLink* pLink = new ScAreaLink( pObjSh, aFileName, aFilterName, aOptions,
+ aSourceArea, aDestArea.aStart, nRefresh );
+ pLink->SetInCreate( TRUE );
+ pLink->SetDestArea( aDestArea );
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, &aFilterName, &aSourceArea );
+ pLink->Update();
+ pLink->SetInCreate( FALSE );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+ScAreaLinkSaveCollection::ScAreaLinkSaveCollection()
+{
+}
+
+ScAreaLinkSaveCollection::ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& rCopy ) :
+ ScCollection( rCopy )
+{
+}
+
+ScAreaLinkSaveCollection::~ScAreaLinkSaveCollection()
+{
+}
+
+ScDataObject* ScAreaLinkSaveCollection::Clone() const
+{
+ return new ScAreaLinkSaveCollection( *this );
+}
+
+BOOL ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
+{
+ // IsEqual can be checked in sequence.
+ // Neither ref-update nor removing links will change the order.
+
+ sfx2::LinkManager* pLinkManager = const_cast<ScDocument*>(pDoc)->GetLinkManager();
+ if (pLinkManager)
+ {
+ USHORT nPos = 0;
+ const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
+ USHORT nLinkCount = rLinks.Count();
+ for (USHORT i=0; i<nLinkCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if (pBase->ISA(ScAreaLink))
+ {
+ if ( nPos >= GetCount() || !(*this)[nPos]->IsEqual( *(ScAreaLink*)pBase ) )
+ return FALSE;
+
+ ++nPos;
+ }
+ }
+ if ( nPos < GetCount() )
+ return FALSE; // fewer links in the document than in the save collection
+ }
+
+ return TRUE;
+}
+
+ScAreaLink* lcl_FindLink( const ::sfx2::SvBaseLinks& rLinks, const ScAreaLinkSaver& rSaver )
+{
+ USHORT nLinkCount = rLinks.Count();
+ for (USHORT i=0; i<nLinkCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if ( pBase->ISA(ScAreaLink) &&
+ rSaver.IsEqualSource( *static_cast<ScAreaLink*>(pBase) ) )
+ {
+ return static_cast<ScAreaLink*>(pBase); // found
+ }
+ }
+ return NULL; // not found
+}
+
+void ScAreaLinkSaveCollection::Restore( ScDocument* pDoc ) const
+{
+ // The save collection may contain additional entries that are not in the document.
+ // They must be inserted again.
+ // Entries from the save collection must be searched via source data, as the order
+ // of links changes if deleted entries are re-added to the link manager (always at the end).
+
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ if (pLinkManager)
+ {
+ const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
+ USHORT nSaveCount = GetCount();
+ for (USHORT nPos=0; nPos<nSaveCount; nPos++)
+ {
+ ScAreaLinkSaver* pSaver = (*this)[nPos];
+ ScAreaLink* pLink = lcl_FindLink( rLinks, *pSaver );
+ if ( pLink )
+ pSaver->WriteToLink( *pLink ); // restore output position
+ else
+ pSaver->InsertNewLink( pDoc ); // re-insert deleted link
+ }
+ }
+}
+
+// static
+ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocument* pDoc )
+{
+ ScAreaLinkSaveCollection* pColl = NULL;
+
+ sfx2::LinkManager* pLinkManager = const_cast<ScDocument*>(pDoc)->GetLinkManager();
+ if (pLinkManager)
+ {
+ const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
+ USHORT nLinkCount = rLinks.Count();
+ for (USHORT i=0; i<nLinkCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if (pBase->ISA(ScAreaLink))
+ {
+ if (!pColl)
+ pColl = new ScAreaLinkSaveCollection;
+
+ ScAreaLinkSaver* pSaver = new ScAreaLinkSaver( *(ScAreaLink*)pBase );
+ if (!pColl->Insert(pSaver))
+ delete pSaver;
+ }
+ }
+ }
+
+ return pColl;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/makefile.mk b/sc/source/ui/undo/makefile.mk
new file mode 100644
index 000000000000..2b8dd60df32d
--- /dev/null
+++ b/sc/source/ui/undo/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=undo
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES = \
+ target.cxx \
+ refundo.cxx \
+ areasave.cxx \
+ undobase.cxx \
+ undoutil.cxx \
+ undocell.cxx \
+ undostyl.cxx \
+ undoolk.cxx \
+ undoblk.cxx \
+ undoblk2.cxx \
+ undoblk3.cxx \
+ undodat.cxx \
+ undodraw.cxx \
+ undotab.cxx
+
+
+
+SLOFILES = \
+ $(SLO)$/target.obj \
+ $(SLO)$/refundo.obj \
+ $(SLO)$/areasave.obj \
+ $(SLO)$/undobase.obj \
+ $(SLO)$/undoutil.obj \
+ $(SLO)$/undocell.obj \
+ $(SLO)$/undostyl.obj \
+ $(SLO)$/undoolk.obj \
+ $(SLO)$/undoblk.obj \
+ $(SLO)$/undoblk2.obj \
+ $(SLO)$/undoblk3.obj \
+ $(SLO)$/undodat.obj \
+ $(SLO)$/undodraw.obj \
+ $(SLO)$/undotab.obj
+
+EXCEPTIONSFILES= \
+ $(SLO)$/undoblk3.obj \
+ $(SLO)$/undocell.obj \
+ $(SLO)$/undostyl.obj \
+ $(SLO)$/undotab.obj
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx
new file mode 100644
index 000000000000..3fd8fbf82f00
--- /dev/null
+++ b/sc/source/ui/undo/refundo.cxx
@@ -0,0 +1,216 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// -----------------------------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "refundo.hxx"
+#include "undobase.hxx"
+#include "document.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "pivot.hxx"
+#include "chartarr.hxx"
+#include "stlpool.hxx"
+#include "conditio.hxx"
+#include "detdata.hxx"
+#include "prnsave.hxx"
+#include "chartlis.hxx"
+#include "dpobject.hxx"
+#include "areasave.hxx"
+#include "unoreflist.hxx"
+
+// -----------------------------------------------------------------------
+
+ScRefUndoData::ScRefUndoData( const ScDocument* pDoc ) :
+ pUnoRefs( NULL )
+{
+ ScDBCollection* pOldDBColl = pDoc->GetDBCollection();
+ pDBCollection = pOldDBColl ? new ScDBCollection(*pOldDBColl) : NULL;
+
+ ScRangeName* pOldRanges = ((ScDocument*)pDoc)->GetRangeName(); //! const
+ pRangeName = pOldRanges ? new ScRangeName(*pOldRanges) : NULL;
+
+ pPrintRanges = pDoc->CreatePrintRangeSaver(); // neu erzeugt
+
+ //! bei Pivot nur Bereiche merken ???
+
+ ScDPCollection* pOldDP = ((ScDocument*)pDoc)->GetDPCollection(); //! const
+ pDPCollection = pOldDP ? new ScDPCollection(*pOldDP) : NULL;
+
+ ScConditionalFormatList* pOldCond = pDoc->GetCondFormList();
+ pCondFormList = pOldCond ? new ScConditionalFormatList(*pOldCond) : NULL;
+
+ ScDetOpList* pOldDetOp = pDoc->GetDetOpList();
+ pDetOpList = pOldDetOp ? new ScDetOpList(*pOldDetOp) : 0;
+
+ ScChartListenerCollection* pOldChartListenerCollection =
+ pDoc->GetChartListenerCollection();
+ pChartListenerCollection = pOldChartListenerCollection ?
+ new ScChartListenerCollection( *pOldChartListenerCollection ) : NULL;
+
+ pAreaLinks = ScAreaLinkSaveCollection::CreateFromDoc(pDoc); // returns NULL if empty
+
+ const_cast<ScDocument*>(pDoc)->BeginUnoRefUndo();
+}
+
+ScRefUndoData::~ScRefUndoData()
+{
+ delete pDBCollection;
+ delete pRangeName;
+ delete pPrintRanges;
+ delete pDPCollection;
+ delete pCondFormList;
+ delete pDetOpList;
+ delete pChartListenerCollection;
+ delete pAreaLinks;
+ delete pUnoRefs;
+}
+
+void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc )
+{
+ if (pDBCollection)
+ {
+ ScDBCollection* pNewDBColl = pDoc->GetDBCollection();
+ if ( pNewDBColl && *pDBCollection == *pNewDBColl )
+ DELETEZ(pDBCollection);
+ }
+ if (pRangeName)
+ {
+ ScRangeName* pNewRanges = ((ScDocument*)pDoc)->GetRangeName(); //! const
+ if ( pNewRanges && *pRangeName == *pNewRanges )
+ DELETEZ(pRangeName);
+ }
+
+ if (pPrintRanges)
+ {
+ ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
+ if ( pNewRanges && *pPrintRanges == *pNewRanges )
+ DELETEZ(pPrintRanges);
+ delete pNewRanges;
+ }
+
+ if (pDPCollection)
+ {
+ ScDPCollection* pNewDP = ((ScDocument*)pDoc)->GetDPCollection(); //! const
+ if ( pNewDP && pDPCollection->RefsEqual(*pNewDP) )
+ DELETEZ(pDPCollection);
+ }
+
+ if (pCondFormList)
+ {
+ ScConditionalFormatList* pNewCond = pDoc->GetCondFormList();
+ if ( pNewCond && *pCondFormList == *pNewCond )
+ DELETEZ(pCondFormList);
+ }
+
+ if (pDetOpList)
+ {
+ ScDetOpList* pNewDetOp = pDoc->GetDetOpList();
+ if ( pNewDetOp && *pDetOpList == *pNewDetOp )
+ DELETEZ(pDetOpList);
+ }
+
+ if ( pChartListenerCollection )
+ {
+ ScChartListenerCollection* pNewChartListenerCollection =
+ pDoc->GetChartListenerCollection();
+ if ( pNewChartListenerCollection &&
+ *pChartListenerCollection == *pNewChartListenerCollection )
+ DELETEZ( pChartListenerCollection );
+ }
+
+ if (pAreaLinks)
+ {
+ if ( pAreaLinks->IsEqual( pDoc ) )
+ DELETEZ(pAreaLinks);
+ }
+
+ if ( pDoc->HasUnoRefUndo() )
+ {
+ pUnoRefs = const_cast<ScDocument*>(pDoc)->EndUnoRefUndo();
+ if ( pUnoRefs && pUnoRefs->IsEmpty() )
+ {
+ DELETEZ( pUnoRefs );
+ }
+ }
+}
+
+void ScRefUndoData::DoUndo( ScDocument* pDoc, BOOL bUndoRefFirst )
+{
+ if (pDBCollection)
+ pDoc->SetDBCollection( new ScDBCollection(*pDBCollection) );
+ if (pRangeName)
+ pDoc->SetRangeName( new ScRangeName(*pRangeName) );
+
+ if (pPrintRanges)
+ pDoc->RestorePrintRanges(*pPrintRanges);
+
+ if (pDPCollection)
+ {
+ ScDPCollection* pDocDP = pDoc->GetDPCollection();
+ if (pDocDP)
+ pDPCollection->WriteRefsTo( *pDocDP );
+ }
+
+ if (pCondFormList)
+ pDoc->SetCondFormList( new ScConditionalFormatList(*pCondFormList) );
+ if (pDetOpList)
+ pDoc->SetDetOpList( new ScDetOpList(*pDetOpList) );
+
+ // #65055# bUndoRefFirst ist bSetChartRangeLists
+ if ( pChartListenerCollection )
+ pDoc->SetChartListenerCollection( new ScChartListenerCollection(
+ *pChartListenerCollection ), bUndoRefFirst );
+
+ if (pDBCollection || pRangeName)
+ {
+ BOOL bOldAutoCalc = pDoc->GetAutoCalc();
+ pDoc->SetAutoCalc( FALSE ); // Mehrfachberechnungen vermeiden
+ pDoc->CompileAll();
+ pDoc->SetDirty();
+ pDoc->SetAutoCalc( bOldAutoCalc );
+ }
+
+ if (pAreaLinks)
+ pAreaLinks->Restore( pDoc );
+
+ if ( pUnoRefs )
+ pUnoRefs->Undo( pDoc );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/target.cxx b/sc/source/ui/undo/target.cxx
new file mode 100644
index 000000000000..6c7c29f08d52
--- /dev/null
+++ b/sc/source/ui/undo/target.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "target.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScTabViewTarget, SfxRepeatTarget);
+
+__EXPORT ScTabViewTarget::~ScTabViewTarget()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undobase.cxx b/sc/source/ui/undo/undobase.cxx
new file mode 100644
index 000000000000..38e7addc42aa
--- /dev/null
+++ b/sc/source/ui/undo/undobase.cxx
@@ -0,0 +1,541 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/virdev.hxx>
+
+#include "undobase.hxx"
+#include "refundo.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "undoolk.hxx"
+#include "undodraw.hxx"
+#include "dbcolect.hxx"
+#include "attrib.hxx"
+#include "queryparam.hxx"
+#include "globstr.hrc"
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScSimpleUndo, SfxUndoAction);
+TYPEINIT1(ScBlockUndo, ScSimpleUndo);
+TYPEINIT1(ScMoveUndo, ScSimpleUndo);
+TYPEINIT1(ScDBFuncUndo, ScSimpleUndo);
+TYPEINIT1(ScUndoWrapper, SfxUndoAction);
+
+// -----------------------------------------------------------------------
+
+ScSimpleUndo::ScSimpleUndo( ScDocShell* pDocSh ) :
+ pDocShell( pDocSh ),
+ pDetectiveUndo( NULL )
+{
+}
+
+__EXPORT ScSimpleUndo::~ScSimpleUndo()
+{
+ delete pDetectiveUndo;
+}
+
+BOOL __EXPORT ScSimpleUndo::Merge( SfxUndoAction *pNextAction )
+{
+ // Zu jeder Undo-Action kann eine SdrUndoGroup fuer das Aktualisieren
+ // der Detektiv-Pfeile gehoeren.
+ // DetectiveRefresh kommt immer hinterher, die SdrUndoGroup ist in
+ // eine ScUndoDraw Action verpackt.
+ // Nur beim automatischen Aktualisieren wird AddUndoAction mit
+ // bTryMerg=TRUE gerufen.
+
+ if ( !pDetectiveUndo && pNextAction->ISA(ScUndoDraw) )
+ {
+ // SdrUndoAction aus der ScUndoDraw Action uebernehmen,
+ // ScUndoDraw wird dann vom UndoManager geloescht
+
+ ScUndoDraw* pCalcUndo = (ScUndoDraw*)pNextAction;
+ pDetectiveUndo = pCalcUndo->GetDrawUndo();
+ pCalcUndo->ForgetDrawUndo();
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void ScSimpleUndo::BeginUndo()
+{
+ pDocShell->SetInUndo( TRUE );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->HideAllCursors(); // z.B. wegen zusammengefassten Zellen
+
+ // detective updates happened last, must be undone first
+ if (pDetectiveUndo)
+ pDetectiveUndo->Undo();
+}
+
+void ScSimpleUndo::EndUndo()
+{
+ pDocShell->SetDocumentModified();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->UpdateAutoFillMark();
+ pViewShell->UpdateInputHandler();
+ pViewShell->ShowAllCursors();
+ }
+
+ pDocShell->SetInUndo( FALSE );
+}
+
+void ScSimpleUndo::BeginRedo()
+{
+ pDocShell->SetInUndo( TRUE ); //! eigenes Flag fuer Redo?
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->HideAllCursors(); // z.B. wegen zusammengefassten Zellen
+}
+
+void ScSimpleUndo::EndRedo()
+{
+ if (pDetectiveUndo)
+ pDetectiveUndo->Redo();
+
+ pDocShell->SetDocumentModified();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->UpdateAutoFillMark();
+ pViewShell->UpdateInputHandler();
+ pViewShell->ShowAllCursors();
+ }
+
+ pDocShell->SetInUndo( FALSE );
+}
+
+void ScSimpleUndo::ShowTable( SCTAB nTab ) // static
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetTabNo( nTab );
+}
+
+void ScSimpleUndo::ShowTable( const ScRange& rRange ) // static
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ SCTAB nStart = rRange.aStart.Tab();
+ SCTAB nEnd = rRange.aEnd.Tab();
+ SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nTab < nStart || nTab > nEnd ) // wenn nicht im Bereich:
+ pViewShell->SetTabNo( nStart ); // auf erste des Bereiches
+ }
+}
+
+
+// -----------------------------------------------------------------------
+
+ScBlockUndo::ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
+ ScBlockUndoMode eBlockMode ) :
+ ScSimpleUndo( pDocSh ),
+ aBlockRange( rRange ),
+ eMode( eBlockMode )
+{
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+}
+
+__EXPORT ScBlockUndo::~ScBlockUndo()
+{
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+void ScBlockUndo::BeginUndo()
+{
+ ScSimpleUndo::BeginUndo();
+ EnableDrawAdjust( pDocShell->GetDocument(), FALSE );
+}
+
+void ScBlockUndo::EndUndo()
+{
+ if (eMode == SC_UNDO_AUTOHEIGHT)
+ AdjustHeight();
+
+ EnableDrawAdjust( pDocShell->GetDocument(), TRUE );
+ DoSdrUndoAction( pDrawUndo, pDocShell->GetDocument() );
+
+ ShowBlock();
+ ScSimpleUndo::EndUndo();
+}
+
+/*
+void ScBlockUndo::BeginRedo()
+{
+ ScSimpleUndo::BeginRedo();
+}
+*/
+
+void ScBlockUndo::EndRedo()
+{
+ if (eMode == SC_UNDO_AUTOHEIGHT)
+ AdjustHeight();
+
+ ShowBlock();
+ ScSimpleUndo::EndRedo();
+}
+
+BOOL ScBlockUndo::AdjustHeight()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ VirtualDevice aVirtDev;
+ Fraction aZoomX( 1, 1 );
+ Fraction aZoomY = aZoomX;
+ double nPPTX, nPPTY;
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ ScViewData* pData = pViewShell->GetViewData();
+ nPPTX = pData->GetPPTX();
+ nPPTY = pData->GetPPTY();
+ aZoomX = pData->GetZoomX();
+ aZoomY = pData->GetZoomY();
+ }
+ else
+ {
+ // Zoom auf 100 lassen
+ nPPTX = ScGlobal::nScreenPPTX;
+ nPPTY = ScGlobal::nScreenPPTY;
+ }
+
+ BOOL bRet = pDoc->SetOptimalHeight( aBlockRange.aStart.Row(), aBlockRange.aEnd.Row(),
+/*!*/ aBlockRange.aStart.Tab(), 0, &aVirtDev,
+ nPPTX, nPPTY, aZoomX, aZoomY, FALSE );
+
+ if (bRet)
+ pDocShell->PostPaint( 0, aBlockRange.aStart.Row(), aBlockRange.aStart.Tab(),
+ MAXCOL, MAXROW, aBlockRange.aEnd.Tab(),
+ PAINT_GRID | PAINT_LEFT );
+
+ return bRet;
+}
+
+void ScBlockUndo::ShowBlock()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ ShowTable( aBlockRange ); // bei mehreren Tabs im Range ist jede davon gut
+ pViewShell->MoveCursorAbs( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(),
+ SC_FOLLOW_JUMP, FALSE, FALSE );
+ SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
+ ScRange aRange = aBlockRange;
+ aRange.aStart.SetTab( nTab );
+ aRange.aEnd.SetTab( nTab );
+ pViewShell->MarkRange( aRange );
+
+ // nicht per SetMarkArea an MarkData, wegen evtl. fehlendem Paint
+ }
+}
+
+
+// -----------------------------------------------------------------------
+
+ScMoveUndo::ScMoveUndo( ScDocShell* pDocSh, ScDocument* pRefDoc, ScRefUndoData* pRefData,
+ ScMoveUndoMode eRefMode ) :
+ ScSimpleUndo( pDocSh ),
+ pRefUndoDoc( pRefDoc ),
+ pRefUndoData( pRefData ),
+ eMode( eRefMode )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pRefUndoData)
+ pRefUndoData->DeleteUnchanged(pDoc);
+ pDrawUndo = GetSdrUndoAction( pDoc );
+}
+
+__EXPORT ScMoveUndo::~ScMoveUndo()
+{
+ delete pRefUndoData;
+ delete pRefUndoDoc;
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+void ScMoveUndo::UndoRef()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRange aRange(0,0,0, MAXCOL,MAXROW,pRefUndoDoc->GetTableCount()-1);
+ pRefUndoDoc->CopyToDocument( aRange, IDF_FORMULA, FALSE, pDoc, NULL, FALSE );
+ if (pRefUndoData)
+ pRefUndoData->DoUndo( pDoc, (eMode == SC_UNDO_REFFIRST) );
+ // #65055# HACK: ScDragDropUndo ist der einzige mit REFFIRST.
+ // Falls nicht, resultiert daraus evtl. ein zu haeufiges Anpassen
+ // der ChartRefs, nicht schoen, aber auch nicht schlecht..
+}
+
+void ScMoveUndo::BeginUndo()
+{
+ ScSimpleUndo::BeginUndo();
+
+ EnableDrawAdjust( pDocShell->GetDocument(), FALSE );
+
+ if (pRefUndoDoc && eMode == SC_UNDO_REFFIRST)
+ UndoRef();
+}
+
+void ScMoveUndo::EndUndo()
+{
+ //@17.12.97 Reihenfolge der Fkt.s geaendert
+ DoSdrUndoAction( pDrawUndo, pDocShell->GetDocument() ); // #125875# must also be called when pointer is null
+
+ if (pRefUndoDoc && eMode == SC_UNDO_REFLAST)
+ UndoRef();
+
+ EnableDrawAdjust( pDocShell->GetDocument(), TRUE );
+
+ ScSimpleUndo::EndUndo();
+}
+
+/*
+void ScMoveUndo::BeginRedo()
+{
+ ScSimpleUndo::BeginRedo();
+}
+*/
+
+/*
+void ScMoveUndo::EndRedo()
+{
+ ScSimpleUndo::EndRedo();
+}
+*/
+
+// -----------------------------------------------------------------------
+
+ScDBFuncUndo::ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal, SdrUndoAction* pDrawUndo ) :
+ ScSimpleUndo( pDocSh ),
+ aOriginalRange( rOriginal ),
+ mpDrawUndo( pDrawUndo )
+{
+ pAutoDBRange = pDocSh->GetOldAutoDBRange();
+}
+
+ScDBFuncUndo::~ScDBFuncUndo()
+{
+ DeleteSdrUndoAction( mpDrawUndo );
+ delete pAutoDBRange;
+}
+
+void ScDBFuncUndo::SetDrawUndoAction( SdrUndoAction* pDrawUndo )
+{
+ DeleteSdrUndoAction( mpDrawUndo );
+ mpDrawUndo = pDrawUndo;
+}
+
+void ScDBFuncUndo::BeginUndo()
+{
+ ScSimpleUndo::BeginUndo();
+ DoSdrUndoAction( mpDrawUndo, pDocShell->GetDocument() );
+}
+
+void ScDBFuncUndo::EndUndo()
+{
+ ScSimpleUndo::EndUndo();
+
+ if ( pAutoDBRange )
+ {
+ USHORT nNoNameIndex;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) )
+ {
+ ScDBData* pNoNameData = (*pColl)[nNoNameIndex];
+
+ SCCOL nRangeX1;
+ SCROW nRangeY1;
+ SCCOL nRangeX2;
+ SCROW nRangeY2;
+ SCTAB nRangeTab;
+ pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+ pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+
+ *pNoNameData = *pAutoDBRange;
+
+ if ( pAutoDBRange->HasAutoFilter() )
+ {
+ // restore AutoFilter buttons
+ pAutoDBRange->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+ pDoc->ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
+ pDocShell->PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID );
+ }
+ }
+ }
+}
+
+void ScDBFuncUndo::BeginRedo()
+{
+ RedoSdrUndoAction( mpDrawUndo );
+ if ( pAutoDBRange )
+ {
+ // move the database range to this function's position again (see ScDocShell::GetDBData)
+
+ USHORT nNoNameIndex;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ if ( pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nNoNameIndex ) )
+ {
+ ScDBData* pNoNameData = (*pColl)[nNoNameIndex];
+
+ SCCOL nRangeX1;
+ SCROW nRangeY1;
+ SCCOL nRangeX2;
+ SCROW nRangeY2;
+ SCTAB nRangeTab;
+ pNoNameData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+ pDocShell->DBAreaDeleted( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+
+ pNoNameData->SetSortParam( ScSortParam() );
+ pNoNameData->SetQueryParam( ScQueryParam() );
+ pNoNameData->SetSubTotalParam( ScSubTotalParam() );
+
+ pNoNameData->SetArea( aOriginalRange.aStart.Tab(),
+ aOriginalRange.aStart.Col(), aOriginalRange.aStart.Row(),
+ aOriginalRange.aEnd.Col(), aOriginalRange.aEnd.Row() );
+
+ pNoNameData->SetByRow( TRUE );
+ pNoNameData->SetAutoFilter( FALSE );
+ // header is always set with the operation in redo
+ }
+ }
+
+ ScSimpleUndo::BeginRedo();
+}
+
+void ScDBFuncUndo::EndRedo()
+{
+ ScSimpleUndo::EndRedo();
+}
+
+// -----------------------------------------------------------------------
+
+ScUndoWrapper::ScUndoWrapper( SfxUndoAction* pUndo ) :
+ pWrappedUndo( pUndo )
+{
+}
+
+ScUndoWrapper::~ScUndoWrapper()
+{
+ delete pWrappedUndo;
+}
+
+void ScUndoWrapper::ForgetWrappedUndo()
+{
+ pWrappedUndo = NULL; // don't delete in dtor - pointer must be stored outside
+}
+
+String ScUndoWrapper::GetComment() const
+{
+ if (pWrappedUndo)
+ return pWrappedUndo->GetComment();
+ else
+ return String();
+}
+
+String ScUndoWrapper::GetRepeatComment(SfxRepeatTarget& rTarget) const
+{
+ if (pWrappedUndo)
+ return pWrappedUndo->GetRepeatComment(rTarget);
+ else
+ return String();
+}
+
+USHORT ScUndoWrapper::GetId() const
+{
+ if (pWrappedUndo)
+ return pWrappedUndo->GetId();
+ else
+ return 0;
+}
+
+BOOL ScUndoWrapper::IsLinked()
+{
+ if (pWrappedUndo)
+ return pWrappedUndo->IsLinked();
+ else
+ return FALSE;
+}
+
+void ScUndoWrapper::SetLinked( BOOL bIsLinked )
+{
+ if (pWrappedUndo)
+ pWrappedUndo->SetLinked(bIsLinked);
+}
+
+BOOL ScUndoWrapper::Merge( SfxUndoAction* pNextAction )
+{
+ if (pWrappedUndo)
+ return pWrappedUndo->Merge(pNextAction);
+ else
+ return FALSE;
+}
+
+void ScUndoWrapper::Undo()
+{
+ if (pWrappedUndo)
+ pWrappedUndo->Undo();
+}
+
+void ScUndoWrapper::Redo()
+{
+ if (pWrappedUndo)
+ pWrappedUndo->Redo();
+}
+
+void ScUndoWrapper::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (pWrappedUndo)
+ pWrappedUndo->Repeat(rTarget);
+}
+
+BOOL ScUndoWrapper::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ if (pWrappedUndo)
+ return pWrappedUndo->CanRepeat(rTarget);
+ else
+ return FALSE;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
new file mode 100644
index 000000000000..c46a59d80722
--- /dev/null
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -0,0 +1,2277 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <vcl/virdev.hxx>
+#include <vcl/waitobj.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <sfx2/app.hxx>
+
+#include "undoblk.hxx"
+#include "undoutil.hxx"
+#include "document.hxx"
+#include "patattr.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "dbcolect.hxx"
+#include "stlpool.hxx"
+#include "stlsheet.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "target.hxx"
+#include "docpool.hxx"
+#include "docfunc.hxx"
+#include "attrib.hxx"
+#include "chgtrack.hxx"
+#include "transobj.hxx"
+#include "refundo.hxx"
+#include "undoolk.hxx"
+#include "clipparam.hxx"
+#include "sc.hrc"
+
+#include <set>
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScUndoInsertCells, SfxUndoAction);
+TYPEINIT1(ScUndoDeleteCells, SfxUndoAction);
+TYPEINIT1(ScUndoDeleteMulti, SfxUndoAction);
+TYPEINIT1(ScUndoCut, ScBlockUndo);
+TYPEINIT1(ScUndoPaste, SfxUndoAction);
+TYPEINIT1(ScUndoDragDrop, SfxUndoAction);
+TYPEINIT1(ScUndoListNames, SfxUndoAction);
+TYPEINIT1(ScUndoUseScenario, SfxUndoAction);
+TYPEINIT1(ScUndoSelectionStyle, SfxUndoAction);
+TYPEINIT1(ScUndoEnterMatrix, ScBlockUndo);
+TYPEINIT1(ScUndoIndent, ScBlockUndo);
+TYPEINIT1(ScUndoTransliterate, ScBlockUndo);
+TYPEINIT1(ScUndoClearItems, ScBlockUndo);
+TYPEINIT1(ScUndoRemoveBreaks, SfxUndoAction);
+TYPEINIT1(ScUndoRemoveMerge, ScBlockUndo);
+TYPEINIT1(ScUndoBorder, ScBlockUndo);
+
+
+
+// To Do:
+/*A*/ // SetOptimalHeight auf Dokument, wenn keine View
+/*B*/ // gelinkte Tabellen
+/*C*/ // ScArea
+//? // spaeter mal pruefen
+
+
+// -----------------------------------------------------------------------
+//
+// Zellen einfuegen
+// Zeilen einfuegen
+// einzeln oder Block
+//
+
+ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell,
+ const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
+ InsCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData,
+ BOOL bNewPartOfPaste ) :
+ ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ),
+ aEffRange( rRange ),
+ nCount( nNewCount ),
+ pTabs( pNewTabs ),
+ pScenarios( pNewScenarios ),
+ eCmd( eNewCmd ),
+ bPartOfPaste( bNewPartOfPaste ),
+ pPasteUndo( NULL )
+{
+ if (eCmd == INS_INSROWS) // ganze Zeilen?
+ {
+ aEffRange.aStart.SetCol(0);
+ aEffRange.aEnd.SetCol(MAXCOL);
+ }
+
+ if (eCmd == INS_INSCOLS) // ganze Spalten?
+ {
+ aEffRange.aStart.SetRow(0);
+ aEffRange.aEnd.SetRow(MAXROW);
+ }
+
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoInsertCells::~ScUndoInsertCells()
+{
+ delete pPasteUndo;
+ delete []pTabs;
+ delete []pScenarios;
+}
+
+String __EXPORT ScUndoInsertCells::GetComment() const
+{
+ return ScGlobal::GetRscString( pPasteUndo ? STR_UNDO_PASTE : STR_UNDO_INSERTCELLS );
+}
+
+BOOL ScUndoInsertCells::Merge( SfxUndoAction* pNextAction )
+{
+ // If a paste undo action has already been added, append (detective) action there.
+ if ( pPasteUndo )
+ return pPasteUndo->Merge( pNextAction );
+
+ if ( bPartOfPaste && pNextAction->ISA( ScUndoWrapper ) )
+ {
+ ScUndoWrapper* pWrapper = (ScUndoWrapper*)pNextAction;
+ SfxUndoAction* pWrappedAction = pWrapper->GetWrappedUndo();
+ if ( pWrappedAction && pWrappedAction->ISA( ScUndoPaste ) )
+ {
+ // Store paste action if this is part of paste with inserting cells.
+ // A list action isn't used because Repeat wouldn't work (insert wrong cells).
+
+ pPasteUndo = pWrappedAction;
+ pWrapper->ForgetWrappedUndo(); // pWrapper is deleted by UndoManager
+ return TRUE;
+ }
+ }
+
+ // Call base class for detective handling
+ return ScMoveUndo::Merge( pNextAction );
+}
+
+void ScUndoInsertCells::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ pChangeTrack->AppendInsert( aEffRange );
+ nEndChangeAction = pChangeTrack->GetActionMax();
+ }
+ else
+ nEndChangeAction = 0;
+}
+
+void ScUndoInsertCells::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB i;
+
+ if ( bUndo )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+ }
+ else
+ SetChangeTrack();
+
+ // refresh of merged cells has to be after inserting/deleting
+
+ switch (eCmd)
+ {
+ case INS_INSROWS:
+ case INS_CELLSDOWN:
+ for( i=0; i<nCount; i++ )
+ {
+ if (bUndo)
+ pDoc->DeleteRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1));
+ else
+ pDoc->InsertRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1));
+ }
+ break;
+ case INS_INSCOLS:
+ case INS_CELLSRIGHT:
+ for( i=0; i<nCount; i++ )
+ {
+ if (bUndo)
+ pDoc->DeleteCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1));
+ else
+ pDoc->InsertCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1));
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ ScRange aWorkRange( aEffRange );
+ if ( eCmd == INS_CELLSRIGHT ) // only "shift right" requires refresh of the moved area
+ aWorkRange.aEnd.SetCol(MAXCOL);
+ for( i=0; i<nCount; i++ )
+ {
+ if ( pDoc->HasAttrib( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i],
+ aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i], HASATTR_MERGED ) )
+ {
+ SCCOL nEndCol = aWorkRange.aEnd.Col();
+ SCROW nEndRow = aWorkRange.aEnd.Row();
+ pDoc->ExtendMerge( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), nEndCol, nEndRow, pTabs[i], TRUE );
+ }
+ }
+
+//? Undo fuer herausgeschobene Attribute ?
+
+ USHORT nPaint = PAINT_GRID;
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ switch (eCmd)
+ {
+ case INS_INSROWS:
+ nPaint |= PAINT_LEFT;
+ aWorkRange.aEnd.SetRow(MAXROW);
+ break;
+ case INS_CELLSDOWN:
+ for( i=0; i<nCount; i++ )
+ {
+ aWorkRange.aEnd.SetRow(MAXROW);
+ if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i] ))
+ {
+ aWorkRange.aStart.SetCol(0);
+ aWorkRange.aEnd.SetCol(MAXCOL);
+ nPaint |= PAINT_LEFT;
+ }
+ }
+ break;
+ case INS_INSCOLS:
+ nPaint |= PAINT_TOP; // obere Leiste
+ case INS_CELLSRIGHT:
+ for( i=0; i<nCount; i++ )
+ {
+ aWorkRange.aEnd.SetCol(MAXCOL); // bis ganz nach rechts
+ if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i]) )
+ { // AdjustDraw zeichnet PAINT_TOP nicht,
+ aWorkRange.aStart.SetCol(0); // daher so geloest
+ aWorkRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_LEFT;
+ }
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ for( i=0; i<nCount; i++ )
+ {
+ pDocShell->PostPaint( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i],
+ aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i]+pScenarios[i], nPaint );
+ }
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+
+void __EXPORT ScUndoInsertCells::Undo()
+{
+ if ( pPasteUndo )
+ pPasteUndo->Undo(); // undo paste first
+
+ WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+void __EXPORT ScUndoInsertCells::Redo()
+{
+ WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+
+ if ( pPasteUndo )
+ pPasteUndo->Redo(); // redo paste last
+}
+
+void __EXPORT ScUndoInsertCells::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ if ( pPasteUndo )
+ {
+ // #94115# Repeat for paste with inserting cells is handled completely
+ // by the Paste undo action
+
+ pPasteUndo->Repeat( rTarget );
+ }
+ else
+ ((ScTabViewTarget&)rTarget).GetViewShell()->InsertCells( eCmd, TRUE );
+ }
+}
+
+BOOL __EXPORT ScUndoInsertCells::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Zellen loeschen
+// Zeilen loeschen
+// einzeln oder Block
+//
+
+ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell,
+ const ScRange& rRange, SCTAB nNewCount, SCTAB* pNewTabs, SCTAB* pNewScenarios,
+ DelCellCmd eNewCmd, ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
+ ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ),
+ aEffRange( rRange ),
+ nCount( nNewCount ),
+ pTabs( pNewTabs ),
+ pScenarios( pNewScenarios ),
+ eCmd( eNewCmd )
+{
+ if (eCmd == DEL_DELROWS) // gaze Zeilen?
+ {
+ aEffRange.aStart.SetCol(0);
+ aEffRange.aEnd.SetCol(MAXCOL);
+ }
+
+ if (eCmd == DEL_DELCOLS) // ganze Spalten?
+ {
+ aEffRange.aStart.SetRow(0);
+ aEffRange.aEnd.SetRow(MAXROW);
+ }
+
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoDeleteCells::~ScUndoDeleteCells()
+{
+ delete []pTabs;
+ delete []pScenarios;
+}
+
+String __EXPORT ScUndoDeleteCells::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_DELETECELLS ); // "Loeschen"
+}
+
+void ScUndoDeleteCells::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->AppendDeleteRange( aEffRange, pRefUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void ScUndoDeleteCells::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB i;
+
+ if ( bUndo )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ }
+ else
+ SetChangeTrack();
+
+ // Ausfuehren
+ switch (eCmd)
+ {
+ case DEL_DELROWS:
+ case DEL_CELLSUP:
+ for( i=0; i<nCount; i++ )
+ {
+ if (bUndo)
+ pDoc->InsertRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1));
+ else
+ pDoc->DeleteRow( aEffRange.aStart.Col(), pTabs[i], aEffRange.aEnd.Col(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Row(), static_cast<SCSIZE>(aEffRange.aEnd.Row()-aEffRange.aStart.Row()+1));
+ }
+ break;
+ case DEL_DELCOLS:
+ case DEL_CELLSLEFT:
+ for( i=0; i<nCount; i++ )
+ {
+ if (bUndo)
+ pDoc->InsertCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1));
+ else
+ pDoc->DeleteCol( aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i],
+ aEffRange.aStart.Col(), static_cast<SCSIZE>(aEffRange.aEnd.Col()-aEffRange.aStart.Col()+1));
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ // bei Undo Referenzen wiederherstellen
+ for( i=0; i<nCount && bUndo; i++ )
+ {
+ pRefUndoDoc->CopyToDocument( aEffRange.aStart.Col(), aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i],
+ IDF_ALL | IDF_NOCAPTIONS, FALSE, pDoc );
+ }
+
+ ScRange aWorkRange( aEffRange );
+ if ( eCmd == DEL_CELLSLEFT ) // only "shift left" requires refresh of the moved area
+ aWorkRange.aEnd.SetCol(MAXCOL);
+
+ for( i=0; i<nCount; i++ )
+ {
+ if ( pDoc->HasAttrib( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i],
+ aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i], HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ // #i51445# old merge flag attributes must be deleted also for single cells,
+ // not only for whole columns/rows
+
+ if ( !bUndo )
+ {
+ if ( eCmd==DEL_DELCOLS || eCmd==DEL_CELLSLEFT )
+ aWorkRange.aEnd.SetCol(MAXCOL);
+ if ( eCmd==DEL_DELROWS || eCmd==DEL_CELLSUP )
+ aWorkRange.aEnd.SetRow(MAXROW);
+ ScMarkData aMarkData;
+ aMarkData.SelectOneTable( aWorkRange.aStart.Tab() );
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( ScMergeFlagAttr() );
+ pDoc->ApplyPatternArea( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(),
+ aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(),
+ aMarkData, aPattern );
+ }
+
+ SCCOL nEndCol = aWorkRange.aEnd.Col();
+ SCROW nEndRow = aWorkRange.aEnd.Row();
+ pDoc->ExtendMerge( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), nEndCol, nEndRow, pTabs[i], TRUE );
+ }
+ }
+
+ // Zeichnen
+ USHORT nPaint = PAINT_GRID;
+ switch (eCmd)
+ {
+ case DEL_DELROWS:
+ nPaint |= PAINT_LEFT;
+ aWorkRange.aEnd.SetRow(MAXROW);
+ break;
+ case DEL_CELLSUP:
+ for( i=0; i<nCount; i++ )
+ {
+ aWorkRange.aEnd.SetRow(MAXROW);
+ if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i] ))
+ {
+ aWorkRange.aStart.SetCol(0);
+ aWorkRange.aEnd.SetCol(MAXCOL);
+ nPaint |= PAINT_LEFT;
+ }
+ }
+ break;
+ case DEL_DELCOLS:
+ nPaint |= PAINT_TOP; // obere Leiste
+ case DEL_CELLSLEFT:
+ for( i=0; i<nCount; i++ )
+ {
+ aWorkRange.aEnd.SetCol(MAXCOL); // bis ganz nach rechts
+ if ( pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), pTabs[i] ) )
+ {
+ aWorkRange.aStart.SetCol(0);
+ aWorkRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_LEFT;
+ }
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ for( i=0; i<nCount; i++ )
+ {
+ pDocShell->PostPaint( aWorkRange.aStart.Col(), aWorkRange.aStart.Row(), pTabs[i],
+ aWorkRange.aEnd.Col(), aWorkRange.aEnd.Row(), pTabs[i]+pScenarios[i], nPaint, SC_PF_LINES );
+ }
+ // Markierung erst nach EndUndo
+
+ pDocShell->PostDataChanged();
+ // CellContentChanged kommt mit der Markierung
+}
+
+void __EXPORT ScUndoDeleteCells::Undo()
+{
+ WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+
+ // Markierung erst nach EndUndo
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ for( SCTAB i=0; i<nCount; i++ )
+ {
+ pViewShell->MarkRange( ScRange(aEffRange.aStart.Col(), aEffRange.aStart.Row(), pTabs[i], aEffRange.aEnd.Col(), aEffRange.aEnd.Row(), pTabs[i]+pScenarios[i]) );
+ }
+ }
+}
+
+void __EXPORT ScUndoDeleteCells::Redo()
+{
+ WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+ BeginRedo();
+ DoChange( FALSE);
+ EndRedo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->DoneBlockMode(); // aktuelle weg
+}
+
+void __EXPORT ScUndoDeleteCells::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteCells( eCmd, TRUE );
+}
+
+BOOL __EXPORT ScUndoDeleteCells::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Zellen loeschen auf Mehrfachselektion
+//
+
+ScUndoDeleteMulti::ScUndoDeleteMulti( ScDocShell* pNewDocShell,
+ BOOL bNewRows, BOOL bNeedsRefresh, SCTAB nNewTab,
+ const SCCOLROW* pRng, SCCOLROW nRngCnt,
+ ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
+ ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST ),
+ bRows( bNewRows ),
+ bRefresh( bNeedsRefresh ),
+ nTab( nNewTab ),
+ nRangeCnt( nRngCnt )
+{
+ pRanges = new SCCOLROW[ 2 * nRangeCnt ];
+ memcpy(pRanges,pRng,nRangeCnt*2*sizeof(SCCOLROW));
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoDeleteMulti::~ScUndoDeleteMulti()
+{
+ delete [] pRanges;
+}
+
+String __EXPORT ScUndoDeleteMulti::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_DELETECELLS ); // wie DeleteCells
+}
+
+void ScUndoDeleteMulti::DoChange() const
+{
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ USHORT nPaint;
+ if (bRows)
+ {
+ nStartCol = 0;
+ nStartRow = static_cast<SCROW>(pRanges[0]);
+ nPaint = PAINT_GRID | PAINT_LEFT;
+ }
+ else
+ {
+ nStartCol = static_cast<SCCOL>(pRanges[0]);
+ nStartRow = 0;
+ nPaint = PAINT_GRID | PAINT_TOP;
+ }
+
+ if ( bRefresh )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCCOL nEndCol = MAXCOL;
+ SCROW nEndRow = MAXROW;
+ pDoc->RemoveFlagsTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, SC_MF_HOR | SC_MF_VER );
+ pDoc->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab, TRUE );
+ }
+
+ pDocShell->PostPaint( nStartCol, nStartRow, nTab, MAXCOL, MAXROW, nTab, nPaint );
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+ ShowTable( nTab );
+}
+
+void ScUndoDeleteMulti::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ nStartChangeAction = pChangeTrack->GetActionMax() + 1;
+ ScRange aRange( 0, 0, nTab, 0, 0, nTab );
+ if ( bRows )
+ aRange.aEnd.SetCol( MAXCOL );
+ else
+ aRange.aEnd.SetRow( MAXROW );
+ // rueckwaerts loeschen
+ SCCOLROW* pOneRange = &pRanges[2*nRangeCnt];
+ for ( SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++ )
+ {
+ SCCOLROW nEnd = *(--pOneRange);
+ SCCOLROW nStart = *(--pOneRange);
+ if ( bRows )
+ {
+ aRange.aStart.SetRow( nStart );
+ aRange.aEnd.SetRow( nEnd );
+ }
+ else
+ {
+ aRange.aStart.SetCol( static_cast<SCCOL>(nStart) );
+ aRange.aEnd.SetCol( static_cast<SCCOL>(nEnd) );
+ }
+ ULONG nDummyStart;
+ pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc,
+ nDummyStart, nEndChangeAction );
+ }
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void __EXPORT ScUndoDeleteMulti::Undo()
+{
+ WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCCOLROW* pOneRange;
+ SCCOLROW nRangeNo;
+
+ // rueckwaerts geloescht -> vorwaerts einfuegen
+ pOneRange = pRanges;
+ for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nStart = *(pOneRange++);
+ SCCOLROW nEnd = *(pOneRange++);
+ if (bRows)
+ pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nStart,static_cast<SCSIZE>(nEnd-nStart+1) );
+ else
+ pDoc->InsertCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) );
+ }
+
+ pOneRange = pRanges;
+ for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nStart = *(pOneRange++);
+ SCCOLROW nEnd = *(pOneRange++);
+ if (bRows)
+ pRefUndoDoc->CopyToDocument( 0,nStart,nTab, MAXCOL,nEnd,nTab, IDF_ALL,FALSE,pDoc );
+ else
+ pRefUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart),0,nTab,
+ static_cast<SCCOL>(nEnd),MAXROW,nTab, IDF_ALL,FALSE,pDoc );
+ }
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ DoChange();
+
+ //! Markierung wieder einzeichnen
+ //! geht im Moment nicht, da keine Daten fuer Markierung vorhanden!
+
+ EndUndo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void __EXPORT ScUndoDeleteMulti::Redo()
+{
+ WaitObject aWait( pDocShell->GetActiveDialogParent() ); // wichtig wegen TrackFormulas bei UpdateReference
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ // rueckwaerts loeschen
+ SCCOLROW* pOneRange = &pRanges[2*nRangeCnt];
+ for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nEnd = *(--pOneRange);
+ SCCOLROW nStart = *(--pOneRange);
+ if (bRows)
+ pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, nStart,static_cast<SCSIZE>(nEnd-nStart+1) );
+ else
+ pDoc->DeleteCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) );
+ }
+
+ SetChangeTrack();
+
+ DoChange();
+
+//! Markierung loeschen, derzeit unnoetig (s.o.)
+//! ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+//! if (pViewShell)
+//! DoneBlockMode();
+
+ EndRedo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void __EXPORT ScUndoDeleteMulti::Repeat(SfxRepeatTarget& rTarget)
+{
+ // DeleteCells, falls einfache Selektion
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteCells( DEL_DELROWS, TRUE );
+}
+
+BOOL __EXPORT ScUndoDeleteMulti::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Ausschneiden (Cut)
+//
+
+ScUndoCut::ScUndoCut( ScDocShell* pNewDocShell,
+ ScRange aRange, ScAddress aOldEnd, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc ) :
+ ScBlockUndo( pNewDocShell, ScRange(aRange.aStart, aOldEnd), SC_UNDO_AUTOHEIGHT ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ aExtendedRange( aRange )
+{
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoCut::~ScUndoCut()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoCut::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_CUT ); // "Ausschneiden"
+}
+
+void ScUndoCut::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction, SC_CACM_CUT );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void ScUndoCut::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ USHORT nExtFlags = 0;
+
+ // do not undo/redo objects and note captions, they are handled via drawing undo
+ USHORT nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
+
+ if (bUndo) // nur bei Undo
+ {
+ // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScRange aCopyRange = aExtendedRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pUndoDoc->CopyToDocument( aCopyRange, nUndoFlags, FALSE, pDoc );
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ }
+ else // nur bei Redo
+ {
+ pDocShell->UpdatePaintExt( nExtFlags, aExtendedRange );
+ pDoc->DeleteArea( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(),
+ aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(), aMarkData, nUndoFlags );
+ SetChangeTrack();
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) )
+/*A*/ pDocShell->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags );
+
+ if ( !bUndo ) // draw redo after updating row heights
+ RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo?
+
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+
+void __EXPORT ScUndoCut::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+void __EXPORT ScUndoCut::Redo()
+{
+ BeginRedo();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ EnableDrawAdjust( pDoc, FALSE ); //! include in ScBlockUndo?
+ DoChange( FALSE );
+ EnableDrawAdjust( pDoc, TRUE ); //! include in ScBlockUndo?
+ EndRedo();
+}
+
+void __EXPORT ScUndoCut::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->CutToClip( NULL, TRUE );
+}
+
+BOOL __EXPORT ScUndoCut::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Einfuegen (Paste)
+//
+
+ScUndoPaste::ScUndoPaste( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ USHORT nNewFlags,
+ ScRefUndoData* pRefData,
+ void* /* pFill1 */, void* /* pFill2 */, void* /* pFill3 */,
+ BOOL bRedoIsFilled, const ScUndoPasteOptions* pOptions ) :
+ ScBlockUndo( pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ pRedoDoc( pNewRedoDoc ),
+ nFlags( nNewFlags ),
+ pRefUndoData( pRefData ),
+ pRefRedoData( NULL ),
+ bRedoFilled( bRedoIsFilled )
+{
+ // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting)
+ // don't have to be changed and branched for 641.
+ // They can be removed later.
+
+ if ( !aMarkData.IsMarked() ) // no cell marked:
+ aMarkData.SetMarkArea( aBlockRange ); // mark paste block
+
+ if ( pRefUndoData )
+ pRefUndoData->DeleteUnchanged( pDocShell->GetDocument() );
+
+ if ( pOptions )
+ aPasteOptions = *pOptions; // used only for Repeat
+
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoPaste::~ScUndoPaste()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+ delete pRefUndoData;
+ delete pRefRedoData;
+}
+
+String __EXPORT ScUndoPaste::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_PASTE ); // "Einfuegen"
+}
+
+void ScUndoPaste::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack && (nFlags & IDF_CONTENTS) )
+ pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction, SC_CACM_PASTE );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void ScUndoPaste::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ // RefUndoData for redo is created before first undo
+ // (with DeleteUnchanged after the DoUndo call)
+ BOOL bCreateRedoData = ( bUndo && pRefUndoData && !pRefRedoData );
+ if ( bCreateRedoData )
+ pRefRedoData = new ScRefUndoData( pDoc );
+
+ ScRefUndoData* pWorkRefData = bUndo ? pRefUndoData : pRefRedoData;
+
+ // fuer Undo immer alle oder keine Inhalte sichern
+ USHORT nUndoFlags = IDF_NONE;
+ if (nFlags & IDF_CONTENTS)
+ nUndoFlags |= IDF_CONTENTS;
+ if (nFlags & IDF_ATTRIB)
+ nUndoFlags |= IDF_ATTRIB;
+
+ // do not undo/redo objects and note captions, they are handled via drawing undo
+ (nUndoFlags &= ~IDF_OBJECTS) |= IDF_NOCAPTIONS;
+
+ BOOL bPaintAll = FALSE;
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // marking is in ScBlockUndo...
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockRange );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if ( bUndo && !bRedoFilled )
+ {
+ if (!pRedoDoc)
+ {
+ BOOL bColInfo = ( aBlockRange.aStart.Row()==0 && aBlockRange.aEnd.Row()==MAXROW );
+ BOOL bRowInfo = ( aBlockRange.aStart.Col()==0 && aBlockRange.aEnd.Col()==MAXCOL );
+
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndoSelected( pDoc, aMarkData, bColInfo, bRowInfo );
+ }
+ // read "redo" data from the document in the first undo
+ // all sheets - CopyToDocument skips those that don't exist in pRedoDoc
+ ScRange aCopyRange = aBlockRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, nUndoFlags, FALSE, pRedoDoc );
+ bRedoFilled = TRUE;
+ }
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aBlockRange );
+
+ aMarkData.MarkToMulti();
+ pDoc->DeleteSelection( nUndoFlags, aMarkData );
+ aMarkData.MarkToSimple();
+
+ SCTAB nFirstSelected = aMarkData.GetFirstSelected();
+ ScRange aTabSelectRange = aBlockRange;
+ SCTAB nTab;
+
+ if ( !bUndo && pRedoDoc ) // Redo: UndoToDocument before handling RefData
+ {
+ aTabSelectRange.aStart.SetTab( nFirstSelected );
+ aTabSelectRange.aEnd.SetTab( nFirstSelected );
+ pRedoDoc->UndoToDocument( aTabSelectRange, nUndoFlags, FALSE, pDoc );
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (nTab != nFirstSelected && aMarkData.GetTableSelect(nTab))
+ {
+ aTabSelectRange.aStart.SetTab( nTab );
+ aTabSelectRange.aEnd.SetTab( nTab );
+ pRedoDoc->CopyToDocument( aTabSelectRange, nUndoFlags, FALSE, pDoc );
+ }
+ }
+
+ if (pWorkRefData)
+ {
+ pWorkRefData->DoUndo( pDoc, TRUE ); // TRUE = bSetChartRangeLists for SetChartListenerCollection
+ if ( pDoc->RefreshAutoFilter( 0,0, MAXCOL,MAXROW, aBlockRange.aStart.Tab() ) )
+ bPaintAll = TRUE;
+ }
+
+ if ( bCreateRedoData && pRefRedoData )
+ pRefRedoData->DeleteUnchanged( pDoc );
+
+ if (bUndo) // Undo: UndoToDocument after handling RefData
+ {
+ aTabSelectRange.aStart.SetTab( nFirstSelected );
+ aTabSelectRange.aEnd.SetTab( nFirstSelected );
+ pUndoDoc->UndoToDocument( aTabSelectRange, nUndoFlags, FALSE, pDoc );
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (nTab != nFirstSelected && aMarkData.GetTableSelect(nTab))
+ {
+ aTabSelectRange.aStart.SetTab( nTab );
+ aTabSelectRange.aEnd.SetTab( nTab );
+ pUndoDoc->UndoToDocument( aTabSelectRange, nUndoFlags, FALSE, pDoc );
+ }
+ }
+
+ if ( bUndo )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ }
+ else
+ SetChangeTrack();
+
+ ScRange aDrawRange( aBlockRange );
+ pDoc->ExtendMerge( aDrawRange, TRUE ); // only needed for single sheet (text/rtf etc.)
+ USHORT nPaint = PAINT_GRID;
+ if (bPaintAll)
+ {
+ aDrawRange.aStart.SetCol(0);
+ aDrawRange.aStart.SetRow(0);
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ aDrawRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_TOP | PAINT_LEFT;
+/*A*/ if (pViewShell)
+ pViewShell->AdjustBlockHeight(FALSE);
+ }
+ else
+ {
+ if ( aBlockRange.aStart.Row() == 0 && aBlockRange.aEnd.Row() == MAXROW ) // ganze Spalte
+ {
+ nPaint |= PAINT_TOP;
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ }
+ if ( aBlockRange.aStart.Col() == 0 && aBlockRange.aEnd.Col() == MAXCOL ) // ganze Zeile
+ {
+ nPaint |= PAINT_LEFT;
+ aDrawRange.aEnd.SetRow(MAXROW);
+ }
+/*A*/ if ((pViewShell) && pViewShell->AdjustBlockHeight(FALSE))
+ {
+ aDrawRange.aStart.SetCol(0);
+ aDrawRange.aStart.SetRow(0);
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ aDrawRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_LEFT;
+ }
+ pDocShell->UpdatePaintExt( nExtFlags, aDrawRange );
+ }
+
+ if ( !bUndo ) // draw redo after updating row heights
+ RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo?
+
+ pDocShell->PostPaint( aDrawRange, nPaint, nExtFlags );
+
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+
+void __EXPORT ScUndoPaste::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ ShowTable( aBlockRange );
+ EndUndo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void __EXPORT ScUndoPaste::Redo()
+{
+ BeginRedo();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ EnableDrawAdjust( pDoc, FALSE ); //! include in ScBlockUndo?
+ DoChange( FALSE );
+ EnableDrawAdjust( pDoc, TRUE ); //! include in ScBlockUndo?
+ EndRedo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void __EXPORT ScUndoPaste::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell* pViewSh = ((ScTabViewTarget&)rTarget).GetViewShell();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pViewSh->GetActiveWin() );
+ if (pOwnClip)
+ {
+ // #129384# keep a reference in case the clipboard is changed during PasteFromClip
+ com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable> aOwnClipRef( pOwnClip );
+ pViewSh->PasteFromClip( nFlags, pOwnClip->GetDocument(),
+ aPasteOptions.nFunction, aPasteOptions.bSkipEmpty, aPasteOptions.bTranspose,
+ aPasteOptions.bAsLink, aPasteOptions.eMoveMode, IDF_NONE,
+ TRUE ); // allow warning dialog
+ }
+ }
+}
+
+BOOL __EXPORT ScUndoPaste::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Verschieben/Kopieren (Drag & Drop)
+//
+
+ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell,
+ const ScRange& rRange, ScAddress aNewDestPos, BOOL bNewCut,
+ ScDocument* pUndoDocument, ScRefUndoData* pRefData, BOOL bScenario ) :
+ ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFFIRST ),
+ aSrcRange( rRange ),
+ bCut( bNewCut ),
+ bKeepScenarioFlags( bScenario )
+{
+ ScAddress aDestEnd(aNewDestPos);
+ aDestEnd.IncRow(aSrcRange.aEnd.Row() - aSrcRange.aStart.Row());
+ aDestEnd.IncCol(aSrcRange.aEnd.Col() - aSrcRange.aStart.Col());
+ aDestEnd.IncTab(aSrcRange.aEnd.Tab() - aSrcRange.aStart.Tab());
+
+ BOOL bIncludeFiltered = bCut;
+ if ( !bIncludeFiltered )
+ {
+ // find number of non-filtered rows
+ SCROW nPastedCount = pDocShell->GetDocument()->CountNonFilteredRows(
+ aSrcRange.aStart.Row(), aSrcRange.aEnd.Row(), aSrcRange.aStart.Tab());
+
+ if ( nPastedCount == 0 )
+ nPastedCount = 1;
+ aDestEnd.SetRow( aNewDestPos.Row() + nPastedCount - 1 );
+ }
+
+ aDestRange.aStart = aNewDestPos;
+ aDestRange.aEnd = aDestEnd;
+
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoDragDrop::~ScUndoDragDrop()
+{
+}
+
+String __EXPORT ScUndoDragDrop::GetComment() const
+{ // "Verschieben" : "Kopieren"
+ return bCut ?
+ ScGlobal::GetRscString( STR_UNDO_MOVE ) :
+ ScGlobal::GetRscString( STR_UNDO_COPY );
+}
+
+void ScUndoDragDrop::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ if ( bCut )
+ {
+ nStartChangeAction = pChangeTrack->GetActionMax() + 1;
+ pChangeTrack->AppendMove( aSrcRange, aDestRange, pRefUndoDoc );
+ nEndChangeAction = pChangeTrack->GetActionMax();
+ }
+ else
+ pChangeTrack->AppendContentRange( aDestRange, pRefUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void ScUndoDragDrop::PaintArea( ScRange aRange, USHORT nExtFlags ) const
+{
+ USHORT nPaint = PAINT_GRID;
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ if (pViewShell)
+ {
+ VirtualDevice aVirtDev;
+ ScViewData* pViewData = pViewShell->GetViewData();
+
+ if ( pDoc->SetOptimalHeight( aRange.aStart.Row(), aRange.aEnd.Row(),
+ aRange.aStart.Tab(), 0, &aVirtDev,
+ pViewData->GetPPTX(), pViewData->GetPPTY(),
+ pViewData->GetZoomX(), pViewData->GetZoomY(),
+ FALSE ) )
+ {
+ aRange.aStart.SetCol(0);
+ aRange.aEnd.SetCol(MAXCOL);
+ aRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_LEFT;
+ }
+ }
+
+ if ( bKeepScenarioFlags )
+ {
+ // Szenarien mitkopiert -> auch Szenario-Rahmen painten
+ aRange.aStart.SetCol(0);
+ aRange.aStart.SetRow(0);
+ aRange.aEnd.SetCol(MAXCOL);
+ aRange.aEnd.SetRow(MAXROW);
+ }
+
+ // column/row info (width/height) included if whole columns/rows were copied
+ if ( aSrcRange.aStart.Col() == 0 && aSrcRange.aEnd.Col() == MAXCOL )
+ {
+ nPaint |= PAINT_LEFT;
+ aRange.aEnd.SetRow(MAXROW);
+ }
+ if ( aSrcRange.aStart.Row() == 0 && aSrcRange.aEnd.Row() == MAXROW )
+ {
+ nPaint |= PAINT_TOP;
+ aRange.aEnd.SetCol(MAXCOL);
+ }
+
+ pDocShell->PostPaint( aRange, nPaint, nExtFlags );
+}
+
+
+void ScUndoDragDrop::DoUndo( ScRange aRange ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+//? DB-Areas vor Daten, damit bei ExtendMerge die Autofilter-Knoepfe stimmen
+
+ ScRange aPaintRange = aRange;
+ pDoc->ExtendMerge( aPaintRange ); // before deleting
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aPaintRange );
+
+ // do not undo objects and note captions, they are handled via drawing undo
+ USHORT nUndoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
+
+ pDoc->DeleteAreaTab( aRange, nUndoFlags );
+ pRefUndoDoc->CopyToDocument( aRange, nUndoFlags, FALSE, pDoc );
+ if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) )
+ pDoc->ExtendMerge( aRange, TRUE );
+
+ aPaintRange.aEnd.SetCol( Max( aPaintRange.aEnd.Col(), aRange.aEnd.Col() ) );
+ aPaintRange.aEnd.SetRow( Max( aPaintRange.aEnd.Row(), aRange.aEnd.Row() ) );
+
+ pDocShell->UpdatePaintExt( nExtFlags, aPaintRange );
+ PaintArea( aPaintRange, nExtFlags );
+}
+
+void __EXPORT ScUndoDragDrop::Undo()
+{
+ BeginUndo();
+ DoUndo(aDestRange);
+ if (bCut)
+ DoUndo(aSrcRange);
+ EndUndo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void __EXPORT ScUndoDragDrop::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+
+ EnableDrawAdjust( pDoc, FALSE ); //! include in ScBlockUndo?
+
+ // do not undo/redo objects and note captions, they are handled via drawing undo
+ USHORT nRedoFlags = (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
+
+ /* TODO: Redoing note captions is quite tricky due to the fact that a
+ helper clip document is used. While (re-)pasting the contents to the
+ destination area, the original pointers to the captions created while
+ dropping have to be restored. A simple CopyFromClip() would create new
+ caption objects that are not tracked by drawing undo, and the captions
+ restored by drawing redo would live without cell note objects pointing
+ to them. So, first, CopyToClip() and CopyFromClip() are called without
+ cloning the caption objects. This leads to cell notes pointing to the
+ wrong captions from source area that will be removed by drawing redo
+ later. Second, the pointers to the new captions have to be restored.
+ Sadly, currently these pointers are not stored anywhere but in the list
+ of drawing undo actions. */
+
+ SCTAB nTab;
+ ScMarkData aSourceMark;
+ for (nTab=aSrcRange.aStart.Tab(); nTab<=aSrcRange.aEnd.Tab(); nTab++)
+ aSourceMark.SelectTable( nTab, TRUE );
+
+ // do not clone objects and note captions into clipdoc (see above)
+ ScClipParam aClipParam(aSrcRange, bCut);
+ pDoc->CopyToClip(aClipParam, pClipDoc, &aSourceMark, false, bKeepScenarioFlags, false, false);
+
+ if (bCut)
+ {
+ ScRange aSrcPaintRange = aSrcRange;
+ pDoc->ExtendMerge( aSrcPaintRange ); // before deleting
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aSrcPaintRange );
+ pDoc->DeleteAreaTab( aSrcRange, nRedoFlags );
+ PaintArea( aSrcPaintRange, nExtFlags );
+ }
+
+ ScMarkData aDestMark;
+ for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++)
+ aDestMark.SelectTable( nTab, TRUE );
+
+ BOOL bIncludeFiltered = bCut;
+ // TODO: restore old note captions instead of cloning new captions...
+ pDoc->CopyFromClip( aDestRange, aDestMark, IDF_ALL & ~IDF_OBJECTS, NULL, pClipDoc, TRUE, FALSE, bIncludeFiltered );
+
+ if (bCut)
+ for (nTab=aSrcRange.aStart.Tab(); nTab<=aSrcRange.aEnd.Tab(); nTab++)
+ pDoc->RefreshAutoFilter( aSrcRange.aStart.Col(), aSrcRange.aStart.Row(),
+ aSrcRange.aEnd.Col(), aSrcRange.aEnd.Row(), nTab );
+
+ // skipped rows and merged cells don't mix
+ if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
+ pDocShell->GetDocFunc().UnmergeCells( aDestRange, FALSE, TRUE );
+
+ for (nTab=aDestRange.aStart.Tab(); nTab<=aDestRange.aEnd.Tab(); nTab++)
+ {
+ SCCOL nEndCol = aDestRange.aEnd.Col();
+ SCROW nEndRow = aDestRange.aEnd.Row();
+ pDoc->ExtendMerge( aDestRange.aStart.Col(), aDestRange.aStart.Row(),
+ nEndCol, nEndRow, nTab, TRUE );
+ PaintArea( ScRange( aDestRange.aStart.Col(), aDestRange.aStart.Row(), nTab,
+ nEndCol, nEndRow, nTab ), 0 );
+ }
+
+ SetChangeTrack();
+
+ delete pClipDoc;
+ ShowTable( aDestRange.aStart.Tab() );
+
+ RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo?
+ EnableDrawAdjust( pDoc, TRUE ); //! include in ScBlockUndo?
+
+ EndRedo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void __EXPORT ScUndoDragDrop::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoDragDrop::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // geht nicht
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Liste der Bereichsnamen einfuegen
+// (Einfuegen|Name|Einfuegen =>[Liste])
+//
+
+ScUndoListNames::ScUndoListNames( ScDocShell* pNewDocShell, const ScRange& rRange,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc ) :
+ ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ),
+ pUndoDoc( pNewUndoDoc ),
+ pRedoDoc( pNewRedoDoc )
+{
+}
+
+__EXPORT ScUndoListNames::~ScUndoListNames()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+}
+
+String __EXPORT ScUndoListNames::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_LISTNAMES );
+}
+
+void ScUndoListNames::DoChange( ScDocument* pSrcDoc ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ pDoc->DeleteAreaTab( aBlockRange, IDF_ALL );
+ pSrcDoc->CopyToDocument( aBlockRange, IDF_ALL, FALSE, pDoc );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID );
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+
+void __EXPORT ScUndoListNames::Undo()
+{
+ BeginUndo();
+ DoChange(pUndoDoc);
+ EndUndo();
+}
+
+void __EXPORT ScUndoListNames::Redo()
+{
+ BeginRedo();
+ DoChange(pRedoDoc);
+ EndRedo();
+}
+
+void __EXPORT ScUndoListNames::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->InsertNameList();
+}
+
+BOOL __EXPORT ScUndoListNames::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Szenario anwenden
+// (Extras|Szenarien)
+//
+
+ScUndoUseScenario::ScUndoUseScenario( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+/*C*/ const ScArea& rDestArea,
+ ScDocument* pNewUndoDoc,
+ const String& rNewName ) :
+ ScSimpleUndo( pNewDocShell ),
+ pUndoDoc( pNewUndoDoc ),
+ aMarkData( rMark ),
+ aName( rNewName )
+{
+ aRange.aStart.SetCol(rDestArea.nColStart);
+ aRange.aStart.SetRow(rDestArea.nRowStart);
+ aRange.aStart.SetTab(rDestArea.nTab);
+ aRange.aEnd.SetCol(rDestArea.nColEnd);
+ aRange.aEnd.SetRow(rDestArea.nRowEnd);
+ aRange.aEnd.SetTab(rDestArea.nTab);
+}
+
+__EXPORT ScUndoUseScenario::~ScUndoUseScenario()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoUseScenario::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_USESCENARIO );
+}
+
+void __EXPORT ScUndoUseScenario::Undo()
+{
+ BeginUndo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->DoneBlockMode();
+ pViewShell->InitOwnBlockMode();
+ }
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->DeleteSelection( IDF_ALL, aMarkData );
+ pUndoDoc->CopyToDocument( aRange, IDF_ALL, TRUE, pDoc, &aMarkData );
+
+ // Szenario-Tabellen
+ BOOL bFrame = FALSE;
+ SCTAB nTab = aRange.aStart.Tab();
+ SCTAB nEndTab = nTab;
+ while ( pUndoDoc->HasTable(nEndTab+1) && pUndoDoc->IsScenario(nEndTab+1) )
+ ++nEndTab;
+ for (SCTAB i = nTab+1; i<=nEndTab; i++)
+ {
+ // Flags immer
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pUndoDoc->GetScenarioData( i, aComment, aColor, nScenFlags );
+ pDoc->SetScenarioData( i, aComment, aColor, nScenFlags );
+ BOOL bActive = pUndoDoc->IsActiveScenario( i );
+ pDoc->SetActiveScenario( i, bActive );
+ // Bei Zurueckkopier-Szenarios auch Inhalte
+ if ( nScenFlags & SC_SCENARIO_TWOWAY )
+ {
+ pDoc->DeleteAreaTab( 0,0, MAXCOL,MAXROW, i, IDF_ALL );
+ pUndoDoc->CopyToDocument( 0,0,i, MAXCOL,MAXROW,i, IDF_ALL,FALSE, pDoc );
+ }
+ if ( nScenFlags & SC_SCENARIO_SHOWFRAME )
+ bFrame = TRUE;
+ }
+
+ // Wenn sichtbare Rahmen, dann alles painten
+ if (bFrame)
+ pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_EXTRAS );
+ else
+ pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS );
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+ ShowTable( aRange.aStart.Tab() );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoUseScenario::Redo()
+{
+ SCTAB nTab = aRange.aStart.Tab();
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->SetTabNo( nTab );
+ pViewShell->DoneBlockMode();
+ pViewShell->InitOwnBlockMode();
+ }
+
+ pDocShell->UseScenario( nTab, aName, FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoUseScenario::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ String aTemp = aName;
+ ((ScTabViewTarget&)rTarget).GetViewShell()->UseScenario(aTemp);
+ }
+}
+
+BOOL __EXPORT ScUndoUseScenario::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScViewData* pViewData = ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData();
+ return !pViewData->GetDocument()->IsScenario( pViewData->GetTabNo() );
+ }
+ return FALSE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Vorlage anwenden
+// (Format|Vorlagenkatalog)
+//
+
+ScUndoSelectionStyle::ScUndoSelectionStyle( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ const ScRange& rRange,
+ const String& rName,
+ ScDocument* pNewUndoDoc ) :
+ ScSimpleUndo( pNewDocShell ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ aStyleName( rName ),
+ aRange( rRange )
+{
+ aMarkData.MarkToMulti();
+}
+
+__EXPORT ScUndoSelectionStyle::~ScUndoSelectionStyle()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoSelectionStyle::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_APPLYCELLSTYLE );
+}
+
+void ScUndoSelectionStyle::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ ScRange aWorkRange( aRange );
+ if ( pDoc->HasAttrib( aWorkRange, HASATTR_MERGED ) ) // zusammengefasste Zellen?
+ pDoc->ExtendMerge( aWorkRange, TRUE );
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aWorkRange );
+
+ if (bUndo) // bei Undo alte Daten wieder reinschubsen
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScRange aCopyRange = aWorkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData );
+ }
+ else // bei Redo Style wieder zuweisen
+ {
+ ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool();
+ ScStyleSheet* pStyleSheet =
+ (ScStyleSheet*) pStlPool->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+ if (!pStyleSheet)
+ {
+ DBG_ERROR("StyleSheet not found");
+ return;
+ }
+ pDoc->ApplySelectionStyle( *pStyleSheet, aMarkData );
+ }
+
+ pDocShell->UpdatePaintExt( nExtFlags, aWorkRange );
+
+ if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) )
+/*A*/ pDocShell->PostPaint( aWorkRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags );
+
+ ShowTable( aWorkRange.aStart.Tab() );
+}
+
+void __EXPORT ScUndoSelectionStyle::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+void __EXPORT ScUndoSelectionStyle::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+}
+
+void __EXPORT ScUndoSelectionStyle::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool();
+ ScStyleSheet* pStyleSheet = (ScStyleSheet*) pStlPool->
+ Find( aStyleName, SFX_STYLE_FAMILY_PARA );
+ if (!pStyleSheet)
+ {
+ DBG_ERROR("StyleSheet not found");
+ return;
+ }
+
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+ rViewShell.SetStyleSheetToMarked( pStyleSheet, TRUE );
+ }
+}
+
+BOOL __EXPORT ScUndoSelectionStyle::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+USHORT __EXPORT ScUndoSelectionStyle::GetId() const
+{
+ return STR_UNDO_APPLYCELLSTYLE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Matrix-Formel eingeben
+//
+
+ScUndoEnterMatrix::ScUndoEnterMatrix( ScDocShell* pNewDocShell, const ScRange& rArea,
+ ScDocument* pNewUndoDoc, const String& rForm ) :
+ ScBlockUndo( pNewDocShell, rArea, SC_UNDO_SIMPLE ),
+ pUndoDoc( pNewUndoDoc ),
+ aFormula( rForm )
+{
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoEnterMatrix::~ScUndoEnterMatrix()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoEnterMatrix::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_ENTERMATRIX );
+}
+
+void ScUndoEnterMatrix::SetChangeTrack()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void __EXPORT ScUndoEnterMatrix::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ pDoc->DeleteAreaTab( aBlockRange, IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->CopyToDocument( aBlockRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID );
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoEnterMatrix::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( aBlockRange.aStart.Tab() );
+ aDestMark.SetMarkArea( aBlockRange );
+
+ pDoc->InsertMatrixFormula( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(),
+ aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(),
+ aDestMark, aFormula );
+// pDocShell->PostPaint( aBlockRange, PAINT_GRID ); // nicht noetig ???
+
+ SetChangeTrack();
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoEnterMatrix::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ String aTemp = aFormula;
+ ((ScTabViewTarget&)rTarget).GetViewShell()->EnterMatrix(aTemp);
+ }
+}
+
+BOOL __EXPORT ScUndoEnterMatrix::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// Einzug vermindern / erhoehen
+//
+
+ScRange lcl_GetMultiMarkRange( const ScMarkData& rMark )
+{
+ DBG_ASSERT( rMark.IsMultiMarked(), "wrong mark type" );
+
+ ScRange aRange;
+ rMark.GetMultiMarkArea( aRange );
+ return aRange;
+}
+
+ScUndoIndent::ScUndoIndent( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, BOOL bIncrement ) :
+ ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ bIsIncrement( bIncrement )
+{
+}
+
+__EXPORT ScUndoIndent::~ScUndoIndent()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoIndent::GetComment() const
+{
+ USHORT nId = bIsIncrement ? STR_UNDO_INC_INDENT : STR_UNDO_DEC_INDENT;
+ return ScGlobal::GetRscString( nId );
+}
+
+void __EXPORT ScUndoIndent::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScRange aCopyRange = aBlockRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoIndent::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->ChangeSelectionIndent( bIsIncrement, aMarkData );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoIndent::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->ChangeIndent( bIsIncrement );
+}
+
+BOOL __EXPORT ScUndoIndent::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// Transliteration for cells
+//
+
+ScUndoTransliterate::ScUndoTransliterate( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, sal_Int32 nType ) :
+ ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ nTransliterationType( nType )
+{
+}
+
+__EXPORT ScUndoTransliterate::~ScUndoTransliterate()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoTransliterate::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_TRANSLITERATE );
+}
+
+void __EXPORT ScUndoTransliterate::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScRange aCopyRange = aBlockRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_CONTENTS, TRUE, pDoc, &aMarkData );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoTransliterate::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->TransliterateText( aMarkData, nTransliterationType );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoTransliterate::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->TransliterateText( nTransliterationType );
+}
+
+BOOL __EXPORT ScUndoTransliterate::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// einzelne Items per Which-IDs aus Bereich loeschen
+//
+
+ScUndoClearItems::ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, const USHORT* pW ) :
+ ScBlockUndo( pNewDocShell, lcl_GetMultiMarkRange(rMark), SC_UNDO_AUTOHEIGHT ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ pWhich( NULL )
+{
+ DBG_ASSERT( pW, "ScUndoClearItems: Which-Pointer ist 0" );
+
+ USHORT nCount = 0;
+ while ( pW[nCount] )
+ ++nCount;
+ pWhich = new USHORT[nCount+1];
+ for (USHORT i=0; i<=nCount; i++)
+ pWhich[i] = pW[i];
+}
+
+__EXPORT ScUndoClearItems::~ScUndoClearItems()
+{
+ delete pUndoDoc;
+ delete pWhich;
+}
+
+String __EXPORT ScUndoClearItems::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
+}
+
+void __EXPORT ScUndoClearItems::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoClearItems::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->ClearSelectionItems( pWhich, aMarkData );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoClearItems::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScViewData* pViewData = ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData();
+ ScDocFunc aFunc(*pViewData->GetDocShell());
+ aFunc.ClearItems( pViewData->GetMarkData(), pWhich, FALSE );
+ }
+}
+
+BOOL __EXPORT ScUndoClearItems::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// Alle Umbrueche einer Tabelle loeschen
+//
+
+ScUndoRemoveBreaks::ScUndoRemoveBreaks( ScDocShell* pNewDocShell,
+ SCTAB nNewTab, ScDocument* pNewUndoDoc ) :
+ ScSimpleUndo( pNewDocShell ),
+ nTab( nNewTab ),
+ pUndoDoc( pNewUndoDoc )
+{
+}
+
+__EXPORT ScUndoRemoveBreaks::~ScUndoRemoveBreaks()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoRemoveBreaks::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_REMOVEBREAKS );
+}
+
+void __EXPORT ScUndoRemoveBreaks::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pDoc );
+ if (pViewShell)
+ pViewShell->UpdatePageBreakData( TRUE );
+ pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoRemoveBreaks::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ pDoc->RemoveManualBreaks(nTab);
+ pDoc->UpdatePageBreaks(nTab);
+ if (pViewShell)
+ pViewShell->UpdatePageBreakData( TRUE );
+ pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoRemoveBreaks::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+ rViewShell.RemoveManualBreaks();
+ }
+}
+
+BOOL __EXPORT ScUndoRemoveBreaks::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// Zusammenfassung aufheben (fuer einen ganzen Bereich)
+//
+
+ScUndoRemoveMerge::ScUndoRemoveMerge( ScDocShell* pNewDocShell,
+ const ScCellMergeOption& rOption, ScDocument* pNewUndoDoc ) :
+ ScBlockUndo( pNewDocShell, rOption.getFirstSingleRange(), SC_UNDO_SIMPLE ),
+ maOption(rOption),
+ pUndoDoc( pNewUndoDoc )
+{
+}
+
+__EXPORT ScUndoRemoveMerge::~ScUndoRemoveMerge()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoRemoveMerge::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_REMERGE ); // "Zusammenfassung aufheben"
+}
+
+void __EXPORT ScUndoRemoveMerge::Undo()
+{
+ using ::std::set;
+
+ SetCurTab();
+ BeginUndo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ for (set<SCTAB>::const_iterator itr = maOption.maTabs.begin(), itrEnd = maOption.maTabs.end();
+ itr != itrEnd; ++itr)
+ {
+ // There is no need to extend merge area because it's already been extended.
+ ScRange aRange = maOption.getSingleRange(*itr);
+ pDoc->DeleteAreaTab(aRange, IDF_ATTRIB);
+ pUndoDoc->CopyToDocument(aRange, IDF_ATTRIB, FALSE, pDoc);
+
+ bool bDidPaint = false;
+ if ( pViewShell )
+ {
+ pViewShell->SetTabNo(*itr);
+ bDidPaint = pViewShell->AdjustRowHeight(maOption.mnStartRow, maOption.mnEndRow);
+ }
+ if (!bDidPaint)
+ ScUndoUtil::PaintMore(pDocShell, aRange);
+ }
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoRemoveMerge::Redo()
+{
+ using ::std::set;
+
+ SetCurTab();
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ for (set<SCTAB>::const_iterator itr = maOption.maTabs.begin(), itrEnd = maOption.maTabs.end();
+ itr != itrEnd; ++itr)
+ {
+ SCTAB nTab = *itr;
+ // There is no need to extend merge area because it's already been extended.
+ ScRange aRange = maOption.getSingleRange(nTab);
+
+ // ausfuehren
+
+ const SfxPoolItem& rDefAttr = pDoc->GetPool()->GetDefaultItem( ATTR_MERGE );
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( rDefAttr );
+ pDoc->ApplyPatternAreaTab( maOption.mnStartCol, maOption.mnStartRow,
+ maOption.mnEndCol, maOption.mnEndRow, nTab,
+ aPattern );
+
+ pDoc->RemoveFlagsTab( maOption.mnStartCol, maOption.mnStartRow,
+ maOption.mnEndCol, maOption.mnEndRow, nTab,
+ SC_MF_HOR | SC_MF_VER );
+
+ pDoc->ExtendMerge(aRange, TRUE, FALSE);
+
+ // Paint
+
+ BOOL bDidPaint = FALSE;
+ if ( pViewShell )
+ {
+ pViewShell->SetTabNo(nTab);
+ bDidPaint = pViewShell->AdjustRowHeight(maOption.mnStartRow, maOption.mnEndRow);
+ }
+ if (!bDidPaint)
+ ScUndoUtil::PaintMore(pDocShell, aRange);
+ }
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoRemoveMerge::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->RemoveMerge();
+}
+
+BOOL __EXPORT ScUndoRemoveMerge::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+void ScUndoRemoveMerge::SetCurTab()
+{
+ SCTAB nCurTab = pDocShell->GetCurTab();
+ aBlockRange.aStart.SetTab(nCurTab);
+ aBlockRange.aEnd.SetTab(nCurTab);
+}
+
+// -----------------------------------------------------------------------
+//
+// nur Umrandung setzen, per ScRangeList (StarOne)
+//
+
+ScRange lcl_TotalRange( const ScRangeList& rRanges )
+{
+ ScRange aTotal;
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange aRange = *rRanges.GetObject(i);
+ if (i==0)
+ aTotal = aRange;
+ else
+ {
+ if (aRange.aStart.Col() < aTotal.aStart.Col())
+ aTotal.aStart.SetCol(aRange.aStart.Col());
+ if (aRange.aStart.Row() < aTotal.aStart.Row())
+ aTotal.aStart.SetRow(aRange.aStart.Row());
+ if (aRange.aStart.Tab() < aTotal.aStart.Tab())
+ aTotal.aStart.SetTab(aRange.aStart.Tab());
+ if (aRange.aEnd.Col() > aTotal.aEnd.Col())
+ aTotal.aEnd.SetCol(aRange.aEnd.Col());
+ if (aRange.aEnd.Row() > aTotal.aEnd.Row())
+ aTotal.aEnd.SetRow(aRange.aEnd.Row());
+ if (aRange.aEnd.Tab() > aTotal.aEnd.Tab())
+ aTotal.aEnd.SetTab(aRange.aEnd.Tab());
+ }
+ }
+ return aTotal;
+}
+
+ScUndoBorder::ScUndoBorder( ScDocShell* pNewDocShell,
+ const ScRangeList& rRangeList, ScDocument* pNewUndoDoc,
+ const SvxBoxItem& rNewOuter, const SvxBoxInfoItem& rNewInner ) :
+ ScBlockUndo( pNewDocShell, lcl_TotalRange(rRangeList), SC_UNDO_SIMPLE ),
+ pUndoDoc( pNewUndoDoc )
+{
+ pRanges = new ScRangeList(rRangeList);
+ pOuter = new SvxBoxItem(rNewOuter);
+ pInner = new SvxBoxInfoItem(rNewInner);
+}
+
+__EXPORT ScUndoBorder::~ScUndoBorder()
+{
+ delete pUndoDoc;
+ delete pRanges;
+ delete pOuter;
+ delete pInner;
+}
+
+String __EXPORT ScUndoBorder::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_SELATTRLINES ); //! eigener String?
+}
+
+void __EXPORT ScUndoBorder::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( *pRanges, FALSE );
+ pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, TRUE, pDoc, &aMarkData );
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoBorder::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument(); //! Funktion an docfunc aufrufen
+ ULONG nCount = pRanges->Count();
+ ULONG i;
+ for (i=0; i<nCount; i++)
+ {
+ ScRange aRange = *pRanges->GetObject(i);
+ SCTAB nTab = aRange.aStart.Tab();
+
+ ScMarkData aMark;
+ aMark.SetMarkArea( aRange );
+ aMark.SelectTable( nTab, TRUE );
+
+ pDoc->ApplySelectionFrame( aMark, pOuter, pInner );
+ }
+ for (i=0; i<nCount; i++)
+ pDocShell->PostPaint( *pRanges->GetObject(i), PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoBorder::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ //! spaeter (wenn die Funktion aus cellsuno nach docfunc gewandert ist)
+}
+
+BOOL __EXPORT ScUndoBorder::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // s.o.
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx
new file mode 100644
index 000000000000..101dcc9b12e7
--- /dev/null
+++ b/sc/source/ui/undo/undoblk2.cxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+#ifndef PCH
+#include "scitems.hxx" // SearchItem
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "undoblk.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "olinetab.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "target.hxx"
+
+#include "undoolk.hxx" //! GetUndo ins Document verschieben!
+
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScUndoWidthOrHeight, SfxUndoAction);
+
+// -----------------------------------------------------------------------
+
+
+
+//
+// Spaltenbreiten oder Zeilenhoehen aendern
+//
+
+ScUndoWidthOrHeight::ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOLROW nNewStart, SCTAB nNewStartTab, SCCOLROW nNewEnd, SCTAB nNewEndTab,
+ ScDocument* pNewUndoDoc, SCCOLROW nNewCnt, SCCOLROW* pNewRanges,
+ ScOutlineTable* pNewUndoTab,
+ ScSizeMode eNewMode, USHORT nNewSizeTwips, BOOL bNewWidth ) :
+ ScSimpleUndo( pNewDocShell ),
+ aMarkData( rMark ),
+ nStart( nNewStart ),
+ nEnd( nNewEnd ),
+ nStartTab( nNewStartTab ),
+ nEndTab( nNewEndTab ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTab( pNewUndoTab ),
+ nRangeCnt( nNewCnt ),
+ pRanges( pNewRanges ),
+ nNewSize( nNewSizeTwips ),
+ bWidth( bNewWidth ),
+ eMode( eNewMode ),
+ pDrawUndo( NULL )
+{
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+}
+
+__EXPORT ScUndoWidthOrHeight::~ScUndoWidthOrHeight()
+{
+ delete[] pRanges;
+ delete pUndoDoc;
+ delete pUndoTab;
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String __EXPORT ScUndoWidthOrHeight::GetComment() const
+{
+ // [ "optimale " ] "Spaltenbreite" | "Zeilenhoehe"
+ return ( bWidth ?
+ ( ( eMode == SC_SIZE_OPTIMAL )?
+ ScGlobal::GetRscString( STR_UNDO_OPTCOLWIDTH ) :
+ ScGlobal::GetRscString( STR_UNDO_COLWIDTH )
+ ) :
+ ( ( eMode == SC_SIZE_OPTIMAL )?
+ ScGlobal::GetRscString( STR_UNDO_OPTROWHEIGHT ) :
+ ScGlobal::GetRscString( STR_UNDO_ROWHEIGHT )
+ ) );
+}
+
+void __EXPORT ScUndoWidthOrHeight::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCCOLROW nPaintStart = nStart > 0 ? nStart-1 : static_cast<SCCOLROW>(0);
+
+ if (eMode==SC_SIZE_OPTIMAL)
+ {
+ if (pViewShell)
+ {
+ pViewShell->SetMarkData( aMarkData );
+
+ nPaintStart = 0; // paint all, because of changed selection
+ }
+ }
+
+ //! outlines from all tables?
+ if (pUndoTab) // Outlines mit gespeichert?
+ pDoc->SetOutlineTable( nStartTab, pUndoTab );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTab;
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (aMarkData.GetTableSelect(nTab))
+ {
+ if (bWidth) // Width
+ {
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE,
+ FALSE, pDoc );
+ pDoc->UpdatePageBreaks( nTab );
+ pDocShell->PostPaint( static_cast<SCCOL>(nPaintStart), 0, nTab,
+ MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_TOP );
+ }
+ else // Height
+ {
+ pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pDoc );
+ pDoc->UpdatePageBreaks( nTab );
+ pDocShell->PostPaint( 0, nPaintStart, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT );
+ }
+ }
+
+ DoSdrUndoAction( pDrawUndo, pDoc );
+
+ if (pViewShell)
+ {
+ pViewShell->UpdateScrollBars();
+
+ SCTAB nCurrentTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nCurrentTab < nStartTab || nCurrentTab > nEndTab )
+ pViewShell->SetTabNo( nStartTab );
+ }
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoWidthOrHeight::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ BOOL bPaintAll = FALSE;
+ if (eMode==SC_SIZE_OPTIMAL)
+ {
+ if (pViewShell)
+ {
+ pViewShell->SetMarkData( aMarkData );
+
+ bPaintAll = TRUE; // paint all, because of changed selection
+ }
+ }
+
+ if (pViewShell)
+ {
+ SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nTab < nStartTab || nTab > nEndTab )
+ pViewShell->SetTabNo( nStartTab );
+ }
+
+ // SetWidthOrHeight aendert aktuelle Tabelle !
+ pViewShell->SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nNewSize, FALSE, TRUE, &aMarkData );
+
+ // paint grid if selection was changed directly at the MarkData
+ if (bPaintAll)
+ pDocShell->PostPaint( 0, 0, nStartTab, MAXCOL, MAXROW, nEndTab, PAINT_GRID );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoWidthOrHeight::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->SetMarkedWidthOrHeight( bWidth, eMode, nNewSize, TRUE );
+}
+
+BOOL __EXPORT ScUndoWidthOrHeight::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undoblk3.cxx b/sc/source/ui/undo/undoblk3.cxx
new file mode 100644
index 000000000000..6b25be0ef684
--- /dev/null
+++ b/sc/source/ui/undo/undoblk3.cxx
@@ -0,0 +1,2181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/virdev.hxx>
+#include <sfx2/app.hxx>
+
+#include "undoblk.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "rangenam.hxx"
+#include "arealink.hxx"
+#include "patattr.hxx"
+#include "target.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "table.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "undoolk.hxx"
+#include "undoutil.hxx"
+#include "chgtrack.hxx"
+#include "dociter.hxx"
+#include "cell.hxx"
+#include "paramisc.hxx"
+#include "postit.hxx"
+#include "docuno.hxx"
+
+// STATIC DATA ---------------------------------------------------------------
+
+TYPEINIT1(ScUndoDeleteContents, SfxUndoAction);
+TYPEINIT1(ScUndoFillTable, SfxUndoAction);
+TYPEINIT1(ScUndoSelectionAttr, SfxUndoAction);
+TYPEINIT1(ScUndoAutoFill, SfxUndoAction);
+TYPEINIT1(ScUndoMerge, SfxUndoAction);
+TYPEINIT1(ScUndoAutoFormat, SfxUndoAction);
+TYPEINIT1(ScUndoReplace, SfxUndoAction);
+TYPEINIT1(ScUndoTabOp, SfxUndoAction);
+TYPEINIT1(ScUndoConversion, SfxUndoAction);
+TYPEINIT1(ScUndoRefConversion, SfxUndoAction);
+TYPEINIT1(ScUndoRefreshLink, SfxUndoAction);
+TYPEINIT1(ScUndoInsertAreaLink, SfxUndoAction);
+TYPEINIT1(ScUndoRemoveAreaLink, SfxUndoAction);
+TYPEINIT1(ScUndoUpdateAreaLink, SfxUndoAction);
+
+
+// To Do:
+/*A*/ // SetOptimalHeight auf Dokument, wenn keine View
+
+
+//============================================================================
+// class ScUndoDeleteContents
+//
+// Inhalte loeschen
+
+//----------------------------------------------------------------------------
+
+ScUndoDeleteContents::ScUndoDeleteContents(
+ ScDocShell* pNewDocShell,
+ const ScMarkData& rMark, const ScRange& rRange,
+ ScDocument* pNewUndoDoc, BOOL bNewMulti,
+ USHORT nNewFlags, BOOL bObjects )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ aRange ( rRange ),
+ aMarkData ( rMark ),
+ pUndoDoc ( pNewUndoDoc ),
+ pDrawUndo ( NULL ),
+ nFlags ( nNewFlags ),
+ bMulti ( bNewMulti ) // ueberliquid
+{
+ if (bObjects)
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+
+ if ( !(aMarkData.IsMarked() || aMarkData.IsMultiMarked()) ) // keine Zelle markiert:
+ aMarkData.SetMarkArea( aRange ); // Zelle unter Cursor markieren
+
+ SetChangeTrack();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoDeleteContents::~ScUndoDeleteContents()
+{
+ delete pUndoDoc;
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoDeleteContents::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); // "Loeschen"
+}
+
+
+void ScUndoDeleteContents::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack && (nFlags & IDF_CONTENTS) )
+ pChangeTrack->AppendContentRange( aRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoDeleteContents::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ USHORT nExtFlags = 0;
+
+ if (bUndo) // nur Undo
+ {
+ USHORT nUndoFlags = IDF_NONE; // entweder alle oder keine Inhalte kopieren
+ if (nFlags & IDF_CONTENTS) // (es sind nur die richtigen ins UndoDoc kopiert worden)
+ nUndoFlags |= IDF_CONTENTS;
+ if (nFlags & IDF_ATTRIB)
+ nUndoFlags |= IDF_ATTRIB;
+ if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute
+ nUndoFlags |= IDF_STRING; // -> Zellen werden geaendert
+ // do not create clones of note captions, they will be restored via drawing undo
+ nUndoFlags |= IDF_NOCAPTIONS;
+
+ ScRange aCopyRange = aRange;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+
+ pUndoDoc->CopyToDocument( aCopyRange, nUndoFlags, bMulti, pDoc, &aMarkData );
+
+ DoSdrUndoAction( pDrawUndo, pDoc );
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ pDocShell->UpdatePaintExt( nExtFlags, aRange ); // content after the change
+ }
+ else // nur Redo
+ {
+ pDocShell->UpdatePaintExt( nExtFlags, aRange ); // content before the change
+
+ aMarkData.MarkToMulti();
+ RedoSdrUndoAction( pDrawUndo );
+ // do not delete objects and note captions, they have been removed via drawing undo
+ USHORT nRedoFlags = (nFlags & ~IDF_OBJECTS) | IDF_NOCAPTIONS;
+ pDoc->DeleteSelection( nRedoFlags, aMarkData );
+ aMarkData.MarkToSimple();
+
+ SetChangeTrack();
+ }
+
+ if ( !( (pViewShell) && pViewShell->AdjustRowHeight(
+ aRange.aStart.Row(), aRange.aEnd.Row() ) ) )
+/*A*/ pDocShell->PostPaint( aRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags );
+
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+ ShowTable( aRange );
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoDeleteContents::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ aChangeRanges.Append( aRange );
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoDeleteContents::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ aChangeRanges.Append( aRange );
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoDeleteContents::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->DeleteContents( nFlags, TRUE );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoDeleteContents::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoFillTable
+//
+// Tabellen ausfuellen
+// (Bearbeiten|Ausfuellen|...)
+
+//----------------------------------------------------------------------------
+
+ScUndoFillTable::ScUndoFillTable( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, BOOL bNewMulti, SCTAB nSrc,
+ USHORT nFlg, USHORT nFunc, BOOL bSkip, BOOL bLink )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
+ aMarkData ( rMark ),
+ pUndoDoc ( pNewUndoDoc ),
+ nFlags ( nFlg ),
+ nFunction ( nFunc ),
+ nSrcTab ( nSrc ),
+ bMulti ( bNewMulti ),
+ bSkipEmpty ( bSkip ),
+ bAsLink ( bLink )
+{
+ SetChangeTrack();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoFillTable::~ScUndoFillTable()
+{
+ delete pUndoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoFillTable::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_FILL_TAB );
+}
+
+
+void ScUndoFillTable::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
+ ScRange aWorkRange(aRange);
+ nStartChangeAction = 0;
+ ULONG nTmpAction;
+ for ( SCTAB i = 0; i < nTabCount; i++ )
+ {
+ if (i != nSrcTab && aMarkData.GetTableSelect(i))
+ {
+ aWorkRange.aStart.SetTab(i);
+ aWorkRange.aEnd.SetTab(i);
+ pChangeTrack->AppendContentRange( aWorkRange, pUndoDoc,
+ nTmpAction, nEndChangeAction );
+ if ( !nStartChangeAction )
+ nStartChangeAction = nTmpAction;
+ }
+ }
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoFillTable::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ if (bUndo) // nur Undo
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScRange aWorkRange(aRange);
+ for ( SCTAB i = 0; i < nTabCount; i++ )
+ if (i != nSrcTab && aMarkData.GetTableSelect(i))
+ {
+ aWorkRange.aStart.SetTab(i);
+ aWorkRange.aEnd.SetTab(i);
+ if (bMulti)
+ pDoc->DeleteSelectionTab( i, IDF_ALL, aMarkData );
+ else
+ pDoc->DeleteAreaTab( aWorkRange, IDF_ALL );
+ pUndoDoc->CopyToDocument( aWorkRange, IDF_ALL, bMulti, pDoc, &aMarkData );
+ }
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ }
+ else // nur Redo
+ {
+ aMarkData.MarkToMulti();
+ pDoc->FillTabMarked( nSrcTab, aMarkData, nFlags, nFunction, bSkipEmpty, bAsLink );
+ aMarkData.MarkToSimple();
+ SetChangeTrack();
+ }
+
+ pDocShell->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_EXTRAS);
+ pDocShell->PostDataChanged();
+
+ // CellContentChanged kommt mit der Markierung
+
+ if (pViewShell)
+ {
+ SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
+ if ( !aMarkData.GetTableSelect(nTab) )
+ pViewShell->SetTabNo( nSrcTab );
+
+ pViewShell->DoneBlockMode(); // gibt sonst Probleme, weil Markierung auf falscher Tabelle
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoFillTable::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoFillTable::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoFillTable::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoFillTable::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoSelectionAttr
+//
+// Zellformat aendern
+
+//----------------------------------------------------------------------------
+
+ScUndoSelectionAttr::ScUndoSelectionAttr( ScDocShell* pNewDocShell,
+ const ScMarkData& rMark,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, BOOL bNewMulti,
+ const ScPatternAttr* pNewApply,
+ const SvxBoxItem* pNewOuter, const SvxBoxInfoItem* pNewInner )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ aMarkData ( rMark ),
+ aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
+ pUndoDoc ( pNewUndoDoc ),
+ bMulti ( bNewMulti )
+{
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ pApplyPattern = (ScPatternAttr*) &pPool->Put( *pNewApply );
+ pLineOuter = pNewOuter ? (SvxBoxItem*) &pPool->Put( *pNewOuter ) : NULL;
+ pLineInner = pNewInner ? (SvxBoxInfoItem*) &pPool->Put( *pNewInner ) : NULL;
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoSelectionAttr::~ScUndoSelectionAttr()
+{
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ pPool->Remove(*pApplyPattern);
+ if (pLineOuter)
+ pPool->Remove(*pLineOuter);
+ if (pLineInner)
+ pPool->Remove(*pLineInner);
+
+ delete pUndoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoSelectionAttr::GetComment() const
+{
+ //"Attribute" "/Linien"
+ return ScGlobal::GetRscString( pLineOuter ? STR_UNDO_SELATTRLINES : STR_UNDO_SELATTR );
+}
+
+//----------------------------------------------------------------------------
+
+ScEditDataArray* ScUndoSelectionAttr::GetDataArray()
+{
+ return &aDataArray;
+}
+
+//----------------------------------------------------------------------------
+
+void ScUndoSelectionAttr::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ ScRange aEffRange( aRange );
+ if ( pDoc->HasAttrib( aEffRange, HASATTR_MERGED ) ) // zusammengefasste Zellen?
+ pDoc->ExtendMerge( aEffRange );
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aEffRange );
+
+ ChangeEditData(bUndo);
+
+ if (bUndo) // nur bei Undo
+ {
+ ScRange aCopyRange = aRange;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pDoc, &aMarkData );
+ }
+ else // nur bei Redo
+ {
+ aMarkData.MarkToMulti();
+ pDoc->ApplySelectionPattern( *pApplyPattern, aMarkData );
+ aMarkData.MarkToSimple();
+
+ if (pLineOuter)
+ pDoc->ApplySelectionFrame( aMarkData, pLineOuter, pLineInner );
+ }
+
+ if ( !( (pViewShell) && pViewShell->AdjustBlockHeight() ) )
+/*A*/ pDocShell->PostPaint( aEffRange, PAINT_GRID | PAINT_EXTRAS, nExtFlags );
+
+ ShowTable( aRange );
+}
+
+void ScUndoSelectionAttr::ChangeEditData( const bool bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ for (const ScEditDataArray::Item* pItem = aDataArray.First(); pItem; pItem = aDataArray.Next())
+ {
+ ScBaseCell* pCell;
+ pDoc->GetCell(pItem->GetCol(), pItem->GetRow(), pItem->GetTab(), pCell);
+ if (!pCell || pCell->GetCellType() != CELLTYPE_EDIT)
+ continue;
+
+ ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
+ if (bUndo)
+ pEditCell->SetData(pItem->GetOldData(), NULL);
+ else
+ pEditCell->SetData(pItem->GetNewData(), NULL);
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoSelectionAttr::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoSelectionAttr::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoSelectionAttr::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+ if (pLineOuter)
+ rViewShell.ApplyPatternLines( *pApplyPattern, pLineOuter, pLineInner, TRUE );
+ else
+ rViewShell.ApplySelectionPattern( *pApplyPattern, TRUE );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoSelectionAttr::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoAutoFill
+//
+// Auto-Fill (nur einfache Bloecke)
+
+//----------------------------------------------------------------------------
+
+ScUndoAutoFill::ScUndoAutoFill( ScDocShell* pNewDocShell,
+ const ScRange& rRange, const ScRange& rSourceArea,
+ ScDocument* pNewUndoDoc, const ScMarkData& rMark,
+ FillDir eNewFillDir, FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd,
+ double fNewStartValue, double fNewStepValue, double fNewMaxValue,
+ USHORT nMaxShIndex )
+ //
+ : ScBlockUndo( pNewDocShell, rRange, SC_UNDO_AUTOHEIGHT ),
+ //
+ aSource ( rSourceArea ),
+ aMarkData ( rMark ),
+ pUndoDoc ( pNewUndoDoc ),
+ eFillDir ( eNewFillDir ),
+ eFillCmd ( eNewFillCmd ),
+ eFillDateCmd ( eNewFillDateCmd ),
+ fStartValue ( fNewStartValue ),
+ fStepValue ( fNewStepValue ),
+ fMaxValue ( fNewMaxValue ),
+ nMaxSharedIndex ( nMaxShIndex)
+{
+ SetChangeTrack();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoAutoFill::~ScUndoAutoFill()
+{
+ pDocShell->GetDocument()->EraseNonUsedSharedNames(nMaxSharedIndex);
+ delete pUndoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoAutoFill::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_AUTOFILL ); //"Ausfuellen"
+}
+
+
+void ScUndoAutoFill::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoAutoFill::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ if (aMarkData.GetTableSelect(nTab))
+ {
+ ScRange aWorkRange = aBlockRange;
+ aWorkRange.aStart.SetTab(nTab);
+ aWorkRange.aEnd.SetTab(nTab);
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aWorkRange );
+ pDoc->DeleteAreaTab( aWorkRange, IDF_AUTOFILL );
+ pUndoDoc->CopyToDocument( aWorkRange, IDF_AUTOFILL, FALSE, pDoc );
+
+ pDoc->ExtendMerge( aWorkRange, TRUE );
+ pDocShell->PostPaint( aWorkRange, PAINT_GRID, nExtFlags );
+ }
+ }
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+// Shared-Names loeschen
+// Falls Undo ins Dokument gespeichert
+// => automatisches Loeschen am Ende
+// umarbeiten!!
+
+ String aName = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("___SC_"));
+ aName += String::CreateFromInt32(nMaxSharedIndex);
+ aName += '_';
+ ScRangeName* pRangeName = pDoc->GetRangeName();
+ BOOL bHasFound = FALSE;
+ for (USHORT i = 0; i < pRangeName->GetCount(); i++)
+ {
+ ScRangeData* pRangeData = (*pRangeName)[i];
+ if (pRangeData)
+ {
+ String aRName;
+ pRangeData->GetName(aRName);
+ if (aRName.Search(aName) != STRING_NOTFOUND)
+ {
+ pRangeName->AtFree(i);
+ bHasFound = TRUE;
+ }
+ }
+ }
+ if (bHasFound)
+ pRangeName->SetSharedMaxIndex(pRangeName->GetSharedMaxIndex()-1);
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoAutoFill::Redo()
+{
+ BeginRedo();
+
+//! Tabellen selektieren
+
+ SCCOLROW nCount = 0;
+ switch (eFillDir)
+ {
+ case FILL_TO_BOTTOM:
+ nCount = aBlockRange.aEnd.Row() - aSource.aEnd.Row();
+ break;
+ case FILL_TO_RIGHT:
+ nCount = aBlockRange.aEnd.Col() - aSource.aEnd.Col();
+ break;
+ case FILL_TO_TOP:
+ nCount = aSource.aStart.Row() - aBlockRange.aStart.Row();
+ break;
+ case FILL_TO_LEFT:
+ nCount = aSource.aStart.Col() - aBlockRange.aStart.Col();
+ break;
+ }
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( fStartValue != MAXDOUBLE )
+ {
+ SCCOL nValX = (eFillDir == FILL_TO_LEFT) ? aSource.aEnd.Col() : aSource.aStart.Col();
+ SCROW nValY = (eFillDir == FILL_TO_TOP ) ? aSource.aEnd.Row() : aSource.aStart.Row();
+ SCTAB nTab = aSource.aStart.Tab();
+ pDoc->SetValue( nValX, nValY, nTab, fStartValue );
+ }
+ pDoc->Fill( aSource.aStart.Col(), aSource.aStart.Row(),
+ aSource.aEnd.Col(), aSource.aEnd.Row(),
+ aMarkData, nCount,
+ eFillDir, eFillCmd, eFillDateCmd,
+ fStepValue, fMaxValue );
+
+ SetChangeTrack();
+
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID );
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoAutoFill::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+ if (eFillCmd==FILL_SIMPLE)
+ rViewShell.FillSimple( eFillDir, TRUE );
+ else
+ rViewShell.FillSeries( eFillDir, eFillCmd, eFillDateCmd,
+ fStartValue, fStepValue, fMaxValue, TRUE );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoAutoFill::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoMerge
+//
+// Zellen zusammenfassen / Zusammenfassung aufheben
+
+//----------------------------------------------------------------------------
+
+ScUndoMerge::ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
+ bool bMergeContents, ScDocument* pUndoDoc, SdrUndoAction* pDrawUndo )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ maOption(rOption),
+ mbMergeContents( bMergeContents ),
+ mpUndoDoc( pUndoDoc ),
+ mpDrawUndo( pDrawUndo )
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+ScUndoMerge::~ScUndoMerge()
+{
+ delete mpUndoDoc;
+ DeleteSdrUndoAction( mpDrawUndo );
+}
+
+
+//----------------------------------------------------------------------------
+
+String ScUndoMerge::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_MERGE );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoMerge::DoChange( bool bUndo ) const
+{
+ using ::std::set;
+
+ if (maOption.maTabs.empty())
+ // Nothing to do.
+ return;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScRange aCurRange = maOption.getSingleRange(pDocShell->GetCurTab());
+ ScUndoUtil::MarkSimpleBlock(pDocShell, aCurRange);
+
+ for (set<SCTAB>::const_iterator itr = maOption.maTabs.begin(), itrEnd = maOption.maTabs.end();
+ itr != itrEnd; ++itr)
+ {
+ SCTAB nTab = *itr;
+ ScRange aRange = maOption.getSingleRange(nTab);
+
+ if (bUndo)
+ // remove merge (contents are copied back below from undo document)
+ pDoc->RemoveMerge( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() );
+ else
+ {
+ // repeat merge, but do not remove note captions (will be done by drawing redo below)
+ pDoc->DoMerge( aRange.aStart.Tab(),
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), false );
+
+ if (maOption.mbCenter)
+ {
+ pDoc->ApplyAttr( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aStart.Tab(),
+ SvxHorJustifyItem( SVX_HOR_JUSTIFY_CENTER, ATTR_HOR_JUSTIFY ) );
+ pDoc->ApplyAttr( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aStart.Tab(),
+ SvxVerJustifyItem( SVX_VER_JUSTIFY_CENTER, ATTR_VER_JUSTIFY ) );
+ }
+ }
+
+ // undo -> copy back deleted contents
+ if (bUndo && mpUndoDoc)
+ {
+ pDoc->DeleteAreaTab( aRange, IDF_CONTENTS|IDF_NOCAPTIONS );
+ mpUndoDoc->CopyToDocument( aRange, IDF_ALL|IDF_NOCAPTIONS, FALSE, pDoc );
+ }
+
+ // redo -> merge contents again
+ else if (!bUndo && mbMergeContents)
+ {
+ pDoc->DoMergeContents( aRange.aStart.Tab(),
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row() );
+ }
+
+ if (bUndo)
+ DoSdrUndoAction( mpDrawUndo, pDoc );
+ else
+ RedoSdrUndoAction( mpDrawUndo );
+
+ bool bDidPaint = false;
+ if ( pViewShell )
+ {
+ pViewShell->SetTabNo(nTab);
+ bDidPaint = pViewShell->AdjustRowHeight(maOption.mnStartRow, maOption.mnEndRow);
+ }
+
+ if (!bDidPaint)
+ ScUndoUtil::PaintMore(pDocShell, aRange);
+ }
+
+ ShowTable(aCurRange);
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoMerge::Undo()
+{
+ BeginUndo();
+ DoChange( true );
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoMerge::Redo()
+{
+ BeginRedo();
+ DoChange( false );
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoMerge::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+ BOOL bCont = FALSE;
+ rViewShell.MergeCells( FALSE, bCont, TRUE );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScUndoMerge::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoAutoFormat
+//
+// Auto-Format (nur einfache Bloecke)
+
+//----------------------------------------------------------------------------
+
+ScUndoAutoFormat::ScUndoAutoFormat( ScDocShell* pNewDocShell,
+ const ScRange& rRange, ScDocument* pNewUndoDoc,
+ const ScMarkData& rMark, BOOL bNewSize, USHORT nNewFormatNo )
+ //
+ : ScBlockUndo( pNewDocShell, rRange, bNewSize ? SC_UNDO_MANUALHEIGHT : SC_UNDO_AUTOHEIGHT ),
+ //
+ pUndoDoc ( pNewUndoDoc ),
+ aMarkData ( rMark ),
+ bSize ( bNewSize ),
+ nFormatNo ( nNewFormatNo )
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoAutoFormat::~ScUndoAutoFormat()
+{
+ delete pUndoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoAutoFormat::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_AUTOFORMAT ); //"Auto-Format"
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoAutoFormat::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ // Attribute
+// pDoc->DeleteAreaTab( aBlockRange, IDF_ATTRIB );
+// pUndoDoc->CopyToDocument( aBlockRange, IDF_ATTRIB, FALSE, pDoc );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pDoc->DeleteArea( aBlockRange.aStart.Col(), aBlockRange.aStart.Row(),
+ aBlockRange.aEnd.Col(), aBlockRange.aEnd.Row(),
+ aMarkData, IDF_ATTRIB );
+ ScRange aCopyRange = aBlockRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, FALSE, pDoc, &aMarkData );
+
+ // Zellhoehen und -breiten (IDF_NONE)
+ if (bSize)
+ {
+ SCCOL nStartX = aBlockRange.aStart.Col();
+ SCROW nStartY = aBlockRange.aStart.Row();
+ SCTAB nStartZ = aBlockRange.aStart.Tab();
+ SCCOL nEndX = aBlockRange.aEnd.Col();
+ SCROW nEndY = aBlockRange.aEnd.Row();
+ SCTAB nEndZ = aBlockRange.aEnd.Tab();
+
+ pUndoDoc->CopyToDocument( nStartX, 0, 0, nEndX, MAXROW, nTabCount-1,
+ IDF_NONE, FALSE, pDoc, &aMarkData );
+ pUndoDoc->CopyToDocument( 0, nStartY, 0, MAXCOL, nEndY, nTabCount-1,
+ IDF_NONE, FALSE, pDoc, &aMarkData );
+ pDocShell->PostPaint( 0, 0, nStartZ, MAXCOL, MAXROW, nEndZ,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP, SC_PF_LINES );
+ }
+ else
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES );
+
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoAutoFormat::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ SCCOL nStartX = aBlockRange.aStart.Col();
+ SCROW nStartY = aBlockRange.aStart.Row();
+ SCTAB nStartZ = aBlockRange.aStart.Tab();
+ SCCOL nEndX = aBlockRange.aEnd.Col();
+ SCROW nEndY = aBlockRange.aEnd.Row();
+ SCTAB nEndZ = aBlockRange.aEnd.Tab();
+
+ pDoc->AutoFormat( nStartX, nStartY, nEndX, nEndY, nFormatNo, aMarkData );
+
+ if (bSize)
+ {
+ VirtualDevice aVirtDev;
+ Fraction aZoomX(1,1);
+ Fraction aZoomY = aZoomX;
+ double nPPTX,nPPTY;
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ ScViewData* pData = pViewShell->GetViewData();
+ nPPTX = pData->GetPPTX();
+ nPPTY = pData->GetPPTY();
+ aZoomX = pData->GetZoomX();
+ aZoomY = pData->GetZoomY();
+ }
+ else
+ {
+ // Zoom auf 100 lassen
+ nPPTX = ScGlobal::nScreenPPTX;
+ nPPTY = ScGlobal::nScreenPPTY;
+ }
+
+ BOOL bFormula = FALSE; //! merken
+
+ for (SCTAB nTab=nStartZ; nTab<=nEndZ; nTab++)
+ {
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( nTab );
+ aDestMark.SetMarkArea( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
+ aDestMark.MarkToMulti();
+
+ // wie SC_SIZE_VISOPT
+ SCROW nLastRow = -1;
+ for (SCROW nRow=nStartY; nRow<=nEndY; nRow++)
+ {
+ BYTE nOld = pDoc->GetRowFlags(nRow,nTab);
+ bool bHidden = pDoc->RowHidden(nRow, nTab, nLastRow);
+ if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
+ pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
+ }
+ pDoc->SetOptimalHeight( nStartY, nEndY, nTab, 0, &aVirtDev,
+ nPPTX, nPPTY, aZoomX, aZoomY, FALSE );
+
+ SCCOL nLastCol = -1;
+ for (SCCOL nCol=nStartX; nCol<=nEndX; nCol++)
+ if (!pDoc->ColHidden(nCol, nTab, nLastCol))
+ {
+ USHORT nThisSize = STD_EXTRA_WIDTH + pDoc->GetOptimalColWidth( nCol, nTab,
+ &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula,
+ &aDestMark );
+ pDoc->SetColWidth( nCol, nTab, nThisSize );
+ pDoc->ShowCol( nCol, nTab, TRUE );
+ }
+ }
+
+ pDocShell->PostPaint( 0, 0, nStartZ,
+ MAXCOL, MAXROW, nEndZ,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP, SC_PF_LINES);
+ }
+ else
+ pDocShell->PostPaint( aBlockRange, PAINT_GRID, SC_PF_LINES );
+
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoAutoFormat::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->AutoFormat( nFormatNo, TRUE );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoAutoFormat::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoReplace
+//
+// Ersetzen
+
+//----------------------------------------------------------------------------
+
+ScUndoReplace::ScUndoReplace( ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
+ const String& rNewUndoStr, ScDocument* pNewUndoDoc,
+ const SvxSearchItem* pItem )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ aCursorPos ( nCurX, nCurY, nCurZ ),
+ aMarkData ( rMark ),
+ aUndoStr ( rNewUndoStr ),
+ pUndoDoc ( pNewUndoDoc )
+{
+ pSearchItem = new SvxSearchItem( *pItem );
+ SetChangeTrack();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoReplace::~ScUndoReplace()
+{
+ delete pUndoDoc;
+ delete pSearchItem;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoReplace::SetChangeTrack()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ if ( pUndoDoc )
+ { //! im UndoDoc stehen nur die geaenderten Zellen,
+ // deswegen per Iterator moeglich
+ pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ }
+ else
+ {
+ nStartChangeAction = pChangeTrack->GetActionMax() + 1;
+ ScChangeActionContent* pContent = new ScChangeActionContent(
+ ScRange( aCursorPos) );
+ pContent->SetOldValue( aUndoStr, pDoc );
+ pContent->SetNewValue( pDoc->GetCell( aCursorPos ), pDoc );
+ pChangeTrack->Append( pContent );
+ nEndChangeAction = pChangeTrack->GetActionMax();
+ }
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoReplace::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_REPLACE ); // "Ersetzen"
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoReplace::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ShowTable( aCursorPos.Tab() );
+
+ if (pUndoDoc) // nur bei ReplaceAll !!
+ {
+ DBG_ASSERT(pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL,
+ "ScUndoReplace:: Falscher Modus");
+
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+//! markierte Tabellen
+//! Bereich merken ?
+
+ // Undo-Dokument hat keine Zeilen-/Spalten-Infos, also mit bColRowFlags = FALSE
+ // kopieren, um Outline-Gruppen nicht kaputtzumachen.
+
+ USHORT nUndoFlags = (pSearchItem->GetPattern()) ? IDF_ATTRIB : IDF_CONTENTS;
+ pUndoDoc->CopyToDocument( 0, 0, 0,
+ MAXCOL, MAXROW, MAXTAB,
+ nUndoFlags, FALSE, pDoc, NULL, FALSE ); // ohne Row-Flags
+ pDocShell->PostPaintGridAll();
+ }
+ else if (pSearchItem->GetPattern() &&
+ pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE)
+ {
+ String aTempStr = pSearchItem->GetSearchString(); // vertauschen
+ pSearchItem->SetSearchString(pSearchItem->GetReplaceString());
+ pSearchItem->SetReplaceString(aTempStr);
+ pDoc->ReplaceStyle( *pSearchItem,
+ aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(),
+ aMarkData, TRUE);
+ pSearchItem->SetReplaceString(pSearchItem->GetSearchString());
+ pSearchItem->SetSearchString(aTempStr);
+ if (pViewShell)
+ pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
+ SC_FOLLOW_JUMP, FALSE, FALSE );
+ pDocShell->PostPaintGridAll();
+ }
+ else if (pSearchItem->GetCellType() == SVX_SEARCHIN_NOTE)
+ {
+ ScPostIt* pNote = pDoc->GetNote( aCursorPos );
+ DBG_ASSERT( pNote, "ScUndoReplace::Undo - cell does not contain a note" );
+ if (pNote)
+ pNote->SetText( aCursorPos, aUndoStr );
+ if (pViewShell)
+ pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
+ SC_FOLLOW_JUMP, FALSE, FALSE );
+ }
+ else
+ {
+ // #78889# aUndoStr may contain line breaks
+ if ( aUndoStr.Search('\n') != STRING_NOTFOUND )
+ pDoc->PutCell( aCursorPos, new ScEditCell( aUndoStr, pDoc ) );
+ else
+ pDoc->SetString( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aUndoStr );
+ if (pViewShell)
+ pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
+ SC_FOLLOW_JUMP, FALSE, FALSE );
+ pDocShell->PostPaintGridAll();
+ }
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoReplace::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ pViewShell->MoveCursorAbs( aCursorPos.Col(), aCursorPos.Row(),
+ SC_FOLLOW_JUMP, FALSE, FALSE );
+ if (pUndoDoc)
+ {
+ if (pViewShell)
+ {
+ pViewShell->SetMarkData( aMarkData );
+
+ pViewShell->SearchAndReplace( pSearchItem, FALSE, TRUE );
+ }
+ }
+ else if (pSearchItem->GetPattern() &&
+ pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE)
+ {
+ pDoc->ReplaceStyle( *pSearchItem,
+ aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(),
+ aMarkData, TRUE);
+ pDocShell->PostPaintGridAll();
+ }
+ else
+ if (pViewShell)
+ pViewShell->SearchAndReplace( pSearchItem, FALSE, TRUE );
+
+ SetChangeTrack();
+
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoReplace::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->SearchAndReplace( pSearchItem, TRUE, FALSE );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoReplace::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//============================================================================
+// class ScUndoTabOp
+//
+// Mehrfachoperation (nur einfache Bloecke)
+
+//----------------------------------------------------------------------------
+
+ScUndoTabOp::ScUndoTabOp( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ, ScDocument* pNewUndoDoc,
+ const ScRefAddress& rFormulaCell,
+ const ScRefAddress& rFormulaEnd,
+ const ScRefAddress& rRowCell,
+ const ScRefAddress& rColCell,
+ BYTE nMd )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ aRange ( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ),
+ pUndoDoc ( pNewUndoDoc ),
+ theFormulaCell ( rFormulaCell ),
+ theFormulaEnd ( rFormulaEnd ),
+ theRowCell ( rRowCell ),
+ theColCell ( rColCell ),
+ nMode ( nMd )
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoTabOp::~ScUndoTabOp()
+{
+ delete pUndoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoTabOp::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_TABOP ); // "Mehrfachoperation"
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoTabOp::Undo()
+{
+ BeginUndo();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aRange );
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aRange );
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->DeleteAreaTab( aRange,IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->CopyToDocument( aRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ pDocShell->PostPaint( aRange, PAINT_GRID, nExtFlags );
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoTabOp::Redo()
+{
+ BeginRedo();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aRange );
+
+ ScTabOpParam aParam( theFormulaCell, theFormulaEnd,
+ theRowCell, theColCell,
+ nMode );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->TabOp( aParam, FALSE);
+
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoTabOp::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoTabOp::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//============================================================================
+// class ScUndoConversion
+//
+// Spelling
+
+//----------------------------------------------------------------------------
+
+ScUndoConversion::ScUndoConversion(
+ ScDocShell* pNewDocShell, const ScMarkData& rMark,
+ SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocument* pNewUndoDoc,
+ SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocument* pNewRedoDoc,
+ const ScConversionParam& rConvParam ) :
+ ScSimpleUndo( pNewDocShell ),
+ aMarkData( rMark ),
+ aCursorPos( nCurX, nCurY, nCurZ ),
+ pUndoDoc( pNewUndoDoc ),
+ aNewCursorPos( nNewX, nNewY, nNewZ ),
+ pRedoDoc( pNewRedoDoc ),
+ maConvParam( rConvParam )
+{
+ SetChangeTrack();
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoConversion::~ScUndoConversion()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoConversion::SetChangeTrack()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ if ( pUndoDoc )
+ pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ else
+ {
+ DBG_ERROR( "ScUndoConversion::SetChangeTrack: kein UndoDoc" );
+ nStartChangeAction = nEndChangeAction = 0;
+ }
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+//----------------------------------------------------------------------------
+
+String ScUndoConversion::GetComment() const
+{
+ String aText;
+ switch( maConvParam.GetType() )
+ {
+ case SC_CONVERSION_SPELLCHECK: aText = ScGlobal::GetRscString( STR_UNDO_SPELLING ); break;
+ case SC_CONVERSION_HANGULHANJA: aText = ScGlobal::GetRscString( STR_UNDO_HANGULHANJA ); break;
+ case SC_CONVERSION_CHINESE_TRANSL: aText = ScGlobal::GetRscString( STR_UNDO_CHINESE_TRANSLATION ); break;
+ default: DBG_ERRORFILE( "ScUndoConversion::GetComment - unknown conversion type" );
+ }
+ return aText;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoConversion::DoChange( ScDocument* pRefDoc, const ScAddress& rCursorPos )
+{
+ if (pRefDoc)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ShowTable( rCursorPos.Tab() );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ // Undo/Redo-doc has only selected tables
+
+ BOOL bMulti = aMarkData.IsMultiMarked();
+ pRefDoc->CopyToDocument( 0, 0, 0,
+ MAXCOL, MAXROW, nTabCount-1,
+ IDF_CONTENTS, bMulti, pDoc, &aMarkData );
+ pDocShell->PostPaintGridAll();
+ }
+ else
+ {
+ DBG_ERROR("Kein Un-/RedoDoc bei Un-/RedoSpelling");
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoConversion::Undo()
+{
+ BeginUndo();
+ DoChange( pUndoDoc, aCursorPos );
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoConversion::Redo()
+{
+ BeginRedo();
+ DoChange( pRedoDoc, aNewCursorPos );
+ SetChangeTrack();
+ EndRedo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoConversion::Repeat( SfxRepeatTarget& rTarget )
+{
+ if( rTarget.ISA( ScTabViewTarget ) )
+ ((ScTabViewTarget&)rTarget).GetViewShell()->DoSheetConversion( maConvParam, TRUE );
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScUndoConversion::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return rTarget.ISA( ScTabViewTarget );
+}
+
+
+//============================================================================
+// class ScUndoRefConversion
+//
+// cell reference conversion
+
+//----------------------------------------------------------------------------
+
+ScUndoRefConversion::ScUndoRefConversion( ScDocShell* pNewDocShell,
+ const ScRange& aMarkRange, const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc, BOOL bNewMulti, USHORT nNewFlag) :
+ScSimpleUndo( pNewDocShell ),
+aMarkData ( rMark ),
+pUndoDoc ( pNewUndoDoc ),
+pRedoDoc ( pNewRedoDoc ),
+aRange ( aMarkRange ),
+bMulti ( bNewMulti ),
+nFlags ( nNewFlag )
+{
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoRefConversion::~ScUndoRefConversion()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+}
+
+String __EXPORT ScUndoRefConversion::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
+}
+
+void ScUndoRefConversion::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack && (nFlags & IDF_FORMULA) )
+ pChangeTrack->AppendContentsIfInRefDoc( pUndoDoc,
+ nStartChangeAction, nEndChangeAction );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void ScUndoRefConversion::DoChange( ScDocument* pRefDoc)
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ShowTable(aRange);
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ ScRange aCopyRange = aRange;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pRefDoc->CopyToDocument( aCopyRange, nFlags, bMulti, pDoc, &aMarkData );
+ pDocShell->PostPaint( aRange, PAINT_GRID);
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+void __EXPORT ScUndoRefConversion::Undo()
+{
+ BeginUndo();
+ if (pUndoDoc)
+ DoChange(pUndoDoc);
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ EndUndo();
+}
+
+void __EXPORT ScUndoRefConversion::Redo()
+{
+ BeginRedo();
+ if (pRedoDoc)
+ DoChange(pRedoDoc);
+ SetChangeTrack();
+ EndRedo();
+}
+
+void __EXPORT ScUndoRefConversion::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->DoRefConversion();
+}
+
+BOOL __EXPORT ScUndoRefConversion::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+//============================================================================
+// class ScUndoRefreshLink
+//
+// Link aktualisieren / aendern
+
+//----------------------------------------------------------------------------
+
+ScUndoRefreshLink::ScUndoRefreshLink( ScDocShell* pNewDocShell,
+ ScDocument* pNewUndoDoc )
+ //
+ : ScSimpleUndo( pNewDocShell ),
+ //
+ pUndoDoc( pNewUndoDoc ),
+ pRedoDoc( NULL )
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoRefreshLink::~ScUndoRefreshLink()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoRefreshLink::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_UPDATELINK );
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoRefreshLink::Undo()
+{
+ BeginUndo();
+
+ BOOL bMakeRedo = !pRedoDoc;
+ if (bMakeRedo)
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+
+ BOOL bFirst = TRUE;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nCount; nTab++)
+ if (pUndoDoc->HasTable(nTab))
+ {
+ ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
+ if (bMakeRedo)
+ {
+ if (bFirst)
+ pRedoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ else
+ pRedoDoc->AddUndoTab( nTab, nTab, TRUE, TRUE );
+ bFirst = FALSE;
+ pDoc->CopyToDocument(aRange, IDF_ALL, FALSE, pRedoDoc);
+// pRedoDoc->TransferDrawPage( pDoc, nTab, nTab );
+ pRedoDoc->SetLink( nTab,
+ pDoc->GetLinkMode(nTab),
+ pDoc->GetLinkDoc(nTab),
+ pDoc->GetLinkFlt(nTab),
+ pDoc->GetLinkOpt(nTab),
+ pDoc->GetLinkTab(nTab),
+ pDoc->GetLinkRefreshDelay(nTab) );
+ }
+
+ pDoc->DeleteAreaTab( aRange,IDF_ALL );
+ pUndoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc );
+// pDoc->TransferDrawPage( pUndoDoc, nTab, nTab );
+ pDoc->SetLink( nTab, pUndoDoc->GetLinkMode(nTab), pUndoDoc->GetLinkDoc(nTab),
+ pUndoDoc->GetLinkFlt(nTab), pUndoDoc->GetLinkOpt(nTab),
+ pUndoDoc->GetLinkTab(nTab),
+ pUndoDoc->GetLinkRefreshDelay(nTab) );
+ }
+
+ pDocShell->PostPaintGridAll();
+
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoRefreshLink::Redo()
+{
+ DBG_ASSERT(pRedoDoc, "Kein RedoDoc bei ScUndoRefreshLink::Redo");
+
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nCount; nTab++)
+ if (pRedoDoc->HasTable(nTab))
+ {
+ ScRange aRange(0,0,nTab,MAXCOL,MAXROW,nTab);
+
+ pDoc->DeleteAreaTab( aRange, IDF_ALL );
+ pRedoDoc->CopyToDocument( aRange, IDF_ALL, FALSE, pDoc );
+// pDoc->TransferDrawPage( pRedoDoc, nTab, nTab );
+ pDoc->SetLink( nTab,
+ pRedoDoc->GetLinkMode(nTab),
+ pRedoDoc->GetLinkDoc(nTab),
+ pRedoDoc->GetLinkFlt(nTab),
+ pRedoDoc->GetLinkOpt(nTab),
+ pRedoDoc->GetLinkTab(nTab),
+ pRedoDoc->GetLinkRefreshDelay(nTab) );
+ }
+
+ pDocShell->PostPaintGridAll();
+
+ EndUndo();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoRefreshLink::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoRefreshLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//----------------------------------------------------------------------------
+
+ScAreaLink* lcl_FindAreaLink( sfx2::LinkManager* pLinkManager, const String& rDoc,
+ const String& rFlt, const String& rOpt,
+ const String& rSrc, const ScRange& rDest )
+{
+ const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
+ USHORT nCount = pLinkManager->GetLinks().Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if (pBase->ISA(ScAreaLink))
+ if ( ((ScAreaLink*)pBase)->IsEqual( rDoc, rFlt, rOpt, rSrc, rDest ) )
+ return (ScAreaLink*)pBase;
+ }
+
+ DBG_ERROR("ScAreaLink nicht gefunden");
+ return NULL;
+}
+
+
+//============================================================================
+// class ScUndoInsertAreaLink
+//
+// Bereichs-Verknuepfung einfuegen
+
+//----------------------------------------------------------------------------
+
+ScUndoInsertAreaLink::ScUndoInsertAreaLink( ScDocShell* pShell,
+ const String& rDoc,
+ const String& rFlt, const String& rOpt,
+ const String& rArea, const ScRange& rDestRange,
+ ULONG nRefresh )
+ //
+ : ScSimpleUndo ( pShell ),
+ //
+ aDocName ( rDoc ),
+ aFltName ( rFlt ),
+ aOptions ( rOpt ),
+ aAreaName ( rArea ),
+ aRange ( rDestRange ),
+ nRefreshDelay ( nRefresh )
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoInsertAreaLink::~ScUndoInsertAreaLink()
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoInsertAreaLink::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_INSERTAREALINK );
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoInsertAreaLink::Undo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+
+ ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aDocName, aFltName, aOptions,
+ aAreaName, aRange );
+ if (pLink)
+ pLinkManager->Remove( pLink );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoInsertAreaLink::Redo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+
+ ScAreaLink* pLink = new ScAreaLink( pDocShell, aDocName, aFltName, aOptions,
+ aAreaName, aRange.aStart, nRefreshDelay );
+ pLink->SetInCreate( TRUE );
+ pLink->SetDestArea( aRange );
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName, &aAreaName );
+ pLink->Update();
+ pLink->SetInCreate( FALSE );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoInsertAreaLink::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ //! ....
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoInsertAreaLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//============================================================================
+// class ScUndoRemoveAreaLink
+//
+// Bereichs-Verknuepfung loeschen
+
+//----------------------------------------------------------------------------
+
+ScUndoRemoveAreaLink::ScUndoRemoveAreaLink( ScDocShell* pShell,
+ const String& rDoc, const String& rFlt, const String& rOpt,
+ const String& rArea, const ScRange& rDestRange,
+ ULONG nRefresh )
+ //
+ : ScSimpleUndo ( pShell ),
+ //
+ aDocName ( rDoc ),
+ aFltName ( rFlt ),
+ aOptions ( rOpt ),
+ aAreaName ( rArea ),
+ aRange ( rDestRange ),
+ nRefreshDelay ( nRefresh )
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoRemoveAreaLink::~ScUndoRemoveAreaLink()
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoRemoveAreaLink::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_REMOVELINK ); //! eigener Text ??
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoRemoveAreaLink::Undo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+
+ ScAreaLink* pLink = new ScAreaLink( pDocShell, aDocName, aFltName, aOptions,
+ aAreaName, aRange.aStart, nRefreshDelay );
+ pLink->SetInCreate( TRUE );
+ pLink->SetDestArea( aRange );
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aDocName, &aFltName, &aAreaName );
+ pLink->Update();
+ pLink->SetInCreate( FALSE );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoRemoveAreaLink::Redo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+
+ ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aDocName, aFltName, aOptions,
+ aAreaName, aRange );
+ if (pLink)
+ pLinkManager->Remove( pLink );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoRemoveAreaLink::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoRemoveAreaLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//============================================================================
+// class ScUndoUpdateAreaLink
+//
+// Bereichs-Verknuepfung aktualisieren
+
+//----------------------------------------------------------------------------
+
+ScUndoUpdateAreaLink::ScUndoUpdateAreaLink( ScDocShell* pShell,
+ const String& rOldD, const String& rOldF, const String& rOldO,
+ const String& rOldA, const ScRange& rOldR, ULONG nOldRD,
+ const String& rNewD, const String& rNewF, const String& rNewO,
+ const String& rNewA, const ScRange& rNewR, ULONG nNewRD,
+ ScDocument* pUndo, ScDocument* pRedo, BOOL bDoInsert )
+ //
+ : ScSimpleUndo( pShell ),
+ //
+ aOldDoc ( rOldD ),
+ aOldFlt ( rOldF ),
+ aOldOpt ( rOldO ),
+ aOldArea ( rOldA ),
+ aOldRange ( rOldR ),
+ aNewDoc ( rNewD ),
+ aNewFlt ( rNewF ),
+ aNewOpt ( rNewO ),
+ aNewArea ( rNewA ),
+ aNewRange ( rNewR ),
+ pUndoDoc ( pUndo ),
+ pRedoDoc ( pRedo ),
+ nOldRefresh ( nOldRD ),
+ nNewRefresh ( nNewRD ),
+ bWithInsert ( bDoInsert )
+{
+ DBG_ASSERT( aOldRange.aStart == aNewRange.aStart, "AreaLink verschoben ?" );
+}
+
+
+//----------------------------------------------------------------------------
+
+__EXPORT ScUndoUpdateAreaLink::~ScUndoUpdateAreaLink()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+}
+
+
+//----------------------------------------------------------------------------
+
+String __EXPORT ScUndoUpdateAreaLink::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_UPDATELINK ); //! eigener Text ??
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScUndoUpdateAreaLink::DoChange( const BOOL bUndo ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ SCCOL nEndX = Max( aOldRange.aEnd.Col(), aNewRange.aEnd.Col() );
+ SCROW nEndY = Max( aOldRange.aEnd.Row(), aNewRange.aEnd.Row() );
+ SCTAB nEndZ = Max( aOldRange.aEnd.Tab(), aNewRange.aEnd.Tab() ); //?
+
+ if ( bUndo )
+ {
+ if ( bWithInsert )
+ {
+ pDoc->FitBlock( aNewRange, aOldRange );
+ pDoc->DeleteAreaTab( aOldRange, IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->UndoToDocument( aOldRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ }
+ else
+ {
+ ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
+ pDoc->DeleteAreaTab( aCopyRange, IDF_ALL & ~IDF_NOTE );
+ pUndoDoc->CopyToDocument( aCopyRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ }
+ }
+ else
+ {
+ if ( bWithInsert )
+ {
+ pDoc->FitBlock( aOldRange, aNewRange );
+ pDoc->DeleteAreaTab( aNewRange, IDF_ALL & ~IDF_NOTE );
+ pRedoDoc->CopyToDocument( aNewRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ }
+ else
+ {
+ ScRange aCopyRange( aOldRange.aStart, ScAddress(nEndX,nEndY,nEndZ) );
+ pDoc->DeleteAreaTab( aCopyRange, IDF_ALL & ~IDF_NOTE );
+ pRedoDoc->CopyToDocument( aCopyRange, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ }
+ }
+
+ ScRange aWorkRange( aNewRange.aStart, ScAddress( nEndX, nEndY, nEndZ ) );
+ pDoc->ExtendMerge( aWorkRange, TRUE );
+
+ // Paint
+
+ if ( aNewRange.aEnd.Col() != aOldRange.aEnd.Col() )
+ aWorkRange.aEnd.SetCol(MAXCOL);
+ if ( aNewRange.aEnd.Row() != aOldRange.aEnd.Row() )
+ aWorkRange.aEnd.SetRow(MAXROW);
+
+ if ( !pDocShell->AdjustRowHeight( aWorkRange.aStart.Row(), aWorkRange.aEnd.Row(), aWorkRange.aStart.Tab() ) )
+ pDocShell->PostPaint( aWorkRange, PAINT_GRID );
+
+ pDocShell->PostDataChanged();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoUpdateAreaLink::Undo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aNewDoc, aNewFlt, aNewOpt,
+ aNewArea, aNewRange );
+ if (pLink)
+ {
+ pLink->SetSource( aOldDoc, aOldFlt, aOldOpt, aOldArea ); // alte Werte im Link
+ pLink->SetDestArea( aOldRange );
+ pLink->SetRefreshDelay( nOldRefresh );
+ }
+
+ DoChange(TRUE);
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoUpdateAreaLink::Redo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ ScAreaLink* pLink = lcl_FindAreaLink( pLinkManager, aOldDoc, aOldFlt, aOldOpt,
+ aOldArea, aOldRange );
+ if (pLink)
+ {
+ pLink->SetSource( aNewDoc, aNewFlt, aNewOpt, aNewArea ); // neue Werte im Link
+ pLink->SetDestArea( aNewRange );
+ pLink->SetRefreshDelay( nNewRefresh );
+ }
+
+ DoChange(FALSE);
+}
+
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ScUndoUpdateAreaLink::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL __EXPORT ScUndoUpdateAreaLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
new file mode 100644
index 000000000000..0a96ee409fd3
--- /dev/null
+++ b/sc/source/ui/undo/undocell.cxx
@@ -0,0 +1,1147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <editeng/editobj.hxx>
+#include <svl/zforlist.hxx>
+#include <sfx2/app.hxx>
+
+#include "undocell.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "patattr.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "cell.hxx"
+#include "target.hxx"
+#include "undoolk.hxx"
+#include "detdata.hxx"
+#include "stlpool.hxx"
+#include "printfun.hxx"
+#include "rangenam.hxx"
+#include "chgtrack.hxx"
+#include "sc.hrc"
+#include "docuno.hxx"
+
+using ::boost::shared_ptr;
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScUndoCursorAttr, ScSimpleUndo);
+TYPEINIT1(ScUndoEnterData, ScSimpleUndo);
+TYPEINIT1(ScUndoEnterValue, ScSimpleUndo);
+TYPEINIT1(ScUndoPutCell, ScSimpleUndo);
+TYPEINIT1(ScUndoPageBreak, ScSimpleUndo);
+TYPEINIT1(ScUndoPrintZoom, ScSimpleUndo);
+TYPEINIT1(ScUndoThesaurus, ScSimpleUndo);
+TYPEINIT1(ScUndoReplaceNote, ScSimpleUndo);
+TYPEINIT1(ScUndoShowHideNote, ScSimpleUndo);
+TYPEINIT1(ScUndoDetective, ScSimpleUndo);
+TYPEINIT1(ScUndoRangeNames, ScSimpleUndo);
+
+
+// -----------------------------------------------------------------------
+//
+// Attribute auf Cursor anwenden
+//
+
+ScUndoCursorAttr::ScUndoCursorAttr( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ const ScPatternAttr* pOldPat, const ScPatternAttr* pNewPat,
+ const ScPatternAttr* pApplyPat, BOOL bAutomatic ) :
+ ScSimpleUndo( pNewDocShell ),
+ nCol( nNewCol ),
+ nRow( nNewRow ),
+ nTab( nNewTab ),
+ pOldEditData( static_cast<EditTextObject*>(NULL) ),
+ pNewEditData( static_cast<EditTextObject*>(NULL) ),
+ bIsAutomatic( bAutomatic )
+{
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ pNewPattern = (ScPatternAttr*) &pPool->Put( *pNewPat );
+ pOldPattern = (ScPatternAttr*) &pPool->Put( *pOldPat );
+ pApplyPattern = (ScPatternAttr*) &pPool->Put( *pApplyPat );
+}
+
+__EXPORT ScUndoCursorAttr::~ScUndoCursorAttr()
+{
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ pPool->Remove(*pNewPattern);
+ pPool->Remove(*pOldPattern);
+ pPool->Remove(*pApplyPattern);
+}
+
+String __EXPORT ScUndoCursorAttr::GetComment() const
+{
+ //! eigener Text fuer automatische Attributierung
+
+ USHORT nId = STR_UNDO_CURSORATTR; // "Attribute"
+ return ScGlobal::GetRscString( nId );
+}
+
+void ScUndoCursorAttr::SetEditData( EditTextObject* pOld, EditTextObject* pNew )
+{
+ pOldEditData.reset(pOld);
+ pNewEditData.reset(pNew);
+}
+
+void ScUndoCursorAttr::DoChange( const ScPatternAttr* pWhichPattern, const shared_ptr<EditTextObject>& pEditData ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->SetPattern( nCol, nRow, nTab, *pWhichPattern, TRUE );
+
+ ScBaseCell* pCell;
+ pDoc->GetCell(nCol, nRow, nTab, pCell);
+ if (pCell && pCell->GetCellType() == CELLTYPE_EDIT && pEditData.get())
+ static_cast<ScEditCell*>(pCell)->SetData(pEditData.get(), NULL);
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->SetTabNo( nTab );
+ pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE );
+ pViewShell->AdjustBlockHeight();
+ }
+
+ const SfxItemSet& rApplySet = pApplyPattern->GetItemSet();
+ BOOL bPaintExt = ( rApplySet.GetItemState( ATTR_SHADOW, TRUE ) != SFX_ITEM_DEFAULT ||
+ rApplySet.GetItemState( ATTR_CONDITIONAL, TRUE ) != SFX_ITEM_DEFAULT );
+ BOOL bPaintRows = ( rApplySet.GetItemState( ATTR_HOR_JUSTIFY, TRUE ) != SFX_ITEM_DEFAULT );
+
+ USHORT nFlags = SC_PF_TESTMERGE;
+ if (bPaintExt)
+ nFlags |= SC_PF_LINES;
+ if (bPaintRows)
+ nFlags |= SC_PF_WHOLEROWS;
+ pDocShell->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, nFlags );
+}
+
+void __EXPORT ScUndoCursorAttr::Undo()
+{
+ BeginUndo();
+ DoChange(pOldPattern, pOldEditData);
+
+ if ( bIsAutomatic )
+ {
+ // wenn automatische Formatierung rueckgaengig gemacht wird,
+ // soll auch nicht weiter automatisch formatiert werden:
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->ForgetFormatArea();
+ }
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoCursorAttr::Redo()
+{
+ BeginRedo();
+ DoChange(pNewPattern, pNewEditData);
+ EndRedo();
+}
+
+void __EXPORT ScUndoCursorAttr::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->ApplySelectionPattern( *pApplyPattern );
+}
+
+BOOL __EXPORT ScUndoCursorAttr::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Daten eingeben
+//
+
+ScUndoEnterData::ScUndoEnterData( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ SCTAB nNewCount, SCTAB* pNewTabs, ScBaseCell** ppOldData,
+ BOOL* pHasForm, ULONG* pOldForm,
+ const String& rNewStr, EditTextObject* pObj ) :
+ ScSimpleUndo( pNewDocShell ),
+ aNewString( rNewStr ),
+ pTabs( pNewTabs ),
+ ppOldCells( ppOldData ),
+ pHasFormat( pHasForm ),
+ pOldFormats( pOldForm ),
+ pNewEditData( pObj ),
+ nCol( nNewCol ),
+ nRow( nNewRow ),
+ nTab( nNewTab ),
+ nCount( nNewCount )
+{
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoEnterData::~ScUndoEnterData()
+{
+ for (USHORT i=0; i<nCount; i++)
+ if (ppOldCells[i])
+ ppOldCells[i]->Delete();
+ delete[] ppOldCells;
+
+ delete[] pHasFormat;
+ delete[] pOldFormats;
+ delete[] pTabs;
+
+ delete pNewEditData;
+}
+
+String __EXPORT ScUndoEnterData::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
+}
+
+void ScUndoEnterData::DoChange() const
+{
+ // Zeilenhoehe anpassen
+ //! nur wenn noetig (alte oder neue EditZelle, oder Attribute) ??
+ for (USHORT i=0; i<nCount; i++)
+ pDocShell->AdjustRowHeight( nRow, nRow, pTabs[i] );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->SetTabNo( nTab );
+ pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE );
+ }
+
+ pDocShell->PostDataChanged();
+}
+
+void ScUndoEnterData::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ nEndChangeAction = pChangeTrack->GetActionMax() + 1;
+ ScAddress aPos( nCol, nRow, nTab );
+ for (USHORT i=0; i<nCount; i++)
+ {
+ aPos.SetTab( pTabs[i] );
+ ULONG nFormat = 0;
+ if ( pHasFormat && pOldFormats )
+ {
+ if ( pHasFormat[i] )
+ nFormat = pOldFormats[i];
+ }
+ pChangeTrack->AppendContent( aPos, ppOldCells[i], nFormat );
+ }
+ if ( nEndChangeAction > pChangeTrack->GetActionMax() )
+ nEndChangeAction = 0; // nichts appended
+ }
+ else
+ nEndChangeAction = 0;
+}
+
+void __EXPORT ScUndoEnterData::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScBaseCell* pNewCell = ppOldCells[i] ? ppOldCells[i]->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
+ pDoc->PutCell( nCol, nRow, pTabs[i], pNewCell );
+
+ if (pHasFormat && pOldFormats)
+ {
+ if ( pHasFormat[i] )
+ pDoc->ApplyAttr( nCol, nRow, pTabs[i],
+ SfxUInt32Item( ATTR_VALUE_FORMAT, pOldFormats[i] ) );
+ else
+ {
+ ScPatternAttr aPattern( *pDoc->GetPattern( nCol, nRow, pTabs[i] ) );
+ aPattern.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
+ pDoc->SetPattern( nCol, nRow, pTabs[i], aPattern, TRUE );
+ }
+ }
+ pDocShell->PostPaintCell( nCol, nRow, pTabs[i] );
+ }
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack && nEndChangeAction >= sal::static_int_cast<ULONG>(nCount) )
+ pChangeTrack->Undo( nEndChangeAction - nCount + 1, nEndChangeAction );
+
+ DoChange();
+ EndUndo();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ aChangeRanges.Append( ScRange( nCol, nRow, pTabs[i] ) );
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+}
+
+void __EXPORT ScUndoEnterData::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if (pNewEditData)
+ pDoc->PutCell( nCol, nRow, pTabs[i], new ScEditCell( pNewEditData,
+ pDoc, NULL ) );
+ else
+ pDoc->SetString( nCol, nRow, pTabs[i], aNewString );
+ pDocShell->PostPaintCell( nCol, nRow, pTabs[i] );
+ }
+
+ SetChangeTrack();
+
+ DoChange();
+ EndRedo();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocShell->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ aChangeRanges.Append( ScRange( nCol, nRow, pTabs[i] ) );
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+}
+
+void __EXPORT ScUndoEnterData::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ String aTemp = aNewString;
+ ((ScTabViewTarget&)rTarget).GetViewShell()->EnterDataAtCursor( aTemp );
+ }
+}
+
+BOOL __EXPORT ScUndoEnterData::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Wert aendern
+//
+
+ScUndoEnterValue::ScUndoEnterValue( ScDocShell* pNewDocShell, const ScAddress& rNewPos,
+ ScBaseCell* pUndoCell, double nVal, BOOL bHeight ) :
+ ScSimpleUndo( pNewDocShell ),
+ aPos ( rNewPos ),
+ pOldCell ( pUndoCell ),
+ nValue ( nVal ),
+ bNeedHeight ( bHeight )
+{
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoEnterValue::~ScUndoEnterValue()
+{
+ if (pOldCell)
+ pOldCell->Delete();
+}
+
+String __EXPORT ScUndoEnterValue::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
+}
+
+void ScUndoEnterValue::SetChangeTrack()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ nEndChangeAction = pChangeTrack->GetActionMax() + 1;
+ pChangeTrack->AppendContent( aPos, pOldCell );
+ if ( nEndChangeAction > pChangeTrack->GetActionMax() )
+ nEndChangeAction = 0; // nichts appended
+ }
+ else
+ nEndChangeAction = 0;
+}
+
+void __EXPORT ScUndoEnterValue::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, SC_CLONECELL_STARTLISTENING ) : 0;
+
+ pDoc->PutCell( aPos, pNewCell );
+
+ pDocShell->PostPaintCell( aPos );
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoEnterValue::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->SetValue( aPos.Col(), aPos.Row(), aPos.Tab(), nValue );
+ pDocShell->PostPaintCell( aPos );
+
+ SetChangeTrack();
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoEnterValue::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+BOOL __EXPORT ScUndoEnterValue::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Beliebige Zelle eingeben
+//
+
+ScUndoPutCell::ScUndoPutCell( ScDocShell* pNewDocShell, const ScAddress& rNewPos,
+ ScBaseCell* pUndoCell, ScBaseCell* pRedoCell, BOOL bHeight ) :
+ ScSimpleUndo( pNewDocShell ),
+ aPos ( rNewPos ),
+ pOldCell ( pUndoCell ),
+ pEnteredCell( pRedoCell ),
+ bNeedHeight ( bHeight )
+{
+ SetChangeTrack();
+}
+
+__EXPORT ScUndoPutCell::~ScUndoPutCell()
+{
+ if (pOldCell)
+ pOldCell->Delete();
+ if (pEnteredCell)
+ pEnteredCell->Delete();
+}
+
+String __EXPORT ScUndoPutCell::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_ENTERDATA ); // "Eingabe"
+}
+
+void ScUndoPutCell::SetChangeTrack()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ nEndChangeAction = pChangeTrack->GetActionMax() + 1;
+ pChangeTrack->AppendContent( aPos, pOldCell );
+ if ( nEndChangeAction > pChangeTrack->GetActionMax() )
+ nEndChangeAction = 0; // nichts appended
+ }
+ else
+ nEndChangeAction = 0;
+}
+
+void __EXPORT ScUndoPutCell::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScBaseCell* pNewCell = pOldCell ? pOldCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0;
+
+ pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell );
+
+ pDocShell->PostPaintCell( aPos );
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoPutCell::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScBaseCell* pNewCell = pEnteredCell ? pEnteredCell->CloneWithoutNote( *pDoc, aPos, SC_CLONECELL_STARTLISTENING ) : 0;
+
+ pDoc->PutCell( aPos.Col(), aPos.Row(), aPos.Tab(), pNewCell );
+
+ pDocShell->PostPaintCell( aPos );
+
+ SetChangeTrack();
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoPutCell::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+BOOL __EXPORT ScUndoPutCell::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Seitenumbrueche
+//
+
+ScUndoPageBreak::ScUndoPageBreak( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ BOOL bNewColumn, BOOL bNewInsert ) :
+ ScSimpleUndo( pNewDocShell ),
+ nCol( nNewCol ),
+ nRow( nNewRow ),
+ nTab( nNewTab ),
+ bColumn( bNewColumn ),
+ bInsert( bNewInsert )
+{
+}
+
+__EXPORT ScUndoPageBreak::~ScUndoPageBreak()
+{
+}
+
+String __EXPORT ScUndoPageBreak::GetComment() const
+{
+ //"Spaltenumbruch" | "Zeilenumbruch" "einfuegen" | "loeschen"
+ return String ( bColumn ?
+ ( bInsert ?
+ ScGlobal::GetRscString( STR_UNDO_INSCOLBREAK ) :
+ ScGlobal::GetRscString( STR_UNDO_DELCOLBREAK )
+ ) :
+ ( bInsert ?
+ ScGlobal::GetRscString( STR_UNDO_INSROWBREAK ) :
+ ScGlobal::GetRscString( STR_UNDO_DELROWBREAK )
+ ) );
+}
+
+void ScUndoPageBreak::DoChange( BOOL bInsertP ) const
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ {
+ pViewShell->SetTabNo( nTab );
+ pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE );
+
+ if (bInsertP)
+ pViewShell->InsertPageBreak(bColumn, FALSE);
+ else
+ pViewShell->DeletePageBreak(bColumn, FALSE);
+
+ pDocShell->GetDocument()->InvalidatePageBreaks(nTab);
+ }
+}
+
+void __EXPORT ScUndoPageBreak::Undo()
+{
+ BeginUndo();
+ DoChange(!bInsert);
+ EndUndo();
+}
+
+void __EXPORT ScUndoPageBreak::Redo()
+{
+ BeginRedo();
+ DoChange(bInsert);
+ EndRedo();
+}
+
+void __EXPORT ScUndoPageBreak::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+
+ if (bInsert)
+ rViewShell.InsertPageBreak(bColumn, TRUE);
+ else
+ rViewShell.DeletePageBreak(bColumn, TRUE);
+ }
+}
+
+BOOL __EXPORT ScUndoPageBreak::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// Druck-Skalierung
+//
+
+ScUndoPrintZoom::ScUndoPrintZoom( ScDocShell* pNewDocShell,
+ SCTAB nT, USHORT nOS, USHORT nOP, USHORT nNS, USHORT nNP ) :
+ ScSimpleUndo( pNewDocShell ),
+ nTab( nT ),
+ nOldScale( nOS ),
+ nOldPages( nOP ),
+ nNewScale( nNS ),
+ nNewPages( nNP )
+{
+}
+
+__EXPORT ScUndoPrintZoom::~ScUndoPrintZoom()
+{
+}
+
+String __EXPORT ScUndoPrintZoom::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_PRINTSCALE );
+}
+
+void ScUndoPrintZoom::DoChange( BOOL bUndo )
+{
+ USHORT nScale = bUndo ? nOldScale : nNewScale;
+ USHORT nPages = bUndo ? nOldPages : nNewPages;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ String aStyleName = pDoc->GetPageStyle( nTab );
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found" );
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nScale ) );
+ rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALETOPAGES, nPages ) );
+
+ ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab );
+ aPrintFunc.UpdatePages();
+ }
+}
+
+void __EXPORT ScUndoPrintZoom::Undo()
+{
+ BeginUndo();
+ DoChange(TRUE);
+ EndUndo();
+}
+
+void __EXPORT ScUndoPrintZoom::Redo()
+{
+ BeginRedo();
+ DoChange(FALSE);
+ EndRedo();
+}
+
+void __EXPORT ScUndoPrintZoom::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+ ScViewData* pViewData = rViewShell.GetViewData();
+ pViewData->GetDocShell()->SetPrintZoom( pViewData->GetTabNo(), nNewScale, nNewPages );
+ }
+}
+
+BOOL __EXPORT ScUndoPrintZoom::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Thesaurus
+//
+
+ScUndoThesaurus::ScUndoThesaurus( ScDocShell* pNewDocShell,
+ SCCOL nNewCol, SCROW nNewRow, SCTAB nNewTab,
+ const String& rNewUndoStr, const EditTextObject* pUndoTObj,
+ const String& rNewRedoStr, const EditTextObject* pRedoTObj) :
+ ScSimpleUndo( pNewDocShell ),
+ nCol( nNewCol ),
+ nRow( nNewRow ),
+ nTab( nNewTab ),
+ aUndoStr( rNewUndoStr ),
+ aRedoStr( rNewRedoStr )
+{
+ pUndoTObject = (pUndoTObj) ? pUndoTObj->Clone() : NULL;
+ pRedoTObject = (pRedoTObj) ? pRedoTObj->Clone() : NULL;
+
+ ScBaseCell* pOldCell;
+ if ( pUndoTObject )
+ pOldCell = new ScEditCell( pUndoTObject, pDocShell->GetDocument(), NULL );
+ else
+ pOldCell = new ScStringCell( aUndoStr );
+ SetChangeTrack( pOldCell );
+ pOldCell->Delete();
+}
+
+__EXPORT ScUndoThesaurus::~ScUndoThesaurus()
+{
+ delete pUndoTObject;
+ delete pRedoTObject;
+}
+
+String __EXPORT ScUndoThesaurus::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_THESAURUS ); // "Thesaurus"
+}
+
+void ScUndoThesaurus::SetChangeTrack( ScBaseCell* pOldCell )
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ nEndChangeAction = pChangeTrack->GetActionMax() + 1;
+ pChangeTrack->AppendContent( ScAddress( nCol, nRow, nTab ), pOldCell );
+ if ( nEndChangeAction > pChangeTrack->GetActionMax() )
+ nEndChangeAction = 0; // nichts appended
+ }
+ else
+ nEndChangeAction = 0;
+}
+
+void __EXPORT ScUndoThesaurus::DoChange( BOOL bUndo, const String& rStr,
+ const EditTextObject* pTObj )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->SetTabNo( nTab );
+ pViewShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_JUMP, FALSE, FALSE );
+ }
+
+ if (pTObj)
+ {
+ ScBaseCell* pCell;
+ pDoc->GetCell( nCol, nRow, nTab, pCell );
+ if (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_EDIT )
+ {
+ ScEditCell* pNewCell = new ScEditCell( pTObj, pDoc, NULL );
+ pDoc->PutCell( nCol, nRow, nTab, pNewCell );
+ if ( !bUndo )
+ SetChangeTrack( pCell );
+ }
+ else
+ {
+ DBG_ERROR("Nicht CELLTYPE_EDIT bei Un/RedoThesaurus");
+ }
+ }
+ }
+ else
+ {
+ ScBaseCell* pCell = NULL;
+ if ( !bUndo )
+ pDoc->GetCell( nCol, nRow, nTab, pCell );
+ pDoc->SetString( nCol, nRow, nTab, rStr );
+ if ( !bUndo )
+ SetChangeTrack( pCell );
+ }
+
+ pDocShell->PostPaintCell( nCol, nRow, nTab );
+}
+
+void __EXPORT ScUndoThesaurus::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE, aUndoStr, pUndoTObject );
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+ EndUndo();
+}
+
+void __EXPORT ScUndoThesaurus::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE, aRedoStr, pRedoTObject );
+ EndRedo();
+}
+
+void __EXPORT ScUndoThesaurus::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->DoThesaurus( TRUE );
+}
+
+BOOL __EXPORT ScUndoThesaurus::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// ============================================================================
+
+ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
+ const ScNoteData& rNoteData, bool bInsert, SdrUndoAction* pDrawUndo ) :
+ ScSimpleUndo( &rDocShell ),
+ maPos( rPos ),
+ mpDrawUndo( pDrawUndo )
+{
+ DBG_ASSERT( rNoteData.mpCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note caption" );
+ (bInsert ? maNewData : maOldData) = rNoteData;
+}
+
+ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rPos,
+ const ScNoteData& rOldData, const ScNoteData& rNewData, SdrUndoAction* pDrawUndo ) :
+ ScSimpleUndo( &rDocShell ),
+ maPos( rPos ),
+ maOldData( rOldData ),
+ maNewData( rNewData ),
+ mpDrawUndo( pDrawUndo )
+{
+ DBG_ASSERT( maOldData.mpCaption || maNewData.mpCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
+ DBG_ASSERT( !maOldData.mxInitData.get() && !maNewData.mxInitData.get(), "ScUndoReplaceNote::ScUndoReplaceNote - unexpected unitialized note" );
+}
+
+ScUndoReplaceNote::~ScUndoReplaceNote()
+{
+ DeleteSdrUndoAction( mpDrawUndo );
+}
+
+void ScUndoReplaceNote::Undo()
+{
+ BeginUndo();
+ DoSdrUndoAction( mpDrawUndo, pDocShell->GetDocument() );
+ /* Undo insert -> remove new note.
+ Undo remove -> insert old note.
+ Undo replace -> remove new note, insert old note. */
+ DoRemoveNote( maNewData );
+ DoInsertNote( maOldData );
+ pDocShell->PostPaintCell( maPos );
+ EndUndo();
+}
+
+void ScUndoReplaceNote::Redo()
+{
+ BeginRedo();
+ RedoSdrUndoAction( mpDrawUndo );
+ /* Redo insert -> insert new note.
+ Redo remove -> remove old note.
+ Redo replace -> remove old note, insert new note. */
+ DoRemoveNote( maOldData );
+ DoInsertNote( maNewData );
+ pDocShell->PostPaintCell( maPos );
+ EndRedo();
+}
+
+void ScUndoReplaceNote::Repeat( SfxRepeatTarget& /*rTarget*/ )
+{
+}
+
+BOOL ScUndoReplaceNote::CanRepeat( SfxRepeatTarget& /*rTarget*/ ) const
+{
+ return FALSE;
+}
+
+String ScUndoReplaceNote::GetComment() const
+{
+ return ScGlobal::GetRscString( maNewData.mpCaption ?
+ (maOldData.mpCaption ? STR_UNDO_EDITNOTE : STR_UNDO_INSERTNOTE) : STR_UNDO_DELETENOTE );
+}
+
+void ScUndoReplaceNote::DoInsertNote( const ScNoteData& rNoteData )
+{
+ if( rNoteData.mpCaption )
+ {
+ ScDocument& rDoc = *pDocShell->GetDocument();
+ DBG_ASSERT( !rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoInsertNote - unexpected cell note" );
+ ScPostIt* pNote = new ScPostIt( rDoc, maPos, rNoteData, false );
+ rDoc.TakeNote( maPos, pNote );
+ }
+}
+
+void ScUndoReplaceNote::DoRemoveNote( const ScNoteData& rNoteData )
+{
+ if( rNoteData.mpCaption )
+ {
+ ScDocument& rDoc = *pDocShell->GetDocument();
+ DBG_ASSERT( rDoc.GetNote( maPos ), "ScUndoReplaceNote::DoRemoveNote - missing cell note" );
+ if( ScPostIt* pNote = rDoc.ReleaseNote( maPos ) )
+ {
+ /* Forget pointer to caption object to suppress removing the
+ caption object from the drawing layer while deleting pNote
+ (removing the caption is done by a drawing undo action). */
+ pNote->ForgetCaption();
+ delete pNote;
+ }
+ }
+}
+
+// ============================================================================
+
+ScUndoShowHideNote::ScUndoShowHideNote( ScDocShell& rDocShell, const ScAddress& rPos, bool bShow ) :
+ ScSimpleUndo( &rDocShell ),
+ maPos( rPos ),
+ mbShown( bShow )
+{
+}
+
+ScUndoShowHideNote::~ScUndoShowHideNote()
+{
+}
+
+void ScUndoShowHideNote::Undo()
+{
+ BeginUndo();
+ if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( maPos ) )
+ pNote->ShowCaption( maPos, !mbShown );
+ EndUndo();
+}
+
+void ScUndoShowHideNote::Redo()
+{
+ BeginRedo();
+ if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( maPos ) )
+ pNote->ShowCaption( maPos, mbShown );
+ EndRedo();
+}
+
+void ScUndoShowHideNote::Repeat( SfxRepeatTarget& /*rTarget*/ )
+{
+}
+
+BOOL ScUndoShowHideNote::CanRepeat( SfxRepeatTarget& /*rTarget*/ ) const
+{
+ return FALSE;
+}
+
+String ScUndoShowHideNote::GetComment() const
+{
+ return ScGlobal::GetRscString( mbShown ? STR_UNDO_SHOWNOTE : STR_UNDO_HIDENOTE );
+}
+
+// ============================================================================
+
+// -----------------------------------------------------------------------
+//
+// Detektiv
+//
+
+ScUndoDetective::ScUndoDetective( ScDocShell* pNewDocShell,
+ SdrUndoAction* pDraw, const ScDetOpData* pOperation,
+ ScDetOpList* pUndoList ) :
+ ScSimpleUndo( pNewDocShell ),
+ pOldList ( pUndoList ),
+ nAction ( 0 ),
+ pDrawUndo ( pDraw )
+{
+ bIsDelete = ( pOperation == NULL );
+ if (!bIsDelete)
+ {
+ nAction = (USHORT) pOperation->GetOperation();
+ aPos = pOperation->GetPos();
+ }
+}
+
+__EXPORT ScUndoDetective::~ScUndoDetective()
+{
+ DeleteSdrUndoAction( pDrawUndo );
+ delete pOldList;
+}
+
+String __EXPORT ScUndoDetective::GetComment() const
+{
+ USHORT nId = STR_UNDO_DETDELALL;
+ if ( !bIsDelete )
+ switch ( (ScDetOpType) nAction )
+ {
+ case SCDETOP_ADDSUCC: nId = STR_UNDO_DETADDSUCC; break;
+ case SCDETOP_DELSUCC: nId = STR_UNDO_DETDELSUCC; break;
+ case SCDETOP_ADDPRED: nId = STR_UNDO_DETADDPRED; break;
+ case SCDETOP_DELPRED: nId = STR_UNDO_DETDELPRED; break;
+ case SCDETOP_ADDERROR: nId = STR_UNDO_DETADDERROR; break;
+ }
+
+ return ScGlobal::GetRscString( nId );
+}
+
+
+void __EXPORT ScUndoDetective::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ DoSdrUndoAction(pDrawUndo, pDoc);
+
+ if (bIsDelete)
+ {
+ if ( pOldList )
+ pDoc->SetDetOpList( new ScDetOpList(*pOldList) );
+ }
+ else
+ {
+ // Eintrag aus der Liste loeschen
+
+ ScDetOpList* pList = pDoc->GetDetOpList();
+ if (pList && pList->Count())
+ {
+ USHORT nPos = pList->Count() - 1;
+ ScDetOpData* pData = (*pList)[nPos];
+ if ( pData->GetOperation() == (ScDetOpType) nAction && pData->GetPos() == aPos )
+ pList->DeleteAndDestroy( nPos, 1 );
+ else
+ {
+ DBG_ERROR("Detektiv-Eintrag in der Liste nicht gefunden");
+ }
+ }
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->RecalcPPT(); //! use broadcast instead?
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoDetective::Redo()
+{
+ BeginRedo();
+
+ RedoSdrUndoAction(pDrawUndo);
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ if (bIsDelete)
+ pDoc->ClearDetectiveOperations();
+ else
+ pDoc->AddDetectiveOperation( ScDetOpData( aPos, (ScDetOpType) nAction ) );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->RecalcPPT(); //! use broadcast instead?
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoDetective::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // hammanich
+}
+
+BOOL __EXPORT ScUndoDetective::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+//
+// Benannte Bereiche
+//
+
+ScUndoRangeNames::ScUndoRangeNames( ScDocShell* pNewDocShell,
+ ScRangeName* pOld, ScRangeName* pNew ) :
+ ScSimpleUndo( pNewDocShell ),
+ pOldRanges ( pOld ),
+ pNewRanges ( pNew )
+{
+}
+
+__EXPORT ScUndoRangeNames::~ScUndoRangeNames()
+{
+ delete pOldRanges;
+ delete pNewRanges;
+}
+
+String __EXPORT ScUndoRangeNames::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_RANGENAMES );
+}
+
+void ScUndoRangeNames::DoChange( BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->CompileNameFormula( TRUE ); // CreateFormulaString
+
+ if ( bUndo )
+ pDoc->SetRangeName( new ScRangeName( *pOldRanges ) );
+ else
+ pDoc->SetRangeName( new ScRangeName( *pNewRanges ) );
+
+ pDoc->CompileNameFormula( FALSE ); // CompileFormulaString
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+}
+
+void __EXPORT ScUndoRangeNames::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+void __EXPORT ScUndoRangeNames::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+}
+
+void __EXPORT ScUndoRangeNames::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // hammanich
+}
+
+BOOL __EXPORT ScUndoRangeNames::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
new file mode 100644
index 000000000000..6dd1c57d9b4d
--- /dev/null
+++ b/sc/source/ui/undo/undodat.cxx
@@ -0,0 +1,2241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+
+#include "undodat.hxx"
+#include "undoutil.hxx"
+#include "undoolk.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "olinetab.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "pivot.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "target.hxx"
+#include "chartarr.hxx"
+#include "dbdocfun.hxx"
+#include "olinefun.hxx"
+#include "dpobject.hxx"
+#include "attrib.hxx"
+#include "hints.hxx"
+#include "sc.hrc"
+#include "chgtrack.hxx" // Amelia Wang
+#include "refundo.hxx" // Amelia Wang
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScUndoDoOutline, ScSimpleUndo);
+TYPEINIT1(ScUndoMakeOutline, ScSimpleUndo);
+TYPEINIT1(ScUndoOutlineLevel, ScSimpleUndo);
+TYPEINIT1(ScUndoOutlineBlock, ScSimpleUndo);
+TYPEINIT1(ScUndoRemoveAllOutlines, ScSimpleUndo);
+TYPEINIT1(ScUndoAutoOutline, ScSimpleUndo);
+TYPEINIT1(ScUndoSubTotals, ScDBFuncUndo);
+TYPEINIT1(ScUndoSort, ScDBFuncUndo);
+TYPEINIT1(ScUndoQuery, ScDBFuncUndo);
+TYPEINIT1(ScUndoAutoFilter, ScDBFuncUndo);
+TYPEINIT1(ScUndoDBData, ScSimpleUndo);
+TYPEINIT1(ScUndoImportData, ScSimpleUndo);
+TYPEINIT1(ScUndoRepeatDB, ScSimpleUndo);
+TYPEINIT1(ScUndoDataPilot, ScSimpleUndo);
+TYPEINIT1(ScUndoConsolidate, ScSimpleUndo);
+TYPEINIT1(ScUndoChartData, ScSimpleUndo);
+TYPEINIT1(ScUndoDataForm, SfxUndoAction); // amelia
+
+// -----------------------------------------------------------------------
+
+
+//
+// Outline-Gruppen ein- oder ausblenden
+//
+
+ScUndoDoOutline::ScUndoDoOutline( ScDocShell* pNewDocShell,
+ SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
+ ScDocument* pNewUndoDoc, BOOL bNewColumns,
+ USHORT nNewLevel, USHORT nNewEntry, BOOL bNewShow ) :
+ ScSimpleUndo( pNewDocShell ),
+ nStart( nNewStart ),
+ nEnd( nNewEnd ),
+ nTab( nNewTab ),
+ pUndoDoc( pNewUndoDoc ),
+ bColumns( bNewColumns ),
+ nLevel( nNewLevel ),
+ nEntry( nNewEntry ),
+ bShow( bNewShow )
+{
+}
+
+__EXPORT ScUndoDoOutline::~ScUndoDoOutline()
+{
+ delete pUndoDoc;
+}
+
+String __EXPORT ScUndoDoOutline::GetComment() const
+{ // Detail einblenden" "Detail ausblenden"
+ return bShow ?
+ ScGlobal::GetRscString( STR_UNDO_DOOUTLINE ) :
+ ScGlobal::GetRscString( STR_UNDO_REDOOUTLINE );
+}
+
+void __EXPORT ScUndoDoOutline::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ // inverse Funktion ausfuehren
+
+ if (bShow)
+ pViewShell->HideOutline( bColumns, nLevel, nEntry, FALSE, FALSE );
+ else
+ pViewShell->ShowOutline( bColumns, nLevel, nEntry, FALSE, FALSE );
+
+ // Original Spalten-/Zeilenstatus
+
+ if (bColumns)
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, FALSE, pDoc);
+ else
+ pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pDoc );
+
+ pViewShell->UpdateScrollBars();
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoDoOutline::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ if (bShow)
+ pViewShell->ShowOutline( bColumns, nLevel, nEntry, FALSE );
+ else
+ pViewShell->HideOutline( bColumns, nLevel, nEntry, FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoDoOutline::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoDoOutline::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // geht nicht
+}
+
+//
+// Outline-Gruppen erzeugen oder loeschen
+//
+
+ScUndoMakeOutline::ScUndoMakeOutline( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScOutlineTable* pNewUndoTab, BOOL bNewColumns, BOOL bNewMake ) :
+ ScSimpleUndo( pNewDocShell ),
+ aBlockStart( nStartX, nStartY, nStartZ ),
+ aBlockEnd( nEndX, nEndY, nEndZ ),
+ pUndoTable( pNewUndoTab ),
+ bColumns( bNewColumns ),
+ bMake( bNewMake )
+{
+}
+
+__EXPORT ScUndoMakeOutline::~ScUndoMakeOutline()
+{
+ delete pUndoTable;
+}
+
+String __EXPORT ScUndoMakeOutline::GetComment() const
+{ // "Gruppierung" "Gruppierung aufheben"
+ return bMake ?
+ ScGlobal::GetRscString( STR_UNDO_MAKEOUTLINE ) :
+ ScGlobal::GetRscString( STR_UNDO_REMAKEOUTLINE );
+}
+
+void __EXPORT ScUndoMakeOutline::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SCTAB nTab = aBlockStart.Tab();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoMakeOutline::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
+
+ if (bMake)
+ pViewShell->MakeOutline( bColumns, FALSE );
+ else
+ pViewShell->RemoveOutline( bColumns, FALSE );
+
+ pDocShell->PostPaint(0,0,aBlockStart.Tab(),MAXCOL,MAXROW,aBlockEnd.Tab(),PAINT_GRID);
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoMakeOutline::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+
+ if (bMake)
+ rViewShell.MakeOutline( bColumns, TRUE );
+ else
+ rViewShell.RemoveOutline( bColumns, TRUE );
+ }
+}
+
+BOOL __EXPORT ScUndoMakeOutline::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+//
+// Outline-Ebene auswaehlen
+//
+
+ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell* pNewDocShell,
+ SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ BOOL bNewColumns, USHORT nNewLevel ) :
+ ScSimpleUndo( pNewDocShell ),
+ nStart( nNewStart ),
+ nEnd( nNewEnd ),
+ nTab( nNewTab ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTable( pNewUndoTab ),
+ bColumns( bNewColumns ),
+ nLevel( nNewLevel )
+{
+}
+
+__EXPORT ScUndoOutlineLevel::~ScUndoOutlineLevel()
+{
+ delete pUndoDoc;
+ delete pUndoTable;
+}
+
+String __EXPORT ScUndoOutlineLevel::GetComment() const
+{ // "Gliederungsebene auswaehlen";
+ return ScGlobal::GetRscString( STR_UNDO_OUTLINELEVEL );
+}
+
+void __EXPORT ScUndoOutlineLevel::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // Original Outline-Table
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ // Original Spalten-/Zeilenstatus
+
+ if (bColumns)
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, FALSE, pDoc);
+ else
+ pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pDoc );
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ pViewShell->UpdateScrollBars();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoOutlineLevel::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pViewShell->SelectLevel( bColumns, nLevel, FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoOutlineLevel::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->SelectLevel( bColumns, nLevel, TRUE );
+}
+
+BOOL __EXPORT ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+//
+// Outline ueber Blockmarken ein- oder ausblenden
+//
+
+ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, BOOL bNewShow ) :
+ ScSimpleUndo( pNewDocShell ),
+ aBlockStart( nStartX, nStartY, nStartZ ),
+ aBlockEnd( nEndX, nEndY, nEndZ ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTable( pNewUndoTab ),
+ bShow( bNewShow )
+{
+}
+
+__EXPORT ScUndoOutlineBlock::~ScUndoOutlineBlock()
+{
+ delete pUndoDoc;
+ delete pUndoTable;
+}
+
+String __EXPORT ScUndoOutlineBlock::GetComment() const
+{ // "Detail einblenden" "Detail ausblenden"
+ return bShow ?
+ ScGlobal::GetRscString( STR_UNDO_DOOUTLINEBLK ) :
+ ScGlobal::GetRscString( STR_UNDO_REDOOUTLINEBLK );
+}
+
+void __EXPORT ScUndoOutlineBlock::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SCTAB nTab = aBlockStart.Tab();
+
+ // Original Outline-Table
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ // Original Spalten-/Zeilenstatus
+
+ SCCOLROW nStartCol = aBlockStart.Col();
+ SCCOLROW nEndCol = aBlockEnd.Col();
+ SCCOLROW nStartRow = aBlockStart.Row();
+ SCCOLROW nEndRow = aBlockEnd.Row();
+
+ if (!bShow)
+ { // Groesse des ausgeblendeten Blocks
+ USHORT nLevel;
+ pUndoTable->GetColArray()->FindTouchedLevel( nStartCol, nEndCol, nLevel );
+ pUndoTable->GetColArray()->ExtendBlock( nLevel, nStartCol, nEndCol );
+ pUndoTable->GetRowArray()->FindTouchedLevel( nStartRow, nEndRow, nLevel );
+ pUndoTable->GetRowArray()->ExtendBlock( nLevel, nStartRow, nEndRow );
+ }
+
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
+ static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, FALSE, pDoc );
+ pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc );
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ pViewShell->UpdateScrollBars();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoOutlineBlock::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
+ if (bShow)
+ pViewShell->ShowMarkedOutlines( FALSE );
+ else
+ pViewShell->HideMarkedOutlines( FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoOutlineBlock::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+
+ if (bShow)
+ rViewShell.ShowMarkedOutlines( TRUE );
+ else
+ rViewShell.HideMarkedOutlines( TRUE );
+ }
+}
+
+BOOL __EXPORT ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+//
+// alle Outlines loeschen
+//
+
+ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
+ ScSimpleUndo( pNewDocShell ),
+ aBlockStart( nStartX, nStartY, nStartZ ),
+ aBlockEnd( nEndX, nEndY, nEndZ ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTable( pNewUndoTab )
+{
+}
+
+__EXPORT ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines()
+{
+ delete pUndoDoc;
+ delete pUndoTable;
+}
+
+String __EXPORT ScUndoRemoveAllOutlines::GetComment() const
+{ // "Gliederung entfernen"
+ return ScGlobal::GetRscString( STR_UNDO_REMOVEALLOTLNS );
+}
+
+void __EXPORT ScUndoRemoveAllOutlines::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SCTAB nTab = aBlockStart.Tab();
+
+ // Original Outline-Table
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ // Original Spalten-/Zeilenstatus
+
+ SCCOL nStartCol = aBlockStart.Col();
+ SCCOL nEndCol = aBlockEnd.Col();
+ SCROW nStartRow = aBlockStart.Row();
+ SCROW nEndRow = aBlockEnd.Row();
+
+ pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, FALSE, pDoc );
+ pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc );
+
+ pDoc->UpdatePageBreaks( nTab );
+
+ pViewShell->UpdateScrollBars();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoRemoveAllOutlines::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
+
+ SCTAB nTab = aBlockStart.Tab();
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pViewShell->RemoveAllOutlines( FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->RemoveAllOutlines( TRUE );
+}
+
+BOOL __EXPORT ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+//
+// Auto-Outline
+//
+
+ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
+ ScSimpleUndo( pNewDocShell ),
+ aBlockStart( nStartX, nStartY, nStartZ ),
+ aBlockEnd( nEndX, nEndY, nEndZ ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTable( pNewUndoTab )
+{
+}
+
+__EXPORT ScUndoAutoOutline::~ScUndoAutoOutline()
+{
+ delete pUndoDoc;
+ delete pUndoTable;
+}
+
+String __EXPORT ScUndoAutoOutline::GetComment() const
+{ // "Auto-Gliederung"
+ return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE );
+}
+
+void __EXPORT ScUndoAutoOutline::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SCTAB nTab = aBlockStart.Tab();
+
+ // Original Outline-Table
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ // Original Spalten-/Zeilenstatus
+
+ if (pUndoDoc && pUndoTable)
+ {
+ SCCOLROW nStartCol;
+ SCCOLROW nStartRow;
+ SCCOLROW nEndCol;
+ SCCOLROW nEndRow;
+ pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
+ pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
+
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
+ static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, FALSE,
+ pDoc);
+ pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc );
+
+ pViewShell->UpdateScrollBars();
+ }
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoAutoOutline::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCTAB nTab = aBlockStart.Tab();
+ if (pViewShell)
+ {
+ // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+ }
+
+ ScRange aRange( aBlockStart.Col(), aBlockStart.Row(), nTab,
+ aBlockEnd.Col(), aBlockEnd.Row(), nTab );
+ ScOutlineDocFunc aFunc( *pDocShell );
+ aFunc.AutoOutline( aRange, FALSE, FALSE );
+
+ // auf der View markieren
+ // Wenn's beim Aufruf eine Mehrfachselektion war, ist es jetzt der
+ // umschliessende Bereich...
+
+ if (pViewShell)
+ pViewShell->MarkRange( aRange );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoAutoOutline::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->AutoOutline( TRUE );
+}
+
+BOOL __EXPORT ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+//
+// Zwischenergebnisse
+//
+
+ScUndoSubTotals::ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScSubTotalParam& rNewParam, SCROW nNewEndY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ) :
+ ScDBFuncUndo( pNewDocShell, ScRange( rNewParam.nCol1, rNewParam.nRow1, nNewTab,
+ rNewParam.nCol2, rNewParam.nRow2, nNewTab ) ),
+ nTab( nNewTab ),
+ aParam( rNewParam ),
+ nNewEndRow( nNewEndY ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTable( pNewUndoTab ),
+ pUndoRange( pNewUndoRange ),
+ pUndoDB( pNewUndoDB )
+{
+}
+
+__EXPORT ScUndoSubTotals::~ScUndoSubTotals()
+{
+ delete pUndoDoc;
+ delete pUndoTable;
+ delete pUndoRange;
+ delete pUndoDB;
+}
+
+String __EXPORT ScUndoSubTotals::GetComment() const
+{ // "Teilergebnisse"
+ return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS );
+}
+
+void __EXPORT ScUndoSubTotals::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // um einzelnen DB-Bereich anzupassen
+/* ScDBData* pOldDBData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
+ aParam.nCol1, aParam.nRow1, aParam.nCol2, nNewEndRow );
+*/
+
+ if (nNewEndRow > aParam.nRow2)
+ {
+ pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aParam.nRow2+1, static_cast<SCSIZE>(nNewEndRow-aParam.nRow2) );
+ }
+ else if (nNewEndRow < aParam.nRow2)
+ {
+ pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, static_cast<SCSIZE>(aParam.nRow2-nNewEndRow) );
+ }
+
+
+ // Original Outline-Table
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ // Original Spalten-/Zeilenstatus
+
+ if (pUndoDoc && pUndoTable)
+ {
+ SCCOLROW nStartCol;
+ SCCOLROW nStartRow;
+ SCCOLROW nEndCol;
+ SCCOLROW nEndRow;
+ pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
+ pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
+
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
+ static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, FALSE,
+ pDoc);
+ pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc );
+
+ pViewShell->UpdateScrollBars();
+ }
+
+ // Original-Daten & Referenzen
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aParam.nRow1+1, nTab,
+ MAXCOL, aParam.nRow2, nTab );
+
+ pDoc->DeleteAreaTab( 0,aParam.nRow1+1, MAXCOL,aParam.nRow2, nTab, IDF_ALL );
+
+ pUndoDoc->CopyToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
+ IDF_NONE, FALSE, pDoc ); // Flags
+ pUndoDoc->UndoToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
+ IDF_ALL, FALSE, pDoc );
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
+ aParam.nCol2,aParam.nRow2,nTab );
+
+/* if (pUndoDBData)
+ *pOldDBData = *pUndoDBData;
+*/
+ if (pUndoRange)
+ pDoc->SetRangeName( new ScRangeName( *pUndoRange ) );
+ if (pUndoDB)
+ pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), TRUE );
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
+ pDocShell->PostDataChanged();
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoSubTotals::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
+ aParam.nCol2,aParam.nRow2,nTab );
+ pViewShell->DoSubTotals( aParam, FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoSubTotals::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoSubTotals::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // geht nicht wegen Spaltennummern
+}
+
+//
+// Sortieren
+//
+
+ScUndoSort::ScUndoSort( ScDocShell* pNewDocShell,
+ SCTAB nNewTab, const ScSortParam& rParam,
+ BOOL bQuery, ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB,
+ const ScRange* pDest ) :
+ ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab,
+ rParam.nCol2, rParam.nRow2, nNewTab ) ),
+ nTab( nNewTab ),
+ aSortParam( rParam ),
+ bRepeatQuery( bQuery ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoDB( pNewUndoDB ),
+ bDestArea( FALSE )
+{
+ if ( pDest )
+ {
+ bDestArea = TRUE;
+ aDestRange = *pDest;
+ }
+}
+
+__EXPORT ScUndoSort::~ScUndoSort()
+{
+ delete pUndoDoc;
+ delete pUndoDB;
+}
+
+String __EXPORT ScUndoSort::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_SORT );
+}
+
+void __EXPORT ScUndoSort::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCCOL nStartCol = aSortParam.nCol1;
+ SCROW nStartRow = aSortParam.nRow1;
+ SCCOL nEndCol = aSortParam.nCol2;
+ SCROW nEndRow = aSortParam.nRow2;
+ SCTAB nSortTab = nTab;
+ if ( !aSortParam.bInplace )
+ {
+ nStartCol = aSortParam.nDestCol;
+ nStartRow = aSortParam.nDestRow;
+ nEndCol = nStartCol + ( aSortParam.nCol2 - aSortParam.nCol1 );
+ nEndRow = nStartRow + ( aSortParam.nRow2 - aSortParam.nRow1 );
+ nSortTab = aSortParam.nDestTab;
+ }
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, nStartCol, nStartRow, nSortTab,
+ nEndCol, nEndRow, nSortTab );
+
+ // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
+ pDoc->DeleteAreaTab( nStartCol,nStartRow, nEndCol,nEndRow, nSortTab, IDF_ALL|IDF_NOCAPTIONS );
+ pUndoDoc->CopyToDocument( nStartCol, nStartRow, nSortTab, nEndCol, nEndRow, nSortTab,
+ IDF_ALL|IDF_NOCAPTIONS, FALSE, pDoc );
+
+ if (bDestArea)
+ {
+ // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
+ pDoc->DeleteAreaTab( aDestRange, IDF_ALL|IDF_NOCAPTIONS );
+ pUndoDoc->CopyToDocument( aDestRange, IDF_ALL|IDF_NOCAPTIONS, FALSE, pDoc );
+ }
+
+ // Zeilenhoehen immer (wegen automatischer Anpassung)
+ //! auf ScBlockUndo umstellen
+// if (bRepeatQuery)
+ pUndoDoc->CopyToDocument( 0, nStartRow, nSortTab, MAXCOL, nEndRow, nSortTab,
+ IDF_NONE, FALSE, pDoc );
+
+ if (pUndoDB)
+ pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), TRUE );
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nSortTab )
+ pViewShell->SetTabNo( nSortTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
+ pDocShell->PostDataChanged();
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoSort::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+// pViewShell->DoneBlockMode();
+// pViewShell->InitOwnBlockMode();
+// pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo
+
+ pViewShell->MarkRange( ScRange( aSortParam.nCol1, aSortParam.nRow1, nTab,
+ aSortParam.nCol2, aSortParam.nRow2, nTab ) );
+
+ pViewShell->Sort( aSortParam, FALSE );
+
+ // Quellbereich painten wegen Markierung
+ if ( !aSortParam.bInplace )
+ pDocShell->PostPaint( aSortParam.nCol1, aSortParam.nRow1, nTab,
+ aSortParam.nCol2, aSortParam.nRow2, nTab, PAINT_GRID );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoSort::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoSort::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // geht nicht wegen Spaltennummern
+}
+
+//
+// Filtern
+//
+
+ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQueryParam& rParam,
+ ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB,
+ const ScRange* pOld, BOOL bSize, const ScRange* pAdvSrc ) :
+ ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab,
+ rParam.nCol2, rParam.nRow2, nNewTab ) ),
+ pDrawUndo( NULL ),
+ nTab( nNewTab ),
+ aQueryParam( rParam ),
+ pUndoDoc( pNewUndoDoc ),
+// pUndoDBData( pNewData )
+ pUndoDB( pNewUndoDB ),
+ bIsAdvanced( FALSE ),
+ bDestArea( FALSE ),
+ bDoSize( bSize )
+{
+ if ( pOld )
+ {
+ bDestArea = TRUE;
+ aOldDest = *pOld;
+ }
+ if ( pAdvSrc )
+ {
+ bIsAdvanced = TRUE;
+ aAdvSource = *pAdvSrc;
+ }
+
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+}
+
+__EXPORT ScUndoQuery::~ScUndoQuery()
+{
+ delete pUndoDoc;
+// delete pUndoDBData;
+ delete pUndoDB;
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String __EXPORT ScUndoQuery::GetComment() const
+{ // "Filtern";
+ return ScGlobal::GetRscString( STR_UNDO_QUERY );
+}
+
+void __EXPORT ScUndoQuery::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ BOOL bCopy = !aQueryParam.bInplace;
+ SCCOL nDestEndCol = 0;
+ SCROW nDestEndRow = 0;
+ if (bCopy)
+ {
+ nDestEndCol = aQueryParam.nDestCol + ( aQueryParam.nCol2-aQueryParam.nCol1 );
+ nDestEndRow = aQueryParam.nDestRow + ( aQueryParam.nRow2-aQueryParam.nRow1 );
+
+ ScDBData* pData = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, TRUE );
+ if (pData)
+ {
+ ScRange aNewDest;
+ pData->GetArea( aNewDest );
+ nDestEndCol = aNewDest.aEnd.Col();
+ nDestEndRow = aNewDest.aEnd.Row();
+ }
+
+ if ( bDoSize && bDestArea )
+ {
+ // aDestRange ist der alte Bereich
+ pDoc->FitBlock( ScRange(
+ aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
+ nDestEndCol, nDestEndRow, aQueryParam.nDestTab ),
+ aOldDest );
+ }
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell,
+ aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
+ nDestEndCol, nDestEndRow, aQueryParam.nDestTab );
+ pDoc->DeleteAreaTab( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ nDestEndCol, nDestEndRow, aQueryParam.nDestTab, IDF_ALL );
+
+ pViewShell->DoneBlockMode();
+
+ pUndoDoc->CopyToDocument( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
+ nDestEndCol, nDestEndRow, aQueryParam.nDestTab,
+ IDF_ALL, FALSE, pDoc );
+ // Attribute werden immer mitkopiert (#49287#)
+
+ // Rest von altem Bereich
+ if ( bDestArea && !bDoSize )
+ {
+ pDoc->DeleteAreaTab( aOldDest, IDF_ALL );
+ pUndoDoc->CopyToDocument( aOldDest, IDF_ALL, FALSE, pDoc );
+ }
+ }
+ else
+ pUndoDoc->CopyToDocument( 0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab,
+ IDF_NONE, FALSE, pDoc );
+
+ if (pUndoDB)
+ pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), TRUE );
+
+ if (!bCopy)
+ {
+ pDoc->InvalidatePageBreaks(nTab);
+ pDoc->UpdatePageBreaks( nTab );
+ }
+
+ ScRange aDirtyRange( 0 , aQueryParam.nRow1, nTab,
+ MAXCOL, aQueryParam.nRow2, nTab );
+ pDoc->SetDirty( aDirtyRange );
+
+ DoSdrUndoAction( pDrawUndo, pDoc );
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ // Paint
+
+ if (bCopy)
+ {
+ SCCOL nEndX = nDestEndCol;
+ SCROW nEndY = nDestEndRow;
+ if (bDestArea)
+ {
+ if ( aOldDest.aEnd.Col() > nEndX )
+ nEndX = aOldDest.aEnd.Col();
+ if ( aOldDest.aEnd.Row() > nEndY )
+ nEndY = aOldDest.aEnd.Row();
+ }
+ if (bDoSize)
+ nEndY = MAXROW;
+ pDocShell->PostPaint( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
+ nEndX, nEndY, aQueryParam.nDestTab, PAINT_GRID );
+ }
+ else
+ pDocShell->PostPaint( 0, aQueryParam.nRow1, nTab, MAXCOL, MAXROW, nTab,
+ PAINT_GRID | PAINT_LEFT );
+ pDocShell->PostDataChanged();
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoQuery::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ if ( bIsAdvanced )
+ pViewShell->Query( aQueryParam, &aAdvSource, FALSE );
+ else
+ pViewShell->Query( aQueryParam, NULL, FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoQuery::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoQuery::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // geht nicht wegen Spaltennummern
+}
+
+//
+// Show or hide AutoFilter buttons (doesn't include filter settings)
+//
+
+ScUndoAutoFilter::ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange,
+ const String& rName, BOOL bSet ) :
+ ScDBFuncUndo( pNewDocShell, rRange ),
+ aDBName( rName ),
+ bFilterSet( bSet )
+{
+}
+
+ScUndoAutoFilter::~ScUndoAutoFilter()
+{
+}
+
+String ScUndoAutoFilter::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_QUERY ); // same as ScUndoQuery
+}
+
+void ScUndoAutoFilter::DoChange( BOOL bUndo )
+{
+ BOOL bNewFilter = bUndo ? !bFilterSet : bFilterSet;
+
+ USHORT nIndex;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ if ( pColl->SearchName( aDBName, nIndex ) )
+ {
+ ScDBData* pDBData = (*pColl)[nIndex];
+ pDBData->SetAutoFilter( bNewFilter );
+
+ SCCOL nRangeX1;
+ SCROW nRangeY1;
+ SCCOL nRangeX2;
+ SCROW nRangeY2;
+ SCTAB nRangeTab;
+ pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
+
+ if ( bNewFilter )
+ pDoc->ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
+ else
+ pDoc->RemoveFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
+
+ pDocShell->PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID );
+ }
+}
+
+void ScUndoAutoFilter::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+void ScUndoAutoFilter::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+}
+
+void ScUndoAutoFilter::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL ScUndoAutoFilter::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+//
+// Datenbankbereiche aendern (Dialog)
+//
+
+ScUndoDBData::ScUndoDBData( ScDocShell* pNewDocShell,
+ ScDBCollection* pNewUndoColl, ScDBCollection* pNewRedoColl ) :
+ ScSimpleUndo( pNewDocShell ),
+ pUndoColl( pNewUndoColl ),
+ pRedoColl( pNewRedoColl )
+{
+}
+
+__EXPORT ScUndoDBData::~ScUndoDBData()
+{
+ delete pUndoColl;
+ delete pRedoColl;
+}
+
+String __EXPORT ScUndoDBData::GetComment() const
+{ // "Datenbankbereiche aendern";
+ return ScGlobal::GetRscString( STR_UNDO_DBDATA );
+}
+
+void __EXPORT ScUndoDBData::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ BOOL bOldAutoCalc = pDoc->GetAutoCalc();
+ pDoc->SetAutoCalc( FALSE ); // unnoetige Berechnungen vermeiden
+ pDoc->CompileDBFormula( TRUE ); // CreateFormulaString
+ pDoc->SetDBCollection( new ScDBCollection(*pUndoColl), TRUE );
+ pDoc->CompileDBFormula( FALSE ); // CompileFormulaString
+ pDoc->SetAutoCalc( bOldAutoCalc );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoDBData::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ BOOL bOldAutoCalc = pDoc->GetAutoCalc();
+ pDoc->SetAutoCalc( FALSE ); // unnoetige Berechnungen vermeiden
+ pDoc->CompileDBFormula( TRUE ); // CreateFormulaString
+ pDoc->SetDBCollection( new ScDBCollection(*pRedoColl), TRUE );
+ pDoc->CompileDBFormula( FALSE ); // CompileFormulaString
+ pDoc->SetAutoCalc( bOldAutoCalc );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoDBData::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoDBData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // geht nicht
+}
+
+//
+// Import
+//
+
+ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY,
+ SCCOL nNewFormula,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ ScDBData* pNewUndoData, ScDBData* pNewRedoData ) :
+ ScSimpleUndo( pNewDocShell ),
+ nTab( nNewTab ),
+ aImportParam( rParam ),
+ nEndCol( nNewEndX ),
+ nEndRow( nNewEndY ),
+ pUndoDoc( pNewUndoDoc ),
+ pRedoDoc( pNewRedoDoc ),
+ pUndoDBData( pNewUndoData ),
+ pRedoDBData( pNewRedoData ),
+ nFormulaCols( nNewFormula ),
+ bRedoFilled( FALSE )
+{
+ // redo doc doesn't contain imported data (but everything else)
+}
+
+__EXPORT ScUndoImportData::~ScUndoImportData()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+ delete pUndoDBData;
+ delete pRedoDBData;
+}
+
+String __EXPORT ScUndoImportData::GetComment() const
+{ // "Importieren";
+ return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA );
+}
+
+void __EXPORT ScUndoImportData::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
+ nEndCol,nEndRow,nTab );
+
+ SCTAB nTable;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ ScDBData* pCurrentData = NULL;
+ if (pUndoDBData && pRedoDBData)
+ {
+ pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ pCurrentData = ScUndoUtil::GetOldDBData( pRedoDBData, pDoc, nTab,
+ nCol1, nRow1, nCol2, nRow2 );
+
+ if ( !bRedoFilled )
+ {
+ // read redo data from document at first undo
+ // imported data is deleted later anyway,
+ // so now delete each column after copying to save memory (#41216#)
+
+ BOOL bOldAutoCalc = pDoc->GetAutoCalc();
+ pDoc->SetAutoCalc( FALSE ); // outside of the loop
+ for (SCCOL nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++)
+ {
+ pDoc->CopyToDocument( nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab,
+ IDF_CONTENTS & ~IDF_NOTE, FALSE, pRedoDoc );
+ pDoc->DeleteAreaTab( nCopyCol,nRow1, nCopyCol,nRow2, nTab, IDF_CONTENTS & ~IDF_NOTE );
+ pDoc->DoColResize( nTab, nCopyCol, nCopyCol, 0 );
+ }
+ pDoc->SetAutoCalc( bOldAutoCalc );
+ bRedoFilled = TRUE;
+ }
+ }
+ BOOL bMoveCells = pUndoDBData && pRedoDBData &&
+ pRedoDBData->IsDoSize(); // in alt und neu gleich
+ if (bMoveCells)
+ {
+ // Undo: erst die neuen Daten loeschen, dann FitBlock rueckwaerts
+
+ ScRange aOld, aNew;
+ pUndoDBData->GetArea( aOld );
+ pRedoDBData->GetArea( aNew );
+
+ pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
+ aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
+
+ aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock auch fuer Formeln
+ aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
+ pDoc->FitBlock( aNew, aOld, FALSE ); // rueckwaerts
+ }
+ else
+ pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
+ nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
+
+ pUndoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
+ nEndCol+nFormulaCols,nEndRow,nTab,
+ IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+
+ if (pCurrentData)
+ {
+ *pCurrentData = *pUndoDBData;
+
+ pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
+ }
+
+// erack! it's broadcasted
+// pDoc->SetDirty();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ if (bMoveCells)
+ pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+ else
+ pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab,
+ nEndCol,nEndRow,nTab, PAINT_GRID );
+ pDocShell->PostDataChanged();
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoImportData::Redo()
+{
+ BeginRedo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
+ nEndCol,nEndRow,nTab );
+
+ SCTAB nTable;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ ScDBData* pCurrentData = NULL;
+ if (pUndoDBData && pRedoDBData)
+ {
+ pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ pCurrentData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
+ nCol1, nRow1, nCol2, nRow2 );
+ }
+ BOOL bMoveCells = pUndoDBData && pRedoDBData &&
+ pRedoDBData->IsDoSize(); // in alt und neu gleich
+ if (bMoveCells)
+ {
+ // Redo: FitBlock, dann Daten loeschen (noetig fuer CopyToDocument)
+
+ ScRange aOld, aNew;
+ pUndoDBData->GetArea( aOld );
+ pRedoDBData->GetArea( aNew );
+
+ aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols ); // FitBlock auch fuer Formeln
+ aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
+ pDoc->FitBlock( aOld, aNew );
+
+ pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
+ aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
+
+ pRedoDoc->CopyToDocument( aNew, IDF_ALL & ~IDF_NOTE, FALSE, pDoc ); // incl. Formeln
+ }
+ else
+ {
+ pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
+ nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
+ pRedoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
+ nEndCol,nEndRow,nTab, IDF_ALL & ~IDF_NOTE, FALSE, pDoc );
+ }
+
+ if (pCurrentData)
+ {
+ *pCurrentData = *pRedoDBData;
+
+ pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
+ ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
+ }
+
+// erack! it's broadcasted
+// pDoc->SetDirty();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ if (bMoveCells)
+ pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+ else
+ pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab,
+ nEndCol,nEndRow,nTab, PAINT_GRID );
+ pDocShell->PostDataChanged();
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoImportData::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
+
+ SCTAB nDummy;
+ ScImportParam aNewParam(aImportParam);
+ ScDBData* pDBData = rViewShell.GetDBData();
+ pDBData->GetArea( nDummy, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+
+ rViewShell.ImportData( aNewParam );
+ }
+}
+
+BOOL __EXPORT ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ // Repeat nur fuer Import per DB-Bereich, dann ist pUndoDBData gesetzt
+
+ if (pUndoDBData)
+ return (rTarget.ISA(ScTabViewTarget));
+ else
+ return FALSE; // Adressbuch
+}
+
+//
+// Operationen wiederholen
+//
+
+ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
+ SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
+ SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY,
+ ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
+ ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB,
+ const ScRange* pOldQ, const ScRange* pNewQ ) :
+ ScSimpleUndo( pNewDocShell ),
+ aBlockStart( nStartX,nStartY,nNewTab ),
+ aBlockEnd( nEndX,nEndY,nNewTab ),
+ nNewEndRow( nResultEndRow ),
+ aCursorPos( nCurX,nCurY,nNewTab ),
+ pUndoDoc( pNewUndoDoc ),
+ pUndoTable( pNewUndoTab ),
+ pUndoRange( pNewUndoRange ),
+ pUndoDB( pNewUndoDB ),
+ bQuerySize( FALSE )
+{
+ if ( pOldQ && pNewQ )
+ {
+ aOldQuery = *pOldQ;
+ aNewQuery = *pNewQ;
+ bQuerySize = TRUE;;
+ }
+}
+
+__EXPORT ScUndoRepeatDB::~ScUndoRepeatDB()
+{
+ delete pUndoDoc;
+ delete pUndoTable;
+ delete pUndoRange;
+ delete pUndoDB;
+}
+
+String __EXPORT ScUndoRepeatDB::GetComment() const
+{ // "Wiederholen"; //! bessere Beschreibung!
+ return ScGlobal::GetRscString( STR_UNDO_REPEATDB );
+}
+
+void __EXPORT ScUndoRepeatDB::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SCTAB nTab = aBlockStart.Tab();
+
+ if (bQuerySize)
+ {
+ pDoc->FitBlock( aNewQuery, aOldQuery, FALSE );
+
+ if ( aNewQuery.aEnd.Col() == aOldQuery.aEnd.Col() )
+ {
+ SCCOL nFormulaCols = 0;
+ SCCOL nCol = aOldQuery.aEnd.Col() + 1;
+ SCROW nRow = aOldQuery.aStart.Row() + 1; //! Header testen
+ while ( nCol <= MAXCOL &&
+ pDoc->GetCellType(ScAddress( nCol, nRow, nTab )) == CELLTYPE_FORMULA )
+ ++nCol, ++nFormulaCols;
+
+ if ( nFormulaCols > 0 )
+ {
+ ScRange aOldForm = aOldQuery;
+ aOldForm.aStart.SetCol( aOldQuery.aEnd.Col() + 1 );
+ aOldForm.aEnd.SetCol( aOldQuery.aEnd.Col() + nFormulaCols );
+ ScRange aNewForm = aOldForm;
+ aNewForm.aEnd.SetRow( aNewQuery.aEnd.Row() );
+ pDoc->FitBlock( aNewForm, aOldForm, FALSE );
+ }
+ }
+ }
+
+ //! Daten von Filter in anderen Bereich fehlen noch !!!!!!!!!!!!!!!!!
+
+ if (nNewEndRow > aBlockEnd.Row())
+ {
+ pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aBlockEnd.Row()+1, static_cast<SCSIZE>(nNewEndRow-aBlockEnd.Row()) );
+ }
+ else if (nNewEndRow < aBlockEnd.Row())
+ {
+ pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, static_cast<SCSIZE>(nNewEndRow-aBlockEnd.Row()) );
+ }
+
+ // Original Outline-Table
+
+ pDoc->SetOutlineTable( nTab, pUndoTable );
+
+ // Original Spalten-/Zeilenstatus
+
+ if (pUndoDoc && pUndoTable)
+ {
+ SCCOLROW nStartCol;
+ SCCOLROW nStartRow;
+ SCCOLROW nEndCol;
+ SCCOLROW nEndRow;
+ pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
+ pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
+
+ pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
+ static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, FALSE,
+ pDoc );
+ pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, FALSE, pDoc );
+
+ pViewShell->UpdateScrollBars();
+ }
+
+ // Original-Daten & Referenzen
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aBlockStart.Row(), nTab,
+ MAXCOL, aBlockEnd.Row(), nTab );
+ pDoc->DeleteAreaTab( 0, aBlockStart.Row(),
+ MAXCOL, aBlockEnd.Row(), nTab, IDF_ALL );
+
+ pUndoDoc->CopyToDocument( 0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
+ IDF_NONE, FALSE, pDoc ); // Flags
+ pUndoDoc->UndoToDocument( 0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
+ IDF_ALL, FALSE, pDoc );
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
+ aBlockEnd.Col(),aBlockEnd.Row(),nTab );
+
+ if (pUndoRange)
+ pDoc->SetRangeName( new ScRangeName( *pUndoRange ) );
+ if (pUndoDB)
+ pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), TRUE );
+
+// erack! it's broadcasted
+// pDoc->SetDirty();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
+ pDocShell->PostDataChanged();
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoRepeatDB::Redo()
+{
+ BeginRedo();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ SCTAB nTab = aBlockStart.Tab();
+
+ SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nVisTab != nTab )
+ pViewShell->SetTabNo( nTab );
+
+ ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
+ aBlockEnd.Col(),aBlockEnd.Row(),nTab );
+ pViewShell->SetCursor( aCursorPos.Col(), aCursorPos.Row() );
+
+ pViewShell->RepeatDB( FALSE );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoRepeatDB::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->RepeatDB( TRUE );
+}
+
+BOOL __EXPORT ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+//
+// data pilot
+//
+
+ScUndoDataPilot::ScUndoDataPilot( ScDocShell* pNewDocShell,
+ ScDocument* pOldDoc, ScDocument* pNewDoc,
+ const ScDPObject* pOldObj, const ScDPObject* pNewObj, BOOL bMove ) :
+ ScSimpleUndo( pNewDocShell ),
+ pOldUndoDoc( pOldDoc ),
+ pNewUndoDoc( pNewDoc ),
+ pOldDPObject( NULL ),
+ pNewDPObject( NULL ),
+ bAllowMove( bMove )
+{
+ if (pOldObj)
+ pOldDPObject = new ScDPObject( *pOldObj );
+ if (pNewObj)
+ pNewDPObject = new ScDPObject( *pNewObj );
+}
+
+__EXPORT ScUndoDataPilot::~ScUndoDataPilot()
+{
+ delete pOldDPObject;
+ delete pNewDPObject;
+ delete pOldUndoDoc;
+ delete pNewUndoDoc;
+}
+
+String __EXPORT ScUndoDataPilot::GetComment() const
+{
+ USHORT nIndex;
+ if ( pOldUndoDoc && pNewUndoDoc )
+ nIndex = STR_UNDO_PIVOT_MODIFY;
+ else if ( pNewUndoDoc )
+ nIndex = STR_UNDO_PIVOT_NEW;
+ else
+ nIndex = STR_UNDO_PIVOT_DELETE;
+
+ return ScGlobal::GetRscString( nIndex );
+}
+
+void __EXPORT ScUndoDataPilot::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScRange aOldRange;
+ ScRange aNewRange;
+
+ if ( pNewDPObject && pNewUndoDoc )
+ {
+ aNewRange = pNewDPObject->GetOutRange();
+ pDoc->DeleteAreaTab( aNewRange, IDF_ALL );
+ pNewUndoDoc->CopyToDocument( aNewRange, IDF_ALL, FALSE, pDoc );
+ }
+ if ( pOldDPObject && pOldUndoDoc )
+ {
+ aOldRange = pOldDPObject->GetOutRange();
+ pDoc->DeleteAreaTab( aOldRange, IDF_ALL );
+ pOldUndoDoc->CopyToDocument( aOldRange, IDF_ALL, FALSE, pDoc );
+ }
+
+ // update objects in collection
+
+ if ( pNewDPObject )
+ {
+ // find updated object
+ //! find by name!
+
+ ScDPObject* pDocObj = pDoc->GetDPAtCursor(
+ aNewRange.aStart.Col(), aNewRange.aStart.Row(), aNewRange.aStart.Tab() );
+ DBG_ASSERT(pDocObj, "DPObject not found");
+ if (pDocObj)
+ {
+ if ( pOldDPObject )
+ {
+ // restore old settings
+ pOldDPObject->WriteSourceDataTo( *pDocObj );
+ ScDPSaveData* pData = pOldDPObject->GetSaveData();
+ if (pData)
+ pDocObj->SetSaveData(*pData);
+ pDocObj->SetOutRange( pOldDPObject->GetOutRange() );
+ pOldDPObject->WriteTempDataTo( *pDocObj );
+ }
+ else
+ {
+ // delete inserted object
+ pDoc->GetDPCollection()->FreeTable(pDocObj);
+ }
+ }
+ }
+ else if ( pOldDPObject )
+ {
+ // re-insert deleted object
+
+ ScDPObject* pDestObj = new ScDPObject( *pOldDPObject );
+ pDestObj->SetAlive(TRUE);
+ if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
+ {
+ DBG_ERROR("cannot insert DPObject");
+ DELETEZ( pDestObj );
+ }
+ }
+
+ if (pNewUndoDoc)
+ pDocShell->PostPaint( aNewRange, PAINT_GRID, SC_PF_LINES );
+ if (pOldUndoDoc)
+ pDocShell->PostPaint( aOldRange, PAINT_GRID, SC_PF_LINES );
+ pDocShell->PostDataChanged();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ //! set current sheet
+ }
+
+ if (pNewDPObject)
+ {
+ // notify API objects
+ pDoc->BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) );
+ }
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoDataPilot::Redo()
+{
+ BeginRedo();
+
+ //! copy output data instead of repeating the change,
+ //! in case external data have changed!
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScDPObject* pSourceObj = NULL;
+ if ( pOldDPObject )
+ {
+ // find object to modify
+ //! find by name!
+
+ ScRange aOldRange = pOldDPObject->GetOutRange();
+ pSourceObj = pDoc->GetDPAtCursor(
+ aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aStart.Tab() );
+ DBG_ASSERT(pSourceObj, "DPObject not found");
+ }
+
+ ScDBDocFunc aFunc( *pDocShell );
+ aFunc.DataPilotUpdate( pSourceObj, pNewDPObject, FALSE, FALSE, bAllowMove ); // no new undo action
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoDataPilot::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ //! allow deletion
+}
+
+BOOL __EXPORT ScUndoDataPilot::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ //! allow deletion
+ return FALSE;
+}
+
+
+//
+// Konsolidieren
+//
+
+ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea,
+ const ScConsolidateParam& rPar, ScDocument* pNewUndoDoc,
+ BOOL bReference, SCROW nInsCount, ScOutlineTable* pTab,
+ ScDBData* pData ) :
+ ScSimpleUndo( pNewDocShell ),
+ aDestArea( rArea ),
+ pUndoDoc( pNewUndoDoc ),
+ aParam( rPar ),
+ bInsRef( bReference ),
+ nInsertCount( nInsCount ),
+ pUndoTab( pTab ),
+ pUndoData( pData )
+{
+}
+
+__EXPORT ScUndoConsolidate::~ScUndoConsolidate()
+{
+ delete pUndoDoc;
+ delete pUndoTab;
+ delete pUndoData;
+}
+
+String __EXPORT ScUndoConsolidate::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE );
+}
+
+void __EXPORT ScUndoConsolidate::Undo()
+{
+ BeginUndo();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTab = aDestArea.nTab;
+
+ ScRange aOldRange;
+ if (pUndoData)
+ pUndoData->GetArea(aOldRange);
+
+ if (bInsRef)
+ {
+ // Zeilen loeschen
+ pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aDestArea.nRowStart, nInsertCount );
+
+ // Outlines
+ pDoc->SetOutlineTable( nTab, pUndoTab );
+
+ // Zeilenstatus
+ pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pDoc );
+
+ // Daten & Referenzen
+ pDoc->DeleteAreaTab( 0,aDestArea.nRowStart, MAXCOL,aDestArea.nRowEnd, nTab, IDF_ALL );
+ pUndoDoc->UndoToDocument( 0, aDestArea.nRowStart, nTab,
+ MAXCOL, aDestArea.nRowEnd, nTab,
+ IDF_ALL, FALSE, pDoc );
+
+ // Original-Bereich
+ if (pUndoData)
+ {
+ pDoc->DeleteAreaTab(aOldRange, IDF_ALL);
+ pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, FALSE, pDoc);
+ }
+
+ pDocShell->PostPaint( 0,aDestArea.nRowStart,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_SIZE );
+ }
+ else
+ {
+ pDoc->DeleteAreaTab( aDestArea.nColStart,aDestArea.nRowStart,
+ aDestArea.nColEnd,aDestArea.nRowEnd, nTab, IDF_ALL );
+ pUndoDoc->CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, nTab,
+ aDestArea.nColEnd, aDestArea.nRowEnd, nTab,
+ IDF_ALL, FALSE, pDoc );
+
+ // Original-Bereich
+ if (pUndoData)
+ {
+ pDoc->DeleteAreaTab(aOldRange, IDF_ALL);
+ pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, FALSE, pDoc);
+ }
+
+ SCCOL nEndX = aDestArea.nColEnd;
+ SCROW nEndY = aDestArea.nRowEnd;
+ if ( pUndoData )
+ {
+ if ( aOldRange.aEnd.Col() > nEndX )
+ nEndX = aOldRange.aEnd.Col();
+ if ( aOldRange.aEnd.Row() > nEndY )
+ nEndY = aOldRange.aEnd.Row();
+ }
+ pDocShell->PostPaint( aDestArea.nColStart, aDestArea.nRowStart, nTab,
+ nEndX, nEndY, nTab, PAINT_GRID );
+ }
+
+ // DB-Bereich wieder anpassen
+ if (pUndoData)
+ {
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ if (pColl)
+ {
+ USHORT nIndex;
+ if (pColl->SearchName( pUndoData->GetName(), nIndex ))
+ {
+ ScDBData* pDocData = (*pColl)[nIndex];
+ if (pDocData)
+ *pDocData = *pUndoData;
+ }
+ else
+ {
+ DBG_ERROR("alte DB-Daten nicht gefunden");
+ }
+ }
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nViewTab != nTab )
+ pViewShell->SetTabNo( nTab );
+ }
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoConsolidate::Redo()
+{
+ BeginRedo();
+
+ pDocShell->DoConsolidate( aParam, FALSE );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nViewTab != aParam.nTab )
+ pViewShell->SetTabNo( aParam.nTab );
+ }
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoConsolidate::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoConsolidate::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//
+// Quell-Daten von Chart aendern
+//
+
+void ScUndoChartData::Init()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ aOldRangeListRef = new ScRangeList;
+ pDoc->GetOldChartParameters( aChartName, *aOldRangeListRef, bOldColHeaders, bOldRowHeaders );
+}
+
+ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName,
+ const ScRange& rNew, BOOL bColHdr, BOOL bRowHdr,
+ BOOL bAdd ) :
+ ScSimpleUndo( pNewDocShell ),
+ aChartName( rName ),
+ bNewColHeaders( bColHdr ),
+ bNewRowHeaders( bRowHdr ),
+ bAddRange( bAdd )
+{
+ aNewRangeListRef = new ScRangeList;
+ aNewRangeListRef->Append( rNew );
+
+ Init();
+}
+
+ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName,
+ const ScRangeListRef& rNew, BOOL bColHdr, BOOL bRowHdr,
+ BOOL bAdd ) :
+ ScSimpleUndo( pNewDocShell ),
+ aChartName( rName ),
+ aNewRangeListRef( rNew ),
+ bNewColHeaders( bColHdr ),
+ bNewRowHeaders( bRowHdr ),
+ bAddRange( bAdd )
+{
+ Init();
+}
+
+__EXPORT ScUndoChartData::~ScUndoChartData()
+{
+}
+
+String __EXPORT ScUndoChartData::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_CHARTDATA );
+}
+
+void __EXPORT ScUndoChartData::Undo()
+{
+ BeginUndo();
+
+ pDocShell->GetDocument()->UpdateChartArea( aChartName, aOldRangeListRef,
+ bOldColHeaders, bOldRowHeaders, FALSE );
+
+ EndUndo();
+}
+
+void __EXPORT ScUndoChartData::Redo()
+{
+ BeginRedo();
+
+ pDocShell->GetDocument()->UpdateChartArea( aChartName, aNewRangeListRef,
+ bNewColHeaders, bNewRowHeaders, bAddRange );
+
+ EndRedo();
+}
+
+void __EXPORT ScUndoChartData::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL __EXPORT ScUndoChartData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+// Amelia Wang
+ScUndoDataForm::ScUndoDataForm( ScDocShell* pNewDocShell,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
+ const ScMarkData& rMark,
+ ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
+ USHORT nNewFlags,
+ ScRefUndoData* pRefData,
+ void* /*pFill1*/, void* /*pFill2*/, void* /*pFill3*/,
+ BOOL bRedoIsFilled ) :
+ ScBlockUndo( pNewDocShell, ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ), SC_UNDO_SIMPLE ),
+ aMarkData( rMark ),
+ pUndoDoc( pNewUndoDoc ),
+ pRedoDoc( pNewRedoDoc ),
+ nFlags( nNewFlags ),
+ pRefUndoData( pRefData ),
+ pRefRedoData( NULL ),
+ bRedoFilled( bRedoIsFilled )
+{
+ // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting)
+ // don't have to be changed and branched for 641.
+ // They can be removed later.
+
+ if ( !aMarkData.IsMarked() ) // no cell marked:
+ aMarkData.SetMarkArea( aBlockRange ); // mark paste block
+
+ if ( pRefUndoData )
+ pRefUndoData->DeleteUnchanged( pDocShell->GetDocument() );
+
+ SetChangeTrack();
+}
+
+ScUndoDataForm::~ScUndoDataForm()
+{
+ delete pUndoDoc;
+ delete pRedoDoc;
+ delete pRefUndoData;
+ delete pRefRedoData;
+}
+
+String ScUndoDataForm::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_PASTE );
+}
+
+void ScUndoDataForm::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack && (nFlags & IDF_CONTENTS) )
+ pChangeTrack->AppendContentRange( aBlockRange, pUndoDoc,
+ nStartChangeAction, nEndChangeAction, SC_CACM_PASTE );
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+
+void ScUndoDataForm::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ ShowTable( aBlockRange );
+ EndUndo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void ScUndoDataForm::Redo()
+{
+ BeginRedo();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ EnableDrawAdjust( pDoc, FALSE ); //! include in ScBlockUndo?
+ DoChange( FALSE );
+ EnableDrawAdjust( pDoc, TRUE ); //! include in ScBlockUndo?
+ EndRedo();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+void ScUndoDataForm::Repeat(SfxRepeatTarget& /*rTarget*/)
+{
+}
+
+BOOL ScUndoDataForm::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+void ScUndoDataForm::DoChange( const BOOL bUndo )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ // RefUndoData for redo is created before first undo
+ // (with DeleteUnchanged after the DoUndo call)
+ BOOL bCreateRedoData = ( bUndo && pRefUndoData && !pRefRedoData );
+ if ( bCreateRedoData )
+ pRefRedoData = new ScRefUndoData( pDoc );
+
+ ScRefUndoData* pWorkRefData = bUndo ? pRefUndoData : pRefRedoData;
+
+ // fuer Undo immer alle oder keine Inhalte sichern
+ USHORT nUndoFlags = IDF_NONE;
+ if (nFlags & IDF_CONTENTS)
+ nUndoFlags |= IDF_CONTENTS;
+ if (nFlags & IDF_ATTRIB)
+ nUndoFlags |= IDF_ATTRIB;
+
+ BOOL bPaintAll = FALSE;
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ // marking is in ScBlockUndo...
+ //ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockRange );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if ( bUndo && !bRedoFilled )
+ {
+ if (!pRedoDoc)
+ {
+ BOOL bColInfo = ( aBlockRange.aStart.Row()==0 && aBlockRange.aEnd.Row()==MAXROW );
+ BOOL bRowInfo = ( aBlockRange.aStart.Col()==0 && aBlockRange.aEnd.Col()==MAXCOL );
+
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndoSelected( pDoc, aMarkData, bColInfo, bRowInfo );
+ }
+ // read "redo" data from the document in the first undo
+ // all sheets - CopyToDocument skips those that don't exist in pRedoDoc
+ ScRange aCopyRange = aBlockRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, 1, FALSE, pRedoDoc );
+ bRedoFilled = TRUE;
+ }
+
+ USHORT nExtFlags = 0;
+ pDocShell->UpdatePaintExt( nExtFlags, aBlockRange );
+
+ for ( sal_uInt16 i=0; i <= ( aBlockRange.aEnd.Col() - aBlockRange.aStart.Col() ); i++ )
+ {
+ String aOldString;
+ pUndoDoc->GetString( aBlockRange.aStart.Col()+i , aBlockRange.aStart.Row() , aBlockRange.aStart.Tab() , aOldString );
+ pDoc->SetString( aBlockRange.aStart.Col()+i , aBlockRange.aStart.Row() , aBlockRange.aStart.Tab() , aOldString );
+ }
+
+ //ScRange aTabSelectRange = aBlockRange;
+
+ if (pWorkRefData)
+ {
+ pWorkRefData->DoUndo( pDoc, TRUE ); // TRUE = bSetChartRangeLists for SetChartListenerCollection
+ if ( pDoc->RefreshAutoFilter( 0,0, MAXCOL,MAXROW, aBlockRange.aStart.Tab() ) )
+ bPaintAll = TRUE;
+ }
+
+ if ( bCreateRedoData && pRefRedoData )
+ pRefRedoData->DeleteUnchanged( pDoc );
+
+ if ( bUndo )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+ }
+ else
+ SetChangeTrack();
+
+ ScRange aDrawRange( aBlockRange );
+ pDoc->ExtendMerge( aDrawRange, TRUE ); // only needed for single sheet (text/rtf etc.)
+ USHORT nPaint = PAINT_GRID;
+ if (bPaintAll)
+ {
+ aDrawRange.aStart.SetCol(0);
+ aDrawRange.aStart.SetRow(0);
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ aDrawRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_TOP | PAINT_LEFT;
+/*A*/ if (pViewShell)
+ pViewShell->AdjustBlockHeight(FALSE);
+ }
+ else
+ {
+ if ( aBlockRange.aStart.Row() == 0 && aBlockRange.aEnd.Row() == MAXROW ) // ganze Spalte
+ {
+ nPaint |= PAINT_TOP;
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ }
+ if ( aBlockRange.aStart.Col() == 0 && aBlockRange.aEnd.Col() == MAXCOL ) // ganze Zeile
+ {
+ nPaint |= PAINT_LEFT;
+ aDrawRange.aEnd.SetRow(MAXROW);
+ }
+/*A*/ if ((pViewShell) && pViewShell->AdjustBlockHeight(FALSE))
+ {
+ aDrawRange.aStart.SetCol(0);
+ aDrawRange.aStart.SetRow(0);
+ aDrawRange.aEnd.SetCol(MAXCOL);
+ aDrawRange.aEnd.SetRow(MAXROW);
+ nPaint |= PAINT_LEFT;
+ }
+ pDocShell->UpdatePaintExt( nExtFlags, aDrawRange );
+ }
+
+ if ( !bUndo ) // draw redo after updating row heights
+ RedoSdrUndoAction( pDrawUndo ); //! include in ScBlockUndo?
+
+ pDocShell->PostPaint( aDrawRange, nPaint, nExtFlags );
+
+ pDocShell->PostDataChanged();
+ if (pViewShell)
+ pViewShell->CellContentChanged();
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undodraw.cxx b/sc/source/ui/undo/undodraw.cxx
new file mode 100644
index 000000000000..11f98d1442e1
--- /dev/null
+++ b/sc/source/ui/undo/undodraw.cxx
@@ -0,0 +1,271 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// TOOLS
+#define _BIGINT_HXX
+#define _SFXMULTISEL_HXX
+#define _STACK_HXX
+#define _QUEUE_HXX
+#define _DYNARR_HXX
+#define _TREELIST_HXX
+#define _CACHESTR_HXX
+#define _NEW_HXX
+//#define _SHL_HXX
+//#define _LINK_HXX
+//#define _ERRCODE_HXX
+//#define _GEN_HXX
+//#define _FRACT_HXX
+//#define _STRING_HXX
+//#define _MTF_HXX
+//#define _CONTNR_HXX
+//#define _LIST_HXX
+//#define _TABLE_HXX
+#define _DYNARY_HXX
+//#define _UNQIDX_HXX
+#define _SVMEMPOOL_HXX
+//#define _UNQID_HXX
+//#define _DEBUG_HXX
+//#define _DATE_HXX
+//#define _TIME_HXX
+//#define _DATETIME_HXX
+//#define _INTN_HXX
+//#define _WLDCRD_HXX
+//#define _FSYS_HXX
+//#define _STREAM_HXX
+#define _CACHESTR_HXX
+#define _SV_MULTISEL_HXX
+
+//SV
+//#define _CLIP_HXX
+#define _CONFIG_HXX
+#define _CURSOR_HXX
+#define _FONTDLG_HXX
+#define _PRVWIN_HXX
+//#define _COLOR_HXX
+//#define _PAL_HXX
+//#define _BITMAP_HXX
+//#define _GDIOBJ_HXX
+//#define _POINTR_HXX
+//#define _ICON_HXX
+//#define _IMAGE_HXX
+//#define _KEYCOD_HXX
+//#define _EVENT_HXX
+#define _HELP_HXX
+//#define _APP_HXX
+//#define _MDIAPP_HXX
+//#define _TIMER_HXX
+//#define _METRIC_HXX
+//#define _REGION_HXX
+//#define _OUTDEV_HXX
+//#define _SYSTEM_HXX
+//#define _VIRDEV_HXX
+//#define _JOBSET_HXX
+//#define _PRINT_HXX
+//#define _WINDOW_HXX
+//#define _SYSWIN_HXX
+//#define _WRKWIN_HXX
+#define _MDIWIN_HXX
+//#define _FLOATWIN_HXX
+//#define _DOCKWIN_HXX
+//#define _CTRL_HXX
+//#define _SCRBAR_HXX
+//#define _BUTTON_HXX
+//#define _IMAGEBTN_HXX
+//#define _FIXED_HXX
+//#define _GROUP_HXX
+//#define _EDIT_HXX
+//#define _COMBOBOX_HXX
+//#define _LSTBOX_HXX
+//#define _SELENG_HXX
+//#define _SPLIT_HXX
+#define _SPIN_HXX
+//#define _FIELD_HXX
+//#define _MOREBTN_HXX
+//#define _TOOLBOX_HXX
+//#define _STATUS_HXX
+//#define _DIALOG_HXX
+//#define _MSGBOX_HXX
+//#define _SYSDLG_HXX
+#define _FILDLG_HXX
+//#define _PRNDLG_HXX
+#define _COLDLG_HXX
+//#define _TABDLG_HXX
+//#define _MENU_HXX
+//#define _GDIMTF_HXX
+//#define _POLY_HXX
+//#define _ACCEL_HXX
+//#define _GRAPH_HXX
+#define _SOUND_HXX
+
+
+#define SI_NOITEMS
+//#define SI_NODRW
+#define _SI_NOSBXCONTROLS
+#define _SI_NOOTHERFORMS
+#define _SI_NOCONTROL
+#define _SI_NOSBXCONTROLS
+#define _SIDLL_HXX
+
+// SFX
+#define _SFXAPPWIN_HXX
+#define _SFX_SAVEOPT_HXX
+//#define _SFX_CHILDWIN_HXX
+//#define _SFXCTRLITEM_HXX
+#define _SFXPRNMON_HXX
+#define _INTRO_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSGPOOL_HXX
+#define _SFXFILEDLG_HXX
+#define _PASSWD_HXX
+#define _SFXTBXCTRL_HXX
+#define _SFXSTBITEM_HXX
+#define _SFXMNUITEM_HXX
+#define _SFXIMGMGR_HXX
+#define _SFXTBXMGR_HXX
+#define _SFXSTBMGR_HXX
+#define _SFX_MINFITEM_HXX
+#define _SFXEVENT_HXX
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdundo.hxx>
+
+#include "undodraw.hxx"
+#include "docsh.hxx"
+
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScUndoDraw, SfxUndoAction);
+
+// -----------------------------------------------------------------------
+
+ScUndoDraw::ScUndoDraw( SfxUndoAction* pUndo, ScDocShell* pDocSh ) :
+ pDrawUndo( pUndo ),
+ pDocShell( pDocSh )
+{
+}
+
+__EXPORT ScUndoDraw::~ScUndoDraw()
+{
+ delete pDrawUndo;
+}
+
+void ScUndoDraw::ForgetDrawUndo()
+{
+ pDrawUndo = NULL; // nicht loeschen (Draw-Undo muss dann von aussen gemerkt werden)
+}
+
+String __EXPORT ScUndoDraw::GetComment() const
+{
+ if (pDrawUndo)
+ return pDrawUndo->GetComment();
+ else
+ return String();
+}
+
+String __EXPORT ScUndoDraw::GetRepeatComment(SfxRepeatTarget& rTarget) const
+{
+ if (pDrawUndo)
+ return pDrawUndo->GetRepeatComment(rTarget);
+ else
+ return String();
+}
+
+USHORT __EXPORT ScUndoDraw::GetId() const
+{
+ if (pDrawUndo)
+ return pDrawUndo->GetId();
+ else
+ return 0;
+}
+
+BOOL __EXPORT ScUndoDraw::IsLinked()
+{
+ if (pDrawUndo)
+ return pDrawUndo->IsLinked();
+ else
+ return FALSE;
+}
+
+void __EXPORT ScUndoDraw::SetLinked( BOOL bIsLinked )
+{
+ if (pDrawUndo)
+ pDrawUndo->SetLinked(bIsLinked);
+}
+
+BOOL __EXPORT ScUndoDraw::Merge( SfxUndoAction* pNextAction )
+{
+ if (pDrawUndo)
+ return pDrawUndo->Merge(pNextAction);
+ else
+ return FALSE;
+}
+
+void __EXPORT ScUndoDraw::Undo()
+{
+ if (pDrawUndo)
+ {
+ pDrawUndo->Undo();
+ pDocShell->SetDrawModified();
+ }
+}
+
+void __EXPORT ScUndoDraw::Redo()
+{
+ if (pDrawUndo)
+ {
+ pDrawUndo->Redo();
+ pDocShell->SetDrawModified();
+ }
+}
+
+void __EXPORT ScUndoDraw::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (pDrawUndo)
+ pDrawUndo->Repeat(rTarget);
+}
+
+BOOL __EXPORT ScUndoDraw::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ if (pDrawUndo)
+ return pDrawUndo->CanRepeat(rTarget);
+ else
+ return FALSE;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undoolk.cxx b/sc/source/ui/undo/undoolk.cxx
new file mode 100644
index 000000000000..9873bcf40926
--- /dev/null
+++ b/sc/source/ui/undo/undoolk.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdundo.hxx>
+
+#include "document.hxx"
+#include "drwlayer.hxx"
+
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+SdrUndoAction* GetSdrUndoAction( ScDocument* pDoc )
+{
+ ScDrawLayer* pLayer = pDoc->GetDrawLayer();
+ if (pLayer)
+ return pLayer->GetCalcUndo(); // muss vorhanden sein
+ else
+ return NULL;
+}
+
+void DoSdrUndoAction( SdrUndoAction* pUndoAction, ScDocument* pDoc )
+{
+ if ( pUndoAction )
+ pUndoAction->Undo();
+ else
+ {
+ // #125875# if no drawing layer existed when the action was created,
+ // but it was created after that, there is no draw undo action,
+ // and after undo there might be a drawing layer with a wrong page count.
+ // The drawing layer must have been empty in that case, so any missing
+ // pages can just be created now.
+
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if ( pDrawLayer )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nPages = static_cast<SCTAB>(pDrawLayer->GetPageCount());
+ while ( nPages < nTabCount )
+ {
+ pDrawLayer->ScAddPage( nPages );
+ ++nPages;
+ }
+ }
+ }
+}
+
+
+void RedoSdrUndoAction( SdrUndoAction* pUndoAction )
+{
+ // #125875# DoSdrUndoAction/RedoSdrUndoAction is called even if the pointer is null
+
+ if ( pUndoAction )
+ pUndoAction->Redo();
+}
+
+void DeleteSdrUndoAction( SdrUndoAction* pUndoAction )
+{
+ delete pUndoAction;
+}
+
+void EnableDrawAdjust( ScDocument* pDoc, BOOL bEnable )
+{
+ ScDrawLayer* pLayer = pDoc->GetDrawLayer();
+ if (pLayer)
+ pLayer->EnableAdjust(bEnable);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undostyl.cxx b/sc/source/ui/undo/undostyl.cxx
new file mode 100644
index 000000000000..d9c1cfd4c84a
--- /dev/null
+++ b/sc/source/ui/undo/undostyl.cxx
@@ -0,0 +1,313 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svl/itemset.hxx>
+#include <vcl/virdev.hxx>
+
+#include "undostyl.hxx"
+#include "docsh.hxx"
+#include "docpool.hxx"
+#include "stlpool.hxx"
+#include "printfun.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "globstr.hrc"
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScUndoModifyStyle, ScSimpleUndo);
+TYPEINIT1(ScUndoApplyPageStyle, ScSimpleUndo);
+
+// -----------------------------------------------------------------------
+//
+// modify style (cell or page style)
+//
+
+ScStyleSaveData::ScStyleSaveData() :
+ pItems( NULL )
+{
+}
+
+ScStyleSaveData::ScStyleSaveData( const ScStyleSaveData& rOther ) :
+ aName( rOther.aName ),
+ aParent( rOther.aParent )
+{
+ if (rOther.pItems)
+ pItems = new SfxItemSet( *rOther.pItems );
+ else
+ pItems = NULL;
+}
+
+ScStyleSaveData::~ScStyleSaveData()
+{
+ delete pItems;
+}
+
+ScStyleSaveData& ScStyleSaveData::operator=( const ScStyleSaveData& rOther )
+{
+ aName = rOther.aName;
+ aParent = rOther.aParent;
+
+ delete pItems;
+ if (rOther.pItems)
+ pItems = new SfxItemSet( *rOther.pItems );
+ else
+ pItems = NULL;
+
+ return *this;
+}
+
+void ScStyleSaveData::InitFromStyle( const SfxStyleSheetBase* pSource )
+{
+ if ( pSource )
+ {
+ aName = pSource->GetName();
+ aParent = pSource->GetParent();
+ delete pItems;
+ pItems = new SfxItemSet( ((SfxStyleSheetBase*)pSource)->GetItemSet() );
+ }
+ else
+ *this = ScStyleSaveData(); // empty
+}
+
+// -----------------------------------------------------------------------
+
+ScUndoModifyStyle::ScUndoModifyStyle( ScDocShell* pDocSh, SfxStyleFamily eFam,
+ const ScStyleSaveData& rOld, const ScStyleSaveData& rNew ) :
+ ScSimpleUndo( pDocSh ),
+ eFamily( eFam ),
+ aOldData( rOld ),
+ aNewData( rNew )
+{
+}
+
+ScUndoModifyStyle::~ScUndoModifyStyle()
+{
+}
+
+String ScUndoModifyStyle::GetComment() const
+{
+ USHORT nId = (eFamily == SFX_STYLE_FAMILY_PARA) ?
+ STR_UNDO_EDITCELLSTYLE :
+ STR_UNDO_EDITPAGESTYLE;
+ return ScGlobal::GetRscString( nId );
+}
+
+void lcl_DocStyleChanged( ScDocument* pDoc, SfxStyleSheetBase* pStyle, BOOL bRemoved )
+{
+ //! move to document or docshell
+
+ VirtualDevice aVDev;
+ Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
+ double nPPTX = aLogic.X() / 1000.0;
+ double nPPTY = aLogic.Y() / 1000.0;
+ Fraction aZoom(1,1);
+ pDoc->StyleSheetChanged( pStyle, bRemoved, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
+
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ if (pHdl)
+ pHdl->ForgetLastPattern();
+}
+
+// static
+void ScUndoModifyStyle::DoChange( ScDocShell* pDocSh, const String& rName,
+ SfxStyleFamily eStyleFamily, const ScStyleSaveData& rData )
+{
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScStyleSheetPool* pStlPool = pDoc->GetStyleSheetPool();
+ String aNewName = rData.GetName();
+ BOOL bDelete = ( aNewName.Len() == 0 ); // no new name -> delete style
+ BOOL bNew = ( rName.Len() == 0 && !bDelete ); // creating new style
+
+ SfxStyleSheetBase* pStyle = NULL;
+ if ( rName.Len() )
+ {
+ // find old style to modify
+ pStyle = pStlPool->Find( rName, eStyleFamily );
+ DBG_ASSERT( pStyle, "style not found" );
+
+ if ( pStyle && !bDelete )
+ {
+ // set new name
+ pStyle->SetName( aNewName );
+ }
+ }
+ else if ( !bDelete )
+ {
+ // create style (with new name)
+ pStyle = &pStlPool->Make( aNewName, eStyleFamily, SFXSTYLEBIT_USERDEF );
+
+ if ( eStyleFamily == SFX_STYLE_FAMILY_PARA )
+ pDoc->GetPool()->CellStyleCreated( aNewName );
+ }
+
+ if ( pStyle )
+ {
+ if ( bDelete )
+ {
+ if ( eStyleFamily == SFX_STYLE_FAMILY_PARA )
+ lcl_DocStyleChanged( pDoc, pStyle, TRUE ); // TRUE: remove usage of style
+ else
+ pDoc->RemovePageStyleInUse( rName );
+
+ // delete style
+ pStlPool->Remove( pStyle );
+ }
+ else
+ {
+ // modify style
+
+ String aNewParent = rData.GetParent();
+ if ( aNewParent != pStyle->GetParent() )
+ pStyle->SetParent( aNewParent );
+
+ SfxItemSet& rStyleSet = pStyle->GetItemSet();
+ const SfxItemSet* pNewSet = rData.GetItems();
+ DBG_ASSERT( pNewSet, "no ItemSet for style" );
+ if (pNewSet)
+ rStyleSet.Set( *pNewSet, FALSE );
+
+ if ( eStyleFamily == SFX_STYLE_FAMILY_PARA )
+ {
+ lcl_DocStyleChanged( pDoc, pStyle, FALSE ); // cell styles: row heights
+ }
+ else
+ {
+ // page styles
+
+ if ( bNew && aNewName != rName )
+ pDoc->RenamePageStyleInUse( rName, aNewName );
+
+ if (pNewSet)
+ pDoc->ModifyStyleSheet( *pStyle, *pNewSet );
+
+ pDocSh->PageStyleModified( aNewName, TRUE );
+ }
+ }
+ }
+
+ pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+
+ //! undo/redo document modifications for deleted styles
+ //! undo/redo modifications of number formatter
+}
+
+void ScUndoModifyStyle::Undo()
+{
+ BeginUndo();
+ DoChange( pDocShell, aNewData.GetName(), eFamily, aOldData );
+ EndUndo();
+}
+
+void ScUndoModifyStyle::Redo()
+{
+ BeginRedo();
+ DoChange( pDocShell, aOldData.GetName(), eFamily, aNewData );
+ EndRedo();
+}
+
+void ScUndoModifyStyle::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL ScUndoModifyStyle::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // no repeat possible
+}
+
+// -----------------------------------------------------------------------
+//
+// apply page style
+//
+ScUndoApplyPageStyle::ApplyStyleEntry::ApplyStyleEntry( SCTAB nTab, const String& rOldStyle ) :
+ mnTab( nTab ),
+ maOldStyle( rOldStyle )
+{
+}
+
+ScUndoApplyPageStyle::ScUndoApplyPageStyle( ScDocShell* pDocSh, const String& rNewStyle ) :
+ ScSimpleUndo( pDocSh ),
+ maNewStyle( rNewStyle )
+{
+}
+
+ScUndoApplyPageStyle::~ScUndoApplyPageStyle()
+{
+}
+
+void ScUndoApplyPageStyle::AddSheetAction( SCTAB nTab, const String& rOldStyle )
+{
+ maEntries.push_back( ApplyStyleEntry( nTab, rOldStyle ) );
+}
+
+String ScUndoApplyPageStyle::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_APPLYPAGESTYLE );
+}
+
+void ScUndoApplyPageStyle::Undo()
+{
+ BeginUndo();
+ for( ApplyStyleVec::const_iterator aIt = maEntries.begin(), aEnd = maEntries.end(); aIt != aEnd; ++aIt )
+ {
+ pDocShell->GetDocument()->SetPageStyle( aIt->mnTab, aIt->maOldStyle );
+ ScPrintFunc( pDocShell, pDocShell->GetPrinter(), aIt->mnTab ).UpdatePages();
+ }
+ EndUndo();
+}
+
+void ScUndoApplyPageStyle::Redo()
+{
+ BeginRedo();
+ for( ApplyStyleVec::const_iterator aIt = maEntries.begin(), aEnd = maEntries.end(); aIt != aEnd; ++aIt )
+ {
+ pDocShell->GetDocument()->SetPageStyle( aIt->mnTab, maNewStyle );
+ ScPrintFunc( pDocShell, pDocShell->GetPrinter(), aIt->mnTab ).UpdatePages();
+ }
+ EndRedo();
+}
+
+void ScUndoApplyPageStyle::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ //! set same page style to current tab
+}
+
+BOOL ScUndoApplyPageStyle::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undotab.cxx b/sc/source/ui/undo/undotab.cxx
new file mode 100644
index 000000000000..f32a33575aa1
--- /dev/null
+++ b/sc/source/ui/undo/undotab.cxx
@@ -0,0 +1,1668 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/smplhint.hxx>
+
+#include "undotab.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "sc.hrc"
+#include "undoolk.hxx"
+#include "target.hxx"
+#include "uiitems.hxx"
+#include "prnsave.hxx"
+#include "printfun.hxx"
+#include "chgtrack.hxx"
+#include "tabprotection.hxx"
+#include "viewdata.hxx"
+
+// for ScUndoRenameObject - might me moved to another file later
+#include <svx/svditer.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include "drwlayer.hxx"
+#include "scresid.hxx"
+
+extern BOOL bDrawIsInUndo; //! irgendwo als Member !!!
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Sequence;
+using ::std::auto_ptr;
+
+// STATIC DATA -----------------------------------------------------------
+
+TYPEINIT1(ScUndoInsertTab, SfxUndoAction);
+TYPEINIT1(ScUndoInsertTables, SfxUndoAction);
+TYPEINIT1(ScUndoDeleteTab, SfxUndoAction);
+TYPEINIT1(ScUndoRenameTab, SfxUndoAction);
+TYPEINIT1(ScUndoMoveTab, SfxUndoAction);
+TYPEINIT1(ScUndoCopyTab, SfxUndoAction);
+TYPEINIT1(ScUndoMakeScenario, SfxUndoAction);
+TYPEINIT1(ScUndoImportTab, SfxUndoAction);
+TYPEINIT1(ScUndoRemoveLink, SfxUndoAction);
+TYPEINIT1(ScUndoShowHideTab, SfxUndoAction);
+TYPEINIT1(ScUndoPrintRange, SfxUndoAction);
+TYPEINIT1(ScUndoScenarioFlags, SfxUndoAction);
+TYPEINIT1(ScUndoRenameObject, SfxUndoAction);
+TYPEINIT1(ScUndoLayoutRTL, SfxUndoAction);
+TYPEINIT1(ScUndoTabColor, SfxUndoAction);
+
+
+// -----------------------------------------------------------------------
+//
+// Tabelle einfuegen
+//
+
+ScUndoInsertTab::ScUndoInsertTab( ScDocShell* pNewDocShell,
+ SCTAB nTabNum,
+ BOOL bApp,
+ const String& rNewName) :
+ ScSimpleUndo( pNewDocShell ),
+ sNewName( rNewName ),
+ pDrawUndo( NULL ),
+ nTab( nTabNum ),
+ bAppend( bApp )
+{
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+ SetChangeTrack();
+}
+
+ScUndoInsertTab::~ScUndoInsertTab()
+{
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String ScUndoInsertTab::GetComment() const
+{
+ if (bAppend)
+ return ScGlobal::GetRscString( STR_UNDO_APPEND_TAB );
+ else
+ return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB );
+}
+
+void ScUndoInsertTab::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
+ pChangeTrack->AppendInsert( aRange );
+ nEndChangeAction = pChangeTrack->GetActionMax();
+ }
+ else
+ nEndChangeAction = 0;
+}
+
+void ScUndoInsertTab::Undo()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ pViewShell->SetTabNo(nTab);
+
+ pDocShell->SetInUndo( TRUE ); //! BeginUndo
+ bDrawIsInUndo = TRUE;
+ pViewShell->DeleteTable( nTab, FALSE );
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( FALSE ); //! EndUndo
+
+ DoSdrUndoAction( pDrawUndo, pDocShell->GetDocument() );
+
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nEndChangeAction, nEndChangeAction );
+
+ // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
+ pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
+}
+
+void ScUndoInsertTab::Redo()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ RedoSdrUndoAction( pDrawUndo ); // Draw Redo first
+
+ pDocShell->SetInUndo( TRUE ); //! BeginRedo
+ bDrawIsInUndo = TRUE;
+ if (bAppend)
+ pViewShell->AppendTable( sNewName, FALSE );
+ else
+ {
+ pViewShell->SetTabNo(nTab);
+ pViewShell->InsertTable( sNewName, nTab, FALSE );
+ }
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( FALSE ); //! EndRedo
+
+ SetChangeTrack();
+}
+
+void ScUndoInsertTab::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
+ Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+}
+
+BOOL ScUndoInsertTab::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+// -----------------------------------------------------------------------
+//
+// Tabellen einfuegen
+//
+
+ScUndoInsertTables::ScUndoInsertTables( ScDocShell* pNewDocShell,
+ SCTAB nTabNum,
+ BOOL bApp,SvStrings *pNewNameList) :
+ ScSimpleUndo( pNewDocShell ),
+ pDrawUndo( NULL ),
+ nTab( nTabNum ),
+ bAppend( bApp )
+{
+ pNameList = pNewNameList;
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+
+ SetChangeTrack();
+}
+
+ScUndoInsertTables::~ScUndoInsertTables()
+{
+ String *pStr=NULL;
+ if(pNameList!=NULL)
+ {
+ for(int i=0;i<pNameList->Count();i++)
+ {
+ pStr=pNameList->GetObject(sal::static_int_cast<USHORT>(i));
+ delete pStr;
+ }
+ pNameList->Remove(0,pNameList->Count());
+ delete pNameList;
+ }
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String ScUndoInsertTables::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB );
+}
+
+void ScUndoInsertTables::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ nStartChangeAction = pChangeTrack->GetActionMax() + 1;
+ nEndChangeAction = 0;
+ ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
+ for( int i = 0; i < pNameList->Count(); i++ )
+ {
+ aRange.aStart.SetTab( sal::static_int_cast<SCTAB>( nTab + i ) );
+ aRange.aEnd.SetTab( sal::static_int_cast<SCTAB>( nTab + i ) );
+ pChangeTrack->AppendInsert( aRange );
+ nEndChangeAction = pChangeTrack->GetActionMax();
+ }
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+void ScUndoInsertTables::Undo()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ pViewShell->SetTabNo(nTab);
+
+ pDocShell->SetInUndo( TRUE ); //! BeginUndo
+ bDrawIsInUndo = TRUE;
+
+ SvShorts TheTabs;
+ for(int i=0;i<pNameList->Count();i++)
+ {
+ TheTabs.Insert( sal::static_int_cast<short>(nTab+i), TheTabs.Count() );
+ }
+
+ pViewShell->DeleteTables( TheTabs, FALSE );
+ TheTabs.Remove(0,TheTabs.Count());
+
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( FALSE ); //! EndUndo
+
+ DoSdrUndoAction( pDrawUndo, pDocShell->GetDocument() );
+
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
+ pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
+}
+
+void ScUndoInsertTables::Redo()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ RedoSdrUndoAction( pDrawUndo ); // Draw Redo first
+
+ pDocShell->SetInUndo( TRUE ); //! BeginRedo
+ bDrawIsInUndo = TRUE;
+ pViewShell->SetTabNo(nTab);
+ pViewShell->InsertTables( pNameList, nTab, static_cast<SCTAB>(pNameList->Count()),FALSE );
+
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( FALSE ); //! EndRedo
+
+ SetChangeTrack();
+}
+
+void ScUndoInsertTables::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
+ Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+}
+
+BOOL ScUndoInsertTables::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//----------------------------------------------------------------------------------
+//
+// Tabelle loeschen
+//
+
+ScUndoDeleteTab::ScUndoDeleteTab( ScDocShell* pNewDocShell,const SvShorts &aTab, //SCTAB nNewTab,
+ ScDocument* pUndoDocument, ScRefUndoData* pRefData ) :
+ ScMoveUndo( pNewDocShell, pUndoDocument, pRefData, SC_UNDO_REFLAST )
+{
+ for(int i=0;i<aTab.Count();i++)
+ theTabs.Insert(aTab[sal::static_int_cast<USHORT>(i)],theTabs.Count());
+
+ SetChangeTrack();
+}
+
+ScUndoDeleteTab::~ScUndoDeleteTab()
+{
+ theTabs.Remove(0,theTabs.Count());
+}
+
+String ScUndoDeleteTab::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_DELETE_TAB );
+}
+
+void ScUndoDeleteTab::SetChangeTrack()
+{
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ {
+ ULONG nTmpChangeAction;
+ nStartChangeAction = pChangeTrack->GetActionMax() + 1;
+ nEndChangeAction = 0;
+ ScRange aRange( 0, 0, 0, MAXCOL, MAXROW, 0 );
+ for ( int i = 0; i < theTabs.Count(); i++ )
+ {
+ aRange.aStart.SetTab( theTabs[sal::static_int_cast<USHORT>(i)] );
+ aRange.aEnd.SetTab( theTabs[sal::static_int_cast<USHORT>(i)] );
+ pChangeTrack->AppendDeleteRange( aRange, pRefUndoDoc,
+ nTmpChangeAction, nEndChangeAction, (short) i );
+ }
+ }
+ else
+ nStartChangeAction = nEndChangeAction = 0;
+}
+
+SCTAB lcl_GetVisibleTabBefore( ScDocument& rDoc, SCTAB nTab )
+{
+ while ( nTab > 0 && !rDoc.IsVisible( nTab ) )
+ --nTab;
+
+ return nTab;
+}
+
+void ScUndoDeleteTab::Undo()
+{
+ BeginUndo();
+ int i=0;
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ BOOL bLink = FALSE;
+ String aName;
+
+ for(i=0;i<theTabs.Count();i++)
+ {
+ SCTAB nTab = theTabs[sal::static_int_cast<USHORT>(i)];
+ pRefUndoDoc->GetName( nTab, aName );
+
+ bDrawIsInUndo = TRUE;
+ BOOL bOk = pDoc->InsertTab( nTab, aName );
+ bDrawIsInUndo = FALSE;
+ if (bOk)
+ {
+ // Ref-Undo passiert in EndUndo
+ // pUndoDoc->UndoToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pDoc );
+ pRefUndoDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pDoc );
+
+ String aOldName;
+ pRefUndoDoc->GetName( nTab, aOldName );
+ pDoc->RenameTab( nTab, aOldName, FALSE );
+ if (pRefUndoDoc->IsLinked(nTab))
+ {
+ pDoc->SetLink( nTab, pRefUndoDoc->GetLinkMode(nTab), pRefUndoDoc->GetLinkDoc(nTab),
+ pRefUndoDoc->GetLinkFlt(nTab), pRefUndoDoc->GetLinkOpt(nTab),
+ pRefUndoDoc->GetLinkTab(nTab), pRefUndoDoc->GetLinkRefreshDelay(nTab) );
+ bLink = TRUE;
+ }
+
+ if ( pRefUndoDoc->IsScenario(nTab) )
+ {
+ pDoc->SetScenario( nTab, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pRefUndoDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
+ pDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
+ BOOL bActive = pRefUndoDoc->IsActiveScenario( nTab );
+ pDoc->SetActiveScenario( nTab, bActive );
+ }
+ pDoc->SetVisible( nTab, pRefUndoDoc->IsVisible( nTab ) );
+ pDoc->SetTabBgColor( nTab, pRefUndoDoc->GetTabBgColor(nTab) );
+ pDoc->SetSheetEvents( nTab, pRefUndoDoc->GetSheetEvents( nTab ) );
+
+ if ( pRefUndoDoc->IsTabProtected( nTab ) )
+ pDoc->SetTabProtection(nTab, pRefUndoDoc->GetTabProtection(nTab));
+
+ // Drawing-Layer passiert beim MoveUndo::EndUndo
+ // pDoc->TransferDrawPage(pRefUndoDoc, nTab,nTab);
+ }
+ }
+ if (bLink)
+ {
+ pDocShell->UpdateLinks(); // Link-Manager updaten
+ }
+
+ EndUndo(); // Draw-Undo muss vor dem Broadcast kommen!
+
+ ScChangeTrack* pChangeTrack = pDocShell->GetDocument()->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->Undo( nStartChangeAction, nEndChangeAction );
+
+ for(i=0;i<theTabs.Count();i++)
+ {
+ pDocShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, theTabs[sal::static_int_cast<USHORT>(i)]) );
+ }
+ SfxApplication* pSfxApp = SFX_APP(); // Navigator
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+
+ pDocShell->PostPaint(0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_ALL ); // incl. Extras
+
+ // nicht ShowTable wegen SetTabNo(..., TRUE):
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetTabNo( lcl_GetVisibleTabBefore( *pDoc, theTabs[0] ), TRUE );
+
+// EndUndo();
+}
+
+void ScUndoDeleteTab::Redo()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ pViewShell->SetTabNo( lcl_GetVisibleTabBefore( *pDocShell->GetDocument(), theTabs[0] ) );
+
+ RedoSdrUndoAction( pDrawUndo ); // Draw Redo first
+
+ pDocShell->SetInUndo( TRUE ); //! BeginRedo
+ bDrawIsInUndo = TRUE;
+ pViewShell->DeleteTables( theTabs, FALSE );
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( TRUE ); //! EndRedo
+
+ SetChangeTrack();
+
+ // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
+ pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
+}
+
+void ScUndoDeleteTab::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ScTabViewShell* pViewShell = ((ScTabViewTarget&)rTarget).GetViewShell();
+ pViewShell->DeleteTable( pViewShell->GetViewData()->GetTabNo(), TRUE );
+ }
+}
+
+BOOL ScUndoDeleteTab::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+//---------------------------------------------------------------------------------
+//
+// Tabelle umbenennen
+//
+
+ScUndoRenameTab::ScUndoRenameTab( ScDocShell* pNewDocShell,
+ SCTAB nT,
+ const String& rOldName,
+ const String& rNewName) :
+ ScSimpleUndo( pNewDocShell ),
+ nTab ( nT )
+{
+ sOldName = rOldName;
+ sNewName = rNewName;
+}
+
+ScUndoRenameTab::~ScUndoRenameTab()
+{
+}
+
+String ScUndoRenameTab::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_RENAME_TAB );
+}
+
+void ScUndoRenameTab::DoChange( SCTAB nTabP, const String& rName ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->RenameTab( nTabP, rName );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator
+
+ pDocShell->PostPaintGridAll();
+ pDocShell->PostPaintExtras();
+ pDocShell->PostDataChanged();
+
+ // Der Tabellenname koennte in einer Formel vorkommen...
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->UpdateInputHandler();
+}
+
+void ScUndoRenameTab::Undo()
+{
+ DoChange(nTab, sOldName);
+}
+
+void ScUndoRenameTab::Redo()
+{
+ DoChange(nTab, sNewName);
+}
+
+void ScUndoRenameTab::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // Repeat macht keinen Sinn
+}
+
+BOOL ScUndoRenameTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//----------------------------------------------------------------------------------
+//
+// Tabelle verschieben
+//
+
+ScUndoMoveTab::ScUndoMoveTab( ScDocShell* pNewDocShell,
+ const SvShorts &aOldTab,
+ const SvShorts &aNewTab) :
+ ScSimpleUndo( pNewDocShell )
+{
+ int i;
+ for(i=0;i<aOldTab.Count();i++)
+ theOldTabs.Insert(aOldTab[sal::static_int_cast<USHORT>(i)],theOldTabs.Count());
+
+ for(i=0;i<aNewTab.Count();i++)
+ theNewTabs.Insert(aNewTab[sal::static_int_cast<USHORT>(i)],theNewTabs.Count());
+}
+
+ScUndoMoveTab::~ScUndoMoveTab()
+{
+ theNewTabs.Remove(0,theNewTabs.Count());
+ theOldTabs.Remove(0,theOldTabs.Count());
+}
+
+String ScUndoMoveTab::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_MOVE_TAB );
+}
+
+void ScUndoMoveTab::DoChange( BOOL bUndo ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (bUndo) // UnDo
+ {
+ for(int i=theNewTabs.Count()-1;i>=0;i--)
+ {
+ SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nOldTab = theOldTabs[sal::static_int_cast<USHORT>(i)];
+ if (nDestTab > MAXTAB) // angehaengt ?
+ nDestTab = pDoc->GetTableCount() - 1;
+
+ pDoc->MoveTab( nDestTab, nOldTab );
+ pViewShell->GetViewData()->MoveTab( nDestTab, nOldTab );
+ pViewShell->SetTabNo( nOldTab, TRUE );
+ }
+ }
+ else
+ {
+ for(int i=0;i<theNewTabs.Count();i++)
+ {
+ SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nNewTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nOldTab = theOldTabs[sal::static_int_cast<USHORT>(i)];
+ if (nDestTab > MAXTAB) // angehaengt ?
+ nDestTab = pDoc->GetTableCount() - 1;
+
+ pDoc->MoveTab( nOldTab, nNewTab );
+ pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab );
+ pViewShell->SetTabNo( nDestTab, TRUE );
+ }
+ }
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator
+
+ pDocShell->PostPaintGridAll();
+ pDocShell->PostPaintExtras();
+ pDocShell->PostDataChanged();
+}
+
+void ScUndoMoveTab::Undo()
+{
+ DoChange( TRUE );
+}
+
+void ScUndoMoveTab::Redo()
+{
+ DoChange( FALSE );
+}
+
+void ScUndoMoveTab::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // kein Repeat ! ? !
+}
+
+BOOL ScUndoMoveTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//----------------------------------------------------------------------------------
+//
+// Tabelle kopieren
+//
+
+ScUndoCopyTab::ScUndoCopyTab( ScDocShell* pNewDocShell,
+ const SvShorts &aOldTab,
+ const SvShorts &aNewTab) :
+ ScSimpleUndo( pNewDocShell ),
+ pDrawUndo( NULL )
+{
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+
+ int i;
+ for(i=0;i<aOldTab.Count();i++)
+ theOldTabs.Insert(aOldTab[sal::static_int_cast<USHORT>(i)],theOldTabs.Count());
+
+ for(i=0;i<aNewTab.Count();i++)
+ theNewTabs.Insert(aNewTab[sal::static_int_cast<USHORT>(i)],theNewTabs.Count());
+}
+
+ScUndoCopyTab::~ScUndoCopyTab()
+{
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String ScUndoCopyTab::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_COPY_TAB );
+}
+
+void ScUndoCopyTab::DoChange() const
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ if (pViewShell)
+ pViewShell->SetTabNo(theOldTabs[0],TRUE);
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator
+
+ pDocShell->PostPaintGridAll();
+ pDocShell->PostPaintExtras();
+ pDocShell->PostDataChanged();
+}
+
+void ScUndoCopyTab::Undo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ DoSdrUndoAction( pDrawUndo, pDoc ); // before the sheets are deleted
+
+ int i;
+ for(i=theNewTabs.Count()-1;i>=0;i--)
+ {
+ SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ if (nDestTab > MAXTAB) // append?
+ nDestTab = pDoc->GetTableCount() - 1;
+
+ bDrawIsInUndo = TRUE;
+ pDoc->DeleteTab(nDestTab);
+ bDrawIsInUndo = FALSE;
+ }
+
+ // ScTablesHint broadcasts after all sheets have been deleted,
+ // so sheets and draw pages are in sync!
+
+ for(i=theNewTabs.Count()-1;i>=0;i--)
+ {
+ SCTAB nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ if (nDestTab > MAXTAB) // append?
+ nDestTab = pDoc->GetTableCount() - 1;
+
+ pDocShell->Broadcast( ScTablesHint( SC_TAB_DELETED, nDestTab ) );
+ }
+
+ DoChange();
+}
+
+void ScUndoCopyTab::Redo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+
+ SCTAB nDestTab = 0;
+ for(int i=0;i<theNewTabs.Count();i++)
+ {
+ nDestTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nNewTab = theNewTabs[sal::static_int_cast<USHORT>(i)];
+ SCTAB nOldTab = theOldTabs[sal::static_int_cast<USHORT>(i)];
+ if (nDestTab > MAXTAB) // angehaengt ?
+ nDestTab = pDoc->GetTableCount() - 1;
+
+ bDrawIsInUndo = TRUE;
+ pDoc->CopyTab( nOldTab, nNewTab );
+ bDrawIsInUndo = FALSE;
+
+ pViewShell->GetViewData()->MoveTab( nOldTab, nNewTab );
+
+ SCTAB nAdjSource = nOldTab;
+ if ( nNewTab <= nOldTab )
+ ++nAdjSource; // new position of source table after CopyTab
+
+ if ( pDoc->IsScenario(nAdjSource) )
+ {
+ pDoc->SetScenario(nNewTab, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pDoc->GetScenarioData(nAdjSource, aComment, aColor, nScenFlags );
+ pDoc->SetScenarioData(nNewTab, aComment, aColor, nScenFlags );
+ BOOL bActive = pDoc->IsActiveScenario(nAdjSource);
+ pDoc->SetActiveScenario(nNewTab, bActive );
+ BOOL bVisible=pDoc->IsVisible(nAdjSource);
+ pDoc->SetVisible(nNewTab,bVisible );
+ }
+
+ if ( pDoc->IsTabProtected( nAdjSource ) )
+ pDoc->CopyTabProtection(nAdjSource, nNewTab);
+ }
+
+ RedoSdrUndoAction( pDrawUndo ); // after the sheets are inserted
+
+ pViewShell->SetTabNo( nDestTab, TRUE ); // after draw-undo
+
+ DoChange();
+
+}
+
+void ScUndoCopyTab::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // kein Repeat ! ? !
+}
+
+BOOL ScUndoCopyTab::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+//---------------------------------------------------------------------------------
+//
+// Tab Bg Color
+//
+
+ScUndoTabColor::ScUndoTabColor(
+ ScDocShell* pNewDocShell, SCTAB nT, const Color& aOTabBgColor, const Color& aNTabBgColor) :
+ ScSimpleUndo( pNewDocShell )
+{
+ ScUndoTabColorInfo aInfo(nT);
+ aInfo.maOldTabBgColor = aOTabBgColor;
+ aInfo.maNewTabBgColor = aNTabBgColor;
+ aTabColorList.push_back(aInfo);
+}
+
+ScUndoTabColor::ScUndoTabColor(
+ ScDocShell* pNewDocShell,
+ const ScUndoTabColorInfo::List& rUndoTabColorList) :
+ ScSimpleUndo(pNewDocShell),
+ aTabColorList(rUndoTabColorList)
+{
+}
+
+ScUndoTabColor::~ScUndoTabColor()
+{
+}
+
+String ScUndoTabColor::GetComment() const
+{
+ if (aTabColorList.size() > 1)
+ return ScGlobal::GetRscString(STR_UNDO_SET_MULTI_TAB_BG_COLOR);
+ return ScGlobal::GetRscString(STR_UNDO_SET_TAB_BG_COLOR);
+}
+
+void ScUndoTabColor::DoChange(bool bUndoType) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (!pDoc)
+ return;
+
+ size_t nTabColorCount = aTabColorList.size();
+ for (size_t i = 0; i < nTabColorCount; ++i)
+ {
+ const ScUndoTabColorInfo& rTabColor = aTabColorList[i];
+ pDoc->SetTabBgColor(rTabColor.mnTabId,
+ bUndoType ? rTabColor.maOldTabBgColor : rTabColor.maNewTabBgColor);
+ }
+
+ pDocShell->PostPaintExtras();
+ ScDocShellModificator aModificator( *pDocShell );
+ aModificator.SetDocumentModified();
+}
+
+void ScUndoTabColor::Undo()
+{
+ DoChange(true);
+}
+
+void ScUndoTabColor::Redo()
+{
+ DoChange(false);
+}
+
+void ScUndoTabColor::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // No Repeat
+}
+
+BOOL ScUndoTabColor::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+//
+// Szenario anlegen
+//
+
+ScUndoMakeScenario::ScUndoMakeScenario( ScDocShell* pNewDocShell,
+ SCTAB nSrc, SCTAB nDest,
+ const String& rN, const String& rC,
+ const Color& rCol, USHORT nF,
+ const ScMarkData& rMark ) :
+ ScSimpleUndo( pNewDocShell ),
+ nSrcTab( nSrc ),
+ nDestTab( nDest ),
+ aName( rN ),
+ aComment( rC ),
+ aColor( rCol ),
+ nFlags( nF ),
+ aMarkData( rMark ),
+ pDrawUndo( NULL )
+{
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+}
+
+ScUndoMakeScenario::~ScUndoMakeScenario()
+{
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String ScUndoMakeScenario::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_MAKESCENARIO );
+}
+
+void ScUndoMakeScenario::Undo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ pDocShell->SetInUndo( TRUE );
+ bDrawIsInUndo = TRUE;
+ pDoc->DeleteTab( nDestTab );
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( FALSE );
+
+ DoSdrUndoAction( pDrawUndo, pDoc );
+
+ pDocShell->PostPaint(0,0,nDestTab,MAXCOL,MAXROW,MAXTAB, PAINT_ALL);
+ pDocShell->PostDataChanged();
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetTabNo( nSrcTab, TRUE );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+
+ // SetTabNo(...,TRUE) for all views to sync with drawing layer pages
+ pDocShell->Broadcast( SfxSimpleHint( SC_HINT_FORCESETTAB ) );
+}
+
+void ScUndoMakeScenario::Redo()
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetMarkData( aMarkData );
+
+ RedoSdrUndoAction( pDrawUndo ); // Draw Redo first
+
+ pDocShell->SetInUndo( TRUE );
+ bDrawIsInUndo = TRUE;
+
+ pDocShell->MakeScenario( nSrcTab, aName, aComment, aColor, nFlags, aMarkData, FALSE );
+
+ bDrawIsInUndo = FALSE;
+ pDocShell->SetInUndo( FALSE );
+
+ if (pViewShell)
+ pViewShell->SetTabNo( nDestTab, TRUE );
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+}
+
+void ScUndoMakeScenario::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ {
+ ((ScTabViewTarget&)rTarget).GetViewShell()->MakeScenario( aName, aComment, aColor, nFlags );
+ }
+}
+
+BOOL ScUndoMakeScenario::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Tabelle einfuegen
+//
+
+ScUndoImportTab::ScUndoImportTab( ScDocShell* pShell,
+ SCTAB nNewTab, SCTAB nNewCount, BOOL bNewLink ) :
+ ScSimpleUndo( pShell ),
+ nTab( nNewTab ),
+ nCount( nNewCount ),
+ bLink( bNewLink ),
+ pRedoDoc( NULL ),
+ pDrawUndo( NULL )
+{
+ pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
+}
+
+ScUndoImportTab::~ScUndoImportTab()
+{
+ delete pRedoDoc;
+ DeleteSdrUndoAction( pDrawUndo );
+}
+
+String ScUndoImportTab::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_INSERT_TAB );
+}
+
+void ScUndoImportTab::DoChange() const
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if (pViewShell)
+ {
+ if(nTab<nTabCount)
+ {
+ pViewShell->SetTabNo(nTab,TRUE);
+ }
+ else
+ {
+ pViewShell->SetTabNo(nTab-1,TRUE);
+ }
+ }
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) ); // Navigator
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
+ PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS );
+}
+
+void ScUndoImportTab::Undo()
+{
+ //! eingefuegte Bereichsnamen etc.
+
+ SCTAB i;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bMakeRedo = !pRedoDoc;
+ if (bMakeRedo)
+ {
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, nTab,nTab+nCount-1, TRUE,TRUE );
+
+ String aOldName;
+ for (i=0; i<nCount; i++)
+ {
+ SCTAB nTabPos=nTab+i;
+
+ pDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, IDF_ALL,FALSE, pRedoDoc );
+ pDoc->GetName( nTabPos, aOldName );
+ pRedoDoc->RenameTab( nTabPos, aOldName, FALSE );
+
+ if ( pDoc->IsScenario(nTabPos) )
+ {
+ pRedoDoc->SetScenario(nTabPos, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
+ pRedoDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags );
+ BOOL bActive = pDoc->IsActiveScenario(nTabPos);
+ pRedoDoc->SetActiveScenario(nTabPos, bActive );
+ BOOL bVisible=pDoc->IsVisible(nTabPos);
+ pRedoDoc->SetVisible(nTabPos,bVisible );
+ }
+
+ if ( pDoc->IsTabProtected( nTabPos ) )
+ pRedoDoc->SetTabProtection(nTabPos, pDoc->GetTabProtection(nTabPos));
+ }
+
+ }
+
+ DoSdrUndoAction( pDrawUndo, pDoc ); // before the sheets are deleted
+
+ bDrawIsInUndo = TRUE;
+ for (i=0; i<nCount; i++)
+ pDoc->DeleteTab( nTab );
+ bDrawIsInUndo = FALSE;
+
+ DoChange();
+}
+
+void ScUndoImportTab::Redo()
+{
+ if (!pRedoDoc)
+ {
+ DBG_ERROR("wo ist mein Redo-Document?");
+ return;
+ }
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ String aName;
+ SCTAB i;
+ for (i=0; i<nCount; i++) // first insert all sheets (#63304#)
+ {
+ SCTAB nTabPos=nTab+i;
+ pRedoDoc->GetName(nTabPos,aName);
+ bDrawIsInUndo = TRUE;
+ pDoc->InsertTab(nTabPos,aName);
+ bDrawIsInUndo = FALSE;
+ }
+ for (i=0; i<nCount; i++) // then copy into inserted sheets
+ {
+ SCTAB nTabPos=nTab+i;
+ pRedoDoc->CopyToDocument(0,0,nTabPos, MAXCOL,MAXROW,nTabPos, IDF_ALL,FALSE, pDoc );
+
+ if ( pRedoDoc->IsScenario(nTabPos) )
+ {
+ pDoc->SetScenario(nTabPos, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pRedoDoc->GetScenarioData(nTabPos, aComment, aColor, nScenFlags );
+ pDoc->SetScenarioData(nTabPos, aComment, aColor, nScenFlags );
+ BOOL bActive = pRedoDoc->IsActiveScenario(nTabPos);
+ pDoc->SetActiveScenario(nTabPos, bActive );
+ BOOL bVisible=pRedoDoc->IsVisible(nTabPos);
+ pDoc->SetVisible(nTabPos,bVisible );
+ }
+
+ if ( pRedoDoc->IsTabProtected( nTabPos ) )
+ pDoc->SetTabProtection(nTabPos, pRedoDoc->GetTabProtection(nTabPos));
+ }
+
+ RedoSdrUndoAction( pDrawUndo ); // after the sheets are inserted
+
+ DoChange();
+}
+
+void ScUndoImportTab::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
+ Execute(FID_INS_TABLE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+}
+
+BOOL ScUndoImportTab::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Tabellen-Verknuepfung aufheben
+//
+
+ScUndoRemoveLink::ScUndoRemoveLink( ScDocShell* pShell, const String& rDoc ) :
+ ScSimpleUndo( pShell ),
+ aDocName( rDoc ),
+ nCount( 0 )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pTabs = new SCTAB[nTabCount];
+ pModes = new BYTE[nTabCount];
+ pTabNames = new String[nTabCount];
+
+ for (SCTAB i=0; i<nTabCount; i++)
+ {
+ BYTE nMode = pDoc->GetLinkMode(i);
+ if (nMode)
+ if (pDoc->GetLinkDoc(i) == aDocName)
+ {
+ if (!nCount)
+ {
+ aFltName = pDoc->GetLinkFlt(i);
+ aOptions = pDoc->GetLinkOpt(i);
+ nRefreshDelay = pDoc->GetLinkRefreshDelay(i);
+ }
+ else
+ {
+ DBG_ASSERT(aFltName == pDoc->GetLinkFlt(i) &&
+ aOptions == pDoc->GetLinkOpt(i),
+ "verschiedene Filter fuer ein Dokument?");
+ }
+ pTabs[nCount] = i;
+ pModes[nCount] = nMode;
+ pTabNames[nCount] = pDoc->GetLinkTab(i);
+ ++nCount;
+ }
+ }
+}
+
+ScUndoRemoveLink::~ScUndoRemoveLink()
+{
+ delete pTabs;
+ delete pModes;
+ delete[] pTabNames;
+}
+
+String ScUndoRemoveLink::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_REMOVELINK );
+}
+
+void ScUndoRemoveLink::DoChange( BOOL bLink ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ String aEmpty;
+ for (USHORT i=0; i<nCount; i++)
+ if (bLink) // establish link
+ pDoc->SetLink( pTabs[i], pModes[i], aDocName, aFltName, aOptions, pTabNames[i], nRefreshDelay );
+ else // remove link
+ pDoc->SetLink( pTabs[i], SC_LINK_NONE, aEmpty, aEmpty, aEmpty, aEmpty, 0 );
+ pDocShell->UpdateLinks();
+}
+
+void ScUndoRemoveLink::Undo()
+{
+ DoChange( TRUE );
+}
+
+void ScUndoRemoveLink::Redo()
+{
+ DoChange( FALSE );
+}
+
+void ScUndoRemoveLink::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+BOOL ScUndoRemoveLink::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+// -----------------------------------------------------------------------
+//
+// Tabellen ein-/ausblenden
+//
+
+ScUndoShowHideTab::ScUndoShowHideTab( ScDocShell* pShell, SCTAB nNewTab, BOOL bNewShow ) :
+ ScSimpleUndo( pShell ),
+ nTab( nNewTab ),
+ bShow( bNewShow )
+{
+}
+
+ScUndoShowHideTab::~ScUndoShowHideTab()
+{
+}
+
+void ScUndoShowHideTab::DoChange( BOOL bShowP ) const
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->SetVisible( nTab, bShowP );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetTabNo(nTab,TRUE);
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pDocShell->SetDocumentModified();
+}
+
+void ScUndoShowHideTab::Undo()
+{
+ DoChange(!bShow);
+}
+
+void ScUndoShowHideTab::Redo()
+{
+ DoChange(bShow);
+}
+
+void ScUndoShowHideTab::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
+ Execute( bShow ? FID_TABLE_SHOW : FID_TABLE_HIDE,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+}
+
+BOOL ScUndoShowHideTab::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+String ScUndoShowHideTab::GetComment() const
+{
+ USHORT nId = bShow ? STR_UNDO_SHOWTAB : STR_UNDO_HIDETAB;
+ return ScGlobal::GetRscString( nId );
+}
+
+// ============================================================================
+
+ScUndoDocProtect::ScUndoDocProtect(ScDocShell* pShell, auto_ptr<ScDocProtection> pProtectSettings) :
+ ScSimpleUndo(pShell),
+ mpProtectSettings(pProtectSettings)
+{
+}
+
+ScUndoDocProtect::~ScUndoDocProtect()
+{
+}
+
+void ScUndoDocProtect::DoProtect(bool bProtect)
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ if (bProtect)
+ {
+ // set protection.
+ auto_ptr<ScDocProtection> pCopy(new ScDocProtection(*mpProtectSettings));
+ pCopy->setProtected(true);
+ pDoc->SetDocProtection(pCopy.get());
+ }
+ else
+ {
+ // remove protection.
+ pDoc->SetDocProtection(NULL);
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->UpdateLayerLocks();
+ pViewShell->UpdateInputHandler(TRUE); // damit sofort wieder eingegeben werden kann
+ }
+
+ pDocShell->PostPaintGridAll();
+}
+
+void ScUndoDocProtect::Undo()
+{
+ BeginUndo();
+ DoProtect(!mpProtectSettings->isProtected());
+ EndUndo();
+}
+
+void ScUndoDocProtect::Redo()
+{
+ BeginRedo();
+ DoProtect(mpProtectSettings->isProtected());
+ EndRedo();
+}
+
+void ScUndoDocProtect::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+BOOL ScUndoDocProtect::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // gippsnich
+}
+
+String ScUndoDocProtect::GetComment() const
+{
+ USHORT nId = mpProtectSettings->isProtected() ? STR_UNDO_PROTECT_DOC : STR_UNDO_UNPROTECT_DOC;
+ return ScGlobal::GetRscString( nId );
+}
+
+// ============================================================================
+
+ScUndoTabProtect::ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab, auto_ptr<ScTableProtection> pProtectSettings) :
+ ScSimpleUndo(pShell),
+ mnTab(nTab),
+ mpProtectSettings(pProtectSettings)
+{
+}
+
+ScUndoTabProtect::~ScUndoTabProtect()
+{
+}
+
+void ScUndoTabProtect::DoProtect(bool bProtect)
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ if (bProtect)
+ {
+ // set protection.
+ auto_ptr<ScTableProtection> pCopy(new ScTableProtection(*mpProtectSettings));
+ pCopy->setProtected(true);
+ pDoc->SetTabProtection(mnTab, pCopy.get());
+ }
+ else
+ {
+ // remove protection.
+ pDoc->SetTabProtection(mnTab, NULL);
+ }
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ pViewShell->UpdateLayerLocks();
+ pViewShell->UpdateInputHandler(TRUE); // damit sofort wieder eingegeben werden kann
+ }
+
+ pDocShell->PostPaintGridAll();
+}
+
+void ScUndoTabProtect::Undo()
+{
+ BeginUndo();
+ DoProtect(!mpProtectSettings->isProtected());
+ EndUndo();
+}
+
+void ScUndoTabProtect::Redo()
+{
+ BeginRedo();
+ DoProtect(mpProtectSettings->isProtected());
+ EndRedo();
+}
+
+void ScUndoTabProtect::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+BOOL ScUndoTabProtect::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // gippsnich
+}
+
+String ScUndoTabProtect::GetComment() const
+{
+ USHORT nId = mpProtectSettings->isProtected() ? STR_UNDO_PROTECT_TAB : STR_UNDO_UNPROTECT_TAB;
+ return ScGlobal::GetRscString( nId );
+}
+
+// -----------------------------------------------------------------------
+//
+// Druck-/Wiederholungsbereiche aendern
+//
+
+ScUndoPrintRange::ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
+ ScPrintRangeSaver* pOld, ScPrintRangeSaver* pNew ) :
+ ScSimpleUndo( pShell ),
+ nTab( nNewTab ),
+ pOldRanges( pOld ),
+ pNewRanges( pNew )
+{
+}
+
+ScUndoPrintRange::~ScUndoPrintRange()
+{
+ delete pOldRanges;
+ delete pNewRanges;
+}
+
+void ScUndoPrintRange::DoChange(BOOL bUndo)
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (bUndo)
+ pDoc->RestorePrintRanges( *pOldRanges );
+ else
+ pDoc->RestorePrintRanges( *pNewRanges );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetTabNo( nTab );
+
+ ScPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab ).UpdatePages();
+
+ pDocShell->PostPaint( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab), PAINT_GRID );
+}
+
+void ScUndoPrintRange::Undo()
+{
+ BeginUndo();
+ DoChange( TRUE );
+ EndUndo();
+}
+
+void ScUndoPrintRange::Redo()
+{
+ BeginRedo();
+ DoChange( FALSE );
+ EndRedo();
+}
+
+void ScUndoPrintRange::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // gippsnich
+}
+
+BOOL ScUndoPrintRange::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE; // gippsnich
+}
+
+String ScUndoPrintRange::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_PRINTRANGES );
+}
+
+
+//------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------------
+//
+// Szenario-Flags
+//
+
+ScUndoScenarioFlags::ScUndoScenarioFlags( ScDocShell* pNewDocShell, SCTAB nT,
+ const String& rON, const String& rNN, const String& rOC, const String& rNC,
+ const Color& rOCol, const Color& rNCol, USHORT nOF, USHORT nNF ) :
+ ScSimpleUndo( pNewDocShell ),
+ nTab ( nT ),
+ aOldName ( rON ),
+ aNewName ( rNN ),
+ aOldComment ( rOC ),
+ aNewComment ( rNC ),
+ aOldColor ( rOCol ),
+ aNewColor ( rNCol ),
+ nOldFlags ( nOF ),
+ nNewFlags ( nNF )
+{
+}
+
+ScUndoScenarioFlags::~ScUndoScenarioFlags()
+{
+}
+
+String ScUndoScenarioFlags::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_EDITSCENARIO );
+}
+
+void ScUndoScenarioFlags::Undo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ pDoc->RenameTab( nTab, aOldName );
+ pDoc->SetScenarioData( nTab, aOldComment, aOldColor, nOldFlags );
+
+ pDocShell->PostPaintGridAll();
+ // Der Tabellenname koennte in einer Formel vorkommen...
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->UpdateInputHandler();
+
+ if ( aOldName != aNewName )
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+}
+
+void ScUndoScenarioFlags::Redo()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ pDoc->RenameTab( nTab, aNewName );
+ pDoc->SetScenarioData( nTab, aNewComment, aNewColor, nNewFlags );
+
+ pDocShell->PostPaintGridAll();
+ // Der Tabellenname koennte in einer Formel vorkommen...
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->UpdateInputHandler();
+
+ if ( aOldName != aNewName )
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+}
+
+void ScUndoScenarioFlags::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+ // Repeat macht keinen Sinn
+}
+
+BOOL ScUndoScenarioFlags::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+
+//---------------------------------------------------------------------------------
+//
+// rename object
+// (move to different file?)
+//
+
+ScUndoRenameObject::ScUndoRenameObject( ScDocShell* pNewDocShell, const String& rPN,
+ const String& rON, const String& rNN ) :
+ ScSimpleUndo( pNewDocShell ),
+ aPersistName( rPN ),
+ aOldName ( rON ),
+ aNewName ( rNN )
+{
+}
+
+ScUndoRenameObject::~ScUndoRenameObject()
+{
+}
+
+String ScUndoRenameObject::GetComment() const
+{
+ // string resource shared with title for dialog
+ return String( ScResId(SCSTR_RENAMEOBJECT) );
+}
+
+SdrObject* ScUndoRenameObject::GetObject()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if ( pDrawLayer )
+ {
+ USHORT nCount = pDrawLayer->GetPageCount();
+ for (USHORT nTab=0; nTab<nCount; nTab++)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(nTab);
+ DBG_ASSERT(pPage,"Page ?");
+
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 &&
+ ((SdrOle2Obj*)pObject)->GetPersistName() == aPersistName )
+ {
+ return pObject;
+ }
+
+ pObject = aIter.Next();
+ }
+ }
+ }
+ DBG_ERROR("Object not found");
+ return NULL;
+}
+
+void ScUndoRenameObject::Undo()
+{
+ BeginUndo();
+ SdrObject* pObj = GetObject();
+ if ( pObj )
+ pObj->SetName( aOldName );
+ EndUndo();
+}
+
+void ScUndoRenameObject::Redo()
+{
+ BeginRedo();
+ SdrObject* pObj = GetObject();
+ if ( pObj )
+ pObj->SetName( aNewName );
+ EndRedo();
+}
+
+void ScUndoRenameObject::Repeat(SfxRepeatTarget& /* rTarget */)
+{
+}
+
+BOOL ScUndoRenameObject::CanRepeat(SfxRepeatTarget& /* rTarget */) const
+{
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+//
+// Switch sheet between left-to-right and right-to-left
+//
+
+ScUndoLayoutRTL::ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, BOOL bNewRTL ) :
+ ScSimpleUndo( pShell ),
+ nTab( nNewTab ),
+ bRTL( bNewRTL )
+{
+}
+
+ScUndoLayoutRTL::~ScUndoLayoutRTL()
+{
+}
+
+void ScUndoLayoutRTL::DoChange( BOOL bNew )
+{
+ pDocShell->SetInUndo( TRUE );
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->SetLayoutRTL( nTab, bNew );
+
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ pViewShell->SetTabNo(nTab,TRUE);
+
+ pDocShell->SetDocumentModified();
+
+ pDocShell->SetInUndo( FALSE );
+}
+
+void ScUndoLayoutRTL::Undo()
+{
+ DoChange(!bRTL);
+}
+
+void ScUndoLayoutRTL::Redo()
+{
+ DoChange(bRTL);
+}
+
+void ScUndoLayoutRTL::Repeat(SfxRepeatTarget& rTarget)
+{
+ if (rTarget.ISA(ScTabViewTarget))
+ ((ScTabViewTarget&)rTarget).GetViewShell()->GetViewData()->GetDispatcher().
+ Execute( FID_TAB_RTL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+}
+
+BOOL ScUndoLayoutRTL::CanRepeat(SfxRepeatTarget& rTarget) const
+{
+ return (rTarget.ISA(ScTabViewTarget));
+}
+
+String ScUndoLayoutRTL::GetComment() const
+{
+ return ScGlobal::GetRscString( STR_UNDO_TAB_RTL );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/undo/undoutil.cxx b/sc/source/ui/undo/undoutil.cxx
new file mode 100644
index 000000000000..6c8066dd0c38
--- /dev/null
+++ b/sc/source/ui/undo/undoutil.cxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "undoutil.hxx"
+
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "dbcolect.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+
+void ScUndoUtil::MarkSimpleBlock( ScDocShell* /* pDocShell */,
+ SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
+ SCCOL nEndX, SCROW nEndY, SCTAB nEndZ )
+{
+ ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
+ if (pViewShell)
+ {
+ SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
+ if ( nViewTab < nStartZ || nViewTab > nEndZ )
+ pViewShell->SetTabNo( nStartZ );
+
+ pViewShell->DoneBlockMode();
+ pViewShell->MoveCursorAbs( nStartX, nStartY, SC_FOLLOW_JUMP, FALSE, FALSE );
+ pViewShell->InitOwnBlockMode();
+ pViewShell->GetViewData()->GetMarkData().
+ SetMarkArea( ScRange( nStartX, nStartY, nStartZ, nEndX, nEndY, nEndZ ) );
+ pViewShell->MarkDataChanged();
+ }
+}
+
+
+void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
+ const ScAddress& rBlockStart,
+ const ScAddress& rBlockEnd )
+{
+ MarkSimpleBlock( pDocShell, rBlockStart.Col(), rBlockStart.Row(), rBlockStart.Tab(),
+ rBlockEnd.Col(), rBlockEnd.Row(), rBlockEnd.Tab() );
+}
+
+
+void ScUndoUtil::MarkSimpleBlock( ScDocShell* pDocShell,
+ const ScRange& rRange )
+{
+ MarkSimpleBlock( pDocShell, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aStart.Tab(),
+ rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aEnd.Tab() );
+}
+
+
+
+ScDBData* ScUndoUtil::GetOldDBData( ScDBData* pUndoData, ScDocument* pDoc, SCTAB nTab,
+ SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
+{
+ ScDBData* pRet = pDoc->GetDBAtArea( nTab, nCol1, nRow1, nCol2, nRow2 );
+
+ if (!pRet)
+ {
+ BOOL bWasTemp = FALSE;
+ if ( pUndoData )
+ {
+ String aName;
+ pUndoData->GetName( aName );
+ if ( aName == ScGlobal::GetRscString( STR_DB_NONAME ) )
+ bWasTemp = TRUE;
+ }
+ DBG_ASSERT(bWasTemp, "Undo: didn't find database range");
+
+ USHORT nIndex;
+ ScDBCollection* pColl = pDoc->GetDBCollection();
+ if (pColl->SearchName( ScGlobal::GetRscString( STR_DB_NONAME ), nIndex ))
+ pRet = (*pColl)[nIndex];
+ else
+ {
+ pRet = new ScDBData( ScGlobal::GetRscString( STR_DB_NONAME ), nTab,
+ nCol1,nRow1, nCol2,nRow2, TRUE,
+ pDoc->HasColHeader( nCol1,nRow1,nCol2,nRow2,nTab ) );
+ pColl->Insert( pRet );
+ }
+ }
+
+ return pRet;
+}
+
+
+void ScUndoUtil::PaintMore( ScDocShell* pDocShell,
+ const ScRange& rRange )
+{
+ SCCOL nCol1 = rRange.aStart.Col();
+ SCROW nRow1 = rRange.aStart.Row();
+ SCCOL nCol2 = rRange.aEnd.Col();
+ SCROW nRow2 = rRange.aEnd.Row();
+ if (nCol1 > 0) --nCol1;
+ if (nRow1 > 0) --nRow1;
+ if (nCol2<MAXCOL) ++nCol2;
+ if (nRow2<MAXROW) ++nRow2;
+
+ pDocShell->PostPaint( nCol1,nRow1,rRange.aStart.Tab(),
+ nCol2,nRow2,rRange.aEnd.Tab(), PAINT_GRID );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/ChartRangeSelectionListener.cxx b/sc/source/ui/unoobj/ChartRangeSelectionListener.cxx
new file mode 100644
index 000000000000..95976b1054ab
--- /dev/null
+++ b/sc/source/ui/unoobj/ChartRangeSelectionListener.cxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "ChartRangeSelectionListener.hxx"
+
+#include <com/sun/star/chart2/data/XRangeHighlighter.hpp>
+
+#include <sfx2/viewfrm.hxx>
+#include "tabvwsh.hxx"
+#include "unonames.hxx"
+#include "miscuno.hxx"
+
+using namespace ::com::sun::star;
+
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::rtl::OUString;
+
+SC_SIMPLE_SERVICE_INFO( ScChartRangeSelectionListener, "ScChartRangeSelectionListener",
+ SC_SERVICENAME_CHRANGEHILIGHT )
+
+ScChartRangeSelectionListener::ScChartRangeSelectionListener( ScTabViewShell * pViewShell ) :
+ ScChartRangeSelectionListener_Base( m_aMutex ),
+ m_pViewShell( pViewShell )
+{}
+
+ScChartRangeSelectionListener::~ScChartRangeSelectionListener()
+{}
+
+// ____ XModifyListener ____
+void SAL_CALL ScChartRangeSelectionListener::selectionChanged( const lang::EventObject& aEvent )
+ throw (uno::RuntimeException)
+{
+ Reference< chart2::data::XRangeHighlighter > xRangeHighlighter( aEvent.Source, uno::UNO_QUERY );
+ if( xRangeHighlighter.is())
+ {
+ Sequence< chart2::data::HighlightedRange > aRanges( xRangeHighlighter->getSelectedRanges());
+
+ // search the view on which the chart is active
+
+ if( m_pViewShell )
+ {
+ m_pViewShell->DoChartSelection( aRanges );
+ }
+// SfxViewFrame *pFrame = SfxViewFrame::GetFirst( m_pDocShell );
+// while (pFrame)
+// {
+// SfxViewShell* pSh = pFrame->GetViewShell();
+// if (pSh && pSh->ISA(ScTabViewShell))
+// {
+// ScTabViewShell* pViewSh = (ScTabViewShell*)pSh;
+// }
+// pFrame = SfxViewFrame::GetNext( *pFrame, m_pDocShell );
+// }
+ }
+}
+
+// ____ XEventListener ____
+void SAL_CALL ScChartRangeSelectionListener::disposing( const lang::EventObject& /*Source*/ )
+ throw (uno::RuntimeException)
+{
+}
+
+// ____ WeakComponentImplHelperBase ____
+void SAL_CALL ScChartRangeSelectionListener::disposing()
+{
+ m_pViewShell = 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/addruno.cxx b/sc/source/ui/unoobj/addruno.cxx
new file mode 100644
index 000000000000..e9618d43210c
--- /dev/null
+++ b/sc/source/ui/unoobj/addruno.cxx
@@ -0,0 +1,329 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <svl/itemprop.hxx>
+#include <vcl/svapp.hxx>
+
+#include "docsh.hxx"
+#include "unonames.hxx"
+#include "miscuno.hxx"
+#include "convuno.hxx"
+#include "addruno.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+ScAddressConversionObj::ScAddressConversionObj(ScDocShell* pDocSh, sal_Bool bForRange) :
+ pDocShell( pDocSh ),
+ nRefSheet( 0 ),
+ bIsRange( bForRange )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScAddressConversionObj::~ScAddressConversionObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScAddressConversionObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // invalid
+ }
+}
+
+sal_Bool ScAddressConversionObj::ParseUIString( const String& rUIString, ::formula::FormulaGrammar::AddressConvention eConv )
+{
+ if (!pDocShell)
+ return sal_False;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sal_Bool bSuccess = sal_False;
+ if ( bIsRange )
+ {
+ USHORT nResult = aRange.ParseAny( rUIString, pDoc, eConv );
+ if ( nResult & SCA_VALID )
+ {
+ if ( ( nResult & SCA_TAB_3D ) == 0 )
+ aRange.aStart.SetTab( static_cast<SCTAB>(nRefSheet) );
+ if ( ( nResult & SCA_TAB2_3D ) == 0 )
+ aRange.aEnd.SetTab( aRange.aStart.Tab() );
+ // different sheets are not supported in CellRangeAddress
+ if ( aRange.aStart.Tab() == aRange.aEnd.Tab() )
+ bSuccess = sal_True;
+ }
+ }
+ else
+ {
+ USHORT nResult = aRange.aStart.Parse( rUIString, pDoc, eConv );
+ if ( nResult & SCA_VALID )
+ {
+ if ( ( nResult & SCA_TAB_3D ) == 0 )
+ aRange.aStart.SetTab( static_cast<SCTAB>(nRefSheet) );
+ bSuccess = sal_True;
+ }
+ }
+ return bSuccess;
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAddressConversionObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( bIsRange )
+ {
+ static SfxItemPropertyMapEntry aPropertyMap[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ADDRESS), 0, &getCppuType((table::CellRangeAddress*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PERSREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_XL_A1_REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_REFSHEET), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_UIREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static uno::Reference<beans::XPropertySetInfo> aRef(new SfxItemPropertySetInfo( aPropertyMap ));
+ return aRef;
+ }
+ else
+ {
+ static SfxItemPropertyMapEntry aPropertyMap[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ADDRESS), 0, &getCppuType((table::CellAddress*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PERSREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_XL_A1_REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_REFSHEET), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_UIREPR), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static uno::Reference<beans::XPropertySetInfo> aRef(new SfxItemPropertySetInfo( aPropertyMap ));
+ return aRef;
+ }
+}
+
+void SAL_CALL ScAddressConversionObj::setPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ sal_Bool bSuccess = sal_False;
+ String aNameStr(aPropertyName);
+ if ( aNameStr.EqualsAscii( SC_UNONAME_ADDRESS ) )
+ {
+ // read the cell/range address from API struct
+ if ( bIsRange )
+ {
+ table::CellRangeAddress aRangeAddress;
+ if ( aValue >>= aRangeAddress )
+ {
+ ScUnoConversion::FillScRange( aRange, aRangeAddress );
+ bSuccess = sal_True;
+ }
+ }
+ else
+ {
+ table::CellAddress aCellAddress;
+ if ( aValue >>= aCellAddress )
+ {
+ ScUnoConversion::FillScAddress( aRange.aStart, aCellAddress );
+ bSuccess = sal_True;
+ }
+ }
+ }
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_REFSHEET ) )
+ {
+ // set the reference sheet
+ sal_Int32 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ {
+ nRefSheet = nIntVal;
+ bSuccess = sal_True;
+ }
+ }
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_UIREPR ) )
+ {
+ // parse the UI representation string
+ rtl::OUString sRepresentation;
+ if (aValue >>= sRepresentation)
+ {
+ String aUIString = sRepresentation;
+ bSuccess = ParseUIString( aUIString );
+ }
+ }
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) || aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
+ {
+ ::formula::FormulaGrammar::AddressConvention aConv = ::formula::FormulaGrammar::CONV_OOO;
+ if ( aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
+ aConv = ::formula::FormulaGrammar::CONV_XL_A1;
+ // parse the file format string
+ rtl::OUString sRepresentation;
+ if (aValue >>= sRepresentation)
+ {
+ String aUIString(sRepresentation);
+
+ // cell or range: strip a single "." at the start
+ if ( aUIString.GetChar(0) == (sal_Unicode) '.' )
+ aUIString.Erase( 0, 1 );
+
+ if ( bIsRange )
+ {
+ // range: also strip a "." after the last colon
+ sal_Int32 nColon = rtl::OUString(aUIString).lastIndexOf( (sal_Unicode) ':' );
+ if ( nColon >= 0 && nColon < aUIString.Len() - 1 &&
+ aUIString.GetChar((xub_StrLen)nColon+1) == (sal_Unicode) '.' )
+ aUIString.Erase( (xub_StrLen)nColon+1, 1 );
+ }
+
+ // parse the rest like a UI string
+ bSuccess = ParseUIString( aUIString, aConv );
+ }
+ }
+ else
+ throw beans::UnknownPropertyException();
+
+ if ( !bSuccess )
+ throw lang::IllegalArgumentException();
+}
+
+uno::Any SAL_CALL ScAddressConversionObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ uno::Any aRet;
+
+ String aNameStr(aPropertyName);
+ if ( aNameStr.EqualsAscii( SC_UNONAME_ADDRESS ) )
+ {
+ if ( bIsRange )
+ {
+ table::CellRangeAddress aRangeAddress;
+ ScUnoConversion::FillApiRange( aRangeAddress, aRange );
+ aRet <<= aRangeAddress;
+ }
+ else
+ {
+ table::CellAddress aCellAddress;
+ ScUnoConversion::FillApiAddress( aCellAddress, aRange.aStart );
+ aRet <<= aCellAddress;
+ }
+ }
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_REFSHEET ) )
+ {
+ aRet <<= nRefSheet;
+ }
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_UIREPR ) )
+ {
+ // generate UI representation string - include sheet only if different from ref sheet
+ String aFormatStr;
+ USHORT nFlags = SCA_VALID;
+ if ( aRange.aStart.Tab() != nRefSheet )
+ nFlags |= SCA_TAB_3D;
+ if ( bIsRange )
+ aRange.Format( aFormatStr, nFlags, pDoc );
+ else
+ aRange.aStart.Format( aFormatStr, nFlags, pDoc );
+ aRet <<= rtl::OUString( aFormatStr );
+ }
+ else if ( aNameStr.EqualsAscii( SC_UNONAME_PERSREPR ) || aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
+ {
+ ::formula::FormulaGrammar::AddressConvention aConv = ::formula::FormulaGrammar::CONV_OOO;
+ if ( aNameStr.EqualsAscii( SC_UNONAME_XL_A1_REPR ) )
+ aConv = ::formula::FormulaGrammar::CONV_XL_A1;
+
+ // generate file format string - always include sheet
+ String aFormatStr;
+ aRange.aStart.Format( aFormatStr, SCA_VALID | SCA_TAB_3D, pDoc, aConv );
+ if ( bIsRange )
+ {
+ // manually concatenate range so both parts always have the sheet name
+ aFormatStr.Append( (sal_Unicode) ':' );
+ String aSecond;
+ USHORT nFlags = SCA_VALID;
+ if( aConv != ::formula::FormulaGrammar::CONV_XL_A1 )
+ nFlags |= SCA_TAB_3D;
+ aRange.aEnd.Format( aSecond, SCA_VALID | SCA_TAB_3D, pDoc, aConv );
+ aFormatStr.Append( aSecond );
+ }
+ aRet <<= rtl::OUString( aFormatStr );
+ }
+ else
+ throw beans::UnknownPropertyException();
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAddressConversionObj )
+
+// lang::XServiceInfo
+
+rtl::OUString SAL_CALL ScAddressConversionObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScAddressConversionObj" );
+}
+
+sal_Bool SAL_CALL ScAddressConversionObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( bIsRange ? SC_SERVICENAME_RANGEADDRESS
+ : SC_SERVICENAME_CELLADDRESS );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScAddressConversionObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( bIsRange ? SC_SERVICENAME_RANGEADDRESS
+ : SC_SERVICENAME_CELLADDRESS );
+ return aRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx
new file mode 100644
index 000000000000..7ac66db2d5df
--- /dev/null
+++ b/sc/source/ui/unoobj/afmtuno.cxx
@@ -0,0 +1,886 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "scitems.hxx"
+#include <editeng/memberids.hrc>
+#include <tools/debug.hxx>
+#include <tools/shl.hxx>
+#include <svl/poolitem.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/unomid.hxx>
+#include "unowids.hxx"
+#include <rtl/uuid.h>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/CellVertJustify2.hpp>
+#include <com/sun/star/table/ShadowLocation.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/table/CellContentType.hpp>
+#include <com/sun/star/table/TableOrientation.hpp>
+#include <com/sun/star/table/CellHoriJustify.hpp>
+#include <com/sun/star/util/SortField.hpp>
+#include <com/sun/star/util/SortFieldType.hpp>
+#include <com/sun/star/table/CellOrientation.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/awt/SimpleFontMetric.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/CharSet.hpp>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWidth.hpp>
+#include <com/sun/star/awt/XFont.hpp>
+#include <com/sun/star/awt/FontType.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontFamily.hpp>
+#include <com/sun/star/awt/FontPitch.hpp>
+
+#include "afmtuno.hxx"
+#include "miscuno.hxx"
+#include "autoform.hxx"
+#include "scdll.hxx"
+#include "unonames.hxx"
+#include "cellsuno.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+// ein AutoFormat hat immer 16 Eintraege
+#define SC_AF_FIELD_COUNT 16
+
+//------------------------------------------------------------------------
+
+// AutoFormat-Map nur fuer PropertySetInfo, ohne Which-IDs
+
+const SfxItemPropertyMapEntry* lcl_GetAutoFormatMap()
+{
+ static SfxItemPropertyMapEntry aAutoFormatMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_INCBACK), 0, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_INCBORD), 0, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_INCFONT), 0, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_INCJUST), 0, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_INCNUM), 0, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_INCWIDTH), 0, &::getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aAutoFormatMap_Impl;
+}
+
+//! Zahlformat (String/Language) ??? (in XNumberFormat nur ReadOnly)
+//! table::TableBorder ??!?
+
+const SfxItemPropertyMapEntry* lcl_GetAutoFieldMap()
+{
+ static SfxItemPropertyMapEntry aAutoFieldMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT, &::getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &::getCppuType((const sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &::getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &::getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &::getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT, &::getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT, &::getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &::getCppuType((const sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &::getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE, &::getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE, &::getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &::getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE, &::getCppuType((const sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &::getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT, &::getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT, &::getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &::getCppuType((const table::CellHoriJustify*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &::getCppuType((const table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aAutoFieldMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+#define SCAUTOFORMATSOBJ_SERVICE "com.sun.star.sheet.TableAutoFormats"
+
+SC_SIMPLE_SERVICE_INFO( ScAutoFormatFieldObj, "ScAutoFormatFieldObj", "com.sun.star.sheet.TableAutoFormatField" )
+SC_SIMPLE_SERVICE_INFO( ScAutoFormatObj, "ScAutoFormatObj", "com.sun.star.sheet.TableAutoFormat" )
+SC_SIMPLE_SERVICE_INFO( ScAutoFormatsObj, "ScAutoFormatsObj", SCAUTOFORMATSOBJ_SERVICE )
+
+//------------------------------------------------------------------------
+
+sal_Bool lcl_FindAutoFormatIndex( const ScAutoFormat& rFormats, const String& rName, sal_uInt16& rOutIndex )
+{
+ String aEntryName;
+ sal_uInt16 nCount = rFormats.GetCount();
+ for( sal_uInt16 nPos=0; nPos<nCount; nPos++ )
+ {
+ ScAutoFormatData* pEntry = rFormats[nPos];
+ pEntry->GetName( aEntryName );
+ if ( aEntryName == rName )
+ {
+ rOutIndex = nPos;
+ return sal_True;
+ }
+ }
+ return sal_False; // is nich
+}
+
+//------------------------------------------------------------------------
+
+ScAutoFormatsObj::ScAutoFormatsObj()
+{
+ //! Dieses Objekt darf es nur einmal geben, und es muss an den Auto-Format-Daten
+ //! bekannt sein, damit Aenderungen gebroadcasted werden koennen
+}
+
+ScAutoFormatsObj::~ScAutoFormatsObj()
+{
+}
+
+// stuff for exService_...
+
+uno::Reference<uno::XInterface> SAL_CALL ScAutoFormatsObj_CreateInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ static uno::Reference< uno::XInterface > xInst((::cppu::OWeakObject*) new ScAutoFormatsObj);
+ return xInst;
+}
+
+rtl::OUString ScAutoFormatsObj::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScAutoFormatsObj" );
+}
+
+uno::Sequence<rtl::OUString> ScAutoFormatsObj::getSupportedServiceNames_Static()
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCAUTOFORMATSOBJ_SERVICE );
+ return aRet;
+}
+
+// XTableAutoFormats
+
+ScAutoFormatObj* ScAutoFormatsObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
+{
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats && nIndex < pFormats->GetCount())
+ return new ScAutoFormatObj(nIndex);
+
+ return NULL; // falscher Index
+}
+
+ScAutoFormatObj* ScAutoFormatsObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats)
+ {
+ String aString(aName);
+ sal_uInt16 nIndex;
+ if (lcl_FindAutoFormatIndex( *pFormats, aString, nIndex ))
+ return GetObjectByIndex_Impl(nIndex);
+ }
+ return NULL;
+}
+
+// container::XNameContainer
+
+void SAL_CALL ScAutoFormatsObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::ElementExistException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bDone = sal_False;
+ // Reflection muss nicht uno::XInterface sein, kann auch irgendein Interface sein...
+ uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
+ if ( xInterface.is() )
+ {
+ ScAutoFormatObj* pFormatObj = ScAutoFormatObj::getImplementation( xInterface );
+ if ( pFormatObj && !pFormatObj->IsInserted() ) // noch nicht eingefuegt?
+ {
+ String aNameStr(aName);
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+
+ sal_uInt16 nDummy;
+ if (pFormats && !lcl_FindAutoFormatIndex( *pFormats, aNameStr, nDummy ))
+ {
+ ScAutoFormatData* pNew = new ScAutoFormatData();
+ pNew->SetName( aNameStr );
+
+ if (pFormats->Insert( pNew ))
+ {
+ //! Notify fuer andere Objekte
+ pFormats->Save(); // sofort speichern
+
+ sal_uInt16 nNewIndex;
+ if (lcl_FindAutoFormatIndex( *pFormats, aNameStr, nNewIndex ))
+ {
+ pFormatObj->InitFormat( nNewIndex ); // kann jetzt benutzt werden
+ bDone = sal_True;
+ }
+ }
+ else
+ {
+ delete pNew;
+ DBG_ERROR("AutoFormat konnte nicht eingefuegt werden");
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ {
+ throw container::ElementExistException();
+ }
+ }
+ }
+
+ if (!bDone)
+ {
+ // other errors are handled above
+ throw lang::IllegalArgumentException();
+ }
+}
+
+void SAL_CALL ScAutoFormatsObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! zusammenfassen?
+ removeByName( aName );
+ insertByName( aName, aElement );
+}
+
+void SAL_CALL ScAutoFormatsObj::removeByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr(aName);
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+
+ sal_uInt16 nIndex;
+ if (pFormats && lcl_FindAutoFormatIndex( *pFormats, aNameStr, nIndex ))
+ {
+ pFormats->AtFree( nIndex );
+
+ //! Notify fuer andere Objekte
+ pFormats->Save(); // sofort speichern
+ }
+ else
+ {
+ throw container::NoSuchElementException();
+ }
+}
+
+// container::XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScAutoFormatsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormatEnumeration")));
+}
+
+// container::XIndexAccess
+
+sal_Int32 SAL_CALL ScAutoFormatsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats)
+ return pFormats->GetCount();
+
+ return 0;
+}
+
+uno::Any SAL_CALL ScAutoFormatsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< container::XNamed > xFormat(GetObjectByIndex_Impl((sal_uInt16)nIndex));
+ if (!xFormat.is())
+ throw lang::IndexOutOfBoundsException();
+ return uno::makeAny(xFormat);
+}
+
+uno::Type SAL_CALL ScAutoFormatsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::getCppuType((const uno::Reference< container::XNamed >*)0); // muss zu getByIndex passen
+}
+
+sal_Bool SAL_CALL ScAutoFormatsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// container::XNameAccess
+
+uno::Any SAL_CALL ScAutoFormatsObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< container::XNamed > xFormat(GetObjectByName_Impl(aName));
+ if (!xFormat.is())
+ throw container::NoSuchElementException();
+ return uno::makeAny(xFormat);
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScAutoFormatsObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats)
+ {
+ String aName;
+ sal_uInt16 nCount = pFormats->GetCount();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (sal_uInt16 i=0; i<nCount; i++)
+ {
+ (*pFormats)[i]->GetName(aName);
+ pAry[i] = aName;
+ }
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+sal_Bool SAL_CALL ScAutoFormatsObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats)
+ {
+ String aString(aName);
+ sal_uInt16 nDummy;
+ return lcl_FindAutoFormatIndex( *pFormats, aString, nDummy );
+ }
+ return sal_False;
+}
+
+//------------------------------------------------------------------------
+
+ScAutoFormatObj::ScAutoFormatObj(sal_uInt16 nIndex) :
+ aPropSet( lcl_GetAutoFormatMap() ),
+ nFormatIndex( nIndex )
+{
+ //! Listening !!!
+}
+
+ScAutoFormatObj::~ScAutoFormatObj()
+{
+ // Wenn ein AutoFormat-Objekt losgelassen wird, werden eventuelle Aenderungen
+ // gespeichert, damit sie z.B. im Writer sichtbar sind
+
+ if (IsInserted())
+ {
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if ( pFormats && pFormats->IsSaveLater() )
+ pFormats->Save();
+
+ // Save() setzt SaveLater Flag zurueck
+ }
+}
+
+void ScAutoFormatObj::InitFormat( sal_uInt16 nNewIndex )
+{
+ DBG_ASSERT( nFormatIndex == SC_AFMTOBJ_INVALID, "ScAutoFormatObj::InitFormat mehrfach" );
+ nFormatIndex = nNewIndex;
+ //! Listening !!!
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScAutoFormatObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScAutoFormatObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScAutoFormatObj* ScAutoFormatObj::getImplementation(
+ const uno::Reference<uno::XInterface> xObj )
+{
+ ScAutoFormatObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScAutoFormatObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+void ScAutoFormatObj::Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ )
+{
+ // spaeter...
+}
+
+// XTableAutoFormat
+
+ScAutoFormatFieldObj* ScAutoFormatObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
+{
+ if ( IsInserted() && nIndex < SC_AF_FIELD_COUNT )
+ return new ScAutoFormatFieldObj( nFormatIndex, nIndex );
+
+ return NULL;
+}
+
+// container::XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScAutoFormatObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableAutoFormatEnumeration")));
+}
+
+// container::XIndexAccess
+
+sal_Int32 SAL_CALL ScAutoFormatObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (IsInserted())
+ return SC_AF_FIELD_COUNT; // immer 16 Elemente
+ else
+ return 0;
+}
+
+uno::Any SAL_CALL ScAutoFormatObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( nIndex < 0 || nIndex >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+
+ if (IsInserted())
+ return uno::makeAny(uno::Reference< beans::XPropertySet >(GetObjectByIndex_Impl((sal_uInt16)nIndex)));
+ return uno::Any();
+}
+
+uno::Type SAL_CALL ScAutoFormatObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::getCppuType((const uno::Reference< beans::XPropertySet >*)0); // muss zu getByIndex passen
+}
+
+sal_Bool SAL_CALL ScAutoFormatObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// container::XNamed
+
+rtl::OUString SAL_CALL ScAutoFormatObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount())
+ {
+ String aName;
+ (*pFormats)[nFormatIndex]->GetName(aName);
+ return aName;
+ }
+ return rtl::OUString();
+}
+
+void SAL_CALL ScAutoFormatObj::setName( const rtl::OUString& aNewName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNewString(aNewName);
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+
+ sal_uInt16 nDummy;
+ if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount() &&
+ !lcl_FindAutoFormatIndex( *pFormats, aNewString, nDummy ))
+ {
+ ScAutoFormatData* pData = (*pFormats)[nFormatIndex];
+ DBG_ASSERT(pData,"AutoFormat Daten nicht da");
+
+ ScAutoFormatData* pNew = new ScAutoFormatData(*pData);
+ pNew->SetName( aNewString );
+
+ pFormats->AtFree( nFormatIndex );
+ if (pFormats->Insert( pNew ))
+ {
+ nFormatIndex = pFormats->IndexOf( pNew ); // ist evtl. anders einsortiert...
+
+ //! Notify fuer andere Objekte
+ pFormats->SetSaveLater(sal_True);
+ }
+ else
+ {
+ delete pNew;
+ DBG_ERROR("AutoFormat konnte nicht eingefuegt werden");
+ nFormatIndex = 0; //! alter Index ist ungueltig
+ }
+ }
+ else
+ {
+ // not inserted or name exists
+ throw uno::RuntimeException();
+ }
+}
+
+// beans::XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAutoFormatObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScAutoFormatObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount())
+ {
+ ScAutoFormatData* pData = (*pFormats)[nFormatIndex];
+ DBG_ASSERT(pData,"AutoFormat Daten nicht da");
+
+ String aPropString(aPropertyName);
+ sal_Bool bBool = sal_Bool();
+ if (aPropString.EqualsAscii( SC_UNONAME_INCBACK ) && (aValue >>= bBool))
+ pData->SetIncludeBackground( bBool );
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCBORD ) && (aValue >>= bBool))
+ pData->SetIncludeFrame( bBool );
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCFONT ) && (aValue >>= bBool))
+ pData->SetIncludeFont( bBool );
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCJUST ) && (aValue >>= bBool))
+ pData->SetIncludeJustify( bBool );
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCNUM ) && (aValue >>= bBool))
+ pData->SetIncludeValueFormat( bBool );
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCWIDTH ) && (aValue >>= bBool))
+ pData->SetIncludeWidthHeight( bBool );
+
+ // else Fehler
+
+ //! Notify fuer andere Objekte
+ pFormats->SetSaveLater(sal_True);
+ }
+}
+
+uno::Any SAL_CALL ScAutoFormatObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aAny;
+
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ if (pFormats && IsInserted() && nFormatIndex < pFormats->GetCount())
+ {
+ ScAutoFormatData* pData = (*pFormats)[nFormatIndex];
+ DBG_ASSERT(pData,"AutoFormat Daten nicht da");
+
+ sal_Bool bValue;
+ sal_Bool bError = sal_False;
+
+ String aPropString(aPropertyName);
+ if (aPropString.EqualsAscii( SC_UNONAME_INCBACK ))
+ bValue = pData->GetIncludeBackground();
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCBORD ))
+ bValue = pData->GetIncludeFrame();
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCFONT ))
+ bValue = pData->GetIncludeFont();
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCJUST ))
+ bValue = pData->GetIncludeJustify();
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCNUM ))
+ bValue = pData->GetIncludeValueFormat();
+ else if (aPropString.EqualsAscii( SC_UNONAME_INCWIDTH ))
+ bValue = pData->GetIncludeWidthHeight();
+ else
+ bError = sal_True; // unbekannte Property
+
+ if (!bError)
+ aAny <<= bValue;
+ }
+
+ return aAny;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAutoFormatObj )
+
+//------------------------------------------------------------------------
+
+ScAutoFormatFieldObj::ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField) :
+ aPropSet( lcl_GetAutoFieldMap() ),
+ nFormatIndex( nFormat ),
+ nFieldIndex( nField )
+{
+ //! Listening !!!
+}
+
+ScAutoFormatFieldObj::~ScAutoFormatFieldObj()
+{
+}
+
+void ScAutoFormatFieldObj::Notify( SfxBroadcaster& /* rBC */, const SfxHint& /* rHint */ )
+{
+ // spaeter...
+}
+
+// beans::XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAutoFormatFieldObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ const SfxItemPropertySimpleEntry* pEntry =
+ aPropSet.getPropertyMap()->getByName( aPropertyName );
+
+ if ( pEntry && pEntry->nWID && pFormats && nFormatIndex < pFormats->GetCount() )
+ {
+ ScAutoFormatData* pData = (*pFormats)[nFormatIndex];
+
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ if( const SfxPoolItem* pItem = pData->GetItem( nFieldIndex, pEntry->nWID ) )
+ {
+ sal_Bool bDone = sal_False;
+
+ switch( pEntry->nWID )
+ {
+ case ATTR_STACKED:
+ {
+ table::CellOrientation eOrient;
+ if( aValue >>= eOrient )
+ {
+ switch( eOrient )
+ {
+ case table::CellOrientation_STANDARD:
+ pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, FALSE ) );
+ break;
+ case table::CellOrientation_TOPBOTTOM:
+ pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, FALSE ) );
+ pData->PutItem( nFieldIndex, SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
+ break;
+ case table::CellOrientation_BOTTOMTOP:
+ pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, FALSE ) );
+ pData->PutItem( nFieldIndex, SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
+ break;
+ case table::CellOrientation_STACKED:
+ pData->PutItem( nFieldIndex, SfxBoolItem( ATTR_STACKED, TRUE ) );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ bDone = sal_True;
+ }
+ }
+ break;
+ default:
+ SfxPoolItem* pNewItem = pItem->Clone();
+ bDone = pNewItem->PutValue( aValue, pEntry->nMemberId );
+ if (bDone)
+ pData->PutItem( nFieldIndex, *pNewItem );
+ delete pNewItem;
+ }
+
+ if (bDone)
+ //! Notify fuer andere Objekte?
+ pFormats->SetSaveLater(sal_True);
+ }
+ }
+ else
+ {
+ switch (pEntry->nWID)
+ {
+ case SC_WID_UNO_TBLBORD:
+ {
+ table::TableBorder aBorder;
+ if ( aValue >>= aBorder ) // empty = nothing to do
+ {
+ SvxBoxItem aOuter(ATTR_BORDER);
+ SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
+ ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
+ pData->PutItem( nFieldIndex, aOuter );
+
+ //! Notify fuer andere Objekte?
+ pFormats->SetSaveLater(sal_True);
+ }
+ }
+ break;
+ }
+ }
+ }
+}
+
+uno::Any SAL_CALL ScAutoFormatFieldObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aVal;
+
+ ScAutoFormat* pFormats = ScGlobal::GetAutoFormat();
+ const SfxItemPropertySimpleEntry* pEntry =
+ aPropSet.getPropertyMap()->getByName( aPropertyName );
+
+ if ( pEntry && pEntry->nWID && pFormats && nFormatIndex < pFormats->GetCount() )
+ {
+ const ScAutoFormatData* pData = (*pFormats)[nFormatIndex];
+
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ if( const SfxPoolItem* pItem = pData->GetItem( nFieldIndex, pEntry->nWID ) )
+ {
+ switch( pEntry->nWID )
+ {
+ case ATTR_STACKED:
+ {
+ const SfxInt32Item* pRotItem = (const SfxInt32Item*)pData->GetItem( nFieldIndex, ATTR_ROTATE_VALUE );
+ sal_Int32 nRot = pRotItem ? pRotItem->GetValue() : 0;
+ BOOL bStacked = ((const SfxBoolItem*)pItem)->GetValue();
+ SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( aVal );
+ }
+ break;
+ default:
+ pItem->QueryValue( aVal, pEntry->nMemberId );
+ }
+ }
+ }
+ else
+ {
+ switch (pEntry->nWID)
+ {
+ case SC_WID_UNO_TBLBORD:
+ {
+ const SfxPoolItem* pItem = pData->GetItem(nFieldIndex, ATTR_BORDER);
+ if (pItem)
+ {
+ SvxBoxItem aOuter(*(static_cast<const SvxBoxItem*>(pItem)));
+ SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
+
+ table::TableBorder aBorder;
+ ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
+ aVal <<= aBorder;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ return aVal;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAutoFormatFieldObj )
+
+//------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
new file mode 100644
index 000000000000..21e0ac0790fc
--- /dev/null
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -0,0 +1,1087 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "appluno.hxx"
+#include "sal/types.h"
+#include <osl/diagnose.h>
+#include <cppuhelper/factory.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include "afmtuno.hxx"
+#include "funcuno.hxx"
+#include "filtuno.hxx"
+#include "miscuno.hxx"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "inputopt.hxx"
+#include "printopt.hxx"
+#include "userlist.hxx"
+#include "sc.hrc" // VAR_ARGS
+#include "unonames.hxx"
+#include "funcdesc.hxx"
+#include <com/sun/star/sheet/FunctionArgument.hpp>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+// Calc document
+extern uno::Sequence< rtl::OUString > SAL_CALL ScDocument_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr, const sal_uInt64 _nCreationFlags ) throw( uno::Exception );
+
+// Calc XML import
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLImport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Meta_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLImport_Meta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Meta_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Styles_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLImport_Styles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Styles_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Content_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLImport_Content_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Content_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLImport_Settings_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLImport_Settings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLImport_Settings_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+
+// Calc XML export
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOOoExport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Meta_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOOoExport_Meta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Meta_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Styles_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOOoExport_Styles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Styles_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Content_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOOoExport_Content_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Content_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOOoExport_Settings_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOOoExport_Settings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOOoExport_Settings_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+
+// Calc XML Oasis export
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOasisExport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Meta_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOasisExport_Meta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Meta_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Styles_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOasisExport_Styles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Styles_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Content_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOasisExport_Content_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Content_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+extern uno::Sequence< rtl::OUString > SAL_CALL ScXMLOasisExport_Settings_getSupportedServiceNames() throw();
+extern rtl::OUString SAL_CALL ScXMLOasisExport_Settings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL ScXMLOasisExport_Settings_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception );
+
+//------------------------------------------------------------------------
+
+// Anzahl der Funktionen, die als zuletzt benutzt gespeichert werden
+//! Define mit funcpage.hxx und dwfunctr.hxx zusammenfassen !!!
+#define LRU_MAX 10
+
+// Spezial-Werte fuer Zoom
+//! irgendwo zentral
+#define SC_ZOOMVAL_OPTIMAL (-1)
+#define SC_ZOOMVAL_WHOLEPAGE (-2)
+#define SC_ZOOMVAL_PAGEWIDTH (-3)
+
+// Anzahl der PropertyValues in einer Function-Description
+#define SC_FUNCDESC_PROPCOUNT 5
+
+//------------------------------------------------------------------------
+
+// alles ohne Which-ID, Map nur fuer PropertySetInfo
+
+static const SfxItemPropertyMapEntry* lcl_GetSettingsPropertyMap()
+{
+ static SfxItemPropertyMapEntry aSettingsPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_DOAUTOCP), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ENTERED), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_EXPREF), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_EXTFMT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_LINKUPD), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_MARKHDR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_METRIC), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_MOVEDIR), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_MOVESEL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_PRALLSH), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_PREMPTY), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_RANGEFIN), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SCALE), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_STBFUNC), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ULISTS), 0, &getCppuType((uno::Sequence<rtl::OUString>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_PRMETRICS),0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_USETABCOL),0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_REPLWARN), 0, &getBooleanCppuType(), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aSettingsPropertyMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+#define SCFUNCTIONLISTOBJ_SERVICE "com.sun.star.sheet.FunctionDescriptions"
+#define SCRECENTFUNCTIONSOBJ_SERVICE "com.sun.star.sheet.RecentFunctions"
+#define SCSPREADSHEETSETTINGS_SERVICE "com.sun.star.sheet.GlobalSheetSettings"
+
+SC_SIMPLE_SERVICE_INFO( ScFunctionListObj, "ScFunctionListObj", SCFUNCTIONLISTOBJ_SERVICE )
+SC_SIMPLE_SERVICE_INFO( ScRecentFunctionsObj, "ScRecentFunctionsObj", SCRECENTFUNCTIONSOBJ_SERVICE )
+SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettings, "ScSpreadsheetSettings", SCSPREADSHEETSETTINGS_SERVICE )
+
+//------------------------------------------------------------------------
+
+static void lcl_WriteInfo( registry::XRegistryKey* pRegistryKey,
+ const rtl::OUString& rImplementationName,
+ const uno::Sequence< rtl::OUString >& rServices )
+ throw( registry::InvalidRegistryException )
+{
+ rtl::OUString aImpl(rtl::OUString::createFromAscii( "/" ));
+ aImpl += rImplementationName;
+ aImpl += rtl::OUString::createFromAscii( "/UNO/SERVICES" );
+ uno::Reference<registry::XRegistryKey> xNewKey(pRegistryKey->createKey(aImpl));
+
+ const rtl::OUString* pArray = rServices.getConstArray();
+ for( sal_Int32 i = 0; i < rServices.getLength(); i++ )
+ xNewKey->createKey( pArray[i]);
+}
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void * /* pServiceManager */, registry::XRegistryKey * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ lcl_WriteInfo( pRegistryKey,
+ ScSpreadsheetSettings::getImplementationName_Static(),
+ ScSpreadsheetSettings::getSupportedServiceNames_Static() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScRecentFunctionsObj::getImplementationName_Static(),
+ ScRecentFunctionsObj::getSupportedServiceNames_Static() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScFunctionListObj::getImplementationName_Static(),
+ ScFunctionListObj::getSupportedServiceNames_Static() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScAutoFormatsObj::getImplementationName_Static(),
+ ScAutoFormatsObj::getSupportedServiceNames_Static() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScFunctionAccess::getImplementationName_Static(),
+ ScFunctionAccess::getSupportedServiceNames_Static() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScFilterOptionsObj::getImplementationName_Static(),
+ ScFilterOptionsObj::getSupportedServiceNames_Static() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLImport_getImplementationName(),
+ ScXMLImport_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLImport_Meta_getImplementationName(),
+ ScXMLImport_Meta_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLImport_Styles_getImplementationName(),
+ ScXMLImport_Styles_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLImport_Content_getImplementationName(),
+ ScXMLImport_Content_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLImport_Settings_getImplementationName(),
+ ScXMLImport_Settings_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOOoExport_getImplementationName(),
+ ScXMLOOoExport_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOOoExport_Meta_getImplementationName(),
+ ScXMLOOoExport_Meta_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOOoExport_Styles_getImplementationName(),
+ ScXMLOOoExport_Styles_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOOoExport_Content_getImplementationName(),
+ ScXMLOOoExport_Content_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOOoExport_Settings_getImplementationName(),
+ ScXMLOOoExport_Settings_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOasisExport_getImplementationName(),
+ ScXMLOasisExport_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOasisExport_Meta_getImplementationName(),
+ ScXMLOasisExport_Meta_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOasisExport_Styles_getImplementationName(),
+ ScXMLOasisExport_Styles_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOasisExport_Content_getImplementationName(),
+ ScXMLOasisExport_Content_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScXMLOasisExport_Settings_getImplementationName(),
+ ScXMLOasisExport_Settings_getSupportedServiceNames() );
+
+ lcl_WriteInfo( pRegistryKey,
+ ScDocument_getImplementationName(),
+ ScDocument_getSupportedServiceNames() );
+
+ return sal_True;
+ }
+ catch (registry::InvalidRegistryException&)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /* pRegistryKey */ )
+{
+ if (!pServiceManager)
+ return NULL;
+
+ uno::Reference<lang::XSingleServiceFactory> xFactory;
+ rtl::OUString aImpl(rtl::OUString::createFromAscii(pImplName));
+
+ if ( aImpl == ScSpreadsheetSettings::getImplementationName_Static() )
+ xFactory.set(cppu::createOneInstanceFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScSpreadsheetSettings::getImplementationName_Static(),
+ ScSpreadsheetSettings_CreateInstance,
+ ScSpreadsheetSettings::getSupportedServiceNames_Static() ));
+
+ if ( aImpl == ScRecentFunctionsObj::getImplementationName_Static() )
+ xFactory.set(cppu::createOneInstanceFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScRecentFunctionsObj::getImplementationName_Static(),
+ ScRecentFunctionsObj_CreateInstance,
+ ScRecentFunctionsObj::getSupportedServiceNames_Static() ));
+
+ if ( aImpl == ScFunctionListObj::getImplementationName_Static() )
+ xFactory.set(cppu::createOneInstanceFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScFunctionListObj::getImplementationName_Static(),
+ ScFunctionListObj_CreateInstance,
+ ScFunctionListObj::getSupportedServiceNames_Static() ));
+
+ if ( aImpl == ScAutoFormatsObj::getImplementationName_Static() )
+ xFactory.set(cppu::createOneInstanceFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScAutoFormatsObj::getImplementationName_Static(),
+ ScAutoFormatsObj_CreateInstance,
+ ScAutoFormatsObj::getSupportedServiceNames_Static() ));
+
+ if ( aImpl == ScFunctionAccess::getImplementationName_Static() )
+ xFactory.set(cppu::createOneInstanceFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScFunctionAccess::getImplementationName_Static(),
+ ScFunctionAccess_CreateInstance,
+ ScFunctionAccess::getSupportedServiceNames_Static() ));
+
+ if ( aImpl == ScFilterOptionsObj::getImplementationName_Static() )
+ xFactory.set(cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScFilterOptionsObj::getImplementationName_Static(),
+ ScFilterOptionsObj_CreateInstance,
+ ScFilterOptionsObj::getSupportedServiceNames_Static() ));
+
+ if ( aImpl == ScXMLImport_getImplementationName() )
+ xFactory.set(cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLImport_getImplementationName(),
+ ScXMLImport_createInstance,
+ ScXMLImport_getSupportedServiceNames() ));
+
+ if ( aImpl == ScXMLImport_Meta_getImplementationName() )
+ xFactory.set(cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLImport_Meta_getImplementationName(),
+ ScXMLImport_Meta_createInstance,
+ ScXMLImport_Meta_getSupportedServiceNames() ));
+
+ if ( aImpl == ScXMLImport_Styles_getImplementationName() )
+ xFactory.set(cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLImport_Styles_getImplementationName(),
+ ScXMLImport_Styles_createInstance,
+ ScXMLImport_Styles_getSupportedServiceNames() ));
+
+ if ( aImpl == ScXMLImport_Content_getImplementationName() )
+ xFactory.set(cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLImport_Content_getImplementationName(),
+ ScXMLImport_Content_createInstance,
+ ScXMLImport_Content_getSupportedServiceNames() ));
+
+ if ( aImpl == ScXMLImport_Settings_getImplementationName() )
+ xFactory.set(cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLImport_Settings_getImplementationName(),
+ ScXMLImport_Settings_createInstance,
+ ScXMLImport_Settings_getSupportedServiceNames() ));
+
+ if ( aImpl == ScXMLOOoExport_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOOoExport_getImplementationName(),
+ ScXMLOOoExport_createInstance,
+ ScXMLOOoExport_getSupportedServiceNames() );
+
+ if ( aImpl == ScXMLOOoExport_Meta_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOOoExport_Meta_getImplementationName(),
+ ScXMLOOoExport_Meta_createInstance,
+ ScXMLOOoExport_Meta_getSupportedServiceNames() );
+
+ if ( aImpl == ScXMLOOoExport_Styles_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOOoExport_Styles_getImplementationName(),
+ ScXMLOOoExport_Styles_createInstance,
+ ScXMLOOoExport_Styles_getSupportedServiceNames() );
+
+ if ( aImpl == ScXMLOOoExport_Content_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOOoExport_Content_getImplementationName(),
+ ScXMLOOoExport_Content_createInstance,
+ ScXMLOOoExport_Content_getSupportedServiceNames() );
+
+ if ( aImpl == ScXMLOOoExport_Settings_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOOoExport_Settings_getImplementationName(),
+ ScXMLOOoExport_Settings_createInstance,
+ ScXMLOOoExport_Settings_getSupportedServiceNames() );
+
+ if ( aImpl == ScXMLOasisExport_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOasisExport_getImplementationName(),
+ ScXMLOasisExport_createInstance,
+ ScXMLOasisExport_getSupportedServiceNames() );
+ if ( aImpl == ScXMLOasisExport_Meta_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOasisExport_Meta_getImplementationName(),
+ ScXMLOasisExport_Meta_createInstance,
+ ScXMLOasisExport_Meta_getSupportedServiceNames() );
+ if ( aImpl == ScXMLOasisExport_Styles_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOasisExport_Styles_getImplementationName(),
+ ScXMLOasisExport_Styles_createInstance,
+ ScXMLOasisExport_Styles_getSupportedServiceNames() );
+ if ( aImpl == ScXMLOasisExport_Content_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOasisExport_Content_getImplementationName(),
+ ScXMLOasisExport_Content_createInstance,
+ ScXMLOasisExport_Content_getSupportedServiceNames() );
+ if ( aImpl == ScXMLOasisExport_Settings_getImplementationName() )
+ xFactory = cppu::createSingleFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScXMLOasisExport_Settings_getImplementationName(),
+ ScXMLOasisExport_Settings_createInstance,
+ ScXMLOasisExport_Settings_getSupportedServiceNames() );
+
+ if ( aImpl == ScDocument_getImplementationName() )
+ xFactory.set(sfx2::createSfxModelFactory(
+ reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
+ ScDocument_getImplementationName(),
+ ScDocument_createInstance,
+ ScDocument_getSupportedServiceNames() ));
+
+ void* pRet = NULL;
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ return pRet;
+}
+
+} // extern C
+
+//------------------------------------------------------------------------
+
+ScSpreadsheetSettings::ScSpreadsheetSettings() :
+ aPropSet( lcl_GetSettingsPropertyMap() )
+{
+}
+
+ScSpreadsheetSettings::~ScSpreadsheetSettings()
+{
+}
+
+uno::Reference<uno::XInterface> SAL_CALL ScSpreadsheetSettings_CreateInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScSpreadsheetSettings());
+ return xInst;
+}
+
+rtl::OUString ScSpreadsheetSettings::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScSpreadsheetSettings" );
+}
+
+uno::Sequence<rtl::OUString> ScSpreadsheetSettings::getSupportedServiceNames_Static()
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSPREADSHEETSETTINGS_SERVICE );
+ return aRet;
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettings::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScSpreadsheetSettings::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+
+ ScModule* pScMod = SC_MOD();
+ ScAppOptions aAppOpt(pScMod->GetAppOptions());
+ ScInputOptions aInpOpt(pScMod->GetInputOptions());
+ BOOL bSaveApp = FALSE;
+ BOOL bSaveInp = FALSE;
+ // print options aren't loaded until needed
+
+ if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP ))
+ {
+ aAppOpt.SetAutoComplete( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveApp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_ENTERED ))
+ {
+ aInpOpt.SetEnterEdit( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_EXPREF ))
+ {
+ aInpOpt.SetExpandRefs( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_EXTFMT ))
+ {
+ aInpOpt.SetExtendFormat( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_LINKUPD ))
+ {
+ aAppOpt.SetLinkMode( (ScLkUpdMode) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ bSaveApp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_MARKHDR ))
+ {
+ aInpOpt.SetMarkHeader( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_MOVESEL ))
+ {
+ aInpOpt.SetMoveSelection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN ))
+ {
+ aInpOpt.SetRangeFinder( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_USETABCOL ))
+ {
+ aInpOpt.SetUseTabCol( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS ))
+ {
+ aInpOpt.SetTextWysiwyg( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_REPLWARN ))
+ {
+ aInpOpt.SetReplaceCellsWarn( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_METRIC ))
+ {
+ aAppOpt.SetAppMetric( (FieldUnit) ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ bSaveApp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_MOVEDIR ))
+ {
+ aInpOpt.SetMoveDir( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ bSaveInp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_SCALE ))
+ {
+ short nVal = ScUnoHelpFunctions::GetInt16FromAny( aValue );
+ if ( nVal < 0 )
+ {
+ SvxZoomType eType = SVX_ZOOM_PERCENT;
+ switch (nVal)
+ {
+ case SC_ZOOMVAL_OPTIMAL: eType = SVX_ZOOM_OPTIMAL; break;
+ case SC_ZOOMVAL_WHOLEPAGE: eType = SVX_ZOOM_WHOLEPAGE; break;
+ case SC_ZOOMVAL_PAGEWIDTH: eType = SVX_ZOOM_PAGEWIDTH; break;
+ }
+ aAppOpt.SetZoomType( eType );
+ }
+ else if ( nVal >= MINZOOM && nVal <= MAXZOOM )
+ {
+ aAppOpt.SetZoom( nVal );
+ aAppOpt.SetZoomType( SVX_ZOOM_PERCENT );
+ }
+ bSaveApp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_STBFUNC ))
+ {
+ aAppOpt.SetStatusFunc( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ bSaveApp = TRUE;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_ULISTS ))
+ {
+ ScUserList* pUserList = ScGlobal::GetUserList();
+ uno::Sequence<rtl::OUString> aSeq;
+ if ( pUserList && ( aValue >>= aSeq ) )
+ {
+ // es wird direkt die "lebende" Liste veraendert,
+ // mehr tut ScGlobal::SetUserList auch nicht
+
+ pUserList->FreeAll(); // alle Eintraege raus
+ USHORT nCount = (USHORT)aSeq.getLength();
+ const rtl::OUString* pAry = aSeq.getConstArray();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ String aEntry = pAry[i];
+ ScUserListData* pData = new ScUserListData(aEntry);
+ if (!pUserList->Insert(pData)) // hinten anhaengen
+ delete pData; // sollte nicht vorkommen
+ }
+ bSaveApp = TRUE; // Liste wird mit den App-Optionen gespeichert
+ }
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_PRALLSH ))
+ {
+ ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
+ aPrintOpt.SetAllSheets( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ pScMod->SetPrintOptions( aPrintOpt );
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_PREMPTY ))
+ {
+ ScPrintOptions aPrintOpt(pScMod->GetPrintOptions());
+ aPrintOpt.SetSkipEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) ); // reversed
+ pScMod->SetPrintOptions( aPrintOpt );
+ SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) ); // update previews
+ }
+
+ if ( bSaveApp )
+ pScMod->SetAppOptions( aAppOpt );
+ if ( bSaveInp )
+ pScMod->SetInputOptions( aInpOpt );
+}
+
+uno::Any SAL_CALL ScSpreadsheetSettings::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString = aPropertyName;
+ uno::Any aRet;
+
+ ScModule* pScMod = SC_MOD();
+ ScAppOptions aAppOpt = pScMod->GetAppOptions();
+ ScInputOptions aInpOpt = pScMod->GetInputOptions();
+ // print options aren't loaded until needed
+
+ if (aString.EqualsAscii( SC_UNONAME_DOAUTOCP )) ScUnoHelpFunctions::SetBoolInAny( aRet, aAppOpt.GetAutoComplete() );
+ else if (aString.EqualsAscii( SC_UNONAME_ENTERED )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetEnterEdit() );
+ else if (aString.EqualsAscii( SC_UNONAME_EXPREF )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExpandRefs() );
+ else if (aString.EqualsAscii( SC_UNONAME_EXTFMT )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetExtendFormat() );
+ else if (aString.EqualsAscii( SC_UNONAME_LINKUPD )) aRet <<= (sal_Int16) aAppOpt.GetLinkMode();
+ else if (aString.EqualsAscii( SC_UNONAME_MARKHDR )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMarkHeader() );
+ else if (aString.EqualsAscii( SC_UNONAME_MOVESEL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetMoveSelection() );
+ else if (aString.EqualsAscii( SC_UNONAME_RANGEFIN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetRangeFinder() );
+ else if (aString.EqualsAscii( SC_UNONAME_USETABCOL )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetUseTabCol() );
+ else if (aString.EqualsAscii( SC_UNONAME_PRMETRICS )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetTextWysiwyg() );
+ else if (aString.EqualsAscii( SC_UNONAME_REPLWARN )) ScUnoHelpFunctions::SetBoolInAny( aRet, aInpOpt.GetReplaceCellsWarn() );
+ else if (aString.EqualsAscii( SC_UNONAME_METRIC )) aRet <<= (sal_Int16) aAppOpt.GetAppMetric();
+ else if (aString.EqualsAscii( SC_UNONAME_MOVEDIR )) aRet <<= (sal_Int16) aInpOpt.GetMoveDir();
+ else if (aString.EqualsAscii( SC_UNONAME_STBFUNC )) aRet <<= (sal_Int16) aAppOpt.GetStatusFunc();
+ else if (aString.EqualsAscii( SC_UNONAME_SCALE ))
+ {
+ INT16 nZoomVal = 0;
+ switch ( aAppOpt.GetZoomType() )
+ {
+ case SVX_ZOOM_PERCENT: nZoomVal = aAppOpt.GetZoom(); break;
+ case SVX_ZOOM_OPTIMAL: nZoomVal = SC_ZOOMVAL_OPTIMAL; break;
+ case SVX_ZOOM_WHOLEPAGE: nZoomVal = SC_ZOOMVAL_WHOLEPAGE; break;
+ case SVX_ZOOM_PAGEWIDTH: nZoomVal = SC_ZOOMVAL_PAGEWIDTH; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ aRet <<= (sal_Int16) nZoomVal;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_ULISTS ))
+ {
+ ScUserList* pUserList = ScGlobal::GetUserList();
+ if (pUserList)
+ {
+ USHORT nCount = pUserList->GetCount();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ String aEntry((*pUserList)[i]->GetString());
+ pAry[i] = aEntry;
+ }
+ aRet <<= aSeq;
+ }
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_PRALLSH ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pScMod->GetPrintOptions().GetAllSheets() );
+ else if (aString.EqualsAscii( SC_UNONAME_PREMPTY ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, !pScMod->GetPrintOptions().GetSkipEmpty() ); // reversed
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettings )
+
+//------------------------------------------------------------------------
+
+ScRecentFunctionsObj::ScRecentFunctionsObj()
+{
+}
+
+ScRecentFunctionsObj::~ScRecentFunctionsObj()
+{
+}
+
+// stuff for exService_...
+
+uno::Reference<uno::XInterface> SAL_CALL ScRecentFunctionsObj_CreateInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScRecentFunctionsObj());
+ return xInst;
+}
+
+rtl::OUString ScRecentFunctionsObj::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScRecentFunctionsObj" );
+}
+
+uno::Sequence<rtl::OUString> ScRecentFunctionsObj::getSupportedServiceNames_Static()
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCRECENTFUNCTIONSOBJ_SERVICE );
+ return aRet;
+}
+
+// XRecentFunctions
+
+uno::Sequence<sal_Int32> SAL_CALL ScRecentFunctionsObj::getRecentFunctionIds()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScAppOptions& rOpt = SC_MOD()->GetAppOptions();
+ USHORT nCount = rOpt.GetLRUFuncListCount();
+ const USHORT* pFuncs = rOpt.GetLRUFuncList();
+ if (pFuncs)
+ {
+ uno::Sequence<sal_Int32> aSeq(nCount);
+ sal_Int32* pAry = aSeq.getArray();
+ for (USHORT i=0; i<nCount; i++)
+ pAry[i] = pFuncs[i];
+ return aSeq;
+ }
+ return uno::Sequence<sal_Int32>(0);
+}
+
+void SAL_CALL ScRecentFunctionsObj::setRecentFunctionIds(
+ const uno::Sequence<sal_Int32>& aRecentFunctionIds )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = (USHORT) Min( aRecentFunctionIds.getLength(), (INT32) LRU_MAX );
+ const INT32* pAry = aRecentFunctionIds.getConstArray();
+
+ USHORT* pFuncs = nCount ? new USHORT[nCount] : NULL;
+ for (USHORT i=0; i<nCount; i++)
+ pFuncs[i] = (USHORT)pAry[i]; //! auf gueltige Werte testen?
+
+ ScModule* pScMod = SC_MOD();
+ ScAppOptions aNewOpts(pScMod->GetAppOptions());
+ aNewOpts.SetLRUFuncList(pFuncs, nCount);
+ pScMod->SetAppOptions(aNewOpts);
+
+ pScMod->RecentFunctionsChanged(); // update function list child window
+
+ delete[] pFuncs;
+}
+
+sal_Int32 SAL_CALL ScRecentFunctionsObj::getMaxRecentFunctions() throw(uno::RuntimeException)
+{
+ return LRU_MAX;
+}
+
+//------------------------------------------------------------------------
+
+ScFunctionListObj::ScFunctionListObj()
+{
+}
+
+ScFunctionListObj::~ScFunctionListObj()
+{
+}
+
+// stuff for exService_...
+
+uno::Reference<uno::XInterface> SAL_CALL ScFunctionListObj_CreateInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& /* rSMgr */ )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ static uno::Reference<uno::XInterface> xInst((cppu::OWeakObject*)new ScFunctionListObj());
+ return xInst;
+}
+
+rtl::OUString ScFunctionListObj::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScFunctionListObj" );
+}
+
+uno::Sequence<rtl::OUString> ScFunctionListObj::getSupportedServiceNames_Static()
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCFUNCTIONLISTOBJ_SERVICE );
+ return aRet;
+}
+
+
+static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, const ScFuncDesc& rDesc )
+{
+ rDesc.initArgumentInfo(); // full argument info is needed
+
+ DBG_ASSERT( rSequence.getLength() == SC_FUNCDESC_PROPCOUNT, "Falscher Count" );
+
+ beans::PropertyValue* pArray = rSequence.getArray();
+
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_ID );
+ pArray[0].Value <<= (sal_Int32) rDesc.nFIndex;
+
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_CATEGORY );
+ pArray[1].Value <<= (sal_Int32) rDesc.nCategory;
+
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_NAME );
+ if (rDesc.pFuncName)
+ pArray[2].Value <<= rtl::OUString( *rDesc.pFuncName );
+
+ pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_DESCRIPTION );
+ if (rDesc.pFuncDesc)
+ pArray[3].Value <<= rtl::OUString( *rDesc.pFuncDesc );
+
+ pArray[4].Name = rtl::OUString::createFromAscii( SC_UNONAME_ARGUMENTS );
+ if (rDesc.ppDefArgNames && rDesc.ppDefArgDescs && rDesc.pDefArgFlags )
+ {
+ USHORT nCount = rDesc.nArgCount;
+ if (nCount >= VAR_ARGS)
+ nCount -= VAR_ARGS - 1;
+ USHORT nSeqCount = rDesc.GetSuppressedArgCount();
+ if (nSeqCount >= VAR_ARGS)
+ nSeqCount -= VAR_ARGS - 1;
+
+ if (nSeqCount)
+ {
+ uno::Sequence<sheet::FunctionArgument> aArgSeq(nSeqCount);
+ sheet::FunctionArgument* pArgAry = aArgSeq.getArray();
+ for (USHORT i=0, j=0; i<nCount; i++)
+ {
+ if (!rDesc.pDefArgFlags[i].bSuppress)
+ {
+ String aArgName;
+ if (rDesc.ppDefArgNames[i]) aArgName = *rDesc.ppDefArgNames[i];
+ String aArgDesc;
+ if (rDesc.ppDefArgDescs[i]) aArgDesc = *rDesc.ppDefArgDescs[i];
+ sheet::FunctionArgument aArgument;
+ aArgument.Name = aArgName;
+ aArgument.Description = aArgDesc;
+ aArgument.IsOptional = rDesc.pDefArgFlags[i].bOptional;
+ pArgAry[j++] = aArgument;
+ }
+ }
+ pArray[4].Value <<= aArgSeq;
+ }
+ }
+}
+
+// XFunctionDescriptions
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScFunctionListObj::getById( sal_Int32 nId )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ {
+ USHORT nCount = (USHORT)pFuncList->GetCount();
+ for (USHORT nIndex=0; nIndex<nCount; nIndex++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
+ if ( pDesc && pDesc->nFIndex == nId )
+ {
+ uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
+ lcl_FillSequence( aSeq, *pDesc );
+ return aSeq;
+ }
+ }
+
+ throw lang::IllegalArgumentException(); // not found
+ }
+ else
+ throw uno::RuntimeException(); // should not happen
+
+// return uno::Sequence<beans::PropertyValue>(0);
+}
+
+// XNameAccess
+
+uno::Any SAL_CALL ScFunctionListObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr(aName);
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ {
+ USHORT nCount = (USHORT)pFuncList->GetCount();
+ for (USHORT nIndex=0; nIndex<nCount; nIndex++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
+ //! Case-insensitiv ???
+ if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
+ {
+ uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
+ lcl_FillSequence( aSeq, *pDesc );
+ return uno::makeAny(aSeq);
+ }
+ }
+
+ throw container::NoSuchElementException(); // not found
+ }
+ else
+ throw uno::RuntimeException(); // should not happen
+
+// return uno::Any();
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScFunctionListObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = 0;
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ nCount = (USHORT)pFuncList->GetCount();
+ return nCount;
+}
+
+uno::Any SAL_CALL ScFunctionListObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ {
+ if ( nIndex >= 0 && nIndex < (sal_Int32)pFuncList->GetCount() )
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
+ if ( pDesc )
+ {
+ uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
+ lcl_FillSequence( aSeq, *pDesc );
+ return uno::makeAny(aSeq);
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException(); // illegal index
+ }
+ else
+ throw uno::RuntimeException(); // should not happen
+
+// return uno::Any();
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScFunctionListObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.FunctionDescriptionEnumeration")));
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScFunctionListObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Sequence<beans::PropertyValue>*)0);
+}
+
+sal_Bool SAL_CALL ScFunctionListObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() > 0 );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScFunctionListObj::getElementNames() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ {
+ USHORT nCount = (USHORT)pFuncList->GetCount();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (USHORT nIndex=0; nIndex<nCount; nIndex++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
+ if ( pDesc && pDesc->pFuncName )
+ pAry[nIndex] = *pDesc->pFuncName;
+ }
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+sal_Bool SAL_CALL ScFunctionListObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr(aName);
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ {
+ USHORT nCount = (USHORT)pFuncList->GetCount();
+ for (USHORT nIndex=0; nIndex<nCount; nIndex++)
+ {
+ const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
+ //! Case-insensitiv ???
+ if ( pDesc && pDesc->pFuncName && aNameStr == *pDesc->pFuncName )
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/celllistsource.cxx b/sc/source/ui/unoobj/celllistsource.cxx
new file mode 100644
index 000000000000..2c1346a32023
--- /dev/null
+++ b/sc/source/ui/unoobj/celllistsource.cxx
@@ -0,0 +1,452 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "celllistsource.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+//.........................................................................
+namespace calc
+{
+//.........................................................................
+
+#define PROP_HANDLE_RANGE_ADDRESS 1
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::table;
+ using namespace ::com::sun::star::text;
+ using namespace ::com::sun::star::sheet;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::form::binding;
+
+ //=====================================================================
+ //= OCellListSource
+ //=====================================================================
+ DBG_NAME( OCellListSource )
+ //---------------------------------------------------------------------
+#ifdef DBG_UTIL
+ const char* OCellListSource::checkConsistency_static( const void* _pThis )
+ {
+ return static_cast< const OCellListSource* >( _pThis )->checkConsistency( );
+ }
+
+ const char* OCellListSource::checkConsistency( ) const
+ {
+ const char* pAssertion = NULL;
+
+ // TODO: place any checks here to ensure consistency of this instance
+
+ return pAssertion;
+ }
+#endif
+
+ //---------------------------------------------------------------------
+ OCellListSource::OCellListSource( const Reference< XSpreadsheetDocument >& _rxDocument )
+ :OCellListSource_Base( m_aMutex )
+ ,OCellListSource_PBase( OCellListSource_Base::rBHelper )
+ ,m_xDocument( _rxDocument )
+ ,m_aListEntryListeners( m_aMutex )
+ ,m_bInitialized( sal_False )
+ {
+ DBG_CTOR( OCellListSource, checkConsistency_static );
+
+ OSL_PRECOND( m_xDocument.is(), "OCellListSource::OCellListSource: invalid document!" );
+
+ // register our property at the base class
+ CellRangeAddress aInitialPropValue;
+ registerPropertyNoMember(
+ ::rtl::OUString::createFromAscii( "CellRange" ),
+ PROP_HANDLE_RANGE_ADDRESS,
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY,
+ ::getCppuType( &aInitialPropValue ),
+ &aInitialPropValue
+ );
+ }
+
+ //---------------------------------------------------------------------
+ OCellListSource::~OCellListSource( )
+ {
+ if ( !OCellListSource_Base::rBHelper.bDisposed )
+ {
+ acquire(); // prevent duplicate dtor
+ dispose();
+ }
+
+ DBG_DTOR( OCellListSource, checkConsistency_static );
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( OCellListSource, OCellListSource_Base, OCellListSource_PBase )
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( OCellListSource, OCellListSource_Base, OCellListSource_PBase )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::disposing()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+
+ Reference<XModifyBroadcaster> xBroadcaster( m_xRange, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->removeModifyListener( this );
+ }
+
+ EventObject aDisposeEvent( *this );
+ m_aListEntryListeners.disposeAndClear( aDisposeEvent );
+
+// OCellListSource_Base::disposing();
+ WeakAggComponentImplHelperBase::disposing();
+
+ // TODO: clean up here whatever you need to clean up (e.g. revoking listeners etc.)
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL OCellListSource::getPropertySetInfo( ) throw(RuntimeException)
+ {
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ return createPropertySetInfo( getInfoHelper() ) ;
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL OCellListSource::getInfoHelper()
+ {
+ return *OCellListSource_PABase::getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OCellListSource::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
+ {
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ DBG_ASSERT( _nHandle == PROP_HANDLE_RANGE_ADDRESS, "OCellListSource::getFastPropertyValue: invalid handle!" );
+ // we only have this one property ....
+ (void)_nHandle; // avoid warning in product version
+
+ _rValue <<= getRangeAddress( );
+ }
+
+ //--------------------------------------------------------------------
+ void OCellListSource::checkDisposed( ) const SAL_THROW( ( DisposedException ) )
+ {
+ if ( OCellListSource_Base::rBHelper.bInDispose || OCellListSource_Base::rBHelper.bDisposed )
+ throw DisposedException();
+ // TODO: is it worth having an error message here?
+ }
+
+ //--------------------------------------------------------------------
+ void OCellListSource::checkInitialized() SAL_THROW( ( RuntimeException ) )
+ {
+ if ( !m_bInitialized )
+ throw RuntimeException();
+ // TODO: error message
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OCellListSource::getImplementationName( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sheet.OCellListSource" ) );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL OCellListSource::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupportedServices( getSupportedServiceNames() );
+ const ::rtl::OUString* pLookup = aSupportedServices.getConstArray();
+ const ::rtl::OUString* pLookupEnd = aSupportedServices.getConstArray() + aSupportedServices.getLength();
+ while ( pLookup != pLookupEnd )
+ if ( *pLookup++ == _rServiceName )
+ return sal_True;
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OCellListSource::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServices( 2 );
+ aServices[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellRangeListSource" ) );
+ aServices[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.binding.ListEntrySource" ) );
+ return aServices;
+ }
+
+ //--------------------------------------------------------------------
+ CellRangeAddress OCellListSource::getRangeAddress( ) const
+ {
+ OSL_PRECOND( m_xRange.is(), "OCellListSource::getRangeAddress: invalid range!" );
+
+ CellRangeAddress aAddress;
+ Reference< XCellRangeAddressable > xRangeAddress( m_xRange, UNO_QUERY );
+ if ( xRangeAddress.is() )
+ aAddress = xRangeAddress->getRangeAddress( );
+ return aAddress;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString OCellListSource::getCellTextContent_noCheck( sal_Int32 _nRangeRelativeColumn, sal_Int32 _nRangeRelativeRow )
+ {
+ OSL_PRECOND( m_xRange.is(), "OCellListSource::getRangeAddress: invalid range!" );
+ Reference< XTextRange > xCellText;
+ if ( m_xRange.is() )
+ xCellText.set(xCellText.query( m_xRange->getCellByPosition( _nRangeRelativeColumn, _nRangeRelativeRow ) ));
+
+ ::rtl::OUString sText;
+ if ( xCellText.is() )
+ sText = xCellText->getString();
+ return sText;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL OCellListSource::getListEntryCount( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ checkDisposed();
+ checkInitialized();
+
+ CellRangeAddress aAddress( getRangeAddress( ) );
+ return aAddress.EndRow - aAddress.StartRow + 1;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OCellListSource::getListEntry( sal_Int32 _nPosition ) throw (IndexOutOfBoundsException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ checkDisposed();
+ checkInitialized();
+
+ if ( _nPosition >= getListEntryCount() )
+ throw IndexOutOfBoundsException();
+
+ return getCellTextContent_noCheck( 0, _nPosition );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OCellListSource::getAllListEntries( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ checkDisposed();
+ checkInitialized();
+
+ Sequence< ::rtl::OUString > aAllEntries( getListEntryCount() );
+ ::rtl::OUString* pAllEntries = aAllEntries.getArray();
+ for ( sal_Int32 i = 0; i < aAllEntries.getLength(); ++i )
+ {
+ *pAllEntries++ = getCellTextContent_noCheck( 0, i );
+ }
+
+ return aAllEntries;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::addListEntryListener( const Reference< XListEntryListener >& _rxListener ) throw (NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ checkDisposed();
+ checkInitialized();
+
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+
+ m_aListEntryListeners.addInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::removeListEntryListener( const Reference< XListEntryListener >& _rxListener ) throw (NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+ checkDisposed();
+ checkInitialized();
+
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+
+ m_aListEntryListeners.removeInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::modified( const EventObject& /* aEvent */ ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+
+ notifyModified();
+ }
+
+ //--------------------------------------------------------------------
+ void OCellListSource::notifyModified()
+ {
+ EventObject aEvent;
+ aEvent.Source.set(*this);
+
+ ::cppu::OInterfaceIteratorHelper aIter( m_aListEntryListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ try
+ {
+ static_cast< XListEntryListener* >( aIter.next() )->allEntriesChanged( aEvent );
+ }
+ catch( const RuntimeException& )
+ {
+ // silent this
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "OCellListSource::notifyModified: caught a (non-runtime) exception!" );
+ }
+ }
+
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::disposing( const EventObject& aEvent ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellListSource, checkConsistency_static );
+
+ Reference<XInterface> xRangeInt( m_xRange, UNO_QUERY );
+ if ( xRangeInt == aEvent.Source )
+ {
+ // release references to range object
+ m_xRange.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellListSource::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bInitialized )
+ throw Exception();
+ // TODO: error message
+
+ // get the cell address
+ CellRangeAddress aRangeAddress;
+ sal_Bool bFoundAddress = sal_False;
+
+ const Any* pLoop = _rArguments.getConstArray();
+ const Any* pLoopEnd = _rArguments.getConstArray() + _rArguments.getLength();
+ for ( ; ( pLoop != pLoopEnd ) && !bFoundAddress; ++pLoop )
+ {
+ NamedValue aValue;
+ if ( *pLoop >>= aValue )
+ {
+ if ( aValue.Name.equalsAscii( "CellRange" ) )
+ {
+ if ( aValue.Value >>= aRangeAddress )
+ bFoundAddress = sal_True;
+ }
+ }
+ }
+
+ if ( !bFoundAddress )
+ // TODO: error message
+ throw Exception();
+
+ // determine the range we're bound to
+ try
+ {
+ if ( m_xDocument.is() )
+ {
+ // first the sheets collection
+ Reference< XIndexAccess > xSheets(m_xDocument->getSheets( ), UNO_QUERY);
+ DBG_ASSERT( xSheets.is(), "OCellListSource::initialize: could not retrieve the sheets!" );
+
+ if ( xSheets.is() )
+ {
+ // the concrete sheet
+ Reference< XCellRange > xSheet(xSheets->getByIndex( aRangeAddress.Sheet ), UNO_QUERY);
+ DBG_ASSERT( xSheet.is(), "OCellListSource::initialize: NULL sheet, but no exception!" );
+
+ // the concrete cell
+ if ( xSheet.is() )
+ {
+ m_xRange.set(xSheet->getCellRangeByPosition(
+ aRangeAddress.StartColumn, aRangeAddress.StartRow,
+ aRangeAddress.EndColumn, aRangeAddress.EndRow));
+ DBG_ASSERT( Reference< XCellRangeAddressable >( m_xRange, UNO_QUERY ).is(), "OCellListSource::initialize: either NULL range, or cell without address access!" );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "OCellListSource::initialize: caught an exception while retrieving the cell object!" );
+ }
+
+
+ if ( !m_xRange.is() )
+ throw Exception();
+ // TODO error message
+
+ Reference<XModifyBroadcaster> xBroadcaster( m_xRange, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->addModifyListener( this );
+ }
+
+ // TODO: add as XEventListener to the cell range, so we get notified when it dies,
+ // and can dispose ourself then
+
+ // TODO: somehow add as listener so we get notified when the address of the cell range changes
+ // We need to forward this as change in our CellRange property to our property change listeners
+
+ // TODO: somehow add as listener to the cells in the range, so that we get notified
+ // when their content changes. We need to forward this to our list entry listeners then
+
+ // TODO: somehow add as listener so that we get notified of insertions and removals of rows in our
+ // range. In this case, we need to fire a change in our CellRange property, and additionally
+ // notify our XListEntryListeners
+
+ m_bInitialized = sal_True;
+ }
+
+//.........................................................................
+} // namespace calc
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/celllistsource.hxx b/sc/source/ui/unoobj/celllistsource.hxx
new file mode 100644
index 000000000000..0b8807f61f20
--- /dev/null
+++ b/sc/source/ui/unoobj/celllistsource.hxx
@@ -0,0 +1,178 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CELLLISTSOURCE_HXX
+#define SC_CELLLISTSOURCE_HXX
+
+#include <com/sun/star/form/binding/XListEntrySource.hpp>
+#include <cppuhelper/compbase4.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/util/XModifyListener.hpp>
+
+
+//.........................................................................
+namespace calc
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OCellListSource
+ //=====================================================================
+ class OCellListSource;
+ // the base for our interfaces
+ typedef ::cppu::WeakAggComponentImplHelper4 < ::com::sun::star::form::binding::XListEntrySource
+ , ::com::sun::star::util::XModifyListener
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::lang::XInitialization
+ > OCellListSource_Base;
+ // the base for the property handling
+ typedef ::comphelper::OPropertyContainer OCellListSource_PBase;
+ // the second base for property handling
+ typedef ::comphelper::OPropertyArrayUsageHelper< OCellListSource >
+ OCellListSource_PABase;
+
+ class OCellListSource :public ::comphelper::OBaseMutex
+ ,public OCellListSource_Base // order matters! before OCellListSource_PBase, so rBHelper gets initialized
+ ,public OCellListSource_PBase
+ ,public OCellListSource_PABase
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
+ m_xDocument; /// the document where our cell lives
+ ::com::sun::star::uno::Reference< ::com::sun::star::table::XCellRange >
+ m_xRange; /// the range of cells we're bound to
+ ::cppu::OInterfaceContainerHelper
+ m_aListEntryListeners; /// our listeners
+ sal_Bool m_bInitialized; /// has XInitialization::initialize been called?
+
+ public:
+ OCellListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& _rxDocument
+ );
+
+ using OCellListSource_PBase::getFastPropertyValue;
+
+ protected:
+ ~OCellListSource( );
+
+ protected:
+ // XInterface
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
+ // XListEntrySource
+ virtual sal_Int32 SAL_CALL getListEntryCount( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getListEntry( sal_Int32 Position ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAllListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addListEntryListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntryListener >& Listener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeListEntryListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntryListener >& Listener ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper/XComponent
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
+
+ // ::comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ private:
+ void checkDisposed( ) const
+ SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
+ void checkInitialized()
+ SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
+
+ /** retrieves the actual address of our cell range
+ @precond
+ our m_xRange is not <NULL/>
+ */
+ ::com::sun::star::table::CellRangeAddress
+ getRangeAddress( ) const;
+
+ /** retrievs the text of a cell within our range
+ @param _nRangeRelativeColumn
+ the relative column index of the cell within our range
+ @param _nRangeRelativeRow
+ the relative row index of the cell within our range
+ @precond
+ our m_xRange is not <NULL/>
+ */
+ ::rtl::OUString
+ getCellTextContent_noCheck(
+ sal_Int32 _nRangeRelativeColumn,
+ sal_Int32 _nRangeRelativeRow
+ );
+
+ void notifyModified();
+
+ private:
+ OCellListSource(); // never implemented
+ OCellListSource( const OCellListSource& ); // never implemented
+ OCellListSource& operator=( const OCellListSource& ); // never implemented
+
+#ifdef DBG_UTIL
+ private:
+ static const char* checkConsistency_static( const void* _pThis );
+ const char* checkConsistency( ) const;
+#endif
+ };
+
+//.........................................................................
+} // namespace calc
+//.........................................................................
+
+#endif // SC_CELLLISTSOURCE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
new file mode 100644
index 000000000000..eadb12a8f50b
--- /dev/null
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -0,0 +1,9855 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <svx/svdpool.hxx>
+
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/fmdpage.hxx>
+#include <editeng/langitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/unomid.hxx>
+#include <editeng/unoprnms.hxx>
+#include <editeng/unotext.hxx>
+#include <svx/svdpage.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <rtl/uuid.h>
+#include <float.h> // DBL_MIN
+
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/util/CellProtection.hpp>
+#include <com/sun/star/table/CellHoriJustify.hpp>
+#include <com/sun/star/table/CellOrientation.hpp>
+#include <com/sun/star/table/CellVertJustify2.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/BorderLine2.hpp>
+#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/sheet/FormulaResult.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/beans/TolerantPropertySetResultType.hpp>
+#include <com/sun/star/beans/SetPropertyTolerantFailed.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+
+#include "autoform.hxx"
+#include "cellmergeoption.hxx"
+#include "cellsuno.hxx"
+#include "cursuno.hxx"
+#include "textuno.hxx"
+#include "editsrc.hxx"
+#include "notesuno.hxx"
+#include "fielduno.hxx"
+#include "docuno.hxx" // ScTableColumnsObj etc
+#include "datauno.hxx"
+#include "dapiuno.hxx"
+#include "chartuno.hxx"
+#include "fmtuno.hxx"
+#include "miscuno.hxx"
+#include "convuno.hxx"
+#include "srchuno.hxx"
+#include "targuno.hxx"
+#include "tokenuno.hxx"
+#include "eventuno.hxx"
+#include "docsh.hxx"
+#include "markdata.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "docfunc.hxx"
+#include "dbdocfun.hxx"
+#include "olinefun.hxx"
+#include "hints.hxx"
+#include "cell.hxx"
+#include "undocell.hxx"
+#include "undotab.hxx"
+#include "undoblk.hxx" // fuer lcl_ApplyBorder - nach docfunc verschieben!
+#include "stlsheet.hxx"
+#include "dbcolect.hxx"
+#include "attrib.hxx"
+#include "chartarr.hxx"
+#include "chartlis.hxx"
+#include "drwlayer.hxx"
+#include "printfun.hxx"
+#include "prnsave.hxx"
+#include "tablink.hxx"
+#include "dociter.hxx"
+#include "rangeutl.hxx"
+#include "conditio.hxx"
+#include "validat.hxx"
+#include "sc.hrc"
+#include "brdcst.hxx"
+#include "cellform.hxx"
+#include "globstr.hrc"
+#include "unonames.hxx"
+#include "styleuno.hxx"
+#include "rangeseq.hxx"
+#include "unowids.hxx"
+#include "paramisc.hxx"
+#include "formula/errorcodes.hxx"
+#include "unoreflist.hxx"
+#include "formula/grammar.hxx"
+
+#include <list>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+
+class ScNamedEntry
+{
+ String aName;
+ ScRange aRange;
+
+public:
+ ScNamedEntry(const String& rN, const ScRange& rR) :
+ aName(rN), aRange(rR) {}
+
+ const String& GetName() const { return aName; }
+ const ScRange& GetRange() const { return aRange; }
+};
+
+
+//------------------------------------------------------------------------
+
+// Die Namen in den Maps muessen (nach strcmp) sortiert sein!
+//! statt Which-ID 0 special IDs verwenden, und nicht ueber Namen vergleichen !!!!!!!!!
+
+// Left/Right/Top/BottomBorder are mapped directly to the core items,
+// not collected/applied to the borders of a range -> ATTR_BORDER can be used directly
+
+const SfxItemPropertySet* lcl_GetCellsPropertySet()
+{
+ static SfxItemPropertyMapEntry aCellsPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aCellsPropertySet( aCellsPropertyMap_Impl );
+ return &aCellsPropertySet;
+}
+
+// CellRange enthaelt alle Eintraege von Cells, zusaetzlich eigene Eintraege
+// mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
+
+const SfxItemPropertySet* lcl_GetRangePropertySet()
+{
+ static SfxItemPropertyMapEntry aRangePropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aRangePropertySet( aRangePropertyMap_Impl );
+ return &aRangePropertySet;
+}
+
+// Cell enthaelt alle Eintraege von CellRange, zusaetzlich eigene Eintraege
+// mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
+
+const SfxItemPropertySet* lcl_GetCellPropertySet()
+{
+ static SfxItemPropertyMapEntry aCellPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_FORMLOC), SC_WID_UNO_FORMLOC, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_FORMRT), SC_WID_UNO_FORMRT, &getCppuType((table::CellContentType*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aCellPropertySet( aCellPropertyMap_Impl );
+ return &aCellPropertySet;
+}
+
+// Column und Row enthalten alle Eintraege von CellRange, zusaetzlich eigene Eintraege
+// mit Which-ID 0 (werden nur fuer getPropertySetInfo benoetigt).
+
+const SfxItemPropertySet* lcl_GetColumnPropertySet()
+{
+ static SfxItemPropertyMapEntry aColumnPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+// {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_OWIDTH), SC_WID_UNO_OWIDTH, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLWID), SC_WID_UNO_CELLWID, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aColumnPropertySet( aColumnPropertyMap_Impl );
+ return &aColumnPropertySet;
+}
+
+const SfxItemPropertySet* lcl_GetRowPropertySet()
+{
+ static SfxItemPropertyMapEntry aRowPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHGT), SC_WID_UNO_CELLHGT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), SC_WID_UNO_CELLFILT,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), SC_WID_UNO_MANPAGE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), SC_WID_UNO_NEWPAGE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT), SC_WID_UNO_OHEIGHT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aRowPropertySet( aRowPropertyMap_Impl );
+ return &aRowPropertySet;
+}
+
+const SfxItemPropertySet* lcl_GetSheetPropertySet()
+{
+ static SfxItemPropertyMapEntry aSheetPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ABSNAME), SC_WID_UNO_ABSNAME, &getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_AUTOPRINT),SC_WID_UNO_AUTOPRINT,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BORDCOL), SC_WID_UNO_BORDCOL, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &getCppuType((sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &getCppuType((util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLSTYL), SC_WID_UNO_CELLSTYL,&getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&getCppuType((float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&getCppuType((awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&getCppuType((float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHCOLHDR), SC_WID_UNO_CHCOLHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CHROWHDR), SC_WID_UNO_CHROWHDR,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDFMT), SC_WID_UNO_CONDFMT, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDLOC), SC_WID_UNO_CONDLOC, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CONDXML), SC_WID_UNO_CONDXML, &getCppuType((uno::Reference<sheet::XSheetConditionalEntries>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COPYBACK), SC_WID_UNO_COPYBACK,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COPYFORM), SC_WID_UNO_COPYFORM,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COPYSTYL), SC_WID_UNO_COPYSTYL,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine2*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &getCppuType((table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ISACTIVE), SC_WID_UNO_ISACTIVE,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), SC_WID_UNO_CELLVIS, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT), SC_WID_UNO_LINKDISPBIT,&getCppuType((uno::Reference<awt::XBitmap>*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), SC_WID_UNO_LINKDISPNAME,&getCppuType((rtl::OUString*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &getCppuType((table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PAGESTL), SC_WID_UNO_PAGESTL, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &getCppuType((sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &getCppuType((sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_POS), SC_WID_UNO_POS, &getCppuType((awt::Point*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PRINTBORD),SC_WID_UNO_PRINTBORD,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PROTECT), SC_WID_UNO_PROTECT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &getCppuType((table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHOWBORD), SC_WID_UNO_SHOWBORD,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SIZE), SC_WID_UNO_SIZE, &getCppuType((awt::Size*)0), 0 | beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &getCppuType((table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TABLAYOUT),SC_WID_UNO_TABLAYOUT,&getCppuType((sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine2*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIDAT), SC_WID_UNO_VALIDAT, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALILOC), SC_WID_UNO_VALILOC, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VALIXML), SC_WID_UNO_VALIXML, &getCppuType((uno::Reference<beans::XPropertySet>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TABCOLOR), SC_WID_UNO_TABCOLOR, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_CODENAME), SC_WID_UNO_CODENAME, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aSheetPropertySet( aSheetPropertyMap_Impl );
+ return &aSheetPropertySet;
+}
+
+const SfxItemPropertyMapEntry* lcl_GetEditPropertyMap()
+{
+ static SfxItemPropertyMapEntry aEditPropertyMap_Impl[] =
+ {
+ SVX_UNOEDIT_CHAR_PROPERTIES,
+ SVX_UNOEDIT_FONT_PROPERTIES,
+ SVX_UNOEDIT_PARA_PROPERTIES,
+ SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
+ {MAP_CHAR_LEN(SC_UNONAME_TEXTUSER), EE_CHAR_XMLATTRIBS, &getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), EE_PARA_XMLATTRIBS, &getCppuType((const uno::Reference< container::XNameContainer >*)0), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aEditPropertyMap_Impl;
+}
+const SvxItemPropertySet* lcl_GetEditPropertySet()
+{
+ static SvxItemPropertySet aEditPropertySet( lcl_GetEditPropertyMap(), SdrObject::GetGlobalDrawObjectItemPool() );
+ return &aEditPropertySet;
+}
+
+
+//------------------------------------------------------------------------
+
+//! diese Funktionen in einen allgemeinen Header verschieben
+inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
+inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
+
+//------------------------------------------------------------------------
+
+#define SCCHARPROPERTIES_SERVICE "com.sun.star.style.CharacterProperties"
+#define SCPARAPROPERTIES_SERVICE "com.sun.star.style.ParagraphProperties"
+#define SCCELLPROPERTIES_SERVICE "com.sun.star.table.CellProperties"
+#define SCCELLRANGE_SERVICE "com.sun.star.table.CellRange"
+#define SCCELL_SERVICE "com.sun.star.table.Cell"
+#define SCSHEETCELLRANGES_SERVICE "com.sun.star.sheet.SheetCellRanges"
+#define SCSHEETCELLRANGE_SERVICE "com.sun.star.sheet.SheetCellRange"
+#define SCSPREADSHEET_SERVICE "com.sun.star.sheet.Spreadsheet"
+#define SCSHEETCELL_SERVICE "com.sun.star.sheet.SheetCell"
+
+SC_SIMPLE_SERVICE_INFO( ScCellFormatsEnumeration, "ScCellFormatsEnumeration", "com.sun.star.sheet.CellFormatRangesEnumeration" )
+SC_SIMPLE_SERVICE_INFO( ScCellFormatsObj, "ScCellFormatsObj", "com.sun.star.sheet.CellFormatRanges" )
+SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsEnumeration, "ScUniqueCellFormatsEnumeration", "com.sun.star.sheet.UniqueCellFormatRangesEnumeration" )
+SC_SIMPLE_SERVICE_INFO( ScUniqueCellFormatsObj, "ScUniqueCellFormatsObj", "com.sun.star.sheet.UniqueCellFormatRanges" )
+SC_SIMPLE_SERVICE_INFO( ScCellRangesBase, "ScCellRangesBase", "stardiv.unknown" )
+SC_SIMPLE_SERVICE_INFO( ScCellsEnumeration, "ScCellsEnumeration", "com.sun.star.sheet.CellsEnumeration" )
+SC_SIMPLE_SERVICE_INFO( ScCellsObj, "ScCellsObj", "com.sun.star.sheet.Cells" )
+SC_SIMPLE_SERVICE_INFO( ScTableColumnObj, "ScTableColumnObj", "com.sun.star.table.TableColumn" )
+SC_SIMPLE_SERVICE_INFO( ScTableRowObj, "ScTableRowObj", "com.sun.star.table.TableRow" )
+
+//------------------------------------------------------------------------
+
+SV_IMPL_PTRARR( XModifyListenerArr_Impl, XModifyListenerPtr );
+SV_IMPL_PTRARR( ScNamedEntryArr_Impl, ScNamedEntryPtr );
+
+//------------------------------------------------------------------------
+
+//! ScLinkListener in anderes File verschieben !!!
+
+ScLinkListener::~ScLinkListener()
+{
+}
+
+void ScLinkListener::Notify( SvtBroadcaster&, const SfxHint& rHint )
+{
+ aLink.Call( (SfxHint*)&rHint );
+}
+
+//------------------------------------------------------------------------
+
+void lcl_CopyProperties( beans::XPropertySet& rDest, beans::XPropertySet& rSource )
+{
+ uno::Reference<beans::XPropertySetInfo> xInfo(rSource.getPropertySetInfo());
+ if (xInfo.is())
+ {
+ uno::Sequence<beans::Property> aSeq(xInfo->getProperties());
+ const beans::Property* pAry = aSeq.getConstArray();
+ ULONG nCount = aSeq.getLength();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ rtl::OUString aName(pAry[i].Name);
+ rDest.setPropertyValue( aName, rSource.getPropertyValue( aName ) );
+ }
+ }
+}
+
+SCTAB lcl_FirstTab( const ScRangeList& rRanges )
+{
+ DBG_ASSERT(rRanges.Count() >= 1, "was fuer Ranges ?!?!");
+ const ScRange* pFirst = rRanges.GetObject(0);
+ if (pFirst)
+ return pFirst->aStart.Tab();
+
+ return 0; // soll nicht sein
+}
+
+BOOL lcl_WholeSheet( const ScRangeList& rRanges )
+{
+ if ( rRanges.Count() == 1 )
+ {
+ ScRange* pRange = rRanges.GetObject(0);
+ if ( pRange && pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
+ pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+ScSubTotalFunc lcl_SummaryToSubTotal( sheet::GeneralFunction eSummary )
+{
+ ScSubTotalFunc eSubTotal;
+ switch (eSummary)
+ {
+ case sheet::GeneralFunction_SUM:
+ eSubTotal = SUBTOTAL_FUNC_SUM;
+ break;
+ case sheet::GeneralFunction_COUNT:
+ eSubTotal = SUBTOTAL_FUNC_CNT2;
+ break;
+ case sheet::GeneralFunction_AVERAGE:
+ eSubTotal = SUBTOTAL_FUNC_AVE;
+ break;
+ case sheet::GeneralFunction_MAX:
+ eSubTotal = SUBTOTAL_FUNC_MAX;
+ break;
+ case sheet::GeneralFunction_MIN:
+ eSubTotal = SUBTOTAL_FUNC_MIN;
+ break;
+ case sheet::GeneralFunction_PRODUCT:
+ eSubTotal = SUBTOTAL_FUNC_PROD;
+ break;
+ case sheet::GeneralFunction_COUNTNUMS:
+ eSubTotal = SUBTOTAL_FUNC_CNT;
+ break;
+ case sheet::GeneralFunction_STDEV:
+ eSubTotal = SUBTOTAL_FUNC_STD;
+ break;
+ case sheet::GeneralFunction_STDEVP:
+ eSubTotal = SUBTOTAL_FUNC_STDP;
+ break;
+ case sheet::GeneralFunction_VAR:
+ eSubTotal = SUBTOTAL_FUNC_VAR;
+ break;
+ case sheet::GeneralFunction_VARP:
+ eSubTotal = SUBTOTAL_FUNC_VARP;
+ break;
+
+ case sheet::GeneralFunction_NONE:
+ case sheet::GeneralFunction_AUTO:
+ default:
+ eSubTotal = SUBTOTAL_FUNC_NONE;
+ break;
+ }
+ return eSubTotal;
+}
+
+//------------------------------------------------------------------------
+
+const SvxBorderLine* ScHelperFunctions::GetBorderLine( SvxBorderLine& rLine, const table::BorderLine& rStruct )
+{
+ // Calc braucht Twips, im Uno-Struct sind 1/100mm
+
+ rLine.SetOutWidth( (USHORT)HMMToTwips( rStruct.OuterLineWidth ) );
+ rLine.SetInWidth( (USHORT)HMMToTwips( rStruct.InnerLineWidth ) );
+ rLine.SetDistance( (USHORT)HMMToTwips( rStruct.LineDistance ) );
+ rLine.SetColor( ColorData( rStruct.Color ) );
+
+ if ( rLine.GetOutWidth() || rLine.GetInWidth() || rLine.GetDistance() )
+ return &rLine;
+ else
+ return NULL;
+}
+
+void ScHelperFunctions::FillBoxItems( SvxBoxItem& rOuter, SvxBoxInfoItem& rInner, const table::TableBorder& rBorder )
+{
+ SvxBorderLine aLine;
+ rOuter.SetDistance( (USHORT)HMMToTwips( rBorder.Distance ) );
+ rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.TopLine ), BOX_LINE_TOP );
+ rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.BottomLine ), BOX_LINE_BOTTOM );
+ rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.LeftLine ), BOX_LINE_LEFT );
+ rOuter.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.RightLine ), BOX_LINE_RIGHT );
+ rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.HorizontalLine ), BOXINFO_LINE_HORI );
+ rInner.SetLine( ScHelperFunctions::GetBorderLine( aLine, rBorder.VerticalLine ), BOXINFO_LINE_VERT );
+ rInner.SetValid( VALID_TOP, rBorder.IsTopLineValid );
+ rInner.SetValid( VALID_BOTTOM, rBorder.IsBottomLineValid );
+ rInner.SetValid( VALID_LEFT, rBorder.IsLeftLineValid );
+ rInner.SetValid( VALID_RIGHT, rBorder.IsRightLineValid );
+ rInner.SetValid( VALID_HORI, rBorder.IsHorizontalLineValid );
+ rInner.SetValid( VALID_VERT, rBorder.IsVerticalLineValid );
+ rInner.SetValid( VALID_DISTANCE, rBorder.IsDistanceValid );
+ rInner.SetTable( TRUE );
+}
+
+void ScHelperFunctions::FillBorderLine( table::BorderLine& rStruct, const SvxBorderLine* pLine )
+{
+ if (pLine)
+ {
+ rStruct.Color = pLine->GetColor().GetColor();
+ rStruct.InnerLineWidth = (sal_Int16)TwipsToHMM( pLine->GetInWidth() );
+ rStruct.OuterLineWidth = (sal_Int16)TwipsToHMM( pLine->GetOutWidth() );
+ rStruct.LineDistance = (sal_Int16)TwipsToHMM( pLine->GetDistance() );
+ }
+ else
+ rStruct.Color = rStruct.InnerLineWidth =
+ rStruct.OuterLineWidth = rStruct.LineDistance = 0;
+}
+
+void ScHelperFunctions::FillTableBorder( table::TableBorder& rBorder,
+ const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
+{
+ ScHelperFunctions::FillBorderLine( rBorder.TopLine, rOuter.GetTop() );
+ ScHelperFunctions::FillBorderLine( rBorder.BottomLine, rOuter.GetBottom() );
+ ScHelperFunctions::FillBorderLine( rBorder.LeftLine, rOuter.GetLeft() );
+ ScHelperFunctions::FillBorderLine( rBorder.RightLine, rOuter.GetRight() );
+ ScHelperFunctions::FillBorderLine( rBorder.HorizontalLine, rInner.GetHori() );
+ ScHelperFunctions::FillBorderLine( rBorder.VerticalLine, rInner.GetVert() );
+
+ rBorder.Distance = rOuter.GetDistance();
+ rBorder.IsTopLineValid = rInner.IsValid(VALID_TOP);
+ rBorder.IsBottomLineValid = rInner.IsValid(VALID_BOTTOM);
+ rBorder.IsLeftLineValid = rInner.IsValid(VALID_LEFT);
+ rBorder.IsRightLineValid = rInner.IsValid(VALID_RIGHT);
+ rBorder.IsHorizontalLineValid = rInner.IsValid(VALID_HORI);
+ rBorder.IsVerticalLineValid = rInner.IsValid(VALID_VERT);
+ rBorder.IsDistanceValid = rInner.IsValid(VALID_DISTANCE);
+}
+
+//------------------------------------------------------------------------
+
+//! lcl_ApplyBorder nach docfunc verschieben!
+
+void ScHelperFunctions::ApplyBorder( ScDocShell* pDocShell, const ScRangeList& rRanges,
+ const SvxBoxItem& rOuter, const SvxBoxInfoItem& rInner )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ ScDocument* pUndoDoc = NULL;
+ if (bUndo)
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ULONG nCount = rRanges.Count();
+ ULONG i;
+ for (i=0; i<nCount; i++)
+ {
+ ScRange aRange(*rRanges.GetObject(i));
+ SCTAB nTab = aRange.aStart.Tab();
+
+ if (bUndo)
+ {
+ if ( i==0 )
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ else
+ pUndoDoc->AddUndoTab( nTab, nTab );
+ pDoc->CopyToDocument( aRange, IDF_ATTRIB, FALSE, pUndoDoc );
+ }
+
+ ScMarkData aMark;
+ aMark.SetMarkArea( aRange );
+ aMark.SelectTable( nTab, TRUE );
+
+ pDoc->ApplySelectionFrame( aMark, &rOuter, &rInner );
+ // RowHeight bei Umrandung alleine nicht noetig
+ }
+
+ if (bUndo)
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoBorder( pDocShell, rRanges, pUndoDoc, rOuter, rInner ) );
+ }
+
+ for (i=0; i<nCount; i++)
+ pDocShell->PostPaint( *rRanges.GetObject(i), PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ pDocShell->SetDocumentModified();
+}
+
+//! move lcl_PutDataArray to docfunc?
+//! merge loop with ScFunctionAccess::callFunction
+
+BOOL lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
+ const uno::Sequence< uno::Sequence<uno::Any> >& aData )
+{
+// BOOL bApi = TRUE;
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCTAB nTab = rRange.aStart.Tab();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
+ {
+ //! error message
+ return FALSE;
+ }
+
+ long nCols = 0;
+ long nRows = aData.getLength();
+ const uno::Sequence<uno::Any>* pArray = aData.getConstArray();
+ if ( nRows )
+ nCols = pArray[0].getLength();
+
+ if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
+ {
+ //! error message?
+ return FALSE;
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bUndo )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( rRange, IDF_CONTENTS|IDF_NOCAPTIONS, FALSE, pUndoDoc );
+ }
+
+ pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
+
+ BOOL bError = FALSE;
+ SCROW nDocRow = nStartRow;
+ for (long nRow=0; nRow<nRows; nRow++)
+ {
+ const uno::Sequence<uno::Any>& rColSeq = pArray[nRow];
+ if ( rColSeq.getLength() == nCols )
+ {
+ SCCOL nDocCol = nStartCol;
+ const uno::Any* pColArr = rColSeq.getConstArray();
+ for (long nCol=0; nCol<nCols; nCol++)
+ {
+ const uno::Any& rElement = pColArr[nCol];
+ uno::TypeClass eElemClass = rElement.getValueTypeClass();
+ if ( eElemClass == uno::TypeClass_VOID )
+ {
+ // void = "no value"
+ pDoc->SetError( nDocCol, nDocRow, nTab, NOTAVAILABLE );
+ }
+ else if ( eElemClass == uno::TypeClass_BYTE ||
+ eElemClass == uno::TypeClass_SHORT ||
+ eElemClass == uno::TypeClass_UNSIGNED_SHORT ||
+ eElemClass == uno::TypeClass_LONG ||
+ eElemClass == uno::TypeClass_UNSIGNED_LONG ||
+ eElemClass == uno::TypeClass_FLOAT ||
+ eElemClass == uno::TypeClass_DOUBLE )
+ {
+ // #87871# accept integer types because Basic passes a floating point
+ // variable as byte, short or long if it's an integer number.
+ double fVal(0.0);
+ rElement >>= fVal;
+ pDoc->SetValue( nDocCol, nDocRow, nTab, fVal );
+ }
+ else if ( eElemClass == uno::TypeClass_STRING )
+ {
+ rtl::OUString aUStr;
+ rElement >>= aUStr;
+ if ( aUStr.getLength() )
+ pDoc->PutCell( nDocCol, nDocRow, nTab, new ScStringCell( aUStr ) );
+ }
+ else
+ bError = TRUE; // invalid type
+
+ ++nDocCol;
+ }
+ }
+ else
+ bError = TRUE; // wrong size
+
+ ++nDocRow;
+ }
+
+ BOOL bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
+
+ if ( pUndoDoc )
+ {
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( nTab );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoPaste( &rDocShell,
+ nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, aDestMark,
+ pUndoDoc, NULL, IDF_CONTENTS, NULL,NULL,NULL,NULL, FALSE ) );
+ }
+
+ if (!bHeight)
+ rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
+
+ rDocShell.SetDocumentModified();
+
+ return !bError;
+}
+
+BOOL lcl_PutFormulaArray( ScDocShell& rDocShell, const ScRange& rRange,
+ const uno::Sequence< uno::Sequence<rtl::OUString> >& aData,
+ const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
+{
+// BOOL bApi = TRUE;
+
+ ScDocument* pDoc = rDocShell.GetDocument();
+ SCTAB nTab = rRange.aStart.Tab();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ SCCOL nEndCol = rRange.aEnd.Col();
+ SCROW nEndRow = rRange.aEnd.Row();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ if ( !pDoc->IsBlockEditable( nTab, nStartCol,nStartRow, nEndCol,nEndRow ) )
+ {
+ //! error message
+ return FALSE;
+ }
+
+ long nCols = 0;
+ long nRows = aData.getLength();
+ const uno::Sequence<rtl::OUString>* pArray = aData.getConstArray();
+ if ( nRows )
+ nCols = pArray[0].getLength();
+
+ if ( nCols != nEndCol-nStartCol+1 || nRows != nEndRow-nStartRow+1 )
+ {
+ //! error message?
+ return FALSE;
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bUndo )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( rRange, IDF_CONTENTS, FALSE, pUndoDoc );
+ }
+
+ pDoc->DeleteAreaTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, IDF_CONTENTS );
+
+ ScDocFunc aFunc( rDocShell ); // for InterpretEnglishString
+
+ BOOL bError = FALSE;
+ SCROW nDocRow = nStartRow;
+ for (long nRow=0; nRow<nRows; nRow++)
+ {
+ const uno::Sequence<rtl::OUString>& rColSeq = pArray[nRow];
+ if ( rColSeq.getLength() == nCols )
+ {
+ SCCOL nDocCol = nStartCol;
+ const rtl::OUString* pColArr = rColSeq.getConstArray();
+ for (long nCol=0; nCol<nCols; nCol++)
+ {
+ String aText(pColArr[nCol]);
+ ScAddress aPos( nDocCol, nDocRow, nTab );
+ ScBaseCell* pNewCell = aFunc.InterpretEnglishString( aPos, aText, rFormulaNmsp, eGrammar );
+ pDoc->PutCell( aPos, pNewCell );
+
+ ++nDocCol;
+ }
+ }
+ else
+ bError = TRUE; // wrong size
+
+ ++nDocRow;
+ }
+
+ BOOL bHeight = rDocShell.AdjustRowHeight( nStartRow, nEndRow, nTab );
+
+ if ( pUndoDoc )
+ {
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( nTab );
+ rDocShell.GetUndoManager()->AddUndoAction(
+ new ScUndoPaste( &rDocShell,
+ nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab, aDestMark,
+ pUndoDoc, NULL, IDF_CONTENTS, NULL,NULL,NULL,NULL, FALSE ) );
+ }
+
+ if (!bHeight)
+ rDocShell.PostPaint( rRange, PAINT_GRID ); // AdjustRowHeight may have painted already
+
+ rDocShell.SetDocumentModified();
+
+ return !bError;
+}
+
+// used in ScCellRangeObj::getFormulaArray and ScCellObj::GetInputString_Impl
+String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, BOOL bEnglish )
+{
+ String aVal;
+ if ( pDoc )
+ {
+ ScBaseCell* pCell = pDoc->GetCell( rPosition );
+ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
+ {
+ CellType eType = pCell->GetCellType();
+ if ( eType == CELLTYPE_FORMULA )
+ {
+ ScFormulaCell* pForm = (ScFormulaCell*)pCell;
+ pForm->GetFormula( aVal,formula::FormulaGrammar::mapAPItoGrammar( bEnglish, false));
+ }
+ else
+ {
+ SvNumberFormatter* pFormatter = bEnglish ? ScGlobal::GetEnglishFormatter() :
+ pDoc->GetFormatTable();
+ // Since the English formatter was constructed with
+ // LANGUAGE_ENGLISH_US the "General" format has index key 0,
+ // we don't have to query.
+ sal_uInt32 nNumFmt = bEnglish ?
+// pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US) :
+ 0 :
+ pDoc->GetNumberFormat( rPosition );
+
+ if ( eType == CELLTYPE_EDIT )
+ {
+ // GetString an der EditCell macht Leerzeichen aus Umbruechen,
+ // hier werden die Umbrueche aber gebraucht
+ const EditTextObject* pData = ((ScEditCell*)pCell)->GetData();
+ if (pData)
+ {
+ EditEngine& rEngine = pDoc->GetEditEngine();
+ rEngine.SetText( *pData );
+ aVal = rEngine.GetText( LINEEND_LF );
+ }
+ }
+ else
+ ScCellFormat::GetInputString( pCell, nNumFmt, aVal, *pFormatter );
+
+ // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler
+ if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT )
+ {
+ double fDummy;
+ sal_Bool bIsNumberFormat(pFormatter->IsNumberFormat(aVal, nNumFmt, fDummy));
+ if ( bIsNumberFormat )
+ aVal.Insert('\'',0);
+ else if ( aVal.Len() && aVal.GetChar(0) == '\'' )
+ {
+ // if the string starts with a "'", add another one because setFormula
+ // strips one (like text input, except for "text" number formats)
+ if ( bEnglish || ( pFormatter->GetType(nNumFmt) != NUMBERFORMAT_TEXT ) )
+ aVal.Insert('\'',0);
+ }
+ }
+ }
+ }
+ }
+ return aVal;
+}
+
+//------------------------------------------------------------------------
+
+// Default-ctor fuer SMART_REFLECTION Krempel
+ScCellRangesBase::ScCellRangesBase() :
+ pPropSet(lcl_GetCellsPropertySet()),
+ pDocShell( NULL ),
+ pValueListener( NULL ),
+ pCurrentFlat( NULL ),
+ pCurrentDeep( NULL ),
+ pCurrentDataSet( NULL ),
+ pNoDfltCurrentDataSet( NULL ),
+ pMarkData( NULL ),
+ nObjectId( 0 ),
+ bChartColAsHdr( FALSE ),
+ bChartRowAsHdr( FALSE ),
+ bCursorOnly( FALSE ),
+ bGotDataChangedHint( FALSE ),
+ aValueListeners( 0 )
+{
+}
+
+ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRange& rR) :
+ pPropSet(lcl_GetCellsPropertySet()),
+ pDocShell( pDocSh ),
+ pValueListener( NULL ),
+ pCurrentFlat( NULL ),
+ pCurrentDeep( NULL ),
+ pCurrentDataSet( NULL ),
+ pNoDfltCurrentDataSet( NULL ),
+ pMarkData( NULL ),
+ nObjectId( 0 ),
+ bChartColAsHdr( FALSE ),
+ bChartRowAsHdr( FALSE ),
+ bCursorOnly( FALSE ),
+ bGotDataChangedHint( FALSE ),
+ aValueListeners( 0 )
+{
+ ScRange aCellRange(rR);
+ aCellRange.Justify();
+ aRanges.Append( aCellRange );
+
+ if (pDocShell) // Null if created with createInstance
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->AddUnoObject(*this);
+ nObjectId = pDoc->GetNewUnoId();
+ }
+}
+
+ScCellRangesBase::ScCellRangesBase(ScDocShell* pDocSh, const ScRangeList& rR) :
+ pPropSet(lcl_GetCellsPropertySet()),
+ pDocShell( pDocSh ),
+ pValueListener( NULL ),
+ pCurrentFlat( NULL ),
+ pCurrentDeep( NULL ),
+ pCurrentDataSet( NULL ),
+ pNoDfltCurrentDataSet( NULL ),
+ pMarkData( NULL ),
+ aRanges( rR ),
+ nObjectId( 0 ),
+ bChartColAsHdr( FALSE ),
+ bChartRowAsHdr( FALSE ),
+ bCursorOnly( FALSE ),
+ bGotDataChangedHint( FALSE ),
+ aValueListeners( 0 )
+{
+ if (pDocShell) // Null if created with createInstance
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->AddUnoObject(*this);
+ nObjectId = pDoc->GetNewUnoId();
+ }
+}
+
+ScCellRangesBase::~ScCellRangesBase()
+{
+ // #107294# call RemoveUnoObject first, so no notification can happen
+ // during ForgetCurrentAttrs
+
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+
+ ForgetCurrentAttrs();
+ ForgetMarkData();
+
+ delete pValueListener;
+
+ //! XChartDataChangeEventListener abmelden ??
+ //! (ChartCollection haelt dann auch dieses Objekt fest!)
+}
+
+void ScCellRangesBase::ForgetCurrentAttrs()
+{
+ delete pCurrentFlat;
+ delete pCurrentDeep;
+ delete pCurrentDataSet;
+ delete pNoDfltCurrentDataSet;
+ pCurrentFlat = NULL;
+ pCurrentDeep = NULL;
+ pCurrentDataSet = NULL;
+ pNoDfltCurrentDataSet = NULL;
+
+ // #i62483# pMarkData can remain unchanged, is deleted only if the range changes (RefChanged)
+}
+
+void ScCellRangesBase::ForgetMarkData()
+{
+ delete pMarkData;
+ pMarkData = NULL;
+}
+
+const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsFlat()
+{
+ // get and cache direct cell attributes for this object's range
+
+ if ( !pCurrentFlat && pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pCurrentFlat = pDoc->CreateSelectionPattern( *GetMarkData(), FALSE );
+ }
+ return pCurrentFlat;
+}
+
+const ScPatternAttr* ScCellRangesBase::GetCurrentAttrsDeep()
+{
+ // get and cache cell attributes (incl. styles) for this object's range
+
+ if ( !pCurrentDeep && pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pCurrentDeep = pDoc->CreateSelectionPattern( *GetMarkData(), TRUE );
+ }
+ return pCurrentDeep;
+}
+
+SfxItemSet* ScCellRangesBase::GetCurrentDataSet(bool bNoDflt)
+{
+ if(!pCurrentDataSet)
+ {
+ const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
+ if ( pPattern )
+ {
+ // Dontcare durch Default ersetzen, damit man immer eine Reflection hat
+ pCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
+ pNoDfltCurrentDataSet = new SfxItemSet( pPattern->GetItemSet() );
+ pCurrentDataSet->ClearInvalidItems();
+ }
+ }
+ return bNoDflt ? pNoDfltCurrentDataSet : pCurrentDataSet;
+}
+
+const ScMarkData* ScCellRangesBase::GetMarkData()
+{
+ if (!pMarkData)
+ {
+ pMarkData = new ScMarkData();
+ pMarkData->MarkFromRangeList( aRanges, FALSE );
+ }
+ return pMarkData;
+}
+
+void ScCellRangesBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangeList* pUndoRanges = NULL;
+ if ( pDoc->HasUnoRefUndo() )
+ pUndoRanges = new ScRangeList( aRanges );
+
+ if ( aRanges.UpdateReference( rRef.GetMode(), pDoc, rRef.GetRange(),
+ rRef.GetDx(), rRef.GetDy(), rRef.GetDz() ) )
+ {
+ if (rRef.GetMode() == URM_INSDEL &&
+ aRanges.Count() == 1 &&
+ ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ))
+ {
+ // #101755#; the range size of a sheet does not change
+ ScRange* pR = aRanges.First();
+ if (pR)
+ {
+ pR->aStart.SetCol(0);
+ pR->aStart.SetRow(0);
+ pR->aEnd.SetCol(MAXCOL);
+ pR->aEnd.SetRow(MAXROW);
+ }
+ }
+ RefChanged();
+
+ // #129050# any change of the range address is broadcast to value (modify) listeners
+ if ( aValueListeners.Count() )
+ bGotDataChangedHint = TRUE;
+
+ if ( pUndoRanges )
+ pDoc->AddUnoRefChange( nObjectId, *pUndoRanges );
+ }
+
+ delete pUndoRanges;
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ ForgetCurrentAttrs();
+ pDocShell = NULL; // invalid
+
+ if ( aValueListeners.Count() != 0 )
+ {
+ // dispose listeners
+
+ lang::EventObject aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ for ( USHORT n=0; n<aValueListeners.Count(); n++ )
+ (*aValueListeners[n])->disposing( aEvent );
+
+ aValueListeners.DeleteAndDestroy( 0, aValueListeners.Count() );
+
+ // The listeners can't have the last ref to this, as it's still held
+ // by the DocShell.
+ }
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ {
+ // document content changed -> forget cached attributes
+ ForgetCurrentAttrs();
+
+ if ( bGotDataChangedHint && pDocShell )
+ {
+ // This object was notified of content changes, so one call
+ // for each listener is generated now.
+ // The calls can't be executed directly because the document's
+ // UNO broadcaster list must not be modified.
+ // Instead, add to the document's list of listener calls,
+ // which will be executed directly after the broadcast of
+ // SFX_HINT_DATACHANGED.
+
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+
+ // the EventObject holds a Ref to this object until after the listener calls
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ for ( USHORT n=0; n<aValueListeners.Count(); n++ )
+ pDoc->AddUnoListenerCall( *aValueListeners[n], aEvent );
+
+ bGotDataChangedHint = FALSE;
+ }
+ }
+ else if ( nId == SC_HINT_CALCALL )
+ {
+ // broadcast from DoHardRecalc - set bGotDataChangedHint
+ // (SFX_HINT_DATACHANGED follows separately)
+
+ if ( aValueListeners.Count() )
+ bGotDataChangedHint = TRUE;
+ }
+ }
+ else if ( rHint.ISA( ScUnoRefUndoHint ) )
+ {
+ const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
+ if ( rUndoHint.GetObjectId() == nObjectId )
+ {
+ // restore ranges from hint
+
+ aRanges = rUndoHint.GetRanges();
+
+ RefChanged();
+ if ( aValueListeners.Count() )
+ bGotDataChangedHint = TRUE; // need to broadcast the undo, too
+ }
+ }
+}
+
+void ScCellRangesBase::RefChanged()
+{
+ //! adjust XChartDataChangeEventListener
+
+ if ( pValueListener && aValueListeners.Count() != 0 )
+ {
+ pValueListener->EndListeningAll();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ pDoc->StartListeningArea( *aRanges.GetObject(i), pValueListener );
+ }
+
+ ForgetCurrentAttrs();
+ ForgetMarkData();
+}
+
+ScDocument* ScCellRangesBase::GetDocument() const
+{
+ if (pDocShell)
+ return pDocShell->GetDocument();
+ else
+ return NULL;
+}
+
+void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
+{
+ if ( !pDocShell && pDocSh )
+ {
+ pDocShell = pDocSh;
+
+ ScRange aCellRange(rR);
+ aCellRange.Justify();
+ aRanges.RemoveAll();
+ aRanges.Append( aCellRange );
+
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ RefChanged(); // Range im Range-Objekt anpassen
+ }
+}
+
+void ScCellRangesBase::AddRange(const ScRange& rRange, const sal_Bool bMergeRanges)
+{
+ if (bMergeRanges)
+ aRanges.Join(rRange);
+ else
+ aRanges.Append(rRange);
+ RefChanged();
+}
+
+void ScCellRangesBase::SetNewRange(const ScRange& rNew)
+{
+ ScRange aCellRange(rNew);
+ aCellRange.Justify();
+
+ aRanges.RemoveAll();
+ aRanges.Append( aCellRange );
+ RefChanged();
+}
+
+void ScCellRangesBase::SetNewRanges(const ScRangeList& rNew)
+{
+ aRanges = rNew;
+ RefChanged();
+}
+
+void ScCellRangesBase::SetCursorOnly( BOOL bSet )
+{
+ // set for a selection object that is created from the cursor position
+ // without anything selected (may contain several sheets)
+
+ bCursorOnly = bSet;
+}
+
+uno::Any SAL_CALL ScCellRangesBase::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( beans::XPropertySet )
+ SC_QUERYINTERFACE( beans::XMultiPropertySet )
+ SC_QUERYINTERFACE( beans::XTolerantMultiPropertySet )
+ SC_QUERYINTERFACE( beans::XPropertyState )
+ SC_QUERYINTERFACE( sheet::XSheetOperation )
+ SC_QUERYINTERFACE( chart::XChartDataArray )
+ SC_QUERYINTERFACE( chart::XChartData )
+ SC_QUERYINTERFACE( util::XIndent )
+ SC_QUERYINTERFACE( sheet::XCellRangesQuery )
+ SC_QUERYINTERFACE( sheet::XFormulaQuery )
+ SC_QUERYINTERFACE( util::XReplaceable )
+ SC_QUERYINTERFACE( util::XSearchable )
+ SC_QUERYINTERFACE( util::XModifyBroadcaster )
+ SC_QUERYINTERFACE( lang::XServiceInfo )
+ SC_QUERYINTERFACE( lang::XUnoTunnel )
+ SC_QUERYINTERFACE( lang::XTypeProvider )
+
+ return OWeakObject::queryInterface( rType );
+}
+
+void SAL_CALL ScCellRangesBase::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL ScCellRangesBase::release() throw()
+{
+ OWeakObject::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScCellRangesBase::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ aTypes.realloc(13);
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[0] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
+ pPtr[1] = getCppuType((const uno::Reference<beans::XMultiPropertySet>*)0);
+ pPtr[2] = getCppuType((const uno::Reference<beans::XPropertyState>*)0);
+ pPtr[3] = getCppuType((const uno::Reference<sheet::XSheetOperation>*)0);
+ pPtr[4] = getCppuType((const uno::Reference<chart::XChartDataArray>*)0);
+ pPtr[5] = getCppuType((const uno::Reference<util::XIndent>*)0);
+ pPtr[6] = getCppuType((const uno::Reference<sheet::XCellRangesQuery>*)0);
+ pPtr[7] = getCppuType((const uno::Reference<sheet::XFormulaQuery>*)0);
+ pPtr[8] = getCppuType((const uno::Reference<util::XReplaceable>*)0);
+ pPtr[9] = getCppuType((const uno::Reference<util::XModifyBroadcaster>*)0);
+ pPtr[10]= getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
+ pPtr[11]= getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
+ pPtr[12]= getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScCellRangesBase::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// ---
+
+void ScCellRangesBase::PaintRanges_Impl( USHORT nPart )
+{
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ pDocShell->PostPaint( *aRanges.GetObject(i), nPart );
+}
+
+// XSheetOperation
+
+double SAL_CALL ScCellRangesBase::computeFunction( sheet::GeneralFunction nFunction )
+ throw(uno::Exception, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScMarkData aMark(*GetMarkData());
+ aMark.MarkToSimple();
+ if (!aMark.IsMarked())
+ aMark.SetMarkNegative(TRUE); // um Dummy Position angeben zu koennen
+
+ ScAddress aDummy; // wenn nicht Marked, ignoriert wegen Negative
+ double fVal;
+ ScSubTotalFunc eFunc = lcl_SummaryToSubTotal( nFunction );
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( !pDoc->GetSelectionFunction( eFunc, aDummy, aMark, fVal ) )
+ {
+ throw uno::RuntimeException(); //! own exception?
+ }
+
+ return fVal;
+}
+
+void SAL_CALL ScCellRangesBase::clearContents( sal_Int32 nContentFlags ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( aRanges.Count() )
+ {
+ // only for clearContents: EDITATTR is only used if no contents are deleted
+ USHORT nDelFlags = static_cast< USHORT >( nContentFlags & IDF_ALL );
+ if ( ( nContentFlags & IDF_EDITATTR ) && ( nContentFlags & IDF_CONTENTS ) == 0 )
+ nDelFlags |= IDF_EDITATTR;
+
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.DeleteContents( *GetMarkData(), nDelFlags, TRUE, TRUE );
+ }
+ // sonst ist nichts zu tun
+}
+
+// XPropertyState
+
+const SfxItemPropertyMap* ScCellRangesBase::GetItemPropertyMap()
+{
+ return pPropSet->getPropertyMap();
+}
+
+void lcl_GetPropertyWhich( const SfxItemPropertySimpleEntry* pEntry,
+ USHORT& rItemWhich )
+{
+ // Which-ID des betroffenen Items, auch wenn das Item die Property
+ // nicht alleine behandeln kann
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ rItemWhich = pEntry->nWID;
+ else
+ switch ( pEntry->nWID )
+ {
+ case SC_WID_UNO_TBLBORD:
+ rItemWhich = ATTR_BORDER;
+ break;
+ case SC_WID_UNO_CONDFMT:
+ case SC_WID_UNO_CONDLOC:
+ case SC_WID_UNO_CONDXML:
+ rItemWhich = ATTR_CONDITIONAL;
+ break;
+ case SC_WID_UNO_VALIDAT:
+ case SC_WID_UNO_VALILOC:
+ case SC_WID_UNO_VALIXML:
+ rItemWhich = ATTR_VALIDDATA;
+ break;
+ }
+ }
+
+}
+
+beans::PropertyState ScCellRangesBase::GetOnePropertyState( USHORT nItemWhich, const SfxItemPropertySimpleEntry* pEntry )
+{
+ beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
+ if ( nItemWhich ) // item wid (from map or special case)
+ {
+ // For items that contain several properties (like background),
+ // "ambiguous" is returned too often here
+
+ // for PropertyState, don't look at styles
+ const ScPatternAttr* pPattern = GetCurrentAttrsFlat();
+ if ( pPattern )
+ {
+ SfxItemState eState = pPattern->GetItemSet().GetItemState( nItemWhich, FALSE );
+
+// // if no rotate value is set, look at orientation
+// //! also for a fixed value of 0 (in case orientation is ambiguous)?
+// if ( nItemWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT )
+// eState = pPattern->GetItemSet().GetItemState( ATTR_ORIENTATION, FALSE );
+
+ if ( nItemWhich == ATTR_VALUE_FORMAT && eState == SFX_ITEM_DEFAULT )
+ eState = pPattern->GetItemSet().GetItemState( ATTR_LANGUAGE_FORMAT, FALSE );
+
+ if ( eState == SFX_ITEM_SET )
+ eRet = beans::PropertyState_DIRECT_VALUE;
+ else if ( eState == SFX_ITEM_DEFAULT )
+ eRet = beans::PropertyState_DEFAULT_VALUE;
+ else if ( eState == SFX_ITEM_DONTCARE )
+ eRet = beans::PropertyState_AMBIGUOUS_VALUE;
+ else
+ {
+ DBG_ERROR("unbekannter ItemState");
+ }
+ }
+ }
+ else if ( pEntry )
+ {
+ if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR || pEntry->nWID == SC_WID_UNO_CHROWHDR || pEntry->nWID == SC_WID_UNO_ABSNAME )
+ eRet = beans::PropertyState_DIRECT_VALUE;
+ else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
+ {
+ // a style is always set, there's no default state
+ const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
+ if (pStyle)
+ eRet = beans::PropertyState_DIRECT_VALUE;
+ else
+ eRet = beans::PropertyState_AMBIGUOUS_VALUE;
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_NUMRULES )
+ eRet = beans::PropertyState_DEFAULT_VALUE; // numbering rules are always default
+ }
+ return eRet;
+}
+
+beans::PropertyState SAL_CALL ScCellRangesBase::getPropertyState( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertyMap* pMap = GetItemPropertyMap(); // from derived class
+ USHORT nItemWhich = 0;
+ const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aPropertyName );
+ lcl_GetPropertyWhich( pEntry, nItemWhich );
+ return GetOnePropertyState( nItemWhich, pEntry );
+}
+
+uno::Sequence<beans::PropertyState> SAL_CALL ScCellRangesBase::getPropertyStates(
+ const uno::Sequence<rtl::OUString>& aPropertyNames )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+
+ uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
+ beans::PropertyState* pStates = aRet.getArray();
+ for(INT32 i = 0; i < aPropertyNames.getLength(); i++)
+ {
+ USHORT nItemWhich = 0;
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
+ lcl_GetPropertyWhich( pEntry, nItemWhich );
+ pStates[i] = GetOnePropertyState(nItemWhich, pEntry);
+ }
+ return aRet;
+}
+
+void SAL_CALL ScCellRangesBase::setPropertyToDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+ USHORT nItemWhich = 0;
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
+ lcl_GetPropertyWhich( pEntry, nItemWhich );
+ if ( nItemWhich ) // item wid (from map or special case)
+ {
+ if ( aRanges.Count() ) // leer = nichts zu tun
+ {
+ ScDocFunc aFunc(*pDocShell);
+
+ //! Bei Items, die mehrere Properties enthalten (z.B. Hintergrund)
+ //! wird hier zuviel zurueckgesetzt
+
+// //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
+
+ USHORT aWIDs[3];
+ aWIDs[0] = nItemWhich;
+ if ( nItemWhich == ATTR_VALUE_FORMAT )
+ {
+ aWIDs[1] = ATTR_LANGUAGE_FORMAT; // #67847# language for number formats
+ aWIDs[2] = 0;
+ }
+ else
+ aWIDs[1] = 0;
+ aFunc.ClearItems( *GetMarkData(), aWIDs, TRUE );
+ }
+ }
+ else if ( pEntry )
+ {
+ if ( pEntry->nWID == SC_WID_UNO_CHCOLHDR )
+ bChartColAsHdr = FALSE;
+ else if ( pEntry->nWID == SC_WID_UNO_CHROWHDR )
+ bChartRowAsHdr = FALSE;
+ else if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.ApplyStyle( *GetMarkData(), ScGlobal::GetRscString(STR_STYLENAME_STANDARD), TRUE, TRUE );
+ }
+ }
+ }
+}
+
+uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ //! mit getPropertyValue zusammenfassen
+
+ SolarMutexGuard aGuard;
+ uno::Any aAny;
+
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ const ScPatternAttr* pPattern = pDoc->GetDefPattern();
+ if ( pPattern )
+ {
+ const SfxItemSet& rSet = pPattern->GetItemSet();
+
+ switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
+ {
+ case ATTR_VALUE_FORMAT:
+ // default has no language set
+ aAny <<= (sal_Int32)( ((const SfxUInt32Item&)rSet.Get(pEntry->nWID)).GetValue() );
+ break;
+ case ATTR_INDENT:
+ aAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
+ rSet.Get(pEntry->nWID)).GetValue()) );
+ break;
+ default:
+ pPropSet->getPropertyValue(aPropertyName, rSet, aAny);
+ }
+ }
+ }
+ else
+ switch ( pEntry->nWID )
+ {
+ case SC_WID_UNO_CHCOLHDR:
+ case SC_WID_UNO_CHROWHDR:
+ ScUnoHelpFunctions::SetBoolInAny( aAny, FALSE );
+ break;
+ case SC_WID_UNO_CELLSTYL:
+ aAny <<= rtl::OUString( ScStyleNameConversion::DisplayToProgrammaticName(
+ ScGlobal::GetRscString(STR_STYLENAME_STANDARD), SFX_STYLE_FAMILY_PARA ) );
+ break;
+ case SC_WID_UNO_TBLBORD:
+ {
+ const ScPatternAttr* pPattern = pDoc->GetDefPattern();
+ if ( pPattern )
+ {
+ table::TableBorder aBorder;
+ ScHelperFunctions::FillTableBorder( aBorder,
+ (const SvxBoxItem&)pPattern->GetItem(ATTR_BORDER),
+ (const SvxBoxInfoItem&)pPattern->GetItem(ATTR_BORDER_INNER) );
+ aAny <<= aBorder;
+ }
+ }
+ break;
+ case SC_WID_UNO_CONDFMT:
+ case SC_WID_UNO_CONDLOC:
+ case SC_WID_UNO_CONDXML:
+ {
+ BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
+ BOOL bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
+ formula::FormulaGrammar::Grammar eGrammar = (bXML ?
+ pDoc->GetStorageGrammar() :
+ formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
+
+ aAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
+ new ScTableConditionalFormat( pDoc, 0, eGrammar ));
+ }
+ break;
+ case SC_WID_UNO_VALIDAT:
+ case SC_WID_UNO_VALILOC:
+ case SC_WID_UNO_VALIXML:
+ {
+ BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
+ BOOL bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
+ formula::FormulaGrammar::Grammar eGrammar = (bXML ?
+ pDoc->GetStorageGrammar() :
+ formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
+
+ aAny <<= uno::Reference<beans::XPropertySet>(
+ new ScTableValidationObj( pDoc, 0, eGrammar ));
+ }
+ break;
+ case SC_WID_UNO_NUMRULES:
+ {
+ aAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
+ }
+ break;
+ }
+ }
+ }
+
+ return aAny;
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangesBase::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( pPropSet->getPropertyMap() ));
+ return aRef;
+}
+
+
+void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const uno::Any& rValue,
+ ScPatternAttr& rPattern, ScDocument* pDoc,
+ USHORT& rFirstItemId, USHORT& rSecondItemId )
+{
+ rFirstItemId = rEntry.nWID;
+ rSecondItemId = 0;
+
+ SfxItemSet& rSet = rPattern.GetItemSet();
+ switch ( rEntry.nWID )
+ {
+ case ATTR_VALUE_FORMAT:
+ {
+ // #67847# language for number formats
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ ULONG nOldFormat = ((const SfxUInt32Item&)rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
+ LanguageType eOldLang = ((const SvxLanguageItem&)rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
+ nOldFormat = pFormatter->GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
+
+ sal_Int32 nIntVal = 0;
+ if ( rValue >>= nIntVal )
+ {
+ ULONG nNewFormat = (ULONG)nIntVal;
+ rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
+
+ const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
+ LanguageType eNewLang =
+ pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
+ if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
+ {
+ rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
+
+ // #40606# if only language is changed,
+ // don't touch number format attribute
+ ULONG nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
+ if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
+ nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
+ {
+ rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value
+ }
+
+ rSecondItemId = ATTR_LANGUAGE_FORMAT;
+ }
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case ATTR_INDENT:
+ {
+ sal_Int16 nIntVal = 0;
+ if ( rValue >>= nIntVal )
+ rSet.Put( SfxUInt16Item( rEntry.nWID, (USHORT)HMMToTwips(nIntVal) ) );
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case ATTR_ROTATE_VALUE:
+ {
+ sal_Int32 nRotVal = 0;
+ if ( rValue >>= nRotVal )
+ {
+ // stored value is always between 0 and 360 deg.
+ nRotVal %= 36000;
+ if ( nRotVal < 0 )
+ nRotVal += 36000;
+
+ rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case ATTR_STACKED:
+ {
+ table::CellOrientation eOrient;
+ if( rValue >>= eOrient )
+ {
+ switch( eOrient )
+ {
+ case table::CellOrientation_STANDARD:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
+ break;
+ case table::CellOrientation_TOPBOTTOM:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
+ rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
+ rSecondItemId = ATTR_ROTATE_VALUE;
+ break;
+ case table::CellOrientation_BOTTOMTOP:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
+ rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
+ rSecondItemId = ATTR_ROTATE_VALUE;
+ break;
+ case table::CellOrientation_STACKED:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, TRUE ) );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ }
+ break;
+ default:
+ {
+ lcl_GetCellsPropertySet()->setPropertyValue(rEntry, rValue, rSet);
+ }
+ }
+}
+
+void SAL_CALL ScCellRangesBase::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell || aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ SetOnePropertyValue( pEntry, aValue );
+}
+
+void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ if ( aRanges.Count() ) // leer = nichts zu tun
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDocFunc aFunc(*pDocShell);
+
+ // Fuer Teile von zusammengesetzten Items mit mehreren Properties (z.B. Hintergrund)
+ // muss vorher das alte Item aus dem Dokument geholt werden
+ //! Das kann hier aber nicht erkannt werden
+ //! -> eigenes Flag im PropertyMap-Eintrag, oder was ???
+ //! Item direkt von einzelner Position im Bereich holen?
+ // ClearInvalidItems, damit auf jeden Fall ein Item vom richtigen Typ da ist
+
+ ScPatternAttr aPattern( *GetCurrentAttrsDeep() );
+ SfxItemSet& rSet = aPattern.GetItemSet();
+ rSet.ClearInvalidItems();
+
+ USHORT nFirstItem, nSecondItem;
+ lcl_SetCellProperty( *pEntry, aValue, aPattern, pDoc, nFirstItem, nSecondItem );
+
+ for (USHORT nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; nWhich++)
+ if ( nWhich != nFirstItem && nWhich != nSecondItem )
+ rSet.ClearItem(nWhich);
+
+ aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE );
+ }
+ }
+ else // implemented here
+ switch ( pEntry->nWID )
+ {
+ case SC_WID_UNO_CHCOLHDR:
+ // chart header flags are set for this object, not stored with document
+ bChartColAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ break;
+ case SC_WID_UNO_CHROWHDR:
+ bChartRowAsHdr = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ break;
+ case SC_WID_UNO_CELLSTYL:
+ {
+ rtl::OUString aStrVal;
+ aValue >>= aStrVal;
+ String aString(ScStyleNameConversion::ProgrammaticToDisplayName(
+ aStrVal, SFX_STYLE_FAMILY_PARA ));
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.ApplyStyle( *GetMarkData(), aString, TRUE, TRUE );
+ }
+ break;
+ case SC_WID_UNO_TBLBORD:
+ {
+ table::TableBorder aBorder;
+ if ( aRanges.Count() && ( aValue >>= aBorder ) ) // empty = nothing to do
+ {
+ SvxBoxItem aOuter(ATTR_BORDER);
+ SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
+ ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
+
+ ScHelperFunctions::ApplyBorder( pDocShell, aRanges, aOuter, aInner ); //! docfunc
+ }
+ }
+ break;
+ case SC_WID_UNO_CONDFMT:
+ case SC_WID_UNO_CONDLOC:
+ case SC_WID_UNO_CONDXML:
+ {
+ uno::Reference<sheet::XSheetConditionalEntries> xInterface(aValue, uno::UNO_QUERY);
+ if ( aRanges.Count() && xInterface.is() ) // leer = nichts zu tun
+ {
+ ScTableConditionalFormat* pFormat =
+ ScTableConditionalFormat::getImplementation( xInterface );
+ if (pFormat)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
+ BOOL bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
+ formula::FormulaGrammar::Grammar eGrammar = (bXML ?
+ formula::FormulaGrammar::GRAM_UNSPECIFIED :
+ formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
+
+ ScConditionalFormat aNew( 0, pDoc ); // Index wird beim Einfuegen gesetzt
+ pFormat->FillFormat( aNew, pDoc, eGrammar );
+ ULONG nIndex = pDoc->AddCondFormat( aNew );
+
+ ScDocFunc aFunc(*pDocShell);
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
+ aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE );
+ }
+ }
+ }
+ break;
+ case SC_WID_UNO_VALIDAT:
+ case SC_WID_UNO_VALILOC:
+ case SC_WID_UNO_VALIXML:
+ {
+ uno::Reference<beans::XPropertySet> xInterface(aValue, uno::UNO_QUERY);
+ if ( aRanges.Count() && xInterface.is() ) // leer = nichts zu tun
+ {
+ ScTableValidationObj* pValidObj =
+ ScTableValidationObj::getImplementation( xInterface );
+ if (pValidObj)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
+ BOOL bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
+ formula::FormulaGrammar::Grammar eGrammar = (bXML ?
+ formula::FormulaGrammar::GRAM_UNSPECIFIED :
+ formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
+
+ ScValidationData* pNewData =
+ pValidObj->CreateValidationData( pDoc, eGrammar );
+ ULONG nIndex = pDoc->AddValidationEntry( *pNewData );
+ delete pNewData;
+
+ ScDocFunc aFunc(*pDocShell);
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
+ aFunc.ApplyAttributes( *GetMarkData(), aPattern, TRUE, TRUE );
+ }
+ }
+ }
+ break;
+ // SC_WID_UNO_NUMRULES is ignored...
+ }
+ }
+}
+
+uno::Any SAL_CALL ScCellRangesBase::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell || aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ uno::Any aAny;
+ GetOnePropertyValue( pEntry, aAny );
+ return aAny;
+}
+
+void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
+ uno::Any& rAny )
+ throw(uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ SfxItemSet* pDataSet = GetCurrentDataSet();
+ if ( pDataSet )
+ {
+ switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
+ {
+ case ATTR_VALUE_FORMAT:
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ULONG nOldFormat = ((const SfxUInt32Item&)
+ pDataSet->Get( ATTR_VALUE_FORMAT )).GetValue();
+ LanguageType eOldLang = ((const SvxLanguageItem&)
+ pDataSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
+ nOldFormat = pDoc->GetFormatTable()->
+ GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
+ rAny <<= (sal_Int32)( nOldFormat );
+ }
+ break;
+ case ATTR_INDENT:
+ rAny <<= (sal_Int16)( TwipsToHMM(((const SfxUInt16Item&)
+ pDataSet->Get(pEntry->nWID)).GetValue()) );
+ break;
+ case ATTR_STACKED:
+ {
+ sal_Int32 nRot = ((const SfxInt32Item&)pDataSet->Get(ATTR_ROTATE_VALUE)).GetValue();
+ BOOL bStacked = ((const SfxBoolItem&)pDataSet->Get(pEntry->nWID)).GetValue();
+ SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( rAny );
+ }
+ break;
+ default:
+ pPropSet->getPropertyValue(*pEntry, *pDataSet, rAny);
+ }
+ }
+ }
+ else // implemented here
+ switch ( pEntry->nWID )
+ {
+ case SC_WID_UNO_CHCOLHDR:
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bChartColAsHdr );
+ break;
+ case SC_WID_UNO_CHROWHDR:
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bChartRowAsHdr );
+ break;
+ case SC_WID_UNO_CELLSTYL:
+ {
+ String aStyleName;
+ const ScStyleSheet* pStyle = pDocShell->GetDocument()->GetSelectionStyle(*GetMarkData());
+ if (pStyle)
+ aStyleName = pStyle->GetName();
+ rAny <<= rtl::OUString( ScStyleNameConversion::DisplayToProgrammaticName(
+ aStyleName, SFX_STYLE_FAMILY_PARA ) );
+ }
+ break;
+ case SC_WID_UNO_TBLBORD:
+ {
+ //! loop throgh all ranges
+ const ScRange* pFirst = aRanges.GetObject(0);
+ if (pFirst)
+ {
+ SvxBoxItem aOuter(ATTR_BORDER);
+ SvxBoxInfoItem aInner(ATTR_BORDER_INNER);
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScMarkData aMark;
+ aMark.SetMarkArea( *pFirst );
+ aMark.SelectTable( pFirst->aStart.Tab(), TRUE );
+ pDoc->GetSelectionFrame( aMark, aOuter, aInner );
+
+ table::TableBorder aBorder;
+ ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
+ rAny <<= aBorder;
+ }
+ }
+ break;
+ case SC_WID_UNO_CONDFMT:
+ case SC_WID_UNO_CONDLOC:
+ case SC_WID_UNO_CONDXML:
+ {
+ const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
+ if ( pPattern )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_CONDLOC );
+ BOOL bXML = ( pEntry->nWID == SC_WID_UNO_CONDXML );
+ formula::FormulaGrammar::Grammar eGrammar = (bXML ?
+ pDoc->GetStorageGrammar() :
+ formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
+ ULONG nIndex = ((const SfxUInt32Item&)
+ pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
+ rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
+ new ScTableConditionalFormat( pDoc, nIndex, eGrammar ));
+ }
+ }
+ break;
+ case SC_WID_UNO_VALIDAT:
+ case SC_WID_UNO_VALILOC:
+ case SC_WID_UNO_VALIXML:
+ {
+ const ScPatternAttr* pPattern = GetCurrentAttrsDeep();
+ if ( pPattern )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bEnglish = ( pEntry->nWID != SC_WID_UNO_VALILOC );
+ BOOL bXML = ( pEntry->nWID == SC_WID_UNO_VALIXML );
+ formula::FormulaGrammar::Grammar eGrammar = (bXML ?
+ pDoc->GetStorageGrammar() :
+ formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
+ ULONG nIndex = ((const SfxUInt32Item&)
+ pPattern->GetItem(ATTR_VALIDDATA)).GetValue();
+ rAny <<= uno::Reference<beans::XPropertySet>(
+ new ScTableValidationObj( pDoc, nIndex, eGrammar ));
+ }
+ }
+ break;
+ case SC_WID_UNO_NUMRULES:
+ {
+ // always return empty numbering rules object
+ rAny <<= uno::Reference<container::XIndexReplace>(ScStyleObj::CreateEmptyNumberingRules());
+ }
+ break;
+ case SC_WID_UNO_ABSNAME:
+ {
+ String sRet;
+ aRanges.Format(sRet, SCR_ABS_3D, pDocShell->GetDocument());
+ rAny <<= rtl::OUString(sRet);
+ }
+ }
+ }
+}
+
+void SAL_CALL ScCellRangesBase::addPropertyChangeListener( const rtl::OUString& /* aPropertyName */,
+ const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScCellRangesBase::removePropertyChangeListener( const rtl::OUString& /* aPropertyName */,
+ const uno::Reference<beans::XPropertyChangeListener>& /* aListener */)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScCellRangesBase::addVetoableChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XVetoableChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScCellRangesBase::removeVetoableChangeListener( const rtl::OUString&,
+ const uno::Reference<beans::XVetoableChangeListener>&)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+// XMultiPropertySet
+
+void SAL_CALL ScCellRangesBase::setPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames,
+ const uno::Sequence< uno::Any >& aValues )
+ throw (beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nCount(aPropertyNames.getLength());
+ sal_Int32 nValues(aValues.getLength());
+ if (nCount != nValues)
+ throw lang::IllegalArgumentException();
+
+ if ( pDocShell && nCount )
+ {
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+ const uno::Any* pValues = aValues.getConstArray();
+
+ const SfxItemPropertySimpleEntry** pEntryArray = new const SfxItemPropertySimpleEntry*[nCount];
+
+ sal_Int32 i;
+ for(i = 0; i < nCount; i++)
+ {
+ // first loop: find all properties in map, but handle only CellStyle
+ // (CellStyle must be set before any other cell properties)
+
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( pNames[i] );
+ pEntryArray[i] = pEntry;
+ if (pEntry)
+ {
+ if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
+ {
+ try
+ {
+ SetOnePropertyValue( pEntry, pValues[i] );
+ }
+ catch ( lang::IllegalArgumentException& )
+ {
+ DBG_ERROR("exception when setting cell style"); // not supposed to happen
+ }
+ }
+ }
+ }
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScPatternAttr* pOldPattern = NULL;
+ ScPatternAttr* pNewPattern = NULL;
+
+ for(i = 0; i < nCount; i++)
+ {
+ // second loop: handle other properties
+
+ const SfxItemPropertySimpleEntry* pEntry = pEntryArray[i];
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
+ {
+ if ( !pOldPattern )
+ {
+ pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
+ pOldPattern->GetItemSet().ClearInvalidItems();
+ pNewPattern = new ScPatternAttr( pDoc->GetPool() );
+ }
+
+ // collect items in pNewPattern, apply with one call after the loop
+
+ USHORT nFirstItem, nSecondItem;
+ lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
+
+ // put only affected items into new set
+ if ( nFirstItem )
+ pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
+ if ( nSecondItem )
+ pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
+ }
+ else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
+ {
+ // call virtual method to set a single property
+ SetOnePropertyValue( pEntry, pValues[i] );
+ }
+ }
+ }
+
+ if ( pNewPattern && aRanges.Count() )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.ApplyAttributes( *GetMarkData(), *pNewPattern, TRUE, TRUE );
+ }
+
+ delete pNewPattern;
+ delete pOldPattern;
+ delete[] pEntryArray;
+ }
+}
+
+uno::Sequence<uno::Any> SAL_CALL ScCellRangesBase::getPropertyValues(
+ const uno::Sequence< rtl::OUString >& aPropertyNames )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+
+ uno::Sequence<uno::Any> aRet(aPropertyNames.getLength());
+ uno::Any* pProperties = aRet.getArray();
+ for(INT32 i = 0; i < aPropertyNames.getLength(); i++)
+ {
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
+ GetOnePropertyValue( pEntry, pProperties[i] );
+ }
+ return aRet;
+}
+
+void SAL_CALL ScCellRangesBase::addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& /* aPropertyNames */,
+ const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScCellRangesBase::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScCellRangesBase::firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& /* aPropertyNames */,
+ const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ )
+ throw (uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+IMPL_LINK( ScCellRangesBase, ValueListenerHdl, SfxHint*, pHint )
+{
+ if ( pDocShell && pHint && pHint->ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint*)pHint)->GetId() & (SC_HINT_DATACHANGED | SC_HINT_DYING) )
+ {
+ // This may be called several times for a single change, if several formulas
+ // in the range are notified. So only a flag is set that is checked when
+ // SFX_HINT_DATACHANGED is received.
+
+ bGotDataChangedHint = TRUE;
+ }
+ return 0;
+}
+
+// XTolerantMultiPropertySet
+uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL ScCellRangesBase::setPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames,
+ const uno::Sequence< uno::Any >& aValues )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nCount(aPropertyNames.getLength());
+ sal_Int32 nValues(aValues.getLength());
+ if (nCount != nValues)
+ throw lang::IllegalArgumentException();
+
+ if ( pDocShell && nCount )
+ {
+ uno::Sequence < beans::SetPropertyTolerantFailed > aReturns(nCount);
+ beans::SetPropertyTolerantFailed* pReturns = aReturns.getArray();
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+ const uno::Any* pValues = aValues.getConstArray();
+
+ const SfxItemPropertySimpleEntry** pMapArray = new const SfxItemPropertySimpleEntry*[nCount];
+
+ sal_Int32 i;
+ for(i = 0; i < nCount; i++)
+ {
+ // first loop: find all properties in map, but handle only CellStyle
+ // (CellStyle must be set before any other cell properties)
+
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( pNames[i] );
+ pMapArray[i] = pEntry;
+ if (pEntry)
+ {
+ if ( pEntry->nWID == SC_WID_UNO_CELLSTYL )
+ {
+ try
+ {
+ SetOnePropertyValue( pEntry, pValues[i] );
+ }
+ catch ( lang::IllegalArgumentException& )
+ {
+ DBG_ERROR("exception when setting cell style"); // not supposed to happen
+ }
+ }
+ }
+ }
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScPatternAttr* pOldPattern = NULL;
+ ScPatternAttr* pNewPattern = NULL;
+
+ sal_Int32 nFailed(0);
+ for(i = 0; i < nCount; i++)
+ {
+ // second loop: handle other properties
+
+ const SfxItemPropertySimpleEntry* pEntry = pMapArray[i];
+ if ( pEntry && ((pEntry->nFlags & beans::PropertyAttribute::READONLY) == 0))
+ {
+ if ( IsScItemWid( pEntry->nWID ) ) // can be handled by SfxItemPropertySet
+ {
+ if ( !pOldPattern )
+ {
+ pOldPattern = new ScPatternAttr( *GetCurrentAttrsDeep() );
+ pOldPattern->GetItemSet().ClearInvalidItems();
+ pNewPattern = new ScPatternAttr( pDoc->GetPool() );
+ }
+
+ // collect items in pNewPattern, apply with one call after the loop
+
+ USHORT nFirstItem, nSecondItem;
+ try
+ {
+ lcl_SetCellProperty( *pEntry, pValues[i], *pOldPattern, pDoc, nFirstItem, nSecondItem );
+
+ // put only affected items into new set
+ if ( nFirstItem )
+ pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nFirstItem ) );
+ if ( nSecondItem )
+ pNewPattern->GetItemSet().Put( pOldPattern->GetItemSet().Get( nSecondItem ) );
+ }
+ catch ( lang::IllegalArgumentException& )
+ {
+ pReturns[nFailed].Name = pNames[i];
+ pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
+ }
+ }
+ else if ( pEntry->nWID != SC_WID_UNO_CELLSTYL ) // CellStyle is handled above
+ {
+ // call virtual method to set a single property
+ try
+ {
+ SetOnePropertyValue( pEntry, pValues[i] );
+ }
+ catch ( lang::IllegalArgumentException& )
+ {
+ pReturns[nFailed].Name = pNames[i];
+ pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::ILLEGAL_ARGUMENT;
+ }
+ }
+ }
+ else
+ {
+ pReturns[nFailed].Name = pNames[i];
+ if (pEntry)
+ pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::PROPERTY_VETO;
+ else
+ pReturns[nFailed++].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
+ }
+ }
+
+ if ( pNewPattern && aRanges.Count() )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.ApplyAttributes( *GetMarkData(), *pNewPattern, TRUE, TRUE );
+ }
+
+ delete pNewPattern;
+ delete pOldPattern;
+ delete[] pMapArray;
+
+ aReturns.realloc(nFailed);
+
+ return aReturns;
+ }
+ return uno::Sequence < beans::SetPropertyTolerantFailed >();
+}
+
+uno::Sequence< beans::GetPropertyTolerantResult > SAL_CALL ScCellRangesBase::getPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nCount(aPropertyNames.getLength());
+ uno::Sequence < beans::GetPropertyTolerantResult > aReturns(nCount);
+ beans::GetPropertyTolerantResult* pReturns = aReturns.getArray();
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+
+ for(INT32 i = 0; i < nCount; i++)
+ {
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
+ if (!pEntry)
+ {
+ pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
+ }
+ else
+ {
+ USHORT nItemWhich = 0;
+ lcl_GetPropertyWhich( pEntry, nItemWhich );
+ pReturns[i].State = GetOnePropertyState( nItemWhich, pEntry );
+ GetOnePropertyValue( pEntry, pReturns[i].Value );
+ pReturns[i].Result = beans::TolerantPropertySetResultType::SUCCESS;
+ }
+ }
+ return aReturns;
+}
+
+uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL ScCellRangesBase::getDirectPropertyValuesTolerant( const uno::Sequence< ::rtl::OUString >& aPropertyNames )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nCount(aPropertyNames.getLength());
+ uno::Sequence < beans::GetDirectPropertyTolerantResult > aReturns(nCount);
+ beans::GetDirectPropertyTolerantResult* pReturns = aReturns.getArray();
+
+ const SfxItemPropertyMap* pPropertyMap = GetItemPropertyMap(); // from derived class
+
+ INT32 j = 0;
+ for(INT32 i = 0; i < nCount; i++)
+ {
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( aPropertyNames[i] );
+ if (!pEntry)
+ {
+ pReturns[i].Result = beans::TolerantPropertySetResultType::UNKNOWN_PROPERTY;
+ }
+ else
+ {
+ USHORT nItemWhich = 0;
+ lcl_GetPropertyWhich( pEntry, nItemWhich );
+ pReturns[j].State = GetOnePropertyState( nItemWhich, pEntry );
+ if (pReturns[j].State == beans::PropertyState_DIRECT_VALUE)
+ {
+ GetOnePropertyValue( pEntry, pReturns[j].Value );
+ pReturns[j].Result = beans::TolerantPropertySetResultType::SUCCESS;
+ pReturns[j].Name = aPropertyNames[i];
+ ++j;
+ }
+ }
+ }
+ if (j < nCount)
+ aReturns.realloc(j);
+ return aReturns;
+}
+
+// XIndent
+
+void SAL_CALL ScCellRangesBase::decrementIndent() throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell && aRanges.Count() ) // leer = nichts zu tun
+ {
+ ScDocFunc aFunc(*pDocShell);
+ //#97041#; put only MultiMarked ScMarkData in ChangeIndent
+ ScMarkData aMarkData(*GetMarkData());
+ aMarkData.MarkToMulti();
+ aFunc.ChangeIndent( aMarkData, FALSE, TRUE );
+ }
+}
+
+void SAL_CALL ScCellRangesBase::incrementIndent() throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell && aRanges.Count() ) // leer = nichts zu tun
+ {
+ ScDocFunc aFunc(*pDocShell);
+ //#97041#; put only MultiMarked ScMarkData in ChangeIndent
+ ScMarkData aMarkData(*GetMarkData());
+ aMarkData.MarkToMulti();
+ aFunc.ChangeIndent( aMarkData, TRUE, TRUE );
+ }
+}
+
+// XChartData
+
+ScMemChart* ScCellRangesBase::CreateMemChart_Impl() const
+{
+ if ( pDocShell && aRanges.Count() )
+ {
+ ScRangeListRef xChartRanges;
+ if ( aRanges.Count() == 1 )
+ {
+ // ganze Tabelle sinnvoll begrenzen (auf belegten Datenbereich)
+ // (nur hier, Listener werden auf den ganzen Bereich angemeldet)
+ //! direkt testen, ob es ein ScTableSheetObj ist?
+
+ ScRange* pRange = aRanges.GetObject(0);
+ if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
+ pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
+ {
+ SCTAB nTab = pRange->aStart.Tab();
+
+ SCCOL nStartX;
+ SCROW nStartY; // Anfang holen
+ if (!pDocShell->GetDocument()->GetDataStart( nTab, nStartX, nStartY ))
+ {
+ nStartX = 0;
+ nStartY = 0;
+ }
+
+ SCCOL nEndX;
+ SCROW nEndY; // Ende holen
+ if (!pDocShell->GetDocument()->GetTableArea( nTab, nEndX, nEndY ))
+ {
+ nEndX = 0;
+ nEndY = 0;
+ }
+
+ xChartRanges = new ScRangeList;
+ xChartRanges->Append( ScRange( nStartX, nStartY, nTab, nEndX, nEndY, nTab ) );
+ }
+ }
+ if (!xChartRanges.Is()) // sonst Ranges direkt uebernehmen
+ xChartRanges = new ScRangeList(aRanges);
+ ScChartArray aArr( pDocShell->GetDocument(), xChartRanges, String() );
+
+ // RowAsHdr = ColHeaders und umgekehrt
+ aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr );
+
+ return aArr.CreateMemChart();
+ }
+ return NULL;
+}
+
+uno::Sequence< uno::Sequence<double> > SAL_CALL ScCellRangesBase::getData()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScMemChart* pMemChart = CreateMemChart_Impl();
+ if ( pMemChart )
+ {
+ sal_Int32 nColCount = pMemChart->GetColCount();
+ sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
+
+ uno::Sequence< uno::Sequence<double> > aRowSeq( nRowCount );
+ uno::Sequence<double>* pRowAry = aRowSeq.getArray();
+ for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
+ {
+ uno::Sequence<double> aColSeq( nColCount );
+ double* pColAry = aColSeq.getArray();
+ for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
+ pColAry[nCol] = pMemChart->GetData( static_cast<short>(nCol), static_cast<short>(nRow) );
+
+ pRowAry[nRow] = aColSeq;
+ }
+
+ delete pMemChart;
+ return aRowSeq;
+ }
+
+ return uno::Sequence< uno::Sequence<double> >(0);
+}
+
+ScRangeListRef ScCellRangesBase::GetLimitedChartRanges_Impl( long nDataColumns, long nDataRows ) const
+{
+ if ( aRanges.Count() == 1 )
+ {
+ ScRange* pRange = aRanges.GetObject(0);
+ if ( pRange->aStart.Col() == 0 && pRange->aEnd.Col() == MAXCOL &&
+ pRange->aStart.Row() == 0 && pRange->aEnd.Row() == MAXROW )
+ {
+ // if aRanges is a complete sheet, limit to given size
+
+ SCTAB nTab = pRange->aStart.Tab();
+
+ long nEndColumn = nDataColumns - 1 + ( bChartColAsHdr ? 1 : 0 );
+ if ( nEndColumn < 0 )
+ nEndColumn = 0;
+ if ( nEndColumn > MAXCOL )
+ nEndColumn = MAXCOL;
+
+ long nEndRow = nDataRows - 1 + ( bChartRowAsHdr ? 1 : 0 );
+ if ( nEndRow < 0 )
+ nEndRow = 0;
+ if ( nEndRow > MAXROW )
+ nEndRow = MAXROW;
+
+ ScRangeListRef xChartRanges = new ScRangeList;
+ xChartRanges->Append( ScRange( 0, 0, nTab, (SCCOL)nEndColumn, (SCROW)nEndRow, nTab ) );
+ return xChartRanges;
+ }
+ }
+
+ return new ScRangeList(aRanges); // as-is
+}
+
+void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<double> >& aData )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ long nRowCount = aData.getLength();
+ long nColCount = nRowCount ? aData[0].getLength() : 0;
+ ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, nRowCount );
+ if ( pDocShell && xChartRanges.Is() )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChartArray aArr( pDoc, xChartRanges, String() );
+ aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
+ const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
+ if (pPosMap)
+ {
+ if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) &&
+ pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
+ {
+ for (long nRow=0; nRow<nRowCount; nRow++)
+ {
+ const uno::Sequence<double>& rRowSeq = aData[nRow];
+ const double* pArray = rRowSeq.getConstArray();
+ nColCount = rRowSeq.getLength();
+ for (long nCol=0; nCol<nColCount; nCol++)
+ {
+ const ScAddress* pPos = pPosMap->GetPosition(
+ sal::static_int_cast<SCCOL>(nCol),
+ sal::static_int_cast<SCROW>(nRow) );
+ if (pPos)
+ {
+ double fVal = pArray[nCol];
+ if ( fVal == DBL_MIN )
+ pDoc->PutCell( *pPos, NULL ); // empty cell
+ else
+ pDoc->SetValue( pPos->Col(), pPos->Row(), pPos->Tab(), pArray[nCol] );
+ }
+ }
+ }
+
+ //! undo
+ PaintRanges_Impl( PAINT_GRID );
+ pDocShell->SetDocumentModified();
+ ForceChartListener_Impl(); // call listeners for this object synchronously
+ bDone = TRUE;
+ }
+ }
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesBase::getRowDescriptions()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScMemChart* pMemChart = CreateMemChart_Impl();
+ if ( pMemChart )
+ {
+ sal_Int32 nRowCount = static_cast<sal_Int32>(pMemChart->GetRowCount());
+ uno::Sequence<rtl::OUString> aSeq( nRowCount );
+ rtl::OUString* pAry = aSeq.getArray();
+ for (sal_Int32 nRow = 0; nRow < nRowCount; nRow++)
+ pAry[nRow] = pMemChart->GetRowText(static_cast<short>(nRow));
+
+ delete pMemChart;
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+void SAL_CALL ScCellRangesBase::setRowDescriptions(
+ const uno::Sequence<rtl::OUString>& aRowDescriptions )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if ( bChartColAsHdr )
+ {
+ long nRowCount = aRowDescriptions.getLength();
+ ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( 1, nRowCount );
+ if ( pDocShell && xChartRanges.Is() )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChartArray aArr( pDoc, xChartRanges, String() );
+ aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
+ const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
+ if (pPosMap)
+ {
+ if ( pPosMap->GetRowCount() == static_cast<SCROW>(nRowCount) )
+ {
+ const rtl::OUString* pArray = aRowDescriptions.getConstArray();
+ for (long nRow=0; nRow<nRowCount; nRow++)
+ {
+ const ScAddress* pPos = pPosMap->GetRowHeaderPosition(
+ static_cast<SCSIZE>(nRow) );
+ if (pPos)
+ {
+ String aStr = pArray[nRow];
+ if ( aStr.Len() )
+ pDoc->PutCell( *pPos, new ScStringCell( aStr ) );
+ else
+ pDoc->PutCell( *pPos, NULL ); // empty cell
+ }
+ }
+
+ //! undo
+ PaintRanges_Impl( PAINT_GRID );
+ pDocShell->SetDocumentModified();
+ ForceChartListener_Impl(); // call listeners for this object synchronously
+ bDone = TRUE;
+ }
+ }
+ }
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesBase::getColumnDescriptions()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScMemChart* pMemChart = CreateMemChart_Impl();
+ if ( pMemChart )
+ {
+ sal_Int32 nColCount = pMemChart->GetColCount();
+ uno::Sequence<rtl::OUString> aSeq( nColCount );
+ rtl::OUString* pAry = aSeq.getArray();
+ for (sal_Int32 nCol = 0; nCol < nColCount; nCol++)
+ pAry[nCol] = pMemChart->GetColText(static_cast<short>(nCol));
+
+ delete pMemChart;
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+void SAL_CALL ScCellRangesBase::setColumnDescriptions(
+ const uno::Sequence<rtl::OUString>& aColumnDescriptions )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if ( bChartRowAsHdr )
+ {
+ long nColCount = aColumnDescriptions.getLength();
+ ScRangeListRef xChartRanges = GetLimitedChartRanges_Impl( nColCount, 1 );
+ if ( pDocShell && xChartRanges.Is() )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChartArray aArr( pDoc, xChartRanges, String() );
+ aArr.SetHeaders( bChartRowAsHdr, bChartColAsHdr ); // RowAsHdr = ColHeaders
+ const ScChartPositionMap* pPosMap = aArr.GetPositionMap();
+ if (pPosMap)
+ {
+ if ( pPosMap->GetColCount() == static_cast<SCCOL>(nColCount) )
+ {
+ const rtl::OUString* pArray = aColumnDescriptions.getConstArray();
+ for (long nCol=0; nCol<nColCount; nCol++)
+ {
+ const ScAddress* pPos = pPosMap->GetColHeaderPosition(
+ sal::static_int_cast<SCCOL>(nCol) );
+ if (pPos)
+ {
+ String aStr(pArray[nCol]);
+ if ( aStr.Len() )
+ pDoc->PutCell( *pPos, new ScStringCell( aStr ) );
+ else
+ pDoc->PutCell( *pPos, NULL ); // empty cell
+ }
+ }
+
+ //! undo
+ PaintRanges_Impl( PAINT_GRID );
+ pDocShell->SetDocumentModified();
+ ForceChartListener_Impl(); // call listeners for this object synchronously
+ bDone = TRUE;
+ }
+ }
+ }
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException();
+}
+
+void ScCellRangesBase::ForceChartListener_Impl()
+{
+ // call Update immediately so the caller to setData etc. can
+ // regognize the listener call
+
+ if ( pDocShell )
+ {
+ ScChartListenerCollection* pColl = pDocShell->GetDocument()->GetChartListenerCollection();
+ if ( pColl )
+ {
+ USHORT nCollCount = pColl->GetCount();
+ for ( USHORT nIndex = 0; nIndex < nCollCount; nIndex++ )
+ {
+ ScChartListener* pChartListener = (ScChartListener*)pColl->At(nIndex);
+ if ( pChartListener &&
+ pChartListener->GetUnoSource() == static_cast<chart::XChartData*>(this) &&
+ pChartListener->IsDirty() )
+ pChartListener->Update();
+ }
+ }
+ }
+}
+
+String lcl_UniqueName( ScStrCollection& rColl, const String& rPrefix )
+{
+ long nNumber = 1;
+ USHORT nCollCount = rColl.GetCount();
+ while (TRUE)
+ {
+ String aName(rPrefix);
+ aName += String::CreateFromInt32( nNumber );
+ BOOL bFound = FALSE;
+ for (USHORT i=0; i<nCollCount; i++)
+ if ( rColl[i]->GetString() == aName )
+ {
+ bFound = TRUE;
+ break;
+ }
+ if (!bFound)
+ return aName;
+ ++nNumber;
+ }
+}
+
+void SAL_CALL ScCellRangesBase::addChartDataChangeEventListener( const uno::Reference<
+ chart::XChartDataChangeEventListener >& aListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell && aRanges.Count() )
+ {
+ //! auf doppelte testen?
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangeListRef aRangesRef( new ScRangeList(aRanges) );
+ ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
+ String aName(lcl_UniqueName( *pColl,
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("__Uno")) ));
+ ScChartListener* pListener = new ScChartListener( aName, pDoc, aRangesRef );
+ pListener->SetUno( aListener, this );
+ pColl->Insert( pListener );
+ pListener->StartListeningTo();
+ }
+}
+
+void SAL_CALL ScCellRangesBase::removeChartDataChangeEventListener( const uno::Reference<
+ chart::XChartDataChangeEventListener >& aListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell && aRanges.Count() )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScChartListenerCollection* pColl = pDoc->GetChartListenerCollection();
+ pColl->FreeUno( aListener, this );
+ }
+}
+
+double SAL_CALL ScCellRangesBase::getNotANumber() throw(::com::sun::star::uno::RuntimeException)
+{
+ // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
+ return DBL_MIN;
+}
+
+sal_Bool SAL_CALL ScCellRangesBase::isNotANumber( double nNumber ) throw(uno::RuntimeException)
+{
+ // im ScChartArray wird DBL_MIN verwendet, weil das Chart es so will
+ return (nNumber == DBL_MIN);
+}
+
+// XModifyBroadcaster
+
+void SAL_CALL ScCellRangesBase::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ uno::Reference<util::XModifyListener> *pObj =
+ new uno::Reference<util::XModifyListener>( aListener );
+ aValueListeners.Insert( pObj, aValueListeners.Count() );
+
+ if ( aValueListeners.Count() == 1 )
+ {
+ if (!pValueListener)
+ pValueListener = new ScLinkListener( LINK( this, ScCellRangesBase, ValueListenerHdl ) );
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ pDoc->StartListeningArea( *aRanges.GetObject(i), pValueListener );
+
+ acquire(); // don't lose this object (one ref for all listeners)
+ }
+}
+
+void SAL_CALL ScCellRangesBase::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw(uno::RuntimeException)
+{
+
+ SolarMutexGuard aGuard;
+ if ( aRanges.Count() == 0 )
+ throw uno::RuntimeException();
+
+ acquire(); // in case the listeners have the last ref - released below
+
+ USHORT nCount = aValueListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XModifyListener> *pObj = aValueListeners[n];
+ if ( *pObj == aListener )
+ {
+ aValueListeners.DeleteAndDestroy( n );
+
+ if ( aValueListeners.Count() == 0 )
+ {
+ if (pValueListener)
+ pValueListener->EndListeningAll();
+
+ release(); // release the ref for the listeners
+ }
+
+ break;
+ }
+ }
+
+ release(); // might delete this object
+}
+
+// XCellRangesQuery
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleCells()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ //! fuer alle Tabellen getrennt, wenn Markierungen pro Tabelle getrennt sind!
+ SCTAB nTab = lcl_FirstTab(aRanges);
+
+ ScMarkData aMarkData(*GetMarkData());
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCCOL nCol = 0, nLastCol;
+ while (nCol <= MAXCOL)
+ {
+ if (pDoc->ColHidden(nCol, nTab, nLastCol))
+ // hidden columns. Unselect them.
+ aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
+
+ nCol = nLastCol + 1;
+ }
+
+ SCROW nRow = 0, nLastRow;
+ while (nRow <= MAXROW)
+ {
+ if (pDoc->RowHidden(nRow, nTab, nLastRow))
+ // These rows are hidden. Unselect them.
+ aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
+
+ nRow = nLastRow + 1;
+ }
+
+ ScRangeList aNewRanges;
+ aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
+ return new ScCellRangesObj( pDocShell, aNewRanges );
+ }
+
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCells()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScMarkData aMarkData(*GetMarkData());
+
+ // belegte Zellen wegmarkieren
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange aRange = *aRanges.GetObject(i);
+
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ // Notizen zaehlen als nicht-leer
+ if ( !pCell->IsBlank() )
+ aMarkData.SetMultiMarkArea(
+ ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ),
+ FALSE );
+
+ pCell = aIter.GetNext();
+ }
+ }
+
+ ScRangeList aNewRanges;
+ // IsMultiMarked reicht hier nicht (wird beim deselektieren nicht zurueckgesetzt)
+ if (aMarkData.HasAnyMultiMarks())
+ aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
+
+ return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
+ }
+
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentCells(
+ sal_Int16 nContentFlags )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScMarkData aMarkData;
+
+ // passende Zellen selektieren
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange aRange = *aRanges.GetObject(i);
+
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ BOOL bAdd = FALSE;
+ if ( pCell->HasNote() && ( nContentFlags & sheet::CellFlags::ANNOTATION ) )
+ bAdd = TRUE;
+ else
+ switch ( pCell->GetCellType() )
+ {
+ case CELLTYPE_STRING:
+ if ( nContentFlags & sheet::CellFlags::STRING )
+ bAdd = TRUE;
+ break;
+ case CELLTYPE_EDIT:
+ if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
+ bAdd = TRUE;
+ break;
+ case CELLTYPE_FORMULA:
+ if ( nContentFlags & sheet::CellFlags::FORMULA )
+ bAdd = TRUE;
+ break;
+ case CELLTYPE_VALUE:
+ if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
+ == (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
+ bAdd = TRUE;
+ else
+ {
+ // Date/Time Erkennung
+
+ ULONG nIndex = (ULONG)((SfxUInt32Item*)pDoc->GetAttr(
+ aIter.GetCol(), aIter.GetRow(), aIter.GetTab(),
+ ATTR_VALUE_FORMAT ))->GetValue();
+ short nTyp = pDoc->GetFormatTable()->GetType(nIndex);
+ if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) ||
+ (nTyp == NUMBERFORMAT_DATETIME))
+ {
+ if ( nContentFlags & sheet::CellFlags::DATETIME )
+ bAdd = TRUE;
+ }
+ else
+ {
+ if ( nContentFlags & sheet::CellFlags::VALUE )
+ bAdd = TRUE;
+ }
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if (bAdd)
+ aMarkData.SetMultiMarkArea(
+ ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ),
+ TRUE );
+
+ pCell = aIter.GetNext();
+ }
+ }
+
+ ScRangeList aNewRanges;
+ if (aMarkData.IsMultiMarked())
+ aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
+
+ return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
+ }
+
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaCells(
+ sal_Int32 nResultFlags )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScMarkData aMarkData;
+
+ // passende Zellen selektieren
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange aRange = *aRanges.GetObject(i);
+
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
+ BOOL bAdd = FALSE;
+ if (pFCell->GetErrCode())
+ {
+ if ( nResultFlags & sheet::FormulaResult::ERROR )
+ bAdd = TRUE;
+ }
+ else if (pFCell->IsValue())
+ {
+ if ( nResultFlags & sheet::FormulaResult::VALUE )
+ bAdd = TRUE;
+ }
+ else // String
+ {
+ if ( nResultFlags & sheet::FormulaResult::STRING )
+ bAdd = TRUE;
+ }
+
+ if (bAdd)
+ aMarkData.SetMultiMarkArea(
+ ScRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() ),
+ TRUE );
+ }
+
+ pCell = aIter.GetNext();
+ }
+ }
+
+ ScRangeList aNewRanges;
+ if (aMarkData.IsMultiMarked())
+ aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
+
+ return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
+ }
+
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
+ const table::CellAddress& aCompare, BOOL bColumnDiff)
+{
+ if (pDocShell)
+ {
+ ULONG nRangeCount = aRanges.Count();
+ ULONG i;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScMarkData aMarkData;
+
+ SCCOLROW nCmpPos = bColumnDiff ? (SCCOLROW)aCompare.Row : (SCCOLROW)aCompare.Column;
+
+ // zuerst alles selektieren, wo ueberhaupt etwas in der Vergleichsspalte steht
+ // (fuer gleiche Zellen wird die Selektion im zweiten Schritt aufgehoben)
+
+ SCTAB nTab = lcl_FirstTab(aRanges); //! fuer alle Tabellen, wenn Markierungen pro Tabelle!
+ ScRange aCmpRange, aCellRange;
+ if (bColumnDiff)
+ aCmpRange = ScRange( 0,nCmpPos,nTab, MAXCOL,nCmpPos,nTab );
+ else
+ aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
+ ScCellIterator aCmpIter( pDoc, aCmpRange );
+ ScBaseCell* pCmpCell = aCmpIter.GetFirst();
+ while (pCmpCell)
+ {
+ if (pCmpCell->GetCellType() != CELLTYPE_NOTE)
+ {
+ SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetCol()) : static_cast<SCCOLROW>(aCmpIter.GetRow());
+ if (bColumnDiff)
+ aCellRange = ScRange( static_cast<SCCOL>(nCellPos),0,nTab,
+ static_cast<SCCOL>(nCellPos),MAXROW,nTab );
+ else
+ aCellRange = ScRange( 0,nCellPos,nTab, MAXCOL,nCellPos,nTab );
+
+ for (i=0; i<nRangeCount; i++)
+ {
+ ScRange aRange(*aRanges.GetObject(i));
+ if ( aRange.Intersects( aCellRange ) )
+ {
+ if (bColumnDiff)
+ {
+ aRange.aStart.SetCol(static_cast<SCCOL>(nCellPos));
+ aRange.aEnd.SetCol(static_cast<SCCOL>(nCellPos));
+ }
+ else
+ {
+ aRange.aStart.SetRow(nCellPos);
+ aRange.aEnd.SetRow(nCellPos);
+ }
+ aMarkData.SetMultiMarkArea( aRange );
+ }
+ }
+ }
+ pCmpCell = aCmpIter.GetNext();
+ }
+
+ // alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
+ // selektieren oder aufheben
+
+ ScAddress aCmpAddr;
+ for (i=0; i<nRangeCount; i++)
+ {
+ ScRange aRange(*aRanges.GetObject(i));
+
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if (bColumnDiff)
+ aCmpAddr = ScAddress( aIter.GetCol(), nCmpPos, aIter.GetTab() );
+ else
+ aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetRow(), aIter.GetTab() );
+ const ScBaseCell* pOtherCell = pDoc->GetCell( aCmpAddr );
+
+ ScRange aOneRange( aIter.GetCol(), aIter.GetRow(), aIter.GetTab() );
+ if ( !ScBaseCell::CellEqual( pCell, pOtherCell ) )
+ aMarkData.SetMultiMarkArea( aOneRange );
+ else
+ aMarkData.SetMultiMarkArea( aOneRange, FALSE ); // deselect
+
+ pCell = aIter.GetNext();
+ }
+ }
+
+ ScRangeList aNewRanges;
+ if (aMarkData.IsMultiMarked())
+ aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
+
+ return new ScCellRangesObj( pDocShell, aNewRanges ); // aNewRanges kann leer sein
+ }
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellRanges > SAL_CALL ScCellRangesBase::queryColumnDifferences(
+ const table::CellAddress& aCompare ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return QueryDifferences_Impl( aCompare, TRUE );
+}
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryRowDifferences(
+ const table::CellAddress& aCompare ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return QueryDifferences_Impl( aCompare, FALSE );
+}
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryIntersection(
+ const table::CellRangeAddress& aRange ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRange aMask( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
+ (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
+
+ ScRangeList aNew;
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange aTemp(*aRanges.GetObject(i));
+ if ( aTemp.Intersects( aMask ) )
+ aNew.Join( ScRange( Max( aTemp.aStart.Col(), aMask.aStart.Col() ),
+ Max( aTemp.aStart.Row(), aMask.aStart.Row() ),
+ Max( aTemp.aStart.Tab(), aMask.aStart.Tab() ),
+ Min( aTemp.aEnd.Col(), aMask.aEnd.Col() ),
+ Min( aTemp.aEnd.Row(), aMask.aEnd.Row() ),
+ Min( aTemp.aEnd.Tab(), aMask.aEnd.Tab() ) ) );
+ }
+
+ return new ScCellRangesObj( pDocShell, aNew ); // kann leer sein
+}
+
+// XFormulaQuery
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPrecedents(
+ sal_Bool bRecursive ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScRangeList aNewRanges(aRanges);
+ BOOL bFound;
+ do
+ {
+ bFound = FALSE;
+
+ // #97205# aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( aNewRanges, FALSE );
+ aMarkData.MarkToMulti(); // needed for IsAllMarked
+
+ ULONG nCount = aNewRanges.Count();
+ for (ULONG nR=0; nR<nCount; nR++)
+ {
+ ScRange aRange(*aNewRanges.GetObject(nR));
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if ( pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
+
+ ScDetectiveRefIter aRefIter( pFCell );
+ ScRange aRefRange;
+ while ( aRefIter.GetNextRef( aRefRange) )
+ {
+ if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
+ bFound = TRUE;
+ aMarkData.SetMultiMarkArea( aRefRange, TRUE );
+ }
+ }
+ pCell = aIter.GetNext();
+ }
+ }
+
+ aMarkData.FillRangeListWithMarks( &aNewRanges, TRUE );
+ }
+ while ( bRecursive && bFound );
+
+ return new ScCellRangesObj( pDocShell, aNewRanges );
+ }
+
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependents(
+ sal_Bool bRecursive ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ ScRangeList aNewRanges(aRanges);
+ BOOL bFound;
+ do
+ {
+ bFound = FALSE;
+ ULONG nRangesCount = aNewRanges.Count();
+
+ // #97205# aMarkData uses aNewRanges, not aRanges, so GetMarkData can't be used
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( aNewRanges, FALSE );
+ aMarkData.MarkToMulti(); // needed for IsAllMarked
+
+ SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
+
+ ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab );
+ ScBaseCell* pCell = aCellIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ BOOL bMark = FALSE;
+ ScDetectiveRefIter aIter( (ScFormulaCell*) pCell );
+ ScRange aRefRange;
+ while ( aIter.GetNextRef( aRefRange) )
+ {
+ for (ULONG nR=0; nR<nRangesCount; nR++)
+ {
+ ScRange aRange(*aNewRanges.GetObject(nR));
+ if (aRange.Intersects(aRefRange))
+ bMark = TRUE; // von Teil des Ranges abhaengig
+ }
+ }
+ if (bMark)
+ {
+ ScRange aCellRange( aCellIter.GetCol(),
+ aCellIter.GetRow(),
+ aCellIter.GetTab() );
+ if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
+ bFound = TRUE;
+ aMarkData.SetMultiMarkArea( aCellRange, TRUE );
+ }
+ }
+ pCell = aCellIter.GetNext();
+ }
+
+ aMarkData.FillRangeListWithMarks( &aNewRanges, TRUE );
+ }
+ while ( bRecursive && bFound );
+
+ return new ScCellRangesObj( pDocShell, aNewRanges );
+ }
+
+ return NULL;
+}
+
+// XSearchable
+
+uno::Reference<util::XSearchDescriptor> SAL_CALL ScCellRangesBase::createSearchDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScCellSearchObj;
+}
+
+uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangesBase::findAll(
+ const uno::Reference<util::XSearchDescriptor>& xDesc )
+ throw(uno::RuntimeException)
+{
+ // Wenn nichts gefunden wird, soll Null zurueckgegeben werden (?)
+ uno::Reference<container::XIndexAccess> xRet;
+ if ( pDocShell && xDesc.is() )
+ {
+ ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
+ if (pSearch)
+ {
+ SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
+ if (pSearchItem)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pSearchItem->SetCommand( SVX_SEARCHCMD_FIND_ALL );
+ // immer nur innerhalb dieses Objekts
+ pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
+
+ ScMarkData aMark(*GetMarkData());
+
+ String aDummyUndo;
+ SCCOL nCol = 0;
+ SCROW nRow = 0;
+ SCTAB nTab = 0;
+ BOOL bFound = pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab,
+ aMark, aDummyUndo, NULL );
+ if (bFound)
+ {
+ ScRangeList aNewRanges;
+ aMark.FillRangeListWithMarks( &aNewRanges, TRUE );
+ // bei findAll immer CellRanges, egal wieviel gefunden wurde
+ xRet.set(new ScCellRangesObj( pDocShell, aNewRanges ));
+ }
+ }
+ }
+ }
+ return xRet;
+}
+
+uno::Reference<uno::XInterface> ScCellRangesBase::Find_Impl(
+ const uno::Reference<util::XSearchDescriptor>& xDesc,
+ const ScAddress* pLastPos )
+{
+ uno::Reference<uno::XInterface> xRet;
+ if ( pDocShell && xDesc.is() )
+ {
+ ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
+ if (pSearch)
+ {
+ SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
+ if (pSearchItem)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pSearchItem->SetCommand( SVX_SEARCHCMD_FIND );
+ // immer nur innerhalb dieses Objekts
+ pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
+
+ ScMarkData aMark(*GetMarkData());
+
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ if (pLastPos)
+ pLastPos->GetVars( nCol, nRow, nTab );
+ else
+ {
+ nTab = lcl_FirstTab(aRanges); //! mehrere Tabellen?
+ ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
+ }
+
+ String aDummyUndo;
+ BOOL bFound = pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab,
+ aMark, aDummyUndo, NULL );
+ if (bFound)
+ {
+ ScAddress aFoundPos( nCol, nRow, nTab );
+ xRet.set((cppu::OWeakObject*) new ScCellObj( pDocShell, aFoundPos ));
+ }
+ }
+ }
+ }
+ return xRet;
+}
+
+uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findFirst(
+ const uno::Reference<util::XSearchDescriptor>& xDesc )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return Find_Impl( xDesc, NULL );
+}
+
+uno::Reference<uno::XInterface> SAL_CALL ScCellRangesBase::findNext(
+ const uno::Reference<uno::XInterface>& xStartAt,
+ const uno::Reference<util::XSearchDescriptor >& xDesc )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( xStartAt.is() )
+ {
+ ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xStartAt );
+ if ( pRangesImp && pRangesImp->GetDocShell() == pDocShell )
+ {
+ const ScRangeList& rStartRanges = pRangesImp->GetRangeList();
+ if ( rStartRanges.Count() == 1 )
+ {
+ ScAddress aStartPos = rStartRanges.GetObject(0)->aStart;
+ return Find_Impl( xDesc, &aStartPos );
+ }
+ }
+ }
+ return NULL;
+}
+
+// XReplaceable
+
+uno::Reference<util::XReplaceDescriptor> SAL_CALL ScCellRangesBase::createReplaceDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScCellSearchObj;
+}
+
+sal_Int32 SAL_CALL ScCellRangesBase::replaceAll( const uno::Reference<util::XSearchDescriptor>& xDesc )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ INT32 nReplaced = 0;
+ if ( pDocShell && xDesc.is() )
+ {
+ ScCellSearchObj* pSearch = ScCellSearchObj::getImplementation( xDesc );
+ if (pSearch)
+ {
+ SvxSearchItem* pSearchItem = pSearch->GetSearchItem();
+ if (pSearchItem)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ pSearchItem->SetCommand( SVX_SEARCHCMD_REPLACE_ALL );
+ // immer nur innerhalb dieses Objekts
+ pSearchItem->SetSelection( !lcl_WholeSheet(aRanges) );
+
+ ScMarkData aMark(*GetMarkData());
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ BOOL bProtected = !pDocShell->IsEditable();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( aMark.GetTableSelect(i) && pDoc->IsTabProtected(i) )
+ bProtected = TRUE;
+ if (bProtected)
+ {
+ //! Exception, oder was?
+ }
+ else
+ {
+ SCTAB nTab = aMark.GetFirstSelected(); // bei SearchAndReplace nicht benutzt
+ SCCOL nCol = 0;
+ SCROW nRow = 0;
+
+ String aUndoStr;
+ ScDocument* pUndoDoc = NULL;
+ if (bUndo)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ }
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( aMark.GetTableSelect(i) && i != nTab && bUndo)
+ pUndoDoc->AddUndoTab( i, i );
+ ScMarkData* pUndoMark = NULL;
+ if (bUndo)
+ pUndoMark = new ScMarkData(aMark);
+
+ BOOL bFound(FALSE);
+ if (bUndo)
+ bFound = pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab,
+ aMark, aUndoStr, pUndoDoc );
+ if (bFound)
+ {
+ nReplaced = pUndoDoc->GetCellCount();
+
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoReplace( pDocShell, *pUndoMark, nCol, nRow, nTab,
+ aUndoStr, pUndoDoc, pSearchItem ) );
+
+ pDocShell->PostPaintGridAll();
+ pDocShell->SetDocumentModified();
+ }
+ else
+ {
+ delete pUndoDoc;
+ delete pUndoMark;
+ // nReplaced bleibt 0
+ }
+ }
+ }
+ }
+ }
+ return nReplaced;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScCellRangesBase::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScCellRangesBase::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScCellRangesBase* ScCellRangesBase::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScCellRangesBase* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScCellRangesBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScCellRangesObj::ScCellRangesObj(ScDocShell* pDocSh, const ScRangeList& rR) :
+ ScCellRangesBase( pDocSh, rR )
+{
+}
+
+ScCellRangesObj::~ScCellRangesObj()
+{
+}
+
+void ScCellRangesObj::RefChanged()
+{
+ ScCellRangesBase::RefChanged();
+
+ // nix weiter...
+}
+
+uno::Any SAL_CALL ScCellRangesObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XSheetCellRangeContainer )
+ SC_QUERYINTERFACE( sheet::XSheetCellRanges )
+ SC_QUERYINTERFACE( container::XIndexAccess )
+ SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
+ SC_QUERYINTERFACE( container::XEnumerationAccess )
+ SC_QUERYINTERFACE( container::XNameContainer )
+ SC_QUERYINTERFACE( container::XNameReplace )
+ SC_QUERYINTERFACE( container::XNameAccess )
+
+ return ScCellRangesBase::queryInterface( rType );
+}
+
+void SAL_CALL ScCellRangesObj::acquire() throw()
+{
+ ScCellRangesBase::acquire();
+}
+
+void SAL_CALL ScCellRangesObj::release() throw()
+{
+ ScCellRangesBase::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScCellRangesObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 3 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSheetCellRangeContainer>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNameContainer>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScCellRangesObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XCellRanges
+
+ScCellRangeObj* ScCellRangesObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
+{
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ if ( pDocSh && nIndex >= 0 && nIndex < sal::static_int_cast<sal_Int32>(rRanges.Count()) )
+ {
+ ScRange aRange(*rRanges.GetObject(nIndex));
+ if ( aRange.aStart == aRange.aEnd )
+ return new ScCellObj( pDocSh, aRange.aStart );
+ else
+ return new ScCellRangeObj( pDocSh, aRange );
+ }
+
+ return NULL; // keine DocShell oder falscher Index
+}
+
+uno::Sequence<table::CellRangeAddress> SAL_CALL ScCellRangesObj::getRangeAddresses()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ ULONG nCount = rRanges.Count();
+ if ( pDocSh && nCount )
+ {
+ table::CellRangeAddress aRangeAddress;
+ uno::Sequence<table::CellRangeAddress> aSeq(nCount);
+ table::CellRangeAddress* pAry = aSeq.getArray();
+ for (sal_uInt32 i=0; i<nCount; i++)
+ {
+ ScUnoConversion::FillApiRange( aRangeAddress, *rRanges.GetObject(i) );
+ pAry[i] = aRangeAddress;
+ }
+ return aSeq;
+ }
+
+ return uno::Sequence<table::CellRangeAddress>(0); // leer ist moeglich
+}
+
+uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellRangesObj::getCells()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // getCells with empty range list is possible (no exception),
+ // the resulting enumeration just has no elements
+ // (same behaviour as a valid range with no cells)
+ // This is handled in ScCellsEnumeration ctor.
+
+ const ScRangeList& rRanges = GetRangeList();
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ return new ScCellsObj( pDocSh, rRanges );
+ return NULL;
+}
+
+rtl::OUString SAL_CALL ScCellRangesObj::getRangeAddressesAsString()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString;
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ if (pDocSh)
+ rRanges.Format( aString, SCA_VALID | SCA_TAB_3D, pDocSh->GetDocument() );
+ return aString;
+}
+
+// XSheetCellRangeContainer
+
+void SAL_CALL ScCellRangesObj::addRangeAddress( const table::CellRangeAddress& rRange,
+ sal_Bool bMergeRanges )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
+ static_cast<SCROW>(rRange.StartRow),
+ static_cast<SCTAB>(rRange.Sheet),
+ static_cast<SCCOL>(rRange.EndColumn),
+ static_cast<SCROW>(rRange.EndRow),
+ static_cast<SCTAB>(rRange.Sheet));
+ AddRange(aRange, bMergeRanges);
+}
+
+void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const ScRange& rRange )
+{
+ USHORT nCount = rNamedEntries.Count();
+ for ( USHORT n=nCount; n--; )
+ if ( rNamedEntries[n]->GetRange() == rRange )
+ rNamedEntries.DeleteAndDestroy( n );
+}
+
+void SAL_CALL ScCellRangesObj::removeRangeAddress( const table::CellRangeAddress& rRange )
+ throw(::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+
+ ScRangeList aSheetRanges;
+ ScRangeList aNotSheetRanges;
+ for (sal_uInt32 i = 0; i < rRanges.Count(); ++i)
+ {
+ if (rRanges.GetObject(i)->aStart.Tab() == rRange.Sheet)
+ {
+ aSheetRanges.Append(*rRanges.GetObject(i));
+ }
+ else
+ {
+ aNotSheetRanges.Append(*rRanges.GetObject(i));
+ }
+ }
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( aSheetRanges, FALSE );
+ ScRange aRange(static_cast<SCCOL>(rRange.StartColumn),
+ static_cast<SCROW>(rRange.StartRow),
+ static_cast<SCTAB>(rRange.Sheet),
+ static_cast<SCCOL>(rRange.EndColumn),
+ static_cast<SCROW>(rRange.EndRow),
+ static_cast<SCTAB>(rRange.Sheet));
+ if (aMarkData.GetTableSelect( aRange.aStart.Tab() ))
+ {
+ aMarkData.MarkToMulti();
+ if (aMarkData.IsAllMarked( aRange ) )
+ {
+ aMarkData.SetMultiMarkArea( aRange, FALSE );
+ lcl_RemoveNamedEntry(aNamedEntries, aRange);
+ }
+ else
+ throw container::NoSuchElementException();
+ }
+ SetNewRanges(aNotSheetRanges);
+ ScRangeList aNew;
+ aMarkData.FillRangeListWithMarks( &aNew, FALSE );
+ for (sal_uInt32 j = 0; j < aNew.Count(); ++j)
+ {
+ AddRange(*aNew.GetObject(j), sal_False);
+ }
+}
+
+void SAL_CALL ScCellRangesObj::addRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRanges,
+ sal_Bool bMergeRanges )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 nCount(rRanges.getLength());
+ if (nCount)
+ {
+ const table::CellRangeAddress* pRanges = rRanges.getConstArray();
+ for (sal_Int32 i = 0; i < rRanges.getLength(); i++, pRanges++)
+ {
+ ScRange aRange(static_cast<SCCOL>(pRanges->StartColumn),
+ static_cast<SCROW>(pRanges->StartRow),
+ static_cast<SCTAB>(pRanges->Sheet),
+ static_cast<SCCOL>(pRanges->EndColumn),
+ static_cast<SCROW>(pRanges->EndRow),
+ static_cast<SCTAB>(pRanges->Sheet));
+ AddRange(aRange, bMergeRanges);
+ }
+ }
+}
+
+void SAL_CALL ScCellRangesObj::removeRangeAddresses( const uno::Sequence<table::CellRangeAddress >& rRangeSeq )
+ throw(::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ // with this implementation not needed
+// SolarMutexGuard aGuard;
+
+
+ // use sometimes a better/faster implementation
+ sal_uInt32 nCount(rRangeSeq.getLength());
+ if (nCount)
+ {
+ const table::CellRangeAddress* pRanges = rRangeSeq.getConstArray();
+ for (sal_uInt32 i=0; i < nCount; ++i, ++pRanges)
+ {
+ removeRangeAddress(*pRanges);
+ }
+ }
+}
+
+// XNameContainer
+
+void lcl_RemoveNamedEntry( ScNamedEntryArr_Impl& rNamedEntries, const String& rName )
+{
+ USHORT nCount = rNamedEntries.Count();
+ for ( USHORT n=nCount; n--; )
+ if ( rNamedEntries[n]->GetName() == rName )
+ rNamedEntries.DeleteAndDestroy( n );
+}
+
+void SAL_CALL ScCellRangesObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::ElementExistException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ BOOL bDone = FALSE;
+
+ //! Type of aElement can be some specific interface instead of XInterface
+
+ uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
+ if ( pDocSh && xInterface.is() )
+ {
+ ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
+ if ( pRangesImp && pRangesImp->GetDocShell() == pDocSh )
+ {
+ // if explicit name is given and already existing, throw exception
+
+ String aNamStr(aName);
+ if ( aNamStr.Len() )
+ {
+ USHORT nNamedCount = aNamedEntries.Count();
+ for (USHORT n=0; n<nNamedCount; n++)
+ if ( aNamedEntries[n]->GetName() == aNamStr )
+ throw container::ElementExistException();
+ }
+
+ ScRangeList aNew(GetRangeList());
+ const ScRangeList& rAddRanges = pRangesImp->GetRangeList();
+ ULONG nAddCount = rAddRanges.Count();
+ for (ULONG i=0; i<nAddCount; i++)
+ aNew.Join( *rAddRanges.GetObject(i) );
+ SetNewRanges(aNew);
+ bDone = TRUE;
+
+ if ( aName.getLength() && nAddCount == 1 )
+ {
+ // if a name is given, also insert into list of named entries
+ // (only possible for a single range)
+ // name is not in aNamedEntries (tested above)
+
+ ScNamedEntry* pEntry = new ScNamedEntry( aNamStr, *rAddRanges.GetObject(0) );
+ aNamedEntries.Insert( pEntry, aNamedEntries.Count() );
+ }
+ }
+ }
+
+ if (!bDone)
+ {
+ // invalid element - double names are handled above
+ throw lang::IllegalArgumentException();
+ }
+}
+
+BOOL lcl_FindRangeByName( const ScRangeList& rRanges, ScDocShell* pDocSh,
+ const String& rName, ULONG& rIndex )
+{
+ if (pDocSh)
+ {
+ String aRangeStr;
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ rRanges.GetObject(i)->Format( aRangeStr, SCA_VALID | SCA_TAB_3D, pDoc );
+ if ( aRangeStr == rName )
+ {
+ rIndex = i;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE; // nicht gefunden
+}
+
+BOOL lcl_FindRangeOrEntry( const ScNamedEntryArr_Impl& rNamedEntries,
+ const ScRangeList& rRanges, ScDocShell* pDocSh,
+ const String& rName, ScRange& rFound )
+{
+ // exact range in list?
+
+ ULONG nIndex = 0;
+ if ( lcl_FindRangeByName( rRanges, pDocSh, rName, nIndex ) )
+ {
+ rFound = *rRanges.GetObject(nIndex);
+ return TRUE;
+ }
+
+ // range contained in selection? (sheet must be specified)
+
+ ScRange aCellRange;
+ USHORT nParse = aCellRange.ParseAny( rName, pDocSh->GetDocument() );
+ if ( ( nParse & ( SCA_VALID | SCA_TAB_3D ) ) == ( SCA_VALID | SCA_TAB_3D ) )
+ {
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( rRanges, FALSE );
+ aMarkData.MarkToMulti(); // needed for IsAllMarked
+ if ( aMarkData.IsAllMarked( aCellRange ) )
+ {
+ rFound = aCellRange;
+ return TRUE;
+ }
+ }
+
+ // named entry in this object?
+
+ if ( rNamedEntries.Count() )
+ {
+ for ( USHORT n=0; n<rNamedEntries.Count(); n++ )
+ if ( rNamedEntries[n]->GetName() == rName )
+ {
+ // test if named entry is contained in rRanges
+
+ const ScRange& rComp = rNamedEntries[n]->GetRange();
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( rRanges, FALSE );
+ aMarkData.MarkToMulti(); // needed for IsAllMarked
+ if ( aMarkData.IsAllMarked( rComp ) )
+ {
+ rFound = rComp;
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE; // not found
+}
+
+void SAL_CALL ScCellRangesObj::removeByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ String aNameStr(aName);
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ ULONG nIndex = 0;
+ if ( lcl_FindRangeByName( rRanges, pDocSh, aNameStr, nIndex ) )
+ {
+ // einzelnen Range weglassen
+ ScRangeList aNew;
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ if (i != nIndex)
+ aNew.Append( *rRanges.GetObject(i) );
+ SetNewRanges(aNew);
+ bDone = TRUE;
+ }
+ else if (pDocSh)
+ {
+ // deselect any ranges (parsed or named entry)
+ ScRangeList aDiff;
+ BOOL bValid = ( aDiff.Parse( aNameStr, pDocSh->GetDocument() ) & SCA_VALID ) != 0;
+ if ( !bValid && aNamedEntries.Count() )
+ {
+ USHORT nCount = aNamedEntries.Count();
+ for (USHORT n=0; n<nCount && !bValid; n++)
+ if (aNamedEntries[n]->GetName() == aNameStr)
+ {
+ aDiff.RemoveAll();
+ aDiff.Append( aNamedEntries[n]->GetRange() );
+ bValid = TRUE;
+ }
+ }
+ if ( bValid )
+ {
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( rRanges, FALSE );
+
+ ULONG nDiffCount = aDiff.Count();
+ for (ULONG i=0; i<nDiffCount; i++)
+ {
+ ScRange* pDiffRange = aDiff.GetObject(i);
+ if (aMarkData.GetTableSelect( pDiffRange->aStart.Tab() ))
+ aMarkData.SetMultiMarkArea( *pDiffRange, FALSE );
+ }
+
+ ScRangeList aNew;
+ aMarkData.FillRangeListWithMarks( &aNew, FALSE );
+ SetNewRanges(aNew);
+
+ bDone = TRUE; //! error if range was not selected before?
+ }
+ }
+
+ if (aNamedEntries.Count())
+ lcl_RemoveNamedEntry( aNamedEntries, aNameStr ); // remove named entry
+
+ if (!bDone)
+ throw container::NoSuchElementException(); // not found
+}
+
+// XNameReplace
+
+void SAL_CALL ScCellRangesObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! zusammenfassen?
+ removeByName( aName );
+ insertByName( aName, aElement );
+}
+
+// XNameAccess
+
+uno::Any SAL_CALL ScCellRangesObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+
+ String aNameStr(aName);
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ ScRange aRange;
+ if ( lcl_FindRangeOrEntry( aNamedEntries, rRanges, pDocSh, aNameStr, aRange ) )
+ {
+ uno::Reference<table::XCellRange> xRange;
+ if ( aRange.aStart == aRange.aEnd )
+ xRange.set(new ScCellObj( pDocSh, aRange.aStart ));
+ else
+ xRange.set(new ScCellRangeObj( pDocSh, aRange ));
+ aRet <<= xRange;
+ }
+ else
+ throw container::NoSuchElementException();
+ return aRet;
+}
+
+BOOL lcl_FindEntryName( const ScNamedEntryArr_Impl& rNamedEntries,
+ const ScRange& rRange, String& rName )
+{
+ USHORT nCount = rNamedEntries.Count();
+ for (USHORT i=0; i<nCount; i++)
+ if (rNamedEntries[i]->GetRange() == rRange)
+ {
+ rName = rNamedEntries[i]->GetName();
+ return TRUE;
+ }
+ return FALSE;
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ if (pDocSh)
+ {
+ String aRangeStr;
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ULONG nCount = rRanges.Count();
+
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ // use given name if for exactly this range, otherwise just format
+ ScRange aRange = *rRanges.GetObject(i);
+ if ( !aNamedEntries.Count() || !lcl_FindEntryName( aNamedEntries, aRange, aRangeStr ) )
+ aRange.Format( aRangeStr, SCA_VALID | SCA_TAB_3D, pDoc );
+ pAry[i] = aRangeStr;
+ }
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+sal_Bool SAL_CALL ScCellRangesObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr(aName);
+ ScDocShell* pDocSh = GetDocShell();
+ const ScRangeList& rRanges = GetRangeList();
+ ScRange aRange;
+ return lcl_FindRangeOrEntry( aNamedEntries, rRanges, pDocSh, aNameStr, aRange );
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScCellRangesObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetCellRangesEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScCellRangesObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ return rRanges.Count();
+}
+
+uno::Any SAL_CALL ScCellRangesObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
+ if (xRange.is())
+ return uno::makeAny(xRange);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScCellRangesObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<table::XCellRange>*)0);
+}
+
+sal_Bool SAL_CALL ScCellRangesObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ return rRanges.Count() != 0;
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScCellRangesObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScCellRangesObj" );
+}
+
+sal_Bool SAL_CALL ScCellRangesObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr(rServiceName);
+ return aServiceStr.EqualsAscii( SCSHEETCELLRANGES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellRangesObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(4);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSHEETCELLRANGES_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
+ pArray[2] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
+ pArray[3] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+// static
+uno::Reference<table::XCellRange> ScCellRangeObj::CreateRangeFromDoc( ScDocument* pDoc, const ScRange& rR )
+{
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ return new ScCellRangeObj( (ScDocShell*) pObjSh, rR );
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+
+ScCellRangeObj::ScCellRangeObj(ScDocShell* pDocSh, const ScRange& rR) :
+ ScCellRangesBase( pDocSh, rR ),
+ pRangePropSet( lcl_GetRangePropertySet() ),
+ aRange( rR )
+{
+ aRange.Justify(); // Anfang / Ende richtig
+}
+
+ScCellRangeObj::~ScCellRangeObj()
+{
+}
+
+void ScCellRangeObj::RefChanged()
+{
+ ScCellRangesBase::RefChanged();
+
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT(rRanges.Count() == 1, "was fuer Ranges ?!?!");
+ const ScRange* pFirst = rRanges.GetObject(0);
+ if (pFirst)
+ {
+ aRange = *pFirst;
+ aRange.Justify();
+ }
+}
+
+uno::Any SAL_CALL ScCellRangeObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XCellRangeAddressable )
+ SC_QUERYINTERFACE( table::XCellRange )
+ SC_QUERYINTERFACE( sheet::XSheetCellRange )
+ SC_QUERYINTERFACE( sheet::XArrayFormulaRange )
+ SC_QUERYINTERFACE( sheet::XArrayFormulaTokens )
+ SC_QUERYINTERFACE( sheet::XCellRangeData )
+ SC_QUERYINTERFACE( sheet::XCellRangeFormula )
+ SC_QUERYINTERFACE( sheet::XMultipleOperation )
+ SC_QUERYINTERFACE( util::XMergeable )
+ SC_QUERYINTERFACE( sheet::XCellSeries )
+ SC_QUERYINTERFACE( table::XAutoFormattable )
+ SC_QUERYINTERFACE( util::XSortable )
+ SC_QUERYINTERFACE( sheet::XSheetFilterableEx )
+ SC_QUERYINTERFACE( sheet::XSheetFilterable )
+ SC_QUERYINTERFACE( sheet::XSubTotalCalculatable )
+ SC_QUERYINTERFACE( table::XColumnRowRange )
+ SC_QUERYINTERFACE( util::XImportable )
+ SC_QUERYINTERFACE( sheet::XCellFormatRangesSupplier )
+ SC_QUERYINTERFACE( sheet::XUniqueCellFormatRangesSupplier )
+
+ return ScCellRangesBase::queryInterface( rType );
+}
+
+void SAL_CALL ScCellRangeObj::acquire() throw()
+{
+ ScCellRangesBase::acquire();
+}
+
+void SAL_CALL ScCellRangeObj::release() throw()
+{
+ ScCellRangesBase::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScCellRangeObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(ScCellRangesBase::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 17 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XCellRangeAddressable>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XSheetCellRange>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XArrayFormulaRange>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XArrayFormulaTokens>*)0);
+ pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XCellRangeData>*)0);
+ pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XCellRangeFormula>*)0);
+ pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XMultipleOperation>*)0);
+ pPtr[nParentLen + 7] = getCppuType((const uno::Reference<util::XMergeable>*)0);
+ pPtr[nParentLen + 8] = getCppuType((const uno::Reference<sheet::XCellSeries>*)0);
+ pPtr[nParentLen + 9] = getCppuType((const uno::Reference<table::XAutoFormattable>*)0);
+ pPtr[nParentLen +10] = getCppuType((const uno::Reference<util::XSortable>*)0);
+ pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetFilterableEx>*)0);
+ pPtr[nParentLen +12] = getCppuType((const uno::Reference<sheet::XSubTotalCalculatable>*)0);
+ pPtr[nParentLen +13] = getCppuType((const uno::Reference<table::XColumnRowRange>*)0);
+ pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XImportable>*)0);
+ pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XCellFormatRangesSupplier>*)0);
+ pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XUniqueCellFormatRangesSupplier>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScCellRangeObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XCellRange
+
+// ColumnCount / RowCount sind weggefallen
+//! werden im Writer fuer Tabellen noch gebraucht ???
+
+uno::Reference<table::XCell> ScCellRangeObj::GetCellByPosition_Impl(
+ sal_Int32 nColumn, sal_Int32 nRow )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ throw uno::RuntimeException();
+
+ if ( nColumn >= 0 && nRow >= 0 )
+ {
+ sal_Int32 nPosX = aRange.aStart.Col() + nColumn;
+ sal_Int32 nPosY = aRange.aStart.Row() + nRow;
+
+ if ( nPosX <= aRange.aEnd.Col() && nPosY <= aRange.aEnd.Row() )
+ {
+ ScAddress aNew( (SCCOL)nPosX, (SCROW)nPosY, aRange.aStart.Tab() );
+ return new ScCellObj( pDocSh, aNew );
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+// return NULL;
+}
+
+uno::Reference<table::XCell> SAL_CALL ScCellRangeObj::getCellByPosition(
+ sal_Int32 nColumn, sal_Int32 nRow )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return GetCellByPosition_Impl(nColumn, nRow);
+}
+
+uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByPosition(
+ sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ throw uno::RuntimeException();
+
+ if ( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
+ {
+ sal_Int32 nStartX = aRange.aStart.Col() + nLeft;
+ sal_Int32 nStartY = aRange.aStart.Row() + nTop;
+ sal_Int32 nEndX = aRange.aStart.Col() + nRight;
+ sal_Int32 nEndY = aRange.aStart.Row() + nBottom;
+
+ if ( nStartX <= nEndX && nEndX <= aRange.aEnd.Col() &&
+ nStartY <= nEndY && nEndY <= aRange.aEnd.Row() )
+ {
+ ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, aRange.aStart.Tab(),
+ (SCCOL)nEndX, (SCROW)nEndY, aRange.aEnd.Tab() );
+ return new ScCellRangeObj( pDocSh, aNew );
+ }
+ }
+
+ throw lang::IndexOutOfBoundsException();
+// return NULL;
+}
+
+
+uno::Reference<table::XCellRange> SAL_CALL ScCellRangeObj::getCellRangeByName(
+ const rtl::OUString& aName ) throw(uno::RuntimeException)
+{
+ return getCellRangeByName( aName, ScAddress::detailsOOOa1 );
+}
+
+uno::Reference<table::XCellRange> ScCellRangeObj::getCellRangeByName(
+ const rtl::OUString& aName, const ScAddress::Details& rDetails ) throw(uno::RuntimeException)
+{
+ // name refers to the whole document (with the range's table as default),
+ // valid only if the range is within this range
+
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ ScRange aCellRange;
+ BOOL bFound = FALSE;
+ String aString(aName);
+ USHORT nParse = aCellRange.ParseAny( aString, pDoc, rDetails );
+ if ( nParse & SCA_VALID )
+ {
+ if ( !(nParse & SCA_TAB_3D) ) // keine Tabelle angegeben -> auf dieser Tabelle
+ {
+ aCellRange.aStart.SetTab(nTab);
+ aCellRange.aEnd.SetTab(nTab);
+ }
+ bFound = TRUE;
+ }
+ else
+ {
+ ScRangeUtil aRangeUtil;
+ if ( aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_NAMES ) ||
+ aRangeUtil.MakeRangeFromName( aString, pDoc, nTab, aCellRange, RUTL_DBASE ) )
+ bFound = TRUE;
+ }
+
+ if (bFound) // valid only if within this object's range
+ {
+ if (!aRange.In(aCellRange))
+ bFound = FALSE;
+ }
+
+ if (bFound)
+ {
+ if ( aCellRange.aStart == aCellRange.aEnd )
+ return new ScCellObj( pDocSh, aCellRange.aStart );
+ else
+ return new ScCellRangeObj( pDocSh, aCellRange );
+ }
+ }
+
+ throw uno::RuntimeException();
+// return NULL;
+}
+
+// XColumnRowRange
+
+uno::Reference<table::XTableColumns> SAL_CALL ScCellRangeObj::getColumns() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ return new ScTableColumnsObj( pDocSh, aRange.aStart.Tab(),
+ aRange.aStart.Col(), aRange.aEnd.Col() );
+
+ DBG_ERROR("Dokument ungueltig");
+ return NULL;
+}
+
+uno::Reference<table::XTableRows> SAL_CALL ScCellRangeObj::getRows() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ return new ScTableRowsObj( pDocSh, aRange.aStart.Tab(),
+ aRange.aStart.Row(), aRange.aEnd.Row() );
+
+ DBG_ERROR("Dokument ungueltig");
+ return NULL;
+}
+
+// XAddressableCellRange
+
+table::CellRangeAddress SAL_CALL ScCellRangeObj::getRangeAddress() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aRet;
+ ScUnoConversion::FillApiRange( aRet, aRange );
+ return aRet;
+}
+
+// XSheetCellRange
+
+uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellRangeObj::getSpreadsheet()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ return new ScTableSheetObj( pDocSh, aRange.aStart.Tab() );
+
+ DBG_ERROR("Dokument ungueltig");
+ return NULL;
+}
+
+// XArrayFormulaRange
+
+rtl::OUString SAL_CALL ScCellRangeObj::getArrayFormula() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // Matrix-Formel, wenn eindeutig Teil einer Matrix,
+ // also wenn Anfang und Ende des Blocks zur selben Matrix gehoeren.
+ // Sonst Leerstring.
+
+ String aFormula;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ const ScBaseCell* pCell1 = pDoc->GetCell( aRange.aStart );
+ const ScBaseCell* pCell2 = pDoc->GetCell( aRange.aEnd );
+ if ( pCell1 && pCell2 && pCell1->GetCellType() == CELLTYPE_FORMULA &&
+ pCell2->GetCellType() == CELLTYPE_FORMULA )
+ {
+ const ScFormulaCell* pFCell1 = (const ScFormulaCell*)pCell1;
+ const ScFormulaCell* pFCell2 = (const ScFormulaCell*)pCell2;
+ ScAddress aStart1;
+ ScAddress aStart2;
+ if ( pFCell1->GetMatrixOrigin( aStart1 ) && pFCell2->GetMatrixOrigin( aStart2 ) )
+ {
+ if ( aStart1 == aStart2 ) // beides dieselbe Matrix
+ pFCell1->GetFormula( aFormula ); // egal, von welcher Zelle
+ }
+ }
+ }
+ return aFormula;
+}
+
+void ScCellRangeObj::SetArrayFormula_Impl( const rtl::OUString& rFormula,
+ const rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ ScDocFunc aFunc(*pDocSh);
+ if ( rFormula.getLength() )
+ {
+ if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
+ {
+ // #74681# don't set array formula for sheet object
+ throw uno::RuntimeException();
+ }
+
+ aFunc.EnterMatrix( aRange, NULL, NULL, rFormula, TRUE, TRUE, rFormulaNmsp, eGrammar );
+ }
+ else
+ {
+ // empty string -> erase array formula
+ ScMarkData aMark;
+ aMark.SetMarkArea( aRange );
+ aMark.SelectTable( aRange.aStart.Tab(), TRUE );
+ aFunc.DeleteContents( aMark, IDF_CONTENTS, TRUE, TRUE );
+ }
+ }
+}
+
+void SAL_CALL ScCellRangeObj::setArrayFormula( const rtl::OUString& aFormula )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // GRAM_PODF_A1 for API compatibility.
+ SetArrayFormula_Impl( aFormula, ::rtl::OUString(), formula::FormulaGrammar::GRAM_PODF_A1);
+}
+
+void ScCellRangeObj::SetArrayFormulaWithGrammar( const rtl::OUString& rFormula,
+ const rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SetArrayFormula_Impl( rFormula, rFormulaNmsp, eGrammar);
+}
+
+// XArrayFormulaTokens
+
+uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellRangeObj::getArrayTokens() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // same cell logic as in getArrayFormula
+
+ uno::Sequence<sheet::FormulaToken> aSequence;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ const ScBaseCell* pCell1 = pDoc->GetCell( aRange.aStart );
+ const ScBaseCell* pCell2 = pDoc->GetCell( aRange.aEnd );
+ if ( pCell1 && pCell2 && pCell1->GetCellType() == CELLTYPE_FORMULA &&
+ pCell2->GetCellType() == CELLTYPE_FORMULA )
+ {
+ const ScFormulaCell* pFCell1 = (const ScFormulaCell*)pCell1;
+ const ScFormulaCell* pFCell2 = (const ScFormulaCell*)pCell2;
+ ScAddress aStart1;
+ ScAddress aStart2;
+ if ( pFCell1->GetMatrixOrigin( aStart1 ) && pFCell2->GetMatrixOrigin( aStart2 ) )
+ {
+ if ( aStart1 == aStart2 )
+ {
+ ScTokenArray* pTokenArray = pFCell1->GetCode();
+ if ( pTokenArray )
+ (void)ScTokenConversion::ConvertToTokenSequence( *pDoc, aSequence, *pTokenArray );
+ }
+ }
+ }
+ }
+ return aSequence;
+}
+
+void SAL_CALL ScCellRangeObj::setArrayTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ if ( rTokens.getLength() )
+ {
+ if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
+ {
+ throw uno::RuntimeException();
+ }
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScTokenArray aTokenArray;
+ (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
+
+ // Actually GRAM_PODF_A1 is a don't-care here because of the token
+ // array being set, it fits with other API compatibility grammars
+ // though.
+ aFunc.EnterMatrix( aRange, NULL, &aTokenArray, EMPTY_STRING, TRUE, TRUE, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
+ }
+ else
+ {
+ // empty sequence -> erase array formula
+ ScMarkData aMark;
+ aMark.SetMarkArea( aRange );
+ aMark.SelectTable( aRange.aStart.Tab(), TRUE );
+ aFunc.DeleteContents( aMark, IDF_CONTENTS, TRUE, TRUE );
+ }
+ }
+}
+
+// XCellRangeData
+
+uno::Sequence< uno::Sequence<uno::Any> > SAL_CALL ScCellRangeObj::getDataArray()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
+ {
+ // don't create a data array for the sheet
+ throw uno::RuntimeException();
+ }
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ uno::Any aAny;
+ // bAllowNV = TRUE: errors as void
+ if ( ScRangeToSequence::FillMixedArray( aAny, pDocSh->GetDocument(), aRange, TRUE ) )
+ {
+ uno::Sequence< uno::Sequence<uno::Any> > aSeq;
+ if ( aAny >>= aSeq )
+ return aSeq; // success
+ }
+ }
+
+ throw uno::RuntimeException(); // no other exceptions specified
+// return uno::Sequence< uno::Sequence<uno::Any> >(0);
+}
+
+void SAL_CALL ScCellRangeObj::setDataArray(
+ const uno::Sequence< uno::Sequence<uno::Any> >& aArray )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ BOOL bDone = FALSE;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ //! move lcl_PutDataArray to docfunc?
+ bDone = lcl_PutDataArray( *pDocSh, aRange, aArray );
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+// XCellRangeFormula
+
+uno::Sequence< uno::Sequence<rtl::OUString> > SAL_CALL ScCellRangeObj::getFormulaArray()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( ScTableSheetObj::getImplementation( (cppu::OWeakObject*)this ) )
+ {
+ // don't create a data array for the sheet
+ throw uno::RuntimeException();
+ }
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ SCCOL nColCount = nEndCol + 1 - nStartCol;
+ SCROW nRowCount = nEndRow + 1 - nStartRow;
+ SCTAB nTab = aRange.aStart.Tab();
+
+ uno::Sequence< uno::Sequence<rtl::OUString> > aRowSeq( nRowCount );
+ uno::Sequence<rtl::OUString>* pRowAry = aRowSeq.getArray();
+ for (SCROW nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
+ {
+ uno::Sequence<rtl::OUString> aColSeq( nColCount );
+ rtl::OUString* pColAry = aColSeq.getArray();
+ for (SCCOL nColIndex = 0; nColIndex < nColCount; nColIndex++)
+ pColAry[nColIndex] = lcl_GetInputString( pDocSh->GetDocument(),
+ ScAddress( nStartCol+nColIndex, nStartRow+nRowIndex, nTab ), TRUE );
+
+ pRowAry[nRowIndex] = aColSeq;
+ }
+
+ return aRowSeq;
+ }
+
+ throw uno::RuntimeException(); // no other exceptions specified
+// return uno::Sequence< uno::Sequence<rtl::OUString> >(0);
+}
+
+void SAL_CALL ScCellRangeObj::setFormulaArray(
+ const uno::Sequence< uno::Sequence<rtl::OUString> >& aArray )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ BOOL bDone = FALSE;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ ScExternalRefManager::ApiGuard aExtRefGuard(pDocSh->GetDocument());
+
+ // GRAM_PODF_A1 for API compatibility.
+ bDone = lcl_PutFormulaArray( *pDocSh, aRange, aArray, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+// XMultipleOperation
+
+void SAL_CALL ScCellRangeObj::setTableOperation( const table::CellRangeAddress& aFormulaRange,
+ sheet::TableOperationMode nMode,
+ const table::CellAddress& aColumnCell,
+ const table::CellAddress& aRowCell )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ BOOL bError = FALSE;
+ ScTabOpParam aParam;
+ aParam.aRefFormulaCell = ScRefAddress( (SCCOL)aFormulaRange.StartColumn,
+ (SCROW)aFormulaRange.StartRow, aFormulaRange.Sheet,
+ FALSE, FALSE, FALSE );
+ aParam.aRefFormulaEnd = ScRefAddress( (SCCOL)aFormulaRange.EndColumn,
+ (SCROW)aFormulaRange.EndRow, aFormulaRange.Sheet,
+ FALSE, FALSE, FALSE );
+ aParam.aRefRowCell = ScRefAddress( (SCCOL)aRowCell.Column,
+ (SCROW)aRowCell.Row, aRowCell.Sheet,
+ FALSE, FALSE, FALSE );
+ aParam.aRefColCell = ScRefAddress( (SCCOL)aColumnCell.Column,
+ (SCROW)aColumnCell.Row, aColumnCell.Sheet,
+ FALSE, FALSE, FALSE );
+ switch (nMode)
+ {
+ case sheet::TableOperationMode_COLUMN:
+ aParam.nMode = 0;
+ break;
+ case sheet::TableOperationMode_ROW:
+ aParam.nMode = 1;
+ break;
+ case sheet::TableOperationMode_BOTH:
+ aParam.nMode = 2;
+ break;
+ default:
+ bError = TRUE;
+ }
+
+ if (!bError)
+ {
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.TabOp( aRange, NULL, aParam, TRUE, TRUE );
+ }
+ }
+}
+
+// XMergeable
+
+void SAL_CALL ScCellRangeObj::merge( sal_Bool bMerge ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ ScCellMergeOption aMergeOption(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), false);
+ aMergeOption.maTabs.insert(aRange.aStart.Tab());
+ if ( bMerge )
+ aFunc.MergeCells( aMergeOption, FALSE, TRUE, TRUE );
+ else
+ aFunc.UnmergeCells( aMergeOption, TRUE, TRUE );
+
+ //! Fehler abfangen?
+ }
+}
+
+sal_Bool SAL_CALL ScCellRangeObj::getIsMerged() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ return pDocSh && pDocSh->GetDocument()->HasAttrib( aRange, HASATTR_MERGED );
+}
+
+// XCellSeries
+
+void SAL_CALL ScCellRangeObj::fillSeries( sheet::FillDirection nFillDirection,
+ sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode,
+ double fStep, double fEndValue ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BOOL bError = FALSE;
+
+ FillDir eDir = FILL_TO_BOTTOM;
+ switch (nFillDirection)
+ {
+ case sheet::FillDirection_TO_BOTTOM:
+ eDir = FILL_TO_BOTTOM;
+ break;
+ case sheet::FillDirection_TO_RIGHT:
+ eDir = FILL_TO_RIGHT;
+ break;
+ case sheet::FillDirection_TO_TOP:
+ eDir = FILL_TO_TOP;
+ break;
+ case sheet::FillDirection_TO_LEFT:
+ eDir = FILL_TO_LEFT;
+ break;
+ default:
+ bError = TRUE;
+ }
+
+ FillCmd eCmd = FILL_SIMPLE;
+ switch ( nFillMode )
+ {
+ case sheet::FillMode_SIMPLE:
+ eCmd = FILL_SIMPLE;
+ break;
+ case sheet::FillMode_LINEAR:
+ eCmd = FILL_LINEAR;
+ break;
+ case sheet::FillMode_GROWTH:
+ eCmd = FILL_GROWTH;
+ break;
+ case sheet::FillMode_DATE:
+ eCmd = FILL_DATE;
+ break;
+ case sheet::FillMode_AUTO:
+ eCmd = FILL_AUTO;
+ break;
+ default:
+ bError = TRUE;
+ }
+
+ FillDateCmd eDateCmd = FILL_DAY;
+ switch ( nFillDateMode )
+ {
+ case sheet::FillDateMode_FILL_DATE_DAY:
+ eDateCmd = FILL_DAY;
+ break;
+ case sheet::FillDateMode_FILL_DATE_WEEKDAY:
+ eDateCmd = FILL_WEEKDAY;
+ break;
+ case sheet::FillDateMode_FILL_DATE_MONTH:
+ eDateCmd = FILL_MONTH;
+ break;
+ case sheet::FillDateMode_FILL_DATE_YEAR:
+ eDateCmd = FILL_YEAR;
+ break;
+ default:
+ bError = TRUE;
+ }
+
+ if (!bError)
+ {
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.FillSeries( aRange, NULL, eDir, eCmd, eDateCmd,
+ MAXDOUBLE, fStep, fEndValue, TRUE, TRUE );
+ }
+ }
+}
+
+void SAL_CALL ScCellRangeObj::fillAuto( sheet::FillDirection nFillDirection,
+ sal_Int32 nSourceCount ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh && nSourceCount )
+ {
+ ScRange aSourceRange(aRange);
+ SCsCOLROW nCount = 0; // "Dest-Count"
+ FillDir eDir = FILL_TO_BOTTOM;
+ BOOL bError = FALSE;
+ switch (nFillDirection)
+ {
+ case sheet::FillDirection_TO_BOTTOM:
+ aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount - 1 ) );
+ nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
+ eDir = FILL_TO_BOTTOM;
+ break;
+ case sheet::FillDirection_TO_RIGHT:
+ aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
+ nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
+ eDir = FILL_TO_RIGHT;
+ break;
+ case sheet::FillDirection_TO_TOP:
+ aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
+ nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
+ eDir = FILL_TO_TOP;
+ break;
+ case sheet::FillDirection_TO_LEFT:
+ aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
+ nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
+ eDir = FILL_TO_LEFT;
+ break;
+ default:
+ bError = TRUE;
+ }
+ if (nCount < 0 || nCount > MAXROW) // overflow
+ bError = TRUE;
+
+ if (!bError)
+ {
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.FillAuto( aSourceRange, NULL, eDir, nCount, TRUE, TRUE );
+ }
+ }
+}
+
+// XAutoFormattable
+
+void SAL_CALL ScCellRangeObj::autoFormat( const rtl::OUString& aName )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAutoFormat* pAutoFormat = ScGlobal::GetAutoFormat();
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh && pAutoFormat )
+ {
+ String aNameString(aName);
+ USHORT nCount = pAutoFormat->GetCount();
+ USHORT nIndex;
+ String aCompare;
+ for (nIndex=0; nIndex<nCount; nIndex++)
+ {
+ (*pAutoFormat)[nIndex]->GetName(aCompare);
+ if ( aCompare == aNameString ) //! Case-insensitiv ???
+ break;
+ }
+ if (nIndex<nCount)
+ {
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.AutoFormat( aRange, NULL, nIndex, TRUE, TRUE );
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+}
+
+// XSortable
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createSortDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSortParam aParam;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
+ if (pData)
+ {
+ pData->GetSortParam(aParam);
+
+ // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOLROW nFieldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
+ static_cast<SCCOLROW>(aDBRange.aStart.Row());
+ for (USHORT i=0; i<MAXSORT; i++)
+ if ( aParam.bDoSort[i] && aParam.nField[i] >= nFieldStart )
+ aParam.nField[i] -= nFieldStart;
+ }
+ }
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
+ ScSortDescriptor::FillProperties( aSeq, aParam );
+ return aSeq;
+}
+
+void SAL_CALL ScCellRangeObj::sort( const uno::Sequence<beans::PropertyValue>& aDescriptor )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ USHORT i;
+ ScSortParam aParam;
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
+ if (pData)
+ {
+ // alten Einstellungen holen, falls nicht alles neu gesetzt wird
+ pData->GetSortParam(aParam);
+ SCCOLROW nOldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aRange.aStart.Col()) :
+ static_cast<SCCOLROW>(aRange.aStart.Row());
+ for (i=0; i<MAXSORT; i++)
+ if ( aParam.bDoSort[i] && aParam.nField[i] >= nOldStart )
+ aParam.nField[i] -= nOldStart;
+ }
+
+ ScSortDescriptor::FillSortParam( aParam, aDescriptor );
+
+ // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ // ByRow kann bei FillSortParam umgesetzt worden sein
+ SCCOLROW nFieldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aRange.aStart.Col()) :
+ static_cast<SCCOLROW>(aRange.aStart.Row());
+ for (i=0; i<MAXSORT; i++)
+ aParam.nField[i] += nFieldStart;
+
+ SCTAB nTab = aRange.aStart.Tab();
+ aParam.nCol1 = aRange.aStart.Col();
+ aParam.nRow1 = aRange.aStart.Row();
+ aParam.nCol2 = aRange.aEnd.Col();
+ aParam.nRow2 = aRange.aEnd.Row();
+
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
+
+ ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
+ aFunc.Sort( nTab, aParam, TRUE, TRUE, TRUE );
+ }
+}
+
+// XFilterable
+
+uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptor(
+ sal_Bool bEmpty ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh);
+ if ( !bEmpty && pDocSh )
+ {
+ // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
+ if (pData)
+ {
+ ScQueryParam aParam;
+ pData->GetQueryParam(aParam);
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOLROW nFieldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aDBRange.aStart.Col()) :
+ static_cast<SCCOLROW>(aDBRange.aStart.Row());
+ SCSIZE nCount = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
+ rEntry.nField -= nFieldStart;
+ }
+ pNew->SetParam(aParam);
+ }
+ }
+ return pNew;
+}
+
+void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDescriptor>& xDescriptor )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // das koennte theoretisch ein fremdes Objekt sein, also nur das
+ // oeffentliche XSheetFilterDescriptor Interface benutzen, um
+ // die Daten in ein ScFilterDescriptor Objekt zu kopieren:
+ //! wenn es schon ein ScFilterDescriptor ist, direkt per getImplementation?
+
+ ScDocShell* pDocSh = GetDocShell();
+ ScFilterDescriptor aImpl(pDocSh);
+ uno::Reference< sheet::XSheetFilterDescriptor2 > xDescriptor2( xDescriptor, uno::UNO_QUERY );
+ if ( xDescriptor2.is() )
+ {
+ aImpl.setFilterFields2( xDescriptor2->getFilterFields2() );
+ }
+ else
+ {
+ aImpl.setFilterFields( xDescriptor->getFilterFields() );
+ }
+ // Rest sind jetzt Properties...
+
+ uno::Reference<beans::XPropertySet> xPropSet( xDescriptor, uno::UNO_QUERY );
+ if (xPropSet.is())
+ lcl_CopyProperties( aImpl, *(beans::XPropertySet*)xPropSet.get() );
+
+ //
+ // ausfuehren...
+ //
+
+ if (pDocSh)
+ {
+ ScQueryParam aParam = aImpl.GetParam();
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ SCCOLROW nFieldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aRange.aStart.Col()) :
+ static_cast<SCCOLROW>(aRange.aStart.Row());
+ SCSIZE nCount = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (rEntry.bDoQuery)
+ {
+ rEntry.nField += nFieldStart;
+ // Im Dialog wird immer der String angezeigt -> muss zum Wert passen
+ if ( !rEntry.bQueryByString )
+ pDocSh->GetDocument()->GetFormatTable()->
+ GetInputLineString( rEntry.nVal, 0, *rEntry.pStr );
+ }
+ }
+
+ SCTAB nTab = aRange.aStart.Tab();
+ aParam.nCol1 = aRange.aStart.Col();
+ aParam.nRow1 = aRange.aStart.Row();
+ aParam.nCol2 = aRange.aEnd.Col();
+ aParam.nRow2 = aRange.aEnd.Row();
+
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
+
+ //! keep source range in filter descriptor
+ //! if created by createFilterDescriptorByObject ???
+
+ ScDBDocFunc aFunc(*pDocSh);
+ aFunc.Query( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
+ }
+}
+
+//! get/setAutoFilter als Properties!!!
+
+// XAdvancedFilterSource
+
+uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScCellRangeObj::createFilterDescriptorByObject(
+ const uno::Reference<sheet::XSheetFilterable>& xObject )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // this ist hier nicht der Bereich, der gefiltert wird, sondern der
+ // Bereich mit der Abfrage...
+
+ uno::Reference<sheet::XCellRangeAddressable> xAddr( xObject, uno::UNO_QUERY );
+
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh && xAddr.is() )
+ {
+ //! Test, ob xObject im selben Dokument ist
+
+ ScFilterDescriptor* pNew = new ScFilterDescriptor(pDocSh); //! stattdessen vom Objekt?
+ //XSheetFilterDescriptorRef xNew = xObject->createFilterDescriptor(TRUE);
+
+ ScQueryParam aParam = pNew->GetParam();
+ aParam.bHasHeader = TRUE;
+
+ table::CellRangeAddress aDataAddress(xAddr->getRangeAddress());
+ aParam.nCol1 = (SCCOL)aDataAddress.StartColumn;
+ aParam.nRow1 = (SCROW)aDataAddress.StartRow;
+ aParam.nCol2 = (SCCOL)aDataAddress.EndColumn;
+ aParam.nRow2 = (SCROW)aDataAddress.EndRow;
+ aParam.nTab = aDataAddress.Sheet;
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bOk = pDoc->CreateQueryParam(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(),
+ aRange.aStart.Tab(), aParam );
+ if ( bOk )
+ {
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ SCCOLROW nFieldStart = aParam.bByRow ?
+ static_cast<SCCOLROW>(aDataAddress.StartColumn) :
+ static_cast<SCCOLROW>(aDataAddress.StartRow);
+ SCSIZE nCount = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
+ rEntry.nField -= nFieldStart;
+ }
+
+ pNew->SetParam( aParam );
+ return pNew;
+ }
+ else
+ {
+ delete pNew;
+ return NULL; // ungueltig -> null
+ }
+ }
+
+ DBG_ERROR("kein Dokument oder kein Bereich");
+ return NULL;
+}
+
+// XSubTotalSource
+
+uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScCellRangeObj::createSubTotalDescriptor(
+ sal_Bool bEmpty ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalDescriptor* pNew = new ScSubTotalDescriptor;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( !bEmpty && pDocSh )
+ {
+ // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
+ if (pData)
+ {
+ ScSubTotalParam aParam;
+ pData->GetSubTotalParam(aParam);
+ // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOL nFieldStart = aDBRange.aStart.Col();
+ for (USHORT i=0; i<MAXSUBTOTAL; i++)
+ {
+ if ( aParam.bGroupActive[i] )
+ {
+ if ( aParam.nField[i] >= nFieldStart )
+ aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] - nFieldStart );
+ for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
+ if ( aParam.pSubTotals[i][j] >= nFieldStart )
+ aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] - nFieldStart );
+ }
+ }
+ pNew->SetParam(aParam);
+ }
+ }
+ return pNew;
+}
+
+void SAL_CALL ScCellRangeObj::applySubTotals(
+ const uno::Reference<sheet::XSubTotalDescriptor>& xDescriptor,
+ sal_Bool bReplace ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (!xDescriptor.is()) return;
+
+ ScDocShell* pDocSh = GetDocShell();
+ ScSubTotalDescriptorBase* pImp =
+ ScSubTotalDescriptorBase::getImplementation( xDescriptor );
+
+ if (pDocSh && pImp)
+ {
+ ScSubTotalParam aParam;
+ pImp->GetData(aParam); // virtuelle Methode der Basisklasse
+
+ // im SubTotalDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ SCCOL nFieldStart = aRange.aStart.Col();
+ for (USHORT i=0; i<MAXSUBTOTAL; i++)
+ {
+ if ( aParam.bGroupActive[i] )
+ {
+ aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
+ for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
+ aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
+ }
+ }
+
+ aParam.bReplace = bReplace;
+
+ SCTAB nTab = aRange.aStart.Tab();
+ aParam.nCol1 = aRange.aStart.Col();
+ aParam.nRow1 = aRange.aStart.Row();
+ aParam.nCol2 = aRange.aEnd.Col();
+ aParam.nRow2 = aRange.aEnd.Row();
+
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
+
+ ScDBDocFunc aFunc(*pDocSh);
+ aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
+ }
+}
+
+void SAL_CALL ScCellRangeObj::removeSubTotals() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ ScSubTotalParam aParam;
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
+ if (pData)
+ pData->GetSubTotalParam(aParam); // auch bei Remove die Feld-Eintraege behalten
+
+ aParam.bRemoveOnly = TRUE;
+
+ SCTAB nTab = aRange.aStart.Tab();
+ aParam.nCol1 = aRange.aStart.Col();
+ aParam.nRow1 = aRange.aStart.Row();
+ aParam.nCol2 = aRange.aEnd.Col();
+ aParam.nRow2 = aRange.aEnd.Row();
+
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
+
+ ScDBDocFunc aFunc(*pDocSh);
+ aFunc.DoSubTotals( nTab, aParam, NULL, TRUE, TRUE ); // Bereich muss angelegt sein
+ }
+}
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScCellRangeObj::createImportDescriptor( sal_Bool bEmpty )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScImportParam aParam;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( !bEmpty && pDocSh )
+ {
+ // DB-Bereich anlegen erst beim Ausfuehren, per API immer genau den Bereich
+ ScDBData* pData = pDocSh->GetDBData( aRange, SC_DB_OLD, SC_DBSEL_FORCE_MARK );
+ if (pData)
+ pData->GetImportParam(aParam);
+ }
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
+ ScImportDescriptor::FillProperties( aSeq, aParam );
+ return aSeq;
+}
+
+void SAL_CALL ScCellRangeObj::doImport( const uno::Sequence<beans::PropertyValue>& aDescriptor )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ ScImportParam aParam;
+ ScImportDescriptor::FillImportParam( aParam, aDescriptor );
+
+ SCTAB nTab = aRange.aStart.Tab();
+ aParam.nCol1 = aRange.aStart.Col();
+ aParam.nRow1 = aRange.aStart.Row();
+ aParam.nCol2 = aRange.aEnd.Col();
+ aParam.nRow2 = aRange.aEnd.Row();
+
+ //! TODO: could we get passed a valid result set by any means?
+ uno::Reference< sdbc::XResultSet > xResultSet;
+
+ pDocSh->GetDBData( aRange, SC_DB_MAKE, SC_DBSEL_FORCE_MARK ); // ggf. Bereich anlegen
+
+ ScDBDocFunc aFunc(*pDocSh); // Bereich muss angelegt sein
+ aFunc.DoImport( nTab, aParam, xResultSet, NULL, TRUE, FALSE ); //! Api-Flag als Parameter
+ }
+}
+
+// XCellFormatRangesSupplier
+
+uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getCellFormatRanges()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScCellFormatsObj( pDocSh, aRange );
+ return NULL;
+}
+
+// XUniqueCellFormatRangesSupplier
+
+uno::Reference<container::XIndexAccess> SAL_CALL ScCellRangeObj::getUniqueCellFormatRanges()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScUniqueCellFormatsObj( pDocSh, aRange );
+ return NULL;
+}
+
+// XPropertySet erweitert fuer Range-Properties
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellRangeObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( pRangePropSet->getPropertyMap() ));
+ return aRef;
+}
+
+void ScCellRangeObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ // Range has only Position and Size in addition to ScCellRangesBase, both are ReadOnly
+ // -> nothing to do here
+
+ ScCellRangesBase::SetOnePropertyValue( pEntry, aValue );
+}
+
+void ScCellRangeObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
+ uno::Any& rAny )
+ throw(uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( pEntry->nWID == SC_WID_UNO_POS )
+ {
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
+ Rectangle aMMRect(pDocSh->GetDocument()->GetMMRect(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
+ awt::Point aPos( aMMRect.Left(), aMMRect.Top() );
+ rAny <<= aPos;
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_SIZE )
+ {
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ // GetMMRect converts using HMM_PER_TWIPS, like the DrawingLayer
+ Rectangle aMMRect = pDocSh->GetDocument()->GetMMRect(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() );
+ Size aSize(aMMRect.GetSize());
+ awt::Size aAwtSize( aSize.Width(), aSize.Height() );
+ rAny <<= aAwtSize;
+ }
+ }
+ else
+ ScCellRangesBase::GetOnePropertyValue( pEntry, rAny );
+
+ }
+}
+
+const SfxItemPropertyMap* ScCellRangeObj::GetItemPropertyMap()
+{
+ return pRangePropSet->getPropertyMap();
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScCellRangeObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScCellRangeObj" );
+}
+
+sal_Bool SAL_CALL ScCellRangeObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCSHEETCELLRANGE_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLRANGE_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellRangeObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(5);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSHEETCELLRANGE_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCCELLRANGE_SERVICE );
+ pArray[2] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
+ pArray[3] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
+ pArray[4] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+const SvxItemPropertySet* ScCellObj::GetEditPropertySet() // static
+{
+ return lcl_GetEditPropertySet();
+}
+const SfxItemPropertyMap* ScCellObj::GetCellPropertyMap()
+{
+ return lcl_GetCellPropertySet()->getPropertyMap();
+}
+
+ScCellObj::ScCellObj(ScDocShell* pDocSh, const ScAddress& rP) :
+ ScCellRangeObj( pDocSh, ScRange(rP,rP) ),
+ pUnoText( NULL ),
+ pCellPropSet( lcl_GetCellPropertySet() ),
+ aCellPos( rP ),
+ nActionLockCount( 0 )
+{
+ // pUnoText is allocated on demand (GetUnoText)
+ // can't be aggregated because getString/setString is handled here
+}
+
+SvxUnoText& ScCellObj::GetUnoText()
+{
+ if (!pUnoText)
+ {
+ pUnoText = new ScCellTextObj( GetDocShell(), aCellPos );
+ pUnoText->acquire();
+ if (nActionLockCount)
+ {
+ ScSharedCellEditSource* pEditSource =
+ static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
+ if (pEditSource)
+ pEditSource->SetDoUpdateData(sal_False);
+ }
+ }
+ return *pUnoText;
+}
+
+ScCellObj::~ScCellObj()
+{
+ if (pUnoText)
+ pUnoText->release();
+}
+
+void ScCellObj::RefChanged()
+{
+ ScCellRangeObj::RefChanged();
+
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT(rRanges.Count() == 1, "was fuer Ranges ?!?!");
+ const ScRange* pFirst = rRanges.GetObject(0);
+ if (pFirst)
+ aCellPos = pFirst->aStart;
+}
+
+uno::Any SAL_CALL ScCellObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( table::XCell )
+ SC_QUERYINTERFACE( sheet::XFormulaTokens )
+ SC_QUERYINTERFACE( sheet::XCellAddressable )
+ SC_QUERYINTERFACE( text::XText )
+ SC_QUERYINTERFACE( text::XSimpleText )
+ SC_QUERYINTERFACE( text::XTextRange )
+ SC_QUERYINTERFACE( container::XEnumerationAccess )
+ SC_QUERYINTERFACE( container::XElementAccess )
+ SC_QUERYINTERFACE( sheet::XSheetAnnotationAnchor )
+ SC_QUERYINTERFACE( text::XTextFieldsSupplier )
+ SC_QUERYINTERFACE( document::XActionLockable )
+
+ return ScCellRangeObj::queryInterface( rType );
+}
+
+void SAL_CALL ScCellObj::acquire() throw()
+{
+ ScCellRangeObj::acquire();
+}
+
+void SAL_CALL ScCellObj::release() throw()
+{
+ ScCellRangeObj::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScCellObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 8 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<table::XCell>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XCellAddressable>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<text::XText>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
+ pPtr[nParentLen + 4] = getCppuType((const uno::Reference<sheet::XSheetAnnotationAnchor>*)0);
+ pPtr[nParentLen + 5] = getCppuType((const uno::Reference<text::XTextFieldsSupplier>*)0);
+ pPtr[nParentLen + 6] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
+ pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XFormulaTokens>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScCellObj::getImplementationId() throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// Hilfsfunktionen
+
+String ScCellObj::GetInputString_Impl(BOOL bEnglish) const // fuer getFormula / FormulaLocal
+{
+ if (GetDocShell())
+ return lcl_GetInputString( GetDocShell()->GetDocument(), aCellPos, bEnglish );
+ return String();
+}
+
+String ScCellObj::GetOutputString_Impl(ScDocument* pDoc, const ScAddress& aCellPos)
+{
+ String aVal;
+ if ( pDoc )
+ {
+ ScBaseCell* pCell = pDoc->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
+ {
+ if ( pCell->GetCellType() == CELLTYPE_EDIT )
+ {
+ // GetString an der EditCell macht Leerzeichen aus Umbruechen,
+ // hier werden die Umbrueche aber gebraucht
+ const EditTextObject* pData = ((ScEditCell*)pCell)->GetData();
+ if (pData)
+ {
+ EditEngine& rEngine = pDoc->GetEditEngine();
+ rEngine.SetText( *pData );
+ aVal = rEngine.GetText( LINEEND_LF );
+ }
+ // Edit-Zellen auch nicht per NumberFormatter formatieren
+ // (passend zur Ausgabe)
+ }
+ else
+ {
+ // wie in GetString am Dokument (column)
+ Color* pColor;
+ ULONG nNumFmt = pDoc->GetNumberFormat( aCellPos );
+ ScCellFormat::GetString( pCell, nNumFmt, aVal, &pColor, *pDoc->GetFormatTable() );
+ }
+ }
+ }
+ return aVal;
+}
+
+String ScCellObj::GetOutputString_Impl() const
+{
+ ScDocShell* pDocSh = GetDocShell();
+ String aVal;
+ if ( pDocSh )
+ aVal = GetOutputString_Impl(pDocSh->GetDocument(), aCellPos);
+ return aVal;
+}
+
+void ScCellObj::SetString_Impl(const String& rString, BOOL bInterpret, BOOL bEnglish)
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ // GRAM_PODF_A1 for API compatibility.
+ (void)aFunc.SetCellText( aCellPos, rString, bInterpret, bEnglish, TRUE, EMPTY_STRING, formula::FormulaGrammar::GRAM_PODF_A1 );
+ }
+}
+
+double ScCellObj::GetValue_Impl() const
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return pDocSh->GetDocument()->GetValue( aCellPos );
+
+ return 0.0;
+}
+
+void ScCellObj::SetValue_Impl(double fValue)
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ (void)aFunc.PutCell( aCellPos, new ScValueCell(fValue), TRUE );
+ }
+}
+
+// only for XML import
+
+void ScCellObj::SetFormulaResultString( const ::rtl::OUString& rResult )
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScBaseCell* pCell = pDocSh->GetDocument()->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ ((ScFormulaCell*)pCell)->SetHybridString( rResult );
+ }
+}
+
+void ScCellObj::SetFormulaResultDouble( double fResult )
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScBaseCell* pCell = pDocSh->GetDocument()->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ ((ScFormulaCell*)pCell)->SetHybridDouble( fResult );
+ }
+}
+
+void ScCellObj::SetFormulaWithGrammar( const ::rtl::OUString& rFormula,
+ const ::rtl::OUString& rFormulaNmsp, const formula::FormulaGrammar::Grammar eGrammar )
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.SetCellText( aCellPos, rFormula, TRUE, TRUE, TRUE, rFormulaNmsp, eGrammar);
+ }
+}
+
+// XText
+
+uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScCellTextCursor( *this );
+}
+
+uno::Reference<text::XTextCursor> SAL_CALL ScCellObj::createTextCursorByRange(
+ const uno::Reference<text::XTextRange>& aTextPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SvxUnoTextCursor* pCursor = new ScCellTextCursor( *this );
+ uno::Reference<text::XTextCursor> xCursor(pCursor);
+
+ SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
+ if(pRange)
+ pCursor->SetSelection( pRange->GetSelection() );
+ else
+ {
+ ScCellTextCursor* pOther = ScCellTextCursor::getImplementation( aTextPosition );
+ if(pOther)
+ pCursor->SetSelection( pOther->GetSelection() );
+ else
+ throw uno::RuntimeException();
+ }
+
+ return xCursor;
+}
+
+rtl::OUString SAL_CALL ScCellObj::getString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetOutputString_Impl();
+}
+
+void SAL_CALL ScCellObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aText);
+ SetString_Impl(aString, FALSE, FALSE); // immer Text
+
+ // don't create pUnoText here if not there
+ if (pUnoText)
+ pUnoText->SetSelection(ESelection( 0,0, 0,aString.Len() ));
+}
+
+void SAL_CALL ScCellObj::insertString( const uno::Reference<text::XTextRange>& xRange,
+ const rtl::OUString& aString, sal_Bool bAbsorb )
+ throw(uno::RuntimeException)
+{
+ // special handling for ScCellTextCursor is no longer needed,
+ // SvxUnoText::insertString checks for SvxUnoTextRangeBase instead of SvxUnoTextRange
+
+ SolarMutexGuard aGuard;
+ GetUnoText().insertString(xRange, aString, bAbsorb);
+}
+
+void SAL_CALL ScCellObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().insertControlCharacter(xRange, nControlCharacter, bAbsorb);
+}
+
+void SAL_CALL ScCellObj::insertTextContent( const uno::Reference<text::XTextRange >& xRange,
+ const uno::Reference<text::XTextContent >& xContent,
+ sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh && xContent.is() )
+ {
+ ScCellFieldObj* pCellField = ScCellFieldObj::getImplementation( xContent );
+ SvxUnoTextRangeBase* pTextRange = ScCellTextCursor::getImplementation( xRange );
+
+ if ( pCellField && !pCellField->IsInserted() && pTextRange )
+ {
+ SvxEditSource* pEditSource = pTextRange->GetEditSource();
+ ESelection aSelection(pTextRange->GetSelection());
+
+ if (!bAbsorb)
+ {
+ // nicht ersetzen -> hinten anhaengen
+ aSelection.Adjust();
+ aSelection.nStartPara = aSelection.nEndPara;
+ aSelection.nStartPos = aSelection.nEndPos;
+ }
+
+ SvxFieldItem aItem(pCellField->CreateFieldItem());
+
+ SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+ pForwarder->QuickInsertField( aItem, aSelection );
+ pEditSource->UpdateData();
+
+ // neue Selektion: ein Zeichen
+ aSelection.Adjust();
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos + 1;
+ pCellField->InitDoc( pDocSh, aCellPos, aSelection );
+
+ // #91431# for bAbsorb=FALSE, the new selection must be behind the inserted content
+ // (the xml filter relies on this)
+ if (!bAbsorb)
+ aSelection.nStartPos = aSelection.nEndPos;
+
+ pTextRange->SetSelection( aSelection );
+
+ return;
+ }
+ }
+ GetUnoText().insertTextContent(xRange, xContent, bAbsorb);
+}
+
+void SAL_CALL ScCellObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
+ throw(container::NoSuchElementException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( xContent.is() )
+ {
+ ScCellFieldObj* pCellField = ScCellFieldObj::getImplementation( xContent );
+ if ( pCellField && pCellField->IsInserted() )
+ {
+ //! Testen, ob das Feld in dieser Zelle ist
+ pCellField->DeleteField();
+ return;
+ }
+ }
+ GetUnoText().removeTextContent(xContent);
+}
+
+uno::Reference<text::XText> SAL_CALL ScCellObj::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return this;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getStart();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellObj::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getEnd();
+}
+
+uno::Reference<container::XEnumeration> SAL_CALL ScCellObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().createEnumeration();
+}
+
+uno::Type SAL_CALL ScCellObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getElementType();
+}
+
+sal_Bool SAL_CALL ScCellObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().hasElements();
+}
+
+// XCell
+
+rtl::OUString SAL_CALL ScCellObj::getFormula() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // TRUE = englisch
+ return GetInputString_Impl(TRUE);
+}
+
+void SAL_CALL ScCellObj::setFormula( const rtl::OUString& aFormula ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aFormula);
+ SetString_Impl(aString, TRUE, TRUE); // englisch interpretieren
+}
+
+double SAL_CALL ScCellObj::getValue() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetValue_Impl();
+}
+
+void SAL_CALL ScCellObj::setValue( double nValue ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SetValue_Impl(nValue);
+}
+
+table::CellContentType SAL_CALL ScCellObj::getType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellContentType eRet = table::CellContentType_EMPTY;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ CellType eCalcType = pDocSh->GetDocument()->GetCellType( aCellPos );
+ switch (eCalcType)
+ {
+ case CELLTYPE_VALUE:
+ eRet = table::CellContentType_VALUE;
+ break;
+ case CELLTYPE_STRING:
+ case CELLTYPE_EDIT:
+ eRet = table::CellContentType_TEXT;
+ break;
+ case CELLTYPE_FORMULA:
+ eRet = table::CellContentType_FORMULA;
+ break;
+ default:
+ eRet = table::CellContentType_EMPTY;
+ }
+ }
+ else
+ {
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ }
+
+ return eRet;
+}
+
+table::CellContentType ScCellObj::GetResultType_Impl()
+{
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScBaseCell* pCell = pDocSh->GetDocument()->GetCell(aCellPos);
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ BOOL bValue = ((ScFormulaCell*)pCell)->IsValue();
+ return bValue ? table::CellContentType_VALUE : table::CellContentType_TEXT;
+ }
+ }
+ return getType(); // wenn keine Formel
+}
+
+sal_Int32 SAL_CALL ScCellObj::getError() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nError = 0;
+ ScDocShell* pDocSh = GetDocShell();
+ if (pDocSh)
+ {
+ ScBaseCell* pCell = pDocSh->GetDocument()->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ nError = ((ScFormulaCell*)pCell)->GetErrCode();
+ // sonst bleibt's bei 0
+ }
+ else
+ {
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ }
+
+ return nError;
+}
+
+// XFormulaTokens
+
+uno::Sequence<sheet::FormulaToken> SAL_CALL ScCellObj::getTokens() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence<sheet::FormulaToken> aSequence;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScBaseCell* pCell = pDoc->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ ScTokenArray* pTokenArray = static_cast<ScFormulaCell*>(pCell)->GetCode();
+ if ( pTokenArray )
+ (void)ScTokenConversion::ConvertToTokenSequence( *pDoc, aSequence, *pTokenArray );
+ }
+ }
+ return aSequence;
+}
+
+void SAL_CALL ScCellObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScTokenArray aTokenArray;
+ (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, rTokens );
+
+ ScDocFunc aFunc( *pDocSh );
+ ScBaseCell* pNewCell = new ScFormulaCell( pDoc, aCellPos, &aTokenArray );
+ (void)aFunc.PutCell( aCellPos, pNewCell, TRUE );
+ }
+}
+
+// XCellAddressable
+
+table::CellAddress SAL_CALL ScCellObj::getCellAddress() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellAddress aAdr;
+ aAdr.Sheet = aCellPos.Tab();
+ aAdr.Column = aCellPos.Col();
+ aAdr.Row = aCellPos.Row();
+ return aAdr;
+}
+
+// XSheetAnnotationAnchor
+
+uno::Reference<sheet::XSheetAnnotation> SAL_CALL ScCellObj::getAnnotation()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScAnnotationObj( pDocSh, aCellPos );
+
+ DBG_ERROR("getAnnotation ohne DocShell");
+ return NULL;
+}
+
+// XFieldTypesSupplier
+
+uno::Reference<container::XEnumerationAccess> SAL_CALL ScCellObj::getTextFields()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScCellFieldsObj( pDocSh, aCellPos );
+
+ return NULL;
+}
+
+uno::Reference<container::XNameAccess> SAL_CALL ScCellObj::getTextFieldMasters()
+ throw(uno::RuntimeException)
+{
+ // sowas gibts nicht im Calc (?)
+ return NULL;
+}
+
+// XPropertySet erweitert fuer Zell-Properties
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( pCellPropSet->getPropertyMap() ));
+ return aRef;
+}
+
+void ScCellObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
+ {
+ rtl::OUString aStrVal;
+ aValue >>= aStrVal;
+ String aString(aStrVal);
+ SetString_Impl(aString, TRUE, FALSE); // lokal interpretieren
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
+ {
+ // Read-Only
+ //! Exception oder so...
+ }
+ else
+ ScCellRangeObj::SetOnePropertyValue( pEntry, aValue );
+ }
+}
+
+void ScCellObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
+ uno::Any& rAny )
+ throw(uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( pEntry->nWID == SC_WID_UNO_FORMLOC )
+ {
+ // FALSE = lokal
+ rAny <<= rtl::OUString( GetInputString_Impl(FALSE) );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_FORMRT )
+ {
+ table::CellContentType eType = GetResultType_Impl();
+ rAny <<= eType;
+ }
+ else
+ ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
+ }
+}
+
+const SfxItemPropertyMap* ScCellObj::GetItemPropertyMap()
+{
+ return pCellPropSet->getPropertyMap();
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScCellObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScCellObj" );
+}
+
+sal_Bool SAL_CALL ScCellObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ // CellRange/SheetCellRange are not in SheetCell service description,
+ // but ScCellObj is used instead of ScCellRangeObj in CellRanges collections,
+ // so it must support them
+
+ String aServiceStr(rServiceName);
+ return aServiceStr.EqualsAscii( SCSHEETCELL_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELL_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCSHEETCELLRANGE_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLRANGE_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(7);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSHEETCELL_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCCELL_SERVICE );
+ pArray[2] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
+ pArray[3] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
+ pArray[4] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
+ pArray[5] = rtl::OUString::createFromAscii( SCSHEETCELLRANGE_SERVICE );
+ pArray[6] = rtl::OUString::createFromAscii( SCCELLRANGE_SERVICE );
+ return aRet;
+}
+
+// XActionLockable
+
+sal_Bool SAL_CALL ScCellObj::isActionLocked() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return nActionLockCount != 0;
+}
+
+void SAL_CALL ScCellObj::addActionLock() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!nActionLockCount)
+ {
+ if (pUnoText)
+ {
+ ScSharedCellEditSource* pEditSource =
+ static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
+ if (pEditSource)
+ pEditSource->SetDoUpdateData(sal_False);
+ }
+ }
+ nActionLockCount++;
+}
+
+void SAL_CALL ScCellObj::removeActionLock() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nActionLockCount > 0)
+ {
+ nActionLockCount--;
+ if (!nActionLockCount)
+ {
+ if (pUnoText)
+ {
+ ScSharedCellEditSource* pEditSource =
+ static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
+ if (pEditSource)
+ {
+ pEditSource->SetDoUpdateData(sal_True);
+ if (pEditSource->IsDirty())
+ pEditSource->UpdateData();
+ }
+ }
+ }
+ }
+}
+
+void SAL_CALL ScCellObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pUnoText)
+ {
+ ScSharedCellEditSource* pEditSource =
+ static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
+ if (pEditSource)
+ {
+ pEditSource->SetDoUpdateData(nLock == 0);
+ if ((nActionLockCount > 0) && (nLock == 0) && pEditSource->IsDirty())
+ pEditSource->UpdateData();
+ }
+ }
+ nActionLockCount = nLock;
+}
+
+sal_Int16 SAL_CALL ScCellObj::resetActionLocks() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nRet(nActionLockCount);
+ if (pUnoText)
+ {
+ ScSharedCellEditSource* pEditSource =
+ static_cast<ScSharedCellEditSource*> (pUnoText->GetEditSource());
+ if (pEditSource)
+ {
+ pEditSource->SetDoUpdateData(sal_True);
+ if (pEditSource->IsDirty())
+ pEditSource->UpdateData();
+ }
+ }
+ nActionLockCount = 0;
+ return nRet;
+}
+
+//------------------------------------------------------------------------
+
+ScTableSheetObj::ScTableSheetObj( ScDocShell* pDocSh, SCTAB nTab ) :
+ ScCellRangeObj( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) ),
+ pSheetPropSet(lcl_GetSheetPropertySet())
+{
+}
+
+ScTableSheetObj::~ScTableSheetObj()
+{
+}
+
+void ScTableSheetObj::InitInsertSheet(ScDocShell* pDocSh, SCTAB nTab)
+{
+ InitInsertRange( pDocSh, ScRange(0,0,nTab, MAXCOL,MAXROW,nTab) );
+}
+
+uno::Any SAL_CALL ScTableSheetObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XSpreadsheet )
+ SC_QUERYINTERFACE( container::XNamed )
+ SC_QUERYINTERFACE( sheet::XSheetPageBreak )
+ SC_QUERYINTERFACE( sheet::XCellRangeMovement )
+ SC_QUERYINTERFACE( table::XTableChartsSupplier )
+ SC_QUERYINTERFACE( sheet::XDataPilotTablesSupplier )
+ SC_QUERYINTERFACE( sheet::XScenariosSupplier )
+ SC_QUERYINTERFACE( sheet::XSheetAnnotationsSupplier )
+ SC_QUERYINTERFACE( drawing::XDrawPageSupplier )
+ SC_QUERYINTERFACE( sheet::XPrintAreas )
+ SC_QUERYINTERFACE( sheet::XSheetAuditing )
+ SC_QUERYINTERFACE( sheet::XSheetOutline )
+ SC_QUERYINTERFACE( util::XProtectable )
+ SC_QUERYINTERFACE( sheet::XScenario )
+ SC_QUERYINTERFACE( sheet::XScenarioEnhanced )
+ SC_QUERYINTERFACE( sheet::XSheetLinkable )
+ SC_QUERYINTERFACE( sheet::XExternalSheetName )
+ SC_QUERYINTERFACE( document::XEventsSupplier )
+
+ return ScCellRangeObj::queryInterface( rType );
+}
+
+void SAL_CALL ScTableSheetObj::acquire() throw()
+{
+ ScCellRangeObj::acquire();
+}
+
+void SAL_CALL ScTableSheetObj::release() throw()
+{
+ ScCellRangeObj::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScTableSheetObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes = ScCellRangeObj::getTypes();
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 18 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheet>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XNamed>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XSheetPageBreak>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<sheet::XCellRangeMovement>*)0);
+ pPtr[nParentLen + 4] = getCppuType((const uno::Reference<table::XTableChartsSupplier>*)0);
+ pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XDataPilotTablesSupplier>*)0);
+ pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XScenariosSupplier>*)0);
+ pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XSheetAnnotationsSupplier>*)0);
+ pPtr[nParentLen + 8] = getCppuType((const uno::Reference<drawing::XDrawPageSupplier>*)0);
+ pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XPrintAreas>*)0);
+ pPtr[nParentLen +10] = getCppuType((const uno::Reference<sheet::XSheetAuditing>*)0);
+ pPtr[nParentLen +11] = getCppuType((const uno::Reference<sheet::XSheetOutline>*)0);
+ pPtr[nParentLen +12] = getCppuType((const uno::Reference<util::XProtectable>*)0);
+ pPtr[nParentLen +13] = getCppuType((const uno::Reference<sheet::XScenario>*)0);
+ pPtr[nParentLen +14] = getCppuType((const uno::Reference<sheet::XScenarioEnhanced>*)0);
+ pPtr[nParentLen +15] = getCppuType((const uno::Reference<sheet::XSheetLinkable>*)0);
+ pPtr[nParentLen +16] = getCppuType((const uno::Reference<sheet::XExternalSheetName>*)0);
+ pPtr[nParentLen +17] = getCppuType((const uno::Reference<document::XEventsSupplier>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScTableSheetObj::getImplementationId() throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// Hilfsfunktionen
+
+SCTAB ScTableSheetObj::GetTab_Impl() const
+{
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT(rRanges.Count() == 1, "was fuer Ranges ?!?!");
+ const ScRange* pFirst = rRanges.GetObject(0);
+ if (pFirst)
+ return pFirst->aStart.Tab();
+
+ return 0; // soll nicht sein
+}
+
+// former XSheet
+
+uno::Reference<table::XTableCharts> SAL_CALL ScTableSheetObj::getCharts() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScChartsObj( pDocSh, GetTab_Impl() );
+
+ DBG_ERROR("kein Dokument");
+ return NULL;
+}
+
+uno::Reference<sheet::XDataPilotTables> SAL_CALL ScTableSheetObj::getDataPilotTables()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScDataPilotTablesObj( pDocSh, GetTab_Impl() );
+
+ DBG_ERROR("kein Dokument");
+ return NULL;
+}
+
+uno::Reference<sheet::XScenarios> SAL_CALL ScTableSheetObj::getScenarios() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+
+ if ( pDocSh )
+ return new ScScenariosObj( pDocSh, GetTab_Impl() );
+
+ DBG_ERROR("kein Dokument");
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetAnnotations> SAL_CALL ScTableSheetObj::getAnnotations()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+
+ if ( pDocSh )
+ return new ScAnnotationsObj( pDocSh, GetTab_Impl() );
+
+ DBG_ERROR("kein Dokument");
+ return NULL;
+}
+
+uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByName(
+ const rtl::OUString& rRange ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::getCellRangeByName( rRange );
+}
+
+uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ //! einzelne Zelle oder ganze Tabelle???????
+ SCTAB nTab = GetTab_Impl();
+ return new ScCellCursorObj( pDocSh, ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) );
+ }
+ return NULL;
+}
+
+uno::Reference<sheet::XSheetCellCursor> SAL_CALL ScTableSheetObj::createCursorByRange(
+ const uno::Reference<sheet::XSheetCellRange>& xCellRange )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh && xCellRange.is() )
+ {
+ ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xCellRange );
+ if (pRangesImp)
+ {
+ const ScRangeList& rRanges = pRangesImp->GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ return new ScCellCursorObj( pDocSh, *rRanges.GetObject(0) );
+ }
+ }
+ return NULL;
+}
+
+// XSheetCellRange
+
+uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTableSheetObj::getSpreadsheet()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return this; //!???
+}
+
+// XCellRange
+
+uno::Reference<table::XCell> SAL_CALL ScTableSheetObj::getCellByPosition(
+ sal_Int32 nColumn, sal_Int32 nRow )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::GetCellByPosition_Impl(nColumn, nRow);
+}
+
+uno::Reference<table::XCellRange> SAL_CALL ScTableSheetObj::getCellRangeByPosition(
+ sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
+}
+
+uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPageBreaks()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ Size aSize(pDoc->GetPageSize( nTab ));
+ if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
+ pDoc->UpdatePageBreaks( nTab );
+ else
+ {
+ // Umbrueche updaten wie in ScDocShell::PageStyleModified:
+ ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
+ aPrintFunc.UpdatePages();
+ }
+
+ SCCOL nCount = 0;
+ SCCOL nCol;
+ for (nCol=0; nCol<=MAXCOL; nCol++)
+ if (pDoc->HasColBreak(nCol, nTab))
+ ++nCount;
+
+ sheet::TablePageBreakData aData;
+ uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
+ sheet::TablePageBreakData* pAry = aSeq.getArray();
+ USHORT nPos = 0;
+ for (nCol=0; nCol<=MAXCOL; nCol++)
+ {
+ ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
+ if (nBreak)
+ {
+ aData.Position = nCol;
+ aData.ManualBreak = (nBreak & BREAK_MANUAL);
+ pAry[nPos] = aData;
+ ++nPos;
+ }
+ }
+ return aSeq;
+ }
+ return uno::Sequence<sheet::TablePageBreakData>(0);
+}
+
+uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBreaks()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ Size aSize(pDoc->GetPageSize( nTab ));
+ if (aSize.Width() && aSize.Height()) // effektive Groesse schon gesetzt?
+ pDoc->UpdatePageBreaks( nTab );
+ else
+ {
+ // Umbrueche updaten wie in ScDocShell::PageStyleModified:
+ ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
+ aPrintFunc.UpdatePages();
+ }
+ return pDoc->GetRowBreakData(nTab);
+ }
+ return uno::Sequence<sheet::TablePageBreakData>(0);
+}
+
+void SAL_CALL ScTableSheetObj::removeAllManualPageBreaks() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ //! docfunc Funktion, auch fuer ScViewFunc::RemoveManualBreaks
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+ SCTAB nTab = GetTab_Impl();
+
+ if (bUndo)
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
+ }
+
+ pDoc->RemoveManualBreaks(nTab);
+ pDoc->UpdatePageBreaks(nTab);
+
+ //? UpdatePageBreakData( TRUE );
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+ }
+}
+
+// XNamed
+
+rtl::OUString SAL_CALL ScTableSheetObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aName;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ pDocSh->GetDocument()->GetName( GetTab_Impl(), aName );
+ return aName;
+}
+
+void SAL_CALL ScTableSheetObj::setName( const rtl::OUString& aNewName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ String aString(aNewName);
+ ScDocFunc aFunc( *pDocSh );
+ aFunc.RenameTable( GetTab_Impl(), aString, TRUE, TRUE );
+ }
+}
+
+// XDrawPageSupplier
+
+uno::Reference<drawing::XDrawPage> SAL_CALL ScTableSheetObj::getDrawPage()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDrawLayer* pDrawLayer = pDocSh->MakeDrawLayer();
+ DBG_ASSERT(pDrawLayer,"kann Draw-Layer nicht anlegen");
+
+ SCTAB nTab = GetTab_Impl();
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage,"Draw-Page nicht gefunden");
+ if (pPage)
+ return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
+
+ // Das DrawPage-Objekt meldet sich als Listener am SdrModel an
+ // und sollte von dort alle Aktionen mitbekommen
+ }
+ return NULL;
+}
+
+// XCellMovement
+
+void SAL_CALL ScTableSheetObj::insertCells( const table::CellRangeAddress& rRangeAddress,
+ sheet::CellInsertMode nMode ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BOOL bDo = TRUE;
+ InsCellCmd eCmd = INS_NONE;
+ switch (nMode)
+ {
+ case sheet::CellInsertMode_NONE: bDo = FALSE; break;
+ case sheet::CellInsertMode_DOWN: eCmd = INS_CELLSDOWN; break;
+ case sheet::CellInsertMode_RIGHT: eCmd = INS_CELLSRIGHT; break;
+ case sheet::CellInsertMode_ROWS: eCmd = INS_INSROWS; break;
+ case sheet::CellInsertMode_COLUMNS: eCmd = INS_INSCOLS; break;
+ default:
+ DBG_ERROR("insertCells: falscher Mode");
+ bDo = FALSE;
+ }
+
+ if (bDo)
+ {
+ DBG_ASSERT( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
+ ScRange aScRange;
+ ScUnoConversion::FillScRange( aScRange, rRangeAddress );
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.InsertCells( aScRange, NULL, eCmd, TRUE, TRUE );
+ }
+ }
+}
+
+void SAL_CALL ScTableSheetObj::removeRange( const table::CellRangeAddress& rRangeAddress,
+ sheet::CellDeleteMode nMode ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BOOL bDo = TRUE;
+ DelCellCmd eCmd = DEL_NONE;
+ switch (nMode)
+ {
+ case sheet::CellDeleteMode_NONE: bDo = FALSE; break;
+ case sheet::CellDeleteMode_UP: eCmd = DEL_CELLSUP; break;
+ case sheet::CellDeleteMode_LEFT: eCmd = DEL_CELLSLEFT; break;
+ case sheet::CellDeleteMode_ROWS: eCmd = DEL_DELROWS; break;
+ case sheet::CellDeleteMode_COLUMNS: eCmd = DEL_DELCOLS; break;
+ default:
+ DBG_ERROR("deleteCells: falscher Mode");
+ bDo = FALSE;
+ }
+
+ if (bDo)
+ {
+ DBG_ASSERT( rRangeAddress.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
+ ScRange aScRange;
+ ScUnoConversion::FillScRange( aScRange, rRangeAddress );
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.DeleteCells( aScRange, NULL, eCmd, TRUE, TRUE );
+ }
+ }
+}
+
+void SAL_CALL ScTableSheetObj::moveRange( const table::CellAddress& aDestination,
+ const table::CellRangeAddress& aSource )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ DBG_ASSERT( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
+ ScRange aSourceRange;
+ ScUnoConversion::FillScRange( aSourceRange, aSource );
+ ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.MoveBlock( aSourceRange, aDestPos, TRUE, TRUE, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::copyRange( const table::CellAddress& aDestination,
+ const table::CellRangeAddress& aSource )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ DBG_ASSERT( aSource.Sheet == GetTab_Impl(), "falsche Tabelle in CellRangeAddress" );
+ ScRange aSourceRange;
+ ScUnoConversion::FillScRange( aSourceRange, aSource );
+ ScAddress aDestPos( (SCCOL)aDestination.Column, (SCROW)aDestination.Row, aDestination.Sheet );
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.MoveBlock( aSourceRange, aDestPos, FALSE, TRUE, TRUE, TRUE );
+ }
+}
+
+// XPrintAreas
+
+void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
+{
+ // Umbrueche und Undo
+
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ SCTAB nTab = GetTab_Impl();
+
+ ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoPrintRange( pDocSh, nTab, pOldRanges, pNewRanges ) );
+ }
+
+ ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
+
+ SfxBindings* pBindings = pDocSh->GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_DELETE_PRINTAREA );
+
+ pDocSh->SetDocumentModified();
+ }
+ else
+ delete pOldRanges;
+}
+
+uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ USHORT nCount = pDoc->GetPrintRangeCount( nTab );
+
+ table::CellRangeAddress aRangeAddress;
+ uno::Sequence<table::CellRangeAddress> aSeq(nCount);
+ table::CellRangeAddress* pAry = aSeq.getArray();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ const ScRange* pRange = pDoc->GetPrintRange( nTab, i );
+ DBG_ASSERT(pRange,"wo ist der Druckbereich");
+ if (pRange)
+ {
+ ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
+ aRangeAddress.Sheet = nTab; // core does not care about sheet index
+ pAry[i] = aRangeAddress;
+ }
+ }
+ return aSeq;
+ }
+ return uno::Sequence<table::CellRangeAddress>();
+}
+
+void SAL_CALL ScTableSheetObj::setPrintAreas(
+ const uno::Sequence<table::CellRangeAddress>& aPrintAreas )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+
+ USHORT nCount = (USHORT) aPrintAreas.getLength();
+ pDoc->ClearPrintRanges( nTab );
+ if (nCount)
+ {
+ ScRange aPrintRange;
+ const table::CellRangeAddress* pAry = aPrintAreas.getConstArray();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScUnoConversion::FillScRange( aPrintRange, pAry[i] );
+ pDoc->AddPrintRange( nTab, aPrintRange );
+ }
+ }
+
+ PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
+ }
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleColumns() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ return ( pDoc->GetRepeatColRange(nTab) != NULL );
+ }
+ return FALSE;
+}
+
+void SAL_CALL ScTableSheetObj::setPrintTitleColumns( sal_Bool bPrintTitleColumns )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+
+ if ( bPrintTitleColumns )
+ {
+ if ( !pDoc->GetRepeatColRange( nTab ) ) // keinen bestehenden Bereich veraendern
+ {
+ ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
+ pDoc->SetRepeatColRange( nTab, &aNew ); // einschalten
+ }
+ }
+ else
+ pDoc->SetRepeatColRange( nTab, NULL ); // abschalten
+
+ PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
+
+ //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
+ }
+}
+
+table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleColumns() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aRet;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ const ScRange* pRange = pDoc->GetRepeatColRange(nTab);
+ if (pRange)
+ {
+ ScUnoConversion::FillApiRange( aRet, *pRange );
+ aRet.Sheet = nTab; // core does not care about sheet index
+ }
+ }
+ return aRet;
+}
+
+void SAL_CALL ScTableSheetObj::setTitleColumns( const table::CellRangeAddress& aTitleColumns )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+
+ ScRange aNew;
+ ScUnoConversion::FillScRange( aNew, aTitleColumns );
+ pDoc->SetRepeatColRange( nTab, &aNew ); // immer auch einschalten
+
+ PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
+ }
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::getPrintTitleRows() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ return ( pDoc->GetRepeatRowRange(nTab) != NULL );
+ }
+ return FALSE;
+}
+
+void SAL_CALL ScTableSheetObj::setPrintTitleRows( sal_Bool bPrintTitleRows )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+
+ if ( bPrintTitleRows )
+ {
+ if ( !pDoc->GetRepeatRowRange( nTab ) ) // keinen bestehenden Bereich veraendern
+ {
+ ScRange aNew( 0, 0, nTab, 0, 0, nTab ); // Default
+ pDoc->SetRepeatRowRange( nTab, &aNew ); // einschalten
+ }
+ }
+ else
+ pDoc->SetRepeatRowRange( nTab, NULL ); // abschalten
+
+ PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
+
+ //! zuletzt gesetzten Bereich beim Abschalten merken und beim Einschalten wiederherstellen ???
+ }
+}
+
+table::CellRangeAddress SAL_CALL ScTableSheetObj::getTitleRows() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aRet;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ const ScRange* pRange = pDoc->GetRepeatRowRange(nTab);
+ if (pRange)
+ {
+ ScUnoConversion::FillApiRange( aRet, *pRange );
+ aRet.Sheet = nTab; // core does not care about sheet index
+ }
+ }
+ return aRet;
+}
+
+void SAL_CALL ScTableSheetObj::setTitleRows( const table::CellRangeAddress& aTitleRows )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+
+ ScRange aNew;
+ ScUnoConversion::FillScRange( aNew, aTitleRows );
+ pDoc->SetRepeatRowRange( nTab, &aNew ); // immer auch einschalten
+
+ PrintAreaUndo_Impl( pOldRanges ); // Undo, Umbrueche, Modified etc.
+ }
+}
+
+// XSheetLinkable
+
+sheet::SheetLinkMode SAL_CALL ScTableSheetObj::getLinkMode() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sheet::SheetLinkMode eRet = sheet::SheetLinkMode_NONE;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BYTE nMode = pDocSh->GetDocument()->GetLinkMode( GetTab_Impl() );
+ if ( nMode == SC_LINK_NORMAL )
+ eRet = sheet::SheetLinkMode_NORMAL;
+ else if ( nMode == SC_LINK_VALUE )
+ eRet = sheet::SheetLinkMode_VALUE;
+ }
+ return eRet;
+}
+
+void SAL_CALL ScTableSheetObj::setLinkMode( sheet::SheetLinkMode nLinkMode )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! Filter und Options aus altem Link suchen
+
+ rtl::OUString aUrl(getLinkUrl());
+ rtl::OUString aSheet(getLinkSheetName());
+
+ rtl::OUString aEmpty;
+ link( aUrl, aSheet, aEmpty, aEmpty, nLinkMode );
+}
+
+rtl::OUString SAL_CALL ScTableSheetObj::getLinkUrl() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aFile;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ aFile = pDocSh->GetDocument()->GetLinkDoc( GetTab_Impl() );
+ return aFile;
+}
+
+void SAL_CALL ScTableSheetObj::setLinkUrl( const rtl::OUString& aLinkUrl )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! Filter und Options aus altem Link suchen
+
+ sheet::SheetLinkMode eMode = getLinkMode();
+ rtl::OUString aSheet(getLinkSheetName());
+
+ rtl::OUString aEmpty;
+ link( aLinkUrl, aSheet, aEmpty, aEmpty, eMode );
+}
+
+rtl::OUString SAL_CALL ScTableSheetObj::getLinkSheetName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aSheet;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ aSheet = pDocSh->GetDocument()->GetLinkTab( GetTab_Impl() );
+ return aSheet;
+}
+
+void SAL_CALL ScTableSheetObj::setLinkSheetName( const rtl::OUString& aLinkSheetName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! Filter und Options aus altem Link suchen
+
+ sheet::SheetLinkMode eMode = getLinkMode();
+ rtl::OUString aUrl(getLinkUrl());
+
+ rtl::OUString aEmpty;
+ link( aUrl, aLinkSheetName, aEmpty, aEmpty, eMode );
+}
+
+void SAL_CALL ScTableSheetObj::link( const rtl::OUString& aUrl, const rtl::OUString& aSheetName,
+ const rtl::OUString& aFilterName, const rtl::OUString& aFilterOptions,
+ sheet::SheetLinkMode nMode ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ String aFileString (aUrl);
+ String aFilterString (aFilterName);
+ String aOptString (aFilterOptions);
+ String aSheetString (aSheetName);
+
+ aFileString = ScGlobal::GetAbsDocName( aFileString, pDocSh );
+ if ( !aFilterString.Len() )
+ ScDocumentLoader::GetFilterName( aFileString, aFilterString, aOptString, TRUE, FALSE );
+
+ // remove application prefix from filter name here, so the filter options
+ // aren't reset when the filter name is changed in ScTableLink::DataChanged
+ ScDocumentLoader::RemoveAppPrefix( aFilterString );
+
+ BYTE nLinkMode = SC_LINK_NONE;
+ if ( nMode == sheet::SheetLinkMode_NORMAL )
+ nLinkMode = SC_LINK_NORMAL;
+ else if ( nMode == sheet::SheetLinkMode_VALUE )
+ nLinkMode = SC_LINK_VALUE;
+
+ ULONG nRefresh = 0;
+ pDoc->SetLink( nTab, nLinkMode, aFileString, aFilterString, aOptString, aSheetString, nRefresh );
+
+ pDocSh->UpdateLinks(); // ggf. Link eintragen oder loeschen
+ SfxBindings* pBindings = pDocSh->GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate(SID_LINKS);
+
+ //! Undo fuer Link-Daten an der Table
+
+ if ( nLinkMode != SC_LINK_NONE && pDoc->IsExecuteLinkEnabled() ) // Link updaten
+ {
+ // Update immer, auch wenn der Link schon da war
+ //! Update nur fuer die betroffene Tabelle???
+
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+ USHORT nCount = pLinkManager->GetLinks().Count();
+ for ( USHORT i=0; i<nCount; i++ )
+ {
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
+ if (pBase->ISA(ScTableLink))
+ {
+ ScTableLink* pTabLink = (ScTableLink*)pBase;
+ if ( pTabLink->GetFileName() == aFileString )
+ pTabLink->Update(); // inkl. Paint&Undo
+
+ //! Der Dateiname sollte nur einmal vorkommen (?)
+ }
+ }
+ }
+
+ //! Notify fuer ScSheetLinkObj Objekte!!!
+ }
+}
+
+// XSheetAuditing
+
+sal_Bool SAL_CALL ScTableSheetObj::hideDependents( const table::CellAddress& aPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCTAB nTab = GetTab_Impl();
+ DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
+ ScDocFunc aFunc(*pDocSh);
+ return aFunc.DetectiveDelSucc( aPos );
+ }
+ return FALSE;
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::hidePrecedents( const table::CellAddress& aPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCTAB nTab = GetTab_Impl();
+ DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
+ ScDocFunc aFunc(*pDocSh);
+ return aFunc.DetectiveDelPred( aPos );
+ }
+ return FALSE;
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::showDependents( const table::CellAddress& aPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCTAB nTab = GetTab_Impl();
+ DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
+ ScDocFunc aFunc(*pDocSh);
+ return aFunc.DetectiveAddSucc( aPos );
+ }
+ return FALSE;
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::showPrecedents( const table::CellAddress& aPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCTAB nTab = GetTab_Impl();
+ DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
+ ScDocFunc aFunc(*pDocSh);
+ return aFunc.DetectiveAddPred( aPos );
+ }
+ return FALSE;
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::showErrors( const table::CellAddress& aPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCTAB nTab = GetTab_Impl();
+ DBG_ASSERT( aPosition.Sheet == nTab, "falsche Tabelle in CellAddress" );
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
+ ScDocFunc aFunc(*pDocSh);
+ return aFunc.DetectiveAddError( aPos );
+ }
+ return FALSE;
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::showInvalid() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ return aFunc.DetectiveMarkInvalid( GetTab_Impl() );
+ }
+ return FALSE;
+}
+
+void SAL_CALL ScTableSheetObj::clearArrows() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.DetectiveDelAll( GetTab_Impl() );
+ }
+}
+
+// XSheetOutline
+
+void SAL_CALL ScTableSheetObj::group( const table::CellRangeAddress& rGroupRange,
+ table::TableOrientation nOrientation )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BOOL bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
+ ScRange aGroupRange;
+ ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.MakeOutline( aGroupRange, bColumns, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::ungroup( const table::CellRangeAddress& rGroupRange,
+ table::TableOrientation nOrientation )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BOOL bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
+ ScRange aGroupRange;
+ ScUnoConversion::FillScRange( aGroupRange, rGroupRange );
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.RemoveOutline( aGroupRange, bColumns, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::autoOutline( const table::CellRangeAddress& rCellRange )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScRange aFormulaRange;
+ ScUnoConversion::FillScRange( aFormulaRange, rCellRange );
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.AutoOutline( aFormulaRange, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::clearOutline() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCTAB nTab = GetTab_Impl();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.RemoveAllOutlines( nTab, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::hideDetail( const table::CellRangeAddress& rCellRange )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScRange aMarkRange;
+ ScUnoConversion::FillScRange( aMarkRange, rCellRange );
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.HideMarkedOutlines( aMarkRange, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::showDetail( const table::CellRangeAddress& rCellRange )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScRange aMarkRange;
+ ScUnoConversion::FillScRange( aMarkRange, rCellRange );
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.ShowMarkedOutlines( aMarkRange, TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::showLevel( sal_Int16 nLevel, table::TableOrientation nOrientation )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ BOOL bColumns = ( nOrientation == table::TableOrientation_COLUMNS );
+ SCTAB nTab = GetTab_Impl();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.SelectLevel( nTab, bColumns, nLevel, TRUE, TRUE, TRUE );
+ }
+}
+
+// XProtectable
+
+void SAL_CALL ScTableSheetObj::protect( const rtl::OUString& aPassword )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ // #i108245# if already protected, don't change anything
+ if ( pDocSh && !pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() ) )
+ {
+ String aString(aPassword);
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.Protect( GetTab_Impl(), aString, TRUE );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::unprotect( const rtl::OUString& aPassword )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ String aString(aPassword);
+ ScDocFunc aFunc(*pDocSh);
+ BOOL bDone = aFunc.Unprotect( GetTab_Impl(), aString, TRUE );
+ if (!bDone)
+ throw lang::IllegalArgumentException();
+ }
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::isProtected() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return pDocSh->GetDocument()->IsTabProtected( GetTab_Impl() );
+
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ return FALSE;
+}
+
+// XScenario
+
+sal_Bool SAL_CALL ScTableSheetObj::getIsScenario() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return pDocSh->GetDocument()->IsScenario( GetTab_Impl() );
+
+ return FALSE;
+}
+
+rtl::OUString SAL_CALL ScTableSheetObj::getScenarioComment() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDocSh->GetDocument()->GetScenarioData( GetTab_Impl(), aComment, aColor, nFlags );
+ return aComment;
+ }
+ return rtl::OUString();
+}
+
+void SAL_CALL ScTableSheetObj::setScenarioComment( const rtl::OUString& aScenarioComment )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ aComment = String( aScenarioComment );
+
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+}
+
+void SAL_CALL ScTableSheetObj::addRanges( const uno::Sequence<table::CellRangeAddress>& rScenRanges )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ if (pDoc->IsScenario(nTab))
+ {
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( nTab, TRUE );
+
+ USHORT nRangeCount = (USHORT)rScenRanges.getLength();
+ if (nRangeCount)
+ {
+ const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ DBG_ASSERT( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
+ ScRange aOneRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
+ (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
+
+ aMarkData.SetMultiMarkArea( aOneRange );
+ }
+ }
+
+ // Szenario-Ranges sind durch Attribut gekennzeichnet
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
+ aPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) );
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.ApplyAttributes( aMarkData, aPattern, TRUE, TRUE );
+ }
+
+ // don't use. We should use therefor a private interface, so we can also set the flags.
+/* else if (nTab > 0 && pDoc->IsImportingXML()) // make this sheet as an scenario and only if it is not the first sheet and only if it is ImportingXML,
+ // because than no UNDO and repaint is necessary.
+ {
+ USHORT nRangeCount = (USHORT)rScenRanges.getLength();
+ if (nRangeCount)
+ {
+ pDoc->SetScenario( nTab, TRUE );
+
+ // default flags
+ Color aColor( COL_LIGHTGRAY ); // Default
+ USHORT nFlags = SC_SCENARIO_SHOWFRAME | SC_SCENARIO_PRINTFRAME | SC_SCENARIO_TWOWAY;
+ String aComment;
+
+ pDoc->SetScenarioData( nTab, aComment, aColor, nFlags );
+ const table::CellRangeAddress* pAry = rScenRanges.getConstArray();
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ DBG_ASSERT( pAry[i].Sheet == nTab, "addRanges mit falscher Tab" );
+ pDoc->ApplyFlagsTab( (USHORT)pAry[i].StartColumn, (USHORT)pAry[i].StartRow,
+ (USHORT)pAry[i].EndColumn, (USHORT)pAry[i].EndRow, nTab, SC_MF_SCENARIO );
+ }
+ pDoc->SetActiveScenario( nTab, TRUE );
+
+ // set to next visible tab
+ USHORT j = nTab - 1;
+ BOOL bFinished = FALSE;
+ while (j < nTab && !bFinished)
+ {
+ if (pDoc->IsVisible(j))
+ {
+ pDoc->SetVisibleTab(j);
+ bFinished = TRUE;
+ }
+ else
+ --j;
+ }
+
+ ScDocFunc aFunc(*pDocSh);
+ aFunc.SetTableVisible( nTab, FALSE, TRUE );
+ }
+ }*/
+ }
+}
+
+void SAL_CALL ScTableSheetObj::apply() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ String aName;
+ pDoc->GetName( nTab, aName ); // Name dieses Szenarios
+
+ SCTAB nDestTab = nTab;
+ while ( nDestTab > 0 && pDoc->IsScenario(nDestTab) )
+ --nDestTab;
+
+ if ( !pDoc->IsScenario(nDestTab) )
+ pDocSh->UseScenario( nDestTab, aName );
+
+ //! sonst Fehler oder so
+ }
+}
+
+// XScenarioEnhanced
+
+uno::Sequence< table::CellRangeAddress > SAL_CALL ScTableSheetObj::getRanges( )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ const ScRangeList* pRangeList = pDoc->GetScenarioRanges(nTab);
+ if (pRangeList)
+ {
+ sal_Int32 nCount = pRangeList->Count();
+ uno::Sequence< table::CellRangeAddress > aRetRanges(nCount);
+ table::CellRangeAddress* pAry = aRetRanges.getArray();
+ for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ const ScRange* pRange = pRangeList->GetObject( nIndex );
+ pAry->StartColumn = pRange->aStart.Col();
+ pAry->StartRow = pRange->aStart.Row();
+ pAry->EndColumn = pRange->aEnd.Col();
+ pAry->EndRow = pRange->aEnd.Row();
+ pAry->Sheet = pRange->aStart.Tab();
+ ++pAry;
+ }
+ return aRetRanges;
+ }
+ }
+ return uno::Sequence< table::CellRangeAddress > ();
+}
+
+// XExternalSheetName
+
+void ScTableSheetObj::setExternalName( const ::rtl::OUString& aUrl, const ::rtl::OUString& aSheetName )
+ throw (container::ElementExistException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ if ( pDoc )
+ {
+ const SCTAB nTab = GetTab_Impl();
+ const String aAbsDocName( ScGlobal::GetAbsDocName( aUrl, pDocSh ) );
+ const String aDocTabName( ScGlobal::GetDocTabName( aAbsDocName, aSheetName ) );
+ if ( !pDoc->RenameTab( nTab, aDocTabName, FALSE /*bUpdateRef*/, TRUE /*bExternalDocument*/ ) )
+ {
+ throw container::ElementExistException( ::rtl::OUString(), *this );
+ }
+ }
+ }
+}
+
+// XEventsSupplier
+
+uno::Reference<container::XNameReplace> SAL_CALL ScTableSheetObj::getEvents() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ return new ScSheetEventsObj( pDocSh, GetTab_Impl() );
+
+ return NULL;
+}
+
+// XPropertySet erweitert fuer Sheet-Properties
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableSheetObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( pSheetPropSet->getPropertyMap() ));
+ return aRef;
+}
+
+void ScTableSheetObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ // for Item WIDs, call ScCellRangesBase directly
+ ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
+ return;
+ }
+
+ // own properties
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ return; //! Exception oder so?
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+ ScDocFunc aFunc(*pDocSh);
+
+ if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
+ {
+ rtl::OUString aStrVal;
+ aValue >>= aStrVal;
+ String aNewStr(ScStyleNameConversion::ProgrammaticToDisplayName(
+ aStrVal, SFX_STYLE_FAMILY_PAGE ));
+
+ //! Undo? (auch bei SID_STYLE_APPLY an der View)
+
+ if ( pDoc->GetPageStyle( nTab ) != aNewStr )
+ {
+ pDoc->SetPageStyle( nTab, aNewStr );
+ if (!pDoc->IsImportingXML())
+ {
+ ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
+
+ SfxBindings* pBindings = pDocSh->GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( SID_STYLE_FAMILY4 );
+ pBindings->Invalidate( SID_STATUS_PAGESTYLE );
+ pBindings->Invalidate( FID_RESET_PRINTZOOM );
+ pBindings->Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ pBindings->Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ }
+ pDocSh->SetDocumentModified();
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
+ {
+ BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ aFunc.SetTableVisible( nTab, bVis, TRUE );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
+ {
+ if (pDoc->IsScenario(nTab))
+ pDoc->SetActiveScenario( nTab, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ sal_Int32 nNewColor = 0;
+ if (aValue >>= nNewColor)
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ aColor = Color(static_cast<sal_uInt32>(nNewColor));
+
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+ sal_Bool bModify(sal_False);
+
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ if (!(nFlags & SC_SCENARIO_PROTECT))
+ {
+ nFlags |= SC_SCENARIO_PROTECT;
+ bModify = sal_True;
+ }
+ }
+ else
+ {
+ if (nFlags & SC_SCENARIO_PROTECT)
+ {
+ nFlags -= SC_SCENARIO_PROTECT;
+ bModify = sal_True;
+ }
+ }
+
+ if (bModify)
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+ sal_Bool bModify(sal_False);
+
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ if (!(nFlags & SC_SCENARIO_SHOWFRAME))
+ {
+ nFlags |= SC_SCENARIO_SHOWFRAME;
+ bModify = sal_True;
+ }
+ }
+ else
+ {
+ if (nFlags & SC_SCENARIO_SHOWFRAME)
+ {
+ nFlags -= SC_SCENARIO_SHOWFRAME;
+ bModify = sal_True;
+ }
+ }
+
+ if (bModify)
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+ sal_Bool bModify(sal_False);
+
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ if (!(nFlags & SC_SCENARIO_PRINTFRAME))
+ {
+ nFlags |= SC_SCENARIO_PRINTFRAME;
+ bModify = sal_True;
+ }
+ }
+ else
+ {
+ if (nFlags & SC_SCENARIO_PRINTFRAME)
+ {
+ nFlags -= SC_SCENARIO_PRINTFRAME;
+ bModify = sal_True;
+ }
+ }
+
+ if (bModify)
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+ sal_Bool bModify(sal_False);
+
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ if (!(nFlags & SC_SCENARIO_TWOWAY))
+ {
+ nFlags |= SC_SCENARIO_TWOWAY;
+ bModify = sal_True;
+ }
+ }
+ else
+ {
+ if (nFlags & SC_SCENARIO_TWOWAY)
+ {
+ nFlags -= SC_SCENARIO_TWOWAY;
+ bModify = sal_True;
+ }
+ }
+
+ if (bModify)
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+ sal_Bool bModify(sal_False);
+
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ if (!(nFlags & SC_SCENARIO_ATTRIB))
+ {
+ nFlags |= SC_SCENARIO_ATTRIB;
+ bModify = sal_True;
+ }
+ }
+ else
+ {
+ if (nFlags & SC_SCENARIO_ATTRIB)
+ {
+ nFlags -= SC_SCENARIO_ATTRIB;
+ bModify = sal_True;
+ }
+ }
+
+ if (bModify)
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetName( nTab, aName );
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+ sal_Bool bModify(sal_False);
+
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ if (nFlags & SC_SCENARIO_VALUE)
+ {
+ nFlags -= SC_SCENARIO_VALUE;
+ bModify = sal_True;
+ }
+ }
+ else
+ {
+ if (!(nFlags & SC_SCENARIO_VALUE))
+ {
+ nFlags |= SC_SCENARIO_VALUE;
+ bModify = sal_True;
+ }
+ }
+
+ if (bModify)
+ pDocSh->ModifyScenario( nTab, aName, aComment, aColor, nFlags );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
+ {
+ sal_Int16 nValue = 0;
+ if (aValue >>= nValue)
+ {
+ if (nValue == com::sun::star::text::WritingMode2::RL_TB)
+ aFunc.SetLayoutRTL(nTab, sal_True, sal_True);
+ else
+ aFunc.SetLayoutRTL(nTab, sal_False, sal_True);
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
+ {
+ BOOL bAutoPrint = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bAutoPrint)
+ pDoc->SetPrintEntireSheet( nTab ); // clears all print ranges
+ else
+ {
+ if (pDoc->IsPrintEntireSheet( nTab ))
+ pDoc->ClearPrintRanges( nTab ); // if this flag is true, there are no PrintRanges, so Clear clears only the flag.
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
+ {
+ sal_Int32 nColor = COL_AUTO;
+ if (aValue >>= nColor)
+ {
+ if (static_cast<ColorData>(nColor) != COL_AUTO)
+ pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor)));
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
+ {
+ rtl::OUString aCodeName;
+ if ( pDocSh && ( aValue >>= aCodeName ) )
+ {
+ String sNewName( aCodeName );
+ pDocSh->GetDocument()->SetCodeName( GetTab_Impl(), sNewName );
+ }
+ }
+ else
+ ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
+ }
+}
+
+void ScTableSheetObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
+ uno::Any& rAny )
+ throw(uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ throw uno::RuntimeException();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetTab_Impl();
+
+ if ( pEntry->nWID == SC_WID_UNO_PAGESTL )
+ {
+ rAny <<= rtl::OUString( ScStyleNameConversion::DisplayToProgrammaticName(
+ pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE ) );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
+ {
+ BOOL bVis = pDoc->IsVisible( nTab );
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_LINKDISPBIT )
+ {
+ // no target bitmaps for individual entries (would be all equal)
+ // ScLinkTargetTypeObj::SetLinkTargetBitmap( aAny, SC_LINKTARGETTYPE_SHEET );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_LINKDISPNAME )
+ {
+ // LinkDisplayName for hyperlink dialog
+ rAny <<= getName(); // sheet name
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_ISACTIVE )
+ {
+ if (pDoc->IsScenario(nTab))
+ ScUnoHelpFunctions::SetBoolInAny( rAny, pDoc->IsActiveScenario( nTab ));
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_BORDCOL )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ rAny <<= static_cast<sal_Int32>(aColor.GetColor());
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_PROTECT )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PROTECT) != 0 );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_SHOWBORD )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_SHOWFRAME) != 0 );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_PRINTBORD )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_PRINTFRAME) != 0 );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_COPYBACK )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_TWOWAY) != 0 );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_COPYSTYL )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ ScUnoHelpFunctions::SetBoolInAny( rAny, (nFlags & SC_SCENARIO_ATTRIB) != 0 );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_COPYFORM )
+ {
+ if (pDoc->IsScenario(nTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nFlags );
+
+ ScUnoHelpFunctions::SetBoolInAny( rAny, !(nFlags & SC_SCENARIO_VALUE));
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_TABLAYOUT )
+ {
+ if (pDoc->IsLayoutRTL(nTab))
+ rAny <<= sal_Int16(com::sun::star::text::WritingMode2::RL_TB);
+ else
+ rAny <<= sal_Int16(com::sun::star::text::WritingMode2::LR_TB);
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_AUTOPRINT )
+ {
+ BOOL bAutoPrint = pDoc->IsPrintEntireSheet( nTab );
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bAutoPrint );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_TABCOLOR )
+ {
+ rAny <<= sal_Int32(pDoc->GetTabBgColor(nTab).GetColor());
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CODENAME )
+ {
+ String aCodeName;
+ if ( pDocSh )
+ pDocSh->GetDocument()->GetCodeName( GetTab_Impl(), aCodeName );
+ rAny <<= rtl::OUString( aCodeName );
+ }
+ else
+ ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
+ }
+}
+
+const SfxItemPropertyMap* ScTableSheetObj::GetItemPropertyMap()
+{
+ return pSheetPropSet->getPropertyMap();
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScTableSheetObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScTableSheetObj" );
+}
+
+sal_Bool SAL_CALL ScTableSheetObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCSPREADSHEET_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCSHEETCELLRANGE_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLRANGE_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCHARPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCPARAPROPERTIES_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCLINKTARGET_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScTableSheetObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(7);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSPREADSHEET_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCSHEETCELLRANGE_SERVICE );
+ pArray[2] = rtl::OUString::createFromAscii( SCCELLRANGE_SERVICE );
+ pArray[3] = rtl::OUString::createFromAscii( SCCELLPROPERTIES_SERVICE );
+ pArray[4] = rtl::OUString::createFromAscii( SCCHARPROPERTIES_SERVICE );
+ pArray[5] = rtl::OUString::createFromAscii( SCPARAPROPERTIES_SERVICE );
+ pArray[6] = rtl::OUString::createFromAscii( SCLINKTARGET_SERVICE );
+ return aRet;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScTableSheetObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+
+ return ScCellRangeObj::getSomething( rId );
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScTableSheetObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScTableSheetObj* ScTableSheetObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScTableSheetObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScTableSheetObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScTableColumnObj::ScTableColumnObj( ScDocShell* pDocSh, SCCOL nCol, SCTAB nTab ) :
+ ScCellRangeObj( pDocSh, ScRange(nCol,0,nTab, nCol,MAXROW,nTab) ),
+ pColPropSet(lcl_GetColumnPropertySet())
+{
+}
+
+ScTableColumnObj::~ScTableColumnObj()
+{
+}
+
+uno::Any SAL_CALL ScTableColumnObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( container::XNamed )
+
+ return ScCellRangeObj::queryInterface( rType );
+}
+
+void SAL_CALL ScTableColumnObj::acquire() throw()
+{
+ ScCellRangeObj::acquire();
+}
+
+void SAL_CALL ScTableColumnObj::release() throw()
+{
+ ScCellRangeObj::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScTableColumnObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 1 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<container::XNamed>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScTableColumnObj::getImplementationId() throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XNamed
+
+rtl::OUString SAL_CALL ScTableColumnObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const ScRange& rRange = GetRange();
+ DBG_ASSERT(rRange.aStart.Col() == rRange.aEnd.Col(), "too many columns");
+ SCCOL nCol = rRange.aStart.Col();
+
+ return ScColToAlpha( nCol ); // from global.hxx
+}
+
+void SAL_CALL ScTableColumnObj::setName( const rtl::OUString& /* aNewName */ )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ throw uno::RuntimeException(); // read-only
+}
+
+// XPropertySet erweitert fuer Spalten-Properties
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( pColPropSet->getPropertyMap() ));
+ return aRef;
+}
+
+void ScTableColumnObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ // for Item WIDs, call ScCellRangesBase directly
+ ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
+ return;
+ }
+
+ // own properties
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ return; //! Exception oder so?
+ const ScRange& rRange = GetRange();
+ DBG_ASSERT(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
+ SCCOL nCol = rRange.aStart.Col();
+ SCTAB nTab = rRange.aStart.Tab();
+ ScDocFunc aFunc(*pDocSh);
+
+ SCCOLROW nColArr[2];
+ nColArr[0] = nColArr[1] = nCol;
+
+ if ( pEntry->nWID == SC_WID_UNO_CELLWID )
+ {
+ sal_Int32 nNewWidth = 0;
+ if ( aValue >>= nNewWidth )
+ {
+ // property is 1/100mm, column width is twips
+ nNewWidth = HMMToTwips(nNewWidth);
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
+ (USHORT)nNewWidth, TRUE, TRUE );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
+ {
+ BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab, eMode, 0, TRUE, TRUE );
+ // SC_SIZE_DIRECT mit Groesse 0 blendet aus
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
+ {
+ BOOL bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bOpt)
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab,
+ SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, TRUE, TRUE );
+ // FALSE bei Spalten momentan ohne Auswirkung
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
+ {
+ BOOL bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bSet)
+ aFunc.InsertPageBreak( TRUE, rRange.aStart, TRUE, TRUE, TRUE );
+ else
+ aFunc.RemovePageBreak( TRUE, rRange.aStart, TRUE, TRUE, TRUE );
+ }
+ else
+ ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
+ }
+}
+
+void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
+ uno::Any& rAny )
+ throw(uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ throw uno::RuntimeException();
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ const ScRange& rRange = GetRange();
+ DBG_ASSERT(rRange.aStart.Col() == rRange.aEnd.Col(), "zuviele Spalten");
+ SCCOL nCol = rRange.aStart.Col();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ if ( pEntry->nWID == SC_WID_UNO_CELLWID )
+ {
+ // for hidden column, return original height
+ USHORT nWidth = pDoc->GetOriginalWidth( nCol, nTab );
+ // property is 1/100mm, column width is twips
+ nWidth = (USHORT) TwipsToHMM(nWidth);
+ rAny <<= (sal_Int32)( nWidth );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
+ {
+ SCCOL nDummy;
+ bool bHidden = pDoc->ColHidden(nCol, nTab, nDummy);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
+ {
+ //! momentan immer gesetzt ??!?!
+ BOOL bOpt = !(pDoc->GetColFlags( nCol, nTab ) & CR_MANUALSIZE);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
+ {
+ ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
+ {
+ ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
+ ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL));
+ }
+ else
+ ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
+ }
+}
+
+const SfxItemPropertyMap* ScTableColumnObj::GetItemPropertyMap()
+{
+ return pColPropSet->getPropertyMap();
+}
+
+//------------------------------------------------------------------------
+
+ScTableRowObj::ScTableRowObj(ScDocShell* pDocSh, SCROW nRow, SCTAB nTab) :
+ ScCellRangeObj( pDocSh, ScRange(0,nRow,nTab, MAXCOL,nRow,nTab) ),
+ pRowPropSet(lcl_GetRowPropertySet())
+{
+}
+
+ScTableRowObj::~ScTableRowObj()
+{
+}
+
+// XPropertySet erweitert fuer Zeilen-Properties
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( pRowPropSet->getPropertyMap() ));
+ return aRef;
+}
+
+void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry, const uno::Any& aValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ // for Item WIDs, call ScCellRangesBase directly
+ ScCellRangesBase::SetOnePropertyValue(pEntry, aValue);
+ return;
+ }
+
+ // own properties
+
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ return; //! Exception oder so?
+ ScDocument* pDoc = pDocSh->GetDocument();
+ const ScRange& rRange = GetRange();
+ DBG_ASSERT(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
+ SCROW nRow = rRange.aStart.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+ ScDocFunc aFunc(*pDocSh);
+
+ SCCOLROW nRowArr[2];
+ nRowArr[0] = nRowArr[1] = nRow;
+
+ if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
+ {
+ sal_Int32 nNewHeight = 0;
+ if ( aValue >>= nNewHeight )
+ {
+ // property is 1/100mm, row height is twips
+ nNewHeight = HMMToTwips(nNewHeight);
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
+ (USHORT)nNewHeight, TRUE, TRUE );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
+ {
+ BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE );
+ // SC_SIZE_DIRECT mit Groesse 0 blendet aus
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
+ {
+ BOOL bFil = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+// ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
+// aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE );
+ // SC_SIZE_DIRECT mit Groesse 0 blendet aus
+ pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
+ {
+ BOOL bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bOpt)
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, TRUE, TRUE );
+ else
+ {
+ // set current height again manually
+ USHORT nHeight = pDoc->GetOriginalHeight( nRow, nTab );
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_ORIGINAL, nHeight, TRUE, TRUE );
+ }
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE || pEntry->nWID == SC_WID_UNO_MANPAGE )
+ {
+ BOOL bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bSet)
+ aFunc.InsertPageBreak( FALSE, rRange.aStart, TRUE, TRUE, TRUE );
+ else
+ aFunc.RemovePageBreak( FALSE, rRange.aStart, TRUE, TRUE, TRUE );
+ }
+ else
+ ScCellRangeObj::SetOnePropertyValue(pEntry, aValue); // base class, no Item WID
+ }
+}
+
+void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntry,
+ uno::Any& rAny )
+ throw(uno::RuntimeException)
+{
+ if ( pEntry )
+ {
+ ScDocShell* pDocSh = GetDocShell();
+ if (!pDocSh)
+ throw uno::RuntimeException();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ const ScRange& rRange = GetRange();
+ DBG_ASSERT(rRange.aStart.Row() == rRange.aEnd.Row(), "zuviele Zeilen");
+ SCROW nRow = rRange.aStart.Row();
+ SCTAB nTab = rRange.aStart.Tab();
+
+ if ( pEntry->nWID == SC_WID_UNO_CELLHGT )
+ {
+ // for hidden row, return original height
+ USHORT nHeight = pDoc->GetOriginalHeight( nRow, nTab );
+ // property is 1/100mm, row height is twips
+ nHeight = (USHORT) TwipsToHMM(nHeight);
+ rAny <<= (sal_Int32)( nHeight );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
+ {
+ SCROW nDummy;
+ bool bHidden = pDoc->RowHidden(nRow, nTab, nDummy);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
+ {
+ bool bVis = pDoc->RowFiltered(nRow, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
+ {
+ BOOL bOpt = !(pDoc->GetRowFlags( nRow, nTab ) & CR_MANUALSIZE);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, bOpt );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
+ {
+ ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
+ }
+ else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
+ {
+ ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
+ ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
+ }
+ else
+ ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
+ }
+}
+
+const SfxItemPropertyMap* ScTableRowObj::GetItemPropertyMap()
+{
+ return pRowPropSet->getPropertyMap();
+}
+
+//------------------------------------------------------------------------
+
+ScCellsObj::ScCellsObj(ScDocShell* pDocSh, const ScRangeList& rR) :
+ pDocShell( pDocSh ),
+ aRanges( rR )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScCellsObj::~ScCellsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScCellsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+ aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
+ rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScCellsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScCellsEnumeration( pDocShell, aRanges );
+ return NULL;
+}
+
+uno::Type SAL_CALL ScCellsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<table::XCell>*)0);
+}
+
+sal_Bool SAL_CALL ScCellsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bHas = FALSE;
+ if ( pDocShell )
+ {
+ //! schneller selber testen?
+
+ uno::Reference<container::XEnumeration> xEnum(new ScCellsEnumeration( pDocShell, aRanges ));
+ bHas = xEnum->hasMoreElements();
+ }
+ return bHas;
+}
+
+//------------------------------------------------------------------------
+
+ScCellsEnumeration::ScCellsEnumeration(ScDocShell* pDocSh, const ScRangeList& rR) :
+ pDocShell( pDocSh ),
+ aRanges( rR ),
+ pMark( NULL ),
+ bAtEnd( FALSE )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->AddUnoObject(*this);
+
+ if ( aRanges.Count() == 0 )
+ bAtEnd = TRUE;
+ else
+ {
+ SCTAB nTab = 0;
+ const ScRange* pFirst = aRanges.GetObject(0);
+ if (pFirst)
+ nTab = pFirst->aStart.Tab();
+ aPos = ScAddress(0,0,nTab);
+ CheckPos_Impl(); // aPos auf erste passende Zelle setzen
+ }
+}
+
+void ScCellsEnumeration::CheckPos_Impl()
+{
+ if (pDocShell)
+ {
+ BOOL bFound = FALSE;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScBaseCell* pCell = pDoc->GetCell(aPos);
+ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE )
+ {
+ if (!pMark)
+ {
+ pMark = new ScMarkData;
+ pMark->MarkFromRangeList( aRanges, FALSE );
+ pMark->MarkToMulti(); // needed for GetNextMarkedCell
+ }
+ bFound = pMark->IsCellMarked( aPos.Col(), aPos.Row() );
+ }
+ if (!bFound)
+ Advance_Impl();
+ }
+}
+
+ScCellsEnumeration::~ScCellsEnumeration()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+ delete pMark;
+}
+
+void ScCellsEnumeration::Advance_Impl()
+{
+ DBG_ASSERT(!bAtEnd,"zuviel Advance_Impl");
+ if (!pMark)
+ {
+ pMark = new ScMarkData;
+ pMark->MarkFromRangeList( aRanges, FALSE );
+ pMark->MarkToMulti(); // needed for GetNextMarkedCell
+ }
+
+ SCCOL nCol = aPos.Col();
+ SCROW nRow = aPos.Row();
+ SCTAB nTab = aPos.Tab();
+ BOOL bFound = pDocShell->GetDocument()->GetNextMarkedCell( nCol, nRow, nTab, *pMark );
+ if (bFound)
+ aPos.Set( nCol, nRow, nTab );
+ else
+ bAtEnd = TRUE; // kommt nix mehr
+}
+
+void ScCellsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ if (pDocShell)
+ {
+ const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+ aRanges.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
+ rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
+
+ delete pMark; // aus verschobenen Bereichen neu erzeugen
+ pMark = NULL;
+
+ if (!bAtEnd) // aPos anpassen
+ {
+ ScRangeList aNew;
+ aNew.Append(ScRange(aPos));
+ aNew.UpdateReference( rRef.GetMode(), pDocShell->GetDocument(), rRef.GetRange(),
+ rRef.GetDx(), rRef.GetDy(), rRef.GetDz() );
+ if (aNew.Count()==1)
+ {
+ aPos = aNew.GetObject(0)->aStart;
+ CheckPos_Impl();
+ }
+ }
+ }
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XEnumeration
+
+sal_Bool SAL_CALL ScCellsEnumeration::hasMoreElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return !bAtEnd;
+}
+
+uno::Any SAL_CALL ScCellsEnumeration::nextElement() throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell && !bAtEnd)
+ {
+ // Interface-Typ muss zu ScCellsObj::getElementType passen
+
+ ScAddress aTempPos(aPos);
+ Advance_Impl();
+ return uno::makeAny(uno::Reference<table::XCell>(new ScCellObj( pDocShell, aTempPos )));
+ }
+
+ throw container::NoSuchElementException(); // no more elements
+// return uno::Any();
+}
+
+//------------------------------------------------------------------------
+
+ScCellFormatsObj::ScCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
+ pDocShell( pDocSh ),
+ aTotalRange( rRange )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->AddUnoObject(*this);
+
+ DBG_ASSERT( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
+}
+
+ScCellFormatsObj::~ScCellFormatsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ //! aTotalRange...
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+ScCellRangeObj* ScCellFormatsObj::GetObjectByIndex_Impl(long nIndex) const
+{
+ //! direkt auf die AttrArrays zugreifen !!!!
+
+ ScCellRangeObj* pRet = NULL;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ long nPos = 0;
+ ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
+ aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
+ aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
+ {
+ if ( nPos == nIndex )
+ {
+ SCTAB nTab = aTotalRange.aStart.Tab();
+ ScRange aNext( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
+
+ if ( aNext.aStart == aNext.aEnd )
+ pRet = new ScCellObj( pDocShell, aNext.aStart );
+ else
+ pRet = new ScCellRangeObj( pDocShell, aNext );
+ }
+ ++nPos;
+ }
+ }
+ return pRet;
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScCellFormatsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! direkt auf die AttrArrays zugreifen !!!!
+
+ long nCount = 0;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScAttrRectIterator aIter( pDoc, aTotalRange.aStart.Tab(),
+ aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
+ aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ while ( aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
+ ++nCount;
+ }
+ return nCount;
+}
+
+uno::Any SAL_CALL ScCellFormatsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<table::XCellRange> xRange(GetObjectByIndex_Impl(nIndex));
+ if (xRange.is())
+ return uno::makeAny(xRange);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScCellFormatsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<table::XCellRange>*)0);
+}
+
+sal_Bool SAL_CALL ScCellFormatsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 ); //! immer groesser 0 ??
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScCellFormatsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScCellFormatsEnumeration( pDocShell, aTotalRange );
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+
+ScCellFormatsEnumeration::ScCellFormatsEnumeration(ScDocShell* pDocSh, const ScRange& rRange) :
+ pDocShell( pDocSh ),
+ nTab( rRange.aStart.Tab() ),
+ pIter( NULL ),
+ bAtEnd( FALSE ),
+ bDirty( FALSE )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->AddUnoObject(*this);
+
+ DBG_ASSERT( rRange.aStart.Tab() == rRange.aEnd.Tab(),
+ "CellFormatsEnumeration: unterschiedliche Tabellen" );
+
+ pIter = new ScAttrRectIterator( pDoc, nTab,
+ rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row() );
+ Advance_Impl();
+}
+
+ScCellFormatsEnumeration::~ScCellFormatsEnumeration()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+ delete pIter;
+}
+
+void ScCellFormatsEnumeration::Advance_Impl()
+{
+ DBG_ASSERT(!bAtEnd,"zuviel Advance_Impl");
+
+ if ( pIter )
+ {
+ if ( bDirty )
+ {
+ pIter->DataChanged(); // AttrArray-Index neu suchen
+ bDirty = FALSE;
+ }
+
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ if ( pIter->GetNext( nCol1, nCol2, nRow1, nRow2 ) )
+ aNext = ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
+ else
+ bAtEnd = TRUE; // kommt nix mehr
+ }
+ else
+ bAtEnd = TRUE; // Dok weggekommen oder so
+}
+
+ScCellRangeObj* ScCellFormatsEnumeration::NextObject_Impl()
+{
+ ScCellRangeObj* pRet = NULL;
+ if (pDocShell && !bAtEnd)
+ {
+ if ( aNext.aStart == aNext.aEnd )
+ pRet = new ScCellObj( pDocShell, aNext.aStart );
+ else
+ pRet = new ScCellRangeObj( pDocShell, aNext );
+ Advance_Impl();
+ }
+ return pRet;
+}
+
+void ScCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ //! und nun ???
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ delete pIter;
+ pIter = NULL;
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ {
+ bDirty = TRUE; // AttrArray-Index evtl. ungueltig geworden
+ }
+ }
+}
+
+// XEnumeration
+
+sal_Bool SAL_CALL ScCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return !bAtEnd;
+}
+
+uno::Any SAL_CALL ScCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( bAtEnd || !pDocShell )
+ throw container::NoSuchElementException(); // no more elements
+
+ // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
+
+ return uno::makeAny(uno::Reference<table::XCellRange> (NextObject_Impl()));
+}
+
+//------------------------------------------------------------------------
+
+ScUniqueCellFormatsObj::ScUniqueCellFormatsObj(ScDocShell* pDocSh, const ScRange& rRange) :
+ pDocShell( pDocSh ),
+ aTotalRange( rRange ),
+ aRangeLists()
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ DBG_ASSERT( aTotalRange.aStart.Tab() == aTotalRange.aEnd.Tab(), "unterschiedliche Tabellen" );
+
+ GetObjects_Impl();
+}
+
+ScUniqueCellFormatsObj::~ScUniqueCellFormatsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScUniqueCellFormatsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ //! aTotalRange...
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+//
+// Fill the list of formats from the document
+//
+
+// hash code to access the range lists by ScPatternAttr pointer
+struct ScPatternHashCode
+{
+ size_t operator()( const ScPatternAttr* pPattern ) const
+ {
+ return reinterpret_cast<size_t>(pPattern);
+ }
+};
+
+// Hash map to find a range by its start row
+typedef ::std::hash_map< SCROW, ScRange > ScRowRangeHashMap;
+
+typedef ::std::vector<ScRange> ScRangeVector;
+
+// Hash map entry.
+// The Join method depends on the column-wise order of ScAttrRectIterator
+class ScUniqueFormatsEntry
+{
+ enum EntryState { STATE_EMPTY, STATE_SINGLE, STATE_COMPLEX };
+
+ EntryState eState;
+ ScRange aSingleRange;
+ ScRowRangeHashMap aJoinedRanges; // "active" ranges to be merged
+ ScRangeVector aCompletedRanges; // ranges that will no longer be touched
+ ScRangeListRef aReturnRanges; // result as ScRangeList for further use
+
+public:
+ ScUniqueFormatsEntry() : eState( STATE_EMPTY ) {}
+ ScUniqueFormatsEntry( const ScUniqueFormatsEntry& r ) :
+ eState( r.eState ),
+ aSingleRange( r.aSingleRange ),
+ aJoinedRanges( r.aJoinedRanges ),
+ aCompletedRanges( r.aCompletedRanges ),
+ aReturnRanges( r.aReturnRanges ) {}
+ ~ScUniqueFormatsEntry() {}
+
+ void Join( const ScRange& rNewRange );
+ const ScRangeList& GetRanges();
+ void Clear() { aReturnRanges.Clear(); } // aJoinedRanges and aCompletedRanges are cleared in GetRanges
+};
+
+void ScUniqueFormatsEntry::Join( const ScRange& rNewRange )
+{
+ // Special-case handling for single range
+
+ if ( eState == STATE_EMPTY )
+ {
+ aSingleRange = rNewRange;
+ eState = STATE_SINGLE;
+ return;
+ }
+ if ( eState == STATE_SINGLE )
+ {
+ if ( aSingleRange.aStart.Row() == rNewRange.aStart.Row() &&
+ aSingleRange.aEnd.Row() == rNewRange.aEnd.Row() &&
+ aSingleRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
+ {
+ aSingleRange.aEnd.SetCol( rNewRange.aEnd.Col() );
+ return; // still a single range
+ }
+
+ SCROW nSingleRow = aSingleRange.aStart.Row();
+ aJoinedRanges.insert( ScRowRangeHashMap::value_type( nSingleRow, aSingleRange ) );
+ eState = STATE_COMPLEX;
+ // continue normally
+ }
+
+ // This is called in the order of ScAttrRectIterator results.
+ // rNewRange can only be joined with an existing entry if it's the same rows, starting in the next column.
+ // If the old entry for the start row extends to a different end row, or ends in a different column, it
+ // can be moved to aCompletedRanges because it can't be joined with following iterator results.
+ // Everything happens within one sheet, so Tab can be ignored.
+
+ SCROW nStartRow = rNewRange.aStart.Row();
+ ScRowRangeHashMap::iterator aIter( aJoinedRanges.find( nStartRow ) ); // find the active entry for the start row
+ if ( aIter != aJoinedRanges.end() )
+ {
+ ScRange& rOldRange = aIter->second;
+ if ( rOldRange.aEnd.Row() == rNewRange.aEnd.Row() &&
+ rOldRange.aEnd.Col() + 1 == rNewRange.aStart.Col() )
+ {
+ // extend existing range
+ rOldRange.aEnd.SetCol( rNewRange.aEnd.Col() );
+ }
+ else
+ {
+ // move old range to aCompletedRanges, keep rNewRange for joining
+ aCompletedRanges.push_back( rOldRange );
+ rOldRange = rNewRange; // replace in hash map
+ }
+ }
+ else
+ {
+ // keep rNewRange for joining
+ aJoinedRanges.insert( ScRowRangeHashMap::value_type( nStartRow, rNewRange ) );
+ }
+}
+
+const ScRangeList& ScUniqueFormatsEntry::GetRanges()
+{
+ if ( eState == STATE_SINGLE )
+ {
+ aReturnRanges = new ScRangeList;
+ aReturnRanges->Append( aSingleRange );
+ return *aReturnRanges;
+ }
+
+ // move remaining entries from aJoinedRanges to aCompletedRanges
+
+ ScRowRangeHashMap::const_iterator aJoinedEnd = aJoinedRanges.end();
+ for ( ScRowRangeHashMap::const_iterator aJoinedIter = aJoinedRanges.begin(); aJoinedIter != aJoinedEnd; ++aJoinedIter )
+ aCompletedRanges.push_back( aJoinedIter->second );
+ aJoinedRanges.clear();
+
+ // sort all ranges for a predictable API result
+
+ std::sort( aCompletedRanges.begin(), aCompletedRanges.end() );
+
+ // fill and return ScRangeList
+
+ aReturnRanges = new ScRangeList;
+ ScRangeVector::const_iterator aCompEnd( aCompletedRanges.end() );
+ for ( ScRangeVector::const_iterator aCompIter( aCompletedRanges.begin() ); aCompIter != aCompEnd; ++aCompIter )
+ aReturnRanges->Append( *aCompIter );
+ aCompletedRanges.clear();
+
+ return *aReturnRanges;
+}
+
+typedef ::std::hash_map< const ScPatternAttr*, ScUniqueFormatsEntry, ScPatternHashCode > ScUniqueFormatsHashMap;
+
+// function object to sort the range lists by start of first range
+struct ScUniqueFormatsOrder
+{
+ bool operator()( const ScRangeList& rList1, const ScRangeList& rList2 ) const
+ {
+ // all range lists have at least one entry
+ DBG_ASSERT( rList1.Count() > 0 && rList2.Count() > 0, "ScUniqueFormatsOrder: empty list" );
+
+ // compare start positions using ScAddress comparison operator
+ return ( rList1.GetObject(0)->aStart < rList2.GetObject(0)->aStart );
+ }
+};
+
+void ScUniqueCellFormatsObj::GetObjects_Impl()
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTab = aTotalRange.aStart.Tab();
+ ScAttrRectIterator aIter( pDoc, nTab,
+ aTotalRange.aStart.Col(), aTotalRange.aStart.Row(),
+ aTotalRange.aEnd.Col(), aTotalRange.aEnd.Row() );
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+
+ // Collect the ranges for each format in a hash map, to avoid nested loops
+
+ ScUniqueFormatsHashMap aHashMap;
+ while (aIter.GetNext( nCol1, nCol2, nRow1, nRow2 ) )
+ {
+ ScRange aRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
+ const ScPatternAttr* pPattern = pDoc->GetPattern(nCol1, nRow1, nTab);
+ aHashMap[pPattern].Join( aRange );
+ }
+
+ // Fill the vector aRangeLists with the range lists from the hash map
+
+ aRangeLists.reserve( aHashMap.size() );
+ ScUniqueFormatsHashMap::iterator aMapIter( aHashMap.begin() );
+ ScUniqueFormatsHashMap::iterator aMapEnd( aHashMap.end() );
+ while ( aMapIter != aMapEnd )
+ {
+ ScUniqueFormatsEntry& rEntry = aMapIter->second;
+ const ScRangeList& rRanges = rEntry.GetRanges();
+ aRangeLists.push_back( rRanges ); // copy ScRangeList
+ rEntry.Clear(); // free memory, don't hold both copies of all ranges
+ ++aMapIter;
+ }
+
+ // Sort the vector by first range's start position, to avoid random shuffling
+ // due to using the ScPatterAttr pointers
+
+ ScUniqueFormatsOrder aComp;
+ ::std::sort( aRangeLists.begin(), aRangeLists.end(), aComp );
+ }
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScUniqueCellFormatsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return aRangeLists.size();
+}
+
+uno::Any SAL_CALL ScUniqueCellFormatsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if(static_cast<sal_uInt32>(nIndex) < aRangeLists.size())
+ return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nIndex])));
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScUniqueCellFormatsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XSheetCellRangeContainer>*)0);
+}
+
+sal_Bool SAL_CALL ScUniqueCellFormatsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( aRangeLists.size() != 0 );
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScUniqueCellFormatsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScUniqueCellFormatsEnumeration( pDocShell, aRangeLists );
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+
+ScUniqueCellFormatsEnumeration::ScUniqueCellFormatsEnumeration(ScDocShell* pDocSh, const ScMyRangeLists& rRangeLists) :
+ aRangeLists(rRangeLists),
+ pDocShell( pDocSh ),
+ nCurrentPosition(0)
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScUniqueCellFormatsEnumeration::~ScUniqueCellFormatsEnumeration()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScUniqueCellFormatsEnumeration::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ //! und nun ???
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XEnumeration
+
+sal_Bool SAL_CALL ScUniqueCellFormatsEnumeration::hasMoreElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return static_cast<sal_uInt32>(nCurrentPosition) < aRangeLists.size();
+}
+
+uno::Any SAL_CALL ScUniqueCellFormatsEnumeration::nextElement() throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !hasMoreElements() || !pDocShell )
+ throw container::NoSuchElementException(); // no more elements
+
+ // Interface-Typ muss zu ScCellFormatsObj::getElementType passen
+
+ return uno::makeAny(uno::Reference<sheet::XSheetCellRangeContainer>(new ScCellRangesObj(pDocShell, aRangeLists[nCurrentPosition++])));
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/cellvaluebinding.cxx b/sc/source/ui/unoobj/cellvaluebinding.cxx
new file mode 100644
index 000000000000..8301557757ba
--- /dev/null
+++ b/sc/source/ui/unoobj/cellvaluebinding.cxx
@@ -0,0 +1,666 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "cellvaluebinding.hxx"
+#include <tools/debug.hxx>
+#include <rtl/math.hxx>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeData.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+
+//.........................................................................
+namespace calc
+{
+//.........................................................................
+
+#define PROP_HANDLE_BOUND_CELL 1
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::table;
+ using namespace ::com::sun::star::text;
+ using namespace ::com::sun::star::sheet;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::form::binding;
+
+ //=====================================================================
+ //= OCellValueBinding
+ //=====================================================================
+ DBG_NAME( OCellValueBinding )
+ //---------------------------------------------------------------------
+#ifdef DBG_UTIL
+ const char* OCellValueBinding::checkConsistency_static( const void* _pThis )
+ {
+ return static_cast< const OCellValueBinding* >( _pThis )->checkConsistency( );
+ }
+
+ const char* OCellValueBinding::checkConsistency( ) const
+ {
+ const char* pAssertion = NULL;
+ if ( m_xCellText.is() && !m_xCell.is() )
+ // there are places (e.g. getSupportedTypes) which rely on the fact
+ // that m_xCellText.is() implies m_xCell.is()
+ pAssertion = "cell references inconsistent!";
+
+ // TODO: place any additional checks here to ensure consistency of this instance
+ return pAssertion;
+ }
+#endif
+
+ //---------------------------------------------------------------------
+ OCellValueBinding::OCellValueBinding( const Reference< XSpreadsheetDocument >& _rxDocument, sal_Bool _bListPos )
+ :OCellValueBinding_Base( m_aMutex )
+ ,OCellValueBinding_PBase( OCellValueBinding_Base::rBHelper )
+ ,m_xDocument( _rxDocument )
+ ,m_aModifyListeners( m_aMutex )
+ ,m_bInitialized( sal_False )
+ ,m_bListPos( _bListPos )
+ {
+ DBG_CTOR( OCellValueBinding, checkConsistency_static );
+
+ // register our property at the base class
+ CellAddress aInitialPropValue;
+ registerPropertyNoMember(
+ ::rtl::OUString::createFromAscii( "BoundCell" ),
+ PROP_HANDLE_BOUND_CELL,
+ PropertyAttribute::BOUND | PropertyAttribute::READONLY,
+ ::getCppuType( &aInitialPropValue ),
+ &aInitialPropValue
+ );
+
+ // TODO: implement a ReadOnly property as required by the service,
+ // which probably maps to the cell being locked
+ }
+
+ //---------------------------------------------------------------------
+ OCellValueBinding::~OCellValueBinding( )
+ {
+ if ( !OCellValueBinding_Base::rBHelper.bDisposed )
+ {
+ acquire(); // prevent duplicate dtor
+ dispose();
+ }
+
+ DBG_DTOR( OCellValueBinding, checkConsistency_static );
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( OCellValueBinding, OCellValueBinding_Base, OCellValueBinding_PBase )
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( OCellValueBinding, OCellValueBinding_Base, OCellValueBinding_PBase )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::disposing()
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+
+ Reference<XModifyBroadcaster> xBroadcaster( m_xCell, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->removeModifyListener( this );
+ }
+
+// OCellValueBinding_Base::disposing();
+ WeakAggComponentImplHelperBase::disposing();
+
+ // TODO: clean up here whatever you need to clean up (e.g. deregister as XEventListener
+ // for the cell)
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL OCellValueBinding::getPropertySetInfo( ) throw(RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+ return createPropertySetInfo( getInfoHelper() ) ;
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL OCellValueBinding::getInfoHelper()
+ {
+ return *OCellValueBinding_PABase::getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OCellValueBinding::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+ DBG_ASSERT( _nHandle == PROP_HANDLE_BOUND_CELL, "OCellValueBinding::getFastPropertyValue: invalid handle!" );
+ // we only have this one property ....
+ (void)_nHandle; // avoid warning in product version
+
+ _rValue.clear();
+ Reference< XCellAddressable > xCellAddress( m_xCell, UNO_QUERY );
+ if ( xCellAddress.is() )
+ _rValue <<= xCellAddress->getCellAddress( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OCellValueBinding::getSupportedValueTypes( ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+ checkDisposed( );
+ checkInitialized( );
+
+ sal_Int32 nCount = m_xCellText.is() ? 3 : m_xCell.is() ? 1 : 0;
+ if ( m_bListPos )
+ ++nCount;
+
+ Sequence< Type > aTypes( nCount );
+ if ( m_xCell.is() )
+ {
+ // an XCell can be used to set/get "double" values
+ aTypes[0] = ::getCppuType( static_cast< double* >( NULL ) );
+ if ( m_xCellText.is() )
+ {
+ // an XTextRange can be used to set/get "string" values
+ aTypes[1] = ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ // and additionally, we use it to handle booleans
+ aTypes[2] = ::getCppuType( static_cast< sal_Bool* >( NULL ) );
+ }
+
+ // add sal_Int32 only if constructed as ListPositionCellBinding
+ if ( m_bListPos )
+ aTypes[nCount-1] = ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ }
+
+ return aTypes;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL OCellValueBinding::supportsType( const Type& aType ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+ checkDisposed( );
+ checkInitialized( );
+
+ // look up in our sequence
+ Sequence< Type > aSupportedTypes( getSupportedValueTypes() );
+ const Type* pTypes = aSupportedTypes.getConstArray();
+ const Type* pTypesEnd = aSupportedTypes.getConstArray() + aSupportedTypes.getLength();
+ while ( pTypes != pTypesEnd )
+ if ( aType.equals( *pTypes++ ) )
+ return sal_True;
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL OCellValueBinding::getValue( const Type& aType ) throw (IncompatibleTypesException, RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+ checkDisposed( );
+ checkInitialized( );
+ checkValueType( aType );
+
+ Any aReturn;
+ switch ( aType.getTypeClass() )
+ {
+ case TypeClass_STRING:
+ DBG_ASSERT( m_xCellText.is(), "OCellValueBinding::getValue: don't have a text!" );
+ if ( m_xCellText.is() )
+ aReturn <<= m_xCellText->getString();
+ else
+ aReturn <<= ::rtl::OUString();
+ break;
+
+ case TypeClass_BOOLEAN:
+ DBG_ASSERT( m_xCell.is(), "OCellValueBinding::getValue: don't have a double value supplier!" );
+ if ( m_xCell.is() )
+ {
+ // check if the cell has a numeric value (this might go into a helper function):
+
+ sal_Bool bHasValue = sal_False;
+ CellContentType eCellType = m_xCell->getType();
+ if ( eCellType == CellContentType_VALUE )
+ bHasValue = sal_True;
+ else if ( eCellType == CellContentType_FORMULA )
+ {
+ // check if the formula result is a value
+ if ( m_xCell->getError() == 0 )
+ {
+ Reference<XPropertySet> xProp( m_xCell, UNO_QUERY );
+ if ( xProp.is() )
+ {
+ CellContentType eResultType;
+ if ( (xProp->getPropertyValue(::rtl::OUString::createFromAscii( "FormulaResultType" ) ) >>= eResultType) && eResultType == CellContentType_VALUE )
+ bHasValue = sal_True;
+ }
+ }
+ }
+
+ if ( bHasValue )
+ {
+ // 0 is "unchecked", any other value is "checked", regardless of number format
+ double nCellValue = m_xCell->getValue();
+ sal_Bool bBoolValue = ( nCellValue != 0.0 );
+ aReturn <<= bBoolValue;
+ }
+ // empty cells, text cells and text or error formula results: leave return value empty
+ }
+ break;
+
+ case TypeClass_DOUBLE:
+ DBG_ASSERT( m_xCell.is(), "OCellValueBinding::getValue: don't have a double value supplier!" );
+ if ( m_xCell.is() )
+ aReturn <<= m_xCell->getValue();
+ else
+ aReturn <<= (double)0;
+ break;
+
+ case TypeClass_LONG:
+ DBG_ASSERT( m_xCell.is(), "OCellValueBinding::getValue: don't have a double value supplier!" );
+ if ( m_xCell.is() )
+ {
+ // The list position value in the cell is 1-based.
+ // We subtract 1 from any cell value (no special handling for 0 or negative values).
+
+ sal_Int32 nValue = (sal_Int32) rtl::math::approxFloor( m_xCell->getValue() );
+ --nValue;
+
+ aReturn <<= nValue;
+ }
+ else
+ aReturn <<= (sal_Int32)0;
+ break;
+
+ default:
+ DBG_ERROR( "OCellValueBinding::getValue: unreachable code!" );
+ // a type other than double and string should never have survived the checkValueType
+ // above
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::setValue( const Any& aValue ) throw (IncompatibleTypesException, NoSupportException, RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+ checkDisposed( );
+ checkInitialized( );
+ if ( aValue.hasValue() )
+ checkValueType( aValue.getValueType() );
+
+ switch ( aValue.getValueType().getTypeClass() )
+ {
+ case TypeClass_STRING:
+ {
+ DBG_ASSERT( m_xCellText.is(), "OCellValueBinding::setValue: don't have a text!" );
+
+ ::rtl::OUString sText;
+ aValue >>= sText;
+ if ( m_xCellText.is() )
+ m_xCellText->setString( sText );
+ }
+ break;
+
+ case TypeClass_BOOLEAN:
+ {
+ DBG_ASSERT( m_xCell.is(), "OCellValueBinding::setValue: don't have a double value supplier!" );
+
+ // boolean is stored as values 0 or 1
+ // TODO: set the number format to boolean if no format is set?
+
+ sal_Bool bValue( sal_False );
+ aValue >>= bValue;
+ double nCellValue = bValue ? 1.0 : 0.0;
+
+ if ( m_xCell.is() )
+ m_xCell->setValue( nCellValue );
+
+ setBooleanFormat();
+ }
+ break;
+
+ case TypeClass_DOUBLE:
+ {
+ DBG_ASSERT( m_xCell.is(), "OCellValueBinding::setValue: don't have a double value supplier!" );
+
+ double nValue = 0;
+ aValue >>= nValue;
+ if ( m_xCell.is() )
+ m_xCell->setValue( nValue );
+ }
+ break;
+
+ case TypeClass_LONG:
+ {
+ DBG_ASSERT( m_xCell.is(), "OCellValueBinding::setValue: don't have a double value supplier!" );
+
+ sal_Int32 nValue = 0;
+ aValue >>= nValue; // list index from control layer (0-based)
+ ++nValue; // the list position value in the cell is 1-based
+ if ( m_xCell.is() )
+ m_xCell->setValue( nValue );
+ }
+ break;
+
+ case TypeClass_VOID:
+ {
+ // #N/A error value can only be set using XCellRangeData
+
+ Reference<XCellRangeData> xData( m_xCell, UNO_QUERY );
+ DBG_ASSERT( xData.is(), "OCellValueBinding::setValue: don't have XCellRangeData!" );
+ if ( xData.is() )
+ {
+ Sequence<Any> aInner(1); // one empty element
+ Sequence< Sequence<Any> > aOuter( &aInner, 1 ); // one row
+ xData->setDataArray( aOuter );
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "OCellValueBinding::setValue: unreachable code!" );
+ // a type other than double and string should never have survived the checkValueType
+ // above
+ }
+ }
+ //--------------------------------------------------------------------
+ void OCellValueBinding::setBooleanFormat()
+ {
+ // set boolean number format if not already set
+
+ ::rtl::OUString sPropName( ::rtl::OUString::createFromAscii( "NumberFormat" ) );
+ Reference<XPropertySet> xCellProp( m_xCell, UNO_QUERY );
+ Reference<XNumberFormatsSupplier> xSupplier( m_xDocument, UNO_QUERY );
+ if ( xSupplier.is() && xCellProp.is() )
+ {
+ Reference<XNumberFormats> xFormats(xSupplier->getNumberFormats());
+ Reference<XNumberFormatTypes> xTypes( xFormats, UNO_QUERY );
+ if ( xTypes.is() )
+ {
+ Locale aLocale;
+ sal_Bool bWasBoolean = sal_False;
+
+ sal_Int32 nOldIndex = ::comphelper::getINT32( xCellProp->getPropertyValue( sPropName ) );
+ Reference<XPropertySet> xOldFormat;
+ try
+ {
+ xOldFormat.set(xFormats->getByKey( nOldIndex ));
+ }
+ catch ( Exception& )
+ {
+ // non-existing format - can happen, use defaults
+ }
+ if ( xOldFormat.is() )
+ {
+ // use the locale of the existing format
+ xOldFormat->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale;
+
+ sal_Int16 nOldType = ::comphelper::getINT16(
+ xOldFormat->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) );
+ if ( nOldType & NumberFormat::LOGICAL )
+ bWasBoolean = sal_True;
+ }
+
+ if ( !bWasBoolean )
+ {
+ sal_Int32 nNewIndex = xTypes->getStandardFormat( NumberFormat::LOGICAL, aLocale );
+ xCellProp->setPropertyValue( sPropName, makeAny( nNewIndex ) );
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OCellValueBinding::checkDisposed( ) const SAL_THROW( ( DisposedException ) )
+ {
+ if ( OCellValueBinding_Base::rBHelper.bInDispose || OCellValueBinding_Base::rBHelper.bDisposed )
+ throw DisposedException();
+ // TODO: is it worth having an error message here?
+ }
+
+ //--------------------------------------------------------------------
+ void OCellValueBinding::checkInitialized() SAL_THROW( ( RuntimeException ) )
+ {
+ if ( !m_bInitialized )
+ throw RuntimeException();
+ // TODO: error message
+ }
+
+ //--------------------------------------------------------------------
+ void OCellValueBinding::checkValueType( const Type& _rType ) const SAL_THROW( ( IncompatibleTypesException ) )
+ {
+ OCellValueBinding* pNonConstThis = const_cast< OCellValueBinding* >( this );
+ if ( !pNonConstThis->supportsType( _rType ) )
+ {
+ ::rtl::OUString sMessage( RTL_CONSTASCII_USTRINGPARAM( "The given type (" ) );
+ sMessage += _rType.getTypeName();
+ sMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ") is not supported by this binding." ) );
+ // TODO: localize this error message
+
+ throw IncompatibleTypesException( sMessage, *pNonConstThis );
+ // TODO: alternatively use a type converter service for this?
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OCellValueBinding::getImplementationName( ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sheet.OCellValueBinding" ) );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL OCellValueBinding::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+
+ Sequence< ::rtl::OUString > aSupportedServices( getSupportedServiceNames() );
+ const ::rtl::OUString* pLookup = aSupportedServices.getConstArray();
+ const ::rtl::OUString* pLookupEnd = aSupportedServices.getConstArray() + aSupportedServices.getLength();
+ while ( pLookup != pLookupEnd )
+ if ( *pLookup++ == _rServiceName )
+ return sal_True;
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OCellValueBinding::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+
+ Sequence< ::rtl::OUString > aServices( m_bListPos ? 3 : 2 );
+ aServices[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.CellValueBinding" ) );
+ aServices[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.binding.ValueBinding" ) );
+ if ( m_bListPos )
+ aServices[ 2 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.table.ListPositionCellBinding" ) );
+ return aServices;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::addModifyListener( const Reference< XModifyListener >& _rxListener ) throw (RuntimeException)
+ {
+ if ( _rxListener.is() )
+ m_aModifyListeners.addInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::removeModifyListener( const Reference< XModifyListener >& _rxListener ) throw (RuntimeException)
+ {
+ if ( _rxListener.is() )
+ m_aModifyListeners.removeInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void OCellValueBinding::notifyModified()
+ {
+ EventObject aEvent;
+ aEvent.Source.set(*this);
+
+ ::cppu::OInterfaceIteratorHelper aIter( m_aModifyListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ try
+ {
+ static_cast< XModifyListener* >( aIter.next() )->modified( aEvent );
+ }
+ catch( const RuntimeException& )
+ {
+ // silent this
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "OCellValueBinding::notifyModified: caught a (non-runtime) exception!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::modified( const EventObject& /* aEvent */ ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+
+ notifyModified();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::disposing( const EventObject& aEvent ) throw (RuntimeException)
+ {
+ DBG_CHKTHIS( OCellValueBinding, checkConsistency_static );
+
+ Reference<XInterface> xCellInt( m_xCell, UNO_QUERY );
+ if ( xCellInt == aEvent.Source )
+ {
+ // release references to cell object
+ m_xCell.clear();
+ m_xCellText.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OCellValueBinding::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bInitialized )
+ throw Exception();
+ // TODO: error message
+
+ // get the cell address
+ CellAddress aAddress;
+ sal_Bool bFoundAddress = sal_False;
+
+ const Any* pLoop = _rArguments.getConstArray();
+ const Any* pLoopEnd = _rArguments.getConstArray() + _rArguments.getLength();
+ for ( ; ( pLoop != pLoopEnd ) && !bFoundAddress; ++pLoop )
+ {
+ NamedValue aValue;
+ if ( *pLoop >>= aValue )
+ {
+ if ( aValue.Name.equalsAscii( "BoundCell" ) )
+ {
+ if ( aValue.Value >>= aAddress )
+ bFoundAddress = sal_True;
+ }
+ }
+ }
+
+ if ( !bFoundAddress )
+ // TODO: error message
+ throw Exception();
+
+ // get the cell object
+ try
+ {
+ // first the sheets collection
+ Reference< XIndexAccess > xSheets;
+ if ( m_xDocument.is() )
+ xSheets.set(xSheets.query( m_xDocument->getSheets( ) ));
+ DBG_ASSERT( xSheets.is(), "OCellValueBinding::initialize: could not retrieve the sheets!" );
+
+ if ( xSheets.is() )
+ {
+ // the concrete sheet
+ Reference< XCellRange > xSheet(xSheets->getByIndex( aAddress.Sheet ), UNO_QUERY);
+ DBG_ASSERT( xSheet.is(), "OCellValueBinding::initialize: NULL sheet, but no exception!" );
+
+ // the concrete cell
+ if ( xSheet.is() )
+ {
+ m_xCell.set(xSheet->getCellByPosition( aAddress.Column, aAddress.Row ));
+ Reference< XCellAddressable > xAddressAccess( m_xCell, UNO_QUERY );
+ DBG_ASSERT( xAddressAccess.is(), "OCellValueBinding::initialize: either NULL cell, or cell without address access!" );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "OCellValueBinding::initialize: caught an exception while retrieving the cell object!" );
+ }
+
+ if ( !m_xCell.is() )
+ throw Exception();
+ // TODO error message
+
+ m_xCellText.set(m_xCellText.query( m_xCell ));
+
+ Reference<XModifyBroadcaster> xBroadcaster( m_xCell, UNO_QUERY );
+ if ( xBroadcaster.is() )
+ {
+ xBroadcaster->addModifyListener( this );
+ }
+
+ // TODO: add as XEventListener to the cell, so we get notified when it dies,
+ // and can dispose ourself then
+
+ // TODO: somehow add as listener so we get notified when the address of the cell changes
+ // We need to forward this as change in our BoundCell property to our property change listeners
+
+ // TODO: be an XModifyBroadcaster, so that changes in our cell can be notified
+ // to the BindableValue which is/will be bound to this instance.
+
+ m_bInitialized = sal_True;
+ // TODO: place your code here
+ }
+
+
+//.........................................................................
+} // namespace calc
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/cellvaluebinding.hxx b/sc/source/ui/unoobj/cellvaluebinding.hxx
new file mode 100644
index 000000000000..012c11ece7e5
--- /dev/null
+++ b/sc/source/ui/unoobj/cellvaluebinding.hxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_CELLVALUEBINDING_HXX
+#define SC_CELLVALUEBINDING_HXX
+
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
+#include <cppuhelper/compbase5.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+
+
+//.........................................................................
+namespace calc
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OCellValueBinding
+ //=====================================================================
+ class OCellValueBinding;
+ // the base for our interfaces
+ typedef ::cppu::WeakAggComponentImplHelper5 < ::com::sun::star::form::binding::XValueBinding
+ , ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::util::XModifyBroadcaster
+ , ::com::sun::star::util::XModifyListener
+ , ::com::sun::star::lang::XInitialization
+ > OCellValueBinding_Base;
+ // the base for the property handling
+ typedef ::comphelper::OPropertyContainer OCellValueBinding_PBase;
+ // the second base for property handling
+ typedef ::comphelper::OPropertyArrayUsageHelper< OCellValueBinding >
+ OCellValueBinding_PABase;
+
+ class OCellValueBinding :public ::comphelper::OBaseMutex
+ ,public OCellValueBinding_Base // order matters! before OCellValueBinding_PBase, so rBHelper gets initialized
+ ,public OCellValueBinding_PBase
+ ,public OCellValueBinding_PABase
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
+ m_xDocument; /// the document where our cell lives
+ ::com::sun::star::uno::Reference< ::com::sun::star::table::XCell >
+ m_xCell; /// the cell we're bound to, for double value access
+ ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >
+ m_xCellText; /// the cell we're bound to, for text access
+ ::cppu::OInterfaceContainerHelper
+ m_aModifyListeners; /// our modify listeners
+ sal_Bool m_bInitialized; /// has XInitialization::initialize been called?
+ sal_Bool m_bListPos; /// constructed as ListPositionCellBinding?
+
+ public:
+ OCellValueBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& _rxDocument,
+ sal_Bool _bListPos
+ );
+
+ using OCellValueBinding_PBase::getFastPropertyValue;
+
+ protected:
+ ~OCellValueBinding( );
+
+ protected:
+ // XInterface
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
+ // XValueBinding
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getSupportedValueTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsType( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::form::binding::IncompatibleTypesException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::form::binding::IncompatibleTypesException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // OComponentHelper/XComponent
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& _rValue, sal_Int32 _nHandle ) const;
+
+ // ::comphelper::OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XModifyListener
+ virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ private:
+ void checkDisposed( ) const
+ SAL_THROW( ( ::com::sun::star::lang::DisposedException ) );
+ void checkValueType( const ::com::sun::star::uno::Type& _rType ) const
+ SAL_THROW( ( ::com::sun::star::form::binding::IncompatibleTypesException ) );
+ void checkInitialized()
+ SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) );
+
+ /** notifies our modify listeners
+ @precond
+ our mutex is <em>not</em> locked
+ */
+ void notifyModified();
+
+ void setBooleanFormat();
+
+ private:
+ OCellValueBinding(); // never implemented
+ OCellValueBinding( const OCellValueBinding& ); // never implemented
+ OCellValueBinding& operator=( const OCellValueBinding& ); // never implemented
+
+#ifdef DBG_UTIL
+ private:
+ static const char* checkConsistency_static( const void* _pThis );
+ const char* checkConsistency( ) const;
+#endif
+ };
+
+//.........................................................................
+} // namespace calc
+//.........................................................................
+
+#endif // SC_CELLVALUEBINDING_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
new file mode 100644
index 000000000000..b228cee7897a
--- /dev/null
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -0,0 +1,3865 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "chart2uno.hxx"
+#include "miscuno.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "chartpos.hxx"
+#include "unonames.hxx"
+#include "globstr.hrc"
+#include "convuno.hxx"
+#include "rangeutl.hxx"
+#include "hints.hxx"
+#include "unoreflist.hxx"
+#include "compiler.hxx"
+#include "reftokenhelper.hxx"
+#include "chartlis.hxx"
+
+#include <sfx2/objsh.hxx>
+#include <tools/table.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <comphelper/extract.hxx>
+
+#include <vector>
+#include <list>
+#include <rtl/math.hxx>
+
+SC_SIMPLE_SERVICE_INFO( ScChart2DataProvider, "ScChart2DataProvider",
+ "com.sun.star.chart2.data.DataProvider")
+SC_SIMPLE_SERVICE_INFO( ScChart2DataSource, "ScChart2DataSource",
+ "com.sun.star.chart2.data.DataSource")
+SC_SIMPLE_SERVICE_INFO( ScChart2LabeledDataSequence, "ScChart2LabeledDataSequence",
+ "com.sun.star.chart2.data.LabeledDataSequence")
+SC_SIMPLE_SERVICE_INFO( ScChart2DataSequence, "ScChart2DataSequence",
+ "com.sun.star.chart2.data.DataSequence")
+#if USE_CHART2_EMPTYDATASEQUENCE
+SC_SIMPLE_SERVICE_INFO( ScChart2EmptyDataSequence, "ScChart2EmptyDataSequence",
+ "com.sun.star.chart2.data.DataSequence")
+#endif
+
+using namespace ::com::sun::star;
+using namespace ::formula;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::std::auto_ptr;
+using ::std::vector;
+using ::std::list;
+using ::std::distance;
+using ::std::unary_function;
+using ::std::hash_set;
+using ::boost::shared_ptr;
+
+namespace
+{
+const SfxItemPropertyMapEntry* lcl_GetDataProviderPropertyMap()
+{
+ static SfxItemPropertyMapEntry aDataProviderPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_INCLUDEHIDDENCELLS), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aDataProviderPropertyMap_Impl;
+}
+
+const SfxItemPropertyMapEntry* lcl_GetDataSequencePropertyMap()
+{
+ static SfxItemPropertyMapEntry aDataSequencePropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_HIDDENVALUES), 0, &getCppuType((uno::Sequence<sal_Int32>*)0 ), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROLE), 0, &getCppuType((::com::sun::star::chart2::data::DataSequenceRole*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_INCLUDEHIDDENCELLS), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aDataSequencePropertyMap_Impl;
+}
+
+template< typename T >
+::com::sun::star::uno::Sequence< T > lcl_VectorToSequence(
+ const ::std::vector< T > & rCont )
+{
+ ::com::sun::star::uno::Sequence< T > aResult( rCont.size());
+ ::std::copy( rCont.begin(), rCont.end(), aResult.getArray());
+ return aResult;
+}
+
+struct lcl_appendTableNumber : public ::std::unary_function< SCTAB, void >
+{
+ lcl_appendTableNumber( ::rtl::OUStringBuffer & rBuffer ) :
+ m_rBuffer( rBuffer )
+ {}
+ void operator() ( SCTAB nTab )
+ {
+ // there is no append with SCTAB or sal_Int16
+ m_rBuffer.append( static_cast< sal_Int32 >( nTab ));
+ m_rBuffer.append( sal_Unicode( ' ' ));
+ }
+private:
+ ::rtl::OUStringBuffer & m_rBuffer;
+};
+
+::rtl::OUString lcl_createTableNumberList( const ::std::list< SCTAB > & rTableList )
+{
+ ::rtl::OUStringBuffer aBuffer;
+ ::std::for_each( rTableList.begin(), rTableList.end(), lcl_appendTableNumber( aBuffer ));
+ // remove last trailing ' '
+ if( aBuffer.getLength() > 0 )
+ aBuffer.setLength( aBuffer.getLength() - 1 );
+ return aBuffer.makeStringAndClear();
+}
+
+uno::Reference< frame::XModel > lcl_GetXModel( ScDocument * pDoc )
+{
+ uno::Reference< frame::XModel > xModel;
+ SfxObjectShell * pObjSh( pDoc ? pDoc->GetDocumentShell() : 0 );
+ if( pObjSh )
+ xModel.set( pObjSh->GetModel());
+ return xModel;
+}
+
+uno::Reference< sheet::XSpreadsheetDocument > lcl_GetSpreadSheetDocument( ScDocument * pDoc )
+{
+ return uno::Reference< sheet::XSpreadsheetDocument >( lcl_GetXModel( pDoc ), uno::UNO_QUERY );
+}
+
+// ============================================================================
+
+namespace {
+
+struct DeleteInstance : public unary_function<FormulaToken*, void>
+{
+ void operator() (FormulaToken* p) const
+ {
+ delete p;
+ }
+};
+
+}
+
+struct TokenTable
+{
+ SCROW mnRowCount;
+ SCCOL mnColCount;
+ vector<FormulaToken*> maTokens;
+
+ void init( SCCOL nColCount, SCROW nRowCount )
+ {
+ mnColCount = nColCount;
+ mnRowCount = nRowCount;
+ maTokens.reserve(mnColCount*mnRowCount);
+ }
+ void clear()
+ {
+ ::std::for_each(maTokens.begin(), maTokens.end(), DeleteInstance());
+ }
+
+ void push_back( FormulaToken* pToken )
+ {
+ maTokens.push_back( pToken );
+ DBG_ASSERT( maTokens.size()<= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too much tokens" );
+ }
+
+ sal_uInt32 getIndex(SCCOL nCol, SCROW nRow) const
+ {
+ DBG_ASSERT( nCol<mnColCount, "wrong column index" );
+ DBG_ASSERT( nRow<mnRowCount, "wrong row index" );
+ sal_uInt32 nRet = static_cast<sal_uInt32>(nCol*mnRowCount + nRow);
+ DBG_ASSERT( maTokens.size()>= static_cast<sal_uInt32>( mnColCount*mnRowCount ), "too few tokens" );
+ return nRet;
+ }
+
+ vector<ScSharedTokenRef>* getColRanges(SCCOL nCol) const;
+ vector<ScSharedTokenRef>* getRowRanges(SCROW nRow) const;
+ vector<ScSharedTokenRef>* getAllRanges() const;
+};
+
+vector<ScSharedTokenRef>* TokenTable::getColRanges(SCCOL nCol) const
+{
+ if (nCol >= mnColCount)
+ return NULL;
+ if( mnRowCount<=0 )
+ return NULL;
+
+ auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
+ sal_uInt32 nLast = getIndex(nCol, mnRowCount-1);
+ for (sal_uInt32 i = getIndex(nCol, 0); i <= nLast; ++i)
+ {
+ FormulaToken* p = maTokens[i];
+ if (!p)
+ continue;
+
+ ScSharedTokenRef pCopy(static_cast<ScToken*>(p->Clone()));
+ ScRefTokenHelper::join(*pTokens, pCopy);
+ }
+ return pTokens.release();
+}
+
+vector<ScSharedTokenRef>* TokenTable::getRowRanges(SCROW nRow) const
+{
+ if (nRow >= mnRowCount)
+ return NULL;
+ if( mnColCount<=0 )
+ return NULL;
+
+ auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
+ sal_uInt32 nLast = getIndex(mnColCount-1, nRow);
+ for (sal_uInt32 i = getIndex(0, nRow); i <= nLast; i += mnRowCount)
+ {
+ FormulaToken* p = maTokens[i];
+ if (!p)
+ continue;
+
+ ScSharedTokenRef p2(static_cast<ScToken*>(p->Clone()));
+ ScRefTokenHelper::join(*pTokens, p2);
+ }
+ return pTokens.release();
+}
+
+vector<ScSharedTokenRef>* TokenTable::getAllRanges() const
+{
+ auto_ptr< vector<ScSharedTokenRef> > pTokens(new vector<ScSharedTokenRef>);
+ sal_uInt32 nStop = mnColCount*mnRowCount;
+ for (sal_uInt32 i = 0; i < nStop; i++)
+ {
+ FormulaToken* p = maTokens[i];
+ if (!p)
+ continue;
+
+ ScSharedTokenRef p2(static_cast<ScToken*>(p->Clone()));
+ ScRefTokenHelper::join(*pTokens, p2);
+ }
+ return pTokens.release();
+}
+
+// ============================================================================
+
+class Chart2PositionMap
+{
+public:
+ Chart2PositionMap(SCCOL nColCount, SCROW nRowCount,
+ bool bFillRowHeader, bool bFillColumnHeader, Table& rCols,
+ ScDocument* pDoc );
+ ~Chart2PositionMap();
+
+ SCCOL getDataColCount() const { return mnDataColCount; }
+ SCROW getDataRowCount() const { return mnDataRowCount; }
+
+ vector<ScSharedTokenRef>* getLeftUpperCornerRanges() const;
+ vector<ScSharedTokenRef>* getAllColHeaderRanges() const;
+ vector<ScSharedTokenRef>* getAllRowHeaderRanges() const;
+
+ vector<ScSharedTokenRef>* getColHeaderRanges(SCCOL nChartCol) const;
+ vector<ScSharedTokenRef>* getRowHeaderRanges(SCROW nChartRow) const;
+
+ vector<ScSharedTokenRef>* getDataColRanges(SCCOL nCol) const;
+ vector<ScSharedTokenRef>* getDataRowRanges(SCROW nRow) const;
+
+private:
+ SCCOL mnDataColCount;
+ SCROW mnDataRowCount;
+
+ TokenTable maLeftUpperCorner; //nHeaderColCount*nHeaderRowCount
+ TokenTable maColHeaders; //mnDataColCount*nHeaderRowCount
+ TokenTable maRowHeaders; //nHeaderColCount*mnDataRowCount
+ TokenTable maData;//mnDataColCount*mnDataRowCount
+};
+
+Chart2PositionMap::Chart2PositionMap(SCCOL nAllColCount, SCROW nAllRowCount,
+ bool bFillRowHeader, bool bFillColumnHeader, Table& rCols, ScDocument* pDoc)
+{
+ // if bFillRowHeader is true, at least the first column serves as a row header.
+ // If more than one column is pure text all the first pure text columns are used as header.
+ // Likewise, if bFillColumnHeader is true, at least the first row serves as a column header.
+ // If more than one row is pure text all the first pure text rows are used as header.
+
+ SCROW nHeaderRowCount = (bFillColumnHeader && nAllColCount && nAllRowCount) ? 1 : 0;
+ SCCOL nHeaderColCount = (bFillRowHeader && nAllColCount && nAllRowCount) ? 1 : 0;
+
+ if( nHeaderColCount || nHeaderRowCount )
+ {
+ const SCCOL nInitialHeaderColCount = nHeaderColCount;
+ //check whether there is more than one text column or row that should be added to the headers
+ SCROW nSmallestValueRowIndex = nAllRowCount;
+ bool bFoundValues = false;
+ bool bFoundAnything = false;
+ Table* pCol = static_cast<Table*>(rCols.First());
+ for (SCCOL nCol = 0; !bFoundValues && nCol < nAllColCount; ++nCol)
+ {
+ if (pCol && nCol>=nHeaderColCount)
+ {
+ ScToken* pToken = static_cast<ScToken*>(pCol->First());
+ for (SCROW nRow = 0; !bFoundValues && nRow < nSmallestValueRowIndex; ++nRow)
+ {
+ if (pToken && nRow>=nHeaderRowCount)
+ {
+ ScRange aRange;
+ bool bExternal = false;
+ StackVar eType = pToken->GetType();
+ if( eType==svExternal || eType==svExternalSingleRef || eType==svExternalDoubleRef || eType==svExternalName )
+ bExternal = true;//lllll todo correct?
+ ScSharedTokenRef pSharedToken(static_cast<ScToken*>(pToken->Clone()));
+ ScRefTokenHelper::getRangeFromToken(aRange, pSharedToken, bExternal );
+ SCCOL nCol1=0, nCol2=0;
+ SCROW nRow1=0, nRow2=0;
+ SCTAB nTab1=0, nTab2=0;
+ aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 );
+ if (pDoc && pDoc->HasValueData( nCol1, nRow1, nTab1 ))
+ {
+ bFoundValues = bFoundAnything = true;
+ nSmallestValueRowIndex = std::min( nSmallestValueRowIndex, nRow );
+ }
+ if( !bFoundAnything )
+ {
+ if (pDoc && pDoc->HasData( nCol1, nRow1, nTab1 ) )
+ bFoundAnything = true;
+ }
+ }
+ pToken = static_cast<ScToken*>(pCol->Next());
+ }
+ if(!bFoundValues && nHeaderColCount>0)
+ nHeaderColCount++;
+ }
+ pCol = static_cast<Table*>(rCols.Next());
+ }
+ if( bFoundAnything )
+ {
+ if(nHeaderRowCount>0)
+ {
+ if( bFoundValues )
+ nHeaderRowCount = nSmallestValueRowIndex;
+ else if( nAllRowCount>1 )
+ nHeaderRowCount = nAllRowCount-1;
+ }
+ }
+ else //if the cells are completely empty, just use single header rows and columns
+ nHeaderColCount = nInitialHeaderColCount;
+ }
+
+ mnDataColCount = nAllColCount - nHeaderColCount;
+ mnDataRowCount = nAllRowCount - nHeaderRowCount;
+
+ maLeftUpperCorner.init(nHeaderColCount,nHeaderRowCount);
+ maColHeaders.init(mnDataColCount,nHeaderRowCount);
+ maRowHeaders.init(nHeaderColCount,mnDataRowCount);
+ maData.init(mnDataColCount,mnDataRowCount);
+
+ Table* pCol = static_cast<Table*>(rCols.First());
+ FormulaToken* pToken = static_cast<FormulaToken*>(pCol->First());
+ for (SCCOL nCol = 0; nCol < nAllColCount; ++nCol)
+ {
+ if (pCol)
+ {
+ pToken = static_cast<FormulaToken*>(pCol->First());
+ for (SCROW nRow = 0; nRow < nAllRowCount; ++nRow)
+ {
+ if( nCol < nHeaderColCount )
+ {
+ if( nRow < nHeaderRowCount )
+ maLeftUpperCorner.push_back(pToken);
+ else
+ maRowHeaders.push_back(pToken);
+ }
+ else if( nRow < nHeaderRowCount )
+ maColHeaders.push_back(pToken);
+ else
+ maData.push_back(pToken);
+
+ pToken = static_cast<FormulaToken*>(pCol->Next());
+ }
+ }
+ pCol = static_cast<Table*>(rCols.Next());
+ }
+}
+
+Chart2PositionMap::~Chart2PositionMap()
+{
+ maLeftUpperCorner.clear();
+ maColHeaders.clear();
+ maRowHeaders.clear();
+ maData.clear();
+}
+
+vector<ScSharedTokenRef>* Chart2PositionMap::getLeftUpperCornerRanges() const
+{
+ return maLeftUpperCorner.getAllRanges();
+}
+vector<ScSharedTokenRef>* Chart2PositionMap::getAllColHeaderRanges() const
+{
+ return maColHeaders.getAllRanges();
+}
+vector<ScSharedTokenRef>* Chart2PositionMap::getAllRowHeaderRanges() const
+{
+ return maRowHeaders.getAllRanges();
+}
+vector<ScSharedTokenRef>* Chart2PositionMap::getColHeaderRanges(SCCOL nCol) const
+{
+ return maColHeaders.getColRanges( nCol);
+}
+vector<ScSharedTokenRef>* Chart2PositionMap::getRowHeaderRanges(SCROW nRow) const
+{
+ return maRowHeaders.getRowRanges( nRow);
+}
+
+vector<ScSharedTokenRef>* Chart2PositionMap::getDataColRanges(SCCOL nCol) const
+{
+ return maData.getColRanges( nCol);
+}
+
+vector<ScSharedTokenRef>* Chart2PositionMap::getDataRowRanges(SCROW nRow) const
+{
+ return maData.getRowRanges( nRow);
+}
+
+// ----------------------------------------------------------------------------
+
+/**
+ * Designed to be a drop-in replacement for ScChartPositioner, in order to
+ * handle external references.
+ */
+class Chart2Positioner
+{
+ enum GlueType
+ {
+ GLUETYPE_NA,
+ GLUETYPE_NONE,
+ GLUETYPE_COLS,
+ GLUETYPE_ROWS,
+ GLUETYPE_BOTH
+ };
+
+public:
+ Chart2Positioner(ScDocument* pDoc, const vector<ScSharedTokenRef>& rRefTokens) :
+ mpRefTokens(new vector<ScSharedTokenRef>(rRefTokens)),
+ mpPositionMap(NULL),
+ meGlue(GLUETYPE_NA),
+ mpDoc(pDoc),
+ mbColHeaders(false),
+ mbRowHeaders(false),
+ mbDummyUpperLeft(false)
+ {
+ }
+
+ ~Chart2Positioner()
+ {
+ }
+
+ void setHeaders(bool bColHeaders, bool bRowHeaders)
+ {
+ mbColHeaders = bColHeaders;
+ mbRowHeaders = bRowHeaders;
+ }
+
+ bool hasColHeaders() const { return mbColHeaders; }
+ bool hasRowHeaders() const { return mbRowHeaders; }
+
+ Chart2PositionMap* getPositionMap()
+ {
+ createPositionMap();
+ return mpPositionMap.get();
+ }
+
+private:
+ Chart2Positioner(); // disabled
+
+ void invalidateGlue();
+ void glueState();
+ void createPositionMap();
+
+private:
+ shared_ptr< vector<ScSharedTokenRef> > mpRefTokens;
+ auto_ptr<Chart2PositionMap> mpPositionMap;
+ GlueType meGlue;
+ SCCOL mnStartCol;
+ SCROW mnStartRow;
+ ScDocument* mpDoc;
+ bool mbColHeaders:1;
+ bool mbRowHeaders:1;
+ bool mbDummyUpperLeft:1;
+};
+
+void Chart2Positioner::invalidateGlue()
+{
+ meGlue = GLUETYPE_NA;
+ mpPositionMap.reset(NULL);
+}
+
+void Chart2Positioner::glueState()
+{
+ if (meGlue != GLUETYPE_NA)
+ return;
+
+ mbDummyUpperLeft = false;
+ if (mpRefTokens->size() <= 1)
+ {
+ const ScSharedTokenRef& p = mpRefTokens->front();
+ ScComplexRefData aData;
+ if (ScRefTokenHelper::getDoubleRefDataFromToken(aData, p))
+ {
+ if (aData.Ref1.nTab == aData.Ref2.nTab)
+ meGlue = GLUETYPE_NONE;
+ else
+ meGlue = GLUETYPE_COLS;
+ mnStartCol = aData.Ref1.nCol;
+ mnStartRow = aData.Ref1.nRow;
+ }
+ else
+ {
+ invalidateGlue();
+ mnStartCol = 0;
+ mnStartRow = 0;
+ }
+ return;
+ }
+
+ ScComplexRefData aData;
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, mpRefTokens->front());
+ mnStartCol = aData.Ref1.nCol;
+ mnStartRow = aData.Ref1.nRow;
+
+ SCCOL nMaxCols = 0, nEndCol = 0;
+ SCROW nMaxRows = 0, nEndRow = 0;
+ for (vector<ScSharedTokenRef>::const_iterator itr = mpRefTokens->begin(), itrEnd = mpRefTokens->end()
+ ; itr != itrEnd; ++itr)
+ {
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
+ SCCOLROW n1 = aData.Ref1.nCol;
+ SCCOLROW n2 = aData.Ref2.nCol;
+ if (n1 > MAXCOL)
+ n1 = MAXCOL;
+ if (n2 > MAXCOL)
+ n2 = MAXCOL;
+ SCCOLROW nTmp = n2 - n1 + 1;
+ if (n1 < mnStartCol)
+ mnStartCol = static_cast<SCCOL>(n1);
+ if (n2 > nEndCol)
+ nEndCol = static_cast<SCCOL>(n2);
+ if (nTmp > nMaxCols)
+ nMaxCols = static_cast<SCCOL>(nTmp);
+
+ n1 = aData.Ref1.nRow;
+ n2 = aData.Ref2.nRow;
+ if (n1 > MAXROW)
+ n1 = MAXROW;
+ if (n2 > MAXROW)
+ n2 = MAXROW;
+ nTmp = n2 - n1 + 1;
+
+ if (n1 < mnStartRow)
+ mnStartRow = static_cast<SCROW>(n1);
+ if (n2 > nEndRow)
+ nEndRow = static_cast<SCROW>(n2);
+ if (nTmp > nMaxRows)
+ nMaxRows = static_cast<SCROW>(nTmp);
+ }
+
+ // total column size ?
+ SCCOL nC = nEndCol - mnStartCol + 1;
+ if (nC == 1)
+ {
+ meGlue = GLUETYPE_ROWS;
+ return;
+ }
+ // total row size ?
+ SCROW nR = nEndRow - mnStartRow + 1;
+ if (nR == 1)
+ {
+ meGlue = GLUETYPE_COLS;
+ return;
+ }
+ // #i103540# prevent invalid vector size
+ if ((nC <= 0) || (nR <= 0))
+ {
+ invalidateGlue();
+ mnStartCol = 0;
+ mnStartRow = 0;
+ return;
+ }
+ sal_uInt32 nCR = static_cast<sal_uInt32>(nC*nR);
+
+ const sal_uInt8 nHole = 0;
+ const sal_uInt8 nOccu = 1;
+ const sal_uInt8 nFree = 2;
+ const sal_uInt8 nGlue = 3;
+
+ vector<sal_uInt8> aCellStates(nCR);
+ for (vector<ScSharedTokenRef>::const_iterator itr = mpRefTokens->begin(), itrEnd = mpRefTokens->end();
+ itr != itrEnd; ++itr)
+ {
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
+ SCCOL nCol1 = static_cast<SCCOL>(aData.Ref1.nCol) - mnStartCol;
+ SCCOL nCol2 = static_cast<SCCOL>(aData.Ref2.nCol) - mnStartCol;
+ SCROW nRow1 = static_cast<SCROW>(aData.Ref1.nRow) - mnStartRow;
+ SCROW nRow2 = static_cast<SCROW>(aData.Ref2.nRow) - mnStartRow;
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
+ for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow)
+ {
+ size_t i = nCol*nR + nRow;
+ aCellStates[i] = nOccu;
+ }
+ }
+ bool bGlue = true;
+
+ size_t i = 0;
+ bool bGlueCols = false;
+ for (SCCOL nCol = 0; bGlue && nCol < nC; ++nCol)
+ {
+ for (SCROW nRow = 0; bGlue && nRow < nR; ++nRow)
+ {
+ i = nCol*nR + nRow;
+ if (aCellStates[i] == nOccu)
+ {
+ if (nRow > 0 && nRow > 0)
+ bGlue = false;
+ else
+ nRow = nR;
+ }
+ else
+ aCellStates[i] = nFree;
+ }
+ i = (nCol+1)*nR - 1; // index for the last cell in the column.
+ if (bGlue && (aCellStates[i] == nFree))
+ {
+ aCellStates[i] = nGlue;
+ bGlueCols = true;
+ }
+ }
+
+ bool bGlueRows = false;
+ for (SCROW nRow = 0; bGlue && nRow < nR; ++nRow)
+ {
+ i = nRow;
+ for (SCCOL nCol = 0; bGlue && nCol < nC; ++nCol, i += nR)
+ {
+ if (aCellStates[i] == nOccu)
+ {
+ if (nCol > 0 && nRow > 0)
+ bGlue = false;
+ else
+ nCol = nC;
+ }
+ else
+ aCellStates[i] = nFree;
+ }
+ i = (nC-1)*nR + nRow; // index for the row position in the last column.
+ if (bGlue && aCellStates[i] == nFree)
+ {
+ aCellStates[i] = nGlue;
+ bGlueRows = true;
+ }
+ }
+
+ i = 1;
+ for (sal_uInt32 n = 1; bGlue && n < nCR; ++n, ++i)
+ if (aCellStates[i] == nHole)
+ bGlue = false;
+
+ if (bGlue)
+ {
+ if (bGlueCols && bGlueRows)
+ meGlue = GLUETYPE_BOTH;
+ else if (bGlueRows)
+ meGlue = GLUETYPE_ROWS;
+ else
+ meGlue = GLUETYPE_COLS;
+ if (aCellStates.front() != nOccu)
+ mbDummyUpperLeft = true;
+ }
+ else
+ meGlue = GLUETYPE_NONE;
+}
+
+void Chart2Positioner::createPositionMap()
+{
+ if (meGlue == GLUETYPE_NA && mpPositionMap.get())
+ mpPositionMap.reset(NULL);
+
+ if (mpPositionMap.get())
+ return;
+
+ glueState();
+
+ bool bNoGlue = (meGlue == GLUETYPE_NONE);
+ auto_ptr<Table> pCols(new Table);
+ auto_ptr<FormulaToken> pNewAddress;
+ auto_ptr<Table> pNewRowTable(new Table);
+ Table* pCol = NULL;
+ SCROW nNoGlueRow = 0;
+ for (vector<ScSharedTokenRef>::const_iterator itr = mpRefTokens->begin(), itrEnd = mpRefTokens->end();
+ itr != itrEnd; ++itr)
+ {
+ const ScSharedTokenRef& pToken = *itr;
+
+ bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
+ sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0;
+ String aTabName = bExternal ? pToken->GetString() : String();
+
+ ScComplexRefData aData;
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, *itr);
+ const ScSingleRefData& s = aData.Ref1;
+ const ScSingleRefData& e = aData.Ref2;
+ SCCOL nCol1 = s.nCol, nCol2 = e.nCol;
+ SCROW nRow1 = s.nRow, nRow2 = e.nRow;
+ SCTAB nTab1 = s.nTab, nTab2 = e.nTab;
+
+ for (SCTAB nTab = nTab1; nTab <= nTab2; ++nTab)
+ {
+ // What's this for ???
+ sal_uInt32 nInsCol = (static_cast<sal_uInt32>(nTab) << 16) |
+ (bNoGlue ? 0 : static_cast<sal_uInt32>(nCol1));
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol, ++nInsCol)
+ {
+ if (bNoGlue || meGlue == GLUETYPE_ROWS)
+ {
+ pCol = static_cast<Table*>(pCols->Get(nInsCol));
+ if (!pCol)
+ {
+ pCol = pNewRowTable.get();
+ pCols->Insert(nInsCol, pNewRowTable.release());
+ pNewRowTable.reset(new Table);
+ }
+ }
+ else
+ {
+ if (pCols->Insert(nInsCol, pNewRowTable.get()))
+ {
+ pCol = pNewRowTable.release();
+ pNewRowTable.reset(new Table);
+ }
+ else
+ pCol = static_cast<Table*>(pCols->Get(nInsCol));
+ }
+
+ sal_uInt32 nInsRow = static_cast<sal_uInt32>(bNoGlue ? nNoGlueRow : nRow1);
+ for (SCROW nRow = nRow1; nRow <= nRow2; ++nRow, ++nInsRow)
+ {
+ ScSingleRefData aCellData;
+ aCellData.InitFlags();
+ aCellData.SetFlag3D(true);
+ aCellData.SetColRel(false);
+ aCellData.SetRowRel(false);
+ aCellData.SetTabRel(false);
+ aCellData.nCol = nCol;
+ aCellData.nRow = nRow;
+ aCellData.nTab = nTab;
+
+ if (bExternal)
+ pNewAddress.reset(new ScExternalSingleRefToken(nFileId, aTabName, aCellData));
+ else
+ pNewAddress.reset(new ScSingleRefToken(aCellData));
+
+ if (pCol->Insert(nInsRow, pNewAddress.get()))
+ pNewAddress.release(); // To prevent the instance from being destroyed.
+ }
+ }
+ }
+ nNoGlueRow += nRow2 - nRow1 + 1;
+ }
+ pNewAddress.reset(NULL);
+ pNewRowTable.reset(NULL);
+
+ bool bFillRowHeader = mbRowHeaders;
+ bool bFillColumnHeader = mbColHeaders;
+
+ SCSIZE nAllColCount = static_cast<SCSIZE>(pCols->Count());
+ SCSIZE nAllRowCount = 0;
+ pCol = static_cast<Table*>(pCols->First());
+ if (pCol)
+ {
+ if (mbDummyUpperLeft)
+ pCol->Insert(0, NULL); // Dummy fuer Beschriftung
+ nAllRowCount = static_cast<SCSIZE>(pCol->Count());
+ }
+
+ if( nAllColCount!=0 && nAllRowCount!=0 )
+ {
+ if (bNoGlue)
+ {
+ Table* pFirstCol = static_cast<Table*>(pCols->First());
+ sal_uInt32 nCount = pFirstCol->Count();
+ pFirstCol->First();
+ for (sal_uInt32 n = 0; n < nCount; ++n, pFirstCol->Next())
+ {
+ sal_uInt32 nKey = pFirstCol->GetCurKey();
+ pCols->First();
+ for (pCol = static_cast<Table*>(pCols->Next()); pCol; pCol = static_cast<Table*>(pCols->Next()))
+ pCol->Insert(nKey, NULL);
+ }
+ }
+ }
+ mpPositionMap.reset(
+ new Chart2PositionMap(
+ static_cast<SCCOL>(nAllColCount), static_cast<SCROW>(nAllRowCount),
+ bFillRowHeader, bFillColumnHeader, *pCols, mpDoc));
+
+ // Destroy all column instances.
+ for (pCol = static_cast<Table*>(pCols->First()); pCol; pCol = static_cast<Table*>(pCols->Next()))
+ delete pCol;
+}
+
+// ============================================================================
+
+/**
+ * Function object to create a range string from a token list.
+ */
+class Tokens2RangeString : public unary_function<ScSharedTokenRef, void>
+{
+public:
+ Tokens2RangeString(ScDocument* pDoc, FormulaGrammar::Grammar eGram, sal_Unicode cRangeSep) :
+ mpRangeStr(new OUStringBuffer),
+ mpDoc(pDoc),
+ meGrammar(eGram),
+ mcRangeSep(cRangeSep),
+ mbFirst(true)
+ {
+ }
+
+ Tokens2RangeString(const Tokens2RangeString& r) :
+ mpRangeStr(r.mpRangeStr),
+ mpDoc(r.mpDoc),
+ meGrammar(r.meGrammar),
+ mcRangeSep(r.mcRangeSep),
+ mbFirst(r.mbFirst)
+ {
+ }
+
+ void operator() (const ScSharedTokenRef& rToken)
+ {
+ ScCompiler aCompiler(mpDoc, ScAddress(0,0,0));
+ aCompiler.SetGrammar(meGrammar);
+ String aStr;
+ aCompiler.CreateStringFromToken(aStr, rToken.get());
+ if (mbFirst)
+ mbFirst = false;
+ else
+ mpRangeStr->append(mcRangeSep);
+ mpRangeStr->append(aStr);
+ }
+
+ void getString(OUString& rStr)
+ {
+ rStr = mpRangeStr->makeStringAndClear();
+ }
+
+private:
+ Tokens2RangeString(); // disabled
+
+private:
+ shared_ptr<OUStringBuffer> mpRangeStr;
+ ScDocument* mpDoc;
+ FormulaGrammar::Grammar meGrammar;
+ sal_Unicode mcRangeSep;
+ bool mbFirst;
+};
+
+/**
+ * Function object to convert a list of tokens into a string form suitable
+ * for ODF export. In ODF, a range is expressed as
+ *
+ * (start cell address):(end cell address)
+ *
+ * and each address doesn't include any '$' symbols.
+ */
+class Tokens2RangeStringXML : public unary_function<ScSharedTokenRef, void>
+{
+public:
+ Tokens2RangeStringXML(ScDocument* pDoc) :
+ mpRangeStr(new OUStringBuffer),
+ mpDoc(pDoc),
+ mcRangeSep(' '),
+ mcAddrSep(':'),
+ mbFirst(true)
+ {
+ }
+
+ Tokens2RangeStringXML(const Tokens2RangeStringXML& r) :
+ mpRangeStr(r.mpRangeStr),
+ mpDoc(r.mpDoc),
+ mcRangeSep(r.mcRangeSep),
+ mcAddrSep(r.mcAddrSep),
+ mbFirst(r.mbFirst)
+ {
+ }
+
+ void operator() (const ScSharedTokenRef& rToken)
+ {
+ if (mbFirst)
+ mbFirst = false;
+ else
+ mpRangeStr->append(mcRangeSep);
+
+ ScSharedTokenRef aStart, aEnd;
+ splitRangeToken(rToken, aStart, aEnd);
+ ScCompiler aCompiler(mpDoc, ScAddress(0,0,0));
+ aCompiler.SetGrammar(FormulaGrammar::GRAM_ENGLISH);
+ {
+ String aStr;
+ aCompiler.CreateStringFromToken(aStr, aStart.get());
+ mpRangeStr->append(aStr);
+ }
+ mpRangeStr->append(mcAddrSep);
+ {
+ String aStr;
+ aCompiler.CreateStringFromToken(aStr, aEnd.get());
+ mpRangeStr->append(aStr);
+ }
+ }
+
+ void getString(OUString& rStr)
+ {
+ rStr = mpRangeStr->makeStringAndClear();
+ }
+
+private:
+ Tokens2RangeStringXML(); // disabled
+
+ void splitRangeToken(const ScSharedTokenRef& pToken, ScSharedTokenRef& rStart, ScSharedTokenRef& rEnd) const
+ {
+ ScComplexRefData aData;
+ ScRefTokenHelper::getDoubleRefDataFromToken(aData, pToken);
+ bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
+ sal_uInt16 nFileId = bExternal ? pToken->GetIndex() : 0;
+ String aTabName = bExternal ? pToken->GetString() : String();
+
+ // In saving to XML, we don't prepend address with '$'.
+ setRelative(aData.Ref1);
+ setRelative(aData.Ref2);
+
+ // In XML, the end range must explicitly specify sheet name.
+ aData.Ref2.SetFlag3D(true);
+
+ if (bExternal)
+ rStart.reset(new ScExternalSingleRefToken(nFileId, aTabName, aData.Ref1));
+ else
+ rStart.reset(new ScSingleRefToken(aData.Ref1));
+
+ if (bExternal)
+ rEnd.reset(new ScExternalSingleRefToken(nFileId, aTabName, aData.Ref2));
+ else
+ rEnd.reset(new ScSingleRefToken(aData.Ref2));
+ }
+
+ void setRelative(ScSingleRefData& rData) const
+ {
+ rData.SetColRel(true);
+ rData.SetRowRel(true);
+ rData.SetTabRel(true);
+ }
+
+private:
+ shared_ptr<OUStringBuffer> mpRangeStr;
+ ScDocument* mpDoc;
+ sal_Unicode mcRangeSep;
+ sal_Unicode mcAddrSep;
+ bool mbFirst;
+};
+
+void lcl_convertTokensToString(OUString& rStr, const vector<ScSharedTokenRef>& rTokens, ScDocument* pDoc)
+{
+ const sal_Unicode cRangeSep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ FormulaGrammar::Grammar eGrammar = pDoc->GetGrammar();
+ Tokens2RangeString func(pDoc, eGrammar, cRangeSep);
+ func = ::std::for_each(rTokens.begin(), rTokens.end(), func);
+ func.getString(rStr);
+}
+
+} // anonymous namespace
+
+// DataProvider ==============================================================
+
+ScChart2DataProvider::ScChart2DataProvider( ScDocument* pDoc )
+ : m_pDocument( pDoc)
+ , m_aPropSet(lcl_GetDataProviderPropertyMap())
+ , m_bIncludeHiddenCells( sal_True)
+{
+ if ( m_pDocument )
+ m_pDocument->AddUnoObject( *this);
+}
+
+ScChart2DataProvider::~ScChart2DataProvider()
+{
+ if ( m_pDocument )
+ m_pDocument->RemoveUnoObject( *this);
+}
+
+
+void ScChart2DataProvider::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ m_pDocument = NULL;
+ }
+}
+
+::sal_Bool SAL_CALL ScChart2DataProvider::createDataSourcePossible( const uno::Sequence< beans::PropertyValue >& aArguments )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( ! m_pDocument )
+ return false;
+
+ rtl::OUString aRangeRepresentation;
+ for(sal_Int32 i = 0; i < aArguments.getLength(); ++i)
+ {
+ rtl::OUString sName(aArguments[i].Name);
+ if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
+ {
+ aArguments[i].Value >>= aRangeRepresentation;
+ }
+ }
+
+ vector<ScSharedTokenRef> aTokens;
+ ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ return !aTokens.empty();
+}
+
+namespace
+{
+
+ScChart2LabeledDataSequence* lcl_createScChart2DataSequenceFromTokens( auto_ptr< vector<ScSharedTokenRef> > pValueTokens, auto_ptr< vector<ScSharedTokenRef> > pLabelTokens,
+ ScDocument* pDoc, const uno::Reference < chart2::data::XDataProvider >& xDP, bool bIncludeHiddenCells )
+{
+ ScChart2LabeledDataSequence* pRet = 0;
+ bool bHasValues = pValueTokens.get() && !pValueTokens->empty();
+ bool bHasLabel = pLabelTokens.get() && !pLabelTokens->empty();
+ if( bHasValues || bHasLabel )
+ {
+ pRet = new ScChart2LabeledDataSequence(pDoc);
+ if(bHasValues)
+ {
+ uno::Reference < chart2::data::XDataSequence > xSeq(new ScChart2DataSequence(pDoc, xDP, pValueTokens.release(), bIncludeHiddenCells));
+ pRet->setValues(xSeq);
+ }
+ if(bHasLabel)
+ {
+ uno::Reference < chart2::data::XDataSequence > xLabelSeq(new ScChart2DataSequence(pDoc, xDP, pLabelTokens.release(), bIncludeHiddenCells));
+ pRet->setLabel(xLabelSeq);
+ }
+ }
+ return pRet;
+}
+
+//----------------------------------------------------
+/**
+ * Check the current list of reference tokens, and add the upper left
+ * corner of the minimum range that encloses all ranges if certain
+ * conditions are met.
+ *
+ * @param rRefTokens list of reference tokens
+ *
+ * @return true if the corner was added, false otherwise.
+ */
+bool lcl_addUpperLeftCornerIfMissing(vector<ScSharedTokenRef>& rRefTokens,
+ SCROW nCornerRowCount=1, SCCOL nCornerColumnCount=1)
+{
+ using ::std::max;
+ using ::std::min;
+
+ if (rRefTokens.empty())
+ return false;
+
+ SCCOL nMinCol = MAXCOLCOUNT;
+ SCROW nMinRow = MAXROWCOUNT;
+ SCCOL nMaxCol = 0;
+ SCROW nMaxRow = 0;
+ SCTAB nTab = 0;
+
+ USHORT nFileId = 0;
+ String aExtTabName;
+ bool bExternal = false;
+
+ vector<ScSharedTokenRef>::const_iterator itr = rRefTokens.begin(), itrEnd = rRefTokens.end();
+
+ // Get the first ref token.
+ ScSharedTokenRef pToken = *itr;
+ switch (pToken->GetType())
+ {
+ case svSingleRef:
+ {
+ const ScSingleRefData& rData = pToken->GetSingleRef();
+ nMinCol = rData.nCol;
+ nMinRow = rData.nRow;
+ nMaxCol = rData.nCol;
+ nMaxRow = rData.nRow;
+ nTab = rData.nTab;
+ }
+ break;
+ case svDoubleRef:
+ {
+ const ScComplexRefData& rData = pToken->GetDoubleRef();
+ nMinCol = min(rData.Ref1.nCol, rData.Ref2.nCol);
+ nMinRow = min(rData.Ref1.nRow, rData.Ref2.nRow);
+ nMaxCol = max(rData.Ref1.nCol, rData.Ref2.nCol);
+ nMaxRow = max(rData.Ref1.nRow, rData.Ref2.nRow);
+ nTab = rData.Ref1.nTab;
+ }
+ break;
+ case svExternalSingleRef:
+ {
+ const ScSingleRefData& rData = pToken->GetSingleRef();
+ nMinCol = rData.nCol;
+ nMinRow = rData.nRow;
+ nMaxCol = rData.nCol;
+ nMaxRow = rData.nRow;
+ nTab = rData.nTab;
+ nFileId = pToken->GetIndex();
+ aExtTabName = pToken->GetString();
+ bExternal = true;
+ }
+ break;
+ case svExternalDoubleRef:
+ {
+ const ScComplexRefData& rData = pToken->GetDoubleRef();
+ nMinCol = min(rData.Ref1.nCol, rData.Ref2.nCol);
+ nMinRow = min(rData.Ref1.nRow, rData.Ref2.nRow);
+ nMaxCol = max(rData.Ref1.nCol, rData.Ref2.nCol);
+ nMaxRow = max(rData.Ref1.nRow, rData.Ref2.nRow);
+ nTab = rData.Ref1.nTab;
+ nFileId = pToken->GetIndex();
+ aExtTabName = pToken->GetString();
+ bExternal = true;
+ }
+ break;
+ default:
+ ;
+ }
+
+ // Determine the minimum range enclosing all data ranges. Also make sure
+ // that they are all on the same table.
+
+ for (++itr; itr != itrEnd; ++itr)
+ {
+ pToken = *itr;
+ switch (pToken->GetType())
+ {
+ case svSingleRef:
+ {
+ const ScSingleRefData& rData = pToken->GetSingleRef();
+
+ nMinCol = min(nMinCol, rData.nCol);
+ nMinRow = min(nMinRow, rData.nRow);
+ nMaxCol = max(nMaxCol, rData.nCol);
+ nMaxRow = max(nMaxRow, rData.nRow);
+ if (nTab != rData.nTab || bExternal)
+ return false;
+ }
+ break;
+ case svDoubleRef:
+ {
+ const ScComplexRefData& rData = pToken->GetDoubleRef();
+
+ nMinCol = min(nMinCol, rData.Ref1.nCol);
+ nMinCol = min(nMinCol, rData.Ref2.nCol);
+ nMinRow = min(nMinRow, rData.Ref1.nRow);
+ nMinRow = min(nMinRow, rData.Ref2.nRow);
+
+ nMaxCol = max(nMaxCol, rData.Ref1.nCol);
+ nMaxCol = max(nMaxCol, rData.Ref2.nCol);
+ nMaxRow = max(nMaxRow, rData.Ref1.nRow);
+ nMaxRow = max(nMaxRow, rData.Ref2.nRow);
+
+ if (nTab != rData.Ref1.nTab || bExternal)
+ return false;
+ }
+ break;
+ case svExternalSingleRef:
+ {
+ if (!bExternal)
+ return false;
+
+ if (nFileId != pToken->GetIndex() || aExtTabName != pToken->GetString())
+ return false;
+
+ const ScSingleRefData& rData = pToken->GetSingleRef();
+
+ nMinCol = min(nMinCol, rData.nCol);
+ nMinRow = min(nMinRow, rData.nRow);
+ nMaxCol = max(nMaxCol, rData.nCol);
+ nMaxRow = max(nMaxRow, rData.nRow);
+ }
+ break;
+ case svExternalDoubleRef:
+ {
+ if (!bExternal)
+ return false;
+
+ if (nFileId != pToken->GetIndex() || aExtTabName != pToken->GetString())
+ return false;
+
+ const ScComplexRefData& rData = pToken->GetDoubleRef();
+
+ nMinCol = min(nMinCol, rData.Ref1.nCol);
+ nMinCol = min(nMinCol, rData.Ref2.nCol);
+ nMinRow = min(nMinRow, rData.Ref1.nRow);
+ nMinRow = min(nMinRow, rData.Ref2.nRow);
+
+ nMaxCol = max(nMaxCol, rData.Ref1.nCol);
+ nMaxCol = max(nMaxCol, rData.Ref2.nCol);
+ nMaxRow = max(nMaxRow, rData.Ref1.nRow);
+ nMaxRow = max(nMaxRow, rData.Ref2.nRow);
+ }
+ break;
+ default:
+ ;
+ }
+ }
+
+ if (nMinRow >= nMaxRow || nMinCol >= nMaxCol ||
+ nMinRow >= MAXROWCOUNT || nMinCol >= MAXCOLCOUNT ||
+ nMaxRow >= MAXROWCOUNT || nMaxCol >= MAXCOLCOUNT)
+ {
+ // Invalid range. Bail out.
+ return false;
+ }
+
+ // Check if the following conditions are met:
+ //
+ // 1) The upper-left corner cell is not included.
+ // 2) The three adjacent cells of that corner cell are included.
+
+ bool bRight = false, bBottom = false, bDiagonal = false;
+ for (itr = rRefTokens.begin(); itr != itrEnd; ++itr)
+ {
+ pToken = *itr;
+ switch (pToken->GetType())
+ {
+ case svSingleRef:
+ case svExternalSingleRef:
+ {
+ const ScSingleRefData& rData = pToken->GetSingleRef();
+ if (rData.nCol == nMinCol && rData.nRow == nMinRow)
+ // The corner cell is contained.
+ return false;
+
+ if (rData.nCol == nMinCol+nCornerColumnCount && rData.nRow == nMinRow)
+ bRight = true;
+
+ if (rData.nCol == nMinCol && rData.nRow == nMinRow+nCornerRowCount)
+ bBottom = true;
+
+ if (rData.nCol == nMinCol+nCornerColumnCount && rData.nRow == nMinRow+nCornerRowCount)
+ bDiagonal = true;
+ }
+ break;
+ case svDoubleRef:
+ case svExternalDoubleRef:
+ {
+ const ScComplexRefData& rData = pToken->GetDoubleRef();
+ const ScSingleRefData& r1 = rData.Ref1;
+ const ScSingleRefData& r2 = rData.Ref2;
+ if (r1.nCol <= nMinCol && nMinCol <= r2.nCol &&
+ r1.nRow <= nMinRow && nMinRow <= r2.nRow)
+ // The corner cell is contained.
+ return false;
+
+ if (r1.nCol <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.nCol &&
+ r1.nRow <= nMinRow && nMinRow <= r2.nRow)
+ bRight = true;
+
+ if (r1.nCol <= nMinCol && nMinCol <= r2.nCol &&
+ r1.nRow <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.nRow)
+ bBottom = true;
+
+ if (r1.nCol <= nMinCol+nCornerColumnCount && nMinCol+nCornerColumnCount <= r2.nCol &&
+ r1.nRow <= nMinRow+nCornerRowCount && nMinRow+nCornerRowCount <= r2.nRow)
+ bDiagonal = true;
+ }
+ break;
+ default:
+ ;
+ }
+ }
+
+ if (!bRight || !bBottom || !bDiagonal)
+ // Not all the adjacent cells are included. Bail out.
+ return false;
+
+ ScSingleRefData aData;
+ aData.InitFlags();
+ aData.SetFlag3D(true);
+ aData.SetColRel(false);
+ aData.SetRowRel(false);
+ aData.SetTabRel(false);
+ aData.nCol = nMinCol;
+ aData.nRow = nMinRow;
+ aData.nTab = nTab;
+
+ if( nCornerRowCount==1 && nCornerColumnCount==1 )
+ {
+ if (bExternal)
+ {
+ ScSharedTokenRef pCorner(
+ new ScExternalSingleRefToken(nFileId, aExtTabName, aData));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
+ else
+ {
+ ScSharedTokenRef pCorner(new ScSingleRefToken(aData));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
+ }
+ else
+ {
+ ScSingleRefData aDataEnd(aData);
+ aDataEnd.nCol += (nCornerColumnCount-1);
+ aDataEnd.nRow += (nCornerRowCount-1);
+ ScComplexRefData r;
+ r.Ref1=aData;
+ r.Ref2=aDataEnd;
+ if (bExternal)
+ {
+ ScSharedTokenRef pCorner(
+ new ScExternalDoubleRefToken(nFileId, aExtTabName, r));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
+ else
+ {
+ ScSharedTokenRef pCorner(new ScDoubleRefToken(r));
+ ScRefTokenHelper::join(rRefTokens, pCorner);
+ }
+ }
+
+ return true;
+}
+
+}
+
+uno::Reference< chart2::data::XDataSource> SAL_CALL
+ScChart2DataProvider::createDataSource(
+ const uno::Sequence< beans::PropertyValue >& aArguments )
+ throw( lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( ! m_pDocument )
+ throw uno::RuntimeException();
+
+ uno::Reference< chart2::data::XDataSource> xResult;
+ bool bLabel = true;
+ bool bCategories = false;
+ bool bOrientCol = true;
+ ::rtl::OUString aRangeRepresentation;
+ uno::Sequence< sal_Int32 > aSequenceMapping;
+ for(sal_Int32 i = 0; i < aArguments.getLength(); ++i)
+ {
+ rtl::OUString sName(aArguments[i].Name);
+ if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")))
+ {
+ chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
+ if( ! (aArguments[i].Value >>= eSource))
+ {
+ sal_Int32 nSource(0);
+ if( aArguments[i].Value >>= nSource )
+ eSource = (static_cast< chart::ChartDataRowSource >( nSource ));
+ }
+ bOrientCol = (eSource == chart::ChartDataRowSource_COLUMNS);
+ }
+ else if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")))
+ {
+ bLabel = ::cppu::any2bool(aArguments[i].Value);
+ }
+ else if (aArguments[i].Name == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")))
+ {
+ bCategories = ::cppu::any2bool(aArguments[i].Value);
+ }
+ else if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation")))
+ {
+ aArguments[i].Value >>= aRangeRepresentation;
+ }
+ else if (aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("SequenceMapping")))
+ {
+ aArguments[i].Value >>= aSequenceMapping;
+ }
+ }
+
+ vector<ScSharedTokenRef> aRefTokens;
+ ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ if (aRefTokens.empty())
+ // Invalid range representation. Bail out.
+ throw lang::IllegalArgumentException();
+
+ if (bLabel)
+ lcl_addUpperLeftCornerIfMissing(aRefTokens); //#i90669#
+
+ bool bColHeaders = (bOrientCol ? bLabel : bCategories );
+ bool bRowHeaders = (bOrientCol ? bCategories : bLabel );
+
+ Chart2Positioner aChPositioner(m_pDocument, aRefTokens);
+ aChPositioner.setHeaders(bColHeaders, bRowHeaders);
+
+ const Chart2PositionMap* pChartMap = aChPositioner.getPositionMap();
+ if (!pChartMap)
+ // No chart position map instance. Bail out.
+ return xResult;
+
+ ScChart2DataSource* pDS = NULL;
+ std::list < ScChart2LabeledDataSequence* > aSeqs;
+
+ // Fill Categories
+ if( bCategories )
+ {
+ auto_ptr< vector<ScSharedTokenRef> > pValueTokens(NULL);
+ if (bOrientCol)
+ pValueTokens.reset(pChartMap->getAllRowHeaderRanges());
+ else
+ pValueTokens.reset(pChartMap->getAllColHeaderRanges());
+
+ auto_ptr< vector<ScSharedTokenRef> > pLabelTokens(NULL);
+ pLabelTokens.reset(pChartMap->getLeftUpperCornerRanges());
+
+ ScChart2LabeledDataSequence* pCategories = lcl_createScChart2DataSequenceFromTokens( pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells );//ownership of pointers is transfered!
+ if( pCategories )
+ aSeqs.push_back(pCategories);
+ }
+
+ // Fill Serieses (values and label)
+ sal_Int32 nCount = bOrientCol ? pChartMap->getDataColCount() : pChartMap->getDataRowCount();
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ {
+ auto_ptr< vector<ScSharedTokenRef> > pValueTokens(NULL);
+ auto_ptr< vector<ScSharedTokenRef> > pLabelTokens(NULL);
+ if (bOrientCol)
+ {
+ pValueTokens.reset(pChartMap->getDataColRanges(static_cast<SCCOL>(i)));
+ pLabelTokens.reset(pChartMap->getColHeaderRanges(static_cast<SCCOL>(i)));
+ }
+ else
+ {
+ pValueTokens.reset(pChartMap->getDataRowRanges(static_cast<SCROW>(i)));
+ pLabelTokens.reset(pChartMap->getRowHeaderRanges(static_cast<SCROW>(i)));
+ }
+ ScChart2LabeledDataSequence* pChartSeries = lcl_createScChart2DataSequenceFromTokens( pValueTokens, pLabelTokens, m_pDocument, this, m_bIncludeHiddenCells ); //ownership of pointers is transfered!
+ if( pChartSeries )
+ aSeqs.push_back(pChartSeries);
+ }
+
+ pDS = new ScChart2DataSource(m_pDocument);
+ std::list < ScChart2LabeledDataSequence* >::iterator aItr(aSeqs.begin());
+ std::list < ScChart2LabeledDataSequence* >::iterator aEndItr(aSeqs.end());
+
+ //reorder labeled sequences according to aSequenceMapping
+ std::vector< ScChart2LabeledDataSequence* > aSeqVector;
+ while(aItr != aEndItr)
+ {
+ aSeqVector.push_back(*aItr);
+ ++aItr;
+ }
+
+ std::map< sal_Int32, ScChart2LabeledDataSequence* > aSequenceMap;
+ for( sal_Int32 nNewIndex = 0; nNewIndex < aSequenceMapping.getLength(); nNewIndex++ )
+ {
+ // note: assuming that the values in the sequence mapping are always non-negative
+ std::vector< ScChart2LabeledDataSequence* >::size_type nOldIndex( static_cast< sal_uInt32 >( aSequenceMapping[nNewIndex] ));
+ if( nOldIndex < aSeqVector.size() )
+ {
+ pDS->AddLabeledSequence( aSeqVector[nOldIndex] );
+ aSeqVector[nOldIndex] = 0;
+ }
+
+ }
+
+ std::vector< ScChart2LabeledDataSequence* >::iterator aVectorItr(aSeqVector.begin());
+ std::vector< ScChart2LabeledDataSequence* >::iterator aVectorEndItr(aSeqVector.end());
+ while(aVectorItr != aVectorEndItr)
+ {
+ if(*aVectorItr)
+ pDS->AddLabeledSequence(*aVectorItr);
+ ++aVectorItr;
+ }
+
+ xResult.set( pDS );
+ return xResult;
+}
+
+namespace
+{
+
+/**
+ * Function object to create a list of table numbers from a token list.
+ */
+class InsertTabNumber : public unary_function<ScSharedTokenRef, void>
+{
+public:
+ InsertTabNumber() :
+ mpTabNumList(new list<SCTAB>())
+ {
+ }
+
+ InsertTabNumber(const InsertTabNumber& r) :
+ mpTabNumList(r.mpTabNumList)
+ {
+ }
+
+ void operator() (const ScSharedTokenRef& pToken) const
+ {
+ if (!ScRefTokenHelper::isRef(pToken))
+ return;
+
+ const ScSingleRefData& r = pToken->GetSingleRef();
+ mpTabNumList->push_back(r.nTab);
+ }
+
+ void getList(list<SCTAB>& rList)
+ {
+ mpTabNumList->swap(rList);
+ }
+private:
+ shared_ptr< list<SCTAB> > mpTabNumList;
+};
+
+class RangeAnalyzer
+{
+public:
+ RangeAnalyzer();
+ void initRangeAnalyzer( const vector<ScSharedTokenRef>& rTokens );
+ void analyzeRange( sal_Int32& rnDataInRows, sal_Int32& rnDataInCols,
+ bool& rbRowSourceAmbiguous ) const;
+ bool inSameSingleRow( RangeAnalyzer& rOther );
+ bool inSameSingleColumn( RangeAnalyzer& rOther );
+ SCROW getRowCount() { return mnRowCount; }
+ SCCOL getColumnCount() { return mnColumnCount; }
+
+private:
+ bool mbEmpty;
+ bool mbAmbiguous;
+ SCROW mnRowCount;
+ SCCOL mnColumnCount;
+
+ SCCOL mnStartColumn;
+ SCROW mnStartRow;
+};
+
+RangeAnalyzer::RangeAnalyzer()
+ : mbEmpty(true)
+ , mbAmbiguous(false)
+ , mnRowCount(0)
+ , mnColumnCount(0)
+ , mnStartColumn(-1)
+ , mnStartRow(-1)
+{
+}
+
+void RangeAnalyzer::initRangeAnalyzer( const vector<ScSharedTokenRef>& rTokens )
+{
+ mnRowCount=0;
+ mnColumnCount=0;
+ mnStartColumn = -1;
+ mnStartRow = -1;
+ mbAmbiguous=false;
+ if( rTokens.empty() )
+ {
+ mbEmpty=true;
+ return;
+ }
+ mbEmpty=false;
+
+ vector<ScSharedTokenRef>::const_iterator itr = rTokens.begin(), itrEnd = rTokens.end();
+ for (; itr != itrEnd ; ++itr)
+ {
+ ScSharedTokenRef aRefToken = *itr;
+ StackVar eVar = aRefToken->GetType();
+ if (eVar == svDoubleRef || eVar == svExternalDoubleRef)
+ {
+ const ScComplexRefData& r = aRefToken->GetDoubleRef();
+ if (r.Ref1.nTab == r.Ref2.nTab)
+ {
+ mnColumnCount = std::max<SCCOL>( mnColumnCount, static_cast<SCCOL>(abs(r.Ref2.nCol - r.Ref1.nCol)+1) );
+ mnRowCount = std::max<SCROW>( mnRowCount, static_cast<SCROW>(abs(r.Ref2.nRow - r.Ref1.nRow)+1) );
+ if( mnStartColumn == -1 )
+ {
+ mnStartColumn = r.Ref1.nCol;
+ mnStartRow = r.Ref1.nRow;
+ }
+ else
+ {
+ if( mnStartColumn != r.Ref1.nCol && mnStartRow != r.Ref1.nRow )
+ mbAmbiguous=true;
+ }
+ }
+ else
+ mbAmbiguous=true;
+ }
+ else if (eVar == svSingleRef || eVar == svExternalSingleRef)
+ {
+ const ScSingleRefData& r = aRefToken->GetSingleRef();
+ mnColumnCount = std::max<SCCOL>( mnColumnCount, 1);
+ mnRowCount = std::max<SCROW>( mnRowCount, 1);
+ if( mnStartColumn == -1 )
+ {
+ mnStartColumn = r.nCol;
+ mnStartRow = r.nRow;
+ }
+ else
+ {
+ if( mnStartColumn != r.nCol && mnStartRow != r.nRow )
+ mbAmbiguous=true;
+ }
+ }
+ else
+ mbAmbiguous=true;
+ }
+}
+
+void RangeAnalyzer::analyzeRange( sal_Int32& rnDataInRows,
+ sal_Int32& rnDataInCols,
+ bool& rbRowSourceAmbiguous ) const
+{
+ if(!mbEmpty && !mbAmbiguous)
+ {
+ if( mnRowCount==1 && mnColumnCount>1 )
+ ++rnDataInRows;
+ else if( mnColumnCount==1 && mnRowCount>1 )
+ ++rnDataInCols;
+ else if( mnRowCount>1 && mnColumnCount>1 )
+ rbRowSourceAmbiguous = true;
+ }
+ else if( !mbEmpty )
+ rbRowSourceAmbiguous = true;
+}
+
+bool RangeAnalyzer::inSameSingleRow( RangeAnalyzer& rOther )
+{
+ if( mnStartRow==rOther.mnStartRow &&
+ mnRowCount==1 && rOther.mnRowCount==1 )
+ return true;
+ return false;
+}
+
+bool RangeAnalyzer::inSameSingleColumn( RangeAnalyzer& rOther )
+{
+ if( mnStartColumn==rOther.mnStartColumn &&
+ mnColumnCount==1 && rOther.mnColumnCount==1 )
+ return true;
+ return false;
+}
+
+} //end anonymous namespace
+
+uno::Sequence< beans::PropertyValue > SAL_CALL ScChart2DataProvider::detectArguments(
+ const uno::Reference< chart2::data::XDataSource >& xDataSource )
+ throw (uno::RuntimeException)
+{
+ ::std::vector< beans::PropertyValue > aResult;
+ bool bRowSourceDetected = false;
+ bool bFirstCellAsLabel = false;
+ bool bHasCategories = false;
+ ::rtl::OUString sRangeRep;
+
+ bool bHasCategoriesLabels = false;
+ vector<ScSharedTokenRef> aAllCategoriesValuesTokens;
+ vector<ScSharedTokenRef> aAllSeriesLabelTokens;
+
+ chart::ChartDataRowSource eRowSource = chart::ChartDataRowSource_COLUMNS;
+
+ vector<ScSharedTokenRef> aAllTokens;
+
+ // parse given data source and collect infos
+ {
+ SolarMutexGuard aGuard;
+ DBG_ASSERT( m_pDocument, "No Document -> no detectArguments" );
+ if(!m_pDocument ||!xDataSource.is())
+ return lcl_VectorToSequence( aResult );
+
+ sal_Int32 nDataInRows = 0;
+ sal_Int32 nDataInCols = 0;
+ bool bRowSourceAmbiguous = false;
+
+ Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences());
+ const sal_Int32 nCount( aSequences.getLength());
+ RangeAnalyzer aPrevLabel,aPrevValues;
+ for( sal_Int32 nIdx=0; nIdx<nCount; ++nIdx )
+ {
+ Reference< chart2::data::XLabeledDataSequence > xLS(aSequences[nIdx]);
+ if( xLS.is() )
+ {
+ bool bThisIsCategories = false;
+ if(!bHasCategories)
+ {
+ Reference< beans::XPropertySet > xSeqProp( xLS->getValues(), uno::UNO_QUERY );
+ ::rtl::OUString aRole;
+ if( xSeqProp.is() && (xSeqProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Role"))) >>= aRole) &&
+ aRole.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("categories")) )
+ bThisIsCategories = bHasCategories = true;
+ }
+
+ RangeAnalyzer aLabel,aValues;
+ // label
+ Reference< chart2::data::XDataSequence > xLabel( xLS->getLabel());
+ if( xLabel.is())
+ {
+ bFirstCellAsLabel = true;
+ vector<ScSharedTokenRef> aTokens;
+ ScRefTokenHelper::compileRangeRepresentation( aTokens, xLabel->getSourceRangeRepresentation(), m_pDocument, m_pDocument->GetGrammar() );
+ aLabel.initRangeAnalyzer(aTokens);
+ vector<ScSharedTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScRefTokenHelper::join(aAllTokens, *itr);
+ if(!bThisIsCategories)
+ ScRefTokenHelper::join(aAllSeriesLabelTokens, *itr);
+ }
+ if(bThisIsCategories)
+ bHasCategoriesLabels=true;
+ }
+ // values
+ Reference< chart2::data::XDataSequence > xValues( xLS->getValues());
+ if( xValues.is())
+ {
+ vector<ScSharedTokenRef> aTokens;
+ ScRefTokenHelper::compileRangeRepresentation( aTokens, xValues->getSourceRangeRepresentation(), m_pDocument, m_pDocument->GetGrammar() );
+ aValues.initRangeAnalyzer(aTokens);
+ vector<ScSharedTokenRef>::const_iterator itr = aTokens.begin(), itrEnd = aTokens.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScRefTokenHelper::join(aAllTokens, *itr);
+ if(bThisIsCategories)
+ ScRefTokenHelper::join(aAllCategoriesValuesTokens, *itr);
+ }
+ }
+ //detect row source
+ if(!bThisIsCategories || nCount==1) //categories might span multiple rows *and* columns, so they should be used for detection only if nothing else is available
+ {
+ if (!bRowSourceAmbiguous)
+ {
+ aValues.analyzeRange(nDataInRows,nDataInCols,bRowSourceAmbiguous);
+ aLabel.analyzeRange(nDataInRows,nDataInCols,bRowSourceAmbiguous);
+ if (nDataInRows > 1 && nDataInCols > 1)
+ bRowSourceAmbiguous = true;
+ else if( !bRowSourceAmbiguous && !nDataInRows && !nDataInCols )
+ {
+ if( aValues.inSameSingleColumn( aLabel ) )
+ nDataInCols++;
+ else if( aValues.inSameSingleRow( aLabel ) )
+ nDataInRows++;
+ else
+ {
+ //#i86188# also detect a single column split into rows correctly
+ if( aValues.inSameSingleColumn( aPrevValues ) )
+ nDataInRows++;
+ else if( aValues.inSameSingleRow( aPrevValues ) )
+ nDataInCols++;
+ else if( aLabel.inSameSingleColumn( aPrevLabel ) )
+ nDataInRows++;
+ else if( aLabel.inSameSingleRow( aPrevLabel ) )
+ nDataInCols++;
+ }
+ }
+ }
+ }
+ aPrevValues=aValues;
+ aPrevLabel=aLabel;
+ }
+ }
+
+ if (!bRowSourceAmbiguous)
+ {
+ bRowSourceDetected = true;
+ eRowSource = ( nDataInRows > 0
+ ? chart::ChartDataRowSource_ROWS
+ : chart::ChartDataRowSource_COLUMNS );
+ }
+ else
+ {
+ // set DataRowSource to the better of the two ambiguities
+ eRowSource = ( nDataInRows > nDataInCols
+ ? chart::ChartDataRowSource_ROWS
+ : chart::ChartDataRowSource_COLUMNS );
+ }
+
+ }
+
+ // TableNumberList
+ {
+ list<SCTAB> aTableNumList;
+ InsertTabNumber func;
+ func = ::std::for_each(aAllTokens.begin(), aAllTokens.end(), func);
+ func.getList(aTableNumList);
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("TableNumberList"), -1,
+ uno::makeAny( lcl_createTableNumberList( aTableNumList ) ),
+ beans::PropertyState_DIRECT_VALUE ));
+ }
+
+ // DataRowSource (calculated before)
+ if( bRowSourceDetected )
+ {
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("DataRowSource"), -1,
+ uno::makeAny( eRowSource ), beans::PropertyState_DIRECT_VALUE ));
+ }
+
+ // HasCategories
+ if( bRowSourceDetected )
+ {
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("HasCategories"), -1,
+ uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ));
+ }
+
+ // FirstCellAsLabel
+ if( bRowSourceDetected )
+ {
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
+ uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ));
+ }
+
+ // Add the left upper corner to the range if it is missing.
+ if (bRowSourceDetected && bFirstCellAsLabel && bHasCategories && !bHasCategoriesLabels )
+ {
+ RangeAnalyzer aTop,aLeft;
+ if( eRowSource==chart::ChartDataRowSource_COLUMNS )
+ {
+ aTop.initRangeAnalyzer(aAllSeriesLabelTokens);
+ aLeft.initRangeAnalyzer(aAllCategoriesValuesTokens);
+ }
+ else
+ {
+ aTop.initRangeAnalyzer(aAllCategoriesValuesTokens);
+ aLeft.initRangeAnalyzer(aAllSeriesLabelTokens);
+ }
+ lcl_addUpperLeftCornerIfMissing(aAllTokens, aTop.getRowCount(), aLeft.getColumnCount());//e.g. #i91212#
+ }
+
+ // Get range string.
+ lcl_convertTokensToString(sRangeRep, aAllTokens, m_pDocument);
+
+ // add cell range property
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
+ uno::makeAny( sRangeRep ), beans::PropertyState_DIRECT_VALUE ));
+
+ //Sequence Mapping
+ bool bSequencesReordered = true;//todo detect this above or detect this sequence mapping cheaper ...
+ if( bSequencesReordered && bRowSourceDetected )
+ {
+ bool bDifferentIndexes = false;
+
+ std::vector< sal_Int32 > aSequenceMappingVector;
+
+ uno::Reference< chart2::data::XDataSource > xCompareDataSource;
+ try
+ {
+ xCompareDataSource.set( this->createDataSource( lcl_VectorToSequence( aResult ) ) );
+ }
+ catch( const lang::IllegalArgumentException & )
+ {
+ // creation of data source to compare didn't work, so we cannot
+ // create a sequence mapping
+ }
+
+ if( xDataSource.is() && xCompareDataSource.is() )
+ {
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence> > aOldSequences(
+ xCompareDataSource->getDataSequences() );
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSequences(
+ xDataSource->getDataSequences());
+
+ rtl::OUString aOldLabel;
+ rtl::OUString aNewLabel;
+ rtl::OUString aOldValues;
+ rtl::OUString aNewValues;
+ rtl::OUString aEmpty;
+
+ for( sal_Int32 nNewIndex = 0; nNewIndex < aNewSequences.getLength(); nNewIndex++ )
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence> xNew( aNewSequences[nNewIndex] );
+ for( sal_Int32 nOldIndex = 0; nOldIndex < aOldSequences.getLength(); nOldIndex++ )
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence> xOld( aOldSequences[nOldIndex] );
+
+ if( xOld.is() && xNew.is() )
+ {
+ aOldLabel = aNewLabel = aOldValues = aNewValues = aEmpty;
+ if( xOld.is() && xOld->getLabel().is() )
+ aOldLabel = xOld->getLabel()->getSourceRangeRepresentation();
+ if( xNew.is() && xNew->getLabel().is() )
+ aNewLabel = xNew->getLabel()->getSourceRangeRepresentation();
+ if( xOld.is() && xOld->getValues().is() )
+ aOldValues = xOld->getValues()->getSourceRangeRepresentation();
+ if( xNew.is() && xNew->getValues().is() )
+ aNewValues = xNew->getValues()->getSourceRangeRepresentation();
+
+ if( aOldLabel.equals(aNewLabel)
+ && ( aOldValues.equals(aNewValues) ) )
+ {
+ if( nOldIndex!=nNewIndex )
+ bDifferentIndexes = true;
+ aSequenceMappingVector.push_back(nOldIndex);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if( bDifferentIndexes && aSequenceMappingVector.size() )
+ {
+ aResult.push_back(
+ beans::PropertyValue( ::rtl::OUString::createFromAscii("SequenceMapping"), -1,
+ uno::makeAny( lcl_VectorToSequence(aSequenceMappingVector) )
+ , beans::PropertyState_DIRECT_VALUE ));
+ }
+ }
+
+ return lcl_VectorToSequence( aResult );
+}
+
+::sal_Bool SAL_CALL ScChart2DataProvider::createDataSequenceByRangeRepresentationPossible( const ::rtl::OUString& aRangeRepresentation )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( ! m_pDocument )
+ return false;
+
+ vector<ScSharedTokenRef> aTokens;
+ ScRefTokenHelper::compileRangeRepresentation(aTokens, aRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ return !aTokens.empty();
+}
+
+uno::Reference< chart2::data::XDataSequence > SAL_CALL
+ ScChart2DataProvider::createDataSequenceByRangeRepresentation(
+ const ::rtl::OUString& aRangeRepresentation )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< chart2::data::XDataSequence > xResult;
+
+ DBG_ASSERT( m_pDocument, "No Document -> no createDataSequenceByRangeRepresentation" );
+ if(!m_pDocument || (aRangeRepresentation.getLength() == 0))
+ return xResult;
+
+ // Note: the range representation must be in Calc A1 format. The import
+ // filters use this method to pass data ranges, and they have no idea what
+ // the current formula syntax is. In the future we should add another
+ // method to allow the client code to directly pass tokens representing
+ // ranges.
+
+ vector<ScSharedTokenRef> aRefTokens;
+ ScRefTokenHelper::compileRangeRepresentation(aRefTokens, aRangeRepresentation, m_pDocument);
+ if (aRefTokens.empty())
+ return xResult;
+
+ // ScChart2DataSequence manages the life cycle of pRefTokens.
+ vector<ScSharedTokenRef>* pRefTokens = new vector<ScSharedTokenRef>();
+ pRefTokens->swap(aRefTokens);
+ xResult.set(new ScChart2DataSequence(m_pDocument, this, pRefTokens, m_bIncludeHiddenCells));
+
+ return xResult;
+}
+
+uno::Reference< sheet::XRangeSelection > SAL_CALL ScChart2DataProvider::getRangeSelection()
+ throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XRangeSelection > xResult;
+
+ uno::Reference< frame::XModel > xModel( lcl_GetXModel( m_pDocument ));
+ if( xModel.is())
+ xResult.set( xModel->getCurrentController(), uno::UNO_QUERY );
+
+ return xResult;
+}
+
+/*uno::Reference< util::XNumberFormatsSupplier > SAL_CALL ScChart2DataProvider::getNumberFormatsSupplier()
+ throw (uno::RuntimeException)
+{
+ return uno::Reference< util::XNumberFormatsSupplier >( lcl_GetXModel( m_pDocument ), uno::UNO_QUERY );
+}*/
+
+// XRangeXMLConversion ---------------------------------------------------
+
+rtl::OUString SAL_CALL ScChart2DataProvider::convertRangeToXML( const rtl::OUString& sRangeRepresentation )
+ throw ( uno::RuntimeException, lang::IllegalArgumentException )
+{
+ OUString aRet;
+ if (!m_pDocument)
+ return aRet;
+
+ if (!sRangeRepresentation.getLength())
+ // Empty data range is allowed.
+ return aRet;
+
+ vector<ScSharedTokenRef> aRefTokens;
+ ScRefTokenHelper::compileRangeRepresentation(aRefTokens, sRangeRepresentation, m_pDocument, m_pDocument->GetGrammar());
+ if (aRefTokens.empty())
+ throw lang::IllegalArgumentException();
+
+ Tokens2RangeStringXML converter(m_pDocument);
+ converter = ::std::for_each(aRefTokens.begin(), aRefTokens.end(), converter);
+ converter.getString(aRet);
+
+ return aRet;
+}
+
+rtl::OUString SAL_CALL ScChart2DataProvider::convertRangeFromXML( const rtl::OUString& sXMLRange )
+ throw ( uno::RuntimeException, lang::IllegalArgumentException )
+{
+ const sal_Unicode cSep = ' ';
+ const sal_Unicode cQuote = '\'';
+
+ if (!m_pDocument)
+ {
+ // #i74062# When loading flat XML, this is called before the referenced sheets are in the document,
+ // so the conversion has to take place directly with the strings, without looking up the sheets.
+
+ rtl::OUStringBuffer sRet;
+ sal_Int32 nOffset = 0;
+ while( nOffset >= 0 )
+ {
+ rtl::OUString sToken;
+ ScRangeStringConverter::GetTokenByOffset( sToken, sXMLRange, nOffset, cSep, cQuote );
+ if( nOffset >= 0 )
+ {
+ // convert one address (remove dots)
+
+ String aUIString(sToken);
+
+ sal_Int32 nIndex = ScRangeStringConverter::IndexOf( sToken, ':', 0, cQuote );
+ if ( nIndex >= 0 && nIndex < aUIString.Len() - 1 &&
+ aUIString.GetChar((xub_StrLen)nIndex + 1) == (sal_Unicode) '.' )
+ aUIString.Erase( (xub_StrLen)nIndex + 1, 1 );
+
+ if ( aUIString.GetChar(0) == (sal_Unicode) '.' )
+ aUIString.Erase( 0, 1 );
+
+ if( sRet.getLength() )
+ sRet.append( (sal_Unicode) ';' );
+ sRet.append( aUIString );
+ }
+ }
+
+ return sRet.makeStringAndClear();
+ }
+
+ OUString aRet;
+ ScRangeStringConverter::GetStringFromXMLRangeString(aRet, sXMLRange, m_pDocument);
+ return aRet;
+}
+
+// DataProvider XPropertySet -------------------------------------------------
+
+uno::Reference< beans::XPropertySetInfo> SAL_CALL
+ScChart2DataProvider::getPropertySetInfo() throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( m_aPropSet.getPropertyMap() );
+ return aRef;
+}
+
+
+void SAL_CALL ScChart2DataProvider::setPropertyValue(
+ const ::rtl::OUString& rPropertyName, const uno::Any& rValue)
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS)))
+ {
+ if ( !(rValue >>= m_bIncludeHiddenCells))
+ throw lang::IllegalArgumentException();
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
+
+uno::Any SAL_CALL ScChart2DataProvider::getPropertyValue(
+ const ::rtl::OUString& rPropertyName)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aRet;
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS)))
+ aRet <<= m_bIncludeHiddenCells;
+ else
+ throw beans::UnknownPropertyException();
+ return aRet;
+}
+
+
+void SAL_CALL ScChart2DataProvider::addPropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener>& /*xListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2DataProvider::removePropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2DataProvider::addVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2DataProvider::removeVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener>& /*rListener*/ )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+// DataSource ================================================================
+
+ScChart2DataSource::ScChart2DataSource( ScDocument* pDoc)
+ : m_pDocument( pDoc)
+{
+ if ( m_pDocument )
+ m_pDocument->AddUnoObject( *this);
+}
+
+
+ScChart2DataSource::~ScChart2DataSource()
+{
+ if ( m_pDocument )
+ m_pDocument->RemoveUnoObject( *this);
+}
+
+
+void ScChart2DataSource::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ m_pDocument = NULL;
+ }
+}
+
+
+uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence> > SAL_CALL
+ScChart2DataSource::getDataSequences() throw ( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ LabeledList::const_iterator aItr(m_aLabeledSequences.begin());
+ LabeledList::const_iterator aEndItr(m_aLabeledSequences.end());
+
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aRet(m_aLabeledSequences.size());
+
+ sal_Int32 i = 0;
+ while (aItr != aEndItr)
+ {
+ aRet[i] = *aItr;
+ ++i;
+ ++aItr;
+ }
+
+ return aRet;
+
+/* typedef ::std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > tVec;
+ tVec aVec;
+ bool bSeries = false;
+ // split into columns - FIXME: different if GlueState() is used
+ for ( ScRangePtr p = m_xRanges->First(); p; p = m_xRanges->Next())
+ {
+ for ( SCCOL nCol = p->aStart.Col(); nCol <= p->aEnd.Col(); ++nCol)
+ {
+ uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSeq(
+ new ScChart2LabeledDataSequence( m_pDocument));
+ if( xLabeledSeq.is())
+ {
+ aVec.push_back( xLabeledSeq );
+ if( bSeries )
+ {
+ ScRangeListRef aColRanges = new ScRangeList;
+ // one single sheet selected assumed for now
+ aColRanges->Append( ScRange( nCol, p->aStart.Row(),
+ p->aStart.Tab(), nCol, p->aStart.Row(),
+ p->aStart.Tab()));
+ // TEST: add range two times, once as label, once as data
+ // TODO: create pure Numerical and Text sequences if possible
+ uno::Reference< chart2::data::XDataSequence > xLabel(
+ new ScChart2DataSequence( m_pDocument, aColRanges));
+
+ // set role
+ uno::Reference< beans::XPropertySet > xProp( xLabel, uno::UNO_QUERY );
+ if( xProp.is())
+ xProp->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" )),
+ ::uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "label" ))));
+
+ xLabeledSeq->setLabel( xLabel );
+ }
+
+ ScRangeListRef aColRanges = new ScRangeList;
+
+ // one single sheet selected assumed for now
+ aColRanges->Append( ScRange( nCol, p->aStart.Row() + 1,
+ p->aStart.Tab(), nCol, p->aEnd.Row(),
+ p->aStart.Tab()));
+ uno::Reference< chart2::data::XDataSequence > xData(
+ new ScChart2DataSequence( m_pDocument, aColRanges));
+
+ // set role
+ uno::Reference< beans::XPropertySet > xProp( xData, uno::UNO_QUERY );
+ if( xProp.is())
+ xProp->setPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Role" )),
+ ::uno::makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "values" ))));
+
+ xLabeledSeq->setValues( xData );
+
+ bSeries = true;
+ }
+ }
+ }
+ uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence> > aSequences(
+ aVec.size());
+ uno::Reference< chart2::data::XLabeledDataSequence> * pArr = aSequences.getArray();
+ sal_Int32 j = 0;
+ for ( tVec::const_iterator iSeq = aVec.begin(); iSeq != aVec.end();
+ ++iSeq, ++j)
+ {
+ pArr[j] = *iSeq;
+ }
+ return aSequences;*/
+}
+
+void ScChart2DataSource::AddLabeledSequence(const uno::Reference < chart2::data::XLabeledDataSequence >& xNew)
+{
+ m_aLabeledSequences.push_back(xNew);
+}
+
+// LabeledDataSequence =======================================================
+
+ScChart2LabeledDataSequence::ScChart2LabeledDataSequence(
+ ScDocument* pDoc ) :
+ m_pDocument( pDoc )
+{
+ if ( m_pDocument )
+ m_pDocument->AddUnoObject( *this);
+}
+
+ScChart2LabeledDataSequence::~ScChart2LabeledDataSequence()
+{
+ if ( m_pDocument )
+ m_pDocument->RemoveUnoObject( *this);
+}
+
+// SfxListener -----------------------------------------------------------
+
+void ScChart2LabeledDataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ SolarMutexGuard aGuard;
+ m_pDocument = NULL;
+ }
+}
+
+// XLabeledDataSequence --------------------------------------------------
+
+uno::Reference< chart2::data::XDataSequence > SAL_CALL ScChart2LabeledDataSequence::getValues()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return m_aData;
+}
+
+void SAL_CALL ScChart2LabeledDataSequence::setValues(
+ const uno::Reference< chart2::data::XDataSequence >& xSequence )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ m_aData = xSequence;
+}
+
+uno::Reference< chart2::data::XDataSequence > SAL_CALL ScChart2LabeledDataSequence::getLabel()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return m_aLabel;
+}
+
+void SAL_CALL ScChart2LabeledDataSequence::setLabel(
+ const uno::Reference< chart2::data::XDataSequence >& xSequence )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ m_aLabel = xSequence;
+}
+
+// XCloneable ================================================================
+
+uno::Reference< util::XCloneable > SAL_CALL ScChart2LabeledDataSequence::createClone()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< util::XCloneable > xToClone(m_aData, uno::UNO_QUERY);
+ if (xToClone.is())
+ {
+ ScChart2LabeledDataSequence* pRet = new ScChart2LabeledDataSequence(m_pDocument);
+ uno::Reference< chart2::data::XDataSequence > xSequence(xToClone->createClone(), uno::UNO_QUERY);
+ pRet->setValues(xSequence);
+ xToClone.set(m_aLabel, uno::UNO_QUERY);
+ if(xToClone.is())
+ {
+ xSequence.set(xToClone->createClone(), uno::UNO_QUERY);
+ pRet->setLabel(xSequence);
+ }
+ return pRet;
+ }
+ return NULL;
+}
+
+// XModifyBroadcaster ========================================================
+
+void SAL_CALL ScChart2LabeledDataSequence::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ // quick'n dirty: just add the listener to each DataSequence
+
+ uno::Reference<util::XModifyBroadcaster> xDataBroadcaster( m_aData, uno::UNO_QUERY );
+ if ( xDataBroadcaster.is() )
+ xDataBroadcaster->addModifyListener( aListener );
+ uno::Reference<util::XModifyBroadcaster> xLabelBroadcaster( m_aLabel, uno::UNO_QUERY );
+ if ( xLabelBroadcaster.is() )
+ xLabelBroadcaster->addModifyListener( aListener );
+}
+
+void SAL_CALL ScChart2LabeledDataSequence::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ uno::Reference<util::XModifyBroadcaster> xDataBroadcaster( m_aData, uno::UNO_QUERY );
+ if ( xDataBroadcaster.is() )
+ xDataBroadcaster->removeModifyListener( aListener );
+ uno::Reference<util::XModifyBroadcaster> xLabelBroadcaster( m_aLabel, uno::UNO_QUERY );
+ if ( xLabelBroadcaster.is() )
+ xLabelBroadcaster->removeModifyListener( aListener );
+}
+
+// DataSequence ==============================================================
+
+ScChart2DataSequence::Item::Item() :
+ mfValue(0.0), mbIsValue(false)
+{
+ ::rtl::math::setNan(&mfValue);
+}
+
+ScChart2DataSequence::HiddenRangeListener::HiddenRangeListener(ScChart2DataSequence& rParent) :
+ mrParent(rParent)
+{
+}
+
+ScChart2DataSequence::HiddenRangeListener::~HiddenRangeListener()
+{
+}
+
+void ScChart2DataSequence::HiddenRangeListener::notify()
+{
+ mrParent.setDataChangedHint(true);
+}
+
+ScChart2DataSequence::ScChart2DataSequence( ScDocument* pDoc,
+ const uno::Reference < chart2::data::XDataProvider >& xDP,
+ vector<ScSharedTokenRef>* pTokens,
+ bool bIncludeHiddenCells )
+ : m_bIncludeHiddenCells( bIncludeHiddenCells)
+ , m_nObjectId( 0 )
+ , m_pDocument( pDoc)
+ , m_pTokens(pTokens)
+ , m_pRangeIndices(NULL)
+ , m_pExtRefListener(NULL)
+ , m_xDataProvider( xDP)
+ , m_aPropSet(lcl_GetDataSequencePropertyMap())
+ , m_pHiddenListener(NULL)
+ , m_pValueListener( NULL )
+ , m_bGotDataChangedHint(false)
+ , m_bExtDataRebuildQueued(false)
+{
+ DBG_ASSERT(pTokens, "reference token list is null");
+
+ if ( m_pDocument )
+ {
+ m_pDocument->AddUnoObject( *this);
+ m_nObjectId = m_pDocument->GetNewUnoId();
+ }
+ // FIXME: real implementation of identifier and it's mapping to ranges.
+ // Reuse ScChartListener?
+
+ // BM: don't use names of named ranges but the UI range strings
+// String aStr;
+// rRangeList->Format( aStr, SCR_ABS_3D, m_pDocument );
+// m_aIdentifier = ::rtl::OUString( aStr );
+
+// m_aIdentifier = ::rtl::OUString::createFromAscii( "ID_");
+// static sal_Int32 nID = 0;
+// m_aIdentifier += ::rtl::OUString::valueOf( ++nID);
+}
+
+ScChart2DataSequence::~ScChart2DataSequence()
+{
+ if ( m_pDocument )
+ {
+ m_pDocument->RemoveUnoObject( *this);
+ if (m_pHiddenListener.get())
+ {
+ ScChartListenerCollection* pCLC = m_pDocument->GetChartListenerCollection();
+ if (pCLC)
+ pCLC->EndListeningHiddenRange(m_pHiddenListener.get());
+ }
+ StopListeningToAllExternalRefs();
+ }
+
+ delete m_pValueListener;
+}
+
+void ScChart2DataSequence::RefChanged()
+{
+ if( m_pValueListener && m_aValueListeners.Count() != 0 )
+ {
+ m_pValueListener->EndListeningAll();
+
+ if( m_pDocument )
+ {
+ ScChartListenerCollection* pCLC = NULL;
+ if (m_pHiddenListener.get())
+ {
+ pCLC = m_pDocument->GetChartListenerCollection();
+ if (pCLC)
+ pCLC->EndListeningHiddenRange(m_pHiddenListener.get());
+ }
+
+ vector<ScSharedTokenRef>::const_iterator itr = m_pTokens->begin(), itrEnd = m_pTokens->end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScRange aRange;
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
+ continue;
+
+ m_pDocument->StartListeningArea(aRange, m_pValueListener);
+ if (pCLC)
+ pCLC->StartListeningHiddenRange(aRange, m_pHiddenListener.get());
+ }
+ }
+ }
+}
+
+void ScChart2DataSequence::BuildDataCache()
+{
+ m_bExtDataRebuildQueued = false;
+
+ if (!m_aDataArray.empty())
+ return;
+
+ if (!m_pTokens.get())
+ {
+ DBG_ERROR("m_pTokens == NULL! Something is wrong.");
+ return;
+ }
+
+ StopListeningToAllExternalRefs();
+
+ ::std::list<sal_Int32> aHiddenValues;
+ sal_Int32 nDataCount = 0;
+ sal_Int32 nHiddenValueCount = 0;
+
+ for (vector<ScSharedTokenRef>::const_iterator itr = m_pTokens->begin(), itrEnd = m_pTokens->end();
+ itr != itrEnd; ++itr)
+ {
+ if (ScRefTokenHelper::isExternalRef(*itr))
+ {
+ nDataCount += FillCacheFromExternalRef(*itr);
+ }
+ else
+ {
+ ScRange aRange;
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
+ continue;
+
+ SCCOL nLastCol = -1;
+ SCROW nLastRow = -1;
+ for (SCTAB nTab = aRange.aStart.Tab(); nTab <= aRange.aEnd.Tab(); ++nTab)
+ {
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ {
+ for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
+ {
+ bool bColHidden = m_pDocument->ColHidden(nCol, nTab, nLastCol);
+ bool bRowHidden = m_pDocument->RowHidden(nRow, nTab, nLastRow);
+
+ if (bColHidden || bRowHidden)
+ {
+ // hidden cell
+ ++nHiddenValueCount;
+ aHiddenValues.push_back(nDataCount-1);
+
+ if( !m_bIncludeHiddenCells )
+ continue;
+ }
+
+ m_aDataArray.push_back(Item());
+ Item& rItem = m_aDataArray.back();
+ ++nDataCount;
+
+ ScAddress aAdr(nCol, nRow, nTab);
+ ScBaseCell* pCell = m_pDocument->GetCell(aAdr);
+ if (!pCell)
+ continue;
+
+ if (pCell->HasStringData())
+ rItem.maString = pCell->GetStringData();
+ else
+ {
+ String aStr;
+ m_pDocument->GetString(nCol, nRow, nTab, aStr);
+ rItem.maString = aStr;
+ }
+
+ switch (pCell->GetCellType())
+ {
+ case CELLTYPE_VALUE:
+ rItem.mfValue = static_cast< ScValueCell*>(pCell)->GetValue();
+ rItem.mbIsValue = true;
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ USHORT nErr = pFCell->GetErrCode();
+ if (nErr)
+ break;
+
+ if (pFCell->HasValueData())
+ {
+ rItem.mfValue = pFCell->GetValue();
+ rItem.mbIsValue = true;
+ }
+ }
+ break;
+#if DBG_UTIL
+ case CELLTYPE_DESTROYED:
+#endif
+ case CELLTYPE_EDIT:
+ case CELLTYPE_NONE:
+ case CELLTYPE_NOTE:
+ case CELLTYPE_STRING:
+ case CELLTYPE_SYMBOLS:
+ default:
+ ; // do nothing
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // convert the hidden cell list to sequence.
+ m_aHiddenValues.realloc(nHiddenValueCount);
+ sal_Int32* pArr = m_aHiddenValues.getArray();
+ ::std::list<sal_Int32>::const_iterator itr = aHiddenValues.begin(), itrEnd = aHiddenValues.end();
+ for (;itr != itrEnd; ++itr, ++pArr)
+ *pArr = *itr;
+
+ // Clear the data series cache when the array is re-built.
+ m_aMixedDataCache.realloc(0);
+}
+
+void ScChart2DataSequence::RebuildDataCache()
+{
+ if (!m_bExtDataRebuildQueued)
+ {
+ m_aDataArray.clear();
+ m_pDocument->BroadcastUno(ScHint(SC_HINT_DATACHANGED, ScAddress(), NULL));
+ m_bExtDataRebuildQueued = true;
+ m_bGotDataChangedHint = true;
+ }
+}
+
+sal_Int32 ScChart2DataSequence::FillCacheFromExternalRef(const ScSharedTokenRef& pToken)
+{
+ ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
+ ScRange aRange;
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, pToken, true))
+ return 0;
+
+ sal_uInt16 nFileId = pToken->GetIndex();
+ const String& rTabName = pToken->GetString();
+ ScExternalRefCache::TokenArrayRef pArray = pRefMgr->getDoubleRefTokens(nFileId, rTabName, aRange, NULL);
+ if (!pArray)
+ // no external data exists for this range.
+ return 0;
+
+ // Start listening for this external document.
+ ExternalRefListener* pExtRefListener = GetExtRefListener();
+ pRefMgr->addLinkListener(nFileId, pExtRefListener);
+ pExtRefListener->addFileId(nFileId);
+
+ ScExternalRefCache::TableTypeRef pTable = pRefMgr->getCacheTable(nFileId, rTabName, false, NULL);
+ sal_Int32 nDataCount = 0;
+ for (FormulaToken* p = pArray->First(); p; p = pArray->Next())
+ {
+ // Cached external range is always represented as a single
+ // matrix token, although that might change in the future when
+ // we introduce a new token type to store multi-table range
+ // data.
+
+ if (p->GetType() != svMatrix)
+ {
+ DBG_ERROR("Cached array is not a matrix token.");
+ continue;
+ }
+
+ const ScMatrix* pMat = static_cast<ScToken*>(p)->GetMatrix();
+ SCSIZE nCSize, nRSize;
+ pMat->GetDimensions(nCSize, nRSize);
+ for (SCSIZE nC = 0; nC < nCSize; ++nC)
+ {
+ for (SCSIZE nR = 0; nR < nRSize; ++nR)
+ {
+ if (pMat->IsValue(nC, nR) || pMat->IsBoolean(nC, nR))
+ {
+ m_aDataArray.push_back(Item());
+ Item& rItem = m_aDataArray.back();
+ ++nDataCount;
+
+ rItem.mbIsValue = true;
+ rItem.mfValue = pMat->GetDouble(nC, nR);
+
+ SvNumberFormatter* pFormatter = m_pDocument->GetFormatTable();
+ if (pFormatter)
+ {
+ String aStr;
+ const double fVal = rItem.mfValue;
+ Color* pColor = NULL;
+ sal_uInt32 nFmt = 0;
+ if (pTable)
+ {
+ // Get the correct format index from the cache.
+ SCCOL nCol = aRange.aStart.Col() + static_cast<SCCOL>(nC);
+ SCROW nRow = aRange.aStart.Row() + static_cast<SCROW>(nR);
+ pTable->getCell(nCol, nRow, &nFmt);
+ }
+ pFormatter->GetOutputString(fVal, nFmt, aStr, &pColor);
+ rItem.maString = aStr;
+ }
+ }
+ else if (pMat->IsString(nC, nR))
+ {
+ m_aDataArray.push_back(Item());
+ Item& rItem = m_aDataArray.back();
+ ++nDataCount;
+
+ rItem.mbIsValue = false;
+ rItem.maString = pMat->GetString(nC, nR);
+ }
+ }
+ }
+ }
+ return nDataCount;
+}
+
+void ScChart2DataSequence::UpdateTokensFromRanges(const ScRangeList& rRanges)
+{
+ if (!m_pRangeIndices.get())
+ return;
+
+ sal_uInt32 nCount = rRanges.Count();
+ for (sal_uInt32 i = 0; i < nCount; ++i)
+ {
+ ScSharedTokenRef pToken;
+ ScRange* pRange = static_cast<ScRange*>(rRanges.GetObject(i));
+ DBG_ASSERT(pRange, "range object is NULL.");
+
+ ScRefTokenHelper::getTokenFromRange(pToken, *pRange);
+ sal_uInt32 nOrigPos = (*m_pRangeIndices)[i];
+ (*m_pTokens)[nOrigPos] = pToken;
+ }
+
+ RefChanged();
+
+ // any change of the range address is broadcast to value (modify) listeners
+ if ( m_aValueListeners.Count() )
+ m_bGotDataChangedHint = true;
+}
+
+ScChart2DataSequence::ExternalRefListener* ScChart2DataSequence::GetExtRefListener()
+{
+ if (!m_pExtRefListener.get())
+ m_pExtRefListener.reset(new ExternalRefListener(*this, m_pDocument));
+
+ return m_pExtRefListener.get();
+}
+
+void ScChart2DataSequence::StopListeningToAllExternalRefs()
+{
+ if (!m_pExtRefListener.get())
+ return;
+
+ const hash_set<sal_uInt16>& rFileIds = m_pExtRefListener->getAllFileIds();
+ hash_set<sal_uInt16>::const_iterator itr = rFileIds.begin(), itrEnd = rFileIds.end();
+ ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
+ for (; itr != itrEnd; ++itr)
+ pRefMgr->removeLinkListener(*itr, m_pExtRefListener.get());
+
+ m_pExtRefListener.reset(NULL);
+}
+
+void ScChart2DataSequence::CopyData(const ScChart2DataSequence& r)
+{
+ if (!m_pDocument)
+ {
+ DBG_ERROR("document instance is NULL!?");
+ return;
+ }
+
+ list<Item> aDataArray(r.m_aDataArray);
+ m_aDataArray.swap(aDataArray);
+
+ m_aHiddenValues = r.m_aHiddenValues;
+ m_aRole = r.m_aRole;
+
+ if (r.m_pRangeIndices.get())
+ m_pRangeIndices.reset(new vector<sal_uInt32>(*r.m_pRangeIndices));
+
+ if (r.m_pExtRefListener.get())
+ {
+ // Re-register all external files that the old instance was
+ // listening to.
+
+ ScExternalRefManager* pRefMgr = m_pDocument->GetExternalRefManager();
+ m_pExtRefListener.reset(new ExternalRefListener(*this, m_pDocument));
+ const hash_set<sal_uInt16>& rFileIds = r.m_pExtRefListener->getAllFileIds();
+ hash_set<sal_uInt16>::const_iterator itr = rFileIds.begin(), itrEnd = rFileIds.end();
+ for (; itr != itrEnd; ++itr)
+ {
+ pRefMgr->addLinkListener(*itr, m_pExtRefListener.get());
+ m_pExtRefListener->addFileId(*itr);
+ }
+ }
+}
+
+void ScChart2DataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = static_cast<const SfxSimpleHint&>(rHint).GetId();
+ if ( nId ==SFX_HINT_DYING )
+ {
+ m_pDocument = NULL;
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ {
+ // delayed broadcast as in ScCellRangesBase
+
+ if ( m_bGotDataChangedHint && m_pDocument )
+ {
+ m_aDataArray.clear();
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+
+ if( m_pDocument )
+ {
+ for ( USHORT n=0; n<m_aValueListeners.Count(); n++ )
+ m_pDocument->AddUnoListenerCall( *m_aValueListeners[n], aEvent );
+ }
+
+ m_bGotDataChangedHint = false;
+ }
+ }
+ else if ( nId == SC_HINT_CALCALL )
+ {
+ // broadcast from DoHardRecalc - set m_bGotDataChangedHint
+ // (SFX_HINT_DATACHANGED follows separately)
+
+ if ( m_aValueListeners.Count() )
+ m_bGotDataChangedHint = true;
+ }
+ }
+ else if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+ // Create a range list from the token list, have the range list
+ // updated, and bring the change back to the token list.
+
+ ScRangeList aRanges;
+ m_pRangeIndices.reset(new vector<sal_uInt32>());
+ vector<ScSharedTokenRef>::const_iterator itrBeg = m_pTokens->begin(), itrEnd = m_pTokens->end();
+ for (vector<ScSharedTokenRef>::const_iterator itr = itrBeg ;itr != itrEnd; ++itr)
+ {
+ if (!ScRefTokenHelper::isExternalRef(*itr))
+ {
+ ScRange aRange;
+ ScRefTokenHelper::getRangeFromToken(aRange, *itr);
+ aRanges.Append(aRange);
+ sal_uInt32 nPos = distance(itrBeg, itr);
+ m_pRangeIndices->push_back(nPos);
+ }
+ }
+
+ DBG_ASSERT(m_pRangeIndices->size() == static_cast<size_t>(aRanges.Count()),
+ "range list and range index list have different sizes.");
+
+ auto_ptr<ScRangeList> pUndoRanges;
+ if ( m_pDocument->HasUnoRefUndo() )
+ pUndoRanges.reset(new ScRangeList(aRanges));
+
+ const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+ bool bChanged = aRanges.UpdateReference(
+ rRef.GetMode(), m_pDocument, rRef.GetRange(), rRef.GetDx(), rRef.GetDy(), rRef.GetDz());
+
+ if (bChanged)
+ {
+ DBG_ASSERT(m_pRangeIndices->size() == static_cast<size_t>(aRanges.Count()),
+ "range list and range index list have different sizes after the reference update.");
+
+ // Bring the change back from the range list to the token list.
+ UpdateTokensFromRanges(aRanges);
+
+ if (pUndoRanges.get())
+ m_pDocument->AddUnoRefChange(m_nObjectId, *pUndoRanges);
+ }
+ }
+ else if ( rHint.ISA( ScUnoRefUndoHint ) )
+ {
+ const ScUnoRefUndoHint& rUndoHint = static_cast<const ScUnoRefUndoHint&>(rHint);
+
+ do
+ {
+ if (rUndoHint.GetObjectId() != m_nObjectId)
+ break;
+
+ // The hint object provides the old ranges. Restore the old state
+ // from these ranges.
+
+ if (!m_pRangeIndices.get() || m_pRangeIndices->empty())
+ {
+ DBG_ERROR(" faulty range indices");
+ break;
+ }
+
+ const ScRangeList& rRanges = rUndoHint.GetRanges();
+
+ sal_uInt32 nCount = rRanges.Count();
+ if (nCount != m_pRangeIndices->size())
+ {
+ DBG_ERROR("range count and range index count differ.");
+ break;
+ }
+
+ UpdateTokensFromRanges(rRanges);
+ }
+ while (false);
+ }
+}
+
+
+IMPL_LINK( ScChart2DataSequence, ValueListenerHdl, SfxHint*, pHint )
+{
+ if ( m_pDocument && pHint && pHint->ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint*)pHint)->GetId() & (SC_HINT_DATACHANGED | SC_HINT_DYING) )
+ {
+ // This may be called several times for a single change, if several formulas
+ // in the range are notified. So only a flag is set that is checked when
+ // SFX_HINT_DATACHANGED is received.
+
+ setDataChangedHint(true);
+ }
+ return 0;
+}
+
+// ----------------------------------------------------------------------------
+
+ScChart2DataSequence::ExternalRefListener::ExternalRefListener(
+ ScChart2DataSequence& rParent, ScDocument* pDoc) :
+ ScExternalRefManager::LinkListener(),
+ mrParent(rParent),
+ mpDoc(pDoc)
+{
+}
+
+ScChart2DataSequence::ExternalRefListener::~ExternalRefListener()
+{
+ if (!mpDoc || mpDoc->IsInDtorClear())
+ // The document is being destroyed. Do nothing.
+ return;
+
+ // Make sure to remove all pointers to this object.
+ mpDoc->GetExternalRefManager()->removeLinkListener(this);
+}
+
+void ScChart2DataSequence::ExternalRefListener::notify(sal_uInt16 nFileId, ScExternalRefManager::LinkUpdateType eType)
+{
+ switch (eType)
+ {
+ case ScExternalRefManager::LINK_MODIFIED:
+ {
+ if (maFileIds.count(nFileId))
+ // We are listening to this external document.
+ mrParent.RebuildDataCache();
+ }
+ break;
+ case ScExternalRefManager::LINK_BROKEN:
+ removeFileId(nFileId);
+ break;
+ }
+}
+
+void ScChart2DataSequence::ExternalRefListener::addFileId(sal_uInt16 nFileId)
+{
+ maFileIds.insert(nFileId);
+}
+
+void ScChart2DataSequence::ExternalRefListener::removeFileId(sal_uInt16 nFileId)
+{
+ maFileIds.erase(nFileId);
+}
+
+const hash_set<sal_uInt16>& ScChart2DataSequence::ExternalRefListener::getAllFileIds()
+{
+ return maFileIds;
+}
+
+// ----------------------------------------------------------------------------
+
+uno::Sequence< uno::Any> SAL_CALL ScChart2DataSequence::getData()
+ throw ( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ throw uno::RuntimeException();
+
+ BuildDataCache();
+
+ if (!m_aMixedDataCache.getLength())
+ {
+ // Build a cache for the 1st time...
+
+ sal_Int32 nCount = m_aDataArray.size();
+ m_aMixedDataCache.realloc(nCount);
+ uno::Any* pArr = m_aMixedDataCache.getArray();
+ ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end();
+ for (; itr != itrEnd; ++itr, ++pArr)
+ {
+ if (itr->mbIsValue)
+ *pArr <<= itr->mfValue;
+ else
+ *pArr <<= itr->maString;
+ }
+ }
+ return m_aMixedDataCache;
+}
+
+// XNumericalDataSequence --------------------------------------------------
+
+uno::Sequence< double > SAL_CALL ScChart2DataSequence::getNumericalData()
+ throw ( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ throw uno::RuntimeException();
+
+ BuildDataCache();
+
+ double fNAN;
+ ::rtl::math::setNan(&fNAN);
+
+ sal_Int32 nCount = m_aDataArray.size();
+ uno::Sequence<double> aSeq(nCount);
+ double* pArr = aSeq.getArray();
+ ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end();
+ for (; itr != itrEnd; ++itr, ++pArr)
+ *pArr = itr->mbIsValue ? itr->mfValue : fNAN;
+
+ return aSeq;
+}
+
+// XTextualDataSequence --------------------------------------------------
+
+uno::Sequence< rtl::OUString > SAL_CALL ScChart2DataSequence::getTextualData( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ throw uno::RuntimeException();
+
+ BuildDataCache();
+
+ sal_Int32 nCount = m_aDataArray.size();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pArr = aSeq.getArray();
+ ::std::list<Item>::const_iterator itr = m_aDataArray.begin(), itrEnd = m_aDataArray.end();
+ for (; itr != itrEnd; ++itr, ++pArr)
+ *pArr = itr->maString;
+
+ return aSeq;
+}
+
+::rtl::OUString SAL_CALL ScChart2DataSequence::getSourceRangeRepresentation()
+ throw ( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ OUString aStr;
+ DBG_ASSERT( m_pDocument, "No Document -> no SourceRangeRepresentation" );
+ if (m_pDocument && m_pTokens.get())
+ lcl_convertTokensToString(aStr, *m_pTokens, m_pDocument);
+
+ return aStr;
+}
+
+namespace {
+
+/**
+ * This function object is used to accumulatively count the numbers of
+ * columns and rows in all reference tokens.
+ */
+class AccumulateRangeSize : public unary_function<ScSharedTokenRef, void>
+{
+public:
+ AccumulateRangeSize() :
+ mnCols(0), mnRows(0) {}
+
+ AccumulateRangeSize(const AccumulateRangeSize& r) :
+ mnCols(r.mnCols), mnRows(r.mnRows) {}
+
+ void operator() (const ScSharedTokenRef& pToken)
+ {
+ ScRange r;
+ bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
+ ScRefTokenHelper::getRangeFromToken(r, pToken, bExternal);
+ r.Justify();
+ mnCols += r.aEnd.Col() - r.aStart.Col() + 1;
+ mnRows += r.aEnd.Row() - r.aStart.Row() + 1;
+ }
+
+ SCCOL getCols() const { return mnCols; }
+ SCROW getRows() const { return mnRows; }
+private:
+ SCCOL mnCols;
+ SCROW mnRows;
+};
+
+/**
+ * This function object is used to generate label strings from a list of
+ * reference tokens.
+ */
+class GenerateLabelStrings : public unary_function<ScSharedTokenRef, void>
+{
+public:
+ GenerateLabelStrings(sal_Int32 nSize, chart2::data::LabelOrigin eOrigin, bool bColumn) :
+ mpLabels(new Sequence<OUString>(nSize)),
+ meOrigin(eOrigin),
+ mnCount(0),
+ mbColumn(bColumn) {}
+
+ GenerateLabelStrings(const GenerateLabelStrings& r) :
+ mpLabels(r.mpLabels),
+ meOrigin(r.meOrigin),
+ mnCount(r.mnCount),
+ mbColumn(r.mbColumn) {}
+
+ void operator() (const ScSharedTokenRef& pToken)
+ {
+ bool bExternal = ScRefTokenHelper::isExternalRef(pToken);
+ ScRange aRange;
+ ScRefTokenHelper::getRangeFromToken(aRange, pToken, bExternal);
+ OUString* pArr = mpLabels->getArray();
+ if (mbColumn)
+ {
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ {
+ if ( meOrigin != chart2::data::LabelOrigin_LONG_SIDE)
+ {
+ String aString = ScGlobal::GetRscString(STR_COLUMN);
+ aString += ' ';
+ ScAddress aPos( nCol, 0, 0 );
+ String aColStr;
+ aPos.Format( aColStr, SCA_VALID_COL, NULL );
+ aString += aColStr;
+ pArr[mnCount] = aString;
+ }
+ else //only indices for categories
+ pArr[mnCount] = String::CreateFromInt32( mnCount+1 );
+ ++mnCount;
+ }
+ }
+ else
+ {
+ for (sal_Int32 nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
+ {
+ if (meOrigin != chart2::data::LabelOrigin_LONG_SIDE)
+ {
+ String aString = ScGlobal::GetRscString(STR_ROW);
+ aString += ' ';
+ aString += String::CreateFromInt32( nRow+1 );
+ pArr[mnCount] = aString;
+ }
+ else //only indices for categories
+ pArr[mnCount] = String::CreateFromInt32( mnCount+1 );
+ ++mnCount;
+ }
+ }
+ }
+
+ Sequence<OUString> getLabels() const { return *mpLabels; }
+
+private:
+ GenerateLabelStrings(); // disabled
+
+ shared_ptr< Sequence<OUString> > mpLabels;
+ chart2::data::LabelOrigin meOrigin;
+ sal_Int32 mnCount;
+ bool mbColumn;
+};
+
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL ScChart2DataSequence::generateLabel(chart2::data::LabelOrigin eOrigin)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ throw uno::RuntimeException();
+
+ if (!m_pTokens.get())
+ return Sequence<OUString>();
+
+ // Determine the total size of all ranges.
+ AccumulateRangeSize func;
+ func = ::std::for_each(m_pTokens->begin(), m_pTokens->end(), func);
+ SCCOL nCols = func.getCols();
+ SCROW nRows = func.getRows();
+
+ // Detemine whether this is column-major or row-major.
+ bool bColumn = true;
+ if ((eOrigin == chart2::data::LabelOrigin_SHORT_SIDE) ||
+ (eOrigin == chart2::data::LabelOrigin_LONG_SIDE))
+ {
+ if (nRows > nCols)
+ {
+ if (eOrigin == chart2::data::LabelOrigin_SHORT_SIDE)
+ bColumn = true;
+ else
+ bColumn = false;
+ }
+ else if (nCols > nRows)
+ {
+ if (eOrigin == chart2::data::LabelOrigin_SHORT_SIDE)
+ bColumn = false;
+ else
+ bColumn = true;
+ }
+ else
+ return Sequence<OUString>();
+ }
+
+ // Generate label strings based on the info so far.
+ sal_Int32 nCount = bColumn ? nCols : nRows;
+ GenerateLabelStrings genLabels(nCount, eOrigin, bColumn);
+ genLabels = ::std::for_each(m_pTokens->begin(), m_pTokens->end(), genLabels);
+ Sequence<OUString> aSeq = genLabels.getLabels();
+
+ return aSeq;
+}
+
+::sal_Int32 SAL_CALL ScChart2DataSequence::getNumberFormatKeyByIndex( ::sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException,
+ uno::RuntimeException)
+{
+ // index -1 means a heuristic value for the entire sequence
+ bool bGetSeriesFormat = (nIndex == -1);
+ sal_Int32 nResult = 0;
+
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument || !m_pTokens.get())
+ return nResult;
+
+ sal_Int32 nCount = 0;
+ bool bFound = false;
+ ScRangePtr p;
+
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( lcl_GetSpreadSheetDocument( m_pDocument ));
+ if (!xSpreadDoc.is())
+ return nResult;
+
+ uno::Reference<container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
+ if (!xIndex.is())
+ return nResult;
+
+ ScRangeList aRanges;
+ ScRefTokenHelper::getRangeListFromTokens(aRanges, *m_pTokens);
+ uno::Reference< table::XCellRange > xSheet;
+ for ( p = aRanges.First(); p && !bFound; p = aRanges.Next())
+ {
+ // TODO: use DocIter?
+ table::CellAddress aStart, aEnd;
+ ScUnoConversion::FillApiAddress( aStart, p->aStart );
+ ScUnoConversion::FillApiAddress( aEnd, p->aEnd );
+ for ( sal_Int16 nSheet = aStart.Sheet; nSheet <= aEnd.Sheet && !bFound; ++nSheet)
+ {
+ xSheet.set(xIndex->getByIndex(nSheet), uno::UNO_QUERY);
+ for ( sal_Int32 nCol = aStart.Column; nCol <= aEnd.Column && !bFound; ++nCol)
+ {
+ for ( sal_Int32 nRow = aStart.Row; nRow <= aEnd.Row && !bFound; ++nRow)
+ {
+ if( bGetSeriesFormat )
+ {
+ // TODO: use nicer heuristic
+ // return format of first non-empty cell
+ uno::Reference< text::XText > xText(
+ xSheet->getCellByPosition(nCol, nRow), uno::UNO_QUERY);
+ if (xText.is() && xText->getString().getLength())
+ {
+ uno::Reference< beans::XPropertySet > xProp(xText, uno::UNO_QUERY);
+ if( xProp.is())
+ xProp->getPropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormat"))) >>= nResult;
+ bFound = true;
+ break;
+ }
+ }
+ else if( nCount == nIndex )
+ {
+ uno::Reference< beans::XPropertySet > xProp(
+ xSheet->getCellByPosition(nCol, nRow), uno::UNO_QUERY);
+ if( xProp.is())
+ xProp->getPropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NumberFormat"))) >>= nResult;
+ bFound = true;
+ break;
+ }
+ ++nCount;
+ }
+ }
+ }
+ }
+
+ return nResult;
+}
+
+// XCloneable ================================================================
+
+uno::Reference< util::XCloneable > SAL_CALL ScChart2DataSequence::createClone()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ auto_ptr< vector<ScSharedTokenRef> > pTokensNew;
+ if (m_pTokens.get())
+ {
+ // Clone tokens.
+ pTokensNew.reset(new vector<ScSharedTokenRef>);
+ pTokensNew->reserve(m_pTokens->size());
+ vector<ScSharedTokenRef>::const_iterator itr = m_pTokens->begin(), itrEnd = m_pTokens->end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScSharedTokenRef p(static_cast<ScToken*>((*itr)->Clone()));
+ pTokensNew->push_back(p);
+ }
+ }
+
+ auto_ptr<ScChart2DataSequence> p(new ScChart2DataSequence(m_pDocument, m_xDataProvider, pTokensNew.release(), m_bIncludeHiddenCells));
+ p->CopyData(*this);
+ Reference< util::XCloneable > xClone(p.release());
+
+ return xClone;
+}
+
+// XModifyBroadcaster ========================================================
+
+void SAL_CALL ScChart2DataSequence::addModifyListener( const uno::Reference< util::XModifyListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ // like ScCellRangesBase::addModifyListener
+ SolarMutexGuard aGuard;
+ if (!m_pTokens.get() || m_pTokens->empty())
+ return;
+
+ ScRangeList aRanges;
+ ScRefTokenHelper::getRangeListFromTokens(aRanges, *m_pTokens);
+ uno::Reference<util::XModifyListener> *pObj =
+ new uno::Reference<util::XModifyListener>( aListener );
+ m_aValueListeners.Insert( pObj, m_aValueListeners.Count() );
+
+ if ( m_aValueListeners.Count() == 1 )
+ {
+ if (!m_pValueListener)
+ m_pValueListener = new ScLinkListener( LINK( this, ScChart2DataSequence, ValueListenerHdl ) );
+
+ if (!m_pHiddenListener.get())
+ m_pHiddenListener.reset(new HiddenRangeListener(*this));
+
+ if( m_pDocument )
+ {
+ ScChartListenerCollection* pCLC = m_pDocument->GetChartListenerCollection();
+ vector<ScSharedTokenRef>::const_iterator itr = m_pTokens->begin(), itrEnd = m_pTokens->end();
+ for (; itr != itrEnd; ++itr)
+ {
+ ScRange aRange;
+ if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
+ continue;
+
+ m_pDocument->StartListeningArea( aRange, m_pValueListener );
+ if (pCLC)
+ pCLC->StartListeningHiddenRange(aRange, m_pHiddenListener.get());
+ }
+ }
+
+ acquire(); // don't lose this object (one ref for all listeners)
+ }
+}
+
+void SAL_CALL ScChart2DataSequence::removeModifyListener( const uno::Reference< util::XModifyListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ // like ScCellRangesBase::removeModifyListener
+
+ SolarMutexGuard aGuard;
+ if (!m_pTokens.get() || m_pTokens->empty())
+ return;
+
+ acquire(); // in case the listeners have the last ref - released below
+
+ USHORT nCount = m_aValueListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XModifyListener> *pObj = m_aValueListeners[n];
+ if ( *pObj == aListener )
+ {
+ m_aValueListeners.DeleteAndDestroy( n );
+
+ if ( m_aValueListeners.Count() == 0 )
+ {
+ if (m_pValueListener)
+ m_pValueListener->EndListeningAll();
+
+ if (m_pHiddenListener.get() && m_pDocument)
+ {
+ ScChartListenerCollection* pCLC = m_pDocument->GetChartListenerCollection();
+ if (pCLC)
+ pCLC->EndListeningHiddenRange(m_pHiddenListener.get());
+ }
+
+ release(); // release the ref for the listeners
+ }
+
+ break;
+ }
+ }
+
+ release(); // might delete this object
+}
+
+// DataSequence XPropertySet -------------------------------------------------
+
+uno::Reference< beans::XPropertySetInfo> SAL_CALL
+ScChart2DataSequence::getPropertySetInfo() throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( m_aPropSet.getPropertyMap() );
+ return aRef;
+}
+
+
+void SAL_CALL ScChart2DataSequence::setPropertyValue(
+ const ::rtl::OUString& rPropertyName, const uno::Any& rValue)
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_ROLE)))
+ {
+ if ( !(rValue >>= m_aRole))
+ throw lang::IllegalArgumentException();
+ }
+ else if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS)))
+ {
+ sal_Bool bOldValue = m_bIncludeHiddenCells;
+ if ( !(rValue >>= m_bIncludeHiddenCells))
+ throw lang::IllegalArgumentException();
+ if( bOldValue != m_bIncludeHiddenCells )
+ m_aDataArray.clear();//data array is dirty now
+ }
+ else
+ throw beans::UnknownPropertyException();
+ // TODO: support optional properties
+}
+
+
+uno::Any SAL_CALL ScChart2DataSequence::getPropertyValue(
+ const ::rtl::OUString& rPropertyName)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aRet;
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_ROLE)))
+ aRet <<= m_aRole;
+ else if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS)))
+ aRet <<= m_bIncludeHiddenCells;
+ else if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SC_UNONAME_HIDDENVALUES)))
+ {
+ // This property is read-only thus cannot be set externally via
+ // setPropertyValue(...).
+ BuildDataCache();
+ aRet <<= m_aHiddenValues;
+ }
+ else
+ throw beans::UnknownPropertyException();
+ // TODO: support optional properties
+ return aRet;
+}
+
+
+void SAL_CALL ScChart2DataSequence::addPropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener>& /*xListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2DataSequence::removePropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2DataSequence::addVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2DataSequence::removeVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+void ScChart2DataSequence::setDataChangedHint(bool b)
+{
+ m_bGotDataChangedHint = b;
+}
+
+// XUnoTunnel
+
+// sal_Int64 SAL_CALL ScChart2DataSequence::getSomething(
+// const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+// {
+// if ( rId.getLength() == 16 &&
+// 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+// rId.getConstArray(), 16 ) )
+// {
+// return (sal_Int64)this;
+// }
+// return 0;
+// }
+
+// // static
+// const uno::Sequence<sal_Int8>& ScChart2DataSequence::getUnoTunnelId()
+// {
+// static uno::Sequence<sal_Int8> * pSeq = 0;
+// if( !pSeq )
+// {
+// osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+// if( !pSeq )
+// {
+// static uno::Sequence< sal_Int8 > aSeq( 16 );
+// rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+// pSeq = &aSeq;
+// }
+// }
+// return *pSeq;
+// }
+
+// // static
+// ScChart2DataSequence* ScChart2DataSequence::getImplementation( const uno::Reference<uno::XInterface> xObj )
+// {
+// ScChart2DataSequence* pRet = NULL;
+// uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+// if (xUT.is())
+// pRet = (ScChart2DataSequence*) xUT->getSomething( getUnoTunnelId() );
+// return pRet;
+// }
+
+#if USE_CHART2_EMPTYDATASEQUENCE
+// DataSequence ==============================================================
+
+ScChart2EmptyDataSequence::ScChart2EmptyDataSequence( ScDocument* pDoc,
+ const uno::Reference < chart2::data::XDataProvider >& xDP,
+ const ScRangeListRef& rRangeList,
+ sal_Bool bColumn)
+ : m_bIncludeHiddenCells( sal_True)
+ , m_xRanges( rRangeList)
+ , m_pDocument( pDoc)
+ , m_xDataProvider( xDP)
+ , m_aPropSet(lcl_GetDataSequencePropertyMap())
+ , m_bColumn(bColumn)
+{
+ if ( m_pDocument )
+ m_pDocument->AddUnoObject( *this);
+ // FIXME: real implementation of identifier and it's mapping to ranges.
+ // Reuse ScChartListener?
+
+ // BM: don't use names of named ranges but the UI range strings
+// String aStr;
+// rRangeList->Format( aStr, SCR_ABS_3D, m_pDocument );
+// m_aIdentifier = ::rtl::OUString( aStr );
+
+// m_aIdentifier = ::rtl::OUString::createFromAscii( "ID_");
+// static sal_Int32 nID = 0;
+// m_aIdentifier += ::rtl::OUString::valueOf( ++nID);
+}
+
+
+ScChart2EmptyDataSequence::~ScChart2EmptyDataSequence()
+{
+ if ( m_pDocument )
+ m_pDocument->RemoveUnoObject( *this);
+}
+
+
+void ScChart2EmptyDataSequence::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ m_pDocument = NULL;
+ }
+}
+
+
+uno::Sequence< uno::Any> SAL_CALL ScChart2EmptyDataSequence::getData()
+ throw ( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ throw uno::RuntimeException();
+ return uno::Sequence< uno::Any>();
+}
+
+// XTextualDataSequence --------------------------------------------------
+
+uno::Sequence< rtl::OUString > SAL_CALL ScChart2EmptyDataSequence::getTextualData( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ throw uno::RuntimeException();
+
+ sal_Int32 nCount = 0;
+ ScRangePtr p;
+
+ DBG_ASSERT(m_xRanges->Count() == 1, "not handled count of ranges");
+
+ for ( p = m_xRanges->First(); p; p = m_xRanges->Next())
+ {
+ p->Justify();
+ // TODO: handle overlaping ranges?
+ nCount += m_bColumn ? p->aEnd.Col() - p->aStart.Col() + 1 : p->aEnd.Row() - p->aStart.Row() + 1;
+ }
+ uno::Sequence< rtl::OUString > aSeq( nCount);
+ rtl::OUString* pArr = aSeq.getArray();
+ nCount = 0;
+ for ( p = m_xRanges->First(); p; p = m_xRanges->Next())
+ {
+ if (m_bColumn)
+ {
+ for (SCCOL nCol = p->aStart.Col(); nCol <= p->aEnd.Col(); ++nCol)
+ {
+ String aString = ScGlobal::GetRscString(STR_COLUMN);
+ aString += ' ';
+ ScAddress aPos( nCol, 0, 0 );
+ String aColStr;
+ aPos.Format( aColStr, SCA_VALID_COL, NULL );
+ aString += aColStr;
+ pArr[nCount] = aString;
+ ++nCount;
+ }
+ }
+ else
+ {
+ sal_Int32 n = p->aEnd.Row() - p->aStart.Row() + 1;
+ for (sal_Int32 i = 0; i < n; ++i)
+ pArr[nCount++] = String::CreateFromInt32( i+1 );
+ }
+ }
+ return aSeq;
+}
+
+::rtl::OUString SAL_CALL ScChart2EmptyDataSequence::getSourceRangeRepresentation()
+ throw ( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aStr;
+ DBG_ASSERT( m_pDocument, "No Document -> no SourceRangeRepresentation" );
+ if( m_pDocument )
+ m_xRanges->Format( aStr, SCR_ABS_3D, m_pDocument, m_pDocument->GetAddressConvention() );
+ return aStr;
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL ScChart2EmptyDataSequence::generateLabel(chart2::data::LabelOrigin /*nOrigin*/)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence< ::rtl::OUString > aRet;
+ return aRet;
+}
+
+::sal_Int32 SAL_CALL ScChart2EmptyDataSequence::getNumberFormatKeyByIndex( ::sal_Int32 /*nIndex*/ )
+ throw (lang::IndexOutOfBoundsException,
+ uno::RuntimeException)
+{
+ sal_Int32 nResult = 0;
+
+ SolarMutexGuard aGuard;
+ if ( !m_pDocument)
+ return nResult;
+
+ return nResult;
+}
+
+// XCloneable ================================================================
+
+uno::Reference< util::XCloneable > SAL_CALL ScChart2EmptyDataSequence::createClone()
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (m_xDataProvider.is())
+ {
+ // copy properties
+ uno::Reference < util::XCloneable > xClone(new ScChart2EmptyDataSequence(m_pDocument, m_xDataProvider, new ScRangeList(*m_xRanges), m_bColumn));
+ uno::Reference< beans::XPropertySet > xProp( xClone, uno::UNO_QUERY );
+ if( xProp.is())
+ {
+ xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ROLE )),
+ uno::makeAny( m_aRole ));
+ xProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS )),
+ uno::makeAny( m_bIncludeHiddenCells ));
+ }
+ return xClone;
+ }
+ return uno::Reference< util::XCloneable >();
+}
+
+// XModifyBroadcaster ========================================================
+
+void SAL_CALL ScChart2EmptyDataSequence::addModifyListener( const uno::Reference< util::XModifyListener >& /*aListener*/ )
+ throw (uno::RuntimeException)
+{
+ // TODO: Implement
+}
+
+void SAL_CALL ScChart2EmptyDataSequence::removeModifyListener( const uno::Reference< util::XModifyListener >& /*aListener*/ )
+ throw (uno::RuntimeException)
+{
+ // TODO: Implement
+}
+
+// DataSequence XPropertySet -------------------------------------------------
+
+uno::Reference< beans::XPropertySetInfo> SAL_CALL
+ScChart2EmptyDataSequence::getPropertySetInfo() throw( uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( m_aPropSet.getPropertyMap() );
+ return aRef;
+}
+
+
+void SAL_CALL ScChart2EmptyDataSequence::setPropertyValue(
+ const ::rtl::OUString& rPropertyName, const uno::Any& rValue)
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_ROLE)))
+ {
+ if ( !(rValue >>= m_aRole))
+ throw lang::IllegalArgumentException();
+ }
+ else if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS)))
+ {
+ if ( !(rValue >>= m_bIncludeHiddenCells))
+ throw lang::IllegalArgumentException();
+ }
+ else
+ throw beans::UnknownPropertyException();
+ // TODO: support optional properties
+}
+
+
+uno::Any SAL_CALL ScChart2EmptyDataSequence::getPropertyValue(
+ const ::rtl::OUString& rPropertyName)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aRet;
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_ROLE)))
+ aRet <<= m_aRole;
+ else if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_UNONAME_INCLUDEHIDDENCELLS)))
+ aRet <<= m_bIncludeHiddenCells;
+ else
+ throw beans::UnknownPropertyException();
+ // TODO: support optional properties
+ return aRet;
+}
+
+
+void SAL_CALL ScChart2EmptyDataSequence::addPropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener>& /*xListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2EmptyDataSequence::removePropertyChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2EmptyDataSequence::addVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener>& /*rListener*/)
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+
+void SAL_CALL ScChart2EmptyDataSequence::removeVetoableChangeListener(
+ const ::rtl::OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener>& /*rListener*/ )
+ throw( beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ // FIXME: real implementation
+// throw uno::RuntimeException();
+ OSL_ENSURE( false, "Not yet implemented" );
+}
+
+// XUnoTunnel
+
+// sal_Int64 SAL_CALL ScChart2EmptyDataSequence::getSomething(
+// const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+// {
+// if ( rId.getLength() == 16 &&
+// 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+// rId.getConstArray(), 16 ) )
+// {
+// return (sal_Int64)this;
+// }
+// return 0;
+// }
+
+// // static
+// const uno::Sequence<sal_Int8>& ScChart2EmptyDataSequence::getUnoTunnelId()
+// {
+// static uno::Sequence<sal_Int8> * pSeq = 0;
+// if( !pSeq )
+// {
+// osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+// if( !pSeq )
+// {
+// static uno::Sequence< sal_Int8 > aSeq( 16 );
+// rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+// pSeq = &aSeq;
+// }
+// }
+// return *pSeq;
+// }
+
+// // static
+// ScChart2DataSequence* ScChart2EmptyDataSequence::getImplementation( const uno::Reference<uno::XInterface> xObj )
+// {
+// ScChart2DataSequence* pRet = NULL;
+// uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+// if (xUT.is())
+// pRet = (ScChart2EmptyDataSequence*) xUT->getSomething( getUnoTunnelId() );
+// return pRet;
+// }
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/chartuno.cxx b/sc/source/ui/unoobj/chartuno.cxx
new file mode 100644
index 000000000000..f5e7db756f4d
--- /dev/null
+++ b/sc/source/ui/unoobj/chartuno.cxx
@@ -0,0 +1,818 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+
+#include <svx/svditer.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/app.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <sot/clsids.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include "chartuno.hxx"
+#include "miscuno.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "undodat.hxx"
+#include "chartarr.hxx"
+#include "chartlis.hxx"
+#include "chart2uno.hxx"
+#include "convuno.hxx"
+
+using namespace com::sun::star;
+
+#define PROP_HANDLE_RELATED_CELLRANGES 1
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScChartObj, "ScChartObj", "com.sun.star.table.TableChart" )
+SC_SIMPLE_SERVICE_INFO( ScChartsObj, "ScChartsObj", "com.sun.star.table.TableCharts" )
+
+//------------------------------------------------------------------------
+
+SdrOle2Obj* lcl_FindChartObj( ScDocShell* pDocShell, SCTAB nTab, const String& rName )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage, "Page nicht gefunden");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+ if ( xObj.is() )
+ {
+ String aObjName = pDocShell->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj );
+ if ( aObjName == rName )
+ return (SdrOle2Obj*)pObject;
+ }
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+//------------------------------------------------------------------------
+
+ScChartsObj::ScChartsObj(ScDocShell* pDocSh, SCTAB nT) :
+ pDocShell( pDocSh ),
+ nTab( nT )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScChartsObj::~ScChartsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScChartsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! Referenz-Update
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+ScChartObj* ScChartsObj::GetObjectByIndex_Impl(long nIndex) const
+{
+ String aName;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage, "Page nicht gefunden");
+ if (pPage)
+ {
+ long nPos = 0;
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) )
+ {
+ if ( nPos == nIndex )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+ if ( xObj.is() )
+ aName = pDocShell->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj );
+ break; // nicht weitersuchen
+ }
+ ++nPos;
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+
+ if (aName.Len())
+ return new ScChartObj( pDocShell, nTab, aName );
+ return NULL;
+}
+
+ScChartObj* ScChartsObj::GetObjectByName_Impl(const rtl::OUString& aName) const
+{
+ String aNameString(aName);
+ if ( lcl_FindChartObj( pDocShell, nTab, aNameString ) )
+ return new ScChartObj( pDocShell, nTab, aNameString );
+ return NULL;
+}
+
+// XTableCharts
+
+void SAL_CALL ScChartsObj::addNewByName( const rtl::OUString& aName,
+ const awt::Rectangle& aRect,
+ const uno::Sequence<table::CellRangeAddress>& aRanges,
+ sal_Bool bColumnHeaders, sal_Bool bRowHeaders )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ return;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pModel = pDocShell->MakeDrawLayer();
+ SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage,"addChart: keine Page");
+ if (!pPage || !pDoc)
+ return;
+
+ // chart can't be inserted if any ole object with that name exists on any table
+ // (empty string: generate valid name)
+
+ String aNameString(aName);
+ SCTAB nDummy;
+ if ( aNameString.Len() && pModel->GetNamedObject( aNameString, OBJ_OLE2, nDummy ) )
+ {
+ // object exists - only RuntimeException is specified
+ throw uno::RuntimeException();
+ }
+
+ ScRangeList* pList = new ScRangeList;
+ USHORT nRangeCount = (USHORT)aRanges.getLength();
+ if (nRangeCount)
+ {
+ const table::CellRangeAddress* pAry = aRanges.getConstArray();
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ ScRange aRange( static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow, pAry[i].Sheet,
+ static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow, pAry[i].Sheet );
+ pList->Append( aRange );
+ }
+ }
+ ScRangeListRef xNewRanges( pList );
+
+ uno::Reference < embed::XEmbeddedObject > xObj;
+ ::rtl::OUString aTmp( aNameString );
+ if ( SvtModuleOptions().IsChart() )
+ xObj = pDocShell->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID ).GetByteSequence(), aTmp );
+ if ( xObj.is() )
+ {
+ String aObjName = aTmp; // wirklich eingefuegter Name...
+
+ // Rechteck anpassen
+ //! Fehler/Exception, wenn leer/ungueltig ???
+ Point aRectPos( aRect.X, aRect.Y );
+ if (aRectPos.X() < 0) aRectPos.X() = 0;
+ if (aRectPos.Y() < 0) aRectPos.Y() = 0;
+ Size aRectSize( aRect.Width, aRect.Height );
+ if (aRectSize.Width() <= 0) aRectSize.Width() = 5000; // Default-Groesse
+ if (aRectSize.Height() <= 0) aRectSize.Height() = 5000;
+ Rectangle aInsRect( aRectPos, aRectSize );
+
+ sal_Int64 nAspect(embed::Aspects::MSOLE_CONTENT);
+ MapUnit aMapUnit(VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ));
+ Size aSize(aInsRect.GetSize());
+ aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) );
+ awt::Size aSz;
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+
+ // Calc -> DataProvider
+ uno::Reference< chart2::data::XDataProvider > xDataProvider = new
+ ScChart2DataProvider( pDoc );
+ // Chart -> DataReceiver
+ uno::Reference< chart2::data::XDataReceiver > xReceiver;
+ uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY );
+ if( xCompSupp.is())
+ xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY );
+ if( xReceiver.is())
+ {
+ String sRangeStr;
+ xNewRanges->Format(sRangeStr, SCR_ABS_3D, pDoc);
+
+ // connect
+ if( sRangeStr.Len() )
+ xReceiver->attachDataProvider( xDataProvider );
+ else
+ sRangeStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "all" ) );
+
+ uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pDocShell->GetModel(), uno::UNO_QUERY );
+ xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier );
+
+ // set arguments
+ uno::Sequence< beans::PropertyValue > aArgs( 4 );
+ aArgs[0] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("CellRangeRepresentation"), -1,
+ uno::makeAny( ::rtl::OUString( sRangeStr )), beans::PropertyState_DIRECT_VALUE );
+ aArgs[1] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("HasCategories"), -1,
+ uno::makeAny( bRowHeaders ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[2] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("FirstCellAsLabel"), -1,
+ uno::makeAny( bColumnHeaders ), beans::PropertyState_DIRECT_VALUE );
+ aArgs[3] = beans::PropertyValue(
+ ::rtl::OUString::createFromAscii("DataRowSource"), -1,
+ uno::makeAny( chart::ChartDataRowSource_COLUMNS ), beans::PropertyState_DIRECT_VALUE );
+ xReceiver->setArguments( aArgs );
+ }
+
+ ScChartListener* pChartListener =
+ new ScChartListener( aObjName, pDoc, xNewRanges );
+ pDoc->GetChartListenerCollection()->Insert( pChartListener );
+ pChartListener->StartListeningTo();
+
+ SdrOle2Obj* pObj = new SdrOle2Obj( ::svt::EmbeddedObjectRef( xObj, embed::Aspects::MSOLE_CONTENT ), aObjName, aInsRect );
+
+ // set VisArea
+ if( xObj.is())
+ xObj->setVisualAreaSize( nAspect, aSz );
+
+ pPage->InsertObject( pObj );
+ pModel->AddUndo( new SdrUndoInsertObj( *pObj ) ); //! Undo-Kommentar?
+
+ // Dies veranlaesst Chart zum sofortigen Update
+ //SvData aEmpty;
+ //aIPObj->SendDataChanged( aEmpty );
+ }
+}
+
+void SAL_CALL ScChartsObj::removeByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aName);
+ SdrOle2Obj* pObj = lcl_FindChartObj( pDocShell, nTab, aNameString );
+ if (pObj)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pModel = pDoc->GetDrawLayer(); // ist nicht 0
+ SdrPage* pPage = pModel->GetPage(static_cast<sal_uInt16>(nTab)); // ist nicht 0
+
+ pModel->AddUndo( new SdrUndoRemoveObj( *pObj ) ); //! Undo-Kommentar?
+ pPage->RemoveObject( pObj->GetOrdNum() );
+
+ //! Notify etc.???
+ }
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScChartsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableChartsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScChartsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ INT32 nCount = 0;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage, "Page nicht gefunden");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) )
+ ++nCount;
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+ return nCount;
+}
+
+uno::Any SAL_CALL ScChartsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XTableChart> xChart(GetObjectByIndex_Impl(nIndex));
+ if (xChart.is())
+ return uno::makeAny(xChart);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScChartsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<table::XTableChart>*)0);
+}
+
+sal_Bool SAL_CALL ScChartsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCount() != 0;
+}
+
+uno::Any SAL_CALL ScChartsObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XTableChart> xChart(GetObjectByName_Impl(aName));
+ if (xChart.is())
+ return uno::makeAny(xChart);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScChartsObj::getElementNames() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ long nCount = getCount();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+
+ long nPos = 0;
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage, "Page nicht gefunden");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart(pObject) )
+ {
+ String aName;
+ uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObject)->GetObjRef();
+ if ( xObj.is() )
+ aName = pDocShell->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xObj );
+
+ DBG_ASSERT(nPos<nCount, "huch, verzaehlt?");
+ pAry[nPos++] = aName;
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ DBG_ASSERT(nPos==nCount, "nanu, verzaehlt?");
+
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+sal_Bool SAL_CALL ScChartsObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aName);
+ return ( lcl_FindChartObj( pDocShell, nTab, aNameString ) != NULL );
+}
+
+//------------------------------------------------------------------------
+
+ScChartObj::ScChartObj(ScDocShell* pDocSh, SCTAB nT, const String& rN)
+ :ScChartObj_Base( m_aMutex )
+ ,ScChartObj_PBase( ScChartObj_Base::rBHelper )
+ ,pDocShell( pDocSh )
+ ,nTab( nT )
+ ,aChartName( rN )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ uno::Sequence< table::CellRangeAddress > aInitialPropValue;
+ registerPropertyNoMember( ::rtl::OUString::createFromAscii( "RelatedCellRanges" ),
+ PROP_HANDLE_RELATED_CELLRANGES, beans::PropertyAttribute::MAYBEVOID,
+ ::getCppuType( &aInitialPropValue ), &aInitialPropValue );
+}
+
+ScChartObj::~ScChartObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScChartObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! Referenz-Update
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+void ScChartObj::GetData_Impl( ScRangeListRef& rRanges, bool& rColHeaders, bool& rRowHeaders ) const
+{
+ bool bFound = false;
+ ScDocument* pDoc = (pDocShell? pDocShell->GetDocument(): 0);
+
+ if( pDoc )
+ {
+ uno::Reference< chart2::XChartDocument > xChartDoc( pDoc->GetChartByName( aChartName ) );
+ if( xChartDoc.is() )
+ {
+ uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY );
+ uno::Reference< chart2::data::XDataProvider > xProvider = xChartDoc->getDataProvider();
+ if( xReceiver.is() && xProvider.is() )
+ {
+ uno::Sequence< beans::PropertyValue > aArgs( xProvider->detectArguments( xReceiver->getUsedData() ) );
+
+ rtl::OUString aRanges;
+ chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS;
+ bool bHasCategories=false;
+ bool bFirstCellAsLabel=false;
+ const beans::PropertyValue* pPropArray = aArgs.getConstArray();
+ long nPropCount = aArgs.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( "CellRangeRepresentation" ))
+ rProp.Value >>= aRanges;
+ else if (aPropName.EqualsAscii( "DataRowSource" ))
+ eDataRowSource = (chart::ChartDataRowSource)ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( "HasCategories" ))
+ bHasCategories = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( "FirstCellAsLabel" ))
+ bFirstCellAsLabel = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ }
+
+ if( chart::ChartDataRowSource_COLUMNS == eDataRowSource )
+ {
+ rColHeaders=bFirstCellAsLabel;
+ rRowHeaders=bHasCategories;
+ }
+ else
+ {
+ rColHeaders=bHasCategories;
+ rRowHeaders=bFirstCellAsLabel;
+ }
+ rRanges->Parse( aRanges, pDoc);
+ }
+ bFound = true;
+ }
+ }
+ if( !bFound )
+ {
+ rRanges = 0;
+ rColHeaders = false;
+ rRowHeaders = false;
+ }
+}
+
+void ScChartObj::Update_Impl( const ScRangeListRef& rRanges, bool bColHeaders, bool bRowHeaders )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ if (bUndo)
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoChartData( pDocShell, aChartName, rRanges, bColHeaders, bRowHeaders, FALSE ) );
+ }
+ pDoc->UpdateChartArea( aChartName, rRanges, bColHeaders, bRowHeaders, FALSE );
+ }
+}
+
+// ::comphelper::OPropertySetHelper
+
+::cppu::IPropertyArrayHelper& ScChartObj::getInfoHelper()
+{
+ return *ScChartObj_PABase::getArrayHelper();
+}
+
+void ScChartObj::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const uno::Any& rValue ) throw (uno::Exception)
+{
+ switch ( nHandle )
+ {
+ case PROP_HANDLE_RELATED_CELLRANGES:
+ {
+ uno::Sequence< table::CellRangeAddress > aCellRanges;
+ if ( rValue >>= aCellRanges )
+ {
+ ScRangeListRef rRangeList = new ScRangeList();
+ const table::CellRangeAddress* pCellRanges = aCellRanges.getArray();
+ sal_Int32 nCount = aCellRanges.getLength();
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ table::CellRangeAddress aCellRange = pCellRanges[ i ];
+ ScRange aRange;
+ ScUnoConversion::FillScRange( aRange, aCellRange );
+ rRangeList->Append( aRange );
+ }
+ ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL );
+ ScChartListenerCollection* pCollection = ( pDoc ? pDoc->GetChartListenerCollection() : NULL );
+ if ( pCollection )
+ {
+ pCollection->ChangeListening( aChartName, rRangeList );
+ }
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+void ScChartObj::getFastPropertyValue( uno::Any& rValue, sal_Int32 nHandle ) const
+{
+ switch ( nHandle )
+ {
+ case PROP_HANDLE_RELATED_CELLRANGES:
+ {
+ ScDocument* pDoc = ( pDocShell ? pDocShell->GetDocument() : NULL );
+ if ( pDoc )
+ {
+ ScRange aEmptyRange;
+ USHORT nIndex = 0;
+ ScChartListener aSearcher( aChartName, pDoc, aEmptyRange );
+ ScChartListenerCollection* pCollection = pDoc->GetChartListenerCollection();
+ if ( pCollection && pCollection->Search( &aSearcher, nIndex ) )
+ {
+ ScChartListener* pListener = static_cast< ScChartListener* >( pCollection->At( nIndex ) );
+ if ( pListener )
+ {
+ const ScRangeListRef& rRangeList = pListener->GetRangeList();
+ if ( rRangeList.Is() )
+ {
+ ULONG nCount = rRangeList->Count();
+ uno::Sequence< table::CellRangeAddress > aCellRanges( nCount );
+ table::CellRangeAddress* pCellRanges = aCellRanges.getArray();
+ for ( USHORT i = 0; i < nCount; ++i )
+ {
+ ScRange aRange( *rRangeList->GetObject( i ) );
+ table::CellRangeAddress aCellRange;
+ ScUnoConversion::FillApiRange( aCellRange, aRange );
+ pCellRanges[ i ] = aCellRange;
+ }
+ rValue <<= aCellRanges;
+ }
+ }
+ }
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+}
+
+// ::comphelper::OPropertyArrayUsageHelper
+
+::cppu::IPropertyArrayHelper* ScChartObj::createArrayHelper() const
+{
+ uno::Sequence< beans::Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+}
+
+// XInterface
+
+IMPLEMENT_FORWARD_XINTERFACE2( ScChartObj, ScChartObj_Base, ScChartObj_PBase )
+
+// XTypeProvider
+
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( ScChartObj, ScChartObj_Base, ScChartObj_PBase )
+
+// XComponent
+
+void ScChartObj::disposing()
+{
+ ScChartObj_Base::disposing();
+}
+
+// XTableChart
+
+sal_Bool SAL_CALL ScChartObj::getHasColumnHeaders() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRangeListRef xRanges = new ScRangeList;
+ bool bColHeaders, bRowHeaders;
+ GetData_Impl( xRanges, bColHeaders, bRowHeaders );
+ return bColHeaders;
+}
+
+void SAL_CALL ScChartObj::setHasColumnHeaders( sal_Bool bHasColumnHeaders )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRangeListRef xRanges = new ScRangeList;
+ bool bOldColHeaders, bOldRowHeaders;
+ GetData_Impl( xRanges, bOldColHeaders, bOldRowHeaders );
+ if ( bOldColHeaders != (bHasColumnHeaders != sal_False) )
+ Update_Impl( xRanges, bHasColumnHeaders, bOldRowHeaders );
+}
+
+sal_Bool SAL_CALL ScChartObj::getHasRowHeaders() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRangeListRef xRanges = new ScRangeList;
+ bool bColHeaders, bRowHeaders;
+ GetData_Impl( xRanges, bColHeaders, bRowHeaders );
+ return bRowHeaders;
+}
+
+void SAL_CALL ScChartObj::setHasRowHeaders( sal_Bool bHasRowHeaders )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRangeListRef xRanges = new ScRangeList;
+ bool bOldColHeaders, bOldRowHeaders;
+ GetData_Impl( xRanges, bOldColHeaders, bOldRowHeaders );
+ if ( bOldRowHeaders != (bHasRowHeaders != sal_False) )
+ Update_Impl( xRanges, bOldColHeaders, bHasRowHeaders );
+}
+
+uno::Sequence<table::CellRangeAddress> SAL_CALL ScChartObj::getRanges() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRangeListRef xRanges = new ScRangeList;
+ bool bColHeaders, bRowHeaders;
+ GetData_Impl( xRanges, bColHeaders, bRowHeaders );
+ if ( xRanges.Is() )
+ {
+ ULONG nCount = xRanges->Count();
+
+ table::CellRangeAddress aRangeAddress;
+ uno::Sequence<table::CellRangeAddress> aSeq(nCount);
+ table::CellRangeAddress* pAry = aSeq.getArray();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScRange aRange(*xRanges->GetObject(i));
+
+ aRangeAddress.Sheet = aRange.aStart.Tab();
+ aRangeAddress.StartColumn = aRange.aStart.Col();
+ aRangeAddress.StartRow = aRange.aStart.Row();
+ aRangeAddress.EndColumn = aRange.aEnd.Col();
+ aRangeAddress.EndRow = aRange.aEnd.Row();
+
+ pAry[i] = aRangeAddress;
+ }
+ return aSeq;
+ }
+
+ DBG_ERROR("ScChartObj::getRanges: keine Ranges");
+ return uno::Sequence<table::CellRangeAddress>();
+}
+
+void SAL_CALL ScChartObj::setRanges( const uno::Sequence<table::CellRangeAddress>& aRanges )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRangeListRef xOldRanges = new ScRangeList;
+ bool bColHeaders, bRowHeaders;
+ GetData_Impl( xOldRanges, bColHeaders, bRowHeaders );
+
+ ScRangeList* pList = new ScRangeList;
+ USHORT nRangeCount = (USHORT)aRanges.getLength();
+ if (nRangeCount)
+ {
+ const table::CellRangeAddress* pAry = aRanges.getConstArray();
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ ScRange aRange( static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow, pAry[i].Sheet,
+ static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow, pAry[i].Sheet );
+ pList->Append( aRange );
+ }
+ }
+ ScRangeListRef xNewRanges( pList );
+
+ if ( !xOldRanges.Is() || *xOldRanges != *xNewRanges )
+ Update_Impl( xNewRanges, bColHeaders, bRowHeaders );
+}
+
+// XEmbeddedObjectSupplier
+
+uno::Reference<lang::XComponent> SAL_CALL ScChartObj::getEmbeddedObject() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SdrOle2Obj* pObject = lcl_FindChartObj( pDocShell, nTab, aChartName );
+ if ( pObject && svt::EmbeddedObjectRef::TryRunningState( pObject->GetObjRef() ) )
+ {
+ //TODO/LATER: is it OK that something is returned for *all* objects, not only own objects?
+ return uno::Reference < lang::XComponent > ( pObject->GetObjRef()->getComponent(), uno::UNO_QUERY );
+ }
+
+ return NULL;
+}
+
+// XNamed
+
+rtl::OUString SAL_CALL ScChartObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aChartName;
+}
+
+void SAL_CALL ScChartObj::setName( const rtl::OUString& /* aName */ ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ throw uno::RuntimeException(); // name cannot be changed
+}
+
+// XPropertySet
+
+uno::Reference< beans::XPropertySetInfo > ScChartObj::getPropertySetInfo() throw (uno::RuntimeException)
+{
+ return createPropertySetInfo( getInfoHelper() ) ;
+}
+
+//------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
new file mode 100644
index 000000000000..a9021c102955
--- /dev/null
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -0,0 +1,490 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "confuno.hxx"
+#include "unonames.hxx"
+#include "scdll.hxx"
+#include "docsh.hxx"
+#include "miscuno.hxx"
+#include "forbiuno.hxx"
+#include "viewopti.hxx"
+#include "docpool.hxx"
+#include "sc.hrc"
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <sfx2/printer.hxx>
+#include <xmloff/xmluconv.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace com::sun::star;
+
+#define SCCOMPSCPREADSHEETSETTINGS_SERVICE "com.sun.star.comp.SpreadsheetSettings"
+#define SCDOCUMENTSETTINGS_SERVICE "com.sun.star.document.Settings"
+#define SCSAVEVERSION "SaveVersionOnClose"
+
+
+const SfxItemPropertyMapEntry* lcl_GetConfigPropertyMap()
+{
+ static SfxItemPropertyMapEntry aConfigPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_SHOWZERO), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWNOTES), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWGRID), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_LINKUPD), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SNAPTORASTER), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RASTERVIS), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RASTERRESX), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RASTERRESY), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RASTERSUBX), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RASTERSUBY), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RASTERSYNC), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_AUTOCALC), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_PRINTERNAME), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_PRINTERSETUP), 0, &getCppuType((uno::Sequence<sal_Int8>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_APPLYDOCINF), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_FORBIDDEN), 0, &getCppuType((uno::Reference<i18n::XForbiddenCharacters>*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_CHARCOMP), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ASIANKERN), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SCSAVEVERSION), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_UPDTEMPL), 0, &getBooleanCppuType(), 0, 0},
+ /*Stampit enable/disable print cancel */
+ {MAP_CHAR_LEN(SC_UNO_ALLOWPRINTJOBCANCEL), 0, &getBooleanCppuType(), 0, 0},
+ // --> PB 2004-08-25 #i33095# Security Options
+ {MAP_CHAR_LEN(SC_UNO_LOADREADONLY), 0, &getBooleanCppuType(), 0, 0},
+ // <--
+ {MAP_CHAR_LEN(SC_UNO_SHAREDOC), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_MODIFYPASSWORDINFO), 0, &getCppuType((uno::Sequence< beans::PropertyValue >*)0), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aConfigPropertyMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+ScDocumentConfiguration::ScDocumentConfiguration(ScDocShell* pDocSh)
+ : pDocShell(pDocSh) ,
+ aPropSet ( lcl_GetConfigPropertyMap() )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDocumentConfiguration::~ScDocumentConfiguration()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDocumentConfiguration::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocumentConfiguration::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScDocumentConfiguration::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if(pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ sal_Bool bUpdateHeights = sal_False;
+
+ ScViewOptions aViewOpt(pDoc->GetViewOptions());
+
+ /*Stampit enable/disable print cancel */
+ if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
+ pDocShell->Stamp_SetPrintCancelState( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ /*Stampit enable/disable print cancel */
+
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
+ aViewOpt.SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
+ aViewOpt.SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
+ aViewOpt.SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
+ {
+ sal_Int64 nColor = 0;
+ if (aValue >>= nColor)
+ {
+ String aColorName;
+ Color aColor(static_cast<sal_uInt32>(nColor));
+ aViewOpt.SetGridColor(aColor, aColorName);
+ }
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
+ aViewOpt.SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
+ pDoc->SetLinkMode( static_cast<ScLkUpdMode> ( ScUnoHelpFunctions::GetInt16FromAny( aValue ) ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
+ aViewOpt.SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
+ aViewOpt.SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
+ aViewOpt.SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
+ pDoc->SetAutoCalc( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
+ {
+ rtl::OUString sPrinterName;
+ if ( aValue >>= sPrinterName )
+ {
+ // #i75610# if the name is empty, do nothing (don't create any printer)
+ if ( sPrinterName.getLength() != 0 && pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
+ {
+ SfxPrinter* pPrinter = pDocShell->GetPrinter();
+ if (pPrinter)
+ {
+ String aString(sPrinterName);
+ if (pPrinter->GetName() != aString)
+ {
+ SfxPrinter* pNewPrinter = new SfxPrinter( pPrinter->GetOptions().Clone(), aString );
+ if (pNewPrinter->IsKnown())
+ pDocShell->SetPrinter( pNewPrinter, SFX_PRINTER_PRINTER );
+ else
+ delete pNewPrinter;
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
+ {
+ uno::Sequence<sal_Int8> aSequence;
+ if ( aValue >>= aSequence )
+ {
+ sal_uInt32 nSize = aSequence.getLength();
+ // #i75610# if the sequence is empty, do nothing (don't create any printer)
+ if ( nSize != 0 )
+ {
+ SvMemoryStream aStream (aSequence.getArray(), nSize, STREAM_READ );
+ aStream.Seek ( STREAM_SEEK_TO_BEGIN );
+ SfxItemSet* pSet = new SfxItemSet( *pDoc->GetPool(),
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ SID_PRINT_SELECTEDSHEET, SID_PRINT_SELECTEDSHEET,
+ SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
+ NULL );
+ pDocShell->SetPrinter( SfxPrinter::Create( aStream, pSet ) );
+ }
+ }
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
+ {
+ sal_Bool bTmp=sal_True;
+ if ( aValue >>= bTmp )
+ pDocShell->SetUseUserData( bTmp );
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
+ {
+ // read-only - should not be set
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
+ {
+ // Int16 contains CharacterCompressionType values
+ sal_Int16 nUno = ScUnoHelpFunctions::GetInt16FromAny( aValue );
+ pDoc->SetAsianCompression( (BYTE) nUno );
+ bUpdateHeights = sal_True;
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
+ {
+ pDoc->SetAsianKerning( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ bUpdateHeights = sal_True;
+ }
+ else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
+ {
+ sal_Bool bTmp=sal_False;
+ if ( aValue >>= bTmp )
+ pDocShell->SetSaveVersionOnClose( bTmp );
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
+ {
+ sal_Bool bTmp=sal_True;
+ if ( aValue >>= bTmp )
+ pDocShell->SetQueryLoadTemplate( bTmp );
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
+ {
+ sal_Bool bTmp=sal_False;
+ if ( aValue >>= bTmp )
+ pDocShell->SetLoadReadonly( bTmp );
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
+ {
+ sal_Bool bDocShared = sal_False;
+ if ( aValue >>= bDocShared )
+ {
+ pDocShell->SetSharedXMLFlag( bDocShared );
+ }
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
+ {
+ uno::Sequence< beans::PropertyValue > aInfo;
+ if ( !( aValue >>= aInfo ) )
+ throw lang::IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type Sequence<PropertyValue> expected!" ) ),
+ uno::Reference< uno::XInterface >(),
+ 2 );
+
+ if ( !pDocShell->SetModifyPasswordInfo( aInfo ) )
+ throw beans::PropertyVetoException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ),
+ uno::Reference< uno::XInterface >() );
+ }
+ else
+ {
+ ScGridOptions aGridOpt(aViewOpt.GetGridOptions());
+ if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
+ aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
+ aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
+ aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
+ aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
+ aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
+ aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( aValue ) ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
+ aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else
+ throw beans::UnknownPropertyException();
+ aViewOpt.SetGridOptions(aGridOpt);
+ }
+ pDoc->SetViewOptions(aViewOpt);
+
+ if ( bUpdateHeights && !pDoc->IsImportingXML() )
+ {
+ // update automatic row heights and repaint
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if ( !pDocShell->AdjustRowHeight( 0, MAXROW, nTab ) )
+ pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL ScDocumentConfiguration::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+
+ if(pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ const ScViewOptions& aViewOpt = pDoc->GetViewOptions();
+
+ /*Stampit enable/disable print cancel */
+ if ( aPropertyName.compareToAscii( SC_UNO_ALLOWPRINTJOBCANCEL ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->Stamp_GetPrintCancelState() );
+ /*Stampit enable/disable print cancel */
+
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NULLVALS ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_NOTES ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_GRID ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
+ {
+ String aColorName;
+ Color aColor = aViewOpt.GetGridColor(&aColorName);
+ aRet <<= static_cast<sal_Int64>(aColor.GetColor());
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_PAGEBREAKS ) );
+ else if ( aPropertyName.compareToAscii( SC_UNONAME_LINKUPD ) == 0 )
+ aRet <<= static_cast<sal_Int16> ( pDoc->GetLinkMode() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_HEADER ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_TABCONTROLS ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aViewOpt.GetOption( VOPT_OUTLINER ) );
+ else if ( aPropertyName.compareToAscii( SC_UNO_AUTOCALC ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAutoCalc() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERNAME ) == 0 )
+ {
+ // #i75610# don't create the printer, return empty string if no printer created yet
+ // (as in SwXDocumentSettings)
+ SfxPrinter* pPrinter = pDoc->GetPrinter( FALSE );
+ if (pPrinter)
+ aRet <<= rtl::OUString ( pPrinter->GetName());
+ else
+ aRet <<= rtl::OUString();
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_PRINTERSETUP ) == 0 )
+ {
+ // #i75610# don't create the printer, return empty sequence if no printer created yet
+ // (as in SwXDocumentSettings)
+ SfxPrinter* pPrinter = pDoc->GetPrinter( FALSE );
+ if (pPrinter)
+ {
+ SvMemoryStream aStream;
+ pPrinter->Store( aStream );
+ aStream.Seek ( STREAM_SEEK_TO_END );
+ sal_uInt32 nSize = aStream.Tell();
+ aStream.Seek ( STREAM_SEEK_TO_BEGIN );
+ uno::Sequence < sal_Int8 > aSequence( nSize );
+ aStream.Read ( aSequence.getArray(), nSize );
+ aRet <<= aSequence;
+ }
+ else
+ aRet <<= uno::Sequence<sal_Int8>();
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_APPLYDOCINF ) == 0 )
+ aRet <<= pDocShell->IsUseUserData();
+ else if ( aPropertyName.compareToAscii( SC_UNO_FORBIDDEN ) == 0 )
+ {
+ aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell ));
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_CHARCOMP ) == 0 )
+ aRet <<= static_cast<sal_Int16> ( pDoc->GetAsianCompression() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_ASIANKERN ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->GetAsianKerning() );
+ else if ( aPropertyName.compareToAscii( SCSAVEVERSION ) == 0)
+ aRet <<= pDocShell->IsSaveVersionOnClose();
+ else if ( aPropertyName.compareToAscii( SC_UNO_UPDTEMPL ) == 0 )
+ aRet <<= pDocShell->IsQueryLoadTemplate();
+ else if ( aPropertyName.compareToAscii( SC_UNO_LOADREADONLY ) == 0 )
+ aRet <<= pDocShell->IsLoadReadonly();
+ // <--
+ else if ( aPropertyName.compareToAscii( SC_UNO_SHAREDOC ) == 0 )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDocShell->HasSharedXMLFlagSet() );
+ }
+ else if ( aPropertyName.compareToAscii( SC_UNO_MODIFYPASSWORDINFO ) == 0 )
+ aRet <<= pDocShell->GetModifyPasswordInfo();
+ else
+ {
+ const ScGridOptions& aGridOpt = aViewOpt.GetGridOptions();
+ if ( aPropertyName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetUseGridSnap() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetGridVisible() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
+ aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
+ aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
+ aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
+ aRet <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
+ else if ( aPropertyName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aGridOpt.GetSynchronize() );
+ else
+ throw beans::UnknownPropertyException();
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ else
+ throw uno::RuntimeException();
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocumentConfiguration )
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScDocumentConfiguration::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScDocumentConfiguration" );
+}
+
+sal_Bool SAL_CALL ScDocumentConfiguration::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCDOCUMENTSETTINGS_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScDocumentConfiguration::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCCOMPSCPREADSHEETSETTINGS_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCDOCUMENTSETTINGS_SERVICE );
+ return aRet;
+}
+
+//-------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/convuno.cxx b/sc/source/ui/unoobj/convuno.cxx
new file mode 100644
index 000000000000..eca685afa290
--- /dev/null
+++ b/sc/source/ui/unoobj/convuno.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <tools/debug.hxx>
+#include <i18npool/mslangid.hxx>
+
+#include "convuno.hxx"
+#include "global.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+// everything is static...
+
+LanguageType ScUnoConversion::GetLanguage( const lang::Locale& rLocale )
+{
+ // empty language -> LANGUAGE_SYSTEM
+ if ( rLocale.Language.getLength() == 0 )
+ return LANGUAGE_SYSTEM;
+
+ LanguageType eRet = MsLangId::convertLocaleToLanguage( rLocale );
+ if ( eRet == LANGUAGE_NONE )
+ eRet = LANGUAGE_SYSTEM; //! or throw an exception?
+
+ return eRet;
+}
+
+void ScUnoConversion::FillLocale( lang::Locale& rLocale, LanguageType eLang )
+{
+ MsLangId::convertLanguageToLocale( eLang, rLocale );
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/cursuno.cxx b/sc/source/ui/unoobj/cursuno.cxx
new file mode 100644
index 000000000000..dd37d32040d8
--- /dev/null
+++ b/sc/source/ui/unoobj/cursuno.cxx
@@ -0,0 +1,512 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "scitems.hxx"
+#include <svl/intitem.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/uuid.h>
+
+#include "cursuno.hxx"
+#include "cellsuno.hxx"
+#include "docsh.hxx"
+#include "hints.hxx"
+#include "markdata.hxx"
+#include "dociter.hxx"
+#include "miscuno.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+#define SCSHEETCELLCURSOR_SERVICE "com.sun.star.sheet.SheetCellCursor"
+#define SCCELLCURSOR_SERVICE "com.sun.star.table.CellCursor"
+
+//------------------------------------------------------------------------
+
+ScCellCursorObj::ScCellCursorObj(ScDocShell* pDocSh, const ScRange& rR) :
+ ScCellRangeObj( pDocSh, rR )
+{
+}
+
+ScCellCursorObj::~ScCellCursorObj()
+{
+}
+
+uno::Any SAL_CALL ScCellCursorObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XSheetCellCursor )
+ SC_QUERYINTERFACE( sheet::XUsedAreaCursor )
+ SC_QUERYINTERFACE( table::XCellCursor )
+
+ return ScCellRangeObj::queryInterface( rType );
+}
+
+void SAL_CALL ScCellCursorObj::acquire() throw()
+{
+ ScCellRangeObj::acquire();
+}
+
+void SAL_CALL ScCellCursorObj::release() throw()
+{
+ ScCellRangeObj::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScCellCursorObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 3 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSheetCellCursor>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XUsedAreaCursor>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<table::XCellCursor>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScCellCursorObj::getImplementationId() throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XSheetCellCursor
+
+void SAL_CALL ScCellCursorObj::collapseToCurrentRegion() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+
+ aOneRange.Justify();
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCCOL nStartCol = aOneRange.aStart.Col();
+ SCROW nStartRow = aOneRange.aStart.Row();
+ SCCOL nEndCol = aOneRange.aEnd.Col();
+ SCROW nEndRow = aOneRange.aEnd.Row();
+ SCTAB nTab = aOneRange.aStart.Tab();
+
+ pDocSh->GetDocument()->GetDataArea(
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, TRUE, false );
+
+ ScRange aNew( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
+ SetNewRange( aNew );
+ }
+}
+
+void SAL_CALL ScCellCursorObj::collapseToCurrentArray() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+
+ aOneRange.Justify();
+ ScAddress aCursor(aOneRange.aStart); // use the start address of the range
+
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScRange aMatrix;
+
+ // finding the matrix range is now in GetMatrixFormulaRange in the document
+ if ( pDoc->GetMatrixFormulaRange( aCursor, aMatrix ) )
+ {
+ SetNewRange( aMatrix );
+ }
+ }
+ // thats a Bug, that this assertion comes; the API Reference says, that
+ // if there is no Matrix, the Range is left unchanged; they says nothing
+ // about a exception
+ /*if (!bFound)
+ {
+ DBG_ERROR("keine Matrix");
+ //! Exception, oder was?
+ }*/
+}
+
+void SAL_CALL ScCellCursorObj::collapseToMergedArea() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aNewRange(*rRanges.GetObject(0));
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ pDoc->ExtendOverlapped( aNewRange );
+ pDoc->ExtendMerge( aNewRange ); // after ExtendOverlapped!
+
+ SetNewRange( aNewRange );
+ }
+}
+
+void SAL_CALL ScCellCursorObj::expandToEntireColumns() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aNewRange(*rRanges.GetObject(0));
+
+ aNewRange.aStart.SetRow( 0 );
+ aNewRange.aEnd.SetRow( MAXROW );
+
+ SetNewRange( aNewRange );
+}
+
+void SAL_CALL ScCellCursorObj::expandToEntireRows() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aNewRange(*rRanges.GetObject(0));
+
+ aNewRange.aStart.SetCol( 0 );
+ aNewRange.aEnd.SetCol( MAXCOL );
+
+ SetNewRange( aNewRange );
+}
+
+void SAL_CALL ScCellCursorObj::collapseToSize( sal_Int32 nColumns, sal_Int32 nRows )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( nColumns <= 0 || nRows <= 0 )
+ {
+ DBG_ERROR("leerer Range geht nicht");
+ //! und dann?
+ }
+ else
+ {
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aNewRange(*rRanges.GetObject(0));
+
+ aNewRange.Justify(); //! wirklich?
+
+ long nEndX = aNewRange.aStart.Col() + nColumns - 1;
+ long nEndY = aNewRange.aStart.Row() + nRows - 1;
+ if ( nEndX < 0 ) nEndX = 0;
+ if ( nEndX > MAXCOL ) nEndX = MAXCOL;
+ if ( nEndY < 0 ) nEndY = 0;
+ if ( nEndY > MAXROW ) nEndY = MAXROW;
+ //! Fehler/Exception oder so, wenn zu gross/zu klein?
+
+ aNewRange.aEnd.SetCol((SCCOL)nEndX);
+ aNewRange.aEnd.SetRow((SCROW)nEndY);
+
+ aNewRange.Justify(); //! wirklich?
+
+ SetNewRange( aNewRange );
+ }
+}
+
+// XUsedAreaCursor
+
+void SAL_CALL ScCellCursorObj::gotoStartOfUsedArea( sal_Bool bExpand )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aNewRange(*rRanges.GetObject(0));
+ SCTAB nTab = aNewRange.aStart.Tab();
+
+ SCCOL nUsedX = 0; // Anfang holen
+ SCROW nUsedY = 0;
+ if (!pDocSh->GetDocument()->GetDataStart( nTab, nUsedX, nUsedY ))
+ {
+ nUsedX = 0;
+ nUsedY = 0;
+ }
+
+ aNewRange.aStart.SetCol( nUsedX );
+ aNewRange.aStart.SetRow( nUsedY );
+ if (!bExpand)
+ aNewRange.aEnd = aNewRange.aStart;
+ SetNewRange( aNewRange );
+ }
+}
+
+void SAL_CALL ScCellCursorObj::gotoEndOfUsedArea( sal_Bool bExpand )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aNewRange(*rRanges.GetObject(0));
+ SCTAB nTab = aNewRange.aStart.Tab();
+
+ SCCOL nUsedX = 0; // Ende holen
+ SCROW nUsedY = 0;
+ if (!pDocSh->GetDocument()->GetTableArea( nTab, nUsedX, nUsedY ))
+ {
+ nUsedX = 0;
+ nUsedY = 0;
+ }
+
+ aNewRange.aEnd.SetCol( nUsedX );
+ aNewRange.aEnd.SetRow( nUsedY );
+ if (!bExpand)
+ aNewRange.aStart = aNewRange.aEnd;
+ SetNewRange( aNewRange );
+ }
+}
+
+// XCellCursor
+
+void SAL_CALL ScCellCursorObj::gotoStart() throw(uno::RuntimeException)
+{
+ // this is similar to collapseToCurrentRegion
+ //! something like gotoEdge with 4 possible directions is needed
+
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+
+ aOneRange.Justify();
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCCOL nStartCol = aOneRange.aStart.Col();
+ SCROW nStartRow = aOneRange.aStart.Row();
+ SCCOL nEndCol = aOneRange.aEnd.Col();
+ SCROW nEndRow = aOneRange.aEnd.Row();
+ SCTAB nTab = aOneRange.aStart.Tab();
+
+ pDocSh->GetDocument()->GetDataArea(
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
+
+ ScRange aNew( nStartCol, nStartRow, nTab );
+ SetNewRange( aNew );
+ }
+}
+
+void SAL_CALL ScCellCursorObj::gotoEnd() throw(uno::RuntimeException)
+{
+ // this is similar to collapseToCurrentRegion
+ //! something like gotoEdge with 4 possible directions is needed
+
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+
+ aOneRange.Justify();
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ {
+ SCCOL nStartCol = aOneRange.aStart.Col();
+ SCROW nStartRow = aOneRange.aStart.Row();
+ SCCOL nEndCol = aOneRange.aEnd.Col();
+ SCROW nEndRow = aOneRange.aEnd.Row();
+ SCTAB nTab = aOneRange.aStart.Tab();
+
+ pDocSh->GetDocument()->GetDataArea(
+ nTab, nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
+
+ ScRange aNew( nEndCol, nEndRow, nTab );
+ SetNewRange( aNew );
+ }
+}
+
+void SAL_CALL ScCellCursorObj::gotoNext() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+
+ aOneRange.Justify();
+ ScAddress aCursor(aOneRange.aStart); // bei Block immer den Start nehmen
+
+ ScMarkData aMark; // not used with bMarked=FALSE
+ SCCOL nNewX = aCursor.Col();
+ SCROW nNewY = aCursor.Row();
+ SCTAB nTab = aCursor.Tab();
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ pDocSh->GetDocument()->GetNextPos( nNewX,nNewY, nTab, 1,0, FALSE,TRUE, aMark );
+ //! sonst Exception oder so
+
+ SetNewRange( ScRange( nNewX, nNewY, nTab ) );
+}
+
+void SAL_CALL ScCellCursorObj::gotoPrevious() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+
+ aOneRange.Justify();
+ ScAddress aCursor(aOneRange.aStart); // bei Block immer den Start nehmen
+
+ ScMarkData aMark; // not used with bMarked=FALSE
+ SCCOL nNewX = aCursor.Col();
+ SCROW nNewY = aCursor.Row();
+ SCTAB nTab = aCursor.Tab();
+ ScDocShell* pDocSh = GetDocShell();
+ if ( pDocSh )
+ pDocSh->GetDocument()->GetNextPos( nNewX,nNewY, nTab, -1,0, FALSE,TRUE, aMark );
+ //! sonst Exception oder so
+
+ SetNewRange( ScRange( nNewX, nNewY, nTab ) );
+}
+
+void SAL_CALL ScCellCursorObj::gotoOffset( sal_Int32 nColumnOffset, sal_Int32 nRowOffset )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScRangeList& rRanges = GetRangeList();
+ DBG_ASSERT( rRanges.Count() == 1, "Range? Ranges?" );
+ ScRange aOneRange(*rRanges.GetObject(0));
+ aOneRange.Justify();
+
+ if ( aOneRange.aStart.Col() + nColumnOffset >= 0 &&
+ aOneRange.aEnd.Col() + nColumnOffset <= MAXCOL &&
+ aOneRange.aStart.Row() + nRowOffset >= 0 &&
+ aOneRange.aEnd.Row() + nRowOffset <= MAXROW )
+ {
+ ScRange aNew( (SCCOL)(aOneRange.aStart.Col() + nColumnOffset),
+ (SCROW)(aOneRange.aStart.Row() + nRowOffset),
+ aOneRange.aStart.Tab(),
+ (SCCOL)(aOneRange.aEnd.Col() + nColumnOffset),
+ (SCROW)(aOneRange.aEnd.Row() + nRowOffset),
+ aOneRange.aEnd.Tab() );
+ SetNewRange( aNew );
+ }
+}
+
+// XSheetCellRange
+
+uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellCursorObj::getSpreadsheet()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::getSpreadsheet();
+}
+
+// XCellRange
+
+uno::Reference<table::XCell> SAL_CALL ScCellCursorObj::getCellByPosition(
+ sal_Int32 nColumn, sal_Int32 nRow )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::getCellByPosition(nColumn,nRow);
+}
+
+uno::Reference<table::XCellRange> SAL_CALL ScCellCursorObj::getCellRangeByPosition(
+ sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
+ throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
+}
+
+uno::Reference<table::XCellRange> SAL_CALL ScCellCursorObj::getCellRangeByName(
+ const rtl::OUString& rRange ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScCellRangeObj::getCellRangeByName(rRange);
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScCellCursorObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScCellCursorObj" );
+}
+
+sal_Bool SAL_CALL ScCellCursorObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCSHEETCELLCURSOR_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCCELLCURSOR_SERVICE ) ||
+ ScCellRangeObj::supportsService(rServiceName);
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellCursorObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ // get all service names from cell range
+ uno::Sequence<rtl::OUString> aParentSeq(ScCellRangeObj::getSupportedServiceNames());
+ sal_Int32 nParentLen = aParentSeq.getLength();
+ const rtl::OUString* pParentArr = aParentSeq.getConstArray();
+
+ // SheetCellCursor should be first (?)
+ uno::Sequence<rtl::OUString> aTotalSeq( nParentLen + 2 );
+ rtl::OUString* pTotalArr = aTotalSeq.getArray();
+ pTotalArr[0] = rtl::OUString::createFromAscii( SCSHEETCELLCURSOR_SERVICE );
+ pTotalArr[1] = rtl::OUString::createFromAscii( SCCELLCURSOR_SERVICE );
+
+ // append cell range services
+ for (long i=0; i<nParentLen; i++)
+ pTotalArr[i+2] = pParentArr[i];
+
+ return aTotalSeq;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
new file mode 100644
index 000000000000..81d8423e7fad
--- /dev/null
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -0,0 +1,3556 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <algorithm>
+#include <svl/smplhint.hxx>
+#include <vcl/svapp.hxx>
+#include <rtl/uuid.h>
+
+#include "dapiuno.hxx"
+#include "datauno.hxx"
+#include "miscuno.hxx"
+#include "convuno.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "pivot.hxx"
+#include "rangeutl.hxx"
+#include "dpobject.hxx"
+#include "dpshttab.hxx"
+#include "dpsdbtab.hxx"
+#include "dpsave.hxx"
+#include "dbdocfun.hxx"
+#include "unonames.hxx"
+#include "dpgroup.hxx"
+#include "dpdimsave.hxx"
+#include "hints.hxx"
+
+#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
+#include <com/sun/star/sheet/XLevelsSupplier.hpp>
+#include <com/sun/star/sheet/XMembersSupplier.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
+
+#include <comphelper/extract.hxx>
+#include <comphelper/sequence.hxx>
+
+using namespace com::sun::star;
+using namespace com::sun::star::sheet;
+
+using ::rtl::OUString;
+
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+
+using ::com::sun::star::container::ElementExistException;
+using ::com::sun::star::container::NoSuchElementException;
+using ::com::sun::star::container::XEnumeration;
+using ::com::sun::star::container::XIndexAccess;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::container::XNamed;
+
+using ::com::sun::star::beans::PropertyVetoException;
+using ::com::sun::star::beans::UnknownPropertyException;
+using ::com::sun::star::beans::XPropertyChangeListener;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::beans::XPropertySetInfo;
+using ::com::sun::star::beans::XVetoableChangeListener;
+
+using ::com::sun::star::lang::IllegalArgumentException;
+using ::com::sun::star::lang::IndexOutOfBoundsException;
+using ::com::sun::star::lang::WrappedTargetException;
+
+using ::com::sun::star::table::CellAddress;
+using ::com::sun::star::table::CellRangeAddress;
+
+// ============================================================================
+
+namespace {
+
+const SfxItemPropertyMapEntry* lcl_GetDataPilotDescriptorBaseMap()
+{
+ static SfxItemPropertyMapEntry aDataPilotDescriptorBaseMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_COLGRAND), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_DRILLDOWN), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_IGNEMPROWS), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_IMPORTDESC), 0, &getCppuType((uno::Sequence<beans::PropertyValue>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_RPTEMPTY), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_ROWGRAND), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SERVICEARG), 0, &getCppuType((uno::Sequence<beans::PropertyValue>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SHOWFILT), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SOURCESERV), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aDataPilotDescriptorBaseMap_Impl;
+}
+
+// ----------------------------------------------------------------------------
+
+const SfxItemPropertyMapEntry* lcl_GetDataPilotFieldMap()
+{
+ using namespace ::com::sun::star::beans::PropertyAttribute;
+ static SfxItemPropertyMapEntry aDataPilotFieldMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_AUTOSHOW), 0, &getCppuType((DataPilotFieldAutoShowInfo*)0), MAYBEVOID, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_FUNCTION), 0, &getCppuType((GeneralFunction*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_GROUPINFO), 0, &getCppuType((DataPilotFieldGroupInfo*)0), MAYBEVOID, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_HASAUTOSHOW), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_HASLAYOUTINFO),0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_HASREFERENCE), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_HASSORTINFO), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ISGROUP), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LAYOUTINFO), 0, &getCppuType((DataPilotFieldLayoutInfo*)0), MAYBEVOID, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ORIENT), 0, &getCppuType((DataPilotFieldOrientation*)0), MAYBEVOID, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_REFERENCE), 0, &getCppuType((DataPilotFieldReference*)0), MAYBEVOID, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SELPAGE), 0, &getCppuType((OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHOWEMPTY), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SORTINFO), 0, &getCppuType((DataPilotFieldSortInfo*)0), MAYBEVOID, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SUBTOTALS), 0, &getCppuType((Sequence<GeneralFunction>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_USESELPAGE), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aDataPilotFieldMap_Impl;
+}
+
+// ----------------------------------------------------------------------------
+
+const SfxItemPropertyMapEntry* lcl_GetDataPilotItemMap()
+{
+ static SfxItemPropertyMapEntry aDataPilotItemMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ISHIDDEN), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_POS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHOWDETAIL), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aDataPilotItemMap_Impl;
+}
+
+// ----------------------------------------------------------------------------
+
+inline bool lclCheckValidDouble( double fValue, sal_Bool bAuto )
+{
+ return bAuto || ::rtl::math::isFinite( fValue );
+}
+
+bool lclCheckMinMaxStep( const DataPilotFieldGroupInfo& rInfo )
+{
+ return
+ lclCheckValidDouble( rInfo.Start, rInfo.HasAutoStart ) &&
+ lclCheckValidDouble( rInfo.End, rInfo.HasAutoEnd ) &&
+ (rInfo.HasAutoStart || rInfo.HasAutoEnd || (rInfo.Start <= rInfo.End)) &&
+ lclCheckValidDouble( rInfo.Step, sal_False ) &&
+ (0.0 <= rInfo.Step);
+}
+
+} // namespace
+
+// ============================================================================
+
+SC_SIMPLE_SERVICE_INFO( ScDataPilotDescriptor, "ScDataPilotDescriptor", "stardiv::one::sheet::DataPilotDescriptor" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldObj, "ScDataPilotFieldObj", "com.sun.star.sheet.DataPilotField" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldsObj, "ScDataPilotFieldsObj", "com.sun.star.sheet.DataPilotFields" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotTableObj, "ScDataPilotTableObj", "com.sun.star.sheet.DataPilotTable" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotTablesObj, "ScDataPilotTablesObj", "com.sun.star.sheet.DataPilotTables" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotItemsObj, "ScDataPilotItemsObj", "com.sun.star.sheet.DataPilotItems" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotItemObj, "ScDataPilotItemObj", "com.sun.star.sheet.DataPilotItem" )
+
+SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupsObj, "ScDataPilotFieldGroupsObj", "com.sun.star.sheet.DataPilotFieldGroups" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupObj, "ScDataPilotFieldGroupObj", "com.sun.star.sheet.DataPilotFieldGroup" )
+SC_SIMPLE_SERVICE_INFO( ScDataPilotFieldGroupItemObj, "ScDataPilotFieldGroupItemObj", "com.sun.star.sheet.DataPilotFieldGroupItem" )
+
+//------------------------------------------------------------------------
+
+// name that is used in the API for the data layout field
+#define SC_DATALAYOUT_NAME "Data"
+
+//------------------------------------------------------------------------
+
+GeneralFunction ScDataPilotConversion::FirstFunc( USHORT nBits )
+{
+ if ( nBits & PIVOT_FUNC_SUM ) return GeneralFunction_SUM;
+ if ( nBits & PIVOT_FUNC_COUNT ) return GeneralFunction_COUNT;
+ if ( nBits & PIVOT_FUNC_AVERAGE ) return GeneralFunction_AVERAGE;
+ if ( nBits & PIVOT_FUNC_MAX ) return GeneralFunction_MAX;
+ if ( nBits & PIVOT_FUNC_MIN ) return GeneralFunction_MIN;
+ if ( nBits & PIVOT_FUNC_PRODUCT ) return GeneralFunction_PRODUCT;
+ if ( nBits & PIVOT_FUNC_COUNT_NUM ) return GeneralFunction_COUNTNUMS;
+ if ( nBits & PIVOT_FUNC_STD_DEV ) return GeneralFunction_STDEV;
+ if ( nBits & PIVOT_FUNC_STD_DEVP ) return GeneralFunction_STDEVP;
+ if ( nBits & PIVOT_FUNC_STD_VAR ) return GeneralFunction_VAR;
+ if ( nBits & PIVOT_FUNC_STD_VARP ) return GeneralFunction_VARP;
+ if ( nBits & PIVOT_FUNC_AUTO ) return GeneralFunction_AUTO;
+ return GeneralFunction_NONE;
+}
+
+USHORT ScDataPilotConversion::FunctionBit( GeneralFunction eFunc )
+{
+ USHORT nRet = PIVOT_FUNC_NONE; // 0
+ switch (eFunc)
+ {
+ case GeneralFunction_SUM: nRet = PIVOT_FUNC_SUM; break;
+ case GeneralFunction_COUNT: nRet = PIVOT_FUNC_COUNT; break;
+ case GeneralFunction_AVERAGE: nRet = PIVOT_FUNC_AVERAGE; break;
+ case GeneralFunction_MAX: nRet = PIVOT_FUNC_MAX; break;
+ case GeneralFunction_MIN: nRet = PIVOT_FUNC_MIN; break;
+ case GeneralFunction_PRODUCT: nRet = PIVOT_FUNC_PRODUCT; break;
+ case GeneralFunction_COUNTNUMS: nRet = PIVOT_FUNC_COUNT_NUM; break;
+ case GeneralFunction_STDEV: nRet = PIVOT_FUNC_STD_DEV; break;
+ case GeneralFunction_STDEVP: nRet = PIVOT_FUNC_STD_DEVP; break;
+ case GeneralFunction_VAR: nRet = PIVOT_FUNC_STD_VAR; break;
+ case GeneralFunction_VARP: nRet = PIVOT_FUNC_STD_VARP; break;
+ case GeneralFunction_AUTO: nRet = PIVOT_FUNC_AUTO; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return nRet;
+}
+
+void ScDataPilotConversion::FillGroupInfo( DataPilotFieldGroupInfo& rInfo, const ScDPNumGroupInfo& rGroupInfo )
+{
+ rInfo.HasDateValues = rGroupInfo.DateValues;
+ rInfo.HasAutoStart = rGroupInfo.AutoStart;
+ rInfo.Start = rGroupInfo.Start;
+ rInfo.HasAutoEnd = rGroupInfo.AutoEnd;
+ rInfo.End = rGroupInfo.End;
+ rInfo.Step = rGroupInfo.Step;
+}
+
+//------------------------------------------------------------------------
+
+ScDPObject* lcl_GetDPObject( ScDocShell* pDocShell, SCTAB nTab, const String& rName )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDPCollection* pColl = pDoc->GetDPCollection();
+ if ( pColl )
+ {
+ USHORT nCount = pColl->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScDPObject* pDPObj = (*pColl)[i];
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
+ pDPObj->GetName() == rName )
+ return pDPObj;
+ }
+ }
+ }
+ return NULL; // nicht gefunden
+}
+
+String lcl_CreatePivotName( ScDocShell* pDocShell )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDPCollection* pColl = pDoc->GetDPCollection();
+ if ( pColl )
+ return pColl->CreateNewName();
+ }
+ return String(); // sollte nicht vorkommen
+}
+
+sal_Int32 lcl_GetObjectIndex( ScDPObject* pDPObj, const ScFieldIdentifier& rFieldId )
+{
+ // used for items - nRepeat in identifier can be ignored
+ if ( pDPObj )
+ {
+ sal_Int32 nCount = pDPObj->GetDimCount();
+ for ( sal_Int32 nDim = 0; nDim < nCount; ++nDim )
+ {
+ BOOL bIsDataLayout = FALSE;
+ OUString aDimName( pDPObj->GetDimName( nDim, bIsDataLayout ) );
+ if ( rFieldId.mbDataLayout ? bIsDataLayout : (aDimName == rFieldId.maFieldName) )
+ return nDim;
+ }
+ }
+ return -1; // none
+}
+
+//------------------------------------------------------------------------
+
+ScDataPilotTablesObj::ScDataPilotTablesObj(ScDocShell* pDocSh, SCTAB nT) :
+ pDocShell( pDocSh ),
+ nTab( nT )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDataPilotTablesObj::~ScDataPilotTablesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDataPilotTablesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! Referenz-Update
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XDataPilotTables
+
+ScDataPilotTableObj* ScDataPilotTablesObj::GetObjectByIndex_Impl( sal_Int32 nIndex )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDPCollection* pColl = pDoc->GetDPCollection();
+ if ( pColl )
+ {
+ // count tables on this sheet
+ // api only handles sheet data at this time
+ //! allow all data sources!!!
+ sal_Int32 nFound = 0;
+ USHORT nCount = pColl->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScDPObject* pDPObj = (*pColl)[i];
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
+ {
+ if ( nFound == nIndex )
+ {
+ String aName = pDPObj->GetName();
+ return new ScDataPilotTableObj( pDocShell, nTab, aName );
+ }
+ ++nFound;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+ScDataPilotTableObj* ScDataPilotTablesObj::GetObjectByName_Impl(const OUString& rName)
+{
+ if (hasByName(rName))
+ return new ScDataPilotTableObj( pDocShell, nTab, rName );
+ return 0;
+}
+
+Reference<XDataPilotDescriptor> SAL_CALL ScDataPilotTablesObj::createDataPilotDescriptor()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScDataPilotDescriptor(pDocShell);
+ return NULL;
+}
+
+bool lcl_IsDuplicated( const Reference<XPropertySet> xDimProps )
+{
+ try
+ {
+ Any aAny = xDimProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ORIGINAL ) ) );
+ Reference< XNamed > xOriginal( aAny, UNO_QUERY );
+ return xOriginal.is();
+ }
+ catch( Exception& )
+ {
+ }
+ return false;
+}
+
+OUString lcl_GetOriginalName( const Reference< XNamed > xDim )
+{
+ Reference< XNamed > xOriginal;
+
+ Reference< XPropertySet > xDimProps( xDim, UNO_QUERY );
+ if ( xDimProps.is() )
+ {
+ try
+ {
+ Any aAny = xDimProps->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIGINAL)));
+ aAny >>= xOriginal;
+ }
+ catch( Exception& )
+ {
+ }
+ }
+
+ if ( !xOriginal.is() )
+ xOriginal = xDim;
+
+ return xOriginal->getName();
+}
+
+void SAL_CALL ScDataPilotTablesObj::insertNewByName( const OUString& aNewName,
+ const CellAddress& aOutputAddress,
+ const Reference<XDataPilotDescriptor>& xDescriptor )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!xDescriptor.is()) return;
+
+ // inserting with already existing name?
+ if ( aNewName.getLength() && hasByName( aNewName ) )
+ throw RuntimeException(); // no other exceptions specified
+
+ BOOL bDone = FALSE;
+ ScDataPilotDescriptorBase* pImp = ScDataPilotDescriptorBase::getImplementation( xDescriptor );
+ if ( pDocShell && pImp )
+ {
+ ScDPObject* pNewObj = pImp->GetDPObject();
+
+ if (pNewObj)
+ {
+ ScRange aOutputRange((SCCOL)aOutputAddress.Column, (SCROW)aOutputAddress.Row, (SCTAB)aOutputAddress.Sheet,
+ (SCCOL)aOutputAddress.Column, (SCROW)aOutputAddress.Row, (SCTAB)aOutputAddress.Sheet);
+ pNewObj->SetOutRange(aOutputRange);
+ String aName = aNewName;
+ if (!aName.Len())
+ aName = lcl_CreatePivotName( pDocShell );
+ pNewObj->SetName(aName);
+ String aTag = xDescriptor->getTag();
+ pNewObj->SetTag(aTag);
+
+ // todo: handle double fields (for more information see ScDPObject
+
+ ScDBDocFunc aFunc(*pDocShell);
+ bDone = aFunc.DataPilotUpdate( NULL, pNewObj, TRUE, TRUE );
+ }
+ }
+
+ if (!bDone)
+ throw RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScDataPilotTablesObj::removeByName( const OUString& aName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr(aName);
+ ScDPObject* pDPObj = lcl_GetDPObject( pDocShell, nTab, aNameStr );
+ if (pDPObj && pDocShell)
+ {
+ ScDBDocFunc aFunc(*pDocShell);
+ aFunc.DataPilotUpdate( pDPObj, NULL, TRUE, TRUE ); // remove - incl. undo etc.
+ }
+ else
+ throw RuntimeException(); // no other exceptions specified
+}
+
+// XEnumerationAccess
+
+Reference< XEnumeration > SAL_CALL ScDataPilotTablesObj::createEnumeration() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotTablesEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDataPilotTablesObj::getCount() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDPCollection* pColl = pDoc->GetDPCollection();
+ if ( pColl )
+ {
+ // count tables on this sheet
+ // api only handles sheet data at this time
+ //! allow all data sources!!!
+
+ USHORT nFound = 0;
+ USHORT nCount = pColl->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScDPObject* pDPObj = (*pColl)[i];
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
+ ++nFound;
+ }
+ return nFound;
+ }
+ }
+
+ return 0;
+}
+
+Any SAL_CALL ScDataPilotTablesObj::getByIndex( sal_Int32 nIndex )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference<XDataPilotTable2> xTable(GetObjectByIndex_Impl(nIndex));
+ if (!xTable.is())
+ throw IndexOutOfBoundsException();
+ return Any( xTable );
+}
+
+uno::Type SAL_CALL ScDataPilotTablesObj::getElementType() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((Reference<XDataPilotTable2>*)0);
+}
+
+sal_Bool SAL_CALL ScDataPilotTablesObj::hasElements() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// XNameAccess
+
+Any SAL_CALL ScDataPilotTablesObj::getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference<XDataPilotTable2> xTable(GetObjectByName_Impl(aName));
+ if (!xTable.is())
+ throw NoSuchElementException();
+ return Any( xTable );
+}
+
+Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDPCollection* pColl = pDoc->GetDPCollection();
+ if ( pColl )
+ {
+ // count tables on this sheet
+ // api only handles sheet data at this time
+ //! allow all data sources!!!
+
+ USHORT nFound = 0;
+ USHORT nCount = pColl->GetCount();
+ USHORT i;
+ for (i=0; i<nCount; i++)
+ {
+ ScDPObject* pDPObj = (*pColl)[i];
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
+ ++nFound;
+ }
+
+ USHORT nPos = 0;
+ Sequence<OUString> aSeq(nFound);
+ OUString* pAry = aSeq.getArray();
+ for (i=0; i<nCount; i++)
+ {
+ ScDPObject* pDPObj = (*pColl)[i];
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
+ pAry[nPos++] = pDPObj->GetName();
+ }
+
+ return aSeq;
+ }
+ }
+ return Sequence<OUString>(0);
+}
+
+sal_Bool SAL_CALL ScDataPilotTablesObj::hasByName( const OUString& aName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDPCollection* pColl = pDoc->GetDPCollection();
+ if ( pColl )
+ {
+ String aNamStr(aName);
+ USHORT nCount = pColl->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ // api only handles sheet data at this time
+ //! allow all data sources!!!
+
+ ScDPObject* pDPObj = (*pColl)[i];
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
+ pDPObj->GetName() == aNamStr )
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+ScDataPilotDescriptorBase::ScDataPilotDescriptorBase(ScDocShell* pDocSh) :
+ maPropSet( lcl_GetDataPilotDescriptorBaseMap() ),
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDataPilotDescriptorBase::~ScDataPilotDescriptorBase()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+Any SAL_CALL ScDataPilotDescriptorBase::queryInterface( const uno::Type& rType )
+ throw(RuntimeException)
+{
+ SC_QUERYINTERFACE( XDataPilotDescriptor )
+ SC_QUERYINTERFACE( XPropertySet )
+ SC_QUERYINTERFACE( XDataPilotDataLayoutFieldSupplier )
+ SC_QUERYINTERFACE( XNamed ) // base of XDataPilotDescriptor
+ SC_QUERYINTERFACE( lang::XUnoTunnel )
+ SC_QUERYINTERFACE( lang::XTypeProvider )
+ SC_QUERYINTERFACE( lang::XServiceInfo )
+
+ return OWeakObject::queryInterface( rType );
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::release() throw()
+{
+ OWeakObject::release();
+}
+
+Sequence< uno::Type > SAL_CALL ScDataPilotDescriptorBase::getTypes()
+ throw(RuntimeException)
+{
+ static Sequence< uno::Type > aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ aTypes.realloc( 6 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[ 0 ] = getCppuType( (const Reference< XDataPilotDescriptor >*)0 );
+ pPtr[ 1 ] = getCppuType( (const Reference< XPropertySet >*)0 );
+ pPtr[ 2 ] = getCppuType( (const Reference< XDataPilotDataLayoutFieldSupplier >*)0 );
+ pPtr[ 3 ] = getCppuType( (const Reference< lang::XUnoTunnel >*)0 );
+ pPtr[ 4 ] = getCppuType( (const Reference< lang::XTypeProvider >*)0 );
+ pPtr[ 5 ] = getCppuType( (const Reference< lang::XServiceInfo >*)0 );
+ }
+ return aTypes;
+}
+
+Sequence<sal_Int8> SAL_CALL ScDataPilotDescriptorBase::getImplementationId()
+ throw(RuntimeException)
+{
+ static Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+void ScDataPilotDescriptorBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! Referenz-Update?
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XDataPilotDescriptor
+
+CellRangeAddress SAL_CALL ScDataPilotDescriptorBase::getSourceRange()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ ScDPObject* pDPObject(GetDPObject());
+ if (!pDPObject)
+ throw RuntimeException();
+
+ CellRangeAddress aRet;
+ if (pDPObject->IsSheetData())
+ ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->aSourceRange );
+ return aRet;
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::setSourceRange( const CellRangeAddress& aSourceRange ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ ScDPObject* pDPObject = GetDPObject();
+ if (!pDPObject)
+ throw RuntimeException();
+
+ ScSheetSourceDesc aSheetDesc;
+ if (pDPObject->IsSheetData())
+ aSheetDesc = *pDPObject->GetSheetDesc();
+ ScUnoConversion::FillScRange( aSheetDesc.aSourceRange, aSourceRange );
+ pDPObject->SetSheetDesc( aSheetDesc );
+ SetDPObject( pDPObject );
+}
+
+Reference<XSheetFilterDescriptor> SAL_CALL ScDataPilotDescriptorBase::getFilterDescriptor()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFilterDescriptor( pDocShell, this );
+}
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getDataPilotFields()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFieldsObj( *this );
+}
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getColumnFields()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_COLUMN );
+}
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getRowFields()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_ROW );
+}
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getPageFields()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_PAGE );
+}
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getDataFields()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_DATA );
+}
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotDescriptorBase::getHiddenFields()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScDataPilotFieldsObj( *this, DataPilotFieldOrientation_HIDDEN );
+}
+
+// XPropertySet
+Reference< XPropertySetInfo > SAL_CALL ScDataPilotDescriptorBase::getPropertySetInfo( )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static Reference<XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( maPropSet.getPropertyMap() );
+ return aRef;
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
+ WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObject = GetDPObject();
+ if (pDPObject)
+ {
+ ScDPSaveData* pOldData = pDPObject->GetSaveData();
+ DBG_ASSERT(pOldData, "Here should be a SaveData");
+ if ( pOldData )
+ {
+ ScDPSaveData aNewData( *pOldData );
+
+ String aNameString = aPropertyName;
+ if ( aNameString.EqualsAscii( SC_UNO_COLGRAND ) )
+ {
+ aNewData.SetColumnGrand(::cppu::any2bool( aValue ));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_IGNEMPROWS ) )
+ {
+ aNewData.SetIgnoreEmptyRows(::cppu::any2bool( aValue ));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_RPTEMPTY ) )
+ {
+ aNewData.SetRepeatIfEmpty(::cppu::any2bool( aValue ));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_ROWGRAND ) )
+ {
+ aNewData.SetRowGrand(::cppu::any2bool( aValue ));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SHOWFILT ) )
+ {
+ aNewData.SetFilterButton(::cppu::any2bool( aValue ));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_DRILLDOWN ) )
+ {
+ aNewData.SetDrillDown(::cppu::any2bool( aValue ));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_IMPORTDESC ) )
+ {
+ uno::Sequence<beans::PropertyValue> aArgSeq;
+ if ( aValue >>= aArgSeq )
+ {
+ ScImportSourceDesc aImportDesc;
+
+ const ScImportSourceDesc* pOldDesc = pDPObject->GetImportSourceDesc();
+ if (pOldDesc)
+ aImportDesc = *pOldDesc;
+
+ ScImportParam aParam;
+ ScImportDescriptor::FillImportParam( aParam, aArgSeq );
+
+ USHORT nNewType = sheet::DataImportMode_NONE;
+ if ( aParam.bImport )
+ {
+ if ( aParam.bSql )
+ nNewType = sheet::DataImportMode_SQL;
+ else if ( aParam.nType == ScDbQuery )
+ nNewType = sheet::DataImportMode_QUERY;
+ else
+ nNewType = sheet::DataImportMode_TABLE;
+ }
+ aImportDesc.nType = nNewType;
+ aImportDesc.aDBName = aParam.aDBName;
+ aImportDesc.aObject = aParam.aStatement;
+ aImportDesc.bNative = aParam.bNative;
+
+ pDPObject->SetImportDesc( aImportDesc );
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SOURCESERV ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ {
+ String aEmpty;
+ ScDPServiceDesc aServiceDesc(aEmpty, aEmpty, aEmpty, aEmpty, aEmpty);
+
+ const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
+ if (pOldDesc)
+ aServiceDesc = *pOldDesc;
+
+ aServiceDesc.aServiceName = aStrVal;
+
+ pDPObject->SetServiceData( aServiceDesc );
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SERVICEARG ) )
+ {
+ uno::Sequence<beans::PropertyValue> aArgSeq;
+ if ( aValue >>= aArgSeq )
+ {
+ String aEmpty;
+ ScDPServiceDesc aServiceDesc(aEmpty, aEmpty, aEmpty, aEmpty, aEmpty);
+
+ const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
+ if (pOldDesc)
+ aServiceDesc = *pOldDesc;
+
+ rtl::OUString aStrVal;
+ sal_Int32 nArgs = aArgSeq.getLength();
+ for (sal_Int32 nArgPos=0; nArgPos<nArgs; ++nArgPos)
+ {
+ const beans::PropertyValue& rProp = aArgSeq[nArgPos];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNO_SOURCENAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParSource = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_OBJECTNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParName = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_USERNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParUser = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_PASSWORD ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParPass = aStrVal;
+ }
+ }
+
+ pDPObject->SetServiceData( aServiceDesc );
+ }
+ }
+ else
+ throw UnknownPropertyException();
+
+ pDPObject->SetSaveData( aNewData );
+ }
+
+ SetDPObject(pDPObject);
+ }
+}
+
+Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Any aRet;
+
+ ScDPObject* pDPObject(GetDPObject());
+ if (pDPObject)
+ {
+ ScDPSaveData* pOldData = pDPObject->GetSaveData();
+ DBG_ASSERT(pOldData, "Here should be a SaveData");
+ if ( pOldData )
+ {
+ ScDPSaveData aNewData( *pOldData );
+
+ String aNameString = aPropertyName;
+ if ( aNameString.EqualsAscii( SC_UNO_COLGRAND ) )
+ {
+ aRet = ::cppu::bool2any( aNewData.GetColumnGrand() );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_IGNEMPROWS ) )
+ {
+ aRet = ::cppu::bool2any( aNewData.GetIgnoreEmptyRows() );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_RPTEMPTY ) )
+ {
+ aRet = ::cppu::bool2any( aNewData.GetRepeatIfEmpty() );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_ROWGRAND ) )
+ {
+ aRet = ::cppu::bool2any( aNewData.GetRowGrand() );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SHOWFILT ) )
+ {
+ aRet = ::cppu::bool2any( aNewData.GetFilterButton() );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_DRILLDOWN ) )
+ {
+ aRet = ::cppu::bool2any( aNewData.GetDrillDown() );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_IMPORTDESC ) )
+ {
+ const ScImportSourceDesc* pImportDesc = pDPObject->GetImportSourceDesc();
+ if ( pImportDesc )
+ {
+ // fill ScImportParam so ScImportDescriptor::FillProperties can be used
+ ScImportParam aParam;
+ aParam.bImport = ( pImportDesc->nType != sheet::DataImportMode_NONE );
+ aParam.aDBName = pImportDesc->aDBName;
+ aParam.aStatement = pImportDesc->aObject;
+ aParam.bNative = pImportDesc->bNative;
+ aParam.bSql = ( pImportDesc->nType == sheet::DataImportMode_SQL );
+ aParam.nType = static_cast<BYTE>(( pImportDesc->nType == sheet::DataImportMode_QUERY ) ? ScDbQuery : ScDbTable);
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
+ ScImportDescriptor::FillProperties( aSeq, aParam );
+ aRet <<= aSeq;
+ }
+ else
+ {
+ // empty sequence
+ uno::Sequence<beans::PropertyValue> aEmpty(0);
+ aRet <<= aEmpty;
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SOURCESERV ) )
+ {
+ rtl::OUString aServiceName;
+ const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
+ if (pServiceDesc)
+ aServiceName = pServiceDesc->aServiceName;
+ aRet <<= aServiceName; // empty string if no ServiceDesc set
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SERVICEARG ) )
+ {
+ const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
+ if (pServiceDesc)
+ {
+ uno::Sequence<beans::PropertyValue> aSeq( 4 );
+ beans::PropertyValue* pArray = aSeq.getArray();
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNO_SOURCENAME );
+ pArray[0].Value <<= rtl::OUString( pServiceDesc->aParSource );
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNO_OBJECTNAME );
+ pArray[1].Value <<= rtl::OUString( pServiceDesc->aParName );
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNO_USERNAME );
+ pArray[2].Value <<= rtl::OUString( pServiceDesc->aParUser );
+ pArray[3].Name = rtl::OUString::createFromAscii( SC_UNO_PASSWORD );
+ pArray[3].Value <<= rtl::OUString( pServiceDesc->aParPass );
+ aRet <<= aSeq;
+ }
+ else
+ {
+ // empty sequence
+ uno::Sequence<beans::PropertyValue> aEmpty(0);
+ aRet <<= aEmpty;
+ }
+ }
+ else
+ throw UnknownPropertyException();
+ }
+ }
+
+ return aRet;
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::addPropertyChangeListener(
+ const OUString& /* aPropertyName */, const Reference<XPropertyChangeListener >& /* xListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::removePropertyChangeListener(
+ const OUString& /* aPropertyName */, const Reference<XPropertyChangeListener >& /* aListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::addVetoableChangeListener(
+ const OUString& /* PropertyName */, const Reference<XVetoableChangeListener >& /* aListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SAL_CALL ScDataPilotDescriptorBase::removeVetoableChangeListener(
+ const OUString& /* PropertyName */, const Reference<XVetoableChangeListener >& /* aListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+// XDataPilotDataLayoutFieldSupplier
+
+Reference< XDataPilotField > SAL_CALL ScDataPilotDescriptorBase::getDataLayoutField() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( ScDPObject* pDPObject = GetDPObject() )
+ {
+ if( ScDPSaveData* pSaveData = pDPObject->GetSaveData() )
+ {
+ if( /*ScDPSaveDimension* pDataDim =*/ pSaveData->GetDataLayoutDimension() )
+ {
+ ScFieldIdentifier aFieldId( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_DATALAYOUT_NAME ) ), 0, true );
+ return new ScDataPilotFieldObj( *this, aFieldId );
+ }
+ }
+ }
+ return 0;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScDataPilotDescriptorBase::getSomething(
+ const Sequence<sal_Int8 >& rId ) throw(RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const Sequence<sal_Int8>& ScDataPilotDescriptorBase::getUnoTunnelId()
+{
+ static Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScDataPilotDescriptorBase* ScDataPilotDescriptorBase::getImplementation(
+ const Reference<XDataPilotDescriptor> xObj )
+{
+ ScDataPilotDescriptorBase* pRet = NULL;
+ Reference<lang::XUnoTunnel> xUT( xObj, UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScDataPilotDescriptorBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScDataPilotTableObj::ScDataPilotTableObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) :
+ ScDataPilotDescriptorBase( pDocSh ),
+ nTab( nT ),
+ aName( rN ),
+ aModifyListeners( 0 )
+{
+}
+
+ScDataPilotTableObj::~ScDataPilotTableObj()
+{
+}
+
+Any SAL_CALL ScDataPilotTableObj::queryInterface( const uno::Type& rType )
+ throw(RuntimeException)
+{
+ // since we manually do resolve the query for XDataPilotTable2
+ // we also need to do the same for XDataPilotTable
+ SC_QUERYINTERFACE( XDataPilotTable )
+ SC_QUERYINTERFACE( XDataPilotTable2 )
+ SC_QUERYINTERFACE( XModifyBroadcaster )
+
+ return ScDataPilotDescriptorBase::queryInterface( rType );
+}
+
+void SAL_CALL ScDataPilotTableObj::acquire() throw()
+{
+ ScDataPilotDescriptorBase::acquire();
+}
+
+void SAL_CALL ScDataPilotTableObj::release() throw()
+{
+ ScDataPilotDescriptorBase::release();
+}
+
+Sequence< uno::Type > SAL_CALL ScDataPilotTableObj::getTypes() throw(RuntimeException)
+{
+ static Sequence< uno::Type > aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ Sequence< uno::Type > aParentTypes = ScDataPilotDescriptorBase::getTypes();
+ sal_Int32 nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 2 );
+ uno::Type* pPtr = aTypes.getArray();
+ for (sal_Int32 i = 0; i < nParentLen; ++i)
+ pPtr[ i ] = pParentPtr[ i ]; // parent types first
+
+ pPtr[ nParentLen ] = getCppuType( (const Reference< XDataPilotTable2 >*)0 );
+ pPtr[ nParentLen+1 ] = getCppuType( (const Reference< XModifyBroadcaster >*)0 );
+ }
+ return aTypes;
+}
+
+Sequence<sal_Int8> SAL_CALL ScDataPilotTableObj::getImplementationId()
+ throw(RuntimeException)
+{
+ static Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// ---
+ScDPObject* ScDataPilotTableObj::GetDPObject() const
+{
+ return lcl_GetDPObject(GetDocShell(), nTab, aName);
+}
+
+void ScDataPilotTableObj::SetDPObject( ScDPObject* pDPObject )
+{
+ ScDocShell* pDocSh = GetDocShell();
+ ScDPObject* pDPObj = lcl_GetDPObject(pDocSh, nTab, aName);
+ if ( pDPObj && pDocSh )
+ {
+ ScDBDocFunc aFunc(*pDocSh);
+ aFunc.DataPilotUpdate( pDPObj, pDPObject, TRUE, TRUE );
+ }
+}
+
+// "rest of XDataPilotDescriptor"
+
+OUString SAL_CALL ScDataPilotTableObj::getName() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
+ if (pDPObj)
+ return pDPObj->GetName();
+ return OUString();
+}
+
+void SAL_CALL ScDataPilotTableObj::setName( const OUString& aNewName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
+ if (pDPObj)
+ {
+ //! test for existing names !!!
+
+ String aString(aNewName);
+ pDPObj->SetName( aString ); //! Undo - DBDocFunc ???
+ aName = aString;
+
+ // DataPilotUpdate would do too much (output table is not changed)
+ GetDocShell()->SetDocumentModified();
+ }
+}
+
+OUString SAL_CALL ScDataPilotTableObj::getTag() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
+ if (pDPObj)
+ return pDPObj->GetTag();
+ return OUString();
+}
+
+void SAL_CALL ScDataPilotTableObj::setTag( const OUString& aNewTag )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
+ if (pDPObj)
+ {
+ String aString(aNewTag);
+ pDPObj->SetTag( aString ); //! Undo - DBDocFunc ???
+
+ // DataPilotUpdate would do too much (output table is not changed)
+ GetDocShell()->SetDocumentModified();
+ }
+}
+
+// XDataPilotTable
+
+CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRange() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ CellRangeAddress aRet;
+ ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName);
+ if (pDPObj)
+ {
+ ScRange aRange(pDPObj->GetOutRange());
+ aRet.Sheet = aRange.aStart.Tab();
+ aRet.StartColumn = aRange.aStart.Col();
+ aRet.StartRow = aRange.aStart.Row();
+ aRet.EndColumn = aRange.aEnd.Col();
+ aRet.EndRow = aRange.aEnd.Row();
+ }
+ return aRet;
+}
+
+ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, BOOL bRecord, BOOL bApi );
+
+void SAL_CALL ScDataPilotTableObj::refresh() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName) )
+ RefreshDPObject( pDPObj, NULL, GetDocShell(), TRUE, TRUE );
+ //if (pDPObj)
+ //{
+ // ScDPObject* pNew = new ScDPObject(*pDPObj);
+ // ScDBDocFunc aFunc(*GetDocShell());
+ // aFunc.DataPilotUpdate( pDPObj, pNew, TRUE, TRUE );
+ // delete pNew; // DataPilotUpdate copies settings from "new" object
+ //}
+
+}
+
+Sequence< Sequence<Any> > SAL_CALL ScDataPilotTableObj::getDrillDownData(const CellAddress& aAddr)
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Sequence< Sequence<Any> > aTabData;
+ ScAddress aAddr2(static_cast<SCCOL>(aAddr.Column), static_cast<SCROW>(aAddr.Row), aAddr.Sheet);
+ ScDPObject* pObj = GetDPObject();
+ if (!pObj)
+ throw RuntimeException();
+
+ pObj->GetDrillDownData(aAddr2, aTabData);
+ return aTabData;
+}
+
+DataPilotTablePositionData SAL_CALL ScDataPilotTableObj::getPositionData(const CellAddress& aAddr)
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ DataPilotTablePositionData aPosData;
+ ScAddress aAddr2(static_cast<SCCOL>(aAddr.Column), static_cast<SCROW>(aAddr.Row), aAddr.Sheet);
+ ScDPObject* pObj = GetDPObject();
+ if (!pObj)
+ throw RuntimeException();
+
+ pObj->GetPositionData(aAddr2, aPosData);
+ return aPosData;
+}
+
+void SAL_CALL ScDataPilotTableObj::insertDrillDownSheet(const CellAddress& aAddr)
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = GetDPObject();
+ if (!pDPObj)
+ throw RuntimeException();
+
+ Sequence<DataPilotFieldFilter> aFilters;
+ pDPObj->GetDataFieldPositionData(
+ ScAddress(static_cast<SCCOL>(aAddr.Column), static_cast<SCROW>(aAddr.Row), aAddr.Sheet), aFilters);
+ GetDocShell()->GetBestViewShell()->ShowDataPilotSourceData(*pDPObj, aFilters);
+}
+
+CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRangeByType( sal_Int32 nType )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nType < 0 || nType > DataPilotOutputRangeType::RESULT)
+ throw IllegalArgumentException();
+
+ CellRangeAddress aRet;
+ if (ScDPObject* pDPObj = lcl_GetDPObject(GetDocShell(), nTab, aName))
+ ScUnoConversion::FillApiRange( aRet, pDPObj->GetOutputRangeByType( nType ) );
+ return aRet;
+}
+
+void SAL_CALL ScDataPilotTableObj::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<util::XModifyListener> *pObj = new uno::Reference<util::XModifyListener>( aListener );
+ aModifyListeners.Insert( pObj, aModifyListeners.Count() );
+
+ if ( aModifyListeners.Count() == 1 )
+ {
+ acquire(); // don't lose this object (one ref for all listeners)
+ }
+}
+
+void SAL_CALL ScDataPilotTableObj::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ acquire(); // in case the listeners have the last ref - released below
+
+ USHORT nCount = aModifyListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XModifyListener> *pObj = aModifyListeners[n];
+ if ( *pObj == aListener )
+ {
+ aModifyListeners.DeleteAndDestroy( n );
+
+ if ( aModifyListeners.Count() == 0 )
+ {
+ release(); // release the ref for the listeners
+ }
+
+ break;
+ }
+ }
+
+ release(); // might delete this object
+}
+
+void ScDataPilotTableObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA(ScDataPilotModifiedHint) &&
+ static_cast<const ScDataPilotModifiedHint&>(rHint).GetName() == aName )
+ {
+ Refreshed_Impl();
+ }
+
+ ScDataPilotDescriptorBase::Notify( rBC, rHint );
+}
+
+void ScDataPilotTableObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+
+ // the EventObject holds a Ref to this object until after the listener calls
+
+ ScDocument* pDoc = GetDocShell()->GetDocument();
+ for ( USHORT n=0; n<aModifyListeners.Count(); n++ )
+ pDoc->AddUnoListenerCall( *aModifyListeners[n], aEvent );
+}
+
+// ============================================================================
+
+ScDataPilotDescriptor::ScDataPilotDescriptor(ScDocShell* pDocSh) :
+ ScDataPilotDescriptorBase( pDocSh ),
+ mpDPObject(new ScDPObject(pDocSh ? pDocSh->GetDocument() : NULL) )
+{
+ mpDPObject->SetAlive(sal_True);
+ ScDPSaveData aSaveData;
+ // set defaults like in ScPivotParam constructor
+ aSaveData.SetColumnGrand( sal_True );
+ aSaveData.SetRowGrand( sal_True );
+ aSaveData.SetIgnoreEmptyRows( sal_False );
+ aSaveData.SetRepeatIfEmpty( sal_False );
+ mpDPObject->SetSaveData(aSaveData);
+ ScSheetSourceDesc aSheetDesc;
+ mpDPObject->SetSheetDesc(aSheetDesc);
+ mpDPObject->GetSource();
+}
+
+ScDataPilotDescriptor::~ScDataPilotDescriptor()
+{
+ delete mpDPObject;
+}
+
+ScDPObject* ScDataPilotDescriptor::GetDPObject() const
+{
+ return mpDPObject;
+}
+
+void ScDataPilotDescriptor::SetDPObject( ScDPObject* pDPObject )
+{
+ if (mpDPObject != pDPObject)
+ {
+ delete mpDPObject;
+ mpDPObject = pDPObject;
+ DBG_ERROR("replace DPObject should not happen");
+ }
+}
+
+// "rest of XDataPilotDescriptor"
+
+OUString SAL_CALL ScDataPilotDescriptor::getName() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return mpDPObject->GetName();
+}
+
+void SAL_CALL ScDataPilotDescriptor::setName( const OUString& aNewName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ mpDPObject->SetName( aNewName );
+}
+
+OUString SAL_CALL ScDataPilotDescriptor::getTag() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return mpDPObject->GetTag();
+}
+
+void SAL_CALL ScDataPilotDescriptor::setTag( const OUString& aNewTag )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ mpDPObject->SetTag( aNewTag );
+}
+
+// ============================================================================
+
+ScDataPilotChildObjBase::ScDataPilotChildObjBase( ScDataPilotDescriptorBase& rParent ) :
+ mrParent( rParent )
+{
+ mrParent.acquire();
+}
+
+ScDataPilotChildObjBase::ScDataPilotChildObjBase( ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId ) :
+ mrParent( rParent ),
+ maFieldId( rFieldId )
+{
+ mrParent.acquire();
+}
+
+ScDataPilotChildObjBase::~ScDataPilotChildObjBase()
+{
+ mrParent.release();
+}
+
+ScDPObject* ScDataPilotChildObjBase::GetDPObject() const
+{
+ return mrParent.GetDPObject();
+}
+
+void ScDataPilotChildObjBase::SetDPObject( ScDPObject* pDPObject )
+{
+ mrParent.SetDPObject( pDPObject );
+}
+
+ScDPSaveDimension* ScDataPilotChildObjBase::GetDPDimension( ScDPObject** ppDPObject ) const
+{
+ if( ScDPObject* pDPObj = GetDPObject() )
+ {
+ if( ppDPObject ) *ppDPObject = pDPObj;
+ if( ScDPSaveData* pSaveData = pDPObj->GetSaveData() )
+ {
+ if( maFieldId.mbDataLayout )
+ return pSaveData->GetDataLayoutDimension();
+
+ if( maFieldId.mnFieldIdx == 0 )
+ return pSaveData->GetDimensionByName( maFieldId.maFieldName );
+
+ // find dimension with specified index (search in duplicated dimensions)
+ String aFieldName = maFieldId.maFieldName; // needed for comparison
+ const List& rDimensions = pSaveData->GetDimensions();
+ ULONG nDimCount = rDimensions.Count();
+ sal_Int32 nFoundIdx = 0;
+ for( ULONG nDim = 0; nDim < nDimCount; ++nDim )
+ {
+ ScDPSaveDimension* pDim = static_cast< ScDPSaveDimension* >( rDimensions.GetObject( nDim ) );
+ if( !pDim->IsDataLayout() && (pDim->GetName() == aFieldName) )
+ {
+ if( nFoundIdx == maFieldId.mnFieldIdx )
+ return pDim;
+ ++nFoundIdx;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+sal_Int32 ScDataPilotChildObjBase::GetMemberCount() const
+{
+ sal_Int32 nRet = 0;
+ Reference<XNameAccess> xMembersNA = GetMembers();
+ if (xMembersNA.is())
+ {
+ Reference< XIndexAccess > xMembersIA( new ScNameToIndexAccess( xMembersNA ) );
+ nRet = xMembersIA->getCount();
+ }
+ return nRet;
+}
+
+Reference< XNameAccess > ScDataPilotChildObjBase::GetMembers() const
+{
+ Reference< XNameAccess > xMembersNA;
+ if( ScDPObject* pDPObj = GetDPObject() )
+ pDPObj->GetMembersNA( lcl_GetObjectIndex( pDPObj, maFieldId ), xMembersNA );
+ return xMembersNA;
+}
+
+// ============================================================================
+
+ScDataPilotFieldsObj::ScDataPilotFieldsObj( ScDataPilotDescriptorBase& rParent ) :
+ ScDataPilotChildObjBase( rParent )
+{
+}
+
+ScDataPilotFieldsObj::ScDataPilotFieldsObj( ScDataPilotDescriptorBase& rParent, DataPilotFieldOrientation eOrient ) :
+ ScDataPilotChildObjBase( rParent ),
+ maOrient( eOrient )
+{
+}
+
+ScDataPilotFieldsObj::~ScDataPilotFieldsObj()
+{
+}
+
+sal_Int32 lcl_GetFieldCount( const Reference<XDimensionsSupplier>& rSource, const Any& rOrient )
+{
+ sal_Int32 nRet = 0;
+
+ Reference<XNameAccess> xDimsName(rSource->getDimensions());
+ Reference<XIndexAccess> xIntDims(new ScNameToIndexAccess( xDimsName ));
+ sal_Int32 nIntCount = xIntDims->getCount();
+ if (rOrient.hasValue())
+ {
+ // all fields of the specified orientation, including duplicated
+ Reference<XPropertySet> xDim;
+ for (sal_Int32 i = 0; i < nIntCount; ++i)
+ {
+ xDim.set(xIntDims->getByIndex(i), UNO_QUERY);
+ if (xDim.is() && (xDim->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIENTAT))) == rOrient))
+ ++nRet;
+ }
+ }
+ else
+ {
+ // count all non-duplicated fields
+
+ Reference<XPropertySet> xDim;
+ for (sal_Int32 i = 0; i < nIntCount; ++i)
+ {
+ xDim.set(xIntDims->getByIndex(i), UNO_QUERY);
+ if ( xDim.is() && !lcl_IsDuplicated( xDim ) )
+ ++nRet;
+ }
+ }
+
+ return nRet;
+}
+
+BOOL lcl_GetFieldDataByIndex( const Reference<XDimensionsSupplier>& rSource,
+ const Any& rOrient, SCSIZE nIndex, ScFieldIdentifier& rFieldId )
+{
+ BOOL bOk = FALSE;
+ SCSIZE nPos = 0;
+ sal_Int32 nDimIndex = 0;
+
+ Reference<XNameAccess> xDimsName(rSource->getDimensions());
+ Reference<XIndexAccess> xIntDims(new ScNameToIndexAccess( xDimsName ));
+ sal_Int32 nIntCount = xIntDims->getCount();
+ Reference<XPropertySet> xDim;
+ if (rOrient.hasValue())
+ {
+ sal_Int32 i = 0;
+ while (i < nIntCount && !bOk)
+ {
+ xDim.set(xIntDims->getByIndex(i), UNO_QUERY);
+ if (xDim.is() && (xDim->getPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ORIENTAT))) == rOrient))
+ {
+ if (nPos == nIndex)
+ {
+ bOk = sal_True;
+ nDimIndex = i;
+ }
+ else
+ ++nPos;
+ }
+ ++i;
+ }
+ }
+ else
+ {
+ sal_Int32 i = 0;
+ while (i < nIntCount && !bOk)
+ {
+ xDim.set(xIntDims->getByIndex(i), UNO_QUERY);
+ if ( xDim.is() && !lcl_IsDuplicated( xDim ) )
+ {
+ if (nPos == nIndex)
+ {
+ bOk = sal_True;
+ nDimIndex = i;
+ }
+ else
+ ++nPos;
+ }
+ ++i;
+ }
+ }
+
+ if ( bOk )
+ {
+ xDim.set( xIntDims->getByIndex(nDimIndex), UNO_QUERY );
+ Reference<XNamed> xDimName( xDim, UNO_QUERY );
+ if ( xDimName.is() )
+ {
+ OUString sOriginalName( lcl_GetOriginalName( xDimName ) );
+ rFieldId.maFieldName = sOriginalName;
+ rFieldId.mbDataLayout = ScUnoHelpFunctions::GetBoolProperty( xDim,
+ OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ISDATALA)) );
+
+ sal_Int32 nRepeat = 0;
+ if ( rOrient.hasValue() && lcl_IsDuplicated( xDim ) )
+ {
+ // find the repeat count
+ // (this relies on the original dimension always being before the duplicates)
+
+ Reference<XNamed> xPrevName;
+ for (sal_Int32 i = 0; i < nDimIndex; ++i)
+ {
+ xPrevName.set( xIntDims->getByIndex(i), UNO_QUERY );
+ if ( xPrevName.is() && lcl_GetOriginalName( xPrevName ) == sOriginalName )
+ ++nRepeat;
+ }
+ }
+ rFieldId.mnFieldIdx = nRepeat;
+ }
+ else
+ bOk = sal_False;
+ }
+
+ return bOk;
+}
+
+BOOL lcl_GetFieldDataByName( ScDPObject* pDPObj, const OUString& rFieldName, ScFieldIdentifier& rFieldId )
+{
+ // "By name" is always the first match.
+ // The name "Data" always refers to the data layout field.
+ rFieldId.maFieldName = rFieldName;
+ rFieldId.mnFieldIdx = 0;
+ rFieldId.mbDataLayout = rFieldName.equalsAscii( SC_DATALAYOUT_NAME );
+
+ pDPObj->GetSource(); // IsDimNameInUse doesn't update source data
+
+ // check if the named field exists (not for data layout)
+ return rFieldId.mbDataLayout || pDPObj->IsDimNameInUse( rFieldName );
+}
+
+// XDataPilotFields
+
+ScDataPilotFieldObj* ScDataPilotFieldsObj::GetObjectByIndex_Impl( sal_Int32 nIndex ) const
+{
+// TODO
+ if (ScDPObject* pObj = GetDPObject())
+ {
+ ScFieldIdentifier aFieldId;
+ if (lcl_GetFieldDataByIndex( pObj->GetSource(), maOrient, nIndex, aFieldId ))
+ return new ScDataPilotFieldObj( mrParent, aFieldId, maOrient );
+ }
+ return 0;
+}
+
+ScDataPilotFieldObj* ScDataPilotFieldsObj::GetObjectByName_Impl(const OUString& aName) const
+{
+ if (ScDPObject* pDPObj = GetDPObject())
+ {
+ ScFieldIdentifier aFieldId;
+ if (lcl_GetFieldDataByName( pDPObj, aName, aFieldId ))
+ return new ScDataPilotFieldObj( mrParent, aFieldId, maOrient );
+ }
+ return 0;
+}
+
+// XEnumerationAccess
+
+Reference<XEnumeration> SAL_CALL ScDataPilotFieldsObj::createEnumeration()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotFieldsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDataPilotFieldsObj::getCount() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+// TODO
+ ScDPObject* pDPObj = GetDPObject();
+ return pDPObj ? lcl_GetFieldCount( pDPObj->GetSource(), maOrient ) : 0;
+}
+
+Any SAL_CALL ScDataPilotFieldsObj::getByIndex( sal_Int32 nIndex )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference< XPropertySet > xField( GetObjectByIndex_Impl( nIndex ) );
+ if (!xField.is())
+ throw IndexOutOfBoundsException();
+ return Any( xField );
+}
+
+uno::Type SAL_CALL ScDataPilotFieldsObj::getElementType() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((Reference<XPropertySet>*)0);
+}
+
+sal_Bool SAL_CALL ScDataPilotFieldsObj::hasElements() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+Any SAL_CALL ScDataPilotFieldsObj::getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference<XPropertySet> xField(GetObjectByName_Impl(aName));
+ if (!xField.is())
+ throw NoSuchElementException();
+ return Any( xField );
+}
+
+Sequence<OUString> SAL_CALL ScDataPilotFieldsObj::getElementNames()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+// TODO
+ if (ScDPObject* pDPObj = GetDPObject())
+ {
+ Sequence< OUString > aSeq( lcl_GetFieldCount( pDPObj->GetSource(), maOrient ) );
+ OUString* pAry = aSeq.getArray();
+ const List& rDimensions = pDPObj->GetSaveData()->GetDimensions();
+ sal_Int32 nDimCount = rDimensions.Count();
+ for (sal_Int32 nDim = 0; nDim < nDimCount; nDim++)
+ {
+ ScDPSaveDimension* pDim = (ScDPSaveDimension*)rDimensions.GetObject(nDim);
+ if(maOrient.hasValue() && (pDim->GetOrientation() == maOrient.get< DataPilotFieldOrientation >()))
+ {
+ *pAry = pDim->GetName();
+ ++pAry;
+ }
+ }
+ return aSeq;
+ }
+ return Sequence<OUString>();
+}
+
+sal_Bool SAL_CALL ScDataPilotFieldsObj::hasByName( const OUString& aName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return GetObjectByName_Impl(aName) != NULL;
+}
+
+//------------------------------------------------------------------------
+
+ScDataPilotFieldObj::ScDataPilotFieldObj(
+ ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId ) :
+ ScDataPilotChildObjBase( rParent, rFieldId ),
+ maPropSet( lcl_GetDataPilotFieldMap() )
+{
+}
+
+ScDataPilotFieldObj::ScDataPilotFieldObj( ScDataPilotDescriptorBase& rParent,
+ const ScFieldIdentifier& rFieldId, const Any& rOrient ) :
+ ScDataPilotChildObjBase( rParent, rFieldId ),
+ maPropSet( lcl_GetDataPilotFieldMap() ),
+ maOrient( rOrient )
+{
+}
+
+ScDataPilotFieldObj::~ScDataPilotFieldObj()
+{
+}
+
+// XNamed
+
+OUString SAL_CALL ScDataPilotFieldObj::getName() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ OUString aName;
+ if( ScDPSaveDimension* pDim = GetDPDimension() )
+ {
+ if( pDim->IsDataLayout() )
+ aName = OUString( RTL_CONSTASCII_USTRINGPARAM( SC_DATALAYOUT_NAME ) );
+ else
+ {
+ const rtl::OUString* pLayoutName = pDim->GetLayoutName();
+ if (pLayoutName)
+ aName = *pLayoutName;
+ else
+ aName = pDim->GetName();
+ } }
+ return aName;
+}
+
+void SAL_CALL ScDataPilotFieldObj::setName( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ ScDPSaveDimension* pDim = GetDPDimension( &pDPObj );
+ if( pDim && !pDim->IsDataLayout() )
+ {
+ String aName( rName );
+ pDim->SetLayoutName(aName);
+ SetDPObject( pDPObj );
+ }
+}
+
+// XPropertySet
+
+Reference<XPropertySetInfo> SAL_CALL ScDataPilotFieldObj::getPropertySetInfo()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static Reference<XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( maPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScDataPilotFieldObj::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ if ( aNameString.EqualsAscii( SC_UNONAME_FUNCTION ) )
+ {
+ // #i109350# use GetEnumFromAny because it also allows sal_Int32
+ GeneralFunction eFunction = (GeneralFunction)
+ ScUnoHelpFunctions::GetEnumFromAny( aValue );
+ setFunction( eFunction );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SUBTOTALS ) )
+ {
+ Sequence< GeneralFunction > aSubtotals;
+ if( aValue >>= aSubtotals )
+ setSubtotals( aSubtotals );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ORIENT ) )
+ {
+ //! test for correct enum type?
+ DataPilotFieldOrientation eOrient = (DataPilotFieldOrientation)
+ ScUnoHelpFunctions::GetEnumFromAny( aValue );
+ setOrientation( eOrient );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SELPAGE ) )
+ {
+ OUString sCurrentPage;
+ if (aValue >>= sCurrentPage)
+ setCurrentPage(sCurrentPage);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_USESELPAGE ) )
+ {
+ setUseCurrentPage(cppu::any2bool(aValue));
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASAUTOSHOW ) )
+ {
+ if (!cppu::any2bool(aValue))
+ setAutoShowInfo(NULL);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_AUTOSHOW ) )
+ {
+ DataPilotFieldAutoShowInfo aInfo;
+ if (aValue >>= aInfo)
+ setAutoShowInfo(&aInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASLAYOUTINFO ) )
+ {
+ if (!cppu::any2bool(aValue))
+ setLayoutInfo(NULL);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_LAYOUTINFO ) )
+ {
+ DataPilotFieldLayoutInfo aInfo;
+ if (aValue >>= aInfo)
+ setLayoutInfo(&aInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASREFERENCE ) )
+ {
+ if (!cppu::any2bool(aValue))
+ setReference(NULL);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFERENCE ) )
+ {
+ DataPilotFieldReference aRef;
+ if (aValue >>= aRef)
+ setReference(&aRef);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASSORTINFO ) )
+ {
+ if (!cppu::any2bool(aValue))
+ setSortInfo(NULL);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SORTINFO ) )
+ {
+ DataPilotFieldSortInfo aInfo;
+ if (aValue >>= aInfo)
+ setSortInfo(&aInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ISGROUP ) )
+ {
+ if (!cppu::any2bool(aValue))
+ setGroupInfo(NULL);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_GROUPINFO ) )
+ {
+ DataPilotFieldGroupInfo aInfo;
+ if (aValue >>= aInfo)
+ setGroupInfo(&aInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SHOWEMPTY ) )
+ {
+ setShowEmpty(cppu::any2bool(aValue));
+ }
+}
+
+Any SAL_CALL ScDataPilotFieldObj::getPropertyValue( const OUString& aPropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ Any aRet;
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_FUNCTION ) )
+ aRet <<= getFunction();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SUBTOTALS ) )
+ aRet <<= getSubtotals();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ORIENT ) )
+ aRet <<= getOrientation();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SELPAGE ) )
+ aRet <<= getCurrentPage();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_USESELPAGE ) )
+ aRet <<= getUseCurrentPage();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASAUTOSHOW ) )
+ aRet = ::cppu::bool2any(getAutoShowInfo() != NULL);
+ else if ( aNameString.EqualsAscii( SC_UNONAME_AUTOSHOW ) )
+ {
+ const DataPilotFieldAutoShowInfo* pInfo = getAutoShowInfo();
+ if (pInfo)
+ aRet <<= DataPilotFieldAutoShowInfo(*pInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASLAYOUTINFO ) )
+ aRet = ::cppu::bool2any(getLayoutInfo() != NULL);
+ else if ( aNameString.EqualsAscii( SC_UNONAME_LAYOUTINFO ) )
+ {
+ const DataPilotFieldLayoutInfo* pInfo = getLayoutInfo();
+ if (pInfo)
+ aRet <<= DataPilotFieldLayoutInfo(*pInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASREFERENCE ) )
+ aRet = ::cppu::bool2any(getReference() != NULL);
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFERENCE ) )
+ {
+ const DataPilotFieldReference* pRef = getReference();
+ if (pRef)
+ aRet <<= DataPilotFieldReference(*pRef);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HASSORTINFO ) )
+ aRet = ::cppu::bool2any(getSortInfo() != NULL);
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SORTINFO ) )
+ {
+ const DataPilotFieldSortInfo* pInfo = getSortInfo();
+ if (pInfo)
+ aRet <<= DataPilotFieldSortInfo(*pInfo);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ISGROUP ) )
+ aRet = ::cppu::bool2any(hasGroupInfo());
+ else if ( aNameString.EqualsAscii( SC_UNONAME_GROUPINFO ) )
+ {
+ aRet <<= getGroupInfo();
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_SHOWEMPTY ) )
+ aRet <<= getShowEmpty();
+
+ return aRet;
+}
+
+// XDatePilotField
+
+Reference<XIndexAccess> SAL_CALL ScDataPilotFieldObj::getItems()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!mxItems.is())
+ mxItems.set( new ScDataPilotItemsObj( mrParent, maFieldId ) );
+ return mxItems;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDataPilotFieldObj )
+
+DataPilotFieldOrientation ScDataPilotFieldObj::getOrientation() const
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim ? static_cast< DataPilotFieldOrientation >( pDim->GetOrientation() ) : DataPilotFieldOrientation_HIDDEN;
+}
+
+void ScDataPilotFieldObj::setOrientation(DataPilotFieldOrientation eNew)
+{
+ SolarMutexGuard aGuard;
+ if (maOrient.hasValue() && (eNew == maOrient.get< DataPilotFieldOrientation >()))
+ return;
+
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+
+ /* If the field was taken from getDataPilotFields(), don't reset the
+ orientation for an existing use, but create a duplicated field
+ instead (for "Data" orientation only). */
+ if ( !maOrient.hasValue() && !maFieldId.mbDataLayout &&
+ (pDim->GetOrientation() != DataPilotFieldOrientation_HIDDEN) &&
+ (eNew == DataPilotFieldOrientation_DATA) )
+ {
+
+ ScDPSaveDimension* pNewDim = 0;
+
+ // look for existing duplicate with orientation "hidden"
+
+ String aNameStr( maFieldId.maFieldName );
+ const List& rDimensions = pSaveData->GetDimensions();
+ sal_Int32 nDimCount = rDimensions.Count();
+ sal_Int32 nFound = 0;
+ for ( sal_Int32 nDim = 0; nDim < nDimCount && !pNewDim; nDim++ )
+ {
+ ScDPSaveDimension* pOneDim = static_cast<ScDPSaveDimension*>(rDimensions.GetObject(nDim));
+ if ( !pOneDim->IsDataLayout() && (pOneDim->GetName() == aNameStr) )
+ {
+ if ( pOneDim->GetOrientation() == DataPilotFieldOrientation_HIDDEN )
+ pNewDim = pOneDim; // use this one
+ else
+ ++nFound; // count existing non-hidden occurences
+ }
+ }
+
+ if ( !pNewDim ) // if none found, create a new duplicated dimension
+ pNewDim = &pSaveData->DuplicateDimension( *pDim );
+
+ maFieldId.mnFieldIdx = nFound; // keep accessing the new one
+ pDim = pNewDim;
+ }
+
+ pDim->SetOrientation(sal::static_int_cast<USHORT>(eNew));
+
+ // move changed field behind all other fields (make it the last field in dimension)
+ pSaveData->SetPosition( pDim, pSaveData->GetDimensions().Count() );
+
+ SetDPObject( pDPObj );
+
+ maOrient <<= eNew; // modifying the same object's orientation again doesn't create another duplicate
+ }
+}
+
+GeneralFunction ScDataPilotFieldObj::getFunction() const
+{
+ SolarMutexGuard aGuard;
+ GeneralFunction eRet = GeneralFunction_NONE;
+ if( ScDPSaveDimension* pDim = GetDPDimension() )
+ {
+ if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
+ {
+ // for non-data fields, property Function is the subtotals
+ long nSubCount = pDim->GetSubTotalsCount();
+ if ( nSubCount > 0 )
+ eRet = (GeneralFunction)pDim->GetSubTotalFunc(0); // always use the first one
+ // else keep NONE
+ }
+ else
+ eRet = (GeneralFunction)pDim->GetFunction();
+ }
+ return eRet;
+}
+
+void ScDataPilotFieldObj::setFunction(GeneralFunction eNewFunc)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
+ {
+ // for non-data fields, property Function is the subtotals
+ if ( eNewFunc == GeneralFunction_NONE )
+ pDim->SetSubTotals( 0, NULL );
+ else
+ {
+ USHORT nFunc = sal::static_int_cast<USHORT>( eNewFunc );
+ pDim->SetSubTotals( 1, &nFunc );
+ }
+ }
+ else
+ pDim->SetFunction( sal::static_int_cast<USHORT>( eNewFunc ) );
+ SetDPObject( pDPObj );
+ }
+}
+
+Sequence< GeneralFunction > ScDataPilotFieldObj::getSubtotals() const
+{
+ SolarMutexGuard aGuard;
+ Sequence< GeneralFunction > aRet;
+ if( ScDPSaveDimension* pDim = GetDPDimension() )
+ {
+ if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
+ {
+ // for non-data fields, property Functions is the sequence of subtotals
+ sal_Int32 nCount = static_cast< sal_Int32 >( pDim->GetSubTotalsCount() );
+ if ( nCount > 0 )
+ {
+ aRet.realloc( nCount );
+ for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
+ aRet[ nIdx ] = (GeneralFunction)pDim->GetSubTotalFunc( nIdx );
+ }
+ }
+ }
+ return aRet;
+}
+
+void ScDataPilotFieldObj::setSubtotals( const Sequence< GeneralFunction >& rSubtotals )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ if( pDim->GetOrientation() != DataPilotFieldOrientation_DATA )
+ {
+ sal_Int32 nCount = rSubtotals.getLength();
+ if( nCount == 1 )
+ {
+ // count 1: all values are allowed (including NONE and AUTO)
+ if( rSubtotals[ 0 ] == GeneralFunction_NONE )
+ pDim->SetSubTotals( 0, NULL );
+ else
+ {
+ USHORT nFunc = sal::static_int_cast<USHORT>( rSubtotals[ 0 ] );
+ pDim->SetSubTotals( 1, &nFunc );
+ }
+ }
+ else if( nCount > 1 )
+ {
+ // set multiple functions, ignore NONE and AUTO in this case
+ ::std::vector< USHORT > aSubt;
+ for( sal_Int32 nIdx = 0; nIdx < nCount; ++nIdx )
+ {
+ GeneralFunction eFunc = rSubtotals[ nIdx ];
+ if( (eFunc != GeneralFunction_NONE) && (eFunc != GeneralFunction_AUTO) )
+ {
+ // do not insert functions twice
+ USHORT nFunc = static_cast< USHORT >( eFunc );
+ if( ::std::find( aSubt.begin(), aSubt.end(), nFunc ) == aSubt.end() )
+ aSubt.push_back( nFunc );
+ }
+ }
+ // set values from vector to ScDPSaveDimension
+ if ( aSubt.empty() )
+ pDim->SetSubTotals( 0, NULL );
+ else
+ pDim->SetSubTotals( static_cast< long >( aSubt.size() ), &aSubt.front() );
+ }
+ }
+ SetDPObject( pDPObj );
+ }
+}
+
+OUString ScDataPilotFieldObj::getCurrentPage() const
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ if( pDim && pDim->HasCurrentPage() )
+ return pDim->GetCurrentPage();
+ return OUString();
+}
+
+void ScDataPilotFieldObj::setCurrentPage( const OUString& rPage )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ String aPage( rPage );
+ pDim->SetCurrentPage( &aPage );
+ SetDPObject( pDPObj );
+ }
+}
+
+sal_Bool ScDataPilotFieldObj::getUseCurrentPage() const
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim && pDim->HasCurrentPage();
+}
+
+void ScDataPilotFieldObj::setUseCurrentPage( sal_Bool bUse )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ if( bUse )
+ {
+ /* It is somehow useless to set the property "HasSelectedPage" to
+ true, because it is still needed to set an explicit page name. */
+ if( !pDim->HasCurrentPage() )
+ {
+ String aPage;
+ pDim->SetCurrentPage( &aPage );
+ }
+ }
+ else
+ pDim->SetCurrentPage( 0 );
+ SetDPObject( pDPObj );
+ }
+}
+
+const DataPilotFieldAutoShowInfo* ScDataPilotFieldObj::getAutoShowInfo()
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim ? pDim->GetAutoShowInfo() : 0;
+}
+
+void ScDataPilotFieldObj::setAutoShowInfo( const DataPilotFieldAutoShowInfo* pInfo )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ pDim->SetAutoShowInfo( pInfo );
+ SetDPObject( pDPObj );
+ }
+}
+
+const DataPilotFieldLayoutInfo* ScDataPilotFieldObj::getLayoutInfo()
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim ? pDim->GetLayoutInfo() : 0;
+}
+
+void ScDataPilotFieldObj::setLayoutInfo( const DataPilotFieldLayoutInfo* pInfo )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ pDim->SetLayoutInfo( pInfo );
+ SetDPObject( pDPObj );
+ }
+}
+
+const DataPilotFieldReference* ScDataPilotFieldObj::getReference()
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim ? pDim->GetReferenceValue() : 0;
+}
+
+void ScDataPilotFieldObj::setReference( const DataPilotFieldReference* pInfo )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ pDim->SetReferenceValue( pInfo );
+ SetDPObject( pDPObj );
+ }
+}
+
+const DataPilotFieldSortInfo* ScDataPilotFieldObj::getSortInfo()
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim ? pDim->GetSortInfo() : 0;
+}
+
+void ScDataPilotFieldObj::setSortInfo( const DataPilotFieldSortInfo* pInfo )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ pDim->SetSortInfo( pInfo );
+ SetDPObject( pDPObj );
+ }
+}
+
+sal_Bool ScDataPilotFieldObj::getShowEmpty() const
+{
+ SolarMutexGuard aGuard;
+ ScDPSaveDimension* pDim = GetDPDimension();
+ return pDim && pDim->GetShowEmpty();
+}
+
+void ScDataPilotFieldObj::setShowEmpty( sal_Bool bShow )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ pDim->SetShowEmpty( bShow );
+ SetDPObject( pDPObj );
+ }
+}
+
+sal_Bool ScDataPilotFieldObj::hasGroupInfo()
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ if( const ScDPDimensionSaveData* pDimData = pDPObj->GetSaveData()->GetExistingDimensionData() )
+ return pDimData->GetNamedGroupDim( pDim->GetName() ) || pDimData->GetNumGroupDim( pDim->GetName() );
+ return sal_False;
+}
+
+DataPilotFieldGroupInfo ScDataPilotFieldObj::getGroupInfo()
+{
+ SolarMutexGuard aGuard;
+ DataPilotFieldGroupInfo aInfo;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ if( const ScDPDimensionSaveData* pDimData = pDPObj->GetSaveData()->GetExistingDimensionData() )
+ {
+ if( const ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDim( pDim->GetName() ) )
+ {
+ // grouped by ...
+ aInfo.GroupBy = pGroupDim->GetDatePart();
+
+ // find source field
+ try
+ {
+ Reference< XNameAccess > xFields( mrParent.getDataPilotFields(), UNO_QUERY_THROW );
+ aInfo.SourceField.set( xFields->getByName( pGroupDim->GetSourceDimName() ), UNO_QUERY );
+ }
+ catch( Exception& )
+ {
+ }
+
+ ScDataPilotConversion::FillGroupInfo( aInfo, pGroupDim->GetDateInfo() );
+ if( pGroupDim->GetDatePart() == 0 )
+ {
+ // fill vector of group and group member information
+ ScFieldGroups aGroups;
+ for( sal_Int32 nIdx = 0, nCount = pGroupDim->GetGroupCount(); nIdx < nCount; ++nIdx )
+ {
+ if( const ScDPSaveGroupItem* pGroup = pGroupDim->GetGroupByIndex( nIdx ) )
+ {
+ ScFieldGroup aGroup;
+ aGroup.maName = pGroup->GetGroupName();
+ for( sal_Int32 nMemIdx = 0, nMemCount = pGroup->GetElementCount(); nMemIdx < nMemCount; ++nMemIdx )
+ if( const String* pMem = pGroup->GetElementByIndex( nMemIdx ) )
+ aGroup.maMembers.push_back( *pMem );
+ aGroups.push_back( aGroup );
+ }
+ }
+ aInfo.Groups = new ScDataPilotFieldGroupsObj( aGroups );
+ }
+ }
+ else if( const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( pDim->GetName() ) )
+ {
+ if (pNumGroupDim->GetDatePart())
+ {
+ ScDataPilotConversion::FillGroupInfo( aInfo, pNumGroupDim->GetDateInfo() );
+ aInfo.GroupBy = pNumGroupDim->GetDatePart();
+ }
+ else
+ {
+ ScDataPilotConversion::FillGroupInfo( aInfo, pNumGroupDim->GetInfo() );
+ }
+ }
+ }
+ }
+ return aInfo;
+}
+
+void ScDataPilotFieldObj::setGroupInfo( const DataPilotFieldGroupInfo* pInfo )
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( /*ScDPSaveDimension* pDim =*/ GetDPDimension( &pDPObj ) )
+ {
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+ if( pInfo && lclCheckMinMaxStep( *pInfo ) )
+ {
+ ScDPNumGroupInfo aInfo;
+ aInfo.Enable = sal_True;
+ aInfo.DateValues = pInfo->HasDateValues;
+ aInfo.AutoStart = pInfo->HasAutoStart;
+ aInfo.AutoEnd = pInfo->HasAutoEnd;
+ aInfo.Start = pInfo->Start;
+ aInfo.End = pInfo->End;
+ aInfo.Step = pInfo->Step;
+ Reference< XNamed > xNamed( pInfo->SourceField, UNO_QUERY );
+ if( xNamed.is() )
+ {
+ ScDPSaveGroupDimension aGroupDim( xNamed->getName(), getName() );
+ if( pInfo->GroupBy )
+ aGroupDim.SetDateInfo(aInfo, pInfo->GroupBy);
+ else
+ {
+ Reference<XIndexAccess> xIndex(pInfo->Groups, UNO_QUERY);
+ if (xIndex.is())
+ {
+ sal_Int32 nCount(xIndex->getCount());
+ for(sal_Int32 i = 0; i < nCount; i++)
+ {
+ Reference<XNamed> xGroupNamed(xIndex->getByIndex(i), UNO_QUERY);
+ if (xGroupNamed.is())
+ {
+ ScDPSaveGroupItem aItem(xGroupNamed->getName());
+ Reference<XIndexAccess> xGroupIndex(xGroupNamed, UNO_QUERY);
+ if (xGroupIndex.is())
+ {
+ sal_Int32 nItemCount(xGroupIndex->getCount());
+ for (sal_Int32 j = 0; j < nItemCount; ++j)
+ {
+ Reference<XNamed> xItemNamed(xGroupIndex->getByIndex(j), UNO_QUERY);
+ if (xItemNamed.is())
+ aItem.AddElement(xItemNamed->getName());
+ }
+ }
+ aGroupDim.AddGroupItem(aItem);
+ }
+ }
+ }
+ }
+
+ // get dimension savedata or create new if none
+ ScDPDimensionSaveData& rDimSaveData = *pSaveData->GetDimensionData();
+ rDimSaveData.ReplaceGroupDimension( aGroupDim );
+ }
+ else // no source field in group info -> numeric group
+ {
+ ScDPDimensionSaveData* pDimData = pSaveData->GetDimensionData(); // created if not there
+
+ ScDPSaveNumGroupDimension* pExisting = pDimData->GetNumGroupDimAcc( getName() );
+ if ( pExisting )
+ {
+ if (pInfo->GroupBy)
+ pExisting->SetDateInfo(aInfo, pInfo->GroupBy);
+ // modify existing group dimension
+ pExisting->SetGroupInfo( aInfo );
+ }
+ else if (pInfo->GroupBy)
+ {
+ // create new group dimension
+ ScDPSaveNumGroupDimension aNumGroupDim( getName(), aInfo, pInfo->GroupBy );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+ else
+ {
+ // create new group dimension
+ ScDPSaveNumGroupDimension aNumGroupDim( getName(), aInfo );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+ }
+ }
+ else // null passed as argument
+ {
+ pSaveData->SetDimensionData( 0 );
+ }
+
+ pDPObj->SetSaveData( *pSaveData );
+ SetDPObject( pDPObj );
+ }
+}
+
+sal_Bool ScDataPilotFieldObj::HasString(const Sequence< OUString >& rItems, const OUString& aString)
+{
+ sal_Bool bRet = sal_False;
+
+ sal_Int32 nCount(rItems.getLength());
+ sal_Int32 nItem(0);
+ while (nItem < nCount && !bRet)
+ {
+ bRet = rItems[nItem] == aString;
+ ++nItem;
+ }
+
+ return bRet;
+}
+
+// XDataPilotFieldGrouping
+Reference< XDataPilotField > SAL_CALL ScDataPilotFieldObj::createNameGroup( const Sequence< OUString >& rItems )
+ throw (RuntimeException, IllegalArgumentException)
+{
+ SolarMutexGuard aGuard;
+
+ Reference< XDataPilotField > xRet;
+ OUString sNewDim;
+
+ if( !rItems.hasElements() )
+ throw IllegalArgumentException();
+
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ String aDimName = pDim->GetName();
+
+ ScDPSaveData aSaveData = *pDPObj->GetSaveData();
+ ScDPDimensionSaveData* pDimData = aSaveData.GetDimensionData(); // created if not there
+
+ // find original base
+ String aBaseDimName( aDimName );
+ const ScDPSaveGroupDimension* pBaseGroupDim = pDimData->GetNamedGroupDim( aDimName );
+ if ( pBaseGroupDim )
+ {
+ // any entry's SourceDimName is the original base
+ aBaseDimName = pBaseGroupDim->GetSourceDimName();
+ }
+
+ // find existing group dimension
+ // (using the selected dim, can be intermediate group dim)
+ ScDPSaveGroupDimension* pGroupDimension = pDimData->GetGroupDimAccForBase( aDimName );
+
+ // remove the selected items from their groups
+ // (empty groups are removed, too)
+ sal_Int32 nEntryCount = rItems.getLength();
+ sal_Int32 nEntry;
+ if ( pGroupDimension )
+ {
+ for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName(rItems[nEntry]);
+ if ( pBaseGroupDim )
+ {
+ // for each selected (intermediate) group, remove all its items
+ // (same logic as for adding, below)
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
+ if ( pBaseGroup )
+ pBaseGroup->RemoveElementsFromGroups( *pGroupDimension ); // remove all elements
+ else
+ pGroupDimension->RemoveFromGroups( aEntryName );
+ }
+ else
+ pGroupDimension->RemoveFromGroups( aEntryName );
+ }
+ }
+
+ ScDPSaveGroupDimension* pNewGroupDim = 0;
+ if ( !pGroupDimension )
+ {
+ // create a new group dimension
+ String aGroupDimName = pDimData->CreateGroupDimName( aBaseDimName, *pDPObj, false, NULL );
+ pNewGroupDim = new ScDPSaveGroupDimension( aBaseDimName, aGroupDimName );
+ sNewDim = aGroupDimName;
+
+ pGroupDimension = pNewGroupDim; // make changes to the new dim if none existed
+
+ if ( pBaseGroupDim )
+ {
+ // If it's a higher-order group dimension, pre-allocate groups for all
+ // non-selected original groups, so the individual base members aren't
+ // used for automatic groups (this would make the original groups hard
+ // to find).
+ //! Also do this when removing groups?
+ //! Handle this case dynamically with automatic groups?
+
+ long nGroupCount = pBaseGroupDim->GetGroupCount();
+ for ( long nGroup = 0; nGroup < nGroupCount; nGroup++ )
+ {
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetGroupByIndex( nGroup );
+
+ StrData aStrData( pBaseGroup->GetGroupName() );
+ if ( !HasString(rItems, aStrData.GetString()) ) //! ignore case?
+ {
+ // add an additional group for each item that is not in the selection
+ ScDPSaveGroupItem aGroup( pBaseGroup->GetGroupName() );
+ aGroup.AddElementsFromGroup( *pBaseGroup );
+ pGroupDimension->AddGroupItem( aGroup );
+ }
+ }
+ }
+ }
+ String aGroupDimName = pGroupDimension->GetGroupDimName();
+
+ //! localized prefix string
+ String aGroupName = pGroupDimension->CreateGroupName( String( RTL_CONSTASCII_USTRINGPARAM( "Group" ) ) );
+ ScDPSaveGroupItem aGroup( aGroupName );
+ Reference< XNameAccess > xMembers = GetMembers();
+ if (!xMembers.is())
+ {
+ delete pNewGroupDim;
+ throw RuntimeException();
+ }
+
+ for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName(rItems[nEntry]);
+
+ if (!xMembers->hasByName(aEntryName))
+ {
+ delete pNewGroupDim;
+ throw IllegalArgumentException();
+ }
+
+ if ( pBaseGroupDim )
+ {
+ // for each selected (intermediate) group, add all its items
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
+ if ( pBaseGroup )
+ aGroup.AddElementsFromGroup( *pBaseGroup );
+ else
+ aGroup.AddElement( aEntryName ); // no group found -> automatic group, add the item itself
+ }
+ else
+ aGroup.AddElement( aEntryName ); // no group dimension, add all items directly
+ }
+
+ pGroupDimension->AddGroupItem( aGroup );
+
+ if ( pNewGroupDim )
+ {
+ pDimData->AddGroupDimension( *pNewGroupDim );
+ delete pNewGroupDim; // AddGroupDimension copies the object
+ // don't access pGroupDimension after here
+ }
+ pGroupDimension = pNewGroupDim = NULL;
+
+ // set orientation
+ ScDPSaveDimension* pSaveDimension = aSaveData.GetDimensionByName( aGroupDimName );
+ if ( pSaveDimension->GetOrientation() == DataPilotFieldOrientation_HIDDEN )
+ {
+ ScDPSaveDimension* pOldDimension = aSaveData.GetDimensionByName( aDimName );
+ pSaveDimension->SetOrientation( pOldDimension->GetOrientation() );
+ long nPosition = 0; //! before (immediate) base
+ aSaveData.SetPosition( pSaveDimension, nPosition );
+ }
+
+ // apply changes
+ pDPObj->SetSaveData( aSaveData );
+ SetDPObject( pDPObj );
+ }
+
+ // if new grouping field has been created (on first group), return it
+ if( sNewDim.getLength() > 0 )
+ {
+ Reference< XNameAccess > xFields(mrParent.getDataPilotFields(), UNO_QUERY);
+ if (xFields.is())
+ {
+ xRet.set(xFields->getByName(sNewDim), UNO_QUERY);
+ DBG_ASSERT(xRet.is(), "there is a name, so there should be also a field");
+ }
+ }
+ return xRet;
+}
+
+Reference < XDataPilotField > SAL_CALL ScDataPilotFieldObj::createDateGroup( const DataPilotFieldGroupInfo& rInfo )
+ throw (RuntimeException, IllegalArgumentException)
+{
+ SolarMutexGuard aGuard;
+ using namespace ::com::sun::star::sheet::DataPilotFieldGroupBy;
+
+ // check min/max/step, HasDateValues must be set always
+ if( !rInfo.HasDateValues || !lclCheckMinMaxStep( rInfo ) )
+ throw IllegalArgumentException();
+ // only a single date flag is allowed
+ if( (rInfo.GroupBy == 0) || (rInfo.GroupBy > YEARS) || ((rInfo.GroupBy & (rInfo.GroupBy - 1)) != 0) )
+ throw IllegalArgumentException();
+ // step must be zero, if something else than DAYS is specified
+ if( rInfo.Step >= ((rInfo.GroupBy == DAYS) ? 32768.0 : 1.0) )
+ throw IllegalArgumentException();
+
+ String aGroupDimName;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ ScDPNumGroupInfo aInfo;
+ aInfo.Enable = sal_True;
+ aInfo.DateValues = (rInfo.GroupBy == DAYS) && (rInfo.Step >= 1.0);
+ aInfo.AutoStart = rInfo.HasAutoStart;
+ aInfo.AutoEnd = rInfo.HasAutoEnd;
+ aInfo.Start = rInfo.Start;
+ aInfo.End = rInfo.End;
+ aInfo.Step = static_cast< sal_Int32 >( rInfo.Step );
+
+ // create a local copy of the entire save data (will be written back below)
+ ScDPSaveData aSaveData = *pDPObj->GetSaveData();
+ // get or create dimension save data
+ ScDPDimensionSaveData& rDimData = *aSaveData.GetDimensionData();
+
+ // find source dimension name
+ const String& rDimName = pDim->GetName();
+ const ScDPSaveGroupDimension* pGroupDim = rDimData.GetNamedGroupDim( rDimName );
+ String aSrcDimName = pGroupDim ? pGroupDim->GetSourceDimName() : rDimName;
+
+ // find a group dimension for the base field, or get numeric grouping
+ pGroupDim = rDimData.GetFirstNamedGroupDim( aSrcDimName );
+ const ScDPSaveNumGroupDimension* pNumGroupDim = rDimData.GetNumGroupDim( aSrcDimName );
+
+ // do not group by dates, if named groups or numeric grouping is present
+ bool bHasNamedGrouping = pGroupDim && !pGroupDim->GetDateInfo().Enable;
+ bool bHasNumGrouping = pNumGroupDim && pNumGroupDim->GetInfo().Enable && !pNumGroupDim->GetInfo().DateValues && !pNumGroupDim->GetDateInfo().Enable;
+ if( bHasNamedGrouping || bHasNumGrouping )
+ throw IllegalArgumentException();
+
+ if( aInfo.DateValues ) // create day ranges grouping
+ {
+ // first remove all named group dimensions
+ while( pGroupDim )
+ {
+ String aGroupDimName2 = pGroupDim->GetGroupDimName();
+ // find next group dimension before deleting this group
+ pGroupDim = rDimData.GetNextNamedGroupDim( aGroupDimName2 );
+ // remove from dimension save data
+ rDimData.RemoveGroupDimension( aGroupDimName2 );
+ // also remove save data settings for the dimension that no longer exists
+ aSaveData.RemoveDimensionByName( aGroupDimName2 );
+ }
+ // create or replace the number grouping dimension
+ ScDPSaveNumGroupDimension aNumGroupDim( aSrcDimName, aInfo );
+ rDimData.ReplaceNumGroupDimension( aNumGroupDim );
+ }
+ else // create date grouping
+ {
+ // collect all existing date flags
+ sal_Int32 nDateParts = rDimData.CollectDateParts( aSrcDimName );
+ if( nDateParts == 0 )
+ {
+ // insert numeric group dimension, if no date groups exist yet (or replace day range grouping)
+ ScDPSaveNumGroupDimension aNumGroupDim( aSrcDimName, aInfo, rInfo.GroupBy );
+ rDimData.ReplaceNumGroupDimension( aNumGroupDim );
+ }
+ else if( (nDateParts & rInfo.GroupBy) == 0 ) // do nothing if date field exists already
+ {
+ // create new named group dimension for additional date groups
+ aGroupDimName = rDimData.CreateDateGroupDimName( rInfo.GroupBy, *pDPObj, true, 0 );
+ ScDPSaveGroupDimension aGroupDim( aSrcDimName, aGroupDimName, aInfo, rInfo.GroupBy );
+ rDimData.AddGroupDimension( aGroupDim );
+
+ // set orientation of new named group dimension
+ ScDPSaveDimension& rSaveDim = *aSaveData.GetDimensionByName( aGroupDimName );
+ if( rSaveDim.GetOrientation() == DataPilotFieldOrientation_HIDDEN )
+ {
+ ScDPSaveDimension& rOldDim = *aSaveData.GetDimensionByName( aSrcDimName );
+ rSaveDim.SetOrientation( rOldDim.GetOrientation() );
+ aSaveData.SetPosition( &rSaveDim, 0 ); //! before (immediate) base
+ }
+ }
+ }
+
+ // apply changes
+ pDPObj->SetSaveData( aSaveData );
+ SetDPObject( pDPObj );
+ }
+
+ // return the UNO object of the new dimension, after writing back saved data
+ Reference< XDataPilotField > xRet;
+ if( aGroupDimName.Len() > 0 ) try
+ {
+ Reference< XNameAccess > xFields( mrParent.getDataPilotFields(), UNO_QUERY_THROW );
+ xRet.set( xFields->getByName( aGroupDimName ), UNO_QUERY );
+ }
+ catch( Exception& )
+ {
+ }
+ return xRet;
+}
+
+// ============================================================================
+
+namespace {
+
+bool lclExtractGroupMembers( ScFieldGroupMembers& rMembers, const Any& rElement )
+{
+ // allow empty value to create a new group
+ if( !rElement.hasValue() )
+ return true;
+
+ // try to extract a simple sequence of strings
+ Sequence< OUString > aSeq;
+ if( rElement >>= aSeq )
+ {
+ if( aSeq.hasElements() )
+ rMembers.insert( rMembers.end(), aSeq.getConstArray(), aSeq.getConstArray() + aSeq.getLength() );
+ return true;
+ }
+
+ // try to use XIndexAccess providing objects that support XNamed
+ Reference< XIndexAccess > xItemsIA( rElement, UNO_QUERY );
+ if( xItemsIA.is() )
+ {
+ for( sal_Int32 nIdx = 0, nCount = xItemsIA->getCount(); nIdx < nCount; ++nIdx )
+ {
+ try // getByIndex() should not throw, but we cannot be sure
+ {
+ Reference< XNamed > xItemName( xItemsIA->getByIndex( nIdx ), UNO_QUERY_THROW );
+ rMembers.push_back( xItemName->getName() );
+ }
+ catch( Exception& )
+ {
+ // ignore exceptions, go ahead with next element in the array
+ }
+ }
+ return true;
+ }
+
+ // nothing valid inside the Any -> return false
+ return false;
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+ScDataPilotFieldGroupsObj::ScDataPilotFieldGroupsObj( const ScFieldGroups& rGroups ) :
+ maGroups( rGroups )
+{
+}
+
+ScDataPilotFieldGroupsObj::~ScDataPilotFieldGroupsObj()
+{
+}
+
+// XNameAccess
+
+Any SAL_CALL ScDataPilotFieldGroupsObj::getByName( const OUString& rName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( implFindByName( rName ) == maGroups.end() )
+ throw NoSuchElementException();
+ return Any( Reference< XNameAccess >( new ScDataPilotFieldGroupObj( *this, rName ) ) );
+}
+
+Sequence< OUString > SAL_CALL ScDataPilotFieldGroupsObj::getElementNames() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Sequence< OUString > aSeq;
+ if( !maGroups.empty() )
+ {
+ aSeq.realloc( static_cast< sal_Int32 >( maGroups.size() ) );
+ OUString* pName = aSeq.getArray();
+ for( ScFieldGroups::iterator aIt = maGroups.begin(), aEnd = maGroups.end(); aIt != aEnd; ++aIt, ++pName )
+ *pName = aIt->maName;
+ }
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScDataPilotFieldGroupsObj::hasByName( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return implFindByName( rName ) != maGroups.end();
+}
+
+// XNameReplace
+
+void SAL_CALL ScDataPilotFieldGroupsObj::replaceByName( const OUString& rName, const Any& rElement )
+ throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( rName.getLength() == 0 )
+ throw IllegalArgumentException();
+
+ ScFieldGroups::iterator aIt = implFindByName( rName );
+ if( aIt == maGroups.end() )
+ throw NoSuchElementException();
+
+ // read all item names provided by the passed object
+ ScFieldGroupMembers aMembers;
+ if( !lclExtractGroupMembers( aMembers, rElement ) )
+ throw IllegalArgumentException();
+
+ // copy and forget, faster than vector assignment
+ aIt->maMembers.swap( aMembers );
+}
+
+// XNameContainer
+
+void SAL_CALL ScDataPilotFieldGroupsObj::insertByName( const OUString& rName, const Any& rElement )
+ throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( rName.getLength() == 0 )
+ throw IllegalArgumentException();
+
+ ScFieldGroups::iterator aIt = implFindByName( rName );
+ if( aIt != maGroups.end() )
+ throw ElementExistException();
+
+ // read all item names provided by the passed object
+ ScFieldGroupMembers aMembers;
+ if( !lclExtractGroupMembers( aMembers, rElement ) )
+ throw IllegalArgumentException();
+
+ // create the new entry if no error has been occured
+ maGroups.resize( maGroups.size() + 1 );
+ ScFieldGroup& rGroup = maGroups.back();
+ rGroup.maName = rName;
+ rGroup.maMembers.swap( aMembers );
+}
+
+void SAL_CALL ScDataPilotFieldGroupsObj::removeByName( const OUString& rName )
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( rName.getLength() == 0 )
+ throw IllegalArgumentException();
+
+ ScFieldGroups::iterator aIt = implFindByName( rName );
+ if( aIt == maGroups.end() )
+ throw NoSuchElementException();
+
+ maGroups.erase( aIt );
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDataPilotFieldGroupsObj::getCount() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return static_cast< sal_Int32 >( maGroups.size() );
+}
+
+Any SAL_CALL ScDataPilotFieldGroupsObj::getByIndex( sal_Int32 nIndex )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ((nIndex < 0) || (nIndex >= static_cast< sal_Int32 >( maGroups.size() )))
+ throw IndexOutOfBoundsException();
+ return Any( Reference< XNameAccess >( new ScDataPilotFieldGroupObj( *this, maGroups[ nIndex ].maName ) ) );
+}
+
+// XEnumerationAccess
+
+Reference<XEnumeration> SAL_CALL ScDataPilotFieldGroupsObj::createEnumeration() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration( this, OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.DataPilotFieldGroupsEnumeration" ) ) );
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScDataPilotFieldGroupsObj::getElementType() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType( (Reference< XNameAccess >*)0 );
+}
+
+sal_Bool SAL_CALL ScDataPilotFieldGroupsObj::hasElements() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return !maGroups.empty();
+}
+
+// implementation
+
+ScFieldGroup& ScDataPilotFieldGroupsObj::getFieldGroup( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScFieldGroups::iterator aIt = implFindByName( rName );
+ if( aIt == maGroups.end() )
+ throw RuntimeException();
+ return *aIt;
+}
+
+void ScDataPilotFieldGroupsObj::renameFieldGroup( const OUString& rOldName, const OUString& rNewName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScFieldGroups::iterator aOldIt = implFindByName( rOldName );
+ ScFieldGroups::iterator aNewIt = implFindByName( rNewName );
+ // new name must not exist yet
+ if( (aOldIt == maGroups.end()) || ((aNewIt != maGroups.end()) && (aNewIt != aOldIt)) )
+ throw RuntimeException();
+ aOldIt->maName = rNewName;
+}
+
+// private
+
+ScFieldGroups::iterator ScDataPilotFieldGroupsObj::implFindByName( const OUString& rName )
+{
+ for( ScFieldGroups::iterator aIt = maGroups.begin(), aEnd = maGroups.end(); aIt != aEnd; ++aIt )
+ if( aIt->maName == rName )
+ return aIt;
+ return maGroups.end();
+}
+
+// ============================================================================
+
+namespace {
+
+OUString lclExtractMember( const Any& rElement )
+{
+ if( rElement.has< OUString >() )
+ return rElement.get< OUString >();
+
+ Reference< XNamed > xNamed( rElement, UNO_QUERY );
+ if( xNamed.is() )
+ return xNamed->getName();
+
+ return OUString();
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+ScDataPilotFieldGroupObj::ScDataPilotFieldGroupObj( ScDataPilotFieldGroupsObj& rParent, const OUString& rGroupName ) :
+ mrParent( rParent ),
+ maGroupName( rGroupName )
+{
+ mrParent.acquire();
+}
+
+ScDataPilotFieldGroupObj::~ScDataPilotFieldGroupObj()
+{
+ mrParent.release();
+}
+
+// XNameAccess
+
+Any SAL_CALL ScDataPilotFieldGroupObj::getByName( const OUString& rName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScFieldGroupMembers& rMembers = mrParent.getFieldGroup( maGroupName ).maMembers;
+ ScFieldGroupMembers::iterator aIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
+ if( aIt == rMembers.end() )
+ throw NoSuchElementException();
+ return Any( Reference< XNamed >( new ScDataPilotFieldGroupItemObj( *this, *aIt ) ) );
+}
+
+Sequence< OUString > SAL_CALL ScDataPilotFieldGroupObj::getElementNames() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::comphelper::containerToSequence( mrParent.getFieldGroup( maGroupName ).maMembers );
+}
+
+sal_Bool SAL_CALL ScDataPilotFieldGroupObj::hasByName( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScFieldGroupMembers& rMembers = mrParent.getFieldGroup( maGroupName ).maMembers;
+ return ::std::find( rMembers.begin(), rMembers.end(), rName ) != rMembers.end();
+}
+
+// XNameReplace
+
+void SAL_CALL ScDataPilotFieldGroupObj::replaceByName( const OUString& rName, const Any& rElement )
+ throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // it should be possible to quickly rename an item -> accept string or XNamed
+ OUString aNewName = lclExtractMember( rElement );
+ if( (rName.getLength() == 0) || (aNewName.getLength() == 0) )
+ throw IllegalArgumentException();
+ if( rName == aNewName )
+ return;
+
+ ScFieldGroupMembers& rMembers = mrParent.getFieldGroup( maGroupName ).maMembers;
+ ScFieldGroupMembers::iterator aOldIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
+ ScFieldGroupMembers::iterator aNewIt = ::std::find( rMembers.begin(), rMembers.end(), aNewName );
+ // throw if passed member name does not exist
+ if( aOldIt == rMembers.end() )
+ throw NoSuchElementException();
+ // throw if new name already exists
+ if( aNewIt != rMembers.end() )
+ throw IllegalArgumentException();
+ *aOldIt = aNewName;
+}
+
+// XNameContainer
+
+void SAL_CALL ScDataPilotFieldGroupObj::insertByName( const OUString& rName, const Any& /*rElement*/ )
+ throw (IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // we will ignore the passed element and just try to insert the name
+ if( rName.getLength() == 0 )
+ throw IllegalArgumentException();
+
+ ScFieldGroupMembers& rMembers = mrParent.getFieldGroup( maGroupName ).maMembers;
+ ScFieldGroupMembers::iterator aIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
+ // throw if passed name already exists
+ if( aIt != rMembers.end() )
+ throw IllegalArgumentException();
+ rMembers.push_back( rName );
+}
+
+void SAL_CALL ScDataPilotFieldGroupObj::removeByName( const OUString& rName )
+ throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( rName.getLength() == 0 )
+ throw IllegalArgumentException();
+ ScFieldGroupMembers& rMembers = mrParent.getFieldGroup( maGroupName ).maMembers;
+ ScFieldGroupMembers::iterator aIt = ::std::find( rMembers.begin(), rMembers.end(), rName );
+ // throw if passed name does not exist
+ if( aIt == rMembers.end() )
+ throw NoSuchElementException();
+ rMembers.erase( aIt );
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDataPilotFieldGroupObj::getCount() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return static_cast< sal_Int32 >( mrParent.getFieldGroup( maGroupName ).maMembers.size() );
+}
+
+Any SAL_CALL ScDataPilotFieldGroupObj::getByIndex( sal_Int32 nIndex )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScFieldGroupMembers& rMembers = mrParent.getFieldGroup( maGroupName ).maMembers;
+ if ((nIndex < 0) || (nIndex >= static_cast< sal_Int32 >( rMembers.size() )))
+ throw IndexOutOfBoundsException();
+ return Any( Reference< XNamed >( new ScDataPilotFieldGroupItemObj( *this, rMembers[ nIndex ] ) ) );
+}
+
+// XEnumerationAccess
+
+Reference< XEnumeration > SAL_CALL ScDataPilotFieldGroupObj::createEnumeration() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration( this, OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.DataPilotFieldGroupEnumeration" ) ) );
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScDataPilotFieldGroupObj::getElementType() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType( (Reference< XNamed >*)0 );
+}
+
+sal_Bool SAL_CALL ScDataPilotFieldGroupObj::hasElements() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return !mrParent.getFieldGroup( maGroupName ).maMembers.empty();
+}
+
+// XNamed
+
+OUString SAL_CALL ScDataPilotFieldGroupObj::getName() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return maGroupName;
+}
+
+void SAL_CALL ScDataPilotFieldGroupObj::setName( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ mrParent.renameFieldGroup( maGroupName, rName );
+ // if call to renameFieldGroup() did not throw, remember the new name
+ maGroupName = rName;
+}
+
+// ============================================================================
+
+ScDataPilotFieldGroupItemObj::ScDataPilotFieldGroupItemObj( ScDataPilotFieldGroupObj& rParent, const OUString& rName ) :
+ mrParent( rParent ),
+ maName( rName )
+{
+ mrParent.acquire();
+}
+
+ScDataPilotFieldGroupItemObj::~ScDataPilotFieldGroupItemObj()
+{
+ mrParent.release();
+}
+
+// XNamed
+
+OUString SAL_CALL ScDataPilotFieldGroupItemObj::getName() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return maName;
+}
+
+void SAL_CALL ScDataPilotFieldGroupItemObj::setName( const OUString& rName ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ mrParent.replaceByName( maName, Any( rName ) );
+ // if call to replaceByName() did not throw, remember the new name
+ maName = rName;
+}
+
+// ============================================================================
+
+ScDataPilotItemsObj::ScDataPilotItemsObj( ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId ) :
+ ScDataPilotChildObjBase( rParent, rFieldId )
+{
+}
+
+ScDataPilotItemsObj::~ScDataPilotItemsObj()
+{
+}
+
+// XDataPilotItems
+
+ScDataPilotItemObj* ScDataPilotItemsObj::GetObjectByIndex_Impl( sal_Int32 nIndex ) const
+{
+ return ((0 <= nIndex) && (nIndex < GetMemberCount())) ?
+ new ScDataPilotItemObj( mrParent, maFieldId, nIndex ) : 0;
+}
+
+// XNameAccess
+
+Any SAL_CALL ScDataPilotItemsObj::getByName( const OUString& aName )
+ throw(NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference<XNameAccess> xMembers = GetMembers();
+ if (xMembers.is())
+ {
+ Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( xMembers ));
+ sal_Int32 nCount = xMembersIndex->getCount();
+ sal_Bool bFound(sal_False);
+ sal_Int32 nItem = 0;
+ while (nItem < nCount && !bFound )
+ {
+ Reference<XNamed> xMember(xMembersIndex->getByIndex(nItem), UNO_QUERY);
+ if (xMember.is() && (aName == xMember->getName()))
+ return Any( Reference< XPropertySet >( GetObjectByIndex_Impl( nItem ) ) );
+ ++nItem;
+ }
+ if (!bFound)
+ throw NoSuchElementException();
+ }
+ return Any();
+}
+
+Sequence<OUString> SAL_CALL ScDataPilotItemsObj::getElementNames()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Sequence< OUString > aSeq;
+ if( ScDPObject* pDPObj = GetDPObject() )
+ pDPObj->GetMemberNames( lcl_GetObjectIndex( pDPObj, maFieldId ), aSeq );
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScDataPilotItemsObj::hasByName( const OUString& aName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bFound = sal_False;
+ Reference<XNameAccess> xMembers = GetMembers();
+ if (xMembers.is())
+ {
+ Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( xMembers ));
+ sal_Int32 nCount = xMembersIndex->getCount();
+ sal_Int32 nItem = 0;
+ while (nItem < nCount && !bFound )
+ {
+ Reference<XNamed> xMember(xMembersIndex->getByIndex(nItem), UNO_QUERY);
+ if (xMember.is() && aName == xMember->getName())
+ bFound = sal_True;
+ else
+ nItem++;
+ }
+ }
+ return bFound;
+}
+
+// XEnumerationAccess
+
+Reference<XEnumeration> SAL_CALL ScDataPilotItemsObj::createEnumeration()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DataPilotItemsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDataPilotItemsObj::getCount() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetMemberCount();
+}
+
+Any SAL_CALL ScDataPilotItemsObj::getByIndex( sal_Int32 nIndex )
+ throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference< XPropertySet > xItem( GetObjectByIndex_Impl( nIndex ) );
+ if (!xItem.is())
+ throw IndexOutOfBoundsException();
+ return Any( xItem );
+}
+
+uno::Type SAL_CALL ScDataPilotItemsObj::getElementType() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((Reference<XPropertySet>*)0);
+}
+
+sal_Bool SAL_CALL ScDataPilotItemsObj::hasElements() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+//------------------------------------------------------------------------
+
+ScDataPilotItemObj::ScDataPilotItemObj( ScDataPilotDescriptorBase& rParent, const ScFieldIdentifier& rFieldId, sal_Int32 nIndex ) :
+ ScDataPilotChildObjBase( rParent, rFieldId ),
+ maPropSet( lcl_GetDataPilotItemMap() ),
+ mnIndex( nIndex )
+{
+}
+
+ScDataPilotItemObj::~ScDataPilotItemObj()
+{
+}
+
+ // XNamed
+OUString SAL_CALL ScDataPilotItemObj::getName() throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ OUString sRet;
+ Reference<XNameAccess> xMembers = GetMembers();
+ if (xMembers.is())
+ {
+ Reference<XIndexAccess> xMembersIndex(new ScNameToIndexAccess( xMembers ));
+ sal_Int32 nCount = xMembersIndex->getCount();
+ if (mnIndex < nCount)
+ {
+ Reference<XNamed> xMember(xMembersIndex->getByIndex(mnIndex), UNO_QUERY);
+ sRet = xMember->getName();
+ }
+ }
+ return sRet;
+}
+
+void SAL_CALL ScDataPilotItemObj::setName( const OUString& /* aName */ )
+ throw(RuntimeException)
+{
+}
+
+ // XPropertySet
+Reference< XPropertySetInfo >
+ SAL_CALL ScDataPilotItemObj::getPropertySetInfo( )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static Reference<XPropertySetInfo> aRef =
+ new SfxItemPropertySetInfo( maPropSet.getPropertyMap() );
+ return aRef;
+}
+
+void SAL_CALL ScDataPilotItemObj::setPropertyValue( const OUString& aPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDPObject* pDPObj = 0;
+ if( ScDPSaveDimension* pDim = GetDPDimension( &pDPObj ) )
+ {
+ Reference<XNameAccess> xMembers = GetMembers();
+ if( xMembers.is() )
+ {
+ Reference<XIndexAccess> xMembersIndex( new ScNameToIndexAccess( xMembers ) );
+ sal_Int32 nCount = xMembersIndex->getCount();
+ if( mnIndex < nCount )
+ {
+ Reference<XNamed> xMember(xMembersIndex->getByIndex(mnIndex), UNO_QUERY);
+ String sName(xMember->getName());
+ ScDPSaveMember* pMember = pDim->GetMemberByName(sName);
+ if (pMember)
+ {
+ bool bGetNewIndex = false;
+ if ( aPropertyName.equalsAscii( SC_UNONAME_SHOWDETAIL ) )
+ pMember->SetShowDetails(cppu::any2bool(aValue));
+ else if ( aPropertyName.equalsAscii( SC_UNONAME_ISHIDDEN ) )
+ pMember->SetIsVisible(!cppu::any2bool(aValue));
+ else if ( aPropertyName.equalsAscii( SC_UNONAME_POS ) )
+ {
+ sal_Int32 nNewPos = 0;
+ if ( ( aValue >>= nNewPos ) && nNewPos >= 0 && nNewPos < nCount )
+ {
+ pDim->SetMemberPosition( sName, nNewPos );
+ // get new effective index (depends on sorting mode, which isn't modified)
+ bGetNewIndex = true;
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ SetDPObject( pDPObj );
+
+ if ( bGetNewIndex ) // after SetDPObject, get the new index
+ {
+ OUString aOUName( sName );
+ Sequence< OUString > aItemNames = xMembers->getElementNames();
+ sal_Int32 nItemCount = aItemNames.getLength();
+ for (sal_Int32 nItem=0; nItem<nItemCount; ++nItem)
+ if (aItemNames[nItem] == aOUName)
+ mnIndex = nItem;
+ }
+ }
+ }
+ }
+ }
+}
+
+Any SAL_CALL ScDataPilotItemObj::getPropertyValue( const OUString& aPropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Any aRet;
+ if( ScDPSaveDimension* pDim = GetDPDimension() )
+ {
+ Reference< XNameAccess > xMembers = GetMembers();
+ if( xMembers.is() )
+ {
+ Reference< XIndexAccess > xMembersIndex( new ScNameToIndexAccess( xMembers ) );
+ sal_Int32 nCount = xMembersIndex->getCount();
+ if( mnIndex < nCount )
+ {
+ Reference< XNamed > xMember( xMembersIndex->getByIndex( mnIndex ), UNO_QUERY );
+ String sName( xMember->getName() );
+ ScDPSaveMember* pMember = pDim->GetExistingMemberByName( sName );
+ if( aPropertyName.equalsAscii( SC_UNONAME_SHOWDETAIL ) )
+ {
+ if (pMember && pMember->HasShowDetails())
+ {
+ aRet <<= (bool)pMember->GetShowDetails();
+ }
+ else
+ {
+ Reference< XPropertySet > xMemberProps( xMember, UNO_QUERY );
+ if( xMemberProps.is() )
+ aRet = xMemberProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHOWDETA ) ) );
+ else
+ aRet <<= true;
+ }
+ }
+ else if ( aPropertyName.equalsAscii( SC_UNONAME_ISHIDDEN ) )
+ {
+ if (pMember && pMember->HasIsVisible())
+ {
+ aRet <<= !pMember->GetIsVisible();
+ }
+ else
+ {
+ Reference< XPropertySet > xMemberProps( xMember, UNO_QUERY );
+ if( xMemberProps.is() )
+ aRet <<= !cppu::any2bool( xMemberProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ISVISIBL ) ) ) );
+ else
+ aRet <<= false;
+ }
+ }
+ else if ( aPropertyName.equalsAscii( SC_UNONAME_POS ) )
+ {
+ aRet <<= mnIndex;
+ }
+ }
+ }
+ }
+ return aRet;
+}
+
+void SAL_CALL ScDataPilotItemObj::addPropertyChangeListener(
+ const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* xListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SAL_CALL ScDataPilotItemObj::removePropertyChangeListener(
+ const OUString& /* aPropertyName */, const Reference< XPropertyChangeListener >& /* aListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SAL_CALL ScDataPilotItemObj::addVetoableChangeListener(
+ const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SAL_CALL ScDataPilotItemObj::removeVetoableChangeListener(
+ const OUString& /* PropertyName */, const Reference< XVetoableChangeListener >& /* aListener */ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
new file mode 100644
index 000000000000..ec9e6add155b
--- /dev/null
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -0,0 +1,2373 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <tools/debug.hxx>
+#include <svl/smplhint.hxx>
+#include <svl/zforlist.hxx>
+#include <rtl/uuid.h>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/util/SortField.hpp>
+#include <com/sun/star/table/TableSortField.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/table/TableOrientation.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/DataImportMode.hpp>
+#include <com/sun/star/sheet/FilterOperator2.hpp>
+#include <com/sun/star/sheet/TableFilterField2.hpp>
+
+#include "datauno.hxx"
+#include "dapiuno.hxx"
+#include "cellsuno.hxx"
+#include "miscuno.hxx"
+#include "targuno.hxx"
+#include "rangeutl.hxx"
+#include "dbcolect.hxx"
+#include "docsh.hxx"
+#include "dbdocfun.hxx"
+#include "unonames.hxx"
+#include "globstr.hrc"
+#ifndef SC_CONVUNO_HXX
+#include "convuno.hxx"
+#include "hints.hxx"
+#endif
+#include "attrib.hxx"
+#include "dpshttab.hxx"
+#include <comphelper/extract.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+
+using namespace com::sun::star;
+
+SV_IMPL_PTRARR( XDBRefreshListenerArr_Impl, XDBRefreshListenerPtr );
+
+//------------------------------------------------------------------------
+
+// alles ohne Which-ID, Map nur fuer PropertySetInfo
+
+const SfxItemPropertyMapEntry* lcl_GetSubTotalPropertyMap()
+{
+ // some old property names are for 5.2 compatibility
+
+ static SfxItemPropertyMapEntry aSubTotalPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_BINDFMT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_CASE), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ENABSORT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ENUSLIST), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_FORMATS), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_INSBRK), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ISCASE), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_MAXFLD), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SORTASC), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ULIST), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_UINDEX), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_USINDEX), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aSubTotalPropertyMap_Impl;
+}
+
+const SfxItemPropertyMapEntry* lcl_GetFilterPropertyMap()
+{
+ static SfxItemPropertyMapEntry aFilterPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_CONTHDR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_COPYOUT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ISCASE), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_MAXFLD), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ORIENT), 0, &getCppuType((table::TableOrientation*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_OUTPOS), 0, &getCppuType((table::CellAddress*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SAVEOUT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SKIPDUP), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_USEREGEX), 0, &getBooleanCppuType(), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aFilterPropertyMap_Impl;
+}
+
+const SfxItemPropertyMapEntry* lcl_GetDBRangePropertyMap()
+{
+ static SfxItemPropertyMapEntry aDBRangePropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_AUTOFLT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_FLTCRT), 0, &getCppuType((table::CellRangeAddress*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_FROMSELECT),0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ISUSER), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_KEEPFORM), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT), 0, &getCppuType((uno::Reference<awt::XBitmap>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), 0, &getCppuType((rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_MOVCELLS), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_REFPERIOD), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_STRIPDAT), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_TOKENINDEX),0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_USEFLTCRT),0, &getBooleanCppuType(), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aDBRangePropertyMap_Impl;
+}
+
+
+//------------------------------------------------------------------------
+
+#define SCDATABASERANGEOBJ_SERVICE "com.sun.star.sheet.DatabaseRange"
+
+SC_SIMPLE_SERVICE_INFO( ScConsolidationDescriptor, "ScConsolidationDescriptor", "com.sun.star.sheet.ConsolidationDescriptor" )
+SC_SIMPLE_SERVICE_INFO( ScDatabaseRangesObj, "ScDatabaseRangesObj", "com.sun.star.sheet.DatabaseRanges" )
+SC_SIMPLE_SERVICE_INFO( ScFilterDescriptorBase, "ScFilterDescriptorBase", "com.sun.star.sheet.SheetFilterDescriptor" )
+SC_SIMPLE_SERVICE_INFO( ScSubTotalDescriptorBase, "ScSubTotalDescriptorBase", "com.sun.star.sheet.SubTotalDescriptor" )
+SC_SIMPLE_SERVICE_INFO( ScSubTotalFieldObj, "ScSubTotalFieldObj", "com.sun.star.sheet.SubTotalField" )
+
+
+//------------------------------------------------------------------------
+
+// static
+ScSubTotalFunc ScDataUnoConversion::GeneralToSubTotal( sheet::GeneralFunction eSummary )
+{
+ ScSubTotalFunc eSubTotal;
+ switch (eSummary)
+ {
+ case sheet::GeneralFunction_NONE: eSubTotal = SUBTOTAL_FUNC_NONE; break;
+ case sheet::GeneralFunction_SUM: eSubTotal = SUBTOTAL_FUNC_SUM; break;
+ case sheet::GeneralFunction_COUNT: eSubTotal = SUBTOTAL_FUNC_CNT2; break;
+ case sheet::GeneralFunction_AVERAGE: eSubTotal = SUBTOTAL_FUNC_AVE; break;
+ case sheet::GeneralFunction_MAX: eSubTotal = SUBTOTAL_FUNC_MAX; break;
+ case sheet::GeneralFunction_MIN: eSubTotal = SUBTOTAL_FUNC_MIN; break;
+ case sheet::GeneralFunction_PRODUCT: eSubTotal = SUBTOTAL_FUNC_PROD; break;
+ case sheet::GeneralFunction_COUNTNUMS: eSubTotal = SUBTOTAL_FUNC_CNT; break;
+ case sheet::GeneralFunction_STDEV: eSubTotal = SUBTOTAL_FUNC_STD; break;
+ case sheet::GeneralFunction_STDEVP: eSubTotal = SUBTOTAL_FUNC_STDP; break;
+ case sheet::GeneralFunction_VAR: eSubTotal = SUBTOTAL_FUNC_VAR; break;
+ case sheet::GeneralFunction_VARP: eSubTotal = SUBTOTAL_FUNC_VARP; break;
+ case sheet::GeneralFunction_AUTO:
+ default:
+ DBG_ERROR("GeneralToSubTotal: falscher enum");
+ eSubTotal = SUBTOTAL_FUNC_NONE;
+ }
+ return eSubTotal;
+}
+
+// static
+sheet::GeneralFunction ScDataUnoConversion::SubTotalToGeneral( ScSubTotalFunc eSubTotal )
+{
+ sheet::GeneralFunction eGeneral;
+ switch (eSubTotal)
+ {
+ case SUBTOTAL_FUNC_NONE: eGeneral = sheet::GeneralFunction_NONE; break;
+ case SUBTOTAL_FUNC_AVE: eGeneral = sheet::GeneralFunction_AVERAGE; break;
+ case SUBTOTAL_FUNC_CNT: eGeneral = sheet::GeneralFunction_COUNTNUMS; break;
+ case SUBTOTAL_FUNC_CNT2: eGeneral = sheet::GeneralFunction_COUNT; break;
+ case SUBTOTAL_FUNC_MAX: eGeneral = sheet::GeneralFunction_MAX; break;
+ case SUBTOTAL_FUNC_MIN: eGeneral = sheet::GeneralFunction_MIN; break;
+ case SUBTOTAL_FUNC_PROD: eGeneral = sheet::GeneralFunction_PRODUCT; break;
+ case SUBTOTAL_FUNC_STD: eGeneral = sheet::GeneralFunction_STDEV; break;
+ case SUBTOTAL_FUNC_STDP: eGeneral = sheet::GeneralFunction_STDEVP; break;
+ case SUBTOTAL_FUNC_SUM: eGeneral = sheet::GeneralFunction_SUM; break;
+ case SUBTOTAL_FUNC_VAR: eGeneral = sheet::GeneralFunction_VAR; break;
+ case SUBTOTAL_FUNC_VARP: eGeneral = sheet::GeneralFunction_VARP; break;
+ default:
+ DBG_ERROR("SubTotalToGeneral: falscher enum");
+ eGeneral = sheet::GeneralFunction_NONE;
+ break;
+ }
+ return eGeneral;
+}
+
+//------------------------------------------------------------------------
+
+// ScImportDescriptor: alles static
+
+long ScImportDescriptor::GetPropertyCount()
+{
+ return 4;
+}
+
+void ScImportDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScImportParam& rParam )
+{
+ DBG_ASSERT( rSeq.getLength() == GetPropertyCount(), "falscher Count" );
+
+ beans::PropertyValue* pArray = rSeq.getArray();
+
+ sheet::DataImportMode eMode = sheet::DataImportMode_NONE;
+ if ( rParam.bImport )
+ {
+ if ( rParam.bSql )
+ eMode = sheet::DataImportMode_SQL;
+ else if ( rParam.nType == ScDbQuery )
+ eMode = sheet::DataImportMode_QUERY;
+ else
+ eMode = sheet::DataImportMode_TABLE; // Type ist immer ScDbQuery oder ScDbTable
+ }
+
+ ::svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(rParam.aDBName);
+ if (aDescriptor.has( svx::daDataSource ))
+ {
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_DBNAME );
+ pArray[0].Value <<= rtl::OUString( rParam.aDBName );
+ }
+ else if (aDescriptor.has( svx::daConnectionResource ))
+ {
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_CONRES );
+ pArray[0].Value <<= rtl::OUString( rParam.aDBName );
+ }
+
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_SRCTYPE );
+ pArray[1].Value <<= eMode;
+
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_SRCOBJ );
+ pArray[2].Value <<= rtl::OUString( rParam.aStatement );
+
+ pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_ISNATIVE );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[3].Value, rParam.bNative );
+}
+
+void ScImportDescriptor::FillImportParam( ScImportParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
+{
+ rtl::OUString aStrVal;
+ const beans::PropertyValue* pPropArray = rSeq.getConstArray();
+ long nPropCount = rSeq.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNONAME_ISNATIVE ))
+ rParam.bNative = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_DBNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ rParam.aDBName = String( aStrVal );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_CONRES ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ rParam.aDBName = String( aStrVal );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_SRCOBJ ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ rParam.aStatement = String( aStrVal );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_SRCTYPE ))
+ {
+ //! test for correct enum type?
+ sheet::DataImportMode eMode = (sheet::DataImportMode)
+ ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
+ switch (eMode)
+ {
+ case sheet::DataImportMode_NONE:
+ rParam.bImport = FALSE;
+ break;
+ case sheet::DataImportMode_SQL:
+ rParam.bImport = TRUE;
+ rParam.bSql = TRUE;
+ break;
+ case sheet::DataImportMode_TABLE:
+ rParam.bImport = TRUE;
+ rParam.bSql = FALSE;
+ rParam.nType = ScDbTable;
+ break;
+ case sheet::DataImportMode_QUERY:
+ rParam.bImport = TRUE;
+ rParam.bSql = FALSE;
+ rParam.nType = ScDbQuery;
+ break;
+ default:
+ DBG_ERROR("falscher Mode");
+ rParam.bImport = FALSE;
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+// ScSortDescriptor: alles static
+
+//! SortAscending muss aus der SheetSortDescriptor service-Beschreibung raus
+
+long ScSortDescriptor::GetPropertyCount()
+{
+ return 9; // TableSortDescriptor and SheetSortDescriptor
+}
+
+void ScSortDescriptor::FillProperties( uno::Sequence<beans::PropertyValue>& rSeq, const ScSortParam& rParam )
+{
+ DBG_ASSERT( rSeq.getLength() == GetPropertyCount(), "falscher Count" );
+
+ beans::PropertyValue* pArray = rSeq.getArray();
+
+ // Uno-Werte zusammensuchen
+
+ table::CellAddress aOutPos;
+ aOutPos.Sheet = rParam.nDestTab;
+ aOutPos.Column = rParam.nDestCol;
+ aOutPos.Row = rParam.nDestRow;
+
+ USHORT nSortCount = 0;
+ while ( nSortCount < MAXSORT && rParam.bDoSort[nSortCount] )
+ ++nSortCount;
+
+ uno::Sequence<table::TableSortField> aFields(nSortCount);
+ if (nSortCount)
+ {
+ table::TableSortField* pFieldArray = aFields.getArray();
+ for (USHORT i=0; i<nSortCount; i++)
+ {
+ pFieldArray[i].Field = rParam.nField[i];
+ pFieldArray[i].IsAscending = rParam.bAscending[i];
+ pFieldArray[i].FieldType = table::TableSortFieldType_AUTOMATIC; // immer Automatic
+ pFieldArray[i].IsCaseSensitive = rParam.bCaseSens;
+ pFieldArray[i].CollatorLocale = rParam.aCollatorLocale;
+ pFieldArray[i].CollatorAlgorithm = rtl::OUString( rParam.aCollatorAlgorithm );
+ }
+ }
+
+ // Sequence fuellen
+
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_ISSORTCOLUMNS );
+ pArray[0].Value = ::cppu::bool2any(!rParam.bByRow);
+
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_CONTHDR );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[1].Value, rParam.bHasHeader );
+
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_MAXFLD );
+ pArray[2].Value <<= (sal_Int32) MAXSORT;
+
+ pArray[3].Name = rtl::OUString::createFromAscii( SC_UNONAME_SORTFLD );
+ pArray[3].Value <<= aFields;
+
+ pArray[4].Name = rtl::OUString::createFromAscii( SC_UNONAME_BINDFMT );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[4].Value, rParam.bIncludePattern );
+
+ pArray[5].Name = rtl::OUString::createFromAscii( SC_UNONAME_COPYOUT );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[5].Value, !rParam.bInplace );
+
+ pArray[6].Name = rtl::OUString::createFromAscii( SC_UNONAME_OUTPOS );
+ pArray[6].Value <<= aOutPos;
+
+ pArray[7].Name = rtl::OUString::createFromAscii( SC_UNONAME_ISULIST );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[7].Value, rParam.bUserDef );
+
+ pArray[8].Name = rtl::OUString::createFromAscii( SC_UNONAME_UINDEX );
+ pArray[8].Value <<= (sal_Int32) rParam.nUserIndex;
+}
+
+void ScSortDescriptor::FillSortParam( ScSortParam& rParam, const uno::Sequence<beans::PropertyValue>& rSeq )
+{
+ sal_Bool bOldSortDescriptor(sal_False);
+ sal_Bool bNewSortDescriptor(sal_False);
+ const beans::PropertyValue* pPropArray = rSeq.getConstArray();
+ long nPropCount = rSeq.getLength();
+ for (long nProp = 0; nProp < nPropCount; nProp++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[nProp];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNONAME_ORIENT ))
+ {
+ bOldSortDescriptor = sal_True;
+ //! test for correct enum type?
+ table::TableOrientation eOrient = (table::TableOrientation)
+ ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
+ rParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_ISSORTCOLUMNS ))
+ {
+ bNewSortDescriptor = sal_True;
+ rParam.bByRow = !::cppu::any2bool(rProp.Value);
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_CONTHDR ))
+ rParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_MAXFLD ))
+ {
+ sal_Int32 nVal;
+ if ( (rProp.Value >>= nVal) && nVal > MAXSORT )
+ {
+ //! specify exceptions
+ //! throw lang::IllegalArgumentException();
+ }
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_SORTFLD ))
+ {
+ uno::Sequence<util::SortField> aSeq;
+ uno::Sequence<table::TableSortField> aNewSeq;
+ if ( rProp.Value >>= aSeq )
+ {
+ bOldSortDescriptor = sal_True;
+ INT32 nCount = aSeq.getLength();
+ INT32 i;
+ if ( nCount > MAXSORT )
+ {
+ DBG_ERROR("Zu viele Sortierfelder");
+ nCount = MAXSORT;
+ }
+ const util::SortField* pFieldArray = aSeq.getConstArray();
+ for (i=0; i<nCount; i++)
+ {
+ rParam.nField[i] = (SCCOLROW)pFieldArray[i].Field;
+ rParam.bAscending[i] = pFieldArray[i].SortAscending;
+
+ // FieldType wird ignoriert
+ rParam.bDoSort[i] = TRUE;
+ }
+ for (i=nCount; i<MAXSORT; i++)
+ rParam.bDoSort[i] = FALSE;
+ }
+ else if ( rProp.Value >>= aNewSeq )
+ {
+ bNewSortDescriptor = sal_True;
+ INT32 nCount = aNewSeq.getLength();
+ INT32 i;
+ if ( nCount > MAXSORT )
+ {
+ DBG_ERROR("Zu viele Sortierfelder");
+ nCount = MAXSORT;
+ }
+ const table::TableSortField* pFieldArray = aNewSeq.getConstArray();
+ for (i=0; i<nCount; i++)
+ {
+ rParam.nField[i] = (SCCOLROW)pFieldArray[i].Field;
+ rParam.bAscending[i] = pFieldArray[i].IsAscending;
+
+ // only one is possible, sometime we should make it possible to have different for every entry
+ rParam.bCaseSens = pFieldArray[i].IsCaseSensitive;
+ rParam.aCollatorLocale = pFieldArray[i].CollatorLocale;
+ rParam.aCollatorAlgorithm = pFieldArray[i].CollatorAlgorithm;
+
+ // FieldType wird ignoriert
+ rParam.bDoSort[i] = TRUE;
+ }
+ for (i=nCount; i<MAXSORT; i++)
+ rParam.bDoSort[i] = FALSE;
+ }
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_ISCASE ))
+ {
+ bOldSortDescriptor = sal_True;
+ rParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_BINDFMT ))
+ rParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_COPYOUT ))
+ rParam.bInplace = !ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_OUTPOS ))
+ {
+ table::CellAddress aAddress;
+ if ( rProp.Value >>= aAddress )
+ {
+ rParam.nDestTab = aAddress.Sheet;
+ rParam.nDestCol = (SCCOL)aAddress.Column;
+ rParam.nDestRow = (SCROW)aAddress.Row;
+ }
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_ISULIST ))
+ rParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_UINDEX ))
+ {
+ sal_Int32 nVal = 0;
+ if ( rProp.Value >>= nVal )
+ rParam.nUserIndex = (USHORT)nVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_COLLLOC ))
+ {
+ bOldSortDescriptor = sal_True;
+ rProp.Value >>= rParam.aCollatorLocale;
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_COLLALG ))
+ {
+ bOldSortDescriptor = sal_True;
+ rtl::OUString sStr;
+ if ( rProp.Value >>= sStr )
+ rParam.aCollatorAlgorithm = sStr;
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScSubTotalFieldObj::ScSubTotalFieldObj( ScSubTotalDescriptorBase* pDesc, USHORT nP ) :
+ xRef( pDesc ), // Objekt festhalten
+ rParent( *pDesc ),
+ nPos( nP )
+{
+ DBG_ASSERT(pDesc, "ScSubTotalFieldObj: Parent ist 0");
+}
+
+ScSubTotalFieldObj::~ScSubTotalFieldObj()
+{
+}
+
+// XSubTotalField
+
+sal_Int32 SAL_CALL ScSubTotalFieldObj::getGroupColumn() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ rParent.GetData(aParam);
+
+ return aParam.nField[nPos];
+}
+
+void SAL_CALL ScSubTotalFieldObj::setGroupColumn( sal_Int32 nGroupColumn ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ rParent.GetData(aParam);
+
+ aParam.nField[nPos] = (SCCOL)nGroupColumn;
+
+ rParent.PutData(aParam);
+}
+
+uno::Sequence<sheet::SubTotalColumn> SAL_CALL ScSubTotalFieldObj::getSubTotalColumns()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ rParent.GetData(aParam);
+
+ SCCOL nCount = aParam.nSubTotals[nPos];
+ uno::Sequence<sheet::SubTotalColumn> aSeq(nCount);
+ sheet::SubTotalColumn* pAry = aSeq.getArray();
+ for (SCCOL i=0; i<nCount; i++)
+ {
+ pAry[i].Column = aParam.pSubTotals[nPos][i];
+ pAry[i].Function = ScDataUnoConversion::SubTotalToGeneral(
+ aParam.pFunctions[nPos][i] );
+ }
+ return aSeq;
+}
+
+void SAL_CALL ScSubTotalFieldObj::setSubTotalColumns(
+ const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ rParent.GetData(aParam);
+
+ UINT32 nColCount = aSubTotalColumns.getLength();
+ if ( nColCount <= sal::static_int_cast<UINT32>(SCCOL_MAX) )
+ {
+ SCCOL nCount = static_cast<SCCOL>(nColCount);
+ aParam.nSubTotals[nPos] = nCount;
+ if (nCount != 0)
+ {
+ aParam.pSubTotals[nPos] = new SCCOL[nCount];
+ aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
+
+ const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
+ for (SCCOL i=0; i<nCount; i++)
+ {
+ aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
+ aParam.pFunctions[nPos][i] =
+ ScDataUnoConversion::GeneralToSubTotal( pAry[i].Function );
+ }
+ }
+ else
+ {
+ aParam.pSubTotals[nPos] = NULL;
+ aParam.pFunctions[nPos] = NULL;
+ }
+ }
+ //! sonst Exception oder so? (zuviele Spalten)
+
+ rParent.PutData(aParam);
+}
+
+//------------------------------------------------------------------------
+
+ScSubTotalDescriptorBase::ScSubTotalDescriptorBase() :
+ aPropSet( lcl_GetSubTotalPropertyMap() )
+{
+}
+
+ScSubTotalDescriptorBase::~ScSubTotalDescriptorBase()
+{
+}
+
+// GetData/PutData hier nur wegen NewInstance-Krempel implementiert...
+
+void ScSubTotalDescriptorBase::GetData( ScSubTotalParam& /* rParam */ ) const
+{
+ DBG_ERROR("ScSubTotalDescriptorBase::GetData soll nicht gerufen werden");
+}
+
+void ScSubTotalDescriptorBase::PutData( const ScSubTotalParam& /* rParam */ )
+{
+ DBG_ERROR("ScSubTotalDescriptorBase::PutData soll nicht gerufen werden");
+}
+
+// XSubTotalDesctiptor
+
+ScSubTotalFieldObj* ScSubTotalDescriptorBase::GetObjectByIndex_Impl(USHORT nIndex)
+{
+ if ( nIndex < getCount() )
+ return new ScSubTotalFieldObj( this, nIndex );
+ return NULL;
+}
+
+void SAL_CALL ScSubTotalDescriptorBase::clear() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ GetData(aParam);
+
+ for (USHORT i=0; i<MAXSUBTOTAL; i++)
+ aParam.bGroupActive[i] = FALSE;
+
+ //! Notify oder so fuer die Field-Objekte???
+
+ PutData(aParam);
+}
+
+void SAL_CALL ScSubTotalDescriptorBase::addNew(
+ const uno::Sequence<sheet::SubTotalColumn>& aSubTotalColumns,
+ sal_Int32 nGroupColumn ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ GetData(aParam);
+
+ USHORT nPos = 0;
+ while ( nPos < MAXSUBTOTAL && aParam.bGroupActive[nPos] )
+ ++nPos;
+
+ UINT32 nColCount = aSubTotalColumns.getLength();
+
+ if ( nPos < MAXSUBTOTAL && nColCount <= sal::static_int_cast<UINT32>(SCCOL_MAX) )
+ {
+ aParam.bGroupActive[nPos] = TRUE;
+ aParam.nField[nPos] = static_cast<SCCOL>(nGroupColumn);
+
+ delete aParam.pSubTotals[nPos];
+ delete aParam.pFunctions[nPos];
+
+ SCCOL nCount = static_cast<SCCOL>(nColCount);
+ aParam.nSubTotals[nPos] = nCount;
+ if (nCount != 0)
+ {
+ aParam.pSubTotals[nPos] = new SCCOL[nCount];
+ aParam.pFunctions[nPos] = new ScSubTotalFunc[nCount];
+
+ const sheet::SubTotalColumn* pAry = aSubTotalColumns.getConstArray();
+ for (SCCOL i=0; i<nCount; i++)
+ {
+ aParam.pSubTotals[nPos][i] = static_cast<SCCOL>(pAry[i].Column);
+ aParam.pFunctions[nPos][i] =
+ ScDataUnoConversion::GeneralToSubTotal( pAry[i].Function );
+ }
+ }
+ else
+ {
+ aParam.pSubTotals[nPos] = NULL;
+ aParam.pFunctions[nPos] = NULL;
+ }
+ }
+ else // too many fields / columns
+ throw uno::RuntimeException(); // no other exceptions specified
+
+ PutData(aParam);
+}
+
+// Flags/Einstellungen als Properties
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScSubTotalDescriptorBase::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SubTotalFieldsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScSubTotalDescriptorBase::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ GetData(aParam);
+
+ USHORT nCount = 0;
+ while ( nCount < MAXSUBTOTAL && aParam.bGroupActive[nCount] )
+ ++nCount;
+ return nCount;
+}
+
+uno::Any SAL_CALL ScSubTotalDescriptorBase::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XSubTotalField> xField(GetObjectByIndex_Impl((USHORT)nIndex));
+ if (xField.is())
+ return uno::makeAny(xField);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScSubTotalDescriptorBase::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XSubTotalField>*)0);
+}
+
+sal_Bool SAL_CALL ScSubTotalDescriptorBase::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSubTotalDescriptorBase::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScSubTotalDescriptorBase::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ GetData(aParam);
+
+ String aString(aPropertyName);
+
+ // some old property names are for 5.2 compatibility
+
+ if (aString.EqualsAscii( SC_UNONAME_CASE ) || aString.EqualsAscii( SC_UNONAME_ISCASE ))
+ aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_FORMATS ) || aString.EqualsAscii( SC_UNONAME_BINDFMT ))
+ aParam.bIncludePattern = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_ENABSORT ))
+ aParam.bDoSort = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_SORTASC ))
+ aParam.bAscending = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_INSBRK ))
+ aParam.bPagebreak = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_ULIST ) || aString.EqualsAscii( SC_UNONAME_ENUSLIST ))
+ aParam.bUserDef = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_UINDEX ) || aString.EqualsAscii( SC_UNONAME_USINDEX ))
+ {
+ sal_Int32 nVal = 0;
+ if ( aValue >>= nVal )
+ aParam.nUserIndex = (USHORT)nVal;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
+ {
+ sal_Int32 nVal = 0;
+ if ( (aValue >>= nVal) && nVal > sal::static_int_cast<sal_Int32>(MAXSUBTOTAL) )
+ {
+ throw lang::IllegalArgumentException();
+ }
+ }
+
+ PutData(aParam);
+}
+
+uno::Any SAL_CALL ScSubTotalDescriptorBase::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSubTotalParam aParam;
+ GetData(aParam);
+
+ String aString(aPropertyName);
+ uno::Any aRet;
+
+ // some old property names are for 5.2 compatibility
+
+ if (aString.EqualsAscii( SC_UNONAME_CASE ) || aString.EqualsAscii( SC_UNONAME_ISCASE ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bCaseSens );
+ else if (aString.EqualsAscii( SC_UNONAME_FORMATS ) || aString.EqualsAscii( SC_UNONAME_BINDFMT ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bIncludePattern );
+ else if (aString.EqualsAscii( SC_UNONAME_ENABSORT ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bDoSort );
+ else if (aString.EqualsAscii( SC_UNONAME_SORTASC ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bAscending );
+ else if (aString.EqualsAscii( SC_UNONAME_INSBRK ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bPagebreak );
+ else if (aString.EqualsAscii( SC_UNONAME_ULIST ) || aString.EqualsAscii( SC_UNONAME_ENUSLIST ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bUserDef );
+ else if (aString.EqualsAscii( SC_UNONAME_UINDEX ) || aString.EqualsAscii( SC_UNONAME_USINDEX ))
+ aRet <<= (sal_Int32) aParam.nUserIndex;
+ else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
+ aRet <<= (sal_Int32) MAXSUBTOTAL;
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSubTotalDescriptorBase )
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScSubTotalDescriptorBase::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScSubTotalDescriptorBase::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScSubTotalDescriptorBase* ScSubTotalDescriptorBase::getImplementation(
+ const uno::Reference<sheet::XSubTotalDescriptor> xObj )
+{
+ ScSubTotalDescriptorBase* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScSubTotalDescriptorBase*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScSubTotalDescriptor::ScSubTotalDescriptor()
+{
+}
+
+ScSubTotalDescriptor::~ScSubTotalDescriptor()
+{
+}
+
+void ScSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
+{
+ rParam = aStoredParam; // Abfrage fuer Interface
+}
+
+void ScSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
+{
+ aStoredParam = rParam; // vom Interface gesetzt
+}
+
+void ScSubTotalDescriptor::SetParam( const ScSubTotalParam& rNew )
+{
+ aStoredParam = rNew; // von aussen gesetzt
+}
+
+//------------------------------------------------------------------------
+
+ScRangeSubTotalDescriptor::ScRangeSubTotalDescriptor(ScDatabaseRangeObj* pPar) :
+ pParent(pPar)
+{
+ if (pParent)
+ pParent->acquire();
+}
+
+ScRangeSubTotalDescriptor::~ScRangeSubTotalDescriptor()
+{
+ if (pParent)
+ pParent->release();
+}
+
+void ScRangeSubTotalDescriptor::GetData( ScSubTotalParam& rParam ) const
+{
+ if (pParent)
+ pParent->GetSubTotalParam( rParam );
+}
+
+void ScRangeSubTotalDescriptor::PutData( const ScSubTotalParam& rParam )
+{
+ if (pParent)
+ pParent->SetSubTotalParam( rParam );
+}
+
+//------------------------------------------------------------------------
+
+ScConsolidationDescriptor::ScConsolidationDescriptor()
+{
+}
+
+ScConsolidationDescriptor::~ScConsolidationDescriptor()
+{
+}
+
+void ScConsolidationDescriptor::SetParam( const ScConsolidateParam& rNew )
+{
+ aParam = rNew;
+}
+
+// XConsolidationDescriptor
+
+sheet::GeneralFunction SAL_CALL ScConsolidationDescriptor::getFunction() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScDataUnoConversion::SubTotalToGeneral(aParam.eFunction);
+}
+
+void SAL_CALL ScConsolidationDescriptor::setFunction( sheet::GeneralFunction nFunction )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aParam.eFunction = ScDataUnoConversion::GeneralToSubTotal(nFunction);
+}
+
+uno::Sequence<table::CellRangeAddress> SAL_CALL ScConsolidationDescriptor::getSources()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aParam.nDataAreaCount;
+ if (!aParam.ppDataAreas)
+ nCount = 0;
+ table::CellRangeAddress aRange;
+ uno::Sequence<table::CellRangeAddress> aSeq(nCount);
+ table::CellRangeAddress* pAry = aSeq.getArray();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScArea* pArea = aParam.ppDataAreas[i];
+ if (pArea)
+ {
+ aRange.Sheet = pArea->nTab;
+ aRange.StartColumn = pArea->nColStart;
+ aRange.StartRow = pArea->nRowStart;
+ aRange.EndColumn = pArea->nColEnd;
+ aRange.EndRow = pArea->nRowEnd;
+ }
+ pAry[i] = aRange;
+ }
+ return aSeq;
+}
+
+void SAL_CALL ScConsolidationDescriptor::setSources(
+ const uno::Sequence<table::CellRangeAddress>& aSources )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = (USHORT)aSources.getLength();
+ if (nCount)
+ {
+ const table::CellRangeAddress* pAry = aSources.getConstArray();
+ ScArea** pNew = new ScArea*[nCount];
+ USHORT i;
+ for (i=0; i<nCount; i++)
+ pNew[i] = new ScArea( pAry[i].Sheet,
+ static_cast<SCCOL>(pAry[i].StartColumn), pAry[i].StartRow,
+ static_cast<SCCOL>(pAry[i].EndColumn), pAry[i].EndRow );
+
+ aParam.SetAreas( pNew, nCount ); // kopiert alles
+
+ for (i=0; i<nCount; i++)
+ delete pNew[i];
+ delete[] pNew;
+ }
+ else
+ aParam.ClearDataAreas();
+}
+
+table::CellAddress SAL_CALL ScConsolidationDescriptor::getStartOutputPosition()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellAddress aPos;
+ aPos.Column = aParam.nCol;
+ aPos.Row = aParam.nRow;
+ aPos.Sheet = aParam.nTab;
+ return aPos;
+}
+
+void SAL_CALL ScConsolidationDescriptor::setStartOutputPosition(
+ const table::CellAddress& aStartOutputPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aParam.nCol = (SCCOL)aStartOutputPosition.Column;
+ aParam.nRow = (SCROW)aStartOutputPosition.Row;
+ aParam.nTab = aStartOutputPosition.Sheet;
+}
+
+sal_Bool SAL_CALL ScConsolidationDescriptor::getUseColumnHeaders() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aParam.bByCol;
+}
+
+void SAL_CALL ScConsolidationDescriptor::setUseColumnHeaders( sal_Bool bUseColumnHeaders )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aParam.bByCol = bUseColumnHeaders;
+}
+
+sal_Bool SAL_CALL ScConsolidationDescriptor::getUseRowHeaders() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aParam.bByRow;
+}
+
+void SAL_CALL ScConsolidationDescriptor::setUseRowHeaders( sal_Bool bUseRowHeaders )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aParam.bByRow = bUseRowHeaders;
+}
+
+sal_Bool SAL_CALL ScConsolidationDescriptor::getInsertLinks() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aParam.bReferenceData;
+}
+
+void SAL_CALL ScConsolidationDescriptor::setInsertLinks( sal_Bool bInsertLinks )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aParam.bReferenceData = bInsertLinks;
+}
+
+//------------------------------------------------------------------------
+
+ScFilterDescriptorBase::ScFilterDescriptorBase(ScDocShell* pDocShell) :
+ aPropSet( lcl_GetFilterPropertyMap() ),
+ pDocSh(pDocShell)
+{
+ if (pDocSh)
+ pDocSh->GetDocument()->AddUnoObject(*this);
+}
+
+ScFilterDescriptorBase::~ScFilterDescriptorBase()
+{
+ if (pDocSh)
+ pDocSh->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScFilterDescriptorBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ pDocSh = NULL; // invalid
+ }
+ }
+}
+
+// XSheetFilterDescriptor and XSheetFilterDescriptor2
+
+uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilterFields()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScQueryParam aParam;
+ GetData(aParam);
+
+ SCSIZE nEntries = aParam.GetEntryCount(); // allozierte Eintraege im Param
+ SCSIZE nCount = 0; // aktive
+ while ( nCount < nEntries &&
+ aParam.GetEntry(nCount).bDoQuery )
+ ++nCount;
+
+ sheet::TableFilterField aField;
+ uno::Sequence<sheet::TableFilterField> aSeq(static_cast<sal_Int32>(nCount));
+ sheet::TableFilterField* pAry = aSeq.getArray();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ const ScQueryEntry& rEntry = aParam.GetEntry(i);
+
+ rtl::OUString aStringValue;
+ if (rEntry.pStr)
+ aStringValue = *rEntry.pStr;
+
+ aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
+ sheet::FilterConnection_OR;
+ aField.Field = rEntry.nField;
+ aField.IsNumeric = !rEntry.bQueryByString;
+ aField.StringValue = aStringValue;
+ aField.NumericValue = rEntry.nVal;
+
+ switch (rEntry.eOp) // ScQueryOp
+ {
+ case SC_EQUAL:
+ {
+ aField.Operator = sheet::FilterOperator_EQUAL;
+ if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
+ {
+ if (rEntry.nVal == SC_EMPTYFIELDS)
+ {
+ aField.Operator = sheet::FilterOperator_EMPTY;
+ aField.NumericValue = 0;
+ }
+ else if (rEntry.nVal == SC_NONEMPTYFIELDS)
+ {
+ aField.Operator = sheet::FilterOperator_NOT_EMPTY;
+ aField.NumericValue = 0;
+ }
+ }
+ }
+ break;
+ case SC_LESS: aField.Operator = sheet::FilterOperator_LESS; break;
+ case SC_GREATER: aField.Operator = sheet::FilterOperator_GREATER; break;
+ case SC_LESS_EQUAL: aField.Operator = sheet::FilterOperator_LESS_EQUAL; break;
+ case SC_GREATER_EQUAL: aField.Operator = sheet::FilterOperator_GREATER_EQUAL; break;
+ case SC_NOT_EQUAL: aField.Operator = sheet::FilterOperator_NOT_EQUAL; break;
+ case SC_TOPVAL: aField.Operator = sheet::FilterOperator_TOP_VALUES; break;
+ case SC_BOTVAL: aField.Operator = sheet::FilterOperator_BOTTOM_VALUES; break;
+ case SC_TOPPERC: aField.Operator = sheet::FilterOperator_TOP_PERCENT; break;
+ case SC_BOTPERC: aField.Operator = sheet::FilterOperator_BOTTOM_PERCENT; break;
+ default:
+ DBG_ERROR("Falscher Filter-enum");
+ aField.Operator = sheet::FilterOperator_EMPTY;
+ }
+ pAry[i] = aField;
+ }
+ return aSeq;
+}
+
+uno::Sequence<sheet::TableFilterField2> SAL_CALL ScFilterDescriptorBase::getFilterFields2()
+throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScQueryParam aParam;
+ GetData(aParam);
+
+ SCSIZE nEntries = aParam.GetEntryCount(); // allozierte Eintraege im Param
+ SCSIZE nCount = 0; // aktive
+ while ( nCount < nEntries &&
+ aParam.GetEntry(nCount).bDoQuery )
+ ++nCount;
+
+ sheet::TableFilterField2 aField;
+ uno::Sequence<sheet::TableFilterField2> aSeq(static_cast<sal_Int32>(nCount));
+ sheet::TableFilterField2* pAry = aSeq.getArray();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ const ScQueryEntry& rEntry = aParam.GetEntry(i);
+
+ rtl::OUString aStringValue;
+ if (rEntry.pStr)
+ aStringValue = *rEntry.pStr;
+
+ aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND : sheet::FilterConnection_OR;
+ aField.Field = rEntry.nField;
+ aField.IsNumeric = !rEntry.bQueryByString;
+ aField.StringValue = aStringValue;
+ aField.NumericValue = rEntry.nVal;
+
+ switch (rEntry.eOp) // ScQueryOp
+ {
+ case SC_EQUAL:
+ {
+ aField.Operator = sheet::FilterOperator2::EQUAL;
+ if (!rEntry.bQueryByString && *rEntry.pStr == EMPTY_STRING)
+ {
+ if (rEntry.nVal == SC_EMPTYFIELDS)
+ {
+ aField.Operator = sheet::FilterOperator2::EMPTY;
+ aField.NumericValue = 0;
+ }
+ else if (rEntry.nVal == SC_NONEMPTYFIELDS)
+ {
+ aField.Operator = sheet::FilterOperator2::NOT_EMPTY;
+ aField.NumericValue = 0;
+ }
+ }
+ }
+ break;
+ case SC_LESS: aField.Operator = sheet::FilterOperator2::LESS; break;
+ case SC_GREATER: aField.Operator = sheet::FilterOperator2::GREATER; break;
+ case SC_LESS_EQUAL: aField.Operator = sheet::FilterOperator2::LESS_EQUAL; break;
+ case SC_GREATER_EQUAL: aField.Operator = sheet::FilterOperator2::GREATER_EQUAL; break;
+ case SC_NOT_EQUAL: aField.Operator = sheet::FilterOperator2::NOT_EQUAL; break;
+ case SC_TOPVAL: aField.Operator = sheet::FilterOperator2::TOP_VALUES; break;
+ case SC_BOTVAL: aField.Operator = sheet::FilterOperator2::BOTTOM_VALUES; break;
+ case SC_TOPPERC: aField.Operator = sheet::FilterOperator2::TOP_PERCENT; break;
+ case SC_BOTPERC: aField.Operator = sheet::FilterOperator2::BOTTOM_PERCENT; break;
+ case SC_CONTAINS: aField.Operator = sheet::FilterOperator2::CONTAINS; break;
+ case SC_DOES_NOT_CONTAIN: aField.Operator = sheet::FilterOperator2::DOES_NOT_CONTAIN; break;
+ case SC_BEGINS_WITH: aField.Operator = sheet::FilterOperator2::BEGINS_WITH; break;
+ case SC_DOES_NOT_BEGIN_WITH: aField.Operator = sheet::FilterOperator2::DOES_NOT_BEGIN_WITH; break;
+ case SC_ENDS_WITH: aField.Operator = sheet::FilterOperator2::ENDS_WITH; break;
+ case SC_DOES_NOT_END_WITH: aField.Operator = sheet::FilterOperator2::DOES_NOT_END_WITH; break;
+ default:
+ DBG_ERROR("Falscher Filter-enum");
+ aField.Operator = sheet::FilterOperator2::EMPTY;
+ }
+ pAry[i] = aField;
+ }
+ return aSeq;
+}
+
+void SAL_CALL ScFilterDescriptorBase::setFilterFields(
+ const uno::Sequence<sheet::TableFilterField>& aFilterFields )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScQueryParam aParam;
+ GetData(aParam);
+
+ SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
+ DBG_ASSERT( nCount <= MAXQUERY, "setFilterFields: zu viele" );
+
+ aParam.Resize( nCount );
+
+ const sheet::TableFilterField* pAry = aFilterFields.getConstArray();
+ SCSIZE i;
+ for (i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (!rEntry.pStr)
+ rEntry.pStr = new String; // sollte nicht sein (soll immer initialisiert sein)
+
+ rEntry.bDoQuery = TRUE;
+ rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
+ rEntry.nField = pAry[i].Field;
+ rEntry.bQueryByString = !pAry[i].IsNumeric;
+ *rEntry.pStr = String( pAry[i].StringValue );
+ rEntry.nVal = pAry[i].NumericValue;
+
+ if (!rEntry.bQueryByString && pDocSh)
+ {
+ pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr);
+ }
+
+ switch (pAry[i].Operator) // FilterOperator
+ {
+ case sheet::FilterOperator_EQUAL: rEntry.eOp = SC_EQUAL; break;
+ case sheet::FilterOperator_LESS: rEntry.eOp = SC_LESS; break;
+ case sheet::FilterOperator_GREATER: rEntry.eOp = SC_GREATER; break;
+ case sheet::FilterOperator_LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break;
+ case sheet::FilterOperator_GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break;
+ case sheet::FilterOperator_NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break;
+ case sheet::FilterOperator_TOP_VALUES: rEntry.eOp = SC_TOPVAL; break;
+ case sheet::FilterOperator_BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break;
+ case sheet::FilterOperator_TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break;
+ case sheet::FilterOperator_BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break;
+ case sheet::FilterOperator_EMPTY:
+ {
+ rEntry.eOp = SC_EQUAL;
+ rEntry.nVal = SC_EMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ *rEntry.pStr = EMPTY_STRING;
+ }
+ break;
+ case sheet::FilterOperator_NOT_EMPTY:
+ {
+ rEntry.eOp = SC_EQUAL;
+ rEntry.nVal = SC_NONEMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ *rEntry.pStr = EMPTY_STRING;
+ }
+ break;
+ default:
+ DBG_ERROR("Falscher Query-enum");
+ rEntry.eOp = SC_EQUAL;
+ }
+ }
+
+ SCSIZE nParamCount = aParam.GetEntryCount(); // Param wird nicht unter 8 resized
+ for (i=nCount; i<nParamCount; i++)
+ aParam.GetEntry(i).bDoQuery = FALSE; // ueberzaehlige Felder zuruecksetzen
+
+ PutData(aParam);
+}
+
+void SAL_CALL ScFilterDescriptorBase::setFilterFields2(
+ const uno::Sequence<sheet::TableFilterField2>& aFilterFields )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScQueryParam aParam;
+ GetData(aParam);
+
+ SCSIZE nCount = static_cast<SCSIZE>(aFilterFields.getLength());
+ DBG_ASSERT( nCount <= MAXQUERY, "setFilterFields: zu viele" );
+
+ aParam.Resize( nCount );
+
+ const sheet::TableFilterField2* pAry = aFilterFields.getConstArray();
+ SCSIZE i;
+ for (i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (!rEntry.pStr)
+ rEntry.pStr = new String; // sollte nicht sein (soll immer initialisiert sein)
+
+ rEntry.bDoQuery = TRUE;
+ rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
+ rEntry.nField = pAry[i].Field;
+ rEntry.bQueryByString = !pAry[i].IsNumeric;
+ *rEntry.pStr = String( pAry[i].StringValue );
+ rEntry.nVal = pAry[i].NumericValue;
+
+ if (!rEntry.bQueryByString && pDocSh)
+ {
+ pDocSh->GetDocument()->GetFormatTable()->GetInputLineString(rEntry.nVal, 0, *rEntry.pStr);
+ }
+
+ switch (pAry[i].Operator) // FilterOperator
+ {
+ case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break;
+ case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break;
+ case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break;
+ case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break;
+ case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break;
+ case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break;
+ case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break;
+ case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break;
+ case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break;
+ case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break;
+ case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break;
+ case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break;
+ case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break;
+ case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break;
+ case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break;
+ case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break;
+ case sheet::FilterOperator2::EMPTY:
+ {
+ rEntry.eOp = SC_EQUAL;
+ rEntry.nVal = SC_EMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ *rEntry.pStr = EMPTY_STRING;
+ }
+ break;
+ case sheet::FilterOperator2::NOT_EMPTY:
+ {
+ rEntry.eOp = SC_EQUAL;
+ rEntry.nVal = SC_NONEMPTYFIELDS;
+ rEntry.bQueryByString = FALSE;
+ *rEntry.pStr = EMPTY_STRING;
+ }
+ break;
+ default:
+ DBG_ERROR("Falscher Query-enum");
+ rEntry.eOp = SC_EQUAL;
+ }
+ }
+
+ SCSIZE nParamCount = aParam.GetEntryCount(); // Param wird nicht unter 8 resized
+ for (i=nCount; i<nParamCount; i++)
+ aParam.GetEntry(i).bDoQuery = FALSE; // ueberzaehlige Felder zuruecksetzen
+
+ PutData(aParam);
+}
+
+// Rest sind Properties
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFilterDescriptorBase::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScFilterDescriptorBase::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScQueryParam aParam;
+ GetData(aParam);
+
+ String aString(aPropertyName);
+ if (aString.EqualsAscii( SC_UNONAME_CONTHDR ))
+ aParam.bHasHeader = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_COPYOUT ))
+ aParam.bInplace = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
+ else if (aString.EqualsAscii( SC_UNONAME_ISCASE ))
+ aParam.bCaseSens = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
+ {
+ sal_Int32 nVal = 0;
+ if ( (aValue >>= nVal) && nVal > sal::static_int_cast<sal_Int32>(MAXQUERY) )
+ {
+ throw lang::IllegalArgumentException();
+ }
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_ORIENT ))
+ {
+ //! test for correct enum type?
+ table::TableOrientation eOrient = (table::TableOrientation)
+ ScUnoHelpFunctions::GetEnumFromAny( aValue );
+ aParam.bByRow = ( eOrient != table::TableOrientation_COLUMNS );
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_OUTPOS ))
+ {
+ table::CellAddress aAddress;
+ if ( aValue >>= aAddress )
+ {
+ aParam.nDestTab = aAddress.Sheet;
+ aParam.nDestCol = (SCCOL)aAddress.Column;
+ aParam.nDestRow = (SCROW)aAddress.Row;
+ }
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_SAVEOUT ))
+ aParam.bDestPers = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if (aString.EqualsAscii( SC_UNONAME_SKIPDUP ))
+ aParam.bDuplicate = !(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
+ else if (aString.EqualsAscii( SC_UNONAME_USEREGEX ))
+ aParam.bRegExp = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+
+ PutData(aParam);
+}
+
+uno::Any SAL_CALL ScFilterDescriptorBase::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScQueryParam aParam;
+ GetData(aParam);
+
+ String aString(aPropertyName);
+ uno::Any aRet;
+
+ if (aString.EqualsAscii( SC_UNONAME_CONTHDR ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bHasHeader );
+ else if (aString.EqualsAscii( SC_UNONAME_COPYOUT ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bInplace) );
+ else if (aString.EqualsAscii( SC_UNONAME_ISCASE ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bCaseSens );
+ else if (aString.EqualsAscii( SC_UNONAME_MAXFLD ))
+ aRet <<= (sal_Int32) MAXQUERY;
+ else if (aString.EqualsAscii( SC_UNONAME_ORIENT ))
+ {
+ table::TableOrientation eOrient = aParam.bByRow ? table::TableOrientation_ROWS :
+ table::TableOrientation_COLUMNS;
+ aRet <<= eOrient;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_OUTPOS ))
+ {
+ table::CellAddress aOutPos;
+ aOutPos.Sheet = aParam.nDestTab;
+ aOutPos.Column = aParam.nDestCol;
+ aOutPos.Row = aParam.nDestRow;
+ aRet <<= aOutPos;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_SAVEOUT ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bDestPers );
+ else if (aString.EqualsAscii( SC_UNONAME_SKIPDUP ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, !(aParam.bDuplicate) );
+ else if (aString.EqualsAscii( SC_UNONAME_USEREGEX ))
+ ScUnoHelpFunctions::SetBoolInAny( aRet, aParam.bRegExp );
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFilterDescriptorBase )
+
+//------------------------------------------------------------------------
+
+ScFilterDescriptor::ScFilterDescriptor(ScDocShell* pDocShell)
+ :
+ ScFilterDescriptorBase(pDocShell)
+{
+}
+
+ScFilterDescriptor::~ScFilterDescriptor()
+{
+}
+
+void ScFilterDescriptor::GetData( ScQueryParam& rParam ) const
+{
+ rParam = aStoredParam; // Abfrage fuer Interface
+}
+
+void ScFilterDescriptor::PutData( const ScQueryParam& rParam )
+{
+ aStoredParam = rParam; // vom Interface gesetzt
+}
+
+void ScFilterDescriptor::SetParam( const ScQueryParam& rNew )
+{
+ aStoredParam = rNew; // von aussen gesetzt
+}
+
+//------------------------------------------------------------------------
+
+ScRangeFilterDescriptor::ScRangeFilterDescriptor(ScDocShell* pDocShell, ScDatabaseRangeObj* pPar) :
+ ScFilterDescriptorBase(pDocShell),
+ pParent(pPar)
+{
+ if (pParent)
+ pParent->acquire();
+}
+
+ScRangeFilterDescriptor::~ScRangeFilterDescriptor()
+{
+ if (pParent)
+ pParent->release();
+}
+
+void ScRangeFilterDescriptor::GetData( ScQueryParam& rParam ) const
+{
+ if (pParent)
+ pParent->GetQueryParam( rParam );
+}
+
+void ScRangeFilterDescriptor::PutData( const ScQueryParam& rParam )
+{
+ if (pParent)
+ pParent->SetQueryParam( rParam );
+}
+
+//------------------------------------------------------------------------
+
+ScDataPilotFilterDescriptor::ScDataPilotFilterDescriptor(ScDocShell* pDocShell, ScDataPilotDescriptorBase* pPar) :
+ ScFilterDescriptorBase(pDocShell),
+ pParent(pPar)
+{
+ if (pParent)
+ pParent->acquire();
+}
+
+ScDataPilotFilterDescriptor::~ScDataPilotFilterDescriptor()
+{
+ if (pParent)
+ pParent->release();
+}
+
+void ScDataPilotFilterDescriptor::GetData( ScQueryParam& rParam ) const
+{
+ if (pParent)
+ {
+ ScDPObject* pDPObj = pParent->GetDPObject();
+ if (pDPObj && pDPObj->IsSheetData())
+ rParam = pDPObj->GetSheetDesc()->aQueryParam;
+ }
+}
+
+void ScDataPilotFilterDescriptor::PutData( const ScQueryParam& rParam )
+{
+ if (pParent)
+ {
+ ScDPObject* pDPObj = pParent->GetDPObject();
+ if (pDPObj)
+ {
+ ScSheetSourceDesc aSheetDesc;
+ if (pDPObj->IsSheetData())
+ aSheetDesc = *pDPObj->GetSheetDesc();
+ aSheetDesc.aQueryParam = rParam;
+ pDPObj->SetSheetDesc(aSheetDesc);
+ pParent->SetDPObject(pDPObj);
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScDatabaseRangeObj::ScDatabaseRangeObj(ScDocShell* pDocSh, const String& rNm) :
+ pDocShell( pDocSh ),
+ aName( rNm ),
+ aPropSet( lcl_GetDBRangePropertyMap() )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDatabaseRangeObj::~ScDatabaseRangeObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDatabaseRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+
+ if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // ungueltig geworden
+ else if ( rHint.ISA (ScDBRangeRefreshedHint) )
+ {
+ ScDBData* pDBData = GetDBData_Impl();
+ const ScDBRangeRefreshedHint& rRef = (const ScDBRangeRefreshedHint&)rHint;
+ ScImportParam aParam;
+ pDBData->GetImportParam(aParam);
+ if (aParam == rRef.GetImportParam())
+ Refreshed_Impl();
+ }
+}
+
+// Hilfsfuntionen
+
+ScDBData* ScDatabaseRangeObj::GetDBData_Impl() const
+{
+ ScDBData* pRet = NULL;
+ if (pDocShell)
+ {
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (pNames)
+ {
+ USHORT nPos = 0;
+ if (pNames->SearchName( aName, nPos ))
+ pRet = (*pNames)[nPos];
+ }
+ }
+ return pRet;
+}
+
+// XNamed
+
+rtl::OUString SAL_CALL ScDatabaseRangeObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aName;
+}
+
+void SAL_CALL ScDatabaseRangeObj::setName( const rtl::OUString& aNewName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDBDocFunc aFunc(*pDocShell);
+ String aNewStr(aNewName);
+ BOOL bOk = aFunc.RenameDBRange( aName, aNewStr, TRUE );
+ if (bOk)
+ aName = aNewStr;
+ }
+}
+
+// XDatabaseRange
+
+table::CellRangeAddress SAL_CALL ScDatabaseRangeObj::getDataArea() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aAddress;
+ ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ {
+ ScRange aRange;
+ pData->GetArea(aRange);
+ aAddress.Sheet = aRange.aStart.Tab();
+ aAddress.StartColumn = aRange.aStart.Col();
+ aAddress.StartRow = aRange.aStart.Row();
+ aAddress.EndColumn = aRange.aEnd.Col();
+ aAddress.EndRow = aRange.aEnd.Row();
+ }
+ return aAddress;
+}
+
+void SAL_CALL ScDatabaseRangeObj::setDataArea( const table::CellRangeAddress& aDataArea )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDBData* pData = GetDBData_Impl();
+ if ( pDocShell && pData )
+ {
+ ScDBData aNewData( *pData );
+ //! MoveTo ???
+ aNewData.SetArea( aDataArea.Sheet, (SCCOL)aDataArea.StartColumn, (SCROW)aDataArea.StartRow,
+ (SCCOL)aDataArea.EndColumn, (SCROW)aDataArea.EndRow );
+ ScDBDocFunc aFunc(*pDocShell);
+ aFunc.ModifyDBData(aNewData, TRUE);
+ }
+}
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getSortDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScSortParam aParam;
+ const ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ {
+ pData->GetSortParam(aParam);
+
+ // im SortDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
+ for (USHORT i=0; i<MAXSORT; i++)
+ if ( aParam.bDoSort[i] && aParam.nField[i] >= nFieldStart )
+ aParam.nField[i] -= nFieldStart;
+ }
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScSortDescriptor::GetPropertyCount() );
+ ScSortDescriptor::FillProperties( aSeq, aParam );
+ return aSeq;
+}
+
+void ScDatabaseRangeObj::GetQueryParam(ScQueryParam& rQueryParam) const
+{
+ const ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ {
+ pData->GetQueryParam(rQueryParam);
+
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOLROW nFieldStart = rQueryParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
+ SCSIZE nCount = rQueryParam.GetEntryCount();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = rQueryParam.GetEntry(i);
+ if (rEntry.bDoQuery && rEntry.nField >= nFieldStart)
+ rEntry.nField -= nFieldStart;
+ }
+ }
+}
+
+void ScDatabaseRangeObj::SetQueryParam(const ScQueryParam& rQueryParam)
+{
+ const ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ {
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScQueryParam aParam(rQueryParam);
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOLROW nFieldStart = aParam.bByRow ? static_cast<SCCOLROW>(aDBRange.aStart.Col()) : static_cast<SCCOLROW>(aDBRange.aStart.Row());
+
+ SCSIZE nCount = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nCount; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (rEntry.bDoQuery)
+ rEntry.nField += nFieldStart;
+ }
+
+ ScDBData aNewData( *pData );
+ aNewData.SetQueryParam(aParam);
+ aNewData.SetHeader(aParam.bHasHeader); // not in ScDBData::SetQueryParam
+ ScDBDocFunc aFunc(*pDocShell);
+ aFunc.ModifyDBData(aNewData, TRUE);
+ }
+}
+
+uno::Reference<sheet::XSheetFilterDescriptor> SAL_CALL ScDatabaseRangeObj::getFilterDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScRangeFilterDescriptor(pDocShell, this);
+}
+
+void ScDatabaseRangeObj::GetSubTotalParam(ScSubTotalParam& rSubTotalParam) const
+{
+ const ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ {
+ pData->GetSubTotalParam(rSubTotalParam);
+
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOL nFieldStart = aDBRange.aStart.Col();
+ for (USHORT i=0; i<MAXSUBTOTAL; i++)
+ {
+ if ( rSubTotalParam.bGroupActive[i] )
+ {
+ if ( rSubTotalParam.nField[i] >= nFieldStart )
+ rSubTotalParam.nField[i] = sal::static_int_cast<SCCOL>( rSubTotalParam.nField[i] - nFieldStart );
+ for (SCCOL j=0; j<rSubTotalParam.nSubTotals[i]; j++)
+ if ( rSubTotalParam.pSubTotals[i][j] >= nFieldStart )
+ rSubTotalParam.pSubTotals[i][j] =
+ sal::static_int_cast<SCCOL>( rSubTotalParam.pSubTotals[i][j] - nFieldStart );
+ }
+ }
+ }
+}
+
+void ScDatabaseRangeObj::SetSubTotalParam(const ScSubTotalParam& rSubTotalParam)
+{
+ const ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ {
+ // im FilterDescriptor sind die Fields innerhalb des Bereichs gezaehlt
+ ScSubTotalParam aParam(rSubTotalParam);
+ ScRange aDBRange;
+ pData->GetArea(aDBRange);
+ SCCOL nFieldStart = aDBRange.aStart.Col();
+ for (USHORT i=0; i<MAXSUBTOTAL; i++)
+ {
+ if ( aParam.bGroupActive[i] )
+ {
+ aParam.nField[i] = sal::static_int_cast<SCCOL>( aParam.nField[i] + nFieldStart );
+ for (SCCOL j=0; j<aParam.nSubTotals[i]; j++)
+ aParam.pSubTotals[i][j] = sal::static_int_cast<SCCOL>( aParam.pSubTotals[i][j] + nFieldStart );
+ }
+ }
+
+ ScDBData aNewData( *pData );
+ aNewData.SetSubTotalParam(aParam);
+ ScDBDocFunc aFunc(*pDocShell);
+ aFunc.ModifyDBData(aNewData, TRUE);
+ }
+}
+
+uno::Reference<sheet::XSubTotalDescriptor> SAL_CALL ScDatabaseRangeObj::getSubTotalDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScRangeSubTotalDescriptor(this);
+}
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScDatabaseRangeObj::getImportDescriptor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScImportParam aParam;
+ const ScDBData* pData = GetDBData_Impl();
+ if (pData)
+ pData->GetImportParam(aParam);
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
+ ScImportDescriptor::FillProperties( aSeq, aParam );
+ return aSeq;
+}
+
+// XRefreshable
+
+void SAL_CALL ScDatabaseRangeObj::refresh() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDBData* pData = GetDBData_Impl();
+ if ( pDocShell && pData )
+ {
+ ScDBDocFunc aFunc(*pDocShell);
+
+ // Import zu wiederholen?
+ BOOL bContinue = TRUE;
+ ScImportParam aImportParam;
+ pData->GetImportParam( aImportParam );
+ if (aImportParam.bImport && !pData->HasImportSelection())
+ {
+ SCTAB nTab;
+ SCCOL nDummyCol;
+ SCROW nDummyRow;
+ pData->GetArea( nTab, nDummyCol,nDummyRow,nDummyCol,nDummyRow );
+ uno::Reference< sdbc::XResultSet > xResultSet;
+ bContinue = aFunc.DoImport( nTab, aImportParam, xResultSet, NULL, TRUE, FALSE ); //! Api-Flag als Parameter
+ }
+
+ // interne Operationen (sort, query, subtotal) nur, wenn kein Fehler
+ if (bContinue)
+ aFunc.RepeatDB( pData->GetName(), TRUE, TRUE );
+ }
+}
+
+void SAL_CALL ScDatabaseRangeObj::addRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<util::XRefreshListener>* pObj =
+ new uno::Reference<util::XRefreshListener>( xListener );
+ aRefreshListeners.Insert( pObj, aRefreshListeners.Count() );
+
+ // hold one additional ref to keep this object alive as long as there are listeners
+ if ( aRefreshListeners.Count() == 1 )
+ acquire();
+}
+
+void SAL_CALL ScDatabaseRangeObj::removeRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aRefreshListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XRefreshListener>* pObj = aRefreshListeners[n];
+ if ( *pObj == xListener )
+ {
+ aRefreshListeners.DeleteAndDestroy( n );
+ if ( aRefreshListeners.Count() == 0 )
+ release(); // release ref for listeners
+ break;
+ }
+ }
+}
+
+void ScDatabaseRangeObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source = (cppu::OWeakObject*)this;
+ for ( USHORT n=0; n<aRefreshListeners.Count(); n++ )
+ (*aRefreshListeners[n])->refreshed( aEvent );
+}
+
+// XCellRangeSource
+
+uno::Reference<table::XCellRange> SAL_CALL ScDatabaseRangeObj::getReferredCells()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRange aRange;
+ ScDBData* pData = GetDBData_Impl();
+ if ( pData )
+ {
+ //! static Funktion um ScCellObj/ScCellRangeObj zu erzeugen am ScCellRangeObj ???
+
+ pData->GetArea(aRange);
+ if ( aRange.aStart == aRange.aEnd )
+ return new ScCellObj( pDocShell, aRange.aStart );
+ else
+ return new ScCellRangeObj( pDocShell, aRange );
+ }
+ return NULL;
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDatabaseRangeObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScDatabaseRangeObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDBData* pData = GetDBData_Impl();
+ if ( pDocShell && pData )
+ {
+ ScDBData aNewData( *pData );
+ BOOL bDo = TRUE;
+
+ String aString(aPropertyName);
+ if ( aString.EqualsAscii( SC_UNONAME_KEEPFORM ) )
+ aNewData.SetKeepFmt( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNONAME_MOVCELLS ) )
+ aNewData.SetDoSize( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNONAME_STRIPDAT ) )
+ aNewData.SetStripData( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNONAME_AUTOFLT ))
+ {
+ sal_Bool bAutoFilter(ScUnoHelpFunctions::GetBoolFromAny( aValue ));
+ aNewData.SetAutoFilter(bAutoFilter);
+ ScRange aRange;
+ aNewData.GetArea(aRange);
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (bAutoFilter && pDoc)
+ pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aStart.Row(),
+ aRange.aStart.Tab(), SC_MF_AUTO );
+ else if (!bAutoFilter && pDoc)
+ pDoc->RemoveFlagsTab(aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aStart.Row(),
+ aRange.aStart.Tab(), SC_MF_AUTO );
+ ScRange aPaintRange(aRange.aStart, aRange.aEnd);
+ aPaintRange.aEnd.SetRow(aPaintRange.aStart.Row());
+ pDocShell->PostPaint(aPaintRange, PAINT_GRID);
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_USEFLTCRT ))
+ {
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ {
+ ScRange aRange;
+ aNewData.GetAdvancedQuerySource(aRange);
+ aNewData.SetAdvancedQuerySource(&aRange);
+ }
+ else
+ aNewData.SetAdvancedQuerySource(NULL);
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_FLTCRT ))
+ {
+ table::CellRangeAddress aRange;
+ if (aValue >>= aRange)
+ {
+ ScRange aCoreRange;
+ ScUnoConversion::FillScRange(aCoreRange, aRange);
+
+ aNewData.SetAdvancedQuerySource(&aCoreRange);
+ }
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_FROMSELECT ))
+ {
+ aNewData.SetImportSelection(::cppu::any2bool(aValue));
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_REFPERIOD ))
+ {
+ sal_Int32 nRefresh = 0;
+ if (aValue >>= nRefresh)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ aNewData.SetRefreshDelay(nRefresh);
+ if (pDoc && pDoc->GetDBCollection())
+ {
+ aNewData.SetRefreshHandler( pDoc->GetDBCollection()->GetRefreshHandler() );
+ aNewData.SetRefreshControl( pDoc->GetRefreshTimerControlAddress() );
+ }
+ }
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_CONRES ))
+ {
+ }
+ else
+ bDo = FALSE;
+
+ if (bDo)
+ {
+ ScDBDocFunc aFunc(*pDocShell);
+ aFunc.ModifyDBData(aNewData, TRUE);
+ }
+ }
+}
+
+uno::Any SAL_CALL ScDatabaseRangeObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ ScDBData* pData = GetDBData_Impl();
+ if ( pData )
+ {
+ String aString(aPropertyName);
+ if ( aString.EqualsAscii( SC_UNONAME_KEEPFORM ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsKeepFmt() );
+ else if ( aString.EqualsAscii( SC_UNONAME_MOVCELLS ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsDoSize() );
+ else if ( aString.EqualsAscii( SC_UNONAME_STRIPDAT ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pData->IsStripData() );
+ else if ( aString.EqualsAscii( SC_UNONAME_ISUSER ) )
+ {
+ // all database ranges except "unnamed" are user defined
+ ScUnoHelpFunctions::SetBoolInAny( aRet,
+ ( pData->GetName() != ScGlobal::GetRscString(STR_DB_NONAME) ) );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_LINKDISPBIT ) )
+ {
+ // no target bitmaps for individual entries (would be all equal)
+ // ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_DBAREA );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_LINKDISPNAME ) )
+ aRet <<= rtl::OUString( aName );
+ else if (aString.EqualsAscii( SC_UNONAME_AUTOFLT ))
+ {
+ sal_Bool bAutoFilter(GetDBData_Impl()->HasAutoFilter());
+
+ ScUnoHelpFunctions::SetBoolInAny( aRet, bAutoFilter );
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_USEFLTCRT ))
+ {
+ ScRange aRange;
+ sal_Bool bIsAdvancedSource(GetDBData_Impl()->GetAdvancedQuerySource(aRange));
+
+ ScUnoHelpFunctions::SetBoolInAny( aRet, bIsAdvancedSource );
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_FLTCRT ))
+ {
+ table::CellRangeAddress aRange;
+ ScRange aCoreRange;
+ if (GetDBData_Impl()->GetAdvancedQuerySource(aCoreRange))
+ ScUnoConversion::FillApiRange(aRange, aCoreRange);
+
+ aRet <<= aRange;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_FROMSELECT ))
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, GetDBData_Impl()->HasImportSelection() );
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_REFPERIOD ))
+ {
+ sal_Int32 nRefresh(GetDBData_Impl()->GetRefreshDelay());
+ aRet <<= nRefresh;
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_CONRES ))
+ {
+ }
+ else if (aString.EqualsAscii( SC_UNONAME_TOKENINDEX ))
+ {
+ // get index for use in formula tokens (read-only)
+ aRet <<= static_cast<sal_Int32>(GetDBData_Impl()->GetIndex());
+ }
+ }
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDatabaseRangeObj )
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScDatabaseRangeObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScDatabaseRangeObj" );
+}
+
+sal_Bool SAL_CALL ScDatabaseRangeObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCDATABASERANGEOBJ_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCLINKTARGET_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangeObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCDATABASERANGEOBJ_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCLINKTARGET_SERVICE );
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+ScDatabaseRangesObj::ScDatabaseRangesObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDatabaseRangesObj::~ScDatabaseRangesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDatabaseRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XDatabaseRanges
+
+ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByIndex_Impl(USHORT nIndex)
+{
+ if (pDocShell)
+ {
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (pNames && nIndex < pNames->GetCount())
+ return new ScDatabaseRangeObj( pDocShell, (*pNames)[nIndex]->GetName() );
+ }
+ return NULL;
+}
+
+ScDatabaseRangeObj* ScDatabaseRangesObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ if ( pDocShell && hasByName(aName) )
+ {
+ String aString(aName);
+ return new ScDatabaseRangeObj( pDocShell, aString );
+ }
+ return NULL;
+}
+
+
+void SAL_CALL ScDatabaseRangesObj::addNewByName( const rtl::OUString& aName,
+ const table::CellRangeAddress& aRange )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ ScDBDocFunc aFunc(*pDocShell);
+
+ String aString(aName);
+ ScRange aNameRange( (SCCOL)aRange.StartColumn, (SCROW)aRange.StartRow, aRange.Sheet,
+ (SCCOL)aRange.EndColumn, (SCROW)aRange.EndRow, aRange.Sheet );
+ bDone = aFunc.AddDBRange( aString, aNameRange, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScDatabaseRangesObj::removeByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ ScDBDocFunc aFunc(*pDocShell);
+ String aString(aName);
+ bDone = aFunc.DeleteDBRange( aString, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScDatabaseRangesObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DatabaseRangesEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDatabaseRangesObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! "unbenannt" weglassen ?
+
+ if (pDocShell)
+ {
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (pNames)
+ return pNames->GetCount();
+ }
+ return 0;
+}
+
+uno::Any SAL_CALL ScDatabaseRangesObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByIndex_Impl((USHORT)nIndex));
+ if (xRange.is())
+ return uno::makeAny(xRange);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScDatabaseRangesObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XDatabaseRange>*)0);
+}
+
+sal_Bool SAL_CALL ScDatabaseRangesObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// XNameAccess
+
+uno::Any SAL_CALL ScDatabaseRangesObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XDatabaseRange> xRange(GetObjectByName_Impl(aName));
+ if (xRange.is())
+ return uno::makeAny(xRange);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScDatabaseRangesObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! "unbenannt" weglassen ?
+
+ if (pDocShell)
+ {
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (pNames)
+ {
+ USHORT nCount = pNames->GetCount();
+ String aName;
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (USHORT i=0; i<nCount; i++)
+ pAry[i] = (*pNames)[i]->GetName();
+
+ return aSeq;
+ }
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+sal_Bool SAL_CALL ScDatabaseRangesObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! "unbenannt" weglassen ?
+
+ if (pDocShell)
+ {
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (pNames)
+ {
+ String aString(aName);
+ USHORT nPos = 0;
+ if (pNames->SearchName( aString, nPos ))
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx
new file mode 100644
index 000000000000..cf1f27cee254
--- /dev/null
+++ b/sc/source/ui/unoobj/defltuno.cxx
@@ -0,0 +1,389 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <editeng/memberids.hrc>
+#include <svl/smplhint.hxx>
+#include <svl/itemprop.hxx>
+#include <svx/unomid.hxx>
+#include <vcl/svapp.hxx>
+#include <i18npool/mslangid.hxx>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include "scitems.hxx"
+#include "defltuno.hxx"
+#include "miscuno.hxx"
+#include "docsh.hxx"
+#include "docpool.hxx"
+#include "unonames.hxx"
+#include "docoptio.hxx"
+
+#include <limits>
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+const SfxItemPropertyMapEntry* lcl_GetDocDefaultsMap()
+{
+ static SfxItemPropertyMapEntry aDocDefaultsMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE, &getCppuType((lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), 0, &getCppuType((sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_TABSTOPDIS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aDocDefaultsMap_Impl;
+}
+
+inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
+inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
+inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScDocDefaultsObj, "ScDocDefaultsObj", "com.sun.star.sheet.Defaults" )
+
+//------------------------------------------------------------------------
+
+ScDocDefaultsObj::ScDocDefaultsObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh ),
+ aPropertyMap(lcl_GetDocDefaultsMap())
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDocDefaultsObj::~ScDocDefaultsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDocDefaultsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // document gone
+ }
+}
+
+void ScDocDefaultsObj::ItemsChanged()
+{
+ if (pDocShell)
+ {
+ //! if not in XML import, adjust row heights
+
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ }
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScDocDefaultsObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef = new SfxItemPropertySetInfo(
+ &aPropertyMap );
+ return aRef;
+}
+
+void SAL_CALL ScDocDefaultsObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+ if(!pEntry->nWID)
+ {
+ if(aPropertyName.compareToAscii(SC_UNO_STANDARDDEC) == 0)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ ScDocOptions aDocOpt(pDoc->GetDocOptions());
+ sal_Int16 nValue = 0;
+ if (aValue >>= nValue)
+ {
+ aDocOpt.SetStdPrecision(static_cast<sal_uInt16> (nValue));
+ pDoc->SetDocOptions(aDocOpt);
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ else if (aPropertyName.compareToAscii(SC_UNO_TABSTOPDIS) == 0)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ ScDocOptions aDocOpt(pDoc->GetDocOptions());
+ sal_Int32 nValue = 0;
+ if (aValue >>= nValue)
+ {
+ aDocOpt.SetTabDistance(static_cast<sal_uInt16>(HMMToTwips(nValue)));
+ pDoc->SetDocOptions(aDocOpt);
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ }
+ else if ( pEntry->nWID == ATTR_FONT_LANGUAGE ||
+ pEntry->nWID == ATTR_CJK_FONT_LANGUAGE ||
+ pEntry->nWID == ATTR_CTL_FONT_LANGUAGE )
+ {
+ // for getPropertyValue the PoolDefaults are sufficient,
+ // but setPropertyValue has to be handled differently
+
+ lang::Locale aLocale;
+ if ( aValue >>= aLocale )
+ {
+ LanguageType eNew;
+ if (aLocale.Language.getLength() || aLocale.Country.getLength())
+ eNew = MsLangId::convertLocaleToLanguage( aLocale );
+ else
+ eNew = LANGUAGE_NONE;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+
+ if ( pEntry->nWID == ATTR_CJK_FONT_LANGUAGE )
+ eCjk = eNew;
+ else if ( pEntry->nWID == ATTR_CTL_FONT_LANGUAGE )
+ eCtl = eNew;
+ else
+ eLatin = eNew;
+
+ pDoc->SetLanguage( eLatin, eCjk, eCtl );
+ }
+ }
+ else
+ {
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ SfxPoolItem* pNewItem = pPool->GetDefaultItem(pEntry->nWID).Clone();
+
+ if( !pNewItem->PutValue( aValue, pEntry->nMemberId ) )
+ throw lang::IllegalArgumentException();
+
+ pPool->SetPoolDefaultItem( *pNewItem );
+ delete pNewItem; // copied in SetPoolDefaultItem
+
+ ItemsChanged();
+ }
+}
+
+uno::Any SAL_CALL ScDocDefaultsObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ // use pool default if set
+
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ uno::Any aRet;
+ const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ if (!pEntry->nWID)
+ {
+ if(aPropertyName.compareToAscii(SC_UNO_STANDARDDEC) == 0)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ const ScDocOptions& aDocOpt = pDoc->GetDocOptions();
+ sal_uInt16 nPrec = aDocOpt.GetStdPrecision();
+ // the max value of unsigned 16-bit integer is used as the flag
+ // value for unlimited precision, c.f.
+ // SvNumberFormatter::UNLIMITED_PRECISION.
+ if (nPrec <= ::std::numeric_limits<sal_Int16>::max())
+ aRet <<= static_cast<sal_Int16> (nPrec);
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ else if (aPropertyName.compareToAscii(SC_UNO_TABSTOPDIS) == 0)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (pDoc)
+ {
+ const ScDocOptions& aDocOpt = pDoc->GetDocOptions();
+ sal_Int32 nValue (TwipsToEvenHMM(aDocOpt.GetTabDistance()));
+ aRet <<= nValue;
+ }
+ else
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ {
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ const SfxPoolItem& rItem = pPool->GetDefaultItem( pEntry->nWID );
+ rItem.QueryValue( aRet, pEntry->nMemberId );
+ }
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScDocDefaultsObj )
+
+// XPropertyState
+
+beans::PropertyState SAL_CALL ScDocDefaultsObj::getPropertyState( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE;
+
+ USHORT nWID = pEntry->nWID;
+ if ( nWID == ATTR_FONT || nWID == ATTR_CJK_FONT || nWID == ATTR_CTL_FONT || !nWID )
+ {
+ // static default for font is system-dependent,
+ // so font default is always treated as "direct value".
+
+ eRet = beans::PropertyState_DIRECT_VALUE;
+ }
+ else
+ {
+ // check if pool default is set
+
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ if ( pPool->GetPoolDefaultItem( nWID ) != NULL )
+ eRet = beans::PropertyState_DIRECT_VALUE;
+ }
+
+ return eRet;
+}
+
+uno::Sequence<beans::PropertyState> SAL_CALL ScDocDefaultsObj::getPropertyStates(
+ const uno::Sequence<rtl::OUString>& aPropertyNames )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ // the simple way: call getPropertyState
+
+ SolarMutexGuard aGuard;
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+ uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
+ beans::PropertyState* pStates = aRet.getArray();
+ for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
+ pStates[i] = getPropertyState(pNames[i]);
+ return aRet;
+}
+
+void SAL_CALL ScDocDefaultsObj::setPropertyToDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ if (pEntry->nWID)
+ {
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ pPool->ResetPoolDefaultItem( pEntry->nWID );
+
+ ItemsChanged();
+ }
+}
+
+uno::Any SAL_CALL ScDocDefaultsObj::getPropertyDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ // always use static default
+
+ SolarMutexGuard aGuard;
+
+ if ( !pDocShell )
+ throw uno::RuntimeException();
+
+ const SfxItemPropertySimpleEntry* pEntry = aPropertyMap.getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ uno::Any aRet;
+ if (pEntry->nWID)
+ {
+ ScDocumentPool* pPool = pDocShell->GetDocument()->GetPool();
+ const SfxPoolItem* pItem = pPool->GetItem( pEntry->nWID, SFX_ITEMS_STATICDEFAULT );
+ if (pItem)
+ pItem->QueryValue( aRet, pEntry->nMemberId );
+ }
+ return aRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/detreg.cxx b/sc/source/ui/unoobj/detreg.cxx
new file mode 100644
index 000000000000..653fbefa0a51
--- /dev/null
+++ b/sc/source/ui/unoobj/detreg.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scdetect.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/uno/Sequence.h>
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char** ppEnvironmentTypeName,
+ uno_Environment** /* ppEnvironment */ )
+{
+ *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /* pServiceManager */ ,
+ void* pRegistryKey )
+{
+ Reference< ::registry::XRegistryKey >
+ xKey( reinterpret_cast< ::registry::XRegistryKey* >( pRegistryKey ) ) ;
+
+ OUString aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
+ OUString aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
+
+ // Eigentliche Implementierung und ihre Services registrieren
+ sal_Int32 i;
+ Reference< ::registry::XRegistryKey > xNewKey(xKey->createKey( aDelimiter + ScFilterDetect::impl_getStaticImplementationName() +
+ aUnoServices ));
+
+ Sequence< OUString > aServices(ScFilterDetect::impl_getStaticSupportedServiceNames());
+ for(i = 0; i < aServices.getLength(); i++ )
+ xNewKey->createKey( aServices.getConstArray()[i] );
+
+ return sal_True;
+}
+
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /* pRegistryKey */ )
+{
+ // Set default return value for this operation - if it failed.
+ void* pReturn = NULL ;
+
+ if (
+ ( pImplementationName != NULL ) &&
+ ( pServiceManager != NULL )
+ )
+ {
+ // Define variables which are used in following macros.
+ Reference< XSingleServiceFactory > xFactory ;
+ Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+
+ if( ScFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) )
+ {
+ xFactory.set(::cppu::createSingleFactory( xServiceManager,
+ ScFilterDetect::impl_getStaticImplementationName(),
+ ScFilterDetect::impl_createInstance,
+ ScFilterDetect::impl_getStaticSupportedServiceNames() ));
+ }
+
+ // Factory is valid - service was found.
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pReturn = xFactory.get();
+ }
+ }
+
+ // Return with result of this operation.
+ return pReturn ;
+}
+} // extern "C"
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx
new file mode 100644
index 000000000000..ded35a1148b5
--- /dev/null
+++ b/sc/source/ui/unoobj/dispuno.cxx
@@ -0,0 +1,417 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <sfx2/viewfrm.hxx>
+#include <comphelper/uno3.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <svl/smplhint.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+
+#include "dispuno.hxx"
+#include "tabvwsh.hxx"
+#include "dbdocfun.hxx"
+#include "dbcolect.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+const char* cURLInsertColumns = ".uno:DataSourceBrowser/InsertColumns"; //data into text
+const char* cURLDocDataSource = ".uno:DataSourceBrowser/DocumentDataSource";
+
+//------------------------------------------------------------------------
+
+SV_IMPL_PTRARR( XStatusListenerArr_Impl, XStatusListenerPtr );
+
+//------------------------------------------------------------------------
+
+uno::Reference<view::XSelectionSupplier> lcl_GetSelectionSupplier( SfxViewShell* pViewShell )
+{
+ if ( pViewShell )
+ {
+ SfxViewFrame* pViewFrame = pViewShell->GetViewFrame();
+ if (pViewFrame)
+ {
+ return uno::Reference<view::XSelectionSupplier>( pViewFrame->GetFrame().GetController(), uno::UNO_QUERY );
+ }
+ }
+ return uno::Reference<view::XSelectionSupplier>();
+}
+
+//------------------------------------------------------------------------
+
+
+ScDispatchProviderInterceptor::ScDispatchProviderInterceptor(ScTabViewShell* pViewSh) :
+ pViewShell( pViewSh )
+{
+ if ( pViewShell )
+ {
+ m_xIntercepted.set(uno::Reference<frame::XDispatchProviderInterception>(pViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY));
+ if (m_xIntercepted.is())
+ {
+ comphelper::increment( m_refCount );
+
+ m_xIntercepted->registerDispatchProviderInterceptor(
+ static_cast<frame::XDispatchProviderInterceptor*>(this));
+ // this should make us the top-level dispatch-provider for the component, via a call to our
+ // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill
+ uno::Reference<lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->addEventListener(static_cast<lang::XEventListener*>(this));
+
+ comphelper::decrement( m_refCount );
+ }
+
+ StartListening(*pViewShell);
+ }
+}
+
+ScDispatchProviderInterceptor::~ScDispatchProviderInterceptor()
+{
+ if (pViewShell)
+ EndListening(*pViewShell);
+}
+
+void ScDispatchProviderInterceptor::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pViewShell = NULL;
+}
+
+// XDispatchProvider
+
+uno::Reference<frame::XDispatch> SAL_CALL ScDispatchProviderInterceptor::queryDispatch(
+ const util::URL& aURL, const rtl::OUString& aTargetFrameName,
+ sal_Int32 nSearchFlags )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<frame::XDispatch> xResult;
+ // create some dispatch ...
+ if ( pViewShell && (
+ !aURL.Complete.compareToAscii(cURLInsertColumns) ||
+ !aURL.Complete.compareToAscii(cURLDocDataSource) ) )
+ {
+ if (!m_xMyDispatch.is())
+ m_xMyDispatch = new ScDispatch( pViewShell );
+ xResult = m_xMyDispatch;
+ }
+
+ // ask our slave provider
+ if (!xResult.is() && m_xSlaveDispatcher.is())
+ xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+
+ return xResult;
+}
+
+uno::Sequence< uno::Reference<frame::XDispatch> > SAL_CALL
+ ScDispatchProviderInterceptor::queryDispatches(
+ const uno::Sequence<frame::DispatchDescriptor>& aDescripts )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Sequence< uno::Reference< frame::XDispatch> > aReturn(aDescripts.getLength());
+ uno::Reference< frame::XDispatch>* pReturn = aReturn.getArray();
+ const frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
+ for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts)
+ {
+ *pReturn = queryDispatch(pDescripts->FeatureURL,
+ pDescripts->FrameName, pDescripts->SearchFlags);
+ }
+ return aReturn;
+}
+
+// XDispatchProviderInterceptor
+
+uno::Reference<frame::XDispatchProvider> SAL_CALL
+ ScDispatchProviderInterceptor::getSlaveDispatchProvider()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return m_xSlaveDispatcher;
+}
+
+void SAL_CALL ScDispatchProviderInterceptor::setSlaveDispatchProvider(
+ const uno::Reference<frame::XDispatchProvider>& xNewDispatchProvider )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ m_xSlaveDispatcher.set(xNewDispatchProvider);
+}
+
+uno::Reference<frame::XDispatchProvider> SAL_CALL
+ ScDispatchProviderInterceptor::getMasterDispatchProvider()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return m_xMasterDispatcher;
+}
+
+void SAL_CALL ScDispatchProviderInterceptor::setMasterDispatchProvider(
+ const uno::Reference<frame::XDispatchProvider>& xNewSupplier )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ m_xMasterDispatcher.set(xNewSupplier);
+}
+
+// XEventListener
+
+void SAL_CALL ScDispatchProviderInterceptor::disposing( const lang::EventObject& /* Source */ )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (m_xIntercepted.is())
+ {
+ m_xIntercepted->releaseDispatchProviderInterceptor(
+ static_cast<frame::XDispatchProviderInterceptor*>(this));
+ uno::Reference<lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->removeEventListener(static_cast<lang::XEventListener*>(this));
+
+ m_xMyDispatch = NULL;
+ }
+ m_xIntercepted = NULL;
+}
+
+//------------------------------------------------------------------------
+
+ScDispatch::ScDispatch(ScTabViewShell* pViewSh) :
+ pViewShell( pViewSh ),
+ bListeningToView( FALSE )
+{
+ if (pViewShell)
+ StartListening(*pViewShell);
+}
+
+ScDispatch::~ScDispatch()
+{
+ if (pViewShell)
+ EndListening(*pViewShell);
+
+ if (bListeningToView && pViewShell)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier(lcl_GetSelectionSupplier( pViewShell ));
+ if ( xSupplier.is() )
+ xSupplier->removeSelectionChangeListener(this);
+ }
+}
+
+void ScDispatch::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pViewShell = NULL;
+}
+
+// XDispatch
+
+void SAL_CALL ScDispatch::dispatch( const util::URL& aURL,
+ const uno::Sequence<beans::PropertyValue>& aArgs )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ BOOL bDone = FALSE;
+ if ( pViewShell && !aURL.Complete.compareToAscii(cURLInsertColumns) )
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScAddress aPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
+
+ ScDBDocFunc aFunc( *pViewData->GetDocShell() );
+ bDone = aFunc.DoImportUno( aPos, aArgs );
+ }
+ // cURLDocDataSource is never dispatched
+
+ if (!bDone)
+ throw uno::RuntimeException();
+}
+
+void lcl_FillDataSource( frame::FeatureStateEvent& rEvent, const ScImportParam& rParam )
+{
+ rEvent.IsEnabled = rParam.bImport;
+
+ ::svx::ODataAccessDescriptor aDescriptor;
+ if ( rParam.bImport )
+ {
+ sal_Int32 nType = rParam.bSql ? sdb::CommandType::COMMAND :
+ ( (rParam.nType == ScDbQuery) ? sdb::CommandType::QUERY :
+ sdb::CommandType::TABLE );
+
+ aDescriptor.setDataSource(rtl::OUString( rParam.aDBName ));
+ aDescriptor[svx::daCommand] <<= rtl::OUString( rParam.aStatement );
+ aDescriptor[svx::daCommandType] <<= nType;
+ }
+ else
+ {
+ // descriptor has to be complete anyway
+
+ rtl::OUString aEmpty;
+ aDescriptor[svx::daDataSource] <<= aEmpty;
+ aDescriptor[svx::daCommand] <<= aEmpty;
+ aDescriptor[svx::daCommandType] <<= (sal_Int32)sdb::CommandType::TABLE;
+ }
+ rEvent.State <<= aDescriptor.createPropertyValueSequence();
+}
+
+void SAL_CALL ScDispatch::addStatusListener(
+ const uno::Reference<frame::XStatusListener>& xListener,
+ const util::URL& aURL )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (!pViewShell)
+ throw uno::RuntimeException();
+
+ // initial state
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ aEvent.FeatureURL = aURL;
+
+ if ( !aURL.Complete.compareToAscii(cURLDocDataSource) )
+ {
+ uno::Reference<frame::XStatusListener>* pObj =
+ new uno::Reference<frame::XStatusListener>( xListener );
+ aDataSourceListeners.Insert( pObj, aDataSourceListeners.Count() );
+
+ if (!bListeningToView)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier(lcl_GetSelectionSupplier( pViewShell ));
+ if ( xSupplier.is() )
+ xSupplier->addSelectionChangeListener(this);
+ bListeningToView = sal_True;
+ }
+
+ ScDBData* pDBData = pViewShell->GetDBData(FALSE,SC_DB_OLD);
+ if ( pDBData )
+ pDBData->GetImportParam( aLastImport );
+ lcl_FillDataSource( aEvent, aLastImport ); // modifies State, IsEnabled
+ }
+ //! else add to listener for "enabled" changes?
+
+ xListener->statusChanged( aEvent );
+}
+
+void SAL_CALL ScDispatch::removeStatusListener(
+ const uno::Reference<frame::XStatusListener>& xListener,
+ const util::URL& aURL )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( !aURL.Complete.compareToAscii(cURLDocDataSource) )
+ {
+ USHORT nCount = aDataSourceListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<frame::XStatusListener> *pObj = aDataSourceListeners[n];
+ if ( *pObj == xListener )
+ {
+ aDataSourceListeners.DeleteAndDestroy( n );
+ break;
+ }
+ }
+
+ if ( aDataSourceListeners.Count() == 0 && pViewShell )
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier(lcl_GetSelectionSupplier( pViewShell ));
+ if ( xSupplier.is() )
+ xSupplier->removeSelectionChangeListener(this);
+ bListeningToView = sal_False;
+ }
+ }
+}
+
+// XSelectionChangeListener
+
+void SAL_CALL ScDispatch::selectionChanged( const ::com::sun::star::lang::EventObject& /* aEvent */ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ // currently only called for URL cURLDocDataSource
+
+ if ( pViewShell )
+ {
+ ScImportParam aNewImport;
+ ScDBData* pDBData = pViewShell->GetDBData(FALSE,SC_DB_OLD);
+ if ( pDBData )
+ pDBData->GetImportParam( aNewImport );
+
+ // notify listeners only if data source has changed
+ if ( aNewImport.bImport != aLastImport.bImport ||
+ aNewImport.aDBName != aLastImport.aDBName ||
+ aNewImport.aStatement != aLastImport.aStatement ||
+ aNewImport.bSql != aLastImport.bSql ||
+ aNewImport.nType != aLastImport.nType )
+ {
+ frame::FeatureStateEvent aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ aEvent.FeatureURL.Complete = rtl::OUString::createFromAscii( cURLDocDataSource );
+
+ lcl_FillDataSource( aEvent, aNewImport ); // modifies State, IsEnabled
+
+ for ( USHORT n=0; n<aDataSourceListeners.Count(); n++ )
+ (*aDataSourceListeners[n])->statusChanged( aEvent );
+
+ aLastImport = aNewImport;
+ }
+ }
+}
+
+// XEventListener
+
+void SAL_CALL ScDispatch::disposing( const ::com::sun::star::lang::EventObject& rSource )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Reference<view::XSelectionSupplier> xSupplier(rSource.Source, uno::UNO_QUERY);
+ xSupplier->removeSelectionChangeListener(this);
+ bListeningToView = sal_False;
+
+ lang::EventObject aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ for ( USHORT n=0; n<aDataSourceListeners.Count(); n++ )
+ (*aDataSourceListeners[n])->disposing( aEvent );
+
+ pViewShell = NULL;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
new file mode 100644
index 000000000000..c042f396dab8
--- /dev/null
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -0,0 +1,3726 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include <svx/fmdpage.hxx>
+#include <svx/fmview.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svxids.hrc>
+#include <svx/unoshape.hxx>
+
+#include <svl/numuno.hxx>
+#include <svl/smplhint.hxx>
+#include <unotools/undoopt.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/pdfextoutdevdata.hxx>
+#include <vcl/waitobj.hxx>
+#include <unotools/charclass.hxx>
+#include <tools/multisel.hxx>
+#include <tools/resary.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+
+#include <ctype.h>
+#include <float.h> // DBL_MAX
+
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XLabelRanges.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/reflection/XIdlClassProvider.hpp>
+#include <comphelper/processfactory.hxx>
+
+#include "docuno.hxx"
+#include "cellsuno.hxx"
+#include "nameuno.hxx"
+#include "datauno.hxx"
+#include "miscuno.hxx"
+#include "notesuno.hxx"
+#include "styleuno.hxx"
+#include "linkuno.hxx"
+#include "servuno.hxx"
+#include "targuno.hxx"
+#include "convuno.hxx"
+#include "optuno.hxx"
+#include "forbiuno.hxx"
+#include "docsh.hxx"
+#include "hints.hxx"
+#include "docfunc.hxx"
+#include "dociter.hxx"
+#include "cell.hxx"
+#include "drwlayer.hxx"
+#include "rangeutl.hxx"
+#include "markdata.hxx"
+#include "docoptio.hxx"
+#include "unonames.hxx"
+#include "shapeuno.hxx"
+#include "viewuno.hxx"
+#include "tabvwsh.hxx"
+#include "printfun.hxx"
+#include "pfuncache.hxx"
+#include "scmod.hxx"
+#include "rangeutl.hxx"
+#include "ViewSettingsSequenceDefines.hxx"
+#include "sheetevents.hxx"
+#include "sc.hrc"
+#include "scresid.hxx"
+
+using namespace com::sun::star;
+#define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ?
+
+//------------------------------------------------------------------------
+
+// alles ohne Which-ID, Map nur fuer PropertySetInfo
+
+//! umbenennen, sind nicht mehr nur Options
+const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap()
+{
+ static SfxItemPropertyMapEntry aDocOptPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_APPLYFMDES), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_AREALINKS), 0, &getCppuType((uno::Reference<sheet::XAreaLinks>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ), 0, &getCppuType((beans::PropertyValue*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_COLLABELRNG), 0, &getCppuType((uno::Reference<sheet::XLabelRanges>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_DDELINKS), 0, &getCppuType((uno::Reference<container::XNameAccess>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_DEFTABSTOP), PROP_UNO_DEFTABSTOP, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_EXTERNALDOCLINKS), 0, &getCppuType((uno::Reference<sheet::XExternalDocLinks>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_FORBIDDEN), 0, &getCppuType((uno::Reference<i18n::XForbiddenCharacters>*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_HASDRAWPAGES), 0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_IGNORECASE), PROP_UNO_IGNORECASE, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ITERENABLED), PROP_UNO_ITERENABLED, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ITERCOUNT), PROP_UNO_ITERCOUNT, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ITEREPSILON), PROP_UNO_ITEREPSILON, &getCppuType((double*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_MATCHWHOLE), PROP_UNO_MATCHWHOLE, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_NAMEDRANGES), 0, &getCppuType((uno::Reference<sheet::XNamedRanges>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_DATABASERNG), 0, &getCppuType((uno::Reference<sheet::XDatabaseRanges>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_NULLDATE), PROP_UNO_NULLDATE, &getCppuType((util::Date*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ROWLABELRNG), 0, &getCppuType((uno::Reference<sheet::XLabelRanges>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHEETLINKS), 0, &getCppuType((uno::Reference<container::XNameAccess>*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SPELLONLINE), PROP_UNO_SPELLONLINE, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), PROP_UNO_STANDARDDEC, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_RUNTIMEUID), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_HASVALIDSIGNATURES),0, &getBooleanCppuType(), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN(SC_UNO_ISLOADED), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ISUNDOENABLED), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ISADJUSTHEIGHTENABLED), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ISEXECUTELINKENABLED), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ISCHANGEREADONLYENABLED), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_REFERENCEDEVICE), 0, &getCppuType((uno::Reference<awt::XDevice>*)0), beans::PropertyAttribute::READONLY, 0},
+ {MAP_CHAR_LEN("BuildId"), 0, &::getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_CODENAME), 0, &getCppuType(static_cast< const rtl::OUString * >(0)), 0, 0},
+
+ {0,0,0,0,0,0}
+ };
+ return aDocOptPropertyMap_Impl;
+}
+
+//! StandardDecimals als Property und vom NumberFormatter ????????
+
+const SfxItemPropertyMapEntry* lcl_GetColumnsPropertyMap()
+{
+ static SfxItemPropertyMapEntry aColumnsPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_OWIDTH), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLWID), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aColumnsPropertyMap_Impl;
+}
+
+const SfxItemPropertyMapEntry* lcl_GetRowsPropertyMap()
+{
+ static SfxItemPropertyMapEntry aRowsPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHGT), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLFILT), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_OHEIGHT), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_MANPAGE), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_NEWPAGE), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVIS), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ // not sorted, not used with SfxItemPropertyMapEntry::GetByName
+ {0,0,0,0,0,0}
+ };
+ return aRowsPropertyMap_Impl;
+}
+
+//! move these functions to a header file
+inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
+inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
+
+//------------------------------------------------------------------------
+
+#define SCMODELOBJ_SERVICE "com.sun.star.sheet.SpreadsheetDocument"
+#define SCDOCSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetDocumentSettings"
+#define SCDOC_SERVICE "com.sun.star.document.OfficeDocument"
+
+SC_SIMPLE_SERVICE_INFO( ScAnnotationsObj, "ScAnnotationsObj", "com.sun.star.sheet.CellAnnotations" )
+SC_SIMPLE_SERVICE_INFO( ScDrawPagesObj, "ScDrawPagesObj", "com.sun.star.drawing.DrawPages" )
+SC_SIMPLE_SERVICE_INFO( ScScenariosObj, "ScScenariosObj", "com.sun.star.sheet.Scenarios" )
+SC_SIMPLE_SERVICE_INFO( ScSpreadsheetSettingsObj, "ScSpreadsheetSettingsObj", "com.sun.star.sheet.SpreadsheetDocumentSettings" )
+SC_SIMPLE_SERVICE_INFO( ScTableColumnsObj, "ScTableColumnsObj", "com.sun.star.table.TableColumns" )
+SC_SIMPLE_SERVICE_INFO( ScTableRowsObj, "ScTableRowsObj", "com.sun.star.table.TableRows" )
+SC_SIMPLE_SERVICE_INFO( ScTableSheetsObj, "ScTableSheetsObj", "com.sun.star.sheet.Spreadsheets" )
+
+//------------------------------------------------------------------------
+
+class ScPrintUIOptions : public vcl::PrinterOptionsHelper
+{
+public:
+ ScPrintUIOptions();
+ void SetDefaults();
+};
+
+ScPrintUIOptions::ScPrintUIOptions()
+{
+ const ScPrintOptions& rPrintOpt = SC_MOD()->GetPrintOptions();
+ sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1;
+ sal_Bool bSuppress = rPrintOpt.GetSkipEmpty();
+
+ ResStringArray aStrings( ScResId( SCSTR_PRINT_OPTIONS ) );
+ DBG_ASSERT( aStrings.Count() >= 19, "resource incomplete" );
+ if( aStrings.Count() < 19 ) // bad resource ?
+ return;
+
+ m_aUIProperties.realloc( 8 );
+
+ // create Section for spreadsheet (results in an extra tab page in dialog)
+ SvtModuleOptions aOpt;
+ String aAppGroupname( aStrings.GetString( 18 ) );
+ aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
+ aOpt.GetModuleName( SvtModuleOptions::E_SCALC ) );
+ m_aUIProperties[0].Value = getGroupControlOpt( aAppGroupname, rtl::OUString() );
+
+ // create subgroup for pages
+ m_aUIProperties[1].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 0 ) ), rtl::OUString() );
+
+ // create a bool option for empty pages
+ m_aUIProperties[2].Value = getBoolControlOpt( rtl::OUString( aStrings.GetString( 1 ) ),
+ rtl::OUString( aStrings.GetString( 2 ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsIncludeEmptyPages" ) ),
+ ! bSuppress
+ );
+ // create Subgroup for print content
+ vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
+ aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
+ m_aUIProperties[3].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 6 ) ),
+ rtl::OUString(),
+ aPrintRangeOpt
+ );
+
+ // create a choice for the content to create
+ uno::Sequence< rtl::OUString > aChoices( 3 ), aHelpTexts( 3 );
+ aChoices[0] = aStrings.GetString( 7 );
+ aHelpTexts[0] = aStrings.GetString( 8 );
+ aChoices[1] = aStrings.GetString( 9 );
+ aHelpTexts[1] = aStrings.GetString( 10 );
+ aChoices[2] = aStrings.GetString( 11 );
+ aHelpTexts[2] = aStrings.GetString( 12 );
+ m_aUIProperties[4].Value = getChoiceControlOpt( rtl::OUString(),
+ aHelpTexts,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ),
+ aChoices,
+ nContent );
+
+ // create Subgroup for print range
+ aPrintRangeOpt.mbInternalOnly = sal_True;
+ m_aUIProperties[5].Value = getSubgroupControlOpt( rtl::OUString( aStrings.GetString( 13 ) ),
+ rtl::OUString(),
+ aPrintRangeOpt
+ );
+
+ // create a choice for the range to print
+ rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
+ aChoices.realloc( 2 );
+ aHelpTexts.realloc( 2 );
+ aChoices[0] = aStrings.GetString( 14 );
+ aHelpTexts[0] = aStrings.GetString( 15 );
+ aChoices[1] = aStrings.GetString( 16 );
+ aHelpTexts[1] = aStrings.GetString( 17 );
+ m_aUIProperties[6].Value = getChoiceControlOpt( rtl::OUString(),
+ aHelpTexts,
+ aPrintRangeName,
+ aChoices,
+ 0 );
+
+ // create a an Edit dependent on "Pages" selected
+ vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True );
+ m_aUIProperties[7].Value = getEditControlOpt( rtl::OUString(),
+ rtl::OUString(),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ),
+ rtl::OUString(),
+ aPageRangeOpt
+ );
+}
+
+void ScPrintUIOptions::SetDefaults()
+{
+ // re-initialize the default values from print options
+
+ const ScPrintOptions& rPrintOpt = SC_MOD()->GetPrintOptions();
+ sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1;
+ sal_Bool bSuppress = rPrintOpt.GetSkipEmpty();
+
+ for (sal_Int32 nUIPos=0; nUIPos<m_aUIProperties.getLength(); ++nUIPos)
+ {
+ uno::Sequence<beans::PropertyValue> aUIProp;
+ if ( m_aUIProperties[nUIPos].Value >>= aUIProp )
+ {
+ for (sal_Int32 nPropPos=0; nPropPos<aUIProp.getLength(); ++nPropPos)
+ {
+ rtl::OUString aName = aUIProp[nPropPos].Name;
+ if ( aName.equalsAscii("Property") )
+ {
+ beans::PropertyValue aPropertyValue;
+ if ( aUIProp[nPropPos].Value >>= aPropertyValue )
+ {
+ if ( aPropertyValue.Name.equalsAscii( "PrintContent" ) )
+ {
+ aPropertyValue.Value <<= nContent;
+ aUIProp[nPropPos].Value <<= aPropertyValue;
+ }
+ else if ( aPropertyValue.Name.equalsAscii( "IsIncludeEmptyPages" ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aPropertyValue.Value, ! bSuppress );
+ aUIProp[nPropPos].Value <<= aPropertyValue;
+ }
+ }
+ }
+ }
+ m_aUIProperties[nUIPos].Value <<= aUIProp;
+ }
+ }
+}
+
+// static
+void ScModelObj::CreateAndSet(ScDocShell* pDocSh)
+{
+ if (pDocSh)
+ pDocSh->SetBaseModel( new ScModelObj(pDocSh) );
+}
+
+ScModelObj::ScModelObj( ScDocShell* pDocSh ) :
+ SfxBaseModel( pDocSh ),
+ aPropSet( lcl_GetDocOptPropertyMap() ),
+ pDocShell( pDocSh ),
+ pPrintFuncCache( NULL ),
+ pPrinterOptions( NULL ),
+ maChangesListeners( m_aMutex )
+{
+ // pDocShell may be NULL if this is the base of a ScDocOptionsObj
+ if ( pDocShell )
+ {
+ pDocShell->GetDocument()->AddUnoObject(*this); // SfxModel is derived from SfxListener
+ }
+}
+
+ScModelObj::~ScModelObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+
+ if (xNumberAgg.is())
+ xNumberAgg->setDelegator(uno::Reference<uno::XInterface>());
+
+ delete pPrintFuncCache;
+ delete pPrinterOptions;
+}
+
+uno::Reference< uno::XAggregation> ScModelObj::GetFormatter()
+{
+ // pDocShell may be NULL if this is the base of a ScDocOptionsObj
+ if ( !xNumberAgg.is() && pDocShell )
+ {
+ // setDelegator veraendert den RefCount, darum eine Referenz selber halten
+ // (direkt am m_refCount, um sich beim release nicht selbst zu loeschen)
+ comphelper::increment( m_refCount );
+ // waehrend des queryInterface braucht man ein Ref auf das
+ // SvNumberFormatsSupplierObj, sonst wird es geloescht.
+ uno::Reference<util::XNumberFormatsSupplier> xFormatter(new SvNumberFormatsSupplierObj(pDocShell->GetDocument()->GetFormatTable() ));
+ {
+ xNumberAgg.set(uno::Reference<uno::XAggregation>( xFormatter, uno::UNO_QUERY ));
+ // extra block to force deletion of the temporary before setDelegator
+ }
+
+ // beim setDelegator darf die zusaetzliche Ref nicht mehr existieren
+ xFormatter = NULL;
+
+ if (xNumberAgg.is())
+ xNumberAgg->setDelegator( (cppu::OWeakObject*)this );
+ comphelper::decrement( m_refCount );
+ } // if ( !xNumberAgg.is() )
+ return xNumberAgg;
+}
+
+ScDocument* ScModelObj::GetDocument() const
+{
+ if (pDocShell)
+ return pDocShell->GetDocument();
+ return NULL;
+}
+
+SfxObjectShell* ScModelObj::GetEmbeddedObject() const
+{
+ return pDocShell;
+}
+
+void ScModelObj::UpdateAllRowHeights(const ScMarkData* pTabMark)
+{
+ if (pDocShell)
+ pDocShell->UpdateAllRowHeights(pTabMark);
+}
+
+void ScModelObj::BeforeXMLLoading()
+{
+ if (pDocShell)
+ pDocShell->BeforeXMLLoading();
+}
+
+void ScModelObj::AfterXMLLoading(sal_Bool bRet)
+{
+ if (pDocShell)
+ pDocShell->AfterXMLLoading(bRet);
+}
+
+ScSheetSaveData* ScModelObj::GetSheetSaveData()
+{
+ if (pDocShell)
+ return pDocShell->GetSheetSaveData();
+ return NULL;
+}
+
+uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XSpreadsheetDocument )
+ SC_QUERYINTERFACE( document::XActionLockable )
+ SC_QUERYINTERFACE( sheet::XCalculatable )
+ SC_QUERYINTERFACE( util::XProtectable )
+ SC_QUERYINTERFACE( drawing::XDrawPagesSupplier )
+ SC_QUERYINTERFACE( sheet::XGoalSeek )
+ SC_QUERYINTERFACE( sheet::XConsolidatable )
+ SC_QUERYINTERFACE( sheet::XDocumentAuditing )
+ SC_QUERYINTERFACE( style::XStyleFamiliesSupplier )
+ SC_QUERYINTERFACE( view::XRenderable )
+ SC_QUERYINTERFACE( document::XLinkTargetSupplier )
+ SC_QUERYINTERFACE( beans::XPropertySet )
+ SC_QUERYINTERFACE( lang::XMultiServiceFactory )
+ SC_QUERYINTERFACE( lang::XServiceInfo )
+ SC_QUERYINTERFACE( util::XChangesNotifier )
+
+ uno::Any aRet(SfxBaseModel::queryInterface( rType ));
+ if ( !aRet.hasValue()
+ && rType != ::getCppuType((uno::Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0)
+ && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XController>*)0)
+ && rType != ::getCppuType((uno::Reference< com::sun::star::frame::XFrame>*)0)
+ && rType != ::getCppuType((uno::Reference< com::sun::star::script::XInvocation>*)0)
+ && rType != ::getCppuType((uno::Reference< com::sun::star::reflection::XIdlClassProvider>*)0)
+ && rType != ::getCppuType((uno::Reference< com::sun::star::beans::XFastPropertySet>*)0)
+ && rType != ::getCppuType((uno::Reference< com::sun::star::awt::XWindow>*)0))
+ {
+ GetFormatter();
+ if ( xNumberAgg.is() )
+ aRet = xNumberAgg->queryAggregation( rType );
+ }
+
+ return aRet;
+}
+
+void SAL_CALL ScModelObj::acquire() throw()
+{
+ SfxBaseModel::acquire();
+}
+
+void SAL_CALL ScModelObj::release() throw()
+{
+ SfxBaseModel::release();
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScModelObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(SfxBaseModel::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ uno::Sequence<uno::Type> aAggTypes;
+ if ( GetFormatter().is() )
+ {
+ const uno::Type& rProvType = ::getCppuType((uno::Reference<lang::XTypeProvider>*) 0);
+ uno::Any aNumProv(xNumberAgg->queryAggregation(rProvType));
+ if(aNumProv.getValueType() == rProvType)
+ {
+ uno::Reference<lang::XTypeProvider> xNumProv(
+ *(uno::Reference<lang::XTypeProvider>*)aNumProv.getValue());
+ aAggTypes = xNumProv->getTypes();
+ }
+ }
+ long nAggLen = aAggTypes.getLength();
+ const uno::Type* pAggPtr = aAggTypes.getConstArray();
+
+ const long nThisLen = 15;
+ aTypes.realloc( nParentLen + nAggLen + nThisLen );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetDocument>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<document::XActionLockable>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<sheet::XCalculatable>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<util::XProtectable>*)0);
+ pPtr[nParentLen + 4] = getCppuType((const uno::Reference<drawing::XDrawPagesSupplier>*)0);
+ pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XGoalSeek>*)0);
+ pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XConsolidatable>*)0);
+ pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XDocumentAuditing>*)0);
+ pPtr[nParentLen + 8] = getCppuType((const uno::Reference<style::XStyleFamiliesSupplier>*)0);
+ pPtr[nParentLen + 9] = getCppuType((const uno::Reference<view::XRenderable>*)0);
+ pPtr[nParentLen +10] = getCppuType((const uno::Reference<document::XLinkTargetSupplier>*)0);
+ pPtr[nParentLen +11] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
+ pPtr[nParentLen +12] = getCppuType((const uno::Reference<lang::XMultiServiceFactory>*)0);
+ pPtr[nParentLen +13] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
+ pPtr[nParentLen +14] = getCppuType((const uno::Reference<util::XChangesNotifier>*)0);
+
+ long i;
+ for (i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+
+ for (i=0; i<nAggLen; i++)
+ pPtr[nParentLen+nThisLen+i] = pAggPtr[i]; // aggregated types last
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScModelObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ // Not interested in reference update hints here
+
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // has become invalid
+ if (xNumberAgg.is())
+ {
+ SvNumberFormatsSupplierObj* pNumFmt =
+ SvNumberFormatsSupplierObj::getImplementation(
+ uno::Reference<util::XNumberFormatsSupplier>(xNumberAgg, uno::UNO_QUERY) );
+ if ( pNumFmt )
+ pNumFmt->SetNumberFormatter( NULL );
+ }
+
+ DELETEZ( pPrintFuncCache ); // must be deleted because it has a pointer to the DocShell
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ {
+ // cached data for rendering become invalid when contents change
+ // (if a broadcast is added to SetDrawModified, is has to be tested here, too)
+
+ DELETEZ( pPrintFuncCache );
+
+ // handle "OnCalculate" sheet events (search also for VBA event handlers)
+ if ( pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) )
+ HandleCalculateEvents();
+ }
+ }
+ else if ( rHint.ISA( ScPointerChangedHint ) )
+ {
+ USHORT nFlags = ((const ScPointerChangedHint&)rHint).GetFlags();
+ if (nFlags & SC_POINTERCHANGED_NUMFMT)
+ {
+ // NumberFormatter-Pointer am Uno-Objekt neu setzen
+
+ if (GetFormatter().is())
+ {
+ SvNumberFormatsSupplierObj* pNumFmt =
+ SvNumberFormatsSupplierObj::getImplementation(
+ uno::Reference<util::XNumberFormatsSupplier>(xNumberAgg, uno::UNO_QUERY) );
+ if ( pNumFmt && pDocShell )
+ pNumFmt->SetNumberFormatter( pDocShell->GetDocument()->GetFormatTable() );
+ }
+ }
+ }
+
+ // always call parent - SfxBaseModel might need to handle the same hints again
+ SfxBaseModel::Notify( rBC, rHint ); // SfxBaseModel is derived from SfxListener
+}
+
+// XSpreadsheetDocument
+
+uno::Reference<sheet::XSpreadsheets> SAL_CALL ScModelObj::getSheets() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScTableSheetsObj(pDocShell);
+ return NULL;
+}
+
+// XStyleFamiliesSupplier
+
+uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getStyleFamilies()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScStyleFamiliesObj(pDocShell);
+ return NULL;
+}
+
+// XRenderable
+
+OutputDevice* lcl_GetRenderDevice( const uno::Sequence<beans::PropertyValue>& rOptions )
+{
+ OutputDevice* pRet = NULL;
+ const beans::PropertyValue* pPropArray = rOptions.getConstArray();
+ long nPropCount = rOptions.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNONAME_RENDERDEV ))
+ {
+ uno::Reference<awt::XDevice> xRenderDevice(rProp.Value, uno::UNO_QUERY);
+ if ( xRenderDevice.is() )
+ {
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
+ if ( pDevice )
+ {
+ pRet = pDevice->GetOutputDevice();
+ pRet->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
+ }
+ }
+ }
+ }
+ return pRet;
+}
+
+bool lcl_ParseTarget( const String& rTarget, ScRange& rTargetRange, Rectangle& rTargetRect,
+ bool& rIsSheet, ScDocument* pDoc, SCTAB nSourceTab )
+{
+ // test in same order as in SID_CURRENTCELL execute
+
+ ScAddress aAddress;
+ ScRangeUtil aRangeUtil;
+ SCTAB nNameTab;
+ sal_Int32 nNumeric = 0;
+
+ bool bRangeValid = false;
+ bool bRectValid = false;
+
+ if ( rTargetRange.Parse( rTarget, pDoc ) & SCA_VALID )
+ {
+ bRangeValid = true; // range reference
+ }
+ else if ( aAddress.Parse( rTarget, pDoc ) & SCA_VALID )
+ {
+ rTargetRange = aAddress;
+ bRangeValid = true; // cell reference
+ }
+ else if ( aRangeUtil.MakeRangeFromName( rTarget, pDoc, nSourceTab, rTargetRange, RUTL_NAMES ) ||
+ aRangeUtil.MakeRangeFromName( rTarget, pDoc, nSourceTab, rTargetRange, RUTL_DBASE ) )
+ {
+ bRangeValid = true; // named range or database range
+ }
+ else if ( ByteString( rTarget, RTL_TEXTENCODING_ASCII_US ).IsNumericAscii() &&
+ ( nNumeric = rTarget.ToInt32() ) > 0 && nNumeric <= MAXROW+1 )
+ {
+ // row number is always mapped to cell A(row) on the same sheet
+ rTargetRange = ScAddress( 0, (SCROW)(nNumeric-1), nSourceTab ); // target row number is 1-based
+ bRangeValid = true; // row number
+ }
+ else if ( pDoc->GetTable( rTarget, nNameTab ) )
+ {
+ rTargetRange = ScAddress(0,0,nNameTab);
+ bRangeValid = true; // sheet name
+ rIsSheet = true; // needs special handling (first page of the sheet)
+ }
+ else
+ {
+ // look for named drawing object
+
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if ( pDrawLayer )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount && !bRangeValid; i++)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
+ DBG_ASSERT(pPage,"Page ?");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !bRangeValid)
+ {
+ if ( ScDrawLayer::GetVisibleName( pObject ) == rTarget )
+ {
+ rTargetRect = pObject->GetLogicRect(); // 1/100th mm
+ rTargetRange = pDoc->GetRange( i, rTargetRect ); // underlying cells
+ bRangeValid = bRectValid = true; // rectangle is valid
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+ }
+ if ( bRangeValid && !bRectValid )
+ {
+ // get rectangle for cell range
+ rTargetRect = pDoc->GetMMRect( rTargetRange.aStart.Col(), rTargetRange.aStart.Row(),
+ rTargetRange.aEnd.Col(), rTargetRange.aEnd.Row(),
+ rTargetRange.aStart.Tab() );
+ }
+
+ return bRangeValid;
+}
+
+BOOL ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
+ const uno::Sequence< beans::PropertyValue >& rOptions,
+ ScMarkData& rMark,
+ ScPrintSelectionStatus& rStatus, String& rPagesStr ) const
+{
+ DBG_ASSERT( !rMark.IsMarked() && !rMark.IsMultiMarked(), "FillRenderMarkData: MarkData must be empty" );
+ DBG_ASSERT( pDocShell, "FillRenderMarkData: DocShell must be set" );
+
+ BOOL bDone = FALSE;
+
+ uno::Reference<frame::XController> xView;
+
+ // defaults when no options are passed: all sheets, include empty pages
+ sal_Bool bSelectedSheetsOnly = sal_False;
+ sal_Bool bIncludeEmptyPages = sal_True;
+
+ bool bHasPrintContent = false;
+ sal_Int32 nPrintContent = 0; // all sheets / selected sheets / selected cells
+ sal_Int32 nPrintRange = 0; // all pages / pages
+ rtl::OUString aPageRange; // "pages" edit value
+
+ for( sal_Int32 i = 0, nLen = rOptions.getLength(); i < nLen; i++ )
+ {
+ if( rOptions[i].Name.equalsAscii( "IsOnlySelectedSheets" ) )
+ {
+ rOptions[i].Value >>= bSelectedSheetsOnly;
+ }
+ else if( rOptions[i].Name.equalsAscii( "IsIncludeEmptyPages" ) )
+ {
+ rOptions[i].Value >>= bIncludeEmptyPages;
+ }
+ else if( rOptions[i].Name.equalsAscii( "PageRange" ) )
+ {
+ rOptions[i].Value >>= aPageRange;
+ }
+ else if( rOptions[i].Name.equalsAscii( "PrintRange" ) )
+ {
+ rOptions[i].Value >>= nPrintRange;
+ }
+ else if( rOptions[i].Name.equalsAscii( "PrintContent" ) )
+ {
+ bHasPrintContent = true;
+ rOptions[i].Value >>= nPrintContent;
+ }
+ else if( rOptions[i].Name.equalsAscii( "View" ) )
+ {
+ rOptions[i].Value >>= xView;
+ }
+ }
+
+ // "Print Content" selection wins over "Selected Sheets" option
+ if ( bHasPrintContent )
+ bSelectedSheetsOnly = ( nPrintContent != 0 );
+
+ uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
+ if ( xInterface.is() )
+ {
+ ScCellRangesBase* pSelObj = ScCellRangesBase::getImplementation( xInterface );
+ uno::Reference< drawing::XShapes > xShapes( xInterface, uno::UNO_QUERY );
+ if ( pSelObj && pSelObj->GetDocShell() == pDocShell )
+ {
+ BOOL bSheet = ( ScTableSheetObj::getImplementation( xInterface ) != NULL );
+ BOOL bCursor = pSelObj->IsCursorOnly();
+ const ScRangeList& rRanges = pSelObj->GetRangeList();
+
+ rMark.MarkFromRangeList( rRanges, FALSE );
+ rMark.MarkToSimple();
+
+ if ( rMark.IsMultiMarked() )
+ {
+ // #i115266# copy behavior of old printing:
+ // treat multiple selection like a single selection with the enclosing range
+ ScRange aMultiMarkArea;
+ rMark.GetMultiMarkArea( aMultiMarkArea );
+ rMark.ResetMark();
+ rMark.SetMarkArea( aMultiMarkArea );
+ }
+
+ if ( rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ // a sheet object is treated like an empty selection: print the used area of the sheet
+
+ if ( bCursor || bSheet ) // nothing selected -> use whole tables
+ {
+ rMark.ResetMark(); // doesn't change table selection
+ rStatus.SetMode( SC_PRINTSEL_CURSOR );
+ }
+ else
+ rStatus.SetMode( SC_PRINTSEL_RANGE );
+
+ rStatus.SetRanges( rRanges );
+ bDone = TRUE;
+ }
+ // multi selection isn't supported
+ }
+ else if( xShapes.is() )
+ {
+ //print a selected ole object
+ uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY );
+ if( xIndexAccess.is() )
+ {
+ // multi selection isn't supported yet
+ uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY );
+ SvxShape* pShape = SvxShape::getImplementation( xShape );
+ if( pShape )
+ {
+ SdrObject *pSdrObj = pShape->GetSdrObject();
+ if( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if( pDoc && pSdrObj )
+ {
+ Rectangle aObjRect = pSdrObj->GetCurrentBoundRect();
+ SCTAB nCurrentTab = ScDocShell::GetCurTab();
+ ScRange aRange = pDoc->GetRange( nCurrentTab, aObjRect );
+ rMark.SetMarkArea( aRange );
+
+ if( rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ rStatus.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
+ bDone = TRUE;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( ScModelObj::getImplementation( xInterface ) == this )
+ {
+ // render the whole document
+ // -> no selection, all sheets
+
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
+ for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+ rMark.SelectTable( nTab, TRUE );
+ rStatus.SetMode( SC_PRINTSEL_DOCUMENT );
+ bDone = TRUE;
+ }
+ // other selection types aren't supported
+ }
+
+ // restrict to selected sheets if a view is available
+ if ( bSelectedSheetsOnly && xView.is() )
+ {
+ ScTabViewObj* pViewObj = ScTabViewObj::getImplementation( xView );
+ if (pViewObj)
+ {
+ ScTabViewShell* pViewSh = pViewObj->GetViewShell();
+ if (pViewSh)
+ {
+ const ScMarkData& rViewMark = pViewSh->GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
+ for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+ if (!rViewMark.GetTableSelect(nTab))
+ rMark.SelectTable( nTab, FALSE );
+ }
+ }
+ }
+
+ ScPrintOptions aNewOptions;
+ aNewOptions.SetSkipEmpty( !bIncludeEmptyPages );
+ aNewOptions.SetAllSheets( !bSelectedSheetsOnly );
+ rStatus.SetOptions( aNewOptions );
+
+ // "PrintRange" enables (1) or disables (0) the "PageRange" edit
+ if ( nPrintRange == 1 )
+ rPagesStr = aPageRange;
+ else
+ rPagesStr.Erase();
+
+ return bDone;
+}
+
+
+sal_Int32 SAL_CALL ScModelObj::getRendererCount( const uno::Any& aSelection,
+ const uno::Sequence<beans::PropertyValue>& rOptions )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScMarkData aMark;
+ ScPrintSelectionStatus aStatus;
+ String aPagesStr;
+ if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) )
+ return 0;
+
+ // The same ScPrintFuncCache object in pPrintFuncCache is used as long as
+ // the same selection is used (aStatus) and the document isn't changed
+ // (pPrintFuncCache is cleared in Notify handler)
+
+ if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
+ {
+ delete pPrintFuncCache;
+ pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
+ }
+ sal_Int32 nPages = pPrintFuncCache->GetPageCount();
+
+ sal_Int32 nSelectCount = nPages;
+ if ( aPagesStr.Len() )
+ {
+ MultiSelection aPageRanges( aPagesStr );
+ aPageRanges.SetTotalRange( Range( 1, nPages ) );
+ nSelectCount = aPageRanges.GetSelectCount();
+ }
+ return nSelectCount;
+}
+
+sal_Int32 lcl_GetRendererNum( sal_Int32 nSelRenderer, const String& rPagesStr, sal_Int32 nTotalPages )
+{
+ if ( !rPagesStr.Len() )
+ return nSelRenderer;
+
+ MultiSelection aPageRanges( rPagesStr );
+ aPageRanges.SetTotalRange( Range( 1, nTotalPages ) );
+
+ sal_Int32 nSelected = aPageRanges.FirstSelected();
+ while ( nSelRenderer > 0 )
+ {
+ nSelected = aPageRanges.NextSelected();
+ --nSelRenderer;
+ }
+ return nSelected - 1; // selection is 1-based
+}
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 nSelRenderer,
+ const uno::Any& aSelection, const uno::Sequence<beans::PropertyValue>& rOptions )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScMarkData aMark;
+ ScPrintSelectionStatus aStatus;
+ String aPagesStr;
+ // #i115266# if FillRenderMarkData fails, keep nTotalPages at 0, but still handle getRenderer(0) below
+ long nTotalPages = 0;
+ if ( FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) )
+ {
+ if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
+ {
+ delete pPrintFuncCache;
+ pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
+ }
+ nTotalPages = pPrintFuncCache->GetPageCount();
+ }
+ sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );
+ if ( nRenderer >= nTotalPages )
+ {
+ if ( nSelRenderer == 0 )
+ {
+ // getRenderer(0) is used to query the settings, so it must always return something
+
+ SCTAB nCurTab = 0; //! use current sheet from view?
+ ScPrintFunc aDefaultFunc( pDocShell, pDocShell->GetPrinter(), nCurTab );
+ Size aTwips = aDefaultFunc.GetPageSize();
+ awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) );
+
+ uno::Sequence<beans::PropertyValue> aSequence(1);
+ beans::PropertyValue* pArray = aSequence.getArray();
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_PAGESIZE );
+ pArray[0].Value <<= aPageSize;
+
+ if( ! pPrinterOptions )
+ pPrinterOptions = new ScPrintUIOptions;
+ else
+ pPrinterOptions->SetDefaults();
+ pPrinterOptions->appendPrintUIOptions( aSequence );
+ return aSequence;
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+
+ // printer is used as device (just for page layout), draw view is not needed
+
+ SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer );
+
+ ScRange aRange;
+ const ScRange* pSelRange = NULL;
+ if ( aMark.IsMarked() )
+ {
+ aMark.GetMarkArea( aRange );
+ pSelRange = &aRange;
+ }
+ ScPrintFunc aFunc( pDocShell, pDocShell->GetPrinter(), nTab,
+ pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() );
+ aFunc.SetRenderFlag( TRUE );
+
+ Range aPageRange( nRenderer+1, nRenderer+1 );
+ MultiSelection aPage( aPageRange );
+ aPage.SetTotalRange( Range(0,RANGE_MAX) );
+ aPage.Select( aPageRange );
+
+ long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab );
+ long nTabStart = pPrintFuncCache->GetTabStart( nTab );
+
+ (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, FALSE, NULL, NULL );
+
+ ScRange aCellRange;
+ BOOL bWasCellRange = aFunc.GetLastSourceRange( aCellRange );
+ Size aTwips = aFunc.GetPageSize();
+ awt::Size aPageSize( TwipsToHMM( aTwips.Width() ), TwipsToHMM( aTwips.Height() ) );
+
+ long nPropCount = bWasCellRange ? 3 : 2;
+ uno::Sequence<beans::PropertyValue> aSequence(nPropCount);
+ beans::PropertyValue* pArray = aSequence.getArray();
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_PAGESIZE );
+ pArray[0].Value <<= aPageSize;
+ // #i111158# all positions are relative to the whole page, including non-printable area
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_INC_NP_AREA );
+ pArray[1].Value = uno::makeAny( sal_True );
+ if ( bWasCellRange )
+ {
+ table::CellRangeAddress aRangeAddress( nTab,
+ aCellRange.aStart.Col(), aCellRange.aStart.Row(),
+ aCellRange.aEnd.Col(), aCellRange.aEnd.Row() );
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_SOURCERANGE );
+ pArray[2].Value <<= aRangeAddress;
+ }
+
+ // FIXME: is this for side effects ?
+ SC_MOD()->GetPrintOptions();
+ if( ! pPrinterOptions )
+ pPrinterOptions = new ScPrintUIOptions;
+ else
+ pPrinterOptions->SetDefaults();
+ pPrinterOptions->appendPrintUIOptions( aSequence );
+ return aSequence;
+}
+
+void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelection,
+ const uno::Sequence<beans::PropertyValue>& rOptions )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScMarkData aMark;
+ ScPrintSelectionStatus aStatus;
+ String aPagesStr;
+ if ( !FillRenderMarkData( aSelection, rOptions, aMark, aStatus, aPagesStr ) )
+ throw lang::IllegalArgumentException();
+
+ if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
+ {
+ delete pPrintFuncCache;
+ pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
+ }
+ long nTotalPages = pPrintFuncCache->GetPageCount();
+ sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );
+ if ( nRenderer >= nTotalPages )
+ throw lang::IllegalArgumentException();
+
+ OutputDevice* pDev = lcl_GetRenderDevice( rOptions );
+ if ( !pDev )
+ throw lang::IllegalArgumentException();
+
+ SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer );
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ FmFormView* pDrawView = NULL;
+ Rectangle aFull( 0, 0, LONG_MAX, LONG_MAX );
+
+ // #114135#
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+
+ if( pModel )
+ {
+ pDrawView = new FmFormView( pModel, pDev );
+ pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
+ pDrawView->SetPrintPreview( TRUE );
+ }
+
+ ScRange aRange;
+ const ScRange* pSelRange = NULL;
+ if ( aMark.IsMarked() )
+ {
+ aMark.GetMarkArea( aRange );
+ pSelRange = &aRange;
+ }
+
+ // to increase performance, ScPrintState might be used here for subsequent
+ // pages of the same sheet
+
+ ScPrintFunc aFunc( pDev, pDocShell, nTab, pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions() );
+ aFunc.SetDrawView( pDrawView );
+ aFunc.SetRenderFlag( TRUE );
+ if( aStatus.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS )
+ aFunc.SetExclusivelyDrawOleAndDrawObjects();
+
+ Range aPageRange( nRenderer+1, nRenderer+1 );
+ MultiSelection aPage( aPageRange );
+ aPage.SetTotalRange( Range(0,RANGE_MAX) );
+ aPage.Select( aPageRange );
+
+ long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab );
+ long nTabStart = pPrintFuncCache->GetTabStart( nTab );
+
+ vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
+ if ( nRenderer == nTabStart )
+ {
+ // first page of a sheet: add outline item for the sheet name
+
+ if ( pPDFData && pPDFData->GetIsExportBookmarks() )
+ {
+ // the sheet starts at the top of the page
+ Rectangle aArea( pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
+ sal_Int32 nDestID = pPDFData->CreateDest( aArea );
+ String aTabName;
+ pDoc->GetName( nTab, aTabName );
+ sal_Int32 nParent = -1; // top-level
+ pPDFData->CreateOutlineItem( nParent, aTabName, nDestID );
+ }
+ //--->i56629
+ // add the named destination stuff
+ if( pPDFData && pPDFData->GetIsExportNamedDestinations() )
+ {
+ Rectangle aArea( pDev->PixelToLogic( Rectangle( 0,0,0,0 ) ) );
+ String aTabName;
+ pDoc->GetName( nTab, aTabName );
+//need the PDF page number here
+ pPDFData->CreateNamedDest( aTabName, aArea );
+ }
+ //<---i56629
+ }
+
+ (void)aFunc.DoPrint( aPage, nTabStart, nDisplayStart, TRUE, NULL, NULL );
+
+ // resolve the hyperlinks for PDF export
+
+ if ( pPDFData )
+ {
+ // iterate over the hyperlinks that were output for this page
+
+ std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->GetBookmarks();
+ std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIter = rBookmarks.begin();
+ std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
+ while ( aIter != aIEnd )
+ {
+ rtl::OUString aBookmark = aIter->aBookmark;
+ if ( aBookmark.toChar() == (sal_Unicode) '#' )
+ {
+ // try to resolve internal link
+
+ String aTarget( aBookmark.copy( 1 ) );
+
+ ScRange aTargetRange;
+ Rectangle aTargetRect; // 1/100th mm
+ bool bIsSheet = false;
+ bool bValid = lcl_ParseTarget( aTarget, aTargetRange, aTargetRect, bIsSheet, pDoc, nTab );
+
+ if ( bValid )
+ {
+ sal_Int32 nPage = -1;
+ Rectangle aArea;
+ if ( bIsSheet )
+ {
+ // Get first page for sheet (if nothing from that sheet is printed,
+ // this page can show a different sheet)
+ nPage = pPrintFuncCache->GetTabStart( aTargetRange.aStart.Tab() );
+ aArea = pDev->PixelToLogic( Rectangle( 0,0,0,0 ) );
+ }
+ else
+ {
+ pPrintFuncCache->InitLocations( aMark, pDev ); // does nothing if already initialized
+
+ ScPrintPageLocation aLocation;
+ if ( pPrintFuncCache->FindLocation( aTargetRange.aStart, aLocation ) )
+ {
+ nPage = aLocation.nPage;
+
+ // get the rectangle of the page's cell range in 1/100th mm
+ ScRange aLocRange = aLocation.aCellRange;
+ Rectangle aLocationMM = pDoc->GetMMRect(
+ aLocRange.aStart.Col(), aLocRange.aStart.Row(),
+ aLocRange.aEnd.Col(), aLocRange.aEnd.Row(),
+ aLocRange.aStart.Tab() );
+ Rectangle aLocationPixel = aLocation.aRectangle;
+
+ // Scale and move the target rectangle from aLocationMM to aLocationPixel,
+ // to get the target rectangle in pixels.
+
+ Fraction aScaleX( aLocationPixel.GetWidth(), aLocationMM.GetWidth() );
+ Fraction aScaleY( aLocationPixel.GetHeight(), aLocationMM.GetHeight() );
+
+ long nX1 = aLocationPixel.Left() + (long)
+ ( Fraction( aTargetRect.Left() - aLocationMM.Left(), 1 ) * aScaleX );
+ long nX2 = aLocationPixel.Left() + (long)
+ ( Fraction( aTargetRect.Right() - aLocationMM.Left(), 1 ) * aScaleX );
+ long nY1 = aLocationPixel.Top() + (long)
+ ( Fraction( aTargetRect.Top() - aLocationMM.Top(), 1 ) * aScaleY );
+ long nY2 = aLocationPixel.Top() + (long)
+ ( Fraction( aTargetRect.Bottom() - aLocationMM.Top(), 1 ) * aScaleY );
+
+ if ( nX1 > aLocationPixel.Right() ) nX1 = aLocationPixel.Right();
+ if ( nX2 > aLocationPixel.Right() ) nX2 = aLocationPixel.Right();
+ if ( nY1 > aLocationPixel.Bottom() ) nY1 = aLocationPixel.Bottom();
+ if ( nY2 > aLocationPixel.Bottom() ) nY2 = aLocationPixel.Bottom();
+
+ // The link target area is interpreted using the device's MapMode at
+ // the time of the CreateDest call, so PixelToLogic can be used here,
+ // regardless of the MapMode that is actually selected.
+
+ aArea = pDev->PixelToLogic( Rectangle( nX1, nY1, nX2, nY2 ) );
+ }
+ }
+
+ if ( nPage >= 0 )
+ pPDFData->SetLinkDest( aIter->nLinkId, pPDFData->CreateDest( aArea, nPage ) );
+ }
+ }
+ else
+ {
+ // external link, use as-is
+ pPDFData->SetLinkURL( aIter->nLinkId, aBookmark );
+ }
+ aIter++;
+ }
+ rBookmarks.clear();
+ }
+
+ delete pDrawView;
+}
+
+// XLinkTargetSupplier
+
+uno::Reference<container::XNameAccess> SAL_CALL ScModelObj::getLinks() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScLinkTargetTypesObj(pDocShell);
+ return NULL;
+}
+
+// XActionLockable
+
+sal_Bool SAL_CALL ScModelObj::isActionLocked() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bLocked = FALSE;
+ if (pDocShell)
+ bLocked = ( pDocShell->GetLockCount() != 0 );
+ return bLocked;
+}
+
+void SAL_CALL ScModelObj::addActionLock() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ pDocShell->LockDocument();
+}
+
+void SAL_CALL ScModelObj::removeActionLock() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ pDocShell->UnlockDocument();
+}
+
+void SAL_CALL ScModelObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ pDocShell->SetLockCount(nLock);
+}
+
+sal_Int16 SAL_CALL ScModelObj::resetActionLocks() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nRet = 0;
+ if (pDocShell)
+ {
+ nRet = pDocShell->GetLockCount();
+ pDocShell->SetLockCount(0);
+ }
+ return nRet;
+}
+
+void SAL_CALL ScModelObj::lockControllers() throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxBaseModel::lockControllers();
+ if (pDocShell)
+ pDocShell->LockPaint();
+}
+
+void SAL_CALL ScModelObj::unlockControllers() throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (hasControllersLocked())
+ {
+ SfxBaseModel::unlockControllers();
+ if (pDocShell)
+ pDocShell->UnlockPaint();
+ }
+}
+
+// XCalculate
+
+void SAL_CALL ScModelObj::calculate() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ pDocShell->DoRecalc(TRUE);
+ else
+ {
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ }
+}
+
+void SAL_CALL ScModelObj::calculateAll() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ pDocShell->DoHardRecalc(TRUE);
+ else
+ {
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ }
+}
+
+sal_Bool SAL_CALL ScModelObj::isAutomaticCalculationEnabled() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return pDocShell->GetDocument()->GetAutoCalc();
+
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ return FALSE;
+}
+
+void SAL_CALL ScModelObj::enableAutomaticCalculation( sal_Bool bEnabled )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( pDoc->GetAutoCalc() != bEnabled )
+ {
+ pDoc->SetAutoCalc( bEnabled );
+ pDocShell->SetDocumentModified();
+ }
+ }
+ else
+ {
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ }
+}
+
+// XProtectable
+
+void SAL_CALL ScModelObj::protect( const rtl::OUString& aPassword ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // #i108245# if already protected, don't change anything
+ if ( pDocShell && !pDocShell->GetDocument()->IsDocProtected() )
+ {
+ String aString(aPassword);
+
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.Protect( TABLEID_DOC, aString, TRUE );
+ }
+}
+
+void SAL_CALL ScModelObj::unprotect( const rtl::OUString& aPassword )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ String aString(aPassword);
+
+ ScDocFunc aFunc(*pDocShell);
+ BOOL bDone = aFunc.Unprotect( TABLEID_DOC, aString, TRUE );
+ if (!bDone)
+ throw lang::IllegalArgumentException();
+ }
+}
+
+sal_Bool SAL_CALL ScModelObj::isProtected() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return pDocShell->GetDocument()->IsDocProtected();
+
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ return FALSE;
+}
+
+// XDrawPagesSupplier
+
+uno::Reference<drawing::XDrawPages> SAL_CALL ScModelObj::getDrawPages() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScDrawPagesObj(pDocShell);
+
+ DBG_ERROR("keine DocShell"); //! Exception oder so?
+ return NULL;
+}
+
+// XGoalSeek
+
+sheet::GoalResult SAL_CALL ScModelObj::seekGoal(
+ const table::CellAddress& aFormulaPosition,
+ const table::CellAddress& aVariablePosition,
+ const ::rtl::OUString& aGoalValue )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sheet::GoalResult aResult;
+ aResult.Divergence = DBL_MAX; // nichts gefunden
+ if (pDocShell)
+ {
+ WaitObject aWait( pDocShell->GetActiveDialogParent() );
+ String aGoalString(aGoalValue);
+ ScDocument* pDoc = pDocShell->GetDocument();
+ double fValue = 0.0;
+ BOOL bFound = pDoc->Solver(
+ (SCCOL)aFormulaPosition.Column, (SCROW)aFormulaPosition.Row, aFormulaPosition.Sheet,
+ (SCCOL)aVariablePosition.Column, (SCROW)aVariablePosition.Row, aVariablePosition.Sheet,
+ aGoalString, fValue );
+ aResult.Result = fValue;
+ if (bFound)
+ aResult.Divergence = 0.0; //! das ist gelogen
+ }
+ return aResult;
+}
+
+// XConsolidatable
+
+uno::Reference<sheet::XConsolidationDescriptor> SAL_CALL ScModelObj::createConsolidationDescriptor(
+ sal_Bool bEmpty ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScConsolidationDescriptor* pNew = new ScConsolidationDescriptor;
+ if ( pDocShell && !bEmpty )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ const ScConsolidateParam* pParam = pDoc->GetConsolidateDlgData();
+ if (pParam)
+ pNew->SetParam( *pParam );
+ }
+ return pNew;
+}
+
+void SAL_CALL ScModelObj::consolidate(
+ const uno::Reference<sheet::XConsolidationDescriptor>& xDescriptor )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // das koennte theoretisch ein fremdes Objekt sein, also nur das
+ // oeffentliche XConsolidationDescriptor Interface benutzen, um
+ // die Daten in ein ScConsolidationDescriptor Objekt zu kopieren:
+ //! wenn es schon ein ScConsolidationDescriptor ist, direkt per getImplementation?
+
+ ScConsolidationDescriptor aImpl;
+ aImpl.setFunction( xDescriptor->getFunction() );
+ aImpl.setSources( xDescriptor->getSources() );
+ aImpl.setStartOutputPosition( xDescriptor->getStartOutputPosition() );
+ aImpl.setUseColumnHeaders( xDescriptor->getUseColumnHeaders() );
+ aImpl.setUseRowHeaders( xDescriptor->getUseRowHeaders() );
+ aImpl.setInsertLinks( xDescriptor->getInsertLinks() );
+
+ if (pDocShell)
+ {
+ const ScConsolidateParam& rParam = aImpl.GetParam();
+ pDocShell->DoConsolidate( rParam, TRUE );
+ pDocShell->GetDocument()->SetConsolidateDlgData( &rParam );
+ }
+}
+
+// XDocumentAuditing
+
+void SAL_CALL ScModelObj::refreshArrows() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.DetectiveRefresh();
+ }
+}
+
+// XViewDataSupplier
+uno::Reference< container::XIndexAccess > SAL_CALL ScModelObj::getViewData( )
+ throw (uno::RuntimeException)
+{
+ uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() );
+
+ if( !xRet.is() )
+ {
+ SolarMutexGuard aGuard;
+ if (pDocShell && pDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
+ {
+ xRet.set(uno::Reference < container::XIndexAccess >::query(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.IndexedPropertyValues")))));
+
+ uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY );
+ DBG_ASSERT( xCont.is(), "ScModelObj::getViewData() failed for OLE object" );
+ if( xCont.is() )
+ {
+ uno::Sequence< beans::PropertyValue > aSeq;
+ aSeq.realloc(1);
+ String sName;
+ pDocShell->GetDocument()->GetName( pDocShell->GetDocument()->GetVisibleTab(), sName );
+ rtl::OUString sOUName(sName);
+ aSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE));
+ aSeq[0].Value <<= sOUName;
+ xCont->insertByIndex( 0, uno::makeAny( aSeq ) );
+ }
+ }
+ }
+
+ return xRet;
+}
+
+// XPropertySet (Doc-Optionen)
+//! auch an der Applikation anbieten?
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScModelObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScModelObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
+ ScDocOptions aNewOpt = rOldOpt;
+
+ BOOL bOpt = ScDocOptionsHelper::setPropertyValue( aNewOpt, *aPropSet.getPropertyMap(), aPropertyName, aValue );
+ if (bOpt)
+ {
+ // done...
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) )
+ {
+ lang::Locale aLocale;
+ if ( aValue >>= aLocale )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ eLatin = ScUnoConversion::GetLanguage(aLocale);
+ pDoc->SetLanguage( eLatin, eCjk, eCtl );
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_CODENAME ) )
+ {
+ rtl::OUString sCodeName;
+ if ( aValue >>= sCodeName )
+ pDoc->SetCodeName( sCodeName );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) )
+ {
+ lang::Locale aLocale;
+ if ( aValue >>= aLocale )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ eCjk = ScUnoConversion::GetLanguage(aLocale);
+ pDoc->SetLanguage( eLatin, eCjk, eCtl );
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_CTL_CLOCAL ) )
+ {
+ lang::Locale aLocale;
+ if ( aValue >>= aLocale )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ eCtl = ScUnoConversion::GetLanguage(aLocale);
+ pDoc->SetLanguage( eLatin, eCjk, eCtl );
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_APPLYFMDES ) )
+ {
+ // model is created if not there
+ ScDrawLayer* pModel = pDocShell->MakeDrawLayer();
+ pModel->SetOpenInDesignMode( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+
+ SfxBindings* pBindings = pDocShell->GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_FM_OPEN_READONLY );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_AUTOCONTFOC ) )
+ {
+ // model is created if not there
+ ScDrawLayer* pModel = pDocShell->MakeDrawLayer();
+ pModel->SetAutoControlFocus( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+
+ SfxBindings* pBindings = pDocShell->GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_FM_AUTOCONTROLFOCUS );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISLOADED ) )
+ {
+ pDocShell->SetEmpty( !ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISUNDOENABLED ) )
+ {
+ BOOL bUndoEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ pDoc->EnableUndo( bUndoEnabled );
+ USHORT nCount = ( bUndoEnabled ?
+ static_cast< USHORT >( SvtUndoOptions().GetUndoCount() ) : 0 );
+ pDocShell->GetUndoManager()->SetMaxUndoActionCount( nCount );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED ) )
+ {
+ bool bOldAdjustHeightEnabled = pDoc->IsAdjustHeightEnabled();
+ bool bAdjustHeightEnabled = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if( bOldAdjustHeightEnabled != bAdjustHeightEnabled )
+ {
+ pDoc->EnableAdjustHeight( bAdjustHeightEnabled );
+ if( bAdjustHeightEnabled )
+ pDocShell->UpdateAllRowHeights();
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) )
+ {
+ pDoc->EnableExecuteLink( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED ) )
+ {
+ pDoc->EnableChangeReadOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ }
+ else if ( aString.EqualsAscii( "BuildId" ) )
+ {
+ aValue >>= maBuildId;
+ }
+ else if ( aString.EqualsAscii( "SavedObject" ) ) // set from chart after saving
+ {
+ rtl::OUString aObjName;
+ aValue >>= aObjName;
+ if ( aObjName.getLength() )
+ pDoc->RestoreChartListener( aObjName );
+ }
+
+ if ( aNewOpt != rOldOpt )
+ {
+ pDoc->SetDocOptions( aNewOpt );
+ // Don't recalculate while loading XML, when the formula text is stored.
+ // Recalculation after loading is handled separately.
+ //! Recalc only for options that need it?
+ if ( !pDoc->IsImportingXML() )
+ pDocShell->DoHardRecalc( TRUE );
+ pDocShell->SetDocumentModified();
+ }
+ }
+}
+
+uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+ uno::Any aRet;
+
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ const ScDocOptions& rOpt = pDoc->GetDocOptions();
+ aRet = ScDocOptionsHelper::getPropertyValue( rOpt, *aPropSet.getPropertyMap(), aPropertyName );
+ if ( aRet.hasValue() )
+ {
+ // done...
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_CLOCAL ) )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+
+ lang::Locale aLocale;
+ ScUnoConversion::FillLocale( aLocale, eLatin );
+ aRet <<= aLocale;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_CODENAME ) )
+ {
+ rtl::OUString sCodeName = pDoc->GetCodeName();
+ aRet <<= sCodeName;
+ }
+
+ else if ( aString.EqualsAscii( SC_UNO_CJK_CLOCAL ) )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+
+ lang::Locale aLocale;
+ ScUnoConversion::FillLocale( aLocale, eCjk );
+ aRet <<= aLocale;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_CTL_CLOCAL ) )
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+
+ lang::Locale aLocale;
+ ScUnoConversion::FillLocale( aLocale, eCtl );
+ aRet <<= aLocale;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_NAMEDRANGES ) )
+ {
+ aRet <<= uno::Reference<sheet::XNamedRanges>(new ScNamedRangesObj( pDocShell ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_DATABASERNG ) )
+ {
+ aRet <<= uno::Reference<sheet::XDatabaseRanges>(new ScDatabaseRangesObj( pDocShell ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_COLLABELRNG ) )
+ {
+ aRet <<= uno::Reference<sheet::XLabelRanges>(new ScLabelRangesObj( pDocShell, TRUE ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ROWLABELRNG ) )
+ {
+ aRet <<= uno::Reference<sheet::XLabelRanges>(new ScLabelRangesObj( pDocShell, FALSE ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_AREALINKS ) )
+ {
+ aRet <<= uno::Reference<sheet::XAreaLinks>(new ScAreaLinksObj( pDocShell ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_DDELINKS ) )
+ {
+ aRet <<= uno::Reference<container::XNameAccess>(new ScDDELinksObj( pDocShell ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_EXTERNALDOCLINKS ) )
+ {
+ aRet <<= uno::Reference<sheet::XExternalDocLinks>(new ScExternalDocLinksObj(pDocShell));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_SHEETLINKS ) )
+ {
+ aRet <<= uno::Reference<container::XNameAccess>(new ScSheetLinksObj( pDocShell ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_APPLYFMDES ) )
+ {
+ // default for no model is TRUE
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ sal_Bool bOpenInDesign = pModel ? pModel->GetOpenInDesignMode() : sal_True;
+ ScUnoHelpFunctions::SetBoolInAny( aRet, bOpenInDesign );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_AUTOCONTFOC ) )
+ {
+ // default for no model is FALSE
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ sal_Bool bAutoControlFocus = pModel ? pModel->GetAutoControlFocus() : sal_False;
+ ScUnoHelpFunctions::SetBoolInAny( aRet, bAutoControlFocus );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_FORBIDDEN ) )
+ {
+ aRet <<= uno::Reference<i18n::XForbiddenCharacters>(new ScForbiddenCharsObj( pDocShell ));
+ }
+ else if ( aString.EqualsAscii( SC_UNO_HASDRAWPAGES ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetDocument()->GetDrawLayer() != 0) );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_BASICLIBRARIES ) )
+ {
+ aRet <<= pDocShell->GetBasicContainer();
+ }
+ else if ( aString.EqualsAscii( SC_UNO_DIALOGLIBRARIES ) )
+ {
+ aRet <<= pDocShell->GetDialogContainer();
+ }
+ else if ( aString.EqualsAscii( SC_UNO_VBADOCOBJ ) )
+ {
+ // PropertyValue seems extreme because we store
+ // the model ( as the value member ) of the PropertyValue that is
+ // itself a property of the model ( the intention however is to
+ // store something like a Workbook object... but we don't do that )
+ // yet
+ beans::PropertyValue aProp;
+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") );
+ aProp.Value <<= pDocShell->GetModel();
+ aRet <<= aProp;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) )
+ {
+ aRet <<= getRuntimeUID();
+ }
+ else if ( aString.EqualsAscii( SC_UNO_HASVALIDSIGNATURES ) )
+ {
+ aRet <<= hasValidSignatures();
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISLOADED ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, !pDocShell->IsEmpty() );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISUNDOENABLED ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsUndoEnabled() );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISADJUSTHEIGHTENABLED ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsAdjustHeightEnabled() );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISEXECUTELINKENABLED ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsExecuteLinkEnabled() );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ISCHANGEREADONLYENABLED ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, pDoc->IsChangeReadOnlyEnabled() );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_REFERENCEDEVICE ) )
+ {
+ VCLXDevice* pXDev = new VCLXDevice();
+ pXDev->SetOutputDevice( pDoc->GetRefDevice() );
+ aRet <<= uno::Reference< awt::XDevice >( pXDev );
+ }
+ else if ( aString.EqualsAscii( "BuildId" ) )
+ {
+ aRet <<= maBuildId;
+ }
+ else if ( aString.EqualsAscii( "InternalDocument" ) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny( aRet, (pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL) );
+ }
+ }
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScModelObj )
+
+// XMultiServiceFactory
+
+uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstance(
+ const rtl::OUString& aServiceSpecifier )
+ throw(uno::Exception, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<uno::XInterface> xRet;
+ String aNameStr(aServiceSpecifier);
+ USHORT nType = ScServiceProvider::GetProviderType(aNameStr);
+ if ( nType != SC_SERVICE_INVALID )
+ {
+ // drawing layer tables must be kept as long as the model is alive
+ // return stored instance if already set
+ switch ( nType )
+ {
+ case SC_SERVICE_GRADTAB: xRet.set(xDrawGradTab); break;
+ case SC_SERVICE_HATCHTAB: xRet.set(xDrawHatchTab); break;
+ case SC_SERVICE_BITMAPTAB: xRet.set(xDrawBitmapTab); break;
+ case SC_SERVICE_TRGRADTAB: xRet.set(xDrawTrGradTab); break;
+ case SC_SERVICE_MARKERTAB: xRet.set(xDrawMarkerTab); break;
+ case SC_SERVICE_DASHTAB: xRet.set(xDrawDashTab); break;
+ case SC_SERVICE_CHDATAPROV: xRet.set(xChartDataProv); break;
+ }
+
+ // #i64497# If a chart is in a temporary document during clipoard paste,
+ // there should be no data provider, so that own data is used
+ bool bCreate =
+ ! ( nType == SC_SERVICE_CHDATAPROV &&
+ ( pDocShell->GetCreateMode() == SFX_CREATE_MODE_INTERNAL ));
+ // this should never happen, i.e. the temporary document should never be
+ // loaded, becuase this unlinks the data
+ OSL_ASSERT( bCreate );
+
+ if ( !xRet.is() && bCreate )
+ {
+ xRet.set(ScServiceProvider::MakeInstance( nType, pDocShell ));
+
+ // store created instance
+ switch ( nType )
+ {
+ case SC_SERVICE_GRADTAB: xDrawGradTab.set(xRet); break;
+ case SC_SERVICE_HATCHTAB: xDrawHatchTab.set(xRet); break;
+ case SC_SERVICE_BITMAPTAB: xDrawBitmapTab.set(xRet); break;
+ case SC_SERVICE_TRGRADTAB: xDrawTrGradTab.set(xRet); break;
+ case SC_SERVICE_MARKERTAB: xDrawMarkerTab.set(xRet); break;
+ case SC_SERVICE_DASHTAB: xDrawDashTab.set(xRet); break;
+ case SC_SERVICE_CHDATAPROV: xChartDataProv.set(xRet); break;
+ }
+ }
+ }
+ else
+ {
+ // alles was ich nicht kenn, werf ich der SvxFmMSFactory an den Hals,
+ // da wird dann 'ne Exception geworfen, wenn's nicht passt...
+
+ try
+ {
+ xRet.set(SvxFmMSFactory::createInstance(aServiceSpecifier));
+ // extra block to force deletion of the temporary before ScShapeObj ctor (setDelegator)
+ }
+ catch ( lang::ServiceNotRegisteredException & )
+ {
+ }
+
+ // #96117# if the drawing factory created a shape, a ScShapeObj has to be used
+ // to support own properties like ImageMap:
+
+ uno::Reference<drawing::XShape> xShape( xRet, uno::UNO_QUERY );
+ if ( xShape.is() )
+ {
+ xRet.clear(); // for aggregation, xShape must be the object's only ref
+ new ScShapeObj( xShape ); // aggregates object and modifies xShape
+ xRet.set(xShape);
+ }
+ }
+ return xRet;
+}
+
+uno::Reference<uno::XInterface> SAL_CALL ScModelObj::createInstanceWithArguments(
+ const rtl::OUString& ServiceSpecifier,
+ const uno::Sequence<uno::Any>& aArgs )
+ throw(uno::Exception, uno::RuntimeException)
+{
+ //! unterscheiden zwischen eigenen Services und denen vom Drawing-Layer?
+
+ SolarMutexGuard aGuard;
+ uno::Reference<uno::XInterface> xInt(createInstance(ServiceSpecifier));
+
+ if ( aArgs.getLength() )
+ {
+ // used only for cell value binding so far - it can be initialized after creating
+
+ uno::Reference<lang::XInitialization> xInit( xInt, uno::UNO_QUERY );
+ if ( xInit.is() )
+ xInit->initialize( aArgs );
+ }
+
+ return xInt;
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getAvailableServiceNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! warum sind die Parameter bei concatServiceNames nicht const ???
+ //! return concatServiceNames( ScServiceProvider::GetAllServiceNames(),
+ //! SvxFmMSFactory::getAvailableServiceNames() );
+
+ uno::Sequence<rtl::OUString> aMyServices(ScServiceProvider::GetAllServiceNames());
+ uno::Sequence<rtl::OUString> aDrawServices(SvxFmMSFactory::getAvailableServiceNames());
+
+ return concatServiceNames( aMyServices, aDrawServices );
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScModelObj" );
+}
+
+sal_Bool SAL_CALL ScModelObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr(rServiceName);
+ return aServiceStr.EqualsAscii( SCMODELOBJ_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCDOCSETTINGS_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCDOC_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScModelObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCMODELOBJ_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCDOCSETTINGS_SERVICE );
+ return aRet;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScModelObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
+ }
+
+ // aggregated number formats supplier has XUnoTunnel, too
+ // interface from aggregated object must be obtained via queryAggregation
+
+ sal_Int64 nRet = SfxBaseModel::getSomething( rId );
+ if ( nRet )
+ return nRet;
+
+ if ( GetFormatter().is() )
+ {
+ const uno::Type& rTunnelType = ::getCppuType((uno::Reference<lang::XUnoTunnel>*) 0);
+ uno::Any aNumTunnel(xNumberAgg->queryAggregation(rTunnelType));
+ if(aNumTunnel.getValueType() == rTunnelType)
+ {
+ uno::Reference<lang::XUnoTunnel> xTunnelAgg(
+ *(uno::Reference<lang::XUnoTunnel>*)aNumTunnel.getValue());
+ return xTunnelAgg->getSomething( rId );
+ }
+ }
+
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScModelObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScModelObj* ScModelObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScModelObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScModelObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+// XChangesNotifier
+
+void ScModelObj::addChangesListener( const uno::Reference< util::XChangesListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ maChangesListeners.addInterface( aListener );
+}
+
+void ScModelObj::removeChangesListener( const uno::Reference< util::XChangesListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ maChangesListeners.removeInterface( aListener );
+}
+
+bool ScModelObj::HasChangesListeners() const
+{
+ if ( maChangesListeners.getLength() > 0 )
+ return true;
+
+ // "change" event set in any sheet?
+ return pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript(SC_SHEETEVENT_CHANGE);
+}
+
+void ScModelObj::NotifyChanges( const ::rtl::OUString& rOperation, const ScRangeList& rRanges,
+ const uno::Sequence< beans::PropertyValue >& rProperties )
+{
+ if ( pDocShell && HasChangesListeners() )
+ {
+ util::ChangesEvent aEvent;
+ aEvent.Source.set( static_cast< cppu::OWeakObject* >( this ) );
+ aEvent.Base <<= aEvent.Source;
+
+ ULONG nRangeCount = rRanges.Count();
+ aEvent.Changes.realloc( static_cast< sal_Int32 >( nRangeCount ) );
+ for ( ULONG nIndex = 0; nIndex < nRangeCount; ++nIndex )
+ {
+ uno::Reference< table::XCellRange > xRangeObj;
+
+ ScRange aRange( *rRanges.GetObject( nIndex ) );
+ if ( aRange.aStart == aRange.aEnd )
+ {
+ xRangeObj.set( new ScCellObj( pDocShell, aRange.aStart ) );
+ }
+ else
+ {
+ xRangeObj.set( new ScCellRangeObj( pDocShell, aRange ) );
+ }
+
+ util::ElementChange& rChange = aEvent.Changes[ static_cast< sal_Int32 >( nIndex ) ];
+ rChange.Accessor <<= rOperation;
+ rChange.Element <<= rProperties;
+ rChange.ReplacedElement <<= xRangeObj;
+ }
+
+ ::cppu::OInterfaceIteratorHelper aIter( maChangesListeners );
+ while ( aIter.hasMoreElements() )
+ {
+ try
+ {
+ static_cast< util::XChangesListener* >( aIter.next() )->changesOccurred( aEvent );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ }
+
+ // handle sheet events
+ //! separate method with ScMarkData? Then change HasChangesListeners back.
+ if ( rOperation.compareToAscii("cell-change") == 0 && pDocShell )
+ {
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList( rRanges, FALSE );
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+ if (aMarkData.GetTableSelect(nTab))
+ {
+ const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
+ if (pEvents)
+ {
+ const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CHANGE);
+ if (pScript)
+ {
+ ScRangeList aTabRanges; // collect ranges on this sheet
+ ULONG nRangeCount = rRanges.Count();
+ for ( ULONG nIndex = 0; nIndex < nRangeCount; ++nIndex )
+ {
+ ScRange aRange( *rRanges.GetObject( nIndex ) );
+ if ( aRange.aStart.Tab() == nTab )
+ aTabRanges.Append( aRange );
+ }
+ ULONG nTabRangeCount = aTabRanges.Count();
+ if ( nTabRangeCount > 0 )
+ {
+ uno::Reference<uno::XInterface> xTarget;
+ if ( nTabRangeCount == 1 )
+ {
+ ScRange aRange( *aTabRanges.GetObject( 0 ) );
+ if ( aRange.aStart == aRange.aEnd )
+ xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellObj( pDocShell, aRange.aStart ) ) );
+ else
+ xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangeObj( pDocShell, aRange ) ) );
+ }
+ else
+ xTarget.set( static_cast<cppu::OWeakObject*>( new ScCellRangesObj( pDocShell, aTabRanges ) ) );
+
+ uno::Sequence<uno::Any> aParams(1);
+ aParams[0] <<= xTarget;
+
+ uno::Any aRet;
+ uno::Sequence<sal_Int16> aOutArgsIndex;
+ uno::Sequence<uno::Any> aOutArgs;
+
+ /*ErrCode eRet =*/ pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
+ }
+ }
+ }
+ }
+ }
+}
+
+void ScModelObj::HandleCalculateEvents()
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ // don't call events before the document is visible
+ // (might also set a flag on SFX_EVENT_LOADFINISHED and only disable while loading)
+ if ( pDoc->IsDocVisible() )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
+ {
+ if (pDoc->HasCalcNotification(nTab))
+ {
+ if (const ScSheetEvents* pEvents = pDoc->GetSheetEvents( nTab ))
+ {
+ if (const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE))
+ {
+ uno::Any aRet;
+ uno::Sequence<uno::Any> aParams;
+ uno::Sequence<sal_Int16> aOutArgsIndex;
+ uno::Sequence<uno::Any> aOutArgs;
+ pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
+ }
+ }
+
+ try
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= nTab;
+ xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_CALCULATE ), aArgs );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ }
+ }
+ pDoc->ResetCalcNotifications();
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScDrawPagesObj::ScDrawPagesObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDrawPagesObj::~ScDrawPagesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDrawPagesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+uno::Reference<drawing::XDrawPage> ScDrawPagesObj::GetObjectByIndex_Impl(INT32 nIndex) const
+{
+ if (pDocShell)
+ {
+ ScDrawLayer* pDrawLayer = pDocShell->MakeDrawLayer();
+ DBG_ASSERT(pDrawLayer,"kann Draw-Layer nicht anlegen");
+ if ( pDrawLayer && nIndex >= 0 && nIndex < pDocShell->GetDocument()->GetTableCount() )
+ {
+ SdrPage* pPage = pDrawLayer->GetPage((USHORT)nIndex);
+ DBG_ASSERT(pPage,"Draw-Page nicht gefunden");
+ if (pPage)
+ {
+ return uno::Reference<drawing::XDrawPage> (pPage->getUnoPage(), uno::UNO_QUERY);
+ }
+ }
+ }
+ return NULL;
+}
+
+// XDrawPages
+
+uno::Reference<drawing::XDrawPage> SAL_CALL ScDrawPagesObj::insertNewByIndex( sal_Int32 nPos )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<drawing::XDrawPage> xRet;
+ if (pDocShell)
+ {
+ String aNewName;
+ pDocShell->GetDocument()->CreateValidTabName(aNewName);
+ ScDocFunc aFunc(*pDocShell);
+ if ( aFunc.InsertTable( (SCTAB)nPos, aNewName, TRUE, TRUE ) )
+ xRet.set(GetObjectByIndex_Impl( nPos ));
+ }
+ return xRet;
+}
+
+void SAL_CALL ScDrawPagesObj::remove( const uno::Reference<drawing::XDrawPage>& xPage )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SvxDrawPage* pImp = SvxDrawPage::getImplementation( xPage );
+ if ( pDocShell && pImp )
+ {
+ SdrPage* pPage = pImp->GetSdrPage();
+ if (pPage)
+ {
+ SCTAB nPageNum = static_cast<SCTAB>(pPage->GetPageNum());
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.DeleteTable( nPageNum, TRUE, TRUE );
+ }
+ }
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDrawPagesObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return pDocShell->GetDocument()->GetTableCount();
+ return 0;
+}
+
+uno::Any SAL_CALL ScDrawPagesObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<drawing::XDrawPage> xPage(GetObjectByIndex_Impl(nIndex));
+ if (xPage.is())
+ return uno::makeAny(xPage);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScDrawPagesObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<drawing::XDrawPage>*)0);
+}
+
+sal_Bool SAL_CALL ScDrawPagesObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+//------------------------------------------------------------------------
+
+ScTableSheetsObj::ScTableSheetsObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScTableSheetsObj::~ScTableSheetsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScTableSheetsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XSpreadsheets
+
+ScTableSheetObj* ScTableSheetsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
+{
+ if ( pDocShell && nIndex >= 0 && nIndex < pDocShell->GetDocument()->GetTableCount() )
+ return new ScTableSheetObj( pDocShell, static_cast<SCTAB>(nIndex) );
+
+ return NULL;
+}
+
+ScTableSheetObj* ScTableSheetsObj::GetObjectByName_Impl(const rtl::OUString& aName) const
+{
+ if (pDocShell)
+ {
+ SCTAB nIndex;
+ String aString(aName);
+ if ( pDocShell->GetDocument()->GetTable( aString, nIndex ) )
+ return new ScTableSheetObj( pDocShell, nIndex );
+ }
+ return NULL;
+}
+
+void SAL_CALL ScTableSheetsObj::insertNewByName( const rtl::OUString& aName, sal_Int16 nPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ String aNamStr(aName);
+ ScDocFunc aFunc(*pDocShell);
+ bDone = aFunc.InsertTable( nPosition, aNamStr, TRUE, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScTableSheetsObj::moveByName( const rtl::OUString& aName, sal_Int16 nDestination )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ String aNamStr(aName);
+ SCTAB nSource;
+ if ( pDocShell->GetDocument()->GetTable( aNamStr, nSource ) )
+ bDone = pDocShell->MoveTable( nSource, nDestination, FALSE, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScTableSheetsObj::copyByName( const rtl::OUString& aName,
+ const rtl::OUString& aCopy, sal_Int16 nDestination )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ String aNamStr(aName);
+ String aNewStr(aCopy);
+ SCTAB nSource;
+ if ( pDocShell->GetDocument()->GetTable( aNamStr, nSource ) )
+ {
+ bDone = pDocShell->MoveTable( nSource, nDestination, TRUE, TRUE );
+ if (bDone)
+ {
+ // #i92477# any index past the last sheet means "append" in MoveTable
+ SCTAB nResultTab = static_cast<SCTAB>(nDestination);
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount(); // count after copying
+ if (nResultTab >= nTabCount)
+ nResultTab = nTabCount - 1;
+
+ ScDocFunc aFunc(*pDocShell);
+ bDone = aFunc.RenameTable( nResultTab, aNewStr, TRUE, TRUE );
+ }
+ }
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScTableSheetsObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::ElementExistException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ BOOL bIllArg = FALSE;
+
+ //! Type of aElement can be some specific interface instead of XInterface
+
+ if ( pDocShell )
+ {
+ uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
+ if ( xInterface.is() )
+ {
+ ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface );
+ if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt?
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ String aNamStr(aName);
+ SCTAB nDummy;
+ if ( pDoc->GetTable( aNamStr, nDummy ) )
+ {
+ // name already exists
+ throw container::ElementExistException();
+ }
+ else
+ {
+ SCTAB nPosition = pDoc->GetTableCount();
+ ScDocFunc aFunc(*pDocShell);
+ bDone = aFunc.InsertTable( nPosition, aNamStr, TRUE, TRUE );
+ if (bDone)
+ pSheetObj->InitInsertSheet( pDocShell, nPosition );
+ // Dokument und neuen Range am Objekt setzen
+ }
+ }
+ else
+ bIllArg = TRUE;
+ }
+ else
+ bIllArg = TRUE;
+ }
+
+ if (!bDone)
+ {
+ if (bIllArg)
+ throw lang::IllegalArgumentException();
+ else
+ throw uno::RuntimeException(); // ElementExistException is handled above
+ }
+}
+
+void SAL_CALL ScTableSheetsObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ BOOL bIllArg = FALSE;
+
+ //! Type of aElement can be some specific interface instead of XInterface
+
+ if ( pDocShell )
+ {
+ uno::Reference<uno::XInterface> xInterface(aElement, uno::UNO_QUERY);
+ if ( xInterface.is() )
+ {
+ ScTableSheetObj* pSheetObj = ScTableSheetObj::getImplementation( xInterface );
+ if ( pSheetObj && !pSheetObj->GetDocShell() ) // noch nicht eingefuegt?
+ {
+ String aNamStr(aName);
+ SCTAB nPosition;
+ if ( pDocShell->GetDocument()->GetTable( aNamStr, nPosition ) )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ if ( aFunc.DeleteTable( nPosition, TRUE, TRUE ) )
+ {
+ // InsertTable kann jetzt eigentlich nicht schiefgehen...
+ bDone = aFunc.InsertTable( nPosition, aNamStr, TRUE, TRUE );
+ if (bDone)
+ pSheetObj->InitInsertSheet( pDocShell, nPosition );
+ }
+ }
+ else
+ {
+ // not found
+ throw container::NoSuchElementException();
+ }
+ }
+ else
+ bIllArg = TRUE;
+ }
+ else
+ bIllArg = TRUE;
+ }
+
+ if (!bDone)
+ {
+ if (bIllArg)
+ throw lang::IllegalArgumentException();
+ else
+ throw uno::RuntimeException(); // NoSuchElementException is handled above
+ }
+}
+
+void SAL_CALL ScTableSheetsObj::removeByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ SCTAB nIndex;
+ String aString(aName);
+ if ( pDocShell->GetDocument()->GetTable( aString, nIndex ) )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ bDone = aFunc.DeleteTable( nIndex, TRUE, TRUE );
+ }
+ else
+ {
+ // not found
+ throw container::NoSuchElementException();
+ }
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException(); // NoSuchElementException is handled above
+}
+
+// XCellRangesAccess
+
+uno::Reference< table::XCell > SAL_CALL ScTableSheetsObj::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow, sal_Int32 nSheet )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((USHORT)nSheet)));
+ if (! xSheet.is())
+ throw lang::IndexOutOfBoundsException();
+
+ return xSheet->getCellByPosition(nColumn, nRow);
+}
+
+uno::Reference< table::XCellRange > SAL_CALL ScTableSheetsObj::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom, sal_Int32 nSheet )
+ throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XCellRange> xSheet(static_cast<ScCellRangeObj*>(GetObjectByIndex_Impl((USHORT)nSheet)));
+ if (! xSheet.is())
+ throw lang::IndexOutOfBoundsException();
+
+ return xSheet->getCellRangeByPosition(nLeft, nTop, nRight, nBottom);
+}
+
+uno::Sequence < uno::Reference< table::XCellRange > > SAL_CALL ScTableSheetsObj::getCellRangesByName( const rtl::OUString& aRange )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence < uno::Reference < table::XCellRange > > xRet;
+
+ ScRangeList aRangeList;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (ScRangeStringConverter::GetRangeListFromString( aRangeList, aRange, pDoc, ::formula::FormulaGrammar::CONV_OOO, ';' ))
+ {
+ sal_Int32 nCount = aRangeList.Count();
+ if (nCount)
+ {
+ xRet.realloc(nCount);
+ for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ const ScRange* pRange = aRangeList.GetObject( nIndex );
+ if( pRange )
+ xRet[nIndex] = new ScCellRangeObj(pDocShell, *pRange);
+ }
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+ else
+ throw lang::IllegalArgumentException();
+ return xRet;
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScTableSheetsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScTableSheetsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return pDocShell->GetDocument()->GetTableCount();
+ return 0;
+}
+
+uno::Any SAL_CALL ScTableSheetsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XSpreadsheet> xSheet(GetObjectByIndex_Impl(nIndex));
+ if (xSheet.is())
+ return uno::makeAny(xSheet);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScTableSheetsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XSpreadsheet>*)0);
+}
+
+sal_Bool SAL_CALL ScTableSheetsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// XNameAccess
+
+uno::Any SAL_CALL ScTableSheetsObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XSpreadsheet> xSheet(GetObjectByName_Impl(aName));
+ if (xSheet.is())
+ return uno::makeAny(xSheet);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScTableSheetsObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nCount = pDoc->GetTableCount();
+ String aName;
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (SCTAB i=0; i<nCount; i++)
+ {
+ pDoc->GetName( i, aName );
+ pAry[i] = aName;
+ }
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>();
+}
+
+sal_Bool SAL_CALL ScTableSheetsObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ SCTAB nIndex;
+ if ( pDocShell->GetDocument()->GetTable( String(aName), nIndex ) )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//------------------------------------------------------------------------
+
+ScTableColumnsObj::ScTableColumnsObj(ScDocShell* pDocSh, SCTAB nT, SCCOL nSC, SCCOL nEC) :
+ pDocShell( pDocSh ),
+ nTab ( nT ),
+ nStartCol( nSC ),
+ nEndCol ( nEC )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScTableColumnsObj::~ScTableColumnsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScTableColumnsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Referenz-Update fuer Tab und Start/Ende
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XTableColumns
+
+ScTableColumnObj* ScTableColumnsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
+{
+ SCCOL nCol = static_cast<SCCOL>(nIndex) + nStartCol;
+ if ( pDocShell && nCol <= nEndCol )
+ return new ScTableColumnObj( pDocShell, nCol, nTab );
+
+ return NULL; // falscher Index
+}
+
+ScTableColumnObj* ScTableColumnsObj::GetObjectByName_Impl(const rtl::OUString& aName) const
+{
+ SCCOL nCol = 0;
+ String aString(aName);
+ if ( ::AlphaToCol( nCol, aString) )
+ if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol )
+ return new ScTableColumnObj( pDocShell, nCol, nTab );
+
+ return NULL;
+}
+
+void SAL_CALL ScTableColumnsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCount )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartCol+nPosition <= nEndCol &&
+ nStartCol+nPosition+nCount-1 <= MAXCOL )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ ScRange aRange( (SCCOL)(nStartCol+nPosition), 0, nTab,
+ (SCCOL)(nStartCol+nPosition+nCount-1), MAXROW, nTab );
+ bDone = aFunc.InsertCells( aRange, NULL, INS_INSCOLS, TRUE, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScTableColumnsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ // Der zu loeschende Bereich muss innerhalb des Objekts liegen
+ if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartCol+nIndex+nCount-1 <= nEndCol )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ ScRange aRange( (SCCOL)(nStartCol+nIndex), 0, nTab,
+ (SCCOL)(nStartCol+nIndex+nCount-1), MAXROW, nTab );
+ bDone = aFunc.DeleteCells( aRange, NULL, DEL_DELCOLS, TRUE, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScTableColumnsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableColumnsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScTableColumnsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return nEndCol - nStartCol + 1;
+}
+
+uno::Any SAL_CALL ScTableColumnsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XCellRange> xColumn(GetObjectByIndex_Impl(nIndex));
+ if (xColumn.is())
+ return uno::makeAny(xColumn);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScTableColumnsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<table::XCellRange>*)0);
+}
+
+sal_Bool SAL_CALL ScTableColumnsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+uno::Any SAL_CALL ScTableColumnsObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XCellRange> xColumn(GetObjectByName_Impl(aName));
+ if (xColumn.is())
+ return uno::makeAny(xColumn);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScTableColumnsObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SCCOL nCount = nEndCol - nStartCol + 1;
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ for (SCCOL i=0; i<nCount; i++)
+ pAry[i] = ::ScColToAlpha( nStartCol + i );
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScTableColumnsObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SCCOL nCol = 0;
+ String aString(aName);
+ if ( ::AlphaToCol( nCol, aString) )
+ if ( pDocShell && nCol >= nStartCol && nCol <= nEndCol )
+ return TRUE;
+
+ return FALSE; // nicht gefunden
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableColumnsObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( lcl_GetColumnsPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScTableColumnsObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScDocFunc aFunc(*pDocShell);
+ SCCOLROW nColArr[2];
+ nColArr[0] = nStartCol;
+ nColArr[1] = nEndCol;
+ String aNameString(aPropertyName);
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_CELLWID ) )
+ {
+ sal_Int32 nNewWidth = 0;
+ if ( aValue >>= nNewWidth )
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab, SC_SIZE_ORIGINAL,
+ (USHORT)HMMToTwips(nNewWidth), TRUE, TRUE );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
+ {
+ BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab, eMode, 0, TRUE, TRUE );
+ // SC_SIZE_DIRECT with size 0: hide
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) )
+ {
+ BOOL bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bOpt)
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, nTab,
+ SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH, TRUE, TRUE );
+ // FALSE for columns currently has no effect
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
+ {
+ //! single function to set/remove all breaks?
+ BOOL bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ for (SCCOL nCol=nStartCol; nCol<=nEndCol; nCol++)
+ if (bSet)
+ aFunc.InsertPageBreak( TRUE, ScAddress(nCol,0,nTab), TRUE, TRUE, TRUE );
+ else
+ aFunc.RemovePageBreak( TRUE, ScAddress(nCol,0,nTab), TRUE, TRUE, TRUE );
+ }
+}
+
+uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ String aNameString(aPropertyName);
+ uno::Any aAny;
+
+ //! loop over all columns for current state?
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_CELLWID ) )
+ {
+ // for hidden column, return original height
+ USHORT nWidth = pDoc->GetOriginalWidth( nStartCol, nTab );
+ aAny <<= (sal_Int32)TwipsToHMM(nWidth);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
+ {
+ SCCOL nLastCol;
+ bool bVis = !pDoc->ColHidden(nStartCol, nTab, nLastCol);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) )
+ {
+ BOOL bOpt = !(pDoc->GetColFlags( nStartCol, nTab ) & CR_MANUALSIZE);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, bOpt );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) )
+ {
+ ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
+ {
+ ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) );
+ }
+
+ return aAny;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableColumnsObj )
+
+//------------------------------------------------------------------------
+
+ScTableRowsObj::ScTableRowsObj(ScDocShell* pDocSh, SCTAB nT, SCROW nSR, SCROW nER) :
+ pDocShell( pDocSh ),
+ nTab ( nT ),
+ nStartRow( nSR ),
+ nEndRow ( nER )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScTableRowsObj::~ScTableRowsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScTableRowsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Referenz-Update fuer Tab und Start/Ende
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XTableRows
+
+ScTableRowObj* ScTableRowsObj::GetObjectByIndex_Impl(sal_Int32 nIndex) const
+{
+ SCROW nRow = static_cast<SCROW>(nIndex) + nStartRow;
+ if ( pDocShell && nRow <= nEndRow )
+ return new ScTableRowObj( pDocShell, nRow, nTab );
+
+ return NULL; // falscher Index
+}
+
+void SAL_CALL ScTableRowsObj::insertByIndex( sal_Int32 nPosition, sal_Int32 nCount )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if ( pDocShell && nCount > 0 && nPosition >= 0 && nStartRow+nPosition <= nEndRow &&
+ nStartRow+nPosition+nCount-1 <= MAXROW )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ ScRange aRange( 0, (SCROW)(nStartRow+nPosition), nTab,
+ MAXCOL, (SCROW)(nStartRow+nPosition+nCount-1), nTab );
+ bDone = aFunc.InsertCells( aRange, NULL, INS_INSROWS, TRUE, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScTableRowsObj::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ // Der zu loeschende Bereich muss innerhalb des Objekts liegen
+ if ( pDocShell && nCount > 0 && nIndex >= 0 && nStartRow+nIndex+nCount-1 <= nEndRow )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ ScRange aRange( 0, (SCROW)(nStartRow+nIndex), nTab,
+ MAXCOL, (SCROW)(nStartRow+nIndex+nCount-1), nTab );
+ bDone = aFunc.DeleteCells( aRange, NULL, DEL_DELROWS, TRUE, TRUE );
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScTableRowsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.table.TableRowsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScTableRowsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return nEndRow - nStartRow + 1;
+}
+
+uno::Any SAL_CALL ScTableRowsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<table::XCellRange> xRow(GetObjectByIndex_Impl(nIndex));
+ if (xRow.is())
+ return uno::makeAny(xRow);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScTableRowsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<table::XCellRange>*)0);
+}
+
+sal_Bool SAL_CALL ScTableRowsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableRowsObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( lcl_GetRowsPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScTableRowsObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScDocFunc aFunc(*pDocShell);
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCCOLROW nRowArr[2];
+ nRowArr[0] = nStartRow;
+ nRowArr[1] = nEndRow;
+ String aNameString(aPropertyName);
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) )
+ {
+ sal_Int32 nNewHeight = 0;
+ if ( pDoc->IsImportingXML() && ( aValue >>= nNewHeight ) )
+ {
+ // used to set the stored row height for rows with optimal height when loading.
+
+ // TODO: It's probably cleaner to use a different property name
+ // for this.
+ pDoc->SetRowHeightOnly( nStartRow, nEndRow, nTab, (USHORT)HMMToTwips(nNewHeight) );
+ }
+ else
+ {
+ BOOL bOpt = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ if (bOpt)
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_OPTIMAL, 0, TRUE, TRUE );
+ else
+ {
+ //! manually set old heights again?
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLHGT ) )
+ {
+ sal_Int32 nNewHeight = 0;
+ if ( aValue >>= nNewHeight )
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, SC_SIZE_ORIGINAL,
+ (USHORT)HMMToTwips(nNewHeight), TRUE, TRUE );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
+ {
+ BOOL bVis = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE );
+ // SC_SIZE_DIRECT with size 0: hide
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) )
+ {
+ //! undo etc.
+ if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
+ pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, true);
+ else
+ pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, false);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE) )
+ {
+ //! single function to set/remove all breaks?
+ BOOL bSet = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ for (SCROW nRow=nStartRow; nRow<=nEndRow; nRow++)
+ if (bSet)
+ aFunc.InsertPageBreak( FALSE, ScAddress(0,nRow,nTab), TRUE, TRUE, TRUE );
+ else
+ aFunc.RemovePageBreak( FALSE, ScAddress(0,nRow,nTab), TRUE, TRUE, TRUE );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) )
+ {
+ // #i57867# Background color is specified for row styles in the file format,
+ // so it has to be supported along with the row properties (import only).
+
+ // Use ScCellRangeObj to set the property for all cells in the rows
+ // (this means, the "row attribute" must be set before individual cell attributes).
+
+ ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab );
+ uno::Reference<beans::XPropertySet> xRangeObj = new ScCellRangeObj( pDocShell, aRange );
+ xRangeObj->setPropertyValue( aPropertyName, aValue );
+ }
+}
+
+uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pDocShell)
+ throw uno::RuntimeException();
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ String aNameString(aPropertyName);
+ uno::Any aAny;
+
+ //! loop over all rows for current state?
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_CELLHGT ) )
+ {
+ // for hidden row, return original height
+ USHORT nHeight = pDoc->GetOriginalHeight( nStartRow, nTab );
+ aAny <<= (sal_Int32)TwipsToHMM(nHeight);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
+ {
+ SCROW nLastRow;
+ bool bVis = !pDoc->RowHidden(nStartRow, nTab, nLastRow);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) )
+ {
+ bool bVis = pDoc->RowFiltered(nStartRow, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) )
+ {
+ BOOL bOpt = !(pDoc->GetRowFlags( nStartRow, nTab ) & CR_MANUALSIZE);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, bOpt );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) )
+ {
+ ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
+ {
+ ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab);
+ ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) )
+ {
+ // Use ScCellRangeObj to get the property from the cell range
+ // (for completeness only, this is not used by the XML filter).
+
+ ScRange aRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab );
+ uno::Reference<beans::XPropertySet> xRangeObj = new ScCellRangeObj( pDocShell, aRange );
+ aAny = xRangeObj->getPropertyValue( aPropertyName );
+ }
+
+ return aAny;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableRowsObj )
+
+//------------------------------------------------------------------------
+
+ScSpreadsheetSettingsObj::~ScSpreadsheetSettingsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScSpreadsheetSettingsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSpreadsheetSettingsObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ //! muss noch
+ return NULL;
+}
+
+void SAL_CALL ScSpreadsheetSettingsObj::setPropertyValue(
+ const rtl::OUString& /* aPropertyName */, const uno::Any& /* aValue */ )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ //! muss noch
+}
+
+uno::Any SAL_CALL ScSpreadsheetSettingsObj::getPropertyValue( const rtl::OUString& /* aPropertyName */ )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ //! muss noch
+ return uno::Any();
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSpreadsheetSettingsObj )
+
+//------------------------------------------------------------------------
+
+ScAnnotationsObj::ScAnnotationsObj(ScDocShell* pDocSh, SCTAB nT) :
+ pDocShell( pDocSh ),
+ nTab( nT )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScAnnotationsObj::~ScAnnotationsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScAnnotationsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! nTab bei Referenz-Update anpassen!!!
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+bool ScAnnotationsObj::GetAddressByIndex_Impl( sal_Int32 nIndex, ScAddress& rPos ) const
+{
+ if (pDocShell)
+ {
+ sal_Int32 nFound = 0;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab );
+ for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() )
+ {
+ if (pCell->HasNote())
+ {
+ if (nFound == nIndex)
+ {
+ rPos = ScAddress( aCellIter.GetCol(), aCellIter.GetRow(), aCellIter.GetTab() );
+ return true;
+ }
+ ++nFound;
+ }
+ }
+ }
+ return false;
+}
+
+ScAnnotationObj* ScAnnotationsObj::GetObjectByIndex_Impl( sal_Int32 nIndex ) const
+{
+ if (pDocShell)
+ {
+ ScAddress aPos;
+ if ( GetAddressByIndex_Impl( nIndex, aPos ) )
+ return new ScAnnotationObj( pDocShell, aPos );
+ }
+ return NULL;
+}
+
+// XSheetAnnotations
+
+void SAL_CALL ScAnnotationsObj::insertNew(
+ const table::CellAddress& aPosition, const ::rtl::OUString& rText )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ DBG_ASSERT( aPosition.Sheet == nTab, "addAnnotation mit falschem Sheet" );
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, nTab );
+
+ ScDocFunc aFunc( *pDocShell );
+ aFunc.ReplaceNote( aPos, rText, 0, 0, TRUE );
+ }
+}
+
+void SAL_CALL ScAnnotationsObj::removeByIndex( sal_Int32 nIndex ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScAddress aPos;
+ if ( GetAddressByIndex_Impl( nIndex, aPos ) )
+ {
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( aPos.Tab(), TRUE );
+ aMarkData.SetMultiMarkArea( ScRange(aPos) );
+
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.DeleteContents( aMarkData, IDF_NOTE, TRUE, TRUE );
+ }
+ }
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScAnnotationsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ //! iterate directly (more efficiently)?
+
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAnnotationsEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScAnnotationsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ULONG nCount = 0;
+ if (pDocShell)
+ {
+ ScCellIterator aCellIter( pDocShell->GetDocument(), 0,0, nTab, MAXCOL,MAXROW, nTab );
+ for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext() )
+ if (pCell->HasNote())
+ ++nCount;
+ }
+ return nCount;
+}
+
+uno::Any SAL_CALL ScAnnotationsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XSheetAnnotation> xAnnotation(GetObjectByIndex_Impl(nIndex));
+ if (xAnnotation.is())
+ return uno::makeAny(xAnnotation);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScAnnotationsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XSheetAnnotation>*)0);
+}
+
+sal_Bool SAL_CALL ScAnnotationsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+//------------------------------------------------------------------------
+
+ScScenariosObj::ScScenariosObj(ScDocShell* pDocSh, SCTAB nT) :
+ pDocShell( pDocSh ),
+ nTab ( nT )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScScenariosObj::~ScScenariosObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScScenariosObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Referenz-Update fuer Tab und Start/Ende
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XScenarios
+
+BOOL ScScenariosObj::GetScenarioIndex_Impl( const rtl::OUString& rName, SCTAB& rIndex )
+{
+ //! Case-insensitiv ????
+
+ if ( pDocShell )
+ {
+ String aString(rName);
+
+ String aTabName;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nCount = (SCTAB)getCount();
+ for (SCTAB i=0; i<nCount; i++)
+ if (pDoc->GetName( nTab+i+1, aTabName ))
+ if ( aTabName == aString )
+ {
+ rIndex = i;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+ScTableSheetObj* ScScenariosObj::GetObjectByIndex_Impl(sal_Int32 nIndex)
+{
+ USHORT nCount = (USHORT)getCount();
+ if ( pDocShell && nIndex >= 0 && nIndex < nCount )
+ return new ScTableSheetObj( pDocShell, nTab+static_cast<SCTAB>(nIndex)+1 );
+
+ return NULL; // kein Dokument oder falscher Index
+}
+
+ScTableSheetObj* ScScenariosObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ SCTAB nIndex;
+ if ( pDocShell && GetScenarioIndex_Impl( aName, nIndex ) )
+ return new ScTableSheetObj( pDocShell, nTab+nIndex+1 );
+
+ return NULL; // nicht gefunden
+}
+
+void SAL_CALL ScScenariosObj::addNewByName( const rtl::OUString& aName,
+ const uno::Sequence<table::CellRangeAddress>& aRanges,
+ const rtl::OUString& aComment )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( nTab, TRUE );
+
+ USHORT nRangeCount = (USHORT)aRanges.getLength();
+ if (nRangeCount)
+ {
+ const table::CellRangeAddress* pAry = aRanges.getConstArray();
+ for (USHORT i=0; i<nRangeCount; i++)
+ {
+ DBG_ASSERT( pAry[i].Sheet == nTab, "addScenario mit falscher Tab" );
+ ScRange aRange( (SCCOL)pAry[i].StartColumn, (SCROW)pAry[i].StartRow, nTab,
+ (SCCOL)pAry[i].EndColumn, (SCROW)pAry[i].EndRow, nTab );
+
+ aMarkData.SetMultiMarkArea( aRange );
+ }
+ }
+
+ String aNameStr(aName);
+ String aCommStr(aComment);
+
+ Color aColor( COL_LIGHTGRAY ); // Default
+ USHORT nFlags = SC_SCENARIO_SHOWFRAME | SC_SCENARIO_PRINTFRAME | SC_SCENARIO_TWOWAY | SC_SCENARIO_PROTECT;
+
+ pDocShell->MakeScenario( nTab, aNameStr, aCommStr, aColor, nFlags, aMarkData );
+ }
+}
+
+void SAL_CALL ScScenariosObj::removeByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SCTAB nIndex;
+ if ( pDocShell && GetScenarioIndex_Impl( aName, nIndex ) )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.DeleteTable( nTab+nIndex+1, TRUE, TRUE );
+ }
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScScenariosObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.ScenariosEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScScenariosObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SCTAB nCount = 0;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if (!pDoc->IsScenario(nTab))
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nNext = nTab + 1;
+ while (nNext < nTabCount && pDoc->IsScenario(nNext))
+ {
+ ++nCount;
+ ++nNext;
+ }
+ }
+ }
+ return nCount;
+}
+
+uno::Any SAL_CALL ScScenariosObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XScenario> xScen(GetObjectByIndex_Impl(nIndex));
+ if (xScen.is())
+ return uno::makeAny(xScen);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScScenariosObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XScenario>*)0);
+}
+
+sal_Bool SAL_CALL ScScenariosObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+uno::Any SAL_CALL ScScenariosObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XScenario> xScen(GetObjectByName_Impl(aName));
+ if (xScen.is())
+ return uno::makeAny(xScen);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScScenariosObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SCTAB nCount = (SCTAB)getCount();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+
+ if ( pDocShell ) // sonst ist auch Count = 0
+ {
+ String aTabName;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ rtl::OUString* pAry = aSeq.getArray();
+ for (SCTAB i=0; i<nCount; i++)
+ if (pDoc->GetName( nTab+i+1, aTabName ))
+ pAry[i] = aTabName;
+ }
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScScenariosObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SCTAB nIndex;
+ return GetScenarioIndex_Impl( aName, nIndex );
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/drdefuno.cxx b/sc/source/ui/unoobj/drdefuno.cxx
new file mode 100644
index 000000000000..3cee45eaed4a
--- /dev/null
+++ b/sc/source/ui/unoobj/drdefuno.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "drdefuno.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+ScDrawDefaultsObj::ScDrawDefaultsObj(ScDocShell* pDocSh) :
+ SvxUnoDrawPool( NULL ),
+ pDocShell( pDocSh )
+{
+ // SvxUnoDrawPool is initialized without model,
+ // draw layer is created on demand in getModelPool
+
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDrawDefaultsObj::~ScDrawDefaultsObj() throw ()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDrawDefaultsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // document gone
+ }
+}
+
+SfxItemPool* ScDrawDefaultsObj::getModelPool( sal_Bool bReadOnly ) throw()
+{
+ SfxItemPool* pRet = NULL;
+ if ( pDocShell )
+ {
+ ScDrawLayer* pModel = bReadOnly ?
+ pDocShell->GetDocument()->GetDrawLayer() :
+ pDocShell->MakeDrawLayer();
+ if ( pModel )
+ pRet = &pModel->GetItemPool();
+ }
+ if ( !pRet )
+ pRet = SvxUnoDrawPool::getModelPool( bReadOnly ); // uses default pool
+
+ return pRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
new file mode 100644
index 000000000000..d31b41aeeeaf
--- /dev/null
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -0,0 +1,375 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "editsrc.hxx"
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <editeng/unofored.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdocapt.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/outliner.hxx>
+#include "textuno.hxx"
+#include "editutil.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "hints.hxx"
+#include "patattr.hxx"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include "postit.hxx"
+#include "AccessibleText.hxx"
+
+//------------------------------------------------------------------------
+
+TYPEINIT1( ScHeaderFooterChangedHint, SfxHint );
+
+ScHeaderFooterChangedHint::ScHeaderFooterChangedHint(USHORT nP) :
+ nPart( nP )
+{
+}
+
+ScHeaderFooterChangedHint::~ScHeaderFooterChangedHint()
+{
+}
+
+//------------------------------------------------------------------------
+
+ScSharedHeaderFooterEditSource::ScSharedHeaderFooterEditSource( ScHeaderFooterTextData* pData ) :
+ pTextData( pData )
+{
+ // pTextData is held by the ScHeaderFooterTextObj.
+ // Text range and cursor keep a reference to their parent text, so the text object is
+ // always alive and the TextData is valid as long as there are children.
+}
+
+ScSharedHeaderFooterEditSource::~ScSharedHeaderFooterEditSource()
+{
+}
+
+SvxEditSource* ScSharedHeaderFooterEditSource::Clone() const
+{
+ return new ScSharedHeaderFooterEditSource( pTextData );
+}
+
+SvxTextForwarder* ScSharedHeaderFooterEditSource::GetTextForwarder()
+{
+ return pTextData->GetTextForwarder();
+}
+
+void ScSharedHeaderFooterEditSource::UpdateData()
+{
+ pTextData->UpdateData();
+}
+
+ScEditEngineDefaulter* ScSharedHeaderFooterEditSource::GetEditEngine()
+{
+ return pTextData->GetEditEngine();
+}
+
+//------------------------------------------------------------------------
+
+// each ScHeaderFooterEditSource object has its own ScHeaderFooterTextData
+
+ScHeaderFooterEditSource::ScHeaderFooterEditSource( ScHeaderFooterContentObj* pContent,
+ USHORT nP ) :
+ ScSharedHeaderFooterEditSource( new ScHeaderFooterTextData( *pContent, nP ) )
+{
+}
+
+ScHeaderFooterEditSource::ScHeaderFooterEditSource( ScHeaderFooterContentObj& rContent,
+ USHORT nP ) :
+ ScSharedHeaderFooterEditSource( new ScHeaderFooterTextData( rContent, nP ) )
+{
+}
+
+ScHeaderFooterEditSource::~ScHeaderFooterEditSource()
+{
+ delete GetTextData(); // not accessed in ScSharedHeaderFooterEditSource dtor
+}
+
+SvxEditSource* ScHeaderFooterEditSource::Clone() const
+{
+ const ScHeaderFooterTextData* pData = GetTextData();
+ return new ScHeaderFooterEditSource( pData->GetContentObj(), pData->GetPart() );
+}
+
+//------------------------------------------------------------------------
+
+ScSharedCellEditSource::ScSharedCellEditSource( ScCellTextData* pData ) :
+ pCellTextData( pData )
+{
+ // pCellTextData is part of the ScCellTextObj.
+ // Text range and cursor keep a reference to their parent text, so the text object is
+ // always alive and the CellTextData is valid as long as there are children.
+}
+
+ScSharedCellEditSource::~ScSharedCellEditSource()
+{
+}
+
+SvxEditSource* ScSharedCellEditSource::Clone() const
+{
+ return new ScSharedCellEditSource( pCellTextData );
+}
+
+SvxTextForwarder* ScSharedCellEditSource::GetTextForwarder()
+{
+ return pCellTextData->GetTextForwarder();
+}
+
+void ScSharedCellEditSource::UpdateData()
+{
+ pCellTextData->UpdateData();
+}
+
+void ScSharedCellEditSource::SetDoUpdateData(sal_Bool bValue)
+{
+ pCellTextData->SetDoUpdate(bValue);
+}
+
+sal_Bool ScSharedCellEditSource::IsDirty() const
+{
+ return pCellTextData->IsDirty();
+}
+
+ScEditEngineDefaulter* ScSharedCellEditSource::GetEditEngine()
+{
+ return pCellTextData->GetEditEngine();
+}
+
+//------------------------------------------------------------------------
+
+// each ScCellEditSource object has its own ScCellTextData
+
+ScCellEditSource::ScCellEditSource( ScDocShell* pDocSh, const ScAddress& rP ) :
+ ScSharedCellEditSource( new ScCellTextData( pDocSh, rP ) )
+{
+}
+
+ScCellEditSource::~ScCellEditSource()
+{
+ delete GetCellTextData(); // not accessed in ScSharedCellEditSource dtor
+}
+
+SvxEditSource* ScCellEditSource::Clone() const
+{
+ const ScCellTextData* pData = GetCellTextData();
+ return new ScCellEditSource( pData->GetDocShell(), pData->GetCellPos() );
+}
+
+//------------------------------------------------------------------------
+
+ScAnnotationEditSource::ScAnnotationEditSource(ScDocShell* pDocSh, const ScAddress& rP) :
+ pDocShell( pDocSh ),
+ aCellPos( rP ),
+ pEditEngine( NULL ),
+ pForwarder( NULL ),
+ bDataValid( FALSE )
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScAnnotationEditSource::~ScAnnotationEditSource()
+{
+ SolarMutexGuard aGuard; // needed for EditEngine dtor
+
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+
+ delete pForwarder;
+ delete pEditEngine;
+}
+
+SvxEditSource* ScAnnotationEditSource::Clone() const
+{
+ return new ScAnnotationEditSource( pDocShell, aCellPos );
+}
+
+SdrObject* ScAnnotationEditSource::GetCaptionObj()
+{
+ ScPostIt* pNote = pDocShell->GetDocument()->GetNote( aCellPos );
+ return pNote ? pNote->GetOrCreateCaption( aCellPos ) : 0;
+}
+
+SvxTextForwarder* ScAnnotationEditSource::GetTextForwarder()
+{
+ if (!pEditEngine)
+ {
+ // Notizen haben keine Felder
+ if ( pDocShell )
+ {
+ pEditEngine = new ScNoteEditEngine( pDocShell->GetDocument()->GetNoteEngine() );
+ }
+ else
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ pEditEngine = new ScEditEngineDefaulter( pEnginePool, TRUE );
+ }
+ pForwarder = new SvxEditEngineForwarder(*pEditEngine);
+ }
+
+ if (bDataValid)
+ return pForwarder;
+
+ if ( pDocShell )
+ if ( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( aCellPos ) )
+ if ( const EditTextObject* pEditObj = pNote->GetEditTextObject() )
+ pEditEngine->SetText( *pEditObj ); // incl. Umbrueche
+
+ bDataValid = TRUE;
+ return pForwarder;
+}
+
+void ScAnnotationEditSource::UpdateData()
+{
+ if ( pDocShell && pEditEngine )
+ {
+ ScDocShellModificator aModificator( *pDocShell );
+
+ if( SdrObject* pObj = GetCaptionObj() )
+ {
+ EditTextObject* pEditObj = pEditEngine->CreateTextObject();
+ OutlinerParaObject* pOPO = new OutlinerParaObject( *pEditObj );
+ delete pEditObj;
+ pOPO->SetOutlinerMode( OUTLINERMODE_TEXTOBJECT );
+ pObj->NbcSetOutlinerParaObject( pOPO );
+ pObj->ActionChanged();
+ }
+
+ //! Undo !!!
+
+ aModificator.SetDocumentModified();
+
+ // bDataValid wird bei SetDocumentModified zurueckgesetzt
+ }
+}
+
+void ScAnnotationEditSource::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Ref-Update
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+
+ DELETEZ( pForwarder );
+ DELETEZ( pEditEngine ); // EditEngine uses document's pool
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ bDataValid = FALSE; // Text muss neu geholt werden
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScSimpleEditSource::ScSimpleEditSource( SvxTextForwarder* pForw ) :
+ pForwarder( pForw )
+{
+ // The same forwarder (and EditEngine) is shared by all children of the same Text object.
+ // Text range and cursor keep a reference to their parent text, so the text object is
+ // always alive and the forwarder is valid as long as there are children.
+}
+
+ScSimpleEditSource::~ScSimpleEditSource()
+{
+}
+
+SvxEditSource* ScSimpleEditSource::Clone() const
+{
+ return new ScSimpleEditSource( pForwarder );
+}
+
+SvxTextForwarder* ScSimpleEditSource::GetTextForwarder()
+{
+ return pForwarder;
+}
+
+void ScSimpleEditSource::UpdateData()
+{
+ // nothing
+}
+
+//------------------------------------------------------------------------
+
+ScAccessibilityEditSource::ScAccessibilityEditSource( ::std::auto_ptr < ScAccessibleTextData > pAccessibleCellTextData )
+ : mpAccessibleTextData(pAccessibleCellTextData)
+{
+}
+
+ScAccessibilityEditSource::~ScAccessibilityEditSource()
+{
+}
+
+SvxEditSource* ScAccessibilityEditSource::Clone() const
+{
+ return new ScAccessibilityEditSource(::std::auto_ptr < ScAccessibleTextData > (mpAccessibleTextData->Clone()));
+}
+
+SvxTextForwarder* ScAccessibilityEditSource::GetTextForwarder()
+{
+ return mpAccessibleTextData->GetTextForwarder();
+}
+
+SvxViewForwarder* ScAccessibilityEditSource::GetViewForwarder()
+{
+ return mpAccessibleTextData->GetViewForwarder();
+}
+
+SvxEditViewForwarder* ScAccessibilityEditSource::GetEditViewForwarder( sal_Bool bCreate )
+{
+ return mpAccessibleTextData->GetEditViewForwarder(bCreate);
+}
+
+void ScAccessibilityEditSource::UpdateData()
+{
+ mpAccessibleTextData->UpdateData();
+}
+
+SfxBroadcaster& ScAccessibilityEditSource::GetBroadcaster() const
+{
+ return mpAccessibleTextData->GetBroadcaster();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/eventuno.cxx b/sc/source/ui/unoobj/eventuno.cxx
new file mode 100644
index 000000000000..8f0b38c0eed9
--- /dev/null
+++ b/sc/source/ui/unoobj/eventuno.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: tokenuno.cxx,v $
+ * $Revision: 1.6.108.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "eventuno.hxx"
+#include "miscuno.hxx"
+#include "docsh.hxx"
+#include "sheetevents.hxx"
+#include "unonames.hxx"
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScSheetEventsObj, "ScSheetEventsObj", "com.sun.star.document.Events" )
+
+//------------------------------------------------------------------------
+
+ScSheetEventsObj::ScSheetEventsObj(ScDocShell* pDocSh, SCTAB nT) :
+ mpDocShell( pDocSh ),
+ mnTab( nT )
+{
+ mpDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScSheetEventsObj::~ScSheetEventsObj()
+{
+ if (mpDocShell)
+ mpDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScSheetEventsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! reference update
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ mpDocShell = NULL;
+ }
+}
+
+sal_Int32 lcl_GetEventFromName( const rtl::OUString& aName )
+{
+ for (sal_Int32 nEvent=0; nEvent<SC_SHEETEVENT_COUNT; ++nEvent)
+ if ( aName == ScSheetEvents::GetEventName(nEvent) )
+ return nEvent;
+
+ return -1; // not found
+}
+
+// XNameReplace
+
+void SAL_CALL ScSheetEventsObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!mpDocShell)
+ throw uno::RuntimeException();
+
+ sal_Int32 nEvent = lcl_GetEventFromName(aName);
+ if (nEvent < 0)
+ throw container::NoSuchElementException();
+
+ ScSheetEvents aNewEvents;
+ const ScSheetEvents* pOldEvents = mpDocShell->GetDocument()->GetSheetEvents(mnTab);
+ if (pOldEvents)
+ aNewEvents = *pOldEvents;
+
+ rtl::OUString aScript;
+ if ( aElement.hasValue() ) // empty Any -> reset event
+ {
+ uno::Sequence<beans::PropertyValue> aPropSeq;
+ if ( aElement >>= aPropSeq )
+ {
+ sal_Int32 nPropCount = aPropSeq.getLength();
+ for (sal_Int32 nPos=0; nPos<nPropCount; ++nPos)
+ {
+ const beans::PropertyValue& rProp = aPropSeq[nPos];
+ if ( rProp.Name.compareToAscii( SC_UNO_EVENTTYPE ) == 0 )
+ {
+ rtl::OUString aEventType;
+ if ( rProp.Value >>= aEventType )
+ {
+ // only "Script" is supported
+ if ( aEventType.compareToAscii( SC_UNO_SCRIPT ) != 0 )
+ throw lang::IllegalArgumentException();
+ }
+ }
+ else if ( rProp.Name.compareToAscii( SC_UNO_SCRIPT ) == 0 )
+ rProp.Value >>= aScript;
+ }
+ }
+ }
+ if (aScript.getLength())
+ aNewEvents.SetScript( nEvent, &aScript );
+ else
+ aNewEvents.SetScript( nEvent, NULL ); // reset
+
+ mpDocShell->GetDocument()->SetSheetEvents( mnTab, &aNewEvents );
+ mpDocShell->SetDocumentModified();
+}
+
+// XNameAccess
+
+uno::Any SAL_CALL ScSheetEventsObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 nEvent = lcl_GetEventFromName(aName);
+ if (nEvent < 0)
+ throw container::NoSuchElementException();
+
+ const rtl::OUString* pScript = NULL;
+ if (mpDocShell)
+ {
+ const ScSheetEvents* pEvents = mpDocShell->GetDocument()->GetSheetEvents(mnTab);
+ if (pEvents)
+ pScript = pEvents->GetScript(nEvent);
+ }
+
+ uno::Any aRet;
+ if (pScript)
+ {
+ uno::Sequence<beans::PropertyValue> aPropSeq( 2 );
+ aPropSeq[0] = beans::PropertyValue(
+ rtl::OUString::createFromAscii("EventType"), -1,
+ uno::makeAny( rtl::OUString::createFromAscii("Script") ), beans::PropertyState_DIRECT_VALUE );
+ aPropSeq[1] = beans::PropertyValue(
+ rtl::OUString::createFromAscii("Script"), -1,
+ uno::makeAny( *pScript ), beans::PropertyState_DIRECT_VALUE );
+ aRet <<= aPropSeq;
+ }
+ // empty Any if nothing was set
+ return aRet;
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScSheetEventsObj::getElementNames() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence<rtl::OUString> aNames(SC_SHEETEVENT_COUNT);
+ for (sal_Int32 nEvent=0; nEvent<SC_SHEETEVENT_COUNT; ++nEvent)
+ aNames[nEvent] = ScSheetEvents::GetEventName(nEvent);
+ return aNames;
+}
+
+sal_Bool SAL_CALL ScSheetEventsObj::hasByName( const ::rtl::OUString& aName ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 nEvent = lcl_GetEventFromName(aName);
+ return (nEvent >= 0);
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScSheetEventsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Sequence<beans::PropertyValue>*)0);
+}
+
+sal_Bool SAL_CALL ScSheetEventsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (mpDocShell)
+ return sal_True;
+ return sal_False;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx
new file mode 100644
index 000000000000..253b664b01af
--- /dev/null
+++ b/sc/source/ui/unoobj/fielduno.cxx
@@ -0,0 +1,1530 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <svl/smplhint.hxx>
+#include <vcl/svapp.hxx>
+
+
+#include <editeng/eeitem.hxx>
+
+#include <editeng/editeng.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/flditem.hxx>
+#include <rtl/uuid.h>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/text/WrapTextMode.hpp>
+#include <com/sun/star/text/FilenameDisplayFormat.hpp>
+
+#include "fielduno.hxx"
+#include "textuno.hxx"
+#include "miscuno.hxx"
+#include "docsh.hxx"
+#include "hints.hxx"
+#include "editsrc.hxx"
+#include "cellsuno.hxx"
+#include "servuno.hxx" // fuer IDs
+#include "unonames.hxx"
+#include "editutil.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+// alles ohne Which-ID, Map nur fuer PropertySetInfo
+
+const SfxItemPropertySet* lcl_GetURLPropertySet()
+{
+ static SfxItemPropertyMapEntry aURLPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE), 0, &getCppuType((text::TextContentAnchorType*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES), 0, &getCppuType((uno::Sequence<text::TextContentAnchorType>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_REPR), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_TARGET), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP), 0, &getCppuType((text::WrapTextMode*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_URL), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aURLPropertySet_Impl( aURLPropertyMap_Impl );
+ return &aURLPropertySet_Impl;
+}
+
+const SfxItemPropertySet* lcl_GetHeaderFieldPropertySet()
+{
+ static SfxItemPropertyMapEntry aHeaderFieldPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE), 0, &getCppuType((text::TextContentAnchorType*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES), 0, &getCppuType((uno::Sequence<text::TextContentAnchorType>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP), 0, &getCppuType((text::WrapTextMode*)0), beans::PropertyAttribute::READONLY, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aHeaderFieldPropertySet_Impl( aHeaderFieldPropertyMap_Impl );
+ return &aHeaderFieldPropertySet_Impl;
+}
+
+const SfxItemPropertySet* lcl_GetFileFieldPropertySet()
+{
+ static SfxItemPropertyMapEntry aFileFieldPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ANCTYPE), 0, &getCppuType((text::TextContentAnchorType*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ANCTYPES), 0, &getCppuType((uno::Sequence<text::TextContentAnchorType>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_FILEFORM), 0, &getCppuType((sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TEXTWRAP), 0, &getCppuType((text::WrapTextMode*)0), beans::PropertyAttribute::READONLY, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aFileFieldPropertySet_Impl( aFileFieldPropertyMap_Impl );
+ return &aFileFieldPropertySet_Impl;
+}
+
+//------------------------------------------------------------------------
+
+#define SCTEXTFIELD_SERVICE "com.sun.star.text.TextField"
+#define SCTEXTCONTENT_SERVICE "com.sun.star.text.TextContent"
+
+SC_SIMPLE_SERVICE_INFO( ScCellFieldsObj, "ScCellFieldsObj", "com.sun.star.text.TextFields" )
+SC_SIMPLE_SERVICE_INFO( ScHeaderFieldsObj, "ScHeaderFieldsObj", "com.sun.star.text.TextFields" )
+
+//------------------------------------------------------------------------
+
+// ScUnoEditEngine nur um aus einer EditEngine die Felder herauszubekommen...
+
+enum ScUnoCollectMode
+{
+ SC_UNO_COLLECT_NONE,
+ SC_UNO_COLLECT_COUNT,
+ SC_UNO_COLLECT_FINDINDEX,
+ SC_UNO_COLLECT_FINDPOS
+};
+
+class ScUnoEditEngine : public ScEditEngineDefaulter
+{
+ ScUnoCollectMode eMode;
+ USHORT nFieldCount;
+ TypeId aFieldType;
+ SvxFieldData* pFound; // lokale Kopie
+ USHORT nFieldPar;
+ xub_StrLen nFieldPos;
+ USHORT nFieldIndex;
+
+public:
+ ScUnoEditEngine(ScEditEngineDefaulter* pSource);
+ ~ScUnoEditEngine();
+
+ //! nPos should be xub_StrLen
+ virtual String CalcFieldValue( const SvxFieldItem& rField, USHORT nPara, USHORT nPos,
+ Color*& rTxtColor, Color*& rFldColor );
+
+ USHORT CountFields(TypeId aType);
+ SvxFieldData* FindByIndex(USHORT nIndex, TypeId aType);
+ SvxFieldData* FindByPos(USHORT nPar, xub_StrLen nPos, TypeId aType);
+
+ USHORT GetFieldPar() const { return nFieldPar; }
+ xub_StrLen GetFieldPos() const { return nFieldPos; }
+};
+
+ScUnoEditEngine::ScUnoEditEngine(ScEditEngineDefaulter* pSource) :
+ ScEditEngineDefaulter( *pSource ),
+ eMode( SC_UNO_COLLECT_NONE ),
+ nFieldCount( 0 ),
+ aFieldType( NULL ),
+ pFound( NULL )
+{
+ if (pSource)
+ {
+ EditTextObject* pData = pSource->CreateTextObject();
+ SetText( *pData );
+ delete pData;
+ }
+}
+
+ScUnoEditEngine::~ScUnoEditEngine()
+{
+ delete pFound;
+}
+
+String ScUnoEditEngine::CalcFieldValue( const SvxFieldItem& rField,
+ USHORT nPara, USHORT nPos, Color*& rTxtColor, Color*& rFldColor )
+{
+ String aRet(EditEngine::CalcFieldValue( rField, nPara, nPos, rTxtColor, rFldColor ));
+ if (eMode != SC_UNO_COLLECT_NONE)
+ {
+ const SvxFieldData* pFieldData = rField.GetField();
+ if ( pFieldData )
+ {
+ if ( !aFieldType || pFieldData->Type() == aFieldType )
+ {
+ if ( eMode == SC_UNO_COLLECT_FINDINDEX && !pFound && nFieldCount == nFieldIndex )
+ {
+ pFound = pFieldData->Clone();
+ nFieldPar = nPara;
+ nFieldPos = nPos;
+ }
+ if ( eMode == SC_UNO_COLLECT_FINDPOS && !pFound &&
+ nPara == nFieldPar && nPos == nFieldPos )
+ {
+ pFound = pFieldData->Clone();
+ nFieldIndex = nFieldCount;
+ }
+ ++nFieldCount;
+ }
+ }
+ }
+ return aRet;
+}
+
+USHORT ScUnoEditEngine::CountFields(TypeId aType)
+{
+ eMode = SC_UNO_COLLECT_COUNT;
+ aFieldType = aType;
+ nFieldCount = 0;
+ UpdateFields();
+ aFieldType = NULL;
+ eMode = SC_UNO_COLLECT_NONE;
+
+ return nFieldCount;
+}
+
+SvxFieldData* ScUnoEditEngine::FindByIndex(USHORT nIndex, TypeId aType)
+{
+ eMode = SC_UNO_COLLECT_FINDINDEX;
+ nFieldIndex = nIndex;
+ aFieldType = aType;
+ nFieldCount = 0;
+ UpdateFields();
+ aFieldType = NULL;
+ eMode = SC_UNO_COLLECT_NONE;
+
+ return pFound;
+}
+
+SvxFieldData* ScUnoEditEngine::FindByPos(USHORT nPar, xub_StrLen nPos, TypeId aType)
+{
+ eMode = SC_UNO_COLLECT_FINDPOS;
+ nFieldPar = nPar;
+ nFieldPos = nPos;
+ aFieldType = aType;
+ nFieldCount = 0;
+ UpdateFields();
+ aFieldType = NULL;
+ eMode = SC_UNO_COLLECT_NONE;
+
+ return pFound;
+}
+
+//------------------------------------------------------------------------
+
+ScCellFieldsObj::ScCellFieldsObj(ScDocShell* pDocSh, const ScAddress& rPos) :
+ pDocShell( pDocSh ),
+ aCellPos( rPos ),
+ mpRefreshListeners( NULL )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ pEditSource = new ScCellEditSource( pDocShell, aCellPos );
+}
+
+ScCellFieldsObj::~ScCellFieldsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+
+ delete pEditSource;
+
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+
+ if (mpRefreshListeners)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ if (mpRefreshListeners)
+ {
+ mpRefreshListeners->disposeAndClear(aEvent);
+ DELETEZ( mpRefreshListeners );
+ }
+ }
+}
+
+void ScCellFieldsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Ref-Update
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+
+ // EditSource hat sich selber als Listener angemeldet
+}
+
+// XIndexAccess (via XTextFields)
+
+ScCellFieldObj* ScCellFieldsObj::GetObjectByIndex_Impl(INT32 Index) const
+{
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ if ( aTempEngine.FindByIndex( (USHORT)Index, NULL ) ) // in der Zelle ist der Typ egal
+ {
+ USHORT nPar = aTempEngine.GetFieldPar();
+ xub_StrLen nPos = aTempEngine.GetFieldPos();
+ ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Feld ist 1 Zeichen
+ return new ScCellFieldObj( pDocShell, aCellPos, aSelection );
+ }
+ return NULL;
+}
+
+sal_Int32 SAL_CALL ScCellFieldsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ return aTempEngine.CountFields(NULL); // Felder zaehlen, in Zelle ist der Typ egal
+}
+
+uno::Any SAL_CALL ScCellFieldsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
+ if (xField.is())
+ return uno::makeAny(xField);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScCellFieldsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<text::XTextField>*)0);
+}
+
+sal_Bool SAL_CALL ScCellFieldsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+uno::Reference<container::XEnumeration> SAL_CALL ScCellFieldsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFieldEnumeration")));
+}
+
+void SAL_CALL ScCellFieldsObj::addContainerListener(
+ const uno::Reference<container::XContainerListener>& /* xListener */ )
+ throw(uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScCellFieldsObj::removeContainerListener(
+ const uno::Reference<container::XContainerListener>& /* xListener */ )
+ throw(uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+// XRefreshable
+void SAL_CALL ScCellFieldsObj::refresh( )
+ throw (uno::RuntimeException)
+{
+ if (mpRefreshListeners)
+ {
+ // Call all listeners.
+ uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
+ sal_uInt32 nLength(aListeners.getLength());
+ if (nLength)
+ {
+ const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
+ if (pInterfaces)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source.set(uno::Reference< util::XRefreshable >(const_cast<ScCellFieldsObj*>(this)));
+ sal_uInt32 i(0);
+ while (i < nLength)
+ {
+ try
+ {
+ while(i < nLength)
+ {
+ static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ catch(uno::RuntimeException&)
+ {
+// DBG_ERROR("a object is gone without to remove from Broadcaster");
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ }
+ }
+ }
+}
+
+void SAL_CALL ScCellFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ SolarMutexGuard aGuard;
+ if (!mpRefreshListeners)
+ mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
+ mpRefreshListeners->addInterface(xListener);
+ }
+}
+
+void SAL_CALL ScCellFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ SolarMutexGuard aGuard;
+ if (mpRefreshListeners)
+ mpRefreshListeners->removeInterface(xListener);
+ }
+}
+
+//------------------------------------------------------------------------
+
+// Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
+
+
+ScCellFieldObj::ScCellFieldObj(ScDocShell* pDocSh, const ScAddress& rPos,
+ const ESelection& rSel) :
+ OComponentHelper( getMutex() ),
+ pPropSet( lcl_GetURLPropertySet() ),
+ pDocShell( pDocSh ),
+ aCellPos( rPos ),
+ aSelection( rSel )
+{
+ // pDocShell ist Null, wenn per ServiceProvider erzeugt
+
+ if (pDocShell)
+ {
+ pDocShell->GetDocument()->AddUnoObject(*this);
+ pEditSource = new ScCellEditSource( pDocShell, aCellPos );
+ }
+ else
+ pEditSource = NULL;
+}
+
+uno::Any SAL_CALL ScCellFieldObj::queryAggregation( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( text::XTextField )
+ SC_QUERYINTERFACE( text::XTextContent ) // parent of XTextField
+ SC_QUERYINTERFACE( beans::XPropertySet )
+ SC_QUERYINTERFACE( lang::XUnoTunnel )
+ SC_QUERYINTERFACE( lang::XServiceInfo )
+
+ return OComponentHelper::queryAggregation( rType ); // XComponent
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScCellFieldObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(OComponentHelper::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 4 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<text::XTextField>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScCellFieldObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+uno::Any SAL_CALL ScCellFieldObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ return OComponentHelper::queryInterface( rType );
+}
+
+void SAL_CALL ScCellFieldObj::acquire() throw()
+{
+ OComponentHelper::acquire();
+}
+
+void SAL_CALL ScCellFieldObj::release() throw()
+{
+ OComponentHelper::release();
+}
+
+void ScCellFieldObj::InitDoc( ScDocShell* pDocSh, const ScAddress& rPos,
+ const ESelection& rSel )
+{
+ if ( pDocSh && !pEditSource )
+ {
+ aCellPos = rPos;
+ aSelection = rSel;
+ pDocShell = pDocSh;
+
+ pDocShell->GetDocument()->AddUnoObject(*this);
+ pEditSource = new ScCellEditSource( pDocShell, aCellPos );
+ }
+}
+
+ScCellFieldObj::~ScCellFieldObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+
+ delete pEditSource;
+}
+
+void ScCellFieldObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! Updates fuer aSelection (muessen erst noch erzeugt werden) !!!!!!
+
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Ref-Update
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+
+ // EditSource hat sich selber als Listener angemeldet
+}
+
+// per getImplementation gerufen:
+
+SvxFieldItem ScCellFieldObj::CreateFieldItem()
+{
+ DBG_ASSERT( !pEditSource, "CreateFieldItem mit eingefuegtem Feld" );
+
+ SvxURLField aField;
+ aField.SetFormat(SVXURLFORMAT_APPDEFAULT);
+ aField.SetURL( aUrl );
+ aField.SetRepresentation( aRepresentation );
+ aField.SetTargetFrame( aTarget );
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+}
+
+void ScCellFieldObj::DeleteField()
+{
+ if (pEditSource)
+ {
+ SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+// pEditEngine->QuickDelete( aSelection );
+ pForwarder->QuickInsertText( String(), aSelection );
+ pEditSource->UpdateData();
+
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos;
+
+ //! Broadcast, um Selektion in anderen Objekten anzupassen
+ //! (auch bei anderen Aktionen)
+ }
+}
+
+// XTextField
+
+rtl::OUString SAL_CALL ScCellFieldObj::getPresentation( sal_Bool bShowCommand )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aRet;
+
+ if (pEditSource)
+ {
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ // Typ egal (in Zellen gibts nur URLs)
+ SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 );
+ DBG_ASSERT(pField,"getPresentation: Feld nicht gefunden");
+ if (pField)
+ {
+ SvxURLField* pURL = (SvxURLField*)pField;
+ if (bShowCommand)
+ aRet = pURL->GetURL();
+ else
+ aRet = pURL->GetRepresentation();
+ }
+ }
+
+ return aRet;
+}
+
+// XTextContent
+
+void SAL_CALL ScCellFieldObj::attach( const uno::Reference<text::XTextRange>& xTextRange )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (xTextRange.is())
+ {
+ uno::Reference<text::XText> xText(xTextRange->getText());
+ if (xText.is())
+ {
+ xText->insertTextContent( xTextRange, this, TRUE );
+ }
+ }
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellFieldObj::getAnchor() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ return new ScCellObj( pDocShell, aCellPos );
+ return NULL;
+}
+
+// XComponent
+
+void SAL_CALL ScCellFieldObj::dispose() throw(uno::RuntimeException)
+{
+ OComponentHelper::dispose();
+}
+
+void SAL_CALL ScCellFieldObj::addEventListener(
+ const uno::Reference<lang::XEventListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ OComponentHelper::addEventListener( xListener );
+}
+
+void SAL_CALL ScCellFieldObj::removeEventListener(
+ const uno::Reference<lang::XEventListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ OComponentHelper::removeEventListener( xListener );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellFieldObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef = pPropSet->getPropertySetInfo();
+ return aRef;
+}
+
+void SAL_CALL ScCellFieldObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ rtl::OUString aStrVal;
+ if (pEditSource)
+ {
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ // Typ egal (in Zellen gibts nur URLs)
+ SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 );
+ DBG_ASSERT(pField,"setPropertyValue: Feld nicht gefunden");
+ if (pField)
+ {
+ SvxURLField* pURL = (SvxURLField*)pField; // ist eine Kopie in der ScUnoEditEngine
+
+ BOOL bOk = TRUE;
+ if ( aNameString.EqualsAscii( SC_UNONAME_URL ) )
+ {
+ if (aValue >>= aStrVal)
+ pURL->SetURL( aStrVal );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) )
+ {
+ if (aValue >>= aStrVal)
+ pURL->SetRepresentation( aStrVal );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) )
+ {
+ if (aValue >>= aStrVal)
+ pURL->SetTargetFrame( aStrVal );
+ }
+ else
+ bOk = FALSE;
+
+ if (bOk)
+ {
+ pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
+ pEditSource->UpdateData();
+ }
+ }
+ }
+ else // noch nicht eingefuegt
+ {
+ if ( aNameString.EqualsAscii( SC_UNONAME_URL ) )
+ {
+ if (aValue >>= aStrVal)
+ aUrl = String( aStrVal );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) )
+ {
+ if (aValue >>= aStrVal)
+ aRepresentation = String( aStrVal );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) )
+ {
+ if (aValue >>= aStrVal)
+ aTarget = String( aStrVal );
+ }
+ }
+}
+
+uno::Any SAL_CALL ScCellFieldObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ String aNameString(aPropertyName);
+
+ // anchor type is always "as character", text wrap always "none"
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_ANCTYPE ) )
+ aRet <<= text::TextContentAnchorType_AS_CHARACTER;
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ANCTYPES ) )
+ {
+ uno::Sequence<text::TextContentAnchorType> aSeq(1);
+ aSeq[0] = text::TextContentAnchorType_AS_CHARACTER;
+ aRet <<= aSeq;
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_TEXTWRAP ) )
+ aRet <<= text::WrapTextMode_NONE;
+ else if (pEditSource)
+ {
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ // Typ egal (in Zellen gibts nur URLs)
+ SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 );
+ DBG_ASSERT(pField,"getPropertyValue: Feld nicht gefunden");
+ if (pField)
+ {
+ SvxURLField* pURL = (SvxURLField*)pField;
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_URL ) )
+ aRet <<= rtl::OUString( pURL->GetURL() );
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) )
+ aRet <<= rtl::OUString( pURL->GetRepresentation() );
+ else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) )
+ aRet <<= rtl::OUString( pURL->GetTargetFrame() );
+ }
+ }
+ else // noch nicht eingefuegt
+ {
+ if ( aNameString.EqualsAscii( SC_UNONAME_URL ) )
+ aRet <<= rtl::OUString( aUrl );
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) )
+ aRet <<= rtl::OUString( aRepresentation );
+ else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) )
+ aRet <<= rtl::OUString( aTarget );
+ }
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScCellFieldObj )
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScCellFieldObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScCellFieldObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScCellFieldObj* ScCellFieldObj::getImplementation(
+ const uno::Reference<text::XTextContent> xObj )
+{
+ ScCellFieldObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScCellFieldObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScCellFieldObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScCellFieldObj" );
+}
+
+sal_Bool SAL_CALL ScCellFieldObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCTEXTFIELD_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCTEXTCONTENT_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellFieldObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCTEXTFIELD_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCTEXTCONTENT_SERVICE );
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterContentObj* pContent, USHORT nP, USHORT nT) :
+ pContentObj( pContent ),
+ nPart( nP ),
+ nType( nT ),
+ mpRefreshListeners( NULL )
+{
+ DBG_ASSERT( pContentObj, "ScHeaderFieldsObj ohne Objekt?" );
+
+ if (pContentObj)
+ {
+ pContentObj->acquire(); // darf nicht wegkommen
+ pEditSource = new ScHeaderFooterEditSource( pContentObj, nPart );
+ }
+ else
+ pEditSource = NULL;
+}
+
+ScHeaderFieldsObj::~ScHeaderFieldsObj()
+{
+ delete pEditSource;
+
+ if (pContentObj)
+ pContentObj->release();
+
+ // increment refcount to prevent double call off dtor
+ osl_incrementInterlockedCount( &m_refCount );
+
+ if (mpRefreshListeners)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source = static_cast<cppu::OWeakObject*>(this);
+ if (mpRefreshListeners)
+ {
+ mpRefreshListeners->disposeAndClear(aEvent);
+ DELETEZ( mpRefreshListeners );
+ }
+ }
+}
+
+// XIndexAccess (via XTextFields)
+
+ScHeaderFieldObj* ScHeaderFieldsObj::GetObjectByIndex_Impl(INT32 Index) const
+{
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ TypeId aTypeId = NULL;
+ switch (nType)
+ {
+ case SC_SERVICE_PAGEFIELD: aTypeId = TYPE(SvxPageField); break;
+ case SC_SERVICE_PAGESFIELD: aTypeId = TYPE(SvxPagesField); break;
+ case SC_SERVICE_DATEFIELD: aTypeId = TYPE(SvxDateField); break;
+ case SC_SERVICE_TIMEFIELD: aTypeId = TYPE(SvxTimeField); break;
+ case SC_SERVICE_TITLEFIELD: aTypeId = TYPE(SvxFileField); break;
+ case SC_SERVICE_FILEFIELD: aTypeId = TYPE(SvxExtFileField); break;
+ case SC_SERVICE_SHEETFIELD: aTypeId = TYPE(SvxTableField); break;
+ // bei SC_SERVICE_INVALID bleibt TypeId Null
+ }
+ SvxFieldData* pData = aTempEngine.FindByIndex( (USHORT)Index, aTypeId );
+ if ( pData )
+ {
+ USHORT nPar = aTempEngine.GetFieldPar();
+ xub_StrLen nPos = aTempEngine.GetFieldPos();
+
+ USHORT nFieldType = nType;
+ if ( nFieldType == SC_SERVICE_INVALID )
+ {
+ if ( pData->ISA( SvxPageField ) ) nFieldType = SC_SERVICE_PAGEFIELD;
+ else if ( pData->ISA( SvxPagesField ) ) nFieldType = SC_SERVICE_PAGESFIELD;
+ else if ( pData->ISA( SvxDateField ) ) nFieldType = SC_SERVICE_DATEFIELD;
+ else if ( pData->ISA( SvxTimeField ) ) nFieldType = SC_SERVICE_TIMEFIELD;
+ else if ( pData->ISA( SvxFileField ) ) nFieldType = SC_SERVICE_TITLEFIELD;
+ else if ( pData->ISA( SvxExtFileField ) ) nFieldType = SC_SERVICE_FILEFIELD;
+ else if ( pData->ISA( SvxTableField ) ) nFieldType = SC_SERVICE_SHEETFIELD;
+ }
+
+ ESelection aSelection( nPar, nPos, nPar, nPos+1 ); // Field is 1 character
+ return new ScHeaderFieldObj( pContentObj, nPart, nFieldType, aSelection );
+ }
+ return NULL;
+}
+
+sal_Int32 SAL_CALL ScHeaderFieldsObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! Feld-Funktionen muessen an den Forwarder !!!
+ ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+
+ TypeId aTypeId = NULL;
+ switch (nType)
+ {
+ case SC_SERVICE_PAGEFIELD: aTypeId = TYPE(SvxPageField); break;
+ case SC_SERVICE_PAGESFIELD: aTypeId = TYPE(SvxPagesField); break;
+ case SC_SERVICE_DATEFIELD: aTypeId = TYPE(SvxDateField); break;
+ case SC_SERVICE_TIMEFIELD: aTypeId = TYPE(SvxTimeField); break;
+ case SC_SERVICE_TITLEFIELD: aTypeId = TYPE(SvxFileField); break;
+ case SC_SERVICE_FILEFIELD: aTypeId = TYPE(SvxExtFileField); break;
+ case SC_SERVICE_SHEETFIELD: aTypeId = TYPE(SvxTableField); break;
+ }
+ return aTempEngine.CountFields(aTypeId); // Felder zaehlen
+}
+
+uno::Any SAL_CALL ScHeaderFieldsObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<text::XTextField> xField(GetObjectByIndex_Impl(nIndex));
+ if (xField.is())
+ return uno::makeAny(xField);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScHeaderFieldsObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<text::XTextField>*)0);
+}
+
+sal_Bool SAL_CALL ScHeaderFieldsObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+uno::Reference<container::XEnumeration> SAL_CALL ScHeaderFieldsObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFieldEnumeration")));
+}
+
+void SAL_CALL ScHeaderFieldsObj::addContainerListener(
+ const uno::Reference<container::XContainerListener>& /* xListener */ )
+ throw(uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+void SAL_CALL ScHeaderFieldsObj::removeContainerListener(
+ const uno::Reference<container::XContainerListener>& /* xListener */ )
+ throw(uno::RuntimeException)
+{
+ DBG_ERROR("not implemented");
+}
+
+// XRefreshable
+void SAL_CALL ScHeaderFieldsObj::refresh( )
+ throw (uno::RuntimeException)
+{
+ if (mpRefreshListeners)
+ {
+ // Call all listeners.
+ uno::Sequence< uno::Reference< uno::XInterface > > aListeners(mpRefreshListeners->getElements());
+ sal_uInt32 nLength(aListeners.getLength());
+ if (nLength)
+ {
+ const uno::Reference< uno::XInterface >* pInterfaces = aListeners.getConstArray();
+ if (pInterfaces)
+ {
+ lang::EventObject aEvent;
+ aEvent.Source.set(uno::Reference< util::XRefreshable >(const_cast<ScHeaderFieldsObj*>(this)));
+ sal_uInt32 i(0);
+ while (i < nLength)
+ {
+ try
+ {
+ while(i < nLength)
+ {
+ static_cast< util::XRefreshListener* >(pInterfaces->get())->refreshed(aEvent);
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ catch(uno::RuntimeException&)
+ {
+// DBG_ERROR("a object is gone without to remove from Broadcaster");
+ ++pInterfaces;
+ ++i;
+ }
+ }
+ }
+ }
+ }
+}
+
+void SAL_CALL ScHeaderFieldsObj::addRefreshListener( const uno::Reference< util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ SolarMutexGuard aGuard;
+ if (!mpRefreshListeners)
+ mpRefreshListeners = new cppu::OInterfaceContainerHelper(aMutex);
+ mpRefreshListeners->addInterface(xListener);
+ }
+}
+
+void SAL_CALL ScHeaderFieldsObj::removeRefreshListener( const uno::Reference<util::XRefreshListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ if (xListener.is())
+ {
+ SolarMutexGuard aGuard;
+ if (mpRefreshListeners)
+ mpRefreshListeners->removeInterface(xListener);
+ }
+}
+
+//------------------------------------------------------------------------
+
+SvxFileFormat lcl_UnoToSvxFileFormat( sal_Int16 nUnoValue )
+{
+ switch( nUnoValue )
+ {
+ case text::FilenameDisplayFormat::FULL: return SVXFILEFORMAT_FULLPATH;
+ case text::FilenameDisplayFormat::PATH: return SVXFILEFORMAT_PATH;
+ case text::FilenameDisplayFormat::NAME: return SVXFILEFORMAT_NAME;
+// case text::FilenameDisplayFormat::NAME_AND_EXT:
+ default:
+ return SVXFILEFORMAT_NAME_EXT;
+ }
+}
+
+sal_Int16 lcl_SvxToUnoFileFormat( SvxFileFormat nSvxValue )
+{
+ switch( nSvxValue )
+ {
+ case SVXFILEFORMAT_NAME_EXT: return text::FilenameDisplayFormat::NAME_AND_EXT;
+ case SVXFILEFORMAT_FULLPATH: return text::FilenameDisplayFormat::FULL;
+ case SVXFILEFORMAT_PATH: return text::FilenameDisplayFormat::PATH;
+// case SVXFILEFORMAT_NAME:
+ default:
+ return text::FilenameDisplayFormat::NAME;
+ }
+}
+
+ScHeaderFieldObj::ScHeaderFieldObj(ScHeaderFooterContentObj* pContent, USHORT nP,
+ USHORT nT, const ESelection& rSel) :
+ OComponentHelper( getMutex() ),
+ pPropSet( (nT == SC_SERVICE_FILEFIELD) ? lcl_GetFileFieldPropertySet() : lcl_GetHeaderFieldPropertySet() ),
+ pContentObj( pContent ),
+ nPart( nP ),
+ nType( nT ),
+ aSelection( rSel ),
+ nFileFormat( SVXFILEFORMAT_NAME_EXT )
+{
+ // pContent ist Null, wenn per ServiceProvider erzeugt
+
+ if (pContentObj)
+ {
+ pContentObj->acquire(); // darf nicht wegkommen
+ pEditSource = new ScHeaderFooterEditSource( pContentObj, nPart );
+ }
+ else
+ pEditSource = NULL;
+}
+
+uno::Any SAL_CALL ScHeaderFieldObj::queryAggregation( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( text::XTextField )
+ SC_QUERYINTERFACE( text::XTextContent ) // parent of XTextField
+ SC_QUERYINTERFACE( beans::XPropertySet )
+ SC_QUERYINTERFACE( lang::XUnoTunnel )
+ SC_QUERYINTERFACE( lang::XServiceInfo )
+
+ return OComponentHelper::queryAggregation( rType ); // XComponent
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScHeaderFieldObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aParentTypes(OComponentHelper::getTypes());
+ long nParentLen = aParentTypes.getLength();
+ const uno::Type* pParentPtr = aParentTypes.getConstArray();
+
+ aTypes.realloc( nParentLen + 4 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<text::XTextField>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
+
+ for (long i=0; i<nParentLen; i++)
+ pPtr[i] = pParentPtr[i]; // parent types first
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScHeaderFieldObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+uno::Any SAL_CALL ScHeaderFieldObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ return OComponentHelper::queryInterface( rType );
+}
+
+void SAL_CALL ScHeaderFieldObj::acquire() throw()
+{
+ OComponentHelper::acquire();
+}
+
+void SAL_CALL ScHeaderFieldObj::release() throw()
+{
+ OComponentHelper::release();
+}
+
+void ScHeaderFieldObj::InitDoc( ScHeaderFooterContentObj* pContent, USHORT nP,
+ const ESelection& rSel )
+{
+ if ( pContent && !pEditSource )
+ {
+ DBG_ASSERT( !pContentObj, "ContentObj, aber kein EditSource?" );
+
+ aSelection = rSel;
+ nPart = nP;
+ pContentObj = pContent;
+
+ pContentObj->acquire(); // darf nicht wegkommen
+ pEditSource = new ScHeaderFooterEditSource( pContentObj, nPart );
+ }
+}
+
+ScHeaderFieldObj::~ScHeaderFieldObj()
+{
+ delete pEditSource;
+
+ if (pContentObj)
+ pContentObj->release();
+}
+
+// per getImplementation gerufen:
+
+SvxFieldItem ScHeaderFieldObj::CreateFieldItem()
+{
+ DBG_ASSERT( !pEditSource, "CreateFieldItem mit eingefuegtem Feld" );
+
+ switch (nType)
+ {
+ case SC_SERVICE_PAGEFIELD:
+ {
+ SvxPageField aField;
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ case SC_SERVICE_PAGESFIELD:
+ {
+ SvxPagesField aField;
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ case SC_SERVICE_DATEFIELD:
+ {
+ SvxDateField aField;
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ case SC_SERVICE_TIMEFIELD:
+ {
+ SvxTimeField aField;
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ case SC_SERVICE_TITLEFIELD:
+ {
+ SvxFileField aField;
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ case SC_SERVICE_FILEFIELD:
+ {
+ SvxExtFileField aField;
+ aField.SetFormat( (SvxFileFormat) nFileFormat );
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ case SC_SERVICE_SHEETFIELD:
+ {
+ SvxTableField aField;
+ return SvxFieldItem( aField, EE_FEATURE_FIELD );
+ }
+ }
+
+ return SvxFieldItem( SvxFieldData(), EE_FEATURE_FIELD );
+}
+
+void ScHeaderFieldObj::DeleteField()
+{
+ if (pEditSource)
+ {
+ SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+// pEditEngine->QuickDelete( aSelection );
+ pForwarder->QuickInsertText( String(), aSelection );
+ pEditSource->UpdateData();
+
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos;
+
+ //! Broadcast, um Selektion in anderen Objekten anzupassen
+ //! (auch bei anderen Aktionen)
+ }
+}
+
+// XTextField
+
+rtl::OUString SAL_CALL ScHeaderFieldObj::getPresentation( sal_Bool /* bShowCommand */ )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aRet;
+
+ if (pEditSource)
+ {
+ // Feld von der EditEngine formatieren lassen, bShowCommand gibt's nicht
+
+ SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+ aRet = pForwarder->GetText( aSelection );
+ }
+
+ return aRet;
+}
+
+// XTextContent
+
+void SAL_CALL ScHeaderFieldObj::attach( const uno::Reference<text::XTextRange>& xTextRange )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (xTextRange.is())
+ {
+ uno::Reference<text::XText> xText(xTextRange->getText());
+ if (xText.is())
+ {
+ xText->insertTextContent( xTextRange, this, TRUE );
+ }
+ }
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFieldObj::getAnchor() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pContentObj)
+ {
+ uno::Reference<text::XText> xText;
+ if ( nPart == SC_HDFT_LEFT )
+ xText = pContentObj->getLeftText();
+ else if (nPart == SC_HDFT_CENTER)
+ xText = pContentObj->getCenterText();
+ else
+ xText = pContentObj->getRightText();
+ return uno::Reference<text::XTextRange>( xText, uno::UNO_QUERY );
+ }
+ return NULL;
+}
+
+// XComponent
+
+void SAL_CALL ScHeaderFieldObj::dispose() throw(uno::RuntimeException)
+{
+ OComponentHelper::dispose();
+}
+
+void SAL_CALL ScHeaderFieldObj::addEventListener(
+ const uno::Reference<lang::XEventListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ OComponentHelper::addEventListener( xListener );
+}
+
+void SAL_CALL ScHeaderFieldObj::removeEventListener(
+ const uno::Reference<lang::XEventListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ OComponentHelper::removeEventListener( xListener );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScHeaderFieldObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nType == SC_SERVICE_FILEFIELD)
+ {
+ // file field has different properties
+ static uno::Reference<beans::XPropertySetInfo> aFileFieldInfo = pPropSet->getPropertySetInfo();
+ return aFileFieldInfo;
+ }
+ else
+ {
+ static uno::Reference<beans::XPropertySetInfo> aRef = pPropSet->getPropertySetInfo();
+ return aRef;
+ }
+}
+
+void SAL_CALL ScHeaderFieldObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ if ( nType == SC_SERVICE_FILEFIELD && aNameString.EqualsAscii( SC_UNONAME_FILEFORM ) )
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ {
+ SvxFileFormat eFormat = lcl_UnoToSvxFileFormat( nIntVal );
+ if (pEditSource)
+ {
+ ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+ SvxFieldData* pField = aTempEngine.FindByPos(
+ aSelection.nStartPara, aSelection.nStartPos, TYPE(SvxExtFileField) );
+ DBG_ASSERT(pField,"setPropertyValue: Field not found");
+ if (pField)
+ {
+ SvxExtFileField* pExtFile = (SvxExtFileField*)pField; // local to the ScUnoEditEngine
+ pExtFile->SetFormat( eFormat );
+ pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection );
+ pEditSource->UpdateData();
+ }
+ }
+ else
+ nFileFormat = sal::static_int_cast<sal_Int16>(eFormat); // not inserted yet - store value
+ }
+ }
+}
+
+uno::Any SAL_CALL ScHeaderFieldObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! Properties?
+ uno::Any aRet;
+ String aNameString(aPropertyName);
+
+ // anchor type is always "as character", text wrap always "none"
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_ANCTYPE ) )
+ aRet <<= text::TextContentAnchorType_AS_CHARACTER;
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ANCTYPES ) )
+ {
+ uno::Sequence<text::TextContentAnchorType> aSeq(1);
+ aSeq[0] = text::TextContentAnchorType_AS_CHARACTER;
+ aRet <<= aSeq;
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_TEXTWRAP ) )
+ aRet <<= text::WrapTextMode_NONE;
+ else if ( nType == SC_SERVICE_FILEFIELD && aNameString.EqualsAscii( SC_UNONAME_FILEFORM ) )
+ {
+ SvxFileFormat eFormat = SVXFILEFORMAT_NAME_EXT;
+ if (pEditSource)
+ {
+ ScEditEngineDefaulter* pEditEngine = ((ScHeaderFooterEditSource*)pEditSource)->GetEditEngine();
+ ScUnoEditEngine aTempEngine(pEditEngine);
+ SvxFieldData* pField = aTempEngine.FindByPos(
+ aSelection.nStartPara, aSelection.nStartPos, TYPE(SvxExtFileField) );
+ DBG_ASSERT(pField,"setPropertyValue: Field not found");
+ if (pField)
+ {
+ const SvxExtFileField* pExtFile = (const SvxExtFileField*)pField;
+ eFormat = pExtFile->GetFormat();
+ }
+ }
+ else
+ eFormat = (SvxFileFormat) nFileFormat; // not inserted yet - use stored value
+
+ sal_Int16 nIntVal = lcl_SvxToUnoFileFormat( eFormat );
+ aRet <<= nIntVal;
+ }
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScHeaderFieldObj )
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScHeaderFieldObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScHeaderFieldObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScHeaderFieldObj* ScHeaderFieldObj::getImplementation(
+ const uno::Reference<text::XTextContent> xObj )
+{
+ ScHeaderFieldObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScHeaderFieldObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScHeaderFieldObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScHeaderFieldObj" );
+}
+
+sal_Bool SAL_CALL ScHeaderFieldObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCTEXTFIELD_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCTEXTCONTENT_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScHeaderFieldObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCTEXTFIELD_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCTEXTCONTENT_SERVICE );
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
new file mode 100644
index 000000000000..d12859b95db9
--- /dev/null
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -0,0 +1,314 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <tools/urlobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include "editutil.hxx"
+#include "filtuno.hxx"
+#include "miscuno.hxx"
+#include "scdll.hxx"
+#include "imoptdlg.hxx"
+#include "asciiopt.hxx"
+#include "docsh.hxx"
+#include "globstr.hrc"
+
+
+#include "sc.hrc"
+#include "scabstdlg.hxx"
+#include "i18npool/lang.h"
+
+#include <memory>
+
+using namespace ::com::sun::star;
+using ::rtl::OUStringBuffer;
+
+//------------------------------------------------------------------------
+
+#define SCFILTEROPTIONSOBJ_SERVICE "com.sun.star.ui.dialogs.FilterOptionsDialog"
+#define SCFILTEROPTIONSOBJ_IMPLNAME "com.sun.star.comp.Calc.FilterOptionsDialog"
+
+SC_SIMPLE_SERVICE_INFO( ScFilterOptionsObj, SCFILTEROPTIONSOBJ_IMPLNAME, SCFILTEROPTIONSOBJ_SERVICE )
+
+#define SC_UNONAME_FILENAME "URL"
+#define SC_UNONAME_FILTERNAME "FilterName"
+#define SC_UNONAME_FILTEROPTIONS "FilterOptions"
+#define SC_UNONAME_INPUTSTREAM "InputStream"
+
+//------------------------------------------------------------------------
+
+ScFilterOptionsObj::ScFilterOptionsObj() :
+ bExport( sal_False )
+{
+}
+
+ScFilterOptionsObj::~ScFilterOptionsObj()
+{
+}
+
+// stuff for exService_...
+
+uno::Reference<uno::XInterface> SAL_CALL ScFilterOptionsObj_CreateInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ return (::cppu::OWeakObject*) new ScFilterOptionsObj;
+}
+
+rtl::OUString ScFilterOptionsObj::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii( SCFILTEROPTIONSOBJ_IMPLNAME );
+}
+
+uno::Sequence<rtl::OUString> ScFilterOptionsObj::getSupportedServiceNames_Static()
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCFILTEROPTIONSOBJ_SERVICE );
+ return aRet;
+}
+
+// XPropertyAccess
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScFilterOptionsObj::getPropertyValues() throw(uno::RuntimeException)
+{
+ uno::Sequence<beans::PropertyValue> aRet(1);
+ beans::PropertyValue* pArray = aRet.getArray();
+
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_FILTEROPTIONS );
+ pArray[0].Value <<= aFilterOptions;
+
+ return aRet;
+}
+
+void SAL_CALL ScFilterOptionsObj::setPropertyValues( const uno::Sequence<beans::PropertyValue>& aProps )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ const beans::PropertyValue* pPropArray = aProps.getConstArray();
+ long nPropCount = aProps.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName(rProp.Name);
+
+ if ( aPropName.EqualsAscii( SC_UNONAME_FILENAME ) )
+ rProp.Value >>= aFileName;
+ else if ( aPropName.EqualsAscii( SC_UNONAME_FILTERNAME ) )
+ rProp.Value >>= aFilterName;
+ else if ( aPropName.EqualsAscii( SC_UNONAME_FILTEROPTIONS ) )
+ rProp.Value >>= aFilterOptions;
+ else if ( aPropName.EqualsAscii( SC_UNONAME_INPUTSTREAM ) )
+ rProp.Value >>= xInputStream;
+ }
+}
+
+// XExecutableDialog
+
+void SAL_CALL ScFilterOptionsObj::setTitle( const ::rtl::OUString& /* aTitle */ ) throw(uno::RuntimeException)
+{
+ // not used
+}
+
+sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException)
+{
+ sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
+
+ String aFilterString( aFilterName );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ if ( !bExport && aFilterString == ScDocShell::GetAsciiFilterName() )
+ {
+ // ascii import is special...
+
+ INetURLObject aURL( aFileName );
+ String aExt(aURL.getExtension());
+ String aPrivDatName(aURL.getName());
+ sal_Unicode cAsciiDel;
+ if (aExt.EqualsIgnoreCaseAscii("CSV"))
+ cAsciiDel = ',';
+ else
+ cAsciiDel = '\t';
+
+ SvStream* pInStream = NULL;
+ if ( xInputStream.is() )
+ pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
+
+ AbstractScImportAsciiDlg* pDlg = pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream, RID_SCDLG_ASCII, cAsciiDel);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ ScAsciiOptions aOptions;
+ pDlg->GetOptions( aOptions );
+ pDlg->SaveParameters();
+ aFilterOptions = aOptions.WriteToString();
+ nRet = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ delete pDlg;
+ delete pInStream;
+ }
+ else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() )
+ {
+ if (bExport)
+ nRet = ui::dialogs::ExecutableDialogResults::OK; // export HTML without dialog
+ else
+ {
+ // HTML import.
+ ::std::auto_ptr<AbstractScTextImportOptionsDlg> pDlg(
+ pFact->CreateScTextImportOptionsDlg(NULL, RID_SCDLG_TEXT_IMPORT_OPTIONS));
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ LanguageType eLang = pDlg->GetLanguageType();
+ OUStringBuffer aBuf;
+
+ aBuf.append(String::CreateFromInt32(static_cast<sal_Int32>(eLang)));
+ aBuf.append(sal_Unicode(' '));
+ aBuf.append(pDlg->IsDateConversionSet() ? sal_Unicode('1') : sal_Unicode('0'));
+ aFilterOptions = aBuf.makeStringAndClear();
+ nRet = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ }
+ }
+ else
+ {
+ sal_Bool bMultiByte = sal_True;
+ sal_Bool bDBEnc = sal_False;
+ sal_Bool bAscii = sal_False;
+
+ sal_Unicode cStrDel = '"';
+ sal_Unicode cAsciiDel = ';';
+ rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW;
+
+ String aTitle;
+
+ if ( aFilterString == ScDocShell::GetAsciiFilterName() )
+ {
+ // ascii export (import is handled above)
+
+ INetURLObject aURL( aFileName );
+ String aExt(aURL.getExtension());
+ if (aExt.EqualsIgnoreCaseAscii("CSV"))
+ cAsciiDel = ',';
+ else
+ cAsciiDel = '\t';
+
+ aTitle = ScGlobal::GetRscString( STR_EXPORT_ASCII );
+ bAscii = sal_True;
+ }
+ else if ( aFilterString == ScDocShell::GetLotusFilterName() )
+ {
+ // lotus is only imported
+ DBG_ASSERT( !bExport, "Filter Options for Lotus Export is not implemented" );
+
+ aTitle = ScGlobal::GetRscString( STR_IMPORT_LOTUS );
+ eEncoding = RTL_TEXTENCODING_IBM_437;
+ }
+ else if ( aFilterString == ScDocShell::GetDBaseFilterName() )
+ {
+ if ( bExport )
+ {
+ // dBase export
+ aTitle = ScGlobal::GetRscString( STR_EXPORT_DBF );
+ }
+ else
+ {
+ // dBase import
+ aTitle = ScGlobal::GetRscString( STR_IMPORT_DBF );
+ }
+ // common for dBase import/export
+ eEncoding = RTL_TEXTENCODING_IBM_850;
+ bDBEnc = sal_True;
+ }
+ else if ( aFilterString == ScDocShell::GetDifFilterName() )
+ {
+ if ( bExport )
+ {
+ // DIF export
+ aTitle = ScGlobal::GetRscString( STR_EXPORT_DIF );
+ }
+ else
+ {
+ // DIF import
+ aTitle = ScGlobal::GetRscString( STR_IMPORT_DIF );
+ }
+ // common for DIF import/export
+ eEncoding = RTL_TEXTENCODING_MS_1252;
+ }
+
+ ScImportOptions aOptions( cAsciiDel, cStrDel, eEncoding);
+
+ AbstractScImportOptionsDlg* pDlg = pFact->CreateScImportOptionsDlg( NULL, RID_SCDLG_IMPORTOPT,
+ bAscii, &aOptions, &aTitle, bMultiByte, bDBEnc,
+ !bExport);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ pDlg->GetImportOptions( aOptions );
+ if ( bAscii )
+ aFilterOptions = aOptions.BuildString();
+ else
+ aFilterOptions = aOptions.aStrFont;
+ nRet = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ delete pDlg;
+ }
+
+ xInputStream.clear(); // don't hold the stream longer than necessary
+
+ return nRet;
+}
+
+// XImporter
+
+void SAL_CALL ScFilterOptionsObj::setTargetDocument( const uno::Reference<lang::XComponent>& /* xDoc */ )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ bExport = sal_False;
+}
+
+// XExporter
+
+void SAL_CALL ScFilterOptionsObj::setSourceDocument( const uno::Reference<lang::XComponent>& /* xDoc */ )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ bExport = sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx
new file mode 100644
index 000000000000..56ba41e1bc40
--- /dev/null
+++ b/sc/source/ui/unoobj/fmtuno.cxx
@@ -0,0 +1,1063 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <tools/debug.hxx>
+#include <rtl/uuid.h>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
+
+#include "fmtuno.hxx"
+#include "miscuno.hxx"
+#include "validat.hxx"
+#include "document.hxx"
+#include "unonames.hxx"
+#include "styleuno.hxx" // ScStyleNameConversion
+#include "tokenarray.hxx"
+#include "tokenuno.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::formula;
+
+//------------------------------------------------------------------------
+
+// Map nur fuer PropertySetInfo
+
+const SfxItemPropertyMapEntry* lcl_GetValidatePropertyMap()
+{
+ static SfxItemPropertyMapEntry aValidatePropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ERRALSTY), 0, &getCppuType((sheet::ValidationAlertStyle*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ERRMESS), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_ERRTITLE), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_IGNOREBL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_INPMESS), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_INPTITLE), 0, &getCppuType((rtl::OUString*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SHOWERR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SHOWINP), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_SHOWLIST), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNONAME_TYPE), 0, &getCppuType((sheet::ValidationType*)0), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aValidatePropertyMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScTableConditionalEntry, "ScTableConditionalEntry", "com.sun.star.sheet.TableConditionalEntry" )
+SC_SIMPLE_SERVICE_INFO( ScTableConditionalFormat, "ScTableConditionalFormat", "com.sun.star.sheet.TableConditionalFormat" )
+SC_SIMPLE_SERVICE_INFO( ScTableValidationObj, "ScTableValidationObj", "com.sun.star.sheet.TableValidation" )
+
+//------------------------------------------------------------------------
+
+sheet::ConditionOperator lcl_ConditionModeToOperator( ScConditionMode eMode )
+{
+ sheet::ConditionOperator eOper = sheet::ConditionOperator_NONE;
+ switch (eMode)
+ {
+ case SC_COND_EQUAL: eOper = sheet::ConditionOperator_EQUAL; break;
+ case SC_COND_LESS: eOper = sheet::ConditionOperator_LESS; break;
+ case SC_COND_GREATER: eOper = sheet::ConditionOperator_GREATER; break;
+ case SC_COND_EQLESS: eOper = sheet::ConditionOperator_LESS_EQUAL; break;
+ case SC_COND_EQGREATER: eOper = sheet::ConditionOperator_GREATER_EQUAL; break;
+ case SC_COND_NOTEQUAL: eOper = sheet::ConditionOperator_NOT_EQUAL; break;
+ case SC_COND_BETWEEN: eOper = sheet::ConditionOperator_BETWEEN; break;
+ case SC_COND_NOTBETWEEN: eOper = sheet::ConditionOperator_NOT_BETWEEN; break;
+ case SC_COND_DIRECT: eOper = sheet::ConditionOperator_FORMULA; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return eOper;
+}
+
+ScConditionMode lcl_ConditionOperatorToMode( sheet::ConditionOperator eOper )
+{
+ ScConditionMode eMode = SC_COND_NONE;
+ switch (eOper)
+ {
+ case sheet::ConditionOperator_EQUAL: eMode = SC_COND_EQUAL; break;
+ case sheet::ConditionOperator_LESS: eMode = SC_COND_LESS; break;
+ case sheet::ConditionOperator_GREATER: eMode = SC_COND_GREATER; break;
+ case sheet::ConditionOperator_LESS_EQUAL: eMode = SC_COND_EQLESS; break;
+ case sheet::ConditionOperator_GREATER_EQUAL: eMode = SC_COND_EQGREATER; break;
+ case sheet::ConditionOperator_NOT_EQUAL: eMode = SC_COND_NOTEQUAL; break;
+ case sheet::ConditionOperator_BETWEEN: eMode = SC_COND_BETWEEN; break;
+ case sheet::ConditionOperator_NOT_BETWEEN: eMode = SC_COND_NOTBETWEEN; break;
+ case sheet::ConditionOperator_FORMULA: eMode = SC_COND_DIRECT; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return eMode;
+}
+
+//------------------------------------------------------------------------
+
+ScCondFormatEntryItem::ScCondFormatEntryItem() :
+ meGrammar1( FormulaGrammar::GRAM_UNSPECIFIED ),
+ meGrammar2( FormulaGrammar::GRAM_UNSPECIFIED ),
+ meMode( SC_COND_NONE )
+{
+}
+
+//------------------------------------------------------------------------
+
+ScTableConditionalFormat::ScTableConditionalFormat(
+ ScDocument* pDoc, ULONG nKey, FormulaGrammar::Grammar eGrammar)
+{
+ // Eintrag aus dem Dokument lesen...
+
+ if ( pDoc && nKey )
+ {
+ ScConditionalFormatList* pList = pDoc->GetCondFormList();
+ if (pList)
+ {
+ const ScConditionalFormat* pFormat = pList->GetFormat( nKey );
+ if (pFormat)
+ {
+ // During save to XML.
+ if (pDoc->IsInExternalReferenceMarking())
+ pFormat->MarkUsedExternalReferences();
+
+ USHORT nEntryCount = pFormat->Count();
+ for (USHORT i=0; i<nEntryCount; i++)
+ {
+ ScCondFormatEntryItem aItem;
+ const ScCondFormatEntry* pFormatEntry = pFormat->GetEntry(i);
+ aItem.meMode = pFormatEntry->GetOperation();
+ aItem.maPos = pFormatEntry->GetValidSrcPos();
+ aItem.maExpr1 = pFormatEntry->GetExpression(aItem.maPos, 0, 0, eGrammar);
+ aItem.maExpr2 = pFormatEntry->GetExpression(aItem.maPos, 1, 0, eGrammar);
+ aItem.meGrammar1 = aItem.meGrammar2 = eGrammar;
+ aItem.maStyle = pFormatEntry->GetStyle();
+
+ AddEntry_Impl(aItem);
+ }
+ }
+ }
+ }
+}
+
+namespace {
+
+FormulaGrammar::Grammar lclResolveGrammar( FormulaGrammar::Grammar eExtGrammar, FormulaGrammar::Grammar eIntGrammar )
+{
+ if( eExtGrammar != FormulaGrammar::GRAM_UNSPECIFIED )
+ return eExtGrammar;
+ OSL_ENSURE( eIntGrammar != FormulaGrammar::GRAM_UNSPECIFIED, "lclResolveGrammar - unspecified grammar, using GRAM_PODF_A1" );
+ return (eIntGrammar == FormulaGrammar::GRAM_UNSPECIFIED) ? FormulaGrammar::GRAM_PODF_A1 : eIntGrammar;
+}
+
+} // namespace
+
+void ScTableConditionalFormat::FillFormat( ScConditionalFormat& rFormat,
+ ScDocument* pDoc, FormulaGrammar::Grammar eGrammar) const
+{
+ // ScConditionalFormat = Core-Struktur, muss leer sein
+
+ DBG_ASSERT( rFormat.IsEmpty(), "FillFormat: Format nicht leer" );
+ USHORT nCount = (USHORT)aEntries.Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScTableConditionalEntry* pEntry = (ScTableConditionalEntry*)aEntries.GetObject(i);
+ if ( !pEntry )
+ continue;
+
+ ScCondFormatEntryItem aData;
+ pEntry->GetData(aData);
+
+ FormulaGrammar::Grammar eGrammar1 = lclResolveGrammar( eGrammar, aData.meGrammar1 );
+ FormulaGrammar::Grammar eGrammar2 = lclResolveGrammar( eGrammar, aData.meGrammar2 );
+
+ ScCondFormatEntry aCoreEntry( aData.meMode, aData.maExpr1, aData.maExpr2,
+ pDoc, aData.maPos, aData.maStyle, aData.maExprNmsp1, aData.maExprNmsp2, eGrammar1, eGrammar2 );
+
+ if ( aData.maPosStr.Len() )
+ aCoreEntry.SetSrcString( aData.maPosStr );
+
+ if ( aData.maTokens1.getLength() )
+ {
+ ScTokenArray aTokenArray;
+ if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aData.maTokens1) )
+ aCoreEntry.SetFormula1(aTokenArray);
+ }
+
+ if ( aData.maTokens2.getLength() )
+ {
+ ScTokenArray aTokenArray;
+ if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aData.maTokens2) )
+ aCoreEntry.SetFormula2(aTokenArray);
+ }
+ rFormat.AddEntry( aCoreEntry );
+ }
+}
+
+ScTableConditionalFormat::~ScTableConditionalFormat()
+{
+ ScTableConditionalEntry* pEntry;
+ aEntries.First();
+ while ( ( pEntry = (ScTableConditionalEntry*)aEntries.Remove() ) != NULL )
+ pEntry->release();
+}
+
+void ScTableConditionalFormat::AddEntry_Impl(const ScCondFormatEntryItem& aEntry)
+{
+ ScTableConditionalEntry* pNew = new ScTableConditionalEntry(this, aEntry);
+ pNew->acquire();
+ aEntries.Insert( pNew, LIST_APPEND );
+}
+
+void ScTableConditionalFormat::DataChanged()
+{
+ // wenn's mal das "lebende Objekt" ist, muss hier was passieren...
+}
+
+// XSheetConditionalFormat
+
+ScTableConditionalEntry* ScTableConditionalFormat::GetObjectByIndex_Impl(USHORT nIndex) const
+{
+ return (ScTableConditionalEntry*)aEntries.GetObject(nIndex);
+}
+
+void SAL_CALL ScTableConditionalFormat::addNew(
+ const uno::Sequence<beans::PropertyValue >& aConditionalEntry )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScCondFormatEntryItem aEntry;
+ aEntry.meMode = SC_COND_NONE;
+
+ const beans::PropertyValue* pPropArray = aConditionalEntry.getConstArray();
+ long nPropCount = aConditionalEntry.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+
+ if ( rProp.Name.equalsAscii( SC_UNONAME_OPERATOR ) )
+ {
+ sheet::ConditionOperator eOper = (sheet::ConditionOperator)
+ ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
+ aEntry.meMode = lcl_ConditionOperatorToMode( eOper );
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_FORMULA1 ) )
+ {
+ rtl::OUString aStrVal;
+ uno::Sequence<sheet::FormulaToken> aTokens;
+ if ( rProp.Value >>= aStrVal )
+ aEntry.maExpr1 = aStrVal;
+ else if ( rProp.Value >>= aTokens )
+ {
+ aEntry.maExpr1.Erase();
+ aEntry.maTokens1 = aTokens;
+ }
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_FORMULA2 ) )
+ {
+ rtl::OUString aStrVal;
+ uno::Sequence<sheet::FormulaToken> aTokens;
+ if ( rProp.Value >>= aStrVal )
+ aEntry.maExpr2 = aStrVal;
+ else if ( rProp.Value >>= aTokens )
+ {
+ aEntry.maExpr2.Erase();
+ aEntry.maTokens2 = aTokens;
+ }
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_SOURCEPOS ) )
+ {
+ table::CellAddress aAddress;
+ if ( rProp.Value >>= aAddress )
+ aEntry.maPos = ScAddress( (SCCOL)aAddress.Column, (SCROW)aAddress.Row, aAddress.Sheet );
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_SOURCESTR ) )
+ {
+ rtl::OUString aStrVal;
+ if ( rProp.Value >>= aStrVal )
+ aEntry.maPosStr = String( aStrVal );
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_STYLENAME ) )
+ {
+ rtl::OUString aStrVal;
+ if ( rProp.Value >>= aStrVal )
+ aEntry.maStyle = ScStyleNameConversion::ProgrammaticToDisplayName(
+ aStrVal, SFX_STYLE_FAMILY_PARA );
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_FORMULANMSP1 ) )
+ {
+ rtl::OUString aStrVal;
+ if ( rProp.Value >>= aStrVal )
+ aEntry.maExprNmsp1 = aStrVal;
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_FORMULANMSP2 ) )
+ {
+ rtl::OUString aStrVal;
+ if ( rProp.Value >>= aStrVal )
+ aEntry.maExprNmsp2 = aStrVal;
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_GRAMMAR1 ) )
+ {
+ sal_Int32 nVal = 0;
+ if ( rProp.Value >>= nVal )
+ aEntry.meGrammar1 = static_cast< FormulaGrammar::Grammar >( nVal );
+ }
+ else if ( rProp.Name.equalsAscii( SC_UNONAME_GRAMMAR2 ) )
+ {
+ sal_Int32 nVal = 0;
+ if ( rProp.Value >>= nVal )
+ aEntry.meGrammar2 = static_cast< FormulaGrammar::Grammar >( nVal );
+ }
+ else
+ {
+ DBG_ERROR("falsche Property");
+ //! Exception...
+ }
+ }
+
+ AddEntry_Impl(aEntry);
+ DataChanged();
+}
+
+void SAL_CALL ScTableConditionalFormat::removeByIndex( sal_Int32 nIndex )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTableConditionalEntry* pEntry = (ScTableConditionalEntry*)aEntries.GetObject(nIndex);
+ if (pEntry)
+ {
+ aEntries.Remove(pEntry);
+ pEntry->release();
+ DataChanged();
+ }
+}
+
+void SAL_CALL ScTableConditionalFormat::clear() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTableConditionalEntry* pEntry;
+ aEntries.First();
+ while ( ( pEntry = (ScTableConditionalEntry*)aEntries.Remove() ) != NULL )
+ pEntry->release();
+
+ DataChanged();
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScTableConditionalFormat::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.TableConditionalEntryEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScTableConditionalFormat::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aEntries.Count();
+}
+
+uno::Any SAL_CALL ScTableConditionalFormat::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XSheetConditionalEntry> xEntry(GetObjectByIndex_Impl((USHORT)nIndex));
+ if (xEntry.is())
+ return uno::makeAny(xEntry);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScTableConditionalFormat::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XSheetConditionalEntry>*)0);
+}
+
+sal_Bool SAL_CALL ScTableConditionalFormat::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// conditional format entries have no real names
+// -> generate name from index
+
+rtl::OUString lcl_GetEntryNameFromIndex( sal_Int32 nIndex )
+{
+ rtl::OUString aRet( RTL_CONSTASCII_USTRINGPARAM( "Entry" ) );
+ aRet += rtl::OUString::valueOf( nIndex );
+ return aRet;
+}
+
+uno::Any SAL_CALL ScTableConditionalFormat::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<sheet::XSheetConditionalEntry> xEntry;
+ long nCount = aEntries.Count();
+ for (long i=0; i<nCount; i++)
+ if ( aName == lcl_GetEntryNameFromIndex(i) )
+ {
+ xEntry.set(GetObjectByIndex_Impl((USHORT)i));
+ break;
+ }
+
+ if (xEntry.is())
+ return uno::makeAny(xEntry);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScTableConditionalFormat::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ long nCount = aEntries.Count();
+ uno::Sequence<rtl::OUString> aNames(nCount);
+ rtl::OUString* pArray = aNames.getArray();
+ for (long i=0; i<nCount; i++)
+ pArray[i] = lcl_GetEntryNameFromIndex(i);
+
+ return aNames;
+}
+
+sal_Bool SAL_CALL ScTableConditionalFormat::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ long nCount = aEntries.Count();
+ for (long i=0; i<nCount; i++)
+ if ( aName == lcl_GetEntryNameFromIndex(i) )
+ return TRUE;
+
+ return FALSE;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScTableConditionalFormat::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScTableConditionalFormat::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScTableConditionalFormat* ScTableConditionalFormat::getImplementation(
+ const uno::Reference<sheet::XSheetConditionalEntries> xObj )
+{
+ ScTableConditionalFormat* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScTableConditionalFormat*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScTableConditionalEntry::ScTableConditionalEntry(ScTableConditionalFormat* pPar,
+ const ScCondFormatEntryItem& aItem) :
+ pParent( pPar ),
+ aData( aItem )
+{
+ if (pParent)
+ pParent->acquire();
+}
+
+ScTableConditionalEntry::~ScTableConditionalEntry()
+{
+ if (pParent)
+ pParent->release();
+}
+
+void ScTableConditionalEntry::GetData(ScCondFormatEntryItem& rData) const
+{
+ rData = aData;
+}
+
+// XSheetCondition
+
+sheet::ConditionOperator SAL_CALL ScTableConditionalEntry::getOperator()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return lcl_ConditionModeToOperator( aData.meMode );
+}
+
+void SAL_CALL ScTableConditionalEntry::setOperator( sheet::ConditionOperator nOperator )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aData.meMode = lcl_ConditionOperatorToMode( nOperator );
+ if (pParent)
+ pParent->DataChanged();
+}
+
+rtl::OUString SAL_CALL ScTableConditionalEntry::getFormula1() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aData.maExpr1;
+}
+
+void SAL_CALL ScTableConditionalEntry::setFormula1( const rtl::OUString& aFormula1 )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aData.maExpr1 = String( aFormula1 );
+ if (pParent)
+ pParent->DataChanged();
+}
+
+rtl::OUString SAL_CALL ScTableConditionalEntry::getFormula2() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aData.maExpr2;
+}
+
+void SAL_CALL ScTableConditionalEntry::setFormula2( const rtl::OUString& aFormula2 )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aData.maExpr2 = String( aFormula2 );
+ if (pParent)
+ pParent->DataChanged();
+}
+
+table::CellAddress SAL_CALL ScTableConditionalEntry::getSourcePosition() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellAddress aRet;
+ aRet.Column = aData.maPos.Col();
+ aRet.Row = aData.maPos.Row();
+ aRet.Sheet = aData.maPos.Tab();
+ return aRet;
+}
+
+void SAL_CALL ScTableConditionalEntry::setSourcePosition( const table::CellAddress& aSourcePosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aData.maPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet );
+ if (pParent)
+ pParent->DataChanged();
+}
+
+// XSheetConditionalEntry
+
+rtl::OUString SAL_CALL ScTableConditionalEntry::getStyleName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ScStyleNameConversion::DisplayToProgrammaticName( aData.maStyle, SFX_STYLE_FAMILY_PARA );
+}
+
+void SAL_CALL ScTableConditionalEntry::setStyleName( const rtl::OUString& aStyleName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aData.maStyle = ScStyleNameConversion::ProgrammaticToDisplayName( aStyleName, SFX_STYLE_FAMILY_PARA );
+ if (pParent)
+ pParent->DataChanged();
+}
+
+//------------------------------------------------------------------------
+
+ScTableValidationObj::ScTableValidationObj(ScDocument* pDoc, ULONG nKey,
+ const formula::FormulaGrammar::Grammar eGrammar) :
+ aPropSet( lcl_GetValidatePropertyMap() )
+{
+ // Eintrag aus dem Dokument lesen...
+
+ BOOL bFound = FALSE;
+ if ( pDoc && nKey )
+ {
+ const ScValidationData* pData = pDoc->GetValidationEntry( nKey );
+ if (pData)
+ {
+ nMode = sal::static_int_cast<USHORT>( pData->GetOperation() );
+ aSrcPos = pData->GetValidSrcPos(); // #b4974740# valid pos for expressions
+ aExpr1 = pData->GetExpression( aSrcPos, 0, 0, eGrammar );
+ aExpr2 = pData->GetExpression( aSrcPos, 1, 0, eGrammar );
+ meGrammar1 = meGrammar2 = eGrammar;
+ nValMode = sal::static_int_cast<USHORT>( pData->GetDataMode() );
+ bIgnoreBlank = pData->IsIgnoreBlank();
+ nShowList = pData->GetListType();
+ bShowInput = pData->GetInput( aInputTitle, aInputMessage );
+ ScValidErrorStyle eStyle;
+ bShowError = pData->GetErrMsg( aErrorTitle, aErrorMessage, eStyle );
+ nErrorStyle = sal::static_int_cast<USHORT>( eStyle );
+
+ // During save to XML, sheet::ValidationType_ANY formulas are not
+ // saved, even if in the list, see
+ // ScMyValidationsContainer::GetCondition(), so shall not mark
+ // anything in use.
+ if (nValMode != SC_VALID_ANY && pDoc->IsInExternalReferenceMarking())
+ pData->MarkUsedExternalReferences();
+
+ bFound = TRUE;
+ }
+ }
+ if (!bFound)
+ ClearData_Impl(); // Defaults
+}
+
+ScValidationData* ScTableValidationObj::CreateValidationData( ScDocument* pDoc,
+ formula::FormulaGrammar::Grammar eGrammar ) const
+{
+ // ScValidationData = Core-Struktur
+
+ FormulaGrammar::Grammar eGrammar1 = lclResolveGrammar( eGrammar, meGrammar1 );
+ FormulaGrammar::Grammar eGrammar2 = lclResolveGrammar( eGrammar, meGrammar2 );
+
+ ScValidationData* pRet = new ScValidationData( (ScValidationMode)nValMode,
+ (ScConditionMode)nMode,
+ aExpr1, aExpr2, pDoc, aSrcPos,
+ maExprNmsp1, maExprNmsp2,
+ eGrammar1, eGrammar2 );
+ pRet->SetIgnoreBlank(bIgnoreBlank);
+ pRet->SetListType(nShowList);
+
+ if ( aTokens1.getLength() )
+ {
+ ScTokenArray aTokenArray;
+ if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aTokens1) )
+ pRet->SetFormula1(aTokenArray);
+ }
+
+ if ( aTokens2.getLength() )
+ {
+ ScTokenArray aTokenArray;
+ if ( ScTokenConversion::ConvertToTokenArray(*pDoc, aTokenArray, aTokens2) )
+ pRet->SetFormula2(aTokenArray);
+ }
+
+ // set strings for error / input even if disabled (and disable afterwards)
+ pRet->SetInput( aInputTitle, aInputMessage );
+ if (!bShowInput)
+ pRet->ResetInput();
+ pRet->SetError( aErrorTitle, aErrorMessage, (ScValidErrorStyle)nErrorStyle );
+ if (!bShowError)
+ pRet->ResetError();
+
+ if ( aPosString.Len() )
+ pRet->SetSrcString( aPosString );
+
+ return pRet;
+}
+
+void ScTableValidationObj::ClearData_Impl()
+{
+ nMode = SC_COND_NONE;
+ nValMode = SC_VALID_ANY;
+ bIgnoreBlank = TRUE;
+ nShowList = sheet::TableValidationVisibility::UNSORTED;
+ bShowInput = FALSE;
+ bShowError = FALSE;
+ nErrorStyle = SC_VALERR_STOP;
+ aSrcPos.Set(0,0,0);
+ aExpr1.Erase();
+ aExpr2.Erase();
+ maExprNmsp1.Erase();
+ maExprNmsp2.Erase();
+ meGrammar1 = meGrammar2 = FormulaGrammar::GRAM_UNSPECIFIED; // will be overriden when needed
+ aInputTitle.Erase();
+ aInputMessage.Erase();
+ aErrorTitle.Erase();
+ aErrorMessage.Erase();
+}
+
+ScTableValidationObj::~ScTableValidationObj()
+{
+}
+
+void ScTableValidationObj::DataChanged()
+{
+ // wenn's mal das "lebende Objekt" ist, muss hier was passieren...
+}
+
+// XSheetCondition
+
+sheet::ConditionOperator SAL_CALL ScTableValidationObj::getOperator()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return lcl_ConditionModeToOperator( (ScConditionMode)nMode );
+}
+
+void SAL_CALL ScTableValidationObj::setOperator( sheet::ConditionOperator nOperator )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ nMode = sal::static_int_cast<USHORT>( lcl_ConditionOperatorToMode( nOperator ) );
+ DataChanged();
+}
+
+rtl::OUString SAL_CALL ScTableValidationObj::getFormula1() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aExpr1;
+}
+
+void SAL_CALL ScTableValidationObj::setFormula1( const rtl::OUString& aFormula1 )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aExpr1 = String( aFormula1 );
+ DataChanged();
+}
+
+rtl::OUString SAL_CALL ScTableValidationObj::getFormula2() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aExpr2;
+}
+
+void SAL_CALL ScTableValidationObj::setFormula2( const rtl::OUString& aFormula2 )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aExpr2 = String( aFormula2 );
+ DataChanged();
+}
+
+table::CellAddress SAL_CALL ScTableValidationObj::getSourcePosition() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellAddress aRet;
+ aRet.Column = aSrcPos.Col();
+ aRet.Row = aSrcPos.Row();
+ aRet.Sheet = aSrcPos.Tab();
+ return aRet;
+}
+
+void SAL_CALL ScTableValidationObj::setSourcePosition( const table::CellAddress& aSourcePosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ aSrcPos.Set( (SCCOL)aSourcePosition.Column, (SCROW)aSourcePosition.Row, aSourcePosition.Sheet );
+ DataChanged();
+}
+
+uno::Sequence<sheet::FormulaToken> SAL_CALL ScTableValidationObj::getTokens( sal_Int32 nIndex )
+ throw(uno::RuntimeException,lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ if (nIndex >= 2 || nIndex < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ return nIndex == 0 ? aTokens1 : aTokens2;
+}
+
+void SAL_CALL ScTableValidationObj::setTokens( sal_Int32 nIndex, const uno::Sequence<sheet::FormulaToken>& aTokens )
+ throw(uno::RuntimeException,lang::IndexOutOfBoundsException)
+{
+ SolarMutexGuard aGuard;
+ if (nIndex >= 2 || nIndex < 0)
+ throw lang::IndexOutOfBoundsException();
+
+ if (nIndex == 0)
+ {
+ aTokens1 = aTokens;
+ aExpr1.Erase();
+ }
+ else if (nIndex == 1)
+ {
+ aTokens2 = aTokens;
+ aExpr2.Erase();
+ }
+}
+
+sal_Int32 SAL_CALL ScTableValidationObj::getCount() throw(uno::RuntimeException)
+{
+ return 2;
+}
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTableValidationObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScTableValidationObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+
+ if ( aString.EqualsAscii( SC_UNONAME_SHOWINP ) ) bShowInput = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if ( aString.EqualsAscii( SC_UNONAME_SHOWERR ) ) bShowError = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if ( aString.EqualsAscii( SC_UNONAME_IGNOREBL ) ) bIgnoreBlank = ScUnoHelpFunctions::GetBoolFromAny( aValue );
+ else if ( aString.EqualsAscii( SC_UNONAME_SHOWLIST ) ) aValue >>= nShowList;
+ else if ( aString.EqualsAscii( SC_UNONAME_INPTITLE ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ aInputTitle = String( aStrVal );
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_INPMESS ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ aInputMessage = String( aStrVal );
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_ERRTITLE ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ aErrorTitle = String( aStrVal );
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_ERRMESS ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ aErrorMessage = String( aStrVal );
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_TYPE ) )
+ {
+ sheet::ValidationType eType = (sheet::ValidationType)
+ ScUnoHelpFunctions::GetEnumFromAny( aValue );
+ switch (eType)
+ {
+ case sheet::ValidationType_ANY: nValMode = SC_VALID_ANY; break;
+ case sheet::ValidationType_WHOLE: nValMode = SC_VALID_WHOLE; break;
+ case sheet::ValidationType_DECIMAL: nValMode = SC_VALID_DECIMAL; break;
+ case sheet::ValidationType_DATE: nValMode = SC_VALID_DATE; break;
+ case sheet::ValidationType_TIME: nValMode = SC_VALID_TIME; break;
+ case sheet::ValidationType_TEXT_LEN: nValMode = SC_VALID_TEXTLEN; break;
+ case sheet::ValidationType_LIST: nValMode = SC_VALID_LIST; break;
+ case sheet::ValidationType_CUSTOM: nValMode = SC_VALID_CUSTOM; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_ERRALSTY ) )
+ {
+ sheet::ValidationAlertStyle eStyle = (sheet::ValidationAlertStyle)
+ ScUnoHelpFunctions::GetEnumFromAny( aValue );
+ switch (eStyle)
+ {
+ case sheet::ValidationAlertStyle_STOP: nErrorStyle = SC_VALERR_STOP; break;
+ case sheet::ValidationAlertStyle_WARNING: nErrorStyle = SC_VALERR_WARNING; break;
+ case sheet::ValidationAlertStyle_INFO: nErrorStyle = SC_VALERR_INFO; break;
+ case sheet::ValidationAlertStyle_MACRO: nErrorStyle = SC_VALERR_MACRO; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_SOURCESTR ) )
+ {
+ // internal - only for XML filter, not in PropertySetInfo, only set
+
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ aPosString = String( aStrVal );
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_FORMULANMSP1 ) )
+ {
+ // internal - only for XML filter, not in PropertySetInfo, only set
+
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ maExprNmsp1 = aStrVal;
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_FORMULANMSP2 ) )
+ {
+ // internal - only for XML filter, not in PropertySetInfo, only set
+
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ maExprNmsp2 = aStrVal;
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_GRAMMAR1 ) )
+ {
+ // internal - only for XML filter, not in PropertySetInfo, only set
+
+ sal_Int32 nVal = 0;
+ if ( aValue >>= nVal )
+ meGrammar1 = static_cast< FormulaGrammar::Grammar >(nVal);
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_GRAMMAR2 ) )
+ {
+ // internal - only for XML filter, not in PropertySetInfo, only set
+
+ sal_Int32 nVal = 0;
+ if ( aValue >>= nVal )
+ meGrammar2 = static_cast< FormulaGrammar::Grammar >(nVal);
+ }
+
+ DataChanged();
+}
+
+uno::Any SAL_CALL ScTableValidationObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+ uno::Any aRet;
+
+ if ( aString.EqualsAscii( SC_UNONAME_SHOWINP ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, bShowInput );
+ else if ( aString.EqualsAscii( SC_UNONAME_SHOWERR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, bShowError );
+ else if ( aString.EqualsAscii( SC_UNONAME_IGNOREBL ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, bIgnoreBlank );
+ else if ( aString.EqualsAscii( SC_UNONAME_SHOWLIST ) ) aRet <<= nShowList;
+ else if ( aString.EqualsAscii( SC_UNONAME_INPTITLE ) ) aRet <<= rtl::OUString( aInputTitle );
+ else if ( aString.EqualsAscii( SC_UNONAME_INPMESS ) ) aRet <<= rtl::OUString( aInputMessage );
+ else if ( aString.EqualsAscii( SC_UNONAME_ERRTITLE ) ) aRet <<= rtl::OUString( aErrorTitle );
+ else if ( aString.EqualsAscii( SC_UNONAME_ERRMESS ) ) aRet <<= rtl::OUString( aErrorMessage );
+ else if ( aString.EqualsAscii( SC_UNONAME_TYPE ) )
+ {
+ sheet::ValidationType eType = sheet::ValidationType_ANY;
+ switch (nValMode)
+ {
+ case SC_VALID_ANY: eType = sheet::ValidationType_ANY; break;
+ case SC_VALID_WHOLE: eType = sheet::ValidationType_WHOLE; break;
+ case SC_VALID_DECIMAL: eType = sheet::ValidationType_DECIMAL; break;
+ case SC_VALID_DATE: eType = sheet::ValidationType_DATE; break;
+ case SC_VALID_TIME: eType = sheet::ValidationType_TIME; break;
+ case SC_VALID_TEXTLEN: eType = sheet::ValidationType_TEXT_LEN; break;
+ case SC_VALID_LIST: eType = sheet::ValidationType_LIST; break;
+ case SC_VALID_CUSTOM: eType = sheet::ValidationType_CUSTOM; break;
+ }
+ aRet <<= eType;
+ }
+ else if ( aString.EqualsAscii( SC_UNONAME_ERRALSTY ) )
+ {
+ sheet::ValidationAlertStyle eStyle = sheet::ValidationAlertStyle_STOP;
+ switch (nErrorStyle)
+ {
+ case SC_VALERR_STOP: eStyle = sheet::ValidationAlertStyle_STOP; break;
+ case SC_VALERR_WARNING: eStyle = sheet::ValidationAlertStyle_WARNING; break;
+ case SC_VALERR_INFO: eStyle = sheet::ValidationAlertStyle_INFO; break;
+ case SC_VALERR_MACRO: eStyle = sheet::ValidationAlertStyle_MACRO; break;
+ }
+ aRet <<= eStyle;
+ }
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScTableValidationObj )
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScTableValidationObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScTableValidationObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScTableValidationObj* ScTableValidationObj::getImplementation(
+ const uno::Reference<beans::XPropertySet> xObj )
+{
+ ScTableValidationObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScTableValidationObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/forbiuno.cxx b/sc/source/ui/unoobj/forbiuno.cxx
new file mode 100644
index 000000000000..c6a91c28d54d
--- /dev/null
+++ b/sc/source/ui/unoobj/forbiuno.cxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <editeng/forbiddencharacterstable.hxx>
+
+#include "forbiuno.hxx"
+#include "docsh.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+rtl::Reference<SvxForbiddenCharactersTable> lcl_GetForbidden( ScDocShell* pDocSh )
+{
+ rtl::Reference<SvxForbiddenCharactersTable> xRet;
+ if ( pDocSh )
+ {
+ ScDocument* pDoc = pDocSh->GetDocument();
+ xRet = pDoc->GetForbiddenCharacters();
+ if ( !xRet.is() )
+ {
+ // create an empty SvxForbiddenCharactersTable for SvxUnoForbiddenCharsTable,
+ // so changes can be stored.
+
+ xRet = new SvxForbiddenCharactersTable( pDoc->GetServiceManager() );
+ pDoc->SetForbiddenCharacters( xRet );
+ }
+ }
+ return xRet;
+}
+
+ScForbiddenCharsObj::ScForbiddenCharsObj( ScDocShell* pDocSh ) :
+ SvxUnoForbiddenCharsTable( lcl_GetForbidden( pDocSh ) ),
+ pDocShell( pDocSh )
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScForbiddenCharsObj::~ScForbiddenCharsObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScForbiddenCharsObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // document gone
+ }
+}
+
+void ScForbiddenCharsObj::onChange()
+{
+ if (pDocShell)
+ {
+ pDocShell->GetDocument()->SetForbiddenCharacters( mxForbiddenChars );
+ pDocShell->PostPaintGridAll();
+ pDocShell->SetDocumentModified();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
new file mode 100644
index 000000000000..1849ae4d171f
--- /dev/null
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -0,0 +1,746 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <tools/debug.hxx>
+#include <sfx2/app.hxx>
+#include <svl/itemprop.hxx>
+
+#include "scitems.hxx"
+#include "funcuno.hxx"
+#include "miscuno.hxx"
+#include "cellsuno.hxx"
+#include "scdll.hxx"
+#include "document.hxx"
+#include "compiler.hxx"
+#include "formula/errorcodes.hxx"
+#include "callform.hxx"
+#include "addincol.hxx"
+#include "rangeseq.hxx"
+#include "cell.hxx"
+#include "docoptio.hxx"
+#include "optuno.hxx"
+#include <docuno.hxx>
+// for lcl_CopyData:
+#include "markdata.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "attrib.hxx"
+#include "clipparam.hxx"
+#include "dociter.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+// registered as implementation for service FunctionAccess,
+// also supports service SpreadsheetDocumentSettings (to set null date etc.)
+
+#define SCFUNCTIONACCESS_SERVICE "com.sun.star.sheet.FunctionAccess"
+#define SCDOCSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetDocumentSettings"
+
+//------------------------------------------------------------------------
+
+// helper to use cached document if not in use, temporary document otherwise
+
+class ScTempDocSource
+{
+private:
+ ScTempDocCache& rCache;
+ ScDocument* pTempDoc;
+
+ static ScDocument* CreateDocument(); // create and initialize doc
+
+public:
+ ScTempDocSource( ScTempDocCache& rDocCache );
+ ~ScTempDocSource();
+
+ ScDocument* GetDocument();
+};
+
+//------------------------------------------------------------------------
+
+// static
+ScDocument* ScTempDocSource::CreateDocument()
+{
+ ScDocument* pDoc = new ScDocument; // SCDOCMODE_DOCUMENT
+ pDoc->MakeTable( 0 );
+ return pDoc;
+}
+
+ScTempDocSource::ScTempDocSource( ScTempDocCache& rDocCache ) :
+ rCache( rDocCache ),
+ pTempDoc( NULL )
+{
+ if ( rCache.IsInUse() )
+ pTempDoc = CreateDocument();
+ else
+ {
+ rCache.SetInUse( TRUE );
+ if ( !rCache.GetDocument() )
+ rCache.SetDocument( CreateDocument() );
+ }
+}
+
+ScTempDocSource::~ScTempDocSource()
+{
+ if ( pTempDoc )
+ delete pTempDoc;
+ else
+ rCache.SetInUse( FALSE );
+}
+
+ScDocument* ScTempDocSource::GetDocument()
+{
+ if ( pTempDoc )
+ return pTempDoc;
+ else
+ return rCache.GetDocument();
+}
+
+//------------------------------------------------------------------------
+
+ScTempDocCache::ScTempDocCache() :
+ pDoc( NULL ),
+ bInUse( FALSE )
+{
+}
+
+ScTempDocCache::~ScTempDocCache()
+{
+ DBG_ASSERT( !bInUse, "ScTempDocCache dtor: bInUse" );
+ delete pDoc;
+}
+
+void ScTempDocCache::SetDocument( ScDocument* pNew )
+{
+ DBG_ASSERT( !pDoc, "ScTempDocCache::SetDocument: already set" );
+ pDoc = pNew;
+}
+
+void ScTempDocCache::Clear()
+{
+ DBG_ASSERT( !bInUse, "ScTempDocCache::Clear: bInUse" );
+ delete pDoc;
+ pDoc = NULL;
+}
+
+//------------------------------------------------------------------------
+
+// copy results from one document into another
+//! merge this with ScAreaLink::Refresh
+//! copy directly without a clipboard document?
+
+BOOL lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange,
+ ScDocument* pDestDoc, const ScAddress& rDestPos )
+{
+ SCTAB nSrcTab = rSrcRange.aStart.Tab();
+ SCTAB nDestTab = rDestPos.Tab();
+
+ ScRange aNewRange( rDestPos, ScAddress(
+ rSrcRange.aEnd.Col() - rSrcRange.aStart.Col() + rDestPos.Col(),
+ rSrcRange.aEnd.Row() - rSrcRange.aStart.Row() + rDestPos.Row(),
+ nDestTab ) );
+
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScMarkData aSourceMark;
+ aSourceMark.SelectOneTable( nSrcTab ); // for CopyToClip
+ aSourceMark.SetMarkArea( rSrcRange );
+ ScClipParam aClipParam(rSrcRange, false);
+ pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aSourceMark, false);
+
+ if ( pClipDoc->HasAttrib( 0,0,nSrcTab, MAXCOL,MAXROW,nSrcTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ ScPatternAttr aPattern( pSrcDoc->GetPool() );
+ aPattern.GetItemSet().Put( ScMergeAttr() ); // Defaults
+ aPattern.GetItemSet().Put( ScMergeFlagAttr() );
+ pClipDoc->ApplyPatternAreaTab( 0,0, MAXCOL,MAXROW, nSrcTab, aPattern );
+ }
+
+ // If the range contains formula cells with default number format,
+ // apply a number format for the formula result
+ ScCellIterator aIter( pClipDoc, rSrcRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ ScAddress aCellPos = aIter.GetPos();
+ sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos);
+ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ USHORT nErrCode = pFCell->GetErrCode();
+ if ( nErrCode == 0 && pFCell->IsValue() )
+ {
+ sal_uInt32 nNewFormat = pFCell->GetStandardFormat( *pClipDoc->GetFormatTable(), nFormat );
+ if ( nNewFormat != nFormat )
+ pClipDoc->ApplyAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(),
+ SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
+ }
+ }
+ }
+ pCell = aIter.GetNext();
+ }
+
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( nDestTab );
+ aDestMark.SetMarkArea( aNewRange );
+ pDestDoc->CopyFromClip( aNewRange, aDestMark, IDF_ALL & ~IDF_FORMULA, NULL, pClipDoc, FALSE );
+
+ delete pClipDoc;
+ return TRUE;
+}
+
+//------------------------------------------------------------------------
+
+ScFunctionAccess::ScFunctionAccess() :
+ pOptions( NULL ),
+ aPropertyMap( ScDocOptionsHelper::GetPropertyMap() ),
+ mbArray( true ), // default according to behaviour of older Office versions
+ mbValid( true )
+{
+ StartListening( *SFX_APP() ); // for SFX_HINT_DEINITIALIZING
+}
+
+ScFunctionAccess::~ScFunctionAccess()
+{
+ delete pOptions;
+}
+
+void ScFunctionAccess::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA(SfxSimpleHint) &&
+ ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DEINITIALIZING )
+ {
+ // document must not be used anymore
+ aDocCache.Clear();
+ mbValid = false;
+ }
+}
+
+// stuff for exService_...
+
+uno::Reference<uno::XInterface> SAL_CALL ScFunctionAccess_CreateInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ static uno::Reference< uno::XInterface > xInst((::cppu::OWeakObject*) new ScFunctionAccess);
+ return xInst;
+}
+
+rtl::OUString ScFunctionAccess::getImplementationName_Static()
+{
+ return rtl::OUString::createFromAscii( "stardiv.StarCalc.ScFunctionAccess" );
+}
+
+uno::Sequence<rtl::OUString> ScFunctionAccess::getSupportedServiceNames_Static()
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCFUNCTIONACCESS_SERVICE );
+ return aRet;
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScFunctionAccess::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScFunctionAccess" );
+}
+
+sal_Bool SAL_CALL ScFunctionAccess::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr(rServiceName);
+ return aServiceStr.EqualsAscii( SCFUNCTIONACCESS_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCDOCSETTINGS_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScFunctionAccess::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCFUNCTIONACCESS_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCDOCSETTINGS_SERVICE );
+ return aRet;
+}
+
+// XPropertySet (document settings)
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFunctionAccess::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( &aPropertyMap ));
+ return aRef;
+}
+
+void SAL_CALL ScFunctionAccess::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsArrayFunction" ) ) )
+ {
+ if( !(aValue >>= mbArray) )
+ throw lang::IllegalArgumentException();
+ }
+ else
+ {
+ if ( !pOptions )
+ pOptions = new ScDocOptions();
+
+ // options aren't initialized from configuration - always get the same default behaviour
+
+ BOOL bDone = ScDocOptionsHelper::setPropertyValue( *pOptions, aPropertyMap, aPropertyName, aValue );
+ if (!bDone)
+ throw beans::UnknownPropertyException();
+ }
+}
+
+uno::Any SAL_CALL ScFunctionAccess::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "IsArrayFunction" ) ) )
+ return uno::Any( mbArray );
+
+ if ( !pOptions )
+ pOptions = new ScDocOptions();
+
+ // options aren't initialized from configuration - always get the same default behaviour
+
+ return ScDocOptionsHelper::getPropertyValue( *pOptions, aPropertyMap, aPropertyName );
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFunctionAccess )
+
+// XFunctionAccess
+
+BOOL lcl_AddFunctionToken( ScTokenArray& rArray, const rtl::OUString& rName,const ScCompiler& rCompiler )
+{
+ // function names are always case-insensitive
+ String aUpper( ScGlobal::pCharClass->upper( rName ) );
+
+ // same options as in ScCompiler::IsOpCode:
+ // 1. built-in function name
+
+ OpCode eOp = rCompiler.GetEnglishOpCode( aUpper );
+ if ( eOp != ocNone )
+ {
+ rArray.AddOpCode( eOp );
+ return TRUE;
+ }
+
+ // 2. old add in functions
+
+ USHORT nIndex;
+ if ( ScGlobal::GetFuncCollection()->SearchFunc( aUpper, nIndex ) )
+ {
+ rArray.AddExternal( aUpper.GetBuffer() );
+ return TRUE;
+ }
+
+ // 3. new (uno) add in functions
+
+ String aIntName(ScGlobal::GetAddInCollection()->FindFunction( aUpper, FALSE ));
+ if (aIntName.Len())
+ {
+ rArray.AddExternal( aIntName.GetBuffer() ); // international name
+ return TRUE;
+ }
+
+ return FALSE; // no valid function name
+}
+
+void lcl_AddRef( ScTokenArray& rArray, long nStartRow, long nColCount, long nRowCount )
+{
+ ScComplexRefData aRef;
+ aRef.InitFlags();
+ aRef.Ref1.nTab = 0;
+ aRef.Ref2.nTab = 0;
+ aRef.Ref1.nCol = 0;
+ aRef.Ref1.nRow = (SCROW) nStartRow;
+ aRef.Ref2.nCol = (SCCOL) (nColCount - 1);
+ aRef.Ref2.nRow = (SCROW) (nStartRow + nRowCount - 1);
+ rArray.AddDoubleReference(aRef);
+}
+
+class SimpleVisitor
+{
+protected:
+ bool mbArgError;
+ ScDocument* mpDoc;
+public:
+ SimpleVisitor( ScDocument* pDoc ) : mbArgError( false ), mpDoc( pDoc ) {}
+ // could possibly just get away with JUST the following overload
+ // 1) virtual void visitElem( long& nCol, long& nRow, const double& elem )
+ // 2) virtual void visitElem( long& nCol, long& nRow, const rtl::OUString& elem )
+ // 3) virtual void visitElem( long& nCol, long& nRow, const uno::Any& elem )
+ // the other types methods are here just to reflect the orig code and for
+ // completeness.
+
+ void visitElem( long nCol, long nRow, const sal_Int16& elem )
+ {
+ mpDoc->SetValue( (SCCOL) nCol, (SCROW) nRow, 0, elem );
+ }
+ void visitElem( long nCol, long nRow, const sal_Int32& elem )
+ {
+ mpDoc->SetValue( (SCCOL) nCol, (SCROW) nRow, 0, elem );
+ }
+ void visitElem( long nCol, long nRow, const double& elem )
+ {
+ mpDoc->SetValue( (SCCOL) nCol, (SCROW) nRow, 0, elem );
+ }
+ void visitElem( long nCol, long nRow, const rtl::OUString& elem )
+ {
+ if ( elem.getLength() )
+ mpDoc->PutCell( (SCCOL) nCol, (SCROW) nRow, 0,
+ new ScStringCell( elem ) );
+ }
+ void visitElem( long nCol, long nRow, const uno::Any& rElement )
+ {
+ uno::TypeClass eElemClass = rElement.getValueTypeClass();
+ if ( eElemClass == uno::TypeClass_VOID )
+ {
+ // leave empty
+ }
+ else if ( eElemClass == uno::TypeClass_BYTE ||
+ eElemClass == uno::TypeClass_SHORT ||
+ eElemClass == uno::TypeClass_UNSIGNED_SHORT ||
+ eElemClass == uno::TypeClass_LONG ||
+ eElemClass == uno::TypeClass_UNSIGNED_LONG ||
+ eElemClass == uno::TypeClass_FLOAT ||
+ eElemClass == uno::TypeClass_DOUBLE )
+ {
+ // #87871# accept integer types because Basic passes a floating point
+ // variable as byte, short or long if it's an integer number.
+ double fVal(0.0);
+ rElement >>= fVal;
+ visitElem( nCol, nRow, fVal );
+ }
+ else if ( eElemClass == uno::TypeClass_STRING )
+ {
+ rtl::OUString aUStr;
+ rElement >>= aUStr;
+ visitElem( nCol, nRow, aUStr );
+ }
+ else
+ mbArgError = true;
+ }
+ bool hasArgError() { return mbArgError; }
+};
+
+template< class seq >
+class SequencesContainer
+{
+ uno::Sequence< uno::Sequence< seq > > maSeq;
+
+ long& mrDocRow;
+ bool mbOverflow;
+ bool mbArgError;
+ ScDocument* mpDoc;
+ ScTokenArray& mrTokenArr;
+
+public:
+ SequencesContainer( const uno::Any& rArg, ScTokenArray& rTokenArr, long& rDocRow, ScDocument* pDoc ) :
+ mrDocRow( rDocRow ), mbOverflow(false), mbArgError(false), mpDoc( pDoc ), mrTokenArr( rTokenArr )
+ {
+ rArg >>= maSeq;
+ }
+
+ void process()
+ {
+ SimpleVisitor aVisitor(mpDoc);
+ long nStartRow = mrDocRow;
+ long nRowCount = maSeq.getLength();
+ long nMaxColCount = 0;
+ const uno::Sequence< seq >* pRowArr = maSeq.getConstArray();
+ for ( long nRow=0; nRow<nRowCount; nRow++ )
+ {
+ long nColCount = pRowArr[nRow].getLength();
+ if ( nColCount > nMaxColCount )
+ nMaxColCount = nColCount;
+ const seq* pColArr = pRowArr[nRow].getConstArray();
+ for (long nCol=0; nCol<nColCount; nCol++)
+ if ( nCol <= MAXCOL && mrDocRow <= MAXROW )
+ aVisitor.visitElem( nCol, mrDocRow, pColArr[ nCol ] );
+ else
+ mbOverflow=true;
+ mrDocRow++;
+ }
+ mbArgError = aVisitor.hasArgError();
+ if ( nRowCount && nMaxColCount && !mbOverflow )
+ lcl_AddRef( mrTokenArr, nStartRow, nMaxColCount, nRowCount );
+ }
+ bool getOverflow() { return mbOverflow; }
+ bool getArgError() { return mbArgError; }
+};
+
+template <class T>
+class ArrayOfArrayProc
+{
+public:
+static void processSequences( ScDocument* pDoc, const uno::Any& rArg, ScTokenArray& rTokenArr,
+ long& rDocRow, BOOL& rArgErr, BOOL& rOverflow )
+{
+ SequencesContainer< T > aContainer( rArg, rTokenArr, rDocRow, pDoc );
+ aContainer.process();
+ rArgErr = aContainer.getArgError();
+ rOverflow = aContainer.getOverflow();
+}
+};
+
+uno::Any SAL_CALL ScFunctionAccess::callFunction( const rtl::OUString& aName,
+ const uno::Sequence<uno::Any>& aArguments )
+ throw(container::NoSuchElementException, lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (!mbValid)
+ throw uno::RuntimeException();
+
+ // use cached document if not in use, temporary document otherwise
+ // (deleted in ScTempDocSource dtor)
+ ScTempDocSource aSource( aDocCache );
+ ScDocument* pDoc = aSource.GetDocument();
+ const static SCTAB nTempSheet = 1;
+ // Create an extra tab to contain the Function Cell
+ // this will allow full rows to be used.
+ if ( !pDoc->HasTable( nTempSheet ) )
+ pDoc->MakeTable( nTempSheet );
+
+ /// TODO: check
+ ScAddress aAdr;
+ ScCompiler aCompiler(pDoc,aAdr);
+ aCompiler.SetGrammar(pDoc->GetGrammar());
+ //if (!ScCompiler::IsInitialized())
+ // ScCompiler::InitSymbolsEnglish();
+
+ //
+ // find function
+ //
+
+ ScTokenArray aTokenArr;
+ if ( !lcl_AddFunctionToken( aTokenArr, aName,aCompiler ) )
+ {
+ // function not found
+ throw container::NoSuchElementException();
+ }
+
+ //
+ // set options (null date, etc.)
+ //
+
+ if ( pOptions )
+ pDoc->SetDocOptions( *pOptions );
+
+ //
+ // add arguments to token array
+ //
+
+ BOOL bArgErr = FALSE;
+ BOOL bOverflow = FALSE;
+ long nDocRow = 0;
+ long nArgCount = aArguments.getLength();
+ const uno::Any* pArgArr = aArguments.getConstArray();
+
+ aTokenArr.AddOpCode(ocOpen);
+ for (long nPos=0; nPos<nArgCount; nPos++)
+ {
+ if ( nPos > 0 )
+ aTokenArr.AddOpCode(ocSep);
+
+ const uno::Any& rArg = pArgArr[nPos];
+
+ uno::TypeClass eClass = rArg.getValueTypeClass();
+ uno::Type aType = rArg.getValueType();
+ if ( eClass == uno::TypeClass_BYTE ||
+ eClass == uno::TypeClass_BOOLEAN ||
+ eClass == uno::TypeClass_SHORT ||
+ eClass == uno::TypeClass_UNSIGNED_SHORT ||
+ eClass == uno::TypeClass_LONG ||
+ eClass == uno::TypeClass_UNSIGNED_LONG ||
+ eClass == uno::TypeClass_FLOAT ||
+ eClass == uno::TypeClass_DOUBLE )
+ {
+ // #87871# accept integer types because Basic passes a floating point
+ // variable as byte, short or long if it's an integer number.
+ double fVal = 0;
+ rArg >>= fVal;
+ aTokenArr.AddDouble( fVal );
+ }
+ else if ( eClass == uno::TypeClass_STRING )
+ {
+ rtl::OUString aUStr;
+ rArg >>= aUStr;
+ String aStr( aUStr );
+ aTokenArr.AddString( aStr.GetBuffer() );
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence< uno::Sequence<sal_Int16> > *)0 ) ) )
+ {
+ ArrayOfArrayProc<sal_Int16>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence< uno::Sequence<sal_Int32> > *)0 ) ) )
+ {
+ ArrayOfArrayProc<sal_Int32>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence< uno::Sequence<double> > *)0 ) ) )
+ {
+ ArrayOfArrayProc<double>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence< uno::Sequence<rtl::OUString> > *)0 ) ) )
+ {
+ ArrayOfArrayProc<rtl::OUString>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence< uno::Sequence<uno::Any> > *)0 ) ) )
+ {
+ ArrayOfArrayProc<uno::Any>::processSequences( pDoc, rArg, aTokenArr, nDocRow, bArgErr, bOverflow );
+ }
+ else if ( aType.equals( getCppuType( (uno::Reference<table::XCellRange>*)0 ) ) )
+ {
+ // currently, only our own cell ranges are supported
+
+ uno::Reference<table::XCellRange> xRange(rArg, uno::UNO_QUERY);
+ ScCellRangesBase* pImpl = ScCellRangesBase::getImplementation( xRange );
+ if ( pImpl )
+ {
+ ScDocument* pSrcDoc = pImpl->GetDocument();
+ const ScRangeList& rRanges = pImpl->GetRangeList();
+ if ( pSrcDoc && rRanges.Count() == 1 )
+ {
+ ScRange aSrcRange = *rRanges.GetObject(0);
+
+ long nStartRow = nDocRow;
+ long nColCount = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1;
+ long nRowCount = aSrcRange.aEnd.Row() - aSrcRange.aStart.Row() + 1;
+
+ if ( nStartRow + nRowCount > MAXROWCOUNT )
+ bOverflow = TRUE;
+ else
+ {
+ // copy data
+ if ( !lcl_CopyData( pSrcDoc, aSrcRange, pDoc, ScAddress( 0, (SCROW)nDocRow, 0 ) ) )
+ bOverflow = TRUE;
+ }
+
+ nDocRow += nRowCount;
+ if ( !bOverflow )
+ lcl_AddRef( aTokenArr, nStartRow, nColCount, nRowCount );
+ }
+ else
+ bArgErr = TRUE;
+ }
+ else
+ bArgErr = TRUE;
+ }
+ else
+ bArgErr = TRUE; // invalid type
+ }
+ aTokenArr.AddOpCode(ocClose);
+ aTokenArr.AddOpCode(ocStop);
+
+ //
+ // execute formula
+ //
+
+ uno::Any aRet;
+ if ( !bArgErr && !bOverflow && nDocRow <= MAXROWCOUNT )
+ {
+ ScAddress aFormulaPos( 0, 0, nTempSheet );
+ // GRAM_PODF_A1 doesn't really matter for the token array but fits with
+ // other API compatibility grammars.
+ ScFormulaCell* pFormula = new ScFormulaCell( pDoc, aFormulaPos,
+ &aTokenArr, formula::FormulaGrammar::GRAM_PODF_A1, (BYTE)(mbArray ? MM_FORMULA : MM_NONE) );
+ pDoc->PutCell( aFormulaPos, pFormula ); //! necessary?
+
+ // call GetMatrix before GetErrCode because GetMatrix always recalculates
+ // if there is no matrix result
+
+ const ScMatrix* pMat = mbArray ? pFormula->GetMatrix() : 0;
+ USHORT nErrCode = pFormula->GetErrCode();
+ if ( nErrCode == 0 )
+ {
+ if ( pMat )
+ {
+ // array result
+ ScRangeToSequence::FillMixedArray( aRet, pMat );
+ }
+ else if ( pFormula->IsValue() )
+ {
+ // numeric value
+ aRet <<= (double) pFormula->GetValue();
+ }
+ else
+ {
+ // string result
+ String aStrVal;
+ pFormula->GetString( aStrVal );
+ aRet <<= rtl::OUString( aStrVal );
+ }
+ }
+ else if ( nErrCode == NOTAVAILABLE )
+ {
+ // #N/A: leave result empty, no exception
+ }
+ else
+ {
+ // any other error: IllegalArgumentException
+ bArgErr = TRUE;
+ }
+
+ pDoc->DeleteAreaTab( 0, 0, MAXCOL, MAXROW, 0, IDF_ALL );
+ pDoc->DeleteAreaTab( 0, 0, 0, 0, nTempSheet, IDF_ALL );
+ }
+
+ if (bOverflow)
+ throw uno::RuntimeException();
+
+ if (bArgErr)
+ throw lang::IllegalArgumentException();
+
+ return aRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
new file mode 100644
index 000000000000..886230b6799d
--- /dev/null
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -0,0 +1,1823 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <svl/smplhint.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <vcl/svapp.hxx>
+
+#include "linkuno.hxx"
+#include "miscuno.hxx"
+#include "convuno.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "collect.hxx"
+#include "tablink.hxx"
+#include "arealink.hxx"
+#include "hints.hxx"
+#include "unonames.hxx"
+#include "rangeseq.hxx"
+#include "token.hxx"
+
+#include <vector>
+#include <climits>
+
+using namespace com::sun::star;
+using namespace formula;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::lang::IllegalArgumentException;
+using ::com::sun::star::uno::RuntimeException;
+using ::rtl::OUString;
+using ::std::vector;
+
+//------------------------------------------------------------------------
+
+// fuer Sheet- und Area-Links benutzt:
+const SfxItemPropertyMapEntry* lcl_GetSheetLinkMap()
+{
+ static SfxItemPropertyMapEntry aSheetLinkMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_FILTER), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_FILTOPT), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LINKURL), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_REFDELAY), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_REFPERIOD), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aSheetLinkMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+SV_IMPL_PTRARR( XRefreshListenerArr_Impl, XRefreshListenerPtr );
+
+SC_SIMPLE_SERVICE_INFO( ScAreaLinkObj, "ScAreaLinkObj", "com.sun.star.sheet.CellAreaLink" )
+SC_SIMPLE_SERVICE_INFO( ScAreaLinksObj, "ScAreaLinksObj", "com.sun.star.sheet.CellAreaLinks" )
+SC_SIMPLE_SERVICE_INFO( ScDDELinkObj, "ScDDELinkObj", "com.sun.star.sheet.DDELink" )
+SC_SIMPLE_SERVICE_INFO( ScDDELinksObj, "ScDDELinksObj", "com.sun.star.sheet.DDELinks" )
+SC_SIMPLE_SERVICE_INFO( ScSheetLinkObj, "ScSheetLinkObj", "com.sun.star.sheet.SheetLink" )
+SC_SIMPLE_SERVICE_INFO( ScSheetLinksObj, "ScSheetLinksObj", "com.sun.star.sheet.SheetLinks" )
+
+//------------------------------------------------------------------------
+
+ScSheetLinkObj::ScSheetLinkObj(ScDocShell* pDocSh, const String& rName) :
+ aPropSet( lcl_GetSheetLinkMap() ),
+ pDocShell( pDocSh ),
+ aFileName( rName )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScSheetLinkObj::~ScSheetLinkObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScSheetLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! notify if links in document are changed
+ // UpdateRef is not needed here
+
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ if ( ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // pointer is invalid
+ }
+ else if ( rHint.ISA( ScLinkRefreshedHint ) )
+ {
+ const ScLinkRefreshedHint& rLH = (const ScLinkRefreshedHint&) rHint;
+ if ( rLH.GetLinkType() == SC_LINKREFTYPE_SHEET && rLH.GetUrl() == aFileName )
+ Refreshed_Impl();
+ }
+}
+
+ScTableLink* ScSheetLinkObj::GetLink_Impl() const
+{
+ if (pDocShell)
+ {
+ sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
+ USHORT nCount = pLinkManager->GetLinks().Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
+ if (pBase->ISA(ScTableLink))
+ {
+ ScTableLink* pTabLink = (ScTableLink*)pBase;
+ if ( pTabLink->GetFileName() == aFileName )
+ return pTabLink;
+ }
+ }
+ }
+ return NULL; // nicht gefunden
+}
+
+// XNamed
+
+rtl::OUString SAL_CALL ScSheetLinkObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getFileName(); // Name ist der Dateiname (URL)
+}
+
+void SAL_CALL ScSheetLinkObj::setName( const rtl::OUString& aName ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ setFileName(aName); // Name ist der Dateiname (URL)
+}
+
+// XRefreshable
+
+void SAL_CALL ScSheetLinkObj::refresh() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ pLink->Refresh( pLink->GetFileName(), pLink->GetFilterName(), NULL, pLink->GetRefreshDelay() );
+}
+
+void SAL_CALL ScSheetLinkObj::addRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<util::XRefreshListener>* pObj =
+ new uno::Reference<util::XRefreshListener>( xListener );
+ aRefreshListeners.Insert( pObj, aRefreshListeners.Count() );
+
+ // hold one additional ref to keep this object alive as long as there are listeners
+ if ( aRefreshListeners.Count() == 1 )
+ acquire();
+}
+
+void SAL_CALL ScSheetLinkObj::removeRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aRefreshListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XRefreshListener>* pObj = aRefreshListeners[n];
+ if ( *pObj == xListener )
+ {
+ aRefreshListeners.DeleteAndDestroy( n );
+ if ( aRefreshListeners.Count() == 0 )
+ release(); // release ref for listeners
+ break;
+ }
+ }
+}
+
+void ScSheetLinkObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+ for ( USHORT n=0; n<aRefreshListeners.Count(); n++ )
+ (*aRefreshListeners[n])->refreshed( aEvent );
+}
+
+void ScSheetLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh )
+{
+ ScTableLink* pLink = GetLink_Impl();
+ if( pLink )
+ pLink->SetRefreshDelay( (ULONG) nRefresh );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScSheetLinkObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScSheetLinkObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ rtl::OUString aValStr;
+ if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
+ {
+ if ( aValue >>= aValStr )
+ setFileName( aValStr );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
+ {
+ if ( aValue >>= aValStr )
+ setFilter( aValStr );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
+ {
+ if ( aValue >>= aValStr )
+ setFilterOptions( aValStr );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
+ {
+ sal_Int32 nRefresh = 0;
+ if ( aValue >>= nRefresh )
+ setRefreshDelay( nRefresh );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
+ {
+ sal_Int32 nRefresh = 0;
+ if ( aValue >>= nRefresh )
+ setRefreshDelay( nRefresh );
+ }
+}
+
+uno::Any SAL_CALL ScSheetLinkObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ uno::Any aRet;
+ if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
+ aRet <<= getFileName();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
+ aRet <<= getFilter();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
+ aRet <<= getFilterOptions();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
+ aRet <<= getRefreshDelay();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
+ aRet <<= getRefreshDelay();
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScSheetLinkObj )
+
+// internal:
+
+rtl::OUString ScSheetLinkObj::getFileName(void) const
+{
+ SolarMutexGuard aGuard;
+ return aFileName;
+}
+
+void ScSheetLinkObj::setFileName(const rtl::OUString& rNewName)
+{
+ SolarMutexGuard aGuard;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ {
+ // pLink->Refresh mit neuem Dateinamen bringt sfx2::LinkManager durcheinander
+ // darum per Hand die Tabellen umsetzen und Link per UpdateLinks neu erzeugen
+
+ String aNewStr(ScGlobal::GetAbsDocName( String(rNewName), pDocShell ));
+
+ // zuerst Tabellen umsetzen
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if ( pDoc->IsLinked(nTab) && pDoc->GetLinkDoc(nTab) == aFileName ) // alte Datei
+ pDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), aNewStr,
+ pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
+ pDoc->GetLinkTab(nTab),
+ pDoc->GetLinkRefreshDelay(nTab) ); // nur Datei aendern
+
+ // Links updaten
+ //! Undo !!!
+
+ pLink = NULL; // wird bei UpdateLinks ungueltig
+ pDocShell->UpdateLinks(); // alter Link raus, evtl. neuen Link anlegen
+
+ // Daten kopieren
+
+ aFileName = aNewStr;
+ pLink = GetLink_Impl(); // neuer Link mit neuem Namen
+ if (pLink)
+ pLink->Update(); // inkl. Paint & Undo fuer Daten
+ }
+}
+
+rtl::OUString ScSheetLinkObj::getFilter(void) const
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ aRet = pLink->GetFilterName();
+ return aRet;
+}
+
+void ScSheetLinkObj::setFilter(const rtl::OUString& Filter)
+{
+ SolarMutexGuard aGuard;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ {
+ String aFilterStr(Filter);
+ pLink->Refresh( aFileName, aFilterStr, NULL, pLink->GetRefreshDelay() );
+ }
+}
+
+rtl::OUString ScSheetLinkObj::getFilterOptions(void) const
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ aRet = pLink->GetOptions();
+ return aRet;
+}
+
+void ScSheetLinkObj::setFilterOptions(const rtl::OUString& FilterOptions)
+{
+ SolarMutexGuard aGuard;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ {
+ String aOptStr(FilterOptions);
+ pLink->Refresh( aFileName, pLink->GetFilterName(), &aOptStr, pLink->GetRefreshDelay() );
+ }
+}
+
+sal_Int32 ScSheetLinkObj::getRefreshDelay(void) const
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 nRet = 0;
+ ScTableLink* pLink = GetLink_Impl();
+ if (pLink)
+ nRet = (sal_Int32) pLink->GetRefreshDelay();
+ return nRet;
+}
+
+void ScSheetLinkObj::setRefreshDelay(sal_Int32 nRefreshDelay)
+{
+ SolarMutexGuard aGuard;
+ ModifyRefreshDelay_Impl( nRefreshDelay );
+}
+
+//------------------------------------------------------------------------
+
+ScSheetLinksObj::ScSheetLinksObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScSheetLinksObj::~ScSheetLinksObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScSheetLinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XSheetLinks
+
+ScSheetLinkObj* ScSheetLinksObj::GetObjectByIndex_Impl(INT32 nIndex)
+{
+ if (pDocShell)
+ {
+ INT32 nCount = 0;
+ ScStrCollection aNames; // um doppelte wegzulassen
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsLinked(nTab))
+ {
+ String aLinkDoc = pDoc->GetLinkDoc( nTab );
+ StrData* pData = new StrData(aLinkDoc);
+ if (aNames.Insert(pData))
+ {
+ if ( nCount == nIndex )
+ return new ScSheetLinkObj( pDocShell, aLinkDoc );
+ ++nCount;
+ }
+ else
+ delete pData;
+ }
+ }
+ return NULL; // kein Dokument oder Index zu gross
+}
+
+ScSheetLinkObj* ScSheetLinksObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ // Name ist der Dateiname
+
+ if (pDocShell)
+ {
+ String aNameStr(aName);
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsLinked(nTab))
+ {
+ //! case-insensitiv ???
+ String aLinkDoc = pDoc->GetLinkDoc( nTab );
+ if ( aLinkDoc == aNameStr )
+ return new ScSheetLinkObj( pDocShell, aNameStr );
+ }
+ }
+
+ return NULL;
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScSheetLinksObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SheetLinksEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScSheetLinksObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ INT32 nCount = 0;
+ if (pDocShell)
+ {
+ ScStrCollection aNames; // um doppelte wegzulassen
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsLinked(nTab))
+ {
+ String aLinkDoc(pDoc->GetLinkDoc( nTab ));
+ StrData* pData = new StrData(aLinkDoc);
+ if (aNames.Insert(pData))
+ ++nCount;
+ else
+ delete pData;
+ }
+ }
+ return nCount;
+}
+
+uno::Any SAL_CALL ScSheetLinksObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<beans::XPropertySet> xLink(GetObjectByIndex_Impl(nIndex));
+ if (xLink.is())
+ return uno::makeAny(xLink);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScSheetLinksObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<beans::XPropertySet>*)0);
+}
+
+sal_Bool SAL_CALL ScSheetLinksObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+uno::Any SAL_CALL ScSheetLinksObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<beans::XPropertySet> xLink(GetObjectByName_Impl(aName));
+ if (xLink.is())
+ return uno::makeAny(xLink);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+sal_Bool SAL_CALL ScSheetLinksObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // Name ist der Dateiname
+
+ if (pDocShell)
+ {
+ String aNameStr(aName);
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsLinked(nTab))
+ {
+ //! case-insensitiv ???
+ String aLinkDoc(pDoc->GetLinkDoc( nTab ));
+ if ( aLinkDoc == aNameStr )
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScSheetLinksObj::getElementNames() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // Name ist der Dateiname
+
+ if (pDocShell)
+ {
+ ScStrCollection aNames; // um doppelte wegzulassen
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ String aName;
+
+ INT32 nLinkCount = getCount();
+ uno::Sequence<rtl::OUString> aSeq(nLinkCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ USHORT nPos = 0;
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ if (pDoc->IsLinked(nTab))
+ {
+ String aLinkDoc(pDoc->GetLinkDoc( nTab ));
+ StrData* pData = new StrData(aLinkDoc);
+ if (aNames.Insert(pData))
+ pAry[nPos++] = aLinkDoc;
+ else
+ delete pData;
+ }
+ }
+ DBG_ASSERT( nPos==nLinkCount, "verzaehlt" );
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>();
+}
+
+//------------------------------------------------------------------------
+
+ScAreaLink* lcl_GetAreaLink( ScDocShell* pDocShell, USHORT nPos )
+{
+ if (pDocShell)
+ {
+ sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
+ USHORT nTotalCount = pLinkManager->GetLinks().Count();
+ USHORT nAreaCount = 0;
+ for (USHORT i=0; i<nTotalCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
+ if (pBase->ISA(ScAreaLink))
+ {
+ if ( nAreaCount == nPos )
+ return (ScAreaLink*)pBase;
+ ++nAreaCount;
+ }
+ }
+ }
+ return NULL; // nicht gefunden
+}
+
+ScAreaLinkObj::ScAreaLinkObj(ScDocShell* pDocSh, USHORT nP) :
+ aPropSet( lcl_GetSheetLinkMap() ),
+ pDocShell( pDocSh ),
+ nPos( nP )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScAreaLinkObj::~ScAreaLinkObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScAreaLinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! notify if links in document are changed
+ // UpdateRef is not needed here
+
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ if ( ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // pointer is invalid
+ }
+ else if ( rHint.ISA( ScLinkRefreshedHint ) )
+ {
+ const ScLinkRefreshedHint& rLH = (const ScLinkRefreshedHint&) rHint;
+ if ( rLH.GetLinkType() == SC_LINKREFTYPE_AREA )
+ {
+ // get this link to compare dest position
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if ( pLink && pLink->GetDestArea().aStart == rLH.GetDestPos() )
+ Refreshed_Impl();
+ }
+ }
+}
+
+// XFileLink
+
+void ScAreaLinkObj::Modify_Impl( const rtl::OUString* pNewFile, const rtl::OUString* pNewFilter,
+ const rtl::OUString* pNewOptions, const rtl::OUString* pNewSource,
+ const table::CellRangeAddress* pNewDest )
+{
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ {
+ String aFile (pLink->GetFile());
+ String aFilter (pLink->GetFilter());
+ String aOptions (pLink->GetOptions());
+ String aSource (pLink->GetSource());
+ ScRange aDest (pLink->GetDestArea());
+ ULONG nRefresh = pLink->GetRefreshDelay();
+
+ //! Undo fuer Loeschen
+ //! Undo zusammenfassen
+
+ sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
+ pLinkManager->Remove( pLink );
+ pLink = NULL; // bei Remove geloescht
+
+ BOOL bFitBlock = TRUE; // verschieben, wenn durch Update Groesse geaendert
+ if (pNewFile)
+ {
+ aFile = String( *pNewFile );
+ aFile = ScGlobal::GetAbsDocName( aFile, pDocShell ); //! in InsertAreaLink?
+ }
+ if (pNewFilter)
+ aFilter = String( *pNewFilter );
+ if (pNewOptions)
+ aOptions = String( *pNewOptions );
+ if (pNewSource)
+ aSource = String( *pNewSource );
+ if (pNewDest)
+ {
+ ScUnoConversion::FillScRange( aDest, *pNewDest );
+ bFitBlock = FALSE; // neuer Bereich angegeben -> keine Inhalte verschieben
+ }
+
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.InsertAreaLink( aFile, aFilter, aOptions, aSource, aDest, nRefresh, bFitBlock, TRUE );
+ }
+}
+
+void ScAreaLinkObj::ModifyRefreshDelay_Impl( sal_Int32 nRefresh )
+{
+ ScAreaLink* pLink = lcl_GetAreaLink( pDocShell, nPos );
+ if( pLink )
+ pLink->SetRefreshDelay( (ULONG) nRefresh );
+}
+
+// XRefreshable
+
+void SAL_CALL ScAreaLinkObj::refresh() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ pLink->Refresh( pLink->GetFile(), pLink->GetFilter(), pLink->GetSource(), pLink->GetRefreshDelay() );
+}
+
+void SAL_CALL ScAreaLinkObj::addRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<util::XRefreshListener>* pObj =
+ new uno::Reference<util::XRefreshListener>( xListener );
+ aRefreshListeners.Insert( pObj, aRefreshListeners.Count() );
+
+ // hold one additional ref to keep this object alive as long as there are listeners
+ if ( aRefreshListeners.Count() == 1 )
+ acquire();
+}
+
+void SAL_CALL ScAreaLinkObj::removeRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aRefreshListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XRefreshListener>* pObj = aRefreshListeners[n];
+ if ( *pObj == xListener )
+ {
+ aRefreshListeners.DeleteAndDestroy( n );
+ if ( aRefreshListeners.Count() == 0 )
+ release(); // release ref for listeners
+ break;
+ }
+ }
+}
+
+void ScAreaLinkObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+ for ( USHORT n=0; n<aRefreshListeners.Count(); n++ )
+ (*aRefreshListeners[n])->refreshed( aEvent );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScAreaLinkObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScAreaLinkObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ rtl::OUString aValStr;
+ if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
+ {
+ if ( aValue >>= aValStr )
+ setFileName( aValStr );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
+ {
+ if ( aValue >>= aValStr )
+ setFilter( aValStr );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
+ {
+ if ( aValue >>= aValStr )
+ setFilterOptions( aValStr );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
+ {
+ sal_Int32 nRefresh = 0;
+ if ( aValue >>= nRefresh )
+ setRefreshDelay( nRefresh );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
+ {
+ sal_Int32 nRefresh = 0;
+ if ( aValue >>= nRefresh )
+ setRefreshDelay( nRefresh );
+ }
+}
+
+uno::Any SAL_CALL ScAreaLinkObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+ uno::Any aRet;
+ if ( aNameString.EqualsAscii( SC_UNONAME_LINKURL ) )
+ aRet <<= getFileName();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTER ) )
+ aRet <<= getFilter();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_FILTOPT ) )
+ aRet <<= getFilterOptions();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFPERIOD ) )
+ aRet <<= getRefreshDelay();
+ else if ( aNameString.EqualsAscii( SC_UNONAME_REFDELAY ) )
+ aRet <<= getRefreshDelay();
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScAreaLinkObj )
+
+// internal:
+
+rtl::OUString ScAreaLinkObj::getFileName(void) const
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ aRet = pLink->GetFile();
+ return aRet;
+}
+
+void ScAreaLinkObj::setFileName(const rtl::OUString& rNewName)
+{
+ SolarMutexGuard aGuard;
+ Modify_Impl( &rNewName, NULL, NULL, NULL, NULL );
+}
+
+rtl::OUString ScAreaLinkObj::getFilter(void) const
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ aRet = pLink->GetFilter();
+ return aRet;
+}
+
+void ScAreaLinkObj::setFilter(const rtl::OUString& Filter)
+{
+ SolarMutexGuard aGuard;
+ Modify_Impl( NULL, &Filter, NULL, NULL, NULL );
+}
+
+rtl::OUString ScAreaLinkObj::getFilterOptions(void) const
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ aRet = pLink->GetOptions();
+ return aRet;
+}
+
+void ScAreaLinkObj::setFilterOptions(const rtl::OUString& FilterOptions)
+{
+ SolarMutexGuard aGuard;
+ Modify_Impl( NULL, NULL, &FilterOptions, NULL, NULL );
+}
+
+sal_Int32 ScAreaLinkObj::getRefreshDelay(void) const
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 nRet = 0;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ nRet = (sal_Int32) pLink->GetRefreshDelay();
+ return nRet;
+}
+
+void ScAreaLinkObj::setRefreshDelay(sal_Int32 nRefreshDelay)
+{
+ SolarMutexGuard aGuard;
+ ModifyRefreshDelay_Impl( nRefreshDelay );
+}
+
+// XAreaLink
+
+rtl::OUString SAL_CALL ScAreaLinkObj::getSourceArea() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ aRet = pLink->GetSource();
+ return aRet;
+}
+
+void SAL_CALL ScAreaLinkObj::setSourceArea( const rtl::OUString& aSourceArea )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Modify_Impl( NULL, NULL, NULL, &aSourceArea, NULL );
+}
+
+table::CellRangeAddress SAL_CALL ScAreaLinkObj::getDestArea() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aRet;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, nPos);
+ if (pLink)
+ ScUnoConversion::FillApiRange( aRet, pLink->GetDestArea() );
+ return aRet;
+}
+
+void SAL_CALL ScAreaLinkObj::setDestArea( const table::CellRangeAddress& aDestArea )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Modify_Impl( NULL, NULL, NULL, NULL, &aDestArea );
+}
+
+//------------------------------------------------------------------------
+
+ScAreaLinksObj::ScAreaLinksObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScAreaLinksObj::~ScAreaLinksObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScAreaLinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XAreaLinks
+
+ScAreaLinkObj* ScAreaLinksObj::GetObjectByIndex_Impl(INT32 nIndex)
+{
+ if ( pDocShell && nIndex >= 0 && nIndex < getCount() )
+ return new ScAreaLinkObj( pDocShell, (USHORT)nIndex );
+
+ return NULL; // nicht gefunden
+}
+
+void SAL_CALL ScAreaLinksObj::insertAtPosition( const table::CellAddress& aDestPos,
+ const rtl::OUString& aFileName,
+ const rtl::OUString& aSourceArea,
+ const rtl::OUString& aFilter,
+ const rtl::OUString& aFilterOptions )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ String aFileStr (aFileName);
+ String aFilterStr (aFilter);
+ String aOptionStr (aFilterOptions);
+ String aSourceStr (aSourceArea);
+ ScAddress aDestAddr( (SCCOL)aDestPos.Column, (SCROW)aDestPos.Row, aDestPos.Sheet );
+
+ aFileStr = ScGlobal::GetAbsDocName( aFileStr, pDocShell ); //! in InsertAreaLink ???
+
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.InsertAreaLink( aFileStr, aFilterStr, aOptionStr,
+ aSourceStr, ScRange(aDestAddr),
+ 0, FALSE, TRUE ); // keine Inhalte verschieben
+ }
+}
+
+void SAL_CALL ScAreaLinksObj::removeByIndex( sal_Int32 nIndex ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAreaLink* pLink = lcl_GetAreaLink(pDocShell, (USHORT)nIndex);
+ if (pLink)
+ {
+ //! SetAddUndo oder so
+
+ sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
+ pLinkManager->Remove( pLink );
+ }
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScAreaLinksObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.CellAreaLinksEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScAreaLinksObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ INT32 nAreaCount = 0;
+ if (pDocShell)
+ {
+ sfx2::LinkManager* pLinkManager = pDocShell->GetDocument()->GetLinkManager();
+ USHORT nTotalCount = pLinkManager->GetLinks().Count();
+ for (USHORT i=0; i<nTotalCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *pLinkManager->GetLinks()[i];
+ if (pBase->ISA(ScAreaLink))
+ ++nAreaCount;
+ }
+ }
+ return nAreaCount;
+}
+
+uno::Any SAL_CALL ScAreaLinksObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XAreaLink> xLink(GetObjectByIndex_Impl(nIndex));
+ if (xLink.is())
+ return uno::makeAny(xLink);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScAreaLinksObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XAreaLink>*)0);
+}
+
+sal_Bool SAL_CALL ScAreaLinksObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+//------------------------------------------------------------------------
+
+ScDDELinkObj::ScDDELinkObj(ScDocShell* pDocSh, const String& rA,
+ const String& rT, const String& rI) :
+ pDocShell( pDocSh ),
+ aAppl( rA ),
+ aTopic( rT ),
+ aItem( rI )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDDELinkObj::~ScDDELinkObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDDELinkObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! notify if links in document are changed
+ // UpdateRef is not needed here
+
+ if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ if ( ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // pointer is invalid
+ }
+ else if ( rHint.ISA( ScLinkRefreshedHint ) )
+ {
+ const ScLinkRefreshedHint& rLH = (const ScLinkRefreshedHint&) rHint;
+ if ( rLH.GetLinkType() == SC_LINKREFTYPE_DDE &&
+ rLH.GetDdeAppl() == aAppl &&
+ rLH.GetDdeTopic() == aTopic &&
+ rLH.GetDdeItem() == aItem ) //! mode is ignored
+ Refreshed_Impl();
+ }
+}
+
+// XNamed
+
+String lcl_BuildDDEName( const String& rAppl, const String& rTopic, const String& rItem )
+{
+ // Appl|Topic!Item (wie Excel)
+ String aRet = rAppl;
+ aRet += '|';
+ aRet += rTopic;
+ aRet += '!';
+ aRet += rItem;
+ return aRet;
+}
+
+rtl::OUString SAL_CALL ScDDELinkObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return lcl_BuildDDEName( aAppl, aTopic, aItem );
+}
+
+void SAL_CALL ScDDELinkObj::setName( const rtl::OUString& /* aName */ ) throw(uno::RuntimeException)
+{
+ // name can't be changed (formulas wouldn't find the link)
+ throw uno::RuntimeException();
+}
+
+// XDDELink
+
+rtl::OUString SAL_CALL ScDDELinkObj::getApplication() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! Test, ob Link noch im Dokument enthalten?
+
+ return aAppl;
+}
+
+rtl::OUString SAL_CALL ScDDELinkObj::getTopic() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! Test, ob Link noch im Dokument enthalten?
+
+ return aTopic;
+}
+
+rtl::OUString SAL_CALL ScDDELinkObj::getItem() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! Test, ob Link noch im Dokument enthalten?
+
+ return aItem;
+}
+
+// XRefreshable
+
+void SAL_CALL ScDDELinkObj::refresh() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ (void)pDoc->UpdateDdeLink( aAppl, aTopic, aItem );
+ //! Fehler abfragen
+ }
+}
+
+void SAL_CALL ScDDELinkObj::addRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<util::XRefreshListener>* pObj =
+ new uno::Reference<util::XRefreshListener>( xListener );
+ aRefreshListeners.Insert( pObj, aRefreshListeners.Count() );
+
+ // hold one additional ref to keep this object alive as long as there are listeners
+ if ( aRefreshListeners.Count() == 1 )
+ acquire();
+}
+
+void SAL_CALL ScDDELinkObj::removeRefreshListener(
+ const uno::Reference<util::XRefreshListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aRefreshListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XRefreshListener>* pObj = aRefreshListeners[n];
+ if ( *pObj == xListener )
+ {
+ aRefreshListeners.DeleteAndDestroy( n );
+ if ( aRefreshListeners.Count() == 0 )
+ release(); // release ref for listeners
+ break;
+ }
+ }
+}
+
+// XDDELinkResults
+
+uno::Sequence< uno::Sequence< uno::Any > > ScDDELinkObj::getResults( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence< uno::Sequence< uno::Any > > aReturn;
+ bool bSuccess = false;
+
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( pDoc )
+ {
+ USHORT nPos = 0;
+ if ( pDoc->FindDdeLink( aAppl, aTopic, aItem, SC_DDE_IGNOREMODE, nPos ) )
+ {
+ const ScMatrix* pMatrix = pDoc->GetDdeLinkResultMatrix( nPos );
+ if ( pMatrix )
+ {
+ uno::Any aAny;
+ if ( ScRangeToSequence::FillMixedArray( aAny, pMatrix, true ) )
+ {
+ aAny >>= aReturn;
+ }
+ }
+ bSuccess = true;
+ }
+ }
+ }
+
+ if ( !bSuccess )
+ {
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "ScDDELinkObj::getResults: failed to get results!" ) ),
+ uno::Reference< uno::XInterface >() );
+ }
+
+ return aReturn;
+}
+
+void ScDDELinkObj::setResults( const uno::Sequence< uno::Sequence< uno::Any > >& aResults )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ bool bSuccess = false;
+
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( pDoc )
+ {
+ USHORT nPos = 0;
+ if ( pDoc->FindDdeLink( aAppl, aTopic, aItem, SC_DDE_IGNOREMODE, nPos ) )
+ {
+ uno::Any aAny;
+ aAny <<= aResults;
+ ScMatrixRef xMatrix = ScSequenceToMatrix::CreateMixedMatrix( aAny );
+ bSuccess = pDoc->SetDdeLinkResultMatrix( nPos, xMatrix );
+ }
+ }
+ }
+
+ if ( !bSuccess )
+ {
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "ScDDELinkObj::setResults: failed to set results!" ) ),
+ uno::Reference< uno::XInterface >() );
+ }
+}
+
+void ScDDELinkObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+ for ( USHORT n=0; n<aRefreshListeners.Count(); n++ )
+ (*aRefreshListeners[n])->refreshed( aEvent );
+}
+
+//------------------------------------------------------------------------
+
+ScDDELinksObj::ScDDELinksObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScDDELinksObj::~ScDDELinksObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScDDELinksObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XDDELinks
+
+ScDDELinkObj* ScDDELinksObj::GetObjectByIndex_Impl(INT32 nIndex)
+{
+ if (pDocShell)
+ {
+ String aAppl, aTopic, aItem;
+ if ( nIndex <= USHRT_MAX &&
+ pDocShell->GetDocument()->GetDdeLinkData( (USHORT)nIndex, aAppl, aTopic, aItem ) )
+ return new ScDDELinkObj( pDocShell, aAppl, aTopic, aItem );
+ }
+ return NULL;
+}
+
+ScDDELinkObj* ScDDELinksObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ if (pDocShell)
+ {
+ String aNamStr(aName);
+ String aAppl, aTopic, aItem;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ USHORT nCount = pDoc->GetDdeLinkCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ pDoc->GetDdeLinkData( i, aAppl, aTopic, aItem );
+ if ( lcl_BuildDDEName(aAppl, aTopic, aItem) == aNamStr )
+ return new ScDDELinkObj( pDocShell, aAppl, aTopic, aItem );
+ }
+ }
+ return NULL;
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScDDELinksObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.DDELinksEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScDDELinksObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ INT32 nAreaCount = 0;
+ if (pDocShell)
+ nAreaCount = pDocShell->GetDocument()->GetDdeLinkCount();
+ return nAreaCount;
+}
+
+uno::Any SAL_CALL ScDDELinksObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XDDELink> xLink(GetObjectByIndex_Impl(nIndex));
+ if (xLink.is())
+ return uno::makeAny(xLink);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScDDELinksObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XDDELink>*)0);
+}
+
+sal_Bool SAL_CALL ScDDELinksObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+uno::Any SAL_CALL ScDDELinksObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XDDELink> xLink(GetObjectByName_Impl(aName));
+ if (xLink.is())
+ return uno::makeAny(xLink);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScDDELinksObj::getElementNames() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ String aAppl, aTopic, aItem;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ USHORT nCount = pDoc->GetDdeLinkCount();
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+
+ for (USHORT i=0; i<nCount; i++)
+ {
+ pDoc->GetDdeLinkData( i, aAppl, aTopic, aItem );
+ pAry[i] = lcl_BuildDDEName(aAppl, aTopic, aItem);
+ }
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>();
+}
+
+sal_Bool SAL_CALL ScDDELinksObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ String aNamStr(aName);
+ String aAppl, aTopic, aItem;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ USHORT nCount = pDoc->GetDdeLinkCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ pDoc->GetDdeLinkData( i, aAppl, aTopic, aItem );
+ if ( lcl_BuildDDEName(aAppl, aTopic, aItem) == aNamStr )
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+// XDDELinks
+
+uno::Reference< sheet::XDDELink > ScDDELinksObj::addDDELink(
+ const ::rtl::OUString& aApplication, const ::rtl::OUString& aTopic,
+ const ::rtl::OUString& aItem, ::com::sun::star::sheet::DDELinkMode nMode )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< sheet::XDDELink > xLink;
+
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( pDoc )
+ {
+ BYTE nMod = SC_DDE_DEFAULT;
+ switch ( nMode )
+ {
+ case sheet::DDELinkMode_DEFAULT:
+ {
+ nMod = SC_DDE_DEFAULT;
+ }
+ break;
+ case sheet::DDELinkMode_ENGLISH:
+ {
+ nMod = SC_DDE_ENGLISH;
+ }
+ break;
+ case sheet::DDELinkMode_TEXT:
+ {
+ nMod = SC_DDE_TEXT;
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
+
+ if ( pDoc->CreateDdeLink( aApplication, aTopic, aItem, nMod ) )
+ {
+ const ::rtl::OUString aName( lcl_BuildDDEName( aApplication, aTopic, aItem ) );
+ xLink.set( GetObjectByName_Impl( aName ) );
+ }
+ }
+ }
+
+ if ( !xLink.is() )
+ {
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "ScDDELinksObj::addDDELink: cannot add DDE link!" ) ),
+ uno::Reference< uno::XInterface >() );
+ }
+
+ return xLink;
+}
+
+// ============================================================================
+
+ScExternalSheetCacheObj::ScExternalSheetCacheObj(ScExternalRefCache::TableTypeRef pTable, size_t nIndex) :
+ mpTable(pTable),
+ mnIndex(nIndex)
+{
+}
+
+ScExternalSheetCacheObj::~ScExternalSheetCacheObj()
+{
+}
+
+void SAL_CALL ScExternalSheetCacheObj::setCellValue(sal_Int32 nCol, sal_Int32 nRow, const Any& rValue)
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nRow < 0 || nCol < 0)
+ throw IllegalArgumentException();
+
+ ScExternalRefCache::TokenRef pToken;
+ double fVal = 0.0;
+ OUString aVal;
+ if (rValue >>= fVal)
+ pToken.reset(new FormulaDoubleToken(fVal));
+ else if (rValue >>= aVal)
+ pToken.reset(new FormulaStringToken(aVal));
+ else
+ // unidentified value type.
+ return;
+
+ mpTable->setCell(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), pToken);
+}
+
+Any SAL_CALL ScExternalSheetCacheObj::getCellValue(sal_Int32 nCol, sal_Int32 nRow)
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nRow < 0 || nCol < 0)
+ throw IllegalArgumentException();
+
+ FormulaToken* pToken = mpTable->getCell(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow)).get();
+ if (!pToken)
+ throw IllegalArgumentException();
+
+ Any aValue;
+ switch (pToken->GetType())
+ {
+ case svDouble:
+ {
+ double fVal = pToken->GetDouble();
+ aValue <<= fVal;
+ }
+ break;
+ case svString:
+ {
+ OUString aVal = pToken->GetString();
+ aValue <<= aVal;
+ }
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ return aValue;
+}
+
+Sequence< sal_Int32 > SAL_CALL ScExternalSheetCacheObj::getAllRows()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ vector<SCROW> aRows;
+ mpTable->getAllRows(aRows);
+ size_t nSize = aRows.size();
+ Sequence<sal_Int32> aRowsSeq(nSize);
+ for (size_t i = 0; i < nSize; ++i)
+ aRowsSeq[i] = aRows[i];
+
+ return aRowsSeq;
+}
+
+Sequence< sal_Int32 > SAL_CALL ScExternalSheetCacheObj::getAllColumns(sal_Int32 nRow)
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nRow < 0)
+ throw IllegalArgumentException();
+
+ vector<SCCOL> aCols;
+ mpTable->getAllCols(static_cast<SCROW>(nRow), aCols);
+ size_t nSize = aCols.size();
+ Sequence<sal_Int32> aColsSeq(nSize);
+ for (size_t i = 0; i < nSize; ++i)
+ aColsSeq[i] = aCols[i];
+
+ return aColsSeq;
+}
+
+sal_Int32 SAL_CALL ScExternalSheetCacheObj::getTokenIndex()
+ throw (RuntimeException)
+{
+ return static_cast< sal_Int32 >( mnIndex );
+}
+
+// ============================================================================
+
+ScExternalDocLinkObj::ScExternalDocLinkObj(ScExternalRefManager* pRefMgr, sal_uInt16 nFileId) :
+ mpRefMgr(pRefMgr), mnFileId(nFileId)
+{
+}
+
+ScExternalDocLinkObj::~ScExternalDocLinkObj()
+{
+}
+
+Reference< sheet::XExternalSheetCache > SAL_CALL ScExternalDocLinkObj::addSheetCache(
+ const OUString& aSheetName, sal_Bool bDynamicCache )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ size_t nIndex = 0;
+ ScExternalRefCache::TableTypeRef pTable = mpRefMgr->getCacheTable(mnFileId, aSheetName, true, &nIndex);
+ if (!bDynamicCache)
+ // Set the whole table cached to prevent access to the source document.
+ pTable->setWholeTableCached();
+
+ Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex));
+ return aSheetCache;
+}
+
+Any SAL_CALL ScExternalDocLinkObj::getByName(const::rtl::OUString &aName)
+ throw (container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ size_t nIndex = 0;
+ ScExternalRefCache::TableTypeRef pTable = mpRefMgr->getCacheTable(mnFileId, aName, false, &nIndex);
+ if (!pTable)
+ throw container::NoSuchElementException();
+
+ Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex));
+
+ Any aAny;
+ aAny <<= aSheetCache;
+ return aAny;
+}
+
+Sequence< OUString > SAL_CALL ScExternalDocLinkObj::getElementNames()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ vector<String> aTabNames;
+ mpRefMgr->getAllCachedTableNames(mnFileId, aTabNames);
+ size_t n = aTabNames.size();
+ Sequence<OUString> aSeq(n);
+ for (size_t i = 0; i < n; ++i)
+ aSeq[i] = aTabNames[i];
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScExternalDocLinkObj::hasByName(const OUString &aName)
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return static_cast<sal_Bool>(mpRefMgr->hasCacheTable(mnFileId, aName));
+}
+
+sal_Int32 SAL_CALL ScExternalDocLinkObj::getCount()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return static_cast<sal_Int32>(mpRefMgr->getCacheTableCount(mnFileId));
+}
+
+Any SAL_CALL ScExternalDocLinkObj::getByIndex(sal_Int32 nIndex)
+ throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ size_t nTabCount = mpRefMgr->getCacheTableCount(mnFileId);
+ if (nIndex < 0 || nIndex >= static_cast<sal_Int32>(nTabCount))
+ throw lang::IndexOutOfBoundsException();
+
+ ScExternalRefCache::TableTypeRef pTable = mpRefMgr->getCacheTable(mnFileId, static_cast<size_t>(nIndex));
+ if (!pTable)
+ throw lang::IndexOutOfBoundsException();
+
+ Reference< sheet::XExternalSheetCache > aSheetCache(new ScExternalSheetCacheObj(pTable, nIndex));
+
+ Any aAny;
+ aAny <<= aSheetCache;
+ return aAny;
+}
+
+Reference< container::XEnumeration > SAL_CALL ScExternalDocLinkObj::createEnumeration()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference< container::XEnumeration > aRef(
+ new ScIndexEnumeration(this, OUString::createFromAscii(
+ "com.sun.star.sheet.ExternalDocLink")));
+ return aRef;
+}
+
+uno::Type SAL_CALL ScExternalDocLinkObj::getElementType()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType(static_cast<Reference<sheet::XExternalDocLink>*>(0));
+}
+
+sal_Bool SAL_CALL ScExternalDocLinkObj::hasElements()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return static_cast<sal_Bool>(mpRefMgr->getCacheTableCount(mnFileId) > 0);
+}
+
+sal_Int32 SAL_CALL ScExternalDocLinkObj::getTokenIndex()
+ throw (RuntimeException)
+{
+ return static_cast<sal_Int32>(mnFileId);
+}
+
+// ============================================================================
+
+ScExternalDocLinksObj::ScExternalDocLinksObj(ScDocShell* pDocShell) :
+ mpDocShell(pDocShell),
+ mpRefMgr(pDocShell->GetDocument()->GetExternalRefManager())
+{
+}
+
+ScExternalDocLinksObj::~ScExternalDocLinksObj()
+{
+}
+
+Reference< sheet::XExternalDocLink > SAL_CALL ScExternalDocLinksObj::addDocLink(
+ const OUString& aDocName )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aDocName);
+ Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId));
+ return aDocLink;
+}
+
+Any SAL_CALL ScExternalDocLinksObj::getByName(const::rtl::OUString &aName)
+ throw (container::NoSuchElementException, lang::WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!mpRefMgr->hasExternalFile(aName))
+ throw container::NoSuchElementException();
+
+ sal_uInt16 nFileId = mpRefMgr->getExternalFileId(aName);
+ Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId));
+
+ Any aAny;
+ aAny <<= aDocLink;
+ return aAny;
+}
+
+Sequence< OUString > SAL_CALL ScExternalDocLinksObj::getElementNames()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 n = mpRefMgr->getExternalFileCount();
+ Sequence<OUString> aSeq(n);
+ for (sal_uInt16 i = 0; i < n; ++i)
+ {
+ const String* pName = mpRefMgr->getExternalFileName(i);
+ aSeq[i] = pName ? *pName : EMPTY_STRING;
+ }
+
+ return aSeq;
+}
+
+sal_Bool SAL_CALL ScExternalDocLinksObj::hasByName(const OUString &aName)
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return mpRefMgr->hasExternalFile(aName);
+}
+
+sal_Int32 SAL_CALL ScExternalDocLinksObj::getCount()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return mpRefMgr->getExternalFileCount();
+}
+
+Any SAL_CALL ScExternalDocLinksObj::getByIndex(sal_Int32 nIndex)
+ throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (nIndex > ::std::numeric_limits<sal_uInt16>::max() || nIndex < ::std::numeric_limits<sal_uInt16>::min())
+ throw lang::IndexOutOfBoundsException();
+
+ sal_uInt16 nFileId = static_cast<sal_uInt16>(nIndex);
+
+ if (!mpRefMgr->hasExternalFile(nFileId))
+ throw lang::IndexOutOfBoundsException();
+
+ Reference< sheet::XExternalDocLink > aDocLink(new ScExternalDocLinkObj(mpRefMgr, nFileId));
+ Any aAny;
+ aAny <<= aDocLink;
+ return aAny;
+}
+
+Reference< container::XEnumeration > SAL_CALL ScExternalDocLinksObj::createEnumeration()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Reference< container::XEnumeration > aRef(
+ new ScIndexEnumeration(this, OUString::createFromAscii(
+ "com.sun.star.sheet.ExternalDocLinks")));
+ return aRef;
+}
+
+uno::Type SAL_CALL ScExternalDocLinksObj::getElementType()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType(static_cast<Reference<sheet::XExternalDocLinks>*>(0));
+}
+
+sal_Bool SAL_CALL ScExternalDocLinksObj::hasElements()
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return mpRefMgr->getExternalFileCount() > 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/listenercalls.cxx b/sc/source/ui/unoobj/listenercalls.cxx
new file mode 100644
index 000000000000..281997d31a53
--- /dev/null
+++ b/sc/source/ui/unoobj/listenercalls.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <com/sun/star/util/XModifyListener.hpp>
+#include <tools/debug.hxx>
+
+#include "listenercalls.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+ScUnoListenerCalls::ScUnoListenerCalls()
+{
+}
+
+ScUnoListenerCalls::~ScUnoListenerCalls()
+{
+ DBG_ASSERT( aEntries.empty(), "unhandled listener calls remaining" );
+}
+
+void ScUnoListenerCalls::Add( const uno::Reference<util::XModifyListener>& rListener,
+ const lang::EventObject& rEvent )
+{
+ if ( rListener.is() )
+ aEntries.push_back( ScUnoListenerEntry( rListener, rEvent ) );
+}
+
+void ScUnoListenerCalls::ExecuteAndClear()
+{
+ // Execute all stored calls and remove them from the list.
+ // During each modified() call, Add may be called again.
+ // These new calls are executed here, too.
+
+ if (!aEntries.empty())
+ {
+ std::list<ScUnoListenerEntry>::iterator aItr(aEntries.begin());
+ std::list<ScUnoListenerEntry>::iterator aEndItr(aEntries.end());
+ while ( aItr != aEndItr )
+ {
+ ScUnoListenerEntry aEntry = *aItr;
+ try
+ {
+ aEntry.xListener->modified( aEntry.aEvent );
+ }
+ catch ( uno::RuntimeException )
+ {
+ // the listener is an external object and may throw a RuntimeException
+ // for reasons we don't know
+ }
+
+ // New calls that are added during the modified() call are appended to the end
+ // of aEntries, so the loop will catch them, too (as long as erase happens
+ // after modified).
+
+ aItr = aEntries.erase(aItr);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/makefile.mk b/sc/source/ui/unoobj/makefile.mk
new file mode 100644
index 000000000000..f80f74f513cb
--- /dev/null
+++ b/sc/source/ui/unoobj/makefile.mk
@@ -0,0 +1,117 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=unoobj
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+SLO1FILES = \
+ $(SLO)$/docuno.obj \
+ $(SLO)$/servuno.obj \
+ $(SLO)$/defltuno.obj \
+ $(SLO)$/drdefuno.obj \
+ $(SLO)$/cellsuno.obj \
+ $(SLO)$/tokenuno.obj \
+ $(SLO)$/textuno.obj \
+ $(SLO)$/notesuno.obj \
+ $(SLO)$/cursuno.obj \
+ $(SLO)$/srchuno.obj \
+ $(SLO)$/fielduno.obj \
+ $(SLO)$/miscuno.obj \
+ $(SLO)$/optuno.obj \
+ $(SLO)$/appluno.obj \
+ $(SLO)$/funcuno.obj \
+ $(SLO)$/nameuno.obj \
+ $(SLO)$/viewuno.obj \
+ $(SLO)$/dispuno.obj \
+ $(SLO)$/datauno.obj \
+ $(SLO)$/dapiuno.obj \
+ $(SLO)$/chartuno.obj \
+ $(SLO)$/chart2uno.obj \
+ $(SLO)$/shapeuno.obj \
+ $(SLO)$/pageuno.obj \
+ $(SLO)$/forbiuno.obj \
+ $(SLO)$/styleuno.obj \
+ $(SLO)$/afmtuno.obj \
+ $(SLO)$/fmtuno.obj \
+ $(SLO)$/linkuno.obj \
+ $(SLO)$/targuno.obj \
+ $(SLO)$/convuno.obj \
+ $(SLO)$/editsrc.obj \
+ $(SLO)$/confuno.obj \
+ $(SLO)$/filtuno.obj \
+ $(SLO)$/unodoc.obj \
+ $(SLO)$/addruno.obj \
+ $(SLO)$/eventuno.obj \
+ $(SLO)$/listenercalls.obj \
+ $(SLO)$/cellvaluebinding.obj \
+ $(SLO)$/celllistsource.obj \
+ $(SLO)$/warnpassword.obj \
+ $(SLO)$/unoreflist.obj \
+ $(SLO)$/ChartRangeSelectionListener.obj
+
+SLO2FILES = \
+ $(SLO)$/scdetect.obj \
+ $(SLO)$/detreg.obj
+
+SLOFILES = \
+ $(SLO1FILES) \
+ $(SLO2FILES)
+
+LIB1TARGET = \
+ $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO1FILES)
+
+.IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCSPARC"
+NOOPTFILES= \
+ $(SLO)$/cellsuno.obj
+.ENDIF
+
+# Work around bug in gcc 4.2 / 4.3, see
+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35182
+.IF "$(COM)"=="GCC"
+NOOPTFILES+= \
+ $(SLO)$/chart2uno.obj
+.ENDIF
+
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/unoobj/miscuno.cxx b/sc/source/ui/unoobj/miscuno.cxx
new file mode 100644
index 000000000000..a148c9f476cd
--- /dev/null
+++ b/sc/source/ui/unoobj/miscuno.cxx
@@ -0,0 +1,330 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+
+#include "miscuno.hxx"
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+using ::rtl::OUString;
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScNameToIndexAccess, "ScNameToIndexAccess", "stardiv.unknown" )
+
+//------------------------------------------------------------------------
+
+// static
+uno::Reference<uno::XInterface> ScUnoHelpFunctions::AnyToInterface( const uno::Any& rAny )
+{
+ if ( rAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
+ {
+ return uno::Reference<uno::XInterface>(rAny, uno::UNO_QUERY);
+ }
+ return uno::Reference<uno::XInterface>(); //! Exception?
+}
+
+// static
+sal_Bool ScUnoHelpFunctions::GetBoolProperty( const uno::Reference<beans::XPropertySet>& xProp,
+ const rtl::OUString& rName, sal_Bool bDefault )
+{
+ sal_Bool bRet = bDefault;
+ if ( xProp.is() )
+ {
+ try
+ {
+ uno::Any aAny(xProp->getPropertyValue( rName ));
+ //! type conversion???
+ // operator >>= shouldn't be used for bool (?)
+ if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN )
+ {
+ //! safe way to get bool value from any???
+ bRet = *(sal_Bool*)aAny.getValue();
+ }
+ }
+ catch(uno::Exception&)
+ {
+ // keep default
+ }
+ }
+ return bRet;
+}
+
+// static
+sal_Int32 ScUnoHelpFunctions::GetLongProperty( const uno::Reference<beans::XPropertySet>& xProp,
+ const rtl::OUString& rName, long nDefault )
+{
+ sal_Int32 nRet = nDefault;
+ if ( xProp.is() )
+ {
+ try
+ {
+ //! type conversion???
+ xProp->getPropertyValue( rName ) >>= nRet;
+ }
+ catch(uno::Exception&)
+ {
+ // keep default
+ }
+ }
+ return nRet;
+}
+
+// static
+sal_Int32 ScUnoHelpFunctions::GetEnumProperty( const uno::Reference<beans::XPropertySet>& xProp,
+ const rtl::OUString& rName, long nDefault )
+{
+ sal_Int32 nRet = nDefault;
+ if ( xProp.is() )
+ {
+ try
+ {
+ uno::Any aAny(xProp->getPropertyValue( rName ));
+
+ if ( aAny.getValueTypeClass() == uno::TypeClass_ENUM )
+ {
+ //! get enum value from any???
+ nRet = *(sal_Int32*)aAny.getValue();
+ }
+ else
+ {
+ //! type conversion???
+ aAny >>= nRet;
+ }
+ }
+ catch(uno::Exception&)
+ {
+ // keep default
+ }
+ }
+ return nRet;
+}
+
+// static
+OUString ScUnoHelpFunctions::GetStringProperty(
+ const Reference<beans::XPropertySet>& xProp, const OUString& rName, const OUString& rDefault )
+{
+ OUString aRet = rDefault;
+ if (!xProp.is())
+ return aRet;
+
+ try
+ {
+ Any any = xProp->getPropertyValue(rName);
+ any >>= aRet;
+ }
+ catch (const uno::Exception&)
+ {
+ }
+
+ return aRet;
+}
+
+// static
+sal_Bool ScUnoHelpFunctions::GetBoolFromAny( const uno::Any& aAny )
+{
+ if ( aAny.getValueTypeClass() == uno::TypeClass_BOOLEAN )
+ return *(sal_Bool*)aAny.getValue();
+ return FALSE;
+}
+
+// static
+sal_Int16 ScUnoHelpFunctions::GetInt16FromAny( const uno::Any& aAny )
+{
+ sal_Int16 nRet = 0;
+ if ( aAny >>= nRet )
+ return nRet;
+ return 0;
+}
+
+// static
+sal_Int32 ScUnoHelpFunctions::GetInt32FromAny( const uno::Any& aAny )
+{
+ sal_Int32 nRet = 0;
+ if ( aAny >>= nRet )
+ return nRet;
+ return 0;
+}
+
+// static
+sal_Int32 ScUnoHelpFunctions::GetEnumFromAny( const uno::Any& aAny )
+{
+ sal_Int32 nRet = 0;
+ if ( aAny.getValueTypeClass() == uno::TypeClass_ENUM )
+ nRet = *(sal_Int32*)aAny.getValue();
+ else
+ aAny >>= nRet;
+ return nRet;
+}
+
+// static
+void ScUnoHelpFunctions::SetBoolInAny( uno::Any& rAny, sal_Bool bValue )
+{
+ rAny.setValue( &bValue, getBooleanCppuType() );
+}
+
+// static
+void ScUnoHelpFunctions::SetOptionalPropertyValue(
+ Reference<beans::XPropertySet>& rPropSet, const sal_Char* pPropName, const Any& rVal )
+{
+ try
+ {
+ rPropSet->setPropertyValue(OUString::createFromAscii(pPropName), rVal);
+ }
+ catch (const beans::UnknownPropertyException&)
+ {
+ // ignored - not supported.
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScIndexEnumeration::ScIndexEnumeration(const uno::Reference<container::XIndexAccess>& rInd,
+ const rtl::OUString& rServiceName) :
+ xIndex( rInd ),
+ sServiceName(rServiceName),
+ nPos( 0 )
+{
+}
+
+ScIndexEnumeration::~ScIndexEnumeration()
+{
+}
+
+// XEnumeration
+
+sal_Bool SAL_CALL ScIndexEnumeration::hasMoreElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( nPos < xIndex->getCount() );
+}
+
+uno::Any SAL_CALL ScIndexEnumeration::nextElement() throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aReturn;
+ try
+ {
+ aReturn = xIndex->getByIndex(nPos++);
+ }
+ catch (lang::IndexOutOfBoundsException&)
+ {
+ throw container::NoSuchElementException();
+ }
+ return aReturn;
+}
+
+::rtl::OUString SAL_CALL ScIndexEnumeration::getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("ScIndexEnumeration");
+}
+
+sal_Bool SAL_CALL ScIndexEnumeration::supportsService( const ::rtl::OUString& ServiceName )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ return sServiceName == ServiceName;
+}
+
+::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL ScIndexEnumeration::getSupportedServiceNames(void)
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aRet(1);
+ ::rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = sServiceName;
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+//------------------------------------------------------------------------
+
+ScNameToIndexAccess::ScNameToIndexAccess( const com::sun::star::uno::Reference<
+ com::sun::star::container::XNameAccess>& rNameObj ) :
+ xNameAccess( rNameObj )
+{
+ //! test for XIndexAccess interface at rNameObj, use that instead!
+
+ if ( xNameAccess.is() )
+ aNames = xNameAccess->getElementNames();
+}
+
+ScNameToIndexAccess::~ScNameToIndexAccess()
+{
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScNameToIndexAccess::getCount( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return aNames.getLength();
+}
+
+::com::sun::star::uno::Any SAL_CALL ScNameToIndexAccess::getByIndex( sal_Int32 nIndex )
+ throw(::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ if ( xNameAccess.is() && nIndex >= 0 && nIndex < aNames.getLength() )
+ return xNameAccess->getByName( aNames.getConstArray()[nIndex] );
+
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+// XElementAccess
+
+::com::sun::star::uno::Type SAL_CALL ScNameToIndexAccess::getElementType( )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ if ( xNameAccess.is() )
+ return xNameAccess->getElementType();
+ else
+ return uno::Type();
+}
+
+sal_Bool SAL_CALL ScNameToIndexAccess::hasElements( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return getCount() > 0;
+}
+
+//------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
new file mode 100644
index 000000000000..d85f24fd1484
--- /dev/null
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -0,0 +1,1186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <svl/smplhint.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/sheet/NamedRangeFlag.hpp>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
+
+
+#include "nameuno.hxx"
+#include "miscuno.hxx"
+#include "cellsuno.hxx"
+#include "convuno.hxx"
+#include "targuno.hxx"
+#include "tokenuno.hxx"
+#include "tokenarray.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "rangenam.hxx"
+#include "unonames.hxx"
+
+#include "scui_def.hxx"
+
+//------------------------------------------------------------------------
+
+const SfxItemPropertyMapEntry* lcl_GetNamedRangeMap()
+{
+ static SfxItemPropertyMapEntry aNamedRangeMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT), 0, &getCppuType((uno::Reference<awt::XBitmap>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), 0, &getCppuType((rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TOKENINDEX), 0, &getCppuType((sal_Int32*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ISSHAREDFMLA), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aNamedRangeMap_Impl;
+}
+
+const SfxItemPropertyMapEntry* lcl_GetNamedRangesMap()
+{
+ static SfxItemPropertyMapEntry aNamedRangesMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_MODIFY_BROADCAST), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aNamedRangesMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+#define SCNAMEDRANGEOBJ_SERVICE "com.sun.star.sheet.NamedRange"
+
+SC_SIMPLE_SERVICE_INFO( ScLabelRangeObj, "ScLabelRangeObj", "com.sun.star.sheet.LabelRange" )
+SC_SIMPLE_SERVICE_INFO( ScLabelRangesObj, "ScLabelRangesObj", "com.sun.star.sheet.LabelRanges" )
+SC_SIMPLE_SERVICE_INFO( ScNamedRangesObj, "ScNamedRangesObj", "com.sun.star.sheet.NamedRanges" )
+
+//------------------------------------------------------------------------
+
+sal_Bool lcl_UserVisibleName( const ScRangeData* pData )
+{
+ //! als Methode an ScRangeData
+
+ return ( pData && !pData->HasType( RT_DATABASE ) && !pData->HasType( RT_SHARED ) );
+}
+
+//------------------------------------------------------------------------
+
+ScNamedRangeObj::ScNamedRangeObj(ScNamedRangesObj* pParent, ScDocShell* pDocSh, const String& rNm) :
+ mpParent(pParent),
+ pDocShell( pDocSh ),
+ aName( rNm )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScNamedRangeObj::~ScNamedRangeObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScNamedRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Ref-Update interessiert nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // ungueltig geworden
+}
+
+// Hilfsfuntionen
+
+ScRangeData* ScNamedRangeObj::GetRangeData_Impl()
+{
+ ScRangeData* pRet = NULL;
+ if (pDocShell)
+ {
+ ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
+ if (pNames)
+ {
+ sal_uInt16 nPos = 0;
+ if (pNames->SearchName( aName, nPos ))
+ {
+ pRet = (*pNames)[nPos];
+ pRet->ValidateTabRefs(); // adjust relative tab refs to valid tables
+ }
+ }
+ }
+ return pRet;
+}
+
+// sheet::XNamedRange
+
+void ScNamedRangeObj::Modify_Impl( const String* pNewName, const ScTokenArray* pNewTokens, const String* pNewContent,
+ const ScAddress* pNewPos, const sal_uInt16* pNewType,
+ const formula::FormulaGrammar::Grammar eGrammar )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangeName* pNames = pDoc->GetRangeName();
+ if (pNames)
+ {
+ sal_uInt16 nPos = 0;
+ if (pNames->SearchName( aName, nPos ))
+ {
+ ScRangeName* pNewRanges = new ScRangeName( *pNames );
+ ScRangeData* pOld = (*pNames)[nPos];
+
+ String aInsName(pOld->GetName());
+ if (pNewName)
+ aInsName = *pNewName;
+ String aContent; // Content string based =>
+ pOld->GetSymbol( aContent, eGrammar); // no problems with changed positions and such.
+ if (pNewContent)
+ aContent = *pNewContent;
+ ScAddress aPos(pOld->GetPos());
+ if (pNewPos)
+ aPos = *pNewPos;
+ sal_uInt16 nType = pOld->GetType();
+ if (pNewType)
+ nType = *pNewType;
+
+ ScRangeData* pNew = NULL;
+ if ( pNewTokens )
+ pNew = new ScRangeData( pDoc, aInsName, *pNewTokens, aPos, nType );
+ else
+ pNew = new ScRangeData( pDoc, aInsName, aContent, aPos, nType, eGrammar );
+ pNew->SetIndex( pOld->GetIndex() );
+
+ pNewRanges->AtFree( nPos );
+ if ( pNewRanges->Insert(pNew) )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.SetNewRangeNames( pNewRanges, mpParent->IsModifyAndBroadcast());
+
+ aName = aInsName; //! broadcast?
+ }
+ else
+ {
+ delete pNew; //! uno::Exception/Fehler oder so
+ delete pNewRanges;
+ }
+ }
+ }
+ }
+}
+
+
+rtl::OUString SAL_CALL ScNamedRangeObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return aName;
+}
+
+void SAL_CALL ScNamedRangeObj::setName( const rtl::OUString& aNewName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! Formeln anpassen ?????
+
+ String aNewStr(aNewName);
+ // GRAM_PODF_A1 for API compatibility.
+ Modify_Impl( &aNewStr, NULL, NULL, NULL, NULL,formula::FormulaGrammar::GRAM_PODF_A1 );
+
+ if ( aName != aNewStr ) // some error occured...
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+rtl::OUString SAL_CALL ScNamedRangeObj::getContent() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aContent;
+ ScRangeData* pData = GetRangeData_Impl();
+ if (pData)
+ // GRAM_PODF_A1 for API compatibility.
+ pData->GetSymbol( aContent,formula::FormulaGrammar::GRAM_PODF_A1);
+ return aContent;
+}
+
+void SAL_CALL ScNamedRangeObj::setContent( const rtl::OUString& aContent )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aContStr(aContent);
+ // GRAM_PODF_A1 for API compatibility.
+ Modify_Impl( NULL, NULL, &aContStr, NULL, NULL,formula::FormulaGrammar::GRAM_PODF_A1 );
+}
+
+void ScNamedRangeObj::SetContentWithGrammar( const ::rtl::OUString& aContent,
+ const formula::FormulaGrammar::Grammar eGrammar )
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ String aContStr(aContent);
+ Modify_Impl( NULL, NULL, &aContStr, NULL, NULL, eGrammar );
+}
+
+table::CellAddress SAL_CALL ScNamedRangeObj::getReferencePosition()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAddress aPos;
+ ScRangeData* pData = GetRangeData_Impl();
+ if (pData)
+ aPos = pData->GetPos();
+ table::CellAddress aAddress;
+ aAddress.Column = aPos.Col();
+ aAddress.Row = aPos.Row();
+ aAddress.Sheet = aPos.Tab();
+ if (pDocShell)
+ {
+ SCTAB nDocTabs = pDocShell->GetDocument()->GetTableCount();
+ if ( aAddress.Sheet >= nDocTabs && nDocTabs > 0 )
+ {
+ // Even after ValidateTabRefs, the position can be invalid if
+ // the content points to preceding tables. The resulting string
+ // is invalid in any case, so the position is just shifted.
+ aAddress.Sheet = nDocTabs - 1;
+ }
+ }
+ return aAddress;
+}
+
+void SAL_CALL ScNamedRangeObj::setReferencePosition( const table::CellAddress& aReferencePosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAddress aPos( (SCCOL)aReferencePosition.Column, (SCROW)aReferencePosition.Row, aReferencePosition.Sheet );
+ // GRAM_PODF_A1 for API compatibility.
+ Modify_Impl( NULL, NULL, NULL, &aPos, NULL,formula::FormulaGrammar::GRAM_PODF_A1 );
+}
+
+sal_Int32 SAL_CALL ScNamedRangeObj::getType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Int32 nType=0;
+ ScRangeData* pData = GetRangeData_Impl();
+ if (pData)
+ {
+ // do not return internal RT_* flags
+ // see property 'IsSharedFormula' for RT_SHARED
+ if ( pData->HasType(RT_CRITERIA) ) nType |= sheet::NamedRangeFlag::FILTER_CRITERIA;
+ if ( pData->HasType(RT_PRINTAREA) ) nType |= sheet::NamedRangeFlag::PRINT_AREA;
+ if ( pData->HasType(RT_COLHEADER) ) nType |= sheet::NamedRangeFlag::COLUMN_HEADER;
+ if ( pData->HasType(RT_ROWHEADER) ) nType |= sheet::NamedRangeFlag::ROW_HEADER;
+ }
+ return nType;
+}
+
+void SAL_CALL ScNamedRangeObj::setType( sal_Int32 nUnoType ) throw(uno::RuntimeException)
+{
+ // see property 'IsSharedFormula' for RT_SHARED
+ SolarMutexGuard aGuard;
+ sal_uInt16 nNewType = RT_NAME;
+ if ( nUnoType & sheet::NamedRangeFlag::FILTER_CRITERIA ) nNewType |= RT_CRITERIA;
+ if ( nUnoType & sheet::NamedRangeFlag::PRINT_AREA ) nNewType |= RT_PRINTAREA;
+ if ( nUnoType & sheet::NamedRangeFlag::COLUMN_HEADER ) nNewType |= RT_COLHEADER;
+ if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER;
+
+ // GRAM_PODF_A1 for API compatibility.
+ Modify_Impl( NULL, NULL, NULL, NULL, &nNewType,formula::FormulaGrammar::GRAM_PODF_A1 );
+}
+
+// XFormulaTokens
+
+uno::Sequence<sheet::FormulaToken> SAL_CALL ScNamedRangeObj::getTokens() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence<sheet::FormulaToken> aSequence;
+ ScRangeData* pData = GetRangeData_Impl();
+ if (pData && pDocShell)
+ {
+ ScTokenArray* pTokenArray = pData->GetCode();
+ if ( pTokenArray )
+ (void)ScTokenConversion::ConvertToTokenSequence( *pDocShell->GetDocument(), aSequence, *pTokenArray );
+ }
+ return aSequence;
+}
+
+void SAL_CALL ScNamedRangeObj::setTokens( const uno::Sequence<sheet::FormulaToken>& rTokens ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( pDocShell )
+ {
+ ScTokenArray aTokenArray;
+ (void)ScTokenConversion::ConvertToTokenArray( *pDocShell->GetDocument(), aTokenArray, rTokens );
+ // GRAM_PODF_A1 for API compatibility.
+ Modify_Impl( NULL, &aTokenArray, NULL, NULL, NULL, formula::FormulaGrammar::GRAM_PODF_A1 );
+ }
+}
+
+
+// XCellRangeSource
+
+uno::Reference<table::XCellRange> SAL_CALL ScNamedRangeObj::getReferredCells()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRange aRange;
+ ScRangeData* pData = GetRangeData_Impl();
+ if ( pData && pData->IsValidReference( aRange ) )
+ {
+ //! static Funktion um ScCellObj/ScCellRangeObj zu erzeugen am ScCellRangeObj ???
+
+ if ( aRange.aStart == aRange.aEnd )
+ return new ScCellObj( pDocShell, aRange.aStart );
+ else
+ return new ScCellRangeObj( pDocShell, aRange );
+ }
+ return NULL;
+}
+
+// beans::XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScNamedRangeObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( lcl_GetNamedRangeMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScNamedRangeObj::setPropertyValue(
+ const rtl::OUString& rPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( rPropertyName.equalsAscii( SC_UNONAME_ISSHAREDFMLA ) )
+ {
+ bool bIsShared = false;
+ if( aValue >>= bIsShared )
+ {
+ sal_uInt16 nNewType = bIsShared ? RT_SHARED : RT_NAME;
+ Modify_Impl( NULL, NULL, NULL, NULL, &nNewType,formula::FormulaGrammar::GRAM_PODF_A1 );
+ }
+ }
+}
+
+uno::Any SAL_CALL ScNamedRangeObj::getPropertyValue( const rtl::OUString& rPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ if ( rPropertyName.equalsAscii( SC_UNO_LINKDISPBIT ) )
+ {
+ // no target bitmaps for individual entries (would be all equal)
+ // ScLinkTargetTypeObj::SetLinkTargetBitmap( aRet, SC_LINKTARGETTYPE_RANGENAME );
+ }
+ else if ( rPropertyName.equalsAscii( SC_UNO_LINKDISPNAME ) )
+ aRet <<= rtl::OUString( aName );
+ else if ( rPropertyName.equalsAscii( SC_UNONAME_TOKENINDEX ) )
+ {
+ // get index for use in formula tokens (read-only)
+ ScRangeData* pData = GetRangeData_Impl();
+ if (pData)
+ aRet <<= static_cast<sal_Int32>(pData->GetIndex());
+ }
+ else if ( rPropertyName.equalsAscii( SC_UNONAME_ISSHAREDFMLA ) )
+ {
+ if( ScRangeData* pData = GetRangeData_Impl() )
+ aRet <<= static_cast< bool >( pData->HasType( RT_SHARED ) );
+ }
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScNamedRangeObj )
+
+// lang::XServiceInfo
+
+rtl::OUString SAL_CALL ScNamedRangeObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScNamedRangeObj" ) );
+}
+
+sal_Bool SAL_CALL ScNamedRangeObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ return rServiceName.equalsAscii( SCNAMEDRANGEOBJ_SERVICE ) ||
+ rServiceName.equalsAscii( SCLINKTARGET_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScNamedRangeObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ aRet[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SCNAMEDRANGEOBJ_SERVICE ) );
+ aRet[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SCLINKTARGET_SERVICE ) );
+ return aRet;
+}
+
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScNamedRangeObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScNamedRangeObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScNamedRangeObj* ScNamedRangeObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScNamedRangeObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScNamedRangeObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScNamedRangesObj::ScNamedRangesObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh ),
+ mbModifyAndBroadcast(true)
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScNamedRangesObj::~ScNamedRangesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScNamedRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+bool ScNamedRangesObj::IsModifyAndBroadcast() const
+{
+ return mbModifyAndBroadcast;
+}
+
+// sheet::XNamedRanges
+
+ScNamedRangeObj* ScNamedRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
+{
+ if (pDocShell)
+ {
+ ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
+ if (pNames)
+ {
+ sal_uInt16 nCount = pNames->GetCount();
+ sal_uInt16 nPos = 0;
+ for (sal_uInt16 i=0; i<nCount; i++)
+ {
+ ScRangeData* pData = (*pNames)[i];
+ if (lcl_UserVisibleName(pData)) // interne weglassen
+ {
+ if ( nPos == nIndex )
+ return new ScNamedRangeObj(this, pDocShell, pData->GetName());
+ ++nPos;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
+ScNamedRangeObj* ScNamedRangesObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ if ( pDocShell && hasByName(aName) )
+ return new ScNamedRangeObj(this, pDocShell, String(aName));
+ return NULL;
+}
+
+void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName,
+ const rtl::OUString& aContent, const table::CellAddress& aPosition,
+ sal_Int32 nUnoType ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr(aName);
+ String aContStr(aContent);
+ ScAddress aPos( (SCCOL)aPosition.Column, (SCROW)aPosition.Row, aPosition.Sheet );
+
+ sal_uInt16 nNewType = RT_NAME;
+ if ( nUnoType & sheet::NamedRangeFlag::FILTER_CRITERIA ) nNewType |= RT_CRITERIA;
+ if ( nUnoType & sheet::NamedRangeFlag::PRINT_AREA ) nNewType |= RT_PRINTAREA;
+ if ( nUnoType & sheet::NamedRangeFlag::COLUMN_HEADER ) nNewType |= RT_COLHEADER;
+ if ( nUnoType & sheet::NamedRangeFlag::ROW_HEADER ) nNewType |= RT_ROWHEADER;
+
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangeName* pNames = pDoc->GetRangeName();
+ USHORT nIndex = 0;
+ if (pNames && !pNames->SearchName(aNameStr, nIndex))
+ {
+ ScRangeName* pNewRanges = new ScRangeName( *pNames );
+ // GRAM_PODF_A1 for API compatibility.
+ ScRangeData* pNew = new ScRangeData( pDoc, aNameStr, aContStr,
+ aPos, nNewType,formula::FormulaGrammar::GRAM_PODF_A1 );
+ if ( pNewRanges->Insert(pNew) )
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.SetNewRangeNames(pNewRanges, mbModifyAndBroadcast);
+ bDone = TRUE;
+ }
+ else
+ {
+ delete pNew;
+ delete pNewRanges;
+ }
+ }
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScNamedRangesObj::addNewFromTitles( const table::CellRangeAddress& aSource,
+ sheet::Border aBorder ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! das darf kein enum sein, weil mehrere Bits gesetzt sein koennen !!!
+
+ sal_Bool bTop = ( aBorder == sheet::Border_TOP );
+ sal_Bool bLeft = ( aBorder == sheet::Border_LEFT );
+ sal_Bool bBottom = ( aBorder == sheet::Border_BOTTOM );
+ sal_Bool bRight = ( aBorder == sheet::Border_RIGHT );
+
+ ScRange aRange;
+ ScUnoConversion::FillScRange( aRange, aSource );
+
+ sal_uInt16 nFlags = 0;
+ if (bTop) nFlags |= NAME_TOP;
+ if (bLeft) nFlags |= NAME_LEFT;
+ if (bBottom) nFlags |= NAME_BOTTOM;
+ if (bRight) nFlags |= NAME_RIGHT;
+
+ if (nFlags)
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.CreateNames( aRange, nFlags, sal_True );
+ }
+}
+
+void SAL_CALL ScNamedRangesObj::removeByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
+ if (pNames)
+ {
+ String aString(aName);
+ sal_uInt16 nPos = 0;
+ if (pNames->SearchName( aString, nPos ))
+ if ( lcl_UserVisibleName((*pNames)[nPos]) )
+ {
+ ScRangeName* pNewRanges = new ScRangeName(*pNames);
+ pNewRanges->AtFree(nPos);
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.SetNewRangeNames( pNewRanges, mbModifyAndBroadcast);
+ bDone = TRUE;
+ }
+ }
+ }
+
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+void SAL_CALL ScNamedRangesObj::outputList( const table::CellAddress& aOutputPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScAddress aPos( (SCCOL)aOutputPosition.Column, (SCROW)aOutputPosition.Row, aOutputPosition.Sheet );
+ if (pDocShell)
+ {
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.InsertNameList( aPos, sal_True );
+ }
+}
+
+// container::XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScNamedRangesObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.NamedRangesEnumeration")));
+}
+
+// container::XIndexAccess
+
+sal_Int32 SAL_CALL ScNamedRangesObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ long nRet = 0;
+ if (pDocShell)
+ {
+ ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
+ if (pNames)
+ {
+ sal_uInt16 nCount = pNames->GetCount();
+ for (sal_uInt16 i=0; i<nCount; i++)
+ if (lcl_UserVisibleName( (*pNames)[i] )) // interne weglassen
+ ++nRet;
+ }
+ }
+ return nRet;
+}
+
+uno::Any SAL_CALL ScNamedRangesObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< sheet::XNamedRange > xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex));
+ if ( xRange.is() )
+ return uno::makeAny(xRange);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScNamedRangesObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::getCppuType((const uno::Reference< sheet::XNamedRange >*)0); // muss zu getByIndex passen
+}
+
+sal_Bool SAL_CALL ScNamedRangesObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+Reference<beans::XPropertySetInfo> SAL_CALL ScNamedRangesObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ static Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo(lcl_GetNamedRangesMap()));
+ return aRef;
+}
+
+void SAL_CALL ScNamedRangesObj::setPropertyValue(
+ const rtl::OUString& rPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if (rPropertyName.equalsAscii(SC_UNO_MODIFY_BROADCAST))
+ {
+ aValue >>= mbModifyAndBroadcast;
+ }
+}
+
+Any SAL_CALL ScNamedRangesObj::getPropertyValue( const rtl::OUString& rPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ Any aRet;
+ if (rPropertyName.equalsAscii(SC_UNO_MODIFY_BROADCAST))
+ {
+ aRet <<= mbModifyAndBroadcast;
+ }
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScNamedRangesObj )
+
+uno::Any SAL_CALL ScNamedRangesObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< sheet::XNamedRange > xRange(GetObjectByName_Impl(aName));
+ if ( xRange.is() )
+ return uno::makeAny(xRange);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScNamedRangesObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
+ if (pNames)
+ {
+ long nVisCount = getCount(); // Namen mit lcl_UserVisibleName
+ uno::Sequence<rtl::OUString> aSeq(nVisCount);
+ rtl::OUString* pAry = aSeq.getArray();
+
+ sal_uInt16 nCount = pNames->GetCount();
+ sal_uInt16 nVisPos = 0;
+ for (sal_uInt16 i=0; i<nCount; i++)
+ {
+ ScRangeData* pData = (*pNames)[i];
+ if ( lcl_UserVisibleName(pData) )
+ pAry[nVisPos++] = pData->GetName();
+ }
+// DBG_ASSERT(nVisPos == nVisCount, "huch, verzaehlt?");
+ return aSeq;
+ }
+ }
+ return uno::Sequence<rtl::OUString>(0);
+}
+
+sal_Bool SAL_CALL ScNamedRangesObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScRangeName* pNames = pDocShell->GetDocument()->GetRangeName();
+ if (pNames)
+ {
+ sal_uInt16 nPos = 0;
+ if (pNames->SearchName( String(aName), nPos ))
+ if ( lcl_UserVisibleName((*pNames)[nPos]) )
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+/** called from the XActionLockable interface methods on initial locking */
+void ScNamedRangesObj::lock()
+{
+ pDocShell->GetDocument()->CompileNameFormula( TRUE ); // CreateFormulaString
+}
+
+/** called from the XActionLockable interface methods on final unlock */
+void ScNamedRangesObj::unlock()
+{
+ pDocShell->GetDocument()->CompileNameFormula( FALSE ); // CompileFormulaString
+}
+
+// document::XActionLockable
+
+sal_Bool ScNamedRangesObj::isActionLocked() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return pDocShell->GetDocument()->GetNamedRangesLockCount() != 0;
+}
+
+void ScNamedRangesObj::addActionLock() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sal_Int16 nLockCount = pDoc->GetNamedRangesLockCount();
+ ++nLockCount;
+ if ( nLockCount == 1 )
+ {
+ lock();
+ }
+ pDoc->SetNamedRangesLockCount( nLockCount );
+}
+
+void ScNamedRangesObj::removeActionLock() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sal_Int16 nLockCount = pDoc->GetNamedRangesLockCount();
+ if ( nLockCount > 0 )
+ {
+ --nLockCount;
+ if ( nLockCount == 0 )
+ {
+ unlock();
+ }
+ pDoc->SetNamedRangesLockCount( nLockCount );
+ }
+}
+
+void ScNamedRangesObj::setActionLocks( sal_Int16 nLock ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( nLock >= 0 )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sal_Int16 nLockCount = pDoc->GetNamedRangesLockCount();
+ if ( nLock == 0 && nLockCount > 0 )
+ {
+ unlock();
+ }
+ if ( nLock > 0 && nLockCount == 0 )
+ {
+ lock();
+ }
+ pDoc->SetNamedRangesLockCount( nLock );
+ }
+}
+
+sal_Int16 ScNamedRangesObj::resetActionLocks() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScDocument* pDoc = pDocShell->GetDocument();
+ sal_Int16 nLockCount = pDoc->GetNamedRangesLockCount();
+ if ( nLockCount > 0 )
+ {
+ unlock();
+ }
+ pDoc->SetNamedRangesLockCount( 0 );
+ return nLockCount;
+}
+
+//------------------------------------------------------------------------
+
+ScLabelRangeObj::ScLabelRangeObj(ScDocShell* pDocSh, sal_Bool bCol, const ScRange& rR) :
+ pDocShell( pDocSh ),
+ bColumn( bCol ),
+ aRange( rR )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScLabelRangeObj::~ScLabelRangeObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScLabelRangeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ //! Ref-Update !!!
+
+ if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // ungueltig geworden
+}
+
+// Hilfsfuntionen
+
+ScRangePair* ScLabelRangeObj::GetData_Impl()
+{
+ ScRangePair* pRet = NULL;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangePairList* pList = bColumn ? pDoc->GetColNameRanges() : pDoc->GetRowNameRanges();
+ if (pList)
+ pRet = pList->Find( aRange );
+ }
+ return pRet;
+}
+
+void ScLabelRangeObj::Modify_Impl( const ScRange* pLabel, const ScRange* pData )
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangePairList* pOldList = bColumn ? pDoc->GetColNameRanges() : pDoc->GetRowNameRanges();
+ if (pOldList)
+ {
+ ScRangePairListRef xNewList(pOldList->Clone());
+ ScRangePair* pEntry = xNewList->Find( aRange );
+ if (pEntry)
+ {
+ xNewList->Remove( pEntry ); // nur aus der Liste entfernt, nicht geloescht
+
+ if ( pLabel )
+ pEntry->GetRange(0) = *pLabel;
+ if ( pData )
+ pEntry->GetRange(1) = *pData;
+
+ xNewList->Join( *pEntry );
+ delete pEntry;
+
+ if (bColumn)
+ pDoc->GetColNameRangesRef() = xNewList;
+ else
+ pDoc->GetRowNameRangesRef() = xNewList;
+
+ pDoc->CompileColRowNameFormula();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+
+ //! Undo ?!?! (hier und aus Dialog)
+
+ if ( pLabel )
+ aRange = *pLabel; // Objekt anpassen, um Range wiederzufinden
+ }
+ }
+ }
+}
+
+// sheet::XLabelRange
+
+table::CellRangeAddress SAL_CALL ScLabelRangeObj::getLabelArea()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aRet;
+ ScRangePair* pData = GetData_Impl();
+ if (pData)
+ ScUnoConversion::FillApiRange( aRet, pData->GetRange(0) );
+ return aRet;
+}
+
+void SAL_CALL ScLabelRangeObj::setLabelArea( const table::CellRangeAddress& aLabelArea )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRange aLabelRange;
+ ScUnoConversion::FillScRange( aLabelRange, aLabelArea );
+ Modify_Impl( &aLabelRange, NULL );
+}
+
+table::CellRangeAddress SAL_CALL ScLabelRangeObj::getDataArea()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aRet;
+ ScRangePair* pData = GetData_Impl();
+ if (pData)
+ ScUnoConversion::FillApiRange( aRet, pData->GetRange(1) );
+ return aRet;
+}
+
+void SAL_CALL ScLabelRangeObj::setDataArea( const table::CellRangeAddress& aDataArea )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScRange aDataRange;
+ ScUnoConversion::FillScRange( aDataRange, aDataArea );
+ Modify_Impl( NULL, &aDataRange );
+}
+
+//------------------------------------------------------------------------
+
+ScLabelRangesObj::ScLabelRangesObj(ScDocShell* pDocSh, sal_Bool bCol) :
+ pDocShell( pDocSh ),
+ bColumn( bCol )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScLabelRangesObj::~ScLabelRangesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScLabelRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// sheet::XLabelRanges
+
+ScLabelRangeObj* ScLabelRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangePairList* pList = bColumn ? pDoc->GetColNameRanges() : pDoc->GetRowNameRanges();
+ if ( pList && nIndex < pList->Count() )
+ {
+ ScRangePair* pData = pList->GetObject(nIndex);
+ if (pData)
+ return new ScLabelRangeObj( pDocShell, bColumn, pData->GetRange(0) );
+ }
+ }
+ return NULL;
+}
+
+void SAL_CALL ScLabelRangesObj::addNew( const table::CellRangeAddress& aLabelArea,
+ const table::CellRangeAddress& aDataArea )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangePairList* pOldList = bColumn ? pDoc->GetColNameRanges() : pDoc->GetRowNameRanges();
+ if (pOldList)
+ {
+ ScRangePairListRef xNewList(pOldList->Clone());
+
+ ScRange aLabelRange;
+ ScRange aDataRange;
+ ScUnoConversion::FillScRange( aLabelRange, aLabelArea );
+ ScUnoConversion::FillScRange( aDataRange, aDataArea );
+ xNewList->Join( ScRangePair( aLabelRange, aDataRange ) );
+
+ if (bColumn)
+ pDoc->GetColNameRangesRef() = xNewList;
+ else
+ pDoc->GetRowNameRangesRef() = xNewList;
+
+ pDoc->CompileColRowNameFormula();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+
+ //! Undo ?!?! (hier und aus Dialog)
+ }
+ }
+}
+
+void SAL_CALL ScLabelRangesObj::removeByIndex( sal_Int32 nIndex )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bDone = FALSE;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangePairList* pOldList = bColumn ? pDoc->GetColNameRanges() : pDoc->GetRowNameRanges();
+
+ if ( pOldList && nIndex >= 0 && nIndex < (sal_Int32)pOldList->Count() )
+ {
+ ScRangePairListRef xNewList(pOldList->Clone());
+
+ ScRangePair* pEntry = xNewList->GetObject( nIndex );
+ if (pEntry)
+ {
+ xNewList->Remove( pEntry );
+ delete pEntry;
+
+ if (bColumn)
+ pDoc->GetColNameRangesRef() = xNewList;
+ else
+ pDoc->GetRowNameRangesRef() = xNewList;
+
+ pDoc->CompileColRowNameFormula();
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ pDocShell->SetDocumentModified();
+ bDone = TRUE;
+
+ //! Undo ?!?! (hier und aus Dialog)
+ }
+ }
+ }
+ if (!bDone)
+ throw uno::RuntimeException(); // no other exceptions specified
+}
+
+// container::XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScLabelRangesObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.LabelRangesEnumeration")));
+}
+
+// container::XIndexAccess
+
+sal_Int32 SAL_CALL ScLabelRangesObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScRangePairList* pList = bColumn ? pDoc->GetColNameRanges() : pDoc->GetRowNameRanges();
+ if (pList)
+ return pList->Count();
+ }
+ return 0;
+}
+
+uno::Any SAL_CALL ScLabelRangesObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< sheet::XLabelRange > xRange(GetObjectByIndex_Impl((sal_uInt16)nIndex));
+ if ( xRange.is() )
+ return uno::makeAny(xRange);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScLabelRangesObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::getCppuType((const uno::Reference< sheet::XLabelRange >*)0); // muss zu getByIndex passen
+
+}
+
+sal_Bool SAL_CALL ScLabelRangesObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+//------------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/notesuno.cxx b/sc/source/ui/unoobj/notesuno.cxx
new file mode 100644
index 000000000000..7be42a6ae54a
--- /dev/null
+++ b/sc/source/ui/unoobj/notesuno.cxx
@@ -0,0 +1,735 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <svl/smplhint.hxx>
+
+
+#include "rangelst.hxx"
+#include <editeng/unotext.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdobj.hxx>
+#include <vcl/svapp.hxx>
+#include "notesuno.hxx"
+#include "textuno.hxx"
+#include "cellsuno.hxx" // getParent
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "hints.hxx"
+#include "editsrc.hxx"
+#include "miscuno.hxx"
+
+// setVisible:
+#include <svx/svdundo.hxx>
+#include "drwlayer.hxx"
+#include "detfunc.hxx"
+#include "undocell.hxx"
+#include "userdat.hxx"
+#include <editeng/outlobj.hxx>
+#include <svx/unoshape.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdpage.hxx>
+#include <com/sun/star/drawing/XShapeDescriptor.hpp>
+#include <editeng/unoprnms.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+const SvxItemPropertySet* lcl_GetAnnotationPropertySet()
+{
+ static SfxItemPropertyMapEntry aAnnotationPropertyMap_Impl[] =
+ {
+ SVX_UNOEDIT_CHAR_PROPERTIES,
+ SVX_UNOEDIT_FONT_PROPERTIES,
+ SVX_UNOEDIT_PARA_PROPERTIES,
+ SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
+ {0,0,0,0,0,0}
+ };
+ static SvxItemPropertySet aAnnotationPropertySet_Impl( aAnnotationPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
+ return &aAnnotationPropertySet_Impl;
+}
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScAnnotationObj, "ScAnnotationObj", "com.sun.star.sheet.CellAnnotation" )
+SC_SIMPLE_SERVICE_INFO( ScAnnotationShapeObj, "ScAnnotationShapeObj", "com.sun.star.sheet.CellAnnotationShape" )
+
+//------------------------------------------------------------------------
+
+ScAnnotationObj::ScAnnotationObj(ScDocShell* pDocSh, const ScAddress& rPos) :
+ pDocShell( pDocSh ),
+ aCellPos( rPos ),
+ pUnoText( NULL )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ // pUnoText is allocated on demand (GetUnoText)
+ // can't be aggregated because getString/setString is handled here
+}
+
+ScAnnotationObj::~ScAnnotationObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+
+ if (pUnoText)
+ pUnoText->release();
+}
+
+void ScAnnotationObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Ref-Update
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+
+// XChild
+
+uno::Reference<uno::XInterface> SAL_CALL ScAnnotationObj::getParent() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // Parent der Notiz ist die zugehoerige Zelle
+ //! existierendes Objekt finden und zurueckgeben ???
+
+ if (pDocShell)
+ return (cppu::OWeakObject*)new ScCellObj( pDocShell, aCellPos );
+
+ return NULL;
+}
+
+void SAL_CALL ScAnnotationObj::setParent( const uno::Reference<uno::XInterface>& /* Parent */ )
+ throw(lang::NoSupportException, uno::RuntimeException)
+{
+ // hamma nich
+ //! Exception oder so ??!
+}
+
+// XSimpleText
+
+uno::Reference<text::XTextCursor> SAL_CALL ScAnnotationObj::createTextCursor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // Notizen brauchen keine Extrawurst
+ return GetUnoText().createTextCursor();
+}
+
+uno::Reference<text::XTextCursor> SAL_CALL ScAnnotationObj::createTextCursorByRange(
+ const uno::Reference<text::XTextRange>& aTextPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // Notizen brauchen keine Extrawurst
+ return GetUnoText().createTextCursorByRange(aTextPosition);
+}
+
+rtl::OUString SAL_CALL ScAnnotationObj::getString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getString();
+}
+
+void SAL_CALL ScAnnotationObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().setString(aText);
+}
+
+void SAL_CALL ScAnnotationObj::insertString( const uno::Reference<text::XTextRange>& xRange,
+ const rtl::OUString& aString, sal_Bool bAbsorb )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().insertString( xRange, aString, bAbsorb );
+}
+
+void SAL_CALL ScAnnotationObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().insertControlCharacter( xRange, nControlCharacter, bAbsorb );
+}
+
+uno::Reference<text::XText> SAL_CALL ScAnnotationObj::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getText();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScAnnotationObj::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getStart();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScAnnotationObj::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getEnd();
+}
+
+// XSheetAnnotation
+
+table::CellAddress SAL_CALL ScAnnotationObj::getPosition() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellAddress aAdr;
+ aAdr.Sheet = aCellPos.Tab();
+ aAdr.Column = aCellPos.Col();
+ aAdr.Row = aCellPos.Row();
+ return aAdr;
+}
+
+rtl::OUString SAL_CALL ScAnnotationObj::getAuthor() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScPostIt* pNote = ImplGetNote();
+ return pNote ? pNote->GetAuthor() : rtl::OUString();
+}
+
+rtl::OUString SAL_CALL ScAnnotationObj::getDate() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScPostIt* pNote = ImplGetNote();
+ return pNote ? pNote->GetDate() : rtl::OUString();
+}
+
+sal_Bool SAL_CALL ScAnnotationObj::getIsVisible() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const ScPostIt* pNote = ImplGetNote();
+ return pNote && pNote->IsCaptionShown();
+}
+
+void SAL_CALL ScAnnotationObj::setIsVisible( sal_Bool bIsVisible ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // show/hide note with undo action
+ if( pDocShell )
+ pDocShell->GetDocFunc().ShowNote( aCellPos, bIsVisible );
+}
+
+// XSheetAnnotationShapeSupplier
+uno::Reference < drawing::XShape > SAL_CALL ScAnnotationObj::getAnnotationShape()
+ throw(::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScAnnotationShapeObj(pDocShell, aCellPos);
+}
+
+SvxUnoText& ScAnnotationObj::GetUnoText()
+{
+ if (!pUnoText)
+ {
+ ScAnnotationEditSource aEditSource( pDocShell, aCellPos );
+ pUnoText = new SvxUnoText( &aEditSource, lcl_GetAnnotationPropertySet(),
+ uno::Reference<text::XText>() );
+ pUnoText->acquire();
+ }
+ return *pUnoText;
+}
+
+const ScPostIt* ScAnnotationObj::ImplGetNote() const
+{
+ return pDocShell ? pDocShell->GetDocument()->GetNote( aCellPos ) : 0;
+}
+//------------------------------------------------------------------------
+
+ScAnnotationShapeObj::ScAnnotationShapeObj(ScDocShell* pDocSh, const ScAddress& rPos) :
+ pDocShell( pDocSh ),
+ aCellPos( rPos ),
+ pUnoText( NULL )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ // pUnoText is allocated on demand (GetUnoText)
+ // can't be aggregated because getString/setString is handled here
+}
+
+SvxUnoText& ScAnnotationShapeObj::GetUnoText()
+{
+ if (!pUnoText)
+ {
+ ScAnnotationEditSource aEditSource( pDocShell, aCellPos );
+ pUnoText = new SvxUnoText( &aEditSource, lcl_GetAnnotationPropertySet(),
+ uno::Reference<text::XText>() );
+ pUnoText->acquire();
+ }
+ return *pUnoText;
+}
+
+uno::Reference < drawing::XShape > ScAnnotationShapeObj::GetXShape()
+{
+ if (!xShape.is())
+ if( ScPostIt* pNote = pDocShell->GetDocument()->GetNote( aCellPos ) )
+ if( SdrObject* pCaption = pNote->GetOrCreateCaption( aCellPos ) )
+ xShape.set( pCaption->getUnoShape(), uno::UNO_QUERY );
+ return xShape;
+}
+
+ScAnnotationShapeObj::~ScAnnotationShapeObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+ if (pUnoText)
+ pUnoText->release();
+}
+
+void ScAnnotationShapeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Ref-Update
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+
+// XChild
+
+uno::Reference<uno::XInterface> SAL_CALL ScAnnotationShapeObj::getParent() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // Parent der Notiz ist die zugehoerige Zelle
+ //! existierendes Objekt finden und zurueckgeben ???
+
+ if (pDocShell)
+ return (cppu::OWeakObject*)new ScCellObj( pDocShell, aCellPos );
+
+ return NULL;
+}
+
+void SAL_CALL ScAnnotationShapeObj::setParent( const uno::Reference<uno::XInterface>& /* Parent */ )
+ throw(lang::NoSupportException, uno::RuntimeException)
+{
+ // hamma nich
+ //! Exception oder so ??!
+}
+
+// XElementAccess
+uno::Type SAL_CALL ScAnnotationShapeObj::getElementType( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return GetUnoText().getElementType();
+}
+
+sal_Bool SAL_CALL ScAnnotationShapeObj::hasElements( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return GetUnoText().hasElements();
+}
+
+// XEnumerationAccess
+uno::Reference< container::XEnumeration > SAL_CALL ScAnnotationShapeObj::createEnumeration( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ return GetUnoText().createEnumeration();
+}
+
+// XTextRangeMover
+void SAL_CALL ScAnnotationShapeObj::moveTextRange( const uno::Reference< text::XTextRange >& xRange, sal_Int16 nParagraphs )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetUnoText().moveTextRange( xRange, nParagraphs );
+}
+
+// XText
+void SAL_CALL ScAnnotationShapeObj::insertTextContent( const uno::Reference< text::XTextRange >& xRange,
+ const uno::Reference< text::XTextContent >& xContent, sal_Bool bAbsorb )
+ throw (lang::IllegalArgumentException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetUnoText().insertTextContent( xRange, xContent, bAbsorb );
+}
+
+void SAL_CALL ScAnnotationShapeObj::removeTextContent( const uno::Reference< text::XTextContent >& xContent )
+ throw (container::NoSuchElementException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetUnoText().removeTextContent( xContent );
+}
+
+// XSimpleText
+
+uno::Reference<text::XTextCursor> SAL_CALL ScAnnotationShapeObj::createTextCursor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // Notizen brauchen keine Extrawurst
+ return GetUnoText().createTextCursor();
+}
+
+uno::Reference<text::XTextCursor> SAL_CALL ScAnnotationShapeObj::createTextCursorByRange(
+ const uno::Reference<text::XTextRange>& aTextPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // Notizen brauchen keine Extrawurst
+ return GetUnoText().createTextCursorByRange(aTextPosition);
+}
+
+rtl::OUString SAL_CALL ScAnnotationShapeObj::getString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getString();
+}
+
+void SAL_CALL ScAnnotationShapeObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().setString(aText);
+}
+
+void SAL_CALL ScAnnotationShapeObj::insertString( const uno::Reference<text::XTextRange>& xRange,
+ const rtl::OUString& aString, sal_Bool bAbsorb )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().insertString( xRange, aString, bAbsorb );
+}
+
+void SAL_CALL ScAnnotationShapeObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetUnoText().insertControlCharacter( xRange, nControlCharacter, bAbsorb );
+}
+
+uno::Reference<text::XText> SAL_CALL ScAnnotationShapeObj::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getText();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScAnnotationShapeObj::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getStart();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScAnnotationShapeObj::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return GetUnoText().getEnd();
+}
+
+// XShapeDescriptor
+::rtl::OUString SAL_CALL ScAnnotationShapeObj::getShapeType( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < drawing::XShapeDescriptor > xDesc(GetXShape(), uno::UNO_QUERY);
+ if (xDesc.is())
+ return xDesc->getShapeType();
+ return rtl::OUString();
+}
+
+// XShape
+awt::Point SAL_CALL ScAnnotationShapeObj::getPosition( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetXShape();
+ return xShape.is() ? xShape->getPosition() : awt::Point();
+}
+
+void SAL_CALL ScAnnotationShapeObj::setPosition( const awt::Point& aPosition )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetXShape();
+ if( xShape.is() )
+ xShape->setPosition(aPosition);
+}
+
+awt::Size SAL_CALL ScAnnotationShapeObj::getSize( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetXShape();
+ return xShape.is() ? xShape->getSize() : awt::Size();
+}
+
+void SAL_CALL ScAnnotationShapeObj::setSize( const awt::Size& aSize )
+ throw (beans::PropertyVetoException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ GetXShape();
+ if( xShape.is() )
+ xShape->setSize(aSize);
+}
+
+// XPropertyState
+beans::PropertyState SAL_CALL ScAnnotationShapeObj::getPropertyState( const rtl::OUString& PropertyName )
+ throw (beans::UnknownPropertyException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertyState > xState (GetXShape(), uno::UNO_QUERY);
+ if (xState.is())
+ return xState->getPropertyState( PropertyName );
+ return beans::PropertyState();
+}
+
+uno::Sequence< beans::PropertyState > SAL_CALL ScAnnotationShapeObj::getPropertyStates(
+ const uno::Sequence< rtl::OUString >& aPropertyName )
+ throw (beans::UnknownPropertyException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertyState > xState (GetXShape(), uno::UNO_QUERY);
+ if (xState.is())
+ return xState->getPropertyStates( aPropertyName );
+ return uno::Sequence< beans::PropertyState >();
+}
+
+void SAL_CALL ScAnnotationShapeObj::setPropertyToDefault( const ::rtl::OUString& PropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertyState > xState (GetXShape(), uno::UNO_QUERY);
+ if (xState.is())
+ xState->setPropertyToDefault( PropertyName );
+}
+
+uno::Any SAL_CALL ScAnnotationShapeObj::getPropertyDefault( const rtl::OUString& aPropertyName )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertyState > xState (GetXShape(), uno::UNO_QUERY);
+ if (xState.is())
+ return xState->getPropertyDefault( aPropertyName );
+ return uno::Any();
+}
+
+// XPropertySet
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ScAnnotationShapeObj::getPropertySetInfo( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->getPropertySetInfo();
+ return uno::Reference< beans::XPropertySetInfo >();
+}
+
+void SAL_CALL ScAnnotationShapeObj::setPropertyValue( const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw (beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ xProp->setPropertyValue( aPropertyName, aValue );
+}
+
+uno::Any SAL_CALL ScAnnotationShapeObj::getPropertyValue( const rtl::OUString& PropertyName )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->getPropertyValue( PropertyName );
+ return uno::Any();
+}
+
+void SAL_CALL ScAnnotationShapeObj::addPropertyChangeListener( const rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& xListener )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->addPropertyChangeListener( aPropertyName, xListener );
+}
+
+void SAL_CALL ScAnnotationShapeObj::removePropertyChangeListener( const rtl::OUString& aPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& aListener )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->removePropertyChangeListener( aPropertyName, aListener );
+}
+
+void SAL_CALL ScAnnotationShapeObj::addVetoableChangeListener( const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XVetoableChangeListener >& aListener )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->addVetoableChangeListener( PropertyName, aListener );
+}
+
+void SAL_CALL ScAnnotationShapeObj::removeVetoableChangeListener( const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XVetoableChangeListener >& aListener )
+ throw (beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->removeVetoableChangeListener( PropertyName, aListener );
+}
+
+ // XMultiPropertySet
+void SAL_CALL ScAnnotationShapeObj::setPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames,
+ const uno::Sequence< uno::Any >& aValues )
+ throw (beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XMultiPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ xProp->setPropertyValues( aPropertyNames, aValues );
+}
+
+uno::Sequence< uno::Any > SAL_CALL ScAnnotationShapeObj::getPropertyValues(
+ const uno::Sequence< rtl::OUString >& aPropertyNames )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XMultiPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ return xProp->getPropertyValues( aPropertyNames );
+ return uno::Sequence< uno::Any >();
+}
+
+void SAL_CALL ScAnnotationShapeObj::addPropertiesChangeListener( const uno::Sequence< rtl::OUString >& aPropertyNames,
+ const uno::Reference< beans::XPropertiesChangeListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XMultiPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ xProp->addPropertiesChangeListener( aPropertyNames, xListener );
+}
+
+void SAL_CALL ScAnnotationShapeObj::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XMultiPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ xProp->removePropertiesChangeListener( xListener );
+}
+
+void SAL_CALL ScAnnotationShapeObj::firePropertiesChangeEvent( const uno::Sequence< rtl::OUString >& aPropertyNames,
+ const uno::Reference< beans::XPropertiesChangeListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < beans::XMultiPropertySet > xProp (GetXShape(), uno::UNO_QUERY);
+ if (xProp.is())
+ xProp->firePropertiesChangeEvent( aPropertyNames, xListener );
+}
+
+ // XComponent
+void SAL_CALL ScAnnotationShapeObj::dispose( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < lang::XComponent > xComp (GetXShape(), uno::UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ if (xShape.is())
+ xShape.clear();
+}
+
+void SAL_CALL ScAnnotationShapeObj::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < lang::XComponent > xComp (GetXShape(), uno::UNO_QUERY);
+ if (xComp.is())
+ xComp->addEventListener( xListener );
+}
+
+void SAL_CALL ScAnnotationShapeObj::removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference < lang::XComponent > xComp (GetXShape(), uno::UNO_QUERY);
+ if (xComp.is())
+ xComp->removeEventListener( aListener );
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/optuno.cxx b/sc/source/ui/unoobj/optuno.cxx
new file mode 100644
index 000000000000..a7b929fb298f
--- /dev/null
+++ b/sc/source/ui/unoobj/optuno.cxx
@@ -0,0 +1,238 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <svl/itemprop.hxx>
+
+#include <com/sun/star/util/Date.hpp>
+
+#include "optuno.hxx"
+#include "miscuno.hxx"
+#include "unonames.hxx"
+#include "docoptio.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+// static
+const SfxItemPropertyMapEntry* ScDocOptionsHelper::GetPropertyMap()
+{
+ static SfxItemPropertyMapEntry aMap[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN , &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_DEFTABSTOP), PROP_UNO_DEFTABSTOP , &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_IGNORECASE), PROP_UNO_IGNORECASE , &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ITERENABLED), PROP_UNO_ITERENABLED , &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ITERCOUNT), PROP_UNO_ITERCOUNT , &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ITEREPSILON), PROP_UNO_ITEREPSILON , &getCppuType((double*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_LOOKUPLABELS), PROP_UNO_LOOKUPLABELS, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_MATCHWHOLE), PROP_UNO_MATCHWHOLE , &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_NULLDATE), PROP_UNO_NULLDATE , &getCppuType((util::Date*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SPELLONLINE), PROP_UNO_SPELLONLINE , &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_STANDARDDEC), PROP_UNO_STANDARDDEC , &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_REGEXENABLED), PROP_UNO_REGEXENABLED, &getBooleanCppuType(), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aMap;
+}
+
+// static
+sal_Bool ScDocOptionsHelper::setPropertyValue( ScDocOptions& rOptions,
+ const SfxItemPropertyMap& rPropMap,
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+{
+ //! use map (with new identifiers)
+
+ const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName(aPropertyName );
+ if( !pEntry || !pEntry->nWID )
+ return sal_False;
+ switch( pEntry->nWID )
+ {
+ case PROP_UNO_CALCASSHOWN :
+ rOptions.SetCalcAsShown( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ case PROP_UNO_DEFTABSTOP :
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ rOptions.SetTabDistance( nIntVal );
+ }
+ break;
+ case PROP_UNO_IGNORECASE :
+ rOptions.SetIgnoreCase( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ case PROP_UNO_ITERENABLED:
+ rOptions.SetIter( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ case PROP_UNO_ITERCOUNT :
+ {
+ sal_Int32 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ rOptions.SetIterCount( (USHORT)nIntVal );
+ }
+ break;
+ case PROP_UNO_ITEREPSILON :
+ {
+ double fDoubleVal = 0;
+ if ( aValue >>= fDoubleVal )
+ rOptions.SetIterEps( fDoubleVal );
+ }
+ break;
+ case PROP_UNO_LOOKUPLABELS :
+ rOptions.SetLookUpColRowNames( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ case PROP_UNO_MATCHWHOLE :
+ rOptions.SetMatchWholeCell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ case PROP_UNO_NULLDATE:
+ {
+ util::Date aDate;
+ if ( aValue >>= aDate )
+ rOptions.SetDate( aDate.Day, aDate.Month, aDate.Year );
+ }
+ break;
+ case PROP_UNO_SPELLONLINE:
+ rOptions.SetAutoSpell( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ case PROP_UNO_STANDARDDEC:
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ rOptions.SetStdPrecision( nIntVal );
+ }
+ break;
+ case PROP_UNO_REGEXENABLED:
+ rOptions.SetFormulaRegexEnabled( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ break;
+ default:;
+ }
+ return sal_True;
+}
+
+// static
+uno::Any ScDocOptionsHelper::getPropertyValue(
+ const ScDocOptions& rOptions,
+ const SfxItemPropertyMap& rPropMap,
+ const rtl::OUString& aPropertyName )
+{
+ uno::Any aRet;
+ const SfxItemPropertySimpleEntry* pEntry = rPropMap.getByName( aPropertyName );
+ if( !pEntry || !pEntry->nWID )
+ return aRet;
+ switch( pEntry->nWID )
+ {
+ case PROP_UNO_CALCASSHOWN :
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsCalcAsShown() );
+ break;
+ case PROP_UNO_DEFTABSTOP :
+ aRet <<= (sal_Int16)( rOptions.GetTabDistance() );
+ break;
+ case PROP_UNO_IGNORECASE :
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIgnoreCase() );
+ break;
+ case PROP_UNO_ITERENABLED:
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsIter() );
+ break;
+ case PROP_UNO_ITERCOUNT:
+ aRet <<= (sal_Int32)( rOptions.GetIterCount() );
+ break;
+ case PROP_UNO_ITEREPSILON:
+ aRet <<= (double)( rOptions.GetIterEps() );
+ break;
+ case PROP_UNO_LOOKUPLABELS:
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsLookUpColRowNames() );
+ break;
+ case PROP_UNO_MATCHWHOLE:
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsMatchWholeCell() );
+ break;
+ case PROP_UNO_NULLDATE:
+ {
+ USHORT nD, nM, nY;
+ rOptions.GetDate( nD, nM, nY );
+ util::Date aDate( nD, nM, nY );
+ aRet <<= aDate;
+ }
+ break;
+ case PROP_UNO_SPELLONLINE:
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsAutoSpell() );
+ break;
+ case PROP_UNO_STANDARDDEC :
+ aRet <<= (sal_Int16)( rOptions.GetStdPrecision() );
+ break;
+ case PROP_UNO_REGEXENABLED:
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOptions.IsFormulaRegexEnabled() );
+ break;
+ default:;
+ }
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+ScDocOptionsObj::ScDocOptionsObj( const ScDocOptions& rOpt ) :
+ ScModelObj( NULL ),
+ aOptions( rOpt )
+{
+}
+
+ScDocOptionsObj::~ScDocOptionsObj()
+{
+}
+
+void SAL_CALL ScDocOptionsObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ BOOL bDone = ScDocOptionsHelper::setPropertyValue( aOptions, *GetPropertySet().getPropertyMap(), aPropertyName, aValue );
+
+ if (!bDone)
+ ScModelObj::setPropertyValue( aPropertyName, aValue );
+}
+
+uno::Any SAL_CALL ScDocOptionsObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Any aRet(ScDocOptionsHelper::getPropertyValue( aOptions, *GetPropertySet().getPropertyMap(), aPropertyName ));
+ if ( !aRet.hasValue() )
+ aRet = ScModelObj::getPropertyValue( aPropertyName );
+
+ return aRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/pageuno.cxx b/sc/source/ui/unoobj/pageuno.cxx
new file mode 100644
index 000000000000..e65a8e241a0e
--- /dev/null
+++ b/sc/source/ui/unoobj/pageuno.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "pageuno.hxx"
+#include "shapeuno.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+ScPageObj::ScPageObj( SdrPage* pPage ) :
+ SvxFmDrawPage( pPage )
+{
+}
+
+ScPageObj::~ScPageObj() throw()
+{
+}
+
+uno::Reference<drawing::XShape > ScPageObj::_CreateShape( SdrObject *pObj ) const throw()
+{
+ uno::Reference<drawing::XShape> xShape(SvxFmDrawPage::_CreateShape( pObj ));
+
+ new ScShapeObj( xShape ); // aggregates object and modifies xShape
+
+ return xShape;
+}
+
+::rtl::OUString SAL_CALL ScPageObj::getImplementationName()
+ throw(uno::RuntimeException)
+{
+ return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScPageObj"));
+}
+
+sal_Bool SAL_CALL ScPageObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr(rServiceName);
+ return aServiceStr.EqualsAscii( "com.sun.star.sheet.SpreadsheetDrawPage" );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScPageObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(1);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDrawPage"));
+ return aRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx
new file mode 100644
index 000000000000..21b3e2030a36
--- /dev/null
+++ b/sc/source/ui/unoobj/scdetect.cxx
@@ -0,0 +1,903 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scdetect.hxx"
+
+#include <sal/macros.h>
+
+#include <framework/interaction.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/ucb/CommandAbortedException.hpp>
+#include <com/sun/star/ucb/InteractiveAppException.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+
+
+#include <framework/interaction.hxx>
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <ucbhelper/simpleinteractionrequest.hxx>
+
+#include <svtools/parhtml.hxx>
+#include <rtl/ustring.h>
+#include <rtl/logfile.hxx>
+#include <svl/itemset.hxx>
+#include <vcl/window.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <tools/urlobj.hxx>
+#include <osl/mutex.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/ehdl.hxx>
+#include <sot/storinfo.hxx>
+#include <vcl/svapp.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/request.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/brokenpackageint.hxx>
+#include <sot/storage.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+using ::rtl::OUString;
+
+ScFilterDetect::ScFilterDetect( const REFERENCE < ::com::sun::star::lang::XMultiServiceFactory >& /* xFactory */ )
+{
+}
+
+ScFilterDetect::~ScFilterDetect()
+{
+}
+
+static const sal_Char __FAR_DATA pFilterSc50[] = "StarCalc 5.0";
+static const sal_Char __FAR_DATA pFilterSc50Temp[] = "StarCalc 5.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterSc40[] = "StarCalc 4.0";
+static const sal_Char __FAR_DATA pFilterSc40Temp[] = "StarCalc 4.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterSc30[] = "StarCalc 3.0";
+static const sal_Char __FAR_DATA pFilterSc30Temp[] = "StarCalc 3.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterSc10[] = "StarCalc 1.0";
+static const sal_Char __FAR_DATA pFilterXML[] = "StarOffice XML (Calc)";
+static const sal_Char __FAR_DATA pFilterAscii[] = "Text - txt - csv (StarCalc)";
+static const sal_Char __FAR_DATA pFilterLotus[] = "Lotus";
+static const sal_Char __FAR_DATA pFilterQPro6[] = "Quattro Pro 6.0";
+static const sal_Char __FAR_DATA pFilterExcel4[] = "MS Excel 4.0";
+static const sal_Char __FAR_DATA pFilterEx4Temp[] = "MS Excel 4.0 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcel5[] = "MS Excel 5.0/95";
+static const sal_Char __FAR_DATA pFilterEx5Temp[] = "MS Excel 5.0/95 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcel95[] = "MS Excel 95";
+static const sal_Char __FAR_DATA pFilterEx95Temp[] = "MS Excel 95 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilterExcel97[] = "MS Excel 97";
+static const sal_Char __FAR_DATA pFilterEx97Temp[] = "MS Excel 97 Vorlage/Template";
+static const sal_Char __FAR_DATA pFilter2003XML[] = "MS Excel 2003 XML";
+static const sal_Char __FAR_DATA pFilterDBase[] = "dBase";
+static const sal_Char __FAR_DATA pFilterDif[] = "DIF";
+static const sal_Char __FAR_DATA pFilterSylk[] = "SYLK";
+static const sal_Char __FAR_DATA pFilterHtml[] = "HTML (StarCalc)";
+static const sal_Char __FAR_DATA pFilterHtmlWeb[] = "calc_HTML_WebQuery";
+static const sal_Char __FAR_DATA pFilterRtf[] = "Rich Text Format (StarCalc)";
+
+
+static BOOL lcl_MayBeAscii( SvStream& rStream )
+{
+ // ASCII/CSV is considered possible if there are no null bytes, or a Byte
+ // Order Mark is present, or if, for Unicode UCS2/UTF-16, all null bytes
+ // are on either even or uneven byte positions.
+
+ rStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+ const size_t nBufSize = 2048;
+ sal_uInt16 aBuffer[ nBufSize ];
+ sal_uInt8* pByte = reinterpret_cast<sal_uInt8*>(aBuffer);
+ ULONG nBytesRead = rStream.Read( pByte, nBufSize*2);
+
+ if ( nBytesRead >= 2 && (aBuffer[0] == 0xfffe || aBuffer[0] == 0xfeff) )
+ {
+ // Unicode BOM file may contain null bytes.
+ return TRUE;
+ }
+
+ const sal_uInt16* p = aBuffer;
+ sal_uInt16 nMask = 0xffff;
+ nBytesRead /= 2;
+ while( nBytesRead-- && nMask )
+ {
+ sal_uInt16 nVal = *p++ & nMask;
+ if (!(nVal & 0x00ff))
+ nMask &= 0xff00;
+ if (!(nVal & 0xff00))
+ nMask &= 0x00ff;
+ }
+
+ return nMask != 0;
+}
+
+static BOOL lcl_MayBeDBase( SvStream& rStream )
+{
+ // Look for dbf marker, see connectivity/source/inc/dbase/DTable.hxx
+ // DBFType for values.
+ const BYTE nValidMarks[] = {
+ 0x03, 0x04, 0x05, 0x30, 0x43, 0xB3, 0x83, 0x8b, 0x8e, 0xf5 };
+ BYTE nMark;
+ rStream.Seek(STREAM_SEEK_TO_BEGIN);
+ rStream >> nMark;
+ bool bValidMark = false;
+ for (size_t i=0; i < SAL_N_ELEMENTS(nValidMarks) && !bValidMark; ++i)
+ {
+ if (nValidMarks[i] == nMark)
+ bValidMark = true;
+ }
+ if ( !bValidMark )
+ return FALSE;
+
+ const size_t nHeaderBlockSize = 32;
+ // Empty dbf is >= 32*2+1 bytes in size.
+ const size_t nEmptyDbf = nHeaderBlockSize * 2 + 1;
+
+ rStream.Seek(STREAM_SEEK_TO_END);
+ ULONG nSize = rStream.Tell();
+ if ( nSize < nEmptyDbf )
+ return FALSE;
+
+ // length of header starts at 8
+ rStream.Seek(8);
+ USHORT nHeaderLen;
+ rStream >> nHeaderLen;
+
+ if ( nHeaderLen < nEmptyDbf || nSize < nHeaderLen )
+ return FALSE;
+
+ // Last byte of header must be 0x0d, this is how it's specified.
+ // #i9581#,#i26407# but some applications don't follow the specification
+ // and pad the header with one byte 0x00 to reach an
+ // even boundary. Some (#i88577# ) even pad more or pad using a 0x1a ^Z
+ // control character (#i8857#). This results in:
+ // Last byte of header must be 0x0d on 32 bytes boundary.
+ USHORT nBlocks = (nHeaderLen - 1) / nHeaderBlockSize;
+ BYTE nEndFlag = 0;
+ while ( nBlocks > 1 && nEndFlag != 0x0d ) {
+ rStream.Seek( nBlocks-- * nHeaderBlockSize );
+ rStream >> nEndFlag;
+ }
+
+ return ( 0x0d == nEndFlag );
+}
+
+::rtl::OUString SAL_CALL ScFilterDetect::detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lDescriptor ) throw( ::com::sun::star::uno::RuntimeException )
+{
+ REFERENCE< XInputStream > xStream;
+ REFERENCE< XContent > xContent;
+ REFERENCE< XInteractionHandler > xInteraction;
+ String aURL;
+ ::rtl::OUString sTemp;
+ String aTypeName; // a name describing the type (from MediaDescriptor, usually from flat detection)
+ String aPreselectedFilterName; // a name describing the filter to use (from MediaDescriptor, usually from UI action)
+
+ ::rtl::OUString aDocumentTitle; // interesting only if set in this method
+
+ // opening as template is done when a parameter tells to do so and a template filter can be detected
+ // (otherwise no valid filter would be found) or if the detected filter is a template filter and
+ // there is no parameter that forbids to open as template
+ sal_Bool bOpenAsTemplate = sal_False;
+ sal_Bool bWasReadOnly = sal_False, bReadOnly = sal_False;
+
+ sal_Bool bRepairPackage = sal_False;
+ sal_Bool bRepairAllowed = sal_False;
+
+ // now some parameters that can already be in the array, but may be overwritten or new inserted here
+ // remember their indices in the case new values must be added to the array
+ sal_Int32 nPropertyCount = lDescriptor.getLength();
+ sal_Int32 nIndexOfFilterName = -1;
+ sal_Int32 nIndexOfInputStream = -1;
+ sal_Int32 nIndexOfContent = -1;
+ sal_Int32 nIndexOfReadOnlyFlag = -1;
+ sal_Int32 nIndexOfTemplateFlag = -1;
+ sal_Int32 nIndexOfDocumentTitle = -1;
+ bool bFakeXLS = false;
+
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // extract properties
+ if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aURL = sTemp;
+ }
+ else if( !aURL.Len() && lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("FileName")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aURL = sTemp;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("TypeName")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aTypeName = sTemp;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aPreselectedFilterName = sTemp;
+
+ // if the preselected filter name is not correct, it must be erased after detection
+ // remember index of property to get access to it later
+ nIndexOfFilterName = nProperty;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")) )
+ nIndexOfInputStream = nProperty;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")) )
+ nIndexOfReadOnlyFlag = nProperty;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("UCBContent")) )
+ nIndexOfContent = nProperty;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate")) )
+ {
+ lDescriptor[nProperty].Value >>= bOpenAsTemplate;
+ nIndexOfTemplateFlag = nProperty;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) )
+ lDescriptor[nProperty].Value >>= xInteraction;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("RepairPackage")) )
+ lDescriptor[nProperty].Value >>= bRepairPackage;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle")) )
+ nIndexOfDocumentTitle = nProperty;
+ }
+
+ // can't check the type for external filters, so set the "dont" flag accordingly
+ SolarMutexGuard aGuard;
+ //SfxFilterFlags nMust = SFX_FILTER_IMPORT, nDont = SFX_FILTER_NOTINSTALLED;
+
+ SfxAllItemSet *pSet = new SfxAllItemSet( SFX_APP()->GetPool() );
+ TransformParameters( SID_OPENDOC, lDescriptor, *pSet );
+ SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_DOC_READONLY, FALSE );
+
+ bWasReadOnly = pItem && pItem->GetValue();
+
+ const SfxFilter* pFilter = 0;
+ String aPrefix = String::CreateFromAscii( "private:factory/" );
+ if( aURL.Match( aPrefix ) == aPrefix.Len() )
+ {
+ String aPattern( aPrefix );
+ aPattern += String::CreateFromAscii("scalc");
+ if ( aURL.Match( aPattern ) >= aPattern.Len() )
+ pFilter = SfxFilter::GetDefaultFilterFromFactory( aURL );
+ }
+ else
+ {
+ // container for Calc filters
+ SfxFilterMatcher aMatcher( String::CreateFromAscii("scalc") );
+ if ( aPreselectedFilterName.Len() )
+ pFilter = SfxFilter::GetFilterByName( aPreselectedFilterName );
+ else if( aTypeName.Len() )
+ pFilter = aMatcher.GetFilter4EA( aTypeName );
+
+ // ctor of SfxMedium uses owner transition of ItemSet
+ SfxMedium aMedium( aURL, bWasReadOnly ? STREAM_STD_READ : STREAM_STD_READWRITE, FALSE, NULL, pSet );
+ aMedium.UseInteractionHandler( TRUE );
+
+ BOOL bIsStorage = aMedium.IsStorage();
+ if ( aMedium.GetErrorCode() == ERRCODE_NONE )
+ {
+ // remember input stream and content and put them into the descriptor later
+ // should be done here since later the medium can switch to a version
+ xStream.set(aMedium.GetInputStream());
+ xContent.set(aMedium.GetContent());
+ bReadOnly = aMedium.IsReadOnly();
+
+ // maybe that IsStorage() already created an error!
+ if ( bIsStorage )
+ {
+ uno::Reference < embed::XStorage > xStorage(aMedium.GetStorage( sal_False ));
+ if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE )
+ {
+ // error during storage creation means _here_ that the medium
+ // is broken, but we can not handle it in medium since unpossibility
+ // to create a storage does not _always_ means that the medium is broken
+ aMedium.SetError( aMedium.GetLastStorageCreationState(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ if ( xInteraction.is() )
+ {
+ OUString empty;
+ try
+ {
+ InteractiveAppException xException( empty,
+ REFERENCE< XInterface >(),
+ InteractionClassification_ERROR,
+ aMedium.GetError() );
+
+ REFERENCE< XInteractionRequest > xRequest(
+ new ucbhelper::SimpleInteractionRequest( makeAny( xException ),
+ ucbhelper::CONTINUATION_APPROVE ) );
+ xInteraction->handle( xRequest );
+ }
+ catch ( Exception & ) {};
+ }
+ }
+ else if ( xStorage.is() )
+ {
+ try
+ {
+ String aFilterName;
+ if ( pFilter )
+ aFilterName = pFilter->GetName();
+ aTypeName = SfxFilter::GetTypeFromStorage( xStorage, pFilter ? pFilter->IsOwnTemplateFormat() : FALSE, &aFilterName );
+ }
+ catch( lang::WrappedTargetException& aWrap )
+ {
+ packages::zip::ZipIOException aZipException;
+
+ // repairing is done only if this type is requested from outside
+ if ( ( aWrap.TargetException >>= aZipException ) && aTypeName.Len() )
+ {
+ if ( xInteraction.is() )
+ {
+ // the package is broken one
+ aDocumentTitle = aMedium.GetURLObject().getName(
+ INetURLObject::LAST_SEGMENT,
+ true,
+ INetURLObject::DECODE_WITH_CHARSET );
+
+ if ( !bRepairPackage )
+ {
+ // ask the user whether he wants to try to repair
+ RequestPackageReparation* pRequest = new RequestPackageReparation( aDocumentTitle );
+ uno::Reference< task::XInteractionRequest > xRequest ( pRequest );
+
+ xInteraction->handle( xRequest );
+
+ bRepairAllowed = pRequest->isApproved();
+ }
+
+ if ( !bRepairAllowed )
+ {
+ // repair either not allowed or not successful
+ NotifyBrokenPackage* pNotifyRequest = new NotifyBrokenPackage( aDocumentTitle );
+ uno::Reference< task::XInteractionRequest > xRequest ( pNotifyRequest );
+ xInteraction->handle( xRequest );
+ }
+ }
+
+ if ( !bRepairAllowed )
+ aTypeName.Erase();
+ }
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ aTypeName.Erase();
+ }
+
+ if ( aTypeName.Len() )
+ pFilter = SfxFilterMatcher( String::CreateFromAscii("scalc") ).GetFilter4EA( aTypeName );
+
+ }
+ }
+ else
+ {
+ bool bIsXLS = false;
+ SvStream* pStream = aMedium.GetInStream();
+ const SfxFilter* pPreselectedFilter = pFilter;
+ if ( pPreselectedFilter && ( ( pPreselectedFilter->GetName().SearchAscii("Excel") != STRING_NOTFOUND ) ||
+ ( !aPreselectedFilterName.Len() && pPreselectedFilter->GetFilterName().EqualsAscii( pFilterAscii ) ) ) )
+ bIsXLS = true;
+ pFilter = 0;
+ if ( pStream )
+ {
+ SotStorageRef aStorage = new SotStorage ( pStream, FALSE );
+ if ( !aStorage->GetError() )
+ {
+ // Excel-5: detect through contained streams
+ // there are some "excel" formats from 3rd party vendors that need to be distinguished
+ String aStreamName(RTL_CONSTASCII_STRINGPARAM("Workbook"));
+ BOOL bExcel97Stream = ( aStorage->IsStream( aStreamName ) );
+
+ aStreamName = String(RTL_CONSTASCII_STRINGPARAM("Book"));
+ BOOL bExcel5Stream = ( aStorage->IsStream( aStreamName ) );
+ if ( bExcel97Stream || bExcel5Stream )
+ {
+ if ( bExcel97Stream )
+ {
+ String aOldName;
+ BOOL bIsCalcFilter = TRUE;
+ if ( pPreselectedFilter )
+ {
+ // cross filter; now this should be a type detection only, not a filter detection
+ // we can simulate it by preserving the preselected filter if the type matches
+ // example: Excel filters for Writer
+ aOldName = pPreselectedFilter->GetFilterName();
+ bIsCalcFilter = pPreselectedFilter->GetServiceName().EqualsAscii("com.sun.star.sheet.SpreadsheetDocument");
+ }
+
+ if ( aOldName.EqualsAscii(pFilterEx97Temp) || !bIsCalcFilter )
+ {
+ // Excel 97 template selected -> keep selection
+ }
+ else if ( bExcel5Stream &&
+ ( aOldName.EqualsAscii(pFilterExcel5) || aOldName.EqualsAscii(pFilterEx5Temp) ||
+ aOldName.EqualsAscii(pFilterExcel95) || aOldName.EqualsAscii(pFilterEx95Temp) ) )
+ {
+ // dual format file and Excel 5 selected -> keep selection
+ }
+ else
+ {
+ // else use Excel 97 filter
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterExcel97) );
+ }
+ }
+ else if ( bExcel5Stream )
+ {
+ String aOldName;
+ BOOL bIsCalcFilter = TRUE;
+ if ( pPreselectedFilter )
+ {
+ // cross filter; now this should be a type detection only, not a filter detection
+ // we can simulate it by preserving the preselected filter if the type matches
+ // example: Excel filters for Writer
+ aOldName = pPreselectedFilter->GetFilterName();
+ bIsCalcFilter = pPreselectedFilter->GetServiceName().EqualsAscii("com.sun.star.sheet.SpreadsheetDocument");
+ }
+
+ if ( aOldName.EqualsAscii(pFilterExcel95) || aOldName.EqualsAscii(pFilterEx95Temp) ||
+ aOldName.EqualsAscii(pFilterEx5Temp) || !bIsCalcFilter )
+ {
+ // Excel 95 oder Vorlage (5 oder 95) eingestellt -> auch gut
+ }
+ else if ( aOldName.EqualsAscii(pFilterEx97Temp) )
+ {
+ // #101923# auto detection has found template -> return Excel5 template
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterEx5Temp) );
+ }
+ else
+ {
+ // sonst wird als Excel 5-Datei erkannt
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterExcel5) );
+ }
+ }
+ }
+ }
+ else
+ {
+ SvStream &rStr = *pStream;
+
+ // Tabelle mit Suchmustern
+ // Bedeutung der Sequenzen
+ // 0x00??: genau Byte 0x?? muss an dieser Stelle stehen
+ // 0x0100: ein Byte ueberlesen (don't care)
+ // 0x02nn: ein Byte aus 0xnn Alternativen folgt
+ // 0x8000: Erkennung abgeschlossen
+ //
+
+ #define M_DC 0x0100
+ #define M_ALT(ANZ) (0x0200+(ANZ))
+ #define M_ENDE 0x8000
+
+ static const UINT16 pLotus[] = // Lotus 1/1A/2
+ { 0x0000, 0x0000, 0x0002, 0x0000,
+ M_ALT(2), 0x0004, 0x0006,
+ 0x0004, M_ENDE };
+
+ static const UINT16 pLotusNew[] = // Lotus >= 9.7
+ { 0x0000, 0x0000, M_DC, 0x0000, // Rec# + Len (0x1a)
+ M_ALT(3), 0x0003, 0x0004, 0x0005, // File Revision Code 97->ME
+ 0x0010, 0x0004, 0x0000, 0x0000,
+ M_ENDE };
+
+ static const UINT16 pExcel1[] = // Excel BIFF2, BIFF3, BIFF4
+ { 0x09, // lobyte of BOF rec ID (0x0009, 0x0209, 0x0409)
+ M_ALT(3), 0x00, 0x02, 0x04, // hibyte of BOF rec ID (0x0009, 0x0209, 0x0409)
+ M_ALT(3), 4, 6, 8, // lobyte of BOF rec size (4, 6, 8, 16)
+ 0x00, // hibyte of BOF rec size (4, 6, 8, 16)
+ M_DC, M_DC, // any version
+ M_ALT(3), 0x10, 0x20, 0x40, // lobyte of data type (0x0010, 0x0020, 0x0040)
+ 0x00, // hibyte of data type (0x0010, 0x0020, 0x0040)
+ M_ENDE };
+
+ static const UINT16 pExcel2[] = // Excel BIFF4 Workspace
+ { 0x09, // lobyte of BOF rec ID (0x0409)
+ 0x04, // hibyte of BOF rec ID (0x0409)
+ M_ALT(3), 4, 6, 8, // lobyte of BOF rec size (4, 6, 8, 16)
+ 0x00, // hibyte of BOF rec size (4, 6, 8, 16)
+ M_DC, M_DC, // any version
+ 0x00, // lobyte of data type (0x0100)
+ 0x01, // hibyte of data type (0x0100)
+ M_ENDE };
+
+ static const UINT16 pExcel3[] = // #i23425# Excel BIFF5, BIFF7, BIFF8 (simple book stream)
+ { 0x09, // lobyte of BOF rec ID (0x0809)
+ 0x08, // hibyte of BOF rec ID (0x0809)
+ M_ALT(4), 4, 6, 8, 16, // lobyte of BOF rec size
+ 0x00, // hibyte of BOF rec size
+ M_DC, M_DC, // any version
+ M_ALT(5), 0x05, 0x06, 0x10, 0x20, 0x40, // lobyte of data type
+ 0x00, // hibyte of data type
+ M_ENDE };
+
+ static const UINT16 pSc10[] = // StarCalc 1.0 Dokumente
+ { 'B', 'l', 'a', 'i', 's', 'e', '-', 'T', 'a', 'b', 'e', 'l', 'l',
+ 'e', 0x000A, 0x000D, 0x0000, // Sc10CopyRight[16]
+ M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC, M_DC,
+ M_DC, M_DC, // Sc10CopyRight[29]
+ M_ALT(2), 0x0065, 0x0066, // Versionsnummer 101 oder 102
+ 0x0000,
+ M_ENDE };
+
+ static const UINT16 pLotus2[] = // Lotus >3
+ { 0x0000, 0x0000, 0x001A, 0x0000, // Rec# + Len (26)
+ M_ALT(2), 0x0000, 0x0002, // File Revision Code
+ 0x0010,
+ 0x0004, 0x0000, // File Revision Subcode
+ M_ENDE };
+
+ static const UINT16 pQPro[] =
+ { 0x0000, 0x0000, 0x0002, 0x0000,
+ M_ALT(4), 0x0001, 0x0002, // WB1, WB2
+ 0x0006, 0x0007, // QPro 6/7 (?)
+ 0x0010,
+ M_ENDE };
+
+ static const UINT16 pDIF1[] = // DIF mit CR-LF
+ {
+ 'T', 'A', 'B', 'L', 'E',
+ M_DC, M_DC,
+ '0', ',', '1',
+ M_DC, M_DC,
+ '\"',
+ M_ENDE };
+
+ static const UINT16 pDIF2[] = // DIF mit CR oder LF
+ {
+ 'T', 'A', 'B', 'L', 'E',
+ M_DC,
+ '0', ',', '1',
+ M_DC,
+ '\"',
+ M_ENDE };
+
+ static const UINT16 pSylk[] = // Sylk
+ {
+ 'I', 'D', ';',
+ M_ALT(3), 'P', 'N', 'E', // 'P' plus undocumented Excel extensions 'N' and 'E'
+ M_ENDE };
+
+ static const UINT16 *ppFilterPatterns[] = // Arrays mit Suchmustern
+ {
+ pLotus,
+ pExcel1,
+ pExcel2,
+ pExcel3,
+ pSc10,
+ pDIF1,
+ pDIF2,
+ pSylk,
+ pLotusNew,
+ pLotus2,
+ pQPro
+ };
+ const UINT16 nFilterCount = SAL_N_ELEMENTS(ppFilterPatterns);
+
+ static const sal_Char* const pFilterName[] = // zugehoerige Filter
+ {
+ pFilterLotus,
+ pFilterExcel4,
+ pFilterExcel4,
+ pFilterExcel4,
+ pFilterSc10,
+ pFilterDif,
+ pFilterDif,
+ pFilterSylk,
+ pFilterLotus,
+ pFilterLotus,
+ pFilterQPro6
+ };
+
+ // const UINT16 nByteMask = 0xFF;
+
+ // suchen Sie jetzt!
+ // ... realisiert ueber 'Mustererkennung'
+
+ BYTE nAkt;
+ BOOL bSync; // Datei und Muster stimmen ueberein
+ USHORT nFilter; // Zaehler ueber alle Filter
+ const UINT16 *pSearch; // aktuelles Musterwort
+
+ for ( nFilter = 0 ; nFilter < nFilterCount ; nFilter++ )
+ {
+ rStr.Seek( 0 ); // am Anfang war alles Uebel...
+ rStr >> nAkt;
+ pSearch = ppFilterPatterns[ nFilter ];
+ bSync = TRUE;
+ while( !rStr.IsEof() && bSync )
+ {
+ register UINT16 nMuster = *pSearch;
+
+ if( nMuster < 0x0100 )
+ { // direkter Byte-Vergleich
+ if( ( BYTE ) nMuster != nAkt )
+ bSync = FALSE;
+ }
+ else if( nMuster & M_DC )
+ { // don't care
+ }
+ else if( nMuster & M_ALT(0) )
+ { // alternative Bytes
+ BYTE nAnzAlt = ( BYTE ) nMuster;
+ bSync = FALSE; // zunaechst unsynchron
+ while( nAnzAlt > 0 )
+ {
+ pSearch++;
+ if( ( BYTE ) *pSearch == nAkt )
+ bSync = TRUE; // jetzt erst Synchronisierung
+ nAnzAlt--;
+ }
+ }
+ else if( nMuster & M_ENDE )
+ { // Format detected
+ if ( pFilterName[nFilter] == pFilterExcel4 && pPreselectedFilter &&
+ ( (pPreselectedFilter)->GetFilterName().EqualsAscii(pFilterEx4Temp) || pPreselectedFilter->GetTypeName().EqualsAscii("calc_MS_Excel_40") ) )
+ {
+ // Excel 4 erkannt, Excel 4 Vorlage eingestellt -> auch gut
+ // oder Excel 4 Filter anderer Applikation (simulated type detection!)
+ }
+ else
+ { // gefundenen Filter einstellen
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterName[ nFilter ]) );
+ }
+ bSync = FALSE; // leave inner loop
+ nFilter = nFilterCount; // leave outer loop
+ }
+ else
+ { // Tabellenfehler
+ DBG_ERROR( "-ScApplication::DetectFilter(): Fehler in Mustertabelle");
+ }
+
+ pSearch++;
+ rStr >> nAkt;
+ }
+ }
+
+ if ( pPreselectedFilter && !pFilter )
+ {
+ // further checks for filters only if they are preselected: ASCII, HTML, RTF, DBase
+ // without the preselection other filters (Writer) take precedence
+ // DBase can't be detected reliably, so it also needs preselection
+ bool bMaybeText = lcl_MayBeAscii( rStr );
+
+ // get file header
+ rStr.Seek( 0 );
+ const int nTrySize = 80;
+ ByteString aHeader;
+ for ( int j = 0; j < nTrySize && !rStr.IsEof(); j++ )
+ {
+ sal_Char c;
+ rStr >> c;
+ aHeader += c;
+ }
+ aHeader += '\0';
+
+ if ( HTMLParser::IsHTMLFormat( aHeader.GetBuffer() ) )
+ {
+ // test for HTML
+ if ( pPreselectedFilter->GetName().EqualsAscii(pFilterHtml) )
+ {
+ pFilter = pPreselectedFilter;
+ }
+ else
+ {
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterHtmlWeb) );
+ if ( bIsXLS )
+ bFakeXLS = true;
+ }
+ }
+ else if ( aHeader.CompareTo( "{\\rtf", 5 ) == COMPARE_EQUAL )
+ {
+ // test for RTF
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterRtf) );
+ }
+ else if ( bIsXLS && bMaybeText )
+ {
+ aHeader.EraseLeadingChars();
+ if( aHeader.CompareTo( "<?xml", 5 ) == COMPARE_EQUAL )
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilter2003XML) );
+ else
+ pFilter = aMatcher.GetFilter4FilterName( String::CreateFromAscii(pFilterAscii) );
+ bFakeXLS = true;
+ }
+ else if ( pPreselectedFilter->GetName().EqualsAscii(pFilterDBase) && lcl_MayBeDBase( rStr ) )
+ pFilter = pPreselectedFilter;
+ else if ( pPreselectedFilter->GetFilterName().EqualsAscii(pFilterAscii) && bMaybeText )
+ pFilter = pPreselectedFilter;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if ( nIndexOfInputStream == -1 && xStream.is() )
+ {
+ // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("InputStream");
+ lDescriptor[nPropertyCount].Value <<= xStream;
+ nPropertyCount++;
+ }
+
+ if ( nIndexOfContent == -1 && xContent.is() )
+ {
+ // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("UCBContent");
+ lDescriptor[nPropertyCount].Value <<= xContent;
+ nPropertyCount++;
+ }
+
+ if ( bReadOnly != bWasReadOnly )
+ {
+ if ( nIndexOfReadOnlyFlag == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("ReadOnly");
+ lDescriptor[nPropertyCount].Value <<= bReadOnly;
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfReadOnlyFlag].Value <<= bReadOnly;
+ }
+
+ if ( !bRepairPackage && bRepairAllowed )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("RepairPackage");
+ lDescriptor[nPropertyCount].Value <<= bRepairAllowed;
+ nPropertyCount++;
+
+ bOpenAsTemplate = sal_True;
+
+ // TODO/LATER: set progress bar that should be used
+ }
+
+ if ( bOpenAsTemplate )
+ {
+ if ( nIndexOfTemplateFlag == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("AsTemplate");
+ lDescriptor[nPropertyCount].Value <<= bOpenAsTemplate;
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfTemplateFlag].Value <<= bOpenAsTemplate;
+ }
+
+ if ( aDocumentTitle.getLength() )
+ {
+ // the title was set here
+ if ( nIndexOfDocumentTitle == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("DocumentTitle");
+ lDescriptor[nPropertyCount].Value <<= aDocumentTitle;
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfDocumentTitle].Value <<= aDocumentTitle;
+ }
+
+ if ( bFakeXLS )
+ {
+ if ( nIndexOfFilterName == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString::createFromAscii("FilterName");
+ lDescriptor[nPropertyCount].Value <<= rtl::OUString(pFilter->GetName());
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfFilterName].Value <<= rtl::OUString(pFilter->GetName());
+ }
+
+ if ( pFilter )
+ aTypeName = pFilter->GetTypeName();
+ else
+ aTypeName.Erase();
+ return aTypeName;
+}
+
+SFX_IMPL_SINGLEFACTORY( ScFilterDetect )
+
+/* XServiceInfo */
+UNOOUSTRING SAL_CALL ScFilterDetect::getImplementationName() throw( UNORUNTIMEEXCEPTION )
+{
+ return impl_getStaticImplementationName();
+}
+ \
+/* XServiceInfo */
+sal_Bool SAL_CALL ScFilterDetect::supportsService( const UNOOUSTRING& sServiceName ) throw( UNORUNTIMEEXCEPTION )
+{
+ UNOSEQUENCE< UNOOUSTRING > seqServiceNames(getSupportedServiceNames());
+ const UNOOUSTRING* pArray = seqServiceNames.getConstArray();
+ for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
+ {
+ if ( pArray[nCounter] == sServiceName )
+ {
+ return sal_True ;
+ }
+ }
+ return sal_False ;
+}
+
+/* XServiceInfo */
+UNOSEQUENCE< UNOOUSTRING > SAL_CALL ScFilterDetect::getSupportedServiceNames() throw( UNORUNTIMEEXCEPTION )
+{
+ return impl_getStaticSupportedServiceNames();
+}
+
+/* Helper for XServiceInfo */
+UNOSEQUENCE< UNOOUSTRING > ScFilterDetect::impl_getStaticSupportedServiceNames()
+{
+ UNOMUTEXGUARD aGuard( UNOMUTEX::getGlobalMutex() );
+ UNOSEQUENCE< UNOOUSTRING > seqServiceNames( 1 );
+ seqServiceNames.getArray() [0] = UNOOUSTRING::createFromAscii( "com.sun.star.frame.ExtendedTypeDetection" );
+ return seqServiceNames ;
+}
+
+/* Helper for XServiceInfo */
+UNOOUSTRING ScFilterDetect::impl_getStaticImplementationName()
+{
+ return UNOOUSTRING::createFromAscii( "com.sun.star.comp.calc.FormatDetector" );
+}
+
+/* Helper for registry */
+UNOREFERENCE< UNOXINTERFACE > SAL_CALL ScFilterDetect::impl_createInstance( const UNOREFERENCE< UNOXMULTISERVICEFACTORY >& xServiceManager ) throw( UNOEXCEPTION )
+{
+ return UNOREFERENCE< UNOXINTERFACE >( *new ScFilterDetect( xServiceManager ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/scdetect.hxx b/sc/source/ui/unoobj/scdetect.hxx
new file mode 100644
index 000000000000..659fe15e5e22
--- /dev/null
+++ b/sc/source/ui/unoobj/scdetect.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SC_TYPEDETECT_HXX
+#define _SC_TYPEDETECT_HXX
+
+#include <rtl/ustring.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <cppuhelper/factory.hxx>
+#include <tools/link.hxx>
+#include <tools/string.hxx>
+
+class SfxObjectFactory;
+class SfxFilterMatcher;
+class LoadEnvironment_Impl;
+class SfxMedium;
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace uno
+ {
+ class Any;
+ }
+ namespace lang
+ {
+ class XMultiServiceFactory;
+ }
+ namespace frame
+ {
+ class XFrame;
+ }
+ namespace beans
+ {
+ struct PropertyValue;
+ }
+ }
+ }
+}
+
+#include <sfx2/sfxuno.hxx>
+
+#define REFERENCE ::com::sun::star::uno::Reference
+#define SEQUENCE ::com::sun::star::uno::Sequence
+#define RUNTIME_EXCEPTION ::com::sun::star::uno::RuntimeException
+
+class ScFilterDetect : public ::cppu::WeakImplHelper2< ::com::sun::star::document::XExtendedFilterDetection, ::com::sun::star::lang::XServiceInfo >
+{
+public:
+ ScFilterDetect( const REFERENCE < ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
+ virtual ~ScFilterDetect();
+
+ SFX_DECL_XSERVICEINFO
+
+ //----------------------------------------------------------------------------------
+ // XExtendedFilterDetect
+ //----------------------------------------------------------------------------------
+ virtual ::rtl::OUString SAL_CALL detect( SEQUENCE< ::com::sun::star::beans::PropertyValue >& lDescriptor ) throw( RUNTIME_EXCEPTION );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx
new file mode 100644
index 000000000000..2b76b5759c78
--- /dev/null
+++ b/sc/source/ui/unoobj/servuno.cxx
@@ -0,0 +1,614 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <tools/debug.hxx>
+#include <sal/macros.h>
+#include <svtools/unoimap.hxx>
+#include <svx/unofill.hxx>
+#include <editeng/unonrule.hxx>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include "servuno.hxx"
+#include "unonames.hxx"
+#include "cellsuno.hxx"
+#include "fielduno.hxx"
+#include "styleuno.hxx"
+#include "afmtuno.hxx"
+#include "defltuno.hxx"
+#include "drdefuno.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "confuno.hxx"
+#include "shapeuno.hxx"
+#include "cellvaluebinding.hxx"
+#include "celllistsource.hxx"
+#include "addruno.hxx"
+#include "chart2uno.hxx"
+#include "tokenuno.hxx"
+
+// #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
+#include <svx/xmleohlp.hxx>
+#include <svx/xmlgrhlp.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/document/XCodeNameQuery.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <svx/unomod.hxx>
+#include <vbahelper/vbaaccesshelper.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <basic/basmgr.hxx>
+#include <sfx2/app.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/document/XCodeNameQuery.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <comphelper/componentcontext.hxx>
+#include <cppuhelper/component_context.hxx>
+#include <vbahelper/vbaaccesshelper.hxx>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+
+using namespace ::com::sun::star;
+
+bool isInVBAMode( ScDocShell& rDocSh )
+{
+ uno::Reference<script::XLibraryContainer> xLibContainer = rDocSh.GetBasicContainer();
+ uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY );
+ if ( xVBACompat.is() )
+ return xVBACompat->getVBACompatibilityMode();
+ return false;
+}
+
+class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess >
+{
+ uno::Any maWorkbook;
+ uno::Any maCachedObject;
+ ScDocShell* mpDocShell;
+public:
+ ScVbaObjectForCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell )
+ {
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ if ( !pDoc )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() );
+
+ uno::Sequence< uno::Any > aArgs(2);
+ // access the application object ( parent for workbook )
+ aArgs[0] = uno::Any( ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.Application", uno::Sequence< uno::Any >() ) );
+ aArgs[1] = uno::Any( mpDocShell->GetModel() );
+ maWorkbook <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs );
+ }
+
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException )
+ {
+ SolarMutexGuard aGuard;
+ maCachedObject = uno::Any(); // clear cached object
+ String sName = aName;
+
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ if ( !pDoc )
+ throw uno::RuntimeException();
+ if ( sName == pDoc->GetCodeName() )
+ maCachedObject = maWorkbook;
+ else
+ {
+ String sCodeName;
+ SCTAB nCount = pDoc->GetTableCount();
+ for( SCTAB i = 0; i < nCount; i++ )
+ {
+ pDoc->GetCodeName( i, sCodeName );
+ if( sCodeName == sName )
+ {
+ String sSheetName;
+ if( pDoc->GetName( i, sSheetName ) )
+ {
+ uno::Reference< frame::XModel > xModel( mpDocShell->GetModel() );
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference<sheet::XSpreadsheets > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xSheets, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xSheet( xIndexAccess->getByIndex( i ), uno::UNO_QUERY_THROW );
+ uno::Sequence< uno::Any > aArgs(3);
+ aArgs[0] = maWorkbook;
+ aArgs[1] = uno::Any( xModel );
+ aArgs[2] = uno::Any( rtl::OUString( sSheetName ) );
+ // use the convience function
+ maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs );
+ break;
+ }
+ }
+ }
+ }
+ return maCachedObject.hasValue();
+
+ }
+ ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
+ {
+ SolarMutexGuard aGuard;
+ OSL_TRACE("ScVbaObjectForCodeNameProvider::getByName( %s )",
+ rtl::OUStringToOString( aName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ if ( !hasByName( aName ) )
+ throw ::com::sun::star::container::NoSuchElementException();
+ return maCachedObject;
+ }
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ SolarMutexGuard aGuard;
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ if ( !pDoc )
+ throw uno::RuntimeException();
+ SCTAB nCount = pDoc->GetTableCount();
+ uno::Sequence< rtl::OUString > aNames( nCount + 1 );
+ SCTAB index = 0;
+ String sCodeName;
+ for( ; index < nCount; ++index )
+ {
+ pDoc->GetCodeName( index, sCodeName );
+ aNames[ index ] = sCodeName;
+ }
+ aNames[ index ] = pDoc->GetCodeName();
+ return aNames;
+ }
+ // XElemenAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException){ return uno::Type(); }
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException ) { return sal_True; }
+
+};
+
+class ScVbaCodeNameProvider : public ::cppu::WeakImplHelper1< document::XCodeNameQuery >
+{
+ScDocShell* mpDocShell;
+public:
+ ScVbaCodeNameProvider( ScDocShell* pDocShell ) : mpDocShell( pDocShell ) {}
+ // XCodeNameQuery
+ rtl::OUString SAL_CALL getCodeNameForObject( const uno::Reference< uno::XInterface >& xIf ) throw( uno::RuntimeException )
+ {
+ SolarMutexGuard aGuard;
+ rtl::OUString sCodeName;
+ if ( mpDocShell )
+ {
+ OSL_TRACE( "*** In ScVbaCodeNameProvider::getCodeNameForObject");
+ // need to find the page ( and index ) for this control
+ uno::Reference< drawing::XDrawPagesSupplier > xSupplier( mpDocShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndex( xSupplier->getDrawPages(), uno::UNO_QUERY_THROW );
+ sal_Int32 nLen = xIndex->getCount();
+ bool bMatched = false;
+ uno::Sequence< script::ScriptEventDescriptor > aFakeEvents;
+ for ( sal_Int32 index = 0; index < nLen; ++index )
+ {
+ try
+ {
+ uno::Reference< form::XFormsSupplier > xFormSupplier( xIndex->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xFormIndex( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+ // get the www-standard container
+ uno::Reference< container::XIndexAccess > xFormControls( xFormIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+ sal_Int32 nCntrls = xFormControls->getCount();
+ for( sal_Int32 cIndex = 0; cIndex < nCntrls; ++cIndex )
+ {
+ uno::Reference< uno::XInterface > xControl( xFormControls->getByIndex( cIndex ), uno::UNO_QUERY_THROW );
+ bMatched = ( xControl == xIf );
+ if ( bMatched )
+ {
+ String sName;
+ mpDocShell->GetDocument()->GetCodeName( static_cast<SCTAB>( index ), sName );
+ sCodeName = sName;
+ }
+ }
+ }
+ catch( uno::Exception& ) {}
+ if ( bMatched )
+ break;
+ }
+ }
+ // Probably should throw here ( if !bMatched )
+ return sCodeName;
+ }
+
+};
+
+//------------------------------------------------------------------------
+//
+struct ProvNamesId_Type
+{
+ const char * pName;
+ sal_uInt16 nType;
+};
+
+static const ProvNamesId_Type __FAR_DATA aProvNamesId[] =
+{
+ { "com.sun.star.sheet.Spreadsheet", SC_SERVICE_SHEET },
+ { "com.sun.star.text.TextField.URL", SC_SERVICE_URLFIELD },
+ { "com.sun.star.text.TextField.PageNumber", SC_SERVICE_PAGEFIELD },
+ { "com.sun.star.text.TextField.PageCount", SC_SERVICE_PAGESFIELD },
+ { "com.sun.star.text.TextField.Date", SC_SERVICE_DATEFIELD },
+ { "com.sun.star.text.TextField.Time", SC_SERVICE_TIMEFIELD },
+ { "com.sun.star.text.TextField.DocumentTitle", SC_SERVICE_TITLEFIELD },
+ { "com.sun.star.text.TextField.FileName", SC_SERVICE_FILEFIELD },
+ { "com.sun.star.text.TextField.SheetName", SC_SERVICE_SHEETFIELD },
+ { "com.sun.star.style.CellStyle", SC_SERVICE_CELLSTYLE },
+ { "com.sun.star.style.PageStyle", SC_SERVICE_PAGESTYLE },
+ { "com.sun.star.sheet.TableAutoFormat", SC_SERVICE_AUTOFORMAT },
+ { "com.sun.star.sheet.SheetCellRanges", SC_SERVICE_CELLRANGES },
+ { "com.sun.star.drawing.GradientTable", SC_SERVICE_GRADTAB },
+ { "com.sun.star.drawing.HatchTable", SC_SERVICE_HATCHTAB },
+ { "com.sun.star.drawing.BitmapTable", SC_SERVICE_BITMAPTAB },
+ { "com.sun.star.drawing.TransparencyGradientTable", SC_SERVICE_TRGRADTAB },
+ { "com.sun.star.drawing.MarkerTable", SC_SERVICE_MARKERTAB },
+ { "com.sun.star.drawing.DashTable", SC_SERVICE_DASHTAB },
+ { "com.sun.star.text.NumberingRules", SC_SERVICE_NUMRULES },
+ { "com.sun.star.sheet.Defaults", SC_SERVICE_DOCDEFLTS },
+ { "com.sun.star.drawing.Defaults", SC_SERVICE_DRAWDEFLTS },
+ { "com.sun.star.comp.SpreadsheetSettings", SC_SERVICE_DOCSPRSETT },
+ { "com.sun.star.document.Settings", SC_SERVICE_DOCCONF },
+ { "com.sun.star.image.ImageMapRectangleObject", SC_SERVICE_IMAP_RECT },
+ { "com.sun.star.image.ImageMapCircleObject", SC_SERVICE_IMAP_CIRC },
+ { "com.sun.star.image.ImageMapPolygonObject", SC_SERVICE_IMAP_POLY },
+
+ // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
+ { "com.sun.star.document.ExportGraphicObjectResolver", SC_SERVICE_EXPORT_GOR },
+ { "com.sun.star.document.ImportGraphicObjectResolver", SC_SERVICE_IMPORT_GOR },
+ { "com.sun.star.document.ExportEmbeddedObjectResolver", SC_SERVICE_EXPORT_EOR },
+ { "com.sun.star.document.ImportEmbeddedObjectResolver", SC_SERVICE_IMPORT_EOR },
+
+ { SC_SERVICENAME_VALBIND, SC_SERVICE_VALBIND },
+ { SC_SERVICENAME_LISTCELLBIND, SC_SERVICE_LISTCELLBIND },
+ { SC_SERVICENAME_LISTSOURCE, SC_SERVICE_LISTSOURCE },
+ { SC_SERVICENAME_CELLADDRESS, SC_SERVICE_CELLADDRESS },
+ { SC_SERVICENAME_RANGEADDRESS, SC_SERVICE_RANGEADDRESS },
+
+ { "com.sun.star.sheet.DocumentSettings",SC_SERVICE_SHEETDOCSET },
+
+ { SC_SERVICENAME_CHDATAPROV, SC_SERVICE_CHDATAPROV },
+ { SC_SERVICENAME_FORMULAPARS, SC_SERVICE_FORMULAPARS },
+ { SC_SERVICENAME_OPCODEMAPPER, SC_SERVICE_OPCODEMAPPER },
+ { "ooo.vba.VBAObjectModuleObjectProvider", SC_SERVICE_VBAOBJECTPROVIDER },
+ { "ooo.vba.VBACodeNameProvider", SC_SERVICE_VBACODENAMEPROVIDER },
+ { "ooo.vba.VBAGlobals", SC_SERVICE_VBAGLOBALS },
+
+ // case-correct versions of the service names (#i102468#)
+ { "com.sun.star.text.textfield.URL", SC_SERVICE_URLFIELD },
+ { "com.sun.star.text.textfield.PageNumber", SC_SERVICE_PAGEFIELD },
+ { "com.sun.star.text.textfield.PageCount", SC_SERVICE_PAGESFIELD },
+ { "com.sun.star.text.textfield.Date", SC_SERVICE_DATEFIELD },
+ { "com.sun.star.text.textfield.Time", SC_SERVICE_TIMEFIELD },
+ { "com.sun.star.text.textfield.DocumentTitle", SC_SERVICE_TITLEFIELD },
+ { "com.sun.star.text.textfield.FileName", SC_SERVICE_FILEFIELD },
+ { "com.sun.star.text.textfield.SheetName", SC_SERVICE_SHEETFIELD },
+ { "ooo.vba.VBAGlobals", SC_SERVICE_VBAGLOBALS },
+};
+
+//
+// old service names that were in 567 still work in createInstance,
+// in case some macro is still using them
+//
+
+static const sal_Char* __FAR_DATA aOldNames[SC_SERVICE_COUNT] =
+ {
+ "", // SC_SERVICE_SHEET
+ "stardiv.one.text.TextField.URL", // SC_SERVICE_URLFIELD
+ "stardiv.one.text.TextField.PageNumber", // SC_SERVICE_PAGEFIELD
+ "stardiv.one.text.TextField.PageCount", // SC_SERVICE_PAGESFIELD
+ "stardiv.one.text.TextField.Date", // SC_SERVICE_DATEFIELD
+ "stardiv.one.text.TextField.Time", // SC_SERVICE_TIMEFIELD
+ "stardiv.one.text.TextField.DocumentTitle", // SC_SERVICE_TITLEFIELD
+ "stardiv.one.text.TextField.FileName", // SC_SERVICE_FILEFIELD
+ "stardiv.one.text.TextField.SheetName", // SC_SERVICE_SHEETFIELD
+ "stardiv.one.style.CellStyle", // SC_SERVICE_CELLSTYLE
+ "stardiv.one.style.PageStyle", // SC_SERVICE_PAGESTYLE
+ "", // SC_SERVICE_AUTOFORMAT
+ "", // SC_SERVICE_CELLRANGES
+ "", // SC_SERVICE_GRADTAB
+ "", // SC_SERVICE_HATCHTAB
+ "", // SC_SERVICE_BITMAPTAB
+ "", // SC_SERVICE_TRGRADTAB
+ "", // SC_SERVICE_MARKERTAB
+ "", // SC_SERVICE_DASHTAB
+ "", // SC_SERVICE_NUMRULES
+ "", // SC_SERVICE_DOCDEFLTS
+ "", // SC_SERVICE_DRAWDEFLTS
+ "", // SC_SERVICE_DOCSPRSETT
+ "", // SC_SERVICE_DOCCONF
+ "", // SC_SERVICE_IMAP_RECT
+ "", // SC_SERVICE_IMAP_CIRC
+ "", // SC_SERVICE_IMAP_POLY
+
+ // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
+ "", // SC_SERVICE_EXPORT_GOR
+ "", // SC_SERVICE_IMPORT_GOR
+ "", // SC_SERVICE_EXPORT_EOR
+ "", // SC_SERVICE_IMPORT_EOR
+
+ "", // SC_SERVICE_VALBIND
+ "", // SC_SERVICE_LISTCELLBIND
+ "", // SC_SERVICE_LISTSOURCE
+ "", // SC_SERVICE_CELLADDRESS
+ "", // SC_SERVICE_RANGEADDRESS
+ "", // SC_SERVICE_SHEETDOCSET
+ "", // SC_SERVICE_CHDATAPROV
+ "", // SC_SERVICE_FORMULAPARS
+ "", // SC_SERVICE_OPCODEMAPPER
+ "", // SC_SERVICE_VBAOBJECTPROVIDER
+ "", // SC_SERVICE_VBACODENAMEPROVIDER
+ "", // SC_SERVICE_VBAGLOBALS
+ };
+
+
+
+
+//------------------------------------------------------------------------
+
+// alles static
+
+
+sal_uInt16 ScServiceProvider::GetProviderType(const String& rServiceName)
+{
+ if (rServiceName.Len())
+ {
+ const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
+
+ for (sal_uInt16 i = 0; i < nEntries; i++)
+ {
+ if (rServiceName.EqualsAscii( aProvNamesId[i].pName ))
+ {
+ return aProvNamesId[i].nType;
+ }
+ }
+
+ USHORT i;
+ for (i=0; i<SC_SERVICE_COUNT; i++)
+ {
+ DBG_ASSERT( aOldNames[i], "ScServiceProvider::GetProviderType: no oldname => crash");
+ if (rServiceName.EqualsAscii( aOldNames[i] ))
+ {
+ DBG_ERROR("old service name used");
+ return i;
+ }
+ }
+ }
+ return SC_SERVICE_INVALID;
+}
+
+uno::Reference<uno::XInterface> ScServiceProvider::MakeInstance(
+ sal_uInt16 nType, ScDocShell* pDocShell )
+{
+ uno::Reference<uno::XInterface> xRet;
+ switch (nType)
+ {
+ case SC_SERVICE_SHEET:
+ // noch nicht eingefuegt - DocShell=Null
+ xRet.set((sheet::XSpreadsheet*)new ScTableSheetObj(NULL,0));
+ break;
+ case SC_SERVICE_URLFIELD:
+ xRet.set((text::XTextField*)new ScCellFieldObj( NULL, ScAddress(), ESelection() ));
+ break;
+ case SC_SERVICE_PAGEFIELD:
+ case SC_SERVICE_PAGESFIELD:
+ case SC_SERVICE_DATEFIELD:
+ case SC_SERVICE_TIMEFIELD:
+ case SC_SERVICE_TITLEFIELD:
+ case SC_SERVICE_FILEFIELD:
+ case SC_SERVICE_SHEETFIELD:
+ xRet.set((text::XTextField*)new ScHeaderFieldObj( NULL, 0, nType, ESelection() ));
+ break;
+ case SC_SERVICE_CELLSTYLE:
+ xRet.set((style::XStyle*)new ScStyleObj( NULL, SFX_STYLE_FAMILY_PARA, String() ));
+ break;
+ case SC_SERVICE_PAGESTYLE:
+ xRet.set((style::XStyle*)new ScStyleObj( NULL, SFX_STYLE_FAMILY_PAGE, String() ));
+ break;
+ case SC_SERVICE_AUTOFORMAT:
+ xRet.set((container::XIndexAccess*)new ScAutoFormatObj( SC_AFMTOBJ_INVALID ));
+ break;
+ case SC_SERVICE_CELLRANGES:
+ // wird nicht eingefuegt, sondern gefuellt
+ // -> DocShell muss gesetzt sein, aber leere Ranges
+ if (pDocShell)
+ xRet.set((sheet::XSheetCellRanges*)new ScCellRangesObj( pDocShell, ScRangeList() ));
+ break;
+
+ case SC_SERVICE_DOCDEFLTS:
+ if (pDocShell)
+ xRet.set((beans::XPropertySet*)new ScDocDefaultsObj( pDocShell ));
+ break;
+ case SC_SERVICE_DRAWDEFLTS:
+ if (pDocShell)
+ xRet.set((beans::XPropertySet*)new ScDrawDefaultsObj( pDocShell ));
+ break;
+
+ // Drawing layer tables are not in SvxUnoDrawMSFactory,
+ // because SvxUnoDrawMSFactory doesn't have a SdrModel pointer.
+ // Drawing layer is always allocated if not there (MakeDrawLayer).
+
+ case SC_SERVICE_GRADTAB:
+ if (pDocShell)
+ xRet.set(SvxUnoGradientTable_createInstance( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_HATCHTAB:
+ if (pDocShell)
+ xRet.set(SvxUnoHatchTable_createInstance( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_BITMAPTAB:
+ if (pDocShell)
+ xRet.set(SvxUnoBitmapTable_createInstance( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_TRGRADTAB:
+ if (pDocShell)
+ xRet.set(SvxUnoTransGradientTable_createInstance( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_MARKERTAB:
+ if (pDocShell)
+ xRet.set(SvxUnoMarkerTable_createInstance( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_DASHTAB:
+ if (pDocShell)
+ xRet.set(SvxUnoDashTable_createInstance( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_NUMRULES:
+ if (pDocShell)
+ xRet.set(SvxCreateNumRule( pDocShell->MakeDrawLayer() ));
+ break;
+ case SC_SERVICE_DOCSPRSETT:
+ case SC_SERVICE_SHEETDOCSET:
+ case SC_SERVICE_DOCCONF:
+ if (pDocShell)
+ xRet.set((beans::XPropertySet*)new ScDocumentConfiguration(pDocShell));
+ break;
+
+ case SC_SERVICE_IMAP_RECT:
+ xRet.set(SvUnoImageMapRectangleObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
+ break;
+ case SC_SERVICE_IMAP_CIRC:
+ xRet.set(SvUnoImageMapCircleObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
+ break;
+ case SC_SERVICE_IMAP_POLY:
+ xRet.set(SvUnoImageMapPolygonObject_createInstance( ScShapeObj::GetSupportedMacroItems() ));
+ break;
+
+ // #100263# Support creation of GraphicObjectResolver and EmbeddedObjectResolver
+ case SC_SERVICE_EXPORT_GOR:
+ xRet.set((::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE ));
+ break;
+
+ case SC_SERVICE_IMPORT_GOR:
+ xRet.set((::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ ));
+ break;
+
+ case SC_SERVICE_EXPORT_EOR:
+ if (pDocShell)
+ xRet.set((::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_WRITE ));
+ break;
+
+ case SC_SERVICE_IMPORT_EOR:
+ if (pDocShell)
+ xRet.set((::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ ));
+ break;
+
+ case SC_SERVICE_VALBIND:
+ case SC_SERVICE_LISTCELLBIND:
+ if (pDocShell)
+ {
+ sal_Bool bListPos = ( nType == SC_SERVICE_LISTCELLBIND );
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
+ xRet.set(*new calc::OCellValueBinding( xDoc, bListPos ));
+ }
+ break;
+ case SC_SERVICE_LISTSOURCE:
+ if (pDocShell)
+ {
+ uno::Reference<sheet::XSpreadsheetDocument> xDoc( pDocShell->GetBaseModel(), uno::UNO_QUERY );
+ xRet.set(*new calc::OCellListSource( xDoc ));
+ }
+ break;
+ case SC_SERVICE_CELLADDRESS:
+ case SC_SERVICE_RANGEADDRESS:
+ if (pDocShell)
+ {
+ sal_Bool bRange = ( nType == SC_SERVICE_RANGEADDRESS );
+ xRet.set(*new ScAddressConversionObj( pDocShell, bRange ));
+ }
+ break;
+
+ case SC_SERVICE_CHDATAPROV:
+ if (pDocShell && pDocShell->GetDocument())
+ xRet = *new ScChart2DataProvider( pDocShell->GetDocument() );
+ break;
+
+ case SC_SERVICE_FORMULAPARS:
+ if (pDocShell)
+ xRet.set(static_cast<sheet::XFormulaParser*>(new ScFormulaParserObj( pDocShell )));
+ break;
+
+ case SC_SERVICE_OPCODEMAPPER:
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScAddress aAddress;
+ ScCompiler* pComp = new ScCompiler(pDoc,aAddress);
+ pComp->SetGrammar( pDoc->GetGrammar() );
+ xRet.set(static_cast<sheet::XFormulaOpCodeMapper*>(new ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> (pComp))));
+ break;
+ }
+ case SC_SERVICE_VBAOBJECTPROVIDER:
+ if (pDocShell && pDocShell->GetDocument()->IsInVBAMode())
+ {
+ OSL_TRACE("**** creating VBA Object mapper");
+ xRet.set(static_cast<container::XNameAccess*>(new ScVbaObjectForCodeNameProvider( pDocShell )));
+ }
+ break;
+ case SC_SERVICE_VBACODENAMEPROVIDER:
+ if ( pDocShell && ooo::vba::isAlienExcelDoc( *pDocShell ) && isInVBAMode( *pDocShell ) )
+ {
+ OSL_TRACE("**** creating VBA Object provider");
+ xRet.set(static_cast<document::XCodeNameQuery*>(new ScVbaCodeNameProvider( pDocShell )));
+ }
+ break;
+ case SC_SERVICE_VBAGLOBALS:
+ if (pDocShell)
+ {
+ uno::Any aGlobs;
+ if ( !pDocShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aGlobs ) )
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[ 0 ] <<= pDocShell->GetModel();
+ xRet = ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs );
+ pDocShell->GetBasicManager()->SetGlobalUNOConstant( "VBAGlobals", uno::Any( xRet ) );
+ BasicManager* pAppMgr = SFX_APP()->GetBasicManager();
+ if ( pAppMgr )
+ pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] );
+ }
+ }
+ break;
+ }
+
+ return xRet;
+}
+
+uno::Sequence<rtl::OUString> ScServiceProvider::GetAllServiceNames()
+{
+ const sal_uInt16 nEntries = SAL_N_ELEMENTS(aProvNamesId);
+ uno::Sequence<rtl::OUString> aRet(nEntries);
+ rtl::OUString* pArray = aRet.getArray();
+ for (sal_uInt16 i = 0; i < nEntries; i++)
+ {
+ pArray[i] = rtl::OUString::createFromAscii( aProvNamesId[i].pName );
+ }
+ return aRet;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/shapeuno.cxx b/sc/source/ui/unoobj/shapeuno.cxx
new file mode 100644
index 000000000000..845b64d24ec9
--- /dev/null
+++ b/sc/source/ui/unoobj/shapeuno.cxx
@@ -0,0 +1,1527 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <tools/debug.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/stl_types.hxx>
+#include <svtools/unoevent.hxx>
+#include <svtools/unoimap.hxx>
+#include <svx/svdobj.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/unoshape.hxx>
+#include <editeng/unofield.hxx>
+#include <svx/shapepropertynotifier.hxx>
+#include <toolkit/helper/convert.hxx>
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include "shapeuno.hxx"
+#include "miscuno.hxx"
+#include "cellsuno.hxx"
+#include "textuno.hxx"
+#include "fielduno.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include "unonames.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+DECLARE_STL_USTRINGACCESS_MAP( uno::Sequence< sal_Int8 > *, ScShapeImplementationIdMap );
+
+static ScShapeImplementationIdMap aImplementationIdMap;
+
+const SfxItemPropertyMapEntry* lcl_GetShapeMap()
+{
+ static SfxItemPropertyMapEntry aShapeMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ANCHOR), 0, &getCppuType((uno::Reference<uno::XInterface>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_HORIPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_IMAGEMAP), 0, &getCppuType((uno::Reference<container::XIndexContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_VERTPOS), 0, &getCppuType((sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_MOVEPROTECT), 0, &getCppuType((sal_Bool*)0), 0, 0 },
+ // #i66550 HLINK_FOR_SHAPES
+ {MAP_CHAR_LEN(SC_UNONAME_HYPERLINK), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aShapeMap_Impl;
+}
+
+// static
+const SvEventDescription* ScShapeObj::GetSupportedMacroItems()
+{
+ static const SvEventDescription aMacroDescriptionsImpl[] =
+ {
+ { 0, NULL }
+ };
+ return aMacroDescriptionsImpl;
+}
+// #i66550 HLINK_FOR_SHAPES
+ScMacroInfo* lcl_getShapeHyperMacroInfo( ScShapeObj* pShape, BOOL bCreate = FALSE )
+{
+ if( pShape )
+ if( SdrObject* pObj = pShape->GetSdrObject() )
+ return ScDrawLayer::GetMacroInfo( pObj, bCreate );
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+namespace
+{
+ void lcl_initializeNotifier( SdrObject& _rSdrObj, ::cppu::OWeakObject& _rShape )
+ {
+ ::svx::PPropertyValueProvider pProvider( new ::svx::PropertyValueProvider( _rShape, "Anchor" ) );
+ _rSdrObj.getShapePropertyChangeNotifier().registerProvider( ::svx::eSpreadsheetAnchor, pProvider );
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScShapeObj::ScShapeObj( uno::Reference<drawing::XShape>& xShape ) :
+ pShapePropertySet(NULL),
+ pShapePropertyState(NULL),
+ pImplementationId(NULL),
+ bIsTextShape(FALSE),
+ bInitializedNotifier(false)
+{
+ comphelper::increment( m_refCount );
+
+ {
+ mxShapeAgg = uno::Reference<uno::XAggregation>( xShape, uno::UNO_QUERY );
+ // extra block to force deletion of the temporary before setDelegator
+ }
+
+ if (mxShapeAgg.is())
+ {
+ xShape = NULL; // during setDelegator, mxShapeAgg must be the only ref
+
+ mxShapeAgg->setDelegator( (cppu::OWeakObject*)this );
+
+ xShape.set(uno::Reference<drawing::XShape>( mxShapeAgg, uno::UNO_QUERY ));
+
+ bIsTextShape = ( SvxUnoTextBase::getImplementation( mxShapeAgg ) != NULL );
+ }
+
+ {
+ SdrObject* pObj = GetSdrObject();
+ if ( pObj )
+ {
+ lcl_initializeNotifier( *pObj, *this );
+ bInitializedNotifier = true;
+ }
+ }
+
+ comphelper::decrement( m_refCount );
+}
+
+ScShapeObj::~ScShapeObj()
+{
+// if (mxShapeAgg.is())
+// mxShapeAgg->setDelegator(uno::Reference<uno::XInterface>());
+}
+
+// XInterface
+
+uno::Any SAL_CALL ScShapeObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ uno::Any aRet = ScShapeObj_Base::queryInterface( rType );
+
+ if ( !aRet.hasValue() && bIsTextShape )
+ aRet = ScShapeObj_TextBase::queryInterface( rType );
+
+ if ( !aRet.hasValue() && mxShapeAgg.is() )
+ aRet = mxShapeAgg->queryAggregation( rType );
+
+ return aRet;
+}
+
+void SAL_CALL ScShapeObj::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL ScShapeObj::release() throw()
+{
+ OWeakObject::release();
+}
+
+void ScShapeObj::GetShapePropertySet()
+{
+ // #i61908# Store the result of queryAggregation in a member.
+ // The reference in mxShapeAgg is kept for this object's lifetime, so the pointer is always valid.
+
+ if (!pShapePropertySet)
+ {
+ uno::Reference<beans::XPropertySet> xProp;
+ if ( mxShapeAgg.is() )
+ mxShapeAgg->queryAggregation( getCppuType((uno::Reference<beans::XPropertySet>*) 0) ) >>= xProp;
+ pShapePropertySet = xProp.get();
+ }
+}
+
+void ScShapeObj::GetShapePropertyState()
+{
+ // #i61908# Store the result of queryAggregation in a member.
+ // The reference in mxShapeAgg is kept for this object's lifetime, so the pointer is always valid.
+
+ if (!pShapePropertyState)
+ {
+ uno::Reference<beans::XPropertyState> xState;
+ if ( mxShapeAgg.is() )
+ mxShapeAgg->queryAggregation( getCppuType((uno::Reference<beans::XPropertyState>*) 0) ) >>= xState;
+ pShapePropertyState = xState.get();
+ }
+}
+
+uno::Reference<lang::XComponent> lcl_GetComponent( const uno::Reference<uno::XAggregation>& xAgg )
+{
+ uno::Reference<lang::XComponent> xRet;
+ if ( xAgg.is() )
+ xAgg->queryAggregation( getCppuType((uno::Reference<lang::XComponent>*) 0) ) >>= xRet;
+ return xRet;
+}
+
+uno::Reference<text::XText> lcl_GetText( const uno::Reference<uno::XAggregation>& xAgg )
+{
+ uno::Reference<text::XText> xRet;
+ if ( xAgg.is() )
+ xAgg->queryAggregation( getCppuType((uno::Reference<text::XText>*) 0) ) >>= xRet;
+ return xRet;
+}
+
+uno::Reference<text::XSimpleText> lcl_GetSimpleText( const uno::Reference<uno::XAggregation>& xAgg )
+{
+ uno::Reference<text::XSimpleText> xRet;
+ if ( xAgg.is() )
+ xAgg->queryAggregation( getCppuType((uno::Reference<text::XSimpleText>*) 0) ) >>= xRet;
+ return xRet;
+}
+
+uno::Reference<text::XTextRange> lcl_GetTextRange( const uno::Reference<uno::XAggregation>& xAgg )
+{
+ uno::Reference<text::XTextRange> xRet;
+ if ( xAgg.is() )
+ xAgg->queryAggregation( getCppuType((uno::Reference<text::XTextRange>*) 0) ) >>= xRet;
+ return xRet;
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScShapeObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // #i61527# cache property set info for this object
+ if ( !mxPropSetInfo.is() )
+ {
+ // mix own and aggregated properties:
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ {
+ uno::Reference<beans::XPropertySetInfo> xAggInfo(pShapePropertySet->getPropertySetInfo());
+ const uno::Sequence<beans::Property> aPropSeq(xAggInfo->getProperties());
+ mxPropSetInfo.set(new SfxExtItemPropertySetInfo( lcl_GetShapeMap(), aPropSeq ));
+ }
+ }
+ return mxPropSetInfo;
+}
+
+BOOL lcl_GetPageNum( SdrPage* pPage, SdrModel& rModel, SCTAB& rNum )
+{
+ USHORT nCount = rModel.GetPageCount();
+ for (USHORT i=0; i<nCount; i++)
+ if ( rModel.GetPage(i) == pPage )
+ {
+ rNum = static_cast<SCTAB>(i);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL lcl_GetCaptionPoint( uno::Reference< drawing::XShape >& xShape, awt::Point& rCaptionPoint )
+{
+ BOOL bReturn = FALSE;
+ rtl::OUString sType(xShape->getShapeType());
+ sal_Bool bCaptionShape(sType.equalsAscii("com.sun.star.drawing.CaptionShape"));
+ if (bCaptionShape)
+ {
+ uno::Reference < beans::XPropertySet > xShapeProp (xShape, uno::UNO_QUERY);
+ if (xShapeProp.is())
+ {
+ xShapeProp->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "CaptionPoint" )) ) >>= rCaptionPoint;
+ bReturn = TRUE;
+ }
+ }
+ return bReturn;
+}
+
+ScRange lcl_GetAnchorCell( uno::Reference< drawing::XShape >& xShape, ScDocument* pDoc, SCTAB nTab,
+ awt::Point& rUnoPoint, awt::Size& rUnoSize, awt::Point& rCaptionPoint )
+{
+ ScRange aReturn;
+ rUnoPoint = xShape->getPosition();
+ rtl::OUString sType(xShape->getShapeType());
+ sal_Bool bCaptionShape(lcl_GetCaptionPoint(xShape, rCaptionPoint));
+ if (pDoc->IsNegativePage(nTab))
+ {
+ rUnoSize = xShape->getSize();
+ rUnoPoint.X += rUnoSize.Width; // the right top point is base
+ if (bCaptionShape)
+ {
+ if (rCaptionPoint.X > 0 && rCaptionPoint.X > rUnoSize.Width)
+ rUnoPoint.X += rCaptionPoint.X - rUnoSize.Width;
+ if (rCaptionPoint.Y < 0)
+ rUnoPoint.Y += rCaptionPoint.Y;
+ }
+ aReturn = pDoc->GetRange( nTab, Rectangle( VCLPoint(rUnoPoint), VCLPoint(rUnoPoint) ));
+ }
+ else
+ {
+ if (bCaptionShape)
+ {
+ if (rCaptionPoint.X < 0)
+ rUnoPoint.X += rCaptionPoint.X;
+ if (rCaptionPoint.Y < 0)
+ rUnoPoint.Y += rCaptionPoint.Y;
+ }
+ aReturn = pDoc->GetRange( nTab, Rectangle( VCLPoint(rUnoPoint), VCLPoint(rUnoPoint) ));
+ }
+
+ return aReturn;
+}
+
+awt::Point lcl_GetRelativePos( uno::Reference< drawing::XShape >& xShape, ScDocument* pDoc, SCTAB nTab, ScRange& rRange,
+ awt::Size& rUnoSize, awt::Point& rCaptionPoint)
+{
+ awt::Point aUnoPoint;
+ rRange = lcl_GetAnchorCell(xShape, pDoc, nTab, aUnoPoint, rUnoSize, rCaptionPoint);
+ if (pDoc->IsNegativePage(nTab))
+ {
+ Rectangle aRect(pDoc->GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aStart.Tab() ));
+ Point aPoint(aRect.TopRight());
+ aUnoPoint.X -= aPoint.X();
+ aUnoPoint.Y -= aPoint.Y();
+ }
+ else
+ {
+ ScRange aRange = pDoc->GetRange( nTab, Rectangle( VCLPoint(aUnoPoint), VCLPoint(aUnoPoint) ));
+ Rectangle aRect(pDoc->GetMMRect( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row(), rRange.aStart.Tab() ));
+ Point aPoint(aRect.TopLeft());
+ aUnoPoint.X -= aPoint.X();
+ aUnoPoint.Y -= aPoint.Y();
+ }
+
+ return aUnoPoint;
+}
+
+void SAL_CALL ScShapeObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_ANCHOR ) )
+ {
+ uno::Reference<sheet::XCellRangeAddressable> xRangeAdd(aValue, uno::UNO_QUERY);
+ if (xRangeAdd.is())
+ {
+ SdrObject *pObj = GetSdrObject();
+ if (pObj)
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel && pPage )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocShell* pDocSh = (ScDocShell*)pObjSh;
+
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ table::CellRangeAddress aAddress = xRangeAdd->getRangeAddress();
+ if (nTab == aAddress.Sheet)
+ {
+ if (aAddress.StartRow != aAddress.EndRow) //should be a Spreadsheet
+ {
+ DBG_ASSERT(aAddress.StartRow == 0 && aAddress.EndRow == MAXROW &&
+ aAddress.StartColumn == 0 && aAddress.EndColumn == MAXCOL, "here should be a XSpreadsheet");
+ ScDrawLayer::SetAnchor(pObj, SCA_PAGE);
+ }
+ else
+ {
+ DBG_ASSERT(aAddress.StartRow == aAddress.EndRow &&
+ aAddress.StartColumn == aAddress.EndColumn, "here should be a XCell");
+ ScDrawLayer::SetAnchor(pObj, SCA_CELL);
+ }
+ Rectangle aRect(pDoc->GetMMRect( static_cast<SCCOL>(aAddress.StartColumn), static_cast<SCROW>(aAddress.StartRow),
+ static_cast<SCCOL>(aAddress.EndColumn), static_cast<SCROW>(aAddress.EndRow), aAddress.Sheet ));
+ uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
+ if (xShape.is())
+ {
+ Point aPoint;
+ Point aEndPoint;
+ if (pDoc->IsNegativePage(nTab))
+ {
+ aPoint = aRect.TopRight();
+ aEndPoint = aRect.BottomLeft();
+ }
+ else
+ {
+ aPoint = aRect.TopLeft();
+ aEndPoint = aRect.BottomRight();
+ }
+ awt::Size aUnoSize;
+ awt::Point aCaptionPoint;
+ ScRange aRange;
+ awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
+
+ aUnoPoint.X += aPoint.X();
+ aUnoPoint.Y += aPoint.Y();
+
+ if ( aUnoPoint.Y > aEndPoint.Y() )
+ aUnoPoint.Y = aEndPoint.Y() - 2;
+ if (pDoc->IsNegativePage(nTab))
+ {
+ if ( aUnoPoint.X < aEndPoint.X() )
+ aUnoPoint.X = aEndPoint.X() + 2;
+ aUnoPoint.X -= aUnoSize.Width;
+ // remove difference to caption point
+ if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
+ aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
+ }
+ else
+ {
+ if ( aUnoPoint.X > aEndPoint.X() )
+ aUnoPoint.X = aEndPoint.X() - 2;
+ if (aCaptionPoint.X < 0)
+ aUnoPoint.X -= aCaptionPoint.X;
+ }
+ if (aCaptionPoint.Y < 0)
+ aUnoPoint.Y -= aCaptionPoint.Y;
+
+ xShape->setPosition(aUnoPoint);
+ pDocSh->SetModified();
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ throw lang::IllegalArgumentException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("only XCell or XSpreadsheet objects allowed")), static_cast<cppu::OWeakObject*>(this), 0);
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
+ {
+ SdrObject* pObj = GetSdrObject();
+ if ( pObj )
+ {
+ ImageMap aImageMap;
+ uno::Reference< uno::XInterface > xImageMapInt(aValue, uno::UNO_QUERY);
+
+ if( !xImageMapInt.is() || !SvUnoImageMap_fillImageMap( xImageMapInt, aImageMap ) )
+ throw lang::IllegalArgumentException();
+
+ ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(pObj);
+ if( pIMapInfo )
+ {
+ // replace existing image map
+ pIMapInfo->SetImageMap( aImageMap );
+ }
+ else
+ {
+ // insert new user data with image map
+ pObj->InsertUserData(new ScIMapInfo(aImageMap) );
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HORIPOS ) )
+ {
+ sal_Int32 nPos = 0;
+ if (aValue >>= nPos)
+ {
+ SdrObject *pObj = GetSdrObject();
+ if (pObj)
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel && pPage )
+ {
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocShell* pDocSh = (ScDocShell*)pObjSh;
+ uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
+ if (xShape.is())
+ {
+ if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE)
+ {
+ awt::Point aPoint(xShape->getPosition());
+ awt::Size aSize(xShape->getSize());
+ awt::Point aCaptionPoint;
+ if (pDoc->IsNegativePage(nTab))
+ {
+ nPos *= -1;
+ nPos -= aSize.Width;
+ }
+ if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
+ {
+ if (pDoc->IsNegativePage(nTab))
+ {
+ if (aCaptionPoint.X > 0 && aCaptionPoint.X > aSize.Width)
+ nPos -= aCaptionPoint.X - aSize.Width;
+ }
+ else
+ {
+ if (aCaptionPoint.X < 0)
+ nPos -= aCaptionPoint.X;
+ }
+ }
+ aPoint.X = nPos;
+ xShape->setPosition(aPoint);
+ pDocSh->SetModified();
+ }
+ else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
+ {
+ awt::Size aUnoSize;
+ awt::Point aCaptionPoint;
+ ScRange aRange;
+ awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
+ Rectangle aRect(pDoc->GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
+ if (pDoc->IsNegativePage(nTab))
+ {
+ aUnoPoint.X = -nPos;
+ Point aPoint(aRect.TopRight());
+ Point aEndPoint(aRect.BottomLeft());
+ aUnoPoint.X += aPoint.X();
+ if (aUnoPoint.X < aEndPoint.X())
+ aUnoPoint.X = aEndPoint.X() + 2;
+ aUnoPoint.X -= aUnoSize.Width;
+ if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
+ aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
+ }
+ else
+ {
+ aUnoPoint.X = nPos;
+ Point aPoint(aRect.TopLeft());
+ Point aEndPoint(aRect.BottomRight());
+ aUnoPoint.X += aPoint.X();
+ if (aUnoPoint.X > aEndPoint.X())
+ aUnoPoint.X = aEndPoint.X() - 2;
+ if (aCaptionPoint.X < 0)
+ aUnoPoint.X -= aCaptionPoint.X;
+ }
+ aUnoPoint.Y = xShape->getPosition().Y;
+ xShape->setPosition(aUnoPoint);
+ pDocSh->SetModified();
+ }
+ else
+ {
+ DBG_ERROR("unknown anchor type");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_VERTPOS ) )
+ {
+ sal_Int32 nPos = 0;
+ if (aValue >>= nPos)
+ {
+ SdrObject *pObj = GetSdrObject();
+ if (pObj)
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel && pPage )
+ {
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocShell* pDocSh = (ScDocShell*)pObjSh;
+ uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
+ if (xShape.is())
+ {
+ if (ScDrawLayer::GetAnchor(pObj) == SCA_PAGE)
+ {
+ awt::Point aPoint = xShape->getPosition();
+ awt::Point aCaptionPoint;
+ if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
+ {
+ if (aCaptionPoint.Y < 0)
+ nPos -= aCaptionPoint.Y;
+ }
+ aPoint.Y = nPos;
+ xShape->setPosition(aPoint);
+ pDocSh->SetModified();
+ }
+ else if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
+ {
+ awt::Size aUnoSize;
+ awt::Point aCaptionPoint;
+ ScRange aRange;
+ awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
+ Rectangle aRect(pDoc->GetMMRect( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ));
+ Point aPoint(aRect.TopRight());
+ Point aEndPoint(aRect.BottomLeft());
+ aUnoPoint.Y = nPos;
+ aUnoPoint.Y += aPoint.Y();
+ if (aUnoPoint.Y > aEndPoint.Y())
+ aUnoPoint.Y = aEndPoint.Y() - 2;
+ if (aCaptionPoint.Y < 0)
+ aUnoPoint.Y -= aCaptionPoint.Y;
+ aUnoPoint.X = xShape->getPosition().X;
+ xShape->setPosition(aUnoPoint);
+ pDocSh->SetModified();
+ }
+ else
+ {
+ DBG_ERROR("unknown anchor type");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HYPERLINK ) )
+ {
+ rtl::OUString sHlink;
+ ScMacroInfo* pInfo = lcl_getShapeHyperMacroInfo(this, TRUE);
+ if ( ( aValue >>= sHlink ) && pInfo )
+ pInfo->SetHlink( sHlink );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_MOVEPROTECT ) )
+ {
+ if( SdrObject* pObj = this->GetSdrObject() )
+ {
+ sal_Bool aProt = false;
+ if( aValue >>= aProt )
+ pObj->SetMoveProtect( aProt );
+ }
+ }
+ else
+ {
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ pShapePropertySet->setPropertyValue( aPropertyName, aValue );
+ }
+}
+
+uno::Any SAL_CALL ScShapeObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString = aPropertyName;
+
+ uno::Any aAny;
+ if ( aNameString.EqualsAscii( SC_UNONAME_ANCHOR ) )
+ {
+ SdrObject *pObj = GetSdrObject();
+ if (pObj)
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel && pPage )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocShell* pDocSh = (ScDocShell*)pObjSh;
+ uno::Reference< uno::XInterface > xAnchor;
+ if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
+ {
+ uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
+ if (xShape.is())
+ {
+ awt::Size aUnoSize;
+ awt::Point aCaptionPoint;
+ ScRange aRange;
+ awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
+
+ xAnchor.set(static_cast<cppu::OWeakObject*>(new ScCellObj( pDocSh, aRange.aStart )));
+ }
+ }
+ else
+ {
+ xAnchor.set(static_cast<cppu::OWeakObject*>(new ScTableSheetObj( pDocSh, nTab )));
+ }
+ aAny <<= xAnchor;
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
+ {
+ uno::Reference< uno::XInterface > xImageMap;
+ SdrObject* pObj = GetSdrObject();
+ if ( pObj )
+ {
+ ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(GetSdrObject());
+ if( pIMapInfo )
+ {
+ const ImageMap& rIMap = pIMapInfo->GetImageMap();
+ xImageMap.set(SvUnoImageMap_createInstance( rIMap, GetSupportedMacroItems() ));
+ }
+ else
+ xImageMap = SvUnoImageMap_createInstance( GetSupportedMacroItems() );
+ }
+ aAny <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HORIPOS ) )
+ {
+ SdrObject *pObj = GetSdrObject();
+ if (pObj)
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel && pPage )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
+ if (xShape.is())
+ {
+ if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
+ {
+ awt::Size aUnoSize;
+ awt::Point aCaptionPoint;
+ ScRange aRange;
+ awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
+ if (pDoc->IsNegativePage(nTab))
+ aUnoPoint.X *= -1;
+ aAny <<= aUnoPoint.X;
+ }
+ else
+ {
+ awt::Point aCaptionPoint;
+ awt::Point aUnoPoint(xShape->getPosition());
+ awt::Size aUnoSize(xShape->getSize());
+ if (pDoc->IsNegativePage(nTab))
+ {
+ aUnoPoint.X *= -1;
+ aUnoPoint.X -= aUnoSize.Width;
+ }
+ if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
+ {
+ if (pDoc->IsNegativePage(nTab))
+ {
+ if (aCaptionPoint.X > 0 && aCaptionPoint.X > aUnoSize.Width)
+ aUnoPoint.X -= aCaptionPoint.X - aUnoSize.Width;
+ }
+ else
+ {
+ if (aCaptionPoint.X < 0)
+ aUnoPoint.X += aCaptionPoint.X;
+ }
+ }
+ aAny <<= aUnoPoint.X;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_VERTPOS ) )
+ {
+ SdrObject *pObj = GetSdrObject();
+ if (pObj)
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel && pPage )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ uno::Reference<drawing::XShape> xShape( mxShapeAgg, uno::UNO_QUERY );
+ if (xShape.is())
+ {
+ uno::Reference< uno::XInterface > xAnchor;
+ if (ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
+ {
+ awt::Size aUnoSize;
+ awt::Point aCaptionPoint;
+ ScRange aRange;
+ awt::Point aUnoPoint(lcl_GetRelativePos( xShape, pDoc, nTab, aRange, aUnoSize, aCaptionPoint ));
+
+ aAny <<= aUnoPoint.Y;
+ }
+ else
+ {
+ awt::Point aUnoPoint(xShape->getPosition());
+ awt::Point aCaptionPoint;
+ if (lcl_GetCaptionPoint(xShape, aCaptionPoint))
+ {
+ if (aCaptionPoint.Y < 0)
+ aUnoPoint.Y += aCaptionPoint.Y;
+ }
+ aAny <<= aUnoPoint.Y;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HYPERLINK ) )
+ {
+ rtl::OUString sHlink;
+ if ( ScMacroInfo* pInfo = lcl_getShapeHyperMacroInfo(this) )
+ sHlink = pInfo->GetHlink();
+ aAny <<= sHlink;
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_MOVEPROTECT ) )
+ {
+ sal_Bool aProt = false;
+ if ( SdrObject* pObj = this->GetSdrObject() )
+ aProt = pObj->IsMoveProtect();
+ aAny <<= aProt;
+ }
+ else
+ {
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ aAny = pShapePropertySet->getPropertyValue( aPropertyName );
+ }
+
+ return aAny;
+}
+
+void SAL_CALL ScShapeObj::addPropertyChangeListener( const rtl::OUString& aPropertyName,
+ const uno::Reference<beans::XPropertyChangeListener>& aListener)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ pShapePropertySet->addPropertyChangeListener( aPropertyName, aListener );
+
+ if ( !bInitializedNotifier )
+ {
+ // here's the latest chance to initialize the property notification at the SdrObject
+ // (in the ctor, where we also attempt to do this, we do not necessarily have
+ // and SdrObject, yet)
+ SdrObject* pObj = GetSdrObject();
+ OSL_ENSURE( pObj, "ScShapeObj::addPropertyChangeListener: no SdrObject -> no property change notification!" );
+ if ( pObj )
+ lcl_initializeNotifier( *pObj, *this );
+ bInitializedNotifier = true;
+ }
+}
+
+void SAL_CALL ScShapeObj::removePropertyChangeListener( const rtl::OUString& aPropertyName,
+ const uno::Reference<beans::XPropertyChangeListener>& aListener)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ pShapePropertySet->removePropertyChangeListener( aPropertyName, aListener );
+}
+
+void SAL_CALL ScShapeObj::addVetoableChangeListener( const rtl::OUString& aPropertyName,
+ const uno::Reference<beans::XVetoableChangeListener>& aListener)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ pShapePropertySet->addVetoableChangeListener( aPropertyName, aListener );
+}
+
+void SAL_CALL ScShapeObj::removeVetoableChangeListener( const rtl::OUString& aPropertyName,
+ const uno::Reference<beans::XVetoableChangeListener>& aListener)
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ GetShapePropertySet();
+ if (pShapePropertySet)
+ pShapePropertySet->removeVetoableChangeListener( aPropertyName, aListener );
+}
+
+// XPropertyState
+
+beans::PropertyState SAL_CALL ScShapeObj::getPropertyState( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+
+ beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
+ if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
+ {
+ // ImageMap is always "direct"
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_ANCHOR ) )
+ {
+ // Anchor is always "direct"
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_HORIPOS ) )
+ {
+ // HoriPos is always "direct"
+ }
+ else if ( aNameString.EqualsAscii( SC_UNONAME_VERTPOS ) )
+ {
+ // VertPos is always "direct"
+ }
+ else
+ {
+ GetShapePropertyState();
+ if (pShapePropertyState)
+ eRet = pShapePropertyState->getPropertyState( aPropertyName );
+ }
+
+ return eRet;
+}
+
+uno::Sequence<beans::PropertyState> SAL_CALL ScShapeObj::getPropertyStates(
+ const uno::Sequence<rtl::OUString>& aPropertyNames )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // simple loop to get own and aggregated states
+
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+ uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
+ beans::PropertyState* pStates = aRet.getArray();
+ for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
+ pStates[i] = getPropertyState(pNames[i]);
+ return aRet;
+}
+
+void SAL_CALL ScShapeObj::setPropertyToDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString(aPropertyName);
+
+ if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
+ {
+ SdrObject* pObj = GetSdrObject();
+ if ( pObj )
+ {
+ ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo(pObj);
+ if( pIMapInfo )
+ {
+ ImageMap aEmpty;
+ pIMapInfo->SetImageMap( aEmpty ); // replace with empty image map
+ }
+ else
+ {
+ // nothing to do (no need to insert user data for an empty map)
+ }
+ }
+ }
+ else
+ {
+ GetShapePropertyState();
+ if (pShapePropertyState)
+ pShapePropertyState->setPropertyToDefault( aPropertyName );
+ }
+}
+
+uno::Any SAL_CALL ScShapeObj::getPropertyDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameString = aPropertyName;
+
+ uno::Any aAny;
+ if ( aNameString.EqualsAscii( SC_UNONAME_IMAGEMAP ) )
+ {
+ // default: empty ImageMap
+ uno::Reference< uno::XInterface > xImageMap(SvUnoImageMap_createInstance( GetSupportedMacroItems() ));
+ aAny <<= uno::Reference< container::XIndexContainer >::query( xImageMap );
+ }
+ else
+ {
+ GetShapePropertyState();
+ if (pShapePropertyState)
+ aAny = pShapePropertyState->getPropertyDefault( aPropertyName );
+ }
+
+ return aAny;
+}
+
+// XTextContent
+
+void SAL_CALL ScShapeObj::attach( const uno::Reference<text::XTextRange>& /* xTextRange */ )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ throw lang::IllegalArgumentException(); // anchor cannot be changed
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getAnchor() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XTextRange> xRet;
+
+ SdrObject* pObj = GetSdrObject();
+ if( pObj )
+ {
+ ScDrawLayer* pModel = (ScDrawLayer*)pObj->GetModel();
+ SdrPage* pPage = pObj->GetPage();
+ if ( pModel )
+ {
+ ScDocument* pDoc = pModel->GetDocument();
+ if ( pDoc )
+ {
+ SfxObjectShell* pObjSh = pDoc->GetDocumentShell();
+ if ( pObjSh && pObjSh->ISA(ScDocShell) )
+ {
+ ScDocShell* pDocSh = (ScDocShell*)pObjSh;
+
+ SCTAB nTab = 0;
+ if ( lcl_GetPageNum( pPage, *pModel, nTab ) )
+ {
+ Point aPos(pObj->GetCurrentBoundRect().TopLeft());
+ ScRange aRange(pDoc->GetRange( nTab, Rectangle( aPos, aPos ) ));
+
+ // anchor is always the cell
+
+ xRet.set(new ScCellObj( pDocSh, aRange.aStart ));
+ }
+ }
+ }
+ }
+ }
+
+ return xRet;
+}
+
+// XComponent
+
+void SAL_CALL ScShapeObj::dispose() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
+ if ( xAggComp.is() )
+ xAggComp->dispose();
+}
+
+void SAL_CALL ScShapeObj::addEventListener(
+ const uno::Reference<lang::XEventListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
+ if ( xAggComp.is() )
+ xAggComp->addEventListener(xListener);
+}
+
+void SAL_CALL ScShapeObj::removeEventListener(
+ const uno::Reference<lang::XEventListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<lang::XComponent> xAggComp(lcl_GetComponent(mxShapeAgg));
+ if ( xAggComp.is() )
+ xAggComp->removeEventListener(xListener);
+}
+
+// XText
+// (special handling for ScCellFieldObj)
+
+void lcl_CopyOneProperty( beans::XPropertySet& rDest, beans::XPropertySet& rSource, const sal_Char* pName )
+{
+ rtl::OUString aNameStr(rtl::OUString::createFromAscii(pName));
+ try
+ {
+ rDest.setPropertyValue( aNameStr, rSource.getPropertyValue( aNameStr ) );
+ }
+ catch (uno::Exception&)
+ {
+ DBG_ERROR("Exception in text field");
+ }
+}
+
+void SAL_CALL ScShapeObj::insertTextContent( const uno::Reference<text::XTextRange>& xRange,
+ const uno::Reference<text::XTextContent>& xContent,
+ sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XTextContent> xEffContent;
+
+ ScCellFieldObj* pCellField = ScCellFieldObj::getImplementation( xContent );
+ if ( pCellField )
+ {
+ // #105585# createInstance("TextField.URL") from the document creates a ScCellFieldObj.
+ // To insert it into drawing text, a SvxUnoTextField is needed instead.
+ // The ScCellFieldObj object is left in non-inserted state.
+
+ SvxUnoTextField* pDrawField = new SvxUnoTextField( ID_URLFIELD );
+ xEffContent.set(pDrawField);
+ lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_URL );
+ lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_REPR );
+ lcl_CopyOneProperty( *pDrawField, *pCellField, SC_UNONAME_TARGET );
+ }
+ else
+ xEffContent.set(xContent);
+
+ uno::Reference<text::XText> xAggText(lcl_GetText(mxShapeAgg));
+ if ( xAggText.is() )
+ xAggText->insertTextContent( xRange, xEffContent, bAbsorb );
+}
+
+void SAL_CALL ScShapeObj::removeTextContent( const uno::Reference<text::XTextContent>& xContent )
+ throw(container::NoSuchElementException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ // ScCellFieldObj can't be used here.
+
+ uno::Reference<text::XText> xAggText(lcl_GetText(mxShapeAgg));
+ if ( xAggText.is() )
+ xAggText->removeTextContent( xContent );
+}
+
+// XSimpleText (parent of XText)
+// Use own SvxUnoTextCursor subclass - everything is just passed to aggregated object
+
+uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( mxShapeAgg.is() )
+ {
+ // ScDrawTextCursor must be used to ensure the ScShapeObj is returned by getText
+
+ SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( mxShapeAgg );
+ if (pText)
+ return new ScDrawTextCursor( this, *pText );
+ }
+
+ return uno::Reference<text::XTextCursor>();
+}
+
+uno::Reference<text::XTextCursor> SAL_CALL ScShapeObj::createTextCursorByRange(
+ const uno::Reference<text::XTextRange>& aTextPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if ( mxShapeAgg.is() && aTextPosition.is() )
+ {
+ // ScDrawTextCursor must be used to ensure the ScShapeObj is returned by getText
+
+ SvxUnoTextBase* pText = SvxUnoTextBase::getImplementation( mxShapeAgg );
+ SvxUnoTextRangeBase* pRange = SvxUnoTextRangeBase::getImplementation( aTextPosition );
+ if ( pText && pRange )
+ {
+ SvxUnoTextCursor* pCursor = new ScDrawTextCursor( this, *pText );
+ uno::Reference<text::XTextCursor> xCursor( pCursor );
+ pCursor->SetSelection( pRange->GetSelection() );
+ return xCursor;
+ }
+ }
+
+ return uno::Reference<text::XTextCursor>();
+}
+
+void SAL_CALL ScShapeObj::insertString( const uno::Reference<text::XTextRange>& xRange,
+ const rtl::OUString& aString, sal_Bool bAbsorb )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg));
+ if ( xAggSimpleText.is() )
+ xAggSimpleText->insertString( xRange, aString, bAbsorb );
+ else
+ throw uno::RuntimeException();
+}
+
+void SAL_CALL ScShapeObj::insertControlCharacter( const uno::Reference<text::XTextRange>& xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XSimpleText> xAggSimpleText(lcl_GetSimpleText(mxShapeAgg));
+ if ( xAggSimpleText.is() )
+ xAggSimpleText->insertControlCharacter( xRange, nControlCharacter, bAbsorb );
+ else
+ throw uno::RuntimeException();
+}
+
+// XTextRange
+// (parent of XSimpleText)
+
+uno::Reference<text::XText> SAL_CALL ScShapeObj::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return this;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
+ if ( xAggTextRange.is() )
+ return xAggTextRange->getStart();
+ else
+ throw uno::RuntimeException();
+
+// return uno::Reference<text::XTextRange>();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScShapeObj::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
+ if ( xAggTextRange.is() )
+ return xAggTextRange->getEnd();
+ else
+ throw uno::RuntimeException();
+
+// return uno::Reference<text::XTextRange>();
+}
+
+rtl::OUString SAL_CALL ScShapeObj::getString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
+ if ( xAggTextRange.is() )
+ return xAggTextRange->getString();
+ else
+ throw uno::RuntimeException();
+
+// return rtl::OUString();
+}
+
+void SAL_CALL ScShapeObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<text::XTextRange> xAggTextRange(lcl_GetTextRange(mxShapeAgg));
+ if ( xAggTextRange.is() )
+ xAggTextRange->setString( aText );
+ else
+ throw uno::RuntimeException();
+}
+
+// XTypeProvider
+
+uno::Sequence<uno::Type> SAL_CALL ScShapeObj::getTypes() throw(uno::RuntimeException)
+{
+ uno::Sequence< uno::Type > aBaseTypes( ScShapeObj_Base::getTypes() );
+
+ uno::Sequence< uno::Type > aTextTypes;
+ if ( bIsTextShape )
+ aTextTypes = ScShapeObj_TextBase::getTypes();
+
+ uno::Reference<lang::XTypeProvider> xBaseProvider;
+ if ( mxShapeAgg.is() )
+ mxShapeAgg->queryAggregation( getCppuType((uno::Reference<lang::XTypeProvider>*) 0) ) >>= xBaseProvider;
+ DBG_ASSERT( xBaseProvider.is(), "ScShapeObj: No XTypeProvider from aggregated shape!" );
+
+ uno::Sequence< uno::Type > aAggTypes;
+ if( xBaseProvider.is() )
+ aAggTypes = xBaseProvider->getTypes();
+
+ return ::comphelper::concatSequences( aBaseTypes, aTextTypes, aAggTypes );
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScShapeObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // do we need to compute the implementation id for this instance?
+ if( !pImplementationId && mxShapeAgg.is())
+ {
+ uno::Reference< drawing::XShape > xAggShape;
+ mxShapeAgg->queryAggregation( ::getCppuType((uno::Reference< drawing::XShape >*)0) ) >>= xAggShape;
+
+ if( xAggShape.is() )
+ {
+ const rtl::OUString aShapeType( xAggShape->getShapeType() );
+ // did we already compute an implementation id for the agregated shape type?
+ ScShapeImplementationIdMap::iterator aIter( aImplementationIdMap.find(aShapeType ) );
+ if( aIter == aImplementationIdMap.end() )
+ {
+ // we need to create a new implementation id for this
+ // note: this memory is not free'd until application exists
+ // but since we have a fixed set of shapetypes and the
+ // memory will be reused this is ok.
+ pImplementationId = new uno::Sequence< sal_Int8 >( 16 );
+ rtl_createUuid( (sal_uInt8 *) pImplementationId->getArray(), 0, sal_True );
+ aImplementationIdMap[ aShapeType ] = pImplementationId;
+ }
+ else
+ {
+ // use the already computed implementation id
+ pImplementationId = (*aIter).second;
+ }
+ }
+ }
+ if( NULL == pImplementationId )
+ {
+ DBG_ERROR( "Could not create an implementation id for a ScXShape!" );
+ return uno::Sequence< sal_Int8 > ();
+ }
+ else
+ {
+ return *pImplementationId;
+ }
+}
+
+SdrObject* ScShapeObj::GetSdrObject() const throw()
+{
+ if(mxShapeAgg.is())
+ {
+ SvxShape* pShape = SvxShape::getImplementation( mxShapeAgg );
+ if(pShape)
+ return pShape->GetSdrObject();
+ }
+
+ return NULL;
+}
+
+#define SC_EVENTACC_ONCLICK ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OnClick" ) )
+#define SC_EVENTACC_SCRIPT ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) )
+#define SC_EVENTACC_EVENTTYPE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "EventType" ) )
+
+typedef ::cppu::WeakImplHelper1< container::XNameReplace > ShapeUnoEventAcess_BASE;
+class ShapeUnoEventAccessImpl : public ShapeUnoEventAcess_BASE
+{
+private:
+ ScShapeObj* mpShape;
+
+ ScMacroInfo* getInfo( BOOL bCreate = FALSE )
+ {
+ return lcl_getShapeHyperMacroInfo( mpShape, bCreate );
+ }
+
+public:
+ ShapeUnoEventAccessImpl( ScShapeObj* pShape ): mpShape( pShape )
+ {
+ }
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const rtl::OUString& aName, const uno::Any& aElement ) throw(lang::IllegalArgumentException, container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasByName( aName ) )
+ throw container::NoSuchElementException();
+ uno::Sequence< beans::PropertyValue > aProperties;
+ aElement >>= aProperties;
+ const beans::PropertyValue* pProperties = aProperties.getConstArray();
+ const sal_Int32 nCount = aProperties.getLength();
+ sal_Int32 nIndex;
+ bool isEventType = false;
+ for( nIndex = 0; nIndex < nCount; nIndex++, pProperties++ )
+ {
+ if ( pProperties->Name.equals( SC_EVENTACC_EVENTTYPE ) )
+ {
+ isEventType = true;
+ continue;
+ }
+ if ( isEventType && (pProperties->Name == SC_EVENTACC_SCRIPT) )
+ {
+ rtl::OUString sValue;
+ if ( pProperties->Value >>= sValue )
+ {
+ ScMacroInfo* pInfo = getInfo( TRUE );
+ DBG_ASSERT( pInfo, "shape macro info could not be created!" );
+ if ( !pInfo )
+ break;
+ if ( pProperties->Name == SC_EVENTACC_SCRIPT )
+ pInfo->SetMacro( sValue );
+ else
+ pInfo->SetHlink( sValue );
+ }
+ }
+ }
+ }
+
+ // XNameAccess
+ virtual uno::Any SAL_CALL getByName( const rtl::OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ uno::Sequence< beans::PropertyValue > aProperties;
+ ScMacroInfo* pInfo = getInfo();
+
+ if ( aName == SC_EVENTACC_ONCLICK )
+ {
+ if ( pInfo && (pInfo->GetMacro().getLength() > 0) )
+ {
+ aProperties.realloc( 2 );
+ aProperties[ 0 ].Name = SC_EVENTACC_EVENTTYPE;
+ aProperties[ 0 ].Value <<= SC_EVENTACC_SCRIPT;
+ aProperties[ 1 ].Name = SC_EVENTACC_SCRIPT;
+ aProperties[ 1 ].Value <<= pInfo->GetMacro();
+ }
+ }
+ else
+ {
+ throw container::NoSuchElementException();
+ }
+
+ return uno::Any( aProperties );
+ }
+
+ virtual uno::Sequence< rtl::OUString > SAL_CALL getElementNames() throw(uno::RuntimeException)
+ {
+ uno::Sequence< rtl::OUString > aSeq( 1 );
+ aSeq[ 0 ] = SC_EVENTACC_ONCLICK;
+ return aSeq;
+ }
+
+ virtual sal_Bool SAL_CALL hasByName( const rtl::OUString& aName ) throw(uno::RuntimeException)
+ {
+ return aName == SC_EVENTACC_ONCLICK;
+ }
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw(uno::RuntimeException)
+ {
+ return *SEQTYPE(::getCppuType((const uno::Sequence< beans::PropertyValue >*)0));
+ }
+
+ virtual sal_Bool SAL_CALL hasElements() throw(uno::RuntimeException)
+ {
+ // elements are always present (but contained property sequences may be empty)
+ return sal_True;
+ }
+};
+
+::uno::Reference< container::XNameReplace > SAL_CALL
+ScShapeObj::getEvents( ) throw(uno::RuntimeException)
+{
+ return new ShapeUnoEventAccessImpl( this );
+}
+
+::rtl::OUString SAL_CALL ScShapeObj::getImplementationName( ) throw (uno::RuntimeException)
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sc.ScShapeObj" ) );
+}
+
+::sal_Bool SAL_CALL ScShapeObj::supportsService( const ::rtl::OUString& _ServiceName ) throw (uno::RuntimeException)
+{
+ uno::Sequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
+ for ( const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ pSupported != aSupported.getConstArray() + aSupported.getLength();
+ ++pSupported
+ )
+ if ( _ServiceName == *pSupported )
+ return sal_True;
+ return sal_False;
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL ScShapeObj::getSupportedServiceNames( ) throw (uno::RuntimeException)
+{
+ uno::Reference<lang::XServiceInfo> xSI;
+ if ( mxShapeAgg.is() )
+ mxShapeAgg->queryAggregation( lang::XServiceInfo::static_type() ) >>= xSI;
+
+ uno::Sequence< ::rtl::OUString > aSupported;
+ if ( xSI.is() )
+ aSupported = xSI->getSupportedServiceNames();
+
+ aSupported.realloc( aSupported.getLength() + 1 );
+ aSupported[ aSupported.getLength() - 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.Shape" ) );
+ return aSupported;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/srchuno.cxx b/sc/source/ui/unoobj/srchuno.cxx
new file mode 100644
index 000000000000..74bf2a095af0
--- /dev/null
+++ b/sc/source/ui/unoobj/srchuno.cxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "scitems.hxx"
+#include <svl/srchitem.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/uuid.h>
+
+#include "srchuno.hxx"
+#include "docsh.hxx"
+#include "undoblk.hxx"
+#include "hints.hxx"
+#include "markdata.hxx"
+#include "miscuno.hxx"
+#include "unonames.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+//! SearchWords sucht in ganzen Zellen - umbenennen ???
+
+// SfxItemPropertyMapEntry nur fuer GetPropertySetInfo
+
+const SfxItemPropertyMapEntry* lcl_GetSearchPropertyMap()
+{
+ static SfxItemPropertyMapEntry aSearchPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_SRCHBACK), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHBYROW), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHCASE), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHREGEXP), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHSIM), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHSIMADD), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHSIMEX), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHSIMREL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHSIMREM), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHSTYLES), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SRCHTYPE), 0, &getCppuType((sal_Int16*)0), 0, 0}, // enum TableSearch ist weg
+ {MAP_CHAR_LEN(SC_UNO_SRCHWORDS), 0, &getBooleanCppuType(), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aSearchPropertyMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+#define SCSEARCHDESCRIPTOR_SERVICE "com.sun.star.util.SearchDescriptor"
+#define SCREPLACEDESCRIPTOR_SERVICE "com.sun.star.util.ReplaceDescriptor"
+
+//------------------------------------------------------------------------
+
+ScCellSearchObj::ScCellSearchObj() :
+ aPropSet(lcl_GetSearchPropertyMap())
+{
+ pSearchItem = new SvxSearchItem( SCITEM_SEARCHDATA );
+ // Defaults:
+ pSearchItem->SetWordOnly(FALSE);
+ pSearchItem->SetExact(FALSE);
+ pSearchItem->SetMatchFullHalfWidthForms(FALSE);
+ pSearchItem->SetUseAsianOptions(FALSE); // or all asian bits would have to be handled
+ pSearchItem->SetBackward(FALSE);
+ pSearchItem->SetSelection(FALSE);
+ pSearchItem->SetRegExp(FALSE);
+ pSearchItem->SetPattern(FALSE);
+ pSearchItem->SetLevenshtein(FALSE);
+ pSearchItem->SetLEVRelaxed(FALSE);
+ pSearchItem->SetLEVOther(2);
+ pSearchItem->SetLEVShorter(2);
+ pSearchItem->SetLEVLonger(2);
+ // Calc-Flags
+ pSearchItem->SetRowDirection(FALSE);
+ pSearchItem->SetCellType(SVX_SEARCHIN_FORMULA);
+
+ // Selection-Flag wird beim Aufruf gesetzt
+}
+
+ScCellSearchObj::~ScCellSearchObj()
+{
+ delete pSearchItem;
+}
+
+// XSearchDescriptor
+
+rtl::OUString SAL_CALL ScCellSearchObj::getSearchString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return pSearchItem->GetSearchString();
+}
+
+void SAL_CALL ScCellSearchObj::setSearchString( const rtl::OUString& aString )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ pSearchItem->SetSearchString( aString );
+}
+
+// XReplaceDescriptor
+
+rtl::OUString SAL_CALL ScCellSearchObj::getReplaceString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return pSearchItem->GetReplaceString();
+}
+
+void SAL_CALL ScCellSearchObj::setReplaceString( const rtl::OUString& aReplaceString )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ pSearchItem->SetReplaceString( aReplaceString );
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellSearchObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScCellSearchObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+
+ if (aString.EqualsAscii( SC_UNO_SRCHBACK )) pSearchItem->SetBackward( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHBYROW )) pSearchItem->SetRowDirection( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHCASE )) pSearchItem->SetExact( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHREGEXP )) pSearchItem->SetRegExp( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIM )) pSearchItem->SetLevenshtein( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMREL )) pSearchItem->SetLEVRelaxed( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSTYLES )) pSearchItem->SetPattern( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHWORDS )) pSearchItem->SetWordOnly( ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMADD )) pSearchItem->SetLEVLonger( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMEX )) pSearchItem->SetLEVOther( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMREM )) pSearchItem->SetLEVShorter( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHTYPE )) pSearchItem->SetCellType( ScUnoHelpFunctions::GetInt16FromAny( aValue ) );
+ else if (aString.EqualsAscii( SC_UNO_SRCHFILTERED )) pSearchItem->SetSearchFiltered( ScUnoHelpFunctions::GetBoolFromAny(aValue) );
+}
+
+uno::Any SAL_CALL ScCellSearchObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+ uno::Any aRet;
+
+ if (aString.EqualsAscii( SC_UNO_SRCHBACK )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetBackward() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHBYROW )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetRowDirection() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHCASE )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetExact() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHREGEXP )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetRegExp() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIM )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsLevenshtein() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMREL )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsLEVRelaxed() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSTYLES )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetPattern() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHWORDS )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->GetWordOnly() );
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMADD )) aRet <<= (sal_Int16) pSearchItem->GetLEVLonger();
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMEX )) aRet <<= (sal_Int16) pSearchItem->GetLEVOther();
+ else if (aString.EqualsAscii( SC_UNO_SRCHSIMREM )) aRet <<= (sal_Int16) pSearchItem->GetLEVShorter();
+ else if (aString.EqualsAscii( SC_UNO_SRCHTYPE )) aRet <<= (sal_Int16) pSearchItem->GetCellType();
+ else if (aString.EqualsAscii( SC_UNO_SRCHFILTERED )) ScUnoHelpFunctions::SetBoolInAny( aRet, pSearchItem->IsSearchFiltered() );
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScCellSearchObj )
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScCellSearchObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScCellSearchObj" );
+}
+
+sal_Bool SAL_CALL ScCellSearchObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr(rServiceName);
+ return aServiceStr.EqualsAscii( SCSEARCHDESCRIPTOR_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCREPLACEDESCRIPTOR_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScCellSearchObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSEARCHDESCRIPTOR_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCREPLACEDESCRIPTOR_SERVICE );
+ return aRet;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScCellSearchObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScCellSearchObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScCellSearchObj* ScCellSearchObj::getImplementation(
+ const uno::Reference<util::XSearchDescriptor> xObj )
+{
+ ScCellSearchObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScCellSearchObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+
+//------------------------------------------------------------------------
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/styleuno.cxx b/sc/source/ui/unoobj/styleuno.cxx
new file mode 100644
index 000000000000..e9124658e6dd
--- /dev/null
+++ b/sc/source/ui/unoobj/styleuno.cxx
@@ -0,0 +1,2137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "scitems.hxx"
+#include <editeng/memberids.hrc>
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/numitem.hxx>
+#include <svx/pageitem.hxx>
+#include <editeng/pbinitem.hxx>
+#include <svx/unomid.hxx>
+#include <editeng/unonrule.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/printer.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <svl/intitem.hxx>
+#include <svl/zformat.hxx>
+#include <rtl/uuid.h>
+
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/table/CellVertJustify2.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/ShadowFormat.hpp>
+#include <com/sun/star/table/CellHoriJustify.hpp>
+#include <com/sun/star/table/CellOrientation.hpp>
+#include <com/sun/star/style/PageStyleLayout.hpp>
+#include <com/sun/star/style/GraphicLocation.hpp>
+#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
+#include <com/sun/star/util/CellProtection.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+#include "styleuno.hxx"
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "stlpool.hxx"
+#include "docpool.hxx"
+#include "miscuno.hxx"
+#include "convuno.hxx"
+#include "tablink.hxx"
+#include "unonames.hxx"
+#include "unowids.hxx"
+#include "globstr.hrc"
+#include "cellsuno.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+const SfxItemPropertySet* lcl_GetCellStyleSet()
+{
+ static SfxItemPropertyMapEntry aCellStyleMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNONAME_ASIANVERT),ATTR_VERTICAL_ASIAN,&getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_BOTTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLBACK), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLPRO), ATTR_PROTECTION, &::getCppuType((const util::CellProtection*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCOLOR), ATTR_FONT_COLOR, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_COUTL), ATTR_FONT_CONTOUR, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CCROSS), ATTR_FONT_CROSSEDOUT,&::getBooleanCppuType(), 0, MID_CROSSED_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CEMPHAS), ATTR_FONT_EMPHASISMARK,&getCppuType((sal_Int16*)0), 0, MID_EMPHASIS },
+ {MAP_CHAR_LEN(SC_UNONAME_CFONT), ATTR_FONT, &::getCppuType((const sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFCHARS), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFCHARS), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFCHARS), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_CHAR_SET },
+ {MAP_CHAR_LEN(SC_UNONAME_CFFAMIL), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFFAMIL), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFFAMIL), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_FAMILY },
+ {MAP_CHAR_LEN(SC_UNONAME_CFNAME), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFNAME), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFNAME), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_FAMILY_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CFPITCH), ATTR_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFPITCH), ATTR_CJK_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFPITCH), ATTR_CTL_FONT, &getCppuType((sal_Int16*)0), 0, MID_FONT_PITCH },
+ {MAP_CHAR_LEN(SC_UNONAME_CFSTYLE), ATTR_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CFSTYLE), ATTR_CJK_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CFSTYLE), ATTR_CTL_FONT, &getCppuType((rtl::OUString*)0), 0, MID_FONT_STYLE_NAME },
+ {MAP_CHAR_LEN(SC_UNONAME_CHEIGHT), ATTR_FONT_HEIGHT, &::getCppuType((const float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CHEIGHT), ATTR_CJK_FONT_HEIGHT,&::getCppuType((const float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CHEIGHT), ATTR_CTL_FONT_HEIGHT,&::getCppuType((const float*)0), 0, MID_FONTHEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), ATTR_FONT_LANGUAGE, &::getCppuType((const lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), ATTR_CJK_FONT_LANGUAGE,&::getCppuType((const lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CLOCAL), ATTR_CTL_FONT_LANGUAGE,&::getCppuType((const lang::Locale*)0), 0, MID_LANG_LOCALE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVER), ATTR_FONT_OVERLINE, &::getCppuType((const sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLCOL), ATTR_FONT_OVERLINE, &getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_COVRLHAS), ATTR_FONT_OVERLINE, &getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CPOST), ATTR_FONT_POSTURE, &::getCppuType((const awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CPOST), ATTR_CJK_FONT_POSTURE,&::getCppuType((const awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CPOST), ATTR_CTL_FONT_POSTURE,&::getCppuType((const awt::FontSlant*)0), 0, MID_POSTURE },
+ {MAP_CHAR_LEN(SC_UNONAME_CRELIEF), ATTR_FONT_RELIEF, &getCppuType((sal_Int16*)0), 0, MID_RELIEF },
+ {MAP_CHAR_LEN(SC_UNONAME_CSHADD), ATTR_FONT_SHADOWED, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CSTRIKE), ATTR_FONT_CROSSEDOUT,&getCppuType((sal_Int16*)0), 0, MID_CROSS_OUT },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDER), ATTR_FONT_UNDERLINE,&::getCppuType((const sal_Int16*)0), 0, MID_TL_STYLE },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLCOL), ATTR_FONT_UNDERLINE,&getCppuType((sal_Int32*)0), 0, MID_TL_COLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CUNDLHAS), ATTR_FONT_UNDERLINE,&getBooleanCppuType(), 0, MID_TL_HASCOLOR },
+ {MAP_CHAR_LEN(SC_UNONAME_CWEIGHT), ATTR_FONT_WEIGHT, &::getCppuType((const float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CJK_CWEIGHT), ATTR_CJK_FONT_WEIGHT,&::getCppuType((const float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNO_CTL_CWEIGHT), ATTR_CTL_FONT_WEIGHT,&::getCppuType((const float*)0), 0, MID_WEIGHT },
+ {MAP_CHAR_LEN(SC_UNONAME_CWORDMOD), ATTR_FONT_WORDLINE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_BLTR), ATTR_BORDER_BLTR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DIAGONAL_TLBR), ATTR_BORDER_TLBR, &::getCppuType((const table::BorderLine*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_DISPNAME), SC_WID_UNO_DISPNAME,&::getCppuType((rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS), ATTR_HOR_JUSTIFY, &::getCppuType((const table::CellHoriJustify*)0), 0, MID_HORJUST_HORJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLHJUS_METHOD), ATTR_HOR_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNONAME_WRAP), ATTR_LINEBREAK, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_LEFTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_NUMFMT), ATTR_VALUE_FORMAT, &::getCppuType((const sal_Int32*)0), 0, 0 },
+// {MAP_CHAR_LEN(SC_UNONAME_NUMRULES), SC_WID_UNO_NUMRULES,&getCppuType((const uno::Reference<container::XIndexReplace>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLORI), ATTR_STACKED, &::getCppuType((const table::CellOrientation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PADJUST), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PBMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PINDENT), ATTR_INDENT, &::getCppuType((const sal_Int16*)0), 0, 0 }, //! CONVERT_TWIPS
+ {MAP_CHAR_LEN(SC_UNONAME_PISCHDIST),ATTR_SCRIPTSPACE, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISFORBID),ATTR_FORBIDDEN_RULES,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHANG), ATTR_HANGPUNCTUATION,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PISHYPHEN),ATTR_HYPHENATE, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_PLASTADJ), ATTR_HOR_JUSTIFY, &::getCppuType((const sal_Int16*)0), 0, MID_HORJUST_ADJUST },
+ {MAP_CHAR_LEN(SC_UNONAME_PLMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PRMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_PTMARGIN), ATTR_MARGIN, &::getCppuType((const sal_Int32*)0), 0, MID_MARGIN_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_RIGHTBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTANG), ATTR_ROTATE_VALUE, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_ROTREF), ATTR_ROTATE_MODE, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_SHADOW), ATTR_SHADOW, &::getCppuType((const table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_SHRINK_TO_FIT), ATTR_SHRINKTOFIT, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_TBLBORD), SC_WID_UNO_TBLBORD, &::getCppuType((const table::TableBorder*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_TOPBORDER),ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS), ATTR_VER_JUSTIFY, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_CELLVJUS_METHOD), ATTR_VER_JUSTIFY_METHOD, &::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aCellStyleSet_Impl( aCellStyleMap_Impl );
+ return &aCellStyleSet_Impl;
+}
+
+// Map mit allen Seitenattributen, incl. Kopf-/Fusszeilenattribute
+
+const SfxItemPropertySet * lcl_GetPageStyleSet()
+{
+ static SfxItemPropertyMapEntry aPageStyleMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_PAGE_BACKCOLOR), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICFILT), ATTR_BACKGROUND, &::getCppuType((const ::rtl::OUString*)0), 0, MID_GRAPHIC_FILTER },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICLOC), ATTR_BACKGROUND, &::getCppuType((const style::GraphicLocation*)0), 0, MID_GRAPHIC_POSITION },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_GRAPHICURL), ATTR_BACKGROUND, &::getCppuType((const ::rtl::OUString*)0), 0, MID_GRAPHIC_URL },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_BACKTRANS), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_BACKCOLOR), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_BORDERDIST), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_BOTTBORDER), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_BOTTBRDDIST), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_BOTTMARGIN), ATTR_ULSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_CENTERHOR), ATTR_PAGE_HORCENTER,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_CENTERVER), ATTR_PAGE_VERCENTER,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_DISPNAME), SC_WID_UNO_DISPNAME,&::getCppuType((rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FIRSTPAGE), ATTR_PAGE_FIRSTPAGENO,&::getCppuType((const sal_Int16*)0), 0, 0 },
+//
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKCOL), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFFILT), SC_WID_UNO_FOOTERSET,&::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFLOC), SC_WID_UNO_FOOTERSET,&::getCppuType((const style::GraphicLocation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFURL), SC_WID_UNO_FOOTERSET,&::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKTRAN), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKCOL), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBODYDIST), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBRDDIST), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBOR), SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBDIS), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRDYNAMIC), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRHEIGHT), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRDYNAMIC), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRON), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHARED), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBOR), SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBDIS), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTMAR), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRON), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBOR), SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBDIS),SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTMAR), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHADOW), SC_WID_UNO_FOOTERSET,&::getCppuType((const table::ShadowFormat*)0), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRSHARED), SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBOR), SC_WID_UNO_FOOTERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBDIS), SC_WID_UNO_FOOTERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+//
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKCOL), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFFILT), SC_WID_UNO_HEADERSET,&::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFLOC), SC_WID_UNO_HEADERSET,&::getCppuType((const style::GraphicLocation*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFURL), SC_WID_UNO_HEADERSET,&::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKTRAN), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKCOL), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBODYDIST), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBRDDIST), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBOR), SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBDIS), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRDYNAMIC), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRHEIGHT), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRDYNAMIC), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRON), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHARED), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBOR), SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBDIS), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTMAR), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRON), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBOR), SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBDIS),SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTMAR), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHADOW), SC_WID_UNO_HEADERSET,&::getCppuType((const table::ShadowFormat*)0), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRSHARED), SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBOR), SC_WID_UNO_HEADERSET,&::getCppuType((const table::BorderLine*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBDIS), SC_WID_UNO_HEADERSET,&::getCppuType((const sal_Int32*)0), 0, 0 },
+//
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HEIGHT), ATTR_PAGE_SIZE, &::getCppuType((const sal_Int32*)0), 0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_BACKTRANS), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_LANDSCAPE), ATTR_PAGE, &::getBooleanCppuType(), 0, MID_PAGE_ORIENTATION },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTBORDER), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTBRDDIST), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTMARGIN), ATTR_LRSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTFTRCONT), ATTR_PAGE_FOOTERLEFT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_LEFTHDRCONT), ATTR_PAGE_HEADERLEFT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_NUMBERTYPE), ATTR_PAGE, &::getCppuType((const sal_Int16*)0), 0, MID_PAGE_NUMTYPE },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SCALEVAL), ATTR_PAGE_SCALE, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SYTLELAYOUT), ATTR_PAGE, &::getCppuType((const style::PageStyleLayout*)0), 0, MID_PAGE_LAYOUT },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTANNOT), ATTR_PAGE_NOTES, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTCHARTS), ATTR_PAGE_CHARTS, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTDOWN), ATTR_PAGE_TOPDOWN, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTDRAW), ATTR_PAGE_DRAWINGS, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTFORMUL), ATTR_PAGE_FORMULAS, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTGRID), ATTR_PAGE_GRID, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTHEADER), ATTR_PAGE_HEADERS, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTOBJS), ATTR_PAGE_OBJECTS, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PRINTZERO), ATTR_PAGE_NULLVALS, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_PAPERTRAY), ATTR_PAGE_PAPERBIN, &::getCppuType((const ::rtl::OUString*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTBORDER), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTBRDDIST),ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTMARGIN), ATTR_LRSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTFTRCON), ATTR_PAGE_FOOTERRIGHT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_RIGHTHDRCON), ATTR_PAGE_HEADERRIGHT,&::getCppuType((const uno::Reference< sheet::XHeaderFooterContent >*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOPAG), ATTR_PAGE_SCALETOPAGES,&::getCppuType((const sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOX), ATTR_PAGE_SCALETO, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SCALETOY), ATTR_PAGE_SCALETO, &::getCppuType((const sal_Int16*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SHADOWFORM), ATTR_SHADOW, &::getCppuType((const table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_SIZE), ATTR_PAGE_SIZE, &::getCppuType((const awt::Size*)0), 0, MID_SIZE_SIZE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_TOPBORDER), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_TOPBRDDIST), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_TOPMARGIN), ATTR_ULSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKTRAN),SC_WID_UNO_FOOTERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKTRAN),SC_WID_UNO_HEADERSET,&::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNONAME_USERDEF), ATTR_USERDEF, &getCppuType((uno::Reference<container::XNameContainer>*)0), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_WIDTH), ATTR_PAGE_SIZE, &::getCppuType((const sal_Int32*)0), 0, MID_SIZE_WIDTH | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNONAME_WRITING), ATTR_WRITINGDIR, &getCppuType((sal_Int16*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertySet aPageStyleSet_Impl( aPageStyleMap_Impl );
+ return &aPageStyleSet_Impl;
+}
+
+// Map mit Inhalten des Header-Item-Sets
+
+const SfxItemPropertyMap* lcl_GetHeaderStyleMap()
+{
+ static SfxItemPropertyMapEntry aHeaderStyleMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKCOL), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFFILT), ATTR_BACKGROUND, &::getCppuType((const ::rtl::OUString*)0), 0, MID_GRAPHIC_FILTER },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFLOC), ATTR_BACKGROUND, &::getCppuType((const style::GraphicLocation*)0), 0, MID_GRAPHIC_POSITION },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRGRFURL), ATTR_BACKGROUND, &::getCppuType((const ::rtl::OUString*)0), 0, MID_GRAPHIC_URL },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBACKTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKCOL), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBODYDIST), ATTR_ULSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_LO_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBRDDIST), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRBOTTBDIS), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRDYNAMIC), ATTR_PAGE_DYNAMIC, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRHEIGHT), ATTR_PAGE_SIZE, &::getCppuType((const sal_Int32*)0), 0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRDYNAMIC), ATTR_PAGE_DYNAMIC, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRON), ATTR_PAGE_ON, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHARED), ATTR_PAGE_SHARED, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTBDIS), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRLEFTMAR), ATTR_LRSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRON), ATTR_PAGE_ON, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTBDIS),ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRRIGHTMAR), ATTR_LRSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRSHADOW), ATTR_SHADOW, &::getCppuType((const table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRSHARED), ATTR_PAGE_SHARED, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_HDRTOPBDIS), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_HDRBACKTRAN),ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertyMap aHeaderStyleMap( aHeaderStyleMap_Impl );
+ return &aHeaderStyleMap;
+}
+
+// Map mit Inhalten des Footer-Item-Sets
+
+const SfxItemPropertyMap* lcl_GetFooterStyleMap()
+{
+ static SfxItemPropertyMapEntry aFooterStyleMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKCOL), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFFILT), ATTR_BACKGROUND, &::getCppuType((const ::rtl::OUString*)0), 0, MID_GRAPHIC_FILTER },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFLOC), ATTR_BACKGROUND, &::getCppuType((const style::GraphicLocation*)0), 0, MID_GRAPHIC_POSITION },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRGRFURL), ATTR_BACKGROUND, &::getCppuType((const ::rtl::OUString*)0), 0, MID_GRAPHIC_URL },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBACKTRAN), ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKCOL), ATTR_BACKGROUND, &::getCppuType((const sal_Int32*)0), 0, MID_BACK_COLOR },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBODYDIST), ATTR_ULSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_UP_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBRDDIST), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, BOTTOM_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRBOTTBDIS), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, BOTTOM_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRDYNAMIC), ATTR_PAGE_DYNAMIC, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRHEIGHT), ATTR_PAGE_SIZE, &::getCppuType((const sal_Int32*)0), 0, MID_SIZE_HEIGHT | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRDYNAMIC), ATTR_PAGE_DYNAMIC, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRON), ATTR_PAGE_ON, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHARED), ATTR_PAGE_SHARED, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, LEFT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTBDIS), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, LEFT_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRLEFTMAR), ATTR_LRSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_L_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRON), ATTR_PAGE_ON, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, RIGHT_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTBDIS),ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, RIGHT_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRRIGHTMAR), ATTR_LRSPACE, &::getCppuType((const sal_Int32*)0), 0, MID_R_MARGIN | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRSHADOW), ATTR_SHADOW, &::getCppuType((const table::ShadowFormat*)0), 0, 0 | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRSHARED), ATTR_PAGE_SHARED, &::getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBOR), ATTR_BORDER, &::getCppuType((const table::BorderLine*)0), 0, TOP_BORDER | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(SC_UNO_PAGE_FTRTOPBDIS), ATTR_BORDER, &::getCppuType((const sal_Int32*)0), 0, TOP_BORDER_DISTANCE | CONVERT_TWIPS },
+ {MAP_CHAR_LEN(OLD_UNO_PAGE_FTRBACKTRAN),ATTR_BACKGROUND, &::getBooleanCppuType(), 0, MID_GRAPHIC_TRANSPARENT },
+ {0,0,0,0,0,0}
+ };
+ static SfxItemPropertyMap aFooterStyleMap( aFooterStyleMap_Impl );
+ return &aFooterStyleMap;
+}
+
+
+//------------------------------------------------------------------------
+
+// Index-Access auf die Style-Typen: 0 = Cell, 1 = Page
+
+#define SC_STYLE_FAMILY_COUNT 2
+
+#define SC_FAMILYNAME_CELL "CellStyles"
+#define SC_FAMILYNAME_PAGE "PageStyles"
+
+static UINT16 aStyleFamilyTypes[SC_STYLE_FAMILY_COUNT] = { SFX_STYLE_FAMILY_PARA, SFX_STYLE_FAMILY_PAGE };
+
+//------------------------------------------------------------------------
+
+//! diese Funktionen in einen allgemeinen Header verschieben
+inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
+inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
+
+//------------------------------------------------------------------------
+
+#define SCSTYLE_SERVICE "com.sun.star.style.Style"
+#define SCCELLSTYLE_SERVICE "com.sun.star.style.CellStyle"
+#define SCPAGESTYLE_SERVICE "com.sun.star.style.PageStyle"
+
+SC_SIMPLE_SERVICE_INFO( ScStyleFamiliesObj, "ScStyleFamiliesObj", "com.sun.star.style.StyleFamilies" )
+SC_SIMPLE_SERVICE_INFO( ScStyleFamilyObj, "ScStyleFamilyObj", "com.sun.star.style.StyleFamily" )
+
+//------------------------------------------------------------------------
+
+#define SC_PAPERBIN_DEFAULTNAME "[From printer settings]"
+
+//------------------------------------------------------------------------
+
+// conversion programmatic <-> display (visible) name
+// currently, the core always has the visible names
+// the api is required to use programmatic names for default styles
+// these programmatic names must never change!
+
+#define SC_STYLE_PROG_STANDARD "Default"
+#define SC_STYLE_PROG_RESULT "Result"
+#define SC_STYLE_PROG_RESULT1 "Result2"
+#define SC_STYLE_PROG_HEADLINE "Heading"
+#define SC_STYLE_PROG_HEADLINE1 "Heading1"
+#define SC_STYLE_PROG_REPORT "Report"
+
+struct ScDisplayNameMap
+{
+ String aDispName;
+ String aProgName;
+};
+
+const ScDisplayNameMap* lcl_GetStyleNameMap( UINT16 nType )
+{
+ if ( nType == SFX_STYLE_FAMILY_PARA )
+ {
+ static BOOL bCellMapFilled = FALSE;
+ static ScDisplayNameMap aCellMap[6];
+ if ( !bCellMapFilled )
+ {
+ aCellMap[0].aDispName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
+ aCellMap[0].aProgName = String::CreateFromAscii( SC_STYLE_PROG_STANDARD );
+
+ aCellMap[1].aDispName = ScGlobal::GetRscString( STR_STYLENAME_RESULT );
+ aCellMap[1].aProgName = String::CreateFromAscii( SC_STYLE_PROG_RESULT );
+
+ aCellMap[2].aDispName = ScGlobal::GetRscString( STR_STYLENAME_RESULT1 );
+ aCellMap[2].aProgName = String::CreateFromAscii( SC_STYLE_PROG_RESULT1 );
+
+ aCellMap[3].aDispName = ScGlobal::GetRscString( STR_STYLENAME_HEADLINE );
+ aCellMap[3].aProgName = String::CreateFromAscii( SC_STYLE_PROG_HEADLINE );
+
+ aCellMap[4].aDispName = ScGlobal::GetRscString( STR_STYLENAME_HEADLINE1 );
+ aCellMap[4].aProgName = String::CreateFromAscii( SC_STYLE_PROG_HEADLINE1 );
+
+ // last entry remains empty
+
+ bCellMapFilled = TRUE;
+ }
+ return aCellMap;
+ }
+ else if ( nType == SFX_STYLE_FAMILY_PAGE )
+ {
+ static BOOL bPageMapFilled = FALSE;
+ static ScDisplayNameMap aPageMap[3];
+ if ( !bPageMapFilled )
+ {
+ aPageMap[0].aDispName = ScGlobal::GetRscString( STR_STYLENAME_STANDARD );
+ aPageMap[0].aProgName = String::CreateFromAscii( SC_STYLE_PROG_STANDARD );
+
+ aPageMap[1].aDispName = ScGlobal::GetRscString( STR_STYLENAME_REPORT );
+ aPageMap[1].aProgName = String::CreateFromAscii( SC_STYLE_PROG_REPORT );
+
+ // last entry remains empty
+
+ bPageMapFilled = TRUE;
+ }
+ return aPageMap;
+ }
+ DBG_ERROR("invalid family");
+ return NULL;
+}
+
+// programmatic name suffix for display names that match other programmatic names
+// is " (user)" including a space
+
+#define SC_SUFFIX_USER " (user)"
+#define SC_SUFFIX_USER_LEN 7
+
+BOOL lcl_EndsWithUser( const String& rString )
+{
+ const sal_Unicode *pChar = rString.GetBuffer();
+ xub_StrLen nLen = rString.Len();
+ return nLen >= SC_SUFFIX_USER_LEN &&
+ pChar[nLen-7] == ' ' &&
+ pChar[nLen-6] == '(' &&
+ pChar[nLen-5] == 'u' &&
+ pChar[nLen-4] == 's' &&
+ pChar[nLen-3] == 'e' &&
+ pChar[nLen-2] == 'r' &&
+ pChar[nLen-1] == ')';
+}
+
+// static
+String ScStyleNameConversion::DisplayToProgrammaticName( const String& rDispName, UINT16 nType )
+{
+ BOOL bDisplayIsProgrammatic = FALSE;
+
+ const ScDisplayNameMap* pNames = lcl_GetStyleNameMap( nType );
+ if (pNames)
+ {
+ do
+ {
+ if (pNames->aDispName == rDispName)
+ return pNames->aProgName;
+ else if (pNames->aProgName == rDispName)
+ bDisplayIsProgrammatic = TRUE; // display name matches any programmatic name
+ }
+ while( (++pNames)->aDispName.Len() );
+ }
+
+ if ( bDisplayIsProgrammatic || lcl_EndsWithUser( rDispName ) )
+ {
+ // add the (user) suffix if the display name matches any style's programmatic name
+ // or if it already contains the suffix
+
+ String aRet(rDispName);
+ aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SC_SUFFIX_USER ) );
+ return aRet;
+ }
+
+ return rDispName;
+}
+
+// static
+String ScStyleNameConversion::ProgrammaticToDisplayName( const String& rProgName, UINT16 nType )
+{
+ if ( lcl_EndsWithUser( rProgName ) )
+ {
+ // remove the (user) suffix, don't compare to map entries
+ return rProgName.Copy( 0, rProgName.Len() - SC_SUFFIX_USER_LEN );
+ }
+
+ const ScDisplayNameMap* pNames = lcl_GetStyleNameMap( nType );
+ if (pNames)
+ {
+ do
+ {
+ if (pNames->aProgName == rProgName)
+ return pNames->aDispName;
+ }
+ while( (++pNames)->aDispName.Len() );
+ }
+ return rProgName;
+}
+
+//------------------------------------------------------------------------
+
+sal_Bool lcl_AnyTabProtected( ScDocument& rDoc )
+{
+ SCTAB nTabCount = rDoc.GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (rDoc.IsTabProtected(i))
+ return sal_True;
+ return sal_False;
+}
+
+//------------------------------------------------------------------------
+
+ScStyleFamiliesObj::ScStyleFamiliesObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScStyleFamiliesObj::~ScStyleFamiliesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScStyleFamiliesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XStyleFamilies
+
+ScStyleFamilyObj*ScStyleFamiliesObj::GetObjectByType_Impl(UINT16 nType) const
+{
+ if ( pDocShell )
+ {
+ if ( nType == SFX_STYLE_FAMILY_PARA )
+ return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PARA );
+ else if ( nType == SFX_STYLE_FAMILY_PAGE )
+ return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PAGE );
+ }
+ DBG_ERROR("getStyleFamilyByType: keine DocShell oder falscher Typ");
+ return NULL;
+}
+
+ScStyleFamilyObj* ScStyleFamiliesObj::GetObjectByIndex_Impl(UINT32 nIndex) const
+{
+ if ( nIndex < SC_STYLE_FAMILY_COUNT )
+ return GetObjectByType_Impl(aStyleFamilyTypes[nIndex]);
+
+ return NULL; // ungueltiger Index
+}
+
+ScStyleFamilyObj* ScStyleFamiliesObj::GetObjectByName_Impl(const rtl::OUString& aName) const
+{
+ if ( pDocShell )
+ {
+ String aNameStr( aName );
+ if ( aNameStr.EqualsAscii( SC_FAMILYNAME_CELL ) )
+ return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PARA );
+ else if ( aNameStr.EqualsAscii( SC_FAMILYNAME_PAGE ) )
+ return new ScStyleFamilyObj( pDocShell, SFX_STYLE_FAMILY_PAGE );
+ }
+ // no assertion - called directly from getByName
+ return NULL;
+}
+
+// container::XIndexAccess
+
+sal_Int32 SAL_CALL ScStyleFamiliesObj::getCount() throw(uno::RuntimeException)
+{
+ return SC_STYLE_FAMILY_COUNT;
+}
+
+uno::Any SAL_CALL ScStyleFamiliesObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< container::XNameContainer > xFamily(GetObjectByIndex_Impl(nIndex));
+ if (xFamily.is())
+ return uno::makeAny(xFamily);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScStyleFamiliesObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::getCppuType((const uno::Reference< container::XNameContainer >*)0); // muss zu getByIndex passen
+}
+
+sal_Bool SAL_CALL ScStyleFamiliesObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// container::XNameAccess
+
+uno::Any SAL_CALL ScStyleFamiliesObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< container::XNameContainer > xFamily(GetObjectByName_Impl(aName));
+ if (xFamily.is())
+ return uno::makeAny(xFamily);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScStyleFamiliesObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence<rtl::OUString> aNames(SC_STYLE_FAMILY_COUNT);
+ rtl::OUString* pNames = aNames.getArray();
+ pNames[0] = rtl::OUString::createFromAscii( SC_FAMILYNAME_CELL );
+ pNames[1] = rtl::OUString::createFromAscii( SC_FAMILYNAME_PAGE );
+ return aNames;
+}
+
+sal_Bool SAL_CALL ScStyleFamiliesObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aNameStr( aName );
+ return ( aNameStr.EqualsAscii( SC_FAMILYNAME_CELL ) || aNameStr.EqualsAscii( SC_FAMILYNAME_PAGE ) );
+}
+
+// style::XStyleLoader
+
+void SAL_CALL ScStyleFamiliesObj::loadStylesFromURL( const rtl::OUString& aURL,
+ const uno::Sequence<beans::PropertyValue>& aOptions )
+ throw(io::IOException, uno::RuntimeException)
+{
+ //! use aOptions (like Writer)
+ //! set flag to disable filter option dialogs when importing
+
+ String aFilter; // empty - detect
+ String aFiltOpt;
+ ScDocumentLoader aLoader( aURL, aFilter, aFiltOpt );
+
+ ScDocShell* pSource = aLoader.GetDocShell();
+ if ( pSource && pDocShell )
+ {
+ // collect options
+
+ BOOL bLoadReplace = TRUE; // defaults
+ BOOL bLoadCellStyles = TRUE;
+ BOOL bLoadPageStyles = TRUE;
+
+ const beans::PropertyValue* pPropArray = aOptions.getConstArray();
+ long nPropCount = aOptions.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNONAME_OVERWSTL ))
+ bLoadReplace = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_LOADCELL ))
+ bLoadCellStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_LOADPAGE ))
+ bLoadPageStyles = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ }
+
+ pDocShell->LoadStylesArgs( *pSource, bLoadReplace, bLoadCellStyles, bLoadPageStyles );
+ pDocShell->SetDocumentModified(); // paint is inside LoadStyles
+ }
+}
+
+uno::Sequence<beans::PropertyValue> SAL_CALL ScStyleFamiliesObj::getStyleLoaderOptions()
+ throw(uno::RuntimeException)
+{
+ // return defaults for options (?)
+
+ uno::Sequence<beans::PropertyValue> aSequence(3);
+ beans::PropertyValue* pArray = aSequence.getArray();
+
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNONAME_OVERWSTL );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[0].Value, TRUE );
+
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNONAME_LOADCELL );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[1].Value, TRUE );
+
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNONAME_LOADPAGE );
+ ScUnoHelpFunctions::SetBoolInAny( pArray[2].Value, TRUE );
+
+ return aSequence;
+}
+
+//------------------------------------------------------------------------
+
+ScStyleFamilyObj::ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam) :
+ pDocShell( pDocSh ),
+ eFamily( eFam )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScStyleFamilyObj::~ScStyleFamilyObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScStyleFamilyObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+// XStyleFamily
+
+ScStyleObj* ScStyleFamilyObj::GetObjectByIndex_Impl(UINT32 nIndex)
+{
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+
+ SfxStyleSheetIterator aIter( pStylePool, eFamily );
+ if ( nIndex < aIter.Count() )
+ {
+ SfxStyleSheetBase* pStyle = aIter[(USHORT)nIndex];
+ if ( pStyle )
+ {
+ return new ScStyleObj( pDocShell, eFamily, String (pStyle->GetName()) );
+ }
+ }
+ }
+ return NULL;
+}
+
+ScStyleObj* ScStyleFamilyObj::GetObjectByName_Impl(const rtl::OUString& aName)
+{
+ if ( pDocShell )
+ {
+ String aString(aName);
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ if ( pStylePool->Find( aString, eFamily ) )
+ return new ScStyleObj( pDocShell, eFamily, aString );
+ }
+ return NULL;
+}
+
+void SAL_CALL ScStyleFamilyObj::insertByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::ElementExistException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bDone = sal_False;
+ // Reflection muss nicht uno::XInterface sein, kann auch irgendein Interface sein...
+ uno::Reference< uno::XInterface > xInterface(aElement, uno::UNO_QUERY);
+ if ( xInterface.is() )
+ {
+ ScStyleObj* pStyleObj = ScStyleObj::getImplementation( xInterface );
+ if ( pStyleObj && pStyleObj->GetFamily() == eFamily &&
+ !pStyleObj->IsInserted() ) // noch nicht eingefuegt?
+ {
+ String aNameStr(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<UINT16>(eFamily) ));
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+
+ //! DocFunc-Funktion??
+ //! Undo ?????????????
+
+ if ( !pStylePool->Find( aNameStr, eFamily ) ) // noch nicht vorhanden
+ {
+ (void)pStylePool->Make( aNameStr, eFamily, SFXSTYLEBIT_USERDEF );
+
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
+ pDoc->GetPool()->CellStyleCreated( aNameStr );
+
+ pStyleObj->InitDoc( pDocShell, aNameStr ); // Objekt kann benutzt werden
+
+ pDocShell->SetDocumentModified(); // verwendet wird der neue Style noch nicht
+ bDone = sal_True;
+ }
+ else
+ throw container::ElementExistException();
+ }
+ }
+
+ if (!bDone)
+ {
+ // other errors are handled above
+ throw lang::IllegalArgumentException();
+ }
+}
+
+void SAL_CALL ScStyleFamilyObj::replaceByName( const rtl::OUString& aName, const uno::Any& aElement )
+ throw(lang::IllegalArgumentException, container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ //! zusammenfassen?
+ removeByName( aName );
+ insertByName( aName, aElement );
+}
+
+void SAL_CALL ScStyleFamilyObj::removeByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ BOOL bFound = FALSE;
+ if ( pDocShell )
+ {
+ String aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<UINT16>(eFamily) ));
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+
+ //! DocFunc-Funktion??
+ //! Undo ?????????????
+
+ SfxStyleSheetBase* pStyle = pStylePool->Find( aString, eFamily );
+ if (pStyle)
+ {
+ bFound = TRUE;
+ if ( eFamily == SFX_STYLE_FAMILY_PARA )
+ {
+ // wie ScViewFunc::RemoveStyleSheetInUse
+ VirtualDevice aVDev;
+ Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
+ double nPPTX = aLogic.X() / 1000.0;
+ double nPPTY = aLogic.Y() / 1000.0;
+ Fraction aZoom(1,1);
+ pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+ pDocShell->SetDocumentModified();
+
+ pStylePool->Remove( pStyle );
+
+ //! InvalidateAttribs(); // Bindings-Invalidate
+ }
+ else
+ {
+ if ( pDoc->RemovePageStyleInUse( aString ) )
+ pDocShell->PageStyleModified( ScGlobal::GetRscString(STR_STYLENAME_STANDARD), sal_True );
+
+ pStylePool->Remove( pStyle );
+
+ SfxBindings* pBindings = pDocShell->GetViewBindings();
+ if (pBindings)
+ pBindings->Invalidate( SID_STYLE_FAMILY4 );
+ pDocShell->SetDocumentModified();
+ }
+ }
+ }
+
+ if (!bFound)
+ throw container::NoSuchElementException();
+}
+
+// container::XIndexAccess
+
+sal_Int32 SAL_CALL ScStyleFamilyObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+
+ SfxStyleSheetIterator aIter( pStylePool, eFamily );
+ return aIter.Count();
+ }
+ return 0;
+}
+
+uno::Any SAL_CALL ScStyleFamilyObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< style::XStyle > xObj(GetObjectByIndex_Impl(nIndex));
+ if (xObj.is())
+ return uno::makeAny(xObj);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScStyleFamilyObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ::getCppuType((const uno::Reference< style::XStyle >*)0); // muss zu getByIndex passen
+}
+
+sal_Bool SAL_CALL ScStyleFamilyObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// container::XNameAccess
+
+uno::Any SAL_CALL ScStyleFamilyObj::getByName( const rtl::OUString& aName )
+ throw(container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< style::XStyle > xObj(
+ GetObjectByName_Impl( ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<UINT16>(eFamily) ) ));
+ if (xObj.is())
+ return uno::makeAny(xObj);
+ else
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScStyleFamilyObj::getElementNames()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+
+ SfxStyleSheetIterator aIter( pStylePool, eFamily );
+ UINT16 nCount = aIter.Count();
+
+ String aName;
+ uno::Sequence<rtl::OUString> aSeq(nCount);
+ rtl::OUString* pAry = aSeq.getArray();
+ SfxStyleSheetBase* pStyle = aIter.First();
+ UINT16 nPos = 0;
+ while (pStyle)
+ {
+ DBG_ASSERT( nPos<nCount, "Anzahl durcheinandergekommen" );
+ if (nPos<nCount)
+ pAry[nPos++] = ScStyleNameConversion::DisplayToProgrammaticName(
+ pStyle->GetName(), sal::static_int_cast<UINT16>(eFamily) );
+ pStyle = aIter.Next();
+ }
+ return aSeq;
+ }
+ return uno::Sequence<rtl::OUString>();
+}
+
+sal_Bool SAL_CALL ScStyleFamilyObj::hasByName( const rtl::OUString& aName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( pDocShell )
+ {
+ String aString(ScStyleNameConversion::ProgrammaticToDisplayName( aName, sal::static_int_cast<UINT16>(eFamily) ));
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ if ( pStylePool->Find( aString, eFamily ) )
+ return sal_True;
+ }
+ return sal_False;
+}
+
+// XPropertySet
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ScStyleFamilyObj::getPropertySetInfo( ) throw (uno::RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+ return uno::Reference< beans::XPropertySetInfo >();
+}
+
+void SAL_CALL ScStyleFamilyObj::setPropertyValue( const ::rtl::OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+uno::Any SAL_CALL ScStyleFamilyObj::getPropertyValue( const ::rtl::OUString& sPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aRet;
+
+ if ( sPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("DisplayName") ) )
+ {
+ SolarMutexGuard aGuard;
+ sal_uInt32 nResId = 0;
+ switch ( eFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ nResId = STR_STYLE_FAMILY_CELL; break;
+ case SFX_STYLE_FAMILY_PAGE:
+ nResId = STR_STYLE_FAMILY_PAGE; break;
+ default:
+ OSL_ENSURE( 0, "ScStyleFamilyObj::getPropertyValue(): invalid family" );
+ }
+ if ( nResId > 0 )
+ {
+ ::rtl::OUString sDisplayName( ScGlobal::GetRscString( static_cast< USHORT >( nResId ) ) );
+ aRet = uno::makeAny( sDisplayName );
+ }
+ }
+ else
+ {
+ throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("unknown property: ") ) + sPropertyName, static_cast<OWeakObject *>(this) );
+ }
+
+ return aRet;
+}
+
+void SAL_CALL ScStyleFamilyObj::addPropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+void SAL_CALL ScStyleFamilyObj::removePropertyChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XPropertyChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+void SAL_CALL ScStyleFamilyObj::addVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+void SAL_CALL ScStyleFamilyObj::removeVetoableChangeListener( const ::rtl::OUString&, const uno::Reference< beans::XVetoableChangeListener >& ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE( 0, "###unexpected!" );
+}
+
+//------------------------------------------------------------------------
+
+// Default-ctor wird fuer die Reflection gebraucht
+
+ScStyleObj::ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const String& rName) :
+ pPropSet( (eFam == SFX_STYLE_FAMILY_PARA) ? lcl_GetCellStyleSet() : lcl_GetPageStyleSet() ),
+ pDocShell( pDocSh ),
+ eFamily( eFam ),
+ aStyleName( rName )
+{
+ // pDocShell ist Null, wenn per ServiceProvider erzeugt
+
+ if (pDocShell)
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+void ScStyleObj::InitDoc( ScDocShell* pNewDocSh, const String& rNewName )
+{
+ if ( pNewDocSh && !pDocShell )
+ {
+ aStyleName = rNewName;
+ pDocShell = pNewDocSh;
+ pDocShell->GetDocument()->AddUnoObject(*this);
+ }
+}
+
+ScStyleObj::~ScStyleObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScStyleObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScStyleObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScStyleObj* ScStyleObj::getImplementation(
+ const uno::Reference<uno::XInterface> xObj )
+{
+ ScStyleObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScStyleObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+void ScStyleObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ // Referenz-Update interessiert hier nicht
+
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // ungueltig geworden
+ }
+}
+
+SfxStyleSheetBase* ScStyleObj::GetStyle_Impl()
+{
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ return pStylePool->Find( aStyleName, eFamily );
+ }
+ return NULL;
+}
+
+// style::XStyle
+
+sal_Bool SAL_CALL ScStyleObj::isUserDefined() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ return pStyle->IsUserDefined();
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ScStyleObj::isInUse() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ return pStyle->IsUsed();
+ return sal_False;
+}
+
+rtl::OUString SAL_CALL ScStyleObj::getParentStyle() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetParent(), sal::static_int_cast<UINT16>(eFamily) );
+ return rtl::OUString();
+}
+
+void SAL_CALL ScStyleObj::setParentStyle( const rtl::OUString& rParentStyle )
+ throw(container::NoSuchElementException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ {
+ // #70909# cell styles cannot be modified if any sheet is protected
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
+ return; //! exception?
+
+ //! DocFunc-Funktion??
+ //! Undo ?????????????
+
+ String aString(ScStyleNameConversion::ProgrammaticToDisplayName( rParentStyle, sal::static_int_cast<UINT16>(eFamily) ));
+ sal_Bool bOk = pStyle->SetParent( aString );
+ if (bOk)
+ {
+ // wie bei setPropertyValue
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( eFamily == SFX_STYLE_FAMILY_PARA )
+ {
+ // Zeilenhoehen anpassen...
+
+ VirtualDevice aVDev;
+ Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
+ double nPPTX = aLogic.X() / 1000.0;
+ double nPPTY = aLogic.Y() / 1000.0;
+ Fraction aZoom(1,1);
+ pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
+
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+ pDocShell->SetDocumentModified();
+ }
+ else
+ {
+ //! ModifyStyleSheet am Dokument (alte Werte merken)
+
+ pDocShell->PageStyleModified( aStyleName, sal_True );
+ }
+ }
+ }
+}
+
+// container::XNamed
+
+rtl::OUString SAL_CALL ScStyleObj::getName() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ return ScStyleNameConversion::DisplayToProgrammaticName( pStyle->GetName(), sal::static_int_cast<UINT16>(eFamily) );
+ return rtl::OUString();
+}
+
+void SAL_CALL ScStyleObj::setName( const rtl::OUString& aNewName )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ {
+ // #71225# cell styles cannot be renamed if any sheet is protected
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
+ return; //! exception?
+
+ //! DocFunc-Funktion??
+ //! Undo ?????????????
+
+ String aString(aNewName);
+ sal_Bool bOk = pStyle->SetName( aString );
+ if (bOk)
+ {
+ aStyleName = aString; //! notify other objects for this style?
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && !pDoc->IsImportingXML() )
+ pDoc->GetPool()->CellStyleCreated( aString );
+
+ // Zellvorlagen = 2, Seitenvorlagen = 4
+ UINT16 nId = ( eFamily == SFX_STYLE_FAMILY_PARA ) ?
+ SID_STYLE_FAMILY2 : SID_STYLE_FAMILY4;
+ SfxBindings* pBindings = pDocShell->GetViewBindings();
+ if (pBindings)
+ {
+ pBindings->Invalidate( nId );
+ pBindings->Invalidate( SID_STYLE_APPLY );
+ }
+ }
+ }
+}
+
+// static
+uno::Reference<container::XIndexReplace> ScStyleObj::CreateEmptyNumberingRules()
+{
+ SvxNumRule aRule( 0, 0, TRUE ); // nothing supported
+ return SvxCreateNumRule( &aRule );
+}
+
+// beans::XPropertyState
+
+const SfxItemSet* ScStyleObj::GetStyleItemSet_Impl( const ::rtl::OUString& rPropName,
+ const SfxItemPropertySimpleEntry*& rpResultEntry )
+{
+ //! OUString as argument?
+
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ {
+ const SfxItemPropertySimpleEntry* pEntry = NULL;
+ if ( eFamily == SFX_STYLE_FAMILY_PAGE )
+ {
+ pEntry = lcl_GetHeaderStyleMap()->getByName( rPropName );
+ if ( pEntry ) // only item-wids in header/footer map
+ {
+ rpResultEntry = pEntry;
+ return &((const SvxSetItem&)pStyle->GetItemSet().Get(ATTR_PAGE_HEADERSET)).GetItemSet();
+ }
+ pEntry = lcl_GetFooterStyleMap()->getByName( rPropName );
+ if ( pEntry ) // only item-wids in header/footer map
+ {
+ rpResultEntry = pEntry;
+ return &((const SvxSetItem&)pStyle->GetItemSet().Get(ATTR_PAGE_FOOTERSET)).GetItemSet();
+ }
+ }
+ pEntry = pPropSet->getPropertyMap()->getByName( rPropName );
+ if ( pEntry )
+ {
+ rpResultEntry = pEntry;
+ return &pStyle->GetItemSet();
+ }
+ }
+
+ rpResultEntry = NULL;
+ return NULL;
+}
+
+beans::PropertyState SAL_CALL ScStyleObj::getPropertyState( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ beans::PropertyState eRet = beans::PropertyState_DIRECT_VALUE;
+
+ const SfxItemPropertySimpleEntry* pResultEntry = NULL;
+ const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
+
+ if ( pItemSet && pResultEntry )
+ {
+ USHORT nWhich = pResultEntry->nWID;
+ if ( nWhich == SC_WID_UNO_TBLBORD )
+ {
+ nWhich = ATTR_BORDER;
+ }
+ if ( IsScItemWid( nWhich ) )
+ {
+ SfxItemState eState = pItemSet->GetItemState( nWhich, sal_False );
+
+// // if no rotate value is set, look at orientation
+// //! also for a fixed value of 0 (in case orientation is ambiguous)?
+// if ( nWhich == ATTR_ROTATE_VALUE && eState == SFX_ITEM_DEFAULT )
+// eState = pItemSet->GetItemState( ATTR_ORIENTATION, sal_False );
+
+ if ( eState == SFX_ITEM_SET )
+ eRet = beans::PropertyState_DIRECT_VALUE;
+ else if ( eState == SFX_ITEM_DEFAULT )
+ eRet = beans::PropertyState_DEFAULT_VALUE;
+ else if ( eState == SFX_ITEM_DONTCARE )
+ eRet = beans::PropertyState_AMBIGUOUS_VALUE; // kann eigentlich nicht sein...
+ else
+ {
+ DBG_ERROR("unbekannter ItemState");
+ }
+ }
+ }
+ return eRet;
+}
+
+uno::Sequence<beans::PropertyState> SAL_CALL ScStyleObj::getPropertyStates(
+ const uno::Sequence<rtl::OUString>& aPropertyNames )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ // duemmliche Default-Implementierung: alles einzeln per getPropertyState holen
+ //! sollte optimiert werden!
+
+ SolarMutexGuard aGuard;
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+ uno::Sequence<beans::PropertyState> aRet(aPropertyNames.getLength());
+ beans::PropertyState* pStates = aRet.getArray();
+ for(sal_Int32 i = 0; i < aPropertyNames.getLength(); i++)
+ pStates[i] = getPropertyState(pNames[i]);
+ return aRet;
+}
+
+void SAL_CALL ScStyleObj::setPropertyToDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const SfxItemPropertyMap* pMap = pPropSet->getPropertyMap();
+ const SfxItemPropertySimpleEntry* pEntry = pMap->getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ SetOnePropertyValue( aPropertyName, pEntry, NULL );
+}
+
+uno::Any SAL_CALL ScStyleObj::getPropertyDefault( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aAny;
+
+ const SfxItemPropertySimpleEntry* pResultEntry = NULL;
+ const SfxItemSet* pStyleSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
+
+ if ( pStyleSet && pResultEntry )
+ {
+ USHORT nWhich = pResultEntry->nWID;
+
+ if ( IsScItemWid( nWhich ) )
+ {
+ // Default ist Default vom ItemPool, nicht vom Standard-Style,
+ // damit es zu setPropertyToDefault passt
+ SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
+ // #65253# Default-Items mit falscher Slot-ID funktionieren im SfxItemPropertySet3 nicht
+ //! Slot-IDs aendern...
+ if ( aEmptySet.GetPool()->GetSlotId(nWhich) == nWhich &&
+ aEmptySet.GetItemState(nWhich, sal_False) == SFX_ITEM_DEFAULT )
+ {
+ aEmptySet.Put( aEmptySet.Get( nWhich ) );
+ }
+ const SfxItemSet* pItemSet = &aEmptySet;
+
+ switch ( nWhich ) // fuer Item-Spezial-Behandlungen
+ {
+ case ATTR_VALUE_FORMAT:
+ // default has no language set
+ aAny <<= sal_Int32( ((const SfxUInt32Item&)pItemSet->Get(nWhich)).GetValue() );
+ break;
+ case ATTR_INDENT:
+ aAny <<= sal_Int16( TwipsToHMM(((const SfxUInt16Item&)
+ pItemSet->Get(nWhich)).GetValue()) );
+ break;
+ case ATTR_PAGE_SCALE:
+ case ATTR_PAGE_SCALETOPAGES:
+ case ATTR_PAGE_FIRSTPAGENO:
+ aAny <<= sal_Int16( ((const SfxUInt16Item&)pItemSet->Get(nWhich)).GetValue() );
+ break;
+ case ATTR_PAGE_CHARTS:
+ case ATTR_PAGE_OBJECTS:
+ case ATTR_PAGE_DRAWINGS:
+ //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
+ aAny <<= sal_Bool( ((const ScViewObjectModeItem&)pItemSet->Get(nWhich)).
+ GetValue() == VOBJ_MODE_SHOW );
+ break;
+ case ATTR_PAGE_SCALETO:
+ {
+ const ScPageScaleToItem aItem((const ScPageScaleToItem&)pItemSet->Get(nWhich));
+ if (aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX )))
+ aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetWidth()));
+ else
+ aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetHeight()));
+ }
+ break;
+ default:
+ pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
+ }
+ }
+ else if ( IsScUnoWid( nWhich ) )
+ {
+ SfxItemSet aEmptySet( *pStyleSet->GetPool(), pStyleSet->GetRanges() );
+ const SfxItemSet* pItemSet = &aEmptySet;
+ switch ( nWhich )
+ {
+ case SC_WID_UNO_TBLBORD:
+ {
+ const SfxPoolItem* pItem = &pItemSet->Get( ATTR_BORDER );
+ if ( pItem )
+ {
+ SvxBoxItem aOuter( *( static_cast<const SvxBoxItem*>( pItem ) ) );
+ SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
+ table::TableBorder aBorder;
+ ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
+ aBorder.IsHorizontalLineValid = sal_False;
+ aBorder.IsVerticalLineValid = sal_False;
+ aBorder.IsDistanceValid = sal_False;
+ aAny <<= aBorder;
+ }
+ }
+ break;
+ }
+ }
+ }
+ return aAny;
+}
+
+// XMultiPropertySet
+
+void SAL_CALL ScStyleObj::setPropertyValues( const uno::Sequence< rtl::OUString >& aPropertyNames,
+ const uno::Sequence< uno::Any >& aValues )
+ throw (beans::PropertyVetoException, lang::IllegalArgumentException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nCount = aPropertyNames.getLength();
+ if ( aValues.getLength() != nCount )
+ throw lang::IllegalArgumentException();
+
+ if ( nCount )
+ {
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+ const uno::Any* pValues = aValues.getConstArray();
+
+ const SfxItemPropertyMap* pPropertyMap = pPropSet->getPropertyMap();
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( pNames[i] );
+ SetOnePropertyValue( pNames[i], pEntry, &pValues[i] );
+ }
+ }
+}
+
+uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyValues(
+ const uno::Sequence< rtl::OUString >& aPropertyNames )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! optimize
+
+ sal_Int32 nCount = aPropertyNames.getLength();
+ uno::Sequence<uno::Any> aSequence( nCount );
+ if ( nCount )
+ {
+ uno::Any* pValues = aSequence.getArray();
+ for (sal_Int32 i=0; i<nCount; i++)
+ pValues[i] = getPropertyValue( aPropertyNames[i] );
+ }
+ return aSequence;
+}
+
+void SAL_CALL ScStyleObj::addPropertiesChangeListener( const uno::Sequence<rtl::OUString>& /* aPropertyNames */,
+ const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
+ throw (uno::RuntimeException)
+{
+ // no bound properties
+}
+
+void SAL_CALL ScStyleObj::removePropertiesChangeListener(
+ const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
+ throw (uno::RuntimeException)
+{
+ // no bound properties
+}
+
+void SAL_CALL ScStyleObj::firePropertiesChangeEvent( const uno::Sequence<rtl::OUString>& /* aPropertyNames */,
+ const uno::Reference<beans::XPropertiesChangeListener>& /* xListener */ )
+ throw (uno::RuntimeException)
+{
+ // no bound properties
+}
+
+// XMultiPropertyStates
+// getPropertyStates already defined for XPropertyState
+
+void SAL_CALL ScStyleObj::setAllPropertiesToDefault() throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if ( pStyle )
+ {
+ // #70909# cell styles cannot be modified if any sheet is protected
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
+ throw uno::RuntimeException();
+
+ SfxItemSet& rSet = pStyle->GetItemSet();
+ rSet.ClearItem(); // set all items to default
+
+ //! merge with SetOneProperty
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( eFamily == SFX_STYLE_FAMILY_PARA )
+ {
+ // row heights
+
+ VirtualDevice aVDev;
+ Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
+ double nPPTX = aLogic.X() / 1000.0;
+ double nPPTY = aLogic.Y() / 1000.0;
+ Fraction aZoom(1,1);
+ pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
+
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+ pDocShell->SetDocumentModified();
+ }
+ else
+ {
+ // #i22448# apply the default BoxInfoItem for page styles again
+ // (same content as in ScStyleSheet::GetItemSet, to control the dialog)
+ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
+ aBoxInfoItem.SetTable( FALSE );
+ aBoxInfoItem.SetDist( TRUE );
+ aBoxInfoItem.SetValid( VALID_DISTANCE, TRUE );
+ rSet.Put( aBoxInfoItem );
+
+ pDocShell->PageStyleModified( aStyleName, sal_True );
+ }
+ }
+}
+
+void SAL_CALL ScStyleObj::setPropertiesToDefault( const uno::Sequence<rtl::OUString>& aPropertyNames )
+ throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nCount = aPropertyNames.getLength();
+ if ( nCount )
+ {
+ const rtl::OUString* pNames = aPropertyNames.getConstArray();
+
+ const SfxItemPropertyMap* pPropertyMap = pPropSet->getPropertyMap();
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ const SfxItemPropertySimpleEntry* pEntry = pPropertyMap->getByName( pNames[i] );
+ SetOnePropertyValue( pNames[i], pEntry, NULL );
+ }
+ }
+}
+
+uno::Sequence<uno::Any> SAL_CALL ScStyleObj::getPropertyDefaults(
+ const uno::Sequence<rtl::OUString>& aPropertyNames )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! optimize
+
+ sal_Int32 nCount = aPropertyNames.getLength();
+ uno::Sequence<uno::Any> aSequence( nCount );
+ if ( nCount )
+ {
+ uno::Any* pValues = aSequence.getArray();
+ for (sal_Int32 i=0; i<nCount; i++)
+ pValues[i] = getPropertyDefault( aPropertyNames[i] );
+ }
+ return aSequence;
+}
+
+// beans::XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScStyleObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return pPropSet->getPropertySetInfo();
+}
+
+void SAL_CALL ScStyleObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( aPropertyName );
+ if ( !pEntry )
+ throw beans::UnknownPropertyException();
+
+ SetOnePropertyValue( aPropertyName, pEntry, &aValue );
+}
+
+void ScStyleObj::SetOnePropertyValue( const ::rtl::OUString& rPropertyName, const SfxItemPropertySimpleEntry* pEntry, const uno::Any* pValue )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if ( pStyle && pEntry )
+ {
+ // #70909# cell styles cannot be modified if any sheet is protected
+ if ( eFamily == SFX_STYLE_FAMILY_PARA && lcl_AnyTabProtected( *pDocShell->GetDocument() ) )
+ throw uno::RuntimeException();
+
+ SfxItemSet& rSet = pStyle->GetItemSet(); // direkt im lebenden Style aendern...
+ sal_Bool bDone = sal_False;
+ if ( eFamily == SFX_STYLE_FAMILY_PAGE )
+ {
+ if(pEntry->nWID == SC_WID_UNO_HEADERSET)
+ {
+ const SfxItemPropertySimpleEntry* pHeaderEntry = lcl_GetHeaderStyleMap()->getByName( rPropertyName );
+ if ( pHeaderEntry ) // only item-wids in header/footer map
+ {
+ SvxSetItem aNewHeader( (const SvxSetItem&)rSet.Get(ATTR_PAGE_HEADERSET) );
+ if (pValue)
+ pPropSet->setPropertyValue( *pHeaderEntry, *pValue, aNewHeader.GetItemSet() );
+ else
+ aNewHeader.GetItemSet().ClearItem( pHeaderEntry->nWID );
+ rSet.Put( aNewHeader );
+ bDone = sal_True;
+ }
+ }
+ else if(pEntry->nWID == SC_WID_UNO_FOOTERSET)
+ {
+ const SfxItemPropertySimpleEntry* pFooterEntry = lcl_GetFooterStyleMap()->getByName( rPropertyName );
+ if ( pFooterEntry ) // only item-wids in header/footer map
+ {
+ SvxSetItem aNewFooter( (const SvxSetItem&)rSet.Get(ATTR_PAGE_FOOTERSET) );
+ if (pValue)
+ pPropSet->setPropertyValue( *pFooterEntry, *pValue, aNewFooter.GetItemSet() );
+ else
+ aNewFooter.GetItemSet().ClearItem( pFooterEntry->nWID );
+ rSet.Put( aNewFooter );
+ bDone = sal_True;
+ }
+ }
+ }
+ if (!bDone)
+ {
+ if ( pEntry )
+ {
+ if ( IsScItemWid( pEntry->nWID ) )
+ {
+ if (pValue)
+ {
+ switch ( pEntry->nWID ) // fuer Item-Spezial-Behandlungen
+ {
+ case ATTR_VALUE_FORMAT:
+ {
+ // #67847# language for number formats
+ SvNumberFormatter* pFormatter =
+ pDocShell->GetDocument()->GetFormatTable();
+ UINT32 nOldFormat = ((const SfxUInt32Item&)
+ rSet.Get( ATTR_VALUE_FORMAT )).GetValue();
+ LanguageType eOldLang = ((const SvxLanguageItem&)
+ rSet.Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
+ nOldFormat = pFormatter->
+ GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
+
+ UINT32 nNewFormat = 0;
+ *pValue >>= nNewFormat;
+ rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
+
+ const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
+ LanguageType eNewLang =
+ pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
+ if ( eNewLang != eOldLang && eNewLang != LANGUAGE_DONTKNOW )
+ rSet.Put( SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
+
+ //! keep default state of number format if only language changed?
+ }
+ break;
+ case ATTR_INDENT:
+ {
+ sal_Int16 nVal = 0;
+ *pValue >>= nVal;
+ rSet.Put( SfxUInt16Item( pEntry->nWID, (USHORT)HMMToTwips(nVal) ) );
+ }
+ break;
+ case ATTR_ROTATE_VALUE:
+ {
+ sal_Int32 nRotVal = 0;
+ if ( *pValue >>= nRotVal )
+ {
+ // stored value is always between 0 and 360 deg.
+ nRotVal %= 36000;
+ if ( nRotVal < 0 )
+ nRotVal += 36000;
+ rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, nRotVal ) );
+ }
+ }
+ break;
+ case ATTR_STACKED:
+ {
+ table::CellOrientation eOrient;
+ if( *pValue >>= eOrient )
+ {
+ switch( eOrient )
+ {
+ case table::CellOrientation_STANDARD:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
+ break;
+ case table::CellOrientation_TOPBOTTOM:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
+ rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 27000 ) );
+ break;
+ case table::CellOrientation_BOTTOMTOP:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, FALSE ) );
+ rSet.Put( SfxInt32Item( ATTR_ROTATE_VALUE, 9000 ) );
+ break;
+ case table::CellOrientation_STACKED:
+ rSet.Put( SfxBoolItem( ATTR_STACKED, TRUE ) );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ }
+ break;
+ case ATTR_PAGE_SCALE:
+ case ATTR_PAGE_SCALETOPAGES:
+ {
+ rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
+ rSet.ClearItem(ATTR_PAGE_SCALE);
+ rSet.ClearItem(ATTR_PAGE_SCALETO);
+ sal_Int16 nVal = 0;
+ *pValue >>= nVal;
+ rSet.Put( SfxUInt16Item( pEntry->nWID, nVal ) );
+ }
+ break;
+ case ATTR_PAGE_FIRSTPAGENO:
+ {
+ sal_Int16 nVal = 0;
+ *pValue >>= nVal;
+ rSet.Put( SfxUInt16Item( ATTR_PAGE_FIRSTPAGENO, nVal ) );
+ }
+ break;
+ case ATTR_PAGE_CHARTS:
+ case ATTR_PAGE_OBJECTS:
+ case ATTR_PAGE_DRAWINGS:
+ {
+ sal_Bool bBool = sal_False;
+ *pValue >>= bBool;
+ //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
+ rSet.Put( ScViewObjectModeItem( pEntry->nWID,
+ bBool ? VOBJ_MODE_SHOW : VOBJ_MODE_HIDE ) );
+ }
+ break;
+ case ATTR_PAGE_PAPERBIN:
+ {
+ BYTE nTray = PAPERBIN_PRINTER_SETTINGS;
+ BOOL bFound = FALSE;
+
+ rtl::OUString aName;
+ if ( *pValue >>= aName )
+ {
+ if ( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( SC_PAPERBIN_DEFAULTNAME ) ) )
+ bFound = TRUE;
+ else
+ {
+ Printer* pPrinter = pDocShell->GetPrinter();
+ if (pPrinter)
+ {
+ String aNameStr = aName;
+ USHORT nCount = pPrinter->GetPaperBinCount();
+ for (USHORT i=0; i<nCount; i++)
+ if ( aNameStr == pPrinter->GetPaperBinName(i) )
+ {
+ nTray = (BYTE) i;
+ bFound = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ if ( bFound )
+ rSet.Put( SvxPaperBinItem( ATTR_PAGE_PAPERBIN, nTray ) );
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case ATTR_PAGE_SCALETO:
+ {
+ sal_Int16 nPages = 0;
+ if (*pValue >>= nPages)
+ {
+ ScPageScaleToItem aItem = ((const ScPageScaleToItem&)rSet.Get(ATTR_PAGE_SCALETO));
+ if ( rPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX)))
+ aItem.SetWidth(static_cast<sal_uInt16>(nPages));
+ else
+ aItem.SetHeight(static_cast<sal_uInt16>(nPages));
+ rSet.Put( aItem );
+ rSet.ClearItem(ATTR_PAGE_SCALETOPAGES);
+ rSet.ClearItem(ATTR_PAGE_SCALE);
+ }
+ }
+ break;
+ default:
+ // #65253# Default-Items mit falscher Slot-ID
+ // funktionieren im SfxItemPropertySet3 nicht
+ //! Slot-IDs aendern...
+ if ( rSet.GetPool()->GetSlotId(pEntry->nWID) == pEntry->nWID &&
+ rSet.GetItemState(pEntry->nWID, sal_False) == SFX_ITEM_DEFAULT )
+ {
+ rSet.Put( rSet.Get(pEntry->nWID) );
+ }
+ pPropSet->setPropertyValue( *pEntry, *pValue, rSet );
+ }
+ }
+ else
+ {
+ rSet.ClearItem( pEntry->nWID );
+ // #67847# language for number formats
+ if ( pEntry->nWID == ATTR_VALUE_FORMAT )
+ rSet.ClearItem( ATTR_LANGUAGE_FORMAT );
+
+ //! for ATTR_ROTATE_VALUE, also reset ATTR_ORIENTATION?
+ }
+ }
+ else if ( IsScUnoWid( pEntry->nWID ) )
+ {
+ switch ( pEntry->nWID )
+ {
+ case SC_WID_UNO_TBLBORD:
+ {
+ if (pValue)
+ {
+ table::TableBorder aBorder;
+ if ( *pValue >>= aBorder )
+ {
+ SvxBoxItem aOuter( ATTR_BORDER );
+ SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
+ ScHelperFunctions::FillBoxItems( aOuter, aInner, aBorder );
+ rSet.Put( aOuter );
+ }
+ }
+ else
+ {
+ rSet.ClearItem( ATTR_BORDER );
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ //! DocFunc-Funktion??
+ //! Undo ?????????????
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ if ( eFamily == SFX_STYLE_FAMILY_PARA )
+ {
+ // Zeilenhoehen anpassen...
+
+ VirtualDevice aVDev;
+ Point aLogic = aVDev.LogicToPixel( Point(1000,1000), MAP_TWIP );
+ double nPPTX = aLogic.X() / 1000.0;
+ double nPPTY = aLogic.Y() / 1000.0;
+ Fraction aZoom(1,1);
+ pDoc->StyleSheetChanged( pStyle, sal_False, &aVDev, nPPTX, nPPTY, aZoom, aZoom );
+
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+ pDocShell->SetDocumentModified();
+ }
+ else
+ {
+ //! ModifyStyleSheet am Dokument (alte Werte merken)
+
+ pDocShell->PageStyleModified( aStyleName, sal_True );
+ }
+ }
+}
+
+uno::Any SAL_CALL ScStyleObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aAny;
+
+ if ( aPropertyName.equalsAscii( SC_UNONAME_DISPNAME ) ) // read-only
+ {
+ // core always has the display name
+ SfxStyleSheetBase* pStyle = GetStyle_Impl();
+ if (pStyle)
+ aAny <<= rtl::OUString( pStyle->GetName() );
+ }
+ else
+ {
+ const SfxItemPropertySimpleEntry* pResultEntry = NULL;
+ const SfxItemSet* pItemSet = GetStyleItemSet_Impl( aPropertyName, pResultEntry );
+
+ if ( pItemSet && pResultEntry )
+ {
+ USHORT nWhich = pResultEntry->nWID;
+
+ if ( IsScItemWid( nWhich ) )
+ {
+ switch ( nWhich ) // fuer Item-Spezial-Behandlungen
+ {
+ case ATTR_VALUE_FORMAT:
+ if ( pDocShell )
+ {
+ UINT32 nOldFormat = ((const SfxUInt32Item&)
+ pItemSet->Get( ATTR_VALUE_FORMAT )).GetValue();
+ LanguageType eOldLang = ((const SvxLanguageItem&)
+ pItemSet->Get( ATTR_LANGUAGE_FORMAT )).GetLanguage();
+ nOldFormat = pDocShell->GetDocument()->GetFormatTable()->
+ GetFormatForLanguageIfBuiltIn( nOldFormat, eOldLang );
+ aAny <<= nOldFormat;
+ }
+ break;
+ case ATTR_INDENT:
+ aAny <<= sal_Int16( TwipsToHMM(((const SfxUInt16Item&)
+ pItemSet->Get(nWhich)).GetValue()) );
+ break;
+ case ATTR_STACKED:
+ {
+ sal_Int32 nRot = ((const SfxInt32Item&)pItemSet->Get(ATTR_ROTATE_VALUE)).GetValue();
+ BOOL bStacked = ((const SfxBoolItem&)pItemSet->Get(nWhich)).GetValue();
+ SvxOrientationItem( nRot, bStacked, 0 ).QueryValue( aAny );
+ }
+ break;
+ case ATTR_PAGE_SCALE:
+ case ATTR_PAGE_SCALETOPAGES:
+ case ATTR_PAGE_FIRSTPAGENO:
+ aAny <<= sal_Int16( ((const SfxUInt16Item&)pItemSet->Get(nWhich)).GetValue() );
+ break;
+ case ATTR_PAGE_CHARTS:
+ case ATTR_PAGE_OBJECTS:
+ case ATTR_PAGE_DRAWINGS:
+ //! sal_Bool-MID fuer ScViewObjectModeItem definieren?
+ aAny <<= sal_Bool( ((const ScViewObjectModeItem&)pItemSet->
+ Get(nWhich)).GetValue() == VOBJ_MODE_SHOW );
+ break;
+ case ATTR_PAGE_PAPERBIN:
+ {
+ // property PrinterPaperTray is the name of the tray
+
+ BYTE nValue = ((const SvxPaperBinItem&)pItemSet->Get(nWhich)).GetValue();
+ rtl::OUString aName;
+ if ( nValue == PAPERBIN_PRINTER_SETTINGS )
+ aName = rtl::OUString::createFromAscii( SC_PAPERBIN_DEFAULTNAME );
+ else
+ {
+ Printer* pPrinter = pDocShell->GetPrinter();
+ if (pPrinter)
+ aName = pPrinter->GetPaperBinName( nValue );
+ }
+ aAny <<= aName;
+ }
+ break;
+ case ATTR_PAGE_SCALETO:
+ {
+ ScPageScaleToItem aItem((const ScPageScaleToItem&)pItemSet->Get(ATTR_PAGE_SCALETO));
+ if (aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SC_UNO_PAGE_SCALETOX)))
+ aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetWidth()));
+ else
+ aAny = uno::makeAny(static_cast<sal_Int16>(aItem.GetHeight()));
+ }
+ break;
+ default:
+ // #65253# Default-Items mit falscher Slot-ID
+ // funktionieren im SfxItemPropertySet3 nicht
+ //! Slot-IDs aendern...
+ if ( pItemSet->GetPool()->GetSlotId(nWhich) == nWhich &&
+ pItemSet->GetItemState(nWhich, sal_False) == SFX_ITEM_DEFAULT )
+ {
+ SfxItemSet aNoEmptySet( *pItemSet );
+ aNoEmptySet.Put( aNoEmptySet.Get( nWhich ) );
+ pPropSet->getPropertyValue( *pResultEntry, aNoEmptySet, aAny );
+ }
+ else
+ pPropSet->getPropertyValue( *pResultEntry, *pItemSet, aAny );
+ }
+ }
+ else if ( IsScUnoWid( nWhich ) )
+ {
+ switch ( nWhich )
+ {
+ case SC_WID_UNO_TBLBORD:
+ {
+ const SfxPoolItem* pItem = &pItemSet->Get( ATTR_BORDER );
+ if ( pItem )
+ {
+ SvxBoxItem aOuter( *( static_cast<const SvxBoxItem*>( pItem ) ) );
+ SvxBoxInfoItem aInner( ATTR_BORDER_INNER );
+ table::TableBorder aBorder;
+ ScHelperFunctions::FillTableBorder( aBorder, aOuter, aInner );
+ aBorder.IsHorizontalLineValid = sal_False;
+ aBorder.IsVerticalLineValid = sal_False;
+ aBorder.IsDistanceValid = sal_False;
+ aAny <<= aBorder;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ return aAny;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScStyleObj )
+
+// lang::XServiceInfo
+
+rtl::OUString SAL_CALL ScStyleObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScStyleObj" );
+}
+
+sal_Bool SAL_CALL ScStyleObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ BOOL bPage = ( eFamily == SFX_STYLE_FAMILY_PAGE );
+ return rServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SCSTYLE_SERVICE ) )||
+ rServiceName.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM ( bPage ? SCPAGESTYLE_SERVICE : SCCELLSTYLE_SERVICE ));
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScStyleObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ BOOL bPage = ( eFamily == SFX_STYLE_FAMILY_PAGE );
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCSTYLE_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( bPage ? SCPAGESTYLE_SERVICE
+ : SCCELLSTYLE_SERVICE );
+ return aRet;
+}
+
+//------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/targuno.cxx b/sc/source/ui/unoobj/targuno.cxx
new file mode 100644
index 000000000000..41da7ccc3b4b
--- /dev/null
+++ b/sc/source/ui/unoobj/targuno.cxx
@@ -0,0 +1,317 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <vcl/image.hxx>
+#include <vcl/virdev.hxx>
+#include <toolkit/unohlp.hxx>
+#include <svl/itemprop.hxx>
+#include <svl/smplhint.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/settings.hxx>
+#include <com/sun/star/awt/XBitmap.hpp>
+
+#include "targuno.hxx"
+#include "miscuno.hxx"
+#include "docuno.hxx"
+#include "datauno.hxx"
+#include "nameuno.hxx"
+#include "docsh.hxx"
+#include "content.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "unonames.hxx"
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------
+
+sal_uInt16 nTypeResIds[SC_LINKTARGETTYPE_COUNT] =
+{
+ SCSTR_CONTENT_TABLE, // SC_LINKTARGETTYPE_SHEET
+ SCSTR_CONTENT_RANGENAME, // SC_LINKTARGETTYPE_RANGENAME
+ SCSTR_CONTENT_DBAREA // SC_LINKTARGETTYPE_DBAREA
+};
+
+const SfxItemPropertyMapEntry* lcl_GetLinkTargetMap()
+{
+ static SfxItemPropertyMapEntry aLinkTargetMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPBIT), 0, &getCppuType((const uno::Reference<awt::XBitmap>*)0), beans::PropertyAttribute::READONLY, 0 },
+ {MAP_CHAR_LEN(SC_UNO_LINKDISPNAME), 0, &getCppuType((const ::rtl::OUString*)0), beans::PropertyAttribute::READONLY, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aLinkTargetMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+// service for ScLinkTargetTypeObj is not defined
+// must not support document::LinkTarget because the target type cannot be used as a target
+
+SC_SIMPLE_SERVICE_INFO( ScLinkTargetTypesObj, "ScLinkTargetTypesObj", "com.sun.star.document.LinkTargets" )
+SC_SIMPLE_SERVICE_INFO( ScLinkTargetTypeObj, "ScLinkTargetTypeObj", "com.sun.star.document.LinkTargetSupplier" )
+SC_SIMPLE_SERVICE_INFO( ScLinkTargetsObj, "ScLinkTargetsObj", "com.sun.star.document.LinkTargets" )
+
+//------------------------------------------------------------------------
+
+ScLinkTargetTypesObj::ScLinkTargetTypesObj(ScDocShell* pDocSh) :
+ pDocShell( pDocSh )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+
+ for (sal_uInt16 i=0; i<SC_LINKTARGETTYPE_COUNT; i++)
+ aNames[i] = String( ScResId( nTypeResIds[i] ) );
+}
+
+ScLinkTargetTypesObj::~ScLinkTargetTypesObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScLinkTargetTypesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // document gone
+}
+
+// container::XNameAccess
+
+uno::Any SAL_CALL ScLinkTargetTypesObj::getByName(const rtl::OUString& aName)
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ if (pDocShell)
+ {
+ String aNameStr(aName);
+ for (sal_uInt16 i=0; i<SC_LINKTARGETTYPE_COUNT; i++)
+ if ( aNames[i] == aNameStr )
+ return uno::makeAny(uno::Reference< beans::XPropertySet >(new ScLinkTargetTypeObj( pDocShell, i )));
+ }
+
+ throw container::NoSuchElementException();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScLinkTargetTypesObj::getElementNames(void) throw( uno::RuntimeException )
+{
+ uno::Sequence<rtl::OUString> aRet(SC_LINKTARGETTYPE_COUNT);
+ rtl::OUString* pArray = aRet.getArray();
+ for (sal_uInt16 i=0; i<SC_LINKTARGETTYPE_COUNT; i++)
+ pArray[i] = aNames[i];
+ return aRet;
+}
+
+sal_Bool SAL_CALL ScLinkTargetTypesObj::hasByName(const rtl::OUString& aName) throw( uno::RuntimeException )
+{
+ String aNameStr = aName;
+ for (sal_uInt16 i=0; i<SC_LINKTARGETTYPE_COUNT; i++)
+ if ( aNames[i] == aNameStr )
+ return sal_True;
+ return sal_False;
+}
+
+// container::XElementAccess
+
+uno::Type SAL_CALL ScLinkTargetTypesObj::getElementType(void) throw( uno::RuntimeException )
+{
+ return ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+}
+
+sal_Bool SAL_CALL ScLinkTargetTypesObj::hasElements(void) throw( uno::RuntimeException )
+{
+ return sal_True;
+}
+
+//------------------------------------------------------------------------
+
+ScLinkTargetTypeObj::ScLinkTargetTypeObj(ScDocShell* pDocSh, sal_uInt16 nT) :
+ pDocShell( pDocSh ),
+ nType( nT )
+{
+ pDocShell->GetDocument()->AddUnoObject(*this);
+ aName = String( ScResId( nTypeResIds[nType] ) ); //! on demand?
+}
+
+ScLinkTargetTypeObj::~ScLinkTargetTypeObj()
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScLinkTargetTypeObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pDocShell = NULL; // document gone
+}
+
+// document::XLinkTargetSupplier
+
+uno::Reference< container::XNameAccess > SAL_CALL ScLinkTargetTypeObj::getLinks(void) throw( uno::RuntimeException )
+{
+ uno::Reference< container::XNameAccess > xCollection;
+
+ if ( pDocShell )
+ {
+ switch ( nType )
+ {
+ case SC_LINKTARGETTYPE_SHEET:
+ xCollection.set(new ScTableSheetsObj(pDocShell));
+ break;
+ case SC_LINKTARGETTYPE_RANGENAME:
+ xCollection.set(new ScNamedRangesObj(pDocShell));
+ break;
+ case SC_LINKTARGETTYPE_DBAREA:
+ xCollection.set(new ScDatabaseRangesObj(pDocShell));
+ break;
+ default:
+ DBG_ERROR("invalid type");
+ }
+ }
+
+ // wrap collection in ScLinkTargetsObj because service document::LinkTargets requires
+ // beans::XPropertySet as ElementType in container::XNameAccess.
+ if ( xCollection.is() )
+ return new ScLinkTargetsObj( xCollection );
+ return NULL;
+}
+
+// beans::XPropertySet
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL ScLinkTargetTypeObj::getPropertySetInfo(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( lcl_GetLinkTargetMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScLinkTargetTypeObj::setPropertyValue(const rtl::OUString& /* aPropertyName */,
+ const uno::Any& /* aValue */)
+ throw( beans::UnknownPropertyException,
+ beans::PropertyVetoException,
+ lang::IllegalArgumentException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ // everything is read-only
+ //! exception?
+}
+
+// static
+void ScLinkTargetTypeObj::SetLinkTargetBitmap( uno::Any& rRet, sal_uInt16 nType )
+{
+ sal_uInt16 nImgId = 0;
+ switch ( nType )
+ {
+ case SC_LINKTARGETTYPE_SHEET:
+ nImgId = SC_CONTENT_TABLE;
+ break;
+ case SC_LINKTARGETTYPE_RANGENAME:
+ nImgId = SC_CONTENT_RANGENAME;
+ break;
+ case SC_LINKTARGETTYPE_DBAREA:
+ nImgId = SC_CONTENT_DBAREA;
+ break;
+ }
+ if (nImgId)
+ {
+ BOOL bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+ ImageList aEntryImages( ScResId( bHighContrast ? RID_IMAGELIST_H_NAVCONT : RID_IMAGELIST_NAVCONT ) );
+ const Image& rImage = aEntryImages.GetImage( nImgId );
+ rRet <<= uno::Reference< awt::XBitmap > (VCLUnoHelper::CreateBitmap( rImage.GetBitmapEx() ));
+ }
+}
+
+uno::Any SAL_CALL ScLinkTargetTypeObj::getPropertyValue(const rtl::OUString& PropertyName)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ uno::Any aRet;
+ String aNameStr(PropertyName);
+ if ( aNameStr.EqualsAscii( SC_UNO_LINKDISPBIT ) )
+ SetLinkTargetBitmap( aRet, nType );
+ else if ( aNameStr.EqualsAscii( SC_UNO_LINKDISPNAME ) )
+ aRet <<= rtl::OUString( aName );
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScLinkTargetTypeObj )
+
+//------------------------------------------------------------------------
+
+ScLinkTargetsObj::ScLinkTargetsObj( const uno::Reference< container::XNameAccess > & rColl ) :
+ xCollection( rColl )
+{
+ DBG_ASSERT( xCollection.is(), "ScLinkTargetsObj: NULL" );
+}
+
+ScLinkTargetsObj::~ScLinkTargetsObj()
+{
+}
+
+// container::XNameAccess
+
+uno::Any SAL_CALL ScLinkTargetsObj::getByName(const rtl::OUString& aName)
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ uno::Reference< beans::XPropertySet > xProp( ScUnoHelpFunctions::AnyToInterface( xCollection->getByName(aName) ), uno::UNO_QUERY );
+ if (xProp.is())
+ return uno::makeAny(xProp);
+
+ throw container::NoSuchElementException();
+// return uno::Any();
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScLinkTargetsObj::getElementNames(void) throw( uno::RuntimeException )
+{
+ return xCollection->getElementNames();
+}
+
+sal_Bool SAL_CALL ScLinkTargetsObj::hasByName(const rtl::OUString& aName) throw( uno::RuntimeException )
+{
+ return xCollection->hasByName(aName);
+}
+
+// container::XElementAccess
+
+uno::Type SAL_CALL ScLinkTargetsObj::getElementType(void) throw( uno::RuntimeException )
+{
+ return ::getCppuType((const uno::Reference< beans::XPropertySet >*)0);
+}
+
+sal_Bool SAL_CALL ScLinkTargetsObj::hasElements(void) throw( uno::RuntimeException )
+{
+ return xCollection->hasElements();
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
new file mode 100644
index 000000000000..0de4ab2b976f
--- /dev/null
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -0,0 +1,1147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+#include <svx/svdpool.hxx>
+#include <svx/svdobj.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/unomid.hxx>
+#include <editeng/unoprnms.hxx>
+#include <editeng/unofored.hxx>
+#include <rtl/uuid.h>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/awt/FontSlant.hpp>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <editeng/unoipset.hxx>
+#include "textuno.hxx"
+#include "fielduno.hxx"
+#include "servuno.hxx"
+#include "editsrc.hxx"
+#include "docsh.hxx"
+#include "editutil.hxx"
+#include "miscuno.hxx"
+#include "cellsuno.hxx"
+#include "hints.hxx"
+#include "patattr.hxx"
+#include "cell.hxx"
+#include "docfunc.hxx"
+#include "scmod.hxx"
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+const SvxItemPropertySet * lcl_GetHdFtPropertySet()
+{
+ static SfxItemPropertyMapEntry aHdFtPropertyMap_Impl[] =
+ {
+ SVX_UNOEDIT_CHAR_PROPERTIES,
+ SVX_UNOEDIT_FONT_PROPERTIES,
+ SVX_UNOEDIT_PARA_PROPERTIES,
+ SVX_UNOEDIT_NUMBERING_PROPERTIE, // for completeness of service ParagraphProperties
+ {0,0,0,0,0,0}
+ };
+ static BOOL bTwipsSet = FALSE;
+
+ if (!bTwipsSet)
+ {
+ // modify PropertyMap to include CONVERT_TWIPS flag for font height
+ // (headers/footers are in twips)
+
+ SfxItemPropertyMapEntry* pEntry = aHdFtPropertyMap_Impl;
+ while (pEntry->pName)
+ {
+ if ( ( pEntry->nWID == EE_CHAR_FONTHEIGHT ||
+ pEntry->nWID == EE_CHAR_FONTHEIGHT_CJK ||
+ pEntry->nWID == EE_CHAR_FONTHEIGHT_CTL ) &&
+ pEntry->nMemberId == MID_FONTHEIGHT )
+ {
+ pEntry->nMemberId |= CONVERT_TWIPS;
+ }
+
+ ++pEntry;
+ }
+ bTwipsSet = TRUE;
+ }
+ static SvxItemPropertySet aHdFtPropertySet_Impl( aHdFtPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
+ return &aHdFtPropertySet_Impl;
+}
+
+//------------------------------------------------------------------------
+
+SC_SIMPLE_SERVICE_INFO( ScHeaderFooterContentObj, "ScHeaderFooterContentObj", "com.sun.star.sheet.HeaderFooterContent" )
+SC_SIMPLE_SERVICE_INFO( ScHeaderFooterTextObj, "ScHeaderFooterTextObj", "stardiv.one.Text.Text" )
+
+//------------------------------------------------------------------------
+
+ScHeaderFooterContentObj::ScHeaderFooterContentObj( const EditTextObject* pLeft,
+ const EditTextObject* pCenter,
+ const EditTextObject* pRight ) :
+ pLeftText ( NULL ),
+ pCenterText ( NULL ),
+ pRightText ( NULL )
+{
+ if ( pLeft )
+ pLeftText = pLeft->Clone();
+ if ( pCenter )
+ pCenterText = pCenter->Clone();
+ if ( pRight )
+ pRightText = pRight->Clone();
+}
+
+ScHeaderFooterContentObj::~ScHeaderFooterContentObj()
+{
+ delete pLeftText;
+ delete pCenterText;
+ delete pRightText;
+}
+
+void ScHeaderFooterContentObj::AddListener( SfxListener& rListener )
+{
+ rListener.StartListening( aBC );
+}
+
+void ScHeaderFooterContentObj::RemoveListener( SfxListener& rListener )
+{
+ rListener.EndListening( aBC );
+}
+
+void ScHeaderFooterContentObj::UpdateText( USHORT nPart, EditEngine& rSource )
+{
+ EditTextObject* pNew = rSource.CreateTextObject();
+ switch (nPart)
+ {
+ case SC_HDFT_LEFT:
+ delete pLeftText;
+ pLeftText = pNew;
+ break;
+ case SC_HDFT_CENTER:
+ delete pCenterText;
+ pCenterText = pNew;
+ break;
+ default: // SC_HDFT_RIGHT
+ delete pRightText;
+ pRightText = pNew;
+ break;
+ }
+
+ aBC.Broadcast( ScHeaderFooterChangedHint( nPart ) );
+}
+
+// XHeaderFooterContent
+
+uno::Reference<text::XText> SAL_CALL ScHeaderFooterContentObj::getLeftText()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScHeaderFooterTextObj( *this, SC_HDFT_LEFT );
+}
+
+uno::Reference<text::XText> SAL_CALL ScHeaderFooterContentObj::getCenterText()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScHeaderFooterTextObj( *this, SC_HDFT_CENTER );
+}
+
+uno::Reference<text::XText> SAL_CALL ScHeaderFooterContentObj::getRightText()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScHeaderFooterTextObj( *this, SC_HDFT_RIGHT );
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScHeaderFooterContentObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScHeaderFooterContentObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScHeaderFooterContentObj* ScHeaderFooterContentObj::getImplementation(
+ const uno::Reference<sheet::XHeaderFooterContent> xObj )
+{
+ ScHeaderFooterContentObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScHeaderFooterContentObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+
+//------------------------------------------------------------------------
+
+ScHeaderFooterTextData::ScHeaderFooterTextData( ScHeaderFooterContentObj& rContent,
+ USHORT nP ) :
+ rContentObj( rContent ),
+ nPart( nP ),
+ pEditEngine( NULL ),
+ pForwarder( NULL ),
+ bDataValid( FALSE ),
+ bInUpdate( FALSE )
+{
+ rContentObj.acquire(); // must not go away
+ rContentObj.AddListener( *this );
+}
+
+ScHeaderFooterTextData::~ScHeaderFooterTextData()
+{
+ SolarMutexGuard aGuard; // needed for EditEngine dtor
+
+ rContentObj.RemoveListener( *this );
+
+ delete pForwarder;
+ delete pEditEngine;
+
+ rContentObj.release();
+}
+
+void ScHeaderFooterTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScHeaderFooterChangedHint ) )
+ {
+ if ( ((const ScHeaderFooterChangedHint&)rHint).GetPart() == nPart )
+ {
+ if (!bInUpdate) // not for own updates
+ bDataValid = FALSE; // text has to be fetched again
+ }
+ }
+}
+
+SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder()
+{
+ if (!pEditEngine)
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ ScHeaderEditEngine* pHdrEngine = new ScHeaderEditEngine( pEnginePool, TRUE );
+
+ pHdrEngine->EnableUndo( FALSE );
+ pHdrEngine->SetRefMapMode( MAP_TWIP );
+
+ // default font must be set, independently of document
+ // -> use global pool from module
+
+ SfxItemSet aDefaults( pHdrEngine->GetEmptyItemSet() );
+ const ScPatternAttr& rPattern = (const ScPatternAttr&)SC_MOD()->GetPool().GetDefaultItem(ATTR_PATTERN);
+ rPattern.FillEditItemSet( &aDefaults );
+ // FillEditItemSet adjusts font height to 1/100th mm,
+ // but for header/footer twips is needed, as in the PatternAttr:
+ aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
+ aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
+ aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+ pHdrEngine->SetDefaults( aDefaults );
+
+ ScHeaderFieldData aData;
+ ScHeaderFooterTextObj::FillDummyFieldData( aData );
+ pHdrEngine->SetData( aData );
+
+ pEditEngine = pHdrEngine;
+ pForwarder = new SvxEditEngineForwarder(*pEditEngine);
+ }
+
+ if (bDataValid)
+ return pForwarder;
+
+ const EditTextObject* pData;
+ if (nPart == SC_HDFT_LEFT)
+ pData = rContentObj.GetLeftEditObject();
+ else if (nPart == SC_HDFT_CENTER)
+ pData = rContentObj.GetCenterEditObject();
+ else
+ pData = rContentObj.GetRightEditObject();
+
+ if (pData)
+ pEditEngine->SetText(*pData);
+
+ bDataValid = TRUE;
+ return pForwarder;
+}
+
+void ScHeaderFooterTextData::UpdateData()
+{
+ if ( pEditEngine )
+ {
+ bInUpdate = TRUE; // don't reset bDataValid during UpdateText
+
+ rContentObj.UpdateText( nPart, *pEditEngine );
+
+ bInUpdate = FALSE;
+ }
+}
+
+//------------------------------------------------------------------------
+
+ScHeaderFooterTextObj::ScHeaderFooterTextObj( ScHeaderFooterContentObj& rContent,
+ USHORT nP ) :
+ aTextData( rContent, nP ),
+ pUnoText( NULL )
+{
+ // ScHeaderFooterTextData acquires rContent
+ // pUnoText is created on demand (getString/setString work without it)
+}
+
+void ScHeaderFooterTextObj::CreateUnoText_Impl()
+{
+ if ( !pUnoText )
+ {
+ // can't be aggregated because getString/setString is handled here
+ ScSharedHeaderFooterEditSource aEditSource( &aTextData );
+ pUnoText = new SvxUnoText( &aEditSource, lcl_GetHdFtPropertySet(), uno::Reference<text::XText>() );
+ pUnoText->acquire();
+ }
+}
+
+ScHeaderFooterTextObj::~ScHeaderFooterTextObj()
+{
+ if (pUnoText)
+ pUnoText->release();
+}
+
+const SvxUnoText& ScHeaderFooterTextObj::GetUnoText()
+{
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return *pUnoText;
+}
+
+// XText
+
+uno::Reference<text::XTextCursor> SAL_CALL ScHeaderFooterTextObj::createTextCursor()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScHeaderFooterTextCursor( *this );
+}
+
+uno::Reference<text::XTextCursor> SAL_CALL ScHeaderFooterTextObj::createTextCursorByRange(
+ const uno::Reference<text::XTextRange>& aTextPosition )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->createTextCursorByRange(aTextPosition);
+ //! wie ScCellObj::createTextCursorByRange, wenn SvxUnoTextRange_getReflection verfuegbar
+}
+
+void ScHeaderFooterTextObj::FillDummyFieldData( ScHeaderFieldData& rData ) // static
+{
+ String aDummy(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "???" )));
+ rData.aTitle = aDummy;
+ rData.aLongDocName = aDummy;
+ rData.aShortDocName = aDummy;
+ rData.aTabName = aDummy;
+ rData.nPageNo = 1;
+ rData.nTotalPages = 99;
+}
+
+rtl::OUString SAL_CALL ScHeaderFooterTextObj::getString() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+ const EditTextObject* pData;
+
+ USHORT nPart = aTextData.GetPart();
+ ScHeaderFooterContentObj& rContentObj = aTextData.GetContentObj();
+
+ if (nPart == SC_HDFT_LEFT)
+ pData = rContentObj.GetLeftEditObject();
+ else if (nPart == SC_HDFT_CENTER)
+ pData = rContentObj.GetCenterEditObject();
+ else
+ pData = rContentObj.GetRightEditObject();
+ if (pData)
+ {
+ // for pure text, no font info is needed in pool defaults
+ ScHeaderEditEngine aEditEngine( EditEngine::CreatePool(), TRUE );
+
+ ScHeaderFieldData aData;
+ FillDummyFieldData( aData );
+ aEditEngine.SetData( aData );
+
+ aEditEngine.SetText(*pData);
+ aRet = ScEditUtil::GetSpaceDelimitedString( aEditEngine );
+ }
+ return aRet;
+}
+
+void SAL_CALL ScHeaderFooterTextObj::setString( const rtl::OUString& aText ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aText);
+
+ // for pure text, no font info is needed in pool defaults
+ ScHeaderEditEngine aEditEngine( EditEngine::CreatePool(), TRUE );
+ aEditEngine.SetText( aString );
+
+ aTextData.GetContentObj().UpdateText( aTextData.GetPart(), aEditEngine );
+}
+
+void SAL_CALL ScHeaderFooterTextObj::insertString( const uno::Reference<text::XTextRange>& xRange,
+ const rtl::OUString& aString, sal_Bool bAbsorb )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ pUnoText->insertString( xRange, aString, bAbsorb );
+}
+
+void SAL_CALL ScHeaderFooterTextObj::insertControlCharacter(
+ const uno::Reference<text::XTextRange>& xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ pUnoText->insertControlCharacter( xRange, nControlCharacter, bAbsorb );
+}
+
+void SAL_CALL ScHeaderFooterTextObj::insertTextContent(
+ const uno::Reference<text::XTextRange >& xRange,
+ const uno::Reference<text::XTextContent >& xContent,
+ sal_Bool bAbsorb )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( xContent.is() && xRange.is() )
+ {
+ ScHeaderFieldObj* pHeaderField = ScHeaderFieldObj::getImplementation( xContent );
+
+ SvxUnoTextRangeBase* pTextRange =
+ ScHeaderFooterTextCursor::getImplementation( xRange );
+
+ if ( pHeaderField && !pHeaderField->IsInserted() && pTextRange )
+ {
+ SvxEditSource* pEditSource = pTextRange->GetEditSource();
+ ESelection aSelection(pTextRange->GetSelection());
+
+ if (!bAbsorb)
+ {
+ // don't replace -> append at end
+ aSelection.Adjust();
+ aSelection.nStartPara = aSelection.nEndPara;
+ aSelection.nStartPos = aSelection.nEndPos;
+ }
+
+ SvxFieldItem aItem(pHeaderField->CreateFieldItem());
+
+ SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder();
+ pForwarder->QuickInsertField( aItem, aSelection );
+ pEditSource->UpdateData();
+
+ // neue Selektion: ein Zeichen
+ aSelection.Adjust();
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos + 1;
+ pHeaderField->InitDoc( &aTextData.GetContentObj(), aTextData.GetPart(), aSelection );
+
+ // #91431# for bAbsorb=FALSE, the new selection must be behind the inserted content
+ // (the xml filter relies on this)
+ if (!bAbsorb)
+ aSelection.nStartPos = aSelection.nEndPos;
+
+ pTextRange->SetSelection( aSelection );
+
+ return;
+ }
+ }
+
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ pUnoText->insertTextContent( xRange, xContent, bAbsorb );
+}
+
+void SAL_CALL ScHeaderFooterTextObj::removeTextContent(
+ const uno::Reference<text::XTextContent>& xContent )
+ throw(container::NoSuchElementException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( xContent.is() )
+ {
+ ScHeaderFieldObj* pHeaderField = ScHeaderFieldObj::getImplementation( xContent );
+ if ( pHeaderField && pHeaderField->IsInserted() )
+ {
+ //! Testen, ob das Feld in dieser Zelle ist
+ pHeaderField->DeleteField();
+ return;
+ }
+ }
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ pUnoText->removeTextContent( xContent );
+}
+
+uno::Reference<text::XText> SAL_CALL ScHeaderFooterTextObj::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->getText();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextObj::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->getStart();
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextObj::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->getEnd();
+}
+
+// XTextFieldsSupplier
+
+uno::Reference<container::XEnumerationAccess> SAL_CALL ScHeaderFooterTextObj::getTextFields()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // all fields
+ return new ScHeaderFieldsObj( &aTextData.GetContentObj(), aTextData.GetPart(), SC_SERVICE_INVALID );
+}
+
+uno::Reference<container::XNameAccess> SAL_CALL ScHeaderFooterTextObj::getTextFieldMasters()
+ throw(uno::RuntimeException)
+{
+ // sowas gibts nicht im Calc (?)
+ return NULL;
+}
+
+// XTextRangeMover
+
+void SAL_CALL ScHeaderFooterTextObj::moveTextRange(
+ const uno::Reference<text::XTextRange>& xRange,
+ sal_Int16 nParagraphs )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ pUnoText->moveTextRange( xRange, nParagraphs );
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScHeaderFooterTextObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->createEnumeration();
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScHeaderFooterTextObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->getElementType();
+}
+
+sal_Bool SAL_CALL ScHeaderFooterTextObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!pUnoText)
+ CreateUnoText_Impl();
+ return pUnoText->hasElements();
+}
+
+//------------------------------------------------------------------------
+
+ScCellTextCursor::ScCellTextCursor(const ScCellTextCursor& rOther) :
+ SvxUnoTextCursor( rOther ),
+ rTextObj( rOther.rTextObj )
+{
+ rTextObj.acquire();
+}
+
+ScCellTextCursor::ScCellTextCursor(ScCellObj& rText) :
+ SvxUnoTextCursor( rText.GetUnoText() ),
+ rTextObj( rText )
+{
+ rTextObj.acquire();
+}
+
+ScCellTextCursor::~ScCellTextCursor() throw()
+{
+ rTextObj.release();
+}
+
+// SvxUnoTextCursor methods reimplemented here to return the right objects:
+
+uno::Reference<text::XText> SAL_CALL ScCellTextCursor::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return &rTextObj;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScCellTextCursor* pNew = new ScCellTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel(GetSelection());
+ aNewSel.nEndPara = aNewSel.nStartPara;
+ aNewSel.nEndPos = aNewSel.nStartPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScCellTextCursor::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScCellTextCursor* pNew = new ScCellTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel(GetSelection());
+ aNewSel.nStartPara = aNewSel.nEndPara;
+ aNewSel.nStartPos = aNewSel.nEndPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScCellTextCursor::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return SvxUnoTextCursor::getSomething( rId );
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScCellTextCursor::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScCellTextCursor* ScCellTextCursor::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScCellTextCursor* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScCellTextCursor*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(const ScHeaderFooterTextCursor& rOther) :
+ SvxUnoTextCursor( rOther ),
+ rTextObj( rOther.rTextObj )
+{
+ rTextObj.acquire();
+}
+
+ScHeaderFooterTextCursor::ScHeaderFooterTextCursor(ScHeaderFooterTextObj& rText) :
+ SvxUnoTextCursor( rText.GetUnoText() ),
+ rTextObj( rText )
+{
+ rTextObj.acquire();
+}
+
+ScHeaderFooterTextCursor::~ScHeaderFooterTextCursor() throw()
+{
+ rTextObj.release();
+}
+
+// SvxUnoTextCursor methods reimplemented here to return the right objects:
+
+uno::Reference<text::XText> SAL_CALL ScHeaderFooterTextCursor::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return &rTextObj;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel(GetSelection());
+ aNewSel.nEndPara = aNewSel.nStartPara;
+ aNewSel.nEndPos = aNewSel.nStartPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScHeaderFooterTextCursor::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScHeaderFooterTextCursor* pNew = new ScHeaderFooterTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel(GetSelection());
+ aNewSel.nStartPara = aNewSel.nEndPara;
+ aNewSel.nStartPos = aNewSel.nEndPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScHeaderFooterTextCursor::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return SvxUnoTextCursor::getSomething( rId );
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScHeaderFooterTextCursor::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScHeaderFooterTextCursor* ScHeaderFooterTextCursor::getImplementation(
+ const uno::Reference<uno::XInterface> xObj )
+{
+ ScHeaderFooterTextCursor* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScHeaderFooterTextCursor*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScDrawTextCursor::ScDrawTextCursor(const ScDrawTextCursor& rOther) :
+ SvxUnoTextCursor( rOther ),
+ xParentText( rOther.xParentText )
+{
+}
+
+ScDrawTextCursor::ScDrawTextCursor( const uno::Reference<text::XText>& xParent,
+ const SvxUnoTextBase& rText ) :
+ SvxUnoTextCursor( rText ),
+ xParentText( xParent )
+
+{
+}
+
+ScDrawTextCursor::~ScDrawTextCursor() throw()
+{
+}
+
+// SvxUnoTextCursor methods reimplemented here to return the right objects:
+
+uno::Reference<text::XText> SAL_CALL ScDrawTextCursor::getText() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return xParentText;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getStart() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScDrawTextCursor* pNew = new ScDrawTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel(GetSelection());
+ aNewSel.nEndPara = aNewSel.nStartPara;
+ aNewSel.nEndPos = aNewSel.nStartPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+uno::Reference<text::XTextRange> SAL_CALL ScDrawTextCursor::getEnd() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //! use other object for range than cursor?
+
+ ScDrawTextCursor* pNew = new ScDrawTextCursor( *this );
+ uno::Reference<text::XTextRange> xRange( static_cast<SvxUnoTextRangeBase*>(pNew) );
+
+ ESelection aNewSel(GetSelection());
+ aNewSel.nStartPara = aNewSel.nEndPara;
+ aNewSel.nStartPos = aNewSel.nEndPos;
+ pNew->SetSelection( aNewSel );
+
+ return xRange;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScDrawTextCursor::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return SvxUnoTextCursor::getSomething( rId );
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScDrawTextCursor::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScDrawTextCursor* ScDrawTextCursor::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScDrawTextCursor* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScDrawTextCursor*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+//------------------------------------------------------------------------
+
+ScSimpleEditSourceHelper::ScSimpleEditSourceHelper()
+{
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->SetDefaultMetric( SFX_MAPUNIT_100TH_MM );
+ pEnginePool->FreezeIdRanges();
+
+ pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, TRUE ); // TRUE: become owner of pool
+ pForwarder = new SvxEditEngineForwarder( *pEditEngine );
+ pOriginalSource = new ScSimpleEditSource( pForwarder );
+}
+
+ScSimpleEditSourceHelper::~ScSimpleEditSourceHelper()
+{
+ SolarMutexGuard aGuard; // needed for EditEngine dtor
+
+ delete pOriginalSource;
+ delete pForwarder;
+ delete pEditEngine;
+}
+
+ScEditEngineTextObj::ScEditEngineTextObj() :
+ SvxUnoText( GetOriginalSource(), ScCellObj::GetEditPropertySet(), uno::Reference<text::XText>() )
+{
+}
+
+ScEditEngineTextObj::~ScEditEngineTextObj() throw()
+{
+}
+
+void ScEditEngineTextObj::SetText( const EditTextObject& rTextObject )
+{
+ GetEditEngine()->SetText( rTextObject );
+
+ ESelection aSel;
+ ::GetSelection( aSel, GetEditSource()->GetTextForwarder() );
+ SetSelection( aSel );
+}
+
+EditTextObject* ScEditEngineTextObj::CreateTextObject()
+{
+ return GetEditEngine()->CreateTextObject();
+}
+
+//------------------------------------------------------------------------
+
+ScCellTextData::ScCellTextData(ScDocShell* pDocSh, const ScAddress& rP) :
+ pDocShell( pDocSh ),
+ aCellPos( rP ),
+ pEditEngine( NULL ),
+ pForwarder( NULL ),
+ pOriginalSource( NULL ),
+ bDataValid( FALSE ),
+ bInUpdate( FALSE ),
+ bDirty( FALSE ),
+ bDoUpdate( TRUE )
+{
+ if (pDocShell)
+ pDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScCellTextData::~ScCellTextData()
+{
+ SolarMutexGuard aGuard; // needed for EditEngine dtor
+
+ if (pDocShell)
+ {
+ pDocShell->GetDocument()->RemoveUnoObject(*this);
+ pDocShell->GetDocument()->DisposeFieldEditEngine(pEditEngine);
+ }
+ else
+ delete pEditEngine;
+
+ delete pForwarder;
+
+ delete pOriginalSource;
+}
+
+ScSharedCellEditSource* ScCellTextData::GetOriginalSource()
+{
+ if (!pOriginalSource)
+ pOriginalSource = new ScSharedCellEditSource( this );
+ return pOriginalSource;
+}
+
+void ScCellTextData::GetCellText(const ScAddress& rCellPos, String& rText)
+{
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pDoc->GetInputString( rCellPos.Col(), rCellPos.Row(), rCellPos.Tab(), rText );
+ }
+}
+
+SvxTextForwarder* ScCellTextData::GetTextForwarder()
+{
+ if (!pEditEngine)
+ {
+ if ( pDocShell )
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+ pEditEngine = pDoc->CreateFieldEditEngine();
+ }
+ else
+ {
+ SfxItemPool* pEnginePool = EditEngine::CreatePool();
+ pEnginePool->FreezeIdRanges();
+ pEditEngine = new ScFieldEditEngine( pEnginePool, NULL, TRUE );
+ }
+ // currently, GetPortions doesn't work if UpdateMode is FALSE,
+ // this will be fixed (in EditEngine) by src600
+// pEditEngine->SetUpdateMode( FALSE );
+ pEditEngine->EnableUndo( FALSE );
+ if (pDocShell)
+ pEditEngine->SetRefDevice(pDocShell->GetRefDevice());
+ else
+ pEditEngine->SetRefMapMode( MAP_100TH_MM );
+ pForwarder = new SvxEditEngineForwarder(*pEditEngine);
+ }
+
+ if (bDataValid)
+ return pForwarder;
+
+ String aText;
+
+ if (pDocShell)
+ {
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ SfxItemSet aDefaults( pEditEngine->GetEmptyItemSet() );
+ if( const ScPatternAttr* pPattern =
+ pDoc->GetPattern( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab() ) )
+ {
+ pPattern->FillEditItemSet( &aDefaults );
+ pPattern->FillEditParaItems( &aDefaults ); // including alignment etc. (for reading)
+ }
+
+ const ScBaseCell* pCell = pDoc->GetCell( aCellPos );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT )
+ pEditEngine->SetTextNewDefaults( *((const ScEditCell*)pCell)->GetData(), aDefaults );
+ else
+ {
+ GetCellText( aCellPos, aText );
+ if (aText.Len())
+ pEditEngine->SetTextNewDefaults( aText, aDefaults );
+ else
+ pEditEngine->SetDefaults(aDefaults);
+ }
+ }
+
+ bDataValid = TRUE;
+ return pForwarder;
+}
+
+void ScCellTextData::UpdateData()
+{
+ if ( bDoUpdate )
+ {
+ DBG_ASSERT(pEditEngine != NULL, "no EditEngine for UpdateData()");
+ if ( pDocShell && pEditEngine )
+ {
+ // during the own UpdateData call, bDataValid must not be reset,
+ // or things like attributes after the text would be lost
+ // (are not stored in the cell)
+
+ bInUpdate = TRUE; // prevents bDataValid from being reset
+
+ ScDocFunc aFunc(*pDocShell);
+ aFunc.PutData( aCellPos, *pEditEngine, FALSE, TRUE ); // always as text
+
+ bInUpdate = FALSE;
+ bDirty = FALSE;
+ }
+ }
+ else
+ bDirty = TRUE;
+}
+
+void ScCellTextData::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( ScUpdateRefHint ) )
+ {
+// const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
+
+ //! Ref-Update
+ }
+ else if ( rHint.ISA( SfxSimpleHint ) )
+ {
+ ULONG nId = ((const SfxSimpleHint&)rHint).GetId();
+ if ( nId == SFX_HINT_DYING )
+ {
+ pDocShell = NULL; // invalid now
+
+ DELETEZ( pForwarder );
+ DELETEZ( pEditEngine ); // EditEngine uses document's pool
+ }
+ else if ( nId == SFX_HINT_DATACHANGED )
+ {
+ if (!bInUpdate) // not for own UpdateData calls
+ bDataValid = FALSE; // text has to be read from the cell again
+ }
+ }
+}
+
+ScCellTextObj::ScCellTextObj(ScDocShell* pDocSh, const ScAddress& rP) :
+ ScCellTextData( pDocSh, rP ),
+ SvxUnoText( GetOriginalSource(), ScCellObj::GetEditPropertySet(), uno::Reference<text::XText>() )
+{
+}
+
+ScCellTextObj::~ScCellTextObj() throw()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/tokenuno.cxx b/sc/source/ui/unoobj/tokenuno.cxx
new file mode 100644
index 000000000000..9112d18e563c
--- /dev/null
+++ b/sc/source/ui/unoobj/tokenuno.cxx
@@ -0,0 +1,471 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "tokenuno.hxx"
+
+#include <sal/macros.h>
+
+#include <com/sun/star/sheet/ComplexReference.hpp>
+#include <com/sun/star/sheet/ExternalReference.hpp>
+#include <com/sun/star/sheet/ReferenceFlags.hpp>
+#include <com/sun/star/sheet/AddressConvention.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+
+#include <svl/itemprop.hxx>
+#include <vcl/svapp.hxx>
+
+#include "miscuno.hxx"
+#include "convuno.hxx"
+#include "unonames.hxx"
+#include "token.hxx"
+#include "compiler.hxx"
+#include "tokenarray.hxx"
+#include "docsh.hxx"
+#include "rangeseq.hxx"
+#include "externalrefmgr.hxx"
+
+using namespace ::formula;
+using namespace ::com::sun::star;
+
+// ============================================================================
+
+const SfxItemPropertyMapEntry* lcl_GetFormulaParserMap()
+{
+ static SfxItemPropertyMapEntry aFormulaParserMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_COMPILEFAP), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_COMPILEENGLISH), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_IGNORELEADING), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_FORMULACONVENTION), 0, &getCppuType(&sheet::AddressConvention::UNSPECIFIED), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_OPCODEMAP), 0, &getCppuType((uno::Sequence< sheet::FormulaOpCodeMapEntry >*)0), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aFormulaParserMap_Impl;
+}
+
+SC_SIMPLE_SERVICE_INFO( ScFormulaParserObj, "ScFormulaParserObj", SC_SERVICENAME_FORMULAPARS )
+
+// ============================================================================
+
+ScFormulaParserObj::ScFormulaParserObj(ScDocShell* pDocSh) :
+ mpDocShell( pDocSh ),
+ mnConv( sheet::AddressConvention::UNSPECIFIED ),
+ mbEnglish( false ),
+ mbIgnoreSpaces( true ),
+ mbCompileFAP( false )
+{
+ mpDocShell->GetDocument()->AddUnoObject(*this);
+}
+
+ScFormulaParserObj::~ScFormulaParserObj()
+{
+ if (mpDocShell)
+ mpDocShell->GetDocument()->RemoveUnoObject(*this);
+}
+
+void ScFormulaParserObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) && ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ mpDocShell = NULL;
+}
+
+// XFormulaParser
+
+void ScFormulaParserObj::SetCompilerFlags( ScCompiler& rCompiler ) const
+{
+ static const formula::FormulaGrammar::AddressConvention aConvMap[] = {
+ formula::FormulaGrammar::CONV_OOO, // <- AddressConvention::OOO
+ formula::FormulaGrammar::CONV_XL_A1, // <- AddressConvention::XL_A1
+ formula::FormulaGrammar::CONV_XL_R1C1, // <- AddressConvention::XL_R1C1
+ formula::FormulaGrammar::CONV_XL_OOX, // <- AddressConvention::XL_OOX
+ formula::FormulaGrammar::CONV_LOTUS_A1 // <- AddressConvention::LOTUS_A1
+ };
+ static const sal_Int16 nConvMapCount = SAL_N_ELEMENTS(aConvMap);
+
+ // If mxOpCodeMap is not empty it overrides mbEnglish, and vice versa. We
+ // don't need to initialize things twice.
+ if (mxOpCodeMap.get())
+ rCompiler.SetFormulaLanguage( mxOpCodeMap );
+ else
+ {
+ sal_Int32 nFormulaLanguage = mbEnglish ?
+ sheet::FormulaLanguage::ENGLISH :
+ sheet::FormulaLanguage::NATIVE;
+ ScCompiler::OpCodeMapPtr xMap = rCompiler.GetOpCodeMap( nFormulaLanguage);
+ rCompiler.SetFormulaLanguage( xMap);
+ }
+
+ formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_UNSPECIFIED;
+ if (mnConv >= 0 && mnConv < nConvMapCount)
+ eConv = aConvMap[mnConv];
+
+ rCompiler.SetRefConvention( eConv );
+
+ rCompiler.SetCompileForFAP(mbCompileFAP);
+
+ rCompiler.SetExternalLinks( maExternalLinks);
+}
+
+uno::Sequence<sheet::FormulaToken> SAL_CALL ScFormulaParserObj::parseFormula(
+ const rtl::OUString& aFormula, const table::CellAddress& rReferencePos )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Sequence<sheet::FormulaToken> aRet;
+
+ if (mpDocShell)
+ {
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ ScExternalRefManager::ApiGuard aExtRefGuard(pDoc);
+
+ ScAddress aRefPos( ScAddress::UNINITIALIZED );
+ ScUnoConversion::FillScAddress( aRefPos, rReferencePos );
+ ScCompiler aCompiler( pDoc, aRefPos);
+ aCompiler.SetGrammar(pDoc->GetGrammar());
+ SetCompilerFlags( aCompiler );
+
+ ScTokenArray* pCode = aCompiler.CompileString( aFormula );
+ (void)ScTokenConversion::ConvertToTokenSequence( *pDoc, aRet, *pCode );
+ delete pCode;
+ }
+
+ return aRet;
+}
+
+rtl::OUString SAL_CALL ScFormulaParserObj::printFormula(
+ const uno::Sequence<sheet::FormulaToken>& aTokens, const table::CellAddress& rReferencePos )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ rtl::OUString aRet;
+
+ if (mpDocShell)
+ {
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ ScTokenArray aCode;
+ (void)ScTokenConversion::ConvertToTokenArray( *pDoc, aCode, aTokens );
+ ScAddress aRefPos( ScAddress::UNINITIALIZED );
+ ScUnoConversion::FillScAddress( aRefPos, rReferencePos );
+ ScCompiler aCompiler( pDoc, aRefPos, aCode);
+ aCompiler.SetGrammar(pDoc->GetGrammar());
+ SetCompilerFlags( aCompiler );
+
+ rtl::OUStringBuffer aBuffer;
+ aCompiler.CreateStringFromTokenArray( aBuffer );
+ aRet = aBuffer.makeStringAndClear();
+ }
+
+ return aRet;
+}
+
+// XPropertySet
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScFormulaParserObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< beans::XPropertySetInfo > aRef(new SfxItemPropertySetInfo( lcl_GetFormulaParserMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScFormulaParserObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+ if ( aString.EqualsAscii( SC_UNO_COMPILEFAP ) )
+ {
+ aValue >>= mbCompileFAP;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_COMPILEENGLISH ) )
+ {
+ bool bOldEnglish = mbEnglish;
+ if (aValue >>= mbEnglish)
+ {
+ // Need to recreate the symbol map to change English property
+ // because the map is const. So for performance reasons set
+ // CompileEnglish _before_ OpCodeMap!
+ if (mxOpCodeMap.get() && mbEnglish != bOldEnglish)
+ {
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ ScCompiler aCompiler( pDoc, ScAddress());
+ aCompiler.SetGrammar(pDoc->GetGrammar());
+ mxOpCodeMap = aCompiler.CreateOpCodeMap( maOpCodeMapping, mbEnglish);
+ }
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+ else if ( aString.EqualsAscii( SC_UNO_FORMULACONVENTION ) )
+ {
+ aValue >>= mnConv;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_IGNORELEADING ) )
+ {
+ aValue >>= mbIgnoreSpaces;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_OPCODEMAP ) )
+ {
+ if (aValue >>= maOpCodeMapping)
+ {
+ ScDocument* pDoc = mpDocShell->GetDocument();
+ ScCompiler aCompiler( pDoc, ScAddress());
+ aCompiler.SetGrammar(pDoc->GetGrammar());
+ mxOpCodeMap = aCompiler.CreateOpCodeMap( maOpCodeMapping, mbEnglish);
+ }
+ else
+ throw lang::IllegalArgumentException();
+ }
+ else if ( aString.EqualsAscii( SC_UNO_EXTERNALLINKS ) )
+ {
+ if (!(aValue >>= maExternalLinks))
+ throw lang::IllegalArgumentException();
+ }
+ else
+ throw beans::UnknownPropertyException();
+}
+
+uno::Any SAL_CALL ScFormulaParserObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ String aString(aPropertyName);
+ if ( aString.EqualsAscii( SC_UNO_COMPILEFAP ) )
+ {
+ aRet <<= mbCompileFAP;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_COMPILEENGLISH ) )
+ {
+ aRet <<= mbEnglish;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_FORMULACONVENTION ) )
+ {
+ aRet <<= mnConv;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_IGNORELEADING ) )
+ {
+ aRet <<= mbIgnoreSpaces;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_OPCODEMAP ) )
+ {
+ aRet <<= maOpCodeMapping;
+ }
+ else if ( aString.EqualsAscii( SC_UNO_EXTERNALLINKS ) )
+ {
+ aRet <<= maExternalLinks;
+ }
+ else
+ throw beans::UnknownPropertyException();
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScFormulaParserObj )
+
+// ============================================================================
+
+void lcl_ExternalRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
+{
+ rAPI.Column = rRef.nCol;
+ rAPI.Row = rRef.nRow;
+ rAPI.Sheet = 0;
+ rAPI.RelativeColumn = rRef.nRelCol;
+ rAPI.RelativeRow = rRef.nRelRow;
+ rAPI.RelativeSheet = 0;
+
+ sal_Int32 nFlags = 0;
+ if ( rRef.IsColRel() ) nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
+ if ( rRef.IsRowRel() ) nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+ if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
+ if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
+ if ( rRef.IsFlag3D() ) nFlags |= sheet::ReferenceFlags::SHEET_3D;
+ if ( rRef.IsRelName() ) nFlags |= sheet::ReferenceFlags::RELATIVE_NAME;
+ rAPI.Flags = nFlags;
+}
+
+void lcl_SingleRefToApi( sheet::SingleReference& rAPI, const ScSingleRefData& rRef )
+{
+ rAPI.Column = rRef.nCol;
+ rAPI.Row = rRef.nRow;
+ rAPI.Sheet = rRef.nTab;
+ rAPI.RelativeColumn = rRef.nRelCol;
+ rAPI.RelativeRow = rRef.nRelRow;
+ rAPI.RelativeSheet = rRef.nRelTab;
+
+ sal_Int32 nFlags = 0;
+ if ( rRef.IsColRel() ) nFlags |= sheet::ReferenceFlags::COLUMN_RELATIVE;
+ if ( rRef.IsRowRel() ) nFlags |= sheet::ReferenceFlags::ROW_RELATIVE;
+ if ( rRef.IsTabRel() ) nFlags |= sheet::ReferenceFlags::SHEET_RELATIVE;
+ if ( rRef.IsColDeleted() ) nFlags |= sheet::ReferenceFlags::COLUMN_DELETED;
+ if ( rRef.IsRowDeleted() ) nFlags |= sheet::ReferenceFlags::ROW_DELETED;
+ if ( rRef.IsTabDeleted() ) nFlags |= sheet::ReferenceFlags::SHEET_DELETED;
+ if ( rRef.IsFlag3D() ) nFlags |= sheet::ReferenceFlags::SHEET_3D;
+ if ( rRef.IsRelName() ) nFlags |= sheet::ReferenceFlags::RELATIVE_NAME;
+ rAPI.Flags = nFlags;
+}
+
+// static
+bool ScTokenConversion::ConvertToTokenArray( ScDocument& rDoc,
+ ScTokenArray& rTokenArray, const uno::Sequence<sheet::FormulaToken>& rSequence )
+{
+ return !rTokenArray.Fill(rSequence,rDoc.GetExternalRefManager());
+}
+
+// static
+bool ScTokenConversion::ConvertToTokenSequence( ScDocument& rDoc,
+ uno::Sequence<sheet::FormulaToken>& rSequence, const ScTokenArray& rTokenArray )
+{
+ bool bError = false;
+
+ sal_Int32 nLen = static_cast<sal_Int32>(rTokenArray.GetLen());
+ formula::FormulaToken** pTokens = rTokenArray.GetArray();
+ if ( pTokens )
+ {
+ rSequence.realloc(nLen);
+ for (sal_Int32 nPos=0; nPos<nLen; nPos++)
+ {
+ const formula::FormulaToken& rToken = *pTokens[nPos];
+ sheet::FormulaToken& rAPI = rSequence[nPos];
+
+ OpCode eOpCode = rToken.GetOpCode();
+ // eOpCode may be changed in the following switch/case
+ switch ( rToken.GetType() )
+ {
+ case svByte:
+ // Only the count of spaces is stored as "long". Parameter count is ignored.
+ if ( eOpCode == ocSpaces )
+ rAPI.Data <<= (sal_Int32) rToken.GetByte();
+ else
+ rAPI.Data.clear(); // no data
+ break;
+ case formula::svDouble:
+ rAPI.Data <<= rToken.GetDouble();
+ break;
+ case formula::svString:
+ rAPI.Data <<= rtl::OUString( rToken.GetString() );
+ break;
+ case svExternal:
+ // Function name is stored as string.
+ // Byte (parameter count) is ignored.
+ rAPI.Data <<= rtl::OUString( rToken.GetExternal() );
+ break;
+ case svSingleRef:
+ {
+ sheet::SingleReference aSingleRef;
+ lcl_SingleRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() );
+ rAPI.Data <<= aSingleRef;
+ }
+ break;
+ case formula::svDoubleRef:
+ {
+ sheet::ComplexReference aCompRef;
+ lcl_SingleRefToApi( aCompRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() );
+ lcl_SingleRefToApi( aCompRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() );
+ rAPI.Data <<= aCompRef;
+ }
+ break;
+ case svIndex:
+ rAPI.Data <<= static_cast<sal_Int32>( rToken.GetIndex() );
+ break;
+ case svMatrix:
+ if (!ScRangeToSequence::FillMixedArray( rAPI.Data, static_cast<const ScToken&>(rToken).GetMatrix(), true))
+ rAPI.Data.clear();
+ break;
+ case svExternalSingleRef:
+ {
+ sheet::SingleReference aSingleRef;
+ lcl_ExternalRefToApi( aSingleRef, static_cast<const ScToken&>(rToken).GetSingleRef() );
+ size_t nCacheId;
+ rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId );
+ aSingleRef.Sheet = static_cast< sal_Int32 >( nCacheId );
+ sheet::ExternalReference aExtRef;
+ aExtRef.Index = rToken.GetIndex();
+ aExtRef.Reference <<= aSingleRef;
+ rAPI.Data <<= aExtRef;
+ eOpCode = ocPush;
+ }
+ break;
+ case svExternalDoubleRef:
+ {
+ sheet::ComplexReference aComplRef;
+ lcl_ExternalRefToApi( aComplRef.Reference1, static_cast<const ScToken&>(rToken).GetSingleRef() );
+ lcl_ExternalRefToApi( aComplRef.Reference2, static_cast<const ScToken&>(rToken).GetSingleRef2() );
+ size_t nCacheId;
+ rDoc.GetExternalRefManager()->getCacheTable( rToken.GetIndex(), rToken.GetString(), false, &nCacheId );
+ aComplRef.Reference1.Sheet = static_cast< sal_Int32 >( nCacheId );
+ // NOTE: This assumes that cached sheets are in consecutive order!
+ aComplRef.Reference2.Sheet = aComplRef.Reference1.Sheet + (static_cast<const ScToken&>(rToken).GetSingleRef2().nTab - static_cast<const ScToken&>(rToken).GetSingleRef().nTab);
+ sheet::ExternalReference aExtRef;
+ aExtRef.Index = rToken.GetIndex();
+ aExtRef.Reference <<= aComplRef;
+ rAPI.Data <<= aExtRef;
+ eOpCode = ocPush;
+ }
+ break;
+ case svExternalName:
+ {
+ sheet::ExternalReference aExtRef;
+ aExtRef.Index = rToken.GetIndex();
+ aExtRef.Reference <<= ::rtl::OUString( rToken.GetString() );
+ rAPI.Data <<= aExtRef;
+ eOpCode = ocPush;
+ }
+ break;
+ default:
+ DBG_ERROR1( "ScTokenConversion::ConvertToTokenSequence: unhandled token type SvStackVar %d", rToken.GetType());
+ case svSep: // occurs with ocSep, ocOpen, ocClose, ocArray*
+ case svJump: // occurs with ocIf, ocChose
+ case svMissing: // occurs with ocMissing
+ rAPI.Data.clear(); // no data
+ }
+ rAPI.OpCode = static_cast<sal_Int32>(eOpCode); //! assuming equal values for the moment
+ }
+ }
+ else
+ rSequence.realloc(0);
+
+ return !bError;
+}
+
+// ============================================================================
+
+ScFormulaOpCodeMapperObj::ScFormulaOpCodeMapperObj(::std::auto_ptr<formula::FormulaCompiler> _pCompiler)
+: formula::FormulaOpCodeMapperObj(_pCompiler)
+{
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/unodoc.cxx b/sc/source/ui/unoobj/unodoc.cxx
new file mode 100644
index 000000000000..6fa0a4710a90
--- /dev/null
+++ b/sc/source/ui/unoobj/unodoc.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+#include <tools/string.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include "scmod.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+#include "docsh.hxx"
+
+using namespace ::com::sun::star;
+
+::rtl::OUString SAL_CALL ScDocument_getImplementationName() throw()
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Calc.SpreadsheetDocument" ) );
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL ScDocument_getSupportedServiceNames() throw()
+{
+ uno::Sequence< rtl::OUString > aSeq( 1 );
+ aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocument" ));
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL ScDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & /* rSMgr */, const sal_uInt64 _nCreationFlags ) throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ ScDLL::Init();
+ SfxObjectShell* pShell = new ScDocShell( _nCreationFlags );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/unoreflist.cxx b/sc/source/ui/unoobj/unoreflist.cxx
new file mode 100644
index 000000000000..f67499419e07
--- /dev/null
+++ b/sc/source/ui/unoobj/unoreflist.cxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "unoreflist.hxx"
+#include "document.hxx"
+
+//------------------------------------------------------------------------
+
+ScUnoRefList::ScUnoRefList()
+{
+}
+
+ScUnoRefList::~ScUnoRefList()
+{
+}
+
+void ScUnoRefList::Add( sal_Int64 nId, const ScRangeList& rOldRanges )
+{
+ aEntries.push_back( ScUnoRefEntry( nId, rOldRanges ) );
+}
+
+void ScUnoRefList::Undo( ScDocument* pDoc )
+{
+ std::list<ScUnoRefEntry>::const_iterator aEnd( aEntries.end() );
+ for ( std::list<ScUnoRefEntry>::const_iterator aIter( aEntries.begin() );
+ aIter != aEnd; ++aIter )
+ {
+ ScUnoRefUndoHint aHint( *aIter );
+ pDoc->BroadcastUno( aHint );
+ }
+}
+
+//------------------------------------------------------------------------
+
+TYPEINIT1(ScUnoRefUndoHint, SfxHint);
+
+ScUnoRefUndoHint::ScUnoRefUndoHint( const ScUnoRefEntry& rRefEntry ) :
+ aEntry( rRefEntry )
+{
+}
+
+ScUnoRefUndoHint::~ScUnoRefUndoHint()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx
new file mode 100644
index 000000000000..041ecf707674
--- /dev/null
+++ b/sc/source/ui/unoobj/viewuno.cxx
@@ -0,0 +1,2376 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <com/sun/star/awt/MouseButton.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+#include <com/sun/star/view/DocumentZoomType.hpp>
+
+#include <editeng/outliner.hxx>
+#include <svx/fmdpage.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <svx/unoshape.hxx>
+#include <svx/unoshcol.hxx>
+#include <svx/fmshell.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <rtl/uuid.h>
+#include <toolkit/helper/convert.hxx>
+#include <vcl/svapp.hxx>
+
+#include "drawsh.hxx"
+#include "drtxtob.hxx"
+#include "transobj.hxx"
+#include "editsh.hxx"
+#include "viewuno.hxx"
+#include "cellsuno.hxx"
+#include "miscuno.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "drwlayer.hxx"
+#include "drawview.hxx"
+#include "fupoor.hxx"
+#include "sc.hrc"
+#include "unonames.hxx"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "gridwin.hxx"
+#include "sheetevents.hxx"
+#include "AccessibilityHints.hxx"
+#include <svx/sdrhittesthelper.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------------
+
+//! Clipping-Markierungen
+
+// alles ohne Which-ID, Map nur fuer PropertySetInfo
+
+const SfxItemPropertyMapEntry* lcl_GetViewOptPropertyMap()
+{
+ static SfxItemPropertyMapEntry aViewOptPropertyMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(OLD_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_GRIDCOLOR), 0, &getCppuType((sal_Int32*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_COLROWHDR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_HORSCROLL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_VERTSCROLL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_HIDESPELL), 0, &getBooleanCppuType(), 0, 0}, /* deprecated #i91949 */
+ {MAP_CHAR_LEN(OLD_UNO_HORSCROLL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_VALUEHIGH), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(OLD_UNO_OUTLSYMB), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(OLD_UNO_SHEETTABS), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWANCHOR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWCHARTS), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWDRAW), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWFORM), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWGRID), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWHELP), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWNOTES), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWOBJ), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWPAGEBR), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWZERO), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_SHOWSOLID), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(OLD_UNO_VALUEHIGH), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(OLD_UNO_VERTSCROLL), 0, &getBooleanCppuType(), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_VISAREA), 0, &getCppuType((awt::Rectangle*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ZOOMTYPE), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {MAP_CHAR_LEN(SC_UNO_ZOOMVALUE), 0, &getCppuType((sal_Int16*)0), 0, 0},
+ {0,0,0,0,0,0}
+ };
+ return aViewOptPropertyMap_Impl;
+}
+
+//------------------------------------------------------------------------
+
+SV_IMPL_PTRARR( XRangeSelectionListenerArr_Impl, XRangeSelectionListenerPtr );
+SV_IMPL_PTRARR( XRangeSelectionChangeListenerArr_Impl, XRangeSelectionChangeListenerPtr );
+SV_IMPL_PTRARR( XSelectionChangeListenerArr_Impl, XSelectionChangeListenerPtr );
+SV_IMPL_PTRARR( XViewPropertyChangeListenerArr_Impl, XViewPropertyChangeListenerPtr );
+SV_IMPL_PTRARR( XMouseClickHandlerArr_Impl, XMouseClickHandlerPtr );
+SV_IMPL_PTRARR( XActivationEventListenerArr_Impl, XActivationEventListenerPtr );
+
+#define SCTABVIEWOBJ_SERVICE "com.sun.star.sheet.SpreadsheetView"
+#define SCVIEWSETTINGS_SERVICE "com.sun.star.sheet.SpreadsheetViewSettings"
+
+SC_SIMPLE_SERVICE_INFO( ScViewPaneBase, "ScViewPaneObj", "com.sun.star.sheet.SpreadsheetViewPane" )
+
+//------------------------------------------------------------------------
+
+ScViewPaneBase::ScViewPaneBase(ScTabViewShell* pViewSh, USHORT nP) :
+ pViewShell( pViewSh ),
+ nPane( nP )
+{
+ if (pViewShell)
+ StartListening(*pViewShell);
+}
+
+ScViewPaneBase::~ScViewPaneBase()
+{
+ if (pViewShell)
+ EndListening(*pViewShell);
+}
+
+void ScViewPaneBase::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ if ( rHint.ISA( SfxSimpleHint ) &&
+ ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ pViewShell = NULL;
+}
+
+uno::Any SAL_CALL ScViewPaneBase::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XViewPane )
+ SC_QUERYINTERFACE( sheet::XCellRangeReferrer )
+ SC_QUERYINTERFACE( view::XFormLayerAccess )
+ SC_QUERYINTERFACE( view::XControlAccess )
+ SC_QUERYINTERFACE( lang::XServiceInfo )
+ SC_QUERYINTERFACE( lang::XTypeProvider )
+
+ return uno::Any(); // OWeakObject is in derived objects
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScViewPaneBase::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ aTypes.realloc(5);
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[0] = getCppuType((const uno::Reference<sheet::XViewPane>*)0);
+ pPtr[1] = getCppuType((const uno::Reference<sheet::XCellRangeReferrer>*)0);
+ pPtr[2] = getCppuType((const uno::Reference<view::XFormLayerAccess>*)0);
+ pPtr[3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0);
+ pPtr[4] = getCppuType((const uno::Reference<lang::XTypeProvider>*)0);
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScViewPaneBase::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XViewPane
+
+sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleColumn() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pViewShell)
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewData->GetActivePart() :
+ (ScSplitPos) nPane;
+ ScHSplitPos eWhichH = WhichH( eWhich );
+
+ return pViewData->GetPosX( eWhichH );
+ }
+ DBG_ERROR("keine View ?!?"); //! Exception?
+ return 0;
+}
+
+void SAL_CALL ScViewPaneBase::setFirstVisibleColumn( sal_Int32 nFirstVisibleColumn )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pViewShell)
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewData->GetActivePart() :
+ (ScSplitPos) nPane;
+ ScHSplitPos eWhichH = WhichH( eWhich );
+
+ long nDeltaX = ((long)nFirstVisibleColumn) - pViewData->GetPosX( eWhichH );
+ pViewShell->ScrollX( nDeltaX, eWhichH );
+ }
+}
+
+sal_Int32 SAL_CALL ScViewPaneBase::getFirstVisibleRow() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pViewShell)
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewData->GetActivePart() :
+ (ScSplitPos) nPane;
+ ScVSplitPos eWhichV = WhichV( eWhich );
+
+ return pViewData->GetPosY( eWhichV );
+ }
+ DBG_ERROR("keine View ?!?"); //! Exception?
+ return 0;
+}
+
+void SAL_CALL ScViewPaneBase::setFirstVisibleRow( sal_Int32 nFirstVisibleRow )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pViewShell)
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewData->GetActivePart() :
+ (ScSplitPos) nPane;
+ ScVSplitPos eWhichV = WhichV( eWhich );
+
+ long nDeltaY = ((long)nFirstVisibleRow) - pViewData->GetPosY( eWhichV );
+ pViewShell->ScrollY( nDeltaY, eWhichV );
+ }
+}
+
+table::CellRangeAddress SAL_CALL ScViewPaneBase::getVisibleRange() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ table::CellRangeAddress aAdr;
+ if (pViewShell)
+ {
+ ScViewData* pViewData = pViewShell->GetViewData();
+ ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewData->GetActivePart() :
+ (ScSplitPos) nPane;
+ ScHSplitPos eWhichH = WhichH( eWhich );
+ ScVSplitPos eWhichV = WhichV( eWhich );
+
+ // VisibleCellsX gibt nur komplett sichtbare Zellen,
+ // VisibleRange in Excel auch teilweise sichtbare.
+ //! anpassen ???
+
+ SCCOL nVisX = pViewData->VisibleCellsX( eWhichH );
+ SCROW nVisY = pViewData->VisibleCellsY( eWhichV );
+ if (!nVisX) nVisX = 1; // irgendwas muss ja im Range sein
+ if (!nVisY) nVisY = 1;
+ aAdr.Sheet = pViewData->GetTabNo();
+ aAdr.StartColumn = pViewData->GetPosX( eWhichH );
+ aAdr.StartRow = pViewData->GetPosY( eWhichV );
+ aAdr.EndColumn = aAdr.StartColumn + nVisX - 1;
+ aAdr.EndRow = aAdr.StartRow + nVisY - 1;
+ }
+ return aAdr;
+}
+
+// XCellRangeSource
+
+uno::Reference<table::XCellRange> SAL_CALL ScViewPaneBase::getReferredCells()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (pViewShell)
+ {
+ ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
+
+ table::CellRangeAddress aAdr(getVisibleRange()); //! Hilfsfunktion mit ScRange?
+ ScRange aRange( (SCCOL)aAdr.StartColumn, (SCROW)aAdr.StartRow, aAdr.Sheet,
+ (SCCOL)aAdr.EndColumn, (SCROW)aAdr.EndRow, aAdr.Sheet );
+ if ( aRange.aStart == aRange.aEnd )
+ return new ScCellObj( pDocSh, aRange.aStart );
+ else
+ return new ScCellRangeObj( pDocSh, aRange );
+ }
+
+ return NULL;
+}
+
+namespace
+{
+ bool lcl_prepareFormShellCall( ScTabViewShell* _pViewShell, USHORT _nPane, FmFormShell*& _rpFormShell, Window*& _rpWindow, SdrView*& _rpSdrView )
+ {
+ if ( !_pViewShell )
+ return false;
+
+ ScViewData* pViewData = _pViewShell->GetViewData();
+ ScSplitPos eWhich = ( _nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewData->GetActivePart() :
+ (ScSplitPos) _nPane;
+ _rpWindow = _pViewShell->GetWindowByPos( eWhich );
+ _rpSdrView = _pViewShell->GetSdrView();
+ _rpFormShell = _pViewShell->GetFormShell();
+ return ( _rpFormShell != NULL ) && ( _rpSdrView != NULL )&& ( _rpWindow != NULL );
+ }
+}
+
+// XFormLayerAccess
+uno::Reference< form::runtime::XFormController > SAL_CALL ScViewPaneBase::getFormController( const uno::Reference< form::XForm >& _Form ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference< form::runtime::XFormController > xController;
+
+ Window* pWindow( NULL );
+ SdrView* pSdrView( NULL );
+ FmFormShell* pFormShell( NULL );
+ if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
+ xController = pFormShell->GetFormController( _Form, *pSdrView, *pWindow );
+
+ return xController;
+}
+
+::sal_Bool SAL_CALL ScViewPaneBase::isFormDesignMode( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Bool bIsFormDesignMode( sal_True );
+
+ FmFormShell* pFormShell( pViewShell ? pViewShell->GetFormShell() : NULL );
+ if ( pFormShell )
+ bIsFormDesignMode = pFormShell->IsDesignMode();
+
+ return bIsFormDesignMode;
+}
+
+void SAL_CALL ScViewPaneBase::setFormDesignMode( ::sal_Bool _DesignMode ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Window* pWindow( NULL );
+ SdrView* pSdrView( NULL );
+ FmFormShell* pFormShell( NULL );
+ if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
+ pFormShell->SetDesignMode( _DesignMode );
+}
+
+// XControlAccess
+
+uno::Reference<awt::XControl> SAL_CALL ScViewPaneBase::getControl(
+ const uno::Reference<awt::XControlModel>& xModel )
+ throw(container::NoSuchElementException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference<awt::XControl> xRet;
+
+ Window* pWindow( NULL );
+ SdrView* pSdrView( NULL );
+ FmFormShell* pFormShell( NULL );
+ if ( lcl_prepareFormShellCall( pViewShell, nPane, pFormShell, pWindow, pSdrView ) )
+ pFormShell->GetFormControl( xModel, *pSdrView, *pWindow, xRet );
+
+ if ( !xRet.is() )
+ throw container::NoSuchElementException(); // no control found
+
+ return xRet;
+}
+
+awt::Rectangle ScViewPaneBase::GetVisArea() const
+{
+ awt::Rectangle aVisArea;
+ if (pViewShell)
+ {
+ ScSplitPos eWhich = ( nPane == SC_VIEWPANE_ACTIVE ) ?
+ pViewShell->GetViewData()->GetActivePart() :
+ (ScSplitPos) nPane;
+ ScGridWindow* pWindow = (ScGridWindow*)pViewShell->GetWindowByPos(eWhich);
+ ScDocument* pDoc = pViewShell->GetViewData()->GetDocument();
+ if (pWindow && pDoc)
+ {
+ ScHSplitPos eWhichH = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_BOTTOMLEFT)) ?
+ SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
+ ScVSplitPos eWhichV = ((eWhich == SC_SPLIT_TOPLEFT) || (eWhich == SC_SPLIT_TOPRIGHT)) ?
+ SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
+ ScAddress aCell(pViewShell->GetViewData()->GetPosX(eWhichH),
+ pViewShell->GetViewData()->GetPosY(eWhichV),
+ pViewShell->GetViewData()->GetTabNo());
+ Rectangle aVisRect(pDoc->GetMMRect(aCell.Col(), aCell.Row(), aCell.Col(), aCell.Row(), aCell.Tab()));
+
+ aVisRect.SetSize(pWindow->PixelToLogic(pWindow->GetSizePixel(), pWindow->GetDrawMapMode(sal_True)));
+
+ aVisArea = AWTRectangle(aVisRect);
+ }
+ }
+ return aVisArea;
+}
+
+//------------------------------------------------------------------------
+
+ScViewPaneObj::ScViewPaneObj(ScTabViewShell* pViewSh, USHORT nP) :
+ ScViewPaneBase( pViewSh, nP )
+{
+}
+
+ScViewPaneObj::~ScViewPaneObj()
+{
+}
+
+uno::Any SAL_CALL ScViewPaneObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ // ScViewPaneBase has everything except OWeakObject
+
+ uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
+ if (!aRet.hasValue())
+ aRet = OWeakObject::queryInterface( rType );
+ return aRet;
+}
+
+void SAL_CALL ScViewPaneObj::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+void SAL_CALL ScViewPaneObj::release() throw()
+{
+ OWeakObject::release();
+}
+
+// To process sheet compatibile event
+typedef ::cppu::WeakImplHelper2< awt::XEnhancedMouseClickHandler, view::XSelectionChangeListener > TabViewEventListener_BASE;
+class ScTabViewEventListener: public TabViewEventListener_BASE
+{
+private:
+ ScTabViewObj* pViewObj;
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper;
+ sal_Bool bDelaySelectionEvent;
+ sal_Bool bSelectionChangeOccured;
+
+ void fireSelectionChangeEvent();
+
+public:
+ ScTabViewEventListener( ScTabViewObj* pObj, uno::Reference< script::vba::XVBAEventProcessor >& rVbaEventsHelper);
+ ~ScTabViewEventListener();
+ // XEnhancedMouseClickHandler
+ virtual sal_Bool SAL_CALL mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL mouseReleased( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException);
+
+ // XSelectionChangeListener
+ virtual void SAL_CALL selectionChanged( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
+ // XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw ( uno::RuntimeException );
+};
+
+ScTabViewEventListener::ScTabViewEventListener(ScTabViewObj* pObj, uno::Reference< script::vba::XVBAEventProcessor >& rVbaEventsHelper):
+ pViewObj( pObj ),xVbaEventsHelper( rVbaEventsHelper ), bDelaySelectionEvent( sal_False ), bSelectionChangeOccured( sal_False )
+{
+}
+
+ScTabViewEventListener::~ScTabViewEventListener()
+{
+}
+
+void SAL_CALL ScTabViewEventListener::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+}
+
+void ScTabViewEventListener::fireSelectionChangeEvent()
+{
+ if ( xVbaEventsHelper.is() && pViewObj )
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] = pViewObj->getSelection();
+ try
+ {
+ xVbaEventsHelper->processVbaEvent( script::vba::VBAEventId::WORKSHEET_SELECTIONCHANGE, aArgs );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ bDelaySelectionEvent = sal_False;
+ bSelectionChangeOccured = sal_False;
+}
+
+sal_Bool SAL_CALL ScTabViewEventListener::mousePressed( const awt::EnhancedMouseEvent& e ) throw (uno::RuntimeException)
+{
+ // Delay to fire the selection change event if clicking the left mouse button to do selection.
+ bDelaySelectionEvent = ( e.Buttons == ::com::sun::star::awt::MouseButton::RIGHT ) ? sal_False : sal_True;
+ bSelectionChangeOccured = sal_False;
+
+ // ScTabViewObj::MousePressed should handle process BeforeDoubleClick and BeforeRightClick events
+ return sal_True;
+}
+
+sal_Bool SAL_CALL ScTabViewEventListener::mouseReleased( const awt::EnhancedMouseEvent&/*e*/) throw (uno::RuntimeException)
+{
+ if ( bSelectionChangeOccured )
+ fireSelectionChangeEvent();
+ return sal_True;
+}
+
+void SAL_CALL ScTabViewEventListener::selectionChanged( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ if ( !bDelaySelectionEvent )
+ {
+ fireSelectionChangeEvent();
+ }
+ else
+ {
+ bSelectionChangeOccured = sal_True;
+ }
+}
+
+//------------------------------------------------------------------------
+
+// Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht
+
+ScTabViewObj::ScTabViewObj( ScTabViewShell* pViewSh ) :
+ ScViewPaneBase( pViewSh, SC_VIEWPANE_ACTIVE ),
+ SfxBaseController( pViewSh ),
+ aPropSet( lcl_GetViewOptPropertyMap() ),
+ aMouseClickHandlers( 0 ),
+ aActivationListeners( 0 ),
+ nPreviousTab( 0 ),
+ bDrawSelModeSet(sal_False)
+{
+ if (pViewSh)
+ {
+ nPreviousTab = pViewSh->GetViewData()->GetTabNo();
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if( pViewData )
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEventsHelper (pViewData->GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY );
+ if ( xVbaEventsHelper.is() )
+ {
+ ScTabViewEventListener* pEventListener = new ScTabViewEventListener( this, xVbaEventsHelper );
+ uno::Reference< awt::XEnhancedMouseClickHandler > aMouseClickHandler( *pEventListener, uno::UNO_QUERY );
+ addEnhancedMouseClickHandler( aMouseClickHandler );
+ uno::Reference< view::XSelectionChangeListener > aSelectionChangeListener( *pEventListener, uno::UNO_QUERY );
+ addSelectionChangeListener( aSelectionChangeListener );
+ }
+ }
+ }
+}
+
+ScTabViewObj::~ScTabViewObj()
+{
+ //! Listening oder so
+ if (aMouseClickHandlers.Count())
+ {
+ acquire();
+ EndMouseListening();
+ }
+ if (aActivationListeners.Count())
+ {
+ acquire();
+ EndActivationListening();
+ }
+}
+
+uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType )
+ throw(uno::RuntimeException)
+{
+ SC_QUERYINTERFACE( sheet::XSpreadsheetView )
+ SC_QUERYINTERFACE( sheet::XEnhancedMouseClickBroadcaster )
+ SC_QUERYINTERFACE( sheet::XActivationBroadcaster )
+ SC_QUERYINTERFACE( container::XEnumerationAccess )
+ SC_QUERYINTERFACE( container::XIndexAccess )
+ SC_QUERY_MULTIPLE( container::XElementAccess, container::XIndexAccess )
+ SC_QUERYINTERFACE( view::XSelectionSupplier )
+ SC_QUERYINTERFACE( beans::XPropertySet )
+ SC_QUERYINTERFACE( sheet::XViewSplitable )
+ SC_QUERYINTERFACE( sheet::XViewFreezable )
+ SC_QUERYINTERFACE( sheet::XRangeSelection )
+ SC_QUERYINTERFACE( lang::XUnoTunnel )
+ SC_QUERYINTERFACE( datatransfer::XTransferableSupplier )
+
+ uno::Any aRet(ScViewPaneBase::queryInterface( rType ));
+ if (!aRet.hasValue())
+ aRet = SfxBaseController::queryInterface( rType );
+ return aRet;
+}
+
+void SAL_CALL ScTabViewObj::acquire() throw()
+{
+ SfxBaseController::acquire();
+}
+
+void SAL_CALL ScTabViewObj::release() throw()
+{
+ SfxBaseController::release();
+}
+
+void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent )
+{
+ ScDocument* pDoc = pDocSh->GetDocument();
+ // when deleting a sheet, nPreviousTab can be invalid
+ // (could be handled with reference updates)
+ if (!pDoc->HasTable(nTab))
+ return;
+
+ const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
+ if (pEvents)
+ {
+ const rtl::OUString* pScript = pEvents->GetScript(nEvent);
+ if (pScript)
+ {
+ uno::Any aRet;
+ uno::Sequence<uno::Any> aParams;
+ uno::Sequence<sal_Int16> aOutArgsIndex;
+ uno::Sequence<uno::Any> aOutArgs;
+ /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
+ }
+ }
+
+ // execute VBA event handlers
+ try
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+ // the parameter is the clicked object, as in the mousePressed call above
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= nTab;
+ xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+void ScTabViewObj::SheetChanged()
+{
+ if ( !GetViewShell() )
+ return;
+
+ ScViewData* pViewData = GetViewShell()->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if (aActivationListeners.Count() > 0)
+ {
+ sheet::ActivationEvent aEvent;
+ uno::Reference< sheet::XSpreadsheetView > xView(this);
+ uno::Reference< uno::XInterface > xSource(xView, uno::UNO_QUERY);
+ aEvent.Source = xSource;
+ aEvent.ActiveSheet = new ScTableSheetObj(pDocSh, pViewData->GetTabNo());
+ for ( USHORT n=0; n<aActivationListeners.Count(); n++ )
+ {
+ try
+ {
+ (*aActivationListeners[n])->activeSpreadsheetChanged( aEvent );
+ }
+ catch( uno::Exception& )
+ {
+ aActivationListeners.DeleteAndDestroy( n );
+ --n; // because it will be increased again in the loop
+ }
+ }
+ }
+
+ // handle sheet events
+ SCTAB nNewTab = pViewData->GetTabNo();
+ if ( nNewTab != nPreviousTab )
+ {
+ lcl_CallActivate( pDocSh, nPreviousTab, SC_SHEETEVENT_UNFOCUS );
+ lcl_CallActivate( pDocSh, nNewTab, SC_SHEETEVENT_FOCUS );
+ }
+ nPreviousTab = nNewTab;
+}
+
+uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes() throw(uno::RuntimeException)
+{
+ static uno::Sequence<uno::Type> aTypes;
+ if ( aTypes.getLength() == 0 )
+ {
+ uno::Sequence<uno::Type> aViewPaneTypes(ScViewPaneBase::getTypes());
+ long nViewPaneLen = aViewPaneTypes.getLength();
+ const uno::Type* pViewPanePtr = aViewPaneTypes.getConstArray();
+
+ uno::Sequence<uno::Type> aControllerTypes(SfxBaseController::getTypes());
+ long nControllerLen = aControllerTypes.getLength();
+ const uno::Type* pControllerPtr = aControllerTypes.getConstArray();
+
+ long nParentLen = nViewPaneLen + nControllerLen;
+
+ aTypes.realloc( nParentLen + 12 );
+ uno::Type* pPtr = aTypes.getArray();
+ pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSpreadsheetView>*)0);
+ pPtr[nParentLen + 1] = getCppuType((const uno::Reference<container::XEnumerationAccess>*)0);
+ pPtr[nParentLen + 2] = getCppuType((const uno::Reference<container::XIndexAccess>*)0);
+ pPtr[nParentLen + 3] = getCppuType((const uno::Reference<view::XSelectionSupplier>*)0);
+ pPtr[nParentLen + 4] = getCppuType((const uno::Reference<beans::XPropertySet>*)0);
+ pPtr[nParentLen + 5] = getCppuType((const uno::Reference<sheet::XViewSplitable>*)0);
+ pPtr[nParentLen + 6] = getCppuType((const uno::Reference<sheet::XViewFreezable>*)0);
+ pPtr[nParentLen + 7] = getCppuType((const uno::Reference<sheet::XRangeSelection>*)0);
+ pPtr[nParentLen + 8] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0);
+ pPtr[nParentLen + 9] = getCppuType((const uno::Reference<sheet::XEnhancedMouseClickBroadcaster>*)0);
+ pPtr[nParentLen + 10] = getCppuType((const uno::Reference<sheet::XActivationBroadcaster>*)0);
+ pPtr[nParentLen + 11] = getCppuType((const uno::Reference<datatransfer::XTransferableSupplier>*)0);
+
+ long i;
+ for (i=0; i<nViewPaneLen; i++)
+ pPtr[i] = pViewPanePtr[i]; // parent types first
+ for (i=0; i<nControllerLen; i++)
+ pPtr[nViewPaneLen+i] = pControllerPtr[i];
+ }
+ return aTypes;
+}
+
+uno::Sequence<sal_Int8> SAL_CALL ScTabViewObj::getImplementationId()
+ throw(uno::RuntimeException)
+{
+ static uno::Sequence< sal_Int8 > aId;
+ if( aId.getLength() == 0 )
+ {
+ aId.realloc( 16 );
+ rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True );
+ }
+ return aId;
+}
+
+// XDocumentView
+
+BOOL lcl_TabInRanges( SCTAB nTab, const ScRangeList& rRanges )
+{
+ ULONG nCount = rRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ const ScRange* pRange = rRanges.GetObject(i);
+ if ( nTab >= pRange->aStart.Tab() && nTab <= pRange->aEnd.Tab() )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void lcl_ShowObject( ScTabViewShell& rViewSh, ScDrawView& rDrawView, SdrObject* pSelObj )
+{
+ BOOL bFound = FALSE;
+ SCTAB nObjectTab = 0;
+
+ SdrModel* pModel = rDrawView.GetModel();
+ USHORT nPageCount = pModel->GetPageCount();
+ for (USHORT i=0; i<nPageCount && !bFound; i++)
+ {
+ SdrPage* pPage = pModel->GetPage(i);
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !bFound)
+ {
+ if ( pObject == pSelObj )
+ {
+ bFound = TRUE;
+ nObjectTab = static_cast<SCTAB>(i);
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+
+ if (bFound)
+ {
+ rViewSh.SetTabNo( nObjectTab );
+ rViewSh.ScrollToObject( pSelObj );
+ }
+}
+
+sal_Bool SAL_CALL ScTabViewObj::select( const uno::Any& aSelection )
+ throw(lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+
+ if ( !pViewSh )
+ return FALSE;
+
+ //! Type of aSelection can be some specific interface instead of XInterface
+
+ BOOL bRet = FALSE;
+ uno::Reference<uno::XInterface> xInterface(aSelection, uno::UNO_QUERY);
+ if ( !xInterface.is() ) //clear all selections
+ {
+ ScDrawView* pDrawView = pViewSh->GetScDrawView();
+ if (pDrawView)
+ {
+ pDrawView->ScEndTextEdit();
+ pDrawView->UnmarkAll();
+ }
+ else //#102232#; if there is no DrawView remove range selection
+ pViewSh->Unmark();
+ bRet = TRUE;
+ }
+
+ if (bDrawSelModeSet) // remove DrawSelMode if set by API; if necessary it will be set again later
+ {
+ pViewSh->SetDrawSelMode(sal_False);
+ pViewSh->UpdateLayerLocks();
+ bDrawSelModeSet = sal_False;
+ }
+
+ if (bRet)
+ return bRet;
+
+
+ ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xInterface );
+ uno::Reference<drawing::XShapes> xShapeColl( xInterface, uno::UNO_QUERY );
+ uno::Reference<drawing::XShape> xShapeSel( xInterface, uno::UNO_QUERY );
+ SvxShape* pShapeImp = SvxShape::getImplementation( xShapeSel );
+
+ if (pRangesImp) // Zell-Ranges
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if ( pViewData->GetDocShell() == pRangesImp->GetDocShell() )
+ {
+ // Zuerst evtl. Drawing-Selektion aufheben
+ // (MarkListHasChanged hebt Tabellen-Selektion auf)
+
+ ScDrawView* pDrawView = pViewSh->GetScDrawView();
+ if (pDrawView)
+ {
+ pDrawView->ScEndTextEdit();
+ pDrawView->UnmarkAll();
+ }
+ FuPoor* pFunc = pViewSh->GetDrawFuncPtr();
+ if ( pFunc && pFunc->GetSlotID() != SID_OBJECT_SELECT )
+ {
+ // Slot der Zeichenfunktion nochmal ausfuehren -> abschalten
+ SfxDispatcher* pDisp = pViewSh->GetDispatcher();
+ if (pDisp)
+ pDisp->Execute( pFunc->GetSlotID(), SFX_CALLMODE_SYNCHRON );
+ }
+ pViewSh->SetDrawShell(FALSE);
+ pViewSh->SetDrawSelMode(FALSE); // nach dem Dispatcher-Execute
+
+ // Ranges selektieren
+
+ const ScRangeList& rRanges = pRangesImp->GetRangeList();
+ ULONG nRangeCount = rRanges.Count();
+ // for empty range list, remove selection (cursor remains where it was)
+ if ( nRangeCount == 0 )
+ pViewSh->Unmark();
+ else if ( nRangeCount == 1 )
+ pViewSh->MarkRange( *rRanges.GetObject(0) );
+ else
+ {
+ // Mehrfachselektion
+
+ const ScRange* pFirst = rRanges.GetObject(0);
+ if ( pFirst && !lcl_TabInRanges( pViewData->GetTabNo(), rRanges ) )
+ pViewSh->SetTabNo( pFirst->aStart.Tab() );
+ pViewSh->DoneBlockMode();
+ pViewSh->InitOwnBlockMode();
+ pViewData->GetMarkData().MarkFromRangeList( rRanges, TRUE );
+ pViewSh->MarkDataChanged();
+ pViewData->GetDocShell()->PostPaintGridAll(); // Markierung (alt&neu)
+ if ( pFirst )
+ {
+ pViewSh->AlignToCursor( pFirst->aStart.Col(), pFirst->aStart.Row(),
+ SC_FOLLOW_JUMP );
+ pViewSh->SetCursor( pFirst->aStart.Col(), pFirst->aStart.Row() );
+ }
+
+ //! Methode an der View, um RangeList zu selektieren
+ }
+ bRet = TRUE;
+ }
+ }
+ else if ( pShapeImp || xShapeColl.is() ) // Drawing-Layer
+ {
+ ScDrawView* pDrawView = pViewSh->GetScDrawView();
+ if (pDrawView)
+ {
+ pDrawView->ScEndTextEdit();
+ pDrawView->UnmarkAll();
+
+ if (pShapeImp) // einzelnes Shape
+ {
+ SdrObject *pObj = pShapeImp->GetSdrObject();
+ if (pObj)
+ {
+ lcl_ShowObject( *pViewSh, *pDrawView, pObj );
+ SdrPageView* pPV = pDrawView->GetSdrPageView();
+ if ( pPV && pObj->GetPage() == pPV->GetPage() )
+ {
+ pDrawView->MarkObj( pObj, pPV );
+ bRet = TRUE;
+ }
+ }
+ }
+ else // Shape-Collection (xShapeColl ist nicht 0)
+ {
+ // Es wird auf die Tabelle des ersten Objekts umgeschaltet,
+ // und alle Objekte selektiert, die auf dieser Tabelle liegen
+ //! Exception, wenn Objekte auf verschiedenen Tabellen?
+
+ SdrPageView* pPV = NULL;
+ long nCount = xShapeColl->getCount();
+ if (nCount)
+ {
+ sal_Bool bAllMarked(sal_True);
+ for ( long i = 0; i < nCount; i++ )
+ {
+ uno::Reference<drawing::XShape> xShapeInt(xShapeColl->getByIndex(i), uno::UNO_QUERY);
+ if (xShapeInt.is())
+ {
+ SvxShape* pShape = SvxShape::getImplementation( xShapeInt );
+ if (pShape)
+ {
+ SdrObject *pObj = pShape->GetSdrObject();
+ if (pObj)
+ {
+ if (!bDrawSelModeSet && (pObj->GetLayer() == SC_LAYER_BACK))
+ {
+ pViewSh->SetDrawSelMode(sal_True);
+ pViewSh->UpdateLayerLocks();
+ bDrawSelModeSet = sal_True;
+ }
+ if (!pPV) // erstes Objekt
+ {
+ lcl_ShowObject( *pViewSh, *pDrawView, pObj );
+ pPV = pDrawView->GetSdrPageView();
+ }
+ if ( pPV && pObj->GetPage() == pPV->GetPage() )
+ {
+ if (pDrawView->IsObjMarkable( pObj, pPV ))
+ pDrawView->MarkObj( pObj, pPV );
+ else
+ bAllMarked = sal_False;
+ }
+ }
+ }
+ }
+ }
+ if (bAllMarked)
+ bRet = TRUE;
+ }
+ else
+ bRet = TRUE; // empty XShapes (all shapes are deselected)
+ }
+
+ if (bRet)
+ pViewSh->SetDrawShell(TRUE);
+ }
+ }
+
+ if (!bRet)
+ throw lang::IllegalArgumentException();
+
+ return bRet;
+}
+
+uno::Any SAL_CALL ScTabViewObj::getSelection() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ ScCellRangesBase* pObj = NULL;
+ if (pViewSh)
+ {
+ // Ist auf dem Drawing-Layer etwas selektiert?
+
+ SdrView* pDrawView = pViewSh->GetSdrView();
+ if (pDrawView)
+ {
+ const SdrMarkList& rMarkList = pDrawView->GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+ if (nMarkCount)
+ {
+ // ShapeCollection erzeugen (wie in SdXImpressView::getSelection im Draw)
+ // Zurueckgegeben wird XInterfaceRef, das muss das UsrObject-XInterface sein
+
+ SvxShapeCollection* pShapes = new SvxShapeCollection();
+ uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pShapes));
+
+ for (ULONG i=0; i<nMarkCount; i++)
+ {
+ SdrObject* pDrawObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if (pDrawObj)
+ {
+ uno::Reference<drawing::XShape> xShape( pDrawObj->getUnoShape(), uno::UNO_QUERY );
+ if (xShape.is())
+ pShapes->add(xShape);
+ }
+ }
+ return uno::makeAny(xRet);
+ }
+ }
+
+ // sonst Tabellen-(Zellen-)Selektion
+
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ const ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nTabs = rMark.GetSelectCount();
+
+ ScRange aRange;
+ ScMarkType eMarkType = pViewData->GetSimpleArea(aRange);
+ if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE) )
+ {
+ if (aRange.aStart == aRange.aEnd)
+ pObj = new ScCellObj( pDocSh, aRange.aStart );
+ else
+ pObj = new ScCellRangeObj( pDocSh, aRange );
+ }
+ else if ( nTabs == 1 && (eMarkType == SC_MARK_SIMPLE_FILTERED) )
+ {
+ ScMarkData aFilteredMark( rMark );
+ ScViewUtil::UnmarkFiltered( aFilteredMark, pDocSh->GetDocument());
+ ScRangeList aRangeList;
+ aFilteredMark.FillRangeListWithMarks( &aRangeList, FALSE);
+ // Theoretically a selection may start and end on a filtered row.
+ switch (aRangeList.Count())
+ {
+ case 0:
+ // No unfiltered row, we have to return some object, so
+ // here is one with no ranges.
+ pObj = new ScCellRangesObj( pDocSh, aRangeList );
+ break;
+ case 1:
+ {
+ const ScRange& rRange = *(aRangeList.GetObject(0));
+ if (rRange.aStart == rRange.aEnd)
+ pObj = new ScCellObj( pDocSh, rRange.aStart );
+ else
+ pObj = new ScCellRangeObj( pDocSh, rRange );
+ }
+ break;
+ default:
+ pObj = new ScCellRangesObj( pDocSh, aRangeList );
+ }
+ }
+ else // Mehrfachselektion
+ {
+ ScRangeListRef xRanges;
+ pViewData->GetMultiArea( xRanges );
+
+ // bei mehreren Tabellen Ranges kopieren
+ //! sollte eigentlich schon in ScMarkData::FillRangeListWithMarks passieren?
+ if ( nTabs > 1 )
+ rMark.ExtendRangeListTables( xRanges );
+
+ pObj = new ScCellRangesObj( pDocSh, *xRanges );
+ }
+
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ // remember if the selection was from the cursor position without anything selected
+ // (used when rendering the selection)
+
+ pObj->SetCursorOnly( TRUE );
+ }
+ }
+
+ return uno::makeAny(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj)));
+}
+
+// XEnumerationAccess
+
+uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return new ScIndexEnumeration(this, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetViewPanesEnumeration")));
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScTabViewObj::getCount() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ USHORT nPanes = 0;
+ if (pViewSh)
+ {
+ nPanes = 1;
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
+ nPanes *= 2;
+ if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
+ nPanes *= 2;
+ }
+ return nPanes;
+}
+
+uno::Any SAL_CALL ScTabViewObj::getByIndex( sal_Int32 nIndex )
+ throw(lang::IndexOutOfBoundsException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XViewPane> xPane(GetObjectByIndex_Impl((USHORT)nIndex));
+ if (xPane.is())
+ return uno::makeAny(xPane);
+ else
+ throw lang::IndexOutOfBoundsException();
+// return uno::Any();
+}
+
+uno::Type SAL_CALL ScTabViewObj::getElementType() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return getCppuType((uno::Reference<sheet::XViewPane>*)0);
+}
+
+sal_Bool SAL_CALL ScTabViewObj::hasElements() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return ( getCount() != 0 );
+}
+
+// XSpreadsheetView
+
+ScViewPaneObj* ScTabViewObj::GetObjectByIndex_Impl(USHORT nIndex) const
+{
+ static ScSplitPos ePosHV[4] =
+ { SC_SPLIT_TOPLEFT, SC_SPLIT_BOTTOMLEFT, SC_SPLIT_TOPRIGHT, SC_SPLIT_BOTTOMRIGHT };
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScSplitPos eWhich = SC_SPLIT_BOTTOMLEFT; // default Position
+ BOOL bError = FALSE;
+ ScViewData* pViewData = pViewSh->GetViewData();
+ BOOL bHor = ( pViewData->GetHSplitMode() != SC_SPLIT_NONE );
+ BOOL bVer = ( pViewData->GetVSplitMode() != SC_SPLIT_NONE );
+ if ( bHor && bVer )
+ {
+ // links oben, links unten, rechts oben, rechts unten - wie in Excel
+ if ( nIndex < 4 )
+ eWhich = ePosHV[nIndex];
+ else
+ bError = TRUE;
+ }
+ else if ( bHor )
+ {
+ if ( nIndex > 1 )
+ bError = TRUE;
+ else if ( nIndex == 1 )
+ eWhich = SC_SPLIT_BOTTOMRIGHT;
+ // sonst SC_SPLIT_BOTTOMLEFT
+ }
+ else if ( bVer )
+ {
+ if ( nIndex > 1 )
+ bError = TRUE;
+ else if ( nIndex == 0 )
+ eWhich = SC_SPLIT_TOPLEFT;
+ // sonst SC_SPLIT_BOTTOMLEFT
+ }
+ else if ( nIndex > 0 )
+ bError = TRUE; // nicht geteilt: nur 0 gueltig
+
+ if (!bError)
+ return new ScViewPaneObj( pViewSh, sal::static_int_cast<USHORT>(eWhich) );
+ }
+
+ return NULL;
+}
+
+uno::Reference<sheet::XSpreadsheet> SAL_CALL ScTabViewObj::getActiveSheet()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pData = pViewSh->GetViewData();
+ SCTAB nTab = pData->GetTabNo();
+ return new ScTableSheetObj( pData->GetDocShell(), nTab );
+ }
+ return NULL;
+}
+
+//liuchen 2009-9-2 support expand (but not replace) the active sheet
+void SAL_CALL ScTabViewObj::setActiveSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet )
+ throw(uno::RuntimeException)
+{
+ selectSheet(xActiveSheet, false);
+}
+
+void SAL_CALL
+ScTabViewObj::selectSheet( const uno::Reference<sheet::XSpreadsheet>& xActiveSheet,
+ sal_Bool bExpand)
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bNew = bExpand;
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ if ( pViewSh && xActiveSheet.is() )
+ {
+ // XSpreadsheet und ScCellRangesBase -> muss ein Sheet sein
+
+ ScCellRangesBase* pRangesImp = ScCellRangesBase::getImplementation( xActiveSheet );
+ if ( pRangesImp && pViewSh->GetViewData()->GetDocShell() == pRangesImp->GetDocShell() )
+ {
+ const ScRangeList& rRanges = pRangesImp->GetRangeList();
+ if ( rRanges.Count() == 1 )
+ {
+ SCTAB nNewTab = rRanges.GetObject(0)->aStart.Tab();
+ if ( pViewSh->GetViewData()->GetDocument()->HasTable(nNewTab) )
+ pViewSh->SetTabNo( nNewTab, bNew, bExpand );
+ }
+ }
+ }
+}
+
+uno::Reference< uno::XInterface > ScTabViewObj::GetClickedObject(const Point& rPoint) const
+{
+ uno::Reference< uno::XInterface > xTarget;
+ if (GetViewShell())
+ {
+ SCsCOL nX;
+ SCsROW nY;
+ ScViewData* pData = GetViewShell()->GetViewData();
+ ScSplitPos eSplitMode = pData->GetActivePart();
+ SCTAB nTab(pData->GetTabNo());
+ pData->GetPosFromPixel( rPoint.X(), rPoint.Y(), eSplitMode, nX, nY);
+
+ ScAddress aCellPos (nX, nY, nTab);
+ ScCellObj* pCellObj = new ScCellObj(pData->GetDocShell(), aCellPos);
+
+ xTarget.set(uno::Reference<table::XCell>(pCellObj), uno::UNO_QUERY);
+
+ ScDocument* pDoc = pData->GetDocument();
+ if (pDoc && pDoc->GetDrawLayer())
+ {
+ SdrPage* pDrawPage = NULL;
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ if (pDrawLayer->HasObjects() && (pDrawLayer->GetPageCount() > nTab))
+ pDrawPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(nTab));
+
+ SdrView* pDrawView = GetViewShell()->GetSdrView();
+
+ if (pDrawPage && pDrawView && pDrawView->GetSdrPageView())
+ {
+ Window* pActiveWin = pData->GetActiveWin();
+ Point aPos = pActiveWin->PixelToLogic(rPoint);
+
+ USHORT nHitLog = (USHORT) pActiveWin->PixelToLogic(
+ Size(pDrawView->GetHitTolerancePixel(),0)).Width();
+
+ sal_uInt32 nCount(pDrawPage->GetObjCount());
+ sal_Bool bFound(sal_False);
+ sal_uInt32 i(0);
+ while (i < nCount && !bFound)
+ {
+ SdrObject* pObj = pDrawPage->GetObj(i);
+ if (pObj && SdrObjectPrimitiveHit(*pObj, aPos, nHitLog, *pDrawView->GetSdrPageView(), 0, false))
+ {
+ xTarget.set(pObj->getUnoShape(), uno::UNO_QUERY);
+ bFound = sal_True;
+ }
+ ++i;
+ }
+ }
+ }
+ }
+ return xTarget;
+}
+
+bool ScTabViewObj::IsMouseListening() const
+{
+ if ( aMouseClickHandlers.Count() > 0 )
+ return true;
+
+ // also include sheet events, because MousePressed must be called for them
+ ScViewData* pViewData = GetViewShell()->GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ return
+ pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) ||
+ pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true );
+}
+
+sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e )
+ throw (::uno::RuntimeException)
+{
+ sal_Bool bReturn(sal_False);
+
+ uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
+ if (aMouseClickHandlers.Count() && xTarget.is())
+ {
+ awt::EnhancedMouseEvent aMouseEvent;
+
+ aMouseEvent.Buttons = e.Buttons;
+ aMouseEvent.X = e.X;
+ aMouseEvent.Y = e.Y;
+ aMouseEvent.ClickCount = e.ClickCount;
+ aMouseEvent.PopupTrigger = e.PopupTrigger;
+ aMouseEvent.Target = xTarget;
+
+ for ( USHORT n=0; n<aMouseClickHandlers.Count(); n++ )
+ {
+ try
+ {
+ if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent ))
+ bReturn = sal_True;
+ }
+ catch ( uno::Exception& )
+ {
+ aMouseClickHandlers.DeleteAndDestroy(n);
+ --n; // because it will be increased again in the loop
+ }
+ }
+ }
+
+ // handle sheet events
+ bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 );
+ bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 );
+ if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is())
+ {
+ sal_Int32 nEvent = bDoubleClick ? SC_SHEETEVENT_DOUBLECLICK : SC_SHEETEVENT_RIGHTCLICK;
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
+ if (pEvents)
+ {
+ const rtl::OUString* pScript = pEvents->GetScript(nEvent);
+ if (pScript)
+ {
+ // the macro parameter is the clicked object, as in the mousePressed call above
+ uno::Sequence<uno::Any> aParams(1);
+ aParams[0] <<= xTarget;
+
+ uno::Any aRet;
+ uno::Sequence<sal_Int16> aOutArgsIndex;
+ uno::Sequence<uno::Any> aOutArgs;
+
+ /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
+
+ // look for a boolean return value of true
+ sal_Bool bRetValue = sal_False;
+ if (aRet >>= bRetValue)
+ {
+ if (bRetValue)
+ bReturn = sal_True;
+ }
+ }
+ }
+
+ // execute VBA event handler
+ if (!bReturn && xTarget.is()) try
+ {
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW );
+ // the parameter is the clicked object, as in the mousePressed call above
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= xTarget;
+ xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs );
+ }
+ catch( util::VetoException& )
+ {
+ bReturn = sal_True;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ return bReturn;
+}
+
+sal_Bool ScTabViewObj::MouseReleased( const awt::MouseEvent& e )
+ throw (uno::RuntimeException)
+{
+ sal_Bool bReturn(sal_False);
+
+ if (aMouseClickHandlers.Count())
+ {
+ uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y));
+
+ if (xTarget.is())
+ {
+ awt::EnhancedMouseEvent aMouseEvent;
+
+ aMouseEvent.Buttons = e.Buttons;
+ aMouseEvent.X = e.X;
+ aMouseEvent.Y = e.Y;
+ aMouseEvent.ClickCount = e.ClickCount;
+ aMouseEvent.PopupTrigger = e.PopupTrigger;
+ aMouseEvent.Target = xTarget;
+
+ for ( USHORT n=0; n<aMouseClickHandlers.Count(); n++ )
+ {
+ try
+ {
+ if (!(*aMouseClickHandlers[n])->mouseReleased( aMouseEvent ))
+ bReturn = sal_True;
+ }
+ catch ( uno::Exception& )
+ {
+ aMouseClickHandlers.DeleteAndDestroy(n);
+ --n; // because it will be increased again in the loop
+ }
+ }
+ }
+ }
+ return bReturn;
+}
+
+// XEnhancedMouseClickBroadcaster
+
+void ScTabViewObj::StartMouseListening()
+{
+}
+
+void ScTabViewObj::EndMouseListening()
+{
+ USHORT nCount(aMouseClickHandlers.Count());
+ lang::EventObject aEvent;
+ aEvent.Source = (cppu::OWeakObject*)this;
+ for ( USHORT n=0; n<nCount; n++ )
+ {
+ try
+ {
+ (*aMouseClickHandlers[n])->disposing(aEvent);
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ aMouseClickHandlers.DeleteAndDestroy(0, nCount);
+}
+
+void ScTabViewObj::StartActivationListening()
+{
+}
+
+void ScTabViewObj::EndActivationListening()
+{
+ USHORT nCount = aActivationListeners.Count();
+ lang::EventObject aEvent;
+ aEvent.Source = (cppu::OWeakObject*)this;
+ for ( USHORT n=0; n<nCount; n++ )
+ {
+ try
+ {
+ (*aActivationListeners[n])->disposing(aEvent);
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+ aActivationListeners.DeleteAndDestroy(0, nCount);
+}
+
+void SAL_CALL ScTabViewObj::addEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (aListener.is())
+ {
+ USHORT nCount = aMouseClickHandlers.Count();
+ uno::Reference<awt::XEnhancedMouseClickHandler> *pObj =
+ new uno::Reference<awt::XEnhancedMouseClickHandler>( aListener );
+ aMouseClickHandlers.Insert( pObj, nCount );
+
+ if (aMouseClickHandlers.Count() == 1 && nCount == 0) // only if a listener added
+ StartMouseListening();
+ }
+}
+
+void SAL_CALL ScTabViewObj::removeEnhancedMouseClickHandler( const uno::Reference< awt::XEnhancedMouseClickHandler >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aMouseClickHandlers.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<awt::XEnhancedMouseClickHandler> *pObj = aMouseClickHandlers[n];
+ if ( *pObj == aListener )
+ aMouseClickHandlers.DeleteAndDestroy( n );
+ }
+ if ((aMouseClickHandlers.Count() == 0) && (nCount > 0)) // only if last listener removed
+ EndMouseListening();
+}
+
+// XActivationBroadcaster
+
+void SAL_CALL ScTabViewObj::addActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (aListener.is())
+ {
+ USHORT nCount = aActivationListeners.Count();
+ uno::Reference<sheet::XActivationEventListener> *pObj =
+ new uno::Reference<sheet::XActivationEventListener>( aListener );
+ aActivationListeners.Insert( pObj, nCount );
+
+ if (aActivationListeners.Count() == 1 && nCount == 0) // only if a listener added
+ StartActivationListening();
+ }
+}
+
+void SAL_CALL ScTabViewObj::removeActivationEventListener( const uno::Reference< sheet::XActivationEventListener >& aListener )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aActivationListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<sheet::XActivationEventListener> *pObj = aActivationListeners[n];
+ if ( *pObj == aListener )
+ aActivationListeners.DeleteAndDestroy( n );
+ }
+ if ((aActivationListeners.Count() == 0) && (nCount > 0)) // only if last listener removed
+ EndActivationListening();
+}
+
+INT16 ScTabViewObj::GetZoom(void) const
+{
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ const Fraction& rZoomY = pViewSh->GetViewData()->GetZoomY(); // Y wird angezeigt
+ return (INT16)(( rZoomY.GetNumerator() * 100 ) / rZoomY.GetDenominator());
+ }
+ return 0;
+}
+
+void ScTabViewObj::SetZoom(INT16 nZoom)
+{
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ if ( nZoom != GetZoom() && nZoom != 0 )
+ {
+ if (!pViewSh->GetViewData()->IsPagebreakMode())
+ {
+ ScModule* pScMod = SC_MOD();
+ ScAppOptions aNewOpt(pScMod->GetAppOptions());
+ aNewOpt.SetZoom( nZoom );
+ aNewOpt.SetZoomType( pViewSh->GetViewData()->GetView()->GetZoomType() );
+ pScMod->SetAppOptions( aNewOpt );
+ }
+ }
+ Fraction aFract( nZoom, 100 );
+ pViewSh->SetZoom( aFract, aFract, TRUE );
+ pViewSh->PaintGrid();
+ pViewSh->PaintTop();
+ pViewSh->PaintLeft();
+ pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ pViewSh->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+ }
+}
+
+INT16 ScTabViewObj::GetZoomType(void) const
+{
+ INT16 aZoomType = view::DocumentZoomType::OPTIMAL;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ SvxZoomType eZoomType = pViewSh->GetViewData()->GetView()->GetZoomType();
+ switch (eZoomType)
+ {
+ case SVX_ZOOM_PERCENT:
+ aZoomType = view::DocumentZoomType::BY_VALUE;
+ break;
+ case SVX_ZOOM_OPTIMAL:
+ aZoomType = view::DocumentZoomType::OPTIMAL;
+ break;
+ case SVX_ZOOM_WHOLEPAGE:
+ aZoomType = view::DocumentZoomType::ENTIRE_PAGE;
+ break;
+ case SVX_ZOOM_PAGEWIDTH:
+ aZoomType = view::DocumentZoomType::PAGE_WIDTH;
+ break;
+ case SVX_ZOOM_PAGEWIDTH_NOBORDER:
+ aZoomType = view::DocumentZoomType::PAGE_WIDTH_EXACT;
+ break;
+ }
+ }
+ return aZoomType;
+}
+
+void ScTabViewObj::SetZoomType(INT16 aZoomType)
+{
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScDBFunc* pView = pViewSh->GetViewData()->GetView();
+ if (pView)
+ {
+ SvxZoomType eZoomType;
+ switch (aZoomType)
+ {
+ case view::DocumentZoomType::BY_VALUE:
+ eZoomType = SVX_ZOOM_PERCENT;
+ break;
+ case view::DocumentZoomType::OPTIMAL:
+ eZoomType = SVX_ZOOM_OPTIMAL;
+ break;
+ case view::DocumentZoomType::ENTIRE_PAGE:
+ eZoomType = SVX_ZOOM_WHOLEPAGE;
+ break;
+ case view::DocumentZoomType::PAGE_WIDTH:
+ eZoomType = SVX_ZOOM_PAGEWIDTH;
+ break;
+ case view::DocumentZoomType::PAGE_WIDTH_EXACT:
+ eZoomType = SVX_ZOOM_PAGEWIDTH_NOBORDER;
+ break;
+ default:
+ eZoomType = SVX_ZOOM_OPTIMAL;
+ }
+ sal_Int16 nZoom(GetZoom());
+ sal_Int16 nOldZoom(nZoom);
+ if ( eZoomType == SVX_ZOOM_PERCENT )
+ {
+ if ( nZoom < MINZOOM ) nZoom = MINZOOM;
+ if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
+ }
+ else
+ nZoom = pView->CalcZoom( eZoomType, nOldZoom );
+
+ switch ( eZoomType )
+ {
+ case SVX_ZOOM_WHOLEPAGE:
+ case SVX_ZOOM_PAGEWIDTH:
+ pView->SetZoomType( eZoomType, TRUE );
+ break;
+
+ default:
+ pView->SetZoomType( SVX_ZOOM_PERCENT, TRUE );
+ }
+ SetZoom( nZoom );
+ }
+ }
+}
+
+sal_Bool SAL_CALL ScTabViewObj::getIsWindowSplit() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // wie Menue-Slot SID_WINDOW_SPLIT
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ return ( pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
+ pViewData->GetVSplitMode() == SC_SPLIT_NORMAL );
+ }
+
+ return FALSE;
+}
+
+sal_Bool SAL_CALL ScTabViewObj::hasFrozenPanes() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // wie Menue-Slot SID_WINDOW_FIX
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ return ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
+ pViewData->GetVSplitMode() == SC_SPLIT_FIX );
+ }
+
+ return FALSE;
+}
+
+sal_Int32 SAL_CALL ScTabViewObj::getSplitHorizontal() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
+ return pViewData->GetHSplitPos();
+ }
+ return 0;
+}
+
+sal_Int32 SAL_CALL ScTabViewObj::getSplitVertical() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
+ return pViewData->GetVSplitPos();
+ }
+ return 0;
+}
+
+sal_Int32 SAL_CALL ScTabViewObj::getSplitColumn() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if ( pViewData->GetHSplitMode() != SC_SPLIT_NONE )
+ {
+ long nSplit = pViewData->GetHSplitPos();
+
+ ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
+ if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
+ ePos = SC_SPLIT_TOPLEFT;
+
+ SCsCOL nCol;
+ SCsROW nRow;
+ pViewData->GetPosFromPixel( nSplit, 0, ePos, nCol, nRow, FALSE );
+ if ( nCol > 0 )
+ return nCol;
+ }
+ }
+ return 0;
+}
+
+sal_Int32 SAL_CALL ScTabViewObj::getSplitRow() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ if ( pViewData->GetVSplitMode() != SC_SPLIT_NONE )
+ {
+ long nSplit = pViewData->GetVSplitPos();
+
+ ScSplitPos ePos = SC_SPLIT_TOPLEFT; // es ist vertikal geteilt
+ SCsCOL nCol;
+ SCsROW nRow;
+ pViewData->GetPosFromPixel( 0, nSplit, ePos, nCol, nRow, FALSE );
+ if ( nRow > 0 )
+ return nRow;
+ }
+ }
+ return 0;
+}
+
+void SAL_CALL ScTabViewObj::splitAtPosition( sal_Int32 nPixelX, sal_Int32 nPixelY )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ pViewSh->SplitAtPixel( Point( nPixelX, nPixelY ), TRUE, TRUE );
+ pViewSh->FreezeSplitters( FALSE );
+ pViewSh->InvalidateSplit();
+ }
+}
+
+void SAL_CALL ScTabViewObj::freezeAtPosition( sal_Int32 nColumns, sal_Int32 nRows )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ // erst alles aufheben -> kein Stress mit Scrolling zwischendurch o.ae.
+
+ pViewSh->RemoveSplit();
+
+ Point aWinStart;
+ Window* pWin = pViewSh->GetWindowByPos( SC_SPLIT_BOTTOMLEFT );
+ if (pWin)
+ aWinStart = pWin->GetPosPixel();
+
+ ScViewData* pViewData = pViewSh->GetViewData();
+ Point aSplit(pViewData->GetScrPos( (SCCOL)nColumns, (SCROW)nRows, SC_SPLIT_BOTTOMLEFT, TRUE ));
+ aSplit += aWinStart;
+
+ pViewSh->SplitAtPixel( aSplit, TRUE, TRUE );
+ pViewSh->FreezeSplitters( TRUE );
+ pViewSh->InvalidateSplit();
+ }
+}
+
+void SAL_CALL ScTabViewObj::addSelectionChangeListener(
+ const uno::Reference<view::XSelectionChangeListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<view::XSelectionChangeListener>* pObj =
+ new uno::Reference<view::XSelectionChangeListener>( xListener );
+ aSelectionListeners.Insert( pObj, aSelectionListeners.Count() );
+}
+
+void SAL_CALL ScTabViewObj::removeSelectionChangeListener(
+ const uno::Reference< view::XSelectionChangeListener >& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aSelectionListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<view::XSelectionChangeListener> *pObj = aSelectionListeners[n];
+ if ( *pObj == xListener ) //! wozu der Mumpitz mit queryInterface?
+ {
+ aSelectionListeners.DeleteAndDestroy( n );
+ break;
+ }
+ }
+}
+
+void ScTabViewObj::SelectionChanged()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ for ( USHORT n=0; n<aSelectionListeners.Count(); n++ )
+ (*aSelectionListeners[n])->selectionChanged( aEvent );
+
+ // handle sheet events
+ ScTabViewShell* pViewSh = GetViewShell();
+ ScViewData* pViewData = pViewSh->GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab);
+ if (pEvents)
+ {
+ const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_SELECT);
+ if (pScript)
+ {
+ // the macro parameter is the selection as returned by getSelection
+ uno::Sequence<uno::Any> aParams(1);
+ aParams[0] = getSelection();
+ uno::Any aRet;
+ uno::Sequence<sal_Int16> aOutArgsIndex;
+ uno::Sequence<uno::Any> aOutArgs;
+ /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs );
+ }
+ }
+ // Removed Sun/Oracle code intentionally, it doesn't work properly ( selection should be fired after mouse release )
+}
+
+
+// XPropertySet (View-Optionen)
+//! auch an der Applikation anbieten?
+
+uno::Reference<beans::XPropertySetInfo> SAL_CALL ScTabViewObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo( aPropSet.getPropertyMap() ));
+ return aRef;
+}
+
+void SAL_CALL ScTabViewObj::setPropertyValue(
+ const rtl::OUString& aPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+
+ if ( aString.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION) )
+ {
+ bFilteredRangeSelection = ScUnoHelpFunctions::GetBoolFromAny(aValue);
+ return;
+ }
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ const ScViewOptions& rOldOpt = pViewSh->GetViewData()->GetOptions();
+ ScViewOptions aNewOpt(rOldOpt);
+
+ if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) )
+ aNewOpt.SetOption( VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) )
+ aNewOpt.SetOption( VOPT_HSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) )
+ aNewOpt.SetOption( VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) )
+ aNewOpt.SetOption( VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) )
+ aNewOpt.SetOption( VOPT_ANCHOR, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) )
+ aNewOpt.SetOption( VOPT_FORMULAS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) )
+ aNewOpt.SetOption( VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) )
+ aNewOpt.SetOption( VOPT_HELPLINES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) )
+ aNewOpt.SetOption( VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) )
+ aNewOpt.SetOption( VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) )
+ aNewOpt.SetOption( VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) )
+ aNewOpt.SetOption( VOPT_SOLIDHANDLES, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) )
+ aNewOpt.SetOption( VOPT_SYNTAX, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) )
+ aNewOpt.SetOption( VOPT_VSCROLL, ScUnoHelpFunctions::GetBoolFromAny( aValue ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) )
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ {
+ //#i80528# adapt to new range eventually
+ if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
+
+ aNewOpt.SetObjMode( VOBJ_TYPE_OLE, (ScVObjMode)nIntVal);
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) )
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ {
+ //#i80528# adapt to new range eventually
+ if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
+
+ aNewOpt.SetObjMode( VOBJ_TYPE_CHART, (ScVObjMode)nIntVal);
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) )
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ {
+ //#i80528# adapt to new range eventually
+ if((sal_Int16)VOBJ_MODE_HIDE < nIntVal) nIntVal = (sal_Int16)VOBJ_MODE_SHOW;
+
+ aNewOpt.SetObjMode( VOBJ_TYPE_DRAW, (ScVObjMode)nIntVal);
+ }
+ }
+ else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) )
+ {
+ sal_Int32 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ aNewOpt.SetGridColor( nIntVal, String() );
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) )
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ SetZoomType(nIntVal);
+ }
+ else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) )
+ {
+ sal_Int16 nIntVal = 0;
+ if ( aValue >>= nIntVal )
+ SetZoom(nIntVal);
+ }
+
+ // Optionen werden an der View und am Dokument (fuer neue Views) gesetzt,
+ // damit sie beim Speichern erhalten bleiben.
+ //! An der App (Module) braeuchte man noch eine Extra-Moeglichkeit,
+ //! das einzustellen (fuer neue Dokumente)
+
+ if ( aNewOpt != rOldOpt )
+ {
+ pViewData->SetOptions( aNewOpt );
+ pViewData->GetDocument()->SetViewOptions( aNewOpt );
+ pViewData->GetDocShell()->SetDocumentModified(); //! wirklich?
+
+ pViewSh->UpdateFixPos();
+ pViewSh->PaintGrid();
+ pViewSh->PaintTop();
+ pViewSh->PaintLeft();
+ pViewSh->PaintExtras();
+ pViewSh->InvalidateBorder();
+
+ SfxBindings& rBindings = pViewSh->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue
+ rBindings.Invalidate( FID_TOGGLESYNTAX );
+ }
+ }
+}
+
+uno::Any SAL_CALL ScTabViewObj::getPropertyValue( const rtl::OUString& aPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ String aString(aPropertyName);
+ uno::Any aRet;
+
+ if ( aString.EqualsAscii(SC_UNO_FILTERED_RANGE_SELECTION) )
+ {
+ ScUnoHelpFunctions::SetBoolInAny(aRet, bFilteredRangeSelection);
+ return aRet;
+ }
+
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ const ScViewOptions& rOpt = pViewSh->GetViewData()->GetOptions();
+
+ if ( aString.EqualsAscii( SC_UNO_COLROWHDR ) || aString.EqualsAscii( OLD_UNO_COLROWHDR ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HEADER ) );
+ else if ( aString.EqualsAscii( SC_UNO_HORSCROLL ) || aString.EqualsAscii( OLD_UNO_HORSCROLL ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HSCROLL ) );
+ else if ( aString.EqualsAscii( SC_UNO_OUTLSYMB ) || aString.EqualsAscii( OLD_UNO_OUTLSYMB ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_OUTLINER ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHEETTABS ) || aString.EqualsAscii( OLD_UNO_SHEETTABS ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_TABCONTROLS ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWANCHOR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_ANCHOR ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWFORM ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_FORMULAS ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWGRID ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_GRID ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWHELP ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_HELPLINES ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWNOTES ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NOTES ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWPAGEBR ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_PAGEBREAKS ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWZERO ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_NULLVALS ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWSOLID ) ) ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SOLIDHANDLES ) );
+ else if ( aString.EqualsAscii( SC_UNO_VALUEHIGH ) || aString.EqualsAscii( OLD_UNO_VALUEHIGH ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_SYNTAX ) );
+ else if ( aString.EqualsAscii( SC_UNO_VERTSCROLL ) || aString.EqualsAscii( OLD_UNO_VERTSCROLL ) )
+ ScUnoHelpFunctions::SetBoolInAny( aRet, rOpt.GetOption( VOPT_VSCROLL ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWOBJ ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_OLE ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWCHARTS ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_CHART ) );
+ else if ( aString.EqualsAscii( SC_UNO_SHOWDRAW ) ) aRet <<= (sal_Int16)( rOpt.GetObjMode( VOBJ_TYPE_DRAW ) );
+ else if ( aString.EqualsAscii( SC_UNO_GRIDCOLOR ) ) aRet <<= (sal_Int32)( rOpt.GetGridColor().GetColor() );
+ else if ( aString.EqualsAscii( SC_UNO_VISAREA ) ) aRet <<= GetVisArea();
+ else if ( aString.EqualsAscii( SC_UNO_ZOOMTYPE ) ) aRet <<= GetZoomType();
+ else if ( aString.EqualsAscii( SC_UNO_ZOOMVALUE ) ) aRet <<= GetZoom();
+ }
+
+ return aRet;
+}
+
+void SAL_CALL ScTabViewObj::addPropertyChangeListener( const ::rtl::OUString& /* aPropertyName */,
+ const uno::Reference<beans::XPropertyChangeListener >& xListener )
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<beans::XPropertyChangeListener>* pObj =
+ new uno::Reference<beans::XPropertyChangeListener>( xListener );
+ aPropertyChgListeners.Insert( pObj, aPropertyChgListeners.Count() );
+}
+
+void SAL_CALL ScTabViewObj::removePropertyChangeListener( const ::rtl::OUString& /* aPropertyName */,
+ const uno::Reference<beans::XPropertyChangeListener >& xListener )
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aPropertyChgListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<beans::XPropertyChangeListener> *pObj = aPropertyChgListeners[n];
+ if ( *pObj == xListener ) //! wozu der Mumpitz mit queryInterface?
+ {
+ aPropertyChgListeners.DeleteAndDestroy( n );
+ break;
+ }
+ }
+}
+
+void SAL_CALL ScTabViewObj::addVetoableChangeListener( const ::rtl::OUString& /* PropertyName */,
+ const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+}
+
+void SAL_CALL ScTabViewObj::removeVetoableChangeListener( const ::rtl::OUString& /* PropertyName */,
+ const uno::Reference<beans::XVetoableChangeListener >& /* aListener */ )
+ throw(beans::UnknownPropertyException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+}
+
+void ScTabViewObj::VisAreaChanged()
+{
+ beans::PropertyChangeEvent aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ for ( USHORT n=0; n<aPropertyChgListeners.Count(); n++ )
+ (*aPropertyChgListeners[n])->propertyChange( aEvent );
+}
+
+// XRangeSelection
+
+void SAL_CALL ScTabViewObj::startRangeSelection(
+ const uno::Sequence<beans::PropertyValue>& aArguments )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ {
+ String aInitVal, aTitle;
+ BOOL bCloseOnButtonUp = FALSE;
+ BOOL bSingleCell = FALSE;
+ BOOL bMultiSelection = FALSE;
+
+ rtl::OUString aStrVal;
+ const beans::PropertyValue* pPropArray = aArguments.getConstArray();
+ long nPropCount = aArguments.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNONAME_CLOSEONUP ))
+ bCloseOnButtonUp = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_TITLE ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aTitle = String( aStrVal );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_INITVAL ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aInitVal = String( aStrVal );
+ }
+ else if (aPropName.EqualsAscii( SC_UNONAME_SINGLECELL ))
+ bSingleCell = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ else if (aPropName.EqualsAscii( SC_UNONAME_MULTISEL ))
+ bMultiSelection = ScUnoHelpFunctions::GetBoolFromAny( rProp.Value );
+ }
+
+ pViewSh->StartSimpleRefDialog( aTitle, aInitVal, bCloseOnButtonUp, bSingleCell, bMultiSelection );
+ }
+}
+
+void SAL_CALL ScTabViewObj::abortRangeSelection() throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScTabViewShell* pViewSh = GetViewShell();
+ if (pViewSh)
+ pViewSh->StopSimpleRefDialog();
+}
+
+void SAL_CALL ScTabViewObj::addRangeSelectionListener(
+ const uno::Reference<sheet::XRangeSelectionListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XRangeSelectionListener>* pObj =
+ new uno::Reference<sheet::XRangeSelectionListener>( xListener );
+ aRangeSelListeners.Insert( pObj, aRangeSelListeners.Count() );
+}
+
+void SAL_CALL ScTabViewObj::removeRangeSelectionListener(
+ const uno::Reference<sheet::XRangeSelectionListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aRangeSelListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<sheet::XRangeSelectionListener> *pObj = aRangeSelListeners[n];
+ if ( *pObj == xListener )
+ {
+ aRangeSelListeners.DeleteAndDestroy( n );
+ break;
+ }
+ }
+}
+
+void SAL_CALL ScTabViewObj::addRangeSelectionChangeListener(
+ const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ uno::Reference<sheet::XRangeSelectionChangeListener>* pObj =
+ new uno::Reference<sheet::XRangeSelectionChangeListener>( xListener );
+ aRangeChgListeners.Insert( pObj, aRangeChgListeners.Count() );
+}
+
+void SAL_CALL ScTabViewObj::removeRangeSelectionChangeListener(
+ const uno::Reference<sheet::XRangeSelectionChangeListener>& xListener )
+ throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ USHORT nCount = aRangeChgListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<sheet::XRangeSelectionChangeListener> *pObj = aRangeChgListeners[n];
+ if ( *pObj == xListener )
+ {
+ aRangeChgListeners.DeleteAndDestroy( n );
+ break;
+ }
+ }
+}
+
+void ScTabViewObj::RangeSelDone( const String& rText )
+{
+ sheet::RangeSelectionEvent aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ aEvent.RangeDescriptor = rtl::OUString( rText );
+
+ for ( USHORT n=0; n<aRangeSelListeners.Count(); n++ )
+ (*aRangeSelListeners[n])->done( aEvent );
+}
+
+void ScTabViewObj::RangeSelAborted( const String& rText )
+{
+ sheet::RangeSelectionEvent aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ aEvent.RangeDescriptor = rtl::OUString( rText );
+
+ for ( USHORT n=0; n<aRangeSelListeners.Count(); n++ )
+ (*aRangeSelListeners[n])->aborted( aEvent );
+}
+
+void ScTabViewObj::RangeSelChanged( const String& rText )
+{
+ sheet::RangeSelectionEvent aEvent;
+ aEvent.Source.set(static_cast<cppu::OWeakObject*>(this));
+ aEvent.RangeDescriptor = rtl::OUString( rText );
+
+ for ( USHORT n=0; n<aRangeChgListeners.Count(); n++ )
+ (*aRangeChgListeners[n])->descriptorChanged( aEvent );
+}
+
+// XServiceInfo
+
+rtl::OUString SAL_CALL ScTabViewObj::getImplementationName() throw(uno::RuntimeException)
+{
+ return rtl::OUString::createFromAscii( "ScTabViewObj" );
+}
+
+sal_Bool SAL_CALL ScTabViewObj::supportsService( const rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ String aServiceStr( rServiceName );
+ return aServiceStr.EqualsAscii( SCTABVIEWOBJ_SERVICE ) ||
+ aServiceStr.EqualsAscii( SCVIEWSETTINGS_SERVICE );
+}
+
+uno::Sequence<rtl::OUString> SAL_CALL ScTabViewObj::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ uno::Sequence<rtl::OUString> aRet(2);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = rtl::OUString::createFromAscii( SCTABVIEWOBJ_SERVICE );
+ pArray[1] = rtl::OUString::createFromAscii( SCVIEWSETTINGS_SERVICE );
+ return aRet;
+}
+
+// XUnoTunnel
+
+sal_Int64 SAL_CALL ScTabViewObj::getSomething(
+ const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException)
+{
+ if ( rId.getLength() == 16 &&
+ 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
+ }
+ return 0;
+}
+
+// static
+const uno::Sequence<sal_Int8>& ScTabViewObj::getUnoTunnelId()
+{
+ static uno::Sequence<sal_Int8> * pSeq = 0;
+ if( !pSeq )
+ {
+ osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
+ if( !pSeq )
+ {
+ static uno::Sequence< sal_Int8 > aSeq( 16 );
+ rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
+ pSeq = &aSeq;
+ }
+ }
+ return *pSeq;
+}
+
+// static
+ScTabViewObj* ScTabViewObj::getImplementation( const uno::Reference<uno::XInterface> xObj )
+{
+ ScTabViewObj* pRet = NULL;
+ uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY );
+ if (xUT.is())
+ pRet = reinterpret_cast<ScTabViewObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId())));
+ return pRet;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > SAL_CALL ScTabViewObj::getTransferable( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
+ if (pShell)
+ return pShell->GetEditView()->GetTransferable();
+
+ ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
+ if (pTextShell)
+ {
+ ScViewData* pViewData = GetViewShell()->GetViewData();
+ ScDrawView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ if (pOutView)
+ return pOutView->GetEditView().GetTransferable();
+ }
+
+ ScDrawShell* pDrawShell = PTR_CAST( ScDrawShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
+ if (pDrawShell)
+ return pDrawShell->GetDrawView()->CopyToTransferable();
+
+ ScTransferObj* pObj = GetViewShell()->CopyToTransferable();
+ uno::Reference<datatransfer::XTransferable> xTransferable( pObj );
+ return xTransferable;
+}
+
+void SAL_CALL ScTabViewObj::insertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTrans ) throw (::com::sun::star::datatransfer::UnsupportedFlavorException, ::com::sun::star::uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ScEditShell* pShell = PTR_CAST( ScEditShell, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
+ if (pShell)
+ pShell->GetEditView()->InsertText( xTrans, ::rtl::OUString(), FALSE );
+ else
+ {
+ ScDrawTextObjectBar* pTextShell = PTR_CAST( ScDrawTextObjectBar, GetViewShell()->GetViewFrame()->GetDispatcher()->GetShell(0) );
+ if (pTextShell)
+ {
+ ScViewData* pViewData = GetViewShell()->GetViewData();
+ ScDrawView* pView = pViewData->GetScDrawView();
+ OutlinerView* pOutView = pView->GetTextEditOutlinerView();
+ if ( pOutView )
+ {
+ pOutView->GetEditView().InsertText( xTrans, ::rtl::OUString(), FALSE );
+ return;
+ }
+ }
+
+ GetViewShell()->PasteFromTransferable( xTrans );
+ }
+}
+
+//------------------------------------------------------------------------
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/unoobj/warnpassword.cxx b/sc/source/ui/unoobj/warnpassword.cxx
new file mode 100644
index 000000000000..426644d9f736
--- /dev/null
+++ b/sc/source/ui/unoobj/warnpassword.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// ============================================================================
+#include "warnpassword.hxx"
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/task/XInteractionRequest.hpp>
+#include <svl/itemset.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <ucbhelper/simpleinteractionrequest.hxx>
+#include <com/sun/star/task/InteractionClassification.hpp>
+#include <com/sun/star/ucb/InteractiveAppException.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <svx/svxerr.hxx>
+
+
+using ::rtl::OUString;
+using ::com::sun::star::uno::makeAny;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::task::InteractionClassification_QUERY;
+using ::com::sun::star::task::XInteractionHandler;
+using ::com::sun::star::task::XInteractionRequest;
+using ::com::sun::star::ucb::InteractiveAppException;
+
+bool ScWarnPassword::WarningOnPassword( SfxMedium& rMedium )
+{
+ bool bReturn = true;
+ Reference< XInteractionHandler > xHandler( rMedium.GetInteractionHandler());
+ if( xHandler.is() )
+ {
+
+ OUString empty;
+ Any xException( makeAny(InteractiveAppException(empty,
+ Reference <XInterface> (),
+ InteractionClassification_QUERY,
+ ERRCODE_SVX_EXPORT_FILTER_CRYPT)));
+
+ Reference< ucbhelper::SimpleInteractionRequest > xRequest
+ = new ucbhelper::SimpleInteractionRequest(
+ xException,
+ ucbhelper::CONTINUATION_APPROVE
+ | ucbhelper::CONTINUATION_DISAPPROVE );
+
+ xHandler->handle( xRequest.get() );
+
+ const sal_Int32 nResp = xRequest->getResponse();
+
+ switch ( nResp )
+ {
+ case ucbhelper::CONTINUATION_UNKNOWN:
+ break;
+
+ case ucbhelper::CONTINUATION_APPROVE:
+ // Continue
+ break;
+
+ case ucbhelper::CONTINUATION_DISAPPROVE:
+ bReturn = false;
+ break;
+ }
+ }
+ return bReturn;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx
new file mode 100644
index 000000000000..3ca5ba861dc8
--- /dev/null
+++ b/sc/source/ui/vba/excelvbahelper.cxx
@@ -0,0 +1,437 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <docuno.hxx>
+#include "excelvbahelper.hxx"
+#include "tabvwsh.hxx"
+#include "transobj.hxx"
+#include "scmod.hxx"
+#include "cellsuno.hxx"
+#include "compiler.hxx"
+#include "token.hxx"
+#include "tokenarray.hxx"
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+namespace ooo
+{
+namespace vba
+{
+namespace excel
+{
+
+uno::Reference< sheet::XDatabaseRanges >
+GetDataBaseRanges( ScDocShell* pShell ) throw ( uno::RuntimeException )
+{
+ uno::Reference< frame::XModel > xModel;
+ if ( pShell )
+ xModel.set( pShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xModelProps( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XDatabaseRanges > xDBRanges( xModelProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges") ) ), uno::UNO_QUERY_THROW );
+ return xDBRanges;
+}
+
+// returns the XDatabaseRange for the autofilter on sheet (nSheet)
+// also populates sName with the name of range
+uno::Reference< sheet::XDatabaseRange >
+GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XIndexAccess > xIndexAccess( GetDataBaseRanges( pShell ), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XDatabaseRange > xDataBaseRange;
+ table::CellRangeAddress dbAddress;
+ for ( sal_Int32 index=0; index < xIndexAccess->getCount(); ++index )
+ {
+ uno::Reference< sheet::XDatabaseRange > xDBRange( xIndexAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNamed > xNamed( xDBRange, uno::UNO_QUERY_THROW );
+ // autofilters work weirdly with openoffice, unnamed is the default
+ // named range which is used to create an autofilter, but
+ // its also possible that another name could be used
+ // this also causes problems when an autofilter is created on
+ // another sheet
+ // ( but.. you can use any named range )
+ dbAddress = xDBRange->getDataArea();
+ if ( dbAddress.Sheet == nSheet )
+ {
+ sal_Bool bHasAuto = sal_False;
+ uno::Reference< beans::XPropertySet > xProps( xDBRange, uno::UNO_QUERY_THROW );
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ) ) >>= bHasAuto;
+ if ( bHasAuto )
+ {
+ sName = xNamed->getName();
+ xDataBaseRange=xDBRange;
+ break;
+ }
+ }
+ }
+ return xDataBaseRange;
+}
+
+ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException )
+{
+ ScCellRangesBase* pScCellRangesBase = ScCellRangesBase::getImplementation( xRange );
+ if ( !pScCellRangesBase )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying doc shell uno range object" ) ), uno::Reference< uno::XInterface >() );
+ }
+ return pScCellRangesBase->GetDocShell();
+}
+
+ScDocShell* GetDocShellFromRanges( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException )
+{
+ // need the ScCellRangesBase to get docshell
+ uno::Reference< uno::XInterface > xIf( xRanges, uno::UNO_QUERY_THROW );
+ return GetDocShellFromRange( xIf );
+}
+
+ScDocument* GetDocumentFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException )
+{
+ ScDocShell* pDocShell = GetDocShellFromRange( xRange );
+ if ( !pDocShell )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying document from uno range object" ) ), uno::Reference< uno::XInterface >() );
+ }
+ return pDocShell->GetDocument();
+}
+
+uno::Reference< frame::XModel > GetModelFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException )
+{
+ ScDocShell* pDocShell = GetDocShellFromRange( xRange );
+ if ( !pDocShell )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying model uno range object" ) ), uno::Reference< uno::XInterface >() );
+ }
+ return pDocShell->GetModel();
+}
+
+void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs )
+{
+ ScTabViewShell* pViewSh = excel::getBestViewShell( xModel );
+ Fraction aFract( nZoom, 100 );
+ pViewSh->GetViewData()->SetZoom( aFract, aFract, nTabs );
+ pViewSh->RefreshZoom();
+}
+bool isInPrintPreview( SfxViewFrame* pView )
+{
+ sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0;
+ if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() >
+nViewNo && !pView->GetObjectShell()->IsInPlaceActive() )
+ {
+ SfxViewFactory &rViewFactory =
+ pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
+ if ( pView->GetCurViewId() == rViewFactory.GetOrdinal() )
+ return true;
+ }
+ return false;
+}
+
+const ::rtl::OUString REPLACE_CELLS_WARNING( RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning"));
+
+class PasteCellsWarningReseter
+{
+private:
+ bool bInitialWarningState;
+ static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
+ {
+ static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
+ xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW );
+ return xProps;
+ }
+
+ bool getReplaceCellsWarning() throw ( uno::RuntimeException )
+ {
+ sal_Bool res = sal_False;
+ getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res;
+ return ( res == sal_True );
+ }
+
+ void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException )
+ {
+ getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) );
+ }
+public:
+ PasteCellsWarningReseter() throw ( uno::RuntimeException )
+ {
+ bInitialWarningState = getReplaceCellsWarning();
+ if ( bInitialWarningState )
+ setReplaceCellsWarning( false );
+ }
+ ~PasteCellsWarningReseter()
+ {
+ if ( bInitialWarningState )
+ {
+ // don't allow dtor to throw
+ try
+ {
+ setReplaceCellsWarning( true );
+ }
+ catch ( uno::Exception& /*e*/ ){}
+ }
+ }
+};
+
+void
+implnPaste( const uno::Reference< frame::XModel>& xModel )
+{
+ PasteCellsWarningReseter resetWarningBox;
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ {
+ pViewShell->PasteFromSystem();
+ pViewShell->CellContentChanged();
+ }
+}
+
+
+void
+implnCopy( const uno::Reference< frame::XModel>& xModel )
+{
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ pViewShell->CopyToClip(NULL,false,false,true);
+}
+
+void
+implnCut( const uno::Reference< frame::XModel>& xModel )
+{
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ pViewShell->CutToClip( NULL, TRUE );
+}
+
+void implnPasteSpecial( const uno::Reference< frame::XModel>& xModel, USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose)
+{
+ PasteCellsWarningReseter resetWarningBox;
+ sal_Bool bAsLink(sal_False), bOtherDoc(sal_False);
+ InsCellCmd eMoveMode = INS_NONE;
+
+ ScTabViewShell* pTabViewShell = getBestViewShell( xModel );
+ if ( pTabViewShell )
+ {
+ ScViewData* pView = pTabViewShell->GetViewData();
+ Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL;
+ if ( pView && pWin )
+ {
+ if ( bAsLink && bOtherDoc )
+ pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK
+ else
+ {
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ ScDocument* pDoc = NULL;
+ if ( pOwnClip )
+ pDoc = pOwnClip->GetDocument();
+ pTabViewShell->PasteFromClip( nFlags, pDoc,
+ nFunction, bSkipEmpty, bTranspose, bAsLink,
+ eMoveMode, IDF_NONE, TRUE );
+ pTabViewShell->CellContentChanged();
+ }
+ }
+ }
+
+}
+
+void implnCopyRange( const uno::Reference< frame::XModel>& xModel, const ScRange& rRange )
+{
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ {
+ pViewShell->CopyToClip( NULL, rRange, FALSE, TRUE, TRUE );
+ }
+}
+
+ScDocShell*
+getDocShell( const css::uno::Reference< css::frame::XModel>& xModel )
+{
+ uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW );
+ ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() );
+ ScDocShell* pDocShell = NULL;
+ if ( pModel )
+ pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
+ return pDocShell;
+
+}
+
+ScTabViewShell*
+getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel )
+{
+ ScDocShell* pDocShell = getDocShell( xModel );
+ if ( pDocShell )
+ return pDocShell->GetBestViewShell();
+ return NULL;
+}
+
+ScTabViewShell*
+getCurrentBestViewShell( const uno::Reference< uno::XComponentContext >& xContext )
+{
+ uno::Reference< frame::XModel > xModel = getCurrentExcelDoc( xContext );
+ return getBestViewShell( xModel );
+}
+
+SfxViewFrame*
+getViewFrame( const uno::Reference< frame::XModel >& xModel )
+{
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ if ( pViewShell )
+ return pViewShell->GetViewFrame();
+ return NULL;
+}
+
+sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const rtl::OUString& sRangeStr )
+{
+ ScRangeList aCellRanges;
+ String sAddress( sRangeStr );
+ USHORT nMask = SCA_VALID;
+ USHORT rResFlags = aCellRanges.Parse( sAddress, pDoc, nMask, formula::FormulaGrammar::CONV_XL_R1C1 );
+ if ( rResFlags & SCA_VALID )
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
+uno::Reference< XHelperInterface >
+getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException )
+{
+ uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
+ rtl::OUString sCodeName;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName;
+ // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible
+ // to create a module ( and use 'Option VBASupport 1' ) for a calc document, in this scenario there
+ // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at
+ // the document in the future could fix this, especially IF the switching of the vba mode takes care to
+ // create the special document module objects if they don't exist.
+ uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xRange ) ), uno::UNO_QUERY );
+
+ return xParent;
+}
+
+formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula )
+{
+ formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
+ if ( pDoc && aFormula.hasValue() && aFormula.getValueTypeClass() == uno::TypeClass_STRING )
+ {
+ rtl::OUString sFormula;
+ aFormula >>= sFormula;
+
+ ScCompiler aCompiler( pDoc, sAddress );
+ aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+ ScTokenArray* pCode = aCompiler.CompileString( sFormula );
+ if ( pCode )
+ {
+ USHORT nLen = pCode->GetLen();
+ formula::FormulaToken** pTokens = pCode->GetArray();
+ for ( USHORT nPos = 0; nPos < nLen; nPos++ )
+ {
+ const formula::FormulaToken& rToken = *pTokens[nPos];
+ switch ( rToken.GetType() )
+ {
+ case formula::svSingleRef:
+ case formula::svDoubleRef:
+ {
+ return formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+ }
+ break;
+ default: break;
+ }
+ }
+ }
+ }
+ return eGrammar;
+}
+
+void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula )
+{
+ if ( !pDoc )
+ {
+ return;
+ }
+ ScCompiler aCompiler( pDoc, ScAddress() );
+ aCompiler.SetGrammar( excel::GetFormulaGrammar( pDoc, ScAddress(), uno::Any( rtl::OUString( rOldFormula ) ) ) );
+ ScTokenArray* pCode = aCompiler.CompileString( rOldFormula );
+ aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
+ aCompiler.CreateStringFromTokenArray( rNewFormula );
+}
+
+void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar )
+{
+ // eGrammar can be formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 and formula::FormulaGrammar::GRAM_NATIVE_XL_A1
+ if ( !pDoc )
+ {
+ return;
+ }
+ ScCompiler aCompiler( pDoc, ScAddress() );
+ aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
+ ScTokenArray* pCode = aCompiler.CompileString( rOldFormula );
+ aCompiler.SetGrammar( eGrammar );
+ if ( !pCode )
+ {
+ return;
+ }
+ USHORT nLen = pCode->GetLen();
+ formula::FormulaToken** pTokens = pCode->GetArray();
+ for ( USHORT nPos = 0; nPos < nLen && pTokens[nPos]; nPos++ )
+ {
+ String rFormula;
+ formula::FormulaToken* pToken = pTokens[nPos];
+ aCompiler.CreateStringFromToken( rFormula, pToken, TRUE );
+ if ( pToken->GetOpCode() == ocSep )
+ {
+ // Excel formula separator is ",".
+ rFormula = String::CreateFromAscii(",");
+ }
+ rNewFormula += rFormula;
+ }
+}
+
+uno::Reference< XHelperInterface >
+getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( xRanges, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration();
+ uno::Reference< table::XCellRange > xRange( xEnum->nextElement(), uno::UNO_QUERY_THROW );
+
+ return getUnoSheetModuleObj( xRange );
+}
+
+SfxItemSet*
+ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj )
+{
+ return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0;
+}
+
+
+} //excel
+} //vba
+} //ooo
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx
new file mode 100644
index 000000000000..bdab4fd28ddb
--- /dev/null
+++ b/sc/source/ui/vba/excelvbahelper.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_EXCEL_VBA_HELPER_HXX
+#define SC_EXCEL_VBA_HELPER_HXX
+
+#include<vbahelper/vbahelper.hxx>
+#include <docsh.hxx>
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
+#include <ooo/vba/XHelperInterface.hpp>
+#include <formula/grammar.hxx>
+
+class ScCellRangesBase;
+
+namespace ooo
+{
+ namespace vba
+ {
+ namespace excel
+ {
+ // nTabs empty means apply zoom to all sheets
+ void implSetZoom( const css::uno::Reference< css::frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs );
+ void implnCopy( const css::uno::Reference< css::frame::XModel>& xModel );
+ void implnPaste ( const css::uno::Reference< css::frame::XModel>& xModel );
+ void implnCut( const css::uno::Reference< css::frame::XModel>& xModel );
+ void implnPasteSpecial( const css::uno::Reference< css::frame::XModel>& xModel, sal_uInt16 nFlags,sal_uInt16 nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose);
+ void implnCopyRange( const css::uno::Reference< css::frame::XModel>& xModel, const ScRange& rRange );
+ ScTabViewShell* getBestViewShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
+ ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ;
+ ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel );
+ sal_Bool IsR1C1ReferFormat( ScDocument* pDoc, const ::rtl::OUString& sRangeStr );
+ formula::FormulaGrammar::Grammar GetFormulaGrammar( ScDocument* pDoc, const ScAddress& sAddress, const css::uno::Any& aFormula );
+ void CompileExcelFormulaToODF( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula );
+ void CompileODFFormulaToExcel( ScDocument* pDoc, const String& rOldFormula, String& rNewFormula, const formula::FormulaGrammar::Grammar eGrammar );
+ css::uno::Reference< css::sheet::XDatabaseRanges > GetDataBaseRanges( ScDocShell* pShell ) throw ( css::uno::RuntimeException );
+
+ css::uno::Reference< css::sheet::XDatabaseRange > GetAutoFiltRange( ScDocShell* pShell, sal_Int16 nSheet, rtl::OUString& sName ) throw ( css::uno::RuntimeException );
+ css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
+ css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException );
+ ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
+ ScDocShell* GetDocShellFromRanges( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException );
+ ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
+ css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException );
+
+ class ScVbaCellRangeAccess
+ {
+ public:
+ static SfxItemSet* GetDataSet( ScCellRangesBase* pRangeObj );
+ };
+ }
+ }
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/helperdecl.hxx b/sc/source/ui/vba/helperdecl.hxx
new file mode 100644
index 000000000000..4a0d0d3c01c6
--- /dev/null
+++ b/sc/source/ui/vba/helperdecl.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <comphelper/servicedecl.hxx>
+#include <ooo/vba/XHelperInterface.hpp>
+
+namespace comphelper {
+namespace service_decl {
+template <typename ImplT_, typename WithArgsT = with_args<false> >
+struct vba_service_class_ : public serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT >
+{
+ typedef serviceimpl_base< detail::OwnServiceImpl<ImplT_>, WithArgsT > baseT;
+ /** Default ctor. Implementation class without args, expecting
+ component context as single argument.
+ */
+ vba_service_class_() : baseT() {}
+ template <typename PostProcessFuncT>
+ /** Ctor to pass a post processing function/functor.
+
+ @tpl PostProcessDefaultT let your compiler deduce this
+ @param postProcessFunc function/functor that gets the yet unacquired
+ ImplT_ pointer returning a
+ uno::Reference<uno::XInterface>
+ */
+ explicit vba_service_class_( PostProcessFuncT const& postProcessFunc ) : baseT( postProcessFunc ) {}
+};
+
+} // namespace service_decl
+} // namespace comphelper
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk
new file mode 100644
index 000000000000..ba50cbad9abd
--- /dev/null
+++ b/sc/source/ui/vba/makefile.mk
@@ -0,0 +1,136 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=vbaobj
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+CDEFS+=-DVBA_OOBUILD_HACK
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+DLLPRE =
+
+.IF "$(ENABLE_VBA)"!="YES"
+dummy:
+ @echo "not building vba..."
+.ENDIF
+.IF "$(L10N_framework)"==""
+INCPRE=$(INCCOM)$/$(TARGET)
+
+# ------------------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/excelvbahelper.obj \
+ $(SLO)$/service.obj \
+ $(SLO)$/vbaapplication.obj \
+ $(SLO)$/vbaassistant.obj \
+ $(SLO)$/vbaaxes.obj \
+ $(SLO)$/vbaaxis.obj \
+ $(SLO)$/vbaaxistitle.obj \
+ $(SLO)$/vbaborders.obj \
+ $(SLO)$/vbacharacters.obj \
+ $(SLO)$/vbachart.obj \
+ $(SLO)$/vbachartobject.obj \
+ $(SLO)$/vbachartobjects.obj \
+ $(SLO)$/vbacharts.obj \
+ $(SLO)$/vbacharttitle.obj \
+ $(SLO)$/vbacomment.obj \
+ $(SLO)$/vbacomments.obj \
+ $(SLO)$/vbacommentshape.obj \
+ $(SLO)$/vbacondition.obj \
+ $(SLO)$/vbadialog.obj \
+ $(SLO)$/vbadialogs.obj \
+ $(SLO)$/vbaeventshelper.obj \
+ $(SLO)$/vbafiledialog.obj \
+ $(SLO)$/vbafiledialogselecteditems.obj \
+ $(SLO)$/vbafilesearch.obj \
+ $(SLO)$/vbafont.obj \
+ $(SLO)$/vbaformat.obj \
+ $(SLO)$/vbaformatcondition.obj \
+ $(SLO)$/vbaformatconditions.obj \
+ $(SLO)$/vbafoundfiles.obj \
+ $(SLO)$/vbaglobals.obj \
+ $(SLO)$/vbahyperlink.obj \
+ $(SLO)$/vbahyperlinks.obj \
+ $(SLO)$/vbainterior.obj \
+ $(SLO)$/vbamenubar.obj \
+ $(SLO)$/vbamenubars.obj \
+ $(SLO)$/vbamenu.obj \
+ $(SLO)$/vbamenus.obj \
+ $(SLO)$/vbamenuitem.obj \
+ $(SLO)$/vbamenuitems.obj \
+ $(SLO)$/vbaname.obj \
+ $(SLO)$/vbanames.obj \
+ $(SLO)$/vbaoleobject.obj \
+ $(SLO)$/vbaoleobjects.obj \
+ $(SLO)$/vbaoutline.obj \
+ $(SLO)$/vbapagebreak.obj \
+ $(SLO)$/vbapagebreaks.obj \
+ $(SLO)$/vbapagesetup.obj \
+ $(SLO)$/vbapalette.obj \
+ $(SLO)$/vbapane.obj \
+ $(SLO)$/vbapivotcache.obj \
+ $(SLO)$/vbapivottable.obj \
+ $(SLO)$/vbapivottables.obj \
+ $(SLO)$/vbaquerytable.obj \
+ $(SLO)$/vbarange.obj \
+ $(SLO)$/vbaseriescollection.obj \
+ $(SLO)$/vbasheetobject.obj \
+ $(SLO)$/vbasheetobjects.obj \
+ $(SLO)$/vbastyle.obj \
+ $(SLO)$/vbastyles.obj \
+ $(SLO)$/vbatextboxshape.obj \
+ $(SLO)$/vbatextframe.obj \
+ $(SLO)$/vbavalidation.obj \
+ $(SLO)$/vbawindow.obj \
+ $(SLO)$/vbawindows.obj \
+ $(SLO)$/vbaworkbook.obj \
+ $(SLO)$/vbaworkbooks.obj \
+ $(SLO)$/vbaworksheet.obj \
+ $(SLO)$/vbaworksheets.obj \
+ $(SLO)$/vbawsfunction.obj
+
+.ENDIF
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(L10N_framework)"==""
+
+ALLTAR : \
+ $(MISC)$/$(TARGET).don \
+
+$(SLOFILES) : $(MISC)$/$(TARGET).don
+
+$(MISC)$/$(TARGET).don : $(SOLARBINDIR)$/oovbaapi.rdb
+ +$(CPPUMAKER) -O$(INCCOM)$/$(TARGET) -BUCR $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@
+ echo $@
+
+.ENDIF
diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx
new file mode 100644
index 000000000000..875424fc54ea
--- /dev/null
+++ b/sc/source/ui/vba/service.cxx
@@ -0,0 +1,137 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "cppuhelper/implementationentry.hxx"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "comphelper/servicedecl.hxx"
+
+// =============================================================================
+// component exports
+// =============================================================================
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace sdecl = comphelper::service_decl;
+
+// reference service helper(s)
+namespace range
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace workbook
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace worksheet
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace window
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace globals
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace hyperlink
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace application
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace vbaeventshelper
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+namespace textframe
+{
+extern sdecl::ServiceDecl const serviceDecl;
+}
+
+extern "C"
+{
+ SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+ {
+ OSL_TRACE("In component_getImplementationEnv");
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
+ {
+ OSL_TRACE("In component_writeInfo");
+#if 0
+ // Component registration
+ if ( component_writeInfoHelper( pServiceManager, pRegistryKey,
+ range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
+ {
+ // Singleton registration
+ try
+ {
+ registry::XRegistryKey * pKey =
+ reinterpret_cast< registry::XRegistryKey * >(pRegistryKey);
+
+ Reference< registry::XRegistryKey >xKey = pKey->createKey(
+ rtl::OUString::createFromAscii( ("ooo.vba.Globals/UNO/SINGLETONS/ooo.vba.theGlobals") ) );
+ xKey->setStringValue( ::rtl::OUString::createFromAscii(
+ ("ooo.vba.Globals") ) );
+ return sal_True;
+ }
+ catch( uno::Exception& /*e*/ )
+ {
+ //recomp & friends will detect false returned and fail
+ }
+ }
+ return sal_False;
+#else
+ // Component registration
+ return component_writeInfoHelper( pServiceManager, pRegistryKey,
+ range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl );
+#endif
+
+ }
+
+ SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
+ registry::XRegistryKey * pRegistryKey )
+ {
+ OSL_TRACE("In component_getFactory for %s", pImplName );
+ void* pRet = component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl );
+ if( !pRet )
+ pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl );
+ OSL_TRACE("Ret is 0x%x", pRet);
+ return pRet;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/testvba/README b/sc/source/ui/vba/testvba/README
new file mode 100644
index 000000000000..3a91946de8df
--- /dev/null
+++ b/sc/source/ui/vba/testvba/README
@@ -0,0 +1,37 @@
+to run the tests
+
+build
+=====
+ dmake
+
+windows
+=======
+ a) you can download a cygwin bash shell environment and install perl ( http://cygwin.com/setup.exe )
+ from the cmdline './runTests.pl $(OFFICE_PROGRAM_PATH)' should run the testclient and compare the logs
+ b) use ordinary windows perl [1], but additionally you will need the 'diff' program for window ( download from http://gnuwin32.sourceforge.net/packages/diffutils.htm )
+
+[1] for the testclient the perl ( all inclusive ) bundle from ActivePerl is mor e than adeqate ( download from http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.8.822-MSWin32-x86-280952.msi )
+
+ to run all test cases type
+ 'perl ./runTests.pl $(OFFICE_PROGRAM_PATH)'
+ to run a test case type
+ 'perl ./runTests.pl $(OFFICE_PROGRAM_PATH) testfilename'
+
+unix
+====
+
+assuming perl is installed
+ './runTests.pl $(OFFICE_PROGRAM_PATH)'
+ or './runTests.pl $(OFFICE_PROGRAM_PATH) testfilename' for one file test.
+
+
+Note: For either windows or unix all of the tests should pass ( and you should get a result like )
+Note Also: If you meat a problem that stop running test after serveral test documents have been run. please clean your .ooo-2.0 or .oooxxx first, and then re-run.
+
+========>
+
+skipped 0 test-cases(s)
+compared 9 test-case documents
+ 9 tests passedTests
+
+Note also: the testclient will attempt to connect to an existing instance of open-office, when the testClient exits the soffice process may still be running, if you wish to repeat tests you may want to kill the office instance before re-running.
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/ApplicationRunTest.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/ApplicationRunTest.xls
new file mode 100644
index 000000000000..a5a591c1f849
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/ApplicationRunTest.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/AutoFilter.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/AutoFilter.xls
new file mode 100644
index 000000000000..9b3a1043c5ee
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/AutoFilter.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcFont.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcFont.xls
new file mode 100644
index 000000000000..9ddb69600643
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcFont.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcZoom.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcZoom.xls
new file mode 100644
index 000000000000..5db47c76dbe9
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/CalcZoom.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncTests.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncTests.xls
new file mode 100644
index 000000000000..d4776b98fe1d
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncTests.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncs.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncs.xls
new file mode 100644
index 000000000000..bb8941809947
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/FinancialFuncs.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscOperatorTests.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscOperatorTests.xls
new file mode 100644
index 000000000000..23227ae37e24
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscOperatorTests.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscRangeTests.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscRangeTests.xls
new file mode 100644
index 000000000000..ebd9e91b5b28
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/MiscRangeTests.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/PageBreaks.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/PageBreaks.xls
new file mode 100644
index 000000000000..b6651fa5d617
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/PageBreaks.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-2.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-2.xls
new file mode 100644
index 000000000000..f6e81cf933fd
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-2.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-3.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-3.xls
new file mode 100644
index 000000000000..8722f6d3057e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges-3.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges.xls
new file mode 100644
index 000000000000..1c1d74d37486
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Ranges.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Shapes.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Shapes.xls
new file mode 100644
index 000000000000..254f3c97756c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Shapes.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/StrConv-test.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/StrConv-test.xls
new file mode 100644
index 000000000000..198abbec5871
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/StrConv-test.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Template.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Template.xls
new file mode 100644
index 000000000000..4387231fe744
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Template.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestAddress.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestAddress.xls
new file mode 100644
index 000000000000..48d30cbe2e9e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestAddress.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest.xls
new file mode 100644
index 000000000000..a497d4f10f3e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest2.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest2.xls
new file mode 100644
index 000000000000..34c606fc28f5
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestCalc_Rangetest2.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestIntersection.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestIntersection.xls
new file mode 100644
index 000000000000..24f88db87ccc
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestIntersection.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestUnion.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestUnion.xls
new file mode 100644
index 000000000000..5b8f0968cf38
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/TestUnion.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/VariantTest.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/VariantTest.xls
new file mode 100644
index 000000000000..f604cfbe3975
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/VariantTest.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Window.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Window.xls
new file mode 100644
index 000000000000..6fb6963c2f31
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/Window.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/bytearraystring.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/bytearraystring.xls
new file mode 100644
index 000000000000..471bbc349e5b
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/bytearraystring.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/dateserial.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/dateserial.xls
new file mode 100644
index 000000000000..768fb513eba4
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/dateserial.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/datevalue.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/datevalue.xls
new file mode 100644
index 000000000000..852a51d100b8
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/datevalue.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/format.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/format.xls
new file mode 100644
index 000000000000..99ed64d38915
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/format.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/AutoFilter.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/AutoFilter.log
new file mode 100644
index 000000000000..1fe0cbd01fe5
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/AutoFilter.log
@@ -0,0 +1,20 @@
+Test run started : 17/07/2007 17:36:22
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 'starts with' string criteria
+ ITEM Assertion OK : test2 'not equal to' string criteria
+ ITEM Assertion OK : test3 'ends with' string criteria
+ ITEM Assertion OK : test4 field 'all'
+ ITEM Assertion OK : test5 numeric '<15'
+ ITEM Assertion OK : test6 numeric '>=15'
+ ITEM Assertion OK : test7 numeric '<=12'
+Test Results
+============
+
+Tests passed: 7
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 17/07/2007 17:36:23
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/MiscRangeTests.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/MiscRangeTests.log
new file mode 100644
index 000000000000..260465386d07
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/MiscRangeTests.log
@@ -0,0 +1,45 @@
+Test run started : 17/07/2007 15:01:37
+----------------------------------------------------------------
+MiscRangeTests
+ TEST START : MiscRangeTests
+ ITEM Assertion OK : test 1
+ ITEM Assertion OK : test 2
+ ITEM Assertion OK : test 3
+ ITEM Assertion OK : test 4
+ ITEM Assertion OK : test 5
+ ITEM Assertion OK : test 6
+ ITEM Assertion OK : test 7
+ ITEM Assertion OK : test 8
+ ITEM Assertion OK : test 9
+ ITEM Assertion OK : test 10
+ ITEM Assertion OK : test 11
+ ITEM Assertion OK : test 12
+ ITEM Assertion OK : test 13
+ ITEM Assertion OK : test 14
+ ITEM Assertion OK : test 15
+ ITEM Assertion OK : test 16
+ ITEM Assertion OK : test 17
+ ITEM Assertion OK : test 18
+ ITEM Assertion OK : test 19
+ ITEM Assertion OK : test 20
+ ITEM Assertion OK : test 21
+ ITEM Assertion OK : test 22
+ ITEM Assertion OK : test 23
+ ITEM Assertion OK : test 24
+ ITEM Assertion OK : test 25
+ ITEM Assertion OK : test 26
+ ITEM Assertion OK : test 27
+ ITEM Assertion OK : test 28
+ ITEM Assertion OK : test 29
+ ITEM Assertion OK : test 30
+ ITEM Assertion OK : test 31
+No. tests: 31
+Summary
+=======
+Run: 31
+Passed: 31
+Failed: 0
+
+END 'MiscRangeTests
+ TEST OK : MiscRangeTests
+Test run finished : 17/07/2007 15:01:39
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-2.log
new file mode 100644
index 000000000000..736d5bbc42d0
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-2.log
@@ -0,0 +1,68 @@
+Test run started : 18/06/2007 17:50:04
+----------------------------------------------------------------
+ClearFormtsIssue
+ TEST START : ClearFormtsIssue
+ ITEM Assertion OK : Range.Font.Bold is: True
+ ITEM Assertion OK : Range.Font.Bold is: False
+END 'ClearFormtsIssue' Symbol
+ TEST OK : ClearFormtsIssue
+----------------------------------------------------------------
+VerticalAlignment-Issue
+ TEST START : VerticalAlignment-Issue
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : Range.VeritcalAlignment is Null
+END 'VerticalAlignment-Issue' Symbol
+ TEST OK : VerticalAlignment-Issue
+----------------------------------------------------------------
+HorizontalAlignment-Issue
+ TEST START : HorizontalAlignment-Issue
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : Range.HorizontalAlignment is Null
+END 'HorizontalAlignment-Issue' Symbol
+ TEST OK : HorizontalAlignment-Issue
+----------------------------------------------------------------
+WrapText-Issue
+ TEST START : WrapText-Issue
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : Range.WrapText is Null
+END 'WrapText-Issue' Symbol
+ TEST OK : WrapText-Issue
+----------------------------------------------------------------
+FontBorderIssues
+ TEST START : FontBorderIssues
+ ITEM Assertion OK : - = Borders.Color (getColor)
+ ITEM Assertion OK : - = Font.Color (getColor)
+END 'FontBorderIssues' Symbol
+ TEST OK : FontBorderIssues
+----------------------------------------------------------------
+RangeSizeIssues
+ TEST START : RangeSizeIssues
+ ITEM Assertion OK : Range.Left is: 114
+ ITEM Assertion OK : Range.Top is: 95.25
+ ITEM Assertion OK : Range.Width is: 216
+ ITEM Assertion OK : Range.Height is: 271.5
+END 'RangeSizeIssues' Symbol
+ TEST OK : RangeSizeIssues
+----------------------------------------------------------------
+ApplicationIssues
+ TEST START : ApplicationIssues
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Application.ActiveSheet.Name: Sheet1
+END 'ApplicationIssues' Symbol
+ TEST OK : ApplicationIssues
+Test run finished : 18/06/2007 17:50:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-3.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-3.log
new file mode 100644
index 000000000000..a7de979d5e13
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges-3.log
@@ -0,0 +1,8 @@
+Test run started : 19/06/2007 11:21:42
+----------------------------------------------------------------
+MyGoalseek-Issue
+ TEST START : MyGoalseek-Issue
+ ITEM Assertion OK : Variable Range value: 15
+END 'MyGoalseek-Issue' Symbol
+ TEST OK : MyGoalseek-Issue
+Test run finished : 19/06/2007 11:21:42
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges.log
new file mode 100644
index 000000000000..8c9644aac155
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/Ranges.log
@@ -0,0 +1,280 @@
+Test run started : 01/06/2007 11:28:58
+----------------------------------------------------------------
+ApplicationMethods
+ TEST START : ApplicationMethods
+ ITEM Assertion OK : Name of Workbook is: Ranges.xls
+ ITEM Assertion OK : Address of Application.Columns is: $A:$A
+ ITEM Assertion OK : Address of Application.Rows is: $1:$1
+ ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7
+ ITEM Assertion OK : Please check manually: DefaultFilePath is: C:\Documents and Settings\vituosity\My Documents
+ ITEM Assertion OK : Please check manually: Library Path is: C:\Program Files\Microsoft Office\OFFICE11\LIBRARY
+ ITEM Assertion OK : Please check manually: Template Path is: C:\Documents and Settings\vituosity\Application Data\Microsoft\Templates\
+ ITEM Assertion OK : FileSeparator is \
+ ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls
+END 'ApplicationMethods' Symbol
+ TEST OK : ApplicationMethods
+----------------------------------------------------------------
+Insert-Issue
+ TEST START : Insert-Issue
+ ITEM Assertion OK : Insert with xlShiftToRight: 10
+END 'Insert-Issue' Symbol
+ TEST OK : Insert-Issue
+----------------------------------------------------------------
+MergeCells-Issue
+ TEST START : MergeCells-Issue
+ ITEM Assertion OK : Range.MergeCells is True
+ ITEM Assertion OK : MergeCells is null: True
+ ITEM Assertion OK : RowCount after Merge: 6
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : MergeCells of Second Area is null : True
+ ITEM Assertion OK : MergeCells of Ranges is Null: True
+ ITEM Assertion OK : RowCount after Merge: 7
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+END 'MergeCells-Issue' Symbol
+ TEST OK : MergeCells-Issue
+----------------------------------------------------------------
+Areas-Issue
+ TEST START : Areas-Issue
+ ITEM Assertion OK : Range Areas Count is2
+ ITEM Assertion OK : First Range Address is: $E$8:$G$13
+ ITEM Assertion OK : First Row is: 8
+ ITEM Assertion OK : First Column is: 5
+ ITEM Assertion OK : EntireRow Address is: $8:$13,$13:$19
+ ITEM Assertion OK : EntireColumn Address is: $E:$G,$G:$K
+ ITEM Assertion OK : Range Count:53
+END 'Areas-Issue' Symbol
+ TEST OK : Areas-Issue
+----------------------------------------------------------------
+Fill-Methods-Issue
+ TEST START : Fill-Methods-Issue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyRightFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyBottomFillValue
+END 'Fill-Methods-Issue' Symbol
+ TEST OK : Fill-Methods-Issue
+----------------------------------------------------------------
+Range/Item-Method-Issue
+ TEST START : Range/Item-Method-Issue
+ ITEM Assertion OK : Range of multiple columns is: $A:$A,$C:$C
+ ITEM Assertion OK : Range of multiple rows is: $1:$1,$5:$7
+ ITEM Assertion OK : Range of several columns is: $C:$E,$D:$D
+ ITEM Assertion OK : Range of several rows is: $5:$8,$6:$10
+ ITEM Assertion OK : Range of several single cells is: $C$5,$E$8
+ ITEM Assertion OK : Range of several named ranges is: $L$1:$M$6,$E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range of a single Item Cell is: $E$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$10
+END 'Range/Item-Method-Issue' Symbol
+ TEST OK : Range/Item-Method-Issue
+----------------------------------------------------------------
+R1C1-Formulas-Issue
+ TEST START : R1C1-Formulas-Issue
+ ITEM Assertion OK : R1C1 Range.Formula is: =IF(OR(R[-2]C[1]=0,RC[2]="YES"),"")
+ ITEM Assertion OK : Range.Formula is: =IF(OR(J8=0,K10="YES"),"")
+END 'R1C1-Formulas-Issue' Symbol
+ TEST OK : R1C1-Formulas-Issue
+----------------------------------------------------------------
+Verify_Delete
+ TEST START : Verify_Delete
+ ITEM Assertion OK : Ranges are intersecting: $G$13
+ ITEM Assertion OK : Delete with Default: $AJ$4
+ ITEM Assertion OK : Delete with ShifttoLeft: $AJ$4
+ ITEM Assertion OK : Delete with ShiftUp: $M$22
+END 'Verify_Delete' Symbol
+ TEST OK : Verify_Delete
+----------------------------------------------------------------
+Value-Issue
+ TEST START : Value-Issue
+ ITEM Assertion OK : Value of Range is: 12.3
+ ITEM Assertion OK : Text of Range is: 12.3
+ ITEM Assertion OK : Range has Formula: False
+ ITEM Assertion OK : Cell has Formula: False
+ ITEM Assertion OK : Text of Range is null: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Cell has Formula: True
+ ITEM Assertion OK : Value of Cell is: 12
+ ITEM Assertion OK : Application.Calculation is : -4135
+ ITEM Assertion OK : Calculation is automated: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Value of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Range has Formula after 'ClearContents: False
+ ITEM Assertion OK : Text of Cell is:
+ ITEM Assertion OK : Text of Cell is:
+END 'Value-Issue' Symbol
+ TEST OK : Value-Issue
+----------------------------------------------------------------
+AutoFit issue
+ TEST START : AutoFit issue
+ ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 673
+ ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 612
+END 'AutoFit issue' Symbol
+ TEST OK : AutoFit issue
+----------------------------------------------------------------
+Selections
+ TEST START : Selections
+ ITEM Assertion OK : ActiveCell is : $E$8
+ ITEM Assertion OK : Active Cell is : $E$8
+ ITEM Assertion OK : Number of Cells in Range: 53
+ ITEM Assertion OK : Number of Cells in Range: 53
+ ITEM Assertion OK : Number of Cells in Range: 53
+END 'Selections' Symbol
+ TEST OK : Selections
+----------------------------------------------------------------
+Offset-Resize
+ TEST START : Offset-Resize
+ ITEM Assertion OK : Offset is : $G$10:$I$15,$I$15:$M$21
+ ITEM Assertion OK : Offset is : $G$7:$I$12,$I$12:$M$18
+ ITEM Assertion OK : Resized Range is : $A$20:$D$23
+END 'Offset-Resize' Symbol
+ TEST OK : Offset-Resize
+----------------------------------------------------------------
+Ranges-Address
+ TEST START : Ranges-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: $E8:$G13,$G13:$K19
+ ITEM Assertion OK : Range Address is: E$8:G$13,G$13:K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5],R[11]C[5]:R[17]C[9]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13,$G$13:$K$19
+END 'Ranges-Address' Symbol
+ TEST OK : Ranges-Address
+----------------------------------------------------------------
+Range-Address
+ TEST START : Range-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: $E8:$G13
+ ITEM Assertion OK : Range Address is: E$8:G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13
+END 'Range-Address' Symbol
+ TEST OK : Range-Address
+----------------------------------------------------------------
+Column-Address
+ TEST START : Column-Address
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: $F8:$F13
+ ITEM Assertion OK : Range Address is: F$8:F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R[6]C[4]:R[11]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$8:$F$13
+END 'Column-Address' Symbol
+ TEST OK : Column-Address
+----------------------------------------------------------------
+Row-Address
+ TEST START : Row-Address
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: $E9:$G9
+ ITEM Assertion OK : Range Address is: E$9:G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R[7]C[3]:R[7]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$9:$G$9
+END 'Row-Address' Symbol
+ TEST OK : Row-Address
+----------------------------------------------------------------
+SingleCell-Address
+ TEST START : SingleCell-Address
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: $F9
+ ITEM Assertion OK : Range Address is: F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R[7]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$9
+END 'SingleCell-Address' Symbol
+ TEST OK : SingleCell-Address
+----------------------------------------------------------------
+Heights and Widths
+ TEST START : Heights and Widths
+ ITEM Assertion OK : Range RowHeight is 40
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 238
+ ITEM Assertion OK : Range Width is 798.75
+ ITEM Assertion OK : Range RowHeight is 50
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 297
+ ITEM Assertion OK : Range Width is 798.75
+ ITEM Assertion OK : RowHeight is null: True
+ ITEM Assertion OK : ColumnWidth is null: True
+END 'Heights and Widths' Symbol
+ TEST OK : Heights and Widths
+----------------------------------------------------------------
+RangeRowColumn-Issue
+ TEST START : RangeRowColumn-Issue
+ ITEM Assertion OK : Row is: 8
+ ITEM Assertion OK : Column is: 5
+ ITEM Assertion OK : EntireRow.Columns.Count = 256
+ ITEM Assertion OK : EntireColumn.Rows.Count = 65536
+END 'RangeRowColumn-Issue' Symbol
+ TEST OK : RangeRowColumn-Issue
+----------------------------------------------------------------
+Replace-Issue
+ TEST START : Replace-Issue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New Replace
+ ITEM Assertion OK : Value after Replace:
+END 'Replace-Issue' Symbol
+ TEST OK : Replace-Issue
+----------------------------------------------------------------
+Hidden-Issue
+ TEST START : Hidden-Issue
+ ITEM Assertion OK : - Range.Rows.Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Hidden (get)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (get)
+END 'Hidden-Issue' Symbol
+ TEST OK : Hidden-Issue
+----------------------------------------------------------------
+End issue
+ TEST START : End issue
+ ITEM Assertion OK : - = $E$48
+ ITEM Assertion OK : - = $E$1
+ ITEM Assertion OK : - = $E$3
+ ITEM Assertion OK : - = $A$8
+ ITEM Assertion OK : - = $B$8
+ ITEM Assertion OK : - = $IV$8
+ ITEM Assertion OK : - = $Z$8
+END 'End issue' Symbol
+ TEST OK : End issue
+----------------------------------------------------------------
+Outline issue
+ TEST START : Outline issue
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+END 'Outline issue' Symbol
+ TEST OK : Outline issue
+----------------------------------------------------------------
+Validation
+ TEST START : Validation
+ ITEM Assertion OK : Validation Input Message is : Attention!
+ ITEM Assertion OK : Validation Input Message is : Enter an integer from five to ten
+ ITEM Assertion OK : Validation Error Title is : You must enter a number from five to ten
+ ITEM Assertion OK : Validation Error Message is : An Error occured
+ ITEM Assertion OK : Validation Error Title is : Microsoft Excel
+END 'Validation' Symbol
+ TEST OK : Validation
+Test run finished : 01/06/2007 11:29:00
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestAddress.log
new file mode 100644
index 000000000000..01e5503a7e62
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestAddress.log
@@ -0,0 +1,62 @@
+Test run started : 17/07/2007 15:25:17
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 Range('e3:f3') A1 style addressing
+ ITEM Assertion OK : test2 Range('e3:f3') R1C1 style addressing
+ ITEM Assertion OK : test3 Range ('e:f') A1 style addressing
+ ITEM Assertion OK : test4 Range ('e:f') R1C1 style addressing
+ ITEM Assertion OK : test5 Columns A1 style addressing
+ ITEM Assertion OK : test6 Columns R1C1 style addressing
+ ITEM Assertion OK : test7 Columns(3) A1 style addressing
+ ITEM Assertion OK : test8 Columns(3) R1C1 style addressing
+ ITEM Assertion OK : test9 Columns('e') A1 style addressing
+ ITEM Assertion OK : test10 Columns('e') R1C1 style addressing
+ ITEM Assertion OK : test11 Columns('b:d') A1 style addressing
+ ITEM Assertion OK : test12 Columns('b:d') R1C1 style addressing
+ ITEM Assertion OK : test13 Range('c1:g10').Columns A1 style addressing
+ ITEM Assertion OK : test14 Range('c1:g10').Columns R1C1 style addressing
+ ITEM Assertion OK : test15 Range('c1:g10').Columns(1) A1 style addressing
+ ITEM Assertion OK : test16 Range('c1:g10').Columns(1) R1C1 style addressing
+ ITEM Assertion OK : test17 Range('c1:g10').Columns('a') A1 style addressing
+ ITEM Assertion OK : test18 Range('c1:g10').Columns('a') R1C1 style addressing
+ ITEM Assertion OK : test19 Range('c1:g10').Columns('c') A1 style addressing
+ ITEM Assertion OK : test20 Range('c1:g10').Columns('c') R1C1 style addressing
+ ITEM Assertion OK : test21 Range('c1:g10').Columns('x:z') A1 style addressing
+ ITEM Assertion OK : test22 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test23 Range('c1:g10').Columns(30) A1 style addressing
+ ITEM Assertion OK : test24 Range('c1:g10').Columns(30) R1C1 style addressing
+ ITEM Assertion OK : test25 Worksheets('Sheet2').Cells(1, 1) A1 style addressing
+ ITEM Assertion OK : test26 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, RowAddressAbsolute is false
+ ITEM Assertion OK : test27 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, ColAddressAbsolute is false
+ ITEM Assertion OK : test28 Worksheets('Sheet2').Cells(1, 1) R1C1 style addressing
+ ITEM Assertion OK : test29 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test30 Worksheets('Sheet2').Range('A1').EntireColumn A1 style addressing
+ ITEM Assertion OK : test31 Worksheets('Sheet2').Range('A1:E5').EntireRow A1 style addressing
+ ITEM Assertion OK : test32 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test33 Worksheets('Sheet2').Range('IV65536').EntireRow A1 style addressing
+ ITEM Assertion OK : test34 Worksheets('Sheet2').Range('IU2:IV65536') A1 style addressing
+ ITEM Assertion OK : test35 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test36 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test37 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test38 Worksheets('Sheet2').Range('10:12') A1 style addressing
+ ITEM Assertion OK : test39 Worksheets('Sheet2').Range('10:12') R1C1 style addressing
+ ITEM Assertion OK : test40 Range('Sheet3!A1:B4') A1 style addressing
+ ITEM Assertion OK : test41 Range('Sheet3!A1,B1,D4:F20') A1 style addressing
+ ITEM Assertion OK : test42 Range('g20:h40').Columns('c:c')
+ ITEM Assertion OK : test43 Range('g20:h40').Columns('c:f')
+ ITEM Assertion OK : test44 Range('g20:h40').Columns(-1)
+ ITEM Assertion OK : test45 Range('c4:g10').Rows(-1)
+ ITEM Assertion OK : test46 Range('a2:b4').Rows('1:1')
+ ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2')
+ ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2')
+ ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3')
+Test Results
+============
+
+Tests passed: 49
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 17/07/2007 15:25:19
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest.log
new file mode 100644
index 000000000000..f055279ec6f4
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest.log
@@ -0,0 +1,60 @@
+Test run started : 30/05/2007 11:33:13
+BEGIN TestCalc
+ TEST START : RangeTest2
+ ITEM Assertion OK : - Range("D15").Row
+ ITEM Assertion OK : - WorkSheet("D15").Range.Row
+ ITEM Assertion OK : - Range("D15").Column
+ ITEM Assertion OK : - Worksheet.Range("D15").Column
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Columns.Count
+ ITEM Assertion OK : - Range("D1").EntireColumn.Rows.Count
+ ITEM Assertion OK : - Range("D15").ClearContent
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (get)
+ ITEM Assertion OK : - Range("B38").Orientation (get)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlDownward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlUpward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B39").WrapText (get)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (get)
+ ITEM Assertion OK : - Range("F39").MergeCells (get)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("D41:D42").Replace MatchCase:=False
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM OK (RangeTest2)
+ TEST succesfully completed : RangeTest2
+END TestCalc
+Test run finished : 30/05/2007 11:33:14
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest2.log
new file mode 100644
index 000000000000..19a5ba96b54a
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/excel/TestCalc_Rangetest2.log
@@ -0,0 +1,64 @@
+Test run started : 31/05/2007 11:02:10
+BEGIN TestCalc
+ TEST START : RangeTest3
+ ITEM Assertion OK : - setFormulaR1C1
+ ITEM Assertion OK : - getFormulaR1C1
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy(Range("I10"))
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteValues
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormulas
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormats
+ ITEM Assertion OK : PasteSpecial
+ ITEM Assertion OK : PasteSpecial SkipBlanks:=True
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationAdd
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationSubtract
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationMultiply
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationDivide
+ ITEM Assertion OK : PasteSpecial Transpose:=True
+ ITEM Assertion OK : ActiveWorkbook.Name
+ ITEM Assertion OK : ActiveWorkbook.FullName und ActiveWorkbook.Path
+ ITEM Assertion OK : - = Range("K22").End (xlDown)
+ ITEM Assertion OK : - = Range("K22").End (xlUo)
+ ITEM Assertion OK : - = Range("K22").End (xlToLeft)
+ ITEM Assertion OK : - = Range("K22").End (xlRight)
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="x"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="<>"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="="
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter
+ ITEM Assertion OK : - ActiveSheet.Resize.Select
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Application.GoTo Reference:="R[8]C[2]"
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Ungroup- please check visually
+ ITEM Assertion OK : - Range.Ungroup - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - ActiveSheet.UsedRange.Select
+ ITEM Assertion FAIL : - Range("A13").AddIndent
+ ITEM Assertion OK : - Range("A13").IndentLevel set
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Calculate
+ ITEM Assertion OK : Worksheet.Calculate
+ ITEM Assertion OK : - Application.Calculate
+ ITEM Assertion OK : Global.Calculate
+ ITEM Assertion OK : Calculation set
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) set
+ ITEM Assertion OK : - = ActiveWorkbook.ResetColors
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) get
+ ITEM FAIL (RangeTest3)
+ TEST Not succesfully completed : RangeTest3
+END TestCalc
+Test run finished : 31/05/2007 11:02:12
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/format.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/format.log
new file mode 100644
index 000000000000..5226a161c61a
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/format.log
@@ -0,0 +1,36 @@
+Test run started : 08/10/2008 13:08:40
+BEGIN Format
+ TEST START : Test Predefined_Number_Format_Sample function
+ ITEM Assertion OK : General Number: 562486.2356
+ ITEM Assertion OK : Fixed: 0.20
+ ITEM Assertion OK : Standard: 562,486.24
+ ITEM Assertion OK : Percent: 75.21%
+ ITEM Assertion OK : Scientific: 5.62E+05
+ ITEM Assertion OK : Scientific: -3.46E+03
+ ITEM Assertion OK : Yes/No: No
+ ITEM Assertion OK : Yes/No: Yes
+ ITEM Assertion OK : True/False: False
+ ITEM Assertion OK : True/False: True
+ ITEM Assertion OK : On/Off: Off
+ ITEM Assertion OK : On/Off: On
+ TEST OK : Test Predefined_Number_Format_Sample function
+ TEST START : Test Custom_Number_Format_Sample function
+ ITEM Assertion OK : 00.0000: 23.6750
+ ITEM Assertion OK : 00.00: 23.68
+ ITEM Assertion OK : 00000: 02658
+ ITEM Assertion OK : 00.00: 2658.00
+ ITEM Assertion OK : ##.####: 23.675
+ ITEM Assertion OK : ##.##: 23.68
+ ITEM Assertion OK : #,###.##: 12,345.25
+ ITEM Assertion OK : ##.00%: 25.00%
+ ITEM Assertion OK : #,###: 1,000,000
+ ITEM Assertion OK : ######E-###: 109838E-5
+ ITEM Assertion OK : $#,###.##: $2,345.25
+ ITEM Assertion OK : ##.###\%: .25%
+ TEST OK : Test Custom_Number_Format_Sample function
+ TEST START : Test Custom_Text_Format_Sample function
+ ITEM Assertion OK : <: vba
+ ITEM Assertion OK : >: VBA
+ TEST OK : Test Custom_Text_Format_Sample function
+END Format
+Test run finished : 08/10/2008 13:08:40
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/AutoFilter.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/AutoFilter.log
new file mode 100644
index 000000000000..55f5d9526618
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/AutoFilter.log
@@ -0,0 +1,20 @@
+Test run started : 18/07/2007 10:56:38
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 'starts with' string criteria
+ ITEM Assertion OK : test2 'not equal to' string criteria
+ ITEM Assertion OK : test3 'ends with' string criteria
+ ITEM Assertion OK : test4 field 'all'
+ ITEM Assertion OK : test5 numeric '<15'
+ ITEM Assertion OK : test6 numeric '>=15'
+ ITEM Assertion OK : test7 numeric '<=12'
+Test Results
+============
+
+Tests passed: 7
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 18/07/2007 10:56:44
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcFont.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcFont.log
new file mode 100644
index 000000000000..f3583e4cbb12
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcFont.log
@@ -0,0 +1,17 @@
+Test run started : 10/09/2008 02:40:17 PM
+CalcFont_Format
+ TEST START : Font_Format
+ ITEM Assertion OK : correctly set font to Bold
+ ITEM Assertion OK : correctly set font to Italic
+ ITEM Assertion OK : correctly read FontStyle
+ ITEM Assertion OK : correctly set font to Shadow
+ ITEM Assertion OK : correctly set font color
+ ITEM Assertion OK : correctly set font color index
+ ITEM Assertion OK : correctly set font name
+ ITEM Assertion OK : correctly set font outline
+ ITEM Assertion OK : correctly set font size
+ ITEM Assertion OK : correctly set font strikethrough
+ ITEM Assertion OK : correctly set font underline
+ TEST Success. : Font_Format
+CalcFont_Format
+Test run finished : 10/09/2008 02:40:17 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcZoom.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcZoom.log
new file mode 100644
index 000000000000..f8c83531a8a2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/CalcZoom.log
@@ -0,0 +1,18 @@
+Test run started : 15/06/2009 12:49:35
+CalcZoom
+ TEST START : CalcZoom
+ ITEM Assertion OK : test1 read window.zoom activesheet = sheet1
+ ITEM Assertion OK : test2 read window.zoom activesheet = sheet2
+ ITEM Assertion OK : test3 read window.zoom activesheet = sheet3
+ ITEM Assertion OK : test4 read window.zoom activesheet = sheet3
+ ITEM Assertion OK : test4 read window.zoom activesheet = sheet2
+ ITEM Assertion OK : test4 read window.zoom activesheet = sheet1
+ TEST Success. : CalcZoom
+CalcZoom
+Test Results
+============
+
+Tests passed: 6
+Tests failed: 0
+
+Test run finished : 15/06/2009 12:49:37
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/FinancialFuncTests.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/FinancialFuncTests.log
new file mode 100644
index 000000000000..5633a8100e08
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/FinancialFuncTests.log
@@ -0,0 +1,31 @@
+Test run started : 04/08/2009 12:42:26
+----------------------------------------------------------------
+FinancialFuncs
+ TEST START : FinancialFuncs
+ ITEM Assertion OK : DDB test
+ ITEM Assertion OK : FV test
+ ITEM Assertion OK : IPmt test
+ ITEM Assertion FAIL : IRR test
+ ITEM Assertion OK : MIRR test
+ ITEM Assertion FAIL : NPer test
+ ITEM Assertion FAIL : NPV test
+ ITEM Assertion FAIL : Pmt test
+ ITEM Assertion OK : PPmt test
+ ITEM Assertion OK : PV test
+ ITEM Assertion FAIL : Rate test
+ ITEM Assertion OK : SLN test
+ ITEM Assertion OK : SYD test
+Test Results
+============
+
+IRR test Failed: expected 35.8625323270733 got 35.8625323273411
+NPer test Failed: expected 21.5365977313406 got 21.5365977313408
+NPV test Failed: expected 3874.42183648785 got 3874.42183648784
+Pmt test Failed: expected 20276.3942884139 got 20276.3942884138
+Rate test Failed: expected 4.67819164224935E-02 got 4.67819164225E-02
+Tests passed: 8
+Tests failed: 5
+
+END 'FinancialFuncs
+ TEST OK : FinancialFuncs
+Test run finished : 04/08/2009 12:42:36
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscOperatorTests.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscOperatorTests.log
new file mode 100644
index 000000000000..116f9f98c7e8
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscOperatorTests.log
@@ -0,0 +1,30 @@
+Test run started : 12/05/2009 12:36:15
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1: res = Not ( A > B )
+ ITEM Assertion OK : test2: res = Not ( B > A )
+ ITEM Assertion OK : test3: res = Not ( D )
+ ITEM Assertion OK : test4: res = Not A
+ ITEM Assertion OK : test5: res = ( A > D )
+ ITEM Assertion OK : test6: res = ( D > A )
+ ITEM Assertion OK : test7: res = ( A < D )
+ ITEM Assertion OK : test8: res = ( D < A )
+ ITEM Assertion OK : test9: res = ( A >= D )
+ ITEM Assertion OK : test10: res = ( D >= A )
+ ITEM Assertion OK : test11: res = ( A <= D )
+ ITEM Assertion OK : test12: res = ( D <= A )
+ ITEM Assertion OK : test13: res = ( D = A )
+ ITEM Assertion OK : test14: res = ( A = D )
+ ITEM Assertion OK : test15: res = ( D <> A )
+ ITEM Assertion OK : test16: res = ( A <> D )
+ ITEM Assertion OK : test17: ( A = D ) = True
+Test Results
+============
+
+Tests passed: 17
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 12/05/2009 12:36:15
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscRangeTests.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscRangeTests.log
new file mode 100644
index 000000000000..215842f9a7e6
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/MiscRangeTests.log
@@ -0,0 +1,45 @@
+Test run started : 17/07/2007 20:54:56
+----------------------------------------------------------------
+MiscRangeTests
+ TEST START : MiscRangeTests
+ ITEM Assertion OK : test 1
+ ITEM Assertion OK : test 2
+ ITEM Assertion OK : test 3
+ ITEM Assertion OK : test 4
+ ITEM Assertion OK : test 5
+ ITEM Assertion OK : test 6
+ ITEM Assertion OK : test 7
+ ITEM Assertion OK : test 8
+ ITEM Assertion OK : test 9
+ ITEM Assertion OK : test 10
+ ITEM Assertion OK : test 11
+ ITEM Assertion OK : test 12
+ ITEM Assertion OK : test 13
+ ITEM Assertion OK : test 14
+ ITEM Assertion OK : test 15
+ ITEM Assertion OK : test 16
+ ITEM Assertion OK : test 17
+ ITEM Assertion OK : test 18
+ ITEM Assertion OK : test 19
+ ITEM Assertion OK : test 20
+ ITEM Assertion OK : test 21
+ ITEM Assertion OK : test 22
+ ITEM Assertion OK : test 23
+ ITEM Assertion OK : test 24
+ ITEM Assertion OK : test 25
+ ITEM Assertion OK : test 26
+ ITEM Assertion OK : test 27
+ ITEM Assertion OK : test 28
+ ITEM Assertion OK : test 29
+ ITEM Assertion OK : test 30
+ ITEM Assertion OK : test 31
+No. tests: 31
+Summary
+=======
+Run: 31
+Passed: 31
+Failed: 0
+
+END 'MiscRangeTests
+ TEST OK : MiscRangeTests
+Test run finished : 17/07/2007 20:55:03
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/PageBreaks.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/PageBreaks.log
new file mode 100644
index 000000000000..0ff400d49e85
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/PageBreaks.log
@@ -0,0 +1,10 @@
+Test run started : 07/24/2008 05:06:12 PM
+----------------------------------------------------------------
+ TEST START : PageBreaks-Issue
+ ITEM Assertion OK : HPageBreaks.Count is 3
+ ITEM Assertion OK : HPageBreak.Type is -4135
+ ITEM Assertion OK : HPageBreak.Location: Range.Row is 5
+ ITEM Assertion OK : HPageBreak.Delete: HPageBreaks.Count is 2
+END 'PageBreaks-Issue' Symbol
+ TEST OK : PageBreaks-Issue
+Test run finished : 07/24/2008 05:06:13 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-2.log
new file mode 100644
index 000000000000..8b7076efaea0
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-2.log
@@ -0,0 +1,68 @@
+Test run started : 19/06/2007 11:14:01
+----------------------------------------------------------------
+ClearFormtsIssue
+ TEST START : ClearFormtsIssue
+ ITEM Assertion OK : Range.Font.Bold is: True
+ ITEM Assertion OK : Range.Font.Bold is: False
+END 'ClearFormtsIssue' Symbol
+ TEST OK : ClearFormtsIssue
+----------------------------------------------------------------
+VerticalAlignment-Issue
+ TEST START : VerticalAlignment-Issue
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : Range.VeritcalAlignment is Null
+END 'VerticalAlignment-Issue' Symbol
+ TEST OK : VerticalAlignment-Issue
+----------------------------------------------------------------
+HorizontalAlignment-Issue
+ TEST START : HorizontalAlignment-Issue
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : Range.HorizontalAlignment is Null
+END 'HorizontalAlignment-Issue' Symbol
+ TEST OK : HorizontalAlignment-Issue
+----------------------------------------------------------------
+WrapText-Issue
+ TEST START : WrapText-Issue
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : Range.WrapText is Null
+END 'WrapText-Issue' Symbol
+ TEST OK : WrapText-Issue
+----------------------------------------------------------------
+FontBorderIssues
+ TEST START : FontBorderIssues
+ ITEM Assertion OK : - = Borders.Color (getColor)
+ ITEM Assertion OK : - = Font.Color (getColor)
+END 'FontBorderIssues' Symbol
+ TEST OK : FontBorderIssues
+----------------------------------------------------------------
+RangeSizeIssues
+ TEST START : RangeSizeIssues
+ ITEM Assertion OK : Range.Left is: 118.8432
+ ITEM Assertion OK : Range.Top is: 92.16585
+ ITEM Assertion OK : Range.Width is: 226.2
+ ITEM Assertion OK : Range.Height is: 271.5
+END 'RangeSizeIssues' Symbol
+ TEST OK : RangeSizeIssues
+----------------------------------------------------------------
+ApplicationIssues
+ TEST START : ApplicationIssues
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Application.ActiveSheet.Name: Sheet1
+END 'ApplicationIssues' Symbol
+ TEST OK : ApplicationIssues
+Test run finished : 19/06/2007 11:14:02
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-3.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-3.log
new file mode 100644
index 000000000000..a130737ceb65
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges-3.log
@@ -0,0 +1,8 @@
+Test run started : 19/06/2007 11:26:09
+----------------------------------------------------------------
+MyGoalseek-Issue
+ TEST START : MyGoalseek-Issue
+ ITEM Assertion OK : Variable Range value: 15
+END 'MyGoalseek-Issue' Symbol
+ TEST OK : MyGoalseek-Issue
+Test run finished : 19/06/2007 11:26:10
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges.log
new file mode 100644
index 000000000000..cdd18685e977
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Ranges.log
@@ -0,0 +1,280 @@
+Test run started : 10/03/2008 15:15:11
+----------------------------------------------------------------
+ApplicationMethods
+ TEST START : ApplicationMethods
+ ITEM Assertion OK : Name of Workbook is: Ranges.xls
+ ITEM Assertion OK : Address of Application.Columns is: $A:$A
+ ITEM Assertion OK : Address of Application.Rows is: $1:$1
+ ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7
+ ITEM Assertion OK : Please check manually: DefaultFilePath is: /data4/home/npower/Documents
+ ITEM Assertion OK : Please check manually: Library Path is: /data4/home/npower/.ooo-2.0/user/basic
+ ITEM Assertion OK : Please check manually: Template Path is: /data4/home/npower/.ooo-2.0/user/template
+ ITEM Assertion OK : FileSeparator is /
+ ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls
+END 'ApplicationMethods' Symbol
+ TEST OK : ApplicationMethods
+----------------------------------------------------------------
+Insert-Issue
+ TEST START : Insert-Issue
+ ITEM Assertion OK : Insert with xlShiftToRight: 10
+END 'Insert-Issue' Symbol
+ TEST OK : Insert-Issue
+----------------------------------------------------------------
+MergeCells-Issue
+ TEST START : MergeCells-Issue
+ ITEM Assertion OK : Range.MergeCells is True
+ ITEM Assertion FAIL : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 13
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion FAIL : MergeCells of Second Area is null : False
+ ITEM Assertion FAIL : MergeCells of Ranges is Null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+END 'MergeCells-Issue' Symbol
+ TEST OK : MergeCells-Issue
+----------------------------------------------------------------
+Areas-Issue
+ TEST START : Areas-Issue
+ ITEM Assertion OK : Range Areas Count is2
+ ITEM Assertion OK : First Range Address is: $E$8:$G$13
+ ITEM Assertion OK : First Row is: 8
+ ITEM Assertion OK : First Column is: 5
+ ITEM Assertion OK : EntireRow Address is: $8:$13,$13:$19
+ ITEM Assertion OK : EntireColumn Address is: $E:$G,$G:$K
+ ITEM Assertion OK : Range Count:53
+END 'Areas-Issue' Symbol
+ TEST OK : Areas-Issue
+----------------------------------------------------------------
+Fill-Methods-Issue
+ TEST START : Fill-Methods-Issue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyRightFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyBottomFillValue
+END 'Fill-Methods-Issue' Symbol
+ TEST OK : Fill-Methods-Issue
+----------------------------------------------------------------
+Range/Item-Method-Issue
+ TEST START : Range/Item-Method-Issue
+ ITEM Assertion OK : Range of multiple columns is: $A:$A,$C:$C
+ ITEM Assertion OK : Range of multiple rows is: $1:$1,$5:$7
+ ITEM Assertion OK : Range of several columns is: $C:$E,$D:$D
+ ITEM Assertion OK : Range of several rows is: $5:$8,$6:$10
+ ITEM Assertion OK : Range of several single cells is: $C$5,$E$8
+ ITEM Assertion OK : Range of several named ranges is: $L$1:$M$6,$E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range of a single Item Cell is: $E$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$10
+END 'Range/Item-Method-Issue' Symbol
+ TEST OK : Range/Item-Method-Issue
+----------------------------------------------------------------
+R1C1-Formulas-Issue
+ TEST START : R1C1-Formulas-Issue
+ ITEM Assertion OK : R1C1 Range.Formula is: =IF(OR(R[-2]C[1]=0,RC[2]="YES"),"")
+ ITEM Assertion OK : Range.Formula is: =IF(OR(J8=0,K10="YES"),"")
+END 'R1C1-Formulas-Issue' Symbol
+ TEST OK : R1C1-Formulas-Issue
+----------------------------------------------------------------
+Verify_Delete
+ TEST START : Verify_Delete
+ ITEM Assertion OK : Ranges are intersecting: $G$13
+ ITEM Assertion OK : Delete with Default: $AJ$4
+ ITEM Assertion OK : Delete with ShifttoLeft: $AJ$4
+ ITEM Assertion OK : Delete with ShiftUp: $M$22
+END 'Verify_Delete' Symbol
+ TEST OK : Verify_Delete
+----------------------------------------------------------------
+Value-Issue
+ TEST START : Value-Issue
+ ITEM Assertion OK : Value of Range is: 12.3
+ ITEM Assertion OK : Text of Range is: 12.3
+ ITEM Assertion OK : Range has Formula: False
+ ITEM Assertion OK : Cell has Formula: False
+ ITEM Assertion FAIL : Text of Range is null: False
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Cell has Formula: True
+ ITEM Assertion OK : Value of Cell is: 12
+ ITEM Assertion OK : Application.Calculation is : -4135
+ ITEM Assertion OK : Calculation is automated: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Value of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Range has Formula after 'ClearContents: False
+ ITEM Assertion OK : Text of Cell is:
+ ITEM Assertion OK : Text of Cell is:
+END 'Value-Issue' Symbol
+ TEST OK : Value-Issue
+----------------------------------------------------------------
+AutoFit issue
+ TEST START : AutoFit issue
+ ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 680
+ ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 554
+END 'AutoFit issue' Symbol
+ TEST OK : AutoFit issue
+----------------------------------------------------------------
+Selections
+ TEST START : Selections
+ ITEM Assertion OK : ActiveCell is : $E$8
+ ITEM Assertion OK : Active Cell is : $E$8
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+END 'Selections' Symbol
+ TEST OK : Selections
+----------------------------------------------------------------
+Offset-Resize
+ TEST START : Offset-Resize
+ ITEM Assertion OK : Offset is : $G$10:$I$15,$I$15:$M$21
+ ITEM Assertion OK : Offset is : $G$7:$I$12,$I$12:$M$18
+ ITEM Assertion OK : Resized Range is : $A$20:$D$23
+END 'Offset-Resize' Symbol
+ TEST OK : Offset-Resize
+----------------------------------------------------------------
+Ranges-Address
+ TEST START : Ranges-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: $E8:$G13,$G13:$K19
+ ITEM Assertion OK : Range Address is: E$8:G$13,G$13:K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5],R[11]C[5]:R[17]C[9]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13,$G$13:$K$19
+END 'Ranges-Address' Symbol
+ TEST OK : Ranges-Address
+----------------------------------------------------------------
+Range-Address
+ TEST START : Range-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: $E8:$G13
+ ITEM Assertion OK : Range Address is: E$8:G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13
+END 'Range-Address' Symbol
+ TEST OK : Range-Address
+----------------------------------------------------------------
+Column-Address
+ TEST START : Column-Address
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: $F8:$F13
+ ITEM Assertion OK : Range Address is: F$8:F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion FAIL : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R[6]C[4]:R[11]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$8:$F$13
+END 'Column-Address' Symbol
+ TEST OK : Column-Address
+----------------------------------------------------------------
+Row-Address
+ TEST START : Row-Address
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: $E9:$G9
+ ITEM Assertion OK : Range Address is: E$9:G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion FAIL : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R[7]C[3]:R[7]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$9:$G$9
+END 'Row-Address' Symbol
+ TEST OK : Row-Address
+----------------------------------------------------------------
+SingleCell-Address
+ TEST START : SingleCell-Address
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: $F9
+ ITEM Assertion OK : Range Address is: F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion FAIL : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R[7]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$9
+END 'SingleCell-Address' Symbol
+ TEST OK : SingleCell-Address
+----------------------------------------------------------------
+Heights and Widths
+ TEST START : Heights and Widths
+ ITEM Assertion OK : Range RowHeight is 40
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 240
+ ITEM Assertion OK : Range Width is 795
+ ITEM Assertion OK : Range RowHeight is 50
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 300
+ ITEM Assertion OK : Range Width is 795
+ ITEM Assertion OK : RowHeight is null: True
+ ITEM Assertion OK : ColumnWidth is null: True
+END 'Heights and Widths' Symbol
+ TEST OK : Heights and Widths
+----------------------------------------------------------------
+RangeRowColumn-Issue
+ TEST START : RangeRowColumn-Issue
+ ITEM Assertion OK : Row is: 8
+ ITEM Assertion OK : Column is: 5
+ ITEM Assertion OK : EntireRow.Columns.Count = 256
+ ITEM Assertion OK : EntireColumn.Rows.Count = 131072
+END 'RangeRowColumn-Issue' Symbol
+ TEST OK : RangeRowColumn-Issue
+----------------------------------------------------------------
+Replace-Issue
+ TEST START : Replace-Issue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New Replace
+ ITEM Assertion OK : Value after Replace:
+END 'Replace-Issue' Symbol
+ TEST OK : Replace-Issue
+----------------------------------------------------------------
+Hidden-Issue
+ TEST START : Hidden-Issue
+ ITEM Assertion OK : - Range.Rows.Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Hidden (get)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (get)
+END 'Hidden-Issue' Symbol
+ TEST OK : Hidden-Issue
+----------------------------------------------------------------
+End issue
+ TEST START : End issue
+ ITEM Assertion OK : - = $E$48
+ ITEM Assertion OK : - = $E$1
+ ITEM Assertion OK : - = $E$3
+ ITEM Assertion OK : - = $A$8
+ ITEM Assertion OK : - = $B$8
+ ITEM Assertion OK : - = $IV$8
+ ITEM Assertion OK : - = $Z$8
+END 'End issue' Symbol
+ TEST OK : End issue
+----------------------------------------------------------------
+Outline issue
+ TEST START : Outline issue
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+END 'Outline issue' Symbol
+ TEST OK : Outline issue
+----------------------------------------------------------------
+Validation
+ TEST START : Validation
+ ITEM Assertion OK : Validation Input Message is : Attention!
+ ITEM Assertion OK : Validation Input Message is : Enter an integer from five to ten
+ ITEM Assertion OK : Validation Error Title is : You must enter a number from five to ten
+ ITEM Assertion OK : Validation Error Message is : An Error occured
+ ITEM Assertion OK : Validation Error Title is : Microsoft Excel
+END 'Validation' Symbol
+ TEST OK : Validation
+Test run finished : 10/03/2008 15:15:13
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Shapes.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Shapes.log
new file mode 100644
index 000000000000..3193a0b1094d
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Shapes.log
@@ -0,0 +1,77 @@
+Test run started : 10/16/2007 05:25:21 PM
+BEGIN Shapes_Collection_Behaviour
+ TEST START : Shapes_Collection_Behaviour
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape1'
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape2'
+ TEST Success. : Shapes_Collection_Behaviour
+END Shapes_Collection_Behaviour
+BEGIN Shapes_Select_Item
+ TEST START : Shapes_Select_Item
+ ITEM Assertion OK : Correctly selected shape through Range
+ ITEM Assertion OK : Correctly selected shape through Item
+ ITEM Assertion OK : Needs to be visually checked. Is there a line on the document?
+ ITEM Assertion OK : Needs to be visually checked. Are All Shapes Selected?
+ TEST Success. : Shapes_Select_Item
+END Shapes_Select_Item
+BEGIN Shapes_Fill
+ TEST START : Shapes_Fill
+ ITEM Assertion OK : correctly set visibility of shape fill
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set backcolor of shape fill
+ ITEM Assertion OK : the success of the TwoColorGradient method needs to be verified visually!
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set forecolor of shape fill
+ TEST Success. : Shapes_Fill
+END Shapes_Fill
+BEGIN Shapes_Line
+ TEST START : Shapes_Line
+ ITEM Assertion FAIL : correctly set weight of shape line
+ ITEM Assertion OK : correctly set visibility of shape line
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set forecolor of shape line
+ ITEM Assertion FAIL : correctly set backcolor of shape line
+ TEST Success. : Shapes_Line
+END Shapes_Line
+BEGIN Shapes_TextFrame
+ TEST START : Shapes_TextFrame
+ ITEM Assertion OK : correctly set Autosize of Shape TextFrame
+ TEST Success. : Shapes_TextFrame
+END Shapes_TextFrame
+BEGIN Shapes_SimpleGeometry
+ TEST START : Shapes_SimpleGeometery
+ ITEM Assertion OK : shape height should be 47.0425168477155 and got 46.9984222363199
+ ITEM Assertion OK : shape width should be 101.467710269751 and got 101.423615658355
+ ITEM Assertion OK : shape left should be 68.5574761223637 and got 68.5417279658754
+ ITEM Assertion OK : shape top should be 42.0251943291216 and got 42.0094461726333
+ ITEM Assertion OK : shape rotation should be 0 and got 0
+ ITEM Assertion OK : shape rotation should be 25 and got 25
+ ITEM Assertion OK : shape incrementrotation should be 50 and got 50
+ ITEM Assertion OK : shape incrementleft should be 70.6834602404119 and got 70.6677120839236
+ ITEM Assertion OK : shape incrementtop should be 91.262986503119 and got 91.2472383466307
+ TEST Success. : Shapes_SimpleGeometery
+END Shapes_SimpleGeometry
+BEGIN Shapes_Range
+ TEST START : Shapes_Range
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to return Sheet2Shape1 got Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to return Sheet2Shape3 got Sheet2Shape3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to contain 2 elements, it contains 2
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to return concated element/shape names Sheet2Shape3Sheet2Shape1 and got Sheet2Shape3Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to contain 3 elements, it contains 3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to return concated element/shape names Sheet2Shape3Sheet2Shape1Sheet2Shape2 and got Sheet2Shape3Sheet2Shape1Sheet2Shape2
+ TEST Success. : Shapes_Range
+END Shapes_Range
+BEGIN Shapes_ShapeRange
+ TEST START : Shapes_ShapeRange
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp1.left should be 90.6677120839236 and got 90.6519627935771
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp2.left should be 240.02518299054 and got 240.009433700193
+ ITEM Assertion OK : ShapeRange.IncrementTop shp1.Top should be 111.247238346631 and got 111.231489056284
+ ITEM Assertion OK : ShapeRange.IncrementTop shp2.Top should be 65.0708633026228 and got 65.0551140122763
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp1.Rotation should be 70 and got 70
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp2.Rotation should be 20 and got 20
+END Shapes_ShapeRange
+Test run finished : 10/16/2007 05:25:22 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/StrConv-test.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/StrConv-test.log
new file mode 100644
index 000000000000..c7a7d8750583
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/StrConv-test.log
@@ -0,0 +1,9 @@
+Test run started : 05/29/2008 02:51:03 PM
+BEGIN StrConv
+ TEST START : Test StrConv function
+ ITEM Assertion OK : Converts the string to uppercase characters:ABC EFG HIJ
+ ITEM Assertion OK : Converts the string to lowercase characters:abc efg hij
+ ITEM Assertion OK : Converts the first letter of every word in string to uppercase:Abc Efg Hij
+ TEST OK : Test StrConv function
+END StrConv
+Test run finished : 05/29/2008 02:51:03 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Template.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Template.log
new file mode 100644
index 000000000000..c6376c5b3732
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Template.log
@@ -0,0 +1,14 @@
+Test run started : 2008ï¼07ï¼10 11:57:05
+----------------------------------------------------------------
+TestCaseName
+ TEST START : TestCaseName
+ ITEM Assertion OK : Something has been done.
+Test Results
+============
+
+Tests passed: 1
+Tests failed: 0
+
+END 'TestCaseName
+ TEST OK : TestCaseName
+Test run finished : 2008ï¼07ï¼10 11:57:05
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestAddress.log
new file mode 100644
index 000000000000..4fa4bc820f59
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestAddress.log
@@ -0,0 +1,67 @@
+Test run started : 12/05/2009 11:23:35
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 Range('e3:f3') A1 style addressing
+ ITEM Assertion OK : test2 Range('e3:f3') R1C1 style addressing
+ ITEM Assertion OK : test3 Range ('e:f') A1 style addressing
+ ITEM Assertion OK : test4 Range ('e:f') R1C1 style addressing
+ ITEM Assertion OK : test5 Columns A1 style addressing
+ ITEM Assertion OK : test6 Columns R1C1 style addressing
+ ITEM Assertion OK : test7 Columns(3) A1 style addressing
+ ITEM Assertion OK : test8 Columns(3) R1C1 style addressing
+ ITEM Assertion OK : test9 Columns('e') A1 style addressing
+ ITEM Assertion OK : test10 Columns('e') R1C1 style addressing
+ ITEM Assertion OK : test11 Columns('b:d') A1 style addressing
+ ITEM Assertion OK : test12 Columns('b:d') R1C1 style addressing
+ ITEM Assertion OK : test13 Range('c1:g10').Columns A1 style addressing
+ ITEM Assertion OK : test14 Range('c1:g10').Columns R1C1 style addressing
+ ITEM Assertion OK : test15 Range('c1:g10').Columns(1) A1 style addressing
+ ITEM Assertion OK : test16 Range('c1:g10').Columns(1) R1C1 style addressing
+ ITEM Assertion OK : test17 Range('c1:g10').Columns('a') A1 style addressing
+ ITEM Assertion OK : test18 Range('c1:g10').Columns('a') R1C1 style addressing
+ ITEM Assertion OK : test19 Range('c1:g10').Columns('c') A1 style addressing
+ ITEM Assertion OK : test20 Range('c1:g10').Columns('c') R1C1 style addressing
+ ITEM Assertion OK : test21 Range('c1:g10').Columns('x:z') A1 style addressing
+ ITEM Assertion OK : test22 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test23 Range('c1:g10').Columns(30) A1 style addressing
+ ITEM Assertion OK : test24 Range('c1:g10').Columns(30) R1C1 style addressing
+ ITEM Assertion OK : test25 Worksheets('Sheet2').Cells(1, 1) A1 style addressing
+ ITEM Assertion OK : test26 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, RowAddressAbsolute is false
+ ITEM Assertion OK : test27 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, ColAddressAbsolute is false
+ ITEM Assertion OK : test28 Worksheets('Sheet2').Cells(1, 1) R1C1 style addressing
+ ITEM Assertion OK : test29 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test30 Worksheets('Sheet2').Range('A1').EntireColumn A1 style addressing
+ ITEM Assertion OK : test31 Worksheets('Sheet2').Range('A1:E5').EntireRow A1 style addressing
+ ITEM Assertion OK : test32 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test33 Worksheets('Sheet2').Range('IV65536').EntireRow A1 style addressing
+ ITEM Assertion OK : test34 Worksheets('Sheet2').Range('IU2:IV65536') A1 style addressing
+ ITEM Assertion OK : test35 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test36 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test37 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test38 Worksheets('Sheet2').Range('10:12') A1 style addressing
+ ITEM Assertion OK : test39 Worksheets('Sheet2').Range('10:12') R1C1 style addressing
+ ITEM Assertion OK : test40 Range('Sheet3!A1:B4') A1 style addressing
+ ITEM Assertion OK : test41 Range('Sheet3!A1,B1,D4:F20') A1 style addressing
+ ITEM Assertion OK : test42 Range('g20:h40').Columns('c:c')
+ ITEM Assertion OK : test43 Range('g20:h40').Columns('c:f')
+ ITEM Assertion OK : test44 Range('g20:h40').Columns(-1)
+ ITEM Assertion OK : test45 Range('c4:g10').Rows(-1)
+ ITEM Assertion OK : test46 Range('a2:b4').Rows('1:1')
+ ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2')
+ ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2')
+ ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3')
+ ITEM Assertion OK : test50 Range(' A2:B4 ')
+ ITEM Assertion OK : test51 Range('A 2:B 4')
+ ITEM Assertion OK : test52 Range('A2 : B4 ')
+ ITEM Assertion OK : test53 Range('Sheet1 !A2 : B4 ')
+ ITEM Assertion OK : test54 Range('Sheet1! A2 : B4 ')
+Test Results
+============
+
+Tests passed: 54
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 12/05/2009 11:23:35
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest.log
new file mode 100644
index 000000000000..083819d4b64e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest.log
@@ -0,0 +1,60 @@
+Test run started : 30/05/2007 15:59:40
+BEGIN TestCalc
+ TEST START : RangeTest2
+ ITEM Assertion OK : - Range("D15").Row
+ ITEM Assertion OK : - WorkSheet("D15").Range.Row
+ ITEM Assertion OK : - Range("D15").Column
+ ITEM Assertion OK : - Worksheet.Range("D15").Column
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Columns.Count
+ ITEM Assertion OK : - Range("D1").EntireColumn.Rows.Count
+ ITEM Assertion OK : - Range("D15").ClearContent
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (get)
+ ITEM Assertion OK : - Range("B38").Orientation (get)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlDownward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlUpward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B39").WrapText (get)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (get)
+ ITEM Assertion OK : - Range("F39").MergeCells (get)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion FAIL : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("D41:D42").Replace MatchCase:=False
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM FAIL (RangeTest2)
+ TEST Not succesfully completed : RangeTest2
+END TestCalc
+Test run finished : 30/05/2007 15:59:42
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest2.log
new file mode 100644
index 000000000000..b1573c06d90e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestCalc_Rangetest2.log
@@ -0,0 +1,65 @@
+Test run started : 10/03/2008 15:15:19
+BEGIN TestCalc
+ TEST START : RangeTest3
+ ITEM Assertion OK : - setFormulaR1C1
+ ITEM Assertion OK : - getFormulaR1C1
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy(Range("I10"))
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteValues
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormulas
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormats
+ ITEM Assertion OK : PasteSpecial
+ ITEM Assertion OK : PasteSpecial SkipBlanks:=True
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationAdd
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationSubtract
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationMultiply
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationDivide
+ ITEM Assertion OK : PasteSpecial Transpose:=True
+ ITEM Assertion FAIL : ActiveWorkbook.FileFormat
+ ITEM Assertion OK : ActiveWorkbook.Name
+ ITEM Assertion OK : ActiveWorkbook.FullName und ActiveWorkbook.Path
+ ITEM Assertion FAIL : - = ActiveWorkbook.Colors(3) set
+ ITEM Assertion OK : - = ActiveWorkbook.ResetColors
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) get
+ ITEM Assertion OK : - = Range("K22").End (xlDown)
+ ITEM Assertion OK : - = Range("K22").End (xlUo)
+ ITEM Assertion OK : - = Range("K22").End (xlToLeft)
+ ITEM Assertion OK : - = Range("K22").End (xlRight)
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="x"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="<>"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="="
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter
+ ITEM Assertion OK : - ActiveSheet.Resize.Select
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion FAIL : - Application.GoTo Reference:="R[8]C[2]"
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Ungroup- please check visually
+ ITEM Assertion OK : - Range.Ungroup - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - ActiveSheet.UsedRange.Select
+ ITEM Assertion OK : - Range("A13").AddIndent
+ ITEM Assertion OK : - Range("A13").IndentLevel set
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Calculate
+ ITEM Assertion OK : Worksheet.Calculate
+ ITEM Assertion OK : - Application.Calculate
+ ITEM Assertion OK : Global.Calculate
+ ITEM Assertion OK : Calculation set
+ ITEM FAIL (RangeTest3)
+ TEST Not succesfully completed : RangeTest3
+END TestCalc
+Test run finished : 10/03/2008 15:15:21
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestIntersection.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestIntersection.log
new file mode 100644
index 000000000000..ea686a830cde
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestIntersection.log
@@ -0,0 +1,26 @@
+Test run started : 13/01/2009 14:31:43
+----------------------------------------------------------------
+TestIntersection
+ TEST START : TestIntersection
+ ITEM Assertion OK : test1 Application.Intersect( Range('A2:D10'), Range('C4:E6'))
+ ITEM Assertion OK : test2 Application.Intersect( Range('A2:D10'), Range('A4:G10'))
+ ITEM Assertion OK : test3 Application.Intersect( Range('A2:c8,d2:f8,g2:i8'), Range('A4:G10'))
+ ITEM Assertion OK : test4 Application.Intersect( Range('A4:G10'), Range('A2:c8,d2:f8,g2:i8'))
+ ITEM Assertion OK : test5 Application.Intersect( Range('A2:c8,d2:f8,g2:i8'), Range('g4:i10,A4:G10'))
+ ITEM Assertion OK : test6 Application.Intersect( Range('g4:i10,A4:G10'), Range('A2:c8,d2:f8,g2:i8'))
+ ITEM Assertion OK : test7 Application.Intersect( Range('a2:d10,b5:e10'), Range('a5:i10'))
+ ITEM Assertion OK : test8 Application.Intersect( Range('a2:c8,d2:f8'), Range('b6:e9,a6:f9'))
+ ITEM Assertion OK : test9 Application.Intersect( Range('a2:c8,e2:f8'), Range('b6:e9,a6:f9'))
+ ITEM Assertion OK : test10 Application.Intersect( Range('a1:a3,c1:c3'), Range('a2:c3'))
+ ITEM Assertion OK : test11 Application.Intersect( Range('a1:a3,b1:b3'), Range('a2:c3'))
+ ITEM Assertion OK : test12 Application.Intersect( Range('a2:d5,b3:f7,c1:g4'), Range('b2:e6'))
+ ITEM Assertion OK : test13 Range(" a2:d10,b5:e10,g13:j32 "), Range(" a5:i10,b6:e9 "), Range("b2:r5,f10:h19")
+Test Results
+============
+
+Tests passed: 13
+Tests failed: 0
+
+END 'TestIntersection
+ TEST OK : TestIntersection
+Test run finished : 13/01/2009 14:31:43
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestUnion.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestUnion.log
new file mode 100644
index 000000000000..da3cb35dedb3
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/TestUnion.log
@@ -0,0 +1,17 @@
+Test run started : 13/01/2009 14:32:16
+----------------------------------------------------------------
+TestUnion
+ TEST START : TestUnion
+ ITEM Assertion OK : test1Application.Range('A2:D10'), Range('C4:E6')
+ ITEM Assertion OK : test2Application.Range('A2:D5,a3:d4'), Range('A4:G10')
+ ITEM Assertion OK : test3Application.Range('A4:G10,A1:B6'), Range('A2:D5,A3:D4')
+ ITEM Assertion OK : test4Application.Range('A5:D10'), Range('B5:E10')
+Test Results
+============
+
+Tests passed: 4
+Tests failed: 0
+
+END 'TestUnion
+ TEST OK : TestUnion
+Test run finished : 13/01/2009 14:32:16
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/VariantTest.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/VariantTest.log
new file mode 100644
index 000000000000..a916ac4a37fd
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/VariantTest.log
@@ -0,0 +1,47 @@
+Test run started : 24/09/2008 10:58:18
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1: res = (aboo = '')
+ ITEM Assertion OK : test 2: res = (aboo = 'fiddlesticks')
+ ITEM Assertion OK : test 3: res = ('' = aboo)
+ ITEM Assertion OK : test 4: res = ('fiddlesticks' = aboo )
+ ITEM Assertion OK : test 5: res = (testString = '')
+ ITEM Assertion OK : test 6: res = (testString = 'fiddlesticks')
+ ITEM Assertion OK : test 7: res = ('' = testString)
+ ITEM Assertion OK : test 8: res = ('fiddlesticks' = testString )
+ ITEM Assertion OK : test 9: res = ( aboo < " )
+ ITEM Assertion OK : test 10: res = ( testString < " )
+ ITEM Assertion OK : test 11: res = ( aboo > " )
+ ITEM Assertion OK : test 12: res = ( testString > " )
+ ITEM Assertion OK : test 13: res = ( aboo <> '' )
+ ITEM Assertion OK : test 14: res = ( testString <> '' )
+ ITEM Assertion OK : test 15: res = (aboo = something/14)
+ ITEM Assertion OK : test 16: res = something + 'string'
+ ITEM Assertion OK : test 17: res = something & 'string'
+ ITEM Assertion OK : test 18: res = something MOD 10 )
+ ITEM Assertion OK : test 19: res = something AND 1 )
+ ITEM Assertion OK : test 20: res = something AND 0 )
+ ITEM Assertion OK : test 21: res = something OR 12)
+ ITEM Assertion OK : test 22: res = something OR 0 )
+ ITEM Assertion OK : test 23: res = something XOR 0 )
+ ITEM Assertion OK : test 24: res = something XOR 1 )
+ ITEM Assertion OK : test 25: res = something EQV 0 )
+ ITEM Assertion OK : test 26: res = something EQV 1 )
+ ITEM Assertion OK : test 27: res = something IMP 0 )
+ ITEM Assertion OK : test 28: res = something IMP 1 )
+ ITEM Assertion OK : test 29: res = something IMP 14 )
+ ITEM Assertion OK : test 30: res = NOT something )
+ ITEM Assertion OK : test 31: res = something + 12 )
+ ITEM Assertion OK : test 32: res = something - 12 )
+ ITEM Assertion OK : test 33: res = -something )
+ ITEM Assertion OK : test 34: res = something * 12 )
+Test Results
+============
+
+Tests passed: 34
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 24/09/2008 10:58:20
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Window.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Window.log
new file mode 100644
index 000000000000..ec9a6656113e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/Window.log
@@ -0,0 +1,46 @@
+Test run started : 05/29/2008 02:55:00 PM
+----------------------------------------------------------------
+ TEST START : Window-Issue
+ ITEM Assertion OK : Window.Left is: 0 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Top is: 21 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Width is: 1280 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Height is: 752 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.ScrollColumn is: 100
+ ITEM Assertion OK : Window.ScrollColumn is: 1
+ ITEM Assertion OK : Window.ScrollRow is: 100
+ ITEM Assertion OK : Window.ScrollRow is: 1
+ ITEM Assertion OK : Window.LargeScroll(Down): ScrollRow is: 94 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.LargeScroll(Up): ScrollRow is: 1
+ ITEM Assertion OK : Window.LargeScroll(ToRight): ScrollColumn is: 58 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.LargeScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window.SmallScroll(ToRight): ScrollColumn is: 4 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.SmallScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window.DisplayWorkBookTabs is: False
+ ITEM Assertion OK : Window.DisplayWorkBookTabs is: True
+ ITEM Assertion OK : Window.DisplayVerticalScrollBar is: True
+ ITEM Assertion OK : Window.DisplayVerticalScrollBar is: False
+ ITEM Assertion OK : Window.DisplayHorizontalScrollBar is: False
+ ITEM Assertion OK : Window.DisplayHorizontalScrollBar is: True
+ ITEM Assertion OK : Window.DisplayHeadings is: False
+ ITEM Assertion OK : Window.DisplayHeadings is: True
+ ITEM Assertion OK : Window.DisplayOutline is: False
+ ITEM Assertion OK : Window.DisplayOutline is: True
+ ITEM Assertion OK : Window.Visible is: False
+ ITEM Assertion OK : Window.Visible is: True
+ ITEM Assertion OK : Window.Caption is: MyCaption
+ ITEM Assertion OK : Pane.ScrollColumn is: 100
+ ITEM Assertion OK : Pane.ScrollColumn is: 1
+ ITEM Assertion OK : Pane.ScrollRow is: 100
+ ITEM Assertion OK : Pane.ScrollRow is: 1
+ ITEM Assertion OK : Pane.LargeScroll(Down): ScrollRow is: 94 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.LargeScroll(Up): ScrollRow is: 1
+ ITEM Assertion OK : Pane.LargeScroll(ToRight): ScrollColumn is: 58 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.LargeScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Pane.SmallScroll(ToRight): ScrollColumn is: 4 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.SmallScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window Selection: $A$2:$D$5
+ ITEM Assertion OK : ActiveSheet name of Window: Sheet1
+ ITEM Assertion OK : Window ActiveCell: $A$1
+END 'Window-Issue' Symbol
+ TEST OK : Window-Issue
+Test run finished : 05/29/2008 02:55:01 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/bytearraystring.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/bytearraystring.log
new file mode 100644
index 000000000000..bd243283d8f1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/bytearraystring.log
@@ -0,0 +1,8 @@
+Test run started : 05/29/2008 02:25:58 PM
+BEGIN Bytearray To String
+ TEST START : Test the conversion between bytearray and string
+ ITEM Assertion OK : The number of byte is:6
+ ITEM Assertion OK : the return string is: abc
+ TEST OK : Test the conversion between bytearray and string
+END Bytearray To String
+Test run finished : 05/29/2008 02:25:58 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/dateserial.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/dateserial.log
new file mode 100644
index 000000000000..4dd5f53160f2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/dateserial.log
@@ -0,0 +1,9 @@
+Test run started : 01/24/2008 01:24:50 PM
+BEGIN DateSerial
+ TEST START : Test DateSerial function
+ ITEM Assertion OK : the return date is: 06/15/1999
+ ITEM Assertion OK : the return date is: 06/15/1999
+ ITEM Assertion OK : the return date is: 06/15/1999
+ TEST OK : Test DateSerial function
+END DateSerial
+Test run finished : 01/24/2008 01:24:50 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/datevalue.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/datevalue.log
new file mode 100644
index 000000000000..830d5e7b6c3e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/datevalue.log
@@ -0,0 +1,8 @@
+Test run started : 01/24/2008 01:24:41 PM
+BEGIN DateValue
+ TEST START : Test DateValue function
+ ITEM Assertion OK : the return date is: 02/12/1969
+ ITEM Assertion OK : the return date is: 01/21/2008
+ TEST OK : Test DateValue function
+END DateValue
+Test run finished : 01/24/2008 01:24:41 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/format.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/format.log
new file mode 100644
index 000000000000..96725bf7daa8
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/format.log
@@ -0,0 +1,36 @@
+Test run started : 2008ï¼09ï¼18 11:35:34
+BEGIN Format
+ TEST START : Test Predefined_Number_Format_Sample function
+ ITEM Assertion OK : General Number: 562486.2356
+ ITEM Assertion OK : Fixed: 0.20
+ ITEM Assertion OK : Standard: 562,486.24
+ ITEM Assertion OK : Percent: 75.21%
+ ITEM Assertion OK : Scientific: 5.62E+05
+ ITEM Assertion OK : Scientific: -3.46E+03
+ ITEM Assertion OK : Yes/No: No
+ ITEM Assertion OK : Yes/No: Yes
+ ITEM Assertion OK : True/False: False
+ ITEM Assertion OK : True/False: True
+ ITEM Assertion OK : On/Off: Off
+ ITEM Assertion OK : On/Off: On
+ TEST OK : Test Predefined_Number_Format_Sample function
+ TEST START : Test Custom_Number_Format_Sample function
+ ITEM Assertion OK : 00.0000: 23.6750
+ ITEM Assertion OK : 00.00: 23.68
+ ITEM Assertion OK : 00000: 02658
+ ITEM Assertion OK : 00.00: 2658.00
+ ITEM Assertion OK : ##.####: 23.675
+ ITEM Assertion OK : ##.##: 23.68
+ ITEM Assertion OK : #,###.##: 12,345.25
+ ITEM Assertion OK : ##.00%: 25.00%
+ ITEM Assertion OK : #,###: 1,000,000
+ ITEM Assertion OK : ######E-###: 109838E-5
+ ITEM Assertion OK : $#,###.##: $2,345.25
+ ITEM Assertion OK : ##.###\%: .25%
+ TEST OK : Test Custom_Number_Format_Sample function
+ TEST START : Test Custom_Text_Format_Sample function
+ ITEM Assertion OK : <: vba
+ ITEM Assertion OK : >: VBA
+ TEST OK : Test Custom_Text_Format_Sample function
+END Format
+Test run finished : 2008ï¼09ï¼18 11:35:34
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/pagesetup.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/pagesetup.log
new file mode 100644
index 000000000000..f04585c3f9e1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/pagesetup.log
@@ -0,0 +1,77 @@
+Test run started : 07/21/2008 02:00:06 PM
+BEGIN PageSetup
+ TEST START : Sheet_PrintArea
+ ITEM Assertion OK : PrintArea has changed as expected
+ TEST OK : Sheet_PrintArea
+ TEST START : Test margins (no headers)
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.RightMargin set/get
+ ITEM Assertion OK : PageSetup.TopMargin set/get
+ ITEM Assertion OK : PageSetup.BottomMargin set/get
+Verify that page margins on sheet 1 are all 0.5inch
+ TEST OK : Test margins (no headers)
+ TEST START : Test margins (headers)
+ ITEM Assertion OK : PageSetup.HeaderMargin set/get
+ ITEM Assertion OK : PageSetup.FooterMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+Verify that top/bottom/header/footer page margins on sheet 2 are all 0.5inch
+ TEST OK : Test margins (headers)
+ TEST START : Test header/footer text
+ ITEM Assertion OK : PageSetup.LeftHeader set
+ ITEM Assertion OK : PageSetup.LeftHeader set/get
+ ITEM Assertion OK : PageSetup.CenterHeader set
+ ITEM Assertion OK : PageSetup.CenterHeader set/get
+ ITEM Assertion OK : PageSetup.RightHeader set
+ ITEM Assertion OK : PageSetup.RightHeader set/get
+ ITEM Assertion OK : PageSetup.LeftFooter set
+ ITEM Assertion OK : PageSetup.LeftFooter set/get
+ ITEM Assertion OK : PageSetup.CenterFooter set
+ ITEM Assertion OK : PageSetup.CenterFooter set/get
+ ITEM Assertion OK : PageSetup.RightFooter set
+ ITEM Assertion OK : PageSetup.RightFooter set/get
+Verify that headers on sheet 2 are Ready,to,go
+Verify that footers on sheet 2 are This,now,Works
+ TEST OK : Test header/footer text
+ TEST START : Test zoom
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Zoom set/get
+Verify that sheet 1 zoom is 10%
+ TEST OK : Test zoom
+ TEST START : Test orientation
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Orientation set/get
+Verify that sheet 1 orientation is now landscape
+ TEST OK : Test orientation
+ TEST START : Test order
+ ITEM Assertion OK : PageSetup.Order get
+ ITEM Assertion OK : PageSetup.Order set/get
+Verify that order on sheet 1 is now over, then down.
+ TEST OK : Test order
+ TEST START : Test first page number
+ ITEM Assertion OK : PageSetup.FirstPageNumber get
+ ITEM Assertion OK : PageSetup.FirstPageNumber set/get
+Verify that first page number on sheet 1 is now 2.
+ TEST OK : Test first page number
+ TEST START : Test center vertically
+ ITEM Assertion OK : PageSetup.CenterVertically get
+ ITEM Assertion OK : PageSetup.CenterVertically set/get
+Verify that CenterVertically on sheet 1 is now true.
+ TEST OK : Test center vertically
+ TEST START : Test center horizontally
+ ITEM Assertion OK : PageSetup.CenterHorizontally get
+ ITEM Assertion OK : PageSetup.CenterHorizontally set/get
+Verify that CenterHorizontally on sheet 1 is now true.
+ TEST OK : Test center horizontally
+ TEST START : Test FitToPagesTall
+ ITEM Assertion OK : PageSetup.FitToPagesTall set/get
+ TEST OK : Test FitToPagesTall
+ TEST START : Test FitToPagesWide
+ ITEM Assertion OK : PageSetup.FitToPagesWide set/get
+ TEST OK : Test FitToPagesWide
+ TEST START : Test PrintHeadings
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ TEST OK : Test PrintHeadings
+END PageSetup
+Test run finished : 07/21/2008 02:00:07 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/partition.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/partition.log
new file mode 100644
index 000000000000..7b4f2a01bead
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/partition.log
@@ -0,0 +1,11 @@
+Test run started : 12/10/2007 11:26:43 AM
+BEGIN Partition
+ TEST START : Test Partition function
+ ITEM Assertion OK : the number 20 occurs in the range:20:24
+ ITEM Assertion OK : the number 20 occurs in the range: 20: 20
+ ITEM Assertion OK : the number 120 occurs in the range:100:
+ ITEM Assertion OK : the number -5 occurs in the range: : -1
+ ITEM Assertion OK : the number 2 occurs in the range: 2: 3
+ TEST OK : Test Partition function
+END Partition
+Test run finished : 12/10/2007 11:26:43 AM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/range-4.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/range-4.log
new file mode 100644
index 000000000000..fb37b6ff201b
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/range-4.log
@@ -0,0 +1,16 @@
+Test run started : 2008ï¼06ï¼19 17:14:57
+----------------------------------------------------------------
+ShowDetail-Issue
+ TEST START : ShowDetail-Issue
+ ITEM Assertion OK : Range.ShowDetail is True
+ ITEM Assertion OK : Range.ShowDetail is False
+END 'ShowDetail-Issue' Symbol
+ TEST OK : ShowDetail-Issue
+----------------------------------------------------------------
+RangeMerged-Issue
+ TEST START : RangeMerged-Issue
+ ITEM Assertion OK : Range.RangeMerged is $F$2:$H$5
+ ITEM Assertion OK : The first address of Range.RangeMerged is $F$2
+END 'RangeMerged-Issue' Symbol
+ TEST OK : RangeMerged-Issue
+Test run finished : 2008ï¼06ï¼19 17:14:57
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/replace.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/replace.log
new file mode 100644
index 000000000000..8f600faaa6b1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/replace.log
@@ -0,0 +1,14 @@
+Test run started : 09/05/2008 10:21:46 AM
+BEGIN Replace
+ TEST START : Test Replace function
+ ITEM Assertion OK : common string:aefefdBc
+ ITEM Assertion OK : expression string:aefefdef
+ ITEM Assertion OK : binanary compare:aefefdBc
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : start = 3:cefdBc
+ ITEM Assertion OK : count = 2: aefefdBc
+ ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc
+ TEST OK : Test Replace function
+END Replace
+Test run finished : 09/05/2008 10:21:47 AM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/stringplusdouble.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/stringplusdouble.log
new file mode 100644
index 000000000000..6e8b8d994bd1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/stringplusdouble.log
@@ -0,0 +1,62 @@
+Test run started : 05/29/2008 02:51:22 PM
+BEGIN String Plus Double
+ TEST START : double = string + double
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: 0
+The next compute raises error: s = null, d = 20, r = s + d
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 100
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 30
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = null, r = s & d
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s & d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: -1
+ TEST OK : double = string + double
+ TEST START : string = string + double
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: 0
+The next compute raises error: s = null, d = 20, r = s + d
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 100
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 30
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: abc0
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: abc20
+ TEST OK : string = string + double
+ TEST START : double = string + string
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+The next compute raises error: s = null, d = null, r = s & d
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: 20
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 10
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 1020
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = null, r = s & d
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s & d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: -1
+ TEST OK : double = string + string
+END String Plus Double
+Test run finished : 05/29/2008 02:51:22 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/window2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/window2.log
new file mode 100644
index 000000000000..8e26d0580621
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/unix/window2.log
@@ -0,0 +1,41 @@
+Test run started : 2008ï¼09ï¼22 11:18:57
+BEGIN Window2
+ TEST START : Test Window.SplitRow
+ ITEM Assertion OK : Test SplitColumn: 2 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitRow: 2 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitVertical: 242.465788476212
+ ITEM Assertion OK : Test SplitHorizontal: 242.465788476212
+ ITEM Assertion OK : Test SplitRow: 4 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitColumn: 3 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitColumn: 0
+ ITEM Assertion OK : Test SplitRow: 0
+ TEST OK : Test Window.SplitRow
+ TEST START : Test Window.DisplayGridlines
+ ITEM Assertion OK : Test gridlines are on
+ ITEM Assertion OK : Test gridlines are off
+ TEST OK : Test Window.DisplayGridlines
+ TEST START : Test Window.DisplayHeadings
+ ITEM Assertion OK : Test Headings are on
+ ITEM Assertion OK : Test Headings are off
+ TEST OK : Test Window.DisplayHeadings
+ TEST START : Test Window.Visibility
+ ITEM Assertion OK : Window is visible
+ ITEM Assertion OK : Window is not visible
+ TEST OK : Test Window.Visibility
+ TEST START : Test Window.FreezePanes
+ ITEM Assertion OK : Test no panes frozen
+ ITEM Assertion OK : Test panes frozen at center
+ ITEM Assertion OK : Test panes frozen at split
+ TEST OK : Test Window.FreezePanes
+ TEST START : Test Window.View
+ TEST OK : Test Window.View
+ TEST START : Test Window.Zoom
+ ITEM Assertion OK : Test zoom=100%
+ ITEM Assertion OK : Test zoom=150%
+ TEST OK : Test Window.Zoom
+ TEST START : Test Windows.Count
+ ITEM Assertion OK : Windows Count: 1
+ ITEM Assertion OK : Application.Windows Count: 1
+ TEST OK : Test Windows.Count
+END Window2
+Test run finished : 2008ï¼09ï¼22 11:18:58
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/AutoFilter.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/AutoFilter.log
new file mode 100644
index 000000000000..b8d0b85a8ff9
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/AutoFilter.log
@@ -0,0 +1,20 @@
+Test run started : 16/10/2007 17:42:01
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 'starts with' string criteria
+ ITEM Assertion OK : test2 'not equal to' string criteria
+ ITEM Assertion OK : test3 'ends with' string criteria
+ ITEM Assertion OK : test4 field 'all'
+ ITEM Assertion OK : test5 numeric '<15'
+ ITEM Assertion OK : test6 numeric '>=15'
+ ITEM Assertion OK : test7 numeric '<=12'
+Test Results
+============
+
+Tests passed: 7
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 16/10/2007 17:42:02
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/CalcFont.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/CalcFont.log
new file mode 100644
index 000000000000..e8695523a0a1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/CalcFont.log
@@ -0,0 +1,17 @@
+Test run started : 15/01/2009 17:00:35
+CalcFont_Format
+ TEST START : Font_Format
+ ITEM Assertion OK : correctly set font to Bold
+ ITEM Assertion OK : correctly set font to Italic
+ ITEM Assertion OK : correctly read FontStyle
+ ITEM Assertion OK : correctly set font to Shadow
+ ITEM Assertion OK : correctly set font color
+ ITEM Assertion OK : correctly set font color index
+ ITEM Assertion OK : correctly set font name
+ ITEM Assertion OK : correctly set font outline
+ ITEM Assertion OK : correctly set font size
+ ITEM Assertion OK : correctly set font strikethrough
+ ITEM Assertion OK : correctly set font underline
+ TEST Success. : Font_Format
+CalcFont_Format
+Test run finished : 15/01/2009 17:00:36
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscOperatorTests.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscOperatorTests.log
new file mode 100644
index 000000000000..3ccec0a1577d
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscOperatorTests.log
@@ -0,0 +1,29 @@
+Test run started : 15/01/2009 17:03:13
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1: res = Not ( A > B )
+ ITEM Assertion OK : test2: res = Not ( B > A )
+ ITEM Assertion OK : test3: res = Not ( D )
+ ITEM Assertion OK : test4: res = Not A
+ ITEM Assertion OK : test5: res = ( A > D )
+ ITEM Assertion OK : test6: res = ( D > A )
+ ITEM Assertion OK : test7: res = ( A < D )
+ ITEM Assertion OK : test8: res = ( D < A )
+ ITEM Assertion OK : test9: res = ( A >= D )
+ ITEM Assertion OK : test10: res = ( D >= A )
+ ITEM Assertion OK : test11: res = ( A <= D )
+ ITEM Assertion OK : test12: res = ( D <= A )
+ ITEM Assertion OK : test13: res = ( D = A )
+ ITEM Assertion OK : test14: res = ( A = D )
+ ITEM Assertion OK : test15: res = ( D <> A )
+ ITEM Assertion OK : test16: res = ( A <> D )
+Test Results
+============
+
+Tests passed: 16
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 15/01/2009 17:03:15
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscRangeTests.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscRangeTests.log
new file mode 100644
index 000000000000..d190abb5f645
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/MiscRangeTests.log
@@ -0,0 +1,45 @@
+Test run started : 17/07/2007 15:08:56
+----------------------------------------------------------------
+MiscRangeTests
+ TEST START : MiscRangeTests
+ ITEM Assertion OK : test 1
+ ITEM Assertion OK : test 2
+ ITEM Assertion OK : test 3
+ ITEM Assertion OK : test 4
+ ITEM Assertion OK : test 5
+ ITEM Assertion OK : test 6
+ ITEM Assertion OK : test 7
+ ITEM Assertion OK : test 8
+ ITEM Assertion OK : test 9
+ ITEM Assertion OK : test 10
+ ITEM Assertion OK : test 11
+ ITEM Assertion OK : test 12
+ ITEM Assertion OK : test 13
+ ITEM Assertion OK : test 14
+ ITEM Assertion OK : test 15
+ ITEM Assertion OK : test 16
+ ITEM Assertion OK : test 17
+ ITEM Assertion OK : test 18
+ ITEM Assertion OK : test 19
+ ITEM Assertion OK : test 20
+ ITEM Assertion OK : test 21
+ ITEM Assertion OK : test 22
+ ITEM Assertion OK : test 23
+ ITEM Assertion OK : test 24
+ ITEM Assertion OK : test 25
+ ITEM Assertion OK : test 26
+ ITEM Assertion OK : test 27
+ ITEM Assertion OK : test 28
+ ITEM Assertion OK : test 29
+ ITEM Assertion OK : test 30
+ ITEM Assertion OK : test 31
+No. tests: 31
+Summary
+=======
+Run: 31
+Passed: 31
+Failed: 0
+
+END 'MiscRangeTests
+ TEST OK : MiscRangeTests
+Test run finished : 17/07/2007 15:08:59
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/PageBreaks.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/PageBreaks.log
new file mode 100644
index 000000000000..30b6e45d1681
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/PageBreaks.log
@@ -0,0 +1,10 @@
+Test run started : 08/10/2008 12:02:12
+----------------------------------------------------------------
+ TEST START : PageBreaks-Issue
+ ITEM Assertion OK : HPageBreaks.Count is 3
+ ITEM Assertion OK : HPageBreak.Type is -4135
+ ITEM Assertion OK : HPageBreak.Location: Range.Row is 5
+ ITEM Assertion OK : HPageBreak.Delete: HPageBreaks.Count is 2
+END 'PageBreaks-Issue' Symbol
+ TEST OK : PageBreaks-Issue
+Test run finished : 08/10/2008 12:02:12
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-2.log
new file mode 100644
index 000000000000..b80d996e3d3f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-2.log
@@ -0,0 +1,68 @@
+Test run started : 10/07/2007 01:55:47
+----------------------------------------------------------------
+ClearFormtsIssue
+ TEST START : ClearFormtsIssue
+ ITEM Assertion OK : Range.Font.Bold is: True
+ ITEM Assertion OK : Range.Font.Bold is: False
+END 'ClearFormtsIssue' Symbol
+ TEST OK : ClearFormtsIssue
+----------------------------------------------------------------
+VerticalAlignment-Issue
+ TEST START : VerticalAlignment-Issue
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : Range.VeritcalAlignment is Null
+END 'VerticalAlignment-Issue' Symbol
+ TEST OK : VerticalAlignment-Issue
+----------------------------------------------------------------
+HorizontalAlignment-Issue
+ TEST START : HorizontalAlignment-Issue
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : Range.HorizontalAlignment is Null
+END 'HorizontalAlignment-Issue' Symbol
+ TEST OK : HorizontalAlignment-Issue
+----------------------------------------------------------------
+WrapText-Issue
+ TEST START : WrapText-Issue
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : Range.WrapText is Null
+END 'WrapText-Issue' Symbol
+ TEST OK : WrapText-Issue
+----------------------------------------------------------------
+FontBorderIssues
+ TEST START : FontBorderIssues
+ ITEM Assertion OK : - = Borders.Color (getColor)
+ ITEM Assertion OK : - = Font.Color (getColor)
+END 'FontBorderIssues' Symbol
+ TEST OK : FontBorderIssues
+----------------------------------------------------------------
+RangeSizeIssues
+ TEST START : RangeSizeIssues
+ ITEM Assertion OK : Range.Left is: 100.5291
+ ITEM Assertion OK : Range.Top is: 95.39775
+ ITEM Assertion OK : Range.Width is: 191.25
+ ITEM Assertion OK : Range.Height is: 271.5
+END 'RangeSizeIssues' Symbol
+ TEST OK : RangeSizeIssues
+----------------------------------------------------------------
+ApplicationIssues
+ TEST START : ApplicationIssues
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Application.ActiveSheet.Name: Sheet1
+END 'ApplicationIssues' Symbol
+ TEST OK : ApplicationIssues
+Test run finished : 10/07/2007 01:55:48
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-3.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-3.log
new file mode 100644
index 000000000000..365d126a7e2d
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges-3.log
@@ -0,0 +1,8 @@
+Test run started : 10/07/2007 01:55:51
+----------------------------------------------------------------
+MyGoalseek-Issue
+ TEST START : MyGoalseek-Issue
+ ITEM Assertion OK : Variable Range value: 15
+END 'MyGoalseek-Issue' Symbol
+ TEST OK : MyGoalseek-Issue
+Test run finished : 10/07/2007 01:55:51
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges.log
new file mode 100644
index 000000000000..6491fe4173ec
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Ranges.log
@@ -0,0 +1,280 @@
+Test run started : 08/10/2008 11:30:21
+----------------------------------------------------------------
+ApplicationMethods
+ TEST START : ApplicationMethods
+ ITEM Assertion OK : Name of Workbook is: Ranges.xls
+ ITEM Assertion OK : Address of Application.Columns is: $A:$A
+ ITEM Assertion OK : Address of Application.Rows is: $1:$1
+ ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7
+ ITEM Assertion OK : Please check manually: DefaultFilePath is: C:\Documents and Settings\vituosity\My Documents
+ ITEM Assertion OK : Please check manually: Library Path is: C:\Documents and Settings\vituosity\Application Data\OpenOffice.org\3\user\basic
+ ITEM Assertion OK : Please check manually: Template Path is: C:\Documents and Settings\vituosity\Application Data\OpenOffice.org\3\user\template
+ ITEM Assertion OK : FileSeparator is \
+ ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls
+END 'ApplicationMethods' Symbol
+ TEST OK : ApplicationMethods
+----------------------------------------------------------------
+Insert-Issue
+ TEST START : Insert-Issue
+ ITEM Assertion OK : Insert with xlShiftToRight: 10
+END 'Insert-Issue' Symbol
+ TEST OK : Insert-Issue
+----------------------------------------------------------------
+MergeCells-Issue
+ TEST START : MergeCells-Issue
+ ITEM Assertion OK : Range.MergeCells is True
+ ITEM Assertion FAIL : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 13
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion FAIL : MergeCells of Second Area is null : False
+ ITEM Assertion FAIL : MergeCells of Ranges is Null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+END 'MergeCells-Issue' Symbol
+ TEST OK : MergeCells-Issue
+----------------------------------------------------------------
+Areas-Issue
+ TEST START : Areas-Issue
+ ITEM Assertion OK : Range Areas Count is2
+ ITEM Assertion OK : First Range Address is: $E$8:$G$13
+ ITEM Assertion OK : First Row is: 8
+ ITEM Assertion OK : First Column is: 5
+ ITEM Assertion OK : EntireRow Address is: $8:$13,$13:$19
+ ITEM Assertion OK : EntireColumn Address is: $E:$G,$G:$K
+ ITEM Assertion OK : Range Count:53
+END 'Areas-Issue' Symbol
+ TEST OK : Areas-Issue
+----------------------------------------------------------------
+Fill-Methods-Issue
+ TEST START : Fill-Methods-Issue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyRightFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyBottomFillValue
+END 'Fill-Methods-Issue' Symbol
+ TEST OK : Fill-Methods-Issue
+----------------------------------------------------------------
+Range/Item-Method-Issue
+ TEST START : Range/Item-Method-Issue
+ ITEM Assertion OK : Range of multiple columns is: $A:$A,$C:$C
+ ITEM Assertion OK : Range of multiple rows is: $1:$1,$5:$7
+ ITEM Assertion OK : Range of several columns is: $C:$E,$D:$D
+ ITEM Assertion OK : Range of several rows is: $5:$8,$6:$10
+ ITEM Assertion OK : Range of several single cells is: $C$5,$E$8
+ ITEM Assertion OK : Range of several named ranges is: $L$1:$M$6,$E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range of a single Item Cell is: $E$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$10
+END 'Range/Item-Method-Issue' Symbol
+ TEST OK : Range/Item-Method-Issue
+----------------------------------------------------------------
+R1C1-Formulas-Issue
+ TEST START : R1C1-Formulas-Issue
+ ITEM Assertion OK : R1C1 Range.Formula is: =IF(OR(R[-2]C[1]=0,RC[2]="YES"),"")
+ ITEM Assertion OK : Range.Formula is: =IF(OR(J8=0,K10="YES"),"")
+END 'R1C1-Formulas-Issue' Symbol
+ TEST OK : R1C1-Formulas-Issue
+----------------------------------------------------------------
+Verify_Delete
+ TEST START : Verify_Delete
+ ITEM Assertion OK : Ranges are intersecting: $G$13
+ ITEM Assertion OK : Delete with Default: $AJ$4
+ ITEM Assertion OK : Delete with ShifttoLeft: $AJ$4
+ ITEM Assertion OK : Delete with ShiftUp: $M$22
+END 'Verify_Delete' Symbol
+ TEST OK : Verify_Delete
+----------------------------------------------------------------
+Value-Issue
+ TEST START : Value-Issue
+ ITEM Assertion OK : Value of Range is: 12.3
+ ITEM Assertion OK : Text of Range is: 12.3
+ ITEM Assertion OK : Range has Formula: False
+ ITEM Assertion OK : Cell has Formula: False
+ ITEM Assertion FAIL : Text of Range is null: False
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Cell has Formula: True
+ ITEM Assertion OK : Value of Cell is: 12
+ ITEM Assertion OK : Application.Calculation is : -4135
+ ITEM Assertion OK : Calculation is automated: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Value of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Range has Formula after 'ClearContents: False
+ ITEM Assertion OK : Text of Cell is:
+ ITEM Assertion OK : Text of Cell is:
+END 'Value-Issue' Symbol
+ TEST OK : Value-Issue
+----------------------------------------------------------------
+AutoFit issue
+ TEST START : AutoFit issue
+ ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 680
+ ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 582
+END 'AutoFit issue' Symbol
+ TEST OK : AutoFit issue
+----------------------------------------------------------------
+Selections
+ TEST START : Selections
+ ITEM Assertion OK : ActiveCell is : $E$8
+ ITEM Assertion OK : Active Cell is : $E$8
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+END 'Selections' Symbol
+ TEST OK : Selections
+----------------------------------------------------------------
+Offset-Resize
+ TEST START : Offset-Resize
+ ITEM Assertion OK : Offset is : $G$10:$I$15,$I$15:$M$21
+ ITEM Assertion OK : Offset is : $G$7:$I$12,$I$12:$M$18
+ ITEM Assertion OK : Resized Range is : $A$20:$D$23
+END 'Offset-Resize' Symbol
+ TEST OK : Offset-Resize
+----------------------------------------------------------------
+Ranges-Address
+ TEST START : Ranges-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: $E8:$G13,$G13:$K19
+ ITEM Assertion OK : Range Address is: E$8:G$13,G$13:K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5],R[11]C[5]:R[17]C[9]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13,$G$13:$K$19
+END 'Ranges-Address' Symbol
+ TEST OK : Ranges-Address
+----------------------------------------------------------------
+Range-Address
+ TEST START : Range-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: $E8:$G13
+ ITEM Assertion OK : Range Address is: E$8:G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13
+END 'Range-Address' Symbol
+ TEST OK : Range-Address
+----------------------------------------------------------------
+Column-Address
+ TEST START : Column-Address
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: $F8:$F13
+ ITEM Assertion OK : Range Address is: F$8:F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion FAIL : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R[6]C[4]:R[11]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$8:$F$13
+END 'Column-Address' Symbol
+ TEST OK : Column-Address
+----------------------------------------------------------------
+Row-Address
+ TEST START : Row-Address
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: $E9:$G9
+ ITEM Assertion OK : Range Address is: E$9:G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion FAIL : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R[7]C[3]:R[7]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$9:$G$9
+END 'Row-Address' Symbol
+ TEST OK : Row-Address
+----------------------------------------------------------------
+SingleCell-Address
+ TEST START : SingleCell-Address
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: $F9
+ ITEM Assertion OK : Range Address is: F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion FAIL : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R[7]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$9
+END 'SingleCell-Address' Symbol
+ TEST OK : SingleCell-Address
+----------------------------------------------------------------
+Heights and Widths
+ TEST START : Heights and Widths
+ ITEM Assertion OK : Range RowHeight is 40
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 240
+ ITEM Assertion FAIL : Range Width is 675
+ ITEM Assertion OK : Range RowHeight is 50
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 300
+ ITEM Assertion FAIL : Range Width is 675
+ ITEM Assertion OK : RowHeight is null: True
+ ITEM Assertion OK : ColumnWidth is null: True
+END 'Heights and Widths' Symbol
+ TEST OK : Heights and Widths
+----------------------------------------------------------------
+RangeRowColumn-Issue
+ TEST START : RangeRowColumn-Issue
+ ITEM Assertion OK : Row is: 8
+ ITEM Assertion OK : Column is: 5
+ ITEM Assertion OK : EntireRow.Columns.Count = 1024
+ ITEM Assertion OK : EntireColumn.Rows.Count = 131072
+END 'RangeRowColumn-Issue' Symbol
+ TEST OK : RangeRowColumn-Issue
+----------------------------------------------------------------
+Replace-Issue
+ TEST START : Replace-Issue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New Replace
+ ITEM Assertion OK : Value after Replace:
+END 'Replace-Issue' Symbol
+ TEST OK : Replace-Issue
+----------------------------------------------------------------
+Hidden-Issue
+ TEST START : Hidden-Issue
+ ITEM Assertion OK : - Range.Rows.Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Hidden (get)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (get)
+END 'Hidden-Issue' Symbol
+ TEST OK : Hidden-Issue
+----------------------------------------------------------------
+End issue
+ TEST START : End issue
+ ITEM Assertion OK : - = $E$48
+ ITEM Assertion OK : - = $E$1
+ ITEM Assertion OK : - = $E$3
+ ITEM Assertion OK : - = $A$8
+ ITEM Assertion OK : - = $B$8
+ ITEM Assertion OK : - = $AMJ$8
+ ITEM Assertion OK : - = $Z$8
+END 'End issue' Symbol
+ TEST OK : End issue
+----------------------------------------------------------------
+Outline issue
+ TEST START : Outline issue
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+END 'Outline issue' Symbol
+ TEST OK : Outline issue
+----------------------------------------------------------------
+Validation
+ TEST START : Validation
+ ITEM Assertion OK : Validation Input Message is : Attention!
+ ITEM Assertion OK : Validation Input Message is : Enter an integer from five to ten
+ ITEM Assertion OK : Validation Error Title is : You must enter a number from five to ten
+ ITEM Assertion OK : Validation Error Message is : An Error occured
+ ITEM Assertion OK : Validation Error Title is : Microsoft Excel
+END 'Validation' Symbol
+ TEST OK : Validation
+Test run finished : 08/10/2008 11:30:24
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Shapes.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Shapes.log
new file mode 100644
index 000000000000..fe62ab03d3f2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Shapes.log
@@ -0,0 +1,77 @@
+Test run started : 16/10/2007 17:46:03
+BEGIN Shapes_Collection_Behaviour
+ TEST START : Shapes_Collection_Behaviour
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape1'
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape2'
+ TEST Success. : Shapes_Collection_Behaviour
+END Shapes_Collection_Behaviour
+BEGIN Shapes_Select_Item
+ TEST START : Shapes_Select_Item
+ ITEM Assertion OK : Correctly selected shape through Range
+ ITEM Assertion OK : Correctly selected shape through Item
+ ITEM Assertion OK : Needs to be visually checked. Is there a line on the document?
+ ITEM Assertion OK : Needs to be visually checked. Are All Shapes Selected?
+ TEST Success. : Shapes_Select_Item
+END Shapes_Select_Item
+BEGIN Shapes_Fill
+ TEST START : Shapes_Fill
+ ITEM Assertion OK : correctly set visibility of shape fill
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set backcolor of shape fill
+ ITEM Assertion OK : the success of the TwoColorGradient method needs to be verified visually!
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set forecolor of shape fill
+ TEST Success. : Shapes_Fill
+END Shapes_Fill
+BEGIN Shapes_Line
+ TEST START : Shapes_Line
+ ITEM Assertion FAIL : correctly set weight of shape line
+ ITEM Assertion OK : correctly set visibility of shape line
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set forecolor of shape line
+ ITEM Assertion FAIL : correctly set backcolor of shape line
+ TEST Success. : Shapes_Line
+END Shapes_Line
+BEGIN Shapes_TextFrame
+ TEST START : Shapes_TextFrame
+ ITEM Assertion OK : correctly set Autosize of Shape TextFrame
+ TEST Success. : Shapes_TextFrame
+END Shapes_TextFrame
+BEGIN Shapes_SimpleGeometry
+ TEST START : Shapes_SimpleGeometery
+ ITEM Assertion OK : shape height should be 49.4519655148368 and got 49.4078709034412
+ ITEM Assertion OK : shape width should be 101.467710269751 and got 101.423615658355
+ ITEM Assertion OK : shape left should be 68.5574761223637 and got 68.5417279658754
+ ITEM Assertion OK : shape top should be 44.1511784471699 and got 44.1354302906816
+ ITEM Assertion OK : shape rotation should be 0 and got 0
+ ITEM Assertion OK : shape rotation should be 25 and got 25
+ ITEM Assertion OK : shape incrementrotation should be 50 and got 50
+ ITEM Assertion OK : shape incrementleft should be 69.7480272284707 and got 69.7322790719824
+ ITEM Assertion OK : shape incrementtop should be 93.8141674447769 and got 93.7984192882885
+ TEST Success. : Shapes_SimpleGeometery
+END Shapes_SimpleGeometry
+BEGIN Shapes_Range
+ TEST START : Shapes_Range
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to return Sheet2Shape1 got Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to return Sheet2Shape3 got Sheet2Shape3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to contain 2 elements, it contains 2
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to return concated element/shape names Sheet2Shape3Sheet2Shape1 and got Sheet2Shape3Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to contain 3 elements, it contains 3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to return concated element/shape names Sheet2Shape3Sheet2Shape1Sheet2Shape2 and got Sheet2Shape3Sheet2Shape1Sheet2Shape2
+ TEST Success. : Shapes_Range
+END Shapes_Range
+BEGIN Shapes_ShapeRange
+ TEST START : Shapes_ShapeRange
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp1.left should be 89.7322790719824 and got 89.7165297816359
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp2.left should be 240.02518299054 and got 240.009433700193
+ ITEM Assertion OK : ShapeRange.IncrementTop shp1.Top should be 113.798419288289 and got 113.782669997942
+ ITEM Assertion OK : ShapeRange.IncrementTop shp2.Top should be 67.4519655148368 and got 67.4362162244903
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp1.Rotation should be 70 and got 70
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp2.Rotation should be 20 and got 20
+END Shapes_ShapeRange
+Test run finished : 16/10/2007 17:46:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/StrConv-test.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/StrConv-test.log
new file mode 100644
index 000000000000..b1f7794234f9
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/StrConv-test.log
@@ -0,0 +1,9 @@
+Test run started : 08/10/2008 12:04:16
+BEGIN StrConv
+ TEST START : Test StrConv function
+ ITEM Assertion OK : Converts the string to uppercase characters:ABC EFG HIJ
+ ITEM Assertion OK : Converts the string to lowercase characters:abc efg hij
+ ITEM Assertion OK : Converts the first letter of every word in string to uppercase:Abc Efg Hij
+ TEST OK : Test StrConv function
+END StrConv
+Test run finished : 08/10/2008 12:04:16
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Template.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Template.log
new file mode 100644
index 000000000000..774994adb02c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Template.log
@@ -0,0 +1,14 @@
+Test run started : 08/10/2008 12:05:52
+----------------------------------------------------------------
+TestCaseName
+ TEST START : TestCaseName
+ ITEM Assertion OK : Something has been done.
+Test Results
+============
+
+Tests passed: 1
+Tests failed: 0
+
+END 'TestCaseName
+ TEST OK : TestCaseName
+Test run finished : 08/10/2008 12:05:52
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestAddress.log
new file mode 100644
index 000000000000..0007e6f9c958
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestAddress.log
@@ -0,0 +1,67 @@
+Test run started : 08/10/2008 11:30:32
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 Range('e3:f3') A1 style addressing
+ ITEM Assertion OK : test2 Range('e3:f3') R1C1 style addressing
+ ITEM Assertion OK : test3 Range ('e:f') A1 style addressing
+ ITEM Assertion OK : test4 Range ('e:f') R1C1 style addressing
+ ITEM Assertion OK : test5 Columns A1 style addressing
+ ITEM Assertion OK : test6 Columns R1C1 style addressing
+ ITEM Assertion OK : test7 Columns(3) A1 style addressing
+ ITEM Assertion OK : test8 Columns(3) R1C1 style addressing
+ ITEM Assertion OK : test9 Columns('e') A1 style addressing
+ ITEM Assertion OK : test10 Columns('e') R1C1 style addressing
+ ITEM Assertion OK : test11 Columns('b:d') A1 style addressing
+ ITEM Assertion OK : test12 Columns('b:d') R1C1 style addressing
+ ITEM Assertion OK : test13 Range('c1:g10').Columns A1 style addressing
+ ITEM Assertion OK : test14 Range('c1:g10').Columns R1C1 style addressing
+ ITEM Assertion OK : test15 Range('c1:g10').Columns(1) A1 style addressing
+ ITEM Assertion OK : test16 Range('c1:g10').Columns(1) R1C1 style addressing
+ ITEM Assertion OK : test17 Range('c1:g10').Columns('a') A1 style addressing
+ ITEM Assertion OK : test18 Range('c1:g10').Columns('a') R1C1 style addressing
+ ITEM Assertion OK : test19 Range('c1:g10').Columns('c') A1 style addressing
+ ITEM Assertion OK : test20 Range('c1:g10').Columns('c') R1C1 style addressing
+ ITEM Assertion OK : test21 Range('c1:g10').Columns('x:z') A1 style addressing
+ ITEM Assertion OK : test22 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test23 Range('c1:g10').Columns(30) A1 style addressing
+ ITEM Assertion OK : test24 Range('c1:g10').Columns(30) R1C1 style addressing
+ ITEM Assertion OK : test25 Worksheets('Sheet2').Cells(1, 1) A1 style addressing
+ ITEM Assertion OK : test26 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, RowAddressAbsolute is false
+ ITEM Assertion OK : test27 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, ColAddressAbsolute is false
+ ITEM Assertion OK : test28 Worksheets('Sheet2').Cells(1, 1) R1C1 style addressing
+ ITEM Assertion OK : test29 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test30 Worksheets('Sheet2').Range('A1').EntireColumn A1 style addressing
+ ITEM Assertion OK : test31 Worksheets('Sheet2').Range('A1:E5').EntireRow A1 style addressing
+ ITEM Assertion OK : test32 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test33 Worksheets('Sheet2').Range('IV65536').EntireRow A1 style addressing
+ ITEM Assertion OK : test34 Worksheets('Sheet2').Range('IU2:IV65536') A1 style addressing
+ ITEM Assertion OK : test35 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test36 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test37 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test38 Worksheets('Sheet2').Range('10:12') A1 style addressing
+ ITEM Assertion OK : test39 Worksheets('Sheet2').Range('10:12') R1C1 style addressing
+ ITEM Assertion OK : test40 Range('Sheet3!A1:B4') A1 style addressing
+ ITEM Assertion OK : test41 Range('Sheet3!A1,B1,D4:F20') A1 style addressing
+ ITEM Assertion OK : test42 Range('g20:h40').Columns('c:c')
+ ITEM Assertion OK : test43 Range('g20:h40').Columns('c:f')
+ ITEM Assertion OK : test44 Range('g20:h40').Columns(-1)
+ ITEM Assertion OK : test45 Range('c4:g10').Rows(-1)
+ ITEM Assertion OK : test46 Range('a2:b4').Rows('1:1')
+ ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2')
+ ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2')
+ ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3')
+ ITEM Assertion OK : test50 Range(' A2:B4 ')
+ ITEM Assertion OK : test51 Range('A 2:B 4')
+ ITEM Assertion OK : test52 Range('A2 : B4 ')
+ ITEM Assertion OK : test53 Range('Sheet1 !A2 : B4 ')
+ ITEM Assertion OK : test54 Range('Sheet1! A2 : B4 ')
+Test Results
+============
+
+Tests passed: 54
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 08/10/2008 11:30:32
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest.log
new file mode 100644
index 000000000000..492c24bc023c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest.log
@@ -0,0 +1,60 @@
+Test run started : 10/07/2007 01:56:07
+BEGIN TestCalc
+ TEST START : RangeTest2
+ ITEM Assertion OK : - Range("D15").Row
+ ITEM Assertion OK : - WorkSheet("D15").Range.Row
+ ITEM Assertion OK : - Range("D15").Column
+ ITEM Assertion OK : - Worksheet.Range("D15").Column
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Columns.Count
+ ITEM Assertion OK : - Range("D1").EntireColumn.Rows.Count
+ ITEM Assertion OK : - Range("D15").ClearContent
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (get)
+ ITEM Assertion OK : - Range("B38").Orientation (get)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlDownward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlUpward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B39").WrapText (get)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (get)
+ ITEM Assertion OK : - Range("F39").MergeCells (get)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion FAIL : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("D41:D42").Replace MatchCase:=False
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM FAIL (RangeTest2)
+ TEST Not succesfully completed : RangeTest2
+END TestCalc
+Test run finished : 10/07/2007 01:56:12
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest2.log
new file mode 100644
index 000000000000..9159217cb442
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestCalc_Rangetest2.log
@@ -0,0 +1,65 @@
+Test run started : 08/10/2008 11:30:38
+BEGIN TestCalc
+ TEST START : RangeTest3
+ ITEM Assertion OK : - setFormulaR1C1
+ ITEM Assertion OK : - getFormulaR1C1
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy(Range("I10"))
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteValues
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormulas
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormats
+ ITEM Assertion OK : PasteSpecial
+ ITEM Assertion OK : PasteSpecial SkipBlanks:=True
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationAdd
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationSubtract
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationMultiply
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationDivide
+ ITEM Assertion OK : PasteSpecial Transpose:=True
+ ITEM Assertion FAIL : ActiveWorkbook.FileFormat
+ ITEM Assertion OK : ActiveWorkbook.Name
+ ITEM Assertion OK : ActiveWorkbook.FullName und ActiveWorkbook.Path
+ ITEM Assertion FAIL : - = ActiveWorkbook.Colors(3) set
+ ITEM Assertion OK : - = ActiveWorkbook.ResetColors
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) get
+ ITEM Assertion OK : - = Range("K22").End (xlDown)
+ ITEM Assertion OK : - = Range("K22").End (xlUo)
+ ITEM Assertion OK : - = Range("K22").End (xlToLeft)
+ ITEM Assertion OK : - = Range("K22").End (xlRight)
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="x"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="<>"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="="
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter
+ ITEM Assertion OK : - ActiveSheet.Resize.Select
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion FAIL : - Application.GoTo Reference:="R[8]C[2]"
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Ungroup- please check visually
+ ITEM Assertion OK : - Range.Ungroup - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - ActiveSheet.UsedRange.Select
+ ITEM Assertion OK : - Range("A13").AddIndent
+ ITEM Assertion OK : - Range("A13").IndentLevel set
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Calculate
+ ITEM Assertion OK : Worksheet.Calculate
+ ITEM Assertion OK : - Application.Calculate
+ ITEM Assertion OK : Global.Calculate
+ ITEM Assertion OK : Calculation set
+ ITEM FAIL (RangeTest3)
+ TEST Not succesfully completed : RangeTest3
+END TestCalc
+Test run finished : 08/10/2008 11:30:41
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestIntersection.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestIntersection.log
new file mode 100644
index 000000000000..2cf4fe36ea6f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestIntersection.log
@@ -0,0 +1,26 @@
+Test run started : 15/01/2009 17:05:08
+----------------------------------------------------------------
+TestIntersection
+ TEST START : TestIntersection
+ ITEM Assertion OK : test1 Application.Intersect( Range('A2:D10'), Range('C4:E6'))
+ ITEM Assertion OK : test2 Application.Intersect( Range('A2:D10'), Range('A4:G10'))
+ ITEM Assertion OK : test3 Application.Intersect( Range('A2:c8,d2:f8,g2:i8'), Range('A4:G10'))
+ ITEM Assertion OK : test4 Application.Intersect( Range('A4:G10'), Range('A2:c8,d2:f8,g2:i8'))
+ ITEM Assertion OK : test5 Application.Intersect( Range('A2:c8,d2:f8,g2:i8'), Range('g4:i10,A4:G10'))
+ ITEM Assertion OK : test6 Application.Intersect( Range('g4:i10,A4:G10'), Range('A2:c8,d2:f8,g2:i8'))
+ ITEM Assertion OK : test7 Application.Intersect( Range('a2:d10,b5:e10'), Range('a5:i10'))
+ ITEM Assertion OK : test8 Application.Intersect( Range('a2:c8,d2:f8'), Range('b6:e9,a6:f9'))
+ ITEM Assertion OK : test9 Application.Intersect( Range('a2:c8,e2:f8'), Range('b6:e9,a6:f9'))
+ ITEM Assertion OK : test10 Application.Intersect( Range('a1:a3,c1:c3'), Range('a2:c3'))
+ ITEM Assertion OK : test11 Application.Intersect( Range('a1:a3,b1:b3'), Range('a2:c3'))
+ ITEM Assertion OK : test12 Application.Intersect( Range('a2:d5,b3:f7,c1:g4'), Range('b2:e6'))
+ ITEM Assertion OK : test13 Range(" a2:d10,b5:e10,g13:j32 "), Range(" a5:i10,b6:e9 "), Range("b2:r5,f10:h19")
+Test Results
+============
+
+Tests passed: 13
+Tests failed: 0
+
+END 'TestIntersection
+ TEST OK : TestIntersection
+Test run finished : 15/01/2009 17:05:09
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestUnion.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestUnion.log
new file mode 100644
index 000000000000..2382db549554
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/TestUnion.log
@@ -0,0 +1,17 @@
+Test run started : 15/01/2009 17:06:07
+----------------------------------------------------------------
+TestUnion
+ TEST START : TestUnion
+ ITEM Assertion OK : test1Application.Range('A2:D10'), Range('C4:E6')
+ ITEM Assertion OK : test2Application.Range('A2:D5,a3:d4'), Range('A4:G10')
+ ITEM Assertion OK : test3Application.Range('A4:G10,A1:B6'), Range('A2:D5,A3:D4')
+ ITEM Assertion OK : test4Application.Range('A5:D10'), Range('B5:E10')
+Test Results
+============
+
+Tests passed: 4
+Tests failed: 0
+
+END 'TestUnion
+ TEST OK : TestUnion
+Test run finished : 15/01/2009 17:06:08
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/VariantTest.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/VariantTest.log
new file mode 100644
index 000000000000..d2bfeb8e14a1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/VariantTest.log
@@ -0,0 +1,47 @@
+Test run started : 08/10/2008 12:07:24
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1: res = (aboo = '')
+ ITEM Assertion OK : test 2: res = (aboo = 'fiddlesticks')
+ ITEM Assertion OK : test 3: res = ('' = aboo)
+ ITEM Assertion OK : test 4: res = ('fiddlesticks' = aboo )
+ ITEM Assertion OK : test 5: res = (testString = '')
+ ITEM Assertion OK : test 6: res = (testString = 'fiddlesticks')
+ ITEM Assertion OK : test 7: res = ('' = testString)
+ ITEM Assertion OK : test 8: res = ('fiddlesticks' = testString )
+ ITEM Assertion OK : test 9: res = ( aboo < " )
+ ITEM Assertion OK : test 10: res = ( testString < " )
+ ITEM Assertion OK : test 11: res = ( aboo > " )
+ ITEM Assertion OK : test 12: res = ( testString > " )
+ ITEM Assertion OK : test 13: res = ( aboo <> '' )
+ ITEM Assertion OK : test 14: res = ( testString <> '' )
+ ITEM Assertion OK : test 15: res = (aboo = something/14)
+ ITEM Assertion OK : test 16: res = something + 'string'
+ ITEM Assertion OK : test 17: res = something & 'string'
+ ITEM Assertion OK : test 18: res = something MOD 10 )
+ ITEM Assertion OK : test 19: res = something AND 1 )
+ ITEM Assertion OK : test 20: res = something AND 0 )
+ ITEM Assertion OK : test 21: res = something OR 12)
+ ITEM Assertion OK : test 22: res = something OR 0 )
+ ITEM Assertion OK : test 23: res = something XOR 0 )
+ ITEM Assertion OK : test 24: res = something XOR 1 )
+ ITEM Assertion OK : test 25: res = something EQV 0 )
+ ITEM Assertion OK : test 26: res = something EQV 1 )
+ ITEM Assertion OK : test 27: res = something IMP 0 )
+ ITEM Assertion OK : test 28: res = something IMP 1 )
+ ITEM Assertion OK : test 29: res = something IMP 14 )
+ ITEM Assertion OK : test 30: res = NOT something )
+ ITEM Assertion OK : test 31: res = something + 12 )
+ ITEM Assertion OK : test 32: res = something - 12 )
+ ITEM Assertion OK : test 33: res = -something )
+ ITEM Assertion OK : test 34: res = something * 12 )
+Test Results
+============
+
+Tests passed: 34
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 08/10/2008 12:07:26
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Window.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Window.log
new file mode 100644
index 000000000000..178582e753c7
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/Window.log
@@ -0,0 +1,46 @@
+Test run started : 08/10/2008 12:09:50
+----------------------------------------------------------------
+ TEST START : Window-Issue
+ ITEM Assertion OK : Window.Left is: 0 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Top is: 26 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Width is: 1280 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Height is: 968 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.ScrollColumn is: 100
+ ITEM Assertion OK : Window.ScrollColumn is: 1
+ ITEM Assertion OK : Window.ScrollRow is: 100
+ ITEM Assertion OK : Window.ScrollRow is: 1
+ ITEM Assertion OK : Window.LargeScroll(Down): ScrollRow is: 127 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.LargeScroll(Up): ScrollRow is: 1
+ ITEM Assertion OK : Window.LargeScroll(ToRight): ScrollColumn is: 58 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.LargeScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window.SmallScroll(ToRight): ScrollColumn is: 4 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.SmallScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window.DisplayWorkBookTabs is: False
+ ITEM Assertion OK : Window.DisplayWorkBookTabs is: True
+ ITEM Assertion OK : Window.DisplayVerticalScrollBar is: True
+ ITEM Assertion OK : Window.DisplayVerticalScrollBar is: False
+ ITEM Assertion OK : Window.DisplayHorizontalScrollBar is: False
+ ITEM Assertion OK : Window.DisplayHorizontalScrollBar is: True
+ ITEM Assertion OK : Window.DisplayHeadings is: False
+ ITEM Assertion OK : Window.DisplayHeadings is: True
+ ITEM Assertion OK : Window.DisplayOutline is: False
+ ITEM Assertion OK : Window.DisplayOutline is: True
+ ITEM Assertion OK : Window.Visible is: False
+ ITEM Assertion OK : Window.Visible is: True
+ ITEM Assertion OK : Window.Caption is: MyCaption
+ ITEM Assertion OK : Pane.ScrollColumn is: 100
+ ITEM Assertion OK : Pane.ScrollColumn is: 1
+ ITEM Assertion OK : Pane.ScrollRow is: 100
+ ITEM Assertion OK : Pane.ScrollRow is: 1
+ ITEM Assertion OK : Pane.LargeScroll(Down): ScrollRow is: 127 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.LargeScroll(Up): ScrollRow is: 1
+ ITEM Assertion OK : Pane.LargeScroll(ToRight): ScrollColumn is: 58 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.LargeScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Pane.SmallScroll(ToRight): ScrollColumn is: 4 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.SmallScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window Selection: $A$2:$D$5
+ ITEM Assertion OK : ActiveSheet name of Window: Sheet1
+ ITEM Assertion OK : Window ActiveCell: $A$1
+END 'Window-Issue' Symbol
+ TEST OK : Window-Issue
+Test run finished : 08/10/2008 12:09:50
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/bytearraystring.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/bytearraystring.log
new file mode 100644
index 000000000000..8913fc096dc2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/bytearraystring.log
@@ -0,0 +1,8 @@
+Test run started : 08/10/2008 12:54:46
+BEGIN Bytearray To String
+ TEST START : Test the conversion between bytearray and string
+ ITEM Assertion OK : The number of byte is:6
+ ITEM Assertion OK : the return string is: abc
+ TEST OK : Test the conversion between bytearray and string
+END Bytearray To String
+Test run finished : 08/10/2008 12:54:46
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/dateserial.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/dateserial.log
new file mode 100644
index 000000000000..0b02f7b91a2c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/dateserial.log
@@ -0,0 +1,9 @@
+Test run started : 08/10/2008 12:56:07
+BEGIN DateSerial
+ TEST START : Test DateSerial function
+ ITEM Assertion OK : the return date is: 15/06/1999
+ ITEM Assertion OK : the return date is: 15/06/1999
+ ITEM Assertion OK : the return date is: 15/06/1999
+ TEST OK : Test DateSerial function
+END DateSerial
+Test run finished : 08/10/2008 12:56:07
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/datevalue.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/datevalue.log
new file mode 100644
index 000000000000..4698463362d2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/datevalue.log
@@ -0,0 +1,8 @@
+Test run started : 08/10/2008 13:07:49
+BEGIN DateValue
+ TEST START : Test DateValue function
+ ITEM Assertion OK : the return date is: 12/02/1969
+ ITEM Assertion OK : the return date is: 21/01/2008
+ TEST OK : Test DateValue function
+END DateValue
+Test run finished : 08/10/2008 13:07:49
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/format.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/format.log
new file mode 100644
index 000000000000..ef84cbbdb925
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/format.log
@@ -0,0 +1,36 @@
+Test run started : 15/01/2009 17:07:59
+BEGIN Format
+ TEST START : Test Predefined_Number_Format_Sample function
+ ITEM Assertion OK : General Number: 562486.2356
+ ITEM Assertion OK : Fixed: 0.20
+ ITEM Assertion OK : Standard: 562,486.24
+ ITEM Assertion OK : Percent: 75.21%
+ ITEM Assertion OK : Scientific: 5.62E+05
+ ITEM Assertion OK : Scientific: -3.46E+03
+ ITEM Assertion OK : Yes/No: No
+ ITEM Assertion OK : Yes/No: Yes
+ ITEM Assertion OK : True/False: False
+ ITEM Assertion OK : True/False: True
+ ITEM Assertion OK : On/Off: Off
+ ITEM Assertion OK : On/Off: On
+ TEST OK : Test Predefined_Number_Format_Sample function
+ TEST START : Test Custom_Number_Format_Sample function
+ ITEM Assertion OK : 00.0000: 23.6750
+ ITEM Assertion OK : 00.00: 23.68
+ ITEM Assertion OK : 00000: 02658
+ ITEM Assertion OK : 00.00: 2658.00
+ ITEM Assertion OK : ##.####: 23.675
+ ITEM Assertion OK : ##.##: 23.68
+ ITEM Assertion OK : #,###.##: 12,345.25
+ ITEM Assertion OK : ##.00%: 25.00%
+ ITEM Assertion OK : #,###: 1,000,000
+ ITEM Assertion OK : ######E-###: 109838E-5
+ ITEM Assertion OK : $#,###.##: $2,345.25
+ ITEM Assertion OK : ##.###\%: .25%
+ TEST OK : Test Custom_Number_Format_Sample function
+ TEST START : Test Custom_Text_Format_Sample function
+ ITEM Assertion OK : <: vba
+ ITEM Assertion OK : >: VBA
+ TEST OK : Test Custom_Text_Format_Sample function
+END Format
+Test run finished : 15/01/2009 17:07:59
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/pagesetup.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/pagesetup.log
new file mode 100644
index 000000000000..a1c90473ce07
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/pagesetup.log
@@ -0,0 +1,87 @@
+Test run started : 7/21/2008 10:37:24 AM
+BEGIN PageSetup
+ TEST START : Sheet_PrintArea
+ ITEM Assertion OK : PrintArea has changed as expected
+ TEST OK : Sheet_PrintArea
+ TEST START : Test margins (no headers)
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.RightMargin set/get
+ ITEM Assertion OK : PageSetup.TopMargin set/get
+ ITEM Assertion OK : PageSetup.BottomMargin set/get
+Verify that page margins on sheet 1 are all 0.5inch
+ TEST OK : Test margins (no headers)
+ TEST START : Test margins (headers)
+ ITEM Assertion OK : PageSetup.HeaderMargin set/get
+ ITEM Assertion OK : PageSetup.FooterMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+Verify that top/bottom/header/footer page margins on sheet 2 are all 0.5inch
+ TEST OK : Test margins (headers)
+ TEST START : Test header/footer text
+ ITEM Assertion OK : PageSetup.LeftHeader set
+ ITEM Assertion OK : PageSetup.LeftHeader set/get
+ ITEM Assertion OK : PageSetup.CenterHeader set
+ ITEM Assertion OK : PageSetup.CenterHeader set/get
+ ITEM Assertion OK : PageSetup.RightHeader set
+ ITEM Assertion OK : PageSetup.RightHeader set/get
+ ITEM Assertion OK : PageSetup.LeftFooter set
+ ITEM Assertion OK : PageSetup.LeftFooter set/get
+ ITEM Assertion OK : PageSetup.CenterFooter set
+ ITEM Assertion OK : PageSetup.CenterFooter set/get
+ ITEM Assertion OK : PageSetup.RightFooter set
+ ITEM Assertion OK : PageSetup.RightFooter set/get
+Verify that headers on sheet 2 are Ready,to,go
+Verify that footers on sheet 2 are This,now,Works
+ TEST OK : Test header/footer text
+ TEST START : Test zoom
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Zoom set/get
+Verify that sheet 1 zoom is 10%
+ TEST OK : Test zoom
+ TEST START : Test orientation
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Orientation set/get
+Verify that sheet 1 orientation is now landscape
+ TEST OK : Test orientation
+ TEST START : Test paper size
+ ITEM Assertion OK : PageSetup.PaperSize get
+ ITEM Assertion OK : PageSetup.PaperSize set/get
+Verify that paper size on sheet 1 is now Letter
+ TEST OK : Test paper size
+ TEST START : Test order
+ ITEM Assertion OK : PageSetup.Order get
+ ITEM Assertion OK : PageSetup.Order set/get
+Verify that order on sheet 1 is now over, then down.
+ TEST OK : Test order
+ TEST START : Test first page number
+ ITEM Assertion OK : PageSetup.FirstPageNumber get
+ ITEM Assertion OK : PageSetup.FirstPageNumber set/get
+Verify that first page number on sheet 1 is now 2.
+ TEST OK : Test first page number
+ TEST START : Test center vertically
+ ITEM Assertion OK : PageSetup.CenterVertically get
+ ITEM Assertion OK : PageSetup.CenterVertically set/get
+Verify that CenterVertically on sheet 1 is now true.
+ TEST OK : Test center vertically
+ TEST START : Test center horizontally
+ ITEM Assertion OK : PageSetup.CenterHorizontally get
+ ITEM Assertion OK : PageSetup.CenterHorizontally set/get
+Verify that CenterHorizontally on sheet 1 is now true.
+ TEST OK : Test center horizontally
+ TEST START : Test FitToPagesTall
+ ITEM Assertion OK : PageSetup.FitToPagesTall set/get
+ TEST OK : Test FitToPagesTall
+ TEST START : Test FitToPagesWide
+ ITEM Assertion OK : PageSetup.FitToPagesWide set/get
+ TEST OK : Test FitToPagesWide
+ TEST START : Test PrintHeadings
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ TEST OK : Test PrintHeadings
+ TEST START : Test PrintTitleRows
+ ITEM Assertion OK : PageSetup.PrintTitleRows get
+ ITEM Assertion OK : PageSetup.PrintTitleRows set range/get
+ ITEM Assertion OK : PageSetup.PrintTitleRows set false/get
+ TEST OK : Test PrintTitleRows
+END PageSetup
+Test run finished : 7/21/2008 10:37:32 AM
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/partition.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/partition.log
new file mode 100644
index 000000000000..1ea267d641e8
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/partition.log
@@ -0,0 +1,11 @@
+Test run started : 08/10/2008 13:09:51
+BEGIN Partition
+ TEST START : Test Partition function
+ ITEM Assertion OK : the number 20 occurs in the range:20:24
+ ITEM Assertion OK : the number 20 occurs in the range: 20: 20
+ ITEM Assertion OK : the number 120 occurs in the range:100:
+ ITEM Assertion OK : the number -5 occurs in the range: : -1
+ ITEM Assertion OK : the number 2 occurs in the range: 2: 3
+ TEST OK : Test Partition function
+END Partition
+Test run finished : 08/10/2008 13:09:51
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/range-4.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/range-4.log
new file mode 100644
index 000000000000..11de80133dfa
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/range-4.log
@@ -0,0 +1,16 @@
+Test run started : 08/10/2008 11:30:16
+----------------------------------------------------------------
+ShowDetail-Issue
+ TEST START : ShowDetail-Issue
+ ITEM Assertion OK : Range.ShowDetail is True
+ ITEM Assertion OK : Range.ShowDetail is False
+END 'ShowDetail-Issue' Symbol
+ TEST OK : ShowDetail-Issue
+----------------------------------------------------------------
+RangeMerged-Issue
+ TEST START : RangeMerged-Issue
+ ITEM Assertion OK : Range.RangeMerged is $F$2:$H$5
+ ITEM Assertion OK : The first address of Range.RangeMerged is $F$2
+END 'RangeMerged-Issue' Symbol
+ TEST OK : RangeMerged-Issue
+Test run finished : 08/10/2008 11:30:16
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/replace.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/replace.log
new file mode 100644
index 000000000000..e96004e4d2a6
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/replace.log
@@ -0,0 +1,14 @@
+Test run started : 2007-11-21 11:24:04
+BEGIN Replace
+ TEST START : Test Replace function
+ ITEM Assertion OK : common string:aefefdBc
+ ITEM Assertion OK : expression string:aefefdef
+ ITEM Assertion OK : binanary compare:aefefdBc
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : start = 3:cefdBc
+ ITEM Assertion OK : count = 2: aefefdBc
+ ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc
+ TEST OK : Test Replace function
+END Replace
+Test run finished : 2007-11-21 11:24:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/stringplusdouble.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/stringplusdouble.log
new file mode 100644
index 000000000000..51a958a412cf
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/stringplusdouble.log
@@ -0,0 +1,62 @@
+Test run started : 15/01/2009 17:09:03
+BEGIN String Plus Double
+ TEST START : double = string + double
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: 0
+The next compute raises error: s = null, d = 20, r = s + d
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 100
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 30
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = null, r = s & d
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s & d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: -1
+ TEST OK : double = string + double
+ TEST START : string = string + double
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: 0
+The next compute raises error: s = null, d = 20, r = s + d
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 100
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 30
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: abc0
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: abc20
+ TEST OK : string = string + double
+ TEST START : double = string + string
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+The next compute raises error: s = null, d = null, r = s & d
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: 20
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 10
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 1020
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = null, r = s & d
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s & d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: -1
+ TEST OK : double = string + string
+END String Plus Double
+Test run finished : 15/01/2009 17:09:03
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/window2.log b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/window2.log
new file mode 100644
index 000000000000..01fba9c6dfa6
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/logs/win/window2.log
@@ -0,0 +1,41 @@
+Test run started : 15/01/2009 17:10:02
+BEGIN Window2
+ TEST START : Test Window.SplitRow
+ ITEM Assertion OK : Test SplitColumn: 2 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion FAIL : Test SplitRow: 1 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitVertical: 242.283803521067
+ ITEM Assertion OK : Test SplitHorizontal: 242.283803521067
+ ITEM Assertion FAIL : Test SplitRow: 3 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitColumn: 3 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitColumn: 0
+ ITEM Assertion OK : Test SplitRow: 0
+ TEST OK : Test Window.SplitRow
+ TEST START : Test Window.DisplayGridlines
+ ITEM Assertion OK : Test gridlines are on
+ ITEM Assertion OK : Test gridlines are off
+ TEST OK : Test Window.DisplayGridlines
+ TEST START : Test Window.DisplayHeadings
+ ITEM Assertion OK : Test Headings are on
+ ITEM Assertion OK : Test Headings are off
+ TEST OK : Test Window.DisplayHeadings
+ TEST START : Test Window.Visibility
+ ITEM Assertion OK : Window is visible
+ ITEM Assertion OK : Window is not visible
+ TEST OK : Test Window.Visibility
+ TEST START : Test Window.FreezePanes
+ ITEM Assertion OK : Test no panes frozen
+ ITEM Assertion OK : Test panes frozen at center
+ ITEM Assertion OK : Test panes frozen at split
+ TEST OK : Test Window.FreezePanes
+ TEST START : Test Window.View
+ TEST OK : Test Window.View
+ TEST START : Test Window.Zoom
+ ITEM Assertion OK : Test zoom=100%
+ ITEM Assertion OK : Test zoom=150%
+ TEST OK : Test Window.Zoom
+ TEST START : Test Windows.Count
+ ITEM Assertion OK : Windows Count: 1
+ ITEM Assertion OK : Application.Windows Count: 1
+ TEST OK : Test Windows.Count
+END Window2
+Test run finished : 15/01/2009 17:10:03
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/error.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/error.xls
new file mode 100644
index 000000000000..ea2095d5e3d7
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/error.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/imagecontrols.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/imagecontrols.xls
new file mode 100644
index 000000000000..0de17b403f23
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/imagecontrols.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/keyword.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/keyword.xls
new file mode 100644
index 000000000000..3bf711ed4f42
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/keyword.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/objectmodule.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/objectmodule.xls
new file mode 100644
index 000000000000..d3aff35b938c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/objectmodule.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/stringtodouble.ods b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/stringtodouble.ods
new file mode 100644
index 000000000000..5a732a765886
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/notwork/stringtodouble.ods
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/partition.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/partition.xls
new file mode 100644
index 000000000000..5c8d12b1d54f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/partition.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/range-4.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/range-4.xls
new file mode 100644
index 000000000000..52452369462f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/range-4.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/replace.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/replace.xls
new file mode 100644
index 000000000000..dcf3c6e8ec06
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/replace.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/stringplusdouble.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/stringplusdouble.xls
new file mode 100644
index 000000000000..596be7f6b9bc
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/stringplusdouble.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments-ooo-build/window2.xls b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/window2.xls
new file mode 100644
index 000000000000..4d5e1cbfe944
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments-ooo-build/window2.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/ApplicationRunTest.xls b/sc/source/ui/vba/testvba/TestDocuments/ApplicationRunTest.xls
new file mode 100644
index 000000000000..a5a591c1f849
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/ApplicationRunTest.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/AutoFilter.xls b/sc/source/ui/vba/testvba/TestDocuments/AutoFilter.xls
new file mode 100644
index 000000000000..9b3a1043c5ee
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/AutoFilter.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/CalcFont.xls b/sc/source/ui/vba/testvba/TestDocuments/CalcFont.xls
new file mode 100644
index 000000000000..9ddb69600643
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/CalcFont.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/FinancialFuncs.xls b/sc/source/ui/vba/testvba/TestDocuments/FinancialFuncs.xls
new file mode 100644
index 000000000000..bb8941809947
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/FinancialFuncs.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xls b/sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xls
new file mode 100644
index 000000000000..ebd9e91b5b28
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/MiscRangeTests.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xls b/sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xls
new file mode 100644
index 000000000000..b6651fa5d617
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/PageBreaks.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xls b/sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xls
new file mode 100644
index 000000000000..f6e81cf933fd
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/Ranges-2.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xls b/sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xls
new file mode 100644
index 000000000000..8722f6d3057e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/Ranges-3.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls b/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls
new file mode 100644
index 000000000000..1c1d74d37486
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/Ranges.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/Shapes.xls b/sc/source/ui/vba/testvba/TestDocuments/Shapes.xls
new file mode 100644
index 000000000000..254f3c97756c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/Shapes.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/StrConv-test.xls b/sc/source/ui/vba/testvba/TestDocuments/StrConv-test.xls
new file mode 100755
index 000000000000..198abbec5871
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/StrConv-test.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/Template.xls b/sc/source/ui/vba/testvba/TestDocuments/Template.xls
new file mode 100755
index 000000000000..4387231fe744
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/Template.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls b/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls
new file mode 100644
index 000000000000..48d30cbe2e9e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/TestAddress.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xls b/sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xls
new file mode 100644
index 000000000000..a497d4f10f3e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xls b/sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xls
new file mode 100644
index 000000000000..34c606fc28f5
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/TestCalc_Rangetest2.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/TestIntersection.xls b/sc/source/ui/vba/testvba/TestDocuments/TestIntersection.xls
new file mode 100644
index 000000000000..24f88db87ccc
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/TestIntersection.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/TestUnion.xls b/sc/source/ui/vba/testvba/TestDocuments/TestUnion.xls
new file mode 100644
index 000000000000..5b8f0968cf38
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/TestUnion.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/Window.xls b/sc/source/ui/vba/testvba/TestDocuments/Window.xls
new file mode 100644
index 000000000000..6fb6963c2f31
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/Window.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/bytearraystring.xls b/sc/source/ui/vba/testvba/TestDocuments/bytearraystring.xls
new file mode 100755
index 000000000000..471bbc349e5b
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/bytearraystring.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/dateserial.xls b/sc/source/ui/vba/testvba/TestDocuments/dateserial.xls
new file mode 100755
index 000000000000..768fb513eba4
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/dateserial.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/datevalue.xls b/sc/source/ui/vba/testvba/TestDocuments/datevalue.xls
new file mode 100755
index 000000000000..852a51d100b8
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/datevalue.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/format.xls b/sc/source/ui/vba/testvba/TestDocuments/format.xls
new file mode 100644
index 000000000000..99ed64d38915
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/format.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/AutoFilter.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/AutoFilter.log
new file mode 100644
index 000000000000..1fe0cbd01fe5
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/AutoFilter.log
@@ -0,0 +1,20 @@
+Test run started : 17/07/2007 17:36:22
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 'starts with' string criteria
+ ITEM Assertion OK : test2 'not equal to' string criteria
+ ITEM Assertion OK : test3 'ends with' string criteria
+ ITEM Assertion OK : test4 field 'all'
+ ITEM Assertion OK : test5 numeric '<15'
+ ITEM Assertion OK : test6 numeric '>=15'
+ ITEM Assertion OK : test7 numeric '<=12'
+Test Results
+============
+
+Tests passed: 7
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 17/07/2007 17:36:23
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/MiscRangeTests.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/MiscRangeTests.log
new file mode 100644
index 000000000000..260465386d07
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/MiscRangeTests.log
@@ -0,0 +1,45 @@
+Test run started : 17/07/2007 15:01:37
+----------------------------------------------------------------
+MiscRangeTests
+ TEST START : MiscRangeTests
+ ITEM Assertion OK : test 1
+ ITEM Assertion OK : test 2
+ ITEM Assertion OK : test 3
+ ITEM Assertion OK : test 4
+ ITEM Assertion OK : test 5
+ ITEM Assertion OK : test 6
+ ITEM Assertion OK : test 7
+ ITEM Assertion OK : test 8
+ ITEM Assertion OK : test 9
+ ITEM Assertion OK : test 10
+ ITEM Assertion OK : test 11
+ ITEM Assertion OK : test 12
+ ITEM Assertion OK : test 13
+ ITEM Assertion OK : test 14
+ ITEM Assertion OK : test 15
+ ITEM Assertion OK : test 16
+ ITEM Assertion OK : test 17
+ ITEM Assertion OK : test 18
+ ITEM Assertion OK : test 19
+ ITEM Assertion OK : test 20
+ ITEM Assertion OK : test 21
+ ITEM Assertion OK : test 22
+ ITEM Assertion OK : test 23
+ ITEM Assertion OK : test 24
+ ITEM Assertion OK : test 25
+ ITEM Assertion OK : test 26
+ ITEM Assertion OK : test 27
+ ITEM Assertion OK : test 28
+ ITEM Assertion OK : test 29
+ ITEM Assertion OK : test 30
+ ITEM Assertion OK : test 31
+No. tests: 31
+Summary
+=======
+Run: 31
+Passed: 31
+Failed: 0
+
+END 'MiscRangeTests
+ TEST OK : MiscRangeTests
+Test run finished : 17/07/2007 15:01:39
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-2.log
new file mode 100644
index 000000000000..736d5bbc42d0
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-2.log
@@ -0,0 +1,68 @@
+Test run started : 18/06/2007 17:50:04
+----------------------------------------------------------------
+ClearFormtsIssue
+ TEST START : ClearFormtsIssue
+ ITEM Assertion OK : Range.Font.Bold is: True
+ ITEM Assertion OK : Range.Font.Bold is: False
+END 'ClearFormtsIssue' Symbol
+ TEST OK : ClearFormtsIssue
+----------------------------------------------------------------
+VerticalAlignment-Issue
+ TEST START : VerticalAlignment-Issue
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : Range.VeritcalAlignment is Null
+END 'VerticalAlignment-Issue' Symbol
+ TEST OK : VerticalAlignment-Issue
+----------------------------------------------------------------
+HorizontalAlignment-Issue
+ TEST START : HorizontalAlignment-Issue
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : Range.HorizontalAlignment is Null
+END 'HorizontalAlignment-Issue' Symbol
+ TEST OK : HorizontalAlignment-Issue
+----------------------------------------------------------------
+WrapText-Issue
+ TEST START : WrapText-Issue
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : Range.WrapText is Null
+END 'WrapText-Issue' Symbol
+ TEST OK : WrapText-Issue
+----------------------------------------------------------------
+FontBorderIssues
+ TEST START : FontBorderIssues
+ ITEM Assertion OK : - = Borders.Color (getColor)
+ ITEM Assertion OK : - = Font.Color (getColor)
+END 'FontBorderIssues' Symbol
+ TEST OK : FontBorderIssues
+----------------------------------------------------------------
+RangeSizeIssues
+ TEST START : RangeSizeIssues
+ ITEM Assertion OK : Range.Left is: 114
+ ITEM Assertion OK : Range.Top is: 95.25
+ ITEM Assertion OK : Range.Width is: 216
+ ITEM Assertion OK : Range.Height is: 271.5
+END 'RangeSizeIssues' Symbol
+ TEST OK : RangeSizeIssues
+----------------------------------------------------------------
+ApplicationIssues
+ TEST START : ApplicationIssues
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Application.ActiveSheet.Name: Sheet1
+END 'ApplicationIssues' Symbol
+ TEST OK : ApplicationIssues
+Test run finished : 18/06/2007 17:50:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-3.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-3.log
new file mode 100644
index 000000000000..a7de979d5e13
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges-3.log
@@ -0,0 +1,8 @@
+Test run started : 19/06/2007 11:21:42
+----------------------------------------------------------------
+MyGoalseek-Issue
+ TEST START : MyGoalseek-Issue
+ ITEM Assertion OK : Variable Range value: 15
+END 'MyGoalseek-Issue' Symbol
+ TEST OK : MyGoalseek-Issue
+Test run finished : 19/06/2007 11:21:42
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges.log
new file mode 100644
index 000000000000..8c9644aac155
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/Ranges.log
@@ -0,0 +1,280 @@
+Test run started : 01/06/2007 11:28:58
+----------------------------------------------------------------
+ApplicationMethods
+ TEST START : ApplicationMethods
+ ITEM Assertion OK : Name of Workbook is: Ranges.xls
+ ITEM Assertion OK : Address of Application.Columns is: $A:$A
+ ITEM Assertion OK : Address of Application.Rows is: $1:$1
+ ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7
+ ITEM Assertion OK : Please check manually: DefaultFilePath is: C:\Documents and Settings\vituosity\My Documents
+ ITEM Assertion OK : Please check manually: Library Path is: C:\Program Files\Microsoft Office\OFFICE11\LIBRARY
+ ITEM Assertion OK : Please check manually: Template Path is: C:\Documents and Settings\vituosity\Application Data\Microsoft\Templates\
+ ITEM Assertion OK : FileSeparator is \
+ ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls
+END 'ApplicationMethods' Symbol
+ TEST OK : ApplicationMethods
+----------------------------------------------------------------
+Insert-Issue
+ TEST START : Insert-Issue
+ ITEM Assertion OK : Insert with xlShiftToRight: 10
+END 'Insert-Issue' Symbol
+ TEST OK : Insert-Issue
+----------------------------------------------------------------
+MergeCells-Issue
+ TEST START : MergeCells-Issue
+ ITEM Assertion OK : Range.MergeCells is True
+ ITEM Assertion OK : MergeCells is null: True
+ ITEM Assertion OK : RowCount after Merge: 6
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : MergeCells of Second Area is null : True
+ ITEM Assertion OK : MergeCells of Ranges is Null: True
+ ITEM Assertion OK : RowCount after Merge: 7
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+END 'MergeCells-Issue' Symbol
+ TEST OK : MergeCells-Issue
+----------------------------------------------------------------
+Areas-Issue
+ TEST START : Areas-Issue
+ ITEM Assertion OK : Range Areas Count is2
+ ITEM Assertion OK : First Range Address is: $E$8:$G$13
+ ITEM Assertion OK : First Row is: 8
+ ITEM Assertion OK : First Column is: 5
+ ITEM Assertion OK : EntireRow Address is: $8:$13,$13:$19
+ ITEM Assertion OK : EntireColumn Address is: $E:$G,$G:$K
+ ITEM Assertion OK : Range Count:53
+END 'Areas-Issue' Symbol
+ TEST OK : Areas-Issue
+----------------------------------------------------------------
+Fill-Methods-Issue
+ TEST START : Fill-Methods-Issue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyRightFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyBottomFillValue
+END 'Fill-Methods-Issue' Symbol
+ TEST OK : Fill-Methods-Issue
+----------------------------------------------------------------
+Range/Item-Method-Issue
+ TEST START : Range/Item-Method-Issue
+ ITEM Assertion OK : Range of multiple columns is: $A:$A,$C:$C
+ ITEM Assertion OK : Range of multiple rows is: $1:$1,$5:$7
+ ITEM Assertion OK : Range of several columns is: $C:$E,$D:$D
+ ITEM Assertion OK : Range of several rows is: $5:$8,$6:$10
+ ITEM Assertion OK : Range of several single cells is: $C$5,$E$8
+ ITEM Assertion OK : Range of several named ranges is: $L$1:$M$6,$E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range of a single Item Cell is: $E$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$10
+END 'Range/Item-Method-Issue' Symbol
+ TEST OK : Range/Item-Method-Issue
+----------------------------------------------------------------
+R1C1-Formulas-Issue
+ TEST START : R1C1-Formulas-Issue
+ ITEM Assertion OK : R1C1 Range.Formula is: =IF(OR(R[-2]C[1]=0,RC[2]="YES"),"")
+ ITEM Assertion OK : Range.Formula is: =IF(OR(J8=0,K10="YES"),"")
+END 'R1C1-Formulas-Issue' Symbol
+ TEST OK : R1C1-Formulas-Issue
+----------------------------------------------------------------
+Verify_Delete
+ TEST START : Verify_Delete
+ ITEM Assertion OK : Ranges are intersecting: $G$13
+ ITEM Assertion OK : Delete with Default: $AJ$4
+ ITEM Assertion OK : Delete with ShifttoLeft: $AJ$4
+ ITEM Assertion OK : Delete with ShiftUp: $M$22
+END 'Verify_Delete' Symbol
+ TEST OK : Verify_Delete
+----------------------------------------------------------------
+Value-Issue
+ TEST START : Value-Issue
+ ITEM Assertion OK : Value of Range is: 12.3
+ ITEM Assertion OK : Text of Range is: 12.3
+ ITEM Assertion OK : Range has Formula: False
+ ITEM Assertion OK : Cell has Formula: False
+ ITEM Assertion OK : Text of Range is null: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Cell has Formula: True
+ ITEM Assertion OK : Value of Cell is: 12
+ ITEM Assertion OK : Application.Calculation is : -4135
+ ITEM Assertion OK : Calculation is automated: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Value of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Range has Formula after 'ClearContents: False
+ ITEM Assertion OK : Text of Cell is:
+ ITEM Assertion OK : Text of Cell is:
+END 'Value-Issue' Symbol
+ TEST OK : Value-Issue
+----------------------------------------------------------------
+AutoFit issue
+ TEST START : AutoFit issue
+ ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 673
+ ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 612
+END 'AutoFit issue' Symbol
+ TEST OK : AutoFit issue
+----------------------------------------------------------------
+Selections
+ TEST START : Selections
+ ITEM Assertion OK : ActiveCell is : $E$8
+ ITEM Assertion OK : Active Cell is : $E$8
+ ITEM Assertion OK : Number of Cells in Range: 53
+ ITEM Assertion OK : Number of Cells in Range: 53
+ ITEM Assertion OK : Number of Cells in Range: 53
+END 'Selections' Symbol
+ TEST OK : Selections
+----------------------------------------------------------------
+Offset-Resize
+ TEST START : Offset-Resize
+ ITEM Assertion OK : Offset is : $G$10:$I$15,$I$15:$M$21
+ ITEM Assertion OK : Offset is : $G$7:$I$12,$I$12:$M$18
+ ITEM Assertion OK : Resized Range is : $A$20:$D$23
+END 'Offset-Resize' Symbol
+ TEST OK : Offset-Resize
+----------------------------------------------------------------
+Ranges-Address
+ TEST START : Ranges-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: $E8:$G13,$G13:$K19
+ ITEM Assertion OK : Range Address is: E$8:G$13,G$13:K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5],R[11]C[5]:R[17]C[9]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13,$G$13:$K$19
+END 'Ranges-Address' Symbol
+ TEST OK : Ranges-Address
+----------------------------------------------------------------
+Range-Address
+ TEST START : Range-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: $E8:$G13
+ ITEM Assertion OK : Range Address is: E$8:G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13
+END 'Range-Address' Symbol
+ TEST OK : Range-Address
+----------------------------------------------------------------
+Column-Address
+ TEST START : Column-Address
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: $F8:$F13
+ ITEM Assertion OK : Range Address is: F$8:F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R[6]C[4]:R[11]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$8:$F$13
+END 'Column-Address' Symbol
+ TEST OK : Column-Address
+----------------------------------------------------------------
+Row-Address
+ TEST START : Row-Address
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: $E9:$G9
+ ITEM Assertion OK : Range Address is: E$9:G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R[7]C[3]:R[7]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$9:$G$9
+END 'Row-Address' Symbol
+ TEST OK : Row-Address
+----------------------------------------------------------------
+SingleCell-Address
+ TEST START : SingleCell-Address
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: $F9
+ ITEM Assertion OK : Range Address is: F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R[7]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$9
+END 'SingleCell-Address' Symbol
+ TEST OK : SingleCell-Address
+----------------------------------------------------------------
+Heights and Widths
+ TEST START : Heights and Widths
+ ITEM Assertion OK : Range RowHeight is 40
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 238
+ ITEM Assertion OK : Range Width is 798.75
+ ITEM Assertion OK : Range RowHeight is 50
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 297
+ ITEM Assertion OK : Range Width is 798.75
+ ITEM Assertion OK : RowHeight is null: True
+ ITEM Assertion OK : ColumnWidth is null: True
+END 'Heights and Widths' Symbol
+ TEST OK : Heights and Widths
+----------------------------------------------------------------
+RangeRowColumn-Issue
+ TEST START : RangeRowColumn-Issue
+ ITEM Assertion OK : Row is: 8
+ ITEM Assertion OK : Column is: 5
+ ITEM Assertion OK : EntireRow.Columns.Count = 256
+ ITEM Assertion OK : EntireColumn.Rows.Count = 65536
+END 'RangeRowColumn-Issue' Symbol
+ TEST OK : RangeRowColumn-Issue
+----------------------------------------------------------------
+Replace-Issue
+ TEST START : Replace-Issue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New Replace
+ ITEM Assertion OK : Value after Replace:
+END 'Replace-Issue' Symbol
+ TEST OK : Replace-Issue
+----------------------------------------------------------------
+Hidden-Issue
+ TEST START : Hidden-Issue
+ ITEM Assertion OK : - Range.Rows.Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Hidden (get)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (get)
+END 'Hidden-Issue' Symbol
+ TEST OK : Hidden-Issue
+----------------------------------------------------------------
+End issue
+ TEST START : End issue
+ ITEM Assertion OK : - = $E$48
+ ITEM Assertion OK : - = $E$1
+ ITEM Assertion OK : - = $E$3
+ ITEM Assertion OK : - = $A$8
+ ITEM Assertion OK : - = $B$8
+ ITEM Assertion OK : - = $IV$8
+ ITEM Assertion OK : - = $Z$8
+END 'End issue' Symbol
+ TEST OK : End issue
+----------------------------------------------------------------
+Outline issue
+ TEST START : Outline issue
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+END 'Outline issue' Symbol
+ TEST OK : Outline issue
+----------------------------------------------------------------
+Validation
+ TEST START : Validation
+ ITEM Assertion OK : Validation Input Message is : Attention!
+ ITEM Assertion OK : Validation Input Message is : Enter an integer from five to ten
+ ITEM Assertion OK : Validation Error Title is : You must enter a number from five to ten
+ ITEM Assertion OK : Validation Error Message is : An Error occured
+ ITEM Assertion OK : Validation Error Title is : Microsoft Excel
+END 'Validation' Symbol
+ TEST OK : Validation
+Test run finished : 01/06/2007 11:29:00
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestAddress.log
new file mode 100644
index 000000000000..01e5503a7e62
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestAddress.log
@@ -0,0 +1,62 @@
+Test run started : 17/07/2007 15:25:17
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 Range('e3:f3') A1 style addressing
+ ITEM Assertion OK : test2 Range('e3:f3') R1C1 style addressing
+ ITEM Assertion OK : test3 Range ('e:f') A1 style addressing
+ ITEM Assertion OK : test4 Range ('e:f') R1C1 style addressing
+ ITEM Assertion OK : test5 Columns A1 style addressing
+ ITEM Assertion OK : test6 Columns R1C1 style addressing
+ ITEM Assertion OK : test7 Columns(3) A1 style addressing
+ ITEM Assertion OK : test8 Columns(3) R1C1 style addressing
+ ITEM Assertion OK : test9 Columns('e') A1 style addressing
+ ITEM Assertion OK : test10 Columns('e') R1C1 style addressing
+ ITEM Assertion OK : test11 Columns('b:d') A1 style addressing
+ ITEM Assertion OK : test12 Columns('b:d') R1C1 style addressing
+ ITEM Assertion OK : test13 Range('c1:g10').Columns A1 style addressing
+ ITEM Assertion OK : test14 Range('c1:g10').Columns R1C1 style addressing
+ ITEM Assertion OK : test15 Range('c1:g10').Columns(1) A1 style addressing
+ ITEM Assertion OK : test16 Range('c1:g10').Columns(1) R1C1 style addressing
+ ITEM Assertion OK : test17 Range('c1:g10').Columns('a') A1 style addressing
+ ITEM Assertion OK : test18 Range('c1:g10').Columns('a') R1C1 style addressing
+ ITEM Assertion OK : test19 Range('c1:g10').Columns('c') A1 style addressing
+ ITEM Assertion OK : test20 Range('c1:g10').Columns('c') R1C1 style addressing
+ ITEM Assertion OK : test21 Range('c1:g10').Columns('x:z') A1 style addressing
+ ITEM Assertion OK : test22 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test23 Range('c1:g10').Columns(30) A1 style addressing
+ ITEM Assertion OK : test24 Range('c1:g10').Columns(30) R1C1 style addressing
+ ITEM Assertion OK : test25 Worksheets('Sheet2').Cells(1, 1) A1 style addressing
+ ITEM Assertion OK : test26 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, RowAddressAbsolute is false
+ ITEM Assertion OK : test27 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, ColAddressAbsolute is false
+ ITEM Assertion OK : test28 Worksheets('Sheet2').Cells(1, 1) R1C1 style addressing
+ ITEM Assertion OK : test29 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test30 Worksheets('Sheet2').Range('A1').EntireColumn A1 style addressing
+ ITEM Assertion OK : test31 Worksheets('Sheet2').Range('A1:E5').EntireRow A1 style addressing
+ ITEM Assertion OK : test32 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test33 Worksheets('Sheet2').Range('IV65536').EntireRow A1 style addressing
+ ITEM Assertion OK : test34 Worksheets('Sheet2').Range('IU2:IV65536') A1 style addressing
+ ITEM Assertion OK : test35 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test36 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test37 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test38 Worksheets('Sheet2').Range('10:12') A1 style addressing
+ ITEM Assertion OK : test39 Worksheets('Sheet2').Range('10:12') R1C1 style addressing
+ ITEM Assertion OK : test40 Range('Sheet3!A1:B4') A1 style addressing
+ ITEM Assertion OK : test41 Range('Sheet3!A1,B1,D4:F20') A1 style addressing
+ ITEM Assertion OK : test42 Range('g20:h40').Columns('c:c')
+ ITEM Assertion OK : test43 Range('g20:h40').Columns('c:f')
+ ITEM Assertion OK : test44 Range('g20:h40').Columns(-1)
+ ITEM Assertion OK : test45 Range('c4:g10').Rows(-1)
+ ITEM Assertion OK : test46 Range('a2:b4').Rows('1:1')
+ ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2')
+ ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2')
+ ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3')
+Test Results
+============
+
+Tests passed: 49
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 17/07/2007 15:25:19
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest.log
new file mode 100644
index 000000000000..f055279ec6f4
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest.log
@@ -0,0 +1,60 @@
+Test run started : 30/05/2007 11:33:13
+BEGIN TestCalc
+ TEST START : RangeTest2
+ ITEM Assertion OK : - Range("D15").Row
+ ITEM Assertion OK : - WorkSheet("D15").Range.Row
+ ITEM Assertion OK : - Range("D15").Column
+ ITEM Assertion OK : - Worksheet.Range("D15").Column
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Columns.Count
+ ITEM Assertion OK : - Range("D1").EntireColumn.Rows.Count
+ ITEM Assertion OK : - Range("D15").ClearContent
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (get)
+ ITEM Assertion OK : - Range("B38").Orientation (get)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlDownward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlUpward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B39").WrapText (get)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (get)
+ ITEM Assertion OK : - Range("F39").MergeCells (get)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("D41:D42").Replace MatchCase:=False
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM OK (RangeTest2)
+ TEST succesfully completed : RangeTest2
+END TestCalc
+Test run finished : 30/05/2007 11:33:14
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest2.log
new file mode 100644
index 000000000000..19a5ba96b54a
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/excel/TestCalc_Rangetest2.log
@@ -0,0 +1,64 @@
+Test run started : 31/05/2007 11:02:10
+BEGIN TestCalc
+ TEST START : RangeTest3
+ ITEM Assertion OK : - setFormulaR1C1
+ ITEM Assertion OK : - getFormulaR1C1
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy(Range("I10"))
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteValues
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormulas
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormats
+ ITEM Assertion OK : PasteSpecial
+ ITEM Assertion OK : PasteSpecial SkipBlanks:=True
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationAdd
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationSubtract
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationMultiply
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationDivide
+ ITEM Assertion OK : PasteSpecial Transpose:=True
+ ITEM Assertion OK : ActiveWorkbook.Name
+ ITEM Assertion OK : ActiveWorkbook.FullName und ActiveWorkbook.Path
+ ITEM Assertion OK : - = Range("K22").End (xlDown)
+ ITEM Assertion OK : - = Range("K22").End (xlUo)
+ ITEM Assertion OK : - = Range("K22").End (xlToLeft)
+ ITEM Assertion OK : - = Range("K22").End (xlRight)
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="x"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="<>"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="="
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter
+ ITEM Assertion OK : - ActiveSheet.Resize.Select
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Application.GoTo Reference:="R[8]C[2]"
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Ungroup- please check visually
+ ITEM Assertion OK : - Range.Ungroup - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - ActiveSheet.UsedRange.Select
+ ITEM Assertion FAIL : - Range("A13").AddIndent
+ ITEM Assertion OK : - Range("A13").IndentLevel set
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Calculate
+ ITEM Assertion OK : Worksheet.Calculate
+ ITEM Assertion OK : - Application.Calculate
+ ITEM Assertion OK : Global.Calculate
+ ITEM Assertion OK : Calculation set
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) set
+ ITEM Assertion OK : - = ActiveWorkbook.ResetColors
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) get
+ ITEM FAIL (RangeTest3)
+ TEST Not succesfully completed : RangeTest3
+END TestCalc
+Test run finished : 31/05/2007 11:02:12
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/AutoFilter.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/AutoFilter.log
new file mode 100644
index 000000000000..55f5d9526618
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/AutoFilter.log
@@ -0,0 +1,20 @@
+Test run started : 18/07/2007 10:56:38
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 'starts with' string criteria
+ ITEM Assertion OK : test2 'not equal to' string criteria
+ ITEM Assertion OK : test3 'ends with' string criteria
+ ITEM Assertion OK : test4 field 'all'
+ ITEM Assertion OK : test5 numeric '<15'
+ ITEM Assertion OK : test6 numeric '>=15'
+ ITEM Assertion OK : test7 numeric '<=12'
+Test Results
+============
+
+Tests passed: 7
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 18/07/2007 10:56:44
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/CalcFont.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/CalcFont.log
new file mode 100644
index 000000000000..f3583e4cbb12
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/CalcFont.log
@@ -0,0 +1,17 @@
+Test run started : 10/09/2008 02:40:17 PM
+CalcFont_Format
+ TEST START : Font_Format
+ ITEM Assertion OK : correctly set font to Bold
+ ITEM Assertion OK : correctly set font to Italic
+ ITEM Assertion OK : correctly read FontStyle
+ ITEM Assertion OK : correctly set font to Shadow
+ ITEM Assertion OK : correctly set font color
+ ITEM Assertion OK : correctly set font color index
+ ITEM Assertion OK : correctly set font name
+ ITEM Assertion OK : correctly set font outline
+ ITEM Assertion OK : correctly set font size
+ ITEM Assertion OK : correctly set font strikethrough
+ ITEM Assertion OK : correctly set font underline
+ TEST Success. : Font_Format
+CalcFont_Format
+Test run finished : 10/09/2008 02:40:17 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/MiscRangeTests.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/MiscRangeTests.log
new file mode 100644
index 000000000000..215842f9a7e6
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/MiscRangeTests.log
@@ -0,0 +1,45 @@
+Test run started : 17/07/2007 20:54:56
+----------------------------------------------------------------
+MiscRangeTests
+ TEST START : MiscRangeTests
+ ITEM Assertion OK : test 1
+ ITEM Assertion OK : test 2
+ ITEM Assertion OK : test 3
+ ITEM Assertion OK : test 4
+ ITEM Assertion OK : test 5
+ ITEM Assertion OK : test 6
+ ITEM Assertion OK : test 7
+ ITEM Assertion OK : test 8
+ ITEM Assertion OK : test 9
+ ITEM Assertion OK : test 10
+ ITEM Assertion OK : test 11
+ ITEM Assertion OK : test 12
+ ITEM Assertion OK : test 13
+ ITEM Assertion OK : test 14
+ ITEM Assertion OK : test 15
+ ITEM Assertion OK : test 16
+ ITEM Assertion OK : test 17
+ ITEM Assertion OK : test 18
+ ITEM Assertion OK : test 19
+ ITEM Assertion OK : test 20
+ ITEM Assertion OK : test 21
+ ITEM Assertion OK : test 22
+ ITEM Assertion OK : test 23
+ ITEM Assertion OK : test 24
+ ITEM Assertion OK : test 25
+ ITEM Assertion OK : test 26
+ ITEM Assertion OK : test 27
+ ITEM Assertion OK : test 28
+ ITEM Assertion OK : test 29
+ ITEM Assertion OK : test 30
+ ITEM Assertion OK : test 31
+No. tests: 31
+Summary
+=======
+Run: 31
+Passed: 31
+Failed: 0
+
+END 'MiscRangeTests
+ TEST OK : MiscRangeTests
+Test run finished : 17/07/2007 20:55:03
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/PageBreaks.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/PageBreaks.log
new file mode 100644
index 000000000000..0ff400d49e85
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/PageBreaks.log
@@ -0,0 +1,10 @@
+Test run started : 07/24/2008 05:06:12 PM
+----------------------------------------------------------------
+ TEST START : PageBreaks-Issue
+ ITEM Assertion OK : HPageBreaks.Count is 3
+ ITEM Assertion OK : HPageBreak.Type is -4135
+ ITEM Assertion OK : HPageBreak.Location: Range.Row is 5
+ ITEM Assertion OK : HPageBreak.Delete: HPageBreaks.Count is 2
+END 'PageBreaks-Issue' Symbol
+ TEST OK : PageBreaks-Issue
+Test run finished : 07/24/2008 05:06:13 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-2.log
new file mode 100644
index 000000000000..8b7076efaea0
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-2.log
@@ -0,0 +1,68 @@
+Test run started : 19/06/2007 11:14:01
+----------------------------------------------------------------
+ClearFormtsIssue
+ TEST START : ClearFormtsIssue
+ ITEM Assertion OK : Range.Font.Bold is: True
+ ITEM Assertion OK : Range.Font.Bold is: False
+END 'ClearFormtsIssue' Symbol
+ TEST OK : ClearFormtsIssue
+----------------------------------------------------------------
+VerticalAlignment-Issue
+ TEST START : VerticalAlignment-Issue
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : Range.VeritcalAlignment is Null
+END 'VerticalAlignment-Issue' Symbol
+ TEST OK : VerticalAlignment-Issue
+----------------------------------------------------------------
+HorizontalAlignment-Issue
+ TEST START : HorizontalAlignment-Issue
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : Range.HorizontalAlignment is Null
+END 'HorizontalAlignment-Issue' Symbol
+ TEST OK : HorizontalAlignment-Issue
+----------------------------------------------------------------
+WrapText-Issue
+ TEST START : WrapText-Issue
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : Range.WrapText is Null
+END 'WrapText-Issue' Symbol
+ TEST OK : WrapText-Issue
+----------------------------------------------------------------
+FontBorderIssues
+ TEST START : FontBorderIssues
+ ITEM Assertion OK : - = Borders.Color (getColor)
+ ITEM Assertion OK : - = Font.Color (getColor)
+END 'FontBorderIssues' Symbol
+ TEST OK : FontBorderIssues
+----------------------------------------------------------------
+RangeSizeIssues
+ TEST START : RangeSizeIssues
+ ITEM Assertion OK : Range.Left is: 118.8432
+ ITEM Assertion OK : Range.Top is: 92.16585
+ ITEM Assertion OK : Range.Width is: 226.2
+ ITEM Assertion OK : Range.Height is: 271.5
+END 'RangeSizeIssues' Symbol
+ TEST OK : RangeSizeIssues
+----------------------------------------------------------------
+ApplicationIssues
+ TEST START : ApplicationIssues
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Application.ActiveSheet.Name: Sheet1
+END 'ApplicationIssues' Symbol
+ TEST OK : ApplicationIssues
+Test run finished : 19/06/2007 11:14:02
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-3.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-3.log
new file mode 100644
index 000000000000..a130737ceb65
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges-3.log
@@ -0,0 +1,8 @@
+Test run started : 19/06/2007 11:26:09
+----------------------------------------------------------------
+MyGoalseek-Issue
+ TEST START : MyGoalseek-Issue
+ ITEM Assertion OK : Variable Range value: 15
+END 'MyGoalseek-Issue' Symbol
+ TEST OK : MyGoalseek-Issue
+Test run finished : 19/06/2007 11:26:10
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log
new file mode 100644
index 000000000000..cdd18685e977
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Ranges.log
@@ -0,0 +1,280 @@
+Test run started : 10/03/2008 15:15:11
+----------------------------------------------------------------
+ApplicationMethods
+ TEST START : ApplicationMethods
+ ITEM Assertion OK : Name of Workbook is: Ranges.xls
+ ITEM Assertion OK : Address of Application.Columns is: $A:$A
+ ITEM Assertion OK : Address of Application.Rows is: $1:$1
+ ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7
+ ITEM Assertion OK : Please check manually: DefaultFilePath is: /data4/home/npower/Documents
+ ITEM Assertion OK : Please check manually: Library Path is: /data4/home/npower/.ooo-2.0/user/basic
+ ITEM Assertion OK : Please check manually: Template Path is: /data4/home/npower/.ooo-2.0/user/template
+ ITEM Assertion OK : FileSeparator is /
+ ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls
+END 'ApplicationMethods' Symbol
+ TEST OK : ApplicationMethods
+----------------------------------------------------------------
+Insert-Issue
+ TEST START : Insert-Issue
+ ITEM Assertion OK : Insert with xlShiftToRight: 10
+END 'Insert-Issue' Symbol
+ TEST OK : Insert-Issue
+----------------------------------------------------------------
+MergeCells-Issue
+ TEST START : MergeCells-Issue
+ ITEM Assertion OK : Range.MergeCells is True
+ ITEM Assertion FAIL : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 13
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion FAIL : MergeCells of Second Area is null : False
+ ITEM Assertion FAIL : MergeCells of Ranges is Null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+END 'MergeCells-Issue' Symbol
+ TEST OK : MergeCells-Issue
+----------------------------------------------------------------
+Areas-Issue
+ TEST START : Areas-Issue
+ ITEM Assertion OK : Range Areas Count is2
+ ITEM Assertion OK : First Range Address is: $E$8:$G$13
+ ITEM Assertion OK : First Row is: 8
+ ITEM Assertion OK : First Column is: 5
+ ITEM Assertion OK : EntireRow Address is: $8:$13,$13:$19
+ ITEM Assertion OK : EntireColumn Address is: $E:$G,$G:$K
+ ITEM Assertion OK : Range Count:53
+END 'Areas-Issue' Symbol
+ TEST OK : Areas-Issue
+----------------------------------------------------------------
+Fill-Methods-Issue
+ TEST START : Fill-Methods-Issue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyRightFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyBottomFillValue
+END 'Fill-Methods-Issue' Symbol
+ TEST OK : Fill-Methods-Issue
+----------------------------------------------------------------
+Range/Item-Method-Issue
+ TEST START : Range/Item-Method-Issue
+ ITEM Assertion OK : Range of multiple columns is: $A:$A,$C:$C
+ ITEM Assertion OK : Range of multiple rows is: $1:$1,$5:$7
+ ITEM Assertion OK : Range of several columns is: $C:$E,$D:$D
+ ITEM Assertion OK : Range of several rows is: $5:$8,$6:$10
+ ITEM Assertion OK : Range of several single cells is: $C$5,$E$8
+ ITEM Assertion OK : Range of several named ranges is: $L$1:$M$6,$E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range of a single Item Cell is: $E$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$10
+END 'Range/Item-Method-Issue' Symbol
+ TEST OK : Range/Item-Method-Issue
+----------------------------------------------------------------
+R1C1-Formulas-Issue
+ TEST START : R1C1-Formulas-Issue
+ ITEM Assertion OK : R1C1 Range.Formula is: =IF(OR(R[-2]C[1]=0,RC[2]="YES"),"")
+ ITEM Assertion OK : Range.Formula is: =IF(OR(J8=0,K10="YES"),"")
+END 'R1C1-Formulas-Issue' Symbol
+ TEST OK : R1C1-Formulas-Issue
+----------------------------------------------------------------
+Verify_Delete
+ TEST START : Verify_Delete
+ ITEM Assertion OK : Ranges are intersecting: $G$13
+ ITEM Assertion OK : Delete with Default: $AJ$4
+ ITEM Assertion OK : Delete with ShifttoLeft: $AJ$4
+ ITEM Assertion OK : Delete with ShiftUp: $M$22
+END 'Verify_Delete' Symbol
+ TEST OK : Verify_Delete
+----------------------------------------------------------------
+Value-Issue
+ TEST START : Value-Issue
+ ITEM Assertion OK : Value of Range is: 12.3
+ ITEM Assertion OK : Text of Range is: 12.3
+ ITEM Assertion OK : Range has Formula: False
+ ITEM Assertion OK : Cell has Formula: False
+ ITEM Assertion FAIL : Text of Range is null: False
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Cell has Formula: True
+ ITEM Assertion OK : Value of Cell is: 12
+ ITEM Assertion OK : Application.Calculation is : -4135
+ ITEM Assertion OK : Calculation is automated: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Value of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Range has Formula after 'ClearContents: False
+ ITEM Assertion OK : Text of Cell is:
+ ITEM Assertion OK : Text of Cell is:
+END 'Value-Issue' Symbol
+ TEST OK : Value-Issue
+----------------------------------------------------------------
+AutoFit issue
+ TEST START : AutoFit issue
+ ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 680
+ ITEM Assertion OK : Rows.AutoFit: CurrentHeight is 554
+END 'AutoFit issue' Symbol
+ TEST OK : AutoFit issue
+----------------------------------------------------------------
+Selections
+ TEST START : Selections
+ ITEM Assertion OK : ActiveCell is : $E$8
+ ITEM Assertion OK : Active Cell is : $E$8
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+END 'Selections' Symbol
+ TEST OK : Selections
+----------------------------------------------------------------
+Offset-Resize
+ TEST START : Offset-Resize
+ ITEM Assertion OK : Offset is : $G$10:$I$15,$I$15:$M$21
+ ITEM Assertion OK : Offset is : $G$7:$I$12,$I$12:$M$18
+ ITEM Assertion OK : Resized Range is : $A$20:$D$23
+END 'Offset-Resize' Symbol
+ TEST OK : Offset-Resize
+----------------------------------------------------------------
+Ranges-Address
+ TEST START : Ranges-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: $E8:$G13,$G13:$K19
+ ITEM Assertion OK : Range Address is: E$8:G$13,G$13:K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5],R[11]C[5]:R[17]C[9]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13,$G$13:$K$19
+END 'Ranges-Address' Symbol
+ TEST OK : Ranges-Address
+----------------------------------------------------------------
+Range-Address
+ TEST START : Range-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: $E8:$G13
+ ITEM Assertion OK : Range Address is: E$8:G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13
+END 'Range-Address' Symbol
+ TEST OK : Range-Address
+----------------------------------------------------------------
+Column-Address
+ TEST START : Column-Address
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: $F8:$F13
+ ITEM Assertion OK : Range Address is: F$8:F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion FAIL : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R[6]C[4]:R[11]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$8:$F$13
+END 'Column-Address' Symbol
+ TEST OK : Column-Address
+----------------------------------------------------------------
+Row-Address
+ TEST START : Row-Address
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: $E9:$G9
+ ITEM Assertion OK : Range Address is: E$9:G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion FAIL : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R[7]C[3]:R[7]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$9:$G$9
+END 'Row-Address' Symbol
+ TEST OK : Row-Address
+----------------------------------------------------------------
+SingleCell-Address
+ TEST START : SingleCell-Address
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: $F9
+ ITEM Assertion OK : Range Address is: F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion FAIL : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R[7]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$9
+END 'SingleCell-Address' Symbol
+ TEST OK : SingleCell-Address
+----------------------------------------------------------------
+Heights and Widths
+ TEST START : Heights and Widths
+ ITEM Assertion OK : Range RowHeight is 40
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 240
+ ITEM Assertion OK : Range Width is 795
+ ITEM Assertion OK : Range RowHeight is 50
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 300
+ ITEM Assertion OK : Range Width is 795
+ ITEM Assertion OK : RowHeight is null: True
+ ITEM Assertion OK : ColumnWidth is null: True
+END 'Heights and Widths' Symbol
+ TEST OK : Heights and Widths
+----------------------------------------------------------------
+RangeRowColumn-Issue
+ TEST START : RangeRowColumn-Issue
+ ITEM Assertion OK : Row is: 8
+ ITEM Assertion OK : Column is: 5
+ ITEM Assertion OK : EntireRow.Columns.Count = 256
+ ITEM Assertion OK : EntireColumn.Rows.Count = 131072
+END 'RangeRowColumn-Issue' Symbol
+ TEST OK : RangeRowColumn-Issue
+----------------------------------------------------------------
+Replace-Issue
+ TEST START : Replace-Issue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New Replace
+ ITEM Assertion OK : Value after Replace:
+END 'Replace-Issue' Symbol
+ TEST OK : Replace-Issue
+----------------------------------------------------------------
+Hidden-Issue
+ TEST START : Hidden-Issue
+ ITEM Assertion OK : - Range.Rows.Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Hidden (get)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (get)
+END 'Hidden-Issue' Symbol
+ TEST OK : Hidden-Issue
+----------------------------------------------------------------
+End issue
+ TEST START : End issue
+ ITEM Assertion OK : - = $E$48
+ ITEM Assertion OK : - = $E$1
+ ITEM Assertion OK : - = $E$3
+ ITEM Assertion OK : - = $A$8
+ ITEM Assertion OK : - = $B$8
+ ITEM Assertion OK : - = $IV$8
+ ITEM Assertion OK : - = $Z$8
+END 'End issue' Symbol
+ TEST OK : End issue
+----------------------------------------------------------------
+Outline issue
+ TEST START : Outline issue
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+END 'Outline issue' Symbol
+ TEST OK : Outline issue
+----------------------------------------------------------------
+Validation
+ TEST START : Validation
+ ITEM Assertion OK : Validation Input Message is : Attention!
+ ITEM Assertion OK : Validation Input Message is : Enter an integer from five to ten
+ ITEM Assertion OK : Validation Error Title is : You must enter a number from five to ten
+ ITEM Assertion OK : Validation Error Message is : An Error occured
+ ITEM Assertion OK : Validation Error Title is : Microsoft Excel
+END 'Validation' Symbol
+ TEST OK : Validation
+Test run finished : 10/03/2008 15:15:13
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Shapes.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Shapes.log
new file mode 100644
index 000000000000..3193a0b1094d
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Shapes.log
@@ -0,0 +1,77 @@
+Test run started : 10/16/2007 05:25:21 PM
+BEGIN Shapes_Collection_Behaviour
+ TEST START : Shapes_Collection_Behaviour
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape1'
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape2'
+ TEST Success. : Shapes_Collection_Behaviour
+END Shapes_Collection_Behaviour
+BEGIN Shapes_Select_Item
+ TEST START : Shapes_Select_Item
+ ITEM Assertion OK : Correctly selected shape through Range
+ ITEM Assertion OK : Correctly selected shape through Item
+ ITEM Assertion OK : Needs to be visually checked. Is there a line on the document?
+ ITEM Assertion OK : Needs to be visually checked. Are All Shapes Selected?
+ TEST Success. : Shapes_Select_Item
+END Shapes_Select_Item
+BEGIN Shapes_Fill
+ TEST START : Shapes_Fill
+ ITEM Assertion OK : correctly set visibility of shape fill
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set backcolor of shape fill
+ ITEM Assertion OK : the success of the TwoColorGradient method needs to be verified visually!
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set forecolor of shape fill
+ TEST Success. : Shapes_Fill
+END Shapes_Fill
+BEGIN Shapes_Line
+ TEST START : Shapes_Line
+ ITEM Assertion FAIL : correctly set weight of shape line
+ ITEM Assertion OK : correctly set visibility of shape line
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set forecolor of shape line
+ ITEM Assertion FAIL : correctly set backcolor of shape line
+ TEST Success. : Shapes_Line
+END Shapes_Line
+BEGIN Shapes_TextFrame
+ TEST START : Shapes_TextFrame
+ ITEM Assertion OK : correctly set Autosize of Shape TextFrame
+ TEST Success. : Shapes_TextFrame
+END Shapes_TextFrame
+BEGIN Shapes_SimpleGeometry
+ TEST START : Shapes_SimpleGeometery
+ ITEM Assertion OK : shape height should be 47.0425168477155 and got 46.9984222363199
+ ITEM Assertion OK : shape width should be 101.467710269751 and got 101.423615658355
+ ITEM Assertion OK : shape left should be 68.5574761223637 and got 68.5417279658754
+ ITEM Assertion OK : shape top should be 42.0251943291216 and got 42.0094461726333
+ ITEM Assertion OK : shape rotation should be 0 and got 0
+ ITEM Assertion OK : shape rotation should be 25 and got 25
+ ITEM Assertion OK : shape incrementrotation should be 50 and got 50
+ ITEM Assertion OK : shape incrementleft should be 70.6834602404119 and got 70.6677120839236
+ ITEM Assertion OK : shape incrementtop should be 91.262986503119 and got 91.2472383466307
+ TEST Success. : Shapes_SimpleGeometery
+END Shapes_SimpleGeometry
+BEGIN Shapes_Range
+ TEST START : Shapes_Range
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to return Sheet2Shape1 got Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to return Sheet2Shape3 got Sheet2Shape3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to contain 2 elements, it contains 2
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to return concated element/shape names Sheet2Shape3Sheet2Shape1 and got Sheet2Shape3Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to contain 3 elements, it contains 3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to return concated element/shape names Sheet2Shape3Sheet2Shape1Sheet2Shape2 and got Sheet2Shape3Sheet2Shape1Sheet2Shape2
+ TEST Success. : Shapes_Range
+END Shapes_Range
+BEGIN Shapes_ShapeRange
+ TEST START : Shapes_ShapeRange
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp1.left should be 90.6677120839236 and got 90.6519627935771
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp2.left should be 240.02518299054 and got 240.009433700193
+ ITEM Assertion OK : ShapeRange.IncrementTop shp1.Top should be 111.247238346631 and got 111.231489056284
+ ITEM Assertion OK : ShapeRange.IncrementTop shp2.Top should be 65.0708633026228 and got 65.0551140122763
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp1.Rotation should be 70 and got 70
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp2.Rotation should be 20 and got 20
+END Shapes_ShapeRange
+Test run finished : 10/16/2007 05:25:22 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/StrConv-test.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/StrConv-test.log
new file mode 100644
index 000000000000..c7a7d8750583
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/StrConv-test.log
@@ -0,0 +1,9 @@
+Test run started : 05/29/2008 02:51:03 PM
+BEGIN StrConv
+ TEST START : Test StrConv function
+ ITEM Assertion OK : Converts the string to uppercase characters:ABC EFG HIJ
+ ITEM Assertion OK : Converts the string to lowercase characters:abc efg hij
+ ITEM Assertion OK : Converts the first letter of every word in string to uppercase:Abc Efg Hij
+ TEST OK : Test StrConv function
+END StrConv
+Test run finished : 05/29/2008 02:51:03 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Template.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Template.log
new file mode 100644
index 000000000000..c6376c5b3732
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Template.log
@@ -0,0 +1,14 @@
+Test run started : 2008ï¼07ï¼10 11:57:05
+----------------------------------------------------------------
+TestCaseName
+ TEST START : TestCaseName
+ ITEM Assertion OK : Something has been done.
+Test Results
+============
+
+Tests passed: 1
+Tests failed: 0
+
+END 'TestCaseName
+ TEST OK : TestCaseName
+Test run finished : 2008ï¼07ï¼10 11:57:05
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log
new file mode 100644
index 000000000000..4fa4bc820f59
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestAddress.log
@@ -0,0 +1,67 @@
+Test run started : 12/05/2009 11:23:35
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 Range('e3:f3') A1 style addressing
+ ITEM Assertion OK : test2 Range('e3:f3') R1C1 style addressing
+ ITEM Assertion OK : test3 Range ('e:f') A1 style addressing
+ ITEM Assertion OK : test4 Range ('e:f') R1C1 style addressing
+ ITEM Assertion OK : test5 Columns A1 style addressing
+ ITEM Assertion OK : test6 Columns R1C1 style addressing
+ ITEM Assertion OK : test7 Columns(3) A1 style addressing
+ ITEM Assertion OK : test8 Columns(3) R1C1 style addressing
+ ITEM Assertion OK : test9 Columns('e') A1 style addressing
+ ITEM Assertion OK : test10 Columns('e') R1C1 style addressing
+ ITEM Assertion OK : test11 Columns('b:d') A1 style addressing
+ ITEM Assertion OK : test12 Columns('b:d') R1C1 style addressing
+ ITEM Assertion OK : test13 Range('c1:g10').Columns A1 style addressing
+ ITEM Assertion OK : test14 Range('c1:g10').Columns R1C1 style addressing
+ ITEM Assertion OK : test15 Range('c1:g10').Columns(1) A1 style addressing
+ ITEM Assertion OK : test16 Range('c1:g10').Columns(1) R1C1 style addressing
+ ITEM Assertion OK : test17 Range('c1:g10').Columns('a') A1 style addressing
+ ITEM Assertion OK : test18 Range('c1:g10').Columns('a') R1C1 style addressing
+ ITEM Assertion OK : test19 Range('c1:g10').Columns('c') A1 style addressing
+ ITEM Assertion OK : test20 Range('c1:g10').Columns('c') R1C1 style addressing
+ ITEM Assertion OK : test21 Range('c1:g10').Columns('x:z') A1 style addressing
+ ITEM Assertion OK : test22 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test23 Range('c1:g10').Columns(30) A1 style addressing
+ ITEM Assertion OK : test24 Range('c1:g10').Columns(30) R1C1 style addressing
+ ITEM Assertion OK : test25 Worksheets('Sheet2').Cells(1, 1) A1 style addressing
+ ITEM Assertion OK : test26 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, RowAddressAbsolute is false
+ ITEM Assertion OK : test27 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, ColAddressAbsolute is false
+ ITEM Assertion OK : test28 Worksheets('Sheet2').Cells(1, 1) R1C1 style addressing
+ ITEM Assertion OK : test29 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test30 Worksheets('Sheet2').Range('A1').EntireColumn A1 style addressing
+ ITEM Assertion OK : test31 Worksheets('Sheet2').Range('A1:E5').EntireRow A1 style addressing
+ ITEM Assertion OK : test32 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test33 Worksheets('Sheet2').Range('IV65536').EntireRow A1 style addressing
+ ITEM Assertion OK : test34 Worksheets('Sheet2').Range('IU2:IV65536') A1 style addressing
+ ITEM Assertion OK : test35 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test36 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test37 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test38 Worksheets('Sheet2').Range('10:12') A1 style addressing
+ ITEM Assertion OK : test39 Worksheets('Sheet2').Range('10:12') R1C1 style addressing
+ ITEM Assertion OK : test40 Range('Sheet3!A1:B4') A1 style addressing
+ ITEM Assertion OK : test41 Range('Sheet3!A1,B1,D4:F20') A1 style addressing
+ ITEM Assertion OK : test42 Range('g20:h40').Columns('c:c')
+ ITEM Assertion OK : test43 Range('g20:h40').Columns('c:f')
+ ITEM Assertion OK : test44 Range('g20:h40').Columns(-1)
+ ITEM Assertion OK : test45 Range('c4:g10').Rows(-1)
+ ITEM Assertion OK : test46 Range('a2:b4').Rows('1:1')
+ ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2')
+ ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2')
+ ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3')
+ ITEM Assertion OK : test50 Range(' A2:B4 ')
+ ITEM Assertion OK : test51 Range('A 2:B 4')
+ ITEM Assertion OK : test52 Range('A2 : B4 ')
+ ITEM Assertion OK : test53 Range('Sheet1 !A2 : B4 ')
+ ITEM Assertion OK : test54 Range('Sheet1! A2 : B4 ')
+Test Results
+============
+
+Tests passed: 54
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 12/05/2009 11:23:35
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest.log
new file mode 100644
index 000000000000..083819d4b64e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest.log
@@ -0,0 +1,60 @@
+Test run started : 30/05/2007 15:59:40
+BEGIN TestCalc
+ TEST START : RangeTest2
+ ITEM Assertion OK : - Range("D15").Row
+ ITEM Assertion OK : - WorkSheet("D15").Range.Row
+ ITEM Assertion OK : - Range("D15").Column
+ ITEM Assertion OK : - Worksheet.Range("D15").Column
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Columns.Count
+ ITEM Assertion OK : - Range("D1").EntireColumn.Rows.Count
+ ITEM Assertion OK : - Range("D15").ClearContent
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (get)
+ ITEM Assertion OK : - Range("B38").Orientation (get)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlDownward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlUpward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B39").WrapText (get)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (get)
+ ITEM Assertion OK : - Range("F39").MergeCells (get)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion FAIL : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("D41:D42").Replace MatchCase:=False
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM FAIL (RangeTest2)
+ TEST Not succesfully completed : RangeTest2
+END TestCalc
+Test run finished : 30/05/2007 15:59:42
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest2.log
new file mode 100644
index 000000000000..b1573c06d90e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestCalc_Rangetest2.log
@@ -0,0 +1,65 @@
+Test run started : 10/03/2008 15:15:19
+BEGIN TestCalc
+ TEST START : RangeTest3
+ ITEM Assertion OK : - setFormulaR1C1
+ ITEM Assertion OK : - getFormulaR1C1
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy(Range("I10"))
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteValues
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormulas
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormats
+ ITEM Assertion OK : PasteSpecial
+ ITEM Assertion OK : PasteSpecial SkipBlanks:=True
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationAdd
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationSubtract
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationMultiply
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationDivide
+ ITEM Assertion OK : PasteSpecial Transpose:=True
+ ITEM Assertion FAIL : ActiveWorkbook.FileFormat
+ ITEM Assertion OK : ActiveWorkbook.Name
+ ITEM Assertion OK : ActiveWorkbook.FullName und ActiveWorkbook.Path
+ ITEM Assertion FAIL : - = ActiveWorkbook.Colors(3) set
+ ITEM Assertion OK : - = ActiveWorkbook.ResetColors
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) get
+ ITEM Assertion OK : - = Range("K22").End (xlDown)
+ ITEM Assertion OK : - = Range("K22").End (xlUo)
+ ITEM Assertion OK : - = Range("K22").End (xlToLeft)
+ ITEM Assertion OK : - = Range("K22").End (xlRight)
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="x"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="<>"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="="
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter
+ ITEM Assertion OK : - ActiveSheet.Resize.Select
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion FAIL : - Application.GoTo Reference:="R[8]C[2]"
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Ungroup- please check visually
+ ITEM Assertion OK : - Range.Ungroup - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - ActiveSheet.UsedRange.Select
+ ITEM Assertion OK : - Range("A13").AddIndent
+ ITEM Assertion OK : - Range("A13").IndentLevel set
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Calculate
+ ITEM Assertion OK : Worksheet.Calculate
+ ITEM Assertion OK : - Application.Calculate
+ ITEM Assertion OK : Global.Calculate
+ ITEM Assertion OK : Calculation set
+ ITEM FAIL (RangeTest3)
+ TEST Not succesfully completed : RangeTest3
+END TestCalc
+Test run finished : 10/03/2008 15:15:21
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestIntersection.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestIntersection.log
new file mode 100644
index 000000000000..ea686a830cde
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestIntersection.log
@@ -0,0 +1,26 @@
+Test run started : 13/01/2009 14:31:43
+----------------------------------------------------------------
+TestIntersection
+ TEST START : TestIntersection
+ ITEM Assertion OK : test1 Application.Intersect( Range('A2:D10'), Range('C4:E6'))
+ ITEM Assertion OK : test2 Application.Intersect( Range('A2:D10'), Range('A4:G10'))
+ ITEM Assertion OK : test3 Application.Intersect( Range('A2:c8,d2:f8,g2:i8'), Range('A4:G10'))
+ ITEM Assertion OK : test4 Application.Intersect( Range('A4:G10'), Range('A2:c8,d2:f8,g2:i8'))
+ ITEM Assertion OK : test5 Application.Intersect( Range('A2:c8,d2:f8,g2:i8'), Range('g4:i10,A4:G10'))
+ ITEM Assertion OK : test6 Application.Intersect( Range('g4:i10,A4:G10'), Range('A2:c8,d2:f8,g2:i8'))
+ ITEM Assertion OK : test7 Application.Intersect( Range('a2:d10,b5:e10'), Range('a5:i10'))
+ ITEM Assertion OK : test8 Application.Intersect( Range('a2:c8,d2:f8'), Range('b6:e9,a6:f9'))
+ ITEM Assertion OK : test9 Application.Intersect( Range('a2:c8,e2:f8'), Range('b6:e9,a6:f9'))
+ ITEM Assertion OK : test10 Application.Intersect( Range('a1:a3,c1:c3'), Range('a2:c3'))
+ ITEM Assertion OK : test11 Application.Intersect( Range('a1:a3,b1:b3'), Range('a2:c3'))
+ ITEM Assertion OK : test12 Application.Intersect( Range('a2:d5,b3:f7,c1:g4'), Range('b2:e6'))
+ ITEM Assertion OK : test13 Range(" a2:d10,b5:e10,g13:j32 "), Range(" a5:i10,b6:e9 "), Range("b2:r5,f10:h19")
+Test Results
+============
+
+Tests passed: 13
+Tests failed: 0
+
+END 'TestIntersection
+ TEST OK : TestIntersection
+Test run finished : 13/01/2009 14:31:43
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestUnion.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestUnion.log
new file mode 100644
index 000000000000..da3cb35dedb3
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/TestUnion.log
@@ -0,0 +1,17 @@
+Test run started : 13/01/2009 14:32:16
+----------------------------------------------------------------
+TestUnion
+ TEST START : TestUnion
+ ITEM Assertion OK : test1Application.Range('A2:D10'), Range('C4:E6')
+ ITEM Assertion OK : test2Application.Range('A2:D5,a3:d4'), Range('A4:G10')
+ ITEM Assertion OK : test3Application.Range('A4:G10,A1:B6'), Range('A2:D5,A3:D4')
+ ITEM Assertion OK : test4Application.Range('A5:D10'), Range('B5:E10')
+Test Results
+============
+
+Tests passed: 4
+Tests failed: 0
+
+END 'TestUnion
+ TEST OK : TestUnion
+Test run finished : 13/01/2009 14:32:16
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Window.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Window.log
new file mode 100644
index 000000000000..ec9a6656113e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/Window.log
@@ -0,0 +1,46 @@
+Test run started : 05/29/2008 02:55:00 PM
+----------------------------------------------------------------
+ TEST START : Window-Issue
+ ITEM Assertion OK : Window.Left is: 0 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Top is: 21 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Width is: 1280 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.Height is: 752 (Test only applies to maximized Window)
+ ITEM Assertion OK : Window.ScrollColumn is: 100
+ ITEM Assertion OK : Window.ScrollColumn is: 1
+ ITEM Assertion OK : Window.ScrollRow is: 100
+ ITEM Assertion OK : Window.ScrollRow is: 1
+ ITEM Assertion OK : Window.LargeScroll(Down): ScrollRow is: 94 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.LargeScroll(Up): ScrollRow is: 1
+ ITEM Assertion OK : Window.LargeScroll(ToRight): ScrollColumn is: 58 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.LargeScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window.SmallScroll(ToRight): ScrollColumn is: 4 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Window.SmallScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window.DisplayWorkBookTabs is: False
+ ITEM Assertion OK : Window.DisplayWorkBookTabs is: True
+ ITEM Assertion OK : Window.DisplayVerticalScrollBar is: True
+ ITEM Assertion OK : Window.DisplayVerticalScrollBar is: False
+ ITEM Assertion OK : Window.DisplayHorizontalScrollBar is: False
+ ITEM Assertion OK : Window.DisplayHorizontalScrollBar is: True
+ ITEM Assertion OK : Window.DisplayHeadings is: False
+ ITEM Assertion OK : Window.DisplayHeadings is: True
+ ITEM Assertion OK : Window.DisplayOutline is: False
+ ITEM Assertion OK : Window.DisplayOutline is: True
+ ITEM Assertion OK : Window.Visible is: False
+ ITEM Assertion OK : Window.Visible is: True
+ ITEM Assertion OK : Window.Caption is: MyCaption
+ ITEM Assertion OK : Pane.ScrollColumn is: 100
+ ITEM Assertion OK : Pane.ScrollColumn is: 1
+ ITEM Assertion OK : Pane.ScrollRow is: 100
+ ITEM Assertion OK : Pane.ScrollRow is: 1
+ ITEM Assertion OK : Pane.LargeScroll(Down): ScrollRow is: 94 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.LargeScroll(Up): ScrollRow is: 1
+ ITEM Assertion OK : Pane.LargeScroll(ToRight): ScrollColumn is: 58 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.LargeScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Pane.SmallScroll(ToRight): ScrollColumn is: 4 (Test may only apply to maximized Window)
+ ITEM Assertion OK : Pane.SmallScroll(ToLeft): ScrollColumn is: 1
+ ITEM Assertion OK : Window Selection: $A$2:$D$5
+ ITEM Assertion OK : ActiveSheet name of Window: Sheet1
+ ITEM Assertion OK : Window ActiveCell: $A$1
+END 'Window-Issue' Symbol
+ TEST OK : Window-Issue
+Test run finished : 05/29/2008 02:55:01 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/bytearraystring.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/bytearraystring.log
new file mode 100644
index 000000000000..bd243283d8f1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/bytearraystring.log
@@ -0,0 +1,8 @@
+Test run started : 05/29/2008 02:25:58 PM
+BEGIN Bytearray To String
+ TEST START : Test the conversion between bytearray and string
+ ITEM Assertion OK : The number of byte is:6
+ ITEM Assertion OK : the return string is: abc
+ TEST OK : Test the conversion between bytearray and string
+END Bytearray To String
+Test run finished : 05/29/2008 02:25:58 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/dateserial.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/dateserial.log
new file mode 100644
index 000000000000..4dd5f53160f2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/dateserial.log
@@ -0,0 +1,9 @@
+Test run started : 01/24/2008 01:24:50 PM
+BEGIN DateSerial
+ TEST START : Test DateSerial function
+ ITEM Assertion OK : the return date is: 06/15/1999
+ ITEM Assertion OK : the return date is: 06/15/1999
+ ITEM Assertion OK : the return date is: 06/15/1999
+ TEST OK : Test DateSerial function
+END DateSerial
+Test run finished : 01/24/2008 01:24:50 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/datevalue.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/datevalue.log
new file mode 100644
index 000000000000..830d5e7b6c3e
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/datevalue.log
@@ -0,0 +1,8 @@
+Test run started : 01/24/2008 01:24:41 PM
+BEGIN DateValue
+ TEST START : Test DateValue function
+ ITEM Assertion OK : the return date is: 02/12/1969
+ ITEM Assertion OK : the return date is: 01/21/2008
+ TEST OK : Test DateValue function
+END DateValue
+Test run finished : 01/24/2008 01:24:41 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log
new file mode 100644
index 000000000000..96725bf7daa8
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/format.log
@@ -0,0 +1,36 @@
+Test run started : 2008ï¼09ï¼18 11:35:34
+BEGIN Format
+ TEST START : Test Predefined_Number_Format_Sample function
+ ITEM Assertion OK : General Number: 562486.2356
+ ITEM Assertion OK : Fixed: 0.20
+ ITEM Assertion OK : Standard: 562,486.24
+ ITEM Assertion OK : Percent: 75.21%
+ ITEM Assertion OK : Scientific: 5.62E+05
+ ITEM Assertion OK : Scientific: -3.46E+03
+ ITEM Assertion OK : Yes/No: No
+ ITEM Assertion OK : Yes/No: Yes
+ ITEM Assertion OK : True/False: False
+ ITEM Assertion OK : True/False: True
+ ITEM Assertion OK : On/Off: Off
+ ITEM Assertion OK : On/Off: On
+ TEST OK : Test Predefined_Number_Format_Sample function
+ TEST START : Test Custom_Number_Format_Sample function
+ ITEM Assertion OK : 00.0000: 23.6750
+ ITEM Assertion OK : 00.00: 23.68
+ ITEM Assertion OK : 00000: 02658
+ ITEM Assertion OK : 00.00: 2658.00
+ ITEM Assertion OK : ##.####: 23.675
+ ITEM Assertion OK : ##.##: 23.68
+ ITEM Assertion OK : #,###.##: 12,345.25
+ ITEM Assertion OK : ##.00%: 25.00%
+ ITEM Assertion OK : #,###: 1,000,000
+ ITEM Assertion OK : ######E-###: 109838E-5
+ ITEM Assertion OK : $#,###.##: $2,345.25
+ ITEM Assertion OK : ##.###\%: .25%
+ TEST OK : Test Custom_Number_Format_Sample function
+ TEST START : Test Custom_Text_Format_Sample function
+ ITEM Assertion OK : <: vba
+ ITEM Assertion OK : >: VBA
+ TEST OK : Test Custom_Text_Format_Sample function
+END Format
+Test run finished : 2008ï¼09ï¼18 11:35:34
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/pagesetup.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/pagesetup.log
new file mode 100644
index 000000000000..f04585c3f9e1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/pagesetup.log
@@ -0,0 +1,77 @@
+Test run started : 07/21/2008 02:00:06 PM
+BEGIN PageSetup
+ TEST START : Sheet_PrintArea
+ ITEM Assertion OK : PrintArea has changed as expected
+ TEST OK : Sheet_PrintArea
+ TEST START : Test margins (no headers)
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.RightMargin set/get
+ ITEM Assertion OK : PageSetup.TopMargin set/get
+ ITEM Assertion OK : PageSetup.BottomMargin set/get
+Verify that page margins on sheet 1 are all 0.5inch
+ TEST OK : Test margins (no headers)
+ TEST START : Test margins (headers)
+ ITEM Assertion OK : PageSetup.HeaderMargin set/get
+ ITEM Assertion OK : PageSetup.FooterMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+Verify that top/bottom/header/footer page margins on sheet 2 are all 0.5inch
+ TEST OK : Test margins (headers)
+ TEST START : Test header/footer text
+ ITEM Assertion OK : PageSetup.LeftHeader set
+ ITEM Assertion OK : PageSetup.LeftHeader set/get
+ ITEM Assertion OK : PageSetup.CenterHeader set
+ ITEM Assertion OK : PageSetup.CenterHeader set/get
+ ITEM Assertion OK : PageSetup.RightHeader set
+ ITEM Assertion OK : PageSetup.RightHeader set/get
+ ITEM Assertion OK : PageSetup.LeftFooter set
+ ITEM Assertion OK : PageSetup.LeftFooter set/get
+ ITEM Assertion OK : PageSetup.CenterFooter set
+ ITEM Assertion OK : PageSetup.CenterFooter set/get
+ ITEM Assertion OK : PageSetup.RightFooter set
+ ITEM Assertion OK : PageSetup.RightFooter set/get
+Verify that headers on sheet 2 are Ready,to,go
+Verify that footers on sheet 2 are This,now,Works
+ TEST OK : Test header/footer text
+ TEST START : Test zoom
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Zoom set/get
+Verify that sheet 1 zoom is 10%
+ TEST OK : Test zoom
+ TEST START : Test orientation
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Orientation set/get
+Verify that sheet 1 orientation is now landscape
+ TEST OK : Test orientation
+ TEST START : Test order
+ ITEM Assertion OK : PageSetup.Order get
+ ITEM Assertion OK : PageSetup.Order set/get
+Verify that order on sheet 1 is now over, then down.
+ TEST OK : Test order
+ TEST START : Test first page number
+ ITEM Assertion OK : PageSetup.FirstPageNumber get
+ ITEM Assertion OK : PageSetup.FirstPageNumber set/get
+Verify that first page number on sheet 1 is now 2.
+ TEST OK : Test first page number
+ TEST START : Test center vertically
+ ITEM Assertion OK : PageSetup.CenterVertically get
+ ITEM Assertion OK : PageSetup.CenterVertically set/get
+Verify that CenterVertically on sheet 1 is now true.
+ TEST OK : Test center vertically
+ TEST START : Test center horizontally
+ ITEM Assertion OK : PageSetup.CenterHorizontally get
+ ITEM Assertion OK : PageSetup.CenterHorizontally set/get
+Verify that CenterHorizontally on sheet 1 is now true.
+ TEST OK : Test center horizontally
+ TEST START : Test FitToPagesTall
+ ITEM Assertion OK : PageSetup.FitToPagesTall set/get
+ TEST OK : Test FitToPagesTall
+ TEST START : Test FitToPagesWide
+ ITEM Assertion OK : PageSetup.FitToPagesWide set/get
+ TEST OK : Test FitToPagesWide
+ TEST START : Test PrintHeadings
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ TEST OK : Test PrintHeadings
+END PageSetup
+Test run finished : 07/21/2008 02:00:07 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/partition.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/partition.log
new file mode 100644
index 000000000000..7b4f2a01bead
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/partition.log
@@ -0,0 +1,11 @@
+Test run started : 12/10/2007 11:26:43 AM
+BEGIN Partition
+ TEST START : Test Partition function
+ ITEM Assertion OK : the number 20 occurs in the range:20:24
+ ITEM Assertion OK : the number 20 occurs in the range: 20: 20
+ ITEM Assertion OK : the number 120 occurs in the range:100:
+ ITEM Assertion OK : the number -5 occurs in the range: : -1
+ ITEM Assertion OK : the number 2 occurs in the range: 2: 3
+ TEST OK : Test Partition function
+END Partition
+Test run finished : 12/10/2007 11:26:43 AM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/range-4.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/range-4.log
new file mode 100644
index 000000000000..fb37b6ff201b
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/range-4.log
@@ -0,0 +1,16 @@
+Test run started : 2008ï¼06ï¼19 17:14:57
+----------------------------------------------------------------
+ShowDetail-Issue
+ TEST START : ShowDetail-Issue
+ ITEM Assertion OK : Range.ShowDetail is True
+ ITEM Assertion OK : Range.ShowDetail is False
+END 'ShowDetail-Issue' Symbol
+ TEST OK : ShowDetail-Issue
+----------------------------------------------------------------
+RangeMerged-Issue
+ TEST START : RangeMerged-Issue
+ ITEM Assertion OK : Range.RangeMerged is $F$2:$H$5
+ ITEM Assertion OK : The first address of Range.RangeMerged is $F$2
+END 'RangeMerged-Issue' Symbol
+ TEST OK : RangeMerged-Issue
+Test run finished : 2008ï¼06ï¼19 17:14:57
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log
new file mode 100644
index 000000000000..8f600faaa6b1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/replace.log
@@ -0,0 +1,14 @@
+Test run started : 09/05/2008 10:21:46 AM
+BEGIN Replace
+ TEST START : Test Replace function
+ ITEM Assertion OK : common string:aefefdBc
+ ITEM Assertion OK : expression string:aefefdef
+ ITEM Assertion OK : binanary compare:aefefdBc
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : start = 3:cefdBc
+ ITEM Assertion OK : count = 2: aefefdBc
+ ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc
+ TEST OK : Test Replace function
+END Replace
+Test run finished : 09/05/2008 10:21:47 AM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/stringplusdouble.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/stringplusdouble.log
new file mode 100644
index 000000000000..6e8b8d994bd1
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/stringplusdouble.log
@@ -0,0 +1,62 @@
+Test run started : 05/29/2008 02:51:22 PM
+BEGIN String Plus Double
+ TEST START : double = string + double
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: 0
+The next compute raises error: s = null, d = 20, r = s + d
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 100
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 30
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = null, r = s & d
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s & d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: -1
+ TEST OK : double = string + double
+ TEST START : string = string + double
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: 0
+The next compute raises error: s = null, d = 20, r = s + d
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 100
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 30
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: abc0
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: abc20
+ TEST OK : string = string + double
+ TEST START : double = string + string
+The next compute raises error: s = null, d = null, r = s + d
+ ITEM Assertion OK : s = null, d = null, r = s + d .The result is: -1
+The next compute raises error: s = null, d = null, r = s & d
+ ITEM Assertion OK : s = null, d = null, r = s & d .The result is: -1
+ ITEM Assertion OK : s = null, d = 20, r = s + d .The result is: 20
+ ITEM Assertion OK : s = null, d = 20, r = s & d .The result is: 20
+ ITEM Assertion OK : s = '10', d = null, r = s + d .The result is: 10
+ ITEM Assertion OK : s = '10', d = null, r = s & d .The result is: 10
+ ITEM Assertion OK : s = '10', d = 20, r = s + d .The result is: 1020
+ ITEM Assertion OK : s = '10', d = 20, r = s & d .The result is: 1020
+The next compute raises error: s = 'abc', d = null, r = s + d
+ ITEM Assertion OK : s = 'abc', d = null, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = null, r = s & d
+ ITEM Assertion OK : s = 'abc', d = null, r = s & d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s + d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s + d .The result is: -1
+The next compute raises error: s = 'abc', d = 20, r = s & d
+ ITEM Assertion OK : s = 'abc', d = 20, r = s & d .The result is: -1
+ TEST OK : double = string + string
+END String Plus Double
+Test run finished : 05/29/2008 02:51:22 PM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log
new file mode 100644
index 000000000000..8e26d0580621
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/unix/window2.log
@@ -0,0 +1,41 @@
+Test run started : 2008ï¼09ï¼22 11:18:57
+BEGIN Window2
+ TEST START : Test Window.SplitRow
+ ITEM Assertion OK : Test SplitColumn: 2 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitRow: 2 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitVertical: 242.465788476212
+ ITEM Assertion OK : Test SplitHorizontal: 242.465788476212
+ ITEM Assertion OK : Test SplitRow: 4 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitColumn: 3 (Test only applies to maximized Window and at least has 800*600 solotion)
+ ITEM Assertion OK : Test SplitColumn: 0
+ ITEM Assertion OK : Test SplitRow: 0
+ TEST OK : Test Window.SplitRow
+ TEST START : Test Window.DisplayGridlines
+ ITEM Assertion OK : Test gridlines are on
+ ITEM Assertion OK : Test gridlines are off
+ TEST OK : Test Window.DisplayGridlines
+ TEST START : Test Window.DisplayHeadings
+ ITEM Assertion OK : Test Headings are on
+ ITEM Assertion OK : Test Headings are off
+ TEST OK : Test Window.DisplayHeadings
+ TEST START : Test Window.Visibility
+ ITEM Assertion OK : Window is visible
+ ITEM Assertion OK : Window is not visible
+ TEST OK : Test Window.Visibility
+ TEST START : Test Window.FreezePanes
+ ITEM Assertion OK : Test no panes frozen
+ ITEM Assertion OK : Test panes frozen at center
+ ITEM Assertion OK : Test panes frozen at split
+ TEST OK : Test Window.FreezePanes
+ TEST START : Test Window.View
+ TEST OK : Test Window.View
+ TEST START : Test Window.Zoom
+ ITEM Assertion OK : Test zoom=100%
+ ITEM Assertion OK : Test zoom=150%
+ TEST OK : Test Window.Zoom
+ TEST START : Test Windows.Count
+ ITEM Assertion OK : Windows Count: 1
+ ITEM Assertion OK : Application.Windows Count: 1
+ TEST OK : Test Windows.Count
+END Window2
+Test run finished : 2008ï¼09ï¼22 11:18:58
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/AutoFilter.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/AutoFilter.log
new file mode 100644
index 000000000000..b8d0b85a8ff9
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/AutoFilter.log
@@ -0,0 +1,20 @@
+Test run started : 16/10/2007 17:42:01
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 'starts with' string criteria
+ ITEM Assertion OK : test2 'not equal to' string criteria
+ ITEM Assertion OK : test3 'ends with' string criteria
+ ITEM Assertion OK : test4 field 'all'
+ ITEM Assertion OK : test5 numeric '<15'
+ ITEM Assertion OK : test6 numeric '>=15'
+ ITEM Assertion OK : test7 numeric '<=12'
+Test Results
+============
+
+Tests passed: 7
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 16/10/2007 17:42:02
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/MiscRangeTests.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/MiscRangeTests.log
new file mode 100644
index 000000000000..d190abb5f645
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/MiscRangeTests.log
@@ -0,0 +1,45 @@
+Test run started : 17/07/2007 15:08:56
+----------------------------------------------------------------
+MiscRangeTests
+ TEST START : MiscRangeTests
+ ITEM Assertion OK : test 1
+ ITEM Assertion OK : test 2
+ ITEM Assertion OK : test 3
+ ITEM Assertion OK : test 4
+ ITEM Assertion OK : test 5
+ ITEM Assertion OK : test 6
+ ITEM Assertion OK : test 7
+ ITEM Assertion OK : test 8
+ ITEM Assertion OK : test 9
+ ITEM Assertion OK : test 10
+ ITEM Assertion OK : test 11
+ ITEM Assertion OK : test 12
+ ITEM Assertion OK : test 13
+ ITEM Assertion OK : test 14
+ ITEM Assertion OK : test 15
+ ITEM Assertion OK : test 16
+ ITEM Assertion OK : test 17
+ ITEM Assertion OK : test 18
+ ITEM Assertion OK : test 19
+ ITEM Assertion OK : test 20
+ ITEM Assertion OK : test 21
+ ITEM Assertion OK : test 22
+ ITEM Assertion OK : test 23
+ ITEM Assertion OK : test 24
+ ITEM Assertion OK : test 25
+ ITEM Assertion OK : test 26
+ ITEM Assertion OK : test 27
+ ITEM Assertion OK : test 28
+ ITEM Assertion OK : test 29
+ ITEM Assertion OK : test 30
+ ITEM Assertion OK : test 31
+No. tests: 31
+Summary
+=======
+Run: 31
+Passed: 31
+Failed: 0
+
+END 'MiscRangeTests
+ TEST OK : MiscRangeTests
+Test run finished : 17/07/2007 15:08:59
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-2.log
new file mode 100644
index 000000000000..b80d996e3d3f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-2.log
@@ -0,0 +1,68 @@
+Test run started : 10/07/2007 01:55:47
+----------------------------------------------------------------
+ClearFormtsIssue
+ TEST START : ClearFormtsIssue
+ ITEM Assertion OK : Range.Font.Bold is: True
+ ITEM Assertion OK : Range.Font.Bold is: False
+END 'ClearFormtsIssue' Symbol
+ TEST OK : ClearFormtsIssue
+----------------------------------------------------------------
+VerticalAlignment-Issue
+ TEST START : VerticalAlignment-Issue
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : - Range.VerticalAlignment (get)
+ ITEM Assertion OK : - Range.VerticalAlignment (set)
+ ITEM Assertion OK : Range.VeritcalAlignment is Null
+END 'VerticalAlignment-Issue' Symbol
+ TEST OK : VerticalAlignment-Issue
+----------------------------------------------------------------
+HorizontalAlignment-Issue
+ TEST START : HorizontalAlignment-Issue
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : - Range.HorizontalAlignment (get)
+ ITEM Assertion OK : - Range.HorizontalAlignment (set)
+ ITEM Assertion OK : Range.HorizontalAlignment is Null
+END 'HorizontalAlignment-Issue' Symbol
+ TEST OK : HorizontalAlignment-Issue
+----------------------------------------------------------------
+WrapText-Issue
+ TEST START : WrapText-Issue
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : - Range.WrapText (get)
+ ITEM Assertion OK : Range.WrapText is Null
+END 'WrapText-Issue' Symbol
+ TEST OK : WrapText-Issue
+----------------------------------------------------------------
+FontBorderIssues
+ TEST START : FontBorderIssues
+ ITEM Assertion OK : - = Borders.Color (getColor)
+ ITEM Assertion OK : - = Font.Color (getColor)
+END 'FontBorderIssues' Symbol
+ TEST OK : FontBorderIssues
+----------------------------------------------------------------
+RangeSizeIssues
+ TEST START : RangeSizeIssues
+ ITEM Assertion OK : Range.Left is: 100.5291
+ ITEM Assertion OK : Range.Top is: 95.39775
+ ITEM Assertion OK : Range.Width is: 191.25
+ ITEM Assertion OK : Range.Height is: 271.5
+END 'RangeSizeIssues' Symbol
+ TEST OK : RangeSizeIssues
+----------------------------------------------------------------
+ApplicationIssues
+ TEST START : ApplicationIssues
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range.Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Application.ActiveSheet.Name: Sheet1
+END 'ApplicationIssues' Symbol
+ TEST OK : ApplicationIssues
+Test run finished : 10/07/2007 01:55:48
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-3.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-3.log
new file mode 100644
index 000000000000..365d126a7e2d
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges-3.log
@@ -0,0 +1,8 @@
+Test run started : 10/07/2007 01:55:51
+----------------------------------------------------------------
+MyGoalseek-Issue
+ TEST START : MyGoalseek-Issue
+ ITEM Assertion OK : Variable Range value: 15
+END 'MyGoalseek-Issue' Symbol
+ TEST OK : MyGoalseek-Issue
+Test run finished : 10/07/2007 01:55:51
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges.log
new file mode 100644
index 000000000000..fe77d7a9d467
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Ranges.log
@@ -0,0 +1,280 @@
+Test run started : 10/07/2007 01:55:56
+----------------------------------------------------------------
+ApplicationMethods
+ TEST START : ApplicationMethods
+ ITEM Assertion OK : Name of Workbook is: Ranges.xls
+ ITEM Assertion OK : Address of Application.Columns is: $A:$A
+ ITEM Assertion OK : Address of Application.Rows is: $1:$1
+ ITEM Assertion OK : Address of Application.Range is: $1:$1,$5:$7
+ ITEM Assertion OK : Please check manually: DefaultFilePath is: C:\Documents and Settings\vituosity\My Documents
+ ITEM Assertion OK : Please check manually: Library Path is: C:\Documents and Settings\vituosity\Application Data\OpenOffice.org2\user\basic
+ ITEM Assertion OK : Please check manually: Template Path is: C:\Documents and Settings\vituosity\Application Data\OpenOffice.org2\user\template
+ ITEM Assertion OK : FileSeparator is \
+ ITEM Assertion OK : Name of ActiveWorkbook is: Ranges.xls
+END 'ApplicationMethods' Symbol
+ TEST OK : ApplicationMethods
+----------------------------------------------------------------
+Insert-Issue
+ TEST START : Insert-Issue
+ ITEM Assertion OK : Insert with xlShiftToRight: 10
+END 'Insert-Issue' Symbol
+ TEST OK : Insert-Issue
+----------------------------------------------------------------
+MergeCells-Issue
+ TEST START : MergeCells-Issue
+ ITEM Assertion OK : Range.MergeCells is True
+ ITEM Assertion FAIL : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 13
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion FAIL : MergeCells of Second Area is null : False
+ ITEM Assertion FAIL : MergeCells of Ranges is Null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+ ITEM Assertion OK : Range.MergeCells is False
+ ITEM Assertion OK : MergeCells is null: False
+ ITEM Assertion OK : RowCount after Merge: 7
+END 'MergeCells-Issue' Symbol
+ TEST OK : MergeCells-Issue
+----------------------------------------------------------------
+Areas-Issue
+ TEST START : Areas-Issue
+ ITEM Assertion OK : Range Areas Count is2
+ ITEM Assertion OK : First Range Address is: $E$8:$G$13
+ ITEM Assertion OK : First Row is: 8
+ ITEM Assertion OK : First Column is: 5
+ ITEM Assertion OK : EntireRow Address is: $8:$13,$13:$19
+ ITEM Assertion OK : EntireColumn Address is: $E:$G,$G:$K
+ ITEM Assertion OK : Range Count:53
+END 'Areas-Issue' Symbol
+ TEST OK : Areas-Issue
+----------------------------------------------------------------
+Fill-Methods-Issue
+ TEST START : Fill-Methods-Issue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyRightFillValue
+ ITEM Assertion OK : Range Value after FillDown: MyBottomFillValue
+END 'Fill-Methods-Issue' Symbol
+ TEST OK : Fill-Methods-Issue
+----------------------------------------------------------------
+Range/Item-Method-Issue
+ TEST START : Range/Item-Method-Issue
+ ITEM Assertion OK : Range of multiple columns is: $A:$A,$C:$C
+ ITEM Assertion OK : Range of multiple rows is: $1:$1,$5:$7
+ ITEM Assertion OK : Range of several columns is: $C:$E,$D:$D
+ ITEM Assertion OK : Range of several rows is: $5:$8,$6:$10
+ ITEM Assertion OK : Range of several single cells is: $C$5,$E$8
+ ITEM Assertion OK : Range of several named ranges is: $L$1:$M$6,$E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range of a single Item Cell is: $E$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$21
+ ITEM Assertion OK : Range of a single Item Cell is: $F$10
+END 'Range/Item-Method-Issue' Symbol
+ TEST OK : Range/Item-Method-Issue
+----------------------------------------------------------------
+R1C1-Formulas-Issue
+ TEST START : R1C1-Formulas-Issue
+ ITEM Assertion OK : R1C1 Range.Formula is: =IF(OR(R[-2]C[1]=0,RC[2]="YES"),"")
+ ITEM Assertion FAIL : Range.Formula is: =IF(OR(J8=0,RC[2]="YES"),"")
+END 'R1C1-Formulas-Issue' Symbol
+ TEST OK : R1C1-Formulas-Issue
+----------------------------------------------------------------
+Verify_Delete
+ TEST START : Verify_Delete
+ ITEM Assertion OK : Ranges are intersecting: $G$13
+ ITEM Assertion OK : Delete with Default: $AJ$4
+ ITEM Assertion OK : Delete with ShifttoLeft: $AJ$4
+ ITEM Assertion OK : Delete with ShiftUp: $M$22
+END 'Verify_Delete' Symbol
+ TEST OK : Verify_Delete
+----------------------------------------------------------------
+Value-Issue
+ TEST START : Value-Issue
+ ITEM Assertion OK : Value of Range is: 12.3
+ ITEM Assertion OK : Text of Range is: 12.3
+ ITEM Assertion OK : Range has Formula: False
+ ITEM Assertion OK : Cell has Formula: False
+ ITEM Assertion FAIL : Text of Range is null: False
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Cell has Formula: True
+ ITEM Assertion OK : Value of Cell is: 12
+ ITEM Assertion OK : Application.Calculation is : -4135
+ ITEM Assertion OK : Calculation is automated: True
+ ITEM Assertion OK : Range has Formula: True
+ ITEM Assertion OK : Value of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Text of Cell is: 16
+ ITEM Assertion OK : Range has Formula after 'ClearContents: False
+ ITEM Assertion OK : Text of Cell is:
+ ITEM Assertion OK : Text of Cell is:
+END 'Value-Issue' Symbol
+ TEST OK : Value-Issue
+----------------------------------------------------------------
+AutoFit issue
+ TEST START : AutoFit issue
+ ITEM Assertion OK : Columns.AutoFit: CurrentWidth is 467
+ ITEM Assertion FAIL : Rows.AutoFit: CurrentHeight is 78
+END 'AutoFit issue' Symbol
+ TEST OK : AutoFit issue
+----------------------------------------------------------------
+Selections
+ TEST START : Selections
+ ITEM Assertion OK : ActiveCell is : $E$8
+ ITEM Assertion OK : Active Cell is : $E$8
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+ ITEM Assertion OK : Number of Cells in Range: 52
+END 'Selections' Symbol
+ TEST OK : Selections
+----------------------------------------------------------------
+Offset-Resize
+ TEST START : Offset-Resize
+ ITEM Assertion OK : Offset is : $G$10:$I$15,$I$15:$M$21
+ ITEM Assertion OK : Offset is : $G$7:$I$12,$I$12:$M$18
+ ITEM Assertion OK : Resized Range is : $A$20:$D$23
+END 'Offset-Resize' Symbol
+ TEST OK : Offset-Resize
+----------------------------------------------------------------
+Ranges-Address
+ TEST START : Ranges-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13,$G$13:$K$19
+ ITEM Assertion OK : Range Address is: $E8:$G13,$G13:$K19
+ ITEM Assertion OK : Range Address is: E$8:G$13,G$13:K$19
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R8C5:R13C7,R13C7:R19C11
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5],R[11]C[5]:R[17]C[9]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13,$G$13:$K$19
+END 'Ranges-Address' Symbol
+ TEST OK : Ranges-Address
+----------------------------------------------------------------
+Range-Address
+ TEST START : Range-Address
+ ITEM Assertion OK : Range Address is: $E$8:$G$13
+ ITEM Assertion OK : Range Address is: $E8:$G13
+ ITEM Assertion OK : Range Address is: E$8:G$13
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion FAIL : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R8C5:R13C7
+ ITEM Assertion OK : Range Address is: R[6]C[3]:R[11]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$8:$G$13
+END 'Range-Address' Symbol
+ TEST OK : Range-Address
+----------------------------------------------------------------
+Column-Address
+ TEST START : Column-Address
+ ITEM Assertion OK : Range Address is: $F$8:$F$13
+ ITEM Assertion OK : Range Address is: $F8:$F13
+ ITEM Assertion OK : Range Address is: F$8:F$13
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion FAIL : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R8C6:R13C6
+ ITEM Assertion OK : Range Address is: R[6]C[4]:R[11]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$8:$F$13
+END 'Column-Address' Symbol
+ TEST OK : Column-Address
+----------------------------------------------------------------
+Row-Address
+ TEST START : Row-Address
+ ITEM Assertion OK : Range Address is: $E$9:$G$9
+ ITEM Assertion OK : Range Address is: $E9:$G9
+ ITEM Assertion OK : Range Address is: E$9:G$9
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion FAIL : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R9C5:R9C7
+ ITEM Assertion OK : Range Address is: R[7]C[3]:R[7]C[5]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$E$9:$G$9
+END 'Row-Address' Symbol
+ TEST OK : Row-Address
+----------------------------------------------------------------
+SingleCell-Address
+ TEST START : SingleCell-Address
+ ITEM Assertion OK : Range Address is: $F$9
+ ITEM Assertion OK : Range Address is: $F9
+ ITEM Assertion OK : Range Address is: F$9
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion FAIL : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R9C6
+ ITEM Assertion OK : Range Address is: R[7]C[4]
+ ITEM Assertion OK : RangeAddress is [Ranges.xls]Sheet1!$F$9
+END 'SingleCell-Address' Symbol
+ TEST OK : SingleCell-Address
+----------------------------------------------------------------
+Heights and Widths
+ TEST START : Heights and Widths
+ ITEM Assertion OK : Range RowHeight is 40
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 240
+ ITEM Assertion FAIL : Range Width is 675
+ ITEM Assertion OK : Range RowHeight is 50
+ ITEM Assertion OK : Range ColumnWidth is 50
+ ITEM Assertion OK : Range Height is 300
+ ITEM Assertion FAIL : Range Width is 675
+ ITEM Assertion FAIL : RowHeight is null: False
+ ITEM Assertion OK : ColumnWidth is null: True
+END 'Heights and Widths' Symbol
+ TEST OK : Heights and Widths
+----------------------------------------------------------------
+RangeRowColumn-Issue
+ TEST START : RangeRowColumn-Issue
+ ITEM Assertion OK : Row is: 8
+ ITEM Assertion OK : Column is: 5
+ ITEM Assertion OK : EntireRow.Columns.Count = 256
+ ITEM Assertion OK : EntireColumn.Rows.Count = 131072
+END 'RangeRowColumn-Issue' Symbol
+ TEST OK : RangeRowColumn-Issue
+----------------------------------------------------------------
+Replace-Issue
+ TEST START : Replace-Issue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: YourValue
+ ITEM Assertion OK : Value after Replace: ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New ReplaceValue
+ ITEM Assertion OK : Value after Replace: New Replace
+ ITEM Assertion OK : Value after Replace:
+END 'Replace-Issue' Symbol
+ TEST OK : Replace-Issue
+----------------------------------------------------------------
+Hidden-Issue
+ TEST START : Hidden-Issue
+ ITEM Assertion OK : - Range.Rows.Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Hidden (get)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Rows.Item(1).Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Hidden (get)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (set)
+ ITEM Assertion OK : - Range.Columns.Item(1).Hidden (get)
+END 'Hidden-Issue' Symbol
+ TEST OK : Hidden-Issue
+----------------------------------------------------------------
+End issue
+ TEST START : End issue
+ ITEM Assertion OK : - = $E$48
+ ITEM Assertion OK : - = $E$1
+ ITEM Assertion OK : - = $E$3
+ ITEM Assertion OK : - = $A$8
+ ITEM Assertion OK : - = $B$8
+ ITEM Assertion OK : - = $IV$8
+ ITEM Assertion OK : - = $Z$8
+END 'End issue' Symbol
+ TEST OK : End issue
+----------------------------------------------------------------
+Outline issue
+ TEST START : Outline issue
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+END 'Outline issue' Symbol
+ TEST OK : Outline issue
+----------------------------------------------------------------
+Validation
+ TEST START : Validation
+ ITEM Assertion OK : Validation Input Message is : Attention!
+ ITEM Assertion OK : Validation Input Message is : Enter an integer from five to ten
+ ITEM Assertion OK : Validation Error Title is : You must enter a number from five to ten
+ ITEM Assertion OK : Validation Error Message is : An Error occured
+ ITEM Assertion OK : Validation Error Title is : Microsoft Excel
+END 'Validation' Symbol
+ TEST OK : Validation
+Test run finished : 10/07/2007 01:56:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/Shapes.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Shapes.log
new file mode 100644
index 000000000000..fe62ab03d3f2
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/Shapes.log
@@ -0,0 +1,77 @@
+Test run started : 16/10/2007 17:46:03
+BEGIN Shapes_Collection_Behaviour
+ TEST START : Shapes_Collection_Behaviour
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape1'
+ ITEM Assertion OK : Name of indexed shape should be 'Sheet2Shape2'
+ TEST Success. : Shapes_Collection_Behaviour
+END Shapes_Collection_Behaviour
+BEGIN Shapes_Select_Item
+ TEST START : Shapes_Select_Item
+ ITEM Assertion OK : Correctly selected shape through Range
+ ITEM Assertion OK : Correctly selected shape through Item
+ ITEM Assertion OK : Needs to be visually checked. Is there a line on the document?
+ ITEM Assertion OK : Needs to be visually checked. Are All Shapes Selected?
+ TEST Success. : Shapes_Select_Item
+END Shapes_Select_Item
+BEGIN Shapes_Fill
+ TEST START : Shapes_Fill
+ ITEM Assertion OK : correctly set visibility of shape fill
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set backcolor of shape fill
+ ITEM Assertion OK : the success of the TwoColorGradient method needs to be verified visually!
+ ITEM Assertion OK : correctly set forecolor of shape fill
+ ITEM Assertion FAIL : correctly set forecolor of shape fill
+ TEST Success. : Shapes_Fill
+END Shapes_Fill
+BEGIN Shapes_Line
+ TEST START : Shapes_Line
+ ITEM Assertion FAIL : correctly set weight of shape line
+ ITEM Assertion OK : correctly set visibility of shape line
+ ITEM Assertion OK : correctly set transparency of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set dash style of shape line
+ ITEM Assertion OK : correctly set forecolor of shape line
+ ITEM Assertion FAIL : correctly set backcolor of shape line
+ TEST Success. : Shapes_Line
+END Shapes_Line
+BEGIN Shapes_TextFrame
+ TEST START : Shapes_TextFrame
+ ITEM Assertion OK : correctly set Autosize of Shape TextFrame
+ TEST Success. : Shapes_TextFrame
+END Shapes_TextFrame
+BEGIN Shapes_SimpleGeometry
+ TEST START : Shapes_SimpleGeometery
+ ITEM Assertion OK : shape height should be 49.4519655148368 and got 49.4078709034412
+ ITEM Assertion OK : shape width should be 101.467710269751 and got 101.423615658355
+ ITEM Assertion OK : shape left should be 68.5574761223637 and got 68.5417279658754
+ ITEM Assertion OK : shape top should be 44.1511784471699 and got 44.1354302906816
+ ITEM Assertion OK : shape rotation should be 0 and got 0
+ ITEM Assertion OK : shape rotation should be 25 and got 25
+ ITEM Assertion OK : shape incrementrotation should be 50 and got 50
+ ITEM Assertion OK : shape incrementleft should be 69.7480272284707 and got 69.7322790719824
+ ITEM Assertion OK : shape incrementtop should be 93.8141674447769 and got 93.7984192882885
+ TEST Success. : Shapes_SimpleGeometery
+END Shapes_SimpleGeometry
+BEGIN Shapes_Range
+ TEST START : Shapes_Range
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(1) to return Sheet2Shape1 got Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to contain 1 element, it contains 1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Sheet2Shape3) to return Sheet2Shape3 got Sheet2Shape3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to contain 2 elements, it contains 2
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array(3, 1) to return concated element/shape names Sheet2Shape3Sheet2Shape1 and got Sheet2Shape3Sheet2Shape1
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to contain 3 elements, it contains 3
+ ITEM Assertion OK : expected Sheets(2).Shapes.Range(Array('Sheet2Shape3', 1, 'Sheet2Shape2')) to return concated element/shape names Sheet2Shape3Sheet2Shape1Sheet2Shape2 and got Sheet2Shape3Sheet2Shape1Sheet2Shape2
+ TEST Success. : Shapes_Range
+END Shapes_Range
+BEGIN Shapes_ShapeRange
+ TEST START : Shapes_ShapeRange
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp1.left should be 89.7322790719824 and got 89.7165297816359
+ ITEM Assertion OK : ShapeRange.IncrementLeft shp2.left should be 240.02518299054 and got 240.009433700193
+ ITEM Assertion OK : ShapeRange.IncrementTop shp1.Top should be 113.798419288289 and got 113.782669997942
+ ITEM Assertion OK : ShapeRange.IncrementTop shp2.Top should be 67.4519655148368 and got 67.4362162244903
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp1.Rotation should be 70 and got 70
+ ITEM Assertion OK : ShapeRange.IncrementRotation shp2.Rotation should be 20 and got 20
+END Shapes_ShapeRange
+Test run finished : 16/10/2007 17:46:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestAddress.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestAddress.log
new file mode 100644
index 000000000000..cc51e378f06a
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestAddress.log
@@ -0,0 +1,62 @@
+Test run started : 17/07/2007 15:26:54
+----------------------------------------------------------------
+TestAddress
+ TEST START : TestAddress
+ ITEM Assertion OK : test1 Range('e3:f3') A1 style addressing
+ ITEM Assertion OK : test2 Range('e3:f3') R1C1 style addressing
+ ITEM Assertion OK : test3 Range ('e:f') A1 style addressing
+ ITEM Assertion OK : test4 Range ('e:f') R1C1 style addressing
+ ITEM Assertion OK : test5 Columns A1 style addressing
+ ITEM Assertion OK : test6 Columns R1C1 style addressing
+ ITEM Assertion OK : test7 Columns(3) A1 style addressing
+ ITEM Assertion OK : test8 Columns(3) R1C1 style addressing
+ ITEM Assertion OK : test9 Columns('e') A1 style addressing
+ ITEM Assertion OK : test10 Columns('e') R1C1 style addressing
+ ITEM Assertion OK : test11 Columns('b:d') A1 style addressing
+ ITEM Assertion OK : test12 Columns('b:d') R1C1 style addressing
+ ITEM Assertion OK : test13 Range('c1:g10').Columns A1 style addressing
+ ITEM Assertion OK : test14 Range('c1:g10').Columns R1C1 style addressing
+ ITEM Assertion OK : test15 Range('c1:g10').Columns(1) A1 style addressing
+ ITEM Assertion OK : test16 Range('c1:g10').Columns(1) R1C1 style addressing
+ ITEM Assertion OK : test17 Range('c1:g10').Columns('a') A1 style addressing
+ ITEM Assertion OK : test18 Range('c1:g10').Columns('a') R1C1 style addressing
+ ITEM Assertion OK : test19 Range('c1:g10').Columns('c') A1 style addressing
+ ITEM Assertion OK : test20 Range('c1:g10').Columns('c') R1C1 style addressing
+ ITEM Assertion OK : test21 Range('c1:g10').Columns('x:z') A1 style addressing
+ ITEM Assertion OK : test22 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test23 Range('c1:g10').Columns(30) A1 style addressing
+ ITEM Assertion OK : test24 Range('c1:g10').Columns(30) R1C1 style addressing
+ ITEM Assertion OK : test25 Worksheets('Sheet2').Cells(1, 1) A1 style addressing
+ ITEM Assertion OK : test26 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, RowAddressAbsolute is false
+ ITEM Assertion OK : test27 Worksheets('Sheet2').Cells(1, 1) A1 style addressing, ColAddressAbsolute is false
+ ITEM Assertion OK : test28 Worksheets('Sheet2').Cells(1, 1) R1C1 style addressing
+ ITEM Assertion OK : test29 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test30 Worksheets('Sheet2').Range('A1').EntireColumn A1 style addressing
+ ITEM Assertion OK : test31 Worksheets('Sheet2').Range('A1:E5').EntireRow A1 style addressing
+ ITEM Assertion OK : test32 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test33 Worksheets('Sheet2').Range('IV65536').EntireRow A1 style addressing
+ ITEM Assertion OK : test34 Worksheets('Sheet2').Range('IU2:IV65536') A1 style addressing
+ ITEM Assertion OK : test35 Range('c1:g10').Columns('x:z') R1C1 style addressing
+ ITEM Assertion OK : test36 Worksheets('Sheet2').Range('A1') A1 style addressing
+ ITEM Assertion OK : test37 Worksheets('Sheet2').Range('A1:E5').EntireColumn A1 style addressing
+ ITEM Assertion OK : test38 Worksheets('Sheet2').Range('10:12') A1 style addressing
+ ITEM Assertion OK : test39 Worksheets('Sheet2').Range('10:12') R1C1 style addressing
+ ITEM Assertion OK : test40 Range('Sheet3!A1:B4') A1 style addressing
+ ITEM Assertion OK : test41 Range('Sheet3!A1,B1,D4:F20') A1 style addressing
+ ITEM Assertion OK : test42 Range('g20:h40').Columns('c:c')
+ ITEM Assertion OK : test43 Range('g20:h40').Columns('c:f')
+ ITEM Assertion OK : test44 Range('g20:h40').Columns(-1)
+ ITEM Assertion OK : test45 Range('c4:g10').Rows(-1)
+ ITEM Assertion OK : test46 Range('a2:b4').Rows('1:1')
+ ITEM Assertion OK : test47 Range('a2:b4').Rows('1:2')
+ ITEM Assertion OK : test48 Range('a2:b4').Rows('2:2')
+ ITEM Assertion OK : test49 Range('a2:b4').Rows('2:3')
+Test Results
+============
+
+Tests passed: 49
+Tests failed: 0
+
+END 'TestAddress
+ TEST OK : TestAddress
+Test run finished : 17/07/2007 15:26:56
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest.log
new file mode 100644
index 000000000000..492c24bc023c
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest.log
@@ -0,0 +1,60 @@
+Test run started : 10/07/2007 01:56:07
+BEGIN TestCalc
+ TEST START : RangeTest2
+ ITEM Assertion OK : - Range("D15").Row
+ ITEM Assertion OK : - WorkSheet("D15").Range.Row
+ ITEM Assertion OK : - Range("D15").Column
+ ITEM Assertion OK : - Worksheet.Range("D15").Column
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Valuer
+ ITEM Assertion OK : - Range("D1").EntireRow.Columns.Count
+ ITEM Assertion OK : - Range("D1").EntireColumn.Rows.Count
+ ITEM Assertion OK : - Range("D15").ClearContent
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Rows(1).Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns.Hidden (get)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (set)
+ ITEM Assertion OK : - Range("M1:N2").Columns(1).Hidden (get)
+ ITEM Assertion OK : - Range("B38").Orientation (get)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlDownward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlUpward)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B38").Orientation (set)
+ ITEM Assertion OK : - Range("B38").Orientation (set = xlVertical)
+ ITEM Assertion OK : - Range("B39").WrapText (get)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("B39").WrapText (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (get)
+ ITEM Assertion OK : - Range("F39").MergeCells (get)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion FAIL : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("E39").MergeCells (set)
+ ITEM Assertion OK : - Range("F39").MergeCells (set)
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("C41:C42").Replace MatchCase:=True
+ ITEM Assertion OK : - Range("D41:D42").Replace MatchCase:=False
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (get)
+ ITEM Assertion OK : - Range("B39").VerticalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (get)
+ ITEM Assertion OK : - Range("B39").HorizontalAlignment (set)
+ ITEM FAIL (RangeTest2)
+ TEST Not succesfully completed : RangeTest2
+END TestCalc
+Test run finished : 10/07/2007 01:56:12
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest2.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest2.log
new file mode 100644
index 000000000000..2532289bbe41
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/TestCalc_Rangetest2.log
@@ -0,0 +1,65 @@
+Test run started : 10/07/2007 01:56:15
+BEGIN TestCalc
+ TEST START : RangeTest3
+ ITEM Assertion FAIL : - setFormulaR1C1
+ ITEM Assertion OK : - getFormulaR1C1
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy(Range("I10"))
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteValues
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormulas
+ ITEM Assertion OK : PasteSpecial Paste:=xlPasteFormats
+ ITEM Assertion OK : PasteSpecial
+ ITEM Assertion OK : PasteSpecial SkipBlanks:=True
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationAdd
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationSubtract
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationMultiply
+ ITEM Assertion OK : PasteSpecial Operation:=xlPasteSpecialOperationDivide
+ ITEM Assertion OK : PasteSpecial Transpose:=True
+ ITEM Assertion FAIL : ActiveWorkbook.FileFormat
+ ITEM Assertion OK : ActiveWorkbook.Name
+ ITEM Assertion OK : ActiveWorkbook.FullName und ActiveWorkbook.Path
+ ITEM Assertion FAIL : - = ActiveWorkbook.Colors(3) set
+ ITEM Assertion OK : - = ActiveWorkbook.ResetColors
+ ITEM Assertion OK : - = ActiveWorkbook.Colors(3) get
+ ITEM Assertion OK : - = Range("K22").End (xlDown)
+ ITEM Assertion OK : - = Range("K22").End (xlUo)
+ ITEM Assertion OK : - = Range("K22").End (xlToLeft)
+ ITEM Assertion OK : - = Range("K22").End (xlRight)
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Next
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - ActiveSpreadsheet.Previous
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="x"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="<>"
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter field:=1, Criteria1:="="
+ ITEM Assertion OK : - Range("J4:J11").AutoFilter
+ ITEM Assertion OK : - ActiveSheet.Resize.Select
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion FAIL : - Application.GoTo Reference:="R[8]C[2]"
+ ITEM Assertion OK : - Application.GoTo Reference:="R8C2"
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Ungroup- please check visually
+ ITEM Assertion OK : - Range.Ungroup - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.Group - please check visually
+ ITEM Assertion OK : - Range.clearOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - Range.AutoOutline - please check visually
+ ITEM Assertion OK : - ActiveSheet.UsedRange.Select
+ ITEM Assertion OK : - Range("A13").AddIndent
+ ITEM Assertion OK : - Range("A13").IndentLevel set
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range("A13").IndentLevel get
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Copy() and Range.PasteSpecial()
+ ITEM Assertion OK : - Range.Calculate
+ ITEM Assertion OK : Worksheet.Calculate
+ ITEM Assertion OK : - Application.Calculate
+ ITEM Assertion OK : Global.Calculate
+ ITEM Assertion OK : Calculation set
+ ITEM FAIL (RangeTest3)
+ TEST Not succesfully completed : RangeTest3
+END TestCalc
+Test run finished : 10/07/2007 01:56:23
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/pagesetup.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/pagesetup.log
new file mode 100644
index 000000000000..a1c90473ce07
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/pagesetup.log
@@ -0,0 +1,87 @@
+Test run started : 7/21/2008 10:37:24 AM
+BEGIN PageSetup
+ TEST START : Sheet_PrintArea
+ ITEM Assertion OK : PrintArea has changed as expected
+ TEST OK : Sheet_PrintArea
+ TEST START : Test margins (no headers)
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.RightMargin set/get
+ ITEM Assertion OK : PageSetup.TopMargin set/get
+ ITEM Assertion OK : PageSetup.BottomMargin set/get
+Verify that page margins on sheet 1 are all 0.5inch
+ TEST OK : Test margins (no headers)
+ TEST START : Test margins (headers)
+ ITEM Assertion OK : PageSetup.HeaderMargin set/get
+ ITEM Assertion OK : PageSetup.FooterMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+ ITEM Assertion OK : PageSetup.LeftMargin set/get
+Verify that top/bottom/header/footer page margins on sheet 2 are all 0.5inch
+ TEST OK : Test margins (headers)
+ TEST START : Test header/footer text
+ ITEM Assertion OK : PageSetup.LeftHeader set
+ ITEM Assertion OK : PageSetup.LeftHeader set/get
+ ITEM Assertion OK : PageSetup.CenterHeader set
+ ITEM Assertion OK : PageSetup.CenterHeader set/get
+ ITEM Assertion OK : PageSetup.RightHeader set
+ ITEM Assertion OK : PageSetup.RightHeader set/get
+ ITEM Assertion OK : PageSetup.LeftFooter set
+ ITEM Assertion OK : PageSetup.LeftFooter set/get
+ ITEM Assertion OK : PageSetup.CenterFooter set
+ ITEM Assertion OK : PageSetup.CenterFooter set/get
+ ITEM Assertion OK : PageSetup.RightFooter set
+ ITEM Assertion OK : PageSetup.RightFooter set/get
+Verify that headers on sheet 2 are Ready,to,go
+Verify that footers on sheet 2 are This,now,Works
+ TEST OK : Test header/footer text
+ TEST START : Test zoom
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Zoom set/get
+Verify that sheet 1 zoom is 10%
+ TEST OK : Test zoom
+ TEST START : Test orientation
+ ITEM Assertion OK : PageSetup.Zoom set
+ ITEM Assertion OK : PageSetup.Orientation set/get
+Verify that sheet 1 orientation is now landscape
+ TEST OK : Test orientation
+ TEST START : Test paper size
+ ITEM Assertion OK : PageSetup.PaperSize get
+ ITEM Assertion OK : PageSetup.PaperSize set/get
+Verify that paper size on sheet 1 is now Letter
+ TEST OK : Test paper size
+ TEST START : Test order
+ ITEM Assertion OK : PageSetup.Order get
+ ITEM Assertion OK : PageSetup.Order set/get
+Verify that order on sheet 1 is now over, then down.
+ TEST OK : Test order
+ TEST START : Test first page number
+ ITEM Assertion OK : PageSetup.FirstPageNumber get
+ ITEM Assertion OK : PageSetup.FirstPageNumber set/get
+Verify that first page number on sheet 1 is now 2.
+ TEST OK : Test first page number
+ TEST START : Test center vertically
+ ITEM Assertion OK : PageSetup.CenterVertically get
+ ITEM Assertion OK : PageSetup.CenterVertically set/get
+Verify that CenterVertically on sheet 1 is now true.
+ TEST OK : Test center vertically
+ TEST START : Test center horizontally
+ ITEM Assertion OK : PageSetup.CenterHorizontally get
+ ITEM Assertion OK : PageSetup.CenterHorizontally set/get
+Verify that CenterHorizontally on sheet 1 is now true.
+ TEST OK : Test center horizontally
+ TEST START : Test FitToPagesTall
+ ITEM Assertion OK : PageSetup.FitToPagesTall set/get
+ TEST OK : Test FitToPagesTall
+ TEST START : Test FitToPagesWide
+ ITEM Assertion OK : PageSetup.FitToPagesWide set/get
+ TEST OK : Test FitToPagesWide
+ TEST START : Test PrintHeadings
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ ITEM Assertion OK : PageSetup.PrintHeadings set/get
+ TEST OK : Test PrintHeadings
+ TEST START : Test PrintTitleRows
+ ITEM Assertion OK : PageSetup.PrintTitleRows get
+ ITEM Assertion OK : PageSetup.PrintTitleRows set range/get
+ ITEM Assertion OK : PageSetup.PrintTitleRows set false/get
+ TEST OK : Test PrintTitleRows
+END PageSetup
+Test run finished : 7/21/2008 10:37:32 AM
diff --git a/sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log b/sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
new file mode 100644
index 000000000000..e96004e4d2a6
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/logs/win/replace.log
@@ -0,0 +1,14 @@
+Test run started : 2007-11-21 11:24:04
+BEGIN Replace
+ TEST START : Test Replace function
+ ITEM Assertion OK : common string:aefefdBc
+ ITEM Assertion OK : expression string:aefefdef
+ ITEM Assertion OK : binanary compare:aefefdBc
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : text compare:aefefdef
+ ITEM Assertion OK : start = 3:cefdBc
+ ITEM Assertion OK : count = 2: aefefdBc
+ ITEM Assertion OK : start = 1, count = 0, not support in Unix: abcbcdBc
+ TEST OK : Test Replace function
+END Replace
+Test run finished : 2007-11-21 11:24:04
diff --git a/sc/source/ui/vba/testvba/TestDocuments/pagesetup.xls b/sc/source/ui/vba/testvba/TestDocuments/pagesetup.xls
new file mode 100755
index 000000000000..dfa1b2a8be58
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/pagesetup.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/partition.xls b/sc/source/ui/vba/testvba/TestDocuments/partition.xls
new file mode 100644
index 000000000000..5c8d12b1d54f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/partition.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/range-4.xls b/sc/source/ui/vba/testvba/TestDocuments/range-4.xls
new file mode 100755
index 000000000000..52452369462f
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/range-4.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/replace.xls b/sc/source/ui/vba/testvba/TestDocuments/replace.xls
new file mode 100644
index 000000000000..dcf3c6e8ec06
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/replace.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xls b/sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xls
new file mode 100644
index 000000000000..596be7f6b9bc
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/stringplusdouble.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/TestDocuments/window2.xls b/sc/source/ui/vba/testvba/TestDocuments/window2.xls
new file mode 100755
index 000000000000..4d5e1cbfe944
--- /dev/null
+++ b/sc/source/ui/vba/testvba/TestDocuments/window2.xls
Binary files differ
diff --git a/sc/source/ui/vba/testvba/launchTest.pl b/sc/source/ui/vba/testvba/launchTest.pl
new file mode 100644
index 000000000000..5b64f7522c09
--- /dev/null
+++ b/sc/source/ui/vba/testvba/launchTest.pl
@@ -0,0 +1,45 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+use File::Basename;
+
+my $test_class = shift || die 'must provide a ext name';
+my $TESTDOCUMENT = shift || die 'must provide a path to testdocument dirs';
+my $OUTPUTDIR = shift || die 'must provide an output path to deposit logs in';
+
+die "can't access TestClass $test_class/TestVBA.class" unless -f "$test_class/TestVBA.class";
+die "can't access officepath env variable \$OFFICEPATH" unless -d $ENV{OFFICEPATH};
+die "can't access testdocuments" unless -d $TESTDOCUMENT;
+die "testdocument not of the correct structure $TESTDOCUMENT/logs/excel" unless -d "$TESTDOCUMENT/logs/excel";
+die "can't access output dir" unless -d $OUTPUTDIR;
+
+
+my $officeclasspath = "$ENV{OFFICEPATH}/program/classes/";
+my $classpath = "$officeclasspath/jurt.jar:$officeclasspath/unoil.jar:$officeclasspath/juh.jar:$officeclasspath/java_uno.jar:$officeclasspath/ridl.jar:$test_class:$ENV{CLASSPATH}";
+$ENV{CLASSPATH}=$classpath;
+print "classpath $ENV{CLASSPATH}\n";
+my $status = system("java -classpath $ENV{CLASSPATH} TestVBA $TESTDOCUMENT $OUTPUTDIR" );
diff --git a/sc/source/ui/vba/testvba/makefile.mk b/sc/source/ui/vba/testvba/makefile.mk
new file mode 100644
index 000000000000..fb131f314ed3
--- /dev/null
+++ b/sc/source/ui/vba/testvba/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/..$/
+
+PRJNAME=sc
+TARGET=testvba
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+DLLPRE =
+
+.IF "$(ENABLE_VBA)"!="YES"
+dummy:
+ @echo "not building vba..."
+.ENDIF
+
+INCPRE=$(INCCOM)$/$(TARGET)
+CDEFS+=-DVBA_OOBUILD_HACK
+# ------------------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/testvba.obj \
+
+
+# --- Targets ------------------------------------------------------
+
+APP1TARGET=testclient
+APP1OBJS= $(SLOFILES)
+
+APP1STDLIBS=\
+ $(SALLIB) \
+ $(STDLIBCPP) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB) \
+
+#APP1OBJS= $(OBJ)$/testclient.obj
+.INCLUDE : target.mk
+
+
diff --git a/sc/source/ui/vba/testvba/runTests.pl b/sc/source/ui/vba/testvba/runTests.pl
new file mode 100755
index 000000000000..70f80329cfeb
--- /dev/null
+++ b/sc/source/ui/vba/testvba/runTests.pl
@@ -0,0 +1,121 @@
+#!/usr/bin/perl -w
+use URI::Escape;
+use File::Basename;
+use Cwd;
+use Cwd 'abs_path';
+
+$numArgs = $#ARGV + 1;
+print "thanks, you gave me $numArgs command-line arguments.\n";
+
+foreach $argnum (0 .. $#ARGV) {
+ print "$ARGV[$argnum]\n";
+}
+
+
+my $binDir = abs_path( dirname($0) );
+
+my $sysDir = "unix";
+my $fileSep = "/";
+my $theResult;
+my $officepath = shift || die "please specify path to office installation program dir";
+my $DocName = shift || "";
+my $programpath = "$officepath"."3/program:$officepath/program:";
+my $basiclibrarypath = "$officepath/basis3.3/program";
+my $urelibpath = "$officepath/ure/lib";
+my $binext = "";
+my $testDocDir = "$binDir/TestDocuments";
+my $testLogDir = "$binDir/Logs";
+my $testclientname = "testclient";
+my $buildtestclient = "../../../../unxlngi6.pro/bin/$testclientname";
+
+# test testclient
+if ( -e "$buildtestclient" )
+{
+ print "use the latest build\n";
+ system( "cp $buildtestclient ." );
+}
+elsif ( !( -e "$testclientname" ) )
+{
+ print "$testclientname do not exist\n";
+ exit;
+}
+
+# test for uname
+system("uname");
+$exit_value = $? >> 8;
+$signal_num = $? & 127;
+$dumped_core = $? & 128;
+
+$failed = ( $exit_value || $signal_num || $dumped_core );
+
+print "$failed = ( $exit_value || $signal_num || $dumped_core )\n";
+
+if ( !$failed && open(UNAME, "uname -a|") ) {
+ $theResult = <UNAME>;
+ close(UNAME);
+ if ( $theResult =~ /^CYGWIN/ ) {
+ # windows under cygwin
+ $sysDir = "win" ;
+ $tmpPath=$ENV{"PATH"};
+ $ENV{"PATH"} = "$officepath:$tmpPath";
+ $testDocDir=`cygpath -m $testDocDir`;
+ uri_escape($testDocDir);
+ # hacky windows url construction
+ $testDocDir="file:///$testDocDir";
+
+ chomp($testDocDir);
+ #print "*** doc dir is $testDocDir\n";
+ $testLogDir = `cygpath -m "$testLogDir"`;
+ uri_escape($testLogDir);
+ $testLogDir="file:///$testLogDir";
+ chomp($testLogDir);
+ #print "*** log dir is $testLogDir\n";
+ $binext = ".exe";
+ }
+ else{
+ # unix we need to find sal etc. ( from the office path )
+ my $tmpPath=$ENV{"PATH"};
+ $ENV{"PATH"} = "$programpath:$basiclibrarypath:$urelibpath/../bin:$tmpPath";
+ $tmpPATH = $ENV{"LD_LIBRARY_PATH"};
+ $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$urelibpath../bin/javaldx:$urelibpath/../bin:$tmpPATH";
+ $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$tmpPATH";
+ my $testPath = $ENV{"LD_LIBRARY_PATH"};
+ print "$testPath\n";
+ $testPath = $ENV{"PATH"};
+ print "$testPath\n";
+ $ENV{"STAR_RESOURCEPATH"} = "$officepath/basis3.0/program/resource";
+ $ENV{"SAL_ALLOW_LINKOO_SYMLINKS"} = "1";
+ $testPath = $ENV{"LANG"};
+ print "$testPath\n";
+ }
+}
+else
+{
+ # ordinary windows, not sure if this will actually work
+ $sysDir = "win" ;
+ $tmpPath=$ENV{"PATH"};
+ $ENV{"PATH"} = "$tmpPath;$officepath";
+ $binext = ".exe";
+}
+
+# the exe needs system paths or urls ( urls are by far the least troublesome )
+
+my $runCmd = "";
+my $analyseCmd = "";
+
+if ( "$DocName" eq "" )
+{
+ $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir";
+ $analyseCmd = "perl $binDir/testResults.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir";
+}
+else
+{
+ $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir $testDocDir/$DocName";
+ $analyseCmd = "perl $binDir/testResult.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir $DocName";
+}
+print "runCmd = $runCmd\n";
+
+system ("rm -rf $testLogDir/*");
+my $status = system( $runCmd );
+print "analyseCmd = $analyseCmd\n";
+$status = system( $analyseCmd );
diff --git a/sc/source/ui/vba/testvba/testResult.pl b/sc/source/ui/vba/testvba/testResult.pl
new file mode 100644
index 000000000000..171be2597ddb
--- /dev/null
+++ b/sc/source/ui/vba/testvba/testResult.pl
@@ -0,0 +1,171 @@
+#!/usr/bin/perl -w
+use File::Temp qw/ tempfile tempdir /;
+use File::Basename;
+use File::stat;
+use File::Copy;
+
+my $binDir = dirname($0);
+my $timestampclean= "perl $binDir/timestampsClean.pl";
+#sub gen_diff($)
+
+sub testLog
+{
+ # 2 No Log to compare against
+ # 1 Log passed
+ # 0 Log failed
+ my $result = 0;
+ my $testfile = shift;
+ my $dirtocheck = shift;
+ my $filename = basename($testfile);
+ $filename = "$logdir/$filename";
+ print "processing $testfile $filename\n";
+ if ( -f $filename ) {
+ my $tmpFile;
+ $dir = tempdir( CLEANUP => 1 );
+ ($fh, $tmpFile) = tempfile( DIR => $dir );
+ close($fh);
+ #
+ my $status = system("diff -U 0 -p $testfile $filename | $timestampclean > $tmpFile");
+ my $info = stat($tmpFile) or die "no $tmpFile: $!";
+ if ( ($status >>=8) == 0 && ( $info->size == 0) ) {
+ #print "diff worked size is 0\n";
+ $result = 1;
+ }
+ elsif ( ($status >>=8) == 0 && ( $info->size > 0) )
+ {
+ #print "diff worked size > 0\n";
+ $result = 0;
+ }
+ else
+ {
+ #print "diff failed size > 0\n";
+ $result = 0;
+ }
+ }
+ else
+ {
+ #print "not file > 0\n";
+ $result = 2;
+ }
+ #print "diff result = $result\n";
+ return $result;
+}
+
+if ( ! ( $logdir = shift @ARGV ) ) {
+ print STDERR "No logdir specified!\n";
+ usage();
+ exit 1;
+}
+
+if ( ! ( $testlogdir = shift @ARGV ) ) {
+ print STDERR "No testdocuments dir to compare against specified!\n";
+ usage();
+ exit 1;
+}
+
+if ( !(-d $logdir ) ) {
+ print STDERR "No output directory $logdir exists, please create it!!!!\n";
+ exit 1;
+}
+if ( !(-d $testlogdir ) ) {
+ print STDERR "the directory containing the logfiles to compare against \"$logdir\" does not exist\n";
+ usage();
+ exit 1;
+}
+print "logdir $logdir\n";
+print "testlogdir $testlogdir\n";
+sub filter_crud($)
+{
+ my $a = shift;
+
+ $a =~ /~$/ && return;
+ $a =~ /\#$/ && return;
+ $a =~ /\.orig$/ && return;
+ $a =~ /unxlng.*\.pro$/ && return;
+ $a =~ /wntmsc.*\.pro$/ && return;
+ $a =~ /.swp$/ && return;
+ $a =~ /POSITION/ && return;
+ $a =~ /ReadMe/ && return;
+ $a =~ /.tmp$/ && return;
+ $a =~ /\.svn/ && return;
+ $a eq 'CVS' && return;
+ $a eq '.' && return;
+ $a eq '..' && return;
+
+ return $a;
+}
+sub slurp_dir($);
+
+sub slurp_dir($)
+{
+ my $dir = shift;
+ my ($dirhandle, $fname);
+ my @files = ();
+
+ opendir ($dirhandle, $dir) || die "Can't open $dir";
+ while ($fname = readdir ($dirhandle)) {
+ $fname = filter_crud($fname);
+ defined $fname || next;
+# if (-d "$dir/$fname") {
+# push @files, slurp_dir("$dir/$fname");
+# } else
+ {
+ push @files, "$dir/$fname";
+ }
+ }
+ closedir ($dirhandle);
+
+ return @files;
+}
+
+if (-d $testlogdir) {
+ push @files, slurp_dir($testlogdir);
+}
+
+my $processed = 0;
+my $passed = 0;
+my @passedTests=();
+my @skippedTests=();
+my @failedTests=();
+
+my $failureCmd="";
+my $testfile = shift @ARGV;
+my $testfilepath = "$testlogdir/$testfile";
+$testfilepath =~ s/\.xls/\.log/;
+print "$testfilepath\n";
+for $a (@files) {
+ $filename = $a;
+ if ( "$testfilepath" eq "$filename" )
+ {
+ $processed++;
+ my $testcase = $a;
+ $testcase =~ s/\.log/\.xls/;
+ my $result = testLog( $a, $logdir );
+ if ( $result == 0 ) {
+ push @failedTests, basename($testcase);
+ if ( $failureCmd eq "" ) { $failureCmd = " diff -up $a $logdir "; }
+ }
+ elsif ( $result == 2 ) {
+ #print "skipped $a\n";
+ push @skippedTests, $testcase;
+ }
+ else {
+ $passed++;
+ push @passedTests, $testcase;
+ #print "Test document for $a \t \t passed. \n";
+ }
+ }
+}
+my $compared=@passedTests+@failedTests;
+my $skip = @skippedTests;
+print "skipped $skip test-cases(s)\n";
+print "compared $compared test-case documents\n";
+print "\t \t $passed tests $@passedTests\n";
+if ( @failedTests > 0 ) {
+ print "the following test-case documents failed, please examine the logs manually\n";
+
+ for $a (@failedTests) {
+ print "\t$a\n";
+ }
+ print "e.g. $failureCmd\n"
+}
diff --git a/sc/source/ui/vba/testvba/testResults.pl b/sc/source/ui/vba/testvba/testResults.pl
new file mode 100755
index 000000000000..6f731327e76b
--- /dev/null
+++ b/sc/source/ui/vba/testvba/testResults.pl
@@ -0,0 +1,163 @@
+#!/usr/bin/perl -w
+use File::Temp qw/ tempfile tempdir /;
+use File::Basename;
+use File::stat;
+use File::Copy;
+
+my $binDir = dirname($0);
+my $timestampclean= "perl $binDir/timestampsClean.pl";
+#sub gen_diff($)
+
+sub testLog
+{
+ # 2 No Log to compare against
+ # 1 Log passed
+ # 0 Log failed
+ my $result = 0;
+ my $testfile = shift;
+ my $dirtocheck = shift;
+ my $filename = basename($testfile);
+ $filename = "$logdir/$filename";
+ print "processing $testfile $filename\n";
+ if ( -f $filename ) {
+ my $tmpFile;
+ $dir = tempdir( CLEANUP => 1 );
+ ($fh, $tmpFile) = tempfile( DIR => $dir );
+ close($fh);
+ #
+ my $status = system("diff -U 0 -p $testfile $filename | $timestampclean > $tmpFile");
+ my $info = stat($tmpFile) or die "no $tmpFile: $!";
+ if ( ($status >>=8) == 0 && ( $info->size == 0) ) {
+ #print "diff worked size is 0\n";
+ $result = 1;
+ }
+ elsif ( ($status >>=8) == 0 && ( $info->size > 0) )
+ {
+ #print "diff worked size > 0\n";
+ $result = 0;
+ }
+ else
+ {
+ #print "diff failed size > 0\n";
+ $result = 0;
+ }
+ }
+ else
+ {
+ #print "not file > 0\n";
+ $result = 2;
+ }
+ #print "diff result = $result\n";
+ return $result;
+}
+
+if ( ! ( $logdir = shift @ARGV ) ) {
+ print STDERR "No logdir specified!\n";
+ usage();
+ exit 1;
+}
+
+if ( ! ( $testlogdir = shift @ARGV ) ) {
+ print STDERR "No testdocuments dir to compare against specified!\n";
+ usage();
+ exit 1;
+}
+
+if ( !(-d $logdir ) ) {
+ print STDERR "No output directory $logdir exists, please create it!!!!\n";
+ exit 1;
+}
+if ( !(-d $testlogdir ) ) {
+ print STDERR "the directory containing the logfiles to compare against \"$logdir\" does not exist\n";
+ usage();
+ exit 1;
+}
+print "logdir $logdir\n";
+print "testlogdir $testlogdir\n";
+sub filter_crud($)
+{
+ my $a = shift;
+
+ $a =~ /~$/ && return;
+ $a =~ /\#$/ && return;
+ $a =~ /\.orig$/ && return;
+ $a =~ /unxlng.*\.pro$/ && return;
+ $a =~ /wntmsc.*\.pro$/ && return;
+ $a =~ /.swp$/ && return;
+ $a =~ /POSITION/ && return;
+ $a =~ /ReadMe/ && return;
+ $a =~ /.tmp$/ && return;
+ $a =~ /\.svn/ && return;
+ $a eq 'CVS' && return;
+ $a eq '.' && return;
+ $a eq '..' && return;
+
+ return $a;
+}
+sub slurp_dir($);
+
+sub slurp_dir($)
+{
+ my $dir = shift;
+ my ($dirhandle, $fname);
+ my @files = ();
+
+ opendir ($dirhandle, $dir) || die "Can't open $dir";
+ while ($fname = readdir ($dirhandle)) {
+ $fname = filter_crud($fname);
+ defined $fname || next;
+# if (-d "$dir/$fname") {
+# push @files, slurp_dir("$dir/$fname");
+# } else
+ {
+ push @files, "$dir/$fname";
+ }
+ }
+ closedir ($dirhandle);
+
+ return @files;
+}
+
+if (-d $testlogdir) {
+ push @files, slurp_dir($testlogdir);
+}
+
+my $processed = 0;
+my $passed = 0;
+my @passedTests=();
+my @skippedTests=();
+my @failedTests=();
+
+my $failureCmd="";
+for $a (@files) {
+ $processed++;
+ my $testcase = $a;
+ $testcase =~ s/\.log/\.xls/;
+ my $result = testLog( $a, $logdir );
+ if ( $result == 0 ) {
+ push @failedTests, basename($testcase);
+ if ( $failureCmd eq "" ) { $failureCmd = " diff -up $a $logdir "; }
+ }
+ elsif ( $result == 2 ) {
+ #print "skipped $a\n";
+ push @skippedTests, $testcase;
+ }
+ else {
+ $passed++;
+ push @passedTests, $testcase;
+ #print "Test document for $a \t \t passed. \n";
+ }
+}
+my $compared=@passedTests+@failedTests;
+my $skip = @skippedTests;
+print "skipped $skip test-cases(s)\n";
+print "compared $compared test-case documents\n";
+print "\t \t $passed tests $@passedTests\n";
+if ( @failedTests > 0 ) {
+ print "the following test-case documents failed, please examine the logs manually\n";
+
+ for $a (@failedTests) {
+ print "\t$a\n";
+ }
+ print "e.g. $failureCmd\n"
+}
diff --git a/sc/source/ui/vba/testvba/testclient b/sc/source/ui/vba/testvba/testclient
new file mode 100755
index 000000000000..c9cde8c5b052
--- /dev/null
+++ b/sc/source/ui/vba/testvba/testclient
Binary files differ
diff --git a/sc/source/ui/vba/testvba/testvba.cxx b/sc/source/ui/vba/testvba/testvba.cxx
new file mode 100644
index 000000000000..f240c523edc6
--- /dev/null
+++ b/sc/source/ui/vba/testvba/testvba.cxx
@@ -0,0 +1,312 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#include "cppuhelper/bootstrap.hxx"
+
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
+#include <com/sun/star/document/XTypeDetection.hpp>
+
+#include <tools/urlobj.hxx>
+#include <osl/file.hxx>
+
+#include <memory>
+#include <iostream>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::sheet;
+
+using ::com::sun::star::beans::Property;
+using ::com::sun::star::beans::PropertyValue;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::beans::XPropertySetInfo;
+using ::com::sun::star::container::XNameContainer;
+using ::com::sun::star::lang::XComponent;
+using ::com::sun::star::lang::XMultiComponentFactory;
+using ::com::sun::star::frame::XComponentLoader;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::XComponentContext;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::com::sun::star::document::XTypeDetection;
+using ::rtl::OUString;
+
+using ::std::auto_ptr;
+
+const OUString EXTN = rtl::OUString::createFromAscii(".xls");
+
+OUString convertToURL( const OUString& rPath )
+{
+ rtl::OUString aURL;
+ INetURLObject aObj;
+ aObj.SetURL( rPath );
+ bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
+ if ( bIsURL )
+ aURL = rPath;
+ else
+ {
+ osl::FileBase::getFileURLFromSystemPath( rPath, aURL );
+ if ( aURL.equals( rPath ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "could'nt convert " ).concat( rPath ).concat( rtl::OUString::createFromAscii( " to a URL, is it a fully qualified path name? " ) ), Reference< uno::XInterface >() );
+ }
+ return aURL;
+}
+
+OUString ascii(const sal_Char* cstr)
+{
+ return OUString::createFromAscii(cstr);
+}
+
+const sal_Char* getStr(const OUString& ou)
+{
+ return OUStringToOString(ou, RTL_TEXTENCODING_UTF8).getStr();
+}
+
+
+int usage( const char* pName )
+{
+ std::cerr << "usage: " << pName << "<path to testdocument dir> <output_directory>" << std::endl;
+ return 1;
+
+}
+
+class TestVBA
+{
+private:
+ Reference< XComponentContext > mxContext;
+ Reference< XMultiComponentFactory > mxMCF;
+ Reference< XComponentLoader > mxCompLoader;
+ Reference< XSimpleFileAccess > mxSFA;
+ rtl::OUString msOutDirPath;
+protected:
+public:
+ TestVBA( const Reference< XComponentContext >& _xContext,
+ const Reference< XMultiComponentFactory >& _xMCF,
+ const Reference< XComponentLoader >& _xCompLoader,
+ const rtl::OUString& _outDirPath ) : mxContext( _xContext ), mxMCF( _xMCF ),
+mxCompLoader( _xCompLoader ), msOutDirPath( convertToURL( _outDirPath ) )
+ {
+ mxSFA.set( mxMCF->createInstanceWithContext( rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), mxContext), uno::UNO_QUERY_THROW );
+ }
+
+ rtl::OUString getLogLocation() throw ( beans::UnknownPropertyException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::Exception )
+ {
+ rtl::OUString sLogLocation;
+ Reference< XPropertySet > pathSettings( mxMCF->createInstanceWithContext( rtl::OUString::createFromAscii( "com.sun.star.comp.framework.PathSettings" ), mxContext), uno::UNO_QUERY_THROW );
+ pathSettings->getPropertyValue( rtl::OUString::createFromAscii( "Work" ) ) >>= sLogLocation;
+ sLogLocation = sLogLocation.concat( rtl::OUString::createFromAscii( "/" ) ).concat( rtl::OUString::createFromAscii( "HelperAPI-test.log" ) );
+ return sLogLocation;
+ }
+ rtl::OUString getLogLocationWithName( OUString fileName ) throw ( beans::UnknownPropertyException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::Exception )
+ {
+ printf("%s\n", getenv("HOME") );
+ printf("file name %s\n", rtl::OUStringToOString( fileName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ //rtl::OUString sLogLocation( rtl::OUString::createFromAscii( getenv("HOME") ) );
+ rtl::OUString sLogLocation;
+ Reference< XPropertySet > pathSettings( mxMCF->createInstanceWithContext( rtl::OUString::createFromAscii( "com.sun.star.comp.framework.PathSettings" ), mxContext), uno::UNO_QUERY_THROW );
+ pathSettings->getPropertyValue( rtl::OUString::createFromAscii( "Work" ) ) >>= sLogLocation;
+ sLogLocation = sLogLocation.concat( rtl::OUString::createFromAscii( "/" ) ).concat( fileName.copy ( 0, fileName.lastIndexOf( EXTN ) ) + rtl::OUString::createFromAscii( ".log" ) );
+ return sLogLocation;
+ }
+
+ void init()
+ {
+ // blow away previous logs?
+ }
+
+ void proccessDocument( const rtl::OUString& sUrl )
+ {
+ if ( !mxSFA->isFolder( sUrl ) && sUrl.endsWithIgnoreAsciiCaseAsciiL( ".xls", 4 ) )
+
+ {
+ try
+ {
+ OSL_TRACE( "processing %s", rtl::OUStringToOString( sUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
+ printf( "processing %s\n", rtl::OUStringToOString( sUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
+ // Loading the wanted document
+ Sequence< PropertyValue > propertyValues(1);
+ propertyValues[0].Name = rtl::OUString::createFromAscii( "Hidden" );
+ propertyValues[0].Value <<= sal_False;
+
+ rtl::OUString sfileUrl = convertToURL( sUrl );
+ printf( "try to get xDoc %s\n", rtl::OUStringToOString( sfileUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
+ Reference< uno::XInterface > xDoc =
+ mxCompLoader->loadComponentFromURL( sfileUrl, rtl::OUString::createFromAscii( "_blank" ), 0, propertyValues);
+ printf( "got xDoc\n" );
+
+ OUString logFileURL = convertToURL( getLogLocation() );
+ try
+ {
+ Reference< script::provider::XScriptProviderSupplier > xSupplier( xDoc, uno::UNO_QUERY_THROW ) ;
+ if ( mxSFA->exists( logFileURL ) )
+ mxSFA->kill( logFileURL );
+
+ printf("try to get the ScriptProvider\n");
+ Reference< script::provider::XScriptProvider > xProv = xSupplier->getScriptProvider();
+ printf("get the ScriptProvider\n");
+ printf("try to get the Script\n");
+ Reference< script::provider::XScript > xScript;
+ try
+ {
+ xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:VBAProject.TestMacros.Main?language=Basic&location=document" ));
+ } catch ( uno::Exception& e )
+ {
+ try
+ {
+ xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:VBAProject.testMacro.Main?language=Basic&location=document" ));
+ } catch ( uno::Exception& e2 )
+ {
+ xScript = xProv->getScript( rtl::OUString::createFromAscii( "vnd.sun.star.script:VBAProject.testMain.Main?language=Basic&location=document" ));
+ }
+ }
+ OSL_TRACE("Got script for doc %s", rtl::OUStringToOString( sUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
+ printf("get the Script\n");
+ Sequence< uno::Any > aArgs;
+ Sequence< sal_Int16 > aOutArgsIndex;
+ Sequence< uno::Any > aOutArgs;
+
+ xScript->invoke(aArgs, aOutArgsIndex, aOutArgs);
+
+ OUString fileName = sUrl.copy ( sUrl.lastIndexOf( '/' ) );
+ OUString newLocation = msOutDirPath + fileName.copy ( 0, fileName.lastIndexOf( EXTN ) ) + rtl::OUString::createFromAscii( ".log" );
+ try
+ {
+ printf("move log file\n");
+ mxSFA->move( logFileURL, newLocation );
+ OSL_TRACE("new logfile location is %s ", rtl::OUStringToOString( newLocation, RTL_TEXTENCODING_UTF8 ).getStr() );
+ printf("moved to new location\n");
+ }
+ catch ( uno::Exception& e )
+ {
+ logFileURL = convertToURL( getLogLocationWithName( fileName ) );
+ printf("move log file from %s\n", rtl::OUStringToOString( logFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+ mxSFA->move( logFileURL, newLocation );
+ OSL_TRACE("new logfile location is %s ", rtl::OUStringToOString( newLocation, RTL_TEXTENCODING_UTF8 ).getStr() );
+ printf("moved to new location\n");
+ }
+
+ }
+ catch ( uno::Exception& e )
+ {
+ std::cerr << "Caught exception " << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
+ }
+
+ // interface is supported, otherwise use XComponent.dispose
+ Reference< util::XCloseable > xCloseable ( xDoc, uno::UNO_QUERY );
+
+ if ( xCloseable.is() )
+ {
+ printf("try to close\n");
+ // will close application. and only run a test case for 3.0
+ // maybe it is a bug. yes, it is a bug
+ // if only one frame and model, click a button which related will colse.
+ // will make a crash. It related with window listener.
+ // so, for run all test cases, it should not close the document at this moment.
+ xCloseable->close(sal_False);
+ printf("closed\n");
+ }
+ else
+ {
+ printf("try to dispose\n");
+ Reference< XComponent > xComp( xDoc, uno::UNO_QUERY_THROW );
+ // same as close.
+ xComp->dispose();
+ printf("disposed\n");
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ std::cerr << "Caught exception " << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
+ }
+
+ }
+ printf("complete processing %s\n", rtl::OUStringToOString( sUrl, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+
+ void traverse( const rtl::OUString& sFileDirectory )
+ {
+ rtl::OUString sFileDirectoryURL = convertToURL( sFileDirectory );
+ if ( !mxSFA->isFolder( sFileDirectoryURL) )
+ {
+ throw lang::IllegalArgumentException( rtl::OUString::createFromAscii( "not a directory: ").concat( sFileDirectoryURL ), Reference<uno::XInterface>(), 1 );
+ }
+ // Getting all files and directories in the current directory
+ Sequence<OUString> entries = mxSFA->getFolderContents( sFileDirectoryURL, sal_False );
+
+ // Iterating for each file and directory
+ printf( "Entries %d\n", (int)entries.getLength() );
+ for ( sal_Int32 i = 0; i < entries.getLength(); ++i )
+ {
+ proccessDocument( entries[ i ] );
+ }
+ }
+};
+
+void tryDispose( Reference< uno::XInterface > xIF, const char* sComp )
+{
+ Reference< lang::XComponent > xComponent( xIF, uno::UNO_QUERY );
+ if ( xComponent.is() )
+ {
+ try
+ {
+ xComponent->dispose();
+ }
+ catch( uno::Exception& e )
+ {
+ std::cerr << "tryDispose caught exception " <<rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() << " while disposing " << sComp << std::endl;
+ }
+ }
+}
+int main( int argv, char** argc )
+{
+ if ( !( argv > 2 ) )
+ return usage( argc[0] );
+ try
+ {
+
+ OSL_TRACE("Attempting to bootstrap normal");
+ Reference<XComponentContext> xCC = ::cppu::bootstrap();
+ Reference<XMultiComponentFactory> xFactory = xCC->getServiceManager();
+ OSL_TRACE("got servicemanager");
+ std::cout << "got servicemanager" << std::endl;
+ Reference<XInterface> desktop = xFactory->createInstanceWithContext(
+ ascii("com.sun.star.frame.Desktop"), xCC);
+ OSL_TRACE("got desktop");
+ std::cout << "got desktop" << std::endl;
+ Reference<frame::XComponentLoader> xLoader(desktop, UNO_QUERY_THROW);
+ TestVBA* dTest = new TestVBA( xCC, xFactory, xLoader, ascii( argc[ 2 ] ) );
+ if ( argv == 4 )
+ {
+ std::cout << "before process" << std::endl;
+ dTest->proccessDocument( ascii( argc[ 3 ] ) );
+ std::cout << "after process" << std::endl;
+ }
+ else
+ {
+ dTest->traverse( ascii( argc[ 1 ] ) );
+ }
+ delete dTest;
+// tryDispose( xLoader, "desktop" );
+// tryDispose( xCC, "remote context" );
+
+ }
+ catch( uno::Exception& e )
+ {
+ std::cerr << "Caught Exception " << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() << std::endl;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/testvba/timestampsClean.pl b/sc/source/ui/vba/testvba/timestampsClean.pl
new file mode 100755
index 000000000000..2c947d0cc6d5
--- /dev/null
+++ b/sc/source/ui/vba/testvba/timestampsClean.pl
@@ -0,0 +1,73 @@
+#!/usr/bin/perl -w
+
+my @output_buffer = ();
+my $fname;
+my $detectedSomeGuff = 0;
+sub pure_guff($)
+{
+ my $array = shift;
+ my @lines = @{$array};
+ my $contains_sense = '';
+ my $contains_guff = '';
+ while (scalar @lines)
+ {
+ my $line = pop @lines;
+ if ($line =~ m/Test run started :/ ||
+ $line =~ m/ITEM Assertion OK/ ||
+ $line =~ m/Test run finished :/) {
+ $contains_guff = '1';
+ } elsif ($line =~ m/^[\+\-][^\-\+]/) {
+ $contains_sense = '1';
+ }
+ }
+ if ($contains_guff && $contains_sense) {
+ print STDERR "Patch fragment with mixed good/bad changes in '$ARGV' near $line_index\n";
+ $contains_guff = '';
+ }
+ elsif ( $contains_guff ) {
+ $detectedSomeGuff++;
+ }
+# print "contains guff: $contains_guff\n";
+ return $contains_guff;
+}
+
+sub output_lines($)
+{
+ my $array = shift;
+ my @lines = @{$array};
+
+ if (pure_guff (\@lines)) {
+ return;
+ }
+
+ while (scalar @lines)
+ {
+ my $line = pop @lines;
+ push @output_buffer, $line;
+ }
+}
+
+my $header;
+my @lines;
+my $frag_count = 0;
+$line_index = 0;
+
+while (<>) {
+ if (/^\@\@/ || /^[^ \-\+]/) {
+ output_lines (\@lines);
+ @lines = ();
+ $frag_count++;
+ }
+ unshift @lines, $_;
+ $line_index++;
+ close ARGV if eof;
+}
+output_lines(\@lines);
+
+# $detectedSomeGuff contains the skipped hunks that contain acceptable diff
+# e.g. a timestamp or an OK assertion that contains different content
+# like perhaps a path
+#print "frag_count = $frag_count fragstocount = $fragstocount detectedSomeGuff = $detectedSomeGuff \n";
+if ($frag_count > $detectedSomeGuff) {
+ print @output_buffer;
+}
diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx
new file mode 100644
index 000000000000..8c9581a66d23
--- /dev/null
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -0,0 +1,1813 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <ooo/vba/excel/XlCalculation.hpp>
+#include <ooo/vba/excel/XlCutCopyMode.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XCalculatable.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/task/XStatusIndicatorSupplier.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <ooo/vba/excel/XlMousePointer.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+//2009-11-06 add by limingl
+#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+//end
+#include<ooo/vba/XCommandBars.hpp>
+#include <ooo/vba/excel/XlEnableCancelKey.hpp> //liuchen 2009-11-26
+#include <ooo/vba/excel/XlApplicationInternational.hpp> //liuchen 2009-11-26
+#include <unotools/localedatawrapper.hxx> //liuchen 2009-11-26
+
+#include "vbaapplication.hxx"
+#include "vbaworkbooks.hxx"
+#include "vbaworkbook.hxx"
+#include "vbaworksheets.hxx"
+#include "vbarange.hxx"
+#include "vbawsfunction.hxx"
+#include "vbadialogs.hxx"
+#include "vbawindow.hxx"
+#include "vbawindows.hxx"
+#include "vbaglobals.hxx"
+#include "vbamenubars.hxx"
+#include "tabvwsh.hxx"
+#include "gridwin.hxx"
+#include "vbanames.hxx"
+#include <vbahelper/vbashape.hxx>
+#include "vbatextboxshape.hxx"
+#include "vbaassistant.hxx"
+#include "vbafilesearch.hxx" //liuchen 2009-8-18, add the support of VBA Application.FileSearch
+#include "sc.hrc"
+#include "macromgr.hxx"
+#include "global.hxx" //liuchen 2009-11-26
+#include "scmod.hxx" //liuchen 2009-11-26
+#include "docoptio.hxx" //liuchen 2009-11-26
+#include "appoptio.hxx"
+
+#include <osl/file.hxx>
+
+#include <map>
+
+#include <sfx2/request.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/app.hxx>
+
+#include <comphelper/processfactory.hxx>
+
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+
+#include <docuno.hxx>
+
+#include <basic/sbx.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbuno.hxx>
+#include <basic/sbmeth.hxx>
+
+#include "transobj.hxx"
+#include "convuno.hxx"
+#include "cellsuno.hxx"
+#include "miscuno.hxx"
+#include "unonames.hxx"
+#include "docsh.hxx"
+#include <vbahelper/helperdecl.hxx>
+#include "excelvbahelper.hxx"
+
+#include <basic/sbmeth.hxx>
+#include <basic/sbmod.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sbx.hxx>
+#include <basic/sbxobj.hxx>
+#include <basic/sbuno.hxx>
+//limingl 2009-07-20
+#include "vbafiledialog.hxx"
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::rtl::OUString;
+
+// #TODO is this defined somewhere else?
+#if ( defined UNX ) || ( defined OS2 ) //unix
+#define FILE_PATH_SEPERATOR "/"
+#else // windows
+#define FILE_PATH_SEPERATOR "\\"
+#endif
+
+uno::Any sbxToUnoValue( SbxVariable* pVar );
+
+class ActiveWorkbook : public ScVbaWorkbook
+{
+protected:
+ virtual uno::Reference< frame::XModel > getModel()
+ {
+ return getCurrentExcelDoc(mxContext);
+ }
+public:
+ ActiveWorkbook( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext) : ScVbaWorkbook( xParent, xContext ){}
+};
+
+ScVbaApplication::ScVbaApplication( const uno::Reference<uno::XComponentContext >& xContext ) :
+ ScVbaApplication_BASE( xContext ),
+ m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ),
+ m_bDisplayAlerts( sal_True ),
+ m_bEnableEvents( sal_True )
+{
+}
+
+ScVbaApplication::~ScVbaApplication()
+{
+}
+
+SfxObjectShell* ScVbaApplication::GetDocShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException)
+{
+ return static_cast< SfxObjectShell* >( excel::getDocShell( xModel ) );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::getExactName( const ::rtl::OUString& aApproximateName ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XExactName > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ return xWSF->getExactName( aApproximateName );
+}
+
+uno::Reference< beans::XIntrospectionAccess > SAL_CALL
+ScVbaApplication::getIntrospection() throw(css::uno::RuntimeException)
+{
+ uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ return xWSF->getIntrospection();
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::invoke( const ::rtl::OUString& FunctionName, const uno::Sequence< uno::Any >& Params, uno::Sequence< sal_Int16 >& OutParamIndex, uno::Sequence< uno::Any >& OutParam) throw(lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+{
+ /* When calling the functions directly at the Application object, no runtime
+ errors are thrown, but the error is inserted into the return value. */
+ uno::Any aAny;
+ try
+ {
+ uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ aAny = xWSF->invoke( FunctionName, Params, OutParamIndex, OutParam );
+ }
+ catch( uno::Exception& )
+ {
+ aAny <<= script::BasicErrorException( ::rtl::OUString(), uno::Reference< uno::XInterface >(), 1000, ::rtl::OUString() );
+ }
+ return aAny;
+}
+
+void SAL_CALL
+ScVbaApplication::setValue( const ::rtl::OUString& PropertyName, const uno::Any& Value ) throw(beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+{
+ uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ xWSF->setValue( PropertyName, Value );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::getValue( const ::rtl::OUString& PropertyName ) throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ return xWSF->getValue( PropertyName );
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::hasMethod( const ::rtl::OUString& Name ) throw(uno::RuntimeException)
+{
+ uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ return xWSF->hasMethod( Name );
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::hasProperty( const ::rtl::OUString& Name ) throw(uno::RuntimeException)
+{
+ uno::Reference< script::XInvocation > xWSF( new ScVbaWSFunction( this, mxContext ) );
+ return xWSF->hasProperty( Name );
+}
+
+uno::Reference< excel::XWorkbook >
+ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorkbook > xWrkbk;
+ ScDocShell* pShell = excel::getDocShell( getCurrentExcelDoc( mxContext ) );
+ if ( pShell )
+ {
+ String aName;
+ if ( pShell->GetDocument() )
+ {
+ aName = pShell->GetDocument()->GetCodeName();
+ xWrkbk.set( getUnoDocModule( aName, pShell ), uno::UNO_QUERY );
+ // fallback ( e.g. it's possible a new document was created via the api )
+ // in that case the document will not have the appropriate Document Modules
+ // #TODO #FIXME ( needs to be fixes as part of providing support for an overall document
+ // vba mode etc. )
+ if ( !xWrkbk.is() )
+ return new ActiveWorkbook( this, mxContext );
+ }
+ }
+ return xWrkbk;
+}
+
+uno::Reference< excel::XWorkbook > SAL_CALL
+ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorkbook > xWrkbk;
+ ScDocShell* pShell = excel::getDocShell( getThisExcelDoc( mxContext ) );
+ if ( pShell )
+ {
+ String aName;
+ if ( pShell->GetDocument() )
+ {
+ aName = pShell->GetDocument()->GetCodeName();
+ xWrkbk.set( getUnoDocModule( aName, pShell ), uno::UNO_QUERY );
+ // fallback ( e.g. it's possible a new document was created via the api )
+ // in that case the document will not have the appropriate Document Modules
+ // #TODO #FIXME ( needs to be fixes as part of providing support for an overall document
+ // vba mode etc. )
+ if ( !xWrkbk.is() )
+ return new ActiveWorkbook( this, mxContext );
+ }
+ }
+ return xWrkbk;
+}
+
+uno::Reference< XAssistant > SAL_CALL
+ScVbaApplication::getAssistant() throw (uno::RuntimeException)
+{
+ return uno::Reference< XAssistant >( new ScVbaAssistant( this, mxContext ) );
+}
+
+//liuchen 2009-8-18, add support of VBA Application.FileSearch
+uno::Reference< XFileSearch > SAL_CALL
+ScVbaApplication::getFileSearch() throw (uno::RuntimeException)
+{
+ if (! m_xFileSearch.get() )
+ {
+ m_xFileSearch = uno::Reference< XFileSearch >( new ScVbaFileSearch( this, uno::Reference< XHelperInterface >( this ), mxContext ) );
+ }
+
+ return m_xFileSearch;
+}
+//liuchen
+
+uno::Any SAL_CALL
+ScVbaApplication::getSelection() throw (uno::RuntimeException)
+{
+ OSL_TRACE("** ScVbaApplication::getSelection() ** ");
+ uno::Reference< frame::XModel > xModel( getCurrentDocument() );
+
+ Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), UNO_QUERY_THROW );
+ Reference< beans::XPropertySet > xPropSet( xSelSupp, UNO_QUERY_THROW );
+ OUString aPropName = OUString::createFromAscii( SC_UNO_FILTERED_RANGE_SELECTION );
+ uno::Any aOldVal = xPropSet->getPropertyValue( aPropName );
+ uno::Any any;
+ any <<= sal_False;
+ xPropSet->setPropertyValue( aPropName, any );
+ uno::Reference< uno::XInterface > aSelection = ScUnoHelpFunctions::AnyToInterface(
+ xSelSupp->getSelection() );
+ xPropSet->setPropertyValue( aPropName, aOldVal );
+
+ if (!aSelection.is())
+ {
+ throw uno::RuntimeException(
+ rtl::OUString::createFromAscii("failed to obtain current selection"),
+ uno::Reference< uno::XInterface >() );
+ }
+
+ uno::Reference< lang::XServiceInfo > xServiceInfo( aSelection, uno::UNO_QUERY_THROW );
+ rtl::OUString sImplementationName = xServiceInfo->getImplementationName();
+
+ if( sImplementationName.equalsIgnoreAsciiCaseAscii("com.sun.star.drawing.SvxShapeCollection") )
+ {
+ uno::Reference< drawing::XShapes > xShapes( aSelection, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XShape > xShape( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
+ // if ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape
+ // and the uno object implements the com.sun.star.drawing.Text service
+ // return a textboxshape object
+ if ( ScVbaShape::getType( xShape ) == office::MsoShapeType::msoAutoShape )
+ {
+ uno::Reference< lang::XServiceInfo > xShapeServiceInfo( xShape, uno::UNO_QUERY_THROW );
+ if ( xShapeServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.drawing.Text" ) ) ) )
+ {
+ return uno::makeAny( uno::Reference< msforms::XTextBoxShape >(new ScVbaTextBoxShape( mxContext, xShape, xShapes, xModel ) ) );
+ }
+ }
+ return uno::makeAny( uno::Reference< msforms::XShape >(new ScVbaShape( this, mxContext, xShape, xShapes, xModel, ScVbaShape::getType( xShape ) ) ) );
+ }
+ else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRange")) ||
+ xServiceInfo->supportsService( rtl::OUString::createFromAscii("com.sun.star.sheet.SheetCellRanges")))
+ {
+ uno::Reference< table::XCellRange > xRange( aSelection, ::uno::UNO_QUERY);
+ if ( !xRange.is() )
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( aSelection, ::uno::UNO_QUERY);
+ if ( xRanges.is() )
+ return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges ) ) );
+
+ }
+ return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange ) ) );
+ }
+ else
+ {
+ throw uno::RuntimeException( sImplementationName + rtl::OUString::createFromAscii(" not supported"), uno::Reference< uno::XInterface >() );
+ }
+}
+
+uno::Reference< excel::XRange >
+ScVbaApplication::getActiveCell() throw (uno::RuntimeException )
+{
+ uno::Reference< sheet::XSpreadsheetView > xView( getCurrentDocument()->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xView->getActiveSheet(), ::uno::UNO_QUERY_THROW);
+ ScTabViewShell* pViewShell = excel::getCurrentBestViewShell(mxContext);
+ if ( !pViewShell )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() );
+ ScViewData* pTabView = pViewShell->GetViewData();
+ if ( !pTabView )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewData available"), uno::Reference< uno::XInterface >() );
+
+ sal_Int32 nCursorX = pTabView->GetCurX();
+ sal_Int32 nCursorY = pTabView->GetCurY();
+
+ uno::Reference< XHelperInterface > xParent( excel::getUnoSheetModuleObj( xRange ), uno::UNO_QUERY_THROW );
+ return new ScVbaRange( xParent, mxContext, xRange->getCellRangeByPosition( nCursorX, nCursorY, nCursorX, nCursorY ) );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Workbooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCollection > xWorkBooks( new ScVbaWorkbooks( this, mxContext ) );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ {
+ // void then somebody did Workbooks.something in vba
+ return uno::Any( xWorkBooks );
+ }
+
+ return uno::Any ( xWorkBooks->Item( aIndex, uno::Any() ) );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY );
+ uno::Any result;
+ if ( xWorkbook.is() )
+ result = xWorkbook->Worksheets( aIndex );
+
+ else
+ // Fixme - check if this is reasonable/desired behavior
+ throw uno::RuntimeException( rtl::OUString::createFromAscii(
+ "No ActiveWorkBook available" ), uno::Reference< uno::XInterface >() );
+
+ return result;
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::WorksheetFunction( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return uno::makeAny( uno::Reference< script::XInvocation >( new ScVbaWSFunction( this, mxContext ) ) );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
+{
+ // #TODO Evaluate allows other things to be evaluated, e.g. functions
+ // I think ( like SIN(3) etc. ) need to investigate that
+ // named Ranges also? e.g. [MyRange] if so need a list of named ranges
+ uno::Any aVoid;
+ return uno::Any( getActiveWorkbook()->getActiveSheet()->Range( uno::Any( Name ), aVoid ) );
+}
+
+uno::Any
+ScVbaApplication::Dialogs( const uno::Any &aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XDialogs > xDialogs( new ScVbaDialogs( uno::Reference< XHelperInterface >( this ), mxContext, getCurrentDocument() ) );
+ if( !aIndex.hasValue() )
+ return uno::Any( xDialogs );
+ return uno::Any( xDialogs->Item( aIndex ) );
+}
+
+uno::Reference< excel::XWindow > SAL_CALL
+ScVbaApplication::getActiveWindow() throw (uno::RuntimeException)
+{
+ // #FIXME sofar can't determine Parent
+ uno::Reference< frame::XModel > xModel = getCurrentDocument();
+ ScVbaWindow* pWin = new ScVbaWindow( uno::Reference< XHelperInterface >(), mxContext, xModel );
+ uno::Reference< excel::XWindow > xWin( pWin );
+ return xWin;
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::getCutCopyMode() throw (uno::RuntimeException)
+{
+ uno::Any result;
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( NULL );
+ ScDocument* pDoc = pOwnClip ? pOwnClip->GetDocument() : NULL;
+ if ( pDoc )
+ {
+ if ( pDoc->IsCutMode() )
+ {
+ result <<= excel::XlCutCopyMode::xlCut;
+ }
+ else
+ {
+ result <<= excel::XlCutCopyMode::xlCopy;
+ }
+ }
+ else
+ {
+ result <<= sal_False;
+ }
+ return result;
+}
+
+void SAL_CALL
+ScVbaApplication::setCutCopyMode( const uno::Any& _cutcopymode ) throw (uno::RuntimeException)
+{
+ // According to Excel's behavior, no matter what is the value of _cutcopymode, always releases the clip object.
+ sal_Bool bCutCopyMode = sal_False;
+ if ( ( _cutcopymode >>= bCutCopyMode ) )
+ {
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( NULL );
+ if ( pOwnClip )
+ {
+ pOwnClip->ObjectReleased();
+ ScTabViewShell* pTabViewShell = excel::getBestViewShell( getCurrentDocument() );
+ if ( pTabViewShell )
+ {
+ ScViewData* pView = pTabViewShell->GetViewData();
+ Window* pWindow = pView ? pView->GetActiveWin() : NULL;
+ if ( pWindow )
+ {
+ Reference< datatransfer::clipboard::XClipboard > xClipboard = pWindow->GetClipboard();
+ Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
+ if ( xClipboard.is() )
+ {
+ xClipboard->setContents( NULL, NULL );
+ if ( xFlushableClipboard.is() )
+ {
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ try
+ {
+ xFlushableClipboard->flushClipboard();
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ Application::AcquireSolarMutex( nRef );
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::getStatusBar() throw (uno::RuntimeException)
+{
+ return uno::makeAny( !getDisplayStatusBar() );
+}
+
+void SAL_CALL
+ScVbaApplication::setStatusBar( const uno::Any& _statusbar ) throw (uno::RuntimeException)
+{
+ rtl::OUString sText;
+ sal_Bool bDefault = sal_False;
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< task::XStatusIndicatorSupplier > xStatusIndicatorSupplier( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< task::XStatusIndicator > xStatusIndicator( xStatusIndicatorSupplier->getStatusIndicator(), uno::UNO_QUERY_THROW );
+ if( _statusbar >>= sText )
+ {
+ setDisplayStatusBar( sal_True );
+ xStatusIndicator->start( sText, 100 );
+ //xStatusIndicator->setText( sText );
+ }
+ else if( _statusbar >>= bDefault )
+ {
+ if( bDefault == sal_False )
+ {
+ xStatusIndicator->end();
+ setDisplayStatusBar( sal_True );
+ }
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid prarameter. It should be a string or False" ),
+ uno::Reference< uno::XInterface >() );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaApplication::getCalculation() throw (uno::RuntimeException)
+{
+ uno::Reference<sheet::XCalculatable> xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
+ if(xCalc->isAutomaticCalculationEnabled())
+ return excel::XlCalculation::xlCalculationAutomatic;
+ else
+ return excel::XlCalculation::xlCalculationManual;
+}
+
+void SAL_CALL
+ScVbaApplication::setCalculation( ::sal_Int32 _calculation ) throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XCalculatable > xCalc(getCurrentDocument(), uno::UNO_QUERY_THROW);
+ switch(_calculation)
+ {
+ case excel::XlCalculation::xlCalculationManual:
+ xCalc->enableAutomaticCalculation(sal_False);
+ break;
+ case excel::XlCalculation::xlCalculationAutomatic:
+ case excel::XlCalculation::xlCalculationSemiautomatic:
+ xCalc->enableAutomaticCalculation(sal_True);
+ break;
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWindows > xWindows( new ScVbaWindows( this, mxContext ) );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ return uno::Any( xWindows );
+ return uno::Any( xWindows->Item( aIndex, uno::Any() ) );
+}
+void SAL_CALL
+ScVbaApplication::wait( double time ) throw (uno::RuntimeException)
+{
+ StarBASIC* pBasic = SFX_APP()->GetBasic();
+ SFX_APP()->EnterBasicCall();
+ SbxArrayRef aArgs = new SbxArray;
+ SbxVariableRef aRef = new SbxVariable;
+ aRef->PutDouble( time );
+ aArgs->Put( aRef, 1 );
+ SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("WaitUntil") ), SbxCLASS_METHOD );
+
+ if ( pMeth )
+ {
+ pMeth->SetParameters( aArgs );
+ SbxVariableRef refTemp = pMeth;
+ // forces a broadcast
+ SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth));
+ }
+ SFX_APP()->LeaveBasicCall();
+
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XRange > xVbRange = ScVbaRange::ApplicationRange( mxContext, Cell1, Cell2 );
+ return uno::makeAny( xVbRange );
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Names( const css::uno::Any& aIndex ) throw ( uno::RuntimeException )
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XNamedRanges > xNamedRanges( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("NamedRanges")) , uno::UNO_QUERY_THROW );
+ css::uno::Reference< excel::XNames > xNames ( new ScVbaNames( this , mxContext , xNamedRanges , xModel ) );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ {
+ return uno::Any( xNames );
+}
+ return uno::Any( xNames->Item( aIndex, uno::Any() ) );
+}
+
+
+uno::Reference< excel::XWorksheet > SAL_CALL
+ScVbaApplication::getActiveSheet() throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorksheet > result;
+ uno::Reference< excel::XWorkbook > xWorkbook( getActiveWorkbook(), uno::UNO_QUERY );
+ if ( xWorkbook.is() )
+ {
+ uno::Reference< excel::XWorksheet > xWorksheet(
+ xWorkbook->getActiveSheet(), uno::UNO_QUERY );
+ if ( xWorksheet.is() )
+ {
+ result = xWorksheet;
+ }
+ }
+
+ if ( !result.is() )
+ {
+ // Fixme - check if this is reasonable/desired behavior
+ throw uno::RuntimeException( rtl::OUString::createFromAscii(
+ "No activeSheet available" ), uno::Reference< uno::XInterface >() );
+ }
+ return result;
+
+}
+
+/*******************************************************************************
+ * In msdn:
+ * Reference Optional Variant. The destination. Can be a Range
+ * object, a string that contains a cell reference in R1C1-style notation,
+ * or a string that contains a Visual Basic procedure name.
+ * Scroll Optional Variant. True to scrol, False to not scroll through
+ * the window. The default is False.
+ * Parser is split to three parts, Range, R1C1 string and procedure name.
+ * by test excel, it seems Scroll no effect. ???
+*******************************************************************************/
+void SAL_CALL
+ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) throw (uno::RuntimeException)
+{
+ //test Scroll is a boolean
+ sal_Bool bScroll = sal_False;
+ //R1C1-style string or a string of procedure name.
+
+ if( Scroll.hasValue() )
+ {
+ sal_Bool aScroll = sal_False;
+ if( Scroll >>= aScroll )
+ {
+ bScroll = aScroll;
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "sencond parameter should be boolean" ),
+ uno::Reference< uno::XInterface >() );
+ }
+
+ rtl::OUString sRangeName;
+ if( Reference >>= sRangeName )
+ {
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
+ xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xDoc = xSpreadsheet->getActiveSheet();
+
+ ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext );
+ ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow();
+ try
+ {
+ uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName(
+ mxContext, sRangeName, excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
+
+ if( bScroll )
+ {
+ xVbaSheetRange->Select();
+ uno::Reference< excel::XWindow > xWindow = getActiveWindow();
+ ScSplitPos eWhich = pShell->GetViewData()->GetActivePart();
+ sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich));
+ sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich));
+ xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaSheetRange->getRow() - 1) ),
+ uno::makeAny( (sal_Int16)nValueY ),
+ uno::makeAny( (sal_Int16)(xVbaSheetRange->getColumn() - 1) ),
+ uno::makeAny( (sal_Int16)nValueX ) );
+ gridWindow->GrabFocus();
+ }
+ else
+ {
+ xVbaSheetRange->Select();
+ gridWindow->GrabFocus();
+ }
+ }
+ catch( uno::RuntimeException )
+ {
+ //maybe this should be a procedure name
+ //TODO for procedure name
+ //browse::XBrowseNodeFactory is a singlton. OUString::createFromAscii( "/singletons/com.sun.star.script.browse.theBrowseNodeFactory")
+ //and the createView( browse::BrowseNodeFactoryViewTypes::MACROSELECTOR ) to get a root browse::XBrowseNode.
+ //for query XInvocation interface.
+ //but how to directly get the XInvocation?
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference for range name, it should be procedure name" ),
+ uno::Reference< uno::XInterface >() );
+ }
+ return;
+ }
+ uno::Reference< excel::XRange > xRange;
+ if( Reference >>= xRange )
+ {
+ uno::Reference< excel::XRange > xVbaRange( Reference, uno::UNO_QUERY );
+ ScTabViewShell* pShell = excel::getCurrentBestViewShell( mxContext );
+ ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow();
+ if ( xVbaRange.is() )
+ {
+ //TODO bScroll should be using, In this time, it doesenot have effection
+ if( bScroll )
+ {
+ xVbaRange->Select();
+ uno::Reference< excel::XWindow > xWindow = getActiveWindow();
+ ScSplitPos eWhich = pShell->GetViewData()->GetActivePart();
+ sal_Int32 nValueX = pShell->GetViewData()->GetPosX(WhichH(eWhich));
+ sal_Int32 nValueY = pShell->GetViewData()->GetPosY(WhichV(eWhich));
+ xWindow->SmallScroll( uno::makeAny( (sal_Int16)(xVbaRange->getRow() - 1) ),
+ uno::makeAny( (sal_Int16)nValueY ),
+ uno::makeAny( (sal_Int16)(xVbaRange->getColumn() - 1) ),
+ uno::makeAny( (sal_Int16)nValueX ) );
+ gridWindow->GrabFocus();
+ }
+ else
+ {
+ xVbaRange->Select();
+ gridWindow->GrabFocus();
+ }
+ }
+ return;
+ }
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "invalid reference or name" ),
+ uno::Reference< uno::XInterface >() );
+}
+
+sal_Int32 SAL_CALL
+ScVbaApplication::getCursor() throw (uno::RuntimeException)
+{
+ sal_Int32 nPointerStyle = getPointerStyle(getCurrentDocument());
+
+ switch( nPointerStyle )
+ {
+ case POINTER_ARROW:
+ return excel::XlMousePointer::xlNorthwestArrow;
+ case POINTER_NULL:
+ return excel::XlMousePointer::xlDefault;
+ case POINTER_WAIT:
+ return excel::XlMousePointer::xlWait;
+ case POINTER_TEXT:
+ return excel::XlMousePointer::xlIBeam;
+ default:
+ return excel::XlMousePointer::xlDefault;
+ }
+}
+
+void SAL_CALL
+ScVbaApplication::setCursor( sal_Int32 _cursor ) throw (uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ switch( _cursor )
+ {
+ case excel::XlMousePointer::xlNorthwestArrow:
+ {
+ const Pointer& rPointer( POINTER_ARROW );
+ setCursorHelper( xModel, rPointer, sal_False );
+ break;
+ }
+ case excel::XlMousePointer::xlWait:
+ case excel::XlMousePointer::xlIBeam:
+ {
+ const Pointer& rPointer( static_cast< PointerStyle >( _cursor ) );
+ //It will set the edit window, toobar and statusbar's mouse pointer.
+ setCursorHelper( xModel, rPointer, sal_True );
+ break;
+ }
+ case excel::XlMousePointer::xlDefault:
+ {
+ const Pointer& rPointer( POINTER_NULL );
+ setCursorHelper( xModel, rPointer, sal_False );
+ break;
+ }
+ default:
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Unknown value for Cursor pointer")), uno::Reference< uno::XInterface >() );
+ // TODO: isn't this a flaw in the API? It should be allowed to throw an
+ // IllegalArgumentException, or so
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+// #TODO perhaps we should switch the return type depending of the filter
+// type, e.g. return Calc for Calc and Excel if its an imported doc
+rtl::OUString SAL_CALL
+ScVbaApplication::getName() throw (uno::RuntimeException)
+{
+ static rtl::OUString appName( RTL_CONSTASCII_USTRINGPARAM("Microsoft Excel" ) );
+ return appName;
+}
+
+// #TODO #FIXME get/setDisplayAlerts are just stub impl
+// here just the status of the switch is set
+// the function that throws an error message needs to
+// evaluate this switch in order to know whether it has to disable the
+// error message thrown by OpenOffice
+
+void SAL_CALL
+ScVbaApplication::setDisplayAlerts(sal_Bool displayAlerts) throw (uno::RuntimeException)
+{
+ m_bDisplayAlerts = displayAlerts;
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException)
+{
+ return m_bDisplayAlerts;
+}
+
+void SAL_CALL
+ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException)
+{
+ m_bEnableEvents = bEnable;
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getEnableEvents() throw (uno::RuntimeException)
+{
+ return m_bEnableEvents;
+}
+
+sal_Bool SAL_CALL
+ScVbaApplication::getVisible() throw (uno::RuntimeException)
+{
+ sal_Bool bVisible = sal_True;
+ return bVisible;
+}
+
+void SAL_CALL
+ScVbaApplication::setVisible(sal_Bool /*bVisible*/) throw (uno::RuntimeException)
+{
+}
+
+//liuchen 2009-11-25 add the support of Excel VBA Application.Iteration
+//The Excel Iteration option is global and unique, but in Symphony there is an Iteration property in ScModule and one in every ScDocument,
+//so the set method will set all the Iteration properties
+sal_Bool SAL_CALL
+ScVbaApplication::getIteration() throw (uno::RuntimeException)
+{
+ ScModule* pScMod = SC_MOD();
+ ScDocOptions aDocOpt = pScMod->GetDocOptions();
+
+ return aDocOpt.IsIter();
+}
+
+void SAL_CALL
+ScVbaApplication::setIteration(sal_Bool bIteration) throw (uno::RuntimeException)
+{
+ ScModule* pScMod = SC_MOD();
+ ScDocOptions& aDocOpt = const_cast< ScDocOptions& > (pScMod->GetDocOptions());
+ aDocOpt.SetIter( bIteration );
+
+ uno::Any aIteration;
+ aIteration <<= bIteration;
+
+ OUString aPropName = OUString::createFromAscii( "IsIterationEnabled" );
+
+ uno::Reference< XCollection > xWorkbooks( new ScVbaWorkbooks( this, mxContext ) );
+ sal_Int32 nCount = xWorkbooks->getCount();
+
+ for (sal_Int32 i = 1; i <= nCount; i++)
+ {
+ uno::Reference< ooo::vba::excel::XWorkbook > xWorkbook;
+ uno::Any aWorkbook = xWorkbooks->Item(uno::makeAny(i), uno::Any());
+ aWorkbook >>= xWorkbook;
+ ScVbaWorkbook* pWorkbook = static_cast< ScVbaWorkbook* > ( xWorkbook.get() );
+
+ uno::Reference< frame::XModel > xModel( pWorkbook->getDocModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
+ xPropertySet->setPropertyValue( aPropName, aIteration );
+ }
+}
+//liuchen 2009-11-25 end
+
+//liuchen 2009-11-26 add the support of Excel VBA Application.EnableCancelKey
+sal_Int32 SAL_CALL
+ScVbaApplication::getEnableCancelKey() throw (uno::RuntimeException)
+{
+ return ooo::vba::excel::XlEnableCancelKey::xlDisabled;
+}
+
+void SAL_CALL
+ScVbaApplication::setEnableCancelKey(sal_Int32 /*lEnableCancelKey*/) throw (uno::RuntimeException)
+{
+}
+//liuchen 2009-11-26 end
+
+sal_Int32 SAL_CALL ScVbaApplication::getSheetsInNewWorkbook() throw (uno::RuntimeException)
+{
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ return rAppOpt.GetTabCountInNewSpreadsheet();
+}
+
+void SAL_CALL ScVbaApplication::setSheetsInNewWorkbook( sal_Int32 SheetsInNewWorkbook ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( SheetsInNewWorkbook < 1 || SheetsInNewWorkbook > MAXTAB )
+ {
+ DebugHelper::exception( OUString::createFromAscii("The number must be between 1 and 255"), uno::Exception(), SbERR_METHOD_FAILED, OUString() );
+ }
+ else
+ {
+ ScAppOptions& rAppOpt = const_cast< ScAppOptions& >(SC_MOD()->GetAppOptions());
+ rAppOpt.SetTabCountInNewSpreadsheet( SheetsInNewWorkbook );
+ }
+}
+
+void SAL_CALL
+ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException )
+{
+ uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCalculatable > xCalculatable( getCurrentDocument(), uno::UNO_QUERY_THROW );
+ xCalculatable->calculateAll();
+}
+
+uno::Reference< beans::XPropertySet > lcl_getPathSettingsService( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException )
+{
+ static uno::Reference< beans::XPropertySet > xPathSettings;
+ if ( !xPathSettings.is() )
+ {
+ uno::Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ xPathSettings.set( xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.util.PathSettings"), xContext), uno::UNO_QUERY_THROW );
+ }
+ return xPathSettings;
+}
+rtl::OUString ScVbaApplication::getOfficePath( const rtl::OUString& _sPathType ) throw ( uno::RuntimeException )
+{
+ rtl::OUString sRetPath;
+ uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext );
+ try
+ {
+ rtl::OUString sUrl;
+ xProps->getPropertyValue( _sPathType ) >>= sUrl;
+
+ // if its a list of paths then use the last one
+ sal_Int32 nIndex = sUrl.lastIndexOf( ';' ) ;
+ if ( nIndex > 0 )
+ sUrl = sUrl.copy( nIndex + 1 );
+ ::osl::File::getSystemPathFromFileURL( sUrl, sRetPath );
+ }
+ catch (uno::Exception&)
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return sRetPath;
+}
+void SAL_CALL
+ScVbaApplication::setDefaultFilePath( const ::rtl::OUString& DefaultFilePath ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getPathSettingsService( mxContext );
+ rtl::OUString aURL;
+ osl::FileBase::getFileURLFromSystemPath( DefaultFilePath, aURL );
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")), uno::makeAny( aURL ) );
+
+
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::getDefaultFilePath( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Work")));
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::LibraryPath( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Basic")));
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::TemplatesPath( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return getOfficePath( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Template")));
+}
+
+::rtl::OUString SAL_CALL
+ScVbaApplication::PathSeparator( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ static rtl::OUString sPathSep( RTL_CONSTASCII_USTRINGPARAM( FILE_PATH_SEPERATOR ) );
+ return sPathSep;
+}
+
+// ----------------------------------------------------------------------------
+// Helpers for Intersect and Union
+
+namespace {
+
+typedef ::std::list< ScRange > ListOfScRange;
+
+/** Appends all ranges of a VBA Range object in the passed Any to the list of ranges. */
+void lclAddToListOfScRange( ListOfScRange& rList, const uno::Any& rArg )
+ throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if( rArg.hasValue() )
+ {
+ uno::Reference< excel::XRange > xRange( rArg, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xCol( xRange->Areas( uno::Any() ), uno::UNO_QUERY_THROW );
+ for( sal_Int32 nIdx = 1, nCount = xCol->getCount(); nIdx <= nCount; ++nIdx )
+ {
+ uno::Reference< excel::XRange > xAreaRange( xCol->Item( uno::Any( nIdx ), uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( xAreaRange->getCellRange(), uno::UNO_QUERY_THROW );
+ ScRange aScRange;
+ ScUnoConversion::FillScRange( aScRange, xAddressable->getRangeAddress() );
+ rList.push_back( aScRange );
+ }
+ }
+}
+
+/** Returns true, if the passed ranges can be expressed by a single range. The
+ new range will be contained in r1 then, the range r2 can be removed. */
+bool lclTryJoin( ScRange& r1, const ScRange& r2 )
+{
+ // 1) r2 is completely inside r1
+ if( r1.In( r2 ) )
+ return true;
+
+ // 2) r1 is completely inside r2
+ if( r2.In( r1 ) )
+ {
+ r1 = r2;
+ return true;
+ }
+
+ SCCOL n1L = r1.aStart.Col();
+ SCCOL n1R = r1.aEnd.Col();
+ SCROW n1T = r1.aStart.Row();
+ SCROW n1B = r1.aEnd.Row();
+ SCCOL n2L = r2.aStart.Col();
+ SCCOL n2R = r2.aEnd.Col();
+ SCROW n2T = r2.aStart.Row();
+ SCROW n2B = r2.aEnd.Row();
+
+ // 3) r1 and r2 have equal upper and lower border
+ if( (n1T == n2T) && (n1B == n2B) )
+ {
+ // check that r1 overlaps or touches r2
+ if( ((n1L < n2L) && (n2L - 1 <= n1R)) || ((n2L < n1L) && (n1L - 1 <= n2R)) )
+ {
+ r1.aStart.SetCol( ::std::min( n1L, n2L ) );
+ r1.aEnd.SetCol( ::std::max( n1R, n2R ) );
+ return true;
+ }
+ return false;
+ }
+
+ // 4) r1 and r2 have equal left and right border
+ if( (n1L == n2L) && (n1R == n2R) )
+ {
+ // check that r1 overlaps or touches r2
+ if( ((n1T < n2T) && (n2T + 1 <= n1B)) || ((n2T < n1T) && (n1T + 1 <= n2B)) )
+ {
+ r1.aStart.SetRow( ::std::min( n1T, n2T ) );
+ r1.aEnd.SetRow( ::std::max( n1B, n2B ) );
+ return true;
+ }
+ return false;
+ }
+
+ // 5) cannot join these ranges
+ return false;
+}
+
+/** Strips out ranges that are contained by other ranges, joins ranges that can be joined
+ together (aligned borders, e.g. A4:D10 and B4:E10 would be combined to A4:E10. */
+void lclJoinRanges( ListOfScRange& rList )
+{
+ ListOfScRange::iterator aOuterIt = rList.begin();
+ while( aOuterIt != rList.end() )
+ {
+ bool bAnyErased = false; // true = any range erased from rList
+ ListOfScRange::iterator aInnerIt = rList.begin();
+ while( aInnerIt != rList.end() )
+ {
+ bool bInnerErased = false; // true = aInnerIt erased from rList
+ // do not compare a range with itself
+ if( (aOuterIt != aInnerIt) && lclTryJoin( *aOuterIt, *aInnerIt ) )
+ {
+ // aOuterIt points to joined range, aInnerIt will be removed
+ aInnerIt = rList.erase( aInnerIt );
+ bInnerErased = bAnyErased = true;
+ }
+ /* If aInnerIt has been erased from rList, it already points to
+ the next element (return value of list::erase()). */
+ if( !bInnerErased )
+ ++aInnerIt;
+ }
+ // if any range has been erased, repeat outer loop with the same range
+ if( !bAnyErased )
+ ++aOuterIt;
+ }
+}
+
+/** Intersects the passed list with all ranges of a VBA Range object in the passed Any. */
+void lclIntersectRanges( ListOfScRange& rList, const uno::Any& rArg )
+ throw (script::BasicErrorException, uno::RuntimeException)
+{
+ // extract the ranges from the passed argument, will throw on invalid data
+ ListOfScRange aList2;
+ lclAddToListOfScRange( aList2, rArg );
+ // do nothing, if the passed list is already empty
+ if( !rList.empty() && !aList2.empty() )
+ {
+ // save original list in a local
+ ListOfScRange aList1;
+ aList1.swap( rList );
+ // join ranges from passed argument
+ lclJoinRanges( aList2 );
+ // calculate intersection of the ranges in both lists
+ for( ListOfScRange::const_iterator aOuterIt = aList1.begin(), aOuterEnd = aList1.end(); aOuterIt != aOuterEnd; ++aOuterIt )
+ {
+ for( ListOfScRange::const_iterator aInnerIt = aList2.begin(), aInnerEnd = aList2.end(); aInnerIt != aInnerEnd; ++aInnerIt )
+ {
+ if( aOuterIt->Intersects( *aInnerIt ) )
+ {
+ ScRange aIsectRange(
+ Max( aOuterIt->aStart.Col(), aInnerIt->aStart.Col() ),
+ Max( aOuterIt->aStart.Row(), aInnerIt->aStart.Row() ),
+ Max( aOuterIt->aStart.Tab(), aInnerIt->aStart.Tab() ),
+ Min( aOuterIt->aEnd.Col(), aInnerIt->aEnd.Col() ),
+ Min( aOuterIt->aEnd.Row(), aInnerIt->aEnd.Row() ),
+ Min( aOuterIt->aEnd.Tab(), aInnerIt->aEnd.Tab() ) );
+ rList.push_back( aIsectRange );
+ }
+ }
+ }
+ // again, join the result ranges
+ lclJoinRanges( rList );
+ }
+}
+
+/** Creates a VBA Range object from the passed list of ranges. */
+uno::Reference< excel::XRange > lclCreateVbaRange(
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const ListOfScRange& rList ) throw (uno::RuntimeException)
+{
+ ScDocShell* pDocShell = excel::getDocShell( rxModel );
+ if( !pDocShell ) throw uno::RuntimeException();
+
+ ScRangeList aCellRanges;
+ for( ListOfScRange::const_iterator aIt = rList.begin(), aEnd = rList.end(); aIt != aEnd; ++aIt )
+ aCellRanges.Append( *aIt );
+
+ if( aCellRanges.Count() == 1 )
+ {
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) );
+ return new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), rxContext, xRange );
+ }
+ if( aCellRanges.Count() > 1 )
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) );
+ return new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), rxContext, xRanges );
+ }
+ return 0;
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Intersect(
+ const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2,
+ const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6,
+ const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10,
+ const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14,
+ const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18,
+ const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22,
+ const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26,
+ const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 )
+ throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if( !rArg1.is() || !rArg2.is() )
+ DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
+
+ // initialize the result list with 1st parameter, join its ranges together
+ ListOfScRange aList;
+ lclAddToListOfScRange( aList, uno::Any( rArg1 ) );
+ lclJoinRanges( aList );
+
+ // process all other parameters, this updates the list with intersection
+ lclIntersectRanges( aList, uno::Any( rArg2 ) );
+ lclIntersectRanges( aList, rArg3 );
+ lclIntersectRanges( aList, rArg4 );
+ lclIntersectRanges( aList, rArg5 );
+ lclIntersectRanges( aList, rArg6 );
+ lclIntersectRanges( aList, rArg7 );
+ lclIntersectRanges( aList, rArg8 );
+ lclIntersectRanges( aList, rArg9 );
+ lclIntersectRanges( aList, rArg10 );
+ lclIntersectRanges( aList, rArg11 );
+ lclIntersectRanges( aList, rArg12 );
+ lclIntersectRanges( aList, rArg13 );
+ lclIntersectRanges( aList, rArg14 );
+ lclIntersectRanges( aList, rArg15 );
+ lclIntersectRanges( aList, rArg16 );
+ lclIntersectRanges( aList, rArg17 );
+ lclIntersectRanges( aList, rArg18 );
+ lclIntersectRanges( aList, rArg19 );
+ lclIntersectRanges( aList, rArg20 );
+ lclIntersectRanges( aList, rArg21 );
+ lclIntersectRanges( aList, rArg22 );
+ lclIntersectRanges( aList, rArg23 );
+ lclIntersectRanges( aList, rArg24 );
+ lclIntersectRanges( aList, rArg25 );
+ lclIntersectRanges( aList, rArg26 );
+ lclIntersectRanges( aList, rArg27 );
+ lclIntersectRanges( aList, rArg28 );
+ lclIntersectRanges( aList, rArg29 );
+ lclIntersectRanges( aList, rArg30 );
+
+ // create the VBA Range object
+ return lclCreateVbaRange( mxContext, getCurrentDocument(), aList );
+}
+
+uno::Reference< excel::XRange > SAL_CALL ScVbaApplication::Union(
+ const uno::Reference< excel::XRange >& rArg1, const uno::Reference< excel::XRange >& rArg2,
+ const uno::Any& rArg3, const uno::Any& rArg4, const uno::Any& rArg5, const uno::Any& rArg6,
+ const uno::Any& rArg7, const uno::Any& rArg8, const uno::Any& rArg9, const uno::Any& rArg10,
+ const uno::Any& rArg11, const uno::Any& rArg12, const uno::Any& rArg13, const uno::Any& rArg14,
+ const uno::Any& rArg15, const uno::Any& rArg16, const uno::Any& rArg17, const uno::Any& rArg18,
+ const uno::Any& rArg19, const uno::Any& rArg20, const uno::Any& rArg21, const uno::Any& rArg22,
+ const uno::Any& rArg23, const uno::Any& rArg24, const uno::Any& rArg25, const uno::Any& rArg26,
+ const uno::Any& rArg27, const uno::Any& rArg28, const uno::Any& rArg29, const uno::Any& rArg30 )
+ throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if( !rArg1.is() || !rArg2.is() )
+ DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
+
+ ListOfScRange aList;
+ lclAddToListOfScRange( aList, uno::Any( rArg1 ) );
+ lclAddToListOfScRange( aList, uno::Any( rArg2 ) );
+ lclAddToListOfScRange( aList, rArg3 );
+ lclAddToListOfScRange( aList, rArg4 );
+ lclAddToListOfScRange( aList, rArg5 );
+ lclAddToListOfScRange( aList, rArg6 );
+ lclAddToListOfScRange( aList, rArg7 );
+ lclAddToListOfScRange( aList, rArg8 );
+ lclAddToListOfScRange( aList, rArg9 );
+ lclAddToListOfScRange( aList, rArg10 );
+ lclAddToListOfScRange( aList, rArg11 );
+ lclAddToListOfScRange( aList, rArg12 );
+ lclAddToListOfScRange( aList, rArg13 );
+ lclAddToListOfScRange( aList, rArg14 );
+ lclAddToListOfScRange( aList, rArg15 );
+ lclAddToListOfScRange( aList, rArg16 );
+ lclAddToListOfScRange( aList, rArg17 );
+ lclAddToListOfScRange( aList, rArg18 );
+ lclAddToListOfScRange( aList, rArg19 );
+ lclAddToListOfScRange( aList, rArg20 );
+ lclAddToListOfScRange( aList, rArg21 );
+ lclAddToListOfScRange( aList, rArg22 );
+ lclAddToListOfScRange( aList, rArg23 );
+ lclAddToListOfScRange( aList, rArg24 );
+ lclAddToListOfScRange( aList, rArg25 );
+ lclAddToListOfScRange( aList, rArg26 );
+ lclAddToListOfScRange( aList, rArg27 );
+ lclAddToListOfScRange( aList, rArg28 );
+ lclAddToListOfScRange( aList, rArg29 );
+ lclAddToListOfScRange( aList, rArg30 );
+
+ // simply join together all ranges as much as possible, strip out covered ranges etc.
+ lclJoinRanges( aList );
+
+ // create the VBA Range object
+ return lclCreateVbaRange( mxContext, getCurrentDocument(), aList );
+}
+
+void
+ScVbaApplication::Volatile( const uno::Any& aVolatile ) throw ( uno::RuntimeException )
+{
+ sal_Bool bVolatile = sal_True;
+ aVolatile >>= bVolatile;
+ SbMethod* pMeth = StarBASIC::GetActiveMethod();
+ if ( pMeth )
+ {
+ OSL_TRACE("ScVbaApplication::Volatile() In method ->%s<-", rtl::OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ uno::Reference< frame::XModel > xModel( getCurrentDocument() );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ pDoc->GetMacroManager()->SetUserFuncVolatile( pMeth->GetName(), bVolatile);
+ }
+
+// this is bound to break when loading the document
+ return;
+}
+
+::sal_Bool SAL_CALL
+ScVbaApplication::getDisplayFormulaBar() throw ( css::uno::RuntimeException )
+{
+ sal_Bool bRes = sal_False;
+ ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext );
+ if ( pViewShell )
+ {
+ SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE);
+ SfxAllItemSet reqList( SFX_APP()->GetPool() );
+ reqList.Put( sfxFormBar );
+
+ pViewShell->GetState( reqList );
+ const SfxPoolItem *pItem=0;
+ if ( reqList.GetItemState( FID_TOGGLEINPUTLINE, sal_False, &pItem ) == SFX_ITEM_SET )
+ bRes = ((SfxBoolItem*)pItem)->GetValue();
+ }
+ return bRes;
+}
+
+void SAL_CALL
+ScVbaApplication::setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException )
+{
+ ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext );
+ if ( pViewShell && ( _displayformulabar != getDisplayFormulaBar() ) )
+ {
+ SfxBoolItem sfxFormBar( FID_TOGGLEINPUTLINE, _displayformulabar);
+ SfxAllItemSet reqList( SFX_APP()->GetPool() );
+ SfxRequest aReq( FID_TOGGLEINPUTLINE, 0, reqList );
+ pViewShell->Execute( aReq );
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::Caller( const uno::Any& /*aIndex*/ ) throw ( uno::RuntimeException )
+{
+ StarBASIC* pBasic = SFX_APP()->GetBasic();
+ SFX_APP()->EnterBasicCall();
+ SbMethod* pMeth = (SbMethod*)pBasic->GetRtl()->Find( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FuncCaller") ), SbxCLASS_METHOD );
+ uno::Any aRet;
+ if ( pMeth )
+ {
+ SbxVariableRef refTemp = pMeth;
+ // forces a broadcast
+ SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth));
+ OSL_TRACE("pNew has type %d and string value %s", pNew->GetType(), rtl::OUStringToOString( pNew->GetString(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ aRet = sbxToUnoValue( pNew );
+ }
+ SFX_APP()->LeaveBasicCall();
+ return aRet;
+}
+
+//Add by minz@cn.ibm.com. 2009-07-08.
+uno::Any SAL_CALL
+ScVbaApplication::GetOpenFilename(const uno::Any& FileFilter, const uno::Any& FilterIndex, const uno::Any& Title, const uno::Any& ButtonText, const uno::Any& MultiSelect) throw (uno::RuntimeException)
+{
+ uno::Any aRet = uno::makeAny( sal_False );
+ try
+ {
+ const ::rtl::OUString sServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.FilePicker" );
+ uno::Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+ // Set the type of File Picker Dialog: TemplateDescription::FILEOPEN_SIMPLE.
+ uno::Sequence< uno::Any > aDialogType( 1 );
+ aDialogType[0] <<= ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
+ uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xMSF->createInstanceWithArguments( sServiceName, aDialogType ), UNO_QUERY );
+ uno::Reference< ui::dialogs::XFilePicker2 > xFilePicker2( xFilePicker, UNO_QUERY );
+ uno::Reference< ui::dialogs::XFilterManager > xFilterManager( xFilePicker, UNO_QUERY );
+ uno::Reference< ui::dialogs::XExecutableDialog > xExecutableDialog( xFilePicker, UNO_QUERY );
+ uno::Reference< ui::dialogs::XFilePickerControlAccess > xPickerControlAccess( xFilePicker, UNO_QUERY );
+
+ if ( xFilterManager.is() && FileFilter.hasValue() )
+ {
+ sal_Int32 nFilterIndex = 1;
+ if ( FilterIndex.hasValue() )
+ {
+ FilterIndex >>= nFilterIndex;
+ }
+ ::rtl::OUString strFilter;
+ FileFilter >>= strFilter;
+ sal_Int32 nCommaID = 0;
+ sal_Int32 nIndex = 1;
+ do
+ {
+ ::rtl::OUString aFilterTitleToken = strFilter.getToken( 0, ',' , nCommaID );
+ ::rtl::OUString aFilterToken;
+ if ( nCommaID >= 0 )
+ {
+ aFilterToken = strFilter.getToken( 0, ',' , nCommaID );
+ }
+ else if ( nCommaID < 0 && nIndex == 1 )
+ {
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid FileFilter format!" ), uno::Reference< uno::XInterface >() );
+ }
+ xFilterManager->appendFilter( aFilterTitleToken, aFilterToken );
+ if ( nFilterIndex == nIndex )
+ {
+ xFilterManager->setCurrentFilter( aFilterTitleToken );
+ }
+ nIndex++;
+ } while ( nCommaID >= 0 );
+ }
+ if ( xExecutableDialog.is() && Title.hasValue() )
+ {
+ ::rtl::OUString sTitle;
+ Title >>= sTitle;
+ xExecutableDialog->setTitle( sTitle );
+ }
+ if ( xPickerControlAccess.is() && ButtonText.hasValue() )
+ {
+ ::rtl::OUString sButtonText;
+ ButtonText >>= sButtonText;
+ xPickerControlAccess->setLabel( ui::dialogs::CommonFilePickerElementIds::PUSHBUTTON_OK, sButtonText );
+ }
+ sal_Bool bMultiSelect = sal_False;
+ if ( xFilePicker.is() && MultiSelect.hasValue() )
+ {
+ MultiSelect >>= bMultiSelect;
+ xFilePicker->setMultiSelectionMode( bMultiSelect );
+ }
+
+ if ( xFilePicker.is() && xFilePicker->execute() )
+ {
+ sal_Bool bUseXFilePicker2 = sal_False;
+ uno::Reference< lang::XServiceInfo > xServiceInfo( xFilePicker, UNO_QUERY );
+ if ( xServiceInfo.is() )
+ {
+ rtl::OUString sImplName = xServiceInfo->getImplementationName();
+ if ( sImplName.equalsAscii("com.sun.star.comp.fpicker.VistaFileDialog") || sImplName.equalsAscii("com.sun.star.ui.dialogs.SalGtkFilePicker") )
+ {
+ bUseXFilePicker2 = sal_True;
+ }
+ }
+ uno::Sequence< rtl::OUString > aSelectedFiles;
+ if ( bUseXFilePicker2 && xFilePicker2.is() )
+ {
+ // On Linux, XFilePicker->getFiles() always return one selected file although we select more than one file, also on Vista
+ // XFilePicker->getFiles() does not work well too, so we call XFilePicker2->getSelectedFiles() to get selected files.
+ aSelectedFiles = xFilePicker2->getSelectedFiles();
+ }
+ else
+ {
+ // If only one file is selected, the first entry of the sequence contains the complete path/filename in URL format. If multiple files are selected,
+ // the first entry of the sequence contains the path in URL format, and the other entries contains the names of the selected files without path information.
+ uno::Sequence< rtl::OUString > aTmpFiles = xFilePicker->getFiles();
+ aSelectedFiles = aTmpFiles;
+ sal_Int32 iFileCount = aTmpFiles.getLength();
+ if ( iFileCount > 1 )
+ {
+ aSelectedFiles.realloc( iFileCount - 1 );
+ INetURLObject aPath( aTmpFiles[0] );
+ aPath.setFinalSlash();
+ for ( sal_Int32 i = 1; i < iFileCount; i++ )
+ {
+ if ( aTmpFiles[i].indexOf ('/') > 0 || aTmpFiles[i].indexOf ('\\') > 0 )
+ {
+ aSelectedFiles[i - 1] = aTmpFiles[i];
+ }
+ else
+ {
+ if ( i == 1 )
+ aPath.Append( aTmpFiles[i] );
+ else
+ aPath.setName( aTmpFiles[i] );
+ aSelectedFiles[i - 1] = aPath.GetMainURL( INetURLObject::NO_DECODE );
+ }
+ }
+ }
+ }
+
+ sal_Int32 iFileCount = aSelectedFiles.getLength();
+ for ( sal_Int32 i = 0; i < iFileCount; i++ )
+ {
+ INetURLObject aObj( aSelectedFiles[i] );
+ if ( aObj.GetProtocol() == INET_PROT_FILE )
+ {
+ rtl::OUString aTemp = aObj.PathToFileName();
+ aSelectedFiles[i] = aTemp.getLength() > 0 ? aTemp : aSelectedFiles[i];
+ }
+ }
+ if ( bMultiSelect )
+ {
+ aRet = uno::makeAny( aSelectedFiles );
+ }
+ else if ( aSelectedFiles.getLength() > 0 && !bMultiSelect )
+ {
+ aRet = uno::makeAny( aSelectedFiles[0] );
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+
+ return aRet;
+}
+
+//liming 2009-7-17
+::com::sun::star::uno::Reference< ::ooo::vba::XFileDialog > SAL_CALL
+ScVbaApplication::getFileDialog() throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Reference< XFileDialog > xFileDialogs( new ScVbaFileDialog( uno::Reference< XHelperInterface >( this ), mxContext, getCurrentDocument() ) );
+ return xFileDialogs;
+}
+
+typedef std::map< ::rtl::OUString, ::rtl::OUString > FileFilterMap;
+
+//2009-11-06 add by limingl
+uno::Any SAL_CALL
+ScVbaApplication::GetSaveAsFilename( const ::com::sun::star::uno::Any& InitialFilename, const ::com::sun::star::uno::Any& FileFilter, const ::com::sun::star::uno::Any& FilterIndex, const ::com::sun::star::uno::Any& Title, const ::com::sun::star::uno::Any& ButtonText ) throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Any strRet;
+ try
+ {
+ const ::rtl::OUString sServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.FilePicker" );
+ uno::Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+
+ uno::Sequence< uno::Any > aDialogType( 1 );
+ aDialogType[0] <<= ui::dialogs::TemplateDescription::FILESAVE_SIMPLE;
+ uno::Reference< ui::dialogs::XFilePicker > xFilePicker( xMSF->createInstanceWithArguments( sServiceName, aDialogType ), UNO_QUERY );
+
+ if (InitialFilename.hasValue())
+ {
+ ::rtl::OUString strInitFileName;
+ InitialFilename >>= strInitFileName;
+ xFilePicker->setDefaultName(strInitFileName);
+ }
+
+ // Begin from 1.
+ sal_Int32 nFilterIndex = 1;
+ if (FilterIndex.hasValue())
+ {
+ FilterIndex >>= nFilterIndex;
+ }
+
+ uno::Reference< ui::dialogs::XFilterManager > xFilter( xFilePicker, UNO_QUERY );
+ FileFilterMap mFilterNameMap;
+ if (FileFilter.hasValue())
+ {
+ ::rtl::OUString strFilter;
+ sal_Int32 nCommaID = 0;
+ FileFilter >>= strFilter;
+
+ sal_Int32 nIndex = 1;
+ do
+ {
+ ::rtl::OUString aFilterTitleToken = strFilter.getToken( 0, ',' , nCommaID );
+ ::rtl::OUString aFilterToken;
+ if ( nCommaID >= 0 )
+ {
+ aFilterToken = strFilter.getToken( 0, ',' , nCommaID );
+ }
+ else if ( nCommaID < 0 && nIndex == 1 )
+ {
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid FileFilter format!" ), uno::Reference< uno::XInterface >() );
+ }
+
+ FileFilterMap::const_iterator aIt = mFilterNameMap.find( aFilterTitleToken );
+ if ( aIt == mFilterNameMap.end() )
+ {
+ xFilter->appendFilter( aFilterTitleToken, aFilterToken );
+ if ( nFilterIndex == nIndex )
+ {
+ xFilter->setCurrentFilter( aFilterTitleToken );
+ }
+ nIndex++;
+ mFilterNameMap[aFilterTitleToken] = aFilterToken;
+ }
+ } while ( nCommaID >= 0 );
+ }
+
+ if (Title.hasValue())
+ {
+ ::rtl::OUString strTitle;
+ Title >>= strTitle;
+ uno::Reference< ::com::sun::star::ui::dialogs::XExecutableDialog> xExcTblDlg(xFilePicker, UNO_QUERY );
+ xExcTblDlg->setTitle(strTitle);
+ }
+
+ if (ButtonText.hasValue())
+ {
+ ::rtl::OUString strBttTxt;
+ ButtonText >>= strBttTxt;
+ }
+
+
+ if ( xFilePicker.is() )
+ {
+ sal_Int16 nRet = xFilePicker->execute();
+ if (nRet == 0)
+ {
+ strRet <<= sal_False;
+ }
+ else
+ {
+ uno::Sequence < rtl::OUString > aPathSeq = xFilePicker->getFiles();
+
+ if ( aPathSeq.getLength() )
+ {
+ ::rtl::OUString sSelectedFilters;
+ if ( xFilter.is() )
+ {
+ ::rtl::OUString sSelectedFilterName = xFilter->getCurrentFilter();
+ FileFilterMap::const_iterator aIt = mFilterNameMap.find( sSelectedFilterName );
+ if ( aIt != mFilterNameMap.end() )
+ {
+ sSelectedFilters = aIt->second;
+ }
+ }
+ INetURLObject aURLObj( aPathSeq[0] );
+ ::rtl::OUString aPathStr = aURLObj.PathToFileName();
+ if ( aURLObj.GetProtocol() == INET_PROT_FILE )
+ {
+ sal_Int32 nSemicolonID = 0;
+ ::rtl::OUString sFirstFilter = sSelectedFilters.getToken( 0, ';' , nSemicolonID );
+ ::rtl::OUString sFileExtension = aURLObj.GetExtension();
+ if ( sFileExtension.equalsAscii("") )
+ {
+ sFileExtension = sFirstFilter.equalsAscii("*.*") ? sFileExtension : sFirstFilter.copy( sFirstFilter.indexOfAsciiL("*.", 2) + 2 );
+ aPathStr = sFileExtension.equalsAscii("") ? aPathStr : aPathStr + ::rtl::OUString::createFromAscii(".") + sFileExtension;
+ }
+ else
+ {
+ sal_Bool bValidFilter = sal_False;
+ FileFilterMap::const_iterator aIt = mFilterNameMap.begin();
+ while ( aIt != mFilterNameMap.end() )
+ {
+ sSelectedFilters = aIt->second;
+ nSemicolonID = 0;
+ do
+ {
+ ::rtl::OUString aFilterToken = sSelectedFilters.getToken( 0, ';' , nSemicolonID );
+ if ( aFilterToken.trim().equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("*.") + sFileExtension) )
+ {
+ bValidFilter = sal_True;
+ break;
+ }
+ } while ( nSemicolonID >= 0 );
+ if ( bValidFilter )
+ {
+ break;
+ }
+ aIt++;
+ }
+ if ( !bValidFilter )
+ {
+ sFileExtension = sFirstFilter.equalsAscii("*.*") ? ::rtl::OUString::createFromAscii("") : sFirstFilter.copy( sFirstFilter.indexOfAsciiL("*.", 2) + 2 );
+ aPathStr = sFileExtension.equalsAscii("") ? aPathStr : aPathStr + ::rtl::OUString::createFromAscii(".") + sFileExtension;
+ }
+ }
+ }
+ strRet <<= aPathStr;
+ }
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return strRet;
+}
+
+//end add
+
+uno::Reference< frame::XModel >
+ScVbaApplication::getCurrentDocument() throw (css::uno::RuntimeException)
+{
+ return getCurrentExcelDoc(mxContext);
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< XCommandBars > xCommandBars( CommandBars( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xMenuBars( new ScVbaMenuBars( this, mxContext, xCommandBars ) );
+ if ( aIndex.hasValue() )
+ {
+ return uno::Any ( xMenuBars->Item( aIndex, uno::Any() ) );
+ }
+
+ return uno::Any( xMenuBars );
+}
+
+//liuchen 2009-11-26 add the support of Application.International
+sal_Int32 SAL_CALL
+ConvertCountryCode(const OUString& language)
+{
+ sal_Int32 nCode = 0;
+
+ if( language == OUString::createFromAscii("ar") ) nCode = 966; // Arabic
+ else if ( language == OUString::createFromAscii("cs") ) nCode = 42; // Czech
+ else if ( language == OUString::createFromAscii("da") ) nCode = 45; // Danish
+ else if ( language == OUString::createFromAscii("de") ) nCode = 49; // German
+ else if ( language == OUString::createFromAscii("en") ) nCode = 1; // English
+ else if ( language == OUString::createFromAscii("es") ) nCode = 34; // Spanish
+ else if ( language == OUString::createFromAscii("el") ) nCode = 30; // Greek
+ else if ( language == OUString::createFromAscii("fa") ) nCode = 98; // Persian = Farsi
+ else if ( language == OUString::createFromAscii("fi") ) nCode = 358; // Finnish
+ else if ( language == OUString::createFromAscii("fr") ) nCode = 33; // French
+ else if ( language == OUString::createFromAscii("he") ) nCode = 972; // Hebrew
+ else if ( language == OUString::createFromAscii("hi") ) nCode = 91; // Indian = Hindi
+ else if ( language == OUString::createFromAscii("hu") ) nCode = 36; // Hungarian
+ else if ( language == OUString::createFromAscii("it") ) nCode = 39; // Italian
+ else if ( language == OUString::createFromAscii("ja") ) nCode = 81; // Japanese
+ else if ( language == OUString::createFromAscii("ko") ) nCode = 82; // Korean
+ else if ( language == OUString::createFromAscii("nl") ) nCode = 31; // Dutch
+ else if ( language == OUString::createFromAscii("no") ) nCode = 47; // Norwegian
+ else if ( language == OUString::createFromAscii("pl") ) nCode = 48; // Polish
+ else if ( language == OUString::createFromAscii("pt") ) nCode = 351; // Portuguese
+ else if ( language == OUString::createFromAscii("ru") ) nCode = 7; // Russian
+ else if ( language == OUString::createFromAscii("sv") ) nCode = 46; // Swedish
+ else if ( language == OUString::createFromAscii("th") ) nCode = 66; // Thai
+ else if ( language == OUString::createFromAscii("tk") ) nCode = 90; // Turkish
+ else if ( language == OUString::createFromAscii("ur") ) nCode = 92; // Urdu
+ else if ( language == OUString::createFromAscii("vi") ) nCode = 84; // Vietnamese
+ else if ( language == OUString::createFromAscii("zh") ) nCode = 86; // Simplified Chinese
+
+ return nCode;
+}
+
+uno::Any SAL_CALL
+ScVbaApplication::International( sal_Int32 Index ) throw (uno::RuntimeException)
+{
+ uno::Any aRet;
+ OUString str;
+ const LocaleDataWrapper* pLocaleData = ScGlobal::GetpLocaleData();
+ switch ( Index )
+ {
+ case excel::XlApplicationInternational::xlCountryCode:
+ aRet <<= ConvertCountryCode( pLocaleData->getLanguageCountryInfo().Language );
+ break;
+ case excel::XlApplicationInternational::xlDecimalSeparator:
+ str = pLocaleData->getNumDecimalSep();
+ aRet <<= str;
+ break;
+ case excel::XlApplicationInternational::xlDateSeparator:
+ str = pLocaleData->getDateSep();
+ aRet <<= str;
+ break;
+ default:
+ break;
+ }
+ return aRet;
+}
+//liuchen 2009-11-26 end
+
+//2009-12-11 add by limingl
+void SAL_CALL ScVbaApplication::Undo( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ SfxAllItemSet reqList( SFX_APP()->GetPool() );
+ SfxRequest rReq(SID_UNDO, 0, reqList);
+ ScTabViewShell* pViewShell = excel::getCurrentBestViewShell( mxContext );
+
+ if (pViewShell != NULL)
+ {
+ pViewShell->ExecuteUndo(rReq);
+ }
+}
+//end
+
+double SAL_CALL ScVbaApplication::InchesToPoints( double Inches ) throw (uno::RuntimeException)
+{
+ // Convert a measurement from Inch to Point (1 inch = 72 points).
+ return MetricField::ConvertDoubleValue( Inches, 0, 0, FUNIT_INCH, FUNIT_POINT );
+}
+
+rtl::OUString&
+ScVbaApplication::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaApplication") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaApplication::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Application" ) );
+ }
+ return aServiceNames;
+}
+
+namespace application
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaApplication, sdecl::with_args<false> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaApplication",
+ "ooo.vba.excel.Application" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx
new file mode 100644
index 000000000000..6a5f655f0dbe
--- /dev/null
+++ b/sc/source/ui/vba/vbaapplication.hxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_APPLICATION_HXX
+#define SC_VBA_APPLICATION_HXX
+
+
+#include <ooo/vba/excel/XWorksheetFunction.hpp>
+#include <ooo/vba/excel/XApplication.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbaapplicationbase.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+//typedef InheritedHelperInterfaceImpl1< ov::excel::XApplication > ScVbaApplication_BASE;
+typedef cppu::ImplInheritanceHelper1< VbaApplicationBase, ov::excel::XApplication > ScVbaApplication_BASE;
+
+class ScVbaApplication : public ScVbaApplication_BASE
+{
+private:
+ sal_Int32 m_xCalculation;
+ sal_Bool m_bDisplayAlerts;
+ sal_Bool m_bEnableEvents;
+
+ rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException );
+ css::uno::Reference< ov::XFileSearch > m_xFileSearch; //
+
+protected:
+ virtual css::uno::Reference< css::frame::XModel > getCurrentDocument() throw (css::uno::RuntimeException);
+
+public:
+ ScVbaApplication( const css::uno::Reference< css::uno::XComponentContext >& m_xContext );
+ virtual ~ScVbaApplication();
+
+ virtual SfxObjectShell* GetDocShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw (css::uno::RuntimeException);
+
+ // XExactName
+ virtual ::rtl::OUString SAL_CALL getExactName( const ::rtl::OUString& aApproximateName ) throw (css::uno::RuntimeException);
+
+ // XInvocation
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection(void) throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL invoke(const rtl::OUString& FunctionName, const css::uno::Sequence< css::uno::Any >& Params, css::uno::Sequence< sal_Int16 >& OutParamIndex, css::uno::Sequence< css::uno::Any >& OutParam) throw(css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual void SAL_CALL setValue(const rtl::OUString& PropertyName, const css::uno::Any& Value) throw(css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getValue(const rtl::OUString& PropertyName) throw(css::beans::UnknownPropertyException, css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasMethod(const rtl::OUString& Name) throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasProperty(const rtl::OUString& Name) throw(css::uno::RuntimeException);
+
+ // XApplication
+ virtual ::rtl::OUString SAL_CALL PathSeparator( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setDefaultFilePath( const ::rtl::OUString& DefaultFilePath ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDefaultFilePath( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL LibraryPath( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL TemplatesPath( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ virtual rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getDisplayAlerts() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayAlerts( sal_Bool displayAlerts ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCalculation() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCalculation( ::sal_Int32 _calculation ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getSelection() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getActiveWorkbook() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() throw ( css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayFormulaBar() throw ( css::uno::RuntimeException );
+ virtual void SAL_CALL setDisplayFormulaBar( ::sal_Bool _displayformulabar ) throw ( css::uno::RuntimeException );
+
+ virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::XFileSearch > SAL_CALL getFileSearch() throw (css::uno::RuntimeException); //liuchen 2009-8-18 add the support of Application.FileSearch
+ virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Workbooks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL WorksheetFunction( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Evaluate( const ::rtl::OUString& Name ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Dialogs( const css::uno::Any& DialogIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getCutCopyMode() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCutCopyMode( const css::uno::Any& _cutcopymode ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStatusBar() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStatusBar( const css::uno::Any& _statusbar ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCursor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getIteration() throw (css::uno::RuntimeException); //liuchen 2009-11-25 add the support of Iteration
+ virtual void SAL_CALL setIteration( sal_Bool bIteration ) throw (css::uno::RuntimeException); //liuchen 2009-11-25 add the support of Iteration
+ virtual sal_Int32 SAL_CALL getEnableCancelKey() throw (css::uno::RuntimeException); //liuchen 2009-11-26 add the support of EnableCancelKey
+ virtual void SAL_CALL setEnableCancelKey( sal_Int32 lEnableCancelKey ) throw (css::uno::RuntimeException); //liuchen 2009-11-26 add the support of EnableCancelKey
+
+ virtual sal_Int32 SAL_CALL getSheetsInNewWorkbook() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSheetsInNewWorkbook( sal_Int32 SheetsInNewWorkbook ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL wait( double time ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException );
+ virtual void SAL_CALL GoTo( const css::uno::Any& Reference, const css::uno::Any& Scroll ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Calculate() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Volatile( const css::uno::Any& Volatile ) throw (css::uno::RuntimeException );
+ virtual css::uno::Any SAL_CALL Caller( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL MenuBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL GetOpenFilename( const css::uno::Any& FileFilter, const css::uno::Any& FilterIndex, const css::uno::Any& Title, const css::uno::Any& ButtonText, const css::uno::Any& MultiSelect ) throw (css::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::ooo::vba::XFileDialog > SAL_CALL getFileDialog() throw (::com::sun::star::uno::RuntimeException); //liminl 2009-08-12 add
+ virtual css::uno::Any SAL_CALL International( sal_Int32 Index ) throw (css::uno::RuntimeException); //liuchen 2009-11-26
+ //2009-12-04 add by limingl
+ virtual css::uno::Any SAL_CALL GetSaveAsFilename( const ::com::sun::star::uno::Any& InitialFilename, const ::com::sun::star::uno::Any& FileFilter, const ::com::sun::star::uno::Any& FilterIndex, const ::com::sun::star::uno::Any& Title, const ::com::sun::star::uno::Any& ButtonText ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL InchesToPoints( double Inches ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SC_VBA_APPLICATION_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaassistant.cxx b/sc/source/ui/vba/vbaassistant.cxx
new file mode 100644
index 000000000000..43ab4589809c
--- /dev/null
+++ b/sc/source/ui/vba/vbaassistant.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <sfx2/app.hxx>
+#include <svtools/helpopt.hxx>
+
+#include <ooo/vba/office/MsoAnimationType.hpp>
+
+#include"vbaassistant.hxx"
+
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+using namespace ooo::vba::office::MsoAnimationType;
+
+ScVbaAssistant::ScVbaAssistant( const uno::Reference< XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext ): ScVbaAssistantImpl_BASE( xParent, xContext )
+{
+ m_bIsVisible = sal_False;
+ m_nPointsLeft = 795;
+ m_nPointsTop = 248;
+ m_sName = rtl::OUString::createFromAscii( "Clippit" );
+ m_nAnimation = msoAnimationIdle;
+}
+
+ScVbaAssistant::~ScVbaAssistant()
+{
+}
+
+sal_Bool SAL_CALL ScVbaAssistant::getVisible() throw (uno::RuntimeException)
+{
+ return m_bIsVisible;
+}
+
+void SAL_CALL ScVbaAssistant::setVisible( sal_Bool bVisible ) throw (uno::RuntimeException)
+{
+ m_bIsVisible = bVisible;
+}
+
+sal_Bool SAL_CALL ScVbaAssistant::getOn() throw (uno::RuntimeException)
+{
+ if( SvtHelpOptions().IsHelpAgentAutoStartMode() )
+ return sal_True;
+ else
+ return sal_False;
+}
+
+void SAL_CALL ScVbaAssistant::setOn( sal_Bool bOn ) throw (uno::RuntimeException)
+{
+ SvtHelpOptions().SetHelpAgentAutoStartMode( bOn );
+ setVisible( bOn );
+}
+
+
+::sal_Int32 SAL_CALL
+ScVbaAssistant::getTop() throw (css::uno::RuntimeException)
+{
+ return m_nPointsTop;
+}
+void SAL_CALL
+ScVbaAssistant::setTop( ::sal_Int32 _top ) throw (css::uno::RuntimeException)
+{
+ m_nPointsTop = _top;
+}
+::sal_Int32 SAL_CALL
+ScVbaAssistant::getLeft() throw (css::uno::RuntimeException)
+{
+ return m_nPointsLeft;
+}
+void SAL_CALL
+ScVbaAssistant::setLeft( ::sal_Int32 _left ) throw (css::uno::RuntimeException)
+{
+ m_nPointsLeft = _left;
+}
+::sal_Int32 SAL_CALL
+ScVbaAssistant::getAnimation() throw (css::uno::RuntimeException)
+{
+ return m_nAnimation;
+}
+void SAL_CALL
+ScVbaAssistant::setAnimation( ::sal_Int32 _animation ) throw (css::uno::RuntimeException)
+{
+ m_nAnimation = _animation;
+}
+
+::rtl::OUString SAL_CALL
+ScVbaAssistant::Name( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return m_sName;
+}
+
+rtl::OUString&
+ScVbaAssistant::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaAssistant") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaAssistant::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.Assistant" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaassistant.hxx b/sc/source/ui/vba/vbaassistant.hxx
new file mode 100644
index 000000000000..7c8f93186e8c
--- /dev/null
+++ b/sc/source/ui/vba/vbaassistant.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_ASSISTANT_HXX
+#define SC_VBA_ASSISTANT_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/XAssistant.hpp>
+
+#include <sfx2/sfxhelp.hxx>
+
+#include "excelvbahelper.hxx"
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef ::cppu::WeakImplHelper1< ov::XAssistant > Assistant;
+typedef InheritedHelperInterfaceImpl< Assistant > ScVbaAssistantImpl_BASE;
+
+class ScVbaAssistant : public ScVbaAssistantImpl_BASE
+{
+private:
+ sal_Bool m_bIsVisible;
+ sal_Int32 m_nPointsLeft;
+ sal_Int32 m_nPointsTop;
+ rtl::OUString m_sName;
+ sal_Int32 m_nAnimation;
+public:
+ ScVbaAssistant( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext );
+ virtual ~ScVbaAssistant();
+ // XAssistant
+ virtual sal_Bool SAL_CALL getOn() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setOn( sal_Bool _on ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getTop() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTop( ::sal_Int32 _top ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getLeft() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLeft( ::sal_Int32 _left ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getAnimation() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAnimation( ::sal_Int32 _animation ) throw (css::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL Name( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_ASSISTANT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaaxes.cxx b/sc/source/ui/vba/vbaaxes.cxx
new file mode 100644
index 000000000000..e528b949ff2c
--- /dev/null
+++ b/sc/source/ui/vba/vbaaxes.cxx
@@ -0,0 +1,205 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbaaxes.hxx"
+#include "vbaaxis.hxx"
+#include "vbachart.hxx"
+#include <ooo/vba/excel/XlAxisType.hpp>
+#include <ooo/vba/excel/XlAxisGroup.hpp>
+#include <ooo/vba/excel/XAxis.hpp>
+#include <map>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+using namespace ::ooo::vba::excel::XlAxisType;
+using namespace ::ooo::vba::excel::XlAxisGroup;
+
+// each 'Item' in the Axes collection is indexed via 2 indexes, group and type.
+// We need to 'flatten' this into a single index in order to be able to wrap
+// iteration over the set of Axis(s) in a XIndexAccess implementation
+//
+typedef ::std::pair<sal_Int32, sal_Int32 > AxesCoordinate; // type and group combination
+typedef ::std::vector< AxesCoordinate > vecAxesIndices;
+
+typedef ::cppu::WeakImplHelper1< container::XIndexAccess > AxisIndexWrapper_BASE;
+
+class EnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference<container::XIndexAccess > m_xIndexAccess;
+ sal_Int32 nIndex;
+public:
+ EnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < m_xIndexAccess->getCount() )
+ return m_xIndexAccess->getByIndex( nIndex++ );
+ throw container::NoSuchElementException();
+ }
+};
+
+
+uno::Reference< excel::XAxis >
+ScVbaAxes::createAxis( const uno::Reference< excel::XChart >& xChart, const uno::Reference< uno::XComponentContext >& xContext, sal_Int32 nType, sal_Int32 nAxisGroup ) throw ( uno::RuntimeException )
+{
+ ScVbaChart* pChart = static_cast< ScVbaChart* >( xChart.get() );
+ if ( !pChart )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Object failure, can't access chart implementation" ), uno::Reference< uno::XInterface >() );
+
+ uno::Reference< beans::XPropertySet > xAxisPropertySet;
+ if (((nType == xlCategory) || (nType == xlSeriesAxis) || (nType == xlValue)))
+ {
+ if ((nAxisGroup != xlPrimary) && (nAxisGroup != xlSecondary))
+ throw script::BasicErrorException( rtl::OUString(), NULL, SbERR_METHOD_FAILED, rtl::OUString());
+ xAxisPropertySet.set( pChart->getAxisPropertySet(nType, nAxisGroup), uno::UNO_QUERY_THROW );
+ }
+ else
+ throw script::BasicErrorException( rtl::OUString(), NULL, SbERR_METHOD_FAILED, rtl::OUString());
+ uno::Reference< XHelperInterface > xParent( xChart, uno::UNO_QUERY_THROW );
+ return new ScVbaAxis( xParent, xContext, xAxisPropertySet, nType, nAxisGroup);
+}
+
+class AxisIndexWrapper : public AxisIndexWrapper_BASE
+{
+ // if necessary for better performance we could change this into a map and cache the
+ // indices -> Axis, currently we create a new Axis object
+ // on each getByIndex
+ uno::Reference< uno::XComponentContext > mxContext;
+ vecAxesIndices mCoordinates;
+ uno::Reference< excel::XChart > mxChart;
+public:
+ AxisIndexWrapper( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< excel::XChart >& xChart ) : mxContext( xContext ), mxChart( xChart )
+ {
+ if ( mxChart.is() )
+ {
+ ScVbaChart* pChart = static_cast< ScVbaChart* >( mxChart.get() );
+ // primary
+ sal_Bool bBool = false;
+ uno::Reference< beans::XPropertySet > xDiagramPropertySet( pChart->xDiagramPropertySet() );
+ if ( ( xDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasXAxis" ) ) ) >>= bBool ) && bBool )
+ mCoordinates.push_back( AxesCoordinate( xlPrimary, xlCategory ) );
+ if ( ( xDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasYAxis" ) ) ) >>= bBool ) && bBool )
+ mCoordinates.push_back( AxesCoordinate( xlPrimary, xlSeriesAxis ) );
+
+ if ( pChart->is3D() )
+ mCoordinates.push_back( AxesCoordinate( xlPrimary, xlValue ) );
+
+ // secondary
+ if ( ( xDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSecondaryXAxis" ) ) ) >>= bBool ) && bBool )
+ mCoordinates.push_back( AxesCoordinate( xlSecondary, xlCategory ) );
+ if ( ( xDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasSecondaryYAxis" ) ) ) >>= bBool ) && bBool )
+ mCoordinates.push_back( AxesCoordinate( xlSecondary, xlSeriesAxis ) );
+ }
+
+ }
+ virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException) { return mCoordinates.size(); }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, ::uno::RuntimeException)
+ {
+ AxesCoordinate dIndexes = mCoordinates[ Index ];
+ return uno::makeAny( ScVbaAxes::createAxis( mxChart, mxContext, dIndexes.second, dIndexes.first ) );
+ }
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
+ {
+ return excel::XAxis::static_type(0);
+ }
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return ( mCoordinates.size() > 0 );
+ }
+};
+
+uno::Reference< container::XIndexAccess > createIndexWrapper( const uno::Reference< excel::XChart >& xChart, const uno::Reference< uno::XComponentContext >& xContext )
+{
+ return new AxisIndexWrapper( xContext, xChart );
+}
+
+// #FIXME The collection semantics will never work as this object is not yet initialised correctly
+ScVbaAxes::ScVbaAxes( const uno::Reference< XHelperInterface >& xParent,const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< excel::XChart >& xChart ) : ScVbaAxes_BASE( xParent, xContext, createIndexWrapper( xChart, xContext )), moChartParent( xChart )
+{
+}
+
+uno::Type SAL_CALL
+ScVbaAxes::getElementType() throw (css::uno::RuntimeException)
+{
+ return excel::XAxes::static_type(0);
+}
+
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaAxes::createEnumeration() throw (css::uno::RuntimeException)
+{
+ return new EnumWrapper( m_xIndexAccess );
+}
+
+uno::Any SAL_CALL
+ScVbaAxes::Item( const css::uno::Any& _nType, const css::uno::Any& _oAxisGroup) throw (css::uno::RuntimeException)
+{
+ // #TODO map the possible index combinations to a container::XIndexAccess wrapper impl
+ // using a vector of valid std::pair maybe?
+ // bodgy helperapi port bits
+ sal_Int32 nAxisGroup = xlPrimary;
+ sal_Int32 nType = -1;
+ if ( !_nType.hasValue() || ( ( _nType >>= nType ) == sal_False ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Axes::Item Failed to extract type" ), uno::Reference< uno::XInterface >() );
+
+ if ( _oAxisGroup.hasValue() )
+ _oAxisGroup >>= nAxisGroup ;
+
+ return uno::makeAny( createAxis( moChartParent, mxContext, nType, nAxisGroup ) );
+}
+
+uno::Any
+ScVbaAxes::createCollectionObject(const css::uno::Any& aSource)
+{
+ return aSource; // pass through ( it's already an XAxis object
+}
+
+rtl::OUString&
+ScVbaAxes::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaAxes") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaAxes::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Axes" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaaxes.hxx b/sc/source/ui/vba/vbaaxes.hxx
new file mode 100644
index 000000000000..a9ebf1a76138
--- /dev/null
+++ b/sc/source/ui/vba/vbaaxes.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_AXES_HXX
+#define SC_VBA_AXES_HXX
+#include <ooo/vba/excel/XAxes.hpp>
+#include <ooo/vba/excel/XAxis.hpp>
+#include <ooo/vba/excel/XChart.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XAxes > ScVbaAxes_BASE;
+class ScVbaAxes : public ScVbaAxes_BASE
+{
+ css::uno::Reference< ov::excel::XChart > moChartParent; // not the true parent I guess
+public:
+ ScVbaAxes( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< ov::excel::XChart >& xChart );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ css::uno::Any SAL_CALL Item( const css::uno::Any& aIndex, const css::uno::Any& aIndex2 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject(const css::uno::Any&);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+ static css::uno::Reference< ov::excel::XAxis > createAxis( const css::uno::Reference< ov::excel::XChart >& xChart, const css::uno::Reference< css::uno::XComponentContext >& xContext, sal_Int32 nType, sal_Int32 nAxisGroup ) throw ( css::uno::RuntimeException );
+};
+
+#endif //SC_VBA_AXES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaaxis.cxx b/sc/source/ui/vba/vbaaxis.cxx
new file mode 100644
index 000000000000..9e17b30135a4
--- /dev/null
+++ b/sc/source/ui/vba/vbaaxis.cxx
@@ -0,0 +1,672 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbaaxis.hxx"
+#include <ooo/vba/excel/XlAxisCrosses.hpp>
+#include <ooo/vba/excel/XlAxisType.hpp>
+#include <ooo/vba/excel/XlScaleType.hpp>
+#include "vbaaxistitle.hxx"
+#include "vbachart.hxx"
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+using namespace ::ooo::vba::excel::XlAxisCrosses;
+using namespace ::ooo::vba::excel::XlAxisType;
+using namespace ::ooo::vba::excel::XlScaleType;
+
+const rtl::OUString ORIGIN( RTL_CONSTASCII_USTRINGPARAM("Origin") );
+const rtl::OUString AUTOORIGIN( RTL_CONSTASCII_USTRINGPARAM("AutoOrigin") );
+const rtl::OUString VBA_MIN( RTL_CONSTASCII_USTRINGPARAM("Max") );
+const rtl::OUString VBA_MAX( RTL_CONSTASCII_USTRINGPARAM("Min") );
+ScVbaChart*
+ScVbaAxis::getChartPtr() throw( uno::RuntimeException )
+{
+ ScVbaChart* pChart = static_cast< ScVbaChart* >( moChartParent.get() );
+ if ( !pChart )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Can't access parent chart impl"), uno::Reference< uno::XInterface >() );
+ return pChart;
+}
+
+sal_Bool
+ScVbaAxis::isValueAxis() throw( script::BasicErrorException )
+{
+ if ( getType() == xlCategory )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return sal_True;
+}
+
+ScVbaAxis::ScVbaAxis( const uno::Reference< XHelperInterface >& xParent,const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, sal_Int32 _nType, sal_Int32 _nGroup ) : ScVbaAxis_BASE( xParent, xContext ), mxPropertySet( _xPropertySet ), mnType( _nType ), mnGroup( _nGroup ), bCrossesAreCustomized( sal_False )
+{
+ oShapeHelper.reset( new ShapeHelper( uno::Reference< drawing::XShape >( mxPropertySet, uno::UNO_QUERY ) ) );
+ moChartParent.set( xParent, uno::UNO_QUERY_THROW );
+ setType(_nType);
+ setCrosses(xlAxisCrossesAutomatic);
+}
+
+void SAL_CALL
+ScVbaAxis::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< lang::XComponent > xComponent( mxPropertySet, uno::UNO_QUERY_THROW );
+ xComponent->dispose();
+}
+
+ uno::Reference< ::ooo::vba::excel::XAxisTitle > SAL_CALL
+ScVbaAxis::getAxisTitle( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< excel::XAxisTitle > xAxisTitle;
+ try
+ {
+ ScVbaChart* pChart = getChartPtr();
+
+ if (getHasTitle() )
+ {
+ int nType = getType();
+ switch(nType)
+ {
+ case xlCategory:
+ xAxisTitle = new ScVbaAxisTitle(this, mxContext, pChart->xAxisXSupplier->getXAxisTitle());
+ break;
+ case xlSeriesAxis:
+ xAxisTitle = new ScVbaAxisTitle(this, mxContext, pChart->xAxisZSupplier->getZAxisTitle());
+ break;
+ default: // xlValue:
+ xAxisTitle = new ScVbaAxisTitle(this, mxContext, pChart->xAxisYSupplier->getYAxisTitle());
+ break;
+ }
+ }
+ }
+ catch (uno::Exception& e)
+ {
+ DebugHelper::exception(e);
+ }
+ return xAxisTitle;
+
+}
+
+void SAL_CALL
+ScVbaAxis::setDisplayUnit( ::sal_Int32 /*DisplayUnit*/ ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+}
+
+::sal_Int32 SAL_CALL
+ScVbaAxis::getDisplayUnit( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ return -1;
+}
+
+void SAL_CALL
+ScVbaAxis::setCrosses( ::sal_Int32 _nCrosses ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ double fNum = 0.0;
+ switch (_nCrosses)
+ {
+ case xlAxisCrossesAutomatic: //Microsoft Excel sets the axis crossing point.
+ mxPropertySet->setPropertyValue(AUTOORIGIN, uno::makeAny( sal_True ) );
+ bCrossesAreCustomized = sal_False;
+ return;
+ case xlAxisCrossesMinimum: // The axis crosses at the minimum value.
+ mxPropertySet->getPropertyValue(VBA_MIN) >>= fNum;
+ setCrossesAt( fNum );
+ bCrossesAreCustomized = sal_False;
+ break;
+ case xlAxisCrossesMaximum: // The axis crosses at the maximum value.
+ mxPropertySet->getPropertyValue(VBA_MAX) >>= fNum;
+ setCrossesAt(fNum);
+ bCrossesAreCustomized = sal_False;
+ break;
+ default: //xlAxisCrossesCustom
+ bCrossesAreCustomized = sal_True;
+ break;
+ }
+ mxPropertySet->setPropertyValue(AUTOORIGIN, uno::makeAny(sal_False) );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+::sal_Int32 SAL_CALL
+ScVbaAxis::getCrosses( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Int32 nCrosses = xlAxisCrossesCustom;
+ try
+ {
+ sal_Bool bisAutoOrigin = sal_False;
+ mxPropertySet->getPropertyValue(AUTOORIGIN) >>= bisAutoOrigin;
+ if (bisAutoOrigin)
+ nCrosses = xlAxisCrossesAutomatic;
+ else
+ {
+ if (bCrossesAreCustomized)
+ nCrosses = xlAxisCrossesCustom;
+ else
+ {
+ double forigin = 0.0;
+ mxPropertySet->getPropertyValue(ORIGIN) >>= forigin;
+//obsolete double fmax = AnyConverter.toDouble(mxPropertySet.getPropertyValue("Max"));
+ double fmin = 0.0;
+ mxPropertySet->getPropertyValue(VBA_MIN) >>= fmin;
+ if (forigin == fmin)
+ nCrosses = xlAxisCrossesMinimum;
+ else
+ nCrosses = xlAxisCrossesMaximum;
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return nCrosses;
+}
+
+ void SAL_CALL
+ScVbaAxis::setCrossesAt( double _fCrossesAt ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+// if (getCrosses() == xlAxisCrossesCustom){
+ setMaximumScaleIsAuto( sal_False );
+ setMinimumScaleIsAuto( sal_False );
+ mxPropertySet->setPropertyValue(ORIGIN, uno::makeAny(_fCrossesAt));
+// }
+ }
+ catch (uno::Exception& e)
+ {
+ DebugHelper::exception(e);
+ }
+}
+
+ double SAL_CALL
+ScVbaAxis::getCrossesAt( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ double fCrosses = 0.0;
+ try
+ {
+ mxPropertySet->getPropertyValue(ORIGIN) >>= fCrosses;
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return fCrosses;
+}
+
+void SAL_CALL
+ScVbaAxis::setType( ::sal_Int32 _nType ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ mnType = _nType;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaAxis::getType( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return mnType;
+}
+
+void SAL_CALL
+ScVbaAxis::setHasTitle( ::sal_Bool _bHasTitle ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ ScVbaChart* pChart = getChartPtr();
+ sal_Int32 nType = getType();
+ switch(nType)
+ {
+ case xlCategory:
+ pChart->mxDiagramPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasXAxisTitle")), uno::makeAny(_bHasTitle));
+ break;
+ case xlSeriesAxis:
+ pChart->mxDiagramPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasZAxisTitle")), uno::makeAny(_bHasTitle));
+ break;
+ default: // xlValue:
+ pChart->mxDiagramPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasYAxisTitle")), uno::makeAny(_bHasTitle));
+ }
+
+ }
+ catch (uno::Exception& e)
+ {
+ DebugHelper::exception(e);
+ }
+}
+
+ ::sal_Bool SAL_CALL
+ScVbaAxis::getHasTitle( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bHasTitle = sal_False;
+ try
+ {
+ ScVbaChart* pChart = getChartPtr();
+ int nType = getType();
+ switch(nType)
+ {
+ case xlCategory:
+ pChart->mxDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasXAxisTitle")) ) >>= bHasTitle;
+ break;
+ case xlSeriesAxis:
+ pChart->mxDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasZAxisTitle")) ) >>= bHasTitle;
+ break;
+ default: // xlValue:
+ pChart->mxDiagramPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("HasYAxisTitle")) ) >>= bHasTitle;
+ }
+ }
+ catch (uno::Exception& e)
+ {
+ DebugHelper::exception(e);
+ }
+ return bHasTitle;
+}
+
+void SAL_CALL
+ScVbaAxis::setMinorUnit( double _fMinorUnit ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StepHelp") ), uno::makeAny(_fMinorUnit));
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+double SAL_CALL
+ScVbaAxis::getMinorUnit( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ double fMinor = 1.0;
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StepHelp"))) >>= fMinor;
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return fMinor;
+}
+
+void SAL_CALL
+ScVbaAxis::setMinorUnitIsAuto( ::sal_Bool _bMinorUnitIsAuto ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoStepHelp" ) ), uno::makeAny(_bMinorUnitIsAuto));
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+ ::sal_Bool SAL_CALL
+ScVbaAxis::getMinorUnitIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bIsAuto = sal_False;
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoStepHelp")) ) >>= bIsAuto;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return bIsAuto;
+}
+
+void SAL_CALL
+ScVbaAxis::setReversePlotOrder( ::sal_Bool /*ReversePlotOrder*/ ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+}
+
+::sal_Bool SAL_CALL
+ScVbaAxis::getReversePlotOrder( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ return sal_False;
+}
+
+void SAL_CALL
+ScVbaAxis::setMajorUnit( double _fMajorUnit ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StepMain")), uno::makeAny(_fMajorUnit));
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+double SAL_CALL
+ScVbaAxis::getMajorUnit( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ double fMax = 1.0;
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("StepMain"))) >>= fMax;
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return fMax;
+}
+
+void SAL_CALL
+ScVbaAxis::setMajorUnitIsAuto( ::sal_Bool _bMajorUnitIsAuto ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoStepMain" ) ), uno::makeAny( _bMajorUnitIsAuto ));
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+::sal_Bool SAL_CALL
+ScVbaAxis::getMajorUnitIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bIsAuto = sal_False;
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoStepMain"))) >>= bIsAuto;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return bIsAuto;
+}
+
+void SAL_CALL
+ScVbaAxis::setMaximumScale( double _fMaximumScale ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if ( isValueAxis() )
+ {
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Max" ) ), uno::makeAny(_fMaximumScale));
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+double SAL_CALL
+ScVbaAxis::getMaximumScale( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ double fMax = 1.0;
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Max" ))) >>= fMax;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return fMax;
+
+}
+
+void SAL_CALL
+ScVbaAxis::setMaximumScaleIsAuto( ::sal_Bool _bMaximumScaleIsAuto ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if ( isValueAxis() )
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoMax" ) ), uno::makeAny( _bMaximumScaleIsAuto ));
+
+ }
+ catch ( uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+
+::sal_Bool SAL_CALL
+ScVbaAxis::getMaximumScaleIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bIsAuto = sal_False;
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoMax" )) ) >>= bIsAuto;
+ }
+ catch ( uno::Exception& )
+ {
+ DebugHelper::exception( SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return bIsAuto;
+}
+
+void SAL_CALL
+ScVbaAxis::setMinimumScale( double _fMinimumScale ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Min") ), uno::makeAny( _fMinimumScale ) );
+ }
+ catch ( uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+double SAL_CALL
+ScVbaAxis::getMinimumScale( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ double fMin = 0.0;
+ try
+ {
+ if (isValueAxis())
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Min") )) >>= fMin;
+ }
+ catch (uno::Exception& e)
+ {
+ DebugHelper::exception(e);
+ }
+ return fMin;
+}
+
+void SAL_CALL
+ScVbaAxis::setMinimumScaleIsAuto( ::sal_Bool _bMinimumScaleIsAuto ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoMin") ), uno::makeAny(_bMinimumScaleIsAuto));
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+::sal_Bool SAL_CALL
+ScVbaAxis::getMinimumScaleIsAuto( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bIsAuto = sal_False;
+ try
+ {
+ if (isValueAxis())
+ {
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoMin")) ) >>= bIsAuto;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return bIsAuto;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaAxis::getAxisGroup( ) throw (uno::RuntimeException)
+{
+ return mnGroup;
+}
+
+void SAL_CALL
+ScVbaAxis::setScaleType( ::sal_Int32 _nScaleType ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ if (isValueAxis())
+ {
+ switch (_nScaleType)
+ {
+ case xlScaleLinear:
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( sal_False ) );
+ break;
+ case xlScaleLogarithmic:
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Logarithmic" ) ), uno::makeAny( sal_True ) );
+ break;
+ default:
+ // According to MS the paramenter is ignored and no Error is thrown
+ break;
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+::sal_Int32 SAL_CALL
+ScVbaAxis::getScaleType( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Int32 nScaleType = xlScaleLinear;
+ try
+ {
+ if (isValueAxis())
+ {
+ sal_Bool bisLogarithmic = sal_False;
+ mxPropertySet->getPropertyValue( rtl::OUString( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Logarithmic"))) ) >>= bisLogarithmic;
+ if (bisLogarithmic)
+ nScaleType = xlScaleLogarithmic;
+ else
+ nScaleType = xlScaleLinear;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return nScaleType;
+}
+
+double SAL_CALL
+ScVbaAxis::getHeight( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return oShapeHelper->getHeight();
+}
+
+void SAL_CALL ScVbaAxis::setHeight( double height ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ oShapeHelper->setHeight( height );
+}
+double SAL_CALL ScVbaAxis::getWidth( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return oShapeHelper->getWidth( );
+}
+void SAL_CALL ScVbaAxis::setWidth( double width ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ oShapeHelper->setWidth( width );
+}
+double SAL_CALL ScVbaAxis::getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return oShapeHelper->getTop( );
+}
+void SAL_CALL ScVbaAxis::setTop( double top ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ oShapeHelper->setTop( top );
+}
+double SAL_CALL ScVbaAxis::getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return oShapeHelper->getLeft( );
+}
+void SAL_CALL ScVbaAxis::setLeft( double left ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ oShapeHelper->setLeft( left );
+}
+
+rtl::OUString&
+ScVbaAxis::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaAxis") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaAxis::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Axis" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaaxis.hxx b/sc/source/ui/vba/vbaaxis.hxx
new file mode 100644
index 000000000000..aa42ded186e3
--- /dev/null
+++ b/sc/source/ui/vba/vbaaxis.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_AXIS_HXX
+#define SC_VBA_AXOS_HXX
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/excel/XAxis.hpp>
+#include <ooo/vba/excel/XChart.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <memory>
+typedef InheritedHelperInterfaceImpl1< ov::excel::XAxis > ScVbaAxis_BASE;
+class ScVbaChart;
+class ScVbaAxis : public ScVbaAxis_BASE
+{
+ css::uno::Reference< ov::excel::XChart > moChartParent;
+ css::uno::Reference< css::beans::XPropertySet > mxPropertySet;
+ sal_Int32 mnType;
+ sal_Int32 mnGroup;
+ sal_Int32 mnCrosses;
+ sal_Bool bCrossesAreCustomized;
+ ScVbaChart* getChartPtr() throw( css::uno::RuntimeException );
+ sal_Bool isValueAxis() throw( css::script::BasicErrorException );
+ std::auto_ptr<ov::ShapeHelper> oShapeHelper;
+
+public:
+ ScVbaAxis( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, sal_Int32 _nType, sal_Int32 _nGroup );
+ // Methods
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::excel::XAxisTitle > SAL_CALL getAxisTitle( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayUnit( ::sal_Int32 DisplayUnit ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getDisplayUnit( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setCrosses( ::sal_Int32 Crosses ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCrosses( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setCrossesAt( double CrossesAt ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getCrossesAt( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setType( ::sal_Int32 Type ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getType( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setHasTitle( ::sal_Bool HasTitle ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getHasTitle( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMinorUnit( double MinorUnit ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getMinorUnit( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMinorUnitIsAuto( ::sal_Bool MinorUnitIsAuto ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getMinorUnitIsAuto( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setReversePlotOrder( ::sal_Bool ReversePlotOrder ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getReversePlotOrder( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMajorUnit( double MajorUnit ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getMajorUnit( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMajorUnitIsAuto( ::sal_Bool MajorUnitIsAuto ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getMajorUnitIsAuto( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMaximumScale( double MaximumScale ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getMaximumScale( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMaximumScaleIsAuto( ::sal_Bool MaximumScaleIsAuto ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getMaximumScaleIsAuto( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMinimumScale( double MinimumScale ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getMinimumScale( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMinimumScaleIsAuto( ::sal_Bool MinimumScaleIsAuto ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getMinimumScaleIsAuto( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getAxisGroup( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setScaleType( ::sal_Int32 ScaleType ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getScaleType( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getHeight( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setHeight( double height ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getWidth( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setWidth( double width ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setTop( double top ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual double SAL_CALL getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setLeft( double left ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_AXIS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaaxistitle.cxx b/sc/source/ui/vba/vbaaxistitle.cxx
new file mode 100644
index 000000000000..2499fa756891
--- /dev/null
+++ b/sc/source/ui/vba/vbaaxistitle.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaaxistitle.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+ScVbaAxisTitle::ScVbaAxisTitle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& _xTitleShape ) : AxisTitleBase( xParent, xContext, _xTitleShape )
+{
+}
+
+rtl::OUString&
+ScVbaAxisTitle::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaAxisTitle") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaAxisTitle::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ uno::Sequence< rtl::OUString > BaseServiceNames = AxisTitleBase::getServiceNames();
+ aServiceNames.realloc( BaseServiceNames.getLength() + 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.AxisTitle" ) );
+ for ( sal_Int32 index = 1; index < (BaseServiceNames.getLength() + 1); ++index )
+ aServiceNames[ index ] = BaseServiceNames[ index ];
+ }
+ return aServiceNames;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaaxistitle.hxx b/sc/source/ui/vba/vbaaxistitle.hxx
new file mode 100644
index 000000000000..4ab2c5e06c90
--- /dev/null
+++ b/sc/source/ui/vba/vbaaxistitle.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_AXISTITLE_HXX
+#define SC_VBA_AXISTITLE_HXX
+
+#include "vbatitle.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XAxisTitle.hpp>
+
+typedef TitleImpl< cppu::WeakImplHelper1< ov::excel::XAxisTitle > > AxisTitleBase;
+
+class ScVbaAxisTitle : public AxisTitleBase
+{
+public:
+ ScVbaAxisTitle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& _xTitleShape );
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaborders.cxx b/sc/source/ui/vba/vbaborders.cxx
new file mode 100644
index 000000000000..0cb28dbc6556
--- /dev/null
+++ b/sc/source/ui/vba/vbaborders.cxx
@@ -0,0 +1,577 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaborders.hxx"
+
+#include <sal/macros.h>
+#include <cppuhelper/implbase3.hxx>
+#include <ooo/vba/excel/XlBordersIndex.hpp>
+#include <ooo/vba/excel/XlBorderWeight.hpp>
+#include <ooo/vba/excel/XlLineStyle.hpp>
+#include <ooo/vba/excel/XlColorIndex.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include "vbapalette.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+using namespace ::ooo::vba::excel;
+
+
+typedef ::cppu::WeakImplHelper1<container::XIndexAccess > RangeBorders_Base;
+typedef InheritedHelperInterfaceImpl1<excel::XBorder > ScVbaBorder_Base;
+
+// #TODO sort these indexes to match the order in which Excel iterates over the
+// borders, the enumeration will match the order in this list
+static const sal_Int16 supportedIndexTable[] = { XlBordersIndex::xlEdgeLeft, XlBordersIndex::xlEdgeTop, XlBordersIndex::xlEdgeBottom, XlBordersIndex::xlEdgeRight, XlBordersIndex::xlDiagonalDown, XlBordersIndex::xlDiagonalUp, XlBordersIndex::xlInsideVertical, XlBordersIndex::xlInsideHorizontal };
+
+const static rtl::OUString sTableBorder( RTL_CONSTASCII_USTRINGPARAM("TableBorder") );
+
+// Equiv widths in in 1/100 mm
+const static sal_Int32 OOLineThin = 35;
+const static sal_Int32 OOLineMedium = 88;
+const static sal_Int32 OOLineThick = 141;
+const static sal_Int32 OOLineHairline = 2;
+
+class ScVbaBorder : public ScVbaBorder_Base
+{
+private:
+ uno::Reference< beans::XPropertySet > m_xProps;
+ sal_Int32 m_LineType;
+ ScVbaPalette m_Palette;
+ bool setBorderLine( table::BorderLine& rBorderLine )
+ {
+ table::TableBorder aTableBorder;
+ m_xProps->getPropertyValue( sTableBorder ) >>= aTableBorder;
+
+ switch ( m_LineType )
+ {
+ case XlBordersIndex::xlEdgeLeft:
+ aTableBorder.IsLeftLineValid = sal_True;
+ aTableBorder.LeftLine= rBorderLine;
+ break;
+ case XlBordersIndex::xlEdgeTop:
+ aTableBorder.IsTopLineValid = sal_True;
+ aTableBorder.TopLine = rBorderLine;
+ break;
+
+ case XlBordersIndex::xlEdgeBottom:
+ aTableBorder.IsBottomLineValid = sal_True;
+ aTableBorder.BottomLine = rBorderLine;
+ break;
+ case XlBordersIndex::xlEdgeRight:
+ aTableBorder.IsRightLineValid = sal_True;
+ aTableBorder.RightLine = rBorderLine;
+ break;
+ case XlBordersIndex::xlInsideVertical:
+ aTableBorder.IsVerticalLineValid = sal_True;
+ aTableBorder.VerticalLine = rBorderLine;
+ break;
+ case XlBordersIndex::xlInsideHorizontal:
+ aTableBorder.IsHorizontalLineValid = sal_True;
+ aTableBorder.HorizontalLine = rBorderLine;
+ break;
+ case XlBordersIndex::xlDiagonalDown:
+ case XlBordersIndex::xlDiagonalUp:
+ // #TODO have to ignore at the momement, would be
+ // nice to investigate what we can do here
+ break;
+ default:
+ return false;
+ }
+ m_xProps->setPropertyValue( sTableBorder, uno::makeAny(aTableBorder) );
+ return true;
+ }
+
+ bool getBorderLine( table::BorderLine& rBorderLine )
+ {
+ table::TableBorder aTableBorder;
+ m_xProps->getPropertyValue( sTableBorder ) >>= aTableBorder;
+ switch ( m_LineType )
+ {
+ case XlBordersIndex::xlEdgeLeft:
+ if ( aTableBorder.IsLeftLineValid )
+ rBorderLine = aTableBorder.LeftLine;
+ break;
+ case XlBordersIndex::xlEdgeTop:
+ if ( aTableBorder.IsTopLineValid )
+ rBorderLine = aTableBorder.TopLine;
+ break;
+
+ case XlBordersIndex::xlEdgeBottom:
+ if ( aTableBorder.IsBottomLineValid )
+ rBorderLine = aTableBorder.BottomLine;
+ break;
+ case XlBordersIndex::xlEdgeRight:
+ if ( aTableBorder.IsRightLineValid )
+ rBorderLine = aTableBorder.RightLine;
+ break;
+ case XlBordersIndex::xlInsideVertical:
+ if ( aTableBorder.IsVerticalLineValid )
+ rBorderLine = aTableBorder.VerticalLine;
+ break;
+ case XlBordersIndex::xlInsideHorizontal:
+ if ( aTableBorder.IsHorizontalLineValid )
+ rBorderLine = aTableBorder.HorizontalLine;
+ break;
+
+ case XlBordersIndex::xlDiagonalDown:
+ case XlBordersIndex::xlDiagonalUp:
+ // #TODO have to ignore at the momement, would be
+ // nice to investigate what we can do here
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+ ScVbaBorder(); // no impl
+protected:
+ virtual rtl::OUString& getServiceImplName()
+ {
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaBorder") );
+ return sImplName;
+ }
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames()
+ {
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Border" ) );
+ }
+ return aServiceNames;
+ }
+public:
+ ScVbaBorder( const uno::Reference< beans::XPropertySet > & xProps, const uno::Reference< uno::XComponentContext >& xContext, sal_Int32 lineType, ScVbaPalette& rPalette) : ScVbaBorder_Base( uno::Reference< XHelperInterface >( xProps, uno::UNO_QUERY ), xContext ), m_xProps( xProps ), m_LineType( lineType ), m_Palette( rPalette ) {}
+
+ // XBorder
+ uno::Any SAL_CALL getColor() throw (uno::RuntimeException)
+ {
+ table::BorderLine aBorderLine;
+ if ( getBorderLine( aBorderLine ) )
+ return uno::makeAny( OORGBToXLRGB( aBorderLine.Color ) );
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No Implementation available" ) ), uno::Reference< uno::XInterface >() );
+ }
+ void SAL_CALL setColor( const uno::Any& _color ) throw (uno::RuntimeException)
+ {
+ sal_Int32 nColor = 0;
+ _color >>= nColor;
+ table::BorderLine aBorderLine;
+ if ( getBorderLine( aBorderLine ) )
+ {
+ aBorderLine.Color = XLRGBToOORGB( nColor );
+ setBorderLine( aBorderLine );
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "No Implementation available" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ uno::Any SAL_CALL getColorIndex() throw (uno::RuntimeException)
+ {
+ sal_Int32 nColor = 0;
+ XLRGBToOORGB( getColor() ) >>= nColor;
+ uno::Reference< container::XIndexAccess > xIndex = m_Palette.getPalette();
+ sal_Int32 nElems = xIndex->getCount();
+ sal_Int32 nIndex = -1;
+ for ( sal_Int32 count=0; count<nElems; ++count )
+ {
+ sal_Int32 nPaletteColor = 0;
+ xIndex->getByIndex( count ) >>= nPaletteColor;
+ if ( nPaletteColor == nColor )
+ {
+ nIndex = count + 1;
+ break;
+ }
+ }
+ return uno::makeAny(nIndex);
+ }
+
+ void SAL_CALL setColorIndex( const uno::Any& _colorindex ) throw (uno::RuntimeException)
+ {
+ sal_Int32 nColor = 0;
+ _colorindex >>= nColor;
+ if ( !nColor || nColor == XlColorIndex::xlColorIndexAutomatic )
+ nColor = 1;
+ setColor( OORGBToXLRGB( m_Palette.getPalette()->getByIndex( --nColor ) ) );
+ }
+ uno::Any SAL_CALL getWeight() throw (uno::RuntimeException)
+ {
+ table::BorderLine aBorderLine;
+ if ( getBorderLine( aBorderLine ) )
+ {
+ switch ( aBorderLine.OuterLineWidth )
+ {
+ case 0: // Thin = default OO thickness
+ case OOLineThin:
+ return uno::makeAny( XlBorderWeight::xlThin );
+ case OOLineMedium:
+ return uno::makeAny( XlBorderWeight::xlMedium );
+ case OOLineThick:
+ return uno::makeAny( XlBorderWeight::xlThick );
+ case OOLineHairline:
+ return uno::makeAny( XlBorderWeight::xlHairline );
+ default:
+ break;
+ }
+ }
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Method failed" ) ), uno::Reference< uno::XInterface >() );
+ }
+ void SAL_CALL setWeight( const uno::Any& _weight ) throw (uno::RuntimeException)
+ {
+ sal_Int32 nWeight = 0;
+ _weight >>= nWeight;
+ table::BorderLine aBorderLine;
+ if ( getBorderLine( aBorderLine ) )
+ {
+ switch ( nWeight )
+ {
+ case XlBorderWeight::xlThin:
+ aBorderLine.OuterLineWidth = OOLineThin;
+ break;
+ case XlBorderWeight::xlMedium:
+ aBorderLine.OuterLineWidth = OOLineMedium;
+ break;
+ case XlBorderWeight::xlThick:
+ aBorderLine.OuterLineWidth = OOLineThick;
+ break;
+ case XlBorderWeight::xlHairline:
+ aBorderLine.OuterLineWidth = OOLineHairline;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Bad param" ) ), uno::Reference< uno::XInterface >() );
+ }
+ setBorderLine( aBorderLine );
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Method failed" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ uno::Any SAL_CALL getLineStyle() throw (uno::RuntimeException)
+ {
+ // always return xlContinuous;
+ return uno::makeAny( XlLineStyle::xlContinuous );
+ }
+ void SAL_CALL setLineStyle( const uno::Any& _linestyle ) throw (uno::RuntimeException)
+ {
+ // Urk no choice but to silently ignore we don't support this attribute
+ // #TODO would be nice to support the excel line styles
+ sal_Int32 nLineStyle = 0;
+ _linestyle >>= nLineStyle;
+ table::BorderLine aBorderLine;
+ if ( getBorderLine( aBorderLine ) )
+ {
+ switch ( nLineStyle )
+ {
+ case XlLineStyle::xlContinuous:
+ case XlLineStyle::xlDash:
+ case XlLineStyle::xlDashDot:
+ case XlLineStyle::xlDashDotDot:
+ case XlLineStyle::xlDot:
+ case XlLineStyle::xlDouble:
+ case XlLineStyle::xlLineStyleNone:
+ case XlLineStyle::xlSlantDashDot:
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Bad param" ) ), uno::Reference< uno::XInterface >() );
+ }
+ setBorderLine( aBorderLine );
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Method failed" ) ), uno::Reference< uno::XInterface >() );
+ }
+};
+
+class RangeBorders : public RangeBorders_Base
+{
+private:
+ uno::Reference< table::XCellRange > m_xRange;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ ScVbaPalette m_Palette;
+ sal_Int32 getTableIndex( sal_Int32 nConst )
+ {
+ // hokay return position of the index in the table
+ sal_Int32 nIndexes = getCount();
+ sal_Int32 realIndex = 0;
+ const sal_Int16* pTableEntry = supportedIndexTable;
+ for ( ; realIndex < nIndexes; ++realIndex, ++pTableEntry )
+ {
+ if ( *pTableEntry == nConst )
+ return realIndex;
+ }
+ return getCount(); // error condition
+ }
+public:
+ RangeBorders( const uno::Reference< table::XCellRange >& xRange, const uno::Reference< uno::XComponentContext > & xContext, ScVbaPalette& rPalette ) : m_xRange( xRange ), m_xContext( xContext ), m_Palette( rPalette )
+ {
+ }
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return SAL_N_ELEMENTS( supportedIndexTable );
+ }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+
+ sal_Int32 nIndex = getTableIndex( Index );
+ if ( nIndex >= 0 && nIndex < getCount() )
+ {
+ uno::Reference< beans::XPropertySet > xProps( m_xRange, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< excel::XBorder >( new ScVbaBorder( xProps, m_xContext, supportedIndexTable[ nIndex ], m_Palette )) );
+ }
+ throw lang::IndexOutOfBoundsException();
+ }
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return excel::XBorder::static_type(0);
+ }
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+};
+
+uno::Reference< container::XIndexAccess >
+rangeToBorderIndexAccess( const uno::Reference< table::XCellRange >& xRange, const uno::Reference< uno::XComponentContext > & xContext, ScVbaPalette& rPalette )
+{
+ return new RangeBorders( xRange, xContext, rPalette );
+}
+
+class RangeBorderEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference<container::XIndexAccess > m_xIndexAccess;
+ sal_Int32 nIndex;
+public:
+ RangeBorderEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < m_xIndexAccess->getCount() )
+ return m_xIndexAccess->getByIndex( nIndex++ );
+ throw container::NoSuchElementException();
+ }
+};
+
+ScVbaBorders::ScVbaBorders( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< table::XCellRange >& xRange, ScVbaPalette& rPalette ): ScVbaBorders_BASE( xParent, xContext, rangeToBorderIndexAccess( xRange ,xContext, rPalette ) ), bRangeIsSingleCell( false )
+{
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xRange, uno::UNO_QUERY_THROW );
+ if ( xColumnRowRange->getRows()->getCount() == 1 && xColumnRowRange->getColumns()->getCount() == 1 )
+ bRangeIsSingleCell = true;
+ m_xProps.set( xRange, uno::UNO_QUERY_THROW );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaBorders::createEnumeration() throw (uno::RuntimeException)
+{
+ return new RangeBorderEnumWrapper( m_xIndexAccess );
+}
+
+uno::Any
+ScVbaBorders::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource; // its already a Border object
+}
+
+uno::Type
+ScVbaBorders::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XBorders::static_type(0);
+}
+
+uno::Any
+ScVbaBorders::getItemByIntIndex( const sal_Int32 nIndex ) throw (uno::RuntimeException)
+{
+ return createCollectionObject( m_xIndexAccess->getByIndex( nIndex ) );
+}
+
+
+uno::Any SAL_CALL ScVbaBorders::getColor() throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ uno::Any color;
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ if( XlBordersIndex::xlDiagonalDown != supportedIndexTable[i] && XlBordersIndex::xlDiagonalUp != supportedIndexTable[i] )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ if( color.hasValue() )
+ {
+ if( color != xBorder->getColor() )
+ return uno::makeAny( uno::Reference< uno::XInterface >() );
+ }
+ else
+ color = xBorder->getColor();
+ }
+ }
+ return color;
+}
+void SAL_CALL ScVbaBorders::setColor( const uno::Any& _color ) throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ xBorder->setColor( _color );
+ }
+}
+uno::Any SAL_CALL ScVbaBorders::getColorIndex() throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ uno::Any nColorIndex;
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ if( XlBordersIndex::xlDiagonalDown != supportedIndexTable[i] && XlBordersIndex::xlDiagonalUp != supportedIndexTable[i] )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ if( nColorIndex.hasValue() )
+ {
+ if( nColorIndex != xBorder->getColorIndex() )
+ return uno::makeAny( uno::Reference< uno::XInterface >() );
+ }
+ else
+ nColorIndex = xBorder->getColorIndex();
+ }
+ }
+ return nColorIndex;
+}
+void SAL_CALL ScVbaBorders::setColorIndex( const uno::Any& _colorindex ) throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ xBorder->setColorIndex( _colorindex );
+ }
+}
+
+bool
+lcl_areAllLineWidthsSame( const table::TableBorder& maTableBorder, bool bIsCell )
+{
+
+ bool bRes = false;
+ if (bIsCell)
+ {
+ bRes = ((maTableBorder.TopLine.OuterLineWidth == maTableBorder.BottomLine.OuterLineWidth) &&
+(maTableBorder.TopLine.OuterLineWidth == maTableBorder.LeftLine.OuterLineWidth) &&
+(maTableBorder.TopLine.OuterLineWidth == maTableBorder.RightLine.OuterLineWidth));
+ }
+ else
+ {
+ bRes = ((maTableBorder.TopLine.OuterLineWidth == maTableBorder.BottomLine.OuterLineWidth) &&
+(maTableBorder.TopLine.OuterLineWidth == maTableBorder.LeftLine.OuterLineWidth) &&
+(maTableBorder.TopLine.OuterLineWidth == maTableBorder.HorizontalLine.OuterLineWidth) &&
+(maTableBorder.TopLine.OuterLineWidth == maTableBorder.VerticalLine.OuterLineWidth) &&
+(maTableBorder.TopLine.OuterLineWidth == maTableBorder.RightLine.OuterLineWidth));
+ }
+ return bRes;
+}
+
+uno::Any SAL_CALL ScVbaBorders::getLineStyle() throw (uno::RuntimeException)
+{
+ table::TableBorder maTableBorder;
+ m_xProps->getPropertyValue( sTableBorder ) >>= maTableBorder;
+
+ sal_Int32 aLinestyle = XlLineStyle::xlLineStyleNone;
+
+ if ( lcl_areAllLineWidthsSame( maTableBorder, bRangeIsSingleCell ))
+ {
+ if (maTableBorder.TopLine.LineDistance != 0)
+ {
+ aLinestyle = XlLineStyle::xlDouble;
+ }
+ else if ( maTableBorder.TopLine.OuterLineWidth != 0 )
+ {
+ aLinestyle = XlLineStyle::xlContinuous;
+ }
+ }
+ return uno::makeAny( aLinestyle );
+}
+void SAL_CALL ScVbaBorders::setLineStyle( const uno::Any& _linestyle ) throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ xBorder->setLineStyle( _linestyle );
+ }
+}
+uno::Any SAL_CALL ScVbaBorders::getWeight() throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ uno::Any weight;
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ if( XlBordersIndex::xlDiagonalDown != supportedIndexTable[i] && XlBordersIndex::xlDiagonalUp != supportedIndexTable[i] )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ if( weight.hasValue() )
+ {
+ if( weight != xBorder->getWeight() )
+ return uno::makeAny( uno::Reference< uno::XInterface >() );
+ }
+ else
+ weight = xBorder->getWeight();
+ }
+ }
+ return weight;
+}
+void SAL_CALL ScVbaBorders::setWeight( const uno::Any& _weight ) throw (uno::RuntimeException)
+{
+ sal_Int32 count = getCount();
+ for( sal_Int32 i = 0; i < count ; i++ )
+ {
+ uno::Reference< XBorder > xBorder( getItemByIntIndex( supportedIndexTable[i] ), uno::UNO_QUERY_THROW );
+ xBorder->setWeight( _weight );
+ }
+}
+
+
+rtl::OUString&
+ScVbaBorders::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaBorders") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaBorders::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Borders" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaborders.hxx b/sc/source/ui/vba/vbaborders.hxx
new file mode 100644
index 000000000000..d6784691c488
--- /dev/null
+++ b/sc/source/ui/vba/vbaborders.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_BORDERS_HXX
+#define SC_VBA_BORDERS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XBorders.hpp>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XBorders > ScVbaBorders_BASE;
+class ScVbaPalette;
+class ScVbaBorders : public ScVbaBorders_BASE
+{
+ // XEnumerationAccess
+ virtual css::uno::Any getItemByIntIndex( const sal_Int32 nIndex ) throw (css::uno::RuntimeException);
+ bool bRangeIsSingleCell;
+ css::uno::Reference< css::beans::XPropertySet > m_xProps;
+public:
+ ScVbaBorders( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::table::XCellRange >& xRange, ScVbaPalette& rPalette );
+ virtual ~ScVbaBorders() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+
+ // XBorders
+
+ // ScVbaCollectionBaseImpl
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ virtual css::uno::Any SAL_CALL getColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setColor( const css::uno::Any& _color ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getColorIndex() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getLineStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLineStyle( const css::uno::Any& _linestyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWeight( const css::uno::Any& ) throw (css::uno::RuntimeException);
+ // xxxxBASE
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_BORDERS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacharacters.cxx b/sc/source/ui/vba/vbacharacters.cxx
new file mode 100644
index 000000000000..5d12facad12b
--- /dev/null
+++ b/sc/source/ui/vba/vbacharacters.cxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacharacters.hxx"
+
+#include "vbaglobals.hxx"
+#include "vbafont.hxx"
+
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaCharacters::ScVbaCharacters( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, const uno::Reference< text::XSimpleText>& xRange,const css::uno::Any& Start, const css::uno::Any& Length, sal_Bool Replace ) throw ( css::lang::IllegalArgumentException ) : ScVbaCharacters_BASE( xParent, xContext ), m_xSimpleText(xRange), m_aPalette( dPalette), nLength(-1), nStart(1), bReplace( Replace )
+{
+ Start >>= nStart;
+ if ( nStart < 1 )
+ nStart = 1; // silently correct user error ( as ms )
+ nStart--; // OOo is 0 based
+ Length >>=nLength;
+ uno::Reference< text::XTextCursor > xTextCursor( m_xSimpleText->createTextCursor(), uno::UNO_QUERY_THROW );
+ xTextCursor->collapseToStart();
+ if ( nStart )
+ {
+ if ( ( nStart + 1 ) > m_xSimpleText->getString().getLength() )
+ //nStart = m_xSimpleText->getString().getLength();
+ xTextCursor->gotoEnd( sal_False );
+ xTextCursor->goRight( nStart, sal_False );
+ }
+ if ( nLength < 0 ) // expand to end
+ xTextCursor->gotoEnd( sal_True );
+ else
+ xTextCursor->goRight( nLength, sal_True );
+ m_xTextRange.set( xTextCursor, uno::UNO_QUERY_THROW );
+
+}
+
+::rtl::OUString SAL_CALL
+ScVbaCharacters::getCaption() throw (css::uno::RuntimeException)
+{
+ return m_xTextRange->getString();
+}
+void SAL_CALL
+ScVbaCharacters::setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException)
+{
+ m_xTextRange->setString( _caption );
+
+}
+
+::sal_Int32 SAL_CALL
+ScVbaCharacters::getCount() throw (css::uno::RuntimeException)
+{
+ return getCaption().getLength();
+}
+
+::rtl::OUString SAL_CALL
+ScVbaCharacters::getText() throw (css::uno::RuntimeException)
+{
+ return getCaption();
+}
+void SAL_CALL
+ScVbaCharacters::setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException)
+{
+ setCaption( _text );
+}
+uno::Reference< excel::XFont > SAL_CALL
+ScVbaCharacters::getFont() throw (css::uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xTextRange, uno::UNO_QUERY_THROW );
+ return uno::Reference< excel::XFont >( new ScVbaFont( this, mxContext, m_aPalette, xProps ) );
+}
+void SAL_CALL
+ScVbaCharacters::setFont( const uno::Reference< excel::XFont >& /*_font*/ ) throw (css::uno::RuntimeException)
+{
+ // #TODO #FIXME needs implementation, or can't be done?
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Not Implemented") ), uno::Reference< XInterface >() );
+}
+
+
+// Methods
+void SAL_CALL
+ScVbaCharacters::Insert( const ::rtl::OUString& String ) throw (css::uno::RuntimeException)
+{
+ m_xSimpleText->insertString( m_xTextRange, String, bReplace );
+}
+
+void SAL_CALL
+ScVbaCharacters::Delete( ) throw (css::uno::RuntimeException)
+{
+ // #FIXME #TODO is this a bit suspect?, I wonder should the contents
+ // of the cell be deleted from the parent ( range )
+ m_xSimpleText->setString(rtl::OUString());
+}
+
+
+rtl::OUString&
+ScVbaCharacters::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCharacters") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaCharacters::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Characters" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacharacters.hxx b/sc/source/ui/vba/vbacharacters.hxx
new file mode 100644
index 000000000000..a0a6c350282c
--- /dev/null
+++ b/sc/source/ui/vba/vbacharacters.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHARACTERS_HXX
+#define SC_VBA_CHARACTERS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <ooo/vba/excel/XCharacters.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/text/XSimpleText.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+#include "vbapalette.hxx"
+typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaCharacters_BASE;
+
+class ScVbaCharacters : public ScVbaCharacters_BASE
+{
+private:
+ css::uno::Reference< css::text::XTextRange > m_xTextRange;
+ css::uno::Reference< css::text::XSimpleText > m_xSimpleText;
+ ScVbaPalette m_aPalette;
+ sal_Int16 nLength;
+ sal_Int16 nStart;
+ // Add becuase of MSO has diferent behavior.
+ sal_Bool bReplace;
+public:
+ ScVbaCharacters( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const ScVbaPalette& dPalette, const css::uno::Reference< css::text::XSimpleText >& xRange, const css::uno::Any& Start, const css::uno::Any& Length, sal_Bool bReplace = sal_False ) throw ( css::lang::IllegalArgumentException );
+
+ virtual ~ScVbaCharacters() {}
+ // Attributes
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setText( const ::rtl::OUString& _text ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& _font ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Insert( const ::rtl::OUString& String ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
+
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+
+#endif /* SC_VBA_CHARACTER_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbachart.cxx b/sc/source/ui/vba/vbachart.cxx
new file mode 100644
index 000000000000..fb02586e62f5
--- /dev/null
+++ b/sc/source/ui/vba/vbachart.cxx
@@ -0,0 +1,1255 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbachart.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/chart/XAxisXSupplier.hpp>
+#include <com/sun/star/chart/XAxisYSupplier.hpp>
+#include <com/sun/star/chart/XAxisZSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
+#include <com/sun/star/chart/XChartDataArray.hpp>
+#include <com/sun/star/chart/ChartSymbolType.hpp>
+#include <com/sun/star/chart/ChartSolidType.hpp>
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
+#include <com/sun/star/chart/ChartDataCaption.hpp>
+#include <ooo/vba/excel/XlChartType.hpp>
+#include <ooo/vba/excel/XlRowCol.hpp>
+#include <ooo/vba/excel/XlAxisType.hpp>
+#include <ooo/vba/excel/XlAxisGroup.hpp>
+
+#include <basic/sberrors.hxx>
+#include "vbachartobject.hxx"
+#include "vbarange.hxx"
+#include "vbacharttitle.hxx"
+#include "vbaaxes.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+using namespace ::ooo::vba::excel::XlChartType;
+using namespace ::ooo::vba::excel::XlRowCol;
+using namespace ::ooo::vba::excel::XlAxisType;
+using namespace ::ooo::vba::excel::XlAxisGroup;
+
+const rtl::OUString CHART_NAME( RTL_CONSTASCII_USTRINGPARAM("Name") );
+// #TODO move this constant to vbaseries.[ch]xx ( when it exists )
+const rtl::OUString DEFAULTSERIESPREFIX( RTL_CONSTASCII_USTRINGPARAM("Series") );
+const rtl::OUString DATAROWSOURCE( RTL_CONSTASCII_USTRINGPARAM("DataRowSource") );
+const rtl::OUString UPDOWN( RTL_CONSTASCII_USTRINGPARAM("UpDown") );
+const rtl::OUString VOLUME( RTL_CONSTASCII_USTRINGPARAM("Volume") );
+const rtl::OUString LINES( RTL_CONSTASCII_USTRINGPARAM("Lines") );
+const rtl::OUString SPLINETYPE( RTL_CONSTASCII_USTRINGPARAM("SplineType") );
+const rtl::OUString SYMBOLTYPE( RTL_CONSTASCII_USTRINGPARAM("SymbolType") );
+const rtl::OUString DEEP( RTL_CONSTASCII_USTRINGPARAM("Deep") );
+const rtl::OUString SOLIDTYPE( RTL_CONSTASCII_USTRINGPARAM("SolidType") );
+const rtl::OUString VERTICAL( RTL_CONSTASCII_USTRINGPARAM("Vertical") );
+const rtl::OUString PERCENT( RTL_CONSTASCII_USTRINGPARAM("Percent") );
+const rtl::OUString STACKED( RTL_CONSTASCII_USTRINGPARAM("Stacked") );
+const rtl::OUString DIM3D( RTL_CONSTASCII_USTRINGPARAM("Dim3D") );
+const rtl::OUString HASMAINTITLE( RTL_CONSTASCII_USTRINGPARAM("HasMainTitle") );
+const rtl::OUString HASLEGEND( RTL_CONSTASCII_USTRINGPARAM("HasLegend") );
+const rtl::OUString DATACAPTION( RTL_CONSTASCII_USTRINGPARAM("DataCaption") );
+
+ScVbaChart::ScVbaChart( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::lang::XComponent >& _xChartComponent, const css::uno::Reference< css::table::XTableChart >& _xTableChart ) : ChartImpl_BASE( _xParent, _xContext ), mxTableChart( _xTableChart )
+{
+ mxChartDocument.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
+ // #TODO is is possible that the XPropertySet interface is not set
+ // code in setPlotBy seems to indicate that this is possible? but
+ // additionally there is no check in most of the places where it is used
+ // ( and therefore could possibly be NULL )
+ // I'm going to let it throw for the moment ( npower )
+ mxDiagramPropertySet.set( mxChartDocument->getDiagram(), uno::UNO_QUERY_THROW );
+ mxChartPropertySet.set( _xChartComponent, uno::UNO_QUERY_THROW ) ;
+}
+
+::rtl::OUString SAL_CALL
+ScVbaChart::getName() throw (css::uno::RuntimeException)
+{
+ rtl::OUString sName;
+ uno::Reference< beans::XPropertySet > xProps( mxChartDocument, uno::UNO_QUERY_THROW );
+ try
+ {
+ xProps->getPropertyValue( CHART_NAME ) >>= sName;
+ }
+ catch( uno::Exception e ) // swallow exceptions
+ {
+ }
+ return sName;
+}
+
+uno::Any SAL_CALL
+ScVbaChart::SeriesCollection(const uno::Any&) throw (uno::RuntimeException)
+{
+ return uno::Any();
+}
+
+::sal_Int32 SAL_CALL
+ScVbaChart::getChartType() throw ( uno::RuntimeException, script::BasicErrorException)
+{
+ sal_Int32 nChartType = -1;
+ try
+ {
+ rtl::OUString sDiagramType = mxChartDocument->getDiagram()->getDiagramType();
+ if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.chart.AreaDiagram" ))))
+ {
+ if (is3D())
+ {
+ nChartType = getStackedType(xl3DAreaStacked, xl3DAreaStacked100, xl3DArea);
+ }
+ else
+ {
+ nChartType = getStackedType(xlAreaStacked, xlAreaStacked100, xlArea);
+ }
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram"))))
+ {
+ if (is3D())
+ nChartType = xl3DPie;
+ else
+ nChartType = xlPie; /*TODO XlChartType xlPieExploded, XlChartType xlPieOfPie */
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram"))))
+ {
+ sal_Int32 nSolidType = chart::ChartSolidType::RECTANGULAR_SOLID;
+ if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
+ { //in 2D diagrams 'SolidType' may not be set
+ if (is3D())
+ mxDiagramPropertySet->getPropertyValue(SOLIDTYPE) >>= nSolidType;
+ }
+ switch (nSolidType)
+ {
+ case chart::ChartSolidType::CONE:
+ nChartType = getSolidType(xlConeCol, xlConeColStacked, xlConeColStacked100, xlConeColClustered, xlConeBarStacked, xlConeBarStacked100, xlConeBarClustered);
+ break;
+ case chart::ChartSolidType::CYLINDER:
+ nChartType = getSolidType(xlCylinderCol, xlCylinderColStacked, xlCylinderColStacked100, xlCylinderColClustered, xlCylinderBarStacked, xlCylinderBarStacked100, xlCylinderBarClustered);
+ break;
+ case chart::ChartSolidType::PYRAMID:
+ nChartType = getSolidType(xlPyramidCol, xlPyramidColStacked, xlPyramidColStacked100, xlPyramidColClustered, xlPyramidBarStacked, xlPyramidBarStacked100, xlPyramidBarClustered);
+ break;
+ default: // RECTANGULAR_SOLID
+ if (is3D())
+ {
+ nChartType = getSolidType(xl3DColumn, xl3DColumnStacked, xl3DColumnStacked100, xl3DColumnClustered, xl3DBarStacked, xl3DBarStacked100, xl3DBarClustered);
+ }
+ else
+ {
+ nChartType = getSolidType(xlColumnClustered, xlColumnStacked, xlColumnStacked100, xlColumnClustered, xlBarStacked, xlBarStacked100, xlBarClustered);
+ }
+ break;
+ }
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram"))))
+ {
+ sal_Bool bVolume = sal_False;
+ mxDiagramPropertySet->getPropertyValue(VOLUME) >>= bVolume;
+ if (bVolume)
+ {
+ nChartType = getStockUpDownValue(xlStockVOHLC, xlStockVHLC);
+ }
+ else
+ {
+ nChartType = getStockUpDownValue(xlStockOHLC, xlStockHLC);
+ }
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram"))))
+ {
+ sal_Bool bHasLines = sal_False;
+ mxDiagramPropertySet->getPropertyValue(LINES) >>= bHasLines;
+ sal_Int32 nSplineType = 0;
+ mxDiagramPropertySet->getPropertyValue(SPLINETYPE) >>= nSplineType;
+ if (nSplineType == 1)
+ {
+ nChartType = getMarkerType(xlXYScatterSmooth, xlXYScatterSmoothNoMarkers);
+ }
+ else if (bHasLines)
+ {
+ nChartType = getMarkerType(xlXYScatterLines, xlXYScatterLinesNoMarkers);
+ }
+ else
+ {
+ nChartType = xlXYScatter;
+ }
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram"))))
+ {
+ if (is3D())
+ {
+ nChartType = xl3DLine;
+ }
+ else if (hasMarkers())
+ {
+ nChartType = getStackedType(xlLineMarkersStacked, xlLineMarkersStacked100, xlLineMarkers);
+ }
+ else
+ {
+ nChartType = getStackedType(xlLineStacked, xlLineStacked100, xlLine);
+ }
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram"))))
+ {
+ nChartType = xlDoughnut; // TODO DoughnutExploded ??
+ }
+ else if (sDiagramType.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram"))))
+ {
+ nChartType = getMarkerType(xlRadarMarkers, xlRadar);
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return nChartType;
+}
+
+void SAL_CALL
+ScVbaChart::setChartType( ::sal_Int32 _nChartType ) throw ( uno::RuntimeException, script::BasicErrorException)
+{
+try
+{
+ switch (_nChartType)
+ {
+ case xlColumnClustered:
+ case xlColumnStacked:
+ case xlColumnStacked100:
+ case xl3DColumnClustered:
+ case xl3DColumnStacked:
+ case xl3DColumnStacked100:
+ case xl3DColumn:
+ case xlBarClustered:
+ case xlBarStacked:
+ case xlBarStacked100:
+ case xl3DBarClustered:
+ case xl3DBarStacked:
+ case xl3DBarStacked100:
+ case xlConeColClustered:
+ case xlConeColStacked:
+ case xlConeColStacked100:
+ case xlConeBarClustered:
+ case xlConeBarStacked:
+ case xlConeBarStacked100:
+ case xlConeCol:
+ case xlPyramidColClustered:
+ case xlPyramidColStacked:
+ case xlPyramidColStacked100:
+ case xlPyramidBarClustered:
+ case xlPyramidBarStacked:
+ case xlPyramidBarStacked100:
+ case xlPyramidCol:
+ case xlCylinderColClustered:
+ case xlCylinderColStacked:
+ case xlCylinderColStacked100:
+ case xlCylinderBarClustered:
+ case xlCylinderBarStacked:
+ case xlCylinderBarStacked100:
+ case xlCylinderCol:
+ case xlSurface: // not possible
+ case xlSurfaceWireframe:
+ case xlSurfaceTopView:
+ case xlSurfaceTopViewWireframe:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.BarDiagram")));
+ break;
+ case xlLine:
+ case xl3DLine:
+ case xlLineStacked:
+ case xlLineStacked100:
+ case xlLineMarkers:
+ case xlLineMarkersStacked:
+ case xlLineMarkersStacked100:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.LineDiagram")));
+ break;
+ case xl3DArea:
+ case xlArea:
+ case xlAreaStacked:
+ case xlAreaStacked100:
+ case xl3DAreaStacked:
+ case xl3DAreaStacked100:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.AreaDiagram")) );
+ break;
+ case xlDoughnut:
+ case xlDoughnutExploded:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.DonutDiagram") ) );
+ break;
+ case xlStockHLC:
+ case xlStockOHLC:
+ case xlStockVHLC:
+ case xlStockVOHLC:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.StockDiagram")));
+ mxDiagramPropertySet->setPropertyValue( UPDOWN, uno::makeAny(sal_Bool((_nChartType == xlStockOHLC) || (_nChartType == xlStockVOHLC))));
+ mxDiagramPropertySet->setPropertyValue(VOLUME, uno::makeAny(sal_Bool((_nChartType == xlStockVHLC) || (_nChartType == xlStockVOHLC))));
+ break;
+
+ case xlPieOfPie: // not possible
+ case xlPieExploded: // SegmentOffset an ChartDataPointProperties ->am XDiagram abholen //wie macht Excel das?
+ case xl3DPieExploded:
+ case xl3DPie:
+ case xlPie:
+ case xlBarOfPie: // not possible (Zoom pie)
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.PieDiagram")));
+ break;
+
+ case xlRadar:
+ case xlRadarMarkers:
+ case xlRadarFilled:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.NetDiagram")));
+ break;
+ case xlXYScatter:
+ case xlBubble: // not possible
+ case xlBubble3DEffect: // not possible
+ case xlXYScatterLines:
+ case xlXYScatterLinesNoMarkers:
+ case xlXYScatterSmooth:
+ case xlXYScatterSmoothNoMarkers:
+ setDiagram( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart.XYDiagram")));
+ switch(_nChartType)
+ {
+ case xlXYScatter:
+ case xlBubble: // not possible
+ case xlBubble3DEffect: // not possible
+ mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_False ));
+ break;
+ case xlXYScatterLines:
+ case xlXYScatterLinesNoMarkers:
+ mxDiagramPropertySet->setPropertyValue(LINES, uno::makeAny( sal_True ));
+ break;
+ case xlXYScatterSmooth:
+ case xlXYScatterSmoothNoMarkers:
+ mxDiagramPropertySet->setPropertyValue(SPLINETYPE, uno::makeAny( sal_Int32(1)));
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_CONVERSION, rtl::OUString() );
+ }
+
+ switch (_nChartType)
+ {
+ case xlLineMarkers:
+ case xlLineMarkersStacked:
+ case xlLineMarkersStacked100:
+ case xlRadarMarkers:
+ case xlXYScatterLines:
+ case xlXYScatterSmooth:
+ case xlXYScatter:
+ case xlBubble: // not possible
+ case xlBubble3DEffect: // not possible
+ mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny( chart::ChartSymbolType::AUTO));
+ break;
+ default:
+ if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SYMBOLTYPE))
+ {
+ mxDiagramPropertySet->setPropertyValue(SYMBOLTYPE, uno::makeAny(chart::ChartSymbolType::NONE));
+ }
+ break;
+ }
+
+ switch (_nChartType)
+ {
+ case xlConeCol:
+ case xlPyramidCol:
+ case xlCylinderCol:
+ case xl3DColumn:
+ case xlSurface: // not possible
+ case xlSurfaceWireframe:
+ case xlSurfaceTopView:
+ case xlSurfaceTopViewWireframe:
+ mxDiagramPropertySet->setPropertyValue(DEEP,uno::makeAny( sal_True ));
+ break;
+ default:
+ if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DEEP))
+ {
+ mxDiagramPropertySet->setPropertyValue(DEEP, uno::makeAny( sal_False));
+ }
+ break;
+ }
+
+
+ switch (_nChartType)
+ {
+ case xlConeColClustered:
+ case xlConeColStacked:
+ case xlConeColStacked100:
+ case xlConeBarClustered:
+ case xlConeBarStacked:
+ case xlConeBarStacked100:
+ case xlConeCol:
+ mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CONE));
+ break;
+ case xlPyramidColClustered:
+ case xlPyramidColStacked:
+ case xlPyramidColStacked100:
+ case xlPyramidBarClustered:
+ case xlPyramidBarStacked:
+ case xlPyramidBarStacked100:
+ case xlPyramidCol:
+ mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::PYRAMID));
+ break;
+ case xlCylinderColClustered:
+ case xlCylinderColStacked:
+ case xlCylinderColStacked100:
+ case xlCylinderBarClustered:
+ case xlCylinderBarStacked:
+ case xlCylinderBarStacked100:
+ case xlCylinderCol:
+ mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::CYLINDER));
+ break;
+ default:
+ if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(SOLIDTYPE))
+ {
+ mxDiagramPropertySet->setPropertyValue(SOLIDTYPE, uno::makeAny(chart::ChartSolidType::RECTANGULAR_SOLID));
+ }
+ break;
+ }
+
+ switch ( _nChartType)
+ {
+ case xlConeCol:
+ case xlConeColClustered:
+ case xlConeColStacked:
+ case xlConeColStacked100:
+ case xlPyramidColClustered:
+ case xlPyramidColStacked:
+ case xlPyramidColStacked100:
+ case xlCylinderColClustered:
+ case xlCylinderColStacked:
+ case xlCylinderColStacked100:
+ case xlColumnClustered:
+ case xlColumnStacked:
+ case xlColumnStacked100:
+ case xl3DColumnClustered:
+ case xl3DColumnStacked:
+ case xl3DColumnStacked100:
+ case xlSurface: // not possible
+ case xlSurfaceWireframe:
+ case xlSurfaceTopView:
+ case xlSurfaceTopViewWireframe:
+ mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny( sal_True));
+ break;
+ default:
+ if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(VERTICAL))
+ {
+ mxDiagramPropertySet->setPropertyValue(VERTICAL, uno::makeAny(sal_False));
+ }
+ break;
+ }
+
+ switch (_nChartType)
+ {
+ case xlColumnStacked:
+ case xl3DColumnStacked:
+ case xlBarStacked:
+ case xl3DBarStacked:
+ case xlLineStacked:
+ case xlLineMarkersStacked:
+ case xlAreaStacked:
+ case xl3DAreaStacked:
+ case xlCylinderColStacked:
+ case xlCylinderBarStacked:
+ case xlConeColStacked:
+ case xlConeBarStacked:
+ case xlPyramidColStacked:
+ case xlPyramidBarStacked:
+ mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False ));
+ mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True ));
+ break;
+ case xlPyramidColStacked100:
+ case xlPyramidBarStacked100:
+ case xlConeColStacked100:
+ case xlConeBarStacked100:
+ case xlCylinderBarStacked100:
+ case xlCylinderColStacked100:
+ case xl3DAreaStacked100:
+ case xlLineMarkersStacked100:
+ case xlAreaStacked100:
+ case xlLineStacked100:
+ case xl3DBarStacked100:
+ case xlBarStacked100:
+ case xl3DColumnStacked100:
+ case xlColumnStacked100:
+ mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_True));
+ mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_True ));
+ break;
+ default:
+ mxDiagramPropertySet->setPropertyValue(PERCENT, uno::makeAny( sal_False));
+ mxDiagramPropertySet->setPropertyValue(STACKED, uno::makeAny( sal_False));
+ break;
+ }
+ switch (_nChartType)
+ {
+ case xl3DArea:
+ case xl3DAreaStacked:
+ case xl3DAreaStacked100:
+ case xl3DBarClustered:
+ case xl3DBarStacked:
+ case xl3DBarStacked100:
+ case xl3DColumn:
+ case xl3DColumnClustered:
+ case xl3DColumnStacked:
+ case xl3DColumnStacked100:
+ case xl3DLine:
+ case xl3DPie:
+ case xl3DPieExploded:
+ case xlConeColClustered:
+ case xlConeColStacked:
+ case xlConeColStacked100:
+ case xlConeBarClustered:
+ case xlConeBarStacked:
+ case xlConeBarStacked100:
+ case xlConeCol:
+ case xlPyramidColClustered:
+ case xlPyramidColStacked:
+ case xlPyramidColStacked100:
+ case xlPyramidBarClustered:
+ case xlPyramidBarStacked:
+ case xlPyramidBarStacked100:
+ case xlPyramidCol:
+ case xlCylinderColClustered:
+ case xlCylinderColStacked:
+ case xlCylinderColStacked100:
+ case xlCylinderBarClustered:
+ case xlCylinderBarStacked:
+ case xlCylinderBarStacked100:
+ case xlCylinderCol:
+ mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_True));
+ break;
+ default:
+ if (mxDiagramPropertySet->getPropertySetInfo()->hasPropertyByName(DIM3D))
+ {
+ mxDiagramPropertySet->setPropertyValue(DIM3D, uno::makeAny( sal_False));
+ }
+ break;
+ }
+ }
+ catch ( uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+void SAL_CALL
+ScVbaChart::Activate() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ // #TODO how are Chart sheets handled ( I know we don't even consider
+ // them in the worksheets/sheets collections ), but.....???
+ // note: in vba for excel the parent of a Chart sheet is a workbook,
+ // e.g. 'ThisWorkbook'
+ uno::Reference< XHelperInterface > xParent( getParent() );
+ ScVbaChartObject* pChartObj = static_cast< ScVbaChartObject* >( xParent.get() );
+ if ( pChartObj )
+ pChartObj->Activate();
+ else
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "no ChartObject as parent" ) ) );
+}
+
+void SAL_CALL
+ScVbaChart::setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange >& _xCalcRange, const css::uno::Any& _aPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Sequence< table::CellRangeAddress > mRangeAddresses(1);
+ table::CellRangeAddress mSingleRangeAddress;
+
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( _xCalcRange->getCellRange(), uno::UNO_QUERY_THROW );
+ mSingleRangeAddress = xAddressable->getRangeAddress();
+
+ mRangeAddresses[0] = mSingleRangeAddress;
+
+ mxTableChart->setRanges(mRangeAddresses);
+
+ sal_Bool bsetRowHeaders = sal_False;
+ sal_Bool bsetColumnHeaders = sal_False;
+
+ ScVbaRange* pRange = static_cast< ScVbaRange* >( _xCalcRange.get() );
+ if ( pRange )
+ {
+ ScDocument* pDoc = pRange->getScDocument();
+ if ( pDoc )
+ {
+ bsetRowHeaders = pDoc->HasRowHeader( static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ) );;
+ bsetColumnHeaders = pDoc->HasColHeader( static_cast< SCCOL >( mSingleRangeAddress.StartColumn ), static_cast< SCROW >( mSingleRangeAddress.StartRow ), static_cast< SCCOL >( mSingleRangeAddress.EndColumn ), static_cast< SCROW >( mSingleRangeAddress.EndRow ), static_cast< SCTAB >( mSingleRangeAddress.Sheet ));
+;
+ }
+ }
+ mxTableChart->setHasRowHeaders(bsetRowHeaders);
+ mxTableChart->setHasColumnHeaders(bsetColumnHeaders);
+
+ if ((!bsetColumnHeaders) || (!bsetRowHeaders))
+ {
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ if (!bsetColumnHeaders)
+ {
+ xChartDataArray->setColumnDescriptions( getDefaultSeriesDescriptions(xChartDataArray->getColumnDescriptions().getLength() ));
+ }
+ if (!bsetRowHeaders)
+ {
+ xChartDataArray->setRowDescriptions(getDefaultSeriesDescriptions(xChartDataArray->getRowDescriptions().getLength() ));
+ }
+ }
+
+ if ( _aPlotBy.hasValue() )
+ {
+ sal_Int32 nVal = 0;
+ _aPlotBy >>= nVal;
+ setPlotBy( nVal );
+ }
+ else
+ {
+ sal_Int32 nRows = mSingleRangeAddress.EndRow - mSingleRangeAddress.StartRow;
+ sal_Int32 nCols = mSingleRangeAddress.EndColumn - mSingleRangeAddress.StartColumn;
+ // AutoDetect emulation
+ if ( nRows > nCols )
+ setPlotBy( xlColumns );
+ else if ( nRows <= nCols )
+ setPlotBy( xlRows );
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaChart::getDefaultSeriesDescriptions( sal_Int32 _nCount )
+{
+ uno::Sequence< rtl::OUString > sDescriptions ( _nCount );
+ sal_Int32 nLen = sDescriptions.getLength();
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ sDescriptions[i] = DEFAULTSERIESPREFIX + rtl::OUString::valueOf(i+1);
+ }
+ return sDescriptions;
+}
+
+void
+ScVbaChart::setDefaultChartType() throw ( script::BasicErrorException )
+{
+ setChartType( xlColumnClustered );
+}
+
+void
+ScVbaChart::setPlotBy( ::sal_Int32 _nPlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ try
+ {
+ if ( !mxDiagramPropertySet.is() )
+ setDefaultChartType();
+ switch (_nPlotBy)
+ {
+ case xlRows:
+ mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE, uno::makeAny( chart::ChartDataRowSource_ROWS ) );
+ break;
+ case xlColumns:
+ mxDiagramPropertySet->setPropertyValue( DATAROWSOURCE, uno::makeAny( chart::ChartDataRowSource_COLUMNS) );
+ break;
+ default:
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+::sal_Int32 SAL_CALL
+ScVbaChart::getPlotBy( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ chart::ChartDataRowSource aChartDataRowSource;
+ mxDiagramPropertySet->getPropertyValue(DATAROWSOURCE) >>= aChartDataRowSource;
+ if (aChartDataRowSource == chart::ChartDataRowSource_COLUMNS)
+ {
+ return xlColumns;
+ }
+ else
+ {
+ return xlRows;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+void
+ScVbaChart::setDiagram( const rtl::OUString& _sDiagramType ) throw( script::BasicErrorException )
+{
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMSF( mxChartDocument, uno::UNO_QUERY_THROW );
+ uno::Reference< chart::XDiagram > xDiagram( xMSF->createInstance( _sDiagramType ), uno::UNO_QUERY_THROW );
+ mxChartDocument->setDiagram( xDiagram );
+ mxDiagramPropertySet.set( xDiagram, uno::UNO_QUERY_THROW );
+ }
+ catch ( uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+// #TODO find out why we have Location/getLocation ? there is afaiks no
+// Location property, just a Location function for the Chart object
+sal_Int32 SAL_CALL
+ScVbaChart::Location() throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return getLocation();
+}
+
+sal_Int32 SAL_CALL
+ScVbaChart::getLocation() throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return -1;
+}
+
+void SAL_CALL
+ScVbaChart::setLocation( ::sal_Int32 /*where*/, const css::uno::Any& /*Name*/ ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ // Helper api just stubs out the code <shrug>
+ // #TODO come back and make sense out of this
+// String sheetName = null;
+//
+// if ((name != null) && name instanceof String) {
+// sheetName = (String) name;
+// }
+// XSpreadsheetDocument xShDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface( XSpreadsheetDocument.class,getXModel() );
+// com.sun.star.sheet.XSpreadsheets xSheets = xShDoc.Sheets();
+//
+// switch (where) {
+// case ClLocationType.clLocationAsObject_value: //{
+//
+// if (sheetName == null) {
+// DebugHelper.writeInfo("Can't embed in Chart without knowing SheetName");
+// return;
+// }
+//
+// try {
+// Any any = (Any) xSheets.getByName(sheetName);
+// chartSheet = (XSpreadsheet) any.getObject();
+//
+// // chartSheet = (XSpreadsheet) xSheets.getByName( sheetName );
+// } catch (NoSuchElementException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+//
+// return;
+// } catch (WrappedTargetException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+//
+// return;
+// } catch (java.lang.Exception e) {
+// e.printStackTrace();
+// }
+//
+// XTableChartsSupplier xTCS = (XTableChartsSupplier) UnoRuntime.queryInterface( XTableChartsSupplier.class, chartSheet);
+// XTableCharts xTableCharts = xTCS.getCharts();
+// XIndexAccess xIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xTableCharts);
+// int numCharts = xIA.getCount();
+// chartName = "Chart " + (numCharts + 1);
+//
+// //}
+// break;
+//
+// case ClLocationType.clLocationAsNewSheet_value:
+// case ClLocationType.clLocationAutomatic_value:default: //{
+// chartName = "Chart 1"; // Since it's a new sheet, it's the first on it...
+//
+// XIndexAccess xSheetIA = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, xSheets);
+//
+// short newSheetNum = (short) (xSheetIA.getCount() + 1);
+//
+// if (sheetName == null){
+// sheetName = "ChartSheet " + newSheetNum; // Why not?
+// }
+// // DPK TODO : Probably should use Sheets to create this!
+// xSheets.insertNewByName(sheetName, newSheetNum);
+//
+// try {
+// chartSheet =
+// (XSpreadsheet) xSheets.getByName(sheetName);
+// } catch (NoSuchElementException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+//
+// return;
+// } catch (WrappedTargetException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+//
+// return;
+// }
+//
+// //}
+// break;
+// }
+//
+// // Last thing should be a call to createChartForReal(), one of them
+// // should succeed.
+// createChartForReal();
+
+}
+
+sal_Bool SAL_CALL
+ScVbaChart::getHasTitle( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bHasTitle = sal_False;
+ try
+ {
+ mxChartPropertySet->getPropertyValue(HASMAINTITLE) >>= bHasTitle;
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return bHasTitle;
+}
+
+void SAL_CALL
+ScVbaChart::setHasTitle( ::sal_Bool bTitle ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ mxChartPropertySet->setPropertyValue(HASMAINTITLE, uno::makeAny( bTitle ));
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+
+}
+
+::sal_Bool SAL_CALL
+ScVbaChart::getHasLegend( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ sal_Bool bHasLegend = sal_False;
+ try
+ {
+ mxChartPropertySet->getPropertyValue(HASLEGEND) >>= bHasLegend;
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return bHasLegend;
+}
+
+void SAL_CALL
+ScVbaChart::setHasLegend( ::sal_Bool bLegend ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ mxChartPropertySet->setPropertyValue(HASLEGEND, uno::makeAny(bLegend));
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+uno::Reference< excel::XChartTitle > SAL_CALL
+ScVbaChart::getChartTitle( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< drawing::XShape > xTitleShape = mxChartDocument->getTitle();
+ // #TODO check parent
+ return new ScVbaChartTitle(this, mxContext, xTitleShape);
+}
+
+uno::Any SAL_CALL
+ScVbaChart::Axes( const uno::Any& Type, const uno::Any& AxisGroup ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ // mmm chart probably is the parent, #TODO check parent
+ uno::Reference< excel::XAxes > xAxes = new ScVbaAxes( this, mxContext, this );
+ if ( !Type.hasValue() )
+ return uno::makeAny( xAxes );
+ return xAxes->Item( Type, AxisGroup );
+}
+bool
+ScVbaChart::is3D() throw ( uno::RuntimeException )
+{
+ // #TODO perhaps provide limited Debughelper functionality
+ sal_Bool is3d = sal_False;
+ mxDiagramPropertySet->getPropertyValue(DIM3D) >>= is3d;
+ return is3d;
+}
+
+sal_Int32
+ScVbaChart::getStackedType( sal_Int32 _nStacked, sal_Int32 _n100PercentStacked, sal_Int32 _nUnStacked ) throw ( uno::RuntimeException )
+{
+ // #TODO perhaps provide limited Debughelper functionality
+ if (isStacked())
+ {
+ if (is100PercentStacked())
+ return _n100PercentStacked;
+ else
+ return _nStacked;
+ }
+ else
+ return _nUnStacked;
+}
+
+bool
+ScVbaChart::isStacked() throw ( uno::RuntimeException )
+{
+ // #TODO perhaps provide limited Debughelper functionality
+ sal_Bool bStacked = sal_False;
+ mxDiagramPropertySet->getPropertyValue(STACKED) >>= bStacked;
+ return bStacked;
+}
+
+bool
+ScVbaChart::is100PercentStacked() throw ( uno::RuntimeException )
+{
+ // #TODO perhaps provide limited Debughelper functionality
+ sal_Bool b100Percent = sal_False;
+ mxDiagramPropertySet->getPropertyValue(PERCENT) >>= b100Percent;
+ return b100Percent;
+}
+
+sal_Int32
+ScVbaChart::getSolidType(sal_Int32 _nDeep, sal_Int32 _nVertiStacked, sal_Int32 _nVerti100PercentStacked, sal_Int32 _nVertiUnStacked, sal_Int32 _nHoriStacked, sal_Int32 _nHori100PercentStacked, sal_Int32 _nHoriUnStacked) throw ( script::BasicErrorException )
+{
+ sal_Bool bIsVertical = true;
+ try
+ {
+ mxDiagramPropertySet->getPropertyValue(VERTICAL) >>= bIsVertical;
+ sal_Bool bIsDeep = false;
+ mxDiagramPropertySet->getPropertyValue(DEEP) >>= bIsDeep;
+
+ if (bIsDeep)
+ {
+ return _nDeep;
+ }
+ else
+ {
+ if (bIsVertical)
+ {
+ return getStackedType(_nVertiStacked, _nVerti100PercentStacked, _nVertiUnStacked);
+ }
+ else
+ {
+ return getStackedType(_nHoriStacked, _nHori100PercentStacked, _nHoriUnStacked);
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+
+sal_Int32
+ScVbaChart::getStockUpDownValue(sal_Int32 _nUpDown, sal_Int32 _nNotUpDown) throw (script::BasicErrorException)
+{
+ sal_Bool bUpDown = sal_False;
+ try
+ {
+ mxDiagramPropertySet->getPropertyValue(UPDOWN) >>= bUpDown;
+ if (bUpDown)
+ {
+ return _nUpDown;
+ }
+ else
+ {
+ return _nNotUpDown;
+ }
+ }
+ catch (uno::Exception& )
+ {
+ rtl::OUString aTemp; // temporary needed for g++ 3.3.5
+ script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return _nNotUpDown;
+}
+
+bool
+ScVbaChart::hasMarkers() throw ( script::BasicErrorException )
+{
+ bool bHasMarkers = false;
+ try
+ {
+ sal_Int32 nSymbol=0;
+ mxDiagramPropertySet->getPropertyValue(SYMBOLTYPE) >>= nSymbol;
+ bHasMarkers = nSymbol != chart::ChartSymbolType::NONE;
+ }
+ catch ( uno::Exception& )
+ {
+ rtl::OUString aTemp; // temporary needed for g++ 3.3.5
+ script::BasicErrorException( aTemp, uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return bHasMarkers;
+}
+
+sal_Int32
+ScVbaChart::getMarkerType(sal_Int32 _nWithMarkers, sal_Int32 _nWithoutMarkers) throw ( script::BasicErrorException )
+{
+ if (hasMarkers())
+ return _nWithMarkers;
+ return _nWithoutMarkers;
+}
+
+void
+ScVbaChart::assignDiagramAttributes()
+{
+ xAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
+ xAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
+ xAxisZSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
+ xTwoAxisXSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
+ xTwoAxisYSupplier.set( mxDiagramPropertySet, uno::UNO_QUERY_THROW );
+}
+
+bool
+ScVbaChart::isSeriesIndexValid(sal_Int32 _seriesindex) throw( script::BasicErrorException )
+{
+ bool bret = false;
+ try
+ {
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ // dblValues = xChartDataArray.getData();
+ //TODO I guess we have to differentiate between XlRowCol
+ if ( !xChartDataArray.is() )
+ {
+ if (getPlotBy() == xlRows)
+ {
+ if ((_seriesindex < xChartDataArray->getRowDescriptions().getLength() ) && (_seriesindex >= 0))
+ bret = true;
+ }
+ else
+ {
+ if ((_seriesindex < xChartDataArray->getColumnDescriptions().getLength() ) && (_seriesindex >= 0))
+ bret = true;
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ if (!bret)
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_OUT_OF_RANGE, rtl::OUString() );
+ }
+ return bret;
+}
+
+bool
+ScVbaChart::areIndicesValid( sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( css::script::BasicErrorException )
+{
+ if (isSeriesIndexValid(_seriesindex))
+ {
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ dblValues = xChartDataArray->getData();
+ return (_valindex < dblValues[_seriesindex].getLength() );
+ }
+ return false;
+}
+
+sal_Int32
+ScVbaChart::getSeriesIndex(rtl::OUString _sseriesname) throw ( script::BasicErrorException )
+{
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ if (getPlotBy() == xlRows)
+ return ContainerUtilities::FieldInList(xChartDataArray->getRowDescriptions(), _sseriesname);
+ return ContainerUtilities::FieldInList(xChartDataArray->getColumnDescriptions(), _sseriesname);
+}
+void
+ScVbaChart::setSeriesName(sal_Int32 _index, rtl::OUString _sname) throw ( script::BasicErrorException )
+{
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ if (isSeriesIndexValid(_index))
+ {
+ uno::Sequence< rtl::OUString > sDescriptions = xChartDataArray->getColumnDescriptions();
+ sDescriptions[_index] = _sname;
+ xChartDataArray->setColumnDescriptions(sDescriptions);
+ }
+}
+
+sal_Int32
+ScVbaChart::getSeriesCount() throw ( script::BasicErrorException )
+{
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+
+ if (getPlotBy() == xlRows)
+ return xChartDataArray->getRowDescriptions().getLength();
+ return xChartDataArray->getColumnDescriptions().getLength();
+
+}
+
+rtl::OUString
+ScVbaChart::getSeriesName(sal_Int32 _index) throw ( script::BasicErrorException )
+{
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ uno::Sequence< rtl::OUString > sDescriptions;
+ rtl::OUString sName;
+ if (isSeriesIndexValid(_index))
+ {
+ if (getPlotBy() == xlRows)
+ sDescriptions = xChartDataArray->getRowDescriptions();
+ else
+ sDescriptions = xChartDataArray->getColumnDescriptions();
+ sName = sDescriptions[_index];
+ }
+ return sName;
+}
+
+double
+ScVbaChart::getValue(sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( script::BasicErrorException )
+{
+ double result = -1.0;
+ if (areIndicesValid(_seriesindex, _valindex))
+ {
+ if (getPlotBy() == xlRows)
+ result = dblValues[_seriesindex][_valindex];
+ else
+ result = dblValues[_valindex][_seriesindex];
+ }
+ return result;
+}
+
+sal_Int32
+ScVbaChart::getValuesCount(sal_Int32 _seriesIndex) throw ( script::BasicErrorException )
+{
+ sal_Int32 nCount = 0;
+ uno::Reference< chart::XChartDataArray > xChartDataArray( mxChartDocument->getData(), uno::UNO_QUERY_THROW );
+ if (isSeriesIndexValid(_seriesIndex))
+ {
+ dblValues = xChartDataArray->getData();
+ if (getPlotBy() == xlRows)
+ nCount = dblValues[_seriesIndex].getLength();
+ else
+ nCount = dblValues.getLength();
+ }
+ return nCount;
+}
+
+
+uno::Reference< excel::XDataLabels >
+ScVbaChart::DataLabels( const uno::Reference< ov::excel::XSeries > /*_oSeries*/ ) throw ( css::script::BasicErrorException )
+{
+ if ( true )
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ // #TODO #FIXE provide implementation
+ return uno::Reference< excel::XDataLabels > ();
+}
+
+bool
+ScVbaChart::getHasDataCaption( const uno::Reference< css::beans::XPropertySet >& _xPropertySet )throw ( script::BasicErrorException )
+{
+ bool bResult = false;
+ try
+ {
+ sal_Int32 nChartDataCaption = 0;
+ _xPropertySet->getPropertyValue(DATACAPTION) >>= nChartDataCaption;
+ bResult = (nChartDataCaption != chart::ChartDataCaption::NONE);
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return bResult;
+}
+
+void
+ScVbaChart::setHasDataCaption( const uno::Reference< beans::XPropertySet >& _xPropertySet, bool _bHasDataLabels )throw ( script::BasicErrorException )
+{
+ try
+ {
+ if ( _bHasDataLabels )
+ _xPropertySet->setPropertyValue(DATACAPTION, uno::makeAny ( chart::ChartDataCaption::VALUE) );
+ else
+ _xPropertySet->setPropertyValue(DATACAPTION, uno::makeAny ( chart::ChartDataCaption::NONE) );
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+uno::Reference< beans::XPropertySet >
+ScVbaChart::getAxisPropertySet(sal_Int32 _nAxisType, sal_Int32 _nAxisGroup) throw ( script::BasicErrorException )
+{
+ assignDiagramAttributes();
+ uno::Reference< beans::XPropertySet > xAxisProps;
+ switch(_nAxisType)
+ {
+ case xlCategory:
+ if (_nAxisGroup == xlPrimary)
+ {
+ xAxisProps = xAxisXSupplier->getXAxis();
+ }
+ else if (_nAxisGroup == xlSecondary)
+ {
+ xAxisProps = xTwoAxisXSupplier->getSecondaryXAxis();
+ }
+ break;
+ case xlSeriesAxis:
+// if (_nAxisGroup == xlPrimary){
+ xAxisProps = xAxisZSupplier->getZAxis();
+ break;
+// }
+// else if (_nAxisGroup == xlSecondary){
+ // return xTwoAxisXSupplier.getSecondaryZAxis();
+ // }
+ case xlValue:
+ if (_nAxisGroup == xlPrimary)
+ xAxisProps = xAxisYSupplier->getYAxis();
+ else if (_nAxisGroup == xlSecondary)
+ xAxisProps = xTwoAxisYSupplier->getSecondaryYAxis();
+ break;
+ default:
+ return xAxisProps;
+ }
+ return xAxisProps;
+}
+
+
+rtl::OUString&
+ScVbaChart::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaChart") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaChart::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Chart" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbachart.hxx b/sc/source/ui/vba/vbachart.hxx
new file mode 100644
index 000000000000..3602baafaa64
--- /dev/null
+++ b/sc/source/ui/vba/vbachart.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHART_HXX
+#define SC_VBA_CHART_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/table/XTableChart.hpp>
+#include <com/sun/star/chart/XChartDocument.hpp>
+#include <com/sun/star/chart/XAxisXSupplier.hpp>
+#include <com/sun/star/chart/XAxisYSupplier.hpp>
+#include <com/sun/star/chart/XAxisZSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisXSupplier.hpp>
+#include <com/sun/star/chart/XTwoAxisYSupplier.hpp>
+#include <ooo/vba/excel/XChart.hpp>
+#include <ooo/vba/excel/XDataLabels.hpp>
+#include <ooo/vba/excel/XSeries.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1<ov::excel::XChart > ChartImpl_BASE;
+
+class ScVbaChart : public ChartImpl_BASE
+{
+friend class ScVbaAxis;
+
+ css::uno::Reference< css::chart::XChartDocument > mxChartDocument;
+ css::uno::Reference< css::table::XTableChart > mxTableChart;
+ css::uno::Reference< css::beans::XPropertySet > mxDiagramPropertySet;
+ css::uno::Reference< css::beans::XPropertySet > mxChartPropertySet;
+ css::uno::Reference< css::chart::XAxisXSupplier > xAxisXSupplier;
+ css::uno::Reference< css::chart::XAxisYSupplier> xAxisYSupplier;
+ css::uno::Reference< css::chart::XAxisZSupplier > xAxisZSupplier;
+ css::uno::Reference< css::chart::XTwoAxisXSupplier > xTwoAxisXSupplier;
+ css::uno::Reference< css::chart::XTwoAxisYSupplier > xTwoAxisYSupplier;
+
+ css::uno::Sequence< rtl::OUString > getDefaultSeriesDescriptions( sal_Int32 nCount );
+ css::uno::Sequence< css::uno::Sequence< double > > dblValues;
+ void setDefaultChartType()throw ( css::script::BasicErrorException ) ;
+ void setDiagram( const rtl::OUString& _sDiagramType) throw( css::script::BasicErrorException );
+ bool isStacked() throw ( css::uno::RuntimeException );
+ bool is100PercentStacked() throw ( css::uno::RuntimeException );
+ sal_Int32 getStackedType( sal_Int32 _nStacked, sal_Int32 _n100PercentStacked, sal_Int32 _nUnStacked ) throw ( css::uno::RuntimeException );
+ sal_Int32 getSolidType(sal_Int32 _nDeep, sal_Int32 _nVertiStacked, sal_Int32 _nVerti100PercentStacked, sal_Int32 _nVertiUnStacked, sal_Int32 _nHoriStacked, sal_Int32 _nHori100PercentStacked, sal_Int32 _nHoriUnStacked) throw ( css::script::BasicErrorException );
+ sal_Int32 getStockUpDownValue(sal_Int32 _nUpDown, sal_Int32 _nNotUpDown) throw (css::script::BasicErrorException);
+ bool hasMarkers() throw ( css::script::BasicErrorException );
+ sal_Int32 getMarkerType(sal_Int32 _nWithMarkers, sal_Int32 _nWithoutMarkers) throw ( css::script::BasicErrorException );
+ void assignDiagramAttributes();
+ void setDefaultSeriesDescriptionLabels(){}
+public:
+ ScVbaChart( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::lang::XComponent >& _xChartComponent, const css::uno::Reference< css::table::XTableChart >& _xTableChart );
+
+ // Non-interface
+ css::uno::Reference< css::beans::XPropertySet > xDiagramPropertySet() { return mxDiagramPropertySet; }
+ bool isSeriesIndexValid(sal_Int32 _seriesindex) throw( css::script::BasicErrorException );
+ bool areIndicesValid(sal_Int32 _seriesindex, sal_Int32 _valindex) throw ( css::script::BasicErrorException );
+ void setSeriesName(sal_Int32 _index, rtl::OUString _sname) throw ( css::script::BasicErrorException );
+ sal_Int32 getSeriesIndex(rtl::OUString _sseriesname) throw ( css::script::BasicErrorException );
+ sal_Int32 getSeriesCount() throw ( css::script::BasicErrorException );
+ rtl::OUString getSeriesName(sal_Int32 _index) throw ( css::script::BasicErrorException );
+ double getValue(sal_Int32 _seriesIndex, sal_Int32 _valindex) throw ( css::script::BasicErrorException );
+ sal_Int32 getValuesCount(sal_Int32 _seriesIndex) throw ( css::script::BasicErrorException );
+ css::uno::Reference< ov::excel::XDataLabels > DataLabels( const css::uno::Reference< ov::excel::XSeries > _oSeries ) throw ( css::script::BasicErrorException );
+ bool getHasDataCaption( const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet )throw ( css::script::BasicErrorException );
+ void setHasDataCaption( const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, bool _bHasDataLabels )throw ( css::script::BasicErrorException );
+ bool is3D() throw ( css::uno::RuntimeException );
+ css::uno::Reference< css::beans::XPropertySet > getAxisPropertySet(sal_Int32 _nAxisType, sal_Int32 _nAxisGroup) throw ( css::script::BasicErrorException );
+ // Methods
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL SeriesCollection(const css::uno::Any&) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getChartType() throw ( css::uno::RuntimeException, css::script::BasicErrorException);
+ virtual void SAL_CALL setChartType( ::sal_Int32 _charttype ) throw ( css::uno::RuntimeException, css::script::BasicErrorException);
+ virtual void SAL_CALL Activate( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setSourceData( const css::uno::Reference< ::ooo::vba::excel::XRange >& range, const css::uno::Any& PlotBy ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL Location( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getLocation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setLocation( ::sal_Int32 where, const css::uno::Any& Name ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getHasTitle( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setHasTitle( ::sal_Bool bTitle ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getHasLegend( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setHasLegend( ::sal_Bool bLegend ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setPlotBy( ::sal_Int32 xlRowCol ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getPlotBy( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XChartTitle > SAL_CALL getChartTitle( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Axes( const css::uno::Any& Type, const css::uno::Any& AxisGroup ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+
+#endif //SC_VBA_WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbachartobject.cxx b/sc/source/ui/vba/vbachartobject.cxx
new file mode 100644
index 000000000000..839b7cf27cc0
--- /dev/null
+++ b/sc/source/ui/vba/vbachartobject.cxx
@@ -0,0 +1,213 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbachart.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/script/BasicErrorException.hpp>
+#include <basic/sberrors.hxx>
+#include "vbachartobject.hxx"
+#include "vbachartobjects.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+const rtl::OUString CHART_NAME( RTL_CONSTASCII_USTRINGPARAM("Name") );
+const rtl::OUString PERSIST_NAME( RTL_CONSTASCII_USTRINGPARAM("PersistName") );
+
+ScVbaChartObject::ScVbaChartObject( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::table::XTableChart >& _xTableChart, const css::uno::Reference< css::drawing::XDrawPageSupplier >& _xDrawPageSupplier ) : ChartObjectImpl_BASE( _xParent, _xContext ), xTableChart( _xTableChart ), xDrawPageSupplier( _xDrawPageSupplier )
+{
+ xDrawPage = xDrawPageSupplier->getDrawPage();
+ xEmbeddedObjectSupplier.set( xTableChart, uno::UNO_QUERY_THROW );
+ xNamed.set( xTableChart, uno::UNO_QUERY_THROW );
+ sPersistName = getPersistName();
+ xShape = setShape();
+ setName(sPersistName);
+ oShapeHelper.reset(new ShapeHelper(xShape));
+}
+
+rtl::OUString ScVbaChartObject::getPersistName()
+{
+ if ( !sPersistName.getLength() )
+ sPersistName = xNamed->getName();
+ return sPersistName;
+}
+
+uno::Reference< drawing::XShape >
+ScVbaChartObject::setShape() throw ( script::BasicErrorException )
+{
+ try
+ {
+ sal_Int32 nItems = xDrawPage->getCount();
+ for (int i = 0; i < nItems; i++)
+ {
+ xShape.set( xDrawPage->getByIndex(i), uno::UNO_QUERY_THROW );
+ if (xShape->getShapeType().compareToAscii("com.sun.star.drawing.OLE2Shape") == 0 )
+ {
+ uno::Reference< beans::XPropertySet > xShapePropertySet(xShape, uno::UNO_QUERY_THROW );
+ rtl::OUString sName;
+ xShapePropertySet->getPropertyValue(PERSIST_NAME ) >>=sName;
+ if ( sName.equals(sPersistName))
+ {
+ xNamedShape.set( xShape, uno::UNO_QUERY_THROW );
+ return xShape;
+ }
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return NULL;
+}
+
+void SAL_CALL
+ScVbaChartObject::setName( const rtl::OUString& sName ) throw (css::uno::RuntimeException)
+{
+ xNamedShape->setName(sName);
+}
+
+
+::rtl::OUString SAL_CALL
+ScVbaChartObject::getName() throw (css::uno::RuntimeException)
+{
+ return xNamedShape->getName();
+}
+
+void SAL_CALL
+ScVbaChartObject::Delete() throw ( css::script::BasicErrorException )
+{
+ // parent of this object is sheet
+ uno::Reference< excel::XWorksheet > xParent( getParent(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XChartObjects > xColl( xParent->ChartObjects( uno::Any() ), uno::UNO_QUERY_THROW );
+ ScVbaChartObjects* pChartObjectsImpl = static_cast< ScVbaChartObjects* >( xColl.get() );
+ if (pChartObjectsImpl)
+ pChartObjectsImpl->removeByName( getPersistName() );
+ else
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Parent is not ChartObjects" ) ) );
+}
+
+void
+ScVbaChartObject::Activate() throw ( script::BasicErrorException )
+{
+ try
+ {
+ // #TODO #FIXME should be ThisWorkbook or equivelant, or in
+ // fact probably the chart object should be created with
+ // the XModel owner
+ //uno::Reference< view::XSelectionSupplier > xSelectionSupplier( getXModel().getCurrentController());
+ uno::Reference< view::XSelectionSupplier > xSelectionSupplier( getCurrentExcelDoc(mxContext)->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSelectionSupplier->select(uno::makeAny(xShape));
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ChartObject Activate internal error" ) ) );
+ }
+}
+
+uno::Reference< excel::XChart > SAL_CALL
+ScVbaChartObject::getChart() throw (css::uno::RuntimeException)
+{
+ return new ScVbaChart( this, mxContext, xEmbeddedObjectSupplier->getEmbeddedObject(), xTableChart );
+}
+
+rtl::OUString&
+ScVbaChartObject::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaChartObject") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaChartObject::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.ChartObject" ) );
+ }
+ return aServiceNames;
+}
+
+double
+ScVbaChartObject::getHeight()
+{
+ return oShapeHelper->getHeight();
+}
+
+void
+ScVbaChartObject::setHeight(double _fheight) throw ( script::BasicErrorException )
+{
+ oShapeHelper->setHeight(_fheight);
+}
+
+double
+ScVbaChartObject::getWidth()
+{
+ return oShapeHelper->getWidth();
+}
+
+void
+ScVbaChartObject::setWidth(double _fWidth) throw ( script::BasicErrorException )
+{
+ oShapeHelper->setWidth(_fWidth);
+}
+
+double
+ScVbaChartObject::getLeft()
+{
+ return oShapeHelper->getLeft();
+}
+
+void
+ScVbaChartObject::setLeft(double _fLeft)
+{
+ oShapeHelper->setLeft(_fLeft);
+}
+
+double
+ScVbaChartObject::getTop()
+{
+ return oShapeHelper->getTop();
+}
+
+void
+ScVbaChartObject::setTop(double _fTop)
+{
+ oShapeHelper->setTop(_fTop);
+}
+
+uno::Reference< uno::XInterface >
+ScVbaChartObject::getUnoObject() throw (script::BasicErrorException)
+{
+ return uno::Reference< uno::XInterface >( xShape, uno::UNO_QUERY );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbachartobject.hxx b/sc/source/ui/vba/vbachartobject.hxx
new file mode 100644
index 000000000000..4e995d98a9fa
--- /dev/null
+++ b/sc/source/ui/vba/vbachartobject.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHARTOBJECT_HXX
+#define SC_VBA_CHARTOBJECT_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/table/XTableChart.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
+#include <ooo/vba/excel/XChartObject.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <memory>
+
+typedef InheritedHelperInterfaceImpl1<ov::excel::XChartObject > ChartObjectImpl_BASE;
+
+class ScVbaChartObject : public ChartObjectImpl_BASE
+{
+
+ css::uno::Reference< css::table::XTableChart > xTableChart;
+ css::uno::Reference< css::document::XEmbeddedObjectSupplier > xEmbeddedObjectSupplier;
+ css::uno::Reference< css::beans::XPropertySet > xPropertySet;
+ css::uno::Reference< css::drawing::XDrawPageSupplier > xDrawPageSupplier;
+ css::uno::Reference< css::drawing::XDrawPage > xDrawPage;
+ css::uno::Reference< css::drawing::XShape > xShape;
+ css::uno::Reference< css::container::XNamed > xNamed;
+ rtl::OUString sPersistName;
+ std::auto_ptr<ov::ShapeHelper> oShapeHelper;
+ css::uno::Reference< css::container::XNamed > xNamedShape;
+ rtl::OUString getPersistName();
+ css::uno::Reference< css::drawing::XShape > setShape() throw ( css::script::BasicErrorException );
+public:
+ ScVbaChartObject( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::table::XTableChart >& _xTableChart, const css::uno::Reference< css::drawing::XDrawPageSupplier >& _xDrawPageSupplier );
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& sName ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XChart > SAL_CALL getChart() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete() throw ( css::script::BasicErrorException );
+ virtual void Activate() throw ( css::script::BasicErrorException );
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+ // non interface methods
+ double getHeight();
+ void setHeight( double _fheight ) throw ( css::script::BasicErrorException );
+ double getWidth();
+ void setWidth( double _fwidth ) throw ( css::script::BasicErrorException );
+ double getLeft();
+ void setLeft( double _fleft );
+ double getTop();
+ void setTop( double _ftop );
+ // should make this part of the XHelperInterface with a default
+ // implementation returning NULL
+ css::uno::Reference< css::uno::XInterface > getUnoObject() throw ( css::script::BasicErrorException );
+};
+
+#endif //SC_VBA_WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbachartobjects.cxx b/sc/source/ui/vba/vbachartobjects.cxx
new file mode 100644
index 000000000000..ff97462b1b56
--- /dev/null
+++ b/sc/source/ui/vba/vbachartobjects.cxx
@@ -0,0 +1,196 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbachart.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
+#include <com/sun/star/table/XTableChartsSupplier.hpp>
+#include <com/sun/star/table/XTableChart.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <ooo/vba/excel/XlChartType.hpp>
+
+
+#include "vbachartobjects.hxx"
+#include "vbachartobject.hxx"
+#include "vbaglobals.hxx"
+#include "cellsuno.hxx"
+#include <vector>
+#include <basic/sberrors.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+
+class ChartObjectEnumerationImpl : public EnumerationHelperImpl
+{
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier;
+
+public:
+
+ ChartObjectEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< drawing::XDrawPageSupplier >& _xDrawPageSupplier, const uno::Reference< XHelperInterface >& _xParent ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( _xParent, xContext, xEnumeration ), xDrawPageSupplier( _xDrawPageSupplier ) {}
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ uno::Reference< table::XTableChart > xTableChart( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ // parent Object is sheet
+ return uno::makeAny( uno::Reference< excel::XChartObject > ( new ScVbaChartObject( m_xParent, m_xContext, xTableChart, xDrawPageSupplier ) ) );
+ }
+};
+
+
+ScVbaChartObjects::ScVbaChartObjects( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::table::XTableCharts >& _xTableCharts, const uno::Reference< drawing::XDrawPageSupplier >& _xDrawPageSupplier ) : ChartObjects_BASE(_xParent, _xContext, css::uno::Reference< css::container::XIndexAccess >( _xTableCharts, css::uno::UNO_QUERY ) ), xTableCharts( _xTableCharts ) , xDrawPageSupplier( _xDrawPageSupplier )
+{
+
+}
+
+void
+ScVbaChartObjects::removeByName(const rtl::OUString& _sChartName)
+{
+ xTableCharts->removeByName( _sChartName );
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaChartObjects::getChartObjectNames() throw( css::script::BasicErrorException )
+{
+ uno::Sequence< rtl::OUString > sChartNames;
+ try
+ {
+ // c++ hackery
+ uno::Reference< uno::XInterface > xIf( xDrawPageSupplier, uno::UNO_QUERY_THROW );
+ ScCellRangesBase* pUno= dynamic_cast< ScCellRangesBase* >( xIf.get() );
+ ScDocShell* pDocShell = NULL;
+ if ( !pUno )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Failed to obtain the impl class from the drawpage"), uno::Reference< uno::XInterface >() );
+ pDocShell = pUno->GetDocShell();
+ if ( !pDocShell )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Failed to obtain the docshell implclass"), uno::Reference< uno::XInterface >() );
+
+ uno::Reference< sheet::XSpreadsheetDocument > xSpreadsheetDocument( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheets > xSpreadsheets = xSpreadsheetDocument->getSheets();
+ std::vector< rtl::OUString > aChartNamesVector;
+
+ uno::Sequence< rtl::OUString > sSheetNames = xSpreadsheets->getElementNames();
+ sal_Int32 nItems = sSheetNames.getLength();
+ for (sal_Int32 i = 0; i < nItems; i++)
+ {
+ uno::Reference< table::XTableChartsSupplier > xLocTableChartsSupplier( xSpreadsheets->getByName(sSheetNames[i]), uno::UNO_QUERY_THROW );
+ uno::Sequence< rtl::OUString > scurchartnames = xLocTableChartsSupplier->getCharts()->getElementNames();
+ sal_Int32 nChartNames = scurchartnames.getLength();
+ for (sal_Int32 n = 0; n < nChartNames; n++ )
+ aChartNamesVector.push_back(scurchartnames[n]);
+ }
+ sChartNames.realloc( aChartNamesVector.size() );
+ std::vector< rtl::OUString > ::const_iterator it = aChartNamesVector.begin();
+ std::vector< rtl::OUString > ::const_iterator it_end = aChartNamesVector.end();
+ for ( sal_Int32 index = 0 ; it != it_end; ++it, ++index )
+ sChartNames[index] = *it;
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return sChartNames;
+}
+
+// XChartObjects
+uno::Any SAL_CALL
+ScVbaChartObjects::Add( double _nX, double _nY, double _nWidth, double _nHeight ) throw (script::BasicErrorException)
+{
+ try
+ {
+ uno::Sequence< table::CellRangeAddress > aCellRangeAddress( 1 );
+ awt::Rectangle aRectangle;
+ aRectangle.X = Millimeter::getInHundredthsOfOneMillimeter(_nX);
+ aRectangle.Y = Millimeter::getInHundredthsOfOneMillimeter(_nY);
+ aRectangle.Width = Millimeter::getInHundredthsOfOneMillimeter(_nWidth);
+ aRectangle.Height = Millimeter::getInHundredthsOfOneMillimeter(_nHeight);
+ // Note the space at the end of the stem ("Chart "). In ChartSheets only "Chart" is the stem
+ rtl::OUString sPersistChartName = ContainerUtilities::getUniqueName( getChartObjectNames(), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Chart " ) ) , rtl::OUString(), 1);
+ xTableCharts->addNewByName(sPersistChartName, aRectangle, aCellRangeAddress, true, false );
+ uno::Reference< excel::XChartObject > xChartObject( getItemByStringIndex( sPersistChartName ), uno::UNO_QUERY_THROW );
+ xChartObject->getChart()->setChartType(excel::XlChartType::xlColumnClustered);
+ return uno::makeAny( xChartObject );
+ }
+ catch ( uno::Exception& ex)
+ {
+ OSL_TRACE("AddItem caught exception ->%s", rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ return aNULL();
+}
+void SAL_CALL ScVbaChartObjects::Delete( ) throw (script::BasicErrorException)
+{
+ uno::Sequence< rtl::OUString > sChartNames = xTableCharts->getElementNames();
+ sal_Int32 ncount = sChartNames.getLength();
+ for (sal_Int32 i = 0; i < ncount ; i++)
+ removeByName(sChartNames[i]);
+}
+
+// XEnumerationAccess
+
+uno::Reference< container::XEnumeration >
+ScVbaChartObjects::createEnumeration() throw (uno::RuntimeException)
+{
+ css::uno::Reference< container::XEnumerationAccess > xEnumAccess( xTableCharts, uno::UNO_QUERY_THROW );
+ return new ChartObjectEnumerationImpl( mxContext, xEnumAccess->createEnumeration(), xDrawPageSupplier, getParent() /* sheet */);
+}
+
+// XElementAccess
+
+uno::Type
+ScVbaChartObjects::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XChartObject::static_type(0);
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any
+ScVbaChartObjects::createCollectionObject( const css::uno::Any& aSource )
+{
+ uno::Reference< table::XTableChart > xTableChart( aSource, uno::UNO_QUERY_THROW );
+ // correct parent object is sheet
+ return uno::makeAny( uno::Reference< excel::XChartObject > ( new ScVbaChartObject( getParent(), mxContext, xTableChart, xDrawPageSupplier ) ) );
+}
+
+rtl::OUString&
+ScVbaChartObjects::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaChartObjects") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaChartObjects::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.ChartObjects") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbachartobjects.hxx b/sc/source/ui/vba/vbachartobjects.hxx
new file mode 100644
index 000000000000..232b07401b90
--- /dev/null
+++ b/sc/source/ui/vba/vbachartobjects.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHARTOBJECTS_HXX
+#define SC_VBA_CHARTOBJECTS_HXX
+#include <ooo/vba/excel/XChartObjects.hpp>
+#include <ooo/vba/excel/XChartObject.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/table/XTableCharts.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include "excelvbahelper.hxx"
+#include <hash_map>
+
+typedef CollTestImplHelper< ov::excel::XChartObjects > ChartObjects_BASE;
+/* #TODO see if this hash table is 'really' necessary
+typedef ::std::hash_map< ::rtl::OUString,
+css::uno::Reference< ov::excel::XChartObject >,
+ ::rtl::OUStringHash,
+ ::std::equal_to< ::rtl::OUString > > aHashTable;
+*/
+
+class ScVbaChartObjects : public ChartObjects_BASE
+{
+
+ css::uno::Reference< css::table::XTableCharts > xTableCharts;
+ css::uno::Reference< css::drawing::XDrawPageSupplier > xDrawPageSupplier;
+ // method associated with populating the hashmap ( I'm not convinced this is necessary )
+ //css::uno::Reference< ov::excel::XChartObject > putByPersistName( const rtl:::OUString& _sPersistChartName );
+public:
+ ScVbaChartObjects( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::table::XTableCharts >& _xTableCharts, const css::uno::Reference< css::drawing::XDrawPageSupplier >& _xDrawPageSupplier );
+
+ css::uno::Sequence< rtl::OUString > getChartObjectNames() throw( css::script::BasicErrorException );
+ void removeByName(const rtl::OUString& _sChartName);
+
+ // XChartObjects
+ virtual ::com::sun::star::uno::Any SAL_CALL Add( double Left, double Top, double Width, double Height ) throw (::com::sun::star::script::BasicErrorException);
+ virtual void SAL_CALL Delete( ) throw (::com::sun::star::script::BasicErrorException);
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ // ScVbaCollectionBaseImpl
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ // ChartObjects_BASE
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacharts.cxx b/sc/source/ui/vba/vbacharts.cxx
new file mode 100644
index 000000000000..d9a720dc3dd1
--- /dev/null
+++ b/sc/source/ui/vba/vbacharts.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacharts.hxx"
+#include <basic/sberrors.hxx>
+#include <com/sun/star/table/XTableChartsSupplier.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+
+ScVbaCharts::ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const uno::Reference< frame::XModel >& xModel ) : Charts_BASE(_xParent, _xContext, uno::Reference< container::XIndexAccess >())
+{
+ xComponent.set( xModel, uno::UNO_QUERY_THROW );
+ xSpreadsheetDocument.set( xComponent, uno::UNO_QUERY_THROW );
+}
+
+uno::Any SAL_CALL
+ScVbaCharts::Add() throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ // Not implemented in the helperapi ( see ChartsImpl.java )
+ if ( true )
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_BAD_METHOD, rtl::OUString() );
+ return aNULL();
+}
+
+uno::Reference< excel::XChart > SAL_CALL
+ScVbaCharts::getActiveChart() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return xActiveChart;
+}
+
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaCharts::createEnumeration() throw (uno::RuntimeException)
+{
+ // #FIXME not implemented
+ if ( true )
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_BAD_METHOD, rtl::OUString() );
+ return uno::Reference< container::XEnumeration >();
+}
+
+// #FIXME #TODO this method shouldn't appear in this class directly
+// a XIndexAccess/XNameAccess wrapper should be passed to the base class instead
+::sal_Int32 SAL_CALL
+ScVbaCharts::getCount() throw (uno::RuntimeException)
+{
+ sal_Int32 ncount = 0;
+ try
+ {
+ uno::Reference< sheet::XSpreadsheets > xSpreadsheets( xSpreadsheetDocument->getSheets() );
+ uno::Sequence< rtl::OUString > SheetNames = xSpreadsheets->getElementNames();
+ sal_Int32 nLen = SheetNames.getLength();
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ uno::Reference< table::XTableChartsSupplier > xTableChartsSupplier( xSpreadsheets->getByName(SheetNames[i]), uno::UNO_QUERY);
+ if ( xTableChartsSupplier.is() )
+ {
+ uno::Reference< table::XTableCharts > xTableCharts = xTableChartsSupplier->getCharts();
+ ncount =+ xTableCharts->getElementNames().getLength();
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return ncount;
+}
+
+uno::Any
+ScVbaCharts::createCollectionObject( const uno::Any& aSource )
+{
+ if ( true )
+ throw script::BasicErrorException( rtl::OUString(), uno::Reference< uno::XInterface >(), SbERR_BAD_METHOD, rtl::OUString() );
+ // #TODO implementation please
+ return aSource;
+}
+
+rtl::OUString&
+ScVbaCharts::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCharts") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaCharts::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Charts") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacharts.hxx b/sc/source/ui/vba/vbacharts.hxx
new file mode 100644
index 000000000000..399910a6c2f6
--- /dev/null
+++ b/sc/source/ui/vba/vbacharts.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHARTS_HXX
+#define SC_VBA_CHARTS_HXX
+#include <ooo/vba/excel/XCharts.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include "excelvbahelper.hxx"
+#include <hash_map>
+
+typedef CollTestImplHelper< ov::excel::XCharts > Charts_BASE;
+
+class ScVbaCharts : public Charts_BASE
+{
+ css::uno::Reference< ov::excel::XChart > xActiveChart;
+ css::uno::Reference< css::sheet::XSpreadsheetDocument > xSpreadsheetDocument;
+ css::uno::Reference< css::lang::XComponent > xComponent;
+public:
+ ScVbaCharts( const css::uno::Reference< ov::XHelperInterface >& _xParent, const css::uno::Reference< css::uno::XComponentContext >& _xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ // XCharts
+ virtual css::uno::Any SAL_CALL Add() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XChart > SAL_CALL getActiveChart( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XCollection
+ ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException) { return ov::excel::XChart::static_type(0); }
+ // ScVbaCollectionBaseImpl
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ // Charts_BASE or HelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacharttitle.cxx b/sc/source/ui/vba/vbacharttitle.cxx
new file mode 100644
index 000000000000..ca81743b179f
--- /dev/null
+++ b/sc/source/ui/vba/vbacharttitle.cxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacharttitle.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaChartTitle::ScVbaChartTitle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& _xTitleShape ) : ChartTitleBase( xParent, xContext, _xTitleShape )
+{
+}
+
+rtl::OUString&
+ScVbaChartTitle::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaChartTitle") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaChartTitle::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ uno::Sequence< rtl::OUString > BaseServiceNames = ChartTitleBase::getServiceNames();
+ aServiceNames.realloc( BaseServiceNames.getLength() + 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Chart" ) );
+ for ( sal_Int32 index = 1; index < (BaseServiceNames.getLength() + 1); ++index )
+ aServiceNames[ index ] = BaseServiceNames[ index ];
+ }
+ return aServiceNames;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacharttitle.hxx b/sc/source/ui/vba/vbacharttitle.hxx
new file mode 100644
index 000000000000..2fe2d9e618d9
--- /dev/null
+++ b/sc/source/ui/vba/vbacharttitle.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CHARTTITLE_HXX
+#define SC_VBA_CHARTTITLE_HXX
+#include "vbatitle.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XChartTitle.hpp>
+
+
+typedef TitleImpl< cppu::WeakImplHelper1< ov::excel::XChartTitle > > ChartTitleBase;
+
+class ScVbaChartTitle : public ChartTitleBase
+{
+public:
+ ScVbaChartTitle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& _xTitleShape );
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacomment.cxx b/sc/source/ui/vba/vbacomment.cxx
new file mode 100644
index 000000000000..f707fad1eb13
--- /dev/null
+++ b/sc/source/ui/vba/vbacomment.cxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacomment.hxx"
+
+#include <ooo/vba/excel/XlCreator.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationAnchor.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationShapeSupplier.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/text/XText.hpp>
+
+#include <cellsuno.hxx>
+#include <postit.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdocapt.hxx>
+#include <ooo/vba/msforms/XShape.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+
+#include <vbahelper/vbashape.hxx>
+#include "vbaglobals.hxx"
+#include "vbacomments.hxx"
+#include "vbacommentshape.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaComment::ScVbaComment(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< frame::XModel >& xModel,
+ const uno::Reference< table::XCellRange >& xRange ) throw( lang::IllegalArgumentException ) :
+ ScVbaComment_BASE( xParent, xContext ),
+ mxModel( xModel, uno::UNO_SET_THROW ),
+ mxRange( xRange )
+{
+ if ( !xRange.is() )
+ throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "range is not set " ) ), uno::Reference< uno::XInterface >() , 1 );
+ uno::Reference< text::XSimpleText > xAnnoText( getAnnotation(), uno::UNO_QUERY );
+}
+
+// private helper functions
+
+uno::Reference< sheet::XSheetAnnotation > SAL_CALL
+ScVbaComment::getAnnotation() throw (uno::RuntimeException)
+{
+ uno::Reference< table::XCell > xCell( mxRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSheetAnnotationAnchor > xAnnoAnchor( xCell, uno::UNO_QUERY_THROW );
+ return uno::Reference< sheet::XSheetAnnotation > ( xAnnoAnchor->getAnnotation(), uno::UNO_QUERY_THROW );
+}
+
+uno::Reference< sheet::XSheetAnnotations > SAL_CALL
+ScVbaComment::getAnnotations() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCellRange > xSheetCellRange(mxRange, ::uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xSheet = xSheetCellRange->getSpreadsheet();
+ uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnosSupp( xSheet, uno::UNO_QUERY_THROW );
+
+ return uno::Reference< sheet::XSheetAnnotations > ( xAnnosSupp->getAnnotations(), uno::UNO_QUERY_THROW );
+}
+
+sal_Int32 SAL_CALL
+ScVbaComment::getAnnotationIndex() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetAnnotations > xAnnos = getAnnotations();
+ table::CellAddress aAddress = getAnnotation()->getPosition();
+
+ sal_Int32 aIndex = 0;
+ sal_Int32 aCount = xAnnos->getCount();
+
+ for ( ; aIndex < aCount ; aIndex++ )
+ {
+ uno::Reference< sheet::XSheetAnnotation > xAnno( xAnnos->getByIndex( aIndex ), uno::UNO_QUERY_THROW );
+ table::CellAddress xAddress = xAnno->getPosition();
+
+ if ( xAddress.Column == aAddress.Column && xAddress.Row == aAddress.Row && xAddress.Sheet == aAddress.Sheet )
+ {
+ OSL_TRACE("** terminating search, index is %d", aIndex );
+ break;
+ }
+ }
+ OSL_TRACE("** returning index is %d", aIndex );
+
+ return aIndex;
+}
+
+uno::Reference< excel::XComment > SAL_CALL
+ScVbaComment::getCommentByIndex( sal_Int32 Index ) throw (uno::RuntimeException)
+{
+ uno::Reference< container::XIndexAccess > xIndexAccess( getAnnotations(), uno::UNO_QUERY_THROW );
+ // parent is sheet ( parent of the range which is the parent of the comment )
+ uno::Reference< XCollection > xColl( new ScVbaComments( getParent()->getParent(), mxContext, mxModel, xIndexAccess ) );
+
+ return uno::Reference< excel::XComment > ( xColl->Item( uno::makeAny( Index ), uno::Any() ), uno::UNO_QUERY_THROW );
+ }
+
+// public vba functions
+
+rtl::OUString SAL_CALL
+ScVbaComment::getAuthor() throw (uno::RuntimeException)
+{
+ return getAnnotation()->getAuthor();
+}
+
+void SAL_CALL
+ScVbaComment::setAuthor( const rtl::OUString& /*_author*/ ) throw (uno::RuntimeException)
+{
+ // #TODO #FIXME implementation needed
+}
+
+uno::Reference< msforms::XShape > SAL_CALL
+ScVbaComment::getShape() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetAnnotationShapeSupplier > xAnnoShapeSupp( getAnnotation(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XShape > xAnnoShape( xAnnoShapeSupp->getAnnotationShape(), uno::UNO_SET_THROW );
+ uno::Reference< sheet::XSheetCellRange > xCellRange( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupp( xCellRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XShapes > xShapes( xDrawPageSupp->getDrawPage(), uno::UNO_QUERY_THROW );
+ return new ScVbaShape( this, mxContext, xAnnoShape, xShapes, mxModel, office::MsoShapeType::msoComment );
+}
+
+sal_Bool SAL_CALL
+ScVbaComment::getVisible() throw (uno::RuntimeException)
+{
+ return getAnnotation()->getIsVisible();
+}
+
+void SAL_CALL
+ScVbaComment::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
+{
+ getAnnotation()->setIsVisible( _visible );
+}
+
+void SAL_CALL
+ScVbaComment::Delete() throw (uno::RuntimeException)
+{
+ getAnnotations()->removeByIndex( getAnnotationIndex() );
+}
+
+uno::Reference< excel::XComment > SAL_CALL
+ScVbaComment::Next() throw (uno::RuntimeException)
+{
+ // index: uno = 0, vba = 1
+ return getCommentByIndex( getAnnotationIndex() + 2 );
+}
+
+uno::Reference< excel::XComment > SAL_CALL
+ScVbaComment::Previous() throw (uno::RuntimeException)
+{
+ // index: uno = 0, vba = 1
+ return getCommentByIndex( getAnnotationIndex() );
+}
+
+rtl::OUString SAL_CALL
+ScVbaComment::Text( const uno::Any& aText, const uno::Any& aStart, const uno::Any& Overwrite ) throw (uno::RuntimeException)
+{
+ rtl::OUString sText;
+ aText >>= sText;
+
+ uno::Reference< text::XSimpleText > xAnnoText( getAnnotation(), uno::UNO_QUERY_THROW );
+
+ if ( aStart.hasValue() )
+ {
+ sal_Int16 nStart = 0;
+ sal_Bool bOverwrite = sal_True;
+ Overwrite >>= bOverwrite;
+
+ if ( aStart >>= nStart )
+ {
+ uno::Reference< text::XTextCursor > xTextCursor( xAnnoText->createTextCursor(), uno::UNO_QUERY_THROW );
+
+ if ( bOverwrite )
+ {
+ xTextCursor->collapseToStart();
+ xTextCursor->gotoStart( sal_False );
+ xTextCursor->goRight( nStart - 1, sal_False );
+ xTextCursor->gotoEnd( sal_True );
+ }
+ else
+ {
+ xTextCursor->collapseToStart();
+ xTextCursor->gotoStart( sal_False );
+ xTextCursor->goRight( nStart - 1 , sal_True );
+ }
+
+ uno::Reference< text::XTextRange > xRange( xTextCursor, uno::UNO_QUERY_THROW );
+ xAnnoText->insertString( xRange, sText, bOverwrite );
+ return xAnnoText->getString();
+ }
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScVbaComment::Text - bad Start value " ) ), uno::Reference< uno::XInterface >() );
+ }
+ else if ( aText.hasValue() )
+ {
+ uno::Reference< sheet::XCellAddressable > xCellAddr(mxRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ table::CellAddress aAddress = xCellAddr->getCellAddress();
+ getAnnotations()->insertNew( aAddress, sText );
+ }
+
+ rtl::OUString sAnnoText = xAnnoText->getString();
+ return sAnnoText;
+}
+
+rtl::OUString&
+ScVbaComment::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComment") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaComment::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.ScVbaComment" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacomment.hxx b/sc/source/ui/vba/vbacomment.hxx
new file mode 100644
index 000000000000..7f6a5a3d5a77
--- /dev/null
+++ b/sc/source/ui/vba/vbacomment.hxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_COMMENT_HXX
+#define SC_VBA_COMMENT_HXX
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <ooo/vba/excel/XComment.hpp>
+#include <ooo/vba/excel/XApplication.hpp>
+#include <ooo/vba/msforms/XShape.hpp>
+#include <com/sun/star/sheet/XSheetAnnotations.hpp>
+#include <com/sun/star/sheet/XSheetAnnotation.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XComment > ScVbaComment_BASE;
+
+class ScVbaComment : public ScVbaComment_BASE
+{
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::table::XCellRange > mxRange;
+
+private:
+ css::uno::Reference< css::sheet::XSheetAnnotation > SAL_CALL getAnnotation() throw (css::uno::RuntimeException);
+ css::uno::Reference< css::sheet::XSheetAnnotations > SAL_CALL getAnnotations() throw (css::uno::RuntimeException);
+ sal_Int32 SAL_CALL getAnnotationIndex() throw (css::uno::RuntimeException);
+ css::uno::Reference< ov::excel::XComment > SAL_CALL getCommentByIndex( sal_Int32 Index ) throw (css::uno::RuntimeException);
+public:
+ ScVbaComment(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::lang::IllegalArgumentException );
+
+ virtual ~ScVbaComment() {}
+
+ // Attributes
+ virtual rtl::OUString SAL_CALL getAuthor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAuthor( const rtl::OUString& _author ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XShape > SAL_CALL getShape() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Bool _visible ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XComment > SAL_CALL Next() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XComment > SAL_CALL Previous() throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL Text( const css::uno::Any& Text, const css::uno::Any& Start, const css::uno::Any& Overwrite ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SC_VBA_COMMENT_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacomments.cxx b/sc/source/ui/vba/vbacomments.cxx
new file mode 100644
index 000000000000..4d8d79a2106b
--- /dev/null
+++ b/sc/source/ui/vba/vbacomments.cxx
@@ -0,0 +1,119 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbacomments.hxx"
+
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sheet/XSheetAnnotation.hpp>
+
+#include "vbaglobals.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+uno::Any AnnotationToComment( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< sheet::XSheetAnnotation > xAnno( aSource, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XChild > xChild( xAnno, uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xCellRange( xChild->getParent(), uno::UNO_QUERY_THROW );
+
+ // #FIXME needs to find the correct Parent
+ return uno::makeAny( uno::Reference< excel::XComment > (
+ new ScVbaComment( uno::Reference< XHelperInterface >(), xContext, xModel, xCellRange ) ) );
+}
+
+class CommentEnumeration : public EnumerationHelperImpl
+{
+ css::uno::Reference< css::frame::XModel > mxModel;
+public:
+ CommentEnumeration(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< container::XEnumeration >& xEnumeration,
+ const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) :
+ EnumerationHelperImpl( xParent, xContext, xEnumeration ),
+ mxModel( xModel, uno::UNO_SET_THROW )
+ {}
+
+ virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ return AnnotationToComment( m_xEnumeration->nextElement(), m_xContext, mxModel );
+ }
+
+};
+
+ScVbaComments::ScVbaComments(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext > & xContext,
+ const uno::Reference< frame::XModel >& xModel,
+ const uno::Reference< container::XIndexAccess >& xIndexAccess ) :
+ ScVbaComments_BASE( xParent, xContext, xIndexAccess ),
+ mxModel( xModel, uno::UNO_SET_THROW )
+{
+}
+
+// public helper functions
+
+uno::Reference< container::XEnumeration >
+ScVbaComments::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel );
+}
+
+uno::Any
+ScVbaComments::createCollectionObject( const css::uno::Any& aSource )
+{
+ return AnnotationToComment( aSource, mxContext, mxModel );
+}
+
+uno::Type
+ScVbaComments::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XComment::static_type(0);
+}
+
+rtl::OUString&
+ScVbaComments::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaComments") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaComments::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Comments") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacomments.hxx b/sc/source/ui/vba/vbacomments.hxx
new file mode 100644
index 000000000000..babefb4e6739
--- /dev/null
+++ b/sc/source/ui/vba/vbacomments.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_COMMENTS_HXX
+#define SC_VBA_COMMENTS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <ooo/vba/excel/XComments.hpp>
+
+#include "excelvbahelper.hxx"
+#include <vbahelper/vbacollectionimpl.hxx>
+#include "vbacomment.hxx"
+
+typedef CollTestImplHelper< ov::excel::XComments > ScVbaComments_BASE;
+
+class ScVbaComments : public ScVbaComments_BASE
+{
+public:
+ ScVbaComments(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+
+ virtual ~ScVbaComments() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // ScVbaComments_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+private:
+ css::uno::Reference< css::frame::XModel > mxModel;
+};
+
+#endif /* SC_VBA_COMMENTS_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacommentshape.cxx b/sc/source/ui/vba/vbacommentshape.cxx
new file mode 100644
index 000000000000..768b63636ad2
--- /dev/null
+++ b/sc/source/ui/vba/vbacommentshape.cxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbacommentshape.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaCommentShape::ScVbaCommentShape( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< excel::XComment >& xComment,
+ const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel, sal_Int32 nType ) : ScVbaShape( xParent, xContext, xShape, xShapes, xModel, nType )
+{
+ m_xComment.set( xComment, uno::UNO_QUERY );
+}
+
+void SAL_CALL ScVbaCommentShape::Delete() throw (uno::RuntimeException)
+{
+ if ( m_xComment.is() )
+ {
+ m_xComment->Delete();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacommentshape.hxx b/sc/source/ui/vba/vbacommentshape.hxx
new file mode 100644
index 000000000000..6943321cbaef
--- /dev/null
+++ b/sc/source/ui/vba/vbacommentshape.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_COMMENTSHAPE_HXX
+#define SC_VBA_COMMENTSHAPE_HXX
+
+#include <ooo/vba/excel/XComment.hpp>
+#include <vbahelper/vbashape.hxx>
+
+class ScVbaCommentShape : public ScVbaShape
+{
+ css::uno::Reference< ooo::vba::excel::XComment > m_xComment;
+
+public:
+ ScVbaCommentShape( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape,
+ const css::uno::Reference< ooo::vba::excel::XComment >& xComment, const css::uno::Reference< css::drawing::XShapes >& xShapes, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nType );
+
+ // Methods
+ virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
+};
+#endif //SC_VBA_COMMENTSHAPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacondition.cxx b/sc/source/ui/vba/vbacondition.cxx
new file mode 100644
index 000000000000..6065f123ef39
--- /dev/null
+++ b/sc/source/ui/vba/vbacondition.cxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbacondition.hxx"
+#include <ooo/vba/excel/XlFormatConditionOperator.hpp>
+#include <ooo/vba/excel/XFormatCondition.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+const sal_Int32 ISFORMULA = 98765432;
+
+template< typename Ifc1 >
+ScVbaCondition< Ifc1 >::ScVbaCondition( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition ) : ScVbaCondition_BASE( xParent, xContext ), mxSheetCondition( _xSheetCondition )
+{
+ mxAddressable.set( xParent, uno::UNO_QUERY_THROW );
+}
+
+template< typename Ifc1 >
+sheet::ConditionOperator
+ScVbaCondition< Ifc1 >::retrieveAPIOperator( const uno::Any& _aOperator) throw ( script::BasicErrorException )
+{
+ sheet::ConditionOperator aRetAPIOperator = sheet::ConditionOperator_NONE;
+ sal_Int32 nOperator = 0;
+ if ( (_aOperator >>= nOperator ) )
+ {
+ switch(nOperator)
+ {
+ case excel::XlFormatConditionOperator::xlBetween:
+ aRetAPIOperator = sheet::ConditionOperator_BETWEEN;
+ break;
+ case excel::XlFormatConditionOperator::xlNotBetween:
+ aRetAPIOperator = sheet::ConditionOperator_NOT_BETWEEN;
+ break;
+ case excel::XlFormatConditionOperator::xlEqual:
+ aRetAPIOperator = sheet::ConditionOperator_EQUAL;
+ break;
+ case excel::XlFormatConditionOperator::xlNotEqual:
+ aRetAPIOperator = sheet::ConditionOperator_NOT_EQUAL;
+ break;
+ case excel::XlFormatConditionOperator::xlGreater:
+ aRetAPIOperator = sheet::ConditionOperator_GREATER;
+ break;
+ case excel::XlFormatConditionOperator::xlLess:
+ aRetAPIOperator = sheet::ConditionOperator_LESS;
+ break;
+ case excel::XlFormatConditionOperator::xlGreaterEqual:
+ aRetAPIOperator = sheet::ConditionOperator_GREATER_EQUAL;
+ break;
+ case excel::XlFormatConditionOperator::xlLessEqual:
+ aRetAPIOperator = sheet::ConditionOperator_LESS_EQUAL;
+ break;
+ default:
+ aRetAPIOperator = sheet::ConditionOperator_NONE;
+ break;
+ }
+ }
+ return aRetAPIOperator;
+}
+
+template< typename Ifc1 >
+rtl::OUString
+ScVbaCondition< Ifc1 >::Formula1( ) throw ( script::BasicErrorException, uno::RuntimeException )
+{
+ return mxSheetCondition->getFormula1();
+}
+
+template< typename Ifc1 >
+rtl::OUString
+ScVbaCondition< Ifc1 >::Formula2( ) throw ( script::BasicErrorException, uno::RuntimeException )
+{
+ return mxSheetCondition->getFormula2();
+}
+
+template< typename Ifc1 >
+void
+ScVbaCondition< Ifc1 >::setFormula1( const uno::Any& _aFormula1) throw ( script::BasicErrorException )
+{
+ rtl::OUString sFormula;
+ if ( (_aFormula1 >>= sFormula ))
+ {
+ mxSheetCondition->setFormula1( sFormula );
+ table::CellRangeAddress aCellRangeAddress = mxAddressable->getRangeAddress();
+ table::CellAddress aCellAddress( aCellRangeAddress.Sheet, aCellRangeAddress.StartColumn, aCellRangeAddress.StartRow );
+ mxSheetCondition->setSourcePosition(aCellAddress);
+ }
+}
+
+template< typename Ifc1 >
+void
+ScVbaCondition< Ifc1 >::setFormula2( const uno::Any& _aFormula2) throw ( script::BasicErrorException )
+{
+ rtl::OUString sFormula2;
+ // #TODO surely this can't be right?
+ // ( from helperapi/impl/.../calc/ConditionImpl.java
+ if ( (_aFormula2 >>= sFormula2 ))
+ mxSheetCondition->setFormula1(sFormula2);
+}
+
+template< typename Ifc1 >
+sal_Int32
+ScVbaCondition< Ifc1 >::Operator(sal_Bool _bIncludeFormulaValue) throw ( script::BasicErrorException )
+{
+ sal_Int32 retvalue = -1;
+ sheet::ConditionOperator aConditionalOperator = mxSheetCondition->getOperator();
+ switch (aConditionalOperator)
+ {
+ case sheet::ConditionOperator_EQUAL:
+ retvalue = excel::XlFormatConditionOperator::xlEqual;
+ break;
+ case sheet::ConditionOperator_NOT_EQUAL:
+ retvalue = excel::XlFormatConditionOperator::xlNotEqual;
+ break;
+ case sheet::ConditionOperator_GREATER:
+ retvalue = excel::XlFormatConditionOperator::xlGreater;
+ break;
+ case sheet::ConditionOperator_GREATER_EQUAL:
+ retvalue = excel::XlFormatConditionOperator::xlGreaterEqual;
+ break;
+ case sheet::ConditionOperator_LESS:
+ retvalue = excel::XlFormatConditionOperator::xlLess;
+ break;
+ case sheet::ConditionOperator_LESS_EQUAL:
+ retvalue = excel::XlFormatConditionOperator::xlLessEqual;
+ break;
+ case sheet::ConditionOperator_BETWEEN:
+ retvalue = excel::XlFormatConditionOperator::xlBetween;
+ break;
+ case sheet::ConditionOperator_NOT_BETWEEN:
+ retvalue = excel::XlFormatConditionOperator::xlNotBetween;
+ break;
+ case sheet::ConditionOperator_FORMULA:
+ if (_bIncludeFormulaValue)
+ {
+ //#FIXME huh what's this all about
+ // from helperapi/impl/.../calc/ConditionImpl
+ retvalue = ISFORMULA;
+ break;
+ }
+ case sheet::ConditionOperator_NONE:
+ default:
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Operator not supported")));
+ break;
+ }
+ return retvalue;
+}
+
+template class ScVbaCondition< excel::XFormatCondition >;
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbacondition.hxx b/sc/source/ui/vba/vbacondition.hxx
new file mode 100644
index 000000000000..80e1b5bccd88
--- /dev/null
+++ b/sc/source/ui/vba/vbacondition.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_CONDITION_HXX
+#define SC_VBA_CONDITION_HXX
+#include <com/sun/star/sheet/XSheetCondition.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <com/sun/star/sheet/ConditionOperator.hpp>
+
+template< typename Ifc1 >
+class ScVbaCondition : public InheritedHelperInterfaceImpl1< Ifc1 >
+{
+typedef InheritedHelperInterfaceImpl1< Ifc1 > ScVbaCondition_BASE;
+protected:
+ css::uno::Reference< css::sheet::XCellRangeAddressable > mxAddressable;
+ css::uno::Reference< css::sheet::XSheetCondition > mxSheetCondition;
+public:
+ ScVbaCondition( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::sheet::XSheetCondition >& _xSheetCondition );
+
+ static css::sheet::ConditionOperator retrieveAPIOperator( const css::uno::Any& _aOperator) throw ( css::script::BasicErrorException );
+
+ virtual rtl::OUString SAL_CALL Formula1( ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ virtual rtl::OUString SAL_CALL Formula2( ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ virtual void setFormula1( const css::uno::Any& _aFormula1) throw ( css::script::BasicErrorException );
+ virtual void setFormula2( const css::uno::Any& _aFormula2) throw ( css::script::BasicErrorException );
+ virtual sal_Int32 Operator(sal_Bool _bIncludeFormulaValue) throw ( css::script::BasicErrorException );
+ virtual sal_Int32 SAL_CALL Operator() throw ( css::script::BasicErrorException, css::uno::RuntimeException ) = 0;
+
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialog.cxx b/sc/source/ui/vba/vbadialog.cxx
new file mode 100644
index 000000000000..452fa9aeb84a
--- /dev/null
+++ b/sc/source/ui/vba/vbadialog.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbadialog.hxx"
+
+#include <sal/macros.h>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+//liuchen 2009-7-27
+//solve the problem that "Application.Dialogs.Item(***).Show" and "Application.Dialogs.Count" cannot get the correct result
+struct DialogMatch
+{
+ sal_Int32 nVbaDlgIndex;
+ rtl::OUString aOODlgName;
+};
+
+static const DialogMatch aDialogMatchList[] =
+{
+ { 1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Open" ) ) }, // xlDialogOpen -> .uno:Open
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatCellDialog" ) ) }, // ??? -> .uno:FormatCellDialog
+ { 55, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertCell" ) ) }, // xlDialogInsert -> .uno:InsertCell
+ { 8, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Print" ) ) }, // xlDialogPrint -> .uno:Print
+ { 9, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PrinterSetup" ) ) }, // xlDialogPrinterSetup -> .uno:PrinterSetup
+ { 53, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PasteSpecial" ) ) }, // xlDialogPasteSpecial -> .uno:PasteSpecial
+ { 28, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ToolProtectionDocument" ) ) }, // xlDialogProtectDocument -> uno:ToolProtectionDocument
+ { 47, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ColumnWidth" ) ) }, // xlDialogColumnWidth -> .uno:ColumnWidth
+ { 61, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineName" ) ) }, // xlDialogDefineName -> .uno:DefineName
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConfigureDialog" ) ) }, // ??? -> .uno:ConfigureDialog
+ { 596, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:HyperlinkDialog" ) ) }, // xlDialogInsertHyperlink -> .uno:HyperlinkDialog
+ { 342, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertGraphic" ) ) }, // xlDialogInsertPicture -> .uno:InsertGraphic
+ { 259, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:InsertObject" ) ) }, // xlDialogInsertObject -> .uno:InsertObject
+ { 7, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PageFormatDialog" ) ) }, // xlDialogPageSetup -> .uno:PageFormatDialog
+ { 39, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataSort" ) ) }, // xlDialogSort -> .uno:DataSort
+ { 127, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:RowHeight" ) ) }, // xlDialogRowHeight -> .uno:RowHeight
+ { 485, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoCorrectDlg" ) ) }, // xlDialogAutoCorrect -> .uno:AutoCorrectDlg
+ { 583, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ConditionalFormatDialog" ) ) }, // xlDialogCondiationalFormatting -> .uno:ConditionalFormatDialog
+ { 191, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataConsolidate" ) ) }, // xlDialogConsolidate -> .uno:DataConsolidate
+ { 62, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CreateNames" ) ) }, // xlDialogCreateNames -> .uno:CreateNames
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FillSeries" ) ) }, // ??? -> .uno:FillSeries
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:Validation" ) ) }, // ??? -> .uno:Validation"
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DefineLabelRange" ) ) }, // ??? -> .uno:DefineLabelRange
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterAutoFilter" ) ) }, // ??? -> .uno:DataFilterAutoFilter
+ { -1, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:DataFilterSpecialFilter" ) ) }, // ??? -> .uno:DataFilterSpecialFilter
+ { 269, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:AutoFormat" ) ) } // xlDialogFormatAuto -> .uno:AutoFormat
+};
+
+const sal_Int32 nDialogSize = SAL_N_ELEMENTS( aDialogMatchList ) ;
+
+//liuchen modified 2009-2-27
+rtl::OUString
+ScVbaDialog::mapIndexToName( sal_Int32 nIndex )
+{
+ for (int i = 0; i < nDialogSize; i++)
+ {
+ if ( aDialogMatchList[i].nVbaDlgIndex == nIndex )
+ {
+ return aDialogMatchList[i].aOODlgName;
+ }
+ }
+
+ return rtl::OUString();
+}
+
+rtl::OUString&
+ScVbaDialog::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaDialog") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaDialog::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Dialog" ) );
+ }
+ return aServiceNames;
+}
+
+//liuchen add 2009-7-27
+sal_Int32 ScVbaDialog::GetSupportedDialogCount()
+{
+ return nDialogSize;
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialog.hxx b/sc/source/ui/vba/vbadialog.hxx
new file mode 100644
index 000000000000..9c73aca10fbf
--- /dev/null
+++ b/sc/source/ui/vba/vbadialog.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_DIALOG_HXX
+#define SC_VBA_DIALOG_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XDialog.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbadialogbase.hxx>
+
+typedef cppu::ImplInheritanceHelper1< VbaDialogBase, ov::excel::XDialog > ScVbaDialog_BASE;
+
+class ScVbaDialog : public ScVbaDialog_BASE
+{
+public:
+ ScVbaDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XModel >& xModel, sal_Int32 nIndex ):ScVbaDialog_BASE( xParent, xContext, xModel, nIndex ) {}
+ virtual ~ScVbaDialog() {}
+
+ // Methods
+ virtual rtl::OUString mapIndexToName( sal_Int32 nIndex );
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+ //liuchen 2009-7-27
+ static sal_Int32 GetSupportedDialogCount();
+};
+
+#endif /* SC_VBA_DIALOG_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialogs.cxx b/sc/source/ui/vba/vbadialogs.cxx
new file mode 100644
index 000000000000..361d1a45329c
--- /dev/null
+++ b/sc/source/ui/vba/vbadialogs.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <ooo/vba/excel/XDialog.hpp>
+#include "vbadialogs.hxx"
+#include "vbadialog.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+void
+ScVbaDialogs::Dummy() throw (uno::RuntimeException)
+{
+}
+
+uno::Any
+ScVbaDialogs::Item( const uno::Any &aItem ) throw (uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ aItem >>= nIndex;
+ uno::Reference< excel::XDialog > aDialog( new ScVbaDialog( uno::Reference< XHelperInterface >( Application(),uno::UNO_QUERY_THROW ), mxContext, m_xModel, nIndex ) );
+ return uno::Any( aDialog );
+}
+
+rtl::OUString&
+ScVbaDialogs::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaDialogs") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaDialogs::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Dialogs" ) );
+ }
+ return aServiceNames;
+}
+
+//liuchen 2009-7-27
+::sal_Int32
+ScVbaDialogs::getCount() throw (uno::RuntimeException)
+{
+ return ScVbaDialog::GetSupportedDialogCount();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbadialogs.hxx b/sc/source/ui/vba/vbadialogs.hxx
new file mode 100644
index 000000000000..785757b0a4e5
--- /dev/null
+++ b/sc/source/ui/vba/vbadialogs.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_DIALOGS_HXX
+#define SC_VBA_DIALOGS_HXX
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <ooo/vba/excel/XDialogs.hpp>
+#include <ooo/vba/XCollection.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbadialogsbase.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+typedef cppu::ImplInheritanceHelper1< VbaDialogsBase, ov::excel::XDialogs > ScVbaDialogs_BASE;
+
+class ScVbaDialogs : public ScVbaDialogs_BASE
+{
+public:
+ ScVbaDialogs( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ): ScVbaDialogs_BASE( xParent, xContext, xModel ) {}
+ virtual ~ScVbaDialogs() {}
+
+ // XCollection
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException); //liuchen 2009-7-27
+
+ // XDialogs
+ virtual void SAL_CALL Dummy() throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SC_VBA_DIALOGS_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx
new file mode 100644
index 000000000000..abca80602ef5
--- /dev/null
+++ b/sc/source/ui/vba/vbaeventshelper.cxx
@@ -0,0 +1,764 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbaeventshelper.hxx"
+
+#include <com/sun/star/awt/XWindowListener.hpp>
+#include <com/sun/star/frame/XBorderResizeListener.hpp>
+#include <com/sun/star/frame/XControllerBorder.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/util/XChangesListener.hpp>
+#include <com/sun/star/util/XChangesNotifier.hpp>
+#include <com/sun/star/util/XCloseListener.hpp>
+
+#include <ooo/vba/excel/XApplication.hpp>
+
+#include <cppuhelper/implbase4.hxx>
+#include <toolkit/unohlp.hxx>
+#include <vbahelper/helperdecl.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/window.hxx>
+
+#include "cellsuno.hxx"
+#include "convuno.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::script::vba::VBAEventId;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+typedef ::cppu::WeakImplHelper4<
+ awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener, util::XChangesListener > ScVbaEventsListener_BASE;
+
+// This class is to process Workbook window related event
+class ScVbaEventsListener : public ScVbaEventsListener_BASE
+{
+public :
+ ScVbaEventsListener( ScVbaEventsHelper& rVbaEvents, const uno::Reference< frame::XModel >& rxModel, ScDocShell* pDocShell );
+ virtual ~ScVbaEventsListener();
+
+ void startListening();
+ void stopListening();
+
+ // XWindowListener
+ virtual void SAL_CALL windowResized( const awt::WindowEvent& aEvent ) throw (uno::RuntimeException);
+ virtual void SAL_CALL windowMoved( const awt::WindowEvent& aEvent ) throw (uno::RuntimeException);
+ virtual void SAL_CALL windowShown( const lang::EventObject& aEvent ) throw (uno::RuntimeException);
+ virtual void SAL_CALL windowHidden( const lang::EventObject& aEvent ) throw (uno::RuntimeException);
+ virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw (uno::RuntimeException);
+
+ // XCloseListener
+ virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException);
+ virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
+
+ // XBorderResizeListener
+ virtual void SAL_CALL borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException);
+
+ // XChangesListener
+ virtual void SAL_CALL changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException);
+
+private:
+ uno::Reference< frame::XFrame > getFrame();
+ uno::Reference< awt::XWindow > getContainerWindow();
+ bool isMouseReleased();
+ DECL_LINK( fireResizeMacro, void* );
+ void processWindowResizeMacro();
+
+private:
+ ::osl::Mutex maMutex;
+ ScVbaEventsHelper& mrVbaEvents;
+ uno::Reference< frame::XModel > mxModel;
+ ScDocShell* mpDocShell;
+ bool mbWindowResized;
+ bool mbBorderChanged;
+ bool mbDisposed;
+};
+
+// ----------------------------------------------------------------------------
+
+ScVbaEventsListener::ScVbaEventsListener( ScVbaEventsHelper& rVbaEvents, const uno::Reference< frame::XModel >& rxModel, ScDocShell* pDocShell ) :
+ mrVbaEvents( rVbaEvents ),
+ mxModel( rxModel ),
+ mpDocShell( pDocShell ),
+ mbWindowResized( false ),
+ mbBorderChanged( false ),
+ mbDisposed( !rxModel.is() )
+{
+ OSL_TRACE( "ScVbaEventsListener::ScVbaEventsListener( 0x%x ) - ctor ", this );
+}
+
+ScVbaEventsListener::~ScVbaEventsListener()
+{
+ OSL_TRACE( "ScVbaEventsListener::~ScVbaEventsListener( 0x%x ) - dtor ", this );
+ stopListening();
+}
+
+void ScVbaEventsListener::startListening()
+{
+ if( !mbDisposed )
+ {
+ // add window listener
+ try
+ {
+ uno::Reference< awt::XWindow > xWindow( getContainerWindow(), uno::UNO_QUERY_THROW );
+ xWindow->addWindowListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ // add close listener
+ try
+ {
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( mxModel, uno::UNO_QUERY_THROW );
+ xCloseBroadcaster->addCloseListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ // add Border resize listener
+ try
+ {
+ uno::Reference< frame::XControllerBorder > xControllerBorder( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xControllerBorder->addBorderResizeListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ // add content change listener
+ try
+ {
+ uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModel, uno::UNO_QUERY_THROW );
+ xChangesNotifier->addChangesListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+void ScVbaEventsListener::stopListening()
+{
+ if( !mbDisposed )
+ {
+ try
+ {
+ uno::Reference< awt::XWindow > xWindow( getContainerWindow(), uno::UNO_QUERY_THROW );
+ xWindow->removeWindowListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ try
+ {
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( mxModel, uno::UNO_QUERY_THROW );
+ xCloseBroadcaster->removeCloseListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ try
+ {
+ uno::Reference< frame::XControllerBorder > xControllerBorder( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xControllerBorder->removeBorderResizeListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ try
+ {
+ uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModel, uno::UNO_QUERY_THROW );
+ xChangesNotifier->removeChangesListener( this );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ mbDisposed = true;
+}
+
+void SAL_CALL ScVbaEventsListener::windowResized( const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ // Workbook_window_resize event
+ mbWindowResized = true;
+ if( !mbDisposed && mbBorderChanged )
+ {
+ if( /*Window* pWindow =*/ VCLUnoHelper::GetWindow( getContainerWindow() ) )
+ {
+ mbBorderChanged = mbWindowResized = false;
+ acquire(); // ensure we don't get deleted before the event is handled
+ Application::PostUserEvent( LINK( this, ScVbaEventsListener, fireResizeMacro ), 0 );
+ }
+ }
+}
+
+void SAL_CALL ScVbaEventsListener::windowMoved( const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ // not interest this time
+}
+
+void SAL_CALL ScVbaEventsListener::windowShown( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ // not interest this time
+}
+
+void SAL_CALL ScVbaEventsListener::windowHidden( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ // not interest this time
+}
+
+void SAL_CALL ScVbaEventsListener::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ OSL_TRACE( "ScVbaEventsListener::disposing( 0x%x )", this );
+ mbDisposed = true;
+}
+
+void SAL_CALL ScVbaEventsListener::queryClosing( const lang::EventObject& /*Source*/, sal_Bool /*GetsOwnership*/ ) throw (util::CloseVetoException, uno::RuntimeException)
+{
+ // it can cancel the close, but need to throw a CloseVetoException, and it will be transmit to caller.
+}
+
+void SAL_CALL ScVbaEventsListener::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ stopListening();
+}
+
+void SAL_CALL ScVbaEventsListener::borderWidthsChanged( const uno::Reference< uno::XInterface >& /*aObject*/, const frame::BorderWidths& /*aNewSize*/ ) throw (uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( maMutex );
+ // work with WindowResized event to guard Window Resize event.
+ mbBorderChanged = true;
+ if( !mbDisposed && mbWindowResized )
+ {
+ if( /*Window* pWindow =*/ VCLUnoHelper::GetWindow( getContainerWindow() ) )
+ {
+ mbWindowResized = mbBorderChanged = false;
+ acquire(); // ensure we don't get deleted before the timer fires.
+ Application::PostUserEvent( LINK( this, ScVbaEventsListener, fireResizeMacro ), 0 );
+ }
+ }
+}
+
+void SAL_CALL ScVbaEventsListener::changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException)
+{
+ sal_Int32 nCount = aEvent.Changes.getLength();
+ if( nCount == 0 )
+ return;
+
+ util::ElementChange aChange = aEvent.Changes[ 0 ];
+ rtl::OUString sOperation;
+ aChange.Accessor >>= sOperation;
+ if( !sOperation.equalsIgnoreAsciiCaseAscii("cell-change") )
+ return;
+
+ if( nCount == 1 )
+ {
+ uno::Reference< table::XCellRange > xRangeObj;
+ aChange.ReplacedElement >>= xRangeObj;
+ if( xRangeObj.is() )
+ {
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] <<= xRangeObj;
+ mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs );
+ }
+ return;
+ }
+
+ ScRangeList aRangeList;
+ for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ aChange = aEvent.Changes[ nIndex ];
+ aChange.Accessor >>= sOperation;
+ uno::Reference< table::XCellRange > xRangeObj;
+ aChange.ReplacedElement >>= xRangeObj;
+ if( xRangeObj.is() && sOperation.equalsIgnoreAsciiCaseAscii("cell-change") )
+ {
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable( xRangeObj, uno::UNO_QUERY );
+ if( xCellRangeAddressable.is() )
+ {
+ ScRange aRange;
+ ScUnoConversion::FillScRange( aRange, xCellRangeAddressable->getRangeAddress() );
+ aRangeList.Append( aRange );
+ }
+ }
+ }
+
+ if( (aRangeList.Count() > 0) && mpDocShell )
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( mpDocShell, aRangeList ) );
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] <<= xRanges;
+ mrVbaEvents.processVbaEvent( WORKSHEET_CHANGE, aArgs );
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+uno::Reference< frame::XFrame > ScVbaEventsListener::getFrame()
+{
+ if( !mbDisposed && mxModel.is() ) try
+ {
+ uno::Reference< frame::XController > xController( mxModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ return xController->getFrame();
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return uno::Reference< frame::XFrame >();
+}
+
+uno::Reference< awt::XWindow > ScVbaEventsListener::getContainerWindow()
+{
+ try
+ {
+ uno::Reference< frame::XFrame > xFrame( getFrame(), uno::UNO_SET_THROW );
+ return xFrame->getContainerWindow();
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return uno::Reference< awt::XWindow >();
+}
+
+bool ScVbaEventsListener::isMouseReleased()
+{
+ if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) )
+ {
+ Window::PointerState aPointerState = pWindow->GetPointerState();
+ return (aPointerState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT )) == 0;
+ }
+ return false;
+}
+
+IMPL_LINK( ScVbaEventsListener, fireResizeMacro, void*, EMPTYARG )
+{
+ if( !mbDisposed && isMouseReleased() )
+ processWindowResizeMacro();
+ release();
+ return 0;
+}
+
+void ScVbaEventsListener::processWindowResizeMacro()
+{
+ OSL_TRACE( "**** Attempt to FIRE MACRO **** " );
+ if( !mbDisposed )
+ {
+ try
+ {
+ mrVbaEvents.processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+// ============================================================================
+
+ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& xContext ) :
+ VbaEventsHelperBase( rArgs, xContext ),
+ mbOpened( false )
+{
+ mpDocShell = dynamic_cast< ScDocShell* >( mpShell ); // mpShell from base class
+ mpDoc = mpDocShell ? mpDocShell->GetDocument() : 0;
+
+ if( !mxModel.is() || !mpDocShell || !mpDoc )
+ return;
+
+#define REGISTER_EVENT( eventid, eventname, type, cancelindex, worksheet ) \
+ registerEventHandler( eventid, eventname, type, cancelindex, uno::Any( worksheet ) )
+
+#define REGISTER_WORKBOOK_EVENT( eventid, eventname, cancelindex ) \
+ REGISTER_EVENT( WORKBOOK_##eventid, "Workbook_" eventname, EVENTHANDLER_DOCUMENT, cancelindex, false )
+
+#define REGISTER_WORKSHEET_EVENT( eventid, eventname, cancelindex ) \
+ REGISTER_EVENT( WORKSHEET_##eventid, "Worksheet_" eventname, EVENTHANDLER_DOCUMENT, cancelindex, true ); \
+ REGISTER_EVENT( (USERDEFINED_START + WORKSHEET_##eventid), "Workbook_Sheet" eventname, EVENTHANDLER_DOCUMENT, (((cancelindex) >= 0) ? ((cancelindex) + 1) : -1), false )
+
+ // global
+ REGISTER_EVENT( AUTO_OPEN, "Auto_Open", EVENTHANDLER_GLOBAL, -1, false );
+ REGISTER_EVENT( AUTO_CLOSE, "Auto_Close", EVENTHANDLER_GLOBAL, -1, false );
+
+ // Workbook
+ REGISTER_WORKBOOK_EVENT( ACTIVATE, "Activate", -1 );
+ REGISTER_WORKBOOK_EVENT( DEACTIVATE, "Deactivate", -1 );
+ REGISTER_WORKBOOK_EVENT( OPEN, "Open", -1 );
+ REGISTER_WORKBOOK_EVENT( BEFORECLOSE, "BeforeClose", 0 );
+ REGISTER_WORKBOOK_EVENT( BEFOREPRINT, "BeforePrint", 0 );
+ REGISTER_WORKBOOK_EVENT( BEFORESAVE, "BeforeSave", 1 );
+ REGISTER_WORKBOOK_EVENT( AFTERSAVE, "AfterSave", -1 );
+ REGISTER_WORKBOOK_EVENT( NEWSHEET, "NewSheet", -1 );
+ REGISTER_WORKBOOK_EVENT( WINDOWACTIVATE, "WindowActivate", -1 );
+ REGISTER_WORKBOOK_EVENT( WINDOWDEACTIVATE, "WindowDeactivate", -1 );
+ REGISTER_WORKBOOK_EVENT( WINDOWRESIZE, "WindowResize", -1 );
+
+ // Worksheet events. All events have a corresponding workbook event.
+ REGISTER_WORKSHEET_EVENT( ACTIVATE, "Activate", -1 );
+ REGISTER_WORKSHEET_EVENT( DEACTIVATE, "Deactivate", -1 );
+ REGISTER_WORKSHEET_EVENT( BEFOREDOUBLECLICK, "BeforeDoubleClick", 1 );
+ REGISTER_WORKSHEET_EVENT( BEFORERIGHTCLICK, "BeforeRightClick", 1 );
+ REGISTER_WORKSHEET_EVENT( CALCULATE, "Calculate", -1 );
+ REGISTER_WORKSHEET_EVENT( CHANGE, "Change", -1 );
+ REGISTER_WORKSHEET_EVENT( SELECTIONCHANGE, "SelectionChange", -1 );
+ REGISTER_WORKSHEET_EVENT( FOLLOWHYPERLINK, "FollowHyperlink", -1 );
+
+#undef REGISTER_EVENT
+#undef REGISTER_WORKBOOK_EVENT
+#undef REGISTER_WORKSHEET_EVENT
+}
+
+ScVbaEventsHelper::~ScVbaEventsHelper()
+{
+}
+
+void SAL_CALL ScVbaEventsHelper::disposing( const lang::EventObject& rSource ) throw (uno::RuntimeException)
+{
+ mxListener.clear();
+ VbaEventsHelperBase::disposing( rSource );
+}
+
+// protected ------------------------------------------------------------------
+
+bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException)
+{
+ // document and document shell are needed during event processing
+ if( !mpDocShell || !mpDoc )
+ throw uno::RuntimeException();
+
+ // get Application object and check if events are enabled (this is an Excel-only attribute)
+ uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY );
+ if( !xApplication.is() && mpShell )
+ {
+ uno::Any aVBAGlobals;
+ mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals );
+ uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY );
+ if( xHelperInterface.is() )
+ {
+ xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY );
+ mxApplication = xApplication;
+ }
+ }
+ if( !xApplication.is() )
+ throw uno::RuntimeException();
+
+ // return whether event processing is enabled
+ return xApplication->getEnableEvents();
+}
+
+bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue,
+ const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException)
+{
+ // check preconditions for some events, add more events if needed
+ bool bExecuteEvent = true;
+ switch( rInfo.mnEventId )
+ {
+ case WORKBOOK_ACTIVATE:
+ // while loading, framework fires this before 'opened' event, delay it
+ bExecuteEvent = mbOpened;
+ break;
+ case WORKBOOK_OPEN:
+ bExecuteEvent = !mbOpened;
+ if( bExecuteEvent )
+ {
+ // execute delayed Activate event too (see above)
+ rEventQueue.push_back( WORKBOOK_ACTIVATE );
+ rEventQueue.push_back( WORKBOOK_WINDOWACTIVATE );
+ rEventQueue.push_back( AUTO_OPEN );
+ }
+ break;
+ case WORKSHEET_SELECTIONCHANGE:
+ // if selection is not changed, then do not fire the event
+ bExecuteEvent = mbOpened && isSelectionChanged( rArgs, 0 );
+ break;
+ }
+
+ // add workbook event associated to a sheet event
+ bool bSheetEvent = false;
+ rInfo.maUserData >>= bSheetEvent;
+ if( bSheetEvent && bExecuteEvent )
+ rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) );
+
+ return bExecuteEvent;
+}
+
+uno::Sequence< uno::Any > ScVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& rInfo,
+ const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException)
+{
+ // fill arguments for workbook events associated to sheet events according to sheet events, sheet will be added below
+ bool bSheetEventAsBookEvent = rInfo.mnEventId > USERDEFINED_START;
+ sal_Int32 nEventId = bSheetEventAsBookEvent ? (rInfo.mnEventId - USERDEFINED_START) : rInfo.mnEventId;
+
+ uno::Sequence< uno::Any > aVbaArgs;
+ switch( nEventId )
+ {
+ // *** Workbook ***
+
+ // no arguments
+ case WORKBOOK_ACTIVATE:
+ case WORKBOOK_DEACTIVATE:
+ case WORKBOOK_OPEN:
+ break;
+ // 1 arg: cancel
+ case WORKBOOK_BEFORECLOSE:
+ case WORKBOOK_BEFOREPRINT:
+ aVbaArgs.realloc( 1 );
+ // current cancel state will be inserted by caller
+ break;
+ // 2 args: saveAs, cancel
+ case WORKBOOK_BEFORESAVE:
+ aVbaArgs.realloc( 2 );
+ checkArgumentType< bool >( rArgs, 0 );
+ aVbaArgs[ 0 ] = rArgs[ 0 ];
+ // current cancel state will be inserted by caller
+ break;
+ // 1 arg: success
+ case WORKBOOK_AFTERSAVE:
+ aVbaArgs.realloc( 1 );
+ checkArgumentType< bool >( rArgs, 0 );
+ aVbaArgs[ 0 ] = rArgs[ 0 ];
+ break;
+ // 1 arg: window
+ case WORKBOOK_WINDOWACTIVATE:
+ case WORKBOOK_WINDOWDEACTIVATE:
+ case WORKBOOK_WINDOWRESIZE:
+ aVbaArgs.realloc( 1 );
+ aVbaArgs[ 0 ] = createWindow();
+ break;
+ // 1 arg: worksheet
+ case WORKBOOK_NEWSHEET:
+ aVbaArgs.realloc( 1 );
+ aVbaArgs[ 0 ] = createWorksheet( rArgs, 0 );
+ break;
+
+ // *** Worksheet ***
+
+ // no arguments
+ case WORKSHEET_ACTIVATE:
+ case WORKSHEET_CALCULATE:
+ case WORKSHEET_DEACTIVATE:
+ break;
+ // 1 arg: range
+ case WORKSHEET_CHANGE:
+ case WORKSHEET_SELECTIONCHANGE:
+ aVbaArgs.realloc( 1 );
+ aVbaArgs[ 0 ] = createRange( rArgs, 0 );
+ break;
+ // 2 args: range, cancel
+ case WORKSHEET_BEFOREDOUBLECLICK:
+ case WORKSHEET_BEFORERIGHTCLICK:
+ aVbaArgs.realloc( 2 );
+ aVbaArgs[ 0 ] = createRange( rArgs, 0 );
+ // current cancel state will be inserted by caller
+ break;
+ // 1 arg: hyperlink
+ case WORKSHEET_FOLLOWHYPERLINK:
+ aVbaArgs.realloc( 1 );
+ aVbaArgs[ 0 ] = createHyperlink( rArgs, 0 );
+ break;
+ }
+
+ /* For workbook events associated to sheet events, the workbook event gets
+ the same arguments but with a Worksheet object in front of them. */
+ if( bSheetEventAsBookEvent )
+ {
+ sal_Int32 nLength = aVbaArgs.getLength();
+ uno::Sequence< uno::Any > aVbaArgs2( nLength + 1 );
+ aVbaArgs2[ 0 ] = createWorksheet( rArgs, 0 );
+ for( sal_Int32 nIndex = 0; nIndex < nLength; ++nIndex )
+ aVbaArgs2[ nIndex + 1 ] = aVbaArgs[ nIndex ];
+ aVbaArgs = aVbaArgs2;
+ }
+
+ return aVbaArgs;
+}
+
+void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue,
+ const EventHandlerInfo& rInfo, bool /*bSuccess*/, bool bCancel ) throw (uno::RuntimeException)
+{
+ switch( rInfo.mnEventId )
+ {
+ case WORKBOOK_OPEN:
+ mbOpened = true;
+ // register the listeners
+ if( !mxListener.is() )
+ {
+ mxListener = new ScVbaEventsListener( *this, mxModel, mpDocShell );
+ mxListener->startListening();
+ }
+ break;
+ case WORKBOOK_BEFORECLOSE:
+ /* Execute Auto_Close only if not cancelled by event handler, but
+ before UI asks user whether to cancel closing the document. */
+ if( !bCancel )
+ rEventQueue.push_back( AUTO_CLOSE );
+ break;
+ }
+}
+
+::rtl::OUString ScVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& rInfo,
+ const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException)
+{
+ bool bSheetEvent = false;
+ rInfo.maUserData >>= bSheetEvent;
+ SCTAB nTab = bSheetEvent ? getTabFromArgs( rArgs, 0 ) : -1;
+ if( bSheetEvent && (nTab < 0) )
+ throw lang::IllegalArgumentException();
+
+ String aCodeName;
+ if( bSheetEvent )
+ mpDoc->GetCodeName( nTab, aCodeName );
+ else
+ aCodeName = mpDoc->GetCodeName();
+ return aCodeName;
+}
+
+// private --------------------------------------------------------------------
+
+SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException)
+{
+ checkArgument( rArgs, nIndex );
+
+ // first try to extract a sheet index
+ SCTAB nTab = -1;
+ if( rArgs[ nIndex ] >>= nTab )
+ return nTab;
+
+ // next, try single range object
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex );
+ if( xCellRangeAddressable.is() )
+ return xCellRangeAddressable->getRangeAddress().Sheet;
+
+ // at last, try range list
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex );
+ if( xRanges.is() )
+ {
+ uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses();
+ if( aRangeAddresses.getLength() > 0 )
+ return aRangeAddresses[ 0 ].Sheet;
+ }
+
+ throw lang::IllegalArgumentException();
+}
+
+bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false );
+ if( ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ) )
+ {
+ bool bChanged = maOldSelection != pNewCellRanges->GetRangeList();
+ maOldSelection = pNewCellRanges->GetRangeList();
+ return bChanged;
+ }
+ maOldSelection.Clear();
+ return true;
+}
+
+uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ // Eventually we will be able to pull the Workbook/Worksheet objects
+ // directly from basic and register them as listeners
+
+ // extract sheet index, will throw, if parameter is invalid
+ SCTAB nTab = getTabFromArgs( rArgs, nIndex );
+
+ // create Workbook
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[ 0 ] <<= uno::Reference< uno::XInterface >();
+ aArgs[ 1 ] <<= mxModel;
+ uno::Reference< uno::XInterface > xWorkbook( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Workbook", aArgs ), uno::UNO_SET_THROW );
+
+ // create WorkSheet
+ String aSheetName;
+ mpDoc->GetName( nTab, aSheetName );
+ aArgs = uno::Sequence< uno::Any >( 3 );
+ aArgs[ 0 ] <<= xWorkbook;
+ aArgs[ 1 ] <<= mxModel;
+ aArgs[ 2 ] <<= ::rtl::OUString( aSheetName );
+ uno::Reference< uno::XInterface > xWorksheet( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Worksheet", aArgs ), uno::UNO_SET_THROW );
+ return uno::Any( xWorksheet );
+}
+
+uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex );
+ uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex );
+ if ( !xRanges.is() && !xRange.is() )
+ throw lang::IllegalArgumentException();
+
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent
+ if ( xRanges.is() )
+ aArgs[ 1 ] <<= xRanges;
+ else
+ aArgs[ 1 ] <<= xRange;
+ uno::Reference< uno::XInterface > xVbaRange( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_SET_THROW );
+ return uno::Any( xVbaRange );
+}
+
+uno::Any ScVbaEventsHelper::createHyperlink( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent
+ aArgs[ 1 ] <<= getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false );
+ uno::Reference< uno::XInterface > xHyperlink( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Hyperlink", aArgs ), uno::UNO_SET_THROW );
+ return uno::Any( xHyperlink );
+}
+
+uno::Any ScVbaEventsHelper::createWindow() const throw (uno::RuntimeException)
+{
+ uno::Sequence< uno::Any > aArgs( 2 );
+ aArgs[ 0 ] <<= createVBAUnoAPIService( mpShell, "ooo.vba.Application" );
+ aArgs[ 1 ] <<= mxModel;
+ uno::Reference< uno::XInterface > xWindow( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Window", aArgs ), uno::UNO_SET_THROW );
+ return uno::Any( xWindow );
+}
+
+// ============================================================================
+
+namespace vbaeventshelper
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::class_<ScVbaEventsHelper, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaEventsHelper",
+ "com.sun.star.script.vba.VBASpreadsheetEventProcessor" );
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx
new file mode 100644
index 000000000000..3bd9655139b5
--- /dev/null
+++ b/sc/source/ui/vba/vbaeventshelper.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBAEVENTS_HXX
+#define SC_VBAEVENTS_HXX
+
+#include <rtl/ref.hxx>
+#include <vbahelper/vbaeventshelperbase.hxx>
+#include "excelvbahelper.hxx"
+#include "rangelst.hxx"
+
+namespace ooo { namespace vba { namespace excel { class XApplication; } } }
+
+class ScVbaEventsListener;
+
+// ============================================================================
+
+class ScVbaEventsHelper : public VbaEventsHelperBase
+{
+public:
+ ScVbaEventsHelper(
+ const css::uno::Sequence< css::uno::Any >& rArgs,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext );
+ virtual ~ScVbaEventsHelper();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) throw (css::uno::RuntimeException);
+
+protected:
+ virtual bool implEventsEnabled() throw (css::uno::RuntimeException);
+ virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException);
+ virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException);
+ virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException);
+
+private:
+ /** Extracts a sheet index from the first element of the passed sequence. The
+ element may be an integer, or a Calc range or ranges object. */
+ static SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException);
+ /** Checks if selection has been changed compared to selection of last call.
+ @return true, if the selection has been changed. */
+ bool isSelectionChanged( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+
+ /** Creates a VBA Worksheet object (the argument must contain a sheet index). */
+ css::uno::Any createWorksheet( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+ /** Creates a VBA Range object (the argument must contain a UNO range or UNO range list). */
+ css::uno::Any createRange( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+ /** Creates a VBA Hyperlink object (the argument must contain a UNO cell). */
+ css::uno::Any createHyperlink( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException);
+ /** Creates a VBA Window object. */
+ css::uno::Any createWindow() const throw (css::uno::RuntimeException);
+
+private:
+ mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication;
+ ::rtl::Reference< ScVbaEventsListener > mxListener;
+ ScDocShell* mpDocShell;
+ ScDocument* mpDoc;
+ ScRangeList maOldSelection;
+ bool mbOpened;
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialog.cxx b/sc/source/ui/vba/vbafiledialog.cxx
new file mode 100644
index 000000000000..9cb308529b88
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialog.cxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbafiledialog.hxx"
+#include "comphelper/processfactory.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
+#include <com/sun/star/ui/dialogs/XFilePicker2.hpp>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+#include "tools/urlobj.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+ScVbaFileDialog::ScVbaFileDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel )
+: ScVbaFileDialog_BASE( xParent, xContext, xModel )
+{
+ m_pFileDialogSelectedItems = new VbaFileDialogSelectedItems(xParent, xContext, (com::sun::star::container::XIndexAccess *)&m_FileDialogSelectedObj);
+}
+
+ScVbaFileDialog::~ScVbaFileDialog()
+{
+ if (m_pFileDialogSelectedItems != NULL)
+ {
+ delete m_pFileDialogSelectedItems;
+ }
+}
+
+rtl::OUString&
+ScVbaFileDialog::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFileDialog") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaFileDialog::getServiceNames()
+{
+ static Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FileDialog" ) );
+ }
+ return aServiceNames;
+
+}
+
+css::uno::Reference< ov::XFileDialogSelectedItems > SAL_CALL
+ScVbaFileDialog::getSelectedItems() throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< ov::XFileDialogSelectedItems > xFileDlgSlc = (ov::XFileDialogSelectedItems *)m_pFileDialogSelectedItems;
+ return xFileDlgSlc;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaFileDialog::Show( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ // Returns an Integer indicating if user pressed "Open" button(-1) or "Cancel" button(0).
+ sal_Int32 nResult = -1;
+ try
+ {
+ m_sSelectedItems.realloc(0);
+
+ const ::rtl::OUString sServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.FilePicker" );
+
+ Reference< lang::XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory(), uno::UNO_QUERY );
+ // Set the type of File Picker Dialog: TemplateDescription::FILEOPEN_SIMPLE.
+ Sequence< uno::Any > aDialogType( 1 );
+ aDialogType[0] <<= ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE;
+ Reference < ui::dialogs::XFilePicker > xFilePicker( xMSF->createInstanceWithArguments( sServiceName, aDialogType ), UNO_QUERY );
+ Reference < ui::dialogs::XFilePicker2 > xFilePicker2( xFilePicker, UNO_QUERY );
+ if ( xFilePicker.is() )
+ {
+ xFilePicker->setMultiSelectionMode(sal_True);
+ if ( xFilePicker->execute() )
+ {
+ sal_Bool bUseXFilePicker2 = sal_False;
+ Reference< lang::XServiceInfo > xServiceInfo( xFilePicker, UNO_QUERY );
+ if (xServiceInfo.is())
+ {
+ rtl::OUString sImplName = xServiceInfo->getImplementationName();
+ if (sImplName.equalsAscii("com.sun.star.comp.fpicker.VistaFileDialog") ||
+ sImplName.equalsAscii("com.sun.star.ui.dialogs.SalGtkFilePicker"))
+ {
+ bUseXFilePicker2 = sal_True;
+ }
+ }
+ if ( bUseXFilePicker2 && xFilePicker2.is() )
+ {
+ // On Linux, XFilePicker->getFiles() always return one selected file although we select
+ // more than one file, also on Vista XFilePicker->getFiles() does not work well too,
+ // so we call XFilePicker2->getSelectedFiles() to get selected files.
+ m_sSelectedItems = xFilePicker2->getSelectedFiles();
+ }
+ else
+ {
+ // If only one file is selected, the first entry of the sequence contains the complete path/filename in
+ // URL format. If multiple files are selected, the first entry of the sequence contains the path in URL
+ // format, and the other entries contains the names of the selected files without path information.
+ Sequence< rtl::OUString > aSelectedFiles = xFilePicker->getFiles();
+ sal_Int32 iFileCount = aSelectedFiles.getLength();
+ if ( iFileCount > 1 )
+ {
+ m_sSelectedItems.realloc( iFileCount - 1 );
+ INetURLObject aPath( aSelectedFiles[0] );
+ aPath.setFinalSlash();
+ for ( sal_Int32 i = 1; i < iFileCount; i++ )
+ {
+ if ( aSelectedFiles[i].indexOf ('/') > 0 || aSelectedFiles[i].indexOf ('\\') > 0 )
+ {
+ m_sSelectedItems[i - 1] = aSelectedFiles[i];
+ }
+ else
+ {
+ if ( i == 1 )
+ aPath.Append( aSelectedFiles[i] );
+ else
+ aPath.setName( aSelectedFiles[i] );
+ m_sSelectedItems[i - 1] = aPath.GetMainURL(INetURLObject::NO_DECODE);
+ }
+ }
+ }
+ else if ( iFileCount == 1 )
+ {
+ m_sSelectedItems = aSelectedFiles;
+ }
+ }
+
+ sal_Int32 iFileCount = m_sSelectedItems.getLength();
+ rtl::OUString aTemp;
+ for ( sal_Int32 i = 0; i < iFileCount; i++ )
+ {
+ INetURLObject aObj( m_sSelectedItems[i] );
+ if ( aObj.GetProtocol() == INET_PROT_FILE )
+ {
+ aTemp = aObj.PathToFileName();
+ m_sSelectedItems[i] = aTemp.getLength() > 0 ? aTemp : m_sSelectedItems[i];
+ }
+ }
+ }
+ else
+ {
+ nResult = 0;
+ }
+ }
+
+ m_FileDialogSelectedObj.SetSelectedFile(m_sSelectedItems);
+ }
+ catch( const uno::Exception& )
+ {
+ return 0;
+ }
+
+ return nResult;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialog.hxx b/sc/source/ui/vba/vbafiledialog.hxx
new file mode 100644
index 000000000000..ac905f541185
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialog.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _vbafiledialog_hxx_
+#define _vbafiledialog_hxx_
+
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbadialogsbase.hxx>
+#include <ooo/vba/XFileDialog.hpp>
+#include "vbafiledialogselecteditems.hxx"
+
+
+typedef cppu::ImplInheritanceHelper1< VbaDialogsBase, ov::XFileDialog > ScVbaFileDialog_BASE;
+
+class ScVbaFileDialog : public ScVbaFileDialog_BASE
+{
+public:
+
+ ScVbaFileDialog( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::frame::XModel >& xModel ) ;
+ virtual ~ScVbaFileDialog() ;
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+ //XFileDialog
+ virtual css::uno::Reference< ov::XFileDialogSelectedItems > SAL_CALL getSelectedItems() throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL Show( ) throw (::com::sun::star::uno::RuntimeException) ;
+
+private:
+ css::uno::Sequence < rtl::OUString > m_sSelectedItems;
+ VbaFileDialogSelectedItems *m_pFileDialogSelectedItems;
+ VbaFileDialogSelectedObj m_FileDialogSelectedObj;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.cxx b/sc/source/ui/vba/vbafiledialogselecteditems.cxx
new file mode 100644
index 000000000000..d8ebc937b489
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialogselecteditems.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbafiledialogselecteditems.hxx"
+
+using namespace ::com::sun::star;
+
+VbaFileDialogSelectedItems::VbaFileDialogSelectedItems( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess
+ )
+ : FileDialogSelectedItems_BASE( xParent, xContext, xIndexAccess )
+{
+}
+
+
+rtl::OUString& VbaFileDialogSelectedItems::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaFileDialogSelectedItems") );
+ return sImplName;
+
+}
+css::uno::Sequence<rtl::OUString> VbaFileDialogSelectedItems::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.FileDialogSelectedItems" ) );
+ }
+ return aServiceNames;
+
+}
+
+css::uno::Any VbaFileDialogSelectedItems::createCollectionObject( const css::uno::Any& aSource )
+{
+ css::uno::Any aRet;
+ aRet = aSource;
+ return aRet;
+}
+
+
+css::uno::Type SAL_CALL
+VbaFileDialogSelectedItems::getElementType() throw (css::uno::RuntimeException)
+{
+ return ooo::vba::XFileDialogSelectedItems::static_type(0);
+}
+
+css::uno::Reference< css::container::XEnumeration > SAL_CALL
+VbaFileDialogSelectedItems::createEnumeration() throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::container::XEnumeration > xEnumRet(m_xIndexAccess, css::uno::UNO_QUERY);
+ return xEnumRet;
+}
+
+
+//VbaFileDialogSelectedObj
+//////////////////////////////////////////////////////////////////////////
+
+VbaFileDialogSelectedObj::VbaFileDialogSelectedObj()
+{
+ m_nIndex = 0;
+}
+
+
+sal_Bool
+VbaFileDialogSelectedObj::SetSelectedFile(css::uno::Sequence<rtl::OUString> &sFList)
+{
+ m_sFileList = sFList;
+ return sal_True;
+}
+
+sal_Int32 SAL_CALL
+VbaFileDialogSelectedObj::getCount() throw(::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 nListCnt = m_sFileList.getLength();
+ return nListCnt;
+}
+
+::com::sun::star::uno::Any SAL_CALL VbaFileDialogSelectedObj::getByIndex( sal_Int32 nIndex )
+throw(::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ css::uno::Any aRet;
+
+ if ( nIndex >= getCount() )
+ {
+ throw css::lang::IndexOutOfBoundsException();
+ }
+
+ return uno::makeAny(m_sFileList[nIndex]);
+}
+
+::com::sun::star::uno::Type SAL_CALL
+VbaFileDialogSelectedObj::getElementType()
+throw(::com::sun::star::uno::RuntimeException)
+{
+ return getCppuType((uno::Reference<com::sun::star::container::XIndexAccess>*)0);
+}
+
+sal_Bool SAL_CALL VbaFileDialogSelectedObj::hasElements()
+throw(::com::sun::star::uno::RuntimeException)
+{
+ return ( getCount() != 0 );
+}
+
+::sal_Bool SAL_CALL
+VbaFileDialogSelectedObj::hasMoreElements( )
+throw (uno::RuntimeException)
+{
+ if (getCount() > m_nIndex)
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
+uno::Any SAL_CALL
+VbaFileDialogSelectedObj::nextElement( )
+throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if (!hasMoreElements())
+ {
+ throw container::NoSuchElementException();
+ }
+
+ return uno::makeAny(m_sFileList[m_nIndex++]);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafiledialogselecteditems.hxx b/sc/source/ui/vba/vbafiledialogselecteditems.hxx
new file mode 100644
index 000000000000..063bc502667a
--- /dev/null
+++ b/sc/source/ui/vba/vbafiledialogselecteditems.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _vbafiledialogselecteditems_hxx_
+#define _vbafiledialogselecteditems_hxx_
+
+#include <ooo/vba/XFileDialogSelectedItems.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+typedef CollTestImplHelper< ov::XFileDialogSelectedItems > FileDialogSelectedItems_BASE;
+
+
+class VbaFileDialogSelectedItems : public FileDialogSelectedItems_BASE
+{
+public:
+ VbaFileDialogSelectedItems( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+protected:
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+private:
+};
+
+
+class VbaFileDialogSelectedObj : public cppu::WeakImplHelper2<css::container::XIndexAccess, css::container::XEnumeration>
+{
+public:
+ VbaFileDialogSelectedObj();
+ sal_Bool SetSelectedFile(css::uno::Sequence<rtl::OUString> &sFList);
+ //XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex )
+ throw(::com::sun::star::lang::IndexOutOfBoundsException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
+
+ //XEnumeration
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL nextElement( ) throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+protected:
+private:
+ css::uno::Sequence<rtl::OUString> m_sFileList;
+ sal_Int32 m_nIndex;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafilesearch.cxx b/sc/source/ui/vba/vbafilesearch.cxx
new file mode 100644
index 000000000000..6df035c21c2b
--- /dev/null
+++ b/sc/source/ui/vba/vbafilesearch.cxx
@@ -0,0 +1,245 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbafilesearch.hxx"
+#include "vbaapplication.hxx"
+#include "vbafoundfiles.hxx"
+#include <comphelper/processfactory.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/wldcrd.hxx>
+#include <com/sun/star/ucb/XSimpleFileAccess3.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <vector>
+#include "unotools/viewoptions.hxx"
+#include <osl/file.hxx>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::lang;
+using namespace comphelper;
+
+static Reference< XSimpleFileAccess3 > getFileAccess( void )
+{
+ static Reference< XSimpleFileAccess3 > xSFI;
+ if( !xSFI.is() )
+ {
+ Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory();
+ if( xSMgr.is() )
+ {
+ xSFI = Reference< XSimpleFileAccess3 >( xSMgr->createInstance
+ ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY );
+ }
+ }
+ return xSFI;
+}
+
+ScVbaFileSearch::ScVbaFileSearch( ScVbaApplication* pApp, const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext )
+ : ScVbaFileSearchImpl_BASE( xParent, xContext ), m_pApplication( pApp )
+{
+ NewSearch();
+}
+
+ScVbaFileSearch::~ScVbaFileSearch()
+{
+}
+
+::rtl::OUString SAL_CALL ScVbaFileSearch::getFileName() throw (css::uno::RuntimeException)
+{
+ return m_sFileName;
+}
+
+void SAL_CALL ScVbaFileSearch::setFileName(const ::rtl::OUString& _fileName ) throw (css::uno::RuntimeException)
+{
+ m_sFileName = _fileName;
+}
+
+::rtl::OUString SAL_CALL ScVbaFileSearch::getLookIn() throw (css::uno::RuntimeException)
+{
+ return m_sLookIn;
+}
+
+void SAL_CALL ScVbaFileSearch::setLookIn( const ::rtl::OUString& _lookIn ) throw (css::uno::RuntimeException)
+{
+ m_sLookIn = _lookIn;
+}
+
+sal_Bool SAL_CALL ScVbaFileSearch::getSearchSubFolders() throw (css::uno::RuntimeException)
+{
+ return m_bSearchSubFolders;
+}
+
+void SAL_CALL ScVbaFileSearch::setSearchSubFolders( sal_Bool _searchSubFolders ) throw (css::uno::RuntimeException)
+{
+ m_bSearchSubFolders = _searchSubFolders;
+}
+
+sal_Bool SAL_CALL ScVbaFileSearch::getMatchTextExactly() throw (css::uno::RuntimeException)
+{
+ return m_bMatchTextExactly;
+}
+
+void SAL_CALL ScVbaFileSearch::setMatchTextExactly( sal_Bool _matchTextExactly ) throw (css::uno::RuntimeException)
+{
+ m_bMatchTextExactly = _matchTextExactly;
+}
+
+static bool IsWildCard( const ::rtl::OUString& fileName )
+{
+ static sal_Char cWild1 = '*';
+ static sal_Char cWild2 = '?';
+
+ return ( ( fileName.indexOf( cWild1 ) >= 0 )
+ || ( fileName.indexOf( cWild2 ) >= 0 ) );
+}
+
+static void SearchWildCard(const WildCard& wildCard, const ::rtl::OUString& aDir, bool bSearchSubFolders, css::uno::Sequence< rtl::OUString >& aSearchedFiles)
+{
+ Reference< XSimpleFileAccess3 > xSFI = getFileAccess();
+ Sequence< rtl::OUString > aDirSeq;
+ try
+ {
+ if ( xSFI.is() )
+ {
+ aDirSeq = xSFI->getFolderContents( aDir, bSearchSubFolders );
+ }
+ }
+ catch( css::uno::Exception& )
+ {
+ }
+ sal_Int32 nLength = aDirSeq.getLength();
+ for ( sal_Int32 i = 0; i < nLength; i++ )
+ {
+ rtl::OUString aURLStr = aDirSeq[i];
+ if ( xSFI->isFolder( aURLStr ) )
+ {
+ if ( bSearchSubFolders )
+ {
+ SearchWildCard( wildCard, aURLStr, true, aSearchedFiles );
+ }
+ }
+ else
+ {
+ INetURLObject aFileURL( aURLStr );
+ rtl::OUString aFileName = aFileURL.GetLastName( INetURLObject::DECODE_UNAMBIGUOUS );
+ if ( wildCard.Matches( aFileName.toAsciiLowerCase() ) )
+ {
+ sal_Int32 nFilesLength = aSearchedFiles.getLength();
+ aSearchedFiles.realloc( nFilesLength + 1 );
+ rtl::OUString sSystemPath;
+ ::osl::File::getSystemPathFromFileURL( aURLStr, sSystemPath );
+ aSearchedFiles[nFilesLength] = sSystemPath;
+ }
+ }
+ }
+}
+
+sal_Int32 SAL_CALL ScVbaFileSearch::Execute( ) throw (css::uno::RuntimeException)
+{
+ m_aSearchedFiles.realloc(0);
+ Reference< XSimpleFileAccess3 > xSFI = getFileAccess();
+ if ( !xSFI.is() || !xSFI->isFolder( m_sLookIn ) )
+ {
+ return 0;
+ }
+
+ if ( m_sFileName == ::rtl::OUString::createFromAscii( "" ) )
+ {
+ return 1;
+ }
+
+ ::rtl::OUString aTempFileName = m_sFileName.toAsciiLowerCase();
+ if ( IsWildCard( aTempFileName ) )
+ {
+ bool bEndWithAsterisk = aTempFileName.endsWithAsciiL("*", 1);
+ bool bStartWithAsterisk = (aTempFileName.indexOf(::rtl::OUString::createFromAscii("*")) == 0);
+ if ( !bEndWithAsterisk && !bStartWithAsterisk )
+ {
+ aTempFileName = ::rtl::OUString::createFromAscii("*") + aTempFileName + ::rtl::OUString::createFromAscii("*");
+ }
+ }
+ else
+ {
+ aTempFileName = ::rtl::OUString::createFromAscii("*") + aTempFileName + ::rtl::OUString::createFromAscii("*");
+ }
+ WildCard wildCard( aTempFileName );
+ SearchWildCard( wildCard, m_sLookIn, m_bSearchSubFolders, m_aSearchedFiles );
+
+ return m_aSearchedFiles.getLength();
+}
+
+//liuchen 2009-11-5 set ScVbaApplication::getDefaultFilePath( ) as the InitPath for FileSearch
+ ::rtl::OUString ScVbaFileSearch::getInitPath() throw (css::uno::RuntimeException)
+{
+ String aPath;
+
+ if (m_pApplication != NULL)
+ {
+ aPath = m_pApplication->getDefaultFilePath();
+ }
+
+ return aPath;
+}
+
+void SAL_CALL ScVbaFileSearch::NewSearch( ) throw (css::uno::RuntimeException)
+{
+ m_sFileName = ::rtl::OUString::createFromAscii( "" );
+ m_sLookIn = getInitPath();
+ m_bSearchSubFolders = false;
+ m_bMatchTextExactly = false;
+ m_aSearchedFiles.realloc(0);
+}
+
+Reference< XFoundFiles > SAL_CALL ScVbaFileSearch::getFoundFiles() throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< ov::XFoundFiles > xFoundFiles = new VbaFoundFiles(
+ mxParent, mxContext, (css::container::XIndexAccess *) new VbaFoundFilesEnum(m_aSearchedFiles) );
+ return xFoundFiles;
+}
+
+rtl::OUString& ScVbaFileSearch::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaFileSearch") );
+ return sImplName;
+}
+
+css::uno::Sequence< rtl::OUString > ScVbaFileSearch::getServiceNames()
+{
+ static css::uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.FileSearch") );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafilesearch.hxx b/sc/source/ui/vba/vbafilesearch.hxx
new file mode 100644
index 000000000000..33e9caa53ca6
--- /dev/null
+++ b/sc/source/ui/vba/vbafilesearch.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_FILESEARCH_HXX
+#define SC_VBA_FILESEARCH_HXX
+
+#include <ooo/vba/XFileSearch.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbahelperinterface.hxx>
+
+namespace css = ::com::sun::star;
+
+typedef InheritedHelperInterfaceImpl1< ooo::vba::XFileSearch > ScVbaFileSearchImpl_BASE;
+
+class ScVbaApplication;
+
+class ScVbaFileSearch : public ScVbaFileSearchImpl_BASE
+{
+private:
+ rtl::OUString m_sFileName;
+ rtl::OUString m_sLookIn;
+ sal_Bool m_bSearchSubFolders;
+ sal_Bool m_bMatchTextExactly;
+ ScVbaApplication* m_pApplication;
+ css::uno::Sequence< rtl::OUString > m_aSearchedFiles;
+
+ ::rtl::OUString getInitPath() throw (css::uno::RuntimeException);
+
+public:
+ ScVbaFileSearch( ScVbaApplication* pApp, const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ virtual ~ScVbaFileSearch();
+
+ // Attributes
+ virtual ::rtl::OUString SAL_CALL getFileName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFileName(const ::rtl::OUString& _fileName ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getLookIn() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLookIn(const ::rtl::OUString& _lookIn ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getSearchSubFolders() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSearchSubFolders( sal_Bool _searchSubFolders ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMatchTextExactly() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setMatchTextExactly( sal_Bool _matchTextExactly ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::XFoundFiles > SAL_CALL getFoundFiles() throw (css::uno::RuntimeException);
+
+ virtual sal_Int32 SAL_CALL Execute( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL NewSearch( ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence< rtl::OUString > getServiceNames();
+};
+
+#endif /* SC_VBA_FILESEARCH_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafont.cxx b/sc/source/ui/vba/vbafont.cxx
new file mode 100644
index 000000000000..1d37851785fe
--- /dev/null
+++ b/sc/source/ui/vba/vbafont.cxx
@@ -0,0 +1,504 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <com/sun/star/beans/XProperty.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/text/XSimpleText.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <ooo/vba/excel/XlColorIndex.hpp>
+#include <ooo/vba/excel/XlUnderlineStyle.hpp>
+#include <svl/itemset.hxx>
+#include "excelvbahelper.hxx"
+#include "vbafont.hxx"
+#include "scitems.hxx"
+#include "cellsuno.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaFont::ScVbaFont(
+ const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const ScVbaPalette& dPalette,
+ const uno::Reference< beans::XPropertySet >& xPropertySet,
+ ScCellRangeObj* pRangeObj, bool bFormControl ) throw ( uno::RuntimeException ) :
+ ScVbaFont_BASE( xParent, xContext, dPalette.getPalette(), xPropertySet, bFormControl ),
+ mPalette( dPalette ),
+ mpRangeObj( pRangeObj )
+{
+}
+
+SfxItemSet*
+ScVbaFont::GetDataSet()
+{
+ return mpRangeObj ? excel::ScVbaCellRangeAccess::GetDataSet( mpRangeObj ) : 0;
+}
+
+ScVbaFont::~ScVbaFont()
+{
+}
+
+
+uno::Reference< beans::XPropertySet > lcl_TextProperties( uno::Reference< table::XCell >& xIf ) throw ( uno::RuntimeException )
+{
+ uno::Reference< text::XTextRange > xTxtRange( xIf, uno::UNO_QUERY_THROW );
+ uno::Reference< text::XSimpleText > xTxt( xTxtRange->getText(), uno::UNO_QUERY_THROW ) ;
+ uno::Reference< beans::XPropertySet > xProps( xTxt->createTextCursor(), uno::UNO_QUERY_THROW );
+ return xProps;
+}
+void SAL_CALL
+ScVbaFont::setSuperscript( const uno::Any& aValue ) throw ( uno::RuntimeException )
+{
+ // #FIXEME create some sort of generic get/set code where
+ // you can pass a functor
+ // get/set - Super/sub script code is exactly the same
+ // except for the call applied at each cell position
+ uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
+ uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
+ if ( !xCell.is() )
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
+ sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
+ sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
+ for ( sal_Int32 col = 0; col < nCols; ++col )
+ {
+ for ( sal_Int32 row = 0; row < nRows; ++row )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
+ ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
+ aFont.setSuperscript( aValue );
+ }
+ }
+ return;
+
+ }
+ xCell.set( xCellRange->getCellByPosition( 0,0 ) );
+
+ uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
+ sal_Bool bValue = sal_False;
+ aValue >>= bValue;
+ sal_Int16 nValue = NORMAL;
+ sal_Int8 nValue2 = NORMALHEIGHT;
+
+ if( bValue )
+ {
+ nValue = SUPERSCRIPT;
+ nValue2 = SUPERSCRIPTHEIGHT;
+ }
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ), ( uno::Any )nValue );
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapementHeight" ) ), ( uno::Any )nValue2 );
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getSuperscript() throw ( uno::RuntimeException )
+{
+ uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
+ uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
+ if ( !xCell.is() )
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
+ sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
+ sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
+ uno::Any aRes;
+ for ( sal_Int32 col = 0; col < nCols; ++col )
+ {
+ for ( sal_Int32 row = 0; row < nRows; ++row )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
+ ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
+ if ( !col && !row )
+ aRes = aFont.getSuperscript();
+ else if ( aRes != aFont.getSuperscript() )
+ return aNULL();
+ }
+ }
+ return aRes;
+
+ }
+ xCell.set( xCellRange->getCellByPosition( 0,0 ) );
+ uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
+ short nValue = 0;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue;
+ return uno::makeAny( ( nValue == SUPERSCRIPT ) );
+}
+
+void SAL_CALL
+ScVbaFont::setSubscript( const uno::Any& aValue ) throw ( uno::RuntimeException )
+{
+ uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
+ uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
+ if ( !xCell.is() )
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
+ sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
+ sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
+ for ( sal_Int32 col = 0; col < nCols; ++col )
+ {
+ for ( sal_Int32 row = 0; row < nRows; ++row )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ) , uno::UNO_QUERY_THROW );
+ ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
+ aFont.setSubscript( aValue );
+ }
+ }
+ return;
+
+ }
+ xCell.set( xCellRange->getCellByPosition( 0,0 ) );
+ uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
+
+ sal_Bool bValue = sal_False;
+ aValue >>= bValue;
+ sal_Int16 nValue = NORMAL;
+ sal_Int8 nValue2 = NORMALHEIGHT;
+
+ if( bValue )
+ {
+ nValue= SUBSCRIPT;
+ nValue2 = SUBSCRIPTHEIGHT;
+ }
+
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapementHeight" ) ), ( uno::Any )nValue2 );
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ), ( uno::Any )nValue );
+
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getSubscript() throw ( uno::RuntimeException )
+{
+ uno::Reference< table::XCell> xCell( mxFont, uno::UNO_QUERY );
+ uno::Reference< table::XCellRange > xCellRange( mxFont, uno::UNO_QUERY );
+ if ( !xCell.is() )
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xCellRange, uno::UNO_QUERY_THROW );
+ sal_Int32 nCols = xColumnRowRange->getColumns()->getCount();
+ sal_Int32 nRows = xColumnRowRange->getRows()->getCount();
+ uno::Any aRes;
+ for ( sal_Int32 col = 0; col < nCols; ++col )
+ {
+ for ( sal_Int32 row = 0; row < nRows; ++row )
+ {
+ uno::Reference< beans::XPropertySet > xProps( xCellRange->getCellByPosition( col, row ), uno::UNO_QUERY_THROW );
+ ScVbaFont aFont( getParent(), mxContext, mPalette, xProps );
+ if ( !col && !row )
+ aRes = aFont.getSubscript();
+ else if ( aRes != aFont.getSubscript() )
+ return aNULL();
+ }
+ }
+ return aRes;
+
+ }
+ xCell.set( xCellRange->getCellByPosition( 0,0 ) );
+ uno::Reference< beans::XPropertySet > xProps = lcl_TextProperties( xCell );
+
+ short nValue = NORMAL;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharEscapement" ) ) ) >>= nValue;
+ return uno::makeAny( ( nValue == SUBSCRIPT ) );
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getSize() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_HEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return ScVbaFont_BASE::getSize();
+}
+
+void SAL_CALL
+ScVbaFont::setColorIndex( const uno::Any& _colorindex ) throw( uno::RuntimeException )
+{
+ sal_Int32 nIndex = 0;
+ _colorindex >>= nIndex;
+ // #FIXME xlColorIndexAutomatic & xlColorIndexNone are not really
+ // handled properly here
+
+ if ( !nIndex || ( nIndex == excel::XlColorIndex::xlColorIndexAutomatic ) )
+ {
+ nIndex = 1; // check defualt ( assume black )
+ ScVbaFont_BASE::setColorIndex( uno::makeAny( nIndex ) );
+ }
+ else
+ ScVbaFont_BASE::setColorIndex( _colorindex );
+}
+
+
+uno::Any SAL_CALL
+ScVbaFont::getColorIndex() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_COLOR, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return ScVbaFont_BASE::getColorIndex();
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+void SAL_CALL
+ScVbaFont::setStandardFontSize( const uno::Any& /*aValue*/ ) throw( uno::RuntimeException )
+{
+//XXX #TODO# #FIXME#
+ //mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharSize" ) ), ( uno::Any )fValue );
+ throw uno::RuntimeException(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setStandardFontSize not supported") ), uno::Reference< uno::XInterface >() );
+}
+
+
+uno::Any SAL_CALL
+ScVbaFont::getStandardFontSize() throw ( uno::RuntimeException )
+{
+//XXX #TODO# #FIXME#
+ throw uno::RuntimeException(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getStandardFontSize not supported") ), uno::Reference< uno::XInterface >() );
+ // return uno::Any();
+}
+
+
+void SAL_CALL
+ScVbaFont::setStandardFont( const uno::Any& /*aValue*/ ) throw( uno::RuntimeException )
+{
+//XXX #TODO# #FIXME#
+ throw uno::RuntimeException(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("setStandardFont not supported") ), uno::Reference< uno::XInterface >() );
+}
+
+
+uno::Any SAL_CALL
+ScVbaFont::getStandardFont() throw ( uno::RuntimeException )
+{
+//XXX #TODO# #FIXME#
+ throw uno::RuntimeException(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("getStandardFont not supported") ), uno::Reference< uno::XInterface >() );
+ // return uno::Any();
+}
+
+void SAL_CALL
+ScVbaFont::setFontStyle( const uno::Any& aValue ) throw( uno::RuntimeException )
+{
+ sal_Bool bBold = sal_False;
+ sal_Bool bItalic = sal_False;
+
+ rtl::OUString aStyles;
+ aValue >>= aStyles;
+
+ std::vector< rtl::OUString > aTokens;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ rtl::OUString aToken = aStyles.getToken( 0, ' ', nIndex );
+ aTokens.push_back( aToken );
+ }while( nIndex >= 0 );
+
+ std::vector< rtl::OUString >::iterator it;
+ for( it = aTokens.begin(); it != aTokens.end(); ++it )
+ {
+ if( (*it).equalsIgnoreAsciiCaseAscii( "Bold" ) )
+ bBold = sal_True;
+
+ if( (*it).equalsIgnoreAsciiCaseAscii( "Italic" ) )
+ bItalic = sal_True;
+ }
+
+ setBold( uno::makeAny( bBold ) );
+ setItalic( uno::makeAny( bItalic ) );
+}
+
+
+uno::Any SAL_CALL
+ScVbaFont::getFontStyle() throw ( uno::RuntimeException )
+{
+ rtl::OUStringBuffer aStyles;
+ sal_Bool bValue = sal_False;
+ getBold() >>= bValue;
+ if( bValue )
+ aStyles.appendAscii("Bold");
+
+ getItalic() >>= bValue;
+ if( bValue )
+ {
+ if( aStyles.getLength() )
+ aStyles.appendAscii(" ");
+ aStyles.appendAscii("Italic");
+ }
+ return uno::makeAny( aStyles.makeStringAndClear() );
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getBold() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_WEIGHT, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return ScVbaFont_BASE::getBold();
+}
+
+void SAL_CALL
+ScVbaFont::setUnderline( const uno::Any& aValue ) throw ( uno::RuntimeException )
+{
+ // default
+ sal_Int32 nValue = excel::XlUnderlineStyle::xlUnderlineStyleNone;
+ aValue >>= nValue;
+ switch ( nValue )
+ {
+// NOTE:: #TODO #FIMXE
+// xlUnderlineStyleDoubleAccounting & xlUnderlineStyleSingleAccounting
+// don't seem to be supported in Openoffice.
+// The import filter converts them to single or double underlines as appropriate
+// So, here at the moment we are similarly silently converting
+// xlUnderlineStyleSingleAccounting to xlUnderlineStyleSingle.
+
+ case excel::XlUnderlineStyle::xlUnderlineStyleNone:
+ nValue = awt::FontUnderline::NONE;
+ break;
+ case excel::XlUnderlineStyle::xlUnderlineStyleSingle:
+ case excel::XlUnderlineStyle::xlUnderlineStyleSingleAccounting:
+ nValue = awt::FontUnderline::SINGLE;
+ break;
+ case excel::XlUnderlineStyle::xlUnderlineStyleDouble:
+ case excel::XlUnderlineStyle::xlUnderlineStyleDoubleAccounting:
+ nValue = awt::FontUnderline::DOUBLE;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown value for Underline")), uno::Reference< uno::XInterface >() );
+ }
+
+ mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ), ( uno::Any )nValue );
+
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getUnderline() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_UNDERLINE, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+
+ sal_Int32 nValue = awt::FontUnderline::NONE;
+ mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharUnderline" ) ) ) >>= nValue;
+ switch ( nValue )
+ {
+ case awt::FontUnderline::DOUBLE:
+ nValue = excel::XlUnderlineStyle::xlUnderlineStyleDouble;
+ break;
+ case awt::FontUnderline::SINGLE:
+ nValue = excel::XlUnderlineStyle::xlUnderlineStyleSingle;
+ break;
+ case awt::FontUnderline::NONE:
+ nValue = excel::XlUnderlineStyle::xlUnderlineStyleNone;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Unknown value retrieved for Underline") ), uno::Reference< uno::XInterface >() );
+
+ }
+ return uno::makeAny( nValue );
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getStrikethrough() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_CROSSEDOUT, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return ScVbaFont_BASE::getStrikethrough();
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getShadow() throw (uno::RuntimeException)
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_SHADOWED, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return ScVbaFont_BASE::getShadow();
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getItalic() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_POSTURE, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+
+ return ScVbaFont_BASE::getItalic();
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getName() throw ( uno::RuntimeException )
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return ScVbaFont_BASE::getName();
+}
+uno::Any
+ScVbaFont::getColor() throw (uno::RuntimeException)
+{
+ // #TODO #FIXME - behave like getXXX above ( wrt. GetDataSet )
+ uno::Any aAny;
+ aAny = OORGBToXLRGB( mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharColor" ) ) ) );
+ return aAny;
+}
+
+void SAL_CALL
+ScVbaFont::setOutlineFont( const uno::Any& aValue ) throw ( uno::RuntimeException )
+{
+ mxFont->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharContoured" ) ), aValue );
+}
+
+uno::Any SAL_CALL
+ScVbaFont::getOutlineFont() throw (uno::RuntimeException)
+{
+ if ( GetDataSet() )
+ if ( GetDataSet()->GetItemState( ATTR_FONT_CONTOUR, TRUE, NULL) == SFX_ITEM_DONTCARE )
+ return aNULL();
+ return mxFont->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharContoured" ) ) );
+}
+
+rtl::OUString&
+ScVbaFont::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFont") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaFont::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Font" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafont.hxx b/sc/source/ui/vba/vbafont.hxx
new file mode 100644
index 000000000000..d7f9010c3cfd
--- /dev/null
+++ b/sc/source/ui/vba/vbafont.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_FONT_HXX
+#define SC_VBA_FONT_HXX
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/excel/XFont.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbafontbase.hxx>
+#include "vbapalette.hxx"
+
+class ScTableSheetsObj;
+class ScCellRangeObj;
+
+typedef cppu::ImplInheritanceHelper1< VbaFontBase, ov::excel::XFont > ScVbaFont_BASE;
+
+class ScVbaFont : public ScVbaFont_BASE
+{
+ ScVbaPalette mPalette;
+ ScCellRangeObj* mpRangeObj;
+ SfxItemSet* GetDataSet();
+public:
+ ScVbaFont(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const ScVbaPalette& dPalette,
+ const css::uno::Reference< css::beans::XPropertySet >& xPropertySet,
+ ScCellRangeObj* pRangeObj = 0, bool bFormControl = false ) throw ( css::uno::RuntimeException );
+ virtual ~ScVbaFont();// {}
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getSize() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStandardFontSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStandardFontSize( const css::uno::Any& _standardfontsize ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStandardFont() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStandardFont( const css::uno::Any& _standardfont ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFontStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFontStyle( const css::uno::Any& _fontstyle ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getColorIndex() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getBold() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getUnderline() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setUnderline( const css::uno::Any& _underline ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStrikethrough() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getShadow() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getItalic() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getSubscript() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSubscript( const css::uno::Any& _subscript ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getSuperscript() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSuperscript( const css::uno::Any& _superscript ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getColor() throw (css::uno::RuntimeException) ;
+ virtual css::uno::Any SAL_CALL getOutlineFont() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setOutlineFont( const css::uno::Any& _outlinefont ) throw (css::uno::RuntimeException) ;
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+
+
+
+#endif /* SC_VBA_FONT_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaformat.cxx b/sc/source/ui/vba/vbaformat.cxx
new file mode 100644
index 000000000000..a38c7f3c8876
--- /dev/null
+++ b/sc/source/ui/vba/vbaformat.cxx
@@ -0,0 +1,845 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaformat.hxx"
+#include <ooo/vba/excel/XStyle.hpp>
+#include <ooo/vba/excel/XlVAlign.hpp>
+#include <ooo/vba/excel/XlHAlign.hpp>
+#include <ooo/vba/excel/XlOrientation.hpp>
+#include <ooo/vba/excel/Constants.hpp>
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/table/CellVertJustify2.hpp>
+#include <com/sun/star/table/CellHoriJustify.hpp>
+#include <com/sun/star/table/CellOrientation.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/text/WritingMode.hpp>
+#include <com/sun/star/util/CellProtection.hpp>
+
+#include <rtl/math.hxx>
+
+#include "excelvbahelper.hxx"
+#include "vbaborders.hxx"
+#include "vbapalette.hxx"
+#include "vbafont.hxx"
+#include "vbainterior.hxx"
+
+#include <unonames.hxx>
+#include <cellsuno.hxx>
+#include <scitems.hxx>
+#include <attrib.hxx>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+#define FORMATSTRING "FormatString"
+#define LOCALE "Locale"
+
+template< typename Ifc1 >
+ScVbaFormat< Ifc1 >::ScVbaFormat( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( script::BasicErrorException ) : ScVbaFormat_BASE( xParent, xContext ), m_aDefaultLocale( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("en") ), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US") ), rtl::OUString() ), mxPropertySet( _xPropertySet ), mxModel( xModel ), mbCheckAmbiguoity( bCheckAmbiguoity ), mbAddIndent( sal_False )
+{
+ try
+ {
+ mxServiceInfo.set( mxPropertySet, uno::UNO_QUERY_THROW );
+ if ( !mxModel.is() )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XModel Interface could not be retrieved") ) );
+ mxNumberFormatsSupplier.set( mxModel, uno::UNO_QUERY_THROW );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setVerticalAlignment( const uno::Any& _oAlignment) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ uno::Any aVal;
+ sal_Int32 nAlignment = 0;
+ if ( !(_oAlignment >>= nAlignment ))
+ throw uno::RuntimeException();
+ switch (nAlignment)
+ {
+ case excel::XlVAlign::xlVAlignBottom :
+ aVal = uno::makeAny( table::CellVertJustify2::BOTTOM );
+ break;
+ case excel::XlVAlign::xlVAlignCenter :
+ aVal = uno::makeAny( table::CellVertJustify2::CENTER );
+ break;
+ case excel::XlVAlign::xlVAlignDistributed:
+ case excel::XlVAlign::xlVAlignJustify:
+ aVal = uno::makeAny( table::CellVertJustify2::STANDARD );
+ break;
+
+ case excel::XlVAlign::xlVAlignTop:
+ aVal = uno::makeAny( table::CellVertJustify2::TOP);
+ break;
+ default:
+ aVal = uno::makeAny( table::CellVertJustify2::STANDARD );
+ break;
+ }
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLVJUS ) ), aVal );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getVerticalAlignment( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aResult = aNULL();
+ try
+ {
+ if (!isAmbiguous( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLVJUS ) ) ) )
+ {
+ sal_Int32 aAPIAlignment = table::CellVertJustify2::STANDARD;
+ mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLVJUS ) ) ) >>= aAPIAlignment;
+ switch( aAPIAlignment )
+ {
+ case table::CellVertJustify2::BOTTOM:
+ aResult = uno::makeAny( excel::XlVAlign::xlVAlignBottom );
+ break;
+ case table::CellVertJustify2::CENTER:
+ aResult = uno::makeAny( excel::XlVAlign::xlVAlignCenter );
+ break;
+ case table::CellVertJustify2::STANDARD:
+ aResult = uno::makeAny( excel::XlVAlign::xlVAlignBottom );
+ break;
+ case table::CellVertJustify2::TOP:
+ aResult = uno::makeAny( excel::XlVAlign::xlVAlignTop );
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return aResult;
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setHorizontalAlignment( const uno::Any& HorizontalAlignment ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ uno::Any aVal;
+ sal_Int32 nAlignment = 0;
+ if ( !( HorizontalAlignment >>= nAlignment ) )
+ throw uno::RuntimeException();
+ switch ( nAlignment )
+ {
+ case excel::XlHAlign::xlHAlignJustify:
+ aVal = uno::makeAny( table::CellHoriJustify_BLOCK);
+ break;
+ case excel::XlHAlign::xlHAlignCenter:
+ aVal = uno::makeAny( table::CellHoriJustify_CENTER );
+ break;
+ case excel::XlHAlign::xlHAlignDistributed:
+ aVal = uno::makeAny( table::CellHoriJustify_BLOCK);
+ break;
+ case excel::XlHAlign::xlHAlignLeft:
+ aVal = uno::makeAny( table::CellHoriJustify_LEFT);
+ break;
+ case excel::XlHAlign::xlHAlignRight:
+ aVal = uno::makeAny( table::CellHoriJustify_RIGHT);
+ break;
+ }
+ // #FIXME what about the default case above?
+ // shouldn't need the test below
+ if ( aVal.hasValue() )
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHJUS ) ), aVal );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getHorizontalAlignment( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any NRetAlignment = aNULL();
+ try
+ {
+ rtl::OUString sHoriJust( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHJUS ) );
+ if (!isAmbiguous(sHoriJust))
+ {
+ table::CellHoriJustify aAPIAlignment = table::CellHoriJustify_BLOCK;
+
+ if ( mxPropertySet->getPropertyValue(sHoriJust) >>= aAPIAlignment )
+ {
+ switch( aAPIAlignment )
+ {
+ case table::CellHoriJustify_BLOCK:
+ NRetAlignment = uno::makeAny( excel::XlHAlign::xlHAlignJustify );
+ break;
+ case table::CellHoriJustify_CENTER:
+ NRetAlignment = uno::makeAny( excel::XlHAlign::xlHAlignCenter );
+ break;
+ case table::CellHoriJustify_LEFT:
+ NRetAlignment = uno::makeAny( excel::XlHAlign::xlHAlignLeft );
+ break;
+ case table::CellHoriJustify_RIGHT:
+ NRetAlignment = uno::makeAny( excel::XlHAlign::xlHAlignRight );
+ break;
+ default: // handle those other cases with a NULL return
+ break;
+ }
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return NRetAlignment;
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setOrientation( const uno::Any& _aOrientation ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ sal_Int32 nOrientation = 0;
+ if ( !( _aOrientation >>= nOrientation ) )
+ throw uno::RuntimeException();
+ uno::Any aVal;
+ switch( nOrientation )
+ {
+ case excel::XlOrientation::xlDownward:
+ aVal = uno::makeAny( table::CellOrientation_TOPBOTTOM);
+ break;
+ case excel::XlOrientation::xlHorizontal:
+ aVal = uno::makeAny( table::CellOrientation_STANDARD );
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ROTANG ) ), uno::makeAny( sal_Int32(0) ) );
+ break;
+ case excel::XlOrientation::xlUpward:
+ aVal = uno::makeAny( table::CellOrientation_BOTTOMTOP);
+ break;
+ case excel::XlOrientation::xlVertical:
+ aVal = uno::makeAny( table::CellOrientation_STACKED);
+ break;
+ }
+ // #FIXME what about the default case above?
+ // shouldn't need the test below
+ if ( aVal.hasValue() )
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLORI ) ), aVal );
+
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getOrientation( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any NRetOrientation = aNULL();
+ try
+ {
+ if (!isAmbiguous(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLORI ) )))
+ {
+ table::CellOrientation aOrientation = table::CellOrientation_STANDARD;
+ if ( !( mxPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLORI ) ) ) >>= aOrientation ) )
+ throw uno::RuntimeException();
+
+ switch(aOrientation)
+ {
+ case table::CellOrientation_STANDARD:
+ NRetOrientation = uno::makeAny( excel::XlOrientation::xlHorizontal );
+ break;
+ case table::CellOrientation_BOTTOMTOP:
+ NRetOrientation = uno::makeAny( excel::XlOrientation::xlUpward );
+ break;
+ case table::CellOrientation_TOPBOTTOM:
+ NRetOrientation = uno::makeAny( excel::XlOrientation::xlDownward );
+ break;
+ case table::CellOrientation_STACKED:
+ NRetOrientation = uno::makeAny( excel::XlOrientation::xlVertical );
+ break;
+ default:
+ NRetOrientation = uno::makeAny( excel::XlOrientation::xlHorizontal );
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return NRetOrientation;
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setWrapText( const uno::Any& _aWrapText ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_WRAP ) ), _aWrapText);
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getWrapText( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aWrap = aNULL();
+ try
+ {
+ rtl::OUString aPropName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_WRAP ) ) );
+ if (!isAmbiguous( aPropName ))
+ {
+ aWrap = mxPropertySet->getPropertyValue(aPropName);
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return aWrap;
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::Borders( const uno::Any& Index ) throw (script::BasicErrorException, uno::RuntimeException )
+{
+ ScVbaPalette aPalette( excel::getDocShell( mxModel ) );
+ uno::Reference< XCollection > xColl = new ScVbaBorders( thisHelperIface(), ScVbaFormat_BASE::mxContext, uno::Reference< table::XCellRange >( mxPropertySet, uno::UNO_QUERY_THROW ), aPalette );
+
+ if ( Index.hasValue() )
+ {
+ return xColl->Item( Index, uno::Any() );
+ }
+ return uno::makeAny( xColl );
+}
+
+template< typename Ifc1 >
+uno::Reference< excel::XFont > SAL_CALL
+ScVbaFormat<Ifc1>::Font( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ ScVbaPalette aPalette( excel::getDocShell( mxModel ) );
+ return new ScVbaFont( thisHelperIface(), ScVbaFormat_BASE::mxContext, aPalette, mxPropertySet );
+}
+
+template< typename Ifc1 >
+uno::Reference< excel::XInterior > SAL_CALL
+ScVbaFormat<Ifc1>::Interior( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return new ScVbaInterior( thisHelperIface(), ScVbaFormat_BASE::mxContext, mxPropertySet );
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getNumberFormatLocal( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aRet = uno::makeAny( rtl::OUString() );
+ try
+ {
+ rtl::OUString sPropName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_NUMBERFO ) );
+ if (!isAmbiguous( sPropName ))
+ {
+
+ initializeNumberFormats();
+
+ sal_Int32 nFormat = 0;
+ if ( ! (mxPropertySet->getPropertyValue( sPropName ) >>= nFormat ) )
+ throw uno::RuntimeException();
+
+ rtl::OUString sFormat;
+ xNumberFormats->getByKey(nFormat)->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( FORMATSTRING ))) >>= sFormat;
+ aRet = uno::makeAny( sFormat.toAsciiLowerCase() );
+
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return aRet;
+
+}
+
+template< typename Ifc1 >
+void
+ScVbaFormat<Ifc1>::setNumberFormat( lang::Locale _aLocale, const rtl::OUString& _sFormatString) throw( script::BasicErrorException )
+{
+ try
+ {
+ initializeNumberFormats();
+ sal_Int32 nFormat = xNumberFormats->queryKey(_sFormatString, _aLocale , sal_True);
+ if (nFormat == -1)
+ {
+ xNumberFormats->addNew(_sFormatString, _aLocale);
+ }
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_NUMBERFO ) ), uno::makeAny( nFormat ) );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setNumberFormatLocal( const uno::Any& _oLocalFormatString ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ rtl::OUString sLocalFormatString;
+ sal_Int32 nFormat = -1;
+ rtl::OUString sNumFormat( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_NUMBERFO ) );
+ if ( !(_oLocalFormatString >>= sLocalFormatString )
+ || !( mxPropertySet->getPropertyValue(sNumFormat) >>= nFormat ) )
+ throw uno::RuntimeException();
+
+ sLocalFormatString = sLocalFormatString.toAsciiUpperCase();
+ initializeNumberFormats();
+ lang::Locale aRangeLocale;
+ xNumberFormats->getByKey(nFormat)->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LOCALE ) ) ) >>= aRangeLocale;
+ sal_Int32 nNewFormat = xNumberFormats->queryKey(sLocalFormatString, aRangeLocale, sal_True);
+
+ if (nNewFormat == -1)
+ nNewFormat = xNumberFormats->addNew(sLocalFormatString, aRangeLocale);
+ mxPropertySet->setPropertyValue(sNumFormat, uno::makeAny( nNewFormat ));
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setNumberFormat( const uno::Any& _oFormatString ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ rtl::OUString sFormatString;
+ if ( !( _oFormatString >>= sFormatString ) )
+ throw uno::RuntimeException();
+
+ sFormatString = sFormatString.toAsciiUpperCase();
+
+ lang::Locale aDefaultLocale = m_aDefaultLocale;
+ initializeNumberFormats();
+ sal_Int32 nFormat = xNumberFormats->queryKey(sFormatString, aDefaultLocale, sal_True);
+
+ if (nFormat == -1)
+ nFormat = xNumberFormats->addNew(sFormatString, aDefaultLocale);
+
+ lang::Locale aRangeLocale;
+ xNumberFormats->getByKey(nFormat)->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( LOCALE ) ) ) >>= aRangeLocale;
+ sal_Int32 nNewFormat = xNumberFormatTypes->getFormatForLocale(nFormat, aRangeLocale);
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_NUMBERFO ) ), uno::makeAny( nNewFormat));
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setIndentLevel( const uno::Any& _aLevel ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ sal_Int32 nLevel = 0;
+ if ( !(_aLevel >>= nLevel ) )
+ throw uno::RuntimeException();
+ table::CellHoriJustify aAPIAlignment = table::CellHoriJustify_STANDARD;
+
+ rtl::OUString sHoriJust( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHJUS ) );
+ if ( !( mxPropertySet->getPropertyValue(sHoriJust) >>= aAPIAlignment ) )
+ throw uno::RuntimeException();
+ if (aAPIAlignment == table::CellHoriJustify_STANDARD)
+ mxPropertySet->setPropertyValue( sHoriJust, uno::makeAny( table::CellHoriJustify_LEFT) ) ;
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_PINDENT ) ), uno::makeAny( sal_Int16(nLevel * 352.8) ) );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getIndentLevel( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any NRetIndentLevel = aNULL();
+ try
+ {
+ rtl::OUString sParaIndent( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_PINDENT ) );
+ if (!isAmbiguous(sParaIndent))
+ {
+ sal_Int16 IndentLevel = 0;
+ if ( ( mxPropertySet->getPropertyValue(sParaIndent) >>= IndentLevel ) )
+ NRetIndentLevel = uno::makeAny( sal_Int32( rtl::math::round(static_cast<double>( IndentLevel ) / 352.8)) );
+ else
+ NRetIndentLevel = uno::makeAny( sal_Int32(0) );
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return NRetIndentLevel;
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setLocked( const uno::Any& _aLocked ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ sal_Bool bIsLocked = sal_False;
+ if ( !( _aLocked >>= bIsLocked ) )
+ throw uno::RuntimeException();
+ util::CellProtection aCellProtection;
+ rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) );
+ mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection;
+ aCellProtection.IsLocked = bIsLocked;
+ mxPropertySet->setPropertyValue(sCellProt, uno::makeAny( aCellProtection ) );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setFormulaHidden( const uno::Any& FormulaHidden ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ sal_Bool bIsFormulaHidden = sal_False;
+ FormulaHidden >>= bIsFormulaHidden;
+ util::CellProtection aCellProtection;
+ rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) );
+ mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection;
+ aCellProtection.IsFormulaHidden = bIsFormulaHidden;
+ mxPropertySet->setPropertyValue(sCellProt,uno::makeAny(aCellProtection));
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception( SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getLocked( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aCellProtection = aNULL();
+ try
+ {
+ rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) );
+
+ if (!isAmbiguous(sCellProt))
+ {
+ SfxItemSet* pDataSet = getCurrentDataSet();
+ if ( pDataSet )
+ {
+ const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE);
+ SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL);
+ if(eState != SFX_ITEM_DONTCARE)
+ aCellProtection = uno::makeAny(rProtAttr.GetProtection());
+ }
+ else // fallback to propertyset
+ {
+ util::CellProtection cellProtection;
+ mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection;
+ aCellProtection = uno::makeAny( cellProtection.IsLocked );
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return aCellProtection;
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getFormulaHidden( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aBoolRet = aNULL();
+ try
+ {
+ rtl::OUString sCellProt( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLPRO ) );
+ if (!isAmbiguous(sCellProt))
+ {
+ SfxItemSet* pDataSet = getCurrentDataSet();
+ if ( pDataSet )
+ {
+ const ScProtectionAttr& rProtAttr = (const ScProtectionAttr &) pDataSet->Get(ATTR_PROTECTION, TRUE);
+ SfxItemState eState = pDataSet->GetItemState(ATTR_PROTECTION, TRUE, NULL);
+ if(eState != SFX_ITEM_DONTCARE)
+ aBoolRet = uno::makeAny(rProtAttr.GetHideFormula());
+ }
+ else
+ {
+ util::CellProtection aCellProtection;
+ mxPropertySet->getPropertyValue(sCellProt) >>= aCellProtection;
+ aBoolRet = uno::makeAny( aCellProtection.IsFormulaHidden );
+ }
+ }
+ }
+ catch (uno::Exception e)
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return aBoolRet;
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setShrinkToFit( const uno::Any& ShrinkToFit ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ mxPropertySet->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHRINK_TO_FIT ) ), ShrinkToFit);
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString() );
+ }
+
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getShrinkToFit( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aRet = aNULL();
+ try
+ {
+ rtl::OUString sShrinkToFit( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHRINK_TO_FIT ) );
+ if (!isAmbiguous(sShrinkToFit))
+ aRet = mxPropertySet->getPropertyValue(sShrinkToFit);
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ }
+ return aRet;
+}
+
+template< typename Ifc1 >
+void SAL_CALL
+ScVbaFormat<Ifc1>::setReadingOrder( const uno::Any& ReadingOrder ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ sal_Int32 nReadingOrder = 0;
+ if ( !(ReadingOrder >>= nReadingOrder ))
+ throw uno::RuntimeException();
+ uno::Any aVal;
+ switch(nReadingOrder)
+ {
+ case excel::Constants::xlLTR:
+ aVal = uno::makeAny( text::WritingMode_LR_TB );
+ break;
+ case excel::Constants::xlRTL:
+ aVal = uno::makeAny( text::WritingMode_RL_TB );
+ break;
+ case excel::Constants::xlContext:
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ break;
+ default:
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ mxPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_WRITING ) ), aVal );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat<Ifc1>::getReadingOrder( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any NRetReadingOrder = aNULL();
+ try
+ {
+ rtl::OUString sWritingMode( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_WRITING ) );
+ if (!isAmbiguous(sWritingMode))
+ {
+ text::WritingMode aWritingMode = text::WritingMode_LR_TB;
+ if ( ( mxPropertySet->getPropertyValue(sWritingMode) ) >>= aWritingMode )
+ switch (aWritingMode){
+ case text::WritingMode_LR_TB:
+ NRetReadingOrder = uno::makeAny(excel::Constants::xlLTR);
+ break;
+ case text::WritingMode_RL_TB:
+ NRetReadingOrder = uno::makeAny(excel::Constants::xlRTL);
+ break;
+ default:
+ NRetReadingOrder = uno::makeAny(excel::Constants::xlRTL);
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ }
+ return NRetReadingOrder;
+
+}
+
+template< typename Ifc1 >
+uno::Any SAL_CALL
+ScVbaFormat< Ifc1 >::getNumberFormat( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aFormat = aNULL();
+ try
+ {
+ sal_Int32 nFormat = -1;
+ rtl::OUString sNumFormat( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_NUMBERFO ) );
+ if (!isAmbiguous(sNumFormat) &&
+ ( mxPropertySet->getPropertyValue(sNumFormat) >>= nFormat) )
+ {
+ initializeNumberFormats();
+
+ sal_Int32 nNewFormat = xNumberFormatTypes->getFormatForLocale(nFormat, getDefaultLocale() );
+ rtl::OUString sFormat;
+ xNumberFormats->getByKey(nNewFormat)->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( FORMATSTRING ))) >>= sFormat;
+ aFormat = uno::makeAny( sFormat );
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return aFormat;
+}
+
+template< typename Ifc1 >
+bool
+ScVbaFormat<Ifc1>::isAmbiguous(const rtl::OUString& _sPropertyName) throw ( script::BasicErrorException )
+{
+ bool bResult = false;
+ try
+ {
+ if (mbCheckAmbiguoity)
+ bResult = ( getXPropertyState()->getPropertyState(_sPropertyName) == beans::PropertyState_AMBIGUOUS_VALUE );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return bResult;
+}
+
+template< typename Ifc1 >
+void
+ScVbaFormat<Ifc1>::initializeNumberFormats() throw ( script::BasicErrorException )
+{
+ if ( !xNumberFormats.is() )
+ {
+ mxNumberFormatsSupplier.set( mxModel, uno::UNO_QUERY_THROW );
+ xNumberFormats = mxNumberFormatsSupplier->getNumberFormats();
+ xNumberFormatTypes.set( xNumberFormats, uno::UNO_QUERY ); // _THROW?
+ }
+}
+
+template< typename Ifc1 >
+uno::Reference< beans::XPropertyState >
+ScVbaFormat<Ifc1>::getXPropertyState() throw ( uno::RuntimeException )
+{
+ if ( !xPropertyState.is() )
+ xPropertyState.set( mxPropertySet, uno::UNO_QUERY_THROW );
+ return xPropertyState;
+}
+
+template< typename Ifc1 >
+rtl::OUString&
+ScVbaFormat<Ifc1>::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFormat") );
+ return sImplName;
+}
+
+template< typename Ifc1 >
+uno::Sequence< rtl::OUString >
+ScVbaFormat<Ifc1>::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Format" ) );
+ }
+ return aServiceNames;
+}
+
+template< typename Ifc1 >
+ScCellRangesBase*
+ScVbaFormat<Ifc1>::getCellRangesBase() throw ( ::uno::RuntimeException )
+{
+ return ScCellRangesBase::getImplementation( mxPropertySet );
+}
+
+template< typename Ifc1 >
+SfxItemSet*
+ScVbaFormat<Ifc1>::getCurrentDataSet( ) throw ( uno::RuntimeException )
+{
+ SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( getCellRangesBase() );
+ if ( !pDataSet )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for XPropertySet" ) ), uno::Reference< uno::XInterface >() );
+ return pDataSet;
+}
+
+
+template class ScVbaFormat< excel::XStyle >;
+template class ScVbaFormat< excel::XRange >;
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaformat.hxx b/sc/source/ui/vba/vbaformat.hxx
new file mode 100644
index 000000000000..60d1a4460ae1
--- /dev/null
+++ b/sc/source/ui/vba/vbaformat.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_FORMAT_HXX
+#define SC_VBA_FORMAT_HXX
+#include <ooo/vba/excel/XFormat.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+class ScCellRangesBase;
+
+template< typename Ifc1 >
+class ScVbaFormat : public InheritedHelperInterfaceImpl1< Ifc1 >
+{
+typedef InheritedHelperInterfaceImpl1< Ifc1 > ScVbaFormat_BASE;
+ css::lang::Locale m_aDefaultLocale;
+protected:
+ css::lang::Locale getDefaultLocale() { return m_aDefaultLocale; }
+ css::uno::Reference< css::beans::XPropertySet > mxPropertySet;
+ css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
+ css::uno::Reference< css::util::XNumberFormats > xNumberFormats;
+ css::uno::Reference< css::util::XNumberFormatTypes > xNumberFormatTypes;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::lang::XServiceInfo > mxServiceInfo;
+ css::uno::Reference< css::beans::XPropertyState > xPropertyState;
+ sal_Bool mbCheckAmbiguoity;
+ sal_Bool mbAddIndent;
+ //NumberFormatter oNumberFormatter = null;
+ css::uno::Reference< css::lang::XMultiServiceFactory > xMultiServiceFactory;
+ bool isAmbiguous(const rtl::OUString& _sPropertyName) throw ( css::script::BasicErrorException );
+ css::uno::Reference< css::beans::XPropertyState > getXPropertyState() throw ( css::uno::RuntimeException );
+ void initializeNumberFormats() throw ( css::script::BasicErrorException );
+ void setNumberFormat( css::lang::Locale _aLocale, const rtl::OUString& _sFormatString) throw( css::script::BasicErrorException );
+ SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException );
+protected:
+ virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException );
+public:
+ ScVbaFormat( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, const css::uno::Reference< css::frame::XModel >& xModel, bool bCheckAmbiguoity ) throw ( css::script::BasicErrorException );
+ virtual ~ScVbaFormat() {}
+ virtual css::uno::Reference< ov::XHelperInterface > thisHelperIface() = 0;
+ css::uno::Reference< css::lang::XServiceInfo > getXServiceInfo() { return mxServiceInfo; }
+ void SAL_CALL setAddIndent( const css::uno::Any& _BAddIndent) throw( css::uno::RuntimeException ) { _BAddIndent >>= mbAddIndent; }
+ css::uno::Any SAL_CALL getAddIndent() throw( css::uno::RuntimeException ) { return css::uno::makeAny( mbAddIndent ); }
+ // Interface Methods
+ virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& Index ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setNumberFormat( const css::uno::Any& NumberFormat ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getNumberFormat( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setNumberFormatLocal( const css::uno::Any& NumberFormatLocal ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getNumberFormatLocal( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setIndentLevel( const css::uno::Any& IndentLevel ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getIndentLevel( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setHorizontalAlignment( const css::uno::Any& HorizontalAlignment ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHorizontalAlignment( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setVerticalAlignment( const css::uno::Any& VerticalAlignment ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getVerticalAlignment( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setOrientation( const css::uno::Any& Orientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setShrinkToFit( const css::uno::Any& ShrinkToFit ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getShrinkToFit( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setWrapText( const css::uno::Any& WrapText ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWrapText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setLocked( const css::uno::Any& Locked ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getLocked( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setFormulaHidden( const css::uno::Any& FormulaHidden ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormulaHidden( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMergeCells( const css::uno::Any& MergeCells ) throw (css::script::BasicErrorException, css::uno::RuntimeException) = 0;
+ virtual css::uno::Any SAL_CALL getMergeCells( ) throw (css::script::BasicErrorException, css::uno::RuntimeException) = 0;
+ virtual void SAL_CALL setReadingOrder( const css::uno::Any& ReadingOrder ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getReadingOrder( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaformatcondition.cxx b/sc/source/ui/vba/vbaformatcondition.cxx
new file mode 100644
index 000000000000..ce7ecfd52a1c
--- /dev/null
+++ b/sc/source/ui/vba/vbaformatcondition.cxx
@@ -0,0 +1,179 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaformatcondition.hxx"
+#include "vbaformatconditions.hxx"
+#include <ooo/vba/excel/XlFormatConditionType.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaFormatConditions*
+lcl_getScVbaFormatConditionsPtr( const uno::Reference< excel::XFormatConditions >& xFormatConditions ) throw ( script::BasicErrorException )
+{
+ ScVbaFormatConditions* pFormatConditions = static_cast< ScVbaFormatConditions* >( xFormatConditions.get() );
+ if ( !pFormatConditions )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ return pFormatConditions;
+}
+ScVbaFormatCondition::ScVbaFormatCondition( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntry >& _xSheetConditionalEntry, const uno::Reference< excel::XStyle >& _xStyle, const uno::Reference< excel::XFormatConditions >& _xFormatConditions, const uno::Reference< css::beans::XPropertySet >& _xPropertySet ) throw ( css::uno::RuntimeException ) : ScVbaFormatCondition_BASE( xParent, xContext, uno::Reference< sheet::XSheetCondition >( _xSheetConditionalEntry, css::uno::UNO_QUERY_THROW ) ), moFormatConditions( _xFormatConditions ), mxStyle( _xStyle ), mxParentRangePropertySet( _xPropertySet )
+{
+ mxSheetConditionalEntries = lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getSheetConditionalEntries();
+
+ mxSheetConditionalEntry = _xSheetConditionalEntry;
+ msStyleName = mxStyle->getName();
+}
+
+
+void SAL_CALL
+ScVbaFormatCondition::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ ScVbaFormatConditions* pFormatConditions = lcl_getScVbaFormatConditionsPtr( moFormatConditions );
+ pFormatConditions->removeFormatCondition(msStyleName, sal_True);
+ notifyRange();
+}
+
+void SAL_CALL
+ScVbaFormatCondition::Modify( ::sal_Int32 _nType, const uno::Any& _aOperator, const uno::Any& _aFormula1, const uno::Any& _aFormula2 ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ ScVbaFormatConditions* pFormatConditions = lcl_getScVbaFormatConditionsPtr( moFormatConditions );
+ pFormatConditions->removeFormatCondition(msStyleName, sal_False);
+ pFormatConditions->Add(_nType, _aOperator, _aFormula1, _aFormula2, mxStyle);
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+uno::Reference< excel::XInterior > SAL_CALL
+ScVbaFormatCondition::Interior( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return mxStyle->Interior();
+}
+
+uno::Reference< excel::XFont > SAL_CALL
+ScVbaFormatCondition::Font( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return mxStyle->Font();
+}
+uno::Any SAL_CALL
+ScVbaFormatCondition::Borders( const uno::Any& Index ) throw (script::BasicErrorException, uno::RuntimeException)
+{ return mxStyle->Borders( Index );
+}
+
+sheet::ConditionOperator
+ScVbaFormatCondition::retrieveAPIType(sal_Int32 _nVBAType, const uno::Reference< sheet::XSheetCondition >& _xSheetCondition ) throw ( script::BasicErrorException )
+{
+ sheet::ConditionOperator aAPIType = sheet::ConditionOperator_NONE;
+ switch (_nVBAType)
+ {
+ case excel::XlFormatConditionType::xlExpression:
+ aAPIType = sheet::ConditionOperator_FORMULA;
+ break;
+ case excel::XlFormatConditionType::xlCellValue:
+ if ( _xSheetCondition.is() && (_xSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA ) )
+ aAPIType = sheet::ConditionOperator_NONE;
+ break;
+ default:
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return aAPIType;
+}
+
+void
+ScVbaFormatCondition::setFormula1( const uno::Any& _aFormula1) throw ( script::BasicErrorException )
+{
+ // getA1Formula *SHOULD* detect whether the formula is r1c1 or A1 syntax
+ // and if R1C1 convert to A1
+ ScVbaFormatCondition_BASE::setFormula1( uno::makeAny( lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getA1Formula(_aFormula1) ) );
+}
+
+void
+ScVbaFormatCondition::setFormula2( const uno::Any& _aFormula2) throw ( script::BasicErrorException )
+{
+ ScVbaFormatCondition_BASE::setFormula1( uno::makeAny( lcl_getScVbaFormatConditionsPtr( moFormatConditions )->getA1Formula(_aFormula2)) );
+}
+
+::sal_Int32 SAL_CALL
+ScVbaFormatCondition::Type( ) throw ( script::BasicErrorException, uno::RuntimeException )
+{
+ sal_Int32 nReturnType = 0;
+ if ( mxSheetCondition->getOperator() == sheet::ConditionOperator_FORMULA)
+ nReturnType = excel::XlFormatConditionType::xlExpression;
+ else
+ nReturnType = excel::XlFormatConditionType::xlCellValue;
+ return nReturnType;
+}
+
+
+::sal_Int32
+ScVbaFormatCondition::Operator( sal_Bool bVal ) throw (script::BasicErrorException )
+{
+ return ScVbaFormatCondition_BASE::Operator( bVal );
+}
+::sal_Int32 SAL_CALL
+ScVbaFormatCondition::Operator( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return ScVbaFormatCondition_BASE::Operator( sal_True );
+}
+
+void
+ScVbaFormatCondition::notifyRange() throw ( script::BasicErrorException )
+{
+ try
+ {
+ mxParentRangePropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ConditionalFormat") ), uno::makeAny( mxSheetConditionalEntries) );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+}
+
+rtl::OUString&
+ScVbaFormatCondition::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFormatCondition") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaFormatCondition::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FormatCondition" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaformatcondition.hxx b/sc/source/ui/vba/vbaformatcondition.hxx
new file mode 100644
index 000000000000..75706878d1c3
--- /dev/null
+++ b/sc/source/ui/vba/vbaformatcondition.hxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_FORMATCONDITION_HXX
+#define SC_VBA_FORMATCONDITION_HXX
+#include <ooo/vba/excel/XFormatCondition.hpp>
+#include <ooo/vba/excel/XFormatConditions.hpp>
+#include <ooo/vba/excel/XStyle.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+#include <com/sun/star/sheet/XSheetCondition.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "vbacondition.hxx"
+
+typedef ScVbaCondition< ov::excel::XFormatCondition > ScVbaFormatCondition_BASE;
+class ScVbaFormatCondition : public ScVbaFormatCondition_BASE
+{
+protected:
+ rtl::OUString msStyleName;
+ css::uno::Reference< css::sheet::XSheetConditionalEntry > mxSheetConditionalEntry;
+ css::uno::Reference< css::sheet::XSheetConditionalEntries > mxSheetConditionalEntries;
+ css::uno::Reference< ov::excel::XFormatConditions> moFormatConditions;
+ css::uno::Reference< ov::excel::XStyle > mxStyle;
+ css::uno::Reference< css::beans::XPropertySet > mxParentRangePropertySet;
+public:
+ ScVbaFormatCondition( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::sheet::XSheetConditionalEntry >& _xSheetConditionalEntry, const css::uno::Reference< ov::excel::XStyle >&, const css::uno::Reference< ov::excel::XFormatConditions >& _xFormatConditions, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet ) throw ( css::uno::RuntimeException );
+
+ void notifyRange() throw ( css::script::BasicErrorException );
+ static css::sheet::ConditionOperator retrieveAPIType(sal_Int32 _nVBAType, const css::uno::Reference< css::sheet::XSheetCondition >& _xSheetCondition ) throw( css::script::BasicErrorException );
+
+ //Methods
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Modify( ::sal_Int32 Type, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL Type( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 Operator( sal_Bool ) throw (css::script::BasicErrorException);
+ virtual ::sal_Int32 SAL_CALL Operator( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void setFormula1( const css::uno::Any& _aFormula1) throw ( css::script::BasicErrorException );
+ virtual void setFormula2( const css::uno::Any& _aFormula2) throw ( css::script::BasicErrorException );
+ virtual css::uno::Reference< ::ooo::vba::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& Index ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaformatconditions.cxx b/sc/source/ui/vba/vbaformatconditions.cxx
new file mode 100644
index 000000000000..26dcaac89040
--- /dev/null
+++ b/sc/source/ui/vba/vbaformatconditions.cxx
@@ -0,0 +1,303 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntry.hpp>
+#include <vector>
+#include "vbaformatconditions.hxx"
+#include "vbaformatcondition.hxx"
+#include "vbaworkbook.hxx"
+#include "vbastyles.hxx"
+#include "vbaglobals.hxx"
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+typedef std::vector< beans::PropertyValue > VecPropValues;
+
+static rtl::OUString OPERATOR( RTL_CONSTASCII_USTRINGPARAM("Operator") );
+static rtl::OUString FORMULA1( RTL_CONSTASCII_USTRINGPARAM("Formula1") );
+static rtl::OUString FORMULA2( RTL_CONSTASCII_USTRINGPARAM("Formula2") );
+static rtl::OUString STYLENAME( RTL_CONSTASCII_USTRINGPARAM("StyleName") );
+static rtl::OUString sStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM("Excel_CondFormat") );
+
+ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& /*xModel*/ ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries )
+{
+ mxRangeParent.set( xParent, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XApplication> xApp( Application(), uno::UNO_QUERY_THROW );
+ mxStyles.set( xApp->getThisWorkbook()->Styles( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeAddressable > xCellRange( mxRangeParent->getCellRange(), uno::UNO_QUERY_THROW );
+ mxParentRangePropertySet.set( xCellRange, uno::UNO_QUERY_THROW );
+
+ table::CellRangeAddress rangeAddress = xCellRange->getRangeAddress();
+ maCellAddress = table::CellAddress( rangeAddress.Sheet, rangeAddress.StartColumn, rangeAddress.StartRow );
+}
+
+void SAL_CALL
+ScVbaFormatConditions::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ ScVbaStyles* pStyles = static_cast< ScVbaStyles* >( mxStyles.get() );
+ if ( !pStyles )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ sal_Int32 nCount = mxSheetConditionalEntries->getCount();
+ for (sal_Int32 i = nCount - 1; i >= 0; i--)
+ {
+ uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry( mxSheetConditionalEntries->getByIndex(i), uno::UNO_QUERY_THROW );
+ pStyles->Delete(xSheetConditionalEntry->getStyleName());
+ mxSheetConditionalEntries->removeByIndex(i);
+ }
+ notifyRange();
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+uno::Type SAL_CALL
+ScVbaFormatConditions::getElementType() throw (css::uno::RuntimeException)
+{
+ return excel::XFormatCondition::static_type(0);
+}
+
+
+uno::Any xSheetConditionToFormatCondition( const uno::Reference< XHelperInterface >& xRangeParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< excel::XStyles >& xStyles, const uno::Reference< excel::XFormatConditions >& xFormatConditions, const uno::Reference< beans::XPropertySet >& xRangeProps, const uno::Any& aObject )
+{
+ uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry;
+ aObject >>= xSheetConditionalEntry;
+
+ uno::Reference< excel::XStyle > xStyle( xStyles->Item( uno::makeAny( xSheetConditionalEntry->getStyleName() ), uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XFormatCondition > xCondition = new ScVbaFormatCondition( xRangeParent, xContext, xSheetConditionalEntry, xStyle, xFormatConditions, xRangeProps );
+ return uno::makeAny( xCondition );
+}
+
+uno::Any
+ScVbaFormatConditions::createCollectionObject(const uno::Any& aObject )
+{
+ return xSheetConditionToFormatCondition( uno::Reference< XHelperInterface >( mxRangeParent, uno::UNO_QUERY_THROW ), mxContext, mxStyles, this, mxParentRangePropertySet, aObject );
+}
+
+class EnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference<container::XIndexAccess > m_xIndexAccess;
+ uno::Reference<excel::XRange > m_xParentRange;
+ uno::Reference<uno::XComponentContext > m_xContext;
+ uno::Reference<excel::XStyles > m_xStyles;
+ uno::Reference<excel::XFormatConditions > m_xParentCollection;
+ uno::Reference<beans::XPropertySet > m_xProps;
+
+ sal_Int32 nIndex;
+public:
+ EnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference<excel::XRange >& xRange, const uno::Reference<uno::XComponentContext >& xContext, const uno::Reference<excel::XStyles >& xStyles, const uno::Reference< excel::XFormatConditions >& xCollection, const uno::Reference<beans::XPropertySet >& xProps ) : m_xIndexAccess( xIndexAccess ), m_xParentRange( xRange ), m_xContext( xContext ), m_xStyles( xStyles ), m_xParentCollection( xCollection ), m_xProps( xProps ), nIndex( 0 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < m_xIndexAccess->getCount() )
+ return xSheetConditionToFormatCondition( uno::Reference< XHelperInterface >( m_xParentRange, uno::UNO_QUERY_THROW ), m_xContext, m_xStyles, m_xParentCollection, m_xProps, m_xIndexAccess->getByIndex( nIndex++ ) );
+ throw container::NoSuchElementException();
+ }
+};
+
+uno::Reference< excel::XFormatCondition > SAL_CALL
+ScVbaFormatConditions::Add( ::sal_Int32 _nType, const uno::Any& _aOperator, const uno::Any& _aFormula1, const uno::Any& _aFormula2 ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return Add( _nType, _aOperator, _aFormula1, _aFormula2, uno::Reference< excel::XStyle >() );
+}
+
+uno::Reference< excel::XFormatCondition >
+ScVbaFormatConditions::Add( ::sal_Int32 _nType, const uno::Any& _aOperator, const uno::Any& _aFormula1, const uno::Any& _aFormula2, const css::uno::Reference< excel::XStyle >& _xStyle ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ // #TODO
+ // #FIXME
+ // This method will NOT handle r1c1 formulas [*]and only assumes that
+ // the formulas are _xlA1 based ( need to hook into calc work ths should
+ // address this )
+ // [*] reason: getA1Formula method below is just a hook and just
+ // returns whats it gets ( e.g. doesn't convert anything )
+ uno::Reference< excel::XStyle > xStyle( _xStyle );
+ uno::Reference< excel::XFormatCondition > xFormatCondition;
+ try
+ {
+ rtl::OUString sStyleName;
+ if ( !xStyle.is() )
+ {
+ sStyleName = getStyleName();
+ xStyle = mxStyles->Add(sStyleName, uno::Any() );
+ }
+ else
+ {
+ sStyleName = xStyle->getName();
+ }
+
+ VecPropValues aPropertyValueVector;
+ sheet::ConditionOperator aType = ScVbaFormatCondition::retrieveAPIType(_nType, uno::Reference< sheet::XSheetCondition >() );
+ uno::Any aValue;
+
+ if ( aType == sheet::ConditionOperator_FORMULA)
+ aValue = uno::makeAny( sheet::ConditionOperator_FORMULA );
+ else
+ aValue = uno::makeAny( ScVbaFormatCondition::retrieveAPIOperator(_aOperator) );
+
+ beans::PropertyValue aProperty( OPERATOR, 0, aValue, beans::PropertyState_DIRECT_VALUE );
+ aPropertyValueVector.push_back( aProperty );
+
+ if ( _aFormula1.hasValue() )
+ {
+ beans::PropertyValue aProp( FORMULA1, 0, uno::makeAny( getA1Formula( _aFormula1 ) ), beans::PropertyState_DIRECT_VALUE );
+ aPropertyValueVector.push_back( aProp );
+ }
+ if ( _aFormula2.hasValue() )
+ {
+ beans::PropertyValue aProp( FORMULA2, 0, uno::makeAny( getA1Formula( _aFormula2 ) ), beans::PropertyState_DIRECT_VALUE );
+ aPropertyValueVector.push_back( aProp );
+ }
+ aProperty.Name = STYLENAME;
+ aProperty.Value = uno::makeAny( sStyleName );
+
+ // convert vector to sequence
+ uno::Sequence< beans::PropertyValue > aPropertyValueList(aPropertyValueVector.size());
+ VecPropValues::iterator it = aPropertyValueVector.begin();
+ VecPropValues::iterator it_end = aPropertyValueVector.end();
+ for ( sal_Int32 index=0; it != it_end; ++it )
+ aPropertyValueList[ index++ ] = *it;
+
+ mxSheetConditionalEntries->addNew(aPropertyValueList);
+ for (sal_Int32 i = mxSheetConditionalEntries->getCount()-1; i >= 0; i--)
+ {
+ uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry( mxSheetConditionalEntries->getByIndex(i), uno::UNO_QUERY_THROW );
+ if (xSheetConditionalEntry->getStyleName().equals(sStyleName))
+ {
+ xFormatCondition = new ScVbaFormatCondition(uno::Reference< XHelperInterface >( mxRangeParent, uno::UNO_QUERY_THROW ), mxContext, xSheetConditionalEntry, xStyle, this, mxParentRangePropertySet);
+ notifyRange();
+ return xFormatCondition;
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ }
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ return xFormatCondition;
+}
+
+
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaFormatConditions::createEnumeration() throw (uno::RuntimeException)
+{
+ return new EnumWrapper( m_xIndexAccess, mxRangeParent, mxContext, mxStyles, this, mxParentRangePropertySet );
+}
+
+
+void
+ScVbaFormatConditions::notifyRange() throw ( script::BasicErrorException )
+{
+ try
+ {
+ mxParentRangePropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ConditionalFormat")), uno::makeAny( mxSheetConditionalEntries ));
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+rtl::OUString
+ScVbaFormatConditions::getA1Formula(const css::uno::Any& _aFormula) throw ( script::BasicErrorException )
+{
+ // #TODO, #FIXME hook-in proper formula conversion detection & logic
+ rtl::OUString sFormula;
+ if ( !( _aFormula >>= sFormula ) )
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ return sFormula;
+}
+
+rtl::OUString
+ScVbaFormatConditions::getStyleName()
+{
+ ScVbaStyles* pStyles = static_cast< ScVbaStyles* >( mxStyles.get() );
+ if ( !pStyles )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ uno::Sequence< rtl::OUString > sCellStyleNames = pStyles->getStyleNames();
+ return ContainerUtilities::getUniqueName(sCellStyleNames, sStyleNamePrefix, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_") ));
+}
+
+void
+ScVbaFormatConditions::removeFormatCondition( const rtl::OUString& _sStyleName, sal_Bool _bRemoveStyle) throw ( script::BasicErrorException )
+{
+ try
+ {
+ sal_Int32 nElems = mxSheetConditionalEntries->getCount();
+ for (sal_Int32 i = 0; i < nElems; i++)
+ {
+ uno::Reference< sheet::XSheetConditionalEntry > xSheetConditionalEntry( mxSheetConditionalEntries->getByIndex(i), uno::UNO_QUERY_THROW );
+ if (_sStyleName.equals(xSheetConditionalEntry->getStyleName()))
+ {
+ mxSheetConditionalEntries->removeByIndex(i);
+ if (_bRemoveStyle)
+ {
+ ScVbaStyles* pStyles = static_cast< ScVbaStyles* >( mxStyles.get() );
+ if ( !pStyles )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ pStyles->Delete( _sStyleName );
+ }
+ return;
+ }
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+rtl::OUString&
+ScVbaFormatConditions::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaFormatConditions") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaFormatConditions::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.FormatConditions" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaformatconditions.hxx b/sc/source/ui/vba/vbaformatconditions.hxx
new file mode 100644
index 000000000000..e51ca233164d
--- /dev/null
+++ b/sc/source/ui/vba/vbaformatconditions.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_FORMATCONDITIONS_HXX
+#define SC_VBA_FORMATCONDITIONS_HXX
+#include <ooo/vba/excel/XFormatConditions.hpp>
+#include <ooo/vba/excel/XStyles.hpp>
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/sheet/XSheetConditionalEntries.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XFormatConditions > ScVbaFormatConditions_BASE;
+class ScVbaFormatConditions: public ScVbaFormatConditions_BASE
+{
+ css::table::CellAddress maCellAddress;
+ css::uno::Reference< css::sheet::XSheetConditionalEntries > mxSheetConditionalEntries;
+ css::uno::Reference< ov::excel::XStyles > mxStyles;
+ css::uno::Reference< ov::excel::XRange > mxRangeParent;
+ css::uno::Reference< css::beans::XPropertySet > mxParentRangePropertySet;
+public:
+ ScVbaFormatConditions( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::sheet::XSheetConditionalEntries >&, const css::uno::Reference< css::frame::XModel >& );
+ void notifyRange() throw ( css::script::BasicErrorException );
+ virtual css::uno::Reference< ov::excel::XFormatCondition > Add( ::sal_Int32 Type, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2, const css::uno::Reference< ov::excel::XStyle >& _xCalcStyle ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ rtl::OUString getA1Formula(const css::uno::Any& _aFormula) throw ( css::script::BasicErrorException );
+ rtl::OUString getStyleName();
+ void removeFormatCondition( const rtl::OUString& _sStyleName, sal_Bool _bRemoveStyle) throw ( css::script::BasicErrorException );
+ css::uno::Reference< css::sheet::XSheetConditionalEntries > getSheetConditionalEntries() { return mxSheetConditionalEntries; }
+ // XFormatConditions
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XFormatCondition > SAL_CALL Add( ::sal_Int32 Type, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject(const css::uno::Any&);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_AXES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafoundfiles.cxx b/sc/source/ui/vba/vbafoundfiles.cxx
new file mode 100644
index 000000000000..9d3af947e1dd
--- /dev/null
+++ b/sc/source/ui/vba/vbafoundfiles.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbafoundfiles.hxx"
+
+////////////////////////////////VbaFoundFilesEnum//////////////////////////////////////////
+VbaFoundFilesEnum::VbaFoundFilesEnum() : m_nIndex(0)
+{
+
+}
+
+VbaFoundFilesEnum::VbaFoundFilesEnum( css::uno::Sequence<rtl::OUString>& sFileList ) : m_nIndex(0), m_sFileList(sFileList)
+{
+
+}
+
+VbaFoundFilesEnum::~VbaFoundFilesEnum()
+{
+
+}
+
+void VbaFoundFilesEnum::SetFileList( css::uno::Sequence<rtl::OUString>& sFileList )
+{
+ m_nIndex = 0;
+ m_sFileList = sFileList;
+}
+
+sal_Int32 SAL_CALL VbaFoundFilesEnum::getCount() throw (css::uno::RuntimeException)
+{
+ return m_sFileList.getLength();
+}
+
+css::uno::Any SAL_CALL VbaFoundFilesEnum::getByIndex( sal_Int32 nIndex )
+ throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException)
+{
+ if ( nIndex >= getCount() )
+ {
+ throw css::lang::IndexOutOfBoundsException();
+ }
+
+ return css::uno::makeAny( m_sFileList[nIndex] );
+}
+
+css::uno::Type SAL_CALL VbaFoundFilesEnum::getElementType() throw (css::uno::RuntimeException)
+{
+ return getCppuType((css::uno::Reference< css::container::XIndexAccess >*)0);
+}
+
+sal_Bool SAL_CALL VbaFoundFilesEnum::hasElements() throw (css::uno::RuntimeException)
+{
+ return ( getCount() != 0 );
+}
+
+sal_Bool SAL_CALL VbaFoundFilesEnum::hasMoreElements() throw (css::uno::RuntimeException)
+{
+ if ( getCount() > m_nIndex )
+ {
+ return sal_True;
+ }
+ return sal_False;
+}
+
+css::uno::Any SAL_CALL VbaFoundFilesEnum::nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException)
+{
+ if ( !hasMoreElements() )
+ {
+ throw css::container::NoSuchElementException();
+ }
+
+ return css::uno::makeAny( m_sFileList[m_nIndex++] );
+}
+
+////////////////////////////////VbaFoundFiles//////////////////////////////////////////
+VbaFoundFiles::VbaFoundFiles( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess
+ ) : VbaFoundFilesImpl_BASE( xParent, xContext, xIndexAccess )
+{
+
+}
+
+VbaFoundFiles::~VbaFoundFiles()
+{
+
+}
+
+css::uno::Reference< css::container::XEnumeration > VbaFoundFiles::createEnumeration() throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::container::XEnumeration > xEnumRet( m_xIndexAccess, css::uno::UNO_QUERY );
+ return xEnumRet;
+}
+
+css::uno::Any VbaFoundFiles::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource;
+}
+
+css::uno::Type VbaFoundFiles::getElementType() throw (css::uno::RuntimeException)
+{
+ return ov::XFoundFiles::static_type(0);
+}
+
+rtl::OUString& VbaFoundFiles::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("VbaFoundFiles") );
+ return sImplName;
+}
+
+css::uno::Sequence< rtl::OUString > VbaFoundFiles::getServiceNames()
+{
+ static css::uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.FoundFiles") );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbafoundfiles.hxx b/sc/source/ui/vba/vbafoundfiles.hxx
new file mode 100644
index 000000000000..7a0a1e7b2a19
--- /dev/null
+++ b/sc/source/ui/vba/vbafoundfiles.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_FOUNDFILES_HXX
+#define SC_VBA_FOUNDFILES_HXX
+
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <ooo/vba/XFoundFiles.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+namespace css = ::com::sun::star;
+
+typedef CollTestImplHelper< ooo::vba::XFoundFiles > VbaFoundFilesImpl_BASE;
+
+class VbaFoundFilesEnum : public cppu::WeakImplHelper2< css::container::XIndexAccess, css::container::XEnumeration >
+{
+private:
+ sal_Int32 m_nIndex;
+ css::uno::Sequence< rtl::OUString > m_sFileList;
+
+public:
+ VbaFoundFilesEnum();
+ VbaFoundFilesEnum( css::uno::Sequence< rtl::OUString >& sFileList );
+ ~VbaFoundFilesEnum();
+
+ void SetFileList( css::uno::Sequence< rtl::OUString >& sFileList );
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (css::lang::IndexOutOfBoundsException, css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
+
+ // XEnumeration
+ virtual sal_Bool SAL_CALL hasMoreElements() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL nextElement() throw (css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException);
+};
+
+class VbaFoundFiles : public VbaFoundFilesImpl_BASE
+{
+private:
+
+public:
+ VbaFoundFiles( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+ virtual ~VbaFoundFiles();
+
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence< rtl::OUString > getServiceNames();
+};
+
+#endif /* SC_VBA_FOUNDFILES_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx
new file mode 100644
index 000000000000..b3e56cddb958
--- /dev/null
+++ b/sc/source/ui/vba/vbaglobals.cxx
@@ -0,0 +1,313 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+#include "vbaglobals.hxx"
+
+#include <sal/macros.h>
+
+#include <comphelper/unwrapargs.hxx>
+
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/component_context.hxx>
+#include "vbaapplication.hxx"
+#include "vbaworksheet.hxx"
+#include "vbarange.hxx"
+#include <cppuhelper/bootstrap.hxx>
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::ooo::vba;
+
+
+
+// =============================================================================
+// ScVbaGlobals
+// =============================================================================
+
+//ScVbaGlobals::ScVbaGlobals( css::uno::Reference< css::uno::XComponentContext >const& rxContext, ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext )
+rtl::OUString sDocCtxName( RTL_CONSTASCII_USTRINGPARAM("ExcelDocumentContext") );
+
+ScVbaGlobals::ScVbaGlobals( uno::Sequence< uno::Any > const& aArgs, uno::Reference< uno::XComponentContext >const& rxContext ) : ScVbaGlobals_BASE( uno::Reference< XHelperInterface >(), rxContext, sDocCtxName )
+{
+ OSL_TRACE("ScVbaGlobals::ScVbaGlobals()");
+
+ uno::Sequence< beans::PropertyValue > aInitArgs( 2 );
+ aInitArgs[ 0 ].Name = rtl::OUString::createFromAscii("Application");
+ aInitArgs[ 0 ].Value = uno::makeAny( getApplication() );
+ aInitArgs[ 1 ].Name = sDocCtxName;
+ aInitArgs[ 1 ].Value = uno::makeAny( getXSomethingFromArgs< frame::XModel >( aArgs, 0 ) );
+
+ init( aInitArgs );
+}
+
+ScVbaGlobals::~ScVbaGlobals()
+{
+ OSL_TRACE("ScVbaGlobals::~ScVbaGlobals");
+}
+
+// =============================================================================
+// XGlobals
+// =============================================================================
+uno::Reference<excel::XApplication >
+ScVbaGlobals::getApplication() throw (uno::RuntimeException)
+{
+// OSL_TRACE("In ScVbaGlobals::getApplication");
+ if ( !mxApplication.is() )
+ mxApplication.set( new ScVbaApplication( mxContext) );
+ return mxApplication;
+}
+
+
+uno::Reference<excel::XApplication > SAL_CALL
+ScVbaGlobals::getExcel() throw (uno::RuntimeException)
+{
+ return getApplication();
+}
+
+
+
+uno::Reference< excel::XWorkbook > SAL_CALL
+ScVbaGlobals::getActiveWorkbook() throw (uno::RuntimeException)
+{
+// OSL_TRACE("In ScVbaGlobals::getActiveWorkbook");
+ uno::Reference< excel::XWorkbook > xWorkbook( getApplication()->getActiveWorkbook(), uno::UNO_QUERY);
+ if ( xWorkbook.is() )
+ {
+ return xWorkbook;
+ }
+// FIXME check if this is correct/desired behavior
+ throw uno::RuntimeException( rtl::OUString::createFromAscii(
+ "No activeWorkbook available" ), Reference< uno::XInterface >() );
+}
+
+
+uno::Reference< excel::XWindow > SAL_CALL
+ScVbaGlobals::getActiveWindow() throw (uno::RuntimeException)
+{
+ return getApplication()->getActiveWindow();
+}
+
+uno::Reference< excel::XWorksheet > SAL_CALL
+ScVbaGlobals::getActiveSheet() throw (uno::RuntimeException)
+{
+ return getApplication()->getActiveSheet();
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::WorkBooks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return uno::Any( getApplication()->Workbooks(aIndex) );
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::WorkSheets(const uno::Any& aIndex) throw (uno::RuntimeException)
+{
+ return getApplication()->Worksheets( aIndex );
+}
+uno::Any SAL_CALL
+ScVbaGlobals::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return WorkSheets( aIndex );
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::Range( const uno::Any& Cell1, const uno::Any& Cell2 ) throw (uno::RuntimeException)
+{
+ return getApplication()->Range( Cell1, Cell2 );
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::Names( const css::uno::Any& aIndex ) throw ( uno::RuntimeException )
+{
+ return getApplication()->Names( aIndex );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaGlobals::getActiveCell() throw (uno::RuntimeException)
+{
+ return getApplication()->getActiveCell();
+}
+
+uno::Reference< XAssistant > SAL_CALL
+ScVbaGlobals::getAssistant() throw (uno::RuntimeException)
+{
+ return getApplication()->getAssistant();
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::getSelection() throw (uno::RuntimeException)
+{
+ return getApplication()->getSelection();
+}
+
+uno::Reference< excel::XWorkbook > SAL_CALL
+ScVbaGlobals::getThisWorkbook() throw (uno::RuntimeException)
+{
+ return getApplication()->getThisWorkbook();
+}
+void SAL_CALL
+ScVbaGlobals::Calculate() throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException)
+{
+ return getApplication()->Calculate();
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaGlobals::Cells( const uno::Any& RowIndex, const uno::Any& ColumnIndex ) throw (uno::RuntimeException)
+{
+ return getApplication()->getActiveSheet()->Cells( RowIndex, ColumnIndex );
+}
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaGlobals::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return getApplication()->getActiveSheet()->Columns( aIndex );
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::CommandBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< XApplicationBase > xBase( getApplication(), uno::UNO_QUERY_THROW );
+ return xBase->CommandBars( aIndex );
+}
+
+css::uno::Reference< ov::excel::XRange > SAL_CALL
+ScVbaGlobals::Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return getApplication()->Union( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
+}
+css::uno::Reference< ov::excel::XRange > SAL_CALL
+ScVbaGlobals::Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ return getApplication()->Intersect( Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7, Arg8, Arg9, Arg10, Arg11, Arg12, Arg13, Arg14, Arg15, Arg16, Arg17, Arg18, Arg19, Arg20, Arg21, Arg22, Arg23, Arg24, Arg25, Arg26, Arg27, Arg28, Arg29, Arg30 );
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
+{
+ return getApplication()->Evaluate( Name );
+}
+
+css::uno::Any SAL_CALL
+ScVbaGlobals::WorksheetFunction( ) throw (css::uno::RuntimeException)
+{
+ return getApplication()->WorksheetFunction();
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return getApplication()->Windows( aIndex );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaGlobals::Rows( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return getApplication()->getActiveSheet()->Rows( aIndex );
+
+}
+
+
+uno::Any SAL_CALL
+ScVbaGlobals::getDebug() throw (uno::RuntimeException)
+{
+ try // return empty object on error
+ {
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
+ uno::Reference< uno::XInterface > xVBADebug = xServiceManager->createInstanceWithArgumentsAndContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.Debug" ) ), aArgs, mxContext );
+ return uno::Any( xVBADebug );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return uno::Any();
+}
+
+uno::Any SAL_CALL
+ScVbaGlobals::MenuBars( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return uno::Any( getApplication()->MenuBars(aIndex) );
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL
+ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException)
+{
+ static bool bInit = false;
+ static uno::Sequence< rtl::OUString > serviceNames( ScVbaGlobals_BASE::getAvailableServiceNames() );
+ if ( !bInit )
+ {
+ rtl::OUString names[] = {
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Range" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Workbook" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Window" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ) )
+ };
+ sal_Int32 nExcelServices = ( SAL_N_ELEMENTS(names) );
+ sal_Int32 startIndex = serviceNames.getLength();
+ serviceNames.realloc( serviceNames.getLength() + nExcelServices );
+ for ( sal_Int32 index = 0; index < nExcelServices; ++index )
+ serviceNames[ startIndex + index ] = names[ index ];
+ bInit = true;
+ }
+ return serviceNames;
+}
+
+rtl::OUString&
+ScVbaGlobals::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaGlobals") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaGlobals::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Globals" ) );
+ }
+ return aServiceNames;
+}
+
+namespace globals
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaGlobals, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaGlobals",
+ "ooo.vba.excel.Globals" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaglobals.hxx b/sc/source/ui/vba/vbaglobals.hxx
new file mode 100644
index 000000000000..dc7518ad64c2
--- /dev/null
+++ b/sc/source/ui/vba/vbaglobals.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_GLOBALS
+#define SC_VBA_GLOBALS
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <ooo/vba/excel/XGlobals.hpp>
+#include <ooo/vba/excel/XApplication.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+#include "excelvbahelper.hxx"
+
+#include <vbahelper/vbaglobalbase.hxx>
+ // =============================================================================
+ // class ScVbaGlobals
+ // =============================================================================
+
+typedef ::cppu::ImplInheritanceHelper1< VbaGlobalsBase, ov::excel::XGlobals > ScVbaGlobals_BASE;
+
+ class ScVbaGlobals : public ScVbaGlobals_BASE
+ {
+ css::uno::Reference< ov::excel::XApplication > mxApplication;
+ virtual css::uno::Reference<
+ ov::excel::XApplication > SAL_CALL getApplication()
+ throw (css::uno::RuntimeException);
+ public:
+
+ ScVbaGlobals( css::uno::Sequence< css::uno::Any > const& aArgs,
+ css::uno::Reference< css::uno::XComponentContext >const& rxContext );
+ //ScVbaGlobals(
+ // css::uno::Reference< css::uno::XComponentContext >const& rxContext, );
+ virtual ~ScVbaGlobals();
+
+ // XGlobals
+ virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getActiveWorkbook() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWindow > SAL_CALL getActiveWindow() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::XAssistant > SAL_CALL getAssistant() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Calculate( ) throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getSelection() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getActiveCell() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorkbook > SAL_CALL getThisWorkbook() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any& RowIndex, const css::uno::Any& ColumnIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Evaluate( const ::rtl::OUString& Name ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL WorkSheets(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL WorkBooks(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL WorksheetFunction( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ::ooo::vba::excel::XRange > SAL_CALL Rows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw ( css::uno::RuntimeException );
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Intersect( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Union( const css::uno::Reference< ov::excel::XRange >& Arg1, const css::uno::Reference< ov::excel::XRange >& Arg2, const css::uno::Any& Arg3, const css::uno::Any& Arg4, const css::uno::Any& Arg5, const css::uno::Any& Arg6, const css::uno::Any& Arg7, const css::uno::Any& Arg8, const css::uno::Any& Arg9, const css::uno::Any& Arg10, const css::uno::Any& Arg11, const css::uno::Any& Arg12, const css::uno::Any& Arg13, const css::uno::Any& Arg14, const css::uno::Any& Arg15, const css::uno::Any& Arg16, const css::uno::Any& Arg17, const css::uno::Any& Arg18, const css::uno::Any& Arg19, const css::uno::Any& Arg20, const css::uno::Any& Arg21, const css::uno::Any& Arg22, const css::uno::Any& Arg23, const css::uno::Any& Arg24, const css::uno::Any& Arg25, const css::uno::Any& Arg26, const css::uno::Any& Arg27, const css::uno::Any& Arg28, const css::uno::Any& Arg29, const css::uno::Any& Arg30 ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XApplication > SAL_CALL getExcel() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getDebug() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL MenuBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
+
+ // XMultiServiceFactory
+ virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+ };
+#endif //
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbahelper.cxx b/sc/source/ui/vba/vbahelper.cxx
new file mode 100644
index 000000000000..bc1b07d738ab
--- /dev/null
+++ b/sc/source/ui/vba/vbahelper.cxx
@@ -0,0 +1,761 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <svl/stritem.hxx>
+
+#include <docuno.hxx>
+
+#include <basic/sbx.hxx>
+#include <basic/sbstar.hxx>
+#include <rtl/math.hxx>
+
+#include <math.h>
+#include "vbahelper.hxx"
+#include "tabvwsh.hxx"
+#include "transobj.hxx"
+#include "scmod.hxx"
+#include "vbashape.hxx"
+#include "unonames.hxx"
+#include "cellsuno.hxx"
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+#define POINTTO100THMILLIMETERFACTOR 35.27778
+void unoToSbxValue( SbxVariable* pVar, const uno::Any& aValue );
+
+uno::Any sbxToUnoValue( SbxVariable* pVar );
+
+
+namespace ooo
+{
+namespace vba
+{
+
+const double Millimeter::factor = 35.27778;
+
+uno::Reference< beans::XIntrospectionAccess >
+getIntrospectionAccess( const uno::Any& aObject ) throw (uno::RuntimeException)
+{
+ static uno::Reference< beans::XIntrospection > xIntrospection;
+ if( !xIntrospection.is() )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ xIntrospection.set( xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.beans.Introspection") ), uno::UNO_QUERY_THROW );
+ }
+ return xIntrospection->inspect( aObject );
+}
+
+uno::Reference< script::XTypeConverter >
+getTypeConverter( const uno::Reference< uno::XComponentContext >& xContext ) throw (uno::RuntimeException)
+{
+ static uno::Reference< script::XTypeConverter > xTypeConv( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter") ), xContext ), uno::UNO_QUERY_THROW );
+ return xTypeConv;
+}
+// helper method to determine if the view ( calc ) is in print-preview mode
+bool isInPrintPreview( SfxViewFrame* pView )
+{
+ sal_uInt16 nViewNo = SID_VIEWSHELL1 - SID_VIEWSHELL0;
+ if ( pView->GetObjectShell()->GetFactory().GetViewFactoryCount() >
+nViewNo && !pView->GetObjectShell()->IsInPlaceActive() )
+ {
+ SfxViewFactory &rViewFactory =
+ pView->GetObjectShell()->GetFactory().GetViewFactory(nViewNo);
+ if ( pView->GetCurViewId() == rViewFactory.GetOrdinal() )
+ return true;
+ }
+ return false;
+}
+const ::rtl::OUString REPLACE_CELLS_WARNING( RTL_CONSTASCII_USTRINGPARAM( "ReplaceCellsWarning"));
+const uno::Any&
+aNULL()
+{
+ static uno::Any aNULLL = uno::makeAny( uno::Reference< uno::XInterface >() );
+ return aNULLL;
+}
+
+class PasteCellsWarningReseter
+{
+private:
+ bool bInitialWarningState;
+ static uno::Reference< beans::XPropertySet > getGlobalSheetSettings() throw ( uno::RuntimeException )
+ {
+ static uno::Reference< beans::XPropertySet > xTmpProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ static uno::Reference<uno::XComponentContext > xContext( xTmpProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ static uno::Reference<lang::XMultiComponentFactory > xServiceManager(
+ xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ static uno::Reference< beans::XPropertySet > xProps( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.GlobalSheetSettings" ) ) ,xContext ), uno::UNO_QUERY_THROW );
+ return xProps;
+ }
+
+ bool getReplaceCellsWarning() throw ( uno::RuntimeException )
+ {
+ sal_Bool res = sal_False;
+ getGlobalSheetSettings()->getPropertyValue( REPLACE_CELLS_WARNING ) >>= res;
+ return ( res == sal_True );
+ }
+
+ void setReplaceCellsWarning( bool bState ) throw ( uno::RuntimeException )
+ {
+ getGlobalSheetSettings()->setPropertyValue( REPLACE_CELLS_WARNING, uno::makeAny( bState ) );
+ }
+public:
+ PasteCellsWarningReseter() throw ( uno::RuntimeException )
+ {
+ bInitialWarningState = getReplaceCellsWarning();
+ if ( bInitialWarningState )
+ setReplaceCellsWarning( false );
+ }
+ ~PasteCellsWarningReseter()
+ {
+ if ( bInitialWarningState )
+ {
+ // don't allow dtor to throw
+ try
+ {
+ setReplaceCellsWarning( true );
+ }
+ catch ( uno::Exception& /*e*/ ){}
+ }
+ }
+};
+
+void dispatchExecute(css::uno::Reference< css::frame::XModel>& xModel, USHORT nSlot, SfxCallMode nCall)
+{
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ SfxViewFrame* pViewFrame = NULL;
+ if ( pViewShell )
+ pViewFrame = pViewShell->GetViewFrame();
+ if ( pViewFrame )
+ {
+ SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
+ if( pDispatcher )
+ {
+ pDispatcher->Execute( nSlot , nCall );
+ }
+ }
+}
+
+void
+implnPaste()
+{
+ PasteCellsWarningReseter resetWarningBox;
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( pViewShell )
+ {
+ pViewShell->PasteFromSystem();
+ pViewShell->CellContentChanged();
+ }
+}
+
+
+void
+implnCopy()
+{
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( pViewShell )
+ pViewShell->CopyToClip(NULL,false,false,true);
+}
+
+void
+implnCut()
+{
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( pViewShell )
+ pViewShell->CutToClip( NULL, TRUE );
+}
+
+void implnPasteSpecial(USHORT nFlags,USHORT nFunction,sal_Bool bSkipEmpty, sal_Bool bTranspose)
+{
+ PasteCellsWarningReseter resetWarningBox;
+ sal_Bool bAsLink(sal_False), bOtherDoc(sal_False);
+ InsCellCmd eMoveMode = INS_NONE;
+
+ ScTabViewShell* pTabViewShell = ScTabViewShell::GetActiveViewShell();
+ if ( !pTabViewShell )
+ // none active, try next best
+ pTabViewShell = getCurrentBestViewShell();
+ if ( pTabViewShell )
+ {
+ ScViewData* pView = pTabViewShell->GetViewData();
+ Window* pWin = ( pView != NULL ) ? pView->GetActiveWin() : NULL;
+ if ( pView && pWin )
+ {
+ if ( bAsLink && bOtherDoc )
+ pTabViewShell->PasteFromSystem(0);//SOT_FORMATSTR_ID_LINK
+ else
+ {
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ ScDocument* pDoc = NULL;
+ if ( pOwnClip )
+ pDoc = pOwnClip->GetDocument();
+ pTabViewShell->PasteFromClip( nFlags, pDoc,
+ nFunction, bSkipEmpty, bTranspose, bAsLink,
+ eMoveMode, IDF_NONE, TRUE );
+ pTabViewShell->CellContentChanged();
+ }
+ }
+ }
+
+}
+
+ uno::Reference< frame::XModel >
+getCurrentDocument() throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel;
+ SbxObject* pBasic = dynamic_cast< SbxObject* > ( SFX_APP()->GetBasic() );
+ SbxObject* basicChosen = pBasic ;
+ if ( basicChosen == NULL)
+ {
+ OSL_TRACE("getModelFromBasic() StarBASIC* is NULL" );
+ return xModel;
+ }
+ SbxObject* p = pBasic;
+ SbxObject* pParent = p->GetParent();
+ SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL;
+
+ if( pParentParent )
+ {
+ basicChosen = pParentParent;
+ }
+ else if( pParent )
+ {
+ basicChosen = pParent;
+ }
+
+
+ uno::Any aModel;
+ SbxVariable *pCompVar = basicChosen->Find( UniString(RTL_CONSTASCII_USTRINGPARAM("ThisComponent")), SbxCLASS_OBJECT );
+
+ if ( pCompVar )
+ {
+ aModel = sbxToUnoValue( pCompVar );
+ if ( sal_False == ( aModel >>= xModel ) ||
+ !xModel.is() )
+ {
+ // trying last gasp try the current component
+ uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ // test if vba service is present
+ uno::Reference< uno::XComponentContext > xCtx( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ uno::Reference<lang::XMultiComponentFactory > xSMgr( xCtx->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XDesktop > xDesktop (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), xCtx), uno::UNO_QUERY_THROW );
+ xModel.set( xDesktop->getCurrentComponent(), uno::UNO_QUERY );
+ if ( !xModel.is() )
+ {
+ throw uno::RuntimeException(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't extract model from basic ( its obviously not set yet ) therefore don't know the currently selected document") ), uno::Reference< uno::XInterface >() );
+ }
+ return xModel;
+ }
+ else
+ {
+ OSL_TRACE("Have model ThisComponent points to url %s",
+ ::rtl::OUStringToOString( xModel->getURL(),
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ }
+ else
+ {
+ OSL_TRACE("Failed to get ThisComponent");
+ throw uno::RuntimeException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(
+ "Can't determine the currently selected document") ),
+ uno::Reference< uno::XInterface >() );
+ }
+ return xModel;
+}
+
+ScDocShell*
+getDocShell( css::uno::Reference< css::frame::XModel>& xModel )
+{
+ uno::Reference< uno::XInterface > xIf( xModel, uno::UNO_QUERY_THROW );
+ ScModelObj* pModel = dynamic_cast< ScModelObj* >( xIf.get() );
+ ScDocShell* pDocShell = NULL;
+ if ( pModel )
+ pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
+ return pDocShell;
+
+}
+
+ScTabViewShell*
+getBestViewShell( css::uno::Reference< css::frame::XModel>& xModel )
+{
+ ScDocShell* pDocShell = getDocShell( xModel );
+ if ( pDocShell )
+ return pDocShell->GetBestViewShell();
+ return NULL;
+}
+
+ScTabViewShell*
+getCurrentBestViewShell()
+{
+ uno::Reference< frame::XModel > xModel = getCurrentDocument();
+ return getBestViewShell( xModel );
+}
+
+SfxViewFrame*
+getCurrentViewFrame()
+{
+ ScTabViewShell* pViewShell = getCurrentBestViewShell();
+ if ( pViewShell )
+ return pViewShell->GetViewFrame();
+ return NULL;
+}
+
+sal_Int32
+OORGBToXLRGB( sal_Int32 nCol )
+{
+ sal_Int32 nRed = nCol;
+ nRed &= 0x00FF0000;
+ nRed >>= 16;
+ sal_Int32 nGreen = nCol;
+ nGreen &= 0x0000FF00;
+ nGreen >>= 8;
+ sal_Int32 nBlue = nCol;
+ nBlue &= 0x000000FF;
+ sal_Int32 nRGB = ( (nBlue << 16) | (nGreen << 8) | nRed );
+ return nRGB;
+}
+sal_Int32
+XLRGBToOORGB( sal_Int32 nCol )
+{
+ sal_Int32 nBlue = nCol;
+ nBlue &= 0x00FF0000;
+ nBlue >>= 16;
+ sal_Int32 nGreen = nCol;
+ nGreen &= 0x0000FF00;
+ nGreen >>= 8;
+ sal_Int32 nRed = nCol;
+ nRed &= 0x000000FF;
+ sal_Int32 nRGB = ( (nRed << 16) | (nGreen << 8) | nBlue );
+ return nRGB;
+}
+uno::Any
+OORGBToXLRGB( const uno::Any& aCol )
+{
+ sal_Int32 nCol=0;
+ aCol >>= nCol;
+ nCol = OORGBToXLRGB( nCol );
+ return uno::makeAny( nCol );
+}
+uno::Any
+XLRGBToOORGB( const uno::Any& aCol )
+{
+ sal_Int32 nCol=0;
+ aCol >>= nCol;
+ nCol = XLRGBToOORGB( nCol );
+ return uno::makeAny( nCol );
+}
+
+void PrintOutHelper( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& /*ActivePrinter*/, const uno::Any& /*PrintToFile*/, const uno::Any& Collate, const uno::Any& PrToFileName, css::uno::Reference< frame::XModel >& xModel, sal_Bool bUseSelection )
+{
+ sal_Int32 nTo = 0;
+ sal_Int32 nFrom = 0;
+ sal_Int16 nCopies = 1;
+ sal_Bool bPreview = sal_False;
+ sal_Bool bCollate = sal_False;
+ sal_Bool bSelection = bUseSelection;
+ From >>= nFrom;
+ To >>= nTo;
+ Copies >>= nCopies;
+ Preview >>= bPreview;
+ if ( nCopies > 1 ) // Collate only useful when more that 1 copy
+ Collate >>= bCollate;
+
+ rtl::OUString sRange( RTL_CONSTASCII_USTRINGPARAM( "-" ) );
+ rtl::OUString sFileName;
+
+ if (( nFrom || nTo ) )
+ {
+ if ( nFrom )
+ sRange = ( ::rtl::OUString::valueOf( nFrom ) + sRange );
+ if ( nTo )
+ sRange += ::rtl::OUString::valueOf( nTo );
+ }
+
+ if ( PrToFileName.getValue() )
+ {
+ PrToFileName >>= sFileName;
+ }
+ ScTabViewShell* pViewShell = getBestViewShell( xModel );
+ SfxViewFrame* pViewFrame = NULL;
+ if ( pViewShell )
+ pViewFrame = pViewShell->GetViewFrame();
+ if ( pViewFrame )
+ {
+ SfxAllItemSet aArgs( SFX_APP()->GetPool() );
+
+ SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate );
+ aArgs.Put( sfxCollate, sfxCollate.Which() );
+ SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
+ aArgs.Put( sfxCopies, sfxCopies.Which() );
+ if ( sFileName.getLength() )
+ {
+ SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
+ aArgs.Put( sfxFileName, sfxFileName.Which() );
+
+ }
+ if ( sRange.getLength() )
+ {
+ SfxStringItem sfxRange( SID_PRINT_PAGES, sRange );
+ aArgs.Put( sfxRange, sfxRange.Which() );
+ }
+ SfxBoolItem sfxSelection( SID_SELECTION, bSelection );
+ aArgs.Put( sfxSelection, sfxSelection.Which() );
+ SfxBoolItem sfxAsync( SID_ASYNCHRON, sal_False );
+ aArgs.Put( sfxAsync, sfxAsync.Which() );
+ SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
+
+ if ( pDispatcher )
+ {
+ if ( bPreview )
+ {
+ if ( !pViewFrame->GetFrame().IsInPlace() )
+ {
+ SC_MOD()->InputEnterHandler();
+ pViewFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_SYNCHRON );
+ while ( isInPrintPreview( pViewFrame ) )
+ Application::Yield();
+ }
+ }
+ else
+ pDispatcher->Execute( (USHORT)SID_PRINTDOC, (SfxCallMode)SFX_CALLMODE_SYNCHRON, aArgs );
+ }
+
+ }
+
+ // #FIXME #TODO
+ // 1 ActivePrinter ( how/can we switch a printer via API? )
+ // 2 PrintToFile ( ms behaviour if this option is specified but no
+ // filename supplied 'PrToFileName' then the user will be prompted )
+ // 3 Need to check behaviour of Selected sheets with range ( e.g. From & To
+ // values ) in oOO these options are mutually exclusive
+ // 4 There is a pop up to do with transparent objects in the print source
+ // should be able to disable that via configuration for the duration
+ // of this method
+}
+
+ void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, css::uno::Reference< css::frame::XModel >& xModel )
+{
+ dispatchExecute( xModel, SID_VIEWSHELL1 );
+}
+
+rtl::OUString getAnyAsString( const uno::Any& pvargItem ) throw ( uno::RuntimeException )
+{
+ uno::Type aType = pvargItem.getValueType();
+ uno::TypeClass eTypeClass = aType.getTypeClass();
+ rtl::OUString sString;
+ switch ( eTypeClass )
+ {
+ case uno::TypeClass_BOOLEAN:
+ {
+ sal_Bool bBool = sal_False;
+ pvargItem >>= bBool;
+ sString = rtl::OUString::valueOf( bBool );
+ break;
+ }
+ case uno::TypeClass_STRING:
+ pvargItem >>= sString;
+ break;
+ case uno::TypeClass_FLOAT:
+ {
+ float aFloat = 0;
+ pvargItem >>= aFloat;
+ sString = rtl::OUString::valueOf( aFloat );
+ break;
+ }
+ case uno::TypeClass_DOUBLE:
+ {
+ double aDouble = 0;
+ pvargItem >>= aDouble;
+ sString = rtl::OUString::valueOf( aDouble );
+ break;
+ }
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ case uno::TypeClass_BYTE:
+ {
+ sal_Int32 aNum = 0;
+ pvargItem >>= aNum;
+ sString = rtl::OUString::valueOf( aNum );
+ break;
+ }
+
+ case uno::TypeClass_HYPER:
+ {
+ sal_Int64 aHyper = 0;
+ pvargItem >>= aHyper;
+ sString = rtl::OUString::valueOf( aHyper );
+ break;
+ }
+ default:
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid type, can't convert" ), uno::Reference< uno::XInterface >() );
+ }
+ return sString;
+}
+
+
+rtl::OUString
+ContainerUtilities::getUniqueName( const uno::Sequence< ::rtl::OUString >& _slist, const rtl::OUString& _sElementName, const ::rtl::OUString& _sSuffixSeparator)
+{
+ return getUniqueName(_slist, _sElementName, _sSuffixSeparator, sal_Int32(2));
+}
+
+rtl::OUString
+ContainerUtilities::getUniqueName( const uno::Sequence< rtl::OUString >& _slist, const rtl::OUString _sElementName, const rtl::OUString& _sSuffixSeparator, sal_Int32 _nStartSuffix)
+{
+ sal_Int32 a = _nStartSuffix;
+ rtl::OUString scompname = _sElementName;
+ bool bElementexists = true;
+ sal_Int32 nLen = _slist.getLength();
+ if ( nLen == 0 )
+ return _sElementName;
+
+ while (bElementexists == true)
+ {
+ for (sal_Int32 i = 0; i < nLen; i++)
+ {
+ if (FieldInList(_slist, scompname) == -1)
+ {
+ return scompname;
+ }
+ }
+ scompname = _sElementName + _sSuffixSeparator + rtl::OUString::valueOf( a++ );
+ }
+ return rtl::OUString();
+}
+
+sal_Int32
+ContainerUtilities::FieldInList( const uno::Sequence< rtl::OUString >& SearchList, const rtl::OUString& SearchString )
+{
+ sal_Int32 FieldLen = SearchList.getLength();
+ sal_Int32 retvalue = -1;
+ for (sal_Int32 i = 0; i < FieldLen; i++)
+ {
+ // I wonder why comparing lexicographically is done
+ // when its a match is whats interesting?
+ //if (SearchList[i].compareTo(SearchString) == 0)
+ if ( SearchList[i].equals( SearchString ) )
+ {
+ retvalue = i;
+ break;
+ }
+ }
+ return retvalue;
+
+}
+bool NeedEsc(sal_Unicode cCode)
+{
+ String sEsc(RTL_CONSTASCII_USTRINGPARAM(".^$+\\|{}()"));
+ return (STRING_NOTFOUND != sEsc.Search(cCode));
+}
+
+rtl::OUString VBAToRegexp(const rtl::OUString &rIn, bool bForLike )
+{
+ rtl::OUStringBuffer sResult;
+ const sal_Unicode *start = rIn.getStr();
+ const sal_Unicode *end = start + rIn.getLength();
+
+ int seenright = 0;
+ if ( bForLike )
+ sResult.append(static_cast<sal_Unicode>('^'));
+
+ while (start < end)
+ {
+ switch (*start)
+ {
+ case '?':
+ sResult.append(static_cast<sal_Unicode>('.'));
+ start++;
+ break;
+ case '*':
+ sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".*")));
+ start++;
+ break;
+ case '#':
+ sResult.append(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[0-9]")));
+ start++;
+ break;
+ case '~':
+ sResult.append(static_cast<sal_Unicode>('\\'));
+ sResult.append(*(++start));
+ start++;
+ break;
+ // dump the ~ and escape the next characture
+ case ']':
+ sResult.append(static_cast<sal_Unicode>('\\'));
+ sResult.append(*start++);
+ break;
+ case '[':
+ sResult.append(*start++);
+ seenright = 0;
+ while (start < end && !seenright)
+ {
+ switch (*start)
+ {
+ case '[':
+ case '?':
+ case '*':
+ sResult.append(static_cast<sal_Unicode>('\\'));
+ sResult.append(*start);
+ break;
+ case ']':
+ sResult.append(*start);
+ seenright = 1;
+ break;
+ case '!':
+ sResult.append(static_cast<sal_Unicode>('^'));
+ break;
+ default:
+ if (NeedEsc(*start))
+ sResult.append(static_cast<sal_Unicode>('\\'));
+ sResult.append(*start);
+ break;
+ }
+ start++;
+ }
+ break;
+ default:
+ if (NeedEsc(*start))
+ sResult.append(static_cast<sal_Unicode>('\\'));
+ sResult.append(*start++);
+ }
+ }
+
+ if ( bForLike )
+ sResult.append(static_cast<sal_Unicode>('$'));
+
+ return sResult.makeStringAndClear( );
+}
+
+double getPixelTo100thMillimeterConversionFactor( css::uno::Reference< css::awt::XDevice >& xDevice, sal_Bool bVertical)
+{
+ double fConvertFactor = 1.0;
+ if( bVertical )
+ {
+ fConvertFactor = xDevice->getInfo().PixelPerMeterY/100000;
+ }
+ else
+ {
+ fConvertFactor = xDevice->getInfo().PixelPerMeterX/100000;
+ }
+ return fConvertFactor;
+}
+
+double PointsToPixels( css::uno::Reference< css::awt::XDevice >& xDevice, double fPoints, sal_Bool bVertical)
+{
+ double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
+ return fPoints * POINTTO100THMILLIMETERFACTOR * fConvertFactor;
+}
+double PixelsToPoints( css::uno::Reference< css::awt::XDevice >& xDevice, double fPixels, sal_Bool bVertical)
+{
+ double fConvertFactor = getPixelTo100thMillimeterConversionFactor( xDevice, bVertical );
+ return (fPixels/fConvertFactor)/POINTTO100THMILLIMETERFACTOR;
+}
+
+ConcreteXShapeGeometryAttributes::ConcreteXShapeGeometryAttributes( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape )
+{
+ m_xShape = new ScVbaShape( xContext, xShape );
+}
+
+#define VBA_LEFT "PositionX"
+#define VBA_TOP "PositionY"
+UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
+{
+ mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW );
+}
+ double UserFormGeometryHelper::getLeft()
+ {
+ sal_Int32 nLeft = 0;
+ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft;
+ return Millimeter::getInPoints( nLeft );
+ }
+ void UserFormGeometryHelper::setLeft( double nLeft )
+ {
+ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nLeft ) ) );
+ }
+ double UserFormGeometryHelper::getTop()
+ {
+ sal_Int32 nTop = 0;
+ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop;
+ return Millimeter::getInPoints( nTop );
+ }
+ void UserFormGeometryHelper::setTop( double nTop )
+ {
+ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nTop ) ) );
+ }
+ double UserFormGeometryHelper::getHeight()
+ {
+ sal_Int32 nHeight = 0;
+ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ) ) >>= nHeight;
+ return Millimeter::getInPoints( nHeight );
+ }
+ void UserFormGeometryHelper::setHeight( double nHeight )
+ {
+ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLHGT ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nHeight ) ) );
+ }
+ double UserFormGeometryHelper::getWidth()
+ {
+ sal_Int32 nWidth = 0;
+ mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ) ) >>= nWidth;
+ return Millimeter::getInPoints( nWidth );
+ }
+ void UserFormGeometryHelper::setWidth( double nWidth)
+ {
+ mxModel->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_CELLWID ) ), uno::makeAny( Millimeter::getInHundredthsOfOneMillimeter( nWidth ) ) );
+ }
+
+SfxItemSet*
+ScVbaCellRangeAccess::GetDataSet( ScCellRangeObj* pRangeObj )
+{
+ SfxItemSet* pDataSet = pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : NULL ;
+ return pDataSet;
+
+}
+
+} // vba
+} // ooo
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbahyperlink.cxx b/sc/source/ui/vba/vbahyperlink.cxx
new file mode 100644
index 000000000000..4499a1183400
--- /dev/null
+++ b/sc/source/ui/vba/vbahyperlink.cxx
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbahyperlink.hxx"
+#include <vbahelper/helperdecl.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <ooo/vba/office/MsoHyperlinkType.hpp>
+#include <ooo/vba/msforms/XShape.hpp>
+#include "vbarange.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+// ============================================================================
+
+ScVbaHyperlink::ScVbaHyperlink( const uno::Sequence< uno::Any >& rArgs,
+ const uno::Reference< uno::XComponentContext >& rxContext ) throw (lang::IllegalArgumentException) :
+ HyperlinkImpl_BASE( getXSomethingFromArgs< XHelperInterface >( rArgs, 0 ), rxContext ),
+ mxCell( getXSomethingFromArgs< table::XCell >( rArgs, 1, false ) ),
+ mnType( office::MsoHyperlinkType::msoHyperlinkRange )
+{
+ uno::Reference< text::XTextFieldsSupplier > xTextFields( mxCell, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndex( xTextFields->getTextFields(), uno::UNO_QUERY_THROW );
+ mxTextField.set( xIndex->getByIndex(0), uno::UNO_QUERY_THROW );
+}
+
+ScVbaHyperlink::ScVbaHyperlink( const uno::Reference< XHelperInterface >& rxAnchor,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Any& rAddress, const uno::Any& rSubAddress,
+ const uno::Any& rScreenTip, const uno::Any& rTextToDisplay ) throw (uno::RuntimeException) :
+ HyperlinkImpl_BASE( rxAnchor, rxContext ) // parent of Hyperlink is the anchor object
+{
+ // extract parameters, Address must not be empty
+ UrlComponents aUrlComp;
+ OUString aTextToDisplay;
+ if( !(rAddress >>= aUrlComp.first) || (aUrlComp.first.getLength() == 0) )
+ throw uno::RuntimeException( OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot get address" ) ), uno::Reference< uno::XInterface >() );
+ rSubAddress >>= aUrlComp.second;
+ rScreenTip >>= maScreenTip;
+ rTextToDisplay >>= aTextToDisplay;
+
+ // get anchor range or anchor shape
+ uno::Reference< excel::XRange > xAnchorRange( rxAnchor, uno::UNO_QUERY );
+ if( xAnchorRange.is() )
+ {
+ mnType = office::MsoHyperlinkType::msoHyperlinkRange;
+ // only single ranges are allowed
+ uno::Reference< table::XCellRange > xUnoRange( ScVbaRange::getCellRange( xAnchorRange ), uno::UNO_QUERY_THROW );
+ // insert the hyperlink into the top-left cell only
+ mxCell.set( xUnoRange->getCellByPosition( 0, 0 ), uno::UNO_SET_THROW );
+ uno::Reference< text::XText > xText( mxCell, uno::UNO_QUERY_THROW );
+ // use cell text or URL if no TextToDisplay has been passed
+ if( aTextToDisplay.getLength() == 0 )
+ {
+ aTextToDisplay = xText->getString();
+ if( aTextToDisplay.getLength() == 0 )
+ {
+ OUStringBuffer aBuffer( aUrlComp.first );
+ if( aUrlComp.second.getLength() > 0 )
+ aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ) ).append( aUrlComp.second );
+ aTextToDisplay = aBuffer.makeStringAndClear();
+ }
+ }
+ // create and initialize a new URL text field
+ uno::Reference< lang::XMultiServiceFactory > xFactory( ScVbaRange::getUnoModel( xAnchorRange ), uno::UNO_QUERY_THROW );
+ uno::Reference< text::XTextContent > xUrlField( xFactory->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.TextField.URL" ) ) ), uno::UNO_QUERY_THROW );
+ mxTextField.set( xUrlField, uno::UNO_QUERY_THROW );
+ setUrlComponents( aUrlComp );
+ setTextToDisplay( aTextToDisplay );
+ // insert the text field into the document
+ xText->setString( OUString() );
+ uno::Reference< text::XTextRange > xRange( xText->createTextCursor(), uno::UNO_QUERY_THROW );
+ xText->insertTextContent( xRange, xUrlField, sal_False );
+ }
+ else
+ {
+ uno::Reference< msforms::XShape > xAnchorShape( rxAnchor, uno::UNO_QUERY_THROW );
+ mnType = office::MsoHyperlinkType::msoHyperlinkShape;
+ // FIXME: insert hyperlink into shape
+ throw uno::RuntimeException();
+ }
+}
+
+ScVbaHyperlink::~ScVbaHyperlink()
+{
+}
+
+OUString ScVbaHyperlink::getName() throw (uno::RuntimeException)
+{
+ // it seems this attribute is same as TextToDisplay
+ return getTextToDisplay();
+}
+
+void ScVbaHyperlink::setName( const OUString& rName ) throw (uno::RuntimeException)
+{
+ setTextToDisplay( rName );
+}
+
+OUString ScVbaHyperlink::getAddress() throw (uno::RuntimeException)
+{
+ return getUrlComponents().first;
+}
+
+void ScVbaHyperlink::setAddress( const OUString& rAddress ) throw (uno::RuntimeException)
+{
+ UrlComponents aUrlComp = getUrlComponents();
+ aUrlComp.first = rAddress;
+ setUrlComponents( aUrlComp );
+}
+
+OUString ScVbaHyperlink::getSubAddress() throw (uno::RuntimeException)
+{
+ return getUrlComponents().second;
+}
+
+void ScVbaHyperlink::setSubAddress( const OUString& rSubAddress ) throw (uno::RuntimeException)
+{
+ UrlComponents aUrlComp = getUrlComponents();
+ aUrlComp.second = rSubAddress;
+ setUrlComponents( aUrlComp );
+}
+
+OUString SAL_CALL ScVbaHyperlink::getScreenTip() throw (uno::RuntimeException)
+{
+ return maScreenTip;
+}
+
+void SAL_CALL ScVbaHyperlink::setScreenTip( const OUString& rScreenTip ) throw (uno::RuntimeException)
+{
+ maScreenTip = rScreenTip;
+}
+
+OUString ScVbaHyperlink::getTextToDisplay() throw (uno::RuntimeException)
+{
+ ensureTextField();
+ OUString aTextToDisplay;
+ mxTextField->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Representation" ) ) ) >>= aTextToDisplay;
+ return aTextToDisplay;
+}
+
+void ScVbaHyperlink::setTextToDisplay( const OUString& rTextToDisplay ) throw (uno::RuntimeException)
+{
+ ensureTextField();
+ mxTextField->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Representation" ) ), uno::Any( rTextToDisplay ) );
+}
+
+sal_Int32 SAL_CALL ScVbaHyperlink::getType() throw (uno::RuntimeException)
+{
+ return mnType;
+}
+
+uno::Reference< excel::XRange > SAL_CALL ScVbaHyperlink::getRange() throw (uno::RuntimeException)
+{
+ if( mnType == office::MsoHyperlinkType::msoHyperlinkRange )
+ {
+ // if constructed from Hyperlinks object, range has been passed as parent
+ uno::Reference< excel::XRange > xAnchorRange( getParent(), uno::UNO_QUERY );
+ if( !xAnchorRange.is() )
+ {
+ // if constructed via service c'tor, create new range based on cell
+ uno::Reference< table::XCellRange > xRange( mxCell, uno::UNO_QUERY_THROW );
+ // FIXME: need to pass current worksheet as the parent of XRange.
+ xAnchorRange.set( new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xRange ) );
+ }
+ return xAnchorRange;
+ }
+ // error if called at a shape Hyperlink object
+ throw uno::RuntimeException();
+}
+
+uno::Reference< msforms::XShape > SAL_CALL ScVbaHyperlink::getShape() throw (uno::RuntimeException)
+{
+ // error if called at a range Hyperlink object
+ return uno::Reference< msforms::XShape >( getParent(), uno::UNO_QUERY_THROW );
+}
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaHyperlink, "ooo.vba.excel.Hyperlink" )
+
+// private --------------------------------------------------------------------
+
+void ScVbaHyperlink::ensureTextField() throw (uno::RuntimeException)
+{
+ if( !mxTextField.is() )
+ throw uno::RuntimeException();
+}
+
+ScVbaHyperlink::UrlComponents ScVbaHyperlink::getUrlComponents() throw (uno::RuntimeException)
+{
+ ensureTextField();
+ OUString aUrl;
+ mxTextField->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) ) >>= aUrl;
+ sal_Int32 nHashPos = aUrl.indexOf( '#' );
+ if( nHashPos < 0 )
+ return UrlComponents( aUrl, OUString() );
+ return UrlComponents( aUrl.copy( 0, nHashPos ), aUrl.copy( nHashPos + 1 ) );
+}
+
+void ScVbaHyperlink::setUrlComponents( const UrlComponents& rUrlComp ) throw (uno::RuntimeException)
+{
+ ensureTextField();
+ OUStringBuffer aUrl( rUrlComp.first );
+ if( rUrlComp.second.getLength() > 0 )
+ aUrl.append( sal_Unicode( '#' ) ).append( rUrlComp.second );
+ mxTextField->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ), uno::Any( aUrl.makeStringAndClear() ) );
+}
+
+namespace hyperlink
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaHyperlink, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaHyperlink",
+ "ooo.vba.excel.Hyperlink" );
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbahyperlink.hxx b/sc/source/ui/vba/vbahyperlink.hxx
new file mode 100644
index 000000000000..1e74707c2397
--- /dev/null
+++ b/sc/source/ui/vba/vbahyperlink.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_HYPERLINK_HXX
+#define SC_VBA_HYPERLINK_HXX
+
+#include <ooo/vba/excel/XHyperlink.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/excel/XRange.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XHyperlink > HyperlinkImpl_BASE;
+
+class ScVbaHyperlink : public HyperlinkImpl_BASE
+{
+public:
+ ScVbaHyperlink(
+ const css::uno::Sequence< css::uno::Any >& rArgs,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext ) throw (css::lang::IllegalArgumentException);
+
+ ScVbaHyperlink(
+ const css::uno::Reference< ov::XHelperInterface >& rxAnchor,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Any& rAddress, const css::uno::Any& rSubAddress,
+ const css::uno::Any& rScreenTip, const css::uno::Any& rTextToDisplay ) throw (css::uno::RuntimeException);
+
+ virtual ~ScVbaHyperlink();
+
+ // Attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAddress() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAddress( const ::rtl::OUString& rAddress ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSubAddress() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSubAddress( const ::rtl::OUString& rSubAddress ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getScreenTip() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setScreenTip( const ::rtl::OUString& rScreenTip ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTextToDisplay() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTextToDisplay( const ::rtl::OUString& rTextToDisplay ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getRange() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::msforms::XShape > SAL_CALL getShape() throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ typedef ::std::pair< ::rtl::OUString, ::rtl::OUString > UrlComponents;
+
+ void ensureTextField() throw (css::uno::RuntimeException);
+ UrlComponents getUrlComponents() throw (css::uno::RuntimeException);
+ void setUrlComponents( const UrlComponents& rUrlComp ) throw (css::uno::RuntimeException);
+
+private:
+ css::uno::Reference< css::table::XCell > mxCell;
+ css::uno::Reference< css::beans::XPropertySet > mxTextField;
+ ::rtl::OUString maScreenTip;
+ long mnType;
+};
+
+#endif /* SC_VBA_HYPERLINK_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbahyperlinks.cxx b/sc/source/ui/vba/vbahyperlinks.cxx
new file mode 100644
index 000000000000..686f636669c8
--- /dev/null
+++ b/sc/source/ui/vba/vbahyperlinks.cxx
@@ -0,0 +1,296 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbahyperlinks.hxx"
+#include <algorithm>
+#include <vector>
+#include <ooo/vba/office/MsoHyperlinkType.hpp>
+#include "rangelst.hxx"
+#include "vbahyperlink.hxx"
+#include "vbarange.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+// ============================================================================
+
+namespace {
+
+/** Returns true, if every range of rxInner is contained in any range of rScOuter. */
+bool lclContains( const ScRangeList& rScOuter, const uno::Reference< excel::XRange >& rxInner ) throw (uno::RuntimeException)
+{
+ const ScRangeList& rScInner = ScVbaRange::getScRangeList( rxInner );
+ if( (rScInner.Count() == 0) || (rScOuter.Count() == 0) )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Empty range objects" ) ), uno::Reference< uno::XInterface >() );
+
+ for( ULONG nIndex = 0, nCount = rScInner.Count(); nIndex < nCount; ++nIndex )
+ if( !rScOuter.In( *rScInner.GetObject( nIndex ) ) )
+ return false;
+ return true;
+}
+
+// ----------------------------------------------------------------------------
+
+/** Functor to decide whether the anchors of two Hyperlink objects are equal. */
+struct EqualAnchorFunctor
+{
+ uno::Reference< excel::XRange > mxAnchorRange;
+ uno::Reference< msforms::XShape > mxAnchorShape;
+ sal_Int32 mnType;
+ EqualAnchorFunctor( const uno::Reference< excel::XHyperlink >& rxHlink ) throw (uno::RuntimeException);
+ bool operator()( const uno::Reference< excel::XHyperlink >& rxHlink ) const throw (uno::RuntimeException);
+};
+
+EqualAnchorFunctor::EqualAnchorFunctor( const uno::Reference< excel::XHyperlink >& rxHlink ) throw (uno::RuntimeException) :
+ mnType( rxHlink->getType() )
+{
+ switch( mnType )
+ {
+ case office::MsoHyperlinkType::msoHyperlinkRange:
+ mxAnchorRange.set( rxHlink->getRange(), uno::UNO_QUERY_THROW );
+ break;
+ case office::MsoHyperlinkType::msoHyperlinkShape:
+ case office::MsoHyperlinkType::msoHyperlinkInlineShape:
+ mxAnchorShape.set( rxHlink->getShape(), uno::UNO_QUERY_THROW );
+ break;
+ default:
+ throw uno::RuntimeException();
+ }
+}
+
+bool EqualAnchorFunctor::operator()( const uno::Reference< excel::XHyperlink >& rxHlink ) const throw (uno::RuntimeException)
+{
+ sal_Int32 nType = rxHlink->getType();
+ if( nType != mnType )
+ return false;
+
+ switch( nType )
+ {
+ case office::MsoHyperlinkType::msoHyperlinkRange:
+ {
+ uno::Reference< excel::XRange > xAnchorRange( rxHlink->getRange(), uno::UNO_QUERY_THROW );
+ const ScRangeList& rScRanges1 = ScVbaRange::getScRangeList( xAnchorRange );
+ const ScRangeList& rScRanges2 = ScVbaRange::getScRangeList( mxAnchorRange );
+ return (rScRanges1.Count() == 1) && (rScRanges2.Count() == 1) && (*rScRanges1.GetObject( 0 ) == *rScRanges2.GetObject( 0 ));
+ }
+ case office::MsoHyperlinkType::msoHyperlinkShape:
+ case office::MsoHyperlinkType::msoHyperlinkInlineShape:
+ {
+ uno::Reference< msforms::XShape > xAnchorShape( rxHlink->getShape(), uno::UNO_QUERY_THROW );
+ return xAnchorShape.get() == mxAnchorShape.get();
+ }
+ default:
+ throw uno::RuntimeException();
+ }
+}
+
+} // namespace
+
+// ============================================================================
+
+namespace detail {
+
+class ScVbaHlinkContainer : public ::cppu::WeakImplHelper1< container::XIndexAccess >
+{
+public:
+ explicit ScVbaHlinkContainer() throw (uno::RuntimeException);
+ explicit ScVbaHlinkContainer( const ScVbaHlinkContainerRef& rxSheetContainer, const ScRangeList& rScRanges ) throw (uno::RuntimeException);
+ virtual ~ScVbaHlinkContainer();
+
+ /** Inserts the passed hyperlink into the collection. Will remove a
+ Hyperlink object with the same anchor as the passed Hyperlink object. */
+ void insertHyperlink( const uno::Reference< excel::XHyperlink >& rxHlink ) throw (uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException);
+
+private:
+ typedef ::std::vector< uno::Reference< excel::XHyperlink > > HyperlinkVector;
+ HyperlinkVector maHlinks;
+};
+
+// ----------------------------------------------------------------------------
+
+ScVbaHlinkContainer::ScVbaHlinkContainer() throw (uno::RuntimeException)
+{
+ // TODO FIXME: fill with existing hyperlinks
+}
+
+ScVbaHlinkContainer::ScVbaHlinkContainer( const ScVbaHlinkContainerRef& rxSheetContainer,
+ const ScRangeList& rScRanges ) throw (uno::RuntimeException)
+{
+ for( sal_Int32 nIndex = 0, nCount = rxSheetContainer->getCount(); nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< excel::XHyperlink > xHlink( rxSheetContainer->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XRange > xHlinkRange( xHlink->getRange(), uno::UNO_QUERY_THROW );
+ if( lclContains( rScRanges, xHlinkRange ) )
+ maHlinks.push_back( xHlink );
+ }
+}
+
+ScVbaHlinkContainer::~ScVbaHlinkContainer()
+{
+}
+
+void ScVbaHlinkContainer::insertHyperlink( const uno::Reference< excel::XHyperlink >& rxHlink ) throw (uno::RuntimeException)
+{
+ HyperlinkVector::iterator aIt = ::std::find_if( maHlinks.begin(), maHlinks.end(), EqualAnchorFunctor( rxHlink ) );
+ if( aIt == maHlinks.end() )
+ maHlinks.push_back( rxHlink );
+ else
+ *aIt = rxHlink;
+}
+
+sal_Int32 SAL_CALL ScVbaHlinkContainer::getCount() throw (uno::RuntimeException)
+{
+ return static_cast< sal_Int32 >( maHlinks.size() );
+}
+
+uno::Any SAL_CALL ScVbaHlinkContainer::getByIndex( sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( (0 <= nIndex) && (nIndex < getCount()) )
+ return uno::Any( maHlinks[ static_cast< size_t >( nIndex ) ] );
+ throw lang::IndexOutOfBoundsException();
+}
+
+uno::Type SAL_CALL ScVbaHlinkContainer::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XHyperlink::static_type( 0 );
+}
+
+sal_Bool SAL_CALL ScVbaHlinkContainer::hasElements() throw (uno::RuntimeException)
+{
+ return !maHlinks.empty();
+}
+
+// ============================================================================
+
+ScVbaHlinkContainerMember::ScVbaHlinkContainerMember( ScVbaHlinkContainer* pContainer ) :
+ mxContainer( pContainer )
+{
+}
+
+ScVbaHlinkContainerMember::~ScVbaHlinkContainerMember()
+{
+}
+
+} // namespace detail
+
+// ============================================================================
+
+ScVbaHyperlinks::ScVbaHyperlinks( const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext ) throw (uno::RuntimeException) :
+ detail::ScVbaHlinkContainerMember( new detail::ScVbaHlinkContainer ),
+ ScVbaHyperlinks_BASE( rxParent, rxContext, uno::Reference< container::XIndexAccess >( mxContainer.get() ) )
+{
+}
+
+ScVbaHyperlinks::ScVbaHyperlinks( const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const ScVbaHyperlinksRef& rxSheetHlinks, const ScRangeList& rScRanges ) throw (uno::RuntimeException) :
+ detail::ScVbaHlinkContainerMember( new detail::ScVbaHlinkContainer( rxSheetHlinks->mxContainer, rScRanges ) ),
+ ScVbaHyperlinks_BASE( rxParent, rxContext, uno::Reference< container::XIndexAccess >( mxContainer.get() ) ),
+ mxSheetHlinks( rxSheetHlinks )
+{
+}
+
+ScVbaHyperlinks::~ScVbaHyperlinks()
+{
+}
+
+// XHyperlinks ----------------------------------------------------------------
+
+uno::Reference< excel::XHyperlink > SAL_CALL ScVbaHyperlinks::Add(
+ const uno::Any& rAnchor, const uno::Any& rAddress, const uno::Any& rSubAddress,
+ const uno::Any& rScreenTip, const uno::Any& rTextToDisplay ) throw (uno::RuntimeException)
+{
+ /* If this Hyperlinks object has been craeted from a Range object, the
+ call to Add() is passed to the Hyperlinks object of the parent
+ worksheet. This container will not be modified (it will not contain the
+ inserted hyperlink).
+ For details, see documentation in hyperlinks.hxx.
+ */
+ if( mxSheetHlinks.is() )
+ return mxSheetHlinks->Add( rAnchor, rAddress, rSubAddress, rScreenTip, rTextToDisplay );
+
+ // get anchor object (can be a Range or a Shape object)
+ uno::Reference< XHelperInterface > xAnchor( rAnchor, uno::UNO_QUERY_THROW );
+
+ /* Create the Hyperlink object, this tries to insert the hyperlink into
+ the spreadsheet document. Parent of the Hyperlink is the anchor object. */
+ uno::Reference< excel::XHyperlink > xHlink( new ScVbaHyperlink(
+ xAnchor, mxContext, rAddress, rSubAddress, rScreenTip, rTextToDisplay ) );
+
+ /* If creation of the hyperlink did not throw, insert it into the
+ collection. */
+ mxContainer->insertHyperlink( xHlink );
+ return xHlink;
+}
+
+void SAL_CALL ScVbaHyperlinks::Delete() throw (uno::RuntimeException)
+{
+ // FIXME not implemented
+ throw uno::RuntimeException();
+}
+
+// XEnumerationAccess ---------------------------------------------------------
+
+uno::Reference< container::XEnumeration > SAL_CALL ScVbaHyperlinks::createEnumeration() throw (uno::RuntimeException)
+{
+ return new SimpleIndexAccessToEnumeration( m_xIndexAccess );
+}
+
+// XElementAccess -------------------------------------------------------------
+
+uno::Type SAL_CALL ScVbaHyperlinks::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XHyperlink::static_type( 0 );
+}
+
+// ScVbaCollectionBase --------------------------------------------------------
+
+uno::Any ScVbaHyperlinks::createCollectionObject( const uno::Any& rSource )
+{
+ // container stores XHyperlink objects, just return the passed object
+ return rSource;
+}
+
+// XHelperInterface -----------------------------------------------------------
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaHyperlinks, "ooo.vba.excel.Hyperlinks" )
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbahyperlinks.hxx b/sc/source/ui/vba/vbahyperlinks.hxx
new file mode 100644
index 000000000000..37dab9dd886a
--- /dev/null
+++ b/sc/source/ui/vba/vbahyperlinks.hxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_HYPERLINKS_HXX
+#define SC_VBA_HYPERLINKS_HXX
+
+#include <ooo/vba/excel/XHyperlinks.hpp>
+#include <rtl/ref.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+class ScRangeList;
+
+// ============================================================================
+
+namespace detail {
+
+class ScVbaHlinkContainer;
+typedef ::rtl::Reference< ScVbaHlinkContainer > ScVbaHlinkContainerRef;
+
+/** Base class for ScVbaHyperlinks to get an initialized ScVbaHlinkContainer
+ class member before the ScVbaHyperlinks_BASE base class will be constructed.
+ */
+struct ScVbaHlinkContainerMember
+{
+ ScVbaHlinkContainerRef mxContainer;
+
+ explicit ScVbaHlinkContainerMember( ScVbaHlinkContainer* pContainer );
+ ~ScVbaHlinkContainerMember();
+};
+
+} // namespace detail
+
+// ============================================================================
+
+class ScVbaHyperlinks;
+typedef ::rtl::Reference< ScVbaHyperlinks > ScVbaHyperlinksRef;
+
+typedef CollTestImplHelper< ov::excel::XHyperlinks > ScVbaHyperlinks_BASE;
+
+/** Represents a collection of hyperlinks of a worksheet or of a range.
+
+ When a Hyperlinks collection object has been constructed from a VBA
+ Worksheet object, it will always represent the current set of all
+ hyperlinks existing in the sheet. Insertion and deletion of hyperlinks will
+ be reflected by the instance.
+
+ When a Hyperlinks collection object has been constructed from a VBA Range
+ object, it will represent the set of hyperlinks that have existed at its
+ construction time, and that are located completely inside the range(s)
+ represented by the Range object. Insertion and deletion of hyperlinks will
+ *not* be reflected by that instance. The instance will always offer all
+ hyperlinks it has been constructed with, even if they no longer exist.
+ Furthermore, the instance will not offer hyperlinks inserted later, even if
+ the instance itself has been used to insert the new hyperlinks.
+
+ VBA code example:
+
+ With ThisWorkbook.Worksheets(1)
+
+ Set hlinks = .Hyperlinks ' global Hyperlinks object
+ Set myrange = .Range("A1:C3")
+ Set rangelinks1 = myrange.Hyperlinks ' hyperlinks of range A1:C3
+
+ MsgBox hlinks.Count ' 0
+ MsgBox rangelinks1.Count ' 0
+
+ hlinks.Add .Range("A1"), "http://example.com"
+ ' a new hyperlink has been added in cell A1
+
+ MsgBox hlinks.Count ' 1
+ MsgBox rangelinks1.Count ' still 0!
+ Set rangelinks2 = myrange.Hyperlinks ' hyperlinks of range A1:C3
+ MsgBox rangelinks2.Count ' 1 (constructed after Add)
+
+ rangelinks1.Add .Range("A2"), "http://example.com"
+ ' a new hyperlink has been constructed via the rangelinks1 object
+ ' but this addition has been done by the worksheet Hyperlinks object
+
+ MsgBox hlinks.Count ' 2
+ MsgBox rangelinks1.Count ' still 0!!!
+ MsgBox rangelinks2.Count ' still 1!!!
+ MsgBox myrange.Hyperlinks.Count ' 2 (constructed after Add)
+
+ End With
+ */
+class ScVbaHyperlinks : private detail::ScVbaHlinkContainerMember, public ScVbaHyperlinks_BASE
+{
+public:
+ explicit ScVbaHyperlinks(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext ) throw (css::uno::RuntimeException);
+
+ explicit ScVbaHyperlinks(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const ScVbaHyperlinksRef& rxSheetHlinks, const ScRangeList& rScRanges ) throw (css::uno::RuntimeException);
+
+ virtual ~ScVbaHyperlinks();
+
+ // XHyperlinks
+ virtual css::uno::Reference< ov::excel::XHyperlink > SAL_CALL Add(
+ const css::uno::Any& rAnchor, const css::uno::Any& rAddress, const css::uno::Any& rSubAddress,
+ const css::uno::Any& rScreenTip, const css::uno::Any& rTextToDisplay )
+ throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+
+ // ScVbaCollectionBase
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& rSource );
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ ScVbaHyperlinksRef mxSheetHlinks;
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbainterior.cxx b/sc/source/ui/vba/vbainterior.cxx
new file mode 100644
index 000000000000..f3ea1b0f53dd
--- /dev/null
+++ b/sc/source/ui/vba/vbainterior.cxx
@@ -0,0 +1,419 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/reflection/XIdlMethod.hpp>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/xml/AttributeData.hpp>
+
+#include <ooo/vba/excel/XlColorIndex.hpp>
+#include <ooo/vba/excel/XlPattern.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+#include <map>
+
+#include <svx/xtable.hxx>
+
+#include "vbainterior.hxx"
+#include "vbapalette.hxx"
+#include "document.hxx"
+
+#define STATIC_TABLE_SIZE( array ) (sizeof(array)/sizeof(*(array)))
+#define COLORMAST 0xFFFFFF
+const sal_uInt16 EXC_COLOR_WINDOWBACK = 65;
+typedef std::map< sal_Int32, sal_Int32 > PatternMap;
+typedef std::pair< sal_Int32, sal_Int32 > PatternPair;
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+using namespace ::ooo::vba::excel::XlPattern;
+static const rtl::OUString BACKCOLOR( RTL_CONSTASCII_USTRINGPARAM( "CellBackColor" ) );
+static const rtl::OUString PATTERN( RTL_CONSTASCII_USTRINGPARAM( "Pattern" ) );
+static const rtl::OUString PATTERNCOLOR( RTL_CONSTASCII_USTRINGPARAM( "PatternColor" ) );
+
+PatternMap lcl_getPatternMap()
+{
+ PatternMap aPatternMap;
+ aPatternMap.insert( PatternPair( xlPatternAutomatic, 0 ) );
+ aPatternMap.insert( PatternPair( xlPatternChecker, 9 ) );
+ aPatternMap.insert( PatternPair( xlPatternCrissCross, 16 ) );
+ aPatternMap.insert( PatternPair( xlPatternDown, 7 ) );
+ aPatternMap.insert( PatternPair( xlPatternGray16, 17 ) );
+ aPatternMap.insert( PatternPair( xlPatternGray25, 4 ) );
+ aPatternMap.insert( PatternPair( xlPatternGray50, 2 ) );
+ aPatternMap.insert( PatternPair( xlPatternGray75, 3 ) );
+ aPatternMap.insert( PatternPair( xlPatternGray8, 18 ) );
+ aPatternMap.insert( PatternPair( xlPatternGrid, 15 ) );
+ aPatternMap.insert( PatternPair( xlPatternHorizontal, 5 ) );
+ aPatternMap.insert( PatternPair( xlPatternLightDown, 13 ) );
+ aPatternMap.insert( PatternPair( xlPatternLightHorizontal, 11 ) );
+ aPatternMap.insert( PatternPair( xlPatternLightUp, 14 ) );
+ aPatternMap.insert( PatternPair( xlPatternLightVertical, 12 ) );
+ aPatternMap.insert( PatternPair( xlPatternNone, 0 ) );
+ aPatternMap.insert( PatternPair( xlPatternSemiGray75, 10 ) );
+ aPatternMap.insert( PatternPair( xlPatternSolid, 0 ) );
+ aPatternMap.insert( PatternPair( xlPatternUp, 8 ) );
+ aPatternMap.insert( PatternPair( xlPatternVertical, 6 ) );
+ return aPatternMap;
+}
+
+static PatternMap aPatternMap( lcl_getPatternMap() );
+
+ScVbaInterior::ScVbaInterior( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< beans::XPropertySet >& xProps, ScDocument* pScDoc ) throw ( lang::IllegalArgumentException) : ScVbaInterior_BASE( xParent, xContext ), m_xProps(xProps), m_pScDoc( pScDoc )
+{
+ // auto color
+ //m_aPattColor.SetColor( (sal_uInt32)0xFFFFFFFF );
+ m_aPattColor.SetColor( (sal_uInt32)0x0 );
+ m_nPattern = 0L;
+ if ( !m_xProps.is() )
+ throw lang::IllegalArgumentException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "properties") ), uno::Reference< uno::XInterface >(), 2 );
+}
+
+uno::Any
+ScVbaInterior::getColor() throw (uno::RuntimeException)
+{
+ Color aBackColor( GetBackColor() );
+ return uno::makeAny( OORGBToXLRGB( aBackColor.GetColor() ) );
+}
+
+void
+ScVbaInterior::setColor( const uno::Any& _color ) throw (uno::RuntimeException)
+{
+ sal_Int32 nColor = 0;
+ if( _color >>= nColor )
+ {
+ SetUserDefinedAttributes( BACKCOLOR, SetAttributeData( XLRGBToOORGB( nColor ) ) );
+ //m_xProps->setPropertyValue( BACKCOLOR , XLRGBToOORGB(_color));
+ SetMixedColor();
+ }
+}
+
+void
+ScVbaInterior::SetMixedColor()
+{
+ // pattern
+ uno::Any aPattern = GetUserDefinedAttributes( PATTERN );
+ if( aPattern.hasValue() )
+ {
+ m_nPattern = GetAttributeData( aPattern );
+ }
+ sal_Int32 nPattern = aPatternMap[ m_nPattern ];
+ // pattern color
+ uno::Any aPatternColor = GetUserDefinedAttributes( PATTERNCOLOR );
+ if( aPatternColor.hasValue() )
+ {
+ sal_uInt32 nPatternColor = GetAttributeData( aPatternColor );
+ m_aPattColor.SetColor( nPatternColor );
+ }
+ sal_Int32 nPatternColor = m_aPattColor.GetColor();
+ // back color
+ Color aBackColor( GetBackColor() );
+ // set mixed color
+ Color aMixedColor;
+ if( nPattern > 0 )
+ aMixedColor = GetPatternColor( Color(nPatternColor), aBackColor, (sal_uInt32)nPattern );
+ else
+ aMixedColor = GetPatternColor( aBackColor, aBackColor, (sal_uInt32)nPattern );
+ sal_Int32 nMixedColor = aMixedColor.GetColor() & COLORMAST;
+ m_xProps->setPropertyValue( BACKCOLOR , uno::makeAny( nMixedColor ) );
+}
+
+uno::Reference< container::XIndexAccess >
+ScVbaInterior::getPalette()
+{
+ if ( !m_pScDoc )
+ throw uno::RuntimeException();
+ SfxObjectShell* pShell = m_pScDoc->GetDocumentShell();
+ ScVbaPalette aPalette( pShell );
+ return aPalette.getPalette();
+}
+
+void SAL_CALL
+ScVbaInterior::setColorIndex( const css::uno::Any& _colorindex ) throw (css::uno::RuntimeException)
+{
+ sal_Int32 nIndex = 0;
+ _colorindex >>= nIndex;
+
+ // hackly for excel::XlColorIndex::xlColorIndexNone
+ if( nIndex == excel::XlColorIndex::xlColorIndexNone )
+ {
+ m_xProps->setPropertyValue( BACKCOLOR, uno::makeAny( sal_Int32( -1 ) ) );
+ }
+ else
+ {
+ // setColor expects colors in XL RGB values
+ // #FIXME this is daft we convert OO RGB val to XL RGB val and
+ // then back again to OO RGB value
+ setColor( OORGBToXLRGB( GetIndexColor( nIndex ) ) );
+ }
+}
+uno::Any
+ScVbaInterior::GetIndexColor( const sal_Int32& nColorIndex )
+{
+ sal_Int32 nIndex = nColorIndex;
+ // #FIXME xlColorIndexAutomatic & xlColorIndexNone are not really
+ // handled properly here
+ if ( !nIndex || ( nIndex == excel::XlColorIndex::xlColorIndexAutomatic ) || ( nIndex == excel::XlColorIndex::xlColorIndexNone ) )
+ nIndex = 2; // default is white ( this maybe will probably break, e.g. we may at some stage need to know what this interior is, a cell or something else and then pick a default colour based on that )
+ --nIndex; // OOo indices are zero bases
+ uno::Reference< container::XIndexAccess > xIndex = getPalette();
+ return xIndex->getByIndex( nIndex );
+}
+
+sal_Int32
+ScVbaInterior::GetColorIndex( const sal_Int32 nColor )
+{
+ uno::Reference< container::XIndexAccess > xIndex = getPalette();
+ sal_Int32 nElems = xIndex->getCount();
+ sal_Int32 nIndex = -1;
+ for ( sal_Int32 count=0; count<nElems; ++count )
+ {
+ sal_Int32 nPaletteColor = 0;
+ xIndex->getByIndex( count ) >>= nPaletteColor;
+ if ( nPaletteColor == nColor )
+ {
+ nIndex = count + 1; // 1 based
+ break;
+ }
+ }
+ return nIndex;
+}
+
+uno::Any SAL_CALL
+ScVbaInterior::getColorIndex() throw ( css::uno::RuntimeException )
+{
+ sal_Int32 nColor = 0;
+ // hackly for excel::XlColorIndex::xlColorIndexNone
+ uno::Any aColor = m_xProps->getPropertyValue( BACKCOLOR );
+ if( ( aColor >>= nColor ) && ( nColor == -1 ) )
+ {
+ nColor = excel::XlColorIndex::xlColorIndexNone;
+ return uno::makeAny( nColor );
+ }
+
+ // getColor returns Xl ColorValue, need to convert it to OO val
+ // as the palette deals with OO RGB values
+ // #FIXME this is daft in getColor we convert OO RGB val to XL RGB val
+ // and then back again to OO RGB value
+ XLRGBToOORGB( getColor() ) >>= nColor;
+
+ return uno::makeAny( GetColorIndex( nColor ) );
+}
+Color
+ScVbaInterior::GetPatternColor( const Color& rPattColor, const Color& rBackColor, sal_uInt32 nXclPattern )
+{
+ // 0x00 == 0% transparence (full rPattColor)
+ // 0x80 == 100% transparence (full rBackColor)
+ static const sal_uInt8 pnRatioTable[] =
+ {
+ 0x80, 0x00, 0x40, 0x20, 0x60, 0x40, 0x40, 0x40, // 00 - 07
+ 0x40, 0x40, 0x20, 0x60, 0x60, 0x60, 0x60, 0x48, // 08 - 15
+ 0x50, 0x70, 0x78 // 16 - 18
+ };
+ return ( nXclPattern < STATIC_TABLE_SIZE( pnRatioTable ) ) ?
+ GetMixedColor( rPattColor, rBackColor, pnRatioTable[ nXclPattern ] ) : rPattColor;
+}
+Color
+ScVbaInterior::GetMixedColor( const Color& rFore, const Color& rBack, sal_uInt8 nTrans )
+{
+ return Color(
+ nTrans,
+ GetMixedColorComp( rFore.GetRed(), rBack.GetRed(), nTrans ),
+ GetMixedColorComp( rFore.GetGreen(), rBack.GetGreen(), nTrans ),
+ GetMixedColorComp( rFore.GetBlue(), rBack.GetBlue(), nTrans ));
+}
+sal_uInt8
+ScVbaInterior::GetMixedColorComp( sal_uInt8 nFore, sal_uInt8 nBack, sal_uInt8 nTrans )
+{
+ sal_uInt32 nTemp = ((static_cast< sal_Int32 >( nBack ) - nFore) * nTrans) / 0x80 + nFore;
+ return static_cast< sal_uInt8 >( nTemp );
+}
+uno::Reference< container::XNameContainer >
+ScVbaInterior::GetAttributeContainer()
+{
+ return uno::Reference < container::XNameContainer > ( m_xProps->getPropertyValue( rtl::OUString::createFromAscii( "UserDefinedAttributes" ) ), uno::UNO_QUERY_THROW );
+}
+sal_Int32
+ScVbaInterior::GetAttributeData( uno::Any aValue )
+{
+ xml::AttributeData aDataValue;
+ if( aValue >>= aDataValue )
+ {
+ return aDataValue.Value.toInt32();
+ }
+ return sal_Int32( 0 );
+}
+uno::Any
+ScVbaInterior::SetAttributeData( sal_Int32 nValue )
+{
+ xml::AttributeData aAttributeData;
+ //aAttributeData.Namespace = rtl::OUString::createFromAscii( "ooo.vba.excel.CellPatten");
+ aAttributeData.Type = rtl::OUString::createFromAscii( "sal_Int32" );
+ aAttributeData.Value = rtl::OUString::valueOf( nValue );
+ return uno::makeAny( aAttributeData );
+}
+uno::Any
+ScVbaInterior::GetUserDefinedAttributes( const rtl::OUString& sName )
+{
+ uno::Reference< container::XNameContainer > xNameContainer( GetAttributeContainer(), uno::UNO_QUERY_THROW );
+ if( xNameContainer->hasByName( sName ) )
+ {
+ return xNameContainer->getByName( sName );
+ }
+ return uno::Any();
+}
+void
+ScVbaInterior::SetUserDefinedAttributes( const rtl::OUString& sName, const uno::Any& aValue )
+{
+ if( aValue.hasValue() )
+ {
+ uno::Reference< container::XNameContainer > xNameContainer( GetAttributeContainer(), uno::UNO_QUERY_THROW );
+ if( xNameContainer->hasByName( sName ) )
+ xNameContainer->removeByName( sName );
+ xNameContainer->insertByName( sName, aValue );
+ m_xProps->setPropertyValue( rtl::OUString::createFromAscii( "UserDefinedAttributes" ), uno::makeAny( xNameContainer ) );
+ }
+}
+// OOo do not support below API
+uno::Any SAL_CALL
+ScVbaInterior::getPattern() throw (uno::RuntimeException)
+{
+ // XlPattern
+ uno::Any aPattern = GetUserDefinedAttributes( PATTERN );
+ if( aPattern.hasValue() )
+ return uno::makeAny( GetAttributeData( aPattern ) );
+ return uno::makeAny( excel::XlPattern::xlPatternNone );
+}
+void SAL_CALL
+ScVbaInterior::setPattern( const uno::Any& _pattern ) throw (uno::RuntimeException)
+{
+ if( _pattern >>= m_nPattern )
+ {
+ SetUserDefinedAttributes( PATTERN, SetAttributeData( m_nPattern ) );
+ SetMixedColor();
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid Pattern index" ), uno::Reference< uno::XInterface >() );
+}
+Color
+ScVbaInterior::GetBackColor()
+{
+ sal_Int32 nColor = 0;
+ Color aBackColor;
+ uno::Any aColor = GetUserDefinedAttributes( BACKCOLOR );
+ if( aColor.hasValue() )
+ {
+ nColor = GetAttributeData( aColor );
+ aBackColor.SetColor( nColor );
+ }
+ else
+ {
+ uno::Any aAny;
+ aAny = OORGBToXLRGB( m_xProps->getPropertyValue( BACKCOLOR ) );
+ if( aAny >>= nColor )
+ {
+ nColor = XLRGBToOORGB( nColor );
+ aBackColor.SetColor( nColor );
+ SetUserDefinedAttributes( BACKCOLOR, SetAttributeData( nColor ) );
+ }
+ }
+ return aBackColor;
+}
+uno::Any SAL_CALL
+ScVbaInterior::getPatternColor() throw (uno::RuntimeException)
+{
+ // 0 is the default color. no filled.
+ uno::Any aPatternColor = GetUserDefinedAttributes( PATTERNCOLOR );
+ if( aPatternColor.hasValue() )
+ {
+ sal_uInt32 nPatternColor = GetAttributeData( aPatternColor );
+ return uno::makeAny( OORGBToXLRGB( nPatternColor ) );
+ }
+ return uno::makeAny( sal_Int32( 0 ) );
+}
+void SAL_CALL
+ScVbaInterior::setPatternColor( const uno::Any& _patterncolor ) throw (uno::RuntimeException)
+{
+ sal_Int32 nPattColor = 0;
+ if( _patterncolor >>= nPattColor )
+ {
+ SetUserDefinedAttributes( PATTERNCOLOR, SetAttributeData( XLRGBToOORGB( nPattColor ) ) );
+ SetMixedColor();
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid Pattern Color" ), uno::Reference< uno::XInterface >() );
+}
+uno::Any SAL_CALL
+ScVbaInterior::getPatternColorIndex() throw (uno::RuntimeException)
+{
+ sal_Int32 nColor = 0;
+ XLRGBToOORGB( getPatternColor() ) >>= nColor;
+
+ return uno::makeAny( GetIndexColor( nColor ) );
+}
+void SAL_CALL
+ScVbaInterior::setPatternColorIndex( const uno::Any& _patterncolorindex ) throw (uno::RuntimeException)
+{
+ sal_Int32 nColorIndex = 0;
+ if( _patterncolorindex >>= nColorIndex )
+ {
+ if( nColorIndex == 0 )
+ return;
+ sal_Int32 nPattColor = 0;
+ GetIndexColor( nColorIndex ) >>= nPattColor;
+ setPatternColor( uno::makeAny( OORGBToXLRGB( nPattColor ) ) );
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid Pattern Color" ), uno::Reference< uno::XInterface >() );
+}
+
+rtl::OUString&
+ScVbaInterior::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaInterior") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaInterior::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Interior" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbainterior.hxx b/sc/source/ui/vba/vbainterior.hxx
new file mode 100644
index 000000000000..51b06e7d97c4
--- /dev/null
+++ b/sc/source/ui/vba/vbainterior.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_INTERIOR_HXX
+#define SC_VBA_INTERIOR_HXX
+
+#include <ooo/vba/excel/XInterior.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+
+#include <com/sun/star/script/XInvocation.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+#include <tools/color.hxx>
+
+class ScDocument;
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XInterior > ScVbaInterior_BASE;
+
+class ScVbaInterior : public ScVbaInterior_BASE
+{
+ css::uno::Reference< css::beans::XPropertySet > m_xProps;
+ ScDocument* m_pScDoc;
+ Color m_aPattColor;
+ sal_Int32 m_nPattern;
+
+ css::uno::Reference< css::container::XIndexAccess > getPalette();
+ css::uno::Reference< css::container::XNameContainer > GetAttributeContainer();
+ css::uno::Any SetAttributeData( sal_Int32 nValue );
+ sal_Int32 GetAttributeData( css::uno::Any aValue );
+ Color GetBackColor();
+protected:
+ Color GetPatternColor( const Color& rPattColor, const Color& rBackColor, sal_uInt32 nXclPattern );
+ Color GetMixedColor( const Color& rFore, const Color& rBack, sal_uInt8 nTrans );
+ sal_uInt8 GetMixedColorComp( sal_uInt8 nFore, sal_uInt8 nBack, sal_uInt8 nTrans );
+ css::uno::Any GetIndexColor( const sal_Int32& nColorIndex );
+ sal_Int32 GetColorIndex( const sal_Int32 nColor );
+ css::uno::Any GetUserDefinedAttributes( const rtl::OUString& sName );
+ void SetUserDefinedAttributes( const rtl::OUString& sName, const css::uno::Any& aValue );
+ void SetMixedColor();
+public:
+ ScVbaInterior( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::beans::XPropertySet >& xProps, ScDocument* pScDoc = NULL) throw ( css::lang::IllegalArgumentException);
+
+ virtual ~ScVbaInterior(){}
+
+ virtual css::uno::Any SAL_CALL getColor() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setColor( const css::uno::Any& _color ) throw (css::uno::RuntimeException) ;
+
+ virtual css::uno::Any SAL_CALL getColorIndex() throw ( css::uno::RuntimeException);
+ virtual void SAL_CALL setColorIndex( const css::uno::Any& _colorindex ) throw ( css::uno::RuntimeException );
+ virtual css::uno::Any SAL_CALL getPattern() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPattern( const css::uno::Any& _pattern ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getPatternColor() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPatternColor( const css::uno::Any& _patterncolor ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getPatternColorIndex() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPatternColorIndex( const css::uno::Any& _patterncolorindex ) throw (css::uno::RuntimeException);
+ //XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenu.cxx b/sc/source/ui/vba/vbamenu.cxx
new file mode 100644
index 000000000000..ae6d4e4b1223
--- /dev/null
+++ b/sc/source/ui/vba/vbamenu.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "vbamenu.hxx"
+#include "vbamenuitems.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaMenu::ScVbaMenu( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBarControl >& xCommandBarControl ) throw( uno::RuntimeException ) : Menu_BASE( xParent, xContext ), m_xCommandBarControl( xCommandBarControl )
+{
+}
+
+::rtl::OUString SAL_CALL
+ScVbaMenu::getCaption() throw ( uno::RuntimeException )
+{
+ return m_xCommandBarControl->getCaption();
+}
+
+void SAL_CALL
+ScVbaMenu::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
+{
+ m_xCommandBarControl->setCaption( _caption );
+}
+
+void SAL_CALL
+ScVbaMenu::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ m_xCommandBarControl->Delete();
+}
+
+uno::Any SAL_CALL
+ScVbaMenu::MenuItems( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< XCommandBarControls > xCommandBarControls( m_xCommandBarControl->Controls( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenuItems > xMenuItems( new ScVbaMenuItems( this, mxContext, xCommandBarControls ) );
+ if( aIndex.hasValue() )
+ {
+ return xMenuItems->Item( aIndex, uno::Any() );
+ }
+ return uno::makeAny( xMenuItems );
+}
+
+rtl::OUString&
+ScVbaMenu::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenu") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenu::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Menu" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenu.hxx b/sc/source/ui/vba/vbamenu.hxx
new file mode 100644
index 000000000000..3141b5718447
--- /dev/null
+++ b/sc/source/ui/vba/vbamenu.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef SC_VBA_MENU_HXX
+#define SC_VBA_MENU_HXX
+
+#include <ooo/vba/excel/XMenu.hpp>
+#include <ooo/vba/XCommandBarControl.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XMenu > Menu_BASE;
+
+class ScVbaMenu : public Menu_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControl > m_xCommandBarControl;
+
+public:
+ ScVbaMenu( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< ov::XCommandBarControl >& xCommandBarControl ) throw( css::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL MenuItems( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif//SC_VBA_MENU_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenubar.cxx b/sc/source/ui/vba/vbamenubar.cxx
new file mode 100644
index 000000000000..1ad19a6a3b51
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubar.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "vbamenubar.hxx"
+#include "vbamenus.hxx"
+#include <ooo/vba/XCommandBarControls.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaMenuBar::ScVbaMenuBar( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBar >& xCommandBar ) throw( uno::RuntimeException ) : MenuBar_BASE( xParent, xContext ), m_xCommandBar( xCommandBar )
+{
+}
+
+uno::Any SAL_CALL
+ScVbaMenuBar::Menus( const uno::Any& aIndex ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< XCommandBarControls > xCommandBarControls( m_xCommandBar->Controls( uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenus > xMenus( new ScVbaMenus( this, mxContext, xCommandBarControls ) );
+ if( aIndex.hasValue() )
+ {
+ return xMenus->Item( aIndex, uno::Any() );
+ }
+ return uno::makeAny( xMenus );
+}
+
+rtl::OUString&
+ScVbaMenuBar::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuBar") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuBar::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuBar" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenubar.hxx b/sc/source/ui/vba/vbamenubar.hxx
new file mode 100644
index 000000000000..15253d4e73cb
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubar.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef SC_VBA_MENUBAR_HXX
+#define SC_VBA_MENUBAR_HXX
+
+#include <ooo/vba/excel/XMenuBar.hpp>
+#include <ooo/vba/XCommandBar.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XMenuBar > MenuBar_BASE;
+
+class ScVbaMenuBar : public MenuBar_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBar > m_xCommandBar;
+
+public:
+ ScVbaMenuBar( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< ov::XCommandBar >& xCommandBar ) throw( css::uno::RuntimeException );
+
+ virtual css::uno::Any SAL_CALL Menus( const css::uno::Any& aIndex ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif//SC_VBA_MENUBAR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenubars.cxx b/sc/source/ui/vba/vbamenubars.cxx
new file mode 100644
index 000000000000..4dfaefcddda4
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubars.cxx
@@ -0,0 +1,140 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "vbamenubars.hxx"
+#include "vbamenubar.hxx"
+#include <ooo/vba/excel/XlSheetType.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuBarEnumeration_BASE;
+
+class MenuBarEnumeration : public MenuBarEnumeration_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< container::XEnumeration > m_xEnumeration;
+public:
+ MenuBarEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
+ {
+ }
+ virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+ {
+ return m_xEnumeration->hasMoreElements();
+ }
+ virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ // FIXME: should be add menubar
+ if( hasMoreElements() )
+ {
+ uno::Reference< XCommandBar > xCommandBar( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( m_xParent, m_xContext, xCommandBar ) );
+ return uno::makeAny( xMenuBar );
+ }
+ else
+ throw container::NoSuchElementException();
+ return uno::Any();
+ }
+};
+
+ScVbaMenuBars::ScVbaMenuBars( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBars >& xCommandBars ) throw ( uno::RuntimeException ) : MenuBars_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBars( xCommandBars )
+{
+}
+
+ScVbaMenuBars::~ScVbaMenuBars()
+{
+}
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaMenuBars::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XMenuBar::static_type( 0 );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaMenuBars::createEnumeration() throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBars, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XEnumeration >( new MenuBarEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
+}
+
+uno::Any
+ScVbaMenuBars::createCollectionObject( const uno::Any& aSource )
+{
+ // make no sense
+ return aSource;
+}
+
+sal_Int32 SAL_CALL
+ScVbaMenuBars::getCount() throw(css::uno::RuntimeException)
+{
+ return m_xCommandBars->getCount();
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaMenuBars::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
+{
+ sal_Int16 nIndex = 0;
+ aIndex >>= nIndex;
+ if( nIndex == excel::XlSheetType::xlWorksheet )
+ {
+ uno::Any aSource;
+ aSource <<= rtl::OUString::createFromAscii( "Worksheet Menu Bar" );
+ uno::Reference< XCommandBar > xCommandBar( m_xCommandBars->Item( aSource, uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XMenuBar > xMenuBar( new ScVbaMenuBar( this, mxContext, xCommandBar ) );
+ return uno::makeAny( xMenuBar );
+ }
+
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+
+ return uno::Any();
+}
+
+// XHelperInterface
+rtl::OUString&
+ScVbaMenuBars::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuBars") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuBars::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuBars" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenubars.hxx b/sc/source/ui/vba/vbamenubars.hxx
new file mode 100644
index 000000000000..2579eb74f8aa
--- /dev/null
+++ b/sc/source/ui/vba/vbamenubars.hxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef SC_VBA_MENUBARS_HXX
+#define SC_VBA_MENUBARS_HXX
+
+#include <ooo/vba/excel/XMenuBars.hpp>
+#include <ooo/vba/excel/XMenuBar.hpp>
+#include <ooo/vba/XCommandBars.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XMenuBars > MenuBars_BASE;
+
+class ScVbaMenuBars : public MenuBars_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBars > m_xCommandBars;
+
+public:
+ ScVbaMenuBars( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< ov::XCommandBars >& xCommandBars ) throw (css::uno::RuntimeException);
+ virtual ~ScVbaMenuBars();
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& aIndex, const css::uno::Any& /*aIndex2*/ ) throw( css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_MENUBARS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenuitem.cxx b/sc/source/ui/vba/vbamenuitem.cxx
new file mode 100644
index 000000000000..8843544f31f0
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitem.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "vbamenuitem.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaMenuItem::ScVbaMenuItem( const uno::Reference< ov::XHelperInterface > xParent, const uno::Reference< uno::XComponentContext > xContext, const uno::Reference< XCommandBarControl >& xCommandBarControl ) throw( uno::RuntimeException ) : MenuItem_BASE( xParent, xContext ), m_xCommandBarControl( xCommandBarControl )
+{
+}
+
+::rtl::OUString SAL_CALL
+ScVbaMenuItem::getCaption() throw ( uno::RuntimeException )
+{
+ return m_xCommandBarControl->getCaption();
+}
+
+void SAL_CALL
+ScVbaMenuItem::setCaption( const ::rtl::OUString& _caption ) throw (uno::RuntimeException)
+{
+ m_xCommandBarControl->setCaption( _caption );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaMenuItem::getOnAction() throw ( uno::RuntimeException )
+{
+ return m_xCommandBarControl->getOnAction();
+}
+
+void SAL_CALL
+ScVbaMenuItem::setOnAction( const ::rtl::OUString& _onaction ) throw (uno::RuntimeException)
+{
+ m_xCommandBarControl->setOnAction( _onaction );
+}
+
+void SAL_CALL
+ScVbaMenuItem::Delete( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ m_xCommandBarControl->Delete();
+}
+
+rtl::OUString&
+ScVbaMenuItem::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuItem") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuItem::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuItem" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenuitem.hxx b/sc/source/ui/vba/vbamenuitem.hxx
new file mode 100644
index 000000000000..5c22b3409a28
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitem.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef SC_VBA_MENUITEM_HXX
+#define SC_VBA_MENUITEM_HXX
+
+#include <ooo/vba/excel/XMenuItem.hpp>
+#include <ooo/vba/XCommandBarControl.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XMenuItem > MenuItem_BASE;
+
+class ScVbaMenuItem : public MenuItem_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControl > m_xCommandBarControl;
+
+public:
+ ScVbaMenuItem( const css::uno::Reference< ov::XHelperInterface > xParent, const css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< ov::XCommandBarControl >& xCommandBarControl ) throw( css::uno::RuntimeException );
+
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& _caption ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setOnAction( const ::rtl::OUString& _onaction ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Delete( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif//SC_VBA_MENUITEM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenuitems.cxx b/sc/source/ui/vba/vbamenuitems.cxx
new file mode 100644
index 000000000000..5722830fce0a
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitems.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "vbamenuitems.hxx"
+#include "vbamenuitem.hxx"
+#include "vbamenu.hxx"
+#include <ooo/vba/office/MsoControlType.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuEnumeration_BASE;
+
+class MenuEnumeration : public MenuEnumeration_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< container::XEnumeration > m_xEnumeration;
+public:
+ MenuEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
+ {
+ }
+ virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+ {
+ return m_xEnumeration->hasMoreElements();
+ }
+ virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ // FIXME: should be add menu
+ if( hasMoreElements() )
+ {
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
+ {
+ uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) );
+ return uno::makeAny( xMenu );
+ }
+ else if( xCommandBarControl->getType() == office::MsoControlType::msoControlButton )
+ {
+ uno::Reference< excel::XMenuItem > xMenuItem( new ScVbaMenuItem( m_xParent, m_xContext, xCommandBarControl ) );
+ return uno::makeAny( xMenuItem );
+ }
+ nextElement();
+ }
+ else
+ throw container::NoSuchElementException();
+ return uno::Any();
+ }
+};
+
+ScVbaMenuItems::ScVbaMenuItems( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBarControls >& xCommandBarControls ) throw ( uno::RuntimeException ) : MenuItems_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBarControls( xCommandBarControls )
+{
+}
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaMenuItems::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XMenuItem::static_type( 0 );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaMenuItems::createEnumeration() throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBarControls, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XEnumeration >( new MenuEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
+}
+
+uno::Any
+ScVbaMenuItems::createCollectionObject( const uno::Any& aSource )
+{
+ // make no sense
+ return aSource;
+}
+
+sal_Int32 SAL_CALL
+ScVbaMenuItems::getCount() throw(css::uno::RuntimeException)
+{
+ // FIXME: should check if it is a popup menu
+ return m_xCommandBarControls->getCount();
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaMenuItems::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
+{
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
+ return uno::makeAny( uno::Reference< excel::XMenu > ( new ScVbaMenu( this, mxContext, xCommandBarControl ) ) );
+ else if( xCommandBarControl->getType() == office::MsoControlType::msoControlButton )
+ return uno::makeAny( uno::Reference< excel::XMenuItem > ( new ScVbaMenuItem( this, mxContext, xCommandBarControl ) ) );
+ throw uno::RuntimeException();
+}
+
+uno::Reference< excel::XMenuItem > SAL_CALL ScVbaMenuItems::Add( const rtl::OUString& Caption, const css::uno::Any& OnAction, const css::uno::Any& /*ShortcutKey*/, const css::uno::Any& Before, const css::uno::Any& Restore, const css::uno::Any& /*StatusBar*/, const css::uno::Any& /*HelpFile*/, const css::uno::Any& /*HelpContextID*/ ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ sal_Int32 nType = office::MsoControlType::msoControlButton;
+ uno::Reference< XCommandBarControl > xCommandBarControl = m_xCommandBarControls->Add( uno::makeAny( nType ), uno::Any(), uno::Any(), Before, Restore );
+ xCommandBarControl->setCaption( Caption );
+ if( OnAction.hasValue() )
+ {
+ rtl::OUString sAction;
+ OnAction >>= sAction;
+ xCommandBarControl->setOnAction( sAction );
+ }
+ return uno::Reference< excel::XMenuItem >( new ScVbaMenuItem( this, mxContext, xCommandBarControl ) );
+}
+
+// XHelperInterface
+rtl::OUString&
+ScVbaMenuItems::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenuItems") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenuItems::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.MenuItems" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenuitems.hxx b/sc/source/ui/vba/vbamenuitems.hxx
new file mode 100644
index 000000000000..8a8dd6021b2d
--- /dev/null
+++ b/sc/source/ui/vba/vbamenuitems.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef SC_VBA_MENUITEMS_HXX
+#define SC_VBA_MENUITEMS_HXX
+
+#include <ooo/vba/excel/XMenuItems.hpp>
+#include <ooo/vba/excel/XMenuItem.hpp>
+#include <ooo/vba/XCommandBarControls.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XMenuItems > MenuItems_BASE;
+
+class ScVbaMenuItems : public MenuItems_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControls > m_xCommandBarControls;
+
+public:
+ ScVbaMenuItems( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< ov::XCommandBarControls >& xCommandBarControls ) throw( css::uno::RuntimeException );
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // Methods
+ virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XMenuItem > SAL_CALL Add( const rtl::OUString& Caption, const css::uno::Any& OnAction, const css::uno::Any& ShortcutKey, const css::uno::Any& Before, const css::uno::Any& Restore, const css::uno::Any& StatusBar, const css::uno::Any& HelpFile, const css::uno::Any& HelpContextID ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_MENUITEMS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenus.cxx b/sc/source/ui/vba/vbamenus.cxx
new file mode 100644
index 000000000000..e604d7b59242
--- /dev/null
+++ b/sc/source/ui/vba/vbamenus.cxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#include "vbamenus.hxx"
+#include "vbamenu.hxx"
+#include <ooo/vba/office/MsoControlType.hpp>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > MenuEnumeration_BASE;
+
+class MenuEnumeration : public MenuEnumeration_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< container::XEnumeration > m_xEnumeration;
+public:
+ MenuEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration )
+ {
+ }
+ virtual sal_Bool SAL_CALL hasMoreElements() throw ( uno::RuntimeException )
+ {
+ return m_xEnumeration->hasMoreElements();
+ }
+ virtual uno::Any SAL_CALL nextElement() throw ( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ // FIXME: should be add menu
+ if( hasMoreElements() )
+ {
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() == office::MsoControlType::msoControlPopup )
+ {
+ uno::Reference< excel::XMenu > xMenu( new ScVbaMenu( m_xParent, m_xContext, xCommandBarControl ) );
+ return uno::makeAny( xMenu );
+ }
+ nextElement();
+ }
+ else
+ throw container::NoSuchElementException();
+ return uno::Any();
+ }
+};
+
+ScVbaMenus::ScVbaMenus( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCommandBarControls >& xCommandBarControls ) throw ( uno::RuntimeException ) : Menus_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() ), m_xCommandBarControls( xCommandBarControls )
+{
+}
+
+// XEnumerationAccess
+uno::Type SAL_CALL
+ScVbaMenus::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XMenu::static_type( 0 );
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaMenus::createEnumeration() throw ( uno::RuntimeException )
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xCommandBarControls, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XEnumeration >( new MenuEnumeration( this, mxContext, xEnumAccess->createEnumeration() ) );
+}
+
+uno::Any
+ScVbaMenus::createCollectionObject( const uno::Any& aSource )
+{
+ // make no sense
+ return aSource;
+}
+
+sal_Int32 SAL_CALL
+ScVbaMenus::getCount() throw(css::uno::RuntimeException)
+{
+ // FIXME: should check if it is a popup menu
+ return m_xCommandBarControls->getCount();
+}
+
+// ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaMenus::Item( const uno::Any& aIndex, const uno::Any& /*aIndex2*/ ) throw( uno::RuntimeException )
+{
+ uno::Reference< XCommandBarControl > xCommandBarControl( m_xCommandBarControls->Item( aIndex, uno::Any() ), uno::UNO_QUERY_THROW );
+ if( xCommandBarControl->getType() != office::MsoControlType::msoControlPopup )
+ throw uno::RuntimeException();
+ return uno::makeAny( uno::Reference< excel::XMenu > ( new ScVbaMenu( this, mxContext, xCommandBarControl ) ) );
+}
+
+uno::Reference< excel::XMenu > SAL_CALL ScVbaMenus::Add( const rtl::OUString& Caption, const css::uno::Any& Before, const css::uno::Any& Restore ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ sal_Int32 nType = office::MsoControlType::msoControlPopup;
+ uno::Reference< XCommandBarControl > xCommandBarControl = m_xCommandBarControls->Add( uno::makeAny( nType ), uno::Any(), uno::Any(), Before, Restore );
+ xCommandBarControl->setCaption( Caption );
+ return uno::Reference< excel::XMenu >( new ScVbaMenu( this, mxContext, xCommandBarControl ) );
+}
+
+// XHelperInterface
+rtl::OUString&
+ScVbaMenus::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaMenus") );
+ return sImplName;
+}
+uno::Sequence<rtl::OUString>
+ScVbaMenus::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Menus" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbamenus.hxx b/sc/source/ui/vba/vbamenus.hxx
new file mode 100644
index 000000000000..a85e73bdb394
--- /dev/null
+++ b/sc/source/ui/vba/vbamenus.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Pei Feng Lin <pflin@novell.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+#ifndef SC_VBA_MENUS_HXX
+#define SC_VBA_MENUS_HXX
+
+#include <ooo/vba/excel/XMenus.hpp>
+#include <ooo/vba/excel/XMenu.hpp>
+#include <ooo/vba/XCommandBarControls.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XMenus > Menus_BASE;
+
+class ScVbaMenus : public Menus_BASE
+{
+private:
+ css::uno::Reference< ov::XCommandBarControls > m_xCommandBarControls;
+
+public:
+ ScVbaMenus( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< ov::XCommandBarControls >& xCommandBarControls ) throw( css::uno::RuntimeException );
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // Methods
+ virtual sal_Int32 SAL_CALL getCount() throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index, const css::uno::Any& /*Index2*/ ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XMenu > SAL_CALL Add( const rtl::OUString& Caption, const css::uno::Any& Before, const css::uno::Any& Restore ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif//SC_VBA_MENUS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx
new file mode 100644
index 000000000000..37170f60bb39
--- /dev/null
+++ b/sc/source/ui/vba/vbaname.cxx
@@ -0,0 +1,234 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+
+#include "vbaname.hxx"
+#include "vbarange.hxx"
+#include "vbaglobals.hxx"
+#include <vector>
+#include <rangenam.hxx>
+#include <vcl/msgbox.hxx>
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaName::ScVbaName(const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::sheet::XNamedRange >& xName,
+ const css::uno::Reference< css::sheet::XNamedRanges >& xNames,
+ const css::uno::Reference< css::frame::XModel >& xModel ):
+ NameImpl_BASE( xParent , xContext ),
+ mxModel( xModel ),
+ mxNamedRange( xName ),
+ mxNames( xNames )
+{
+}
+
+ScVbaName::~ScVbaName()
+{
+}
+
+css::uno::Reference< ov::excel::XWorksheet >
+ScVbaName::getWorkSheet() throw (css::uno::RuntimeException)
+{
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ return xApplication->getActiveSheet();
+}
+
+::rtl::OUString
+ScVbaName::getName() throw (css::uno::RuntimeException)
+{
+ String sName;
+ //sName += UniString( getWorkSheet()->getName()); //liuchen 2009-9-9 resolve the defect that the name get by macro code are not the same with that in UI (for example, if a name of "AA" is found in the UI "Define Names" dialog box, the result of get that name through macro code will be "Sheet1!AA")
+ //sName += String::CreateFromAscii("!");
+ sName += UniString ( mxNamedRange->getName() );
+ return ::rtl::OUString( sName );
+}
+
+void
+ScVbaName::setName( const ::rtl::OUString & rName ) throw (css::uno::RuntimeException)
+{
+ mxNamedRange->setName( rName );
+}
+
+::rtl::OUString
+ScVbaName::getNameLocal() throw (css::uno::RuntimeException)
+{
+ return getName();
+}
+
+void
+ScVbaName::setNameLocal( const ::rtl::OUString & rName ) throw (css::uno::RuntimeException)
+{
+ setName( rName );
+}
+
+sal_Bool
+ScVbaName::getVisible() throw (css::uno::RuntimeException)
+{
+ return true;
+}
+
+void
+ScVbaName::setVisible( sal_Bool /*bVisible*/ ) throw (css::uno::RuntimeException)
+{
+}
+
+::rtl::OUString
+ScVbaName::getValue() throw (css::uno::RuntimeException)
+{
+ return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
+}
+
+::rtl::OUString
+ScVbaName::getValue(const formula::FormulaGrammar::Grammar eGrammar) throw (css::uno::RuntimeException)
+{
+ rtl::OUString sValue = mxNamedRange->getContent();
+ ScDocShell* pDocShell = excel::getDocShell( mxModel );
+ ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
+ String aContent;
+ excel::CompileODFFormulaToExcel( pDoc, sValue, aContent, eGrammar );
+ if ( aContent.Len() > 0 )
+ {
+ sValue = aContent;
+ }
+ if ( sValue.indexOf('=') != 0 )
+ {
+ sValue = rtl::OUString::createFromAscii("=") + sValue;
+ }
+ return sValue;
+}
+
+void
+ScVbaName::setValue( const ::rtl::OUString & rValue ) throw (css::uno::RuntimeException)
+{
+ ::rtl::OUString sValue = rValue;
+ ScDocShell* pDocShell = excel::getDocShell( mxModel );
+ ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
+ String aContent;
+ excel::CompileExcelFormulaToODF( pDoc, sValue, aContent );
+ if ( aContent.Len() > 0 )
+ {
+ sValue = aContent;
+ }
+ mxNamedRange->setContent( sValue );
+}
+
+::rtl::OUString
+ScVbaName::getRefersTo() throw (css::uno::RuntimeException)
+{
+ return getValue();
+}
+
+void
+ScVbaName::setRefersTo( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
+{
+ setValue( rRefersTo );
+}
+
+::rtl::OUString
+ScVbaName::getRefersToLocal() throw (css::uno::RuntimeException)
+{
+ return getRefersTo();
+}
+
+void
+ScVbaName::setRefersToLocal( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
+{
+ setRefersTo( rRefersTo );
+}
+
+::rtl::OUString
+ScVbaName::getRefersToR1C1() throw (css::uno::RuntimeException)
+{
+ return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+}
+
+void
+ScVbaName::setRefersToR1C1( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
+{
+ setRefersTo( rRefersTo );
+}
+
+::rtl::OUString
+ScVbaName::getRefersToR1C1Local() throw (css::uno::RuntimeException)
+{
+ return getValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+}
+
+void
+ScVbaName::setRefersToR1C1Local( const ::rtl::OUString & rRefersTo ) throw (css::uno::RuntimeException)
+{
+ setRefersTo( rRefersTo );
+}
+
+css::uno::Reference< ov::excel::XRange >
+ScVbaName::getRefersToRange() throw (css::uno::RuntimeException)
+{
+ uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName(
+ mxContext, mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 );
+ return xRange;
+}
+
+void
+ScVbaName::setRefersToRange( const css::uno::Reference< ov::excel::XRange > /*rRange*/ ) throw (css::uno::RuntimeException)
+{
+}
+
+void
+ScVbaName::Delete() throw (css::uno::RuntimeException)
+{
+ mxNames->removeByName( mxNamedRange->getName() );
+}
+
+rtl::OUString&
+ScVbaName::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaName") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaName::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Name" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaname.hxx b/sc/source/ui/vba/vbaname.hxx
new file mode 100644
index 000000000000..4ef4b3a13a39
--- /dev/null
+++ b/sc/source/ui/vba/vbaname.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_NAME_HXX
+#define SC_VBA_NAME_HXX
+
+#include <ooo/vba/excel/XName.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+
+#include <formula/grammar.hxx>
+
+class ScDocument;
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XName > NameImpl_BASE;
+
+class ScVbaName : public NameImpl_BASE
+{
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::sheet::XNamedRange > mxNamedRange;
+ css::uno::Reference< css::sheet::XNamedRanges > mxNames;
+
+ ScDocument * m_pDoc;
+
+protected:
+ virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; }
+ virtual css::uno::Reference< ov::excel::XWorksheet > getWorkSheet() throw (css::uno::RuntimeException);
+ // Get value by FormulaGrammar, such as FormulaGrammar::GRAM_NATIVE_XL_R1C1
+ virtual ::rtl::OUString SAL_CALL getValue(const formula::FormulaGrammar::Grammar eGrammar) throw (css::uno::RuntimeException);
+
+public:
+ ScVbaName( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XNamedRange >& xName , const css::uno::Reference< css::sheet::XNamedRanges >& xNames , const css::uno::Reference< css::frame::XModel >& xModel );
+ virtual ~ScVbaName();
+
+ // Attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString &rName ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameLocal() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setNameLocal( const ::rtl::OUString &rName ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getValue() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::rtl::OUString &rValue ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRefersTo() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRefersTo( const ::rtl::OUString &rRefersTo ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRefersToLocal() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRefersToLocal( const ::rtl::OUString &rRefersTo ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRefersToR1C1() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRefersToR1C1( const ::rtl::OUString &rRefersTo ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getRefersToR1C1Local() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRefersToR1C1Local( const ::rtl::OUString &rRefersTo ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getRefersToRange() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRefersToRange( const css::uno::Reference< ov::excel::XRange > xRange ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SC_VBA_NAME_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx
new file mode 100644
index 000000000000..bee4fbb58856
--- /dev/null
+++ b/sc/source/ui/vba/vbanames.cxx
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+
+#include "vbanames.hxx"
+#include "vbaname.hxx"
+#include "vbarange.hxx"
+#include "vbaglobals.hxx"
+#include <vector>
+#include <rangenam.hxx>
+#include <vcl/msgbox.hxx>
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class NamesEnumeration : public EnumerationHelperImpl
+{
+ uno::Reference< frame::XModel > m_xModel;
+ uno::WeakReference< XHelperInterface > m_xParent;
+ uno::Reference< sheet::XNamedRanges > m_xNames;
+public:
+ NamesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel , const uno::Reference< sheet::XNamedRanges >& xNames ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ), m_xNames( xNames ) {}
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ uno::Reference< sheet::XNamedRange > xNamed( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< excel::XName > ( new ScVbaName( m_xParent, m_xContext, xNamed ,m_xNames , m_xModel ) ) );
+ }
+
+};
+
+
+ScVbaNames::ScVbaNames(const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::sheet::XNamedRanges >& xNames,
+ const css::uno::Reference< css::frame::XModel >& xModel ):
+ ScVbaNames_BASE( xParent , xContext , uno::Reference< container::XIndexAccess >( xNames, uno::UNO_QUERY ) ),
+ mxModel( xModel ),
+ mxNames( xNames )
+{
+ m_xNameAccess.set( xNames, uno::UNO_QUERY_THROW );
+}
+
+ScVbaNames::~ScVbaNames()
+{
+}
+
+ScDocument *
+ScVbaNames::getScDocument()
+{
+ uno::Reference< frame::XModel > xModel( getModel() , uno::UNO_QUERY_THROW );
+ ScTabViewShell * pTabViewShell = excel::getBestViewShell( xModel );
+ if ( !pTabViewShell )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewShell available"), uno::Reference< uno::XInterface >() );
+ ScViewData* pViewData = pTabViewShell->GetViewData();
+ if ( !pViewData )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No ViewData available"), uno::Reference< uno::XInterface >() );
+ return pViewData->GetDocument();
+}
+
+void GetRangeOrRefersTo( const css::uno::Any& RefersTo, const uno::Reference< uno::XComponentContext >& xContext, css::uno::Reference< excel::XRange >& xRange, rtl::OUString& sRefersTo )
+{
+ if ( RefersTo.getValueTypeClass() == uno::TypeClass_STRING )
+ {
+ RefersTo >>= sRefersTo;
+ }
+ else if ( RefersTo.getValueTypeClass() == uno::TypeClass_INTERFACE )
+ {
+ RefersTo >>= xRange;
+ }
+ else if ( RefersTo.hasValue() )
+ {
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( xContext );
+ try
+ {
+ if ( xConverter.is() )
+ {
+ uno::Any aConverted = xConverter->convertTo( RefersTo, getCppuType((rtl::OUString*)0) );
+ aConverted >>= sRefersTo;
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+css::uno::Any
+ScVbaNames::Add( const css::uno::Any& Name ,
+ const css::uno::Any& RefersTo,
+ const css::uno::Any& /*Visible*/,
+ const css::uno::Any& /*MacroType*/,
+ const css::uno::Any& /*ShoutcutKey*/,
+ const css::uno::Any& /*Category*/,
+ const css::uno::Any& NameLocal,
+ const css::uno::Any& /*RefersToLocal*/,
+ const css::uno::Any& /*CategoryLocal*/,
+ const css::uno::Any& RefersToR1C1,
+ const css::uno::Any& RefersToR1C1Local ) throw (css::uno::RuntimeException)
+{
+ rtl::OUString sSheetName;
+ rtl::OUString sName;
+ rtl::OUString sRefersTo;
+ uno::Reference< excel::XRange > xRange;
+ if ( Name.hasValue() )
+ Name >>= sName;
+ else if ( NameLocal.hasValue() )
+ NameLocal >>= sName;
+ if ( sName.getLength() != 0 )
+ {
+ sal_Int32 nTokenIndex = sName.indexOf('!');
+ if ( nTokenIndex >= 0 )
+ {
+ sSheetName = sName.copy( 0, nTokenIndex );
+ sName = sName.copy( nTokenIndex + 1 );
+ }
+ if ( !ScRangeData::IsNameValid( sName , getScDocument() ) )
+ {
+ ::rtl::OUString sResult ;
+ sal_Int32 nToken = 0;
+ sal_Int32 nIndex = 0;
+ sResult = sName.getToken( nToken , '!' , nIndex );
+ if ( -1 == nIndex )
+ sResult = sName;
+ else
+ sResult = sName.copy( nIndex );
+ sName = sResult ;
+ if ( !ScRangeData::IsNameValid( sName , getScDocument() ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("This Name is a invalid ."), uno::Reference< uno::XInterface >() );
+ }
+ }
+ if ( RefersTo.hasValue() || RefersToR1C1.hasValue() || RefersToR1C1Local.hasValue() )
+ {
+ if ( RefersTo.hasValue() )
+ GetRangeOrRefersTo( RefersTo, mxContext, xRange, sRefersTo );
+ if ( RefersToR1C1.hasValue() )
+ GetRangeOrRefersTo( RefersToR1C1, mxContext, xRange, sRefersTo );
+ if ( RefersToR1C1Local.hasValue() )
+ GetRangeOrRefersTo( RefersToR1C1Local, mxContext, xRange, sRefersTo );
+ }
+
+ String aContent;
+ table::CellAddress aPosition;
+ RangeType nType = RT_NAME;
+ if ( xRange.is() )
+ {
+ ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
+ uno::Reference< table::XCellRange > thisRange ;
+ uno::Any xAny = pRange->getCellRange() ;
+ if ( xAny.hasValue() )
+ xAny >>= thisRange;
+ uno::Reference< sheet::XCellRangeAddressable > thisRangeAdd( thisRange, ::uno::UNO_QUERY_THROW);
+ table::CellRangeAddress aAddr = thisRangeAdd->getRangeAddress();
+ ScAddress aPos( static_cast< SCCOL >( aAddr.StartColumn ) , static_cast< SCROW >( aAddr.StartRow ) , static_cast< SCTAB >(aAddr.Sheet ) );
+ uno::Any xAny2 ;
+ String sRangeAdd = xRange->Address( xAny2, xAny2 , xAny2 , xAny2, xAny2 );
+ aContent += String::CreateFromAscii("$");
+ aContent += UniString(xRange->getWorksheet()->getName());
+ aContent += String::CreateFromAscii(".");
+ aContent += sRangeAdd;
+ aPosition = table::CellAddress( aAddr.Sheet , aAddr.StartColumn , aAddr.StartRow );
+ }
+ else
+ {
+ ScDocShell* pDocShell = excel::getDocShell( mxModel );
+ ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
+ excel::CompileExcelFormulaToODF( pDoc, sRefersTo, aContent );
+ if ( aContent.Len() == 0 )
+ {
+ aContent = sRefersTo;
+ }
+ }
+
+ uno::Reference< sheet::XNamedRange > xNewNamedRange;
+ if ( mxNames.is() )
+ {
+ if ( mxNames->hasByName( sName ) )
+ {
+ mxNames->removeByName( sName );
+ }
+ mxNames->addNewByName( sName, rtl::OUString( aContent ), aPosition, (sal_Int32) nType );
+ xNewNamedRange = uno::Reference< sheet::XNamedRange >( mxNames->getByName( sName ), uno::UNO_QUERY );
+ }
+ if ( xNewNamedRange.is() )
+ {
+ return uno::makeAny( uno::Reference< excel::XName >( new ScVbaName( mxParent, mxContext, xNewNamedRange ,mxNames , mxModel ) ) );
+ }
+ return css::uno::Any();
+}
+
+// XEnumerationAccess
+css::uno::Type
+ScVbaNames::getElementType() throw( css::uno::RuntimeException )
+{
+ return ov::excel::XName::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaNames::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( mxNames, uno::UNO_QUERY_THROW );
+ return new NamesEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel , mxNames );
+}
+
+uno::Any
+ScVbaNames::createCollectionObject( const uno::Any& aSource )
+{
+ uno::Reference< sheet::XNamedRange > xName( aSource, uno::UNO_QUERY );
+ return uno::makeAny( uno::Reference< excel::XName > ( new ScVbaName( getParent(), mxContext, xName, mxNames , mxModel ) ) );
+}
+
+rtl::OUString&
+ScVbaNames::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaNames") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaNames::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.NamedRanges" ) );
+ }
+ return aServiceNames;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbanames.hxx b/sc/source/ui/vba/vbanames.hxx
new file mode 100644
index 000000000000..de9b2d862e56
--- /dev/null
+++ b/sc/source/ui/vba/vbanames.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_NAMES_HXX
+#define SC_VBA_NAMES_HXX
+
+#include <ooo/vba/excel/XNames.hpp>
+#include <ooo/vba/XCollection.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+class ScDocument;
+class ScDocShell;
+
+typedef CollTestImplHelper< ov::excel::XNames > ScVbaNames_BASE;
+
+class ScVbaNames : public ScVbaNames_BASE
+{
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::sheet::XNamedRanges > mxNames;
+
+protected:
+ virtual css::uno::Reference< css::frame::XModel > getModel() { return mxModel; }
+
+public:
+ ScVbaNames( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XNamedRanges >& xNames , const css::uno::Reference< css::frame::XModel >& xModel );
+
+ ScDocument* getScDocument();
+ ScDocShell* getScDocShell();
+
+ virtual ~ScVbaNames();
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& aName ,
+ const css::uno::Any& aRefersTo,
+ const css::uno::Any& aVisible,
+ const css::uno::Any& aMacroType,
+ const css::uno::Any& aShoutcutKey,
+ const css::uno::Any& aCategory,
+ const css::uno::Any& aNameLocal,
+ const css::uno::Any& aRefersToLocal,
+ const css::uno::Any& aCategoryLocal,
+ const css::uno::Any& aRefersToR1C1,
+ const css::uno::Any& aRefersToR1C1Local ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // ScVbaNames_BASE
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+#endif /* SC_VBA_NAMES_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaoleobject.cxx b/sc/source/ui/vba/vbaoleobject.cxx
new file mode 100644
index 000000000000..2d8347bdbd8b
--- /dev/null
+++ b/sc/source/ui/vba/vbaoleobject.cxx
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/view/XControlAccess.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/drawing/XShape.hpp>
+#include <ooo/vba/XControlProvider.hpp>
+
+#include "vbaoleobject.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+
+sal_Int32 pt2mm( double pt ) //1/100mm
+{
+ return static_cast<sal_Int32>(pt * 0.352778);
+}
+
+double mm2pt( sal_Int32 mm )
+{
+ return mm * 2.8345;
+}
+
+
+ScVbaOLEObject::ScVbaOLEObject( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
+ css::uno::Reference< css::drawing::XControlShape > xControlShape )
+: OLEObjectImpl_BASE( xParent, xContext ), m_xControlShape( xControlShape )
+{
+ //init m_xWindowPeer
+ uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl(), css::uno::UNO_QUERY_THROW );
+ uno::Reference< container::XChild > xChild( xControlModel, uno::UNO_QUERY_THROW );
+ xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
+ xChild.set( xChild->getParent(), uno::UNO_QUERY_THROW );
+ css::uno::Reference< css::frame::XModel > xModel( xChild->getParent(), uno::UNO_QUERY_THROW );
+ uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW );
+ m_xControl.set( xControlProvider->createControl( xControlShape, xModel ) );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL
+ScVbaOLEObject::getObject() throw (uno::RuntimeException)
+{
+ return uno::Reference< uno::XInterface >( m_xControl, uno::UNO_QUERY_THROW );
+}
+
+sal_Bool SAL_CALL
+ScVbaOLEObject::getEnabled() throw (uno::RuntimeException)
+{
+ return m_xControl->getEnabled();
+}
+
+void SAL_CALL
+ScVbaOLEObject::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
+{
+ m_xControl->setEnabled( _enabled );
+}
+
+sal_Bool SAL_CALL
+ScVbaOLEObject::getVisible() throw (uno::RuntimeException)
+{
+ OSL_TRACE("OleObject %s returning visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), m_xControl->getVisible() ? "true" : "false" );
+ return m_xControl->getVisible();
+}
+
+void SAL_CALL
+ScVbaOLEObject::setVisible( sal_Bool _visible ) throw (uno::RuntimeException)
+{
+ OSL_TRACE("OleObject %s set visible %s", rtl::OUStringToOString( m_xControl->getName(), RTL_TEXTENCODING_UTF8 ).getStr(), _visible ? "true" : "false" );
+ m_xControl->setVisible( _visible );
+}
+
+double SAL_CALL
+ScVbaOLEObject::getLeft() throw (uno::RuntimeException)
+{
+ return m_xControl->getLeft();
+}
+
+void SAL_CALL
+ScVbaOLEObject::setLeft( double _left ) throw (uno::RuntimeException)
+{
+ m_xControl->setLeft( _left );
+
+}
+
+double SAL_CALL
+ScVbaOLEObject::getTop() throw (uno::RuntimeException)
+{
+ return m_xControl->getTop();
+}
+
+void SAL_CALL
+ScVbaOLEObject::setTop( double _top ) throw (uno::RuntimeException)
+{
+ m_xControl->setTop( _top );
+}
+
+double SAL_CALL
+ScVbaOLEObject::getHeight() throw (uno::RuntimeException)
+{
+ return m_xControl->getHeight();
+}
+
+void SAL_CALL
+ScVbaOLEObject::setHeight( double _height ) throw (uno::RuntimeException)
+{
+ m_xControl->setHeight( _height );
+}
+
+double SAL_CALL
+ScVbaOLEObject::getWidth() throw (uno::RuntimeException)
+{
+ return m_xControl->getWidth();
+}
+
+void SAL_CALL
+ScVbaOLEObject::setWidth( double _width ) throw (uno::RuntimeException)
+{
+ m_xControl->setWidth( _width );
+}
+rtl::OUString&
+ScVbaOLEObject::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaOLEObject") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaOLEObject::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.OLEObject" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaoleobject.hxx b/sc/source/ui/vba/vbaoleobject.hxx
new file mode 100644
index 000000000000..da0630282506
--- /dev/null
+++ b/sc/source/ui/vba/vbaoleobject.hxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_OLEOBJECT_HXX
+#define SC_VBA_OLEOBJECT_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <ooo/vba/excel/XOLEObject.hpp>
+#include <ooo/vba/msforms/XControl.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XOLEObject > OLEObjectImpl_BASE;
+
+class ScVbaOLEObject : public OLEObjectImpl_BASE
+{
+protected:
+ css::uno::Reference< css::drawing::XControlShape > m_xControlShape;
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+ css::uno::Reference< ov::msforms::XControl> m_xControl;
+public:
+ ScVbaOLEObject( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::drawing::XControlShape > xControlShape );
+
+ // XOLEObject Attributes
+ virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getObject() throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getEnabled() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setEnabled( ::sal_Bool _enabled ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( ::sal_Bool _visible ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLeft( double _left ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTop( double _top ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeight( double _height ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWidth( double _width ) throw (css::uno::RuntimeException);
+
+};
+#endif //SC_VBA_OLEOBJECT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaoleobjects.cxx b/sc/source/ui/vba/vbaoleobjects.cxx
new file mode 100644
index 000000000000..bbb88d9b7680
--- /dev/null
+++ b/sc/source/ui/vba/vbaoleobjects.cxx
@@ -0,0 +1,188 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <ooo/vba/excel/XOLEObject.hpp>
+
+#include "vbaoleobject.hxx"
+#include "vbaoleobjects.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
+
+class IndexAccessWrapper : public XIndexAccess_BASE
+{
+typedef std::vector< uno::Reference< drawing::XControlShape > > OLEObjects;
+ OLEObjects vObjects;
+public:
+ IndexAccessWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess )
+ {
+ sal_Int32 nLen = xIndexAccess->getCount();
+ for ( sal_Int32 index = 0; index < nLen; ++index )
+ {
+ uno::Reference< drawing::XControlShape > xControlShape( xIndexAccess->getByIndex( index), uno::UNO_QUERY);
+ if ( xControlShape.is() )
+ vObjects.push_back( xControlShape );
+ }
+ }
+
+ virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
+ {
+ return vObjects.size();
+ }
+
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+ return uno::makeAny( vObjects[ Index ] );
+ }
+
+ // Methods XElementAcess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
+ {
+ return drawing::XControlShape::static_type(0);
+ }
+
+ virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
+ {
+ return ( getCount() > 0 );
+ }
+
+};
+
+class EnumWrapper : public EnumerationHelper_BASE
+{
+
+ uno::Reference<XHelperInterface > m_xParent;
+ uno::Reference<uno::XComponentContext > m_xContext;
+ uno::Reference<container::XIndexAccess > m_xIndexAccess;
+ sal_Int32 nIndex;
+public:
+ EnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xParent( xParent ), m_xContext( xContext), m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
+
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < m_xIndexAccess->getCount() )
+ {
+ uno::Reference< drawing::XControlShape > xControlShape ( m_xIndexAccess->getByIndex( nIndex++ ), uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< ov::excel::XOLEObject >( new ScVbaOLEObject( m_xParent, m_xContext, xControlShape ) ) );
+ }
+ throw container::NoSuchElementException();
+ }
+};
+
+uno::Reference< container::XIndexAccess > oleObjectIndexWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess )
+{
+ return new IndexAccessWrapper( xIndexAccess );
+}
+
+ScVbaOLEObjects::ScVbaOLEObjects( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess )
+ : OLEObjectsImpl_BASE( xParent, xContext, oleObjectIndexWrapper( xIndexAccess ) )
+{
+}
+uno::Reference< container::XEnumeration >
+ScVbaOLEObjects::createEnumeration() throw (uno::RuntimeException)
+{
+ return new EnumWrapper( getParent(), mxContext, m_xIndexAccess );
+}
+
+uno::Any
+ScVbaOLEObjects::createCollectionObject( const css::uno::Any& aSource )
+{
+ if( aSource.hasValue() )
+ {
+ uno::Reference< drawing::XControlShape > xControlShape( aSource, uno::UNO_QUERY_THROW );
+ // parent of OLEObject is the same parent as the collection ( e.g. the sheet )
+ return uno::makeAny( uno::Reference< ov::excel::XOLEObject >( new ScVbaOLEObject( getParent(), mxContext, xControlShape ) ) );
+ }
+ return uno::Any();
+}
+
+uno::Any
+ScVbaOLEObjects::getItemByStringIndex( const rtl::OUString& sIndex ) throw (uno::RuntimeException)
+{
+ try
+ {
+ return OLEObjectsImpl_BASE::getItemByStringIndex( sIndex );
+ }
+ catch( uno::RuntimeException )
+ {
+ uno::Reference< container::XIndexAccess > xIndexAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ sal_Int32 nCount = xIndexAccess->getCount();
+ for( int index = 0; index < nCount; index++ )
+ {
+ uno::Any aUnoObj = xIndexAccess->getByIndex( index );
+ uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XControlModel > xControlModel( xControlShape->getControl() );
+ uno::Reference< container::XNamed > xNamed( xControlModel, uno::UNO_QUERY_THROW );
+ if( sIndex.equals( xNamed->getName() ))
+ {
+ return createCollectionObject( aUnoObj );
+ }
+
+ }
+ return uno::Any();
+ }
+}
+
+uno::Type
+ScVbaOLEObjects::getElementType() throw (uno::RuntimeException)
+{
+ return ooo::vba::excel::XOLEObject::static_type(0);
+}
+rtl::OUString&
+ScVbaOLEObjects::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaOLEObjects") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaOLEObjects::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.OLEObjects" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaoleobjects.hxx b/sc/source/ui/vba/vbaoleobjects.hxx
new file mode 100644
index 000000000000..7ebbf4956734
--- /dev/null
+++ b/sc/source/ui/vba/vbaoleobjects.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_OLEOBJECTS_HXX
+#define SC_VBA_OLEOBJECTS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XOLEObjects.hpp>
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include "excelvbahelper.hxx"
+
+typedef CollTestImplHelper< ov::excel::XOLEObjects > OLEObjectsImpl_BASE;
+
+class ScVbaOLEObjects : public OLEObjectsImpl_BASE
+{
+protected:
+ virtual css::uno::Any getItemByStringIndex( const rtl::OUString& sIndex ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+public:
+ ScVbaOLEObjects( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // ScVbaCollectionBaseImpl
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+};
+#endif //SC_VBA_OLEOBJECTS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaoutline.cxx b/sc/source/ui/vba/vbaoutline.cxx
new file mode 100644
index 000000000000..3d00b80ca0a5
--- /dev/null
+++ b/sc/source/ui/vba/vbaoutline.cxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaoutline.hxx"
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+void
+ScVbaOutline::ShowLevels( const uno::Any& RowLevels, const uno::Any& ColumnLevels ) throw (uno::RuntimeException)
+{
+ sal_Int16 nLevel = 0;
+ if (mxOutline.is())
+ {
+ if (RowLevels >>= nLevel)
+ {
+ mxOutline->showLevel(nLevel, table::TableOrientation_ROWS);
+ }
+ if (ColumnLevels >>= nLevel)
+ {
+ mxOutline->showLevel(nLevel,table::TableOrientation_COLUMNS);
+ }
+ }
+}
+
+rtl::OUString&
+ScVbaOutline::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaOutline") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaOutline::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Outline" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaoutline.hxx b/sc/source/ui/vba/vbaoutline.hxx
new file mode 100644
index 000000000000..4cc1c7386779
--- /dev/null
+++ b/sc/source/ui/vba/vbaoutline.hxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_OUTLINE_HXX
+#define SC_VBA_OUTLINE_HXX
+
+#include <com/sun/star/sheet/XSheetOutline.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XOutline.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XOutline > ScVbaOutline_BASE;
+
+class ScVbaOutline : public ScVbaOutline_BASE
+{
+ css::uno::Reference< css::sheet::XSheetOutline > mxOutline;
+public:
+ ScVbaOutline( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference<css::sheet::XSheetOutline> outline): ScVbaOutline_BASE( xParent, xContext) , mxOutline(outline)
+ {}
+ virtual ~ScVbaOutline(){}
+
+ virtual void SAL_CALL ShowLevels( const css::uno::Any& RowLevels, const css::uno::Any& ColumnLevels ) throw (css::uno::RuntimeException) ;
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagebreak.cxx b/sc/source/ui/vba/vbapagebreak.cxx
new file mode 100644
index 000000000000..813a5954d6e1
--- /dev/null
+++ b/sc/source/ui/vba/vbapagebreak.cxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapagebreak.hxx"
+#include "vbarange.hxx"
+#include <ooo/vba/excel/XlPageBreak.hpp>
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+template< typename Ifc1 >
+ScVbaPageBreak<Ifc1>::ScVbaPageBreak( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ uno::Reference< beans::XPropertySet >& xProps,
+ sheet::TablePageBreakData aTablePageBreakData) throw (uno::RuntimeException):
+ ScVbaPageBreak_BASE( xParent, xContext ),
+ mxRowColPropertySet( xProps ),
+ maTablePageBreakData( aTablePageBreakData )
+{
+}
+
+template< typename Ifc1 >
+sal_Int32 ScVbaPageBreak<Ifc1>::getType() throw (uno::RuntimeException)
+{
+ uno::Any aValue = mxRowColPropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )));
+ sal_Bool hasPageBreak = sal_False;
+ aValue >>= hasPageBreak;
+
+ if( !hasPageBreak )
+ return excel::XlPageBreak::xlPageBreakNone;
+
+ if( maTablePageBreakData.ManualBreak )
+ return excel::XlPageBreak::xlPageBreakManual;
+
+ return excel::XlPageBreak::xlPageBreakAutomatic;
+}
+
+template< typename Ifc1 >
+void ScVbaPageBreak<Ifc1>::setType(sal_Int32 type) throw (uno::RuntimeException)
+{
+ if( (type != excel::XlPageBreak::xlPageBreakNone) &&
+ (type != excel::XlPageBreak::xlPageBreakManual) &&
+ (type != excel::XlPageBreak::xlPageBreakAutomatic) )
+ {
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+
+ if( type == excel::XlPageBreak::xlPageBreakNone )
+ {
+ mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
+ return;
+ }
+
+ mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_True));
+ if( type == excel::XlPageBreak::xlPageBreakManual )
+ maTablePageBreakData.ManualBreak = sal_True;
+ else
+ maTablePageBreakData.ManualBreak = sal_False;
+}
+
+template< typename Ifc1 >
+void ScVbaPageBreak<Ifc1>::Delete() throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ mxRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_False));
+}
+
+template< typename Ifc1 >
+uno::Reference< excel::XRange> ScVbaPageBreak<Ifc1>::Location() throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< table::XCellRange > xRange( mxRowColPropertySet, uno::UNO_QUERY_THROW );
+ return new ScVbaRange( ScVbaPageBreak_BASE::getParent(), ScVbaPageBreak_BASE::mxContext, xRange);
+}
+
+template< typename Ifc1 >
+rtl::OUString&
+ScVbaPageBreak<Ifc1>::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPageBreak") );
+ return sImplName;
+}
+
+template< typename Ifc1 >
+uno::Sequence< rtl::OUString >
+ScVbaPageBreak<Ifc1>::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PageBreak" ) );
+ }
+ return aServiceNames;
+}
+
+template class ScVbaPageBreak< excel::XHPageBreak >;
+
+/* class ScVbaHPageBreak */
+rtl::OUString&
+ScVbaHPageBreak::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaHPageBreak") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaHPageBreak::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.HPageBreak" ) );
+ }
+ return aServiceNames;
+}
+
+template class ScVbaPageBreak< excel::XVPageBreak >;
+
+/* class ScVbaVPageBreak */
+ScVbaVPageBreak::ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::beans::XPropertySet >& xProps,
+ css::sheet::TablePageBreakData aTablePageBreakData ) throw ( css::uno::RuntimeException )
+: ScVbaVPageBreak_BASE( xParent, xContext, xProps, aTablePageBreakData )
+{
+}
+
+ScVbaVPageBreak::~ScVbaVPageBreak()
+{
+}
+
+rtl::OUString&
+ScVbaVPageBreak::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaVPageBreak") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaVPageBreak::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.VPageBreak" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagebreak.hxx b/sc/source/ui/vba/vbapagebreak.hxx
new file mode 100644
index 000000000000..c0579787a4c6
--- /dev/null
+++ b/sc/source/ui/vba/vbapagebreak.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PAGEBREAK_HXX
+#define SC_VBA_PAGEBREAK_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XPageBreak.hpp>
+#include <ooo/vba/excel/XHPageBreak.hpp>
+#include <ooo/vba/excel/XVPageBreak.hpp>
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/script/BasicErrorException.hpp>
+#include <com/sun/star/sheet/TablePageBreakData.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+template< typename Ifc1 >
+class ScVbaPageBreak : public InheritedHelperInterfaceImpl1< Ifc1 >
+{
+typedef InheritedHelperInterfaceImpl1< Ifc1 > ScVbaPageBreak_BASE;
+protected:
+ css::uno::Reference< css::beans::XPropertySet > mxRowColPropertySet;
+ css::sheet::TablePageBreakData maTablePageBreakData;
+public:
+ ScVbaPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::beans::XPropertySet >& xProps,
+ css::sheet::TablePageBreakData aTablePageBreakData) throw (css::uno::RuntimeException);
+ virtual ~ScVbaPageBreak(){}
+
+ virtual sal_Int32 SAL_CALL getType( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setType(sal_Int32 type) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Delete() throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange> SAL_CALL Location() throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+
+typedef ScVbaPageBreak < ov::excel::XHPageBreak > ScVbaHPageBreak_BASE;
+
+class ScVbaHPageBreak : public ScVbaHPageBreak_BASE
+{
+public:
+ ScVbaHPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::beans::XPropertySet >& xProps,
+ css::sheet::TablePageBreakData aTablePageBreakData) throw (css::uno::RuntimeException):
+ ScVbaHPageBreak_BASE( xParent,xContext,xProps,aTablePageBreakData ){}
+
+ virtual ~ScVbaHPageBreak(){}
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+//VPageBreak
+typedef ScVbaPageBreak < ov::excel::XVPageBreak > ScVbaVPageBreak_BASE;
+
+class ScVbaVPageBreak : public ScVbaVPageBreak_BASE
+{
+public:
+ ScVbaVPageBreak( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::beans::XPropertySet >& xProps,
+ css::sheet::TablePageBreakData aTablePageBreakData) throw (css::uno::RuntimeException);
+
+ virtual ~ScVbaVPageBreak();
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagebreaks.cxx b/sc/source/ui/vba/vbapagebreaks.cxx
new file mode 100644
index 000000000000..e6c83ed618c7
--- /dev/null
+++ b/sc/source/ui/vba/vbapagebreaks.cxx
@@ -0,0 +1,321 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapagebreaks.hxx"
+#include "vbapagebreak.hxx"
+#include <ooo/vba/excel/XWorksheet.hpp>
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+typedef ::cppu::WeakImplHelper1<container::XIndexAccess > RangePageBreaks_Base;
+class RangePageBreaks : public RangePageBreaks_Base
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< sheet::XSheetPageBreak > mxSheetPageBreak;
+ sal_Bool m_bColumn;
+
+public:
+ RangePageBreaks( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ uno::Reference< sheet::XSheetPageBreak >& xSheetPageBreak,
+ sal_Bool bColumn ) : mxParent( xParent ), mxContext( xContext ), mxSheetPageBreak( xSheetPageBreak ), m_bColumn( bColumn )
+ {
+ }
+
+ sal_Int32 getAPIStartofRange( const uno::Reference< excel::XRange >& xRange ) throw (css::uno::RuntimeException)
+ {
+ if( m_bColumn )
+ return xRange->getColumn() - 1;
+ return xRange->getRow() - 1;
+ }
+
+ sal_Int32 getAPIEndIndexofRange( const uno::Reference< excel::XRange >& xRange, sal_Int32 nUsedStart ) throw (uno::RuntimeException)
+ {
+ if( m_bColumn )
+ return nUsedStart + xRange->Columns( uno::Any() )->getCount();
+ return nUsedStart + xRange->Rows( uno::Any() )->getCount();
+ }
+
+ uno::Sequence<sheet::TablePageBreakData> getAllPageBreaks() throw (uno::RuntimeException)
+ {
+ if( m_bColumn )
+ return mxSheetPageBreak->getColumnPageBreaks();
+ return mxSheetPageBreak->getRowPageBreaks();
+ }
+
+ uno::Reference<container::XIndexAccess> getRowColContainer() throw (uno::RuntimeException)
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange( mxSheetPageBreak, uno::UNO_QUERY_THROW );
+ uno::Reference<container::XIndexAccess> xIndexAccess;
+ if( m_bColumn )
+ xIndexAccess.set( xColumnRowRange->getColumns(), uno::UNO_QUERY_THROW );
+ else
+ xIndexAccess.set( xColumnRowRange->getRows(), uno::UNO_QUERY_THROW );
+ return xIndexAccess;
+ }
+
+ sheet::TablePageBreakData getTablePageBreakData( sal_Int32 nAPIItemIndex ) throw ( script::BasicErrorException, uno::RuntimeException);
+ uno::Any Add( const css::uno::Any& Before ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ if( m_bColumn )
+ return excel::XVPageBreak::static_type(0);
+ return excel::XHPageBreak::static_type(0);
+ }
+ virtual sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+};
+
+/** @TODO Unlike MS Excel this method only considers the pagebreaks that intersect the used range
+* To become completely compatible the print area has to be considered. As far as I found out this printarea
+* also considers the position and sizes of shapes and manually inserted page breaks
+* Note: In MS there is a limit of 1026 horizontal page breaks per sheet.
+*/
+sal_Int32 SAL_CALL RangePageBreaks::getCount( ) throw (uno::RuntimeException)
+{
+ sal_Int32 nCount = 0;
+ uno::Reference< excel::XWorksheet > xWorksheet( mxParent, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XRange > xRange = xWorksheet->getUsedRange();
+ sal_Int32 nUsedStart = getAPIStartofRange( xRange );
+ sal_Int32 nUsedEnd = getAPIEndIndexofRange( xRange, nUsedStart );
+ uno::Sequence<sheet::TablePageBreakData> aTablePageBreakData = getAllPageBreaks();
+
+ sal_Int32 nLength = aTablePageBreakData.getLength();
+ for( sal_Int32 i=0; i<nLength; i++ )
+ {
+ sal_Int32 nPos = aTablePageBreakData[i].Position;
+
+ // VBA. minz@cn.ibm.com. All page breaks before the used range should be counted.
+ // And the page break at the end of the used range also should be counted.
+ if( nPos <= nUsedEnd + 1 )
+ nCount++;
+ else
+ return nCount;
+ }
+
+ return nCount;
+}
+
+uno::Any SAL_CALL RangePageBreaks::getByIndex( sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( (Index < getCount()) && ( Index >= 0 ))
+ {
+ sheet::TablePageBreakData aTablePageBreakData = getTablePageBreakData( Index );
+ uno::Reference< container::XIndexAccess > xIndexAccess = getRowColContainer();
+ sal_Int32 nPos = aTablePageBreakData.Position;
+ if( (nPos < xIndexAccess->getCount()) && (nPos > -1) )
+ {
+ uno::Reference< beans::XPropertySet > xRowColPropertySet( xIndexAccess->getByIndex(nPos), uno::UNO_QUERY_THROW );
+ if( m_bColumn )
+ return uno::makeAny( uno::Reference< excel::XVPageBreak >( new ScVbaVPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) ));
+ return uno::makeAny( uno::Reference< excel::XHPageBreak >( new ScVbaHPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) ));
+ }
+ }
+ throw lang::IndexOutOfBoundsException();
+}
+
+sheet::TablePageBreakData RangePageBreaks::getTablePageBreakData( sal_Int32 nAPIItemIndex ) throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ sheet::TablePageBreakData aTablePageBreakData;
+ uno::Reference< excel::XWorksheet > xWorksheet( mxParent, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XRange > xRange = xWorksheet->getUsedRange();
+ uno::Sequence<sheet::TablePageBreakData> aTablePageBreakDataList = getAllPageBreaks();
+
+ sal_Int32 nLength = aTablePageBreakDataList.getLength();
+ //VBA. minz@cn.ibm.com. No need to filter the page break. All page breaks before the used range are counted.
+ if ( nAPIItemIndex < nLength && nAPIItemIndex>=0 )
+ aTablePageBreakData = aTablePageBreakDataList[nAPIItemIndex];
+
+ return aTablePageBreakData;
+}
+
+uno::Any RangePageBreaks::Add( const css::uno::Any& Before ) throw ( css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ uno::Reference< excel::XRange > xRange;
+ Before >>= xRange;
+ if( !xRange.is() )
+ {
+ DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
+ }
+
+ sal_Int32 nAPIRowColIndex = getAPIStartofRange( xRange );
+ uno::Reference< container::XIndexAccess > xIndexAccess = getRowColContainer();
+ uno::Reference< beans::XPropertySet > xRowColPropertySet( xIndexAccess->getByIndex(nAPIRowColIndex), uno::UNO_QUERY_THROW );
+ xRowColPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsStartOfNewPage" )), uno::makeAny(sal_True));
+ sheet::TablePageBreakData aTablePageBreakData;
+ aTablePageBreakData.ManualBreak = sal_True;
+ aTablePageBreakData.Position = nAPIRowColIndex;
+ if( m_bColumn )
+ return uno::makeAny( uno::Reference< excel::XVPageBreak >( new ScVbaVPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) ));
+ return uno::makeAny( uno::Reference< excel::XHPageBreak >( new ScVbaHPageBreak( mxParent, mxContext, xRowColPropertySet, aTablePageBreakData) ));
+}
+
+
+class RangePageBreaksEnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference<container::XIndexAccess > m_xIndexAccess;
+ sal_Int32 nIndex;
+public:
+ RangePageBreaksEnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess ) : m_xIndexAccess( xIndexAccess ), nIndex( 0 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < m_xIndexAccess->getCount() )
+ return m_xIndexAccess->getByIndex( nIndex++ );
+ throw container::NoSuchElementException();
+ }
+};
+
+ScVbaHPageBreaks::ScVbaHPageBreaks( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ uno::Reference< sheet::XSheetPageBreak >& xSheetPageBreak) throw (uno::RuntimeException):
+ ScVbaHPageBreaks_BASE( xParent,xContext, new RangePageBreaks( xParent, xContext, xSheetPageBreak, sal_False )),
+ mxSheetPageBreak( xSheetPageBreak )
+{
+}
+
+uno::Any SAL_CALL ScVbaHPageBreaks::Add( const uno::Any& Before) throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ RangePageBreaks* pPageBreaks = dynamic_cast< RangePageBreaks* >( m_xIndexAccess.get() );
+ if( pPageBreaks )
+ {
+ return pPageBreaks->Add( Before );
+ }
+ return uno::Any();
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaHPageBreaks::createEnumeration() throw (uno::RuntimeException)
+{
+ return new RangePageBreaksEnumWrapper( m_xIndexAccess );
+}
+
+uno::Any
+ScVbaHPageBreaks::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource; // its already a pagebreak object
+}
+
+uno::Type
+ScVbaHPageBreaks::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XHPageBreak::static_type(0);
+}
+
+rtl::OUString&
+ScVbaHPageBreaks::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaHPageBreaks") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaHPageBreaks::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.HPageBreaks" ) );
+ }
+ return aServiceNames;
+}
+
+//VPageBreak
+ScVbaVPageBreaks::ScVbaVPageBreaks( const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ uno::Reference< sheet::XSheetPageBreak >& xSheetPageBreak ) throw ( uno::RuntimeException )
+: ScVbaVPageBreaks_BASE( xParent, xContext, new RangePageBreaks( xParent, xContext, xSheetPageBreak, sal_True ) ),
+ mxSheetPageBreak( xSheetPageBreak )
+{
+}
+
+ScVbaVPageBreaks::~ScVbaVPageBreaks()
+{
+}
+
+uno::Any SAL_CALL
+ScVbaVPageBreaks::Add( const uno::Any& Before ) throw ( script::BasicErrorException, uno::RuntimeException )
+{
+ RangePageBreaks* pPageBreaks = dynamic_cast< RangePageBreaks* >( m_xIndexAccess.get() );
+ if( pPageBreaks )
+ {
+ return pPageBreaks->Add( Before );
+ }
+ return uno::Any();
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaVPageBreaks::createEnumeration() throw ( uno::RuntimeException )
+{
+ return new RangePageBreaksEnumWrapper( m_xIndexAccess );
+}
+
+uno::Any
+ScVbaVPageBreaks::createCollectionObject( const css::uno::Any& aSource )
+{
+ return aSource; // its already a pagebreak object
+}
+
+uno::Type
+ScVbaVPageBreaks::getElementType() throw ( uno::RuntimeException )
+{
+ return excel::XVPageBreak::static_type( 0 );
+}
+
+rtl::OUString&
+ScVbaVPageBreaks::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM( "ScVbaVPageBreaks" ) );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaVPageBreaks::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.VPageBreaks" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagebreaks.hxx b/sc/source/ui/vba/vbapagebreaks.hxx
new file mode 100644
index 000000000000..0230b2be0b58
--- /dev/null
+++ b/sc/source/ui/vba/vbapagebreaks.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PAGEBREAKS_HXX
+#define SC_VBA_PAGEBREAKS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XHPageBreaks.hpp>
+#include <ooo/vba/excel/XHPageBreak.hpp>
+#include <ooo/vba/excel/XVPageBreaks.hpp>
+#include <ooo/vba/excel/XVPageBreak.hpp>
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/script/BasicErrorException.hpp>
+#include <com/sun/star/sheet/XSheetPageBreak.hpp>
+#include <com/sun/star/sheet/TablePageBreakData.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XHPageBreaks > ScVbaHPageBreaks_BASE;
+
+class ScVbaHPageBreaks : public ScVbaHPageBreaks_BASE
+{
+ css::uno::Reference< css::sheet::XSheetPageBreak > mxSheetPageBreak;
+public:
+ ScVbaHPageBreaks( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::sheet::XSheetPageBreak >& xSheetPageBreak) throw (css::uno::RuntimeException);
+ virtual ~ScVbaHPageBreaks(){}
+
+ // XHPageBreaks
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Before) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject(const css::uno::Any&);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+//VPageBreaks
+typedef CollTestImplHelper< ov::excel::XVPageBreaks > ScVbaVPageBreaks_BASE;
+
+class ScVbaVPageBreaks : public ScVbaVPageBreaks_BASE
+{
+ css::uno::Reference< css::sheet::XSheetPageBreak > mxSheetPageBreak;
+
+public:
+ ScVbaVPageBreaks( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::sheet::XSheetPageBreak >& xSheetPageBreak ) throw ( css::uno::RuntimeException );
+
+ virtual ~ScVbaVPageBreaks();
+
+ // XVPageBreaks
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Before ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw ( css::uno::RuntimeException );
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw ( css::uno::RuntimeException );
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagesetup.cxx b/sc/source/ui/vba/vbapagesetup.cxx
new file mode 100644
index 000000000000..c80e407fb532
--- /dev/null
+++ b/sc/source/ui/vba/vbapagesetup.cxx
@@ -0,0 +1,734 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapagesetup.hxx"
+#include "cellsuno.hxx"
+#include "convuno.hxx"
+#include "rangelst.hxx"
+#include "excelvbahelper.hxx"
+#include <com/sun/star/sheet/XPrintAreas.hpp>
+#include <com/sun/star/sheet/XHeaderFooterContent.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <ooo/vba/excel/XlPageOrientation.hpp>
+#include <ooo/vba/excel/XlOrder.hpp>
+#include <ooo/vba/excel/Constants.hpp>
+#include <i18npool/paper.hxx>
+#include <editeng/paperinf.hxx>
+#include <ooo/vba/excel/XlPaperSize.hpp>
+#include <sal/macros.h>
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+#define ZOOM_IN 10
+#define ZOOM_MAX 400
+
+bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, ScRange& refRange, ScRangeList& aCellRanges, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException );
+
+ScVbaPageSetup::ScVbaPageSetup(const uno::Reference< XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< sheet::XSpreadsheet >& xSheet,
+ const uno::Reference< frame::XModel >& xModel) throw (uno::RuntimeException):
+ ScVbaPageSetup_BASE( xParent, xContext ), mxSheet( xSheet )
+{
+ // query for current page style
+ mxModel.set( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xSheetProps( mxSheet, uno::UNO_QUERY_THROW );
+ uno::Any aValue = xSheetProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageStyle" )));
+ rtl::OUString aStyleName;
+ aValue >>= aStyleName;
+
+ uno::Reference< style::XStyleFamiliesSupplier > xStyleFamiliesSup( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xStyleFamilies = xStyleFamiliesSup->getStyleFamilies();
+ uno::Reference< container::XNameAccess > xPageStyle( xStyleFamilies->getByName(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageStyles"))), uno::UNO_QUERY_THROW );
+ mxPageProps.set( xPageStyle->getByName(aStyleName), uno::UNO_QUERY_THROW );
+ mnOrientLandscape = excel::XlPageOrientation::xlLandscape;
+ mnOrientPortrait = excel::XlPageOrientation::xlPortrait;
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getPrintArea() throw (css::uno::RuntimeException)
+{
+ String aPrintArea;
+ uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
+ uno::Sequence< table::CellRangeAddress > aSeq = xPrintAreas->getPrintAreas();
+ sal_Int32 nCount = aSeq.getLength();
+ if( nCount )
+ {
+ ScAddress::Details aDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
+ USHORT nFlags = SCA_VALID;
+ nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE );
+ ScRangeList aRangeList;
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ ScRange aRange;
+ ScUnoConversion::FillScRange( aRange, aSeq[i] );
+ aRangeList.Append( aRange );
+ }
+ ScDocument* pDoc = excel::getDocShell( mxModel )->GetDocument();
+ aRangeList.Format( aPrintArea, nFlags, pDoc, formula::FormulaGrammar::CONV_XL_A1, ',' );
+ }
+
+ return aPrintArea;
+}
+
+void SAL_CALL ScVbaPageSetup::setPrintArea( const rtl::OUString& rAreas ) throw (css::uno::RuntimeException)
+{
+ uno::Reference< sheet::XPrintAreas > xPrintAreas( mxSheet, uno::UNO_QUERY_THROW );
+ if( rAreas.getLength() == 0 ||
+ rAreas.equalsIgnoreAsciiCase ( rtl::OUString::createFromAscii("FALSE") ) )
+ {
+ // print the whole sheet
+ uno::Sequence< table::CellRangeAddress > aSeq;
+ xPrintAreas->setPrintAreas( aSeq );
+ }
+ else
+ {
+ ScRangeList aCellRanges;
+ ScRange aRange;
+ if( getScRangeListForAddress( rAreas, excel::getDocShell( mxModel ) , aRange, aCellRanges ) )
+ {
+ uno::Sequence< table::CellRangeAddress > aSeq( aCellRanges.Count() );
+ USHORT i=0;
+ for( ScRange* pRange = aCellRanges.First(); pRange; pRange = aCellRanges.Next() )
+ {
+ table::CellRangeAddress aRangeAddress;
+ ScUnoConversion::FillApiRange( aRangeAddress, *pRange );
+ aSeq[ i++ ] = aRangeAddress;
+ }
+ xPrintAreas->setPrintAreas( aSeq );
+ }
+ }
+}
+
+double SAL_CALL ScVbaPageSetup::getHeaderMargin() throw (css::uno::RuntimeException)
+{
+ return VbaPageSetupBase::getHeaderMargin();
+}
+
+void SAL_CALL ScVbaPageSetup::setHeaderMargin( double margin ) throw (css::uno::RuntimeException)
+{
+ VbaPageSetupBase::setHeaderMargin( margin );
+}
+
+double SAL_CALL ScVbaPageSetup::getFooterMargin() throw (css::uno::RuntimeException)
+{
+ return VbaPageSetupBase::getFooterMargin();
+}
+
+void SAL_CALL ScVbaPageSetup::setFooterMargin( double margin ) throw (css::uno::RuntimeException)
+{
+ VbaPageSetupBase::setFooterMargin( margin );
+}
+
+uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesTall() throw (css::uno::RuntimeException)
+{
+ return mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")));
+}
+
+void SAL_CALL ScVbaPageSetup::setFitToPagesTall( const uno::Any& fitToPagesTall) throw (css::uno::RuntimeException)
+{
+ USHORT scaleToPageY = 0;
+ try
+ {
+ sal_Bool aValue;
+ if( fitToPagesTall.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesTall >>= aValue))
+ {
+ fitToPagesTall >>= scaleToPageY;
+ }
+
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")), uno::makeAny( scaleToPageY ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+uno::Any SAL_CALL ScVbaPageSetup::getFitToPagesWide() throw (css::uno::RuntimeException)
+{
+ return mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")));
+}
+
+void SAL_CALL ScVbaPageSetup::setFitToPagesWide( const uno::Any& fitToPagesWide) throw (css::uno::RuntimeException)
+{
+ USHORT scaleToPageX = 0;
+ try
+ {
+ sal_Bool aValue = sal_False;
+ if( fitToPagesWide.getValueTypeClass() != uno::TypeClass_BOOLEAN || (fitToPagesWide >>= aValue))
+ {
+ fitToPagesWide >>= scaleToPageX;
+ }
+
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")), uno::makeAny( scaleToPageX ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+uno::Any SAL_CALL ScVbaPageSetup::getZoom() throw (css::uno::RuntimeException)
+{
+ return mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageScale")));
+}
+
+void SAL_CALL ScVbaPageSetup::setZoom( const uno::Any& zoom) throw (css::uno::RuntimeException)
+{
+ USHORT pageScale = 0;
+ try
+ {
+ if( zoom.getValueTypeClass() == uno::TypeClass_BOOLEAN )
+ {
+ sal_Bool aValue = sal_False;
+ zoom >>= aValue;
+ if( aValue )
+ {
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+ }
+ else
+ {
+ zoom >>= pageScale;
+ if(( pageScale < ZOOM_IN )||( pageScale > ZOOM_MAX ))
+ {
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+ }
+
+ // these only exist in S08
+ USHORT nScale = 0;
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPages")), uno::makeAny( nScale ));
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesX")), uno::makeAny( nScale ));
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ScaleToPagesY")), uno::makeAny( nScale ));
+ }
+ catch( beans::UnknownPropertyException& )
+ {
+ if( pageScale == 0 )
+ {
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PageScale")), uno::makeAny( pageScale ));
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getLeftHeader() throw (css::uno::RuntimeException)
+{
+ rtl::OUString leftHeader;
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
+ if( xHeaderContent.is() )
+ {
+ uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
+ leftHeader = xText->getString();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return leftHeader;
+}
+
+void SAL_CALL ScVbaPageSetup::setLeftHeader( const rtl::OUString& leftHeader) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
+ if( xHeaderContent.is() )
+ {
+ uno::Reference< text::XText > xText = xHeaderContent->getLeftText();
+ xText->setString( leftHeader );
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent")), uno::makeAny(xHeaderContent) );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getCenterHeader() throw (css::uno::RuntimeException)
+{
+ rtl::OUString centerHeader;
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
+ if( xHeaderContent.is() )
+ {
+ uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
+ centerHeader = xText->getString();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return centerHeader;
+}
+
+void SAL_CALL ScVbaPageSetup::setCenterHeader( const rtl::OUString& centerHeader) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
+ if( xHeaderContent.is() )
+ {
+ uno::Reference< text::XText > xText = xHeaderContent->getCenterText();
+ xText->setString( centerHeader );
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent")), uno::makeAny(xHeaderContent) );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getRightHeader() throw (css::uno::RuntimeException)
+{
+ rtl::OUString rightHeader;
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
+ if( xHeaderContent.is() )
+ {
+ uno::Reference< text::XText > xText = xHeaderContent->getRightText();
+ rightHeader = xText->getString();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return rightHeader;
+}
+
+void SAL_CALL ScVbaPageSetup::setRightHeader( const rtl::OUString& rightHeader) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xHeaderContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent"))), uno::UNO_QUERY_THROW);
+ if( xHeaderContent.is() )
+ {
+ uno::Reference< text::XText > xText = xHeaderContent->getRightText();
+ xText->setString( rightHeader );
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageHeaderContent")), uno::makeAny(xHeaderContent) );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getLeftFooter() throw (css::uno::RuntimeException)
+{
+ rtl::OUString leftFooter;
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
+ if( xFooterContent.is() )
+ {
+ uno::Reference< text::XText > xText = xFooterContent->getLeftText();
+ leftFooter = xText->getString();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return leftFooter;
+}
+
+void SAL_CALL ScVbaPageSetup::setLeftFooter( const rtl::OUString& leftFooter) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
+ if( xFooterContent.is() )
+ {
+ uno::Reference< text::XText > xText = xFooterContent->getLeftText();
+ xText->setString( leftFooter );
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent")), uno::makeAny(xFooterContent) );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getCenterFooter() throw (css::uno::RuntimeException)
+{
+ rtl::OUString centerFooter;
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
+ if( xFooterContent.is() )
+ {
+ uno::Reference< text::XText > xText = xFooterContent->getCenterText();
+ centerFooter = xText->getString();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return centerFooter;
+}
+
+void SAL_CALL ScVbaPageSetup::setCenterFooter( const rtl::OUString& centerFooter) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
+ if( xFooterContent.is() )
+ {
+ uno::Reference< text::XText > xText = xFooterContent->getCenterText();
+ xText->setString( centerFooter );
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent")), uno::makeAny(xFooterContent) );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+}
+
+rtl::OUString SAL_CALL ScVbaPageSetup::getRightFooter() throw (css::uno::RuntimeException)
+{
+ rtl::OUString rightFooter;
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
+ if( xFooterContent.is() )
+ {
+ uno::Reference< text::XText > xText = xFooterContent->getRightText();
+ rightFooter = xText->getString();
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return rightFooter;
+}
+
+void SAL_CALL ScVbaPageSetup::setRightFooter( const rtl::OUString& rightFooter) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ uno::Reference<sheet::XHeaderFooterContent> xFooterContent( mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent"))), uno::UNO_QUERY_THROW);
+ if( xFooterContent.is() )
+ {
+ uno::Reference< text::XText > xText = xFooterContent->getRightText();
+ xText->setString( rightFooter );
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("RightPageFooterContent")), uno::makeAny(xFooterContent) );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+sal_Int32 SAL_CALL ScVbaPageSetup::getOrder() throw (css::uno::RuntimeException)
+{
+ sal_Int32 order = excel::XlOrder::xlDownThenOver;
+ try
+ {
+ uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintDownFirst")));
+ sal_Bool bPrintDownFirst = sal_False;
+ aValue >>= bPrintDownFirst;
+ if( !bPrintDownFirst )
+ order = excel::XlOrder::xlOverThenDown;
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return order;
+}
+
+void SAL_CALL ScVbaPageSetup::setOrder( sal_Int32 order) throw (css::uno::RuntimeException)
+{
+ sal_Bool bOrder = sal_True;
+ switch( order )
+ {
+ case excel::XlOrder::xlDownThenOver:
+ break;
+ case excel::XlOrder::xlOverThenDown:
+ bOrder = sal_False;
+ break;
+ default:
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+
+ try
+ {
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintDownFirst")), uno::makeAny( bOrder ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+sal_Int32 SAL_CALL ScVbaPageSetup::getFirstPageNumber() throw (css::uno::RuntimeException)
+{
+ sal_Int16 number = 0;
+ try
+ {
+ uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstPageNumber")));
+ aValue >>= number;
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ if( number ==0 )
+ {
+ number = excel::Constants::xlAutomatic;
+ }
+
+ return number;
+}
+
+void SAL_CALL ScVbaPageSetup::setFirstPageNumber( sal_Int32 firstPageNumber) throw (css::uno::RuntimeException)
+{
+ if( firstPageNumber < 0 )
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ if( firstPageNumber == excel::Constants::xlAutomatic )
+ firstPageNumber = 0;
+
+ try
+ {
+ uno::Any aValue;
+ aValue <<= (sal_Int16)firstPageNumber;
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FirstPageNumber")), aValue );
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+sal_Bool SAL_CALL ScVbaPageSetup::getCenterVertically() throw (css::uno::RuntimeException)
+{
+ sal_Bool centerVertically = sal_False;
+ try
+ {
+ uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterVertically")));
+ aValue >>= centerVertically;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return centerVertically;
+}
+
+void SAL_CALL ScVbaPageSetup::setCenterVertically( sal_Bool centerVertically) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterVertically")), uno::makeAny( centerVertically ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+sal_Bool SAL_CALL ScVbaPageSetup::getCenterHorizontally() throw (css::uno::RuntimeException)
+{
+ sal_Bool centerHorizontally = sal_False;
+ try
+ {
+ uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterHorizontally")));
+ aValue >>= centerHorizontally;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return centerHorizontally;
+}
+
+void SAL_CALL ScVbaPageSetup::setCenterHorizontally( sal_Bool centerHorizontally) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CenterHorizontally")), uno::makeAny( centerHorizontally ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+sal_Bool SAL_CALL ScVbaPageSetup::getPrintHeadings() throw (css::uno::RuntimeException)
+{
+ sal_Bool printHeadings = sal_False;
+ try
+ {
+ uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")));
+ aValue >>= printHeadings;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return printHeadings;
+}
+
+void SAL_CALL ScVbaPageSetup::setPrintHeadings( sal_Bool printHeadings) throw (css::uno::RuntimeException)
+{
+ try
+ {
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrintHeaders")), uno::makeAny( printHeadings ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+
+rtl::OUString&
+ScVbaPageSetup::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPageSetup") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaPageSetup::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PageSetup" ) );
+ }
+ return aServiceNames;
+}
+
+//liuchen 2009-12-11
+
+struct PaperSizeMap
+{
+ Paper ePaper;
+ sal_Int32 xlPaper;
+};
+
+static PaperSizeMap paperSizeMappings[] =
+{
+ { PAPER_A3, ooo::vba::excel::XlPaperSize::xlPaperA3 },
+ { PAPER_A4, ooo::vba::excel::XlPaperSize::xlPaperA4 },
+ { PAPER_A5, ooo::vba::excel::XlPaperSize::xlPaperA5 },
+ { PAPER_B4_ISO, ooo::vba::excel::XlPaperSize::xlPaperB4 },
+ { PAPER_B5_ISO, ooo::vba::excel::XlPaperSize::xlPaperB5 },
+ { PAPER_LETTER, ooo::vba::excel::XlPaperSize::xlPaperLetter },
+ { PAPER_LEGAL, ooo::vba::excel::XlPaperSize::xlPaperLegal },
+ { PAPER_TABLOID, ooo::vba::excel::XlPaperSize::xlPaperTabloid },
+ { PAPER_USER, ooo::vba::excel::XlPaperSize::xlPaperUser },
+ { PAPER_B6_ISO, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeB6 },
+ { PAPER_ENV_C4, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC4 },
+ { PAPER_ENV_C5, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC5 },
+ { PAPER_ENV_C6, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC6 },
+ { PAPER_ENV_C65, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeC65 },
+ { PAPER_ENV_DL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeDL },
+ { PAPER_C, ooo::vba::excel::XlPaperSize::xlPaperCsheet },
+ { PAPER_D, ooo::vba::excel::XlPaperSize::xlPaperDsheet },
+ { PAPER_E, ooo::vba::excel::XlPaperSize::xlPaperEsheet },
+ { PAPER_ENV_MONARCH, ooo::vba::excel::XlPaperSize::xlPaperEnvelopeMonarch },
+ { PAPER_ENV_PERSONAL, ooo::vba::excel::XlPaperSize::xlPaperEnvelopePersonal },
+ { PAPER_ENV_9, ooo::vba::excel::XlPaperSize::xlPaperEnvelope9 },
+ { PAPER_ENV_10, ooo::vba::excel::XlPaperSize::xlPaperEnvelope10 },
+ { PAPER_ENV_11, ooo::vba::excel::XlPaperSize::xlPaperEnvelope11 },
+ { PAPER_ENV_12, ooo::vba::excel::XlPaperSize::xlPaperEnvelope12 }
+};
+
+static const int nMapSize = SAL_N_ELEMENTS(paperSizeMappings);
+
+sal_Int32 PaperSizeOOoToExcel(Paper ePaper)
+{
+ sal_Int32 nPaperSize = ooo::vba::excel::XlPaperSize::xlPaperUser;
+
+ for (int i = 0; i < nMapSize; i++)
+ {
+ if (ePaper == paperSizeMappings[i].ePaper)
+ {
+ nPaperSize = paperSizeMappings[i].xlPaper;
+ break;
+ }
+ }
+
+ return nPaperSize;
+}
+
+sal_Int32 SAL_CALL ScVbaPageSetup::getPaperSize() throw (css::uno::RuntimeException)
+{
+ com::sun::star::awt::Size size;
+ Paper ePaper = PAPER_USER;
+
+ try
+ {
+ uno::Any aValue = mxPageProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Size")));
+ aValue >>= size;
+ ePaper = SvxPaperInfo::GetSvxPaper( Size(size.Width, size.Height), MAP_100TH_MM, TRUE);
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return PaperSizeOOoToExcel(ePaper);
+}
+
+Paper PaperSizeExcelToOOo( sal_Int32 xlPaper)
+{
+ Paper ePaper = PAPER_USER;
+
+ for (int i = 0; i < nMapSize; i++)
+ {
+ if (xlPaper == paperSizeMappings[i].xlPaper)
+ {
+ ePaper = paperSizeMappings[i].ePaper;
+ break;
+ }
+ }
+
+ return ePaper;
+}
+void SAL_CALL ScVbaPageSetup::setPaperSize( sal_Int32 paperSize) throw (css::uno::RuntimeException)
+{
+ Paper ePaper = PaperSizeExcelToOOo( paperSize );
+
+ try
+ {
+ Size size1 = SvxPaperInfo::GetPaperSize( ePaper, MAP_100TH_MM );
+ com::sun::star::awt::Size size(size1.Width(), size1.Height());
+ mxPageProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Size")), uno::makeAny( size ));
+ }
+ catch( uno::Exception& )
+ {
+ }
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapagesetup.hxx b/sc/source/ui/vba/vbapagesetup.hxx
new file mode 100644
index 000000000000..9fc3a5b295d6
--- /dev/null
+++ b/sc/source/ui/vba/vbapagesetup.hxx
@@ -0,0 +1,95 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PAGESETUP_HXX
+#define SC_VBA_PAGESETUP_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XPageSetup.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbapagesetupbase.hxx>
+
+typedef cppu::ImplInheritanceHelper1< VbaPageSetupBase, ov::excel::XPageSetup > ScVbaPageSetup_BASE;
+
+class ScVbaPageSetup : public ScVbaPageSetup_BASE
+{
+ css::uno::Reference< css::sheet::XSpreadsheet > mxSheet;
+public:
+ ScVbaPageSetup( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::sheet::XSpreadsheet>& xSheet,
+ const css::uno::Reference< css::frame::XModel >& xModel) throw (css::uno::RuntimeException);
+ virtual ~ScVbaPageSetup(){}
+
+ // Attribute
+ virtual rtl::OUString SAL_CALL getPrintArea() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPrintArea( const rtl::OUString& rAreas ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getHeaderMargin() throw (css::uno::RuntimeException);
+ void SAL_CALL setHeaderMargin( double margin ) throw (css::uno::RuntimeException);
+ double SAL_CALL getFooterMargin() throw (css::uno::RuntimeException);
+ void SAL_CALL setFooterMargin( double margin ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFitToPagesTall() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFitToPagesTall( const css::uno::Any& fitToPagesTall ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFitToPagesWide() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFitToPagesWide( const css::uno::Any& fitToPagesWide ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getZoom() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setZoom( const css::uno::Any& zoom ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getLeftHeader() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLeftHeader( const rtl::OUString& leftHeader ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getCenterHeader() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCenterHeader( const rtl::OUString& centerHeader ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getRightHeader() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRightHeader( const rtl::OUString& rightHeader ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getLeftFooter() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLeftFooter( const rtl::OUString& leftFooter ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getCenterFooter() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCenterFooter( const rtl::OUString& centerFooter ) throw (css::uno::RuntimeException);
+ virtual rtl::OUString SAL_CALL getRightFooter() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRightFooter( const rtl::OUString& rightFooter ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getOrder() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setOrder( sal_Int32 order ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getFirstPageNumber() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFirstPageNumber( sal_Int32 firstPageNumber ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCenterVertically() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCenterVertically( sal_Bool centerVertically ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getCenterHorizontally() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCenterHorizontally( sal_Bool centerHorizontally ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getPrintHeadings() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPrintHeadings( sal_Bool printHeadings ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPaperSize() throw (css::uno::RuntimeException); //liuchen 2009-12-11
+ virtual void SAL_CALL setPaperSize( sal_Int32 paperSize ) throw (css::uno::RuntimeException); //liuchen 2009-12-11
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapalette.cxx b/sc/source/ui/vba/vbapalette.cxx
new file mode 100644
index 000000000000..209dd2d8e564
--- /dev/null
+++ b/sc/source/ui/vba/vbapalette.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbapalette.hxx"
+
+#include <sal/macros.h>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include "excelvbahelper.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+/** Standard EGA colors, bright. */
+#define EXC_PALETTE_EGA_COLORS_LIGHT \
+ 0x000000, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF
+/** Standard EGA colors, dark. */
+#define EXC_PALETTE_EGA_COLORS_DARK \
+ 0x800000, 0x008000, 0x000080, 0x808000, 0x800080, 0x008080, 0xC0C0C0, 0x808080
+
+static const ColorData spnDefColorTable8[] =
+{
+/* 8 */ EXC_PALETTE_EGA_COLORS_LIGHT,
+/* 16 */ EXC_PALETTE_EGA_COLORS_DARK,
+/* 24 */ 0x9999FF, 0x993366, 0xFFFFCC, 0xCCFFFF, 0x660066, 0xFF8080, 0x0066CC, 0xCCCCFF,
+/* 32 */ 0x000080, 0xFF00FF, 0xFFFF00, 0x00FFFF, 0x800080, 0x800000, 0x008080, 0x0000FF,
+/* 40 */ 0x00CCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFF99, 0x99CCFF, 0xFF99CC, 0xCC99FF, 0xFFCC99,
+/* 48 */ 0x3366FF, 0x33CCCC, 0x99CC00, 0xFFCC00, 0xFF9900, 0xFF6600, 0x666699, 0x969696,
+/* 56 */ 0x003366, 0x339966, 0x003300, 0x333300, 0x993300, 0x993366, 0x333399, 0x333333
+};
+
+typedef ::cppu::WeakImplHelper1< container::XIndexAccess > XIndexAccess_BASE;
+
+class DefaultPalette : public XIndexAccess_BASE
+{
+public:
+ DefaultPalette(){}
+
+ // Methods XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException)
+ {
+ return SAL_N_ELEMENTS(spnDefColorTable8);
+ }
+
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+ return uno::makeAny( sal_Int32( spnDefColorTable8[ Index ] ) );
+ }
+
+ // Methods XElementAcess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException)
+ {
+ return ::getCppuType( (sal_Int32*)0 );
+ }
+ virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException)
+ {
+ return sal_True;
+ }
+
+};
+
+ScVbaPalette::ScVbaPalette( const uno::Reference< frame::XModel >& rxModel ) :
+ m_pShell( excel::getDocShell( rxModel ) )
+{
+}
+
+uno::Reference< container::XIndexAccess >
+ScVbaPalette::getDefaultPalette()
+{
+ return new DefaultPalette();
+}
+
+uno::Reference< container::XIndexAccess >
+ScVbaPalette::getPalette() const
+{
+ uno::Reference< container::XIndexAccess > xIndex;
+ uno::Reference< beans::XPropertySet > xProps;
+ if ( m_pShell )
+ xProps.set( m_pShell->GetModel(), uno::UNO_QUERY_THROW );
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't extract palette, no doc shell" ) ), uno::Reference< uno::XInterface >() );
+ xIndex.set( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ColorPalette") ) ), uno::UNO_QUERY );
+ if ( !xIndex.is() )
+ return new DefaultPalette();
+ return xIndex;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapalette.hxx b/sc/source/ui/vba/vbapalette.hxx
new file mode 100644
index 000000000000..a1ec16979c96
--- /dev/null
+++ b/sc/source/ui/vba/vbapalette.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBAPALETTE_HXX
+#define SC_VBAPALETTE_HXX
+
+#include <vbahelper/vbahelper.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace container { class XIndexAccess; }
+ namespace frame { class XModel; }
+} } }
+
+class SfxObjectShell;
+
+class ScVbaPalette
+{
+private:
+ SfxObjectShell* m_pShell;
+public:
+ ScVbaPalette( SfxObjectShell* pShell = 0 ) : m_pShell( pShell ) {}
+ ScVbaPalette( const css::uno::Reference< css::frame::XModel >& rxModel );
+ // if no palette available e.g. because the document doesn't have a
+ // palette defined then a default palette will be returned.
+ css::uno::Reference< css::container::XIndexAccess > getPalette() const;
+ static css::uno::Reference< css::container::XIndexAccess > getDefaultPalette();
+};
+
+#endif //SC_VBAPALETTE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapane.cxx b/sc/source/ui/vba/vbapane.cxx
new file mode 100644
index 000000000000..ee32fc3e5286
--- /dev/null
+++ b/sc/source/ui/vba/vbapane.cxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbapane.hxx"
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include "vbarange.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaPane::ScVbaPane(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< frame::XModel >& xModel,
+ const uno::Reference< sheet::XViewPane > xViewPane ) throw (uno::RuntimeException) :
+ ScVbaPane_BASE( xParent, xContext ),
+ m_xModel( xModel, uno::UNO_SET_THROW ),
+ m_xViewPane( xViewPane, uno::UNO_SET_THROW )
+{
+}
+
+sal_Int32 SAL_CALL
+ScVbaPane::getScrollColumn() throw (uno::RuntimeException)
+{
+ return ( m_xViewPane->getFirstVisibleColumn() + 1 );
+}
+
+void SAL_CALL
+ScVbaPane::setScrollColumn( sal_Int32 _scrollcolumn ) throw (uno::RuntimeException)
+{
+ if( _scrollcolumn < 1 )
+ {
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Column number should not less than 1" ),
+ uno::Reference< uno::XInterface >() );
+ }
+ m_xViewPane->setFirstVisibleColumn( _scrollcolumn - 1 );
+}
+
+sal_Int32 SAL_CALL
+ScVbaPane::getScrollRow() throw (uno::RuntimeException)
+{
+ return ( m_xViewPane->getFirstVisibleRow() + 1 );
+}
+
+void SAL_CALL
+ScVbaPane::setScrollRow( sal_Int32 _scrollrow ) throw (uno::RuntimeException)
+{
+ if( _scrollrow < 1 )
+ {
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Row number should not less than 1" ),
+ uno::Reference< uno::XInterface >() );
+ }
+ m_xViewPane->setFirstVisibleRow( _scrollrow - 1 );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaPane::getVisibleRange() throw (uno::RuntimeException)
+{
+ // TODO: Excel includes partly visible rows/columns, Calc does not
+ table::CellRangeAddress aRangeAddr = m_xViewPane->getVisibleRange();
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xSheetsIA( xDoc->getSheets(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xSheet( xSheetsIA->getByIndex( aRangeAddr.Sheet ), uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xSheet->getCellRangeByPosition( aRangeAddr.StartColumn, aRangeAddr.StartRow, aRangeAddr.EndColumn, aRangeAddr.EndRow ), uno::UNO_SET_THROW );
+ // TODO: getParent() returns the window, Range needs the worksheet
+ return new ScVbaRange( getParent(), mxContext, xRange );
+}
+
+//Method
+void SAL_CALL
+ScVbaPane::SmallScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
+{
+ rtl::OUString messageBuffer;
+ sal_Int32 downRows = 0;
+ sal_Int32 rightCols = 0;
+ table::CellRangeAddress visibleRange = m_xViewPane->getVisibleRange();
+
+ if( Down.hasValue() )
+ {
+ sal_Int32 down = 0;
+ if( Down >>= down )
+ downRows += down;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: Down\n" );
+ }
+ if( Up.hasValue() )
+ {
+ sal_Int32 up = 0;
+ if( Up >>= up )
+ downRows -= up;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: Up\n" );
+ }
+ if( ToRight.hasValue() )
+ {
+ sal_Int32 right = 0;
+ if( ToRight >>= right )
+ rightCols += right;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: ToRight\n" );
+ }
+ if( ToLeft.hasValue() )
+ {
+ sal_Int32 left = 0;
+ if( ToLeft >>= left )
+ rightCols -= left;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: ToLeft\n" );
+ }
+ if( messageBuffer.getLength() > 0 )
+ throw(uno::RuntimeException( messageBuffer, uno::Reference< uno::XInterface >() ) );
+
+ sal_Int32 newStartRow = visibleRange.StartRow + downRows;
+ if( newStartRow < 0 )
+ newStartRow = 0;
+ sal_Int32 newStartCol = visibleRange.StartColumn + rightCols;
+ if( newStartCol < 0 )
+ newStartCol = 0;
+ m_xViewPane->setFirstVisibleRow( newStartRow );
+ m_xViewPane->setFirstVisibleColumn( newStartCol );
+}
+
+void SAL_CALL
+ScVbaPane::LargeScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
+{
+ rtl::OUString messageBuffer;
+ table::CellRangeAddress visibleRange = m_xViewPane->getVisibleRange();
+
+ sal_Int32 vertPageSize = 1 + visibleRange.EndRow - visibleRange.StartRow;
+ sal_Int32 horizPageSize = 1 + visibleRange.EndColumn - visibleRange.StartColumn;
+ sal_Int32 downPages = 0;
+ sal_Int32 acrossPages = 0;
+ if( Down.hasValue() )
+ {
+ sal_Int32 down = 0;
+ if( Down >>= down )
+ downPages += down;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: Down\n" );
+ }
+ if( Up.hasValue() )
+ {
+ sal_Int32 up = 0;
+ if( Up >>= up )
+ downPages -= up;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: Up\n" );
+ }
+ if( ToRight.hasValue() )
+ {
+ sal_Int32 right = 0;
+ if( ToRight >>= right )
+ acrossPages += right;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: ToRight\n" );
+ }
+ if( ToLeft.hasValue() )
+ {
+ sal_Int32 left = 0;
+ if( ToLeft >>= left )
+ acrossPages -= left;
+ else
+ messageBuffer += rtl::OUString::createFromAscii( "Error getting parameter: ToLeft\n" );
+ }
+ if( messageBuffer.getLength() > 0 )
+ throw(uno::RuntimeException( messageBuffer, uno::Reference< uno::XInterface >() ) );
+
+ sal_Int32 newStartRow = visibleRange.StartRow + (downPages * vertPageSize );
+ if( newStartRow < 0 )
+ newStartRow = 0;
+ sal_Int32 newStartCol = visibleRange.StartColumn + (acrossPages * horizPageSize );
+ if( newStartCol < 0 )
+ newStartCol = 0;
+ m_xViewPane->setFirstVisibleRow( newStartRow );
+ m_xViewPane->setFirstVisibleColumn( newStartCol );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaPane, "ooo.vba.excel.Pane" )
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapane.hxx b/sc/source/ui/vba/vbapane.hxx
new file mode 100644
index 000000000000..841776a7d918
--- /dev/null
+++ b/sc/source/ui/vba/vbapane.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PANE_HXX
+#define SC_VBA_PANE_HXX
+
+#include <com/sun/star/sheet/XViewPane.hpp>
+#include <ooo/vba/excel/XPane.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include "excelvbahelper.hxx"
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XPane > ScVbaPane_BASE;
+
+class ScVbaPane : public ScVbaPane_BASE
+{
+public:
+ ScVbaPane(
+ const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::frame::XModel >& xModel,
+ const css::uno::Reference< css::sheet::XViewPane > xViewPane ) throw (css::uno::RuntimeException);
+
+ css::uno::Reference< css::sheet::XViewPane > getViewPane() { return m_xViewPane; }
+
+ // XPane attributes
+ virtual sal_Int32 SAL_CALL getScrollColumn() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setScrollColumn( sal_Int32 _scrollcolumn ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScrollRow() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setScrollRow( sal_Int32 _scrollrow ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getVisibleRange() throw (css::uno::RuntimeException);
+
+ // XPane methods
+ virtual void SAL_CALL SmallScroll( const css::uno::Any& Down, const css::uno::Any& Up, const css::uno::Any& ToRight, const css::uno::Any& ToLeft ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL LargeScroll( const css::uno::Any& Down, const css::uno::Any& Up, const css::uno::Any& ToRight, const css::uno::Any& ToLeft ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+protected:
+ css::uno::Reference< css::frame::XModel > m_xModel;
+ css::uno::Reference< css::sheet::XViewPane > m_xViewPane;
+};
+
+#endif //SC_VBA_PANE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapivotcache.cxx b/sc/source/ui/vba/vbapivotcache.cxx
new file mode 100644
index 000000000000..7b2b4c6ddf61
--- /dev/null
+++ b/sc/source/ui/vba/vbapivotcache.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapivotcache.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+ScVbaPivotCache::ScVbaPivotCache( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XDataPilotTable >& xTable ) : PivotCacheImpl_BASE( xParent, xContext ), m_xTable( xTable )
+{
+}
+
+sal_Int32
+ScVbaPivotCache::getMissingItemsLimit() throw (css::uno::RuntimeException)
+{
+ return -1;
+}
+
+void
+ScVbaPivotCache::setMissingItemsLimit( sal_Int32 /*aValue*/ ) throw ( css::uno::RuntimeException)
+{
+}
+
+void SAL_CALL
+ScVbaPivotCache::Refresh() throw (css::uno::RuntimeException)
+{
+ m_xTable->refresh();
+}
+rtl::OUString&
+ScVbaPivotCache::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotCache") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaPivotCache::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotCache" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapivotcache.hxx b/sc/source/ui/vba/vbapivotcache.hxx
new file mode 100644
index 000000000000..da8c7752bd46
--- /dev/null
+++ b/sc/source/ui/vba/vbapivotcache.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PIVOTCACHE_HXX
+#define SC_VBA_PIVOTCACHE_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/sheet/XDataPilotTable.hpp>
+
+#include <ooo/vba/excel/XPivotCache.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1<ov::excel::XPivotCache > PivotCacheImpl_BASE;
+
+class ScVbaPivotCache : public PivotCacheImpl_BASE
+{
+ css::uno::Reference< css::sheet::XDataPilotTable > m_xTable;
+public:
+ ScVbaPivotCache( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XDataPilotTable >& xTable );
+
+ virtual ::sal_Int32 SAL_CALL getMissingItemsLimit() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setMissingItemsLimit( ::sal_Int32 aValue ) throw ( css::uno::RuntimeException);
+
+ virtual void SAL_CALL Refresh() throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_PIVOTCACHE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapivottable.cxx b/sc/source/ui/vba/vbapivottable.cxx
new file mode 100644
index 000000000000..7d788b1ed321
--- /dev/null
+++ b/sc/source/ui/vba/vbapivottable.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapivottable.hxx"
+#include "vbapivotcache.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+ScVbaPivotTable::ScVbaPivotTable( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XDataPilotTable >& xTable ) : PivotTableImpl_BASE( uno::Reference< XHelperInterface >(), xContext), m_xTable( xTable )
+{
+}
+
+uno::Reference< excel::XPivotCache >
+ScVbaPivotTable::PivotCache() throw (uno::RuntimeException)
+{
+ // #FIXME with a quick example failed to determine what the parent
+ // should be, leaving as null at the moment
+ return new ScVbaPivotCache( uno::Reference< XHelperInterface >(), mxContext, m_xTable );
+}
+
+rtl::OUString&
+ScVbaPivotTable::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotTable") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaPivotTable::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotTable" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapivottable.hxx b/sc/source/ui/vba/vbapivottable.hxx
new file mode 100644
index 000000000000..dd7201be6170
--- /dev/null
+++ b/sc/source/ui/vba/vbapivottable.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PIVOTTABLE_HXX
+#define SC_VBA_PIVOTTABLE_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/sheet/XDataPilotTable.hpp>
+#include <ooo/vba/excel/XPivotTable.hpp>
+#include "excelvbahelper.hxx"
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XPivotTable > PivotTableImpl_BASE;
+
+class ScVbaPivotTable : public PivotTableImpl_BASE
+{
+ css::uno::Reference< css::sheet::XDataPilotTable > m_xTable;
+public:
+ ScVbaPivotTable( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XDataPilotTable >& xTable );
+ virtual css::uno::Reference< ov::excel::XPivotCache > SAL_CALL PivotCache( ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_PIVOTTABLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapivottables.cxx b/sc/source/ui/vba/vbapivottables.cxx
new file mode 100644
index 000000000000..3212ac27a1af
--- /dev/null
+++ b/sc/source/ui/vba/vbapivottables.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapivottables.hxx"
+#include "vbapivottable.hxx"
+#include <com/sun/star/sheet/XDataPilotTable.hpp>
+#include <ooo/vba/excel/XPivotTable.hpp>
+
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+uno::Any DataPilotToPivotTable( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext )
+{
+ uno::Reference< sheet::XDataPilotTable > xTable( aSource, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< excel::XPivotTable > ( new ScVbaPivotTable( xContext, xTable ) ) );
+}
+
+class PivotTableEnumeration : public EnumerationHelperImpl
+{
+public:
+ PivotTableEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ) {}
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ return DataPilotToPivotTable( m_xEnumeration->nextElement(), m_xContext );
+ }
+
+};
+
+ScVbaPivotTables::ScVbaPivotTables( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ): ScVbaPivotTables_BASE( xParent, xContext, xIndexAccess )
+{
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaPivotTables::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return new PivotTableEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration() );
+}
+
+uno::Any
+ScVbaPivotTables::createCollectionObject( const css::uno::Any& aSource )
+{
+ return DataPilotToPivotTable( aSource, mxContext );
+}
+
+uno::Type
+ScVbaPivotTables::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XPivotTable::static_type(0);
+}
+
+rtl::OUString&
+ScVbaPivotTables::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaPivotTables") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaPivotTables::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.PivotTables") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapivottables.hxx b/sc/source/ui/vba/vbapivottables.hxx
new file mode 100644
index 000000000000..c511f064b229
--- /dev/null
+++ b/sc/source/ui/vba/vbapivottables.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PIVOTTABLES_HXX
+#define SC_VBA_PIVOTTABLES_HXX
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <ooo/vba/excel/XPivotTables.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "excelvbahelper.hxx"
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+
+typedef CollTestImplHelper< ov::excel::XPivotTables > ScVbaPivotTables_BASE;
+
+class ScVbaPivotTables : public ScVbaPivotTables_BASE
+{
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+public:
+ ScVbaPivotTables( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+ virtual ~ScVbaPivotTables() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+
+ // XPivotTables
+
+ // ScVbaPivotTables_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ virtual rtl::OUString& getServiceImplName();
+
+};
+
+#endif //SC_VBA_PIVOTTABLES
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapropvalue.cxx b/sc/source/ui/vba/vbapropvalue.cxx
new file mode 100644
index 000000000000..a850ef44269b
--- /dev/null
+++ b/sc/source/ui/vba/vbapropvalue.cxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbapropvalue.hxx"
+
+using namespace com::sun::star;
+
+ScVbaPropValue::ScVbaPropValue( PropListener* pListener ) : m_pListener( pListener )
+{
+}
+
+css::uno::Any SAL_CALL
+ScVbaPropValue::getValue() throw (css::uno::RuntimeException)
+{
+ return m_pListener->getValueEvent();
+}
+
+void SAL_CALL
+ScVbaPropValue::setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException)
+{
+ m_pListener->setValueEvent( _value );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbapropvalue.hxx b/sc/source/ui/vba/vbapropvalue.hxx
new file mode 100644
index 000000000000..51608e8642ed
--- /dev/null
+++ b/sc/source/ui/vba/vbapropvalue.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_PROPVALULE_HXX
+#define SC_VBA_PROPVALULE_HXX
+#include <ooo/vba/XPropValue.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+#include "excelvbahelper.hxx"
+
+typedef ::cppu::WeakImplHelper1< ov::XPropValue > PropValueImpl_BASE;
+
+class PropListener
+{
+public:
+ virtual void setValueEvent( const css::uno::Any& value ) = 0;
+ virtual css::uno::Any getValueEvent() = 0;
+};
+
+
+class ScVbaPropValue : public PropValueImpl_BASE
+{
+ PropListener* m_pListener;
+public:
+ ScVbaPropValue( PropListener* pListener );
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const css::uno::Any& _value ) throw (css::uno::RuntimeException);
+
+ rtl::OUString SAL_CALL getDefaultPropertyName() throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
+
+};
+#endif //SC_VBA_PROPVALULE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaquerytable.cxx b/sc/source/ui/vba/vbaquerytable.cxx
new file mode 100644
index 000000000000..305c14262d3a
--- /dev/null
+++ b/sc/source/ui/vba/vbaquerytable.cxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbaquerytable.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "sfx2/lnkbase.hxx"
+#include "sfx2/linkmgr.hxx"
+#include "arealink.hxx"
+#include "vbarange.hxx"
+
+using namespace com::sun::star;
+
+
+ScVbaQueryTable::ScVbaQueryTable(const css::uno::Reference< ov::XHelperInterface >& /*xParent*/,
+ const css::uno::Reference< css::uno::XComponentContext > & /*xContext*/,
+ ScDocument *pDocument ,
+ ScVbaRange *pParent
+ )
+//:QueryTable_Base(xParent, xContext)
+{
+ m_pDocument = pDocument;
+ m_pParent = pParent;
+}
+
+ScVbaQueryTable::~ScVbaQueryTable()
+{
+
+}
+
+::sal_Bool SAL_CALL
+ScVbaQueryTable::Refresh( const ::com::sun::star::uno::Any& /*aBackgroundQuery*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+
+ //Get parent Info
+ sal_Int32 nRow = m_pParent->getRow();
+ sal_Int32 nClm = m_pParent->getColumn();
+ sal_Int16 nTab = m_pParent->getWorksheet()->getIndex() - 1; //The vba index begin from 1.
+ ScAddress crrRngAddr(nClm, nRow, nTab);
+
+ //Get link info
+ sfx2::LinkManager *pLinkMng = m_pDocument->GetLinkManager();
+ const ::sfx2::SvBaseLinks &rLinks = pLinkMng->GetLinks();
+ USHORT nCount = rLinks.Count();
+
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ::sfx2::SvBaseLink* pBase = *rLinks[i];
+ if (pBase->ISA(ScAreaLink))
+ {
+
+ ScAreaLink *pAreaLink = (ScAreaLink *)pBase;
+ const ScRange &destRange = pAreaLink->GetDestArea();
+ if (destRange.In(crrRngAddr))
+ {
+ pBase->Update();
+ }
+ }
+ }
+
+ return sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaquerytable.hxx b/sc/source/ui/vba/vbaquerytable.hxx
new file mode 100644
index 000000000000..f7deea7014cb
--- /dev/null
+++ b/sc/source/ui/vba/vbaquerytable.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright IBM Corporation 2009, 2010.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_QUERYTABLE_HXX
+#define SC_VBA_QUERYTABLE_HXX
+
+
+#include <ooo/vba/excel/XQueryTable.hpp>
+#include "vbahelper/vbahelperinterface.hxx"
+
+using namespace ::ooo::vba;
+typedef ::cppu::WeakImplHelper1<excel::XQueryTable> QueryTable_Base;
+
+class ScDocument;
+class ScVbaRange;
+
+class ScVbaQueryTable : public QueryTable_Base
+{
+private:
+ ScDocument *m_pDocument;
+ ScVbaRange *m_pParent;
+public:
+ ScVbaQueryTable(const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext > & xContext,
+ ScDocument *pDocument = NULL,
+ ScVbaRange *pParent = NULL
+ );
+ ~ScVbaQueryTable();
+ virtual ::sal_Bool SAL_CALL Refresh( const ::com::sun::star::uno::Any& aBackgroundQuery )
+ throw (::com::sun::star::uno::RuntimeException);
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
new file mode 100644
index 000000000000..c9dce622bf36
--- /dev/null
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -0,0 +1,6239 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+
+#include <comphelper/unwrapargs.hxx>
+#include <comphelper/processfactory.hxx>
+#include <sfx2/objsh.hxx>
+
+#include <com/sun/star/script/ArrayWrapper.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/sheet/XGoalSeek.hpp>
+#include <com/sun/star/sheet/XSheetOperation.hpp>
+#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/table/CellContentType.hpp>
+#include <com/sun/star/sheet/XCellSeries.hpp>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSheetCellCursor.hpp>
+#include <com/sun/star/sheet/XArrayFormulaRange.hpp>
+#include <com/sun/star/sheet/XNamedRange.hpp>
+#include <com/sun/star/sheet/XNamedRanges.hpp>
+#include <com/sun/star/sheet/XPrintAreas.hpp>
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XFunctionAccess.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include <com/sun/star/table/XCellCursor.hpp>
+#include <com/sun/star/table/XTableRows.hpp>
+#include <com/sun/star/table/XTableColumns.hpp>
+#include <com/sun/star/table/TableSortField.hpp>
+#include <com/sun/star/util/XMergeable.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/util/XNumberFormats.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/util/XReplaceable.hpp>
+#include <com/sun/star/util/XSortable.hpp>
+#include <com/sun/star/sheet/XCellRangeMovement.hpp>
+#include <com/sun/star/sheet/XCellRangeData.hpp>
+#include <com/sun/star/sheet/FormulaResult.hpp>
+#include <com/sun/star/sheet/FilterOperator2.hpp>
+#include <com/sun/star/sheet/TableFilterField.hpp>
+#include <com/sun/star/sheet/TableFilterField2.hpp>
+#include <com/sun/star/sheet/XSheetFilterDescriptor2.hpp>
+#include <com/sun/star/sheet/XSheetFilterable.hpp>
+#include <com/sun/star/sheet/FilterConnection.hpp>
+#include <com/sun/star/util/CellProtection.hpp>
+#include <com/sun/star/util/TriState.hpp>
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/awt/XDevice.hpp>
+
+#include <com/sun/star/sheet/XCellRangeMovement.hpp>
+#include <com/sun/star/sheet/XSubTotalCalculatable.hpp>
+#include <com/sun/star/sheet/XSubTotalDescriptor.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hdl>
+
+#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
+#include <com/sun/star/sheet/XSheetAnnotations.hpp>
+
+#include <com/sun/star/sheet/XDataPilotTable.hpp>
+#include <com/sun/star/sheet/XDataPilotTable2.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
+
+#include <ooo/vba/excel/XlPasteSpecialOperation.hpp>
+#include <ooo/vba/excel/XlPasteType.hpp>
+#include <ooo/vba/excel/Constants.hpp>
+#include <ooo/vba/excel/XlFindLookIn.hpp>
+#include <ooo/vba/excel/XlLookAt.hpp>
+#include <ooo/vba/excel/XlSearchOrder.hpp>
+#include <ooo/vba/excel/XlSortOrder.hpp>
+#include <ooo/vba/excel/XlYesNoGuess.hpp>
+#include <ooo/vba/excel/XlSortOrientation.hpp>
+#include <ooo/vba/excel/XlSortMethod.hpp>
+#include <ooo/vba/excel/XlDirection.hpp>
+#include <ooo/vba/excel/XlSortDataOption.hpp>
+#include <ooo/vba/excel/XlDeleteShiftDirection.hpp>
+#include <ooo/vba/excel/XlInsertShiftDirection.hpp>
+#include <ooo/vba/excel/XlReferenceStyle.hpp>
+#include <ooo/vba/excel/XlBordersIndex.hpp>
+#include <ooo/vba/excel/XlPageBreak.hpp>
+#include <ooo/vba/excel/XlAutoFilterOperator.hpp>
+#include <ooo/vba/excel/XlAutoFillType.hpp>
+#include <ooo/vba/excel/XlTextParsingType.hpp>
+#include <ooo/vba/excel/XlTextQualifier.hpp>
+#include <ooo/vba/excel/XlCellType.hpp>
+#include <ooo/vba/excel/XlSpecialCellsValue.hpp>
+#include <ooo/vba/excel/XlConsolidationFunction.hpp>
+#include <ooo/vba/excel/XlSearchDirection.hpp>
+#include <ooo/vba/excel/XlColumnDataType.hpp>
+#include <ooo/vba/excel/XlFilterAction.hpp>
+
+#include <scitems.hxx>
+#include <svl/srchitem.hxx>
+#include <cellsuno.hxx>
+#include <dbcolect.hxx>
+#include "docfunc.hxx"
+#include <docuno.hxx>
+
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/itemwrapper.hxx>
+#include <sc.hrc>
+#include <globstr.hrc>
+#include <unonames.hxx>
+#include <tools/stream.hxx>
+
+#include "vbarange.hxx"
+#include "vbafont.hxx"
+#include "vbacomment.hxx"
+#include "vbainterior.hxx"
+#include "vbacharacters.hxx"
+#include "vbaborders.hxx"
+#include "vbaworksheet.hxx"
+#include "vbavalidation.hxx"
+#include "vbahyperlinks.hxx"
+
+#include "vbapivottable.hxx"
+
+#include "asciiopt.hxx"
+#include "impex.hxx"
+#include "tabvwsh.hxx"
+#include "rangelst.hxx"
+#include "rangenam.hxx"
+#include "convuno.hxx"
+#include "compiler.hxx"
+#include "attrib.hxx"
+#include "undodat.hxx"
+#include "dbdocfun.hxx"
+#include "patattr.hxx"
+#include "olinetab.hxx"
+#include <comphelper/anytostring.hxx>
+
+#include <global.hxx>
+
+#include "vbaglobals.hxx"
+#include "vbastyle.hxx"
+#include "vbaname.hxx"
+#include "vbanames.hxx"
+#include <vector>
+#include <vbahelper/vbacollectionimpl.hxx>
+// begin test includes
+#include <com/sun/star/sheet/FunctionArgument.hpp>
+// end test includes
+
+#include <ooo/vba/excel/Range.hpp>
+#include <com/sun/star/bridge/oleautomation/Date.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+using ::std::vector;
+
+// * 1 point = 1/72 inch = 20 twips
+// * 1 inch = 72 points = 1440 twips
+// * 1 cm = 567 twips
+double lcl_hmmToPoints( double nVal ) { return ( (double)((nVal /1000 ) * 567 ) / 20 ); }
+
+static const sal_Int16 supportedIndexTable[] = { excel::XlBordersIndex::xlEdgeLeft, excel::XlBordersIndex::xlEdgeTop, excel::XlBordersIndex::xlEdgeBottom, excel::XlBordersIndex::xlEdgeRight, excel::XlBordersIndex::xlDiagonalDown, excel::XlBordersIndex::xlDiagonalUp, excel::XlBordersIndex::xlInsideVertical, excel::XlBordersIndex::xlInsideHorizontal };
+
+USHORT lcl_pointsToTwips( double nVal )
+{
+ nVal = nVal * static_cast<double>(20);
+ short nTwips = static_cast<short>(nVal);
+ return nTwips;
+}
+double lcl_TwipsToPoints( USHORT nVal )
+{
+ double nPoints = nVal;
+ return nPoints / 20;
+}
+
+double lcl_Round2DecPlaces( double nVal )
+{
+ nVal = (nVal * (double)100);
+ long tmp = static_cast<long>(nVal);
+ if ( ( ( nVal - tmp ) >= 0.5 ) )
+ ++tmp;
+ nVal = tmp;
+ nVal = nVal/100;
+ return nVal;
+}
+
+uno::Any lcl_makeRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any aAny, bool bIsRows, bool bIsColumns )
+{
+ uno::Reference< table::XCellRange > xCellRange( aAny, uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xCellRange, bIsRows, bIsColumns ) ) );
+}
+
+uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSheetCellRanges >& xLocSheetCellRanges, ScDocShell* pDoc )
+{
+ uno::Reference< excel::XRange > xRange;
+ uno::Sequence< table::CellRangeAddress > sAddresses = xLocSheetCellRanges->getRangeAddresses();
+ ScRangeList aCellRanges;
+ sal_Int32 nLen = sAddresses.getLength();
+ if ( nLen )
+ {
+ for ( sal_Int32 index = 0; index < nLen; ++index )
+ {
+ ScRange refRange;
+ ScUnoConversion::FillScRange( refRange, sAddresses[ index ] );
+ aCellRanges.Append( refRange );
+ }
+ // Single range
+ if ( aCellRanges.First() == aCellRanges.Last() )
+ {
+ uno::Reference< table::XCellRange > xTmpRange( new ScCellRangeObj( pDoc, *aCellRanges.First() ) );
+ xRange = new ScVbaRange( xParent, xContext, xTmpRange );
+ }
+ else
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDoc, aCellRanges ) );
+ xRange = new ScVbaRange( xParent, xContext, xRanges );
+ }
+ }
+ return xRange;
+}
+
+ScCellRangesBase* ScVbaRange::getCellRangesBase() throw ( uno::RuntimeException )
+{
+ if( mxRanges.is() )
+ return ScCellRangesBase::getImplementation( mxRanges );
+ if( mxRange.is() )
+ return ScCellRangesBase::getImplementation( mxRange );
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("General Error creating range - Unknown" ), uno::Reference< uno::XInterface >() );
+}
+
+ScCellRangeObj* ScVbaRange::getCellRangeObj() throw ( uno::RuntimeException )
+{
+ return dynamic_cast< ScCellRangeObj* >( getCellRangesBase() );
+}
+
+ScCellRangesObj* ScVbaRange::getCellRangesObj() throw ( uno::RuntimeException )
+{
+ return dynamic_cast< ScCellRangesObj* >( getCellRangesBase() );
+}
+
+SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException )
+{
+ SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( getCellRangesBase() );
+ if ( !pDataSet )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't access Itemset for range" ) ), uno::Reference< uno::XInterface >() );
+ return pDataSet;
+}
+
+class SingleRangeEnumeration : public EnumerationHelper_BASE
+{
+ uno::Reference< XHelperInterface > m_xParent;
+ uno::Reference< table::XCellRange > m_xRange;
+ uno::Reference< uno::XComponentContext > mxContext;
+ bool bHasMore;
+public:
+
+ SingleRangeEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xRange( xRange ), mxContext( xContext ), bHasMore( true ) { }
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) { return bHasMore; }
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !bHasMore )
+ throw container::NoSuchElementException();
+ bHasMore = false;
+ return uno::makeAny( m_xRange );
+ }
+};
+
+// very simple class to pass to ScVbaCollectionBaseImpl containing
+// just one item
+typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumerationAccess > SingleRange_BASE;
+
+class SingleRangeIndexAccess : public SingleRange_BASE
+{
+private:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< table::XCellRange > m_xRange;
+ uno::Reference< uno::XComponentContext > mxContext;
+ SingleRangeIndexAccess(); // not defined
+public:
+ SingleRangeIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ):mxParent( xParent ), m_xRange( xRange ), mxContext( xContext ) {}
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount() throw (::uno::RuntimeException) { return 1; }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index != 0 )
+ throw lang::IndexOutOfBoundsException();
+ return uno::makeAny( m_xRange );
+ }
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException){ return table::XCellRange::static_type(0); }
+
+ virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException) { return sal_True; }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException) { return new SingleRangeEnumeration( mxParent, mxContext, m_xRange ); }
+
+};
+
+
+
+class RangesEnumerationImpl : public EnumerationHelperImpl
+{
+ bool mbIsRows;
+ bool mbIsColumns;
+public:
+
+ RangesEnumerationImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, bool bIsRows, bool bIsColumns ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {}
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ return lcl_makeRange( m_xParent, m_xContext, m_xEnumeration->nextElement(), mbIsRows, mbIsColumns );
+ }
+};
+
+
+class ScVbaRangeAreas : public ScVbaCollectionBaseImpl
+{
+ bool mbIsRows;
+ bool mbIsColumns;
+public:
+ ScVbaRangeAreas( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, bool bIsRows, bool bIsColumns ) : ScVbaCollectionBaseImpl( xParent, xContext, xIndexAccess ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {}
+
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException){ return excel::XRange::static_type(0); }
+
+ virtual uno::Any createCollectionObject( const uno::Any& aSource );
+
+ virtual rtl::OUString& getServiceImplName() { static rtl::OUString sDummy; return sDummy; }
+
+ virtual uno::Sequence< rtl::OUString > getServiceNames() { return uno::Sequence< rtl::OUString >(); }
+
+};
+
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaRangeAreas::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return new RangesEnumerationImpl( mxParent, mxContext, xEnumAccess->createEnumeration(), mbIsRows, mbIsColumns );
+}
+
+uno::Any
+ScVbaRangeAreas::createCollectionObject( const uno::Any& aSource )
+{
+ return lcl_makeRange( mxParent, mxContext, aSource, mbIsRows, mbIsColumns );
+}
+
+ScDocument*
+ScVbaRange::getScDocument() throw (uno::RuntimeException)
+{
+ if ( mxRanges.is() )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ return excel::GetDocumentFromRange( xRange );
+ }
+ return excel::GetDocumentFromRange( mxRange );
+}
+
+ScDocShell*
+ScVbaRange::getScDocShell() throw (uno::RuntimeException)
+{
+ if ( mxRanges.is() )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ return excel::GetDocShellFromRange( xRange );
+ }
+ return excel::GetDocShellFromRange( mxRange );
+}
+
+/*static*/ ScVbaRange* ScVbaRange::getImplementation( const uno::Reference< excel::XRange >& rxRange )
+{
+ // FIXME: always save to use dynamic_cast? Or better to (implement and) use XTunnel?
+ return dynamic_cast< ScVbaRange* >( rxRange.get() );
+}
+
+uno::Reference< frame::XModel > ScVbaRange::getUnoModel() throw (uno::RuntimeException)
+{
+ if( ScDocShell* pDocShell = getScDocShell() )
+ return pDocShell->GetModel();
+ throw uno::RuntimeException();
+}
+
+/*static*/ uno::Reference< frame::XModel > ScVbaRange::getUnoModel( const uno::Reference< excel::XRange >& rxRange ) throw (uno::RuntimeException)
+{
+ if( ScVbaRange* pScVbaRange = getImplementation( rxRange ) )
+ return pScVbaRange->getUnoModel();
+ throw uno::RuntimeException();
+}
+
+const ScRangeList& ScVbaRange::getScRangeList() throw (uno::RuntimeException)
+{
+ if( ScCellRangesBase* pScRangesBase = getCellRangesBase() )
+ return pScRangesBase->GetRangeList();
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain UNO range implementation object" ) ), uno::Reference< uno::XInterface >() );
+}
+
+/*static*/ const ScRangeList& ScVbaRange::getScRangeList( const uno::Reference< excel::XRange >& rxRange ) throw (uno::RuntimeException)
+{
+ if( ScVbaRange* pScVbaRange = getImplementation( rxRange ) )
+ return pScVbaRange->getScRangeList();
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain VBA range implementation object" ) ), uno::Reference< uno::XInterface >() );
+}
+
+
+class NumFormatHelper
+{
+ uno::Reference< util::XNumberFormatsSupplier > mxSupplier;
+ uno::Reference< beans::XPropertySet > mxRangeProps;
+ uno::Reference< util::XNumberFormats > mxFormats;
+public:
+ NumFormatHelper( const uno::Reference< table::XCellRange >& xRange )
+ {
+ mxSupplier.set( excel::GetModelFromRange( xRange ), uno::UNO_QUERY_THROW );
+ mxRangeProps.set( xRange, uno::UNO_QUERY_THROW);
+ mxFormats = mxSupplier->getNumberFormats();
+ }
+ uno::Reference< beans::XPropertySet > getNumberProps()
+ {
+ long nIndexKey = 0;
+ uno::Any aValue = mxRangeProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberFormat")));
+ aValue >>= nIndexKey;
+
+ if ( mxFormats.is() )
+ return mxFormats->getByKey( nIndexKey );
+ return uno::Reference< beans::XPropertySet > ();
+ }
+
+ bool isBooleanType()
+ {
+
+ if ( getNumberFormat() & util::NumberFormat::LOGICAL )
+ return true;
+ return false;
+ }
+
+ bool isDateType()
+ {
+ sal_Int16 nType = getNumberFormat();
+ if(( nType & util::NumberFormat::DATETIME ))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ rtl::OUString getNumberFormatString()
+ {
+ uno::Reference< uno::XInterface > xIf( mxRangeProps, uno::UNO_QUERY_THROW );
+ ScCellRangesBase* pUnoCellRange = ScCellRangesBase::getImplementation( xIf );
+ if ( pUnoCellRange )
+ {
+
+ SfxItemSet* pDataSet = excel::ScVbaCellRangeAccess::GetDataSet( pUnoCellRange );
+ SfxItemState eState = pDataSet->GetItemState( ATTR_VALUE_FORMAT, TRUE, NULL);
+ // one of the cells in the range is not like the other ;-)
+ // so return a zero length format to indicate that
+ if ( eState == SFX_ITEM_DONTCARE )
+ return rtl::OUString();
+ }
+
+
+ uno::Reference< beans::XPropertySet > xNumberProps( getNumberProps(), uno::UNO_QUERY_THROW );
+ ::rtl::OUString aFormatString;
+ uno::Any aString = xNumberProps->getPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FormatString")));
+ aString >>= aFormatString;
+ return aFormatString;
+ }
+
+ sal_Int16 getNumberFormat()
+ {
+ uno::Reference< beans::XPropertySet > xNumberProps = getNumberProps();
+ sal_Int16 nType = ::comphelper::getINT16(
+ xNumberProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) );
+ return nType;
+ }
+
+ bool setNumberFormat( const rtl::OUString& rFormat )
+ {
+ lang::Locale aLocale;
+ uno::Reference< beans::XPropertySet > xNumProps = getNumberProps();
+ xNumProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale;
+ sal_Int32 nNewIndex = mxFormats->queryKey(rFormat, aLocale, false );
+ if ( nNewIndex == -1 ) // format not defined
+ {
+ nNewIndex = mxFormats->addNew( rFormat, aLocale );
+ }
+ mxRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberFormat") ), uno::makeAny( nNewIndex ) );
+ return true;
+ }
+
+ bool setNumberFormat( sal_Int16 nType )
+ {
+ uno::Reference< beans::XPropertySet > xNumberProps = getNumberProps();
+ lang::Locale aLocale;
+ xNumberProps->getPropertyValue( ::rtl::OUString::createFromAscii( "Locale" ) ) >>= aLocale;
+ uno::Reference<util::XNumberFormatTypes> xTypes( mxFormats, uno::UNO_QUERY );
+ if ( xTypes.is() )
+ {
+ sal_Int32 nNewIndex = xTypes->getStandardFormat( nType, aLocale );
+ mxRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NumberFormat") ), uno::makeAny( nNewIndex ) );
+ return true;
+ }
+ return false;
+ }
+
+};
+
+struct CellPos
+{
+ CellPos():m_nRow(-1), m_nCol(-1), m_nArea(0) {};
+ CellPos( sal_Int32 nRow, sal_Int32 nCol, sal_Int32 nArea ):m_nRow(nRow), m_nCol(nCol), m_nArea( nArea ) {};
+sal_Int32 m_nRow;
+sal_Int32 m_nCol;
+sal_Int32 m_nArea;
+};
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > CellsEnumeration_BASE;
+typedef ::std::vector< CellPos > vCellPos;
+
+// #FIXME - QUICK
+// we could probably could and should modify CellsEnumeration below
+// to handle rows and columns ( but I do this seperately for now
+// and.. this class only handles singe areas ( does it have to handle
+// multi area ranges?? )
+class ColumnsRowEnumeration: public CellsEnumeration_BASE
+{
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< excel::XRange > mxRange;
+ sal_Int32 mMaxElems;
+ sal_Int32 mCurElem;
+
+public:
+ ColumnsRowEnumeration( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< excel::XRange >& xRange, sal_Int32 nElems ) : mxContext( xContext ), mxRange( xRange ), mMaxElems( nElems ), mCurElem( 0 )
+ {
+ }
+
+ virtual ::sal_Bool SAL_CALL hasMoreElements() throw (::uno::RuntimeException){ return mCurElem < mMaxElems; }
+
+ virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ throw container::NoSuchElementException();
+ sal_Int32 vbaIndex = 1 + mCurElem++;
+ return uno::makeAny( mxRange->Item( uno::makeAny( vbaIndex ), uno::Any() ) );
+ }
+};
+
+class CellsEnumeration : public CellsEnumeration_BASE
+{
+ uno::WeakReference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< XCollection > m_xAreas;
+ vCellPos m_CellPositions;
+ vCellPos::const_iterator m_it;
+
+ uno::Reference< table::XCellRange > getArea( sal_Int32 nVBAIndex ) throw ( uno::RuntimeException )
+ {
+ if ( nVBAIndex < 1 || nVBAIndex > m_xAreas->getCount() )
+ throw uno::RuntimeException();
+ uno::Reference< excel::XRange > xRange( m_xAreas->Item( uno::makeAny(nVBAIndex), uno::Any() ), uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xCellRange( ScVbaRange::getCellRange( xRange ), uno::UNO_QUERY_THROW );
+ return xCellRange;
+ }
+
+ void populateArea( sal_Int32 nVBAIndex )
+ {
+ uno::Reference< table::XCellRange > xRange = getArea( nVBAIndex );
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(xRange, uno::UNO_QUERY_THROW );
+ sal_Int32 nRowCount = xColumnRowRange->getRows()->getCount();
+ sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount();
+ for ( sal_Int32 i=0; i<nRowCount; ++i )
+ {
+ for ( sal_Int32 j=0; j<nColCount; ++j )
+ m_CellPositions.push_back( CellPos( i,j,nVBAIndex ) );
+ }
+ }
+public:
+ CellsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCollection >& xAreas ): mxParent( xParent ), mxContext( xContext ), m_xAreas( xAreas )
+ {
+ sal_Int32 nItems = m_xAreas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ populateArea( index );
+ }
+ m_it = m_CellPositions.begin();
+ }
+ virtual ::sal_Bool SAL_CALL hasMoreElements() throw (::uno::RuntimeException){ return m_it != m_CellPositions.end(); }
+
+ virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ throw container::NoSuchElementException();
+ CellPos aPos = *(m_it)++;
+
+ uno::Reference< table::XCellRange > xRangeArea = getArea( aPos.m_nArea );
+ uno::Reference< table::XCellRange > xCellRange( xRangeArea->getCellByPosition( aPos.m_nCol, aPos.m_nRow ), uno::UNO_QUERY_THROW );
+ return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, xCellRange ) ) );
+
+ }
+};
+
+
+const static ::rtl::OUString ISVISIBLE( RTL_CONSTASCII_USTRINGPARAM( "IsVisible"));
+const static ::rtl::OUString WIDTH( RTL_CONSTASCII_USTRINGPARAM( "Width"));
+const static ::rtl::OUString HEIGHT( RTL_CONSTASCII_USTRINGPARAM( "Height"));
+const static ::rtl::OUString POSITION( RTL_CONSTASCII_USTRINGPARAM( "Position"));
+const static rtl::OUString EQUALS( RTL_CONSTASCII_USTRINGPARAM("=") );
+const static rtl::OUString NOTEQUALS( RTL_CONSTASCII_USTRINGPARAM("<>") );
+const static rtl::OUString GREATERTHAN( RTL_CONSTASCII_USTRINGPARAM(">") );
+const static rtl::OUString GREATERTHANEQUALS( RTL_CONSTASCII_USTRINGPARAM(">=") );
+const static rtl::OUString LESSTHAN( RTL_CONSTASCII_USTRINGPARAM("<") );
+const static rtl::OUString LESSTHANEQUALS( RTL_CONSTASCII_USTRINGPARAM("<=") );
+const static rtl::OUString CONTS_HEADER( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader" ));
+const static rtl::OUString INSERTPAGEBREAKS( RTL_CONSTASCII_USTRINGPARAM("InsertPageBreaks" ));
+const static rtl::OUString STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY( RTL_CONSTASCII_USTRINGPARAM("The command you chose cannot be performed with multiple selections.\nSelect a single range and click the command again") );
+const static rtl::OUString STR_ERRORMESSAGE_NOCELLSWEREFOUND( RTL_CONSTASCII_USTRINGPARAM("No cells were found") );
+const static rtl::OUString STR_ERRORMESSAGE_APPLIESTOROWCOLUMNSONLY( RTL_CONSTASCII_USTRINGPARAM("Property only applicable for Columns and Rows") );
+const static rtl::OUString CELLSTYLE( RTL_CONSTASCII_USTRINGPARAM("CellStyle") );
+
+class CellValueSetter : public ValueSetter
+{
+protected:
+ uno::Any maValue;
+ uno::TypeClass mTypeClass;
+public:
+ CellValueSetter( const uno::Any& aValue );
+ virtual bool processValue( const uno::Any& aValue, const uno::Reference< table::XCell >& xCell );
+ virtual void visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell );
+
+};
+
+CellValueSetter::CellValueSetter( const uno::Any& aValue ): maValue( aValue ), mTypeClass( aValue.getValueTypeClass() ) {}
+
+void
+CellValueSetter::visitNode( sal_Int32 /*i*/, sal_Int32 /*j*/, const uno::Reference< table::XCell >& xCell )
+{
+ processValue( maValue, xCell );
+}
+
+bool
+CellValueSetter::processValue( const uno::Any& aValue, const uno::Reference< table::XCell >& xCell )
+{
+
+ bool isExtracted = false;
+ switch ( aValue.getValueTypeClass() )
+ {
+ case uno::TypeClass_BOOLEAN:
+ {
+ sal_Bool bState = sal_False;
+ if ( aValue >>= bState )
+ {
+ uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW );
+ if ( bState )
+ xCell->setValue( (double) 1 );
+ else
+ xCell->setValue( (double) 0 );
+ NumFormatHelper cellNumFormat( xRange );
+ cellNumFormat.setNumberFormat( util::NumberFormat::LOGICAL );
+ }
+ break;
+ }
+ case uno::TypeClass_STRING:
+ {
+ rtl::OUString aString;
+ if ( aValue >>= aString )
+ {
+ uno::Reference< text::XTextRange > xTextRange( xCell, uno::UNO_QUERY_THROW );
+ xTextRange->setString( aString );
+ }
+ else
+ isExtracted = false;
+ break;
+ }
+ default:
+ {
+ double nDouble = 0.0;
+ if ( aValue >>= nDouble )
+ {
+ xCell->setValue( nDouble );
+ uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW );
+ NumFormatHelper cellNumFormat( xRange );
+ if ( cellNumFormat.isBooleanType() )
+ {
+ cellNumFormat.setNumberFormat( util::NumberFormat::NUMBER );
+ }
+ }
+ else
+ isExtracted = false;
+ break;
+ }
+ }
+ return isExtracted;
+
+}
+
+
+class CellValueGetter : public ValueGetter
+{
+protected:
+ uno::Any maValue;
+ uno::TypeClass mTypeClass;
+public:
+ CellValueGetter() {}
+ virtual void visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell );
+ virtual void processValue( sal_Int32 x, sal_Int32 y, const uno::Any& aValue );
+ const uno::Any& getValue() const { return maValue; }
+
+};
+
+void
+CellValueGetter::processValue( sal_Int32 /*x*/, sal_Int32 /*y*/, const uno::Any& aValue )
+{
+ maValue = aValue;
+}
+void CellValueGetter::visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell )
+{
+ uno::Any aValue;
+ table::CellContentType eType = xCell->getType();
+ if( eType == table::CellContentType_VALUE || eType == table::CellContentType_FORMULA )
+ {
+ if ( eType == table::CellContentType_FORMULA )
+ {
+
+ rtl::OUString sFormula = xCell->getFormula();
+ if ( sFormula.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=TRUE()") ) ) )
+ aValue <<= sal_True;
+ else if ( sFormula.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("=FALSE()") ) ) )
+ aValue <<= sal_False;
+ else
+ {
+ uno::Reference< beans::XPropertySet > xProp( xCell, uno::UNO_QUERY_THROW );
+
+ table::CellContentType eFormulaType = table::CellContentType_VALUE;
+ // some formulas give textual results
+ xProp->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FormulaResultType" ) ) ) >>= eFormulaType;
+
+ if ( eFormulaType == table::CellContentType_TEXT )
+ {
+ uno::Reference< text::XTextRange > xTextRange(xCell, ::uno::UNO_QUERY_THROW);
+ aValue <<= xTextRange->getString();
+ }
+ else
+ aValue <<= xCell->getValue();
+ }
+ }
+ else
+ {
+ uno::Reference< table::XCellRange > xRange( xCell, uno::UNO_QUERY_THROW );
+ NumFormatHelper cellFormat( xRange );
+ if ( cellFormat.isBooleanType() )
+ aValue = uno::makeAny( ( xCell->getValue() != 0.0 ) );
+ else if ( cellFormat.isDateType() )
+ aValue = uno::makeAny( bridge::oleautomation::Date( xCell->getValue() ) );
+ else
+ aValue <<= xCell->getValue();
+ }
+ }
+ if( eType == table::CellContentType_TEXT )
+ {
+ uno::Reference< text::XTextRange > xTextRange(xCell, ::uno::UNO_QUERY_THROW);
+ aValue <<= xTextRange->getString();
+ }
+ processValue( x,y,aValue );
+}
+
+class CellFormulaValueSetter : public CellValueSetter
+{
+private:
+ ScDocument* m_pDoc;
+ formula::FormulaGrammar::Grammar m_eGrammar;
+public:
+ CellFormulaValueSetter( const uno::Any& aValue, ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ):CellValueSetter( aValue ), m_pDoc( pDoc ), m_eGrammar( eGram ){}
+protected:
+ bool processValue( const uno::Any& aValue, const uno::Reference< table::XCell >& xCell )
+ {
+ rtl::OUString sFormula;
+ double aDblValue = 0.0;
+ if ( aValue >>= sFormula )
+ {
+ // convert to GRAM_PODF_A1 style grammar because XCell::setFormula
+ // always compile it in that grammar. Perhaps
+ // css.sheet.FormulaParser should be used in future to directly
+ // pass formula tokens when that API stabilizes.
+ if ( m_eGrammar != formula::FormulaGrammar::GRAM_PODF_A1 && ( sFormula.trim().indexOf('=') == 0 ) )
+ {
+ uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW );
+ ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() );
+ if ( pUnoRangesBase )
+ {
+ ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+ ScCompiler aCompiler( m_pDoc, aCellRanges.First()->aStart );
+ aCompiler.SetGrammar(m_eGrammar);
+ // compile the string in the format passed in
+ aCompiler.CompileString( sFormula );
+ // set desired convention to that of the document
+ aCompiler.SetGrammar( formula::FormulaGrammar::GRAM_PODF_A1 );
+ String sConverted;
+ aCompiler.CreateStringFromTokenArray(sConverted);
+ sFormula = EQUALS + sConverted;
+ }
+ }
+
+ xCell->setFormula( sFormula );
+ return true;
+ }
+ else if ( aValue >>= aDblValue )
+ {
+ xCell->setValue( aDblValue );
+ return true;
+ }
+ return false;
+ }
+
+};
+
+class CellFormulaValueGetter : public CellValueGetter
+{
+private:
+ ScDocument* m_pDoc;
+ formula::FormulaGrammar::Grammar m_eGrammar;
+public:
+ CellFormulaValueGetter(ScDocument* pDoc, formula::FormulaGrammar::Grammar eGram ) : CellValueGetter( ), m_pDoc( pDoc ), m_eGrammar( eGram ) {}
+ virtual void visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell )
+ {
+ uno::Any aValue;
+ aValue <<= xCell->getFormula();
+ rtl::OUString sVal;
+ aValue >>= sVal;
+ uno::Reference< uno::XInterface > xIf( xCell, uno::UNO_QUERY_THROW );
+ ScCellRangesBase* pUnoRangesBase = dynamic_cast< ScCellRangesBase* >( xIf.get() );
+ if ( ( xCell->getType() == table::CellContentType_FORMULA ) &&
+ pUnoRangesBase )
+ {
+ ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+ ScCompiler aCompiler( m_pDoc, aCellRanges.First()->aStart );
+ aCompiler.SetGrammar(formula::FormulaGrammar::GRAM_DEFAULT);
+ aCompiler.CompileString( sVal );
+ // set desired convention
+ aCompiler.SetGrammar( m_eGrammar );
+ String sConverted;
+ aCompiler.CreateStringFromTokenArray(sConverted);
+ sVal = EQUALS + sConverted;
+ aValue <<= sVal;
+ }
+
+ processValue( x,y,aValue );
+ }
+
+};
+
+
+class Dim2ArrayValueGetter : public ArrayVisitor
+{
+protected:
+ uno::Any maValue;
+ ValueGetter& mValueGetter;
+ virtual void processValue( sal_Int32 x, sal_Int32 y, const uno::Any& aValue )
+ {
+ uno::Sequence< uno::Sequence< uno::Any > >& aMatrix = *( uno::Sequence< uno::Sequence< uno::Any > >* )( maValue.getValue() );
+ aMatrix[x][y] = aValue;
+ }
+
+public:
+ Dim2ArrayValueGetter(sal_Int32 nRowCount, sal_Int32 nColCount, ValueGetter& rValueGetter ): mValueGetter(rValueGetter)
+ {
+ uno::Sequence< uno::Sequence< uno::Any > > aMatrix;
+ aMatrix.realloc( nRowCount );
+ for ( sal_Int32 index = 0; index < nRowCount; ++index )
+ aMatrix[index].realloc( nColCount );
+ maValue <<= aMatrix;
+ }
+ void visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell )
+
+ {
+ mValueGetter.visitNode( x, y, xCell );
+ processValue( x, y, mValueGetter.getValue() );
+ }
+ const uno::Any& getValue() const { return maValue; }
+
+};
+
+const static rtl::OUString sNA = rtl::OUString::createFromAscii("#N/A");
+
+class Dim1ArrayValueSetter : public ArrayVisitor
+{
+ uno::Sequence< uno::Any > aMatrix;
+ sal_Int32 nColCount;
+ ValueSetter& mCellValueSetter;
+public:
+ Dim1ArrayValueSetter( const uno::Any& aValue, ValueSetter& rCellValueSetter ):mCellValueSetter( rCellValueSetter )
+ {
+ aValue >>= aMatrix;
+ nColCount = aMatrix.getLength();
+ }
+ virtual void visitNode( sal_Int32 /*x*/, sal_Int32 y, const uno::Reference< table::XCell >& xCell )
+ {
+ if ( y < nColCount )
+ mCellValueSetter.processValue( aMatrix[ y ], xCell );
+ else
+ mCellValueSetter.processValue( uno::makeAny( sNA ), xCell );
+ }
+};
+
+
+
+class Dim2ArrayValueSetter : public ArrayVisitor
+{
+ uno::Sequence< uno::Sequence< uno::Any > > aMatrix;
+ ValueSetter& mCellValueSetter;
+ sal_Int32 nRowCount;
+ sal_Int32 nColCount;
+public:
+ Dim2ArrayValueSetter( const uno::Any& aValue, ValueSetter& rCellValueSetter ) : mCellValueSetter( rCellValueSetter )
+ {
+ aValue >>= aMatrix;
+ nRowCount = aMatrix.getLength();
+ nColCount = aMatrix[0].getLength();
+ }
+
+ virtual void visitNode( sal_Int32 x, sal_Int32 y, const uno::Reference< table::XCell >& xCell )
+ {
+ if ( x < nRowCount && y < nColCount )
+ mCellValueSetter.processValue( aMatrix[ x ][ y ], xCell );
+ else
+ mCellValueSetter.processValue( uno::makeAny( sNA ), xCell );
+
+ }
+};
+
+class RangeProcessor
+{
+public:
+ virtual void process( const uno::Reference< excel::XRange >& xRange ) = 0;
+};
+
+class RangeValueProcessor : public RangeProcessor
+{
+ const uno::Any& m_aVal;
+public:
+ RangeValueProcessor( const uno::Any& rVal ):m_aVal( rVal ) {}
+ virtual void process( const uno::Reference< excel::XRange >& xRange )
+ {
+ xRange->setValue( m_aVal );
+ }
+};
+
+class RangeFormulaProcessor : public RangeProcessor
+{
+ const uno::Any& m_aVal;
+public:
+ RangeFormulaProcessor( const uno::Any& rVal ):m_aVal( rVal ) {}
+ virtual void process( const uno::Reference< excel::XRange >& xRange )
+ {
+ xRange->setFormula( m_aVal );
+ }
+};
+
+class RangeCountProcessor : public RangeProcessor
+{
+ sal_Int32 nCount;
+public:
+ RangeCountProcessor():nCount(0){}
+ virtual void process( const uno::Reference< excel::XRange >& xRange )
+ {
+ nCount = nCount + xRange->getCount();
+ }
+ sal_Int32 value() { return nCount; }
+};
+class AreasVisitor
+{
+private:
+ uno::Reference< XCollection > m_Areas;
+public:
+ AreasVisitor( const uno::Reference< XCollection >& rAreas ):m_Areas( rAreas ){}
+
+ void visit( RangeProcessor& processor )
+ {
+ if ( m_Areas.is() )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ processor.process( xRange );
+ }
+ }
+ }
+};
+
+class RangeHelper
+{
+ uno::Reference< table::XCellRange > m_xCellRange;
+
+public:
+ RangeHelper( const uno::Reference< table::XCellRange >& xCellRange ) throw (uno::RuntimeException) : m_xCellRange( xCellRange )
+ {
+ if ( !m_xCellRange.is() )
+ throw uno::RuntimeException();
+ }
+ RangeHelper( const uno::Any aCellRange ) throw (uno::RuntimeException)
+ {
+ m_xCellRange.set( aCellRange, uno::UNO_QUERY_THROW );
+ }
+ uno::Reference< sheet::XSheetCellRange > getSheetCellRange() throw (uno::RuntimeException)
+ {
+ return uno::Reference< sheet::XSheetCellRange >(m_xCellRange, uno::UNO_QUERY_THROW);
+ }
+ uno::Reference< sheet::XSpreadsheet > getSpreadSheet() throw (uno::RuntimeException)
+ {
+ return getSheetCellRange()->getSpreadsheet();
+ }
+
+ uno::Reference< table::XCellRange > getCellRangeFromSheet() throw (uno::RuntimeException)
+ {
+ return uno::Reference< table::XCellRange >(getSpreadSheet(), uno::UNO_QUERY_THROW );
+ }
+
+ uno::Reference< sheet::XCellRangeAddressable > getCellRangeAddressable() throw (uno::RuntimeException)
+ {
+ return uno::Reference< sheet::XCellRangeAddressable >(m_xCellRange, ::uno::UNO_QUERY_THROW);
+
+ }
+
+ uno::Reference< sheet::XSheetCellCursor > getSheetCellCursor() throw ( uno::RuntimeException )
+ {
+ return uno::Reference< sheet::XSheetCellCursor >( getSpreadSheet()->createCursorByRange( getSheetCellRange() ), uno::UNO_QUERY_THROW );
+ }
+
+ static uno::Reference< excel::XRange > createRangeFromRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference<uno::XComponentContext >& xContext,
+ const uno::Reference< table::XCellRange >& xRange, const uno::Reference< sheet::XCellRangeAddressable >& xCellRangeAddressable,
+ sal_Int32 nStartColOffset = 0, sal_Int32 nStartRowOffset = 0, sal_Int32 nEndColOffset = 0, sal_Int32 nEndRowOffset = 0 )
+ {
+ return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext,
+ xRange->getCellRangeByPosition(
+ xCellRangeAddressable->getRangeAddress().StartColumn + nStartColOffset,
+ xCellRangeAddressable->getRangeAddress().StartRow + nStartRowOffset,
+ xCellRangeAddressable->getRangeAddress().EndColumn + nEndColOffset,
+ xCellRangeAddressable->getRangeAddress().EndRow + nEndRowOffset ) ) );
+ }
+
+};
+
+bool
+getCellRangesForAddress( USHORT& rResFlags, const rtl::OUString& sAddress, ScDocShell* pDocSh, ScRangeList& rCellRanges, formula::FormulaGrammar::AddressConvention& eConv, char cDelimiter = 0 )
+{
+
+ ScDocument* pDoc = NULL;
+ if ( pDocSh )
+ {
+ pDoc = pDocSh->GetDocument();
+ String aString(sAddress);
+ USHORT nMask = SCA_VALID;
+ rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, cDelimiter );
+ if ( rResFlags & SCA_VALID )
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, ScRange& refRange, ScRangeList& aCellRanges, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException )
+{
+ // see if there is a match with a named range
+ uno::Reference< beans::XPropertySet > xProps( pDocSh->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW );
+ // Strangly enough you can have Range( "namedRange1, namedRange2, etc," )
+ // loop around each ',' seperated name
+ std::vector< rtl::OUString > vNames;
+ sal_Int32 nIndex = 0;
+ do
+ {
+ rtl::OUString aToken = sName.getToken( 0, ',', nIndex );
+ vNames.push_back( aToken );
+ } while ( nIndex >= 0 );
+
+ if ( !vNames.size() )
+ vNames.push_back( sName );
+
+ std::vector< rtl::OUString >::iterator it = vNames.begin();
+ std::vector< rtl::OUString >::iterator it_end = vNames.end();
+ for ( ; it != it_end; ++it )
+ {
+
+ formula::FormulaGrammar::AddressConvention eConv = aConv;
+ // spaces are illegal ( but the user of course can enter them )
+ rtl::OUString sAddress = (*it).trim();
+ // if a local name ( on the active sheet ) exists this will
+ // take precedence over a global with the same name
+ if ( !xNameAccess->hasByName( sAddress ) && pDocSh )
+ {
+ // try a local name
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nCurTab = pDocSh->GetCurTab();
+ if ( pDoc )
+ {
+ NameToNameMap* pMap = pDoc->GetLocalNameMap( nCurTab );
+ if ( pMap )
+ {
+ NameToNameMap::iterator itTmp = pMap->find( sAddress );
+ if ( itTmp != pMap->end() ) // found a mapping
+ sAddress = itTmp->second;
+ }
+ }
+ }
+ char aChar = 0;
+ if ( xNameAccess->hasByName( sAddress ) )
+ {
+ uno::Reference< sheet::XNamedRange > xNamed( xNameAccess->getByName( sAddress ), uno::UNO_QUERY_THROW );
+ sAddress = xNamed->getContent();
+ // As the address comes from OOO, the addressing
+ // style is may not be XL_A1
+ eConv = pDocSh->GetDocument()->GetAddressConvention();
+ aChar = ';';
+ }
+
+ USHORT nFlags = 0;
+ if ( !getCellRangesForAddress( nFlags, sAddress, pDocSh, aCellRanges, eConv, aChar ) )
+ return false;
+
+ bool bTabFromReferrer = !( nFlags & SCA_TAB_3D );
+
+ for ( ScRange* pRange = aCellRanges.First() ; pRange; pRange = aCellRanges.Next() )
+ {
+ pRange->aStart.SetCol( refRange.aStart.Col() + pRange->aStart.Col() );
+ pRange->aStart.SetRow( refRange.aStart.Row() + pRange->aStart.Row() );
+ pRange->aStart.SetTab( bTabFromReferrer ? refRange.aStart.Tab() : pRange->aStart.Tab() );
+ pRange->aEnd.SetCol( refRange.aStart.Col() + pRange->aEnd.Col() );
+ pRange->aEnd.SetRow( refRange.aStart.Row() + pRange->aEnd.Row() );
+ pRange->aEnd.SetTab( bTabFromReferrer ? refRange.aEnd.Tab() : pRange->aEnd.Tab() );
+ }
+ }
+ return true;
+}
+
+
+ScVbaRange*
+getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException )
+{
+ ScRangeList aCellRanges;
+ ScRange refRange;
+ ScUnoConversion::FillScRange( refRange, pAddr );
+ if ( !getScRangeListForAddress ( sName, pDocSh, refRange, aCellRanges, eConv ) )
+ throw uno::RuntimeException();
+ // Single range
+ if ( aCellRanges.First() == aCellRanges.Last() )
+ {
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocSh, *aCellRanges.First() ) );
+ uno::Reference< XHelperInterface > xFixThisParent = excel::getUnoSheetModuleObj( xRange );
+ return new ScVbaRange( xFixThisParent, xContext, xRange );
+ }
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocSh, aCellRanges ) );
+
+ uno::Reference< XHelperInterface > xFixThisParent = excel::getUnoSheetModuleObj( xRanges );
+ return new ScVbaRange( xFixThisParent, xContext, xRanges );
+}
+
+// ----------------------------------------------------------------------------
+
+namespace {
+
+template< typename RangeType >
+inline table::CellRangeAddress lclGetRangeAddress( const uno::Reference< RangeType >& rxCellRange ) throw (uno::RuntimeException)
+{
+ return uno::Reference< sheet::XCellRangeAddressable >( rxCellRange, uno::UNO_QUERY_THROW )->getRangeAddress();
+}
+
+void lclClearRange( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException)
+{
+ using namespace ::com::sun::star::sheet::CellFlags;
+ sal_Int32 nFlags = VALUE | DATETIME | STRING | ANNOTATION | FORMULA | HARDATTR | STYLES | EDITATTR | FORMATTED;
+ uno::Reference< sheet::XSheetOperation > xSheetOperation( rxCellRange, uno::UNO_QUERY_THROW );
+ xSheetOperation->clearContents( nFlags );
+}
+
+uno::Reference< sheet::XSheetCellRange > lclExpandToMerged( const uno::Reference< table::XCellRange >& rxCellRange, bool bRecursive ) throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCellRange > xNewCellRange( rxCellRange, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xSheet( xNewCellRange->getSpreadsheet(), uno::UNO_SET_THROW );
+ table::CellRangeAddress aNewAddress = lclGetRangeAddress( xNewCellRange );
+ table::CellRangeAddress aOldAddress;
+ // expand as long as there are new merged ranges included
+ do
+ {
+ aOldAddress = aNewAddress;
+ uno::Reference< sheet::XSheetCellCursor > xCursor( xSheet->createCursorByRange( xNewCellRange ), uno::UNO_SET_THROW );
+ xCursor->collapseToMergedArea();
+ xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW );
+ aNewAddress = lclGetRangeAddress( xNewCellRange );
+ }
+ while( bRecursive && (aOldAddress != aNewAddress) );
+ return xNewCellRange;
+}
+
+uno::Reference< sheet::XSheetCellRangeContainer > lclExpandToMerged( const uno::Reference< sheet::XSheetCellRangeContainer >& rxCellRanges, bool bRecursive ) throw (uno::RuntimeException)
+{
+ if( !rxCellRanges.is() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Missing cell ranges object" ) ), uno::Reference< uno::XInterface >() );
+ sal_Int32 nCount = rxCellRanges->getCount();
+ if( nCount < 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Missing cell ranges object" ) ), uno::Reference< uno::XInterface >() );
+
+ ScRangeList aScRanges;
+ for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< table::XCellRange > xRange( rxCellRanges->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ table::CellRangeAddress aRangeAddr = lclGetRangeAddress( lclExpandToMerged( xRange, bRecursive ) );
+ ScRange aScRange;
+ ScUnoConversion::FillScRange( aScRange, aRangeAddr );
+ aScRanges.Append( aScRange );
+ }
+ return new ScCellRangesObj( excel::GetDocShellFromRanges( rxCellRanges ), aScRanges );
+}
+
+void lclExpandAndMerge( const uno::Reference< table::XCellRange >& rxCellRange, bool bMerge ) throw (uno::RuntimeException)
+{
+ uno::Reference< util::XMergeable > xMerge( lclExpandToMerged( rxCellRange, true ), uno::UNO_QUERY_THROW );
+ // Calc cannot merge over merged ranges, always unmerge first
+ xMerge->merge( sal_False );
+ if( bMerge )
+ {
+ // clear all contents of the covered cells (not the top-left cell)
+ table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange );
+ sal_Int32 nLastColIdx = aRangeAddr.EndColumn - aRangeAddr.StartColumn;
+ sal_Int32 nLastRowIdx = aRangeAddr.EndRow - aRangeAddr.StartRow;
+ // clear cells of top row, right of top-left cell
+ if( nLastColIdx > 0 )
+ lclClearRange( rxCellRange->getCellRangeByPosition( 1, 0, nLastColIdx, 0 ) );
+ // clear all rows below top row
+ if( nLastRowIdx > 0 )
+ lclClearRange( rxCellRange->getCellRangeByPosition( 0, 1, nLastColIdx, nLastRowIdx ) );
+ // merge the range
+ xMerge->merge( sal_True );
+ }
+}
+
+util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxCellRange ) throw (uno::RuntimeException)
+{
+ /* 1) Check if range is completely inside one single merged range. To do
+ this, try to extend from top-left cell only (not from entire range).
+ This will exclude cases where this range consists of several merged
+ ranges (or parts of them). */
+ table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxCellRange );
+ uno::Reference< table::XCellRange > xTopLeft( rxCellRange->getCellRangeByPosition( 0, 0, 0, 0 ), uno::UNO_SET_THROW );
+ uno::Reference< sheet::XSheetCellRange > xExpanded( lclExpandToMerged( xTopLeft, false ), uno::UNO_SET_THROW );
+ table::CellRangeAddress aExpAddr = lclGetRangeAddress( xExpanded );
+ // check that expanded range has more than one cell (really merged)
+ if( ((aExpAddr.StartColumn < aExpAddr.EndColumn) || (aExpAddr.StartRow < aExpAddr.EndRow)) && ScUnoConversion::Contains( aExpAddr, aRangeAddr ) )
+ return util::TriState_YES;
+
+ /* 2) Check if this range contains any merged cells (completely or
+ partly). This seems to be hardly possible via API, as
+ XMergeable::getIsMerged() returns only true, if the top-left cell of a
+ merged range is part of this range, so cases where just the lower part
+ of a merged range is part of this range are not covered. */
+ ScRange aScRange;
+ ScUnoConversion::FillScRange( aScRange, aRangeAddr );
+ bool bHasMerged = excel::GetDocumentFromRange( rxCellRange )->HasAttrib( aScRange, HASATTR_MERGED | HASATTR_OVERLAPPED );
+ return bHasMerged ? util::TriState_INDETERMINATE : util::TriState_NO;
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+css::uno::Reference< excel::XRange >
+ScVbaRange::getRangeObjectForName(
+ const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sRangeName,
+ ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv ) throw ( uno::RuntimeException )
+{
+ table::CellRangeAddress refAddr;
+ return getRangeForName( xContext, sRangeName, pDocSh, refAddr, eConv );
+}
+
+table::CellAddress ScVbaRange::getLeftUpperCellAddress()
+{
+ table::CellAddress aCellAddress;
+ uno::Reference< table::XCellRange > xCellRange = mxRange;
+ if ( mxRanges.is() && m_Areas.is() && m_Areas->getCount() > 1 )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY );
+ if ( xIndex.is() && xIndex->getCount() > 0 )
+ {
+ xCellRange.set( xIndex->getByIndex( 0 ), uno::UNO_QUERY );
+ }
+ }
+ if ( xCellRange.is() )
+ {
+ uno::Reference< sheet::XCellAddressable > xCellAddr( xCellRange->getCellByPosition( 0, 0 ), uno::UNO_QUERY );
+ if ( xCellAddr.is() )
+ {
+ aCellAddress = xCellAddr->getCellAddress();
+ }
+ }
+ return aCellAddress;
+}
+
+table::CellRangeAddress getCellRangeAddressForVBARange( const uno::Any& aParam, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1) throw ( uno::RuntimeException )
+{
+ uno::Reference< table::XCellRange > xRangeParam;
+ switch ( aParam.getValueTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ {
+ rtl::OUString rString;
+ aParam >>= rString;
+ ScRangeList aCellRanges;
+ ScRange refRange;
+ if ( getScRangeListForAddress ( rString, pDocSh, refRange, aCellRanges, aConv ) )
+ {
+ if ( aCellRanges.First() == aCellRanges.Last() )
+ {
+ table::CellRangeAddress aRangeAddress;
+ ScUnoConversion::FillApiRange( aRangeAddress, *aCellRanges.First() );
+ return aRangeAddress;
+ }
+ }
+ }
+ case uno::TypeClass_INTERFACE:
+ {
+ uno::Reference< excel::XRange > xRange;
+ aParam >>= xRange;
+ if ( xRange.is() )
+ {
+ ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
+ if ( pRange && pDocSh && pRange->getScDocument() != pDocSh->GetDocument() )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Invalid range" ) ), uno::Reference< uno::XInterface >() );
+ }
+ xRange->getCellRange() >>= xRangeParam;
+ }
+ break;
+ }
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't extact CellRangeAddress from type" ) ), uno::Reference< uno::XInterface >() );
+ }
+ return lclGetRangeAddress( xRangeParam );
+}
+
+uno::Reference< XCollection >
+lcl_setupBorders( const uno::Reference< excel::XRange >& xParentRange, const uno::Reference<uno::XComponentContext>& xContext, const uno::Reference< table::XCellRange >& xRange ) throw( uno::RuntimeException )
+{
+ uno::Reference< XHelperInterface > xParent( xParentRange, uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::GetDocumentFromRange(xRange);
+ if ( !pDoc )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
+ ScVbaPalette aPalette( pDoc->GetDocumentShell() );
+ uno::Reference< XCollection > borders( new ScVbaBorders( xParent, xContext, xRange, aPalette ) );
+ return borders;
+}
+
+void lcl_NotifyRangeChanges( const uno::Reference< frame::XModel >& xModel, ScCellRangesBase* pUnoRangesBase )
+{
+ if ( xModel.is() && pUnoRangesBase )
+ {
+ ScModelObj* pModelObj = ScModelObj::getImplementation( xModel );
+ const ScRangeList& aCellRanges = pUnoRangesBase->GetRangeList();
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aCellRanges );
+ }
+ }
+}
+
+ScVbaRange::ScVbaRange( uno::Sequence< uno::Any> const & args,
+ uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaRange_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< beans::XPropertySet >( args, 1, false ), excel::GetModelFromRange( getXSomethingFromArgs< uno::XInterface >( args, 1 ) ), true ), mbIsRows( sal_False ), mbIsColumns( sal_False )
+{
+ mxRange.set( mxPropertySet, uno::UNO_QUERY );
+ mxRanges.set( mxPropertySet, uno::UNO_QUERY );
+ uno::Reference< container::XIndexAccess > xIndex;
+ if ( mxRange.is() )
+ {
+ xIndex = new SingleRangeIndexAccess( mxParent, mxContext, mxRange );
+ }
+ else if ( mxRanges.is() )
+ {
+ xIndex.set( mxRanges, uno::UNO_QUERY_THROW );
+ }
+ m_Areas = new ScVbaRangeAreas( mxParent, mxContext, xIndex, mbIsRows, mbIsColumns );
+}
+
+ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange, sal_Bool bIsRows, sal_Bool bIsColumns ) throw( lang::IllegalArgumentException )
+: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRange, uno::UNO_QUERY_THROW ), excel::GetModelFromRange( xRange), true ), mxRange( xRange ),
+ mbIsRows( bIsRows ),
+ mbIsColumns( bIsColumns )
+{
+ if ( !xContext.is() )
+ throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "context is not set " ) ), uno::Reference< uno::XInterface >() , 1 );
+ if ( !xRange.is() )
+ throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "range is not set " ) ), uno::Reference< uno::XInterface >() , 1 );
+
+ uno::Reference< container::XIndexAccess > xIndex( new SingleRangeIndexAccess( mxParent, mxContext, xRange ) );
+ m_Areas = new ScVbaRangeAreas( mxParent, mxContext, xIndex, mbIsRows, mbIsColumns );
+
+}
+
+ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows, sal_Bool bIsColumns ) throw ( lang::IllegalArgumentException )
+: ScVbaRange_BASE( xParent, xContext, uno::Reference< beans::XPropertySet >( xRanges, uno::UNO_QUERY_THROW ), excel::GetModelFromRange( uno::Reference< uno::XInterface >( xRanges, uno::UNO_QUERY_THROW ) ), true ), mxRanges( xRanges ),mbIsRows( bIsRows ), mbIsColumns( bIsColumns )
+
+{
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ m_Areas = new ScVbaRangeAreas( xParent, mxContext, xIndex, mbIsRows, mbIsColumns );
+
+}
+
+ScVbaRange::~ScVbaRange()
+{
+}
+
+uno::Reference< XCollection >& ScVbaRange::getBorders()
+{
+ if ( !m_Borders.is() )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(1) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ m_Borders = lcl_setupBorders( this, mxContext, uno::Reference< table::XCellRange >( xRange->getCellRange(), uno::UNO_QUERY_THROW ) );
+ }
+ return m_Borders;
+}
+
+void
+ScVbaRange::visitArray( ArrayVisitor& visitor )
+{
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY_THROW );
+ sal_Int32 nRowCount = xColumnRowRange->getRows()->getCount();
+ sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount();
+ for ( sal_Int32 i=0; i<nRowCount; ++i )
+ {
+ for ( sal_Int32 j=0; j<nColCount; ++j )
+ {
+ uno::Reference< table::XCell > xCell( mxRange->getCellByPosition( j, i ), uno::UNO_QUERY_THROW );
+
+ visitor.visitNode( i, j, xCell );
+ }
+ }
+}
+
+uno::Any SAL_CALL ScVbaRange::getName() throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XName > xName;
+
+ ScDocShell* pDocShell = getScDocShell();
+ uno::Reference< frame::XModel > xModel = pDocShell ? pDocShell->GetModel() : NULL;
+ if ( !xModel.is() )
+ {
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Invalid document" ), uno::Reference< uno::XInterface >() );
+ }
+ uno::Reference< beans::XPropertySet > xPropertySet( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XNamedRanges > xNamedRanges( xPropertySet->getPropertyValue( rtl::OUString::createFromAscii("NamedRanges")) , uno::UNO_QUERY_THROW );
+
+ uno::Reference< excel::XNames > xNames( new ScVbaNames( uno::Reference< XHelperInterface >(), mxContext , xNamedRanges , xModel ) );
+ sal_Int32 nCount = xNames->getCount();
+ ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
+ if ( pUnoRangesBase && nCount > 0 )
+ {
+ ScRangeList aRangeList = pUnoRangesBase->GetRangeList();
+ for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ uno::Reference< excel::XName > xTmpName( xNames->Item( uno::makeAny( nIndex + 1 ), uno::Any() ), uno::UNO_QUERY );
+ if ( xTmpName.is() )
+ {
+ try
+ {
+ uno::Reference< excel::XRange > xRange = xTmpName->getRefersToRange();
+ if ( xRange.is() )
+ {
+ ScVbaRange* pRange = dynamic_cast< ScVbaRange* >( xRange.get() );
+ ScCellRangesBase* pCurRangesBase = pRange ? pRange->getCellRangesBase() : NULL;
+ if ( pCurRangesBase && aRangeList == pCurRangesBase->GetRangeList() )
+ {
+ xName = xTmpName;
+ break;
+ }
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+ }
+ }
+
+ return uno::makeAny( xName );
+}
+
+uno::Any
+ScVbaRange::getValue( ValueGetter& valueGetter) throw (uno::RuntimeException)
+{
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY_THROW );
+ // single cell range
+ if ( isSingleCellRange() )
+ {
+ visitArray( valueGetter );
+ return valueGetter.getValue();
+ }
+ sal_Int32 nRowCount = xColumnRowRange->getRows()->getCount();
+ sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount();
+ // multi cell range ( return array )
+ Dim2ArrayValueGetter arrayGetter( nRowCount, nColCount, valueGetter );
+ visitArray( arrayGetter );
+ return uno::makeAny( script::ArrayWrapper( sal_False, arrayGetter.getValue() ) );
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getValue() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->getValue();
+ }
+
+ CellValueGetter valueGetter;
+ return getValue( valueGetter );
+
+}
+
+
+void
+ScVbaRange::setValue( const uno::Any &aValue, ValueSetter& valueSetter ) throw (uno::RuntimeException)
+{
+ uno::TypeClass aClass = aValue.getValueTypeClass();
+ if ( aClass == uno::TypeClass_SEQUENCE )
+ {
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ uno::Any aConverted;
+ try
+ {
+ // test for single dimension, could do
+ // with a better test than this
+ if ( aValue.getValueTypeName().indexOf('[') == aValue.getValueTypeName().lastIndexOf('[') )
+ {
+ aConverted = xConverter->convertTo( aValue, getCppuType((uno::Sequence< uno::Any >*)0) );
+ Dim1ArrayValueSetter setter( aConverted, valueSetter );
+ visitArray( setter );
+ }
+ else
+ {
+ aConverted = xConverter->convertTo( aValue, getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) );
+ Dim2ArrayValueSetter setter( aConverted, valueSetter );
+ visitArray( setter );
+ }
+ }
+ catch ( uno::Exception& e )
+ {
+ OSL_TRACE("Bahhh, caught exception %s",
+ rtl::OUStringToOString( e.Message,
+ RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ }
+ else
+ {
+ visitArray( valueSetter );
+ }
+}
+
+void SAL_CALL
+ScVbaRange::setValue( const uno::Any &aValue ) throw (uno::RuntimeException)
+{
+ // If this is a multiple selection apply setValue over all areas
+ if ( m_Areas->getCount() > 1 )
+ {
+ AreasVisitor aVisitor( m_Areas );
+ RangeValueProcessor valueProcessor( aValue );
+ aVisitor.visit( valueProcessor );
+ return;
+ }
+ CellValueSetter valueSetter( aValue );
+ setValue( aValue, valueSetter );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
+}
+
+void
+ScVbaRange::Clear() throw (uno::RuntimeException)
+{
+ using namespace ::com::sun::star::sheet::CellFlags;
+ sal_Int32 nFlags = VALUE | DATETIME | STRING | FORMULA | HARDATTR | EDITATTR | FORMATTED;
+ ClearContents( nFlags );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
+}
+
+//helper ClearContent
+void
+ScVbaRange::ClearContents( sal_Int32 nFlags ) throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ ScVbaRange* pRange = getImplementation( xRange );
+ if ( pRange )
+ pRange->ClearContents( nFlags );
+ }
+ return;
+ }
+
+
+ uno::Reference< sheet::XSheetOperation > xSheetOperation(mxRange, uno::UNO_QUERY_THROW);
+ xSheetOperation->clearContents( nFlags );
+}
+void
+ScVbaRange::ClearComments() throw (uno::RuntimeException)
+{
+ ClearContents( sheet::CellFlags::ANNOTATION );
+}
+
+void
+ScVbaRange::ClearContents() throw (uno::RuntimeException)
+{
+ sal_Int32 nClearFlags = ( sheet::CellFlags::VALUE |
+ sheet::CellFlags::STRING | sheet::CellFlags::DATETIME |
+ sheet::CellFlags::FORMULA );
+ ClearContents( nClearFlags );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
+}
+
+void
+ScVbaRange::ClearFormats() throw (uno::RuntimeException)
+{
+ //FIXME: need to check if we need to combine sheet::CellFlags::FORMATTED
+ sal_Int32 nClearFlags = sheet::CellFlags::HARDATTR | sheet::CellFlags::FORMATTED | sheet::CellFlags::EDITATTR;
+ ClearContents( nClearFlags );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
+}
+
+void
+ScVbaRange::setFormulaValue( const uno::Any& rFormula, formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException)
+{
+ // If this is a multiple selection apply setFormula over all areas
+ if ( m_Areas->getCount() > 1 )
+ {
+ AreasVisitor aVisitor( m_Areas );
+ RangeFormulaProcessor valueProcessor( rFormula );
+ aVisitor.visit( valueProcessor );
+ return;
+ }
+ CellFormulaValueSetter formulaValueSetter( rFormula, getScDocument(), eGram );
+ setValue( rFormula, formulaValueSetter );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
+}
+
+uno::Any
+ScVbaRange::getFormulaValue( formula::FormulaGrammar::Grammar eGram ) throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->getFormula();
+ }
+ CellFormulaValueGetter valueGetter( getScDocument(), eGram );
+ return getValue( valueGetter );
+
+}
+
+void
+ScVbaRange::setFormula(const uno::Any &rFormula ) throw (uno::RuntimeException)
+{
+ // #FIXME converting "=$a$1" e.g. CONV_XL_A1 -> CONV_OOO // results in "=$a$1:a1", temporalily disable conversion
+ setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );;
+}
+
+uno::Any
+ScVbaRange::getFormulaR1C1() throw (::com::sun::star::uno::RuntimeException)
+{
+ return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+}
+
+void
+ScVbaRange::setFormulaR1C1(const uno::Any& rFormula ) throw (uno::RuntimeException)
+{
+ setFormulaValue( rFormula,formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1 );
+}
+
+uno::Any
+ScVbaRange::getFormula() throw (::com::sun::star::uno::RuntimeException)
+{
+ return getFormulaValue( formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
+}
+
+sal_Int32
+ScVbaRange::getCount() throw (uno::RuntimeException)
+{
+ // If this is a multiple selection apply setValue over all areas
+ if ( m_Areas->getCount() > 1 )
+ {
+ AreasVisitor aVisitor( m_Areas );
+ RangeCountProcessor valueProcessor;
+ aVisitor.visit( valueProcessor );
+ return valueProcessor.value();
+ }
+ sal_Int32 rowCount = 0;
+ sal_Int32 colCount = 0;
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY_THROW );
+ rowCount = xColumnRowRange->getRows()->getCount();
+ colCount = xColumnRowRange->getColumns()->getCount();
+
+ if( IsRows() )
+ return rowCount;
+ if( IsColumns() )
+ return colCount;
+ return rowCount * colCount;
+}
+
+sal_Int32
+ScVbaRange::getRow() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->getRow();
+ }
+ uno::Reference< sheet::XCellAddressable > xCellAddressable(mxRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ return xCellAddressable->getCellAddress().Row + 1; // Zero value indexing
+}
+
+sal_Int32
+ScVbaRange::getColumn() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->getColumn();
+ }
+ uno::Reference< sheet::XCellAddressable > xCellAddressable(mxRange->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
+ return xCellAddressable->getCellAddress().Column + 1; // Zero value indexing
+}
+
+uno::Any
+ScVbaRange::HasFormula() throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ uno::Any aResult = aNULL();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ // if the HasFormula for any area is different to another
+ // return null
+ if ( index > 1 )
+ if ( aResult != xRange->HasFormula() )
+ return aNULL();
+ aResult = xRange->HasFormula();
+ if ( aNULL() == aResult )
+ return aNULL();
+ }
+ return aResult;
+ }
+ uno::Reference< uno::XInterface > xIf( mxRange, uno::UNO_QUERY_THROW );
+ ScCellRangesBase* pThisRanges = dynamic_cast< ScCellRangesBase * > ( xIf.get() );
+ if ( pThisRanges )
+ {
+ uno::Reference<uno::XInterface> xRanges( pThisRanges->queryFormulaCells( ( sheet::FormulaResult::ERROR | sheet::FormulaResult::VALUE | sheet::FormulaResult::STRING ) ), uno::UNO_QUERY_THROW );
+ ScCellRangesBase* pFormulaRanges = dynamic_cast< ScCellRangesBase * > ( xRanges.get() );
+ // check if there are no formula cell, return false
+ if ( pFormulaRanges->GetRangeList().Count() == 0 )
+ return uno::makeAny(sal_False);
+
+ // chech if there are holes (where some cells are not formulas)
+ // or returned range is not equal to this range
+ if ( ( pFormulaRanges->GetRangeList().Count() > 1 )
+ || ( pFormulaRanges->GetRangeList().GetObject(0)->aStart != pThisRanges->GetRangeList().GetObject(0)->aStart )
+ || ( pFormulaRanges->GetRangeList().GetObject(0)->aEnd != pThisRanges->GetRangeList().GetObject(0)->aEnd ) )
+ return aNULL(); // should return aNULL;
+ }
+ return uno::makeAny( sal_True );
+}
+void
+ScVbaRange::fillSeries( sheet::FillDirection nFillDirection, sheet::FillMode nFillMode, sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( uno::RuntimeException )
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ // Multi-Area Range
+ uno::Reference< XCollection > xCollection( m_Areas, uno::UNO_QUERY_THROW );
+ for ( sal_Int32 index = 1; index <= xCollection->getCount(); ++index )
+ {
+ uno::Reference< excel::XRange > xRange( xCollection->Item( uno::makeAny( index ), uno::Any() ), uno::UNO_QUERY_THROW );
+ ScVbaRange* pThisRange = getImplementation( xRange );
+ pThisRange->fillSeries( nFillDirection, nFillMode, nFillDateMode, fStep, fEndValue );
+
+ }
+ return;
+ }
+
+ uno::Reference< sheet::XCellSeries > xCellSeries(mxRange, uno::UNO_QUERY_THROW );
+ xCellSeries->fillSeries( nFillDirection, nFillMode, nFillDateMode, fStep, fEndValue );
+
+ // Fires the range change event.
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), getCellRangesBase() );
+}
+
+void
+ScVbaRange::FillLeft() throw (uno::RuntimeException)
+{
+ fillSeries(sheet::FillDirection_TO_LEFT,
+ sheet::FillMode_SIMPLE, sheet::FillDateMode_FILL_DATE_DAY, 0, 0x7FFFFFFF);
+}
+
+void
+ScVbaRange::FillRight() throw (uno::RuntimeException)
+{
+ fillSeries(sheet::FillDirection_TO_RIGHT,
+ sheet::FillMode_SIMPLE, sheet::FillDateMode_FILL_DATE_DAY, 0, 0x7FFFFFFF);
+}
+
+void
+ScVbaRange::FillUp() throw (uno::RuntimeException)
+{
+ fillSeries(sheet::FillDirection_TO_TOP,
+ sheet::FillMode_SIMPLE, sheet::FillDateMode_FILL_DATE_DAY, 0, 0x7FFFFFFF);
+}
+
+void
+ScVbaRange::FillDown() throw (uno::RuntimeException)
+{
+ fillSeries(sheet::FillDirection_TO_BOTTOM,
+ sheet::FillMode_SIMPLE, sheet::FillDateMode_FILL_DATE_DAY, 0, 0x7FFFFFFF);
+}
+
+::rtl::OUString
+ScVbaRange::getText() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->getText();
+ }
+ uno::Reference< text::XTextRange > xTextRange(mxRange->getCellByPosition(0,0), uno::UNO_QUERY_THROW );
+ return xTextRange->getString();
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::Offset( const ::uno::Any &nRowOff, const uno::Any &nColOff ) throw (uno::RuntimeException)
+{
+ SCROW nRowOffset = 0;
+ SCCOL nColOffset = 0;
+ sal_Bool bIsRowOffset = ( nRowOff >>= nRowOffset );
+ sal_Bool bIsColumnOffset = ( nColOff >>= nColOffset );
+ ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
+
+ ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+
+
+ for ( ScRange* pRange = aCellRanges.First() ; pRange; pRange = aCellRanges.Next() )
+ {
+ if ( bIsColumnOffset )
+ {
+ pRange->aStart.SetCol( pRange->aStart.Col() + nColOffset );
+ pRange->aEnd.SetCol( pRange->aEnd.Col() + nColOffset );
+ }
+ if ( bIsRowOffset )
+ {
+ pRange->aStart.SetRow( pRange->aStart.Row() + nRowOffset );
+ pRange->aEnd.SetRow( pRange->aEnd.Row() + nRowOffset );
+ }
+ }
+
+ if ( aCellRanges.Count() > 1 ) // Multi-Area
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pUnoRangesBase->GetDocShell(), aCellRanges ) );
+ return new ScVbaRange( mxParent, mxContext, xRanges );
+ }
+ // normal range
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), *aCellRanges.First() ) );
+ return new ScVbaRange( mxParent, mxContext, xRange );
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::CurrentRegion() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->CurrentRegion();
+ }
+
+ RangeHelper helper( mxRange );
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor =
+ helper.getSheetCellCursor();
+ xSheetCellCursor->collapseToCurrentRegion();
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW);
+ return RangeHelper::createRangeFromRange( mxParent, mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable );
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::CurrentArray() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->CurrentArray();
+ }
+ RangeHelper helper( mxRange );
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor =
+ helper.getSheetCellCursor();
+ xSheetCellCursor->collapseToCurrentArray();
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW);
+ return RangeHelper::createRangeFromRange( mxParent, mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable );
+}
+
+uno::Any
+ScVbaRange::getFormulaArray() throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->getFormulaArray();
+ }
+
+ uno::Reference< sheet::XCellRangeFormula> xCellRangeFormula( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ uno::Any aMatrix;
+
+ //VBA, minz@cn.ibm.com
+ uno::Sequence< uno::Sequence<rtl::OUString> > aFmArray = xCellRangeFormula->getFormulaArray();
+ if( aFmArray.getLength() )
+ {
+ if( aFmArray.getLength() == 1 && aFmArray[0].getLength() == 1 )
+ aMatrix <<= aFmArray[0][0];
+ else
+ aMatrix = xConverter->convertTo( uno::makeAny( xCellRangeFormula->getFormulaArray() ) , getCppuType((uno::Sequence< uno::Sequence< uno::Any > >*)0) ) ;
+ }
+ return aMatrix;
+}
+
+void
+ScVbaRange::setFormulaArray(const uno::Any& rFormula) throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->setFormulaArray( rFormula );
+ }
+ // #TODO need to distinguish between getFormula and getFormulaArray e.g. (R1C1)
+ // but for the moment its just easier to treat them the same for setting
+
+ setFormula( rFormula );
+}
+
+::rtl::OUString
+ScVbaRange::Characters(const uno::Any& Start, const uno::Any& Length) throw (uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->Characters( Start, Length );
+ }
+
+ long nIndex = 0, nCount = 0;
+ ::rtl::OUString rString;
+ uno::Reference< text::XTextRange > xTextRange(mxRange, ::uno::UNO_QUERY_THROW );
+ rString = xTextRange->getString();
+ if( !( Start >>= nIndex ) && !( Length >>= nCount ) )
+ return rString;
+ if(!( Start >>= nIndex ) )
+ nIndex = 1;
+ if(!( Length >>= nCount ) )
+ nIndex = rString.getLength();
+ return rString.copy( --nIndex, nCount ); // Zero value indexing
+}
+
+::rtl::OUString
+ScVbaRange::Address( const uno::Any& RowAbsolute, const uno::Any& ColumnAbsolute, const uno::Any& ReferenceStyle, const uno::Any& External, const uno::Any& RelativeTo ) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ // Multi-Area Range
+ rtl::OUString sAddress;
+ uno::Reference< XCollection > xCollection( m_Areas, uno::UNO_QUERY_THROW );
+ uno::Any aExternalCopy = External;
+ for ( sal_Int32 index = 1; index <= xCollection->getCount(); ++index )
+ {
+ uno::Reference< excel::XRange > xRange( xCollection->Item( uno::makeAny( index ), uno::Any() ), uno::UNO_QUERY_THROW );
+ if ( index > 1 )
+ {
+ sAddress += rtl::OUString( ',' );
+ // force external to be false
+ // only first address should have the
+ // document and sheet specifications
+ aExternalCopy = uno::makeAny(sal_False);
+ }
+ sAddress += xRange->Address( RowAbsolute, ColumnAbsolute, ReferenceStyle, aExternalCopy, RelativeTo );
+ }
+ return sAddress;
+
+ }
+ ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
+ if ( ReferenceStyle.hasValue() )
+ {
+ sal_Int32 refStyle = excel::XlReferenceStyle::xlA1;
+ ReferenceStyle >>= refStyle;
+ if ( refStyle == excel::XlReferenceStyle::xlR1C1 )
+ dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, 0, 0 );
+ }
+ USHORT nFlags = SCA_VALID;
+ ScDocShell* pDocShell = getScDocShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) );
+ String sRange;
+ USHORT ROW_ABSOLUTE = ( SCA_ROW_ABSOLUTE | SCA_ROW2_ABSOLUTE );
+ USHORT COL_ABSOLUTE = ( SCA_COL_ABSOLUTE | SCA_COL2_ABSOLUTE );
+ // default
+ nFlags |= ( SCA_TAB_ABSOLUTE | SCA_COL_ABSOLUTE | SCA_ROW_ABSOLUTE | SCA_TAB2_ABSOLUTE | SCA_COL2_ABSOLUTE | SCA_ROW2_ABSOLUTE );
+ if ( RowAbsolute.hasValue() )
+ {
+ sal_Bool bVal = sal_True;
+ RowAbsolute >>= bVal;
+ if ( !bVal )
+ nFlags &= ~ROW_ABSOLUTE;
+ }
+ if ( ColumnAbsolute.hasValue() )
+ {
+ sal_Bool bVal = sal_True;
+ ColumnAbsolute >>= bVal;
+ if ( !bVal )
+ nFlags &= ~COL_ABSOLUTE;
+ }
+ sal_Bool bLocal = sal_False;
+ if ( External.hasValue() )
+ {
+ External >>= bLocal;
+ if ( bLocal )
+ nFlags |= SCA_TAB_3D | SCA_FORCE_DOC;
+ }
+ if ( RelativeTo.hasValue() )
+ {
+ // #TODO should I throw an error if R1C1 is not set?
+
+ table::CellRangeAddress refAddress = getCellRangeAddressForVBARange( RelativeTo, pDocShell );
+ dDetails = ScAddress::Details( formula::FormulaGrammar::CONV_XL_R1C1, static_cast< SCROW >( refAddress.StartRow ), static_cast< SCCOL >( refAddress.StartColumn ) );
+ }
+ aRange.Format( sRange, nFlags, pDoc, dDetails );
+ return sRange;
+}
+
+uno::Reference < excel::XFont >
+ScVbaRange::Font() throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY );
+ ScDocument* pDoc = getScDocument();
+ if ( mxRange.is() )
+ xProps.set(mxRange, ::uno::UNO_QUERY );
+ else if ( mxRanges.is() )
+ xProps.set(mxRanges, ::uno::UNO_QUERY );
+ if ( !pDoc )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
+
+ ScVbaPalette aPalette( pDoc->GetDocumentShell() );
+ ScCellRangeObj* pRangeObj = NULL;
+ try
+ {
+ pRangeObj = getCellRangeObj();
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return new ScVbaFont( this, mxContext, aPalette, xProps, pRangeObj );
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) throw(uno::RuntimeException)
+{
+ // #TODO code within the test below "if ( m_Areas.... " can be removed
+ // Test is performed only because m_xRange is NOT set to be
+ // the first range in m_Areas ( to force failure while
+ // the implementations for each method are being updated )
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->Cells( nRowIndex, nColumnIndex );
+ }
+
+ sal_Int32 nRow = 0, nColumn = 0;
+
+ sal_Bool bIsIndex = nRowIndex.hasValue();
+ sal_Bool bIsColumnIndex = nColumnIndex.hasValue();
+
+ // Sometimes we might get a float or a double or whatever
+ // set in the Any, we should convert as appropriate
+ // #FIXME - perhaps worth turning this into some sort of
+ // convertion routine e.g. bSuccess = getValueFromAny( nRow, nRowIndex, getCppuType((sal_Int32*)0) )
+ uno::Any aRowIndexAny = nRowIndex;
+ if ( aRowIndexAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
+ {
+ try
+ {
+ aRowIndexAny = getDefaultPropByIntrospection( aRowIndexAny );
+ }
+ catch( uno::Exception& ) {}
+ }
+ else if ( aRowIndexAny.hasValue() && !( aRowIndexAny >>= nRow ) )
+ {
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ uno::Any aConverted;
+ try
+ {
+ aConverted = xConverter->convertTo( aRowIndexAny, getCppuType((sal_Int32*)0) );
+ bIsIndex = ( aConverted >>= nRow );
+ }
+ catch( uno::Exception& ) {} // silence any errors
+ }
+
+ uno::Any aColumnAny = nColumnIndex;
+
+ if ( bIsColumnIndex )
+ {
+ // Column index can be a col address e.g Cells( 1, "B" ) etc.
+ rtl::OUString sCol;
+ if ( nColumnIndex >>= sCol )
+ {
+ ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
+ ScRange tmpRange;
+ USHORT flags = tmpRange.ParseCols( sCol, excel::GetDocumentFromRange( mxRange ), dDetails );
+ if ( ( flags & 0x200 ) != 0x200 )
+ throw uno::RuntimeException();
+ nColumn = tmpRange.aStart.Col() + 1;
+ }
+ else
+ {
+ if ( aColumnAny.getValueTypeClass() == uno::TypeClass_INTERFACE )
+ {
+ try
+ {
+ aColumnAny = getDefaultPropByIntrospection( aColumnAny );
+ }
+ catch( uno::Exception& ) {}
+ }
+ if ( !( aColumnAny >>= nColumn ) )
+ {
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ uno::Any aConverted;
+ try
+ {
+ aConverted = xConverter->convertTo( aColumnAny, getCppuType((sal_Int32*)0) );
+ bIsColumnIndex = ( aConverted >>= nColumn );
+ }
+ catch( uno::Exception& ) {} // silence any errors
+ }
+ }
+ }
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet();
+ if( !bIsIndex && !bIsColumnIndex ) // .Cells
+ // #FIXE needs proper parent ( Worksheet )
+ return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) );
+
+ sal_Int32 nIndex = --nRow;
+ if( bIsIndex && !bIsColumnIndex ) // .Cells(n)
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, ::uno::UNO_QUERY_THROW);
+ sal_Int32 nColCount = xColumnRowRange->getColumns()->getCount();
+
+ if ( !nIndex || nIndex < 0 )
+ nRow = 0;
+ else
+ nRow = nIndex / nColCount;
+ nColumn = nIndex % nColCount;
+ }
+ else
+ --nColumn;
+ nRow = nRow + thisRangeAddress.StartRow;
+ nColumn = nColumn + thisRangeAddress.StartColumn;
+ return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) );
+}
+
+void
+ScVbaRange::Select() throw (uno::RuntimeException)
+{
+ ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
+ if ( !pUnoRangesBase )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying uno range object" ) ), uno::Reference< uno::XInterface >() );
+ ScDocShell* pShell = pUnoRangesBase->GetDocShell();
+ if ( pShell )
+ {
+ uno::Reference< frame::XModel > xModel( pShell->GetModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ if ( mxRanges.is() )
+ xSelection->select( uno::Any( lclExpandToMerged( mxRanges, true ) ) );
+ else
+ xSelection->select( uno::Any( lclExpandToMerged( mxRange, true ) ) );
+ // set focus on document e.g.
+ // ThisComponent.CurrentController.Frame.getContainerWindow.SetFocus
+ try
+ {
+ uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XWindow > xWin( xFrame->getContainerWindow(), uno::UNO_QUERY_THROW );
+ xWin->setFocus();
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+}
+
+bool cellInRange( const table::CellRangeAddress& rAddr, const sal_Int32& nCol, const sal_Int32& nRow )
+{
+ if ( nCol >= rAddr.StartColumn && nCol <= rAddr.EndColumn &&
+ nRow >= rAddr.StartRow && nRow <= rAddr.EndRow )
+ return true;
+ return false;
+}
+
+void setCursor( const SCCOL& nCol, const SCROW& nRow, const uno::Reference< frame::XModel >& xModel, bool bInSel = true )
+{
+ ScTabViewShell* pShell = excel::getBestViewShell( xModel );
+ if ( pShell )
+ {
+ if ( bInSel )
+ pShell->SetCursor( nCol, nRow );
+ else
+ pShell->MoveCursorAbs( nCol, nRow, SC_FOLLOW_NONE, FALSE, FALSE, TRUE, FALSE );
+ }
+}
+
+void
+ScVbaRange::Activate() throw (uno::RuntimeException)
+{
+ // get first cell of current range
+ uno::Reference< table::XCellRange > xCellRange;
+ if ( mxRanges.is() )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ xCellRange.set( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ }
+ else
+ xCellRange.set( mxRange, uno::UNO_QUERY_THROW );
+
+ RangeHelper thisRange( xCellRange );
+ uno::Reference< sheet::XCellRangeAddressable > xThisRangeAddress = thisRange.getCellRangeAddressable();
+ table::CellRangeAddress thisRangeAddress = xThisRangeAddress->getRangeAddress();
+ uno::Reference< frame::XModel > xModel;
+ ScDocShell* pShell = getScDocShell();
+
+ if ( pShell )
+ xModel = pShell->GetModel();
+
+ if ( !xModel.is() )
+ throw uno::RuntimeException();
+
+ // get current selection
+ uno::Reference< sheet::XCellRangeAddressable > xRange( xModel->getCurrentSelection(), ::uno::UNO_QUERY);
+
+ uno::Reference< sheet::XSheetCellRanges > xRanges( xModel->getCurrentSelection(), ::uno::UNO_QUERY);
+
+ if ( xRanges.is() )
+ {
+ uno::Sequence< table::CellRangeAddress > nAddrs = xRanges->getRangeAddresses();
+ for ( sal_Int32 index = 0; index < nAddrs.getLength(); ++index )
+ {
+ if ( cellInRange( nAddrs[index], thisRangeAddress.StartColumn, thisRangeAddress.StartRow ) )
+ {
+ setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), xModel );
+ return;
+ }
+
+ }
+ }
+
+ if ( xRange.is() && cellInRange( xRange->getRangeAddress(), thisRangeAddress.StartColumn, thisRangeAddress.StartRow ) )
+ setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), xModel );
+ else
+ {
+ // if this range is multi cell select the range other
+ // wise just position the cell at this single range position
+ if ( isSingleCellRange() )
+ // This top-leftmost cell of this Range is not in the current
+ // selection so just select this range
+ setCursor( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), xModel, false );
+ else
+ Select();
+ }
+
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ SCROW nStartRow = 0;
+ SCROW nEndRow = 0;
+
+ sal_Int32 nValue = 0;
+ rtl::OUString sAddress;
+
+ if ( aIndex.hasValue() )
+ {
+ ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
+ ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+
+ ScRange aRange = *aCellRanges.First();
+ if( aIndex >>= nValue )
+ {
+ aRange.aStart.SetRow( aRange.aStart.Row() + --nValue );
+ aRange.aEnd.SetRow( aRange.aStart.Row() );
+ }
+
+ else if ( aIndex >>= sAddress )
+ {
+ ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
+ ScRange tmpRange;
+ tmpRange.ParseRows( sAddress, excel::GetDocumentFromRange( mxRange ), dDetails );
+ nStartRow = tmpRange.aStart.Row();
+ nEndRow = tmpRange.aEnd.Row();
+
+ aRange.aStart.SetRow( aRange.aStart.Row() + nStartRow );
+ aRange.aEnd.SetRow( aRange.aStart.Row() + ( nEndRow - nStartRow ));
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Illegal param" ) ), uno::Reference< uno::XInterface >() );
+
+ if ( aRange.aStart.Row() < 0 || aRange.aEnd.Row() < 0 )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Internal failure, illegal param"), uno::Reference< uno::XInterface >() );
+ // return a normal range ( even for multi-selection
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), aRange ) );
+ return new ScVbaRange( mxParent, mxContext, xRange, true );
+ }
+ // Rows() - no params
+ if ( m_Areas->getCount() > 1 )
+ return new ScVbaRange( mxParent, mxContext, mxRanges, true );
+ return new ScVbaRange( mxParent, mxContext, mxRange, true );
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ SCCOL nStartCol = 0;
+ SCCOL nEndCol = 0;
+
+ sal_Int32 nValue = 0;
+ rtl::OUString sAddress;
+
+ ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
+ ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+
+ ScRange aRange = *aCellRanges.First();
+ if ( aIndex.hasValue() )
+ {
+ if ( aIndex >>= nValue )
+ {
+ aRange.aStart.SetCol( aRange.aStart.Col() + static_cast< SCCOL > ( --nValue ) );
+ aRange.aEnd.SetCol( aRange.aStart.Col() );
+ }
+
+ else if ( aIndex >>= sAddress )
+ {
+ ScAddress::Details dDetails( formula::FormulaGrammar::CONV_XL_A1, 0, 0 );
+ ScRange tmpRange;
+ tmpRange.ParseCols( sAddress, excel::GetDocumentFromRange( mxRange ), dDetails );
+ nStartCol = tmpRange.aStart.Col();
+ nEndCol = tmpRange.aEnd.Col();
+
+ aRange.aStart.SetCol( aRange.aStart.Col() + nStartCol );
+ aRange.aEnd.SetCol( aRange.aStart.Col() + ( nEndCol - nStartCol ));
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Illegal param" ) ), uno::Reference< uno::XInterface >() );
+
+ if ( aRange.aStart.Col() < 0 || aRange.aEnd.Col() < 0 )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("Internal failure, illegal param"), uno::Reference< uno::XInterface >() );
+ }
+ // Columns() - no params
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), aRange ) );
+ return new ScVbaRange( mxParent, mxContext, xRange, false, true );
+}
+
+void
+ScVbaRange::setMergeCells( const uno::Any& aIsMerged ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ bool bMerge = extractBoolFromAny( aIsMerged );
+
+ if( mxRanges.is() )
+ {
+ sal_Int32 nCount = mxRanges->getCount();
+
+ // VBA does nothing (no error) if the own ranges overlap somehow
+ ::std::vector< table::CellRangeAddress > aList;
+ for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( mxRanges->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ table::CellRangeAddress aAddress = xRangeAddr->getRangeAddress();
+ for( ::std::vector< table::CellRangeAddress >::const_iterator aIt = aList.begin(), aEnd = aList.end(); aIt != aEnd; ++aIt )
+ if( ScUnoConversion::Intersects( *aIt, aAddress ) )
+ return;
+ aList.push_back( aAddress );
+ }
+
+ // (un)merge every range after it has been extended to intersecting merged ranges from sheet
+ for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< table::XCellRange > xRange( mxRanges->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ lclExpandAndMerge( xRange, bMerge );
+ }
+ return;
+ }
+
+ // otherwise, merge single range
+ lclExpandAndMerge( mxRange, bMerge );
+}
+
+uno::Any
+ScVbaRange::getMergeCells() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if( mxRanges.is() )
+ {
+ sal_Int32 nCount = mxRanges->getCount();
+ for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< table::XCellRange > xRange( mxRanges->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ util::TriState eMerged = lclGetMergedState( xRange );
+ /* Excel always returns NULL, if one range of the range list is
+ partly or completely merged. Even if all ranges are completely
+ merged, the return value is still NULL. */
+ if( eMerged != util::TriState_NO )
+ return aNULL();
+ }
+ // no range is merged anyhow, return false
+ return uno::Any( false );
+ }
+
+ // otherwise, check single range
+ switch( lclGetMergedState( mxRange ) )
+ {
+ case util::TriState_YES: return uno::Any( true );
+ case util::TriState_NO: return uno::Any( false );
+ default: return aNULL();
+ }
+}
+
+void
+ScVbaRange::Copy(const ::uno::Any& Destination) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() );
+ if ( Destination.hasValue() )
+ {
+ uno::Reference< excel::XRange > xRange( Destination, uno::UNO_QUERY_THROW );
+ uno::Any aRange = xRange->getCellRange();
+ uno::Reference< table::XCellRange > xCellRange;
+ aRange >>= xCellRange;
+ uno::Reference< sheet::XSheetCellRange > xSheetCellRange(xCellRange, ::uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XSpreadsheet > xSheet = xSheetCellRange->getSpreadsheet();
+ uno::Reference< table::XCellRange > xDest( xSheet, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeMovement > xMover( xSheet, uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XCellAddressable > xDestination( xDest->getCellByPosition(
+ xRange->getColumn()-1,xRange->getRow()-1), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeAddressable > xSource( mxRange, uno::UNO_QUERY);
+ xMover->copyRange( xDestination->getCellAddress(), xSource->getRangeAddress() );
+ }
+ else
+ {
+ ScRange aRange;
+ RangeHelper thisRange( mxRange );
+ ScUnoConversion::FillScRange( aRange, thisRange.getCellRangeAddressable()->getRangeAddress() );
+ uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRange );
+ excel::implnCopyRange( xModel, aRange );
+ }
+}
+
+void
+ScVbaRange::Cut(const ::uno::Any& Destination) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() );
+ if (Destination.hasValue())
+ {
+ uno::Reference< excel::XRange > xRange( Destination, uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xCellRange( xRange->getCellRange(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSheetCellRange > xSheetCellRange(xCellRange, ::uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSpreadsheet > xSheet = xSheetCellRange->getSpreadsheet();
+ uno::Reference< table::XCellRange > xDest( xSheet, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeMovement > xMover( xSheet, uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XCellAddressable > xDestination( xDest->getCellByPosition(
+ xRange->getColumn()-1,xRange->getRow()-1), uno::UNO_QUERY);
+ uno::Reference< sheet::XCellRangeAddressable > xSource( mxRange, uno::UNO_QUERY);
+ xMover->moveRange( xDestination->getCellAddress(), xSource->getRangeAddress() );
+ }
+ //VBA, minz@cn.ibm.com.
+ else {
+ uno::Reference< frame::XModel > xModel = excel::GetModelFromRange( mxRange );
+ Select();
+ excel::implnCut( xModel );
+ }
+}
+
+void
+ScVbaRange::setNumberFormat( const uno::Any& aFormat ) throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ rtl::OUString sFormat;
+ aFormat >>= sFormat;
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->setNumberFormat( aFormat );
+ }
+ return;
+ }
+ NumFormatHelper numFormat( mxRange );
+ numFormat.setNumberFormat( sFormat );
+}
+
+uno::Any
+ScVbaRange::getNumberFormat() throw ( script::BasicErrorException, uno::RuntimeException)
+{
+
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ uno::Any aResult = aNULL();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ // if the numberformat of one area is different to another
+ // return null
+ if ( index > 1 )
+ if ( aResult != xRange->getNumberFormat() )
+ return aNULL();
+ aResult = xRange->getNumberFormat();
+ if ( aNULL() == aResult )
+ return aNULL();
+ }
+ return aResult;
+ }
+ NumFormatHelper numFormat( mxRange );
+ rtl::OUString sFormat = numFormat.getNumberFormatString();
+ if ( sFormat.getLength() > 0 )
+ return uno::makeAny( sFormat );
+ return aNULL();
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::Resize( const uno::Any &RowSize, const uno::Any &ColumnSize ) throw (uno::RuntimeException)
+{
+ long nRowSize = 0, nColumnSize = 0;
+ sal_Bool bIsRowChanged = ( RowSize >>= nRowSize ), bIsColumnChanged = ( ColumnSize >>= nColumnSize );
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, ::uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellRange > xSheetRange(mxRange, ::uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellCursor > xCursor( xSheetRange->getSpreadsheet()->createCursorByRange(xSheetRange), ::uno::UNO_QUERY_THROW );
+
+ if( !bIsRowChanged )
+ nRowSize = xColumnRowRange->getRows()->getCount();
+ if( !bIsColumnChanged )
+ nColumnSize = xColumnRowRange->getColumns()->getCount();
+
+ xCursor->collapseToSize( nColumnSize, nRowSize );
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xCursor, ::uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xSheetRange->getSpreadsheet(), ::uno::UNO_QUERY_THROW );
+ return new ScVbaRange( mxParent, mxContext,xRange->getCellRangeByPosition(
+ xCellRangeAddressable->getRangeAddress().StartColumn,
+ xCellRangeAddressable->getRangeAddress().StartRow,
+ xCellRangeAddressable->getRangeAddress().EndColumn,
+ xCellRangeAddressable->getRangeAddress().EndRow ) );
+}
+
+void
+ScVbaRange::setWrapText( const uno::Any& aIsWrapped ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ uno::Any aResult;
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->setWrapText( aIsWrapped );
+ }
+ return;
+ }
+
+ uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW );
+ bool bIsWrapped = extractBoolFromAny( aIsWrapped );
+ xProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ), uno::Any( bIsWrapped ) );
+}
+
+uno::Any
+ScVbaRange::getWrapText() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ uno::Any aResult;
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ if ( index > 1 )
+ if ( aResult != xRange->getWrapText() )
+ return aNULL();
+ aResult = xRange->getWrapText();
+ }
+ return aResult;
+ }
+
+ SfxItemSet* pDataSet = getCurrentDataSet();
+
+ SfxItemState eState = pDataSet->GetItemState( ATTR_LINEBREAK, TRUE, NULL);
+ if ( eState == SFX_ITEM_DONTCARE )
+ return aNULL();
+
+ uno::Reference< beans::XPropertySet > xProps(mxRange, ::uno::UNO_QUERY_THROW );
+ uno::Any aValue = xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsTextWrapped" ) ) );
+ return aValue;
+}
+
+uno::Reference< excel::XInterior > ScVbaRange::Interior( ) throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( mxRange, uno::UNO_QUERY_THROW );
+ return new ScVbaInterior ( this, mxContext, xProps, getScDocument() );
+}
+uno::Reference< excel::XRange >
+ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2 ) throw (uno::RuntimeException)
+{
+ return Range( Cell1, Cell2, false );
+}
+uno::Reference< excel::XRange >
+ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseInpuRangeTab ) throw (uno::RuntimeException)
+
+{
+ uno::Reference< table::XCellRange > xCellRange = mxRange;
+
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ xCellRange.set( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ }
+ else
+ xCellRange.set( mxRange );
+
+ RangeHelper thisRange( xCellRange );
+ uno::Reference< table::XCellRange > xRanges = thisRange.getCellRangeFromSheet();
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( xRanges, uno::UNO_QUERY_THROW );
+
+ uno::Reference< table::XCellRange > xReferrer =
+ xRanges->getCellRangeByPosition( getColumn()-1, getRow()-1,
+ xAddressable->getRangeAddress().EndColumn,
+ xAddressable->getRangeAddress().EndRow );
+ // xAddressable now for this range
+ xAddressable.set( xReferrer, uno::UNO_QUERY_THROW );
+
+ if( !Cell1.hasValue() )
+ throw uno::RuntimeException(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " Invalid Argument " ) ),
+ uno::Reference< XInterface >() );
+
+ table::CellRangeAddress resultAddress;
+ table::CellRangeAddress parentRangeAddress = xAddressable->getRangeAddress();
+
+ ScRange aRange;
+ // Cell1 defined only
+ if ( !Cell2.hasValue() )
+ {
+ rtl::OUString sName;
+ Cell1 >>= sName;
+ RangeHelper referRange( xReferrer );
+ table::CellRangeAddress referAddress = referRange.getCellRangeAddressable()->getRangeAddress();
+ return getRangeForName( mxContext, sName, getScDocShell(), referAddress );
+
+ }
+ else
+ {
+ table::CellRangeAddress cell1, cell2;
+ cell1 = getCellRangeAddressForVBARange( Cell1, getScDocShell() );
+ // Cell1 & Cell2 defined
+ // Excel seems to combine the range as the range defined by
+ // the combination of Cell1 & Cell2
+
+ cell2 = getCellRangeAddressForVBARange( Cell2, getScDocShell() );
+
+ resultAddress.StartColumn = ( cell1.StartColumn < cell2.StartColumn ) ? cell1.StartColumn : cell2.StartColumn;
+ resultAddress.StartRow = ( cell1.StartRow < cell2.StartRow ) ? cell1.StartRow : cell2.StartRow;
+ resultAddress.EndColumn = ( cell1.EndColumn > cell2.EndColumn ) ? cell1.EndColumn : cell2.EndColumn;
+ resultAddress.EndRow = ( cell1.EndRow > cell2.EndRow ) ? cell1.EndRow : cell2.EndRow;
+ if ( bForceUseInpuRangeTab )
+ {
+ // this is a call from Application.Range( x,y )
+ // its possiblefor x or y to specify a different sheet from
+ // the current or active on ( but they must be the same )
+ if ( cell1.Sheet != cell2.Sheet )
+ throw uno::RuntimeException();
+ parentRangeAddress.Sheet = cell1.Sheet;
+ }
+ else
+ {
+ // this is not a call from Application.Range( x,y )
+ // if a different sheet from this range is specified it's
+ // an error
+ if ( parentRangeAddress.Sheet != cell1.Sheet
+ || parentRangeAddress.Sheet != cell2.Sheet
+ )
+ throw uno::RuntimeException();
+
+ }
+ ScUnoConversion::FillScRange( aRange, resultAddress );
+ }
+ ScRange parentAddress;
+ ScUnoConversion::FillScRange( parentAddress, parentRangeAddress);
+ if ( aRange.aStart.Col() >= 0 && aRange.aStart.Row() >= 0 && aRange.aEnd.Col() >= 0 && aRange.aEnd.Row() >= 0 )
+ {
+ sal_Int32 nStartX = parentAddress.aStart.Col() + aRange.aStart.Col();
+ sal_Int32 nStartY = parentAddress.aStart.Row() + aRange.aStart.Row();
+ sal_Int32 nEndX = parentAddress.aStart.Col() + aRange.aEnd.Col();
+ sal_Int32 nEndY = parentAddress.aStart.Row() + aRange.aEnd.Row();
+
+ if ( nStartX <= nEndX && nEndX <= parentAddress.aEnd.Col() &&
+ nStartY <= nEndY && nEndY <= parentAddress.aEnd.Row() )
+ {
+ ScRange aNew( (SCCOL)nStartX, (SCROW)nStartY, parentAddress.aStart.Tab(),
+ (SCCOL)nEndX, (SCROW)nEndY, parentAddress.aEnd.Tab() );
+ xCellRange = new ScCellRangeObj( getScDocShell(), aNew );
+ }
+ }
+
+ return new ScVbaRange( mxParent, mxContext, xCellRange );
+
+}
+
+// Allow access to underlying openoffice uno api ( useful for debugging
+// with openoffice basic )
+uno::Any SAL_CALL ScVbaRange::getCellRange( ) throw (uno::RuntimeException)
+{
+ uno::Any aAny;
+ if ( mxRanges.is() )
+ aAny <<= mxRanges;
+ else if ( mxRange.is() )
+ aAny <<= mxRange;
+ return aAny;
+}
+
+/*static*/ uno::Any ScVbaRange::getCellRange( const uno::Reference< excel::XRange >& rxRange ) throw (uno::RuntimeException)
+{
+ if( ScVbaRange* pVbaRange = getImplementation( rxRange ) )
+ return pVbaRange->getCellRange();
+ throw uno::RuntimeException();
+}
+
+static USHORT
+getPasteFlags (sal_Int32 Paste)
+{
+ USHORT nFlags = IDF_NONE;
+ switch (Paste) {
+ case excel::XlPasteType::xlPasteComments:
+ nFlags = IDF_NOTE;break;
+ case excel::XlPasteType::xlPasteFormats:
+ nFlags = IDF_ATTRIB;break;
+ case excel::XlPasteType::xlPasteFormulas:
+ nFlags = IDF_FORMULA;break;
+ case excel::XlPasteType::xlPasteFormulasAndNumberFormats :
+ case excel::XlPasteType::xlPasteValues:
+#ifdef VBA_OOBUILD_HACK
+ nFlags = ( IDF_VALUE | IDF_DATETIME | IDF_STRING | IDF_SPECIAL_BOOLEAN ); break;
+#else
+ nFlags = ( IDF_VALUE | IDF_DATETIME | IDF_STRING ); break;
+#endif
+ case excel::XlPasteType::xlPasteValuesAndNumberFormats:
+ nFlags = IDF_VALUE | IDF_ATTRIB; break;
+ case excel::XlPasteType::xlPasteColumnWidths:
+ case excel::XlPasteType::xlPasteValidation:
+ nFlags = IDF_NONE;break;
+ case excel::XlPasteType::xlPasteAll:
+ case excel::XlPasteType::xlPasteAllExceptBorders:
+ default:
+ nFlags = IDF_ALL;break;
+ };
+return nFlags;
+}
+
+static USHORT
+getPasteFormulaBits( sal_Int32 Operation)
+{
+ USHORT nFormulaBits = PASTE_NOFUNC ;
+ switch (Operation)
+ {
+ case excel::XlPasteSpecialOperation::xlPasteSpecialOperationAdd:
+ nFormulaBits = PASTE_ADD;break;
+ case excel::XlPasteSpecialOperation::xlPasteSpecialOperationSubtract:
+ nFormulaBits = PASTE_SUB;break;
+ case excel::XlPasteSpecialOperation::xlPasteSpecialOperationMultiply:
+ nFormulaBits = PASTE_MUL;break;
+ case excel::XlPasteSpecialOperation::xlPasteSpecialOperationDivide:
+ nFormulaBits = PASTE_DIV;break;
+
+ case excel::XlPasteSpecialOperation::xlPasteSpecialOperationNone:
+ default:
+ nFormulaBits = PASTE_NOFUNC; break;
+ };
+
+return nFormulaBits;
+}
+void SAL_CALL
+ScVbaRange::PasteSpecial( const uno::Any& Paste, const uno::Any& Operation, const uno::Any& SkipBlanks, const uno::Any& Transpose ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() );
+ ScDocShell* pShell = getScDocShell();
+
+ uno::Reference< frame::XModel > xModel( ( pShell ? pShell->GetModel() : NULL ), uno::UNO_QUERY_THROW );
+ uno::Reference< view::XSelectionSupplier > xSelection( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ // select this range
+ xSelection->select( uno::makeAny( mxRange ) );
+ // set up defaults
+ sal_Int32 nPaste = excel::XlPasteType::xlPasteAll;
+ sal_Int32 nOperation = excel::XlPasteSpecialOperation::xlPasteSpecialOperationNone;
+ sal_Bool bTranspose = sal_False;
+ sal_Bool bSkipBlanks = sal_False;
+
+ if ( Paste.hasValue() )
+ Paste >>= nPaste;
+ if ( Operation.hasValue() )
+ Operation >>= nOperation;
+ if ( SkipBlanks.hasValue() )
+ SkipBlanks >>= bSkipBlanks;
+ if ( Transpose.hasValue() )
+ Transpose >>= bTranspose;
+
+ USHORT nFlags = getPasteFlags(nPaste);
+ USHORT nFormulaBits = getPasteFormulaBits(nOperation);
+ excel::implnPasteSpecial(pShell->GetModel(), nFlags,nFormulaBits,bSkipBlanks,bTranspose);
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::getEntireColumnOrRow( bool bColumn ) throw (uno::RuntimeException)
+{
+ ScCellRangesBase* pUnoRangesBase = getCellRangesBase();
+ // copy the range list
+ ScRangeList aCellRanges = pUnoRangesBase->GetRangeList();
+
+ for ( ScRange* pRange = aCellRanges.First() ; pRange; pRange = aCellRanges.Next() )
+ {
+ if ( bColumn )
+ {
+ pRange->aStart.SetRow( 0 );
+ pRange->aEnd.SetRow( MAXROW );
+ }
+ else
+ {
+ pRange->aStart.SetCol( 0 );
+ pRange->aEnd.SetCol( MAXCOL );
+ }
+ }
+ if ( aCellRanges.Count() > 1 ) // Multi-Area
+ {
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pUnoRangesBase->GetDocShell(), aCellRanges ) );
+
+ return new ScVbaRange( mxParent, mxContext, xRanges, !bColumn, bColumn );
+ }
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), *aCellRanges.First() ) );
+ return new ScVbaRange( mxParent, mxContext, xRange, !bColumn, bColumn );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::getEntireRow() throw (uno::RuntimeException)
+{
+ return getEntireColumnOrRow(false);
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::getEntireColumn() throw (uno::RuntimeException)
+{
+ return getEntireColumnOrRow();
+}
+
+uno::Reference< excel::XComment > SAL_CALL
+ScVbaRange::AddComment( const uno::Any& Text ) throw (uno::RuntimeException)
+{
+ // if there is already a comment in the top-left cell then throw
+ if( getComment().is() )
+ throw uno::RuntimeException();
+
+ // workaround: Excel allows to create empty comment, Calc does not
+ ::rtl::OUString aNoteText;
+ if( Text.hasValue() && !(Text >>= aNoteText) )
+ throw uno::RuntimeException();
+ if( aNoteText.getLength() == 0 )
+ aNoteText = ::rtl::OUString( sal_Unicode( ' ' ) );
+
+ // try to create a new annotation
+ table::CellRangeAddress aRangePos = lclGetRangeAddress( mxRange );
+ table::CellAddress aNotePos( aRangePos.Sheet, aRangePos.StartColumn, aRangePos.StartRow );
+ uno::Reference< sheet::XSheetCellRange > xCellRange( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnosSupp( xCellRange->getSpreadsheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSheetAnnotations > xAnnos( xAnnosSupp->getAnnotations(), uno::UNO_SET_THROW );
+ xAnnos->insertNew( aNotePos, aNoteText );
+ return new ScVbaComment( this, mxContext, getUnoModel(), mxRange );
+}
+
+uno::Reference< excel::XComment > SAL_CALL
+ScVbaRange::getComment() throw (uno::RuntimeException)
+{
+ // intentional behavior to return a null object if no
+ // comment defined
+ uno::Reference< excel::XComment > xComment( new ScVbaComment( this, mxContext, getUnoModel(), mxRange ) );
+ if ( !xComment->Text( uno::Any(), uno::Any(), uno::Any() ).getLength() )
+ return NULL;
+ return xComment;
+
+}
+
+uno::Reference< beans::XPropertySet >
+getRowOrColumnProps( const uno::Reference< table::XCellRange >& xCellRange, bool bRows ) throw ( uno::RuntimeException )
+{
+ uno::Reference< table::XColumnRowRange > xColRow( xCellRange, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps;
+ if ( bRows )
+ xProps.set( xColRow->getRows(), uno::UNO_QUERY_THROW );
+ else
+ xProps.set( xColRow->getColumns(), uno::UNO_QUERY_THROW );
+ return xProps;
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getHidden() throw (uno::RuntimeException)
+{
+ // if multi-area result is the result of the
+ // first area
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(sal_Int32(1)), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->getHidden();
+ }
+ bool bIsVisible = false;
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProps = getRowOrColumnProps( mxRange, mbIsRows );
+ if ( !( xProps->getPropertyValue( ISVISIBLE ) >>= bIsVisible ) )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to get IsVisible property")), uno::Reference< uno::XInterface >() );
+ }
+ catch( uno::Exception& e )
+ {
+ throw uno::RuntimeException( e.Message, uno::Reference< uno::XInterface >() );
+ }
+ return uno::makeAny( !bIsVisible );
+}
+
+void SAL_CALL
+ScVbaRange::setHidden( const uno::Any& _hidden ) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->setHidden( _hidden );
+ }
+ return;
+ }
+
+ bool bHidden = extractBoolFromAny( _hidden );
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProps = getRowOrColumnProps( mxRange, mbIsRows );
+ xProps->setPropertyValue( ISVISIBLE, uno::Any( !bHidden ) );
+ }
+ catch( uno::Exception& e )
+ {
+ throw uno::RuntimeException( e.Message, uno::Reference< uno::XInterface >() );
+ }
+}
+
+::sal_Bool SAL_CALL
+ScVbaRange::Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replacement, const uno::Any& LookAt, const uno::Any& SearchOrder, const uno::Any& MatchCase, const uno::Any& MatchByte, const uno::Any& SearchFormat, const uno::Any& ReplaceFormat ) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ for ( sal_Int32 index = 1; index <= m_Areas->getCount(); ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( index ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->Replace( What, Replacement, LookAt, SearchOrder, MatchCase, MatchByte, SearchFormat, ReplaceFormat );
+ }
+ return sal_True; // seems to return true always ( or at least I haven't found the trick of
+ }
+
+ // sanity check required params
+ if ( !What.getLength() /*|| !Replacement.getLength()*/ )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, missing params" )) , uno::Reference< uno::XInterface >() );
+ rtl::OUString sWhat = VBAToRegexp( What);
+ // #TODO #FIXME SearchFormat & ReplacesFormat are not processed
+ // What do we do about MatchByte.. we don't seem to support that
+ const SvxSearchItem& globalSearchOptions = ScGlobal::GetSearchItem();
+ SvxSearchItem newOptions( globalSearchOptions );
+
+ sal_Int16 nLook = globalSearchOptions.GetWordOnly() ? excel::XlLookAt::xlPart : excel::XlLookAt::xlWhole;
+ sal_Int16 nSearchOrder = globalSearchOptions.GetRowDirection() ? excel::XlSearchOrder::xlByRows : excel::XlSearchOrder::xlByColumns;
+
+ sal_Bool bMatchCase = sal_False;
+ uno::Reference< util::XReplaceable > xReplace( mxRange, uno::UNO_QUERY );
+ if ( xReplace.is() )
+ {
+ uno::Reference< util::XReplaceDescriptor > xDescriptor =
+ xReplace->createReplaceDescriptor();
+
+ xDescriptor->setSearchString( sWhat);
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHREGEXP ) ), uno::makeAny( sal_True ) );
+ xDescriptor->setReplaceString( Replacement);
+ if ( LookAt.hasValue() )
+ {
+ // sets SearchWords ( true is Cell match )
+ nLook = ::comphelper::getINT16( LookAt );
+ sal_Bool bSearchWords = sal_False;
+ if ( nLook == excel::XlLookAt::xlPart )
+ bSearchWords = sal_False;
+ else if ( nLook == excel::XlLookAt::xlWhole )
+ bSearchWords = sal_True;
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for LookAt" )) , uno::Reference< uno::XInterface >() );
+ // set global search props ( affects the find dialog
+ // and of course the defaults for this method
+ newOptions.SetWordOnly( bSearchWords );
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHWORDS ) ), uno::makeAny( bSearchWords ) );
+ }
+ // sets SearchByRow ( true for Rows )
+ if ( SearchOrder.hasValue() )
+ {
+ nSearchOrder = ::comphelper::getINT16( SearchOrder );
+ sal_Bool bSearchByRow = sal_False;
+ if ( nSearchOrder == excel::XlSearchOrder::xlByColumns )
+ bSearchByRow = sal_False;
+ else if ( nSearchOrder == excel::XlSearchOrder::xlByRows )
+ bSearchByRow = sal_True;
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for SearchOrder" )) , uno::Reference< uno::XInterface >() );
+
+ newOptions.SetRowDirection( bSearchByRow );
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHBYROW ) ), uno::makeAny( bSearchByRow ) );
+ }
+ if ( MatchCase.hasValue() )
+ {
+ // SearchCaseSensitive
+ MatchCase >>= bMatchCase;
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHCASE ) ), uno::makeAny( bMatchCase ) );
+ }
+
+ ScGlobal::SetSearchItem( newOptions );
+ // ignore MatchByte for the moment, its not supported in
+ // OOo.org afaik
+
+ uno::Reference< util::XSearchDescriptor > xSearch( xDescriptor, uno::UNO_QUERY );
+ // Find all cells that being replaced, used to fire the range changed event.
+ uno::Reference< container::XIndexAccess > xIndexAccess = xReplace->findAll( xSearch );
+ xReplace->replaceAll( xSearch );
+
+ if ( xIndexAccess.is() && xIndexAccess->getCount() > 0 )
+ {
+ // Fires the range change event.
+ ScCellRangesBase* pScCellRangesBase = ScCellRangesBase::getImplementation( xIndexAccess ); //liuchen 2010-01-05
+ lcl_NotifyRangeChanges( getScDocShell()->GetModel(), pScCellRangesBase ); //liuchen 2010-01-05 the original convert method will fail in SUSE
+ }
+ }
+ return sal_True; // always
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& LookIn, const uno::Any& LookAt, const uno::Any& SearchOrder, const uno::Any& SearchDirection, const uno::Any& MatchCase, const uno::Any& /*MatchByte*/, const uno::Any& /*SearchFormat*/ ) throw (uno::RuntimeException)
+{
+ // return a Range object that represents the first cell where that information is found.
+ rtl::OUString sWhat;
+ sal_Int32 nWhat = 0;
+ double fWhat = 0.0;
+
+ // string.
+ if( What >>= sWhat )
+ {
+ if( !sWhat.getLength() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Find, missing params" )) , uno::Reference< uno::XInterface >() );
+ }
+ else if( What >>= nWhat )
+ {
+ sWhat = rtl::OUString::valueOf( nWhat );
+ }
+ else if( What >>= fWhat )
+ {
+ sWhat = rtl::OUString::valueOf( fWhat );
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Find, missing params" )) , uno::Reference< uno::XInterface >() );
+
+ rtl::OUString sSearch = VBAToRegexp( sWhat );
+
+ const SvxSearchItem& globalSearchOptions = ScGlobal::GetSearchItem();
+ SvxSearchItem newOptions( globalSearchOptions );
+
+ sal_Int16 nLookAt = globalSearchOptions.GetWordOnly() ? excel::XlLookAt::xlPart : excel::XlLookAt::xlWhole;
+ sal_Int16 nSearchOrder = globalSearchOptions.GetRowDirection() ? excel::XlSearchOrder::xlByRows : excel::XlSearchOrder::xlByColumns;
+
+ uno::Reference< util::XSearchable > xSearch( mxRange, uno::UNO_QUERY );
+ if( xSearch.is() )
+ {
+ uno::Reference< util::XSearchDescriptor > xDescriptor = xSearch->createSearchDescriptor();
+ xDescriptor->setSearchString( sSearch );
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHREGEXP ) ), uno::Any( true ) );
+
+ uno::Reference< excel::XRange > xAfterRange;
+ uno::Reference< table::XCellRange > xStartCell;
+ if( After >>= xAfterRange )
+ {
+ // After must be a single cell in the range
+ if( xAfterRange->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("After must be a single cell." )) , uno::Reference< uno::XInterface >() );
+ uno::Reference< excel::XRange > xCell( Cells( uno::makeAny( xAfterRange->getRow() ), uno::makeAny( xAfterRange->getColumn() ) ), uno::UNO_QUERY );
+ if( !xCell.is() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("After must be in range." )) , uno::Reference< uno::XInterface >() );
+ xStartCell.set( xAfterRange->getCellRange(), uno::UNO_QUERY_THROW );
+ }
+
+ // LookIn
+ if( LookIn.hasValue() )
+ {
+ sal_Int32 nLookIn = 0;
+ if( LookIn >>= nLookIn )
+ {
+ sal_Int16 nSearchType = 0;
+ switch( nLookIn )
+ {
+ case excel::XlFindLookIn::xlComments :
+ nSearchType = SVX_SEARCHIN_NOTE; // Notes
+ break;
+ case excel::XlFindLookIn::xlFormulas :
+ nSearchType = SVX_SEARCHIN_FORMULA;
+ break;
+ case excel::XlFindLookIn::xlValues :
+ nSearchType = SVX_SEARCHIN_VALUE;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for LookIn." )) , uno::Reference< uno::XInterface >() );
+ }
+ newOptions.SetCellType( nSearchType );
+ xDescriptor->setPropertyValue( rtl::OUString::createFromAscii( "SearchType" ), uno::makeAny( nSearchType ) );
+ }
+ }
+
+ // LookAt
+ if ( LookAt.hasValue() )
+ {
+ nLookAt = ::comphelper::getINT16( LookAt );
+ sal_Bool bSearchWords = sal_False;
+ if ( nLookAt == excel::XlLookAt::xlPart )
+ bSearchWords = sal_False;
+ else if ( nLookAt == excel::XlLookAt::xlWhole )
+ bSearchWords = sal_True;
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for LookAt" )) , uno::Reference< uno::XInterface >() );
+ newOptions.SetWordOnly( bSearchWords );
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHWORDS ) ), uno::makeAny( bSearchWords ) );
+ }
+
+ // SearchOrder
+ if ( SearchOrder.hasValue() )
+ {
+ nSearchOrder = ::comphelper::getINT16( SearchOrder );
+ sal_Bool bSearchByRow = sal_False;
+ if ( nSearchOrder == excel::XlSearchOrder::xlByColumns )
+ bSearchByRow = sal_False;
+ else if ( nSearchOrder == excel::XlSearchOrder::xlByRows )
+ bSearchByRow = sal_True;
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for SearchOrder" )) , uno::Reference< uno::XInterface >() );
+
+ newOptions.SetRowDirection( bSearchByRow );
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHBYROW ) ), uno::makeAny( bSearchByRow ) );
+ }
+
+ // SearchDirection
+ if ( SearchDirection.hasValue() )
+ {
+ sal_Int32 nSearchDirection = 0;
+ if( SearchDirection >>= nSearchDirection )
+ {
+ sal_Bool bSearchBackwards = sal_False;
+ if ( nSearchDirection == excel::XlSearchDirection::xlNext )
+ bSearchBackwards = sal_False;
+ else if( nSearchDirection == excel::XlSearchDirection::xlPrevious )
+ bSearchBackwards = sal_True;
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for SearchDirection" )) , uno::Reference< uno::XInterface >() );
+ newOptions.SetBackward( bSearchBackwards );
+ xDescriptor->setPropertyValue( rtl::OUString::createFromAscii( "SearchBackwards" ), uno::makeAny( bSearchBackwards ) );
+ }
+ }
+
+ // MatchCase
+ sal_Bool bMatchCase = sal_False;
+ if ( MatchCase.hasValue() )
+ {
+ // SearchCaseSensitive
+ if( !( MatchCase >>= bMatchCase ) )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Range::Replace, illegal value for MatchCase" )) , uno::Reference< uno::XInterface >() );
+ }
+ xDescriptor->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SRCHCASE ) ), uno::makeAny( bMatchCase ) );
+
+ // MatchByte
+ // SearchFormat
+ // ignore
+
+ ScGlobal::SetSearchItem( newOptions );
+
+ uno::Reference< uno::XInterface > xInterface = xStartCell.is() ? xSearch->findNext( xStartCell, xDescriptor) : xSearch->findFirst( xDescriptor );
+ uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY );
+ // if we are searching from a starting cell and failed to find a match
+ // then try from the begining
+ if ( !xCellRange.is() && xStartCell.is() )
+ {
+ xInterface = xSearch->findFirst( xDescriptor );
+ xCellRange.set( xInterface, uno::UNO_QUERY );
+ }
+ if ( xCellRange.is() )
+ {
+ uno::Reference< excel::XRange > xResultRange = new ScVbaRange( mxParent, mxContext, xCellRange );
+ if( xResultRange.is() )
+ {
+ xResultRange->Select();
+ return xResultRange;
+ }
+ }
+
+ }
+
+ return uno::Reference< excel::XRange >();
+}
+
+uno::Reference< table::XCellRange > processKey( const uno::Any& Key, uno::Reference< uno::XComponentContext >& xContext, ScDocShell* pDocSh )
+{
+ uno::Reference< excel::XRange > xKeyRange;
+ if ( Key.getValueType() == excel::XRange::static_type() )
+ {
+ xKeyRange.set( Key, uno::UNO_QUERY_THROW );
+ }
+ else if ( Key.getValueType() == ::getCppuType( static_cast< const rtl::OUString* >(0) ) )
+
+ {
+ rtl::OUString sRangeName = ::comphelper::getString( Key );
+ table::CellRangeAddress aRefAddr;
+ if ( !pDocSh )
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort no docshell to calculate key param")), uno::Reference< uno::XInterface >() );
+ xKeyRange = getRangeForName( xContext, sRangeName, pDocSh, aRefAddr );
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort illegal type value for key param")), uno::Reference< uno::XInterface >() );
+ uno::Reference< table::XCellRange > xKey;
+ xKey.set( xKeyRange->getCellRange(), uno::UNO_QUERY_THROW );
+ return xKey;
+}
+
+// helper method for Sort
+sal_Int32 findSortPropertyIndex( const uno::Sequence< beans::PropertyValue >& props,
+const rtl::OUString& sPropName ) throw( uno::RuntimeException )
+{
+ const beans::PropertyValue* pProp = props.getConstArray();
+ sal_Int32 nItems = props.getLength();
+
+ sal_Int32 count=0;
+ for ( ; count < nItems; ++count, ++pProp )
+ if ( pProp->Name.equals( sPropName ) )
+ return count;
+ if ( count == nItems )
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort unknown sort property")), uno::Reference< uno::XInterface >() );
+ return -1; //should never reach here ( satisfy compiler )
+}
+
+// helper method for Sort
+void updateTableSortField( const uno::Reference< table::XCellRange >& xParentRange,
+ const uno::Reference< table::XCellRange >& xColRowKey, sal_Int16 nOrder,
+ table::TableSortField& aTableField, sal_Bool bIsSortColumn, sal_Bool bMatchCase ) throw ( uno::RuntimeException )
+{
+ RangeHelper parentRange( xParentRange );
+ RangeHelper colRowRange( xColRowKey );
+
+ table::CellRangeAddress parentRangeAddress = parentRange.getCellRangeAddressable()->getRangeAddress();
+
+ table::CellRangeAddress colRowKeyAddress = colRowRange.getCellRangeAddressable()->getRangeAddress();
+
+ // make sure that upper left poing of key range is within the
+ // parent range
+ if ( ( !bIsSortColumn && colRowKeyAddress.StartColumn >= parentRangeAddress.StartColumn &&
+ colRowKeyAddress.StartColumn <= parentRangeAddress.EndColumn ) || ( bIsSortColumn &&
+ colRowKeyAddress.StartRow >= parentRangeAddress.StartRow &&
+ colRowKeyAddress.StartRow <= parentRangeAddress.EndRow ) )
+ {
+ //determine col/row index
+ if ( bIsSortColumn )
+ aTableField.Field = colRowKeyAddress.StartRow - parentRangeAddress.StartRow;
+ else
+ aTableField.Field = colRowKeyAddress.StartColumn - parentRangeAddress.StartColumn;
+ aTableField.IsCaseSensitive = bMatchCase;
+
+ if ( nOrder == excel::XlSortOrder::xlAscending )
+ aTableField.IsAscending = sal_True;
+ else
+ aTableField.IsAscending = sal_False;
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal Key param" ) ), uno::Reference< uno::XInterface >() );
+
+
+}
+
+void SAL_CALL
+ScVbaRange::Sort( const uno::Any& Key1, const uno::Any& Order1, const uno::Any& Key2, const uno::Any& /*Type*/, const uno::Any& Order2, const uno::Any& Key3, const uno::Any& Order3, const uno::Any& Header, const uno::Any& OrderCustom, const uno::Any& MatchCase, const uno::Any& Orientation, const uno::Any& SortMethod, const uno::Any& DataOption1, const uno::Any& DataOption2, const uno::Any& DataOption3 ) throw (uno::RuntimeException)
+{
+ // #TODO# #FIXME# can we do something with Type
+ if ( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("That command cannot be used on multiple selections" ) ), uno::Reference< uno::XInterface >() );
+
+ sal_Int16 nDataOption1 = excel::XlSortDataOption::xlSortNormal;
+ sal_Int16 nDataOption2 = excel::XlSortDataOption::xlSortNormal;;
+ sal_Int16 nDataOption3 = excel::XlSortDataOption::xlSortNormal;
+
+ ScDocument* pDoc = getScDocument();
+ if ( !pDoc )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
+
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisRangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ ScSortParam aSortParam;
+ SCTAB nTab = thisRangeAddress.Sheet;
+ pDoc->GetSortParam( aSortParam, nTab );
+
+ if ( DataOption1.hasValue() )
+ DataOption1 >>= nDataOption1;
+ if ( DataOption2.hasValue() )
+ DataOption2 >>= nDataOption2;
+ if ( DataOption3.hasValue() )
+ DataOption3 >>= nDataOption3;
+
+ // 1) #TODO #FIXME need to process DataOption[1..3] not used currently
+ // 2) #TODO #FIXME need to refactor this ( below ) into a IsSingleCell() method
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY_THROW );
+
+ // 'Fraid I don't remember what I was trying to achieve here ???
+/*
+ if ( isSingleCellRange() )
+ {
+ uno::Reference< XRange > xCurrent = CurrentRegion();
+ xCurrent->Sort( Key1, Order1, Key2, Type, Order2, Key3, Order3, Header, OrderCustom, MatchCase, Orientation, SortMethod, DataOption1, DataOption2, DataOption3 );
+ return;
+ }
+*/
+ // set up defaults
+
+ sal_Int16 nOrder1 = aSortParam.bAscending[0] ? excel::XlSortOrder::xlAscending : excel::XlSortOrder::xlDescending;
+ sal_Int16 nOrder2 = aSortParam.bAscending[1] ? excel::XlSortOrder::xlAscending : excel::XlSortOrder::xlDescending;
+ sal_Int16 nOrder3 = aSortParam.bAscending[2] ? excel::XlSortOrder::xlAscending : excel::XlSortOrder::xlDescending;
+
+ sal_Int16 nCustom = aSortParam.nUserIndex;
+ sal_Int16 nSortMethod = excel::XlSortMethod::xlPinYin;
+ sal_Bool bMatchCase = aSortParam.bCaseSens;
+
+ // seems to work opposite to expected, see below
+ sal_Int16 nOrientation = aSortParam.bByRow ? excel::XlSortOrientation::xlSortColumns : excel::XlSortOrientation::xlSortRows;
+
+ if ( Orientation.hasValue() )
+ {
+ // Documentation says xlSortRows is default but that doesn't appear to be
+ // the case. Also it appears that xlSortColumns is the default which
+ // strangely enought sorts by Row
+ nOrientation = ::comphelper::getINT16( Orientation );
+ // persist new option to be next calls default
+ if ( nOrientation == excel::XlSortOrientation::xlSortRows )
+ aSortParam.bByRow = FALSE;
+ else
+ aSortParam.bByRow = TRUE;
+
+ }
+
+ sal_Bool bIsSortColumns=sal_False; // sort by row
+
+ if ( nOrientation == excel::XlSortOrientation::xlSortRows )
+ bIsSortColumns = sal_True;
+ sal_Int16 nHeader = 0;
+#ifdef VBA_OOBUILD_HACK
+ nHeader = aSortParam.nCompatHeader;
+#endif
+ sal_Bool bContainsHeader = sal_False;
+
+ if ( Header.hasValue() )
+ {
+ nHeader = ::comphelper::getINT16( Header );
+#ifdef VBA_OOBUILD_HACK
+ aSortParam.nCompatHeader = nHeader;
+#endif
+ }
+
+ if ( nHeader == excel::XlYesNoGuess::xlGuess )
+ {
+ bool bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), static_cast< SCCOL >( thisRangeAddress.EndColumn ), static_cast< SCROW >( thisRangeAddress.EndRow ), static_cast< SCTAB >( thisRangeAddress.Sheet ));
+ bool bHasRowHeader = pDoc->HasRowHeader( static_cast< SCCOL >( thisRangeAddress.StartColumn ), static_cast< SCROW >( thisRangeAddress.StartRow ), static_cast< SCCOL >( thisRangeAddress.EndColumn ), static_cast< SCROW >( thisRangeAddress.EndRow ), static_cast< SCTAB >( thisRangeAddress.Sheet ) );
+ if ( bHasColHeader || bHasRowHeader )
+ nHeader = excel::XlYesNoGuess::xlYes;
+ else
+ nHeader = excel::XlYesNoGuess::xlNo;
+#ifdef VBA_OOBUILD_HACK
+ aSortParam.nCompatHeader = nHeader;
+#endif
+ }
+
+ if ( nHeader == excel::XlYesNoGuess::xlYes )
+ bContainsHeader = sal_True;
+
+ if ( SortMethod.hasValue() )
+ {
+ nSortMethod = ::comphelper::getINT16( SortMethod );
+ }
+
+ if ( OrderCustom.hasValue() )
+ {
+ OrderCustom >>= nCustom;
+ --nCustom; // 0-based in OOo
+ aSortParam.nUserIndex = nCustom;
+ }
+
+ if ( MatchCase.hasValue() )
+ {
+ MatchCase >>= bMatchCase;
+ aSortParam.bCaseSens = bMatchCase;
+ }
+
+ if ( Order1.hasValue() )
+ {
+ nOrder1 = ::comphelper::getINT16(Order1);
+ if ( nOrder1 == excel::XlSortOrder::xlAscending )
+ aSortParam.bAscending[0] = TRUE;
+ else
+ aSortParam.bAscending[0] = FALSE;
+
+ }
+ if ( Order2.hasValue() )
+ {
+ nOrder2 = ::comphelper::getINT16(Order2);
+ if ( nOrder2 == excel::XlSortOrder::xlAscending )
+ aSortParam.bAscending[1] = TRUE;
+ else
+ aSortParam.bAscending[1] = FALSE;
+ }
+ if ( Order3.hasValue() )
+ {
+ nOrder3 = ::comphelper::getINT16(Order3);
+ if ( nOrder3 == excel::XlSortOrder::xlAscending )
+ aSortParam.bAscending[2] = TRUE;
+ else
+ aSortParam.bAscending[2] = FALSE;
+ }
+
+ uno::Reference< table::XCellRange > xKey1;
+ uno::Reference< table::XCellRange > xKey2;
+ uno::Reference< table::XCellRange > xKey3;
+ ScDocShell* pDocShell = getScDocShell();
+ xKey1 = processKey( Key1, mxContext, pDocShell );
+ if ( !xKey1.is() )
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort needs a key1 param")), uno::Reference< uno::XInterface >() );
+
+ if ( Key2.hasValue() )
+ xKey2 = processKey( Key2, mxContext, pDocShell );
+ if ( Key3.hasValue() )
+ xKey3 = processKey( Key3, mxContext, pDocShell );
+
+ uno::Reference< util::XSortable > xSort( mxRange, uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::PropertyValue > sortDescriptor = xSort->createSortDescriptor();
+ sal_Int32 nTableSortFieldIndex = findSortPropertyIndex( sortDescriptor, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SortFields") ) );
+
+ uno::Sequence< table::TableSortField > sTableFields(1);
+ sal_Int32 nTableIndex = 0;
+ updateTableSortField( mxRange, xKey1, nOrder1, sTableFields[ nTableIndex++ ], bIsSortColumns, bMatchCase );
+
+ if ( xKey2.is() )
+ {
+ sTableFields.realloc( sTableFields.getLength() + 1 );
+ updateTableSortField( mxRange, xKey2, nOrder2, sTableFields[ nTableIndex++ ], bIsSortColumns, bMatchCase );
+ }
+ if ( xKey3.is() )
+ {
+ sTableFields.realloc( sTableFields.getLength() + 1 );
+ updateTableSortField( mxRange, xKey3, nOrder3, sTableFields[ nTableIndex++ ], bIsSortColumns, bMatchCase );
+ }
+ sortDescriptor[ nTableSortFieldIndex ].Value <<= sTableFields;
+
+ sal_Int32 nIndex = findSortPropertyIndex( sortDescriptor, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsSortColumns")) );
+ sortDescriptor[ nIndex ].Value <<= bIsSortColumns;
+
+ nIndex = findSortPropertyIndex( sortDescriptor, CONTS_HEADER );
+ sortDescriptor[ nIndex ].Value <<= bContainsHeader;
+
+ pDoc->SetSortParam( aSortParam, nTab );
+ xSort->sort( sortDescriptor );
+
+ // #FIXME #TODO
+ // The SortMethod param is not processed ( not sure what its all about, need to
+
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::End( ::sal_Int32 Direction ) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( getArea( 0 ), uno::UNO_QUERY_THROW );
+ return xRange->End( Direction );
+ }
+
+ table::CellAddress aAddress = getLeftUpperCellAddress();
+ SCTAB nTab = aAddress.Sheet;
+ SCCOL nCurX = aAddress.Column;
+ SCROW nCurY = aAddress.Row;
+ SCCOL nNewX = nCurX;
+ SCROW nNewY = nCurY;
+
+ ScDocShell* pDocShell = getScDocShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ SCsCOL nMoveX = 0;
+ SCsROW nMoveY = 0;
+ switch ( Direction )
+ {
+ case excel::XlDirection::xlDown:
+ nMoveY = 1;
+ break;
+ case excel::XlDirection::xlUp:
+ nMoveY = -1;
+ break;
+ case excel::XlDirection::xlToLeft:
+ nMoveX = -1;
+ break;
+ case excel::XlDirection::xlToRight:
+ nMoveX = 1;
+ break;
+ default:
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Invalid Direction" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ if ( pDoc )
+ {
+ pDoc->FindAreaPos( nNewX, nNewY, nTab, nMoveX, nMoveY );
+ }
+
+ ScRange aNewRange( (SCCOL)nNewX, (SCROW)nNewY, nTab, (SCCOL)nNewX, (SCROW)nNewY, nTab );
+ uno::Reference< table::XCellRange > xCellRange( new ScCellRangeObj( getScDocShell(), aNewRange ) );
+ uno::Reference< excel::XRange > xResultRange = new ScVbaRange( mxParent, mxContext, xCellRange );
+ return xResultRange;
+}
+
+bool
+ScVbaRange::isSingleCellRange()
+{
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY);
+ if ( xColumnRowRange.is() && xColumnRowRange->getRows()->getCount() == 1 && xColumnRowRange->getColumns()->getCount() == 1 )
+ return true;
+ return false;
+}
+
+uno::Reference< excel::XCharacters > SAL_CALL
+ScVbaRange::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException)
+{
+ if ( !isSingleCellRange() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't create Characters property for multicell range ") ), uno::Reference< uno::XInterface >() );
+ uno::Reference< text::XSimpleText > xSimple(mxRange->getCellByPosition(0,0) , uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::GetDocumentFromRange(mxRange);
+ if ( !pDoc )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
+
+ ScVbaPalette aPalette( pDoc->GetDocumentShell() );
+ return new ScVbaCharacters( this, mxContext, aPalette, xSimple, Start, Length );
+}
+
+ void SAL_CALL
+ScVbaRange::Delete( const uno::Any& Shift ) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->Delete( Shift );
+ }
+ return;
+ }
+ sheet::CellDeleteMode mode = sheet::CellDeleteMode_NONE ;
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ if ( Shift.hasValue() )
+ {
+ sal_Int32 nShift = 0;
+ Shift >>= nShift;
+ switch ( nShift )
+ {
+ case excel::XlDeleteShiftDirection::xlShiftUp:
+ mode = sheet::CellDeleteMode_UP;
+ break;
+ case excel::XlDeleteShiftDirection::xlShiftToLeft:
+ mode = sheet::CellDeleteMode_LEFT;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("Illegal paramater ") ), uno::Reference< uno::XInterface >() );
+ }
+ }
+ else
+ {
+ bool bFullRow = ( thisAddress.StartColumn == 0 && thisAddress.EndColumn == MAXCOL );
+ sal_Int32 nCols = thisAddress.EndColumn - thisAddress.StartColumn;
+ sal_Int32 nRows = thisAddress.EndRow - thisAddress.StartRow;
+ if ( mbIsRows || bFullRow || ( nCols >= nRows ) )
+ mode = sheet::CellDeleteMode_UP;
+ else
+ mode = sheet::CellDeleteMode_LEFT;
+ }
+ uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ xCellRangeMove->removeRange( thisAddress, mode );
+
+}
+
+//XElementAccess
+sal_Bool SAL_CALL
+ScVbaRange::hasElements() throw (uno::RuntimeException)
+{
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY );
+ if ( xColumnRowRange.is() )
+ if ( xColumnRowRange->getRows()->getCount() ||
+ xColumnRowRange->getColumns()->getCount() )
+ return sal_True;
+ return sal_False;
+}
+
+// XEnumerationAccess
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaRange::createEnumeration() throw (uno::RuntimeException)
+{
+ if ( mbIsColumns || mbIsRows )
+ {
+ uno::Reference< table::XColumnRowRange > xColumnRowRange(mxRange, uno::UNO_QUERY );
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(1) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ sal_Int32 nElems = 0;
+ if ( mbIsColumns )
+ nElems = xColumnRowRange->getColumns()->getCount();
+ else
+ nElems = xColumnRowRange->getRows()->getCount();
+ return new ColumnsRowEnumeration( mxContext, xRange, nElems );
+
+ }
+ return new CellsEnumeration( mxParent, mxContext, m_Areas );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaRange::getDefaultMethodName( ) throw (uno::RuntimeException)
+{
+ const static rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM("Item") );
+ return sName;
+}
+
+
+uno::Reference< awt::XDevice >
+getDeviceFromDoc( const uno::Reference< frame::XModel >& xModel ) throw( uno::RuntimeException )
+{
+ uno::Reference< frame::XController > xController( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< frame::XFrame> xFrame( xController->getFrame(), uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XDevice > xDevice( xFrame->getComponentWindow(), uno::UNO_QUERY_THROW );
+ return xDevice;
+}
+
+// returns calc internal col. width ( in points )
+double
+ScVbaRange::getCalcColWidth( const table::CellRangeAddress& rAddress) throw (uno::RuntimeException)
+{
+ ScDocument* pDoc = getScDocument();
+ USHORT nWidth = pDoc->GetOriginalWidth( static_cast< SCCOL >( rAddress.StartColumn ), static_cast< SCTAB >( rAddress.Sheet ) );
+ double nPoints = lcl_TwipsToPoints( nWidth );
+ nPoints = lcl_Round2DecPlaces( nPoints );
+ return nPoints;
+}
+
+double
+ScVbaRange::getCalcRowHeight( const table::CellRangeAddress& rAddress ) throw (uno::RuntimeException)
+{
+ ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
+ USHORT nWidth = pDoc->GetOriginalHeight( rAddress.StartRow, rAddress.Sheet );
+ double nPoints = lcl_TwipsToPoints( nWidth );
+ nPoints = lcl_Round2DecPlaces( nPoints );
+ return nPoints;
+}
+
+// return Char Width in points
+double getDefaultCharWidth( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException )
+{
+ const static rtl::OUString sDflt( RTL_CONSTASCII_USTRINGPARAM("Default"));
+ const static rtl::OUString sCharFontName( RTL_CONSTASCII_USTRINGPARAM("CharFontName"));
+ const static rtl::OUString sPageStyles( RTL_CONSTASCII_USTRINGPARAM("PageStyles"));
+ // get the font from the default style
+ uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess( xStyleSupplier->getStyleFamilies(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess2( xNameAccess->getByName( sPageStyles ), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xNameAccess2->getByName( sDflt ), uno::UNO_QUERY_THROW );
+ rtl::OUString sFontName;
+ xProps->getPropertyValue( sCharFontName ) >>= sFontName;
+
+ uno::Reference< awt::XDevice > xDevice = getDeviceFromDoc( xModel );
+ awt::FontDescriptor aDesc;
+ aDesc.Name = sFontName;
+ uno::Reference< awt::XFont > xFont( xDevice->getFont( aDesc ), uno::UNO_QUERY_THROW );
+ double nCharPixelWidth = xFont->getCharWidth( (sal_Int8)'0' );
+
+ double nPixelsPerMeter = xDevice->getInfo().PixelPerMeterX;
+ double nCharWidth = nCharPixelWidth / nPixelsPerMeter;
+ nCharWidth = nCharWidth * (double)56700;// in twips
+ return lcl_TwipsToPoints( (USHORT)nCharWidth );
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getColumnWidth() throw (uno::RuntimeException)
+{
+ sal_Int32 nLen = m_Areas->getCount();
+ if ( nLen > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(1) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->getColumnWidth();
+ }
+
+ double nColWidth = 0;
+ ScDocShell* pShell = getScDocShell();
+ if ( pShell )
+ {
+ uno::Reference< frame::XModel > xModel = pShell->GetModel();
+ double defaultCharWidth = getDefaultCharWidth( xModel );
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ sal_Int32 nStartCol = thisAddress.StartColumn;
+ sal_Int32 nEndCol = thisAddress.EndColumn;
+ USHORT nColTwips = 0;
+ for( sal_Int32 nCol = nStartCol ; nCol <= nEndCol; ++nCol )
+ {
+ thisAddress.StartColumn = nCol;
+ USHORT nCurTwips = pShell->GetDocument()->GetOriginalWidth( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCTAB >( thisAddress.Sheet ) );
+ if ( nCol == nStartCol )
+ nColTwips = nCurTwips;
+ if ( nColTwips != nCurTwips )
+ return aNULL();
+ }
+ nColWidth = lcl_Round2DecPlaces( lcl_TwipsToPoints( nColTwips ) );
+ if ( xModel.is() )
+ nColWidth = nColWidth / defaultCharWidth;
+ }
+ nColWidth = lcl_Round2DecPlaces( nColWidth );
+ return uno::makeAny( nColWidth );
+}
+
+void SAL_CALL
+ScVbaRange::setColumnWidth( const uno::Any& _columnwidth ) throw (uno::RuntimeException)
+{
+ sal_Int32 nLen = m_Areas->getCount();
+ if ( nLen > 1 )
+ {
+ for ( sal_Int32 index = 1; index != nLen; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(index) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->setColumnWidth( _columnwidth );
+ }
+ return;
+ }
+ double nColWidth = 0;
+ _columnwidth >>= nColWidth;
+ nColWidth = lcl_Round2DecPlaces( nColWidth );
+ ScDocShell* pDocShell = getScDocShell();
+ if ( pDocShell )
+ {
+ uno::Reference< frame::XModel > xModel = pDocShell->GetModel();
+ if ( xModel.is() )
+ {
+
+ nColWidth = ( nColWidth * getDefaultCharWidth( xModel ) );
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ USHORT nTwips = lcl_pointsToTwips( nColWidth );
+
+ ScDocFunc aFunc(*pDocShell);
+ SCCOLROW nColArr[2];
+ nColArr[0] = thisAddress.StartColumn;
+ nColArr[1] = thisAddress.EndColumn;
+ aFunc.SetWidthOrHeight( TRUE, 1, nColArr, thisAddress.Sheet, SC_SIZE_ORIGINAL,
+ nTwips, TRUE, TRUE );
+
+ }
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getWidth() throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(1) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->getWidth();
+ }
+ uno::Reference< table::XColumnRowRange > xColRowRange( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xColRowRange->getColumns(), uno::UNO_QUERY_THROW );
+ sal_Int32 nElems = xIndexAccess->getCount();
+ double nWidth = 0;
+ for ( sal_Int32 index=0; index<nElems; ++index )
+ {
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( xIndexAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ double nTmpWidth = getCalcColWidth( xAddressable->getRangeAddress() );
+ nWidth += nTmpWidth;
+ }
+ return uno::makeAny( nWidth );
+}
+
+uno::Any SAL_CALL
+ScVbaRange::Areas( const uno::Any& item) throw (uno::RuntimeException)
+{
+ if ( !item.hasValue() )
+ return uno::makeAny( m_Areas );
+ return m_Areas->Item( item, uno::Any() );
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException )
+{
+ if ( !m_Areas.is() )
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No areas available")), uno::Reference< uno::XInterface >() );
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( ++nIndex ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange;
+}
+
+uno::Any
+ScVbaRange::Borders( const uno::Any& item ) throw( script::BasicErrorException, uno::RuntimeException )
+{
+ if ( !item.hasValue() )
+ return uno::makeAny( getBorders() );
+ return getBorders()->Item( item, uno::Any() );
+}
+
+uno::Any SAL_CALL
+ScVbaRange::BorderAround( const css::uno::Any& LineStyle, const css::uno::Any& Weight,
+ const css::uno::Any& ColorIndex, const css::uno::Any& Color ) throw (css::uno::RuntimeException)
+{
+ sal_Int32 nCount = getBorders()->getCount();
+
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ const sal_Int32 nLineType = supportedIndexTable[i];
+ switch( nLineType )
+ {
+ case excel::XlBordersIndex::xlEdgeLeft:
+ case excel::XlBordersIndex::xlEdgeTop:
+ case excel::XlBordersIndex::xlEdgeBottom:
+ case excel::XlBordersIndex::xlEdgeRight:
+ {
+ uno::Reference< excel::XBorder > xBorder( m_Borders->Item( uno::makeAny( nLineType ), uno::Any() ), uno::UNO_QUERY_THROW );
+ if( LineStyle.hasValue() )
+ {
+ xBorder->setLineStyle( LineStyle );
+ }
+ if( Weight.hasValue() )
+ {
+ xBorder->setWeight( Weight );
+ }
+ if( ColorIndex.hasValue() )
+ {
+ xBorder->setColorIndex( ColorIndex );
+ }
+ if( Color.hasValue() )
+ {
+ xBorder->setColor( Color );
+ }
+ break;
+ }
+ case excel::XlBordersIndex::xlInsideVertical:
+ case excel::XlBordersIndex::xlInsideHorizontal:
+ case excel::XlBordersIndex::xlDiagonalDown:
+ case excel::XlBordersIndex::xlDiagonalUp:
+ break;
+ default:
+ return uno::makeAny( sal_False );
+ }
+ }
+ return uno::makeAny( sal_True );
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getRowHeight() throw (uno::RuntimeException)
+{
+ sal_Int32 nLen = m_Areas->getCount();
+ if ( nLen > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(1) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->getRowHeight();
+ }
+
+ // if any row's RowHeight in the
+ // range is different from any other then return NULL
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+
+ sal_Int32 nStartRow = thisAddress.StartRow;
+ sal_Int32 nEndRow = thisAddress.EndRow;
+ USHORT nRowTwips = 0;
+ // #TODO probably possible to use the SfxItemSet ( and see if
+ // SFX_ITEM_DONTCARE is set ) to improve performance
+// #CHECKME looks like this is general behaviour not just row Range specific
+// if ( mbIsRows )
+ ScDocShell* pShell = getScDocShell();
+ if ( pShell )
+ {
+ for ( sal_Int32 nRow = nStartRow ; nRow <= nEndRow; ++nRow )
+ {
+ thisAddress.StartRow = nRow;
+ USHORT nCurTwips = pShell->GetDocument()->GetOriginalHeight( thisAddress.StartRow, thisAddress.Sheet );
+ if ( nRow == nStartRow )
+ nRowTwips = nCurTwips;
+ if ( nRowTwips != nCurTwips )
+ return aNULL();
+ }
+ }
+ double nHeight = lcl_Round2DecPlaces( lcl_TwipsToPoints( nRowTwips ) );
+ return uno::makeAny( nHeight );
+}
+
+void SAL_CALL
+ScVbaRange::setRowHeight( const uno::Any& _rowheight) throw (uno::RuntimeException)
+{
+ sal_Int32 nLen = m_Areas->getCount();
+ if ( nLen > 1 )
+ {
+ for ( sal_Int32 index = 1; index != nLen; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(index) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->setRowHeight( _rowheight );
+ }
+ return;
+ }
+ double nHeight = 0; // Incomming height is in points
+ _rowheight >>= nHeight;
+ nHeight = lcl_Round2DecPlaces( nHeight );
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ USHORT nTwips = lcl_pointsToTwips( nHeight );
+
+ ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange );
+ ScDocFunc aFunc(*pDocShell);
+ SCCOLROW nRowArr[2];
+ nRowArr[0] = thisAddress.StartRow;
+ nRowArr[1] = thisAddress.EndRow;
+ aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, thisAddress.Sheet, SC_SIZE_ORIGINAL,
+ nTwips, TRUE, TRUE );
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getPageBreak() throw (uno::RuntimeException)
+{
+ sal_Int32 nPageBreak = excel::XlPageBreak::xlPageBreakNone;
+ ScDocShell* pShell = excel::GetDocShellFromRange( mxRange );
+ if ( pShell )
+ {
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ BOOL bColumn = FALSE;
+
+ if (thisAddress.StartRow==0)
+ bColumn = TRUE;
+
+ uno::Reference< frame::XModel > xModel = pShell->GetModel();
+ if ( xModel.is() )
+ {
+ ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
+
+ ScBreakType nBreak = BREAK_NONE;
+ if ( !bColumn )
+ nBreak = pDoc->HasRowBreak(thisAddress.StartRow, thisAddress.Sheet);
+ else
+ nBreak = pDoc->HasColBreak(thisAddress.StartColumn, thisAddress.Sheet);
+
+ if (nBreak & BREAK_PAGE)
+ nPageBreak = excel::XlPageBreak::xlPageBreakAutomatic;
+
+ if (nBreak & BREAK_MANUAL)
+ nPageBreak = excel::XlPageBreak::xlPageBreakManual;
+ }
+ }
+
+ return uno::makeAny( nPageBreak );
+}
+
+void SAL_CALL
+ScVbaRange::setPageBreak( const uno::Any& _pagebreak) throw (uno::RuntimeException)
+{
+ sal_Int32 nPageBreak = 0;
+ _pagebreak >>= nPageBreak;
+
+ ScDocShell* pShell = excel::GetDocShellFromRange( mxRange );
+ if ( pShell )
+ {
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ if ((thisAddress.StartColumn==0) && (thisAddress.StartRow==0))
+ return;
+ BOOL bColumn = FALSE;
+
+ if (thisAddress.StartRow==0)
+ bColumn = TRUE;
+
+ ScAddress aAddr( static_cast<SCCOL>(thisAddress.StartColumn), thisAddress.StartRow, thisAddress.Sheet );
+ uno::Reference< frame::XModel > xModel = pShell->GetModel();
+ if ( xModel.is() )
+ {
+ ScTabViewShell* pViewShell = excel::getBestViewShell( xModel );
+ if ( nPageBreak == excel::XlPageBreak::xlPageBreakManual )
+ pViewShell->InsertPageBreak( bColumn, TRUE, &aAddr);
+ else if ( nPageBreak == excel::XlPageBreak::xlPageBreakNone )
+ pViewShell->DeletePageBreak( bColumn, TRUE, &aAddr);
+ }
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getHeight() throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(1) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->getHeight();
+ }
+
+ uno::Reference< table::XColumnRowRange > xColRowRange( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xColRowRange->getRows(), uno::UNO_QUERY_THROW );
+ sal_Int32 nElems = xIndexAccess->getCount();
+ double nHeight = 0;
+ for ( sal_Int32 index=0; index<nElems; ++index )
+ {
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( xIndexAccess->getByIndex( index ), uno::UNO_QUERY_THROW );
+ nHeight += getCalcRowHeight(xAddressable->getRangeAddress() );
+ }
+ return uno::makeAny( nHeight );
+}
+
+awt::Point
+ScVbaRange::getPosition() throw ( uno::RuntimeException )
+{
+ awt::Point aPoint;
+ uno::Reference< beans::XPropertySet > xProps;
+ if ( mxRange.is() )
+ xProps.set( mxRange, uno::UNO_QUERY_THROW );
+ else
+ xProps.set( mxRanges, uno::UNO_QUERY_THROW );
+ xProps->getPropertyValue(POSITION) >>= aPoint;
+ return aPoint;
+}
+uno::Any SAL_CALL
+ScVbaRange::getLeft() throw (uno::RuntimeException)
+{
+ // helperapi returns the first ranges left ( and top below )
+ if ( m_Areas->getCount() > 1 )
+ return getArea( 0 )->getLeft();
+ awt::Point aPoint = getPosition();
+ return uno::makeAny( lcl_hmmToPoints( aPoint.X ) );
+}
+
+
+uno::Any SAL_CALL
+ScVbaRange::getTop() throw (uno::RuntimeException)
+{
+ // helperapi returns the first ranges top
+ if ( m_Areas->getCount() > 1 )
+ return getArea( 0 )->getTop();
+ awt::Point aPoint= getPosition();
+ return uno::makeAny( lcl_hmmToPoints( aPoint.Y ) );
+}
+
+uno::Reference< excel::XWorksheet >
+ScVbaRange::getWorksheet() throw (uno::RuntimeException)
+{
+ // #TODO #FIXME parent should always be set up ( currently thats not
+ // the case )
+ uno::Reference< excel::XWorksheet > xSheet( getParent(), uno::UNO_QUERY );
+ if ( !xSheet.is() )
+ {
+ uno::Reference< table::XCellRange > xRange = mxRange;
+
+ if ( mxRanges.is() ) // assign xRange to first range
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ xRange.set( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ }
+ ScDocShell* pDocShell = excel::GetDocShellFromRange(xRange);
+ RangeHelper rHelper(xRange);
+ // parent should be Thisworkbook
+ xSheet.set( new ScVbaWorksheet( uno::Reference< XHelperInterface >(), mxContext,rHelper.getSpreadSheet(),pDocShell->GetModel()) );
+ }
+ return xSheet;
+}
+
+// #TODO remove this ugly application processing
+// Process an application Range request e.g. 'Range("a1,b2,a4:b6")
+uno::Reference< excel::XRange >
+ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException)
+{
+ // Althought the documentation seems clear that Range without a
+ // qualifier then its a shortcut for ActiveSheet.Range
+ // however, similarly Application.Range is apparently also a
+ // shortcut for ActiveSheet.Range
+ // The is however a subtle behavioural difference I've come across
+ // wrt to named ranges.
+ // If a named range "test" exists { Sheet1!$A1 } and the active sheet
+ // is Sheet2 then the following will fail
+ // msgbox ActiveSheet.Range("test").Address ' failes
+ // msgbox WorkSheets("Sheet2").Range("test").Address
+ // but !!!
+ // msgbox Range("test").Address ' works
+ // msgbox Application.Range("test").Address ' works
+
+ // Single param Range
+ rtl::OUString sRangeName;
+ Cell1 >>= sRangeName;
+ if ( Cell1.hasValue() && !Cell2.hasValue() && sRangeName.getLength() )
+ {
+ const static rtl::OUString sNamedRanges( RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
+ uno::Reference< beans::XPropertySet > xPropSet( getCurrentExcelDoc(xContext), uno::UNO_QUERY_THROW );
+
+ uno::Reference< container::XNameAccess > xNamed( xPropSet->getPropertyValue( sNamedRanges ), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XCellRangeReferrer > xReferrer;
+ try
+ {
+ xReferrer.set ( xNamed->getByName( sRangeName ), uno::UNO_QUERY );
+ }
+ catch( uno::Exception& /*e*/ )
+ {
+ // do nothing
+ }
+ if ( xReferrer.is() )
+ {
+ uno::Reference< table::XCellRange > xRange = xReferrer->getReferredCells();
+ if ( xRange.is() )
+ {
+ uno::Reference< excel::XRange > xVbRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), xContext, xRange );
+ return xVbRange;
+ }
+ }
+ }
+
+ // Add these codes for supporting shortcut: Application.Range(Range1, Range2), Range1 or Range2 is not the range of current active sheet.
+ // If Range1 and Range2 are not in current active sheet, we should not use the active sheet, but use the sheet of Range1 and Range2.
+ // If Range1 and Range2 are not in the same sheet, we throw an exception.
+ uno::Reference< sheet::XSpreadsheet > xSpreadsheet;
+ uno::Reference< excel::XRange > xRange1( Cell1, uno::UNO_QUERY ), xRange2( Cell2, uno::UNO_QUERY );
+ if ( xRange1.is() )
+ {
+ RangeHelper thisRange( xRange1->getCellRange() );
+ xSpreadsheet = thisRange.getSpreadSheet();
+ }
+ else if ( xRange2.is() )
+ {
+ RangeHelper thisRange( xRange2->getCellRange() );
+ xSpreadsheet = thisRange.getSpreadSheet();
+ }
+ if ( !xSpreadsheet.is() )
+ {
+ uno::Reference< frame::XModel > xModel = getCurrentExcelDoc( xContext );
+ if ( xModel.is() )
+ {
+ uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSpreadsheet = xView->getActiveSheet();
+ }
+ }
+
+ uno::Reference< table::XCellRange > xSheetRange( xSpreadsheet, uno::UNO_QUERY_THROW );
+ ScVbaRange* pRange = new ScVbaRange( excel::getUnoSheetModuleObj( xSheetRange ), xContext, xSheetRange );
+
+ uno::Reference< excel::XRange > xVbSheetRange( pRange );
+ return pRange->Range( Cell1, Cell2, true );
+}
+
+// Helper functions for AutoFilter
+ScDBData* lcl_GetDBData_Impl( ScDocShell* pDocShell, sal_Int16 nSheet )
+{
+ rtl::OUString sName;
+ excel::GetAutoFiltRange( pDocShell, nSheet, sName );
+ OSL_TRACE("lcl_GetDBData_Impl got autofilter range %s for sheet %d",
+ rtl::OUStringToOString( sName, RTL_TEXTENCODING_UTF8 ).getStr() , nSheet );
+ ScDBData* pRet = NULL;
+ if (pDocShell)
+ {
+ ScDBCollection* pNames = pDocShell->GetDocument()->GetDBCollection();
+ if (pNames)
+ {
+ USHORT nPos = 0;
+ if (pNames->SearchName( sName , nPos ))
+ pRet = (*pNames)[nPos];
+ }
+ }
+ return pRet;
+}
+
+void lcl_SelectAll( ScDocShell* pDocShell, ScQueryParam& aParam )
+{
+ if ( pDocShell )
+ {
+ ScViewData* pViewData = pDocShell->GetViewData();
+ if ( pViewData )
+ {
+ OSL_TRACE("Pushing out SelectAll query");
+ pViewData->GetView()->Query( aParam, NULL, TRUE );
+ }
+ }
+}
+
+ScQueryParam lcl_GetQueryParam( ScDocShell* pDocShell, sal_Int16 nSheet )
+{
+ ScDBData* pDBData = lcl_GetDBData_Impl( pDocShell, nSheet );
+ ScQueryParam aParam;
+ if (pDBData)
+ {
+ pDBData->GetQueryParam( aParam );
+ }
+ return aParam;
+}
+
+void lcl_SetAllQueryForField( ScQueryParam& aParam, SCCOLROW nField )
+{
+ bool bFound = false;
+ SCSIZE i = 0;
+ for (; i<MAXQUERY && !bFound; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if ( rEntry.nField == nField)
+ {
+ OSL_TRACE("found at pos %d", i );
+ bFound = true;
+ }
+ }
+ if ( bFound )
+ {
+ OSL_TRACE("field %d to delete at pos %d", nField, ( i - 1 ) );
+ aParam.DeleteQuery(--i);
+ }
+}
+
+
+void lcl_SetAllQueryForField( ScDocShell* pDocShell, SCCOLROW nField, sal_Int16 nSheet )
+{
+ ScQueryParam aParam = lcl_GetQueryParam( pDocShell, nSheet );
+ lcl_SetAllQueryForField( aParam, nField );
+ lcl_SelectAll( pDocShell, aParam );
+}
+
+// Modifies sCriteria, and nOp depending on the value of sCriteria
+void lcl_setTableFieldsFromCriteria( rtl::OUString& sCriteria1, uno::Reference< beans::XPropertySet >& xDescProps, sheet::TableFilterField2& rFilterField )
+{
+ // #TODO make this more efficient and cycle through
+ // sCriteria1 character by character to pick up <,<>,=, * etc.
+ // right now I am more concerned with just getting it to work right
+
+ sCriteria1 = sCriteria1.trim();
+ // table of translation of criteria text to FilterOperators
+ // <>searchtext - NOT_EQUAL
+ // =searchtext - EQUAL
+ // *searchtext - startwith
+ // <>*searchtext - doesn't startwith
+ // *searchtext* - contains
+ // <>*searchtext* - doesn't contain
+ // [>|>=|<=|...]searchtext for GREATER_value, GREATER_EQUAL_value etc.
+ sal_Int32 nPos = 0;
+ bool bIsNumeric = false;
+ if ( ( nPos = sCriteria1.indexOf( EQUALS ) ) == 0 )
+ {
+ if ( sCriteria1.getLength() == EQUALS.getLength() )
+ rFilterField.Operator = sheet::FilterOperator2::EMPTY;
+ else
+ {
+ rFilterField.Operator = sheet::FilterOperator2::EQUAL;
+ sCriteria1 = sCriteria1.copy( EQUALS.getLength() );
+ sCriteria1 = VBAToRegexp( sCriteria1 );
+ // UseRegularExpressions
+ if ( xDescProps.is() )
+ xDescProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseRegularExpressions" ) ), uno::Any( sal_True ) );
+ }
+
+ }
+ else if ( ( nPos = sCriteria1.indexOf( NOTEQUALS ) ) == 0 )
+ {
+ if ( sCriteria1.getLength() == NOTEQUALS.getLength() )
+ rFilterField.Operator = sheet::FilterOperator2::NOT_EMPTY;
+ else
+ {
+ rFilterField.Operator = sheet::FilterOperator2::NOT_EQUAL;
+ sCriteria1 = sCriteria1.copy( NOTEQUALS.getLength() );
+ sCriteria1 = VBAToRegexp( sCriteria1 );
+ // UseRegularExpressions
+ if ( xDescProps.is() )
+ xDescProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseRegularExpressions" ) ), uno::Any( sal_True ) );
+ }
+ }
+ else if ( ( nPos = sCriteria1.indexOf( GREATERTHAN ) ) == 0 )
+ {
+ bIsNumeric = true;
+ if ( ( nPos = sCriteria1.indexOf( GREATERTHANEQUALS ) ) == 0 )
+ {
+ sCriteria1 = sCriteria1.copy( GREATERTHANEQUALS.getLength() );
+ rFilterField.Operator = sheet::FilterOperator2::GREATER_EQUAL;
+ }
+ else
+ {
+ sCriteria1 = sCriteria1.copy( GREATERTHAN.getLength() );
+ rFilterField.Operator = sheet::FilterOperator2::GREATER;
+ }
+
+ }
+ else if ( ( nPos = sCriteria1.indexOf( LESSTHAN ) ) == 0 )
+ {
+ bIsNumeric = true;
+ if ( ( nPos = sCriteria1.indexOf( LESSTHANEQUALS ) ) == 0 )
+ {
+ sCriteria1 = sCriteria1.copy( LESSTHANEQUALS.getLength() );
+ rFilterField.Operator = sheet::FilterOperator2::LESS_EQUAL;
+ }
+ else
+ {
+ sCriteria1 = sCriteria1.copy( LESSTHAN.getLength() );
+ rFilterField.Operator = sheet::FilterOperator2::LESS;
+ }
+
+ }
+ else
+ rFilterField.Operator = sheet::FilterOperator2::EQUAL;
+
+ if ( bIsNumeric )
+ {
+ rFilterField.IsNumeric= sal_True;
+ rFilterField.NumericValue = sCriteria1.toDouble();
+ }
+ rFilterField.StringValue = sCriteria1;
+}
+
+void SAL_CALL
+ScVbaRange::AutoFilter( const uno::Any& Field, const uno::Any& Criteria1, const uno::Any& Operator, const uno::Any& Criteria2, const uno::Any& VisibleDropDown ) throw (uno::RuntimeException)
+{
+ // Is there an existing autofilter
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ sal_Int16 nSheet = thisAddress.Sheet;
+ ScDocShell* pShell = getScDocShell();
+ sal_Bool bHasAuto = sal_False;
+ rtl::OUString sAutofiltRangeName;
+ uno::Reference< sheet::XDatabaseRange > xDataBaseRange = excel::GetAutoFiltRange( pShell, nSheet, sAutofiltRangeName );
+ if ( xDataBaseRange.is() )
+ bHasAuto = true;
+
+ uno::Reference< table::XCellRange > xFilterRange;
+ if ( !bHasAuto )
+ {
+ if ( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY, uno::Reference< uno::XInterface >() );
+
+ table::CellRangeAddress autoFiltAddress;
+ //CurrentRegion()
+ if ( isSingleCellRange() )
+ {
+ uno::Reference< excel::XRange > xCurrent( CurrentRegion() );
+ if ( xCurrent.is() )
+ {
+ ScVbaRange* pRange = getImplementation( xCurrent );
+ if ( pRange->isSingleCellRange() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can't create AutoFilter") ), uno::Reference< uno::XInterface >() );
+ if ( pRange )
+ {
+ RangeHelper currentRegion( pRange->mxRange );
+ autoFiltAddress = currentRegion.getCellRangeAddressable()->getRangeAddress();
+ }
+ }
+ }
+ else // multi-cell range
+ {
+ RangeHelper multiCellRange( mxRange );
+ autoFiltAddress = multiCellRange.getCellRangeAddressable()->getRangeAddress();
+ }
+
+ uno::Reference< sheet::XDatabaseRanges > xDBRanges = excel::GetDataBaseRanges( pShell );
+ if ( xDBRanges.is() )
+ {
+ rtl::OUString sGenName( RTL_CONSTASCII_USTRINGPARAM("VBA_Autofilter_") );
+ sGenName += rtl::OUString::valueOf( static_cast< sal_Int32 >( nSheet ) );
+ OSL_TRACE("Going to add new autofilter range.. name %s",
+ rtl::OUStringToOString( sGenName, RTL_TEXTENCODING_UTF8 ).getStr() , nSheet );
+ if ( !xDBRanges->hasByName( sGenName ) )
+ xDBRanges->addNewByName( sGenName, autoFiltAddress );
+ xDataBaseRange.set( xDBRanges->getByName( sGenName ), uno::UNO_QUERY_THROW );
+ }
+ if ( !xDataBaseRange.is() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Failed to find the autofilter placeholder range" ) ), uno::Reference< uno::XInterface >() );
+
+ uno::Reference< beans::XPropertySet > xDBRangeProps( xDataBaseRange, uno::UNO_QUERY_THROW );
+ // set autofilt
+ xDBRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ), uno::Any(sal_True) );
+ // set header
+ uno::Reference< beans::XPropertySet > xFiltProps( xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY_THROW );
+ sal_Bool bHasColHeader = sal_False;
+ ScDocument* pDoc = pShell ? pShell->GetDocument() : NULL;
+
+ bHasColHeader = pDoc->HasColHeader( static_cast< SCCOL >( autoFiltAddress.StartColumn ), static_cast< SCROW >( autoFiltAddress.StartRow ), static_cast< SCCOL >( autoFiltAddress.EndColumn ), static_cast< SCROW >( autoFiltAddress.EndRow ), static_cast< SCTAB >( autoFiltAddress.Sheet ) ) ? sal_True : sal_False;
+ xFiltProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ContainsHeader") ), uno::Any( bHasColHeader ) );
+ }
+
+
+ sal_Int32 nField = 0; // *IS* 1 based
+ rtl::OUString sCriteria1;
+ sal_Int32 nOperator = excel::XlAutoFilterOperator::xlAnd;
+
+ sal_Bool bVisible = sal_True;
+ bool bChangeDropDown = false;
+ VisibleDropDown >>= bVisible;
+
+ if ( bVisible == bHasAuto ) // dropdown is displayed/notdisplayed as
+ // required
+ bVisible = sal_False;
+ else
+ bChangeDropDown = true;
+ sheet::FilterConnection nConn = sheet::FilterConnection_AND;
+ double nCriteria1 = 0;
+
+ bool bHasCritValue = Criteria1.hasValue();
+ bool bCritHasNumericValue = sal_False; // not sure if a numeric criteria is possible
+ if ( bHasCritValue )
+ bCritHasNumericValue = ( Criteria1 >>= nCriteria1 );
+
+ if ( !Field.hasValue() && ( Criteria1.hasValue() || Operator.hasValue() || Criteria2.hasValue() ) )
+ throw uno::RuntimeException();
+ // Use the normal uno api, sometimes e.g. when you want to use ALL as the filter
+ // we can't use refresh as the uno interface doesn't have a concept of ALL
+ // in this case we just call the core calc functionality -
+ bool bAll = false;
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ bool bIsValidFieldValue = ( Field >>= nField );
+ if ( !bIsValidFieldValue && xConverter.is() )
+ {
+ try
+ {
+ uno::Any aConverted = xConverter->convertTo( Field, getCppuType( (sal_Int32*)0 ) );
+ bIsValidFieldValue = ( aConverted >>= nField );
+ }
+ catch( const uno::Exception& ex )
+ {
+ }
+ }
+ if ( bIsValidFieldValue )
+ {
+ uno::Reference< sheet::XSheetFilterDescriptor2 > xDesc(
+ xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY );
+ if ( xDesc.is() )
+ {
+ uno::Sequence< sheet::TableFilterField2 > sTabFilts;
+ uno::Reference< beans::XPropertySet > xDescProps( xDesc, uno::UNO_QUERY_THROW );
+ if ( Criteria1.hasValue() )
+ {
+ sTabFilts.realloc( 1 );
+ sTabFilts[0].Operator = sheet::FilterOperator2::EQUAL;// sensible default
+ if ( !bCritHasNumericValue )
+ {
+ Criteria1 >>= sCriteria1;
+ sTabFilts[0].IsNumeric = bCritHasNumericValue;
+ if ( bHasCritValue && sCriteria1.getLength() )
+ lcl_setTableFieldsFromCriteria( sCriteria1, xDescProps, sTabFilts[0] );
+ else
+ bAll = true;
+ }
+ else // numeric
+ {
+ sTabFilts[0].IsNumeric = sal_True;
+ sTabFilts[0].NumericValue = nCriteria1;
+ }
+ }
+ else // no value specified
+ bAll = true;
+ // not sure what the relationship between Criteria1 and Operator is,
+ // e.g. can you have a Operator without a Criteria ? in openoffice it
+ bool bIsValidOpValue = ( Operator.hasValue() && ( Operator >>= nOperator ) );
+ if ( Operator.hasValue() && !bIsValidOpValue && xConverter.is() )
+ {
+ try
+ {
+ uno::Any aConverted = xConverter->convertTo( Operator, getCppuType( (sal_Int32*)0 ) );
+ bIsValidOpValue = ( aConverted >>= nOperator );
+ }
+ catch( const uno::Exception& ex )
+ {
+ }
+ }
+ if ( bIsValidOpValue )
+ {
+ // if its a bottom/top Ten(Percent/Value) and there
+ // is no value specified for critera1 set it to 10
+ if ( !bCritHasNumericValue && !sCriteria1.getLength() && ( nOperator != excel::XlAutoFilterOperator::xlOr ) && ( nOperator != excel::XlAutoFilterOperator::xlAnd ) )
+ {
+ sTabFilts[0].IsNumeric = sal_True;
+ sTabFilts[0].NumericValue = 10;
+ bAll = false;
+ }
+ switch ( nOperator )
+ {
+ case excel::XlAutoFilterOperator::xlBottom10Items:
+ sTabFilts[0].Operator = sheet::FilterOperator2::BOTTOM_VALUES;
+ break;
+ case excel::XlAutoFilterOperator::xlBottom10Percent:
+ sTabFilts[0].Operator = sheet::FilterOperator2::BOTTOM_PERCENT;
+ break;
+ case excel::XlAutoFilterOperator::xlTop10Items:
+ sTabFilts[0].Operator = sheet::FilterOperator2::TOP_VALUES;
+ break;
+ case excel::XlAutoFilterOperator::xlTop10Percent:
+ sTabFilts[0].Operator = sheet::FilterOperator2::TOP_PERCENT;
+ break;
+ case excel::XlAutoFilterOperator::xlOr:
+ nConn = sheet::FilterConnection_OR;
+ break;
+ case excel::XlAutoFilterOperator::xlAnd:
+ nConn = sheet::FilterConnection_AND;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UnknownOption") ), uno::Reference< uno::XInterface >() );
+
+ }
+
+ }
+ if ( !bAll )
+ {
+ sTabFilts[0].Connection = sheet::FilterConnection_AND;
+ sTabFilts[0].Field = (nField - 1);
+
+ rtl::OUString sCriteria2;
+ if ( Criteria2.hasValue() ) // there is a Criteria2
+ {
+ sTabFilts.realloc(2);
+ sTabFilts[1].Field = sTabFilts[0].Field;
+ sTabFilts[1].Connection = nConn;
+
+ if ( Criteria2 >>= sCriteria2 )
+ {
+ if ( sCriteria2.getLength() > 0 )
+ {
+ uno::Reference< beans::XPropertySet > xProps;
+ lcl_setTableFieldsFromCriteria( sCriteria2, xProps, sTabFilts[1] );
+ sTabFilts[1].IsNumeric = sal_False;
+ }
+ }
+ else // numeric
+ {
+ Criteria2 >>= sTabFilts[1].NumericValue;
+ sTabFilts[1].IsNumeric = sal_True;
+ sTabFilts[1].Operator = sheet::FilterOperator2::EQUAL;
+ }
+ }
+ }
+
+ xDesc->setFilterFields2( sTabFilts );
+ if ( !bAll )
+ {
+ xDataBaseRange->refresh();
+ }
+ else
+ // was 0 based now seems to be 1
+ lcl_SetAllQueryForField( pShell, nField, nSheet );
+ }
+ }
+ else
+ {
+ // this is just to toggle autofilter on and off ( not to be confused with
+ // a VisibleDropDown option combined with a field, in that case just the
+ // button should be disabled ) - currently we don't support that
+ bChangeDropDown = true;
+ uno::Reference< beans::XPropertySet > xDBRangeProps( xDataBaseRange, uno::UNO_QUERY_THROW );
+ if ( bHasAuto )
+ {
+ // find the any field with the query and select all
+ ScQueryParam aParam = lcl_GetQueryParam( pShell, nSheet );
+ SCSIZE i = 0;
+ for (; i<MAXQUERY; i++)
+ {
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if ( rEntry.bDoQuery )
+ lcl_SetAllQueryForField( pShell, rEntry.nField, nSheet );
+ }
+ // remove exising filters
+ uno::Reference< sheet::XSheetFilterDescriptor2 > xSheetFilterDescriptor(
+ xDataBaseRange->getFilterDescriptor(), uno::UNO_QUERY );
+ if( xSheetFilterDescriptor.is() )
+ xSheetFilterDescriptor->setFilterFields2( uno::Sequence< sheet::TableFilterField2 >() );
+ }
+ xDBRangeProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AutoFilter") ), uno::Any(!bHasAuto) );
+
+ }
+}
+
+void SAL_CALL
+ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (uno::RuntimeException)
+{
+ sal_Bool bCopyOrigin = sal_True;
+ CopyOrigin >>= bCopyOrigin;
+ // It appears ( from the web ) that the undocumented CopyOrigin
+ // param should contain member of enum XlInsertFormatOrigin
+ // which can have values xlFormatFromLeftOrAbove or xlFormatFromRightOrBelow
+ // #TODO investigate resultant behaviour using these constants
+ // currently just processing Shift
+
+ sheet::CellInsertMode mode = sheet::CellInsertMode_NONE;
+ if ( Shift.hasValue() )
+ {
+ sal_Int32 nShift = 0;
+ Shift >>= nShift;
+ switch ( nShift )
+ {
+ case excel::XlInsertShiftDirection::xlShiftToRight:
+ mode = sheet::CellInsertMode_RIGHT;
+ break;
+ case excel::XlInsertShiftDirection::xlShiftDown:
+ mode = sheet::CellInsertMode_DOWN;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("Illegal paramater ") ), uno::Reference< uno::XInterface >() );
+ }
+ }
+ else
+ {
+ if ( getRow() >= getColumn() )
+ mode = sheet::CellInsertMode_DOWN;
+ else
+ mode = sheet::CellInsertMode_RIGHT;
+ }
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ uno::Reference< sheet::XCellRangeMovement > xCellRangeMove( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ xCellRangeMove->insertCells( thisAddress, mode );
+ if ( bCopyOrigin )
+ {
+ // After the insert ( this range ) actually has moved
+ ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) );
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( excel::GetDocShellFromRange( mxRange ) , aRange ) );
+ uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( mxParent, mxContext, xRange, mbIsRows, mbIsColumns ) );
+ xVbaRange->PasteSpecial( uno::Any(), uno::Any(), uno::Any(), uno::Any() );
+ }
+}
+
+void SAL_CALL
+ScVbaRange::Autofit() throw (uno::RuntimeException)
+{
+ sal_Int32 nLen = m_Areas->getCount();
+ if ( nLen > 1 )
+ {
+ for ( sal_Int32 index = 1; index != nLen; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32(index) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->Autofit();
+ }
+ return;
+ }
+ // if the range is a not a row or column range autofit will
+ // throw an error
+
+ if ( !( mbIsColumns || mbIsRows ) )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ ScDocShell* pDocShell = excel::GetDocShellFromRange( mxRange );
+ if ( pDocShell )
+ {
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+
+ ScDocFunc aFunc(*pDocShell);
+ SCCOLROW nColArr[2];
+ nColArr[0] = thisAddress.StartColumn;
+ nColArr[1] = thisAddress.EndColumn;
+ BOOL bDirection = TRUE;
+ if ( mbIsRows )
+ {
+ bDirection = FALSE;
+ nColArr[0] = thisAddress.StartRow;
+ nColArr[1] = thisAddress.EndRow;
+ }
+ aFunc.SetWidthOrHeight( bDirection, 1, nColArr, thisAddress.Sheet, SC_SIZE_OPTIMAL,
+ 0, TRUE, TRUE );
+
+ }
+}
+
+/***************************************************************************************
+ * interface for text:
+ * com.sun.star.text.XText, com.sun.star.table.XCell, com.sun.star.container.XEnumerationAccess
+ * com.sun.star.text.XTextRange,
+ * the main problem is to recognize the numeric and date, which assosiate with DecimalSeparator, ThousandsSeparator,
+ * TrailingMinusNumbers and FieldInfo.
+***************************************************************************************/
+void SAL_CALL
+ScVbaRange::TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier,
+ const css::uno::Any& ConsecutiveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma,
+ const css::uno::Any& Space, const css::uno::Any& Other, const css::uno::Any& OtherChar, const css::uno::Any& FieldInfo,
+ const css::uno::Any& DecimalSeparator, const css::uno::Any& ThousandsSeparator, const css::uno::Any& /*TrailingMinusNumbers*/ ) throw (css::uno::RuntimeException)
+{
+ uno::Reference< excel::XRange > xRange;
+ if( Destination.hasValue() )
+ {
+ if( !( Destination >>= xRange ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Destination parameter should be a range" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set range\n");
+ }
+ else
+ {
+ //set as current
+ xRange = this;
+ OSL_TRACE("set range as himself\n");
+ }
+
+ sal_Int16 xlTextParsingType = excel::XlTextParsingType::xlDelimited;
+ if ( DataType.hasValue() )
+ {
+ if( !( DataType >>= xlTextParsingType ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "DataType parameter should be a short" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set Datatype\n" );
+ }
+ sal_Bool bDilimited = ( xlTextParsingType == excel::XlTextParsingType::xlDelimited );
+
+ sal_Int16 xlTextQualifier = excel::XlTextQualifier::xlTextQualifierDoubleQuote;
+ if( TextQualifier.hasValue() )
+ {
+ if( !( TextQualifier >>= xlTextQualifier ))
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "TextQualifier parameter should be a short" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set TextQualifier\n");
+ }
+
+ sal_Bool bConsecutiveDelimiter = sal_False;
+ if( ConsecutiveDelimiter.hasValue() )
+ {
+ if( !( ConsecutiveDelimiter >>= bConsecutiveDelimiter ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "ConsecutiveDelimiter parameter should be a boolean" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set ConsecutiveDelimiter\n");
+ }
+
+ sal_Bool bTab = sal_False;
+ if( Tab.hasValue() && bDilimited )
+ {
+ if( !( Tab >>= bTab ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Tab parameter should be a boolean" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set Tab\n");
+ }
+
+ sal_Bool bSemicolon = sal_False;
+ if( Semicolon.hasValue() && bDilimited )
+ {
+ if( !( Semicolon >>= bSemicolon ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Semicolon parameter should be a boolean" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set Semicolon\n");
+ }
+ sal_Bool bComma = sal_False;
+ if( Comma.hasValue() && bDilimited )
+ {
+ if( !( Comma >>= bComma ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Comma parameter should be a boolean" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set Comma\n");
+ }
+ sal_Bool bSpace = sal_False;
+ if( Space.hasValue() && bDilimited )
+ {
+ if( !( Space >>= bSpace ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Space parameter should be a boolean" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set Space\n");
+ }
+ sal_Bool bOther = sal_False;
+ rtl::OUString sOtherChar;
+ if( Other.hasValue() && bDilimited )
+ {
+ if( Other >>= bOther )
+ {
+ if( OtherChar.hasValue() )
+ if( !( OtherChar >>= sOtherChar ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "OtherChar parameter should be a String" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set OtherChar\n" );
+ }
+ else if( bOther )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "Other parameter should be a True" ),
+ uno::Reference< uno::XInterface >() );
+ }
+ // FieldInfo, Optional Variant. An array containing parse information for the individual columns of data.
+ // The interpretation depends on the value of DataType. When the data is delimited, this argument is an array
+ // of two-element arrays, with each two-element array specifying the conversion options for a particular column.
+ // The first element is the column number (1-based), and the second element is one of the xlColumnDataType
+ // constants specifying how the column is parsed.
+ uno::Sequence< uno::Sequence< uno::Any > > sFieldInfo;
+ FieldInfo >>= sFieldInfo;
+
+ rtl::OUString sDecimalSeparator;
+ if( DecimalSeparator.hasValue() )
+ {
+ if( !( DecimalSeparator >>= sDecimalSeparator ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "DecimalSeparator parameter should be a String" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set DecimalSeparator\n" );
+ }
+ rtl::OUString sThousandsSeparator;
+ if( ThousandsSeparator.hasValue() )
+ {
+ if( !( ThousandsSeparator >>= sThousandsSeparator ) )
+ throw uno::RuntimeException( rtl::OUString::createFromAscii( "ThousandsSeparator parameter should be a String" ),
+ uno::Reference< uno::XInterface >() );
+ OSL_TRACE("set ThousandsSpeparator\n" );
+ }
+ //TODO* TrailingMinusNumbers Optional Variant. Numbers that begin with a minus character.
+
+ // Get the destination range's left-upper cell address.
+ ScVbaRange* pDestVbaRange = dynamic_cast< ScVbaRange* >( xRange.get() );
+ ScAddress aScDestAddress;
+ if ( pDestVbaRange )
+ {
+ ScUnoConversion::FillScAddress( aScDestAddress, pDestVbaRange->getLeftUpperCellAddress() );
+ }
+
+ // Parse the value of parameter FieldInfo.
+ USHORT nCount = 0, nRealCount = 0;
+ xub_StrLen* pColumns = NULL;
+ BYTE* pFormats = NULL;
+ if ( sFieldInfo.getLength() > 0 )
+ {
+ nCount = sFieldInfo.getLength();
+ pColumns = new xub_StrLen[nCount];
+ pFormats = new BYTE[nCount];
+ USHORT nFormat = 1;
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ {
+ if ( sFieldInfo[nIndex].getLength() >= 2 )
+ {
+ nFormat = 1;
+ try
+ {
+ uno::Any aConverted = xConverter->convertTo( sFieldInfo[nIndex][0], getCppuType((xub_StrLen*)0) );
+ aConverted >>= pColumns[nRealCount];
+ aConverted = xConverter->convertTo( sFieldInfo[nIndex][1], getCppuType((USHORT*)0) );
+ aConverted >>= nFormat;
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ pFormats[nRealCount++] = nFormat;
+ }
+ }
+ }
+
+ sal_Unicode cTextQualifier = '"';
+ cTextQualifier = xlTextQualifier == excel::XlTextQualifier::xlTextQualifierNone ? '\0' : cTextQualifier;
+ cTextQualifier = xlTextQualifier == excel::XlTextQualifier::xlTextQualifierSingleQuote ? '\'' : cTextQualifier;
+
+ // Get field delimiters.
+ String rFieldDelimiters;
+ if ( bTab ) rFieldDelimiters += '\t';
+ if ( bSemicolon ) rFieldDelimiters += ';';
+ if ( bComma ) rFieldDelimiters += ',';
+ if ( bSpace ) rFieldDelimiters += ' ';
+ if ( bOther ) rFieldDelimiters += *sOtherChar.getStr();
+
+ // Get the text in current range to SvMemoryStream.
+ ScRange aSrcScRange;
+ ScCellRangesBase* pSrcCellRangesBase = getCellRangesBase();
+ if ( pSrcCellRangesBase )
+ {
+ ScRangeList aRangeList = pSrcCellRangesBase->GetRangeList();
+ if ( aRangeList.First() )
+ {
+ aSrcScRange = *aRangeList.First();
+ }
+ }
+ ScImportExport aExport( getScDocument(), aSrcScRange );
+ aExport.SetDelimiter( static_cast< sal_Unicode >( 0 ) );
+ SvMemoryStream aStream;
+ aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
+ ScImportExport::SetNoEndianSwap( aStream );
+ aExport.ExportStream( aStream, String(), FORMAT_STRING );
+ aStream.Seek( 0 );
+
+ // Set ScAsciiOptions according to the input parameters.
+ ScAsciiOptions aOptions;
+ aOptions.SetFixedLen( !bDilimited );
+ aOptions.SetStartRow( 0 );
+ aOptions.SetColInfo( nRealCount, pColumns, pFormats );
+ if ( bDilimited )
+ {
+ aOptions.SetFieldSeps( rFieldDelimiters );
+ aOptions.SetMergeSeps( bConsecutiveDelimiter );
+ aOptions.SetTextSep( cTextQualifier );
+ }
+
+ // Split the String in to columns.
+ if ( pDestVbaRange && pDestVbaRange->getScDocument() )
+ {
+ ScImportExport aImport( pDestVbaRange->getScDocument(), aScDestAddress );
+ aImport.SetExtOptions( aOptions );
+ aImport.SetApi( false );
+ aImport.ImportStream( aStream, String(), FORMAT_STRING );
+ }
+ if ( pColumns )
+ {
+ DELETEZ( pColumns );
+ }
+ if ( pFormats )
+ {
+ DELETEZ( pFormats );
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaRange::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ /* The range object always returns a new Hyperlinks object containing a
+ fixed list of existing hyperlinks in the range.
+ See vbahyperlinks.hxx for more details. */
+
+ // get the global hyperlink object of the sheet (sheet should always be the parent of a Range object)
+ uno::Reference< excel::XWorksheet > xWorksheet( getParent(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XHyperlinks > xSheetHlinks( xWorksheet->Hyperlinks( uno::Any() ), uno::UNO_QUERY_THROW );
+ ScVbaHyperlinksRef xScSheetHlinks( dynamic_cast< ScVbaHyperlinks* >( xSheetHlinks.get() ) );
+ if( !xScSheetHlinks.is() )
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain hyperlinks implementation object" ) ), uno::Reference< uno::XInterface >() );
+
+ // create a new local hyperlinks object based on the sheet hyperlinks
+ ScVbaHyperlinksRef xHlinks( new ScVbaHyperlinks( getParent(), mxContext, xScSheetHlinks, getScRangeList() ) );
+ if( aIndex.hasValue() )
+ return xHlinks->Item( aIndex, uno::Any() );
+ return uno::Any( uno::Reference< excel::XHyperlinks >( xHlinks.get() ) );
+}
+
+css::uno::Reference< excel::XValidation > SAL_CALL
+ScVbaRange::getValidation() throw (css::uno::RuntimeException)
+{
+ if ( !m_xValidation.is() )
+ m_xValidation = new ScVbaValidation( this, mxContext, mxRange );
+ return m_xValidation;
+}
+
+namespace {
+
+sal_Unicode lclGetPrefixChar( const uno::Reference< table::XCell >& rxCell ) throw (uno::RuntimeException)
+{
+ /* TODO/FIXME: We need an apostroph-prefix property at the cell to
+ implement this correctly. For now, return an apostroph for every text
+ cell.
+
+ TODO/FIXME: When Application.TransitionNavigKeys is supported and true,
+ this function needs to inspect the cell formatting and return different
+ prefixes according to the horizontal cell alignment.
+ */
+ return (rxCell->getType() == table::CellContentType_TEXT) ? '\'' : 0;
+}
+
+sal_Unicode lclGetPrefixChar( const uno::Reference< table::XCellRange >& rxRange ) throw (uno::RuntimeException)
+{
+ /* This implementation is able to handle different prefixes (needed if
+ Application.TransitionNavigKeys is true). The function lclGetPrefixChar
+ for single cells called from here may return any prefix. If that
+ function returns an empty prefix (NUL character) or different non-empty
+ prefixes for two cells, this function returns 0.
+ */
+ sal_Unicode cCurrPrefix = 0;
+ table::CellRangeAddress aRangeAddr = lclGetRangeAddress( rxRange );
+ sal_Int32 nEndCol = aRangeAddr.EndColumn - aRangeAddr.StartColumn;
+ sal_Int32 nEndRow = aRangeAddr.EndRow - aRangeAddr.StartRow;
+ for( sal_Int32 nRow = 0; nRow <= nEndRow; ++nRow )
+ {
+ for( sal_Int32 nCol = 0; nCol <= nEndCol; ++nCol )
+ {
+ uno::Reference< table::XCell > xCell( rxRange->getCellByPosition( nCol, nRow ), uno::UNO_SET_THROW );
+ sal_Unicode cNewPrefix = lclGetPrefixChar( xCell );
+ if( (cNewPrefix == 0) || ((cCurrPrefix != 0) && (cNewPrefix != cCurrPrefix)) )
+ return 0;
+ cCurrPrefix = cNewPrefix;
+ }
+ }
+ // all cells contain the same prefix - return it
+ return cCurrPrefix;
+}
+
+sal_Unicode lclGetPrefixChar( const uno::Reference< sheet::XSheetCellRangeContainer >& rxRanges ) throw (uno::RuntimeException)
+{
+ sal_Unicode cCurrPrefix = 0;
+ uno::Reference< container::XEnumerationAccess > xRangesEA( rxRanges, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration > xRangesEnum( xRangesEA->createEnumeration(), uno::UNO_SET_THROW );
+ while( xRangesEnum->hasMoreElements() )
+ {
+ uno::Reference< table::XCellRange > xRange( xRangesEnum->nextElement(), uno::UNO_QUERY_THROW );
+ sal_Unicode cNewPrefix = lclGetPrefixChar( xRange );
+ if( (cNewPrefix == 0) || ((cCurrPrefix != 0) && (cNewPrefix != cCurrPrefix)) )
+ return 0;
+ cCurrPrefix = cNewPrefix;
+ }
+ // all ranges contain the same prefix - return it
+ return cCurrPrefix;
+}
+
+inline uno::Any lclGetPrefixVariant( sal_Unicode cPrefixChar )
+{
+ return uno::Any( (cPrefixChar == 0) ? ::rtl::OUString() : ::rtl::OUString( cPrefixChar ) );
+}
+
+} // namespace
+
+uno::Any SAL_CALL ScVbaRange::getPrefixCharacter() throw (uno::RuntimeException)
+{
+ /* (1) If Application.TransitionNavigKeys is false, this function returns
+ an apostroph character if the text cell begins with an apostroph
+ character (formula return values are not taken into account); otherwise
+ an empty string.
+
+ (2) If Application.TransitionNavigKeys is true, this function returns
+ an apostroph character, if the cell is left-aligned; a double-quote
+ character, if the cell is right-aligned; a circumflex character, if the
+ cell is centered; a backslash character, if the cell is set to filled;
+ or an empty string, if nothing of the above.
+
+ If a range or a list of ranges contains texts with leading apostroph
+ character as well as other cells, this function returns an empty
+ string.
+ */
+
+ if( mxRange.is() )
+ return lclGetPrefixVariant( lclGetPrefixChar( mxRange ) );
+ if( mxRanges.is() )
+ return lclGetPrefixVariant( lclGetPrefixChar( mxRanges ) );
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unexpected empty Range object" ) ), uno::Reference< uno::XInterface >() );
+}
+
+uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException)
+{
+ // #FIXME, If the specified range is in a PivotTable report
+
+ // In MSO VBA, the specified range must be a single summary column or row in an outline. otherwise throw exception
+ if( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not get Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() );
+
+ sal_Bool bShowDetail = sal_False;
+
+ RangeHelper helper( mxRange );
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = helper.getSheetCellCursor();
+ xSheetCellCursor->collapseToCurrentRegion();
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW);
+ table::CellRangeAddress aOutlineAddress = xCellRangeAddressable->getRangeAddress();
+
+ // check if the specified range is a single summary column or row.
+ table::CellRangeAddress thisAddress = helper.getCellRangeAddressable()->getRangeAddress();
+ if( (thisAddress.StartRow == thisAddress.EndRow && thisAddress.EndRow == aOutlineAddress.EndRow ) ||
+ (thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn ))
+ {
+ sal_Bool bColumn =thisAddress.StartRow == thisAddress.EndRow ? sal_False:sal_True;
+ ScDocument* pDoc = excel::GetDocumentFromRange( mxRange );
+ ScOutlineTable* pOutlineTable = pDoc->GetOutlineTable(static_cast<SCTAB>(thisAddress.Sheet), sal_True);
+ const ScOutlineArray* pOutlineArray = bColumn ? pOutlineTable->GetColArray(): pOutlineTable->GetRowArray();
+ if( pOutlineArray )
+ {
+ SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1);
+ ScOutlineEntry* pEntry = pOutlineArray->GetEntryByPos( 0, nPos );
+ if( pEntry )
+ {
+ bShowDetail = !pEntry->IsHidden();
+ return uno::makeAny( bShowDetail );
+ }
+ }
+ }
+ else
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not set Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() );
+ }
+ return aNULL();
+}
+
+void ScVbaRange::setShowDetail(const uno::Any& aShowDetail) throw ( css::uno::RuntimeException)
+{
+ // #FIXME, If the specified range is in a PivotTable report
+
+ // In MSO VBA, the specified range must be a single summary column or row in an outline. otherwise throw exception
+ if( m_Areas->getCount() > 1 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not set Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() );
+
+ bool bShowDetail = extractBoolFromAny( aShowDetail );
+
+ RangeHelper helper( mxRange );
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = helper.getSheetCellCursor();
+ xSheetCellCursor->collapseToCurrentRegion();
+ uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW);
+ table::CellRangeAddress aOutlineAddress = xCellRangeAddressable->getRangeAddress();
+
+ // check if the specified range is a single summary column or row.
+ table::CellRangeAddress thisAddress = helper.getCellRangeAddressable()->getRangeAddress();
+ if( (thisAddress.StartRow == thisAddress.EndRow && thisAddress.EndRow == aOutlineAddress.EndRow ) ||
+ (thisAddress.StartColumn == thisAddress.EndColumn && thisAddress.EndColumn == aOutlineAddress.EndColumn ))
+ {
+ // #FIXME, seems there is a different behavior between MSO and OOo.
+ // In OOo, the showDetail will show all the level entrys, while only show the first level entry in MSO
+ uno::Reference< sheet::XSheetOutline > xSheetOutline( helper.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ if( bShowDetail )
+ xSheetOutline->showDetail( aOutlineAddress );
+ else
+ xSheetOutline->hideDetail( aOutlineAddress );
+ }
+ else
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Can not set Range.ShowDetail attribute ")), uno::Reference< uno::XInterface >() );
+ }
+}
+
+//09-09-16 add by limingl
+::com::sun::star::uno::Reference< ::ooo::vba::excel::XQueryTable > SAL_CALL
+ScVbaRange::getQueryTable() throw (::com::sun::star::uno::RuntimeException)
+{
+ /*
+ if (m_pQueryTable == NULL)
+ {
+ m_pQueryTable = new ScVbaQueryTable(mxParent ,mxContext, getScDocument(), this); //add by limingl
+ }
+ //*/
+ if (!m_xQueryTable.is())
+ {
+ m_xQueryTable = new ScVbaQueryTable(mxParent ,mxContext, getScDocument(), this); //add by limingl
+ }
+
+ return m_xQueryTable;
+}
+//end add
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCellRange > xMergeShellCellRange(mxRange->getCellRangeByPosition(0,0,0,0), uno::UNO_QUERY_THROW);
+ uno::Reference< sheet::XSheetCellCursor > xMergeSheetCursor(xMergeShellCellRange->getSpreadsheet()->createCursorByRange( xMergeShellCellRange ), uno::UNO_QUERY_THROW);
+ if( xMergeSheetCursor.is() )
+ {
+ xMergeSheetCursor->collapseToMergedArea();
+ uno::Reference<sheet::XCellRangeAddressable> xMergeCellAddress(xMergeSheetCursor, uno::UNO_QUERY_THROW);
+ if( xMergeCellAddress.is() )
+ {
+ table::CellRangeAddress aCellAddress = xMergeCellAddress->getRangeAddress();
+ if( aCellAddress.StartColumn ==0 && aCellAddress.EndColumn==0 &&
+ aCellAddress.StartRow==0 && aCellAddress.EndRow==0)
+ {
+ return new ScVbaRange( mxParent,mxContext,mxRange );
+ }
+ else
+ {
+ ScRange refRange( static_cast< SCCOL >( aCellAddress.StartColumn ), static_cast< SCROW >( aCellAddress.StartRow ), static_cast< SCTAB >( aCellAddress.Sheet ),
+ static_cast< SCCOL >( aCellAddress.EndColumn ), static_cast< SCROW >( aCellAddress.EndRow ), static_cast< SCTAB >( aCellAddress.Sheet ) );
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell() , refRange ) );
+ return new ScVbaRange( mxParent, mxContext,xRange );
+ }
+ }
+ }
+ return new ScVbaRange( mxParent, mxContext, mxRange );
+}
+
+//2008-08-25 add by limingl
+//The recordset's member: Recordset.Fields.Item will get a Field obj.
+//Field.value is the column value.
+::sal_Int32 SAL_CALL
+ScVbaRange::CopyFromRecordset( const ::com::sun::star::uno::Any& Data, const ::com::sun::star::uno::Any& MaxRows, const ::com::sun::star::uno::Any& MaxColumns )
+throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException)
+{
+ uno::Sequence< uno::Any > aParams;
+ uno::Sequence< uno::Any > aFieldsParams(1);
+ uno::Sequence< sal_Int16 > aOutParamIndex;
+ uno::Sequence< uno::Any > aOutParam;
+ uno::Reference< uno::XInterface > xIntRes;
+ uno::Reference< uno::XInterface > xIntFields;
+ uno::Reference< uno::XInterface > xIntFld;
+ uno::Any aRet;
+ uno::Any aPar;
+ uno::Any aCrrCol;
+ uno::Any aCrrRow;
+ sal_Int16 nCrrCol = 0;
+ sal_Int32 nCrrRow = 0;
+ sal_Int32 nCol;
+ sal_Int32 nMaxRows = 0;
+ sal_Int32 nMaxColumns = 0;
+ sal_Bool bEof;
+// sal_Bool bColName = sal_True;
+ long lColCnt = 0;
+ if (MaxColumns.hasValue())
+ {
+ MaxColumns >>= nMaxColumns;
+ }
+
+ long lMaxCol = nMaxColumns;
+
+ if (MaxRows.hasValue())
+ {
+ MaxRows >>= nMaxRows;
+ }
+
+
+ Data >>= xIntRes;
+ uno::Reference< script::XInvocation > xInvRes(xIntRes, uno::UNO_QUERY_THROW);
+ rtl::OUString oMoveNext = rtl::OUString::createFromAscii("MoveNext") ;
+ rtl::OUString oEof = rtl::OUString::createFromAscii("EOF") ;
+ rtl::OUString oFields = rtl::OUString::createFromAscii("Fields") ;
+
+ if( !xInvRes->hasMethod(oMoveNext))
+ {
+ return -1;
+ }
+
+ //Get columns count
+ aRet = xInvRes->getValue(oFields);
+ aRet >>= xIntFields;
+ uno::Reference< script::XInvocation > xInvFields(xIntFields, uno::UNO_QUERY_THROW);
+ aRet = xInvFields->getValue( rtl::OUString::createFromAscii("Count")) ;
+ aRet >>= lColCnt;
+
+ //Set the assign column number
+ if (lMaxCol != 0)
+ {
+ if (lColCnt > lMaxCol)
+ {
+ lColCnt = lMaxCol;
+ }
+ }
+
+ aCrrRow <<= nCrrRow;
+ aCrrCol <<= nCrrCol;
+
+
+ //Get start position
+ uno::Reference< excel::XRange > xRngStartRow = Rows(uno::Any(sal_Int32(1)) );
+ uno::Reference< excel::XRange > xRngPos = xRngStartRow->Columns( uno::Any(sal_Int32(1)) );
+
+ while(1)
+ {//travel recordset
+ //get every column
+ for (long l = 0; l < lColCnt ; l++)
+ {
+ nCol = l;
+ aPar <<= nCol;
+ //get every field
+ aRet = xInvFields->invoke( rtl::OUString::createFromAscii("Item"), uno::Sequence< uno::Any >(&aPar,1) , aOutParamIndex,aOutParam);
+ aRet >>= xIntFld;
+ uno::Reference< script::XInvocation > xInvFld(xIntFld, uno::UNO_QUERY_THROW); //Get the Field obj
+
+ //set the field value
+ aRet = xInvFld->getValue( rtl::OUString::createFromAscii("Value") );
+ uno::Reference< excel::XRange > xRngToFill = xRngPos->Offset(aCrrRow,aCrrCol );
+
+ xRngToFill->setValue(aRet);
+ nCrrCol++;
+ aCrrCol <<= nCrrCol;
+ }
+
+ aRet = xInvRes->invoke(oMoveNext, aParams,aOutParamIndex,aOutParam );
+ aRet = xInvRes->getValue(oEof);
+ aRet >>= bEof;
+ if (bEof || ( nCrrRow >= nMaxRows && nMaxRows != 0) )
+ {//Arrive the end of recordset
+ break;
+ }
+
+ nCrrRow++;
+ aCrrRow <<= nCrrRow;
+ nCrrCol = 0;
+ aCrrCol <<= nCrrCol;
+ }
+
+ return 0;
+}
+//end add
+void SAL_CALL
+ScVbaRange::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName ) throw (uno::RuntimeException)
+{
+ ScDocShell* pShell = NULL;
+
+ sal_Int32 nItems = m_Areas->getCount();
+ uno::Sequence< table::CellRangeAddress > printAreas( nItems );
+ uno::Reference< sheet::XPrintAreas > xPrintAreas;
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+
+ RangeHelper thisRange( xRange->getCellRange() );
+ table::CellRangeAddress rangeAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ if ( index == 1 )
+ {
+ ScVbaRange* pRange = getImplementation( xRange );
+ // initialise the doc shell and the printareas
+ pShell = excel::GetDocShellFromRange( pRange->mxRange );
+ xPrintAreas.set( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ }
+ printAreas[ index - 1 ] = rangeAddress;
+ }
+ if ( pShell )
+ {
+ if ( xPrintAreas.is() )
+ {
+ xPrintAreas->setPrintAreas( printAreas );
+ uno::Reference< frame::XModel > xModel = pShell->GetModel();
+ PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True );
+ }
+ }
+}
+
+void SAL_CALL
+ScVbaRange::AutoFill( const uno::Reference< excel::XRange >& Destination, const uno::Any& Type ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XRange > xDest( Destination, uno::UNO_QUERY_THROW );
+ ScVbaRange* pRange = getImplementation( xDest );
+ RangeHelper destRangeHelper( pRange->mxRange );
+ table::CellRangeAddress destAddress = destRangeHelper.getCellRangeAddressable()->getRangeAddress();
+
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ ScRange sourceRange;
+ ScRange destRange;
+
+ ScUnoConversion::FillScRange( destRange, destAddress );
+ ScUnoConversion::FillScRange( sourceRange, thisAddress );
+
+
+ // source is valid
+// if ( !sourceRange.In( destRange ) )
+// throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "source not in destination" ) ), uno::Reference< uno::XInterface >() );
+
+ FillDir eDir = FILL_TO_BOTTOM;
+ double fStep = 1.0;
+
+ ScRange aRange( destRange );
+ ScRange aSourceRange( destRange );
+
+ // default to include the number of Rows in the source range;
+ SCCOLROW nSourceCount = ( sourceRange.aEnd.Row() - sourceRange.aStart.Row() ) + 1;
+ SCCOLROW nCount = 0;
+
+ if ( sourceRange != destRange )
+ {
+ // Find direction of fill, vertical or horizontal
+ if ( sourceRange.aStart == destRange.aStart )
+ {
+ if ( sourceRange.aEnd.Row() == destRange.aEnd.Row() )
+ {
+ nSourceCount = ( sourceRange.aEnd.Col() - sourceRange.aStart.Col() + 1 );
+ aSourceRange.aEnd.SetCol( static_cast<SCCOL>( aSourceRange.aStart.Col() + nSourceCount - 1 ) );
+ eDir = FILL_TO_RIGHT;
+ nCount = aRange.aEnd.Col() - aSourceRange.aEnd.Col();
+ }
+ else if ( sourceRange.aEnd.Col() == destRange.aEnd.Col() )
+ {
+ aSourceRange.aEnd.SetRow( static_cast<SCROW>( aSourceRange.aStart.Row() + nSourceCount ) - 1 );
+ nCount = aRange.aEnd.Row() - aSourceRange.aEnd.Row();
+ eDir = FILL_TO_BOTTOM;
+ }
+ }
+
+ else if ( aSourceRange.aEnd == destRange.aEnd )
+ {
+ if ( sourceRange.aStart.Col() == destRange.aStart.Col() )
+ {
+ aSourceRange.aStart.SetRow( static_cast<SCROW>( aSourceRange.aEnd.Row() - nSourceCount + 1 ) );
+ nCount = aSourceRange.aStart.Row() - aRange.aStart.Row();
+ eDir = FILL_TO_TOP;
+ fStep = -fStep;
+ }
+ else if ( sourceRange.aStart.Row() == destRange.aStart.Row() )
+ {
+ nSourceCount = ( sourceRange.aEnd.Col() - sourceRange.aStart.Col() ) + 1;
+ aSourceRange.aStart.SetCol( static_cast<SCCOL>( aSourceRange.aEnd.Col() - nSourceCount + 1 ) );
+ nCount = aSourceRange.aStart.Col() - aRange.aStart.Col();
+ eDir = FILL_TO_LEFT;
+ fStep = -fStep;
+ }
+ }
+ }
+ ScDocShell* pDocSh= excel::GetDocShellFromRange( mxRange );
+
+ FillCmd eCmd = FILL_AUTO;
+ FillDateCmd eDateCmd = FILL_DAY;
+
+#ifdef VBA_OOBUILD_HACK
+ double fEndValue = MAXDOUBLE;
+#endif
+
+ if ( Type.hasValue() )
+ {
+ sal_Int16 nFillType = excel::XlAutoFillType::xlFillDefault;
+ Type >>= nFillType;
+ switch ( nFillType )
+ {
+ case excel::XlAutoFillType::xlFillCopy:
+ eCmd = FILL_SIMPLE;
+ fStep = 0.0;
+ break;
+ case excel::XlAutoFillType::xlFillDays:
+ eCmd = FILL_DATE;
+ break;
+ case excel::XlAutoFillType::xlFillMonths:
+ eCmd = FILL_DATE;
+ eDateCmd = FILL_MONTH;
+ break;
+ case excel::XlAutoFillType::xlFillWeekdays:
+ eCmd = FILL_DATE;
+ eDateCmd = FILL_WEEKDAY;
+ break;
+ case excel::XlAutoFillType::xlFillYears:
+ eCmd = FILL_DATE;
+ eDateCmd = FILL_YEAR;
+ break;
+ case excel::XlAutoFillType::xlGrowthTrend:
+ eCmd = FILL_GROWTH;
+ break;
+ case excel::XlAutoFillType::xlFillFormats:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "xlFillFormat not supported for AutoFill" ) ), uno::Reference< uno::XInterface >() );
+ case excel::XlAutoFillType::xlFillValues:
+ case excel::XlAutoFillType::xlFillSeries:
+ case excel::XlAutoFillType::xlLinearTrend:
+ eCmd = FILL_LINEAR;
+ break;
+ case excel::XlAutoFillType::xlFillDefault:
+ default:
+ eCmd = FILL_AUTO;
+ break;
+ }
+ }
+ ScDocFunc aFunc(*pDocSh);
+#ifdef VBA_OOBUILD_HACK
+ aFunc.FillAuto( aSourceRange, NULL, eDir, eCmd, eDateCmd, nCount, fStep, fEndValue, TRUE, TRUE );
+#endif
+}
+sal_Bool SAL_CALL
+ScVbaRange::GoalSeek( const uno::Any& Goal, const uno::Reference< excel::XRange >& ChangingCell ) throw (uno::RuntimeException)
+{
+ ScDocShell* pDocShell = getScDocShell();
+ sal_Bool bRes = sal_True;
+ ScVbaRange* pRange = static_cast< ScVbaRange* >( ChangingCell.get() );
+ if ( pDocShell && pRange )
+ {
+ uno::Reference< sheet::XGoalSeek > xGoalSeek( pDocShell->GetModel(), uno::UNO_QUERY_THROW );
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ RangeHelper changingCellRange( pRange->mxRange );
+ table::CellRangeAddress changingCellAddr = changingCellRange.getCellRangeAddressable()->getRangeAddress();
+ rtl::OUString sGoal = getAnyAsString( Goal );
+ table::CellAddress thisCell( thisAddress.Sheet, thisAddress.StartColumn, thisAddress.StartRow );
+ table::CellAddress changingCell( changingCellAddr.Sheet, changingCellAddr.StartColumn, changingCellAddr.StartRow );
+ sheet::GoalResult res = xGoalSeek->seekGoal( thisCell, changingCell, sGoal );
+ ChangingCell->setValue( uno::makeAny( res.Result ) );
+
+ // openoffice behaves differently, result is 0 if the divergence is too great
+ // but... if it detects 0 is the value it requires then it will use that
+ // e.g. divergence & result both = 0.0 does NOT mean there is an error
+ if ( ( res.Divergence != 0.0 ) && ( res.Result == 0.0 ) )
+ bRes = sal_False;
+ }
+ else
+ bRes = sal_False;
+ return bRes;
+}
+
+void
+ScVbaRange::Calculate( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ getWorksheet()->Calculate();
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::Item( const uno::Any& row, const uno::Any& column ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( mbIsRows || mbIsColumns )
+ {
+ if ( column.hasValue() )
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ uno::Reference< excel::XRange > xRange;
+ if ( mbIsColumns )
+ xRange = Columns( row );
+ else
+ xRange = Rows( row );
+ return xRange;
+ }
+ return Cells( row, column );
+}
+
+void
+ScVbaRange::AutoOutline( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ // #TODO #FIXME needs to check for summary row/col ( whatever they are )
+ // not valid for multi Area Addresses
+ if ( m_Areas->getCount() > 1 )
+ DebugHelper::exception(SbERR_METHOD_FAILED, STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY);
+ // So needs to either span an entire Row or a just be a single cell
+ // ( that contains a summary RowColumn )
+ // also the Single cell cause doesn't seem to be handled specially in
+ // this code ( ported from the helperapi RangeImpl.java,
+ // RangeRowsImpl.java, RangesImpl.java, RangeSingleCellImpl.java
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+
+ uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ xSheetOutline->autoOutline( thisAddress );
+}
+
+void SAL_CALL
+ScVbaRange:: ClearOutline( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->ClearOutline();
+ }
+ return;
+ }
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ xSheetOutline->clearOutline();
+}
+
+void
+ScVbaRange::groupUnGroup( bool bUnGroup ) throw ( script::BasicErrorException, uno::RuntimeException )
+{
+ if ( m_Areas->getCount() > 1 )
+ DebugHelper::exception(SbERR_METHOD_FAILED, STR_ERRORMESSAGE_APPLIESTOSINGLERANGEONLY);
+ table::TableOrientation nOrient = table::TableOrientation_COLUMNS;
+ if ( mbIsRows )
+ nOrient = table::TableOrientation_ROWS;
+ RangeHelper thisRange( mxRange );
+ table::CellRangeAddress thisAddress = thisRange.getCellRangeAddressable()->getRangeAddress();
+ uno::Reference< sheet::XSheetOutline > xSheetOutline( thisRange.getSpreadSheet(), uno::UNO_QUERY_THROW );
+ if ( bUnGroup )
+ xSheetOutline->ungroup( thisAddress, nOrient );
+ else
+ xSheetOutline->group( thisAddress, nOrient );
+}
+
+void SAL_CALL
+ScVbaRange::Group( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ groupUnGroup();
+}
+void SAL_CALL
+ScVbaRange::Ungroup( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ groupUnGroup(true);
+}
+
+void lcl_mergeCellsOfRange( const uno::Reference< table::XCellRange >& xCellRange, sal_Bool _bMerge = sal_True ) throw ( uno::RuntimeException )
+{
+ uno::Reference< util::XMergeable > xMergeable( xCellRange, uno::UNO_QUERY_THROW );
+ xMergeable->merge(_bMerge);
+}
+void SAL_CALL
+ScVbaRange::Merge( const uno::Any& Across ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->Merge(Across);
+ }
+ return;
+ }
+ uno::Reference< table::XCellRange > oCellRange;
+ sal_Bool bAcross = sal_False;
+ Across >>= bAcross;
+ if ( !bAcross )
+ lcl_mergeCellsOfRange( mxRange );
+ else
+ {
+ uno::Reference< excel::XRange > oRangeRowsImpl = Rows( uno::Any() );
+ // #TODO #FIXME this seems incredibly lame, this can't be right
+ for (sal_Int32 i=1; i <= oRangeRowsImpl->getCount();i++)
+ {
+ oRangeRowsImpl->Cells( uno::makeAny( i ), uno::Any() )->Merge( uno::makeAny( sal_False ) );
+ }
+ }
+}
+
+void SAL_CALL
+ScVbaRange::UnMerge( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ sal_Int32 nItems = m_Areas->getCount();
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->UnMerge();
+ }
+ return;
+ }
+ lcl_mergeCellsOfRange( mxRange, sal_False);
+}
+
+uno::Any SAL_CALL
+ScVbaRange::getStyle() throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32( 1 ) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->getStyle();
+ }
+ uno::Reference< beans::XPropertySet > xProps( mxRange, uno::UNO_QUERY_THROW );
+ rtl::OUString sStyleName;
+ xProps->getPropertyValue(CELLSTYLE) >>= sStyleName;
+ ScDocShell* pShell = getScDocShell();
+ uno::Reference< frame::XModel > xModel( pShell->GetModel() );
+ uno::Reference< excel::XStyle > xStyle = new ScVbaStyle( this, mxContext, sStyleName, xModel );
+ return uno::makeAny( xStyle );
+}
+void SAL_CALL
+ScVbaRange::setStyle( const uno::Any& _style ) throw (uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32( 1 ) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange->setStyle( _style );
+ return;
+ }
+ uno::Reference< beans::XPropertySet > xProps( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XStyle > xStyle;
+ _style >>= xStyle;
+ xProps->setPropertyValue(CELLSTYLE, uno::makeAny(xStyle->getName()));
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::PreviousNext( bool bIsPrevious )
+{
+ ScMarkData markedRange;
+ ScRange refRange;
+ RangeHelper thisRange( mxRange );
+
+ ScUnoConversion::FillScRange( refRange, thisRange.getCellRangeAddressable()->getRangeAddress());
+ markedRange. SetMarkArea( refRange );
+ short nMove = bIsPrevious ? -1 : 1;
+
+ SCCOL nNewX = refRange.aStart.Col();
+ SCROW nNewY = refRange.aStart.Row();
+ SCTAB nTab = refRange.aStart.Tab();
+
+ ScDocument* pDoc = getScDocument();
+ pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, TRUE,TRUE, markedRange );
+ refRange.aStart.SetCol( nNewX );
+ refRange.aStart.SetRow( nNewY );
+ refRange.aStart.SetTab( nTab );
+ refRange.aEnd.SetCol( nNewX );
+ refRange.aEnd.SetRow( nNewY );
+ refRange.aEnd.SetTab( nTab );
+
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell() , refRange ) );
+
+ return new ScVbaRange( mxParent, mxContext, xRange );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::Next() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32( 1 ) ), uno::Any() ) , uno::UNO_QUERY_THROW );
+ return xRange->Next();
+ }
+ return PreviousNext( false );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::Previous() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ if ( m_Areas->getCount() > 1 )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny( sal_Int32( 1 ) ), uno::Any() ), uno::UNO_QUERY_THROW );
+ return xRange->Previous();
+ }
+ return PreviousNext( true );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaRange::SpecialCells( const uno::Any& _oType, const uno::Any& _oValue) throw ( script::BasicErrorException )
+{
+ bool bIsSingleCell = isSingleCellRange();
+ bool bIsMultiArea = ( m_Areas->getCount() > 1 );
+ ScVbaRange* pRangeToUse = this;
+ uno::Reference< excel::XRange > xUsedRange( getWorksheet()->getUsedRange() );
+ sal_Int32 nType = 0;
+ if ( !( _oType >>= nType ) )
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ switch(nType)
+ {
+ case excel::XlCellType::xlCellTypeSameFormatConditions:
+ case excel::XlCellType::xlCellTypeAllValidation:
+ case excel::XlCellType::xlCellTypeSameValidation:
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ break;
+ case excel::XlCellType::xlCellTypeBlanks:
+ case excel::XlCellType::xlCellTypeComments:
+ case excel::XlCellType::xlCellTypeConstants:
+ case excel::XlCellType::xlCellTypeFormulas:
+ case excel::XlCellType::xlCellTypeVisible:
+ case excel::XlCellType::xlCellTypeLastCell:
+ {
+ if ( bIsMultiArea )
+ {
+ // need to process each area, gather the results and
+ // create a new range from those
+ std::vector< table::CellRangeAddress > rangeResults;
+ sal_Int32 nItems = ( m_Areas->getCount() + 1 );
+ for ( sal_Int32 index=1; index <= nItems; ++index )
+ {
+ uno::Reference< excel::XRange > xRange( m_Areas->Item( uno::makeAny(index), uno::Any() ), uno::UNO_QUERY_THROW );
+ xRange = xRange->SpecialCells( _oType, _oValue);
+ ScVbaRange* pRange = getImplementation( xRange );
+ if ( xRange.is() && pRange )
+ {
+ sal_Int32 nElems = ( pRange->m_Areas->getCount() + 1 );
+ for ( sal_Int32 nArea = 1; nArea < nElems; ++nArea )
+ {
+ uno::Reference< excel::XRange > xTmpRange( m_Areas->Item( uno::makeAny( nArea ), uno::Any() ), uno::UNO_QUERY_THROW );
+ RangeHelper rHelper( xTmpRange->getCellRange() );
+ rangeResults.push_back( rHelper.getCellRangeAddressable()->getRangeAddress() );
+ }
+ }
+ }
+ ScRangeList aCellRanges;
+ std::vector< table::CellRangeAddress >::iterator it = rangeResults.begin();
+ std::vector< table::CellRangeAddress >::iterator it_end = rangeResults.end();
+ for ( ; it != it_end; ++ it )
+ {
+ ScRange refRange;
+ ScUnoConversion::FillScRange( refRange, *it );
+ aCellRanges.Append( refRange );
+ }
+ // Single range
+ if ( aCellRanges.First() == aCellRanges.Last() )
+ {
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), *aCellRanges.First() ) );
+ return new ScVbaRange( mxParent, mxContext, xRange );
+ }
+ uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( getScDocShell(), aCellRanges ) );
+
+ return new ScVbaRange( mxParent, mxContext, xRanges );
+ }
+ else if ( bIsSingleCell )
+ {
+ pRangeToUse = static_cast< ScVbaRange* >( xUsedRange.get() );
+ }
+
+ break;
+ }
+ default:
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ break;
+ }
+ if ( !pRangeToUse )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ return pRangeToUse->SpecialCellsImpl( nType, _oValue );
+}
+
+sal_Int32 lcl_getFormulaResultFlags(const uno::Any& aType) throw ( script::BasicErrorException )
+{
+ sal_Int32 nType = excel::XlSpecialCellsValue::xlNumbers;
+ aType >>= nType;
+ sal_Int32 nRes = sheet::FormulaResult::VALUE;
+
+ switch(nType)
+ {
+ case excel::XlSpecialCellsValue::xlErrors:
+ nRes= sheet::FormulaResult::ERROR;
+ break;
+ case excel::XlSpecialCellsValue::xlLogical:
+ //TODO bc93774: ask NN if this is really an appropriate substitute
+ nRes = sheet::FormulaResult::VALUE;
+ break;
+ case excel::XlSpecialCellsValue::xlNumbers:
+ nRes = sheet::FormulaResult::VALUE;
+ break;
+ case excel::XlSpecialCellsValue::xlTextValues:
+ nRes = sheet::FormulaResult::STRING;
+ break;
+ default:
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+ return nRes;
+}
+
+uno::Reference< excel::XRange >
+ScVbaRange::SpecialCellsImpl( sal_Int32 nType, const uno::Any& _oValue) throw ( script::BasicErrorException )
+{
+ uno::Reference< excel::XRange > xRange;
+ try
+ {
+ uno::Reference< sheet::XCellRangesQuery > xQuery( mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XRange > oLocRangeImpl;
+ uno::Reference< sheet::XSheetCellRanges > xLocSheetCellRanges;
+ switch(nType)
+ {
+ case excel::XlCellType::xlCellTypeAllFormatConditions:
+ case excel::XlCellType::xlCellTypeSameFormatConditions:
+ case excel::XlCellType::xlCellTypeAllValidation:
+ case excel::XlCellType::xlCellTypeSameValidation:
+ // Shouldn't get here ( should be filtered out by
+ // ScVbaRange::SpecialCells()
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ break;
+ case excel::XlCellType::xlCellTypeBlanks:
+ xLocSheetCellRanges = xQuery->queryEmptyCells();
+ break;
+ case excel::XlCellType::xlCellTypeComments:
+ xLocSheetCellRanges = xQuery->queryContentCells(sheet::CellFlags::ANNOTATION);
+ break;
+ case excel::XlCellType::xlCellTypeConstants:
+ xLocSheetCellRanges = xQuery->queryContentCells(23);
+ break;
+ case excel::XlCellType::xlCellTypeFormulas:
+ {
+ sal_Int32 nFormulaResult = lcl_getFormulaResultFlags(_oValue);
+ xLocSheetCellRanges = xQuery->queryFormulaCells(nFormulaResult);
+ break;
+ }
+ case excel::XlCellType::xlCellTypeLastCell:
+ xRange = Cells( uno::makeAny( getCount() ), uno::Any() );
+ case excel::XlCellType::xlCellTypeVisible:
+ xLocSheetCellRanges = xQuery->queryVisibleCells();
+ break;
+ default:
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ break;
+ }
+ if (xLocSheetCellRanges.is())
+ {
+ xRange = lcl_makeXRangeFromSheetCellRanges( getParent(), mxContext, xLocSheetCellRanges, getScDocShell() );
+ }
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, STR_ERRORMESSAGE_NOCELLSWEREFOUND);
+ }
+ return xRange;
+}
+
+void SAL_CALL
+ScVbaRange::RemoveSubtotal( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< sheet::XSubTotalCalculatable > xSub( mxRange, uno::UNO_QUERY_THROW );
+ xSub->removeSubTotals();
+}
+
+void SAL_CALL
+ScVbaRange::Subtotal( ::sal_Int32 _nGroupBy, ::sal_Int32 _nFunction, const uno::Sequence< ::sal_Int32 >& _nTotalList, const uno::Any& aReplace, const uno::Any& PageBreaks, const uno::Any& /*SummaryBelowData*/ ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ sal_Bool bDoReplace = sal_False;
+ aReplace >>= bDoReplace;
+ sal_Bool bAddPageBreaks = sal_False;
+ PageBreaks >>= bAddPageBreaks;
+
+ uno::Reference< sheet::XSubTotalCalculatable> xSub(mxRange, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSubTotalDescriptor > xSubDesc = xSub->createSubTotalDescriptor(sal_True);
+ uno::Reference< beans::XPropertySet > xSubDescPropertySet( xSubDesc, uno::UNO_QUERY_THROW );
+ xSubDescPropertySet->setPropertyValue(INSERTPAGEBREAKS, uno::makeAny( bAddPageBreaks));
+ sal_Int32 nLen = _nTotalList.getLength();
+ uno::Sequence< sheet::SubTotalColumn > aColumns( nLen );
+ for (int i = 0; i < nLen; i++)
+ {
+ aColumns[i].Column = _nTotalList[i] - 1;
+ switch (_nFunction)
+ {
+ case excel::XlConsolidationFunction::xlAverage:
+ aColumns[i].Function = sheet::GeneralFunction_AVERAGE;
+ break;
+ case excel::XlConsolidationFunction::xlCount:
+ aColumns[i].Function = sheet::GeneralFunction_COUNT;
+ break;
+ case excel::XlConsolidationFunction::xlCountNums:
+ aColumns[i].Function = sheet::GeneralFunction_COUNTNUMS;
+ break;
+ case excel::XlConsolidationFunction::xlMax:
+ aColumns[i].Function = sheet::GeneralFunction_MAX;
+ break;
+ case excel::XlConsolidationFunction::xlMin:
+ aColumns[i].Function = sheet::GeneralFunction_MIN;
+ break;
+ case excel::XlConsolidationFunction::xlProduct:
+ aColumns[i].Function = sheet::GeneralFunction_PRODUCT;
+ break;
+ case excel::XlConsolidationFunction::xlStDev:
+ aColumns[i].Function = sheet::GeneralFunction_STDEV;
+ break;
+ case excel::XlConsolidationFunction::xlStDevP:
+ aColumns[i].Function = sheet::GeneralFunction_STDEVP;
+ break;
+ case excel::XlConsolidationFunction::xlSum:
+ aColumns[i].Function = sheet::GeneralFunction_SUM;
+ break;
+ case excel::XlConsolidationFunction::xlUnknown:
+ aColumns[i].Function = sheet::GeneralFunction_NONE;
+ break;
+ case excel::XlConsolidationFunction::xlVar:
+ aColumns[i].Function = sheet::GeneralFunction_VAR;
+ break;
+ case excel::XlConsolidationFunction::xlVarP:
+ aColumns[i].Function = sheet::GeneralFunction_VARP;
+ break;
+ default:
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString()) ;
+ return;
+ }
+ }
+ xSubDesc->addNew(aColumns, _nGroupBy - 1);
+ xSub->applySubTotals(xSubDesc, bDoReplace);
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+uno::Any SAL_CALL ScVbaRange::AdvancedFilter( sal_Int32 Action, const uno::Any& CriteriaRange,
+ const uno::Any& CopyToRange, const uno::Any& Unique ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Any aRet;
+ aRet <<= sal_True;
+
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter( mxContext );
+ ScDocument* pDoc = getScDocument();
+ if ( !pDoc )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from range" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ // Action
+ if ( Action != excel::XlFilterAction::xlFilterInPlace && Action != excel::XlFilterAction::xlFilterCopy )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Invalid input parameter" ) ), uno::Reference< uno::XInterface >() );
+ }
+ if ( m_Areas->getCount() > 1 )
+ {
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Invalid range" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ sal_Bool bCopyOut = ( Action != excel::XlFilterAction::xlFilterInPlace );
+ uno::Reference< sheet::XSheetFilterDescriptor > xFilterDesc;
+ uno::Reference< sheet::XSheetFilterable > xSheetFilter( mxRange, uno::UNO_QUERY_THROW );
+
+ // CriteriaRange
+ String aBuiltInCriteria; // Excel Built-In Filter Criteria.
+ ScRangeData* pData = NULL;
+ table::CellRangeAddress refParentAddr;
+ uno::Any aCriteriaRange = CriteriaRange;
+ formula::FormulaGrammar::AddressConvention aConv = formula::FormulaGrammar::CONV_XL_A1;
+ if ( aCriteriaRange.hasValue() && aCriteriaRange.getValueTypeClass() == uno::TypeClass_STRING )
+ {
+ rtl::OUString rRangeString;
+ aCriteriaRange >>= rRangeString;
+ aConv = excel::IsR1C1ReferFormat( pDoc, rRangeString ) ? formula::FormulaGrammar::CONV_XL_R1C1 : aConv;
+ }
+ else
+ {
+ // Get Excel BuiltIn Filter Criteria.
+ ScRangeName* pRangeNames = pDoc->GetRangeName();
+ const USHORT nCount = pRangeNames ? pRangeNames->GetCount() : 0;
+ for ( USHORT index = 0; index < nCount; index++ )
+ {
+ pData = ( ScRangeData* )( pRangeNames->At( index ) );
+ if ( pData && pData->HasType( RT_CRITERIA ) )
+ {
+ pData->GetSymbol( aBuiltInCriteria, formula::FormulaGrammar::GRAM_NATIVE_XL_A1 );
+ break;
+ }
+ }
+ aCriteriaRange = aBuiltInCriteria.Len() > 0 ? uno::makeAny( rtl::OUString( aBuiltInCriteria ) ) : aCriteriaRange;
+ }
+ if ( aCriteriaRange.hasValue() )
+ {
+ table::CellRangeAddress criteriaRangeAddress = getCellRangeAddressForVBARange( aCriteriaRange, getScDocShell(), aConv );
+ ScRange refRange;
+ ScUnoConversion::FillScRange( refRange, criteriaRangeAddress );
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), refRange ) );
+ uno::Reference< sheet::XSheetFilterableEx > xCriteria( xRange, uno::UNO_QUERY );
+ if ( xCriteria.is() )
+ {
+ xFilterDesc = xCriteria->createFilterDescriptorByObject( xSheetFilter );
+ }
+ }
+ else if ( mxRange.is() )
+ {
+ uno::Reference< sheet::XSheetFilterableEx > xCriteria( mxRange, uno::UNO_QUERY );
+ if ( xCriteria.is() )
+ {
+ xFilterDesc = xCriteria->createFilterDescriptorByObject( xSheetFilter );
+ }
+ }
+
+ uno::Reference< beans::XPropertySet > xPropertySet( xFilterDesc, uno::UNO_QUERY );
+ if ( xPropertySet.is() )
+ {
+ xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_COPYOUT ) ), uno::makeAny( bCopyOut ) );
+ }
+
+ // CopyToRange
+ if ( bCopyOut && CopyToRange.hasValue() && xPropertySet.is() )
+ {
+ formula::FormulaGrammar::AddressConvention aTmpConv = formula::FormulaGrammar::CONV_XL_A1;
+ if ( CopyToRange.getValueTypeClass() == uno::TypeClass_STRING )
+ {
+ rtl::OUString rRangeString;
+ CopyToRange >>= rRangeString;
+ aTmpConv = excel::IsR1C1ReferFormat( pDoc, rRangeString ) ? formula::FormulaGrammar::CONV_XL_R1C1 : aConv;
+ }
+ ScRange refRange;
+ ScUnoConversion::FillScRange( refRange, getCellRangeAddressForVBARange( CopyToRange, getScDocShell(), aTmpConv ) );
+ uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), refRange ) );
+ uno::Reference< sheet::XCellAddressable > xCellAddr( xRange->getCellByPosition( 0, 0 ), uno::UNO_QUERY_THROW );
+ xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_OUTPOS ) ), uno::makeAny( xCellAddr->getCellAddress() ) );
+ }
+
+ // Unique
+ if ( xPropertySet.is() )
+ {
+ sal_Bool bUnique = sal_False;
+ uno::Any aUnique;
+ try
+ {
+ aUnique <<= bUnique;
+ aUnique = ( xConverter.is() && Unique.hasValue() ) ? xConverter->convertTo( Unique, getCppuType( ( sal_Bool* ) 0 ) ) : aUnique;
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ xPropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SKIPDUP ) ), aUnique );
+ }
+
+ // Do filter.
+ if ( xFilterDesc.is() )
+ {
+ xSheetFilter->filter( xFilterDesc );
+ }
+
+ return aRet;
+}
+
+//Add by minz@cn.ibm.com. Range.PivotTable.
+//Returns a PivotTable object that represents the PivotTable report containing the upper-left corner of the specified range.
+uno::Reference< excel::XPivotTable >
+ScVbaRange::PivotTable() throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XPivotTable > xDestPVTable;
+
+ uno::Reference< sheet::XSpreadsheet > xSheet;
+ if ( mxRange.is() )
+ {
+ RangeHelper thisRange( mxRange );
+ xSheet = thisRange.getSpreadSheet();
+ }
+ else if ( mxRanges.is() )
+ {
+ uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW );
+ uno::Reference< table::XCellRange > xRange( xIndex->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ RangeHelper thisRange( xRange );
+ xSheet = thisRange.getSpreadSheet();
+ }
+
+// RangeHelper thisRange( mxRange );
+// uno::Reference< sheet::XSpreadsheet > xSheet = thisRange.getSpreadSheet();
+ uno::Reference< sheet::XDataPilotTablesSupplier > xTables(xSheet, uno::UNO_QUERY_THROW ) ;
+ uno::Reference< container::XIndexAccess > xIndexAccess( xTables->getDataPilotTables(), uno::UNO_QUERY_THROW );
+ if ( xIndexAccess.is() )
+ {
+ //get the upper-left cell address
+ table::CellAddress aAddress = getLeftUpperCellAddress();
+
+ sal_Int32 nCount = xIndexAccess->getCount();
+ for (sal_Int32 i=0; i < nCount; i++)
+ {
+ uno::Reference< sheet::XDataPilotTable > xDPTable(xIndexAccess->getByIndex(i), uno::UNO_QUERY);
+ uno::Reference< sheet::XDataPilotTable2 > xDPTable2(xDPTable, uno::UNO_QUERY);
+
+ //check if the cell is in the pivot table
+ sheet::DataPilotTablePositionData posData = xDPTable2->getPositionData(aAddress);
+ table::CellRangeAddress aCellRangeAddress = xDPTable->getOutputRange();
+ ScRange aScRange( aCellRangeAddress.StartColumn, aCellRangeAddress.StartRow, aCellRangeAddress.Sheet,
+ aCellRangeAddress.EndColumn, aCellRangeAddress.EndRow, aCellRangeAddress.Sheet );
+ ScAddress aPos( aAddress.Column, aAddress.Row, aAddress.Sheet );
+ if( !(posData.PositionType == sheet::DataPilotTablePositionType::NOT_IN_TABLE) || aScRange.In( aPos ) )
+ {
+ xDestPVTable = new ScVbaPivotTable( mxContext, xDPTable );
+ break;
+ }
+ }
+ }
+ return xDestPVTable;
+}
+
+
+rtl::OUString&
+ScVbaRange::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaRange") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaRange::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Range" ) );
+ }
+ return aServiceNames;
+}
+
+sal_Bool SAL_CALL
+ScVbaRange::hasError() throw (uno::RuntimeException)
+{
+ double dResult = sal_False;
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< script::XInvocation > xInvoc( xApplication->WorksheetFunction(), uno::UNO_QUERY_THROW );
+
+ static rtl::OUString FunctionName( RTL_CONSTASCII_USTRINGPARAM("IsError" ) );
+ uno::Sequence< uno::Any > Params(1);
+ uno::Reference< excel::XRange > aRange( this );
+ Params[0] = uno::makeAny( aRange );
+ uno::Sequence< sal_Int16 > OutParamIndex;
+ uno::Sequence< uno::Any > OutParam;
+ xInvoc->invoke( FunctionName, Params, OutParamIndex, OutParam ) >>= dResult;
+ if ( dResult > 0.0 )
+ return sal_True;
+ return sal_False;
+}
+
+namespace range
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaRange, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "SvVbaRange",
+ "ooo.vba.excel.Range" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx
new file mode 100644
index 000000000000..059d85502f3e
--- /dev/null
+++ b/sc/source/ui/vba/vbarange.hxx
@@ -0,0 +1,312 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_RANGE_HXX
+#define SC_VBA_RANGE_HXX
+
+#include <cppuhelper/implbase4.hxx>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <ooo/vba/excel/XFont.hpp>
+#include <ooo/vba/excel/XComment.hpp>
+#include <ooo/vba/XCollection.hpp>
+#include <ooo/vba/excel/XPivotTable.hpp>
+#include <ooo/vba/excel/XlPasteType.hdl>
+#include <ooo/vba/excel/XlPasteSpecialOperation.hdl>
+
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/script/XDefaultMethod.hpp>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include <com/sun/star/sheet/FillDateMode.hpp>
+#include <com/sun/star/sheet/FillMode.hpp>
+#include <com/sun/star/sheet/FillDirection.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XSheetCellRangeContainer.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include "vbaquerytable.hxx" //09-09-18 add by limingl
+
+#include "vbaformat.hxx"
+#include <formula/grammar.hxx>
+
+class ScTableSheetsObj;
+class ScCellRangesBase;
+class ScCellRangeObj;
+class ScCellRangesObj;
+class ScDocShell;
+class ScDocument;
+class ScRangeList;
+
+typedef ScVbaFormat< ov::excel::XRange > ScVbaRange_BASE;
+
+class ArrayVisitor
+{
+public:
+ virtual void visitNode( sal_Int32 x, sal_Int32 y, const css::uno::Reference< css::table::XCell >& xCell ) = 0;
+ virtual ~ArrayVisitor(){}
+};
+
+class ValueSetter : public ArrayVisitor
+{
+public:
+ virtual bool processValue( const css::uno::Any& aValue, const css::uno::Reference< css::table::XCell >& xCell ) = 0;
+
+
+};
+
+class ValueGetter : public ArrayVisitor
+{
+
+public:
+ virtual void processValue( sal_Int32 x, sal_Int32 y, const css::uno::Any& aValue ) = 0;
+ virtual const css::uno::Any& getValue() const = 0;
+};
+
+
+
+class ScVbaRange : public ScVbaRange_BASE
+{
+ css::uno::Reference< ov::XCollection > m_Areas;
+ css::uno::Reference< ov::XCollection > m_Borders;
+ css::uno::Reference< css::table::XCellRange > mxRange;
+ css::uno::Reference< css::sheet::XSheetCellRangeContainer > mxRanges;
+ sal_Bool mbIsRows;
+ sal_Bool mbIsColumns;
+ css::uno::Reference< ov::excel::XValidation > m_xValidation;
+ css::uno::Reference<excel::XQueryTable> m_xQueryTable; //09-09-16 add by limingl
+ double getCalcColWidth( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
+ double getCalcRowHeight( const css::table::CellRangeAddress& ) throw (css::uno::RuntimeException);
+ void visitArray( ArrayVisitor& vistor );
+
+ css::uno::Reference< ov::excel::XRange > getEntireColumnOrRow( bool bColumn = true ) throw( css::uno::RuntimeException );
+
+ void fillSeries( css::sheet::FillDirection nFillDirection, css::sheet::FillMode nFillMode, css::sheet::FillDateMode nFillDateMode, double fStep, double fEndValue ) throw( css::uno::RuntimeException );
+
+ void ClearContents( sal_Int32 nFlags ) throw (css::uno::RuntimeException);
+ virtual void setValue( const css::uno::Any& aValue, ValueSetter& setter) throw ( css::uno::RuntimeException);
+ virtual css::uno::Any getValue( ValueGetter& rValueGetter ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any getFormulaValue( formula::FormulaGrammar::Grammar ) throw (css::uno::RuntimeException);
+ virtual void setFormulaValue( const css::uno::Any& aValue, formula::FormulaGrammar::Grammar ) throw ( css::uno::RuntimeException);
+ css::uno::Reference< ov::excel::XRange > getArea( sal_Int32 nIndex ) throw( css::uno::RuntimeException );
+ ScCellRangeObj* getCellRangeObj( ) throw ( css::uno::RuntimeException );
+ ScCellRangesObj* getCellRangesObj() throw ( css::uno::RuntimeException );
+ css::uno::Reference< ov::XCollection >& getBorders();
+ void groupUnGroup( bool bUnGroup = false ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ css::uno::Reference< ov::excel::XRange > PreviousNext( bool bIsPrevious );
+ css::uno::Reference< ov::excel::XRange > SpecialCellsImpl( sal_Int32 nType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
+ css::awt::Point getPosition() throw ( css::uno::RuntimeException );
+protected:
+ virtual ScCellRangesBase* getCellRangesBase() throw ( css::uno::RuntimeException );
+ virtual SfxItemSet* getCurrentDataSet( ) throw ( css::uno::RuntimeException );
+public:
+ ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException );
+ ScVbaRange( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges, sal_Bool bIsRows = false, sal_Bool bIsColumns = false ) throw ( css::lang::IllegalArgumentException );
+ ScVbaRange( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
+
+ ScDocument* getScDocument() throw (css::uno::RuntimeException);
+ ScDocShell* getScDocShell() throw (css::uno::RuntimeException);
+
+ /** Returns the ScVbaRange implementation object for the passed VBA Range object. */
+ static ScVbaRange* getImplementation( const css::uno::Reference< ov::excel::XRange >& rxRange );
+
+ css::uno::Reference< css::frame::XModel > getUnoModel() throw (css::uno::RuntimeException);
+ static css::uno::Reference< css::frame::XModel > getUnoModel( const css::uno::Reference< ov::excel::XRange >& rxRange ) throw (css::uno::RuntimeException);
+
+ const ScRangeList& getScRangeList() throw (css::uno::RuntimeException);
+ static const ScRangeList& getScRangeList( const css::uno::Reference< ov::excel::XRange >& rxRange ) throw (css::uno::RuntimeException);
+
+ virtual ~ScVbaRange();
+ virtual css::uno::Reference< ov::XHelperInterface > thisHelperIface() { return this; }
+ bool isSingleCellRange();
+
+ static css::uno::Reference< ov::excel::XRange > getRangeObjectForName(
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const rtl::OUString& sRangeName, ScDocShell* pDocSh,
+ formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException );
+ css::table::CellAddress getLeftUpperCellAddress();
+
+ // Attributes
+ virtual css::uno::Any SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getValue() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const css::uno::Any& aValue ) throw ( css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormula() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFormula( const css::uno::Any& rFormula ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormulaArray() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFormulaArray(const css::uno::Any& rFormula) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getFormulaR1C1() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFormulaR1C1( const css::uno::Any &rFormula ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getRow() throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getColumn() throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+ using ScVbaRange_BASE::setNumberFormat;
+ virtual void SAL_CALL setNumberFormat( const css::uno::Any& rNumberFormat ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getNumberFormat() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setMergeCells( const css::uno::Any& bMerge ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getMergeCells() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setWrapText( const css::uno::Any& bIsWrapped ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWrapText() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getEntireRow() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getEntireColumn() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XComment > SAL_CALL getComment() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHidden() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHidden( const css::uno::Any& _hidden ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getColumnWidth() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setColumnWidth( const css::uno::Any& _columnwidth ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getRowHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setRowHeight( const css::uno::Any& _rowheight ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWidth() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getTop() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getLeft() throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getWorksheet() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getPageBreak() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPageBreak( const css::uno::Any& _pagebreak ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XValidation > SAL_CALL getValidation() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getPrefixCharacter() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getShowDetail() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setShowDetail(const css::uno::Any& aShowDetail) throw (css::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::ooo::vba::excel::XQueryTable > SAL_CALL getQueryTable() throw (::com::sun::star::uno::RuntimeException); //09-09-16 add by limingl
+ // Methods
+ sal_Bool IsRows() { return mbIsRows; }
+ sal_Bool IsColumns() { return mbIsColumns; }
+ virtual css::uno::Reference< ov::excel::XComment > SAL_CALL AddComment( const css::uno::Any& Text ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Clear() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearComments() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearContents() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ClearFormats() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL HasFormula() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillLeft() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillRight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillUp() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL FillDown() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Offset( const css::uno::Any &nRowOffset, const css::uno::Any &nColOffset )
+ throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL CurrentRegion() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL CurrentArray() throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL Characters( const css::uno::Any& nIndex, const css::uno::Any& nCount )
+ throw (css::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL Address( const css::uno::Any& RowAbsolute, const css::uno::Any& ColumnAbsolute, const css::uno::Any& ReferenceStyle, const css::uno::Any& External, const css::uno::Any& RelativeTo ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any &nRow, const css::uno::Any &nCol )
+ throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Select() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Rows( const css::uno::Any& nIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns( const css::uno::Any &nIndex ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Copy( const css::uno::Any& Destination ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Cut( const css::uno::Any& Destination ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Resize( const css::uno::Any& RowSize, const css::uno::Any& ColumnSize )
+ throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XFont > SAL_CALL Font() throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) throw ( css::script::BasicErrorException, css::uno::RuntimeException) ;
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > Range( const css::uno::Any &Cell1, const css::uno::Any &Cell2, bool bForceUseInpuRangeTab ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getCellRange( ) throw (css::uno::RuntimeException);
+ static css::uno::Any getCellRange( const css::uno::Reference< ov::excel::XRange >& rxRange ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PasteSpecial( const css::uno::Any& Paste, const css::uno::Any& Operation, const css::uno::Any& SkipBlanks, const css::uno::Any& Transpose ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL Replace( const ::rtl::OUString& What, const ::rtl::OUString& Replacement, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat, const css::uno::Any& ReplaceFormat ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Find( const css::uno::Any& What, const css::uno::Any& After, const css::uno::Any& LookIn, const css::uno::Any& LookAt, const css::uno::Any& SearchOrder, const css::uno::Any& SearchDirection, const css::uno::Any& MatchCase, const css::uno::Any& MatchByte, const css::uno::Any& SearchFormat ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Sort( const css::uno::Any& Key1, const css::uno::Any& Order1, const css::uno::Any& Key2, const css::uno::Any& Type, const css::uno::Any& Order2, const css::uno::Any& Key3, const css::uno::Any& Order3, const css::uno::Any& Header, const css::uno::Any& OrderCustom, const css::uno::Any& MatchCase, const css::uno::Any& Orientation, const css::uno::Any& SortMethod, const css::uno::Any& DataOption1, const css::uno::Any& DataOption2, const css::uno::Any& DataOption3 ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL End( ::sal_Int32 Direction ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XCharacters > SAL_CALL characters( const css::uno::Any& Start, const css::uno::Any& Length ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete( const css::uno::Any& Shift ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Areas( const css::uno::Any& ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Borders( const css::uno::Any& ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL BorderAround( const css::uno::Any& LineStyle,
+ const css::uno::Any& Weight, const css::uno::Any& ColorIndex, const css::uno::Any& Color ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL TextToColumns( const css::uno::Any& Destination, const css::uno::Any& DataType, const css::uno::Any& TextQualifier,
+ const css::uno::Any& ConsecutiveDelimiter, const css::uno::Any& Tab, const css::uno::Any& Semicolon, const css::uno::Any& Comma,
+ const css::uno::Any& Space, const css::uno::Any& Other, const css::uno::Any& OtherChar, const css::uno::Any& FieldInfo,
+ const css::uno::Any& DecimalSeparator, const css::uno::Any& ThousandsSeparator, const css::uno::Any& TrailingMinusNumbers ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL AutoFilter( const css::uno::Any& Field, const css::uno::Any& Criteria1, const css::uno::Any& Operator, const css::uno::Any& Criteria2, const css::uno::Any& VisibleDropDown ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Insert( const css::uno::Any& Shift, const css::uno::Any& CopyOrigin ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Autofit() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL AutoFill( const css::uno::Reference< ov::excel::XRange >& Destination, const css::uno::Any& Type ) throw (css::uno::RuntimeException) ;
+ void SAL_CALL Calculate( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL AutoOutline( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Item( const ::css::uno::Any& row, const css::uno::Any& column ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL ClearOutline( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Ungroup( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Group( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Merge( const css::uno::Any& Across ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL UnMerge( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getStyle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setStyle( const css::uno::Any& _style ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Next() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Previous() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL RemoveSubtotal( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL MergeArea() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Subtotal( ::sal_Int32 GroupBy, ::sal_Int32 Function, const css::uno::Sequence< ::sal_Int32 >& TotalList, const css::uno::Any& Replace, const css::uno::Any& PageBreaks, const css::uno::Any& SummaryBelowData ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL AdvancedFilter( ::sal_Int32 Action, const css::uno::Any& CriteriaRange, const css::uno::Any& CopyToRange, const css::uno::Any& Unique ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+
+ virtual css::uno::Reference< ov::excel::XPivotTable > SAL_CALL PivotTable( ) throw (css::uno::RuntimeException);
+
+ virtual ::sal_Int32 SAL_CALL CopyFromRecordset( const ::com::sun::star::uno::Any& Data, const ::com::sun::star::uno::Any& MaxRows, const ::com::sun::star::uno::Any& MaxColumns ) throw (::com::sun::star::script::BasicErrorException, ::com::sun::star::uno::RuntimeException); //2008-08-25 add by limingl
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException)
+ {
+ return ov::excel::XRange::static_type(0);
+
+ }
+ virtual sal_Bool SAL_CALL hasElements() throw (css::uno::RuntimeException);
+ // XDefaultMethod
+ ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (css::uno::RuntimeException);
+ // XDefaultProperty
+ ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (css::uno::RuntimeException) { return ::rtl::OUString::createFromAscii("Value"); }
+
+
+// #TODO completely rewrite ScVbaRange, its become a hackfest
+// it needs to be closer to ScCellRangeBase in that the underlying
+// object model should probably be a ScRangelst.
+// * would be nice to be able to construct a range from an addres only
+// * or a list of address ( multi-area )
+// * object should be a lightweight as possible
+// * we shouldn't need hacks like this below
+ static css::uno::Reference< ov::excel::XRange > ApplicationRange( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Any &Cell1, const css::uno::Any &Cell2 ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL GoalSeek( const css::uno::Any& Goal, const css::uno::Reference< ov::excel::XRange >& ChangingCell ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL SpecialCells( const css::uno::Any& _oType, const css::uno::Any& _oValue) throw ( css::script::BasicErrorException );
+ // XErrorQuery
+ virtual ::sal_Bool SAL_CALL hasError( ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif /* SC_VBA_RANGE_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaseriescollection.cxx b/sc/source/ui/vba/vbaseriescollection.cxx
new file mode 100644
index 000000000000..794f91137092
--- /dev/null
+++ b/sc/source/ui/vba/vbaseriescollection.cxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaseriescollection.hxx"
+#include <ooo/vba/excel/XSeries.hpp>
+
+#include "vbaglobals.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+ScVbaSeriesCollection::ScVbaSeriesCollection( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : SeriesCollection_BASE( xParent, xContext, uno::Reference< container::XIndexAccess>() )
+{
+}
+
+// XEnumerationAccess
+
+uno::Reference< container::XEnumeration >
+ScVbaSeriesCollection::createEnumeration() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumeration > xEnum;
+ return xEnum;
+}
+
+// XElementAccess
+
+uno::Type
+ScVbaSeriesCollection::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XSeries::static_type(0);
+}
+
+uno::Any
+ScVbaSeriesCollection::createCollectionObject( const css::uno::Any& rSource )
+{
+ return rSource;
+}
+
+rtl::OUString&
+ScVbaSeriesCollection::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaSeriesCollection") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaSeriesCollection::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.SeriesCollection") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaseriescollection.hxx b/sc/source/ui/vba/vbaseriescollection.hxx
new file mode 100644
index 000000000000..ddffda7ac375
--- /dev/null
+++ b/sc/source/ui/vba/vbaseriescollection.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_SERIESCOLLECTION_HXX
+#define SC_VBA_SERIESCOLLECTION_HXX
+
+#include <ooo/vba/excel/XSeriesCollection.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include "excelvbahelper.hxx"
+
+
+typedef CollTestImplHelper< ov::excel::XSeriesCollection > SeriesCollection_BASE;
+
+class ScVbaSeriesCollection : public SeriesCollection_BASE
+{
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+public:
+ ScVbaSeriesCollection( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // SeriesCollection_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbasheetobject.cxx b/sc/source/ui/vba/vbasheetobject.cxx
new file mode 100644
index 000000000000..dc6c0e26a9ad
--- /dev/null
+++ b/sc/source/ui/vba/vbasheetobject.cxx
@@ -0,0 +1,520 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbasheetobject.hxx"
+#include <com/sun/star/awt/TextAlign.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/style/VerticalAlignment.hpp>
+#include <ooo/vba/excel/Constants.hpp>
+#include <ooo/vba/excel/XlOrientation.hpp>
+#include <ooo/vba/excel/XlPlacement.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <filter/msfilter/msvbahelper.hxx>
+#include <oox/helper/helper.hxx>
+#include "vbafont.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+ScVbaButtonCharacters::ScVbaButtonCharacters(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< beans::XPropertySet >& rxPropSet,
+ const ScVbaPalette& rPalette,
+ const uno::Any& rStart,
+ const uno::Any& rLength ) throw (uno::RuntimeException) :
+ ScVbaButtonCharacters_BASE( rxParent, rxContext ),
+ maPalette( rPalette ),
+ mxPropSet( rxPropSet, uno::UNO_SET_THROW )
+{
+ // extract optional start parameter (missing or invalid -> from beginning)
+ if( !(rStart >>= mnStart) || (mnStart < 1) )
+ mnStart = 1;
+ --mnStart; // VBA is 1-based, rtl string is 0-based
+
+ // extract optional length parameter (missing or invalid -> to end)
+ if( !(rLength >>= mnLength) || (mnLength < 1) )
+ mnLength = SAL_MAX_INT32;
+}
+
+ScVbaButtonCharacters::~ScVbaButtonCharacters()
+{
+}
+
+// XCharacters attributes
+
+OUString SAL_CALL ScVbaButtonCharacters::getCaption() throw (uno::RuntimeException)
+{
+ // ignore invalid mnStart and/or mnLength members
+ OUString aString = getFullString();
+ sal_Int32 nStart = ::std::min( mnStart, aString.getLength() );
+ sal_Int32 nLength = ::std::min( mnLength, aString.getLength() - nStart );
+ return aString.copy( nStart, nLength );
+}
+
+void SAL_CALL ScVbaButtonCharacters::setCaption( const OUString& rCaption ) throw (uno::RuntimeException)
+{
+ /* Replace the covered text with the passed text, ignore invalid mnStart
+ and/or mnLength members. This operation does not affect the mnLength
+ parameter. If the inserted text is longer than mnLength, the additional
+ characters are not covered by this object. If the inserted text is
+ shorter than mnLength, other uncovered characters from the original
+ string will be covered now, thus may be changed with subsequent
+ operations. */
+ OUString aString = getFullString();
+ sal_Int32 nStart = ::std::min( mnStart, aString.getLength() );
+ sal_Int32 nLength = ::std::min( mnLength, aString.getLength() - nStart );
+ setFullString( aString.replaceAt( nStart, nLength, rCaption ) );
+}
+
+sal_Int32 SAL_CALL ScVbaButtonCharacters::getCount() throw (uno::RuntimeException)
+{
+ // always return the total length of the caption
+ return getFullString().getLength();
+}
+
+OUString SAL_CALL ScVbaButtonCharacters::getText() throw (uno::RuntimeException)
+{
+ // Text attribute same as Caption attribute?
+ return getCaption();
+}
+
+void SAL_CALL ScVbaButtonCharacters::setText( const OUString& rText ) throw (uno::RuntimeException)
+{
+ // Text attribute same as Caption attribute?
+ setCaption( rText );
+}
+
+uno::Reference< excel::XFont > SAL_CALL ScVbaButtonCharacters::getFont() throw (uno::RuntimeException)
+{
+ return new ScVbaFont( this, mxContext, maPalette, mxPropSet, 0, true );
+}
+
+void SAL_CALL ScVbaButtonCharacters::setFont( const uno::Reference< excel::XFont >& /*rxFont*/ ) throw (uno::RuntimeException)
+{
+ // TODO
+}
+
+// XCharacters methods
+
+void SAL_CALL ScVbaButtonCharacters::Insert( const OUString& rString ) throw (uno::RuntimeException)
+{
+ /* The Insert() operation is in fact "replace covered characters", at
+ least for buttons... It seems there is no easy way to really insert a
+ substring. This operation does not affect the mnLength parameter. */
+ setCaption( rString );
+}
+
+void SAL_CALL ScVbaButtonCharacters::Delete() throw (uno::RuntimeException)
+{
+ /* The Delete() operation is nothing else than "replace with empty string".
+ This does not affect the mnLength parameter, multiple calls of Delete()
+ will remove characters as long as there are some more covered by this
+ object. */
+ setCaption( OUString() );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaButtonCharacters, "ooo.vba.excel.Characters" )
+
+// private
+
+OUString ScVbaButtonCharacters::getFullString() const throw (uno::RuntimeException)
+{
+ return mxPropSet->getPropertyValue( CREATE_OUSTRING( "Label" ) ).get< OUString >();
+}
+
+void ScVbaButtonCharacters::setFullString( const OUString& rString ) throw (uno::RuntimeException)
+{
+ mxPropSet->setPropertyValue( CREATE_OUSTRING( "Label" ), uno::Any( rString ) );
+}
+
+// ============================================================================
+
+ScVbaSheetObjectBase::ScVbaSheetObjectBase(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException) :
+ ScVbaSheetObject_BASE( rxParent, rxContext ),
+ maPalette( rxModel ),
+ mxModel( rxModel, uno::UNO_SET_THROW ),
+ mxShape( rxShape, uno::UNO_SET_THROW ),
+ mxShapeProps( rxShape, uno::UNO_QUERY_THROW )
+{
+}
+
+// XSheetObject attributes
+
+double SAL_CALL ScVbaSheetObjectBase::getLeft() throw (uno::RuntimeException)
+{
+ return HmmToPoints( mxShape->getPosition().X );
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setLeft( double fLeft ) throw (uno::RuntimeException)
+{
+ if( fLeft < 0.0 )
+ throw uno::RuntimeException();
+ mxShape->setPosition( awt::Point( PointsToHmm( fLeft ), mxShape->getPosition().Y ) );
+}
+
+double SAL_CALL ScVbaSheetObjectBase::getTop() throw (uno::RuntimeException)
+{
+ return HmmToPoints( mxShape->getPosition().Y );
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setTop( double fTop ) throw (uno::RuntimeException)
+{
+ if( fTop < 0.0 )
+ throw uno::RuntimeException();
+ mxShape->setPosition( awt::Point( mxShape->getPosition().X, PointsToHmm( fTop ) ) );
+}
+
+double SAL_CALL ScVbaSheetObjectBase::getWidth() throw (uno::RuntimeException)
+{
+ return HmmToPoints( mxShape->getSize().Width );
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setWidth( double fWidth ) throw (uno::RuntimeException)
+{
+ if( fWidth <= 0.0 )
+ throw uno::RuntimeException();
+ mxShape->setSize( awt::Size( PointsToHmm( fWidth ), mxShape->getSize().Height ) );
+}
+
+double SAL_CALL ScVbaSheetObjectBase::getHeight() throw (uno::RuntimeException)
+{
+ return HmmToPoints( mxShape->getSize().Height );
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setHeight( double fHeight ) throw (uno::RuntimeException)
+{
+ if( fHeight <= 0.0 )
+ throw uno::RuntimeException();
+ mxShape->setSize( awt::Size( mxShape->getSize().Width, PointsToHmm( fHeight ) ) );
+}
+
+OUString SAL_CALL ScVbaSheetObjectBase::getName() throw (uno::RuntimeException)
+{
+ return mxShapeProps->getPropertyValue( CREATE_OUSTRING( "Name" ) ).get< OUString >();
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setName( const OUString& rName ) throw (uno::RuntimeException)
+{
+ mxShapeProps->setPropertyValue( CREATE_OUSTRING( "Name" ), uno::Any( rName ) );
+}
+
+sal_Int32 SAL_CALL ScVbaSheetObjectBase::getPlacement() throw (uno::RuntimeException)
+{
+ // TODO
+ return excel::XlPlacement::xlMoveAndSize;
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setPlacement( sal_Int32 /*nPlacement*/ ) throw (uno::RuntimeException)
+{
+ // TODO
+}
+
+sal_Bool SAL_CALL ScVbaSheetObjectBase::getPrintObject() throw (uno::RuntimeException)
+{
+ // not supported
+ return sal_True;
+}
+
+void SAL_CALL ScVbaSheetObjectBase::setPrintObject( sal_Bool /*bPrintObject*/ ) throw (uno::RuntimeException)
+{
+ // not supported
+}
+
+// private
+
+void ScVbaSheetObjectBase::setDefaultProperties( sal_Int32 nIndex ) throw (uno::RuntimeException)
+{
+ OUString aName = ::rtl::OUStringBuffer( implGetBaseName() ).append( sal_Unicode( ' ' ) ).append( nIndex + 1 ).makeStringAndClear();
+ setName( aName );
+ implSetDefaultProperties();
+}
+
+void ScVbaSheetObjectBase::implSetDefaultProperties() throw (uno::RuntimeException)
+{
+}
+
+// ============================================================================
+
+ScVbaControlObjectBase::ScVbaControlObjectBase(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< container::XIndexContainer >& rxFormIC,
+ const uno::Reference< drawing::XControlShape >& rxControlShape,
+ ListenerType eListenerType ) throw (uno::RuntimeException) :
+ ScVbaControlObject_BASE( rxParent, rxContext, rxModel, uno::Reference< drawing::XShape >( rxControlShape, uno::UNO_QUERY_THROW ) ),
+ mxFormIC( rxFormIC, uno::UNO_SET_THROW ),
+ mxControlProps( rxControlShape->getControl(), uno::UNO_QUERY_THROW )
+{
+ // set listener and event name to be used for OnAction attribute
+ switch( eListenerType )
+ {
+ case LISTENER_ACTION:
+ maListenerType = CREATE_OUSTRING( "XActionListener" );
+ maEventMethod = CREATE_OUSTRING( "actionPerformed" );
+ break;
+ case LISTENER_MOUSE:
+ maListenerType = CREATE_OUSTRING( "XMouseListener" );
+ maEventMethod = CREATE_OUSTRING( "mouseReleased" );
+ break;
+ case LISTENER_TEXT:
+ maListenerType = CREATE_OUSTRING( "XTextListener" );
+ maEventMethod = CREATE_OUSTRING( "textChanged" );
+ break;
+ case LISTENER_VALUE:
+ maListenerType = CREATE_OUSTRING( "XAdjustmentListener" );
+ maEventMethod = CREATE_OUSTRING( "adjustmentValueChanged" );
+ break;
+ case LISTENER_CHANGE:
+ maListenerType = CREATE_OUSTRING( "XChangeListener" );
+ maEventMethod = CREATE_OUSTRING( "changed" );
+ break;
+ // no default, to let the compiler complain about missing case
+ }
+}
+
+// XSheetObject attributes
+
+OUString SAL_CALL ScVbaControlObjectBase::getName() throw (uno::RuntimeException)
+{
+ return mxControlProps->getPropertyValue( CREATE_OUSTRING( "Name" ) ).get< OUString >();
+}
+
+void SAL_CALL ScVbaControlObjectBase::setName( const OUString& rName ) throw (uno::RuntimeException)
+{
+ mxControlProps->setPropertyValue( CREATE_OUSTRING( "Name" ), uno::Any( rName ) );
+}
+
+OUString SAL_CALL ScVbaControlObjectBase::getOnAction() throw (uno::RuntimeException)
+{
+ uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
+ sal_Int32 nIndex = getModelIndexInForm();
+ uno::Sequence< script::ScriptEventDescriptor > aEvents = xEventMgr->getScriptEvents( nIndex );
+ if( aEvents.hasElements() )
+ {
+ const script::ScriptEventDescriptor* pEvent = aEvents.getConstArray();
+ const script::ScriptEventDescriptor* pEventEnd = pEvent + aEvents.getLength();
+ const OUString aScriptType = CREATE_OUSTRING( "Script" );
+ for( ; pEvent < pEventEnd; ++pEvent )
+ if( (pEvent->ListenerType == maListenerType) && (pEvent->EventMethod == maEventMethod) && (pEvent->ScriptType == aScriptType) )
+ return extractMacroName( pEvent->ScriptCode );
+ }
+ return OUString();
+}
+
+void SAL_CALL ScVbaControlObjectBase::setOnAction( const OUString& rMacroName ) throw (uno::RuntimeException)
+{
+ uno::Reference< script::XEventAttacherManager > xEventMgr( mxFormIC, uno::UNO_QUERY_THROW );
+ sal_Int32 nIndex = getModelIndexInForm();
+
+ // first, remove a registered event (try/catch just in case implementation throws)
+ try { xEventMgr->revokeScriptEvent( nIndex, maListenerType, maEventMethod, OUString() ); } catch( uno::Exception& ) {}
+
+ // if a macro name has been passed, try to attach it to the event
+ if( rMacroName.getLength() > 0 )
+ {
+ VBAMacroResolvedInfo aResolvedMacro = resolveVBAMacro( getSfxObjShell( mxModel ), rMacroName );
+ if( !aResolvedMacro.IsResolved() )
+ throw uno::RuntimeException();
+ script::ScriptEventDescriptor aDescriptor;
+ aDescriptor.ListenerType = maListenerType;
+ aDescriptor.EventMethod = maEventMethod;
+ aDescriptor.ScriptType = CREATE_OUSTRING( "Script" );
+ aDescriptor.ScriptCode = makeMacroURL( aResolvedMacro.ResolvedMacro() );
+ xEventMgr->registerScriptEvent( nIndex, aDescriptor );
+ }
+}
+
+sal_Bool SAL_CALL ScVbaControlObjectBase::getPrintObject() throw (uno::RuntimeException)
+{
+ return mxControlProps->getPropertyValue( CREATE_OUSTRING( "Printable" ) ).get< sal_Bool >();
+}
+
+void SAL_CALL ScVbaControlObjectBase::setPrintObject( sal_Bool bPrintObject ) throw (uno::RuntimeException)
+{
+ mxControlProps->setPropertyValue( CREATE_OUSTRING( "Printable" ), uno::Any( bPrintObject ) );
+}
+
+// XControlObject attributes
+
+sal_Bool SAL_CALL ScVbaControlObjectBase::getAutoSize() throw (uno::RuntimeException)
+{
+ // not supported
+ return sal_False;
+}
+
+void SAL_CALL ScVbaControlObjectBase::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
+{
+ // not supported
+}
+
+// private
+
+sal_Int32 ScVbaControlObjectBase::getModelIndexInForm() const throw (uno::RuntimeException)
+{
+ for( sal_Int32 nIndex = 0, nCount = mxFormIC->getCount(); nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< beans::XPropertySet > xProps( mxFormIC->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ if( mxControlProps.get() == xProps.get() )
+ return nIndex;
+ }
+ throw uno::RuntimeException();
+}
+
+// ============================================================================
+
+ScVbaButton::ScVbaButton(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< container::XIndexContainer >& rxFormIC,
+ const uno::Reference< drawing::XControlShape >& rxControlShape ) throw (uno::RuntimeException) :
+ ScVbaButton_BASE( rxParent, rxContext, rxModel, rxFormIC, rxControlShape, LISTENER_ACTION )
+{
+}
+
+// XButton attributes
+
+OUString SAL_CALL ScVbaButton::getCaption() throw (uno::RuntimeException)
+{
+ return mxControlProps->getPropertyValue( CREATE_OUSTRING( "Label" ) ).get< OUString >();
+}
+
+void SAL_CALL ScVbaButton::setCaption( const OUString& rCaption ) throw (uno::RuntimeException)
+{
+ mxControlProps->setPropertyValue( CREATE_OUSTRING( "Label" ), uno::Any( rCaption ) );
+}
+
+uno::Reference< excel::XFont > SAL_CALL ScVbaButton::getFont() throw (uno::RuntimeException)
+{
+ return new ScVbaFont( this, mxContext, maPalette, mxControlProps, 0, true );
+}
+
+void SAL_CALL ScVbaButton::setFont( const uno::Reference< excel::XFont >& /*rxFont*/ ) throw (uno::RuntimeException)
+{
+ // TODO
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getHorizontalAlignment() throw (uno::RuntimeException)
+{
+ switch( mxControlProps->getPropertyValue( CREATE_OUSTRING( "Align" ) ).get< sal_Int16 >() )
+ {
+ case awt::TextAlign::LEFT: return excel::Constants::xlLeft;
+ case awt::TextAlign::RIGHT: return excel::Constants::xlRight;
+ case awt::TextAlign::CENTER: return excel::Constants::xlCenter;
+ }
+ return excel::Constants::xlCenter;
+}
+
+void SAL_CALL ScVbaButton::setHorizontalAlignment( sal_Int32 nAlign ) throw (uno::RuntimeException)
+{
+ sal_Int32 nAwtAlign = awt::TextAlign::CENTER;
+ switch( nAlign )
+ {
+ case excel::Constants::xlLeft: nAwtAlign = awt::TextAlign::LEFT; break;
+ case excel::Constants::xlRight: nAwtAlign = awt::TextAlign::RIGHT; break;
+ case excel::Constants::xlCenter: nAwtAlign = awt::TextAlign::CENTER; break;
+ }
+ // form controls expect short value
+ mxControlProps->setPropertyValue( CREATE_OUSTRING( "Align" ), uno::Any( static_cast< sal_Int16 >( nAwtAlign ) ) );
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getVerticalAlignment() throw (uno::RuntimeException)
+{
+ switch( mxControlProps->getPropertyValue( CREATE_OUSTRING( "VerticalAlign" ) ).get< style::VerticalAlignment >() )
+ {
+ case style::VerticalAlignment_TOP: return excel::Constants::xlTop;
+ case style::VerticalAlignment_BOTTOM: return excel::Constants::xlBottom;
+ case style::VerticalAlignment_MIDDLE: return excel::Constants::xlCenter;
+ default:;
+ }
+ return excel::Constants::xlCenter;
+}
+
+void SAL_CALL ScVbaButton::setVerticalAlignment( sal_Int32 nAlign ) throw (uno::RuntimeException)
+{
+ style::VerticalAlignment eAwtAlign = style::VerticalAlignment_MIDDLE;
+ switch( nAlign )
+ {
+ case excel::Constants::xlTop: eAwtAlign = style::VerticalAlignment_TOP; break;
+ case excel::Constants::xlBottom: eAwtAlign = style::VerticalAlignment_BOTTOM; break;
+ case excel::Constants::xlCenter: eAwtAlign = style::VerticalAlignment_MIDDLE; break;
+ }
+ mxControlProps->setPropertyValue( CREATE_OUSTRING( "VerticalAlign" ), uno::Any( eAwtAlign ) );
+}
+
+sal_Int32 SAL_CALL ScVbaButton::getOrientation() throw (uno::RuntimeException)
+{
+ // not supported
+ return excel::XlOrientation::xlHorizontal;
+}
+
+void SAL_CALL ScVbaButton::setOrientation( sal_Int32 /*nOrientation*/ ) throw (uno::RuntimeException)
+{
+ // not supported
+}
+
+// XButton methods
+
+uno::Reference< excel::XCharacters > SAL_CALL ScVbaButton::Characters( const uno::Any& rStart, const uno::Any& rLength ) throw (uno::RuntimeException)
+{
+ return new ScVbaButtonCharacters( this, mxContext, mxControlProps, maPalette, rStart, rLength );
+}
+
+// XHelperInterface
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaButton, "ooo.vba.excel.Button" )
+
+// private
+
+OUString ScVbaButton::implGetBaseName() const
+{
+ return CREATE_OUSTRING( "Button" );
+}
+
+void ScVbaButton::implSetDefaultProperties() throw (uno::RuntimeException)
+{
+ setCaption( getName() );
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbasheetobject.hxx b/sc/source/ui/vba/vbasheetobject.hxx
new file mode 100644
index 000000000000..928c9006e757
--- /dev/null
+++ b/sc/source/ui/vba/vbasheetobject.hxx
@@ -0,0 +1,223 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_SHEETOBJECT_HXX
+#define SC_VBA_SHEETOBJECT_HXX
+
+#include <memory>
+#include <ooo/vba/excel/XButton.hpp>
+#include <ooo/vba/excel/XControlObject.hpp>
+#include <ooo/vba/excel/XSheetObject.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include "vbapalette.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace container { class XIndexContainer; }
+ namespace drawing { class XControlShape; }
+} } }
+
+// ============================================================================
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XCharacters > ScVbaButtonCharacters_BASE;
+
+/** Simple implementation of the Characters symbol for drawing button objects. */
+class ScVbaButtonCharacters : public ScVbaButtonCharacters_BASE
+{
+public:
+ explicit ScVbaButtonCharacters(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::beans::XPropertySet >& rxPropSet,
+ const ScVbaPalette& rPalette,
+ const css::uno::Any& rStart,
+ const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
+ virtual ~ScVbaButtonCharacters();
+
+ // XCharacters attributes
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setText( const ::rtl::OUString& rText ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getCount() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
+
+ // XCharacters methods
+ virtual void SAL_CALL Insert( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete() throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+private:
+ ::rtl::OUString getFullString() const throw (css::uno::RuntimeException);
+ void setFullString( const ::rtl::OUString& rString ) throw (css::uno::RuntimeException);
+
+private:
+ ScVbaPalette maPalette;
+ css::uno::Reference< css::beans::XPropertySet > mxPropSet;
+ sal_Int32 mnStart;
+ sal_Int32 mnLength;
+};
+
+// ============================================================================
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XSheetObject > ScVbaSheetObject_BASE;
+
+/** Base class for drawing objects embedded in sheets. */
+class ScVbaSheetObjectBase : public ScVbaSheetObject_BASE
+{
+public:
+ explicit ScVbaSheetObjectBase(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxModel,
+ const css::uno::Reference< css::drawing::XShape >& rxShape ) throw (css::uno::RuntimeException);
+
+ // XSheetObject attributes
+ virtual double SAL_CALL getLeft() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setLeft( double fLeft ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getTop() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setTop( double fTop ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getWidth() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWidth( double fWidth ) throw (css::uno::RuntimeException);
+ virtual double SAL_CALL getHeight() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHeight( double fHeight ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPlacement() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPlacement( sal_Int32 nPlacement ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
+
+ /** Sets default properties after a new object has been created. */
+ void setDefaultProperties( sal_Int32 nIndex ) throw (css::uno::RuntimeException);
+
+protected:
+ /** Derived classes return the base name used for new objects. */
+ virtual ::rtl::OUString implGetBaseName() const = 0;
+ /** Derived classes set default properties for new drawing objects. */
+ virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
+
+protected:
+ ScVbaPalette maPalette;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::drawing::XShape > mxShape;
+ css::uno::Reference< css::beans::XPropertySet > mxShapeProps;
+};
+
+// ============================================================================
+
+typedef ::cppu::ImplInheritanceHelper1< ScVbaSheetObjectBase, ov::excel::XControlObject > ScVbaControlObject_BASE;
+
+class ScVbaControlObjectBase : public ScVbaControlObject_BASE
+{
+public:
+ /** Specifies the listener used for OnAction events. */
+ enum ListenerType
+ {
+ LISTENER_ACTION, /// XActionListener.actionPerformed
+ LISTENER_MOUSE, /// XMouseListener.mouseReleased
+ LISTENER_TEXT, /// XTextListener.textChanged
+ LISTENER_VALUE, /// XAdjustmentListener.adjustmentValueChanged
+ LISTENER_CHANGE /// XChangeListener.changed
+ };
+
+ explicit ScVbaControlObjectBase(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxModel,
+ const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
+ const css::uno::Reference< css::drawing::XControlShape >& rxControlShape,
+ ListenerType eListenerType ) throw (css::uno::RuntimeException);
+
+ // XSheetObject attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& rName ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getOnAction() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setOnAction( const ::rtl::OUString& rMacroName ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getPrintObject() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPrintObject( sal_Bool bPrintObject ) throw (css::uno::RuntimeException);
+
+ // XControlObject attributes
+ virtual sal_Bool SAL_CALL getAutoSize() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoSize( sal_Bool bAutoSize ) throw (css::uno::RuntimeException);
+
+protected:
+ sal_Int32 getModelIndexInForm() const throw (css::uno::RuntimeException);
+
+protected:
+ css::uno::Reference< css::container::XIndexContainer > mxFormIC;
+ css::uno::Reference< css::beans::XPropertySet > mxControlProps;
+ ::rtl::OUString maListenerType;
+ ::rtl::OUString maEventMethod;
+};
+
+// ============================================================================
+
+typedef ::cppu::ImplInheritanceHelper1< ScVbaControlObjectBase, ov::excel::XButton > ScVbaButton_BASE;
+
+class ScVbaButton : public ScVbaButton_BASE
+{
+public:
+ explicit ScVbaButton(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxModel,
+ const css::uno::Reference< css::container::XIndexContainer >& rxFormIC,
+ const css::uno::Reference< css::drawing::XControlShape >& rxControlShape ) throw (css::uno::RuntimeException);
+
+ // XButton attributes
+ virtual ::rtl::OUString SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const ::rtl::OUString& rCaption ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XFont > SAL_CALL getFont() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFont( const css::uno::Reference< ov::excel::XFont >& rxFont ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getHorizontalAlignment() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setHorizontalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getVerticalAlignment() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVerticalAlignment( sal_Int32 nAlign ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getOrientation() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setOrientation( sal_Int32 nOrientation ) throw (css::uno::RuntimeException);
+
+ // XButton methods
+ css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters(
+ const css::uno::Any& rStart, const css::uno::Any& rLength ) throw (css::uno::RuntimeException);
+
+ // XHelperInterface
+ VBAHELPER_DECL_XHELPERINTERFACE
+
+protected:
+ virtual ::rtl::OUString implGetBaseName() const;
+ virtual void implSetDefaultProperties() throw (css::uno::RuntimeException);
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbasheetobjects.cxx b/sc/source/ui/vba/vbasheetobjects.cxx
new file mode 100644
index 000000000000..b05aa82722b8
--- /dev/null
+++ b/sc/source/ui/vba/vbasheetobjects.cxx
@@ -0,0 +1,537 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbasheetobjects.hxx"
+#include <vector>
+#include <rtl/math.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XIndexContainer.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/XFormComponent.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <oox/helper/helper.hxx>
+#include "vbasheetobject.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+// ============================================================================
+
+namespace {
+
+template< typename Type >
+inline bool lclGetProperty( Type& orValue, const uno::Reference< beans::XPropertySet >& rxPropSet, const OUString& rPropName )
+{
+ try
+ {
+ return rxPropSet->getPropertyValue( rPropName ) >>= orValue;
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return false;
+}
+
+/** Rounds the passed value to a multiple of 0.75 and converts it to 1/100 mm. */
+inline double lclPointsToHmm( const uno::Any& rPoints ) throw (uno::RuntimeException)
+{
+ return PointsToHmm( ::rtl::math::approxFloor( rPoints.get< double >() / 0.75 ) * 0.75 );
+}
+
+} // namespace
+
+// ============================================================================
+// Base implementations
+// ============================================================================
+
+/** Container for a specific type of drawing object in a spreadsheet.
+
+ Derived classes provide all required functionality specific to the type of
+ shapes covered by the container.
+ */
+class ScVbaObjectContainer : public ::cppu::WeakImplHelper1< container::XIndexAccess >
+{
+public:
+ explicit ScVbaObjectContainer(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ const uno::Type& rVbaType ) throw (uno::RuntimeException);
+
+ /** Returns the VBA helper interface of the VBA collection object. */
+ inline const uno::Reference< XHelperInterface >& getParent() const { return mxParent; }
+ /** Returns the component context of the VBA collection object. */
+ inline const uno::Reference< uno::XComponentContext >& getContext() const { return mxContext; }
+ /** Returns the VBA type information of the objects in this container. */
+ inline const uno::Type& getVbaType() const { return maVbaType; }
+
+ /** Collects all shapes supported by this instance and inserts them into
+ the internal shape vector. */
+ void collectShapes() throw (uno::RuntimeException);
+ /** Creates and returns a new UNO shape. */
+ uno::Reference< drawing::XShape > createShape( const awt::Point& rPos, const awt::Size& rSize ) throw (uno::RuntimeException);
+ /** Inserts the passed shape into the draw page and into this container, and returns its index in the draw page. */
+ sal_Int32 insertShape( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
+ /** Creates and returns a new VBA implementation object for the passed shape. */
+ ::rtl::Reference< ScVbaSheetObjectBase > createVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
+ /** Creates and returns a new VBA implementation object for the passed shape in an Any. */
+ uno::Any createCollectionObject( const uno::Any& rSource ) throw (uno::RuntimeException);
+ /** Returns the VBA implementation object with the specified name. */
+ uno::Any getItemByStringIndex( const OUString& rIndex ) throw (uno::RuntimeException);
+
+ // XIndexAccess
+ virtual sal_Int32 SAL_CALL getCount() throw (uno::RuntimeException);
+ virtual uno::Any SAL_CALL getByIndex( sal_Int32 nIndex ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException);
+
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType() throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException);
+
+protected:
+ /** Derived classes return true, if the passed shape is supported by the instance. */
+ virtual bool implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const = 0;
+ /** Derived classes create and return a new VBA implementation object for the passed shape. */
+ virtual ScVbaSheetObjectBase* implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException) = 0;
+ /** Derived classes return the service name of the UNO shape. */
+ virtual OUString implGetShapeServiceName() const = 0;
+
+ /** Returns the shape name via 'Name' property of the UNO shape. May be overwritten. */
+ virtual OUString implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException);
+ /** Is called when a new UNO shape has been created but not yet inserted into the drawing page. */
+ virtual void implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
+ /** Is called when a new UNO shape has been inserted into the drawing page. */
+ virtual void implOnShapeInserted( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
+
+protected:
+ uno::Reference< XHelperInterface > mxParent;
+ uno::Reference< uno::XComponentContext > mxContext;
+ uno::Reference< frame::XModel > mxModel;
+ uno::Reference< lang::XMultiServiceFactory > mxFactory;
+ uno::Reference< drawing::XShapes > mxShapes;
+
+private:
+ typedef ::std::vector< uno::Reference< drawing::XShape > > ShapeVector;
+ const uno::Type maVbaType;
+ ShapeVector maShapes;
+};
+
+// ----------------------------------------------------------------------------
+
+ScVbaObjectContainer::ScVbaObjectContainer(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ const uno::Type& rVbaType ) throw (uno::RuntimeException) :
+ mxParent( rxParent ),
+ mxContext( rxContext ),
+ mxModel( rxModel, uno::UNO_SET_THROW ),
+ mxFactory( rxModel, uno::UNO_QUERY_THROW ),
+ maVbaType( rVbaType )
+{
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupp( rxSheet, uno::UNO_QUERY_THROW );
+ mxShapes.set( xDrawPageSupp->getDrawPage(), uno::UNO_QUERY_THROW );
+}
+
+void ScVbaObjectContainer::collectShapes() throw (uno::RuntimeException)
+{
+ maShapes.clear();
+ for( sal_Int32 nIndex = 0, nCount = mxShapes->getCount(); nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< drawing::XShape > xShape( mxShapes->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ if( implPickShape( xShape ) )
+ maShapes.push_back( xShape );
+ }
+}
+
+uno::Reference< drawing::XShape > ScVbaObjectContainer::createShape( const awt::Point& rPos, const awt::Size& rSize ) throw (uno::RuntimeException)
+{
+ uno::Reference< drawing::XShape > xShape( mxFactory->createInstance( implGetShapeServiceName() ), uno::UNO_QUERY_THROW );
+ xShape->setPosition( rPos );
+ xShape->setSize( rSize );
+ implOnShapeCreated( xShape );
+ return xShape;
+}
+
+sal_Int32 ScVbaObjectContainer::insertShape( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
+{
+ mxShapes->add( rxShape );
+ maShapes.push_back( rxShape );
+ implOnShapeInserted( rxShape );
+ return mxShapes->getCount() - 1;
+}
+
+::rtl::Reference< ScVbaSheetObjectBase > ScVbaObjectContainer::createVbaObject(
+ const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
+{
+ return implCreateVbaObject( rxShape );
+}
+
+uno::Any ScVbaObjectContainer::createCollectionObject( const uno::Any& rSource ) throw (uno::RuntimeException)
+{
+ uno::Reference< drawing::XShape > xShape( rSource, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XSheetObject > xSheetObject( implCreateVbaObject( xShape ) );
+ return uno::Any( xSheetObject );
+}
+
+uno::Any ScVbaObjectContainer::getItemByStringIndex( const OUString& rIndex ) throw (uno::RuntimeException)
+{
+ for( ShapeVector::iterator aIt = maShapes.begin(), aEnd = maShapes.end(); aIt != aEnd; ++aIt )
+ if( rIndex == implGetShapeName( *aIt ) )
+ return createCollectionObject( uno::Any( *aIt ) );
+ throw uno::RuntimeException();
+}
+
+// XIndexAccess
+
+sal_Int32 SAL_CALL ScVbaObjectContainer::getCount() throw (uno::RuntimeException)
+{
+ return static_cast< sal_Int32 >( maShapes.size() );
+}
+
+uno::Any SAL_CALL ScVbaObjectContainer::getByIndex( sal_Int32 nIndex )
+ throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ if( (0 <= nIndex) && (nIndex < getCount()) )
+ return uno::Any( maShapes[ static_cast< size_t >( nIndex ) ] );
+ throw lang::IndexOutOfBoundsException();
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScVbaObjectContainer::getElementType() throw (uno::RuntimeException)
+{
+ return drawing::XShape::static_type( 0 );
+}
+
+sal_Bool SAL_CALL ScVbaObjectContainer::hasElements() throw (uno::RuntimeException)
+{
+ return !maShapes.empty();
+}
+
+// private
+
+OUString ScVbaObjectContainer::implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xPropSet( rxShape, uno::UNO_QUERY_THROW );
+ return xPropSet->getPropertyValue( CREATE_OUSTRING( "Name" ) ).get< OUString >();
+}
+
+void ScVbaObjectContainer::implOnShapeCreated( const uno::Reference< drawing::XShape >& /*rxShape*/ ) throw (uno::RuntimeException)
+{
+}
+
+void ScVbaObjectContainer::implOnShapeInserted( const uno::Reference< drawing::XShape >& /*rxShape*/ ) throw (uno::RuntimeException)
+{
+}
+
+// ============================================================================
+
+class ScVbaObjectEnumeration : public SimpleEnumerationBase
+{
+public:
+ explicit ScVbaObjectEnumeration( const ScVbaObjectContainerRef& rxContainer );
+ virtual uno::Any createCollectionObject( const uno::Any& rSource );
+
+private:
+ ScVbaObjectContainerRef mxContainer;
+};
+
+// ----------------------------------------------------------------------------
+
+ScVbaObjectEnumeration::ScVbaObjectEnumeration( const ScVbaObjectContainerRef& rxContainer ) :
+ SimpleEnumerationBase( rxContainer->getParent(), rxContainer->getContext(), rxContainer.get() ),
+ mxContainer( rxContainer )
+{
+}
+
+uno::Any ScVbaObjectEnumeration::createCollectionObject( const uno::Any& rSource )
+{
+ return mxContainer->createCollectionObject( rSource );
+}
+
+// ============================================================================
+
+ScVbaSheetObjectsBase::ScVbaSheetObjectsBase( const ScVbaObjectContainerRef& rxContainer ) throw (css::uno::RuntimeException) :
+ ScVbaSheetObjects_BASE( rxContainer->getParent(), rxContainer->getContext(), rxContainer.get() ),
+ mxContainer( rxContainer )
+{
+ mxContainer->collectShapes();
+}
+
+ScVbaSheetObjectsBase::~ScVbaSheetObjectsBase()
+{
+}
+
+void ScVbaSheetObjectsBase::collectShapes() throw (uno::RuntimeException)
+{
+ mxContainer->collectShapes();
+}
+
+// XEnumerationAccess
+
+uno::Reference< container::XEnumeration > SAL_CALL ScVbaSheetObjectsBase::createEnumeration() throw (uno::RuntimeException)
+{
+ return new ScVbaObjectEnumeration( mxContainer );
+}
+
+// XElementAccess
+
+uno::Type SAL_CALL ScVbaSheetObjectsBase::getElementType() throw (uno::RuntimeException)
+{
+ return mxContainer->getVbaType();
+}
+
+// ScVbaCollectionBase
+
+uno::Any ScVbaSheetObjectsBase::createCollectionObject( const uno::Any& rSource )
+{
+ return mxContainer->createCollectionObject( rSource );
+}
+
+uno::Any ScVbaSheetObjectsBase::getItemByStringIndex( const OUString& rIndex ) throw (uno::RuntimeException)
+{
+ return mxContainer->getItemByStringIndex( rIndex );
+}
+
+// ============================================================================
+// Graphic object containers supporting ooo.vba.excel.XGraphicObject
+// ============================================================================
+
+ScVbaGraphicObjectsBase::ScVbaGraphicObjectsBase( const ScVbaObjectContainerRef& rxContainer ) throw (uno::RuntimeException) :
+ ScVbaGraphicObjects_BASE( rxContainer )
+{
+}
+
+// XGraphicObjects
+
+uno::Any SAL_CALL ScVbaGraphicObjectsBase::Add( const uno::Any& rLeft, const uno::Any& rTop, const uno::Any& rWidth, const uno::Any& rHeight ) throw (uno::RuntimeException)
+{
+ /* Extract double values from passed Anys (the lclPointsToHmm() helper
+ function will throw a RuntimeException on any error), and convert from
+ points to 1/100 mm. */
+ awt::Point aPos( lclPointsToHmm( rLeft ), lclPointsToHmm( rTop ) );
+ awt::Size aSize( lclPointsToHmm( rWidth ), lclPointsToHmm( rHeight ) );
+ // TODO: translate coordinates for RTL sheets
+ if( (aPos.X < 0) || (aPos.Y < 0) || (aSize.Width <= 0) || (aSize.Height <= 0) )
+ throw uno::RuntimeException();
+
+ // create the UNO shape
+ uno::Reference< drawing::XShape > xShape( mxContainer->createShape( aPos, aSize ), uno::UNO_SET_THROW );
+ sal_Int32 nIndex = mxContainer->insertShape( xShape );
+
+ // create and return the VBA object
+ ::rtl::Reference< ScVbaSheetObjectBase > xVbaObject = mxContainer->createVbaObject( xShape );
+ xVbaObject->setDefaultProperties( nIndex );
+ return uno::Any( uno::Reference< excel::XSheetObject >( xVbaObject.get() ) );
+}
+
+// ============================================================================
+// Drawing controls
+// ============================================================================
+
+class ScVbaControlContainer : public ScVbaObjectContainer
+{
+public:
+ explicit ScVbaControlContainer(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ const uno::Type& rVbaType,
+ const OUString& rModelServiceName,
+ sal_Int16 nComponentType ) throw (uno::RuntimeException);
+
+protected:
+ uno::Reference< container::XIndexContainer > createForm() throw (uno::RuntimeException);
+
+ virtual bool implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const;
+ virtual OUString implGetShapeServiceName() const;
+ virtual bool implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const;
+ virtual OUString implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException);
+ virtual void implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
+
+protected:
+ uno::Reference< container::XIndexContainer > mxFormIC;
+ OUString maModelServiceName;
+ sal_Int16 mnComponentType;
+};
+
+// ----------------------------------------------------------------------------
+
+ScVbaControlContainer::ScVbaControlContainer(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet,
+ const uno::Type& rVbaType,
+ const OUString& rModelServiceName,
+ sal_Int16 nComponentType ) throw (uno::RuntimeException) :
+ ScVbaObjectContainer( rxParent, rxContext, rxModel, rxSheet, rVbaType ),
+ maModelServiceName( rModelServiceName ),
+ mnComponentType( nComponentType )
+{
+}
+
+uno::Reference< container::XIndexContainer > ScVbaControlContainer::createForm() throw (uno::RuntimeException)
+{
+ if( !mxFormIC.is() )
+ {
+ uno::Reference< form::XFormsSupplier > xFormsSupp( mxShapes, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameContainer > xFormsNC( xFormsSupp->getForms(), uno::UNO_SET_THROW );
+ OUString aFormName = CREATE_OUSTRING( "Standard" );
+ if( xFormsNC->hasByName( aFormName ) )
+ {
+ mxFormIC.set( xFormsNC->getByName( aFormName ), uno::UNO_QUERY_THROW );
+ }
+ else
+ {
+ uno::Reference< form::XForm > xForm( mxFactory->createInstance( CREATE_OUSTRING( "com.sun.star.form.component.Form" ) ), uno::UNO_QUERY_THROW );
+ xFormsNC->insertByName( aFormName, uno::Any( xForm ) );
+ mxFormIC.set( xForm, uno::UNO_QUERY_THROW );
+ }
+ }
+ return mxFormIC;
+}
+
+bool ScVbaControlContainer::implPickShape( const uno::Reference< drawing::XShape >& rxShape ) const
+{
+ try
+ {
+ uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xModelProps( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+ sal_Int16 nClassId = -1;
+ return lclGetProperty( nClassId, xModelProps, CREATE_OUSTRING( "ClassId" ) ) &&
+ (nClassId == mnComponentType) && implCheckProperties( xModelProps );
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return false;
+}
+
+OUString ScVbaControlContainer::implGetShapeServiceName() const
+{
+ return CREATE_OUSTRING( "com.sun.star.drawing.ControlShape" );
+}
+
+bool ScVbaControlContainer::implCheckProperties( const uno::Reference< beans::XPropertySet >& /*rxModelProps*/ ) const
+{
+ return true;
+}
+
+OUString ScVbaControlContainer::implGetShapeName( const uno::Reference< drawing::XShape >& rxShape ) const throw (uno::RuntimeException)
+{
+ uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
+ return uno::Reference< container::XNamed >( xControlShape->getControl(), uno::UNO_QUERY_THROW )->getName();
+}
+
+void ScVbaControlContainer::implOnShapeCreated( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
+{
+ // passed shape must be a control shape
+ uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
+
+ // create the UNO control model
+ uno::Reference< form::XFormComponent > xFormComponent( mxFactory->createInstance( maModelServiceName ), uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XControlModel > xControlModel( xFormComponent, uno::UNO_QUERY_THROW );
+
+ // insert the control model into the form and the shape
+ createForm();
+ mxFormIC->insertByIndex( mxFormIC->getCount(), uno::Any( xFormComponent ) );
+ xControlShape->setControl( xControlModel );
+}
+
+// ============================================================================
+// Push button
+// ============================================================================
+
+class ScVbaButtonContainer : public ScVbaControlContainer
+{
+public:
+ explicit ScVbaButtonContainer(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet ) throw (uno::RuntimeException);
+
+protected:
+ virtual ScVbaSheetObjectBase* implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException);
+ virtual bool implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const;
+};
+
+// ----------------------------------------------------------------------------
+
+ScVbaButtonContainer::ScVbaButtonContainer(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet ) throw (uno::RuntimeException) :
+ ScVbaControlContainer(
+ rxParent, rxContext, rxModel, rxSheet,
+ excel::XButton::static_type( 0 ),
+ CREATE_OUSTRING( "com.sun.star.form.component.CommandButton" ),
+ form::FormComponentType::COMMANDBUTTON )
+{
+}
+
+ScVbaSheetObjectBase* ScVbaButtonContainer::implCreateVbaObject( const uno::Reference< drawing::XShape >& rxShape ) throw (uno::RuntimeException)
+{
+ uno::Reference< drawing::XControlShape > xControlShape( rxShape, uno::UNO_QUERY_THROW );
+ return new ScVbaButton( mxParent, mxContext, mxModel, createForm(), xControlShape );
+}
+
+bool ScVbaButtonContainer::implCheckProperties( const uno::Reference< beans::XPropertySet >& rxModelProps ) const
+{
+ // do not insert toggle buttons into the 'Buttons' collection
+ bool bToggle = false;
+ return lclGetProperty( bToggle, rxModelProps, CREATE_OUSTRING( "Toggle" ) ) && !bToggle;
+}
+
+// ============================================================================
+
+ScVbaButtons::ScVbaButtons(
+ const uno::Reference< XHelperInterface >& rxParent,
+ const uno::Reference< uno::XComponentContext >& rxContext,
+ const uno::Reference< frame::XModel >& rxModel,
+ const uno::Reference< sheet::XSpreadsheet >& rxSheet ) throw (uno::RuntimeException) :
+ ScVbaGraphicObjectsBase( new ScVbaButtonContainer( rxParent, rxContext, rxModel, rxSheet ) )
+{
+}
+
+VBAHELPER_IMPL_XHELPERINTERFACE( ScVbaButtons, "ooo.vba.excel.Buttons" )
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbasheetobjects.hxx b/sc/source/ui/vba/vbasheetobjects.hxx
new file mode 100644
index 000000000000..c59ec8882e91
--- /dev/null
+++ b/sc/source/ui/vba/vbasheetobjects.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_VBA_SHEETOBJECTS_HXX
+#define SC_VBA_SHEETOBJECTS_HXX
+
+#include <ooo/vba/excel/XGraphicObjects.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <rtl/ref.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace container { class XEnumeration; }
+ namespace frame { class XModel; }
+ namespace sheet { class XSpreadsheet; }
+} } }
+
+// ============================================================================
+
+class ScVbaObjectContainer;
+typedef ::rtl::Reference< ScVbaObjectContainer > ScVbaObjectContainerRef;
+
+// ============================================================================
+
+typedef CollTestImplHelper< ov::XCollection > ScVbaSheetObjects_BASE;
+
+/** Base class for collections containing a specific type of drawing object
+ embedded in a sheet (worksheet, chart sheet, or dialog sheet).
+ */
+class ScVbaSheetObjectsBase : public ScVbaSheetObjects_BASE
+{
+public:
+ explicit ScVbaSheetObjectsBase( const ScVbaObjectContainerRef& rxContainer ) throw (css::uno::RuntimeException);
+ virtual ~ScVbaSheetObjectsBase();
+
+ /** Updates the collection by fetching all shapes from the draw page. */
+ void collectShapes() throw (css::uno::RuntimeException);
+
+ // XEnumerationAccess
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // XElementAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+
+ // ScVbaCollectionBase
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& rSource );
+ virtual css::uno::Any getItemByStringIndex( const ::rtl::OUString& rIndex ) throw (css::uno::RuntimeException);
+
+protected:
+ ScVbaObjectContainerRef mxContainer;
+};
+
+// ============================================================================
+
+typedef ::cppu::ImplInheritanceHelper1< ScVbaSheetObjectsBase, ov::excel::XGraphicObjects > ScVbaGraphicObjects_BASE;
+
+/** Base class for collections containing a specific type of graphic object
+ from a sheet.
+ */
+class ScVbaGraphicObjectsBase : public ScVbaGraphicObjects_BASE
+{
+public:
+ explicit ScVbaGraphicObjectsBase( const ScVbaObjectContainerRef& rxContainer ) throw (css::uno::RuntimeException);
+
+ // XGraphicObjects
+ virtual css::uno::Any SAL_CALL Add(
+ const css::uno::Any& rLeft,
+ const css::uno::Any& rTop,
+ const css::uno::Any& rWidth,
+ const css::uno::Any& rHeight ) throw (css::uno::RuntimeException);
+};
+
+// ============================================================================
+
+/** Collection containing all button controls from a sheet (not ActiveX controls). */
+class ScVbaButtons : public ScVbaGraphicObjectsBase
+{
+public:
+ explicit ScVbaButtons(
+ const css::uno::Reference< ov::XHelperInterface >& rxParent,
+ const css::uno::Reference< css::uno::XComponentContext >& rxContext,
+ const css::uno::Reference< css::frame::XModel >& rxModel,
+ const css::uno::Reference< css::sheet::XSpreadsheet >& rxSheet ) throw (css::uno::RuntimeException);
+
+ VBAHELPER_DECL_XHELPERINTERFACE
+};
+
+// ============================================================================
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbastyle.cxx b/sc/source/ui/vba/vbastyle.cxx
new file mode 100644
index 000000000000..2594effca2e0
--- /dev/null
+++ b/sc/source/ui/vba/vbastyle.cxx
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbastyle.hxx"
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+static rtl::OUString DISPLAYNAME( RTL_CONSTASCII_USTRINGPARAM("DisplayName") );
+
+
+
+uno::Reference< container::XNameAccess >
+ScVbaStyle::getStylesNameContainer( const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException )
+{
+ uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( xModel, uno::UNO_QUERY_THROW);
+ uno::Reference< container::XNameAccess > xStylesAccess( xStyleSupplier->getStyleFamilies()->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CellStyles" ) ) ), uno::UNO_QUERY_THROW );
+ return xStylesAccess;
+}
+
+uno::Reference< beans::XPropertySet >
+lcl_getStyleProps( const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException, uno::RuntimeException )
+{
+
+ uno::Reference< beans::XPropertySet > xStyleProps( ScVbaStyle::getStylesNameContainer( xModel )->getByName( sStyleName ), uno::UNO_QUERY_THROW );
+ return xStyleProps;
+}
+
+
+void ScVbaStyle::initialise() throw ( uno::RuntimeException )
+{
+ if (!mxModel.is() )
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "XModel Interface could not be retrieved")) );
+ uno::Reference< lang::XServiceInfo > xServiceInfo( mxPropertySet, uno::UNO_QUERY_THROW );
+ if ( !xServiceInfo->supportsService( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.style.CellStyle" ) ) ) )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ mxStyle.set( mxPropertySet, uno::UNO_QUERY_THROW );
+
+ uno::Reference< style::XStyleFamiliesSupplier > xStyleSupplier( mxModel, uno::UNO_QUERY_THROW );
+ mxStyleFamilyNameContainer.set( ScVbaStyle::getStylesNameContainer( mxModel ), uno::UNO_QUERY_THROW );
+
+}
+
+ScVbaStyle::ScVbaStyle( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const rtl::OUString& sStyleName, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, lcl_getStyleProps( sStyleName, _xModel ), _xModel, false ), mxModel( _xModel )
+{
+ try
+ {
+ initialise();
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+ScVbaStyle::ScVbaStyle( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet >& _xPropertySet, const uno::Reference< frame::XModel >& _xModel ) throw ( script::BasicErrorException, uno::RuntimeException ) : ScVbaStyle_BASE( xParent, xContext, _xPropertySet, _xModel, false ), mxModel( _xModel )
+{
+ try
+ {
+ initialise();
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+
+::sal_Bool SAL_CALL
+ScVbaStyle::BuiltIn() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return !mxStyle->isUserDefined();
+
+}
+void SAL_CALL
+ScVbaStyle::setName( const ::rtl::OUString& Name ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ mxStyle->setName(Name);
+}
+
+::rtl::OUString SAL_CALL
+ScVbaStyle::getName() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return mxStyle->getName();
+}
+
+void SAL_CALL
+ScVbaStyle::setNameLocal( const ::rtl::OUString& NameLocal ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ mxPropertySet->setPropertyValue(DISPLAYNAME, uno::makeAny( NameLocal ) );
+ }
+ catch (uno::Exception& e)
+ {
+ DebugHelper::exception(e);
+ }
+}
+
+::rtl::OUString SAL_CALL
+ScVbaStyle::getNameLocal() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ rtl::OUString sName;
+ try
+ {
+ mxPropertySet->getPropertyValue(DISPLAYNAME) >>= sName;
+ }
+ catch (uno::Exception e)
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return sName;
+}
+
+void SAL_CALL
+ScVbaStyle::Delete() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ try
+ {
+ mxStyleFamilyNameContainer->removeByName(mxStyle->getName());
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+void SAL_CALL
+ScVbaStyle::setMergeCells( const uno::Any& /*MergeCells*/ ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+}
+
+uno::Any SAL_CALL
+ScVbaStyle::getMergeCells( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ DebugHelper::exception(SbERR_NOT_IMPLEMENTED, rtl::OUString());
+ return uno::Any();
+}
+
+
+rtl::OUString&
+ScVbaStyle::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaStyle") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaStyle::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XStyle" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbastyle.hxx b/sc/source/ui/vba/vbastyle.hxx
new file mode 100644
index 000000000000..c965146a1703
--- /dev/null
+++ b/sc/source/ui/vba/vbastyle.hxx
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_STYLE_HXX
+#define SC_VBA_STYLE_HXX
+#include <ooo/vba/excel/XStyle.hpp>
+#include <com/sun/star/style/XStyle.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include "vbaformat.hxx"
+
+
+typedef ScVbaFormat< ov::excel::XStyle > ScVbaStyle_BASE;
+
+class ScVbaStyle : public ScVbaStyle_BASE
+{
+protected:
+ css::uno::Reference< css::style::XStyle > mxStyle;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::container::XNameContainer > mxStyleFamilyNameContainer;
+ void initialise() throw ( css::uno::RuntimeException );
+public:
+ ScVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const rtl::OUString& sStyleName, const css::uno::Reference< css::frame::XModel >& _xModel ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ ScVbaStyle( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::beans::XPropertySet >& _xPropertySet, const css::uno::Reference< css::frame::XModel >& _xModel ) throw ( css::script::BasicErrorException, css::uno::RuntimeException );
+ virtual ~ScVbaStyle(){}
+ static css::uno::Reference< css::container::XNameAccess > getStylesNameContainer( const css::uno::Reference< css::frame::XModel >& xModel ) throw( css::uno::RuntimeException );
+ virtual css::uno::Reference< ov::XHelperInterface > thisHelperIface() { return this; };
+ // XStyle Methods
+ virtual ::sal_Bool SAL_CALL BuiltIn() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString& Name ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setNameLocal( const ::rtl::OUString& NameLocal ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNameLocal() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL Delete() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XFormat
+ virtual void SAL_CALL setMergeCells( const css::uno::Any& MergeCells ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getMergeCells( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+/*
+ // XFormat
+ virtual css::uno::Reference< ::ooo::vba::excel::XBorders > SAL_CALL Borders( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Reference< ::ooo::vba::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Reference< ::ooo::vba::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setNumberFormat( const css::uno::Any& NumberFormat ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getNumberFormat( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setNumberFormatLocal( const css::uno::Any& NumberFormatLocal ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getNumberFormatLocal( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setIndentLevel( const css::uno::Any& IndentLevel ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getIndentLevel( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setHorizontalAlignment( const css::uno::Any& HorizontalAlignment ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getHorizontalAlignment( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setVerticalAlignment( const css::uno::Any& VerticalAlignment ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getVerticalAlignment( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setOrientation( const css::uno::Any& Orientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setShrinkToFit( const css::uno::Any& ShrinkToFit ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getShrinkToFit( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setWrapText( const css::uno::Any& WrapText ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getWrapText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setLocked( const css::uno::Any& Locked ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getLocked( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setFormulaHidden( const css::uno::Any& FormulaHidden ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+/ virtual css::uno::Any SAL_CALL getFormulaHidden( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual void SAL_CALL setMergeCells( const css::uno::Any& MergeCells ) throw (css::script::BasicErrorException, css::uno::RuntimeException) = 0;
+ virtual css::uno::Any SAL_CALL getMergeCells( ) throw (css::script::BasicErrorException, css::uno::RuntimeException) = 0;
+ virtual void SAL_CALL setReadingOrder( const css::uno::Any& ReadingOrder ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+ virtual css::uno::Any SAL_CALL getReadingOrder( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);;
+*/
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_AXIS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbastyles.cxx b/sc/source/ui/vba/vbastyles.cxx
new file mode 100644
index 000000000000..1ffc2af27997
--- /dev/null
+++ b/sc/source/ui/vba/vbastyles.cxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbastyles.hxx"
+#include "vbastyle.hxx"
+#include <ooo/vba/excel/XRange.hpp>
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+static rtl::OUString SDEFAULTCELLSTYLENAME( RTL_CONSTASCII_USTRINGPARAM("Default") );
+css::uno::Any
+lcl_createAPIStyleToVBAObject( const css::uno::Any& aObject, const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< beans::XPropertySet > xStyleProps( aObject, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XStyle > xStyle( new ScVbaStyle( xParent, xContext, xStyleProps, xModel ) );
+ return uno::makeAny( xStyle );
+}
+
+
+ScVbaStyles::ScVbaStyles( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext > & xContext, const uno::Reference< frame::XModel >& xModel ) throw ( script::BasicErrorException ) : ScVbaStyles_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( ScVbaStyle::getStylesNameContainer( xModel ), uno::UNO_QUERY_THROW ) ), mxModel( xModel ), mxParent( xParent )
+{
+ try
+ {
+ mxMSF.set( mxModel, uno::UNO_QUERY_THROW );
+ mxNameContainerCellStyles.set( m_xNameAccess, uno::UNO_QUERY_THROW );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaStyles::getStyleNames() throw ( uno::RuntimeException )
+{
+ return mxNameContainerCellStyles->getElementNames();
+}
+
+
+uno::Any
+ScVbaStyles::createCollectionObject(const uno::Any& aObject)
+{
+ return lcl_createAPIStyleToVBAObject( aObject, mxParent, mxContext, mxModel );
+}
+
+uno::Type SAL_CALL
+ScVbaStyles::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XStyle::static_type(0);
+}
+
+class EnumWrapper : public EnumerationHelper_BASE
+{
+ uno::Reference<container::XIndexAccess > m_xIndexAccess;
+ uno::Reference<XHelperInterface > m_xParent;
+ uno::Reference<uno::XComponentContext > m_xContext;
+ uno::Reference<frame::XModel > m_xModel;
+
+ sal_Int32 nIndex;
+public:
+ EnumWrapper( const uno::Reference< container::XIndexAccess >& xIndexAccess, const uno::Reference<XHelperInterface >& xParent, const uno::Reference<uno::XComponentContext >& xContext, const uno::Reference<frame::XModel >& xModel ) : m_xIndexAccess( xIndexAccess ), m_xParent( xParent ), m_xContext( xContext ), m_xModel( xModel ), nIndex( 0 ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( nIndex < m_xIndexAccess->getCount() );
+ }
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( nIndex < m_xIndexAccess->getCount() )
+ return lcl_createAPIStyleToVBAObject( m_xIndexAccess->getByIndex( nIndex++ ), m_xParent, m_xContext, m_xModel );
+ throw container::NoSuchElementException();
+ }
+};
+
+uno::Reference< container::XEnumeration > SAL_CALL
+ScVbaStyles::createEnumeration() throw (uno::RuntimeException)
+{
+ return new EnumWrapper( m_xIndexAccess, mxParent, mxContext, mxModel );
+}
+
+uno::Reference< excel::XStyle > SAL_CALL
+ScVbaStyles::Add( const ::rtl::OUString& _sName, const uno::Any& _aBasedOn ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< excel::XStyle > aRet;
+ try
+ {
+ rtl::OUString sParentCellStyleName( RTL_CONSTASCII_USTRINGPARAM("Default"));
+ if ( _aBasedOn.hasValue() )
+ {
+ uno::Reference< excel::XRange > oRange;
+ if ( _aBasedOn >>= oRange)
+ {
+ uno::Reference< excel::XStyle > oStyle( oRange->getStyle(), uno::UNO_QUERY_THROW );
+ if ( oStyle.is() )
+ {
+ sParentCellStyleName = oStyle->getName();
+ }
+ else
+ {
+ DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString() );
+ }
+ }
+ else
+ {
+ DebugHelper::exception(SbERR_BAD_ARGUMENT, rtl::OUString());
+ }
+ }
+
+ uno::Reference< style::XStyle > xStyle( mxMSF->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.style.CellStyle"))), uno::UNO_QUERY_THROW );
+
+ if (!mxNameContainerCellStyles->hasByName(_sName))
+ {
+ mxNameContainerCellStyles->insertByName(_sName, uno::makeAny( xStyle) );
+ }
+ if (!sParentCellStyleName.equals(SDEFAULTCELLSTYLENAME))
+ {
+ xStyle->setParentStyle( sParentCellStyleName );
+ }
+ aRet.set( Item( uno::makeAny( _sName ), uno::Any() ), uno::UNO_QUERY_THROW );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+ return aRet;
+}
+
+void
+ScVbaStyles::Delete(const rtl::OUString _sStyleName) throw ( script::BasicErrorException )
+{
+ try
+ {
+ if (mxNameContainerCellStyles->hasByName( _sStyleName ) )
+ mxNameContainerCellStyles->removeByName( _sStyleName );
+ }
+ catch (uno::Exception& )
+ {
+ DebugHelper::exception(SbERR_METHOD_FAILED, rtl::OUString());
+ }
+}
+
+rtl::OUString&
+ScVbaStyles::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaStyles") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaStyles::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XStyles" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbastyles.hxx b/sc/source/ui/vba/vbastyles.hxx
new file mode 100644
index 000000000000..b9677954463f
--- /dev/null
+++ b/sc/source/ui/vba/vbastyles.hxx
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_STYLES_HXX
+#define SC_VBA_STYLES_HXX
+#include <ooo/vba/excel/XStyles.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <vbahelper/vbacollectionimpl.hxx>
+
+typedef CollTestImplHelper< ov::excel::XStyles > ScVbaStyles_BASE;
+class ScVbaStyles: public ScVbaStyles_BASE
+{
+ css::uno::Reference< css::frame::XModel > mxModel;
+ // hard ref to parent ( perhaps we should try this in the
+ // XHelperInterface itself
+ css::uno::Reference< ov::XHelperInterface > mxParent;
+ css::uno::Reference< css::lang::XMultiServiceFactory > mxMSF;
+ css::uno::Reference< css::container::XNameContainer > mxNameContainerCellStyles;
+public:
+ ScVbaStyles( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::script::BasicErrorException );
+ css::uno::Sequence< rtl::OUString > getStyleNames() throw ( css::uno::RuntimeException );
+ void Delete(const rtl::OUString _sStyleName) throw ( css::script::BasicErrorException );
+ // XStyles
+ virtual css::uno::Reference< ov::excel::XStyle > SAL_CALL Add( const ::rtl::OUString& Name, const css::uno::Any& BasedOn ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject(const css::uno::Any&);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbatextboxshape.cxx b/sc/source/ui/vba/vbatextboxshape.cxx
new file mode 100644
index 000000000000..558d33111cd4
--- /dev/null
+++ b/sc/source/ui/vba/vbatextboxshape.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "vbatextboxshape.hxx"
+#include "vbacharacters.hxx"
+#include <com/sun/star/text/XSimpleText.hpp>
+#include <vector>
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+ScVbaTextBoxShape::ScVbaTextBoxShape( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< drawing::XShape >& xShape, const uno::Reference< drawing::XShapes >& xShapes, const uno::Reference< frame::XModel >& xModel ) : TextBoxShapeImpl_BASE( uno::Reference< XHelperInterface >(), xContext, xShape, xShapes, xModel, ScVbaShape::getType( xShape ) )
+{
+ m_xTextRange.set( xShape , uno::UNO_QUERY_THROW );
+ m_xModel.set( xModel );
+}
+
+rtl::OUString SAL_CALL
+ScVbaTextBoxShape::getText() throw (css::uno::RuntimeException)
+{
+ return m_xTextRange->getString();
+}
+
+void SAL_CALL
+ScVbaTextBoxShape::setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException)
+{
+ m_xTextRange->setString( _text );
+}
+
+uno::Reference< excel::XCharacters > SAL_CALL
+ScVbaTextBoxShape::characters( const uno::Any& Start, const uno::Any& Length ) throw (uno::RuntimeException)
+{
+ ScDocShell* pDocShell = excel::getDocShell( m_xModel );
+ ScDocument* pDoc = pDocShell ? pDocShell->GetDocument() : NULL;
+
+ if ( !pDoc )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access document from shell" ) ), uno::Reference< uno::XInterface >() );
+ uno::Reference< text::XSimpleText > xSimple( m_xTextRange, uno::UNO_QUERY_THROW );
+
+ ScVbaPalette aPalette( pDoc->GetDocumentShell() );
+ return new ScVbaCharacters( this, mxContext, aPalette, xSimple, Start, Length, sal_True );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbatextboxshape.hxx b/sc/source/ui/vba/vbatextboxshape.hxx
new file mode 100644
index 000000000000..0947bea6868c
--- /dev/null
+++ b/sc/source/ui/vba/vbatextboxshape.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_TEXTBOX_HXX
+#define SC_VBA_TEXTBOX_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/text/XTextRange.hpp>
+#include <ooo/vba/msforms/XTextBoxShape.hpp>
+#include <vbahelper/vbashape.hxx>
+#include "excelvbahelper.hxx"
+#include "vbacharacters.hxx"
+
+typedef cppu::ImplInheritanceHelper1< ScVbaShape, ov::msforms::XTextBoxShape > TextBoxShapeImpl_BASE;
+
+class ScVbaTextBoxShape : public TextBoxShapeImpl_BASE
+{
+ css::uno::Reference< css::text::XTextRange > m_xTextRange;
+ css::uno::Reference< css::frame::XModel > m_xModel;
+public:
+ ScVbaTextBoxShape( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& xShape, const css::uno::Reference< css::drawing::XShapes >& xShapes, const css::uno::Reference< css::frame::XModel >& xModel );
+
+ // Attributes
+ virtual rtl::OUString SAL_CALL getText() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setText( const rtl::OUString& _text ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XCharacters > SAL_CALL characters( const css::uno::Any& Start, const css::uno::Any& Length ) throw (css::uno::RuntimeException);
+};
+#endif //SC_VBA_TEXTBOX_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbatextframe.cxx b/sc/source/ui/vba/vbatextframe.cxx
new file mode 100644
index 000000000000..c00af2d94775
--- /dev/null
+++ b/sc/source/ui/vba/vbatextframe.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+#include <com/sun/star/drawing/TextFitToSizeType.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include "vbatextframe.hxx"
+#include "vbacharacters.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+ScVbaTextFrame::ScVbaTextFrame( uno::Sequence< uno::Any> const & args, uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : ScVbaTextFrame_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext, getXSomethingFromArgs< drawing::XShape >( args, 1, false ) )
+{
+}
+
+// Methods
+uno::Any SAL_CALL
+ScVbaTextFrame::Characters() throw (uno::RuntimeException)
+{
+ uno::Reference< text::XSimpleText > xSimpleText( m_xShape, uno::UNO_QUERY_THROW );
+ ScVbaPalette aPalette( SfxObjectShell::Current() );
+ uno::Any aStart( sal_Int32( 1 ) );
+ uno::Any aLength(sal_Int32( -1 ) );
+ return uno::makeAny( uno::Reference< ov::excel::XCharacters >( new ScVbaCharacters( this, mxContext, aPalette, xSimpleText, aStart, aLength, sal_True ) ) );
+}
+
+rtl::OUString&
+ScVbaTextFrame::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaTextFrame") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaTextFrame::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.TextFrame" ) );
+ }
+ return aServiceNames;
+}
+
+namespace textframe
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaTextFrame, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaTextFrame",
+ "ooo.vba.excel.TextFrame" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbatextframe.hxx b/sc/source/ui/vba/vbatextframe.hxx
new file mode 100644
index 000000000000..7e2b6b81ee88
--- /dev/null
+++ b/sc/source/ui/vba/vbatextframe.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_TEXTFRAME_HXX
+#define SC_VBA_TEXTFRAME_HXX
+#include <ooo/vba/excel/XTextFrame.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbatextframe.hxx>
+
+//typedef InheritedHelperInterfaceImpl1< ov::excel::XTextFrame > ScVbaTextFrame_BASE;
+typedef cppu::ImplInheritanceHelper1< VbaTextFrame, ov::excel::XTextFrame > ScVbaTextFrame_BASE;
+
+class ScVbaTextFrame : public ScVbaTextFrame_BASE
+{
+public:
+ ScVbaTextFrame( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext ) throw ( css::lang::IllegalArgumentException );
+ virtual ~ScVbaTextFrame() {}
+ // Methods
+ virtual css::uno::Any SAL_CALL Characters( ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+
+#endif//SC_VBA_TEXTFRAME_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbatitle.hxx b/sc/source/ui/vba/vbatitle.hxx
new file mode 100644
index 000000000000..5e1594b8786c
--- /dev/null
+++ b/sc/source/ui/vba/vbatitle.hxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_TITLE_HXX
+#define SC_VBA_TITLE_HXX
+
+#include <vbahelper/vbahelperinterface.hxx>
+#include "excelvbahelper.hxx"
+#include "vbainterior.hxx"
+#include "vbafont.hxx"
+#include "vbapalette.hxx"
+#include <com/sun/star/drawing/XShape.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/excel/XTitle.hpp>
+#include <ooo/vba/excel/XCharacters.hpp>
+#include <basic/sberrors.hxx>
+#include <memory>
+
+template< typename Ifc1 >
+class TitleImpl : public InheritedHelperInterfaceImpl< Ifc1 >
+{
+typedef InheritedHelperInterfaceImpl< Ifc1 > BaseClass;
+
+protected:
+ css::uno::Reference< css::drawing::XShape > xTitleShape;
+ css::uno::Reference< css::beans::XPropertySet > xShapePropertySet;
+ std::auto_ptr<ov::ShapeHelper> oShapeHelper;
+ ScVbaPalette m_Palette;
+public:
+ TitleImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::drawing::XShape >& _xTitleShape ) : BaseClass( xParent, xContext ), xTitleShape( _xTitleShape )
+ {
+ xShapePropertySet.set( xTitleShape, css::uno::UNO_QUERY_THROW );
+ oShapeHelper.reset( new ov::ShapeHelper(xTitleShape) );
+ }
+ css::uno::Reference< ov::excel::XInterior > SAL_CALL Interior( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ // #TODO find out what the proper parent should be
+ // leaving as set by the helperapi for the moment
+ // #TODO we really need the ScDocument to pass to ScVbaInterior
+ // otherwise attemps to access the palette will fail
+ return new ScVbaInterior( BaseClass::mxParent, BaseClass::mxContext, xShapePropertySet );
+ }
+ css::uno::Reference< ov::excel::XFont > SAL_CALL Font( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ // #TODO find out what the proper parent should be
+ // leaving as set by the helperapi for the moment
+ return new ScVbaFont( BaseClass::mxParent, BaseClass::mxContext, m_Palette, xShapePropertySet );
+
+ }
+ void SAL_CALL setText( const ::rtl::OUString& Text ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ try
+ {
+ xShapePropertySet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("String") ), css::uno::makeAny( Text ));
+ }
+ catch ( css::uno::Exception& )
+ {
+ throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ }
+ ::rtl::OUString SAL_CALL getText( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ ::rtl::OUString sText;
+ try
+ {
+ xShapePropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("String") ) ) >>= sText;
+ }
+ catch ( css::uno::Exception& )
+ {
+ throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return sText;
+ }
+
+ css::uno::Reference< ov::excel::XCharacters > SAL_CALL Characters( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ // #FIXME #TODO the helperapi Characters implementation doesn't
+ // seem to do very much, need to know how the existing Characters
+ // impl ( that we use for Range ) can be reused
+ return css::uno::Reference< ov::excel::XCharacters > ();
+ }
+
+ void SAL_CALL setTop( double Top ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ oShapeHelper->setTop( Top );
+ }
+ double SAL_CALL getTop( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ return oShapeHelper->getTop();
+ }
+ void SAL_CALL setLeft( double Left ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ oShapeHelper->setLeft( Left );
+ }
+ double SAL_CALL getLeft( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ return oShapeHelper->getLeft();
+ }
+ void SAL_CALL setOrientation( ::sal_Int32 _nOrientation ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ try
+ {
+ xShapePropertySet->setPropertyValue(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextRotation")), css::uno::makeAny(_nOrientation*100));
+ }
+ catch (css::uno::Exception& )
+ {
+ throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ }
+ ::sal_Int32 SAL_CALL getOrientation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+ {
+ sal_Int32 nSOOrientation = 0;
+ try
+ {
+ xShapePropertySet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TextRotation"))) >>= nSOOrientation;
+ }
+ catch (css::uno::Exception& )
+ {
+ throw css::script::BasicErrorException( rtl::OUString(), css::uno::Reference< css::uno::XInterface >(), SbERR_METHOD_FAILED, rtl::OUString() );
+ }
+ return static_cast< sal_Int32 >(nSOOrientation / 100) ;
+ }
+// XHelperInterface
+ rtl::OUString& getServiceImplName()
+ {
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("TitleImpl") );
+ return sImplName;
+ }
+ css::uno::Sequence< rtl::OUString > getServiceNames()
+ {
+ static css::uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.XTitle" ) );
+ }
+ return aServiceNames;
+ }
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbavalidation.cxx b/sc/source/ui/vba/vbavalidation.cxx
new file mode 100644
index 000000000000..229e8f41c5cd
--- /dev/null
+++ b/sc/source/ui/vba/vbavalidation.cxx
@@ -0,0 +1,346 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbavalidation.hxx"
+#include "vbaformatcondition.hxx"
+#include <com/sun/star/sheet/XSheetCondition.hpp>
+#include <com/sun/star/sheet/ValidationType.hpp>
+#include <com/sun/star/sheet/ValidationAlertStyle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/excel/XlDVType.hpp>
+#include <ooo/vba/excel/XlFormatConditionOperator.hpp>
+#include <ooo/vba/excel/XlDVAlertStyle.hpp>
+
+#include "unonames.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+const static rtl::OUString VALIDATION( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_VALIDAT ) );
+const static rtl::OUString IGNOREBLANK( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_IGNOREBL ) );
+const static rtl::OUString SHOWINPUT( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHOWINP ) );
+const static rtl::OUString SHOWERROR( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHOWERR ) );
+const static rtl::OUString ERRORTITLE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ERRTITLE ) );
+const static rtl::OUString INPUTTITLE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_INPTITLE ) );
+const static rtl::OUString INPUTMESS( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_INPMESS ) );
+const static rtl::OUString ERRORMESS( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ERRMESS ) );
+const static rtl::OUString STYPE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_TYPE ) );
+const static rtl::OUString SHOWLIST( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_SHOWLIST ) );
+const static rtl::OUString ALERTSTYLE( RTL_CONSTASCII_USTRINGPARAM( SC_UNONAME_ERRALSTY ) );
+
+void
+lcl_setValidationProps( const uno::Reference< table::XCellRange >& xRange, const uno::Reference< beans::XPropertySet >& xProps )
+{
+ uno::Reference< beans::XPropertySet > xRangeProps( xRange, uno::UNO_QUERY_THROW );
+ xRangeProps->setPropertyValue( VALIDATION , uno::makeAny( xProps ) );
+}
+
+uno::Reference< beans::XPropertySet >
+lcl_getValidationProps( const uno::Reference< table::XCellRange >& xRange )
+{
+ uno::Reference< beans::XPropertySet > xProps( xRange, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xValProps;
+ xValProps.set( xProps->getPropertyValue( VALIDATION ), uno::UNO_QUERY_THROW );
+ return xValProps;
+}
+
+::sal_Bool SAL_CALL
+ScVbaValidation::getIgnoreBlank() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ sal_Bool bBlank = sal_False;
+ xProps->getPropertyValue( IGNOREBLANK ) >>= bBlank;
+ return bBlank;
+}
+
+void SAL_CALL
+ScVbaValidation::setIgnoreBlank( ::sal_Bool _ignoreblank ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ xProps->setPropertyValue( IGNOREBLANK, uno::makeAny( _ignoreblank ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::sal_Bool SAL_CALL
+ScVbaValidation::getInCellDropdown() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ sal_Int32 nShowList = 0;
+ xProps->getPropertyValue( SHOWLIST ) >>= nShowList;
+ return ( nShowList ? sal_True : sal_False );
+}
+
+void SAL_CALL
+ScVbaValidation::setInCellDropdown( ::sal_Bool _incelldropdown ) throw (uno::RuntimeException)
+{
+ sal_Int32 nDropDown = sal_False;
+ if ( _incelldropdown )
+ nDropDown = 1;
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps(m_xRange) );
+ xProps->setPropertyValue( SHOWLIST, uno::makeAny( nDropDown ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::sal_Bool SAL_CALL
+ScVbaValidation::getShowInput() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ sal_Bool bShowInput = sal_False;
+ xProps->getPropertyValue( SHOWINPUT ) >>= bShowInput;
+ return bShowInput;
+}
+
+void SAL_CALL
+ScVbaValidation:: setShowInput( ::sal_Bool _showinput ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps(m_xRange) );
+ xProps->setPropertyValue( IGNOREBLANK, uno::makeAny( _showinput ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::sal_Bool SAL_CALL
+ScVbaValidation::getShowError() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ sal_Bool bShowError = sal_False;
+ xProps->getPropertyValue( SHOWERROR ) >>= bShowError;
+ return bShowError;
+}
+
+void SAL_CALL
+ScVbaValidation::setShowError( ::sal_Bool _showerror ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ xProps->setPropertyValue( SHOWERROR, uno::makeAny( _showerror ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaValidation::getErrorTitle() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ rtl::OUString sErrorTitle;
+ xProps->getPropertyValue( ERRORTITLE ) >>= sErrorTitle;
+ return sErrorTitle;
+}
+
+void
+ScVbaValidation::setErrorTitle( const rtl::OUString& _errormessage ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ xProps->setPropertyValue( ERRORTITLE, uno::makeAny( _errormessage ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaValidation::getInputMessage() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ rtl::OUString sMsg;
+ xProps->getPropertyValue( INPUTMESS ) >>= sMsg;
+ return sMsg;
+}
+
+void SAL_CALL
+ScVbaValidation::setInputMessage( const ::rtl::OUString& _inputmessage ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ xProps->setPropertyValue( INPUTMESS, uno::makeAny( _inputmessage ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaValidation::getInputTitle() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ rtl::OUString sString;
+ xProps->getPropertyValue( INPUTTITLE ) >>= sString;
+ return sString;
+}
+
+void SAL_CALL
+ScVbaValidation::setInputTitle( const ::rtl::OUString& _inputtitle ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ xProps->setPropertyValue( INPUTTITLE, uno::makeAny( _inputtitle ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaValidation::getErrorMessage() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps = lcl_getValidationProps( m_xRange );
+ rtl::OUString sString;
+ xProps->getPropertyValue( ERRORMESS ) >>= sString;
+ return sString;
+}
+
+void SAL_CALL
+ScVbaValidation::setErrorMessage( const ::rtl::OUString& _errormessage ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ xProps->setPropertyValue( ERRORMESS, uno::makeAny( _errormessage ) );
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+
+void SAL_CALL
+ScVbaValidation::Delete( ) throw (uno::RuntimeException)
+{
+ rtl::OUString sBlank;
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( IGNOREBLANK, uno::makeAny( sal_True ) );
+ xProps->setPropertyValue( SHOWINPUT, uno::makeAny( sal_True ) );
+ xProps->setPropertyValue( SHOWERROR, uno::makeAny( sal_True ) );
+ xProps->setPropertyValue( ERRORTITLE, uno::makeAny( sBlank ) );
+ xProps->setPropertyValue( INPUTMESS, uno::makeAny( sBlank) );
+ xProps->setPropertyValue( ALERTSTYLE, uno::makeAny( sheet::ValidationAlertStyle_STOP) );
+ xProps->setPropertyValue( STYPE, uno::makeAny( sheet::ValidationType_ANY ) );
+ xCond->setFormula1( sBlank );
+ xCond->setFormula2( sBlank );
+ xCond->setOperator( sheet::ConditionOperator_NONE );
+
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+// Fix the defect that validatation cannot work when the input should be limited between a lower bound and an upper bound
+void SAL_CALL
+ScVbaValidation::Add( const uno::Any& Type, const uno::Any& AlertStyle, const uno::Any& Operator, const uno::Any& Formula1, const uno::Any& Formula2 ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( lcl_getValidationProps( m_xRange ) );
+ uno::Reference< sheet::XSheetCondition > xCond( xProps, uno::UNO_QUERY_THROW );
+
+ sheet::ValidationType nValType = sheet::ValidationType_ANY;
+ xProps->getPropertyValue( STYPE ) >>= nValType;
+ if ( nValType != sheet::ValidationType_ANY )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "validation object already exists" ) ), uno::Reference< uno::XInterface >() );
+ sal_Int32 nType = -1;
+ if ( !Type.hasValue() || !( Type >>= nType ) )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "missing required param" ) ), uno::Reference< uno::XInterface >() );
+
+ Delete(); // set up defaults
+ rtl::OUString sFormula1;
+ Formula1 >>= sFormula1;
+ rtl::OUString sFormula2;
+ Formula2 >>= sFormula2;
+ switch ( nType )
+ {
+ case excel::XlDVType::xlValidateList:
+ {
+ // for validate list
+ // at least formula1 is required
+ if ( !Formula1.hasValue() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "missing param" ) ), uno::Reference< uno::XInterface >() );
+ nValType = sheet::ValidationType_LIST;
+ xProps->setPropertyValue( STYPE, uno::makeAny(nValType ));
+ // #TODO validate required params
+ // #TODO need to correct the ';' delimited formula on get/set
+ break;
+ }
+ case excel::XlDVType::xlValidateWholeNumber:
+ nValType = sheet::ValidationType_WHOLE;
+ xProps->setPropertyValue( STYPE, uno::makeAny(nValType ));
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "unsupported operation..." ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ sheet::ValidationAlertStyle eStyle = sheet::ValidationAlertStyle_STOP;
+ sal_Int32 nVbaAlertStyle = excel::XlDVAlertStyle::xlValidAlertStop;
+ if ( AlertStyle.hasValue() && ( AlertStyle >>= nVbaAlertStyle ) )
+ {
+ switch( nVbaAlertStyle )
+ {
+ case excel::XlDVAlertStyle::xlValidAlertStop:
+ // yes I know it's already defaulted but safer to assume
+ // someone propbably could change the code above
+ eStyle = sheet::ValidationAlertStyle_STOP;
+ break;
+ case excel::XlDVAlertStyle::xlValidAlertWarning:
+ eStyle = sheet::ValidationAlertStyle_WARNING;
+ break;
+ case excel::XlDVAlertStyle::xlValidAlertInformation:
+ eStyle = sheet::ValidationAlertStyle_INFO;
+ break;
+ default:
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "bad param..." ) ), uno::Reference< uno::XInterface >() );
+
+ }
+ }
+
+ xProps->setPropertyValue( ALERTSTYLE, uno::makeAny( eStyle ) );
+
+ //2009-11-11 fix the defect that validatation cannot work when the input should be limited between a lower bound and an upper bound
+ if ( Operator.hasValue() )
+ {
+ css::sheet::ConditionOperator conOperator = ScVbaFormatCondition::retrieveAPIOperator( Operator );
+ xCond->setOperator( conOperator );
+ }
+ //2009-11-11
+ if ( sFormula1.getLength() )
+ xCond->setFormula1( sFormula1 );
+ if ( sFormula2.getLength() )
+ xCond->setFormula2( sFormula2 );
+
+ lcl_setValidationProps( m_xRange, xProps );
+}
+
+::rtl::OUString SAL_CALL
+ScVbaValidation::getFormula1() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCondition > xCond( lcl_getValidationProps( m_xRange ), uno::UNO_QUERY_THROW );
+ return xCond->getFormula1();
+}
+
+::rtl::OUString SAL_CALL
+ScVbaValidation::getFormula2() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCondition > xCond( lcl_getValidationProps( m_xRange ), uno::UNO_QUERY_THROW );
+ return xCond->getFormula2();
+}
+
+rtl::OUString&
+ScVbaValidation::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaValidation") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaValidation::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Validation" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbavalidation.hxx b/sc/source/ui/vba/vbavalidation.hxx
new file mode 100644
index 000000000000..6ede46176544
--- /dev/null
+++ b/sc/source/ui/vba/vbavalidation.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_VALIDATION_HXX
+#define SC_VBA_VALIDATION_HXX
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <ooo/vba/excel/XValidation.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+
+typedef InheritedHelperInterfaceImpl1<ov::excel::XValidation > ValidationImpl_BASE;
+
+class ScVbaValidation : public ValidationImpl_BASE
+{
+ css::uno::Reference< css::table::XCellRange > m_xRange;
+
+public:
+ ScVbaValidation( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::table::XCellRange >& xRange ) : ValidationImpl_BASE( xParent, xContext ), m_xRange( xRange) {}
+ // Attributes
+ virtual ::sal_Bool SAL_CALL getIgnoreBlank() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setIgnoreBlank( ::sal_Bool _ignoreblank ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getInCellDropdown() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setInCellDropdown( ::sal_Bool _incelldropdown ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getShowInput() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setShowInput( ::sal_Bool _showinput ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getShowError() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setShowError( ::sal_Bool _showerror ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getInputTitle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setInputTitle( const ::rtl::OUString& _inputtitle ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getErrorTitle() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setErrorTitle( const ::rtl::OUString& _errortitle ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getInputMessage() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setInputMessage( const ::rtl::OUString& _inputmessage ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getErrorMessage() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setErrorMessage( const ::rtl::OUString& _errormessage ) throw (css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getFormula1() throw (css::uno::RuntimeException) ;
+ virtual ::rtl::OUString SAL_CALL getFormula2() throw (css::uno::RuntimeException);
+ // Methods
+ virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Add( const css::uno::Any& Type, const css::uno::Any& AlertStyle, const css::uno::Any& Operator, const css::uno::Any& Formula1, const css::uno::Any& Formula2 ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbawindow.cxx b/sc/source/ui/vba/vbawindow.cxx
new file mode 100644
index 000000000000..625666b236b9
--- /dev/null
+++ b/sc/source/ui/vba/vbawindow.cxx
@@ -0,0 +1,861 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+#include "vbawindow.hxx"
+#include "vbaworksheets.hxx"
+#include "vbaworksheet.hxx"
+#include "vbaglobals.hxx"
+#include "vbapane.hxx"
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/view/DocumentZoomType.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <ooo/vba/excel/XlWindowState.hpp>
+#include <ooo/vba/excel/XlWindowView.hpp>
+#include <ooo/vba/excel/Constants.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindow2.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+
+#include <docsh.hxx>
+#include <tabvwsh.hxx>
+#include <docuno.hxx>
+#include <sc.hrc>
+#include <hash_map>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/wrkwin.hxx>
+#include "unonames.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+using namespace ::ooo::vba::excel::XlWindowState;
+
+typedef std::hash_map< rtl::OUString,
+SCTAB, ::rtl::OUStringHash,
+::std::equal_to< ::rtl::OUString > > NameIndexHash;
+
+typedef std::vector < uno::Reference< sheet::XSpreadsheet > > Sheets;
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration
+
+> Enumeration_BASE;
+
+typedef ::cppu::WeakImplHelper3< container::XEnumerationAccess
+ , com::sun::star::container::XIndexAccess
+ , com::sun::star::container::XNameAccess
+ > SelectedSheets_BASE;
+
+
+class SelectedSheetsEnum : public Enumeration_BASE
+{
+public:
+ uno::Reference< uno::XComponentContext > m_xContext;
+ Sheets m_sheets;
+ uno::Reference< frame::XModel > m_xModel;
+ Sheets::const_iterator m_it;
+
+ SelectedSheetsEnum( const uno::Reference< uno::XComponentContext >& xContext, const Sheets& sheets, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : m_xContext( xContext ), m_sheets( sheets ), m_xModel( xModel )
+ {
+ m_it = m_sheets.begin();
+ }
+ // XEnumeration
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return m_it != m_sheets.end();
+ }
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ {
+ throw container::NoSuchElementException();
+ }
+ // #FIXME needs ThisWorkbook as parent
+ return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( uno::Reference< XHelperInterface >(), m_xContext, *(m_it++), m_xModel ) ) );
+ }
+
+
+};
+
+class SelectedSheetsEnumAccess : public SelectedSheets_BASE
+{
+ uno::Reference< uno::XComponentContext > m_xContext;
+ NameIndexHash namesToIndices;
+ Sheets sheets;
+ uno::Reference< frame::XModel > m_xModel;
+public:
+ SelectedSheetsEnumAccess( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ):m_xContext( xContext ), m_xModel( xModel )
+ {
+ ScModelObj* pModel = static_cast< ScModelObj* >( m_xModel.get() );
+ if ( !pModel )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain current document" ) ), uno::Reference< uno::XInterface >() );
+ ScDocShell* pDocShell = (ScDocShell*)pModel->GetEmbeddedObject();
+ if ( !pDocShell )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain docshell" ) ), uno::Reference< uno::XInterface >() );
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( !pViewShell )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain view shell" ) ), uno::Reference< uno::XInterface >() );
+
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
+ uno::Sequence<sal_Int32> aSheets( nTabCount );
+ SCTAB nIndex = 0;
+ const ScMarkData& rMarkData = pViewShell->GetViewData()->GetMarkData();
+ sheets.reserve( nTabCount );
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadSheet( m_xModel, uno::UNO_QUERY_THROW );
+ uno::Reference <container::XIndexAccess> xIndex( xSpreadSheet->getSheets(), uno::UNO_QUERY_THROW );
+ for ( SCTAB nTab=0; nTab<nTabCount; nTab++ )
+ {
+ if ( rMarkData.GetTableSelect(nTab) )
+ {
+ uno::Reference< sheet::XSpreadsheet > xSheet( xIndex->getByIndex( nTab ), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
+ sheets.push_back( xSheet );
+ namesToIndices[ xNamed->getName() ] = nIndex++;
+ }
+ }
+
+ }
+
+ //XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new SelectedSheetsEnum( m_xContext, sheets, m_xModel );
+ }
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return sheets.size();
+ }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw ( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0
+ || static_cast< Sheets::size_type >( Index ) >= sheets.size() )
+ throw lang::IndexOutOfBoundsException();
+
+ return uno::makeAny( sheets[ Index ] );
+ }
+
+ //XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return excel::XWorksheet::static_type(0);
+ }
+
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return (sheets.size() > 0);
+ }
+
+ //XNameAccess
+ virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ NameIndexHash::const_iterator it = namesToIndices.find( aName );
+ if ( it == namesToIndices.end() )
+ throw container::NoSuchElementException();
+ return uno::makeAny( sheets[ it->second ] );
+
+ }
+
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
+ {
+ uno::Sequence< ::rtl::OUString > names( namesToIndices.size() );
+ ::rtl::OUString* pString = names.getArray();
+ NameIndexHash::const_iterator it = namesToIndices.begin();
+ NameIndexHash::const_iterator it_end = namesToIndices.end();
+ for ( ; it != it_end; ++it, ++pString )
+ *pString = it->first;
+ return names;
+ }
+
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+ NameIndexHash::const_iterator it = namesToIndices.find( aName );
+ return (it != namesToIndices.end());
+ }
+
+
+};
+
+ScVbaWindow::ScVbaWindow( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< frame::XModel >& xModel ) : WindowImpl_BASE( xParent, xContext, xModel )
+{
+ init();
+}
+
+ScVbaWindow::ScVbaWindow( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xContext )
+ : WindowImpl_BASE( args, xContext )
+{
+ init();
+}
+
+void
+ScVbaWindow::init()
+{
+ /* This method is called from the constructor, thus the own refcount is
+ still zero. The implementation of ActivePane() uses a UNO reference of
+ this (to set this window as parent of the pane obejct). This requires
+ the own refcount to be non-zero, otherwise this instance will be
+ desctructed immediately! */
+ osl_incrementInterlockedCount( &m_refCount );
+ uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ m_xViewPane.set( xController, uno::UNO_QUERY_THROW );
+ m_xViewFreezable.set( xController, uno::UNO_QUERY_THROW );
+ m_xViewSplitable.set( xController, uno::UNO_QUERY_THROW );
+ m_xPane.set( ActivePane(), uno::UNO_QUERY_THROW );
+ m_xDevice.set( xController->getFrame()->getComponentWindow(), uno::UNO_QUERY_THROW );
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+void
+ScVbaWindow::Scroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft, bool bLargeScroll ) throw (uno::RuntimeException)
+{
+ if( bLargeScroll )
+ m_xPane->LargeScroll( Down, Up, ToRight, ToLeft );
+ else
+ m_xPane->SmallScroll( Down, Up, ToRight, ToLeft );
+}
+
+void SAL_CALL
+ScVbaWindow::SmallScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
+{
+ Scroll( Down, Up, ToRight, ToLeft );
+}
+
+void SAL_CALL
+ScVbaWindow::LargeScroll( const uno::Any& Down, const uno::Any& Up, const uno::Any& ToRight, const uno::Any& ToLeft ) throw (uno::RuntimeException)
+{
+ Scroll( Down, Up, ToRight, ToLeft, true );
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::SelectedSheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( new SelectedSheetsEnumAccess( mxContext, m_xModel ) );
+ // #FIXME needs a workbook as a parent
+ uno::Reference< excel::XWorksheets > xSheets( new ScVbaWorksheets( uno::Reference< XHelperInterface >(), mxContext, xEnumAccess, m_xModel ) );
+ if ( aIndex.hasValue() )
+ {
+ uno::Reference< XCollection > xColl( xSheets, uno::UNO_QUERY_THROW );
+ return xColl->Item( aIndex, uno::Any() );
+ }
+ return uno::makeAny( xSheets );
+}
+
+void SAL_CALL
+ScVbaWindow::ScrollWorkbookTabs( const uno::Any& /*Sheets*/, const uno::Any& /*Position*/ ) throw (uno::RuntimeException)
+{
+// #TODO #FIXME need some implementation to scroll through the tabs
+// but where is this done?
+/*
+ sal_Int32 nSheets = 0;
+ sal_Int32 nPosition = 0;
+ throw uno::RuntimeException( rtl::OUString::createFromAscii("No Implemented" ), uno::Reference< uno::XInterface >() );
+ sal_Bool bSheets = ( Sheets >>= nSheets );
+ sal_Bool bPosition = ( Position >>= nPosition );
+ if ( bSheets || bPosition ) // at least one param specified
+ if ( bSheets )
+ ;// use sheets
+ else if ( bPosition )
+ ; //use position
+*/
+
+}
+uno::Reference< beans::XPropertySet >
+getPropsFromModel( const uno::Reference< frame::XModel >& xModel )
+{
+ uno::Reference< frame::XController > xController = xModel->getCurrentController();
+ if ( !xController.is() )
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM ("No controller for model") ), uno::Reference< uno::XInterface >() );
+ return uno::Reference< beans::XPropertySet >( xController->getFrame(), uno::UNO_QUERY );
+}
+
+
+uno::Any SAL_CALL
+ScVbaWindow::getCaption() throw (uno::RuntimeException)
+{
+ static rtl::OUString sCrud(RTL_CONSTASCII_USTRINGPARAM(" - OpenOffice.org Calc" ) );
+ static sal_Int32 nCrudLen = sCrud.getLength();
+
+ uno::Reference< beans::XPropertySet > xProps = getPropsFromModel( m_xModel );
+ rtl::OUString sTitle;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( SC_UNONAME_TITLE ) ) ) >>= sTitle;
+ sal_Int32 nCrudIndex = sTitle.indexOf( sCrud );
+ // adjust title ( by removing crud )
+ // sCrud string present
+ if ( nCrudIndex != -1 )
+ {
+ // and ends with sCrud
+ if ( ( nCrudLen + nCrudIndex ) == sTitle.getLength() )
+ {
+ sTitle = sTitle.copy( 0, nCrudIndex );
+ ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+ rtl::OUString sName = workbook.getName();
+ // rather bizare hack to make sure the name behavior
+ // is like XL
+ // if the adjusted title == workbook name, use name
+ // if the adjusted title != workbook name but ...
+ // name == title + extension ( .csv, ,odt, .xls )
+ // etc. then also use the name
+
+ if ( !sTitle.equals( sName ) )
+ {
+ static rtl::OUString sDot( RTL_CONSTASCII_USTRINGPARAM(".") );
+ // starts with title
+ if ( sName.indexOf( sTitle ) == 0 )
+ // extention starts immediately after
+ if ( sName.match( sDot, sTitle.getLength() ) )
+ sTitle = sName;
+ }
+ }
+ }
+ return uno::makeAny( sTitle );
+}
+
+void SAL_CALL
+ScVbaWindow::setCaption( const uno::Any& _caption ) throw (uno::RuntimeException)
+{
+
+ uno::Reference< beans::XPropertySet > xProps = getPropsFromModel( m_xModel );
+ xProps->setPropertyValue( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM ( SC_UNONAME_TITLE ) ) , _caption );
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::getScrollRow() throw (uno::RuntimeException)
+{
+ sal_Int32 nValue = 0;
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( pViewShell )
+ {
+ ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
+ nValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich));
+ }
+
+ return uno::makeAny( nValue + 1);
+}
+
+void SAL_CALL
+ScVbaWindow::setScrollRow( const uno::Any& _scrollrow ) throw (uno::RuntimeException)
+{
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( pViewShell )
+ {
+ sal_Int32 scrollRow = 0;
+ _scrollrow >>= scrollRow;
+ ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
+ sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosY(WhichV(eWhich)) + 1;
+ pViewShell->ScrollLines(0, scrollRow - nOldValue);
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::getScrollColumn() throw (uno::RuntimeException)
+{
+ sal_Int32 nValue = 0;
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( pViewShell )
+ {
+ ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
+ nValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich));
+ }
+
+ return uno::makeAny( nValue + 1);
+}
+
+void SAL_CALL
+ScVbaWindow::setScrollColumn( const uno::Any& _scrollcolumn ) throw (uno::RuntimeException)
+{
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( pViewShell )
+ {
+ sal_Int32 scrollColumn = 0;
+ _scrollcolumn >>= scrollColumn;
+ ScSplitPos eWhich = pViewShell->GetViewData()->GetActivePart();
+ sal_Int32 nOldValue = pViewShell->GetViewData()->GetPosX(WhichH(eWhich)) + 1;
+ pViewShell->ScrollLines(scrollColumn - nOldValue, 0);
+ }
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::getWindowState() throw (uno::RuntimeException)
+{
+ sal_Int32 nwindowState = xlNormal;
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
+ WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
+ if ( pWork )
+ {
+ if ( pWork -> IsMaximized())
+ nwindowState = xlMaximized;
+ else if (pWork -> IsMinimized())
+ nwindowState = xlMinimized;
+ }
+ return uno::makeAny( nwindowState );
+}
+
+void SAL_CALL
+ScVbaWindow::setWindowState( const uno::Any& _windowstate ) throw (uno::RuntimeException)
+{
+ sal_Int32 nwindowState = xlMaximized;
+ _windowstate >>= nwindowState;
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ SfxViewFrame* pViewFrame = pViewShell -> GetViewFrame();
+ WorkWindow* pWork = (WorkWindow*) pViewFrame->GetFrame().GetSystemWindow();
+ if ( pWork )
+ {
+ if ( nwindowState == xlMaximized)
+ pWork -> Maximize();
+ else if (nwindowState == xlMinimized)
+ pWork -> Minimize();
+ else if (nwindowState == xlNormal)
+ pWork -> Restore();
+ else
+ throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Invalid Parameter" ) ), uno::Reference< uno::XInterface >() );
+ }
+}
+
+void
+ScVbaWindow::Activate() throw (css::uno::RuntimeException)
+{
+ ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+
+ workbook.Activate();
+}
+
+void
+ScVbaWindow::Close( const uno::Any& SaveChanges, const uno::Any& FileName, const uno::Any& RouteWorkBook ) throw (uno::RuntimeException)
+{
+ ScVbaWorkbook workbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), mxContext, m_xModel );
+ workbook.Close(SaveChanges, FileName, RouteWorkBook );
+}
+
+uno::Reference< excel::XPane > SAL_CALL
+ScVbaWindow::ActivePane() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ return new ScVbaPane( this, mxContext, m_xModel, m_xViewPane );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaWindow::ActiveCell( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ return xApplication->getActiveCell();
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::Selection( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ return xApplication->getSelection();
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaWindow::RangeSelection() throw (script::BasicErrorException, uno::RuntimeException)
+{
+ /* TODO / FIXME: According to documentation, this method returns the range
+ selection even if shapes are selected. */
+ return uno::Reference< excel::XRange >( Selection(), uno::UNO_QUERY_THROW );
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getDisplayGridlines() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHOWGRID ) );
+ sal_Bool bGrid = sal_True;
+ xProps->getPropertyValue( sName ) >>= bGrid;
+ return bGrid;
+}
+
+
+void SAL_CALL
+ScVbaWindow::setDisplayGridlines( ::sal_Bool _displaygridlines ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHOWGRID ) );
+ xProps->setPropertyValue( sName, uno::makeAny( _displaygridlines ));
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getDisplayHeadings() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLROWHDR ) );
+ sal_Bool bHeading = sal_True;
+ xProps->getPropertyValue( sName ) >>= bHeading;
+ return bHeading;
+}
+
+void SAL_CALL
+ScVbaWindow::setDisplayHeadings( ::sal_Bool _bDisplayHeadings ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_COLROWHDR ) );
+ xProps->setPropertyValue( sName, uno::makeAny( _bDisplayHeadings ));
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getDisplayHorizontalScrollBar() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_HORSCROLL ) );
+ sal_Bool bHorizontalScrollBar = sal_True;
+ xProps->getPropertyValue( sName ) >>= bHorizontalScrollBar;
+ return bHorizontalScrollBar;
+}
+
+void SAL_CALL
+ScVbaWindow::setDisplayHorizontalScrollBar( ::sal_Bool _bDisplayHorizontalScrollBar ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_HORSCROLL ) );
+ xProps->setPropertyValue( sName, uno::makeAny( _bDisplayHorizontalScrollBar ));
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getDisplayOutline() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_OUTLSYMB ) );
+ sal_Bool bOutline = sal_True;
+ xProps->getPropertyValue( sName ) >>= bOutline;
+ return bOutline;
+}
+
+void SAL_CALL
+ScVbaWindow::setDisplayOutline( ::sal_Bool _bDisplayOutline ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_OUTLSYMB ) );
+ xProps->setPropertyValue( sName, uno::makeAny( _bDisplayOutline ));
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getDisplayVerticalScrollBar() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_VERTSCROLL ) );
+ sal_Bool bVerticalScrollBar = sal_True;
+ xProps->getPropertyValue( sName ) >>= bVerticalScrollBar;
+ return bVerticalScrollBar;
+}
+
+void SAL_CALL
+ScVbaWindow::setDisplayVerticalScrollBar( ::sal_Bool _bDisplayVerticalScrollBar ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_VERTSCROLL ) );
+ xProps->setPropertyValue( sName, uno::makeAny( _bDisplayVerticalScrollBar ));
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getDisplayWorkbookTabs() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHEETTABS ) );
+ sal_Bool bWorkbookTabs = sal_True;
+ xProps->getPropertyValue( sName ) >>= bWorkbookTabs;
+ return bWorkbookTabs;
+}
+
+void SAL_CALL
+ScVbaWindow::setDisplayWorkbookTabs( ::sal_Bool _bDisplayWorkbookTabs ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_SHEETTABS ) );
+ xProps->setPropertyValue( sName, uno::makeAny( _bDisplayWorkbookTabs ));
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getFreezePanes() throw (uno::RuntimeException)
+{
+ return m_xViewFreezable->hasFrozenPanes();
+}
+
+void SAL_CALL
+ScVbaWindow::setFreezePanes( ::sal_Bool /*_bFreezePanes*/ ) throw (uno::RuntimeException)
+{
+ if( m_xViewSplitable->getIsWindowSplit() )
+ {
+ // if there is a split we freeze at the split
+ sal_Int32 nColumn = getSplitColumn();
+ sal_Int32 nRow = getSplitRow();
+ m_xViewFreezable->freezeAtPosition( nColumn, nRow );
+ }
+ else
+ {
+ // otherwise we freeze in the center of the visible sheet
+ table::CellRangeAddress aCellRangeAddress = m_xViewPane->getVisibleRange();
+ sal_Int32 nColumn = aCellRangeAddress.StartColumn + (( aCellRangeAddress.EndColumn - aCellRangeAddress.StartColumn )/2 );
+ sal_Int32 nRow = aCellRangeAddress.StartRow + (( aCellRangeAddress.EndRow - aCellRangeAddress.StartRow )/2 );
+ m_xViewFreezable->freezeAtPosition( nColumn, nRow );
+ }
+}
+
+::sal_Bool SAL_CALL
+ScVbaWindow::getSplit() throw (uno::RuntimeException)
+{
+ return m_xViewSplitable->getIsWindowSplit();
+}
+
+void SAL_CALL
+ScVbaWindow::setSplit( ::sal_Bool _bSplit ) throw (uno::RuntimeException)
+{
+ if( !_bSplit )
+ {
+ m_xViewSplitable->splitAtPosition(0,0);
+ }
+ else
+ {
+ uno::Reference< excel::XRange > xRange = ActiveCell();
+ sal_Int32 nRow = xRange->getRow();
+ sal_Int32 nColumn = xRange->getColumn();
+ m_xViewFreezable->freezeAtPosition( nColumn-1, nRow-1 );
+ SplitAtDefinedPosition( sal_True );
+ }
+}
+
+sal_Int32 SAL_CALL
+ScVbaWindow::getSplitColumn() throw (uno::RuntimeException)
+{
+ return m_xViewSplitable->getSplitColumn();
+}
+
+void SAL_CALL
+ScVbaWindow::setSplitColumn( sal_Int32 _splitcolumn ) throw (uno::RuntimeException)
+{
+ if( getSplitColumn() != _splitcolumn )
+ {
+ sal_Bool bFrozen = getFreezePanes();
+ sal_Int32 nRow = getSplitRow();
+ m_xViewFreezable->freezeAtPosition( _splitcolumn, nRow );
+ SplitAtDefinedPosition( !bFrozen );
+ }
+}
+
+double SAL_CALL
+ScVbaWindow::getSplitHorizontal() throw (uno::RuntimeException)
+{
+ double fSplitHorizontal = m_xViewSplitable->getSplitHorizontal();
+ double fHoriPoints = PixelsToPoints( m_xDevice, fSplitHorizontal, sal_True );
+ return fHoriPoints;
+}
+
+void SAL_CALL
+ScVbaWindow::setSplitHorizontal( double _splithorizontal ) throw (uno::RuntimeException)
+{
+ double fHoriPixels = PointsToPixels( m_xDevice, _splithorizontal, sal_True );
+ m_xViewSplitable->splitAtPosition( static_cast<sal_Int32>( fHoriPixels ), 0 );
+}
+
+sal_Int32 SAL_CALL
+ScVbaWindow::getSplitRow() throw (uno::RuntimeException)
+{
+ sal_Int32 nValue = m_xViewSplitable->getSplitRow();
+ return nValue ? nValue - 1 : nValue;
+}
+
+void SAL_CALL
+ScVbaWindow::setSplitRow( sal_Int32 _splitrow ) throw (uno::RuntimeException)
+{
+ if( getSplitRow() != _splitrow )
+ {
+ sal_Bool bFrozen = getFreezePanes();
+ sal_Int32 nColumn = getSplitColumn();
+ m_xViewFreezable->freezeAtPosition( nColumn , _splitrow );
+ SplitAtDefinedPosition( !bFrozen );
+ }
+}
+
+double SAL_CALL
+ScVbaWindow::getSplitVertical() throw (uno::RuntimeException)
+{
+ double fSplitVertical = m_xViewSplitable->getSplitVertical();
+ double fVertiPoints = PixelsToPoints( m_xDevice, fSplitVertical, sal_False );
+ return fVertiPoints;
+}
+
+void SAL_CALL
+ScVbaWindow::setSplitVertical(double _splitvertical ) throw (uno::RuntimeException)
+{
+ double fVertiPixels = PointsToPixels( m_xDevice, _splitvertical, sal_False );
+ m_xViewSplitable->splitAtPosition( 0, static_cast<sal_Int32>( fVertiPixels ) );
+}
+
+void ScVbaWindow::SplitAtDefinedPosition(sal_Bool _bUnFreezePane)
+{
+ sal_Int32 nVertSplit = m_xViewSplitable->getSplitVertical();
+ sal_Int32 nHoriSplit = m_xViewSplitable->getSplitHorizontal();
+ if( _bUnFreezePane )
+ {
+ m_xViewFreezable->freezeAtPosition(0,0);
+ }
+ m_xViewSplitable->splitAtPosition(nHoriSplit, nVertSplit);
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::getZoom() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( m_xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ rtl::OUString sName( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_ZOOMTYPE ) );
+ sal_Int16 nZoomType = view::DocumentZoomType::PAGE_WIDTH;
+ xProps->getPropertyValue( sName ) >>= nZoomType;
+ if( nZoomType == view::DocumentZoomType::PAGE_WIDTH )
+ {
+ return uno::makeAny( sal_True );
+ }
+ else if( nZoomType == view::DocumentZoomType::BY_VALUE )
+ {
+ sName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(SC_UNO_ZOOMVALUE));
+ sal_Int16 nZoom = 100;
+ xProps->getPropertyValue( sName ) >>= nZoom;
+ return uno::makeAny( nZoom );
+ }
+ return uno::Any();
+}
+
+void SAL_CALL
+ScVbaWindow::setZoom( const uno::Any& _zoom ) throw (uno::RuntimeException)
+{
+ sal_Int16 nZoom = 100;
+ _zoom >>= nZoom;
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( m_xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XWorksheet > xActiveSheet = ActiveSheet();
+ SCTAB nTab = 0;
+ if ( !ScVbaWorksheets::nameExists (xSpreadDoc, xActiveSheet->getName(), nTab) )
+ throw uno::RuntimeException();
+ std::vector< SCTAB > vTabs;
+ vTabs.push_back( nTab );
+ excel::implSetZoom( m_xModel, nZoom, vTabs );
+}
+
+uno::Reference< excel::XWorksheet > SAL_CALL
+ScVbaWindow::ActiveSheet( ) throw (script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ return xApplication->getActiveSheet();
+}
+
+uno::Any SAL_CALL
+ScVbaWindow::getView() throw (uno::RuntimeException)
+{
+ // not supported now
+ sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
+ return uno::makeAny( nWindowView );
+}
+
+void SAL_CALL
+ScVbaWindow::setView( const uno::Any& _view) throw (uno::RuntimeException)
+{
+ sal_Int32 nWindowView = excel::XlWindowView::xlNormalView;
+ _view >>= nWindowView;
+ USHORT nSlot = FID_NORMALVIEWMODE;
+ switch ( nWindowView )
+ {
+ case excel::XlWindowView::xlNormalView:
+ nSlot = FID_NORMALVIEWMODE;
+ break;
+ case excel::XlWindowView::xlPageBreakPreview:
+ nSlot = FID_PAGEBREAKMODE;
+ break;
+ default:
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+ ScTabViewShell* pViewShell = excel::getBestViewShell( m_xModel );
+ if ( pViewShell )
+ dispatchExecute( pViewShell, nSlot );
+}
+
+uno::Reference< excel::XRange > SAL_CALL
+ScVbaWindow::getVisibleRange() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XIndexAccess > xPanesIA( m_xViewPane, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XViewPane > xTopLeftPane( xPanesIA->getByIndex( 0 ), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XPane > xPane( new ScVbaPane( this, mxContext, m_xModel, xTopLeftPane ) );
+ return xPane->getVisibleRange();
+}
+
+sal_Int32 SAL_CALL
+ScVbaWindow::PointsToScreenPixelsX(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ sal_Int32 nHundredthsofOneMillimeters = Millimeter::getInHundredthsOfOneMillimeter( _points );
+ double fConvertFactor = (m_xDevice->getInfo().PixelPerMeterX/100000);
+ return static_cast<sal_Int32>(fConvertFactor * nHundredthsofOneMillimeters );
+}
+
+sal_Int32 SAL_CALL
+ScVbaWindow::PointsToScreenPixelsY(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ sal_Int32 nHundredthsofOneMillimeters = Millimeter::getInHundredthsOfOneMillimeter( _points );
+ double fConvertFactor = (m_xDevice->getInfo().PixelPerMeterY/100000);
+ return static_cast<sal_Int32>(fConvertFactor * nHundredthsofOneMillimeters );
+}
+
+void SAL_CALL
+ScVbaWindow::PrintOut( const css::uno::Any& From, const css::uno::Any&To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ // need test, print current active sheet
+ PrintOutHelper( excel::getBestViewShell( m_xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, sal_True );
+}
+
+void SAL_CALL
+ScVbaWindow::PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ // need test, print preview current active sheet
+ PrintPreviewHelper( EnableChanges, excel::getBestViewShell( m_xModel ) );
+}
+
+rtl::OUString&
+ScVbaWindow::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWindow") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaWindow::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Window" ) );
+ }
+ return aServiceNames;
+}
+namespace window
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaWindow, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaWindow",
+ "ooo.vba.excel.Window" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbawindow.hxx b/sc/source/ui/vba/vbawindow.hxx
new file mode 100644
index 000000000000..7daf0ba54c63
--- /dev/null
+++ b/sc/source/ui/vba/vbawindow.hxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_WINDOW_HXX
+#define SC_VBA_WINDOW_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XWindow.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/sheet/XViewPane.hpp>
+#include <com/sun/star/sheet/XViewFreezable.hpp>
+#include <com/sun/star/sheet/XViewSplitable.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <ooo/vba/excel/XPane.hpp>
+#include <com/sun/star/awt/XDevice.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbawindowbase.hxx>
+#include "vbaworkbook.hxx"
+
+typedef cppu::ImplInheritanceHelper1< VbaWindowBase, ov::excel::XWindow > WindowImpl_BASE;
+
+class ScVbaWindow : public WindowImpl_BASE
+{
+private:
+ css::uno::Reference< css::sheet::XViewPane > m_xViewPane;
+ css::uno::Reference< css::sheet::XViewFreezable > m_xViewFreezable;
+ css::uno::Reference< css::sheet::XViewSplitable > m_xViewSplitable;
+ css::uno::Reference< ov::excel::XPane > m_xPane;
+ css::uno::Reference< css::awt::XDevice > m_xDevice;
+ void init();
+protected:
+ void SplitAtDefinedPosition(sal_Bool _bUnFreezePane);
+public:
+ void Scroll( const css::uno::Any& Down, const css::uno::Any& Up, const css::uno::Any& ToRight, const css::uno::Any& ToLeft, bool bLargeScroll = false ) throw (css::uno::RuntimeException);
+public:
+ ScVbaWindow( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::frame::XModel >& xModel );
+ ScVbaWindow( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext > const& xContext );
+
+ // XWindow
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL ActiveCell( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XPane > SAL_CALL ActivePane() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL ActiveSheet( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL setCaption( const css::uno::Any& _caption ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getCaption() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayGridlines() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayGridlines( ::sal_Bool _displaygridlines ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayHeadings() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayHeadings( ::sal_Bool _bDisplayHeadings ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayHorizontalScrollBar() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayHorizontalScrollBar( ::sal_Bool _bDisplayHorizontalScrollBar ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayOutline() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayOutline( ::sal_Bool _bDisplayOutline ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayVerticalScrollBar() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayVerticalScrollBar( ::sal_Bool _bDisplayVerticalScrollBar ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getDisplayWorkbookTabs() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayWorkbookTabs( ::sal_Bool _bDisplayWorkbookTabs ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getFreezePanes() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setFreezePanes( ::sal_Bool _bFreezePanes ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getSplit() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setSplit( ::sal_Bool _bSplit ) throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getSplitColumn() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setSplitColumn( sal_Int32 _splitcolumn ) throw (css::uno::RuntimeException) ;
+ virtual double SAL_CALL getSplitHorizontal() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setSplitHorizontal( double _splithorizontal ) throw (css::uno::RuntimeException) ;
+ virtual sal_Int32 SAL_CALL getSplitRow() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setSplitRow( sal_Int32 _splitrow ) throw (css::uno::RuntimeException) ;
+ virtual double SAL_CALL getSplitVertical() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setSplitVertical( double _splitvertical ) throw (css::uno::RuntimeException) ;
+ virtual css::uno::Any SAL_CALL getScrollRow() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setScrollRow( const css::uno::Any& _scrollrow ) throw (css::uno::RuntimeException) ;
+ virtual css::uno::Any SAL_CALL getScrollColumn() throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL setScrollColumn( const css::uno::Any& _scrollcolumn ) throw (css::uno::RuntimeException) ;
+ virtual css::uno::Any SAL_CALL getView() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setView( const css::uno::Any& _view ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getVisibleRange() throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getWindowState() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setWindowState( const css::uno::Any& _windowstate ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getZoom() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setZoom( const css::uno::Any& _zoom ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL SmallScroll( const css::uno::Any& Down, const css::uno::Any& Up, const css::uno::Any& ToRight, const css::uno::Any& ToLeft ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL LargeScroll( const css::uno::Any& Down, const css::uno::Any& Up, const css::uno::Any& ToRight, const css::uno::Any& ToLeft ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL SelectedSheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ScrollWorkbookTabs( const css::uno::Any& Sheets, const css::uno::Any& Position ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Activate( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Close( const css::uno::Any& SaveChanges, const css::uno::Any& FileName, const css::uno::Any& RouteWorkBook ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Selection( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL RangeSelection() throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL PointsToScreenPixelsX(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL PointsToScreenPixelsY(sal_Int32 _points) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any&To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL PrintPreview( const css::uno::Any& EnableChanges ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_WINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbawindows.cxx b/sc/source/ui/vba/vbawindows.cxx
new file mode 100644
index 000000000000..1456c71af12c
--- /dev/null
+++ b/sc/source/ui/vba/vbawindows.cxx
@@ -0,0 +1,262 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbawindows.hxx"
+
+#include <hash_map>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <cppuhelper/implbase3.hxx>
+
+#include <tools/urlobj.hxx>
+#include "vbawindow.hxx"
+#include "vbaglobals.hxx"
+
+using namespace ::com::sun::star;
+using namespace ::ooo::vba;
+
+typedef std::hash_map< rtl::OUString,
+sal_Int32, ::rtl::OUStringHash,
+::std::equal_to< ::rtl::OUString > > NameIndexHash;
+
+
+uno::Reference< XHelperInterface > lcl_createWorkbookHIParent( const uno::Reference< frame::XModel >& xModel, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication )
+{
+ return new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel );
+}
+
+uno::Any ComponentToWindow( const uno::Any& aSource, uno::Reference< uno::XComponentContext > & xContext, const uno::Any& aApplication )
+{
+ uno::Reference< frame::XModel > xModel( aSource, uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XWindow > xWin( new ScVbaWindow( lcl_createWorkbookHIParent( xModel, xContext, aApplication ), xContext,xModel ) );
+ return uno::makeAny( xWin );
+}
+
+typedef std::vector < uno::Reference< sheet::XSpreadsheetDocument > > Components;
+// #TODO more or less the same as class in workwindows ( code sharing needed )
+class WindowComponentEnumImpl : public EnumerationHelper_BASE
+{
+protected:
+ uno::Reference< uno::XComponentContext > m_xContext;
+ Components m_components;
+ Components::const_iterator m_it;
+
+public:
+ WindowComponentEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const Components& components ) throw ( uno::RuntimeException ) : m_xContext( xContext ), m_components( components )
+ {
+ m_it = m_components.begin();
+ }
+
+ WindowComponentEnumImpl( const uno::Reference< uno::XComponentContext >& xContext ) throw ( uno::RuntimeException ) : m_xContext( xContext )
+ {
+ uno::Reference< lang::XMultiComponentFactory > xSMgr(
+ m_xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< frame::XDesktop > xDesktop
+ (xSMgr->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop"), m_xContext), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration > mxComponents = xDesktop->getComponents()->createEnumeration();
+ while( mxComponents->hasMoreElements() )
+ {
+ uno::Reference< sheet::XSpreadsheetDocument > xNext( mxComponents->nextElement(), uno::UNO_QUERY );
+ if ( xNext.is() )
+ m_components.push_back( xNext );
+ }
+ m_it = m_components.begin();
+ }
+ // XEnumeration
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return m_it != m_components.end();
+ }
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ {
+ throw container::NoSuchElementException();
+ }
+ return makeAny( *(m_it++) );
+ }
+};
+
+class WindowEnumImpl : public WindowComponentEnumImpl
+{
+ uno::Any m_aApplication;
+public:
+ WindowEnumImpl(const uno::Reference< uno::XComponentContext >& xContext, const Components& components, const uno::Any& aApplication ):WindowComponentEnumImpl( xContext, components ), m_aApplication( aApplication ){}
+ WindowEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Any& aApplication ): WindowComponentEnumImpl( xContext ), m_aApplication( aApplication ) {}
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ return ComponentToWindow( WindowComponentEnumImpl::nextElement(), m_xContext, m_aApplication );
+ }
+};
+
+typedef ::cppu::WeakImplHelper3< container::XEnumerationAccess
+ , com::sun::star::container::XIndexAccess
+ , com::sun::star::container::XNameAccess
+ > WindowsAccessImpl_BASE;
+
+class WindowsAccessImpl : public WindowsAccessImpl_BASE
+{
+ uno::Reference< uno::XComponentContext > m_xContext;
+ Components m_windows;
+ NameIndexHash namesToIndices;
+public:
+ WindowsAccessImpl( const uno::Reference< uno::XComponentContext >& xContext ):m_xContext( xContext )
+ {
+ uno::Reference< container::XEnumeration > xEnum = new WindowComponentEnumImpl( m_xContext );
+ sal_Int32 nIndex=0;
+ while( xEnum->hasMoreElements() )
+ {
+ uno::Reference< sheet::XSpreadsheetDocument > xNext( xEnum->nextElement(), uno::UNO_QUERY );
+ if ( xNext.is() )
+ {
+ m_windows.push_back( xNext );
+ uno::Reference< frame::XModel > xModel( xNext, uno::UNO_QUERY_THROW ); // that the spreadsheetdocument is a xmodel is a given
+ uno::Reference< XHelperInterface > xTemp; // temporary needed for g++ 3.3.5
+ ScVbaWindow window( xTemp, m_xContext, xModel );
+ rtl::OUString sCaption;
+ window.getCaption() >>= sCaption;
+ namesToIndices[ sCaption ] = nIndex++;
+ }
+ }
+
+ }
+
+ //XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new WindowComponentEnumImpl( m_xContext, m_windows );
+ }
+ // XIndexAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException)
+ {
+ return m_windows.size();
+ }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw ( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( Index < 0
+ || static_cast< Components::size_type >( Index ) >= m_windows.size() )
+ throw lang::IndexOutOfBoundsException();
+ return makeAny( m_windows[ Index ] ); // returns xspreadsheetdoc
+ }
+
+ //XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException)
+ {
+ return sheet::XSpreadsheetDocument::static_type(0);
+ }
+
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException)
+ {
+ return (m_windows.size() > 0);
+ }
+
+ //XNameAccess
+ virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ NameIndexHash::const_iterator it = namesToIndices.find( aName );
+ if ( it == namesToIndices.end() )
+ throw container::NoSuchElementException();
+ return makeAny( m_windows[ it->second ] );
+
+ }
+
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
+ {
+ uno::Sequence< ::rtl::OUString > names( namesToIndices.size() );
+ ::rtl::OUString* pString = names.getArray();
+ NameIndexHash::const_iterator it = namesToIndices.begin();
+ NameIndexHash::const_iterator it_end = namesToIndices.end();
+ for ( ; it != it_end; ++it, ++pString )
+ *pString = it->first;
+ return names;
+ }
+
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+ NameIndexHash::const_iterator it = namesToIndices.find( aName );
+ return (it != namesToIndices.end());
+ }
+
+};
+
+
+ScVbaWindows::ScVbaWindows( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess ): ScVbaWindows_BASE( xParent, xContext, xIndexAccess )
+{
+}
+
+ScVbaWindows::ScVbaWindows( const uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWindows_BASE( xParent, xContext, uno::Reference< container::XIndexAccess > ( new WindowsAccessImpl( xContext ) ) )
+{
+}
+uno::Reference< container::XEnumeration >
+ScVbaWindows::createEnumeration() throw (uno::RuntimeException)
+{
+ return new WindowEnumImpl( mxContext, Application() );
+}
+
+uno::Any
+ScVbaWindows::createCollectionObject( const css::uno::Any& aSource )
+{
+ return ComponentToWindow( aSource, mxContext, Application() );
+}
+
+uno::Type
+ScVbaWindows::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XWindows::static_type(0);
+}
+
+
+void SAL_CALL
+ScVbaWindows::Arrange( ::sal_Int32 /*ArrangeStyle*/, const uno::Any& /*ActiveWorkbook*/, const uno::Any& /*SyncHorizontal*/, const uno::Any& /*SyncVertical*/ ) throw (uno::RuntimeException)
+{
+ //#TODO #FIXME see what can be done for an implementation here
+}
+
+
+rtl::OUString&
+ScVbaWindows::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWindows") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaWindows::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Windows") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbawindows.hxx b/sc/source/ui/vba/vbawindows.hxx
new file mode 100644
index 000000000000..71d5f7cd59cb
--- /dev/null
+++ b/sc/source/ui/vba/vbawindows.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_WINDOWS_HXX
+#define SC_VBA_WINDOWS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <ooo/vba/excel/XWindows.hpp>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include "excelvbahelper.hxx"
+#include <vbahelper/vbacollectionimpl.hxx>
+
+
+typedef CollTestImplHelper< ov::excel::XWindows > ScVbaWindows_BASE;
+
+class ScVbaWindows : public ScVbaWindows_BASE
+{
+public:
+ ScVbaWindows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xIndexAccess );
+ ScVbaWindows( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext );
+ virtual ~ScVbaWindows() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+
+ // XWindows
+ virtual void SAL_CALL Arrange( ::sal_Int32 ArrangeStyle, const css::uno::Any& ActiveWorkbook, const css::uno::Any& SyncHorizontal, const css::uno::Any& SyncVertical ) throw (::com::sun::star::uno::RuntimeException);
+ // ScVbaCollectionBaseImpl
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif //SC_VBA_WINDOWS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworkbook.cxx b/sc/source/ui/vba/vbaworkbook.cxx
new file mode 100644
index 000000000000..1af4fee63ef3
--- /dev/null
+++ b/sc/source/ui/vba/vbaworkbook.cxx
@@ -0,0 +1,435 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <vbahelper/helperdecl.hxx>
+#include <tools/urlobj.hxx>
+#include <comphelper/unwrapargs.hxx>
+
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/util/XProtectable.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <ooo/vba/excel/XlFileFormat.hpp>
+#include <ooo/vba/excel/XApplication.hpp> //liuchen 2009-12-16
+
+#include "scextopt.hxx"
+#include "vbaworksheet.hxx"
+#include "vbaworksheets.hxx"
+#include "vbaworkbook.hxx"
+#include "vbawindows.hxx"
+#include "vbastyles.hxx"
+#include "excelvbahelper.hxx"
+#include "vbapalette.hxx"
+#include <osl/file.hxx>
+#include <stdio.h>
+#include "vbanames.hxx" // Amelia Wang
+#include "nameuno.hxx"
+#include "docoptio.hxx"
+#include "unonames.hxx"
+
+// Much of the impl. for the equivalend UNO module is
+// sc/source/ui/unoobj/docuno.cxx, viewuno.cxx
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+class ActiveSheet : public ScVbaWorksheet
+{
+protected:
+ virtual uno::Reference< frame::XModel > getModel()
+ {
+ return getCurrentExcelDoc( mxContext );
+ }
+ virtual uno::Reference< sheet::XSpreadsheet > getSheet()
+ {
+ uno::Reference< frame::XModel > xModel = getModel();
+ uno::Reference< sheet::XSpreadsheet > xSheet;
+ if ( xModel.is() )
+ {
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
+ xModel->getCurrentController(), uno::UNO_QUERY );
+ if ( xSpreadsheet.is() )
+ xSheet = xSpreadsheet->getActiveSheet();
+ }
+ return xSheet;
+ }
+public:
+ ActiveSheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : ScVbaWorksheet( xParent, xContext ) {}
+
+};
+
+uno::Sequence< sal_Int32 > ScVbaWorkbook::ColorData;
+
+void ScVbaWorkbook::initColorData( const uno::Sequence< sal_Int32 >& sColors )
+{
+ const sal_Int32* pSource = sColors.getConstArray();
+ sal_Int32* pDest = ColorData.getArray();
+ const sal_Int32* pEnd = pSource + sColors.getLength();
+ for ( ; pSource != pEnd; ++pSource, ++pDest )
+ *pDest = *pSource;
+}
+
+
+void SAL_CALL
+ScVbaWorkbook::ResetColors( ) throw (::script::BasicErrorException, ::uno::RuntimeException)
+{
+ uno::Reference< container::XIndexAccess > xIndexAccess( ScVbaPalette::getDefaultPalette(), uno::UNO_QUERY_THROW );
+ sal_Int32 nLen = xIndexAccess->getCount();
+ ColorData.realloc( nLen );
+
+ uno::Sequence< sal_Int32 > dDefaultColors( nLen );
+ sal_Int32* pDest = dDefaultColors.getArray();
+ for ( sal_Int32 index=0; index < nLen; ++pDest, ++index )
+ xIndexAccess->getByIndex( index ) >>= (*pDest);
+ initColorData( dDefaultColors );
+}
+
+::uno::Any SAL_CALL
+ScVbaWorkbook::Colors( const ::uno::Any& Index ) throw (::script::BasicErrorException, ::uno::RuntimeException)
+{
+ uno::Any aRet;
+ if ( Index.getValue() )
+ {
+ sal_Int32 nIndex = 0;
+ Index >>= nIndex;
+ aRet = uno::makeAny( XLRGBToOORGB( ColorData[ --nIndex ] ) );
+ }
+ else
+ aRet = uno::makeAny( ColorData );
+ return aRet;
+}
+
+::sal_Int32 SAL_CALL
+ScVbaWorkbook::getFileFormat( ) throw (::uno::RuntimeException)
+{
+ sal_Int32 aFileFormat = 0;
+ rtl::OUString aFilterName;
+ uno::Sequence< beans::PropertyValue > aArgs = getModel()->getArgs();
+
+ // #FIXME - seems suspect should we not walk through the properties
+ // to find the FilterName
+ if (aArgs[0].Name.equalsAscii( "FilterName")) {
+ aArgs[0].Value >>= aFilterName;
+ } else {
+ aArgs[1].Value >>= aFilterName;
+ }
+
+ if (aFilterName.equalsAscii("Text - txt - csv (StarCalc)")) {
+ aFileFormat = excel::XlFileFormat::xlCSV; //xlFileFormat.
+ }
+
+ if (aFilterName.equalsAscii("DBF")) {
+ aFileFormat = excel::XlFileFormat::xlDBF4;
+ }
+
+ if (aFilterName.equalsAscii("DIF")) {
+ aFileFormat = excel::XlFileFormat::xlDIF;
+ }
+
+ if (aFilterName.equalsAscii("Lotus")) {
+ aFileFormat = excel::XlFileFormat::xlWK3;
+ }
+
+ if (aFilterName.equalsAscii("MS Excel 4.0")) {
+ aFileFormat = excel::XlFileFormat::xlExcel4Workbook;
+ }
+
+ if (aFilterName.equalsAscii("MS Excel 5.0/95")) {
+ aFileFormat = excel::XlFileFormat::xlExcel5;
+ }
+
+ if (aFilterName.equalsAscii("MS Excel 97")) {
+ aFileFormat = excel::XlFileFormat::xlExcel9795;
+ }
+
+ if (aFilterName.equalsAscii("HTML (StarCalc)")) {
+ aFileFormat = excel::XlFileFormat::xlHtml;
+ }
+
+ if (aFilterName.equalsAscii("calc_StarOffice_XML_Calc_Template")) {
+ aFileFormat = excel::XlFileFormat::xlTemplate;
+ }
+
+ if (aFilterName.equalsAscii("StarOffice XML (Calc)")) {
+ aFileFormat = excel::XlFileFormat::xlWorkbookNormal;
+ }
+ if (aFilterName.equalsAscii("calc8")) {
+ aFileFormat = excel::XlFileFormat::xlWorkbookNormal;
+ }
+
+ return aFileFormat;
+}
+
+//VBA by minz@cn.ibm.com. Convert Excel fileformat to OO file filter
+::rtl::OUString ScVbaWorkbook::convertFileFormat(sal_Int32 aFileFormat)
+{
+ rtl::OUString aFilterName;
+
+ switch(aFileFormat)
+ {
+ case excel::XlFileFormat::xlCSV:
+ aFilterName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Text - txt - csv (StarCalc)" ) );
+ break;
+ case excel::XlFileFormat::xlExcel9795:
+ aFilterName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MS Excel 97" ) );
+ break;
+ }
+
+ return aFilterName;
+}
+
+void
+ScVbaWorkbook::init()
+{
+ if ( !ColorData.getLength() )
+ ResetColors();
+}
+ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext) :ScVbaWorkbook_BASE( xParent, xContext )
+{
+ //#FIXME this persists the color data per office instance and
+ // not per workbook instance, need to hook the data into XModel
+ // ( e.g. we already store the imported palette in there )
+ // so we should,
+ // a) make the class that does that a service
+ // b) make that service implement XIndexContainer
+ init();
+}
+
+ScVbaWorkbook::ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, css::uno::Reference< css::frame::XModel > xModel ) : ScVbaWorkbook_BASE( xParent, xContext, xModel )
+{
+ init();
+}
+
+ScVbaWorkbook::ScVbaWorkbook( uno::Sequence< uno::Any> const & args,
+ uno::Reference< uno::XComponentContext> const & xContext ) : ScVbaWorkbook_BASE( args, xContext )
+{
+ init();
+}
+
+uno::Reference< excel::XWorksheet >
+ScVbaWorkbook::getActiveSheet() throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getCurrentExcelDoc( mxContext ), uno::UNO_SET_THROW );
+ uno::Reference< sheet::XSpreadsheetView > xView( xModel->getCurrentController(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xSheetProps( xView->getActiveSheet(), uno::UNO_QUERY_THROW );
+ // #162503# return the original document module wrapper object, instead of a new instance
+ ::rtl::OUString aCodeName;
+ xSheetProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= aCodeName;
+ ScDocShell* pShell = excel::getDocShell( xModel );
+ if( !pShell )
+ throw uno::RuntimeException();
+ return uno::Reference< excel::XWorksheet >( getUnoDocModule( aCodeName, pShell ), uno::UNO_QUERY_THROW );
+}
+
+uno::Any SAL_CALL
+ScVbaWorkbook::Sheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return Worksheets( aIndex );
+}
+
+uno::Any SAL_CALL
+ScVbaWorkbook::Worksheets( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getModel() );
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference<container::XIndexAccess > xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xWorkSheets( new ScVbaWorksheets( this, mxContext, xSheets, xModel ) );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ {
+ return uno::Any( xWorkSheets );
+ }
+ // pass on to collection
+ return uno::Any( xWorkSheets->Item( aIndex, uno::Any() ) );
+}
+uno::Any SAL_CALL
+ScVbaWorkbook::Windows( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+
+ uno::Reference< excel::XWindows > xWindows( new ScVbaWindows( getParent(), mxContext ) );
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ return uno::Any( xWindows );
+ return uno::Any( xWindows->Item( aIndex, uno::Any() ) );
+}
+
+void SAL_CALL
+ScVbaWorkbook::Activate() throw (uno::RuntimeException)
+{
+ VbaDocumentBase::Activate();
+}
+
+void
+ScVbaWorkbook::Protect( const uno::Any &aPassword ) throw (uno::RuntimeException)
+{
+ VbaDocumentBase::Protect( aPassword );
+}
+
+::sal_Bool
+ScVbaWorkbook::getProtectStructure() throw (uno::RuntimeException)
+{
+ uno::Reference< util::XProtectable > xProt( getModel(), uno::UNO_QUERY_THROW );
+ return xProt->isProtected();
+}
+
+::sal_Bool SAL_CALL ScVbaWorkbook::getPrecisionAsDisplayed() throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ return pDoc->GetDocOptions().IsCalcAsShown();
+}
+
+void SAL_CALL ScVbaWorkbook::setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ ScDocOptions aOpt = pDoc->GetDocOptions();
+ aOpt.SetCalcAsShown( _precisionAsDisplayed );
+ pDoc->SetDocOptions( aOpt );
+}
+
+void
+ScVbaWorkbook::SaveCopyAs( const rtl::OUString& sFileName ) throw ( uno::RuntimeException)
+{
+ rtl::OUString aURL;
+ osl::FileBase::getFileURLFromSystemPath( sFileName, aURL );
+ uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::PropertyValue > storeProps(1);
+ storeProps[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
+ storeProps[0].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MS Excel 97" ) );
+ xStor->storeToURL( aURL, storeProps );
+}
+
+//VBA by minz@cn.ibm.com. Add Workbook.SaveAs.
+void
+ScVbaWorkbook::SaveAs( const rtl::OUString& FileName, const uno::Any& FileFormat, const uno::Any& /*CreateBackup*/ ) throw ( uno::RuntimeException)
+{
+ rtl::OUString aURL;
+ osl::FileBase::getFileURLFromSystemPath( FileName, aURL );
+ //liuchen 2009-12-16 if the input parameter "FileName" takes the form as "MyFile", we need to get the current directory and combine the current directory and the file name
+ INetURLObject aFileNameURL( aURL );
+ aURL = aFileNameURL.GetMainURL( INetURLObject::NO_DECODE );
+ if ( aURL.getLength() == 0 )
+ {
+ uno::Reference< excel::XApplication > xApplication ( Application(),uno::UNO_QUERY_THROW );
+ rtl::OUString aPathStr = xApplication->getDefaultFilePath();
+ rtl::OUString aPathURLStr;
+ osl::FileBase::getFileURLFromSystemPath( aPathStr, aPathURLStr );
+ INetURLObject aPathURL( aPathURLStr );
+ aPathURL.Append( FileName );
+ aURL = aPathURL.GetMainURL( INetURLObject::NO_DECODE );
+ }
+ //liuchen 2009-12-16
+ uno::Reference< frame::XStorable > xStor( getModel(), uno::UNO_QUERY_THROW );
+
+ sal_Int32 aFileFormat = excel::XlFileFormat::xlExcel9795;
+ FileFormat >>= aFileFormat;
+
+ if ( FileName.indexOf('.') == -1 )
+ {
+ if ( aFileFormat == excel::XlFileFormat::xlExcel9795 )
+ {
+ aURL = aURL + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".xls" ) );
+ }
+ else if ( aFileFormat == excel::XlFileFormat::xlCSV )
+ {
+ aURL = aURL + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".csv" ) );
+ }
+ }
+
+ uno::Sequence< beans::PropertyValue > storeProps(1);
+ storeProps[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ) );
+ storeProps[0].Value <<= convertFileFormat(aFileFormat);
+
+ xStor->storeAsURL( aURL, storeProps );
+}
+
+css::uno::Any SAL_CALL
+ScVbaWorkbook::Styles( const::uno::Any& Item ) throw (uno::RuntimeException)
+{
+ // quick look and Styles object doesn't seem to have a valid parent
+ // or a least the object browser just shows an object that has no
+ // variables ( therefore... leave as NULL for now )
+ uno::Reference< XCollection > dStyles = new ScVbaStyles( uno::Reference< XHelperInterface >(), mxContext, getModel() );
+ if ( Item.hasValue() )
+ return dStyles->Item( Item, uno::Any() );
+ return uno::makeAny( dStyles );
+}
+
+// Amelia Wang
+uno::Any SAL_CALL
+ScVbaWorkbook::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< frame::XModel > xModel( getModel() );
+ uno::Reference< beans::XPropertySet > xProps( xModel, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XNamedRanges > xNamedRanges( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NamedRanges") ) ), uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xNames( new ScVbaNames( this , mxContext , xNamedRanges , xModel ));
+ if ( aIndex.getValueTypeClass() == uno::TypeClass_VOID )
+ {
+ return uno::Any( xNames );
+}
+ return uno::Any( xNames->Item( aIndex, uno::Any() ) );
+}
+
+rtl::OUString&
+ScVbaWorkbook::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorkbook") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaWorkbook::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbook" ) );
+ }
+ return aServiceNames;
+}
+
+::rtl::OUString SAL_CALL
+ScVbaWorkbook::getCodeName() throw (css::uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY_THROW );
+ return xModelProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ).get< ::rtl::OUString >();
+}
+
+namespace workbook
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaWorkbook, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaWorkbook",
+ "ooo.vba.excel.Workbook" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworkbook.hxx b/sc/source/ui/vba/vbaworkbook.hxx
new file mode 100644
index 000000000000..6bde08a111ae
--- /dev/null
+++ b/sc/source/ui/vba/vbaworkbook.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_WORKBOOK_HXX
+#define SC_VBA_WORKBOOK_HXX
+
+#include <com/sun/star/frame/XModel.hpp>
+#include <ooo/vba/excel/XWorkbook.hpp>
+#include <vbahelper/vbahelperinterface.hxx>
+#include <vbahelper/vbadocumentbase.hxx>
+
+class ScModelObj;
+
+typedef cppu::ImplInheritanceHelper1< VbaDocumentBase, ov::excel::XWorkbook > ScVbaWorkbook_BASE;
+
+class ScVbaWorkbook : public ScVbaWorkbook_BASE
+{
+ static css::uno::Sequence< sal_Int32 > ColorData;
+ void initColorData( const css::uno::Sequence< sal_Int32 >& sColors );
+ void init();
+
+ ::rtl::OUString convertFileFormat(sal_Int32 aFileFormat);
+protected:
+
+ ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
+public:
+ ScVbaWorkbook( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ css::uno::Reference< css::frame::XModel > xModel );
+ ScVbaWorkbook( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext );
+ virtual ~ScVbaWorkbook() {}
+
+ // Attributes
+ virtual ::sal_Bool SAL_CALL getProtectStructure() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getActiveSheet() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getPrecisionAsDisplayed() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setPrecisionAsDisplayed( sal_Bool _precisionAsDisplayed ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual css::uno::Any SAL_CALL Worksheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Sheets( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Protect( const css::uno::Any & aPassword ) throw (css::uno::RuntimeException);
+ // Amelia Wang
+ virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL Styles( const css::uno::Any& Item ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL ResetColors( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Colors( const css::uno::Any& Index ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getFileFormat( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL SaveCopyAs( const rtl::OUString& Filename ) throw ( css::uno::RuntimeException);
+ virtual void SAL_CALL SaveAs( const rtl::OUString& FileName, const css::uno::Any& FileFormat, const css::uno::Any& CreateBackup ) throw (css::uno::RuntimeException);
+
+ // code name
+ virtual ::rtl::OUString SAL_CALL getCodeName() throw ( css::uno::RuntimeException);
+
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+ virtual css::uno::Reference< css::frame::XModel > getDocModel() { return mxModel; }
+};
+
+#endif /* SC_VBA_WORKBOOK_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx
new file mode 100644
index 000000000000..2d64f50764ba
--- /dev/null
+++ b/sc/source/ui/vba/vbaworkbooks.cxx
@@ -0,0 +1,370 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <comphelper/processfactory.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/PropertyVetoException.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/document/XTypeDetection.hpp>
+#include <com/sun/star/uri/XUriReference.hpp>
+#include <com/sun/star/uri/XUriReferenceFactory.hpp>
+#include <com/sun/star/script/vba/XVBACompatibility.hpp>
+#include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
+#include <com/sun/star/script/ModuleInfo.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
+
+#include <sfx2/objsh.hxx>
+#include <tools/urlobj.hxx>
+
+#include "vbaglobals.hxx"
+#include "vbaworkbook.hxx"
+#include "vbaworkbooks.hxx"
+#include <vbahelper/vbahelper.hxx>
+
+#include <hash_map>
+#include <vector>
+#include <osl/file.hxx>
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+const sal_Int16 CUSTOM_CHAR = 5;
+
+void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc )
+{
+ uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
+ ScDocShell* pShell = excel::getDocShell( xModel );
+ if ( pShell )
+ {
+ uno::Reference<script::XLibraryContainer> xLibContainer = pShell->GetBasicContainer();
+ uno::Reference<script::vba::XVBACompatibility> xVBACompat( xLibContainer, uno::UNO_QUERY_THROW );
+ xVBACompat->setVBACompatibilityMode( sal_True );
+ String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
+ pShell->GetBasicManager()->SetName( aPrjName );
+
+ if( xLibContainer.is() )
+ {
+ if( !xLibContainer->hasByName( aPrjName ) )
+ xLibContainer->createLibrary( aPrjName );
+ uno::Any aLibAny = xLibContainer->getByName( aPrjName );
+ uno::Reference< container::XNameContainer > xLib;
+ aLibAny >>= xLib;
+ if( xLib.is() )
+ {
+ uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW );
+ uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW);
+ // bootstrap vbaglobals
+ xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals")));
+ uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW );
+ // set up the module info for the workbook and sheets in the nealy created
+ // spreadsheet
+ ScDocument* pDoc = pShell->GetDocument();
+ String sCodeName = pDoc->GetCodeName();
+ if ( sCodeName.Len() == 0 )
+ {
+ sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") );
+ pDoc->SetCodeName( sCodeName );
+ }
+
+ std::vector< rtl::OUString > sDocModuleNames;
+ sDocModuleNames.push_back( sCodeName );
+
+ uno::Reference<container::XNameAccess > xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW );
+ uno::Sequence< rtl::OUString > sSheets( xSheets->getElementNames() );
+
+ for ( sal_Int32 index=0; index < sSheets.getLength() ; ++index )
+ {
+ sDocModuleNames.push_back( sSheets[ index ] );
+ }
+
+ std::vector<rtl::OUString>::iterator it_end = sDocModuleNames.end();
+
+ for ( std::vector<rtl::OUString>::iterator it = sDocModuleNames.begin(); it != it_end; ++it )
+ {
+ script::ModuleInfo sModuleInfo;
+
+ sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( *it ), uno::UNO_QUERY );
+ sModuleInfo.ModuleType = script::ModuleType::DOCUMENT;
+ xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo );
+ if( xLib->hasByName( *it ) )
+ xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) );
+ else
+ xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) );
+ }
+ }
+ }
+ }
+}
+
+static uno::Any
+getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Reference< XHelperInterface >& xParent )
+{
+ // FIXME: fine as long as ScVbaWorkbook is stateless ...
+ uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY );
+ if( !xModel.is() )
+ return uno::Any();
+
+ ScDocShell* pShell = excel::getDocShell( xModel );
+ if ( pShell )
+ {
+ String sCodeName = pShell->GetDocument()->GetCodeName();
+ uno::Reference< uno::XInterface > xIf = getUnoDocModule( sCodeName, pShell );
+ if ( xIf.is() )
+ {
+ OSL_TRACE(" *** Returning Module uno Object *** ");
+ return uno::makeAny( xIf );
+ }
+ }
+
+ ScVbaWorkbook *pWb = new ScVbaWorkbook( xParent, xContext, xModel );
+ return uno::Any( uno::Reference< excel::XWorkbook > (pWb) );
+}
+
+class WorkBookEnumImpl : public EnumerationHelperImpl
+{
+ uno::Any m_aApplication;
+public:
+ WorkBookEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {}
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ return getWorkbook( m_xContext, xDoc, m_xParent );
+ }
+
+};
+
+ScVbaWorkbooks::ScVbaWorkbooks( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext ) : ScVbaWorkbooks_BASE( xParent, xContext, VbaDocumentsBase::EXCEL_DOCUMENT )
+{
+}
+// XEnumerationAccess
+uno::Type
+ScVbaWorkbooks::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XWorkbook::static_type(0);
+}
+uno::Reference< container::XEnumeration >
+ScVbaWorkbooks::createEnumeration() throw (uno::RuntimeException)
+{
+ // #FIXME its possible the WorkBookEnumImpl here doens't reflect
+ // the state of this object ( although it should ) would be
+ // safer to create an enumeration based on this objects state
+ // rather than one effectively based of the desktop component
+ uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return new WorkBookEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() );
+}
+
+uno::Any
+ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource )
+{
+ uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY_THROW );
+ return getWorkbook( mxContext, xDoc, mxParent );
+}
+
+
+uno::Any SAL_CALL
+ScVbaWorkbooks::Add() throw (uno::RuntimeException)
+{
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW );
+
+ // need to set up the document modules ( and vba mode ) here
+ setUpDocumentModules( xSpreadDoc );
+ if( xSpreadDoc.is() )
+ return getWorkbook( mxContext, xSpreadDoc, mxParent );
+ return uno::Any();
+}
+
+void
+ScVbaWorkbooks::Close() throw (uno::RuntimeException)
+{
+ VbaDocumentsBase::Close();
+}
+
+bool
+ScVbaWorkbooks::isTextFile( const rtl::OUString& sType )
+{
+ // will return true if the file is
+ // a) a variant of a text file
+ // b) a csv file
+ // c) unknown
+ // returning true basically means treat this like a csv file
+ const static rtl::OUString txtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text" ) );
+ const static rtl::OUString csvType( RTL_CONSTASCII_USTRINGPARAM("calc_Text_txt_csv_StarCalc" ) );
+ const static rtl::OUString encodedTxtType( RTL_CONSTASCII_USTRINGPARAM("writer_Text_encoded" ) );
+ return sType.equals( txtType ) || sType.equals( csvType ) || ( sType.getLength() == 0 ) || sType.equals( encodedTxtType );
+}
+
+bool
+ScVbaWorkbooks::isSpreadSheetFile( const rtl::OUString& sType )
+{
+ // include calc_QPro etc. ? ( not for the moment anyway )
+ if ( sType.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("calc_MS"))) == 0
+ || sType.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("calc8"))) == 0
+ || sType.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("calc_StarOffice"))) == 0 )
+ return true;
+ return false;
+}
+
+rtl::OUString
+ScVbaWorkbooks::getFileFilterType( const rtl::OUString& rFileName )
+{
+ uno::Reference< document::XTypeDetection > xTypeDetect( mxContext->getServiceManager()->createInstanceWithContext(::rtl::OUString::createFromAscii("com.sun.star.document.TypeDetection"), mxContext), uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::PropertyValue > aMediaDesc(1);
+ aMediaDesc[ 0 ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("URL" ) );
+ aMediaDesc[ 0 ].Value <<= rFileName;
+ rtl::OUString sType = xTypeDetect->queryTypeByDescriptor( aMediaDesc, sal_True );
+ return sType;
+}
+
+// #TODO# #FIXME# can any of the unused params below be used?
+uno::Any
+ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLinks*/, const uno::Any& ReadOnly, const uno::Any& Format, const uno::Any& /*Password*/, const uno::Any& /*WriteResPassword*/, const uno::Any& /*IgnoreReadOnlyRecommended*/, const uno::Any& /*Origin*/, const uno::Any& Delimiter, const uno::Any& /*Editable*/, const uno::Any& /*Notify*/, const uno::Any& /*Converter*/, const uno::Any& /*AddToMru*/ ) throw (uno::RuntimeException)
+{
+ // we need to detect if this is a URL, if not then assume its a file path
+ rtl::OUString aURL;
+ INetURLObject aObj;
+ aObj.SetURL( rFileName );
+ bool bIsURL = aObj.GetProtocol() != INET_PROT_NOT_VALID;
+ if ( bIsURL )
+ aURL = rFileName;
+ else
+ osl::FileBase::getFileURLFromSystemPath( rFileName, aURL );
+
+ uno::Sequence< beans::PropertyValue > sProps(0);
+ sal_Int32 nIndex = 0;
+
+ rtl::OUString sType = getFileFilterType( aURL );
+ // A text file means it needs to be processed as a csv file
+ if ( isTextFile( sType ) )
+ {
+ // Values for format
+ // 1 Tabs
+ // 2 Commas
+ // 3 Spaces
+ // 4 Semicolons
+ // 5 Nothing
+ // 6 Custom character (see the Delimiter argument
+ // no format means use the current delimiter
+ sProps.realloc( 3 );
+ sProps[ nIndex ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FilterOptions" ) );
+ sal_Int16 delims[] = { 0 /*default not used*/, 9/*tab*/, 44/*comma*/, 32/*space*/, 59/*semicolon*/ };
+ static rtl::OUString sRestOfFormat( RTL_CONSTASCII_USTRINGPARAM(",34,0,1" ) );
+
+ rtl::OUString sFormat;
+ sal_Int16 nFormat = 0; // default indicator
+
+
+ if ( Format.hasValue() )
+ {
+ Format >>= nFormat; // val of nFormat overwritten if extracted
+ // validate param
+ if ( nFormat < 1 || nFormat > 6 )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Illegal value for Format" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ sal_Int16 nDelim = getCurrentDelim();
+
+ if ( nFormat > 0 && nFormat < CUSTOM_CHAR )
+ {
+ nDelim = delims[ nFormat ];
+ }
+ else if ( nFormat > CUSTOM_CHAR )
+ {
+ // Need to check Delimiter param
+ if ( !Delimiter.hasValue() )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Expected value for Delimiter" ) ), uno::Reference< uno::XInterface >() );
+ rtl::OUString sStr;
+ Delimiter >>= sStr;
+ String aUniStr( sStr );
+ if ( aUniStr.Len() )
+ nDelim = aUniStr.GetChar(0);
+ else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Incorrect value for Delimiter" ) ), uno::Reference< uno::XInterface >() );
+ }
+
+ getCurrentDelim() = nDelim; //set new current
+
+ sFormat = rtl::OUString::valueOf( (sal_Int32)nDelim ) + sRestOfFormat;
+ sProps[ nIndex++ ].Value <<= sFormat;
+ sProps[ nIndex ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FilterName") );
+ sProps[ nIndex++ ].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Text - txt - csv (StarCalc)") );
+ // Ensure WORKAROUND_CSV_TXT_BUG_i60158 gets called in typedetection.cxx so
+ // csv is forced for deep detected 'writerxxx' types
+ sProps[ nIndex ].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DocumentService") );
+ sProps[ nIndex ].Value <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sheet.SpreadsheetDocument") );
+ }
+ else if ( !isSpreadSheetFile( sType ) )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() );
+
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW );
+ uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent );
+ uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY );
+ if ( xWBook.is() )
+ xWBook->Activate();
+ return aRet;
+}
+
+uno::Any
+ScVbaWorkbooks::Open( const rtl::OUString& Filename, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException)
+{
+ return VbaDocumentsBase::Open( Filename, ReadOnly, rProps );
+}
+
+rtl::OUString&
+ScVbaWorkbooks::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorkbooks") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaWorkbooks::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Workbooks") );
+ }
+ return sNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworkbooks.hxx b/sc/source/ui/vba/vbaworkbooks.hxx
new file mode 100644
index 000000000000..6cd6d90fc46b
--- /dev/null
+++ b/sc/source/ui/vba/vbaworkbooks.hxx
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_WORKBOOKS_HXX
+#define SC_VBA_WORKBOOKS_HXX
+
+
+#include <vbahelper/vbacollectionimpl.hxx>
+#include <ooo/vba/excel/XWorkbooks.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <vbahelper/vbadocumentsbase.hxx>
+#include "excelvbahelper.hxx"
+
+
+class ScModelObj;
+
+typedef cppu::ImplInheritanceHelper1< VbaDocumentsBase, ov::excel::XWorkbooks > ScVbaWorkbooks_BASE;
+
+class ScVbaWorkbooks : public ScVbaWorkbooks_BASE
+{
+private:
+ rtl::OUString getFileFilterType( const rtl::OUString& rString );
+ bool isTextFile( const rtl::OUString& rString );
+ bool isSpreadSheetFile( const rtl::OUString& rString );
+ static sal_Int16& getCurrentDelim(){ static sal_Int16 nDelim = 44; return nDelim; }
+public:
+ ScVbaWorkbooks( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
+ virtual ~ScVbaWorkbooks() {}
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+ // ScVbaWorkbooks_BASE
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+ // XWorkbooks
+ virtual css::uno::Any SAL_CALL Add() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Close( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& UpdateLinks, const css::uno::Any& ReadOnly, const css::uno::Any& Format, const css::uno::Any& Password, const css::uno::Any& WriteResPassword, const css::uno::Any& IgnoreReadOnlyRecommended, const css::uno::Any& Origin, const css::uno::Any& Delimiter, const css::uno::Any& Editable, const css::uno::Any& Notify, const css::uno::Any& Converter, const css::uno::Any& AddToMru ) throw (css::uno::RuntimeException);
+
+ // VbaDocumentsBase / XDocumentsBase (to avoid warning C4266 for hiding function on wntmsci)
+ virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException);
+};
+
+#endif /* SC_VBA_WORKBOOKS_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheet.cxx b/sc/source/ui/vba/vbaworksheet.cxx
new file mode 100644
index 000000000000..ca00ef9ee495
--- /dev/null
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -0,0 +1,1112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <vbahelper/helperdecl.hxx>
+#include <cppuhelper/queryinterface.hxx>
+
+#include "vbaworksheet.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/util/XProtectable.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XCalculatable.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XSheetCellRange.hpp>
+#include <com/sun/star/sheet/XSheetCellCursor.hpp>
+#include <com/sun/star/sheet/XSheetAnnotationsSupplier.hpp>
+#include <com/sun/star/sheet/XUsedAreaCursor.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/sheet/XSheetPastable.hpp>
+#include <com/sun/star/sheet/XCellAddressable.hpp>
+#include <com/sun/star/sheet/XSheetOutline.hpp>
+#include <com/sun/star/sheet/XSheetPageBreak.hpp>
+#include <com/sun/star/sheet/XDataPilotTablesSupplier.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XTableChartsSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <ooo/vba/excel/XlEnableSelection.hpp>
+#include <ooo/vba/excel/XWorkbook.hpp>
+#include <ooo/vba/XControlProvider.hpp>
+#include <ooo/vba/excel/XlSheetVisibility.hpp>
+
+#include <comphelper/processfactory.hxx>
+#include <vbahelper/vbashapes.hxx>
+
+#include <tools/string.hxx>
+
+//zhangyun showdataform
+#include <sfx2/sfxdlg.hxx>
+#include "scabstdlg.hxx"
+#include "tabvwsh.hxx"
+#include "scitems.hxx"
+
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+
+#include "cellsuno.hxx"
+#include "drwlayer.hxx"
+#include "tabprotection.hxx"
+#include "scextopt.hxx"
+#include "vbaoutline.hxx"
+#include "vbarange.hxx"
+#include "vbacomments.hxx"
+#include "vbachartobjects.hxx"
+#include "vbapivottables.hxx"
+#include "vbaoleobject.hxx"
+#include "vbaoleobjects.hxx"
+#include "vbapagesetup.hxx"
+#include "vbapagebreaks.hxx"
+#include "vbaworksheets.hxx"
+#include "vbahyperlinks.hxx"
+#include "vbasheetobjects.hxx"
+#include "viewuno.hxx" //liuchen 2009-9-2
+
+#define STANDARDWIDTH 2267
+#define STANDARDHEIGHT 427
+#define DOESNOTEXIST -1
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+static void getNewSpreadsheetName (rtl::OUString &aNewName, rtl::OUString aOldName, uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc )
+{
+ if (!xSpreadDoc.is())
+ throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getNewSpreadsheetName() xSpreadDoc is null" ) ), uno::Reference< uno::XInterface >(), 1 );
+ static rtl::OUString aUnderScre( RTL_CONSTASCII_USTRINGPARAM( "_" ) );
+ int currentNum =2;
+ aNewName = aOldName + aUnderScre+ String::CreateFromInt32(currentNum) ;
+ SCTAB nTab = 0;
+ while ( ScVbaWorksheets::nameExists(xSpreadDoc,aNewName, nTab ) )
+ {
+ aNewName = aOldName + aUnderScre +
+ String::CreateFromInt32(++currentNum) ;
+ }
+}
+
+static void removeAllSheets( uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc, rtl::OUString aSheetName)
+{
+ if (!xSpreadDoc.is())
+ throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "removeAllSheets() xSpreadDoc is null" ) ), uno::Reference< uno::XInterface >(), 1 );
+ uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
+ uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY );
+
+ if ( xIndex.is() )
+ {
+ uno::Reference<container::XNameContainer> xNameContainer(xSheets,uno::UNO_QUERY_THROW);
+ for (sal_Int32 i = xIndex->getCount() -1; i>= 1; i--)
+ {
+ uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(i), uno::UNO_QUERY);
+ uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
+ if (xNamed.is())
+ {
+ xNameContainer->removeByName(xNamed->getName());
+ }
+ }
+
+ uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(0), uno::UNO_QUERY);
+ uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
+ if (xNamed.is())
+ {
+ xNamed->setName(aSheetName);
+ }
+ }
+}
+
+static uno::Reference<frame::XModel>
+openNewDoc(rtl::OUString aSheetName )
+{
+ uno::Reference<frame::XModel> xModel;
+ try
+ {
+ uno::Reference< beans::XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XComponentContext > xContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), uno::UNO_QUERY_THROW );
+ uno::Reference<lang::XMultiComponentFactory > xServiceManager(
+ xContext->getServiceManager(), uno::UNO_QUERY_THROW );
+
+ uno::Reference <frame::XComponentLoader > xComponentLoader(
+ xServiceManager->createInstanceWithContext(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ),
+ xContext ), uno::UNO_QUERY_THROW );
+
+ uno::Reference<lang::XComponent > xComponent( xComponentLoader->loadComponentFromURL(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/scalc" ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), 0,
+ uno::Sequence < ::com::sun::star::beans::PropertyValue >() ) );
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( xComponent, uno::UNO_QUERY_THROW );
+ if ( xSpreadDoc.is() )
+ {
+ removeAllSheets(xSpreadDoc,aSheetName);
+ }
+ xModel.set(xSpreadDoc,uno::UNO_QUERY_THROW);
+ }
+ catch ( uno::Exception & /*e*/ )
+ {
+ }
+ return xModel;
+}
+
+ScVbaWorksheet::ScVbaWorksheet( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext ) : WorksheetImpl_BASE( xParent, xContext )
+{
+}
+
+ScVbaWorksheet::ScVbaWorksheet(const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< sheet::XSpreadsheet >& xSheet,
+ const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) : WorksheetImpl_BASE( xParent, xContext ), mxSheet( xSheet ), mxModel(xModel)
+{
+}
+
+ScVbaWorksheet::ScVbaWorksheet( uno::Sequence< uno::Any> const & args,
+ uno::Reference< uno::XComponentContext> const & xContext ) throw ( lang::IllegalArgumentException ) : WorksheetImpl_BASE( getXSomethingFromArgs< XHelperInterface >( args, 0 ), xContext ), mxModel( getXSomethingFromArgs< frame::XModel >( args, 1 ) )
+{
+ if ( args.getLength() < 2 )
+ throw lang::IllegalArgumentException();
+
+ rtl::OUString sSheetName;
+ args[2] >>= sSheetName;
+
+ uno::Reference< sheet::XSpreadsheetDocument > xSpreadDoc( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNameAccess > xNameAccess( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
+ mxSheet.set( xNameAccess->getByName( sSheetName ), uno::UNO_QUERY_THROW );
+}
+
+ScVbaWorksheet::~ScVbaWorksheet()
+{
+}
+
+::rtl::OUString
+ScVbaWorksheet::getName() throw (uno::RuntimeException)
+{
+ uno::Reference< container::XNamed > xNamed( getSheet(), uno::UNO_QUERY_THROW );
+ return xNamed->getName();
+}
+
+void
+ScVbaWorksheet::setName(const ::rtl::OUString &rName ) throw (uno::RuntimeException)
+{
+ uno::Reference< container::XNamed > xNamed( getSheet(), uno::UNO_QUERY_THROW );
+ xNamed->setName( rName );
+}
+
+::sal_Int32
+ScVbaWorksheet::getVisible() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Any aValue = xProps->getPropertyValue
+ (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ) );
+ sal_Bool bRet = false;
+ aValue >>= bRet;
+ if ( bRet )
+ {
+ return excel::XlSheetVisibility::xlSheetVisible;
+ }
+ else
+ {
+ return excel::XlSheetVisibility::xlSheetHidden;
+ }
+}
+
+void
+ScVbaWorksheet::setVisible( ::sal_Int32 _Visible ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xProps( getSheet(), uno::UNO_QUERY_THROW );
+
+ //VBA by minz@cn.ibm.com.
+ sal_Bool bVisible = true;
+ switch( _Visible )
+ {
+ case excel::XlSheetVisibility::xlSheetHidden:
+ case excel::XlSheetVisibility::xlSheetVeryHidden:
+ bVisible = false;
+ break;
+ case excel::XlSheetVisibility::xlSheetVisible:
+ bVisible = true;
+ break;
+ }
+ uno::Any aValue( bVisible );
+ xProps->setPropertyValue
+ (rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsVisible" ) ), aValue);
+}
+
+sal_Int16
+ScVbaWorksheet::getIndex() throw (uno::RuntimeException)
+{
+ return getSheetID() + 1;
+}
+
+sal_Int32
+ScVbaWorksheet::getEnableSelection() throw (uno::RuntimeException)
+{
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ SCTAB nTab = 0;
+ if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
+ {
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ sal_Bool bLockedCells = sal_False;
+ sal_Bool bUnlockedCells = sal_False;
+ if( pProtect )
+ {
+ bLockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bUnlockedCells = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+ if( bLockedCells )
+ return excel::XlEnableSelection::xlNoRestrictions;
+ if( bUnlockedCells )
+ return excel::XlEnableSelection::xlUnlockedCells;
+ return excel::XlEnableSelection::xlNoSelection;
+ }
+ else
+ throw uno::RuntimeException(::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ),
+ uno::Reference< XInterface >() );
+ return excel::XlEnableSelection::xlNoSelection;
+}
+
+
+void
+ScVbaWorksheet::setEnableSelection( sal_Int32 nSelection ) throw (uno::RuntimeException)
+{
+ if( (nSelection != excel::XlEnableSelection::xlNoRestrictions) &&
+ (nSelection != excel::XlEnableSelection::xlUnlockedCells) &&
+ (nSelection != excel::XlEnableSelection::xlNoSelection) )
+ {
+ DebugHelper::exception(SbERR_BAD_PARAMETER, rtl::OUString() );
+ }
+
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ SCTAB nTab = 0;
+ if ( ScVbaWorksheets::nameExists(xSpreadDoc, getName(), nTab) )
+ {
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ // default is xlNoSelection
+ sal_Bool bLockedCells = sal_False;
+ sal_Bool bUnlockedCells = sal_False;
+ if( nSelection == excel::XlEnableSelection::xlNoRestrictions )
+ {
+ bLockedCells = sal_True;
+ bUnlockedCells = sal_True;
+ }
+ else if( nSelection == excel::XlEnableSelection::xlUnlockedCells )
+ {
+ bUnlockedCells = sal_True;
+ }
+ if( pProtect )
+ {
+ pProtect->setOption( ScTableProtection::SELECT_LOCKED_CELLS, bLockedCells );
+ pProtect->setOption( ScTableProtection::SELECT_UNLOCKED_CELLS, bUnlockedCells );
+ }
+ }
+ else
+ throw uno::RuntimeException(::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "Sheet Name does not exist. ") ),
+ uno::Reference< XInterface >() );
+
+}
+
+uno::Reference< beans::XPropertySet > ScVbaWorksheet::getFirstDBRangeProperties() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xModelProps( mxModel, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xDBRangesIA( xModelProps->getPropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DatabaseRanges" ) ) ), uno::UNO_QUERY_THROW );
+
+ for( sal_Int32 nIndex = 0, nCount = xDBRangesIA->getCount(); nIndex < nCount; ++nIndex )
+ {
+ uno::Reference< sheet::XCellRangeReferrer > xDBRange( xDBRangesIA->getByIndex( nIndex ), uno::UNO_QUERY_THROW );
+ // check if the database area is on this sheet
+ uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( xDBRange->getReferredCells(), uno::UNO_QUERY_THROW );
+ if( getSheetID() == xRangeAddr->getRangeAddress().Sheet )
+ return uno::Reference< beans::XPropertySet >( xDBRange, uno::UNO_QUERY_THROW );
+ }
+ return uno::Reference< beans::XPropertySet >();
+}
+
+sal_Bool SAL_CALL ScVbaWorksheet::getAutoFilterMode() throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties();
+ sal_Bool bAutoFilterMode = sal_False;
+ return
+ xDBRangeProps.is() &&
+ (xDBRangeProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ) ) >>= bAutoFilterMode) &&
+ bAutoFilterMode;
+}
+
+void SAL_CALL ScVbaWorksheet::setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xDBRangeProps = getFirstDBRangeProperties();
+ if( xDBRangeProps.is() )
+ xDBRangeProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AutoFilter" ) ), uno::Any( bAutoFilterMode ) );
+}
+
+uno::Reference< excel::XRange >
+ScVbaWorksheet::getUsedRange() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetCellRange > xSheetCellRange(getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor( getSheet()->createCursorByRange( xSheetCellRange ), uno::UNO_QUERY_THROW );
+ uno::Reference<sheet::XUsedAreaCursor> xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
+ xUsedCursor->gotoStartOfUsedArea( false );
+ xUsedCursor->gotoEndOfUsedArea( true );
+ uno::Reference< table::XCellRange > xRange( xSheetCellCursor, uno::UNO_QUERY);
+ return new ScVbaRange(this, mxContext, xRange);
+}
+
+uno::Reference< excel::XOutline >
+ScVbaWorksheet::Outline( ) throw (uno::RuntimeException)
+{
+ uno::Reference<sheet::XSheetOutline> xOutline(getSheet(),uno::UNO_QUERY_THROW);
+ return new ScVbaOutline( this, mxContext, xOutline);
+}
+
+uno::Reference< excel::XPageSetup >
+ScVbaWorksheet::PageSetup( ) throw (uno::RuntimeException)
+{
+ return new ScVbaPageSetup( this, mxContext, getSheet(), getModel() );
+}
+
+uno::Any
+ScVbaWorksheet::HPageBreaks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak(getSheet(),uno::UNO_QUERY_THROW);
+ uno::Reference< excel::XHPageBreaks > xHPageBreaks( new ScVbaHPageBreaks( this, mxContext, xSheetPageBreak));
+ if ( aIndex.hasValue() )
+ return xHPageBreaks->Item( aIndex, uno::Any());
+ return uno::makeAny( xHPageBreaks );
+}
+
+uno::Any
+ScVbaWorksheet::VPageBreaks( const uno::Any& aIndex ) throw ( uno::RuntimeException )
+{
+ uno::Reference< sheet::XSheetPageBreak > xSheetPageBreak( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XVPageBreaks > xVPageBreaks( new ScVbaVPageBreaks( this, mxContext, xSheetPageBreak ) );
+ if( aIndex.hasValue() )
+ return xVPageBreaks->Item( aIndex, uno::Any());
+ return uno::makeAny( xVPageBreaks );
+}
+
+sal_Int32
+ScVbaWorksheet::getStandardWidth() throw (uno::RuntimeException)
+{
+ return STANDARDWIDTH ;
+}
+
+sal_Int32
+ScVbaWorksheet::getStandardHeight() throw (uno::RuntimeException)
+{
+ return STANDARDHEIGHT;
+}
+
+sal_Bool
+ScVbaWorksheet::getProtectionMode() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+sal_Bool
+ScVbaWorksheet::getProtectContents()throw (uno::RuntimeException)
+{
+ uno::Reference<util::XProtectable > xProtectable(getSheet(), uno::UNO_QUERY_THROW);
+ return xProtectable->isProtected();
+}
+
+sal_Bool
+ScVbaWorksheet::getProtectDrawingObjects() throw (uno::RuntimeException)
+{
+ SCTAB nTab = 0;
+ rtl::OUString aSheetName = getName();
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ bool bSheetExists = ScVbaWorksheets::nameExists (xSpreadDoc, aSheetName, nTab);
+ if ( bSheetExists )
+ {
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScDocument* pDoc = excel::getDocShell( xModel )->GetDocument();
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if ( pProtect )
+ return pProtect->isOptionEnabled( ScTableProtection::OBJECTS );
+ }
+ return sal_False;
+}
+
+sal_Bool
+ScVbaWorksheet::getProtectScenarios() throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+void
+ScVbaWorksheet::Activate() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
+ getModel()->getCurrentController(), uno::UNO_QUERY_THROW );
+ xSpreadsheet->setActiveSheet(getSheet());
+}
+
+//liuchen 2009-9-2, support expand (but not replace) the active sheet
+void
+ScVbaWorksheet::Select(const css::uno::Any& aReplace) throw (uno::RuntimeException)
+{
+ sal_Bool bReplace = true;
+ if (aReplace.hasValue() && aReplace.getValueTypeClass() == uno::TypeClass_BOOLEAN)
+ {
+ aReplace >>= bReplace;
+ }
+
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheet(
+ getModel()->getCurrentController(), uno::UNO_QUERY_THROW );
+ ScTabViewObj* pTabView = static_cast< ScTabViewObj* >( xSpreadsheet.get() );
+
+ if (bReplace)
+ {
+ pTabView->selectSheet(getSheet(), false);
+ }
+ else
+ {
+ uno::Reference< sheet::XSpreadsheet > xOldActiveSheet = pTabView->getActiveSheet();
+ pTabView->selectSheet(getSheet(), true);
+ pTabView->selectSheet(xOldActiveSheet, true);
+ }
+}
+
+void
+ScVbaWorksheet::Move( const uno::Any& Before, const uno::Any& After ) throw (uno::RuntimeException)
+{
+ uno::Reference<excel::XWorksheet> xSheet;
+ rtl::OUString aCurrSheetName = getName();
+
+ if (!(Before >>= xSheet) && !(After >>=xSheet)&& !(Before.hasValue()) && !(After.hasValue()))
+ {
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = getSheet()->createCursor( );
+ uno::Reference<sheet::XUsedAreaCursor> xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
+ uno::Reference< table::XCellRange > xRange1( xSheetCellCursor, uno::UNO_QUERY);
+ // #FIXME needs worksheet as parent
+ uno::Reference<excel::XRange> xRange = new ScVbaRange( this, mxContext, xRange1);
+ if (xRange.is())
+ xRange->Select();
+ excel::implnCopy(mxModel);
+ uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName);
+ if (xModel.is())
+ {
+ excel::implnPaste(xModel);
+ Delete();
+ }
+ return ;
+ }
+
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ SCTAB nDest = 0;
+ if ( ScVbaWorksheets::nameExists (xSpreadDoc, xSheet->getName(), nDest) )
+ {
+ sal_Bool bAfter = After.hasValue();
+ if (bAfter)
+ nDest++;
+ uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
+ xSheets->moveByName(aCurrSheetName,nDest);
+ }
+}
+
+void
+ScVbaWorksheet::Copy( const uno::Any& Before, const uno::Any& After ) throw (uno::RuntimeException)
+{
+ uno::Reference<excel::XWorksheet> xSheet;
+ rtl::OUString aCurrSheetName =getName();
+ if (!(Before >>= xSheet) && !(After >>=xSheet)&& !(Before.hasValue()) && !(After.hasValue()))
+ {
+ uno::Reference< sheet::XSheetCellCursor > xSheetCellCursor = getSheet()->createCursor( );
+ uno::Reference<sheet::XUsedAreaCursor> xUsedCursor(xSheetCellCursor,uno::UNO_QUERY_THROW);
+ uno::Reference< table::XCellRange > xRange1( xSheetCellCursor, uno::UNO_QUERY);
+ uno::Reference<excel::XRange> xRange = new ScVbaRange( this, mxContext, xRange1);
+ if (xRange.is())
+ xRange->Select();
+ excel::implnCopy(mxModel);
+ uno::Reference<frame::XModel> xModel = openNewDoc(aCurrSheetName);
+ if (xModel.is())
+ {
+ excel::implnPaste(xModel);
+ }
+ return;
+ }
+
+ ScVbaWorksheet* pDestSheet = static_cast< ScVbaWorksheet* >(xSheet.get());
+ uno::Reference <sheet::XSpreadsheetDocument> xDestDoc( pDestSheet->getModel(), uno::UNO_QUERY );
+ uno::Reference <sheet::XSpreadsheetDocument> xSrcDoc( getModel(), uno::UNO_QUERY );
+
+ SCTAB nDest = 0;
+ SCTAB nSrc = 0;
+ rtl::OUString aSheetName = xSheet->getName();
+ bool bSameDoc = ( pDestSheet->getModel() == getModel() );
+ bool bDestSheetExists = ScVbaWorksheets::nameExists (xDestDoc, aSheetName, nDest );
+ bool bSheetExists = ScVbaWorksheets::nameExists (xSrcDoc, aCurrSheetName, nSrc );
+
+ // set sheet name to be newSheet name
+ aSheetName = aCurrSheetName;
+ SCTAB nDummy=0;
+ if ( bSheetExists && bDestSheetExists )
+ {
+ sal_Bool bAfter = After.hasValue();
+ if(bAfter)
+ nDest++;
+ uno::Reference<sheet::XSpreadsheets> xSheets = xDestDoc->getSheets();
+ if ( bSameDoc || ScVbaWorksheets::nameExists( xDestDoc, aCurrSheetName, nDummy ) )
+ getNewSpreadsheetName(aSheetName,aCurrSheetName,xDestDoc);
+ if ( bSameDoc )
+ xSheets->copyByName(aCurrSheetName,aSheetName,nDest);
+ else
+ {
+ ScDocShell* pDestDocShell = excel::getDocShell( pDestSheet->getModel() );
+ ScDocShell* pSrcDocShell = excel::getDocShell( getModel() );
+ if ( pDestDocShell && pSrcDocShell )
+ pDestDocShell->TransferTab( *pSrcDocShell, static_cast<SCTAB>(nSrc), static_cast<SCTAB>(nDest), TRUE, TRUE );
+ }
+ }
+ // active the new sheet
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ uno::Reference< excel::XWorksheet > xNewSheet( xApplication->Worksheets( uno::makeAny( aSheetName ) ), uno::UNO_QUERY_THROW );
+ xNewSheet->Activate();
+}
+
+
+void
+ScVbaWorksheet::Paste( const uno::Any& Destination, const uno::Any& /*Link*/ ) throw (uno::RuntimeException)
+{
+ // #TODO# #FIXME# Link is not used
+ uno::Reference<excel::XRange> xRange( Destination, uno::UNO_QUERY );
+ if ( xRange.is() )
+ xRange->Select();
+ excel::implnPaste( mxModel );
+}
+
+void
+ScVbaWorksheet::Delete() throw (uno::RuntimeException)
+{
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ rtl::OUString aSheetName = getName();
+ if ( xSpreadDoc.is() )
+ {
+ SCTAB nTab = 0;
+ if (!ScVbaWorksheets::nameExists(xSpreadDoc, aSheetName, nTab ))
+ {
+ return;
+ }
+ uno::Reference<sheet::XSpreadsheets> xSheets = xSpreadDoc->getSheets();
+ uno::Reference<container::XNameContainer> xNameContainer(xSheets,uno::UNO_QUERY_THROW);
+ xNameContainer->removeByName(aSheetName);
+ mxSheet.clear();
+ }
+}
+
+uno::Reference< excel::XWorksheet >
+ScVbaWorksheet::getSheetAtOffset(SCTAB offset) throw (uno::RuntimeException)
+{
+ uno::Reference <sheet::XSpreadsheetDocument> xSpreadDoc( getModel(), uno::UNO_QUERY_THROW );
+ uno::Reference <sheet::XSpreadsheets> xSheets( xSpreadDoc->getSheets(), uno::UNO_QUERY_THROW );
+ uno::Reference <container::XIndexAccess> xIndex( xSheets, uno::UNO_QUERY_THROW );
+
+ SCTAB nIdx = 0;
+ if ( !ScVbaWorksheets::nameExists (xSpreadDoc, getName(), nIdx ) )
+ return uno::Reference< excel::XWorksheet >();
+ nIdx = nIdx + offset;
+ uno::Reference< sheet::XSpreadsheet > xSheet(xIndex->getByIndex(nIdx), uno::UNO_QUERY_THROW);
+ // parent will be the parent of 'this' worksheet
+ return new ScVbaWorksheet (getParent(), mxContext, xSheet, getModel());
+}
+
+uno::Reference< excel::XWorksheet >
+ScVbaWorksheet::getNext() throw (uno::RuntimeException)
+{
+ //VBA, minz@cn.ibm.com. catch the exception for index out of bound
+ try{
+ return getSheetAtOffset(static_cast<SCTAB>(1));
+ }catch( lang::IndexOutOfBoundsException& /*e*/ )
+ {
+ return NULL;
+ }
+}
+
+uno::Reference< excel::XWorksheet >
+ScVbaWorksheet::getPrevious() throw (uno::RuntimeException)
+{
+ //VBA, minz@cn.ibm.com. catch the exception for index out of bound
+ try{
+ return getSheetAtOffset(-1);
+ }catch( lang::IndexOutOfBoundsException& /*e*/ )
+ {
+ return NULL;
+ }
+}
+
+
+void
+ScVbaWorksheet::Protect( const uno::Any& Password, const uno::Any& /*DrawingObjects*/, const uno::Any& /*Contents*/, const uno::Any& /*Scenarios*/, const uno::Any& /*UserInterfaceOnly*/ ) throw (uno::RuntimeException)
+{
+ // #TODO# #FIXME# is there anything we can do witht the unused param
+ // can the implementation use anything else here
+ uno::Reference<util::XProtectable > xProtectable(getSheet(), uno::UNO_QUERY_THROW);
+ ::rtl::OUString aPasswd;
+ Password >>= aPasswd;
+ xProtectable->protect( aPasswd );
+}
+
+void
+ScVbaWorksheet::Unprotect( const uno::Any& Password ) throw (uno::RuntimeException)
+{
+ uno::Reference<util::XProtectable > xProtectable(getSheet(), uno::UNO_QUERY_THROW);
+ ::rtl::OUString aPasswd;
+ Password >>= aPasswd;
+ xProtectable->unprotect( aPasswd );
+}
+
+void
+ScVbaWorksheet::Calculate() throw (uno::RuntimeException)
+{
+ uno::Reference <sheet::XCalculatable> xReCalculate(getModel(), uno::UNO_QUERY_THROW);
+ xReCalculate->calculate();
+}
+
+uno::Reference< excel::XRange >
+ScVbaWorksheet::Range( const ::uno::Any& Cell1, const ::uno::Any& Cell2 ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XRange > xSheetRange( new ScVbaRange( this, mxContext
+, uno::Reference< table::XCellRange >( getSheet(), uno::UNO_QUERY_THROW ) ) );
+ return xSheetRange->Range( Cell1, Cell2 );
+}
+
+void
+ScVbaWorksheet::CheckSpelling( const uno::Any& /*CustomDictionary*/,const uno::Any& /*IgnoreUppercase*/,const uno::Any& /*AlwaysSuggest*/, const uno::Any& /*SpellingLang*/ ) throw (uno::RuntimeException)
+{
+ // #TODO# #FIXME# unused params above, can we do anything with those
+ rtl::OUString url = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SpellDialog"));
+ uno::Reference< frame::XModel > xModel( getModel() );
+ dispatchRequests(xModel,url);
+}
+
+uno::Reference< excel::XRange >
+ScVbaWorksheet::getSheetRange() throw (uno::RuntimeException)
+{
+ uno::Reference< table::XCellRange > xRange( getSheet(),uno::UNO_QUERY_THROW );
+ return uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRange ) );
+}
+
+// These are hacks - we prolly (somehow) need to inherit
+// the vbarange functionality here ...
+uno::Reference< excel::XRange >
+ScVbaWorksheet::Cells( const ::uno::Any &nRow, const ::uno::Any &nCol )
+ throw (uno::RuntimeException)
+{
+ return getSheetRange()->Cells( nRow, nCol );
+}
+
+uno::Reference< excel::XRange >
+ScVbaWorksheet::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return getSheetRange()->Rows( aIndex );
+}
+
+uno::Reference< excel::XRange >
+ScVbaWorksheet::Columns( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ return getSheetRange()->Columns( aIndex );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::ChartObjects( const uno::Any& Index ) throw (uno::RuntimeException)
+{
+ if ( !mxCharts.is() )
+ {
+ uno::Reference< table::XTableChartsSupplier > xChartSupplier( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< table::XTableCharts > xTableCharts = xChartSupplier->getCharts();
+
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW ); //VBA, minz@cn.ibm.com.
+ mxCharts = new ScVbaChartObjects( this, mxContext, xTableCharts, xDrawPageSupplier );
+ }
+ if ( Index.hasValue() )
+ {
+ uno::Reference< XCollection > xColl( mxCharts, uno::UNO_QUERY_THROW );
+ return xColl->Item( Index, uno::Any() );
+ }
+ else
+ return uno::makeAny( mxCharts );
+
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::PivotTables( const uno::Any& Index ) throw (uno::RuntimeException)
+{
+ uno::Reference< css::sheet::XSpreadsheet > xSheet = getSheet();
+ uno::Reference< sheet::XDataPilotTablesSupplier > xTables(xSheet, uno::UNO_QUERY_THROW ) ;
+ uno::Reference< container::XIndexAccess > xIndexAccess( xTables->getDataPilotTables(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< XCollection > xColl( new ScVbaPivotTables( this, mxContext, xIndexAccess ) );
+ if ( Index.hasValue() )
+ return xColl->Item( Index, uno::Any() );
+ return uno::makeAny( xColl );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Comments( const uno::Any& Index ) throw (uno::RuntimeException)
+{
+ uno::Reference< css::sheet::XSpreadsheet > xSheet = getSheet();
+ uno::Reference< sheet::XSheetAnnotationsSupplier > xAnnosSupp( xSheet, uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XSheetAnnotations > xAnnos( xAnnosSupp->getAnnotations(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xAnnos, uno::UNO_QUERY_THROW );
+ uno::Reference< XCollection > xColl( new ScVbaComments( this, mxContext, mxModel, xIndexAccess ) );
+ if ( Index.hasValue() )
+ return xColl->Item( Index, uno::Any() );
+ return uno::makeAny( xColl );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Hyperlinks( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ /* The worksheet always returns the same Hyperlinks object.
+ See vbahyperlinks.hxx for more details. */
+ if( !mxHlinks.is() )
+ mxHlinks.set( new ScVbaHyperlinks( this, mxContext ) );
+ if( aIndex.hasValue() )
+ return uno::Reference< XCollection >( mxHlinks, uno::UNO_QUERY_THROW )->Item( aIndex, uno::Any() );
+ return uno::Any( mxHlinks );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Names( const css::uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< excel::XWorkbook > xWorkbook( getParent(), uno::UNO_QUERY_THROW );
+ return xWorkbook->Names( aIndex );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::OLEObjects( const uno::Any& Index ) throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPage, uno::UNO_QUERY_THROW );
+
+ uno::Reference< excel::XOLEObjects >xOleObjects( new ScVbaOLEObjects( this, mxContext, xIndexAccess ) );
+ if( Index.hasValue() )
+ return xOleObjects->Item( Index, uno::Any() );
+ return uno::Any( xOleObjects );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Shapes( const uno::Any& aIndex ) throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XShapes > xShapes( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xShapes, uno::UNO_QUERY_THROW );
+
+ uno::Reference< msforms::XShapes> xVbaShapes( new ScVbaShapes( this, mxContext, xIndexAccess, getModel() ) );
+ if ( aIndex.hasValue() )
+ return xVbaShapes->Item( aIndex, uno::Any() );
+ return uno::makeAny( xVbaShapes );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Buttons( const uno::Any& rIndex ) throw (uno::RuntimeException)
+{
+ if( !mxButtons.is() )
+ mxButtons.set( new ScVbaButtons( this, mxContext, mxModel, mxSheet ) );
+ else
+ mxButtons->collectShapes();
+ if( rIndex.hasValue() )
+ return mxButtons->Item( rIndex, uno::Any() );
+ return uno::Any( uno::Reference< XCollection >( mxButtons.get() ) );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::CheckBoxes( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::DropDowns( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::GroupBoxes( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Labels( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::ListBoxes( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::OptionButtons( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::ScrollBars( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Spinners( const uno::Any& /*rIndex*/ ) throw (uno::RuntimeException)
+{
+ throw uno::RuntimeException();
+}
+
+void SAL_CALL
+ScVbaWorksheet::ShowDataForm( ) throw (uno::RuntimeException)
+{
+#ifdef VBA_OOBUILD_HACK
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ ScTabViewShell* pTabViewShell = excel::getBestViewShell( xModel );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ pDlg->Execute();
+#else
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+#endif
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::Evaluate( const ::rtl::OUString& Name ) throw (uno::RuntimeException)
+{
+ // #TODO Evaluate allows other things to be evaluated, e.g. functions
+ // I think ( like SIN(3) etc. ) need to investigate that
+ // named Ranges also? e.g. [MyRange] if so need a list of named ranges
+ uno::Any aVoid;
+ return uno::Any( Range( uno::Any( Name ), aVoid ) );
+}
+
+
+uno::Reference< beans::XIntrospectionAccess > SAL_CALL
+ScVbaWorksheet::getIntrospection( ) throw (uno::RuntimeException)
+{
+ return uno::Reference< beans::XIntrospectionAccess >();
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheet::invoke( const ::rtl::OUString& aFunctionName, const uno::Sequence< uno::Any >& /*aParams*/, uno::Sequence< ::sal_Int16 >& /*aOutParamIndex*/, uno::Sequence< uno::Any >& /*aOutParam*/ ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+{
+ OSL_TRACE("** ScVbaWorksheet::invoke( %s ), will barf",
+ rtl::OUStringToOString( aFunctionName, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ throw uno::RuntimeException(); // unsupported operation
+}
+
+void SAL_CALL
+ScVbaWorksheet::setValue( const ::rtl::OUString& aPropertyName, const uno::Any& aValue ) throw (beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+{
+ setDefaultPropByIntrospection( uno::makeAny( getValue( aPropertyName ) ), aValue );
+}
+uno::Any SAL_CALL
+ScVbaWorksheet::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::UnknownPropertyException, uno::RuntimeException)
+{
+ uno::Reference< drawing::XControlShape > xControlShape( getControlShape( aPropertyName ), uno::UNO_QUERY_THROW );
+
+ uno::Reference<lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< XControlProvider > xControlProvider( xServiceManager->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.ControlProvider" ) ), mxContext ), uno::UNO_QUERY_THROW );
+ uno::Reference< msforms::XControl > xControl( xControlProvider->createControl( xControlShape, getModel() ) );
+ return uno::makeAny( xControl );
+}
+
+::sal_Bool SAL_CALL
+ScVbaWorksheet::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::RuntimeException)
+{
+ return sal_False;
+}
+
+uno::Reference< container::XNameAccess >
+ScVbaWorksheet::getFormControls()
+{
+ uno::Reference< container::XNameAccess > xFormControls;
+ try
+ {
+ uno::Reference< sheet::XSpreadsheet > xSpreadsheet( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( xSpreadsheet, uno::UNO_QUERY_THROW );
+ uno::Reference< form::XFormsSupplier > xFormSupplier( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xFormSupplier->getForms(), uno::UNO_QUERY_THROW );
+ // get the www-standard container ( maybe we should access the
+ // 'www-standard' by name rather than index, this seems an
+ // implementation detail
+ xFormControls.set( xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW );
+
+ }
+ catch( uno::Exception& )
+ {
+ }
+ return xFormControls;
+
+ }
+::sal_Bool SAL_CALL
+ScVbaWorksheet::hasProperty( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+{
+ uno::Reference< container::XNameAccess > xFormControls( getFormControls() );
+ if ( xFormControls.is() )
+ return xFormControls->hasByName( aName );
+ return sal_False;
+}
+
+uno::Any
+ScVbaWorksheet::getControlShape( const ::rtl::OUString& sName )
+{
+ // ideally we would get an XControl object but it appears an XControl
+ // implementation only exists for a Control implementation optained from the
+ // view ( e.g. in basic you would get this from
+ // thiscomponent.currentcontroller.getControl( controlModel ) )
+ // and the thing to realise is that it is only possible to get an XControl
+ // for a currently displayed control :-( often we would want to modify
+ // a control not on the active sheet. But.. you can always access the
+ // XControlShape from the DrawPage whether that is the active drawpage or not
+
+ uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier( getSheet(), uno::UNO_QUERY_THROW );
+ uno::Reference< container::XIndexAccess > xIndexAccess( xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY_THROW );
+
+ sal_Int32 nCount = xIndexAccess->getCount();
+ for( int index = 0; index < nCount; index++ )
+ {
+ uno::Any aUnoObj = xIndexAccess->getByIndex( index );
+ // It seems there are some drawing objects that can not query into Control shapes?
+ uno::Reference< drawing::XControlShape > xControlShape( aUnoObj, uno::UNO_QUERY );
+ if( xControlShape.is() )
+ {
+ uno::Reference< container::XNamed > xNamed( xControlShape->getControl(), uno::UNO_QUERY_THROW );
+ if( sName.equals( xNamed->getName() ))
+ {
+ return aUnoObj;
+ }
+ }
+ }
+ return uno::Any();
+}
+
+
+rtl::OUString&
+ScVbaWorksheet::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorksheet") );
+ return sImplName;
+}
+void SAL_CALL
+ScVbaWorksheet::setEnableCalculation( ::sal_Bool bEnableCalculation ) throw ( script::BasicErrorException, uno::RuntimeException)
+{
+ uno::Reference <sheet::XCalculatable> xCalculatable(getModel(), uno::UNO_QUERY_THROW);
+ xCalculatable->enableAutomaticCalculation( bEnableCalculation);
+}
+::sal_Bool SAL_CALL
+ScVbaWorksheet::getEnableCalculation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException)
+{
+ uno::Reference <sheet::XCalculatable> xCalculatable(getModel(), uno::UNO_QUERY_THROW);
+ return xCalculatable->isAutomaticCalculationEnabled();
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaWorksheet::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheet" ) );
+ }
+ return aServiceNames;
+}
+
+rtl::OUString SAL_CALL
+ScVbaWorksheet::getCodeName() throw (css::uno::RuntimeException)
+{
+ uno::Reference< beans::XPropertySet > xSheetProp( mxSheet, uno::UNO_QUERY_THROW );
+ return xSheetProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CodeName" ) ) ).get< ::rtl::OUString >();
+}
+
+sal_Int16
+ScVbaWorksheet::getSheetID() throw (uno::RuntimeException)
+{
+ uno::Reference< sheet::XCellRangeAddressable > xAddressable( getSheet(), uno::UNO_QUERY_THROW ); //VBA. minz@cn.ibm.com. if ActiveSheet, mxSheet is null.
+ return xAddressable->getRangeAddress().Sheet;
+}
+
+void SAL_CALL
+ScVbaWorksheet::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName, const uno::Any& IgnorePrintAreas ) throw (uno::RuntimeException)
+{
+ sal_Int32 nTo = 0;
+ sal_Int32 nFrom = 0;
+ sal_Int16 nCopies = 1;
+ sal_Bool bCollate = sal_False;
+ sal_Bool bSelection = sal_False;
+ sal_Bool bIgnorePrintAreas = sal_False;
+ From >>= nFrom;
+ To >>= nTo;
+ Copies >>= nCopies;
+ IgnorePrintAreas >>= bIgnorePrintAreas;
+ if ( nCopies > 1 ) // Collate only useful when more that 1 copy
+ Collate >>= bCollate;
+
+ if ( !( nFrom || nTo ) )
+ bSelection = sal_True;
+
+ uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW );
+ PrintOutHelper( excel::getBestViewShell( xModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
+}
+
+namespace worksheet
+{
+namespace sdecl = comphelper::service_decl;
+sdecl::vba_service_class_<ScVbaWorksheet, sdecl::with_args<true> > serviceImpl;
+extern sdecl::ServiceDecl const serviceDecl(
+ serviceImpl,
+ "ScVbaWorksheet",
+ "ooo.vba.excel.Worksheet" );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheet.hxx b/sc/source/ui/vba/vbaworksheet.hxx
new file mode 100644
index 000000000000..b27bf99fd40a
--- /dev/null
+++ b/sc/source/ui/vba/vbaworksheet.hxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_WORKSHEET_HXX
+#define SC_VBA_WORKSHEET_HXX
+
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/unwrapargs.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <ooo/vba/excel/XWorksheet.hpp>
+#include <ooo/vba/excel/XComments.hpp>
+#include <ooo/vba/excel/XRange.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <ooo/vba/excel/XOutline.hpp>
+#include <ooo/vba/excel/XPageSetup.hpp>
+#include <ooo/vba/excel/XHPageBreaks.hpp>
+#include <ooo/vba/excel/XVPageBreaks.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+
+#include <vbahelper/vbahelperinterface.hxx>
+#include "address.hxx"
+
+namespace ooo { namespace vba { namespace excel {
+ class XChartObjects;
+ class XHyperlinks;
+} } }
+
+class ScVbaSheetObjectsBase;
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XWorksheet > WorksheetImpl_BASE;
+
+class ScVbaWorksheet : public WorksheetImpl_BASE
+{
+ css::uno::Reference< css::sheet::XSpreadsheet > mxSheet;
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< ov::excel::XChartObjects > mxCharts;
+ css::uno::Reference< ov::excel::XHyperlinks > mxHlinks;
+ ::rtl::Reference< ScVbaSheetObjectsBase > mxButtons;
+
+ css::uno::Reference< ov::excel::XWorksheet > getSheetAtOffset(SCTAB offset) throw (css::uno::RuntimeException);
+ css::uno::Reference< ov::excel::XRange > getSheetRange() throw (css::uno::RuntimeException);
+
+ css::uno::Reference< css::container::XNameAccess > getFormControls();
+ css::uno::Any getControlShape( const rtl::OUString& sName );
+
+ css::uno::Reference< css::beans::XPropertySet > getFirstDBRangeProperties() throw (css::uno::RuntimeException);
+
+protected:
+
+ ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext );
+public:
+ ScVbaWorksheet( const css::uno::Reference< ov::XHelperInterface >& xParent,
+ const css::uno::Reference< css::uno::XComponentContext >& xContext,
+ const css::uno::Reference< css::sheet::XSpreadsheet >& xSheet,
+ const css::uno::Reference< css::frame::XModel >& xModel )throw (css::uno::RuntimeException) ;
+ ScVbaWorksheet( css::uno::Sequence< css::uno::Any > const& aArgs, css::uno::Reference< css::uno::XComponentContext >const& xContext ) throw ( css::lang::IllegalArgumentException );
+
+ virtual ~ScVbaWorksheet();
+
+ virtual css::uno::Reference< css::frame::XModel > getModel()
+ { return mxModel; }
+ virtual css::uno::Reference< css::sheet::XSpreadsheet > getSheet()
+ { return mxSheet; }
+
+ // Attributes
+ virtual ::rtl::OUString SAL_CALL getName() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setName( const ::rtl::OUString &rName ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( ::sal_Int32 _Visible ) throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getStandardWidth() throw (css::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getStandardHeight() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getProtectionMode() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getProtectContents() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getProtectDrawingObjects() throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getProtectScenarios() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL getUsedRange() throw (css::uno::RuntimeException) ;
+ virtual css::uno::Any SAL_CALL ChartObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XOutline > SAL_CALL Outline( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XPageSetup > SAL_CALL PageSetup( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL HPageBreaks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL VPageBreaks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getNext() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XWorksheet > SAL_CALL getPrevious() throw (css::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getIndex() throw (css::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getEnableSelection() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setEnableSelection( sal_Int32 nSelection ) throw (css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoFilterMode() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setAutoFilterMode( sal_Bool bAutoFilterMode ) throw (css::uno::RuntimeException);
+
+ // Methods
+ virtual void SAL_CALL Activate() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Select(const css::uno::Any& aReplace) throw (css::uno::RuntimeException); //liuchen 2009-9-2, add the input parameter to support expand selection
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Move( const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException) ;
+ virtual void SAL_CALL Copy( const css::uno::Any& Before, const css::uno::Any& After ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Paste( const css::uno::Any& Destination, const css::uno::Any& Link ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Protect( const css::uno::Any& Password, const css::uno::Any& DrawingObjects, const css::uno::Any& Contents, const css::uno::Any& Scenarios, const css::uno::Any& UserInterfaceOnly ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Unprotect( const css::uno::Any& Password ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL Calculate( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL CheckSpelling( const css::uno::Any& CustomDictionary,const css::uno::Any& IgnoreUppercase,const css::uno::Any& AlwaysSuggest, const css::uno::Any& SpellingLang ) throw (css::uno::RuntimeException);
+ // Hacks (?)
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Cells( const css::uno::Any &nRow, const css::uno::Any &nCol ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Rows(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< ov::excel::XRange > SAL_CALL Columns(const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL Evaluate( const ::rtl::OUString& Name ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL PivotTables( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Comments( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Hyperlinks( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Names( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL OLEObjects( const css::uno::Any& Index ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Shapes( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL Buttons( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL CheckBoxes( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL DropDowns( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL GroupBoxes( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Labels( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL ListBoxes( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL OptionButtons( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL ScrollBars( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Spinners( const css::uno::Any& rIndex ) throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL setEnableCalculation( ::sal_Bool EnableCalculation ) throw ( css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getEnableCalculation( ) throw (css::script::BasicErrorException, css::uno::RuntimeException);
+ virtual void SAL_CALL ShowDataForm( ) throw (css::uno::RuntimeException);
+ // XInvocation
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const css::uno::Sequence< css::uno::Any >& aParams, css::uno::Sequence< ::sal_Int16 >& aOutParamIndex, css::uno::Sequence< css::uno::Any >& aOutParam ) throw (css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const css::uno::Any& aValue ) throw (css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (css::uno::RuntimeException);
+ // CodeName
+ virtual rtl::OUString SAL_CALL getCodeName() throw (css::uno::RuntimeException);
+ sal_Int16 getSheetID() throw (css::uno::RuntimeException);
+
+ virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName, const css::uno::Any& IgnorePrintAreas ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+
+#endif /* SC_VBA_WORKSHEET_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx
new file mode 100644
index 000000000000..5263b9a8ea34
--- /dev/null
+++ b/sc/source/ui/vba/vbaworksheets.cxx
@@ -0,0 +1,504 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "vbaworksheets.hxx"
+
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/itemwrapper.hxx>
+#include <svl/itemset.hxx>
+#include <svl/eitem.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/implbase3.hxx>
+
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <ooo/vba/excel/XApplication.hpp>
+#include <tools/string.hxx>
+#include "tabvwsh.hxx"
+
+#include "vbaglobals.hxx"
+#include "vbaworksheet.hxx"
+#include "vbaworkbook.hxx"
+#include "unonames.hxx"
+
+using namespace ::ooo::vba;
+using namespace ::com::sun::star;
+
+
+typedef ::cppu::WeakImplHelper1< container::XEnumeration > SheetEnumeration_BASE;
+typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess, container::XEnumerationAccess > SheetCollectionHelper_BASE;
+// a map ( or hashmap ) wont do as we need also to preserve the order
+// (as added ) of the items
+typedef std::vector< uno::Reference< sheet::XSpreadsheet > > SheetMap;
+
+
+// #FIXME #TODO the implementation of the Sheets collections sucks,
+// e.g. there is no support for tracking sheets added/removed from the collection
+
+uno::Reference< uno::XInterface >
+lcl_getModulAsUnoObject( const uno::Reference< sheet::XSpreadsheet >& xSheet, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException )
+{
+ uno::Reference< uno::XInterface > xRet;
+ if ( !xSheet.is() )
+ throw uno::RuntimeException();
+ uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW );
+ rtl::OUString sName;
+ xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= sName;
+
+ ScDocShell* pShell = excel::getDocShell( xModel );
+
+ if ( pShell )
+ xRet = getUnoDocModule( sName, pShell );
+ return xRet;
+}
+
+class WorkSheetsEnumeration : public SheetEnumeration_BASE
+{
+ SheetMap mSheetMap;
+ SheetMap::iterator mIt;
+public:
+ WorkSheetsEnumeration( const SheetMap& sMap ) : mSheetMap( sMap ), mIt( mSheetMap.begin() ) {}
+ virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException)
+ {
+ return ( mIt != mSheetMap.end() );
+ }
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasMoreElements() )
+ throw container::NoSuchElementException();
+ uno::Reference< sheet::XSpreadsheet > xSheet( *mIt++ );
+ return uno::makeAny( xSheet ) ;
+ }
+};
+
+class SheetCollectionHelper : public SheetCollectionHelper_BASE
+{
+ SheetMap mSheetMap;
+ SheetMap::iterator cachePos;
+public:
+ SheetCollectionHelper( const SheetMap& sMap ) : mSheetMap( sMap ), cachePos(mSheetMap.begin()) {}
+ // XElementAccess
+ virtual uno::Type SAL_CALL getElementType( ) throw (uno::RuntimeException) { return sheet::XSpreadsheet::static_type(0); }
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (uno::RuntimeException) { return ( mSheetMap.size() > 0 ); }
+ // XNameAcess
+ virtual uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if ( !hasByName(aName) )
+ throw container::NoSuchElementException();
+ return uno::makeAny( *cachePos );
+ }
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (uno::RuntimeException)
+ {
+ uno::Sequence< rtl::OUString > sNames( mSheetMap.size() );
+ rtl::OUString* pString = sNames.getArray();
+ SheetMap::iterator it = mSheetMap.begin();
+ SheetMap::iterator it_end = mSheetMap.end();
+
+ for ( ; it != it_end; ++it, ++pString )
+ {
+ uno::Reference< container::XNamed > xName( *it, uno::UNO_QUERY_THROW );
+ *pString = xName->getName();
+ }
+ return sNames;
+ }
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+ {
+ cachePos = mSheetMap.begin();
+ SheetMap::iterator it_end = mSheetMap.end();
+ for ( ; cachePos != it_end; ++cachePos )
+ {
+ uno::Reference< container::XNamed > xName( *cachePos, uno::UNO_QUERY_THROW );
+ if ( aName.equals( xName->getName() ) )
+ break;
+ }
+ return ( cachePos != it_end );
+ }
+
+ // XElementAccess
+ virtual ::sal_Int32 SAL_CALL getCount( ) throw (uno::RuntimeException) { return mSheetMap.size(); }
+ virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+ {
+ if ( Index < 0 || Index >= getCount() )
+ throw lang::IndexOutOfBoundsException();
+
+ return uno::makeAny( mSheetMap[ Index ] );
+
+ }
+ // XEnumerationAccess
+ virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration( ) throw (uno::RuntimeException)
+ {
+ return new WorkSheetsEnumeration( mSheetMap );
+ }
+};
+
+class SheetsEnumeration : public EnumerationHelperImpl
+{
+ uno::Reference< frame::XModel > m_xModel;
+public:
+ SheetsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ) {}
+
+ virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ uno::Reference< sheet::XSpreadsheet > xSheet( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
+ uno::Reference< uno::XInterface > xIf = lcl_getModulAsUnoObject( xSheet, m_xModel );
+ uno::Any aRet;
+ if ( !xIf.is() )
+ {
+ // if the Sheet is in a document created by the api unfortunately ( at the
+ // moment, it actually wont have the special Document modules
+ uno::Reference< excel::XWorksheet > xNewSheet( new ScVbaWorksheet( m_xParent, m_xContext, xSheet, m_xModel ) );
+ aRet <<= xNewSheet;
+ }
+ else
+ aRet <<= xIf;
+ return aRet;
+ }
+
+};
+
+ScVbaWorksheets::ScVbaWorksheets( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< container::XIndexAccess >& xSheets, const uno::Reference< frame::XModel >& xModel ): ScVbaWorksheets_BASE( xParent, xContext, xSheets ), mxModel( xModel ), m_xSheets( uno::Reference< sheet::XSpreadsheets >( xSheets, uno::UNO_QUERY ) )
+{
+}
+
+ScVbaWorksheets::ScVbaWorksheets( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext, const uno::Reference< container::XEnumerationAccess >& xEnumAccess, const uno::Reference< frame::XModel >& xModel ): ScVbaWorksheets_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( xEnumAccess, uno::UNO_QUERY ) ), mxModel(xModel)
+{
+}
+
+// XEnumerationAccess
+uno::Type
+ScVbaWorksheets::getElementType() throw (uno::RuntimeException)
+{
+ return excel::XWorksheet::static_type(0);
+}
+
+uno::Reference< container::XEnumeration >
+ScVbaWorksheets::createEnumeration() throw (uno::RuntimeException)
+{
+ if ( !m_xSheets.is() )
+ {
+ uno::Reference< container::XEnumerationAccess > xAccess( m_xIndexAccess, uno::UNO_QUERY_THROW );
+ return xAccess->createEnumeration();
+ }
+ uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xSheets, uno::UNO_QUERY_THROW );
+ return new SheetsEnumeration( this, mxContext, xEnumAccess->createEnumeration(), mxModel );
+}
+
+uno::Any
+ScVbaWorksheets::createCollectionObject( const uno::Any& aSource )
+{
+ uno::Reference< sheet::XSpreadsheet > xSheet( aSource, uno::UNO_QUERY );
+ uno::Reference< XInterface > xIf = lcl_getModulAsUnoObject( xSheet, mxModel );
+ uno::Any aRet;
+ if ( !xIf.is() )
+ {
+ // if the Sheet is in a document created by the api unfortunately ( at the
+ // moment, it actually wont have the special Document modules
+ uno::Reference< excel::XWorksheet > xNewSheet( new ScVbaWorksheet( getParent(), mxContext, xSheet, mxModel ) );
+ aRet <<= xNewSheet;
+ }
+ else
+ aRet <<= xIf;
+ return aRet;
+}
+
+// XWorksheets
+uno::Any
+ScVbaWorksheets::Add( const uno::Any& Before, const uno::Any& After,
+ const uno::Any& Count, const uno::Any& Type ) throw (uno::RuntimeException)
+{
+ if ( isSelectedSheets() )
+ return uno::Any(); // or should we throw?
+
+ rtl::OUString aStringSheet;
+ sal_Bool bBefore(sal_True);
+ SCTAB nSheetIndex = 0;
+ SCTAB nNewSheets = 1, nType = 0;
+ Count >>= nNewSheets;
+ Type >>= nType;
+ SCTAB nCount = 0;
+
+ uno::Reference< excel::XWorksheet > xBeforeAfterSheet;
+
+ if ( Before.hasValue() )
+ {
+ if ( Before >>= xBeforeAfterSheet )
+ aStringSheet = xBeforeAfterSheet->getName();
+ else
+ Before >>= aStringSheet;
+ }
+
+ if (!aStringSheet.getLength() && After.hasValue() )
+ {
+ if ( After >>= xBeforeAfterSheet )
+ aStringSheet = xBeforeAfterSheet->getName();
+ else
+ After >>= aStringSheet;
+ bBefore = sal_False;
+ }
+ if (!aStringSheet.getLength())
+ {
+ uno::Reference< excel::XApplication > xApplication( Application(), uno::UNO_QUERY_THROW );
+ aStringSheet = xApplication->getActiveWorkbook()->getActiveSheet()->getName();
+ bBefore = sal_True;
+ }
+ nCount = static_cast< SCTAB >( m_xIndexAccess->getCount() );
+ for (SCTAB i=0; i < nCount; i++)
+ {
+ uno::Reference< sheet::XSpreadsheet > xSheet(m_xIndexAccess->getByIndex(i), uno::UNO_QUERY);
+ uno::Reference< container::XNamed > xNamed( xSheet, uno::UNO_QUERY_THROW );
+ if (xNamed->getName() == aStringSheet)
+ {
+ nSheetIndex = i;
+ break;
+ }
+ }
+
+ if(!bBefore)
+ nSheetIndex++;
+
+ SCTAB nSheetName = nCount + 1L;
+ String aStringBase( RTL_CONSTASCII_USTRINGPARAM("Sheet") );
+ uno::Any result;
+ for (SCTAB i=0; i < nNewSheets; i++, nSheetName++)
+ {
+ String aStringName = aStringBase;
+ aStringName += String::CreateFromInt32(nSheetName);
+ while (m_xNameAccess->hasByName(aStringName))
+ {
+ nSheetName++;
+ aStringName = aStringBase;
+ aStringName += String::CreateFromInt32(nSheetName);
+ }
+ m_xSheets->insertNewByName(aStringName, nSheetIndex + i);
+ result = getItemByStringIndex( aStringName );
+ }
+ uno::Reference< excel::XWorksheet > xNewSheet( result, uno::UNO_QUERY );
+ if ( xNewSheet.is() )
+ xNewSheet->Activate();
+ return result;
+}
+
+void
+ScVbaWorksheets::Delete() throw (uno::RuntimeException)
+{
+ // #TODO #INVESTIGATE
+ // mmm this method could be trouble if the underlying
+ // uno objects ( the m_xIndexAccess etc ) aren't aware of the
+ // contents that are deleted
+ sal_Int32 nElems = getCount();
+ for ( sal_Int32 nItem = 1; nItem <= nElems; ++nItem )
+ {
+ uno::Reference< excel::XWorksheet > xSheet( Item( uno::makeAny( nItem ), uno::Any() ), uno::UNO_QUERY_THROW );
+ xSheet->Delete();
+ }
+}
+
+bool
+ScVbaWorksheets::isSelectedSheets()
+{
+ return !m_xSheets.is();
+}
+
+void SAL_CALL
+ScVbaWorksheets::PrintOut( const uno::Any& From, const uno::Any& To, const uno::Any& Copies, const uno::Any& Preview, const uno::Any& ActivePrinter, const uno::Any& PrintToFile, const uno::Any& Collate, const uno::Any& PrToFileName ) throw (uno::RuntimeException)
+{
+ sal_Int32 nTo = 0;
+ sal_Int32 nFrom = 0;
+ sal_Int16 nCopies = 1;
+ sal_Bool bCollate = sal_False;
+ sal_Bool bSelection = sal_False;
+ From >>= nFrom;
+ To >>= nTo;
+ Copies >>= nCopies;
+ if ( nCopies > 1 ) // Collate only useful when more that 1 copy
+ Collate >>= bCollate;
+
+ if ( !( nFrom || nTo ) )
+ if ( isSelectedSheets() )
+ bSelection = sal_True;
+
+ PrintOutHelper( excel::getBestViewShell( mxModel ), From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, bSelection );
+}
+
+uno::Any SAL_CALL
+ScVbaWorksheets::getVisible() throw (uno::RuntimeException)
+{
+ sal_Bool bVisible = sal_True;
+ uno::Reference< container::XEnumeration > xEnum( createEnumeration(), uno::UNO_QUERY_THROW );
+ while ( xEnum->hasMoreElements() )
+ {
+ uno::Reference< excel::XWorksheet > xSheet( xEnum->nextElement(), uno::UNO_QUERY_THROW );
+ if ( xSheet->getVisible() == sal_False )
+ {
+ bVisible = sal_False;
+ break;
+ }
+ }
+ return uno::makeAny( bVisible );
+}
+
+void SAL_CALL
+ScVbaWorksheets::setVisible( const uno::Any& _visible ) throw (uno::RuntimeException)
+{
+ sal_Bool bState = sal_False;
+ if ( _visible >>= bState )
+ {
+ uno::Reference< container::XEnumeration > xEnum( createEnumeration(), uno::UNO_QUERY_THROW );
+ while ( xEnum->hasMoreElements() )
+ {
+ uno::Reference< excel::XWorksheet > xSheet( xEnum->nextElement(), uno::UNO_QUERY_THROW );
+ xSheet->setVisible( bState );
+ }
+ }
+ else
+ throw uno::RuntimeException( rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM( "Visible property doesn't support non boolean #FIXME" ) ), uno::Reference< uno::XInterface >() );
+}
+
+void SAL_CALL
+ScVbaWorksheets::Select( const uno::Any& Replace ) throw (uno::RuntimeException)
+{
+ ScTabViewShell* pViewShell = excel::getBestViewShell( mxModel );
+ if ( !pViewShell )
+ throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Cannot obtain view shell" ) ), uno::Reference< uno::XInterface >() );
+
+ ScMarkData& rMarkData = pViewShell->GetViewData()->GetMarkData();
+ sal_Bool bReplace = sal_True;
+ Replace >>= bReplace;
+ // Replace is defaulted to True, meanining this current collection
+ // becomes the Selection, if it were false then the current selection would
+ // be extended
+ bool bSelectSingle = bReplace;
+ sal_Int32 nElems = getCount();
+ for ( sal_Int32 nItem = 1; nItem <= nElems; ++nItem )
+ {
+ uno::Reference< excel::XWorksheet > xSheet( Item( uno::makeAny( nItem ), uno::Any() ), uno::UNO_QUERY_THROW );
+ ScVbaWorksheet* pSheet = dynamic_cast< ScVbaWorksheet* >( xSheet.get() );
+ if ( pSheet )
+ {
+ if ( bSelectSingle )
+ {
+ rMarkData.SelectOneTable( static_cast< SCTAB >( pSheet->getSheetID() ) );
+ bSelectSingle = false;
+ }
+ else
+ rMarkData.SelectTable( static_cast< SCTAB >( pSheet->getSheetID() ), TRUE );
+
+ }
+ }
+
+
+}
+
+//ScVbaCollectionBaseImpl
+uno::Any SAL_CALL
+ScVbaWorksheets::Item( const uno::Any& Index, const uno::Any& Index2 ) throw (uno::RuntimeException)
+{
+ if ( Index.getValueTypeClass() == uno::TypeClass_SEQUENCE )
+ {
+ uno::Reference< script::XTypeConverter > xConverter = getTypeConverter(mxContext);
+ uno::Any aConverted;
+ aConverted = xConverter->convertTo( Index, getCppuType((uno::Sequence< uno::Any >*)0) );
+ SheetMap mSheets;
+ uno::Sequence< uno::Any > sIndices;
+ aConverted >>= sIndices;
+ sal_Int32 nElems = sIndices.getLength();
+ for( sal_Int32 index = 0; index < nElems; ++index )
+ {
+ uno::Reference< excel::XWorksheet > xWorkSheet( ScVbaWorksheets_BASE::Item( sIndices[ index ], Index2 ), uno::UNO_QUERY_THROW );
+ ScVbaWorksheet* pWorkSheet = dynamic_cast< ScVbaWorksheet* >( xWorkSheet.get() );
+ if ( pWorkSheet )
+ {
+ uno::Reference< sheet::XSpreadsheet > xSheet( pWorkSheet->getSheet() , uno::UNO_QUERY_THROW );
+ uno::Reference< container::XNamed > xName( xSheet, uno::UNO_QUERY_THROW );
+ mSheets.push_back( xSheet );
+ }
+ }
+ uno::Reference< container::XIndexAccess > xIndexAccess = new SheetCollectionHelper( mSheets );
+ uno::Reference< XCollection > xSelectedSheets( new ScVbaWorksheets( this->getParent(), mxContext, xIndexAccess, mxModel ) );
+ return uno::makeAny( xSelectedSheets );
+ }
+ return ScVbaWorksheets_BASE::Item( Index, Index2 );
+}
+
+uno::Any
+ScVbaWorksheets::getItemByStringIndex( const rtl::OUString& sIndex ) throw (uno::RuntimeException)
+{
+ return ScVbaWorksheets_BASE::getItemByStringIndex( sIndex );
+}
+
+rtl::OUString&
+ScVbaWorksheets::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWorksheets") );
+ return sImplName;
+}
+
+css::uno::Sequence<rtl::OUString>
+ScVbaWorksheets::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > sNames;
+ if ( sNames.getLength() == 0 )
+ {
+ sNames.realloc( 1 );
+ sNames[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.Worksheets") );
+ }
+ return sNames;
+}
+
+/*static*/ bool ScVbaWorksheets::nameExists( uno::Reference <sheet::XSpreadsheetDocument>& xSpreadDoc, const ::rtl::OUString & name, SCTAB& nTab ) throw ( lang::IllegalArgumentException )
+{
+ if (!xSpreadDoc.is())
+ throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nameExists() xSpreadDoc is null" ) ), uno::Reference< uno::XInterface >(), 1 );
+ uno::Reference <container::XIndexAccess> xIndex( xSpreadDoc->getSheets(), uno::UNO_QUERY );
+ if ( xIndex.is() )
+ {
+ SCTAB nCount = static_cast< SCTAB >( xIndex->getCount() );
+ for (SCTAB i=0; i < nCount; i++)
+ {
+ uno::Reference< container::XNamed > xNamed( xIndex->getByIndex(i), uno::UNO_QUERY_THROW );
+ if (xNamed->getName() == name)
+ {
+ nTab = i;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbaworksheets.hxx b/sc/source/ui/vba/vbaworksheets.hxx
new file mode 100644
index 000000000000..82001c0d77c8
--- /dev/null
+++ b/sc/source/ui/vba/vbaworksheets.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_WORKSHEETS_HXX
+#define SC_VBA_WORKSHEETS_HXX
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <ooo/vba/excel/XWorksheets.hpp>
+#include <com/sun/star/sheet/XSpreadsheets.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/container/XEnumerationAccess.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <vbahelper/vbacollectionimpl.hxx>
+
+#include "address.hxx"
+
+class ScModelObj;
+
+
+typedef CollTestImplHelper< ov::excel::XWorksheets > ScVbaWorksheets_BASE;
+
+class ScVbaWorksheets : public ScVbaWorksheets_BASE
+{
+ css::uno::Reference< css::frame::XModel > mxModel;
+ css::uno::Reference< css::sheet::XSpreadsheets > m_xSheets;
+protected:
+ // ScVbaWorksheets_BASE
+ virtual css::uno::Any getItemByStringIndex( const rtl::OUString& sIndex ) throw (css::uno::RuntimeException);
+public:
+ ScVbaWorksheets( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XIndexAccess >& xSheets, const css::uno::Reference< css::frame::XModel >& xModel );
+ ScVbaWorksheets( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext > & xContext, const css::uno::Reference< css::container::XEnumerationAccess >& xEnum, const css::uno::Reference< css::frame::XModel >& xModel );
+ virtual ~ScVbaWorksheets() {}
+
+ bool isSelectedSheets();
+
+ // XEnumerationAccess
+ virtual css::uno::Type SAL_CALL getElementType() throw (css::uno::RuntimeException);
+ virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw (css::uno::RuntimeException);
+
+
+ // XWorksheets
+ virtual css::uno::Any SAL_CALL getVisible() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( const css::uno::Any& _visible ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL Add( const css::uno::Any& Before, const css::uno::Any& After, const css::uno::Any& Count, const css::uno::Any& Type ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL Delete( ) throw (css::uno::RuntimeException);
+ virtual void SAL_CALL PrintOut( const css::uno::Any& From, const css::uno::Any& To, const css::uno::Any& Copies, const css::uno::Any& Preview, const css::uno::Any& ActivePrinter, const css::uno::Any& PrintToFile, const css::uno::Any& Collate, const css::uno::Any& PrToFileName ) throw (css::uno::RuntimeException);
+ virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource );
+ virtual void SAL_CALL Select( const css::uno::Any& Replace ) throw (css::uno::RuntimeException);
+ // ScVbaWorksheets_BASE
+ virtual css::uno::Any SAL_CALL Item( const css::uno::Any& Index1, const css::uno::Any& Index2 ) throw
+(css::uno::RuntimeException);
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+
+ static bool nameExists( css::uno::Reference <css::sheet::XSpreadsheetDocument>& xSpreadDoc, const ::rtl::OUString & name, SCTAB& nTab ) throw ( css::lang::IllegalArgumentException );
+};
+
+#endif /* SC_VBA_WORKSHEETS_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbawsfunction.cxx b/sc/source/ui/vba/vbawsfunction.cxx
new file mode 100644
index 000000000000..b87ec852b9a5
--- /dev/null
+++ b/sc/source/ui/vba/vbawsfunction.cxx
@@ -0,0 +1,322 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/sheet/XFunctionAccess.hpp>
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/reflection/XIdlMethod.hpp>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include <comphelper/anytostring.hxx>
+
+#include "vbawsfunction.hxx"
+#include "compiler.hxx"
+
+using namespace com::sun::star;
+using namespace ooo::vba;
+
+namespace {
+
+void lclConvertDoubleToBoolean( uno::Any& rAny )
+{
+ if( rAny.has< double >() )
+ {
+ double fValue = rAny.get< double >();
+ if( fValue == 0.0 )
+ rAny <<= false;
+ else if( fValue == 1.0 )
+ rAny <<= true;
+ // do nothing for other values or types
+ }
+}
+
+void lclConvertBooleanToDouble( uno::Any& rAny )
+{
+ sal_Bool bValue( sal_False );
+ if ( rAny >>= bValue )
+ {
+ if ( bValue )
+ rAny <<= double( 1.0 );
+ else
+ rAny <<= double( 0.0 );
+ }
+}
+
+} // namespace
+
+ScVbaWSFunction::ScVbaWSFunction( const uno::Reference< XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) :
+ ScVbaWSFunction_BASE( xParent, xContext )
+{
+}
+
+uno::Reference< beans::XIntrospectionAccess >
+ScVbaWSFunction::getIntrospection(void) throw(uno::RuntimeException)
+{
+ return uno::Reference<beans::XIntrospectionAccess>();
+}
+
+uno::Any SAL_CALL
+ScVbaWSFunction::invoke(const rtl::OUString& FunctionName, const uno::Sequence< uno::Any >& Params, uno::Sequence< sal_Int16 >& /*OutParamIndex*/, uno::Sequence< uno::Any >& /*OutParam*/) throw(lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+{
+ // create copy of parameters, replace Excel range objects with UNO range objects
+ uno::Sequence< uno::Any > aParamTemp( Params );
+ if( aParamTemp.hasElements() )
+ {
+ uno::Any* pArray = aParamTemp.getArray();
+ uno::Any* pArrayEnd = pArray + aParamTemp.getLength();
+ for( ; pArray < pArrayEnd; ++pArray )
+ {
+ switch( pArray->getValueType().getTypeClass() )
+ {
+ case uno::TypeClass_BOOLEAN:
+ lclConvertBooleanToDouble( *pArray );
+ break;
+ case uno::TypeClass_INTERFACE:
+ {
+ uno::Reference< excel::XRange > myRange( *pArray, uno::UNO_QUERY );
+ if( myRange.is() )
+ *pArray = myRange->getCellRange();
+ }
+ break;
+ case uno::TypeClass_SEQUENCE:
+ {
+ // the sheet.FunctionAccess service doesn't deal with Sequences, only Sequences of Sequence
+ uno::Type aType = pArray->getValueType();
+ if ( aType.equals( getCppuType( (uno::Sequence<sal_Int16>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< sal_Int16 > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<sal_Int32>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< sal_Int32 > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<double>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< double > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<rtl::OUString>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence< rtl::OUString > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ else if ( aType.equals( getCppuType( (uno::Sequence<uno::Any>*)0 ) ) )
+ {
+ uno::Sequence< uno::Sequence<uno::Any > > aTmp(1);
+ (*pArray) >>= aTmp[ 0 ];
+ (*pArray) <<= aTmp;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ OSL_TRACE("Param[%d] is %s", (int)(pArray - aParamTemp.getConstArray()), rtl::OUStringToOString( comphelper::anyToString( *pArray ), RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ }
+
+ uno::Any aRet;
+ bool bAsArray = true;
+
+ // special handing for some functions that don't work correctly in FunctionAccess
+ ScCompiler aCompiler( 0, ScAddress() );
+ OpCode eOpCode = aCompiler.GetEnglishOpCode( FunctionName.toAsciiUpperCase() );
+ switch( eOpCode )
+ {
+ // ISLOGICAL does not work in array formula mode
+ case ocIsLogical:
+ {
+ if( aParamTemp.getLength() != 1 )
+ throw lang::IllegalArgumentException();
+ const uno::Any& rParam = aParamTemp[ 0 ];
+ if( rParam.has< bool >() )
+ {
+ aRet <<= true;
+ }
+ else if( rParam.has< uno::Reference< table::XCellRange > >() ) try
+ {
+ uno::Reference< sheet::XCellRangeAddressable > xRangeAddr( rParam, uno::UNO_QUERY_THROW );
+ table::CellRangeAddress aRangeAddr = xRangeAddr->getRangeAddress();
+ bAsArray = (aRangeAddr.StartColumn != aRangeAddr.EndColumn) || (aRangeAddr.StartRow != aRangeAddr.EndRow);
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+ break;
+ default:;
+ }
+
+ if( !aRet.hasValue() )
+ {
+ uno::Reference< lang::XMultiComponentFactory > xSMgr( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< sheet::XFunctionAccess > xFunctionAccess( xSMgr->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.FunctionAccess" ) ), mxContext ),
+ uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( xFunctionAccess, uno::UNO_QUERY_THROW );
+ xPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsArrayFunction" ) ), uno::Any( bAsArray ) );
+ aRet = xFunctionAccess->callFunction( FunctionName, aParamTemp );
+ }
+
+ /* Convert return value from double to to Boolean for some functions that
+ return Booleans. */
+ typedef uno::Sequence< uno::Sequence< uno::Any > > AnySeqSeq;
+ if( (eOpCode == ocIsEmpty) || (eOpCode == ocIsString) || (eOpCode == ocIsNonString) || (eOpCode == ocIsLogical) ||
+ (eOpCode == ocIsRef) || (eOpCode == ocIsValue) || (eOpCode == ocIsFormula) || (eOpCode == ocIsNA) ||
+ (eOpCode == ocIsErr) || (eOpCode == ocIsError) || (eOpCode == ocIsEven) || (eOpCode == ocIsOdd) ||
+ (eOpCode == ocAnd) || (eOpCode == ocOr) || (eOpCode == ocNot) || (eOpCode == ocTrue) || (eOpCode == ocFalse) )
+ {
+ if( aRet.has< AnySeqSeq >() )
+ {
+ AnySeqSeq aAnySeqSeq = aRet.get< AnySeqSeq >();
+ for( sal_Int32 nRow = 0; nRow < aAnySeqSeq.getLength(); ++nRow )
+ for( sal_Int32 nCol = 0; nCol < aAnySeqSeq[ nRow ].getLength(); ++nCol )
+ lclConvertDoubleToBoolean( aAnySeqSeq[ nRow ][ nCol ] );
+ aRet <<= aAnySeqSeq;
+ }
+ else
+ {
+ lclConvertDoubleToBoolean( aRet );
+ }
+ }
+
+ /* Hack/workaround (?): shorten single-row matrix to simple array, shorten
+ 1x1 matrix to single value. */
+ if( aRet.has< AnySeqSeq >() )
+ {
+ AnySeqSeq aAnySeqSeq = aRet.get< AnySeqSeq >();
+ if( aAnySeqSeq.getLength() == 1 )
+ {
+ if( aAnySeqSeq[ 0 ].getLength() == 1 )
+ aRet = aAnySeqSeq[ 0 ][ 0 ];
+ else
+ aRet <<= aAnySeqSeq[ 0 ];
+ }
+ }
+
+#if 0
+ // MATCH function should alwayse return a double value, but currently if the first argument is XCellRange, MATCH function returns an array instead of a double value. Don't know why?
+ // To fix this issue in safe, current solution is to convert this array to a double value just for MATCH function.
+ String aUpper( FunctionName );
+ ScCompiler aCompiler( NULL, ScAddress() );
+ OpCode eOp = aCompiler.GetEnglishOpCode( aUpper.ToUpperAscii() );
+ if( eOp == ocMatch )
+ {
+ double fVal = 0.0;
+ if( aRet >>= fVal )
+ return aRet;
+ uno::Sequence< uno::Sequence< uno::Any > > aSequence;
+ if( !( ( aRet >>= aSequence ) && ( aSequence.getLength() > 0 ) &&
+ ( aSequence[0].getLength() > 0 ) && ( aSequence[0][0] >>= fVal ) ) )
+ throw uno::RuntimeException();
+ aRet <<= fVal;
+ }
+#endif
+
+ return aRet;
+}
+
+void SAL_CALL
+ScVbaWSFunction::setValue(const rtl::OUString& /*PropertyName*/, const uno::Any& /*Value*/) throw(beans::UnknownPropertyException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
+{
+ throw beans::UnknownPropertyException();
+}
+
+uno::Any SAL_CALL
+ScVbaWSFunction::getValue(const rtl::OUString& /*PropertyName*/) throw(beans::UnknownPropertyException, uno::RuntimeException)
+{
+ throw beans::UnknownPropertyException();
+}
+
+sal_Bool SAL_CALL
+ScVbaWSFunction::hasMethod(const rtl::OUString& Name) throw(uno::RuntimeException)
+{
+ sal_Bool bIsFound = sal_False;
+ try
+ {
+ // the function name contained in the com.sun.star.sheet.FunctionDescription service is alwayse localized.
+ // but the function name used in WorksheetFunction is a programmatic name (seems English).
+ // So m_xNameAccess->hasByName( Name ) may fail to find name when a function name has a localized name.
+ ScCompiler aCompiler( NULL, ScAddress() );
+ if( aCompiler.IsEnglishSymbol( Name ) )
+ bIsFound = sal_True;
+ }
+ catch( uno::Exception& /*e*/ )
+ {
+ // failed to find name
+ }
+ return bIsFound;
+}
+
+sal_Bool SAL_CALL
+ScVbaWSFunction::hasProperty(const rtl::OUString& /*Name*/) throw(uno::RuntimeException)
+{
+ return sal_False;
+}
+
+::rtl::OUString SAL_CALL
+ScVbaWSFunction::getExactName( const ::rtl::OUString& aApproximateName ) throw (css::uno::RuntimeException)
+{
+ rtl::OUString sName = aApproximateName.toAsciiUpperCase();
+ if ( !hasMethod( sName ) )
+ return rtl::OUString();
+ return sName;
+}
+
+rtl::OUString&
+ScVbaWSFunction::getServiceImplName()
+{
+ static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaWSFunction") );
+ return sImplName;
+}
+
+uno::Sequence< rtl::OUString >
+ScVbaWSFunction::getServiceNames()
+{
+ static uno::Sequence< rtl::OUString > aServiceNames;
+ if ( aServiceNames.getLength() == 0 )
+ {
+ aServiceNames.realloc( 1 );
+ aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.excel.WorksheetFunction" ) );
+ }
+ return aServiceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/vba/vbawsfunction.hxx b/sc/source/ui/vba/vbawsfunction.hxx
new file mode 100644
index 000000000000..ff7c68cea6ba
--- /dev/null
+++ b/sc/source/ui/vba/vbawsfunction.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef SC_VBA_INTERIOR_HXX
+#define SC_VBA_INTERIOR_HXX
+
+#include <ooo/vba/excel/XWorksheetFunction.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include "vbarange.hxx"
+
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+typedef InheritedHelperInterfaceImpl1< ov::excel::XWorksheetFunction > ScVbaWSFunction_BASE;
+
+class ScVbaWSFunction : public ScVbaWSFunction_BASE
+{
+public:
+ ScVbaWSFunction( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext);
+ virtual ~ScVbaWSFunction(){}
+
+ virtual css::uno::Reference< css::beans::XIntrospectionAccess > SAL_CALL getIntrospection(void) throw(css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL invoke(const rtl::OUString& FunctionName, const css::uno::Sequence< css::uno::Any >& Params, css::uno::Sequence< sal_Int16 >& OutParamIndex, css::uno::Sequence< css::uno::Any >& OutParam) throw(css::lang::IllegalArgumentException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual void SAL_CALL setValue(const rtl::OUString& PropertyName, const css::uno::Any& Value) throw(css::beans::UnknownPropertyException, css::script::CannotConvertException, css::reflection::InvocationTargetException, css::uno::RuntimeException);
+ virtual css::uno::Any SAL_CALL getValue(const rtl::OUString& PropertyName) throw(css::beans::UnknownPropertyException, css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasMethod(const rtl::OUString& Name) throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasProperty(const rtl::OUString& Name) throw(css::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExactName( const ::rtl::OUString& aApproximateName ) throw (css::uno::RuntimeException);
+ // XHelperInterface
+ virtual rtl::OUString& getServiceImplName();
+ virtual css::uno::Sequence<rtl::OUString> getServiceNames();
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/auditsh.cxx b/sc/source/ui/view/auditsh.cxx
new file mode 100644
index 000000000000..f75778991f09
--- /dev/null
+++ b/sc/source/ui/view/auditsh.cxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svl/srchitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+
+#include "auditsh.hxx"
+#include "tabvwsh.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "document.hxx"
+
+//------------------------------------------------------------------------
+
+#define ScAuditingShell
+#include "scslots.hxx"
+
+//------------------------------------------------------------------------
+
+TYPEINIT1( ScAuditingShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScAuditingShell, SfxShell, ScResId(SCSTR_AUDITSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_AUDIT) );
+}
+
+
+//------------------------------------------------------------------------
+
+ScAuditingShell::ScAuditingShell(ScViewData* pData) :
+ SfxShell(pData->GetViewShell()),
+ pViewData( pData ),
+ nFunction( SID_FILL_ADD_PRED )
+{
+ SetPool( &pViewData->GetViewShell()->GetPool() );
+ SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId( HID_SCSHELL_AUDIT );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Auditing")));
+}
+
+//------------------------------------------------------------------------
+
+ScAuditingShell::~ScAuditingShell()
+{
+}
+
+//------------------------------------------------------------------------
+
+void ScAuditingShell::Execute( SfxRequest& rReq )
+{
+ SfxBindings& rBindings = pViewData->GetBindings();
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_FILL_ADD_PRED:
+ case SID_FILL_DEL_PRED:
+ case SID_FILL_ADD_SUCC:
+ case SID_FILL_DEL_SUCC:
+ nFunction = nSlot;
+ rBindings.Invalidate( SID_FILL_ADD_PRED );
+ rBindings.Invalidate( SID_FILL_DEL_PRED );
+ rBindings.Invalidate( SID_FILL_ADD_SUCC );
+ rBindings.Invalidate( SID_FILL_DEL_SUCC );
+ break;
+ case SID_CANCEL: // Escape
+ case SID_FILL_NONE:
+ pViewData->GetViewShell()->SetAuditShell( FALSE );
+ break;
+
+ case SID_FILL_SELECT:
+ {
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pXItem;
+ const SfxPoolItem* pYItem;
+ if ( pReqArgs->GetItemState( SID_RANGE_COL, TRUE, &pXItem ) == SFX_ITEM_SET
+ && pReqArgs->GetItemState( SID_RANGE_ROW, TRUE, &pYItem ) == SFX_ITEM_SET )
+ {
+ DBG_ASSERT( pXItem->ISA(SfxInt16Item) && pYItem->ISA(SfxInt32Item),
+ "falsche Items" );
+ SCsCOL nCol = static_cast<SCsCOL>(((const SfxInt16Item*) pXItem)->GetValue());
+ SCsROW nRow = static_cast<SCsROW>(((const SfxInt32Item*) pYItem)->GetValue());
+ ScViewFunc* pView = pViewData->GetView();
+ pView->MoveCursorAbs( nCol, nRow, SC_FOLLOW_LINE, FALSE, FALSE );
+ switch ( nFunction )
+ {
+ case SID_FILL_ADD_PRED:
+ pView->DetectiveAddPred();
+ break;
+ case SID_FILL_DEL_PRED:
+ pView->DetectiveDelPred();
+ break;
+ case SID_FILL_ADD_SUCC:
+ pView->DetectiveAddSucc();
+ break;
+ case SID_FILL_DEL_SUCC:
+ pView->DetectiveDelSucc();
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScAuditingShell::GetState( SfxItemSet& rSet )
+{
+ rSet.Put( SfxBoolItem( nFunction, TRUE ) ); // aktive Funktion markieren
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellmergeoption.cxx b/sc/source/ui/view/cellmergeoption.cxx
new file mode 100644
index 000000000000..61f2d8bd7727
--- /dev/null
+++ b/sc/source/ui/view/cellmergeoption.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ * [ Kohei Yoshida <kyoshida@novell.com> ]
+ * Portions created by the Initial Developer are Copyright (C) 2010 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "cellmergeoption.hxx"
+#include "address.hxx"
+
+ScCellMergeOption::ScCellMergeOption() :
+ mnStartCol(0),
+ mnStartRow(0),
+ mnEndCol(0),
+ mnEndRow(0),
+ mbCenter(false)
+{
+}
+
+ScCellMergeOption::ScCellMergeOption(const ScRange& rRange) :
+ mnStartCol(rRange.aStart.Col()),
+ mnStartRow(rRange.aStart.Row()),
+ mnEndCol(rRange.aEnd.Col()),
+ mnEndRow(rRange.aEnd.Row()),
+ mbCenter(false)
+{
+ SCTAB nTab1 = rRange.aStart.Tab();
+ SCTAB nTab2 = rRange.aEnd.Tab();
+ for (SCTAB i = nTab1; i <= nTab2; ++i)
+ maTabs.insert(i);
+}
+
+ScCellMergeOption::ScCellMergeOption(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bCenter) :
+ mnStartCol(nStartCol),
+ mnStartRow(nStartRow),
+ mnEndCol(nEndCol),
+ mnEndRow(nEndRow),
+ mbCenter(bCenter)
+{
+}
+
+ScCellMergeOption::ScCellMergeOption(const ScCellMergeOption& r) :
+ maTabs(r.maTabs),
+ mnStartCol(r.mnStartCol),
+ mnStartRow(r.mnStartRow),
+ mnEndCol(r.mnEndCol),
+ mnEndRow(r.mnEndRow),
+ mbCenter(r.mbCenter)
+{
+}
+
+ScRange ScCellMergeOption::getSingleRange(SCTAB nTab) const
+{
+ return ScRange(mnStartCol, mnStartRow, nTab, mnEndCol, mnEndRow, nTab);
+}
+
+ScRange ScCellMergeOption::getFirstSingleRange() const
+{
+ SCTAB nTab = 0;
+ if (!maTabs.empty())
+ nTab = *maTabs.begin();
+
+ return getSingleRange(nTab);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh.cxx b/sc/source/ui/view/cellsh.cxx
new file mode 100644
index 000000000000..ba4127e51331
--- /dev/null
+++ b/sc/source/ui/view/cellsh.cxx
@@ -0,0 +1,1007 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+
+#include <svl/slstitm.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svtools/insdlg.hxx>
+#include <sot/formats.hxx>
+#include <svx/hlnkitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <editeng/langitem.hxx>
+
+#include "cellsh.hxx"
+#include "sc.hrc"
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "globstr.hrc"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "scabstdlg.hxx"
+#include "dociter.hxx"
+#include "postit.hxx"
+
+//------------------------------------------------------------------
+
+#define ScCellShell
+#define CellMovement
+#include "scslots.hxx"
+
+#define SearchSettings
+#include <svx/svxslots.hxx>
+
+TYPEINIT1( ScCellShell, ScFormatShell );
+
+SFX_IMPL_INTERFACE(ScCellShell, ScFormatShell , ScResId(SCSTR_CELLSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_SERVER,
+ ScResId(RID_OBJECTBAR_FORMAT));
+ SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_CELLS));
+}
+
+
+ScCellShell::ScCellShell(ScViewData* pData) :
+ ScFormatShell(pData),
+ pImpl( new CellShell_Impl() ),
+ bPastePossible(FALSE)
+{
+ SetHelpId(HID_SCSHELL_CELLSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Cell")));
+}
+
+ScCellShell::~ScCellShell()
+{
+ if ( pImpl->m_pClipEvtLstnr )
+ {
+ pImpl->m_pClipEvtLstnr->AddRemoveListener( GetViewData()->GetActiveWin(), FALSE );
+
+ // #103849# The listener may just now be waiting for the SolarMutex and call the link
+ // afterwards, in spite of RemoveListener. So the link has to be reset, too.
+ pImpl->m_pClipEvtLstnr->ClearCallbackLink();
+
+ pImpl->m_pClipEvtLstnr->release();
+ }
+
+ delete pImpl->m_pLinkedDlg;
+ delete pImpl->m_pRequest;
+ delete pImpl;
+}
+
+//------------------------------------------------------------------
+
+void ScCellShell::GetBlockState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScRange aMarkRange;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aMarkRange );
+ BOOL bSimpleArea = (eMarkType == SC_MARK_SIMPLE);
+ BOOL bOnlyNotBecauseOfMatrix;
+ BOOL bEditable = pTabViewShell->SelectionEditable( &bOnlyNotBecauseOfMatrix );
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ nCol1 = aMarkRange.aStart.Col();
+ nRow1 = aMarkRange.aStart.Row();
+ nCol2 = aMarkRange.aEnd.Col();
+ nRow2 = aMarkRange.aEnd.Row();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ BOOL bDisable = FALSE;
+ BOOL bNeedEdit = TRUE; // muss Selektion editierbar sein?
+ switch ( nWhich )
+ {
+ case FID_FILL_TO_BOTTOM: // Fuellen oben/unten
+ case FID_FILL_TO_TOP: // mind. 2 Zeilen markiert?
+ bDisable = (!bSimpleArea) || (nRow1 == nRow2);
+ if ( !bDisable && bEditable )
+ { // Matrix nicht zerreissen
+ if ( nWhich == FID_FILL_TO_BOTTOM )
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol2, nRow1, rMark ); // erste Zeile
+ else
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow2, nCol2, nRow2, rMark ); // letzte Zeile
+ }
+ break;
+
+ case FID_FILL_TO_RIGHT: // Fuellen links/rechts
+ case FID_FILL_TO_LEFT: // mind. 2 Spalten markiert?
+ bDisable = (!bSimpleArea) || (nCol1 == nCol2);
+ if ( !bDisable && bEditable )
+ { // Matrix nicht zerreissen
+ if ( nWhich == FID_FILL_TO_RIGHT )
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol1, nRow2, rMark ); // erste Spalte
+ else
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte
+ }
+ break;
+
+ case FID_FILL_SERIES: // Block fuellen
+ case SID_OPENDLG_TABOP: // Mehrfachoperationen, mind. 2 Zellen markiert?
+ if (pDoc->GetChangeTrack()!=NULL &&nWhich ==SID_OPENDLG_TABOP)
+ bDisable = TRUE;
+ else
+ bDisable = (!bSimpleArea) || (nCol1 == nCol2 && nRow1 == nRow2);
+
+ if ( !bDisable && bEditable && nWhich == FID_FILL_SERIES )
+ { // Matrix nicht zerreissen
+ bDisable = pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol2, nRow1, rMark ) // erste Zeile
+ || pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow2, nCol2, nRow2, rMark ) // letzte Zeile
+ || pDoc->HasSelectedBlockMatrixFragment(
+ nCol1, nRow1, nCol1, nRow2, rMark ) // erste Spalte
+ || pDoc->HasSelectedBlockMatrixFragment(
+ nCol2, nRow1, nCol2, nRow2, rMark ); // letzte Spalte
+ }
+ break;
+
+ case SID_CUT: // Ausschneiden,
+ case FID_INS_CELL: // Zellen einfuegen, nur einf. Selektion
+ bDisable = (!bSimpleArea);
+ break;
+
+ case FID_INS_ROW: // insert rows
+ case FID_INS_CELLSDOWN:
+ bDisable = (!bSimpleArea) || GetViewData()->SimpleColMarked();
+ break;
+
+ case FID_INS_COLUMN: // insert columns
+ case FID_INS_CELLSRIGHT:
+ bDisable = (!bSimpleArea) || GetViewData()->SimpleRowMarked();
+ break;
+
+ case SID_COPY: // Kopieren
+ // nur wegen Matrix nicht editierbar? Matrix nicht zerreissen
+ //! schlaegt nicht zu, wenn geschuetzt UND Matrix, aber damit
+ //! muss man leben.. wird in Copy-Routine abgefangen, sonst
+ //! muesste hier nochmal Aufwand getrieben werden
+ if ( !(!bEditable && bOnlyNotBecauseOfMatrix) )
+ bNeedEdit = FALSE; // erlaubt, wenn geschuetzt/ReadOnly
+ break;
+
+ case SID_AUTOFORMAT: // Autoformat, mind. 3x3 selektiert
+ bDisable = (!bSimpleArea)
+ || ((nCol2 - nCol1) < 2) || ((nRow2 - nRow1) < 2);
+ break;
+
+ case SID_OPENDLG_CONDFRMT :
+ {
+ if ( !bEditable && bOnlyNotBecauseOfMatrix )
+ {
+ bNeedEdit = FALSE;
+ }
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ bDisable = TRUE;
+ }
+ }
+ break;
+
+ case FID_CONDITIONAL_FORMAT :
+ case SID_CELL_FORMAT_RESET :
+ case FID_CELL_FORMAT :
+ case SID_ENABLE_HYPHENATION :
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ if ( !bEditable && bOnlyNotBecauseOfMatrix )
+ bNeedEdit = FALSE;
+ break;
+
+ case FID_VALIDATION:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ bDisable = TRUE;
+ }
+ }
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ ScViewUtil::HideDisabledSlot( rSet, GetViewData()->GetBindings(), nWhich );
+ break;
+ }
+ if (!bDisable && bNeedEdit && !bEditable)
+ bDisable = TRUE;
+
+ if (bDisable)
+ rSet.DisableItem(nWhich);
+ else if (nWhich == SID_ENABLE_HYPHENATION)
+ {
+ // toggle slots need a bool item
+ rSet.Put( SfxBoolItem( nWhich, FALSE ) );
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// Funktionen, die je nach Cursorposition disabled sind
+// Default:
+// SID_INSERT_POSTIT, SID_CHARMAP, SID_OPENDLG_FUNCTION
+
+void ScCellShell::GetCellState( SfxItemSet& rSet )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
+ ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ BOOL bDisable = FALSE;
+ BOOL bNeedEdit = TRUE; // muss Cursorposition editierbar sein?
+ switch ( nWhich )
+ {
+ case SID_THESAURUS:
+ {
+ CellType eType = pDoc->GetCellType( aCursor );
+ bDisable = ( eType != CELLTYPE_STRING && eType != CELLTYPE_EDIT);
+ if (!bDisable)
+ {
+ // test for available languages
+ USHORT nLang = ScViewUtil::GetEffLanguage( pDoc, aCursor );
+ bDisable = !ScModule::HasThesaurusLanguage( nLang );
+ }
+ }
+ break;
+ case SID_OPENDLG_FUNCTION:
+ {
+ ScMarkData aMarkData=GetViewData()->GetMarkData();
+ aMarkData.MarkToSimple();
+ ScRange aRange;
+ aMarkData.GetMarkArea(aRange);
+ if(aMarkData.IsMarked())
+ {
+ if (!pDoc->IsBlockEditable( aCursor.Tab(), aRange.aStart.Col(),aRange.aStart.Row(),
+ aRange.aEnd.Col(),aRange.aEnd.Row() ))
+ {
+ bDisable = TRUE;
+ }
+ bNeedEdit=FALSE;
+ }
+
+ }
+ break;
+ case SID_INSERT_POSTIT:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ bDisable = TRUE;
+ }
+ }
+ break;
+ }
+ if (!bDisable && bNeedEdit)
+ if (!pDoc->IsBlockEditable( aCursor.Tab(), aCursor.Col(),aCursor.Row(),
+ aCursor.Col(),aCursor.Row() ))
+ bDisable = TRUE;
+ if (bDisable)
+ rSet.DisableItem(nWhich);
+ nWhich = aIter.NextWhich();
+ }
+}
+
+sal_Bool lcl_TestFormat( SvxClipboardFmtItem& rFormats, const TransferableDataHelper& rDataHelper,
+ SotFormatStringId nFormatId )
+{
+ if ( rDataHelper.HasFormat( nFormatId ) )
+ {
+ // #90675# translated format name strings are no longer inserted here,
+ // handled by "paste special" dialog / toolbox controller instead.
+ // Only the object type name has to be set here:
+ String aStrVal;
+ if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ {
+ TransferableObjectDescriptor aDesc;
+ if ( ((TransferableDataHelper&)rDataHelper).GetTransferableObjectDescriptor(
+ SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDesc ) )
+ aStrVal = aDesc.maTypeName;
+ }
+ else if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE
+ || nFormatId == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE )
+ {
+ String aSource;
+ SvPasteObjectHelper::GetEmbeddedName( rDataHelper, aStrVal, aSource, nFormatId );
+ }
+
+ if ( aStrVal.Len() )
+ rFormats.AddClipbrdFormat( nFormatId, aStrVal );
+ else
+ rFormats.AddClipbrdFormat( nFormatId );
+
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+void ScCellShell::GetPossibleClipboardFormats( SvxClipboardFmtItem& rFormats )
+{
+ Window* pWin = GetViewData()->GetActiveWin();
+ BOOL bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DRAWING );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_SVXB );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_GDIMETAFILE );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_BITMAP );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ if ( !bDraw )
+ {
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_LINK );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_STRING );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_DIF );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMAT_RTF );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_HTML_SIMPLE );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_8 );
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_BIFF_5 );
+ }
+
+ if ( !lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) )
+ lcl_TestFormat( rFormats, aDataHelper, SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );
+}
+
+// Einfuegen, Inhalte einfuegen
+
+BOOL lcl_IsCellPastePossible( const TransferableDataHelper& rData )
+{
+ BOOL bPossible = FALSE;
+ if ( ScTransferObj::GetOwnClipboard( NULL ) || ScDrawTransferObj::GetOwnClipboard( NULL ) )
+ bPossible = TRUE;
+ else
+ {
+ if ( rData.HasFormat( SOT_FORMAT_BITMAP ) ||
+ rData.HasFormat( SOT_FORMAT_GDIMETAFILE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_SVXB ) ||
+ rData.HasFormat( FORMAT_PRIVATE ) ||
+ rData.HasFormat( SOT_FORMAT_RTF ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
+ rData.HasFormat( SOT_FORMAT_STRING ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_SYLK ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_LINK ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_HTML ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) ||
+ rData.HasFormat( SOT_FORMATSTR_ID_DIF ) )
+ {
+ bPossible = TRUE;
+ }
+ }
+ return bPossible;
+}
+
+IMPL_LINK( ScCellShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = lcl_IsCellPastePossible( *pDataHelper );
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+
+void __EXPORT ScCellShell::GetClipState( SfxItemSet& rSet )
+{
+// SID_PASTE
+// SID_PASTE_SPECIAL
+// SID_CLIPBOARD_FORMAT_ITEMS
+
+ if ( !pImpl->m_pClipEvtLstnr )
+ {
+ // create listener
+ pImpl->m_pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScCellShell, ClipboardChanged ) );
+ pImpl->m_pClipEvtLstnr->acquire();
+ Window* pWin = GetViewData()->GetActiveWin();
+ pImpl->m_pClipEvtLstnr->AddRemoveListener( pWin, TRUE );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+ bPastePossible = lcl_IsCellPastePossible( aDataHelper );
+ }
+
+ BOOL bDisable = !bPastePossible;
+
+ // Zellschutz / Multiselektion
+
+ if (!bDisable)
+ {
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
+ if (!pDoc->IsBlockEditable( nTab, nCol,nRow, nCol,nRow ))
+ bDisable = TRUE;
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ bDisable = TRUE;
+ }
+
+ if (bDisable)
+ {
+ rSet.DisableItem( SID_PASTE );
+ rSet.DisableItem( SID_PASTE_SPECIAL );
+ rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ else if ( rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) != SFX_ITEM_UNKNOWN )
+ {
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ GetPossibleClipboardFormats( aFormats );
+ rSet.Put( aFormats );
+ }
+}
+
+// only SID_HYPERLINK_GETLINK:
+
+void ScCellShell::GetHLinkState( SfxItemSet& rSet )
+{
+ // always return an item (or inserting will be disabled)
+ // if the cell at the cursor contains only a link, return that link
+
+ SvxHyperlinkItem aHLinkItem;
+ if ( !GetViewData()->GetView()->HasBookmarkAtCursor( &aHLinkItem ) )
+ {
+ //! put selected text into item?
+ }
+
+ rSet.Put(aHLinkItem);
+}
+
+void ScCellShell::GetState(SfxItemSet &rSet)
+{
+ // removed: SID_BORDER_OBJECT (old Basic)
+
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+// BOOL bOle = pTabViewShell->GetViewFrame()->GetFrame().IsInPlace();
+// BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScViewData* pData = GetViewData();
+ ScDocument* pDoc = pData->GetDocument();
+ ScMarkData& rMark = pData->GetMarkData();
+ SCCOL nPosX = pData->GetCurX();
+ SCROW nPosY = pData->GetCurY();
+ SCTAB nTab = pData->GetTabNo();
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_DETECTIVE_REFRESH:
+ if (!pDoc->HasDetectiveOperations())
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_RANGE_ADDRESS:
+ {
+ ScRange aRange;
+ if ( pData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ String aStr;
+ USHORT nFlags = SCA_VALID | SCA_TAB_3D;
+ aRange.Format(aStr,nFlags,pDoc);
+ rSet.Put( SfxStringItem( nWhich, aStr ) );
+ }
+ }
+ break;
+
+ case SID_RANGE_NOTETEXT:
+ {
+ // #43343# always take cursor position, do not use top-left cell of selection
+ ScAddress aPos( nPosX, nPosY, nTab );
+ String aNoteText;
+ if ( const ScPostIt* pNote = pDoc->GetNote( aPos ) )
+ aNoteText = pNote->GetText();
+ rSet.Put( SfxStringItem( nWhich, aNoteText ) );
+ }
+ break;
+
+ case SID_RANGE_ROW:
+ rSet.Put( SfxInt32Item( nWhich, nPosY+1 ) );
+ break;
+
+ case SID_RANGE_COL:
+ rSet.Put( SfxInt16Item( nWhich, nPosX+1 ) );
+ break;
+
+ case SID_RANGE_TABLE:
+ rSet.Put( SfxInt16Item( nWhich, nTab+1 ) );
+ break;
+
+ case SID_RANGE_VALUE:
+ {
+ double nValue;
+ pDoc->GetValue( nPosX, nPosY, nTab, nValue );
+ rSet.Put( ScDoubleItem( nWhich, nValue ) );
+ }
+ break;
+
+ case SID_RANGE_FORMULA:
+ {
+ String aString;
+ pDoc->GetFormula( nPosX, nPosY, nTab, aString );
+ if( aString.Len() == 0 )
+ {
+ pDoc->GetInputString( nPosX, nPosY, nTab, aString );
+ }
+ rSet.Put( SfxStringItem( nWhich, aString ) );
+ }
+ break;
+
+ case SID_RANGE_TEXTVALUE:
+ {
+ String aString;
+ pDoc->GetString( nPosX, nPosY, nTab, aString );
+ rSet.Put( SfxStringItem( nWhich, aString ) );
+ }
+ break;
+
+ case SID_STATUS_SELMODE:
+ {
+ /* 0: STD Click hebt Sel auf
+ * 1: ER Click erweitert Selektion
+ * 2: ERG Click definiert weitere Selektion
+ */
+ USHORT nMode = pTabViewShell->GetLockedModifiers();
+
+ switch ( nMode )
+ {
+ case KEY_SHIFT: nMode = 1; break;
+ case KEY_MOD1: nMode = 2; break; // Control-Taste
+ case 0:
+ default:
+ nMode = 0;
+ }
+
+ rSet.Put( SfxUInt16Item( nWhich, nMode ) );
+ }
+ break;
+
+ case SID_STATUS_DOCPOS:
+ {
+ String aStr( ScGlobal::GetRscString( STR_TABLE ) );
+
+ aStr += ' ';
+ aStr += String::CreateFromInt32( nTab + 1 );
+ aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aStr += String::CreateFromInt32( nTabCount );
+ rSet.Put( SfxStringItem( nWhich, aStr ) );
+ }
+ break;
+
+ // Summe etc. mit Datum/Zeit/Fehler/Pos&Groesse zusammengefasst
+
+ // #i34458# The SfxStringItem belongs only into SID_TABLE_CELL. It no longer has to be
+ // duplicated in SID_ATTR_POSITION or SID_ATTR_SIZE for SvxPosSizeStatusBarControl.
+ case SID_TABLE_CELL:
+ {
+ // Testen, ob Fehler unter Cursor
+ // (nicht pDoc->GetErrCode, um keine zirkulaeren Referenzen auszuloesen)
+
+ // In interpreter may happen via rescheduled Basic
+ if ( pDoc->IsInInterpreter() )
+ rSet.Put( SfxStringItem( nWhich,
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("...")) ) );
+ else
+ {
+ USHORT nErrCode = 0;
+ ScBaseCell* pCell;
+ pDoc->GetCell( nPosX, nPosY, nTab, pCell );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
+ if (!pFCell->IsRunning())
+ nErrCode = pFCell->GetErrCode();
+ }
+
+ String aFuncStr;
+ if ( pTabViewShell->GetFunction( aFuncStr, nErrCode ) )
+ rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
+ }
+ }
+ break;
+
+ case SID_DATA_SELECT:
+ // HasSelectionData includes column content and validity,
+ // page fields have to be checked separately.
+ if ( !pDoc->HasSelectionData( nPosX, nPosY, nTab ) &&
+ !pTabViewShell->HasPageFieldDataAtCursor() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_STATUS_SUM:
+ {
+ String aFuncStr;
+ if ( pTabViewShell->GetFunction( aFuncStr ) )
+ rSet.Put( SfxStringItem( nWhich, aFuncStr ) );
+ }
+ break;
+
+ case FID_MERGE_ON:
+ if ( pDoc->GetChangeTrack() || !pTabViewShell->TestMergeCells() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_MERGE_OFF:
+ if ( pDoc->GetChangeTrack() || !pTabViewShell->TestRemoveMerge() )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_MERGE_TOGGLE:
+ if ( pDoc->GetChangeTrack() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ bool bCanMerge = pTabViewShell->TestMergeCells();
+ bool bCanSplit = pTabViewShell->TestRemoveMerge();
+ if( !bCanMerge && !bCanSplit )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem( nWhich, bCanSplit ) );
+ }
+ break;
+
+ case FID_INS_ROWBRK:
+ if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_INS_COLBRK:
+ if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_DEL_ROWBRK:
+ if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) == 0 )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_DEL_COLBRK:
+ if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) == 0 )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_FILL_TAB:
+ if ( nTabSelCount < 2 )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_SELECT_SCENARIO:
+ {
+ // ScDocument* pDoc = GetViewData()->GetDocument();
+ // SCTAB nTab = GetViewData()->GetTabNo();
+ List aList;
+
+ Color aDummyCol;
+
+ if ( !pDoc->IsScenario(nTab) )
+ {
+ String aStr;
+ USHORT nFlags;
+ SCTAB nScTab = nTab + 1;
+ String aProtect;
+ bool bSheetProtected = pDoc->IsTabProtected(nTab);
+
+ while ( pDoc->IsScenario(nScTab) )
+ {
+ pDoc->GetName( nScTab, aStr );
+ aList.Insert( new String( aStr ), LIST_APPEND );
+ pDoc->GetScenarioData( nScTab, aStr, aDummyCol, nFlags );
+ aList.Insert( new String( aStr ), LIST_APPEND );
+ // Protection is TRUE if both Sheet and Scenario are protected
+ aProtect = (bSheetProtected && (nFlags & SC_SCENARIO_PROTECT)) ? '1' : '0';
+ aList.Insert( new String( aProtect), LIST_APPEND );
+ ++nScTab;
+ }
+ }
+ else
+ {
+ String aComment;
+ USHORT nDummyFlags;
+ pDoc->GetScenarioData( nTab, aComment, aDummyCol, nDummyFlags );
+ DBG_ASSERT( aList.Count() == 0, "List not empty!" );
+ aList.Insert( new String( aComment ) );
+ }
+
+ rSet.Put( SfxStringListItem( nWhich, &aList ) );
+
+ ULONG nCount = aList.Count();
+ for ( ULONG i=0; i<nCount; i++ )
+ delete (String*) aList.GetObject(i);
+ }
+ break;
+
+ case FID_ROW_HIDE:
+ case FID_ROW_SHOW:
+ case FID_COL_HIDE:
+ case FID_COL_SHOW:
+ case FID_COL_OPT_WIDTH:
+ case FID_ROW_OPT_HEIGHT:
+ case FID_DELETE_CELL:
+ if ( pDoc->IsTabProtected(nTab) || pDocSh->IsReadOnly())
+ rSet.DisableItem( nWhich );
+ break;
+
+/* Zellschutz bei selektierten Zellen wird bei anderen Funktionen auch nicht abgefragt...
+ case SID_DELETE:
+ {
+ if ( pDoc->IsTabProtected(nTab) )
+ {
+ const SfxItemSet& rAttrSet = GetSelectionPattern()->GetItemSet();
+ const ScProtectionAttr& rProtAttr = (const ScProtectionAttr&)rAttrSet.Get( ATTR_PROTECTION, TRUE );
+ if ( rProtAttr.GetProtection() )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+*/
+ case SID_OUTLINE_MAKE:
+ {
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ case SID_OUTLINE_SHOW:
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else if (!pTabViewShell->OutlinePossible(FALSE))
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OUTLINE_HIDE:
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else if (!pTabViewShell->OutlinePossible(TRUE))
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_OUTLINE_REMOVE:
+ {
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ //! test for data pilot operation
+ }
+ else
+ {
+ BOOL bCol, bRow;
+ pTabViewShell->TestRemoveOutline( bCol, bRow );
+ if ( !bCol && !bRow )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FID_COL_WIDTH:
+ {
+ //GetViewData()->GetCurX();
+ SfxUInt16Item aWidthItem( FID_COL_WIDTH, pDoc->GetColWidth( nPosX , nTab) );
+ rSet.Put( aWidthItem );
+ if ( pDocSh->IsReadOnly())
+ rSet.DisableItem( nWhich );
+
+ //XXX Disablen wenn nicht eindeutig
+ }
+ break;
+
+ case FID_ROW_HEIGHT:
+ {
+ //GetViewData()->GetCurY();
+ SfxUInt16Item aHeightItem( FID_ROW_HEIGHT, pDoc->GetRowHeight( nPosY , nTab) );
+ rSet.Put( aHeightItem );
+ //XXX Disablen wenn nicht eindeutig
+ if ( pDocSh->IsReadOnly())
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DETECTIVE_FILLMODE:
+ rSet.Put(SfxBoolItem( nWhich, pTabViewShell->IsAuditShell() ));
+ break;
+
+ case FID_INPUTLINE_STATUS:
+ DBG_ERROR( "Old update method. Use ScTabViewShell::UpdateInputHandler()." );
+ break;
+
+ case SID_SCENARIOS: // Szenarios:
+ if (!(rMark.IsMarked() || rMark.IsMultiMarked())) // nur, wenn etwas selektiert
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_NOTE_VISIBLE:
+ {
+ const ScPostIt* pNote = pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) );
+ if ( pNote && pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) )
+ rSet.Put( SfxBoolItem( nWhich, pNote->IsCaptionShown() ) );
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DELETE_NOTE:
+ {
+ BOOL bEnable = FALSE;
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ if ( pDoc->IsSelectionEditable( rMark ) )
+ {
+ // look for at least one note in selection
+ ScRangeList aRanges;
+ rMark.FillRangeListWithMarks( &aRanges, FALSE );
+ ULONG nCount = aRanges.Count();
+ for (ULONG nPos=0; nPos<nCount && !bEnable; nPos++)
+ {
+ ScCellIterator aCellIter( pDoc, *aRanges.GetObject(nPos) );
+ for( ScBaseCell* pCell = aCellIter.GetFirst(); pCell && !bEnable; pCell = aCellIter.GetNext() )
+ if ( pCell->HasNote() )
+ bEnable = TRUE; // note found
+ }
+ }
+ }
+ else
+ {
+ bEnable = pDoc->IsBlockEditable( nTab, nPosX,nPosY, nPosX,nPosY ) &&
+ pDoc->GetNote( ScAddress( nPosX, nPosY, nTab ) );
+ }
+ if ( !bEnable )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_OPENDLG_CONSOLIDATE:
+ case SCITEM_CONSOLIDATEDATA:
+ {
+ if(pDoc->GetChangeTrack()!=NULL)
+ rSet.DisableItem( nWhich);
+ }
+ break;
+
+ case SID_CHINESE_CONVERSION:
+ case SID_HANGUL_HANJA_CONVERSION:
+ ScViewUtil::HideDisabledSlot( rSet, pData->GetBindings(), nWhich );
+ break;
+
+ case FID_USE_NAME:
+ {
+ if ( pDocSh && pDocSh->IsDocShared() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ ScRange aRange;
+ if ( pData->GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FID_DEFINE_NAME:
+ case FID_INSERT_NAME:
+ case SID_DEFINE_COLROWNAMERANGES:
+ {
+ if ( pDocSh && pDocSh->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_SPELL_DIALOG:
+ {
+ if ( pDoc && pData && pDoc->IsTabProtected( pData->GetTabNo() ) )
+ {
+ bool bVisible = false;
+ SfxViewFrame* pViewFrame = ( pTabViewShell ? pTabViewShell->GetViewFrame() : NULL );
+ if ( pViewFrame && pViewFrame->HasChildWindow( nWhich ) )
+ {
+ SfxChildWindow* pChild = pViewFrame->GetChildWindow( nWhich );
+ Window* pWin = ( pChild ? pChild->GetWindow() : NULL );
+ if ( pWin && pWin->IsVisible() )
+ {
+ bVisible = true;
+ }
+ }
+ if ( !bVisible )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ }
+ break;
+
+ } // switch ( nWitch )
+ nWhich = aIter.NextWhich();
+ } // while ( nWitch )
+}
+
+//------------------------------------------------------------------
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
new file mode 100644
index 000000000000..bd139fab1fd8
--- /dev/null
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -0,0 +1,2198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+//------------------------------------------------------------------
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SI_NOSBXCONTROLS
+#define _VCONT_HXX
+#define _SI_NOOTHERFORMS
+#define _VCTRLS_HXX
+#define _SI_NOCONTROL
+#define _SETBRW_HXX
+#define _VCBRW_HXX
+#define _SI_NOSBXCONTROLS
+
+//------------------------------------------------------------------
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+
+#define _ZFORLIST_DECLARE_TABLE
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/svxdlg.hxx>
+#include <sot/formats.hxx>
+#include <svx/postattr.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <sfx2/passwd.hxx>
+#include <svx/hlnkitem.hxx>
+#include <basic/sbxcore.hxx>
+#include <unotools/useroptions.hxx>
+#include <vcl/waitobj.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "cellsh.hxx"
+#include "sc.hrc"
+#include "document.hxx"
+#include "patattr.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "reffind.hxx"
+#include "uiitems.hxx"
+#include "reffact.hxx"
+#include "inputhdl.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "docfunc.hxx"
+#include "editable.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpgroup.hxx" // for ScDPNumGroupInfo
+#include "spellparam.hxx"
+#include "postit.hxx"
+#include "clipparam.hxx"
+
+#include "globstr.hrc"
+#include "scui_def.hxx"
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "scabstdlg.hxx"
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+#define C2U(cChar) rtl::OUString::createFromAscii(cChar)
+
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/bootstrap.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+
+//------------------------------------------------------------------
+void ScCellShell::ExecuteEdit( SfxRequest& rReq )
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ // Eingabe beenden
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ switch ( nSlot )
+ {
+ case FID_DEFINE_NAME:
+ case FID_USE_NAME:
+ case FID_INSERT_NAME:
+ case SID_SPELL_DIALOG:
+ case SID_HANGUL_HANJA_CONVERSION:
+
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch ( nSlot )
+ {
+ //
+ // Einfuegen / Loeschen von Zellen / Zeilen / Spalten
+ //
+
+ case FID_INS_ROW:
+ pTabViewShell->InsertCells(INS_INSROWS);
+ rReq.Done();
+ break;
+
+ case FID_INS_COLUMN:
+ pTabViewShell->InsertCells(INS_INSCOLS);
+ rReq.Done();
+ break;
+
+ case FID_INS_CELLSDOWN:
+ pTabViewShell->InsertCells(INS_CELLSDOWN);
+ rReq.Done();
+ break;
+
+ case FID_INS_CELLSRIGHT:
+ pTabViewShell->InsertCells(INS_CELLSRIGHT);
+ rReq.Done();
+ break;
+
+ case SID_DEL_ROWS:
+ pTabViewShell->DeleteCells( DEL_DELROWS );
+ rReq.Done();
+ break;
+
+ case SID_DEL_COLS:
+ pTabViewShell->DeleteCells( DEL_DELCOLS );
+ rReq.Done();
+ break;
+
+ case FID_INS_CELL:
+ {
+ InsCellCmd eCmd=INS_NONE;
+
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags;
+
+ if( IS_AVAILABLE( FID_INS_CELL, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+ if( aFlags.Len() )
+ {
+ switch( aFlags.GetChar(0) )
+ {
+ case 'V': eCmd = INS_CELLSDOWN ;break;
+ case '>': eCmd = INS_CELLSRIGHT ;break;
+ case 'R': eCmd = INS_INSROWS ;break;
+ case 'C': eCmd = INS_INSCOLS ;break;
+ }
+ }
+ }
+ else
+ {
+ if ( GetViewData()->SimpleColMarked() )
+ eCmd = INS_INSCOLS;
+ else if ( GetViewData()->SimpleRowMarked() )
+ eCmd = INS_INSROWS;
+ else
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ BOOL bTheFlag=(pDoc->GetChangeTrack()!=NULL);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertCellDlg* pDlg = pFact->CreateScInsertCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_INSCELL, bTheFlag);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if (pDlg->Execute() == RET_OK)
+ eCmd = pDlg->GetInsCellCmd();
+ delete pDlg;
+ }
+ }
+
+ if (eCmd!=INS_NONE)
+ {
+ pTabViewShell->InsertCells( eCmd );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aParam;
+
+ switch( eCmd )
+ {
+ case INS_CELLSDOWN: aParam='V'; break;
+ case INS_CELLSRIGHT: aParam='>'; break;
+ case INS_INSROWS: aParam='R'; break;
+ case INS_INSCOLS: aParam='C'; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case FID_DELETE_CELL:
+ {
+ DelCellCmd eCmd = DEL_NONE;
+
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags;
+
+ if( IS_AVAILABLE( FID_DELETE_CELL, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+ if( aFlags.Len() )
+ {
+ switch( aFlags.GetChar(0) )
+ {
+ case 'U': eCmd = DEL_CELLSUP ;break;
+ case 'L': eCmd = DEL_CELLSLEFT ;break;
+ case 'R': eCmd = DEL_DELROWS ;break;
+ case 'C': eCmd = DEL_DELCOLS ;break;
+ }
+ }
+ }
+ else
+ {
+ if ( GetViewData()->SimpleColMarked() )
+ eCmd = DEL_DELCOLS;
+ else if ( GetViewData()->SimpleRowMarked() )
+ eCmd = DEL_DELROWS;
+ else
+ {
+ ScRange aRange;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ BOOL bTheFlag=GetViewData()->IsMultiMarked() ||
+ (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE_FILTERED) ||
+ (pDoc->GetChangeTrack() != NULL);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDeleteCellDlg* pDlg = pFact->CreateScDeleteCellDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCELL, bTheFlag );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if (pDlg->Execute() == RET_OK)
+ eCmd = pDlg->GetDelCellCmd();
+ delete pDlg;
+ }
+ }
+
+ if (eCmd != DEL_NONE )
+ {
+ pTabViewShell->DeleteCells( eCmd );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aParam;
+
+ switch( eCmd )
+ {
+ case DEL_CELLSUP: aParam='U'; break;
+ case DEL_CELLSLEFT: aParam='L'; break;
+ case DEL_DELROWS: aParam='R'; break;
+ case DEL_DELCOLS: aParam='C'; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //
+ // Inhalte von Zellen loeschen
+ //
+
+ case SID_DELETE_CONTENTS:
+ pTabViewShell->DeleteContents( IDF_CONTENTS );
+ rReq.Done();
+ break;
+
+ case SID_DELETE:
+ {
+ USHORT nFlags = IDF_NONE;
+
+ if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags = 'A';
+
+ if( IS_AVAILABLE( SID_DELETE, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+
+ aFlags.ToUpperAscii();
+ BOOL bCont = TRUE;
+
+ for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
+ {
+ switch( aFlags.GetChar(i) )
+ {
+ case 'A': // Alle
+ nFlags |= IDF_ALL;
+ bCont = FALSE; // nicht mehr weitermachen!
+ break;
+ case 'S': nFlags |= IDF_STRING; break;
+ case 'V': nFlags |= IDF_VALUE; break;
+ case 'D': nFlags |= IDF_DATETIME; break;
+ case 'F': nFlags |= IDF_FORMULA; break;
+ case 'N': nFlags |= IDF_NOTE; break;
+ case 'T': nFlags |= IDF_ATTRIB; break;
+ case 'O': nFlags |= IDF_OBJECTS; break;
+ }
+ }
+ }
+ else
+ {
+ ScEditableTester aTester( pTabViewShell );
+ if (aTester.IsEditable())
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDeleteContentsDlg* pDlg = pFact->CreateScDeleteContentsDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DELCONT );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ if ( pDoc->IsTabProtected(nTab) )
+ pDlg->DisableObjects();
+ if (pDlg->Execute() == RET_OK)
+ {
+ nFlags = pDlg->GetDelContentsCmdBits();
+ }
+ delete pDlg;
+ }
+ else
+ pTabViewShell->ErrorMessage(aTester.GetMessageId());
+ }
+
+ if( nFlags != IDF_NONE )
+ {
+ pTabViewShell->DeleteContents( nFlags );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aFlags;
+
+ if( nFlags == IDF_ALL )
+ {
+ aFlags += 'A';
+ }
+ else
+ {
+ if( nFlags & IDF_STRING ) aFlags += 'S';
+ if( nFlags & IDF_VALUE ) aFlags += 'V';
+ if( nFlags & IDF_DATETIME ) aFlags += 'D';
+ if( nFlags & IDF_FORMULA ) aFlags += 'F';
+ if( nFlags & IDF_NOTE ) aFlags += 'N';
+ if( nFlags & IDF_ATTRIB ) aFlags += 'T';
+ if( nFlags & IDF_OBJECTS ) aFlags += 'O';
+ }
+
+ rReq.AppendItem( SfxStringItem( SID_DELETE, aFlags ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //
+ // Ausfuellen...
+ //
+
+ case FID_FILL_TO_BOTTOM:
+ pTabViewShell->FillSimple( FILL_TO_BOTTOM );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TO_RIGHT:
+ pTabViewShell->FillSimple( FILL_TO_RIGHT );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TO_TOP:
+ pTabViewShell->FillSimple( FILL_TO_TOP );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TO_LEFT:
+ pTabViewShell->FillSimple( FILL_TO_LEFT );
+ rReq.Done();
+ break;
+
+ case FID_FILL_TAB:
+ {
+ USHORT nFlags = IDF_NONE;
+ USHORT nFunction = PASTE_NOFUNC;
+ BOOL bSkipEmpty = FALSE;
+ BOOL bAsLink = FALSE;
+
+ if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags = 'A';
+
+ if( IS_AVAILABLE( FID_FILL_TAB, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+
+ aFlags.ToUpperAscii();
+ BOOL bCont = TRUE;
+
+ for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
+ {
+ switch( aFlags.GetChar(i) )
+ {
+ case 'A': // Alle
+ nFlags |= IDF_ALL;
+ bCont = FALSE; // nicht mehr weitermachen!
+ break;
+ case 'S': nFlags |= IDF_STRING; break;
+ case 'V': nFlags |= IDF_VALUE; break;
+ case 'D': nFlags |= IDF_DATETIME; break;
+ case 'F': nFlags |= IDF_FORMULA; break;
+ case 'N': nFlags |= IDF_NOTE; break;
+ case 'T': nFlags |= IDF_ATTRIB; break;
+ }
+ }
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_INSCONT, 0, /* nCheckDefaults */
+ &ScGlobal::GetRscString(STR_FILL_TAB));
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetFillMode(TRUE);
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ nFlags = pDlg->GetInsContentsCmdBits();
+ nFunction = pDlg->GetFormulaCmdBits();
+ bSkipEmpty = pDlg->IsSkipEmptyCells();
+ bAsLink = pDlg->IsLink();
+ // MoveMode gibt's bei Tabelle fuellen nicht
+ }
+ delete pDlg;
+ }
+
+ if( nFlags != IDF_NONE )
+ {
+ pTabViewShell->FillTab( nFlags, nFunction, bSkipEmpty, bAsLink );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aFlags;
+
+ if( nFlags == IDF_ALL )
+ {
+ aFlags += 'A';
+ }
+ else
+ {
+ if( nFlags & IDF_STRING ) aFlags += 'S';
+ if( nFlags & IDF_VALUE ) aFlags += 'V';
+ if( nFlags & IDF_DATETIME ) aFlags += 'D';
+ if( nFlags & IDF_FORMULA ) aFlags += 'F';
+ if( nFlags & IDF_NOTE ) aFlags += 'N';
+ if( nFlags & IDF_ATTRIB ) aFlags += 'T';
+ }
+
+ rReq.AppendItem( SfxStringItem( FID_FILL_TAB, aFlags ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case FID_FILL_SERIES:
+ {
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+ USHORT nPossDir = FDS_OPT_NONE;
+ FillDir eFillDir = FILL_TO_BOTTOM;
+ FillCmd eFillCmd = FILL_LINEAR;
+ FillDateCmd eFillDateCmd = FILL_DAY;
+ double fStartVal = MAXDOUBLE;
+ double fIncVal = 1;
+ double fMaxVal = MAXDOUBLE;
+ BOOL bDoIt = FALSE;
+
+ GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ if( nStartCol!=nEndCol )
+ {
+ nPossDir |= FDS_OPT_HORZ;
+ eFillDir=FILL_TO_RIGHT;
+ }
+
+ if( nStartRow!=nEndRow )
+ {
+ nPossDir |= FDS_OPT_VERT;
+ eFillDir=FILL_TO_BOTTOM;
+ }
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aFillDir, aFillCmd, aFillDateCmd;
+ String aFillStep, aFillStart, aFillMax;
+ sal_uInt32 nKey;
+ double fTmpVal;
+
+ bDoIt=FALSE;
+
+ if( IS_AVAILABLE( FID_FILL_SERIES, &pItem ) )
+ aFillDir = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ aFillCmd = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ aFillDateCmd = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_3, &pItem ) )
+ aFillStep = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_4, &pItem ) )
+ aFillStart = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_5, &pItem ) )
+ aFillMax = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( aFillDir.Len() )
+ switch( aFillDir.GetChar(0) )
+ {
+ case 'B': case 'b': eFillDir=FILL_TO_BOTTOM; break;
+ case 'R': case 'r': eFillDir=FILL_TO_RIGHT; break;
+ case 'T': case 't': eFillDir=FILL_TO_TOP; break;
+ case 'L': case 'l': eFillDir=FILL_TO_LEFT; break;
+ }
+
+ if( aFillCmd.Len() )
+ switch( aFillCmd.GetChar(0) )
+ {
+ case 'S': case 's': eFillCmd=FILL_SIMPLE; break;
+ case 'L': case 'l': eFillCmd=FILL_LINEAR; break;
+ case 'G': case 'g': eFillCmd=FILL_GROWTH; break;
+ case 'D': case 'd': eFillCmd=FILL_DATE; break;
+ case 'A': case 'a': eFillCmd=FILL_AUTO; break;
+ }
+
+ if( aFillDateCmd.Len() )
+ switch( aFillDateCmd.GetChar(0) )
+ {
+ case 'D': case 'd': eFillDateCmd=FILL_DAY; break;
+ case 'W': case 'w': eFillDateCmd=FILL_WEEKDAY; break;
+ case 'M': case 'm': eFillDateCmd=FILL_MONTH; break;
+ case 'Y': case 'y': eFillDateCmd=FILL_YEAR; break;
+ }
+
+ nKey = 0;
+ if( pFormatter->IsNumberFormat( aFillStart, nKey, fTmpVal ))
+ fStartVal = fTmpVal;
+
+ nKey = 0;
+ if( pFormatter->IsNumberFormat( aFillStep, nKey, fTmpVal ))
+ fIncVal = fTmpVal;
+
+ nKey = 0;
+ if( pFormatter->IsNumberFormat( aFillMax, nKey, fTmpVal ))
+ fMaxVal = fTmpVal;
+
+ bDoIt = TRUE;
+
+ }
+ else // (pReqArgs == NULL) => Dialog hochziehen
+ {
+ //
+ sal_uInt32 nPrivFormat;
+ CellType eCellType;
+ pDoc->GetNumberFormat( nStartCol, nStartRow, nStartTab, nPrivFormat );
+ pDoc->GetCellType( nStartCol, nStartRow, nStartTab,eCellType );
+ const SvNumberformat* pPrivEntry = pFormatter->GetEntry( nPrivFormat );
+ if (!pPrivEntry)
+ {
+ DBG_ERROR("Zahlformat nicht gefunden !!!");
+ }
+ else
+ {
+ short nPrivType = pPrivEntry->GetType();
+ if ( ( nPrivType & NUMBERFORMAT_DATE)>0)
+ {
+ eFillCmd=FILL_DATE;
+ }
+ else if(eCellType==CELLTYPE_STRING)
+ {
+ eFillCmd=FILL_AUTO;
+ }
+ }
+
+ //
+ String aStartStr;
+
+ // Startwert nur vorbelegen, wenn nur 1 Zeile oder Spalte:
+ if ( nStartCol == nEndCol || nStartRow == nEndRow )
+ {
+ double fInputEndVal = 0.0;
+ String aEndStr;
+
+ pDoc->GetInputString( nStartCol, nStartRow, nStartTab, aStartStr);
+ pDoc->GetValue( nStartCol, nStartRow, nStartTab, fStartVal );
+
+
+ if(eFillDir==FILL_TO_BOTTOM && nStartRow < nEndRow )
+ {
+ pDoc->GetInputString( nStartCol, nStartRow+1, nStartTab, aEndStr);
+ if(aEndStr.Len()>0)
+ {
+ pDoc->GetValue( nStartCol, nStartRow+1, nStartTab, fInputEndVal);
+ fIncVal=fInputEndVal-fStartVal;
+ }
+ }
+ else
+ {
+ if(nStartCol < nEndCol)
+ {
+ pDoc->GetInputString( nStartCol+1, nStartRow, nStartTab, aEndStr);
+ if(aEndStr.Len()>0)
+ {
+ pDoc->GetValue( nStartCol+1, nStartRow, nStartTab, fInputEndVal);
+ fIncVal=fInputEndVal-fStartVal;
+ }
+ }
+ }
+ if(eFillCmd==FILL_DATE)
+ {
+ Date aNullDate = *pDoc->GetFormatTable()->GetNullDate();
+ Date aStartDate = aNullDate;
+ aStartDate+= (long)fStartVal;
+ Date aEndDate = aNullDate;
+ aEndDate+= (long)fInputEndVal;
+ double fTempDate=0;
+
+ if(aStartDate.GetYear()!=aEndDate.GetYear())
+ {
+ eFillDateCmd = FILL_YEAR;
+ fTempDate=aEndDate.GetYear()-aStartDate.GetYear();
+ }
+ if(aStartDate.GetMonth()!=aEndDate.GetMonth())
+ {
+ eFillDateCmd = FILL_MONTH;
+ fTempDate=fTempDate*12+aEndDate.GetMonth()-aStartDate.GetMonth();
+ }
+ if(aStartDate.GetDay()==aEndDate.GetDay())
+ {
+ fIncVal=fTempDate;
+ }
+ }
+ }
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScFillSeriesDlg* pDlg = pFact->CreateScFillSeriesDlg( pTabViewShell->GetDialogParent(),
+ *pDoc,
+ eFillDir, eFillCmd, eFillDateCmd,
+ aStartStr, fIncVal, fMaxVal,
+ nPossDir,
+ RID_SCDLG_FILLSERIES);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( nStartCol != nEndCol && nStartRow != nEndRow )
+ {
+ pDlg->SetEdStartValEnabled(FALSE);
+ }
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ eFillDir = pDlg->GetFillDir();
+ eFillCmd = pDlg->GetFillCmd();
+ eFillDateCmd = pDlg->GetFillDateCmd();
+
+ if(eFillCmd==FILL_AUTO)
+ {
+ String aStr=pDlg->GetStartStr();
+ if(aStr.Len()>0)
+ pTabViewShell->EnterData( nStartCol, nStartRow, nStartTab, aStr );
+ }
+ fStartVal = pDlg->GetStart();
+ fIncVal = pDlg->GetStep();
+ fMaxVal = pDlg->GetMax();
+ bDoIt = TRUE;
+ }
+ delete pDlg;
+ }
+
+ if( bDoIt )
+ {
+ //nScFillModeMouseModifier = 0; // kein Ctrl/Copy
+ pTabViewShell->FillSeries( eFillDir, eFillCmd, eFillDateCmd, fStartVal, fIncVal, fMaxVal );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aPara;
+ Color* pColor=0;
+
+ switch( eFillDir )
+ {
+ case FILL_TO_BOTTOM: aPara = 'B'; break;
+ case FILL_TO_RIGHT: aPara = 'R'; break;
+ case FILL_TO_TOP: aPara = 'T'; break;
+ case FILL_TO_LEFT: aPara = 'L'; break;
+ default: aPara.Erase(); break;
+ }
+ rReq.AppendItem( SfxStringItem( FID_FILL_SERIES, aPara ) );
+
+ switch( eFillCmd )
+ {
+ case FILL_SIMPLE: aPara = 'S'; break;
+ case FILL_LINEAR: aPara = 'L'; break;
+ case FILL_GROWTH: aPara = 'G'; break;
+ case FILL_DATE: aPara = 'D'; break;
+ case FILL_AUTO: aPara = 'A'; break;
+ default: aPara.Erase(); break;
+ }
+ rReq.AppendItem( SfxStringItem( FN_PARAM_1, aPara ) );
+
+ switch( eFillDateCmd )
+ {
+ case FILL_DAY: aPara = 'D'; break;
+ case FILL_WEEKDAY: aPara = 'W'; break;
+ case FILL_MONTH: aPara = 'M'; break;
+ case FILL_YEAR: aPara = 'Y'; break;
+ default: aPara.Erase(); break;
+ }
+ rReq.AppendItem( SfxStringItem( FN_PARAM_2, aPara ) );
+
+ ULONG nFormatKey = pFormatter->GetStandardFormat(NUMBERFORMAT_NUMBER,
+ ScGlobal::eLnge );
+
+ pFormatter->GetOutputString( fIncVal, nFormatKey, aPara, &pColor );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_3, aPara ) );
+
+ pFormatter->GetOutputString( fStartVal, nFormatKey, aPara, &pColor );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_4, aPara ) );
+
+ pFormatter->GetOutputString( fMaxVal, nFormatKey, aPara, &pColor );
+ rReq.AppendItem( SfxStringItem( FN_PARAM_5, aPara ) );
+
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case FID_FILL_AUTO:
+ {
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nStartTab, nEndTab;
+
+ GetViewData()->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
+ SCCOL nFillCol = GetViewData()->GetRefEndX();
+ SCROW nFillRow = GetViewData()->GetRefEndY();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+
+ if( IS_AVAILABLE( FID_FILL_AUTO, &pItem ) )
+ {
+ ScAddress aScAddress;
+ String aArg = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( aScAddress.Parse( aArg, pDoc, pDoc->GetAddressConvention() ) & SCA_VALID )
+ {
+ nFillRow = aScAddress.Row();
+ nFillCol = aScAddress.Col();
+ }
+ }
+
+ GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
+ nEndCol,nEndRow,nEndTab );
+ }
+ else // Aufruf per Maus
+ {
+ // #55284# nicht innerhalb einer zusammengefassten Zelle
+
+ if ( nStartCol == nEndCol && nStartRow == nEndRow )
+ {
+ SCCOL nMergeCol = nStartCol;
+ SCROW nMergeRow = nStartRow;
+ if ( GetViewData()->GetDocument()->ExtendMerge(
+ nStartCol, nStartRow, nMergeCol, nMergeRow,
+ GetViewData()->GetTabNo() ) )
+ {
+ if ( nFillCol >= nStartCol && nFillCol <= nMergeCol && nFillRow == nStartRow )
+ nFillCol = nStartCol;
+ if ( nFillRow >= nStartRow && nFillRow <= nMergeRow && nFillCol == nStartCol )
+ nFillRow = nStartRow;
+ }
+ }
+ }
+
+ if ( nFillCol != nEndCol || nFillRow != nEndRow )
+ {
+ if ( nFillCol==nEndCol || nFillRow==nEndRow )
+ {
+ FillDir eDir = FILL_TO_BOTTOM;
+ SCCOLROW nCount = 0;
+
+ if ( nFillCol==nEndCol )
+ {
+ if ( nFillRow > nEndRow )
+ {
+ eDir = FILL_TO_BOTTOM;
+ nCount = nFillRow - nEndRow;
+ }
+ else if ( nFillRow < nStartRow )
+ {
+ eDir = FILL_TO_TOP;
+ nCount = nStartRow - nFillRow;
+ }
+ }
+ else
+ {
+ if ( nFillCol > nEndCol )
+ {
+ eDir = FILL_TO_RIGHT;
+ nCount = nFillCol - nEndCol;
+ }
+ else if ( nFillCol < nStartCol )
+ {
+ eDir = FILL_TO_LEFT;
+ nCount = nStartCol - nFillCol;
+ }
+ }
+
+ if ( nCount != 0)
+ {
+ pTabViewShell->FillAuto( eDir, nStartCol, nStartRow, nEndCol, nEndRow, nCount );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aAdrStr;
+ ScAddress aAdr( nFillCol, nFillRow, 0 );
+ aAdr.Format( aAdrStr, SCR_ABS, pDoc, pDoc->GetAddressConvention() );
+
+ rReq.AppendItem( SfxStringItem( FID_FILL_AUTO, aAdrStr ) );
+ rReq.Done();
+ }
+ }
+
+ }
+ else
+ {
+ DBG_ERROR( "Richtung nicht eindeutig fuer AutoFill" );
+ }
+ }
+ }
+ break;
+
+ //
+ // Gliederung (Outlines)
+ // SID_AUTO_OUTLINE, SID_OUTLINE_DELETEALL in Execute (in docsh.idl)
+ //
+
+ case SID_OUTLINE_HIDE:
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ pTabViewShell->SetDataPilotDetails( FALSE );
+ else
+ pTabViewShell->HideMarkedOutlines();
+ rReq.Done();
+ break;
+
+ case SID_OUTLINE_SHOW:
+ {
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ Sequence<sheet::DataPilotFieldFilter> aFilters;
+ USHORT nOrientation;
+ if ( pTabViewShell->HasSelectionForDrillDown( nOrientation ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDPShowDetailDlg* pDlg = pFact->CreateScDPShowDetailDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DPSHOWDETAIL, *pDPObj, nOrientation );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ String aNewDimName( pDlg->GetDimensionName() );
+ pTabViewShell->SetDataPilotDetails( TRUE, &aNewDimName );
+ }
+ }
+ else if ( !pDPObj->IsServiceData() &&
+ pDPObj->GetDataFieldPositionData(
+ ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() ),
+ aFilters ) )
+ pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters );
+ else
+ pTabViewShell->SetDataPilotDetails( TRUE );
+ }
+ else
+ pTabViewShell->ShowMarkedOutlines();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_MAKE:
+ {
+ BOOL bColumns = FALSE;
+ BOOL bOk = TRUE;
+
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ ScDPNumGroupInfo aNumInfo;
+ aNumInfo.Enable = sal_True;
+ aNumInfo.AutoStart = sal_True;
+ aNumInfo.AutoEnd = sal_True;
+ sal_Int32 nParts = 0;
+ if ( pTabViewShell->HasSelectionForDateGroup( aNumInfo, nParts ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "ScAbstractFactory create fail!" );
+ Date aNullDate( *GetViewData()->GetDocument()->GetFormatTable()->GetNullDate() );
+ AbstractScDPDateGroupDlg* pDlg = pFact->CreateScDPDateGroupDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DPDATEGROUP,
+ aNumInfo, nParts, aNullDate );
+ DBG_ASSERT( pDlg, "Dialog create fail!" );
+ if( pDlg->Execute() == RET_OK )
+ {
+ aNumInfo = pDlg->GetGroupInfo();
+ pTabViewShell->DateGroupDataPilot( aNumInfo, pDlg->GetDatePart() );
+ }
+ }
+ else if ( pTabViewShell->HasSelectionForNumGroup( aNumInfo ) )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "ScAbstractFactory create fail!" );
+ AbstractScDPNumGroupDlg* pDlg = pFact->CreateScDPNumGroupDlg(
+ pTabViewShell->GetDialogParent(), RID_SCDLG_DPNUMGROUP, aNumInfo );
+ DBG_ASSERT( pDlg, "Dialog create fail!" );
+ if( pDlg->Execute() == RET_OK )
+ pTabViewShell->NumGroupDataPilot( pDlg->GetGroupInfo() );
+ }
+ else
+ pTabViewShell->GroupDataPilot();
+
+ bOk = FALSE;
+ }
+ else if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ bOk = FALSE;
+
+ if( IS_AVAILABLE( SID_OUTLINE_MAKE, &pItem ) )
+ {
+ String aCol = ((const SfxStringItem*)pItem)->GetValue();
+ aCol.ToUpperAscii();
+
+ switch( aCol.GetChar(0) )
+ {
+ case 'R': bColumns=FALSE; bOk = TRUE;break;
+ case 'C': bColumns=TRUE; bOk = TRUE;break;
+ }
+ }
+ }
+ else // Dialog, wenn nicht ganze Zeilen/Spalten markiert
+ {
+ if ( GetViewData()->SimpleColMarked() && !GetViewData()->SimpleRowMarked() )
+ bColumns = TRUE;
+ else if ( !GetViewData()->SimpleColMarked() && GetViewData()->SimpleRowMarked() )
+ bColumns = FALSE;
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_MAKE, RID_SCDLG_GRP_MAKE,FALSE);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ bColumns = pDlg->GetColsChecked();
+ else
+ bOk = FALSE;
+ delete pDlg;
+ }
+ }
+ if (bOk)
+ {
+ pTabViewShell->MakeOutline( bColumns );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aCol = bColumns ? 'C' : 'R';
+ rReq.AppendItem( SfxStringItem( SID_OUTLINE_MAKE, aCol ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case SID_OUTLINE_REMOVE:
+ {
+ BOOL bColumns = FALSE;
+ BOOL bOk = TRUE;
+
+ if ( GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() ) )
+ {
+ pTabViewShell->UngroupDataPilot();
+ bOk = FALSE;
+ }
+ else if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ bOk = FALSE;
+
+ if( IS_AVAILABLE( SID_OUTLINE_REMOVE, &pItem ) )
+ {
+ String aCol = ((const SfxStringItem*)pItem)->GetValue();
+ aCol.ToUpperAscii();
+
+ switch( aCol.GetChar(0) )
+ {
+ case 'R': bColumns=FALSE; bOk = TRUE;break;
+ case 'C': bColumns=TRUE; bOk = TRUE;break;
+ }
+ }
+ }
+ else // Dialog nur, wenn Aufheben fuer Zeilen und Spalten moeglich
+ {
+ BOOL bColPoss, bRowPoss;
+ pTabViewShell->TestRemoveOutline( bColPoss, bRowPoss );
+ if ( bColPoss && bRowPoss )
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScGroupDlg* pDlg = pFact->CreateAbstractScGroupDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_GRP_KILL, RID_SCDLG_GRP_KILL,TRUE);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ bColumns = pDlg->GetColsChecked();
+ else
+ bOk = FALSE;
+ delete pDlg;
+ }
+ else if ( bColPoss )
+ bColumns = TRUE;
+ else if ( bRowPoss )
+ bColumns = FALSE;
+ else
+ bOk = FALSE;
+ }
+ if (bOk)
+ {
+ pTabViewShell->RemoveOutline( bColumns );
+
+ if( ! rReq.IsAPI() )
+ {
+ String aCol = bColumns ? 'C' : 'R';
+ rReq.AppendItem( SfxStringItem( SID_OUTLINE_REMOVE, aCol ) );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //
+ // Clipboard
+ //
+
+
+ case SID_COPY: // fuer Grafiken in DrawShell
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ pTabViewShell->CopyToClip( NULL, FALSE, FALSE, TRUE );
+ rReq.Done();
+ GetViewData()->SetPasteMode( (ScPasteFlags) (SC_PASTE_MODE | SC_PASTE_BORDER) );
+ pTabViewShell->ShowCursor();
+ pTabViewShell->UpdateCopySourceOverlay();
+ }
+ break;
+
+ case SID_CUT: // fuer Grafiken in DrawShell
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ pTabViewShell->CutToClip( NULL, TRUE );
+ rReq.Done();
+ GetViewData()->SetPasteMode( SC_PASTE_MODE );
+ pTabViewShell->UpdateCopySourceOverlay();
+ }
+ break;
+
+ case SID_PASTE:
+ {
+ PasteFromClipboard ( GetViewData(), pTabViewShell, true );
+ rReq.Done();
+ }
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+
+ ULONG nFormat = 0;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+
+ if ( nFormat )
+ {
+ Window* pWin = GetViewData()->GetActiveWin();
+ BOOL bCells = ( ScTransferObj::GetOwnClipboard( pWin ) != NULL );
+ BOOL bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+ BOOL bOle = ( nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE );
+
+ if ( bCells && bOle )
+ pTabViewShell->PasteFromSystem();
+ else if ( bDraw && bOle )
+ pTabViewShell->PasteDraw();
+ else
+ pTabViewShell->PasteFromSystem(nFormat);
+ }
+ //?else
+ //? pTabViewShell->PasteFromSystem();
+
+ rReq.Done();
+ }
+ pTabViewShell->CellContentChanged();
+ break;
+
+ case FID_INS_CELL_CONTENTS:
+ {
+ USHORT nFlags = IDF_NONE;
+ USHORT nFunction = PASTE_NOFUNC;
+ BOOL bSkipEmpty = FALSE;
+ BOOL bTranspose = FALSE;
+ BOOL bAsLink = FALSE;
+ InsCellCmd eMoveMode = INS_NONE;
+
+ Window* pWin = GetViewData()->GetActiveWin();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ BOOL bOtherDoc = !pDoc->IsClipboardSource();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ if ( pOwnClip )
+ {
+ // #129384# keep a reference in case the clipboard is changed during dialog or PasteFromClip
+ uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip );
+ if ( pReqArgs!=NULL && pTabViewShell->SelectionEditable() )
+ {
+ const SfxPoolItem* pItem;
+ String aFlags = 'A';
+
+ if( IS_AVAILABLE( FID_INS_CELL_CONTENTS, &pItem ) )
+ aFlags = ((const SfxStringItem*)pItem)->GetValue();
+
+ aFlags.ToUpperAscii();
+ BOOL bCont = TRUE;
+
+ for( xub_StrLen i=0 ; bCont && i<aFlags.Len() ; i++ )
+ {
+ switch( aFlags.GetChar(i) )
+ {
+ case 'A': // Alle
+ nFlags |= IDF_ALL;
+ bCont = FALSE; // nicht mehr weitermachen!
+ break;
+ case 'S': nFlags |= IDF_STRING; break;
+ case 'V': nFlags |= IDF_VALUE; break;
+ case 'D': nFlags |= IDF_DATETIME; break;
+ case 'F': nFlags |= IDF_FORMULA; break;
+ case 'N': nFlags |= IDF_NOTE; break;
+ case 'T': nFlags |= IDF_ATTRIB; break;
+ }
+ }
+
+ SFX_REQUEST_ARG( rReq, pFuncItem, SfxUInt16Item, FN_PARAM_1, sal_False );
+ SFX_REQUEST_ARG( rReq, pSkipItem, SfxBoolItem, FN_PARAM_2, sal_False );
+ SFX_REQUEST_ARG( rReq, pTransposeItem, SfxBoolItem, FN_PARAM_3, sal_False );
+ SFX_REQUEST_ARG( rReq, pLinkItem, SfxBoolItem, FN_PARAM_4, sal_False );
+ SFX_REQUEST_ARG( rReq, pMoveItem, SfxInt16Item, FN_PARAM_5, sal_False );
+ if ( pFuncItem )
+ nFunction = pFuncItem->GetValue();
+ if ( pSkipItem )
+ bSkipEmpty = pSkipItem->GetValue();
+ if ( pTransposeItem )
+ bTranspose = pTransposeItem->GetValue();
+ if ( pLinkItem )
+ bAsLink = pLinkItem->GetValue();
+ if ( pMoveItem )
+ eMoveMode = (InsCellCmd) pMoveItem->GetValue();
+ }
+ else
+ {
+ ScEditableTester aTester( pTabViewShell );
+ if (aTester.IsEditable())
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertContentsDlg* pDlg = pFact->CreateScInsertContentsDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_INSCONT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetOtherDoc( bOtherDoc );
+ // #53661# bei ChangeTrack MoveMode disablen
+ pDlg->SetChangeTrack( pDoc->GetChangeTrack() != NULL );
+ // #72930# cut/move references may disable shift
+ // directions if source and destination ranges intersect
+ if ( !bOtherDoc )
+ {
+ if ( pOwnClip && pOwnClip->GetDocument()->IsCutMode() )
+ {
+ ScViewData* pData = GetViewData();
+ if ( pData->GetMarkData().GetTableSelect(
+ pData->GetTabNo() ) )
+ {
+ SCCOL nPosX = pData->GetCurX();
+ SCROW nPosY = pData->GetCurY();
+ SCCOL nClipStartX, nClipSizeX;
+ SCROW nClipStartY, nClipSizeY;
+ pOwnClip->GetDocument()->GetClipStart( nClipStartX, nClipStartY );
+ // for CutMode, filtered rows can always be included
+ pOwnClip->GetDocument()->GetClipArea( nClipSizeX, nClipSizeY, TRUE );
+ int nDisableShift = 0;
+ if ( nClipStartX <= nPosX + nClipSizeX &&
+ nPosX <= nClipStartX + nClipSizeX )
+ nDisableShift |= SC_CELL_SHIFT_DISABLE_DOWN;
+ if ( nClipStartY <= nPosY + nClipSizeY &&
+ nPosY <= nClipStartY + nClipSizeY )
+ nDisableShift |= SC_CELL_SHIFT_DISABLE_RIGHT;
+ if ( nDisableShift )
+ pDlg->SetCellShiftDisabled( nDisableShift );
+ }
+ }
+ }
+ if (pDlg->Execute() == RET_OK)
+ {
+ nFlags = pDlg->GetInsContentsCmdBits();
+ nFunction = pDlg->GetFormulaCmdBits();
+ bSkipEmpty = pDlg->IsSkipEmptyCells();
+ bTranspose = pDlg->IsTranspose();
+ bAsLink = pDlg->IsLink();
+ eMoveMode = pDlg->GetMoveMode();
+ }
+ delete pDlg;
+ }
+ else
+ pTabViewShell->ErrorMessage(aTester.GetMessageId());
+ }
+
+ if( nFlags != IDF_NONE )
+ {
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ if ( bAsLink && bOtherDoc )
+ pTabViewShell->PasteFromSystem(SOT_FORMATSTR_ID_LINK); // DDE einfuegen
+ else
+ pTabViewShell->PasteFromClip( nFlags, pOwnClip->GetDocument(),
+ nFunction, bSkipEmpty, bTranspose, bAsLink,
+ eMoveMode, IDF_NONE, TRUE ); // allow warning dialog
+ }
+
+ if( !pReqArgs )
+ {
+ String aFlags;
+
+ if( nFlags == IDF_ALL )
+ {
+ aFlags += 'A';
+ }
+ else
+ {
+ if( nFlags & IDF_STRING ) aFlags += 'S';
+ if( nFlags & IDF_VALUE ) aFlags += 'V';
+ if( nFlags & IDF_DATETIME ) aFlags += 'D';
+ if( nFlags & IDF_FORMULA ) aFlags += 'F';
+ if( nFlags & IDF_NOTE ) aFlags += 'N';
+ if( nFlags & IDF_ATTRIB ) aFlags += 'T';
+ }
+
+ rReq.AppendItem( SfxStringItem( FID_INS_CELL_CONTENTS, aFlags ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bSkipEmpty ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_3, bTranspose ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_4, bAsLink ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, nFunction ) );
+ rReq.AppendItem( SfxInt16Item( FN_PARAM_5, (sal_Int16) eMoveMode ) );
+ rReq.Done();
+ }
+ }
+ }
+ }
+ pTabViewShell->CellContentChanged(); // => PasteFromXXX ???
+ break;
+
+ case SID_PASTE_SPECIAL:
+ // Unterscheidung, ob eigene oder fremde Daten,
+ // dadurch FID_INS_CELL_CONTENTS ueberfluessig
+ {
+ Window* pWin = GetViewData()->GetActiveWin();
+
+ // Clipboard-ID als Parameter angegeben? Basic "PasteSpecial(Format)"
+ const SfxPoolItem* pItem=NULL;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ ULONG nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ BOOL bRet=TRUE;
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ BOOL bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+ if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ pTabViewShell->PasteDraw();
+ else
+ bRet = pTabViewShell->PasteFromSystem(nFormat, TRUE); // TRUE: keine Fehlermeldungen
+ }
+
+ if ( bRet )
+ {
+ rReq.SetReturnValue(SfxInt16Item(nSlot, bRet)); // 1 = Erfolg, 0 = Fehler
+ rReq.Done();
+ }
+ else
+ // if format is not available -> fallback to request without parameters
+ pItem = NULL;
+ }
+
+ if ( !pItem )
+ {
+ if ( ScTransferObj::GetOwnClipboard( pWin ) ) // own cell data
+ {
+ rReq.SetSlot( FID_INS_CELL_CONTENTS );
+ ExecuteSlot( rReq, GetInterface() );
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg
+ }
+ else // Zeichenobjekte oder fremde Daten
+ {
+ BOOL bDraw = ( ScDrawTransferObj::GetOwnClipboard( pWin ) != NULL );
+
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ GetPossibleClipboardFormats( aFormats );
+
+ USHORT nFormatCount = aFormats.Count();
+ if ( nFormatCount )
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pTabViewShell->GetDialogParent() );
+ if ( pDlg )
+ {
+ for (USHORT i=0; i<nFormatCount; i++)
+ {
+ ULONG nFormatId = aFormats.GetClipbrdFormatId( i );
+ String aName = aFormats.GetClipbrdFormatName( i );
+ // special case for paste dialog: '*' is replaced by object type
+ if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ aName.Assign((sal_Unicode)'*');
+ pDlg->Insert( nFormatId, aName );
+ }
+
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+ ULONG nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
+ if (nFormat > 0)
+ {
+ {
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ if ( bDraw && nFormat == SOT_FORMATSTR_ID_EMBED_SOURCE )
+ pTabViewShell->PasteDraw();
+ else
+ pTabViewShell->PasteFromSystem(nFormat);
+ }
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 1)); // 1 = Erfolg
+ rReq.AppendItem( SfxUInt32Item( nSlot, nFormat ) );
+ rReq.Done();
+ }
+ else
+ {
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler
+ rReq.Ignore();
+ }
+
+ delete pDlg;
+ }
+ }
+ else
+ rReq.SetReturnValue(SfxInt16Item(nSlot, 0)); // 0 = Fehler
+ }
+ }
+ }
+ pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
+ break;
+
+ //
+ // sonstiges
+ //
+
+ case FID_INS_ROWBRK:
+ pTabViewShell->InsertPageBreak( FALSE );
+ rReq.Done();
+ break;
+
+ case FID_INS_COLBRK:
+ pTabViewShell->InsertPageBreak( TRUE );
+ rReq.Done();
+ break;
+
+ case FID_DEL_ROWBRK:
+ pTabViewShell->DeletePageBreak( FALSE );
+ rReq.Done();
+ break;
+
+ case FID_DEL_COLBRK:
+ pTabViewShell->DeletePageBreak( TRUE );
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_ADD_PRED:
+ pTabViewShell->DetectiveAddPred();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_DEL_PRED:
+ pTabViewShell->DetectiveDelPred();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_ADD_SUCC:
+ pTabViewShell->DetectiveAddSucc();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_DEL_SUCC:
+ pTabViewShell->DetectiveDelSucc();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_ADD_ERR:
+ pTabViewShell->DetectiveAddError();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_INVALID:
+ pTabViewShell->DetectiveMarkInvalid();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_REFRESH:
+ pTabViewShell->DetectiveRefresh();
+ rReq.Done();
+ break;
+
+ case SID_DETECTIVE_MARK_PRED:
+ pTabViewShell->DetectiveMarkPred();
+ break;
+ case SID_DETECTIVE_MARK_SUCC:
+ pTabViewShell->DetectiveMarkSucc();
+ break;
+ case SID_INSERT_CURRENT_DATE:
+ pTabViewShell->InsertCurrentTime(
+ NUMBERFORMAT_DATE, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_DATE));
+ break;
+ case SID_INSERT_CURRENT_TIME:
+ pTabViewShell->InsertCurrentTime(
+ NUMBERFORMAT_TIME, ScGlobal::GetRscString(STR_UNDO_INSERT_CURRENT_TIME));
+ break;
+
+ case SID_SPELL_DIALOG:
+// pTabViewShell->DoSpellingChecker();
+ {
+ SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
+ if( rReq.GetArgs() )
+ pViewFrame->SetChildWindow( SID_SPELL_DIALOG,
+ static_cast< const SfxBoolItem& >( rReq.GetArgs()->
+ Get( SID_SPELL_DIALOG ) ).GetValue() );
+ else
+ pViewFrame->ToggleChildWindow( SID_SPELL_DIALOG );
+
+ pViewFrame->GetBindings().Invalidate( SID_SPELL_DIALOG );
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_HANGUL_HANJA_CONVERSION:
+ pTabViewShell->DoHangulHanjaConversion();
+ break;
+
+ case SID_CHINESE_CONVERSION:
+ {
+ //open ChineseTranslationDialog
+ Reference< XComponentContext > xContext(
+ ::cppu::defaultBootstrap_InitialComponentContext() ); //@todo get context from calc if that has one
+ if(xContext.is())
+ {
+ Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() );
+ if(xMCF.is())
+ {
+ Reference< ui::dialogs::XExecutableDialog > xDialog(
+ xMCF->createInstanceWithContext(
+ rtl::OUString::createFromAscii("com.sun.star.linguistic2.ChineseTranslationDialog")
+ , xContext), UNO_QUERY);
+ Reference< lang::XInitialization > xInit( xDialog, UNO_QUERY );
+ if( xInit.is() )
+ {
+ // initialize dialog
+ Reference< awt::XWindow > xDialogParentWindow(0);
+ Sequence<Any> aSeq(1);
+ Any* pArray = aSeq.getArray();
+ PropertyValue aParam;
+ aParam.Name = rtl::OUString::createFromAscii("ParentWindow");
+ aParam.Value <<= makeAny(xDialogParentWindow);
+ pArray[0] <<= makeAny(aParam);
+ xInit->initialize( aSeq );
+
+ //execute dialog
+ sal_Int16 nDialogRet = xDialog->execute();
+ if( RET_OK == nDialogRet )
+ {
+ //get some parameters from the dialog
+ sal_Bool bToSimplified = sal_True;
+ sal_Bool bUseVariants = sal_True;
+ sal_Bool bCommonTerms = sal_True;
+ Reference< beans::XPropertySet > xProp( xDialog, UNO_QUERY );
+ if( xProp.is() )
+ {
+ try
+ {
+ xProp->getPropertyValue( C2U("IsDirectionToSimplified") ) >>= bToSimplified;
+ xProp->getPropertyValue( C2U("IsUseCharacterVariants") ) >>= bUseVariants;
+ xProp->getPropertyValue( C2U("IsTranslateCommonTerms") ) >>= bCommonTerms;
+ }
+ catch( Exception& )
+ {
+ }
+ }
+
+ //execute translation
+ LanguageType eSourceLang = bToSimplified ? LANGUAGE_CHINESE_TRADITIONAL : LANGUAGE_CHINESE_SIMPLIFIED;
+ LanguageType eTargetLang = bToSimplified ? LANGUAGE_CHINESE_SIMPLIFIED : LANGUAGE_CHINESE_TRADITIONAL;
+ sal_Int32 nOptions = bUseVariants ? i18n::TextConversionOption::USE_CHARACTER_VARIANTS : 0;
+ if( !bCommonTerms )
+ nOptions |= i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+
+ Font aTargetFont = GetViewData()->GetActiveWin()->GetDefaultFont(
+ DEFAULTFONT_CJK_SPREADSHEET,
+ eTargetLang, DEFAULTFONT_FLAGS_ONLYONE );
+ ScConversionParam aConvParam( SC_CONVERSION_CHINESE_TRANSL,
+ eSourceLang, eTargetLang, aTargetFont, nOptions, false );
+ pTabViewShell->DoSheetConversion( aConvParam );
+ }
+ }
+ Reference< lang::XComponent > xComponent( xDialog, UNO_QUERY );
+ if( xComponent.is() )
+ xComponent->dispose();
+ }
+ }
+ }
+ break;
+
+ case SID_THESAURUS:
+ pTabViewShell->DoThesaurus();
+ break;
+
+ case SID_TOGGLE_REL:
+ pTabViewShell->DoRefConversion();
+ break;
+
+ case SID_DEC_INDENT:
+ pTabViewShell->ChangeIndent( FALSE );
+ break;
+ case SID_INC_INDENT:
+ pTabViewShell->ChangeIndent( TRUE );
+ break;
+
+ case FID_USE_NAME:
+ {
+ USHORT nFlags = pTabViewShell->GetCreateNameFlags();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNameCreateDlg* pDlg = pFact->CreateScNameCreateDlg(pTabViewShell->GetDialogParent(), nFlags, RID_SCDLG_NAMES_CREATE );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if( pDlg->Execute() )
+ {
+ nFlags = pDlg->GetFlags();
+ pTabViewShell->CreateNames(nFlags);
+ rReq.Done();
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_CONSOLIDATE:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState( SCITEM_CONSOLIDATEDATA, TRUE, &pItem ) )
+ {
+ const ScConsolidateParam& rParam =
+ ((const ScConsolidateItem*)pItem)->GetData();
+
+ pTabViewShell->Consolidate( rParam );
+ GetViewData()->GetDocument()->SetConsolidateDlgData( &rParam );
+
+ rReq.Done();
+ }
+ else if (rReq.IsAPI())
+ SbxBase::SetError(SbxERR_BAD_PARAMETER);
+ }
+ break;
+
+ case SID_INS_FUNCTION:
+ {
+ const SfxBoolItem* pOkItem = (const SfxBoolItem*)&pReqArgs->Get( SID_DLG_RETOK );
+
+// pScMod->SetFunctionDlg( NULL );
+
+ if ( pOkItem->GetValue() ) // OK
+ {
+ String aFormula;
+ const SfxStringItem* pSItem = (const SfxStringItem*)&pReqArgs->Get( SCITEM_STRING );
+ const SfxBoolItem* pMatrixItem = (const SfxBoolItem*) &pReqArgs->Get( SID_DLG_MATRIX );
+
+ aFormula += pSItem->GetValue();
+ pScMod->ActivateInputWindow( &aFormula, pMatrixItem->GetValue() );
+ }
+ else // CANCEL
+ {
+ pScMod->ActivateInputWindow( NULL );
+ }
+ rReq.Ignore(); // only SID_ENTER_STRING is recorded
+ }
+ break;
+
+ case FID_DEFINE_NAME:
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ String aName, aSymbol, aAttrib;
+
+ if( IS_AVAILABLE( FID_DEFINE_NAME, &pItem ) )
+ aName = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ aSymbol = ((const SfxStringItem*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ aAttrib = ((const SfxStringItem*)pItem)->GetValue();
+
+ if ( aName.Len() && aSymbol.Len() )
+ {
+ if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
+ rReq.Done();
+ else
+ SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler
+ }
+ }
+ else
+ {
+ USHORT nId = ScNameDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case SID_DEFINE_COLROWNAMERANGES:
+ {
+
+ USHORT nId = ScColRowNameRangesDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+
+ }
+ break;
+
+ case SID_UPDATECHART:
+ {
+ BOOL bAll = FALSE;
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+
+ if( IS_AVAILABLE( SID_UPDATECHART, &pItem ) )
+ bAll = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+
+ pTabViewShell->UpdateCharts( bAll );
+
+ if( ! rReq.IsAPI() )
+ {
+ rReq.AppendItem( SfxBoolItem( SID_UPDATECHART, bAll ) );
+ rReq.Done();
+ }
+ }
+ break;
+
+
+ case SID_TABOP:
+ if (pReqArgs)
+ {
+ const ScTabOpItem& rItem =
+ (const ScTabOpItem&)
+ pReqArgs->Get( SID_TABOP );
+
+ pTabViewShell->TabOp( rItem.GetData() );
+
+ rReq.Done( *pReqArgs );
+ }
+ break;
+
+ case SID_SOLVE:
+ if (pReqArgs)
+ {
+ const ScSolveItem& rItem =
+ (const ScSolveItem&)
+ pReqArgs->Get( SCITEM_SOLVEDATA );
+
+ pTabViewShell->Solve( rItem.GetData() );
+
+ rReq.Done( *pReqArgs );
+ }
+ break;
+
+ case FID_INSERT_NAME:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ switch( pDlg->Execute() )
+ {
+ case BTN_PASTE_LIST:
+ pTabViewShell->InsertNameList();
+ break;
+ case BTN_PASTE_NAME:
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pTabViewShell );
+ if (pHdl)
+ {
+ // das "=" per Key-Event, schaltet in den Eingabe-Modus
+ pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
+
+ String aName = pDlg->GetSelectedName();
+ pHdl->InsertFunction( aName, FALSE ); // ohne "()"
+ }
+ }
+ break;
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_RANGE_NOTETEXT:
+ if (pReqArgs)
+ {
+ const SfxStringItem& rTextItem = (const SfxStringItem&)pReqArgs->Get( SID_RANGE_NOTETEXT );
+
+ // #43343# immer Cursorposition
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ pTabViewShell->SetNoteText( aPos, rTextItem.GetValue() );
+ rReq.Done();
+ }
+ break;
+
+ case SID_INSERT_POSTIT:
+ if ( pReqArgs )
+ {
+ const SvxPostItAuthorItem& rAuthorItem = (const SvxPostItAuthorItem&)pReqArgs->Get( SID_ATTR_POSTIT_AUTHOR );
+ const SvxPostItDateItem& rDateItem = (const SvxPostItDateItem&) pReqArgs->Get( SID_ATTR_POSTIT_DATE );
+ const SvxPostItTextItem& rTextItem = (const SvxPostItTextItem&) pReqArgs->Get( SID_ATTR_POSTIT_TEXT );
+
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ pTabViewShell->ReplaceNote( aPos, rTextItem.GetValue(), &rAuthorItem.GetValue(), &rDateItem.GetValue() );
+ rReq.Done();
+ }
+ else
+ {
+ pTabViewShell->EditNote(); // Zeichenobjekt zum Editieren
+ }
+ break;
+
+ case FID_NOTE_VISIBLE:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if( ScPostIt* pNote = pDoc->GetNote( aPos ) )
+ {
+ bool bShow;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && (pReqArgs->GetItemState( FID_NOTE_VISIBLE, TRUE, &pItem ) == SFX_ITEM_SET) )
+ bShow = ((const SfxBoolItem*) pItem)->GetValue();
+ else
+ bShow = !pNote->IsCaptionShown();
+
+ pTabViewShell->ShowNote( bShow );
+
+ if (!pReqArgs)
+ rReq.AppendItem( SfxBoolItem( FID_NOTE_VISIBLE, bShow ) );
+
+ rReq.Done();
+ rBindings.Invalidate( FID_NOTE_VISIBLE );
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_DELETE_NOTE:
+ pTabViewShell->DeleteContents( IDF_NOTE ); // delete all notes in selection
+ rReq.Done();
+ break;
+
+ case SID_CHARMAP:
+ if( pReqArgs != NULL )
+ {
+ String aChars, aFontName;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if ( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem);
+ if ( pItem )
+ {
+ const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, pItem );
+ if ( pStringItem )
+ aChars = pStringItem->GetValue();
+ const SfxPoolItem* pFtItem = NULL;
+ pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem);
+ const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
+ if ( pFontItem )
+ aFontName = pFontItem->GetValue();
+ }
+
+ if ( aChars.Len() )
+ {
+ Font aFont;
+ pTabViewShell->GetSelectionPattern()->GetFont( aFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
+ pTabViewShell->GetSelectionScriptType() );
+ if ( aFontName.Len() )
+ aFont = Font( aFontName, Size(1,1) );
+ pTabViewShell->InsertSpecialChar( aChars, aFont );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ }
+ else
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+
+ // font color doesn't matter here
+ Font aCurFont;
+ pTabViewShell->GetSelectionPattern()->GetFont( aCurFont, SC_AUTOCOL_BLACK, NULL, NULL, NULL,
+ pTabViewShell->GetSelectionScriptType() );
+
+ SfxAllItemSet aSet( GetPool() );
+ aSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) );
+ aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), GetPool().GetWhich(SID_ATTR_CHAR_FONT) ) );
+
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( pTabViewShell->GetDialogParent(), aSet,
+ pTabViewShell->GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, FALSE );
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE );
+
+ if ( pItem && pFontItem )
+ {
+ Font aNewFont( pFontItem->GetFamilyName(), pFontItem->GetStyleName(), Size(1,1) );
+ aNewFont.SetCharSet( pFontItem->GetCharSet() );
+ aNewFont.SetPitch( pFontItem->GetPitch() );
+ pTabViewShell->InsertSpecialChar( pItem->GetValue(), aNewFont );
+ rReq.AppendItem( *pFontItem );
+ rReq.AppendItem( *pItem );
+ rReq.Done();
+ }
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_SELECT_SCENARIO:
+ {
+ // Testing
+
+ if ( pReqArgs )
+ {
+ const SfxStringItem* pItem =
+ (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_SCENARIO );
+
+ if( pItem )
+ {
+ pTabViewShell->UseScenario( pItem->GetValue() );
+ //! wofuer soll der Return-Wert gut sein?!?!
+ rReq.SetReturnValue( SfxStringItem( SID_SELECT_SCENARIO, pItem->GetValue() ) );
+ rReq.Done();
+ }
+ else
+ {
+ DBG_ERROR("NULL");
+ }
+ }
+ }
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( SID_HYPERLINK_SETLINK, &pItem ) )
+ {
+ const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
+ const String& rName = pHyper->GetName();
+ const String& rURL = pHyper->GetURL();
+ const String& rTarget = pHyper->GetTargetFrame();
+ USHORT nType = (USHORT) pHyper->GetInsertMode();
+
+ pTabViewShell->InsertURL( rName, rURL, rTarget, nType );
+ rReq.Done();
+ }
+ else
+ rReq.Ignore();
+ }
+ break;
+
+ case FID_CONDITIONAL_FORMAT:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_CONDITIONAL_FORMAT, &pItem ) )
+ {
+ // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
+ // hat wieder zurueckschalten:
+ if ( GetViewData()->GetTabNo() != GetViewData()->GetRefTabNo() )
+ {
+ pTabViewShell->SetTabNo( GetViewData()->GetRefTabNo() );
+ pTabViewShell->PaintExtras();
+ }
+
+ const ScCondFrmtItem* pCndFmtItem = (const ScCondFrmtItem*) pItem;
+ pTabViewShell->SetConditionalFormat( pCndFmtItem->GetData() );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_EXTERNAL_SOURCE:
+ {
+ String aFile;
+ String aFilter;
+ String aOptions;
+ String aSource;
+ ULONG nRefresh=0;
+
+ SFX_REQUEST_ARG( rReq, pFile, SfxStringItem, SID_FILE_NAME, sal_False );
+ SFX_REQUEST_ARG( rReq, pSource, SfxStringItem, FN_PARAM_1, sal_False );
+ if ( pFile && pSource )
+ {
+ aFile = pFile->GetValue();
+ aSource = pSource->GetValue();
+ SFX_REQUEST_ARG( rReq, pFilter, SfxStringItem, SID_FILTER_NAME, sal_False );
+ if ( pFilter )
+ aFilter = pFilter->GetValue();
+ SFX_REQUEST_ARG( rReq, pOptions, SfxStringItem, SID_FILE_FILTEROPTIONS, sal_False );
+ if ( pOptions )
+ aOptions = pOptions->GetValue();
+ SFX_REQUEST_ARG( rReq, pRefresh, SfxUInt32Item, FN_PARAM_2, sal_False );
+ if ( pRefresh )
+ nRefresh = pRefresh->GetValue();
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ delete pImpl->m_pLinkedDlg;
+ pImpl->m_pLinkedDlg =
+ pFact->CreateScLinkedAreaDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_LINKAREA);
+ DBG_ASSERT(pImpl->m_pLinkedDlg, "Dialog create fail!");
+ delete pImpl->m_pRequest;
+ pImpl->m_pRequest = new SfxRequest( rReq );
+ pImpl->m_pLinkedDlg->StartExecuteModal( LINK( this, ScCellShell, DialogClosed ) );
+ return;
+ }
+
+ ExecuteExternalSource( aFile, aFilter, aOptions, aSource, nRefresh, rReq );
+ }
+ break;
+
+ //
+ //
+ //
+
+ default:
+ DBG_ERROR("falscher Slot bei ExecuteEdit");
+ break;
+ }
+}
+
+void ScCellShell::ExecuteTrans( SfxRequest& rReq )
+{
+ sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
+ if ( nType )
+ {
+ GetViewData()->GetView()->TransliterateText( nType );
+ rReq.Done();
+ }
+}
+
+void ScCellShell::ExecuteExternalSource(
+ const String& _rFile, const String& _rFilter, const String& _rOptions,
+ const String& _rSource, ULONG _nRefresh, SfxRequest& _rRequest )
+{
+ if ( _rFile.Len() && _rSource.Len() ) // filter may be empty
+ {
+ ScRange aLinkRange;
+ BOOL bMove = FALSE;
+
+ ScViewData* pData = GetViewData();
+ ScMarkData& rMark = pData->GetMarkData();
+ rMark.MarkToSimple();
+ if ( rMark.IsMarked() )
+ {
+ rMark.GetMarkArea( aLinkRange );
+ bMove = TRUE; // insert/delete cells to fit range
+ }
+ else
+ aLinkRange = ScRange( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+
+ ScDocFunc aFunc(*pData->GetDocShell());
+ aFunc.InsertAreaLink( _rFile, _rFilter, _rOptions, _rSource,
+ aLinkRange, _nRefresh, bMove, FALSE );
+ _rRequest.Done();
+ }
+ else
+ _rRequest.Ignore();
+}
+
+IMPL_LINK( ScCellShell, DialogClosed, AbstractScLinkedAreaDlg*, EMPTYARG )
+{
+ DBG_ASSERT( pImpl->m_pLinkedDlg, "ScCellShell::DialogClosed(): invalid request" );
+ DBG_ASSERT( pImpl->m_pRequest, "ScCellShell::DialogClosed(): invalid request" );
+ String sFile, sFilter, sOptions, sSource;
+ ULONG nRefresh = 0;
+
+ if ( pImpl->m_pLinkedDlg->GetResult() == RET_OK )
+ {
+ sFile = pImpl->m_pLinkedDlg->GetURL();
+ sFilter = pImpl->m_pLinkedDlg->GetFilter();
+ sOptions = pImpl->m_pLinkedDlg->GetOptions();
+ sSource = pImpl->m_pLinkedDlg->GetSource();
+ nRefresh = pImpl->m_pLinkedDlg->GetRefresh();
+ if ( sFile.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_NAME, sFile ) );
+ if ( sFilter.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILTER_NAME, sFilter ) );
+ if ( sOptions.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( SID_FILE_FILTEROPTIONS, sOptions ) );
+ if ( sSource.Len() )
+ pImpl->m_pRequest->AppendItem( SfxStringItem( FN_PARAM_1, sSource ) );
+ if ( nRefresh )
+ pImpl->m_pRequest->AppendItem( SfxUInt32Item( FN_PARAM_2, nRefresh ) );
+ }
+
+ ExecuteExternalSource( sFile, sFilter, sOptions, sSource, nRefresh, *(pImpl->m_pRequest) );
+ return 0;
+}
+
+void ScCellShell::PasteFromClipboard( ScViewData* pViewData, ScTabViewShell* pTabViewShell, bool bShowDialog )
+{
+ Window* pWin = pViewData->GetActiveWin();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ ScDocument* pThisDoc = pViewData->GetDocument();
+ ScDPObject* pDPObj = pThisDoc->GetDPAtCursor( pViewData->GetCurX(),
+ pViewData->GetCurY(), pViewData->GetTabNo() );
+ if ( pOwnClip && pDPObj )
+ {
+ // paste from Calc into DataPilot table: sort (similar to drag & drop)
+
+ ScDocument* pClipDoc = pOwnClip->GetDocument();
+ SCTAB nSourceTab = pOwnClip->GetVisibleTab();
+
+ SCCOL nClipStartX;
+ SCROW nClipStartY;
+ SCCOL nClipEndX;
+ SCROW nClipEndY;
+ pClipDoc->GetClipStart( nClipStartX, nClipStartY );
+ pClipDoc->GetClipArea( nClipEndX, nClipEndY, TRUE );
+ nClipEndX = nClipEndX + nClipStartX;
+ nClipEndY = nClipEndY + nClipStartY; // GetClipArea returns the difference
+
+ ScRange aSource( nClipStartX, nClipStartY, nSourceTab, nClipEndX, nClipEndY, nSourceTab );
+ BOOL bDone = pTabViewShell->DataPilotMove( aSource, pViewData->GetCurPos() );
+ if ( !bDone )
+ pTabViewShell->ErrorMessage( STR_ERR_DATAPILOT_INPUT );
+ }
+ else
+ {
+ // normal paste
+ WaitObject aWait( pViewData->GetDialogParent() );
+ if (!pOwnClip)
+ pTabViewShell->PasteFromSystem();
+ else
+ {
+ ScDocument* pClipDoc = pOwnClip->GetDocument();
+ sal_uInt16 nFlags = IDF_ALL;
+ if (pClipDoc->GetClipParam().isMultiRange())
+ // For multi-range paste, we paste values by default.
+ nFlags &= ~IDF_FORMULA;
+
+ pTabViewShell->PasteFromClip( nFlags, pClipDoc,
+ PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
+ bShowDialog ); // allow warning dialog
+ }
+ }
+ pTabViewShell->CellContentChanged(); // => PasteFromSystem() ???
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
new file mode 100644
index 000000000000..16959485992b
--- /dev/null
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -0,0 +1,1392 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <svl/aeitem.hxx>
+#include <basic/sbxcore.hxx>
+#include <svl/whiter.hxx>
+#include <svl/zforlist.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/stritem.hxx>
+#include <svl/visitem.hxx>
+#include <unotools/moduleoptions.hxx>
+
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+#include "cellsh.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "uiitems.hxx"
+#include "dbfunc.hxx"
+#include "dbdocfun.hxx"
+#include "filtdlg.hxx"
+#include "dbnamdlg.hxx"
+#include "reffact.hxx"
+#include "pvlaydlg.hxx"
+#include "validat.hxx"
+#include "scresid.hxx"
+#include "pivot.hxx"
+#include "dpobject.hxx"
+#include "dpsdbtab.hxx" // ScImportSourceDesc
+#include "dpshttab.hxx" // ScSheetSourceDesc
+
+#include "validate.hrc" // ScValidationDlg
+#include "scui_def.hxx"
+#include "scabstdlg.hxx"
+#include "impex.hxx"
+#include "asciiopt.hxx"
+using namespace com::sun::star;
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+//------------------------------------------------------------------
+
+bool lcl_GetTextToColumnsRange( const ScViewData* pData, ScRange& rRange )
+{
+ DBG_ASSERT( pData, "lcl_GetTextToColumnsRange: pData is null!" );
+
+ bool bRet = false;
+ const ScMarkData& rMark = pData->GetMarkData();
+
+ if ( rMark.IsMarked() )
+ {
+ if ( !rMark.IsMultiMarked() )
+ {
+ rMark.GetMarkArea( rRange );
+ if ( rRange.aStart.Col() == rRange.aEnd.Col() )
+ {
+ bRet = true;
+ }
+ }
+ }
+ else
+ {
+ const SCCOL nCol = pData->GetCurX();
+ const SCROW nRow = pData->GetCurY();
+ const SCTAB nTab = pData->GetTabNo();
+ rRange = ScRange( nCol, nRow, nTab, nCol, nRow, nTab );
+ bRet = true;
+ }
+
+ const ScDocument* pDoc = pData->GetDocument();
+ DBG_ASSERT( pDoc, "lcl_GetTextToColumnsRange: pDoc is null!" );
+
+ if ( bRet && pDoc->IsBlockEmpty( rRange.aStart.Tab(), rRange.aStart.Col(),
+ rRange.aStart.Row(), rRange.aEnd.Col(),
+ rRange.aEnd.Row() ) )
+ {
+ bRet = false;
+ }
+
+ return bRet;
+}
+
+BOOL lcl_GetSortParam( const ScViewData* pData, ScSortParam& rSortParam )
+{
+ ScTabViewShell* pTabViewShell = pData->GetViewShell();
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScDocument* pDoc = pData->GetDocument();
+ SCTAB nTab = pData->GetTabNo();
+ ScDirection eFillDir = DIR_TOP;
+ BOOL bSort = TRUE;
+ ScRange aExternalRange;
+
+ if( rSortParam.nCol1 != rSortParam.nCol2 )
+ eFillDir = DIR_LEFT;
+ if( rSortParam.nRow1 != rSortParam.nRow2 )
+ eFillDir = DIR_TOP;
+
+ SCSIZE nCount = pDoc->GetEmptyLinesInBlock( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab, eFillDir );
+
+ if( rSortParam.nRow2 == MAXROW )
+ aExternalRange = ScRange( rSortParam.nCol1,sal::static_int_cast<SCROW>( nCount ), nTab );
+ else
+ aExternalRange = ScRange( pData->GetCurX(), pData->GetCurY(), nTab );
+
+ SCROW nStartRow = aExternalRange.aStart.Row();
+ SCCOL nStartCol = aExternalRange.aStart.Col();
+ SCROW nEndRow = aExternalRange.aEnd.Row();
+ SCCOL nEndCol = aExternalRange.aEnd.Col();
+ pDoc->GetDataArea( aExternalRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow, FALSE, false );
+ aExternalRange.aStart.SetRow( nStartRow );
+ aExternalRange.aStart.SetCol( nStartCol );
+ aExternalRange.aEnd.SetRow( nEndRow );
+ aExternalRange.aEnd.SetCol( nEndCol );
+
+ if(( rSortParam.nCol1 == rSortParam.nCol2 && aExternalRange.aStart.Col() != aExternalRange.aEnd.Col() ) ||
+ ( rSortParam.nRow1 == rSortParam.nRow2 && aExternalRange.aStart.Row() != aExternalRange.aEnd.Row() ) )
+ {
+ USHORT nFmt = SCA_VALID;
+ String aExtendStr,aCurrentStr;
+
+ pTabViewShell->AddHighlightRange( aExternalRange,Color( COL_LIGHTBLUE ) );
+ ScRange rExtendRange( aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), nTab, aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row(), nTab );
+ rExtendRange.Format( aExtendStr, nFmt, pDoc );
+
+ ScRange rCurrentRange( rSortParam.nCol1, rSortParam.nRow1, nTab, rSortParam.nCol2, rSortParam.nRow2, nTab );
+ rCurrentRange.Format( aCurrentStr, nFmt, pDoc );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ VclAbstractDialog* pWarningDlg = pFact->CreateScSortWarningDlg( pTabViewShell->GetDialogParent(),aExtendStr,aCurrentStr,RID_SCDLG_SORT_WARNING );
+ DBG_ASSERT(pWarningDlg, "Dialog create fail!");
+ short bResult = pWarningDlg->Execute();
+ if( bResult == BTN_EXTEND_RANGE || bResult == BTN_CURRENT_SELECTION )
+ {
+ if( bResult == BTN_EXTEND_RANGE )
+ {
+ pTabViewShell->MarkRange( aExternalRange, FALSE );
+ pDBData->SetArea( nTab, aExternalRange.aStart.Col(), aExternalRange.aStart.Row(), aExternalRange.aEnd.Col(), aExternalRange.aEnd.Row() );
+ }
+ }
+ else
+ {
+ bSort = FALSE;
+ pData->GetDocShell()->CancelAutoDBRange();
+ }
+
+ delete pWarningDlg;
+ pTabViewShell->ClearHighlightRanges();
+ }
+ return bSort;
+}
+
+//<!-- Added by PengYunQuan for Validity Cell Range Picker
+//after end execute from !IsModalInputMode, it is safer to delay deleting
+namespace
+{
+ long DelayDeleteAbstractDialog( void *pAbstractDialog, void * /*pArg*/ )
+ {
+ delete reinterpret_cast<VclAbstractDialog*>( pAbstractDialog );
+ return 0;
+ }
+}
+//--> Added by PengYunQuan for Validity Cell Range Picker
+
+void ScCellShell::ExecuteDB( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ USHORT nSlotId = rReq.GetSlot();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ ScModule* pScMod = SC_MOD();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ }
+
+ switch ( nSlotId )
+ {
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ {
+ // check if database beamer is open
+
+ SfxViewFrame* pViewFrame = pTabViewShell->GetViewFrame();
+ BOOL bWasOpen = FALSE;
+ {
+ uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
+ uno::Reference<frame::XFrame> xBeamerFrame = xFrame->findFrame(
+ rtl::OUString::createFromAscii("_beamer"),
+ frame::FrameSearchFlag::CHILDREN);
+ if ( xBeamerFrame.is() )
+ bWasOpen = TRUE;
+ }
+
+ if ( bWasOpen )
+ {
+ // close database beamer: just forward to SfxViewFrame
+
+ pViewFrame->ExecuteSlot( rReq );
+ }
+ else
+ {
+ // show database beamer: SfxViewFrame call must be synchronous
+
+ pViewFrame->ExecuteSlot( rReq, (BOOL) FALSE ); // FALSE = synchronous
+
+ // select current database in database beamer
+
+ ScImportParam aImportParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD); // don't create if none found
+ if (pDBData)
+ pDBData->GetImportParam( aImportParam );
+
+ ScDBDocFunc::ShowInBeamer( aImportParam, pTabViewShell->GetViewFrame() );
+ }
+ rReq.Done(); // needed because it's a toggle slot
+ }
+ break;
+
+ case SID_REIMPORT_DATA:
+ {
+ BOOL bOk = FALSE;
+ ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD);
+ if (pDBData)
+ {
+ ScImportParam aImportParam;
+ pDBData->GetImportParam( aImportParam );
+ if (aImportParam.bImport && !pDBData->HasImportSelection())
+ {
+ pTabViewShell->ImportData( aImportParam );
+ pDBData->SetImportParam( aImportParam ); //! Undo ??
+ bOk = TRUE;
+ }
+ }
+
+ if (!bOk && ! rReq.IsAPI() )
+ pTabViewShell->ErrorMessage(STR_REIMPORT_EMPTY);
+
+ if( bOk )
+ rReq.Done();
+ }
+ break;
+
+ case SID_REFRESH_DBAREA:
+ {
+ ScDBData* pDBData = pTabViewShell->GetDBData(TRUE,SC_DB_OLD);
+ if (pDBData)
+ {
+ // Import wiederholen wie SID_REIMPORT_DATA
+
+ BOOL bContinue = TRUE;
+ ScImportParam aImportParam;
+ pDBData->GetImportParam( aImportParam );
+ if (aImportParam.bImport && !pDBData->HasImportSelection())
+ {
+ bContinue = pTabViewShell->ImportData( aImportParam );
+ pDBData->SetImportParam( aImportParam ); //! Undo ??
+
+ // markieren (Groesse kann sich geaendert haben)
+ ScRange aNewRange;
+ pDBData->GetArea(aNewRange);
+ pTabViewShell->MarkRange(aNewRange);
+ }
+
+ if ( bContinue ) // #41905# Fehler beim Import -> Abbruch
+ {
+ // interne Operationen, wenn welche gespeichert
+
+ if ( pDBData->HasQueryParam() || pDBData->HasSortParam() ||
+ pDBData->HasSubTotalParam() )
+ pTabViewShell->RepeatDB();
+
+ // Pivottabellen die den Bereich als Quelldaten haben
+
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ GetViewData()->GetDocShell()->RefreshPivotTables(aRange);
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_SBA_BRW_INSERT:
+ {
+ DBG_ERROR( "Deprecated Slot" );
+ }
+ break;
+
+ case SID_DATA_FORM:
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");//CHINA001
+
+ AbstractScDataFormDlg* pDlg = pFact->CreateScDataFormDlg( pTabViewShell->GetDialogParent(),RID_SCDLG_DATAFORM, pTabViewShell);
+ DBG_ASSERT(pDlg, "Dialog create fail!");//CHINA001
+
+ pDlg->Execute();
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_SUBTOTALS:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ pTabViewShell->DoSubTotals( ((const ScSubTotalItem&) pArgs->Get( SCITEM_SUBTDATA )).
+ GetSubTotalData() );
+ rReq.Done();
+ }
+ else
+ {
+ SfxAbstractTabDialog * pDlg = NULL;
+ ScSubTotalParam aSubTotalParam;
+ SfxItemSet aArgSet( GetPool(), SCITEM_SUBTDATA, SCITEM_SUBTDATA );
+
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ aSubTotalParam.bRemoveOnly = FALSE;
+
+ aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA, GetViewData(), &aSubTotalParam ) );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScSubTotalDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SUBTOTALS );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetCurPageId(1);
+
+ short bResult = pDlg->Execute();
+
+ if ( (bResult == RET_OK) || (bResult == SCRET_REMOVE) )
+ {
+ const SfxItemSet* pOutSet = NULL;
+
+ if ( bResult == RET_OK )
+ {
+ pOutSet = pDlg->GetOutputItemSet();
+ aSubTotalParam =
+ ((const ScSubTotalItem&)
+ pOutSet->Get( SCITEM_SUBTDATA )).
+ GetSubTotalData();
+ }
+ else // if (bResult == SCRET_REMOVE)
+ {
+ pOutSet = &aArgSet;
+ aSubTotalParam.bRemoveOnly = TRUE;
+ aSubTotalParam.bReplace = TRUE;
+ aArgSet.Put( ScSubTotalItem( SCITEM_SUBTDATA,
+ GetViewData(),
+ &aSubTotalParam ) );
+ }
+
+ pTabViewShell->DoSubTotals( aSubTotalParam );
+ rReq.Done( *pOutSet );
+ }
+ else
+ GetViewData()->GetDocShell()->CancelAutoDBRange();
+
+ delete pDlg;
+ }
+ }
+ break;
+
+ case SID_SORT_DESCENDING:
+ case SID_SORT_ASCENDING:
+ {
+ //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
+ //the patch comes from maoyg
+ ScSortParam aSortParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScViewData* pData = GetViewData();
+
+ pDBData->GetSortParam( aSortParam );
+
+ if( lcl_GetSortParam( pData, aSortParam ) )
+ {
+ SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCCOL nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ pDBData->GetSortParam( aSortParam );
+ BOOL bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, nTab );
+
+ if( nCol < aSortParam.nCol1 )
+ nCol = aSortParam.nCol1;
+ else if( nCol > aSortParam.nCol2 )
+ nCol = aSortParam.nCol2;
+
+ aSortParam.bHasHeader = bHasHeader;
+ aSortParam.bByRow = TRUE;
+ aSortParam.bCaseSens = FALSE;
+ aSortParam.bNaturalSort = FALSE;
+ aSortParam.bIncludePattern = TRUE;
+ aSortParam.bInplace = TRUE;
+ aSortParam.bDoSort[0] = TRUE;
+ aSortParam.nField[0] = nCol;
+ aSortParam.bAscending[0] = (nSlotId == SID_SORT_ASCENDING);
+
+ for ( USHORT i=1; i<MAXSORT; i++ )
+ aSortParam.bDoSort[i] = FALSE;
+
+ aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
+
+ pTabViewShell->UISort( aSortParam ); // Teilergebnisse bei Bedarf neu
+
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_SORT:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ //#i60401 ux-ctest: Calc does not support all users' strategies regarding sorting data
+ //the patch comes from maoyg
+
+ if ( pArgs ) // Basic
+ {
+ ScSortParam aSortParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScViewData* pData = GetViewData();
+
+ pDBData->GetSortParam( aSortParam );
+
+ if( lcl_GetSortParam( pData, aSortParam ) )
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ pDBData->GetSortParam( aSortParam );
+ BOOL bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
+ if( bHasHeader )
+ aSortParam.bHasHeader = bHasHeader;
+
+ aSortParam.bInplace = TRUE; // von Basic immer
+
+ const SfxPoolItem* pItem;
+ if ( pArgs->GetItemState( SID_SORT_BYROW, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bByRow = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_HASHEADER, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bHasHeader = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_CASESENS, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bCaseSens = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_NATURALSORT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bNaturalSort = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_ATTRIBS, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bIncludePattern = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pArgs->GetItemState( SID_SORT_USERDEF, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ USHORT nUserIndex = ((const SfxUInt16Item*)pItem)->GetValue();
+ aSortParam.bUserDef = ( nUserIndex != 0 );
+ if ( nUserIndex )
+ aSortParam.nUserIndex = nUserIndex - 1; // Basic: 1-basiert
+ }
+
+ SCCOLROW nField0 = 0;
+ if ( pArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET )
+ nField0 = ((const SfxInt32Item*)pItem)->GetValue();
+ aSortParam.bDoSort[0] = ( nField0 != 0 );
+ aSortParam.nField[0] = nField0 > 0 ? (nField0-1) : 0;
+ if ( pArgs->GetItemState( FN_PARAM_2, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bAscending[0] = ((const SfxBoolItem*)pItem)->GetValue();
+ SCCOLROW nField1 = 0;
+ if ( pArgs->GetItemState( FN_PARAM_3, TRUE, &pItem ) == SFX_ITEM_SET )
+ nField1 = ((const SfxInt32Item*)pItem)->GetValue();
+ aSortParam.bDoSort[1] = ( nField1 != 0 );
+ aSortParam.nField[1] = nField1 > 0 ? (nField1-1) : 0;
+ if ( pArgs->GetItemState( FN_PARAM_4, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bAscending[1] = ((const SfxBoolItem*)pItem)->GetValue();
+ SCCOLROW nField2 = 0;
+ if ( pArgs->GetItemState( FN_PARAM_5, TRUE, &pItem ) == SFX_ITEM_SET )
+ nField2 = ((const SfxInt32Item*)pItem)->GetValue();
+ aSortParam.bDoSort[2] = ( nField2 != 0 );
+ aSortParam.nField[2] = nField2 > 0 ? (nField2-1) : 0;
+ if ( pArgs->GetItemState( FN_PARAM_6, TRUE, &pItem ) == SFX_ITEM_SET )
+ aSortParam.bAscending[2] = ((const SfxBoolItem*)pItem)->GetValue();
+
+ // Teilergebnisse bei Bedarf neu
+ pTabViewShell->UISort( aSortParam );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ ScSortParam aSortParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+ ScViewData* pData = GetViewData();
+
+ pDBData->GetSortParam( aSortParam );
+
+ if( lcl_GetSortParam( pData, aSortParam ) )
+ {
+ SfxAbstractTabDialog* pDlg = NULL;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SfxItemSet aArgSet( GetPool(), SCITEM_SORTDATA, SCITEM_SORTDATA );
+
+ pDBData->GetSortParam( aSortParam );
+ BOOL bHasHeader = pDoc->HasColHeader( aSortParam.nCol1, aSortParam.nRow1, aSortParam.nCol2, aSortParam.nRow2, pData->GetTabNo() );
+ if( bHasHeader )
+ aSortParam.bHasHeader = bHasHeader;
+
+ aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScSortDlg( pTabViewShell->GetDialogParent(), &aArgSet, RID_SCDLG_SORT );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetCurPageId(1); // 1=sort field tab 2=sort options tab
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+ const ScSortParam& rOutParam = ((const ScSortItem&)
+ pOutSet->Get( SCITEM_SORTDATA )).GetSortData();
+
+ // Teilergebnisse bei Bedarf neu
+ pTabViewShell->UISort( rOutParam );
+
+ if ( rOutParam.bInplace )
+ {
+ rReq.AppendItem( SfxBoolItem( SID_SORT_BYROW,
+ rOutParam.bByRow ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
+ rOutParam.bHasHeader ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
+ rOutParam.bCaseSens ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
+ rOutParam.bNaturalSort ) );
+ rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
+ rOutParam.bIncludePattern ) );
+ USHORT nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
+ rReq.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
+ if ( rOutParam.bDoSort[0] )
+ {
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_1,
+ rOutParam.nField[0] + 1 ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_2,
+ rOutParam.bAscending[0] ) );
+ }
+ if ( rOutParam.bDoSort[1] )
+ {
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_3,
+ rOutParam.nField[1] + 1 ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_4,
+ rOutParam.bAscending[1] ) );
+ }
+ if ( rOutParam.bDoSort[2] )
+ {
+ rReq.AppendItem( SfxInt32Item( FN_PARAM_5,
+ rOutParam.nField[2] + 1 ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_6,
+ rOutParam.bAscending[2] ) );
+ }
+ }
+
+ rReq.Done();
+ }
+ else
+ GetViewData()->GetDocShell()->CancelAutoDBRange();
+
+ delete pDlg;
+ }
+ }
+ }
+ break;
+
+ case SID_FILTER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ DBG_ERROR("SID_FILTER with arguments?");
+ pTabViewShell->Query( ((const ScQueryItem&)
+ pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, TRUE );
+ rReq.Done();
+ }
+ else
+ {
+ USHORT nId = ScFilterDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ }
+ break;
+
+ case SID_SPECIAL_FILTER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ DBG_ERROR("SID_SPECIAL_FILTER with arguments?");
+ pTabViewShell->Query( ((const ScQueryItem&)
+ pArgs->Get( SCITEM_QUERYDATA )).GetQueryData(), NULL, TRUE );
+ rReq.Done();
+ }
+ else
+ {
+ USHORT nId = ScSpecialFilterDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ }
+ break;
+
+ case FID_FILTER_OK:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState( SCITEM_QUERYDATA, TRUE, &pItem ) )
+ {
+ const ScQueryItem& rQueryItem = static_cast<const ScQueryItem&>(*pItem);
+
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ SCTAB nRefTab = GetViewData()->GetRefTabNo();
+
+ // If RefInput switched to a different sheet from the data sheet,
+ // switch back:
+
+ if ( nCurTab != nRefTab )
+ {
+ pTabViewShell->SetTabNo( nRefTab );
+ pTabViewShell->PaintExtras();
+ }
+
+ ScRange aAdvSource;
+ if (rQueryItem.GetAdvancedQuerySource(aAdvSource))
+ pTabViewShell->Query( rQueryItem.GetQueryData(), &aAdvSource, TRUE );
+ else
+ pTabViewShell->Query( rQueryItem.GetQueryData(), NULL, TRUE );
+ rReq.Done( *pReqArgs );
+ }
+ }
+ break;
+
+ case SID_UNFILTER:
+ {
+ ScQueryParam aParam;
+ ScDBData* pDBData = pTabViewShell->GetDBData();
+
+ pDBData->GetQueryParam( aParam );
+ SCSIZE nEC = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ aParam.GetEntry(i).bDoQuery = FALSE;
+ aParam.bDuplicate = TRUE;
+ pTabViewShell->Query( aParam, NULL, TRUE );
+ rReq.Done();
+ }
+ break;
+
+ case SID_AUTO_FILTER:
+ pTabViewShell->ToggleAutoFilter();
+ rReq.Done();
+ break;
+
+ case SID_AUTOFILTER_HIDE:
+ pTabViewShell->HideAutoFilter();
+ rReq.Done();
+ break;
+
+ case SID_PIVOT_TABLE:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState( SCITEM_PIVOTDATA, TRUE, &pItem ) )
+ {
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ SCTAB nRefTab = GetViewData()->GetRefTabNo();
+
+ // Wenn RefInput auf andere Tabelle als Datentabelle umgeschaltet
+ // hat wieder zurueckschalten:
+
+ if ( nCurTab != nRefTab )
+ {
+ pTabViewShell->SetTabNo( nRefTab );
+ pTabViewShell->PaintExtras();
+ }
+
+ const ScDPObject* pDPObject = pTabViewShell->GetDialogDPObject();
+ if ( pDPObject )
+ {
+ const ScPivotItem* pPItem = (const ScPivotItem*)pItem;
+ bool bSuccess = pTabViewShell->MakePivotTable(
+ pPItem->GetData(), pPItem->GetDestRange(), pPItem->IsNewSheet(), *pDPObject );
+ SfxBoolItem aRet(0, bSuccess);
+ rReq.SetReturnValue(aRet);
+ }
+ rReq.Done();
+ }
+ else if (rReq.IsAPI())
+ SbxBase::SetError(SbxERR_BAD_PARAMETER);
+ }
+ break;
+
+ case SID_OPENDLG_PIVOTTABLE:
+ {
+ ScViewData* pData = GetViewData();
+ ScDocument* pDoc = pData->GetDocument();
+
+ ScDPObject* pNewDPObject = NULL;
+
+ // ScPivot is no longer used...
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(
+ pData->GetCurX(), pData->GetCurY(),
+ pData->GetTabNo() );
+ if ( pDPObj ) // on an existing table?
+ {
+ pNewDPObject = new ScDPObject( *pDPObj );
+ }
+ else // create new table
+ {
+ // select database range or data
+ pTabViewShell->GetDBData( TRUE, SC_DB_OLD );
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ pTabViewShell->MarkDataArea( FALSE );
+
+ // output to cursor position for non-sheet data
+ ScAddress aDestPos( pData->GetCurX(), pData->GetCurY(),
+ pData->GetTabNo() );
+
+ // first select type of source data
+
+ BOOL bEnableExt = ScDPObject::HasRegisteredSources();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDataPilotSourceTypeDlg* pTypeDlg = pFact->CreateScDataPilotSourceTypeDlg( pTabViewShell->GetDialogParent(), bEnableExt, RID_SCDLG_DAPITYPE );
+ DBG_ASSERT(pTypeDlg, "Dialog create fail!");
+ if ( pTypeDlg->Execute() == RET_OK )
+ {
+ if ( pTypeDlg->IsExternal() )
+ {
+ uno::Sequence<rtl::OUString> aSources = ScDPObject::GetRegisteredSources();
+ AbstractScDataPilotServiceDlg* pServDlg = pFact->CreateScDataPilotServiceDlg( pTabViewShell->GetDialogParent(), aSources, RID_SCDLG_DAPISERVICE );
+ DBG_ASSERT(pServDlg, "Dialog create fail!");
+ if ( pServDlg->Execute() == RET_OK )
+ {
+ ScDPServiceDesc aServDesc(
+ pServDlg->GetServiceName(),
+ pServDlg->GetParSource(),
+ pServDlg->GetParName(),
+ pServDlg->GetParUser(),
+ pServDlg->GetParPass() );
+ pNewDPObject = new ScDPObject( pDoc );
+ pNewDPObject->SetServiceData( aServDesc );
+ }
+ delete pServDlg;
+ }
+ else if ( pTypeDlg->IsDatabase() )
+ {
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScDataPilotDatabaseDlg* pDataDlg = pFact->CreateScDataPilotDatabaseDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_DAPIDATA);
+ DBG_ASSERT(pDataDlg, "Dialog create fail!");
+ if ( pDataDlg->Execute() == RET_OK )
+ {
+ ScImportSourceDesc aImpDesc;
+ pDataDlg->GetValues( aImpDesc );
+ pNewDPObject = new ScDPObject( pDoc );
+ pNewDPObject->SetImportDesc( aImpDesc );
+ }
+ delete pDataDlg;
+ }
+ else // selection
+ {
+ //! use database ranges (select before type dialog?)
+ ScRange aRange;
+ ScMarkType eType = GetViewData()->GetSimpleArea(aRange);
+ if ( (eType & SC_MARK_SIMPLE) == SC_MARK_SIMPLE )
+ {
+ // Shrink the range to the data area.
+ SCCOL nStartCol = aRange.aStart.Col(), nEndCol = aRange.aEnd.Col();
+ SCROW nStartRow = aRange.aStart.Row(), nEndRow = aRange.aEnd.Row();
+ if (pDoc->ShrinkToDataArea(aRange.aStart.Tab(), nStartCol, nStartRow, nEndCol, nEndRow))
+ {
+ aRange.aStart.SetCol(nStartCol);
+ aRange.aStart.SetRow(nStartRow);
+ aRange.aEnd.SetCol(nEndCol);
+ aRange.aEnd.SetRow(nEndRow);
+ rMark.SetMarkArea(aRange);
+ pTabViewShell->MarkRange(aRange);
+ }
+
+ BOOL bOK = TRUE;
+ if ( pDoc->HasSubTotalCells( aRange ) )
+ {
+ // confirm selection if it contains SubTotal cells
+
+ QueryBox aBox( pTabViewShell->GetDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_DATAPILOT_SUBTOTAL) );
+ if (aBox.Execute() == RET_NO)
+ bOK = FALSE;
+ }
+ if (bOK)
+ {
+ ScSheetSourceDesc aShtDesc;
+ aShtDesc.aSourceRange = aRange;
+ pNewDPObject = new ScDPObject( pDoc );
+ pNewDPObject->SetSheetDesc( aShtDesc );
+
+ // output below source data
+ if ( aRange.aEnd.Row()+2 <= MAXROW - 4 )
+ aDestPos = ScAddress( aRange.aStart.Col(),
+ aRange.aEnd.Row()+2,
+ aRange.aStart.Tab() );
+ }
+ }
+ }
+ }
+ delete pTypeDlg;
+
+ if ( pNewDPObject )
+ pNewDPObject->SetOutRange( aDestPos );
+ }
+
+ pTabViewShell->SetDialogDPObject( pNewDPObject ); // is copied
+ if ( pNewDPObject )
+ {
+ // start layout dialog
+
+ USHORT nId = ScPivotLayoutWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ delete pNewDPObject;
+ }
+ break;
+
+ case SID_DEFINE_DBNAME:
+ {
+
+ USHORT nId = ScDbNameDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+
+ }
+ break;
+
+ case SID_SELECT_DB:
+ {
+ if ( pReqArgs )
+ {
+ const SfxStringItem* pItem =
+ (const SfxStringItem*)&pReqArgs->Get( SID_SELECT_DB );
+
+ if( pItem )
+ {
+ pTabViewShell->GotoDBArea( pItem->GetValue() );
+ rReq.Done();
+ }
+ else
+ {
+ DBG_ERROR("NULL");
+ }
+ }
+ else
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBCollection* pDBCol = pDoc->GetDBCollection();
+
+ if ( pDBCol )
+ {
+ const String aStrNoName( ScGlobal::GetRscString(STR_DB_NONAME) );
+ List aList;
+ USHORT nDBCount = pDBCol->GetCount();
+ ScDBData* pDbData = NULL;
+ String* pDBName = NULL;
+
+ for ( USHORT i=0; i < nDBCount; i++ )
+ {
+ pDbData = (ScDBData*)(pDBCol->At( i ));
+ if ( pDbData )
+ {
+ pDBName = new String;
+ pDbData->GetName( *pDBName );
+
+ if ( *pDBName != aStrNoName )
+ aList.Insert( pDBName );
+ else
+ DELETEZ(pDBName);
+ }
+ }
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScSelEntryDlg* pDlg = pFact->CreateScSelEntryDlg( pTabViewShell->GetDialogParent(),
+ RID_SCDLG_SELECTDB,
+ String(ScResId(SCSTR_SELECTDB)),
+ String(ScResId(SCSTR_AREAS)),
+ aList,
+ RID_SCDLG_SELECTDB);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ String aName = pDlg->GetSelectEntry();
+ pTabViewShell->GotoDBArea( aName );
+ rReq.AppendItem( SfxStringItem( SID_SELECT_DB, aName ) );
+ rReq.Done();
+ }
+
+ delete pDlg;
+
+ void* pEntry = aList.First();
+ while ( pEntry )
+ {
+ delete (String*) aList.Remove( pEntry );
+ pEntry = aList.Next();
+ }
+ }
+ }
+ }
+ break;
+
+ case FID_VALIDATION:
+ {
+ const SfxPoolItem* pItem;
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ if ( pArgs )
+ {
+ DBG_ERROR("spaeter...");
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ ::GetTabPageRanges ScTPValidationValueGetRanges = pFact->GetTabPageRangesFunc(TP_VALIDATION_VALUES);
+ DBG_ASSERT(ScTPValidationValueGetRanges, "TabPage create fail!");
+ SfxItemSet aArgSet( GetPool(), (*ScTPValidationValueGetRanges)() );
+ ScValidationMode eMode = SC_VALID_ANY;
+ ScConditionMode eOper = SC_COND_EQUAL;
+ String aExpr1, aExpr2;
+ BOOL bBlank = TRUE;
+ sal_Int16 nListType = ValidListType::UNSORTED;
+ BOOL bShowHelp = FALSE;
+ String aHelpTitle, aHelpText;
+ BOOL bShowError = FALSE;
+ ScValidErrorStyle eErrStyle = SC_VALERR_STOP;
+ String aErrTitle, aErrText;
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aCursorPos( nCurX, nCurY, nTab );
+ ULONG nIndex = ((SfxUInt32Item*)pDoc->GetAttr(
+ nCurX, nCurY, nTab, ATTR_VALIDDATA ))->GetValue();
+ if ( nIndex )
+ {
+ const ScValidationData* pOldData = pDoc->GetValidationEntry( nIndex );
+ if ( pOldData )
+ {
+ eMode = pOldData->GetDataMode();
+ eOper = pOldData->GetOperation();
+ ULONG nNumFmt = 0;
+ if ( eMode == SC_VALID_DATE || eMode == SC_VALID_TIME )
+ {
+ short nType = ( eMode == SC_VALID_DATE ) ? NUMBERFORMAT_DATE
+ : NUMBERFORMAT_TIME;
+ nNumFmt = pDoc->GetFormatTable()->GetStandardFormat(
+ nType, ScGlobal::eLnge );
+ }
+ aExpr1 = pOldData->GetExpression( aCursorPos, 0, nNumFmt );
+ aExpr2 = pOldData->GetExpression( aCursorPos, 1, nNumFmt );
+ bBlank = pOldData->IsIgnoreBlank();
+ nListType = pOldData->GetListType();
+
+ bShowHelp = pOldData->GetInput( aHelpTitle, aHelpText );
+ bShowError = pOldData->GetErrMsg( aErrTitle, aErrText, eErrStyle );
+
+ aArgSet.Put( SfxAllEnumItem( FID_VALID_MODE, sal::static_int_cast<USHORT>(eMode) ) );
+ aArgSet.Put( SfxAllEnumItem( FID_VALID_CONDMODE, sal::static_int_cast<USHORT>(eOper) ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_VALUE1, aExpr1 ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_VALUE2, aExpr2 ) );
+ aArgSet.Put( SfxBoolItem( FID_VALID_BLANK, bBlank ) );
+ aArgSet.Put( SfxInt16Item( FID_VALID_LISTTYPE, nListType ) );
+ aArgSet.Put( SfxBoolItem( FID_VALID_SHOWHELP, bShowHelp ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_HELPTITLE, aHelpTitle ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_HELPTEXT, aHelpText ) );
+ aArgSet.Put( SfxBoolItem( FID_VALID_SHOWERR, bShowError ) );
+ aArgSet.Put( SfxAllEnumItem( FID_VALID_ERRSTYLE, sal::static_int_cast<USHORT>(eErrStyle) ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_ERRTITLE, aErrTitle ) );
+ aArgSet.Put( SfxStringItem( FID_VALID_ERRTEXT, aErrText ) );
+ }
+ }
+
+ // cell range picker
+ SfxAbstractTabDialog* pDlg = pFact->CreateScValidationDlg( NULL, &aArgSet, TAB_DLG_VALIDATION, pTabViewShell );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ short nResult = pDlg->Execute();
+ //When picking Cell Range, other Tab may be switched. Need restore the correct tab
+ pTabViewShell->SetTabNo( nTab );
+ if ( nResult == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ if ( pOutSet->GetItemState( FID_VALID_MODE, TRUE, &pItem ) == SFX_ITEM_SET )
+ eMode = (ScValidationMode) ((const SfxAllEnumItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_CONDMODE, TRUE, &pItem ) == SFX_ITEM_SET )
+ eOper = (ScConditionMode) ((const SfxAllEnumItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_VALUE1, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ String aTemp1 = ((const SfxStringItem*)pItem)->GetValue();
+ if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
+ {
+ sal_uInt32 nNumIndex = 0;
+ double nVal;
+ if (pDoc->GetFormatTable()->IsNumberFormat(aTemp1, nNumIndex, nVal))
+ aExpr1 =String( ::rtl::math::doubleToUString( nVal,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), TRUE));
+ else
+ aExpr1 = aTemp1;
+ }
+ else
+ aExpr1 = aTemp1;
+ }
+ if ( pOutSet->GetItemState( FID_VALID_VALUE2, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ String aTemp2 = ((const SfxStringItem*)pItem)->GetValue();
+ if (eMode == SC_VALID_DATE || eMode == SC_VALID_TIME)
+ {
+ sal_uInt32 nNumIndex = 0;
+ double nVal;
+ if (pDoc->GetFormatTable()->IsNumberFormat(aTemp2, nNumIndex, nVal))
+ aExpr2 =String( ::rtl::math::doubleToUString( nVal,
+ rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
+ ScGlobal::pLocaleData->getNumDecimalSep().GetChar(0), TRUE));
+ else
+ aExpr2 = aTemp2;
+ }
+ else
+ aExpr2 = aTemp2;
+ }
+
+ if ( pOutSet->GetItemState( FID_VALID_BLANK, TRUE, &pItem ) == SFX_ITEM_SET )
+ bBlank = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_LISTTYPE, TRUE, &pItem ) == SFX_ITEM_SET )
+ nListType = ((const SfxInt16Item*)pItem)->GetValue();
+
+ if ( pOutSet->GetItemState( FID_VALID_SHOWHELP, TRUE, &pItem ) == SFX_ITEM_SET )
+ bShowHelp = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_HELPTITLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aHelpTitle = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_HELPTEXT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aHelpText = ((const SfxStringItem*)pItem)->GetValue();
+
+ if ( pOutSet->GetItemState( FID_VALID_SHOWERR, TRUE, &pItem ) == SFX_ITEM_SET )
+ bShowError = ((const SfxBoolItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_ERRSTYLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ eErrStyle = (ScValidErrorStyle) ((const SfxAllEnumItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_ERRTITLE, TRUE, &pItem ) == SFX_ITEM_SET )
+ aErrTitle = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pOutSet->GetItemState( FID_VALID_ERRTEXT, TRUE, &pItem ) == SFX_ITEM_SET )
+ aErrText = ((const SfxStringItem*)pItem)->GetValue();
+
+ ScValidationData aData( eMode, eOper, aExpr1, aExpr2, pDoc, aCursorPos );
+ aData.SetIgnoreBlank( bBlank );
+ aData.SetListType( nListType );
+
+ aData.SetInput(aHelpTitle, aHelpText); // sets bShowInput to TRUE
+ if (!bShowHelp)
+ aData.ResetInput(); // reset only bShowInput
+
+ aData.SetError(aErrTitle, aErrText, eErrStyle); // sets bShowError to TRUE
+ if (!bShowError)
+ aData.ResetError(); // reset only bShowError
+
+ pTabViewShell->SetValidation( aData );
+ rReq.Done( *pOutSet );
+ }
+ //<!-- Modified by PengYunQuan for Validity Cell Range Picker
+ //after end execute from !IsModalInputMode, it is safer to delay deleting
+ //delete pDlg;
+ Application::PostUserEvent( Link( pDlg, &DelayDeleteAbstractDialog ) );
+ //--> Modified by PengYunQuan for Validity Cell Range Picker
+ }
+ }
+ break;
+
+ case SID_TEXT_TO_COLUMNS:
+ {
+ ScViewData* pData = GetViewData();
+ DBG_ASSERT( pData, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pData is null!" );
+ ScRange aRange;
+
+ if ( lcl_GetTextToColumnsRange( pData, aRange ) )
+ {
+ ScDocument* pDoc = pData->GetDocument();
+ DBG_ASSERT( pDoc, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDoc is null!" );
+
+ ScImportExport aExport( pDoc, aRange );
+ aExport.SetExportTextOptions( ScExportTextOptions( ScExportTextOptions::None, 0, false ) );
+
+ // #i87703# text to columns fails with tab separator
+ aExport.SetDelimiter( static_cast< sal_Unicode >( 0 ) );
+
+ SvMemoryStream aStream;
+ aStream.SetStreamCharSet( RTL_TEXTENCODING_UNICODE );
+ ScImportExport::SetNoEndianSwap( aStream );
+ aExport.ExportStream( aStream, String(), FORMAT_STRING );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pFact is null!" );
+ AbstractScImportAsciiDlg *pDlg = pFact->CreateScImportAsciiDlg(
+ NULL, String(), &aStream, RID_SCDLG_ASCII );
+ DBG_ASSERT( pDlg, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDlg is null!" );
+ pDlg->SetTextToColumnsMode();
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ ScDocShell* pDocSh = pData->GetDocShell();
+ DBG_ASSERT( pDocSh, "ScCellShell::ExecuteDB: SID_TEXT_TO_COLUMNS - pDocSh is null!" );
+
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_TEXTTOCOLUMNS );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ ScImportExport aImport( pDoc, aRange.aStart );
+ ScAsciiOptions aOptions;
+ pDlg->GetOptions( aOptions );
+ aImport.SetExtOptions( aOptions );
+ aImport.SetApi( false );
+ aStream.Seek( 0 );
+ aImport.ImportStream( aStream, String(), FORMAT_STRING );
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+ delete pDlg;
+ }
+ }
+ break;
+ }
+}
+
+void __EXPORT ScCellShell::GetDBState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScViewData* pData = GetViewData();
+ ScDocShell* pDocSh = pData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nPosX = pData->GetCurX();
+ SCROW nPosY = pData->GetCurY();
+ SCTAB nTab = pData->GetTabNo();
+
+ BOOL bAutoFilter = FALSE;
+ BOOL bAutoFilterTested = FALSE;
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_REFRESH_DBAREA:
+ {
+ // importierte Daten ohne Selektion
+ // oder Filter,Sortierung,Teilergebis (auch ohne Import)
+ BOOL bOk = FALSE;
+ ScDBData* pDBData = pTabViewShell->GetDBData(FALSE,SC_DB_OLD);
+ if (pDBData && pDoc->GetChangeTrack() == NULL)
+ {
+ if ( pDBData->HasImportParam() )
+ bOk = !pDBData->HasImportSelection();
+ else
+ {
+ bOk = pDBData->HasQueryParam() ||
+ pDBData->HasSortParam() ||
+ pDBData->HasSubTotalParam();
+ }
+ }
+ if (!bOk)
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_FILTER:
+ case SID_SPECIAL_FILTER:
+ {
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+
+ //Bei Redlining und Multiselektion Disablen
+ case SID_SORT_ASCENDING:
+ case SID_SORT_DESCENDING:
+ case SCITEM_SORTDATA:
+ case SCITEM_SUBTDATA:
+ case SID_OPENDLG_PIVOTTABLE:
+ {
+ //! move ReadOnly check to idl flags
+
+ if ( pDocSh->IsReadOnly() || pDoc->GetChangeTrack()!=NULL ||
+ GetViewData()->IsMultiMarked() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_REIMPORT_DATA:
+ {
+ // nur importierte Daten ohne Selektion
+ ScDBData* pDBData = pTabViewShell->GetDBData(FALSE,SC_DB_OLD);
+ if (!pDBData || !pDBData->HasImportParam() || pDBData->HasImportSelection() ||
+ pDoc->GetChangeTrack()!=NULL)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_VIEW_DATA_SOURCE_BROWSER:
+ {
+ if (!SvtModuleOptions().IsModuleInstalled(SvtModuleOptions::E_SDATABASE))
+ rSet.Put(SfxVisibilityItem(nWhich, sal_False));
+ else
+ // get state (BoolItem) from SfxViewFrame
+ pTabViewShell->GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
+ }
+ break;
+ case SID_SBA_BRW_INSERT:
+ {
+ // SBA will ein BOOL-Item, damit ueberhaupt enabled
+
+ BOOL bEnable = TRUE;
+ rSet.Put(SfxBoolItem(nWhich, bEnable));
+ }
+ break;
+
+ case SID_AUTO_FILTER:
+ case SID_AUTOFILTER_HIDE:
+ {
+ if (!bAutoFilterTested)
+ {
+ bAutoFilter = pDoc->HasAutoFilter( nPosX, nPosY, nTab );
+ bAutoFilterTested = TRUE;
+ }
+ if ( nWhich == SID_AUTO_FILTER )
+ {
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy);
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else if (pDoc->GetDPAtBlock(aDummy))
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ rSet.Put( SfxBoolItem( nWhich, bAutoFilter ) );
+ }
+ else
+ if (!bAutoFilter)
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_UNFILTER:
+ {
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ SCTAB nStartTab, nEndTab;
+ BOOL bAnyQuery = FALSE;
+
+ BOOL bSelected = (GetViewData()->GetSimpleArea(
+ nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab )
+ == SC_MARK_SIMPLE);
+
+ if ( bSelected )
+ {
+ if (nStartCol==nEndCol && nStartRow==nEndRow)
+ bSelected = FALSE;
+ }
+ else
+ {
+ nStartCol = GetViewData()->GetCurX();
+ nStartRow = GetViewData()->GetCurY();
+ nStartTab = GetViewData()->GetTabNo();
+ }
+
+ ScDBData* pDBData = bSelected
+ ? pDoc->GetDBAtArea( nStartTab, nStartCol, nStartRow, nEndCol, nEndRow )
+ : pDoc->GetDBAtCursor( nStartCol, nStartRow, nStartTab );
+
+ if ( pDBData )
+ {
+ ScQueryParam aParam;
+ pDBData->GetQueryParam( aParam );
+ if ( aParam.GetEntry(0).bDoQuery )
+ bAnyQuery = TRUE;
+ }
+
+ if ( !bAnyQuery )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_DEFINE_DBNAME:
+ {
+ if ( pDocSh && pDocSh->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_TEXT_TO_COLUMNS:
+ {
+ ScRange aRange;
+ if ( !lcl_GetTextToColumnsRange( pData, aRange ) )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
new file mode 100644
index 000000000000..c56d82691f85
--- /dev/null
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -0,0 +1,932 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+#include "docsh.hxx"
+#include "reffact.hxx"
+#include "uiitems.hxx"
+#include "autoform.hxx"
+#include "autofmt.hxx"
+#include "cellsh.hxx"
+#include "attrdlg.hrc" // TP_ALIGNMENT
+#include "inputhdl.hxx"
+#include "editable.hxx"
+
+#include "scabstdlg.hxx"
+
+#define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
+
+inline long TwipsToHMM(long nTwips) { return (nTwips * 127 + 36) / 72; }
+inline long HMMToTwips(long nHMM) { return (nHMM * 72 + 63) / 127; }
+inline long TwipsToEvenHMM(long nTwips) { return ( (nTwips * 127 + 72) / 144 ) * 2; }
+
+//------------------------------------------------------------------
+
+void ScCellShell::Execute( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ ScModule* pScMod = SC_MOD();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( IS_EDITMODE() )
+ {
+ switch ( nSlot )
+ {
+ // beim Oeffnen eines Referenz-Dialogs darf die SubShell nicht umgeschaltet werden
+ // (beim Schliessen des Dialogs wird StopEditShell gerufen)
+ case SID_OPENDLG_FUNCTION:
+ // #53318# inplace macht die EditShell Aerger...
+ //! kann nicht immer umgeschaltet werden ????
+ if (!pTabViewShell->GetViewFrame()->GetFrame().IsInPlace())
+ pTabViewShell->SetDontSwitch(TRUE); // EditShell nicht abschalten
+ // kein break
+
+ case FID_CELL_FORMAT:
+ case SID_ENABLE_HYPHENATION:
+ case SID_DATA_SELECT:
+ case SID_OPENDLG_CONSOLIDATE:
+ case SID_OPENDLG_SOLVE:
+ case SID_OPENDLG_OPTSOLVER:
+
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+
+ pTabViewShell->SetDontSwitch(FALSE);
+
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ switch ( nSlot )
+ {
+
+
+
+ case SID_ATTR_SIZE://XXX ???
+ break;
+
+ case SID_STATUS_SELMODE:
+ if ( pReqArgs )
+ {
+ /* 0: STD Click hebt Sel auf
+ * 1: ER Click erweitert Selektion
+ * 2: ERG Click definiert weitere Selektion
+ */
+ UINT16 nMode = ((const SfxUInt16Item&)pReqArgs->Get( nSlot )).GetValue();
+
+ switch ( nMode )
+ {
+ case 1: nMode = KEY_SHIFT; break;
+ case 2: nMode = KEY_MOD1; break; // Control-Taste
+ case 0:
+ default:
+ nMode = 0;
+ }
+
+ pTabViewShell->LockModifiers( nMode );
+ }
+ else
+ {
+ // no arguments (also executed by double click on the status bar controller):
+ // advance to next selection mode
+
+ USHORT nModifiers = pTabViewShell->GetLockedModifiers();
+ switch ( nModifiers )
+ {
+ case KEY_SHIFT: nModifiers = KEY_MOD1; break; // EXT -> ADD
+ case KEY_MOD1: nModifiers = 0; break; // ADD -> STD
+ default: nModifiers = KEY_SHIFT; break; // STD -> EXT
+ }
+ pTabViewShell->LockModifiers( nModifiers );
+ }
+
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ rReq.Done();
+ break;
+
+ // SID_STATUS_SELMODE_NORM wird nicht benutzt ???
+
+ case SID_STATUS_SELMODE_NORM:
+ pTabViewShell->LockModifiers( 0 );
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ break;
+
+ // SID_STATUS_SELMODE_ERG / SID_STATUS_SELMODE_ERW als Toggles:
+
+ case SID_STATUS_SELMODE_ERG:
+ if ( pTabViewShell->GetLockedModifiers() & KEY_MOD1 )
+ pTabViewShell->LockModifiers( 0 );
+ else
+ pTabViewShell->LockModifiers( KEY_MOD1 );
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ break;
+
+ case SID_STATUS_SELMODE_ERW:
+ if ( pTabViewShell->GetLockedModifiers() & KEY_SHIFT )
+ pTabViewShell->LockModifiers( 0 );
+ else
+ pTabViewShell->LockModifiers( KEY_SHIFT );
+ rBindings.Invalidate( SID_STATUS_SELMODE );
+ break;
+
+ case SID_ENTER_STRING:
+ {
+ if ( pReqArgs )
+ {
+ String aStr( ((const SfxStringItem&)pReqArgs->
+ Get( SID_ENTER_STRING )).GetValue() );
+
+ pTabViewShell->EnterData( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo(),
+ aStr );
+
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
+ if ( !pHdl || !pHdl->IsInEnterHandler() )
+ {
+ // #101061# UpdateInputHandler is needed after the cell content
+ // has changed, but if called from EnterHandler, UpdateInputHandler
+ // will be called later when moving the cursor.
+
+ pTabViewShell->UpdateInputHandler();
+ }
+
+ rReq.Done();
+
+ // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
+ // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
+ // (GrabFocus passiert in KillEditView)
+ }
+ }
+ break;
+
+ case SID_INSERT_MATRIX:
+ {
+ if ( pReqArgs )
+ {
+ String aStr = ((const SfxStringItem&)pReqArgs->
+ Get( SID_INSERT_MATRIX )).GetValue();
+ pTabViewShell->EnterMatrix( aStr );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case FID_INPUTLINE_ENTER:
+ case FID_INPUTLINE_BLOCK:
+ case FID_INPUTLINE_MATRIX:
+ {
+ if( pReqArgs == 0 ) //XXX vorlaufiger HACK um GPF zu vermeiden
+ break;
+
+ const ScInputStatusItem* pStatusItem
+ = (const ScInputStatusItem*)&pReqArgs->
+ Get( FID_INPUTLINE_STATUS );
+
+ ScAddress aCursorPos = pStatusItem->GetPos();
+ String aString = pStatusItem->GetString();
+ const EditTextObject* pData = pStatusItem->GetEditData();
+ if (pData)
+ {
+ if (nSlot == FID_INPUTLINE_BLOCK)
+ {
+ pTabViewShell->EnterBlock( aString, pData );
+ }
+ else if ( aString.Len() > 0 && ( aString.GetChar(0) == '=' || aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
+ {
+ pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), aString, TRUE, pData );
+ }
+ else
+ {
+ pTabViewShell->EnterData( aCursorPos.Col(), aCursorPos.Row(), aCursorPos.Tab(), pData );
+ }
+ }
+ else
+ {
+ if (nSlot == FID_INPUTLINE_ENTER)
+ {
+ if (
+ aCursorPos.Col() == GetViewData()->GetCurX() &&
+ aCursorPos.Row() == GetViewData()->GetCurY() &&
+ aCursorPos.Tab() == GetViewData()->GetTabNo()
+ )
+ {
+ SfxStringItem aItem( SID_ENTER_STRING, aString );
+
+ // SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+ const SfxPoolItem* aArgs[2];
+ aArgs[0] = &aItem;
+ aArgs[1] = NULL;
+ rBindings.Execute( SID_ENTER_STRING, aArgs );
+ }
+ else
+ {
+ pTabViewShell->EnterData( aCursorPos.Col(),
+ aCursorPos.Row(),
+ aCursorPos.Tab(),
+ aString );
+ rReq.Done();
+ }
+ }
+ else if (nSlot == FID_INPUTLINE_BLOCK)
+ {
+ pTabViewShell->EnterBlock( aString, NULL );
+ rReq.Done();
+ }
+ else
+ {
+ pTabViewShell->EnterMatrix( aString );
+ rReq.Done();
+ }
+
+ }
+
+ // hier kein GrabFocus, weil sonst auf dem Mac die Tabelle vor die
+ // Seitenansicht springt, wenn die Eingabe nicht abgeschlossen war
+ // (GrabFocus passiert in KillEditView)
+ }
+ break;
+
+ case SID_OPENDLG_FUNCTION:
+ {
+ USHORT nId = SID_OPENDLG_FUNCTION;
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_OPENDLG_CONSOLIDATE:
+ {
+ USHORT nId = ScConsolidateDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case FID_CELL_FORMAT:
+ {
+ if ( pReqArgs != NULL )
+ {
+ //----------------------------------
+ // Zellattribute ohne Dialog setzen:
+ //----------------------------------
+ SfxItemSet* pEmptySet =
+ new SfxItemSet( *pReqArgs->GetPool(),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+
+ SfxItemSet* pNewSet =
+ new SfxItemSet( *pReqArgs->GetPool(),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+
+ const SfxPoolItem* pAttr = NULL;
+ USHORT nWhich = 0;
+
+ for ( nWhich=ATTR_PATTERN_START; nWhich<=ATTR_PATTERN_END; nWhich++ )
+ if ( pReqArgs->GetItemState( nWhich, TRUE, &pAttr ) == SFX_ITEM_SET )
+ pNewSet->Put( *pAttr );
+
+ pTabViewShell->ApplyAttributes( pNewSet, pEmptySet );
+
+ delete pNewSet;
+ delete pEmptySet;
+
+ rReq.Done();
+ }
+ else if ( pReqArgs == NULL )
+ {
+ pTabViewShell->ExecuteCellFormatDlg( rReq );
+ }
+ }
+ break;
+
+ case SID_ENABLE_HYPHENATION:
+ pTabViewShell->ExecuteCellFormatDlg( rReq, TP_ALIGNMENT );
+ break;
+
+ case SID_OPENDLG_SOLVE:
+ {
+ USHORT nId = ScSolverDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case SID_OPENDLG_OPTSOLVER:
+ {
+ USHORT nId = ScOptSolverDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case SID_OPENDLG_TABOP:
+ {
+ USHORT nId = ScTabOpDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case SID_SCENARIOS:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ if ( pDoc->IsScenario(nTab) )
+ {
+ rMark.MarkToMulti();
+ if ( rMark.IsMultiMarked() )
+ {
+ if ( rReq.IsAPI()
+ || RET_YES ==
+ QueryBox( pTabViewShell->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString(STR_UPDATE_SCENARIO) ).
+ Execute() )
+ {
+ pTabViewShell->ExtendScenario();
+ rReq.Done();
+ }
+ }
+ else if( ! rReq.IsAPI() )
+ {
+ ErrorBox aErrorBox( pTabViewShell->GetDialogParent(), WinBits(WB_OK | WB_DEF_OK),
+ ScGlobal::GetRscString(STR_NOAREASELECTED) );
+ aErrorBox.Execute();
+ }
+ }
+ else
+ {
+ rMark.MarkToMulti();
+ if ( rMark.IsMultiMarked() )
+ {
+ SCTAB i=1;
+ String aBaseName;
+ String aName;
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+
+ pDoc->GetName( nTab, aBaseName );
+ aBaseName += '_';
+ aBaseName += ScGlobal::GetRscString(STR_SCENARIO);
+ aBaseName += '_';
+
+ // vorneweg testen, ob der Prefix als gueltig erkannt wird
+ // wenn nicht, nur doppelte vermeiden
+ BOOL bPrefix = pDoc->ValidTabName( aBaseName );
+ DBG_ASSERT(bPrefix, "ungueltiger Tabellenname");
+
+ while ( pDoc->IsScenario(nTab+i) )
+ i++;
+
+ BOOL bValid;
+ SCTAB nDummy;
+ do
+ {
+ aName = aBaseName;
+ aName += String::CreateFromInt32( i );
+ if (bPrefix)
+ bValid = pDoc->ValidNewTabName( aName );
+ else
+ bValid = !pDoc->GetTable( aName, nDummy );
+ ++i;
+ }
+ while ( !bValid && i <= 2*MAXTAB );
+
+ if ( pReqArgs != NULL )
+ {
+ String aArgName;
+ String aArgComment;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_SCENARIOS, TRUE, &pItem ) == SFX_ITEM_SET )
+ aArgName = ((const SfxStringItem*)pItem)->GetValue();
+ if ( pReqArgs->GetItemState( SID_NEW_TABLENAME, TRUE, &pItem ) == SFX_ITEM_SET )
+ aArgComment = ((const SfxStringItem*)pItem)->GetValue();
+
+ aColor = Color( COL_LIGHTGRAY ); // Default
+ nFlags = 0; // nicht-TwoWay
+
+ pTabViewShell->MakeScenario( aArgName, aArgComment, aColor, nFlags );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ BOOL bSheetProtected = pDoc->IsTabProtected(nTab);
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNewScenarioDlg* pNewDlg = pFact->CreateScNewScenarioDlg( pTabViewShell->GetDialogParent(), aName, RID_SCDLG_NEWSCENARIO, FALSE,bSheetProtected);
+ DBG_ASSERT(pNewDlg, "Dialog create fail!");
+ if ( pNewDlg->Execute() == RET_OK )
+ {
+ pNewDlg->GetScenarioData( aName, aComment, aColor, nFlags );
+ pTabViewShell->MakeScenario( aName, aComment, aColor, nFlags );
+
+ rReq.AppendItem( SfxStringItem( SID_SCENARIOS, aName ) );
+ rReq.AppendItem( SfxStringItem( SID_NEW_TABLENAME, aComment ) );
+ rReq.Done();
+ }
+ delete pNewDlg;
+ }
+ }
+ else if( ! rReq.IsAPI() )
+ {
+ pTabViewShell->ErrorMessage(STR_ERR_NEWSCENARIO);
+ }
+ }
+ }
+ break;
+
+
+ case SID_SELECTALL:
+ {
+ pTabViewShell->SelectAll();
+ rReq.Done();
+ }
+ break;
+
+ //----------------------------------------------------------------
+
+ case FID_ROW_HEIGHT:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_HEIGHT );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT,
+ sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ ScViewData* pData = GetViewData();
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+ USHORT nCurHeight = pData->GetDocument()->
+ GetRowHeight( pData->GetCurY(),
+ pData->GetTabNo() );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_MAN,
+ nCurHeight,
+ ScGlobal::nStdRowHeight,
+ RID_SCDLG_ROW_MAN,
+ eMetric,
+ 2,
+ MAX_COL_HEIGHT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, (USHORT)nVal );
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, (USHORT)TwipsToEvenHMM(nVal) ) );
+ rReq.Done();
+
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_ROW_OPT_HEIGHT:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_ROW_OPT_HEIGHT );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_OPTIMAL,
+ sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ ScGlobal::nLastRowHeightExtra = rUInt16Item.GetValue();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_ROW_OPT,
+ ScGlobal::nLastRowHeightExtra,
+ 0,
+ RID_SCDLG_ROW_OPT,
+ eMetric,
+ 1,
+ MAX_EXTRA_HEIGHT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_OPTIMAL, (USHORT)nVal );
+ ScGlobal::nLastRowHeightExtra = nVal;
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, (USHORT)TwipsToEvenHMM(nVal) ) );
+ rReq.Done();
+
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_COL_WIDTH:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_WIDTH );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT,
+ sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+ ScViewData* pData = GetViewData();
+ USHORT nCurHeight = pData->GetDocument()->
+ GetColWidth( pData->GetCurX(),
+ pData->GetTabNo() );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_MAN,
+ nCurHeight,
+ STD_COL_WIDTH,
+ RID_SCDLG_COL_MAN,
+ eMetric,
+ 2,
+ MAX_COL_WIDTH);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, (USHORT)nVal );
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, (USHORT)TwipsToEvenHMM(nVal)) );
+ rReq.Done();
+
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_COL_OPT_WIDTH:
+ {
+ if ( pReqArgs )
+ {
+ const SfxUInt16Item& rUInt16Item = (const SfxUInt16Item&)pReqArgs->Get( FID_COL_OPT_WIDTH );
+
+ // #101390#; the value of the macro is in HMM so use HMMToTwips to convert
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL,
+ sal::static_int_cast<USHORT>( HMMToTwips(rUInt16Item.GetValue()) ) );
+ ScGlobal::nLastColWidthExtra = rUInt16Item.GetValue();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMetricInputDlg* pDlg = pFact->CreateScMetricInputDlg( pTabViewShell->GetDialogParent(), RID_SCDLG_COL_OPT,
+ ScGlobal::nLastColWidthExtra,
+ STD_EXTRA_WIDTH,
+ RID_SCDLG_COL_OPT,
+ eMetric,
+ 1,
+ MAX_EXTRA_WIDTH);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ long nVal = pDlg->GetInputValue();
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, (USHORT)nVal );
+ ScGlobal::nLastColWidthExtra = nVal;
+
+ // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert
+ rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, (USHORT)TwipsToEvenHMM(nVal) ) );
+ rReq.Done();
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_COL_OPT_DIRECT:
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_OPTIMAL, STD_EXTRA_WIDTH );
+ rReq.Done();
+ break;
+
+ case FID_ROW_HIDE:
+ pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_DIRECT, 0 );
+ rReq.Done();
+ break;
+ case FID_ROW_SHOW:
+ pTabViewShell->SetMarkedWidthOrHeight( FALSE, SC_SIZE_SHOW, 0 );
+ rReq.Done();
+ break;
+ case FID_COL_HIDE:
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_DIRECT, 0 );
+ rReq.Done();
+ break;
+ case FID_COL_SHOW:
+ pTabViewShell->SetMarkedWidthOrHeight( TRUE, SC_SIZE_SHOW, 0 );
+ rReq.Done();
+ break;
+
+ //----------------------------------------------------------------
+
+
+ case SID_CELL_FORMAT_RESET:
+ {
+ pTabViewShell->DeleteContents( IDF_HARDATTR | IDF_EDITATTR );
+ rReq.Done();
+ }
+ break;
+
+ case FID_MERGE_ON:
+ case FID_MERGE_OFF:
+ case FID_MERGE_TOGGLE:
+ {
+ if ( !GetViewData()->GetDocument()->GetChangeTrack() )
+ {
+ // test whether to merge or to split
+ bool bMerge = false;
+ BOOL bCenter = FALSE;
+ switch( nSlot )
+ {
+ case FID_MERGE_ON:
+ bMerge = true;
+ break;
+ case FID_MERGE_OFF:
+ bMerge = false;
+ break;
+ case FID_MERGE_TOGGLE:
+ {
+ bCenter = TRUE;
+ SfxPoolItem* pItem = 0;
+ if( rBindings.QueryState( nSlot, pItem ) >= SFX_ITEM_DEFAULT )
+ bMerge = !static_cast< SfxBoolItem* >( pItem )->GetValue();
+ }
+ break;
+ }
+
+ if( bMerge )
+ {
+ // merge - check if to move contents of covered cells
+ BOOL bMoveContents = FALSE;
+ BOOL bApi = rReq.IsAPI();
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
+ {
+ DBG_ASSERT(pItem && pItem->ISA(SfxBoolItem), "falsches Item");
+ bMoveContents = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+
+ if (pTabViewShell->MergeCells( bApi, bMoveContents, TRUE, bCenter ))
+ {
+ if (!bApi && bMoveContents) // "ja" im Dialog geklickt
+ rReq.AppendItem( SfxBoolItem( nSlot, bMoveContents ) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ // split cells
+ if (pTabViewShell->RemoveMerge())
+ {
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ }
+ }
+ break;
+ }
+ }
+ break;
+
+ case SID_AUTOFORMAT:
+ {
+ Window* pDlgParent = pTabViewShell->GetDialogParent();
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ pTabViewShell->MarkDataArea( TRUE );
+
+ GetViewData()->GetSimpleArea( nStartCol,nStartRow,nStartTab,
+ nEndCol,nEndRow,nEndTab );
+
+ if ( ( Abs((SCsCOL)nEndCol-(SCsCOL)nStartCol) > 1 )
+ && ( Abs((SCsROW)nEndRow-(SCsROW)nStartRow) > 1 ) )
+ {
+ if ( pReqArgs )
+ {
+ const SfxStringItem& rNameItem = (const SfxStringItem&)pReqArgs->Get( SID_AUTOFORMAT );
+ ScAutoFormat* pFormat = ScGlobal::GetAutoFormat();
+ USHORT nIndex = pFormat->FindIndexPerName( rNameItem.GetValue() );
+
+ pTabViewShell->AutoFormat( nIndex );
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ else
+ {
+ ScGlobal::ClearAutoFormat();
+ ScAutoFormatData* pNewEntry = pTabViewShell->CreateAutoFormatData();
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScAutoFormatDlg* pDlg = pFact->CreateScAutoFormatDlg( pDlgParent, ScGlobal::GetAutoFormat(), pNewEntry,GetViewData()->GetDocument(), RID_SCDLG_AUTOFORMAT );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ ScEditableTester aTester( pTabViewShell );
+ if ( !aTester.IsEditable() )
+ {
+ pTabViewShell->ErrorMessage(aTester.GetMessageId());
+ }
+ else
+ {
+ pTabViewShell->AutoFormat( pDlg->GetIndex() );
+
+ rReq.AppendItem( SfxStringItem( SID_AUTOFORMAT, pDlg->GetCurrFormatName() ) );
+ rReq.Done();
+ }
+ }
+ delete pDlg;
+ delete pNewEntry;
+ }
+ }
+ else
+ ErrorBox( pDlgParent, WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString(STR_INVALID_AFAREA) ).Execute();
+ }
+ break;
+
+ case SID_CANCEL:
+ {
+ if (GetViewData()->HasEditView(GetViewData()->GetActivePart()))
+ pScMod->InputCancelHandler();
+ else if (pTabViewShell->HasPaintBrush())
+ pTabViewShell->ResetBrushDocument(); // abort format paint brush
+ else if (pTabViewShell->HasHintWindow())
+ pTabViewShell->RemoveHintWindow(); // Eingabemeldung abschalten
+ else if( ScViewUtil::IsFullScreen( *pTabViewShell ) )
+ ScViewUtil::SetFullScreen( *pTabViewShell, false );
+ else
+ {
+ // TODO/LATER: when is this code executed?
+ pTabViewShell->Escape();
+ //SfxObjectShell* pObjSh = GetViewData()->GetSfxDocShell();
+ //if (pObjSh->GetInPlaceObject() &&
+ // pObjSh->GetInPlaceObject()->GetIPClient())
+ //{
+ // GetViewData()->GetDocShell()->
+ // DoInPlaceActivate(FALSE); // OLE beenden
+ //}
+ }
+
+// SetSumAssignMode(); //ScInputWindow
+ }
+ break;
+
+ case SID_DATA_SELECT:
+ pTabViewShell->StartDataSelect();
+ break;
+
+ case SID_DETECTIVE_FILLMODE:
+ {
+ BOOL bOldMode = pTabViewShell->IsAuditShell();
+ pTabViewShell->SetAuditShell( !bOldMode );
+ pTabViewShell->Invalidate( nSlot );
+ }
+ break;
+
+ case SID_OPENDLG_CONDFRMT:
+ {
+ USHORT nId = ScCondFormatDlgWrapper::GetChildWindowId();
+ SfxViewFrame* pViewFrm = pTabViewShell->GetViewFrame();
+ SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ // ----------------------------------------------------------------
+
+ case FID_INPUTLINE_STATUS:
+ DBG_ERROR("Execute von InputLine-Status");
+ break;
+
+ case SID_STATUS_DOCPOS:
+ // Launch navigator.
+ GetViewData()->GetDispatcher().Execute(
+ SID_NAVIGATOR, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD );
+ break;
+
+ case SID_MARKAREA:
+ // called from Basic at the hidden view to select a range in the visible view
+ DBG_ERROR("old slot SID_MARKAREA");
+ break;
+
+ default:
+ DBG_ERROR("Unbekannter Slot bei ScCellShell::Execute");
+ break;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh4.cxx b/sc/source/ui/view/cellsh4.cxx
new file mode 100644
index 000000000000..894bee330330
--- /dev/null
+++ b/sc/source/ui/view/cellsh4.cxx
@@ -0,0 +1,456 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ("", off)
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/request.hxx>
+
+#include "cellsh.hxx"
+#include "tabvwsh.hxx"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+
+#include "vcl/svapp.hxx"
+
+//------------------------------------------------------------------
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+
+void ScCellShell::ExecuteCursor( SfxRequest& rReq )
+{
+ ScViewData* pData = GetViewData();
+ ScTabViewShell* pTabViewShell = pData->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlotId = rReq.GetSlot();
+ SCsCOLROW nRepeat = 1;
+ BOOL bSel = FALSE;
+ BOOL bKeep = FALSE;
+
+ if ( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ nRepeat = static_cast<SCsCOLROW>(((const SfxInt16Item*)pItem)->GetValue());
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ bSel = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+ else
+ {
+ // evaluate locked selection mode
+
+ USHORT nLocked = pTabViewShell->GetLockedModifiers();
+ if ( nLocked & KEY_SHIFT )
+ bSel = TRUE; // EXT
+ else if ( nLocked & KEY_MOD1 )
+ {
+ // ADD mode: keep the selection, start a new block when marking with shift again
+ bKeep = TRUE;
+ }
+ }
+
+ if (bSel)
+ {
+ switch (nSlotId)
+ {
+ case SID_CURSORDOWN:
+ rReq.SetSlot(SID_CURSORDOWN_SEL);
+ break;
+ case SID_CURSORUP:
+ rReq.SetSlot(SID_CURSORUP_SEL);
+ break;
+ case SID_CURSORRIGHT:
+ rReq.SetSlot(SID_CURSORRIGHT_SEL);
+ break;
+ case SID_CURSORLEFT:
+ rReq.SetSlot(SID_CURSORLEFT_SEL);
+ break;
+ case SID_CURSORPAGEDOWN:
+ rReq.SetSlot(SID_CURSORPAGEDOWN_SEL);
+ break;
+ case SID_CURSORPAGEUP:
+ rReq.SetSlot(SID_CURSORPAGEUP_SEL);
+ break;
+ case SID_CURSORPAGERIGHT:
+ rReq.SetSlot(SID_CURSORPAGERIGHT_SEL);
+ break;
+ case SID_CURSORPAGELEFT:
+ rReq.SetSlot(SID_CURSORPAGELEFT_SEL);
+ break;
+ case SID_CURSORBLKDOWN:
+ rReq.SetSlot(SID_CURSORBLKDOWN_SEL);
+ break;
+ case SID_CURSORBLKUP:
+ rReq.SetSlot(SID_CURSORBLKUP_SEL);
+ break;
+ case SID_CURSORBLKRIGHT:
+ rReq.SetSlot(SID_CURSORBLKRIGHT_SEL);
+ break;
+ case SID_CURSORBLKLEFT:
+ rReq.SetSlot(SID_CURSORBLKLEFT_SEL);
+ break;
+ default:
+ ;
+ }
+ ExecuteCursorSel(rReq);
+ return;
+ }
+
+ SCsCOLROW nRTLSign = 1;
+ if ( pData->GetDocument()->IsLayoutRTL( pData->GetTabNo() ) )
+ {
+ //! evaluate cursor movement option?
+ nRTLSign = -1;
+ }
+
+ // einmal extra, damit der Cursor bei ExecuteInputDirect nicht zuoft gemalt wird:
+ pTabViewShell->HideAllCursors();
+
+ //OS: einmal fuer alle wird doch reichen!
+ pTabViewShell->ExecuteInputDirect();
+ switch ( nSlotId )
+ {
+ case SID_CURSORDOWN:
+ pTabViewShell->MoveCursorRel( 0, nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKDOWN:
+ pTabViewShell->MoveCursorArea( 0, nRepeat, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORUP:
+ pTabViewShell->MoveCursorRel( 0, -nRepeat, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKUP:
+ pTabViewShell->MoveCursorArea( 0, -nRepeat, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORLEFT:
+ pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(-nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKLEFT:
+ pTabViewShell->MoveCursorArea( static_cast<SCsCOL>(-nRepeat * nRTLSign), 0, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORRIGHT:
+ pTabViewShell->MoveCursorRel( static_cast<SCsCOL>(nRepeat * nRTLSign), 0, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORBLKRIGHT:
+ pTabViewShell->MoveCursorArea( static_cast<SCsCOL>(nRepeat * nRTLSign), 0, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGEDOWN:
+ pTabViewShell->MoveCursorPage( 0, nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGEUP:
+ pTabViewShell->MoveCursorPage( 0, -nRepeat, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGERIGHT_: //XXX !!!
+ pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ case SID_CURSORPAGELEFT_: //XXX !!!
+ pTabViewShell->MoveCursorPage( static_cast<SCsCOL>(-nRepeat), 0, SC_FOLLOW_FIX, bSel, bKeep );
+ break;
+
+ default:
+ DBG_ERROR("Unbekannte Message bei ViewShell (Cursor)");
+ return;
+ }
+
+ pTabViewShell->ShowAllCursors();
+
+ rReq.AppendItem( SfxInt16Item(FN_PARAM_1, static_cast<sal_Int16>(nRepeat)) );
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_2, bSel) );
+ rReq.Done();
+}
+
+void ScCellShell::GetStateCursor( SfxItemSet& /* rSet */ )
+{
+}
+
+void ScCellShell::ExecuteCursorSel( SfxRequest& rReq )
+{
+ sal_uInt16 nSlotId = rReq.GetSlot();
+ ScTabViewShell* pViewShell = GetViewData()->GetViewShell();
+ ScInputHandler* pInputHdl = pViewShell->GetInputHandler();
+ pViewShell->HideAllCursors();
+ if (pInputHdl && pInputHdl->IsInputMode())
+ {
+ // the current cell is in edit mode. Commit the text before moving on.
+ pViewShell->ExecuteInputDirect();
+ }
+
+ // Horizontal direction depends on whether or not the UI language is RTL.
+ SCsCOL nMovX = 1;
+ if (GetViewData()->GetDocument()->IsLayoutRTL(GetViewData()->GetTabNo()))
+ // mirror horizontal movement for right-to-left mode.
+ nMovX = -1;
+
+ switch (nSlotId)
+ {
+ case SID_CURSORDOWN_SEL:
+ pViewShell->ExpandBlock(0, 1, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORUP_SEL:
+ pViewShell->ExpandBlock(0, -1, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORRIGHT_SEL:
+ pViewShell->ExpandBlock(nMovX, 0, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORLEFT_SEL:
+ pViewShell->ExpandBlock(-nMovX, 0, SC_FOLLOW_LINE);
+ break;
+ case SID_CURSORPAGEUP_SEL:
+ pViewShell->ExpandBlockPage(0, -1);
+ break;
+ case SID_CURSORPAGEDOWN_SEL:
+ pViewShell->ExpandBlockPage(0, 1);
+ break;
+ case SID_CURSORPAGERIGHT_SEL:
+ pViewShell->ExpandBlockPage(nMovX, 0);
+ break;
+ case SID_CURSORPAGELEFT_SEL:
+ pViewShell->ExpandBlockPage(-nMovX, 0);
+ break;
+ case SID_CURSORBLKDOWN_SEL:
+ pViewShell->ExpandBlockArea(0, 1);
+ break;
+ case SID_CURSORBLKUP_SEL:
+ pViewShell->ExpandBlockArea(0, -1);
+ break;
+ case SID_CURSORBLKRIGHT_SEL:
+ pViewShell->ExpandBlockArea(nMovX, 0);
+ break;
+ case SID_CURSORBLKLEFT_SEL:
+ pViewShell->ExpandBlockArea(-nMovX, 0);
+ break;
+ default:
+ ;
+ }
+ pViewShell->ShowAllCursors();
+}
+
+void ScCellShell::ExecuteMove( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ USHORT nSlotId = rReq.GetSlot();
+
+ if(nSlotId != SID_CURSORTOPOFSCREEN && nSlotId != SID_CURSORENDOFSCREEN)
+ pTabViewShell->ExecuteInputDirect();
+ switch ( nSlotId )
+ {
+ case SID_NEXT_TABLE:
+ case SID_NEXT_TABLE_SEL:
+ pTabViewShell->SelectNextTab( 1, (nSlotId == SID_NEXT_TABLE_SEL) );
+ break;
+
+ case SID_PREV_TABLE:
+ case SID_PREV_TABLE_SEL:
+ pTabViewShell->SelectNextTab( -1, (nSlotId == SID_PREV_TABLE_SEL) );
+ break;
+
+ // Cursorbewegungen in Bloecken gehen nicht von Basic aus,
+ // weil das ScSbxRange-Objekt bei Eingaben die Markierung veraendert
+
+ case SID_NEXT_UNPROTECT:
+ pTabViewShell->FindNextUnprot( FALSE, !rReq.IsAPI() );
+ break;
+
+ case SID_PREV_UNPROTECT:
+ pTabViewShell->FindNextUnprot( TRUE, !rReq.IsAPI() );
+ break;
+
+ case SID_CURSORENTERUP:
+ if (rReq.IsAPI())
+ pTabViewShell->MoveCursorRel( 0, -1, SC_FOLLOW_LINE, FALSE );
+ else
+ pTabViewShell->MoveCursorEnter( TRUE );
+ break;
+
+ case SID_CURSORENTERDOWN:
+ if (rReq.IsAPI())
+ pTabViewShell->MoveCursorRel( 0, 1, SC_FOLLOW_LINE, FALSE );
+ else
+ pTabViewShell->MoveCursorEnter( FALSE );
+ break;
+
+ case SID_SELECT_COL:
+ pTabViewShell->MarkColumns();
+ break;
+
+ case SID_SELECT_ROW:
+ pTabViewShell->MarkRows();
+ break;
+
+ case SID_SELECT_NONE:
+ pTabViewShell->Unmark();
+ break;
+
+ case SID_ALIGNCURSOR:
+ pTabViewShell->AlignToCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), SC_FOLLOW_JUMP );
+ break;
+
+ case SID_MARKDATAAREA:
+ pTabViewShell->MarkDataArea();
+ break;
+
+ case SID_MARKARRAYFORMULA:
+ pTabViewShell->MarkMatrixFormula();
+ break;
+
+ case SID_SETINPUTMODE:
+ SC_MOD()->SetInputMode( SC_INPUT_TABLE );
+ break;
+
+ case SID_FOCUS_INPUTLINE:
+ {
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pTabViewShell );
+ if (pHdl)
+ {
+ ScInputWindow* pWin = pHdl->GetInputWindow();
+ if (pWin)
+ pWin->SwitchToTextWin();
+ }
+ }
+ break;
+
+ case SID_CURSORTOPOFSCREEN:
+ pTabViewShell->MoveCursorScreen( 0, -1, SC_FOLLOW_LINE, FALSE );
+ break;
+
+ case SID_CURSORENDOFSCREEN:
+ pTabViewShell->MoveCursorScreen( 0, 1, SC_FOLLOW_LINE, FALSE );
+ break;
+
+ default:
+ DBG_ERROR("Unbekannte Message bei ViewShell (Cursor)");
+ return;
+ }
+
+ rReq.Done();
+}
+
+void ScCellShell::ExecutePageSel( SfxRequest& rReq )
+{
+ USHORT nSlotId = rReq.GetSlot();
+ switch ( nSlotId )
+ {
+ case SID_CURSORHOME_SEL: rReq.SetSlot( SID_CURSORHOME ); break;
+ case SID_CURSOREND_SEL: rReq.SetSlot( SID_CURSOREND ); break;
+ case SID_CURSORTOPOFFILE_SEL: rReq.SetSlot( SID_CURSORTOPOFFILE ); break;
+ case SID_CURSORENDOFFILE_SEL: rReq.SetSlot( SID_CURSORENDOFFILE ); break;
+ default:
+ DBG_ERROR("Unbekannte Message bei ViewShell (ExecutePageSel)");
+ return;
+ }
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_2, TRUE) );
+ ExecuteSlot( rReq, GetInterface() );
+}
+
+void ScCellShell::ExecutePage( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlotId = rReq.GetSlot();
+ BOOL bSel = FALSE;
+ BOOL bKeep = FALSE;
+
+ if ( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ bSel = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+ else
+ {
+ // evaluate locked selection mode
+
+ USHORT nLocked = pTabViewShell->GetLockedModifiers();
+ if ( nLocked & KEY_SHIFT )
+ bSel = TRUE; // EXT
+ else if ( nLocked & KEY_MOD1 )
+ {
+ // ADD mode: keep the selection, start a new block when marking with shift again
+ bKeep = TRUE;
+ }
+ }
+
+ pTabViewShell->ExecuteInputDirect();
+ switch ( nSlotId )
+ {
+ case SID_CURSORHOME:
+ pTabViewShell->MoveCursorEnd( -1, 0, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSOREND:
+ pTabViewShell->MoveCursorEnd( 1, 0, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ case SID_CURSORTOPOFFILE:
+ pTabViewShell->MoveCursorEnd( -1, -1, SC_FOLLOW_LINE, bSel, bKeep );
+ break;
+
+ case SID_CURSORENDOFFILE:
+ pTabViewShell->MoveCursorEnd( 1, 1, SC_FOLLOW_JUMP, bSel, bKeep );
+ break;
+
+ default:
+ DBG_ERROR("Unbekannte Message bei ViewShell (ExecutePage)");
+ return;
+ }
+
+ rReq.AppendItem( SfxBoolItem(FN_PARAM_2, bSel) );
+ rReq.Done();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/colrowba.cxx b/sc/source/ui/view/colrowba.cxx
new file mode 100644
index 000000000000..4f4bc7a4db1d
--- /dev/null
+++ b/sc/source/ui/view/colrowba.cxx
@@ -0,0 +1,419 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdtrans.hxx>
+#include <unotools/localedatawrapper.hxx>
+
+#include "colrowba.hxx"
+#include "document.hxx"
+#include "scmod.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "appoptio.hxx"
+#include "globstr.hrc"
+
+// STATIC DATA -----------------------------------------------------------
+
+//==================================================================
+
+String lcl_MetricString( long nTwips, const String& rText )
+{
+ if ( nTwips <= 0 )
+ return ScGlobal::GetRscString(STR_TIP_HIDE);
+ else
+ {
+ FieldUnit eUserMet = SC_MOD()->GetAppOptions().GetAppMetric();
+
+ sal_Int64 nUserVal = MetricField::ConvertValue( nTwips*100, 1, 2, FUNIT_TWIP, eUserMet );
+
+ String aStr = rText;
+ aStr += ' ';
+ aStr += ScGlobal::pLocaleData->getNum( nUserVal, 2 );
+ aStr += ' ';
+ aStr += SdrFormatter::GetUnitStr(eUserMet);
+
+ return aStr;
+ }
+}
+
+//==================================================================
+
+ScColBar::ScColBar( Window* pParent, ScViewData* pData, ScHSplitPos eWhichPos,
+ ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ) :
+ ScHeaderControl( pParent, pEng, MAXCOL+1, HDR_HORIZONTAL ),
+ pViewData( pData ),
+ eWhich( eWhichPos ),
+ pFuncSet( pFunc ),
+ pSelEngine( pEng )
+{
+ Show();
+}
+
+ScColBar::~ScColBar()
+{
+}
+
+inline BOOL ScColBar::UseNumericHeader() const
+{
+ return pViewData->GetDocument()->GetAddressConvention() == formula::FormulaGrammar::CONV_XL_R1C1;
+}
+
+SCCOLROW ScColBar::GetPos()
+{
+ return pViewData->GetPosX(eWhich);
+}
+
+USHORT ScColBar::GetEntrySize( SCCOLROW nEntryNo )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCCOL nLastCol = -1;
+ if (pDoc->ColHidden(static_cast<SCCOL>(nEntryNo), nTab, nLastCol))
+ return 0;
+ else
+ return (USHORT) ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), pViewData->GetPPTX() );
+}
+
+String ScColBar::GetEntryText( SCCOLROW nEntryNo )
+{
+ return UseNumericHeader()
+ ? String::CreateFromInt32( nEntryNo + 1 )
+ : ScColToAlpha( static_cast<SCCOL>(nEntryNo) );
+}
+
+void ScColBar::SetEntrySize( SCCOLROW nPos, USHORT nNewSize )
+{
+ USHORT nSizeTwips;
+ ScSizeMode eMode = SC_SIZE_DIRECT;
+ if (nNewSize>0 && nNewSize<10) nNewSize=10; // (Pixel)
+
+ if ( nNewSize == HDR_SIZE_OPTIMUM )
+ {
+ nSizeTwips = STD_EXTRA_WIDTH;
+ eMode = SC_SIZE_OPTIMAL;
+ }
+ else
+ nSizeTwips = (USHORT) ( nNewSize / pViewData->GetPPTX() );
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+// SCTAB nTab = pViewData->GetTabNo();
+
+ SCCOLROW* pRanges = new SCCOLROW[MAXCOL+1];
+ SCCOL nRangeCnt = 0;
+ if ( rMark.IsColumnMarked( static_cast<SCCOL>(nPos) ) )
+ {
+ SCCOL nStart = 0;
+ while (nStart<=MAXCOL)
+ {
+ while (nStart<MAXCOL && !rMark.IsColumnMarked(nStart))
+ ++nStart;
+ if (rMark.IsColumnMarked(nStart))
+ {
+ SCCOL nEnd = nStart;
+ while (nEnd<MAXCOL && rMark.IsColumnMarked(nEnd))
+ ++nEnd;
+ if (!rMark.IsColumnMarked(nEnd))
+ --nEnd;
+ pRanges[static_cast<size_t>(2*nRangeCnt) ] = nStart;
+ pRanges[static_cast<size_t>(2*nRangeCnt+1)] = nEnd;
+ ++nRangeCnt;
+ nStart = nEnd+1;
+ }
+ else
+ nStart = MAXCOL+1;
+ }
+ }
+ else
+ {
+ pRanges[0] = nPos;
+ pRanges[1] = nPos;
+ nRangeCnt = 1;
+ }
+
+ pViewData->GetView()->SetWidthOrHeight( TRUE, nRangeCnt, pRanges, eMode, nSizeTwips );
+ delete[] pRanges;
+}
+
+void ScColBar::HideEntries( SCCOLROW nStart, SCCOLROW nEnd )
+{
+ SCCOLROW nRange[2];
+ nRange[0] = nStart;
+ nRange[1] = nEnd;
+ pViewData->GetView()->SetWidthOrHeight( TRUE, 1, nRange, SC_SIZE_DIRECT, 0 );
+}
+
+void ScColBar::SetMarking( BOOL bSet )
+{
+ pViewData->GetMarkData().SetMarking( bSet );
+ if (!bSet)
+ {
+ pViewData->GetView()->UpdateAutoFillMark();
+ }
+}
+
+void ScColBar::SelectWindow()
+{
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ pViewSh->SetActive(); // Appear und SetViewFrame
+ pViewSh->DrawDeselectAll();
+
+ ScSplitPos eActive = pViewData->GetActivePart();
+ if (eWhich==SC_SPLIT_LEFT)
+ {
+ if (eActive==SC_SPLIT_TOPRIGHT) eActive=SC_SPLIT_TOPLEFT;
+ if (eActive==SC_SPLIT_BOTTOMRIGHT) eActive=SC_SPLIT_BOTTOMLEFT;
+ }
+ else
+ {
+ if (eActive==SC_SPLIT_TOPLEFT) eActive=SC_SPLIT_TOPRIGHT;
+ if (eActive==SC_SPLIT_BOTTOMLEFT) eActive=SC_SPLIT_BOTTOMRIGHT;
+ }
+ pViewSh->ActivatePart( eActive );
+
+ pFuncSet->SetColumn( TRUE );
+ pFuncSet->SetWhich( eActive );
+
+ pViewSh->ActiveGrabFocus();
+}
+
+BOOL ScColBar::IsDisabled()
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->IsFormulaMode() || pScMod->IsModalMode();
+}
+
+BOOL ScColBar::ResizeAllowed()
+{
+ return !pViewData->HasEditView( pViewData->GetActivePart() );
+}
+
+void ScColBar::DrawInvert( long nDragPosP )
+{
+ Rectangle aRect( nDragPosP,0, nDragPosP+HDR_SLIDERSIZE-1,GetOutputSizePixel().Width()-1 );
+ Update();
+ Invert(aRect);
+
+ pViewData->GetView()->InvertVertical(eWhich,nDragPosP);
+}
+
+String ScColBar::GetDragHelp( long nVal )
+{
+ long nTwips = (long) ( nVal / pViewData->GetPPTX() );
+ return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_WIDTH) );
+}
+
+BOOL ScColBar::IsLayoutRTL() // overloaded only for columns
+{
+ return pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+}
+
+//==================================================================
+
+ScRowBar::ScRowBar( Window* pParent, ScViewData* pData, ScVSplitPos eWhichPos,
+ ScHeaderFunctionSet* pFunc, ScHeaderSelectionEngine* pEng ) :
+ ScHeaderControl( pParent, pEng, MAXROW+1, HDR_VERTICAL ),
+ pViewData( pData ),
+ eWhich( eWhichPos ),
+ pFuncSet( pFunc ),
+ pSelEngine( pEng )
+{
+ Show();
+}
+
+ScRowBar::~ScRowBar()
+{
+}
+
+SCCOLROW ScRowBar::GetPos()
+{
+ return pViewData->GetPosY(eWhich);
+}
+
+USHORT ScRowBar::GetEntrySize( SCCOLROW nEntryNo )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCROW nLastRow = -1;
+ if (pDoc->RowHidden(nEntryNo, nTab, nLastRow))
+ return 0;
+ else
+ return (USHORT) ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo,
+ nTab ), pViewData->GetPPTY() );
+}
+
+String ScRowBar::GetEntryText( SCCOLROW nEntryNo )
+{
+ return String::CreateFromInt32( nEntryNo + 1 );
+}
+
+void ScRowBar::SetEntrySize( SCCOLROW nPos, USHORT nNewSize )
+{
+ USHORT nSizeTwips;
+ ScSizeMode eMode = SC_SIZE_DIRECT;
+ if (nNewSize>0 && nNewSize<10) nNewSize=10; // (Pixel)
+
+ if ( nNewSize == HDR_SIZE_OPTIMUM )
+ {
+ nSizeTwips = 0;
+ eMode = SC_SIZE_OPTIMAL;
+ }
+ else
+ nSizeTwips = (USHORT) ( nNewSize / pViewData->GetPPTY() );
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+// SCTAB nTab = pViewData->GetTabNo();
+
+ SCCOLROW* pRanges = new SCCOLROW[MAXROW+1];
+ SCROW nRangeCnt = 0;
+ if ( rMark.IsRowMarked( nPos ) )
+ {
+ SCROW nStart = 0;
+ while (nStart<=MAXROW)
+ {
+ while (nStart<MAXROW && !rMark.IsRowMarked(nStart))
+ ++nStart;
+ if (rMark.IsRowMarked(nStart))
+ {
+ SCROW nEnd = nStart;
+ while (nEnd<MAXROW && rMark.IsRowMarked(nEnd))
+ ++nEnd;
+ if (!rMark.IsRowMarked(nEnd))
+ --nEnd;
+ pRanges[static_cast<size_t>(2*nRangeCnt) ] = nStart;
+ pRanges[static_cast<size_t>(2*nRangeCnt+1)] = nEnd;
+ ++nRangeCnt;
+ nStart = nEnd+1;
+ }
+ else
+ nStart = MAXROW+1;
+ }
+ }
+ else
+ {
+ pRanges[0] = nPos;
+ pRanges[1] = nPos;
+ nRangeCnt = 1;
+ }
+
+ pViewData->GetView()->SetWidthOrHeight( FALSE, nRangeCnt, pRanges, eMode, nSizeTwips );
+ delete[] pRanges;
+}
+
+void ScRowBar::HideEntries( SCCOLROW nStart, SCCOLROW nEnd )
+{
+ SCCOLROW nRange[2];
+ nRange[0] = nStart;
+ nRange[1] = nEnd;
+ pViewData->GetView()->SetWidthOrHeight( FALSE, 1, nRange, SC_SIZE_DIRECT, 0 );
+}
+
+void ScRowBar::SetMarking( BOOL bSet )
+{
+ pViewData->GetMarkData().SetMarking( bSet );
+ if (!bSet)
+ {
+ pViewData->GetView()->UpdateAutoFillMark();
+ }
+}
+
+void ScRowBar::SelectWindow()
+{
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ pViewSh->SetActive(); // Appear und SetViewFrame
+ pViewSh->DrawDeselectAll();
+
+ ScSplitPos eActive = pViewData->GetActivePart();
+ if (eWhich==SC_SPLIT_TOP)
+ {
+ if (eActive==SC_SPLIT_BOTTOMLEFT) eActive=SC_SPLIT_TOPLEFT;
+ if (eActive==SC_SPLIT_BOTTOMRIGHT) eActive=SC_SPLIT_TOPRIGHT;
+ }
+ else
+ {
+ if (eActive==SC_SPLIT_TOPLEFT) eActive=SC_SPLIT_BOTTOMLEFT;
+ if (eActive==SC_SPLIT_TOPRIGHT) eActive=SC_SPLIT_BOTTOMRIGHT;
+ }
+ pViewSh->ActivatePart( eActive );
+
+ pFuncSet->SetColumn( FALSE );
+ pFuncSet->SetWhich( eActive );
+
+ pViewSh->ActiveGrabFocus();
+}
+
+BOOL ScRowBar::IsDisabled()
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->IsFormulaMode() || pScMod->IsModalMode();
+}
+
+BOOL ScRowBar::ResizeAllowed()
+{
+ return !pViewData->HasEditView( pViewData->GetActivePart() );
+}
+
+void ScRowBar::DrawInvert( long nDragPosP )
+{
+ Rectangle aRect( 0,nDragPosP, GetOutputSizePixel().Width()-1,nDragPosP+HDR_SLIDERSIZE-1 );
+ Update();
+ Invert(aRect);
+
+ pViewData->GetView()->InvertHorizontal(eWhich,nDragPosP);
+}
+
+String ScRowBar::GetDragHelp( long nVal )
+{
+ long nTwips = (long) ( nVal / pViewData->GetPPTY() );
+ return lcl_MetricString( nTwips, ScGlobal::GetRscString(STR_TIP_HEIGHT) );
+}
+
+// GetHiddenCount ist nur fuer Zeilen ueberladen
+
+SCROW ScRowBar::GetHiddenCount( SCROW nEntryNo )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ return pDoc->GetHiddenRowCount( nEntryNo, nTab );
+}
+
+BOOL ScRowBar::IsMirrored() // overloaded only for rows
+{
+ return pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
new file mode 100644
index 000000000000..f9e854e3467d
--- /dev/null
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -0,0 +1,515 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/msgbox.hxx>
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+#include "dbfunc.hxx"
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "sc.hrc"
+#include "undodat.hxx"
+#include "dbcolect.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "dbdocfun.hxx"
+#include "editable.hxx"
+
+//==================================================================
+
+ScDBFunc::ScDBFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
+ ScViewFunc( pParent, rDocSh, pViewShell )
+{
+}
+
+ScDBFunc::~ScDBFunc()
+{
+}
+
+//
+// Hilfsfunktionen
+//
+
+void ScDBFunc::GotoDBArea( const String& rDBName )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBCollection* pDBCol = pDoc->GetDBCollection();
+
+ USHORT nFoundAt = 0;
+ if ( pDBCol->SearchName( rDBName, nFoundAt ) )
+ {
+ ScDBData* pData = (*pDBCol)[nFoundAt];
+ DBG_ASSERT( pData, "GotoDBArea: Datenbankbereich nicht gefunden!" );
+
+ if ( pData )
+ {
+ SCTAB nTab = 0;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+
+ pData->GetArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ SetTabNo( nTab );
+
+ MoveCursorAbs( nStartCol, nStartRow, ScFollowMode( SC_FOLLOW_JUMP ),
+ FALSE, FALSE ); // bShift,bControl
+ DoneBlockMode();
+ InitBlockMode( nStartCol, nStartRow, nTab );
+ MarkCursor( nEndCol, nEndRow, nTab );
+ SelectionChanged();
+ }
+ }
+}
+
+// aktuellen Datenbereich fuer Sortieren / Filtern suchen
+
+ScDBData* ScDBFunc::GetDBData( BOOL bMark, ScGetDBMode eMode, ScGetDBSelection eSel, bool /*bShrinkToData*/, bool bExpandRows )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDBData* pData = NULL;
+ ScRange aRange;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea(aRange);
+ if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
+ {
+ bool bShrinkColumnsOnly = false;
+ if (eSel == SC_DBSEL_ROW_DOWN)
+ {
+ // Don't alter row range, additional rows may have been selected on
+ // purpose to append data, or to have a fake header row.
+ bShrinkColumnsOnly = true;
+ // Select further rows only if only one row or a portion thereof is
+ // selected.
+ if (aRange.aStart.Row() != aRange.aEnd.Row())
+ {
+ // If an area is selected shrink that to the actual used
+ // columns, don't draw filter buttons for empty columns.
+ eSel = SC_DBSEL_SHRINK_TO_USED_DATA;
+ }
+ else if (aRange.aStart.Col() == aRange.aEnd.Col())
+ {
+ // One cell only, if it is not marked obtain entire used data
+ // area.
+ const ScMarkData& rMarkData = GetViewData()->GetMarkData();
+ if (!(rMarkData.IsMarked() || rMarkData.IsMultiMarked()))
+ eSel = SC_DBSEL_KEEP;
+ }
+ }
+ switch (eSel)
+ {
+ case SC_DBSEL_SHRINK_TO_SHEET_DATA:
+ {
+ // Shrink the selection to sheet data area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ case SC_DBSEL_SHRINK_TO_USED_DATA:
+ case SC_DBSEL_ROW_DOWN:
+ {
+ // Shrink the selection to actual used area.
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
+ if (pDoc->ShrinkToUsedDataArea( aRange.aStart.Tab(), nCol1, nRow1, nCol2, nRow2, bShrinkColumnsOnly))
+ {
+ aRange.aStart.SetCol(nCol1);
+ aRange.aEnd.SetCol(nCol2);
+ aRange.aStart.SetRow(nRow1);
+ aRange.aEnd.SetRow(nRow2);
+ }
+ }
+ break;
+ default:
+ ; // nothing
+ }
+ pData = pDocSh->GetDBData( aRange, eMode, eSel );
+ }
+ else if ( eMode != SC_DB_OLD )
+ pData = pDocSh->GetDBData(
+ ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() ),
+ eMode, SC_DBSEL_KEEP );
+
+ if (!pData)
+ return NULL;
+
+ if (bExpandRows)
+ {
+ // Dynamically expand rows to include any new data rows that are
+ // immediately below the original range.
+ GetViewData()->GetDocument()->UpdateDynamicEndRow(*pData);
+ }
+ if (bMark)
+ {
+ ScRange aFound;
+ pData->GetArea(aFound, bExpandRows);
+ MarkRange( aFound, FALSE );
+ }
+ return pData;
+}
+
+// Datenbankbereiche aendern (Dialog)
+
+void ScDBFunc::NotifyCloseDbNameDlg( const ScDBCollection& rNewColl, const List& rDelAreaList )
+{
+
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocShell );
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDBCollection* pOldColl = pDoc->GetDBCollection();
+ ScDBCollection* pUndoColl = NULL;
+ ScDBCollection* pRedoColl = NULL;
+ const BOOL bRecord (pDoc->IsUndoEnabled());
+
+ long nDelCount = rDelAreaList.Count();
+ for (long nDelPos=0; nDelPos<nDelCount; nDelPos++)
+ {
+ ScRange* pEntry = (ScRange*) rDelAreaList.GetObject(nDelPos);
+
+ if ( pEntry )
+ {
+ ScAddress& rStart = pEntry->aStart;
+ ScAddress& rEnd = pEntry->aEnd;
+ pDocShell->DBAreaDeleted( rStart.Tab(),
+ rStart.Col(), rStart.Row(),
+ rEnd.Col(), rEnd.Row() );
+
+ // Targets am SBA abmelden nicht mehr noetig
+ }
+ }
+
+ if (bRecord)
+ pUndoColl = new ScDBCollection( *pOldColl );
+
+ // neue Targets am SBA anmelden nicht mehr noetig
+
+ pDoc->CompileDBFormula( TRUE ); // CreateFormulaString
+ pDoc->SetDBCollection( new ScDBCollection( rNewColl ) );
+ pDoc->CompileDBFormula( FALSE ); // CompileFormulaString
+ pOldColl = NULL;
+ pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID );
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+
+ if (bRecord)
+ {
+ pRedoColl = new ScDBCollection( rNewColl );
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoDBData( pDocShell, pUndoColl, pRedoColl ) );
+ }
+}
+
+//
+// wirkliche Funktionen
+//
+
+// Sortieren
+
+void ScDBFunc::UISort( const ScSortParam& rSortParam, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rSortParam.nCol1, rSortParam.nRow1,
+ rSortParam.nCol2, rSortParam.nRow2 );
+ if (!pDBData)
+ {
+ DBG_ERROR( "Sort: keine DBData" );
+ return;
+ }
+
+ ScSubTotalParam aSubTotalParam;
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ if (aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly)
+ {
+ // Subtotals wiederholen, mit neuer Sortierung
+
+ DoSubTotals( aSubTotalParam, bRecord, &rSortParam );
+ }
+ else
+ {
+ Sort( rSortParam, bRecord ); // nur sortieren
+ }
+}
+
+void ScDBFunc::Sort( const ScSortParam& rSortParam, BOOL bRecord, BOOL bPaint )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDBDocFunc aDBDocFunc( *pDocSh );
+ BOOL bSuccess = aDBDocFunc.Sort( nTab, rSortParam, bRecord, bPaint, FALSE );
+ if ( bSuccess && !rSortParam.bInplace )
+ {
+ // Ziel markieren
+ ScRange aDestRange( rSortParam.nDestCol, rSortParam.nDestRow, rSortParam.nDestTab,
+ rSortParam.nDestCol + rSortParam.nCol2 - rSortParam.nCol1,
+ rSortParam.nDestRow + rSortParam.nRow2 - rSortParam.nRow1,
+ rSortParam.nDestTab );
+ MarkRange( aDestRange );
+ }
+}
+
+// Filtern
+
+void ScDBFunc::Query( const ScQueryParam& rQueryParam, const ScRange* pAdvSource, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDBDocFunc aDBDocFunc( *pDocSh );
+ BOOL bSuccess = aDBDocFunc.Query( nTab, rQueryParam, pAdvSource, bRecord, FALSE );
+
+ if (bSuccess)
+ {
+ BOOL bCopy = !rQueryParam.bInplace;
+ if (bCopy)
+ {
+ // Zielbereich markieren (DB-Bereich wurde ggf. angelegt)
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDBData* pDestData = pDoc->GetDBAtCursor(
+ rQueryParam.nDestCol, rQueryParam.nDestRow,
+ rQueryParam.nDestTab, TRUE );
+ if (pDestData)
+ {
+ ScRange aDestRange;
+ pDestData->GetArea(aDestRange);
+ MarkRange( aDestRange );
+ }
+ }
+
+ if (!bCopy)
+ {
+ UpdateScrollBars();
+ SelectionChanged(); // for attribute states (filtered rows are ignored)
+ }
+
+ GetViewData()->GetBindings().Invalidate( SID_UNFILTER );
+ }
+}
+
+// Autofilter-Knoepfe ein-/ausblenden
+
+void ScDBFunc::ToggleAutoFilter()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScQueryParam aParam;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBData* pDBData = GetDBData(false, SC_DB_MAKE, SC_DBSEL_ROW_DOWN, false, true);
+
+ pDBData->SetByRow( TRUE ); //! Undo, vorher abfragen ??
+ pDBData->GetQueryParam( aParam );
+
+
+ SCCOL nCol;
+ SCROW nRow = aParam.nRow1;
+ SCTAB nTab = GetViewData()->GetTabNo();
+ INT16 nFlag;
+ BOOL bHasAuto = TRUE;
+ BOOL bHeader = pDBData->HasHeader();
+ BOOL bPaint = FALSE;
+
+ //! stattdessen aus DB-Bereich abfragen?
+
+ for (nCol=aParam.nCol1; nCol<=aParam.nCol2 && bHasAuto; nCol++)
+ {
+ nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+
+ if ( (nFlag & SC_MF_AUTO) == 0 )
+ bHasAuto = FALSE;
+ }
+
+ if (bHasAuto) // aufheben
+ {
+ // Filterknoepfe ausblenden
+
+ for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
+ {
+ nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
+ }
+
+ // use a list action for the AutoFilter buttons (ScUndoAutoFilter) and the filter operation
+
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_QUERY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), FALSE ) );
+
+ pDBData->SetAutoFilter(FALSE);
+
+ // Filter aufheben (incl. Paint / Undo)
+
+ SCSIZE nEC = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ aParam.GetEntry(i).bDoQuery = FALSE;
+ aParam.bDuplicate = TRUE;
+ Query( aParam, NULL, TRUE );
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+
+ bPaint = TRUE;
+ }
+ else // Filterknoepfe einblenden
+ {
+ if ( !pDoc->IsBlockEmpty( nTab,
+ aParam.nCol1, aParam.nRow1,
+ aParam.nCol2, aParam.nRow2 ) )
+ {
+ if (!bHeader)
+ {
+ if ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), // "StarCalc"
+ ScGlobal::GetRscString( STR_MSSG_MAKEAUTOFILTER_0 ) // Koepfe aus erster Zeile?
+ ).Execute() == RET_YES )
+ {
+ pDBData->SetHeader( TRUE ); //! Undo ??
+ bHeader = TRUE;
+ }
+ }
+
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), TRUE ) );
+
+ pDBData->SetAutoFilter(TRUE);
+
+ for (nCol=aParam.nCol1; nCol<=aParam.nCol2; nCol++)
+ {
+ nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow, nTab, ScMergeFlagAttr( nFlag | SC_MF_AUTO ) );
+ }
+ pDocSh->PostPaint( aParam.nCol1, nRow, nTab, aParam.nCol2, nRow, nTab,
+ PAINT_GRID );
+ bPaint = TRUE;
+ }
+ else
+ {
+ ErrorBox aErrorBox( GetViewData()->GetDialogParent(), WinBits( WB_OK | WB_DEF_OK ),
+ ScGlobal::GetRscString( STR_ERR_AUTOFILTER ) );
+ aErrorBox.Execute();
+ }
+ }
+
+ if ( bPaint )
+ {
+ aModificator.SetDocumentModified();
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_AUTO_FILTER );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+ }
+}
+
+// nur ausblenden, keine Daten veraendern
+
+void ScDBFunc::HideAutoFilter()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ ScQueryParam aParam;
+ ScDBData* pDBData = GetDBData( FALSE );
+
+ SCTAB nTab;
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ pDBData->GetArea(nTab, nCol1, nRow1, nCol2, nRow2);
+
+ for (SCCOL nCol=nCol1; nCol<=nCol2; nCol++)
+ {
+ INT16 nFlag = ((ScMergeFlagAttr*) pDoc->
+ GetAttr( nCol, nRow1, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ pDoc->ApplyAttr( nCol, nRow1, nTab, ScMergeFlagAttr( nFlag & ~SC_MF_AUTO ) );
+ }
+
+ ScRange aRange;
+ pDBData->GetArea( aRange );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFilter( pDocSh, aRange, pDBData->GetName(), FALSE ) );
+
+ pDBData->SetAutoFilter(FALSE);
+
+ pDocSh->PostPaint( nCol1,nRow1,nTab, nCol2,nRow1,nTab, PAINT_GRID );
+ aModificator.SetDocumentModified();
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_AUTO_FILTER );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+}
+
+// Re-Import
+
+BOOL ScDBFunc::ImportData( const ScImportParam& rParam, BOOL bRecord )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScEditableTester aTester( pDoc, GetViewData()->GetTabNo(), rParam.nCol1,rParam.nRow1,
+ rParam.nCol2,rParam.nRow2 );
+ if ( !aTester.IsEditable() )
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ ScDBDocFunc aDBDocFunc( *GetViewData()->GetDocShell() );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xResultSet;
+ return aDBDocFunc.DoImport( GetViewData()->GetTabNo(), rParam, xResultSet, NULL, bRecord );
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc2.cxx b/sc/source/ui/view/dbfunc2.cxx
new file mode 100644
index 000000000000..15e5f20c7ac4
--- /dev/null
+++ b/sc/source/ui/view/dbfunc2.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+
+#include "dbfunc.hxx"
+#include "docsh.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+
+
+// STATIC DATA -----------------------------------------------------------
+
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+//==================================================================
+
+class ScDrawLayer;
+class ScChartCollection;
+
+void ScDBFunc::UpdateCharts( BOOL bAllCharts )
+{
+ USHORT nFound = 0;
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ if ( pDoc->GetDrawLayer() )
+ nFound = DoUpdateCharts( ScAddress( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo()),
+ pDoc,
+ bAllCharts );
+
+ if ( !nFound && !bAllCharts )
+ ErrorMessage(STR_NOCHARTATCURSOR);
+}
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
new file mode 100644
index 000000000000..7381e3599561
--- /dev/null
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -0,0 +1,2374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "dbfunc.hxx"
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/waitobj.hxx>
+#include <svl/zforlist.hxx>
+#include <sfx2/app.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
+#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
+#include <com/sun/star/sheet/GeneralFunction.hpp>
+#include <com/sun/star/sheet/MemberResultFlags.hpp>
+#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
+#include <com/sun/star/sheet/XDrillDownDataSupplier.hpp>
+
+#include "global.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+#include "undotab.hxx"
+#include "undodat.hxx"
+#include "dbcolect.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "docsh.hxx"
+#include "olinetab.hxx"
+#include "consoli.hxx"
+#include "olinefun.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpdimsave.hxx"
+#include "dbdocfun.hxx"
+#include "dpoutput.hxx"
+#include "dptabsrc.hxx"
+#include "editable.hxx"
+#include "docpool.hxx"
+#include "patattr.hxx"
+#include "unonames.hxx"
+#include "cell.hxx"
+#include "userlist.hxx"
+
+#include <hash_set>
+#include <hash_map>
+#include <memory>
+#include <list>
+#include <vector>
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::beans::XPropertySet;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::sheet::XDimensionsSupplier;
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+using ::rtl::OUStringBuffer;
+using ::std::auto_ptr;
+using ::std::list;
+using ::std::vector;
+using ::std::hash_map;
+using ::std::hash_set;
+
+// STATIC DATA -----------------------------------------------------------
+
+
+//==================================================================
+
+//
+// Outliner
+//
+
+// Outline-Gruppierung erzeugen
+
+void ScDBFunc::MakeOutline( BOOL bColumns, BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.MakeOutline( aRange, bColumns, bRecord, FALSE );
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// Outline-Gruppierung loeschen
+
+void ScDBFunc::RemoveOutline( BOOL bColumns, BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.RemoveOutline( aRange, bColumns, bRecord, FALSE );
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// Menue-Status: Outlines loeschen
+
+void ScDBFunc::TestRemoveOutline( BOOL& rCol, BOOL& rRow )
+{
+ BOOL bColFound = FALSE;
+ BOOL bRowFound = FALSE;
+
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ SCTAB nStartTab, nEndTab;
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ {
+ SCTAB nTab = nStartTab;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ ScOutlineArray* pArray;
+ ScOutlineEntry* pEntry;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+ BOOL bColMarked = ( nStartRow == 0 && nEndRow == MAXROW );
+ BOOL bRowMarked = ( nStartCol == 0 && nEndCol == MAXCOL );
+
+ // Spalten
+
+ if ( !bRowMarked || bColMarked ) // nicht wenn ganze Zeilen markiert
+ {
+ pArray = pTable->GetColArray();
+ ScSubOutlineIterator aColIter( pArray );
+ while ((pEntry=aColIter.GetNext()) != NULL && !bColFound)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( nStartCol<=static_cast<SCCOL>(nEnd) && nEndCol>=static_cast<SCCOL>(nStart) )
+ bColFound = TRUE;
+ }
+ }
+
+ // Zeilen
+
+ if ( !bColMarked || bRowMarked ) // nicht wenn ganze Spalten markiert
+ {
+ pArray = pTable->GetRowArray();
+ ScSubOutlineIterator aRowIter( pArray );
+ while ((pEntry=aRowIter.GetNext()) != NULL && !bRowFound)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( nStartRow<=nEnd && nEndRow>=nStart )
+ bRowFound = TRUE;
+ }
+ }
+ }
+ }
+
+ rCol = bColFound;
+ rRow = bRowFound;
+}
+
+void ScDBFunc::RemoveAllOutlines( BOOL bRecord )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ BOOL bOk = aFunc.RemoveAllOutlines( nTab, bRecord, FALSE );
+ ShowCursor();
+
+ if (bOk)
+ UpdateScrollBars();
+}
+
+// Auto-Outlines
+
+void ScDBFunc::AutoOutline( BOOL bRecord )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScRange aRange( 0,0,nTab, MAXCOL,MAXROW,nTab ); // ganze Tabelle, wenn nichts markiert
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ rMark.MarkToMulti();
+ rMark.GetMultiMarkArea( aRange );
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ aFunc.AutoOutline( aRange, bRecord, FALSE );
+}
+
+// Outline-Ebene auswaehlen
+
+void ScDBFunc::SelectLevel( BOOL bColumns, USHORT nLevel, BOOL bRecord, BOOL bPaint )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ BOOL bOk = aFunc.SelectLevel( nTab, bColumns, nLevel, bRecord, bPaint, FALSE );
+ ShowCursor();
+
+ if (bOk)
+ UpdateScrollBars();
+}
+
+// einzelne Outline-Gruppe einblenden
+
+void ScDBFunc::ShowOutline( BOOL bColumns, USHORT nLevel, USHORT nEntry, BOOL bRecord, BOOL bPaint )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ BOOL bOk = aFunc.ShowOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint, FALSE );
+ ShowCursor();
+
+ if ( bOk && bPaint )
+ UpdateScrollBars();
+}
+
+// einzelne Outline-Gruppe ausblenden
+
+void ScDBFunc::HideOutline( BOOL bColumns, USHORT nLevel, USHORT nEntry, BOOL bRecord, BOOL bPaint )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+
+ HideCursor();
+ BOOL bOk = aFunc.HideOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint, FALSE );
+ ShowCursor();
+
+ if ( bOk && bPaint )
+ UpdateScrollBars();
+}
+
+// Menue-Status: markierten Bereich ein-/ausblenden
+
+BOOL ScDBFunc::OutlinePossible(BOOL bHide)
+{
+ BOOL bEnable = FALSE;
+
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ ScOutlineArray* pArray;
+ ScOutlineEntry* pEntry;
+ SCCOLROW nStart;
+ SCCOLROW nEnd;
+
+ // Spalten
+
+ pArray = pTable->GetColArray();
+ ScSubOutlineIterator aColIter( pArray );
+ while ((pEntry=aColIter.GetNext()) != NULL && !bEnable)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( bHide )
+ {
+ if ( nStartCol<=static_cast<SCCOL>(nEnd) && nEndCol>=static_cast<SCCOL>(nStart) )
+ if (!pEntry->IsHidden())
+ bEnable = TRUE;
+ }
+ else
+ {
+ if ( nStart>=nStartCol && nEnd<=nEndCol )
+ if (pEntry->IsHidden())
+ bEnable = TRUE;
+ }
+ }
+
+ // Zeilen
+
+ pArray = pTable->GetRowArray();
+ ScSubOutlineIterator aRowIter( pArray );
+ while ((pEntry=aRowIter.GetNext()) != NULL)
+ {
+ nStart = pEntry->GetStart();
+ nEnd = pEntry->GetEnd();
+ if ( bHide )
+ {
+ if ( nStartRow<=nEnd && nEndRow>=nStart )
+ if (!pEntry->IsHidden())
+ bEnable = TRUE;
+ }
+ else
+ {
+ if ( nStart>=nStartRow && nEnd<=nEndRow )
+ if (pEntry->IsHidden())
+ bEnable = TRUE;
+ }
+ }
+ }
+ }
+
+ return bEnable;
+}
+
+// markierten Bereich einblenden
+
+void ScDBFunc::ShowMarkedOutlines( BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ HideCursor();
+ BOOL bDone = aFunc.ShowMarkedOutlines( aRange, bRecord, FALSE );
+ ShowCursor();
+ if (bDone)
+ UpdateScrollBars();
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// markierten Bereich ausblenden
+
+void ScDBFunc::HideMarkedOutlines( BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScOutlineDocFunc aFunc(*pDocSh);
+ HideCursor();
+ BOOL bDone = aFunc.HideMarkedOutlines( aRange, bRecord, FALSE );
+ ShowCursor();
+ if (bDone)
+ UpdateScrollBars();
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+// --------------------------------------------------------------------------
+
+//
+// Teilergebnisse
+//
+
+void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, BOOL bRecord,
+ const ScSortParam* pForceNewSort )
+{
+ BOOL bDo = !rParam.bRemoveOnly; // FALSE = nur loeschen
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDBData* pDBData = pDoc->GetDBAtArea( nTab, rParam.nCol1, rParam.nRow1,
+ rParam.nCol2, rParam.nRow2 );
+ if (!pDBData)
+ {
+ DBG_ERROR( "SubTotals: keine DBData" );
+ return;
+ }
+
+ ScEditableTester aTester( pDoc, nTab, 0,rParam.nRow1+1, MAXCOL,MAXROW );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ if (pDoc->HasAttrib( rParam.nCol1, rParam.nRow1+1, nTab,
+ rParam.nCol2, rParam.nRow2, nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ {
+ ErrorMessage(STR_MSSG_INSERTCELLS_0); // nicht in zusammengefasste einfuegen
+ return;
+ }
+
+ WaitObject aWait( GetViewData()->GetDialogParent() );
+ BOOL bOk = TRUE;
+ BOOL bDelete = FALSE;
+ if (rParam.bReplace)
+ if (pDoc->TestRemoveSubTotals( nTab, rParam ))
+ {
+ bDelete = TRUE;
+ bOk = ( MessBox( GetViewData()->GetDialogParent(), WinBits(WB_YES_NO | WB_DEF_YES),
+ // "StarCalc" "Daten loeschen?"
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_1 ) ).Execute()
+ == RET_YES );
+ }
+
+ if (bOk)
+ {
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScSubTotalParam aNewParam( rParam ); // Bereichsende wird veraendert
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ ScRangeName* pUndoRange = NULL;
+ ScDBCollection* pUndoDB = NULL;
+ SCTAB nTabCount = 0; // fuer Referenz-Undo
+
+ if (bRecord) // alte Daten sichern
+ {
+ BOOL bOldFilter = bDo && rParam.bDoSort;
+
+ nTabCount = pDoc->GetTableCount();
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ SCCOLROW nOutStartCol; // Zeilen/Spaltenstatus
+ SCCOLROW nOutStartRow;
+ SCCOLROW nOutEndCol;
+ SCCOLROW nOutEndRow;
+ pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol );
+ pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow );
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, bOldFilter );
+
+ // Datenbereich sichern - incl. Filter-Ergebnis
+ pDoc->CopyToDocument( 0,rParam.nRow1+1,nTab, MAXCOL,rParam.nRow2,nTab,
+ IDF_ALL, FALSE, pUndoDoc );
+
+ // alle Formeln wegen Referenzen
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
+ IDF_FORMULA, FALSE, pUndoDoc );
+
+ // DB- und andere Bereiche
+ ScRangeName* pDocRange = pDoc->GetRangeName();
+ if (pDocRange->GetCount())
+ pUndoRange = new ScRangeName( *pDocRange );
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+ }
+
+// pDoc->SetOutlineTable( nTab, NULL );
+ ScOutlineTable* pOut = pDoc->GetOutlineTable( nTab );
+ if (pOut)
+ pOut->GetRowArray()->RemoveAll(); // nur Zeilen-Outlines loeschen
+
+ if (rParam.bReplace)
+ pDoc->RemoveSubTotals( nTab, aNewParam );
+ BOOL bSuccess = TRUE;
+ if (bDo)
+ {
+ // Sortieren
+ if ( rParam.bDoSort || pForceNewSort )
+ {
+ pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+
+ // Teilergebnis-Felder vor die Sortierung setzen
+ // (doppelte werden weggelassen, kann darum auch wieder aufgerufen werden)
+
+ ScSortParam aOldSort;
+ pDBData->GetSortParam( aOldSort );
+ ScSortParam aSortParam( aNewParam, pForceNewSort ? *pForceNewSort : aOldSort );
+ Sort( aSortParam, FALSE, FALSE );
+ }
+
+ bSuccess = pDoc->DoSubTotals( nTab, aNewParam );
+ }
+ ScRange aDirtyRange( aNewParam.nCol1, aNewParam.nRow1, nTab,
+ aNewParam.nCol2, aNewParam.nRow2, nTab );
+ pDoc->SetDirty( aDirtyRange );
+
+ if (bRecord)
+ {
+// ScDBData* pUndoDBData = pDBData ? new ScDBData( *pDBData ) : NULL;
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoSubTotals( pDocSh, nTab,
+ rParam, aNewParam.nRow2,
+ pUndoDoc, pUndoTab, // pUndoDBData,
+ pUndoRange, pUndoDB ) );
+ }
+
+ if (!bSuccess)
+ {
+ // "Kann keine Zeilen einfuegen"
+ ErrorMessage(STR_MSSG_DOSUBTOTALS_2);
+ }
+
+ // merken
+ pDBData->SetSubTotalParam( aNewParam );
+ pDBData->SetArea( nTab, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
+ pDoc->CompileDBFormula();
+
+ DoneBlockMode();
+ InitOwnBlockMode();
+ rMark.SetMarkArea( ScRange( aNewParam.nCol1,aNewParam.nRow1,nTab,
+ aNewParam.nCol2,aNewParam.nRow2,nTab ) );
+ MarkDataChanged();
+
+ pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+
+ aModificator.SetDocumentModified();
+
+ SelectionChanged();
+ }
+}
+
+//
+// Consolidate
+//
+
+void ScDBFunc::Consolidate( const ScConsolidateParam& rParam, BOOL bRecord )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ pDocShell->DoConsolidate( rParam, bRecord );
+ SetTabNo( rParam.nTab, TRUE );
+}
+
+//
+// Pivot
+//
+
+String lcl_MakePivotTabName( const String& rPrefix, SCTAB nNumber )
+{
+ String aName = rPrefix;
+ aName += String::CreateFromInt32( nNumber );
+ return aName;
+}
+
+bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, BOOL bNewTable,
+ const ScDPObject& rSource, BOOL bApi )
+{
+ // #70096# error message if no fields are set
+ // this must be removed when drag&drop of fields from a toolbox is available
+
+ if ( rData.IsEmpty() && !bApi )
+ {
+ ErrorMessage(STR_PIVOT_NODATA);
+ return false;
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ ScRange aDestRange = rDest;
+ if ( bNewTable )
+ {
+ SCTAB nSrcTab = GetViewData()->GetTabNo();
+
+ String aName( ScGlobal::GetRscString(STR_PIVOT_TABLE) );
+ String aStr;
+
+ pDoc->GetName( nSrcTab, aStr );
+ aName += '_';
+ aName += aStr;
+ aName += '_';
+
+ SCTAB nNewTab = nSrcTab+1;
+
+ SCTAB i=1;
+ while ( !pDoc->InsertTab( nNewTab, lcl_MakePivotTabName( aName, i ) ) && i <= MAXTAB )
+ i++;
+
+ BOOL bAppend = ( nNewTab+1 == pDoc->GetTableCount() );
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( pDocSh, nNewTab, bAppend, lcl_MakePivotTabName( aName, i ) ));
+ }
+
+ GetViewData()->InsertTab( nNewTab );
+ SetTabNo( nNewTab, TRUE );
+
+ aDestRange = ScRange( 0, 0, nNewTab );
+ }
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(
+ aDestRange.aStart.Col(), aDestRange.aStart.Row(), aDestRange.aStart.Tab() );
+
+ ScDPObject aObj( rSource );
+ aObj.SetOutRange( aDestRange );
+ if ( pDPObj && !rData.GetExistingDimensionData() )
+ {
+ // copy dimension data from old object - lost in the dialog
+ //! change the dialog to keep the dimension data
+
+ ScDPSaveData aNewData( rData );
+ const ScDPSaveData* pOldData = pDPObj->GetSaveData();
+ if ( pOldData )
+ {
+ const ScDPDimensionSaveData* pDimSave = pOldData->GetExistingDimensionData();
+ aNewData.SetDimensionData( pDimSave );
+ }
+ aObj.SetSaveData( aNewData );
+ }
+ else
+ aObj.SetSaveData( rData );
+
+ BOOL bAllowMove = ( pDPObj != NULL ); // allow re-positioning when editing existing table
+
+ ScDBDocFunc aFunc( *pDocSh );
+ bool bSuccess = aFunc.DataPilotUpdate( pDPObj, &aObj, TRUE, FALSE, bAllowMove );
+
+ CursorPosChanged(); // shells may be switched
+
+ if ( bNewTable )
+ {
+ pDocSh->PostPaintExtras();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ }
+
+ return bSuccess;
+}
+
+void ScDBFunc::DeletePivotTable()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScDBDocFunc aFunc( *pDocSh );
+ aFunc.DataPilotUpdate( pDPObj, NULL, TRUE, FALSE );
+ CursorPosChanged(); // shells may be switched
+ }
+ else
+ ErrorMessage(STR_PIVOT_NOTFOUND);
+}
+ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh, BOOL bRecord, BOOL bApi )
+{
+ if( !pDPObj )
+ return STR_PIVOT_NOTFOUND;
+
+ if ( pDocSh && !pDoc )
+ pDoc = pDocSh->GetDocument();
+
+ if( !pDoc )
+ return static_cast<ULONG>(-1);
+
+ if( !pDocSh && ( pDocSh = PTR_CAST( ScDocShell, pDoc->GetDocumentShell() ) ) == NULL )
+ return static_cast<ULONG>(-1);
+
+ if( ULONG nErrId = pDPObj->RefreshCache() )
+ return nErrId;
+ else if ( nErrId == 0 )
+ {
+ //Refresh all dpobjects
+ ScDPCollection* pDPCollection = pDoc->GetDPCollection();
+ USHORT nCount = pDPCollection->GetCount();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if ( (*pDPCollection)[i]->GetCacheId() == pDPObj->GetCacheId() )
+ {
+ ScDBDocFunc aFunc( * pDocSh );
+ if ( !aFunc.DataPilotUpdate( (*pDPCollection)[i], (*pDPCollection)[i], bRecord, bApi ) )
+ break;
+ }
+ }
+
+ return nErrId;
+ }
+
+ return 0U;
+}
+
+ULONG ScDBFunc::RecalcPivotTable()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ // old pivot not used any more
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ // Wang Xu Ming -- 2009-6-17
+ // DataPilot Migration
+ //ScDBDocFunc aFunc( *pDocSh );
+ //aFunc.DataPilotUpdate( pDPObj, pDPObj, TRUE, FALSE );
+ //CursorPosChanged(); // shells may be switched
+ ULONG nErrId = RefreshDPObject( pDPObj, pDoc, pDocSh, TRUE, FALSE );//pDPObj->RefreshCache();
+ if ( nErrId == 0 )
+ {
+ // There is no undo for the refresh of the cache table, but the undo history for cell changes
+ // remains valid and should be preserved, so the history isn't cleared here.
+ //GetViewData()->GetDocShell()->GetUndoManager()->Clear();
+ }
+ else if (nErrId <= USHRT_MAX)
+ ErrorMessage(static_cast<USHORT>(nErrId));
+ return nErrId;
+ // End Comments
+ }
+ else
+ ErrorMessage(STR_PIVOT_NOTFOUND);
+ return STR_PIVOT_NOTFOUND;
+}
+
+void ScDBFunc::GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( !pDPObj )
+ return;
+
+ long nStartDimension = -1;
+ long nStartHierarchy = -1;
+ long nStartLevel = -1;
+
+ ScRangeListRef xRanges;
+ GetViewData()->GetMultiArea( xRanges ); // incl. cursor if nothing is selected
+ ULONG nRangeCount = xRanges->Count();
+ BOOL bContinue = TRUE;
+
+ for (ULONG nRangePos=0; nRangePos<nRangeCount && bContinue; nRangePos++)
+ {
+ ScRange aRange = *xRanges->GetObject(nRangePos);
+ SCCOL nStartCol = aRange.aStart.Col();
+ SCROW nStartRow = aRange.aStart.Row();
+ SCCOL nEndCol = aRange.aEnd.Col();
+ SCROW nEndRow = aRange.aEnd.Row();
+ SCTAB nTab = aRange.aStart.Tab();
+
+ for (SCROW nRow=nStartRow; nRow<=nEndRow && bContinue; nRow++)
+ for (SCCOL nCol=nStartCol; nCol<=nEndCol && bContinue; nCol++)
+ {
+ sheet::DataPilotTableHeaderData aData;
+ pDPObj->GetHeaderPositionData(ScAddress(nCol, nRow, nTab), aData);
+ if ( aData.Dimension < 0 )
+ bContinue = FALSE; // not part of any dimension
+ else
+ {
+ if ( nStartDimension < 0 ) // first member?
+ {
+ nStartDimension = aData.Dimension;
+ nStartHierarchy = aData.Hierarchy;
+ nStartLevel = aData.Level;
+ }
+ if ( aData.Dimension != nStartDimension ||
+ aData.Hierarchy != nStartHierarchy ||
+ aData.Level != nStartLevel )
+ {
+ bContinue = FALSE; // cannot mix dimensions
+ }
+ }
+ if ( bContinue )
+ {
+ // accept any part of a member description, also subtotals,
+ // but don't stop if empty parts are contained
+ if ( aData.Flags & sheet::MemberResultFlags::HASMEMBER )
+ {
+ StrData* pNew = new StrData( aData.MemberName );
+ if ( !rEntries.Insert( pNew ) )
+ delete pNew;
+ }
+ }
+ }
+ }
+
+ rDimension = nStartDimension; // dimension from which the found members came
+ if (!bContinue)
+ rEntries.FreeAll(); // remove all if not valid
+}
+
+BOOL ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts )
+{
+ // determine if the date group dialog has to be shown for the current selection
+
+ BOOL bFound = FALSE;
+
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( nCurX, nCurY, nTab );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+ String aBaseDimName( aDimName );
+
+ BOOL bInGroupDim = FALSE;
+ BOOL bFoundParts = FALSE;
+
+ ScDPDimensionSaveData* pDimData =
+ const_cast<ScDPDimensionSaveData*>( pDPObj->GetSaveData()->GetExistingDimensionData() );
+ if ( pDimData )
+ {
+ const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( aDimName );
+ const ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDim( aDimName );
+ if ( pNumGroupDim )
+ {
+ // existing num group dimension
+
+ if ( pNumGroupDim->GetDatePart() != 0 )
+ {
+ // dimension has date info -> edit settings of this dimension
+ // (parts are collected below)
+
+ rOldInfo = pNumGroupDim->GetDateInfo();
+ bFound = TRUE;
+ }
+ else if ( pNumGroupDim->GetInfo().DateValues )
+ {
+ // Numerical grouping with DateValues flag is used for grouping
+ // of days with a "Number of days" value.
+
+ rOldInfo = pNumGroupDim->GetInfo();
+ rParts = com::sun::star::sheet::DataPilotFieldGroupBy::DAYS; // not found in CollectDateParts
+ bFoundParts = TRUE;
+ bFound = TRUE;
+ }
+ bInGroupDim = TRUE;
+ }
+ else if ( pGroupDim )
+ {
+ // existing additional group dimension
+
+ if ( pGroupDim->GetDatePart() != 0 )
+ {
+ // dimension has date info -> edit settings of this dimension
+ // (parts are collected below)
+
+ rOldInfo = pGroupDim->GetDateInfo();
+ aBaseDimName = pGroupDim->GetSourceDimName();
+ bFound = TRUE;
+ }
+ bInGroupDim = TRUE;
+ }
+ }
+ if ( bFound && !bFoundParts )
+ {
+ // collect date parts from all group dimensions
+ rParts = pDimData->CollectDateParts( aBaseDimName );
+ }
+ if ( !bFound && !bInGroupDim )
+ {
+ // create new date group dimensions if the selection is a single cell
+ // in a normal dimension with date content
+
+ ScRange aSelRange;
+ if ( (GetViewData()->GetSimpleArea( aSelRange ) == SC_MARK_SIMPLE) &&
+ aSelRange.aStart == aSelRange.aEnd )
+ {
+ SCCOL nSelCol = aSelRange.aStart.Col();
+ SCROW nSelRow = aSelRange.aStart.Row();
+ SCTAB nSelTab = aSelRange.aStart.Tab();
+ if ( pDoc->HasValueData( nSelCol, nSelRow, nSelTab ) )
+ {
+ ULONG nIndex = static_cast<const SfxUInt32Item*>(pDoc->GetAttr(
+ nSelCol, nSelRow, nSelTab, ATTR_VALUE_FORMAT))->GetValue();
+ short nType = pDoc->GetFormatTable()->GetType(nIndex);
+ if ( nType == NUMBERFORMAT_DATE || nType == NUMBERFORMAT_TIME || nType == NUMBERFORMAT_DATETIME )
+ {
+ bFound = TRUE;
+ // use currently selected value for automatic limits
+ if( rOldInfo.AutoStart )
+ rOldInfo.Start = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.AutoEnd )
+ rOldInfo.End = pDoc->GetValue( aSelRange.aStart );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bFound;
+}
+
+BOOL ScDBFunc::HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo )
+{
+ // determine if the numeric group dialog has to be shown for the current selection
+
+ BOOL bFound = FALSE;
+
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( nCurX, nCurY, nTab );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ BOOL bInGroupDim = FALSE;
+
+ ScDPDimensionSaveData* pDimData =
+ const_cast<ScDPDimensionSaveData*>( pDPObj->GetSaveData()->GetExistingDimensionData() );
+ if ( pDimData )
+ {
+ const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( aDimName );
+ if ( pNumGroupDim )
+ {
+ // existing num group dimension
+ // -> edit settings of this dimension
+
+ rOldInfo = pNumGroupDim->GetInfo();
+ bFound = TRUE;
+ }
+ else if ( pDimData->GetNamedGroupDim( aDimName ) )
+ bInGroupDim = TRUE; // in a group dimension
+ }
+ if ( !bFound && !bInGroupDim )
+ {
+ // create a new num group dimension if the selection is a single cell
+ // in a normal dimension with numeric content
+
+ ScRange aSelRange;
+ if ( (GetViewData()->GetSimpleArea( aSelRange ) == SC_MARK_SIMPLE) &&
+ aSelRange.aStart == aSelRange.aEnd )
+ {
+ if ( pDoc->HasValueData( aSelRange.aStart.Col(), aSelRange.aStart.Row(),
+ aSelRange.aStart.Tab() ) )
+ {
+ bFound = TRUE;
+ // use currently selected value for automatic limits
+ if( rOldInfo.AutoStart )
+ rOldInfo.Start = pDoc->GetValue( aSelRange.aStart );
+ if( rOldInfo.AutoEnd )
+ rOldInfo.End = pDoc->GetValue( aSelRange.aStart );
+ }
+ }
+ }
+ }
+ }
+
+ return bFound;
+}
+
+void ScDBFunc::DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nParts )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+
+ // find original base
+ String aBaseDimName = aDimName;
+ if( const ScDPSaveGroupDimension* pBaseGroupDim = pDimData->GetNamedGroupDim( aDimName ) )
+ aBaseDimName = pBaseGroupDim->GetSourceDimName();
+
+ // remove all existing parts (the grouping is built completely new)
+
+ /* Remove numeric group dimension (exists once at most). No need
+ to delete anything in save data (grouping was done inplace in
+ an existing base dimension). */
+ pDimData->RemoveNumGroupDimension( aBaseDimName );
+
+ /* Remove named group dimension(s). Collect deleted dimension
+ names which may be reused while recreating the groups.
+ Dimensions have to be removed from dimension save data and from
+ save data too. */
+ std::vector< String > aDeletedNames;
+ const ScDPSaveGroupDimension* pExistingGroup = pDimData->GetGroupDimForBase( aBaseDimName );
+ while ( pExistingGroup )
+ {
+ String aGroupDimName = pExistingGroup->GetGroupDimName();
+ pDimData->RemoveGroupDimension( aGroupDimName ); // pExistingGroup is deleted
+
+ // also remove SaveData settings for the dimension that no longer exists
+ aData.RemoveDimensionByName( aGroupDimName );
+
+ /* The name can be used for the new group dimensions, although
+ it is still in use with the DataPilotSource. */
+ aDeletedNames.push_back( aGroupDimName );
+
+ // see if there are more group dimensions
+ pExistingGroup = pDimData->GetGroupDimForBase( aBaseDimName );
+
+ if ( pExistingGroup && pExistingGroup->GetGroupDimName() == aGroupDimName )
+ {
+ // still get the same group dimension?
+ DBG_ERROR("couldn't remove group dimension");
+ pExistingGroup = NULL; // avoid endless loop
+ }
+ }
+
+ if ( nParts )
+ {
+ // create date group dimensions
+
+ ScDPNumGroupInfo aEmpty;
+ bool bFirst = true;
+ sal_Int32 nMask = 1;
+ for (USHORT nBit=0; nBit<32; nBit++)
+ {
+ if ( nParts & nMask )
+ {
+ if ( bFirst )
+ {
+ // innermost part: create NumGroupDimension (replacing original values)
+ // Dimension name is left unchanged
+
+ if ( (nParts == sheet::DataPilotFieldGroupBy::DAYS) && (rInfo.Step >= 1.0) )
+ {
+ // only days, and a step value specified: use numerical grouping
+ // with DateValues flag, not date grouping
+
+ ScDPNumGroupInfo aNumInfo( rInfo );
+ aNumInfo.DateValues = sal_True;
+
+ ScDPSaveNumGroupDimension aNumGroupDim( aBaseDimName, aNumInfo );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+ else
+ {
+ ScDPSaveNumGroupDimension aNumGroupDim( aBaseDimName, rInfo, nMask );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+
+ bFirst = false;
+ }
+ else
+ {
+ // additional parts: create GroupDimension (shown as additional dimensions)
+ String aGroupDimName = pDimData->CreateDateGroupDimName( nMask, *pDPObj, true, &aDeletedNames );
+ ScDPSaveGroupDimension aGroupDim( aBaseDimName, aGroupDimName );
+ aGroupDim.SetDateInfo( rInfo, nMask );
+ pDimData->AddGroupDimension( aGroupDim );
+
+ // set orientation
+ ScDPSaveDimension* pSaveDimension = aData.GetDimensionByName( aGroupDimName );
+ if ( pSaveDimension->GetOrientation() == sheet::DataPilotFieldOrientation_HIDDEN )
+ {
+ ScDPSaveDimension* pOldDimension = aData.GetDimensionByName( aBaseDimName );
+ pSaveDimension->SetOrientation( pOldDimension->GetOrientation() );
+ long nPosition = 0; //! before (immediate) base
+ aData.SetPosition( pSaveDimension, nPosition );
+ }
+ }
+ }
+ nMask *= 2;
+ }
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+}
+
+void ScDBFunc::NumGroupDataPilot( const ScDPNumGroupInfo& rInfo )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+
+ ScDPSaveNumGroupDimension* pExisting = pDimData->GetNumGroupDimAcc( aDimName );
+ if ( pExisting )
+ {
+ // modify existing group dimension
+ pExisting->SetGroupInfo( rInfo );
+ }
+ else
+ {
+ // create new group dimension
+ ScDPSaveNumGroupDimension aNumGroupDim( aDimName, rInfo );
+ pDimData->AddNumGroupDimension( aNumGroupDim );
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+}
+
+void ScDBFunc::GroupDataPilot()
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+
+ // find original base
+ String aBaseDimName( aDimName );
+ const ScDPSaveGroupDimension* pBaseGroupDim = pDimData->GetNamedGroupDim( aDimName );
+ if ( pBaseGroupDim )
+ {
+ // any entry's SourceDimName is the original base
+ aBaseDimName = pBaseGroupDim->GetSourceDimName();
+ }
+
+ // find existing group dimension
+ // (using the selected dim, can be intermediate group dim)
+ ScDPSaveGroupDimension* pGroupDimension = pDimData->GetGroupDimAccForBase( aDimName );
+
+ // remove the selected items from their groups
+ // (empty groups are removed, too)
+ USHORT nEntryCount = aEntries.GetCount();
+ USHORT nEntry;
+ if ( pGroupDimension )
+ {
+ for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ if ( pBaseGroupDim )
+ {
+ // for each selected (intermediate) group, remove all its items
+ // (same logic as for adding, below)
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
+ if ( pBaseGroup )
+ pBaseGroup->RemoveElementsFromGroups( *pGroupDimension ); // remove all elements
+ else
+ pGroupDimension->RemoveFromGroups( aEntryName );
+ }
+ else
+ pGroupDimension->RemoveFromGroups( aEntryName );
+ }
+ }
+
+ ScDPSaveGroupDimension* pNewGroupDim = NULL;
+ if ( !pGroupDimension )
+ {
+ // create a new group dimension
+ String aGroupDimName = pDimData->CreateGroupDimName( aBaseDimName, *pDPObj, false, NULL );
+ pNewGroupDim = new ScDPSaveGroupDimension( aBaseDimName, aGroupDimName );
+
+ pGroupDimension = pNewGroupDim; // make changes to the new dim if none existed
+
+ if ( pBaseGroupDim )
+ {
+ // If it's a higher-order group dimension, pre-allocate groups for all
+ // non-selected original groups, so the individual base members aren't
+ // used for automatic groups (this would make the original groups hard
+ // to find).
+ //! Also do this when removing groups?
+ //! Handle this case dynamically with automatic groups?
+
+ long nGroupCount = pBaseGroupDim->GetGroupCount();
+ for ( long nGroup = 0; nGroup < nGroupCount; nGroup++ )
+ {
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetGroupByIndex( nGroup );
+
+ StrData aStrData( pBaseGroup->GetGroupName() );
+ USHORT nCollIndex;
+ if ( !aEntries.Search( &aStrData, nCollIndex ) ) //! ignore case?
+ {
+ // add an additional group for each item that is not in the selection
+ ScDPSaveGroupItem aGroup( pBaseGroup->GetGroupName() );
+ aGroup.AddElementsFromGroup( *pBaseGroup );
+ pGroupDimension->AddGroupItem( aGroup );
+ }
+ }
+ }
+ }
+ String aGroupDimName = pGroupDimension->GetGroupDimName();
+
+ //! localized prefix string
+ String aGroupName = pGroupDimension->CreateGroupName( String::CreateFromAscii("Group") );
+ ScDPSaveGroupItem aGroup( aGroupName );
+ for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ if ( pBaseGroupDim )
+ {
+ // for each selected (intermediate) group, add all its items
+ const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetNamedGroup( aEntryName );
+ if ( pBaseGroup )
+ aGroup.AddElementsFromGroup( *pBaseGroup );
+ else
+ aGroup.AddElement( aEntryName ); // no group found -> automatic group, add the item itself
+ }
+ else
+ aGroup.AddElement( aEntryName ); // no group dimension, add all items directly
+ }
+
+ pGroupDimension->AddGroupItem( aGroup );
+
+ if ( pNewGroupDim )
+ {
+ pDimData->AddGroupDimension( *pNewGroupDim );
+ delete pNewGroupDim; // AddGroupDimension copies the object
+ // don't access pGroupDimension after here
+ }
+ pGroupDimension = pNewGroupDim = NULL;
+
+ // set orientation
+ ScDPSaveDimension* pSaveDimension = aData.GetDimensionByName( aGroupDimName );
+ if ( pSaveDimension->GetOrientation() == sheet::DataPilotFieldOrientation_HIDDEN )
+ {
+ ScDPSaveDimension* pOldDimension = aData.GetDimensionByName( aDimName );
+ pSaveDimension->SetOrientation( pOldDimension->GetOrientation() );
+ long nPosition = 0; //! before (immediate) base
+ aData.SetPosition( pSaveDimension, nPosition );
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+}
+
+void ScDBFunc::UngroupDataPilot()
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData(); // created if not there
+ //! test first if DimensionData exists?
+
+ BOOL bApply = FALSE;
+
+ ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aDimName );
+ const ScDPSaveNumGroupDimension* pNumGroupDim = pDimData->GetNumGroupDim( aDimName );
+ if ( ( pGroupDim && pGroupDim->GetDatePart() != 0 ) ||
+ ( pNumGroupDim && pNumGroupDim->GetDatePart() != 0 ) )
+ {
+ // Date grouping: need to remove all affected group dimensions.
+ // This is done using DateGroupDataPilot with nParts=0.
+
+ DateGroupDataPilot( ScDPNumGroupInfo(), 0 );
+ // bApply remains FALSE
+ // dimension pointers become invalid
+ }
+ else if ( pGroupDim )
+ {
+ USHORT nEntryCount = aEntries.GetCount();
+ for (USHORT nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ pGroupDim->RemoveGroup( aEntryName );
+ }
+ // remove group dimension if empty
+ bool bEmptyDim = pGroupDim->IsEmpty();
+ if ( !bEmptyDim )
+ {
+ // If all remaining groups in the dimension aren't shown, remove
+ // the dimension too, as if it was completely empty.
+ ScStrCollection aVisibleEntries;
+ pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension );
+ bEmptyDim = pGroupDim->HasOnlyHidden( aVisibleEntries );
+ }
+ if ( bEmptyDim )
+ {
+ pDimData->RemoveGroupDimension( aDimName ); // pGroupDim is deleted
+
+ // also remove SaveData settings for the dimension that no longer exists
+ aData.RemoveDimensionByName( aDimName );
+ }
+ bApply = TRUE;
+ }
+ else if ( pNumGroupDim )
+ {
+ // remove the numerical grouping
+ pDimData->RemoveNumGroupDimension( aDimName );
+ // SaveData settings can remain unchanged - the same dimension still exists
+ bApply = TRUE;
+ }
+
+ if ( bApply )
+ {
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+ }
+}
+
+static OUString lcl_replaceMemberNameInSubtotal(const OUString& rSubtotal, const OUString& rMemberName)
+{
+ sal_Int32 n = rSubtotal.getLength();
+ const sal_Unicode* p = rSubtotal.getStr();
+ OUStringBuffer aBuf, aWordBuf;
+ for (sal_Int32 i = 0; i < n; ++i)
+ {
+ sal_Unicode c = p[i];
+ if (c == sal_Unicode(' '))
+ {
+ OUString aWord = aWordBuf.makeStringAndClear();
+ if (aWord.equals(rMemberName))
+ aBuf.append(sal_Unicode('?'));
+ else
+ aBuf.append(aWord);
+ aBuf.append(c);
+ }
+ else if (c == sal_Unicode('\\'))
+ {
+ // Escape a backslash character.
+ aWordBuf.append(c);
+ aWordBuf.append(c);
+ }
+ else if (c == sal_Unicode('?'))
+ {
+ // A literal '?' must be escaped with a backslash ('\');
+ aWordBuf.append(sal_Unicode('\\'));
+ aWordBuf.append(c);
+ }
+ else
+ aWordBuf.append(c);
+ }
+
+ if (aWordBuf.getLength() > 0)
+ {
+ OUString aWord = aWordBuf.makeStringAndClear();
+ if (aWord.equals(rMemberName))
+ aBuf.append(sal_Unicode('?'));
+ else
+ aBuf.append(aWord);
+ }
+
+ return aBuf.makeStringAndClear();
+}
+
+void ScDBFunc::DataPilotInput( const ScAddress& rPos, const String& rString )
+{
+ using namespace ::com::sun::star::sheet;
+
+ String aNewName( rString );
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( rPos.Col(), rPos.Row(), rPos.Tab() );
+ if (!pDPObj)
+ return;
+
+ String aOldText;
+ pDoc->GetString( rPos.Col(), rPos.Row(), rPos.Tab(), aOldText );
+
+ if ( aOldText == rString )
+ {
+ // nothing to do: silently exit
+ return;
+ }
+
+ USHORT nErrorId = 0;
+
+ pDPObj->BuildAllDimensionMembers();
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ BOOL bChange = FALSE;
+
+ USHORT nOrient = DataPilotFieldOrientation_HIDDEN;
+ long nField = pDPObj->GetHeaderDim( rPos, nOrient );
+ if ( nField >= 0 )
+ {
+ // changing a field title
+ if ( aData.GetExistingDimensionData() )
+ {
+ // only group dimensions can be renamed
+
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
+ ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aOldText );
+ if ( pGroupDim )
+ {
+ // valid name: not empty, no existing dimension (group or other)
+ if ( rString.Len() && !pDPObj->IsDimNameInUse(rString) )
+ {
+ pGroupDim->Rename( aNewName );
+
+ // also rename in SaveData to preserve the field settings
+ ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aOldText );
+ pSaveDim->SetName( aNewName );
+
+ bChange = TRUE;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ else if (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW)
+ {
+ BOOL bDataLayout = false;
+ String aDimName = pDPObj->GetDimName(nField, bDataLayout);
+ ScDPSaveDimension* pDim = bDataLayout ? aData.GetDataLayoutDimension() : aData.GetDimensionByName(aDimName);
+ if (pDim)
+ {
+ if (rString.Len())
+ {
+ if (rString.EqualsIgnoreCaseAscii(aDimName))
+ {
+ pDim->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDPObj->IsDimNameInUse(rString))
+ {
+ pDim->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ }
+ else if (pDPObj->IsDataDescriptionCell(rPos))
+ {
+ // There is only one data dimension.
+ ScDPSaveDimension* pDim = aData.GetFirstDimension(sheet::DataPilotFieldOrientation_DATA);
+ if (pDim)
+ {
+ if (rString.Len())
+ {
+ if (rString.EqualsIgnoreCaseAscii(pDim->GetName()))
+ {
+ pDim->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDPObj->IsDimNameInUse(rString))
+ {
+ pDim->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ else
+ {
+ // This is not a field header.
+ sheet::DataPilotTableHeaderData aPosData;
+ pDPObj->GetHeaderPositionData(rPos, aPosData);
+
+ if ( (aPosData.Flags & MemberResultFlags::HASMEMBER) && aOldText.Len() )
+ {
+ if ( aData.GetExistingDimensionData() && !(aPosData.Flags & MemberResultFlags::SUBTOTAL))
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( aPosData.Dimension, bIsDataLayout );
+
+ ScDPDimensionSaveData* pDimData = aData.GetDimensionData();
+ ScDPSaveGroupDimension* pGroupDim = pDimData->GetNamedGroupDimAcc( aDimName );
+ if ( pGroupDim )
+ {
+ // valid name: not empty, no existing group in this dimension
+ //! ignore case?
+ if ( aNewName.Len() && !pGroupDim->GetNamedGroup( aNewName ) )
+ {
+ ScDPSaveGroupItem* pGroup = pGroupDim->GetNamedGroupAcc( aOldText );
+ if ( pGroup )
+ pGroup->Rename( aNewName ); // rename the existing group
+ else
+ {
+ // create a new group to replace the automatic group
+ ScDPSaveGroupItem aGroup( aNewName );
+ aGroup.AddElement( aOldText );
+ pGroupDim->AddGroupItem( aGroup );
+ }
+
+ // in both cases also adjust savedata, to preserve member settings (show details)
+ ScDPSaveDimension* pSaveDim = aData.GetDimensionByName( aDimName );
+ ScDPSaveMember* pSaveMember = pSaveDim->GetExistingMemberByName( aOldText );
+ if ( pSaveMember )
+ pSaveMember->SetName( aNewName );
+
+ bChange = TRUE;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ else if ((aPosData.Flags & MemberResultFlags::GRANDTOTAL))
+ {
+ aData.SetGrandTotalName(rString);
+ bChange = true;
+ }
+ else if (aPosData.Dimension >= 0 && aPosData.MemberName.getLength() > 0)
+ {
+ BOOL bDataLayout = false;
+ String aDimName = pDPObj->GetDimName(static_cast<long>(aPosData.Dimension), bDataLayout);
+ if (bDataLayout)
+ {
+ // data dimension
+ do
+ {
+ if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
+ break;
+
+ ScDPSaveDimension* pDim = aData.GetDimensionByName(aPosData.MemberName);
+ if (!pDim)
+ break;
+
+ if (!rString.Len())
+ {
+ nErrorId = STR_INVALIDNAME;
+ break;
+ }
+
+ if (aPosData.MemberName.equalsIgnoreAsciiCase(rString))
+ {
+ pDim->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDPObj->IsDimNameInUse(rString))
+ {
+ pDim->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ while (false);
+ }
+ else
+ {
+ // field member
+ do
+ {
+ ScDPSaveDimension* pDim = aData.GetDimensionByName(aDimName);
+ if (!pDim)
+ break;
+
+ ScDPSaveMember* pMem = pDim->GetExistingMemberByName(aPosData.MemberName);
+ if (!pMem)
+ break;
+
+ if ((aPosData.Flags & MemberResultFlags::SUBTOTAL))
+ {
+ // Change subtotal only when the table has one data dimension.
+ if (aData.GetDataDimensionCount() > 1)
+ break;
+
+ // display name for subtotal is allowed only if the subtotal type is 'Automatic'.
+ if (pDim->GetSubTotalsCount() != 1)
+ break;
+
+ if (pDim->GetSubTotalFunc(0) != sheet::GeneralFunction_AUTO)
+ break;
+
+ const OUString* pLayoutName = pMem->GetLayoutName();
+ String aMemberName;
+ if (pLayoutName)
+ aMemberName = *pLayoutName;
+ else
+ aMemberName = aPosData.MemberName;
+
+ String aNew = lcl_replaceMemberNameInSubtotal(rString, aMemberName);
+ pDim->SetSubtotalName(aNew);
+ bChange = true;
+ }
+ else
+ {
+ // Check to make sure the member name isn't
+ // already used.
+ if (rString.Len())
+ {
+ if (rString.EqualsIgnoreCaseAscii(pMem->GetName()))
+ {
+ pMem->RemoveLayoutName();
+ bChange = true;
+ }
+ else if (!pDim->IsMemberNameInUse(rString))
+ {
+ pMem->SetLayoutName(rString);
+ bChange = true;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ else
+ nErrorId = STR_INVALIDNAME;
+ }
+ }
+ while (false);
+ }
+ }
+ }
+ }
+
+ if ( bChange )
+ {
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+ delete pNewObj;
+ }
+ else
+ {
+ if ( !nErrorId )
+ nErrorId = STR_ERR_DATAPILOT_INPUT;
+ ErrorMessage( nErrorId );
+ }
+}
+
+void lcl_MoveToEnd( ScDPSaveDimension& rDim, const String& rItemName )
+{
+ ScDPSaveMember* pNewMember = NULL;
+ const ScDPSaveMember* pOldMember = rDim.GetExistingMemberByName( rItemName );
+ if ( pOldMember )
+ pNewMember = new ScDPSaveMember( *pOldMember );
+ else
+ pNewMember = new ScDPSaveMember( rItemName );
+ rDim.AddMember( pNewMember );
+ // AddMember takes ownership of the new pointer,
+ // puts it to the end of the list even if it was in the list before.
+}
+
+struct ScOUStringCollate
+{
+ CollatorWrapper* mpCollator;
+
+ ScOUStringCollate(CollatorWrapper* pColl) : mpCollator(pColl) {}
+
+ bool operator()(const rtl::OUString& rStr1, const rtl::OUString& rStr2) const
+ {
+ return ( mpCollator->compareString(rStr1, rStr2) < 0 );
+ }
+};
+
+bool ScDBFunc::DataPilotSort( const ScAddress& rPos, bool bAscending, sal_uInt16* pUserListId )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(rPos.Col(), rPos.Row(), rPos.Tab());
+ if (!pDPObj)
+ return false;
+
+ // We need to run this to get all members later.
+ if ( pUserListId )
+ pDPObj->BuildAllDimensionMembers();
+
+ USHORT nOrientation;
+ long nDimIndex = pDPObj->GetHeaderDim(rPos, nOrientation);
+ if (nDimIndex < 0)
+ // Invalid dimension index. Bail out.
+ return false;
+
+ BOOL bDataLayout;
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+ if (!pSaveData)
+ return false;
+
+ ScDPSaveData aNewSaveData(*pSaveData);
+ String aDimName = pDPObj->GetDimName(nDimIndex, bDataLayout);
+ ScDPSaveDimension* pSaveDim = aNewSaveData.GetDimensionByName(aDimName);
+ if (!pSaveDim)
+ return false;
+
+ // manual evaluation of sort order is only needed if a user list id is given
+ if ( pUserListId )
+ {
+ typedef ScDPSaveDimension::MemberList MemList;
+ const MemList& rDimMembers = pSaveDim->GetMembers();
+ list<OUString> aMembers;
+ hash_set<OUString, ::rtl::OUStringHash> aMemberSet;
+ size_t nMemberCount = 0;
+ for (MemList::const_iterator itr = rDimMembers.begin(), itrEnd = rDimMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ ScDPSaveMember* pMem = *itr;
+ aMembers.push_back(pMem->GetName());
+ aMemberSet.insert(pMem->GetName());
+ ++nMemberCount;
+ }
+
+ // Sort the member list in ascending order.
+ ScOUStringCollate aCollate( ScGlobal::GetCollator() );
+ aMembers.sort(aCollate);
+
+ // Collect and rank those custom sort strings that also exist in the member name list.
+
+ typedef hash_map<OUString, sal_uInt16, OUStringHash> UserSortMap;
+ UserSortMap aSubStrs;
+ sal_uInt16 nSubCount = 0;
+ if (pUserListId)
+ {
+ ScUserList* pUserList = ScGlobal::GetUserList();
+ if (!pUserList)
+ return false;
+
+ {
+ sal_uInt16 n = pUserList->GetCount();
+ if (!n || *pUserListId >= n)
+ return false;
+ }
+
+ ScUserListData* pData = static_cast<ScUserListData*>((*pUserList)[*pUserListId]);
+ if (pData)
+ {
+ sal_uInt16 n = pData->GetSubCount();
+ for (sal_uInt16 i = 0; i < n; ++i)
+ {
+ OUString aSub = pData->GetSubStr(i);
+ if (!aMemberSet.count(aSub))
+ // This string doesn't exist in the member name set. Don't add this.
+ continue;
+
+ aSubStrs.insert(UserSortMap::value_type(aSub, nSubCount++));
+ }
+ }
+ }
+
+ // Rank all members.
+
+ vector<OUString> aRankedNames(nMemberCount);
+ sal_uInt16 nCurStrId = 0;
+ for (list<OUString>::const_iterator itr = aMembers.begin(), itrEnd = aMembers.end();
+ itr != itrEnd; ++itr)
+ {
+ OUString aName = *itr;
+ sal_uInt16 nRank = 0;
+ UserSortMap::const_iterator itrSub = aSubStrs.find(aName);
+ if (itrSub == aSubStrs.end())
+ nRank = nSubCount + nCurStrId++;
+ else
+ nRank = itrSub->second;
+
+ if (!bAscending)
+ nRank = static_cast< sal_uInt16 >( nMemberCount - nRank - 1 );
+
+ aRankedNames[nRank] = aName;
+ }
+
+ // Re-order ScDPSaveMember instances with the new ranks.
+
+ for (vector<OUString>::const_iterator itr = aRankedNames.begin(), itrEnd = aRankedNames.end();
+ itr != itrEnd; ++itr)
+ {
+ const ScDPSaveMember* pOldMem = pSaveDim->GetExistingMemberByName(*itr);
+ if (!pOldMem)
+ // All members are supposed to be present.
+ continue;
+
+ ScDPSaveMember* pNewMem = new ScDPSaveMember(*pOldMem);
+ pSaveDim->AddMember(pNewMem);
+ }
+
+ // Set the sorting mode to manual for now. We may introduce a new sorting
+ // mode later on.
+
+ sheet::DataPilotFieldSortInfo aSortInfo;
+ aSortInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
+ pSaveDim->SetSortInfo(&aSortInfo);
+ }
+ else
+ {
+ // without user list id, just apply sorting mode
+
+ sheet::DataPilotFieldSortInfo aSortInfo;
+ aSortInfo.Mode = sheet::DataPilotFieldSortMode::NAME;
+ aSortInfo.IsAscending = bAscending;
+ pSaveDim->SetSortInfo(&aSortInfo);
+ }
+
+ // Update the datapilot with the newly sorted field members.
+
+ auto_ptr<ScDPObject> pNewObj(new ScDPObject(*pDPObj));
+ pNewObj->SetSaveData(aNewSaveData);
+ ScDBDocFunc aFunc(*GetViewData()->GetDocShell());
+
+ return aFunc.DataPilotUpdate(pDPObj, pNewObj.get(), true, false);
+}
+
+BOOL ScDBFunc::DataPilotMove( const ScRange& rSource, const ScAddress& rDest )
+{
+ BOOL bRet = FALSE;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( rSource.aStart.Col(), rSource.aStart.Row(), rSource.aStart.Tab() );
+ if ( pDPObj && pDPObj == pDoc->GetDPAtCursor( rDest.Col(), rDest.Row(), rDest.Tab() ) )
+ {
+ sheet::DataPilotTableHeaderData aDestData;
+ pDPObj->GetHeaderPositionData( rDest, aDestData );
+ bool bValid = ( aDestData.Dimension >= 0 ); // dropping onto a field
+
+ // look through the source range
+ std::hash_set< rtl::OUString, rtl::OUStringHash, std::equal_to<rtl::OUString> > aMembersSet; // for lookup
+ std::vector< rtl::OUString > aMembersVector; // members in original order, for inserting
+ aMembersVector.reserve( std::max( static_cast<SCSIZE>( rSource.aEnd.Col() - rSource.aStart.Col() + 1 ),
+ static_cast<SCSIZE>( rSource.aEnd.Row() - rSource.aStart.Row() + 1 ) ) );
+ for (SCROW nRow = rSource.aStart.Row(); bValid && nRow <= rSource.aEnd.Row(); ++nRow )
+ for (SCCOL nCol = rSource.aStart.Col(); bValid && nCol <= rSource.aEnd.Col(); ++nCol )
+ {
+ sheet::DataPilotTableHeaderData aSourceData;
+ pDPObj->GetHeaderPositionData( ScAddress( nCol, nRow, rSource.aStart.Tab() ), aSourceData );
+ if ( aSourceData.Dimension == aDestData.Dimension && aSourceData.MemberName.getLength() )
+ {
+ if ( aMembersSet.find( aSourceData.MemberName ) == aMembersSet.end() )
+ {
+ aMembersSet.insert( aSourceData.MemberName );
+ aMembersVector.push_back( aSourceData.MemberName );
+ }
+ // duplicates are ignored
+ }
+ else
+ bValid = false; // empty (subtotal) or different field
+ }
+
+ if ( bValid )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( aDestData.Dimension, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPSaveDimension* pDim = aData.GetDimensionByName( aDimName );
+
+ // get all member names in source order
+ uno::Sequence<rtl::OUString> aMemberNames;
+ pDPObj->GetMemberNames( aDestData.Dimension, aMemberNames );
+
+ bool bInserted = false;
+
+ sal_Int32 nMemberCount = aMemberNames.getLength();
+ for (sal_Int32 nMemberPos=0; nMemberPos<nMemberCount; ++nMemberPos)
+ {
+ String aMemberStr( aMemberNames[nMemberPos] );
+
+ if ( !bInserted && aMemberNames[nMemberPos] == aDestData.MemberName )
+ {
+ // insert dragged items before this item
+ for ( std::vector<rtl::OUString>::const_iterator aIter = aMembersVector.begin();
+ aIter != aMembersVector.end(); ++aIter )
+ lcl_MoveToEnd( *pDim, *aIter );
+ bInserted = true;
+ }
+
+ if ( aMembersSet.find( aMemberStr ) == aMembersSet.end() ) // skip dragged items
+ lcl_MoveToEnd( *pDim, aMemberStr );
+ }
+ // insert dragged item at end if dest wasn't found (for example, empty)
+ if ( !bInserted )
+ for ( std::vector<rtl::OUString>::const_iterator aIter = aMembersVector.begin();
+ aIter != aMembersVector.end(); ++aIter )
+ lcl_MoveToEnd( *pDim, *aIter );
+
+ // Items that were in SaveData, but not in the source, end up at the start of the list.
+
+ // set flag for manual sorting
+ sheet::DataPilotFieldSortInfo aSortInfo;
+ aSortInfo.Mode = sheet::DataPilotFieldSortMode::MANUAL;
+ pDim->SetSortInfo( &aSortInfo );
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE ); //! bApi for drag&drop?
+ delete pNewObj;
+
+ Unmark(); // entry was moved - no use in leaving the old cell selected
+
+ bRet = TRUE;
+ }
+ }
+ }
+
+ return bRet;
+}
+
+BOOL ScDBFunc::HasSelectionForDrillDown( USHORT& rOrientation )
+{
+ BOOL bRet = FALSE;
+
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+ ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName( aDimName );
+ if ( pDim )
+ {
+ USHORT nDimOrient = pDim->GetOrientation();
+ ScDPSaveDimension* pInner = pSaveData->GetInnermostDimension( nDimOrient );
+ if ( pDim == pInner )
+ {
+ rOrientation = nDimOrient;
+ bRet = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ return bRet;
+}
+
+void ScDBFunc::SetDataPilotDetails( BOOL bShow, const String* pNewDimensionName )
+{
+ ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ if ( pDPObj )
+ {
+ ScStrCollection aEntries;
+ long nSelectDimension = -1;
+ GetSelectedMemberList( aEntries, nSelectDimension );
+
+ if ( aEntries.GetCount() > 0 )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveData aData( *pDPObj->GetSaveData() );
+ ScDPSaveDimension* pDim = aData.GetDimensionByName( aDimName );
+
+ if ( bShow && pNewDimensionName )
+ {
+ // add the new dimension with the same orientation, at the end
+
+ ScDPSaveDimension* pNewDim = aData.GetDimensionByName( *pNewDimensionName );
+ ScDPSaveDimension* pDuplicated = NULL;
+ if ( pNewDim->GetOrientation() == sheet::DataPilotFieldOrientation_DATA )
+ {
+ // Need to duplicate the dimension, create column/row in addition to data:
+ // The duplicated dimension inherits the existing settings, pNewDim is modified below.
+ pDuplicated = aData.DuplicateDimension( *pNewDimensionName );
+ }
+
+ USHORT nOrientation = pDim->GetOrientation();
+ pNewDim->SetOrientation( nOrientation );
+
+ long nPosition = LONG_MAX;
+ aData.SetPosition( pNewDim, nPosition );
+
+ ScDPSaveDimension* pDataLayout = aData.GetDataLayoutDimension();
+ if ( pDataLayout->GetOrientation() == nOrientation &&
+ aData.GetDataDimensionCount() <= 1 )
+ {
+ // If there is only one data dimension, the data layout dimension
+ // must still be the last one in its orientation.
+ aData.SetPosition( pDataLayout, nPosition );
+ }
+
+ if ( pDuplicated )
+ {
+ // The duplicated (data) dimension needs to be behind the original dimension
+ aData.SetPosition( pDuplicated, nPosition );
+ }
+
+ // Hide details for all visible members (selected are changed below).
+ //! Use all members from source level instead (including non-visible)?
+
+ ScStrCollection aVisibleEntries;
+ pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension );
+
+ USHORT nVisCount = aVisibleEntries.GetCount();
+ for (USHORT nVisPos=0; nVisPos<nVisCount; nVisPos++)
+ {
+ String aVisName = aVisibleEntries[nVisPos]->GetString();
+ ScDPSaveMember* pMember = pDim->GetMemberByName( aVisName );
+ pMember->SetShowDetails( FALSE );
+ }
+ }
+
+ USHORT nEntryCount = aEntries.GetCount();
+ for (USHORT nEntry=0; nEntry<nEntryCount; nEntry++)
+ {
+ String aEntryName = aEntries[nEntry]->GetString();
+ ScDPSaveMember* pMember = pDim->GetMemberByName( aEntryName );
+ pMember->SetShowDetails( bShow );
+ }
+
+ // apply changes
+ ScDBDocFunc aFunc( *GetViewData()->GetDocShell() );
+ ScDPObject* pNewObj = new ScDPObject( *pDPObj );
+ pNewObj->SetSaveData( aData );
+ aFunc.DataPilotUpdate( pDPObj, pNewObj, TRUE, FALSE );
+ delete pNewObj;
+
+ // unmark cell selection
+ Unmark();
+ }
+ }
+ }
+}
+
+void ScDBFunc::ShowDataPilotSourceData( ScDPObject& rDPObj, const Sequence<sheet::DataPilotFieldFilter>& rFilters )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if (pDoc->GetDocumentShell()->IsReadOnly())
+ {
+ ErrorMessage(STR_READONLYERR);
+ return;
+ }
+
+ Reference<sheet::XDimensionsSupplier> xDimSupplier = rDPObj.GetSource();
+ Reference<container::XNameAccess> xDims = xDimSupplier->getDimensions();
+ Reference<sheet::XDrillDownDataSupplier> xDDSupplier(xDimSupplier, UNO_QUERY);
+ if (!xDDSupplier.is())
+ return;
+
+ Sequence< Sequence<Any> > aTabData = xDDSupplier->getDrillDownData(rFilters);
+ sal_Int32 nRowSize = aTabData.getLength();
+ if (nRowSize <= 1)
+ // There is no data to show. Bail out.
+ return;
+
+ sal_Int32 nColSize = aTabData[0].getLength();
+
+ SCTAB nNewTab = GetViewData()->GetTabNo();
+
+ auto_ptr<ScDocument> pInsDoc(new ScDocument(SCDOCMODE_CLIP));
+ pInsDoc->ResetClip( pDoc, nNewTab );
+ for (SCROW nRow = 0; nRow < nRowSize; ++nRow)
+ {
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
+ {
+ const Any& rAny = aTabData[nRow][nCol];
+ rtl::OUString aStr;
+ double fVal;
+ if (rAny >>= aStr)
+ pInsDoc->PutCell( ScAddress(nCol, nRow, nNewTab), new ScStringCell(String(aStr)) );
+ else if (rAny >>= fVal)
+ pInsDoc->SetValue(nCol, nRow, nNewTab, fVal);
+ }
+ }
+
+ // set number format (important for dates)
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
+ {
+ rtl::OUString aStr;
+ if (!(aTabData[0][nCol] >>= aStr))
+ continue;
+
+ Reference<XPropertySet> xPropSet(xDims->getByName(aStr), UNO_QUERY);
+ if (!xPropSet.is())
+ continue;
+
+ Any any = xPropSet->getPropertyValue( rtl::OUString::createFromAscii(SC_UNO_NUMBERFO) );
+ sal_Int32 nNumFmt = 0;
+ if (!(any >>= nNumFmt))
+ continue;
+
+ ScPatternAttr aPattern( pInsDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item(ATTR_VALUE_FORMAT, static_cast<UINT32>(nNumFmt)) );
+ pInsDoc->ApplyPatternAreaTab(nCol, 1, nCol, nRowSize-1, nNewTab, aPattern);
+ }
+
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pInsDoc->GetCellArea( nNewTab, nEndCol, nEndRow );
+ pInsDoc->SetClipArea( ScRange( 0, 0, nNewTab, nEndCol, nEndRow, nNewTab ) );
+
+ SfxUndoManager* pMgr = GetViewData()->GetDocShell()->GetUndoManager();
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_DOOUTLINE );
+ pMgr->EnterListAction( aUndo, aUndo );
+
+ String aNewTabName;
+ pDoc->CreateValidTabName(aNewTabName);
+ if ( InsertTable(aNewTabName, nNewTab) )
+ PasteFromClip( IDF_ALL, pInsDoc.get() );
+
+ pMgr->LeaveListAction();
+}
+
+//
+// DB-Operationen (Sortieren, Filtern, Teilergebnisse) wiederholen
+//
+
+void ScDBFunc::RepeatDB( BOOL bRecord )
+{
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDBData* pDBData = GetDBData();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScQueryParam aQueryParam;
+ pDBData->GetQueryParam( aQueryParam );
+ BOOL bQuery = aQueryParam.GetEntry(0).bDoQuery;
+
+ ScSortParam aSortParam;
+ pDBData->GetSortParam( aSortParam );
+ BOOL bSort = aSortParam.bDoSort[0];
+
+ ScSubTotalParam aSubTotalParam;
+ pDBData->GetSubTotalParam( aSubTotalParam );
+ BOOL bSubTotal = aSubTotalParam.bGroupActive[0] && !aSubTotalParam.bRemoveOnly;
+
+ if ( bQuery || bSort || bSubTotal )
+ {
+ BOOL bQuerySize = FALSE;
+ ScRange aOldQuery;
+ ScRange aNewQuery;
+ if (bQuery && !aQueryParam.bInplace)
+ {
+ ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, TRUE );
+ if (pDest && pDest->IsDoSize())
+ {
+ pDest->GetArea( aOldQuery );
+ bQuerySize = TRUE;
+ }
+ }
+
+ SCTAB nDummy;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pDBData->GetArea( nDummy, nStartCol, nStartRow, nEndCol, nEndRow );
+
+ //! Undo nur benoetigte Daten ?
+
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ ScRangeName* pUndoRange = NULL;
+ ScDBCollection* pUndoDB = NULL;
+
+ if (bRecord)
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nTab );
+ if (pTable)
+ {
+ pUndoTab = new ScOutlineTable( *pTable );
+
+ SCCOLROW nOutStartCol; // Zeilen/Spaltenstatus
+ SCCOLROW nOutStartRow;
+ SCCOLROW nOutEndCol;
+ SCCOLROW nOutEndRow;
+ pTable->GetColArray()->GetRange( nOutStartCol, nOutEndCol );
+ pTable->GetRowArray()->GetRange( nOutStartRow, nOutEndRow );
+
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nOutStartCol), 0, nTab, static_cast<SCCOL>(nOutEndCol), MAXROW, nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+ else
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+
+ // Datenbereich sichern - incl. Filter-Ergebnis
+ pDoc->CopyToDocument( 0,nStartRow,nTab, MAXCOL,nEndRow,nTab, IDF_ALL, FALSE, pUndoDoc );
+
+ // alle Formeln wegen Referenzen
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1, IDF_FORMULA, FALSE, pUndoDoc );
+
+ // DB- und andere Bereiche
+ ScRangeName* pDocRange = pDoc->GetRangeName();
+ if (pDocRange->GetCount())
+ pUndoRange = new ScRangeName( *pDocRange );
+ ScDBCollection* pDocDB = pDoc->GetDBCollection();
+ if (pDocDB->GetCount())
+ pUndoDB = new ScDBCollection( *pDocDB );
+ }
+
+ if (bSort && bSubTotal)
+ {
+ // Sortieren ohne SubTotals
+
+ aSubTotalParam.bRemoveOnly = TRUE; // wird unten wieder zurueckgesetzt
+ DoSubTotals( aSubTotalParam, FALSE );
+ }
+
+ if (bSort)
+ {
+ pDBData->GetSortParam( aSortParam ); // Bereich kann sich geaendert haben
+ Sort( aSortParam, FALSE, FALSE);
+ }
+ if (bQuery)
+ {
+ pDBData->GetQueryParam( aQueryParam ); // Bereich kann sich geaendert haben
+ ScRange aAdvSource;
+ if (pDBData->GetAdvancedQuerySource(aAdvSource))
+ {
+ pDoc->CreateQueryParam(
+ aAdvSource.aStart.Col(), aAdvSource.aStart.Row(),
+ aAdvSource.aEnd.Col(), aAdvSource.aEnd.Row(),
+ aAdvSource.aStart.Tab(), aQueryParam );
+ Query( aQueryParam, &aAdvSource, FALSE );
+ }
+ else
+ Query( aQueryParam, NULL, FALSE );
+
+ // bei nicht-inplace kann die Tabelle umgestellt worden sein
+ if ( !aQueryParam.bInplace && aQueryParam.nDestTab != nTab )
+ SetTabNo( nTab );
+ }
+ if (bSubTotal)
+ {
+ pDBData->GetSubTotalParam( aSubTotalParam ); // Bereich kann sich geaendert haben
+ aSubTotalParam.bRemoveOnly = FALSE;
+ DoSubTotals( aSubTotalParam, FALSE );
+ }
+
+ if (bRecord)
+ {
+ SCTAB nDummyTab;
+ SCCOL nDummyCol;
+ SCROW nDummyRow, nNewEndRow;
+ pDBData->GetArea( nDummyTab, nDummyCol,nDummyRow, nDummyCol,nNewEndRow );
+
+ const ScRange* pOld = NULL;
+ const ScRange* pNew = NULL;
+ if (bQuerySize)
+ {
+ ScDBData* pDest = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
+ aQueryParam.nDestTab, TRUE );
+ if (pDest)
+ {
+ pDest->GetArea( aNewQuery );
+ pOld = &aOldQuery;
+ pNew = &aNewQuery;
+ }
+ }
+
+ GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction(
+ new ScUndoRepeatDB( GetViewData()->GetDocShell(), nTab,
+ nStartCol, nStartRow, nEndCol, nEndRow,
+ nNewEndRow,
+ nCurX, nCurY,
+ pUndoDoc, pUndoTab,
+ pUndoRange, pUndoDB,
+ pOld, pNew ) );
+ }
+
+ GetViewData()->GetDocShell()->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
+ }
+ else // "Keine Operationen auszufuehren"
+ ErrorMessage(STR_MSSG_REPEATDB_0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/dbfunc4.cxx b/sc/source/ui/view/dbfunc4.cxx
new file mode 100644
index 000000000000..c8ecbbc76382
--- /dev/null
+++ b/sc/source/ui/view/dbfunc4.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svditer.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+
+#include "dbfunc.hxx"
+#include "drwlayer.hxx"
+#include "document.hxx"
+
+// -----------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+using namespace com::sun::star;
+
+//==================================================================
+
+// static
+USHORT ScDBFunc::DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, BOOL bAllCharts )
+{
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (!pModel)
+ return 0;
+
+ USHORT nFound = 0;
+
+ USHORT nPageCount = pModel->GetPageCount();
+ for (USHORT nPageNo=0; nPageNo<nPageCount; nPageNo++)
+ {
+ SdrPage* pPage = pModel->GetPage(nPageNo);
+ DBG_ASSERT(pPage,"Page ?");
+
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->GetObjIdentifier() == OBJ_OLE2 && pDoc->IsChart( pObject ) )
+ {
+ String aName = ((SdrOle2Obj*)pObject)->GetPersistName();
+ BOOL bHit = TRUE;
+ if ( !bAllCharts )
+ {
+ ScRangeList aRanges;
+ BOOL bColHeaders = FALSE;
+ BOOL bRowHeaders = FALSE;
+ pDoc->GetOldChartParameters( aName, aRanges, bColHeaders, bRowHeaders );
+ bHit = aRanges.In( rPos );
+ }
+ if ( bHit )
+ {
+ pDoc->UpdateChart( aName );
+ ++nFound;
+ }
+ }
+ pObject = aIter.Next();
+ }
+ }
+ return nFound;
+}
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawattr.cxx b/sc/source/ui/view/drawattr.cxx
new file mode 100644
index 000000000000..d85c0ccbbb70
--- /dev/null
+++ b/sc/source/ui/view/drawattr.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "drawattr.hxx"
+#include "global.hxx"
+
+//------------------------------------------------------------------------
+
+String __EXPORT SvxDrawToolItem::GetValueText() const
+{
+ return GetValueText(GetValue());
+}
+
+//------------------------------------------------------------------------
+
+String __EXPORT SvxDrawToolItem::GetValueText( USHORT nVal ) const
+{
+ const sal_Char* p;
+
+ switch (nVal)
+ {
+ case 0 : p = "SVX_SNAP_DRAW_SELECT" ; break;
+ //
+ case 1 : p = "SVX_SNAP_DRAW_LINE" ; break;
+ case 2 : p = "SVX_SNAP_DRAW_RECT" ; break;
+ case 3 : p = "SVX_SNAP_DRAW_ELLIPSE" ; break;
+ case 4 : p = "SVX_SNAP_DRAW_POLYGON" ; break;
+ case 5 : p = "SVX_SNAP_DRAW_ARC" ; break;
+ case 6 : p = "SVX_SNAP_DRAW_PIE" ; break;
+ case 7 : p = "SVX_SNAP_DRAW_CIRCLECUT" ; break;
+ case 8 : p = "SVX_SNAP_DRAW_TEXT" ; break;
+ default : return EMPTY_STRING;
+ }
+ return String::CreateFromAscii( p );
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT SvxDrawToolItem::Clone( SfxItemPool * ) const
+{
+ return new SvxDrawToolItem(*this);
+}
+
+//------------------------------------------------------------------------
+
+SfxPoolItem* __EXPORT SvxDrawToolItem::Create( SvStream& rStream, USHORT nVer ) const
+{
+ USHORT nVal;
+ rStream >> nVal;
+ return new SvxDrawToolItem(nVal);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawutil.cxx b/sc/source/ui/view/drawutil.cxx
new file mode 100644
index 000000000000..82fae44d1e4c
--- /dev/null
+++ b/sc/source/ui/view/drawutil.cxx
@@ -0,0 +1,118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/outdev.hxx>
+
+#include "drawutil.hxx"
+#include "document.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+
+inline Fraction MakeFraction( long nA, long nB )
+{
+ return ( nA && nB ) ? Fraction(nA,nB) : Fraction(1,1);
+}
+
+void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ OutputDevice* pDev,
+ const Fraction& rZoomX, const Fraction& rZoomY,
+ double nPPTX, double nPPTY,
+ Fraction& rScaleX, Fraction& rScaleY )
+{
+ long nPixelX = 0;
+ long nTwipsX = 0;
+ long nPixelY = 0;
+ long nTwipsY = 0;
+ for (SCCOL i=nStartCol; i<nEndCol; i++)
+ {
+ USHORT nWidth = pDoc->GetColWidth(i,nTab);
+ nTwipsX += (long) nWidth;
+ nPixelX += ScViewData::ToPixel( nWidth, nPPTX );
+ }
+
+ for (SCROW nRow = nStartRow; nRow <= nEndRow-1; ++nRow)
+ {
+ SCROW nLastRow = nRow;
+ if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
+ {
+ nRow = nLastRow;
+ continue;
+ }
+
+ USHORT nHeight = pDoc->GetRowHeight(nRow, nTab);
+ nTwipsY += static_cast<long>(nHeight);
+ nPixelY += ScViewData::ToPixel(nHeight, nPPTY);
+ }
+
+ MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY );
+ Point aPixelLog = pDev->PixelToLogic( Point( nPixelX,nPixelY ), aHMMMode );
+
+ // Fraction(double) ctor can be used here (and avoid overflows of PixelLog * Zoom)
+ // because ReduceInaccurate is called later anyway.
+
+ if ( aPixelLog.X() && nTwipsX )
+ rScaleX = Fraction( ((double)aPixelLog.X()) *
+ ((double)rZoomX.GetNumerator()) /
+ ((double)nTwipsX) /
+ ((double)HMM_PER_TWIPS) /
+ ((double)rZoomX.GetDenominator()) );
+ else
+ rScaleX = Fraction( 1, 1 );
+
+ if ( aPixelLog.Y() && nTwipsY )
+ rScaleY = Fraction( ((double)aPixelLog.Y()) *
+ ((double)rZoomY.GetNumerator()) /
+ ((double)nTwipsY) /
+ ((double)HMM_PER_TWIPS) /
+ ((double)rZoomY.GetDenominator()) );
+ else
+ rScaleY = Fraction( 1, 1 );
+
+ // 25 bits of accuracy are needed to always hit the right part of
+ // cells in the last rows (was 17 before 1M rows).
+ rScaleX.ReduceInaccurate( 25 );
+ rScaleY.ReduceInaccurate( 25 );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawvie2.cxx b/sc/source/ui/view/drawvie2.cxx
new file mode 100644
index 000000000000..0f44641f33ca
--- /dev/null
+++ b/sc/source/ui/view/drawvie2.cxx
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "drawview.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+
+// UpdateBrowser in MarkListHasChanged gerufen
+
+void ScDrawView::UpdateBrowser()
+{
+ // VC's und den Browser dazu gibts nicht mehr...
+}
+
+void ScDrawView::VCAddWin( Window* /* pWin */ )
+{
+ // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden
+}
+
+void ScDrawView::VCRemoveWin( Window* /* pWin */ )
+{
+ // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawvie3.cxx b/sc/source/ui/view/drawvie3.cxx
new file mode 100644
index 000000000000..3c9fb33522e0
--- /dev/null
+++ b/sc/source/ui/view/drawvie3.cxx
@@ -0,0 +1,184 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "drawview.hxx"
+#include "drwlayer.hxx"
+#include "viewdata.hxx"
+#include "dbfunc.hxx"
+#include "document.hxx"
+#include "userdat.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+
+void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap,
+ const TargetList* pTargetList, void* pEditingObj ); // imapwrap
+USHORT ScIMapChildWindowId();
+
+// STATIC DATA -----------------------------------------------------------
+
+ScDrawView::ScDrawView( OutputDevice* pOut, ScViewData* pData ) :
+ FmFormView( pData->GetDocument()->GetDrawLayer(), pOut ),
+ pViewData( pData ),
+ pDev( pOut ),
+ pDoc( pData->GetDocument() ),
+ nTab( pData->GetTabNo() ),
+ pDropMarker( NULL ),
+ pDropMarkObj( NULL ),
+ bInConstruct( TRUE )
+ //HMHbDisableHdl( FALSE )
+{
+ // #i73602# Use default from the configuration
+ SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Calc());
+
+ // #i74769#, #i75172# Use default from the configuration
+ SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Calc());
+
+ Construct();
+}
+
+// Verankerung setzen
+
+void ScDrawView::SetAnchor( ScAnchorType eType )
+{
+ SdrObject* pObj = NULL;
+ if( AreObjectsMarked() )
+ {
+ const SdrMarkList* pMark = &GetMarkedObjectList();
+ ULONG nCount = pMark->GetMarkCount();
+ for( ULONG i=0; i<nCount; i++ )
+ {
+ pObj = pMark->GetMark(i)->GetMarkedSdrObj();
+ ScDrawLayer::SetAnchor( pObj, eType );
+ }
+
+ if ( pViewData )
+ pViewData->GetDocShell()->SetDrawModified();
+ }
+}
+
+ScAnchorType ScDrawView::GetAnchor() const
+{
+ BOOL bPage = FALSE;
+ BOOL bCell = FALSE;
+ const SdrObject* pObj = NULL;
+ if( AreObjectsMarked() )
+ {
+ const SdrMarkList* pMark = &GetMarkedObjectList();
+ ULONG nCount = pMark->GetMarkCount();
+ Point p0;
+ for( ULONG i=0; i<nCount; i++ )
+ {
+ pObj = pMark->GetMark(i)->GetMarkedSdrObj();
+ if( ScDrawLayer::GetAnchor( pObj ) == SCA_CELL )
+ bCell =TRUE;
+ else
+ bPage = TRUE;
+ }
+ }
+ if( bPage && !bCell )
+ return SCA_PAGE;
+ if( !bPage && bCell )
+ return SCA_CELL;
+ return SCA_DONTKNOW;
+}
+
+void __EXPORT ScDrawView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA(ScTabDeletedHint)) // Tabelle geloescht
+ {
+ SCTAB nDelTab = ((ScTabDeletedHint&)rHint).GetTab();
+ if (ValidTab(nDelTab))
+ {
+ // used to be: HidePagePgNum(nDelTab) - hide only if the deleted sheet is shown here
+ if ( nDelTab == nTab )
+ HideSdrPage();
+ }
+ }
+ else if (rHint.ISA(ScTabSizeChangedHint)) // Groesse geaendert
+ {
+ if ( nTab == ((ScTabSizeChangedHint&)rHint).GetTab() )
+ UpdateWorkArea();
+ }
+ else
+ FmFormView::Notify( rBC,rHint );
+}
+
+void ScDrawView::UpdateIMap( SdrObject* pObj )
+{
+ if ( pViewData &&
+ pViewData->GetViewShell()->GetViewFrame()->HasChildWindow( ScIMapChildWindowId() ) &&
+ pObj && ( pObj->ISA(SdrGrafObj) || pObj->ISA(SdrOle2Obj) ) )
+ {
+ Graphic aGraphic;
+ TargetList aTargetList;
+ ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pObj );
+ const ImageMap* pImageMap = NULL;
+ if ( pIMapInfo )
+ pImageMap = &pIMapInfo->GetImageMap();
+
+ // Target-Liste besorgen
+ pViewData->GetViewShell()->GetViewFrame()->GetTargetList( aTargetList );
+
+ // Grafik vom Objekt besorgen
+ if ( pObj->ISA( SdrGrafObj ) )
+ aGraphic = ( (SdrGrafObj*) pObj )->GetGraphic();
+ else
+ {
+ Graphic* pGraphic = ((const SdrOle2Obj*) pObj )->GetGraphic();
+ if ( pGraphic )
+ aGraphic = *pGraphic;
+ }
+
+ ScIMapDlgSet( aGraphic, pImageMap, &aTargetList, pObj ); // aus imapwrap
+
+ // TargetListe kann von uns wieder geloescht werden
+ String* pEntry = aTargetList.First();
+ while( pEntry )
+ {
+ delete pEntry;
+ pEntry = aTargetList.Next();
+ }
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawvie4.cxx b/sc/source/ui/view/drawvie4.cxx
new file mode 100644
index 000000000000..8a848fbc341c
--- /dev/null
+++ b/sc/source/ui/view/drawvie4.cxx
@@ -0,0 +1,358 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <svx/svditer.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/docfile.hxx>
+#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include "drawview.hxx"
+#include "global.hxx"
+#include "drwlayer.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "drwtrans.hxx"
+#include "transobj.hxx" // SetDrawClipDoc
+#include "drawutil.hxx"
+#include "scmod.hxx"
+#include "globstr.hrc"
+#include "chartarr.hxx"
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+Point aDragStartDiff;
+
+// -----------------------------------------------------------------------
+
+//! welche Funktionen aus drawview/drawvie4 muessen wirklich ohne Optimierung sein?
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+// -----------------------------------------------------------------------
+
+void lcl_CheckOle( const SdrMarkList& rMarkList, BOOL& rAnyOle, BOOL& rOneOle )
+{
+ rAnyOle = rOneOle = FALSE;
+ ULONG nCount = rMarkList.GetMarkCount();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ SdrMark* pMark = rMarkList.GetMark(i);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ UINT16 nSdrObjKind = pObj->GetObjIdentifier();
+ if (nSdrObjKind == OBJ_OLE2)
+ {
+ rAnyOle = TRUE;
+ rOneOle = (nCount == 1);
+ break;
+ }
+ else if ( pObj->ISA(SdrObjGroup) )
+ {
+ SdrObjListIter aIter( *pObj, IM_DEEPNOGROUPS );
+ SdrObject* pSubObj = aIter.Next();
+ while (pSubObj)
+ {
+ if ( pSubObj->GetObjIdentifier() == OBJ_OLE2 )
+ {
+ rAnyOle = TRUE;
+ // rOneOle remains FALSE - a group isn't treated like a single OLE object
+ return;
+ }
+ pSubObj = aIter.Next();
+ }
+ }
+ }
+}
+
+BOOL ScDrawView::BeginDrag( Window* pWindow, const Point& rStartPos )
+{
+ BOOL bReturn = FALSE;
+
+ if ( AreObjectsMarked() )
+ {
+ BrkAction();
+
+ Rectangle aMarkedRect = GetAllMarkedRect();
+ Region aRegion( aMarkedRect );
+
+ aDragStartDiff = rStartPos - aMarkedRect.TopLeft();
+
+ BOOL bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ ScDocShellRef aDragShellRef;
+ if (bAnyOle)
+ {
+ aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately
+ aDragShellRef->DoInitNew(NULL);
+ }
+ ScDrawLayer::SetGlobalDrawPersist(aDragShellRef);
+ SdrModel* pModel = GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ // Charts now always copy their data in addition to the source reference, so
+ // there's no need to call SchDLL::Update for the charts in the clipboard doc.
+ // Update with the data (including NumberFormatter) from the live document would
+ // also store the NumberFormatter in the clipboard chart (#88749#)
+ // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ pTransferObj->SetDrawPersist( &aDragShellRef ); // keep persist for ole objects alive
+ pTransferObj->SetDragSource( this ); // copies selection
+
+ SC_MOD()->SetDragObject( NULL, pTransferObj ); // for internal D&D
+ pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+ }
+
+ return bReturn;
+}
+
+void ScDrawView::DoCopy()
+{
+ BOOL bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ // update ScGlobal::pDrawClipDocShellRef
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ SdrModel* pModel = GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ // Charts now always copy their data in addition to the source reference, so
+ // there's no need to call SchDLL::Update for the charts in the clipboard doc.
+ // Update with the data (including NumberFormatter) from the live document would
+ // also store the NumberFormatter in the clipboard chart (#88749#)
+ // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) ); // keep persist for ole objects alive
+ }
+
+ pTransferObj->CopyToClipboard( pViewData->GetActiveWin() ); // system clipboard
+ SC_MOD()->SetClipObject( NULL, pTransferObj ); // internal clipboard
+}
+
+uno::Reference<datatransfer::XTransferable> ScDrawView::CopyToTransferable()
+{
+ BOOL bAnyOle, bOneOle;
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ lcl_CheckOle( rMarkList, bAnyOle, bOneOle );
+
+ // update ScGlobal::pDrawClipDocShellRef
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ SdrModel* pModel = GetAllMarkedModel();
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ // Charts now always copy their data in addition to the source reference, so
+ // there's no need to call SchDLL::Update for the charts in the clipboard doc.
+ // Update with the data (including NumberFormatter) from the live document would
+ // also store the NumberFormatter in the clipboard chart (#88749#)
+ // lcl_RefreshChartData( pModel, pViewData->GetDocument() );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScDrawTransferObj ctor
+
+ ScDrawTransferObj* pTransferObj = new ScDrawTransferObj( pModel, pDocSh, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ pTransferObj->SetDrawPersist( &(*ScGlobal::pDrawClipDocShellRef) ); // keep persist for ole objects alive
+ }
+
+ return xTransferable;
+}
+
+// Korrektur fuer 100% berechnen, unabhaengig von momentanen Einstellungen
+
+void ScDrawView::CalcNormScale( Fraction& rFractX, Fraction& rFractY ) const
+{
+ Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
+ double nPPTX = ScGlobal::nScreenPPTX;
+ double nPPTY = ScGlobal::nScreenPPTY;
+
+ if (pViewData)
+ nPPTX /= pViewData->GetDocShell()->GetOutputFactor();
+
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pDoc->GetTableArea( nTab, nEndCol, nEndRow );
+ if (nEndCol<20)
+ nEndCol = 20;
+ if (nEndRow<20)
+ nEndRow = 1000;
+
+ Fraction aZoom(1,1);
+ ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev, aZoom,aZoom,
+ nPPTX, nPPTY, rFractX,rFractY );
+}
+
+void ScDrawView::SetMarkedOriginalSize()
+{
+ SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*GetModel());
+
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ long nDone = 0;
+ ULONG nCount = rMarkList.GetMarkCount();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ USHORT nIdent = pObj->GetObjIdentifier();
+ BOOL bDo = FALSE;
+ Size aOriginalSize;
+ if (nIdent == OBJ_OLE2)
+ {
+ // TODO/LEAN: working with visual area can switch object to running state
+ uno::Reference < embed::XEmbeddedObject > xObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
+ if ( xObj.is() ) // #121612# NULL for an invalid object that couldn't be loaded
+ {
+ sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
+
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ {
+ MapMode aMapMode( MAP_100TH_MM );
+ aOriginalSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMapMode );
+ bDo = TRUE;
+ }
+ else
+ {
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( ((SdrOle2Obj*)pObj)->GetAspect() ) );
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( ((SdrOle2Obj*)pObj)->GetAspect() );
+ aOriginalSize = OutputDevice::LogicToLogic(
+ Size( aSz.Width, aSz.Height ),
+ aUnit, MAP_100TH_MM );
+ bDo = TRUE;
+ } catch( embed::NoVisualAreaSizeException& )
+ {
+ OSL_ENSURE( sal_False, "Can't get the original size of the object!" );
+ }
+ }
+ }
+ }
+ else if (nIdent == OBJ_GRAF)
+ {
+ const Graphic& rGraphic = ((SdrGrafObj*)pObj)->GetGraphic();
+
+ MapMode aSourceMap = rGraphic.GetPrefMapMode();
+ MapMode aDestMap( MAP_100TH_MM );
+ if (aSourceMap.GetMapUnit() == MAP_PIXEL)
+ {
+ // Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt
+
+ Fraction aNormScaleX, aNormScaleY;
+ CalcNormScale( aNormScaleX, aNormScaleY );
+ aDestMap.SetScaleX(aNormScaleX);
+ aDestMap.SetScaleY(aNormScaleY);
+ }
+ if (pViewData)
+ {
+ Window* pActWin = pViewData->GetActiveWin();
+ if (pActWin)
+ {
+ aOriginalSize = pActWin->LogicToLogic(
+ rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
+ bDo = TRUE;
+ }
+ }
+ }
+
+ if ( bDo )
+ {
+ Rectangle aDrawRect = pObj->GetLogicRect();
+
+ pUndoGroup->AddAction( new SdrUndoGeoObj( *pObj ) );
+ pObj->Resize( aDrawRect.TopLeft(), Fraction( aOriginalSize.Width(), aDrawRect.GetWidth() ),
+ Fraction( aOriginalSize.Height(), aDrawRect.GetHeight() ) );
+ ++nDone;
+ }
+ }
+
+ if (nDone)
+ {
+ pUndoGroup->SetComment(ScGlobal::GetRscString( STR_UNDO_ORIGINALSIZE ));
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ pDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
+ pDocSh->SetDrawModified();
+ }
+ else
+ delete pUndoGroup;
+}
+
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/drawview.cxx b/sc/source/ui/view/drawview.cxx
new file mode 100644
index 000000000000..8a8211442b65
--- /dev/null
+++ b/sc/source/ui/view/drawview.cxx
@@ -0,0 +1,810 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <com/sun/star/embed/EmbedStates.hpp>
+
+#include <svx/svditer.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdocapt.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "drawview.hxx"
+#include "global.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "drawutil.hxx"
+#include "futext.hxx"
+#include "globstr.hrc"
+#include "tabvwsh.hxx"
+#include "client.hxx"
+#include "scmod.hxx"
+#include "drwlayer.hxx"
+#include "docsh.hxx"
+#include "viewuno.hxx"
+#include "userdat.hxx"
+#include "postit.hxx"
+#include "undocell.hxx"
+
+#include "sc.hrc"
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+#define SC_HANDLESIZE_BIG 9
+#define SC_HANDLESIZE_SMALL 7
+
+// -----------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+
+void ScDrawView::Construct()
+{
+ EnableExtendedKeyInputDispatcher(FALSE);
+ EnableExtendedMouseEventDispatcher(FALSE);
+ EnableExtendedCommandEventDispatcher(FALSE);
+
+ SetFrameDragSingles(TRUE);
+// SetSolidMarkHdl(TRUE); // einstellbar -> UpdateUserViewOptions
+
+ SetMinMoveDistancePixel( 2 );
+ SetHitTolerancePixel( 2 );
+
+ if (pViewData)
+ {
+ SCTAB nViewTab = pViewData->GetTabNo();
+ ShowSdrPage(GetModel()->GetPage(nViewTab));
+
+ BOOL bEx = pViewData->GetViewShell()->IsDrawSelMode();
+ BOOL bProt = pDoc->IsTabProtected( nViewTab ) ||
+ pViewData->GetSfxDocShell()->IsReadOnly();
+
+ SdrLayer* pLayer;
+ SdrLayerAdmin& rAdmin = GetModel()->GetLayerAdmin();
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
+ if (pLayer)
+ SetLayerLocked( pLayer->GetName(), bProt || !bEx );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
+ if (pLayer)
+ SetLayerLocked( pLayer->GetName(), TRUE );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
+ if (pLayer)
+ {
+ SetLayerLocked( pLayer->GetName(), bProt );
+ SetActiveLayer( pLayer->GetName() ); // FRONT als aktiven Layer setzen
+ }
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
+ if (pLayer)
+ SetLayerLocked( pLayer->GetName(), bProt );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
+ if (pLayer)
+ {
+ SetLayerLocked( pLayer->GetName(), bProt );
+ SetLayerVisible( pLayer->GetName(), sal_False);
+ }
+
+ SetSwapAsynchron(TRUE);
+ }
+ else
+ {
+ ShowSdrPage(GetModel()->GetPage(nTab));
+ }
+
+ UpdateUserViewOptions();
+ RecalcScale();
+ UpdateWorkArea();
+
+ bInConstruct = FALSE;
+}
+
+void ScDrawView::ImplClearCalcDropMarker()
+{
+ if(pDropMarker)
+ {
+ delete pDropMarker;
+ pDropMarker = 0L;
+ }
+}
+
+__EXPORT ScDrawView::~ScDrawView()
+{
+ ImplClearCalcDropMarker();
+}
+
+void ScDrawView::AddCustomHdl()
+{
+ BOOL bNegativePage = pDoc->IsNegativePage( nTab );
+
+ const SdrMarkList &rMrkList = GetMarkedObjectList();
+ UINT32 nCount = rMrkList.GetMarkCount();
+ for(UINT32 nPos=0; nPos<nCount; nPos++ )
+ {
+ const SdrObject* pObj = rMrkList.GetMark(nPos)->GetMarkedSdrObj();
+ if(ScDrawLayer::GetAnchor(pObj) == SCA_CELL)
+ {
+ const INT32 nDelta = 1;
+
+ Rectangle aBoundRect = pObj->GetCurrentBoundRect();
+ Point aPos;
+ if (bNegativePage)
+ {
+ aPos = aBoundRect.TopRight();
+ aPos.X() = -aPos.X(); // so the loop below is the same
+ }
+ else
+ aPos = aBoundRect.TopLeft();
+ long nPosX = (long) (aPos.X() / HMM_PER_TWIPS) + nDelta;
+ long nPosY = (long) (aPos.Y() / HMM_PER_TWIPS) + nDelta;
+
+ SCCOL nCol;
+ INT32 nWidth = 0;
+
+ for(nCol=0; nCol<=MAXCOL && nWidth<=nPosX; nCol++)
+ nWidth += pDoc->GetColWidth(nCol,nTab);
+
+ if(nCol > 0)
+ --nCol;
+
+ SCROW nRow = nPosY <= 0 ? 0 : pDoc->GetRowForHeight( nTab,
+ (ULONG) nPosY);
+ if(nRow > 0)
+ --nRow;
+
+ ScTabView* pView = pViewData->GetView();
+ ScAddress aScAddress(nCol, nRow, nTab);
+ pView->CreateAnchorHandles(aHdl, aScAddress);
+ }
+ }
+}
+
+void ScDrawView::InvalidateAttribs()
+{
+ if (!pViewData) return;
+ SfxBindings& rBindings = pViewData->GetBindings();
+
+ // echte Statuswerte:
+ rBindings.InvalidateAll( TRUE );
+}
+
+void ScDrawView::InvalidateDrawTextAttrs()
+{
+ if (!pViewData) return;
+ SfxBindings& rBindings = pViewData->GetBindings();
+
+ // cjk/ctl font items have no configured slots,
+ // need no invalidate
+
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+ rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
+ rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
+ rBindings.Invalidate( SID_ALIGNLEFT );
+ rBindings.Invalidate( SID_ALIGNCENTERHOR );
+ rBindings.Invalidate( SID_ALIGNRIGHT );
+ rBindings.Invalidate( SID_ALIGNBLOCK );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 );
+ rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 );
+ rBindings.Invalidate( SID_SET_SUPER_SCRIPT );
+ rBindings.Invalidate( SID_SET_SUB_SCRIPT );
+ rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ // pseudo slots for Format menu
+ rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
+ rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
+ rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+}
+
+//void ScDrawView::DrawMarks( OutputDevice* pOut ) const
+//{
+// DBG_ASSERT(pOut, "ScDrawView::DrawMarks: No OutputDevice (!)");
+// SdrPaintWindow* pPaintWindow = FindPaintWindow(*pOut);
+//
+// if(pPaintWindow)
+// {
+// if(pPaintWindow->isXorVisible())
+// {
+// ToggleShownXor(pOut, 0L);
+// }
+// }
+//}
+
+void ScDrawView::SetMarkedToLayer( BYTE nLayerNo )
+{
+ if (AreObjectsMarked())
+ {
+ // #i11702# use SdrUndoObjectLayerChange for undo
+ // STR_UNDO_SELATTR is "Attributes" - should use a different text later
+ BegUndo( ScGlobal::GetRscString( STR_UNDO_SELATTR ) );
+
+ const SdrMarkList& rMark = GetMarkedObjectList();
+ ULONG nCount = rMark.GetMarkCount();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj();
+ if ( !pObj->ISA(SdrUnoObj) && (pObj->GetLayer() != SC_LAYER_INTERN) )
+ {
+ AddUndo( new SdrUndoObjectLayerChange( *pObj, pObj->GetLayer(), (SdrLayerID)nLayerNo) );
+ pObj->SetLayer( nLayerNo );
+ }
+ }
+
+ EndUndo();
+
+ // repaint is done in SetLayer
+
+ pViewData->GetDocShell()->SetDrawModified();
+
+ // #84073# check mark list now instead of later in a timer
+ CheckMarked();
+ MarkListHasChanged();
+ }
+}
+
+bool ScDrawView::HasMarkedControl() const
+{
+ SdrObjListIter aIter( GetMarkedObjectList() );
+ for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
+ if( pObj->ISA( SdrUnoObj ) )
+ return true;
+ return false;
+}
+
+bool ScDrawView::HasMarkedInternal() const
+{
+ // internal objects should not be inside a group, but who knows...
+ SdrObjListIter aIter( GetMarkedObjectList() );
+ for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() )
+ if( pObj->GetLayer() == SC_LAYER_INTERN )
+ return true;
+ return false;
+}
+
+void ScDrawView::UpdateWorkArea()
+{
+ SdrPage* pPage = GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
+ if (pPage)
+ {
+ Point aPos;
+ Size aPageSize( pPage->GetSize() );
+ Rectangle aNewArea( aPos, aPageSize );
+ if ( aPageSize.Width() < 0 )
+ {
+ // RTL: from max.negative (left) to zero (right)
+ aNewArea.Right() = 0;
+ aNewArea.Left() = aPageSize.Width() + 1;
+ }
+ SetWorkArea( aNewArea );
+ }
+ else
+ {
+ DBG_ERROR("Page nicht gefunden");
+ }
+}
+
+void ScDrawView::DoCut()
+{
+ DoCopy();
+ BegUndo( ScGlobal::GetRscString( STR_UNDO_CUT ) );
+ DeleteMarked(); // auf dieser View - von der 505f Umstellung nicht betroffen
+ EndUndo();
+}
+
+void ScDrawView::GetScale( Fraction& rFractX, Fraction& rFractY ) const
+{
+ rFractX = aScaleX;
+ rFractY = aScaleY;
+}
+
+void ScDrawView::RecalcScale()
+{
+ double nPPTX;
+ double nPPTY;
+ Fraction aZoomX(1,1);
+ Fraction aZoomY(1,1);
+
+ if (pViewData)
+ {
+ nTab = pViewData->GetTabNo();
+ nPPTX = pViewData->GetPPTX();
+ nPPTY = pViewData->GetPPTY();
+ aZoomX = pViewData->GetZoomX();
+ aZoomY = pViewData->GetZoomY();
+ }
+ else
+ {
+ Point aLogic = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP );
+ nPPTX = aLogic.X() / 1000.0;
+ nPPTY = aLogic.Y() / 1000.0;
+ //! Zoom uebergeben ???
+ }
+
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pDoc->GetTableArea( nTab, nEndCol, nEndRow );
+ if (nEndCol<20)
+ nEndCol = 20;
+ if (nEndRow<20)
+ nEndRow = 1000;
+
+ ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, pDev,aZoomX,aZoomY,nPPTX,nPPTY,
+ aScaleX,aScaleY );
+}
+
+void ScDrawView::DoConnect(SdrOle2Obj* pOleObj)
+{
+ if ( pViewData )
+ pViewData->GetViewShell()->ConnectObject( pOleObj );
+}
+
+void ScDrawView::MarkListHasChanged()
+{
+ FmFormView::MarkListHasChanged();
+
+ UpdateBrowser();
+
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ // #i110829# remove the cell selection only if drawing objects are selected
+ if ( !bInConstruct && GetMarkedObjectList().GetMarkCount() )
+ {
+ pViewSh->Unmark(); // remove cell selection
+
+ // #65379# end cell edit mode if drawing objects are selected
+ SC_MOD()->InputEnterHandler();
+ }
+
+ // IP deaktivieren
+
+ ScModule* pScMod = SC_MOD();
+ bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
+
+ ScClient* pClient = (ScClient*) pViewSh->GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
+ {
+ // #41730# beim ViewShell::Activate aus dem Reset2Open nicht die Handles anzeigen
+ //HMHbDisableHdl = TRUE;
+ pClient->DeactivateObject();
+ //HMHbDisableHdl = FALSE;
+ // Image-Ole wieder durch Grafik ersetzen passiert jetzt in ScClient::UIActivate
+ }
+
+ // Ole-Objekt selektiert?
+
+ SdrOle2Obj* pOle2Obj = NULL;
+ SdrGrafObj* pGrafObj = NULL;
+ SdrMediaObj* pMediaObj = NULL;
+
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ ULONG nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount == 0 && !pViewData->GetViewShell()->IsDrawSelMode() && !bInConstruct )
+ {
+ // relock layers that may have been unlocked before
+ LockBackgroundLayer();
+ LockInternalLayer();
+ }
+
+ BOOL bSubShellSet = FALSE;
+ if (nMarkCount == 1)
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if (pObj->GetObjIdentifier() == OBJ_OLE2)
+ {
+ pOle2Obj = (SdrOle2Obj*) pObj;
+ if (!pDoc->IsChart(pObj) )
+ pViewSh->SetOleObjectShell(TRUE);
+ else
+ pViewSh->SetChartShell(TRUE);
+ bSubShellSet = TRUE;
+ }
+ else if (pObj->GetObjIdentifier() == OBJ_GRAF)
+ {
+ pGrafObj = (SdrGrafObj*) pObj;
+ pViewSh->SetGraphicShell(TRUE);
+ bSubShellSet = TRUE;
+ }
+ else if (pObj->GetObjIdentifier() == OBJ_MEDIA)
+ {
+ pMediaObj = (SdrMediaObj*) pObj;
+ pViewSh->SetMediaShell(TRUE);
+ bSubShellSet = TRUE;
+ }
+ else if (pObj->GetObjIdentifier() != OBJ_TEXT // Verhindern, das beim Anlegen
+ || !pViewSh->IsDrawTextShell()) // eines TextObjekts auf die
+ { // DrawShell umgeschaltet wird.
+ pViewSh->SetDrawShell(TRUE); //@#70206#
+ }
+ }
+
+ if ( nMarkCount && !bSubShellSet )
+ {
+ BOOL bOnlyControls = TRUE;
+ BOOL bOnlyGraf = TRUE;
+ for (ULONG i=0; i<nMarkCount; i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ if ( pObj->ISA( SdrObjGroup ) )
+ {
+ const SdrObjList *pLst = ((SdrObjGroup*)pObj)->GetSubList();
+ ULONG nListCount = pLst->GetObjCount();
+ if ( nListCount == 0 )
+ {
+ // #104156# An empty group (may occur during Undo) is no control or graphics object.
+ // Creating the form shell during undo would lead to problems with the undo manager.
+ bOnlyControls = FALSE;
+ bOnlyGraf = FALSE;
+ }
+ for ( USHORT j = 0; j < nListCount; ++j )
+ {
+ SdrObject *pSubObj = pLst->GetObj( j );
+
+ if (!pSubObj->ISA(SdrUnoObj))
+ bOnlyControls = FALSE;
+ if (pSubObj->GetObjIdentifier() != OBJ_GRAF)
+ bOnlyGraf = FALSE;
+
+ if ( !bOnlyControls && !bOnlyGraf ) break;
+ }
+ }
+ else
+ {
+ if (!pObj->ISA(SdrUnoObj))
+ bOnlyControls = FALSE;
+ if (pObj->GetObjIdentifier() != OBJ_GRAF)
+ bOnlyGraf = FALSE;
+ }
+
+ if ( !bOnlyControls && !bOnlyGraf ) break;
+ }
+
+ if(bOnlyControls)
+ {
+ pViewSh->SetDrawFormShell(TRUE); // jetzt UNO-Controls
+ }
+ else if(bOnlyGraf)
+ {
+ pViewSh->SetGraphicShell(TRUE);
+ }
+ else if(nMarkCount>1)
+ {
+ pViewSh->SetDrawShell(TRUE);
+ }
+ }
+
+
+
+ // Verben anpassen
+
+ SfxViewFrame* pViewFrame = pViewSh->GetViewFrame();
+ BOOL bOle = pViewSh->GetViewFrame()->GetFrame().IsInPlace();
+ if ( pOle2Obj && !bOle )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = pOle2Obj->GetObjRef();
+ if (xObj.is())
+ pViewSh->SetVerbs( xObj->getSupportedVerbs() );
+ else
+ {
+ DBG_ERROR("SdrOle2Obj ohne ObjRef");
+ pViewSh->SetVerbs( 0 );
+ }
+ }
+ else
+ pViewSh->SetVerbs( 0 );
+
+ // Image-Map Editor
+
+ if ( pOle2Obj )
+ UpdateIMap( pOle2Obj );
+ else if ( pGrafObj )
+ UpdateIMap( pGrafObj );
+
+ InvalidateAttribs(); // nach dem IMap-Editor Update
+ InvalidateDrawTextAttrs();
+
+ for(sal_uInt32 a(0L); a < PaintWindowCount(); a++)
+ {
+ SdrPaintWindow* pPaintWindow = GetPaintWindow(a);
+ OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
+
+ if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
+ {
+ ((Window&)rOutDev).Update();
+ }
+ }
+
+ // uno object for view returns drawing objects as selection,
+ // so it must notify its SelectionChangeListeners
+
+ if (pViewFrame)
+ {
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ uno::Reference<frame::XController> xController = rFrame.GetController();
+ if (xController.is())
+ {
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SelectionChanged();
+ }
+ }
+
+ // update selection transfer object
+
+ pViewSh->CheckSelectionTransfer();
+
+}
+
+void __EXPORT ScDrawView::ModelHasChanged()
+{
+ SdrObject* pEditObj = GetTextEditObject();
+ if ( pEditObj && !pEditObj->IsInserted() && pViewData )
+ {
+ // #111700# SdrObjEditView::ModelHasChanged will end text edit in this case,
+ // so make sure the EditEngine's undo manager is no longer used.
+ pViewData->GetViewShell()->SetDrawTextUndo(NULL);
+ SetCreateMode(); // don't leave FuText in a funny state
+ }
+
+ FmFormView::ModelHasChanged();
+}
+
+void __EXPORT ScDrawView::UpdateUserViewOptions()
+{
+ if (pViewData)
+ {
+ const ScViewOptions& rOpt = pViewData->GetOptions();
+ const ScGridOptions& rGrid = rOpt.GetGridOptions();
+
+ BOOL bBigHdl = rOpt.GetOption( VOPT_BIGHANDLES );
+
+ SetDragStripes( rOpt.GetOption( VOPT_HELPLINES ) );
+ SetSolidMarkHdl( rOpt.GetOption( VOPT_SOLIDHANDLES ) );
+ SetMarkHdlSizePixel( bBigHdl ? SC_HANDLESIZE_BIG : SC_HANDLESIZE_SMALL );
+
+ SetGridVisible( rGrid.GetGridVisible() );
+ SetSnapEnabled( rGrid.GetUseGridSnap() );
+ SetGridSnap( rGrid.GetUseGridSnap() );
+
+ // Snap from grid options is no longer used
+// SetSnapGrid( Size( rGrid.GetFldSnapX(), rGrid.GetFldSnapY() ) );
+
+ Fraction aFractX( rGrid.GetFldDrawX(), rGrid.GetFldDivisionX() + 1 );
+ Fraction aFractY( rGrid.GetFldDrawY(), rGrid.GetFldDivisionY() + 1 );
+ SetSnapGridWidth( aFractX, aFractY );
+
+ SetGridCoarse( Size( rGrid.GetFldDrawX(), rGrid.GetFldDrawY() ) );
+ SetGridFine( Size( rGrid.GetFldDrawX() / (rGrid.GetFldDivisionX() + 1),
+ rGrid.GetFldDrawY() / (rGrid.GetFldDivisionY() + 1) ) );
+ }
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+BOOL ScDrawView::SelectObject( const String& rName )
+{
+ UnmarkAll();
+
+ SCTAB nObjectTab = 0;
+ SdrObject* pFound = NULL;
+
+ SfxObjectShell* pShell = pDoc->GetDocumentShell();
+ if (pShell)
+ {
+ SdrModel* pDrawLayer = GetModel();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount && !pFound; i++)
+ {
+ SdrPage* pPage = pDrawLayer->GetPage(static_cast<sal_uInt16>(i));
+ DBG_ASSERT(pPage,"Page ?");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject && !pFound)
+ {
+ if ( ScDrawLayer::GetVisibleName( pObject ) == rName )
+ {
+ pFound = pObject;
+ nObjectTab = i;
+ }
+ pObject = aIter.Next();
+ }
+ }
+ }
+ }
+
+ if ( pFound )
+ {
+ ScTabView* pView = pViewData->GetView();
+ if ( nObjectTab != nTab ) // Tabelle umschalten
+ pView->SetTabNo( nObjectTab );
+
+ DBG_ASSERT( nTab == nObjectTab, "Tabellen umschalten hat nicht geklappt" );
+
+ pView->ScrollToObject( pFound );
+
+ /* #61585# To select an object on the background layer, the layer has to
+ be unlocked even if exclusive drawing selection mode is not active
+ (this is reversed in MarkListHasChanged when nothing is selected) */
+ if ( pFound->GetLayer() == SC_LAYER_BACK &&
+ !pViewData->GetViewShell()->IsDrawSelMode() &&
+ !pDoc->IsTabProtected( nTab ) &&
+ !pViewData->GetSfxDocShell()->IsReadOnly() )
+ {
+ UnlockBackgroundLayer();
+ }
+
+ SdrPageView* pPV = GetSdrPageView();
+ MarkObj( pFound, pPV );
+ }
+
+ return ( pFound != NULL );
+}
+
+
+bool ScDrawView::InsertObjectSafe(SdrObject* pObj, SdrPageView& rPV, ULONG nOptions)
+{
+ // Markierung nicht aendern, wenn Ole-Objekt aktiv
+ // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
+
+ if (pViewData)
+ {
+ SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() )
+ nOptions |= SDRINSERT_DONTMARK;
+ }
+
+ return InsertObjectAtView( pObj, rPV, nOptions );
+}
+
+SdrObject* ScDrawView::GetMarkedNoteCaption( ScDrawObjData** ppCaptData )
+{
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ if( pViewData && (rMarkList.GetMarkCount() == 1) )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ if( ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, pViewData->GetTabNo() ) )
+ {
+ if( ppCaptData ) *ppCaptData = pCaptData;
+ return pObj;
+ }
+ }
+ return 0;
+}
+
+void ScDrawView::LockCalcLayer( SdrLayerID nLayer, bool bLock )
+{
+ SdrLayer* pLockLayer = GetModel()->GetLayerAdmin().GetLayerPerID( nLayer );
+ if( pLockLayer && (IsLayerLocked( pLockLayer->GetName() ) != bLock) )
+ SetLayerLocked( pLockLayer->GetName(), bLock );
+}
+
+void __EXPORT ScDrawView::MakeVisible( const Rectangle& rRect, Window& rWin )
+{
+ //! rWin richtig auswerten
+ //! ggf Zoom aendern
+
+ if ( pViewData && pViewData->GetActiveWin() == &rWin )
+ pViewData->GetView()->MakeVisible( rRect );
+}
+
+void ScDrawView::DeleteMarked()
+{
+ // try to delete a note caption object with its cell note in the Calc document
+ ScDrawObjData* pCaptData = 0;
+ if( SdrObject* pCaptObj = GetMarkedNoteCaption( &pCaptData ) )
+ {
+ (void)pCaptObj; // prevent 'unused variable' compiler warning in pro builds
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ ScDocShell* pDocShell = pViewData ? pViewData->GetDocShell() : 0;
+ SfxUndoManager* pUndoMgr = pDocShell ? pDocShell->GetUndoManager() : 0;
+ bool bUndo = pDrawLayer && pDocShell && pUndoMgr && pDoc->IsUndoEnabled();
+
+ // remove the cell note from document, we are its owner now
+ ScPostIt* pNote = pDoc->ReleaseNote( pCaptData->maStart );
+ DBG_ASSERT( pNote, "ScDrawView::DeleteMarked - cell note missing in document" );
+ if( pNote )
+ {
+ // rescue note data for undo (with pointer to caption object)
+ ScNoteData aNoteData = pNote->GetNoteData();
+ DBG_ASSERT( aNoteData.mpCaption == pCaptObj, "ScDrawView::DeleteMarked - caption object does not match" );
+ // collect the drawing undo action created while deleting the note
+ if( bUndo )
+ pDrawLayer->BeginCalcUndo();
+ // delete the note (already removed from document above)
+ delete pNote;
+ // add the undo action for the note
+ if( bUndo )
+ pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, pCaptData->maStart, aNoteData, false, pDrawLayer->GetCalcUndo() ) );
+ // repaint the cell to get rid of the note marker
+ if( pDocShell )
+ pDocShell->PostPaintCell( pCaptData->maStart );
+ // done, return now to skip call of FmFormView::DeleteMarked()
+ return;
+ }
+ }
+
+ FmFormView::DeleteMarked();
+}
+
+SdrEndTextEditKind ScDrawView::ScEndTextEdit()
+{
+ BOOL bIsTextEdit = IsTextEdit();
+ SdrEndTextEditKind eKind = SdrEndTextEdit();
+
+ if ( bIsTextEdit && pViewData )
+ pViewData->GetViewShell()->SetDrawTextUndo(NULL); // "normaler" Undo-Manager
+
+ return eKind;
+}
+
+void ScDrawView::MarkDropObj( SdrObject* pObj )
+{
+ if ( pDropMarkObj != pObj )
+ {
+ pDropMarkObj = pObj;
+ ImplClearCalcDropMarker();
+
+ if(pDropMarkObj)
+ {
+ pDropMarker = new SdrDropMarkerOverlay(*this, *pDropMarkObj);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
new file mode 100644
index 000000000000..bc038a01e449
--- /dev/null
+++ b/sc/source/ui/view/editsh.cxx
@@ -0,0 +1,1202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <svx/clipfmtitem.hxx>
+#include <svx/svxdlg.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/fontitem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/shdditem.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sot/exchange.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <sot/formats.hxx>
+#include <svtools/transfer.hxx>
+#include <svl/stritem.hxx>
+
+#define _EDITSH_CXX
+#include "editsh.hxx"
+
+#include "scresid.hxx"
+#include "global.hxx"
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "viewutil.hxx"
+#include "viewdata.hxx"
+#include "document.hxx"
+#include "reffind.hxx"
+#include "tabvwsh.hxx"
+#include "editutil.hxx"
+#include "globstr.hrc"
+
+#define ScEditShell
+#include "scslots.hxx"
+
+#include "scui_def.hxx"
+#include "scabstdlg.hxx"
+
+
+using namespace ::com::sun::star;
+
+
+TYPEINIT1( ScEditShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScEditShell, SfxShell, ScResId(SCSTR_EDITSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_EDIT) );
+}
+
+
+ScEditShell::ScEditShell(EditView* pView, ScViewData* pData) :
+ pEditView (pView),
+ pViewData (pData),
+ pClipEvtLstnr (NULL),
+ bPastePossible (FALSE),
+ bIsInsertMode (TRUE)
+{
+ SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
+ SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("EditCell")));
+}
+
+ScEditShell::~ScEditShell()
+{
+ if ( pClipEvtLstnr )
+ {
+ pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), FALSE );
+
+ // #122057# The listener may just now be waiting for the SolarMutex and call the link
+ // afterwards, in spite of RemoveListener. So the link has to be reset, too.
+ pClipEvtLstnr->ClearCallbackLink();
+
+ pClipEvtLstnr->release();
+ }
+}
+
+ScInputHandler* ScEditShell::GetMyInputHdl()
+{
+ return SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
+}
+
+void ScEditShell::SetEditView(EditView* pView)
+{
+ pEditView = pView;
+ pEditView->SetInsertMode( bIsInsertMode );
+ SetPool( pEditView->GetEditEngine()->GetEmptyItemSet().GetPool() );
+ SetUndoManager( &pEditView->GetEditEngine()->GetUndoManager() );
+}
+
+void lcl_RemoveAttribs( EditView& rEditView )
+{
+ ScEditEngineDefaulter* pEngine = static_cast<ScEditEngineDefaulter*>(rEditView.GetEditEngine());
+
+ BOOL bOld = pEngine->GetUpdateMode();
+ pEngine->SetUpdateMode(FALSE);
+
+ String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS );
+ pEngine->GetUndoManager().EnterListAction( aName, aName );
+
+ rEditView.RemoveAttribs(TRUE);
+ pEngine->RepeatDefaults(); // #97226# paragraph attributes from cell formats must be preserved
+
+ pEngine->GetUndoManager().LeaveListAction();
+
+ pEngine->SetUpdateMode(bOld);
+}
+
+void lclInsertCharacter( EditView* pTableView, EditView* pTopView, sal_Unicode cChar )
+{
+ String aString( cChar );
+ if( pTableView )
+ pTableView->InsertText( aString );
+ if( pTopView )
+ pTopView->InsertText( aString );
+}
+
+void ScEditShell::Execute( SfxRequest& rReq )
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ SfxBindings& rBindings = pViewData->GetBindings();
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT(pHdl,"kein ScInputHandler");
+
+ EditView* pTopView = pHdl->GetTopView(); // hat Eingabezeile den Focus?
+ EditView* pTableView = pHdl->GetTableView();
+
+ DBG_ASSERT(pTableView,"no EditView :-(");
+ /* #i91683# No EditView if spell-check dialog is active and positioned on
+ * an error and user immediately (without double click or F2) selected a
+ * text portion of that cell with the mouse and wanted to modify it. */
+ /* FIXME: Bailing out only cures the symptom and prevents a crash, no edit
+ * action is possible. A real fix somehow would need to create a valid
+ * EditView from the spell-check view. */
+ if (!pTableView)
+ return;
+
+ EditEngine* pEngine = pTableView->GetEditEngine();
+
+ pHdl->DataChanging();
+ BOOL bSetSelIsRef = FALSE;
+
+ switch ( nSlot )
+ {
+ case FID_INS_CELL_CONTENTS: // Insert-Taste, weil als Acc definiert
+ bIsInsertMode = !pTableView->IsInsertMode();
+ pTableView->SetInsertMode( bIsInsertMode );
+ if (pTopView)
+ pTopView->SetInsertMode( bIsInsertMode );
+ rBindings.Invalidate( SID_ATTR_INSERT );
+ break;
+
+ case SID_ATTR_INSERT:
+ if ( pReqArgs )
+ {
+ bIsInsertMode = ((const SfxBoolItem&)pReqArgs->Get(nSlot)).GetValue();
+ pTableView->SetInsertMode( bIsInsertMode );
+ if (pTopView)
+ pTopView->SetInsertMode( bIsInsertMode );
+ rBindings.Invalidate( SID_ATTR_INSERT );
+ }
+ break;
+
+ case SID_THES:
+ {
+ String aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES , sal_False );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (aReplaceText.Len() > 0)
+ ReplaceTextWithSynonym( *pEditView, aReplaceText );
+ }
+ break;
+
+ case SID_COPY:
+ pTableView->Copy();
+ break;
+
+ case SID_CUT:
+ pTableView->Cut();
+ if (pTopView)
+ pTopView->DeleteSelected();
+ break;
+
+ case SID_PASTE:
+ pTableView->PasteSpecial();
+ if (pTopView)
+ pTopView->Paste();
+ break;
+
+ case SID_DELETE:
+ pTableView->DeleteSelected();
+ if (pTopView)
+ pTopView->DeleteSelected();
+ break;
+
+ case SID_CELL_FORMAT_RESET: // "Standard"
+ lcl_RemoveAttribs( *pTableView );
+ if ( pTopView )
+ lcl_RemoveAttribs( *pTopView );
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ ULONG nFormat = 0;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET &&
+ pItem->ISA(SfxUInt32Item) )
+ {
+ nFormat = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+
+ if ( nFormat )
+ {
+ if (SOT_FORMAT_STRING == nFormat)
+ pTableView->Paste();
+ else
+ pTableView->PasteSpecial();
+
+ if (pTopView)
+ pTopView->Paste();
+ }
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
+ ULONG nFormat = 0;
+ if ( pDlg )
+ {
+ pDlg->Insert( SOT_FORMAT_STRING, EMPTY_STRING );
+ pDlg->Insert( SOT_FORMAT_RTF, EMPTY_STRING );
+
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+
+ nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
+ DELETEZ(pDlg);
+ }
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ return;
+ }
+
+ if (nFormat > 0)
+ {
+ if (SOT_FORMAT_STRING == nFormat)
+ pTableView->Paste();
+ else
+ pTableView->PasteSpecial();
+
+ if (pTopView)
+ pTopView->Paste();
+ }
+
+ if (pTopView)
+ pTopView->GetWindow()->GrabFocus();
+ }
+ break;
+
+ case SID_SELECTALL:
+ {
+ USHORT nPar = pEngine->GetParagraphCount();
+ if (nPar)
+ {
+ xub_StrLen nLen = pEngine->GetTextLen(nPar-1);
+ pTableView->SetSelection(ESelection(0,0,nPar-1,nLen));
+ if (pTopView)
+ pTopView->SetSelection(ESelection(0,0,nPar-1,nLen));
+ }
+ }
+ break;
+
+ case SID_CHARMAP:
+ {
+ USHORT nScript = pTableView->GetSelectedScriptType();
+ USHORT nFontWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? EE_CHAR_FONTINFO_CJK :
+ ( ( nScript == SCRIPTTYPE_COMPLEX ) ? EE_CHAR_FONTINFO_CTL :
+ EE_CHAR_FONTINFO );
+ const SvxFontItem& rItem = (const SvxFontItem&)
+ pTableView->GetAttribs().Get(nFontWhich);
+
+ String aString;
+ SvxFontItem aNewItem( EE_CHAR_FONTINFO );
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem = 0;
+ if( pArgs )
+ pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem);
+
+ if ( pItem )
+ {
+ aString = ((const SfxStringItem*)pItem)->GetValue();
+ const SfxPoolItem* pFtItem = NULL;
+ pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem);
+ const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem );
+ if ( pFontItem )
+ {
+ String aFontName(pFontItem->GetValue());
+ Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR
+ aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(),
+ aFont.GetStyleName(), aFont.GetPitch(),
+ aFont.GetCharSet(), ATTR_FONT );
+ }
+ else
+ aNewItem = rItem;
+ }
+ else
+ {
+ ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString );
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ return;
+ }
+ }
+
+ if ( aString.Len() )
+ {
+ // if string contains WEAK characters, set all fonts
+ BYTE nSetScript;
+ ScDocument* pDoc = pViewData->GetDocument();
+ if ( pDoc->HasStringWeakCharacters( aString ) )
+ nSetScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ else
+ nSetScript = pDoc->GetStringScriptType( aString );
+
+ SfxItemSet aSet( pTableView->GetEmptyItemSet() );
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, GetPool() );
+ aSetItem.PutItemForScriptType( nSetScript, aNewItem );
+ aSet.Put( aSetItem.GetItemSet(), FALSE );
+
+ // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist
+ pTableView->GetEditEngine()->QuickSetAttribs( aSet, pTableView->GetSelection() );
+ pTableView->InsertText(aString);
+ if (pTopView)
+ pTopView->InsertText(aString);
+
+ SfxStringItem aStringItem( SID_CHARMAP, aString );
+ SfxStringItem aFontItem( SID_ATTR_SPECIALCHAR, aNewItem.GetFamilyName() );
+ rReq.AppendItem( aFontItem );
+ rReq.AppendItem( aStringItem );
+ rReq.Done();
+
+
+ }
+
+ if (pTopView)
+ pTopView->GetWindow()->GrabFocus();
+ }
+ break;
+
+ case FID_INSERT_NAME:
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), RID_SCDLG_NAMES_PASTE, FALSE );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ short nRet = pDlg->Execute();
+ // pDlg is needed below
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ delete pDlg;
+ return;
+ }
+
+ if ( nRet == BTN_PASTE_NAME )
+ {
+ String aName = pDlg->GetSelectedName();
+ pTableView->InsertText(aName);
+ if (pTopView)
+ pTopView->InsertText(aName);
+ }
+ delete pDlg;
+
+ if (pTopView)
+ pTopView->GetWindow()->GrabFocus();
+ }
+ break;
+
+ case SID_CHAR_DLG:
+ {
+ SfxItemSet aAttrs( pTableView->GetAttribs() );
+
+ SfxObjectShell* pObjSh = pViewData->GetSfxDocShell();
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &aAttrs,
+ pObjSh, RID_SCDLG_CHAR );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ short nRet = pDlg->Execute();
+ // pDlg is needed below
+
+ // while the dialog was open, edit mode may have been stopped
+ if (!SC_MOD()->IsInputMode())
+ {
+ Sound::Beep();
+ delete pDlg;
+ return;
+ }
+
+ if ( nRet == RET_OK )
+ {
+ const SfxItemSet* pOut = pDlg->GetOutputItemSet();
+ pTableView->SetAttribs( *pOut );
+ }
+ delete pDlg;
+ }
+ break;
+
+ case SID_TOGGLE_REL:
+ {
+ BOOL bOk = FALSE;
+ if (pEngine->GetParagraphCount() == 1)
+ {
+ String aText = pEngine->GetText();
+ ESelection aSel = pEditView->GetSelection(); // aktuelle View
+
+ ScRefFinder aFinder( aText, pViewData->GetDocument() );
+ aFinder.ToggleRel( aSel.nStartPos, aSel.nEndPos );
+ if (aFinder.GetFound())
+ {
+ String aNew = aFinder.GetText();
+ ESelection aNewSel( 0,aFinder.GetSelStart(), 0,aFinder.GetSelEnd() );
+ pEngine->SetText( aNew );
+ pTableView->SetSelection( aNewSel );
+ if ( pTopView )
+ {
+ pTopView->GetEditEngine()->SetText( aNew );
+ pTopView->SetSelection( aNewSel );
+ }
+ bOk = TRUE;
+
+ // Referenz wird selektiert -> beim Tippen nicht ueberschreiben
+ bSetSelIsRef = TRUE;
+ }
+ }
+ if (!bOk)
+ Sound::Beep(); // keine Referenzen oder mehrere Absaetze
+ }
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem;
+ const String& rName = pHyper->GetName();
+ const String& rURL = pHyper->GetURL();
+ const String& rTarget = pHyper->GetTargetFrame();
+ SvxLinkInsertMode eMode = pHyper->GetInsertMode();
+
+ BOOL bDone = FALSE;
+ if ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD )
+ {
+ const SvxURLField* pURLField = GetURLField();
+ if ( pURLField )
+ {
+ // altes Feld selektieren
+
+ ESelection aSel = pTableView->GetSelection();
+ aSel.Adjust();
+ aSel.nEndPara = aSel.nStartPara;
+ aSel.nEndPos = aSel.nStartPos + 1;
+ pTableView->SetSelection( aSel );
+
+ // neues Feld einfuegen
+
+ SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
+ aURLField.SetTargetFrame( rTarget );
+ SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
+ pTableView->InsertField( aURLItem );
+ pTableView->SetSelection( aSel ); // select inserted field
+
+ // #57254# jetzt doch auch Felder in der Top-View
+
+ if ( pTopView )
+ {
+ aSel = pTopView->GetSelection();
+ aSel.nEndPara = aSel.nStartPara;
+ aSel.nEndPos = aSel.nStartPos + 1;
+ pTopView->SetSelection( aSel );
+ pTopView->InsertField( aURLItem );
+ pTopView->SetSelection( aSel ); // select inserted field
+ }
+
+ bDone = TRUE;
+ }
+ }
+
+ if (!bDone)
+ {
+ pViewData->GetViewShell()->
+ InsertURL( rName, rURL, rTarget, (USHORT) eMode );
+
+ // InsertURL an der ViewShell schaltet bei "Button"
+ // die EditShell ab, darum sofort return
+
+ return;
+ }
+ }
+ }
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ {
+ const SvxURLField* pURLField = GetURLField();
+ if ( pURLField )
+ ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() );
+ return;
+ }
+ //break;
+
+ case FN_INSERT_SOFT_HYPHEN:
+ lclInsertCharacter( pTableView, pTopView, CHAR_SHY );
+ break;
+ case FN_INSERT_HARDHYPHEN:
+ lclInsertCharacter( pTableView, pTopView, CHAR_NBHY );
+ break;
+ case FN_INSERT_HARD_SPACE:
+ lclInsertCharacter( pTableView, pTopView, CHAR_NBSP );
+ break;
+ case SID_INSERT_RLM:
+ lclInsertCharacter( pTableView, pTopView, CHAR_RLM );
+ break;
+ case SID_INSERT_LRM:
+ lclInsertCharacter( pTableView, pTopView, CHAR_LRM );
+ break;
+ case SID_INSERT_ZWSP:
+ lclInsertCharacter( pTableView, pTopView, CHAR_ZWSP );
+ break;
+ case SID_INSERT_ZWNBSP:
+ lclInsertCharacter( pTableView, pTopView, CHAR_ZWNBSP );
+ break;
+ }
+
+ pHdl->DataChanged();
+ if (bSetSelIsRef)
+ pHdl->SetSelIsRef(TRUE);
+}
+
+void lcl_DisableAll( SfxItemSet& rSet ) // disable all slots
+{
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ rSet.DisableItem( nWhich );
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void __EXPORT ScEditShell::GetState( SfxItemSet& rSet )
+{
+ // #125326# When deactivating the view, edit mode is stopped, but the EditShell is left active
+ // (a shell can't be removed from within Deactivate). In that state, the EditView isn't inserted
+ // into the EditEngine, so it can have an invalid selection and must not be used.
+ if ( !pViewData->HasEditView( pViewData->GetActivePart() ) )
+ {
+ lcl_DisableAll( rSet );
+ return;
+ }
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
+
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_ATTR_INSERT: // Statuszeile
+ {
+ if ( pActiveView )
+ rSet.Put( SfxBoolItem( nWhich, pActiveView->IsInsertMode() ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, 42 ) );
+ }
+ break;
+
+ case SID_HYPERLINK_GETLINK:
+ {
+ SvxHyperlinkItem aHLinkItem;
+ const SvxURLField* pURLField = GetURLField();
+ if ( pURLField )
+ {
+ aHLinkItem.SetName( pURLField->GetRepresentation() );
+ aHLinkItem.SetURL( pURLField->GetURL() );
+ aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() );
+ }
+ else if ( pActiveView )
+ {
+ // use selected text as name for urls
+ String sReturn = pActiveView->GetSelected();
+ sReturn.Erase(255);
+ sReturn.EraseTrailingChars();
+ aHLinkItem.SetName(sReturn);
+ }
+ rSet.Put(aHLinkItem);
+ }
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ {
+ if ( !GetURLField() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ case SID_INSERT_RLM:
+ case SID_INSERT_LRM:
+ case SID_INSERT_ZWNBSP:
+ case SID_INSERT_ZWSP:
+ ScViewUtil::HideDisabledSlot( rSet, pViewData->GetBindings(), nWhich );
+ break;
+
+ case SID_THES:
+ {
+ String aStatusVal;
+ LanguageType nLang = LANGUAGE_NONE;
+ bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, *pActiveView );
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable thesaurus context menu entry if there is nothing to look up
+ BOOL bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang );
+ if (!bIsLookUpWord || !bCanDoThesaurus)
+ rSet.DisableItem( SID_THES );
+ }
+ break;
+
+
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+const SvxURLField* ScEditShell::GetURLField()
+{
+ ScInputHandler* pHdl = GetMyInputHdl();
+ EditView* pActiveView = pHdl ? pHdl->GetActiveView() : pEditView;
+ if ( pActiveView )
+ {
+ const SvxFieldItem* pFieldItem = pActiveView->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField && pField->ISA(SvxURLField) )
+ return (const SvxURLField*)pField;
+ }
+ }
+
+ return NULL;
+}
+
+IMPL_LINK( ScEditShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) );
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+void __EXPORT ScEditShell::GetClipState( SfxItemSet& rSet )
+{
+ if ( !pClipEvtLstnr )
+ {
+ // create listener
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScEditShell, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
+ Window* pWin = pViewData->GetActiveWin();
+ pClipEvtLstnr->AddRemoveListener( pWin, TRUE );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+ bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_PASTE:
+ case SID_PASTE_SPECIAL:
+ if( !bPastePossible )
+ rSet.DisableItem( nWhich );
+ break;
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ if( bPastePossible )
+ {
+ SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS );
+ TransferableDataHelper aDataHelper(
+ TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
+
+ if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_STRING );
+ if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ aFormats.AddClipbrdFormat( SOT_FORMAT_RTF );
+
+ rSet.Put( aFormats );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void lcl_InvalidateUnder( SfxBindings& rBindings )
+{
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+}
+
+void ScEditShell::ExecuteAttr(SfxRequest& rReq)
+{
+ SfxItemSet aSet( pEditView->GetEmptyItemSet() );
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_FONT:
+ {
+ if (pArgs)
+ {
+ // #i78017 establish the same behaviour as in Writer
+ USHORT nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ {
+ nScript = pEditView->GetSelectedScriptType();
+ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
+ }
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ USHORT nWhich = rPool.GetWhich( nSlot );
+ aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) );
+
+ aSet.Put( aSetItem.GetItemSet(), FALSE );
+ }
+ }
+ break;
+
+ case SID_ATTR_CHAR_COLOR:
+ {
+ if (pArgs)
+ {
+ aSet.Put( pArgs->Get( pArgs->GetPool()->GetWhich( nSlot ) ) );
+ rBindings.Invalidate( nSlot );
+ }
+ }
+ break;
+
+ // Toggles
+
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ USHORT nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+
+ BOOL bOld = FALSE;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), FALSE );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() > WEIGHT_NORMAL )
+ bOld = TRUE;
+
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ aSetItem.PutItemForScriptType( nScript,
+ SvxWeightItem( bOld ? WEIGHT_NORMAL : WEIGHT_BOLD, EE_CHAR_WEIGHT ) );
+ aSet.Put( aSetItem.GetItemSet(), FALSE );
+
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ USHORT nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+
+ BOOL bOld = FALSE;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pEditView->GetAttribs(), FALSE );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxPostureItem*)pCore)->GetValue() != ITALIC_NONE )
+ bOld = TRUE;
+
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ aSetItem.PutItemForScriptType( nScript,
+ SvxPostureItem( bOld ? ITALIC_NONE : ITALIC_NORMAL, EE_CHAR_ITALIC ) );
+ aSet.Put( aSetItem.GetItemSet(), FALSE );
+
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ULINE_VAL_NONE:
+ aSet.Put( SvxUnderlineItem( UNDERLINE_NONE, EE_CHAR_UNDERLINE ) );
+ lcl_InvalidateUnder( rBindings );
+ break;
+
+ case SID_ATTR_CHAR_UNDERLINE: // Toggles
+ case SID_ULINE_VAL_SINGLE:
+ case SID_ULINE_VAL_DOUBLE:
+ case SID_ULINE_VAL_DOTTED:
+ {
+ FontUnderline eOld = ((const SvxUnderlineItem&) pEditView->
+ GetAttribs().Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ FontUnderline eNew = eOld;
+ switch (nSlot)
+ {
+ case SID_ATTR_CHAR_UNDERLINE:
+ eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_SINGLE:
+ eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_DOUBLE:
+ eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
+ break;
+ case SID_ULINE_VAL_DOTTED:
+ eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
+ break;
+ }
+ aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) );
+ lcl_InvalidateUnder( rBindings );
+ }
+ break;
+
+ case SID_ATTR_CHAR_OVERLINE:
+ {
+ FontUnderline eOld = ((const SvxOverlineItem&) pEditView->
+ GetAttribs().Get(EE_CHAR_OVERLINE)).GetLineStyle();
+ FontUnderline eNew = ( eOld != UNDERLINE_NONE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ aSet.Put( SvxOverlineItem( eNew, EE_CHAR_OVERLINE ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_STRIKEOUT:
+ {
+ BOOL bOld = ((const SvxCrossedOutItem&)pEditView->GetAttribs().
+ Get(EE_CHAR_STRIKEOUT)).GetValue() != STRIKEOUT_NONE;
+ aSet.Put( SvxCrossedOutItem( bOld ? STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_SHADOWED:
+ {
+ BOOL bOld = ((const SvxShadowedItem&)pEditView->GetAttribs().
+ Get(EE_CHAR_SHADOW)).GetValue();
+ aSet.Put( SvxShadowedItem( !bOld, EE_CHAR_SHADOW ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_ATTR_CHAR_CONTOUR:
+ {
+ BOOL bOld = ((const SvxContourItem&)pEditView->GetAttribs().
+ Get(EE_CHAR_OUTLINE)).GetValue();
+ aSet.Put( SvxContourItem( !bOld, EE_CHAR_OUTLINE ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_SET_SUPER_SCRIPT:
+ {
+ SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&)
+ pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue();
+ SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUPERSCRIPT) ?
+ SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUPERSCRIPT;
+ aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+ case SID_SET_SUB_SCRIPT:
+ {
+ SvxEscapement eOld = (SvxEscapement) ((const SvxEscapementItem&)
+ pEditView->GetAttribs().Get(EE_CHAR_ESCAPEMENT)).GetEnumValue();
+ SvxEscapement eNew = (eOld == SVX_ESCAPEMENT_SUBSCRIPT) ?
+ SVX_ESCAPEMENT_OFF : SVX_ESCAPEMENT_SUBSCRIPT;
+ aSet.Put( SvxEscapementItem( eNew, EE_CHAR_ESCAPEMENT ) );
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+ }
+
+ //
+ // anwenden
+ //
+
+ EditEngine* pEngine = pEditView->GetEditEngine();
+ BOOL bOld = pEngine->GetUpdateMode();
+ pEngine->SetUpdateMode(FALSE);
+
+ pEditView->SetAttribs( aSet );
+
+ pEngine->SetUpdateMode(bOld);
+ pEditView->Invalidate();
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ pHdl->SetModified();
+
+ rReq.Done();
+}
+
+void ScEditShell::GetAttrState(SfxItemSet &rSet)
+{
+ if ( !pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326#
+ {
+ lcl_DisableAll( rSet );
+ return;
+ }
+
+ SfxItemSet aAttribs = pEditView->GetAttribs();
+ rSet.Put( aAttribs );
+
+ // choose font info according to selection script type
+
+ USHORT nScript = pEditView->GetSelectedScriptType();
+ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
+
+ // #i55929# input-language-dependent script type (depends on input language if nothing selected)
+ USHORT nInputScript = nScript;
+ if ( !pEditView->GetSelection().HasRange() )
+ {
+ LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage();
+ if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ }
+
+ // #i55929# according to spec, nInputScript is used for font and font height only
+ if ( rSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTINFO, nInputScript );
+ if ( rSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_FONTHEIGHT, nInputScript );
+ if ( rSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_WEIGHT, nScript );
+ if ( rSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN )
+ ScViewUtil::PutItemScript( rSet, aAttribs, EE_CHAR_ITALIC, nScript );
+
+ // Unterstreichung
+
+ SfxItemState eState = aAttribs.GetItemState( EE_CHAR_UNDERLINE, TRUE );
+ if ( eState == SFX_ITEM_DONTCARE )
+ {
+ rSet.InvalidateItem( SID_ULINE_VAL_NONE );
+ rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
+ }
+ else
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ aAttribs.Get(EE_CHAR_UNDERLINE)).GetLineStyle();
+ USHORT nId = SID_ULINE_VAL_NONE;
+ switch (eUnderline)
+ {
+ case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
+ case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
+ case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
+ default:
+ break;
+ }
+ rSet.Put( SfxBoolItem( nId, TRUE ) );
+ }
+
+ //! Testen, ob Klammer-Hervorhebung aktiv ist !!!!
+ ScInputHandler* pHdl = GetMyInputHdl();
+ if ( pHdl && pHdl->IsFormulaMode() )
+ rSet.ClearItem( EE_CHAR_WEIGHT ); // hervorgehobene Klammern hier nicht
+}
+
+String ScEditShell::GetSelectionText( BOOL bWholeWord )
+{
+ String aStrSelection;
+
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) ) // #125326#
+ {
+ if ( bWholeWord )
+ {
+ EditEngine* pEngine = pEditView->GetEditEngine();
+ ESelection aSel = pEditView->GetSelection();
+ String aStrCurrentDelimiters = pEngine->GetWordDelimiters();
+
+ pEngine->SetWordDelimiters( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" .,;\"'")) );
+ aStrSelection = pEngine->GetWord( aSel.nEndPara, aSel.nEndPos );
+ pEngine->SetWordDelimiters( aStrCurrentDelimiters );
+ }
+ else
+ {
+ aStrSelection = pEditView->GetSelected();
+ }
+ }
+
+ return aStrSelection;
+}
+
+void ScEditShell::ExecuteUndo(SfxRequest& rReq)
+{
+ // #81733# Undo must be handled here because it's called for both EditViews
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT(pHdl,"no ScInputHandler");
+ EditView* pTopView = pHdl->GetTopView();
+ EditView* pTableView = pHdl->GetTableView();
+ DBG_ASSERT(pTableView,"no EditView");
+
+ pHdl->DataChanging();
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_UNDO:
+ case SID_REDO:
+ {
+ BOOL bIsUndo = ( nSlot == SID_UNDO );
+
+ USHORT nCount = 1;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ nCount = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if ( bIsUndo )
+ {
+ pTableView->Undo();
+ if (pTopView)
+ pTopView->Undo();
+ }
+ else
+ {
+ pTableView->Redo();
+ if (pTopView)
+ pTopView->Redo();
+ }
+ }
+ }
+ break;
+ }
+ pViewData->GetBindings().InvalidateAll(FALSE);
+
+ pHdl->DataChanged();
+}
+
+void ScEditShell::GetUndoState(SfxItemSet &rSet)
+{
+ // Undo state is taken from normal ViewFrame state function
+
+ SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame();
+ if ( pViewFrm && GetUndoManager() )
+ {
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ pViewFrm->GetSlotState( nWhich, NULL, &rSet );
+ nWhich = aIter.NextWhich();
+ }
+ }
+
+ // disable if no action in input line EditView
+
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT(pHdl,"no ScInputHandler");
+ EditView* pTopView = pHdl->GetTopView();
+ if (pTopView)
+ {
+ SfxUndoManager& rTopMgr = pTopView->GetEditEngine()->GetUndoManager();
+ if ( rTopMgr.GetUndoActionCount() == 0 )
+ rSet.DisableItem( SID_UNDO );
+ if ( rTopMgr.GetRedoActionCount() == 0 )
+ rSet.DisableItem( SID_REDO );
+ }
+}
+
+void ScEditShell::ExecuteTrans( SfxRequest& rReq )
+{
+ sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() );
+ if ( nType )
+ {
+ ScInputHandler* pHdl = GetMyInputHdl();
+ DBG_ASSERT( pHdl, "no ScInputHandler" );
+
+ EditView* pTopView = pHdl->GetTopView();
+ EditView* pTableView = pHdl->GetTableView();
+ DBG_ASSERT( pTableView, "no EditView" );
+
+ pHdl->DataChanging();
+
+ pTableView->TransliterateText( nType );
+ if (pTopView)
+ pTopView->TransliterateText( nType );
+
+ pHdl->DataChanged();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
new file mode 100644
index 000000000000..599e800762ce
--- /dev/null
+++ b/sc/source/ui/view/formatsh.cxx
@@ -0,0 +1,2274 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+//------------------------------------------------------------------
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+#define _SI_NOSBXCONTROLS
+#define _VCONT_HXX
+#define _SI_NOOTHERFORMS
+#define _VCTRLS_HXX
+#define _SI_NOCONTROL
+#define _SETBRW_HXX
+#define _VCBRW_HXX
+#define _SI_NOSBXCONTROLS
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#define _ZFORLIST_DECLARE_TABLE
+#include <svl/stritem.hxx>
+#include <svl/zformat.hxx>
+#include <svl/languageoptions.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/numinf.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <editeng/svxenum.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/bolnitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/justifyitem.hxx>
+
+#include "formatsh.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "docsh.hxx"
+#include "patattr.hxx"
+#include "scmod.hxx"
+#include "attrdlg.hrc"
+#include "stlpool.hxx"
+#include "stlsheet.hxx"
+#include "printfun.hxx"
+#include "docpool.hxx"
+#include "scresid.hxx"
+#include "tabvwsh.hxx"
+#include "undostyl.hxx"
+
+
+#define ScFormatShell
+#define TableFont
+#define FormatForSelection
+#include "scslots.hxx"
+
+#define Interior
+#include <svx/svxslots.hxx>
+
+#include "scabstdlg.hxx"
+
+namespace {
+
+SvxCellHorJustify lclConvertSlotToHAlign( USHORT nSlot )
+{
+ SvxCellHorJustify eHJustify = SVX_HOR_JUSTIFY_STANDARD;
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_HDEFAULT: eHJustify = SVX_HOR_JUSTIFY_STANDARD; break;
+ case SID_ALIGN_ANY_LEFT: eHJustify = SVX_HOR_JUSTIFY_LEFT; break;
+ case SID_ALIGN_ANY_HCENTER: eHJustify = SVX_HOR_JUSTIFY_CENTER; break;
+ case SID_ALIGN_ANY_RIGHT: eHJustify = SVX_HOR_JUSTIFY_RIGHT; break;
+ case SID_ALIGN_ANY_JUSTIFIED: eHJustify = SVX_HOR_JUSTIFY_BLOCK; break;
+ default: DBG_ERRORFILE( "lclConvertSlotToHAlign - invalid slot" );
+ }
+ return eHJustify;
+}
+
+SvxCellVerJustify lclConvertSlotToVAlign( USHORT nSlot )
+{
+ SvxCellVerJustify eVJustify = SVX_VER_JUSTIFY_STANDARD;
+ switch( nSlot )
+ {
+ case SID_ALIGN_ANY_VDEFAULT: eVJustify = SVX_VER_JUSTIFY_STANDARD; break;
+ case SID_ALIGN_ANY_TOP: eVJustify = SVX_VER_JUSTIFY_TOP; break;
+ case SID_ALIGN_ANY_VCENTER: eVJustify = SVX_VER_JUSTIFY_CENTER; break;
+ case SID_ALIGN_ANY_BOTTOM: eVJustify = SVX_VER_JUSTIFY_BOTTOM; break;
+ default: DBG_ERRORFILE( "lclConvertSlotToVAlign - invalid slot" );
+ }
+ return eVJustify;
+}
+
+} // namespace
+
+TYPEINIT1( ScFormatShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScFormatShell, SfxShell, ScResId(SCSTR_FORMATSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_SERVER,
+ ScResId(RID_OBJECTBAR_FORMAT));
+
+}
+
+
+ScFormatShell::ScFormatShell(ScViewData* pData) :
+ SfxShell(pData->GetViewShell()),
+ pViewData(pData)
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+
+ SetPool( &pTabViewShell->GetPool() );
+ SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId(HID_SCSHELL_FORMATSH);
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Format")));
+}
+
+ScFormatShell::~ScFormatShell()
+{
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScFormatShell::GetStyleState( SfxItemSet& rSet )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
+
+ BOOL bProtected = FALSE;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (pDoc->IsTabProtected(i)) // ueberhaupt eine Tabelle geschuetzt?
+ bProtected = TRUE;
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ USHORT nSlotId = 0;
+
+ while ( nWhich )
+ {
+ nSlotId = SfxItemPool::IsWhich( nWhich )
+ ? GetPool().GetSlotId( nWhich )
+ : nWhich;
+
+ switch ( nSlotId )
+ {
+ case SID_STYLE_APPLY:
+ if ( !pStylePool )
+ rSet.DisableItem( nSlotId );
+ break;
+
+ case SID_STYLE_FAMILY2: // Zellvorlagen
+ {
+ SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)
+ pTabViewShell->GetStyleSheetFromMarked();
+
+ if ( pStyleSheet )
+ rSet.Put( SfxTemplateItem( nSlotId, pStyleSheet->GetName() ) );
+ else
+ rSet.Put( SfxTemplateItem( nSlotId, String() ) );
+ }
+ break;
+
+ case SID_STYLE_FAMILY4: // Seitenvorlagen
+ {
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ String aPageStyle = pDoc->GetPageStyle( nCurTab );
+ SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)pStylePool->
+ Find( aPageStyle, SFX_STYLE_FAMILY_PAGE );
+
+ if ( pStyleSheet )
+ rSet.Put( SfxTemplateItem( nSlotId, aPageStyle ) );
+ else
+ rSet.Put( SfxTemplateItem( nSlotId, String() ) );
+ }
+ break;
+
+ case SID_STYLE_WATERCAN:
+ {
+ rSet.Put( SfxBoolItem( nSlotId, SC_MOD()->GetIsWaterCan() ) );
+ }
+ break;
+
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ ISfxTemplateCommon* pDesigner = SFX_APP()->
+ GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
+ BOOL bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+
+ if ( bProtected || bPage )
+ rSet.DisableItem( nSlotId );
+ }
+ break;
+
+ case SID_STYLE_EDIT:
+ case SID_STYLE_DELETE:
+ {
+ ISfxTemplateCommon* pDesigner = SFX_APP()->
+ GetCurrentTemplateCommon(pTabViewShell->GetViewFrame()->GetBindings());
+ BOOL bPage = pDesigner && SFX_STYLE_FAMILY_PAGE == pDesigner->GetActualFamily();
+
+ if ( bProtected && !bPage )
+ rSet.DisableItem( nSlotId );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScFormatShell::ExecuteStyle( SfxRequest& rReq )
+{
+ // Wenn ToolBar vertikal :
+ if ( !rReq.GetArgs() )
+ {
+ pViewData->GetDispatcher().Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ return;
+ }
+
+ //--------------------------------------------------------------------
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const USHORT nSlotId = rReq.GetSlot();
+ const SCTAB nCurTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScTabViewShell* pTabViewShell= GetViewData()->GetViewShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScModule* pScMod = SC_MOD();
+ String aRefName;
+ BOOL bUndo = pDoc->IsUndoEnabled();
+
+ if ( (nSlotId == SID_STYLE_NEW)
+ || (nSlotId == SID_STYLE_EDIT)
+ || (nSlotId == SID_STYLE_DELETE)
+ || (nSlotId == SID_STYLE_APPLY)
+ || (nSlotId == SID_STYLE_WATERCAN)
+ || (nSlotId == SID_STYLE_FAMILY)
+ || (nSlotId == SID_STYLE_NEW_BY_EXAMPLE)
+ || (nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE) )
+ {
+ SfxStyleSheetBasePool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = NULL;
+
+ BOOL bStyleToMarked = FALSE;
+ BOOL bListAction = FALSE;
+ BOOL bAddUndo = FALSE; // add ScUndoModifyStyle (style modified)
+ ScStyleSaveData aOldData; // for undo/redo
+ ScStyleSaveData aNewData;
+
+ SfxStyleFamily eFamily = SFX_STYLE_FAMILY_PARA;
+ const SfxPoolItem* pFamItem;
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILY, TRUE, &pFamItem ) )
+ eFamily = (SfxStyleFamily)((const SfxUInt16Item*)pFamItem)->GetValue();
+ else
+ if ( pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_FAMILYNAME, TRUE, &pFamItem ) )
+ {
+ String sFamily = ((const SfxStringItem*)pFamItem)->GetValue();
+ if (sFamily.CompareToAscii("CellStyles") == COMPARE_EQUAL)
+ eFamily = SFX_STYLE_FAMILY_PARA;
+ else
+ if (sFamily.CompareToAscii("PageStyles") == COMPARE_EQUAL)
+ eFamily = SFX_STYLE_FAMILY_PAGE;
+ }
+
+ String aStyleName;
+ USHORT nRetMask = 0xffff;
+// #96983# only stylist sends focus to sheet
+// BOOL bGrabFocus = ( SID_STYLE_APPLY == nSlotId );
+
+ pStylePool->SetSearchMask( eFamily, SFXSTYLEBIT_ALL );
+
+ switch ( nSlotId )
+ {
+ case SID_STYLE_NEW:
+ {
+ const SfxPoolItem* pNameItem;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, TRUE, &pNameItem ))
+ aStyleName = ((const SfxStringItem*)pNameItem)->GetValue();
+
+ const SfxPoolItem* pRefItem=NULL;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( SID_STYLE_REFERENCE, TRUE, &pRefItem ))
+ {
+ if(pRefItem!=NULL)
+ aRefName = ((const SfxStringItem*)pRefItem)->GetValue();
+ }
+
+ pStyleSheet = &(pStylePool->Make( aStyleName, eFamily,
+ SFXSTYLEBIT_USERDEF ) );
+
+ if ( pStyleSheet && pStyleSheet->HasParentSupport() )
+ pStyleSheet->SetParent(aRefName);
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ {
+ SFX_REQUEST_ARG( rReq, pNameItem, SfxStringItem, SID_APPLY_STYLE, sal_False );
+ SFX_REQUEST_ARG( rReq, pFamilyItem, SfxStringItem, SID_STYLE_FAMILYNAME, sal_False );
+ if ( pFamilyItem && pNameItem )
+ {
+ com::sun::star::uno::Reference< com::sun::star::style::XStyleFamiliesSupplier > xModel(pDocSh->GetModel(), com::sun::star::uno::UNO_QUERY);
+ try
+ {
+ com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xStyles;
+ com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xCont = xModel->getStyleFamilies();
+ xCont->getByName(pFamilyItem->GetValue()) >>= xStyles;
+ com::sun::star::uno::Reference< com::sun::star::beans::XPropertySet > xInfo;
+ xStyles->getByName( pNameItem->GetValue() ) >>= xInfo;
+ ::rtl::OUString aUIName;
+ xInfo->getPropertyValue( ::rtl::OUString::createFromAscii("DisplayName") ) >>= aUIName;
+ if ( aUIName.getLength() )
+ rReq.AppendItem( SfxStringItem( SID_STYLE_APPLY, aUIName ) );
+ }
+ catch( com::sun::star::uno::Exception& )
+ {
+ }
+ }
+ }
+ case SID_STYLE_EDIT:
+ case SID_STYLE_DELETE:
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ const SfxPoolItem* pNameItem;
+ if (pArgs && SFX_ITEM_SET == pArgs->GetItemState( nSlotId, TRUE, &pNameItem ))
+ aStyleName = ((const SfxStringItem*)pNameItem)->GetValue();
+ pStyleSheet = pStylePool->Find( aStyleName, eFamily );
+
+ aOldData.InitFromStyle( pStyleSheet );
+ }
+ break;
+
+ case SID_STYLE_WATERCAN:
+ {
+ BOOL bWaterCan = pScMod->GetIsWaterCan();
+
+ if( !bWaterCan )
+ {
+ const SfxPoolItem* pItem;
+
+ if ( SFX_ITEM_SET ==
+ pArgs->GetItemState( nSlotId, TRUE, &pItem ) )
+ {
+ const SfxStringItem* pStrItem = PTR_CAST(SfxStringItem,pItem);
+ if ( pStrItem )
+ {
+ aStyleName = pStrItem->GetValue();
+ pStyleSheet = pStylePool->Find( aStyleName, eFamily );
+
+ if ( pStyleSheet )
+ {
+ ((ScStyleSheetPool*)pStylePool)->
+ SetActualStyleSheet( pStyleSheet );
+ rReq.Done();
+ }
+ }
+ }
+ }
+
+ if ( !bWaterCan && pStyleSheet )
+ {
+ pScMod->SetWaterCan( TRUE );
+ pTabViewShell->SetActivePointer( Pointer(POINTER_FILL) );
+ rReq.Done();
+ }
+ else
+ {
+ pScMod->SetWaterCan( FALSE );
+ pTabViewShell->SetActivePointer( Pointer(POINTER_ARROW) );
+ rReq.Done();
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ // Neuen Style fuer WaterCan-Mode setzen
+ if ( nSlotId == SID_STYLE_APPLY && pScMod->GetIsWaterCan() && pStyleSheet )
+ ((ScStyleSheetPool*)pStylePool)->SetActualStyleSheet( pStyleSheet );
+
+ switch ( eFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ {
+ switch ( nSlotId )
+ {
+ case SID_STYLE_DELETE:
+ {
+ if ( pStyleSheet )
+ {
+ pTabViewShell->RemoveStyleSheetInUse( (SfxStyleSheet*)pStyleSheet );
+ pStylePool->Remove( pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ nRetMask = TRUE;
+ bAddUndo = TRUE;
+ rReq.Done();
+ }
+ else
+ nRetMask = FALSE;
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ {
+ if ( pStyleSheet && !pScMod->GetIsWaterCan() )
+ {
+ // Anwenden der Vorlage auf das Dokument
+ pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ // Vorlage erzeugen/ersetzen durch Attribute
+ // an der Cursor-Position:
+
+ const ScPatternAttr* pAttrItem = NULL;
+
+ // Die Abfrage, ob markiert ist, war hier immer falsch,
+ // darum jetzt gar nicht mehr, und einfach vom Cursor.
+ // Wenn Attribute aus der Selektion genommen werden sollen,
+ // muss noch darauf geachtet werden, Items aus Vorlagen nicht
+ // zu uebernehmen (GetSelectionPattern sammelt auch Items aus
+ // Vorlagen zusammen) (#44748#)
+ // pAttrItem = GetSelectionPattern();
+
+ // ScViewData* pViewData = GetViewData();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ pAttrItem = pDoc->GetPattern( nCol, nRow, nCurTab );
+
+ SfxItemSet aAttrSet = pAttrItem->GetItemSet();
+ aAttrSet.ClearItem( ATTR_MERGE );
+ aAttrSet.ClearItem( ATTR_MERGE_FLAG );
+ // bedingte Formatierung und Gueltigkeit nicht uebernehmen,
+ // weil sie in der Vorlage nicht editiert werden koennen
+ aAttrSet.ClearItem( ATTR_VALIDDATA );
+ aAttrSet.ClearItem( ATTR_CONDITIONAL );
+
+ if ( SID_STYLE_NEW_BY_EXAMPLE == nSlotId )
+ {
+ if ( bUndo )
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ bListAction = TRUE;
+ }
+
+ BOOL bConvertBack = FALSE;
+ SfxStyleSheet* pSheetInUse = (SfxStyleSheet*)
+ pTabViewShell->GetStyleSheetFromMarked();
+
+ // wenn neuer Style vorhanden und in der Selektion
+ // verwendet wird, so darf der Parent nicht uebernommen
+ // werden:
+
+ if ( pStyleSheet && pSheetInUse && pStyleSheet == pSheetInUse )
+ pSheetInUse = NULL;
+
+ // wenn bereits vorhanden, erstmal entfernen...
+ if ( pStyleSheet )
+ {
+ // Style-Pointer zu Namen vor Erase,
+ // weil Zellen sonst ungueltige Pointer
+ // enthalten.
+ //!!! bei Gelenheit mal eine Methode, die
+ // das fuer einen bestimmten Style macht
+ pDoc->StylesToNames();
+ bConvertBack = TRUE;
+ pStylePool->Remove(pStyleSheet);
+ }
+
+ // ...und neu anlegen
+ pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
+ SFXSTYLEBIT_USERDEF );
+
+ // wenn ein Style vorhanden ist, so wird dieser
+ // Parent der neuen Vorlage:
+ if ( pSheetInUse && pStyleSheet->HasParentSupport() )
+ pStyleSheet->SetParent( pSheetInUse->GetName() );
+
+ if ( bConvertBack )
+ // Namen zu Style-Pointer
+ pDoc->UpdStlShtPtrsFrmNms();
+ else
+ pDoc->GetPool()->CellStyleCreated( aStyleName );
+
+ // Attribute uebernehmen und Style anwenden
+ pStyleSheet->GetItemSet().Put( aAttrSet );
+ pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet );
+
+ // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
+ // (pStyleSheet pointer is used!)
+ bStyleToMarked = TRUE;
+ }
+ else // ( nSlotId == SID_STYLE_UPDATE_BY_EXAMPLE )
+ {
+ pStyleSheet = (SfxStyleSheet*)pTabViewShell->GetStyleSheetFromMarked();
+
+ if ( pStyleSheet )
+ {
+ aOldData.InitFromStyle( pStyleSheet );
+
+ if ( bUndo )
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_EDITCELLSTYLE );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ bListAction = TRUE;
+ }
+
+ pStyleSheet->GetItemSet().Put( aAttrSet );
+ pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet );
+
+ // call SetStyleSheetToMarked after adding the ScUndoModifyStyle
+ // (pStyleSheet pointer is used!)
+ bStyleToMarked = TRUE;
+ }
+ }
+
+ aNewData.InitFromStyle( pStyleSheet );
+ bAddUndo = TRUE;
+ rReq.Done();
+ }
+ break;
+
+ default:
+ break;
+ }
+ } // case SFX_STYLE_FAMILY_PARA:
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ {
+ switch ( nSlotId )
+ {
+ case SID_STYLE_DELETE:
+ {
+ nRetMask = ( NULL != pStyleSheet );
+ if ( pStyleSheet )
+ {
+ if ( pDoc->RemovePageStyleInUse( pStyleSheet->GetName() ) )
+ {
+ ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(TRUE), nCurTab ).UpdatePages();
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+ pStylePool->Remove( pStyleSheet );
+ rBindings.Invalidate( SID_STYLE_FAMILY4 );
+ pDocSh->SetDocumentModified();
+ bAddUndo = TRUE;
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_STYLE_APPLY:
+ {
+ nRetMask = ( NULL != pStyleSheet );
+ if ( pStyleSheet && !pScMod->GetIsWaterCan() )
+ {
+ ScUndoApplyPageStyle* pUndoAction = 0;
+ for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
+ {
+ if( rMark.GetTableSelect( nTab ) )
+ {
+ String aOldName = pDoc->GetPageStyle( nTab );
+ if ( aOldName != aStyleName )
+ {
+ pDoc->SetPageStyle( nTab, aStyleName );
+ ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(TRUE), nTab ).UpdatePages();
+ if( !pUndoAction )
+ pUndoAction = new ScUndoApplyPageStyle( pDocSh, aStyleName );
+ pUndoAction->AddSheetAction( nTab, aOldName );
+ }
+ }
+ }
+ if( pUndoAction )
+ {
+ pDocSh->GetUndoManager()->AddUndoAction( pUndoAction );
+ pDocSh->SetDocumentModified();
+ rBindings.Invalidate( SID_STYLE_FAMILY4 );
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ const String& rStrCurStyle = pDoc->GetPageStyle( nCurTab );
+
+ if ( rStrCurStyle != aStyleName )
+ {
+ SfxStyleSheetBase* pCurStyle = pStylePool->Find( rStrCurStyle, eFamily );
+ SfxItemSet aAttrSet = pCurStyle->GetItemSet();
+ SCTAB nInTab;
+ BOOL bUsed = pDoc->IsPageStyleInUse( aStyleName, &nInTab );
+
+ // wenn bereits vorhanden, erstmal entfernen...
+ if ( pStyleSheet )
+ pStylePool->Remove( pStyleSheet );
+
+ // ...und neu anlegen
+ pStyleSheet = &pStylePool->Make( aStyleName, eFamily,
+ SFXSTYLEBIT_USERDEF );
+
+ // Attribute uebernehmen
+ pStyleSheet->GetItemSet().Put( aAttrSet );
+ pDocSh->SetDocumentModified();
+
+ // wenn in Verwendung -> Update
+ if ( bUsed )
+ ScPrintFunc( pDocSh, pTabViewShell->GetPrinter(TRUE), nInTab ).UpdatePages();
+
+ aNewData.InitFromStyle( pStyleSheet );
+ bAddUndo = TRUE;
+ rReq.Done();
+ nRetMask = TRUE;
+ }
+ }
+ break;
+
+ default:
+ break;
+ } // switch ( nSlotId )
+ } // case SFX_STYLE_FAMILY_PAGE:
+ break;
+
+ default:
+ break;
+ } // switch ( eFamily )
+
+ // Neu anlegen oder bearbeiten ueber Dialog:
+ if ( nSlotId == SID_STYLE_NEW || nSlotId == SID_STYLE_EDIT )
+ {
+ if ( pStyleSheet )
+ {
+ SvxNumberInfoItem* pNumberInfoItem = NULL;
+
+ SfxStyleFamily eFam = pStyleSheet->GetFamily();
+ SfxAbstractTabDialog* pDlg = NULL;
+ USHORT nRsc = 0;
+
+ // #37034#/#37245# alte Items aus der Vorlage merken
+ SfxItemSet aOldSet = pStyleSheet->GetItemSet();
+ String aOldName = pStyleSheet->GetName();
+
+ switch ( eFam )
+ {
+ case SFX_STYLE_FAMILY_PAGE:
+ nRsc = RID_SCDLG_STYLES_PAGE;
+ break;
+
+ case SFX_STYLE_FAMILY_PARA:
+ default:
+ {
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+
+ const SfxPoolItem* pItem;
+ if ( rSet.GetItemState( ATTR_VALUE_FORMAT,
+ FALSE, &pItem ) == SFX_ITEM_SET )
+ {
+ // NumberFormat Value aus Value und Language
+ // erzeugen und eintueten
+ ULONG nFormat =
+ ((SfxUInt32Item*)pItem)->GetValue();
+ LanguageType eLang =
+ ((SvxLanguageItem*)&rSet.Get(
+ ATTR_LANGUAGE_FORMAT ))->GetLanguage();
+ ULONG nLangFormat = pDoc->GetFormatTable()->
+ GetFormatForLanguageIfBuiltIn( nFormat, eLang );
+ if ( nLangFormat != nFormat )
+ {
+ SfxUInt32Item aNewItem( ATTR_VALUE_FORMAT, nLangFormat );
+ rSet.Put( aNewItem );
+ aOldSet.Put( aNewItem );
+ // auch in aOldSet fuer Vergleich nach dem Dialog,
+ // sonst geht evtl. eine Aenderung der Sprache verloren
+ }
+ }
+
+ pTabViewShell->MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
+ pDocSh->PutItem( *pNumberInfoItem );
+ nRsc = RID_SCDLG_STYLES_PAR;
+
+ // auf jeden Fall ein SvxBoxInfoItem mit Table = FALSE im Set:
+ // (wenn gar kein Item da ist, loescht der Dialog auch das
+ // BORDER_OUTER SvxBoxItem aus dem Vorlagen-Set)
+
+ if ( rSet.GetItemState( ATTR_BORDER_INNER, FALSE ) != SFX_ITEM_SET )
+ {
+ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
+ aBoxInfoItem.SetTable(FALSE); // keine inneren Linien
+ aBoxInfoItem.SetDist(TRUE);
+ aBoxInfoItem.SetMinDist(FALSE);
+ rSet.Put( aBoxInfoItem );
+ }
+ }
+ break;
+ }
+
+ // If GetDefDialogParent is a dialog, it must be used
+ // (style catalog)
+
+ Window* pParent = Application::GetDefDialogParent();
+ if ( !pParent || !pParent->IsDialog() )
+ {
+ // #107256# GetDefDialogParent currently doesn't return the window
+ // that was set with SetDefDialogParent (but dynamically finds the
+ // topmost parent of the focus window), so IsDialog above is FALSE
+ // even if called from the style catalog.
+ // -> Use NULL if a modal dialog is open, to enable the Dialog's
+ // default parent handling.
+ if ( Application::IsInModalMode() )
+ pParent = NULL;
+ else
+ pParent = pTabViewShell->GetDialogParent();
+ }
+
+ pTabViewShell->SetInFormatDialog(TRUE);
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScStyleDlg( pParent, *pStyleSheet, nRsc, nRsc );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ short nResult = pDlg->Execute();
+ pTabViewShell->SetInFormatDialog(FALSE);
+
+ if ( nResult == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ if ( pOutSet )
+ {
+ nRetMask = pStyleSheet->GetMask();
+
+ // #37034#/#37245# Attribut-Vergleiche (frueher in ModifyStyleSheet)
+ // jetzt hier mit den alten Werten (Style ist schon veraendert)
+
+ if ( SFX_STYLE_FAMILY_PARA == eFam )
+ {
+// pDoc->CellStyleChanged( *pStyleSheet, aOldSet );
+
+ SfxItemSet& rNewSet = pStyleSheet->GetItemSet();
+ BOOL bNumFormatChanged;
+ if ( ScGlobal::CheckWidthInvalidate(
+ bNumFormatChanged, aOldSet, rNewSet ) )
+ pDoc->InvalidateTextWidth( NULL, NULL, bNumFormatChanged );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (pDoc->IsStreamValid(nTab))
+ pDoc->SetStreamValid(nTab, FALSE);
+
+ ULONG nOldFormat = ((const SfxUInt32Item&)aOldSet.
+ Get( ATTR_VALUE_FORMAT )).GetValue();
+ ULONG nNewFormat = ((const SfxUInt32Item&)rNewSet.
+ Get( ATTR_VALUE_FORMAT )).GetValue();
+ if ( nNewFormat != nOldFormat )
+ {
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ const SvNumberformat* pOld = pFormatter->GetEntry( nOldFormat );
+ const SvNumberformat* pNew = pFormatter->GetEntry( nNewFormat );
+ if ( pOld && pNew && pOld->GetLanguage() != pNew->GetLanguage() )
+ rNewSet.Put( SvxLanguageItem(
+ pNew->GetLanguage(), ATTR_LANGUAGE_FORMAT ) );
+ }
+
+ pDoc->GetPool()->CellStyleCreated( pStyleSheet->GetName() );
+ }
+ else
+ {
+ //! auch fuer Seitenvorlagen die Abfragen hier
+
+ String aNewName = pStyleSheet->GetName();
+ if ( aNewName != aOldName &&
+ pDoc->RenamePageStyleInUse( aOldName, aNewName ) )
+ {
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+
+ pDoc->ModifyStyleSheet( *pStyleSheet, *pOutSet );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ }
+
+ pDocSh->SetDocumentModified();
+
+ if ( SFX_STYLE_FAMILY_PARA == eFam )
+ {
+ pTabViewShell->UpdateNumberFormatter( pDoc,
+ (const SvxNumberInfoItem&)
+ *(pDocSh->GetItem(SID_ATTR_NUMBERFORMAT_INFO)) );
+
+ pTabViewShell->UpdateStyleSheetInUse( (SfxStyleSheet*)pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ }
+
+ aNewData.InitFromStyle( pStyleSheet );
+ bAddUndo = TRUE;
+ }
+ }
+ else
+ {
+ if ( nSlotId == SID_STYLE_NEW )
+ pStylePool->Remove( pStyleSheet );
+ else
+ {
+ // falls zwischendurch etwas mit dem temporaer geaenderten
+ // ItemSet gepainted wurde:
+ pDocSh->PostPaintGridAll();
+ }
+ }
+ delete pDlg;
+ }
+ }
+
+// if ( nRetMask != 0xffff )// Irgendein Wert MUSS geliefert werden JN
+ rReq.SetReturnValue( SfxUInt16Item( nSlotId, nRetMask ) );
+
+// #96983# only stylist sends focus to sheet
+// if ( bGrabFocus )
+// pTabViewShell->GetActiveWin()->GrabFocus();
+
+ if ( bAddUndo && bUndo)
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoModifyStyle( pDocSh, eFamily, aOldData, aNewData ) );
+
+ if ( bStyleToMarked )
+ {
+ // call SetStyleSheetToMarked after adding the ScUndoModifyStyle,
+ // so redo will find the modified style
+ pTabViewShell->SetStyleSheetToMarked( (SfxStyleSheet*)pStyleSheet );
+ pTabViewShell->InvalidateAttribs();
+ }
+
+ if ( bListAction )
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+ else
+ {
+ DBG_ERROR( "Unknown slot (ScViewShell::ExecuteStyle)" );
+ }
+}
+
+void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ SfxBindings& rBindings = pTabViewShell->GetViewFrame()->GetBindings();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ // Eingabe beenden
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ switch ( nSlot )
+ {
+ case SID_NUMBER_TWODEC:
+ case SID_NUMBER_SCIENTIFIC:
+ case SID_NUMBER_DATE:
+ case SID_NUMBER_CURRENCY:
+ case SID_NUMBER_PERCENT:
+ case SID_NUMBER_STANDARD:
+ case SID_NUMBER_FORMAT:
+ case SID_NUMBER_INCDEC:
+ case SID_NUMBER_DECDEC:
+ case FID_DEFINE_NAME:
+ case FID_USE_NAME:
+ case FID_INSERT_NAME:
+ case SID_SPELL_DIALOG:
+ case SID_HANGUL_HANJA_CONVERSION:
+
+ pScMod->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ short nType = GetCurrentNumberFormatType();
+ SfxItemSet aSet( GetPool(), nSlot, nSlot );
+ switch ( nSlot )
+ {
+ case SID_NUMBER_TWODEC:
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER, 4 ); // Standard+4 = #.##0,00
+ rReq.Done();
+ break;
+ case SID_NUMBER_SCIENTIFIC:
+ if ((nType & NUMBERFORMAT_SCIENTIFIC))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_SCIENTIFIC );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_SCIENTIFIC)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_DATE:
+ if ((nType & NUMBERFORMAT_DATE))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_DATE );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_DATE)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_TIME:
+ if ((nType & NUMBERFORMAT_TIME))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_TIME );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_TIME)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_CURRENCY:
+ if ((nType & NUMBERFORMAT_CURRENCY))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_CURRENCY );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_CURRENCY)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_PERCENT:
+ if ((nType & NUMBERFORMAT_PERCENT))
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ else
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_PERCENT );
+ aSet.Put( SfxBoolItem(nSlot, !(nType & NUMBERFORMAT_PERCENT)) );
+ rBindings.Invalidate( nSlot );
+ rReq.Done();
+ break;
+ case SID_NUMBER_STANDARD:
+ pTabViewShell->SetNumberFormat( NUMBERFORMAT_NUMBER );
+ rReq.Done();
+ break;
+ case SID_NUMBER_INCDEC:
+ pTabViewShell->ChangeNumFmtDecimals( TRUE );
+ rReq.Done();
+ break;
+ case SID_NUMBER_DECDEC:
+ pTabViewShell->ChangeNumFmtDecimals( FALSE );
+ rReq.Done();
+ break;
+
+ case SID_NUMBER_FORMAT:
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if(pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET)
+ {
+ String aCode = ((const SfxStringItem*)pItem)->GetValue();
+ pTabViewShell->SetNumFmtByStr( aCode );
+ }
+ }
+ break;
+
+ case SID_ATTR_NUMBERFORMAT_VALUE:
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( ATTR_VALUE_FORMAT, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ // We have to accomplish this using ApplyAttributes()
+ // because we also need the language information to be
+ // considered.
+ const SfxItemSet& rOldSet =
+ pTabViewShell->GetSelectionPattern()->GetItemSet();
+ SfxItemPool* pDocPool = GetViewData()->GetDocument()->GetPool();
+ SfxItemSet aNewSet( *pDocPool, ATTR_PATTERN_START, ATTR_PATTERN_END );
+ aNewSet.Put( *pItem );
+ pTabViewShell->ApplyAttributes( &aNewSet, &rOldSet, TRUE );
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR("falscher Slot bei ExecuteEdit");
+ break;
+ }
+}
+
+
+//------------------------------------------------------------------
+
+#define APPLY_HOR_JUSTIFY(j) \
+ { \
+ if ( !pHorJustify || (eHorJustify != (j) ) ) \
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( (j) ) ); \
+ else \
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( SVX_HOR_JUSTIFY_STANDARD ) ); \
+ }
+
+#define APPLY_VER_JUSTIFY(j) \
+ { \
+ if ( !pVerJustify || (eVerJustify != (j) ) ) \
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( (j) ) ); \
+ else \
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( SVX_VER_JUSTIFY_STANDARD ) ); \
+ }
+
+void ScFormatShell::ExecuteAlignment( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pSet = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ switch( nSlot )
+ {
+ // pseudo slots for Format menu
+ case SID_ALIGN_ANY_HDEFAULT:
+ case SID_ALIGN_ANY_LEFT:
+ case SID_ALIGN_ANY_HCENTER:
+ case SID_ALIGN_ANY_RIGHT:
+ case SID_ALIGN_ANY_JUSTIFIED:
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( lclConvertSlotToHAlign( nSlot ), ATTR_HOR_JUSTIFY ) );
+ break;
+ case SID_ALIGN_ANY_VDEFAULT:
+ case SID_ALIGN_ANY_TOP:
+ case SID_ALIGN_ANY_VCENTER:
+ case SID_ALIGN_ANY_BOTTOM:
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( lclConvertSlotToVAlign( nSlot ), ATTR_VER_JUSTIFY ) );
+ break;
+
+ default:
+ if( pSet )
+ {
+ const SfxPoolItem* pItem = NULL;
+ if( pSet->GetItemState(GetPool().GetWhich(nSlot), TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_ALIGN_HOR_JUSTIFY:
+ case SID_ATTR_ALIGN_VER_JUSTIFY:
+ case SID_ATTR_ALIGN_INDENT:
+ case SID_ATTR_ALIGN_HYPHENATION:
+ case SID_ATTR_ALIGN_DEGREES:
+ case SID_ATTR_ALIGN_LOCKPOS:
+ case SID_ATTR_ALIGN_MARGIN:
+ case SID_ATTR_ALIGN_STACKED:
+ pTabViewShell->ApplyAttr( *pItem );
+ break;
+
+ case SID_H_ALIGNCELL:
+ {
+ SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem*)pItem)->GetValue();
+ // #i78476# update alignment of text in cell edit mode
+ pTabViewShell->UpdateInputHandlerCellAdjust( eJust );
+ pTabViewShell->ApplyAttr( SvxHorJustifyItem( eJust, ATTR_HOR_JUSTIFY ) );
+ }
+ break;
+ case SID_V_ALIGNCELL:
+ pTabViewShell->ApplyAttr( SvxVerJustifyItem( (SvxCellVerJustify)((const SvxVerJustifyItem*)pItem)->GetValue(), ATTR_VER_JUSTIFY ) );
+ break;
+ default:
+ DBG_ERROR( "ExecuteAlignment: invalid slot" );
+ return;
+ }
+ }
+ }
+ }
+
+ rBindings.Invalidate( SID_ALIGNLEFT );
+ rBindings.Invalidate( SID_ALIGNRIGHT );
+ rBindings.Invalidate( SID_ALIGNCENTERHOR );
+ rBindings.Invalidate( SID_ALIGNBLOCK );
+ rBindings.Invalidate( SID_ALIGNTOP );
+ rBindings.Invalidate( SID_ALIGNBOTTOM );
+ rBindings.Invalidate( SID_ALIGNCENTERVER );
+ rBindings.Invalidate( SID_V_ALIGNCELL );
+ rBindings.Invalidate( SID_H_ALIGNCELL );
+ // pseudo slots for Format menu
+ rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
+ rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
+ rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
+ rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+ rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
+ rBindings.Invalidate( SID_ALIGN_ANY_TOP );
+ rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
+ rBindings.Update();
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+}
+
+void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
+ const SfxItemSet* pSet = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ SfxAllItemSet* pNewSet = 0;
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( (nSlot == SID_ATTR_CHAR_WEIGHT)
+ ||(nSlot == SID_ATTR_CHAR_POSTURE)
+ ||(nSlot == SID_ATTR_CHAR_UNDERLINE)
+ ||(nSlot == SID_ULINE_VAL_NONE)
+ ||(nSlot == SID_ULINE_VAL_SINGLE)
+ ||(nSlot == SID_ULINE_VAL_DOUBLE)
+ ||(nSlot == SID_ULINE_VAL_DOTTED) )
+ {
+ pNewSet = new SfxAllItemSet( GetPool() );
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ BYTE nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ if ( pSet )
+ aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_WEIGHT ) );
+ else
+ {
+ // toggle manually
+
+ FontWeight eWeight = WEIGHT_BOLD;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), FALSE );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxWeightItem*)pCore)->GetWeight() == WEIGHT_BOLD )
+ eWeight = WEIGHT_NORMAL;
+
+ aSetItem.PutItemForScriptType( nScript, SvxWeightItem( eWeight, ATTR_FONT_WEIGHT ) );
+ }
+ pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
+ pNewSet->Put( aSetItem.GetItemSet(), FALSE );
+ }
+ break;
+
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ BYTE nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ if ( pSet )
+ aSetItem.PutItemForScriptType( nScript, pSet->Get( ATTR_FONT_POSTURE ) );
+ else
+ {
+ // toggle manually
+
+ FontItalic eItalic = ITALIC_NORMAL;
+ SvxScriptSetItem aOldSetItem( nSlot, rPool );
+ aOldSetItem.GetItemSet().Put( pAttrs->GetItemSet(), FALSE );
+ const SfxPoolItem* pCore = aOldSetItem.GetItemOfScript( nScript );
+ if ( pCore && ((const SvxPostureItem*)pCore)->GetPosture() == ITALIC_NORMAL )
+ eItalic = ITALIC_NONE;
+
+ aSetItem.PutItemForScriptType( nScript, SvxPostureItem( eItalic, ATTR_FONT_POSTURE ) );
+ }
+ pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
+ pNewSet->Put( aSetItem.GetItemSet(), FALSE );
+ }
+ break;
+
+ case SID_ATTR_CHAR_UNDERLINE:
+ {
+ FontUnderline eUnderline;
+
+ if( pSet )
+ {
+ const SvxUnderlineItem& rUnderline = (const SvxUnderlineItem&)pSet->Get( ATTR_FONT_UNDERLINE );
+
+ if( rUnderline.ISA(SvxUnderlineItem) )
+ {
+ pTabViewShell->ApplyAttr( rUnderline );
+ pNewSet->Put( rUnderline,rUnderline.Which() );
+ }
+ }
+ else
+ {
+ SvxUnderlineItem aUnderline( (const SvxUnderlineItem&)
+ pAttrs->GetItem(
+ ATTR_FONT_UNDERLINE ) );
+ eUnderline = (UNDERLINE_NONE != aUnderline.GetLineStyle())
+ ? UNDERLINE_NONE
+ : UNDERLINE_SINGLE;
+ aUnderline.SetLineStyle( eUnderline );
+ pTabViewShell->ApplyAttr( aUnderline );
+ pNewSet->Put( aUnderline,aUnderline.Which() );
+ }
+ }
+ break;
+
+ case SID_ULINE_VAL_NONE:
+ pTabViewShell->ApplyAttr( SvxUnderlineItem( UNDERLINE_NONE, ATTR_FONT_UNDERLINE ) );
+ break;
+ case SID_ULINE_VAL_SINGLE: // Toggles
+ case SID_ULINE_VAL_DOUBLE:
+ case SID_ULINE_VAL_DOTTED:
+ {
+ FontUnderline eOld = ((const SvxUnderlineItem&)
+ pAttrs->GetItem(ATTR_FONT_UNDERLINE)).GetLineStyle();
+ FontUnderline eNew = eOld;
+ switch (nSlot)
+ {
+ case SID_ULINE_VAL_SINGLE:
+ eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE;
+ break;
+ case SID_ULINE_VAL_DOUBLE:
+ eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE;
+ break;
+ case SID_ULINE_VAL_DOTTED:
+ eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED;
+ break;
+ }
+ pTabViewShell->ApplyAttr( SvxUnderlineItem( eNew, ATTR_FONT_UNDERLINE ) );
+ }
+ break;
+
+ default:
+ break;
+ }
+ rBindings.Invalidate( nSlot );
+ }
+ else
+ {
+ /*
+ * "Selbstgemachte" RadioButton-Funktionalitaet
+ * Beim Toggle gibt es den Standard-State, d.h. kein
+ * Button ist gedrueckt
+ */
+
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ const SfxPoolItem* pItem = NULL;
+ const SvxHorJustifyItem* pHorJustify = NULL;
+ const SvxVerJustifyItem* pVerJustify = NULL;
+ SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
+ SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
+
+ if (rAttrSet.GetItemState(ATTR_HOR_JUSTIFY, TRUE,&pItem ) == SFX_ITEM_SET)
+ {
+ pHorJustify = (const SvxHorJustifyItem*)pItem;
+ eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
+ }
+ if (rAttrSet.GetItemState(ATTR_VER_JUSTIFY, TRUE,&pItem ) == SFX_ITEM_SET)
+ {
+ pVerJustify = (const SvxVerJustifyItem*)pItem;
+ eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
+ }
+
+ switch ( nSlot )
+ {
+ case SID_ALIGNLEFT:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_LEFT) ?
+ SVX_HOR_JUSTIFY_LEFT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_LEFT );
+ //break;
+
+ case SID_ALIGNRIGHT:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_RIGHT) ?
+ SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_RIGHT );
+ //break;
+
+ case SID_ALIGNCENTERHOR:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_CENTER) ?
+ SVX_HOR_JUSTIFY_CENTER : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_CENTER );
+ //break;
+
+ case SID_ALIGNBLOCK:
+ rReq.SetSlot( SID_H_ALIGNCELL );
+ rReq.AppendItem( SvxHorJustifyItem(
+ !pHorJustify || (eHorJustify != SVX_HOR_JUSTIFY_BLOCK) ?
+ SVX_HOR_JUSTIFY_BLOCK : SVX_HOR_JUSTIFY_STANDARD, SID_H_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_HOR_JUSTIFY( SVX_HOR_JUSTIFY_BLOCK );
+ //break;
+
+ case SID_ALIGNTOP:
+ rReq.SetSlot( SID_V_ALIGNCELL );
+ rReq.AppendItem( SvxVerJustifyItem(
+ !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_TOP) ?
+ SVX_VER_JUSTIFY_TOP : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_TOP );
+ //break;
+
+ case SID_ALIGNBOTTOM:
+ rReq.SetSlot( SID_V_ALIGNCELL );
+ rReq.AppendItem( SvxVerJustifyItem(
+ !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_BOTTOM) ?
+ SVX_VER_JUSTIFY_BOTTOM : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_BOTTOM );
+ //break;
+
+ case SID_ALIGNCENTERVER:
+ rReq.SetSlot( SID_V_ALIGNCELL );
+ rReq.AppendItem( SvxVerJustifyItem(
+ !pVerJustify || (eVerJustify != SVX_VER_JUSTIFY_CENTER) ?
+ SVX_VER_JUSTIFY_CENTER : SVX_VER_JUSTIFY_STANDARD, SID_V_ALIGNCELL ) );
+ ExecuteSlot( rReq, GetInterface() );
+ return;
+// APPLY_VER_JUSTIFY( SVX_VER_JUSTIFY_CENTER );
+ //break;
+
+ default:
+ break;
+ }
+
+ }
+
+ rBindings.Update();
+// rReq.Done();
+
+ if( pNewSet )
+ {
+ rReq.Done( *pNewSet );
+ delete pNewSet;
+ }
+ else
+ {
+ rReq.Done();
+ }
+
+}
+
+#undef APPLY_HOR_JUSTIFY
+#undef APPLY_VER_JUSTIFY
+
+//------------------------------------------------------------------
+
+void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SfxBindings& rBindings = pViewData->GetBindings();
+ const SfxItemSet* pNewAttrs = rReq.GetArgs();
+
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+
+ if ( !pNewAttrs )
+ {
+ USHORT nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ pTabViewShell->ExecuteCellFormatDlg( rReq, TP_FONT ); // wenn ToolBar vertikal
+ break;
+
+ case SID_ATTR_ALIGN_LINEBREAK: // ohne Parameter als Toggle
+ {
+ const ScPatternAttr* pAttrs = pTabViewShell->GetSelectionPattern();
+ BOOL bOld = ((const SfxBoolItem&)pAttrs->GetItem(ATTR_LINEBREAK)).GetValue();
+ SfxBoolItem aBreakItem( ATTR_LINEBREAK, !bOld );
+ pTabViewShell->ApplyAttr( aBreakItem );
+
+ SfxAllItemSet aNewSet( GetPool() );
+ aNewSet.Put( aBreakItem,aBreakItem.Which() );
+ rReq.Done( aNewSet );
+
+ rBindings.Invalidate( nSlot );
+ }
+ break;
+
+ case SID_BACKGROUND_COLOR:
+ {
+ // SID_BACKGROUND_COLOR without arguments -> set transparent background
+
+ SvxBrushItem aBrushItem( (const SvxBrushItem&)
+ pTabViewShell->GetSelectionPattern()->
+ GetItem( ATTR_BACKGROUND ) );
+
+ aBrushItem.SetColor( COL_TRANSPARENT );
+
+ pTabViewShell->ApplyAttr( aBrushItem );
+ }
+ break;
+ }
+ }
+ else
+ {
+ USHORT nSlot = rReq.GetSlot();
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_OVERLINE:
+ case SID_ATTR_CHAR_STRIKEOUT:
+ case SID_ATTR_ALIGN_LINEBREAK:
+ case SID_ATTR_CHAR_COLOR:
+ case SID_ATTR_CHAR_CONTOUR:
+ case SID_ATTR_CHAR_SHADOWED:
+ case SID_ATTR_CHAR_RELIEF:
+ case SID_SCATTR_PROTECTION :
+ pTabViewShell->ApplyAttr( pNewAttrs->Get( pNewAttrs->GetPool()->GetWhich( nSlot ) ) );
+ rBindings.Invalidate( nSlot );
+ rBindings.Update( nSlot );
+ break;
+
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ {
+ // #i78017 establish the same behaviour as in Writer
+ BYTE nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ nScript = pTabViewShell->GetSelectionScriptType();
+
+ SfxItemPool& rPool = GetPool();
+ SvxScriptSetItem aSetItem( nSlot, rPool );
+ USHORT nWhich = rPool.GetWhich( nSlot );
+ aSetItem.PutItemForScriptType( nScript, pNewAttrs->Get( nWhich ) );
+
+ pTabViewShell->ApplyUserItemSet( aSetItem.GetItemSet() );
+
+ rBindings.Invalidate( nSlot );
+ rBindings.Update( nSlot );
+ }
+ break;
+
+ case SID_FRAME_LINESTYLE:
+ {
+ // Default-Linie aktualisieren
+ const SvxBorderLine* pLine =
+ ((const SvxLineItem&)
+ pNewAttrs->Get( SID_FRAME_LINESTYLE )).
+ GetLine();
+
+ if ( pLine )
+ {
+ SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
+
+ if ( pDefLine )
+ {
+ pDefLine->SetOutWidth( pLine->GetOutWidth() );
+ pDefLine->SetInWidth ( pLine->GetInWidth() );
+ pDefLine->SetDistance( pLine->GetDistance() );
+ pDefLine->SetStyle( pLine->GetStyle( ) );
+ pTabViewShell->SetSelectionFrameLines( pDefLine, FALSE );
+ }
+ else
+ {
+ pTabViewShell->SetDefaultFrameLine( pLine );
+ pTabViewShell->GetDefaultFrameLine()->SetColor( COL_BLACK );
+ pTabViewShell->SetSelectionFrameLines( pLine, FALSE );
+ }
+ }
+ else
+ {
+ Color aColorBlack( COL_BLACK );
+ SvxBorderLine aDefLine( &aColorBlack, 20, 0, 0 );
+ pTabViewShell->SetDefaultFrameLine( &aDefLine );
+ pTabViewShell->SetSelectionFrameLines( NULL, FALSE );
+ }
+ }
+ break;
+
+ case SID_FRAME_LINECOLOR:
+ {
+ SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
+ const Color& rColor = ((const SvxColorItem&)
+ pNewAttrs->Get( SID_FRAME_LINECOLOR )).
+ GetValue();
+
+ // Default-Linie aktualisieren
+ if ( pDefLine )
+ {
+ pDefLine->SetColor( rColor );
+ pTabViewShell->SetSelectionFrameLines( pDefLine, TRUE );
+ }
+ else
+ {
+ SvxBorderLine aDefLine( &rColor, 20, 0, 0 );
+ pTabViewShell->SetDefaultFrameLine( &aDefLine );
+ pTabViewShell->SetSelectionFrameLines( &aDefLine, FALSE );
+ }
+ }
+ break;
+
+ case SID_ATTR_BORDER_OUTER:
+ case SID_ATTR_BORDER:
+ {
+ SvxBorderLine* pDefLine = pTabViewShell->GetDefaultFrameLine();
+ const ScPatternAttr* pOldAttrs = pTabViewShell->GetSelectionPattern();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SfxItemSet* pOldSet =
+ new SfxItemSet(
+ *(pDoc->GetPool()),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+ SfxItemSet* pNewSet =
+ new SfxItemSet(
+ *(pDoc->GetPool()),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+ const SfxPoolItem& rBorderAttr =
+ pOldAttrs->GetItemSet().
+ Get( ATTR_BORDER );
+
+ // Border-Items vom Controller auswerten:
+ const SfxPoolItem* pItem = 0;
+
+ if ( pNewAttrs->GetItemState( ATTR_BORDER, TRUE, &pItem )
+ == SFX_ITEM_SET )
+ {
+ // #100959# The SvxFrameToolBoxControl toolbox controller uses a default
+ // SvxBorderLine (all widths 0) to mark the lines that should be set.
+ // Macro recording uses a SvxBoxItem with the real values (OutWidth > 0)
+ // or NULL pointers for no lines.
+ // -> Substitute existing lines with pDefLine only if widths are 0.
+ SvxBoxItem aBoxItem ( *(const SvxBoxItem*)pItem );
+ if ( aBoxItem.GetTop() && aBoxItem.GetTop()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_TOP );
+ if ( aBoxItem.GetBottom() && aBoxItem.GetBottom()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_BOTTOM );
+ if ( aBoxItem.GetLeft() && aBoxItem.GetLeft()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_LEFT );
+ if ( aBoxItem.GetRight() && aBoxItem.GetRight()->GetOutWidth() == 0 )
+ aBoxItem.SetLine( pDefLine, BOX_LINE_RIGHT );
+ pNewSet->Put( aBoxItem );
+ rReq.AppendItem( aBoxItem );
+ }
+
+ if ( pNewAttrs->GetItemState( ATTR_BORDER_INNER, TRUE, &pItem )
+ == SFX_ITEM_SET )
+ {
+ SvxBoxInfoItem aBoxInfoItem( *(const SvxBoxInfoItem*)pItem );
+ if ( aBoxInfoItem.GetHori() && aBoxInfoItem.GetHori()->GetOutWidth() == 0 )
+ aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_HORI );
+ if ( aBoxInfoItem.GetVert() && aBoxInfoItem.GetVert()->GetOutWidth() == 0 )
+ aBoxInfoItem.SetLine( pDefLine, BOXINFO_LINE_VERT );
+ pNewSet->Put( aBoxInfoItem );
+ rReq.AppendItem( aBoxInfoItem );
+ }
+ else
+ {
+ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
+ aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_HORI );
+ aBoxInfoItem.SetLine( NULL, BOXINFO_LINE_VERT );
+ pNewSet->Put( aBoxInfoItem );
+ }
+
+ pOldSet->Put( rBorderAttr );
+ pTabViewShell->ApplyAttributes( pNewSet, pOldSet );
+
+ delete pOldSet;
+ delete pNewSet;
+ }
+ break;
+
+ // ATTR_BACKGROUND (=SID_ATTR_BRUSH) muss ueber zwei IDs
+ // gesetzt werden:
+ case SID_BACKGROUND_COLOR:
+ {
+ const SvxColorItem rNewColorItem = (const SvxColorItem&)
+ pNewAttrs->Get( SID_BACKGROUND_COLOR );
+
+ SvxBrushItem aBrushItem( (const SvxBrushItem&)
+ pTabViewShell->GetSelectionPattern()->
+ GetItem( ATTR_BACKGROUND ) );
+
+ aBrushItem.SetColor( rNewColorItem.GetValue() );
+
+ pTabViewShell->ApplyAttr( aBrushItem );
+ }
+ break;
+
+ case SID_ATTR_BRUSH:
+ {
+ SvxBrushItem aBrushItem( (const SvxBrushItem&)
+ pTabViewShell->GetSelectionPattern()->
+ GetItem( ATTR_BACKGROUND ) );
+ const SvxBrushItem& rNewBrushItem = (const SvxBrushItem&)
+ pNewAttrs->Get( GetPool().GetWhich(nSlot) );
+ aBrushItem.SetColor(rNewBrushItem.GetColor());
+ pTabViewShell->ApplyAttr( aBrushItem );
+ }
+ break;
+
+ case SID_ATTR_BORDER_SHADOW:
+ {
+ const SvxShadowItem& rNewShadowItem = (const SvxShadowItem&)
+ pNewAttrs->Get( ATTR_SHADOW );
+ pTabViewShell->ApplyAttr( rNewShadowItem );
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( ! rReq.IsAPI() )
+ if( ! rReq.IsDone() )
+ rReq.Done();
+ }
+}
+
+void ScFormatShell::GetAttrState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ const SvxBorderLine* pLine = pTabViewShell->GetDefaultFrameLine();
+ const SvxBrushItem& rBrushItem = (const SvxBrushItem&)rAttrSet.Get( ATTR_BACKGROUND );
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+
+ rSet.Put( rAttrSet, FALSE );
+
+ // choose font info according to selection script type
+ BYTE nScript = 0; // GetSelectionScriptType never returns 0
+ if ( rSet.GetItemState( ATTR_FONT ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT, nScript );
+ }
+ if ( rSet.GetItemState( ATTR_FONT_HEIGHT ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_HEIGHT, nScript );
+ }
+
+ while ( nWhich )
+ {
+ switch(nWhich)
+ {
+ case SID_BACKGROUND_COLOR:
+ {
+ rSet.Put( SvxColorItem( rBrushItem.GetColor(), SID_BACKGROUND_COLOR ) );
+ }
+ break;
+ case SID_FRAME_LINECOLOR:
+ {
+ rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
+ }
+ break;
+ case SID_ATTR_BRUSH:
+ {
+ rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
+ }
+ break;
+/* case SID_ATTR_ALIGN_LINEBREAK:
+ {
+ const SfxBoolItem& rBreakItem = (const SfxBoolItem&)rAttrSet.Get( ATTR_LINEBREAK );
+ rSet.Put( rBreakItem, GetPool().GetWhich(nWhich) );
+ }
+ break;
+*/
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetTextAttrState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ rSet.Put( rAttrSet, FALSE ); // ItemStates mitkopieren
+
+ // choose font info according to selection script type
+ BYTE nScript = 0; // GetSelectionScriptType never returns 0
+ if ( rSet.GetItemState( ATTR_FONT_WEIGHT ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_WEIGHT, nScript );
+ }
+ if ( rSet.GetItemState( ATTR_FONT_POSTURE ) != SFX_ITEM_UNKNOWN )
+ {
+ if (!nScript) nScript = pTabViewShell->GetSelectionScriptType();
+ ScViewUtil::PutItemScript( rSet, rAttrSet, ATTR_FONT_POSTURE, nScript );
+ }
+
+ SfxItemState eState;
+// const SfxPoolItem* pItem;
+
+ //--------------------------------------------------------------------
+ // eigene Kontrolle ueber RadioButton-Funktionalitaet:
+ //--------------------------------------------------------------------
+ // Unterstreichung
+ //------------------------
+
+ eState = rAttrSet.GetItemState( ATTR_FONT_UNDERLINE, TRUE );
+ if ( eState == SFX_ITEM_DONTCARE )
+ {
+ rSet.InvalidateItem( SID_ULINE_VAL_NONE );
+ rSet.InvalidateItem( SID_ULINE_VAL_SINGLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOUBLE );
+ rSet.InvalidateItem( SID_ULINE_VAL_DOTTED );
+ }
+ else
+ {
+ FontUnderline eUnderline = ((const SvxUnderlineItem&)
+ rAttrSet.Get(ATTR_FONT_UNDERLINE)).GetLineStyle();
+ USHORT nId = SID_ULINE_VAL_NONE;
+ switch (eUnderline)
+ {
+ case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break;
+ case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break;
+ case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break;
+ default:
+ break;
+ }
+ rSet.Put( SfxBoolItem( nId, TRUE ) );
+ }
+
+ //------------------------
+ // horizontale Ausrichtung
+ //------------------------
+
+ const SvxHorJustifyItem* pHorJustify = NULL;
+ const SvxVerJustifyItem* pVerJustify = NULL;
+ SvxCellHorJustify eHorJustify = SVX_HOR_JUSTIFY_STANDARD;
+ SvxCellVerJustify eVerJustify = SVX_VER_JUSTIFY_STANDARD;
+ USHORT nWhich = 0;
+ BOOL bJustifyStd = FALSE;
+ SfxBoolItem aBoolItem ( 0, TRUE );
+
+ eState = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY, TRUE,
+ (const SfxPoolItem**)&pHorJustify );
+ switch ( eState )
+ {
+ case SFX_ITEM_SET:
+ {
+ eHorJustify = SvxCellHorJustify( pHorJustify->GetValue() );
+
+ switch ( SvxCellHorJustify( pHorJustify->GetValue() ) )
+ {
+ case SVX_HOR_JUSTIFY_STANDARD:
+ break;
+
+ case SVX_HOR_JUSTIFY_LEFT:
+ nWhich = SID_ALIGNLEFT;
+ break;
+
+ case SVX_HOR_JUSTIFY_RIGHT:
+ nWhich = SID_ALIGNRIGHT;
+ break;
+
+ case SVX_HOR_JUSTIFY_CENTER:
+ nWhich = SID_ALIGNCENTERHOR;
+ break;
+
+ case SVX_HOR_JUSTIFY_BLOCK:
+ nWhich = SID_ALIGNBLOCK;
+ break;
+
+ case SVX_HOR_JUSTIFY_REPEAT:
+ default:
+ bJustifyStd = TRUE;
+ break;
+ }
+ }
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ rSet.InvalidateItem( SID_ALIGNLEFT );
+ rSet.InvalidateItem( SID_ALIGNRIGHT );
+ rSet.InvalidateItem( SID_ALIGNCENTERHOR );
+ rSet.InvalidateItem( SID_ALIGNBLOCK );
+ break;
+
+ default:
+ bJustifyStd = TRUE;
+ break;
+ }
+
+ if ( nWhich )
+ {
+ aBoolItem.SetWhich( nWhich );
+ rSet.Put( aBoolItem );
+ }
+ else if ( bJustifyStd )
+ {
+ aBoolItem.SetValue( FALSE );
+ aBoolItem.SetWhich( SID_ALIGNLEFT ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNRIGHT ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNCENTERHOR ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNBLOCK ); rSet.Put( aBoolItem );
+ bJustifyStd = FALSE;
+ }
+
+ //------------------------
+ // vertikale Ausrichtung
+ //------------------------
+
+ nWhich = 0;
+ aBoolItem.SetValue( TRUE );
+
+ eState = rAttrSet.GetItemState( ATTR_VER_JUSTIFY, TRUE,
+ (const SfxPoolItem**)&pVerJustify );
+
+ switch ( eState )
+ {
+ case SFX_ITEM_SET:
+ {
+ eVerJustify = SvxCellVerJustify( pVerJustify->GetValue() );
+
+ switch ( eVerJustify )
+ {
+ case SVX_VER_JUSTIFY_TOP:
+ nWhich = SID_ALIGNTOP;
+ break;
+
+ case SVX_VER_JUSTIFY_BOTTOM:
+ nWhich = SID_ALIGNBOTTOM;
+ break;
+
+ case SVX_VER_JUSTIFY_CENTER:
+ nWhich = SID_ALIGNCENTERVER;
+ break;
+
+ case SVX_VER_JUSTIFY_STANDARD:
+ default:
+ bJustifyStd = TRUE;
+ break;
+ }
+ }
+ break;
+
+ case SFX_ITEM_DONTCARE:
+ rSet.InvalidateItem( SID_ALIGNTOP );
+ rSet.InvalidateItem( SID_ALIGNBOTTOM );
+ rSet.InvalidateItem( SID_ALIGNCENTERVER );
+ break;
+
+ default:
+ bJustifyStd = TRUE;
+ break;
+ }
+
+ if ( nWhich )
+ {
+ aBoolItem.SetWhich( nWhich );
+ rSet.Put( aBoolItem );
+ }
+ else if ( bJustifyStd )
+ {
+ aBoolItem.SetValue( FALSE );
+ aBoolItem.SetWhich( SID_ALIGNTOP ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNBOTTOM ); rSet.Put( aBoolItem );
+ aBoolItem.SetWhich( SID_ALIGNCENTERVER ); rSet.Put( aBoolItem );
+ }
+}
+
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetBorderState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ SvxBoxItem aBoxItem( ATTR_BORDER );
+ SvxBoxInfoItem aInfoItem( ATTR_BORDER_INNER );
+
+ pTabViewShell->GetSelectionFrame( aBoxItem, aInfoItem );
+
+ if ( rSet.GetItemState( ATTR_BORDER ) != SFX_ITEM_UNKNOWN )
+ rSet.Put( aBoxItem );
+ if ( rSet.GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_UNKNOWN )
+ rSet.Put( aInfoItem );
+}
+
+//------------------------------------------------------------------
+
+void ScFormatShell::GetAlignState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ SvxCellHorJustify eHAlign = SVX_HOR_JUSTIFY_STANDARD;
+ bool bHasHAlign = rAttrSet.GetItemState( ATTR_HOR_JUSTIFY ) != SFX_ITEM_DONTCARE;
+ if( bHasHAlign )
+ eHAlign = (SvxCellHorJustify)((const SvxHorJustifyItem&) rAttrSet.Get( ATTR_HOR_JUSTIFY )).GetValue();
+
+ SvxCellVerJustify eVAlign = SVX_VER_JUSTIFY_STANDARD;
+ bool bHasVAlign = rAttrSet.GetItemState( ATTR_VER_JUSTIFY ) != SFX_ITEM_DONTCARE;
+ if( bHasVAlign )
+ eVAlign = (SvxCellVerJustify)((const SvxVerJustifyItem&) rAttrSet.Get( ATTR_VER_JUSTIFY )).GetValue();
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_H_ALIGNCELL:
+ if ( bHasHAlign )
+ rSet.Put( SvxHorJustifyItem( eHAlign, nWhich ));
+ break;
+ case SID_V_ALIGNCELL:
+ if ( bHasVAlign )
+ rSet.Put( SvxVerJustifyItem( eVAlign, nWhich ));
+ break;
+
+ // pseudo slots for Format menu
+ case SID_ALIGN_ANY_HDEFAULT:
+ case SID_ALIGN_ANY_LEFT:
+ case SID_ALIGN_ANY_HCENTER:
+ case SID_ALIGN_ANY_RIGHT:
+ case SID_ALIGN_ANY_JUSTIFIED:
+ rSet.Put( SfxBoolItem( nWhich, bHasHAlign && (eHAlign == lclConvertSlotToHAlign( nWhich )) ) );
+ break;
+ case SID_ALIGN_ANY_VDEFAULT:
+ case SID_ALIGN_ANY_TOP:
+ case SID_ALIGN_ANY_VCENTER:
+ case SID_ALIGN_ANY_BOTTOM:
+ rSet.Put( SfxBoolItem( nWhich, bHasVAlign && (eVAlign == lclConvertSlotToVAlign( nWhich )) ) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScFormatShell::GetNumFormatState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ ScDocument* pDoc = pViewData->GetDocument();
+ short nType = GetCurrentNumberFormatType();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_NUMBER_FORMAT:
+ {
+ String aFormatCode; // bleibt leer, wenn dont-care
+
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+ if ( rAttrSet.GetItemState( ATTR_VALUE_FORMAT ) != SFX_ITEM_DONTCARE )
+ {
+ ULONG nNumberFormat = ((const SfxUInt32Item&)rAttrSet.Get(
+ ATTR_VALUE_FORMAT )).GetValue();
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ const SvNumberformat* pFormatEntry = pFormatter->GetEntry( nNumberFormat );
+ if ( pFormatEntry )
+ aFormatCode = pFormatEntry->GetFormatstring();
+ }
+
+ rSet.Put( SfxStringItem( nWhich, aFormatCode ) );
+ }
+ break;
+ case SID_NUMBER_SCIENTIFIC:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_SCIENTIFIC)) );
+ break;
+ case SID_NUMBER_DATE:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_DATE)) );
+ break;
+ case SID_NUMBER_CURRENCY:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_CURRENCY)) );
+ break;
+ case SID_NUMBER_PERCENT:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_PERCENT)) );
+ break;
+ case SID_NUMBER_TIME:
+ rSet.Put( SfxBoolItem(nWhich, (nType & NUMBERFORMAT_TIME)) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+void ScFormatShell::ExecuteTextDirection( SfxRequest& rReq )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ pTabViewShell->HideListBox(); // Autofilter-DropDown-Listbox
+ if ( GetViewData()->HasEditView( GetViewData()->GetActivePart() ) )
+ {
+ SC_MOD()->InputEnterHandler();
+ pTabViewShell->UpdateInputHandler();
+ }
+
+ USHORT nSlot = rReq.GetSlot();
+ switch( nSlot )
+ {
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ {
+ BOOL bVert = (nSlot == SID_TEXTDIRECTION_TOP_TO_BOTTOM);
+ ScPatternAttr aAttr( GetViewData()->GetDocument()->GetPool() );
+ SfxItemSet& rItemSet = aAttr.GetItemSet();
+ rItemSet.Put( SfxBoolItem( ATTR_STACKED, bVert ) );
+ rItemSet.Put( SfxBoolItem( ATTR_VERTICAL_ASIAN, bVert ) );
+ pTabViewShell->ApplySelectionPattern( aAttr );
+ pTabViewShell->AdjustBlockHeight();
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ {
+ SvxFrameDirection eDirection = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ) ?
+ FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP;
+ pTabViewShell->ApplyAttr( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
+ }
+ break;
+ }
+}
+
+void ScFormatShell::GetTextDirectionState( SfxItemSet& rSet )
+{
+ ScTabViewShell* pTabViewShell = GetViewData()->GetViewShell();
+ const SfxItemSet& rAttrSet = pTabViewShell->GetSelectionPattern()->GetItemSet();
+
+ BOOL bVertDontCare =
+ (rAttrSet.GetItemState( ATTR_VERTICAL_ASIAN ) == SFX_ITEM_DONTCARE) ||
+ (rAttrSet.GetItemState( ATTR_STACKED ) == SFX_ITEM_DONTCARE);
+ BOOL bLeftRight = !bVertDontCare &&
+ !((const SfxBoolItem&) rAttrSet.Get( ATTR_STACKED )).GetValue();
+ BOOL bTopBottom = !bVertDontCare && !bLeftRight &&
+ ((const SfxBoolItem&) rAttrSet.Get( ATTR_VERTICAL_ASIAN )).GetValue();
+
+ BOOL bBidiDontCare = (rAttrSet.GetItemState( ATTR_WRITINGDIR ) == SFX_ITEM_DONTCARE);
+ EEHorizontalTextDirection eBidiDir = EE_HTEXTDIR_DEFAULT;
+ if ( !bBidiDontCare )
+ {
+ SvxFrameDirection eCellDir = (SvxFrameDirection)((const SvxFrameDirectionItem&)
+ rAttrSet.Get( ATTR_WRITINGDIR )).GetValue();
+ if ( eCellDir == FRMDIR_ENVIRONMENT )
+ eBidiDir = (EEHorizontalTextDirection)GetViewData()->GetDocument()->
+ GetEditTextDirection( GetViewData()->GetTabNo() );
+ else if ( eCellDir == FRMDIR_HORI_RIGHT_TOP )
+ eBidiDir = EE_HTEXTDIR_R2L;
+ else
+ eBidiDir = EE_HTEXTDIR_L2R;
+ }
+
+ SvtLanguageOptions aLangOpt;
+ BOOL bDisableCTLFont = !aLangOpt.IsCTLFontEnabled();
+ BOOL bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
+
+ SfxWhichIter aIter( rSet );
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ switch( nWhich )
+ {
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ if ( bDisableVerticalText )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ if( bVertDontCare )
+ rSet.InvalidateItem( nWhich );
+ else if ( nWhich == SID_TEXTDIRECTION_LEFT_TO_RIGHT )
+ rSet.Put( SfxBoolItem( nWhich, bLeftRight ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, bTopBottom ) );
+ }
+ break;
+
+ case SID_ATTR_PARA_LEFT_TO_RIGHT:
+ case SID_ATTR_PARA_RIGHT_TO_LEFT:
+ if ( bDisableCTLFont )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ if ( bTopBottom )
+ rSet.DisableItem( nWhich );
+ else if ( bBidiDontCare )
+ rSet.InvalidateItem( nWhich );
+ else if ( nWhich == SID_ATTR_PARA_LEFT_TO_RIGHT )
+ rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_L2R ) );
+ else
+ rSet.Put( SfxBoolItem( nWhich, eBidiDir == EE_HTEXTDIR_R2L ) );
+ }
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScFormatShell::ExecFormatPaintbrush( SfxRequest& rReq )
+{
+ ScViewFunc* pView = pViewData->GetView();
+ if ( pView->HasPaintBrush() )
+ {
+ // cancel paintbrush mode
+ pView->ResetBrushDocument();
+ }
+ else
+ {
+ BOOL bLock = FALSE;
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 1 )
+ bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue();
+
+ // in case of multi selection, deselect all and use the cursor position
+ ScRange aDummy;
+ if ( pViewData->GetSimpleArea(aDummy) != SC_MARK_SIMPLE )
+ pView->Unmark();
+
+ ScDocument* pBrushDoc = new ScDocument( SCDOCMODE_CLIP );
+ pView->CopyToClip( pBrushDoc, FALSE, TRUE );
+ pView->SetBrushDocument( pBrushDoc, bLock );
+ }
+}
+
+void ScFormatShell::StateFormatPaintbrush( SfxItemSet& rSet )
+{
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
+ rSet.DisableItem( SID_FORMATPAINTBRUSH );
+ else
+ rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, pViewData->GetView()->HasPaintBrush() ) );
+}
+
+short ScFormatShell::GetCurrentNumberFormatType()
+{
+ short nType = NUMBERFORMAT_ALL;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData aMark(GetViewData()->GetMarkData());
+ const SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ if (!pFormatter)
+ return nType;
+
+ // TODO: Find out how to get a selected table range in case multiple tables
+ // are selected. Currently we only check for the current active table.
+
+ if ( aMark.IsMarked() || aMark.IsMultiMarked() )
+ {
+ aMark.MarkToMulti();
+ ScRange aRange;
+ aMark.GetMultiMarkArea(aRange);
+
+ const ScMarkArray* pArray = aMark.GetArray();
+ if (!pArray)
+ return nType;
+
+ short nComboType = NUMBERFORMAT_ALL;
+ bool bFirstItem = true;
+ for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
+ {
+ const ScMarkArray& rColArray = pArray[nCol];
+ if (!rColArray.HasMarks())
+ continue;
+
+ SCROW nRow1, nRow2;
+ ScMarkArrayIter aMarkIter(&rColArray);
+ while (aMarkIter.Next(nRow1, nRow2))
+ {
+ ScRange aColRange(nCol, nRow1, aRange.aStart.Tab());
+ aColRange.aEnd.SetRow(nRow2);
+ sal_uInt32 nNumFmt = pDoc->GetNumberFormat(aColRange);
+ const SvNumberformat* pEntry = pFormatter->GetEntry(nNumFmt);
+ if (!pEntry)
+ return 0;
+
+ short nThisType = pEntry->GetType();
+ if (bFirstItem)
+ {
+ bFirstItem = false;
+ nComboType = nThisType;
+ }
+ else if (nComboType != nThisType)
+ // mixed number format type.
+ return NUMBERFORMAT_ALL;
+ }
+ }
+ nType = nComboType;
+ }
+ else
+ {
+ sal_uInt32 nNumFmt;
+ pDoc->GetNumberFormat( pViewData->GetCurX(), pViewData->GetCurY(),
+ pViewData->GetTabNo(), nNumFmt );
+ const SvNumberformat* pEntry = pFormatter->GetEntry( nNumFmt );
+ nType = pEntry ? pEntry->GetType() : 0;
+ }
+ return nType;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/galwrap.cxx b/sc/source/ui/view/galwrap.cxx
new file mode 100644
index 000000000000..ea36d2430d43
--- /dev/null
+++ b/sc/source/ui/view/galwrap.cxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/graph.hxx>
+#include <svx/gallery.hxx>
+#include <sfx2/app.hxx>
+
+// -----------------------------------------------------------------------
+
+Graphic GalleryGetGraphic()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+ return pGal->GetGraphic();
+}
+
+USHORT GallerySGA_FORMAT_GRAPHIC()
+{
+ return SGA_FORMAT_GRAPHIC;
+}
+
+BOOL GalleryIsLinkage()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+ return pGal->IsLinkage();
+}
+
+String GalleryGetFullPath()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+// return pGal->GetPath().GetFull();
+ return pGal->GetURL().GetMainURL(INetURLObject::NO_DECODE);
+ // URL as stored in GraphicLink must be encoded
+}
+
+String GalleryGetFilterName()
+{
+ GalleryExplorer* pGal = SVX_GALLERY();
+ DBG_ASSERT( pGal, "Wo ist die Gallery?" );
+ return pGal->GetFilterName();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridmerg.cxx b/sc/source/ui/view/gridmerg.cxx
new file mode 100644
index 000000000000..2481d4fc18be
--- /dev/null
+++ b/sc/source/ui/view/gridmerg.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <vcl/outdev.hxx>
+
+#include "gridmerg.hxx"
+
+//------------------------------------------------------------------
+
+ScGridMerger::ScGridMerger( OutputDevice* pOutDev, long nOnePixelX, long nOnePixelY ) :
+ pDev( pOutDev ),
+ nOneX( nOnePixelX ),
+ nOneY( nOnePixelY ),
+ nCount( 0 ),
+ bVertical( FALSE )
+{
+ // optimize (DrawGrid) only for pixel MapMode,
+ // to avoid rounding errors
+
+ bOptimize = ( pDev->GetMapMode().GetMapUnit() == MAP_PIXEL );
+}
+
+ScGridMerger::~ScGridMerger()
+{
+ Flush();
+}
+
+void ScGridMerger::AddLine( long nStart, long nEnd, long nPos )
+{
+ if ( nCount )
+ {
+ // not first line - test fix position
+ // more than one previous line - test distance
+
+ if ( nStart != nFixStart || nEnd != nFixEnd )
+ {
+ if ( nCount == 1 && nPos == nVarStart &&
+ ( nStart == nFixEnd ||
+ nStart == nFixEnd + ( bVertical ? nOneY : nOneX ) ) )
+ {
+ // additional optimization: extend connected lines
+ // keep nCount at 1
+ nFixEnd = nEnd;
+ }
+ else
+ Flush();
+ }
+ else if ( nCount == 1 )
+ {
+ nVarDiff = nPos - nVarStart;
+ ++nCount;
+ }
+ else if ( nPos != nVarStart + nCount * nVarDiff ) //! keep VarEnd?
+ Flush();
+ else
+ ++nCount;
+ }
+
+ if ( !nCount )
+ {
+ // first line (or flushed above) - just store
+
+ nFixStart = nStart;
+ nFixEnd = nEnd;
+ nVarStart = nPos;
+ nVarDiff = 0;
+ nCount = 1;
+ }
+}
+
+void ScGridMerger::AddHorLine( long nX1, long nX2, long nY )
+{
+ if ( bOptimize )
+ {
+ if ( bVertical )
+ {
+ Flush();
+ bVertical = FALSE;
+ }
+ AddLine( nX1, nX2, nY );
+ }
+ else
+ pDev->DrawLine( Point( nX1, nY ), Point( nX2, nY ) );
+}
+
+void ScGridMerger::AddVerLine( long nX, long nY1, long nY2 )
+{
+ if ( bOptimize )
+ {
+ if ( !bVertical )
+ {
+ Flush();
+ bVertical = TRUE;
+ }
+ AddLine( nY1, nY2, nX );
+ }
+ else
+ pDev->DrawLine( Point( nX, nY1 ), Point( nX, nY2 ) );
+}
+
+void ScGridMerger::Flush()
+{
+ if (nCount)
+ {
+ if (bVertical)
+ {
+ if ( nCount == 1 )
+ pDev->DrawLine( Point( nVarStart, nFixStart ), Point( nVarStart, nFixEnd ) );
+ else
+ {
+ long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff;
+ if ( nVarDiff < 0 )
+ {
+ // nVarDiff is negative in RTL layout mode
+ // Change the positions so DrawGrid is called with a positive distance
+ // (nVarStart / nVarDiff can be modified, aren't used after Flush)
+
+ nVarDiff = -nVarDiff;
+ long nTemp = nVarStart;
+ nVarStart = nVarEnd;
+ nVarEnd = nTemp;
+ }
+ pDev->DrawGrid( Rectangle( nVarStart, nFixStart, nVarEnd, nFixEnd ),
+ Size( nVarDiff, nFixEnd - nFixStart ),
+ GRID_VERTLINES );
+ }
+ }
+ else
+ {
+ if ( nCount == 1 )
+ pDev->DrawLine( Point( nFixStart, nVarStart ), Point( nFixEnd, nVarStart ) );
+ else
+ {
+ long nVarEnd = nVarStart + ( nCount - 1 ) * nVarDiff;
+ pDev->DrawGrid( Rectangle( nFixStart, nVarStart, nFixEnd, nVarEnd ),
+ Size( nFixEnd - nFixStart, nVarDiff ),
+ GRID_HORZLINES );
+ }
+ }
+ nCount = 0;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
new file mode 100644
index 000000000000..e765ebf0997f
--- /dev/null
+++ b/sc/source/ui/view/gridwin.cxx
@@ -0,0 +1,5852 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+
+#include <memory> //auto_ptr
+#include <editeng/adjitem.hxx>
+#include <svx/algitem.hxx>
+#include <svx/dbexch.hrc>
+#include <editeng/editview.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/editobj.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/svlbox.hxx>
+#include <svtools/svtabbx.hxx>
+#include <svl/urlbmk.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/cursor.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/hatch.hxx>
+#include <sot/formats.hxx>
+#include <sot/clsids.hxx>
+
+#include <svx/svdview.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT)
+#include <editeng/outliner.hxx> // fuer Command-Handler (COMMAND_INSERTTEXT)
+#include <svx/svditer.hxx>
+#include <svx/svdocapt.hxx>
+#include <svx/svdpagv.hxx>
+
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include <com/sun/star/sheet/DataPilotTableHeaderData.hpp>
+#include <com/sun/star/sheet/DataPilotTableResultData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionData.hpp>
+#include <com/sun/star/sheet/DataPilotTablePositionType.hpp>
+#include <com/sun/star/sheet/MemberResultFlags.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/awt/MouseButton.hpp>
+#include <com/sun/star/script/vba/VBAEventId.hpp>
+#include <com/sun/star/script/vba/XVBAEventProcessor.hpp>
+
+#include "gridwin.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+#include "tabview.hxx"
+#include "select.hxx"
+#include "scmod.hxx"
+#include "document.hxx"
+#include "attrib.hxx"
+#include "dbcolect.hxx"
+#include "stlpool.hxx"
+#include "printfun.hxx"
+#include "cbutton.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "editutil.hxx"
+#include "scresid.hxx"
+#include "inputhdl.hxx"
+#include "uiitems.hxx" // Filter-Dialog - auslagern !!!
+#include "filtdlg.hxx"
+#include "impex.hxx" // Sylk-ID fuer CB
+#include "cell.hxx" // fuer Edit-Felder
+#include "patattr.hxx"
+#include "notemark.hxx"
+#include "rfindlst.hxx"
+#include "docpool.hxx"
+#include "output.hxx"
+#include "docfunc.hxx"
+#include "dbdocfun.hxx"
+#include "dpobject.hxx"
+#include "dpoutput.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "seltrans.hxx"
+#include "sizedev.hxx"
+#include "AccessibilityHints.hxx"
+#include "dpsave.hxx"
+#include "viewuno.hxx"
+#include "compiler.hxx"
+#include "editable.hxx"
+#include "fillinfo.hxx"
+#include "scitems.hxx"
+#include "userdat.hxx"
+#include "drwlayer.hxx"
+#include "attrib.hxx"
+#include "validat.hxx"
+#include "tabprotection.hxx"
+#include "postit.hxx"
+#include "dpcontrol.hxx"
+#include "clipparam.hxx"
+#include "cellsh.hxx"
+#include "overlayobject.hxx"
+#include "cellsuno.hxx"
+
+#include "drawview.hxx"
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/sdr/overlay/overlayselection.hxx>
+
+using namespace com::sun::star;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+
+const BYTE SC_NESTEDBUTTON_NONE = 0;
+const BYTE SC_NESTEDBUTTON_DOWN = 1;
+const BYTE SC_NESTEDBUTTON_UP = 2;
+
+#define SC_AUTOFILTER_ALL 0
+#define SC_AUTOFILTER_TOP10 1
+#define SC_AUTOFILTER_CUSTOM 2
+#define SC_AUTOFILTER_EMPTY 3
+#define SC_AUTOFILTER_NOTEMPTY 4
+
+// Modi fuer die FilterListBox
+enum ScFilterBoxMode
+{
+ SC_FILTERBOX_FILTER,
+ SC_FILTERBOX_DATASELECT,
+ SC_FILTERBOX_SCENARIO,
+ SC_FILTERBOX_PAGEFIELD
+};
+
+extern SfxViewShell* pScActiveViewShell; // global.cxx
+extern USHORT nScClickMouseModifier; // global.cxx
+extern USHORT nScFillModeMouseModifier; // global.cxx
+
+#define SC_FILTERLISTBOX_LINES 12
+
+// ============================================================================
+
+ScGridWindow::VisibleRange::VisibleRange() :
+ mnCol1(0), mnCol2(MAXCOL), mnRow1(0), mnRow2(MAXROW)
+{
+}
+
+bool ScGridWindow::VisibleRange::isInside(SCCOL nCol, SCROW nRow) const
+{
+ return mnCol1 <= nCol && nCol <= mnCol2 && mnRow1 <= nRow && nRow <= mnRow2;
+}
+
+// ============================================================================
+
+class ScFilterListBox : public ListBox
+{
+private:
+ ScGridWindow* pGridWin;
+ SCCOL nCol;
+ SCROW nRow;
+ BOOL bButtonDown;
+ BOOL bInit;
+ BOOL bCancelled;
+ BOOL bInSelect;
+ bool mbListHasDates;
+ ULONG nSel;
+ ScFilterBoxMode eMode;
+
+protected:
+ virtual void LoseFocus();
+ void SelectHdl();
+
+public:
+ ScFilterListBox( Window* pParent, ScGridWindow* pGrid,
+ SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode );
+ ~ScFilterListBox();
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Select();
+
+ SCCOL GetCol() const { return nCol; }
+ SCROW GetRow() const { return nRow; }
+ ScFilterBoxMode GetMode() const { return eMode; }
+ BOOL IsDataSelect() const { return (eMode == SC_FILTERBOX_DATASELECT); }
+ void EndInit();
+ BOOL IsInInit() const { return bInit; }
+ void SetCancelled() { bCancelled = TRUE; }
+ BOOL IsInSelect() const { return bInSelect; }
+ void SetListHasDates(bool b) { mbListHasDates = b; }
+ bool HasDates() const { return mbListHasDates; }
+};
+
+//-------------------------------------------------------------------
+
+// ListBox in einem FloatingWindow (pParent)
+ScFilterListBox::ScFilterListBox( Window* pParent, ScGridWindow* pGrid,
+ SCCOL nNewCol, SCROW nNewRow, ScFilterBoxMode eNewMode ) :
+ ListBox( pParent, WB_AUTOHSCROLL ),
+ pGridWin( pGrid ),
+ nCol( nNewCol ),
+ nRow( nNewRow ),
+ bButtonDown( FALSE ),
+ bInit( TRUE ),
+ bCancelled( FALSE ),
+ bInSelect( FALSE ),
+ mbListHasDates(false),
+ nSel( 0 ),
+ eMode( eNewMode )
+{
+}
+
+__EXPORT ScFilterListBox::~ScFilterListBox()
+{
+ if (IsMouseCaptured())
+ ReleaseMouse();
+}
+
+void ScFilterListBox::EndInit()
+{
+ USHORT nPos = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND == nPos )
+ nSel = 0;
+ else
+ nSel = nPos;
+
+ bInit = FALSE;
+}
+
+void __EXPORT ScFilterListBox::LoseFocus()
+{
+#ifndef UNX
+ Hide();
+#endif
+}
+
+// -----------------------------------------------------------------------
+
+long ScFilterListBox::PreNotify( NotifyEvent& rNEvt )
+{
+ long nDone = 0;
+ if ( rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
+ KeyCode aCode = aKeyEvt.GetKeyCode();
+ if ( !aCode.GetModifier() ) // ohne alle Modifiers
+ {
+ USHORT nKey = aCode.GetCode();
+ if ( nKey == KEY_RETURN )
+ {
+ SelectHdl(); // auswaehlen
+ nDone = 1;
+ }
+ else if ( nKey == KEY_ESCAPE )
+ {
+ pGridWin->ClickExtern(); // loescht die List-Box !!!
+ nDone = 1;
+ }
+ }
+ }
+
+ return nDone ? nDone : ListBox::PreNotify( rNEvt );
+}
+
+void __EXPORT ScFilterListBox::Select()
+{
+ ListBox::Select();
+ SelectHdl();
+}
+
+void __EXPORT ScFilterListBox::SelectHdl()
+{
+ if ( !IsTravelSelect() && !bInit && !bCancelled )
+ {
+ USHORT nPos = GetSelectEntryPos();
+ if ( LISTBOX_ENTRY_NOTFOUND != nPos )
+ {
+ nSel = nPos;
+ if (!bButtonDown)
+ {
+ // #i81298# set bInSelect flag, so the box isn't deleted from modifications within FilterSelect
+ bInSelect = TRUE;
+ pGridWin->FilterSelect( nSel );
+ bInSelect = FALSE;
+ }
+ }
+ }
+}
+
+// ============================================================================
+
+// use a System floating window for the above filter listbox
+class ScFilterFloatingWindow : public FloatingWindow
+{
+public:
+ ScFilterFloatingWindow( Window* pParent, WinBits nStyle = WB_STDFLOATWIN );
+ virtual ~ScFilterFloatingWindow();
+ // required for System FloatingWindows that will not process KeyInput by themselves
+ virtual Window* GetPreferredKeyInputWindow();
+};
+
+ScFilterFloatingWindow::ScFilterFloatingWindow( Window* pParent, WinBits nStyle ) :
+ FloatingWindow( pParent, nStyle|WB_SYSTEMWINDOW ) // make it a system floater
+ {}
+
+ScFilterFloatingWindow::~ScFilterFloatingWindow()
+{
+ EndPopupMode();
+}
+
+Window* ScFilterFloatingWindow::GetPreferredKeyInputWindow()
+{
+ // redirect keyinput in the child window
+ return GetWindow(WINDOW_FIRSTCHILD) ? GetWindow(WINDOW_FIRSTCHILD)->GetPreferredKeyInputWindow() : NULL; // will be the FilterBox
+}
+
+// ============================================================================
+
+BOOL lcl_IsEditableMatrix( ScDocument* pDoc, const ScRange& rRange )
+{
+ // wenn es ein editierbarer Bereich ist, und rechts unten eine Matrix-Zelle
+ // mit Origin links oben liegt, enthaelt der Bereich genau die Matrix.
+ //! Direkt die MatrixEdges Funktionen von der Column herausreichen ???
+
+ if ( !pDoc->IsBlockEditable( rRange.aStart.Tab(), rRange.aStart.Col(),rRange.aStart.Row(),
+ rRange.aEnd.Col(),rRange.aEnd.Row() ) )
+ return FALSE;
+
+ ScAddress aPos;
+ const ScBaseCell* pCell = pDoc->GetCell( rRange.aEnd );
+ return ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA &&
+ ((ScFormulaCell*)pCell)->GetMatrixOrigin(aPos) && aPos == rRange.aStart );
+
+}
+
+void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pDrDoc, const Point& rPos, ScViewData* pViewData )
+{
+ if (!pView && !pPV && !pDrDoc && !pViewData)
+ return;
+
+ ScDocument& rDoc = *pViewData->GetDocument();
+ ScAddress aCellPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
+ ScPostIt* pNote = rDoc.GetNote( aCellPos );
+ SdrObject* pObj = pNote ? pNote->GetCaption() : 0;
+ if( pObj && pObj->GetLogicRect().IsInside( rPos ) && ScDrawLayer::IsNoteCaption( pObj ) )
+ {
+ const ScProtectionAttr* pProtAttr = static_cast< const ScProtectionAttr* > (rDoc.GetAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(), ATTR_PROTECTION ) );
+ bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell() ;
+ bool bProtectDoc = rDoc.IsTabProtected( aCellPos.Tab() ) || pViewData->GetSfxDocShell()->IsReadOnly() ;
+ // unlock internal layer (if not protected), will be relocked in ScDrawView::MarkListHasChanged()
+ pView->LockInternalLayer( bProtectDoc && bProtectAttr );
+ }
+}
+
+sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell )
+{
+ BOOL bFound = FALSE;
+ do
+ {
+ pDoc->GetCell( rPosX, rPosY, nTab, rpCell );
+ if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE )
+ {
+ if ( rPosX <= 0 )
+ return FALSE; // alles leer bis links
+ else
+ --rPosX; // weitersuchen
+ }
+ else if ( rpCell->GetCellType() == CELLTYPE_EDIT)
+ bFound = TRUE;
+ else if (rpCell->GetCellType() == CELLTYPE_FORMULA &&
+ static_cast<ScFormulaCell*>(rpCell)->IsHyperLinkCell())
+ bFound = TRUE;
+ else
+ return FALSE; // andere Zelle
+ }
+ while ( !bFound );
+
+ return bFound;
+}
+
+// ---------------------------------------------------------------------------
+// WB_DIALOGCONTROL noetig fuer UNO-Controls
+ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos )
+: Window( pParent, WB_CLIPCHILDREN | WB_DIALOGCONTROL ),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+ mpOOCursors( NULL ),
+ mpOOSelection( NULL ),
+ mpOOSelectionBorder( NULL ),
+ mpOOAutoFill( NULL ),
+ mpOODragRect( NULL ),
+ mpOOHeader( NULL ),
+ mpOOShrink( NULL ),
+ mpAutoFillRect(static_cast<Rectangle*>(NULL)),
+ pViewData( pData ),
+ eWhich( eWhichPos ),
+ pNoteMarker( NULL ),
+ pFilterBox( NULL ),
+ pFilterFloat( NULL ),
+ mpDPFieldPopup(NULL),
+ mpFilterButton(NULL),
+ nCursorHideCount( 0 ),
+ bMarking( FALSE ),
+ nButtonDown( 0 ),
+ bEEMouse( FALSE ),
+ nMouseStatus( SC_GM_NONE ),
+ nNestedButtonState( SC_NESTEDBUTTON_NONE ),
+ bDPMouse( FALSE ),
+ bRFMouse( FALSE ),
+ nPagebreakMouse( SC_PD_NONE ),
+ bPagebreakDrawn( FALSE ),
+ nPageScript( 0 ),
+ bDragRect( FALSE ),
+ nDragStartX( -1 ),
+ nDragStartY( -1 ),
+ nDragEndX( -1 ),
+ nDragEndY( -1 ),
+ meDragInsertMode( INS_NONE ),
+ nCurrentPointer( 0 ),
+ bIsInScroll( FALSE ),
+ bIsInPaint( FALSE ),
+ aComboButton( this ),
+ aCurMousePos( 0,0 ),
+ nPaintCount( 0 ),
+ bNeedsRepaint( FALSE ),
+ bAutoMarkVisible( FALSE ),
+ bListValButton( FALSE )
+{
+ switch(eWhich)
+ {
+ case SC_SPLIT_TOPLEFT:
+ eHWhich = SC_SPLIT_LEFT;
+ eVWhich = SC_SPLIT_TOP;
+ break;
+ case SC_SPLIT_TOPRIGHT:
+ eHWhich = SC_SPLIT_RIGHT;
+ eVWhich = SC_SPLIT_TOP;
+ break;
+ case SC_SPLIT_BOTTOMLEFT:
+ eHWhich = SC_SPLIT_LEFT;
+ eVWhich = SC_SPLIT_BOTTOM;
+ break;
+ case SC_SPLIT_BOTTOMRIGHT:
+ eHWhich = SC_SPLIT_RIGHT;
+ eVWhich = SC_SPLIT_BOTTOM;
+ break;
+ default:
+ DBG_ERROR("GridWindow: falsche Position");
+ }
+
+ SetBackground();
+
+ SetMapMode(pViewData->GetLogicMode(eWhich));
+// EnableDrop();
+ EnableChildTransparentMode();
+ SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
+
+ SetHelpId( HID_SC_WIN_GRIDWIN );
+ SetUniqueId( HID_SC_WIN_GRIDWIN );
+
+ SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
+ EnableRTL( FALSE );
+}
+
+__EXPORT ScGridWindow::~ScGridWindow()
+{
+ // #114409#
+ ImpDestroyOverlayObjects();
+
+ delete pFilterBox;
+ delete pFilterFloat;
+ delete pNoteMarker;
+}
+
+void __EXPORT ScGridWindow::Resize( const Size& )
+{
+ // gar nix
+}
+
+void ScGridWindow::ClickExtern()
+{
+ do
+ {
+ // #i81298# don't delete the filter box when called from its select handler
+ // (possible through row header size update)
+ // #i84277# when initializing the filter box, a Basic error can deactivate the view
+ if ( pFilterBox && ( pFilterBox->IsInSelect() || pFilterBox->IsInInit() ) )
+ {
+ break;
+ }
+
+ DELETEZ(pFilterBox);
+ DELETEZ(pFilterFloat);
+ }
+ while (false);
+
+ if (mpDPFieldPopup.get())
+ {
+ mpDPFieldPopup->close(false);
+ mpDPFieldPopup.reset();
+ }
+}
+
+IMPL_LINK( ScGridWindow, PopupModeEndHdl, FloatingWindow*, EMPTYARG )
+{
+ if (pFilterBox)
+ pFilterBox->SetCancelled(); // nicht mehr auswaehlen
+ GrabFocus();
+ return 0;
+}
+
+IMPL_LINK( ScGridWindow, PopupSpellingHdl, SpellCallbackInfo*, pInfo )
+{
+ if( pInfo->nCommand == SPELLCMD_STARTSPELLDLG )
+ pViewData->GetDispatcher().Execute( SID_SPELL_DIALOG, SFX_CALLMODE_ASYNCHRON );
+ return 0;
+}
+
+void ScGridWindow::ExecPageFieldSelect( SCCOL nCol, SCROW nRow, BOOL bHasSelection, const String& rStr )
+{
+ //! gridwin2 ?
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
+ if ( pDPObj && nCol > 0 )
+ {
+ // look for the dimension header left of the drop-down arrow
+ USHORT nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+ long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient );
+ if ( nField >= 0 && nOrient == sheet::DataPilotFieldOrientation_PAGE )
+ {
+ ScDPSaveData aSaveData( *pDPObj->GetSaveData() );
+
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nField, bIsDataLayout );
+ if ( !bIsDataLayout )
+ {
+ ScDPSaveDimension* pDim = aSaveData.GetDimensionByName(aDimName);
+
+ if ( bHasSelection )
+ pDim->SetCurrentPage( &rStr );
+ else
+ pDim->SetCurrentPage( NULL );
+
+ ScDPObject aNewObj( *pDPObj );
+ aNewObj.SetSaveData( aSaveData );
+ ScDBDocFunc aFunc( *pViewData->GetDocShell() );
+ aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE );
+ pViewData->GetView()->CursorPosChanged(); // shells may be switched
+ }
+ }
+ }
+}
+
+void ScGridWindow::LaunchPageFieldMenu( SCCOL nCol, SCROW nRow )
+{
+ //! merge position/size handling with DoAutoFilterMenue
+
+ delete pFilterBox;
+ delete pFilterFloat;
+
+ USHORT i;
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ long nSizeX = 0;
+ long nSizeY = 0;
+ long nHeight = 0;
+ pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+ Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+ if ( bLayoutRTL )
+ aPos.X() -= nSizeX;
+
+ Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
+
+ aPos.X() -= 1;
+ aPos.Y() += nSizeY - 1;
+
+ pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // not resizable etc.
+ pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) );
+ pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_PAGEFIELD );
+ if ( bLayoutRTL )
+ pFilterBox->EnableMirroring();
+
+ nSizeX += 1;
+
+ {
+ Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() );
+ MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL );
+
+ nHeight = GetTextHeight();
+ nHeight *= SC_FILTERLISTBOX_LINES;
+
+ SetMapMode( aOldMode );
+ SetFont( aOldFont );
+ }
+
+ // SetSize comes later
+
+ TypedScStrCollection aStrings( 128, 128 );
+
+ // get list box entries and selection
+ BOOL bHasCurrentPage = FALSE;
+ String aCurrentPage;
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
+ if ( pDPObj && nCol > 0 )
+ {
+ // look for the dimension header left of the drop-down arrow
+ USHORT nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+ long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient );
+ if ( nField >= 0 && nOrient == sheet::DataPilotFieldOrientation_PAGE )
+ {
+ pDPObj->FillPageList( aStrings, nField );
+
+ // get current page from SaveData
+
+ ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( nField, bIsDataLayout );
+ if ( pSaveData && !bIsDataLayout )
+ {
+ ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(aDimName);
+ if ( pDim && pDim->HasCurrentPage() )
+ {
+ aCurrentPage = pDim->GetCurrentPage();
+ bHasCurrentPage = TRUE;
+ }
+ }
+ }
+ }
+
+ // include all entry widths for the size of the drop-down
+ long nMaxText = 0;
+ USHORT nCount = aStrings.GetCount();
+ for (i=0; i<nCount; i++)
+ {
+ TypedStrData* pData = aStrings[i];
+ long nTextWidth = pFilterBox->GetTextWidth( pData->GetString() );
+ if ( nTextWidth > nMaxText )
+ nMaxText = nTextWidth;
+ }
+
+ // add scrollbar width if needed (string entries are counted here)
+ // (scrollbar is shown if the box is exactly full?)
+ if ( nCount >= SC_FILTERLISTBOX_LINES )
+ nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize();
+
+ nMaxText += 4; // for borders
+
+ if ( nMaxText > nSizeX )
+ nSizeX = nMaxText; // just modify width - starting position is unchanged
+
+ // adjust position and size to window
+
+ Size aParentSize = GetParent()->GetOutputSizePixel();
+ Size aSize( nSizeX, nHeight );
+
+ if ( aSize.Height() > aParentSize.Height() )
+ aSize.Height() = aParentSize.Height();
+ if ( aPos.Y() + aSize.Height() > aParentSize.Height() )
+ aPos.Y() = aParentSize.Height() - aSize.Height();
+
+ pFilterBox->SetSizePixel( aSize );
+ pFilterBox->Show(); // Show must be called before SetUpdateMode
+ pFilterBox->SetUpdateMode(FALSE);
+
+ pFilterFloat->SetOutputSizePixel( aSize );
+ pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS);
+
+ // fill the list box
+ BOOL bWait = ( nCount > 100 );
+
+ if (bWait)
+ EnterWait();
+
+ for (i=0; i<nCount; i++)
+ pFilterBox->InsertEntry( aStrings[i]->GetString() );
+
+ pFilterBox->SetSeparatorPos( 0 );
+
+ if (bWait)
+ LeaveWait();
+
+ pFilterBox->SetUpdateMode(TRUE);
+
+ USHORT nSelPos = LISTBOX_ENTRY_NOTFOUND;
+ if (bHasCurrentPage)
+ nSelPos = pFilterBox->GetEntryPos( aCurrentPage );
+
+ if ( nSelPos == LISTBOX_ENTRY_NOTFOUND )
+ nSelPos = 0; // first entry
+
+ pFilterBox->GrabFocus();
+
+ // call Select after GrabFocus, so the focus rectangle ends up in the right position
+ if ( nSelPos != LISTBOX_ENTRY_NOTFOUND )
+ pFilterBox->SelectEntryPos( nSelPos );
+
+ pFilterBox->EndInit();
+
+ nMouseStatus = SC_GM_FILTER;
+ CaptureMouse();
+}
+
+void ScGridWindow::LaunchDPFieldMenu( SCCOL nCol, SCROW nRow )
+{
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDPObject* pDPObj = pViewData->GetDocument()->GetDPAtCursor(nCol, nRow, nTab);
+ if (!pDPObj)
+ return;
+
+ // Get the geometry of the cell.
+ Point aScrPos = pViewData->GetScrPos(nCol, nRow, eWhich);
+ long nSizeX, nSizeY;
+ pViewData->GetMergeSizePixel(nCol, nRow, nSizeX, nSizeY);
+ Size aScrSize(nSizeX-1, nSizeY-1);
+
+ DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, ScAddress(nCol, nRow, nTab), pDPObj);
+}
+
+void ScGridWindow::DoScenarioMenue( const ScRange& rScenRange )
+{
+ delete pFilterBox;
+ delete pFilterFloat;
+
+ SCCOL nCol = rScenRange.aEnd.Col(); // Zelle unterhalb des Buttons
+ SCROW nRow = rScenRange.aStart.Row();
+ if (nRow == 0)
+ {
+ nRow = rScenRange.aEnd.Row() + 1; // Bereich ganz oben -> Button unterhalb
+ if (nRow>MAXROW) nRow = MAXROW;
+ //! Texthoehe addieren (wenn sie an der View gespeichert ist...)
+ }
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ long nSizeX = 0;
+ long nSizeY = 0;
+ long nHeight = 0;
+ pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+ Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+ if ( bLayoutRTL )
+ aPos.X() -= nSizeX;
+ Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
+ aCellRect.Top() -= nSizeY;
+ aCellRect.Bottom() -= nSizeY - 1;
+ // Die ListBox direkt unter der schwarzen Linie auf dem Zellgitter
+ // (wenn die Linie verdeckt wird, sieht es komisch aus...)
+
+ pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc.
+ pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) );
+ pFilterBox = new ScFilterListBox( pFilterFloat, this, nCol, nRow, SC_FILTERBOX_SCENARIO );
+ if ( bLayoutRTL )
+ pFilterBox->EnableMirroring();
+
+ nSizeX += 1;
+
+ {
+ Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() );
+ MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL );
+
+ nHeight = GetTextHeight();
+ nHeight *= SC_FILTERLISTBOX_LINES;
+
+ SetMapMode( aOldMode );
+ SetFont( aOldFont );
+ }
+
+ // SetSize spaeter
+/*
+ pFilterBox->SetSelectionMode( SINGLE_SELECTION );
+ pFilterBox->SetTabs( nFilterBoxTabs, MapUnit( MAP_APPFONT ));
+ pFilterBox->SetTabJustify( 1, bLayoutRTL ? AdjustRight : AdjustLeft );
+*/
+
+ // ParentSize Abfrage fehlt
+ Size aSize( nSizeX, nHeight );
+ pFilterBox->SetSizePixel( aSize );
+ pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!!
+ pFilterBox->SetUpdateMode(FALSE);
+
+ // SetOutputSizePixel/StartPopupMode erst unten, wenn die Groesse feststeht
+
+ // Listbox fuellen
+
+ long nMaxText = 0;
+ String aCurrent;
+ String aTabName;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nEntryCount = 0;
+ for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
+ {
+ if (pDoc->HasScenarioRange( i, rScenRange ))
+ if (pDoc->GetName( i, aTabName ))
+ {
+ pFilterBox->InsertEntry( aTabName );
+ if (pDoc->IsActiveScenario(i))
+ aCurrent = aTabName;
+ long nTextWidth = pFilterBox->GetTextWidth( aTabName );
+ if ( nTextWidth > nMaxText )
+ nMaxText = nTextWidth;
+ ++nEntryCount;
+ }
+ }
+ if (nEntryCount > SC_FILTERLISTBOX_LINES)
+ nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize();
+ nMaxText += 4; // fuer Rand
+ if ( nMaxText > 300 )
+ nMaxText = 300; // auch nicht uebertreiben (Pixel)
+
+ if (nMaxText > nSizeX) // Groesse auf benoetigte Groesse anpassen
+ {
+ long nDiff = nMaxText - nSizeX;
+ aSize = Size( nMaxText, nHeight );
+ pFilterBox->SetSizePixel( aSize );
+ pFilterFloat->SetOutputSizePixel( aSize );
+
+ if ( !bLayoutRTL )
+ {
+ // also move popup position
+ long nNewX = aCellRect.Left() - nDiff;
+ if ( nNewX < 0 )
+ nNewX = 0;
+ aCellRect.Left() = nNewX;
+ }
+ }
+
+ pFilterFloat->SetOutputSizePixel( aSize );
+ pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS );
+
+ pFilterBox->SetUpdateMode(TRUE);
+ pFilterBox->GrabFocus();
+
+ // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet
+//! SvLBoxEntry* pSelect = NULL;
+ USHORT nPos = LISTBOX_ENTRY_NOTFOUND;
+ if (aCurrent.Len())
+ {
+ nPos = pFilterBox->GetEntryPos( aCurrent );
+//! pSelect = pFilterBox->GetEntry( nPos );
+ }
+ if (/*!pSelect*/ LISTBOX_ENTRY_NOTFOUND == nPos && pFilterBox->GetEntryCount() > 0 )
+ nPos = 0;
+//! pSelect = pFilterBox->GetEntry(0); // einer sollte immer selektiert sein
+ if (/*pSelect*/ LISTBOX_ENTRY_NOTFOUND != nPos )
+ pFilterBox->SelectEntryPos(nPos);
+
+ pFilterBox->EndInit();
+
+ // Szenario-Auswahl kommt aus MouseButtonDown:
+ // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown
+
+ nMouseStatus = SC_GM_FILTER;
+ CaptureMouse();
+}
+
+void ScGridWindow::DoAutoFilterMenue( SCCOL nCol, SCROW nRow, BOOL bDataSelect )
+{
+ delete pFilterBox;
+ delete pFilterFloat;
+
+ USHORT i;
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ long nSizeX = 0;
+ long nSizeY = 0;
+ long nHeight = 0;
+ pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+ Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+ if ( bLayoutRTL )
+ aPos.X() -= nSizeX;
+
+ Rectangle aCellRect( OutputToScreenPixel(aPos), Size(nSizeX,nSizeY) );
+
+ aPos.X() -= 1;
+ aPos.Y() += nSizeY - 1;
+
+ pFilterFloat = new ScFilterFloatingWindow( this, WinBits(WB_BORDER) ); // nicht resizable etc.
+ pFilterFloat->SetPopupModeEndHdl( LINK( this, ScGridWindow, PopupModeEndHdl ) );
+ pFilterBox = new ScFilterListBox(
+ pFilterFloat, this, nCol, nRow, bDataSelect ? SC_FILTERBOX_DATASELECT : SC_FILTERBOX_FILTER );
+ if ( bLayoutRTL )
+ pFilterBox->EnableMirroring();
+
+ nSizeX += 1;
+
+ {
+ Font aOldFont = GetFont(); SetFont( pFilterBox->GetFont() );
+ MapMode aOldMode = GetMapMode(); SetMapMode( MAP_PIXEL );
+
+ nHeight = GetTextHeight();
+ nHeight *= SC_FILTERLISTBOX_LINES;
+
+ SetMapMode( aOldMode );
+ SetFont( aOldFont );
+ }
+
+ // SetSize spaeter
+/*
+ pFilterBox->SetSelectionMode( SINGLE_SELECTION );
+ pFilterBox->SetTabs( nFilterBoxTabs, MapUnit( MAP_APPFONT ));
+ pFilterBox->SetTabJustify( 1, bLayoutRTL ? AdjustRight : AdjustLeft );
+*/
+
+ BOOL bEmpty = FALSE;
+ TypedScStrCollection aStrings( 128, 128 );
+ if ( bDataSelect ) // Auswahl-Liste
+ {
+ // Liste fuellen
+ aStrings.SetCaseSensitive( TRUE );
+ pDoc->GetDataEntries( nCol, nRow, nTab, aStrings );
+ if ( aStrings.GetCount() == 0 )
+ bEmpty = TRUE;
+ }
+ else // AutoFilter
+ {
+ //! wird der Titel ueberhaupt ausgewertet ???
+ String aString;
+ pDoc->GetString( nCol, nRow, nTab, aString );
+ pFilterBox->SetText( aString );
+
+ long nMaxText = 0;
+
+ // default entries
+ static const USHORT nDefIDs[] = { SCSTR_ALLFILTER, SCSTR_TOP10FILTER, SCSTR_STDFILTER, SCSTR_EMPTY, SCSTR_NOTEMPTY };
+ const USHORT nDefCount = sizeof(nDefIDs) / sizeof(USHORT);
+ for (i=0; i<nDefCount; i++)
+ {
+ String aEntry( (ScResId) nDefIDs[i] );
+ pFilterBox->InsertEntry( aEntry );
+ long nTextWidth = pFilterBox->GetTextWidth( aEntry );
+ if ( nTextWidth > nMaxText )
+ nMaxText = nTextWidth;
+ }
+ pFilterBox->SetSeparatorPos( nDefCount - 1 );
+
+ // get list entries
+ bool bHasDates = false;
+ pDoc->GetFilterEntries( nCol, nRow, nTab, true, aStrings, bHasDates);
+ pFilterBox->SetListHasDates(bHasDates);
+
+ // check widths of numerical entries (string entries are not included)
+ // so all numbers are completely visible
+ USHORT nCount = aStrings.GetCount();
+ for (i=0; i<nCount; i++)
+ {
+ TypedStrData* pData = aStrings[i];
+ if ( !pData->IsStrData() ) // only numerical entries
+ {
+ long nTextWidth = pFilterBox->GetTextWidth( pData->GetString() );
+ if ( nTextWidth > nMaxText )
+ nMaxText = nTextWidth;
+ }
+ }
+
+ // add scrollbar width if needed (string entries are counted here)
+ // (scrollbar is shown if the box is exactly full?)
+ if ( nCount + nDefCount >= SC_FILTERLISTBOX_LINES )
+ nMaxText += GetSettings().GetStyleSettings().GetScrollBarSize();
+
+ nMaxText += 4; // for borders
+
+ if ( nMaxText > nSizeX )
+ nSizeX = nMaxText; // just modify width - starting position is unchanged
+ }
+
+ if (!bEmpty)
+ {
+ // Position und Groesse an Fenster anpassen
+ //! vorher Abfrage, ob die Eintraege hineinpassen (Breite)
+
+ Size aParentSize = GetParent()->GetOutputSizePixel();
+ Size aSize( nSizeX, nHeight );
+
+ if ( aSize.Height() > aParentSize.Height() )
+ aSize.Height() = aParentSize.Height();
+ if ( aPos.Y() + aSize.Height() > aParentSize.Height() )
+ aPos.Y() = aParentSize.Height() - aSize.Height();
+
+ pFilterBox->SetSizePixel( aSize );
+ pFilterBox->Show(); // Show muss vor SetUpdateMode kommen !!!
+ pFilterBox->SetUpdateMode(FALSE);
+
+ pFilterFloat->SetOutputSizePixel( aSize );
+ pFilterFloat->StartPopupMode( aCellRect, FLOATWIN_POPUPMODE_DOWN|FLOATWIN_POPUPMODE_GRABFOCUS);
+
+ // Listbox fuellen
+ USHORT nCount = aStrings.GetCount();
+ BOOL bWait = ( nCount > 100 );
+
+ if (bWait)
+ EnterWait();
+
+ for (i=0; i<nCount; i++)
+ pFilterBox->InsertEntry( aStrings[i]->GetString() );
+
+ if (bWait)
+ LeaveWait();
+
+ pFilterBox->SetUpdateMode(TRUE);
+ }
+
+//! SvLBoxEntry* pSelect = NULL;
+ USHORT nSelPos = LISTBOX_ENTRY_NOTFOUND;
+
+ if (!bDataSelect) // AutoFilter: aktiven Eintrag selektieren
+ {
+ ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
+ if (pDBData)
+ {
+ ScQueryParam aParam;
+ pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben
+
+ BOOL bValid = TRUE;
+ for (SCSIZE j=0; j<MAXQUERY && bValid; j++) // bisherige Filter-Einstellungen
+ if (aParam.GetEntry(j).bDoQuery)
+ {
+ //! Abfrage mit DrawButtons zusammenfassen!
+
+ ScQueryEntry& rEntry = aParam.GetEntry(j);
+ if (j>0)
+ if (rEntry.eConnect != SC_AND)
+ bValid = FALSE;
+ if (rEntry.nField == nCol)
+ {
+ if (rEntry.eOp == SC_EQUAL)
+ {
+ String* pStr = rEntry.pStr;
+ if (pStr)
+ {
+ nSelPos = pFilterBox->GetEntryPos( *pStr );
+//! pSelect = pFilterBox->GetEntry( nPos );
+ }
+ }
+ else if (rEntry.eOp == SC_TOPVAL && rEntry.pStr &&
+ rEntry.pStr->EqualsAscii("10"))
+ nSelPos = SC_AUTOFILTER_TOP10;
+ else
+ nSelPos = SC_AUTOFILTER_CUSTOM;
+ }
+ }
+
+ if (!bValid)
+ nSelPos = SC_AUTOFILTER_CUSTOM;
+ }
+ }
+ else
+ {
+
+ ULONG nIndex = ((SfxUInt32Item*)pDoc->GetAttr(
+ nCol, nRow, nTab, ATTR_VALIDDATA ))->GetValue();
+ if ( nIndex )
+ {
+ const ScValidationData* pData = pDoc->GetValidationEntry( nIndex );
+ if (pData)
+ {
+ TypedStrData* pNew = NULL;
+ String aDocStr;
+ pDoc->GetString( nCol, nRow, nTab, aDocStr );
+ if ( pDoc->HasValueData( nCol, nRow, nTab ) )
+ {
+ double fVal = pDoc->GetValue(ScAddress(nCol, nRow, nTab));
+ pNew = new TypedStrData( aDocStr, fVal, SC_STRTYPE_VALUE );
+ }
+ else
+ pNew = new TypedStrData( aDocStr, 0.0, SC_STRTYPE_STANDARD );
+
+ bool bSortList = ( pData->GetListType() == ValidListType::SORTEDASCENDING);
+ if ( bSortList )
+ {
+ USHORT nStrIndex;
+ if (aStrings.Search(pNew,nStrIndex))
+ nSelPos = nStrIndex;
+ }
+ else
+ {
+ USHORT nCount = aStrings.GetCount();
+ for (i = 0; ((i < nCount) && ( LISTBOX_ENTRY_NOTFOUND == nSelPos)); i++)
+ {
+ if ( aStrings.Compare(aStrings[i], pNew)==0 )
+ nSelPos = i;
+ }
+ }
+ delete pNew;
+ }
+ }
+ }
+
+ // neu (309): irgendwas muss immer selektiert sein:
+ if ( LISTBOX_ENTRY_NOTFOUND == nSelPos && pFilterBox->GetEntryCount() > 0 && !bDataSelect)
+ nSelPos = 0;
+
+ // keine leere Auswahl-Liste anzeigen:
+
+ if ( bEmpty )
+ {
+ DELETEZ(pFilterBox); // war nix
+ DELETEZ(pFilterFloat);
+ Sound::Beep(); // bemerkbar machen
+ }
+ else
+ {
+// pFilterBox->Show(); // schon vorne
+ pFilterBox->GrabFocus();
+
+ // Select erst nach GrabFocus, damit das Focus-Rechteck richtig landet
+ if ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ pFilterBox->SelectEntryPos( nSelPos );
+ else
+ {
+ if (bDataSelect)
+ pFilterBox->SetNoSelection();
+ }
+
+ pFilterBox->EndInit();
+
+ if (!bDataSelect)
+ {
+ // AutoFilter (aus MouseButtonDown):
+ // der naechste MouseMove auf die Filterbox ist wie ein ButtonDown
+
+ nMouseStatus = SC_GM_FILTER;
+ CaptureMouse();
+ }
+ }
+}
+
+void ScGridWindow::FilterSelect( ULONG nSel )
+{
+ String aString;
+/*
+ SvLBoxEntry* pEntry = pFilterBox->GetEntry( nSel );
+ if (pEntry)
+ {
+ SvLBoxString* pStringEntry = (SvLBoxString*) pEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING );
+ if ( pStringEntry )
+ aString = pStringEntry->GetText();
+ }
+*/
+ aString = pFilterBox->GetEntry( static_cast< USHORT >( nSel ) );
+
+ SCCOL nCol = pFilterBox->GetCol();
+ SCROW nRow = pFilterBox->GetRow();
+ switch ( pFilterBox->GetMode() )
+ {
+ case SC_FILTERBOX_DATASELECT:
+ ExecDataSelect( nCol, nRow, aString );
+ break;
+ case SC_FILTERBOX_FILTER:
+ ExecFilter( nSel, nCol, nRow, aString, pFilterBox->HasDates() );
+ break;
+ case SC_FILTERBOX_SCENARIO:
+ pViewData->GetView()->UseScenario( aString );
+ break;
+ case SC_FILTERBOX_PAGEFIELD:
+ // first entry is "all"
+ ExecPageFieldSelect( nCol, nRow, (nSel != 0), aString );
+ break;
+ }
+
+ if (pFilterFloat)
+ pFilterFloat->EndPopupMode();
+
+ GrabFocus(); // unter OS/2 stimmt der Focus sonst nicht
+}
+
+void ScGridWindow::ExecDataSelect( SCCOL nCol, SCROW nRow, const String& rStr )
+{
+ if ( rStr.Len() )
+ {
+ SCTAB nTab = pViewData->GetTabNo();
+ ScViewFunc* pView = pViewData->GetView();
+ pView->EnterData( nCol, nRow, nTab, rStr );
+
+ // #i52307# CellContentChanged is not in EnterData so it isn't called twice
+ // if the cursor is moved afterwards.
+ pView->CellContentChanged();
+ }
+}
+
+void ScGridWindow::ExecFilter( ULONG nSel,
+ SCCOL nCol, SCROW nRow,
+ const String& aValue, bool bCheckForDates )
+{
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
+ if (pDBData)
+ {
+ ScQueryParam aParam;
+ pDBData->GetQueryParam( aParam ); // kann nur MAXQUERY Eintraege ergeben
+
+ if (SC_AUTOFILTER_CUSTOM == nSel)
+ {
+ SCTAB nAreaTab;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pDBData->GetArea( nAreaTab, nStartCol,nStartRow,nEndCol,nEndRow );
+ pViewData->GetView()->MarkRange( ScRange( nStartCol,nStartRow,nAreaTab,nEndCol,nEndRow,nAreaTab));
+ pViewData->GetView()->SetCursor(nCol,nRow); //! auch ueber Slot ??
+ pViewData->GetDispatcher().Execute( SID_FILTER, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ }
+ else
+ {
+ BOOL bDeleteOld = FALSE;
+ SCSIZE nQueryPos = 0;
+ BOOL bFound = FALSE;
+ if (!aParam.bInplace)
+ bDeleteOld = TRUE;
+ if (aParam.bRegExp)
+ bDeleteOld = TRUE;
+ for (SCSIZE i=0; i<MAXQUERY && !bDeleteOld; i++) // bisherige Filter-Einstellungen
+ if (aParam.GetEntry(i).bDoQuery)
+ {
+ //! Abfrage mit DrawButtons zusammenfassen!
+
+ ScQueryEntry& rEntry = aParam.GetEntry(i);
+ if (i>0)
+ if (rEntry.eConnect != SC_AND)
+ bDeleteOld = TRUE;
+
+ if (rEntry.nField == nCol)
+ {
+ if (bFound) // diese Spalte zweimal?
+ bDeleteOld = TRUE;
+ nQueryPos = i;
+ bFound = TRUE;
+ }
+ if (!bFound)
+ nQueryPos = i + 1;
+ }
+
+ if (bDeleteOld)
+ {
+ SCSIZE nEC = aParam.GetEntryCount();
+ for (SCSIZE i=0; i<nEC; i++)
+ aParam.GetEntry(i).Clear();
+ nQueryPos = 0;
+ aParam.bInplace = TRUE;
+ aParam.bRegExp = FALSE;
+ }
+
+ if ( nQueryPos < MAXQUERY || SC_AUTOFILTER_ALL == nSel ) // loeschen geht immer
+ {
+ if (nSel)
+ {
+ ScQueryEntry& rNewEntry = aParam.GetEntry(nQueryPos);
+
+ rNewEntry.bDoQuery = TRUE;
+ rNewEntry.bQueryByString = TRUE;
+ rNewEntry.nField = nCol;
+ rNewEntry.bQueryByDate = bCheckForDates;
+ if ( nSel == SC_AUTOFILTER_TOP10 )
+ {
+ rNewEntry.eOp = SC_TOPVAL;
+ *rNewEntry.pStr = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("10"));
+ }
+ else if (nSel == SC_AUTOFILTER_EMPTY)
+ {
+ rNewEntry.pStr->Erase();
+ rNewEntry.bQueryByString = FALSE;
+ rNewEntry.eOp = SC_EQUAL;
+ rNewEntry.nVal = SC_EMPTYFIELDS;
+
+ }
+ else if (nSel == SC_AUTOFILTER_NOTEMPTY)
+ {
+ rNewEntry.pStr->Erase();
+ rNewEntry.bQueryByString = FALSE;
+ rNewEntry.eOp = SC_EQUAL;
+ rNewEntry.nVal = SC_NONEMPTYFIELDS;
+ }
+ else
+ {
+ rNewEntry.eOp = SC_EQUAL;
+ *rNewEntry.pStr = aValue;
+ }
+ if (nQueryPos > 0)
+ rNewEntry.eConnect = SC_AND;
+ }
+ else
+ {
+ if (bFound)
+ aParam.DeleteQuery(nQueryPos);
+ }
+
+ // #100597# end edit mode - like in ScCellShell::ExecuteDB
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
+ {
+ SC_MOD()->InputEnterHandler();
+ pViewData->GetViewShell()->UpdateInputHandler();
+ }
+
+ aParam.bUseDynamicRange = true;
+ pViewData->GetView()->Query( aParam, NULL, TRUE );
+ pDBData->SetQueryParam( aParam ); // speichern
+ }
+ else // "Zuviele Bedingungen"
+ pViewData->GetView()->ErrorMessage( STR_FILTER_TOOMANY );
+ }
+ }
+ else
+ {
+ DBG_ERROR("Wo ist der Datenbankbereich?");
+ }
+}
+
+void ScGridWindow::SetPointer( const Pointer& rPointer )
+{
+ nCurrentPointer = 0;
+ Window::SetPointer( rPointer );
+}
+
+void ScGridWindow::MoveMouseStatus( ScGridWindow& rDestWin )
+{
+ if (nButtonDown)
+ {
+ rDestWin.nButtonDown = nButtonDown;
+ rDestWin.nMouseStatus = nMouseStatus;
+ }
+
+ if (bRFMouse)
+ {
+ rDestWin.bRFMouse = bRFMouse;
+ rDestWin.bRFSize = bRFSize;
+ rDestWin.nRFIndex = nRFIndex;
+ rDestWin.nRFAddX = nRFAddX;
+ rDestWin.nRFAddY = nRFAddY;
+ bRFMouse = FALSE;
+ }
+
+ if (nPagebreakMouse)
+ {
+ rDestWin.nPagebreakMouse = nPagebreakMouse;
+ rDestWin.nPagebreakBreak = nPagebreakBreak;
+ rDestWin.nPagebreakPrev = nPagebreakPrev;
+ rDestWin.aPagebreakSource = aPagebreakSource;
+ rDestWin.aPagebreakDrag = aPagebreakDrag;
+ nPagebreakMouse = SC_PD_NONE;
+ }
+}
+
+BOOL ScGridWindow::TestMouse( const MouseEvent& rMEvt, BOOL bAction )
+{
+ // MouseEvent buttons must only be checked if bAction==TRUE
+ // to allow changing the mouse pointer in MouseMove,
+ // but not start AutoFill with right button (#74229#).
+ // with bAction==TRUE, SetFillMode / SetDragMode is called
+
+ if ( bAction && !rMEvt.IsLeft() )
+ return FALSE;
+
+ BOOL bNewPointer = FALSE;
+
+ SfxInPlaceClient* pClient = pViewData->GetViewShell()->GetIPClient();
+ BOOL bOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
+
+ if ( pViewData->IsActive() && !bOleActive )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ // Auto-Fill
+
+ ScRange aMarkRange;
+ if (pViewData->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE)
+ {
+ if (aMarkRange.aStart.Tab() == pViewData->GetTabNo() && mpAutoFillRect)
+ {
+ Point aMousePos = rMEvt.GetPosPixel();
+ if (mpAutoFillRect->IsInside(aMousePos))
+ {
+ SetPointer( Pointer( POINTER_CROSS ) ); //! dickeres Kreuz ?
+ if (bAction)
+ {
+ SCCOL nX = aMarkRange.aEnd.Col();
+ SCROW nY = aMarkRange.aEnd.Row();
+
+ if ( lcl_IsEditableMatrix( pViewData->GetDocument(), aMarkRange ) )
+ pViewData->SetDragMode(
+ aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY, SC_FILL_MATRIX );
+ else
+ pViewData->SetFillMode(
+ aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nX, nY );
+
+ // #108266# The simple selection must also be recognized when dragging,
+ // where the Marking flag is set and MarkToSimple won't work anymore.
+ pViewData->GetMarkData().MarkToSimple();
+ }
+ bNewPointer = TRUE;
+ }
+ }
+ }
+
+ // Embedded-Rechteck
+
+ if (pDoc->IsEmbedded())
+ {
+ ScRange aRange;
+ pDoc->GetEmbedded( aRange );
+ if ( pViewData->GetTabNo() == aRange.aStart.Tab() )
+ {
+ Point aStartPos = pViewData->GetScrPos( aRange.aStart.Col(), aRange.aStart.Row(), eWhich );
+ Point aEndPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich );
+ Point aMousePos = rMEvt.GetPosPixel();
+ if ( bLayoutRTL )
+ {
+ aStartPos.X() += 2;
+ aEndPos.X() += 2;
+ }
+ BOOL bTop = ( aMousePos.X() >= aStartPos.X()-3 && aMousePos.X() <= aStartPos.X()+1 &&
+ aMousePos.Y() >= aStartPos.Y()-3 && aMousePos.Y() <= aStartPos.Y()+1 );
+ BOOL bBottom = ( aMousePos.X() >= aEndPos.X()-3 && aMousePos.X() <= aEndPos.X()+1 &&
+ aMousePos.Y() >= aEndPos.Y()-3 && aMousePos.Y() <= aEndPos.Y()+1 );
+ if ( bTop || bBottom )
+ {
+ SetPointer( Pointer( POINTER_CROSS ) );
+ if (bAction)
+ {
+ BYTE nMode = bTop ? SC_FILL_EMBED_LT : SC_FILL_EMBED_RB;
+ pViewData->SetDragMode(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), nMode );
+ }
+ bNewPointer = TRUE;
+ }
+ }
+ }
+ }
+
+ if (!bNewPointer && bAction)
+ {
+// SetPointer( POINTER_ARROW ); // in Fu...
+ pViewData->ResetFillMode();
+ }
+
+ return bNewPointer;
+}
+
+void __EXPORT ScGridWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ nNestedButtonState = SC_NESTEDBUTTON_DOWN;
+
+ HandleMouseButtonDown( rMEvt );
+
+ if ( nNestedButtonState == SC_NESTEDBUTTON_UP )
+ {
+ // #i41690# If an object is deactivated from MouseButtonDown, it might reschedule,
+ // so MouseButtonUp comes before the MouseButtonDown call is finished. In this case,
+ // simulate another MouseButtonUp call, so the selection state is consistent.
+
+ nButtonDown = rMEvt.GetButtons();
+ FakeButtonUp();
+
+ if ( IsTracking() )
+ EndTracking(); // normally done in VCL as part of MouseButtonUp handling
+ }
+ nNestedButtonState = SC_NESTEDBUTTON_NONE;
+}
+
+void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt )
+{
+ // We have to check if a context menu is shown and we have an UI
+ // active inplace client. In that case we have to ignore the event.
+ // Otherwise we would crash (context menu has been
+ // opened by inplace client and we would deactivate the inplace client,
+ // the contex menu is closed by VCL asynchronously which in the end
+ // would work on deleted objects or the context menu has no parent anymore)
+ // See #126086# and #128122#
+ SfxViewShell* pViewSh = pViewData->GetViewShell();
+ SfxInPlaceClient* pClient = pViewSh->GetIPClient();
+ if ( pClient &&
+ pClient->IsObjectInPlaceActive() &&
+ PopupMenu::IsInExecute() )
+ return;
+
+ aCurMousePos = rMEvt.GetPosPixel();
+
+ // Filter-Popup beendet sich mit eigenem Mausklick, nicht erst beim Klick
+ // in das GridWindow, darum ist die folgende Abfrage nicht mehr noetig:
+ ClickExtern(); // loescht FilterBox, wenn vorhanden
+
+ HideNoteMarker(); // Notiz-Anzeige
+
+ bEEMouse = FALSE;
+
+ ScModule* pScMod = SC_MOD();
+ if (pScMod->IsModalMode(pViewData->GetSfxDocShell()))
+ {
+ Sound::Beep();
+ return;
+ }
+
+ pScActiveViewShell = pViewData->GetViewShell(); // falls auf Link geklickt wird
+ nScClickMouseModifier = rMEvt.GetModifier(); // um Control-Klick immer zu erkennen
+
+ BOOL bDetective = pViewData->GetViewShell()->IsAuditShell();
+ BOOL bRefMode = pViewData->IsRefMode(); // Referenz angefangen
+ BOOL bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz
+ BOOL bEditMode = pViewData->HasEditView(eWhich); // auch bei Mode==SC_INPUT_TYPE
+ BOOL bDouble = (rMEvt.GetClicks() == 2);
+
+ // DeactivateIP passiert nur noch bei MarkListHasChanged
+
+ // im GrabFocus Aufruf kann eine Fehlermeldung hochkommen
+ // (z.B. beim Umbenennen von Tabellen per Tab-Reiter)
+
+ if ( !nButtonDown || !bDouble ) // single (first) click is always valid
+ nButtonDown = rMEvt.GetButtons(); // set nButtonDown first, so StopMarking works
+
+// pViewData->GetViewShell()->GetViewFrame()->GetWindow().GrabFocus();
+ if ( ( bEditMode && pViewData->GetActivePart() == eWhich ) || !bFormulaMode )
+ GrabFocus();
+
+ // #i31846# need to cancel a double click if the first click has set the "ignore" state,
+ // but a single (first) click is always valid
+ if ( nMouseStatus == SC_GM_IGNORE && bDouble )
+ {
+ nButtonDown = 0;
+ nMouseStatus = SC_GM_NONE;
+ return;
+ }
+
+ if ( bDetective ) // Detektiv-Fuell-Modus
+ {
+ if ( rMEvt.IsLeft() && !rMEvt.GetModifier() )
+ {
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+
+ SfxInt16Item aPosXItem( SID_RANGE_COL, nPosX );
+ SfxInt32Item aPosYItem( SID_RANGE_ROW, nPosY );
+ pViewData->GetDispatcher().Execute( SID_FILL_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aPosXItem, &aPosYItem, (void*)0L );
+
+ }
+ nButtonDown = 0;
+ nMouseStatus = SC_GM_NONE;
+ return;
+ }
+
+ if (!bDouble)
+ nMouseStatus = SC_GM_NONE;
+
+ if (!bFormulaMode)
+ {
+ if ( pViewData->GetActivePart() != eWhich )
+ pViewData->GetView()->ActivatePart( eWhich );
+ }
+ else
+ {
+ ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine();
+ pSelEng->SetWindow(this);
+ pSelEng->SetWhich(eWhich);
+ pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) );
+ }
+
+ if (bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()))
+ {
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+
+ EditView* pEditView;
+ SCCOL nEditCol;
+ SCROW nEditRow;
+ pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
+ SCCOL nEndCol = pViewData->GetEditEndCol();
+ SCROW nEndRow = pViewData->GetEditEndRow();
+
+ if ( nPosX >= (SCsCOL) nEditCol && nPosX <= (SCsCOL) nEndCol &&
+ nPosY >= (SCsROW) nEditRow && nPosY <= (SCsROW) nEndRow )
+ {
+ // #53966# beim Klick in die Tabellen-EditView immer den Focus umsetzen
+ if (bFormulaMode) // sonst ist es oben schon passiert
+ GrabFocus();
+
+ pScMod->SetInputMode( SC_INPUT_TABLE );
+ bEEMouse = TRUE;
+ bEditMode = pEditView->MouseButtonDown( rMEvt );
+ return;
+ }
+ }
+
+ if (pScMod->GetIsWaterCan())
+ {
+ //! was is mit'm Mac ???
+ if ( rMEvt.GetModifier() + rMEvt.GetButtons() == MOUSE_RIGHT )
+ {
+ nMouseStatus = SC_GM_WATERUNDO;
+ return;
+ }
+ }
+
+ // Reihenfolge passend zum angezeigten Cursor:
+ // RangeFinder, AutoFill, PageBreak, Drawing
+
+ if ( HitRangeFinder( rMEvt.GetPosPixel(), bRFSize, &nRFIndex, &nRFAddX, &nRFAddY ) )
+ {
+ bRFMouse = TRUE; // die anderen Variablen sind oben initialisiert
+
+ if ( pViewData->GetActivePart() != eWhich )
+ pViewData->GetView()->ActivatePart( eWhich ); //! schon oben immer ???
+
+ // CaptureMouse();
+ StartTracking();
+ return;
+ }
+
+ BOOL bCrossPointer = TestMouse( rMEvt, TRUE );
+ if ( bCrossPointer )
+ {
+ if ( bDouble )
+ pViewData->GetView()->FillCrossDblClick();
+ else
+ pScMod->InputEnterHandler(); // Autofill etc.
+ }
+
+ if ( !bCrossPointer )
+ {
+ nPagebreakMouse = HitPageBreak( rMEvt.GetPosPixel(), &aPagebreakSource,
+ &nPagebreakBreak, &nPagebreakPrev );
+ if (nPagebreakMouse)
+ {
+ bPagebreakDrawn = FALSE;
+ // CaptureMouse();
+ StartTracking();
+ PagebreakMove( rMEvt, FALSE );
+ return;
+ }
+ }
+
+ if (!bFormulaMode && !bEditMode && rMEvt.IsLeft())
+ {
+ if ( !bCrossPointer && DrawMouseButtonDown(rMEvt) )
+ {
+ //if (DrawHasMarkedObj())
+ // pViewData->GetViewShell()->SetDrawShellOrSub(); // Draw-Objekt selektiert
+ return;
+ }
+
+ pViewData->GetViewShell()->SetDrawShell( FALSE ); // kein Draw-Objekt selektiert
+
+ // TestMouse schon oben passiert
+ }
+
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+
+ //
+ // AutoFilter buttons
+ //
+
+ if ( !bDouble && !bFormulaMode && rMEvt.IsLeft() )
+ {
+ ScMergeFlagAttr* pAttr = (ScMergeFlagAttr*)
+ pDoc->GetAttr( nPosX, nPosY, nTab, ATTR_MERGE_FLAG );
+ if (pAttr->HasAutoFilter())
+ {
+ if (DoAutoFilterButton(nPosX, nPosY, rMEvt))
+ return;
+ }
+ if (pAttr->HasButton())
+ {
+ DoPushButton( nPosX, nPosY, rMEvt ); // setzt evtl. bPivotMouse / bDPMouse
+ return;
+ }
+
+ // List Validity drop-down button
+
+ if ( bListValButton )
+ {
+ Rectangle aButtonRect = GetListValButtonRect( aListValPos );
+ if ( aButtonRect.IsInside( aPos ) )
+ {
+ DoAutoFilterMenue( aListValPos.Col(), aListValPos.Row(), TRUE );
+
+ nMouseStatus = SC_GM_FILTER; // not set in DoAutoFilterMenue for bDataSelect
+ CaptureMouse();
+ return;
+ }
+ }
+ }
+
+ //
+ // scenario selection
+ //
+
+ ScRange aScenRange;
+ if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) )
+ {
+ DoScenarioMenue( aScenRange );
+ return;
+ }
+
+ //
+ // Doppelklick angefangen ?
+ //
+
+ // StopMarking kann aus DrawMouseButtonDown gerufen werden
+
+ if ( nMouseStatus != SC_GM_IGNORE && !bRefMode )
+ {
+ if ( bDouble && !bCrossPointer )
+ {
+ if (nMouseStatus == SC_GM_TABDOWN)
+ nMouseStatus = SC_GM_DBLDOWN;
+ }
+ else
+ nMouseStatus = SC_GM_TABDOWN;
+ }
+
+ //
+ // Links in Edit-Zellen
+ //
+
+ BOOL bAlt = rMEvt.IsMod2();
+ if ( !bAlt && rMEvt.IsLeft() &&
+ GetEditUrl(rMEvt.GetPosPixel()) ) // Klick auf Link: Cursor nicht bewegen
+ {
+ SetPointer( Pointer( POINTER_REFHAND ) );
+ nMouseStatus = SC_GM_URLDOWN; // auch nur dann beim ButtonUp ausfuehren
+ return;
+ }
+
+ //
+ // Gridwin - SelectionEngine
+ //
+
+ if ( rMEvt.IsLeft() )
+ {
+ ScViewSelectionEngine* pSelEng = pViewData->GetView()->GetSelEngine();
+ pSelEng->SetWindow(this);
+ pSelEng->SetWhich(eWhich);
+ pSelEng->SetVisibleArea( Rectangle(Point(), GetOutputSizePixel()) );
+
+ // SelMouseButtonDown an der View setzt noch das bMoveIsShift Flag
+ if ( pViewData->GetView()->SelMouseButtonDown( rMEvt ) )
+ {
+ if (IsMouseCaptured())
+ {
+ // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
+ //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
+ ReleaseMouse();
+ StartTracking();
+ }
+ pViewData->GetMarkData().SetMarking(TRUE);
+ return;
+ }
+ }
+}
+
+void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ aCurMousePos = rMEvt.GetPosPixel();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+ // #i41690# detect a MouseButtonUp call from within MouseButtonDown
+ // (possible through Reschedule from storing an OLE object that is deselected)
+
+ if ( nNestedButtonState == SC_NESTEDBUTTON_DOWN )
+ nNestedButtonState = SC_NESTEDBUTTON_UP;
+
+ if (nButtonDown != rMEvt.GetButtons())
+ nMouseStatus = SC_GM_IGNORE; // reset und return
+
+ nButtonDown = 0;
+
+ if (nMouseStatus == SC_GM_IGNORE)
+ {
+ nMouseStatus = SC_GM_NONE;
+ // Selection-Engine: Markieren abbrechen
+ pViewData->GetView()->GetSelEngine()->Reset();
+ rMark.SetMarking(FALSE);
+ if (pViewData->IsAnyFillMode())
+ {
+ pViewData->GetView()->StopRefMode();
+ pViewData->ResetFillMode();
+ }
+ StopMarking();
+ DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen
+ ReleaseMouse();
+ return;
+ }
+
+ if (nMouseStatus == SC_GM_FILTER)
+ {
+ if ( pFilterBox && pFilterBox->GetMode() == SC_FILTERBOX_FILTER )
+ {
+ if (mpFilterButton.get())
+ {
+ bool bFilterActive = IsAutoFilterActive(
+ pFilterBox->GetCol(), pFilterBox->GetRow(), pViewData->GetTabNo() );
+
+ mpFilterButton->setHasHiddenMember(bFilterActive);
+ mpFilterButton->setPopupPressed(false);
+ HideCursor();
+ mpFilterButton->draw();
+ ShowCursor();
+ }
+ }
+ nMouseStatus = SC_GM_NONE;
+ ReleaseMouse();
+ return; // da muss nix mehr passieren
+ }
+
+ ScModule* pScMod = SC_MOD();
+ if (pScMod->IsModalMode(pViewData->GetSfxDocShell()))
+ return;
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ if (bEEMouse && pViewData->HasEditView( eWhich ))
+ {
+ EditView* pEditView;
+ SCCOL nEditCol;
+ SCROW nEditRow;
+ pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
+ pEditView->MouseButtonUp( rMEvt );
+
+ if ( rMEvt.IsMiddle() &&
+ GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION )
+ {
+ // EditView may have pasted from selection
+ pScMod->InputChanged( pEditView );
+ }
+ else
+ pScMod->InputSelection( pEditView ); // parentheses etc.
+
+ pViewData->GetView()->InvalidateAttribs();
+ rBindings.Invalidate( SID_HYPERLINK_GETLINK );
+ bEEMouse = FALSE;
+ return;
+ }
+
+ if (bDPMouse)
+ {
+ DPMouseButtonUp( rMEvt ); // resets bDPMouse
+ return;
+ }
+
+ if (bRFMouse)
+ {
+ RFMouseMove( rMEvt, TRUE ); // Range wieder richtigherum
+ bRFMouse = FALSE;
+ SetPointer( Pointer( POINTER_ARROW ) );
+ ReleaseMouse();
+ return;
+ }
+
+ if (nPagebreakMouse)
+ {
+ PagebreakMove( rMEvt, TRUE );
+ nPagebreakMouse = SC_PD_NONE;
+ SetPointer( Pointer( POINTER_ARROW ) );
+ ReleaseMouse();
+ return;
+ }
+
+ if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus
+ {
+ SfxUndoManager* pMgr = pViewData->GetDocShell()->GetUndoManager();
+ if ( pMgr->GetUndoActionCount() && pMgr->GetUndoActionId() == STR_UNDO_APPLYCELLSTYLE )
+ pMgr->Undo();
+ else
+ Sound::Beep();
+ return;
+ }
+
+ if (DrawMouseButtonUp(rMEvt)) // includes format paint brush handling for drawing objects
+ return;
+
+ rMark.SetMarking(FALSE);
+
+ SetPointer( Pointer( POINTER_ARROW ) );
+
+ if (pViewData->IsFillMode() ||
+ ( pViewData->GetFillMode() == SC_FILL_MATRIX && rMEvt.IsMod1() ))
+ {
+ nScFillModeMouseModifier = rMEvt.GetModifier();
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
+// DBG_ASSERT( nStartCol==pViewData->GetRefStartX() && nStartRow==pViewData->GetRefStartY(),
+// "Block falsch fuer AutoFill" );
+ ScRange aDelRange;
+ BOOL bIsDel = pViewData->GetDelMark( aDelRange );
+
+ ScViewFunc* pView = pViewData->GetView();
+ pView->StopRefMode();
+ pViewData->ResetFillMode();
+ pView->GetFunctionSet()->SetAnchorFlag( FALSE ); // #i5819# don't use AutoFill anchor flag for selection
+
+ if ( bIsDel )
+ {
+ pView->MarkRange( aDelRange, FALSE );
+ pView->DeleteContents( IDF_CONTENTS );
+ SCTAB nTab = pViewData->GetTabNo();
+ ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
+ if ( aBlockRange != aDelRange )
+ {
+ if ( aDelRange.aStart.Row() == nStartRow )
+ aBlockRange.aEnd.SetCol( aDelRange.aStart.Col() - 1 );
+ else
+ aBlockRange.aEnd.SetRow( aDelRange.aStart.Row() - 1 );
+ pView->MarkRange( aBlockRange, FALSE );
+ }
+ }
+ else
+ pViewData->GetDispatcher().Execute( FID_FILL_AUTO, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ }
+ else if (pViewData->GetFillMode() == SC_FILL_MATRIX)
+ {
+ SCTAB nTab = pViewData->GetTabNo();
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ pViewData->GetFillData( nStartCol, nStartRow, nEndCol, nEndRow );
+ ScRange aBlockRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
+ SCCOL nFillCol = pViewData->GetRefEndX();
+ SCROW nFillRow = pViewData->GetRefEndY();
+ ScAddress aEndPos( nFillCol, nFillRow, nTab );
+
+ ScTabView* pView = pViewData->GetView();
+ pView->StopRefMode();
+ pViewData->ResetFillMode();
+ pView->GetFunctionSet()->SetAnchorFlag( FALSE );
+
+ if ( aEndPos != aBlockRange.aEnd )
+ {
+ pViewData->GetDocShell()->GetDocFunc().ResizeMatrix( aBlockRange, aEndPos, FALSE );
+ pViewData->GetView()->MarkRange( ScRange( aBlockRange.aStart, aEndPos ) );
+ }
+ }
+ else if (pViewData->IsAnyFillMode())
+ {
+ // Embedded-Area has been changed
+ ScTabView* pView = pViewData->GetView();
+ pView->StopRefMode();
+ pViewData->ResetFillMode();
+ pView->GetFunctionSet()->SetAnchorFlag( FALSE );
+ pViewData->GetDocShell()->UpdateOle(pViewData);
+ }
+
+ BOOL bRefMode = pViewData->IsRefMode();
+ if (bRefMode)
+ pScMod->EndReference();
+
+ //
+ // Giesskannen-Modus (Gestalter)
+ //
+
+ if (pScMod->GetIsWaterCan())
+ {
+ // Abfrage auf Undo schon oben
+
+ ScStyleSheetPool* pStylePool = (ScStyleSheetPool*)
+ (pViewData->GetDocument()->
+ GetStyleSheetPool());
+ if ( pStylePool )
+ {
+ SfxStyleSheet* pStyleSheet = (SfxStyleSheet*)
+ pStylePool->GetActualStyleSheet();
+
+ if ( pStyleSheet )
+ {
+ SfxStyleFamily eFamily = pStyleSheet->GetFamily();
+
+ switch ( eFamily )
+ {
+ case SFX_STYLE_FAMILY_PARA:
+ pViewData->GetView()->SetStyleSheetToMarked( pStyleSheet );
+ pViewData->GetView()->DoneBlockMode();
+ break;
+
+ case SFX_STYLE_FAMILY_PAGE:
+ pViewData->GetDocument()->SetPageStyle( pViewData->GetTabNo(),
+ pStyleSheet->GetName() );
+
+ ScPrintFunc( pViewData->GetDocShell(),
+ pViewData->GetViewShell()->GetPrinter(TRUE),
+ pViewData->GetTabNo() ).UpdatePages();
+
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE );
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ ScDBFunc* pView = pViewData->GetView();
+ ScDocument* pBrushDoc = pView->GetBrushDocument();
+ if ( pBrushDoc )
+ {
+ pView->PasteFromClip( IDF_ATTRIB, pBrushDoc );
+ if ( !pView->IsPaintBrushLocked() )
+ pView->ResetBrushDocument(); // invalidates pBrushDoc pointer
+ }
+
+ //
+ // double click (only left button)
+ //
+
+ BOOL bDouble = ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() );
+ if ( bDouble && !bRefMode && nMouseStatus == SC_GM_DBLDOWN && !pScMod->IsRefDialogOpen() )
+ {
+ // data pilot table
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ SCTAB nTab = pViewData->GetTabNo();
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor( nPosX, nPosY, nTab );
+ if ( pDPObj && pDPObj->GetSaveData()->GetDrillDown() )
+ {
+ ScAddress aCellPos( nPosX, nPosY, pViewData->GetTabNo() );
+
+ // Check for header drill-down first.
+ sheet::DataPilotTableHeaderData aData;
+ pDPObj->GetHeaderPositionData(aCellPos, aData);
+
+ if ( ( aData.Flags & sheet::MemberResultFlags::HASMEMBER ) &&
+ ! ( aData.Flags & sheet::MemberResultFlags::SUBTOTAL ) )
+ {
+ USHORT nDummy;
+ if ( pView->HasSelectionForDrillDown( nDummy ) )
+ {
+ // execute slot to show dialog
+ pViewData->GetDispatcher().Execute( SID_OUTLINE_SHOW, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ }
+ else
+ {
+ // toggle single entry
+ ScDPObject aNewObj( *pDPObj );
+ pDPObj->ToggleDetails( aData, &aNewObj );
+ ScDBDocFunc aFunc( *pViewData->GetDocShell() );
+ aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE );
+ pViewData->GetView()->CursorPosChanged(); // shells may be switched
+ }
+ }
+ else
+ {
+ // Check if the data area is double-clicked.
+
+ Sequence<sheet::DataPilotFieldFilter> aFilters;
+ if ( pDPObj->GetDataFieldPositionData(aCellPos, aFilters) )
+ pViewData->GetView()->ShowDataPilotSourceData( *pDPObj, aFilters );
+ else
+ Sound::Beep(); // nothing to expand/collapse/show
+ }
+
+ return;
+ }
+
+ // Check for cell protection attribute.
+ ScTableProtection* pProtect = pDoc->GetTabProtection( nTab );
+ bool bEditAllowed = true;
+ if ( pProtect && pProtect->isProtected() )
+ {
+ bool bCellProtected = pDoc->HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HASATTR_PROTECTED);
+ bool bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bool bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+
+ if ( bSkipProtected && bSkipUnprotected )
+ bEditAllowed = false;
+ else if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) )
+ bEditAllowed = false;
+ }
+
+ if ( bEditAllowed )
+ {
+ // edit cell contents
+ pViewData->GetViewShell()->UpdateInputHandler();
+ pScMod->SetInputMode( SC_INPUT_TABLE );
+ if (pViewData->HasEditView(eWhich))
+ {
+ // Text-Cursor gleich an die geklickte Stelle setzen
+ EditView* pEditView = pViewData->GetEditView( eWhich );
+ MouseEvent aEditEvt( rMEvt.GetPosPixel(), 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 );
+ pEditView->MouseButtonDown( aEditEvt );
+ pEditView->MouseButtonUp( aEditEvt );
+ }
+ }
+ return;
+ }
+
+ //
+ // Links in edit cells
+ //
+
+ BOOL bAlt = rMEvt.IsMod2();
+ if ( !bAlt && !bRefMode && !bDouble && nMouseStatus == SC_GM_URLDOWN )
+ {
+ // beim ButtonUp nur ausfuehren, wenn ButtonDown auch ueber einer URL war
+
+ String aName, aUrl, aTarget;
+ if ( GetEditUrl( rMEvt.GetPosPixel(), &aName, &aUrl, &aTarget ) )
+ {
+ nMouseStatus = SC_GM_NONE; // keinen Doppelklick anfangen
+ ScGlobal::OpenURL( aUrl, aTarget );
+
+ // fire worksheet_followhyperlink event
+ uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor();
+ if( xVbaEvents.is() ) try
+ {
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ SCTAB nTab = pViewData->GetTabNo();
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+ ScBaseCell* pCell = NULL;
+ if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ) )
+ {
+ ScAddress aCellPos( nPosX, nPosY, nTab );
+ uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) );
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] <<= xCell;
+ xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ return;
+ }
+ }
+
+ //
+ // Gridwin - SelectionEngine
+ //
+
+ // SelMouseButtonDown is called only for left button, but SelMouseButtonUp would return
+ // TRUE for any call, so IsLeft must be checked here, too.
+
+ if ( rMEvt.IsLeft() && pViewData->GetView()->GetSelEngine()->SelMouseButtonUp( rMEvt ) )
+ {
+// rMark.MarkToSimple();
+ pViewData->GetView()->SelectionChanged();
+
+ SfxDispatcher* pDisp = pViewData->GetViewShell()->GetDispatcher();
+ BOOL bFormulaMode = pScMod->IsFormulaMode();
+ DBG_ASSERT( pDisp || bFormulaMode, "Cursor auf nicht aktiver View bewegen ?" );
+
+ // #i14927# execute SID_CURRENTCELL (for macro recording) only if there is no
+ // multiple selection, so the argument string completely describes the selection,
+ // and executing the slot won't change the existing selection (executing the slot
+ // here and from a recorded macro is treated equally)
+
+ if ( pDisp && !bFormulaMode && !rMark.IsMultiMarked() )
+ {
+ String aAddr; // CurrentCell
+ if( rMark.IsMarked() )
+ {
+// BOOL bKeep = rMark.IsMultiMarked(); //! wohin damit ???
+
+ ScRange aScRange;
+ rMark.GetMarkArea( aScRange );
+ aScRange.Format( aAddr, SCR_ABS );
+ if ( aScRange.aStart == aScRange.aEnd )
+ {
+ // make sure there is a range selection string even for a single cell
+ String aSingle = aAddr;
+ aAddr.Append( (sal_Char) ':' );
+ aAddr.Append( aSingle );
+ }
+
+ //! SID_MARKAREA gibts nicht mehr ???
+ //! was passiert beim Markieren mit dem Cursor ???
+ }
+ else // nur Cursor bewegen
+ {
+ ScAddress aScAddress( pViewData->GetCurX(), pViewData->GetCurY(), 0 );
+ aScAddress.Format( aAddr, SCA_ABS );
+ }
+
+ SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
+ // We don't want to align to the cursor position because if the
+ // cell cursor isn't visible after making selection, it would jump
+ // back to the origin of the selection where the cell cursor is.
+ SfxBoolItem aAlignCursorItem( FN_PARAM_2, false );
+ pDisp->Execute( SID_CURRENTCELL, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aPosItem, &aAlignCursorItem, (void*)0L );
+
+ pViewData->GetView()->InvalidateAttribs();
+ }
+ return;
+ }
+}
+
+void ScGridWindow::FakeButtonUp()
+{
+ if ( nButtonDown )
+ {
+ MouseEvent aEvent( aCurMousePos ); // nButtons = 0 -> ignore
+ MouseButtonUp( aEvent );
+ }
+}
+
+void __EXPORT ScGridWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ aCurMousePos = rMEvt.GetPosPixel();
+
+ if ( rMEvt.IsLeaveWindow() && pNoteMarker && !pNoteMarker->IsByKeyboard() )
+ HideNoteMarker();
+
+ ScModule* pScMod = SC_MOD();
+ if (pScMod->IsModalMode(pViewData->GetSfxDocShell()))
+ return;
+
+ // Ob aus dem Edit-Modus Drag&Drop gestartet wurde, bekommt man leider
+ // nicht anders mit:
+
+ if (bEEMouse && nButtonDown && !rMEvt.GetButtons())
+ {
+ bEEMouse = FALSE;
+ nButtonDown = 0;
+ nMouseStatus = SC_GM_NONE;
+ return;
+ }
+
+ if (nMouseStatus == SC_GM_IGNORE)
+ return;
+
+ if (nMouseStatus == SC_GM_WATERUNDO) // Undo im Giesskannenmodus -> nur auf Up warten
+ return;
+
+ if ( pViewData->GetViewShell()->IsAuditShell() ) // Detektiv-Fuell-Modus
+ {
+ SetPointer( Pointer( POINTER_FILL ) );
+ return;
+ }
+
+ if (nMouseStatus == SC_GM_FILTER && pFilterBox)
+ {
+ Point aRelPos = pFilterBox->ScreenToOutputPixel( OutputToScreenPixel( rMEvt.GetPosPixel() ) );
+ if ( Rectangle(Point(),pFilterBox->GetOutputSizePixel()).IsInside(aRelPos) )
+ {
+ nButtonDown = 0;
+ nMouseStatus = SC_GM_NONE;
+ if ( pFilterBox->GetMode() == SC_FILTERBOX_FILTER )
+ {
+ if (mpFilterButton.get())
+ {
+ mpFilterButton->setHasHiddenMember(false);
+ mpFilterButton->setPopupPressed(false);
+ HideCursor();
+ mpFilterButton->draw();
+ ShowCursor();
+ }
+ }
+ ReleaseMouse();
+ pFilterBox->MouseButtonDown( MouseEvent( aRelPos, 1, MOUSE_SIMPLECLICK, MOUSE_LEFT ) );
+ return;
+ }
+ }
+
+ BOOL bFormulaMode = pScMod->IsFormulaMode(); // naechster Klick -> Referenz
+
+ if (bEEMouse && pViewData->HasEditView( eWhich ))
+ {
+ EditView* pEditView;
+ SCCOL nEditCol;
+ SCROW nEditRow;
+ pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
+ pEditView->MouseMove( rMEvt );
+ return;
+ }
+
+ if (bDPMouse)
+ {
+ DPMouseMove( rMEvt );
+ return;
+ }
+
+ if (bRFMouse)
+ {
+ RFMouseMove( rMEvt, FALSE );
+ return;
+ }
+
+ if (nPagebreakMouse)
+ {
+ PagebreakMove( rMEvt, FALSE );
+ return;
+ }
+
+ // anderen Mauszeiger anzeigen?
+
+ BOOL bEditMode = pViewData->HasEditView(eWhich);
+
+ //! Testen ob RefMode-Dragging !!!
+ if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) )
+ {
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+
+ EditView* pEditView;
+ SCCOL nEditCol;
+ SCROW nEditRow;
+ pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
+ SCCOL nEndCol = pViewData->GetEditEndCol();
+ SCROW nEndRow = pViewData->GetEditEndRow();
+
+ if ( nPosX >= (SCsCOL) nEditCol && nPosX <= (SCsCOL) nEndCol &&
+ nPosY >= (SCsROW) nEditRow && nPosY <= (SCsROW) nEndRow )
+ {
+ // Field can only be URL field
+ BOOL bAlt = rMEvt.IsMod2();
+ if ( !bAlt && !nButtonDown && pEditView && pEditView->GetFieldUnderMousePointer() )
+ SetPointer( Pointer( POINTER_REFHAND ) );
+ else if ( pEditView && pEditView->GetEditEngine()->IsVertical() )
+ SetPointer( Pointer( POINTER_TEXT_VERTICAL ) );
+ else
+ SetPointer( Pointer( POINTER_TEXT ) );
+ return;
+ }
+ }
+
+ BOOL bWater = SC_MOD()->GetIsWaterCan() || pViewData->GetView()->HasPaintBrush();
+ if (bWater)
+ SetPointer( Pointer(POINTER_FILL) );
+
+ if (!bWater)
+ {
+ BOOL bCross = FALSE;
+
+ // Range-Finder
+
+ BOOL bCorner;
+ if ( HitRangeFinder( rMEvt.GetPosPixel(), bCorner ) )
+ {
+ if (bCorner)
+ SetPointer( Pointer( POINTER_CROSS ) );
+ else
+ SetPointer( Pointer( POINTER_HAND ) );
+ bCross = TRUE;
+ }
+
+ // Page-Break-Modus
+
+ USHORT nBreakType;
+ if ( !nButtonDown && pViewData->IsPagebreakMode() &&
+ ( nBreakType = HitPageBreak( rMEvt.GetPosPixel() ) ) != 0 )
+ {
+ PointerStyle eNew = POINTER_ARROW;
+ switch ( nBreakType )
+ {
+ case SC_PD_RANGE_L:
+ case SC_PD_RANGE_R:
+ case SC_PD_BREAK_H:
+ eNew = POINTER_ESIZE;
+ break;
+ case SC_PD_RANGE_T:
+ case SC_PD_RANGE_B:
+ case SC_PD_BREAK_V:
+ eNew = POINTER_SSIZE;
+ break;
+ case SC_PD_RANGE_TL:
+ case SC_PD_RANGE_BR:
+ eNew = POINTER_SESIZE;
+ break;
+ case SC_PD_RANGE_TR:
+ case SC_PD_RANGE_BL:
+ eNew = POINTER_NESIZE;
+ break;
+ }
+ SetPointer( Pointer( eNew ) );
+ bCross = TRUE;
+ }
+
+ // Fill-Cursor anzeigen ?
+
+ if ( !bFormulaMode && !nButtonDown )
+ if (TestMouse( rMEvt, FALSE ))
+ bCross = TRUE;
+
+ if ( nButtonDown && pViewData->IsAnyFillMode() )
+ {
+ SetPointer( Pointer( POINTER_CROSS ) );
+ bCross = TRUE;
+ nScFillModeMouseModifier = rMEvt.GetModifier(); // ausgewertet bei AutoFill und Matrix
+ }
+
+ if (!bCross)
+ {
+ BOOL bAlt = rMEvt.IsMod2();
+
+ if (bEditMode) // Edit-Mode muss zuerst kommen!
+ SetPointer( Pointer( POINTER_ARROW ) );
+ else if ( !bAlt && !nButtonDown &&
+ GetEditUrl(rMEvt.GetPosPixel()) )
+ SetPointer( Pointer( POINTER_REFHAND ) );
+ else if ( DrawMouseMove(rMEvt) ) // setzt Pointer um
+ return;
+ }
+ }
+
+ if ( pViewData->GetView()->GetSelEngine()->SelMouseMove( rMEvt ) )
+ return;
+}
+
+void lcl_InitMouseEvent( ::com::sun::star::awt::MouseEvent& rEvent, const MouseEvent& rEvt )
+{
+ rEvent.Modifiers = 0;
+ if ( rEvt.IsShift() )
+ rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::SHIFT;
+ if ( rEvt.IsMod1() )
+ rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD1;
+ if ( rEvt.IsMod2() )
+ rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD2;
+ if ( rEvt.IsMod3() )
+ rEvent.Modifiers |= ::com::sun::star::awt::KeyModifier::MOD3;
+
+ rEvent.Buttons = 0;
+ if ( rEvt.IsLeft() )
+ rEvent.Buttons |= ::com::sun::star::awt::MouseButton::LEFT;
+ if ( rEvt.IsRight() )
+ rEvent.Buttons |= ::com::sun::star::awt::MouseButton::RIGHT;
+ if ( rEvt.IsMiddle() )
+ rEvent.Buttons |= ::com::sun::star::awt::MouseButton::MIDDLE;
+
+ rEvent.X = rEvt.GetPosPixel().X();
+ rEvent.Y = rEvt.GetPosPixel().Y();
+ rEvent.ClickCount = rEvt.GetClicks();
+ rEvent.PopupTrigger = sal_False;
+}
+
+long ScGridWindow::PreNotify( NotifyEvent& rNEvt )
+{
+ bool bDone = false;
+ USHORT nType = rNEvt.GetType();
+ if ( nType == EVENT_MOUSEBUTTONUP || nType == EVENT_MOUSEBUTTONDOWN )
+ {
+ Window* pWindow = rNEvt.GetWindow();
+ if (pWindow == this && pViewData)
+ {
+ SfxViewFrame* pViewFrame = pViewData->GetViewShell()->GetViewFrame();
+ if (pViewFrame)
+ {
+ com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = pViewFrame->GetFrame().GetController();
+ if (xController.is())
+ {
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp && pImp->IsMouseListening())
+ {
+ ::com::sun::star::awt::MouseEvent aEvent;
+ lcl_InitMouseEvent( aEvent, *rNEvt.GetMouseEvent() );
+ if ( rNEvt.GetWindow() )
+ aEvent.Source = rNEvt.GetWindow()->GetComponentInterface();
+ if ( nType == EVENT_MOUSEBUTTONDOWN)
+ bDone = pImp->MousePressed( aEvent );
+ else
+ bDone = pImp->MouseReleased( aEvent );
+ }
+ }
+ }
+ }
+ }
+ if (bDone) // event consumed by a listener
+ {
+ if ( nType == EVENT_MOUSEBUTTONDOWN )
+ {
+ const MouseEvent* pMouseEvent = rNEvt.GetMouseEvent();
+ if ( pMouseEvent->IsRight() && pMouseEvent->GetClicks() == 1 )
+ {
+ // If a listener returned true for a right-click call, also prevent opening the context menu
+ // (this works only if the context menu is opened on mouse-down)
+ nMouseStatus = SC_GM_IGNORE;
+ }
+ }
+
+ return 1;
+ }
+ else
+ return Window::PreNotify( rNEvt );
+}
+
+void ScGridWindow::Tracking( const TrackingEvent& rTEvt )
+{
+ // Weil die SelectionEngine kein Tracking kennt, die Events nur auf
+ // die verschiedenen MouseHandler verteilen...
+
+ const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
+
+ if ( rTEvt.IsTrackingCanceled() ) // alles abbrechen...
+ {
+ if (!pViewData->GetView()->IsInActivatePart())
+ {
+ if (bDPMouse)
+ bDPMouse = FALSE; // gezeichnet wird per bDragRect
+ if (bDragRect)
+ {
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ }
+ if (bRFMouse)
+ {
+ RFMouseMove( rMEvt, TRUE ); // richtig abbrechen geht dabei nicht...
+ bRFMouse = FALSE;
+ }
+ if (nPagebreakMouse)
+ {
+ // if (bPagebreakDrawn)
+ // DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(),
+ // aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE );
+ bPagebreakDrawn = FALSE;
+ UpdateDragRectOverlay();
+ nPagebreakMouse = SC_PD_NONE;
+ }
+
+ SetPointer( Pointer( POINTER_ARROW ) );
+ StopMarking();
+ MouseButtonUp( rMEvt ); // mit Status SC_GM_IGNORE aus StopMarking
+
+ BOOL bRefMode = pViewData->IsRefMode();
+ if (bRefMode)
+ SC_MOD()->EndReference(); // #63148# Dialog nicht verkleinert lassen
+ }
+ }
+ else if ( rTEvt.IsTrackingEnded() )
+ {
+ // MouseButtonUp immer mit passenden Buttons (z.B. wegen Testtool, #63148#)
+ // Schliesslich behauptet der Tracking-Event ja, dass normal beendet und nicht
+ // abgebrochen wurde.
+
+ MouseEvent aUpEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(),
+ rMEvt.GetMode(), nButtonDown, rMEvt.GetModifier() );
+ MouseButtonUp( aUpEvt );
+ }
+ else
+ MouseMove( rMEvt );
+}
+
+void ScGridWindow::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
+{
+ if ( pFilterBox || nPagebreakMouse )
+ return;
+
+ HideNoteMarker();
+
+ CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, TRUE );
+
+ if (bEEMouse && pViewData->HasEditView( eWhich ))
+ {
+ EditView* pEditView;
+ SCCOL nEditCol;
+ SCROW nEditRow;
+ pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
+
+ // #63263# don't remove the edit view while switching views
+ ScModule* pScMod = SC_MOD();
+ pScMod->SetInEditCommand( TRUE );
+
+ pEditView->Command( aDragEvent );
+
+ ScInputHandler* pHdl = pScMod->GetInputHdl();
+ if (pHdl)
+ pHdl->DataChanged();
+
+ pScMod->SetInEditCommand( FALSE );
+ if (!pViewData->IsActive()) // dropped to different view?
+ {
+ ScInputHandler* pViewHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
+ if ( pViewHdl && pViewData->HasEditView( eWhich ) )
+ {
+ pViewHdl->CancelHandler();
+ ShowCursor(); // missing from KillEditView
+ }
+ }
+ }
+ else
+ if ( !DrawCommand(aDragEvent) )
+ pViewData->GetView()->GetSelEngine()->Command( aDragEvent );
+}
+
+void lcl_SetTextCursorPos( ScViewData* pViewData, ScSplitPos eWhich, Window* pWin )
+{
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ Rectangle aEditArea = pViewData->GetEditArea( eWhich, nCol, nRow, pWin, NULL, TRUE );
+ aEditArea.Right() = aEditArea.Left();
+ aEditArea = pWin->PixelToLogic( aEditArea );
+ pWin->SetCursorRect( &aEditArea );
+}
+
+void __EXPORT ScGridWindow::Command( const CommandEvent& rCEvt )
+{
+ // The command event is send to the window after a possible context
+ // menu from an inplace client is closed. Now we have the chance to
+ // deactivate the inplace client without any problem regarding parent
+ // windows and code on the stack.
+ // For more information, see #126086# and #128122#
+ USHORT nCmd = rCEvt.GetCommand();
+ ScTabViewShell* pTabViewSh = pViewData->GetViewShell();
+ SfxInPlaceClient* pClient = pTabViewSh->GetIPClient();
+ if ( pClient &&
+ pClient->IsObjectInPlaceActive() &&
+ nCmd == COMMAND_CONTEXTMENU )
+ {
+ pTabViewSh->DeactivateOle();
+ return;
+ }
+
+ ScModule* pScMod = SC_MOD();
+ DBG_ASSERT( nCmd != COMMAND_STARTDRAG, "ScGridWindow::Command called with COMMAND_STARTDRAG" );
+
+ if ( nCmd == COMMAND_STARTEXTTEXTINPUT ||
+ nCmd == COMMAND_ENDEXTTEXTINPUT ||
+ nCmd == COMMAND_EXTTEXTINPUT ||
+ nCmd == COMMAND_CURSORPOS )
+ {
+ BOOL bEditView = pViewData->HasEditView( eWhich );
+ if (!bEditView)
+ {
+ // only if no cell editview is active, look at drawview
+ SdrView* pSdrView = pViewData->GetView()->GetSdrView();
+ if ( pSdrView )
+ {
+ OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
+ if ( pOlView && pOlView->GetWindow() == this )
+ {
+ pOlView->Command( rCEvt );
+ return; // done
+ }
+ }
+ }
+
+ if ( nCmd == COMMAND_CURSORPOS && !bEditView )
+ {
+ // #88458# CURSORPOS may be called without following text input,
+ // to set the input method window position
+ // -> input mode must not be started,
+ // manually calculate text insert position if not in input mode
+
+ lcl_SetTextCursorPos( pViewData, eWhich, this );
+ return;
+ }
+
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
+ if ( pHdl )
+ {
+ pHdl->InputCommand( rCEvt, TRUE );
+ return; // done
+ }
+
+ Window::Command( rCEvt );
+ return;
+ }
+
+ if ( nCmd == COMMAND_VOICE )
+ {
+ // Der Handler wird nur gerufen, wenn ein Text-Cursor aktiv ist,
+ // also muss es eine EditView oder ein editiertes Zeichenobjekt geben
+
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
+ if ( pHdl && pViewData->HasEditView( eWhich ) )
+ {
+ EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0
+ pHdl->DataChanging();
+ pEditView->Command( rCEvt );
+ pHdl->DataChanged();
+ return; // erledigt
+ }
+ SdrView* pSdrView = pViewData->GetView()->GetSdrView();
+ if ( pSdrView )
+ {
+ OutlinerView* pOlView = pSdrView->GetTextEditOutlinerView();
+ if ( pOlView && pOlView->GetWindow() == this )
+ {
+ pOlView->Command( rCEvt );
+ return; // erledigt
+ }
+ }
+ Window::Command(rCEvt); // sonst soll sich die Basisklasse drum kuemmern...
+ return;
+ }
+
+ if ( nCmd == COMMAND_PASTESELECTION )
+ {
+ if ( bEEMouse )
+ {
+ // EditEngine handles selection in MouseButtonUp - no action
+ // needed in command handler
+ }
+ else
+ {
+ PasteSelection( rCEvt.GetMousePosPixel() );
+ }
+ return;
+ }
+
+ if ( nCmd == COMMAND_INPUTLANGUAGECHANGE )
+ {
+ // #i55929# Font and font size state depends on input language if nothing is selected,
+ // so the slots have to be invalidated when the input language is changed.
+
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ return;
+ }
+
+ if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL )
+ {
+ BOOL bDone = pViewData->GetView()->ScrollCommand( rCEvt, eWhich );
+ if (!bDone)
+ Window::Command(rCEvt);
+ return;
+ }
+ // #i7560# FormulaMode check is below scrolling - scrolling is allowed during formula input
+ BOOL bDisable = pScMod->IsFormulaMode() ||
+ pScMod->IsModalMode(pViewData->GetSfxDocShell());
+ if (bDisable)
+ return;
+
+ if ( nCmd == COMMAND_CONTEXTMENU && !SC_MOD()->GetIsWaterCan() )
+ {
+ BOOL bMouse = rCEvt.IsMouseEvent();
+ if ( bMouse && nMouseStatus == SC_GM_IGNORE )
+ return;
+
+ if (pViewData->IsAnyFillMode())
+ {
+ pViewData->GetView()->StopRefMode();
+ pViewData->ResetFillMode();
+ }
+ ReleaseMouse();
+ StopMarking();
+
+ Point aPosPixel = rCEvt.GetMousePosPixel();
+ Point aMenuPos = aPosPixel;
+
+ if ( bMouse )
+ {
+ SCsCOL nCellX = -1;
+ SCsROW nCellY = -1;
+ pViewData->GetPosFromPixel(aPosPixel.X(), aPosPixel.Y(), eWhich, nCellX, nCellY);
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ bool bSelectAllowed = true;
+ if ( pProtect && pProtect->isProtected() )
+ {
+ // This sheet is protected. Check if a context menu is allowed on this cell.
+ bool bCellProtected = pDoc->HasAttrib(nCellX, nCellY, nTab, nCellX, nCellY, nTab, HASATTR_PROTECTED);
+ bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+
+ if (bCellProtected)
+ bSelectAllowed = bSelProtected;
+ else
+ bSelectAllowed = bSelUnprotected;
+ }
+ if (!bSelectAllowed)
+ // Selecting this cell is not allowed, neither is context menu.
+ return;
+
+ // #i18735# First select the item under the mouse pointer.
+ // This can change the selection, and the view state (edit mode, etc).
+ SelectForContextMenu( aPosPixel, nCellX, nCellY );
+ }
+
+ BOOL bDone = FALSE;
+ BOOL bEdit = pViewData->HasEditView(eWhich);
+ if ( !bEdit )
+ {
+ // Edit-Zelle mit Spelling-Errors ?
+ if ( bMouse && GetEditUrlOrError( TRUE, aPosPixel ) )
+ {
+ // GetEditUrlOrError hat den Cursor schon bewegt
+
+ pScMod->SetInputMode( SC_INPUT_TABLE );
+ bEdit = pViewData->HasEditView(eWhich); // hat's geklappt ?
+
+ DBG_ASSERT( bEdit, "kann nicht in Edit-Modus schalten" );
+ }
+ }
+ if ( bEdit )
+ {
+ EditView* pEditView = pViewData->GetEditView( eWhich ); // ist dann nicht 0
+
+ if ( !bMouse )
+ {
+ Cursor* pCur = pEditView->GetCursor();
+ if ( pCur )
+ {
+ Point aLogicPos = pCur->GetPos();
+ // use the position right of the cursor (spell popup is opened if
+ // the cursor is before the word, but not if behind it)
+ aLogicPos.X() += pCur->GetWidth();
+ aLogicPos.Y() += pCur->GetHeight() / 2; // center vertically
+ aMenuPos = LogicToPixel( aLogicPos );
+ }
+ }
+
+ // if edit mode was just started above, online spelling may be incomplete
+ pEditView->GetEditEngine()->CompleteOnlineSpelling();
+
+ // IsCursorAtWrongSpelledWord could be used for !bMouse
+ // if there was a corresponding ExecuteSpellPopup call
+
+ if( pEditView->IsWrongSpelledWordAtPos( aMenuPos ) )
+ {
+ // Wenn man unter OS/2 neben das Popupmenue klickt, kommt MouseButtonDown
+ // vor dem Ende des Menue-Execute, darum muss SetModified vorher kommen
+ // (Bug #40968#)
+ ScInputHandler* pHdl = pScMod->GetInputHdl();
+ if (pHdl)
+ pHdl->SetModified();
+
+ Link aLink = LINK( this, ScGridWindow, PopupSpellingHdl );
+ pEditView->ExecuteSpellPopup( aMenuPos, &aLink );
+
+ bDone = TRUE;
+ }
+ }
+ else if ( !bMouse )
+ {
+ // non-edit menu by keyboard -> use lower right of cell cursor position
+
+ SCCOL nCurX = pViewData->GetCurX();
+ SCROW nCurY = pViewData->GetCurY();
+ aMenuPos = pViewData->GetScrPos( nCurX, nCurY, eWhich, TRUE );
+ long nSizeXPix;
+ long nSizeYPix;
+ pViewData->GetMergeSizePixel( nCurX, nCurY, nSizeXPix, nSizeYPix );
+ aMenuPos.X() += nSizeXPix;
+ aMenuPos.Y() += nSizeYPix;
+
+ if (pViewData)
+ {
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+ if (pViewSh)
+ {
+ // Is a draw object selected?
+
+ SdrView* pDrawView = pViewSh->GetSdrView();
+ if (pDrawView && pDrawView->AreObjectsMarked())
+ {
+ // #100442#; the conext menu should open in the middle of the selected objects
+ Rectangle aSelectRect(LogicToPixel(pDrawView->GetAllMarkedBoundRect()));
+ aMenuPos = aSelectRect.Center();
+ }
+ }
+ }
+ }
+
+ if (!bDone)
+ {
+ SfxDispatcher::ExecutePopup( 0, this, &aMenuPos );
+ }
+ }
+}
+
+void ScGridWindow::SelectForContextMenu( const Point& rPosPixel, SCsCOL nCellX, SCsROW nCellY )
+{
+ // #i18735# if the click was outside of the current selection,
+ // the cursor is moved or an object at the click position selected.
+ // (see SwEditWin::SelectMenuPosition in Writer)
+
+ ScTabView* pView = pViewData->GetView();
+ ScDrawView* pDrawView = pView->GetScDrawView();
+
+ // check cell edit mode
+
+ if ( pViewData->HasEditView(eWhich) )
+ {
+ ScModule* pScMod = SC_MOD();
+ SCCOL nEditStartCol = pViewData->GetEditViewCol(); //! change to GetEditStartCol after calcrtl is integrated
+ SCROW nEditStartRow = pViewData->GetEditViewRow();
+ SCCOL nEditEndCol = pViewData->GetEditEndCol();
+ SCROW nEditEndRow = pViewData->GetEditEndRow();
+
+ if ( nCellX >= (SCsCOL) nEditStartCol && nCellX <= (SCsCOL) nEditEndCol &&
+ nCellY >= (SCsROW) nEditStartRow && nCellY <= (SCsROW) nEditEndRow )
+ {
+ // handle selection within the EditView
+
+ EditView* pEditView = pViewData->GetEditView( eWhich ); // not NULL (HasEditView)
+ EditEngine* pEditEngine = pEditView->GetEditEngine();
+ Rectangle aOutputArea = pEditView->GetOutputArea();
+ Rectangle aVisArea = pEditView->GetVisArea();
+
+ Point aTextPos = PixelToLogic( rPosPixel );
+ if ( pEditEngine->IsVertical() ) // have to manually transform position
+ {
+ aTextPos -= aOutputArea.TopRight();
+ long nTemp = -aTextPos.X();
+ aTextPos.X() = aTextPos.Y();
+ aTextPos.Y() = nTemp;
+ }
+ else
+ aTextPos -= aOutputArea.TopLeft();
+ aTextPos += aVisArea.TopLeft(); // position in the edit document
+
+ EPosition aDocPosition = pEditEngine->FindDocPosition(aTextPos);
+ ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
+ ESelection aSelection = pEditView->GetSelection();
+ aSelection.Adjust(); // needed for IsLess/IsGreater
+ if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) )
+ {
+ // clicked outside the selected text - deselect and move text cursor
+ MouseEvent aEvent( rPosPixel );
+ pEditView->MouseButtonDown( aEvent );
+ pEditView->MouseButtonUp( aEvent );
+ pScMod->InputSelection( pEditView );
+ }
+
+ return; // clicked within the edit view - keep edit mode
+ }
+ else
+ {
+ // outside of the edit view - end edit mode, regardless of cell selection, then continue
+ pScMod->InputEnterHandler();
+ }
+ }
+
+ // check draw text edit mode
+
+ Point aLogicPos = PixelToLogic( rPosPixel ); // after cell edit mode is ended
+ if ( pDrawView && pDrawView->GetTextEditObject() && pDrawView->GetTextEditOutlinerView() )
+ {
+ OutlinerView* pOlView = pDrawView->GetTextEditOutlinerView();
+ Rectangle aOutputArea = pOlView->GetOutputArea();
+ if ( aOutputArea.IsInside( aLogicPos ) )
+ {
+ // handle selection within the OutlinerView
+
+ Outliner* pOutliner = pOlView->GetOutliner();
+ const EditEngine& rEditEngine = pOutliner->GetEditEngine();
+ Rectangle aVisArea = pOlView->GetVisArea();
+
+ Point aTextPos = aLogicPos;
+ if ( pOutliner->IsVertical() ) // have to manually transform position
+ {
+ aTextPos -= aOutputArea.TopRight();
+ long nTemp = -aTextPos.X();
+ aTextPos.X() = aTextPos.Y();
+ aTextPos.Y() = nTemp;
+ }
+ else
+ aTextPos -= aOutputArea.TopLeft();
+ aTextPos += aVisArea.TopLeft(); // position in the edit document
+
+ EPosition aDocPosition = rEditEngine.FindDocPosition(aTextPos);
+ ESelection aCompare(aDocPosition.nPara, aDocPosition.nIndex);
+ ESelection aSelection = pOlView->GetSelection();
+ aSelection.Adjust(); // needed for IsLess/IsGreater
+ if ( aCompare.IsLess(aSelection) || aCompare.IsGreater(aSelection) )
+ {
+ // clicked outside the selected text - deselect and move text cursor
+ // use DrawView to allow extra handling there (none currently)
+ MouseEvent aEvent( rPosPixel );
+ pDrawView->MouseButtonDown( aEvent, this );
+ pDrawView->MouseButtonUp( aEvent, this );
+ }
+
+ return; // clicked within the edit area - keep edit mode
+ }
+ else
+ {
+ // Outside of the edit area - end text edit mode, then continue.
+ // DrawDeselectAll also ends text edit mode and updates the shells.
+ // If the click was on the edited object, it will be selected again below.
+ pView->DrawDeselectAll();
+ }
+ }
+
+ // look for existing selection
+
+ BOOL bHitSelected = FALSE;
+ if ( pDrawView && pDrawView->IsMarkedObjHit( aLogicPos ) )
+ {
+ // clicked on selected object -> don't change anything
+ bHitSelected = TRUE;
+ }
+ else if ( pViewData->GetMarkData().IsCellMarked(nCellX, nCellY) )
+ {
+ // clicked on selected cell -> don't change anything
+ bHitSelected = TRUE;
+ }
+
+ // select drawing object or move cell cursor
+
+ if ( !bHitSelected )
+ {
+ BOOL bWasDraw = ( pDrawView && pDrawView->AreObjectsMarked() );
+ BOOL bHitDraw = FALSE;
+ if ( pDrawView )
+ {
+ pDrawView->UnmarkAllObj();
+ // Unlock the Internal Layer in order to activate the context menu.
+ // re-lock in ScDrawView::MarkListHasChanged()
+ lcl_UnLockComment( pDrawView, pDrawView->GetSdrPageView(), pDrawView->GetModel(), aLogicPos ,pViewData);
+ bHitDraw = pDrawView->MarkObj( aLogicPos );
+ // draw shell is activated in MarkListHasChanged
+ }
+ if ( !bHitDraw )
+ {
+ pView->Unmark();
+ pView->SetCursor(nCellX, nCellY);
+ if ( bWasDraw )
+ pViewData->GetViewShell()->SetDrawShell( FALSE ); // switch shells
+ }
+ }
+}
+
+static void ClearSingleSelection( ScViewData* pViewData )
+{
+ SCCOL nX;
+ SCROW nY;
+ ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard(
+ pViewData->GetActiveWin() );
+ if (!pTransObj)
+ return;
+
+ ScDocument* pClipDoc = pTransObj->GetDocument();
+ pClipDoc->GetClipArea( nX, nY, TRUE );
+ if (nX == 0 && nY == 0)
+ {
+ ScTabView* pView = pViewData->GetView();
+ pView->Unmark();
+ }
+}
+
+void __EXPORT ScGridWindow::KeyInput(const KeyEvent& rKEvt)
+{
+ // #96965# Cursor control for ref input dialog
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if( SC_MOD()->IsRefDialogOpen() )
+ {
+ if( !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
+ {
+ SC_MOD()->EndReference();
+ return;
+ }
+ else if( pViewData->GetViewShell()->MoveCursorKeyInput( rKEvt ) )
+ {
+ ScRange aRef(
+ pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(),
+ pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() );
+ SC_MOD()->SetReference( aRef, pViewData->GetDocument() );
+ return;
+ }
+ }
+ else if( rKeyCode.GetCode() == KEY_RETURN && pViewData->IsPasteMode() )
+ {
+ ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
+
+ ScCellShell::PasteFromClipboard( pViewData, pTabViewShell, FALSE );
+ ClearSingleSelection( pViewData );
+
+ uno::Reference<datatransfer::clipboard::XClipboard> xSystemClipboard =
+ TransferableHelper::GetSystemClipboard();
+ if (xSystemClipboard.is())
+ {
+ xSystemClipboard->setContents(
+ uno::Reference<datatransfer::XTransferable>(),
+ uno::Reference<datatransfer::clipboard::XClipboardOwner>());
+ }
+
+ // hide the border around the copy source
+ pViewData->SetPasteMode( SC_PASTE_NONE );
+ UpdateCopySourceOverlay();
+ return;
+ }
+ // wenn semi-Modeless-SfxChildWindow-Dialog oben, keine KeyInputs:
+ else if( !pViewData->IsAnyFillMode() )
+ {
+ if (rKeyCode.GetCode() == KEY_ESCAPE)
+ {
+ pViewData->SetPasteMode( SC_PASTE_NONE );
+ UpdateCopySourceOverlay();
+ }
+ // query for existing note marker before calling ViewShell's keyboard handling
+ // which may remove the marker
+ BOOL bHadKeyMarker = ( pNoteMarker && pNoteMarker->IsByKeyboard() );
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+
+ if (pViewData->GetDocShell()->GetProgress())
+ return;
+
+ if (DrawKeyInput(rKEvt))
+ return;
+
+ if (!pViewData->GetView()->IsDrawSelMode() && !DrawHasMarkedObj()) // keine Eingaben im Zeichenmodus
+ { //! DrawShell abfragen !!!
+ if (pViewSh->TabKeyInput(rKEvt))
+ return;
+ }
+ else
+ if (pViewSh->SfxViewShell::KeyInput(rKEvt)) // von SfxViewShell
+ return;
+
+ KeyCode aCode = rKEvt.GetKeyCode();
+ if ( aCode.GetCode() == KEY_ESCAPE && aCode.GetModifier() == 0 )
+ {
+ if ( bHadKeyMarker )
+ HideNoteMarker();
+ else
+ pViewSh->Escape();
+ return;
+ }
+ if ( aCode.GetCode() == KEY_F1 && aCode.GetModifier() == KEY_MOD1 )
+ {
+ // ctrl-F1 shows or hides the note or redlining info for the cursor position
+ // (hard-coded because F1 can't be configured)
+
+ if ( bHadKeyMarker )
+ HideNoteMarker(); // hide when previously visible
+ else
+ ShowNoteMarker( pViewData->GetCurX(), pViewData->GetCurY(), TRUE );
+ return;
+ }
+ if (aCode.GetCode() == KEY_BRACKETLEFT && aCode.GetModifier() == KEY_MOD1)
+ {
+ pViewSh->DetectiveMarkPred();
+ return;
+ }
+ if (aCode.GetCode() == KEY_BRACKETRIGHT && aCode.GetModifier() == KEY_MOD1)
+ {
+ pViewSh->DetectiveMarkSucc();
+ return;
+ }
+
+ }
+
+ Window::KeyInput(rKEvt);
+}
+
+void ScGridWindow::StopMarking()
+{
+ DrawEndAction(); // Markieren/Verschieben auf Drawing-Layer abbrechen
+
+ if (nButtonDown)
+ {
+ pViewData->GetMarkData().SetMarking(FALSE);
+ nMouseStatus = SC_GM_IGNORE;
+ }
+}
+
+void ScGridWindow::UpdateInputContext()
+{
+ BOOL bReadOnly = pViewData->GetDocShell()->IsReadOnly();
+ ULONG nOptions = bReadOnly ? 0 : ( INPUTCONTEXT_TEXT | INPUTCONTEXT_EXTTEXTINPUT );
+
+ // when font from InputContext is used,
+ // it must be taken from the cursor position's cell attributes
+
+ InputContext aContext;
+ aContext.SetOptions( nOptions );
+ SetInputContext( aContext );
+}
+
+//--------------------------------------------------------
+
+ // sensitiver Bereich (Pixel)
+#define SCROLL_SENSITIVE 20
+
+BOOL ScGridWindow::DropScroll( const Point& rMousePos )
+{
+/* doch auch auf nicht aktiven Views...
+ if ( !pViewData->IsActive() )
+ return FALSE;
+*/
+ SCsCOL nDx = 0;
+ SCsROW nDy = 0;
+ Size aSize = GetOutputSizePixel();
+
+ if (aSize.Width() > SCROLL_SENSITIVE * 3)
+ {
+ if ( rMousePos.X() < SCROLL_SENSITIVE && pViewData->GetPosX(WhichH(eWhich)) > 0 )
+ nDx = -1;
+ if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE
+ && pViewData->GetPosX(WhichH(eWhich)) < MAXCOL )
+ nDx = 1;
+ }
+ if (aSize.Height() > SCROLL_SENSITIVE * 3)
+ {
+ if ( rMousePos.Y() < SCROLL_SENSITIVE && pViewData->GetPosY(WhichV(eWhich)) > 0 )
+ nDy = -1;
+ if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE
+ && pViewData->GetPosY(WhichV(eWhich)) < MAXROW )
+ nDy = 1;
+ }
+
+ if ( nDx != 0 || nDy != 0 )
+ {
+// if (bDragRect)
+// pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+
+ if ( nDx != 0 )
+ pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
+ if ( nDy != 0 )
+ pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
+
+// if (bDragRect)
+// pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+ }
+
+ return FALSE;
+}
+
+BOOL lcl_TestScenarioRedliningDrop( ScDocument* pDoc, const ScRange& aDragRange)
+{
+ // Testet, ob bei eingeschalteten RedLining,
+ // bei einem Drop ein Scenario betroffen ist.
+
+ BOOL bReturn = FALSE;
+ SCTAB nTab = aDragRange.aStart.Tab();
+ SCTAB nTabCount = pDoc->GetTableCount();
+
+ if(pDoc->GetChangeTrack()!=NULL)
+ {
+ if( pDoc->IsScenario(nTab) && pDoc->HasScenarioRange(nTab, aDragRange))
+ {
+ bReturn = TRUE;
+ }
+ else
+ {
+ for(SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
+ {
+ if(pDoc->HasScenarioRange(i, aDragRange))
+ {
+ bReturn = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ return bReturn;
+}
+
+ScRange lcl_MakeDropRange( SCCOL nPosX, SCROW nPosY, SCTAB nTab, const ScRange& rSource )
+{
+ SCCOL nCol1 = nPosX;
+ SCCOL nCol2 = nCol1 + ( rSource.aEnd.Col() - rSource.aStart.Col() );
+ if ( nCol2 > MAXCOL )
+ {
+ nCol1 -= nCol2 - MAXCOL;
+ nCol2 = MAXCOL;
+ }
+ SCROW nRow1 = nPosY;
+ SCROW nRow2 = nRow1 + ( rSource.aEnd.Row() - rSource.aStart.Row() );
+ if ( nRow2 > MAXROW )
+ {
+ nRow1 -= nRow2 - MAXROW;
+ nRow2 = MAXROW;
+ }
+
+ return ScRange( nCol1, nRow1, nTab, nCol2, nRow2, nTab );
+}
+
+//--------------------------------------------------------
+
+extern BOOL bPasteIsDrop; // viewfun4 -> move to header
+extern BOOL bPasteIsMove; // viewfun7 -> move to header
+
+//--------------------------------------------------------
+
+sal_Int8 ScGridWindow::AcceptPrivateDrop( const AcceptDropEvent& rEvt )
+{
+ if ( rEvt.mbLeaving )
+ {
+ // if (bDragRect)
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ return rEvt.mnAction;
+ }
+
+ const ScDragData& rData = SC_MOD()->GetDragData();
+ if ( rData.pCellTransfer )
+ {
+ // Don't move source that would include filtered rows.
+ if ((rEvt.mnAction & DND_ACTION_MOVE) && rData.pCellTransfer->HasFilteredRows())
+ {
+ if (bDragRect)
+ {
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ }
+ return DND_ACTION_NONE;
+ }
+
+ Point aPos = rEvt.maPosPixel;
+
+ ScDocument* pSourceDoc = rData.pCellTransfer->GetSourceDocument();
+ ScDocument* pThisDoc = pViewData->GetDocument();
+ if (pSourceDoc == pThisDoc)
+ {
+ if ( pThisDoc->HasChartAtPoint(pViewData->GetTabNo(), PixelToLogic(aPos)) )
+ {
+ if (bDragRect) // Rechteck loeschen
+ {
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ }
+
+ //! highlight chart? (selection border?)
+
+ sal_Int8 nRet = rEvt.mnAction;
+//! if ( rEvt.GetAction() == DROP_LINK )
+//! bOk = rEvt.SetAction( DROP_COPY ); // can't link onto chart
+ return nRet;
+ }
+ }
+//! else
+//! if ( rEvt.GetAction() == DROP_MOVE )
+//! rEvt.SetAction( DROP_COPY ); // different doc: default=COPY
+
+
+ if ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) // whole sheet?
+ {
+ BOOL bOk = pThisDoc->IsDocEditable();
+ return bOk ? rEvt.mnAction : 0; // don't draw selection frame
+ }
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+
+ ScRange aSourceRange = rData.pCellTransfer->GetRange();
+ SCCOL nSourceStartX = aSourceRange.aStart.Col();
+ SCROW nSourceStartY = aSourceRange.aStart.Row();
+ SCCOL nSourceEndX = aSourceRange.aEnd.Col();
+ SCROW nSourceEndY = aSourceRange.aEnd.Row();
+ SCCOL nSizeX = nSourceEndX - nSourceStartX + 1;
+ SCROW nSizeY = nSourceEndY - nSourceStartY + 1;
+
+ if ( rEvt.mnAction != DND_ACTION_MOVE )
+ nSizeY = rData.pCellTransfer->GetNonFilteredRows(); // copy/link: no filtered rows
+
+ SCsCOL nNewDragX = nPosX - rData.pCellTransfer->GetDragHandleX();
+ if (nNewDragX<0) nNewDragX=0;
+ if (nNewDragX+(nSizeX-1) > MAXCOL)
+ nNewDragX = MAXCOL-(nSizeX-1);
+ SCsROW nNewDragY = nPosY - rData.pCellTransfer->GetDragHandleY();
+ if (nNewDragY<0) nNewDragY=0;
+ if (nNewDragY+(nSizeY-1) > MAXROW)
+ nNewDragY = MAXROW-(nSizeY-1);
+
+ // don't break scenario ranges, don't drop on filtered
+ SCTAB nTab = pViewData->GetTabNo();
+ ScRange aDropRange = lcl_MakeDropRange( nNewDragX, nNewDragY, nTab, aSourceRange );
+ if ( lcl_TestScenarioRedliningDrop( pThisDoc, aDropRange ) ||
+ lcl_TestScenarioRedliningDrop( pSourceDoc, aSourceRange ) ||
+ ScViewUtil::HasFiltered( aDropRange, pThisDoc) )
+ {
+ if (bDragRect)
+ {
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ }
+ return DND_ACTION_NONE;
+ }
+
+ InsCellCmd eDragInsertMode = INS_NONE;
+ Window::PointerState aState = GetPointerState();
+
+ // check for datapilot item sorting
+ ScDPObject* pDPObj = NULL;
+ if ( pThisDoc == pSourceDoc && ( pDPObj = pThisDoc->GetDPAtCursor( nNewDragX, nNewDragY, nTab ) ) != NULL )
+ {
+ // drop on DataPilot table: sort or nothing
+
+ bool bDPSort = false;
+ if ( pThisDoc->GetDPAtCursor( nSourceStartX, nSourceStartY, aSourceRange.aStart.Tab() ) == pDPObj )
+ {
+ sheet::DataPilotTableHeaderData aDestData;
+ pDPObj->GetHeaderPositionData( ScAddress(nNewDragX, nNewDragY, nTab), aDestData );
+ bool bValid = ( aDestData.Dimension >= 0 ); // dropping onto a field
+
+ // look through the source range
+ for (SCROW nRow = aSourceRange.aStart.Row(); bValid && nRow <= aSourceRange.aEnd.Row(); ++nRow )
+ for (SCCOL nCol = aSourceRange.aStart.Col(); bValid && nCol <= aSourceRange.aEnd.Col(); ++nCol )
+ {
+ sheet::DataPilotTableHeaderData aSourceData;
+ pDPObj->GetHeaderPositionData( ScAddress( nCol, nRow, aSourceRange.aStart.Tab() ), aSourceData );
+ if ( aSourceData.Dimension != aDestData.Dimension || !aSourceData.MemberName.getLength() )
+ bValid = false; // empty (subtotal) or different field
+ }
+
+ if ( bValid )
+ {
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName( aDestData.Dimension, bIsDataLayout );
+ const ScDPSaveDimension* pDim = pDPObj->GetSaveData()->GetExistingDimensionByName( aDimName );
+ if ( pDim )
+ {
+ ScRange aOutRange = pDPObj->GetOutRange();
+
+ USHORT nOrient = pDim->GetOrientation();
+ if ( nOrient == sheet::DataPilotFieldOrientation_COLUMN )
+ {
+ eDragInsertMode = INS_CELLSRIGHT;
+ nSizeY = aOutRange.aEnd.Row() - nNewDragY + 1;
+ bDPSort = true;
+ }
+ else if ( nOrient == sheet::DataPilotFieldOrientation_ROW )
+ {
+ eDragInsertMode = INS_CELLSDOWN;
+ nSizeX = aOutRange.aEnd.Col() - nNewDragX + 1;
+ bDPSort = true;
+ }
+ }
+ }
+ }
+
+ if ( !bDPSort )
+ {
+ // no valid sorting in a DataPilot table -> disallow
+ if ( bDragRect )
+ {
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ }
+ return DND_ACTION_NONE;
+ }
+ }
+ else if ( aState.mnState & KEY_MOD2 )
+ {
+ if ( pThisDoc == pSourceDoc && nTab == aSourceRange.aStart.Tab() )
+ {
+ long nDeltaX = labs( static_cast< long >( nNewDragX - nSourceStartX ) );
+ long nDeltaY = labs( static_cast< long >( nNewDragY - nSourceStartY ) );
+ if ( nDeltaX <= nDeltaY )
+ {
+ eDragInsertMode = INS_CELLSDOWN;
+ }
+ else
+ {
+ eDragInsertMode = INS_CELLSRIGHT;
+ }
+
+ if ( ( eDragInsertMode == INS_CELLSDOWN && nNewDragY <= nSourceEndY &&
+ ( nNewDragX + nSizeX - 1 ) >= nSourceStartX && nNewDragX <= nSourceEndX &&
+ ( nNewDragX != nSourceStartX || nNewDragY >= nSourceStartY ) ) ||
+ ( eDragInsertMode == INS_CELLSRIGHT && nNewDragX <= nSourceEndX &&
+ ( nNewDragY + nSizeY - 1 ) >= nSourceStartY && nNewDragY <= nSourceEndY &&
+ ( nNewDragY != nSourceStartY || nNewDragX >= nSourceStartX ) ) )
+ {
+ if ( bDragRect )
+ {
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+ }
+ return DND_ACTION_NONE;
+ }
+ }
+ else
+ {
+ if ( static_cast< long >( nSizeX ) >= static_cast< long >( nSizeY ) )
+ {
+ eDragInsertMode = INS_CELLSDOWN;
+
+ }
+ else
+ {
+ eDragInsertMode = INS_CELLSRIGHT;
+ }
+ }
+ }
+
+ if ( nNewDragX != (SCsCOL) nDragStartX || nNewDragY != (SCsROW) nDragStartY ||
+ nDragStartX+nSizeX-1 != nDragEndX || nDragStartY+nSizeY-1 != nDragEndY ||
+ !bDragRect || eDragInsertMode != meDragInsertMode )
+ {
+ // if (bDragRect)
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+
+ nDragStartX = nNewDragX;
+ nDragStartY = nNewDragY;
+ nDragEndX = nDragStartX+nSizeX-1;
+ nDragEndY = nDragStartY+nSizeY-1;
+ bDragRect = TRUE;
+ meDragInsertMode = eDragInsertMode;
+
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+
+ UpdateDragRectOverlay();
+ }
+ }
+
+ return rEvt.mnAction;
+}
+
+sal_Int8 ScGridWindow::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ const ScDragData& rData = SC_MOD()->GetDragData();
+ if ( rEvt.mbLeaving )
+ {
+ DrawMarkDropObj( NULL );
+ if ( rData.pCellTransfer )
+ return AcceptPrivateDrop( rEvt ); // hide drop marker for internal D&D
+ else
+ return rEvt.mnAction;
+ }
+
+ if ( pViewData->GetDocShell()->IsReadOnly() )
+ return DND_ACTION_NONE;
+
+
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if (rData.pCellTransfer)
+ {
+ ScRange aSource = rData.pCellTransfer->GetRange();
+ if ( aSource.aStart.Col() != 0 || aSource.aEnd.Col() != MAXCOL ||
+ aSource.aStart.Row() != 0 || aSource.aEnd.Row() != MAXROW )
+ DropScroll( rEvt.maPosPixel );
+
+ nRet = AcceptPrivateDrop( rEvt );
+ }
+ else
+ {
+ if ( rData.aLinkDoc.Len() )
+ {
+ String aThisName;
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if (pDocSh && pDocSh->HasName())
+ aThisName = pDocSh->GetMedium()->GetName();
+
+ if ( rData.aLinkDoc != aThisName )
+ nRet = rEvt.mnAction;
+ }
+ else if (rData.aJumpTarget.Len())
+ {
+ // internal bookmarks (from Navigator)
+ // local jumps from an unnamed document are possible only within a document
+
+ if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() )
+ nRet = rEvt.mnAction;
+ }
+ else
+ {
+ sal_Int8 nMyAction = rEvt.mnAction;
+
+ if ( !rData.pDrawTransfer ||
+ !IsMyModel(rData.pDrawTransfer->GetDragSourceView()) ) // drawing within the document
+ if ( rEvt.mbDefault && nMyAction == DND_ACTION_MOVE )
+ nMyAction = DND_ACTION_COPY;
+
+ ScDocument* pThisDoc = pViewData->GetDocument();
+ SdrObject* pHitObj = pThisDoc->GetObjectAtPoint(
+ pViewData->GetTabNo(), PixelToLogic(rEvt.maPosPixel) );
+ if ( pHitObj && nMyAction == DND_ACTION_LINK && !rData.pDrawTransfer )
+ {
+ if ( IsDropFormatSupported(SOT_FORMATSTR_ID_SVXB)
+ || IsDropFormatSupported(SOT_FORMAT_GDIMETAFILE)
+ || IsDropFormatSupported(SOT_FORMAT_BITMAP) )
+ {
+ // graphic dragged onto drawing object
+ DrawMarkDropObj( pHitObj );
+ nRet = nMyAction;
+ }
+ }
+ if (!nRet)
+ DrawMarkDropObj( NULL );
+
+ if (!nRet)
+ {
+ switch ( nMyAction )
+ {
+ case DND_ACTION_COPY:
+ case DND_ACTION_MOVE:
+ case DND_ACTION_COPYMOVE:
+ {
+ BOOL bMove = ( nMyAction == DND_ACTION_MOVE );
+ if ( IsDropFormatSupported( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
+ IsDropFormatSupported( SOT_FORMAT_STRING ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SYLK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_HTML ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_HTML_SIMPLE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_DIF ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB ) ||
+ IsDropFormatSupported( SOT_FORMAT_RTF ) ||
+ IsDropFormatSupported( SOT_FORMAT_GDIMETAFILE ) ||
+ IsDropFormatSupported( SOT_FORMAT_BITMAP ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) ||
+ ( !bMove && (
+ IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) ||
+ IsDropFormatSupported( SOT_FORMAT_FILE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) ) ) )
+ {
+ nRet = nMyAction;
+ }
+ }
+ break;
+ case DND_ACTION_LINK:
+ if ( IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) ||
+ IsDropFormatSupported( SOT_FORMAT_FILE_LIST ) ||
+ IsDropFormatSupported( SOT_FORMAT_FILE ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) ||
+ IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) )
+ {
+ nRet = nMyAction;
+ }
+ break;
+ }
+
+ if ( nRet )
+ {
+ // Simple check for protection: It's not known here if the drop will result
+ // in cells or drawing objects (some formats can be both) and how many cells
+ // the result will be. But if IsFormatEditable for the drop cell position
+ // is FALSE (ignores matrix formulas), nothing can be pasted, so the drop
+ // can already be rejected here.
+
+ Point aPos = rEvt.maPosPixel;
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ ScEditableTester aTester( pDoc, nTab, nPosX,nPosY, nPosX,nPosY );
+ if ( !aTester.IsFormatEditable() )
+ nRet = DND_ACTION_NONE; // forbidden
+ }
+ }
+ }
+
+ // scroll only for accepted formats
+ if (nRet)
+ DropScroll( rEvt.maPosPixel );
+ }
+
+ return nRet;
+}
+
+ULONG lcl_GetDropFormatId( const uno::Reference<datatransfer::XTransferable>& xTransfer, bool bPreferText = false )
+{
+ TransferableDataHelper aDataHelper( xTransfer );
+
+ if ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) )
+ {
+ // use bookmark formats if no sba is present
+
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) )
+ return SOT_FORMATSTR_ID_SOLK;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) )
+ return SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) )
+ return SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) )
+ return SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR;
+ }
+
+ ULONG nFormatId = 0;
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
+ nFormatId = SOT_FORMATSTR_ID_DRAWING;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
+ nFormatId = SOT_FORMATSTR_ID_SVXB;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ) )
+ {
+ // If it's a Writer object, insert RTF instead of OLE
+
+ BOOL bDoRtf = FALSE;
+ SotStorageStreamRef xStm;
+ TransferableObjectDescriptor aObjDesc;
+ if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
+ aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) )
+ {
+ SotStorageRef xStore( new SotStorage( *xStm ) );
+ bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) ||
+ aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) )
+ && aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+ if ( bDoRtf )
+ nFormatId = FORMAT_RTF;
+ else
+ nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE;
+ }
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) )
+ nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_DATAEXCHANGE ) )
+ nFormatId = SOT_FORMATSTR_ID_SBA_DATAEXCHANGE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) )
+ nFormatId = SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_BIFF_8 ) )
+ nFormatId = SOT_FORMATSTR_ID_BIFF_8;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_BIFF_5 ) )
+ nFormatId = SOT_FORMATSTR_ID_BIFF_5;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) )
+ nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) )
+ nFormatId = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) )
+ nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ nFormatId = SOT_FORMAT_RTF;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML ) )
+ nFormatId = SOT_FORMATSTR_ID_HTML;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML_SIMPLE ) )
+ nFormatId = SOT_FORMATSTR_ID_HTML_SIMPLE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SYLK ) )
+ nFormatId = SOT_FORMATSTR_ID_SYLK;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK ) )
+ nFormatId = SOT_FORMATSTR_ID_LINK;
+ else if ( bPreferText && aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) // #i86734# the behaviour introduced in #i62773# is wrong when pasting
+ nFormatId = SOT_FORMAT_STRING;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) )
+ nFormatId = SOT_FORMAT_FILE_LIST;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE ) ) // #i62773# FILE_LIST/FILE before STRING (Unix file managers)
+ nFormatId = SOT_FORMAT_FILE;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
+ nFormatId = SOT_FORMAT_STRING;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) )
+ nFormatId = SOT_FORMAT_GDIMETAFILE;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) )
+ nFormatId = SOT_FORMAT_BITMAP;
+
+ return nFormatId;
+}
+
+ULONG lcl_GetDropLinkId( const uno::Reference<datatransfer::XTransferable>& xTransfer )
+{
+ TransferableDataHelper aDataHelper( xTransfer );
+
+ ULONG nFormatId = 0;
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ) )
+ nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ) )
+ nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK ) )
+ nFormatId = SOT_FORMATSTR_ID_LINK;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE_LIST ) )
+ nFormatId = SOT_FORMAT_FILE_LIST;
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_FILE ) )
+ nFormatId = SOT_FORMAT_FILE;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) )
+ nFormatId = SOT_FORMATSTR_ID_SOLK;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) )
+ nFormatId = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) )
+ nFormatId = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK;
+ else if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) )
+ nFormatId = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR;
+
+ return nFormatId;
+}
+
+
+sal_Int8 ScGridWindow::ExecutePrivateDrop( const ExecuteDropEvent& rEvt )
+{
+ // hide drop marker
+ // if (bDragRect)
+ // pViewData->GetView()->DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, eWhich );
+ bDragRect = FALSE;
+ UpdateDragRectOverlay();
+
+ ScModule* pScMod = SC_MOD();
+ const ScDragData& rData = pScMod->GetDragData();
+
+ return DropTransferObj( rData.pCellTransfer, nDragStartX, nDragStartY,
+ PixelToLogic(rEvt.maPosPixel), rEvt.mnAction );
+}
+
+sal_Int8 ScGridWindow::DropTransferObj( ScTransferObj* pTransObj, SCCOL nDestPosX, SCROW nDestPosY,
+ const Point& rLogicPos, sal_Int8 nDndAction )
+{
+ if ( !pTransObj )
+ return 0;
+
+ ScDocument* pSourceDoc = pTransObj->GetSourceDocument();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pThisDoc = pViewData->GetDocument();
+ ScViewFunc* pView = pViewData->GetView();
+ SCTAB nThisTab = pViewData->GetTabNo();
+ USHORT nFlags = pTransObj->GetDragSourceFlags();
+
+ BOOL bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0;
+ BOOL bIsMove = ( nDndAction == DND_ACTION_MOVE && !bIsNavi );
+
+ // workaround for wrong nDndAction on Windows when pressing solely
+ // the Alt key during drag and drop;
+ // can be removed after #i79215# has been fixed
+ if ( meDragInsertMode != INS_NONE )
+ {
+ bIsMove = ( nDndAction & DND_ACTION_MOVE && !bIsNavi );
+ }
+
+ BOOL bIsLink = ( nDndAction == DND_ACTION_LINK );
+
+ ScRange aSource = pTransObj->GetRange();
+
+ // only use visible tab from source range - when dragging within one table,
+ // all selected tables at the time of dropping are used (handled in MoveBlockTo)
+ SCTAB nSourceTab = pTransObj->GetVisibleTab();
+ aSource.aStart.SetTab( nSourceTab );
+ aSource.aEnd.SetTab( nSourceTab );
+
+ SCCOL nSizeX = aSource.aEnd.Col() - aSource.aStart.Col() + 1;
+ SCROW nSizeY = (bIsMove ? (aSource.aEnd.Row() - aSource.aStart.Row() + 1) :
+ pTransObj->GetNonFilteredRows()); // copy/link: no filtered rows
+ ScRange aDest( nDestPosX, nDestPosY, nThisTab,
+ nDestPosX + nSizeX - 1, nDestPosY + nSizeY - 1, nThisTab );
+
+
+ /* NOTE: AcceptPrivateDrop() already checked for filtered conditions during
+ * dragging and adapted drawing of the selection frame. We check here
+ * (again) because this may actually also be called from PasteSelection(),
+ * we would have to duplicate determination of flags and destination range
+ * and would lose the context of the "filtered destination is OK" cases
+ * below, which is already awkward enough as is. */
+
+ // Don't move filtered source.
+ bool bFiltered = (bIsMove && pTransObj->HasFilteredRows());
+ if (!bFiltered)
+ {
+ if (pSourceDoc != pThisDoc && ((nFlags & SC_DROP_TABLE) ||
+ (!bIsLink && meDragInsertMode == INS_NONE)))
+ {
+ // Nothing. Either entire sheet to be dropped, or the one case
+ // where PasteFromClip() is to be called that handles a filtered
+ // destination itself. Drag-copy from another document without
+ // inserting cells.
+ }
+ else
+ // Don't copy or move to filtered destination.
+ bFiltered = ScViewUtil::HasFiltered( aDest, pThisDoc);
+ }
+
+ BOOL bDone = FALSE;
+
+ if (!bFiltered && pSourceDoc == pThisDoc)
+ {
+ if ( nFlags & SC_DROP_TABLE ) // whole sheet?
+ {
+ if ( pThisDoc->IsDocEditable() )
+ {
+ SCTAB nSrcTab = aSource.aStart.Tab();
+ pViewData->GetDocShell()->MoveTable( nSrcTab, nThisTab, !bIsMove, TRUE ); // with Undo
+ pView->SetTabNo( nThisTab, TRUE );
+ bDone = TRUE;
+ }
+ }
+ else // move/copy block
+ {
+ String aChartName;
+ if (pThisDoc->HasChartAtPoint( nThisTab, rLogicPos, &aChartName ))
+ {
+ String aRangeName;
+ aSource.Format( aRangeName, SCR_ABS_3D, pThisDoc );
+ SfxStringItem aNameItem( SID_CHART_NAME, aChartName );
+ SfxStringItem aRangeItem( SID_CHART_SOURCE, aRangeName );
+ USHORT nId = bIsMove ? SID_CHART_SOURCE : SID_CHART_ADDSOURCE;
+ pViewData->GetDispatcher().Execute( nId, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aRangeItem, &aNameItem, (void*) NULL );
+ bDone = TRUE;
+ }
+ else if ( pThisDoc->GetDPAtCursor( nDestPosX, nDestPosY, nThisTab ) )
+ {
+ // drop on DataPilot table: try to sort, fail if that isn't possible
+
+ ScAddress aDestPos( nDestPosX, nDestPosY, nThisTab );
+ if ( aDestPos != aSource.aStart )
+ bDone = pViewData->GetView()->DataPilotMove( aSource, aDestPos );
+ else
+ bDone = TRUE; // same position: nothing
+ }
+ else if ( nDestPosX != aSource.aStart.Col() || nDestPosY != aSource.aStart.Row() ||
+ nSourceTab != nThisTab )
+ {
+ String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ bDone = TRUE;
+ if ( meDragInsertMode != INS_NONE )
+ {
+ // call with bApi = TRUE to avoid error messages in drop handler
+ bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, TRUE /*bRecord*/, TRUE /*bApi*/, TRUE /*bPartOfPaste*/ );
+ if ( bDone )
+ {
+ if ( nThisTab == nSourceTab )
+ {
+ if ( meDragInsertMode == INS_CELLSDOWN &&
+ nDestPosX == aSource.aStart.Col() && nDestPosY < aSource.aStart.Row() )
+ {
+ bDone = aSource.Move( 0, nSizeY, 0, pSourceDoc );
+ }
+ else if ( meDragInsertMode == INS_CELLSRIGHT &&
+ nDestPosY == aSource.aStart.Row() && nDestPosX < aSource.aStart.Col() )
+ {
+ bDone = aSource.Move( nSizeX, 0, 0, pSourceDoc );
+ }
+ }
+ pDocSh->UpdateOle( pViewData );
+ pView->CellContentChanged();
+ }
+ }
+
+ if ( bDone )
+ {
+ if ( bIsLink )
+ {
+ // call with bApi = TRUE to avoid error messages in drop handler
+ bDone = pView->LinkBlock( aSource, aDest.aStart, TRUE /*bApi*/ );
+ }
+ else
+ {
+ // call with bApi = TRUE to avoid error messages in drop handler
+ bDone = pView->MoveBlockTo( aSource, aDest.aStart, bIsMove, TRUE /*bRecord*/, TRUE /*bPaint*/, TRUE /*bApi*/ );
+ }
+ }
+
+ if ( bDone && meDragInsertMode != INS_NONE && bIsMove && nThisTab == nSourceTab )
+ {
+ DelCellCmd eCmd = DEL_NONE;
+ if ( meDragInsertMode == INS_CELLSDOWN )
+ {
+ eCmd = DEL_CELLSUP;
+ }
+ else if ( meDragInsertMode == INS_CELLSRIGHT )
+ {
+ eCmd = DEL_CELLSLEFT;
+ }
+
+ if ( ( eCmd == DEL_CELLSUP && nDestPosX == aSource.aStart.Col() ) ||
+ ( eCmd == DEL_CELLSLEFT && nDestPosY == aSource.aStart.Row() ) )
+ {
+ // call with bApi = TRUE to avoid error messages in drop handler
+ bDone = pDocSh->GetDocFunc().DeleteCells( aSource, NULL, eCmd, TRUE /*bRecord*/, TRUE /*bApi*/ );
+ if ( bDone )
+ {
+ if ( eCmd == DEL_CELLSUP && nDestPosY > aSource.aEnd.Row() )
+ {
+ bDone = aDest.Move( 0, -nSizeY, 0, pThisDoc );
+ }
+ else if ( eCmd == DEL_CELLSLEFT && nDestPosX > aSource.aEnd.Col() )
+ {
+ bDone = aDest.Move( -nSizeX, 0, 0, pThisDoc );
+ }
+ pDocSh->UpdateOle( pViewData );
+ pView->CellContentChanged();
+ }
+ }
+ }
+
+ if ( bDone )
+ {
+ pView->MarkRange( aDest, FALSE, FALSE );
+
+ SCCOL nDCol = pViewData->GetCurX() - aSource.aStart.Col();
+ SCROW nDRow = pViewData->GetCurY() - aSource.aStart.Row();
+ pView->SetCursor( aDest.aStart.Col() + nDCol, aDest.aStart.Row() + nDRow );
+ }
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+
+ if (!bDone)
+ Sound::Beep(); // instead of error message in drop handler
+ }
+ else
+ bDone = TRUE; // nothing to do
+ }
+
+ if (bDone)
+ pTransObj->SetDragWasInternal(); // don't delete source in DragFinished
+ }
+ else if ( !bFiltered && pSourceDoc ) // between documents
+ {
+ if ( nFlags & SC_DROP_TABLE ) // copy/link sheets between documents
+ {
+ if ( pThisDoc->IsDocEditable() )
+ {
+ ScDocShell* pSrcShell = pTransObj->GetSourceDocShell();
+
+ SCTAB nTabs[MAXTABCOUNT];
+
+ ScMarkData aMark = pTransObj->GetSourceMarkData();
+ SCTAB nTabCount = pSourceDoc->GetTableCount();
+ SCTAB nTabSelCount = 0;
+
+ for(SCTAB i=0; i<nTabCount; i++)
+ {
+ if(aMark.GetTableSelect(i))
+ {
+ nTabs[nTabSelCount++]=i;
+ for(SCTAB j=i+1;j<nTabCount;j++)
+ {
+ if((!pSourceDoc->IsVisible(j))&&(pSourceDoc->IsScenario(j)))
+ {
+ nTabs[nTabSelCount++]=j;
+ i=j;
+ }
+ else break;
+ }
+ }
+ }
+
+ pView->ImportTables( pSrcShell,nTabSelCount, nTabs, bIsLink, nThisTab );
+ bDone = TRUE;
+ }
+ }
+ else if ( bIsLink )
+ {
+ // as in PasteDDE
+ // (external references might be used instead?)
+
+ SfxObjectShell* pSourceSh = pSourceDoc->GetDocumentShell();
+ DBG_ASSERT(pSourceSh, "drag document has no shell");
+ if (pSourceSh)
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_COPY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ bDone = TRUE;
+ if ( meDragInsertMode != INS_NONE )
+ {
+ // call with bApi = TRUE to avoid error messages in drop handler
+ bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, TRUE /*bRecord*/, TRUE /*bApi*/, TRUE /*bPartOfPaste*/ );
+ if ( bDone )
+ {
+ pDocSh->UpdateOle( pViewData );
+ pView->CellContentChanged();
+ }
+ }
+
+ if ( bDone )
+ {
+ String aApp = Application::GetAppName();
+ String aTopic = pSourceSh->GetTitle( SFX_TITLE_FULLNAME );
+ String aItem;
+ aSource.Format( aItem, SCA_VALID | SCA_TAB_3D, pSourceDoc );
+
+ // TODO: we could define ocQuote for "
+ const String aQuote( '"' );
+ const String& sSep = ScCompiler::GetNativeSymbol( ocSep);
+ String aFormula( '=' );
+ aFormula += ScCompiler::GetNativeSymbol( ocDde);
+ aFormula += ScCompiler::GetNativeSymbol( ocOpen);
+ aFormula += aQuote;
+ aFormula += aApp;
+ aFormula += aQuote;
+ aFormula += sSep;
+ aFormula += aQuote;
+ aFormula += aTopic;
+ aFormula += aQuote;
+ aFormula += sSep;
+ aFormula += aQuote;
+ aFormula += aItem;
+ aFormula += aQuote;
+ aFormula += ScCompiler::GetNativeSymbol( ocClose);
+
+ pView->DoneBlockMode();
+ pView->InitBlockMode( nDestPosX, nDestPosY, nThisTab );
+ pView->MarkCursor( nDestPosX + nSizeX - 1,
+ nDestPosY + nSizeY - 1, nThisTab );
+
+ pView->EnterMatrix( aFormula );
+
+ pView->MarkRange( aDest, FALSE, FALSE );
+ pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
+ }
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+ }
+ else
+ {
+ //! HasSelectedBlockMatrixFragment without selected sheet?
+ //! or don't start dragging on a part of a matrix
+
+ String aUndo = ScGlobal::GetRscString( bIsMove ? STR_UNDO_MOVE : STR_UNDO_COPY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+
+ bDone = TRUE;
+ if ( meDragInsertMode != INS_NONE )
+ {
+ // call with bApi = TRUE to avoid error messages in drop handler
+ bDone = pDocSh->GetDocFunc().InsertCells( aDest, NULL, meDragInsertMode, TRUE /*bRecord*/, TRUE /*bApi*/, TRUE /*bPartOfPaste*/ );
+ if ( bDone )
+ {
+ pDocSh->UpdateOle( pViewData );
+ pView->CellContentChanged();
+ }
+ }
+
+ if ( bDone )
+ {
+ pView->Unmark(); // before SetCursor, so CheckSelectionTransfer isn't called with a selection
+ pView->SetCursor( nDestPosX, nDestPosY );
+ bDone = pView->PasteFromClip( IDF_ALL, pTransObj->GetDocument() ); // clip-doc
+ if ( bDone )
+ {
+ pView->MarkRange( aDest, FALSE, FALSE );
+ pView->SetCursor( aDest.aStart.Col(), aDest.aStart.Row() );
+ }
+ }
+
+ pDocSh->GetUndoManager()->LeaveListAction();
+
+ // no longer call ResetMark here - the inserted block has been selected
+ // and may have been copied to primary selection
+ }
+ }
+
+ sal_Int8 nRet = bDone ? nDndAction : DND_ACTION_NONE;
+ return nRet;
+}
+
+sal_Int8 ScGridWindow::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ DrawMarkDropObj( NULL ); // drawing layer
+
+ ScModule* pScMod = SC_MOD();
+ const ScDragData& rData = pScMod->GetDragData();
+ if (rData.pCellTransfer)
+ return ExecutePrivateDrop( rEvt );
+
+ Point aPos = rEvt.maPosPixel;
+
+ if ( rData.aLinkDoc.Len() )
+ {
+ // try to insert a link
+
+ BOOL bOk = TRUE;
+ String aThisName;
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ if (pDocSh && pDocSh->HasName())
+ aThisName = pDocSh->GetMedium()->GetName();
+
+ if ( rData.aLinkDoc == aThisName ) // error - no link within a document
+ bOk = FALSE;
+ else
+ {
+ ScViewFunc* pView = pViewData->GetView();
+ if ( rData.aLinkTable.Len() )
+ pView->InsertTableLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING,
+ rData.aLinkTable );
+ else if ( rData.aLinkArea.Len() )
+ {
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+ pView->MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, FALSE, FALSE );
+
+ pView->InsertAreaLink( rData.aLinkDoc, EMPTY_STRING, EMPTY_STRING,
+ rData.aLinkArea, 0 );
+ }
+ else
+ {
+ DBG_ERROR("drop with link: no sheet nor area");
+ bOk = FALSE;
+ }
+ }
+
+ return bOk ? rEvt.mnAction : DND_ACTION_NONE; // don't try anything else
+ }
+
+ Point aLogicPos = PixelToLogic(aPos);
+
+ if (rData.pDrawTransfer)
+ {
+ USHORT nFlags = rData.pDrawTransfer->GetDragSourceFlags();
+
+ BOOL bIsNavi = ( nFlags & SC_DROP_NAVIGATOR ) != 0;
+ BOOL bIsMove = ( rEvt.mnAction == DND_ACTION_MOVE && !bIsNavi );
+
+ bPasteIsMove = bIsMove;
+
+ pViewData->GetView()->PasteDraw( aLogicPos, rData.pDrawTransfer->GetModel() );
+
+ if (bPasteIsMove)
+ rData.pDrawTransfer->SetDragWasInternal();
+ bPasteIsMove = FALSE;
+
+ return rEvt.mnAction;
+ }
+
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+
+ if (rData.aJumpTarget.Len())
+ {
+ // internal bookmark (from Navigator)
+ // bookmark clipboard formats are in PasteScDataObject
+
+ if ( !rData.pJumpLocalDoc || rData.pJumpLocalDoc == pViewData->GetDocument() )
+ {
+ pViewData->GetViewShell()->InsertBookmark( rData.aJumpText, rData.aJumpTarget,
+ nPosX, nPosY );
+ return rEvt.mnAction;
+ }
+ }
+
+ BOOL bIsLink = ( rEvt.mnAction == DND_ACTION_LINK );
+
+ ScDocument* pThisDoc = pViewData->GetDocument();
+ SdrObject* pHitObj = pThisDoc->GetObjectAtPoint( pViewData->GetTabNo(), PixelToLogic(aPos) );
+ if ( pHitObj && bIsLink )
+ {
+ // dropped on drawing object
+ // PasteOnDrawObject checks for valid formats
+ if ( pViewData->GetView()->PasteOnDrawObject( rEvt.maDropEvent.Transferable, pHitObj, TRUE ) )
+ return rEvt.mnAction;
+ }
+
+ BOOL bDone = FALSE;
+
+ ULONG nFormatId = bIsLink ?
+ lcl_GetDropLinkId( rEvt.maDropEvent.Transferable ) :
+ lcl_GetDropFormatId( rEvt.maDropEvent.Transferable );
+ if ( nFormatId )
+ {
+ pScMod->SetInExecuteDrop( TRUE ); // #i28468# prevent error messages from PasteDataFormat
+ bPasteIsDrop = TRUE;
+ bDone = pViewData->GetView()->PasteDataFormat(
+ nFormatId, rEvt.maDropEvent.Transferable, nPosX, nPosY, &aLogicPos, bIsLink );
+ bPasteIsDrop = FALSE;
+ pScMod->SetInExecuteDrop( FALSE );
+ }
+
+ sal_Int8 nRet = bDone ? rEvt.mnAction : DND_ACTION_NONE;
+ return nRet;
+}
+
+//--------------------------------------------------------
+
+void ScGridWindow::PasteSelection( const Point& rPosPixel )
+{
+ Point aLogicPos = PixelToLogic( rPosPixel );
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( rPosPixel.X(), rPosPixel.Y(), eWhich, nPosX, nPosY );
+
+ // If the mouse down was inside a visible note window, ignore it and
+ // leave it up to the ScPostIt to handle it
+ SdrView* pDrawView = pViewData->GetViewShell()->GetSdrView();
+ if (pDrawView)
+ {
+ ULONG nCount = pDrawView->GetMarkedObjectCount();
+ for (ULONG i = 0; i < nCount; ++i)
+ {
+ SdrObject* pObj = pDrawView->GetMarkedObjectByIndex(i);
+ if (pObj && pObj->GetLogicRect().IsInside(aLogicPos))
+ {
+ // Inside an active drawing object. Bail out.
+ return;
+ }
+ }
+ }
+
+ ScSelectionTransferObj* pOwnSelection = SC_MOD()->GetSelectionTransfer();
+ if ( pOwnSelection )
+ {
+ // within Calc
+
+ ScTransferObj* pCellTransfer = pOwnSelection->GetCellData();
+ if ( pCellTransfer )
+ {
+ // keep a reference to the data in case the selection is changed during paste
+ uno::Reference<datatransfer::XTransferable> xRef( pCellTransfer );
+ DropTransferObj( pCellTransfer, nPosX, nPosY, aLogicPos, DND_ACTION_COPY );
+ }
+ else
+ {
+ ScDrawTransferObj* pDrawTransfer = pOwnSelection->GetDrawData();
+ if ( pDrawTransfer )
+ {
+ // keep a reference to the data in case the selection is changed during paste
+ uno::Reference<datatransfer::XTransferable> xRef( pDrawTransfer );
+
+ // #96821# bSameDocClipboard argument for PasteDraw is needed
+ // because only DragData is checked directly inside PasteDraw
+ pViewData->GetView()->PasteDraw( aLogicPos, pDrawTransfer->GetModel(), FALSE,
+ pDrawTransfer->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() );
+ }
+ }
+ }
+ else
+ {
+ // get selection from system
+
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( this ) );
+ uno::Reference<datatransfer::XTransferable> xTransferable = aDataHelper.GetTransferable();
+ if ( xTransferable.is() )
+ {
+ ULONG nFormatId = lcl_GetDropFormatId( xTransferable, true );
+ if ( nFormatId )
+ {
+ bPasteIsDrop = TRUE;
+ pViewData->GetView()->PasteDataFormat( nFormatId, xTransferable, nPosX, nPosY, &aLogicPos );
+ bPasteIsDrop = FALSE;
+ }
+ }
+ }
+}
+
+//--------------------------------------------------------
+
+void ScGridWindow::UpdateEditViewPos()
+{
+ if (pViewData->HasEditView(eWhich))
+ {
+ EditView* pView;
+ SCCOL nCol;
+ SCROW nRow;
+ pViewData->GetEditView( eWhich, pView, nCol, nRow );
+ SCCOL nEndCol = pViewData->GetEditEndCol();
+ SCROW nEndRow = pViewData->GetEditEndRow();
+
+ // hide EditView?
+
+ BOOL bHide = ( nEndCol<pViewData->GetPosX(eHWhich) || nEndRow<pViewData->GetPosY(eVWhich) );
+ if ( SC_MOD()->IsFormulaMode() )
+ if ( pViewData->GetTabNo() != pViewData->GetRefTabNo() )
+ bHide = TRUE;
+
+ if (bHide)
+ {
+ Rectangle aRect = pView->GetOutputArea();
+ long nHeight = aRect.Bottom() - aRect.Top();
+ aRect.Top() = PixelToLogic(GetOutputSizePixel(), pViewData->GetLogicMode()).
+ Height() * 2;
+ aRect.Bottom() = aRect.Top() + nHeight;
+ pView->SetOutputArea( aRect );
+ pView->HideCursor();
+ }
+ else
+ {
+ // bForceToTop = TRUE for editing
+ Rectangle aPixRect = pViewData->GetEditArea( eWhich, nCol, nRow, this, NULL, TRUE );
+ Point aScrPos = PixelToLogic( aPixRect.TopLeft(), pViewData->GetLogicMode() );
+
+ Rectangle aRect = pView->GetOutputArea();
+ aRect.SetPos( aScrPos );
+ pView->SetOutputArea( aRect );
+ pView->ShowCursor();
+ }
+ }
+}
+
+void ScGridWindow::ScrollPixel( long nDifX, long nDifY )
+{
+ ClickExtern();
+ HideNoteMarker();
+
+ bIsInScroll = TRUE;
+ //BOOL bXor=DrawBeforeScroll();
+
+ SetMapMode(MAP_PIXEL);
+ Scroll( nDifX, nDifY, SCROLL_CHILDREN );
+ SetMapMode( GetDrawMapMode() ); // verschobenen MapMode erzeugen
+
+ UpdateEditViewPos();
+
+ DrawAfterScroll(); //bXor);
+ bIsInScroll = FALSE;
+}
+
+// Formeln neu zeichnen -------------------------------------------------
+
+void ScGridWindow::UpdateFormulas()
+{
+ if (pViewData->GetView()->IsMinimized())
+ return;
+
+ if ( nPaintCount )
+ {
+ // nicht anfangen, verschachtelt zu painten
+ // (dann wuerde zumindest der MapMode nicht mehr stimmen)
+
+ bNeedsRepaint = TRUE; // -> am Ende vom Paint nochmal Invalidate auf alles
+ aRepaintPixel = Rectangle(); // alles
+ return;
+ }
+
+ SCCOL nX1 = pViewData->GetPosX( eHWhich );
+ SCROW nY1 = pViewData->GetPosY( eVWhich );
+ SCCOL nX2 = nX1 + pViewData->VisibleCellsX( eHWhich );
+ SCROW nY2 = nY1 + pViewData->VisibleCellsY( eVWhich );
+
+ if (nX2 > MAXCOL) nX2 = MAXCOL;
+ if (nY2 > MAXROW) nY2 = MAXROW;
+
+ // Draw( nX1, nY1, nX2, nY2, SC_UPDATE_CHANGED );
+
+ // don't draw directly - instead use OutputData to find changed area and invalidate
+
+ SCROW nPosY = nY1;
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ pDoc->ExtendHidden( nX1, nY1, nX2, nY2, nTab );
+
+ Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+ long nMirrorWidth = GetSizePixel().Width();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ // unused variable long nLayoutSign = bLayoutRTL ? -1 : 1;
+ if ( bLayoutRTL )
+ {
+ long nEndPixel = pViewData->GetScrPos( nX2+1, nPosY, eWhich ).X();
+ nMirrorWidth = aScrPos.X() - nEndPixel;
+ aScrPos.X() = nEndPixel + 1;
+ }
+
+ long nScrX = aScrPos.X();
+ long nScrY = aScrPos.Y();
+
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
+
+ ScTableInfo aTabInfo;
+ pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab, nPPTX, nPPTY, FALSE, FALSE );
+
+ Fraction aZoomX = pViewData->GetZoomX();
+ Fraction aZoomY = pViewData->GetZoomY();
+ ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
+ nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
+ &aZoomX, &aZoomY );
+ aOutputData.SetMirrorWidth( nMirrorWidth );
+
+ aOutputData.FindChanged();
+
+ PolyPolygon aChangedPoly( aOutputData.GetChangedArea() ); // logic (PixelToLogic)
+ if ( aChangedPoly.Count() )
+ {
+ Invalidate( aChangedPoly );
+ }
+
+ CheckNeedsRepaint(); // #i90362# used to be called via Draw() - still needed here
+}
+
+void ScGridWindow::UpdateAutoFillMark(BOOL bMarked, const ScRange& rMarkRange)
+{
+ if ( bMarked != bAutoMarkVisible || ( bMarked && rMarkRange.aEnd != aAutoMarkPos ) )
+ {
+ HideCursor();
+ bAutoMarkVisible = bMarked;
+ if ( bMarked )
+ aAutoMarkPos = rMarkRange.aEnd;
+ ShowCursor();
+
+ UpdateAutoFillOverlay();
+ }
+}
+
+void ScGridWindow::UpdateListValPos( BOOL bVisible, const ScAddress& rPos )
+{
+ BOOL bOldButton = bListValButton;
+ ScAddress aOldPos = aListValPos;
+
+ bListValButton = bVisible;
+ aListValPos = rPos;
+
+ if ( bListValButton )
+ {
+ if ( !bOldButton || aListValPos != aOldPos )
+ {
+ // paint area of new button
+ Invalidate( PixelToLogic( GetListValButtonRect( aListValPos ) ) );
+ }
+ }
+ if ( bOldButton )
+ {
+ if ( !bListValButton || aListValPos != aOldPos )
+ {
+ // paint area of old button
+ Invalidate( PixelToLogic( GetListValButtonRect( aOldPos ) ) );
+ }
+ }
+}
+
+void ScGridWindow::HideCursor()
+{
+ ++nCursorHideCount;
+ if (nCursorHideCount==1)
+ {
+ DrawCursor();
+ DrawAutoFillMark();
+ }
+}
+
+void ScGridWindow::ShowCursor()
+{
+ if (nCursorHideCount==0)
+ {
+ DBG_ERROR("zuviel ShowCursor");
+ return;
+ }
+
+ if (nCursorHideCount==1)
+ {
+ // #i57745# Draw the cursor before setting the variable, in case the
+ // GetSizePixel call from drawing causes a repaint (resize handler is called)
+ DrawAutoFillMark();
+ DrawCursor();
+ }
+
+ --nCursorHideCount;
+}
+
+void __EXPORT ScGridWindow::GetFocus()
+{
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ pViewShell->GotFocus();
+ pViewShell->SetFormShellAtTop( FALSE ); // focus in GridWindow -> FormShell no longer on top
+
+ if (pViewShell->HasAccessibilityObjects())
+ pViewShell->BroadcastAccessibility(ScAccGridWinFocusGotHint(eWhich, GetAccessible()));
+
+
+ if ( !SC_MOD()->IsFormulaMode() )
+ {
+ pViewShell->UpdateInputHandler();
+// StopMarking(); // falls Dialog (Fehler), weil dann kein ButtonUp
+ // MO: nur wenn nicht im RefInput-Modus
+ // -> GetFocus/MouseButtonDown-Reihenfolge
+ // auf dem Mac
+ }
+
+ pViewData->GetDocShell()->CheckConfigOptions();
+ Window::GetFocus();
+}
+
+void __EXPORT ScGridWindow::LoseFocus()
+{
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ pViewShell->LostFocus();
+
+ if (pViewShell->HasAccessibilityObjects())
+ pViewShell->BroadcastAccessibility(ScAccGridWinFocusLostHint(eWhich, GetAccessible()));
+
+ Window::LoseFocus();
+}
+
+Point ScGridWindow::GetMousePosPixel() const { return aCurMousePos; }
+
+//------------------------------------------------------------------------
+
+BOOL ScGridWindow::HitRangeFinder( const Point& rMouse, BOOL& rCorner,
+ USHORT* pIndex, SCsCOL* pAddX, SCsROW* pAddY )
+{
+ BOOL bFound = FALSE;
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
+ if (pHdl)
+ {
+ ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
+ if ( pRangeFinder && !pRangeFinder->IsHidden() &&
+ pRangeFinder->GetDocName() == pViewData->GetDocShell()->GetTitle() )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( rMouse.X(), rMouse.Y(), eWhich, nPosX, nPosY );
+ // zusammengefasste (einzeln/Bereich) ???
+ ScAddress aAddr( nPosX, nPosY, nTab );
+
+// Point aNext = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich );
+
+ Point aNext = pViewData->GetScrPos( nPosX, nPosY, eWhich, TRUE );
+ long nSizeXPix;
+ long nSizeYPix;
+ pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeXPix, nSizeYPix );
+ aNext.X() += nSizeXPix * nLayoutSign;
+ aNext.Y() += nSizeYPix;
+
+ BOOL bCornerHor;
+ if ( bLayoutRTL )
+ bCornerHor = ( rMouse.X() >= aNext.X() && rMouse.X() <= aNext.X() + 8 );
+ else
+ bCornerHor = ( rMouse.X() >= aNext.X() - 8 && rMouse.X() <= aNext.X() );
+
+ BOOL bCellCorner = ( bCornerHor &&
+ rMouse.Y() >= aNext.Y() - 8 && rMouse.Y() <= aNext.Y() );
+ // corner is hit only if the mouse is within the cell
+
+ USHORT nCount = (USHORT)pRangeFinder->Count();
+ for (USHORT i=nCount; i;)
+ {
+ // rueckwaerts suchen, damit der zuletzt gepaintete Rahmen gefunden wird
+ --i;
+ ScRangeFindData* pData = pRangeFinder->GetObject(i);
+ if ( pData && pData->aRef.In(aAddr) )
+ {
+ if (pIndex) *pIndex = i;
+ if (pAddX) *pAddX = nPosX - pData->aRef.aStart.Col();
+ if (pAddY) *pAddY = nPosY - pData->aRef.aStart.Row();
+ bFound = TRUE;
+ rCorner = ( bCellCorner && aAddr == pData->aRef.aEnd );
+ break;
+ }
+ }
+ }
+ }
+ return bFound;
+}
+
+#define SCE_TOP 1
+#define SCE_BOTTOM 2
+#define SCE_LEFT 4
+#define SCE_RIGHT 8
+#define SCE_ALL 15
+
+void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, USHORT nEdges )
+{
+ // der Range ist immer richtigherum
+
+ SCCOL nCol1 = rRange.aStart.Col();
+ SCROW nRow1 = rRange.aStart.Row();
+ SCTAB nTab1 = rRange.aStart.Tab();
+ SCCOL nCol2 = rRange.aEnd.Col();
+ SCROW nRow2 = rRange.aEnd.Row();
+ SCTAB nTab2 = rRange.aEnd.Tab();
+ BOOL bHiddenEdge = FALSE;
+ SCROW nTmp;
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab1) )
+ {
+ --nCol1;
+ bHiddenEdge = TRUE;
+ }
+ while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab1) )
+ {
+ ++nCol2;
+ bHiddenEdge = TRUE;
+ }
+ nTmp = pDoc->FirstVisibleRow(0, nRow1, nTab1);
+ if (!ValidRow(nTmp))
+ nTmp = 0;
+ if (nTmp < nRow1)
+ {
+ nRow1 = nTmp;
+ bHiddenEdge = TRUE;
+ }
+ nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab1);
+ if (!ValidRow(nTmp))
+ nTmp = MAXROW;
+ if (nTmp > nRow2)
+ {
+ nRow2 = nTmp;
+ bHiddenEdge = TRUE;
+ }
+
+ if ( nCol2 > nCol1 + 1 && nRow2 > nRow1 + 1 && !bHiddenEdge )
+ {
+ // nur an den Raendern entlang
+ // (die Ecken werden evtl. zweimal getroffen)
+
+ if ( nEdges & SCE_TOP )
+ pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow1, nTab2, PAINT_MARKS );
+ if ( nEdges & SCE_LEFT )
+ pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol1, nRow2, nTab2, PAINT_MARKS );
+ if ( nEdges & SCE_RIGHT )
+ pDocSh->PostPaint( nCol2, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS );
+ if ( nEdges & SCE_BOTTOM )
+ pDocSh->PostPaint( nCol1, nRow2, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS );
+ }
+ else // everything in one call
+ pDocSh->PostPaint( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, PAINT_MARKS );
+}
+
+void lcl_PaintRefChanged( ScDocShell* pDocSh, const ScRange& rOldUn, const ScRange& rNewUn )
+{
+ // Repaint fuer die Teile des Rahmens in Old, die bei New nicht mehr da sind
+
+ ScRange aOld = rOldUn;
+ ScRange aNew = rNewUn;
+ aOld.Justify();
+ aNew.Justify();
+
+ if ( aOld.aStart == aOld.aEnd ) //! Tab ignorieren?
+ pDocSh->GetDocument()->ExtendMerge(aOld);
+ if ( aNew.aStart == aNew.aEnd ) //! Tab ignorieren?
+ pDocSh->GetDocument()->ExtendMerge(aNew);
+
+ SCCOL nOldCol1 = aOld.aStart.Col();
+ SCROW nOldRow1 = aOld.aStart.Row();
+ SCCOL nOldCol2 = aOld.aEnd.Col();
+ SCROW nOldRow2 = aOld.aEnd.Row();
+ SCCOL nNewCol1 = aNew.aStart.Col();
+ SCROW nNewRow1 = aNew.aStart.Row();
+ SCCOL nNewCol2 = aNew.aEnd.Col();
+ SCROW nNewRow2 = aNew.aEnd.Row();
+ SCTAB nTab1 = aOld.aStart.Tab(); // Tab aendert sich nicht
+ SCTAB nTab2 = aOld.aEnd.Tab();
+
+ if ( nNewRow2 < nOldRow1 || nNewRow1 > nOldRow2 ||
+ nNewCol2 < nOldCol1 || nNewCol1 > nOldCol2 ||
+ ( nNewCol1 != nOldCol1 && nNewRow1 != nOldRow1 &&
+ nNewCol2 != nOldCol2 && nNewRow2 != nOldRow2 ) )
+ {
+ // komplett weggeschoben oder alle Seiten veraendert
+ // (Abfrage <= statt < geht schief bei einzelnen Zeilen/Spalten)
+
+ lcl_PaintOneRange( pDocSh, aOld, SCE_ALL );
+ }
+ else // alle vier Kanten einzeln testen
+ {
+ // oberer Teil
+ if ( nNewRow1 < nOldRow1 ) // nur obere Linie loeschen
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol1, nOldRow1, nTab1, nOldCol2, nOldRow1, nTab2 ), SCE_ALL );
+ else if ( nNewRow1 > nOldRow1 ) // den Teil, der oben wegkommt
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol1, nOldRow1, nTab1, nOldCol2, nNewRow1-1, nTab2 ),
+ SCE_ALL &~ SCE_BOTTOM );
+
+ // unterer Teil
+ if ( nNewRow2 > nOldRow2 ) // nur untere Linie loeschen
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol1, nOldRow2, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL );
+ else if ( nNewRow2 < nOldRow2 ) // den Teil, der unten wegkommt
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol1, nNewRow2+1, nTab1, nOldCol2, nOldRow2, nTab2 ),
+ SCE_ALL &~ SCE_TOP );
+
+ // linker Teil
+ if ( nNewCol1 < nOldCol1 ) // nur linke Linie loeschen
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol1, nOldRow1, nTab1, nOldCol1, nOldRow2, nTab2 ), SCE_ALL );
+ else if ( nNewCol1 > nOldCol1 ) // den Teil, der links wegkommt
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol1, nOldRow1, nTab1, nNewCol1-1, nOldRow2, nTab2 ),
+ SCE_ALL &~ SCE_RIGHT );
+
+ // rechter Teil
+ if ( nNewCol2 > nOldCol2 ) // nur rechte Linie loeschen
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nOldCol2, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ), SCE_ALL );
+ else if ( nNewCol2 < nOldCol2 ) // den Teil, der rechts wegkommt
+ lcl_PaintOneRange( pDocSh, ScRange(
+ nNewCol2+1, nOldRow1, nTab1, nOldCol2, nOldRow2, nTab2 ),
+ SCE_ALL &~ SCE_LEFT );
+ }
+}
+
+void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, BOOL bUp )
+{
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() );
+ if (!pHdl)
+ return;
+ ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
+ if (!pRangeFinder || nRFIndex >= pRangeFinder->Count())
+ return;
+ ScRangeFindData* pData = pRangeFinder->GetObject( nRFIndex );
+ if (!pData)
+ return;
+
+ // Mauszeiger
+
+ if (bRFSize)
+ SetPointer( Pointer( POINTER_CROSS ) );
+ else
+ SetPointer( Pointer( POINTER_HAND ) );
+
+ // Scrolling
+
+ BOOL bTimer = FALSE;
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nDx = 0;
+ SCsROW nDy = 0;
+ if ( aPos.X() < 0 ) nDx = -1;
+ if ( aPos.Y() < 0 ) nDy = -1;
+ Size aSize = GetOutputSizePixel();
+ if ( aPos.X() >= aSize.Width() )
+ nDx = 1;
+ if ( aPos.Y() >= aSize.Height() )
+ nDy = 1;
+ if ( nDx != 0 || nDy != 0 )
+ {
+ if ( nDx != 0) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
+ if ( nDy != 0 ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
+ bTimer = TRUE;
+ }
+
+ // Umschalten bei Fixierung (damit Scrolling funktioniert)
+
+ if ( eWhich == pViewData->GetActivePart() ) //??
+ {
+ if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX )
+ if ( nDx > 0 )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT );
+ else if ( eWhich == SC_SPLIT_BOTTOMLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
+ }
+
+ if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX )
+ if ( nDy > 0 )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT );
+ else if ( eWhich == SC_SPLIT_TOPRIGHT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
+ }
+ }
+
+ // Verschieben
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+
+ ScRange aOld = pData->aRef;
+ ScRange aNew = aOld;
+ if ( bRFSize )
+ {
+ aNew.aEnd.SetCol((SCCOL)nPosX);
+ aNew.aEnd.SetRow((SCROW)nPosY);
+ }
+ else
+ {
+ long nStartX = nPosX - nRFAddX;
+ if ( nStartX < 0 ) nStartX = 0;
+ long nStartY = nPosY - nRFAddY;
+ if ( nStartY < 0 ) nStartY = 0;
+ long nEndX = nStartX + aOld.aEnd.Col() - aOld.aStart.Col();
+ if ( nEndX > MAXCOL )
+ {
+ nStartX -= ( nEndX - MAXROW );
+ nEndX = MAXCOL;
+ }
+ long nEndY = nStartY + aOld.aEnd.Row() - aOld.aStart.Row();
+ if ( nEndY > MAXROW )
+ {
+ nStartY -= ( nEndY - MAXROW );
+ nEndY = MAXROW;
+ }
+
+ aNew.aStart.SetCol((SCCOL)nStartX);
+ aNew.aStart.SetRow((SCROW)nStartY);
+ aNew.aEnd.SetCol((SCCOL)nEndX);
+ aNew.aEnd.SetRow((SCROW)nEndY);
+ }
+
+ if ( bUp )
+ aNew.Justify(); // beim ButtonUp wieder richtigherum
+
+ if ( aNew != aOld )
+ {
+ pHdl->UpdateRange( nRFIndex, aNew );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ // nur das neuzeichnen, was sich veraendert hat...
+ lcl_PaintRefChanged( pDocSh, aOld, aNew );
+
+ // neuen Rahmen nur drueberzeichnen (synchron)
+ pDocSh->Broadcast( ScIndexHint( SC_HINT_SHOWRANGEFINDER, nRFIndex ) );
+
+ Update(); // was man bewegt, will man auch sofort sehen
+ }
+
+ // Timer fuer Scrolling
+
+ if (bTimer)
+ pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen
+ else
+ pViewData->GetView()->ResetTimer();
+}
+
+//------------------------------------------------------------------------
+
+BOOL ScGridWindow::GetEditUrl( const Point& rPos,
+ String* pName, String* pUrl, String* pTarget )
+{
+ return GetEditUrlOrError( FALSE, rPos, pName, pUrl, pTarget );
+}
+
+BOOL ScGridWindow::GetEditUrlOrError( BOOL bSpellErr, const Point& rPos,
+ String* pName, String* pUrl, String* pTarget )
+{
+ //! nPosX/Y mit uebergeben?
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( rPos.X(), rPos.Y(), eWhich, nPosX, nPosY );
+
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScBaseCell* pCell = NULL;
+
+ BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell );
+ if( !bFound )
+ return FALSE;
+
+ ScHideTextCursor aHideCursor( pViewData, eWhich ); // before GetEditArea (MapMode is changed)
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab );
+ // bForceToTop = FALSE, use the cell's real position
+ Rectangle aEditRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern, FALSE );
+ if (rPos.Y() < aEditRect.Top())
+ return FALSE;
+
+ // vertikal kann (noch) nicht angeklickt werden:
+
+ if (pPattern->GetCellOrientation() != SVX_ORIENTATION_STANDARD)
+ return FALSE;
+
+ BOOL bBreak = ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue() ||
+ ((SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->
+ GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK);
+ SvxCellHorJustify eHorJust = (SvxCellHorJustify)((SvxHorJustifyItem&)pPattern->
+ GetItem(ATTR_HOR_JUSTIFY)).GetValue();
+
+ // EditEngine
+
+ ScFieldEditEngine aEngine( pDoc->GetEditPool() );
+ ScSizeDeviceProvider aProv(pDocSh);
+ aEngine.SetRefDevice( aProv.GetDevice() );
+ aEngine.SetRefMapMode( MAP_100TH_MM );
+ SfxItemSet aDefault( aEngine.GetEmptyItemSet() );
+ pPattern->FillEditItemSet( &aDefault );
+ SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT;
+ switch (eHorJust)
+ {
+ case SVX_HOR_JUSTIFY_LEFT:
+ case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert
+ case SVX_HOR_JUSTIFY_STANDARD: // always Text if an EditCell type
+ eSvxAdjust = SVX_ADJUST_LEFT;
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ eSvxAdjust = SVX_ADJUST_RIGHT;
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ break;
+ case SVX_HOR_JUSTIFY_BLOCK:
+ eSvxAdjust = SVX_ADJUST_BLOCK;
+ break;
+ }
+ aDefault.Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
+ aEngine.SetDefaults( aDefault );
+ if (bSpellErr)
+ aEngine.SetControlWord( aEngine.GetControlWord() | EE_CNTRL_ONLINESPELLING );
+
+ MapMode aEditMode = pViewData->GetLogicMode(eWhich); // ohne Drawing-Skalierung
+ Rectangle aLogicEdit = PixelToLogic( aEditRect, aEditMode );
+ long nThisColLogic = aLogicEdit.Right() - aLogicEdit.Left() + 1;
+ Size aPaperSize = Size( 1000000, 1000000 );
+ if(pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ long nSizeX = 0;
+ long nSizeY = 0;
+ pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
+ aPaperSize = Size(nSizeX, nSizeY );
+ aPaperSize = PixelToLogic(aPaperSize);
+ }
+
+ if (bBreak)
+ aPaperSize.Width() = nThisColLogic;
+ aEngine.SetPaperSize( aPaperSize );
+
+ ::std::auto_ptr< EditTextObject > pTextObj;
+ const EditTextObject* pData;
+ if(pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ ((ScEditCell*)pCell)->GetData(pData);
+ if (pData)
+ aEngine.SetText(*pData);
+ }
+ else // HyperLink Formula cell
+ {
+ pTextObj.reset((static_cast<ScFormulaCell*>(pCell))->CreateURLObject());
+ if (pTextObj.get())
+ aEngine.SetText(*pTextObj);
+ }
+
+ long nStartX = aLogicEdit.Left();
+
+ long nTextWidth = aEngine.CalcTextWidth();
+ long nTextHeight = aEngine.GetTextHeight();
+ if ( nTextWidth < nThisColLogic )
+ {
+ if (eHorJust == SVX_HOR_JUSTIFY_RIGHT)
+ nStartX += nThisColLogic - nTextWidth;
+ else if (eHorJust == SVX_HOR_JUSTIFY_CENTER)
+ nStartX += (nThisColLogic - nTextWidth) / 2;
+ }
+
+ aLogicEdit.Left() = nStartX;
+ if (!bBreak)
+ aLogicEdit.Right() = nStartX + nTextWidth;
+
+ // There is one glitch when dealing with a hyperlink cell and
+ // the cell content is NUMERIC. This defaults to right aligned and
+ // we need to adjust accordingly.
+ if(pCell->GetCellType() == CELLTYPE_FORMULA &&
+ static_cast<ScFormulaCell*>(pCell)->IsValue() &&
+ eHorJust == SVX_HOR_JUSTIFY_STANDARD)
+ {
+ aLogicEdit.Right() = aLogicEdit.Left() + nThisColLogic - 1;
+ aLogicEdit.Left() = aLogicEdit.Right() - nTextWidth;
+ }
+ aLogicEdit.Bottom() = aLogicEdit.Top() + nTextHeight;
+
+
+ Point aLogicClick = PixelToLogic(rPos,aEditMode);
+ if ( aLogicEdit.IsInside(aLogicClick) )
+ {
+// aEngine.SetUpdateMode(FALSE);
+ EditView aTempView( &aEngine, this );
+ aTempView.SetOutputArea( aLogicEdit );
+
+ BOOL bRet = FALSE;
+ MapMode aOld = GetMapMode();
+ SetMapMode(aEditMode); // kein return mehr
+
+ if (bSpellErr) // Spelling-Fehler suchen
+ {
+ bRet = aTempView.IsWrongSpelledWordAtPos( rPos );
+ if ( bRet )
+ pViewData->GetView()->SetCursor( nPosX, nPosY ); // Cursor setzen
+ }
+ else // URL suchen
+ {
+ const SvxFieldItem* pFieldItem = aTempView.GetFieldUnderMousePointer();
+
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField && pField->ISA(SvxURLField) )
+ {
+ if ( pName || pUrl || pTarget )
+ {
+ const SvxURLField* pURLField = (const SvxURLField*)pField;
+ if (pName)
+ *pName = pURLField->GetRepresentation();
+ if (pUrl)
+ *pUrl = pURLField->GetURL();
+ if (pTarget)
+ *pTarget = pURLField->GetTargetFrame();
+ }
+ bRet = TRUE;
+ }
+ }
+ }
+
+ SetMapMode(aOld);
+
+ // text cursor is restored in ScHideTextCursor dtor
+
+ return bRet;
+ }
+ return FALSE;
+}
+
+BOOL ScGridWindow::HasScenarioButton( const Point& rPosPixel, ScRange& rScenRange )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) )
+ {
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ Size aButSize = pViewData->GetScenButSize();
+ long nBWidth = aButSize.Width();
+ if (!nBWidth)
+ return FALSE; // noch kein Button gezeichnet -> da ist auch keiner
+ long nBHeight = aButSize.Height();
+ long nHSpace = (long)( SC_SCENARIO_HSPACE * pViewData->GetPPTX() );
+
+ //! Ranges an der Table cachen!!!!
+
+ ScMarkData aMarks;
+ for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
+ pDoc->MarkScenario( i, nTab, aMarks, FALSE, SC_SCENARIO_SHOWFRAME );
+ ScRangeList aRanges;
+ aMarks.FillRangeListWithMarks( &aRanges, FALSE );
+
+
+ ULONG nRangeCount = aRanges.Count();
+ for (ULONG j=0; j<nRangeCount; j++)
+ {
+ ScRange aRange = *aRanges.GetObject(j);
+ // Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn
+ // dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden
+ pDoc->ExtendTotalMerge( aRange );
+
+ BOOL bTextBelow = ( aRange.aStart.Row() == 0 );
+
+ Point aButtonPos;
+ if ( bTextBelow )
+ {
+ aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aEnd.Row()+1,
+ eWhich, TRUE );
+ }
+ else
+ {
+ aButtonPos = pViewData->GetScrPos( aRange.aEnd.Col()+1, aRange.aStart.Row(),
+ eWhich, TRUE );
+ aButtonPos.Y() -= nBHeight;
+ }
+ if ( bLayoutRTL )
+ aButtonPos.X() -= nHSpace - 1;
+ else
+ aButtonPos.X() -= nBWidth - nHSpace; // same for top or bottom
+
+ Rectangle aButRect( aButtonPos, Size(nBWidth,nBHeight) );
+ if ( aButRect.IsInside( rPosPixel ) )
+ {
+ rScenRange = aRange;
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+// #114409#
+void ScGridWindow::DrawLayerCreated()
+{
+ SetMapMode( GetDrawMapMode() );
+
+ // initially create overlay objects
+ ImpCreateOverlayObjects();
+}
+
+// #114409#
+void ScGridWindow::CursorChanged()
+{
+ // here the created OverlayObjects may be transformed in later versions. For
+ // now, just re-create them
+
+ UpdateCursorOverlay();
+}
+
+// #114409#
+void ScGridWindow::ImpCreateOverlayObjects()
+{
+ UpdateCursorOverlay();
+ UpdateCopySourceOverlay();
+ UpdateSelectionOverlay();
+ UpdateAutoFillOverlay();
+ UpdateDragRectOverlay();
+ UpdateHeaderOverlay();
+ UpdateShrinkOverlay();
+}
+
+// #114409#
+void ScGridWindow::ImpDestroyOverlayObjects()
+{
+ DeleteCursorOverlay();
+ DeleteCopySourceOverlay();
+ DeleteSelectionOverlay();
+ DeleteAutoFillOverlay();
+ DeleteDragRectOverlay();
+ DeleteHeaderOverlay();
+ DeleteShrinkOverlay();
+}
+
+void ScGridWindow::UpdateAllOverlays()
+{
+ // delete and re-allocate all overlay objects
+
+ ImpDestroyOverlayObjects();
+ ImpCreateOverlayObjects();
+}
+
+void ScGridWindow::DeleteCursorOverlay()
+{
+ DELETEZ( mpOOCursors );
+}
+
+void ScGridWindow::DeleteCopySourceOverlay()
+{
+ DELETEZ( mpOOSelectionBorder );
+}
+
+void ScGridWindow::UpdateCopySourceOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ DeleteCopySourceOverlay();
+
+ if (!pViewData->ShowPasteSource())
+ return;
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+ if (!pOverlayManager)
+ return;
+ ScTransferObj* pTransObj = ScTransferObj::GetOwnClipboard( pViewData->GetActiveWin() );
+ if (!pTransObj)
+ return;
+ ScDocument* pClipDoc = pTransObj->GetDocument();
+ if (!pClipDoc)
+ return;
+
+ SCTAB nCurTab = pViewData->GetCurPos().Tab();
+
+ ScClipParam& rClipParam = pClipDoc->GetClipParam();
+ mpOOSelectionBorder = new ::sdr::overlay::OverlayObjectList;
+ for (ScRange* p = rClipParam.maRanges.First(); p; p = rClipParam.maRanges.Next())
+ {
+ if (p->aStart.Tab() != nCurTab)
+ continue;
+
+ SCCOL nClipStartX = p->aStart.Col();
+ SCROW nClipStartY = p->aStart.Row();
+ SCCOL nClipEndX = p->aEnd.Col();
+ SCROW nClipEndY = p->aEnd.Row();
+
+ Point aClipStartScrPos = pViewData->GetScrPos( nClipStartX, nClipStartY, eWhich );
+ Point aClipEndScrPos = pViewData->GetScrPos( nClipEndX + 1, nClipEndY + 1, eWhich );
+ aClipStartScrPos -= Point(1, 1);
+ long nSizeXPix = aClipEndScrPos.X() - aClipStartScrPos.X();
+ long nSizeYPix = aClipEndScrPos.Y() - aClipStartScrPos.Y();
+
+ Rectangle aRect( aClipStartScrPos, Size(nSizeXPix, nSizeYPix) );
+
+
+ Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
+
+ Rectangle aLogic = PixelToLogic(aRect, aDrawMode);
+ ::basegfx::B2DRange aRange(aLogic.Left(), aLogic.Top(), aLogic.Right(), aLogic.Bottom());
+ ScOverlayDashedBorder* pDashedBorder = new ScOverlayDashedBorder(aRange, aHighlight, this);
+ pOverlayManager->add(*pDashedBorder);
+ mpOOSelectionBorder->append(*pDashedBorder);
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+}
+
+void ScGridWindow::UpdateCursorOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ // Existing OverlayObjects may be transformed in later versions.
+ // For now, just re-create them.
+
+ DeleteCursorOverlay();
+
+ std::vector<Rectangle> aPixelRects;
+
+ //
+ // determine the cursor rectangles in pixels (moved from ScGridWindow::DrawCursor)
+ //
+
+ SCTAB nTab = pViewData->GetTabNo();
+ SCCOL nX = pViewData->GetCurX();
+ SCROW nY = pViewData->GetCurY();
+
+ if (!maVisibleRange.isInside(nX, nY))
+ return;
+
+ // don't show the cursor in overlapped cells
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ const ScPatternAttr* pPattern = pDoc->GetPattern(nX,nY,nTab);
+ const ScMergeFlagAttr& rMergeFlag = (const ScMergeFlagAttr&) pPattern->GetItem(ATTR_MERGE_FLAG);
+ BOOL bOverlapped = rMergeFlag.IsOverlapped();
+
+ // left or above of the screen?
+
+ BOOL bVis = ( nX>=pViewData->GetPosX(eHWhich) && nY>=pViewData->GetPosY(eVWhich) );
+ if (!bVis)
+ {
+ SCCOL nEndX = nX;
+ SCROW nEndY = nY;
+ const ScMergeAttr& rMerge = (const ScMergeAttr&) pPattern->GetItem(ATTR_MERGE);
+ if (rMerge.GetColMerge() > 1)
+ nEndX += rMerge.GetColMerge()-1;
+ if (rMerge.GetRowMerge() > 1)
+ nEndY += rMerge.GetRowMerge()-1;
+ bVis = ( nEndX>=pViewData->GetPosX(eHWhich) && nEndY>=pViewData->GetPosY(eVWhich) );
+ }
+
+ if ( bVis && !bOverlapped && !pViewData->HasEditView(eWhich) && pViewData->IsActive() )
+ {
+ Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE );
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ // completely right of/below the screen?
+ // (test with logical start position in aScrPos)
+ BOOL bMaybeVisible;
+ if ( bLayoutRTL )
+ bMaybeVisible = ( aScrPos.X() >= -2 && aScrPos.Y() >= -2 );
+ else
+ {
+ Size aOutSize = GetOutputSizePixel();
+ bMaybeVisible = ( aScrPos.X() <= aOutSize.Width() + 2 && aScrPos.Y() <= aOutSize.Height() + 2 );
+ }
+ if ( bMaybeVisible )
+ {
+ long nSizeXPix;
+ long nSizeYPix;
+ pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
+
+ if ( bLayoutRTL )
+ aScrPos.X() -= nSizeXPix - 2; // move instead of mirroring
+
+ // Now, draw the cursor.
+
+ aScrPos.X() -= 2;
+ aScrPos.Y() -= 2;
+ Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) );
+
+ aPixelRects.push_back(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() ));
+ aPixelRects.push_back(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() ));
+ aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 ));
+ aPixelRects.push_back(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() ));
+ }
+ }
+
+ if ( aPixelRects.size() )
+ {
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ Color aCursorColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ if (pViewData->GetActivePart() != eWhich)
+ // non-active pane uses a different color.
+ aCursorColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
+ std::vector< basegfx::B2DRange > aRanges;
+ const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
+
+ for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
+ {
+ const Rectangle aRA(aPixelRects[a]);
+ basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
+ aRB.transform(aTransform);
+ aRanges.push_back(aRB);
+ }
+
+ sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
+ sdr::overlay::OVERLAY_SOLID,
+ aCursorColor,
+ aRanges,
+ false);
+
+ pOverlayManager->add(*pOverlay);
+ mpOOCursors = new ::sdr::overlay::OverlayObjectList;
+ mpOOCursors->append(*pOverlay);
+ }
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+}
+
+void ScGridWindow::DeleteSelectionOverlay()
+{
+ DELETEZ( mpOOSelection );
+}
+
+void ScGridWindow::UpdateSelectionOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ DeleteSelectionOverlay();
+ std::vector<Rectangle> aPixelRects;
+ GetSelectionRects( aPixelRects );
+
+ if ( aPixelRects.size() && pViewData->IsActive() )
+ {
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ std::vector< basegfx::B2DRange > aRanges;
+ const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
+
+ for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
+ {
+ const Rectangle aRA(aPixelRects[a]);
+ basegfx::B2DRange aRB(aRA.Left() - 1, aRA.Top() - 1, aRA.Right(), aRA.Bottom());
+ aRB.transform(aTransform);
+ aRanges.push_back(aRB);
+ }
+
+ // #i97672# get the system's hilight color and limit it to the maximum
+ // allowed luminance. This is needed to react on too bright hilight colors
+ // which would otherwise vive a bad visualisation
+ Color aHighlight(GetSettings().GetStyleSettings().GetHighlightColor());
+ const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+ const basegfx::BColor aSelection(aHighlight.getBColor());
+ const double fLuminance(aSelection.luminance());
+ const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0);
+
+ if(fLuminance > fMaxLum)
+ {
+ const double fFactor(fMaxLum / fLuminance);
+ const basegfx::BColor aNewSelection(
+ aSelection.getRed() * fFactor,
+ aSelection.getGreen() * fFactor,
+ aSelection.getBlue() * fFactor);
+
+ aHighlight = Color(aNewSelection);
+ }
+
+ sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
+ sdr::overlay::OVERLAY_TRANSPARENT,
+ aHighlight,
+ aRanges,
+ true);
+
+ pOverlayManager->add(*pOverlay);
+ mpOOSelection = new ::sdr::overlay::OverlayObjectList;
+ mpOOSelection->append(*pOverlay);
+ }
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+}
+
+void ScGridWindow::DeleteAutoFillOverlay()
+{
+ DELETEZ( mpOOAutoFill );
+ mpAutoFillRect.reset();
+}
+
+void ScGridWindow::UpdateAutoFillOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ DeleteAutoFillOverlay();
+
+ //
+ // get the AutoFill handle rectangle in pixels (moved from ScGridWindow::DrawAutoFillMark)
+ //
+
+ if ( bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() &&
+ !pViewData->HasEditView(eWhich) && pViewData->IsActive() )
+ {
+ SCCOL nX = aAutoMarkPos.Col();
+ SCROW nY = aAutoMarkPos.Row();
+
+ if (!maVisibleRange.isInside(nX, nY))
+ // Autofill mark is not visible. Bail out.
+ return;
+
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE );
+ long nSizeXPix;
+ long nSizeYPix;
+ pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
+ if ( bLayoutRTL )
+ aFillPos.X() -= nSizeXPix + 3;
+ else
+ aFillPos.X() += nSizeXPix - 2;
+
+ aFillPos.Y() += nSizeYPix;
+ aFillPos.Y() -= 2;
+ mpAutoFillRect.reset(new Rectangle(aFillPos, Size(6, 6)));
+
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ Color aHandleColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ if (pViewData->GetActivePart() != eWhich)
+ // non-active pane uses a different color.
+ aHandleColor = SC_MOD()->GetColorConfig().GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor;
+ std::vector< basegfx::B2DRange > aRanges;
+ const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
+ basegfx::B2DRange aRB(mpAutoFillRect->Left(), mpAutoFillRect->Top(), mpAutoFillRect->Right() + 1, mpAutoFillRect->Bottom() + 1);
+
+ aRB.transform(aTransform);
+ aRanges.push_back(aRB);
+
+ sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
+ sdr::overlay::OVERLAY_SOLID,
+ aHandleColor,
+ aRanges,
+ false);
+
+ pOverlayManager->add(*pOverlay);
+ mpOOAutoFill = new ::sdr::overlay::OverlayObjectList;
+ mpOOAutoFill->append(*pOverlay);
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+ }
+}
+
+void ScGridWindow::DeleteDragRectOverlay()
+{
+ DELETEZ( mpOODragRect );
+}
+
+void ScGridWindow::UpdateDragRectOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ DeleteDragRectOverlay();
+
+ //
+ // get the rectangles in pixels (moved from DrawDragRect)
+ //
+
+ if ( bDragRect || bPagebreakDrawn )
+ {
+ std::vector<Rectangle> aPixelRects;
+
+ SCCOL nX1 = bDragRect ? nDragStartX : aPagebreakDrag.aStart.Col();
+ SCROW nY1 = bDragRect ? nDragStartY : aPagebreakDrag.aStart.Row();
+ SCCOL nX2 = bDragRect ? nDragEndX : aPagebreakDrag.aEnd.Col();
+ SCROW nY2 = bDragRect ? nDragEndY : aPagebreakDrag.aEnd.Row();
+
+ SCTAB nTab = pViewData->GetTabNo();
+
+ SCCOL nPosX = pViewData->GetPosX(WhichH(eWhich));
+ SCROW nPosY = pViewData->GetPosY(WhichV(eWhich));
+ if (nX1 < nPosX) nX1 = nPosX;
+ if (nX2 < nPosX) nX2 = nPosX;
+ if (nY1 < nPosY) nY1 = nPosY;
+ if (nY2 < nPosY) nY2 = nPosY;
+
+ Point aScrPos( pViewData->GetScrPos( nX1, nY1, eWhich ) );
+
+ long nSizeXPix=0;
+ long nSizeYPix=0;
+ ScDocument* pDoc = pViewData->GetDocument();
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
+ SCCOLROW i;
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ if (ValidCol(nX2) && nX2>=nX1)
+ for (i=nX1; i<=nX2; i++)
+ nSizeXPix += ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(i), nTab ), nPPTX );
+ else
+ {
+ aScrPos.X() -= nLayoutSign;
+ nSizeXPix += 2;
+ }
+
+ if (ValidRow(nY2) && nY2>=nY1)
+ for (i=nY1; i<=nY2; i++)
+ nSizeYPix += ScViewData::ToPixel( pDoc->GetRowHeight( i, nTab ), nPPTY );
+ else
+ {
+ aScrPos.Y() -= 1;
+ nSizeYPix += 2;
+ }
+
+ aScrPos.X() -= 2 * nLayoutSign;
+ aScrPos.Y() -= 2;
+// Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) );
+ Rectangle aRect( aScrPos.X(), aScrPos.Y(),
+ aScrPos.X() + ( nSizeXPix + 2 ) * nLayoutSign, aScrPos.Y() + nSizeYPix + 2 );
+ if ( bLayoutRTL )
+ {
+ aRect.Left() = aRect.Right(); // end position is left
+ aRect.Right() = aScrPos.X();
+ }
+
+ if ( meDragInsertMode == INS_CELLSDOWN )
+ {
+ aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Top()+3, aRect.Left()+1, aRect.Bottom()-2 ) );
+ aPixelRects.push_back( Rectangle( aRect.Right()-1, aRect.Top()+3, aRect.Right()-1, aRect.Bottom()-2 ) );
+ aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Top(), aRect.Right()-1, aRect.Top()+2 ) );
+ aPixelRects.push_back( Rectangle( aRect.Left()+1, aRect.Bottom()-1, aRect.Right()-1, aRect.Bottom()-1 ) );
+ }
+ else if ( meDragInsertMode == INS_CELLSRIGHT )
+ {
+ aPixelRects.push_back( Rectangle( aRect.Left(), aRect.Top()+1, aRect.Left()+2, aRect.Bottom()-1 ) );
+ aPixelRects.push_back( Rectangle( aRect.Right()-1, aRect.Top()+1, aRect.Right()-1, aRect.Bottom()-1 ) );
+ aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Top()+1, aRect.Right()-2, aRect.Top()+1 ) );
+ aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Bottom()-1, aRect.Right()-2, aRect.Bottom()-1 ) );
+ }
+ else
+ {
+ aPixelRects.push_back( Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() ) );
+ aPixelRects.push_back( Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() ) );
+ aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 ) );
+ aPixelRects.push_back( Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() ) );
+ }
+
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
+ std::vector< basegfx::B2DRange > aRanges;
+ const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
+
+ for(sal_uInt32 a(0); a < aPixelRects.size(); a++)
+ {
+ const Rectangle aRA(aPixelRects[a]);
+ basegfx::B2DRange aRB(aRA.Left(), aRA.Top(), aRA.Right() + 1, aRA.Bottom() + 1);
+ aRB.transform(aTransform);
+ aRanges.push_back(aRB);
+ }
+
+ sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
+ sdr::overlay::OVERLAY_INVERT,
+ Color(COL_BLACK),
+ aRanges,
+ false);
+
+ pOverlayManager->add(*pOverlay);
+ mpOODragRect = new ::sdr::overlay::OverlayObjectList;
+ mpOODragRect->append(*pOverlay);
+ }
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+}
+
+void ScGridWindow::DeleteHeaderOverlay()
+{
+ DELETEZ( mpOOHeader );
+}
+
+void ScGridWindow::UpdateHeaderOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ DeleteHeaderOverlay();
+
+ // Pixel rectangle is in aInvertRect
+ if ( !aInvertRect.IsEmpty() )
+ {
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
+ std::vector< basegfx::B2DRange > aRanges;
+ const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
+ basegfx::B2DRange aRB(aInvertRect.Left(), aInvertRect.Top(), aInvertRect.Right() + 1, aInvertRect.Bottom() + 1);
+
+ aRB.transform(aTransform);
+ aRanges.push_back(aRB);
+
+ sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
+ sdr::overlay::OVERLAY_INVERT,
+ Color(COL_BLACK),
+ aRanges,
+ false);
+
+ pOverlayManager->add(*pOverlay);
+ mpOOHeader = new ::sdr::overlay::OverlayObjectList;
+ mpOOHeader->append(*pOverlay);
+ }
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+}
+
+void ScGridWindow::DeleteShrinkOverlay()
+{
+ DELETEZ( mpOOShrink );
+}
+
+void ScGridWindow::UpdateShrinkOverlay()
+{
+ MapMode aDrawMode = GetDrawMapMode();
+ MapMode aOldMode = GetMapMode();
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aDrawMode );
+
+ DeleteShrinkOverlay();
+
+ //
+ // get the rectangle in pixels
+ //
+
+ Rectangle aPixRect;
+ ScRange aRange;
+ SCTAB nTab = pViewData->GetTabNo();
+ if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() &&
+ pViewData->GetDelMark( aRange ) )
+ {
+ //! limit to visible area
+ if ( aRange.aStart.Col() <= aRange.aEnd.Col() &&
+ aRange.aStart.Row() <= aRange.aEnd.Row() )
+ {
+ Point aStart = pViewData->GetScrPos( aRange.aStart.Col(),
+ aRange.aStart.Row(), eWhich );
+ Point aEnd = pViewData->GetScrPos( aRange.aEnd.Col()+1,
+ aRange.aEnd.Row()+1, eWhich );
+ aEnd.X() -= 1;
+ aEnd.Y() -= 1;
+
+ aPixRect = Rectangle( aStart,aEnd );
+ }
+ }
+
+ if ( !aPixRect.IsEmpty() )
+ {
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ // Color aHighlight = GetSettings().GetStyleSettings().GetHighlightColor();
+ std::vector< basegfx::B2DRange > aRanges;
+ const basegfx::B2DHomMatrix aTransform(GetInverseViewTransformation());
+ basegfx::B2DRange aRB(aPixRect.Left(), aPixRect.Top(), aPixRect.Right() + 1, aPixRect.Bottom() + 1);
+
+ aRB.transform(aTransform);
+ aRanges.push_back(aRB);
+
+ sdr::overlay::OverlayObject* pOverlay = new sdr::overlay::OverlaySelection(
+ sdr::overlay::OVERLAY_INVERT,
+ Color(COL_BLACK),
+ aRanges,
+ false);
+
+ pOverlayManager->add(*pOverlay);
+ mpOOShrink = new ::sdr::overlay::OverlayObjectList;
+ mpOOShrink->append(*pOverlay);
+ }
+ }
+
+ if ( aOldMode != aDrawMode )
+ SetMapMode( aOldMode );
+}
+
+// #i70788# central method to get the OverlayManager safely
+::sdr::overlay::OverlayManager* ScGridWindow::getOverlayManager()
+{
+ SdrPageView* pPV = pViewData->GetView()->GetScDrawView()->GetSdrPageView();
+
+ if(pPV)
+ {
+ SdrPageWindow* pPageWin = pPV->FindPageWindow( *this );
+
+ if ( pPageWin )
+ {
+ return (pPageWin->GetOverlayManager());
+ }
+ }
+
+ return 0L;
+}
+
+void ScGridWindow::flushOverlayManager()
+{
+ // #i70788# get the OverlayManager safely
+ ::sdr::overlay::OverlayManager* pOverlayManager = getOverlayManager();
+
+ if(pOverlayManager)
+ {
+ pOverlayManager->flush();
+ }
+}
+
+// ---------------------------------------------------------------------------
+// eof
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
new file mode 100644
index 000000000000..ccacee30fe30
--- /dev/null
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -0,0 +1,1075 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+
+#include "gridwin.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+#include "pivot.hxx"
+#include "uiitems.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "pagedata.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+#include "dpoutput.hxx" // ScDPPositionData
+#include "dpshttab.hxx"
+#include "dbdocfun.hxx"
+#include "dpcontrol.hxx"
+#include "dpcontrol.hrc"
+#include "strload.hxx"
+#include "userlist.hxx"
+
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+#include "scabstdlg.hxx"
+
+#include <vector>
+#include <hash_map>
+
+using namespace com::sun::star;
+using ::com::sun::star::sheet::DataPilotFieldOrientation;
+using ::std::vector;
+using ::std::auto_ptr;
+using ::std::hash_map;
+using ::rtl::OUString;
+using ::rtl::OUStringHash;
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+DataPilotFieldOrientation ScGridWindow::GetDPFieldOrientation( SCCOL nCol, SCROW nRow ) const
+{
+ using namespace ::com::sun::star::sheet;
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
+ if (!pDPObj)
+ return DataPilotFieldOrientation_HIDDEN;
+
+ USHORT nOrient = DataPilotFieldOrientation_HIDDEN;
+
+ // Check for page field first.
+ if (nCol > 0)
+ {
+ // look for the dimension header left of the drop-down arrow
+ long nField = pDPObj->GetHeaderDim( ScAddress( nCol-1, nRow, nTab ), nOrient );
+ if ( nField >= 0 && nOrient == DataPilotFieldOrientation_PAGE )
+ {
+ BOOL bIsDataLayout = FALSE;
+ String aFieldName = pDPObj->GetDimName( nField, bIsDataLayout );
+ if ( aFieldName.Len() && !bIsDataLayout )
+ return DataPilotFieldOrientation_PAGE;
+ }
+ }
+
+ nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+
+ // Now, check for row/column field.
+ long nField = pDPObj->GetHeaderDim(ScAddress(nCol, nRow, nTab), nOrient);
+ if (nField >= 0 && (nOrient == DataPilotFieldOrientation_COLUMN || nOrient == DataPilotFieldOrientation_ROW) )
+ {
+ BOOL bIsDataLayout = FALSE;
+ String aFieldName = pDPObj->GetDimName(nField, bIsDataLayout);
+ if (aFieldName.Len() && !bIsDataLayout)
+ return static_cast<DataPilotFieldOrientation>(nOrient);
+ }
+
+ return DataPilotFieldOrientation_HIDDEN;
+}
+
+// private method for mouse button handling
+BOOL ScGridWindow::DoPageFieldSelection( SCCOL nCol, SCROW nRow )
+{
+ if (GetDPFieldOrientation( nCol, nRow ) == sheet::DataPilotFieldOrientation_PAGE)
+ {
+ LaunchPageFieldMenu( nCol, nRow );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ Point aScrPos = pViewData->GetScrPos(nCol, nRow, eWhich);
+ Point aDiffPix = rMEvt.GetPosPixel();
+
+ aDiffPix -= aScrPos;
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ if ( bLayoutRTL )
+ aDiffPix.X() = -aDiffPix.X();
+
+ long nSizeX, nSizeY;
+ pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+ Size aScrSize(nSizeX-1, nSizeY-1);
+
+ // Check if the mouse cursor is clicking on the popup arrow box.
+ mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc));
+ mpFilterButton->setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
+ mpFilterButton->setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL
+ Point aPopupPos;
+ Size aPopupSize;
+ mpFilterButton->getPopupBoundingBox(aPopupPos, aPopupSize);
+ Rectangle aRec(aPopupPos, aPopupSize);
+ if (aRec.IsInside(rMEvt.GetPosPixel()))
+ {
+ if ( DoPageFieldSelection( nCol, nRow ) )
+ return true;
+
+ bool bFilterActive = IsAutoFilterActive(nCol, nRow, nTab);
+ mpFilterButton->setHasHiddenMember(bFilterActive);
+ mpFilterButton->setDrawBaseButton(false);
+ mpFilterButton->setDrawPopupButton(true);
+ mpFilterButton->setPopupPressed(true);
+ HideCursor();
+ mpFilterButton->draw();
+ ShowCursor();
+ DoAutoFilterMenue(nCol, nRow, false);
+ return true;
+ }
+
+ return false;
+}
+
+void ScGridWindow::DoPushButton( SCCOL nCol, SCROW nRow, const MouseEvent& rMEvt )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ ScDPObject* pDPObj = pDoc->GetDPAtCursor(nCol, nRow, nTab);
+
+ if (pDPObj)
+ {
+ USHORT nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+ ScAddress aPos( nCol, nRow, nTab );
+ long nField = pDPObj->GetHeaderDim( aPos, nOrient );
+ if ( nField >= 0 )
+ {
+ bDPMouse = TRUE;
+ nDPField = nField;
+ pDragDPObj = pDPObj;
+
+ if (DPTestFieldPopupArrow(rMEvt, aPos, pDPObj))
+ {
+ // field name pop up menu has been launched. Don't activate
+ // field move.
+ bDPMouse = false;
+ return;
+ }
+
+ DPTestMouse( rMEvt, TRUE );
+ StartTracking();
+ }
+ else if ( pDPObj->IsFilterButton(aPos) )
+ {
+ ReleaseMouse(); // may have been captured in ButtonDown
+
+ ScQueryParam aQueryParam;
+ SCTAB nSrcTab = 0;
+ const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
+ DBG_ASSERT(pDesc, "no sheet source for filter button");
+ if (pDesc)
+ {
+ aQueryParam = pDesc->aQueryParam;
+ nSrcTab = pDesc->aSourceRange.aStart.Tab();
+ }
+
+ SfxItemSet aArgSet( pViewData->GetViewShell()->GetPool(),
+ SCITEM_QUERYDATA, SCITEM_QUERYDATA );
+ aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg( pViewData->GetViewShell()->GetDialogParent(),
+ aArgSet, nSrcTab,
+ RID_SCDLG_PIVOTFILTER);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( pDlg->Execute() == RET_OK )
+ {
+ ScSheetSourceDesc aNewDesc;
+ if (pDesc)
+ aNewDesc = *pDesc;
+
+ const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
+ aNewDesc.aQueryParam = rQueryItem.GetQueryData();
+
+ ScDPObject aNewObj( *pDPObj );
+ aNewObj.SetSheetDesc( aNewDesc );
+ ScDBDocFunc aFunc( *pViewData->GetDocShell() );
+ aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE );
+ pViewData->GetView()->CursorPosChanged(); // shells may be switched
+ }
+ delete pDlg;
+ }
+ else
+ Sound::Beep();
+ }
+ else
+ {
+ DBG_ERROR("Da is ja garnix");
+ }
+}
+
+// -----------------------------------------------------------------------
+//
+// Data Pilot interaction
+//
+
+void ScGridWindow::DPTestMouse( const MouseEvent& rMEvt, BOOL bMove )
+{
+ DBG_ASSERT(pDragDPObj, "pDragDPObj missing");
+
+ // scroll window if at edges
+ //! move this to separate method
+
+ BOOL bTimer = FALSE;
+ Point aPixel = rMEvt.GetPosPixel();
+
+ SCsCOL nDx = 0;
+ SCsROW nDy = 0;
+ if ( aPixel.X() < 0 )
+ nDx = -1;
+ if ( aPixel.Y() < 0 )
+ nDy = -1;
+ Size aSize = GetOutputSizePixel();
+ if ( aPixel.X() >= aSize.Width() )
+ nDx = 1;
+ if ( aPixel.Y() >= aSize.Height() )
+ nDy = 1;
+ if ( nDx != 0 || nDy != 0 )
+ {
+ UpdateDragRect( FALSE, Rectangle() );
+
+ if ( nDx != 0)
+ pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
+ if ( nDy != 0 )
+ pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
+
+ bTimer = TRUE;
+ }
+
+ // ---
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), eWhich, nPosX, nPosY );
+ BOOL bMouseLeft;
+ BOOL bMouseTop;
+ pViewData->GetMouseQuadrant( aPixel, eWhich, nPosX, nPosY, bMouseLeft, bMouseTop );
+
+ ScAddress aPos( nPosX, nPosY, pViewData->GetTabNo() );
+
+ Rectangle aPosRect;
+ USHORT nOrient;
+ long nDimPos;
+ BOOL bHasRange = pDragDPObj->GetHeaderDrag( aPos, bMouseLeft, bMouseTop, nDPField,
+ aPosRect, nOrient, nDimPos );
+ UpdateDragRect( bHasRange && bMove, aPosRect );
+
+ BOOL bIsDataLayout;
+ sal_Int32 nDimFlags = 0;
+ String aDimName = pDragDPObj->GetDimName( nDPField, bIsDataLayout, &nDimFlags );
+ bool bAllowed = !bHasRange || ScDPObject::IsOrientationAllowed( nOrient, nDimFlags );
+
+ if (bMove) // set mouse pointer
+ {
+ PointerStyle ePointer = POINTER_PIVOT_DELETE;
+ if ( !bAllowed )
+ ePointer = POINTER_NOTALLOWED;
+ else if ( bHasRange )
+ switch (nOrient)
+ {
+ case sheet::DataPilotFieldOrientation_COLUMN: ePointer = POINTER_PIVOT_COL; break;
+ case sheet::DataPilotFieldOrientation_ROW: ePointer = POINTER_PIVOT_ROW; break;
+ case sheet::DataPilotFieldOrientation_PAGE:
+ case sheet::DataPilotFieldOrientation_DATA: ePointer = POINTER_PIVOT_FIELD; break;
+ }
+ SetPointer( ePointer );
+ }
+ else // execute change
+ {
+ if (!bHasRange)
+ nOrient = sheet::DataPilotFieldOrientation_HIDDEN;
+
+ if ( bIsDataLayout && ( nOrient != sheet::DataPilotFieldOrientation_COLUMN &&
+ nOrient != sheet::DataPilotFieldOrientation_ROW ) )
+ {
+ // removing data layout is not allowed
+ pViewData->GetView()->ErrorMessage(STR_PIVOT_MOVENOTALLOWED);
+ }
+ else if ( bAllowed )
+ {
+ ScDPSaveData aSaveData( *pDragDPObj->GetSaveData() );
+
+ ScDPSaveDimension* pDim;
+ if ( bIsDataLayout )
+ pDim = aSaveData.GetDataLayoutDimension();
+ else
+ pDim = aSaveData.GetDimensionByName(aDimName);
+ pDim->SetOrientation( nOrient );
+ aSaveData.SetPosition( pDim, nDimPos );
+
+ //! docfunc method with ScDPSaveData as argument?
+
+ ScDPObject aNewObj( *pDragDPObj );
+ aNewObj.SetSaveData( aSaveData );
+ ScDBDocFunc aFunc( *pViewData->GetDocShell() );
+ // when dragging fields, allow re-positioning (bAllowMove)
+ aFunc.DataPilotUpdate( pDragDPObj, &aNewObj, TRUE, FALSE, TRUE );
+ pViewData->GetView()->CursorPosChanged(); // shells may be switched
+ }
+ }
+
+ if (bTimer && bMove)
+ pViewData->GetView()->SetTimer( this, rMEvt ); // repeat event
+ else
+ pViewData->GetView()->ResetTimer();
+}
+
+bool ScGridWindow::DPTestFieldPopupArrow(const MouseEvent& rMEvt, const ScAddress& rPos, ScDPObject* pDPObj)
+{
+ BOOL bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+
+ // Get the geometry of the cell.
+ Point aScrPos = pViewData->GetScrPos(rPos.Col(), rPos.Row(), eWhich);
+ long nSizeX, nSizeY;
+ pViewData->GetMergeSizePixel(rPos.Col(), rPos.Row(), nSizeX, nSizeY);
+ Size aScrSize(nSizeX-1, nSizeY-1);
+
+ // Check if the mouse cursor is clicking on the popup arrow box.
+ ScDPFieldButton aBtn(this, &GetSettings().GetStyleSettings());
+ aBtn.setBoundingBox(aScrPos, aScrSize, bLayoutRTL);
+ aBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now
+ Point aPopupPos;
+ Size aPopupSize;
+ aBtn.getPopupBoundingBox(aPopupPos, aPopupSize);
+ Rectangle aRec(aPopupPos, aPopupSize);
+ if (aRec.IsInside(rMEvt.GetPosPixel()))
+ {
+ // Mouse cursor inside the popup arrow box. Launch the field menu.
+ DPLaunchFieldPopupMenu(OutputToScreenPixel(aScrPos), aScrSize, rPos, pDPObj);
+ return true;
+ }
+
+ return false;
+}
+
+namespace {
+
+struct DPFieldPopupData : public ScDPFieldPopupWindow::ExtendedData
+{
+ ScPivotParam maDPParam;
+ ScDPObject* mpDPObj;
+ long mnDim;
+};
+
+class DPFieldPopupOKAction : public ScMenuFloatingWindow::Action
+{
+public:
+ explicit DPFieldPopupOKAction(ScGridWindow* p) :
+ mpGridWindow(p) {}
+
+ virtual void execute()
+ {
+ mpGridWindow->UpdateDPFromFieldPopupMenu();
+ }
+private:
+ ScGridWindow* mpGridWindow;
+};
+
+class PopupSortAction : public ScMenuFloatingWindow::Action
+{
+public:
+ enum SortType { ASCENDING, DESCENDING, CUSTOM };
+
+ explicit PopupSortAction(const ScAddress& rPos, SortType eType, sal_uInt16 nUserListIndex, ScTabViewShell* pViewShell) :
+ maPos(rPos), meType(eType), mnUserListIndex(nUserListIndex), mpViewShell(pViewShell) {}
+
+ virtual void execute()
+ {
+ switch (meType)
+ {
+ case ASCENDING:
+ mpViewShell->DataPilotSort(maPos, true);
+ break;
+ case DESCENDING:
+ mpViewShell->DataPilotSort(maPos, false);
+ break;
+ case CUSTOM:
+ mpViewShell->DataPilotSort(maPos, true, &mnUserListIndex);
+ break;
+ default:
+ ;
+ }
+ }
+
+private:
+ ScAddress maPos;
+ SortType meType;
+ sal_uInt16 mnUserListIndex;
+ ScTabViewShell* mpViewShell;
+};
+
+}
+
+void ScGridWindow::DPLaunchFieldPopupMenu(
+ const Point& rScrPos, const Size& rScrSize, const ScAddress& rPos, ScDPObject* pDPObj)
+{
+ // We need to get the list of field members.
+ auto_ptr<DPFieldPopupData> pDPData(new DPFieldPopupData);
+ pDPObj->FillLabelData(pDPData->maDPParam);
+ pDPData->mpDPObj = pDPObj;
+
+ USHORT nOrient;
+ pDPData->mnDim = pDPObj->GetHeaderDim(rPos, nOrient);
+
+ if (pDPData->maDPParam.maLabelArray.size() <= static_cast<size_t>(pDPData->mnDim))
+ // out-of-bound dimension ID. This should never happen!
+ return;
+
+ const ScDPLabelData& rLabelData = *pDPData->maDPParam.maLabelArray[pDPData->mnDim];
+
+ mpDPFieldPopup.reset(new ScDPFieldPopupWindow(this, pViewData->GetDocument()));
+ mpDPFieldPopup->setName(OUString::createFromAscii("DataPilot field member popup"));
+ mpDPFieldPopup->setExtendedData(pDPData.release());
+ mpDPFieldPopup->setOKAction(new DPFieldPopupOKAction(this));
+ {
+ // Populate field members.
+ size_t n = rLabelData.maMembers.size();
+ mpDPFieldPopup->setMemberSize(n);
+ for (size_t i = 0; i < n; ++i)
+ {
+ const ScDPLabelData::Member& rMem = rLabelData.maMembers[i];
+ mpDPFieldPopup->addMember(rMem.getDisplayName(), rMem.mbVisible);
+ }
+ mpDPFieldPopup->initMembers();
+ }
+
+ vector<OUString> aUserSortNames;
+ ScUserList* pUserList = ScGlobal::GetUserList();
+ if (pUserList)
+ {
+ sal_uInt16 n = pUserList->GetCount();
+ aUserSortNames.reserve(n);
+ for (sal_uInt16 i = 0; i < n; ++i)
+ {
+ ScUserListData* pData = static_cast<ScUserListData*>((*pUserList)[i]);
+ aUserSortNames.push_back(pData->GetString());
+ }
+ }
+
+ // Populate the menus.
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ mpDPFieldPopup->addMenuItem(
+ ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_ASC).GetString(), true,
+ new PopupSortAction(rPos, PopupSortAction::ASCENDING, 0, pViewShell));
+ mpDPFieldPopup->addMenuItem(
+ ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_DESC).GetString(), true,
+ new PopupSortAction(rPos, PopupSortAction::DESCENDING, 0, pViewShell));
+ ScMenuFloatingWindow* pSubMenu = mpDPFieldPopup->addSubMenuItem(
+ ScRscStrLoader(RID_POPUP_FILTER, STR_MENU_SORT_CUSTOM).GetString(), !aUserSortNames.empty());
+
+ if (pSubMenu && !aUserSortNames.empty())
+ {
+ size_t n = aUserSortNames.size();
+ for (size_t i = 0; i < n; ++i)
+ {
+ pSubMenu->addMenuItem(
+ aUserSortNames[i], true,
+ new PopupSortAction(rPos, PopupSortAction::CUSTOM, static_cast<sal_uInt16>(i), pViewShell));
+ }
+ }
+
+ BOOL bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+
+ Rectangle aCellRect(rScrPos, rScrSize);
+ const Size& rPopupSize = mpDPFieldPopup->getWindowSize();
+ if (bLayoutRTL)
+ {
+ // RTL: rScrPos is logical-left (visual right) position, always right-align with that
+ aCellRect.SetPos(Point(rScrPos.X() - rPopupSize.Width() + 1, rScrPos.Y()));
+ }
+ else if (rScrSize.getWidth() > rPopupSize.getWidth())
+ {
+ // If the cell width is larger than the popup window width, launch it
+ // right-aligned with the cell.
+ long nXOffset = rScrSize.getWidth() - rPopupSize.getWidth();
+ aCellRect.SetPos(Point(rScrPos.X() + nXOffset, rScrPos.Y()));
+ }
+ mpDPFieldPopup->SetPopupModeEndHdl( LINK(this, ScGridWindow, PopupModeEndHdl) );
+ mpDPFieldPopup->StartPopupMode(aCellRect, (FLOATWIN_POPUPMODE_DOWN | FLOATWIN_POPUPMODE_GRABFOCUS));
+}
+
+void ScGridWindow::UpdateDPFromFieldPopupMenu()
+{
+ typedef hash_map<OUString, OUString, OUStringHash> MemNameMapType;
+ typedef hash_map<OUString, bool, OUStringHash> MemVisibilityType;
+
+ if (!mpDPFieldPopup.get())
+ return;
+
+ DPFieldPopupData* pDPData = static_cast<DPFieldPopupData*>(mpDPFieldPopup->getExtendedData());
+ if (!pDPData)
+ return;
+
+ ScDPObject* pDPObj = pDPData->mpDPObj;
+ ScDPObject aNewDPObj(*pDPObj);
+ aNewDPObj.BuildAllDimensionMembers();
+ ScDPSaveData* pSaveData = aNewDPObj.GetSaveData();
+
+ BOOL bIsDataLayout;
+ String aDimName = pDPObj->GetDimName(pDPData->mnDim, bIsDataLayout);
+ ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(aDimName);
+ if (!pDim)
+ return;
+
+ // Build a map of layout names to original names.
+ const ScDPLabelData& rLabelData = *pDPData->maDPParam.maLabelArray[pDPData->mnDim];
+ MemNameMapType aMemNameMap;
+ for (vector<ScDPLabelData::Member>::const_iterator itr = rLabelData.maMembers.begin(), itrEnd = rLabelData.maMembers.end();
+ itr != itrEnd; ++itr)
+ aMemNameMap.insert(MemNameMapType::value_type(itr->maLayoutName, itr->maName));
+
+ // The raw result may contain a mixture of layout names and original names.
+ MemVisibilityType aRawResult;
+ mpDPFieldPopup->getResult(aRawResult);
+
+ MemVisibilityType aResult;
+ for (MemVisibilityType::const_iterator itr = aRawResult.begin(), itrEnd = aRawResult.end(); itr != itrEnd; ++itr)
+ {
+ MemNameMapType::const_iterator itrNameMap = aMemNameMap.find(itr->first);
+ if (itrNameMap == aMemNameMap.end())
+ // This is an original member name. Use it as-is.
+ aResult.insert(MemVisibilityType::value_type(itr->first, itr->second));
+ else
+ {
+ // This is a layout name. Get the original member name and use it.
+ aResult.insert(MemVisibilityType::value_type(itrNameMap->second, itr->second));
+ }
+ }
+ pDim->UpdateMemberVisibility(aResult);
+
+ ScDBDocFunc aFunc(*pViewData->GetDocShell());
+ aFunc.DataPilotUpdate(pDPObj, &aNewDPObj, true, false);
+}
+
+void ScGridWindow::UpdateVisibleRange()
+{
+ SCCOL nPosX = pViewData->GetPosX(eHWhich);
+ SCROW nPosY = pViewData->GetPosY(eVWhich);
+ SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
+ if (nXRight > MAXCOL) nXRight = MAXCOL;
+ SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
+ if (nYBottom > MAXROW) nYBottom = MAXROW;
+
+ // Store the current visible range.
+ maVisibleRange.mnCol1 = nPosX;
+ maVisibleRange.mnCol2 = nXRight;
+ maVisibleRange.mnRow1 = nPosY;
+ maVisibleRange.mnRow2 = nYBottom;
+}
+
+void ScGridWindow::DPMouseMove( const MouseEvent& rMEvt )
+{
+ DPTestMouse( rMEvt, TRUE );
+}
+
+void ScGridWindow::DPMouseButtonUp( const MouseEvent& rMEvt )
+{
+ bDPMouse = FALSE;
+ ReleaseMouse();
+
+ DPTestMouse( rMEvt, FALSE );
+ SetPointer( Pointer( POINTER_ARROW ) );
+}
+
+// -----------------------------------------------------------------------
+
+void ScGridWindow::UpdateDragRect( BOOL bShowRange, const Rectangle& rPosRect )
+{
+ SCCOL nStartX = ( rPosRect.Left() >= 0 ) ? static_cast<SCCOL>(rPosRect.Left()) : SCCOL_MAX;
+ SCROW nStartY = ( rPosRect.Top() >= 0 ) ? static_cast<SCROW>(rPosRect.Top()) : SCROW_MAX;
+ SCCOL nEndX = ( rPosRect.Right() >= 0 ) ? static_cast<SCCOL>(rPosRect.Right()) : SCCOL_MAX;
+ SCROW nEndY = ( rPosRect.Bottom() >= 0 ) ? static_cast<SCROW>(rPosRect.Bottom()) : SCROW_MAX;
+
+ if ( bShowRange == bDragRect && nDragStartX == nStartX && nDragEndX == nEndX &&
+ nDragStartY == nStartY && nDragEndY == nEndY )
+ {
+ return; // everything unchanged
+ }
+
+ // if ( bDragRect )
+ // DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE );
+ if ( bShowRange )
+ {
+ nDragStartX = nStartX;
+ nDragStartY = nStartY;
+ nDragEndX = nEndX;
+ nDragEndY = nEndY;
+ bDragRect = TRUE;
+ // DrawDragRect( nDragStartX, nDragStartY, nDragEndX, nDragEndY, FALSE );
+ }
+ else
+ bDragRect = FALSE;
+
+ UpdateDragRectOverlay();
+}
+
+// -----------------------------------------------------------------------
+
+// Page-Break-Modus
+
+USHORT ScGridWindow::HitPageBreak( const Point& rMouse, ScRange* pSource,
+ SCCOLROW* pBreak, SCCOLROW* pPrev )
+{
+ USHORT nFound = SC_PD_NONE; // 0
+ ScRange aSource;
+ SCCOLROW nBreak = 0;
+ SCCOLROW nPrev = 0;
+
+ ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData();
+ if ( pPageData )
+ {
+ BOOL bHori = FALSE;
+ BOOL bVert = FALSE;
+ SCCOL nHitX = 0;
+ SCROW nHitY = 0;
+
+ long nMouseX = rMouse.X();
+ long nMouseY = rMouse.Y();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( nMouseX, nMouseY, eWhich, nPosX, nPosY );
+ Point aTL = pViewData->GetScrPos( nPosX, nPosY, eWhich );
+ Point aBR = pViewData->GetScrPos( nPosX+1, nPosY+1, eWhich );
+
+ // Horizontal mehr Toleranz als vertikal, weil mehr Platz ist
+ if ( nMouseX <= aTL.X() + 4 )
+ {
+ bHori = TRUE;
+ nHitX = nPosX;
+ }
+ else if ( nMouseX >= aBR.X() - 6 )
+ {
+ bHori = TRUE;
+ nHitX = nPosX+1; // linker Rand der naechsten Zelle
+ }
+ if ( nMouseY <= aTL.Y() + 2 )
+ {
+ bVert = TRUE;
+ nHitY = nPosY;
+ }
+ else if ( nMouseY >= aBR.Y() - 4 )
+ {
+ bVert = TRUE;
+ nHitY = nPosY+1; // oberer Rand der naechsten Zelle
+ }
+
+ if ( bHori || bVert )
+ {
+ USHORT nCount = sal::static_int_cast<USHORT>( pPageData->GetCount() );
+ for (USHORT nPos=0; nPos<nCount && !nFound; nPos++)
+ {
+ ScPrintRangeData& rData = pPageData->GetData(nPos);
+ ScRange aRange = rData.GetPrintRange();
+ BOOL bLHit = ( bHori && nHitX == aRange.aStart.Col() );
+ BOOL bRHit = ( bHori && nHitX == aRange.aEnd.Col() + 1 );
+ BOOL bTHit = ( bVert && nHitY == aRange.aStart.Row() );
+ BOOL bBHit = ( bVert && nHitY == aRange.aEnd.Row() + 1 );
+ BOOL bInsideH = ( nPosX >= aRange.aStart.Col() && nPosX <= aRange.aEnd.Col() );
+ BOOL bInsideV = ( nPosY >= aRange.aStart.Row() && nPosY <= aRange.aEnd.Row() );
+
+ if ( bLHit )
+ {
+ if ( bTHit )
+ nFound = SC_PD_RANGE_TL;
+ else if ( bBHit )
+ nFound = SC_PD_RANGE_BL;
+ else if ( bInsideV )
+ nFound = SC_PD_RANGE_L;
+ }
+ else if ( bRHit )
+ {
+ if ( bTHit )
+ nFound = SC_PD_RANGE_TR;
+ else if ( bBHit )
+ nFound = SC_PD_RANGE_BR;
+ else if ( bInsideV )
+ nFound = SC_PD_RANGE_R;
+ }
+ else if ( bTHit && bInsideH )
+ nFound = SC_PD_RANGE_T;
+ else if ( bBHit && bInsideH )
+ nFound = SC_PD_RANGE_B;
+ if (nFound)
+ aSource = aRange;
+
+ // Umbrueche
+
+ if ( bVert && bInsideH && !nFound )
+ {
+ size_t nRowCount = rData.GetPagesY();
+ const SCROW* pRowEnd = rData.GetPageEndY();
+ for (size_t nRowPos=0; nRowPos+1<nRowCount; nRowPos++)
+ if ( pRowEnd[nRowPos]+1 == nHitY )
+ {
+ nFound = SC_PD_BREAK_V;
+ aSource = aRange;
+ nBreak = nHitY;
+ if ( nRowPos )
+ nPrev = pRowEnd[nRowPos-1]+1;
+ else
+ nPrev = aRange.aStart.Row();
+ }
+ }
+ if ( bHori && bInsideV && !nFound )
+ {
+ size_t nColCount = rData.GetPagesX();
+ const SCCOL* pColEnd = rData.GetPageEndX();
+ for (size_t nColPos=0; nColPos+1<nColCount; nColPos++)
+ if ( pColEnd[nColPos]+1 == nHitX )
+ {
+ nFound = SC_PD_BREAK_H;
+ aSource = aRange;
+ nBreak = nHitX;
+ if ( nColPos )
+ nPrev = pColEnd[nColPos-1]+1;
+ else
+ nPrev = aRange.aStart.Col();
+ }
+ }
+ }
+ }
+ }
+
+ if (pSource)
+ *pSource = aSource; // Druckbereich
+ if (pBreak)
+ *pBreak = nBreak; // X/Y Position des verchobenen Seitenumbruchs
+ if (pPrev)
+ *pPrev = nPrev; // X/Y Anfang der Seite, die am Umbruch zuende ist
+ return nFound;
+}
+
+void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp )
+{
+ //! Scrolling und Umschalten mit RFMouseMove zusammenfassen !
+ //! (Weginvertieren vor dem Scrolling ist anders)
+
+ // Scrolling
+
+ BOOL bTimer = FALSE;
+ Point aPos = rMEvt.GetPosPixel();
+ SCsCOL nDx = 0;
+ SCsROW nDy = 0;
+ if ( aPos.X() < 0 ) nDx = -1;
+ if ( aPos.Y() < 0 ) nDy = -1;
+ Size aSize = GetOutputSizePixel();
+ if ( aPos.X() >= aSize.Width() )
+ nDx = 1;
+ if ( aPos.Y() >= aSize.Height() )
+ nDy = 1;
+ if ( nDx != 0 || nDy != 0 )
+ {
+ if ( bPagebreakDrawn ) // weginvertieren
+ {
+ // DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(),
+ // aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE );
+ bPagebreakDrawn = FALSE;
+ UpdateDragRectOverlay();
+ }
+
+ if ( nDx != 0 ) pViewData->GetView()->ScrollX( nDx, WhichH(eWhich) );
+ if ( nDy != 0 ) pViewData->GetView()->ScrollY( nDy, WhichV(eWhich) );
+ bTimer = TRUE;
+ }
+
+ // Umschalten bei Fixierung (damit Scrolling funktioniert)
+
+ if ( eWhich == pViewData->GetActivePart() ) //??
+ {
+ if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX )
+ if ( nDx > 0 )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT );
+ else if ( eWhich == SC_SPLIT_BOTTOMLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
+ }
+
+ if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX )
+ if ( nDy > 0 )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT );
+ else if ( eWhich == SC_SPLIT_TOPRIGHT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT );
+ }
+ }
+
+ // ab hier neu
+
+ // gesucht wird eine Position zwischen den Zellen (vor nPosX / nPosY)
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY );
+ BOOL bLeft, bTop;
+ pViewData->GetMouseQuadrant( aPos, eWhich, nPosX, nPosY, bLeft, bTop );
+ if ( !bLeft ) ++nPosX;
+ if ( !bTop ) ++nPosY;
+
+ BOOL bBreak = ( nPagebreakMouse == SC_PD_BREAK_H || nPagebreakMouse == SC_PD_BREAK_V );
+ BOOL bHide = FALSE;
+ BOOL bToEnd = FALSE;
+ ScRange aDrawRange = aPagebreakSource;
+ if ( bBreak )
+ {
+ if ( nPagebreakMouse == SC_PD_BREAK_H )
+ {
+ if ( nPosX > aPagebreakSource.aStart.Col() &&
+ nPosX <= aPagebreakSource.aEnd.Col() + 1 ) // ans Ende ist auch erlaubt
+ {
+ bToEnd = ( nPosX == aPagebreakSource.aEnd.Col() + 1 );
+ aDrawRange.aStart.SetCol( nPosX );
+ aDrawRange.aEnd.SetCol( nPosX - 1 );
+ }
+ else
+ bHide = TRUE;
+ }
+ else
+ {
+ if ( nPosY > aPagebreakSource.aStart.Row() &&
+ nPosY <= aPagebreakSource.aEnd.Row() + 1 ) // ans Ende ist auch erlaubt
+ {
+ bToEnd = ( nPosY == aPagebreakSource.aEnd.Row() + 1 );
+ aDrawRange.aStart.SetRow( nPosY );
+ aDrawRange.aEnd.SetRow( nPosY - 1 );
+ }
+ else
+ bHide = TRUE;
+ }
+ }
+ else
+ {
+ if ( nPagebreakMouse & SC_PD_RANGE_L )
+ aDrawRange.aStart.SetCol( nPosX );
+ if ( nPagebreakMouse & SC_PD_RANGE_T )
+ aDrawRange.aStart.SetRow( nPosY );
+ if ( nPagebreakMouse & SC_PD_RANGE_R )
+ {
+ if ( nPosX > 0 )
+ aDrawRange.aEnd.SetCol( nPosX-1 );
+ else
+ bHide = TRUE;
+ }
+ if ( nPagebreakMouse & SC_PD_RANGE_B )
+ {
+ if ( nPosY > 0 )
+ aDrawRange.aEnd.SetRow( nPosY-1 );
+ else
+ bHide = TRUE;
+ }
+ if ( aDrawRange.aStart.Col() > aDrawRange.aEnd.Col() ||
+ aDrawRange.aStart.Row() > aDrawRange.aEnd.Row() )
+ bHide = TRUE;
+ }
+
+ if ( !bPagebreakDrawn || bUp || aDrawRange != aPagebreakDrag )
+ {
+ // zeichnen...
+
+ if ( bPagebreakDrawn )
+ {
+ // weginvertieren
+ // DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(),
+ // aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE );
+ bPagebreakDrawn = FALSE;
+ }
+ aPagebreakDrag = aDrawRange;
+ if ( !bUp && !bHide )
+ {
+ // hininvertieren
+ // DrawDragRect( aPagebreakDrag.aStart.Col(), aPagebreakDrag.aStart.Row(),
+ // aPagebreakDrag.aEnd.Col(), aPagebreakDrag.aEnd.Row(), FALSE );
+ bPagebreakDrawn = TRUE;
+ }
+ UpdateDragRectOverlay();
+ }
+
+ // bei ButtonUp die Aenderung ausfuehren
+
+ if ( bUp )
+ {
+ ScViewFunc* pViewFunc = pViewData->GetView();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ if ( bBreak )
+ {
+ BOOL bColumn = ( nPagebreakMouse == SC_PD_BREAK_H );
+ SCCOLROW nNew = bColumn ? static_cast<SCCOLROW>(nPosX) : static_cast<SCCOLROW>(nPosY);
+ if ( nNew != nPagebreakBreak )
+ {
+ if (bUndo)
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_DRAG_BREAK );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ }
+
+ BOOL bGrow = !bHide && nNew > nPagebreakBreak;
+ if ( bColumn )
+ {
+ if (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakBreak), nTab) & BREAK_MANUAL)
+ {
+ ScAddress aOldAddr( static_cast<SCCOL>(nPagebreakBreak), nPosY, nTab );
+ pViewFunc->DeletePageBreak( TRUE, TRUE, &aOldAddr, FALSE );
+ }
+ if ( !bHide && !bToEnd ) // am Ende nicht
+ {
+ ScAddress aNewAddr( static_cast<SCCOL>(nNew), nPosY, nTab );
+ pViewFunc->InsertPageBreak( TRUE, TRUE, &aNewAddr, FALSE );
+ }
+ if ( bGrow )
+ {
+ // vorigen Break auf hart, und Skalierung aendern
+ bool bManualBreak = (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakPrev), nTab) & BREAK_MANUAL);
+ if ( static_cast<SCCOL>(nPagebreakPrev) > aPagebreakSource.aStart.Col() && !bManualBreak )
+ {
+ ScAddress aPrev( static_cast<SCCOL>(nPagebreakPrev), nPosY, nTab );
+ pViewFunc->InsertPageBreak( TRUE, TRUE, &aPrev, FALSE );
+ }
+
+ if (!pDocSh->AdjustPrintZoom( ScRange(
+ static_cast<SCCOL>(nPagebreakPrev),0,nTab, static_cast<SCCOL>(nNew-1),0,nTab ) ))
+ bGrow = FALSE;
+ }
+ }
+ else
+ {
+ if (pDoc->HasRowBreak(nPagebreakBreak, nTab) & BREAK_MANUAL)
+ {
+ ScAddress aOldAddr( nPosX, nPagebreakBreak, nTab );
+ pViewFunc->DeletePageBreak( FALSE, TRUE, &aOldAddr, FALSE );
+ }
+ if ( !bHide && !bToEnd ) // am Ende nicht
+ {
+ ScAddress aNewAddr( nPosX, nNew, nTab );
+ pViewFunc->InsertPageBreak( FALSE, TRUE, &aNewAddr, FALSE );
+ }
+ if ( bGrow )
+ {
+ // vorigen Break auf hart, und Skalierung aendern
+ bool bManualBreak = (pDoc->HasRowBreak(nPagebreakPrev, nTab) & BREAK_MANUAL);
+ if ( nPagebreakPrev > aPagebreakSource.aStart.Row() && !bManualBreak )
+ {
+ ScAddress aPrev( nPosX, nPagebreakPrev, nTab );
+ pViewFunc->InsertPageBreak( FALSE, TRUE, &aPrev, FALSE );
+ }
+
+ if (!pDocSh->AdjustPrintZoom( ScRange(
+ 0,nPagebreakPrev,nTab, 0,nNew-1,nTab ) ))
+ bGrow = FALSE;
+ }
+ }
+
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+
+ if (!bGrow) // sonst in AdjustPrintZoom schon passiert
+ {
+ pViewFunc->UpdatePageBreakData( TRUE );
+ pDocSh->SetDocumentModified();
+ }
+ }
+ }
+ else if ( bHide || aPagebreakDrag != aPagebreakSource )
+ {
+ // Druckbereich setzen
+
+ String aNewRanges;
+ USHORT nOldCount = pDoc->GetPrintRangeCount( nTab );
+ if ( nOldCount )
+ {
+ for (USHORT nPos=0; nPos<nOldCount; nPos++)
+ {
+ const ScRange* pOld = pDoc->GetPrintRange( nTab, nPos );
+ if ( pOld )
+ {
+ String aTemp;
+ if ( *pOld != aPagebreakSource )
+ pOld->Format( aTemp, SCA_VALID );
+ else if ( !bHide )
+ aPagebreakDrag.Format( aTemp, SCA_VALID );
+ if (aTemp.Len())
+ {
+ if ( aNewRanges.Len() )
+ aNewRanges += ';';
+ aNewRanges += aTemp;
+ }
+ }
+ }
+ }
+ else if (!bHide)
+ aPagebreakDrag.Format( aNewRanges, SCA_VALID );
+
+ pViewFunc->SetPrintRanges( pDoc->IsPrintEntireSheet( nTab ), &aNewRanges, NULL, NULL, FALSE );
+ }
+ }
+
+ // Timer fuer Scrolling
+
+ if (bTimer && !bUp)
+ pViewData->GetView()->SetTimer( this, rMEvt ); // Event wiederholen
+ else
+ pViewData->GetView()->ResetTimer();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin3.cxx b/sc/source/ui/view/gridwin3.cxx
new file mode 100644
index 000000000000..37673bc035d1
--- /dev/null
+++ b/sc/source/ui/view/gridwin3.cxx
@@ -0,0 +1,445 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <svx/svdoutl.hxx>
+#include <svx/svdotext.hxx>
+#include <svx/svdpagv.hxx>
+#include <editeng/sizeitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/ptitem.hxx>
+
+#include "tabvwsh.hxx"
+#include "gridwin.hxx"
+#include "dbfunc.hxx"
+#include "viewdata.hxx"
+#include "output.hxx"
+#include "drawview.hxx"
+#include "fupoor.hxx"
+
+#include "drawutil.hxx"
+#include "document.hxx"
+#include "drwlayer.hxx"
+#include <vcl/svapp.hxx>
+
+// -----------------------------------------------------------------------
+
+BOOL ScGridWindow::DrawMouseButtonDown(const MouseEvent& rMEvt)
+{
+ BOOL bRet = FALSE;
+ FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
+ if (pDraw && !pViewData->IsRefMode())
+ {
+ pDraw->SetWindow( this );
+ Point aLogicPos = PixelToLogic(rMEvt.GetPosPixel());
+ if ( pDraw->IsDetectiveHit( aLogicPos ) )
+ {
+ // auf Detektiv-Pfeilen gar nichts (Doppelklick wird bei ButtonUp ausgewertet)
+ bRet = TRUE;
+ }
+ else
+ {
+ bRet = pDraw->MouseButtonDown( rMEvt );
+ if ( bRet )
+ UpdateStatusPosSize();
+ }
+ }
+
+ // bei rechter Taste Draw-Aktion abbrechen
+
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ if ( pDrView && !rMEvt.IsLeft() && !bRet )
+ {
+ pDrView->BrkAction();
+ bRet = TRUE;
+ }
+ return bRet;
+}
+
+BOOL ScGridWindow::DrawMouseButtonUp(const MouseEvent& rMEvt)
+{
+ ScViewFunc* pView = pViewData->GetView();
+ BOOL bRet = FALSE;
+ FuPoor* pDraw = pView->GetDrawFuncPtr();
+ if (pDraw && !pViewData->IsRefMode())
+ {
+ pDraw->SetWindow( this );
+ bRet = pDraw->MouseButtonUp( rMEvt );
+
+ // execute "format paint brush" for drawing objects
+ SfxItemSet* pDrawBrush = pView->GetDrawBrushSet();
+ if ( pDrawBrush )
+ {
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ if ( pDrView )
+ {
+ BOOL bReplaceAll = TRUE;
+ pDrView->SetAttrToMarked(*pDrawBrush, bReplaceAll);
+ }
+
+ if ( !pView->IsPaintBrushLocked() )
+ pView->ResetBrushDocument(); // end paint brush mode if not locked
+ }
+ }
+
+ return bRet;
+}
+
+BOOL ScGridWindow::DrawMouseMove(const MouseEvent& rMEvt)
+{
+ FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
+ if (pDraw && !pViewData->IsRefMode())
+ {
+ pDraw->SetWindow( this );
+ BOOL bRet = pDraw->MouseMove( rMEvt );
+ if ( bRet )
+ UpdateStatusPosSize();
+ return bRet;
+ }
+ else
+ {
+ SetPointer( Pointer( POINTER_ARROW ) );
+ return FALSE;
+ }
+}
+
+void ScGridWindow::DrawEndAction()
+{
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ if ( pDrView && pDrView->IsAction() )
+ pDrView->BrkAction();
+
+ FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
+ if (pDraw)
+ pDraw->StopDragTimer();
+
+ // ReleaseMouse beim Aufruf
+}
+
+BOOL ScGridWindow::DrawCommand(const CommandEvent& rCEvt)
+{
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
+ if (pDrView && pDraw && !pViewData->IsRefMode())
+ {
+ pDraw->SetWindow( this );
+ BYTE nUsed = pDraw->Command( rCEvt );
+ if( nUsed == SC_CMD_USED )
+ nButtonDown = 0; // MouseButtonUp wird verschluckt...
+ if( nUsed || pDrView->IsAction() )
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL ScGridWindow::DrawKeyInput(const KeyEvent& rKEvt)
+{
+ ScDrawView* pDrView = pViewData->GetScDrawView();
+ FuPoor* pDraw = pViewData->GetView()->GetDrawFuncPtr();
+ if (pDrView && pDraw && !pViewData->IsRefMode())
+ {
+ pDraw->SetWindow( this );
+ BOOL bOldMarked = pDrView->AreObjectsMarked();
+ if (pDraw->KeyInput( rKEvt ))
+ {
+ BOOL bLeaveDraw = FALSE;
+ BOOL bUsed = TRUE;
+ BOOL bNewMarked = pDrView->AreObjectsMarked();
+ if ( !pViewData->GetView()->IsDrawSelMode() )
+ if ( !bNewMarked )
+ {
+ pViewData->GetViewShell()->SetDrawShell( FALSE );
+ bLeaveDraw = TRUE;
+ if ( !bOldMarked &&
+ rKEvt.GetKeyCode().GetCode() == KEY_DELETE )
+ bUsed = FALSE; // nichts geloescht
+ }
+ if (!bLeaveDraw)
+ UpdateStatusPosSize(); // #108137# for moving/resizing etc. by keyboard
+ return bUsed;
+ }
+ }
+
+ return FALSE;
+}
+
+void ScGridWindow::DrawRedraw( ScOutputData& rOutputData, ScUpdateMode eMode, ULONG nLayer )
+{
+ // #109985#
+ const ScViewOptions& rOpts = pViewData->GetOptions();
+
+ // use new flags at SdrPaintView for hiding objects
+ const bool bDrawOle(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_OLE));
+ const bool bDrawChart(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_CHART));
+ const bool bDrawDraw(VOBJ_MODE_SHOW == rOpts.GetObjMode(VOBJ_TYPE_DRAW));
+
+ if(bDrawOle || bDrawChart || bDrawDraw)
+ {
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+
+ if(pDrView)
+ {
+ pDrView->setHideOle(!bDrawOle);
+ pDrView->setHideChart(!bDrawChart);
+ pDrView->setHideDraw(!bDrawDraw);
+ pDrView->setHideFormControl(!bDrawDraw);
+ }
+
+ if(SC_UPDATE_CHANGED == eMode)
+ {
+ rOutputData.DrawingSingle((sal_uInt16)nLayer);
+ }
+ else
+ {
+ rOutputData.DrawSelectiveObjects((sal_uInt16)nLayer);
+ }
+ }
+}
+
+void ScGridWindow::DrawSdrGrid( const Rectangle& rDrawingRect, OutputDevice* pContentDev )
+{
+ // Draw-Gitterlinien
+
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if ( pDrView && pDrView->IsGridVisible() )
+ {
+ SdrPageView* pPV = pDrView->GetSdrPageView();
+ DBG_ASSERT(pPV, "keine PageView");
+ if (pPV)
+ {
+ pContentDev->SetLineColor(COL_GRAY);
+
+ pPV->DrawPageViewGrid( *pContentDev, rDrawingRect );
+ }
+ }
+}
+
+MapMode ScGridWindow::GetDrawMapMode( BOOL bForce )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bNegativePage = pDoc->IsNegativePage( nTab );
+
+ MapMode aDrawMode = pViewData->GetLogicMode();
+
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if ( pDrView || bForce )
+ {
+ Fraction aScaleX;
+ Fraction aScaleY;
+ if (pDrView)
+ pDrView->GetScale( aScaleX, aScaleY );
+ else
+ {
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+ pDoc->GetTableArea( nTab, nEndCol, nEndRow );
+ if (nEndCol<20) nEndCol = 20;
+ if (nEndRow<20) nEndRow = 1000;
+ ScDrawUtil::CalcScale( pDoc, nTab, 0,0, nEndCol,nEndRow, this,
+ pViewData->GetZoomX(),pViewData->GetZoomY(),
+ pViewData->GetPPTX(),pViewData->GetPPTY(),
+ aScaleX,aScaleY );
+ }
+ aDrawMode.SetScaleX(aScaleX);
+ aDrawMode.SetScaleY(aScaleY);
+ }
+ aDrawMode.SetOrigin(Point());
+ Point aStartPos = pViewData->GetPixPos(eWhich);
+ if ( bNegativePage )
+ {
+ // RTL uses negative positions for drawing objects
+ aStartPos.X() = -aStartPos.X() + GetOutputSizePixel().Width() - 1;
+ }
+ aDrawMode.SetOrigin( PixelToLogic( aStartPos, aDrawMode ) );
+
+ return aDrawMode;
+}
+
+//BOOL ScGridWindow::DrawBeforeScroll()
+//{
+// ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+//
+// BOOL bXor = FALSE;
+// if (pDrView)
+// {
+// bXor=pDrView->IsShownXorVisible(this);
+// if (bXor) pDrView->HideShownXor(this);
+// }
+// return bXor;
+//}
+
+void ScGridWindow::DrawAfterScroll(/*BOOL bVal*/)
+{
+ Update(); // immer, damit das Verhalten mit/ohne DrawingLayer gleich ist
+
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if (pDrView)
+ {
+ //if (bVal)
+ // pDrView->ShowShownXor(this);
+
+ OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
+ if (pOlView && pOlView->GetWindow() == this)
+ pOlView->ShowCursor(FALSE); // ist beim Scrollen weggekommen
+ }
+}
+
+//void ScGridWindow::DrawMarks()
+//{
+// ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+// if (pDrView)
+// pDrView->DrawMarks(this);
+//}
+
+//BOOL ScGridWindow::NeedDrawMarks()
+//{
+// ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+// return pDrView && pDrView->IsMarkHdlShown() && pDrView->AreObjectsMarked();
+//}
+
+void ScGridWindow::CreateAnchorHandle(SdrHdlList& rHdl, const ScAddress& rAddress)
+{
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if (pDrView)
+ {
+ const ScViewOptions& rOpts = pViewData->GetOptions();
+ if(rOpts.GetOption( VOPT_ANCHOR ))
+ {
+ BOOL bNegativePage = pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() );
+ Point aPos = pViewData->GetScrPos( rAddress.Col(), rAddress.Row(), eWhich, TRUE );
+ aPos = PixelToLogic(aPos);
+ rHdl.AddHdl(new SdrHdl(aPos, bNegativePage ? HDL_ANCHOR_TR : HDL_ANCHOR));
+ }
+ }
+}
+
+SdrObject* ScGridWindow::GetEditObject()
+{
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if (pDrView)
+ {
+ OutlinerView* pOlView = pDrView->GetTextEditOutlinerView();
+ if (pOlView && pOlView->GetWindow() == this)
+ return pDrView->GetTextEditObject();
+ }
+
+ return NULL;
+}
+
+void ScGridWindow::UpdateStatusPosSize()
+{
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if (!pDrView)
+ return; // shouldn't be called in that case
+
+ SdrPageView* pPV = pDrView->GetSdrPageView();
+ if (!pPV)
+ return; // shouldn't be called in that case either
+
+ SfxItemSet aSet(pViewData->GetViewShell()->GetPool(), SID_ATTR_POSITION, SID_ATTR_SIZE);
+
+ // Fill items for position and size:
+ // #108137# show action rectangle during action,
+ // position and size of selected object(s) if something is selected,
+ // mouse position otherwise
+
+ BOOL bActionItem = FALSE;
+ if ( pDrView->IsAction() ) // action rectangle
+ {
+ Rectangle aRect;
+ pDrView->TakeActionRect( aRect );
+ if ( !aRect.IsEmpty() )
+ {
+ pPV->LogicToPagePos(aRect);
+ aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
+ aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
+ Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
+ bActionItem = TRUE;
+ }
+ }
+ if ( !bActionItem )
+ {
+ if ( pDrView->AreObjectsMarked() ) // selected objects
+ {
+ Rectangle aRect = pDrView->GetAllMarkedRect();
+ pPV->LogicToPagePos(aRect);
+ aSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) );
+ aSet.Put( SvxSizeItem( SID_ATTR_SIZE,
+ Size( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ) ) );
+ }
+ else // mouse position
+ {
+ Point aPos = PixelToLogic(aCurMousePos);
+ pPV->LogicToPagePos(aPos);
+ aSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) );
+ aSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
+ }
+ }
+
+ pViewData->GetBindings().SetState(aSet);
+}
+
+BOOL ScGridWindow::DrawHasMarkedObj()
+{
+ ScDrawView* p = pViewData->GetScDrawView();
+ return p ? p->AreObjectsMarked() : FALSE;
+}
+
+//void ScGridWindow::DrawStartTimer()
+//{
+ //ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ //if (pDrView)
+ //{
+ /* jetzt in DrawMarks
+ USHORT nWinNum = pDrView->FindWin(this);
+ if (nWinNum!=SDRVIEWWIN_NOTFOUND)
+ pDrView->AfterInitRedraw(nWinNum);
+ */
+
+ // pDrView->PostPaint();
+ // pDrView->RestartAfterPaintTimer();
+ //}
+//}
+
+void ScGridWindow::DrawMarkDropObj( SdrObject* pObj )
+{
+ ScDrawView* pDrView = pViewData->GetView()->GetScDrawView();
+ if (pDrView)
+ pDrView->MarkDropObj(pObj);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
new file mode 100644
index 000000000000..fb5158ad7363
--- /dev/null
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -0,0 +1,1939 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <svtools/colorcfg.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/printer.hxx>
+
+#include <svx/svdview.hxx>
+#include "tabvwsh.hxx"
+
+#include "gridwin.hxx"
+#include "viewdata.hxx"
+#include "output.hxx"
+#include "document.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx" // InvertSimple
+#include "dbcolect.hxx"
+#include "docoptio.hxx"
+#include "notemark.hxx"
+#include "dbfunc.hxx" // oder GetPageBreakData an die ViewData
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "rfindlst.hxx"
+#include "hiranges.hxx"
+#include "pagedata.hxx"
+#include "docpool.hxx"
+#include "globstr.hrc"
+#include "docsh.hxx" // oder GetSfxInPlaceObject
+#include "cbutton.hxx"
+#include "invmerge.hxx"
+#include "editutil.hxx"
+#include "inputopt.hxx"
+#include "fillinfo.hxx"
+#include "dpcontrol.hxx"
+#include "queryparam.hxx"
+#include "sc.hrc"
+#include <vcl/virdev.hxx>
+
+// #i74769#
+#include <svx/sdrpaintwindow.hxx>
+
+//------------------------------------------------------------------------
+
+void lcl_LimitRect( Rectangle& rRect, const Rectangle& rVisible )
+{
+ if ( rRect.Top() < rVisible.Top()-1 ) rRect.Top() = rVisible.Top()-1;
+// if ( rRect.Left() < rVisible.Left()-1 ) rRect.Left() = rVisible.Left()-1;
+ if ( rRect.Bottom() > rVisible.Bottom()+1 ) rRect.Bottom() = rVisible.Bottom()+1;
+// if ( rRect.Right() > rVisible.Right()+1 ) rRect.Right() = rVisible.Right()+1;
+
+ // #51122# auch wenn das inner-Rectangle nicht sichtbar ist, muss evtl.
+ // die Titelzeile gezeichnet werden, darum kein Rueckgabewert mehr.
+ // Wenn's weit daneben liegt, wird lcl_DrawOneFrame erst gar nicht gerufen.
+}
+
+void lcl_DrawOneFrame( OutputDevice* pDev, const Rectangle& rInnerPixel,
+ const String& rTitle, const Color& rColor, BOOL bTextBelow,
+ double nPPTX, double nPPTY, const Fraction& rZoomY,
+ ScDocument* pDoc, ScViewData* pButtonViewData, BOOL bLayoutRTL )
+{
+ // pButtonViewData wird nur benutzt, um die Button-Groesse zu setzen,
+ // darf ansonsten NULL sein!
+
+ Rectangle aInner = rInnerPixel;
+ if ( bLayoutRTL )
+ {
+ aInner.Left() = rInnerPixel.Right();
+ aInner.Right() = rInnerPixel.Left();
+ }
+
+ Rectangle aVisible( Point(0,0), pDev->GetOutputSizePixel() );
+ lcl_LimitRect( aInner, aVisible );
+
+ Rectangle aOuter = aInner;
+ long nHor = (long) ( SC_SCENARIO_HSPACE * nPPTX );
+ long nVer = (long) ( SC_SCENARIO_VSPACE * nPPTY );
+ aOuter.Left() -= nHor;
+ aOuter.Right() += nHor;
+ aOuter.Top() -= nVer;
+ aOuter.Bottom() += nVer;
+
+ // use ScPatternAttr::GetFont only for font size
+ Font aAttrFont;
+ ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).
+ GetFont(aAttrFont,SC_AUTOCOL_BLACK,pDev,&rZoomY);
+
+ // everything else from application font
+ Font aAppFont = pDev->GetSettings().GetStyleSettings().GetAppFont();
+ aAppFont.SetSize( aAttrFont.GetSize() );
+
+ aAppFont.SetAlign( ALIGN_TOP );
+ pDev->SetFont( aAppFont );
+
+ Size aTextSize( pDev->GetTextWidth( rTitle ), pDev->GetTextHeight() );
+
+ if ( bTextBelow )
+ aOuter.Bottom() += aTextSize.Height();
+ else
+ aOuter.Top() -= aTextSize.Height();
+
+ pDev->SetLineColor();
+ pDev->SetFillColor( rColor );
+ // links, oben, rechts, unten
+ pDev->DrawRect( Rectangle( aOuter.Left(), aOuter.Top(), aInner.Left(), aOuter.Bottom() ) );
+ pDev->DrawRect( Rectangle( aOuter.Left(), aOuter.Top(), aOuter.Right(), aInner.Top() ) );
+ pDev->DrawRect( Rectangle( aInner.Right(), aOuter.Top(), aOuter.Right(), aOuter.Bottom() ) );
+ pDev->DrawRect( Rectangle( aOuter.Left(), aInner.Bottom(), aOuter.Right(), aOuter.Bottom() ) );
+
+ long nButtonY = bTextBelow ? aInner.Bottom() : aOuter.Top();
+
+ ScDDComboBoxButton aComboButton((Window*)pDev);
+ aComboButton.SetOptSizePixel();
+ long nBWidth = ( aComboButton.GetSizePixel().Width() * rZoomY.GetNumerator() )
+ / rZoomY.GetDenominator();
+ long nBHeight = nVer + aTextSize.Height() + 1;
+ Size aButSize( nBWidth, nBHeight );
+ long nButtonPos = bLayoutRTL ? aOuter.Left() : aOuter.Right()-nBWidth+1;
+ aComboButton.Draw( Point(nButtonPos, nButtonY), aButSize, FALSE );
+ if (pButtonViewData)
+ pButtonViewData->SetScenButSize( aButSize );
+
+ long nTextStart = bLayoutRTL ? aInner.Right() - aTextSize.Width() + 1 : aInner.Left();
+
+ BOOL bWasClip = FALSE;
+ Region aOldClip;
+ BOOL bClip = ( aTextSize.Width() > aOuter.Right() - nBWidth - aInner.Left() );
+ if ( bClip )
+ {
+ if (pDev->IsClipRegion())
+ {
+ bWasClip = TRUE;
+ aOldClip = pDev->GetActiveClipRegion();
+ }
+ long nClipStartX = bLayoutRTL ? aOuter.Left() + nBWidth : aInner.Left();
+ long nClipEndX = bLayoutRTL ? aInner.Right() : aOuter.Right() - nBWidth;
+ pDev->SetClipRegion( Rectangle( nClipStartX, nButtonY + nVer/2,
+ nClipEndX, nButtonY + nVer/2 + aTextSize.Height() ) );
+ }
+
+ pDev->DrawText( Point( nTextStart, nButtonY + nVer/2 ), rTitle );
+
+ if ( bClip )
+ {
+ if ( bWasClip )
+ pDev->SetClipRegion(aOldClip);
+ else
+ pDev->SetClipRegion();
+ }
+
+ pDev->SetFillColor();
+ pDev->SetLineColor( COL_BLACK );
+ pDev->DrawRect( aInner );
+ pDev->DrawRect( aOuter );
+}
+
+void lcl_DrawScenarioFrames( OutputDevice* pDev, ScViewData* pViewData, ScSplitPos eWhich,
+ SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) )
+ {
+ if ( nX1 > 0 ) --nX1;
+ if ( nY1>=2 ) nY1 -= 2; // Hack: Titelzeile beruehrt zwei Zellen
+ else if ( nY1 > 0 ) --nY1;
+ if ( nX2 < MAXCOL ) ++nX2;
+ if ( nY2 < MAXROW-1 ) nY2 += 2; // Hack: Titelzeile beruehrt zwei Zellen
+ else if ( nY2 < MAXROW ) ++nY2;
+ ScRange aViewRange( nX1,nY1,nTab, nX2,nY2,nTab );
+
+ //! Ranges an der Table cachen!!!!
+
+ ScMarkData aMarks;
+ for (SCTAB i=nTab+1; i<nTabCount && pDoc->IsScenario(i); i++)
+ pDoc->MarkScenario( i, nTab, aMarks, FALSE, SC_SCENARIO_SHOWFRAME );
+ ScRangeListRef xRanges = new ScRangeList;
+ aMarks.FillRangeListWithMarks( xRanges, FALSE );
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ USHORT nRangeCount = (USHORT)xRanges->Count();
+ for (USHORT j=0; j<nRangeCount; j++)
+ {
+ ScRange aRange = *xRanges->GetObject(j);
+ // Szenario-Rahmen immer dann auf zusammengefasste Zellen erweitern, wenn
+ // dadurch keine neuen nicht-ueberdeckten Zellen mit umrandet werden
+ pDoc->ExtendTotalMerge( aRange );
+
+ //! -> Repaint beim Zusammenfassen erweitern !!!
+
+ if ( aRange.Intersects( aViewRange ) ) //! Platz fuer Text/Button?
+ {
+ Point aStartPos = pViewData->GetScrPos(
+ aRange.aStart.Col(), aRange.aStart.Row(), eWhich, TRUE );
+ Point aEndPos = pViewData->GetScrPos(
+ aRange.aEnd.Col()+1, aRange.aEnd.Row()+1, eWhich, TRUE );
+ // on the grid:
+ aStartPos.X() -= nLayoutSign;
+ aStartPos.Y() -= 1;
+ aEndPos.X() -= nLayoutSign;
+ aEndPos.Y() -= 1;
+
+ BOOL bTextBelow = ( aRange.aStart.Row() == 0 );
+
+ String aCurrent;
+ Color aColor( COL_LIGHTGRAY );
+ for (SCTAB nAct=nTab+1; nAct<nTabCount && pDoc->IsScenario(nAct); nAct++)
+ if ( pDoc->IsActiveScenario(nAct) && pDoc->HasScenarioRange(nAct,aRange) )
+ {
+ String aDummyComment;
+ USHORT nDummyFlags;
+ pDoc->GetName( nAct, aCurrent );
+ pDoc->GetScenarioData( nAct, aDummyComment, aColor, nDummyFlags );
+ }
+
+ if (!aCurrent.Len())
+ aCurrent = ScGlobal::GetRscString( STR_EMPTYDATA );
+
+ //! eigener Text "(keins)" statt "(leer)" ???
+
+ lcl_DrawOneFrame( pDev, Rectangle( aStartPos, aEndPos ),
+ aCurrent, aColor, bTextBelow,
+ pViewData->GetPPTX(), pViewData->GetPPTY(), pViewData->GetZoomY(),
+ pDoc, pViewData, bLayoutRTL );
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void lcl_DrawHighlight( ScOutputData& rOutputData, ScViewData* pViewData,
+ ScHighlightRanges& rHighlightRanges )
+{
+ SCTAB nTab = pViewData->GetTabNo();
+ ULONG nCount = rHighlightRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScHighlightEntry* pEntry = rHighlightRanges.GetObject( i );
+ if (pEntry)
+ {
+ ScRange aRange = pEntry->aRef;
+ if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
+ {
+ rOutputData.DrawRefMark(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(),
+ pEntry->aColor, FALSE );
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void ScGridWindow::DoInvertRect( const Rectangle& rPixel )
+{
+// Invert( PixelToLogic(rPixel) );
+
+ if ( rPixel == aInvertRect )
+ aInvertRect = Rectangle(); // aufheben
+ else
+ {
+ DBG_ASSERT( aInvertRect.IsEmpty(), "DoInvertRect nicht paarig" );
+
+ aInvertRect = rPixel; // neues Rechteck merken
+ }
+
+ UpdateHeaderOverlay(); // uses aInvertRect
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScGridWindow::PrePaint()
+{
+ // forward PrePaint to DrawingLayer
+ ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
+
+ if(pTabViewShell)
+ {
+ SdrView* pDrawView = pTabViewShell->GetSdrView();
+
+ if(pDrawView)
+ {
+ pDrawView->PrePaint();
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScGridWindow::Paint( const Rectangle& rRect )
+{
+ //TODO/LATER: how to get environment? Do we need that?!
+ /*
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ SvInPlaceEnvironment* pEnv = pDocSh->GetIPEnv();
+ if (pEnv && pEnv->GetRectsChangedLockCount())
+ {
+ Invalidate(rRect);
+ return;
+ }*/
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ if ( pDoc->IsInInterpreter() )
+ {
+ // via Reschedule, interpretierende Zellen nicht nochmal anstossen
+ // hier kein Invalidate, sonst kommt z.B. eine Error-Box nie an die Reihe
+ // (Bug 36381). Durch bNeedsRepaint wird spaeter alles nochmal gemalt.
+
+ if ( bNeedsRepaint )
+ {
+ //! Rechtecke zusammenfassen?
+ aRepaintPixel = Rectangle(); // mehrfach -> alles painten
+ }
+ else
+ {
+ bNeedsRepaint = TRUE;
+ aRepaintPixel = LogicToPixel(rRect); // nur betroffenen Bereich
+ }
+ return;
+ }
+
+ if (bIsInPaint)
+ return;
+
+ bIsInPaint = TRUE;
+
+ Rectangle aPixRect = LogicToPixel( rRect );
+
+ SCCOL nX1 = pViewData->GetPosX(eHWhich);
+ SCROW nY1 = pViewData->GetPosY(eVWhich);
+
+ SCTAB nTab = pViewData->GetTabNo();
+
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
+
+ Rectangle aMirroredPixel = aPixRect;
+ if ( pDoc->IsLayoutRTL( nTab ) )
+ {
+ // mirror and swap
+ long nWidth = GetSizePixel().Width();
+ aMirroredPixel.Left() = nWidth - 1 - aPixRect.Right();
+ aMirroredPixel.Right() = nWidth - 1 - aPixRect.Left();
+ }
+
+ long nScrX = ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ while ( nScrX <= aMirroredPixel.Left() && nX1 < MAXCOL )
+ {
+ ++nX1;
+ nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX1, nTab ), nPPTX );
+ }
+ SCCOL nX2 = nX1;
+ while ( nScrX <= aMirroredPixel.Right() && nX2 < MAXCOL )
+ {
+ ++nX2;
+ nScrX += ScViewData::ToPixel( pDoc->GetColWidth( nX2, nTab ), nPPTX );
+ }
+
+ long nScrY = 0;
+ ScViewData::AddPixelsWhile( nScrY, aPixRect.Top(), nY1, MAXROW, nPPTY, pDoc, nTab);
+ SCROW nY2 = nY1;
+ if (nScrY <= aPixRect.Bottom() && nY2 < MAXROW)
+ {
+ ++nY2;
+ ScViewData::AddPixelsWhile( nScrY, aPixRect.Bottom(), nY2, MAXROW, nPPTY, pDoc, nTab);
+ }
+
+ Draw( nX1,nY1,nX2,nY2, SC_UPDATE_MARKS ); // nicht weiterzeichnen
+
+ bIsInPaint = FALSE;
+}
+
+//
+// Draw ----------------------------------------------------------------
+//
+
+void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode )
+{
+ ScModule* pScMod = SC_MOD();
+ BOOL bTextWysiwyg = pScMod->GetInputOptions().GetTextWysiwyg();
+ BOOL bGridFirst = TRUE; //! entscheiden!!!
+
+ if (pViewData->IsMinimized())
+ return;
+
+ PutInOrder( nX1, nX2 );
+ PutInOrder( nY1, nY2 );
+
+ DBG_ASSERT( ValidCol(nX2) && ValidRow(nY2), "GridWin Draw Bereich zu gross" );
+
+ UpdateVisibleRange();
+
+ if (nX2 < maVisibleRange.mnCol1 || nY2 < maVisibleRange.mnRow1)
+ return;
+ // unsichtbar
+ if (nX1 < maVisibleRange.mnCol1)
+ nX1 = maVisibleRange.mnCol1;
+ if (nY1 < maVisibleRange.mnRow1)
+ nY1 = maVisibleRange.mnRow1;
+
+ if (nX1 > maVisibleRange.mnCol2 || nY1 > maVisibleRange.mnRow2)
+ return;
+
+ if (nX2 > maVisibleRange.mnCol2)
+ nX2 = maVisibleRange.mnCol2;
+ if (nY2 > maVisibleRange.mnRow2)
+ nY2 = maVisibleRange.mnRow2;
+
+ if ( eMode != SC_UPDATE_MARKS && nX2 < maVisibleRange.mnCol2)
+ nX2 = maVisibleRange.mnCol2; // zum Weiterzeichnen
+
+ // ab hier kein return mehr
+
+ ++nPaintCount; // merken, dass gemalt wird (wichtig beim Invertieren)
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ pDoc->ExtendHidden( nX1, nY1, nX2, nY2, nTab );
+
+ Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+ long nMirrorWidth = GetSizePixel().Width();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+ if ( bLayoutRTL )
+ {
+ long nEndPixel = pViewData->GetScrPos( nX2+1, maVisibleRange.mnRow1, eWhich ).X();
+ nMirrorWidth = aScrPos.X() - nEndPixel;
+ aScrPos.X() = nEndPixel + 1;
+ }
+
+ long nScrX = aScrPos.X();
+ long nScrY = aScrPos.Y();
+
+ SCCOL nCurX = pViewData->GetCurX();
+ SCROW nCurY = pViewData->GetCurY();
+ SCCOL nCurEndX = nCurX;
+ SCROW nCurEndY = nCurY;
+ pDoc->ExtendMerge( nCurX, nCurY, nCurEndX, nCurEndY, nTab );
+ BOOL bCurVis = nCursorHideCount==0 &&
+ ( nCurEndX+1 >= nX1 && nCurX <= nX2+1 && nCurEndY+1 >= nY1 && nCurY <= nY2+1 );
+
+ // AutoFill-Anfasser
+ if ( !bCurVis && nCursorHideCount==0 && bAutoMarkVisible && aAutoMarkPos.Tab() == nTab &&
+ ( aAutoMarkPos.Col() != nCurX || aAutoMarkPos.Row() != nCurY ) )
+ {
+ SCCOL nHdlX = aAutoMarkPos.Col();
+ SCROW nHdlY = aAutoMarkPos.Row();
+ pDoc->ExtendMerge( nHdlX, nHdlY, nHdlX, nHdlY, nTab );
+ bCurVis = ( nHdlX+1 >= nX1 && nHdlX <= nX2 && nHdlY+1 >= nY1 && nHdlY <= nY2 );
+ // links und oben ist nicht betroffen
+
+ //! AutoFill-Anfasser alleine (ohne Cursor) zeichnen ???
+ }
+
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
+
+ const ScViewOptions& rOpts = pViewData->GetOptions();
+ BOOL bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
+ BOOL bMarkClipped = rOpts.GetOption( VOPT_CLIPMARKS );
+
+ // Datenblock
+
+ ScTableInfo aTabInfo;
+ pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
+ nPPTX, nPPTY, FALSE, bFormulaMode,
+ &pViewData->GetMarkData() );
+
+ //--------------------------------------------------------------------
+
+ Fraction aZoomX = pViewData->GetZoomX();
+ Fraction aZoomY = pViewData->GetZoomY();
+ ScOutputData aOutputData( this, OUTTYPE_WINDOW, aTabInfo, pDoc, nTab,
+ nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
+ &aZoomX, &aZoomY );
+
+ aOutputData.SetMirrorWidth( nMirrorWidth ); // needed for RTL
+
+ std::auto_ptr< VirtualDevice > xFmtVirtDev;
+ BOOL bLogicText = bTextWysiwyg; // call DrawStrings in logic MapMode?
+
+ if ( bTextWysiwyg )
+ {
+ // use printer for text formatting
+
+ OutputDevice* pFmtDev = pDoc->GetPrinter();
+ pFmtDev->SetMapMode( pViewData->GetLogicMode(eWhich) );
+ aOutputData.SetFmtDevice( pFmtDev );
+ }
+ else if ( aZoomX != aZoomY && pViewData->IsOle() )
+ {
+ // #i45033# For OLE inplace editing with different zoom factors,
+ // use a virtual device with 1/100th mm as text formatting reference
+
+ xFmtVirtDev.reset( new VirtualDevice );
+ xFmtVirtDev->SetMapMode( MAP_100TH_MM );
+ aOutputData.SetFmtDevice( xFmtVirtDev.get() );
+
+ bLogicText = TRUE; // use logic MapMode
+ }
+
+ const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
+ Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID, FALSE ).nColor );
+ if ( aGridColor.GetColor() == COL_TRANSPARENT )
+ {
+ // use view options' grid color only if color config has "automatic" color
+ aGridColor = rOpts.GetGridColor();
+ }
+
+ aOutputData.SetSyntaxMode ( pViewData->IsSyntaxMode() );
+ aOutputData.SetGridColor ( aGridColor );
+ aOutputData.SetShowNullValues ( rOpts.GetOption( VOPT_NULLVALS ) );
+ aOutputData.SetShowFormulas ( bFormulaMode );
+ aOutputData.SetShowSpellErrors ( pDoc->GetDocOptions().IsAutoSpell() );
+ aOutputData.SetMarkClipped ( bMarkClipped );
+
+ aOutputData.SetUseStyleColor( TRUE ); // always set in table view
+
+ aOutputData.SetEditObject( GetEditObject() );
+ aOutputData.SetViewShell( pViewData->GetViewShell() );
+
+ BOOL bGrid = rOpts.GetOption( VOPT_GRID ) && pViewData->GetShowGrid();
+
+ BOOL bPage = rOpts.GetOption( VOPT_PAGEBREAKS );
+
+ if ( eMode == SC_UPDATE_CHANGED )
+ {
+ aOutputData.FindChanged();
+ aOutputData.SetSingleGrid(TRUE);
+ }
+
+ BOOL bPageMode = pViewData->IsPagebreakMode();
+ if (bPageMode) // nach FindChanged
+ {
+ // SetPagebreakMode initialisiert auch bPrinted Flags
+ aOutputData.SetPagebreakMode( pViewData->GetView()->GetPageBreakData() );
+ }
+
+ EditView* pEditView = NULL;
+ BOOL bEditMode = pViewData->HasEditView(eWhich);
+ if ( bEditMode && pViewData->GetRefTabNo() == nTab )
+ {
+ SCCOL nEditCol;
+ SCROW nEditRow;
+ pViewData->GetEditView( eWhich, pEditView, nEditCol, nEditRow );
+ SCCOL nEditEndCol = pViewData->GetEditEndCol();
+ SCROW nEditEndRow = pViewData->GetEditEndRow();
+
+ if ( nEditEndCol >= nX1 && nEditCol <= nX2 && nEditEndRow >= nY1 && nEditRow <= nY2 )
+ aOutputData.SetEditCell( nEditCol, nEditRow );
+ else
+ bEditMode = FALSE;
+ }
+
+ // define drawing layer map mode and paint rectangle
+ const MapMode aDrawMode = GetDrawMapMode();
+ Rectangle aDrawingRectLogic;
+
+ {
+ // get drawing pixel rect
+ Rectangle aDrawingRectPixel(Point(nScrX, nScrY), Size(aOutputData.GetScrW(), aOutputData.GetScrH()));
+
+ // correct for border (left/right)
+ if(MAXCOL == nX2)
+ {
+ if(bLayoutRTL)
+ {
+ aDrawingRectPixel.Left() = 0L;
+ }
+ else
+ {
+ aDrawingRectPixel.Right() = GetOutputSizePixel().getWidth();
+ }
+ }
+
+ // correct for border (bottom)
+ if(MAXROW == nY2)
+ {
+ aDrawingRectPixel.Bottom() = GetOutputSizePixel().getHeight();
+ }
+
+ // get logic positions
+ aDrawingRectLogic = PixelToLogic(aDrawingRectPixel, aDrawMode);
+ }
+
+ OutputDevice* pContentDev = this; // device for document content, used by overlay manager
+ SdrPaintWindow* pTargetPaintWindow = 0; // #i74769# work with SdrPaintWindow directly
+
+ {
+ // init redraw
+ ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
+
+ if(pTabViewShell)
+ {
+ MapMode aCurrentMapMode(pContentDev->GetMapMode());
+ pContentDev->SetMapMode(aDrawMode);
+ SdrView* pDrawView = pTabViewShell->GetSdrView();
+
+ if(pDrawView)
+ {
+ // #i74769# Use new BeginDrawLayers() interface
+ Region aDrawingRegion(aDrawingRectLogic);
+ pTargetPaintWindow = pDrawView->BeginDrawLayers(this, aDrawingRegion);
+ OSL_ENSURE(pTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
+
+ // #i74769# get target device from SdrPaintWindow, this may be the prerender
+ // device now, too.
+ pContentDev = &(pTargetPaintWindow->GetTargetOutputDevice());
+ aOutputData.SetContentDevice( pContentDev );
+ }
+
+ pContentDev->SetMapMode(aCurrentMapMode);
+ }
+ }
+
+ // Rand (Wiese) (Pixel)
+ if ( nX2==MAXCOL || nY2==MAXROW )
+ {
+ // save MapMode and set to pixel
+ MapMode aCurrentMapMode(pContentDev->GetMapMode());
+ pContentDev->SetMapMode(MAP_PIXEL);
+
+ Rectangle aPixRect = Rectangle( Point(), GetOutputSizePixel() );
+ pContentDev->SetFillColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
+ pContentDev->SetLineColor();
+ if ( nX2==MAXCOL )
+ {
+ Rectangle aDrawRect( aPixRect );
+ if ( bLayoutRTL )
+ aDrawRect.Right() = nScrX - 1;
+ else
+ aDrawRect.Left() = nScrX + aOutputData.GetScrW();
+ if (aDrawRect.Right() >= aDrawRect.Left())
+ pContentDev->DrawRect( aDrawRect );
+ }
+ if ( nY2==MAXROW )
+ {
+ Rectangle aDrawRect( aPixRect );
+ aDrawRect.Top() = nScrY + aOutputData.GetScrH();
+ if ( nX2==MAXCOL )
+ {
+ // no double painting of the corner
+ if ( bLayoutRTL )
+ aDrawRect.Left() = nScrX;
+ else
+ aDrawRect.Right() = nScrX + aOutputData.GetScrW() - 1;
+ }
+ if (aDrawRect.Bottom() >= aDrawRect.Top())
+ pContentDev->DrawRect( aDrawRect );
+ }
+
+ // restore MapMode
+ pContentDev->SetMapMode(aCurrentMapMode);
+ }
+
+ if ( pDoc->HasBackgroundDraw( nTab, aDrawingRectLogic ) )
+ {
+ pContentDev->SetMapMode(MAP_PIXEL);
+ aOutputData.DrawClear();
+
+ // Drawing Hintergrund
+
+ pContentDev->SetMapMode(aDrawMode);
+ DrawRedraw( aOutputData, eMode, SC_LAYER_BACK );
+ }
+ else
+ aOutputData.SetSolidBackground(TRUE);
+
+ pContentDev->SetMapMode(MAP_PIXEL);
+ aOutputData.DrawDocumentBackground();
+ if ( bGridFirst && ( bGrid || bPage ) )
+ aOutputData.DrawGrid( bGrid, bPage );
+ aOutputData.DrawBackground();
+ if ( bPageMode )
+ {
+ // #87655# DrawPagePreview draws complete lines/page numbers, must always be clipped
+ if ( aOutputData.SetChangedClip() )
+ {
+ DrawPagePreview(nX1,nY1,nX2,nY2, pContentDev);
+ pContentDev->SetClipRegion();
+ }
+ }
+ aOutputData.DrawShadow();
+ aOutputData.DrawFrame();
+ if ( !bLogicText )
+ aOutputData.DrawStrings(FALSE); // in pixel MapMode
+
+ // edit cells and printer-metrics text must be before the buttons
+ // (DataPilot buttons contain labels in UI font)
+
+ pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich));
+ if ( bLogicText )
+ aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set
+ aOutputData.DrawEdit(TRUE);
+ pContentDev->SetMapMode(MAP_PIXEL);
+
+ // Autofilter- und Pivot-Buttons
+
+ DrawButtons( nX1, nY1, nX2, nY2, aTabInfo, pContentDev ); // Pixel
+
+ // Notiz-Anzeiger
+
+ if ( rOpts.GetOption( VOPT_NOTES ) )
+ aOutputData.DrawNoteMarks();
+
+ if ( !bGridFirst && ( bGrid || bPage ) )
+ {
+ aOutputData.DrawGrid( bGrid, bPage );
+ }
+ aOutputData.DrawClipMarks();
+
+ // Szenario / ChangeTracking muss auf jeden Fall nach DrawGrid sein, auch bei !bGridFirst
+
+ //! Test, ob ChangeTrack-Anzeige aktiv ist
+ //! Szenario-Rahmen per View-Optionen abschaltbar?
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScHighlightRanges* pHigh = pViewData->GetView()->GetHighlightRanges();
+ BOOL bHasScenario = ( nTab+1<nTabCount && pDoc->IsScenario(nTab+1) && !pDoc->IsScenario(nTab) );
+ BOOL bHasChange = ( pDoc->GetChangeTrack() != NULL );
+
+ if ( bHasChange || bHasScenario || pHigh != NULL )
+ {
+
+ //! SetChangedClip() mit DrawMarks() zusammenfassen?? (anderer MapMode!)
+
+ BOOL bAny = TRUE;
+ if (eMode == SC_UPDATE_CHANGED)
+ bAny = aOutputData.SetChangedClip();
+ if (bAny)
+ {
+ if ( bHasChange )
+ aOutputData.DrawChangeTrack();
+
+ if ( bHasScenario )
+ lcl_DrawScenarioFrames( pContentDev, pViewData, eWhich, nX1,nY1,nX2,nY2 );
+
+ if ( pHigh )
+ lcl_DrawHighlight( aOutputData, pViewData, *pHigh );
+
+ if (eMode == SC_UPDATE_CHANGED)
+ pContentDev->SetClipRegion();
+ }
+ }
+
+ // Drawing Vordergrund
+
+ pContentDev->SetMapMode(aDrawMode);
+
+ DrawRedraw( aOutputData, eMode, SC_LAYER_FRONT );
+ DrawRedraw( aOutputData, eMode, SC_LAYER_INTERN );
+ DrawSdrGrid( aDrawingRectLogic, pContentDev );
+
+ if (!bIsInScroll) // Drawing Markierungen
+ {
+ if(eMode == SC_UPDATE_CHANGED && aOutputData.SetChangedClip())
+ {
+ pContentDev->SetClipRegion();
+ }
+ }
+
+ pContentDev->SetMapMode(MAP_PIXEL);
+
+#ifdef OLD_SELECTION_PAINT
+ if (pViewData->IsActive())
+ aOutputData.DrawMark( this );
+#endif
+
+ if ( pViewData->IsRefMode() && nTab >= pViewData->GetRefStartZ() && nTab <= pViewData->GetRefEndZ() )
+ {
+ Color aRefColor( rColorCfg.GetColorValue(svtools::CALCREFERENCE).nColor );
+ aOutputData.DrawRefMark( pViewData->GetRefStartX(), pViewData->GetRefStartY(),
+ pViewData->GetRefEndX(), pViewData->GetRefEndY(),
+ aRefColor, FALSE );
+ }
+
+ // Range-Finder
+
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
+ if (pHdl)
+ {
+ ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
+ if ( pRangeFinder && !pRangeFinder->IsHidden() &&
+ pRangeFinder->GetDocName() == pDocSh->GetTitle() )
+ {
+ USHORT nCount = (USHORT)pRangeFinder->Count();
+ for (USHORT i=0; i<nCount; i++)
+ {
+ ScRangeFindData* pData = pRangeFinder->GetObject(i);
+ if (pData)
+ {
+ ScRange aRef = pData->aRef;
+ aRef.Justify();
+ if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
+ aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(),
+ aRef.aEnd.Col(), aRef.aEnd.Row(),
+ Color( ScRangeFindList::GetColorName( i ) ),
+ TRUE );
+ }
+ }
+ }
+ }
+
+ {
+ // end redraw
+ ScTabViewShell* pTabViewShell = pViewData->GetViewShell();
+
+ if(pTabViewShell)
+ {
+ MapMode aCurrentMapMode(pContentDev->GetMapMode());
+ pContentDev->SetMapMode(aDrawMode);
+ SdrView* pDrawView = pTabViewShell->GetSdrView();
+
+ if(pDrawView)
+ {
+ // #i74769# work with SdrPaintWindow directly
+ pDrawView->EndDrawLayers(*pTargetPaintWindow, true);
+ }
+
+ pContentDev->SetMapMode(aCurrentMapMode);
+ }
+ }
+
+ // InPlace Edit-View
+ // moved after EndDrawLayers() to get it outside the overlay buffer and
+ // on top of everything
+ if ( bEditMode && (pViewData->GetRefTabNo() == pViewData->GetTabNo()) )
+ {
+ //! use pContentDev for EditView?
+ SetMapMode(MAP_PIXEL);
+ SCCOL nCol1 = pViewData->GetEditStartCol();
+ SCROW nRow1 = pViewData->GetEditStartRow();
+ SCCOL nCol2 = pViewData->GetEditEndCol();
+ SCROW nRow2 = pViewData->GetEditEndRow();
+ SetLineColor();
+ SetFillColor( pEditView->GetBackgroundColor() );
+ Point aStart = pViewData->GetScrPos( nCol1, nRow1, eWhich );
+ Point aEnd = pViewData->GetScrPos( nCol2+1, nRow2+1, eWhich );
+ aEnd.X() -= 2 * nLayoutSign; // don't overwrite grid
+ aEnd.Y() -= 2;
+ DrawRect( Rectangle( aStart,aEnd ) );
+
+ SetMapMode(pViewData->GetLogicMode());
+ pEditView->Paint( PixelToLogic( Rectangle( Point( nScrX, nScrY ),
+ Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) ) );
+ SetMapMode(MAP_PIXEL);
+ }
+
+ if (pViewData->HasEditView(eWhich))
+ {
+ // flush OverlayManager before changing the MapMode
+ flushOverlayManager();
+
+ // set MapMode for text edit
+ SetMapMode(pViewData->GetLogicMode());
+ }
+ else
+ SetMapMode(aDrawMode);
+
+ if ( pNoteMarker )
+ pNoteMarker->Draw(); // ueber den Cursor, im Drawing-MapMode
+
+ //
+ // Wenn waehrend des Paint etwas invertiert wurde (Selektion geaendert aus Basic-Macro),
+ // ist das jetzt durcheinandergekommen und es muss neu gemalt werden
+ //
+
+ DBG_ASSERT(nPaintCount, "nPaintCount falsch");
+ --nPaintCount;
+ if (!nPaintCount)
+ CheckNeedsRepaint();
+}
+
+void ScGridWindow::CheckNeedsRepaint()
+{
+ // called at the end of painting, and from timer after background text width calculation
+
+ if (bNeedsRepaint)
+ {
+ bNeedsRepaint = FALSE;
+ if (aRepaintPixel.IsEmpty())
+ Invalidate();
+ else
+ Invalidate(PixelToLogic(aRepaintPixel));
+ aRepaintPixel = Rectangle();
+
+ // selection function in status bar might also be invalid
+ SfxBindings& rBindings = pViewData->GetBindings();
+ rBindings.Invalidate( SID_STATUS_SUM );
+ rBindings.Invalidate( SID_ATTR_SIZE );
+ rBindings.Invalidate( SID_TABLE_CELL );
+ }
+}
+
+void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, OutputDevice* pContentDev )
+{
+ ScPageBreakData* pPageData = pViewData->GetView()->GetPageBreakData();
+ if (pPageData)
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ Size aWinSize = GetOutputSizePixel();
+ const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
+ Color aManual( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKMANUAL).nColor );
+ Color aAutomatic( rColorCfg.GetColorValue(svtools::CALCPAGEBREAK).nColor );
+
+ String aPageStr = ScGlobal::GetRscString( STR_PGNUM );
+ if ( nPageScript == 0 )
+ {
+ // get script type of translated "Page" string only once
+ nPageScript = pDoc->GetStringScriptType( aPageStr );
+ if (nPageScript == 0)
+ nPageScript = ScGlobal::GetDefaultScriptType();
+ }
+
+ Font aFont;
+ ScEditEngineDefaulter* pEditEng = NULL;
+ const ScPatternAttr& rDefPattern = ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN));
+ if ( nPageScript == SCRIPTTYPE_LATIN )
+ {
+ // use single font and call DrawText directly
+ rDefPattern.GetFont( aFont, SC_AUTOCOL_BLACK );
+ aFont.SetColor( Color( COL_LIGHTGRAY ) );
+ // font size is set as needed
+ }
+ else
+ {
+ // use EditEngine to draw mixed-script string
+ pEditEng = new ScEditEngineDefaulter( EditEngine::CreatePool(), TRUE );
+ pEditEng->SetRefMapMode( pContentDev->GetMapMode() );
+ SfxItemSet* pEditDefaults = new SfxItemSet( pEditEng->GetEmptyItemSet() );
+ rDefPattern.FillEditItemSet( pEditDefaults );
+ pEditDefaults->Put( SvxColorItem( Color( COL_LIGHTGRAY ), EE_CHAR_COLOR ) );
+ pEditEng->SetDefaults( pEditDefaults );
+ }
+
+ USHORT nCount = sal::static_int_cast<USHORT>( pPageData->GetCount() );
+ for (USHORT nPos=0; nPos<nCount; nPos++)
+ {
+ ScPrintRangeData& rData = pPageData->GetData(nPos);
+ ScRange aRange = rData.GetPrintRange();
+ if ( aRange.aStart.Col() <= nX2+1 && aRange.aEnd.Col()+1 >= nX1 &&
+ aRange.aStart.Row() <= nY2+1 && aRange.aEnd.Row()+1 >= nY1 )
+ {
+ // 3 Pixel Rahmen um den Druckbereich
+ // (mittlerer Pixel auf den Gitterlinien)
+
+ pContentDev->SetLineColor();
+ if (rData.IsAutomatic())
+ pContentDev->SetFillColor( aAutomatic );
+ else
+ pContentDev->SetFillColor( aManual );
+
+ Point aStart = pViewData->GetScrPos(
+ aRange.aStart.Col(), aRange.aStart.Row(), eWhich, TRUE );
+ Point aEnd = pViewData->GetScrPos(
+ aRange.aEnd.Col() + 1, aRange.aEnd.Row() + 1, eWhich, TRUE );
+ aStart.X() -= 2;
+ aStart.Y() -= 2;
+
+ // Ueberlaeufe verhindern:
+ if ( aStart.X() < -10 ) aStart.X() = -10;
+ if ( aStart.Y() < -10 ) aStart.Y() = -10;
+ if ( aEnd.X() > aWinSize.Width() + 10 )
+ aEnd.X() = aWinSize.Width() + 10;
+ if ( aEnd.Y() > aWinSize.Height() + 10 )
+ aEnd.Y() = aWinSize.Height() + 10;
+
+ pContentDev->DrawRect( Rectangle( aStart, Point(aEnd.X(),aStart.Y()+2) ) );
+ pContentDev->DrawRect( Rectangle( aStart, Point(aStart.X()+2,aEnd.Y()) ) );
+ pContentDev->DrawRect( Rectangle( Point(aStart.X(),aEnd.Y()-2), aEnd ) );
+ pContentDev->DrawRect( Rectangle( Point(aEnd.X()-2,aStart.Y()), aEnd ) );
+
+ // Seitenumbrueche
+ //! anders darstellen (gestrichelt ????)
+
+ size_t nColBreaks = rData.GetPagesX();
+ const SCCOL* pColEnd = rData.GetPageEndX();
+ size_t nColPos;
+ for (nColPos=0; nColPos+1<nColBreaks; nColPos++)
+ {
+ SCCOL nBreak = pColEnd[nColPos]+1;
+ if ( nBreak >= nX1 && nBreak <= nX2+1 )
+ {
+ //! hidden suchen
+ if (pDoc->HasColBreak(nBreak, nTab) & BREAK_MANUAL)
+ pContentDev->SetFillColor( aManual );
+ else
+ pContentDev->SetFillColor( aAutomatic );
+ Point aBreak = pViewData->GetScrPos(
+ nBreak, aRange.aStart.Row(), eWhich, TRUE );
+ pContentDev->DrawRect( Rectangle( aBreak.X()-1, aStart.Y(), aBreak.X(), aEnd.Y() ) );
+ }
+ }
+
+ size_t nRowBreaks = rData.GetPagesY();
+ const SCROW* pRowEnd = rData.GetPageEndY();
+ size_t nRowPos;
+ for (nRowPos=0; nRowPos+1<nRowBreaks; nRowPos++)
+ {
+ SCROW nBreak = pRowEnd[nRowPos]+1;
+ if ( nBreak >= nY1 && nBreak <= nY2+1 )
+ {
+ //! hidden suchen
+ if (pDoc->HasRowBreak(nBreak, nTab) & BREAK_MANUAL)
+ pContentDev->SetFillColor( aManual );
+ else
+ pContentDev->SetFillColor( aAutomatic );
+ Point aBreak = pViewData->GetScrPos(
+ aRange.aStart.Col(), nBreak, eWhich, TRUE );
+ pContentDev->DrawRect( Rectangle( aStart.X(), aBreak.Y()-1, aEnd.X(), aBreak.Y() ) );
+ }
+ }
+
+ // Seitenzahlen
+
+ SCROW nPrStartY = aRange.aStart.Row();
+ for (nRowPos=0; nRowPos<nRowBreaks; nRowPos++)
+ {
+ SCROW nPrEndY = pRowEnd[nRowPos];
+ if ( nPrEndY >= nY1 && nPrStartY <= nY2 )
+ {
+ SCCOL nPrStartX = aRange.aStart.Col();
+ for (nColPos=0; nColPos<nColBreaks; nColPos++)
+ {
+ SCCOL nPrEndX = pColEnd[nColPos];
+ if ( nPrEndX >= nX1 && nPrStartX <= nX2 )
+ {
+ Point aPageStart = pViewData->GetScrPos(
+ nPrStartX, nPrStartY, eWhich, TRUE );
+ Point aPageEnd = pViewData->GetScrPos(
+ nPrEndX+1,nPrEndY+1, eWhich, TRUE );
+
+ long nPageNo = rData.GetFirstPage();
+ if ( rData.IsTopDown() )
+ nPageNo += ((long)nColPos)*nRowBreaks+nRowPos;
+ else
+ nPageNo += ((long)nRowPos)*nColBreaks+nColPos;
+ aPageStr.SearchAndReplaceAscii("%1", String::CreateFromInt32(nPageNo));
+
+ if ( pEditEng )
+ {
+ // find right font size with EditEngine
+ long nHeight = 100;
+ pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
+ pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+ pEditEng->SetText( aPageStr );
+ Size aSize100( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
+
+ // 40% of width or 60% of height
+ long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
+ long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height();
+ nHeight = Min(nSizeX,nSizeY);
+ pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
+ pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ pEditEng->SetDefaultItem( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+
+ // centered output with EditEngine
+ Size aTextSize( pEditEng->CalcTextWidth(), pEditEng->GetTextHeight() );
+ Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
+ (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
+ pEditEng->Draw( pContentDev, aPos );
+ }
+ else
+ {
+ // find right font size for DrawText
+ aFont.SetSize( Size( 0,100 ) );
+ pContentDev->SetFont( aFont );
+ Size aSize100( pContentDev->GetTextWidth( aPageStr ), pContentDev->GetTextHeight() );
+
+ // 40% of width or 60% of height
+ long nSizeX = 40 * ( aPageEnd.X() - aPageStart.X() ) / aSize100.Width();
+ long nSizeY = 60 * ( aPageEnd.Y() - aPageStart.Y() ) / aSize100.Height();
+ aFont.SetSize( Size( 0,Min(nSizeX,nSizeY) ) );
+ pContentDev->SetFont( aFont );
+
+ // centered output with DrawText
+ Size aTextSize( pContentDev->GetTextWidth( aPageStr ), pContentDev->GetTextHeight() );
+ Point aPos( (aPageStart.X()+aPageEnd.X()-aTextSize.Width())/2,
+ (aPageStart.Y()+aPageEnd.Y()-aTextSize.Height())/2 );
+ pContentDev->DrawText( aPos, aPageStr );
+ }
+ }
+ nPrStartX = nPrEndX + 1;
+ }
+ }
+ nPrStartY = nPrEndY + 1;
+ }
+ }
+ }
+
+ delete pEditEng;
+ }
+}
+
+void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2*/, ScTableInfo& rTabInfo, OutputDevice* pContentDev )
+{
+ aComboButton.SetOutputDevice( pContentDev );
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc);
+
+ SCCOL nCol;
+ SCROW nRow;
+ SCSIZE nArrY;
+ SCSIZE nQuery;
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDBData* pDBData = NULL;
+ ScQueryParam* pQueryParam = NULL;
+
+ RowInfo* pRowInfo = rTabInfo.mpRowInfo;
+ USHORT nArrCount = rTabInfo.mnArrCount;
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ Point aOldPos = aComboButton.GetPosPixel(); // Zustand fuer MouseDown/Up
+ Size aOldSize = aComboButton.GetSizePixel(); // merken
+
+ for (nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ if ( pRowInfo[nArrY].bAutoFilter && pRowInfo[nArrY].bChanged )
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+
+ nRow = pThisRowInfo->nRowNo;
+
+
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
+ if ( pInfo->bAutoFilter && !pInfo->bHOverlapped && !pInfo->bVOverlapped )
+ {
+ if (!pQueryParam)
+ pQueryParam = new ScQueryParam;
+
+ BOOL bNewData = TRUE;
+ if (pDBData)
+ {
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nAreaTab;
+ pDBData->GetArea( nAreaTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ if ( nCol >= nStartCol && nCol <= nEndCol &&
+ nRow >= nStartRow && nRow <= nEndRow )
+ bNewData = FALSE;
+ }
+ if (bNewData)
+ {
+ pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
+ if (pDBData)
+ pDBData->GetQueryParam( *pQueryParam );
+ else
+ {
+ // can also be part of DataPilot table
+ // DBG_ERROR("Auto-Filter-Button ohne DBData");
+ }
+ }
+
+ // pQueryParam kann nur MAXQUERY Eintraege enthalten
+
+ BOOL bSimpleQuery = TRUE;
+ BOOL bColumnFound = FALSE;
+ if (!pQueryParam->bInplace)
+ bSimpleQuery = FALSE;
+ for (nQuery=0; nQuery<MAXQUERY && bSimpleQuery; nQuery++)
+ if (pQueryParam->GetEntry(nQuery).bDoQuery)
+ {
+ // hier nicht auf EQUAL beschraenken
+ // (auch bei ">1" soll der Spaltenkopf blau werden)
+
+ if (pQueryParam->GetEntry(nQuery).nField == nCol)
+ bColumnFound = TRUE;
+ if (nQuery > 0)
+ if (pQueryParam->GetEntry(nQuery).eConnect != SC_AND)
+ bSimpleQuery = FALSE;
+ }
+
+ bool bArrowState = bSimpleQuery && bColumnFound;
+ long nSizeX;
+ long nSizeY;
+ pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+ Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+
+ aCellBtn.setBoundingBox(aScrPos, Size(nSizeX-1, nSizeY-1), bLayoutRTL);
+ aCellBtn.setPopupLeft(bLayoutRTL); // #i114944# AutoFilter button is left-aligned in RTL
+ aCellBtn.setDrawBaseButton(false);
+ aCellBtn.setDrawPopupButton(true);
+ aCellBtn.setHasHiddenMember(bArrowState);
+ aCellBtn.draw();
+ }
+ }
+ }
+
+ if ( pRowInfo[nArrY].bPushButton && pRowInfo[nArrY].bChanged )
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ nRow = pThisRowInfo->nRowNo;
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nCol+1];
+ if ( pInfo->bPushButton && !pInfo->bHOverlapped && !pInfo->bVOverlapped )
+ {
+ Point aScrPos = pViewData->GetScrPos( nCol, nRow, eWhich );
+ long nSizeX;
+ long nSizeY;
+ pViewData->GetMergeSizePixel( nCol, nRow, nSizeX, nSizeY );
+ long nPosX = aScrPos.X();
+ long nPosY = aScrPos.Y();
+ // bLayoutRTL is handled in setBoundingBox
+
+ String aStr;
+ pDoc->GetString(nCol, nRow, nTab, aStr);
+ aCellBtn.setText(aStr);
+ aCellBtn.setBoundingBox(Point(nPosX, nPosY), Size(nSizeX-1, nSizeY-1), bLayoutRTL);
+ aCellBtn.setPopupLeft(false); // DataPilot popup is always right-aligned for now
+ aCellBtn.setDrawBaseButton(true);
+ aCellBtn.setDrawPopupButton(pInfo->bPopupButton);
+ aCellBtn.setHasHiddenMember(pInfo->bFilterActive);
+ aCellBtn.draw();
+ }
+ }
+ }
+
+ if ( bListValButton && pRowInfo[nArrY].nRowNo == aListValPos.Row() && pRowInfo[nArrY].bChanged )
+ {
+ Rectangle aRect = GetListValButtonRect( aListValPos );
+ aComboButton.SetPosPixel( aRect.TopLeft() );
+ aComboButton.SetSizePixel( aRect.GetSize() );
+ pContentDev->SetClipRegion( aRect );
+ aComboButton.Draw( FALSE, FALSE );
+ pContentDev->SetClipRegion(); // always called from Draw() without clip region
+ aComboButton.SetPosPixel( aOldPos ); // restore old state
+ aComboButton.SetSizePixel( aOldSize ); // for MouseUp/Down (AutoFilter)
+ }
+ }
+
+ delete pQueryParam;
+ aComboButton.SetOutputDevice( this );
+}
+
+Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ ScDDComboBoxButton aButton( this ); // for optimal size
+ Size aBtnSize = aButton.GetSizePixel();
+
+ SCCOL nCol = rButtonPos.Col();
+ SCROW nRow = rButtonPos.Row();
+
+ long nCellSizeX; // width of this cell, including merged
+ long nDummy;
+ pViewData->GetMergeSizePixel( nCol, nRow, nCellSizeX, nDummy );
+
+ // for height, only the cell's row is used, excluding merged cells
+ long nCellSizeY = ScViewData::ToPixel( pDoc->GetRowHeight( nRow, nTab ), pViewData->GetPPTY() );
+ long nAvailable = nCellSizeX;
+
+ // left edge of next cell if there is a non-hidden next column
+ SCCOL nNextCol = nCol + 1;
+ const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE ));
+ if ( pMerge->GetColMerge() > 1 )
+ nNextCol = nCol + pMerge->GetColMerge(); // next cell after the merged area
+ while ( nNextCol <= MAXCOL && pDoc->ColHidden(nNextCol, nTab) )
+ ++nNextCol;
+ BOOL bNextCell = ( nNextCol <= MAXCOL );
+ if ( bNextCell )
+ nAvailable = ScViewData::ToPixel( pDoc->GetColWidth( nNextCol, nTab ), pViewData->GetPPTX() );
+
+ if ( nAvailable < aBtnSize.Width() )
+ aBtnSize.Width() = nAvailable;
+ if ( nCellSizeY < aBtnSize.Height() )
+ aBtnSize.Height() = nCellSizeY;
+
+ Point aPos = pViewData->GetScrPos( nCol, nRow, eWhich, TRUE );
+ aPos.X() += nCellSizeX * nLayoutSign; // start of next cell
+ if (!bNextCell)
+ aPos.X() -= aBtnSize.Width() * nLayoutSign; // right edge of cell if next cell not available
+ aPos.Y() += nCellSizeY - aBtnSize.Height();
+ // X remains at the left edge
+
+ if ( bLayoutRTL )
+ aPos.X() -= aBtnSize.Width()-1; // align right edge of button with cell border
+
+ return Rectangle( aPos, aBtnSize );
+}
+
+BOOL ScGridWindow::IsAutoFilterActive( SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDBData* pDBData = pDoc->GetDBAtCursor( nCol, nRow, nTab );
+ ScQueryParam aQueryParam;
+
+ if ( pDBData )
+ pDBData->GetQueryParam( aQueryParam );
+ else
+ {
+ DBG_ERROR("Auto-Filter-Button ohne DBData");
+ }
+
+ BOOL bSimpleQuery = TRUE;
+ BOOL bColumnFound = FALSE;
+ SCSIZE nQuery;
+
+ if ( !aQueryParam.bInplace )
+ bSimpleQuery = FALSE;
+
+ // aQueryParam kann nur MAXQUERY Eintraege enthalten
+
+ for ( nQuery=0; nQuery<MAXQUERY && bSimpleQuery; nQuery++ )
+ if ( aQueryParam.GetEntry(nQuery).bDoQuery )
+ {
+ if (aQueryParam.GetEntry(nQuery).nField == nCol)
+ bColumnFound = TRUE;
+
+ if (nQuery > 0)
+ if (aQueryParam.GetEntry(nQuery).eConnect != SC_AND)
+ bSimpleQuery = FALSE;
+ }
+
+ return ( bSimpleQuery && bColumnFound );
+}
+
+void ScGridWindow::DrawComboButton( const Point& rCellPos,
+ long nCellSizeX,
+ long nCellSizeY,
+ BOOL bArrowState,
+ BOOL bBtnIn )
+{
+ Point aScrPos = rCellPos;
+ Size aBtnSize = aComboButton.GetSizePixel();
+
+ if ( nCellSizeX < aBtnSize.Width() || nCellSizeY < aBtnSize.Height() )
+ {
+ if ( nCellSizeX < aBtnSize.Width() )
+ aBtnSize.Width() = nCellSizeX;
+
+ if ( nCellSizeY < aBtnSize.Height() )
+ aBtnSize.Height() = nCellSizeY;
+
+ aComboButton.SetSizePixel( aBtnSize );
+ }
+
+ BOOL bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+
+ if ( bLayoutRTL )
+ aScrPos.X() -= nCellSizeX - 1;
+ else
+ aScrPos.X() += nCellSizeX - aBtnSize.Width();
+ aScrPos.Y() += nCellSizeY - aBtnSize.Height();
+
+ aComboButton.SetPosPixel( aScrPos );
+
+ HideCursor();
+ aComboButton.Draw( bArrowState, bBtnIn );
+ ShowCursor();
+}
+
+void ScGridWindow::InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ BOOL bTestMerge, BOOL bRepeat )
+{
+ //! if INVERT_HIGHLIGHT swaps foreground and background (like on Mac),
+ //! use INVERT_HIGHLIGHT only for cells that have no background color set
+ //! (here and in ScOutputData::DrawMark)
+
+ PutInOrder( nX1, nX2 );
+ PutInOrder( nY1, nY2 );
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ SCCOL nTestX2 = nX2;
+ SCROW nTestY2 = nY2;
+ if (bTestMerge)
+ pDoc->ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab );
+
+ SCCOL nPosX = pViewData->GetPosX( eHWhich );
+ SCROW nPosY = pViewData->GetPosY( eVWhich );
+ if (nTestX2 < nPosX || nTestY2 < nPosY)
+ return; // unsichtbar
+ SCCOL nRealX1 = nX1;
+ if (nX1 < nPosX)
+ nX1 = nPosX;
+ if (nY1 < nPosY)
+ nY1 = nPosY;
+
+ SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
+ if (nXRight > MAXCOL) nXRight = MAXCOL;
+ SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
+ if (nYBottom > MAXROW) nYBottom = MAXROW;
+
+ if (nX1 > nXRight || nY1 > nYBottom)
+ return; // unsichtbar
+ if (nX2 > nXRight) nX2 = nXRight;
+ if (nY2 > nYBottom) nY2 = nYBottom;
+
+ MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL); // erst nach den return's !!!
+
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
+
+ ScInvertMerger aInvert( this );
+
+ Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+ long nScrY = aScrPos.Y();
+ BOOL bWasHidden = FALSE;
+ for (SCROW nY=nY1; nY<=nY2; nY++)
+ {
+ BOOL bFirstRow = ( nY == nPosY ); // first visible row?
+ BOOL bDoHidden = FALSE; // versteckte nachholen ?
+ USHORT nHeightTwips = pDoc->GetRowHeight( nY,nTab );
+ BOOL bDoRow = ( nHeightTwips != 0 );
+ if (bDoRow)
+ {
+ if (bTestMerge)
+ if (bWasHidden) // auf versteckte zusammengefasste testen
+ {
+// --nY; // nY geaendert -> vorherige zeichnen
+ bDoHidden = TRUE;
+ bDoRow = TRUE;
+ }
+
+ bWasHidden = FALSE;
+ }
+ else
+ {
+ bWasHidden = TRUE;
+ if (bTestMerge)
+ if (nY==nY2)
+ bDoRow = TRUE; // letzte Zeile aus Block
+ }
+
+ if ( bDoRow )
+ {
+ SCCOL nLoopEndX = nX2;
+ if (nX2 < nX1) // Rest von zusammengefasst
+ {
+ SCCOL nStartX = nX1;
+ while ( ((const ScMergeFlagAttr*)pDoc->
+ GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG))->IsHorOverlapped() )
+ --nStartX;
+ if (nStartX <= nX2)
+ nLoopEndX = nX1;
+ }
+
+ long nEndY = nScrY + ScViewData::ToPixel( nHeightTwips, nPPTY ) - 1;
+ long nScrX = aScrPos.X();
+ for (SCCOL nX=nX1; nX<=nLoopEndX; nX++)
+ {
+ long nWidth = ScViewData::ToPixel( pDoc->GetColWidth( nX,nTab ), nPPTX );
+ if ( nWidth > 0 )
+ {
+ long nEndX = nScrX + ( nWidth - 1 ) * nLayoutSign;
+ if (bTestMerge)
+ {
+ SCROW nThisY = nY;
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab );
+ const ScMergeFlagAttr* pMergeFlag = (const ScMergeFlagAttr*) &pPattern->
+ GetItem(ATTR_MERGE_FLAG);
+ if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) )
+ {
+ while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 &&
+ (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) )
+ {
+ --nThisY;
+ pPattern = pDoc->GetPattern( nX, nThisY, nTab );
+ pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
+ }
+ }
+
+ // nur Rest von zusammengefasster zu sehen ?
+ SCCOL nThisX = nX;
+ if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 )
+ {
+ while ( pMergeFlag->IsHorOverlapped() )
+ {
+ --nThisX;
+ pPattern = pDoc->GetPattern( nThisX, nThisY, nTab );
+ pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
+ }
+ }
+
+ if ( rMark.IsCellMarked( nThisX, nThisY, TRUE ) == bRepeat )
+ {
+ if ( !pMergeFlag->IsOverlapped() )
+ {
+ ScMergeAttr* pMerge = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
+ if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
+ {
+ Point aEndPos = pViewData->GetScrPos(
+ nThisX + pMerge->GetColMerge(),
+ nThisY + pMerge->GetRowMerge(), eWhich );
+ if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
+ {
+ aInvert.AddRect( Rectangle( nScrX,nScrY,
+ aEndPos.X()-nLayoutSign,aEndPos.Y()-1 ) );
+ }
+ }
+ else if ( nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
+ {
+ aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) );
+ }
+ }
+ }
+ }
+ else // !bTestMerge
+ {
+ if ( rMark.IsCellMarked( nX, nY, TRUE ) == bRepeat &&
+ nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
+ {
+ aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) );
+ }
+ }
+
+ nScrX = nEndX + nLayoutSign;
+ }
+ }
+ nScrY = nEndY + 1;
+ }
+ }
+
+ aInvert.Flush(); // before restoring MapMode
+
+ SetMapMode(aOld);
+
+ CheckInverted();
+}
+
+void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
+{
+ ScMarkData aMultiMark( pViewData->GetMarkData() );
+ aMultiMark.SetMarking( FALSE );
+ aMultiMark.MarkToMulti();
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ if ( !aMultiMark.IsMultiMarked() )
+ return;
+
+ ScRange aMultiRange;
+ aMultiMark.GetMultiMarkArea( aMultiRange );
+ SCCOL nX1 = aMultiRange.aStart.Col();
+ SCROW nY1 = aMultiRange.aStart.Row();
+ SCCOL nX2 = aMultiRange.aEnd.Col();
+ SCROW nY2 = aMultiRange.aEnd.Row();
+
+ PutInOrder( nX1, nX2 );
+ PutInOrder( nY1, nY2 );
+
+ BOOL bTestMerge = TRUE;
+ BOOL bRepeat = TRUE;
+
+ SCCOL nTestX2 = nX2;
+ SCROW nTestY2 = nY2;
+ if (bTestMerge)
+ pDoc->ExtendMerge( nX1,nY1, nTestX2,nTestY2, nTab );
+
+ SCCOL nPosX = pViewData->GetPosX( eHWhich );
+ SCROW nPosY = pViewData->GetPosY( eVWhich );
+ if (nTestX2 < nPosX || nTestY2 < nPosY)
+ return; // unsichtbar
+ SCCOL nRealX1 = nX1;
+ if (nX1 < nPosX)
+ nX1 = nPosX;
+ if (nY1 < nPosY)
+ nY1 = nPosY;
+
+ SCCOL nXRight = nPosX + pViewData->VisibleCellsX(eHWhich);
+ if (nXRight > MAXCOL) nXRight = MAXCOL;
+ SCROW nYBottom = nPosY + pViewData->VisibleCellsY(eVWhich);
+ if (nYBottom > MAXROW) nYBottom = MAXROW;
+
+ if (nX1 > nXRight || nY1 > nYBottom)
+ return; // unsichtbar
+ if (nX2 > nXRight) nX2 = nXRight;
+ if (nY2 > nYBottom) nY2 = nYBottom;
+
+ double nPPTX = pViewData->GetPPTX();
+ double nPPTY = pViewData->GetPPTY();
+
+ ScInvertMerger aInvert( &rPixelRects );
+
+ Point aScrPos = pViewData->GetScrPos( nX1, nY1, eWhich );
+ long nScrY = aScrPos.Y();
+ BOOL bWasHidden = FALSE;
+ for (SCROW nY=nY1; nY<=nY2; nY++)
+ {
+ BOOL bFirstRow = ( nY == nPosY ); // first visible row?
+ BOOL bDoHidden = FALSE; // versteckte nachholen ?
+ USHORT nHeightTwips = pDoc->GetRowHeight( nY,nTab );
+ BOOL bDoRow = ( nHeightTwips != 0 );
+ if (bDoRow)
+ {
+ if (bTestMerge)
+ if (bWasHidden) // auf versteckte zusammengefasste testen
+ {
+ bDoHidden = TRUE;
+ bDoRow = TRUE;
+ }
+
+ bWasHidden = FALSE;
+ }
+ else
+ {
+ bWasHidden = TRUE;
+ if (bTestMerge)
+ if (nY==nY2)
+ bDoRow = TRUE; // letzte Zeile aus Block
+ }
+
+ if ( bDoRow )
+ {
+ SCCOL nLoopEndX = nX2;
+ if (nX2 < nX1) // Rest von zusammengefasst
+ {
+ SCCOL nStartX = nX1;
+ while ( ((const ScMergeFlagAttr*)pDoc->
+ GetAttr(nStartX,nY,nTab,ATTR_MERGE_FLAG))->IsHorOverlapped() )
+ --nStartX;
+ if (nStartX <= nX2)
+ nLoopEndX = nX1;
+ }
+
+ long nEndY = nScrY + ScViewData::ToPixel( nHeightTwips, nPPTY ) - 1;
+ long nScrX = aScrPos.X();
+ for (SCCOL nX=nX1; nX<=nLoopEndX; nX++)
+ {
+ long nWidth = ScViewData::ToPixel( pDoc->GetColWidth( nX,nTab ), nPPTX );
+ if ( nWidth > 0 )
+ {
+ long nEndX = nScrX + ( nWidth - 1 ) * nLayoutSign;
+ if (bTestMerge)
+ {
+ SCROW nThisY = nY;
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab );
+ const ScMergeFlagAttr* pMergeFlag = (const ScMergeFlagAttr*) &pPattern->
+ GetItem(ATTR_MERGE_FLAG);
+ if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) )
+ {
+ while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 &&
+ (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) )
+ {
+ --nThisY;
+ pPattern = pDoc->GetPattern( nX, nThisY, nTab );
+ pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
+ }
+ }
+
+ // nur Rest von zusammengefasster zu sehen ?
+ SCCOL nThisX = nX;
+ if ( pMergeFlag->IsHorOverlapped() && nX == nPosX && nX > nRealX1 )
+ {
+ while ( pMergeFlag->IsHorOverlapped() )
+ {
+ --nThisX;
+ pPattern = pDoc->GetPattern( nThisX, nThisY, nTab );
+ pMergeFlag = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
+ }
+ }
+
+ if ( aMultiMark.IsCellMarked( nThisX, nThisY, TRUE ) == bRepeat )
+ {
+ if ( !pMergeFlag->IsOverlapped() )
+ {
+ ScMergeAttr* pMerge = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
+ if (pMerge->GetColMerge() > 0 || pMerge->GetRowMerge() > 0)
+ {
+ Point aEndPos = pViewData->GetScrPos(
+ nThisX + pMerge->GetColMerge(),
+ nThisY + pMerge->GetRowMerge(), eWhich );
+ if ( aEndPos.X() * nLayoutSign > nScrX * nLayoutSign && aEndPos.Y() > nScrY )
+ {
+ aInvert.AddRect( Rectangle( nScrX,nScrY,
+ aEndPos.X()-nLayoutSign,aEndPos.Y()-1 ) );
+ }
+ }
+ else if ( nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
+ {
+ aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) );
+ }
+ }
+ }
+ }
+ else // !bTestMerge
+ {
+ if ( aMultiMark.IsCellMarked( nX, nY, TRUE ) == bRepeat &&
+ nEndX * nLayoutSign >= nScrX * nLayoutSign && nEndY >= nScrY )
+ {
+ aInvert.AddRect( Rectangle( nScrX,nScrY,nEndX,nEndY ) );
+ }
+ }
+
+ nScrX = nEndX + nLayoutSign;
+ }
+ }
+ nScrY = nEndY + 1;
+ }
+ }
+
+// aInvert.Flush(); // before restoring MapMode
+}
+
+// -------------------------------------------------------------------------
+
+
+
+// -------------------------------------------------------------------------
+
+void ScGridWindow::DrawCursor()
+{
+// #114409#
+// SCTAB nTab = pViewData->GetTabNo();
+// SCCOL nX = pViewData->GetCurX();
+// SCROW nY = pViewData->GetCurY();
+//
+// // in verdeckten Zellen nicht zeichnen
+//
+// ScDocument* pDoc = pViewData->GetDocument();
+// const ScPatternAttr* pPattern = pDoc->GetPattern(nX,nY,nTab);
+// const ScMergeFlagAttr& rMerge = (const ScMergeFlagAttr&) pPattern->GetItem(ATTR_MERGE_FLAG);
+// if (rMerge.IsOverlapped())
+// return;
+//
+// // links/oben ausserhalb des Bildschirms ?
+//
+// BOOL bVis = ( nX>=pViewData->GetPosX(eHWhich) && nY>=pViewData->GetPosY(eVWhich) );
+// if (!bVis)
+// {
+// SCCOL nEndX = nX;
+// SCROW nEndY = nY;
+// ScDocument* pDoc = pViewData->GetDocument();
+// const ScMergeAttr& rMerge = (const ScMergeAttr&) pPattern->GetItem(ATTR_MERGE);
+// if (rMerge.GetColMerge() > 1)
+// nEndX += rMerge.GetColMerge()-1;
+// if (rMerge.GetRowMerge() > 1)
+// nEndY += rMerge.GetRowMerge()-1;
+// bVis = ( nEndX>=pViewData->GetPosX(eHWhich) && nEndY>=pViewData->GetPosY(eVWhich) );
+// }
+//
+// if ( bVis )
+// {
+// // hier kein Update, da aus Paint gerufen und laut Zaehler Cursor schon da
+// // wenn Update noetig, dann bei Hide/Showcursor vor dem Hoch-/Runterzaehlen
+//
+// MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL);
+//
+// Point aScrPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE );
+// BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+//
+// // completely right of/below the screen?
+// // (test with logical start position in aScrPos)
+// BOOL bMaybeVisible;
+// if ( bLayoutRTL )
+// bMaybeVisible = ( aScrPos.X() >= -2 && aScrPos.Y() >= -2 );
+// else
+// {
+// Size aOutSize = GetOutputSizePixel();
+// bMaybeVisible = ( aScrPos.X() <= aOutSize.Width() + 2 && aScrPos.Y() <= aOutSize.Height() + 2 );
+// }
+// if ( bMaybeVisible )
+// {
+// long nSizeXPix;
+// long nSizeYPix;
+// pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
+//
+// if ( bLayoutRTL )
+// aScrPos.X() -= nSizeXPix - 2; // move instead of mirroring
+//
+// BOOL bFix = ( pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
+// pViewData->GetVSplitMode() == SC_SPLIT_FIX );
+// if ( pViewData->GetActivePart()==eWhich || bFix )
+// {
+// // old UNX version with two Invert calls causes flicker.
+// // if optimization is needed, a new flag should be added
+// // to InvertTracking
+//
+// aScrPos.X() -= 2;
+// aScrPos.Y() -= 2;
+// Rectangle aRect( aScrPos, Size( nSizeXPix + 3, nSizeYPix + 3 ) );
+//
+// Invert(Rectangle( aRect.Left(), aRect.Top(), aRect.Left()+2, aRect.Bottom() ));
+// Invert(Rectangle( aRect.Right()-2, aRect.Top(), aRect.Right(), aRect.Bottom() ));
+// Invert(Rectangle( aRect.Left()+3, aRect.Top(), aRect.Right()-3, aRect.Top()+2 ));
+// Invert(Rectangle( aRect.Left()+3, aRect.Bottom()-2, aRect.Right()-3, aRect.Bottom() ));
+// }
+// else
+// {
+// Rectangle aRect( aScrPos, Size( nSizeXPix - 1, nSizeYPix - 1 ) );
+// Invert( aRect );
+// }
+// }
+//
+// SetMapMode(aOld);
+// }
+}
+
+ // AutoFill-Anfasser:
+
+void ScGridWindow::DrawAutoFillMark()
+{
+// #114409#
+// if ( bAutoMarkVisible && aAutoMarkPos.Tab() == pViewData->GetTabNo() )
+// {
+// SCCOL nX = aAutoMarkPos.Col();
+// SCROW nY = aAutoMarkPos.Row();
+// SCTAB nTab = pViewData->GetTabNo();
+// ScDocument* pDoc = pViewData->GetDocument();
+// BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+//
+// Point aFillPos = pViewData->GetScrPos( nX, nY, eWhich, TRUE );
+// long nSizeXPix;
+// long nSizeYPix;
+// pViewData->GetMergeSizePixel( nX, nY, nSizeXPix, nSizeYPix );
+// if ( bLayoutRTL )
+// aFillPos.X() -= nSizeXPix + 3;
+// else
+// aFillPos.X() += nSizeXPix - 2;
+//
+// aFillPos.Y() += nSizeYPix;
+// aFillPos.Y() -= 2;
+// Rectangle aFillRect( aFillPos, Size(6,6) );
+// // Anfasser von Zeichenobjekten sind 7*7
+//
+// MapMode aOld = GetMapMode(); SetMapMode(MAP_PIXEL);
+// Invert( aFillRect );
+// SetMapMode(aOld);
+// }
+}
+
+// -------------------------------------------------------------------------
+
+void ScGridWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged(rDCEvt);
+
+ if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ if ( rDCEvt.GetType() == DATACHANGED_FONTS && eWhich == pViewData->GetActivePart() )
+ pViewData->GetDocShell()->UpdateFontList();
+
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ if ( eWhich == pViewData->GetActivePart() ) // only once for the view
+ {
+ ScTabView* pView = pViewData->GetView();
+
+ // update scale in case the UI ScreenZoom has changed
+ ScGlobal::UpdatePPT(this);
+ pView->RecalcPPT();
+
+ // RepeatResize in case scroll bar sizes have changed
+ pView->RepeatResize();
+ pView->UpdateAllOverlays();
+
+ // invalidate cell attribs in input handler, in case the
+ // EditEngine BackgroundColor has to be changed
+ if ( pViewData->IsActive() )
+ {
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ if (pHdl)
+ pHdl->ForgetLastPattern();
+ }
+ }
+ }
+
+ Invalidate();
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin5.cxx b/sc/source/ui/view/gridwin5.cxx
new file mode 100644
index 000000000000..c3dcba8d8dd5
--- /dev/null
+++ b/sc/source/ui/view/gridwin5.cxx
@@ -0,0 +1,440 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <editeng/eeitem.hxx>
+
+#include <editeng/flditem.hxx>
+
+#include <editeng/editview.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdpagv.hxx>
+#include <svtools/imapobj.hxx>
+#include <vcl/cursor.hxx>
+#include <vcl/help.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include <unotools/localedatawrapper.hxx>
+
+#include "viewuno.hxx"
+#include "AccessibleDocument.hxx"
+#include <com/sun/star/accessibility/XAccessible.hpp>
+
+#include "gridwin.hxx"
+#include "viewdata.hxx"
+#include "drawview.hxx"
+#include "drwlayer.hxx"
+#include "drawpage.hxx"
+#include "document.hxx"
+#include "notemark.hxx"
+#include "chgtrack.hxx"
+#include "chgviset.hxx"
+#include "dbfunc.hxx"
+#include "tabvwsh.hxx"
+#include "userdat.hxx"
+#include "postit.hxx"
+
+// -----------------------------------------------------------------------
+
+ScHideTextCursor::ScHideTextCursor( ScViewData* pData, ScSplitPos eW ) :
+ pViewData(pData),
+ eWhich(eW)
+{
+ Window* pWin = pViewData->GetView()->GetWindowByPos( eWhich );
+ if (pWin)
+ {
+ Cursor* pCur = pWin->GetCursor();
+ if ( pCur && pCur->IsVisible() )
+ pCur->Hide();
+ }
+}
+
+ScHideTextCursor::~ScHideTextCursor()
+{
+ Window* pWin = pViewData->GetView()->GetWindowByPos( eWhich );
+ if (pWin)
+ {
+ // restore text cursor
+ if ( pViewData->HasEditView(eWhich) && pWin->HasFocus() )
+ pViewData->GetEditView(eWhich)->ShowCursor( FALSE, TRUE );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+BOOL ScGridWindow::ShowNoteMarker( SCsCOL nPosX, SCsROW nPosY, BOOL bKeyboard )
+{
+ BOOL bDone = FALSE;
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScAddress aCellPos( nPosX, nPosY, nTab );
+
+ String aTrackText;
+ BOOL bLeftEdge = FALSE;
+
+ // Change-Tracking
+
+ ScChangeTrack* pTrack = pDoc->GetChangeTrack();
+ ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
+ if ( pTrack && pTrack->GetFirst() && pSettings && pSettings->ShowChanges())
+ {
+ const ScChangeAction* pFound = NULL;
+ const ScChangeAction* pFoundContent = NULL;
+ const ScChangeAction* pFoundMove = NULL;
+ long nModified = 0;
+ const ScChangeAction* pAction = pTrack->GetFirst();
+ while (pAction)
+ {
+ if ( pAction->IsVisible() &&
+ ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) )
+ {
+ ScChangeActionType eType = pAction->GetType();
+ const ScBigRange& rBig = pAction->GetBigRange();
+ if ( rBig.aStart.Tab() == nTab )
+ {
+ ScRange aRange = rBig.MakeRange();
+
+ if ( eType == SC_CAT_DELETE_ROWS )
+ aRange.aEnd.SetRow( aRange.aStart.Row() );
+ else if ( eType == SC_CAT_DELETE_COLS )
+ aRange.aEnd.SetCol( aRange.aStart.Col() );
+
+ if ( aRange.In( aCellPos ) )
+ {
+ pFound = pAction; // der letzte gewinnt
+ switch ( eType )
+ {
+ case SC_CAT_CONTENT :
+ pFoundContent = pAction;
+ break;
+ case SC_CAT_MOVE :
+ pFoundMove = pAction;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ ++nModified;
+ }
+ }
+ if ( eType == SC_CAT_MOVE )
+ {
+ ScRange aRange =
+ ((const ScChangeActionMove*)pAction)->
+ GetFromRange().MakeRange();
+ if ( aRange.In( aCellPos ) )
+ {
+ pFound = pAction;
+ ++nModified;
+ }
+ }
+ }
+ pAction = pAction->GetNext();
+ }
+
+ if ( pFound )
+ {
+ if ( pFoundContent && pFound->GetType() != SC_CAT_CONTENT )
+ pFound = pFoundContent; // Content gewinnt
+ if ( pFoundMove && pFound->GetType() != SC_CAT_MOVE &&
+ pFoundMove->GetActionNumber() >
+ pFound->GetActionNumber() )
+ pFound = pFoundMove; // Move gewinnt
+
+ // bei geloeschten Spalten: Pfeil auf die linke Seite der Zelle
+ if ( pFound->GetType() == SC_CAT_DELETE_COLS )
+ bLeftEdge = TRUE;
+
+ DateTime aDT = pFound->GetDateTime();
+ aTrackText = pFound->GetUser();
+ aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ", " ));
+ aTrackText += ScGlobal::pLocaleData->getDate(aDT);
+ aTrackText += ' ';
+ aTrackText += ScGlobal::pLocaleData->getTime(aDT);
+ aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n" ));
+ String aComStr=pFound->GetComment();
+ if(aComStr.Len()>0)
+ {
+ aTrackText += aComStr;
+ aTrackText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n( " ));
+ }
+ pFound->GetDescription( aTrackText, pDoc );
+ if(aComStr.Len()>0)
+ {
+ aTrackText +=')';
+ }
+ }
+ }
+
+ // Notiz nur, wenn sie nicht schon auf dem Drawing-Layer angezeigt wird:
+ const ScPostIt* pNote = pDoc->GetNote( aCellPos );
+ if ( (aTrackText.Len() > 0) || (pNote && !pNote->IsCaptionShown()) )
+ {
+ BOOL bNew = TRUE;
+ BOOL bFast = FALSE;
+ if ( pNoteMarker ) // schon eine Notiz angezeigt
+ {
+ if ( pNoteMarker->GetDocPos() == aCellPos ) // dieselbe
+ bNew = FALSE; // dann stehenlassen
+ else
+ bFast = TRUE; // sonst sofort
+
+ // marker which was shown for ctrl-F1 isn't removed by mouse events
+ if ( pNoteMarker->IsByKeyboard() && !bKeyboard )
+ bNew = FALSE;
+ }
+ if ( bNew )
+ {
+ if ( bKeyboard )
+ bFast = TRUE; // keyboard also shows the marker immediately
+
+ delete pNoteMarker;
+
+ bool bHSplit = pViewData->GetHSplitMode() != SC_SPLIT_NONE;
+ bool bVSplit = pViewData->GetVSplitMode() != SC_SPLIT_NONE;
+
+ Window* pLeft = pViewData->GetView()->GetWindowByPos( bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT );
+ Window* pRight = bHSplit ? pViewData->GetView()->GetWindowByPos( bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT ) : 0;
+ Window* pBottom = bVSplit ? pViewData->GetView()->GetWindowByPos( SC_SPLIT_BOTTOMLEFT ) : 0;
+ Window* pDiagonal = (bHSplit && bVSplit) ? pViewData->GetView()->GetWindowByPos( SC_SPLIT_BOTTOMRIGHT ) : 0;
+ DBG_ASSERT( pLeft, "ScGridWindow::ShowNoteMarker - missing top-left grid window" );
+
+ /* If caption is shown from right or bottom windows, adjust
+ mapmode to include size of top-left window. */
+ MapMode aMapMode = GetDrawMapMode( TRUE );
+ Size aLeftSize = pLeft->PixelToLogic( pLeft->GetOutputSizePixel(), aMapMode );
+ Point aOrigin = aMapMode.GetOrigin();
+ if( (this == pRight) || (this == pDiagonal) )
+ aOrigin.X() += aLeftSize.Width();
+ if( (this == pBottom) || (this == pDiagonal) )
+ aOrigin.Y() += aLeftSize.Height();
+ aMapMode.SetOrigin( aOrigin );
+
+ pNoteMarker = new ScNoteMarker( pLeft, pRight, pBottom, pDiagonal,
+ pDoc, aCellPos, aTrackText,
+ aMapMode, bLeftEdge, bFast, bKeyboard );
+ }
+
+ bDone = TRUE; // something is shown (old or new)
+ }
+
+ return bDone;
+}
+
+// -----------------------------------------------------------------------
+
+void ScGridWindow::RequestHelp(const HelpEvent& rHEvt)
+{
+ BOOL bDone = FALSE;
+ BOOL bHelpEnabled = ( rHEvt.GetMode() & ( HELPMODE_BALLOON | HELPMODE_QUICK ) ) != 0;
+ SdrView* pDrView = pViewData->GetScDrawView();
+
+ BOOL bDrawTextEdit = FALSE;
+ if (pDrView)
+ bDrawTextEdit = pDrView->IsTextEdit();
+
+ // notes or change tracking
+
+ if ( bHelpEnabled && !bDrawTextEdit )
+ {
+ Point aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, nPosX, nPosY );
+
+ if ( ShowNoteMarker( nPosX, nPosY, FALSE ) )
+ {
+ Window::RequestHelp( rHEvt ); // alte Tip/Balloon ausschalten
+ bDone = TRUE;
+ }
+ }
+
+ if ( !bDone && pNoteMarker )
+ {
+ if ( pNoteMarker->IsByKeyboard() )
+ {
+ // marker which was shown for ctrl-F1 isn't removed by mouse events
+ }
+ else
+ DELETEZ(pNoteMarker);
+ }
+
+ // Image-Map / Text-URL
+
+ if ( bHelpEnabled && !bDone && !nButtonDown ) // nur ohne gedrueckten Button
+ {
+ String aHelpText;
+ Rectangle aPixRect;
+ Point aPosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
+
+ if ( pDrView ) // URL / Image-Map
+ {
+ SdrViewEvent aVEvt;
+ MouseEvent aMEvt( aPosPixel, 1, 0, MOUSE_LEFT );
+ SdrHitKind eHit = pDrView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt );
+
+ if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL )
+ {
+ // URL fuer IMapObject unter Pointer ist Hilfetext
+ if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) )
+ {
+ Point aLogicPos = PixelToLogic( aPosPixel );
+ IMapObject* pIMapObj = ScDrawLayer::GetHitIMapObject(
+ aVEvt.pObj, aLogicPos, *this );
+
+ if ( pIMapObj )
+ {
+ // #44990# Bei ImageMaps die Description anzeigen, wenn vorhanden
+ aHelpText = pIMapObj->GetAltText();
+ if (!aHelpText.Len())
+ aHelpText = pIMapObj->GetURL();
+ aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
+ }
+ }
+ // URL in shape text or at shape itself (URL in text overrides object URL)
+ if ( aHelpText.Len() == 0 )
+ {
+ if( aVEvt.eEvent == SDREVENT_EXECUTEURL )
+ {
+ aHelpText = aVEvt.pURLField->GetURL();
+ aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
+ }
+ else
+ {
+ SdrObject* pObj = 0;
+ SdrPageView* pPV = 0;
+ Point aMDPos = PixelToLogic( aPosPixel );
+ if ( pDrView->PickObj(aMDPos, pDrView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) )
+ {
+ if ( pObj->IsGroupObject() )
+ {
+ SdrObject* pHit = 0;
+ if ( pDrView->PickObj(aMDPos, pDrView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) )
+ pObj = pHit;
+ }
+ ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj );
+ if ( pInfo && (pInfo->GetHlink().getLength() > 0) )
+ {
+ aPixRect = LogicToPixel(aVEvt.pObj->GetLogicRect());
+ aHelpText = pInfo->GetHlink();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if ( !aHelpText.Len() ) // Text-URL
+ {
+ String aUrl;
+ if ( GetEditUrl( aPosPixel, NULL, &aUrl, NULL ) )
+ {
+ aHelpText = INetURLObject::decode( aUrl, INET_HEX_ESCAPE,
+ INetURLObject::DECODE_UNAMBIGUOUS );
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ SCTAB nTab = pViewData->GetTabNo();
+ pViewData->GetPosFromPixel( aPosPixel.X(), aPosPixel.Y(), eWhich, nPosX, nPosY );
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nPosX, nPosY, nTab );
+
+ ScHideTextCursor aHideCursor( pViewData, eWhich ); // MapMode is changed in GetEditArea
+
+ // bForceToTop = FALSE, use the cell's real position
+ aPixRect = pViewData->GetEditArea( eWhich, nPosX, nPosY, this, pPattern, FALSE );
+ }
+ }
+
+ if ( aHelpText.Len() )
+ {
+ Rectangle aScreenRect(OutputToScreenPixel(aPixRect.TopLeft()),
+ OutputToScreenPixel(aPixRect.BottomRight()));
+
+ if ( rHEvt.GetMode() & HELPMODE_BALLOON )
+ Help::ShowBalloon(this,rHEvt.GetMousePosPixel(), aScreenRect, aHelpText);
+ else if ( rHEvt.GetMode() & HELPMODE_QUICK )
+ Help::ShowQuickHelp(this,aScreenRect, aHelpText);
+
+ bDone = TRUE;
+ }
+ }
+
+ // Basic-Controls
+
+ if ( pDrView && bHelpEnabled && !bDone )
+ {
+ SdrPageView* pPV = pDrView->GetSdrPageView();
+ DBG_ASSERT( pPV, "SdrPageView* ist NULL" );
+ if (pPV)
+ bDone = ((ScDrawPage*)pPV->GetPage())->RequestHelp( this, pDrView, rHEvt );
+ }
+
+ // Wenn QuickHelp fuer AutoFill angezeigt wird, nicht wieder wegnehmen lassen
+
+ if ( nMouseStatus == SC_GM_TABDOWN && pViewData->GetRefType() == SC_REFTYPE_FILL &&
+ Help::IsQuickHelpEnabled() )
+ bDone = TRUE;
+
+ if (!bDone)
+ Window::RequestHelp( rHEvt );
+}
+
+BOOL ScGridWindow::IsMyModel(SdrEditView* pSdrView)
+{
+ return pSdrView &&
+ pSdrView->GetModel() == pViewData->GetDocument()->GetDrawLayer();
+}
+
+void ScGridWindow::HideNoteMarker()
+{
+ DELETEZ(pNoteMarker);
+}
+
+com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
+ ScGridWindow::CreateAccessible()
+{
+ ScAccessibleDocument* pAccessibleDocument =
+ new ScAccessibleDocument(GetAccessibleParentWindow()->GetAccessible(),
+ pViewData->GetViewShell(), eWhich);
+
+ com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > xAccessible = pAccessibleDocument;
+
+ pAccessibleDocument->Init();
+
+ return xAccessible;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/hdrcont.cxx b/sc/source/ui/view/hdrcont.cxx
new file mode 100644
index 000000000000..ec21c02ce383
--- /dev/null
+++ b/sc/source/ui/view/hdrcont.cxx
@@ -0,0 +1,1039 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/dispatch.hxx>
+#include <vcl/help.hxx>
+#include <tools/poly.hxx>
+#include <svtools/colorcfg.hxx>
+
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "hdrcont.hxx"
+#include "scmod.hxx" // Optionen
+#include "inputopt.hxx" // Optionen
+#include "gridmerg.hxx"
+#include "document.hxx"
+
+// -----------------------------------------------------------------------
+
+#define SC_DRAG_MIN 2
+
+// passes in paint
+// (selection left/right must be first because the continuous lines
+// are partly overwritten later)
+
+#define SC_HDRPAINT_SEL_RIGHT 0
+#define SC_HDRPAINT_SEL_LEFT 1
+#define SC_HDRPAINT_TOP 2
+#define SC_HDRPAINT_SEL_TOP 3
+#define SC_HDRPAINT_SEL_BOTTOM 4
+#define SC_HDRPAINT_BOTTOM 5
+#define SC_HDRPAINT_TEXT 6
+#define SC_HDRPAINT_COUNT 7
+
+//==================================================================
+
+ScHeaderControl::ScHeaderControl( Window* pParent, SelectionEngine* pSelectionEngine,
+ SCCOLROW nNewSize, USHORT nNewFlags ) :
+ Window ( pParent ),
+ pSelEngine ( pSelectionEngine ),
+ nFlags ( nNewFlags ),
+ bVertical ( (nNewFlags & HDR_VERTICAL) != 0 ),
+ nSize ( nNewSize ),
+ nMarkStart ( 0 ),
+ nMarkEnd ( 0 ),
+ bMarkRange ( FALSE ),
+ bDragging ( FALSE ),
+ bIgnoreMove ( FALSE )
+{
+ // --- RTL --- no default mirroring for this window, the spreadsheet itself
+ // is also not mirrored
+ // #107811# mirror the vertical window for correct border drawing
+ // #106948# table layout depends on sheet format, not UI setting, so the
+ // borders of the vertical window have to be handled manually, too.
+ EnableRTL( FALSE );
+
+ aNormFont = GetFont();
+ aNormFont.SetTransparent( TRUE ); //! WEIGHT_NORMAL hart setzen ???
+ aBoldFont = aNormFont;
+ aBoldFont.SetWeight( WEIGHT_BOLD );
+
+ SetFont(aBoldFont);
+ bBoldSet = TRUE;
+
+ Size aSize = LogicToPixel( Size(
+ GetTextWidth( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("8888")) ),
+ GetTextHeight() ) );
+ aSize.Width() += 4; // Platz fuer hervorgehobene Umrandung
+ aSize.Height() += 3;
+ SetSizePixel( aSize );
+
+ nWidth = nSmallWidth = aSize.Width();
+ nBigWidth = LogicToPixel( Size( GetTextWidth(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("8888888")) ), 0 ) ).Width() + 5;
+
+ SetBackground(); // sonst Probleme auf OS/2 !?!?!
+}
+
+void ScHeaderControl::SetWidth( long nNew )
+{
+ DBG_ASSERT( bVertical, "SetDigits nur fuer Zeilenkoepfe erlaubt" );
+ if ( nNew != nWidth )
+ {
+ Size aSize( nNew, GetSizePixel().Height() ); // Hoehe nicht aendern
+ SetSizePixel( aSize );
+
+ nWidth = nNew;
+
+ Invalidate(); // neu zentrieren
+ }
+}
+
+ScHeaderControl::~ScHeaderControl()
+{
+}
+
+void ScHeaderControl::DoPaint( SCCOLROW nStart, SCCOLROW nEnd )
+{
+ BOOL bLayoutRTL = IsLayoutRTL();
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ Rectangle aRect( Point(0,0), GetOutputSizePixel() );
+ if ( bVertical )
+ {
+ aRect.Top() = GetScrPos( nStart )-nLayoutSign; // extra pixel for line at top of selection
+ aRect.Bottom() = GetScrPos( nEnd+1 )-nLayoutSign;
+ }
+ else
+ {
+ aRect.Left() = GetScrPos( nStart )-nLayoutSign; // extra pixel for line left of selection
+ aRect.Right() = GetScrPos( nEnd+1 )-nLayoutSign;
+ }
+ Invalidate(aRect);
+}
+
+void ScHeaderControl::SetMark( BOOL bNewSet, SCCOLROW nNewStart, SCCOLROW nNewEnd )
+{
+ BOOL bEnabled = SC_MOD()->GetInputOptions().GetMarkHeader(); //! cachen?
+ if (!bEnabled)
+ bNewSet = FALSE;
+
+ // Variablen setzen
+
+ BOOL bOldSet = bMarkRange;
+ SCCOLROW nOldStart = nMarkStart;
+ SCCOLROW nOldEnd = nMarkEnd;
+ PutInOrder( nNewStart, nNewEnd );
+ bMarkRange = bNewSet;
+ nMarkStart = nNewStart;
+ nMarkEnd = nNewEnd;
+
+ // Paint
+
+ if ( bNewSet )
+ {
+ if ( bOldSet )
+ {
+ if ( nNewStart == nOldStart )
+ {
+ if ( nNewEnd != nOldEnd )
+ DoPaint( Min( nNewEnd, nOldEnd ) + 1, Max( nNewEnd, nOldEnd ) );
+ // sonst nix
+ }
+ else if ( nNewEnd == nOldEnd )
+ DoPaint( Min( nNewStart, nOldStart ), Max( nNewStart, nOldStart ) - 1 );
+ else if ( nNewStart > nOldEnd || nNewEnd < nOldStart )
+ {
+ // zwei Bereiche...
+ DoPaint( nOldStart, nOldEnd );
+ DoPaint( nNewStart, nNewEnd );
+ }
+ else // irgendwie ueberlappend... (kommt eh nicht oft vor)
+ DoPaint( Min( nNewStart, nOldStart ), Max( nNewEnd, nOldEnd ) );
+ }
+ else
+ DoPaint( nNewStart, nNewEnd ); // komplett neu
+ }
+ else if ( bOldSet )
+ DoPaint( nOldStart, nOldEnd ); // komplett aufheben
+
+ // sonst war nix, is nix
+}
+
+long ScHeaderControl::GetScrPos( SCCOLROW nEntryNo )
+{
+ long nScrPos;
+
+ long nMax = ( bVertical ? GetOutputSizePixel().Height() : GetOutputSizePixel().Width() ) + 1;
+ if (nEntryNo >= nSize)
+ nScrPos = nMax;
+ else
+ {
+ nScrPos = 0;
+ for (SCCOLROW i=GetPos(); i<nEntryNo && nScrPos<nMax; i++)
+ {
+ USHORT nAdd = GetEntrySize(i);
+ if (nAdd)
+ nScrPos += nAdd;
+ else
+ {
+ SCCOLROW nHidden = GetHiddenCount(i);
+ if (nHidden > 0)
+ i += nHidden - 1;
+ }
+ }
+ }
+
+ if ( IsLayoutRTL() )
+ nScrPos = nMax - nScrPos - 2;
+
+ return nScrPos;
+}
+
+// draw a rectangle across the window's width/height, with the outer part in a lighter color
+
+void ScHeaderControl::DrawShadedRect( long nStart, long nEnd, const Color& rBaseColor )
+{
+ Color aWhite( COL_WHITE );
+
+ Color aInner( rBaseColor ); // highlight color, unchanged
+ Color aCenter( rBaseColor );
+ aCenter.Merge( aWhite, 0xd0 ); // lighten up a bit
+ Color aOuter( rBaseColor );
+ aOuter.Merge( aWhite, 0xa0 ); // lighten up more
+
+ if ( IsMirrored() )
+ std::swap( aInner, aOuter ); // just swap colors instead of positions
+
+ Size aWinSize = GetSizePixel();
+ long nBarSize = bVertical ? aWinSize.Width() : aWinSize.Height();
+ long nCenterPos = (nBarSize / 2) - 1;
+
+ SetLineColor();
+ SetFillColor( aOuter );
+ if (bVertical)
+ DrawRect( Rectangle( 0, nStart, nCenterPos-1, nEnd ) );
+ else
+ DrawRect( Rectangle( nStart, 0, nEnd, nCenterPos-1 ) );
+ SetFillColor( aCenter );
+ if (bVertical)
+ DrawRect( Rectangle( nCenterPos, nStart, nCenterPos, nEnd ) );
+ else
+ DrawRect( Rectangle( nStart, nCenterPos, nEnd, nCenterPos ) );
+ SetFillColor( aInner );
+ if (bVertical)
+ DrawRect( Rectangle( nCenterPos+1, nStart, nBarSize-1, nEnd ) );
+ else
+ DrawRect( Rectangle( nStart, nCenterPos+1, nEnd, nBarSize-1 ) );
+}
+
+//
+// Paint
+//
+
+void ScHeaderControl::Paint( const Rectangle& rRect )
+{
+ // fuer VCL ist es wichtig, wenig Aufrufe zu haben, darum werden die aeusseren
+ // Linien zusammengefasst
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ BOOL bHighContrast = rStyleSettings.GetHighContrastMode();
+ BOOL bDark = rStyleSettings.GetFaceColor().IsDark();
+ // Use the same distinction for bDark as in Window::DrawSelectionBackground
+
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ Color aSelTextColor = rStyleSettings.GetHighlightTextColor();
+ aNormFont.SetColor( aTextColor );
+ if ( bHighContrast )
+ aBoldFont.SetColor( aTextColor );
+ else
+ aBoldFont.SetColor( aSelTextColor );
+ SetTextColor( ( bBoldSet && !bHighContrast ) ? aSelTextColor : aTextColor );
+
+ Color aBlack( COL_BLACK );
+ Color aSelLineColor = rStyleSettings.GetHighlightColor();
+ aSelLineColor.Merge( aBlack, 0xe0 ); // darken just a little bit
+
+ BOOL bLayoutRTL = IsLayoutRTL();
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+ BOOL bMirrored = IsMirrored();
+
+// const FunctionSet* pFuncSet = pSelEngine->GetFunctionSet();
+ String aString;
+ USHORT nBarSize;
+ Point aScrPos;
+ Size aTextSize;
+// Size aSize = GetOutputSizePixel();
+
+ if (bVertical)
+ nBarSize = (USHORT) GetSizePixel().Width();
+ else
+ nBarSize = (USHORT) GetSizePixel().Height();
+
+ SCCOLROW nPos = GetPos();
+
+ long nPStart = bVertical ? rRect.Top() : rRect.Left();
+ long nPEnd = bVertical ? rRect.Bottom() : rRect.Right();
+
+ long nTransStart = nPEnd + 1;
+ long nTransEnd = 0;
+
+ long nInitScrPos = 0;
+ if ( bLayoutRTL )
+ {
+ long nTemp = nPStart; // swap nPStart / nPEnd
+ nPStart = nPEnd;
+ nPEnd = nTemp;
+ nTemp = nTransStart; // swap nTransStart / nTransEnd
+ nTransStart = nTransEnd;
+ nTransEnd = nTemp;
+ if ( bVertical ) // start loops from the end
+ nInitScrPos = GetSizePixel().Height() - 1;
+ else
+ nInitScrPos = GetSizePixel().Width() - 1;
+ }
+
+ // aeussere Linien komplett durchzeichnen
+ // Zuerst Ende der letzten Zelle finden
+
+// long nLineEnd = -1;
+ long nLineEnd = nInitScrPos - nLayoutSign;
+
+ for (SCCOLROW i=nPos; i<nSize; i++)
+ {
+ USHORT nSizePix = GetEntrySize( i );
+ if (nSizePix)
+ {
+ nLineEnd += nSizePix * nLayoutSign;
+
+ if ( bMarkRange && i >= nMarkStart && i <= nMarkEnd )
+ {
+ long nLineStart = nLineEnd - ( nSizePix - 1 ) * nLayoutSign;
+ if ( nLineStart * nLayoutSign < nTransStart * nLayoutSign )
+ nTransStart = nLineStart;
+ if ( nLineEnd * nLayoutSign > nTransEnd * nLayoutSign )
+ nTransEnd = nLineEnd;
+ }
+
+ if ( nLineEnd * nLayoutSign > nPEnd * nLayoutSign )
+ {
+ nLineEnd = nPEnd;
+ break;
+ }
+ }
+ else
+ {
+ SCCOLROW nHidden = GetHiddenCount(i);
+ if (nHidden > 0)
+ i += nHidden - 1;
+ }
+ }
+
+ // background is different for entry area and behind the entries
+
+ Rectangle aFillRect;
+ SetLineColor();
+
+ if ( nLineEnd * nLayoutSign >= nInitScrPos * nLayoutSign )
+ {
+ if ( bHighContrast )
+ {
+ // high contrast: single-color background
+ SetFillColor( rStyleSettings.GetFaceColor() );
+ if ( bVertical )
+ aFillRect = Rectangle( 0, nInitScrPos, nBarSize-1, nLineEnd );
+ else
+ aFillRect = Rectangle( nInitScrPos, 0, nLineEnd, nBarSize-1 );
+ DrawRect( aFillRect );
+ }
+ else
+ {
+ // normal: 3-part background
+ DrawShadedRect( nInitScrPos, nLineEnd, rStyleSettings.GetFaceColor() );
+ }
+ }
+
+ if ( nLineEnd * nLayoutSign < nPEnd * nLayoutSign )
+ {
+ SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::APPBACKGROUND).nColor );
+ if ( bVertical )
+ aFillRect = Rectangle( 0, nLineEnd+nLayoutSign, nBarSize-1, nPEnd );
+ else
+ aFillRect = Rectangle( nLineEnd+nLayoutSign, 0, nPEnd, nBarSize-1 );
+ DrawRect( aFillRect );
+ }
+
+ if ( nLineEnd * nLayoutSign >= nPStart * nLayoutSign )
+ {
+ if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign )
+ {
+ if ( bHighContrast )
+ {
+ if ( bDark )
+ {
+ // solid grey background for dark face color is drawn before lines
+
+ SetLineColor();
+ SetFillColor( COL_LIGHTGRAY );
+ if (bVertical)
+ DrawRect( Rectangle( 0, nTransStart, nBarSize-1, nTransEnd ) );
+ else
+ DrawRect( Rectangle( nTransStart, 0, nTransEnd, nBarSize-1 ) );
+ }
+ }
+ else
+ {
+ // background for selection
+
+ DrawShadedRect( nTransStart, nTransEnd, rStyleSettings.GetHighlightColor() );
+ }
+ }
+
+ SetLineColor( rStyleSettings.GetDarkShadowColor() );
+ if (bVertical)
+ {
+ long nDarkPos = bMirrored ? 0 : nBarSize-1;
+ DrawLine( Point( nDarkPos, nPStart ), Point( nDarkPos, nLineEnd ) );
+ }
+ else
+ DrawLine( Point( nPStart, nBarSize-1 ), Point( nLineEnd, nBarSize-1 ) );
+
+ // line in different color for selection
+ if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign && !bHighContrast )
+ {
+ SetLineColor( aSelLineColor );
+ if (bVertical)
+ {
+ long nDarkPos = bMirrored ? 0 : nBarSize-1;
+ DrawLine( Point( nDarkPos, nTransStart ), Point( nDarkPos, nTransEnd ) );
+ }
+ else
+ DrawLine( Point( nTransStart, nBarSize-1 ), Point( nTransEnd, nBarSize-1 ) );
+ }
+ }
+
+ //
+ // loop through entries several times to avoid changing the line color too often
+ // and to allow merging of lines
+ //
+
+ ScGridMerger aGrid( this, 1, 1 );
+
+ // start at SC_HDRPAINT_BOTTOM instead of 0 - selection doesn't get different
+ // borders, light border at top isn't used anymore
+ // use SC_HDRPAINT_SEL_BOTTOM for different color
+
+ for (USHORT nPass = SC_HDRPAINT_SEL_BOTTOM; nPass < SC_HDRPAINT_COUNT; nPass++)
+ {
+ // set line color etc. before entry loop
+ switch ( nPass )
+ {
+ case SC_HDRPAINT_SEL_BOTTOM:
+ // same as non-selected for high contrast
+ SetLineColor( bHighContrast ? rStyleSettings.GetDarkShadowColor() : aSelLineColor );
+ break;
+ case SC_HDRPAINT_BOTTOM:
+ SetLineColor( rStyleSettings.GetDarkShadowColor() );
+ break;
+ case SC_HDRPAINT_TEXT:
+ // DrawSelectionBackground is used only for high contrast on light background
+ if ( nTransEnd * nLayoutSign >= nTransStart * nLayoutSign && bHighContrast && !bDark )
+ {
+ // Transparent selection background is drawn after lines, before text.
+ // #109814# Use DrawSelectionBackground to make sure there is a visible
+ // difference. The case of a dark face color, where DrawSelectionBackground
+ // would just paint over the lines, is handled separately (bDark).
+ // Otherwise, GetHighlightColor is used with 80% transparency.
+ // The window's background color (SetBackground) has to be the background
+ // of the cell area, for the contrast comparison in DrawSelectionBackground.
+
+ Rectangle aTransRect;
+ if (bVertical)
+ aTransRect = Rectangle( 0, nTransStart, nBarSize-1, nTransEnd );
+ else
+ aTransRect = Rectangle( nTransStart, 0, nTransEnd, nBarSize-1 );
+ SetBackground( Color( rStyleSettings.GetFaceColor() ) );
+ DrawSelectionBackground( aTransRect, 0, TRUE, FALSE, FALSE );
+ SetBackground();
+ }
+ break;
+ }
+
+ SCCOLROW nCount=0;
+ long nScrPos=nInitScrPos;
+ do
+ {
+ if (bVertical)
+ aScrPos = Point( 0, nScrPos );
+ else
+ aScrPos = Point( nScrPos, 0 );
+
+ SCCOLROW nEntryNo = nCount + nPos;
+ if ( nEntryNo >= nSize ) // MAXCOL/MAXROW
+ nScrPos = nPEnd + nLayoutSign; // beyond nPEnd -> stop
+ else
+ {
+ USHORT nSizePix = GetEntrySize( nEntryNo );
+
+ if (nSizePix == 0)
+ {
+ SCCOLROW nHidden = GetHiddenCount(nEntryNo);
+ if (nHidden > 0)
+ nCount += nHidden - 1;
+ }
+ else if ((nScrPos+nSizePix*nLayoutSign)*nLayoutSign >= nPStart*nLayoutSign)
+ {
+ Point aEndPos(aScrPos);
+ if (bVertical)
+ aEndPos = Point( aScrPos.X()+nBarSize-1, aScrPos.Y()+(nSizePix-1)*nLayoutSign );
+ else
+ aEndPos = Point( aScrPos.X()+(nSizePix-1)*nLayoutSign, aScrPos.Y()+nBarSize-1 );
+
+ BOOL bMark = bMarkRange && nEntryNo >= nMarkStart && nEntryNo <= nMarkEnd;
+ BOOL bNextToMark = bMarkRange && nEntryNo + 1 >= nMarkStart && nEntryNo <= nMarkEnd;
+
+ switch ( nPass )
+ {
+ case SC_HDRPAINT_SEL_BOTTOM:
+ case SC_HDRPAINT_BOTTOM:
+ if ( nPass == ( bNextToMark ? SC_HDRPAINT_SEL_BOTTOM : SC_HDRPAINT_BOTTOM ) )
+ {
+ if (bVertical)
+ aGrid.AddHorLine( aScrPos.X(), aEndPos.X(), aEndPos.Y() );
+ else
+ aGrid.AddVerLine( aEndPos.X(), aScrPos.Y(), aEndPos.Y() );
+
+ // thick bottom for hidden rows
+ // (drawn directly, without aGrid)
+ if ( nEntryNo+1 < nSize )
+ if ( GetEntrySize(nEntryNo+1)==0 )
+ {
+ if (bVertical)
+ DrawLine( Point(aScrPos.X(),aEndPos.Y()-nLayoutSign),
+ Point(aEndPos.X(),aEndPos.Y()-nLayoutSign) );
+ else
+ DrawLine( Point(aEndPos.X()-nLayoutSign,aScrPos.Y()),
+ Point(aEndPos.X()-nLayoutSign,aEndPos.Y()) );
+ }
+ }
+ break;
+
+ case SC_HDRPAINT_TEXT:
+ if ( nSizePix > 1 ) // minimal check for small columns/rows
+ {
+ if ( bMark != bBoldSet )
+ {
+ if (bMark)
+ SetFont(aBoldFont);
+ else
+ SetFont(aNormFont);
+ bBoldSet = bMark;
+ }
+ aString = GetEntryText( nEntryNo );
+ aTextSize.Width() = GetTextWidth( aString );
+ aTextSize.Height() = GetTextHeight();
+
+ Point aTxtPos(aScrPos);
+ if (bVertical)
+ {
+ aTxtPos.X() += (nBarSize-aTextSize.Width())/2;
+ aTxtPos.Y() += (nSizePix*nLayoutSign-aTextSize.Height())/2;
+ if ( bMirrored )
+ aTxtPos.X() += 1; // dark border is left instead of right
+ }
+ else
+ {
+ aTxtPos.X() += (nSizePix*nLayoutSign-aTextSize.Width()+1)/2;
+ aTxtPos.Y() += (nBarSize-aTextSize.Height())/2;
+ }
+ DrawText( aTxtPos, aString );
+ }
+ break;
+ }
+
+ // bei Selektion der ganzen Zeile/Spalte:
+ // InvertRect( Rectangle( aScrPos, aEndPos ) );
+ }
+ nScrPos += nSizePix * nLayoutSign; // also if before the visible area
+ }
+ ++nCount;
+ }
+ while ( nScrPos * nLayoutSign <= nPEnd * nLayoutSign );
+
+ aGrid.Flush();
+ }
+}
+
+//
+// Maus - Handling
+//
+
+SCCOLROW ScHeaderControl::GetMousePos( const MouseEvent& rMEvt, BOOL& rBorder )
+{
+ BOOL bFound=FALSE;
+ SCCOLROW nCount = 1;
+ SCCOLROW nPos = GetPos();
+ SCCOLROW nHitNo = nPos;
+ long nScrPos;
+ long nMousePos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
+ long nDif;
+ Size aSize = GetOutputSizePixel();
+ long nWinSize = bVertical ? aSize.Height() : aSize.Width();
+
+ BOOL bLayoutRTL = IsLayoutRTL();
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+ long nEndPos = bLayoutRTL ? -1 : nWinSize;
+
+ nScrPos = GetScrPos( nPos ) - nLayoutSign;
+ do
+ {
+ SCCOLROW nEntryNo = nCount + nPos;
+
+// nScrPos = GetScrPos( nEntryNo ) - 1;
+
+ if (nEntryNo > nSize)
+ nScrPos = nEndPos + nLayoutSign;
+ else
+ nScrPos += GetEntrySize( nEntryNo - 1 ) * nLayoutSign; //! GetHiddenCount() ??
+
+ nDif = nMousePos - nScrPos;
+ if (nDif >= -2 && nDif <= 2 && nCount > 0)
+ {
+ bFound=TRUE;
+ nHitNo=nEntryNo-1;
+ }
+ else if (nDif * nLayoutSign >= 0 && nEntryNo < nSize)
+ nHitNo = nEntryNo;
+ ++nCount;
+ }
+ while ( nScrPos * nLayoutSign < nEndPos * nLayoutSign && nDif * nLayoutSign > 0 );
+
+ rBorder = bFound;
+ return nHitNo;
+}
+
+bool ScHeaderControl::IsSelectionAllowed(SCCOLROW nPos) const
+{
+ ScTabViewShell* pViewSh = dynamic_cast<ScTabViewShell*>(SfxViewShell::Current());
+ if (!pViewSh)
+ return false;
+
+ ScViewData* pViewData = pViewSh->GetViewData();
+ USHORT nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+ const ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ bool bSelectAllowed = true;
+ if ( pProtect && pProtect->isProtected() )
+ {
+ // This sheet is protected. Check if a context menu is allowed on this cell.
+ bool bCellsProtected = false;
+ if (bVertical)
+ {
+ // row header
+ SCROW nRPos = static_cast<SCROW>(nPos);
+ bCellsProtected = pDoc->HasAttrib(0, nRPos, nTab, MAXCOL, nRPos, nTab, HASATTR_PROTECTED);
+ }
+ else
+ {
+ // column header
+ SCCOL nCPos = static_cast<SCCOL>(nPos);
+ bCellsProtected = pDoc->HasAttrib(nCPos, 0, nTab, nCPos, MAXROW, nTab, HASATTR_PROTECTED);
+ }
+
+ bool bSelProtected = pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bool bSelUnprotected = pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+
+ if (bCellsProtected)
+ bSelectAllowed = bSelProtected;
+ else
+ bSelectAllowed = bSelUnprotected;
+ }
+ return bSelectAllowed;
+}
+
+void ScHeaderControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if (IsDisabled())
+ return;
+
+ bIgnoreMove = FALSE;
+ SelectWindow();
+
+ BOOL bFound;
+ SCCOLROW nHitNo = GetMousePos( rMEvt, bFound );
+ if (!IsSelectionAllowed(nHitNo))
+ return;
+
+ if ( bFound && rMEvt.IsLeft() && ResizeAllowed() )
+ {
+ nDragNo = nHitNo;
+ USHORT nClicks = rMEvt.GetClicks();
+ if ( nClicks && nClicks%2==0 )
+ {
+ SetEntrySize( nDragNo, HDR_SIZE_OPTIMUM );
+ SetPointer( Pointer( POINTER_ARROW ) );
+ }
+ else
+ {
+ if (bVertical)
+ nDragStart = rMEvt.GetPosPixel().Y();
+ else
+ nDragStart = rMEvt.GetPosPixel().X();
+ nDragPos = nDragStart;
+ ShowDragHelp();
+ DrawInvert( nDragPos );
+
+ // CaptureMouse();
+ StartTracking();
+ bDragging = TRUE;
+ bDragMoved = FALSE;
+ }
+ }
+ else if (rMEvt.IsLeft())
+ {
+ pSelEngine->SetWindow( this );
+ Point aPoint;
+ Rectangle aVis( aPoint,GetOutputSizePixel() );
+ if (bVertical)
+ aVis.Left() = LONG_MIN, aVis.Right() = LONG_MAX;
+ else
+ aVis.Top() = LONG_MIN, aVis.Bottom() = LONG_MAX;
+ pSelEngine->SetVisibleArea( aVis );
+
+ SetMarking( TRUE ); // muss vor SelMouseButtonDown sein
+ pSelEngine->SelMouseButtonDown( rMEvt );
+
+ // #74215# In column/row headers a simple click already is a selection.
+ // -> Call SelMouseMove to ensure CreateAnchor is called (and DestroyAnchor
+ // if the next click is somewhere else with Control key).
+ pSelEngine->SelMouseMove( rMEvt );
+
+ if (IsMouseCaptured())
+ {
+ // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
+ //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
+ ReleaseMouse();
+ StartTracking();
+ }
+ }
+}
+
+void ScHeaderControl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if ( IsDisabled() )
+ return;
+
+ SetMarking( FALSE );
+ bIgnoreMove = FALSE;
+// BOOL bFound;
+// SCCOLROW nHitNo = GetMousePos( rMEvt, bFound );
+
+ if ( bDragging )
+ {
+ DrawInvert( nDragPos );
+ ReleaseMouse();
+ bDragging = FALSE;
+
+ long nScrPos = GetScrPos( nDragNo );
+ long nMousePos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
+ BOOL bLayoutRTL = IsLayoutRTL();
+ long nNewWidth = bLayoutRTL ? ( nScrPos - nMousePos + 1 )
+ : ( nMousePos + 2 - nScrPos );
+
+ if ( nNewWidth < 0 /* && !IsSelected(nDragNo) */ )
+ {
+ SCCOLROW nStart = 0;
+ SCCOLROW nEnd = nDragNo;
+ while (nNewWidth < 0)
+ {
+ nStart = nDragNo;
+ if (nDragNo>0)
+ {
+ --nDragNo;
+ nNewWidth += GetEntrySize( nDragNo ); //! GetHiddenCount() ???
+ }
+ else
+ nNewWidth = 0;
+ }
+ HideEntries( nStart, nEnd );
+ }
+ else
+ {
+ if (nNewWidth<0) nNewWidth=0;
+ if (bDragMoved)
+ SetEntrySize( nDragNo, (USHORT) nNewWidth );
+ }
+ }
+ else
+ {
+ pSelEngine->SelMouseButtonUp( rMEvt );
+ ReleaseMouse();
+ }
+}
+
+void ScHeaderControl::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( IsDisabled() )
+ {
+ SetPointer( Pointer( POINTER_ARROW ) );
+ return;
+ }
+
+ BOOL bFound;
+ (void)GetMousePos( rMEvt, bFound );
+
+ if ( bDragging )
+ {
+ long nNewPos = bVertical ? rMEvt.GetPosPixel().Y() : rMEvt.GetPosPixel().X();
+ if ( nNewPos != nDragPos )
+ {
+ DrawInvert( nDragPos );
+ nDragPos = nNewPos;
+ ShowDragHelp();
+ DrawInvert( nDragPos );
+
+ if (nDragPos <= nDragStart-SC_DRAG_MIN || nDragPos >= nDragStart+SC_DRAG_MIN)
+ bDragMoved = TRUE;
+ }
+ }
+ else
+ {
+ if ( bFound && rMEvt.GetButtons()==0 && ResizeAllowed() )
+ SetPointer( Pointer( bVertical ? POINTER_VSIZEBAR : POINTER_HSIZEBAR ) );
+ else
+ SetPointer( Pointer( POINTER_ARROW ) );
+
+ if (!bIgnoreMove)
+ pSelEngine->SelMouseMove( rMEvt );
+ }
+}
+
+void ScHeaderControl::Tracking( const TrackingEvent& rTEvt )
+{
+ // Weil die SelectionEngine kein Tracking kennt, die Events nur auf
+ // die verschiedenen MouseHandler verteilen...
+
+ if ( rTEvt.IsTrackingCanceled() )
+ StopMarking();
+ else if ( rTEvt.IsTrackingEnded() )
+ MouseButtonUp( rTEvt.GetMouseEvent() );
+ else
+ MouseMove( rTEvt.GetMouseEvent() );
+}
+
+void ScHeaderControl::Command( const CommandEvent& rCEvt )
+{
+ USHORT nCmd = rCEvt.GetCommand();
+ if ( nCmd == COMMAND_CONTEXTMENU )
+ {
+ StopMarking(); // Selektion / Dragging beenden
+
+ // Popup ausfuehren
+
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell,
+ SfxViewShell::Current() );
+ if ( pViewSh )
+ {
+ if ( rCEvt.IsMouseEvent() )
+ {
+ // #i18735# select the column/row under the mouse pointer
+ ScViewData* pViewData = pViewSh->GetViewData();
+
+ SelectWindow(); // also deselects drawing objects, stops draw text edit
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) )
+ SC_MOD()->InputEnterHandler(); // always end edit mode
+
+ MouseEvent aMEvt( rCEvt.GetMousePosPixel() );
+ BOOL bBorder;
+ SCCOLROW nPos = GetMousePos( aMEvt, bBorder );
+ if (!IsSelectionAllowed(nPos))
+ // Selecting this cell is not allowed, neither is context menu.
+ return;
+
+ SCTAB nTab = pViewData->GetTabNo();
+ ScRange aNewRange;
+ if ( bVertical )
+ aNewRange = ScRange( 0, sal::static_int_cast<SCROW>(nPos), nTab,
+ MAXCOL, sal::static_int_cast<SCROW>(nPos), nTab );
+ else
+ aNewRange = ScRange( sal::static_int_cast<SCCOL>(nPos), 0, nTab,
+ sal::static_int_cast<SCCOL>(nPos), MAXROW, nTab );
+
+ // see if any part of the range is already selected
+ BOOL bSelected = FALSE;
+ ScRangeList aRanges;
+ pViewData->GetMarkData().FillRangeListWithMarks( &aRanges, FALSE );
+ ULONG nRangeCount = aRanges.Count();
+ for (ULONG i=0; i<nRangeCount && !bSelected; i++)
+ if ( aRanges.GetObject(i)->Intersects( aNewRange ) )
+ bSelected = TRUE;
+
+ // select the range if no part of it was selected
+ if ( !bSelected )
+ pViewSh->MarkRange( aNewRange );
+ }
+
+ ScResId aResId( bVertical ? RID_POPUP_ROWHEADER : RID_POPUP_COLHEADER );
+ pViewSh->GetDispatcher()->ExecutePopup( aResId );
+ }
+ }
+ else if ( nCmd == COMMAND_STARTDRAG )
+ {
+ pSelEngine->Command( rCEvt );
+ }
+}
+
+void ScHeaderControl::StopMarking()
+{
+ if ( bDragging )
+ {
+ DrawInvert( nDragPos );
+ bDragging = FALSE;
+ }
+
+ SetMarking( FALSE );
+ bIgnoreMove = TRUE;
+
+ // #86260# don't call pSelEngine->Reset, so selection across the parts of
+ // a split/frozen view is possible
+
+ ReleaseMouse();
+}
+
+void ScHeaderControl::ShowDragHelp()
+{
+ if (Help::IsQuickHelpEnabled())
+ {
+ long nScrPos = GetScrPos( nDragNo );
+ BOOL bLayoutRTL = IsLayoutRTL();
+ long nVal = bLayoutRTL ? ( nScrPos - nDragPos + 1 )
+ : ( nDragPos + 2 - nScrPos );
+
+ String aHelpStr = GetDragHelp( nVal );
+ Point aPos = OutputToScreenPixel( Point(0,0) );
+ Size aSize = GetSizePixel();
+
+ Point aMousePos = OutputToScreenPixel(GetPointerPosPixel());
+
+ Rectangle aRect;
+ USHORT nAlign;
+ if (!bVertical)
+ {
+ // oberhalb
+ aRect.Left() = aMousePos.X();
+ aRect.Top() = aPos.Y() - 4;
+ nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
+ }
+ else
+ {
+ // rechts oben
+ aRect.Left() = aPos.X() + aSize.Width() + 8;
+ aRect.Top() = aMousePos.Y() - 2;
+ nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM;
+ }
+
+ aRect.Right() = aRect.Left();
+ aRect.Bottom() = aRect.Top();
+
+ Help::ShowQuickHelp(this, aRect, aHelpStr, nAlign);
+ }
+}
+
+void ScHeaderControl::RequestHelp( const HelpEvent& rHEvt )
+{
+ // Wenn eigene QuickHelp angezeigt wird, nicht durch RequestHelp
+ // wieder wegnehmen lassen
+
+ BOOL bOwn = bDragging && Help::IsQuickHelpEnabled();
+ if (!bOwn)
+ Window::RequestHelp(rHEvt);
+}
+
+// -----------------------------------------------------------------------
+// Dummys fuer virtuelle Methoden
+// -----------------------------------------------------------------------
+
+SCCOLROW ScHeaderControl::GetHiddenCount( SCCOLROW nEntryNo )
+{
+ SCCOLROW nHidden = 0;
+ while ( nEntryNo < nSize && GetEntrySize( nEntryNo ) == 0 )
+ {
+ ++nEntryNo;
+ ++nHidden;
+ }
+ return nHidden;
+}
+
+BOOL ScHeaderControl::IsLayoutRTL()
+{
+ return FALSE;
+}
+
+BOOL ScHeaderControl::IsMirrored()
+{
+ return FALSE;
+}
+
+BOOL ScHeaderControl::IsDisabled()
+{
+ return FALSE;
+}
+
+BOOL ScHeaderControl::ResizeAllowed()
+{
+ return TRUE;
+}
+
+void ScHeaderControl::SelectWindow()
+{
+}
+
+void ScHeaderControl::DrawInvert( long /* nDragPos */ )
+{
+}
+
+String ScHeaderControl::GetDragHelp( long /* nVal */ )
+{
+ return EMPTY_STRING;
+}
+
+void ScHeaderControl::SetMarking( BOOL /* bSet */ )
+{
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/hintwin.cxx b/sc/source/ui/view/hintwin.cxx
new file mode 100644
index 000000000000..de7dc79e0fa8
--- /dev/null
+++ b/sc/source/ui/view/hintwin.cxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "hintwin.hxx"
+#include "global.hxx"
+
+#define HINT_LINESPACE 2
+#define HINT_INDENT 3
+#define HINT_MARGIN 4
+
+//==================================================================
+
+ScHintWindow::ScHintWindow( Window* pParent, const String& rTit, const String& rMsg ) :
+ Window( pParent, WinBits( WB_BORDER ) ),
+ aTitle( rTit ),
+ aMessage( rMsg )
+{
+ aMessage.ConvertLineEnd( LINEEND_CR );
+
+ // Hellgelb, wie Notizen in detfunc.cxx
+ Color aYellow( 255,255,192 ); // hellgelb
+ SetBackground( aYellow );
+
+ aTextFont = GetFont();
+ aTextFont.SetTransparent( TRUE );
+ aTextFont.SetWeight( WEIGHT_NORMAL );
+ aHeadFont = aTextFont;
+ aHeadFont.SetWeight( WEIGHT_BOLD );
+
+ SetFont( aHeadFont );
+ Size aHeadSize( GetTextWidth( aTitle ), GetTextHeight() );
+ SetFont( aTextFont );
+
+ Size aTextSize;
+ xub_StrLen nIndex = 0;
+ while ( nIndex != STRING_NOTFOUND )
+ {
+ String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
+ Size aLineSize( GetTextWidth( aLine ), GetTextHeight() );
+ nTextHeight = aLineSize.Height();
+ aTextSize.Height() += nTextHeight;
+ if ( aLineSize.Width() > aTextSize.Width() )
+ aTextSize.Width() = aLineSize.Width();
+ }
+ aTextSize.Width() += HINT_INDENT;
+
+ aTextStart = Point( HINT_MARGIN + HINT_INDENT,
+ aHeadSize.Height() + HINT_MARGIN + HINT_LINESPACE );
+
+ Size aWinSize( Max( aHeadSize.Width(), aTextSize.Width() ) + 2 * HINT_MARGIN + 1,
+ aHeadSize.Height() + aTextSize.Height() + HINT_LINESPACE + 2 * HINT_MARGIN + 1 );
+ SetOutputSizePixel( aWinSize );
+}
+
+
+ScHintWindow::~ScHintWindow()
+{
+}
+
+
+void __EXPORT ScHintWindow::Paint( const Rectangle& /* rRect */ )
+{
+ SetFont( aHeadFont );
+ DrawText( Point(HINT_MARGIN,HINT_MARGIN), aTitle );
+
+ SetFont( aTextFont );
+ xub_StrLen nIndex = 0;
+ Point aLineStart = aTextStart;
+ while ( nIndex != STRING_NOTFOUND )
+ {
+ String aLine = aMessage.GetToken( 0, CHAR_CR, nIndex );
+ DrawText( aLineStart, aLine );
+ aLineStart.Y() += nTextHeight;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/imapwrap.cxx b/sc/source/ui/view/imapwrap.cxx
new file mode 100644
index 000000000000..23e338d30e29
--- /dev/null
+++ b/sc/source/ui/view/imapwrap.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/imapdlg.hxx>
+#include <sfx2/viewfrm.hxx>
+
+
+USHORT ScIMapChildWindowId()
+{
+ return SvxIMapDlgChildWindow::GetChildWindowId();
+}
+
+SvxIMapDlg* ScGetIMapDlg()
+{
+ //! pass view frame here and in SVXIMAPDLG()
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if( pViewFrm && pViewFrm->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
+ return SVXIMAPDLG();
+ else
+ return NULL;
+}
+
+void ScIMapDlgSet( const Graphic& rGraphic, const ImageMap* pImageMap,
+ const TargetList* pTargetList, void* pEditingObj )
+{
+ SvxIMapDlgChildWindow::UpdateIMapDlg( rGraphic, pImageMap, pTargetList, pEditingObj );
+}
+
+const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg )
+{
+ if ( pDlg )
+ return pDlg->GetEditingObject();
+ else
+ return NULL;
+}
+
+const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg )
+{
+ return pDlg->GetImageMap();
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/invmerge.cxx b/sc/source/ui/view/invmerge.cxx
new file mode 100644
index 000000000000..f7722a33870c
--- /dev/null
+++ b/sc/source/ui/view/invmerge.cxx
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+#include <vcl/window.hxx>
+#include <tools/debug.hxx>
+
+#include "invmerge.hxx"
+
+//------------------------------------------------------------------
+
+ScInvertMerger::ScInvertMerger( Window* pWindow ) :
+ pWin( pWindow ),
+ pRects( NULL )
+{
+ // both rectangles empty
+}
+
+ScInvertMerger::ScInvertMerger( ::std::vector< Rectangle >* pRectangles ) :
+ pWin( NULL ),
+ pRects( pRectangles )
+{
+ // collect rectangles instead of inverting
+}
+
+ScInvertMerger::~ScInvertMerger()
+{
+ Flush();
+}
+
+void ScInvertMerger::Flush()
+{
+ FlushLine();
+ FlushTotal();
+
+ DBG_ASSERT( aLineRect.IsEmpty() && aTotalRect.IsEmpty(), "Flush: not empty" );
+
+ if ( pRects )
+ {
+ //
+ // also join vertically if there are non-adjacent columns involved
+ //
+
+ size_t nComparePos = 0;
+ while ( nComparePos < pRects->size() )
+ {
+ Rectangle aCompRect = (*pRects)[nComparePos];
+ sal_Int32 nBottom = aCompRect.Bottom();
+ size_t nOtherPos = nComparePos + 1;
+
+ while ( nOtherPos < pRects->size() )
+ {
+ Rectangle aOtherRect = (*pRects)[nOtherPos];
+ if ( aOtherRect.Top() > nBottom + 1 )
+ {
+ // rectangles are sorted, so we can stop searching
+ break;
+ }
+ if ( aOtherRect.Top() == nBottom + 1 &&
+ aOtherRect.Left() == aCompRect.Left() &&
+ aOtherRect.Right() == aCompRect.Right() )
+ {
+ // extend first rectangle
+ nBottom = aOtherRect.Bottom();
+ aCompRect.Bottom() = nBottom;
+ (*pRects)[nComparePos].Bottom() = nBottom;
+
+ // remove second rectangle
+ pRects->erase( pRects->begin() + nOtherPos );
+
+ // continue at unmodified nOtherPos
+ }
+ else
+ ++nOtherPos;
+ }
+
+ ++nComparePos;
+ }
+ }
+}
+
+void ScInvertMerger::FlushTotal()
+{
+ if( aTotalRect.IsEmpty() )
+ return; // nothing to do
+
+ if ( pWin )
+ pWin->Invert( aTotalRect, INVERT_HIGHLIGHT );
+ else if ( pRects )
+ pRects->push_back( aTotalRect );
+
+ aTotalRect.SetEmpty();
+}
+
+void ScInvertMerger::FlushLine()
+{
+ if( aLineRect.IsEmpty() )
+ return; // nothing to do
+
+ if ( aTotalRect.IsEmpty() )
+ {
+ aTotalRect = aLineRect; // start new total rect
+ }
+ else
+ {
+ if ( aLineRect.Left() == aTotalRect.Left() &&
+ aLineRect.Right() == aTotalRect.Right() &&
+ aLineRect.Top() == aTotalRect.Bottom() + 1 )
+ {
+ // extend total rect
+ aTotalRect.Bottom() = aLineRect.Bottom();
+ }
+ else
+ {
+ FlushTotal(); // draw old total rect
+ aTotalRect = aLineRect; // and start new one
+ }
+ }
+
+ aLineRect.SetEmpty();
+}
+
+void ScInvertMerger::AddRect( const Rectangle& rRect )
+{
+ Rectangle aJustified = rRect;
+ if ( rRect.Left() > rRect.Right() ) // switch for RTL layout
+ {
+ aJustified.Left() = rRect.Right();
+ aJustified.Right() = rRect.Left();
+ }
+
+ if ( aLineRect.IsEmpty() )
+ {
+ aLineRect = aJustified; // start new line rect
+ }
+ else
+ {
+ BOOL bDone = FALSE;
+ if ( aJustified.Top() == aLineRect.Top() &&
+ aJustified.Bottom() == aLineRect.Bottom() )
+ {
+ // try to extend line rect
+ if ( aJustified.Left() == aLineRect.Right() + 1 )
+ {
+ aLineRect.Right() = aJustified.Right();
+ bDone = TRUE;
+ }
+ else if ( aJustified.Right() + 1 == aLineRect.Left() ) // for RTL layout
+ {
+ aLineRect.Left() = aJustified.Left();
+ bDone = TRUE;
+ }
+ }
+ if (!bDone)
+ {
+ FlushLine(); // use old line rect for total rect
+ aLineRect = aJustified; // and start new one
+ }
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/makefile.mk b/sc/source/ui/view/makefile.mk
new file mode 100644
index 000000000000..3b1d570f71c0
--- /dev/null
+++ b/sc/source/ui/view/makefile.mk
@@ -0,0 +1,174 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=sc
+TARGET=view
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+# drawattr.cxx fuer IDL (enums), sollte in den Svx gehen??
+
+
+SLOFILES = \
+ $(SLO)$/tabview.obj \
+ $(SLO)$/tabview2.obj \
+ $(SLO)$/tabview3.obj \
+ $(SLO)$/tabview4.obj \
+ $(SLO)$/tabview5.obj \
+ $(SLO)$/viewfunc.obj \
+ $(SLO)$/viewfun2.obj \
+ $(SLO)$/viewfun3.obj \
+ $(SLO)$/viewfun4.obj \
+ $(SLO)$/viewfun5.obj \
+ $(SLO)$/viewfun6.obj \
+ $(SLO)$/viewfun7.obj \
+ $(SLO)$/dbfunc.obj \
+ $(SLO)$/dbfunc2.obj \
+ $(SLO)$/dbfunc3.obj \
+ $(SLO)$/dbfunc4.obj \
+ $(SLO)$/tabvwsh.obj \
+ $(SLO)$/tabvwsh2.obj \
+ $(SLO)$/tabvwsh3.obj \
+ $(SLO)$/tabvwsh4.obj \
+ $(SLO)$/tabvwsh5.obj \
+ $(SLO)$/tabvwsh8.obj \
+ $(SLO)$/tabvwsh9.obj \
+ $(SLO)$/tabvwsha.obj \
+ $(SLO)$/tabvwshb.obj \
+ $(SLO)$/tabvwshc.obj \
+ $(SLO)$/tabvwshd.obj \
+ $(SLO)$/tabvwshe.obj \
+ $(SLO)$/tabvwshf.obj \
+ $(SLO)$/tabvwshg.obj \
+ $(SLO)$/tabvwshh.obj \
+ $(SLO)$/printfun.obj \
+ $(SLO)$/pfuncache.obj \
+ $(SLO)$/preview.obj \
+ $(SLO)$/prevwsh.obj \
+ $(SLO)$/prevwsh2.obj \
+ $(SLO)$/prevloc.obj \
+ $(SLO)$/editsh.obj \
+ $(SLO)$/pivotsh.obj \
+ $(SLO)$/auditsh.obj \
+ $(SLO)$/gridwin.obj \
+ $(SLO)$/gridwin2.obj \
+ $(SLO)$/gridwin3.obj \
+ $(SLO)$/gridwin4.obj \
+ $(SLO)$/gridwin5.obj \
+ $(SLO)$/drawview.obj \
+ $(SLO)$/drawvie2.obj \
+ $(SLO)$/drawvie3.obj \
+ $(SLO)$/drawvie4.obj \
+ $(SLO)$/drawutil.obj \
+ $(SLO)$/output.obj \
+ $(SLO)$/output2.obj \
+ $(SLO)$/output3.obj \
+ $(SLO)$/overlayobject.obj \
+ $(SLO)$/gridmerg.obj \
+ $(SLO)$/invmerge.obj \
+ $(SLO)$/cellmergeoption.obj \
+ $(SLO)$/select.obj \
+ $(SLO)$/olinewin.obj \
+ $(SLO)$/hintwin.obj \
+ $(SLO)$/notemark.obj \
+ $(SLO)$/tabcont.obj \
+ $(SLO)$/tabsplit.obj \
+ $(SLO)$/viewutil.obj \
+ $(SLO)$/hdrcont.obj \
+ $(SLO)$/colrowba.obj \
+ $(SLO)$/olkact.obj \
+ $(SLO)$/galwrap.obj \
+ $(SLO)$/imapwrap.obj \
+ $(SLO)$/reffact.obj \
+ $(SLO)$/selectionstate.obj \
+ $(SLO)$/spelleng.obj \
+ $(SLO)$/spelldialog.obj \
+ $(SLO)$/waitoff.obj \
+ $(SLO)$/cellsh.obj \
+ $(SLO)$/cellsh1.obj\
+ $(SLO)$/cellsh2.obj\
+ $(SLO)$/cellsh3.obj\
+ $(SLO)$/cellsh4.obj\
+ $(SLO)$/formatsh.obj\
+ $(SLO)$/pgbrksh.obj\
+ $(SLO)$/viewdata.obj\
+ $(SLO)$/scextopt.obj
+
+.IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCSPARC"
+ NOOPTFILES= \
+ $(SLO)$/drawview.obj \
+ $(SLO)$/dbfunc2.obj \
+ $(SLO)$/tabvwsh2.obj \
+ $(SLO)$/viewfun4.obj \
+ $(SLO)$/viewfun2.obj
+.ELIF "$(OS)$(COM)$(CPUNAME)"=="SOLARISC52INTEL"
+ NOOPTFILES=\
+ $(SLO)$/drawview.obj \
+ $(SLO)$/dbfunc2.obj \
+ $(SLO)$/tabvwsh2.obj
+.ELSE
+ NOOPTFILES=\
+ $(SLO)$/drawview.obj \
+ $(SLO)$/dbfunc2.obj \
+ $(SLO)$/tabvwsh2.obj
+.ENDIF
+
+EXCEPTIONSFILES= \
+ $(SLO)$/dbfunc3.obj \
+ $(SLO)$/gridwin.obj \
+ $(SLO)$/invmerge.obj \
+ $(SLO)$/output2.obj \
+ $(SLO)$/overlayobject.obj \
+ $(SLO)$/pfuncache.obj \
+ $(SLO)$/spelldialog.obj \
+ $(SLO)$/cellsh1.obj \
+ $(SLO)$/drawvie4.obj \
+ $(SLO)$/formatsh.obj \
+ $(SLO)$/gridwin2.obj \
+ $(SLO)$/scextopt.obj \
+ $(SLO)$/tabvwshb.obj \
+ $(SLO)$/tabvwshf.obj \
+ $(SLO)$/viewdata.obj \
+ $(SLO)$/viewfunc.obj \
+ $(SLO)$/viewfun2.obj \
+ $(SLO)$/viewfun3.obj \
+ $(SLO)$/viewfun5.obj \
+ $(SLO)$/viewfun7.obj \
+ $(SLO)$/reffact.obj
+
+# goal seek -O2
+
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx
new file mode 100644
index 000000000000..626853396a01
--- /dev/null
+++ b/sc/source/ui/view/notemark.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <svx/svdoutl.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdocapt.hxx>
+#include <sfx2/printer.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/itempool.hxx>
+#include <vcl/svapp.hxx>
+
+#include "notemark.hxx"
+#include "document.hxx"
+#include "postit.hxx"
+
+#define SC_NOTEMARK_TIME 800
+#define SC_NOTEMARK_SHORT 70
+
+// -----------------------------------------------------------------------
+
+ScNoteMarker::ScNoteMarker( Window* pWin, Window* pRight, Window* pBottom, Window* pDiagonal,
+ ScDocument* pD, ScAddress aPos, const String& rUser,
+ const MapMode& rMap, BOOL bLeftEdge, BOOL bForce, BOOL bKeyboard ) :
+ pWindow( pWin ),
+ pRightWin( pRight ),
+ pBottomWin( pBottom ),
+ pDiagWin( pDiagonal ),
+ pDoc( pD ),
+ aDocPos( aPos ),
+ aUserText( rUser ),
+ aMapMode( rMap ),
+ bLeft( bLeftEdge ),
+ bByKeyboard( bKeyboard ),
+ pModel( NULL ),
+ pObject( NULL ),
+ bVisible( FALSE )
+{
+ Size aSizePixel = pWindow->GetOutputSizePixel();
+ if( pRightWin )
+ aSizePixel.Width() += pRightWin->GetOutputSizePixel().Width();
+ if( pBottomWin )
+ aSizePixel.Height() += pBottomWin->GetOutputSizePixel().Height();
+ Rectangle aVisPixel( Point( 0, 0 ), aSizePixel );
+ aVisRect = pWindow->PixelToLogic( aVisPixel, aMapMode );
+
+ aTimer.SetTimeoutHdl( LINK( this, ScNoteMarker, TimeHdl ) );
+ aTimer.SetTimeout( bForce ? SC_NOTEMARK_SHORT : SC_NOTEMARK_TIME );
+ aTimer.Start();
+}
+
+ScNoteMarker::~ScNoteMarker()
+{
+ InvalidateWin();
+
+ delete pModel;
+}
+
+IMPL_LINK( ScNoteMarker, TimeHdl, Timer*, EMPTYARG )
+{
+ if (!bVisible)
+ {
+ SvtPathOptions aPathOpt;
+ String aPath = aPathOpt.GetPalettePath();
+ pModel = new SdrModel(aPath);
+ pModel->SetScaleUnit(MAP_100TH_MM);
+ SfxItemPool& rPool = pModel->GetItemPool();
+ rPool.SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
+ rPool.FreezeIdRanges();
+
+ OutputDevice* pPrinter = pDoc->GetRefDevice();
+ if (pPrinter)
+ {
+ // Am Outliner des Draw-Model ist auch der Drucker als RefDevice gesetzt,
+ // und es soll einheitlich aussehen.
+ Outliner& rOutliner = pModel->GetDrawOutliner();
+ rOutliner.SetRefDevice(pPrinter);
+ }
+
+ if( SdrPage* pPage = pModel->AllocPage( FALSE ) )
+ {
+ pObject = ScNoteUtil::CreateTempCaption( *pDoc, aDocPos, *pPage, aUserText, aVisRect, bLeft );
+ if( pObject )
+ aRect = pObject->GetCurrentBoundRect();
+
+ // #39351# Page einfuegen damit das Model sie kennt und auch deleted
+ pModel->InsertPage( pPage );
+
+ }
+ bVisible = TRUE;
+ }
+
+ Draw();
+ return 0;
+}
+
+void lcl_DrawWin( SdrObject* pObject, Window* pWindow, const MapMode& rMap )
+{
+ MapMode aOld = pWindow->GetMapMode();
+ pWindow->SetMapMode( rMap );
+
+ ULONG nOldDrawMode = pWindow->GetDrawMode();
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ pWindow->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
+ DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+ }
+
+ pObject->SingleObjectPainter( *pWindow ); // #110094#-17
+
+ pWindow->SetDrawMode( nOldDrawMode );
+ pWindow->SetMapMode( aOld );
+}
+
+MapMode lcl_MoveMapMode( const MapMode& rMap, const Size& rMove )
+{
+ MapMode aNew = rMap;
+ Point aOrigin = aNew.GetOrigin();
+ aOrigin.X() -= rMove.Width();
+ aOrigin.Y() -= rMove.Height();
+ aNew.SetOrigin(aOrigin);
+ return aNew;
+}
+
+void ScNoteMarker::Draw()
+{
+ if ( pObject && bVisible )
+ {
+ lcl_DrawWin( pObject, pWindow, aMapMode );
+
+ if ( pRightWin || pBottomWin )
+ {
+ Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode );
+ if ( pRightWin )
+ lcl_DrawWin( pObject, pRightWin,
+ lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ) );
+ if ( pBottomWin )
+ lcl_DrawWin( pObject, pBottomWin,
+ lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ) );
+ if ( pDiagWin )
+ lcl_DrawWin( pObject, pDiagWin, lcl_MoveMapMode( aMapMode, aWinSize ) );
+ }
+ }
+}
+
+void ScNoteMarker::InvalidateWin()
+{
+ if (bVisible)
+ {
+ pWindow->Invalidate( pWindow->LogicToLogic(aRect, aMapMode, pWindow->GetMapMode()) );
+
+ if ( pRightWin || pBottomWin )
+ {
+ Size aWinSize = pWindow->PixelToLogic( pWindow->GetOutputSizePixel(), aMapMode );
+ if ( pRightWin )
+ pRightWin->Invalidate( pRightWin->LogicToLogic(aRect,
+ lcl_MoveMapMode( aMapMode, Size( aWinSize.Width(), 0 ) ),
+ pRightWin->GetMapMode()) );
+ if ( pBottomWin )
+ pBottomWin->Invalidate( pBottomWin->LogicToLogic(aRect,
+ lcl_MoveMapMode( aMapMode, Size( 0, aWinSize.Height() ) ),
+ pBottomWin->GetMapMode()) );
+ if ( pDiagWin )
+ pDiagWin->Invalidate( pDiagWin->LogicToLogic(aRect,
+ lcl_MoveMapMode( aMapMode, aWinSize ),
+ pDiagWin->GetMapMode()) );
+ }
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/olinewin.cxx b/sc/source/ui/view/olinewin.cxx
new file mode 100644
index 000000000000..c0baa7ae592c
--- /dev/null
+++ b/sc/source/ui/view/olinewin.cxx
@@ -0,0 +1,1047 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include <vcl/svapp.hxx>
+#include <vcl/taskpanelist.hxx>
+
+#include "olinewin.hxx"
+#include "olinetab.hxx"
+#include "document.hxx"
+#include "dbfunc.hxx"
+#include "sc.hrc"
+
+// ============================================================================
+
+const long SC_OL_BITMAPSIZE = 12;
+const long SC_OL_POSOFFSET = 2;
+
+const size_t SC_OL_NOLEVEL = static_cast< size_t >( -1 );
+const size_t SC_OL_HEADERENTRY = static_cast< size_t >( -1 );
+
+const USHORT SC_OL_IMAGE_PLUS = 9;
+const USHORT SC_OL_IMAGE_MINUS = SC_OL_IMAGE_PLUS + 1;
+const USHORT SC_OL_IMAGE_NOTPRESSED = SC_OL_IMAGE_MINUS + 1;
+const USHORT SC_OL_IMAGE_PRESSED = SC_OL_IMAGE_NOTPRESSED + 1;
+
+// ============================================================================
+
+ScOutlineWindow::ScOutlineWindow( Window* pParent, ScOutlineMode eMode, ScViewData* pViewData, ScSplitPos eWhich ) :
+ Window( pParent ),
+ mrViewData( *pViewData ),
+ meWhich( eWhich ),
+ mbHoriz( eMode == SC_OUTLINE_HOR ),
+ mbMirrorEntries( false ), // updated in SetHeaderSize
+ mbMirrorLevels( false ), // updated in SetHeaderSize
+ mpSymbols( NULL ),
+ maLineColor( COL_BLACK ),
+ mnHeaderSize( 0 ),
+ mnHeaderPos( 0 ),
+ mnMainFirstPos( 0 ),
+ mnMainLastPos( 0 ),
+ mbMTActive( false ),
+ mbMTPressed( false ),
+ mnFocusLevel( 0 ),
+ mnFocusEntry( SC_OL_HEADERENTRY ),
+ mbDontDrawFocus( false )
+{
+ EnableRTL( FALSE ); // mirroring is done manually
+
+ InitSettings();
+ maFocusRect.SetEmpty();
+ SetHeaderSize( 0 );
+
+ // insert the window into task pane list for "F6 cycling"
+ if( SystemWindow* pSysWin = GetSystemWindow() )
+ if( TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList() )
+ pTaskPaneList->AddWindow( this );
+}
+
+ScOutlineWindow::~ScOutlineWindow()
+{
+ // remove the window from task pane list
+ if( SystemWindow* pSysWin = GetSystemWindow() )
+ if( TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList() )
+ pTaskPaneList->RemoveWindow( this );
+}
+
+void ScOutlineWindow::SetHeaderSize( long nNewSize )
+{
+ BOOL bLayoutRTL = GetDoc().IsLayoutRTL( GetTab() );
+ mbMirrorEntries = bLayoutRTL && mbHoriz;
+ mbMirrorLevels = bLayoutRTL && !mbHoriz;
+
+ bool bNew = (nNewSize != mnHeaderSize);
+ mnHeaderSize = nNewSize;
+ mnHeaderPos = mbMirrorEntries ? (GetOutputSizeEntry() - mnHeaderSize) : 0;
+ mnMainFirstPos = mbMirrorEntries ? 0 : mnHeaderSize;
+ mnMainLastPos = GetOutputSizeEntry() - (mbMirrorEntries ? mnHeaderSize : 0) - 1;
+ if ( bNew )
+ Invalidate();
+}
+
+long ScOutlineWindow::GetDepthSize() const
+{
+ long nSize = GetLevelCount() * SC_OL_BITMAPSIZE;
+ if ( nSize > 0 )
+ nSize += 2 * SC_OL_POSOFFSET + 1;
+ return nSize;
+}
+
+void ScOutlineWindow::ScrollPixel( long nDiff )
+{
+ HideFocus();
+ mbDontDrawFocus = true;
+
+ long nStart = mnMainFirstPos;
+ long nEnd = mnMainLastPos;
+
+ long nInvStart, nInvEnd;
+ if (nDiff < 0)
+ {
+ nStart -= nDiff;
+ nInvStart = nEnd + nDiff;
+ nInvEnd = nEnd;
+ }
+ else
+ {
+ nEnd -= nDiff;
+ nInvStart = nStart;
+ nInvEnd = nStart + nDiff;
+ }
+
+ ScrollRel( nDiff, nStart, nEnd );
+ Invalidate( GetRectangle( 0, nInvStart, GetOutputSizeLevel() - 1, nInvEnd ) );
+ Update();
+
+ // if focus becomes invisible, move it to next visible button
+ ImplMoveFocusToVisible( nDiff < 0 );
+
+ mbDontDrawFocus = false;
+ ShowFocus();
+}
+
+void ScOutlineWindow::ScrollRel( long nEntryDiff, long nEntryStart, long nEntryEnd )
+{
+ Rectangle aRect( GetRectangle( 0, nEntryStart, GetOutputSizeLevel() - 1, nEntryEnd ) );
+ if ( mbHoriz )
+ Scroll( nEntryDiff, 0, aRect );
+ else
+ Scroll( 0, nEntryDiff, aRect );
+}
+
+// internal -------------------------------------------------------------------
+
+void ScOutlineWindow::InitSettings()
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SetBackground( rStyleSettings.GetFaceColor() );
+ maLineColor = rStyleSettings.GetButtonTextColor();
+ mpSymbols = ScGlobal::GetOutlineSymbols( rStyleSettings.GetHighContrastMode() );
+ Invalidate();
+}
+
+const ScOutlineArray* ScOutlineWindow::GetOutlineArray() const
+{
+ const ScOutlineTable* pTable = GetDoc().GetOutlineTable( GetTab() );
+ if ( !pTable ) return NULL;
+ return mbHoriz ? pTable->GetColArray() : pTable->GetRowArray();
+}
+
+const ScOutlineEntry* ScOutlineWindow::GetOutlineEntry( size_t nLevel, size_t nEntry ) const
+{
+ const ScOutlineArray* pArray = GetOutlineArray();
+ return pArray ? pArray->GetEntry( sal::static_int_cast<USHORT>(nLevel), sal::static_int_cast<USHORT>(nEntry) ) : NULL;
+}
+
+bool ScOutlineWindow::IsHidden( SCCOLROW nColRowIndex ) const
+{
+ return mbHoriz ?
+ GetDoc().ColHidden(static_cast<SCCOL>(nColRowIndex), GetTab()) :
+ GetDoc().RowHidden(static_cast<SCROW>(nColRowIndex), GetTab());
+}
+
+bool ScOutlineWindow::IsFiltered( SCCOLROW nColRowIndex ) const
+{
+ // columns cannot be filtered
+ return !mbHoriz && GetDoc().RowFiltered( static_cast<SCROW>(nColRowIndex), GetTab() );
+}
+
+bool ScOutlineWindow::IsFirstVisible( SCCOLROW nColRowIndex ) const
+{
+ bool bAllHidden = true;
+ for ( SCCOLROW nPos = 0; (nPos < nColRowIndex) && bAllHidden; ++nPos )
+ bAllHidden = IsHidden( nPos );
+ return bAllHidden;
+}
+
+void ScOutlineWindow::GetVisibleRange( SCCOLROW& rnColRowStart, SCCOLROW& rnColRowEnd ) const
+{
+ if ( mbHoriz )
+ {
+ rnColRowStart = mrViewData.GetPosX( WhichH( meWhich ) );
+ rnColRowEnd = rnColRowStart + mrViewData.VisibleCellsX( WhichH( meWhich ) );
+ }
+ else
+ {
+ rnColRowStart = mrViewData.GetPosY( WhichV( meWhich ) );
+ rnColRowEnd = rnColRowStart + mrViewData.VisibleCellsY( WhichV( meWhich ) );
+ }
+
+ // include collapsed columns/rows in front of visible range
+ while ( (rnColRowStart > 0) && IsHidden( rnColRowStart - 1 ) )
+ --rnColRowStart;
+}
+
+Point ScOutlineWindow::GetPoint( long nLevelPos, long nEntryPos ) const
+{
+ return mbHoriz ? Point( nEntryPos, nLevelPos ) : Point( nLevelPos, nEntryPos );
+}
+
+Rectangle ScOutlineWindow::GetRectangle(
+ long nLevelStart, long nEntryStart, long nLevelEnd, long nEntryEnd ) const
+{
+ return Rectangle( GetPoint( nLevelStart, nEntryStart ), GetPoint( nLevelEnd, nEntryEnd ) );
+}
+
+long ScOutlineWindow::GetOutputSizeLevel() const
+{
+ Size aSize( GetOutputSizePixel() );
+ return mbHoriz ? aSize.Height() : aSize.Width();
+}
+
+long ScOutlineWindow::GetOutputSizeEntry() const
+{
+ Size aSize( GetOutputSizePixel() );
+ return mbHoriz ? aSize.Width() : aSize.Height();
+}
+
+size_t ScOutlineWindow::GetLevelCount() const
+{
+ const ScOutlineArray* pArray = GetOutlineArray();
+ size_t nLevelCount = pArray ? pArray->GetDepth() : 0;
+ return nLevelCount ? (nLevelCount + 1) : 0;
+}
+
+long ScOutlineWindow::GetLevelPos( size_t nLevel ) const
+{
+ // #i51970# must always return the *left* edge of the area used by a level
+ long nPos = static_cast< long >( SC_OL_POSOFFSET + nLevel * SC_OL_BITMAPSIZE );
+ return mbMirrorLevels ? (GetOutputSizeLevel() - nPos - SC_OL_BITMAPSIZE) : nPos;
+}
+
+size_t ScOutlineWindow::GetLevelFromPos( long nLevelPos ) const
+{
+ if( mbMirrorLevels ) nLevelPos = GetOutputSizeLevel() - nLevelPos - 1;
+ long nStart = SC_OL_POSOFFSET;
+ if ( nLevelPos < nStart ) return SC_OL_NOLEVEL;
+ size_t nLevel = static_cast< size_t >( (nLevelPos - nStart) / SC_OL_BITMAPSIZE );
+ return (nLevel < GetLevelCount()) ? nLevel : SC_OL_NOLEVEL;
+}
+
+long ScOutlineWindow::GetColRowPos( SCCOLROW nColRowIndex ) const
+{
+ long nDocPos = mbHoriz ?
+ mrViewData.GetScrPos( static_cast<SCCOL>(nColRowIndex), 0, meWhich, TRUE ).X() :
+ mrViewData.GetScrPos( 0, static_cast<SCROW>(nColRowIndex), meWhich, TRUE ).Y();
+ return mnMainFirstPos + nDocPos;
+}
+
+long ScOutlineWindow::GetHeaderEntryPos() const
+{
+ return mnHeaderPos + (mnHeaderSize - SC_OL_BITMAPSIZE) / 2;
+}
+
+bool ScOutlineWindow::GetEntryPos(
+ size_t nLevel, size_t nEntry,
+ long& rnStartPos, long& rnEndPos, long& rnImagePos ) const
+{
+ const ScOutlineEntry* pEntry = GetOutlineEntry( nLevel, nEntry );
+ if ( !pEntry || !pEntry->IsVisible() )
+ return false;
+
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ long nEntriesSign = mbMirrorEntries ? -1 : 1;
+
+ // --- common calculation ---
+
+ rnStartPos = GetColRowPos( nStart );
+ rnEndPos = GetColRowPos( nEnd + 1 );
+
+ bool bHidden = IsHidden( nStart );
+ rnImagePos = bHidden ?
+ (rnStartPos - ( SC_OL_BITMAPSIZE / 2 ) * nEntriesSign) :
+ rnStartPos + nEntriesSign;
+ long nCenter = (rnStartPos + rnEndPos - SC_OL_BITMAPSIZE * nEntriesSign +
+ ( mbMirrorEntries ? 1 : 0 )) / 2L;
+ rnImagePos = mbMirrorEntries ? Max( rnImagePos, nCenter ) : Min( rnImagePos, nCenter );
+
+ // --- refinements ---
+
+ // do not cut leftmost/topmost image
+ if ( bHidden && IsFirstVisible( nStart ) )
+ rnImagePos = rnStartPos;
+
+ // do not cover previous collapsed image
+ if ( !bHidden && nEntry )
+ {
+ const ScOutlineEntry* pPrevEntry = GetOutlineEntry( nLevel, nEntry - 1 );
+ SCCOLROW nPrevEnd = pPrevEntry->GetEnd();
+ if ( (nPrevEnd + 1 == nStart) && IsHidden( nPrevEnd ) )
+ {
+ if ( IsFirstVisible( pPrevEntry->GetStart() ) )
+ rnStartPos += SC_OL_BITMAPSIZE * nEntriesSign;
+ else
+ rnStartPos += ( SC_OL_BITMAPSIZE / 2 ) * nEntriesSign;
+ rnImagePos = rnStartPos;
+ }
+ }
+
+ // restrict rnStartPos...rnEndPos to valid area
+ rnStartPos = std::max( rnStartPos, mnMainFirstPos );
+ rnEndPos = std::max( rnEndPos, mnMainFirstPos );
+
+ if ( mbMirrorEntries )
+ rnImagePos -= SC_OL_BITMAPSIZE - 1; // start pos aligns with right edge of bitmap
+
+ // --- all rows filtered? ---
+
+ bool bVisible = true;
+ if ( !mbHoriz )
+ {
+ bVisible = false;
+ for ( SCCOLROW nRow = nStart; (nRow <= nEnd) && !bVisible; ++nRow )
+ bVisible = !IsFiltered( nRow );
+ }
+ return bVisible;
+}
+
+bool ScOutlineWindow::GetImagePos( size_t nLevel, size_t nEntry, Point& rPos ) const
+{
+ bool bRet = nLevel < GetLevelCount();
+ if ( bRet )
+ {
+ long nLevelPos = GetLevelPos( nLevel );
+ if ( nEntry == SC_OL_HEADERENTRY )
+ rPos = GetPoint( nLevelPos, GetHeaderEntryPos() );
+ else
+ {
+ long nStartPos, nEndPos, nImagePos;
+ bRet = GetEntryPos( nLevel, nEntry, nStartPos, nEndPos, nImagePos );
+ rPos = GetPoint( nLevelPos, nImagePos );
+ }
+ }
+ return bRet;
+}
+
+bool ScOutlineWindow::IsButtonVisible( size_t nLevel, size_t nEntry ) const
+{
+ bool bRet = false;
+ if ( nEntry == SC_OL_HEADERENTRY )
+ bRet = (mnHeaderSize > 0) && (nLevel < GetLevelCount());
+ else
+ {
+ const ScOutlineEntry* pEntry = GetOutlineEntry( nLevel, nEntry );
+ if ( pEntry && pEntry->IsVisible() )
+ {
+ SCCOLROW nStart, nEnd;
+ GetVisibleRange( nStart, nEnd );
+ bRet = (nStart <= pEntry->GetStart()) && (pEntry->GetStart() <= nEnd);
+ }
+ }
+ return bRet;
+}
+
+bool ScOutlineWindow::ItemHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry, bool& rbButton ) const
+{
+ const ScOutlineArray* pArray = GetOutlineArray();
+ if ( !pArray ) return false;
+
+ SCCOLROW nStartIndex, nEndIndex;
+ GetVisibleRange( nStartIndex, nEndIndex );
+
+ size_t nLevel = GetLevelFromPos( mbHoriz ? rPos.Y() : rPos.X() );
+ if ( nLevel == SC_OL_NOLEVEL )
+ return false;
+
+// long nLevelPos = GetLevelPos( nLevel );
+ long nEntryMousePos = mbHoriz ? rPos.X() : rPos.Y();
+
+ // --- level buttons ---
+
+ if ( mnHeaderSize > 0 )
+ {
+ long nImagePos = GetHeaderEntryPos();
+ if ( (nImagePos <= nEntryMousePos) && (nEntryMousePos < nImagePos + SC_OL_BITMAPSIZE) )
+ {
+ rnLevel = nLevel;
+ rnEntry = SC_OL_HEADERENTRY;
+ rbButton = true;
+ return true;
+ }
+ }
+
+ // --- expand/collapse buttons and expanded lines ---
+
+ // search outline entries backwards
+ size_t nEntry = pArray->GetCount( sal::static_int_cast<USHORT>(nLevel) );
+ while ( nEntry )
+ {
+ --nEntry;
+
+ const ScOutlineEntry* pEntry = pArray->GetEntry( sal::static_int_cast<USHORT>(nLevel),
+ sal::static_int_cast<USHORT>(nEntry) );
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ if ( (nEnd >= nStartIndex) && (nStart <= nEndIndex) )
+ {
+ long nStartPos, nEndPos, nImagePos;
+ if ( GetEntryPos( nLevel, nEntry, nStartPos, nEndPos, nImagePos ) )
+ {
+ rnLevel = nLevel;
+ rnEntry = nEntry;
+
+ // button?
+ if ( (nStart >= nStartIndex) && (nImagePos <= nEntryMousePos) && (nEntryMousePos < nImagePos + SC_OL_BITMAPSIZE) )
+ {
+ rbButton = true;
+ return true;
+ }
+
+ // line?
+ if ( mbMirrorEntries )
+ ::std::swap( nStartPos, nEndPos ); // in RTL mode, nStartPos is the larger value
+ if ( (nStartPos <= nEntryMousePos) && (nEntryMousePos <= nEndPos) )
+ {
+ rbButton = false;
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+bool ScOutlineWindow::ButtonHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const
+{
+ bool bButton;
+ bool bRet = ItemHit( rPos, rnLevel, rnEntry, bButton );
+ return bRet && bButton;
+}
+
+bool ScOutlineWindow::LineHit( const Point& rPos, size_t& rnLevel, size_t& rnEntry ) const
+{
+ bool bButton;
+ bool bRet = ItemHit( rPos, rnLevel, rnEntry, bButton );
+ return bRet && !bButton;
+}
+
+void ScOutlineWindow::DoFunction( size_t nLevel, size_t nEntry ) const
+{
+ ScDBFunc& rFunc = *mrViewData.GetView();
+ if ( nEntry == SC_OL_HEADERENTRY )
+ rFunc.SelectLevel( mbHoriz, sal::static_int_cast<USHORT>(nLevel) );
+ else
+ {
+ const ScOutlineEntry* pEntry = GetOutlineEntry( nLevel, nEntry );
+ if ( pEntry )
+ {
+ if ( pEntry->IsHidden() )
+ rFunc.ShowOutline( mbHoriz, sal::static_int_cast<USHORT>(nLevel), sal::static_int_cast<USHORT>(nEntry) );
+ else
+ rFunc.HideOutline( mbHoriz, sal::static_int_cast<USHORT>(nLevel), sal::static_int_cast<USHORT>(nEntry) );
+ }
+ }
+}
+
+void ScOutlineWindow::DoExpand( size_t nLevel, size_t nEntry ) const
+{
+ const ScOutlineEntry* pEntry = GetOutlineEntry( nLevel, nEntry );
+ if ( pEntry && pEntry->IsHidden() )
+ DoFunction( nLevel, nEntry );
+}
+
+void ScOutlineWindow::DoCollapse( size_t nLevel, size_t nEntry ) const
+{
+ const ScOutlineEntry* pEntry = GetOutlineEntry( nLevel, nEntry );
+ if ( pEntry && !pEntry->IsHidden() )
+ DoFunction( nLevel, nEntry );
+}
+
+void ScOutlineWindow::Resize()
+{
+ Window::Resize();
+ SetHeaderSize( mnHeaderSize ); // recalculates header/group positions
+ if ( !IsFocusButtonVisible() )
+ {
+ HideFocus();
+ ShowFocus(); // calculates valid position
+ }
+}
+
+void ScOutlineWindow::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ InitSettings();
+ Invalidate();
+ }
+ Window::DataChanged( rDCEvt );
+}
+
+// drawing --------------------------------------------------------------------
+
+void ScOutlineWindow::SetEntryAreaClipRegion()
+{
+ SetClipRegion( Rectangle(
+ GetPoint( 0, mnMainFirstPos ),
+ GetPoint( GetOutputSizeLevel() - 1, mnMainLastPos ) ) );
+}
+
+void ScOutlineWindow::DrawLineRel(
+ long nLevelStart, long nEntryStart, long nLevelEnd, long nEntryEnd )
+{
+ DrawLine( GetPoint( nLevelStart, nEntryStart ), GetPoint( nLevelEnd, nEntryEnd ) );
+}
+
+void ScOutlineWindow::DrawRectRel(
+ long nLevelStart, long nEntryStart, long nLevelEnd, long nEntryEnd )
+{
+ DrawRect( GetRectangle( nLevelStart, nEntryStart, nLevelEnd, nEntryEnd ) );
+}
+
+void ScOutlineWindow::DrawImageRel( long nLevelPos, long nEntryPos, USHORT nId )
+{
+ DBG_ASSERT( mpSymbols, "ScOutlineWindow::DrawImageRel - no images" );
+ const Image& rImage = mpSymbols->GetImage( nId );
+ SetLineColor();
+ SetFillColor( GetBackground().GetColor() );
+ Point aPos( GetPoint( nLevelPos, nEntryPos ) );
+ DrawRect( Rectangle( aPos, rImage.GetSizePixel() ) );
+ DrawImage( aPos, rImage );
+}
+
+void ScOutlineWindow::DrawBorderRel( size_t nLevel, size_t nEntry, bool bPressed )
+{
+ Point aPos;
+ if ( GetImagePos( nLevel, nEntry, aPos ) )
+ {
+ DBG_ASSERT( mpSymbols, "ScOutlineWindow::DrawBorderRel - no images" );
+ USHORT nId = bPressed ? SC_OL_IMAGE_PRESSED : SC_OL_IMAGE_NOTPRESSED;
+ bool bClip = (nEntry != SC_OL_HEADERENTRY);
+ if ( bClip )
+ SetEntryAreaClipRegion();
+ DrawImage( aPos, mpSymbols->GetImage( nId ) );
+ if ( bClip )
+ SetClipRegion();
+ }
+ mbMTPressed = bPressed;
+}
+
+void ScOutlineWindow::ShowFocus()
+{
+ if ( HasFocus() )
+ {
+ // first move to a visible position
+ ImplMoveFocusToVisible( true );
+
+ if ( IsFocusButtonVisible() )
+ {
+ Point aPos;
+ if ( GetImagePos( mnFocusLevel, mnFocusEntry, aPos ) )
+ {
+ aPos += Point( 1, 1 );
+ maFocusRect = Rectangle( aPos, Size( SC_OL_BITMAPSIZE - 2, SC_OL_BITMAPSIZE - 2 ) );
+ bool bClip = (mnFocusEntry != SC_OL_HEADERENTRY);
+ if ( bClip )
+ SetEntryAreaClipRegion();
+ InvertTracking( maFocusRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ if ( bClip )
+ SetClipRegion();
+ }
+ }
+ }
+}
+
+void ScOutlineWindow::HideFocus()
+{
+ if ( !maFocusRect.IsEmpty() )
+ {
+ bool bClip = (mnFocusEntry != SC_OL_HEADERENTRY);
+ if ( bClip )
+ SetEntryAreaClipRegion();
+ InvertTracking( maFocusRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ if ( bClip )
+ SetClipRegion();
+ maFocusRect.SetEmpty();
+ }
+}
+
+void ScOutlineWindow::Paint( const Rectangle& /* rRect */ )
+{
+ long nEntriesSign = mbMirrorEntries ? -1 : 1;
+ long nLevelsSign = mbMirrorLevels ? -1 : 1;
+
+ Size aSize = GetOutputSizePixel();
+ long nLevelEnd = (mbHoriz ? aSize.Height() : aSize.Width()) - 1;
+ long nEntryEnd = (mbHoriz ? aSize.Width() : aSize.Height()) - 1;
+
+ SetLineColor( maLineColor );
+ long nBorderPos = mbMirrorLevels ? 0 : nLevelEnd;
+ DrawLineRel( nBorderPos, 0, nBorderPos, nEntryEnd );
+
+ const ScOutlineArray* pArray = GetOutlineArray();
+ if ( !pArray ) return;
+
+ size_t nLevelCount = GetLevelCount();
+
+ // --- draw header images ---
+
+ if ( mnHeaderSize > 0 )
+ {
+ long nEntryPos = GetHeaderEntryPos();
+ for ( size_t nLevel = 0; nLevel < nLevelCount; ++nLevel )
+ DrawImageRel( GetLevelPos( nLevel ), nEntryPos, static_cast< USHORT >( nLevel + 1 ) );
+
+ SetLineColor( maLineColor );
+ long nLinePos = mnHeaderPos + (mbMirrorEntries ? 0 : (mnHeaderSize - 1));
+ DrawLineRel( 0, nLinePos, nLevelEnd, nLinePos );
+ }
+
+ // --- draw lines & collapse/expand images ---
+
+ SetEntryAreaClipRegion();
+
+ SCCOLROW nStartIndex, nEndIndex;
+ GetVisibleRange( nStartIndex, nEndIndex );
+
+ for ( size_t nLevel = 0; nLevel + 1 < nLevelCount; ++nLevel )
+ {
+ long nLevelPos = GetLevelPos( nLevel );
+ long nEntryPos1 = 0, nEntryPos2 = 0, nImagePos = 0;
+
+ size_t nEntryCount = pArray->GetCount( sal::static_int_cast<USHORT>(nLevel) );
+ size_t nEntry;
+
+ // first draw all lines in the current level
+ SetLineColor();
+ SetFillColor( maLineColor );
+ for ( nEntry = 0; nEntry < nEntryCount; ++nEntry )
+ {
+ const ScOutlineEntry* pEntry = pArray->GetEntry( sal::static_int_cast<USHORT>(nLevel),
+ sal::static_int_cast<USHORT>(nEntry) );
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ // visible range?
+ bool bDraw = (nEnd >= nStartIndex) && (nStart <= nEndIndex);
+ // find output coordinates
+ if ( bDraw )
+ bDraw = GetEntryPos( nLevel, nEntry, nEntryPos1, nEntryPos2, nImagePos );
+ // draw, if not collapsed
+ if ( bDraw && !pEntry->IsHidden() )
+ {
+ if ( nStart >= nStartIndex )
+ nEntryPos1 += nEntriesSign;
+ nEntryPos2 -= 2 * nEntriesSign;
+ long nLinePos = nLevelPos;
+ if ( mbMirrorLevels )
+ nLinePos += SC_OL_BITMAPSIZE - 1; // align with right edge of bitmap
+ DrawRectRel( nLinePos, nEntryPos1, nLinePos + nLevelsSign, nEntryPos2 );
+
+ if ( nEnd <= nEndIndex )
+ DrawRectRel( nLinePos, nEntryPos2 - nEntriesSign,
+ nLinePos + ( SC_OL_BITMAPSIZE / 3 ) * nLevelsSign, nEntryPos2 );
+ }
+ }
+
+ // draw all images in the level from last to first
+ nEntry = nEntryCount;
+ while ( nEntry )
+ {
+ --nEntry;
+
+ const ScOutlineEntry* pEntry = pArray->GetEntry( sal::static_int_cast<USHORT>(nLevel),
+ sal::static_int_cast<USHORT>(nEntry) );
+ SCCOLROW nStart = pEntry->GetStart();
+// SCCOLROW nEnd = pEntry->GetEnd();
+
+ // visible range?
+ bool bDraw = (nStartIndex <= nStart) && (nStart <= nEndIndex + 1);
+ // find output coordinates
+ if ( bDraw )
+ bDraw = GetEntryPos( nLevel, nEntry, nEntryPos1, nEntryPos2, nImagePos );
+ // draw, if not hidden by higher levels
+ if ( bDraw )
+ {
+ USHORT nImageId = pEntry->IsHidden() ? SC_OL_IMAGE_PLUS : SC_OL_IMAGE_MINUS;
+ DrawImageRel( nLevelPos, nImagePos, nImageId );
+ }
+ }
+ }
+
+ SetClipRegion();
+
+ if ( !mbDontDrawFocus )
+ ShowFocus();
+}
+
+// focus ----------------------------------------------------------------------
+
+/** Increments or decrements a value and wraps at the specified limits.
+ @return true = value wrapped. */
+bool lcl_RotateValue( size_t& rnValue, size_t nMin, size_t nMax, bool bForward )
+{
+ DBG_ASSERT( nMin <= nMax, "lcl_RotateValue - invalid range" );
+ DBG_ASSERT( nMax < static_cast< size_t >( -1 ), "lcl_RotateValue - range overflow" );
+ bool bWrap = false;
+ if ( bForward )
+ {
+ if ( rnValue < nMax )
+ ++rnValue;
+ else
+ {
+ rnValue = nMin;
+ bWrap = true;
+ }
+ }
+ else
+ {
+ if ( rnValue > nMin )
+ --rnValue;
+ else
+ {
+ rnValue = nMax;
+ bWrap = true;
+ }
+ }
+ return bWrap;
+}
+
+bool ScOutlineWindow::IsFocusButtonVisible() const
+{
+ return IsButtonVisible( mnFocusLevel, mnFocusEntry );
+}
+
+bool ScOutlineWindow::ImplMoveFocusByEntry( bool bForward, bool bFindVisible )
+{
+ const ScOutlineArray* pArray = GetOutlineArray();
+ if ( !pArray )
+ return false;
+
+ bool bWrapped = false;
+ size_t nEntryCount = pArray->GetCount( sal::static_int_cast<USHORT>(mnFocusLevel) );
+ // #i29530# entry count may be decreased after changing active sheet
+ if( mnFocusEntry >= nEntryCount )
+ mnFocusEntry = SC_OL_HEADERENTRY;
+ size_t nOldEntry = mnFocusEntry;
+
+ do
+ {
+ if ( mnFocusEntry == SC_OL_HEADERENTRY )
+ {
+ // move from header to first or last entry
+ if ( nEntryCount > 0 )
+ mnFocusEntry = bForward ? 0 : (nEntryCount - 1);
+ /* wrapped, if forward from right header to first entry,
+ or if backward from left header to last entry */
+ // Header and entries are now always in consistent order,
+ // so there's no need to check for mirroring here.
+ if ( !nEntryCount || !bForward )
+ bWrapped = true;
+ }
+ else if ( lcl_RotateValue( mnFocusEntry, 0, nEntryCount - 1, bForward ) )
+ {
+ // lcl_RotateValue returns true -> wrapped the entry range -> move to header
+ mnFocusEntry = SC_OL_HEADERENTRY;
+ /* wrapped, if forward from last entry to left header,
+ or if backward from first entry to right header */
+ if ( bForward )
+ bWrapped = true;
+ }
+ }
+ while ( bFindVisible && !IsFocusButtonVisible() && (nOldEntry != mnFocusEntry) );
+
+ return bWrapped;
+}
+
+bool ScOutlineWindow::ImplMoveFocusByLevel( bool bForward )
+{
+ const ScOutlineArray* pArray = GetOutlineArray();
+ if ( !pArray )
+ return false;
+
+ bool bWrapped = false;
+ size_t nLevelCount = GetLevelCount();
+
+ if ( mnFocusEntry == SC_OL_HEADERENTRY )
+ {
+ if ( nLevelCount > 0 )
+ bWrapped = lcl_RotateValue( mnFocusLevel, 0, nLevelCount - 1, bForward );
+ }
+ else
+ {
+ const ScOutlineEntry* pEntry = pArray->GetEntry( sal::static_int_cast<USHORT>(mnFocusLevel),
+ sal::static_int_cast<USHORT>(mnFocusEntry) );
+ if ( pEntry )
+ {
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+ size_t nNewLevel = mnFocusLevel;
+ size_t nNewEntry = 0;
+
+ bool bFound = false;
+ if ( bForward && (mnFocusLevel + 2 < nLevelCount) )
+ {
+ // next level -> find first child entry
+ nNewLevel = mnFocusLevel + 1;
+ // TODO - change ScOutlineArray interface to size_t usage
+ USHORT nTmpEntry = 0;
+ bFound = pArray->GetEntryIndexInRange( sal::static_int_cast<USHORT>(nNewLevel), nStart, nEnd, nTmpEntry );
+ nNewEntry = nTmpEntry;
+ }
+ else if ( !bForward && (mnFocusLevel > 0) )
+ {
+ // previous level -> find parent entry
+ nNewLevel = mnFocusLevel - 1;
+ // TODO - change ScOutlineArray interface to size_t usage
+ USHORT nTmpEntry = 0;
+ bFound = pArray->GetEntryIndex( sal::static_int_cast<USHORT>(nNewLevel), nStart, nTmpEntry );
+ nNewEntry = nTmpEntry;
+ }
+
+ if ( bFound && IsButtonVisible( nNewLevel, nNewEntry ) )
+ {
+ mnFocusLevel = nNewLevel;
+ mnFocusEntry = nNewEntry;
+ }
+ }
+ }
+
+ return bWrapped;
+}
+
+bool ScOutlineWindow::ImplMoveFocusByTabOrder( bool bForward, bool bFindVisible )
+{
+ bool bRet = false;
+ size_t nOldLevel = mnFocusLevel;
+ size_t nOldEntry = mnFocusEntry;
+
+ do
+ {
+ /* one level up, if backward from left header,
+ or one level down, if forward from right header */
+ if ( (!bForward) && (mnFocusEntry == SC_OL_HEADERENTRY) )
+ bRet |= ImplMoveFocusByLevel( bForward );
+ // move to next/previous entry
+ bool bWrapInLevel = ImplMoveFocusByEntry( bForward, false );
+ bRet |= bWrapInLevel;
+ /* one level up, if wrapped backward to right header,
+ or one level down, if wrapped forward to right header */
+ if ( bForward && bWrapInLevel )
+ bRet |= ImplMoveFocusByLevel( bForward );
+ }
+ while ( bFindVisible && !IsFocusButtonVisible() && ((nOldLevel != mnFocusLevel) || (nOldEntry != mnFocusEntry)) );
+
+ return bRet;
+}
+
+void ScOutlineWindow::ImplMoveFocusToVisible( bool bForward )
+{
+ // first try to find an entry in the same level
+ if ( !IsFocusButtonVisible() )
+ ImplMoveFocusByEntry( bForward, true );
+ // then try to find any other entry
+ if ( !IsFocusButtonVisible() )
+ ImplMoveFocusByTabOrder( bForward, true );
+}
+
+void ScOutlineWindow::MoveFocusByEntry( bool bForward )
+{
+ HideFocus();
+ ImplMoveFocusByEntry( bForward, true );
+ ShowFocus();
+}
+
+void ScOutlineWindow::MoveFocusByLevel( bool bForward )
+{
+ HideFocus();
+ ImplMoveFocusByLevel( bForward );
+ ShowFocus();
+}
+
+void ScOutlineWindow::MoveFocusByTabOrder( bool bForward )
+{
+ HideFocus();
+ ImplMoveFocusByTabOrder( bForward, true );
+ ShowFocus();
+}
+
+void ScOutlineWindow::GetFocus()
+{
+ Window::GetFocus();
+ ShowFocus();
+}
+
+void ScOutlineWindow::LoseFocus()
+{
+ HideFocus();
+ Window::LoseFocus();
+}
+
+
+// mouse ----------------------------------------------------------------------
+
+void ScOutlineWindow::StartMouseTracking( size_t nLevel, size_t nEntry )
+{
+ mbMTActive = true;
+ mnMTLevel = nLevel;
+ mnMTEntry = nEntry;
+ DrawBorderRel( nLevel, nEntry, true );
+}
+
+void ScOutlineWindow::EndMouseTracking()
+{
+ if ( mbMTPressed )
+ DrawBorderRel( mnMTLevel, mnMTEntry, false );
+ mbMTActive = false;
+}
+
+void ScOutlineWindow::MouseMove( const MouseEvent& rMEvt )
+{
+ if ( IsMouseTracking() )
+ {
+ size_t nLevel, nEntry;
+ bool bHit = false;
+
+ if ( ButtonHit( rMEvt.GetPosPixel(), nLevel, nEntry ) )
+ bHit = (nLevel == mnMTLevel) && (nEntry == mnMTEntry);
+
+ if ( bHit != mbMTPressed )
+ DrawBorderRel( mnMTLevel, mnMTEntry, bHit );
+ }
+}
+
+void ScOutlineWindow::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if ( IsMouseTracking() )
+ {
+ EndMouseTracking();
+
+ size_t nLevel, nEntry;
+ if ( ButtonHit( rMEvt.GetPosPixel(), nLevel, nEntry ) )
+ if ( (nLevel == mnMTLevel) && (nEntry == mnMTEntry) )
+ DoFunction( nLevel, nEntry );
+ }
+}
+
+void ScOutlineWindow::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ size_t nLevel, nEntry;
+ bool bHit = ButtonHit( rMEvt.GetPosPixel(), nLevel, nEntry );
+ if ( bHit )
+ StartMouseTracking( nLevel, nEntry );
+ else if ( rMEvt.GetClicks() == 2 )
+ {
+ bHit = LineHit( rMEvt.GetPosPixel(), nLevel, nEntry );
+ if ( bHit )
+ DoFunction( nLevel, nEntry );
+ }
+
+ // if an item has been hit and window is focused, move focus to this item
+ if ( bHit && HasFocus() )
+ {
+ HideFocus();
+ mnFocusLevel = nLevel;
+ mnFocusEntry = nEntry;
+ ShowFocus();
+ }
+}
+
+
+// keyboard -------------------------------------------------------------------
+
+void ScOutlineWindow::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKCode = rKEvt.GetKeyCode();
+ bool bNoMod = !rKCode.GetModifier();
+ bool bShift = (rKCode.GetModifier() == KEY_SHIFT);
+ bool bCtrl = (rKCode.GetModifier() == KEY_MOD1);
+
+ USHORT nCode = rKCode.GetCode();
+ bool bUpDownKey = (nCode == KEY_UP) || (nCode == KEY_DOWN);
+ bool bLeftRightKey = (nCode == KEY_LEFT) || (nCode == KEY_RIGHT);
+
+ // TAB key
+ if ( (nCode == KEY_TAB) && (bNoMod || bShift) )
+ // move forward without SHIFT key
+ MoveFocusByTabOrder( bNoMod ); // TAB uses logical order, regardless of mirroring
+
+ // LEFT/RIGHT/UP/DOWN keys
+ else if ( bNoMod && (bUpDownKey || bLeftRightKey) )
+ {
+ bool bForward = (nCode == KEY_DOWN) || (nCode == KEY_RIGHT);
+ if ( mbHoriz == bLeftRightKey )
+ // move inside level with LEFT/RIGHT in horizontal and with UP/DOWN in vertical
+ MoveFocusByEntry( bForward != mbMirrorEntries );
+ else
+ // move to next/prev level with LEFT/RIGHT in vertical and with UP/DOWN in horizontal
+ MoveFocusByLevel( bForward != mbMirrorLevels );
+ }
+
+ // CTRL + number
+ else if ( bCtrl && (nCode >= KEY_1) && (nCode <= KEY_9) )
+ {
+ size_t nLevel = static_cast< size_t >( nCode - KEY_1 );
+ if ( nLevel < GetLevelCount() )
+ DoFunction( nLevel, SC_OL_HEADERENTRY );
+ }
+
+ // other key codes
+ else switch ( rKCode.GetFullCode() )
+ {
+ case KEY_ADD: DoExpand( mnFocusLevel, mnFocusEntry ); break;
+ case KEY_SUBTRACT: DoCollapse( mnFocusLevel, mnFocusEntry ); break;
+ case KEY_SPACE:
+ case KEY_RETURN: DoFunction( mnFocusLevel, mnFocusEntry ); break;
+ default: Window::KeyInput( rKEvt );
+ }
+}
+
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/olkact.cxx b/sc/source/ui/view/olkact.cxx
new file mode 100644
index 000000000000..fed6f094ada8
--- /dev/null
+++ b/sc/source/ui/view/olkact.cxx
@@ -0,0 +1,284 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#define _BIGINT_HXX
+#define _CACHESTR_HXX
+#define _CONFIG_HXX
+#define _CURSOR_HXX
+#define _CTRLTOOL_HXX
+#define _DLGCFG_HXX
+#define _DYNARR_HXX
+#define _EXTATTR_HXX
+#define _FILDLG_HXX
+#define _FONTDLG_HXX
+#define _FRM3D_HXX
+#define _INTRO_HXX
+#define _ISETBWR_HXX
+#define _NO_SVRTF_PARSER_HXX
+#define _MACRODLG_HXX
+#define _MODALDLG_HXX
+#define _MOREBUTTON_HXX
+#define _OUTLINER_HXX
+#define _PASSWD_HXX
+#define _PRNDLG_HXX
+//#define _POLY_HXX
+#define _PVRWIN_HXX
+#define _QUEUE_HXX
+#define _RULER_HXX
+#define _SCRWIN_HXX
+#define _SETBRW_HXX
+#define _STACK_HXX
+//#define _STATUS_HXX ***
+#define _STDMENU_HXX
+#define _TABBAR_HXX
+//#define _VCBRW_HXX
+#define _VCTRLS_HXX
+//#define _VCSBX_HXX
+#define _VCONT_HXX
+#define _VDRWOBJ_HXX
+
+
+//sfx
+#define _SFXAPPWIN_HXX
+#define _SFXCTRLITEM
+#define _SFXDISPATCH_HXX
+#define _SFXFILEDLG_HXX
+#define _SFXIMGMGR_HXX
+#define _SFXIPFRM_HXX
+#define _SFX_MACRO_HXX
+#define _SFXMULTISEL_HXX
+#define _SFX_MINFITEM_HXX
+
+
+//sfxcore.hxx
+//#define _SFXINIMGR_HXX ***
+//#define _SFXCFGITEM_HXX
+//#define _SFX_PRINTER_HXX
+#define _SFXGENLINK_HXX
+#define _SFXHINTPOST_HXX
+#define _SFXDOCINF_HXX
+#define _SFXLINKHDL_HXX
+//#define _SFX_PROGRESS_HXX
+
+//sfxsh.hxx
+//#define _SFX_SHELL_HXX
+//#define _SFXAPP_HXX
+//#define _SFXDISPATCH_HXX
+//#define _SFXMSG_HXX ***
+//#define _SFXOBJFACE_HXX ***
+//#define _SFXREQUEST_HXX
+#define _SFXMACRO_HXX
+
+// SFX
+//#define _SFXAPPWIN_HXX ***
+#define _SFX_SAVEOPT_HXX
+//#define _SFX_CHILDWIN_HXX
+//#define _SFXCTRLITEM_HXX
+#define _SFXPRNMON_HXX
+#define _INTRO_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSGPOOL_HXX
+#define _SFXFILEDLG_HXX
+#define _PASSWD_HXX
+#define _SFXTBXCTRL_HXX
+#define _SFXSTBITEM_HXX
+#define _SFXMNUITEM_HXX
+#define _SFXIMGMGR_HXX
+#define _SFXTBXMGR_HXX
+#define _SFXSTBMGR_HXX
+#define _SFX_MINFITEM_HXX
+#define _SFXEVENT_HXX
+
+//sfxdoc.hxx
+//#define _SFX_OBJSH_HXX
+//#define _SFX_CLIENTSH_HXX
+//#define _SFXDOCINF_HXX
+//#define _SFX_OBJFAC_HXX
+#define _SFX_DOCFILT_HXX
+//#define _SFXDOCFILE_HXX ***
+//define _VIEWFAC_HXX
+//#define _SFXVIEWFRM_HXX
+//#define _SFXVIEWSH_HXX
+//#define _MDIFRM_HXX ***
+#define _SFX_IPFRM_HXX
+//#define _SFX_INTERNO_HXX
+
+//sfxdlg.hxx
+//#define _SFXTABDLG_HXX
+//#define _BASEDLGS_HXX ***
+#define _SFX_DINFDLG_HXX
+#define _SFXDINFEDT_HXX
+#define _SFX_MGETEMPL_HXX
+#define _SFX_TPLPITEM_HXX
+//#define _SFX_STYLEDLG_HXX
+#define _NEWSTYLE_HXX
+//#define _SFXDOCTEMPL_HXX ***
+//#define _SFXDOCTDLG_HXX ***
+//#define _SFX_TEMPLDLG_HXX ***
+//#define _SFXNEW_HXX ***
+#define _SFXDOCMAN_HXX
+//#define _SFXDOCKWIN_HXX
+
+//sfxitems.hxx
+#define _SFX_WHMAP_HXX
+#define _ARGS_HXX
+//#define _SFXPOOLITEM_HXX
+//#define _SFXINTITEM_HXX
+//#define _SFXENUMITEM_HXX
+#define _SFXFLAGITEM_HXX
+//#define _SFXSTRITEM_HXX
+#define _SFXPTITEM_HXX
+#define _SFXRECTITEM_HXX
+//#define _SFXITEMPOOL_HXX
+//#define _SFXITEMSET_HXX
+#define _SFXITEMITER_HXX
+#define _SFX_WHITER_HXX
+#define _SFXPOOLCACH_HXX
+//#define _AEITEM_HXX
+#define _SFXRNGITEM_HXX
+//#define _SFXSLSTITM_HXX
+//#define _SFXSTYLE_HXX
+
+//xout.hxx
+//#define _XENUM_HXX
+//#define _XPOLY_HXX
+//#define _XATTR_HXX
+//#define _XOUTX_HXX
+//#define _XPOOL_HXX
+//#define _XTABLE_HXX
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+//#define _SDR_NOOBJECTS
+//#define _SDR_NOVIEWS
+
+
+
+
+#define _SFXBASIC_HXX
+#define _SFX_DOCFILE_HXX
+#define _SFX_DOCFILT_HXX
+#define _SFX_DOCINF_HXX
+#define _SFX_DOCSH_HXX
+#define _SFX_TEMPLDLG_HXX
+#define _SFXSTBMGR_HXX
+#define _SFXTBXMGR_HXX
+#define _SFXIMGMGR_HXX
+#define _SFXMNUITEM_HXX
+#define _SFXMNUMGR_HXX
+#define _SFXSTBITEM_HXX
+#define _SFXTBXCTRL_HXX
+#define _SFXFILEDLG_HXX
+#define _SFXREQUEST_HXX
+#define _SFXOBJFACE_HXX
+#define _SFXMSGPOOL_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSG_HXX
+#define _SFX_PRNMON_HXX
+
+//si
+#define _SI_NOSBXCONTROLS
+#define _SI_NOCONTROL
+//#define SI_NOITEMS
+//#define SI_NODRW
+//#define SI_NOOTHERFORMS
+#define _SIDLL_HXX
+//#define _VCSBX_HXX
+//#define _VCBRW_HXX
+
+//#define _SVDATTR_HXX <--- der wars
+#define _SVDXOUT_HXX
+#define _SVDEC_HXX
+//#define _SVDIO_HXX
+//#define _SVDLAYER_HXX
+//#define _SVDRAG_HXX
+#define _SVINCVW_HXX
+//#define _SV_MULTISEL_HXX
+#define _SVRTV_HXX
+#define _SVTABBX_HXX
+
+#define _SVX_DAILDLL_HXX
+#define _SVX_HYPHEN_HXX
+#define _SVX_IMPGRF_HXX
+#define _SVX_OPTITEMS_HXX
+#define _SVX_OPTGERL_HXX
+#define _SVX_OPTSAVE_HXX
+#define _SVX_OPTSPELL_HXX
+#define _SVX_OPTPATH_HXX
+#define _SVX_OPTLINGU_HXX
+#define _SVX_RULER_HXX
+#define _SVX_RULRITEM_HXX
+#define _SVX_SPLWRAP_HXX
+#define _SVX_SPLDLG_HXX
+#define _SVX_THESDLG_HXX
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/childwin.hxx>
+#include <sfx2/objsh.hxx>
+
+#include "document.hxx"
+#include "viewdata.hxx"
+#include "drawview.hxx"
+#include "drawpage.hxx"
+#include "drwlayer.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+void ActivateOlk( ScViewData* /* pViewData */ )
+{
+ // Browser fuer Virtual Controls fuellen
+ // VC's und den Browser dazu gibts nicht mehr...
+
+ // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden
+}
+
+void DeActivateOlk( ScViewData* /* pViewData */ )
+{
+ // Browser fuer Virtual Controls fuellen
+ // VC's und den Browser dazu gibts nicht mehr...
+
+ // GetSbxForm gibt's nicht mehr, muss auch nichts mehr angemeldet werden
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
new file mode 100644
index 000000000000..292f74f507dc
--- /dev/null
+++ b/sc/source/ui/view/output.cxx
@@ -0,0 +1,2443 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <com/sun/star/embed/EmbedMisc.hpp>
+
+#include "scitems.hxx"
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <editeng/editdata.hxx>
+#include <svtools/colorcfg.hxx>
+#include <svx/rotmodit.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/svxfont.hxx>
+#include <svx/svdoole2.hxx>
+#include <tools/poly.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/pdfextoutdevdata.hxx>
+#include <svtools/accessibilityoptions.hxx>
+#include <svx/framelinkarray.hxx>
+
+#include "output.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "tabvwsh.hxx"
+#include "progress.hxx"
+#include "pagedata.hxx"
+#include "chgtrack.hxx"
+#include "chgviset.hxx"
+#include "viewutil.hxx"
+#include "gridmerg.hxx"
+#include "invmerge.hxx"
+#include "fillinfo.hxx"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "postit.hxx"
+
+#include <math.h>
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+// Farben fuer ChangeTracking "nach Autor" wie im Writer (swmodul1.cxx)
+
+#define SC_AUTHORCOLORCOUNT 9
+
+static ColorData nAuthorColor[ SC_AUTHORCOLORCOUNT ] = {
+ COL_LIGHTRED, COL_LIGHTBLUE, COL_LIGHTMAGENTA,
+ COL_GREEN, COL_RED, COL_BLUE,
+ COL_BROWN, COL_MAGENTA, COL_CYAN };
+
+// Hilfsklasse, fuer die Farbzuordnung,
+// um nicht mehrfach hintereinander denselben User aus der Liste zu suchen
+
+class ScActionColorChanger
+{
+private:
+ const ScAppOptions& rOpt;
+ const ScStrCollection& rUsers;
+ String aLastUserName;
+ USHORT nLastUserIndex;
+ ColorData nColor;
+
+public:
+ ScActionColorChanger( const ScChangeTrack& rTrack );
+ ~ScActionColorChanger() {}
+
+ void Update( const ScChangeAction& rAction );
+ ColorData GetColor() const { return nColor; }
+};
+
+//------------------------------------------------------------------
+
+ScActionColorChanger::ScActionColorChanger( const ScChangeTrack& rTrack ) :
+ rOpt( SC_MOD()->GetAppOptions() ),
+ rUsers( rTrack.GetUserCollection() ),
+ nLastUserIndex( 0 ),
+ nColor( COL_BLACK )
+{
+}
+
+void ScActionColorChanger::Update( const ScChangeAction& rAction )
+{
+ ColorData nSetColor;
+ switch (rAction.GetType())
+ {
+ case SC_CAT_INSERT_COLS:
+ case SC_CAT_INSERT_ROWS:
+ case SC_CAT_INSERT_TABS:
+ nSetColor = rOpt.GetTrackInsertColor();
+ break;
+ case SC_CAT_DELETE_COLS:
+ case SC_CAT_DELETE_ROWS:
+ case SC_CAT_DELETE_TABS:
+ nSetColor = rOpt.GetTrackDeleteColor();
+ break;
+ case SC_CAT_MOVE:
+ nSetColor = rOpt.GetTrackMoveColor();
+ break;
+ default:
+ nSetColor = rOpt.GetTrackContentColor();
+ break;
+ }
+ if ( nSetColor != COL_TRANSPARENT ) // Farbe eingestellt
+ nColor = nSetColor;
+ else // nach Autor
+ {
+ if ( rAction.GetUser() != aLastUserName )
+ {
+ aLastUserName = rAction.GetUser();
+ StrData aData(aLastUserName);
+ USHORT nIndex;
+ if (!rUsers.Search(&aData, nIndex))
+ {
+ // empty string is possible if a name wasn't found while saving a 5.0 file
+ DBG_ASSERT( aLastUserName.Len() == 0, "Author not found" );
+ nIndex = 0;
+ }
+ nLastUserIndex = nIndex % SC_AUTHORCOLORCOUNT;
+ }
+ nColor = nAuthorColor[nLastUserIndex];
+ }
+}
+
+//==================================================================
+
+ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
+ ScTableInfo& rTabInfo, ScDocument* pNewDoc,
+ SCTAB nNewTab, long nNewScrX, long nNewScrY,
+ SCCOL nNewX1, SCROW nNewY1, SCCOL nNewX2, SCROW nNewY2,
+ double nPixelPerTwipsX, double nPixelPerTwipsY,
+ const Fraction* pZoomX, const Fraction* pZoomY ) :
+ pDev( pNewDev ),
+ pRefDevice( pNewDev ), // default is output device
+ pFmtDevice( pNewDev ), // default is output device
+ mrTabInfo( rTabInfo ),
+ pRowInfo( rTabInfo.mpRowInfo ),
+ nArrCount( rTabInfo.mnArrCount ),
+ pDoc( pNewDoc ),
+ nTab( nNewTab ),
+ nScrX( nNewScrX ),
+ nScrY( nNewScrY ),
+ nX1( nNewX1 ),
+ nY1( nNewY1 ),
+ nX2( nNewX2 ),
+ nY2( nNewY2 ),
+ eType( eNewType ),
+ nPPTX( nPixelPerTwipsX ),
+ nPPTY( nPixelPerTwipsY ),
+ pEditObj( NULL ),
+ pViewShell( NULL ),
+ pDrawView( NULL ), // #114135#
+ bEditMode( FALSE ),
+ bMetaFile( FALSE ),
+ bSingleGrid( FALSE ),
+ bPagebreakMode( FALSE ),
+ bSolidBackground( FALSE ),
+ bUseStyleColor( FALSE ),
+ bForceAutoColor( SC_MOD()->GetAccessOptions().GetIsAutomaticFontColor() ),
+ bSyntaxMode( FALSE ),
+ pValueColor( NULL ),
+ pTextColor( NULL ),
+ pFormulaColor( NULL ),
+ aGridColor( COL_BLACK ),
+ bShowNullValues( TRUE ),
+ bShowFormulas( FALSE ),
+ bShowSpellErrors( FALSE ),
+ bMarkClipped( FALSE ), // FALSE fuer Drucker/Metafile etc.
+ bSnapPixel( FALSE ),
+ bAnyRotated( FALSE ),
+ bAnyClipped( FALSE ),
+ mpTargetPaintWindow(0) // #i74769# use SdrPaintWindow direct
+{
+ if (pZoomX)
+ aZoomX = *pZoomX;
+ else
+ aZoomX = Fraction(1,1);
+ if (pZoomY)
+ aZoomY = *pZoomY;
+ else
+ aZoomY = Fraction(1,1);
+
+ nVisX1 = nX1;
+ nVisY1 = nY1;
+ nVisX2 = nX2;
+ nVisY2 = nY2;
+ pDoc->StripHidden( nVisX1, nVisY1, nVisX2, nVisY2, nTab );
+
+ nScrW = 0;
+ for (SCCOL nX=nVisX1; nX<=nVisX2; nX++)
+ nScrW += pRowInfo[0].pCellInfo[nX+1].nWidth;
+
+ nMirrorW = nScrW;
+
+ nScrH = 0;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ nScrH += pRowInfo[nArrY].nHeight;
+
+ bTabProtected = pDoc->IsTabProtected( nTab );
+ nTabTextDirection = pDoc->GetEditTextDirection( nTab );
+ bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+}
+
+ScOutputData::~ScOutputData()
+{
+ delete pValueColor;
+ delete pTextColor;
+ delete pFormulaColor;
+}
+
+void ScOutputData::SetContentDevice( OutputDevice* pContentDev )
+{
+ // use pContentDev instead of pDev where used
+
+ if ( pRefDevice == pDev )
+ pRefDevice = pContentDev;
+ if ( pFmtDevice == pDev )
+ pFmtDevice = pContentDev;
+ pDev = pContentDev;
+}
+
+void ScOutputData::SetMirrorWidth( long nNew )
+{
+ nMirrorW = nNew;
+}
+
+void ScOutputData::SetGridColor( const Color& rColor )
+{
+ aGridColor = rColor;
+}
+
+void ScOutputData::SetMarkClipped( BOOL bSet )
+{
+ bMarkClipped = bSet;
+}
+
+void ScOutputData::SetShowNullValues( BOOL bSet )
+{
+ bShowNullValues = bSet;
+}
+
+void ScOutputData::SetShowFormulas( BOOL bSet )
+{
+ bShowFormulas = bSet;
+}
+
+void ScOutputData::SetShowSpellErrors( BOOL bSet )
+{
+ bShowSpellErrors = bSet;
+}
+
+void ScOutputData::SetSnapPixel( BOOL bSet )
+{
+ bSnapPixel = bSet;
+}
+
+void ScOutputData::SetEditCell( SCCOL nCol, SCROW nRow )
+{
+ nEditCol = nCol;
+ nEditRow = nRow;
+ bEditMode = TRUE;
+}
+
+void ScOutputData::SetMetaFileMode( BOOL bNewMode )
+{
+ bMetaFile = bNewMode;
+}
+
+void ScOutputData::SetSingleGrid( BOOL bNewMode )
+{
+ bSingleGrid = bNewMode;
+}
+
+void ScOutputData::SetSyntaxMode( BOOL bNewMode )
+{
+ bSyntaxMode = bNewMode;
+ if (bNewMode)
+ if (!pValueColor)
+ {
+ pValueColor = new Color( COL_LIGHTBLUE );
+ pTextColor = new Color( COL_BLACK );
+ pFormulaColor = new Color( COL_GREEN );
+ }
+}
+
+void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
+{
+ SCCOL nX;
+ SCROW nY;
+ long nPosX;
+ long nPosY;
+ SCSIZE nArrY;
+ ScBreakType nBreak = BREAK_NONE;
+ ScBreakType nBreakOld = BREAK_NONE;
+
+ BOOL bSingle;
+ Color aPageColor;
+ Color aManualColor;
+
+ if (bPagebreakMode)
+ bPage = FALSE; // keine "normalen" Umbrueche ueber volle Breite/Hoehe
+
+ //! um den einen Pixel sieht das Metafile (oder die Druck-Ausgabe) anders aus
+ //! als die Bildschirmdarstellung, aber wenigstens passen Druck und Metafile zusammen
+
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+ if (bMetaFile)
+ nOneX = nOneY = 1;
+
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+ long nSignedOneX = nOneX * nLayoutSign;
+
+ if ( eType == OUTTYPE_WINDOW )
+ {
+ const svtools::ColorConfig& rColorCfg = SC_MOD()->GetColorConfig();
+ aPageColor.SetColor( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKAUTOMATIC).nColor );
+ aManualColor.SetColor( rColorCfg.GetColorValue(svtools::CALCPAGEBREAKMANUAL).nColor );
+ }
+ else
+ {
+ aPageColor = aGridColor;
+ aManualColor = aGridColor;
+ }
+
+ pDev->SetLineColor( aGridColor );
+ ScGridMerger aGrid( pDev, nOneX, nOneY );
+
+ //
+ // Vertikale Linien
+ //
+
+ nPosX = nScrX;
+ if ( bLayoutRTL )
+ nPosX += nMirrorW - nOneX;
+
+ for (nX=nX1; nX<=nX2; nX++)
+ {
+ SCCOL nXplus1 = nX+1;
+ SCCOL nXplus2 = nX+2;
+ USHORT nWidth = pRowInfo[0].pCellInfo[nXplus1].nWidth;
+ if (nWidth)
+ {
+ nPosX += nWidth * nLayoutSign;
+
+ if ( bPage )
+ {
+ // Seitenumbrueche auch in ausgeblendeten suchen
+ SCCOL nCol = nXplus1;
+ while (nCol <= MAXCOL)
+ {
+ nBreak = pDoc->HasColBreak(nCol, nTab);
+ bool bHidden = pDoc->ColHidden(nCol, nTab);
+
+ if ( nBreak || !bHidden )
+ break;
+ ++nCol;
+ }
+
+ if (nBreak != nBreakOld)
+ {
+ aGrid.Flush();
+ pDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
+ nBreak ? aPageColor : aGridColor );
+ nBreakOld = nBreak;
+ }
+ }
+
+ BOOL bDraw = bGrid || nBreakOld; // einfaches Gitter nur wenn eingestellt
+
+ USHORT nWidthXplus2 = pRowInfo[0].pCellInfo[nXplus2].nWidth;
+ bSingle = bSingleGrid; //! in Fillinfo holen !!!!!
+ if ( nX<MAXCOL && !bSingle )
+ {
+ bSingle = ( nWidthXplus2 == 0 );
+ for (nArrY=1; nArrY+1<nArrCount && !bSingle; nArrY++)
+ {
+ if (pRowInfo[nArrY].pCellInfo[nXplus2].bHOverlapped)
+ bSingle = TRUE;
+ if (pRowInfo[nArrY].pCellInfo[nXplus1].bHideGrid)
+ bSingle = TRUE;
+ }
+ }
+
+ if (bDraw)
+ {
+ if ( nX<MAXCOL && bSingle )
+ {
+ SCCOL nVisX = nXplus1;
+ while ( nVisX < MAXCOL && !pDoc->GetColWidth(nVisX,nTab) )
+ ++nVisX;
+
+ nPosY = nScrY;
+ long nNextY;
+ for (nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ nNextY = nPosY + pThisRowInfo->nHeight;
+
+ BOOL bHOver = pThisRowInfo->pCellInfo[nXplus1].bHideGrid;
+ if (!bHOver)
+ {
+ if (nWidthXplus2)
+ bHOver = pThisRowInfo->pCellInfo[nXplus2].bHOverlapped;
+ else
+ {
+ if (nVisX <= nX2)
+ bHOver = pThisRowInfo->pCellInfo[nVisX+1].bHOverlapped;
+ else
+ bHOver = ((ScMergeFlagAttr*)pDoc->GetAttr(
+ nVisX,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG))
+ ->IsHorOverlapped();
+ if (bHOver)
+ bHOver = ((ScMergeFlagAttr*)pDoc->GetAttr(
+ nXplus1,pThisRowInfo->nRowNo,nTab,ATTR_MERGE_FLAG))
+ ->IsHorOverlapped();
+ }
+ }
+
+ if (pThisRowInfo->bChanged && !bHOver)
+ {
+ //Point aStart( nPosX-nSignedOneX, nPosY );
+ //Point aEnd( nPosX-nSignedOneX, nNextY-nOneY );
+ //pDev->DrawLine( aStart, aEnd );
+ aGrid.AddVerLine( nPosX-nSignedOneX, nPosY, nNextY-nOneY );
+ }
+ nPosY = nNextY;
+ }
+ }
+ else
+ {
+ //Point aStart( nPosX-nSignedOneX, nScrY );
+ //Point aEnd( nPosX-nSignedOneX, nScrY+nScrH-nOneY );
+ //pDev->DrawLine( aStart, aEnd );
+ aGrid.AddVerLine( nPosX-nSignedOneX, nScrY, nScrY+nScrH-nOneY );
+ }
+ }
+ }
+ }
+
+ //
+ // Horizontale Linien
+ //
+
+ bool bHiddenRow = true;
+ SCROW nHiddenEndRow = -1;
+ nPosY = nScrY;
+ for (nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ SCSIZE nArrYplus1 = nArrY+1;
+ nY = pRowInfo[nArrY].nRowNo;
+ SCROW nYplus1 = nY+1;
+ nPosY += pRowInfo[nArrY].nHeight;
+
+ if (pRowInfo[nArrY].bChanged)
+ {
+ if ( bPage )
+ {
+ for (SCROW i = nYplus1; i <= MAXROW; ++i)
+ {
+ if (i > nHiddenEndRow)
+ bHiddenRow = pDoc->RowHidden(i, nTab, nHiddenEndRow);
+ /* TODO: optimize the row break thing for large hidden
+ * segments where HasRowBreak() has to be called
+ * nevertheless for each row, as a row break is drawn also
+ * for hidden rows, above them. This needed to be done only
+ * once per hidden segment, maybe giving manual breaks
+ * priority. Something like GetNextRowBreak() and
+ * GetNextManualRowBreak(). */
+ nBreak = pDoc->HasRowBreak(i, nTab);
+ if (!bHiddenRow || nBreak)
+ break;
+ }
+
+ if (nBreakOld != nBreak)
+ {
+ aGrid.Flush();
+ pDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
+ (nBreak) ? aPageColor : aGridColor );
+ nBreakOld = nBreak;
+ }
+ }
+
+ BOOL bDraw = bGrid || nBreakOld; // einfaches Gitter nur wenn eingestellt
+
+ BOOL bNextYisNextRow = (pRowInfo[nArrYplus1].nRowNo == nYplus1);
+ bSingle = !bNextYisNextRow; // Hidden
+ for (SCCOL i=nX1; i<=nX2 && !bSingle; i++)
+ {
+ if (pRowInfo[nArrYplus1].pCellInfo[i+1].bVOverlapped)
+ bSingle = TRUE;
+ }
+
+ if (bDraw)
+ {
+ if ( bSingle && nY<MAXROW )
+ {
+ SCROW nVisY = pRowInfo[nArrYplus1].nRowNo;
+
+ nPosX = nScrX;
+ if ( bLayoutRTL )
+ nPosX += nMirrorW - nOneX;
+
+ long nNextX;
+ for (SCCOL i=nX1; i<=nX2; i++)
+ {
+ nNextX = nPosX + pRowInfo[0].pCellInfo[i+1].nWidth * nLayoutSign;
+ if (nNextX != nPosX) // sichtbar
+ {
+ BOOL bVOver;
+ if ( bNextYisNextRow )
+ bVOver = pRowInfo[nArrYplus1].pCellInfo[i+1].bVOverlapped;
+ else
+ {
+ bVOver = ((ScMergeFlagAttr*)pDoc->GetAttr(
+ i,nYplus1,nTab,ATTR_MERGE_FLAG))
+ ->IsVerOverlapped()
+ && ((ScMergeFlagAttr*)pDoc->GetAttr(
+ i,nVisY,nTab,ATTR_MERGE_FLAG))
+ ->IsVerOverlapped();
+ //! nVisY aus Array ??
+ }
+ if (!bVOver)
+ {
+ //Point aStart( nPosX, nPosY-nOneY );
+ //Point aEnd( nNextX-nSignedOneX, nPosY-nOneY );
+ //pDev->DrawLine( aStart, aEnd );
+ aGrid.AddHorLine( nPosX, nNextX-nSignedOneX, nPosY-nOneY );
+ }
+ }
+ nPosX = nNextX;
+ }
+ }
+ else
+ {
+ //Point aStart( nScrX, nPosY-nOneY );
+ //Point aEnd( nScrX+nScrW-nOneX, nPosY-nOneY );
+ //pDev->DrawLine( aStart, aEnd );
+ aGrid.AddHorLine( nScrX, nScrX+nScrW-nOneX, nPosY-nOneY );
+ }
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+void ScOutputData::SetPagebreakMode( ScPageBreakData* pPageData )
+{
+ bPagebreakMode = TRUE;
+ if (!pPageData)
+ return; // noch nicht initialisiert -> alles "nicht gedruckt"
+
+ // gedruckten Bereich markieren
+ // (in FillInfo ist schon alles auf FALSE initialisiert)
+
+ USHORT nRangeCount = sal::static_int_cast<USHORT>(pPageData->GetCount());
+ for (USHORT nPos=0; nPos<nRangeCount; nPos++)
+ {
+ ScRange aRange = pPageData->GetData( nPos ).GetPrintRange();
+
+ SCCOL nStartX = Max( aRange.aStart.Col(), nX1 );
+ SCCOL nEndX = Min( aRange.aEnd.Col(), nX2 );
+ SCROW nStartY = Max( aRange.aStart.Row(), nY1 );
+ SCROW nEndY = Min( aRange.aEnd.Row(), nY2 );
+
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if ( pThisRowInfo->bChanged && pThisRowInfo->nRowNo >= nStartY &&
+ pThisRowInfo->nRowNo <= nEndY )
+ {
+ for (SCCOL nX=nStartX; nX<=nEndX; nX++)
+ pThisRowInfo->pCellInfo[nX+1].bPrinted = TRUE;
+ }
+ }
+ }
+}
+
+void ScOutputData::FindRotated()
+{
+ //! nRotMax speichern
+ SCCOL nRotMax = nX2;
+ for (SCSIZE nRotY=0; nRotY<nArrCount; nRotY++)
+ if (pRowInfo[nRotY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nRotY].nRotMaxCol > nRotMax)
+ nRotMax = pRowInfo[nRotY].nRotMaxCol;
+
+ for (SCSIZE nArrY=1; nArrY<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if ( pThisRowInfo->nRotMaxCol != SC_ROTMAX_NONE &&
+ ( pThisRowInfo->bChanged || pRowInfo[nArrY-1].bChanged ||
+ ( nArrY+1<nArrCount && pRowInfo[nArrY+1].bChanged ) ) )
+ {
+ SCROW nY = pThisRowInfo->nRowNo;
+
+ for (SCCOL nX=0; nX<=nRotMax; nX++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ const ScPatternAttr* pPattern = pInfo->pPatternAttr;
+ const SfxItemSet* pCondSet = pInfo->pConditionSet;
+
+ if ( !pPattern && !pDoc->ColHidden(nX, nTab) )
+ {
+ pPattern = pDoc->GetPattern( nX, nY, nTab );
+ pCondSet = pDoc->GetCondResult( nX, nY, nTab );
+ }
+
+ if ( pPattern ) // Spalte nicht ausgeblendet
+ {
+ BYTE nDir = pPattern->GetRotateDir( pCondSet );
+ if (nDir != SC_ROTDIR_NONE)
+ {
+ pInfo->nRotateDir = nDir;
+ bAnyRotated = TRUE;
+ }
+ }
+ }
+ }
+ }
+}
+
+// ----------------------------------------------------------------------------
+
+USHORT lcl_GetRotateDir( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
+
+ USHORT nRet = SC_ROTDIR_NONE;
+
+ long nAttrRotate = pPattern->GetRotateVal( pCondSet );
+ if ( nAttrRotate )
+ {
+ SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&)
+ pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
+
+ if ( eRotMode == SVX_ROTATE_MODE_STANDARD )
+ nRet = SC_ROTDIR_STANDARD;
+ else if ( eRotMode == SVX_ROTATE_MODE_CENTER )
+ nRet = SC_ROTDIR_CENTER;
+ else if ( eRotMode == SVX_ROTATE_MODE_TOP || eRotMode == SVX_ROTATE_MODE_BOTTOM )
+ {
+ long nRot180 = nAttrRotate % 18000; // 1/100 Grad
+ if ( nRot180 == 9000 )
+ nRet = SC_ROTDIR_CENTER;
+ else if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nRot180 < 9000 ) ||
+ ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nRot180 > 9000 ) )
+ nRet = SC_ROTDIR_LEFT;
+ else
+ nRet = SC_ROTDIR_RIGHT;
+ }
+ }
+
+ return nRet;
+}
+
+const SvxBrushItem* lcl_FindBackground( ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
+ const SvxBrushItem* pBackground = (const SvxBrushItem*)
+ &pPattern->GetItem( ATTR_BACKGROUND, pCondSet );
+
+ USHORT nDir = lcl_GetRotateDir( pDoc, nCol, nRow, nTab );
+
+ // CENTER wird wie RIGHT behandelt...
+ if ( nDir == SC_ROTDIR_RIGHT || nDir == SC_ROTDIR_CENTER )
+ {
+ // Text geht nach rechts -> Hintergrund von links nehmen
+ while ( nCol > 0 && lcl_GetRotateDir( pDoc, nCol, nRow, nTab ) == nDir &&
+ pBackground->GetColor().GetTransparency() != 255 )
+ {
+ --nCol;
+ pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
+ pBackground = (const SvxBrushItem*)&pPattern->GetItem( ATTR_BACKGROUND, pCondSet );
+ }
+ }
+ else if ( nDir == SC_ROTDIR_LEFT )
+ {
+ // Text geht nach links -> Hintergrund von rechts nehmen
+ while ( nCol < MAXCOL && lcl_GetRotateDir( pDoc, nCol, nRow, nTab ) == nDir &&
+ pBackground->GetColor().GetTransparency() != 255 )
+ {
+ ++nCol;
+ pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
+ pBackground = (const SvxBrushItem*)&pPattern->GetItem( ATTR_BACKGROUND, pCondSet );
+ }
+ }
+
+ return pBackground;
+}
+
+// ----------------------------------------------------------------------------
+
+BOOL lcl_EqualBack( const RowInfo& rFirst, const RowInfo& rOther,
+ SCCOL nX1, SCCOL nX2, BOOL bShowProt, BOOL bPagebreakMode )
+{
+ if ( rFirst.bChanged != rOther.bChanged ||
+ rFirst.bEmptyBack != rOther.bEmptyBack )
+ return FALSE;
+
+ SCCOL nX;
+ if ( bShowProt )
+ {
+ for ( nX=nX1; nX<=nX2; nX++ )
+ {
+ const ScPatternAttr* pPat1 = rFirst.pCellInfo[nX+1].pPatternAttr;
+ const ScPatternAttr* pPat2 = rOther.pCellInfo[nX+1].pPatternAttr;
+ if ( !pPat1 || !pPat2 ||
+ &pPat1->GetItem(ATTR_PROTECTION) != &pPat2->GetItem(ATTR_PROTECTION) )
+ return FALSE;
+ }
+ }
+ else
+ {
+ for ( nX=nX1; nX<=nX2; nX++ )
+ if ( rFirst.pCellInfo[nX+1].pBackground != rOther.pCellInfo[nX+1].pBackground )
+ return FALSE;
+ }
+
+ if ( rFirst.nRotMaxCol != SC_ROTMAX_NONE || rOther.nRotMaxCol != SC_ROTMAX_NONE )
+ for ( nX=nX1; nX<=nX2; nX++ )
+ if ( rFirst.pCellInfo[nX+1].nRotateDir != rOther.pCellInfo[nX+1].nRotateDir )
+ return FALSE;
+
+ if ( bPagebreakMode )
+ for ( nX=nX1; nX<=nX2; nX++ )
+ if ( rFirst.pCellInfo[nX+1].bPrinted != rOther.pCellInfo[nX+1].bPrinted )
+ return FALSE;
+
+ return TRUE;
+}
+
+void ScOutputData::DrawDocumentBackground()
+{
+ if ( !bSolidBackground )
+ return;
+
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+ Rectangle aRect(nScrX - nOneX, nScrY - nOneY, nScrX + nScrW, nScrY + nScrH);
+ Color aBgColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+ pDev->SetFillColor(aBgColor);
+ pDev->DrawRect(aRect);
+}
+
+void ScOutputData::DrawBackground()
+{
+ FindRotated(); //! von aussen ?
+
+ Rectangle aRect;
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ if (bMetaFile)
+ nOneX = nOneY = 0;
+
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+ long nSignedOneX = nOneX * nLayoutSign;
+
+ pDev->SetLineColor();
+
+ BOOL bShowProt = bSyntaxMode && pDoc->IsTabProtected(nTab);
+ BOOL bDoAll = bShowProt || bPagebreakMode || bSolidBackground;
+
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor &&
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ long nRowHeight = pThisRowInfo->nHeight;
+
+ if ( pThisRowInfo->bChanged )
+ {
+ if ( ( ( pThisRowInfo->bEmptyBack ) || bSyntaxMode ) && !bDoAll )
+ {
+ // nichts
+ }
+ else
+ {
+ // scan for rows with the same background:
+ SCSIZE nSkip = 0;
+ while ( nArrY+nSkip+2<nArrCount &&
+ lcl_EqualBack( *pThisRowInfo, pRowInfo[nArrY+nSkip+1],
+ nX1, nX2, bShowProt, bPagebreakMode ) )
+ {
+ ++nSkip;
+ nRowHeight += pRowInfo[nArrY+nSkip].nHeight; // after incrementing
+ }
+
+ long nPosX = nScrX;
+ if ( bLayoutRTL )
+ nPosX += nMirrorW - nOneX;
+ aRect = Rectangle( nPosX, nPosY-nOneY, nPosX, nPosY+nRowHeight-nOneY );
+
+ const SvxBrushItem* pOldBackground = NULL;
+ const SvxBrushItem* pBackground;
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+
+ if (bCellContrast)
+ {
+ // high contrast for cell borders and backgrounds -> empty background
+ pBackground = ScGlobal::GetEmptyBrushItem();
+ }
+ else if (bShowProt) // show cell protection in syntax mode
+ {
+ const ScPatternAttr* pP = pInfo->pPatternAttr;
+ if (pP)
+ {
+ const ScProtectionAttr& rProt = (const ScProtectionAttr&)
+ pP->GetItem(ATTR_PROTECTION);
+ if (rProt.GetProtection() || rProt.GetHideCell())
+ pBackground = ScGlobal::GetProtectedBrushItem();
+ else
+ pBackground = ScGlobal::GetEmptyBrushItem();
+ }
+ else
+ pBackground = NULL;
+ }
+ else
+ pBackground = pInfo->pBackground;
+
+ if ( bPagebreakMode && !pInfo->bPrinted )
+ pBackground = ScGlobal::GetProtectedBrushItem();
+
+ if ( pInfo->nRotateDir > SC_ROTDIR_STANDARD &&
+ pBackground->GetColor().GetTransparency() != 255 &&
+ !bCellContrast )
+ {
+ SCROW nY = pRowInfo[nArrY].nRowNo;
+ pBackground = lcl_FindBackground( pDoc, nX, nY, nTab );
+ }
+
+ if ( pBackground != pOldBackground )
+ {
+ aRect.Right() = nPosX-nSignedOneX;
+ if (pOldBackground) // ==0 if hidden
+ {
+ Color aBackCol = pOldBackground->GetColor();
+ if ( !aBackCol.GetTransparency() ) //! partial transparency?
+ {
+ pDev->SetFillColor( aBackCol );
+ pDev->DrawRect( aRect );
+ }
+ }
+ aRect.Left() = nPosX - nSignedOneX;
+ pOldBackground = pBackground;
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ aRect.Right() = nPosX-nSignedOneX;
+ if (pOldBackground)
+ {
+ Color aBackCol = pOldBackground->GetColor();
+ if ( !aBackCol.GetTransparency() ) //! partial transparency?
+ {
+ pDev->SetFillColor( aBackCol );
+ pDev->DrawRect( aRect );
+ }
+ }
+
+ nArrY += nSkip;
+ }
+ }
+ nPosY += nRowHeight;
+ }
+}
+
+void ScOutputData::DrawShadow()
+{
+ DrawExtraShadow( FALSE, FALSE, FALSE, FALSE );
+}
+
+void ScOutputData::DrawExtraShadow(BOOL bLeft, BOOL bTop, BOOL bRight, BOOL bBottom)
+{
+ pDev->SetLineColor();
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor && rStyleSettings.GetHighContrastMode();
+ Color aAutoTextColor;
+ if ( bCellContrast )
+ aAutoTextColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ nInitPosX += nMirrorW - nOneX;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ long nPosY = nScrY - pRowInfo[0].nHeight;
+ for (SCSIZE nArrY=0; nArrY<nArrCount; nArrY++)
+ {
+ BOOL bCornerY = ( nArrY == 0 ) || ( nArrY+1 == nArrCount );
+ BOOL bSkipY = ( nArrY==0 && !bTop ) || ( nArrY+1 == nArrCount && !bBottom );
+
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ long nRowHeight = pThisRowInfo->nHeight;
+
+ if ( pThisRowInfo->bChanged && !bSkipY )
+ {
+ long nPosX = nInitPosX - pRowInfo[0].pCellInfo[nX1].nWidth * nLayoutSign;
+ for (SCCOL nArrX=nX1; nArrX<=nX2+2; nArrX++)
+ {
+ BOOL bCornerX = ( nArrX==nX1 || nArrX==nX2+2 );
+ BOOL bSkipX = ( nArrX==nX1 && !bLeft ) || ( nArrX==nX2+2 && !bRight );
+
+ for (USHORT nPass=0; nPass<2; nPass++) // horizontal / vertikal
+ {
+ const SvxShadowItem* pAttr = nPass ?
+ pThisRowInfo->pCellInfo[nArrX].pVShadowOrigin :
+ pThisRowInfo->pCellInfo[nArrX].pHShadowOrigin;
+ if ( pAttr && !bSkipX )
+ {
+ ScShadowPart ePart = nPass ?
+ pThisRowInfo->pCellInfo[nArrX].eVShadowPart :
+ pThisRowInfo->pCellInfo[nArrX].eHShadowPart;
+
+ BOOL bDo = TRUE;
+ if ( (nPass==0 && bCornerX) || (nPass==1 && bCornerY) )
+ if ( ePart != SC_SHADOW_CORNER )
+ bDo = FALSE;
+
+ if (bDo)
+ {
+ long nThisWidth = pRowInfo[0].pCellInfo[nArrX].nWidth;
+ long nMaxWidth = nThisWidth;
+ if (!nMaxWidth)
+ {
+ //! direction must depend on shadow location
+ SCCOL nWx = nArrX; // nX+1
+ while (nWx<nX2 && !pRowInfo[0].pCellInfo[nWx+1].nWidth)
+ ++nWx;
+ nMaxWidth = pRowInfo[0].pCellInfo[nWx+1].nWidth;
+ }
+
+// Rectangle aRect( Point(nPosX,nPosY),
+// Size( pRowInfo[0].pCellInfo[nArrX].nWidth,
+// pRowInfo[nArrY].nHeight ) );
+
+ // rectangle is in logical orientation
+ Rectangle aRect( nPosX, nPosY,
+ nPosX + ( nThisWidth - 1 ) * nLayoutSign,
+ nPosY + pRowInfo[nArrY].nHeight - 1 );
+
+ long nSize = pAttr->GetWidth();
+ long nSizeX = (long)(nSize*nPPTX);
+ if (nSizeX >= nMaxWidth) nSizeX = nMaxWidth-1;
+ long nSizeY = (long)(nSize*nPPTY);
+ if (nSizeY >= nRowHeight) nSizeY = nRowHeight-1;
+
+ nSizeX *= nLayoutSign; // used only to add to rectangle values
+
+ SvxShadowLocation eLoc = pAttr->GetLocation();
+ if ( bLayoutRTL )
+ {
+ // Shadow location is specified as "visual" (right is always right),
+ // so the attribute's location value is mirrored here and in FillInfo.
+ switch (eLoc)
+ {
+ case SVX_SHADOW_BOTTOMRIGHT: eLoc = SVX_SHADOW_BOTTOMLEFT; break;
+ case SVX_SHADOW_BOTTOMLEFT: eLoc = SVX_SHADOW_BOTTOMRIGHT; break;
+ case SVX_SHADOW_TOPRIGHT: eLoc = SVX_SHADOW_TOPLEFT; break;
+ case SVX_SHADOW_TOPLEFT: eLoc = SVX_SHADOW_TOPRIGHT; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+
+ if (ePart == SC_SHADOW_HORIZ || ePart == SC_SHADOW_HSTART ||
+ ePart == SC_SHADOW_CORNER)
+ {
+ if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_TOPRIGHT)
+ aRect.Top() = aRect.Bottom() - nSizeY;
+ else
+ aRect.Bottom() = aRect.Top() + nSizeY;
+ }
+ if (ePart == SC_SHADOW_VERT || ePart == SC_SHADOW_VSTART ||
+ ePart == SC_SHADOW_CORNER)
+ {
+ if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_BOTTOMLEFT)
+ aRect.Left() = aRect.Right() - nSizeX;
+ else
+ aRect.Right() = aRect.Left() + nSizeX;
+ }
+ if (ePart == SC_SHADOW_HSTART)
+ {
+ if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_BOTTOMLEFT)
+ aRect.Right() -= nSizeX;
+ else
+ aRect.Left() += nSizeX;
+ }
+ if (ePart == SC_SHADOW_VSTART)
+ {
+ if (eLoc == SVX_SHADOW_TOPLEFT || eLoc == SVX_SHADOW_TOPRIGHT)
+ aRect.Bottom() -= nSizeY;
+ else
+ aRect.Top() += nSizeY;
+ }
+
+ //! merge rectangles?
+ pDev->SetFillColor( bCellContrast ? aAutoTextColor : pAttr->GetColor() );
+ pDev->DrawRect( aRect );
+ }
+ }
+ }
+
+ nPosX += pRowInfo[0].pCellInfo[nArrX].nWidth * nLayoutSign;
+ }
+ }
+ nPosY += nRowHeight;
+ }
+}
+
+//
+// Loeschen
+//
+
+void ScOutputData::DrawClear()
+{
+ Rectangle aRect;
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ // (called only for ScGridWindow)
+ Color aBgColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+
+ if (bMetaFile)
+ nOneX = nOneY = 0;
+
+ pDev->SetLineColor();
+
+ pDev->SetFillColor( aBgColor );
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ long nRowHeight = pThisRowInfo->nHeight;
+
+ if ( pThisRowInfo->bChanged )
+ {
+ // scan for more rows which must be painted:
+ SCSIZE nSkip = 0;
+ while ( nArrY+nSkip+2<nArrCount && pRowInfo[nArrY+nSkip+1].bChanged )
+ {
+ ++nSkip;
+ nRowHeight += pRowInfo[nArrY+nSkip].nHeight; // after incrementing
+ }
+
+ aRect = Rectangle( Point( nScrX, nPosY ),
+ Size( nScrW+1-nOneX, nRowHeight+1-nOneY) );
+ pDev->DrawRect( aRect );
+
+ nArrY += nSkip;
+ }
+ nPosY += nRowHeight;
+ }
+}
+
+
+//
+// Linien
+//
+
+long lclGetSnappedX( OutputDevice& rDev, long nPosX, bool bSnapPixel )
+{
+ return (bSnapPixel && nPosX) ? rDev.PixelToLogic( rDev.LogicToPixel( Size( nPosX, 0 ) ) ).Width() : nPosX;
+}
+
+long lclGetSnappedY( OutputDevice& rDev, long nPosY, bool bSnapPixel )
+{
+ return (bSnapPixel && nPosY) ? rDev.PixelToLogic( rDev.LogicToPixel( Size( 0, nPosY ) ) ).Height() : nPosY;
+}
+
+size_t lclGetArrayColFromCellInfoX( USHORT nCellInfoX, USHORT nCellInfoFirstX, USHORT nCellInfoLastX, bool bRTL )
+{
+ return static_cast< size_t >( bRTL ? (nCellInfoLastX + 2 - nCellInfoX) : (nCellInfoX - nCellInfoFirstX) );
+}
+
+void ScOutputData::DrawFrame()
+{
+ ULONG nOldDrawMode = pDev->GetDrawMode();
+
+ Color aSingleColor;
+ BOOL bUseSingleColor = FALSE;
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor && rStyleSettings.GetHighContrastMode();
+
+ // #107519# if a Calc OLE object is embedded in Draw/Impress, the VCL DrawMode is used
+ // for display mode / B&W printing. The VCL DrawMode handling doesn't work for lines
+ // that are drawn with DrawRect, so if the line/background bits are set, the DrawMode
+ // must be reset and the border colors handled here.
+
+ if ( ( nOldDrawMode & DRAWMODE_WHITEFILL ) && ( nOldDrawMode & DRAWMODE_BLACKLINE ) )
+ {
+ pDev->SetDrawMode( nOldDrawMode & (~DRAWMODE_WHITEFILL) );
+ aSingleColor.SetColor( COL_BLACK );
+ bUseSingleColor = TRUE;
+ }
+ else if ( ( nOldDrawMode & DRAWMODE_SETTINGSFILL ) && ( nOldDrawMode & DRAWMODE_SETTINGSLINE ) )
+ {
+ pDev->SetDrawMode( nOldDrawMode & (~DRAWMODE_SETTINGSFILL) );
+ aSingleColor = rStyleSettings.GetWindowTextColor(); // same as used in VCL for DRAWMODE_SETTINGSLINE
+ bUseSingleColor = TRUE;
+ }
+ else if ( bCellContrast )
+ {
+ aSingleColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ bUseSingleColor = TRUE;
+ }
+
+ const Color* pForceColor = bUseSingleColor ? &aSingleColor : 0;
+
+ if (bAnyRotated)
+ DrawRotatedFrame( pForceColor ); // removes the lines that must not be painted here
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ nInitPosX += nMirrorW - nOneX;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+
+ // *** set column and row sizes of the frame border array ***
+
+ svx::frame::Array& rArray = mrTabInfo.maArray;
+ size_t nColCount = rArray.GetColCount();
+ size_t nRowCount = rArray.GetRowCount();
+
+ // row heights
+
+ // row 0 is not visible (dummy for borders from top) - subtract its height from initial position
+ // subtract 1 unit more, because position 0 is first *in* cell, grid line is one unit before
+ long nOldPosY = nScrY - 1 - pRowInfo[ 0 ].nHeight;
+ long nOldSnapY = lclGetSnappedY( *pDev, nOldPosY, bSnapPixel );
+ rArray.SetYOffset( nOldSnapY );
+ for( size_t nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ long nNewPosY = nOldPosY + pRowInfo[ nRow ].nHeight;
+ long nNewSnapY = lclGetSnappedY( *pDev, nNewPosY, bSnapPixel );
+ rArray.SetRowHeight( nRow, nNewSnapY - nOldSnapY );
+ nOldPosY = nNewPosY;
+ nOldSnapY = nNewSnapY;
+ }
+
+ // column widths
+
+ // column nX1 is not visible (dummy for borders from left) - subtract its width from initial position
+ // subtract 1 unit more, because position 0 is first *in* cell, grid line is one unit above
+ long nOldPosX = nInitPosX - nLayoutSign * (1 + pRowInfo[ 0 ].pCellInfo[ nX1 ].nWidth);
+ long nOldSnapX = lclGetSnappedX( *pDev, nOldPosX, bSnapPixel );
+ // set X offset for left-to-right sheets; for right-to-left sheets this is done after for() loop
+ if( !bLayoutRTL )
+ rArray.SetXOffset( nOldSnapX );
+ for( USHORT nInfoIdx = nX1; nInfoIdx <= nX2 + 2; ++nInfoIdx )
+ {
+ size_t nCol = lclGetArrayColFromCellInfoX( nInfoIdx, nX1, nX2, bLayoutRTL );
+ long nNewPosX = nOldPosX + pRowInfo[ 0 ].pCellInfo[ nInfoIdx ].nWidth * nLayoutSign;
+ long nNewSnapX = lclGetSnappedX( *pDev, nNewPosX, bSnapPixel );
+ rArray.SetColWidth( nCol, Abs( nNewSnapX - nOldSnapX ) );
+ nOldPosX = nNewPosX;
+ nOldSnapX = nNewSnapX;
+ }
+ if( bLayoutRTL )
+ rArray.SetXOffset( nOldSnapX );
+
+ // *** draw the array ***
+
+ size_t nFirstCol = 1;
+ size_t nFirstRow = 1;
+ size_t nLastCol = nColCount - 2;
+ size_t nLastRow = nRowCount - 2;
+
+ if( mrTabInfo.mbPageMode )
+ rArray.SetClipRange( nFirstCol, nFirstRow, nLastCol, nLastRow );
+
+ // draw only rows with set RowInfo::bChanged flag
+ size_t nRow1 = nFirstRow;
+ while( nRow1 <= nLastRow )
+ {
+ while( (nRow1 <= nLastRow) && !pRowInfo[ nRow1 ].bChanged ) ++nRow1;
+ if( nRow1 <= nLastRow )
+ {
+ size_t nRow2 = nRow1;
+ while( (nRow2 + 1 <= nLastRow) && pRowInfo[ nRow2 + 1 ].bChanged ) ++nRow2;
+ rArray.DrawRange( *pDev, nFirstCol, nRow1, nLastCol, nRow2, pForceColor );
+ nRow1 = nRow2 + 1;
+ }
+ }
+
+ pDev->SetDrawMode(nOldDrawMode);
+}
+
+// -------------------------------------------------------------------------
+
+// Linie unter der Zelle
+
+const SvxBorderLine* lcl_FindHorLine( ScDocument* pDoc,
+ SCCOL nCol, SCROW nRow, SCTAB nTab, USHORT nRotDir,
+ BOOL bTopLine )
+{
+ if ( nRotDir != SC_ROTDIR_LEFT && nRotDir != SC_ROTDIR_RIGHT )
+ return NULL;
+
+ BOOL bFound = FALSE;
+ while (!bFound)
+ {
+ if ( nRotDir == SC_ROTDIR_LEFT )
+ {
+ // Text nach links -> Linie von rechts
+ if ( nCol < MAXCOL )
+ ++nCol;
+ else
+ return NULL; // war nix
+ }
+ else
+ {
+ // Text nach rechts -> Linie von links
+ if ( nCol > 0 )
+ --nCol;
+ else
+ return NULL; // war nix
+ }
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ const SfxItemSet* pCondSet = pDoc->GetCondResult( nCol, nRow, nTab );
+ if ( !pPattern->GetRotateVal( pCondSet ) ||
+ ((const SvxRotateModeItem&)pPattern->GetItem(
+ ATTR_ROTATE_MODE, pCondSet)).GetValue() == SVX_ROTATE_MODE_STANDARD )
+ bFound = TRUE;
+ }
+
+ if (bTopLine)
+ --nRow;
+ const SvxBorderLine* pThisBottom;
+ if ( ValidRow(nRow) )
+ pThisBottom = ((const SvxBoxItem*)pDoc->GetAttr( nCol, nRow, nTab, ATTR_BORDER ))->GetBottom();
+ else
+ pThisBottom = NULL;
+ const SvxBorderLine* pNextTop;
+ if ( nRow < MAXROW )
+ pNextTop = ((const SvxBoxItem*)pDoc->GetAttr( nCol, nRow+1, nTab, ATTR_BORDER ))->GetTop();
+ else
+ pNextTop = NULL;
+
+ if ( ScHasPriority( pThisBottom, pNextTop ) )
+ return pThisBottom;
+ else
+ return pNextTop;
+}
+
+// lcl_HorizLine muss genau zu normal ausgegebenen Linien passen!
+
+void lcl_HorizLine( OutputDevice& rDev, const Point& rLeft, const Point& rRight,
+ const svx::frame::Style& rLine, const Color* pForceColor )
+{
+ svx::frame::DrawHorFrameBorder( rDev, rLeft, rRight, rLine, pForceColor );
+}
+
+void lcl_VertLineEnds( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
+ const Color& rColor, long nXOffs, long nWidth,
+ const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine )
+{
+ rDev.SetLineColor(rColor); // PEN_NULL ???
+ rDev.SetFillColor(rColor);
+
+ // Position oben/unten muss unabhaengig von der Liniendicke sein,
+ // damit der Winkel stimmt (oder X-Position auch anpassen)
+ long nTopPos = rTop.Y();
+ long nBotPos = rBottom.Y();
+
+ long nTopLeft = rTop.X() + nXOffs;
+ long nTopRight = nTopLeft + nWidth - 1;
+
+ long nBotLeft = rBottom.X() + nXOffs;
+ long nBotRight = nBotLeft + nWidth - 1;
+
+ // oben abschliessen
+
+ if ( rTopLine.Prim() )
+ {
+ long nLineW = rTopLine.GetWidth();
+ if (nLineW >= 2)
+ {
+ Point aTriangle[3];
+ aTriangle[0] = Point( nTopLeft, nTopPos ); // wie aPoints[0]
+ aTriangle[1] = Point( nTopRight, nTopPos ); // wie aPoints[1]
+ aTriangle[2] = Point( rTop.X(), nTopPos - (nLineW - 1) / 2 );
+ Polygon aTriPoly( 3, aTriangle );
+ rDev.DrawPolygon( aTriPoly );
+ }
+ }
+
+ // unten abschliessen
+
+ if ( rBottomLine.Prim() )
+ {
+ long nLineW = rBottomLine.GetWidth();
+ if (nLineW >= 2)
+ {
+ Point aTriangle[3];
+ aTriangle[0] = Point( nBotLeft, nBotPos ); // wie aPoints[3]
+ aTriangle[1] = Point( nBotRight, nBotPos ); // wie aPoints[2]
+ aTriangle[2] = Point( rBottom.X(), nBotPos - (nLineW - 1) / 2 + nLineW - 1 );
+ Polygon aTriPoly( 3, aTriangle );
+ rDev.DrawPolygon( aTriPoly );
+ }
+ }
+}
+
+void lcl_VertLine( OutputDevice& rDev, const Point& rTop, const Point& rBottom,
+ const svx::frame::Style& rLine,
+ const svx::frame::Style& rTopLine, const svx::frame::Style& rBottomLine,
+ const Color* pForceColor )
+{
+ if( rLine.Prim() )
+ {
+ svx::frame::DrawVerFrameBorderSlanted( rDev, rTop, rBottom, rLine, pForceColor );
+
+ svx::frame::Style aScaled( rLine );
+ aScaled.ScaleSelf( 1.0 / cos( svx::frame::GetVerDiagAngle( rTop, rBottom ) ) );
+ if( pForceColor )
+ aScaled.SetColor( *pForceColor );
+
+ long nXOffs = (aScaled.GetWidth() - 1) / -2L;
+
+ lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColor(),
+ nXOffs, aScaled.Prim(), rTopLine, rBottomLine );
+
+ if( aScaled.Secn() )
+ lcl_VertLineEnds( rDev, rTop, rBottom, aScaled.GetColor(),
+ nXOffs + aScaled.Prim() + aScaled.Dist(), aScaled.Secn(), rTopLine, rBottomLine );
+ }
+}
+
+void ScOutputData::DrawRotatedFrame( const Color* pForceColor )
+{
+ //! nRotMax speichern
+ SCCOL nRotMax = nX2;
+ for (SCSIZE nRotY=0; nRotY<nArrCount; nRotY++)
+ if (pRowInfo[nRotY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nRotY].nRotMaxCol > nRotMax)
+ nRotMax = pRowInfo[nRotY].nRotMaxCol;
+
+ const ScPatternAttr* pPattern;
+ const SfxItemSet* pCondSet;
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor && rStyleSettings.GetHighContrastMode();
+
+ // color (pForceColor) is determined externally, including DrawMode changes
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ nInitPosX += nMirrorW - nOneX;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ Rectangle aClipRect( Point(nScrX, nScrY), Size(nScrW, nScrH) );
+ if (bMetaFile)
+ {
+ pDev->Push();
+ pDev->IntersectClipRegion( aClipRect );
+ }
+ else
+ pDev->SetClipRegion( Region( aClipRect ) );
+
+ svx::frame::Array& rArray = mrTabInfo.maArray;
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY<nArrCount; nArrY++)
+ {
+ // Rotated wird auch 1 Zeile ueber/unter Changed gezeichnet, falls Teile
+ // in die Zeile hineinragen...
+
+ RowInfo& rPrevRowInfo = pRowInfo[nArrY-1];
+ RowInfo& rThisRowInfo = pRowInfo[nArrY];
+ RowInfo& rNextRowInfo = pRowInfo[nArrY+1];
+
+ size_t nRow = static_cast< size_t >( nArrY );
+
+ long nRowHeight = rThisRowInfo.nHeight;
+ if ( rThisRowInfo.nRotMaxCol != SC_ROTMAX_NONE &&
+ ( rThisRowInfo.bChanged || rPrevRowInfo.bChanged ||
+ ( nArrY+1<nArrCount && rNextRowInfo.bChanged ) ) )
+ {
+ SCROW nY = rThisRowInfo.nRowNo;
+ long nPosX = 0;
+ SCCOL nX;
+ for (nX=0; nX<=nRotMax; nX++)
+ {
+ if (nX==nX1) nPosX = nInitPosX; // calculated individually for preceding positions
+
+ USHORT nArrX = nX + 1;
+
+ CellInfo* pInfo = &rThisRowInfo.pCellInfo[nArrX];
+ long nColWidth = pRowInfo[0].pCellInfo[nArrX].nWidth;
+ if ( pInfo->nRotateDir > SC_ROTDIR_STANDARD &&
+ !pInfo->bHOverlapped && !pInfo->bVOverlapped )
+ {
+ pPattern = pInfo->pPatternAttr;
+ pCondSet = pInfo->pConditionSet;
+ if (!pPattern)
+ {
+ pPattern = pDoc->GetPattern( nX, nY, nTab );
+ pInfo->pPatternAttr = pPattern;
+ pCondSet = pDoc->GetCondResult( nX, nY, nTab );
+ pInfo->pConditionSet = pCondSet;
+ }
+
+ //! LastPattern etc.
+
+ long nAttrRotate = pPattern->GetRotateVal( pCondSet );
+ SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&)
+ pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
+
+ if ( nAttrRotate )
+ {
+ if (nX<nX1) // negative Position berechnen
+ {
+ nPosX = nInitPosX;
+ SCCOL nCol = nX1;
+ while (nCol > nX)
+ {
+ --nCol;
+ nPosX -= nLayoutSign * (long) pRowInfo[0].pCellInfo[nCol+1].nWidth;
+ }
+ }
+
+ // Startposition minus 1, damit auch schraege Hintergruende
+ // zur Umrandung passen (Umrandung ist auf dem Gitter)
+
+ long nTop = nPosY - 1;
+ long nBottom = nPosY + nRowHeight - 1;
+ long nTopLeft = nPosX - nLayoutSign;
+ long nTopRight = nPosX + ( nColWidth - 1 ) * nLayoutSign;
+ long nBotLeft = nTopLeft;
+ long nBotRight = nTopRight;
+
+ // inclusion of the sign here hasn't been decided yet
+ // (if not, the extension of the non-rotated background must also be changed)
+ double nRealOrient = nLayoutSign * nAttrRotate * F_PI18000; // 1/100th degrees
+ double nCos = cos( nRealOrient );
+ double nSin = sin( nRealOrient );
+ //! begrenzen !!!
+ long nSkew = (long) ( nRowHeight * nCos / nSin );
+
+ switch (eRotMode)
+ {
+ case SVX_ROTATE_MODE_BOTTOM:
+ nTopLeft += nSkew;
+ nTopRight += nSkew;
+ break;
+ case SVX_ROTATE_MODE_CENTER:
+ nSkew /= 2;
+ nTopLeft += nSkew;
+ nTopRight += nSkew;
+ nBotLeft -= nSkew;
+ nBotRight -= nSkew;
+ break;
+ case SVX_ROTATE_MODE_TOP:
+ nBotLeft -= nSkew;
+ nBotRight -= nSkew;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ Point aPoints[4];
+ aPoints[0] = Point( nTopLeft, nTop );
+ aPoints[1] = Point( nTopRight, nTop );
+ aPoints[2] = Point( nBotRight, nBottom );
+ aPoints[3] = Point( nBotLeft, nBottom );
+
+ const SvxBrushItem* pBackground = pInfo->pBackground;
+ if (!pBackground)
+ pBackground = (const SvxBrushItem*) &pPattern->GetItem(
+ ATTR_BACKGROUND, pCondSet );
+ if (bCellContrast)
+ {
+ // high contrast for cell borders and backgrounds -> empty background
+ pBackground = ScGlobal::GetEmptyBrushItem();
+ }
+ const Color& rColor = pBackground->GetColor();
+ if ( rColor.GetTransparency() != 255 )
+ {
+ // #95879# draw background only for the changed row itself
+ // (background doesn't extend into other cells).
+ // For the borders (rotated and normal), clipping should be
+ // set if the row isn't changed, but at least the borders
+ // don't cover the cell contents.
+ if ( rThisRowInfo.bChanged )
+ {
+ Polygon aPoly( 4, aPoints );
+
+ // ohne Pen wird bei DrawPolygon rechts und unten
+ // ein Pixel weggelassen...
+ if ( rColor.GetTransparency() == 0 )
+ pDev->SetLineColor(rColor);
+ else
+ pDev->SetLineColor();
+ pDev->SetFillColor(rColor);
+ pDev->DrawPolygon( aPoly );
+ }
+ }
+
+ svx::frame::Style aTopLine, aBottomLine, aLeftLine, aRightLine;
+
+ if ( nX < nX1 || nX > nX2 ) // Attribute in FillInfo nicht gesetzt
+ {
+ //! Seitengrenzen fuer Druck beruecksichtigen !!!!!
+ const SvxBorderLine* pLeftLine;
+ const SvxBorderLine* pTopLine;
+ const SvxBorderLine* pRightLine;
+ const SvxBorderLine* pBottomLine;
+ pDoc->GetBorderLines( nX, nY, nTab,
+ &pLeftLine, &pTopLine, &pRightLine, &pBottomLine );
+ aTopLine.Set( pTopLine, nPPTY );
+ aBottomLine.Set( pBottomLine, nPPTY );
+ aLeftLine.Set( pLeftLine, nPPTX );
+ aRightLine.Set( pRightLine, nPPTX );
+ }
+ else
+ {
+ size_t nCol = lclGetArrayColFromCellInfoX( nArrX, nX1, nX2, bLayoutRTL );
+ aTopLine = rArray.GetCellStyleTop( nCol, nRow );
+ aBottomLine = rArray.GetCellStyleBottom( nCol, nRow );
+ aLeftLine = rArray.GetCellStyleLeft( nCol, nRow );
+ aRightLine = rArray.GetCellStyleRight( nCol, nRow );
+ // in RTL mode the array is already mirrored -> swap back left/right borders
+ if( bLayoutRTL )
+ std::swap( aLeftLine, aRightLine );
+ }
+
+ lcl_HorizLine( *pDev, aPoints[bLayoutRTL?1:0], aPoints[bLayoutRTL?0:1], aTopLine, pForceColor );
+ lcl_HorizLine( *pDev, aPoints[bLayoutRTL?2:3], aPoints[bLayoutRTL?3:2], aBottomLine, pForceColor );
+
+ lcl_VertLine( *pDev, aPoints[0], aPoints[3], aLeftLine, aTopLine, aBottomLine, pForceColor );
+ lcl_VertLine( *pDev, aPoints[1], aPoints[2], aRightLine, aTopLine, aBottomLine, pForceColor );
+ }
+ }
+ nPosX += nColWidth * nLayoutSign;
+ }
+
+ // erst hinterher im zweiten Schritt die Linien fuer normale Ausgabe loeschen
+
+ nX = nX1 > 0 ? (nX1-1) : static_cast<SCCOL>(0);
+ for (; nX<=nX2+1; nX++) // sichtbarer Teil +- 1
+ {
+ USHORT nArrX = nX + 1;
+ CellInfo& rInfo = rThisRowInfo.pCellInfo[nArrX];
+ if ( rInfo.nRotateDir > SC_ROTDIR_STANDARD &&
+ !rInfo.bHOverlapped && !rInfo.bVOverlapped )
+ {
+ pPattern = rInfo.pPatternAttr;
+ pCondSet = rInfo.pConditionSet;
+ SvxRotateMode eRotMode = (SvxRotateMode)((const SvxRotateModeItem&)
+ pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
+
+ size_t nCol = lclGetArrayColFromCellInfoX( nArrX, nX1, nX2, bLayoutRTL );
+
+ // horizontal: angrenzende Linie verlaengern
+ // (nur, wenn die gedrehte Zelle eine Umrandung hat)
+ USHORT nDir = rInfo.nRotateDir;
+ if ( rArray.GetCellStyleTop( nCol, nRow ).Prim() && eRotMode != SVX_ROTATE_MODE_TOP )
+ {
+ svx::frame::Style aStyle( lcl_FindHorLine( pDoc, nX, nY, nTab, nDir, TRUE ), nPPTY );
+ rArray.SetCellStyleTop( nCol, nRow, aStyle );
+ if( nRow > 0 )
+ rArray.SetCellStyleBottom( nCol, nRow - 1, aStyle );
+ }
+ if ( rArray.GetCellStyleBottom( nCol, nRow ).Prim() && eRotMode != SVX_ROTATE_MODE_BOTTOM )
+ {
+ svx::frame::Style aStyle( lcl_FindHorLine( pDoc, nX, nY, nTab, nDir, FALSE ), nPPTY );
+ rArray.SetCellStyleBottom( nCol, nRow, aStyle );
+ if( nRow + 1 < rArray.GetRowCount() )
+ rArray.SetCellStyleTop( nCol, nRow + 1, aStyle );
+ }
+
+ // always remove vertical borders
+ if( !rArray.IsMergedOverlappedLeft( nCol, nRow ) )
+ {
+ rArray.SetCellStyleLeft( nCol, nRow, svx::frame::Style() );
+ if( nCol > 0 )
+ rArray.SetCellStyleRight( nCol - 1, nRow, svx::frame::Style() );
+ }
+ if( !rArray.IsMergedOverlappedRight( nCol, nRow ) )
+ {
+ rArray.SetCellStyleRight( nCol, nRow, svx::frame::Style() );
+ if( nCol + 1 < rArray.GetColCount() )
+ rArray.SetCellStyleLeft( nCol + 1, nRow, svx::frame::Style() );
+ }
+
+ // remove diagonal borders
+ rArray.SetCellStyleTLBR( nCol, nRow, svx::frame::Style() );
+ rArray.SetCellStyleBLTR( nCol, nRow, svx::frame::Style() );
+ }
+ }
+ }
+ nPosY += nRowHeight;
+ }
+
+ if (bMetaFile)
+ pDev->Pop();
+ else
+ pDev->SetClipRegion();
+}
+
+// Drucker
+
+PolyPolygon ScOutputData::GetChangedArea()
+{
+ PolyPolygon aPoly;
+
+ Rectangle aDrawingRect;
+ aDrawingRect.Left() = nScrX;
+ aDrawingRect.Right() = nScrX+nScrW-1;
+
+ BOOL bHad = FALSE;
+ long nPosY = nScrY;
+ SCSIZE nArrY;
+ for (nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+
+ if ( pThisRowInfo->bChanged )
+ {
+ if (!bHad)
+ {
+ aDrawingRect.Top() = nPosY;
+ bHad = TRUE;
+ }
+ aDrawingRect.Bottom() = nPosY + pRowInfo[nArrY].nHeight - 1;
+ }
+ else if (bHad)
+ {
+ aPoly.Insert( Polygon( pDev->PixelToLogic(aDrawingRect) ) );
+ bHad = FALSE;
+ }
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ if (bHad)
+ aPoly.Insert( Polygon( pDev->PixelToLogic(aDrawingRect) ) );
+
+ return aPoly;
+}
+
+BOOL ScOutputData::SetChangedClip()
+{
+ PolyPolygon aPoly;
+
+ Rectangle aDrawingRect;
+ aDrawingRect.Left() = nScrX;
+ aDrawingRect.Right() = nScrX+nScrW-1;
+
+ BOOL bHad = FALSE;
+ long nPosY = nScrY;
+ SCSIZE nArrY;
+ for (nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+
+ if ( pThisRowInfo->bChanged )
+ {
+ if (!bHad)
+ {
+ aDrawingRect.Top() = nPosY;
+ bHad = TRUE;
+ }
+ aDrawingRect.Bottom() = nPosY + pRowInfo[nArrY].nHeight - 1;
+ }
+ else if (bHad)
+ {
+ aPoly.Insert( Polygon( pDev->PixelToLogic(aDrawingRect) ) );
+ bHad = FALSE;
+ }
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ if (bHad)
+ aPoly.Insert( Polygon( pDev->PixelToLogic(aDrawingRect) ) );
+
+ BOOL bRet = (aPoly.Count() != 0);
+ if (bRet)
+ pDev->SetClipRegion(Region(aPoly));
+ return bRet;
+}
+
+void ScOutputData::FindChanged()
+{
+ SCCOL nX;
+ SCSIZE nArrY;
+
+ BOOL bWasIdleDisabled = pDoc->IsIdleDisabled();
+ pDoc->DisableIdle( TRUE );
+ for (nArrY=0; nArrY<nArrCount; nArrY++)
+ pRowInfo[nArrY].bChanged = FALSE;
+
+ BOOL bProgress = FALSE;
+ for (nArrY=0; nArrY<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ for (nX=nX1; nX<=nX2; nX++)
+ {
+ ScBaseCell* pCell = pThisRowInfo->pCellInfo[nX+1].pCell;
+ if (pCell)
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
+ if ( !bProgress && pFCell->GetDirty() )
+ {
+ ScProgress::CreateInterpretProgress( pDoc, TRUE );
+ bProgress = TRUE;
+ }
+ if (!pFCell->IsRunning())
+ {
+ (void)pFCell->GetValue();
+ if (pFCell->IsChanged())
+ {
+ pThisRowInfo->bChanged = TRUE;
+ if ( pThisRowInfo->pCellInfo[nX+1].bMerged )
+ {
+ SCSIZE nOverY = nArrY + 1;
+ while ( nOverY<nArrCount &&
+ pRowInfo[nOverY].pCellInfo[nX+1].bVOverlapped )
+ {
+ pRowInfo[nOverY].bChanged = TRUE;
+ ++nOverY;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if ( bProgress )
+ ScProgress::DeleteInterpretProgress();
+ pDoc->DisableIdle( bWasIdleDisabled );
+}
+
+#ifdef OLD_SELECTION_PAINT
+void ScOutputData::DrawMark( Window* pWin )
+{
+ Rectangle aRect;
+ ScInvertMerger aInvert( pWin );
+ //! additional method AddLineRect for ScInvertMerger?
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if (pThisRowInfo->bChanged)
+ {
+ long nPosX = nScrX;
+ if (bLayoutRTL)
+ nPosX += nMirrorW - 1; // always in pixels
+
+ aRect = Rectangle( Point( nPosX,nPosY ), Size(1, pThisRowInfo->nHeight) );
+ if (bLayoutRTL)
+ aRect.Left() = aRect.Right() + 1;
+ else
+ aRect.Right() = aRect.Left() - 1;
+
+ BOOL bOldMarked = FALSE;
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ if (pThisRowInfo->pCellInfo[nX+1].bMarked != bOldMarked)
+ {
+ if (bOldMarked && aRect.Right() >= aRect.Left())
+ aInvert.AddRect( aRect );
+
+ if (bLayoutRTL)
+ aRect.Right() = nPosX;
+ else
+ aRect.Left() = nPosX;
+
+ bOldMarked = pThisRowInfo->pCellInfo[nX+1].bMarked;
+ }
+
+ if (bLayoutRTL)
+ {
+ nPosX -= pRowInfo[0].pCellInfo[nX+1].nWidth;
+ aRect.Left() = nPosX+1;
+ }
+ else
+ {
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth;
+ aRect.Right() = nPosX-1;
+ }
+ }
+ if (bOldMarked && aRect.Right() >= aRect.Left())
+ aInvert.AddRect( aRect );
+ }
+ nPosY += pThisRowInfo->nHeight;
+ }
+}
+#endif
+
+void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY,
+ SCCOL nRefEndX, SCROW nRefEndY,
+ const Color& rColor, BOOL bHandle )
+{
+ PutInOrder( nRefStartX, nRefEndX );
+ PutInOrder( nRefStartY, nRefEndY );
+
+ if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY )
+ pDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab );
+
+ if ( nRefStartX <= nVisX2 && nRefEndX >= nVisX1 &&
+ nRefStartY <= nVisY2 && nRefEndY >= nVisY1 )
+ {
+ long nMinX = nScrX;
+ long nMinY = nScrY;
+ long nMaxX = nScrX+nScrW-1;
+ long nMaxY = nScrY+nScrH-1;
+ if ( bLayoutRTL )
+ {
+ long nTemp = nMinX;
+ nMinX = nMaxX;
+ nMaxX = nTemp;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ BOOL bTop = FALSE;
+ BOOL bBottom = FALSE;
+ BOOL bLeft = FALSE;
+ BOOL bRight = FALSE;
+
+ long nPosY = nScrY;
+ BOOL bNoStartY = ( nY1 < nRefStartY );
+ BOOL bNoEndY = FALSE;
+ for (SCSIZE nArrY=1; nArrY<nArrCount; nArrY++) // loop to end for bNoEndY check
+ {
+ SCROW nY = pRowInfo[nArrY].nRowNo;
+
+ if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) )
+ {
+ nMinY = nPosY;
+ bTop = TRUE;
+ }
+ if ( nY==nRefEndY )
+ {
+ nMaxY = nPosY + pRowInfo[nArrY].nHeight - 2;
+ bBottom = TRUE;
+ }
+ if ( nY>nRefEndY && bNoEndY )
+ {
+ nMaxY = nPosY-2;
+ bBottom = TRUE;
+ }
+ bNoStartY = ( nY < nRefStartY );
+ bNoEndY = ( nY < nRefEndY );
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ long nPosX = nScrX;
+ if ( bLayoutRTL )
+ nPosX += nMirrorW - 1; // always in pixels
+
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ if ( nX==nRefStartX )
+ {
+ nMinX = nPosX;
+ bLeft = TRUE;
+ }
+ if ( nX==nRefEndX )
+ {
+ nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 2 ) * nLayoutSign;
+ bRight = TRUE;
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+
+ if ( nMaxX * nLayoutSign >= nMinX * nLayoutSign &&
+ nMaxY >= nMinY )
+ {
+ pDev->SetLineColor( rColor );
+ if (bTop && bBottom && bLeft && bRight)
+ {
+ pDev->SetFillColor();
+ pDev->DrawRect( Rectangle( nMinX, nMinY, nMaxX, nMaxY ) );
+ }
+ else
+ {
+ if (bTop)
+ pDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) );
+ if (bBottom)
+ pDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) );
+ if (bLeft)
+ pDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) );
+ if (bRight)
+ pDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) );
+ }
+ if ( bHandle && bRight && bBottom )
+ {
+ pDev->SetLineColor();
+ pDev->SetFillColor( rColor );
+ pDev->DrawRect( Rectangle( nMaxX-3*nLayoutSign, nMaxY-3, nMaxX+nLayoutSign, nMaxY+1 ) );
+ }
+ }
+ }
+}
+
+void ScOutputData::DrawOneChange( SCCOL nRefStartX, SCROW nRefStartY,
+ SCCOL nRefEndX, SCROW nRefEndY,
+ const Color& rColor, USHORT nType )
+{
+ PutInOrder( nRefStartX, nRefEndX );
+ PutInOrder( nRefStartY, nRefEndY );
+
+ if ( nRefStartX == nRefEndX && nRefStartY == nRefEndY )
+ pDoc->ExtendMerge( nRefStartX, nRefStartY, nRefEndX, nRefEndY, nTab );
+
+ if ( nRefStartX <= nVisX2 + 1 && nRefEndX >= nVisX1 &&
+ nRefStartY <= nVisY2 + 1 && nRefEndY >= nVisY1 ) // +1 because it touches next cells left/top
+ {
+ long nMinX = nScrX;
+ long nMinY = nScrY;
+ long nMaxX = nScrX+nScrW-1;
+ long nMaxY = nScrY+nScrH-1;
+ if ( bLayoutRTL )
+ {
+ long nTemp = nMinX;
+ nMinX = nMaxX;
+ nMaxX = nTemp;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ BOOL bTop = FALSE;
+ BOOL bBottom = FALSE;
+ BOOL bLeft = FALSE;
+ BOOL bRight = FALSE;
+
+ long nPosY = nScrY;
+ BOOL bNoStartY = ( nY1 < nRefStartY );
+ BOOL bNoEndY = FALSE;
+ for (SCSIZE nArrY=1; nArrY<nArrCount; nArrY++) // loop to end for bNoEndY check
+ {
+ SCROW nY = pRowInfo[nArrY].nRowNo;
+
+ if ( nY==nRefStartY || (nY>nRefStartY && bNoStartY) )
+ {
+ nMinY = nPosY - 1;
+ bTop = TRUE;
+ }
+ if ( nY==nRefEndY )
+ {
+ nMaxY = nPosY + pRowInfo[nArrY].nHeight - 1;
+ bBottom = TRUE;
+ }
+ if ( nY>nRefEndY && bNoEndY )
+ {
+ nMaxY = nPosY - 1;
+ bBottom = TRUE;
+ }
+ bNoStartY = ( nY < nRefStartY );
+ bNoEndY = ( nY < nRefEndY );
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ long nPosX = nScrX;
+ if ( bLayoutRTL )
+ nPosX += nMirrorW - 1; // always in pixels
+
+ for (SCCOL nX=nX1; nX<=nX2+1; nX++)
+ {
+ if ( nX==nRefStartX )
+ {
+ nMinX = nPosX - nLayoutSign;
+ bLeft = TRUE;
+ }
+ if ( nX==nRefEndX )
+ {
+ nMaxX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 1 ) * nLayoutSign;
+ bRight = TRUE;
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+
+ if ( nMaxX * nLayoutSign >= nMinX * nLayoutSign &&
+ nMaxY >= nMinY )
+ {
+ if ( nType == SC_CAT_DELETE_ROWS )
+ bLeft = bRight = bBottom = FALSE; //! dicke Linie ???
+ else if ( nType == SC_CAT_DELETE_COLS )
+ bTop = bBottom = bRight = FALSE; //! dicke Linie ???
+
+ pDev->SetLineColor( rColor );
+ if (bTop && bBottom && bLeft && bRight)
+ {
+ pDev->SetFillColor();
+ pDev->DrawRect( Rectangle( nMinX, nMinY, nMaxX, nMaxY ) );
+ }
+ else
+ {
+ if (bTop)
+ {
+ pDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) );
+ if ( nType == SC_CAT_DELETE_ROWS )
+ pDev->DrawLine( Point( nMinX,nMinY+1 ), Point( nMaxX,nMinY+1 ) );
+ }
+ if (bBottom)
+ pDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) );
+ if (bLeft)
+ {
+ pDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) );
+ if ( nType == SC_CAT_DELETE_COLS )
+ pDev->DrawLine( Point( nMinX+nLayoutSign,nMinY ), Point( nMinX+nLayoutSign,nMaxY ) );
+ }
+ if (bRight)
+ pDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) );
+ }
+ if ( bLeft && bTop )
+ {
+ pDev->SetLineColor();
+ pDev->SetFillColor( rColor );
+ pDev->DrawRect( Rectangle( nMinX+nLayoutSign, nMinY+1, nMinX+3*nLayoutSign, nMinY+3 ) );
+ }
+ }
+ }
+}
+
+void ScOutputData::DrawChangeTrack()
+{
+ ScChangeTrack* pTrack = pDoc->GetChangeTrack();
+ ScChangeViewSettings* pSettings = pDoc->GetChangeViewSettings();
+ if ( !pTrack || !pTrack->GetFirst() || !pSettings || !pSettings->ShowChanges() )
+ return; // nix da oder abgeschaltet
+
+ ScActionColorChanger aColorChanger(*pTrack);
+
+ // Clipping passiert von aussen
+ //! ohne Clipping, nur betroffene Zeilen painten ??!??!?
+
+ SCCOL nEndX = nX2;
+ SCROW nEndY = nY2;
+ if ( nEndX < MAXCOL ) ++nEndX; // auch noch von der naechsten Zelle, weil die Markierung
+ if ( nEndY < MAXROW ) ++nEndY; // in die jeweils vorhergehende Zelle hineinragt
+ ScRange aViewRange( nX1, nY1, nTab, nEndX, nEndY, nTab );
+ const ScChangeAction* pAction = pTrack->GetFirst();
+ while (pAction)
+ {
+ ScChangeActionType eActionType;
+ if ( pAction->IsVisible() )
+ {
+ eActionType = pAction->GetType();
+ const ScBigRange& rBig = pAction->GetBigRange();
+ if ( rBig.aStart.Tab() == nTab )
+ {
+ ScRange aRange = rBig.MakeRange();
+
+ if ( eActionType == SC_CAT_DELETE_ROWS )
+ aRange.aEnd.SetRow( aRange.aStart.Row() );
+ else if ( eActionType == SC_CAT_DELETE_COLS )
+ aRange.aEnd.SetCol( aRange.aStart.Col() );
+
+ if ( aRange.Intersects( aViewRange ) &&
+ ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) )
+ {
+ aColorChanger.Update( *pAction );
+ Color aColor( aColorChanger.GetColor() );
+ DrawOneChange( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aColor, sal::static_int_cast<USHORT>(eActionType) );
+
+ }
+ }
+ if ( eActionType == SC_CAT_MOVE &&
+ ((const ScChangeActionMove*)pAction)->
+ GetFromRange().aStart.Tab() == nTab )
+ {
+ ScRange aRange = ((const ScChangeActionMove*)pAction)->
+ GetFromRange().MakeRange();
+ if ( aRange.Intersects( aViewRange ) &&
+ ScViewUtil::IsActionShown( *pAction, *pSettings, *pDoc ) )
+ {
+ aColorChanger.Update( *pAction );
+ Color aColor( aColorChanger.GetColor() );
+ DrawOneChange( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), aColor, sal::static_int_cast<USHORT>(eActionType) );
+ }
+ }
+ }
+
+ pAction = pAction->GetNext();
+ }
+}
+
+void ScOutputData::DrawNoteMarks()
+{
+ BOOL bFirst = TRUE;
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ nInitPosX += nMirrorW - 1; // always in pixels
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if ( pThisRowInfo->bChanged )
+ {
+ long nPosX = nInitPosX;
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ ScBaseCell* pCell = pInfo->pCell;
+ BOOL bIsMerged = FALSE;
+
+ if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped )
+ {
+ // find start of merged cell
+ bIsMerged = TRUE;
+ SCROW nY = pRowInfo[nArrY].nRowNo;
+ SCCOL nMergeX = nX;
+ SCROW nMergeY = nY;
+ pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab );
+ pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) );
+ // use origin's pCell for NotePtr test below
+ }
+
+ if ( pCell && pCell->HasNote() && ( bIsMerged ||
+ ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) )
+ {
+ if (bFirst)
+ {
+ pDev->SetLineColor();
+
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ if ( bUseStyleColor && rStyleSettings.GetHighContrastMode() )
+ pDev->SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ else
+ pDev->SetFillColor(COL_LIGHTRED);
+
+ bFirst = FALSE;
+ }
+
+ long nMarkX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - 4 ) * nLayoutSign;
+ if ( bIsMerged || pInfo->bMerged )
+ {
+ // if merged, add widths of all cells
+ SCCOL nNextX = nX + 1;
+ while ( nNextX <= nX2 + 1 && pThisRowInfo->pCellInfo[nNextX+1].bHOverlapped )
+ {
+ nMarkX += pRowInfo[0].pCellInfo[nNextX+1].nWidth * nLayoutSign;
+ ++nNextX;
+ }
+ }
+ if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) )
+ pDev->DrawRect( Rectangle( nMarkX,nPosY,nMarkX+2*nLayoutSign,nPosY+2 ) );
+ }
+
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ }
+ nPosY += pThisRowInfo->nHeight;
+ }
+}
+
+void ScOutputData::AddPDFNotes()
+{
+ vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
+ if ( !pPDFData || !pPDFData->GetIsExportNotes() )
+ return;
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ nInitPosX += nMirrorW - nOneX;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if ( pThisRowInfo->bChanged )
+ {
+ long nPosX = nInitPosX;
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ ScBaseCell* pCell = pInfo->pCell;
+ BOOL bIsMerged = FALSE;
+ SCROW nY = pRowInfo[nArrY].nRowNo;
+ SCCOL nMergeX = nX;
+ SCROW nMergeY = nY;
+
+ if ( nX==nX1 && pInfo->bHOverlapped && !pInfo->bVOverlapped )
+ {
+ // find start of merged cell
+ bIsMerged = TRUE;
+ pDoc->ExtendOverlapped( nMergeX, nMergeY, nX, nY, nTab );
+ pCell = pDoc->GetCell( ScAddress(nMergeX,nMergeY,nTab) );
+ // use origin's pCell for NotePtr test below
+ }
+
+ if ( pCell && pCell->HasNote() && ( bIsMerged ||
+ ( !pInfo->bHOverlapped && !pInfo->bVOverlapped ) ) )
+ {
+ long nNoteWidth = (long)( SC_CLIPMARK_SIZE * nPPTX );
+ long nNoteHeight = (long)( SC_CLIPMARK_SIZE * nPPTY );
+
+ long nMarkX = nPosX + ( pRowInfo[0].pCellInfo[nX+1].nWidth - nNoteWidth ) * nLayoutSign;
+ if ( bIsMerged || pInfo->bMerged )
+ {
+ // if merged, add widths of all cells
+ SCCOL nNextX = nX + 1;
+ while ( nNextX <= nX2 + 1 && pThisRowInfo->pCellInfo[nNextX+1].bHOverlapped )
+ {
+ nMarkX += pRowInfo[0].pCellInfo[nNextX+1].nWidth * nLayoutSign;
+ ++nNextX;
+ }
+ }
+ if ( bLayoutRTL ? ( nMarkX >= 0 ) : ( nMarkX < nScrX+nScrW ) )
+ {
+ Rectangle aNoteRect( nMarkX, nPosY, nMarkX+nNoteWidth*nLayoutSign, nPosY+nNoteHeight );
+ const ScPostIt* pNote = pCell->GetNote();
+
+ // Note title is the cell address (as on printed note pages)
+ String aTitle;
+ ScAddress aAddress( nMergeX, nMergeY, nTab );
+ aAddress.Format( aTitle, SCA_VALID, pDoc, pDoc->GetAddressConvention() );
+
+ // Content has to be a simple string without line breaks
+ String aContent = pNote->GetText();
+ xub_StrLen nPos;
+ while ( (nPos=aContent.Search('\n')) != STRING_NOTFOUND )
+ aContent.SetChar( nPos, ' ' );
+
+ vcl::PDFNote aNote;
+ aNote.Title = aTitle;
+ aNote.Contents = aContent;
+ pPDFData->CreateNote( aNoteRect, aNote );
+ }
+ }
+
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ }
+ nPosY += pThisRowInfo->nHeight;
+ }
+}
+
+void ScOutputData::DrawClipMarks()
+{
+ if (!bAnyClipped)
+ return;
+
+ Color aArrowFillCol( COL_LIGHTRED );
+
+ ULONG nOldDrawMode = pDev->GetDrawMode();
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ if ( bUseStyleColor && rStyleSettings.GetHighContrastMode() )
+ {
+ // use DrawMode to change the arrow's outline color
+ pDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE );
+ // use text color also for the fill color
+ aArrowFillCol.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ }
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ nInitPosX += nMirrorW - 1; // always in pixels
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ Rectangle aCellRect;
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if ( pThisRowInfo->bChanged )
+ {
+ SCROW nY = pThisRowInfo->nRowNo;
+ long nPosX = nInitPosX;
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ if (pInfo->nClipMark)
+ {
+ if (pInfo->bHOverlapped || pInfo->bVOverlapped)
+ {
+ // merge origin may be outside of visible area - use document functions
+
+ SCCOL nOverX = nX;
+ SCROW nOverY = nY;
+ long nStartPosX = nPosX;
+ long nStartPosY = nPosY;
+
+ while ( nOverX > 0 && ( ((const ScMergeFlagAttr*)pDoc->GetAttr(
+ nOverX, nOverY, nTab, ATTR_MERGE_FLAG ))->GetValue() & SC_MF_HOR ) )
+ {
+ --nOverX;
+ nStartPosX -= nLayoutSign * (long) ( pDoc->GetColWidth(nOverX,nTab) * nPPTX );
+ }
+
+ while ( nOverY > 0 && ( ((const ScMergeFlagAttr*)pDoc->GetAttr(
+ nOverX, nOverY, nTab, ATTR_MERGE_FLAG ))->GetValue() & SC_MF_VER ) )
+ {
+ --nOverY;
+ nStartPosY -= nLayoutSign * (long) ( pDoc->GetRowHeight(nOverY,nTab) * nPPTY );
+ }
+
+ long nOutWidth = (long) ( pDoc->GetColWidth(nOverX,nTab) * nPPTX );
+ long nOutHeight = (long) ( pDoc->GetRowHeight(nOverY,nTab) * nPPTY );
+
+ const ScMergeAttr* pMerge = (const ScMergeAttr*)
+ pDoc->GetAttr( nOverX, nOverY, nTab, ATTR_MERGE );
+ SCCOL nCountX = pMerge->GetColMerge();
+ for (SCCOL i=1; i<nCountX; i++)
+ nOutWidth += (long) ( pDoc->GetColWidth(nOverX+i,nTab) * nPPTX );
+ SCROW nCountY = pMerge->GetRowMerge();
+ nOutHeight += (long) pDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, nTab, nPPTY);
+
+ if ( bLayoutRTL )
+ nStartPosX -= nOutWidth - 1;
+ aCellRect = Rectangle( Point( nStartPosX, nStartPosY ), Size( nOutWidth, nOutHeight ) );
+ }
+ else
+ {
+ long nOutWidth = pRowInfo[0].pCellInfo[nX+1].nWidth;
+ long nOutHeight = pThisRowInfo->nHeight;
+
+ if ( pInfo->bMerged && pInfo->pPatternAttr )
+ {
+ SCCOL nOverX = nX;
+ SCROW nOverY = nY;
+ const ScMergeAttr* pMerge =
+ (ScMergeAttr*)&pInfo->pPatternAttr->GetItem(ATTR_MERGE);
+ SCCOL nCountX = pMerge->GetColMerge();
+ for (SCCOL i=1; i<nCountX; i++)
+ nOutWidth += (long) ( pDoc->GetColWidth(nOverX+i,nTab) * nPPTX );
+ SCROW nCountY = pMerge->GetRowMerge();
+ nOutHeight += (long) pDoc->GetScaledRowHeight( nOverY+1, nOverY+nCountY-1, nTab, nPPTY);
+ }
+
+ long nStartPosX = nPosX;
+ if ( bLayoutRTL )
+ nStartPosX -= nOutWidth - 1;
+ // #i80447# create aCellRect from two points in case nOutWidth is 0
+ aCellRect = Rectangle( Point( nStartPosX, nPosY ),
+ Point( nStartPosX+nOutWidth-1, nPosY+nOutHeight-1 ) );
+ }
+
+ aCellRect.Bottom() -= 1; // don't paint over the cell grid
+ if ( bLayoutRTL )
+ aCellRect.Left() += 1;
+ else
+ aCellRect.Right() -= 1;
+
+ long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX );
+ Size aMarkSize( nMarkPixel, (nMarkPixel-1)*2 );
+
+ if ( pInfo->nClipMark & ( bLayoutRTL ? SC_CLIPMARK_RIGHT : SC_CLIPMARK_LEFT ) )
+ {
+ // visually left
+ Rectangle aMarkRect = aCellRect;
+ aMarkRect.Right() = aCellRect.Left()+nMarkPixel-1;
+ SvxFont::DrawArrow( *pDev, aMarkRect, aMarkSize, aArrowFillCol, TRUE );
+ }
+ if ( pInfo->nClipMark & ( bLayoutRTL ? SC_CLIPMARK_LEFT : SC_CLIPMARK_RIGHT ) )
+ {
+ // visually right
+ Rectangle aMarkRect = aCellRect;
+ aMarkRect.Left() = aCellRect.Right()-nMarkPixel+1;
+ SvxFont::DrawArrow( *pDev, aMarkRect, aMarkSize, aArrowFillCol, FALSE );
+ }
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ }
+ nPosY += pThisRowInfo->nHeight;
+ }
+
+ pDev->SetDrawMode(nOldDrawMode);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
new file mode 100644
index 000000000000..3e8d9a66c2d9
--- /dev/null
+++ b/sc/source/ui/view/output2.cxx
@@ -0,0 +1,3887 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <editeng/adjitem.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <svx/rotmodit.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/unolingu.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/metric.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/pdfextoutdevdata.hxx>
+
+#ifndef _SVSTDARR_USHORTS
+#define _SVSTDARR_USHORTS
+#include <svl/svstdarr.hxx>
+#endif
+
+#include "output.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "cellform.hxx"
+#include "editutil.hxx"
+#include "progress.hxx"
+#include "scmod.hxx"
+#include "fillinfo.hxx"
+
+#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <math.h>
+
+//! Autofilter-Breite mit column.cxx zusammenfassen
+#define DROPDOWN_BITMAP_SIZE 18
+
+#define DRAWTEXT_MAX 32767
+
+const USHORT SC_SHRINKAGAIN_MAX = 7;
+
+// STATIC DATA -----------------------------------------------------------
+
+
+// -----------------------------------------------------------------------
+
+class ScDrawStringsVars
+{
+ ScOutputData* pOutput; // Verbindung
+
+ const ScPatternAttr* pPattern; // Attribute
+ const SfxItemSet* pCondSet; // aus bedingter Formatierung
+
+ Font aFont; // aus Attributen erzeugt
+ FontMetric aMetric;
+ long nAscentPixel; // always pixels
+ SvxCellOrientation eAttrOrient;
+ SvxCellHorJustify eAttrHorJust;
+ SvxCellVerJustify eAttrVerJust;
+ SvxCellJustifyMethod eAttrHorJustMethod;
+ SvxCellJustifyMethod eAttrVerJustMethod;
+ const SvxMarginItem* pMargin;
+ USHORT nIndent;
+ BOOL bRotated;
+
+ String aString; // Inhalte
+ Size aTextSize;
+ long nOriginalWidth;
+ long nMaxDigitWidth;
+ long nSignWidth;
+ long nDotWidth;
+ long nExpWidth;
+
+ ScBaseCell* pLastCell;
+ ULONG nValueFormat;
+ BOOL bLineBreak;
+ BOOL bRepeat;
+ BOOL bShrink;
+
+ BOOL bPixelToLogic;
+ BOOL bCellContrast;
+
+ Color aBackConfigColor; // used for ScPatternAttr::GetFont calls
+ Color aTextConfigColor;
+
+public:
+ ScDrawStringsVars(ScOutputData* pData, BOOL bPTL);
+ ~ScDrawStringsVars();
+
+ // SetPattern = ex-SetVars
+ // SetPatternSimple: ohne Font
+
+ void SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet, ScBaseCell* pCell, BYTE nScript );
+ void SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet );
+
+ BOOL SetText( ScBaseCell* pCell ); // TRUE -> pOldPattern vergessen
+ void SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth );
+ void SetAutoText( const String& rAutoText );
+
+ const ScPatternAttr* GetPattern() const { return pPattern; }
+ SvxCellOrientation GetOrient() const { return eAttrOrient; }
+ SvxCellHorJustify GetHorJust() const { return eAttrHorJust; }
+ SvxCellVerJustify GetVerJust() const { return eAttrVerJust; }
+ SvxCellJustifyMethod GetHorJustMethod() const { return eAttrHorJustMethod; }
+ SvxCellJustifyMethod GetVerJustMethod() const { return eAttrVerJustMethod; }
+ const SvxMarginItem* GetMargin() const { return pMargin; }
+
+ USHORT GetLeftTotal() const { return pMargin->GetLeftMargin() + nIndent; }
+
+ const String& GetString() const { return aString; }
+ const Size& GetTextSize() const { return aTextSize; }
+ long GetOriginalWidth() const { return nOriginalWidth; }
+
+ ULONG GetValueFormat() const { return nValueFormat; }
+ BOOL GetLineBreak() const { return bLineBreak; }
+ BOOL IsRepeat() const { return bRepeat; }
+ BOOL IsShrink() const { return bShrink; }
+
+ long GetAscent() const { return nAscentPixel; }
+ BOOL IsRotated() const { return bRotated; }
+
+ void SetShrinkScale( long nScale, BYTE nScript );
+
+ BOOL HasCondHeight() const { return pCondSet && SFX_ITEM_SET ==
+ pCondSet->GetItemState( ATTR_FONT_HEIGHT, TRUE ); }
+
+ BOOL HasEditCharacters() const;
+
+private:
+ void SetHashText();
+ long GetMaxDigitWidth(); // in logic units
+ long GetSignWidth();
+ long GetDotWidth();
+ long GetExpWidth();
+ void TextChanged();
+};
+
+//==================================================================
+
+ScDrawStringsVars::ScDrawStringsVars(ScOutputData* pData, BOOL bPTL) :
+ pOutput ( pData ),
+ pPattern ( NULL ),
+ pCondSet ( NULL ),
+ eAttrOrient ( SVX_ORIENTATION_STANDARD ),
+ eAttrHorJust( SVX_HOR_JUSTIFY_STANDARD ),
+ eAttrVerJust( SVX_VER_JUSTIFY_BOTTOM ),
+ eAttrHorJustMethod( SVX_JUSTIFY_METHOD_AUTO ),
+ eAttrVerJustMethod( SVX_JUSTIFY_METHOD_AUTO ),
+ pMargin ( NULL ),
+ nIndent ( 0 ),
+ bRotated ( FALSE ),
+ nOriginalWidth( 0 ),
+ nMaxDigitWidth( 0 ),
+ nSignWidth( 0 ),
+ nDotWidth( 0 ),
+ nExpWidth( 0 ),
+ pLastCell ( NULL ),
+ nValueFormat( 0 ),
+ bLineBreak ( FALSE ),
+ bRepeat ( FALSE ),
+ bShrink ( FALSE ),
+ bPixelToLogic( bPTL )
+{
+ ScModule* pScMod = SC_MOD();
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ bCellContrast = pOutput->bUseStyleColor &&
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ const svtools::ColorConfig& rColorConfig = pScMod->GetColorConfig();
+ aBackConfigColor.SetColor( rColorConfig.GetColorValue(svtools::DOCCOLOR).nColor );
+ aTextConfigColor.SetColor( rColorConfig.GetColorValue(svtools::FONTCOLOR).nColor );
+}
+
+ScDrawStringsVars::~ScDrawStringsVars()
+{
+}
+
+void ScDrawStringsVars::SetShrinkScale( long nScale, BYTE nScript )
+{
+ // text remains valid, size is updated
+
+ OutputDevice* pDev = pOutput->pDev;
+ OutputDevice* pRefDevice = pOutput->pRefDevice;
+ OutputDevice* pFmtDevice = pOutput->pFmtDevice;
+
+ // call GetFont with a modified fraction, use only the height
+
+ Fraction aFraction( nScale, 100 );
+ if ( !bPixelToLogic )
+ aFraction *= pOutput->aZoomY;
+ Font aTmpFont;
+ pPattern->GetFont( aTmpFont, SC_AUTOCOL_RAW, pFmtDevice, &aFraction, pCondSet, nScript );
+ long nNewHeight = aTmpFont.GetHeight();
+ if ( nNewHeight > 0 )
+ aFont.SetHeight( nNewHeight );
+
+ // set font and dependent variables as in SetPattern
+
+ pDev->SetFont( aFont );
+ if ( pFmtDevice != pDev )
+ pFmtDevice->SetFont( aFont );
+
+ aMetric = pFmtDevice->GetFontMetric();
+ if ( pFmtDevice->GetOutDevType() == OUTDEV_PRINTER && aMetric.GetIntLeading() == 0 )
+ {
+ OutputDevice* pDefaultDev = Application::GetDefaultDevice();
+ MapMode aOld = pDefaultDev->GetMapMode();
+ pDefaultDev->SetMapMode( pFmtDevice->GetMapMode() );
+ aMetric = pDefaultDev->GetFontMetric( aFont );
+ pDefaultDev->SetMapMode( aOld );
+ }
+
+ nAscentPixel = aMetric.GetAscent();
+ if ( bPixelToLogic )
+ nAscentPixel = pRefDevice->LogicToPixel( Size( 0, nAscentPixel ) ).Height();
+
+ SetAutoText( aString ); // same text again, to get text size
+}
+
+namespace {
+
+template<typename _ItemType, typename _EnumType>
+_EnumType lcl_GetValue(const ScPatternAttr& rPattern, USHORT nWhich, const SfxItemSet* pCondSet)
+{
+ const _ItemType& rItem = static_cast<const _ItemType&>(rPattern.GetItem(nWhich, pCondSet));
+ return static_cast<_EnumType>(rItem.GetValue());
+}
+
+bool lcl_GetBoolValue(const ScPatternAttr& rPattern, USHORT nWhich, const SfxItemSet* pCondSet)
+{
+ return lcl_GetValue<SfxBoolItem, bool>(rPattern, nWhich, pCondSet);
+}
+
+}
+
+void ScDrawStringsVars::SetPattern( const ScPatternAttr* pNew, const SfxItemSet* pSet,
+ ScBaseCell* pCell, BYTE nScript )
+{
+ nMaxDigitWidth = 0;
+ nSignWidth = 0;
+ nDotWidth = 0;
+ nExpWidth = 0;
+
+ pPattern = pNew;
+ pCondSet = pSet;
+
+ // pPattern auswerten
+
+ OutputDevice* pDev = pOutput->pDev;
+ OutputDevice* pRefDevice = pOutput->pRefDevice;
+ OutputDevice* pFmtDevice = pOutput->pFmtDevice;
+
+ // Font
+
+ ScAutoFontColorMode eColorMode;
+ if ( pOutput->bUseStyleColor )
+ {
+ if ( pOutput->bForceAutoColor )
+ eColorMode = bCellContrast ? SC_AUTOCOL_IGNOREALL : SC_AUTOCOL_IGNOREFONT;
+ else
+ eColorMode = bCellContrast ? SC_AUTOCOL_IGNOREBACK : SC_AUTOCOL_DISPLAY;
+ }
+ else
+ eColorMode = SC_AUTOCOL_PRINT;
+
+ if ( bPixelToLogic )
+ pPattern->GetFont( aFont, eColorMode, pFmtDevice, NULL, pCondSet, nScript,
+ &aBackConfigColor, &aTextConfigColor );
+ else
+ pPattern->GetFont( aFont, eColorMode, pFmtDevice, &pOutput->aZoomY, pCondSet, nScript,
+ &aBackConfigColor, &aTextConfigColor );
+ aFont.SetAlign(ALIGN_BASELINE);
+
+ // Orientierung
+
+ eAttrOrient = pPattern->GetCellOrientation( pCondSet );
+
+ // alignment
+
+ eAttrHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue();
+
+ eAttrVerJust = (SvxCellVerJustify)((const SvxVerJustifyItem&)pPattern->GetItem( ATTR_VER_JUSTIFY, pCondSet )).GetValue();
+ if ( eAttrVerJust == SVX_VER_JUSTIFY_STANDARD )
+ eAttrVerJust = SVX_VER_JUSTIFY_BOTTOM;
+
+ // justification method
+
+ eAttrHorJustMethod = lcl_GetValue<SvxJustifyMethodItem, SvxCellJustifyMethod>(*pPattern, ATTR_HOR_JUSTIFY_METHOD, pCondSet);
+ eAttrVerJustMethod = lcl_GetValue<SvxJustifyMethodItem, SvxCellJustifyMethod>(*pPattern, ATTR_VER_JUSTIFY_METHOD, pCondSet);
+
+ // line break
+
+ bLineBreak = ((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK, pCondSet )).GetValue();
+
+ // handle "repeat" alignment
+
+ bRepeat = ( eAttrHorJust == SVX_HOR_JUSTIFY_REPEAT );
+ if ( bRepeat )
+ {
+ // "repeat" disables rotation (before constructing the font)
+ eAttrOrient = SVX_ORIENTATION_STANDARD;
+
+ // #i31843# "repeat" with "line breaks" is treated as default alignment (but rotation is still disabled)
+ if ( bLineBreak )
+ eAttrHorJust = SVX_HOR_JUSTIFY_STANDARD;
+ }
+
+ short nRot;
+ switch (eAttrOrient)
+ {
+ case SVX_ORIENTATION_STANDARD:
+ nRot = 0;
+ bRotated = (((const SfxInt32Item&)pPattern->GetItem( ATTR_ROTATE_VALUE, pCondSet )).GetValue() != 0) &&
+ !bRepeat;
+ break;
+ case SVX_ORIENTATION_STACKED:
+ nRot = 0;
+ bRotated = FALSE;
+ break;
+ case SVX_ORIENTATION_TOPBOTTOM:
+ nRot = 2700;
+ bRotated = FALSE;
+ break;
+ case SVX_ORIENTATION_BOTTOMTOP:
+ nRot = 900;
+ bRotated = FALSE;
+ break;
+ default:
+ DBG_ERROR("Falscher SvxCellOrientation Wert");
+ nRot = 0;
+ bRotated = FALSE;
+ break;
+ }
+ aFont.SetOrientation( nRot );
+
+ // Syntax-Modus
+
+ if (pOutput->bSyntaxMode)
+ pOutput->SetSyntaxColor( &aFont, pCell );
+
+ pDev->SetFont( aFont );
+ if ( pFmtDevice != pDev )
+ pFmtDevice->SetFont( aFont );
+
+ aMetric = pFmtDevice->GetFontMetric();
+
+ //
+ // Wenn auf dem Drucker das Leading 0 ist, gibt es Probleme
+ // -> Metric vom Bildschirm nehmen (wie EditEngine!)
+ //
+
+ if ( pFmtDevice->GetOutDevType() == OUTDEV_PRINTER && aMetric.GetIntLeading() == 0 )
+ {
+ OutputDevice* pDefaultDev = Application::GetDefaultDevice();
+ MapMode aOld = pDefaultDev->GetMapMode();
+ pDefaultDev->SetMapMode( pFmtDevice->GetMapMode() );
+ aMetric = pDefaultDev->GetFontMetric( aFont );
+ pDefaultDev->SetMapMode( aOld );
+ }
+
+ nAscentPixel = aMetric.GetAscent();
+ if ( bPixelToLogic )
+ nAscentPixel = pRefDevice->LogicToPixel( Size( 0, nAscentPixel ) ).Height();
+
+ Color aULineColor( ((const SvxUnderlineItem&)pPattern->GetItem( ATTR_FONT_UNDERLINE, pCondSet )).GetColor() );
+ pDev->SetTextLineColor( aULineColor );
+
+ Color aOLineColor( ((const SvxOverlineItem&)pPattern->GetItem( ATTR_FONT_OVERLINE, pCondSet )).GetColor() );
+ pDev->SetOverlineColor( aOLineColor );
+
+ // Zahlenformat
+
+// ULONG nOld = nValueFormat;
+ nValueFormat = pPattern->GetNumberFormat( pOutput->pDoc->GetFormatTable(), pCondSet );
+
+/* s.u.
+ if (nValueFormat != nOld)
+ pLastCell = NULL; // immer neu formatieren
+*/
+ // Raender
+
+ pMargin = (const SvxMarginItem*)&pPattern->GetItem( ATTR_MARGIN, pCondSet );
+ if ( eAttrHorJust == SVX_HOR_JUSTIFY_LEFT )
+ nIndent = ((const SfxUInt16Item&)pPattern->GetItem( ATTR_INDENT, pCondSet )).GetValue();
+ else
+ nIndent = 0;
+
+ // "Shrink to fit"
+
+ bShrink = static_cast<const SfxBoolItem&>(pPattern->GetItem( ATTR_SHRINKTOFIT, pCondSet )).GetValue();
+
+ // zumindest die Text-Groesse muss neu geholt werden
+ //! unterscheiden, und den Text nicht neu vom Numberformatter holen?
+
+ pLastCell = NULL;
+}
+
+void ScDrawStringsVars::SetPatternSimple( const ScPatternAttr* pNew, const SfxItemSet* pSet )
+{
+ nMaxDigitWidth = 0;
+ nSignWidth = 0;
+ nDotWidth = 0;
+ nExpWidth = 0;
+ // wird gerufen, wenn sich die Font-Variablen nicht aendern (!StringDiffer)
+
+ pPattern = pNew;
+ pCondSet = pSet; //! noetig ???
+
+ // Zahlenformat
+
+ ULONG nOld = nValueFormat;
+// nValueFormat = pPattern->GetNumberFormat( pFormatter );
+ const SfxPoolItem* pFormItem;
+ if ( !pCondSet || pCondSet->GetItemState(ATTR_VALUE_FORMAT,TRUE,&pFormItem) != SFX_ITEM_SET )
+ pFormItem = &pPattern->GetItem(ATTR_VALUE_FORMAT);
+ const SfxPoolItem* pLangItem;
+ if ( !pCondSet || pCondSet->GetItemState(ATTR_LANGUAGE_FORMAT,TRUE,&pLangItem) != SFX_ITEM_SET )
+ pLangItem = &pPattern->GetItem(ATTR_LANGUAGE_FORMAT);
+ nValueFormat = pOutput->pDoc->GetFormatTable()->GetFormatForLanguageIfBuiltIn(
+ ((SfxUInt32Item*)pFormItem)->GetValue(),
+ ((SvxLanguageItem*)pLangItem)->GetLanguage() );
+
+ if (nValueFormat != nOld)
+ pLastCell = NULL; // immer neu formatieren
+
+ // Raender
+
+ pMargin = (const SvxMarginItem*)&pPattern->GetItem( ATTR_MARGIN, pCondSet );
+
+ if ( eAttrHorJust == SVX_HOR_JUSTIFY_LEFT )
+ nIndent = ((const SfxUInt16Item&)pPattern->GetItem( ATTR_INDENT, pCondSet )).GetValue();
+ else
+ nIndent = 0;
+
+ // "Shrink to fit"
+
+ bShrink = static_cast<const SfxBoolItem&>(pPattern->GetItem( ATTR_SHRINKTOFIT, pCondSet )).GetValue();
+}
+
+inline BOOL SameValue( ScBaseCell* pCell, ScBaseCell* pOldCell ) // pCell ist != 0
+{
+ return pOldCell && pOldCell->GetCellType() == CELLTYPE_VALUE &&
+ pCell->GetCellType() == CELLTYPE_VALUE &&
+ ((ScValueCell*)pCell)->GetValue() == ((ScValueCell*)pOldCell)->GetValue();
+}
+
+BOOL ScDrawStringsVars::SetText( ScBaseCell* pCell )
+{
+ BOOL bChanged = FALSE;
+
+ if (pCell)
+ {
+ if ( !SameValue( pCell, pLastCell ) )
+ {
+ pLastCell = pCell; // Zelle merken
+
+ Color* pColor;
+ ULONG nFormat = GetValueFormat();
+ ScCellFormat::GetString( pCell,
+ nFormat, aString, &pColor,
+ *pOutput->pDoc->GetFormatTable(),
+ pOutput->bShowNullValues,
+ pOutput->bShowFormulas,
+ ftCheck );
+
+ if (aString.Len() > DRAWTEXT_MAX)
+ aString.Erase(DRAWTEXT_MAX);
+
+ if ( pColor && !pOutput->bSyntaxMode && !( pOutput->bUseStyleColor && pOutput->bForceAutoColor ) )
+ {
+ OutputDevice* pDev = pOutput->pDev;
+ aFont.SetColor(*pColor);
+ pDev->SetFont( aFont ); // nur fuer Ausgabe
+ bChanged = TRUE;
+ pLastCell = NULL; // naechstes Mal wieder hierherkommen
+ }
+
+ TextChanged();
+ }
+ // sonst String/Groesse behalten
+ }
+ else
+ {
+ aString.Erase();
+ pLastCell = NULL;
+ aTextSize = Size(0,0);
+ nOriginalWidth = 0;
+ }
+
+ return bChanged;
+}
+
+void ScDrawStringsVars::SetHashText()
+{
+ SetAutoText( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")) );
+}
+
+void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth )
+{
+ // #i113045# do the single-character width calculations in logic units
+ if (bPixelToLogic)
+ nWidth = pOutput->pRefDevice->PixelToLogic(Size(nWidth,0)).Width();
+
+ if (!pCell)
+ return;
+
+ CellType eType = pCell->GetCellType();
+ if (eType != CELLTYPE_VALUE && eType != CELLTYPE_FORMULA)
+ // must be a value or formula cell.
+ return;
+
+ if (eType == CELLTYPE_FORMULA)
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ if (pFCell->GetErrCode() != 0)
+ {
+ SetHashText(); // If the error string doesn't fit, always use "###"
+ return;
+ }
+ // If it's formula, the result must be a value.
+ if (!pFCell->IsValue())
+ return;
+ }
+
+ ULONG nFormat = GetValueFormat();
+ if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0)
+ {
+ // Not 'General' number format. Set hash text and bail out.
+ SetHashText();
+ return;
+ }
+
+ double fVal = (eType == CELLTYPE_VALUE) ?
+ static_cast<ScValueCell*>(pCell)->GetValue() : static_cast<ScFormulaCell*>(pCell)->GetValue();
+
+ const SvNumberformat* pNumFormat = pOutput->pDoc->GetFormatTable()->GetEntry(nFormat);
+ if (!pNumFormat)
+ return;
+
+ long nMaxDigit = GetMaxDigitWidth();
+ sal_uInt16 nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit);
+
+ if (!pNumFormat->GetOutputString(fVal, nNumDigits, aString))
+ // Failed to get output string. Bail out.
+ return;
+
+ sal_uInt8 nSignCount = 0, nDecimalCount = 0, nExpCount = 0;
+ xub_StrLen nLen = aString.Len();
+ sal_Unicode cDecSep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator.getStr()[0];
+ for (xub_StrLen i = 0; i < nLen; ++i)
+ {
+ sal_Unicode c = aString.GetChar(i);
+ if (c == sal_Unicode('-'))
+ ++nSignCount;
+ else if (c == cDecSep)
+ ++nDecimalCount;
+ else if (c == sal_Unicode('E'))
+ ++nExpCount;
+ }
+
+ // #i112250# A small value might be formatted as "0" when only counting the digits,
+ // but fit into the column when considering the smaller width of the decimal separator.
+ if (aString.EqualsAscii("0") && fVal != 0.0)
+ nDecimalCount = 1;
+
+ if (nDecimalCount)
+ nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount;
+ if (nSignCount)
+ nWidth += (nMaxDigit - GetSignWidth()) * nSignCount;
+ if (nExpCount)
+ nWidth += (nMaxDigit - GetExpWidth()) * nExpCount;
+
+ if (nDecimalCount || nSignCount || nExpCount)
+ {
+ // Re-calculate.
+ nNumDigits = static_cast<sal_uInt16>(nWidth / nMaxDigit);
+ if (!pNumFormat->GetOutputString(fVal, nNumDigits, aString))
+ // Failed to get output string. Bail out.
+ return;
+ }
+
+ long nActualTextWidth = pOutput->pFmtDevice->GetTextWidth(aString);
+ if (nActualTextWidth > nWidth)
+ {
+ // Even after the decimal adjustment the text doesn't fit. Give up.
+ SetHashText();
+ return;
+ }
+
+ TextChanged();
+ pLastCell = NULL; // #i113022# equal cell and format in another column may give different string
+}
+
+void ScDrawStringsVars::SetAutoText( const String& rAutoText )
+{
+ aString = rAutoText;
+
+ OutputDevice* pRefDevice = pOutput->pRefDevice;
+ OutputDevice* pFmtDevice = pOutput->pFmtDevice;
+ aTextSize.Width() = pFmtDevice->GetTextWidth( aString );
+ aTextSize.Height() = pFmtDevice->GetTextHeight();
+
+ if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER )
+ {
+ double fMul = pOutput->GetStretch();
+ aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5);
+ }
+
+ aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent();
+ if ( GetOrient() != SVX_ORIENTATION_STANDARD )
+ {
+ long nTemp = aTextSize.Height();
+ aTextSize.Height() = aTextSize.Width();
+ aTextSize.Width() = nTemp;
+ }
+
+ nOriginalWidth = aTextSize.Width();
+ if ( bPixelToLogic )
+ aTextSize = pRefDevice->LogicToPixel( aTextSize );
+
+ pLastCell = NULL; // derselbe Text kann in der naechsten Zelle wieder passen
+}
+
+long ScDrawStringsVars::GetMaxDigitWidth()
+{
+ if (nMaxDigitWidth > 0)
+ return nMaxDigitWidth;
+
+ sal_Char cZero = '0';
+ for (sal_Char i = 0; i < 10; ++i)
+ {
+ sal_Char cDigit = cZero + i;
+ long n = pOutput->pFmtDevice->GetTextWidth(String(cDigit));
+ nMaxDigitWidth = ::std::max(nMaxDigitWidth, n);
+ }
+ return nMaxDigitWidth;
+}
+
+long ScDrawStringsVars::GetSignWidth()
+{
+ if (nSignWidth > 0)
+ return nSignWidth;
+
+ nSignWidth = pOutput->pFmtDevice->GetTextWidth(String('-'));
+ return nSignWidth;
+}
+
+long ScDrawStringsVars::GetDotWidth()
+{
+ if (nDotWidth > 0)
+ return nDotWidth;
+
+ const ::rtl::OUString& sep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator;
+ nDotWidth = pOutput->pFmtDevice->GetTextWidth(sep);
+ return nDotWidth;
+}
+
+long ScDrawStringsVars::GetExpWidth()
+{
+ if (nExpWidth > 0)
+ return nExpWidth;
+
+ nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E'));
+ return nExpWidth;
+}
+
+void ScDrawStringsVars::TextChanged()
+{
+ OutputDevice* pRefDevice = pOutput->pRefDevice;
+ OutputDevice* pFmtDevice = pOutput->pFmtDevice;
+ aTextSize.Width() = pFmtDevice->GetTextWidth( aString );
+ aTextSize.Height() = pFmtDevice->GetTextHeight();
+
+ if ( !pRefDevice->GetConnectMetaFile() || pRefDevice->GetOutDevType() == OUTDEV_PRINTER )
+ {
+ double fMul = pOutput->GetStretch();
+ aTextSize.Width() = (long)(aTextSize.Width() / fMul + 0.5);
+ }
+
+ aTextSize.Height() = aMetric.GetAscent() + aMetric.GetDescent();
+ if ( GetOrient() != SVX_ORIENTATION_STANDARD )
+ {
+ long nTemp = aTextSize.Height();
+ aTextSize.Height() = aTextSize.Width();
+ aTextSize.Width() = nTemp;
+ }
+
+ nOriginalWidth = aTextSize.Width();
+ if ( bPixelToLogic )
+ aTextSize = pRefDevice->LogicToPixel( aTextSize );
+}
+
+BOOL ScDrawStringsVars::HasEditCharacters() const
+{
+ static const sal_Unicode pChars[] =
+ {
+ CHAR_NBSP, CHAR_SHY, CHAR_ZWSP, CHAR_LRM, CHAR_RLM, CHAR_NBHY, CHAR_ZWNBSP, 0
+ };
+ return aString.SearchChar( pChars ) != STRING_NOTFOUND;
+}
+
+//==================================================================
+
+double ScOutputData::GetStretch()
+{
+ if ( pRefDevice->IsMapMode() )
+ {
+ // #95920# If a non-trivial MapMode is set, its scale is now already
+ // taken into account in the OutputDevice's font handling
+ // (OutputDevice::ImplNewFont, see #95414#).
+ // The old handling below is only needed for pixel output.
+ return 1.0;
+ }
+
+ // calculation in double is faster than Fraction multiplication
+ // and doesn't overflow
+
+ if ( pRefDevice == pFmtDevice )
+ {
+ MapMode aOld = pRefDevice->GetMapMode();
+ return ((double)aOld.GetScaleY()) / ((double)aOld.GetScaleX()) * ((double)aZoomY) / ((double)aZoomX);
+ }
+ else
+ {
+ // when formatting for printer, device map mode has already been taken care of
+ return ((double)aZoomY) / ((double)aZoomX);
+ }
+}
+
+//==================================================================
+
+//
+// output strings
+//
+
+void lcl_DoHyperlinkResult( OutputDevice* pDev, const Rectangle& rRect, ScBaseCell* pCell )
+{
+ vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
+
+ String aCellText;
+ String aURL;
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ if ( pFCell->IsHyperLinkCell() )
+ pFCell->GetURLResult( aURL, aCellText );
+ }
+
+ if ( aURL.Len() && pPDFData )
+ {
+ vcl::PDFExtOutDevBookmarkEntry aBookmark;
+ aBookmark.nLinkId = pPDFData->CreateLink( rRect );
+ aBookmark.aBookmark = aURL;
+ std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->GetBookmarks();
+ rBookmarks.push_back( aBookmark );
+ }
+}
+
+void ScOutputData::SetSyntaxColor( Font* pFont, ScBaseCell* pCell )
+{
+ if (pCell)
+ {
+ switch (pCell->GetCellType())
+ {
+ case CELLTYPE_VALUE:
+ pFont->SetColor( *pValueColor );
+ break;
+ case CELLTYPE_STRING:
+ pFont->SetColor( *pTextColor );
+ break;
+ case CELLTYPE_FORMULA:
+ pFont->SetColor( *pFormulaColor );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+}
+
+void lcl_SetEditColor( EditEngine& rEngine, const Color& rColor )
+{
+ ESelection aSel( 0, 0, rEngine.GetParagraphCount(), 0 );
+ SfxItemSet aSet( rEngine.GetEmptyItemSet() );
+ aSet.Put( SvxColorItem( rColor, EE_CHAR_COLOR ) );
+ rEngine.QuickSetAttribs( aSet, aSel );
+ // function is called with update mode set to FALSE
+}
+
+void ScOutputData::SetEditSyntaxColor( EditEngine& rEngine, ScBaseCell* pCell )
+{
+ if (pCell)
+ {
+ Color aColor;
+ switch (pCell->GetCellType())
+ {
+ case CELLTYPE_VALUE:
+ aColor = *pValueColor;
+ break;
+ case CELLTYPE_STRING:
+ aColor = *pTextColor;
+ break;
+ case CELLTYPE_FORMULA:
+ aColor = *pFormulaColor;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ lcl_SetEditColor( rEngine, aColor );
+ }
+}
+
+BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
+ SCCOL& rOverX, SCROW& rOverY,
+ BOOL bVisRowChanged )
+{
+ BOOL bDoMerge = FALSE;
+ BOOL bIsLeft = ( nX == nVisX1 );
+ BOOL bIsTop = ( nY == nVisY1 ) || bVisRowChanged;
+
+ CellInfo* pInfo = &pRowInfo[nArrY].pCellInfo[nX+1];
+ if ( pInfo->bHOverlapped && pInfo->bVOverlapped )
+ bDoMerge = bIsLeft && bIsTop;
+ else if ( pInfo->bHOverlapped )
+ bDoMerge = bIsLeft;
+ else if ( pInfo->bVOverlapped )
+ bDoMerge = bIsTop;
+
+ // weiter solange versteckt
+/* if (!bDoMerge)
+ return FALSE;
+*/
+
+ rOverX = nX;
+ rOverY = nY;
+ BOOL bHOver = pInfo->bHOverlapped;
+ BOOL bVOver = pInfo->bVOverlapped;
+ BOOL bHidden;
+
+ while (bHOver) // nY konstant
+ {
+ --rOverX;
+ bHidden = pDoc->ColHidden(rOverX, nTab);
+ if ( !bDoMerge && !bHidden )
+ return FALSE;
+
+ if (rOverX >= nX1 && !bHidden)
+ {
+// rVirtPosX -= pRowInfo[0].pCellInfo[rOverX+1].nWidth;
+ bHOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bHOverlapped;
+ bVOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bVOverlapped;
+ }
+ else
+ {
+// if (!bClipVirt)
+// rVirtPosX -= (long) (pDoc->GetColWidth( rOverX, nTab ) * nPPTX);
+ USHORT nOverlap = ((ScMergeFlagAttr*)pDoc->GetAttr(
+ rOverX, rOverY, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ bHOver = ((nOverlap & SC_MF_HOR) != 0);
+ bVOver = ((nOverlap & SC_MF_VER) != 0);
+ }
+ }
+
+ while (bVOver)
+ {
+ --rOverY;
+ bHidden = pDoc->RowHidden(rOverY, nTab);
+ if ( !bDoMerge && !bHidden )
+ return FALSE;
+
+ if (nArrY>0)
+ --nArrY; // lokale Kopie !
+
+ if (rOverX >= nX1 && rOverY >= nY1 &&
+ !pDoc->ColHidden(rOverX, nTab) &&
+ !pDoc->RowHidden(rOverY, nTab) &&
+ pRowInfo[nArrY].nRowNo == rOverY)
+ {
+// rVirtPosY -= pRowInfo[nArrY].nHeight;
+ bHOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bHOverlapped;
+ bVOver = pRowInfo[nArrY].pCellInfo[rOverX+1].bVOverlapped;
+ }
+ else
+ {
+// if (!bClipVirt)
+// rVirtPosY -= (long) (pDoc->GetRowHeight( rOverY, nTab ) * nPPTY);
+ USHORT nOverlap = ((ScMergeFlagAttr*)pDoc->GetAttr(
+ rOverX, rOverY, nTab, ATTR_MERGE_FLAG ))->GetValue();
+ bHOver = ((nOverlap & SC_MF_HOR) != 0);
+ bVOver = ((nOverlap & SC_MF_VER) != 0);
+ }
+ }
+
+ return TRUE;
+}
+
+inline BOOL StringDiffer( const ScPatternAttr*& rpOldPattern, const ScPatternAttr*& rpNewPattern )
+{
+ DBG_ASSERT( rpNewPattern, "pNewPattern" );
+
+ if ( rpNewPattern == rpOldPattern )
+ return FALSE;
+ else if ( !rpOldPattern )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT ) != &rpOldPattern->GetItem( ATTR_FONT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CJK_FONT ) != &rpOldPattern->GetItem( ATTR_CJK_FONT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CTL_FONT ) != &rpOldPattern->GetItem( ATTR_CTL_FONT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_FONT_HEIGHT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CJK_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_CJK_FONT_HEIGHT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CTL_FONT_HEIGHT ) != &rpOldPattern->GetItem( ATTR_CTL_FONT_HEIGHT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_FONT_WEIGHT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CJK_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_CJK_FONT_WEIGHT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CTL_FONT_WEIGHT ) != &rpOldPattern->GetItem( ATTR_CTL_FONT_WEIGHT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_FONT_POSTURE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CJK_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_CJK_FONT_POSTURE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_CTL_FONT_POSTURE ) != &rpOldPattern->GetItem( ATTR_CTL_FONT_POSTURE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_UNDERLINE ) != &rpOldPattern->GetItem( ATTR_FONT_UNDERLINE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_OVERLINE ) != &rpOldPattern->GetItem( ATTR_FONT_OVERLINE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_WORDLINE ) != &rpOldPattern->GetItem( ATTR_FONT_WORDLINE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_CROSSEDOUT ) != &rpOldPattern->GetItem( ATTR_FONT_CROSSEDOUT ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_CONTOUR ) != &rpOldPattern->GetItem( ATTR_FONT_CONTOUR ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_SHADOWED ) != &rpOldPattern->GetItem( ATTR_FONT_SHADOWED ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_COLOR ) != &rpOldPattern->GetItem( ATTR_FONT_COLOR ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_HOR_JUSTIFY ) != &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_HOR_JUSTIFY_METHOD ) != &rpOldPattern->GetItem( ATTR_HOR_JUSTIFY_METHOD ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_VER_JUSTIFY ) != &rpOldPattern->GetItem( ATTR_VER_JUSTIFY ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_VER_JUSTIFY_METHOD ) != &rpOldPattern->GetItem( ATTR_VER_JUSTIFY_METHOD ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_STACKED ) != &rpOldPattern->GetItem( ATTR_STACKED ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_LINEBREAK ) != &rpOldPattern->GetItem( ATTR_LINEBREAK ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_MARGIN ) != &rpOldPattern->GetItem( ATTR_MARGIN ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_ROTATE_VALUE ) != &rpOldPattern->GetItem( ATTR_ROTATE_VALUE ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FORBIDDEN_RULES ) != &rpOldPattern->GetItem( ATTR_FORBIDDEN_RULES ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_EMPHASISMARK ) != &rpOldPattern->GetItem( ATTR_FONT_EMPHASISMARK ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_FONT_RELIEF ) != &rpOldPattern->GetItem( ATTR_FONT_RELIEF ) )
+ return TRUE;
+ else if ( &rpNewPattern->GetItem( ATTR_BACKGROUND ) != &rpOldPattern->GetItem( ATTR_BACKGROUND ) )
+ return TRUE; // needed with automatic text color
+ else
+ {
+ rpOldPattern = rpNewPattern;
+ return FALSE;
+ }
+}
+
+inline void lcl_CreateInterpretProgress( BOOL& bProgress, ScDocument* pDoc,
+ ScFormulaCell* pFCell )
+{
+ if ( !bProgress && pFCell->GetDirty() )
+ {
+ ScProgress::CreateInterpretProgress( pDoc, TRUE );
+ bProgress = TRUE;
+ }
+}
+
+inline BYTE GetScriptType( ScDocument* pDoc, ScBaseCell* pCell,
+ const ScPatternAttr* pPattern,
+ const SfxItemSet* pCondSet )
+{
+ return pDoc->GetCellScriptType( pCell, pPattern->GetNumberFormat( pDoc->GetFormatTable(), pCondSet ) );
+}
+
+inline BOOL IsAmbiguousScript( BYTE nScript )
+{
+ return ( nScript != SCRIPTTYPE_LATIN &&
+ nScript != SCRIPTTYPE_ASIAN &&
+ nScript != SCRIPTTYPE_COMPLEX );
+}
+
+BOOL ScOutputData::IsEmptyCellText( RowInfo* pThisRowInfo, SCCOL nX, SCROW nY )
+{
+ // pThisRowInfo may be NULL
+
+ BOOL bEmpty;
+ if ( pThisRowInfo && nX <= nX2 )
+ bEmpty = pThisRowInfo->pCellInfo[nX+1].bEmptyCellText;
+ else
+ bEmpty = ( pDoc->GetCell( ScAddress( nX, nY, nTab ) ) == NULL );
+
+ if ( !bEmpty && ( nX < nX1 || nX > nX2 || !pThisRowInfo ) )
+ {
+ // for the range nX1..nX2 in RowInfo, cell protection attribute is already evaluated
+ // into bEmptyCellText in ScDocument::FillInfo / lcl_HidePrint (printfun)
+
+ BOOL bIsPrint = ( eType == OUTTYPE_PRINTER );
+
+ if ( bIsPrint || bTabProtected )
+ {
+ const ScProtectionAttr* pAttr = (const ScProtectionAttr*)
+ pDoc->GetEffItem( nX, nY, nTab, ATTR_PROTECTION );
+ if ( bIsPrint && pAttr->GetHidePrint() )
+ bEmpty = TRUE;
+ else if ( bTabProtected )
+ {
+ if ( pAttr->GetHideCell() )
+ bEmpty = TRUE;
+ else if ( bShowFormulas && pAttr->GetHideFormula() )
+ {
+ ScBaseCell* pCell = pDoc->GetCell( ScAddress( nX, nY, nTab ) );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+ bEmpty = TRUE;
+ }
+ }
+ }
+ }
+ return bEmpty;
+}
+
+void ScOutputData::GetVisibleCell( SCCOL nCol, SCROW nRow, SCTAB nTabP, ScBaseCell*& rpCell )
+{
+ pDoc->GetCell( nCol, nRow, nTabP, rpCell );
+ if ( rpCell && IsEmptyCellText( NULL, nCol, nRow ) )
+ rpCell = NULL;
+}
+
+BOOL ScOutputData::IsAvailable( SCCOL nX, SCROW nY )
+{
+ // apply the same logic here as in DrawStrings/DrawEdit:
+ // Stop at non-empty or merged or overlapped cell,
+ // where a note is empty as well as a cell that's hidden by protection settings
+
+ const ScBaseCell* pCell = pDoc->GetCell( ScAddress( nX, nY, nTab ) );
+ if ( pCell && pCell->GetCellType() != CELLTYPE_NOTE && !IsEmptyCellText( NULL, nX, nY ) )
+ {
+ return FALSE;
+ }
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nX, nY, nTab );
+ if ( ((const ScMergeAttr&)pPattern->GetItem(ATTR_MERGE)).IsMerged() ||
+ ((const ScMergeFlagAttr&)pPattern->GetItem(ATTR_MERGE_FLAG)).IsOverlapped() )
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+// nX, nArrY: loop variables from DrawStrings / DrawEdit
+// nPosX, nPosY: corresponding positions for nX, nArrY
+// nCellX, nCellY: position of the cell that contains the text
+// nNeeded: Text width, including margin
+// rPattern: cell format at nCellX, nCellY
+// nHorJustify: horizontal alignment (visual) to determine which cells to use for long strings
+// bCellIsValue: if set, don't extend into empty cells
+// bBreak: if set, don't extend, and don't set clip marks (but rLeftClip/rRightClip is set)
+// bOverwrite: if set, also extend into non-empty cells (for rotated text)
+// rParam output: various area parameters.
+
+void ScOutputData::GetOutputArea( SCCOL nX, SCSIZE nArrY, long nPosX, long nPosY,
+ SCCOL nCellX, SCROW nCellY, long nNeeded,
+ const ScPatternAttr& rPattern,
+ USHORT nHorJustify, bool bCellIsValue,
+ bool bBreak, bool bOverwrite,
+ OutputAreaParam& rParam )
+{
+ // rThisRowInfo may be for a different row than nCellY, is still used for clip marks
+ RowInfo& rThisRowInfo = pRowInfo[nArrY];
+
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ long nCellPosX = nPosX; // find nCellX position, starting at nX/nPosX
+ SCCOL nCompCol = nX;
+ while ( nCellX > nCompCol )
+ {
+ //! extra member function for width?
+ long nColWidth = ( nCompCol <= nX2 ) ?
+ pRowInfo[0].pCellInfo[nCompCol+1].nWidth :
+ (long) ( pDoc->GetColWidth( nCompCol, nTab ) * nPPTX );
+ nCellPosX += nColWidth * nLayoutSign;
+ ++nCompCol;
+ }
+ while ( nCellX < nCompCol )
+ {
+ --nCompCol;
+ long nColWidth = ( nCompCol <= nX2 ) ?
+ pRowInfo[0].pCellInfo[nCompCol+1].nWidth :
+ (long) ( pDoc->GetColWidth( nCompCol, nTab ) * nPPTX );
+ nCellPosX -= nColWidth * nLayoutSign;
+ }
+
+ long nCellPosY = nPosY; // find nCellY position, starting at nArrY/nPosY
+ SCSIZE nCompArr = nArrY;
+ SCROW nCompRow = pRowInfo[nCompArr].nRowNo;
+ while ( nCellY > nCompRow )
+ {
+ if ( nCompArr + 1 < nArrCount )
+ {
+ nCellPosY += pRowInfo[nCompArr].nHeight;
+ ++nCompArr;
+ nCompRow = pRowInfo[nCompArr].nRowNo;
+ }
+ else
+ {
+ USHORT nDocHeight = pDoc->GetRowHeight( nCompRow, nTab );
+ if ( nDocHeight )
+ nCellPosY += (long) ( nDocHeight * nPPTY );
+ ++nCompRow;
+ }
+ }
+ nCellPosY -= (long) pDoc->GetScaledRowHeight( nCellY, nCompRow-1, nTab, nPPTY );
+
+ const ScMergeAttr* pMerge = (const ScMergeAttr*)&rPattern.GetItem( ATTR_MERGE );
+ BOOL bMerged = pMerge->IsMerged();
+ long nMergeCols = pMerge->GetColMerge();
+ if ( nMergeCols == 0 )
+ nMergeCols = 1;
+ long nMergeRows = pMerge->GetRowMerge();
+ if ( nMergeRows == 0 )
+ nMergeRows = 1;
+
+ long i;
+ long nMergeSizeX = 0;
+ for ( i=0; i<nMergeCols; i++ )
+ {
+ long nColWidth = ( nCellX+i <= nX2 ) ?
+ pRowInfo[0].pCellInfo[nCellX+i+1].nWidth :
+ (long) ( pDoc->GetColWidth( sal::static_int_cast<SCCOL>(nCellX+i), nTab ) * nPPTX );
+ nMergeSizeX += nColWidth;
+ }
+ long nMergeSizeY = 0;
+ short nDirect = 0;
+ if ( rThisRowInfo.nRowNo == nCellY )
+ {
+ // take first row's height from row info
+ nMergeSizeY += rThisRowInfo.nHeight;
+ nDirect = 1; // skip in loop
+ }
+ // following rows always from document
+ nMergeSizeY += (long) pDoc->GetScaledRowHeight( nCellY+nDirect, nCellY+nMergeRows-1, nTab, nPPTY);
+
+ --nMergeSizeX; // leave out the grid horizontally, also for alignment (align between grid lines)
+
+ rParam.mnColWidth = nMergeSizeX; // store the actual column width.
+
+ //
+ // construct the rectangles using logical left/right values (justify is called at the end)
+ //
+
+ // rAlignRect is the single cell or merged area, used for alignment.
+
+ rParam.maAlignRect.Left() = nCellPosX;
+ rParam.maAlignRect.Right() = nCellPosX + ( nMergeSizeX - 1 ) * nLayoutSign;
+ rParam.maAlignRect.Top() = nCellPosY;
+ rParam.maAlignRect.Bottom() = nCellPosY + nMergeSizeY - 1;
+
+ // rClipRect is all cells that are used for output.
+ // For merged cells this is the same as rAlignRect, otherwise neighboring cells can also be used.
+
+ rParam.maClipRect = rParam.maAlignRect;
+ if ( nNeeded > nMergeSizeX )
+ {
+ SvxCellHorJustify eHorJust = (SvxCellHorJustify)nHorJustify;
+
+ long nMissing = nNeeded - nMergeSizeX;
+ long nLeftMissing = 0;
+ long nRightMissing = 0;
+ switch ( eHorJust )
+ {
+ case SVX_HOR_JUSTIFY_LEFT:
+ nRightMissing = nMissing;
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ nLeftMissing = nMissing;
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ nLeftMissing = nMissing / 2;
+ nRightMissing = nMissing - nLeftMissing;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ // nLeftMissing, nRightMissing are logical, eHorJust values are visual
+ if ( bLayoutRTL )
+ ::std::swap( nLeftMissing, nRightMissing );
+
+ SCCOL nRightX = nCellX;
+ SCCOL nLeftX = nCellX;
+ if ( !bMerged && !bCellIsValue && !bBreak )
+ {
+ // look for empty cells into which the text can be extended
+
+ while ( nRightMissing > 0 && nRightX < MAXCOL && ( bOverwrite || IsAvailable( nRightX+1, nCellY ) ) )
+ {
+ ++nRightX;
+ long nAdd = (long) ( pDoc->GetColWidth( nRightX, nTab ) * nPPTX );
+ nRightMissing -= nAdd;
+ rParam.maClipRect.Right() += nAdd * nLayoutSign;
+
+ if ( rThisRowInfo.nRowNo == nCellY && nRightX >= nX1 && nRightX <= nX2 )
+ rThisRowInfo.pCellInfo[nRightX].bHideGrid = TRUE;
+ }
+
+ while ( nLeftMissing > 0 && nLeftX > 0 && ( bOverwrite || IsAvailable( nLeftX-1, nCellY ) ) )
+ {
+ if ( rThisRowInfo.nRowNo == nCellY && nLeftX >= nX1 && nLeftX <= nX2 )
+ rThisRowInfo.pCellInfo[nLeftX].bHideGrid = TRUE;
+
+ --nLeftX;
+ long nAdd = (long) ( pDoc->GetColWidth( nLeftX, nTab ) * nPPTX );
+ nLeftMissing -= nAdd;
+ rParam.maClipRect.Left() -= nAdd * nLayoutSign;
+ }
+ }
+
+ // Set flag and reserve space for clipping mark triangle,
+ // even if rThisRowInfo isn't for nCellY (merged cells).
+ if ( nRightMissing > 0 && bMarkClipped && nRightX >= nX1 && nRightX <= nX2 && !bBreak && !bCellIsValue )
+ {
+ rThisRowInfo.pCellInfo[nRightX+1].nClipMark |= SC_CLIPMARK_RIGHT;
+ bAnyClipped = TRUE;
+ long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX );
+ rParam.maClipRect.Right() -= nMarkPixel * nLayoutSign;
+ }
+ if ( nLeftMissing > 0 && bMarkClipped && nLeftX >= nX1 && nLeftX <= nX2 && !bBreak && !bCellIsValue )
+ {
+ rThisRowInfo.pCellInfo[nLeftX+1].nClipMark |= SC_CLIPMARK_LEFT;
+ bAnyClipped = TRUE;
+ long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX );
+ rParam.maClipRect.Left() += nMarkPixel * nLayoutSign;
+ }
+
+ rParam.mbLeftClip = ( nLeftMissing > 0 );
+ rParam.mbRightClip = ( nRightMissing > 0 );
+ }
+ else
+ {
+ rParam.mbLeftClip = rParam.mbRightClip = FALSE;
+
+ // leave space for AutoFilter on screen
+ // (for automatic line break: only if not formatting for printer, as in ScColumn::GetNeededSize)
+
+ if ( eType==OUTTYPE_WINDOW &&
+ ( static_cast<const ScMergeFlagAttr&>(rPattern.GetItem(ATTR_MERGE_FLAG)).GetValue() & SC_MF_AUTO ) &&
+ ( !bBreak || pRefDevice == pFmtDevice ) )
+ {
+ // filter drop-down width is now independent from row height
+ const long nFilter = DROPDOWN_BITMAP_SIZE;
+ BOOL bFit = ( nNeeded + nFilter <= nMergeSizeX );
+ if ( bFit || bCellIsValue )
+ {
+ // content fits even in the remaining area without the filter button
+ // -> align within that remaining area
+
+ rParam.maAlignRect.Right() -= nFilter * nLayoutSign;
+ rParam.maClipRect.Right() -= nFilter * nLayoutSign;
+
+ // if a number doesn't fit, don't hide part of the number behind the button
+ // -> set clip flags, so "###" replacement is used (but also within the smaller area)
+
+ if ( !bFit )
+ rParam.mbLeftClip = rParam.mbRightClip = TRUE;
+ }
+ }
+ }
+
+ // justify both rectangles for alignment calculation, use with DrawText etc.
+
+ rParam.maAlignRect.Justify();
+ rParam.maClipRect.Justify();
+}
+
+void ScOutputData::DrawStrings( BOOL bPixelToLogic )
+{
+ DBG_ASSERT( pDev == pRefDevice ||
+ pDev->GetMapMode().GetMapUnit() == pRefDevice->GetMapMode().GetMapUnit(),
+ "DrawStrings: unterschiedliche MapUnits ?!?!" );
+
+ vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
+
+ BOOL bWasIdleDisabled = pDoc->IsIdleDisabled();
+ pDoc->DisableIdle( TRUE );
+ Size aMinSize = pRefDevice->PixelToLogic(Size(0,100)); // erst darueber wird ausgegeben
+// UINT32 nMinHeight = aMinSize.Height() / 200; // 1/2 Pixel
+
+ ScDrawStringsVars aVars( this, bPixelToLogic );
+
+ BOOL bProgress = FALSE;
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ nInitPosX += nMirrorW - 1; // pixels
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ SCCOL nLastContentCol = MAXCOL;
+ if ( nX2 < MAXCOL )
+ nLastContentCol = sal::static_int_cast<SCCOL>(
+ nLastContentCol - pDoc->GetEmptyLinesInBlock( nX2+1, nY1, nTab, MAXCOL, nY2, nTab, DIR_RIGHT ) );
+ SCCOL nLoopStartX = nX1;
+ if ( nX1 > 0 )
+ --nLoopStartX; // start before nX1 for rest of long text to the left
+
+ // variables for GetOutputArea
+ OutputAreaParam aAreaParam;
+ BOOL bCellIsValue = FALSE;
+ long nNeededWidth = 0;
+ SvxCellHorJustify eOutHorJust = SVX_HOR_JUSTIFY_STANDARD;
+ const ScPatternAttr* pPattern = NULL;
+ const SfxItemSet* pCondSet = NULL;
+ const ScPatternAttr* pOldPattern = NULL;
+ const SfxItemSet* pOldCondSet = NULL;
+ BYTE nOldScript = 0;
+
+ // alternative pattern instances in case we need to modify the pattern
+ // before processing the cell value.
+ ::boost::ptr_vector<ScPatternAttr> aAltPatterns;
+
+ long nPosY = nScrY;
+ for (SCSIZE nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ if ( pThisRowInfo->bChanged )
+ {
+ SCROW nY = pThisRowInfo->nRowNo;
+// long nCellHeight = (long) pThisRowInfo->nHeight;
+ long nPosX = nInitPosX;
+ if ( nLoopStartX < nX1 )
+ nPosX -= pRowInfo[0].pCellInfo[nLoopStartX+1].nWidth * nLayoutSign;
+ for (SCCOL nX=nLoopStartX; nX<=nX2; nX++)
+ {
+ BOOL bMergeEmpty = FALSE;
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ BOOL bEmpty = nX < nX1 || pInfo->bEmptyCellText;
+
+ SCCOL nCellX = nX; // position where the cell really starts
+ SCROW nCellY = nY;
+ BOOL bDoCell = FALSE;
+ BOOL bNeedEdit = FALSE;
+
+ //
+ // Part of a merged cell?
+ //
+
+ BOOL bOverlapped = ( pInfo->bHOverlapped || pInfo->bVOverlapped );
+ if ( bOverlapped )
+ {
+ bEmpty = TRUE;
+
+ SCCOL nOverX; // start of the merged cells
+ SCROW nOverY;
+ BOOL bVisChanged = !pRowInfo[nArrY-1].bChanged;
+ if (GetMergeOrigin( nX,nY, nArrY, nOverX,nOverY, bVisChanged ))
+ {
+ nCellX = nOverX;
+ nCellY = nOverY;
+ bDoCell = TRUE;
+ }
+ else
+ bMergeEmpty = TRUE;
+ }
+
+ //
+ // Rest of a long text further to the left?
+ //
+
+ if ( bEmpty && !bMergeEmpty && nX < nX1 && !bOverlapped )
+ {
+ SCCOL nTempX=nX1;
+ while (nTempX > 0 && IsEmptyCellText( pThisRowInfo, nTempX, nY ))
+ --nTempX;
+
+ if ( nTempX < nX1 &&
+ !IsEmptyCellText( pThisRowInfo, nTempX, nY ) &&
+ !pDoc->HasAttrib( nTempX,nY,nTab, nX1,nY,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ nCellX = nTempX;
+ bDoCell = TRUE;
+ }
+ }
+
+ //
+ // Rest of a long text further to the right?
+ //
+
+ if ( bEmpty && !bMergeEmpty && nX == nX2 && !bOverlapped )
+ {
+ // don't have to look further than nLastContentCol
+
+ SCCOL nTempX=nX;
+ while (nTempX < nLastContentCol && IsEmptyCellText( pThisRowInfo, nTempX, nY ))
+ ++nTempX;
+
+ if ( nTempX > nX &&
+ !IsEmptyCellText( pThisRowInfo, nTempX, nY ) &&
+ !pDoc->HasAttrib( nTempX,nY,nTab, nX,nY,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ nCellX = nTempX;
+ bDoCell = TRUE;
+ }
+ }
+
+ //
+ // normal visible cell
+ //
+
+ if (!bEmpty)
+ bDoCell = TRUE;
+
+ //
+ // don't output the cell that's being edited
+ //
+
+ if ( bDoCell && bEditMode && nCellX == nEditCol && nCellY == nEditRow )
+ bDoCell = FALSE;
+
+ //
+ // output the cell text
+ //
+
+ ScBaseCell* pCell = NULL;
+ if (bDoCell)
+ {
+ if ( nCellY == nY && nCellX == nX && nCellX >= nX1 && nCellX <= nX2 )
+ pCell = pThisRowInfo->pCellInfo[nCellX+1].pCell;
+ else
+ GetVisibleCell( nCellX, nCellY, nTab, pCell ); // get from document
+ if ( !pCell )
+ bDoCell = FALSE;
+ else if ( pCell->GetCellType() == CELLTYPE_EDIT )
+ bNeedEdit = TRUE;
+ }
+ if (bDoCell && !bNeedEdit)
+ {
+ if ( nCellY == nY && nCellX >= nX1 && nCellX <= nX2 )
+ {
+ CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nCellX+1];
+ pPattern = rCellInfo.pPatternAttr;
+ pCondSet = rCellInfo.pConditionSet;
+
+ if ( !pPattern )
+ {
+ // #i68085# pattern from cell info for hidden columns is null,
+ // test for null is quicker than using column flags
+ pPattern = pDoc->GetPattern( nCellX, nCellY, nTab );
+ pCondSet = pDoc->GetCondResult( nCellX, nCellY, nTab );
+ }
+ }
+ else // get from document
+ {
+ pPattern = pDoc->GetPattern( nCellX, nCellY, nTab );
+ pCondSet = pDoc->GetCondResult( nCellX, nCellY, nTab );
+ }
+
+ if (pCell->HasValueData() &&
+ static_cast<const SfxBoolItem&>(
+ pPattern->GetItem(ATTR_LINEBREAK, pCondSet)).GetValue())
+ {
+ // Disable line break when the cell content is numeric.
+ aAltPatterns.push_back(new ScPatternAttr(*pPattern));
+ ScPatternAttr* pAltPattern = &aAltPatterns.back();
+ SfxBoolItem aLineBreak(ATTR_LINEBREAK, false);
+ pAltPattern->GetItemSet().Put(aLineBreak);
+ pPattern = pAltPattern;
+ }
+
+ BYTE nScript = GetScriptType( pDoc, pCell, pPattern, pCondSet );
+ if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
+ if ( pPattern != pOldPattern || pCondSet != pOldCondSet ||
+ nScript != nOldScript || bSyntaxMode )
+ {
+ if ( StringDiffer(pOldPattern,pPattern) ||
+ pCondSet != pOldCondSet || nScript != nOldScript || bSyntaxMode )
+ aVars.SetPattern( pPattern, pCondSet, pCell, nScript );
+ else
+ aVars.SetPatternSimple( pPattern, pCondSet );
+ pOldPattern = pPattern;
+ pOldCondSet = pCondSet;
+ nOldScript = nScript;
+ }
+
+ // use edit engine for rotated, stacked or mixed-script text
+ if ( aVars.GetOrient() == SVX_ORIENTATION_STACKED ||
+ aVars.IsRotated() || IsAmbiguousScript(nScript) )
+ bNeedEdit = TRUE;
+ }
+ if (bDoCell && !bNeedEdit)
+ {
+ BOOL bFormulaCell = (pCell->GetCellType() == CELLTYPE_FORMULA );
+ if ( bFormulaCell )
+ lcl_CreateInterpretProgress( bProgress, pDoc, (ScFormulaCell*)pCell );
+ if ( aVars.SetText(pCell) )
+ pOldPattern = NULL;
+ bNeedEdit = aVars.HasEditCharacters() ||
+ (bFormulaCell && ((ScFormulaCell*)pCell)->IsMultilineResult());
+ }
+ long nTotalMargin = 0;
+ if (bDoCell && !bNeedEdit)
+ {
+ CellType eCellType = pCell->GetCellType();
+ bCellIsValue = ( eCellType == CELLTYPE_VALUE );
+ if ( eCellType == CELLTYPE_FORMULA )
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
+ bCellIsValue = pFCell->IsRunning() || pFCell->IsValue();
+ }
+
+ eOutHorJust = ( aVars.GetHorJust() != SVX_HOR_JUSTIFY_STANDARD ) ?
+ aVars.GetHorJust() :
+ ( bCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT );
+
+ if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT )
+ eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // repeat is not yet implemented
+
+ BOOL bBreak = ( aVars.GetLineBreak() || aVars.GetHorJust() == SVX_HOR_JUSTIFY_BLOCK );
+ BOOL bRepeat = aVars.IsRepeat() && !bBreak;
+ BOOL bShrink = aVars.IsShrink() && !bBreak && !bRepeat;
+
+ nTotalMargin =
+ static_cast<long>(aVars.GetLeftTotal() * nPPTX) +
+ static_cast<long>(aVars.GetMargin()->GetRightMargin() * nPPTX);
+
+ nNeededWidth = aVars.GetTextSize().Width() + nTotalMargin;
+
+ // GetOutputArea gives justfied rectangles
+ GetOutputArea( nX, nArrY, nPosX, nPosY, nCellX, nCellY, nNeededWidth,
+ *pPattern, sal::static_int_cast<USHORT>(eOutHorJust),
+ bCellIsValue || bRepeat || bShrink, bBreak, FALSE,
+ aAreaParam );
+
+ if ( bShrink )
+ {
+ if ( aVars.GetOrient() != SVX_ORIENTATION_STANDARD )
+ {
+ // Only horizontal scaling is handled here.
+ // DrawEdit is used to vertically scale 90 deg rotated text.
+ bNeedEdit = TRUE;
+ }
+ else if ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) // horizontal
+ {
+ long nAvailable = aAreaParam.maAlignRect.GetWidth() - nTotalMargin;
+ long nScaleSize = aVars.GetTextSize().Width(); // without margin
+
+ if ( nScaleSize > 0 ) // 0 if the text is empty (formulas, number formats)
+ {
+ long nScale = ( nAvailable * 100 ) / nScaleSize;
+
+ aVars.SetShrinkScale( nScale, nOldScript );
+ long nNewSize = aVars.GetTextSize().Width();
+
+ USHORT nShrinkAgain = 0;
+ while ( nNewSize > nAvailable && nShrinkAgain < SC_SHRINKAGAIN_MAX )
+ {
+ // If the text is still too large, reduce the scale again by 10%, until it fits,
+ // at most 7 times (it's less than 50% of the calculated scale then).
+
+ nScale = ( nScale * 9 ) / 10;
+ aVars.SetShrinkScale( nScale, nOldScript );
+ nNewSize = aVars.GetTextSize().Width();
+ ++nShrinkAgain;
+ }
+ // If even at half the size the font still isn't rendered smaller,
+ // fall back to normal clipping (showing ### for numbers).
+ if ( nNewSize <= nAvailable )
+ aAreaParam.mbLeftClip = aAreaParam.mbRightClip = FALSE;
+
+ pOldPattern = NULL;
+ }
+ }
+ }
+
+ if ( bRepeat && !aAreaParam.mbLeftClip && !aAreaParam.mbRightClip )
+ {
+ long nAvailable = aAreaParam.maAlignRect.GetWidth() - nTotalMargin;
+ long nRepeatSize = aVars.GetTextSize().Width(); // without margin
+ // When formatting for the printer, the text sizes don't always add up.
+ // Round down (too few repetitions) rather than exceeding the cell size then:
+ if ( pFmtDevice != pRefDevice )
+ ++nRepeatSize;
+ if ( nRepeatSize > 0 )
+ {
+ long nRepeatCount = nAvailable / nRepeatSize;
+ if ( nRepeatCount > 1 )
+ {
+ String aCellStr = aVars.GetString();
+ String aRepeated = aCellStr;
+ for ( long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
+ aRepeated.Append( aCellStr );
+ aVars.SetAutoText( aRepeated );
+ }
+ }
+ }
+
+ // use edit engine if automatic line breaks are needed
+ if ( bBreak )
+ {
+ if ( aVars.GetOrient() == SVX_ORIENTATION_STANDARD )
+ bNeedEdit = ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip );
+ else
+ {
+ long nHeight = aVars.GetTextSize().Height() +
+ (long)(aVars.GetMargin()->GetTopMargin()*nPPTY) +
+ (long)(aVars.GetMargin()->GetBottomMargin()*nPPTY);
+ bNeedEdit = ( nHeight > aAreaParam.maClipRect.GetHeight() );
+ }
+ }
+ if (!bNeedEdit)
+ {
+ bNeedEdit =
+ aVars.GetHorJust() == SVX_HOR_JUSTIFY_BLOCK &&
+ aVars.GetHorJustMethod() == SVX_JUSTIFY_METHOD_DISTRIBUTE;
+ }
+ }
+ if (bNeedEdit)
+ {
+ // mark the cell in CellInfo to be drawn in DrawEdit:
+ // Cells to the left are marked directly, cells to the
+ // right are handled by the flag for nX2
+ SCCOL nMarkX = ( nCellX <= nX2 ) ? nCellX : nX2;
+ RowInfo* pMarkRowInfo = ( nCellY == nY ) ? pThisRowInfo : &pRowInfo[0];
+ pMarkRowInfo->pCellInfo[nMarkX+1].bEditEngine = TRUE;
+ bDoCell = FALSE; // don't draw here
+ }
+ if ( bDoCell )
+ {
+ if ( bCellIsValue && ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) )
+ {
+ // Adjust the decimals to fit the available column width.
+ aVars.SetTextToWidthOrHash(pCell, aAreaParam.mnColWidth - nTotalMargin);
+ nNeededWidth = aVars.GetTextSize().Width() +
+ (long) ( aVars.GetLeftTotal() * nPPTX ) +
+ (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX );
+ if ( nNeededWidth <= aAreaParam.maClipRect.GetWidth() )
+ aAreaParam.mbLeftClip = aAreaParam.mbRightClip = FALSE;
+
+ // If the "###" replacement doesn't fit into the cells, no clip marks
+ // are shown, as the "###" already denotes too little space.
+ // The rectangles from the first GetOutputArea call remain valid.
+ }
+
+ long nJustPosX = aAreaParam.maAlignRect.Left(); // "justified" - effect of alignment will be added
+ long nJustPosY = aAreaParam.maAlignRect.Top();
+ long nAvailWidth = aAreaParam.maAlignRect.GetWidth();
+ long nOutHeight = aAreaParam.maAlignRect.GetHeight();
+
+ BOOL bOutside = ( aAreaParam.maClipRect.Right() < nScrX || aAreaParam.maClipRect.Left() >= nScrX + nScrW );
+ if ( aAreaParam.maClipRect.Left() < nScrX )
+ {
+ aAreaParam.maClipRect.Left() = nScrX;
+ aAreaParam.mbLeftClip = TRUE;
+ }
+ if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
+ {
+ aAreaParam.maClipRect.Right() = nScrX + nScrW; //! minus one?
+ aAreaParam.mbRightClip = TRUE;
+ }
+
+ BOOL bHClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
+ BOOL bVClip = FALSE;
+
+ if ( aAreaParam.maClipRect.Top() < nScrY )
+ {
+ aAreaParam.maClipRect.Top() = nScrY;
+ bVClip = TRUE;
+ }
+ if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
+ {
+ aAreaParam.maClipRect.Bottom() = nScrY + nScrH; //! minus one?
+ bVClip = TRUE;
+ }
+
+ //
+ // horizontalen Platz testen
+ //
+
+ BOOL bRightAdjusted = FALSE; // to correct text width calculation later
+ BOOL bNeedEditEngine = FALSE;
+ if ( !bNeedEditEngine && !bOutside )
+ {
+ switch (eOutHorJust)
+ {
+ case SVX_HOR_JUSTIFY_LEFT:
+ nJustPosX += (long) ( aVars.GetLeftTotal() * nPPTX );
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ nJustPosX += nAvailWidth - aVars.GetTextSize().Width() -
+ (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX );
+ bRightAdjusted = TRUE;
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ nJustPosX += ( nAvailWidth - aVars.GetTextSize().Width() +
+ (long) ( aVars.GetLeftTotal() * nPPTX ) -
+ (long) ( aVars.GetMargin()->GetRightMargin() * nPPTX ) ) / 2;
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ long nTestClipHeight = aVars.GetTextSize().Height();
+ switch (aVars.GetVerJust())
+ {
+ case SVX_VER_JUSTIFY_TOP:
+ case SVX_VER_JUSTIFY_BLOCK:
+ {
+ long nTop = (long)( aVars.GetMargin()->GetTopMargin() * nPPTY );
+ nJustPosY += nTop;
+ nTestClipHeight += nTop;
+ }
+ break;
+ case SVX_VER_JUSTIFY_BOTTOM:
+ {
+ long nBot = (long)( aVars.GetMargin()->GetBottomMargin() * nPPTY );
+ nJustPosY += nOutHeight - aVars.GetTextSize().Height() - nBot;
+ nTestClipHeight += nBot;
+ }
+ break;
+ case SVX_VER_JUSTIFY_CENTER:
+ {
+ long nTop = (long)( aVars.GetMargin()->GetTopMargin() * nPPTY );
+ long nBot = (long)( aVars.GetMargin()->GetBottomMargin() * nPPTY );
+ nJustPosY += ( nOutHeight + nTop -
+ aVars.GetTextSize().Height() - nBot ) / 2;
+ nTestClipHeight += Abs( nTop - nBot );
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if ( nTestClipHeight > nOutHeight )
+ {
+ // kein vertikales Clipping beim Drucken von Zellen mit
+ // optimaler Hoehe, ausser bei Groesse in bedingter Formatierung
+ if ( eType != OUTTYPE_PRINTER ||
+ ( pDoc->GetRowFlags( nCellY, nTab ) & CR_MANUALSIZE ) ||
+ ( aVars.HasCondHeight() ) )
+ bVClip = TRUE;
+ }
+
+ if ( bHClip || bVClip )
+ {
+ // nur die betroffene Dimension clippen,
+ // damit bei nicht-proportionalem Resize nicht alle
+ // rechtsbuendigen Zahlen abgeschnitten werden:
+
+ if (!bHClip)
+ {
+ aAreaParam.maClipRect.Left() = nScrX;
+ aAreaParam.maClipRect.Right() = nScrX+nScrW;
+ }
+ if (!bVClip)
+ {
+ aAreaParam.maClipRect.Top() = nScrY;
+ aAreaParam.maClipRect.Bottom() = nScrY+nScrH;
+ }
+
+ // aClipRect is not used after SetClipRegion/IntersectClipRegion,
+ // so it can be modified here
+ if (bPixelToLogic)
+ aAreaParam.maClipRect = pRefDevice->PixelToLogic( aAreaParam.maClipRect );
+
+ if (bMetaFile)
+ {
+ pDev->Push();
+ pDev->IntersectClipRegion( aAreaParam.maClipRect );
+ }
+ else
+ pDev->SetClipRegion( Region( aAreaParam.maClipRect ) );
+ }
+
+ Point aURLStart( nJustPosX, nJustPosY ); // copy before modifying for orientation
+
+ switch (aVars.GetOrient())
+ {
+ case SVX_ORIENTATION_STANDARD:
+ nJustPosY += aVars.GetAscent();
+ break;
+ case SVX_ORIENTATION_TOPBOTTOM:
+ nJustPosX += aVars.GetTextSize().Width() - aVars.GetAscent();
+ break;
+ case SVX_ORIENTATION_BOTTOMTOP:
+ nJustPosY += aVars.GetTextSize().Height();
+ nJustPosX += aVars.GetAscent();
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ // When clipping, the visible part is now completely defined by the alignment,
+ // there's no more special handling to show the right part of RTL text.
+
+ Point aDrawTextPos( nJustPosX, nJustPosY );
+ if ( bPixelToLogic )
+ {
+ // undo text width adjustment in pixels
+ if (bRightAdjusted)
+ aDrawTextPos.X() += aVars.GetTextSize().Width();
+
+ aDrawTextPos = pRefDevice->PixelToLogic( aDrawTextPos );
+
+ // redo text width adjustment in logic units
+ if (bRightAdjusted)
+ aDrawTextPos.X() -= aVars.GetOriginalWidth();
+ }
+
+ // in Metafiles immer DrawTextArray, damit die Positionen mit
+ // aufgezeichnet werden (fuer nicht-proportionales Resize):
+
+ String aString = aVars.GetString();
+ if (bMetaFile || pFmtDevice != pDev || aZoomX != aZoomY)
+ {
+ sal_Int32* pDX = new sal_Int32[aString.Len()];
+ pFmtDevice->GetTextArray( aString, pDX );
+
+ if ( !pRefDevice->GetConnectMetaFile() ||
+ pRefDevice->GetOutDevType() == OUTDEV_PRINTER )
+ {
+ double fMul = GetStretch();
+ xub_StrLen nLen = aString.Len();
+ for (xub_StrLen i=0; i<nLen; i++)
+ pDX[i] = (long)(pDX[i] / fMul + 0.5);
+ }
+
+ pDev->DrawTextArray( aDrawTextPos, aString, pDX );
+ delete[] pDX;
+ }
+ else
+ pDev->DrawText( aDrawTextPos, aString );
+
+ if ( bHClip || bVClip )
+ {
+ if (bMetaFile)
+ pDev->Pop();
+ else
+ pDev->SetClipRegion();
+ }
+
+ // PDF: whole-cell hyperlink from formula?
+ BOOL bHasURL = pPDFData && pCell && pCell->GetCellType() == CELLTYPE_FORMULA &&
+ static_cast<ScFormulaCell*>(pCell)->IsHyperLinkCell();
+ if ( bHasURL )
+ {
+ Rectangle aURLRect( aURLStart, aVars.GetTextSize() );
+ lcl_DoHyperlinkResult( pDev, aURLRect, pCell );
+ }
+ }
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ }
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+ if ( bProgress )
+ ScProgress::DeleteInterpretProgress();
+ pDoc->DisableIdle( bWasIdleDisabled );
+}
+
+// -------------------------------------------------------------------------------
+
+void lcl_ClearEdit( EditEngine& rEngine ) // Text und Attribute
+{
+ rEngine.SetUpdateMode( FALSE );
+
+ rEngine.SetText(EMPTY_STRING);
+ // keine Para-Attribute uebrigbehalten...
+ const SfxItemSet& rPara = rEngine.GetParaAttribs(0);
+ if (rPara.Count())
+ rEngine.SetParaAttribs( 0,
+ SfxItemSet( *rPara.GetPool(), rPara.GetRanges() ) );
+}
+
+BOOL lcl_SafeIsValue( ScBaseCell* pCell )
+{
+ if (!pCell)
+ return FALSE;
+
+ BOOL bRet = FALSE;
+ switch ( pCell->GetCellType() )
+ {
+ case CELLTYPE_VALUE:
+ bRet = TRUE;
+ break;
+ case CELLTYPE_FORMULA:
+ {
+ ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
+ if ( pFCell->IsRunning() || pFCell->IsValue() )
+ bRet = TRUE;
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return bRet;
+}
+
+void lcl_ScaleFonts( EditEngine& rEngine, long nPercent )
+{
+ BOOL bUpdateMode = rEngine.GetUpdateMode();
+ if ( bUpdateMode )
+ rEngine.SetUpdateMode( FALSE );
+
+ USHORT nParCount = rEngine.GetParagraphCount();
+ for (USHORT nPar=0; nPar<nParCount; nPar++)
+ {
+ SvUShorts aPortions;
+ rEngine.GetPortions( nPar, aPortions );
+
+ USHORT nPCount = aPortions.Count();
+ USHORT nStart = 0;
+ for ( USHORT nPos=0; nPos<nPCount; nPos++ )
+ {
+ USHORT nEnd = aPortions.GetObject( nPos );
+ ESelection aSel( nPar, nStart, nPar, nEnd );
+ SfxItemSet aAttribs = rEngine.GetAttribs( aSel );
+
+ long nWestern = static_cast<const SvxFontHeightItem&>(aAttribs.Get(EE_CHAR_FONTHEIGHT)).GetHeight();
+ long nCJK = static_cast<const SvxFontHeightItem&>(aAttribs.Get(EE_CHAR_FONTHEIGHT_CJK)).GetHeight();
+ long nCTL = static_cast<const SvxFontHeightItem&>(aAttribs.Get(EE_CHAR_FONTHEIGHT_CTL)).GetHeight();
+
+ nWestern = ( nWestern * nPercent ) / 100;
+ nCJK = ( nCJK * nPercent ) / 100;
+ nCTL = ( nCTL * nPercent ) / 100;
+
+ aAttribs.Put( SvxFontHeightItem( nWestern, 100, EE_CHAR_FONTHEIGHT ) );
+ aAttribs.Put( SvxFontHeightItem( nCJK, 100, EE_CHAR_FONTHEIGHT_CJK ) );
+ aAttribs.Put( SvxFontHeightItem( nCTL, 100, EE_CHAR_FONTHEIGHT_CTL ) );
+
+ rEngine.QuickSetAttribs( aAttribs, aSel ); //! remove paragraph attributes from aAttribs?
+
+ nStart = nEnd;
+ }
+ }
+
+ if ( bUpdateMode )
+ rEngine.SetUpdateMode( TRUE );
+}
+
+long lcl_GetEditSize( EditEngine& rEngine, BOOL bWidth, BOOL bSwap, long nAttrRotate )
+{
+ if ( bSwap )
+ bWidth = !bWidth;
+
+ if ( nAttrRotate )
+ {
+ long nRealWidth = (long) rEngine.CalcTextWidth();
+ long nRealHeight = rEngine.GetTextHeight();
+
+ // assuming standard mode, otherwise width isn't used
+
+ double nRealOrient = nAttrRotate * F_PI18000; // 1/100th degrees
+ double nAbsCos = fabs( cos( nRealOrient ) );
+ double nAbsSin = fabs( sin( nRealOrient ) );
+ if ( bWidth )
+ return (long) ( nRealWidth * nAbsCos + nRealHeight * nAbsSin );
+ else
+ return (long) ( nRealHeight * nAbsCos + nRealWidth * nAbsSin );
+ }
+ else if ( bWidth )
+ return (long) rEngine.CalcTextWidth();
+ else
+ return rEngine.GetTextHeight();
+}
+
+
+void ScOutputData::ShrinkEditEngine( EditEngine& rEngine, const Rectangle& rAlignRect,
+ long nLeftM, long nTopM, long nRightM, long nBottomM,
+ BOOL bWidth, USHORT nOrient, long nAttrRotate, BOOL bPixelToLogic,
+ long& rEngineWidth, long& rEngineHeight, long& rNeededPixel, bool& rLeftClip, bool& rRightClip )
+{
+ if ( !bWidth )
+ {
+ // vertical
+
+ long nScaleSize = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(0,rEngineHeight)).Height() : rEngineHeight;
+
+ // Don't scale if it fits already.
+ // Allowing to extend into the margin, to avoid scaling at optimal height.
+ if ( nScaleSize <= rAlignRect.GetHeight() )
+ return;
+
+ BOOL bSwap = ( nOrient == SVX_ORIENTATION_TOPBOTTOM || nOrient == SVX_ORIENTATION_BOTTOMTOP );
+ long nAvailable = rAlignRect.GetHeight() - nTopM - nBottomM;
+ long nScale = ( nAvailable * 100 ) / nScaleSize;
+
+ lcl_ScaleFonts( rEngine, nScale );
+ rEngineHeight = lcl_GetEditSize( rEngine, FALSE, bSwap, nAttrRotate );
+ long nNewSize = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(0,rEngineHeight)).Height() : rEngineHeight;
+
+ USHORT nShrinkAgain = 0;
+ while ( nNewSize > nAvailable && nShrinkAgain < SC_SHRINKAGAIN_MAX )
+ {
+ // further reduce, like in DrawStrings
+ lcl_ScaleFonts( rEngine, 90 ); // reduce by 10%
+ rEngineHeight = lcl_GetEditSize( rEngine, FALSE, bSwap, nAttrRotate );
+ nNewSize = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(0,rEngineHeight)).Height() : rEngineHeight;
+ ++nShrinkAgain;
+ }
+
+ // sizes for further processing (alignment etc):
+ rEngineWidth = lcl_GetEditSize( rEngine, TRUE, bSwap, nAttrRotate );
+ long nPixelWidth = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(rEngineWidth,0)).Width() : rEngineWidth;
+ rNeededPixel = nPixelWidth + nLeftM + nRightM;
+ }
+ else if ( rLeftClip || rRightClip )
+ {
+ // horizontal
+
+ long nAvailable = rAlignRect.GetWidth() - nLeftM - nRightM;
+ long nScaleSize = rNeededPixel - nLeftM - nRightM; // without margin
+
+ if ( nScaleSize <= nAvailable )
+ return;
+
+ long nScale = ( nAvailable * 100 ) / nScaleSize;
+
+ lcl_ScaleFonts( rEngine, nScale );
+ rEngineWidth = lcl_GetEditSize( rEngine, TRUE, FALSE, nAttrRotate );
+ long nNewSize = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(rEngineWidth,0)).Width() : rEngineWidth;
+
+ USHORT nShrinkAgain = 0;
+ while ( nNewSize > nAvailable && nShrinkAgain < SC_SHRINKAGAIN_MAX )
+ {
+ // further reduce, like in DrawStrings
+ lcl_ScaleFonts( rEngine, 90 ); // reduce by 10%
+ rEngineWidth = lcl_GetEditSize( rEngine, TRUE, FALSE, nAttrRotate );
+ nNewSize = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(rEngineWidth,0)).Width() : rEngineWidth;
+ ++nShrinkAgain;
+ }
+ if ( nNewSize <= nAvailable )
+ rLeftClip = rRightClip = FALSE;
+
+ // sizes for further processing (alignment etc):
+ rNeededPixel = nNewSize + nLeftM + nRightM;
+ rEngineHeight = lcl_GetEditSize( rEngine, FALSE, FALSE, nAttrRotate );
+ }
+}
+
+namespace {
+
+class EditAlignmentParam
+{
+public:
+ SvxCellHorJustify meHorJust;
+ SvxCellVerJustify meVerJust;
+ SvxCellJustifyMethod meHorJustMethod;
+ SvxCellJustifyMethod meVerJustMethod;
+ SvxCellOrientation meOrient;
+ bool mbBreak;
+ bool mbCellIsValue;
+ bool mbAsianVertical;
+
+ explicit EditAlignmentParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue);
+
+ void calcMargins(long& rTop, long& rLeft, long& rBottom, long& rRight, double nPPTX, double nPPTY) const;
+ void calcPaperSize(Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const;
+ void getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const;
+ long getEngineWidth(ScFieldEditEngine* pEngine) const;
+ bool hasLineBreak() const;
+
+ /**
+ * When the text is vertically oriented, the text is either rotated 90
+ * degrees to the right or 90 degrees to the left. Note that this is
+ * different from being vertically stacked.
+ */
+ bool isVerticallyOriented() const;
+
+ void setAlignmentItems(ScFieldEditEngine* pEngine, ScBaseCell* pCell);
+ bool adjustHorAlignment(ScFieldEditEngine* pEngine);
+
+private:
+ const ScPatternAttr* mpPattern;
+ const SfxItemSet* mpCondSet;
+};
+
+EditAlignmentParam::EditAlignmentParam(const ScPatternAttr* pPattern, const SfxItemSet* pCondSet, bool bCellIsValue) :
+ meHorJust( lcl_GetValue<SvxHorJustifyItem, SvxCellHorJustify>(*pPattern, ATTR_HOR_JUSTIFY, pCondSet) ),
+ meVerJust( lcl_GetValue<SvxVerJustifyItem, SvxCellVerJustify>(*pPattern, ATTR_VER_JUSTIFY, pCondSet) ),
+ meHorJustMethod( lcl_GetValue<SvxJustifyMethodItem, SvxCellJustifyMethod>(*pPattern, ATTR_HOR_JUSTIFY_METHOD, pCondSet) ),
+ meVerJustMethod( lcl_GetValue<SvxJustifyMethodItem, SvxCellJustifyMethod>(*pPattern, ATTR_VER_JUSTIFY_METHOD, pCondSet) ),
+ meOrient( pPattern->GetCellOrientation(pCondSet) ),
+ mbBreak( (meHorJust == SVX_HOR_JUSTIFY_BLOCK) || lcl_GetBoolValue(*pPattern, ATTR_LINEBREAK, pCondSet) ),
+ mbCellIsValue(bCellIsValue),
+ mpPattern(pPattern),
+ mpCondSet(pCondSet)
+{}
+
+void EditAlignmentParam::calcMargins(long& rTopM, long& rLeftM, long& rBottomM, long& rRightM, double nPPTX, double nPPTY) const
+{
+ const SvxMarginItem& rMargin =
+ static_cast<const SvxMarginItem&>(mpPattern->GetItem(ATTR_MARGIN, mpCondSet));
+
+ USHORT nIndent = 0;
+ if (meHorJust == SVX_HOR_JUSTIFY_LEFT)
+ nIndent = lcl_GetValue<SfxUInt16Item, USHORT>(*mpPattern, ATTR_INDENT, mpCondSet);
+
+ rLeftM = static_cast<long>(((rMargin.GetLeftMargin() + nIndent) * nPPTX));
+ rTopM = static_cast<long>((rMargin.GetTopMargin() * nPPTY));
+ rRightM = static_cast<long>((rMargin.GetRightMargin() * nPPTX));
+ rBottomM = static_cast<long>((rMargin.GetBottomMargin() * nPPTY));
+}
+
+void EditAlignmentParam::calcPaperSize(
+ Size& rPaperSize, const Rectangle& rAlignRect, double nPPTX, double nPPTY) const
+{
+ long nTopM, nLeftM, nBottomM, nRightM;
+ calcMargins(nTopM, nLeftM, nBottomM, nRightM, nPPTX, nPPTY);
+
+ if (isVerticallyOriented())
+ {
+ rPaperSize.Width() = rAlignRect.GetHeight() - nTopM - nBottomM;
+ rPaperSize.Height() = rAlignRect.GetWidth() - nLeftM - nRightM;
+ }
+ else
+ {
+ rPaperSize.Width() = rAlignRect.GetWidth() - nLeftM - nRightM;
+ rPaperSize.Height() = rAlignRect.GetHeight() - nTopM - nBottomM;
+ }
+
+ if (mbAsianVertical)
+ {
+ rPaperSize.Height() = rAlignRect.GetHeight() - nTopM - nBottomM;
+ // Subtract some extra value from the height or else the text would go
+ // outside the cell area. The value of 5 is arbitrary, and is based
+ // entirely on heuristics.
+ rPaperSize.Height() -= 5;
+ }
+}
+
+void EditAlignmentParam::getEngineSize(ScFieldEditEngine* pEngine, long& rWidth, long& rHeight) const
+{
+ long nEngineWidth = 0;
+ if (!mbBreak || meOrient == SVX_ORIENTATION_STACKED || mbAsianVertical)
+ nEngineWidth = static_cast<long>(pEngine->CalcTextWidth());
+
+ long nEngineHeight = pEngine->GetTextHeight();
+
+ if (isVerticallyOriented())
+ {
+ long nTemp = nEngineWidth;
+ nEngineWidth = nEngineHeight;
+ nEngineHeight = nTemp;
+ }
+
+ if (meOrient == SVX_ORIENTATION_STACKED)
+ nEngineWidth = nEngineWidth * 11 / 10;
+
+ rWidth = nEngineWidth;
+ rHeight = nEngineHeight;
+}
+
+long EditAlignmentParam::getEngineWidth(ScFieldEditEngine* pEngine) const
+{
+ if (mbBreak && meOrient != SVX_ORIENTATION_STACKED && !mbAsianVertical)
+ return 0;
+ else
+ return static_cast<long>(pEngine->CalcTextWidth());
+}
+
+bool EditAlignmentParam::hasLineBreak() const
+{
+ return (mbBreak || (meOrient == SVX_ORIENTATION_STACKED) || mbAsianVertical);
+}
+
+bool EditAlignmentParam::isVerticallyOriented() const
+{
+ return (meOrient == SVX_ORIENTATION_TOPBOTTOM || meOrient == SVX_ORIENTATION_BOTTOMTOP);
+}
+
+void EditAlignmentParam::setAlignmentItems(ScFieldEditEngine* pEngine, ScBaseCell* pCell)
+{
+ if (isVerticallyOriented() || mbAsianVertical)
+ {
+ SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT;
+ switch (meVerJust)
+ {
+ case SVX_VER_JUSTIFY_TOP:
+ eSvxAdjust = (meOrient == SVX_ORIENTATION_TOPBOTTOM || mbAsianVertical) ?
+ SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT;
+ break;
+ case SVX_VER_JUSTIFY_CENTER:
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ break;
+ case SVX_VER_JUSTIFY_BOTTOM:
+ case SVX_VER_JUSTIFY_STANDARD:
+ eSvxAdjust = (meOrient == SVX_ORIENTATION_TOPBOTTOM || mbAsianVertical) ?
+ SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT;
+ break;
+ case SVX_VER_JUSTIFY_BLOCK:
+ eSvxAdjust = SVX_ADJUST_BLOCK;
+ break;
+ }
+
+ pEngine->SetDefaultItem( SvxAdjustItem(eSvxAdjust, EE_PARA_JUST) );
+ pEngine->SetDefaultItem( SvxJustifyMethodItem(meVerJustMethod, EE_PARA_JUST_METHOD) );
+
+ if (meHorJust == SVX_HOR_JUSTIFY_BLOCK)
+ pEngine->SetDefaultItem( SvxVerJustifyItem(SVX_VER_JUSTIFY_BLOCK, EE_PARA_VER_JUST) );
+ }
+ else
+ {
+ // horizontal alignment now may depend on cell content
+ // (for values with number formats with mixed script types)
+ // -> always set adjustment
+
+ SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT;
+ if (meOrient == SVX_ORIENTATION_STACKED)
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ else if (mbBreak)
+ {
+ if (meOrient == SVX_ORIENTATION_STANDARD)
+ switch (meHorJust)
+ {
+ case SVX_HOR_JUSTIFY_STANDARD:
+ eSvxAdjust = mbCellIsValue ? SVX_ADJUST_RIGHT : SVX_ADJUST_LEFT;
+ break;
+ case SVX_HOR_JUSTIFY_LEFT:
+ case SVX_HOR_JUSTIFY_REPEAT: // nicht implementiert
+ eSvxAdjust = SVX_ADJUST_LEFT;
+ break;
+ case SVX_HOR_JUSTIFY_RIGHT:
+ eSvxAdjust = SVX_ADJUST_RIGHT;
+ break;
+ case SVX_HOR_JUSTIFY_CENTER:
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ break;
+ case SVX_HOR_JUSTIFY_BLOCK:
+ eSvxAdjust = SVX_ADJUST_BLOCK;
+ break;
+ }
+ else
+ switch (meVerJust)
+ {
+ case SVX_VER_JUSTIFY_TOP:
+ eSvxAdjust = SVX_ADJUST_RIGHT;
+ break;
+ case SVX_VER_JUSTIFY_CENTER:
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ break;
+ case SVX_VER_JUSTIFY_BOTTOM:
+ case SVX_VER_JUSTIFY_STANDARD:
+ eSvxAdjust = SVX_ADJUST_LEFT;
+ break;
+ case SVX_VER_JUSTIFY_BLOCK:
+ eSvxAdjust = SVX_ADJUST_BLOCK;
+ break;
+ }
+ }
+
+ pEngine->SetDefaultItem( SvxAdjustItem(eSvxAdjust, EE_PARA_JUST) );
+
+ if (mbAsianVertical)
+ {
+ pEngine->SetDefaultItem( SvxJustifyMethodItem(meVerJustMethod, EE_PARA_JUST_METHOD) );
+ if (meHorJust == SVX_HOR_JUSTIFY_BLOCK)
+ pEngine->SetDefaultItem( SvxVerJustifyItem(SVX_VER_JUSTIFY_BLOCK, EE_PARA_VER_JUST) );
+ }
+ else
+ {
+ pEngine->SetDefaultItem( SvxJustifyMethodItem(meHorJustMethod, EE_PARA_JUST_METHOD) );
+ if (meVerJust == SVX_VER_JUSTIFY_BLOCK)
+ pEngine->SetDefaultItem( SvxVerJustifyItem(SVX_VER_JUSTIFY_BLOCK, EE_PARA_VER_JUST) );
+ }
+ }
+
+ pEngine->SetVertical(mbAsianVertical);
+ if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ // We need to synchronize the vertical mode in the EditTextObject
+ // instance too. No idea why we keep this state in two separate
+ // instances.
+ ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
+ const EditTextObject* pData = pEditCell->GetData();
+ if (pData)
+ const_cast<EditTextObject*>(pData)->SetVertical(mbAsianVertical);
+ }
+}
+
+bool EditAlignmentParam::adjustHorAlignment(ScFieldEditEngine* pEngine)
+{
+ if (meHorJust == SVX_HOR_JUSTIFY_RIGHT || meHorJust == SVX_HOR_JUSTIFY_CENTER ||
+ (meHorJust == SVX_HOR_JUSTIFY_STANDARD && mbCellIsValue))
+ {
+ SvxAdjust eEditAdjust = (meHorJust == SVX_HOR_JUSTIFY_CENTER) ?
+ SVX_ADJUST_CENTER : SVX_ADJUST_RIGHT;
+
+ pEngine->SetUpdateMode(false);
+ pEngine->SetDefaultItem( SvxAdjustItem(eEditAdjust, EE_PARA_JUST) );
+ pEngine->SetUpdateMode(true);
+ return true;
+ }
+ return false;
+}
+
+}
+
+void ScOutputData::DrawEdit(BOOL bPixelToLogic)
+{
+ vcl::PDFExtOutDevData* pPDFData = PTR_CAST( vcl::PDFExtOutDevData, pDev->GetExtOutDevData() );
+ Size aMinSize = pRefDevice->PixelToLogic(Size(0,100)); // erst darueber wird ausgegeben
+// UINT32 nMinHeight = aMinSize.Height() / 200; // 1/2 Pixel
+
+ ScModule* pScMod = SC_MOD();
+ sal_Int32 nConfBackColor = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor &&
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ ScFieldEditEngine* pEngine = NULL;
+ BOOL bHyphenatorSet = FALSE;
+ const ScPatternAttr* pOldPattern = NULL;
+ const SfxItemSet* pOldCondSet = NULL;
+ ScBaseCell* pCell = NULL;
+
+ Size aRefOne = pRefDevice->PixelToLogic(Size(1,1));
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ nInitPosX += nMirrorW - 1;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ //! store nLastContentCol as member!
+ SCCOL nLastContentCol = MAXCOL;
+ if ( nX2 < MAXCOL )
+ nLastContentCol = sal::static_int_cast<SCCOL>(
+ nLastContentCol - pDoc->GetEmptyLinesInBlock( nX2+1, nY1, nTab, MAXCOL, nY2, nTab, DIR_RIGHT ) );
+
+ long nRowPosY = nScrY;
+ for (SCSIZE nArrY=0; nArrY+1<nArrCount; nArrY++) // 0 fuer Reste von zusammengefassten
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+// long nCellHeight = (long) pThisRowInfo->nHeight;
+ if (nArrY==1) nRowPosY = nScrY; // vorher wird einzeln berechnet
+
+ if ( pThisRowInfo->bChanged || nArrY==0 )
+ {
+ long nPosX = 0;
+ for (SCCOL nX=0; nX<=nX2; nX++) // wegen Ueberhaengen
+ {
+ if (nX==nX1) nPosX = nInitPosX; // positions before nX1 are calculated individually
+
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ if (pInfo->bEditEngine)
+ {
+ SCROW nY = pThisRowInfo->nRowNo;
+
+ SCCOL nCellX = nX; // position where the cell really starts
+ SCROW nCellY = nY;
+ BOOL bDoCell = FALSE;
+
+ long nPosY = nRowPosY;
+ if ( nArrY == 0 )
+ {
+ nPosY = nScrY;
+ nY = pRowInfo[1].nRowNo;
+ SCCOL nOverX; // start of the merged cells
+ SCROW nOverY;
+ if (GetMergeOrigin( nX,nY, 1, nOverX,nOverY, TRUE ))
+ {
+ nCellX = nOverX;
+ nCellY = nOverY;
+ bDoCell = TRUE;
+ }
+ }
+ else if ( nX == nX2 && !pThisRowInfo->pCellInfo[nX+1].pCell )
+ {
+ // Rest of a long text further to the right?
+
+ SCCOL nTempX=nX;
+ while (nTempX < nLastContentCol && IsEmptyCellText( pThisRowInfo, nTempX, nY ))
+ ++nTempX;
+
+ if ( nTempX > nX &&
+ !IsEmptyCellText( pThisRowInfo, nTempX, nY ) &&
+ !pDoc->HasAttrib( nTempX,nY,nTab, nX,nY,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ {
+ nCellX = nTempX;
+ bDoCell = TRUE;
+ }
+ }
+ else
+ {
+ bDoCell = TRUE;
+ }
+
+ if ( bDoCell && bEditMode && nCellX == nEditCol && nCellY == nEditRow )
+ bDoCell = FALSE;
+
+ const ScPatternAttr* pPattern = NULL;
+ const SfxItemSet* pCondSet = NULL;
+ if (bDoCell)
+ {
+ if ( nCellY == nY && nCellX >= nX1 && nCellX <= nX2 &&
+ !pDoc->ColHidden(nCellX, nTab) )
+ {
+ CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nCellX+1];
+ pPattern = rCellInfo.pPatternAttr;
+ pCondSet = rCellInfo.pConditionSet;
+ pCell = rCellInfo.pCell;
+ }
+ else // get from document
+ {
+ pPattern = pDoc->GetPattern( nCellX, nCellY, nTab );
+ pCondSet = pDoc->GetCondResult( nCellX, nCellY, nTab );
+ GetVisibleCell( nCellX, nCellY, nTab, pCell );
+ }
+ if ( !pCell )
+ bDoCell = FALSE;
+ }
+ if (bDoCell)
+ {
+ BOOL bHidden = FALSE;
+
+ //
+ // Create EditEngine
+ //
+
+ if (!pEngine)
+ {
+ // Ein RefDevice muss auf jeden Fall gesetzt werden,
+ // sonst legt sich die EditEngine ein VirtualDevice an!
+ pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() );
+ pEngine->SetUpdateMode( FALSE );
+ pEngine->SetRefDevice( pFmtDevice ); // always set
+ ULONG nCtrl = pEngine->GetControlWord();
+ if ( bShowSpellErrors )
+ nCtrl |= EE_CNTRL_ONLINESPELLING;
+ if ( eType == OUTTYPE_PRINTER )
+ nCtrl &= ~EE_CNTRL_MARKFIELDS;
+ pEngine->SetControlWord( nCtrl );
+ pEngine->SetForbiddenCharsTable( pDoc->GetForbiddenCharacters() );
+ pEngine->SetAsianCompressionMode( pDoc->GetAsianCompression() );
+ pEngine->SetKernAsianPunctuation( pDoc->GetAsianKerning() );
+ pEngine->EnableAutoColor( bUseStyleColor );
+ pEngine->SetDefaultHorizontalTextDirection(
+ (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
+ }
+ else
+ lcl_ClearEdit( *pEngine ); // also calls SetUpdateMode(FALSE)
+
+ EditAlignmentParam aAlignParam(pPattern, pCondSet, lcl_SafeIsValue(pCell));
+
+ bool bRepeat = (aAlignParam.meHorJust == SVX_HOR_JUSTIFY_REPEAT && !aAlignParam.mbBreak);
+ bool bShrink = !aAlignParam.mbBreak && !bRepeat && lcl_GetBoolValue(*pPattern, ATTR_SHRINKTOFIT, pCondSet);
+ long nAttrRotate = lcl_GetValue<SfxInt32Item, long>(*pPattern, ATTR_ROTATE_VALUE, pCondSet);
+
+ if ( aAlignParam.meHorJust == SVX_HOR_JUSTIFY_REPEAT )
+ {
+ // ignore orientation/rotation if "repeat" is active
+ aAlignParam.meOrient = SVX_ORIENTATION_STANDARD;
+ nAttrRotate = 0;
+
+ // #i31843# "repeat" with "line breaks" is treated as default alignment
+ // (but rotation is still disabled)
+ if ( aAlignParam.mbBreak )
+ aAlignParam.meHorJust = SVX_HOR_JUSTIFY_STANDARD;
+ }
+ if ( aAlignParam.meOrient==SVX_ORIENTATION_STANDARD && nAttrRotate )
+ {
+ //! Flag setzen, um die Zelle in DrawRotated wiederzufinden ?
+ //! (oder Flag schon bei DrawBackground, dann hier keine Abfrage)
+ bHidden = TRUE; // gedreht wird getrennt ausgegeben
+ }
+
+ aAlignParam.mbAsianVertical = (aAlignParam.meOrient == SVX_ORIENTATION_STACKED) &&
+ lcl_GetBoolValue(*pPattern, ATTR_VERTICAL_ASIAN, pCondSet);
+
+ if ( aAlignParam.mbAsianVertical )
+ {
+ // in asian mode, use EditEngine::SetVertical instead of EE_CNTRL_ONECHARPERLINE
+ aAlignParam.meOrient = SVX_ORIENTATION_STANDARD;
+ // default alignment for asian vertical mode is top-right
+ if ( aAlignParam.meHorJust == SVX_HOR_JUSTIFY_STANDARD )
+ aAlignParam.meHorJust = SVX_HOR_JUSTIFY_RIGHT;
+ }
+
+ SvxCellHorJustify eOutHorJust =
+ ( aAlignParam.meHorJust != SVX_HOR_JUSTIFY_STANDARD ) ? aAlignParam.meHorJust :
+ ( aAlignParam.mbCellIsValue ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT );
+
+ if ( eOutHorJust == SVX_HOR_JUSTIFY_BLOCK || eOutHorJust == SVX_HOR_JUSTIFY_REPEAT )
+ eOutHorJust = SVX_HOR_JUSTIFY_LEFT; // repeat is not yet implemented
+
+ if (!bHidden)
+ {
+ //! mirror margin values for RTL?
+ //! move margin down to after final GetOutputArea call
+ long nTopM, nLeftM, nBottomM, nRightM;
+ aAlignParam.calcMargins(nTopM, nLeftM, nBottomM, nRightM, nPPTX, nPPTY);
+
+ SCCOL nXForPos = nX;
+ if ( nXForPos < nX1 )
+ {
+ nXForPos = nX1;
+ nPosX = nInitPosX;
+ }
+ SCSIZE nArrYForPos = nArrY;
+ if ( nArrYForPos < 1 )
+ {
+ nArrYForPos = 1;
+ nPosY = nScrY;
+ }
+
+ OutputAreaParam aAreaParam;
+
+ //
+ // Initial page size - large for normal text, cell size for automatic line breaks
+ //
+
+ Size aPaperSize = Size( 1000000, 1000000 );
+ if (aAlignParam.hasLineBreak())
+ {
+ // call GetOutputArea with nNeeded=0, to get only the cell width
+
+ //! handle nArrY == 0
+ GetOutputArea( nXForPos, nArrYForPos, nPosX, nPosY, nCellX, nCellY, 0,
+ *pPattern, sal::static_int_cast<USHORT>(eOutHorJust),
+ aAlignParam.mbCellIsValue, true, false, aAreaParam );
+
+ //! special ScEditUtil handling if formatting for printer
+ aAlignParam.calcPaperSize(aPaperSize, aAreaParam.maAlignRect, nPPTX, nPPTY);
+ }
+ if (bPixelToLogic)
+ {
+ Size aLogicSize = pRefDevice->PixelToLogic(aPaperSize);
+ if ( aAlignParam.mbBreak && !aAlignParam.mbAsianVertical && pRefDevice != pFmtDevice )
+ {
+ // #i85342# screen display and formatting for printer,
+ // use same GetEditArea call as in ScViewData::SetEditEngine
+
+ Fraction aFract(1,1);
+ Rectangle aUtilRect = ScEditUtil( pDoc, nCellX, nCellY, nTab, Point(0,0), pFmtDevice,
+ HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, FALSE );
+ aLogicSize.Width() = aUtilRect.GetWidth();
+ }
+ pEngine->SetPaperSize(aLogicSize);
+ }
+ else
+ pEngine->SetPaperSize(aPaperSize);
+
+ //
+ // Fill the EditEngine (cell attributes and text)
+ //
+
+ // default alignment for asian vertical mode is top-right
+ if ( aAlignParam.mbAsianVertical && aAlignParam.meVerJust == SVX_VER_JUSTIFY_STANDARD )
+ aAlignParam.meVerJust = SVX_VER_JUSTIFY_TOP;
+
+ // syntax highlighting mode is ignored here
+ // StringDiffer doesn't look at hyphenate, language items
+ if ( pPattern != pOldPattern || pCondSet != pOldCondSet )
+ {
+ SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() );
+ pPattern->FillEditItemSet( pSet, pCondSet );
+
+ pEngine->SetDefaults( pSet );
+ pOldPattern = pPattern;
+ pOldCondSet = pCondSet;
+
+ ULONG nControl = pEngine->GetControlWord();
+ if (aAlignParam.meOrient==SVX_ORIENTATION_STACKED)
+ nControl |= EE_CNTRL_ONECHARPERLINE;
+ else
+ nControl &= ~EE_CNTRL_ONECHARPERLINE;
+ pEngine->SetControlWord( nControl );
+
+ if ( !bHyphenatorSet && ((const SfxBoolItem&)pSet->Get(EE_PARA_HYPHENATE)).GetValue() )
+ {
+ // set hyphenator the first time it is needed
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() );
+ pEngine->SetHyphenator( xXHyphenator );
+ bHyphenatorSet = TRUE;
+ }
+
+ Color aBackCol = ((const SvxBrushItem&)
+ pPattern->GetItem( ATTR_BACKGROUND, pCondSet )).GetColor();
+ if ( bUseStyleColor && ( aBackCol.GetTransparency() > 0 || bCellContrast ) )
+ aBackCol.SetColor( nConfBackColor );
+ pEngine->SetBackgroundColor( aBackCol );
+ }
+
+ aAlignParam.setAlignmentItems(pEngine, pCell);
+
+ // Read content from cell
+
+ BOOL bWrapFields = FALSE;
+ if (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ const EditTextObject* pData;
+ ((ScEditCell*)pCell)->GetData(pData);
+
+ if (pData)
+ {
+ pEngine->SetText(*pData);
+
+ if ( aAlignParam.mbBreak && !aAlignParam.mbAsianVertical && pData->HasField() )
+ {
+ // Fields aren't wrapped, so clipping is enabled to prevent
+ // a field from being drawn beyond the cell size
+
+ bWrapFields = TRUE;
+ }
+ }
+ else
+ {
+ DBG_ERROR("pData == 0");
+ }
+ }
+ else
+ {
+ ULONG nFormat = pPattern->GetNumberFormat(
+ pDoc->GetFormatTable(), pCondSet );
+ String aString;
+ Color* pColor;
+ ScCellFormat::GetString( pCell,
+ nFormat,aString, &pColor,
+ *pDoc->GetFormatTable(),
+ bShowNullValues,
+ bShowFormulas,
+ ftCheck );
+
+ pEngine->SetText(aString);
+ if ( pColor && !bSyntaxMode && !( bUseStyleColor && bForceAutoColor ) )
+ lcl_SetEditColor( *pEngine, *pColor );
+ }
+
+ if ( bSyntaxMode )
+ SetEditSyntaxColor( *pEngine, pCell );
+ else if ( bUseStyleColor && bForceAutoColor )
+ lcl_SetEditColor( *pEngine, COL_AUTO ); //! or have a flag at EditEngine
+ }
+ else
+ {
+ DBG_ERROR("pCell == NULL");
+ }
+
+ pEngine->SetUpdateMode( TRUE ); // after SetText, before CalcTextWidth/GetTextHeight
+
+ //
+ // Get final output area using the calculated width
+ //
+
+ long nEngineWidth, nEngineHeight;
+ aAlignParam.getEngineSize(pEngine, nEngineWidth, nEngineHeight);
+
+ long nNeededPixel = nEngineWidth;
+ if (bPixelToLogic)
+ nNeededPixel = pRefDevice->LogicToPixel(Size(nNeededPixel,0)).Width();
+ nNeededPixel += nLeftM + nRightM;
+
+ if ( ( !aAlignParam.mbBreak && aAlignParam.meOrient != SVX_ORIENTATION_STACKED ) || aAlignParam.mbAsianVertical || bShrink )
+ {
+ // for break, the first GetOutputArea call is sufficient
+ GetOutputArea( nXForPos, nArrYForPos, nPosX, nPosY, nCellX, nCellY, nNeededPixel,
+ *pPattern, sal::static_int_cast<USHORT>(eOutHorJust),
+ aAlignParam.mbCellIsValue || bRepeat || bShrink, false, false, aAreaParam );
+
+ if ( bShrink )
+ {
+ BOOL bWidth = ( aAlignParam.meOrient == SVX_ORIENTATION_STANDARD && !aAlignParam.mbAsianVertical );
+ ShrinkEditEngine( *pEngine, aAreaParam.maAlignRect,
+ nLeftM, nTopM, nRightM, nBottomM, bWidth,
+ sal::static_int_cast<USHORT>(aAlignParam.meOrient), 0, bPixelToLogic,
+ nEngineWidth, nEngineHeight, nNeededPixel,
+ aAreaParam.mbLeftClip, aAreaParam.mbRightClip );
+ }
+ if ( bRepeat && !aAreaParam.mbLeftClip && !aAreaParam.mbRightClip && pEngine->GetParagraphCount() == 1 )
+ {
+ // First check if twice the space for the formatted text is available
+ // (otherwise just keep it unchanged).
+
+ long nFormatted = nNeededPixel - nLeftM - nRightM; // without margin
+ long nAvailable = aAreaParam.maAlignRect.GetWidth() - nLeftM - nRightM;
+ if ( nAvailable >= 2 * nFormatted )
+ {
+ // "repeat" is handled with unformatted text (for performance reasons)
+ String aCellStr = pEngine->GetText();
+ pEngine->SetText( aCellStr );
+
+ long nRepeatSize = (long) pEngine->CalcTextWidth();
+ if (bPixelToLogic)
+ nRepeatSize = pRefDevice->LogicToPixel(Size(nRepeatSize,0)).Width();
+ if ( pFmtDevice != pRefDevice )
+ ++nRepeatSize;
+ if ( nRepeatSize > 0 )
+ {
+ long nRepeatCount = nAvailable / nRepeatSize;
+ if ( nRepeatCount > 1 )
+ {
+ String aRepeated = aCellStr;
+ for ( long nRepeat = 1; nRepeat < nRepeatCount; nRepeat++ )
+ aRepeated.Append( aCellStr );
+ pEngine->SetText( aRepeated );
+
+ nEngineHeight = pEngine->GetTextHeight();
+ nEngineWidth = (long) pEngine->CalcTextWidth();
+ if (bPixelToLogic)
+ nNeededPixel = pRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width();
+ else
+ nNeededPixel = nEngineWidth;
+ nNeededPixel += nLeftM + nRightM;
+ }
+ }
+ }
+ }
+
+ if ( aAlignParam.mbCellIsValue && ( aAreaParam.mbLeftClip || aAreaParam.mbRightClip ) )
+ {
+ pEngine->SetText( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("###")) );
+ nEngineWidth = (long) pEngine->CalcTextWidth();
+ if (bPixelToLogic)
+ nNeededPixel = pRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width();
+ else
+ nNeededPixel = nEngineWidth;
+ nNeededPixel += nLeftM + nRightM;
+
+ // No clip marks if "###" doesn't fit (same as in DrawStrings)
+ }
+
+ if ( eOutHorJust != SVX_HOR_JUSTIFY_LEFT && aAlignParam.meOrient == SVX_ORIENTATION_STANDARD )
+ {
+ aPaperSize.Width() = nNeededPixel + 1;
+ if (bPixelToLogic)
+ pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize));
+ else
+ pEngine->SetPaperSize(aPaperSize);
+ }
+ }
+
+ long nStartX = aAreaParam.maAlignRect.Left();
+ long nStartY = aAreaParam.maAlignRect.Top();
+ long nCellWidth = aAreaParam.maAlignRect.GetWidth();
+ long nOutWidth = nCellWidth - 1 - nLeftM - nRightM;
+ long nOutHeight = aAreaParam.maAlignRect.GetHeight() - nTopM - nBottomM;
+
+ if ( aAlignParam.mbBreak || aAlignParam.meOrient != SVX_ORIENTATION_STANDARD || aAlignParam.mbAsianVertical )
+ {
+ // text with automatic breaks is aligned only within the
+ // edit engine's paper size, the output of the whole area
+ // is always left-aligned
+
+ nStartX += nLeftM;
+ if (aAlignParam.meOrient == SVX_ORIENTATION_TOPBOTTOM && aAlignParam.meHorJust == SVX_HOR_JUSTIFY_BLOCK)
+ nStartX += aPaperSize.Height();
+ }
+ else
+ {
+ if ( eOutHorJust == SVX_HOR_JUSTIFY_RIGHT )
+ nStartX -= nNeededPixel - nCellWidth + nRightM + 1;
+ else if ( eOutHorJust == SVX_HOR_JUSTIFY_CENTER )
+ nStartX -= ( nNeededPixel - nCellWidth + nRightM + 1 - nLeftM ) / 2;
+ else
+ nStartX += nLeftM;
+ }
+
+ BOOL bOutside = ( aAreaParam.maClipRect.Right() < nScrX || aAreaParam.maClipRect.Left() >= nScrX + nScrW );
+ if ( aAreaParam.maClipRect.Left() < nScrX )
+ {
+ aAreaParam.maClipRect.Left() = nScrX;
+ aAreaParam.mbLeftClip = true;
+ }
+ if ( aAreaParam.maClipRect.Right() > nScrX + nScrW )
+ {
+ aAreaParam.maClipRect.Right() = nScrX + nScrW; //! minus one?
+ aAreaParam.mbRightClip = true;
+ }
+
+ if ( !bHidden && !bOutside )
+ {
+ bool bClip = aAreaParam.mbLeftClip || aAreaParam.mbRightClip;
+ BOOL bSimClip = FALSE;
+
+ if ( bWrapFields )
+ {
+ // Fields in a cell with automatic breaks: clip to cell width
+ bClip = TRUE;
+ }
+
+ if ( aAreaParam.maClipRect.Top() < nScrY )
+ {
+ aAreaParam.maClipRect.Top() = nScrY;
+ bClip = TRUE;
+ }
+ if ( aAreaParam.maClipRect.Bottom() > nScrY + nScrH )
+ {
+ aAreaParam.maClipRect.Bottom() = nScrY + nScrH; //! minus one?
+ bClip = TRUE;
+ }
+
+ Size aCellSize; // output area, excluding margins, in logical units
+ if (bPixelToLogic)
+ aCellSize = pRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) );
+ else
+ aCellSize = Size( nOutWidth, nOutHeight );
+
+ if ( nEngineHeight >= aCellSize.Height() + aRefOne.Height() )
+ {
+ const ScMergeAttr* pMerge =
+ (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
+ BOOL bMerged = pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1;
+
+ // Don't clip for text height when printing rows with optimal height,
+ // except when font size is from conditional formatting.
+ //! Allow clipping when vertically merged?
+ if ( eType != OUTTYPE_PRINTER ||
+ ( pDoc->GetRowFlags( nCellY, nTab ) & CR_MANUALSIZE ) ||
+ ( pCondSet && SFX_ITEM_SET ==
+ pCondSet->GetItemState(ATTR_FONT_HEIGHT, TRUE) ) )
+ bClip = TRUE;
+ else
+ bSimClip = TRUE;
+
+ // Show clip marks if height is at least 5pt too small and
+ // there are several lines of text.
+ // Not for asian vertical text, because that would interfere
+ // with the default right position of the text.
+ // Only with automatic line breaks, to avoid having to find
+ // the cells with the horizontal end of the text again.
+ if ( nEngineHeight - aCellSize.Height() > 100 &&
+ ( aAlignParam.mbBreak || aAlignParam.meOrient == SVX_ORIENTATION_STACKED ) &&
+ !aAlignParam.mbAsianVertical && bMarkClipped &&
+ ( pEngine->GetParagraphCount() > 1 || pEngine->GetLineCount(0) > 1 ) )
+ {
+ CellInfo* pClipMarkCell = NULL;
+ if ( bMerged )
+ {
+ // anywhere in the merged area...
+ SCCOL nClipX = ( nX < nX1 ) ? nX1 : nX;
+ pClipMarkCell = &pRowInfo[(nArrY != 0) ? nArrY : 1].pCellInfo[nClipX+1];
+ }
+ else
+ pClipMarkCell = &pThisRowInfo->pCellInfo[nX+1];
+
+ pClipMarkCell->nClipMark |= SC_CLIPMARK_RIGHT; //! also allow left?
+ bAnyClipped = TRUE;
+
+ long nMarkPixel = (long)( SC_CLIPMARK_SIZE * nPPTX );
+ if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() )
+ aAreaParam.maClipRect.Right() -= nMarkPixel;
+ }
+ }
+
+ Rectangle aLogicClip;
+ if (bClip || bSimClip)
+ {
+ // Clip marks are already handled in GetOutputArea
+
+ if (bPixelToLogic)
+ aLogicClip = pRefDevice->PixelToLogic( aAreaParam.maClipRect );
+ else
+ aLogicClip = aAreaParam.maClipRect;
+
+ if (bClip) // bei bSimClip nur aClipRect initialisieren
+ {
+ if (bMetaFile)
+ {
+ pDev->Push();
+ pDev->IntersectClipRegion( aLogicClip );
+ }
+ else
+ pDev->SetClipRegion( Region( aLogicClip ) );
+ }
+ }
+
+ Point aLogicStart;
+ if (bPixelToLogic)
+ aLogicStart = pRefDevice->PixelToLogic( Point(nStartX,nStartY) );
+ else
+ aLogicStart = Point(nStartX, nStartY);
+ if ( aAlignParam.meOrient!=SVX_ORIENTATION_STANDARD || aAlignParam.mbAsianVertical || !aAlignParam.mbBreak )
+ {
+ long nAvailWidth = aCellSize.Width();
+ // space for AutoFilter is already handled in GetOutputArea
+
+ // horizontal alignment
+
+ if (aAlignParam.meOrient==SVX_ORIENTATION_STANDARD && !aAlignParam.mbAsianVertical)
+ {
+ if (aAlignParam.adjustHorAlignment(pEngine))
+ // #55142# reset adjustment for the next cell
+ pOldPattern = NULL;
+ }
+ else
+ {
+ if (aAlignParam.meHorJust==SVX_HOR_JUSTIFY_RIGHT)
+ aLogicStart.X() += nAvailWidth - nEngineWidth;
+ else if (aAlignParam.meHorJust==SVX_HOR_JUSTIFY_CENTER)
+ aLogicStart.X() += (nAvailWidth - nEngineWidth) / 2;
+ }
+ }
+
+ if ( aAlignParam.mbAsianVertical )
+ {
+ // paper size is subtracted below
+ aLogicStart.X() += nEngineWidth;
+ }
+
+ if ( (aAlignParam.mbAsianVertical || aAlignParam.isVerticallyOriented()) && aAlignParam.mbBreak )
+ {
+ // vertical adjustment is within the EditEngine
+ if (bPixelToLogic)
+ aLogicStart.Y() += pRefDevice->PixelToLogic(Size(0,nTopM)).Height();
+ else
+ aLogicStart.Y() += nTopM;
+ }
+
+ if (!aAlignParam.mbAsianVertical && !aAlignParam.isVerticallyOriented() &&
+ (aAlignParam.meOrient == SVX_ORIENTATION_STANDARD || aAlignParam.meOrient == SVX_ORIENTATION_STACKED || !aAlignParam.mbBreak))
+ {
+ if (aAlignParam.meVerJust==SVX_VER_JUSTIFY_BOTTOM ||
+ aAlignParam.meVerJust==SVX_VER_JUSTIFY_STANDARD)
+ {
+ //! if pRefDevice != pFmtDevice, keep heights in logic units,
+ //! only converting margin?
+
+ if (bPixelToLogic)
+ aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0, nTopM +
+ pRefDevice->LogicToPixel(aCellSize).Height() -
+ pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height()
+ )).Height();
+ else
+ aLogicStart.Y() += nTopM + aCellSize.Height() - nEngineHeight;
+ }
+ else if (aAlignParam.meVerJust==SVX_VER_JUSTIFY_CENTER)
+ {
+ if (bPixelToLogic)
+ aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0, nTopM + (
+ pRefDevice->LogicToPixel(aCellSize).Height() -
+ pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height() )
+ / 2)).Height();
+ else
+ aLogicStart.Y() += nTopM + (aCellSize.Height() - nEngineHeight) / 2;
+ }
+ else // top
+ {
+ if (bPixelToLogic)
+ aLogicStart.Y() += pRefDevice->PixelToLogic(Size(0,nTopM)).Height();
+ else
+ aLogicStart.Y() += nTopM;
+ }
+ }
+
+ Point aURLStart = aLogicStart; // copy before modifying for orientation
+
+ short nOriVal = 0;
+ if (aAlignParam.meOrient == SVX_ORIENTATION_TOPBOTTOM)
+ {
+ // nOriVal = -900;
+ nOriVal = 2700;
+ if (aAlignParam.meHorJust != SVX_HOR_JUSTIFY_BLOCK)
+ {
+ aLogicStart.X() += nEngineWidth;
+ if (!aAlignParam.mbBreak)
+ {
+ // Set the paper width to text size.
+ Size aPSize = pEngine->GetPaperSize();
+ aPSize.Width() = pEngine->CalcTextWidth();
+ pEngine->SetPaperSize(aPSize);
+
+ long nGap = 0;
+ long nTopOffset = 0; // offset by top margin
+ if (bPixelToLogic)
+ {
+ nGap = pRefDevice->LogicToPixel(aPSize).Width() - pRefDevice->LogicToPixel(aCellSize).Height();
+ nGap = pRefDevice->PixelToLogic(Size(0, nGap)).Height();
+ nTopOffset = pRefDevice->PixelToLogic(Size(0,nTopM)).Height();
+ }
+ else
+ {
+ nGap = aPSize.Width() - aCellSize.Height();
+ nTopOffset = nTopM;
+ }
+ aLogicStart.Y() += nTopOffset;
+
+ switch (aAlignParam.meVerJust)
+ {
+ case SVX_VER_JUSTIFY_STANDARD:
+ case SVX_VER_JUSTIFY_BOTTOM:
+ // align to bottom
+ aLogicStart.Y() -= nGap;
+ break;
+ case SVX_VER_JUSTIFY_CENTER:
+ // center it.
+ aLogicStart.Y() -= nGap / 2;
+ break;
+ case SVX_VER_JUSTIFY_BLOCK:
+ case SVX_VER_JUSTIFY_TOP:
+ // align to top (do nothing)
+ default:
+ ;
+ }
+ }
+ }
+ }
+ else if (aAlignParam.meOrient == SVX_ORIENTATION_BOTTOMTOP)
+ {
+ nOriVal = 900;
+ aLogicStart.Y() +=
+ aAlignParam.mbBreak ? pEngine->GetPaperSize().Width() : nEngineHeight;
+ }
+ else if (aAlignParam.meOrient == SVX_ORIENTATION_STACKED)
+ {
+ Size aPaperLogic = pEngine->GetPaperSize();
+ aPaperLogic.Width() = nEngineWidth;
+ pEngine->SetPaperSize(aPaperLogic);
+ }
+
+ if ( pEngine->IsRightToLeft( 0 ) )
+ {
+ // For right-to-left, EditEngine always calculates its lines
+ // beginning from the right edge, but EditLine::nStartPosX is
+ // of USHORT type, so the PaperSize must be limited to USHRT_MAX.
+ Size aLogicPaper = pEngine->GetPaperSize();
+ if ( aLogicPaper.Width() > USHRT_MAX )
+ {
+ aLogicPaper.Width() = USHRT_MAX;
+ pEngine->SetPaperSize(aLogicPaper);
+ }
+ }
+
+ // bMoveClipped handling has been replaced by complete alignment
+ // handling (also extending to the left).
+
+ if ( bSimClip && !nOriVal && !aAlignParam.mbAsianVertical )
+ {
+ // kein hartes Clipping, aber nur die betroffenen
+ // Zeilen ausgeben
+
+ Point aDocStart = aLogicClip.TopLeft();
+ aDocStart -= aLogicStart;
+ pEngine->Draw( pDev, aLogicClip, aDocStart, FALSE );
+ }
+ else
+ {
+ if (aAlignParam.mbAsianVertical)
+ {
+ // with SetVertical, the start position is top left of
+ // the whole output area, not the text itself
+ aLogicStart.X() -= pEngine->GetPaperSize().Width();
+ }
+ pEngine->Draw( pDev, aLogicStart, nOriVal );
+ }
+
+ if (bClip)
+ {
+ if (bMetaFile)
+ pDev->Pop();
+ else
+ pDev->SetClipRegion();
+ }
+
+ // PDF: whole-cell hyperlink from formula?
+ BOOL bHasURL = pPDFData && pCell && pCell->GetCellType() == CELLTYPE_FORMULA &&
+ static_cast<ScFormulaCell*>(pCell)->IsHyperLinkCell();
+ if ( bHasURL )
+ {
+ long nURLWidth = (long) pEngine->CalcTextWidth();
+ long nURLHeight = pEngine->GetTextHeight();
+ if ( aAlignParam.mbBreak )
+ {
+ Size aPaper = pEngine->GetPaperSize();
+ if ( aAlignParam.mbAsianVertical )
+ nURLHeight = aPaper.Height();
+ else
+ nURLWidth = aPaper.Width();
+ }
+ if ( aAlignParam.isVerticallyOriented() )
+ std::swap( nURLWidth, nURLHeight );
+ else if ( aAlignParam.mbAsianVertical )
+ aURLStart.X() -= nURLWidth;
+
+ Rectangle aURLRect( aURLStart, Size( nURLWidth, nURLHeight ) );
+ lcl_DoHyperlinkResult( pDev, aURLRect, pCell );
+ }
+ }
+ }
+ }
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ }
+ nRowPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ delete pEngine;
+
+ if (bAnyRotated)
+ DrawRotated(bPixelToLogic); //! von aussen rufen ?
+}
+
+// -------------------------------------------------------------------------------
+
+void ScOutputData::DrawRotated(BOOL bPixelToLogic)
+{
+ //! nRotMax speichern
+ SCCOL nRotMax = nX2;
+ for (SCSIZE nRotY=0; nRotY<nArrCount; nRotY++)
+ if (pRowInfo[nRotY].nRotMaxCol != SC_ROTMAX_NONE && pRowInfo[nRotY].nRotMaxCol > nRotMax)
+ nRotMax = pRowInfo[nRotY].nRotMaxCol;
+
+
+ ScModule* pScMod = SC_MOD();
+ sal_Int32 nConfBackColor = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor;
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor &&
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ ScFieldEditEngine* pEngine = NULL;
+ BOOL bHyphenatorSet = FALSE;
+ const ScPatternAttr* pPattern;
+ const SfxItemSet* pCondSet;
+ const ScPatternAttr* pOldPattern = NULL;
+ const SfxItemSet* pOldCondSet = NULL;
+ ScBaseCell* pCell = NULL;
+
+ long nInitPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ nInitPosX += nMirrorW - 1;
+ }
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ long nRowPosY = nScrY;
+ for (SCSIZE nArrY=0; nArrY+1<nArrCount; nArrY++) // 0 fuer Reste von zusammengefassten
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+ long nCellHeight = (long) pThisRowInfo->nHeight;
+ if (nArrY==1) nRowPosY = nScrY; // vorher wird einzeln berechnet
+
+ if ( ( pThisRowInfo->bChanged || nArrY==0 ) && pThisRowInfo->nRotMaxCol != SC_ROTMAX_NONE )
+ {
+ long nPosX = 0;
+ for (SCCOL nX=0; nX<=nRotMax; nX++)
+ {
+ if (nX==nX1) nPosX = nInitPosX; // positions before nX1 are calculated individually
+
+ CellInfo* pInfo = &pThisRowInfo->pCellInfo[nX+1];
+ if ( pInfo->nRotateDir != SC_ROTDIR_NONE )
+ {
+ SCROW nY = pThisRowInfo->nRowNo;
+
+ BOOL bHidden = FALSE;
+ if (bEditMode)
+ if ( nX == nEditCol && nY == nEditRow )
+ bHidden = TRUE;
+
+ if (!bHidden)
+ {
+ if (!pEngine)
+ {
+ // Ein RefDevice muss auf jeden Fall gesetzt werden,
+ // sonst legt sich die EditEngine ein VirtualDevice an!
+ pEngine = new ScFieldEditEngine( pDoc->GetEnginePool() );
+ pEngine->SetUpdateMode( FALSE );
+ pEngine->SetRefDevice( pFmtDevice ); // always set
+ ULONG nCtrl = pEngine->GetControlWord();
+ if ( bShowSpellErrors )
+ nCtrl |= EE_CNTRL_ONLINESPELLING;
+ if ( eType == OUTTYPE_PRINTER )
+ nCtrl &= ~EE_CNTRL_MARKFIELDS;
+ pEngine->SetControlWord( nCtrl );
+ pEngine->SetForbiddenCharsTable( pDoc->GetForbiddenCharacters() );
+ pEngine->SetAsianCompressionMode( pDoc->GetAsianCompression() );
+ pEngine->SetKernAsianPunctuation( pDoc->GetAsianKerning() );
+ pEngine->EnableAutoColor( bUseStyleColor );
+ pEngine->SetDefaultHorizontalTextDirection(
+ (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
+ }
+ else
+ lcl_ClearEdit( *pEngine ); // also calls SetUpdateMode(FALSE)
+
+ long nPosY = nRowPosY;
+ BOOL bVisChanged = FALSE;
+
+ //! Rest von zusammengefasster Zelle weiter oben funktioniert nicht!
+
+ BOOL bFromDoc = FALSE;
+ pPattern = pInfo->pPatternAttr;
+ pCondSet = pInfo->pConditionSet;
+ if (!pPattern)
+ {
+ pPattern = pDoc->GetPattern( nX, nY, nTab );
+ bFromDoc = TRUE;
+ }
+ pCell = pInfo->pCell;
+ if (bFromDoc)
+ pCondSet = pDoc->GetCondResult( nX, nY, nTab );
+
+ if (!pCell && nX>nX2)
+ GetVisibleCell( nX, nY, nTab, pCell );
+
+ if ( !pCell || IsEmptyCellText( pThisRowInfo, nX, nY ) )
+ bHidden = TRUE; // nRotateDir is also set without a cell
+
+ long nCellWidth = (long) pRowInfo[0].pCellInfo[nX+1].nWidth;
+
+ SvxCellHorJustify eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
+ pPattern->GetItem(ATTR_HOR_JUSTIFY, pCondSet)).GetValue();
+ BOOL bBreak = ( eHorJust == SVX_HOR_JUSTIFY_BLOCK ) ||
+ ((const SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK, pCondSet)).GetValue();
+ BOOL bRepeat = ( eHorJust == SVX_HOR_JUSTIFY_REPEAT && !bBreak );
+ BOOL bShrink = !bBreak && !bRepeat && static_cast<const SfxBoolItem&>
+ (pPattern->GetItem( ATTR_SHRINKTOFIT, pCondSet )).GetValue();
+ SvxCellOrientation eOrient = pPattern->GetCellOrientation( pCondSet );
+
+ const ScMergeAttr* pMerge =
+ (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
+ BOOL bMerged = pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1;
+
+ long nStartX = nPosX;
+ long nStartY = nPosY;
+ if (nX<nX1)
+ {
+ if ((bBreak || eOrient!=SVX_ORIENTATION_STANDARD) && !bMerged)
+ bHidden = TRUE;
+ else
+ {
+ nStartX = nInitPosX;
+ SCCOL nCol = nX1;
+ while (nCol > nX)
+ {
+ --nCol;
+ nStartX -= nLayoutSign * (long) pRowInfo[0].pCellInfo[nCol+1].nWidth;
+ }
+ }
+ }
+ long nCellStartX = nStartX;
+
+ // Ersatzdarstellung fuer zu kleinen Text weggelassen
+
+ if (!bHidden)
+ {
+ long nOutWidth = nCellWidth - 1;
+ long nOutHeight;
+ if (pInfo)
+ nOutHeight = nCellHeight;
+ else
+ nOutHeight = (long) ( pDoc->GetRowHeight(nY,nTab) * nPPTY );
+
+ if ( bMerged ) // Zusammengefasst
+ {
+ SCCOL nCountX = pMerge->GetColMerge();
+ for (SCCOL i=1; i<nCountX; i++)
+ nOutWidth += (long) ( pDoc->GetColWidth(nX+i,nTab) * nPPTX );
+ SCROW nCountY = pMerge->GetRowMerge();
+ nOutHeight += (long) pDoc->GetScaledRowHeight( nY+1, nY+nCountY-1, nTab, nPPTY);
+ }
+
+ SvxCellVerJustify eVerJust = (SvxCellVerJustify)((const SvxVerJustifyItem&)
+ pPattern->GetItem(ATTR_VER_JUSTIFY, pCondSet)).GetValue();
+
+ // Syntax-Modus wird hier ignoriert...
+
+ // StringDiffer doesn't look at hyphenate, language items
+ if ( pPattern != pOldPattern || pCondSet != pOldCondSet )
+ {
+ SfxItemSet* pSet = new SfxItemSet( pEngine->GetEmptyItemSet() );
+ pPattern->FillEditItemSet( pSet, pCondSet );
+
+ // Ausrichtung fuer EditEngine
+ SvxAdjust eSvxAdjust = SVX_ADJUST_LEFT;
+ if (eOrient==SVX_ORIENTATION_STACKED)
+ eSvxAdjust = SVX_ADJUST_CENTER;
+ // Adjustment fuer bBreak ist hier weggelassen
+ pSet->Put( SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
+
+ pEngine->SetDefaults( pSet );
+ pOldPattern = pPattern;
+ pOldCondSet = pCondSet;
+
+ ULONG nControl = pEngine->GetControlWord();
+ if (eOrient==SVX_ORIENTATION_STACKED)
+ nControl |= EE_CNTRL_ONECHARPERLINE;
+ else
+ nControl &= ~EE_CNTRL_ONECHARPERLINE;
+ pEngine->SetControlWord( nControl );
+
+ if ( !bHyphenatorSet && ((const SfxBoolItem&)pSet->Get(EE_PARA_HYPHENATE)).GetValue() )
+ {
+ // set hyphenator the first time it is needed
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xXHyphenator( LinguMgr::GetHyphenator() );
+ pEngine->SetHyphenator( xXHyphenator );
+ bHyphenatorSet = TRUE;
+ }
+
+ Color aBackCol = ((const SvxBrushItem&)
+ pPattern->GetItem( ATTR_BACKGROUND, pCondSet )).GetColor();
+ if ( bUseStyleColor && ( aBackCol.GetTransparency() > 0 || bCellContrast ) )
+ aBackCol.SetColor( nConfBackColor );
+ pEngine->SetBackgroundColor( aBackCol );
+ }
+
+ // Raender
+
+ //! Position und Papersize auf EditUtil umstellen !!!
+
+ const SvxMarginItem* pMargin = (const SvxMarginItem*)
+ &pPattern->GetItem(ATTR_MARGIN, pCondSet);
+ USHORT nIndent = 0;
+ if ( eHorJust == SVX_HOR_JUSTIFY_LEFT )
+ nIndent = ((const SfxUInt16Item&)pPattern->
+ GetItem(ATTR_INDENT, pCondSet)).GetValue();
+
+ long nTotalHeight = nOutHeight; // ohne Rand abzuziehen
+ if ( bPixelToLogic )
+ nTotalHeight = pRefDevice->PixelToLogic(Size(0,nTotalHeight)).Height();
+
+ long nLeftM = (long) ( (pMargin->GetLeftMargin() + nIndent) * nPPTX );
+ long nTopM = (long) ( pMargin->GetTopMargin() * nPPTY );
+ long nRightM = (long) ( pMargin->GetRightMargin() * nPPTX );
+ long nBottomM = (long) ( pMargin->GetBottomMargin() * nPPTY );
+ nStartX += nLeftM;
+ nStartY += nTopM;
+ nOutWidth -= nLeftM + nRightM;
+ nOutHeight -= nTopM + nBottomM;
+
+ // Rotation schon hier, um bei Umbruch auch PaperSize anzupassen
+ long nAttrRotate = 0;
+ double nSin = 0.0;
+ double nCos = 1.0;
+ SvxRotateMode eRotMode = SVX_ROTATE_MODE_STANDARD;
+ if ( eOrient == SVX_ORIENTATION_STANDARD )
+ {
+ nAttrRotate = ((const SfxInt32Item&)pPattern->
+ GetItem(ATTR_ROTATE_VALUE, pCondSet)).GetValue();
+ if ( nAttrRotate )
+ {
+ eRotMode = (SvxRotateMode)((const SvxRotateModeItem&)
+ pPattern->GetItem(ATTR_ROTATE_MODE, pCondSet)).GetValue();
+
+ if ( nAttrRotate == 18000 )
+ eRotMode = SVX_ROTATE_MODE_STANDARD; // keinen Ueberlauf
+
+ if ( bLayoutRTL )
+ nAttrRotate = -nAttrRotate;
+
+ double nRealOrient = nAttrRotate * F_PI18000; // 1/100 Grad
+ nCos = cos( nRealOrient );
+ nSin = sin( nRealOrient );
+ }
+ }
+
+ Size aPaperSize = Size( 1000000, 1000000 );
+ if (eOrient==SVX_ORIENTATION_STACKED)
+ aPaperSize.Width() = nOutWidth; // zum Zentrieren
+ else if (bBreak)
+ {
+ if (nAttrRotate)
+ {
+ //! richtige PaperSize fuer Umbruch haengt von der Zeilenzahl
+ //! ab, solange die Zeilen nicht einzeln versetzt ausgegeben
+ //! werden koennen -> darum unbegrenzt, also kein Umbruch.
+ //! Mit versetzten Zeilen waere das folgende richtig:
+ aPaperSize.Width() = (long)(nOutHeight / fabs(nSin));
+ }
+ else if (eOrient == SVX_ORIENTATION_STANDARD)
+ aPaperSize.Width() = nOutWidth;
+ else
+ aPaperSize.Width() = nOutHeight - 1;
+ }
+ if (bPixelToLogic)
+ pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize));
+ else
+ pEngine->SetPaperSize(aPaperSize); // Scale ist immer 1
+
+ // Daten aus Zelle lesen
+
+ if (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ const EditTextObject* pData;
+ ((ScEditCell*)pCell)->GetData(pData);
+
+ if (pData)
+ pEngine->SetText(*pData);
+ else
+ {
+ DBG_ERROR("pData == 0");
+ }
+ }
+ else
+ {
+ ULONG nFormat = pPattern->GetNumberFormat(
+ pDoc->GetFormatTable(), pCondSet );
+ String aString;
+ Color* pColor;
+ ScCellFormat::GetString( pCell,
+ nFormat,aString, &pColor,
+ *pDoc->GetFormatTable(),
+ bShowNullValues,
+ bShowFormulas,
+ ftCheck );
+
+ pEngine->SetText(aString);
+ if ( pColor && !bSyntaxMode && !( bUseStyleColor && bForceAutoColor ) )
+ lcl_SetEditColor( *pEngine, *pColor );
+ }
+
+ if ( bSyntaxMode )
+ SetEditSyntaxColor( *pEngine, pCell );
+ else if ( bUseStyleColor && bForceAutoColor )
+ lcl_SetEditColor( *pEngine, COL_AUTO ); //! or have a flag at EditEngine
+ }
+ else
+ {
+ DBG_ERROR("pCell == NULL");
+ }
+
+ pEngine->SetUpdateMode( TRUE ); // after SetText, before CalcTextWidth/GetTextHeight
+
+ long nEngineWidth = (long) pEngine->CalcTextWidth();
+ long nEngineHeight = pEngine->GetTextHeight();
+
+ if (nAttrRotate && bBreak)
+ {
+ double nAbsCos = fabs( nCos );
+ double nAbsSin = fabs( nSin );
+
+ // #47740# adjust witdh of papersize for height of text
+ int nSteps = 5;
+ while (nSteps > 0)
+ {
+ // everything is in pixels
+ long nEnginePixel = pRefDevice->LogicToPixel(
+ Size(0,nEngineHeight)).Height();
+ long nEffHeight = nOutHeight - (long)(nEnginePixel * nAbsCos) + 2;
+ long nNewWidth = (long)(nEffHeight / nAbsSin) + 2;
+ BOOL bFits = ( nNewWidth >= aPaperSize.Width() );
+ if ( bFits )
+ nSteps = 0;
+ else
+ {
+ if ( nNewWidth < 4 )
+ {
+ // can't fit -> fall back to using half height
+ nEffHeight = nOutHeight / 2;
+ nNewWidth = (long)(nEffHeight / nAbsSin) + 2;
+ nSteps = 0;
+ }
+ else
+ --nSteps;
+
+ // set paper width and get new text height
+ aPaperSize.Width() = nNewWidth;
+ if (bPixelToLogic)
+ pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize));
+ else
+ pEngine->SetPaperSize(aPaperSize); // Scale ist immer 1
+ //pEngine->QuickFormatDoc( TRUE );
+ nEngineWidth = (long) pEngine->CalcTextWidth();
+ nEngineHeight = pEngine->GetTextHeight();
+ }
+ }
+ }
+
+ long nRealWidth = nEngineWidth;
+ long nRealHeight = nEngineHeight;
+
+ // wenn gedreht, Groesse anpassen
+ if (nAttrRotate)
+ {
+ double nAbsCos = fabs( nCos );
+ double nAbsSin = fabs( nSin );
+
+ if ( eRotMode == SVX_ROTATE_MODE_STANDARD )
+ nEngineWidth = (long) ( nRealWidth * nAbsCos +
+ nRealHeight * nAbsSin );
+ else
+ nEngineWidth = (long) ( nRealHeight / nAbsSin );
+ //! begrenzen !!!
+
+ nEngineHeight = (long) ( nRealHeight * nAbsCos +
+ nRealWidth * nAbsSin );
+ }
+
+ if (!nAttrRotate) // hier nur gedrehter Text
+ bHidden = TRUE; //! vorher abfragen !!!
+
+ //! weglassen, was nicht hereinragt
+
+ if (!bHidden)
+ {
+ BOOL bClip = FALSE;
+ Size aClipSize = Size( nScrX+nScrW-nStartX, nScrY+nScrH-nStartY );
+
+ // weiterschreiben
+
+ Size aCellSize;
+ if (bPixelToLogic)
+ aCellSize = pRefDevice->PixelToLogic( Size( nOutWidth, nOutHeight ) );
+ else
+ aCellSize = Size( nOutWidth, nOutHeight ); // Scale ist 1
+
+ long nGridWidth = nEngineWidth;
+ BOOL bNegative = FALSE;
+ if ( eRotMode != SVX_ROTATE_MODE_STANDARD )
+ {
+ nGridWidth = aCellSize.Width() +
+ Abs((long) ( aCellSize.Height() * nCos / nSin ));
+ bNegative = ( pInfo->nRotateDir == SC_ROTDIR_LEFT );
+ if ( bLayoutRTL )
+ bNegative = !bNegative;
+ }
+
+ // use GetOutputArea to hide the grid
+ // (clip region is done manually below)
+ OutputAreaParam aAreaParam;
+
+ SCCOL nCellX = nX;
+ SCROW nCellY = nY;
+ SvxCellHorJustify eOutHorJust = eHorJust;
+ if ( eRotMode != SVX_ROTATE_MODE_STANDARD )
+ eOutHorJust = bNegative ? SVX_HOR_JUSTIFY_RIGHT : SVX_HOR_JUSTIFY_LEFT;
+ long nNeededWidth = nGridWidth; // in pixel for GetOutputArea
+ if ( bPixelToLogic )
+ nNeededWidth = pRefDevice->LogicToPixel(Size(nNeededWidth,0)).Width();
+
+ GetOutputArea( nX, nArrY, nCellStartX, nPosY, nCellX, nCellY, nNeededWidth,
+ *pPattern, sal::static_int_cast<USHORT>(eOutHorJust),
+ FALSE, FALSE, TRUE, aAreaParam );
+
+ if ( bShrink )
+ {
+ long nPixelWidth = bPixelToLogic ?
+ pRefDevice->LogicToPixel(Size(nEngineWidth,0)).Width() : nEngineWidth;
+ long nNeededPixel = nPixelWidth + nLeftM + nRightM;
+
+ aAreaParam.mbLeftClip = aAreaParam.mbRightClip = TRUE;
+
+ // always do height
+ ShrinkEditEngine( *pEngine, aAreaParam.maAlignRect, nLeftM, nTopM, nRightM, nBottomM,
+ FALSE, sal::static_int_cast<USHORT>(eOrient), nAttrRotate, bPixelToLogic,
+ nEngineWidth, nEngineHeight, nNeededPixel, aAreaParam.mbLeftClip, aAreaParam.mbRightClip );
+
+ if ( eRotMode == SVX_ROTATE_MODE_STANDARD )
+ {
+ // do width only if rotating within the cell (standard mode)
+ ShrinkEditEngine( *pEngine, aAreaParam.maAlignRect, nLeftM, nTopM, nRightM, nBottomM,
+ TRUE, sal::static_int_cast<USHORT>(eOrient), nAttrRotate, bPixelToLogic,
+ nEngineWidth, nEngineHeight, nNeededPixel, aAreaParam.mbLeftClip, aAreaParam.mbRightClip );
+ }
+
+ // nEngineWidth/nEngineHeight is updated in ShrinkEditEngine
+ // (but width is only valid for standard mode)
+ nRealWidth = (long) pEngine->CalcTextWidth();
+ nRealHeight = pEngine->GetTextHeight();
+
+ if ( eRotMode != SVX_ROTATE_MODE_STANDARD )
+ nEngineWidth = (long) ( nRealHeight / fabs( nSin ) );
+ }
+
+ // BOOL bVClip = ( nEngineHeight > aCellSize.Height() );
+
+ long nClipStartX = nStartX;
+ if (nX<nX1)
+ {
+ //! Clipping unnoetig, wenn links am Fenster
+
+ bClip = TRUE; // nur Rest ausgeben!
+ if (nStartX<nScrX)
+ {
+ long nDif = nScrX - nStartX;
+ nClipStartX = nScrX;
+ aClipSize.Width() -= nDif;
+ }
+ }
+
+ long nClipStartY = nStartY;
+ if (nArrY==0 || bVisChanged)
+ {
+ if ( nClipStartY < nRowPosY )
+ {
+ long nDif = nRowPosY - nClipStartY;
+ bClip = TRUE;
+ nClipStartY = nRowPosY;
+ aClipSize.Height() -= nDif;
+ }
+ }
+
+ bClip = TRUE; // always clip at the window/page border
+
+ //Rectangle aClipRect;
+ if (bClip)
+ {
+ if ( nAttrRotate /* && eRotMode != SVX_ROTATE_MODE_STANDARD */ )
+ {
+ // gedrehten, ausgerichteten Text nur an den
+ // Seitengrenzen clippen
+ nClipStartX = nScrX;
+ aClipSize.Width() = nScrW;
+ }
+
+ if (bPixelToLogic)
+ aAreaParam.maClipRect = pRefDevice->PixelToLogic( Rectangle(
+ Point(nClipStartX,nClipStartY), aClipSize ) );
+ else
+ aAreaParam.maClipRect = Rectangle(Point(nClipStartX, nClipStartY),
+ aClipSize ); // Scale = 1
+
+ if (bMetaFile)
+ {
+ pDev->Push();
+ pDev->IntersectClipRegion( aAreaParam.maClipRect );
+ }
+ else
+ pDev->SetClipRegion( Region( aAreaParam.maClipRect ) );
+ }
+
+ Point aLogicStart;
+ if (bPixelToLogic)
+ aLogicStart = pRefDevice->PixelToLogic( Point(nStartX,nStartY) );
+ else
+ aLogicStart = Point(nStartX, nStartY);
+ if ( eOrient!=SVX_ORIENTATION_STANDARD || !bBreak )
+ {
+ long nAvailWidth = aCellSize.Width();
+ if (eType==OUTTYPE_WINDOW &&
+ eOrient!=SVX_ORIENTATION_STACKED &&
+ pInfo && pInfo->bAutoFilter)
+ {
+ // filter drop-down width is now independent from row height
+ if (bPixelToLogic)
+ nAvailWidth -= pRefDevice->PixelToLogic(Size(0,DROPDOWN_BITMAP_SIZE)).Height();
+ else
+ nAvailWidth -= DROPDOWN_BITMAP_SIZE;
+ long nComp = nEngineWidth;
+ if (nAvailWidth<nComp) nAvailWidth=nComp;
+ }
+
+ // horizontale Ausrichtung
+
+ if (eOrient==SVX_ORIENTATION_STANDARD && !nAttrRotate)
+ {
+ if (eHorJust==SVX_HOR_JUSTIFY_RIGHT ||
+ eHorJust==SVX_HOR_JUSTIFY_CENTER)
+ {
+ pEngine->SetUpdateMode( FALSE );
+
+ SvxAdjust eSvxAdjust =
+ (eHorJust==SVX_HOR_JUSTIFY_RIGHT) ?
+ SVX_ADJUST_RIGHT : SVX_ADJUST_CENTER;
+ pEngine->SetDefaultItem(
+ SvxAdjustItem( eSvxAdjust, EE_PARA_JUST ) );
+
+ aPaperSize.Width() = nOutWidth;
+ if (bPixelToLogic)
+ pEngine->SetPaperSize(pRefDevice->PixelToLogic(aPaperSize));
+ else
+ pEngine->SetPaperSize(aPaperSize);
+
+ pEngine->SetUpdateMode( TRUE );
+ }
+ }
+ else
+ {
+ // bei gedrehtem Text ist Standard zentriert
+ if (eHorJust==SVX_HOR_JUSTIFY_RIGHT)
+ aLogicStart.X() += nAvailWidth - nEngineWidth;
+ else if (eHorJust==SVX_HOR_JUSTIFY_CENTER ||
+ eHorJust==SVX_HOR_JUSTIFY_STANDARD)
+ aLogicStart.X() += (nAvailWidth - nEngineWidth) / 2;
+ }
+ }
+
+ if ( bLayoutRTL )
+ {
+ if (bPixelToLogic)
+ aLogicStart.X() -= pRefDevice->PixelToLogic(
+ Size( nCellWidth, 0 ) ).Width();
+ else
+ aLogicStart.X() -= nCellWidth;
+ }
+
+ if ( eOrient==SVX_ORIENTATION_STANDARD ||
+ eOrient==SVX_ORIENTATION_STACKED || !bBreak )
+ {
+ if (eVerJust==SVX_VER_JUSTIFY_BOTTOM ||
+ eVerJust==SVX_VER_JUSTIFY_STANDARD)
+ {
+ if (bPixelToLogic)
+ aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0,
+ pRefDevice->LogicToPixel(aCellSize).Height() -
+ pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height()
+ )).Height();
+ else
+ aLogicStart.Y() += aCellSize.Height() - nEngineHeight;
+ }
+
+ else if (eVerJust==SVX_VER_JUSTIFY_CENTER)
+ {
+ if (bPixelToLogic)
+ aLogicStart.Y() += pRefDevice->PixelToLogic( Size(0,(
+ pRefDevice->LogicToPixel(aCellSize).Height() -
+ pRefDevice->LogicToPixel(Size(0,nEngineHeight)).Height())
+ / 2)).Height();
+ else
+ aLogicStart.Y() += (aCellSize.Height() - nEngineHeight) / 2;
+ }
+ }
+
+ // TOPBOTTON and BOTTOMTOP are handled in DrawStrings/DrawEdit
+ DBG_ASSERT( eOrient == SVX_ORIENTATION_STANDARD && nAttrRotate,
+ "DrawRotated: no rotation" );
+
+ long nOriVal = 0;
+ if ( nAttrRotate )
+ {
+ // Attribut ist 1/100, Font 1/10 Grad
+ nOriVal = nAttrRotate / 10;
+
+ double nAddX = 0.0;
+ double nAddY = 0.0;
+ if ( nCos > 0.0 && eRotMode != SVX_ROTATE_MODE_STANDARD )
+ {
+ //! begrenzen !!!
+ double nH = nRealHeight * nCos;
+ nAddX += nH * ( nCos / fabs(nSin) );
+ }
+ if ( nCos < 0.0 && eRotMode == SVX_ROTATE_MODE_STANDARD )
+ nAddX -= nRealWidth * nCos;
+ if ( nSin < 0.0 )
+ nAddX -= nRealHeight * nSin;
+ if ( nSin > 0.0 )
+ nAddY += nRealWidth * nSin;
+ if ( nCos < 0.0 )
+ nAddY -= nRealHeight * nCos;
+
+ if ( eRotMode != SVX_ROTATE_MODE_STANDARD )
+ {
+ //! begrenzen !!!
+ double nSkew = nTotalHeight * nCos / fabs(nSin);
+ if ( eRotMode == SVX_ROTATE_MODE_CENTER )
+ nAddX -= nSkew * 0.5;
+ if ( ( eRotMode == SVX_ROTATE_MODE_TOP && nSin > 0.0 ) ||
+ ( eRotMode == SVX_ROTATE_MODE_BOTTOM && nSin < 0.0 ) )
+ nAddX -= nSkew;
+
+ long nUp = 0;
+ if ( eVerJust == SVX_VER_JUSTIFY_CENTER )
+ nUp = ( aCellSize.Height() - nEngineHeight ) / 2;
+ else if ( eVerJust == SVX_VER_JUSTIFY_TOP )
+ {
+ if ( nSin > 0.0 )
+ nUp = aCellSize.Height() - nEngineHeight;
+ }
+ else // BOTTOM / STANDARD
+ {
+ if ( nSin < 0.0 )
+ nUp = aCellSize.Height() - nEngineHeight;
+ }
+ if ( nUp )
+ nAddX += ( nUp * nCos / fabs(nSin) );
+ }
+
+ aLogicStart.X() += (long) nAddX;
+ aLogicStart.Y() += (long) nAddY;
+ }
+
+ // bSimClip is not used here (because nOriVal is set)
+
+ if ( pEngine->IsRightToLeft( 0 ) )
+ {
+ // For right-to-left, EditEngine always calculates its lines
+ // beginning from the right edge, but EditLine::nStartPosX is
+ // of USHORT type, so the PaperSize must be limited to USHRT_MAX.
+ Size aLogicPaper = pEngine->GetPaperSize();
+ if ( aLogicPaper.Width() > USHRT_MAX )
+ {
+ aLogicPaper.Width() = USHRT_MAX;
+ pEngine->SetPaperSize(aLogicPaper);
+ }
+ }
+
+ pEngine->Draw( pDev, aLogicStart, (short)nOriVal );
+
+ if (bClip)
+ {
+ if (bMetaFile)
+ pDev->Pop();
+ else
+ pDev->SetClipRegion();
+ }
+ }
+ }
+ }
+ }
+ nPosX += pRowInfo[0].pCellInfo[nX+1].nWidth * nLayoutSign;
+ }
+ }
+ nRowPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ delete pEngine;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/output3.cxx b/sc/source/ui/view/output3.cxx
new file mode 100644
index 000000000000..2ec9395c2e5f
--- /dev/null
+++ b/sc/source/ui/view/output3.cxx
@@ -0,0 +1,278 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <editeng/eeitem.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdview.hxx>
+#include <vcl/svapp.hxx>
+
+#include "output.hxx"
+#include "drwlayer.hxx"
+#include "document.hxx"
+#include "tabvwsh.hxx"
+#include "fillinfo.hxx"
+
+#include <svx/fmview.hxx>
+
+// STATIC DATA -----------------------------------------------------------
+
+SdrObject* pSkipPaintObj = NULL;
+
+//==================================================================
+
+// #i72502#
+Point ScOutputData::PrePrintDrawingLayer(long nLogStX, long nLogStY )
+{
+ Rectangle aRect;
+ SCCOL nCol;
+ Point aOffset;
+ long nLayoutSign(bLayoutRTL ? -1 : 1);
+
+ for (nCol=0; nCol<nX1; nCol++)
+ aOffset.X() -= pDoc->GetColWidth( nCol, nTab ) * nLayoutSign;
+ aOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nTab );
+
+ long nDataWidth = 0;
+ long nDataHeight = 0;
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ nDataWidth += pDoc->GetColWidth( nCol, nTab );
+ nDataHeight += pDoc->GetRowHeight( nY1, nY2, nTab );
+
+ if ( bLayoutRTL )
+ aOffset.X() += nDataWidth;
+
+ aRect.Left() = aRect.Right() = -aOffset.X();
+ aRect.Top() = aRect.Bottom() = -aOffset.Y();
+
+ Point aMMOffset( aOffset );
+ aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
+ aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
+
+ if (!bMetaFile)
+ aMMOffset += Point( nLogStX, nLogStY );
+
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ aRect.Right() += pDoc->GetColWidth( nCol, nTab );
+ aRect.Bottom() += pDoc->GetRowHeight( nY1, nY2, nTab );
+
+ aRect.Left() = (long) (aRect.Left() * HMM_PER_TWIPS);
+ aRect.Top() = (long) (aRect.Top() * HMM_PER_TWIPS);
+ aRect.Right() = (long) (aRect.Right() * HMM_PER_TWIPS);
+ aRect.Bottom() = (long) (aRect.Bottom() * HMM_PER_TWIPS);
+
+ if(pViewShell || pDrawView)
+ {
+ SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
+
+ if(pLocalDrawView)
+ {
+ // #i76114# MapMode has to be set because BeginDrawLayers uses GetPaintRegion
+ MapMode aOldMode = pDev->GetMapMode();
+ if (!bMetaFile)
+ pDev->SetMapMode( MapMode( MAP_100TH_MM, aMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
+
+ // #i74769# work with SdrPaintWindow directly
+ // #i76114# pass bDisableIntersect = true, because the intersection of the table area
+ // with the Window's paint region can be empty
+ Region aRectRegion(aRect);
+ mpTargetPaintWindow = pLocalDrawView->BeginDrawLayers(pDev, aRectRegion, true);
+ OSL_ENSURE(mpTargetPaintWindow, "BeginDrawLayers: Got no SdrPaintWindow (!)");
+
+ if (!bMetaFile)
+ pDev->SetMapMode( aOldMode );
+ }
+ }
+
+ return aMMOffset;
+}
+
+// #i72502#
+void ScOutputData::PostPrintDrawingLayer(const Point& rMMOffset) // #i74768#
+{
+ // #i74768# just use offset as in PrintDrawingLayer() to also get the form controls
+ // painted with offset
+ MapMode aOldMode = pDev->GetMapMode();
+
+ if (!bMetaFile)
+ {
+ pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
+ }
+
+ if(pViewShell || pDrawView)
+ {
+ SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
+
+ if(pLocalDrawView)
+ {
+ // #i74769# work with SdrPaintWindow directly
+ pLocalDrawView->EndDrawLayers(*mpTargetPaintWindow, true);
+ mpTargetPaintWindow = 0;
+ }
+ }
+
+ // #i74768#
+ if (!bMetaFile)
+ {
+ pDev->SetMapMode( aOldMode );
+ }
+}
+
+// #i72502#
+void ScOutputData::PrintDrawingLayer(const sal_uInt16 nLayer, const Point& rMMOffset)
+{
+ bool bHideAllDrawingLayer(false);
+
+ if(pViewShell || pDrawView)
+ {
+ SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
+
+ if(pLocalDrawView)
+ {
+ bHideAllDrawingLayer = pLocalDrawView->getHideOle() && pLocalDrawView->getHideChart()
+ && pLocalDrawView->getHideDraw() && pLocalDrawView->getHideFormControl();
+ }
+ }
+
+ // #109985#
+ if(bHideAllDrawingLayer || (!pDoc->GetDrawLayer()))
+ {
+ return;
+ }
+
+ MapMode aOldMode = pDev->GetMapMode();
+
+ if (!bMetaFile)
+ {
+ pDev->SetMapMode( MapMode( MAP_100TH_MM, rMMOffset, aOldMode.GetScaleX(), aOldMode.GetScaleY() ) );
+ }
+
+ // #109985#
+ DrawSelectiveObjects( nLayer );
+
+ if (!bMetaFile)
+ {
+ pDev->SetMapMode( aOldMode );
+ }
+}
+
+// #109985#
+void ScOutputData::DrawSelectiveObjects(const sal_uInt16 nLayer)
+{
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ if (!pModel)
+ return;
+
+ // #i46362# high contrast mode (and default text direction) must be handled
+ // by the application, so it's still needed when using DrawLayer().
+
+ SdrOutliner& rOutl = pModel->GetDrawOutliner();
+ rOutl.EnableAutoColor( bUseStyleColor );
+ rOutl.SetDefaultHorizontalTextDirection(
+ (EEHorizontalTextDirection)pDoc->GetEditTextDirection( nTab ) );
+
+ // #i69767# The hyphenator must be set (used to be before drawing a text shape with hyphenation).
+ // LinguMgr::GetHyphenator (EditEngine) uses a wrapper now that creates the real hyphenator on demand,
+ // so it's not a performance problem to call UseHyphenator even when it's not needed.
+
+ pModel->UseHyphenator();
+
+ ULONG nOldDrawMode = pDev->GetDrawMode();
+ if ( bUseStyleColor && Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ pDev->SetDrawMode( nOldDrawMode | DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL |
+ DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
+ }
+
+ // #109985#
+ if(pViewShell || pDrawView)
+ {
+ SdrView* pLocalDrawView = (pDrawView) ? pDrawView : pViewShell->GetSdrView();
+
+ if(pLocalDrawView)
+ {
+ SdrPageView* pPageView = pLocalDrawView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ pPageView->DrawLayer(sal::static_int_cast<SdrLayerID>(nLayer), pDev);
+ }
+ }
+ }
+
+ pDev->SetDrawMode(nOldDrawMode);
+
+ // #109985#
+ return;
+}
+
+// Teile nur fuer Bildschirm
+
+// #109985#
+void ScOutputData::DrawingSingle(const sal_uInt16 nLayer)
+{
+ BOOL bHad = FALSE;
+ long nPosY = nScrY;
+ SCSIZE nArrY;
+ for (nArrY=1; nArrY+1<nArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &pRowInfo[nArrY];
+
+ if ( pThisRowInfo->bChanged )
+ {
+ if (!bHad)
+ {
+ bHad = TRUE;
+ }
+ }
+ else if (bHad)
+ {
+ DrawSelectiveObjects( nLayer );
+ bHad = FALSE;
+ }
+ nPosY += pRowInfo[nArrY].nHeight;
+ }
+
+ if (bHad)
+ DrawSelectiveObjects( nLayer );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/overlayobject.cxx b/sc/source/ui/view/overlayobject.cxx
new file mode 100644
index 000000000000..a477f30576b1
--- /dev/null
+++ b/sc/source/ui/view/overlayobject.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: gridwin.hxx,v $
+ * $Revision: 1.30 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "overlayobject.hxx"
+#include "vcl/outdev.hxx"
+#include "vcl/lineinfo.hxx"
+#include "vcl/salbtype.hxx"
+#include "vcl/window.hxx"
+#include "tools/fract.hxx"
+#include "basegfx/range/b2drange.hxx"
+#include "basegfx/polygon/b2dpolygon.hxx"
+#include "basegfx/polygon/b2dpolygontools.hxx"
+#include "svx/sdr/overlay/overlaymanager.hxx"
+#include "drawinglayer/primitive2d/baseprimitive2d.hxx"
+#include "drawinglayer/primitive2d/polypolygonprimitive2d.hxx"
+
+using ::sdr::overlay::OverlayObject;
+using ::sdr::overlay::OverlayManager;
+using ::drawinglayer::primitive2d::Primitive2DSequence;
+
+#define DASH_UPDATE_INTERVAL 180 // in msec
+
+ScOverlayDashedBorder::ScOverlayDashedBorder(const ::basegfx::B2DRange& rRange, const Color& rColor, Window* pWin) :
+ OverlayObject(rColor),
+ mpParent(pWin),
+ mbToggle(true)
+{
+ mbAllowsAnimation = true;
+ maRange = rRange;
+}
+
+ScOverlayDashedBorder::~ScOverlayDashedBorder()
+{
+}
+
+void ScOverlayDashedBorder::Trigger(sal_uInt32 nTime)
+{
+ OverlayManager* pMgr = getOverlayManager();
+ if (pMgr)
+ {
+ SetTime(nTime + DASH_UPDATE_INTERVAL);
+ mbToggle = !mbToggle;
+ pMgr->InsertEvent(this);
+ objectChange();
+ }
+}
+
+void ScOverlayDashedBorder::stripeDefinitionHasChanged()
+{
+ objectChange();
+}
+
+Primitive2DSequence ScOverlayDashedBorder::createOverlayObjectPrimitive2DSequence()
+{
+ using ::basegfx::B2DPolygon;
+ using ::basegfx::B2DPolyPolygon;
+
+ OverlayManager* pMgr = getOverlayManager();
+ if (!pMgr)
+ return Primitive2DSequence();
+
+ basegfx::BColor aColorA = pMgr->getStripeColorA().getBColor();
+ basegfx::BColor aColorB = pMgr->getStripeColorB().getBColor();
+ if (!mbToggle)
+ ::std::swap(aColorA, aColorB);
+
+ const basegfx::B2DPolygon aPoly = basegfx::tools::createPolygonFromRect(maRange);
+ B2DPolyPolygon aPolygon(aPoly);
+ const drawinglayer::primitive2d::Primitive2DReference aReference(
+ new drawinglayer::primitive2d::PolyPolygonMarkerPrimitive2D(
+ aPolygon, aColorA, aColorB, pMgr->getStripeLengthPixel()));
+
+ return drawinglayer::primitive2d::Primitive2DSequence(&aReference, 1);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx
new file mode 100644
index 000000000000..c9264bc4b618
--- /dev/null
+++ b/sc/source/ui/view/pfuncache.cxx
@@ -0,0 +1,200 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <tools/multisel.hxx>
+
+#include "pfuncache.hxx"
+#include "printfun.hxx"
+#include "docsh.hxx"
+#include "markdata.hxx"
+#include "prevloc.hxx"
+
+//------------------------------------------------------------------------
+
+ScPrintFuncCache::ScPrintFuncCache( ScDocShell* pD, const ScMarkData& rMark,
+ const ScPrintSelectionStatus& rStatus ) :
+ aSelection( rStatus ),
+ pDocSh( pD ),
+ nTotalPages( 0 ),
+ bLocInitialized( false )
+{
+ // page count uses the stored cell widths for the printer anyway,
+ // so ScPrintFunc with the document's printer can be used to count
+
+ SfxPrinter* pPrinter = pDocSh->GetPrinter();
+
+ ScRange aRange;
+ const ScRange* pSelRange = NULL;
+ if ( rMark.IsMarked() )
+ {
+ rMark.GetMarkArea( aRange );
+ pSelRange = &aRange;
+ }
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTab;
+ for ( nTab=0; nTab<nTabCount; nTab++ )
+ {
+ long nAttrPage = nTab > 0 ? nFirstAttr[nTab-1] : 1;
+
+ long nThisTab = 0;
+ if ( rMark.GetTableSelect( nTab ) )
+ {
+ pDoc->InvalidatePageBreaks( nTab ); // user print area (selection) may be different
+
+ ScPrintFunc aFunc( pDocSh, pPrinter, nTab, nAttrPage, 0, pSelRange, &aSelection.GetOptions() );
+ nThisTab = aFunc.GetTotalPages();
+ nFirstAttr[nTab] = aFunc.GetFirstPageNo(); // from page style or previous sheet
+ }
+ else
+ nFirstAttr[nTab] = nAttrPage;
+
+ nPages[nTab] = nThisTab;
+ nTotalPages += nThisTab;
+ }
+}
+
+ScPrintFuncCache::~ScPrintFuncCache()
+{
+}
+
+void ScPrintFuncCache::InitLocations( const ScMarkData& rMark, OutputDevice* pDev )
+{
+ if ( bLocInitialized )
+ return; // initialize only once
+
+ ScRange aRange;
+ const ScRange* pSelRange = NULL;
+ if ( rMark.IsMarked() )
+ {
+ rMark.GetMarkArea( aRange );
+ pSelRange = &aRange;
+ }
+
+ long nRenderer = 0; // 0-based physical page number across sheets
+ long nTabStart = 0;
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for ( SCTAB nTab=0; nTab<nTabCount; nTab++ )
+ {
+ if ( rMark.GetTableSelect( nTab ) )
+ {
+ ScPrintFunc aFunc( pDev, pDocSh, nTab, nFirstAttr[nTab], nTotalPages, pSelRange, &aSelection.GetOptions() );
+ aFunc.SetRenderFlag( TRUE );
+
+ long nDisplayStart = GetDisplayStart( nTab );
+
+ for ( long nPage=0; nPage<nPages[nTab]; nPage++ )
+ {
+ Range aPageRange( nRenderer+1, nRenderer+1 );
+ MultiSelection aPage( aPageRange );
+ aPage.SetTotalRange( Range(0,RANGE_MAX) );
+ aPage.Select( aPageRange );
+
+ ScPreviewLocationData aLocData( pDoc, pDev );
+ aFunc.DoPrint( aPage, nTabStart, nDisplayStart, FALSE, NULL, &aLocData );
+
+ ScRange aCellRange;
+ Rectangle aPixRect;
+ if ( aLocData.GetMainCellRange( aCellRange, aPixRect ) )
+ aLocations.push_back( ScPrintPageLocation( nRenderer, aCellRange, aPixRect ) );
+
+ ++nRenderer;
+ }
+
+ nTabStart += nPages[nTab];
+ }
+ }
+
+ bLocInitialized = true;
+}
+
+bool ScPrintFuncCache::FindLocation( const ScAddress& rCell, ScPrintPageLocation& rLocation ) const
+{
+ for ( std::vector<ScPrintPageLocation>::const_iterator aIter(aLocations.begin());
+ aIter != aLocations.end(); aIter++ )
+ {
+ if ( aIter->aCellRange.In( rCell ) )
+ {
+ rLocation = *aIter;
+ return true;
+ }
+ }
+ return false; // not found
+}
+
+BOOL ScPrintFuncCache::IsSameSelection( const ScPrintSelectionStatus& rStatus ) const
+{
+ return aSelection == rStatus;
+}
+
+SCTAB ScPrintFuncCache::GetTabForPage( long nPage ) const
+{
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTab = 0;
+ while ( nTab < nTabCount && nPage >= nPages[nTab] )
+ nPage -= nPages[nTab++];
+ return nTab;
+}
+
+long ScPrintFuncCache::GetTabStart( SCTAB nTab ) const
+{
+ long nRet = 0;
+ for ( SCTAB i=0; i<nTab; i++ )
+ nRet += nPages[i];
+ return nRet;
+}
+
+long ScPrintFuncCache::GetDisplayStart( SCTAB nTab ) const
+{
+ //! merge with lcl_GetDisplayStart in preview?
+
+ long nDisplayStart = 0;
+ ScDocument* pDoc = pDocSh->GetDocument();
+ for (SCTAB i=0; i<nTab; i++)
+ {
+ if ( pDoc->NeedPageResetAfterTab(i) )
+ nDisplayStart = 0;
+ else
+ nDisplayStart += nPages[i];
+ }
+ return nDisplayStart;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/pgbrksh.cxx b/sc/source/ui/view/pgbrksh.cxx
new file mode 100644
index 000000000000..8516475f9050
--- /dev/null
+++ b/sc/source/ui/view/pgbrksh.cxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svl/srchitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+
+#include "pgbrksh.hxx"
+#include "tabvwsh.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+
+//------------------------------------------------------------------------
+
+#define ScPageBreakShell
+#include "scslots.hxx"
+
+//------------------------------------------------------------------------
+
+TYPEINIT1( ScPageBreakShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScPageBreakShell, SfxShell, ScResId(SCSTR_PAGEBREAKSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PAGEBREAK) );
+}
+
+
+//------------------------------------------------------------------------
+ScPageBreakShell::ScPageBreakShell( ScTabViewShell* pViewSh ) :
+ SfxShell(pViewSh)
+{
+ SetPool( &pViewSh->GetPool() );
+ ScViewData* pViewData = pViewSh->GetViewData();
+ SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId( HID_SCSHELL_PAGEBREAK );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("PageBreak")));
+}
+
+//------------------------------------------------------------------------
+ScPageBreakShell::~ScPageBreakShell()
+{
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/pivotsh.cxx b/sc/source/ui/view/pivotsh.cxx
new file mode 100644
index 000000000000..f50feafd98a0
--- /dev/null
+++ b/sc/source/ui/view/pivotsh.cxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svl/srchitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "sc.hrc"
+#include "pivotsh.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "scresid.hxx"
+#include "document.hxx"
+#include "dpobject.hxx"
+#include "dpshttab.hxx"
+#include "dbdocfun.hxx"
+#include "uiitems.hxx"
+#include "scabstdlg.hxx"
+//------------------------------------------------------------------------
+
+#define ScPivotShell
+#include "scslots.hxx"
+
+//------------------------------------------------------------------------
+
+TYPEINIT1( ScPivotShell, SfxShell );
+
+SFX_IMPL_INTERFACE(ScPivotShell, SfxShell, ScResId(SCSTR_PIVOTSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_PIVOT) );
+}
+
+
+//------------------------------------------------------------------------
+
+ScPivotShell::ScPivotShell( ScTabViewShell* pViewSh ) :
+ SfxShell(pViewSh),
+ pViewShell( pViewSh )
+{
+ SetPool( &pViewSh->GetPool() );
+ ScViewData* pViewData = pViewSh->GetViewData();
+ SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager();
+ SetUndoManager( pMgr );
+ if ( !pViewData->GetDocument()->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetHelpId( HID_SCSHELL_PIVOTSH );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Pivot")));
+}
+
+//------------------------------------------------------------------------
+ScPivotShell::~ScPivotShell()
+{
+}
+
+//------------------------------------------------------------------------
+void ScPivotShell::Execute( SfxRequest& rReq )
+{
+ switch ( rReq.GetSlot() )
+ {
+ case SID_PIVOT_RECALC:
+ pViewShell->RecalcPivotTable();
+ break;
+
+ case SID_PIVOT_KILL:
+ pViewShell->DeletePivotTable();
+ break;
+
+ case SID_DP_FILTER:
+ {
+ ScDPObject* pDPObj = GetCurrDPObject();
+ if( pDPObj )
+ {
+ ScQueryParam aQueryParam;
+ SCTAB nSrcTab = 0;
+ const ScSheetSourceDesc* pDesc = pDPObj->GetSheetDesc();
+ DBG_ASSERT( pDesc, "no sheet source for DP filter dialog" );
+ if( pDesc )
+ {
+ aQueryParam = pDesc->aQueryParam;
+ nSrcTab = pDesc->aSourceRange.aStart.Tab();
+ }
+
+ ScViewData* pViewData = pViewShell->GetViewData();
+ SfxItemSet aArgSet( pViewShell->GetPool(),
+ SCITEM_QUERYDATA, SCITEM_QUERYDATA );
+ aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA, pViewData, &aQueryParam ) );
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScPivotFilterDlg* pDlg = pFact->CreateScPivotFilterDlg( pViewShell->GetDialogParent(),
+ aArgSet, nSrcTab,
+ RID_SCDLG_PIVOTFILTER);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ if( pDlg->Execute() == RET_OK )
+ {
+ ScSheetSourceDesc aNewDesc;
+ if( pDesc )
+ aNewDesc = *pDesc;
+
+ const ScQueryItem& rQueryItem = pDlg->GetOutputItem();
+ aNewDesc.aQueryParam = rQueryItem.GetQueryData();
+
+ ScDPObject aNewObj( *pDPObj );
+ aNewObj.SetSheetDesc( aNewDesc );
+ ScDBDocFunc aFunc( *pViewData->GetDocShell() );
+ aFunc.DataPilotUpdate( pDPObj, &aNewObj, TRUE, FALSE );
+ pViewData->GetView()->CursorPosChanged(); // shells may be switched
+ }
+ delete pDlg;
+ }
+ }
+ break;
+ }
+}
+
+//------------------------------------------------------------------------
+void __EXPORT ScPivotShell::GetState( SfxItemSet& rSet )
+{
+ ScDocShell* pDocSh = pViewShell->GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bDisable = pDocSh->IsReadOnly() || pDoc->GetChangeTrack();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_PIVOT_RECALC:
+ case SID_PIVOT_KILL:
+ {
+ //! move ReadOnly check to idl flags
+ if ( bDisable )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+ case SID_DP_FILTER:
+ {
+ ScDPObject* pDPObj = GetCurrDPObject();
+ if( bDisable || !pDPObj || !pDPObj->IsSheetData() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+//------------------------------------------------------------------------
+
+ScDPObject* ScPivotShell::GetCurrDPObject()
+{
+ const ScViewData& rViewData = *pViewShell->GetViewData();
+ return rViewData.GetDocument()->GetDPAtCursor(
+ rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/preview.cxx b/sc/source/ui/view/preview.cxx
new file mode 100644
index 000000000000..6e970f318d07
--- /dev/null
+++ b/sc/source/ui/view/preview.cxx
@@ -0,0 +1,1616 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <tools/pstm.hxx>
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <svtools/colorcfg.hxx>
+#include <svx/fmview.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/svdpagv.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/accessibilityoptions.hxx>
+#include <svl/itemset.hxx>
+#include <tools/multisel.hxx>
+#include <vcl/waitobj.hxx>
+#include <vcl/sound.hxx>
+
+#include "preview.hxx"
+#include "prevwsh.hxx"
+#include "prevloc.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "printfun.hxx"
+#include "printopt.hxx"
+#include "stlpool.hxx"
+#include "undostyl.hxx"
+#include "drwlayer.hxx"
+#include "scmod.hxx"
+#include "globstr.hrc"
+#include "sc.hrc" // fuer ShellInvalidate
+#include "AccessibleDocumentPagePreview.hxx"
+#include <vcl/lineinfo.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/sizeitem.hxx>
+#include "attrib.hxx"
+#include "pagepar.hxx"
+#include <com/sun/star/accessibility/XAccessible.hpp>
+#include "AccessibilityHints.hxx"
+#include <vcl/svapp.hxx>
+#include "viewutil.hxx"
+
+// STATIC DATA -----------------------------------------------------------
+
+//==================================================================
+
+#define SC_PREVIEW_SHADOWSIZE 2
+
+long lcl_GetDisplayStart( SCTAB nTab, ScDocument* pDoc, long* pPages )
+{
+ long nDisplayStart = 0;
+ for (SCTAB i=0; i<nTab; i++)
+ {
+ if ( pDoc->NeedPageResetAfterTab(i) )
+ nDisplayStart = 0;
+ else
+ nDisplayStart += pPages[i];
+ }
+ return nDisplayStart;
+}
+
+
+ScPreview::ScPreview( Window* pParent, ScDocShell* pDocSh, ScPreviewShell* pViewSh ) :
+ Window( pParent ),
+ nPageNo( 0 ),
+ nZoom( 100 ),
+ bValid( FALSE ),
+ nTabsTested( 0 ),
+ nTab( 0 ),
+ nTabStart( 0 ),
+ nDisplayStart( 0 ),
+ nTotalPages( 0 ),
+ bStateValid( FALSE ),
+ bLocationValid( FALSE ),
+ pLocationData( NULL ),
+ pDrawView( NULL ),
+ nCurTab ( ScDocShell::GetCurTab() ),
+ bInPaint( FALSE ),
+ bInGetState( FALSE ),
+ pDocShell( pDocSh ),
+ pViewShell( pViewSh ),
+ bLeftRulerMove( FALSE ),
+ bRightRulerMove( FALSE ),
+ bTopRulerMove( FALSE ),
+ bBottomRulerMove( FALSE ),
+ bHeaderRulerMove( FALSE ),
+ bFooterRulerMove( FALSE ),
+ bLeftRulerChange( FALSE ),
+ bRightRulerChange( FALSE ),
+ bTopRulerChange( FALSE ),
+ bBottomRulerChange( FALSE ),
+ bHeaderRulerChange( FALSE ),
+ bFooterRulerChange( FALSE ),
+ bPageMargin ( FALSE ),
+ bColRulerMove( FALSE ),
+ mnScale( 0 ),
+ nColNumberButttonDown( 0 ),
+ nHeaderHeight ( 0 ),
+ nFooterHeight ( 0 )
+{
+ SetOutDevViewType( OUTDEV_VIEWTYPE_PRINTPREVIEW ); //#106611#
+ SetBackground();
+
+ SetHelpId( HID_SC_WIN_PREVIEW );
+ SetUniqueId( HID_SC_WIN_PREVIEW );
+
+ SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
+}
+
+
+__EXPORT ScPreview::~ScPreview()
+{
+ delete pDrawView;
+ delete pLocationData;
+}
+
+void ScPreview::UpdateDrawView() // nTab muss richtig sein
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScDrawLayer* pModel = pDoc->GetDrawLayer(); // ist nicht 0
+
+ // #114135#
+ if ( pModel )
+ {
+ SdrPage* pPage = pModel->GetPage(nTab);
+ if ( pDrawView && ( !pDrawView->GetSdrPageView() || pDrawView->GetSdrPageView()->GetPage() != pPage ) )
+ {
+ // die angezeigte Page der DrawView umzustellen (s.u.) funktioniert nicht ?!?
+ delete pDrawView;
+ pDrawView = NULL;
+ }
+
+ if ( !pDrawView ) // neu anlegen?
+ {
+ pDrawView = new FmFormView( pModel, this );
+ // #55259# die DrawView uebernimmt den Design-Modus vom Model
+ // (Einstellung "Im Entwurfsmodus oeffnen"), darum hier zuruecksetzen
+ pDrawView->SetDesignMode( TRUE );
+ pDrawView->SetPrintPreview( TRUE );
+ pDrawView->ShowSdrPage(pPage);
+ }
+ }
+ else if ( pDrawView )
+ {
+ delete pDrawView; // fuer diese Tabelle nicht gebraucht
+ pDrawView = NULL;
+ }
+}
+
+
+void ScPreview::TestLastPage()
+{
+ if (nPageNo >= nTotalPages)
+ {
+ if (nTotalPages)
+ {
+ nPageNo = nTotalPages - 1;
+ nTab = nTabCount - 1;
+ while (nTab > 0 && !nPages[nTab]) // letzte nicht leere Tabelle
+ --nTab;
+ DBG_ASSERT(nPages[nTab],"alle Tabellen leer?");
+ nTabPage = nPages[nTab] - 1;
+ nTabStart = 0;
+ for (USHORT i=0; i<nTab; i++)
+ nTabStart += nPages[i];
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
+ }
+ else // leeres Dokument
+ {
+ nTab = 0;
+ nPageNo = nTabPage = nTabStart = nDisplayStart = 0;
+ aState.nPrintTab = 0;
+ aState.nStartCol = aState.nEndCol = 0;
+ aState.nStartRow = aState.nEndRow = 0;
+ aState.nZoom = 0;
+ aState.nPagesX = aState.nPagesY = 0;
+ aState.nTabPages = aState.nTotalPages =
+ aState.nPageStart = aState.nDocPages = 0;
+ }
+ }
+}
+
+
+void ScPreview::CalcPages( SCTAB /*nToWhichTab*/ )
+{
+ WaitObject( this );
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ nTabCount = pDoc->GetTableCount();
+
+ //SCTAB nAnz = Min( nTabCount, SCTAB(nToWhichTab+1) );
+ SCTAB nAnz = nTabCount;
+ SCTAB nStart = nTabsTested;
+ if (!bValid)
+ {
+ nStart = 0;
+ nTotalPages = 0;
+ nTabsTested = 0;
+ }
+
+ // update all pending row heights with a single progress bar,
+ // instead of a separate progress for each sheet from ScPrintFunc
+ pDocShell->UpdatePendingRowHeights( nAnz-1, true );
+
+ // PrintOptions is passed to PrintFunc for SkipEmpty flag,
+ // but always all sheets are used (there is no selected sheet)
+ ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
+
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( nCurTab, TRUE );
+
+ for (SCTAB i=nStart; i<nAnz; i++)
+ {
+ if (!aOptions.GetAllSheets() && !aMarkData.GetTableSelect( i )) {
+ nPages[i] = 0;
+ nFirstAttr[i] = 0;
+ continue;
+ }
+
+ long nAttrPage = i > 0 ? nFirstAttr[i-1] : 1;
+
+ long nThisStart = nTotalPages;
+ ScPrintFunc aPrintFunc( this, pDocShell, i, nAttrPage, 0, NULL, &aOptions );
+ long nThisTab = aPrintFunc.GetTotalPages();
+ nPages[i] = nThisTab;
+ nTotalPages += nThisTab;
+ nFirstAttr[i] = aPrintFunc.GetFirstPageNo(); // behalten oder aus Vorlage
+
+ if (nPageNo>=nThisStart && nPageNo<nTotalPages)
+ {
+ nTab = i;
+ nTabPage = nPageNo - nThisStart;
+ nTabStart = nThisStart;
+
+ aPrintFunc.GetPrintState( aState );
+ aPageSize = aPrintFunc.GetPageSize();
+ }
+ }
+
+ nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
+
+ if (nAnz > nTabsTested)
+ nTabsTested = nAnz;
+
+ // testen, ob hinter letzter Seite
+
+ if ( nTabsTested >= nTabCount )
+ TestLastPage();
+
+ aState.nDocPages = nTotalPages;
+
+ bValid = TRUE;
+ bStateValid = TRUE;
+ DoInvalidate();
+}
+
+
+void ScPreview::RecalcPages() // nur nPageNo geaendert
+{
+ if (!bValid)
+ return; // dann wird CalcPages aufgerufen
+
+ SCTAB nOldTab = nTab;
+
+ BOOL bDone = FALSE;
+ while (nPageNo >= nTotalPages && nTabsTested < nTabCount)
+ {
+ CalcPages( nTabsTested );
+ bDone = TRUE;
+ }
+
+ if (!bDone)
+ {
+ long nPartPages = 0;
+ for (SCTAB i=0; i<nTabsTested; i++)
+ {
+ long nThisStart = nPartPages;
+ nPartPages += nPages[i];
+
+ if (nPageNo>=nThisStart && nPageNo<nPartPages)
+ {
+ nTab = i;
+ nTabPage = nPageNo - nThisStart;
+ nTabStart = nThisStart;
+
+// aPageSize = aPrintFunc.GetPageSize();
+ }
+ }
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ nDisplayStart = lcl_GetDisplayStart( nTab, pDoc, nPages );
+ }
+
+ TestLastPage(); // testen, ob hinter letzter Seite
+
+ if ( nTab != nOldTab )
+ bStateValid = FALSE;
+
+ DoInvalidate();
+}
+
+
+void ScPreview::DoPrint( ScPreviewLocationData* pFillLocation )
+{
+ if (!bValid)
+ {
+ CalcPages(0);
+ RecalcPages();
+ UpdateDrawView(); // Tabelle evtl. geaendert
+ }
+
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+
+ BOOL bDoPrint = ( pFillLocation == NULL );
+ BOOL bValidPage = ( nPageNo < nTotalPages );
+
+ ScModule* pScMod = SC_MOD();
+ const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
+ Color aBackColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
+
+ if ( bDoPrint && ( aOffset.X() < 0 || aOffset.Y() < 0 ) && bValidPage )
+ {
+ SetMapMode( aMMMode );
+ SetLineColor();
+ SetFillColor(aBackColor);
+
+ Size aWinSize = GetOutputSize();
+ if ( aOffset.X() < 0 )
+ DrawRect(Rectangle( 0, 0, -aOffset.X(), aWinSize.Height() ));
+ if ( aOffset.Y() < 0 )
+ DrawRect(Rectangle( 0, 0, aWinSize.Width(), -aOffset.Y() ));
+ }
+
+ Size aLocalPageSize;
+ if ( bValidPage )
+ {
+ ScPrintOptions aOptions = pScMod->GetPrintOptions();
+
+ ScPrintFunc* pPrintFunc;
+ if (bStateValid)
+ pPrintFunc = new ScPrintFunc( this, pDocShell, aState, &aOptions );
+ else
+ pPrintFunc = new ScPrintFunc( this, pDocShell, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
+
+ pPrintFunc->SetOffset(aOffset);
+ pPrintFunc->SetManualZoom(nZoom);
+ pPrintFunc->SetDateTime(aDate,aTime);
+ pPrintFunc->SetClearFlag(TRUE);
+ pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() );
+
+ pPrintFunc->SetDrawView( pDrawView );
+
+ // MultiSelection fuer die eine Seite muss etwas umstaendlich erzeugt werden...
+ Range aPageRange( nPageNo+1, nPageNo+1 );
+ MultiSelection aPage( aPageRange );
+ aPage.SetTotalRange( Range(0,RANGE_MAX) );
+ aPage.Select( aPageRange );
+
+ long nPrinted = pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart, bDoPrint, NULL, pFillLocation );
+ DBG_ASSERT(nPrinted<=1, "was'n nu los?");
+
+ SetMapMode(aMMMode);
+// USHORT nPrintZoom = pPrintFunc->GetZoom();
+
+ if (nPrinted) // wenn nichts, alles grau zeichnen
+ {
+ aLocalPageSize = pPrintFunc->GetPageSize();
+ aLocalPageSize.Width() = (long) (aLocalPageSize.Width() * HMM_PER_TWIPS );
+ aLocalPageSize.Height() = (long) (aLocalPageSize.Height() * HMM_PER_TWIPS );
+ }
+
+ if (!bStateValid)
+ {
+ pPrintFunc->GetPrintState( aState );
+ aState.nDocPages = nTotalPages;
+ bStateValid = TRUE;
+ }
+ delete pPrintFunc;
+ }
+
+ if ( bDoPrint )
+ {
+ long nPageEndX = aLocalPageSize.Width() - aOffset.X();
+ long nPageEndY = aLocalPageSize.Height() - aOffset.Y();
+ if ( !bValidPage )
+ nPageEndX = nPageEndY = 0;
+
+ Size aWinSize = GetOutputSize();
+ Point aWinEnd( aWinSize.Width(), aWinSize.Height() );
+ BOOL bRight = nPageEndX <= aWinEnd.X();
+ BOOL bBottom = nPageEndY <= aWinEnd.Y();
+ if (bRight || bBottom)
+ {
+ SetLineColor();
+ SetFillColor(aBackColor);
+ if (bRight)
+ DrawRect(Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y()));
+ if (bBottom)
+ {
+ if (bRight)
+ DrawRect(Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Ecke nicht doppelt
+ else
+ DrawRect(Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y()));
+ }
+ }
+
+ if ( bValidPage )
+ {
+ Color aBorderColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+
+ // draw border
+
+ if ( aOffset.X() <= 0 || aOffset.Y() <= 0 || bRight || bBottom )
+ {
+ SetLineColor( aBorderColor );
+ SetFillColor();
+
+ Rectangle aPixel( LogicToPixel( Rectangle( -aOffset.X(), -aOffset.Y(), nPageEndX, nPageEndY ) ) );
+ --aPixel.Right();
+ --aPixel.Bottom();
+ DrawRect( PixelToLogic( aPixel ) );
+ }
+
+ // draw shadow
+
+ SetLineColor();
+ SetFillColor( aBorderColor );
+
+ Rectangle aPixel;
+
+ aPixel = LogicToPixel( Rectangle( nPageEndX, -aOffset.Y(), nPageEndX, nPageEndY ) );
+ aPixel.Top() += SC_PREVIEW_SHADOWSIZE;
+ aPixel.Right() += SC_PREVIEW_SHADOWSIZE - 1;
+ aPixel.Bottom() += SC_PREVIEW_SHADOWSIZE - 1;
+ DrawRect( PixelToLogic( aPixel ) );
+
+ aPixel = LogicToPixel( Rectangle( -aOffset.X(), nPageEndY, nPageEndX, nPageEndY ) );
+ aPixel.Left() += SC_PREVIEW_SHADOWSIZE;
+ aPixel.Right() += SC_PREVIEW_SHADOWSIZE - 1;
+ aPixel.Bottom() += SC_PREVIEW_SHADOWSIZE - 1;
+ DrawRect( PixelToLogic( aPixel ) );
+ }
+ }
+}
+
+//Issue51656 Add resizeable margin on page preview from maoyg
+void __EXPORT ScPreview::Paint( const Rectangle& /* rRect */ )
+{
+ if (!bValid)
+ {
+ CalcPages(0);
+ RecalcPages();
+ UpdateDrawView(); // Table possibly amended
+ }
+
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+
+ ScModule* pScMod = SC_MOD();
+ const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig();
+ Color aBackColor( rColorCfg.GetColorValue(svtools::APPBACKGROUND).nColor );
+
+ if ( aOffset.X() < 0 || aOffset.Y() < 0 )
+ {
+ SetMapMode( aMMMode );
+ SetLineColor();
+ SetFillColor(aBackColor);
+
+ Size aWinSize = GetOutputSize();
+ if ( aOffset.X() < 0 )
+ DrawRect(Rectangle( 0, 0, -aOffset.X(), aWinSize.Height() ));
+ if ( aOffset.Y() < 0 )
+ DrawRect(Rectangle( 0, 0, aWinSize.Width(), -aOffset.Y() ));
+ }
+
+ long nLeftMargin = 0;
+ long nRightMargin = 0;
+ long nTopMargin = 0;
+ long nBottomMargin = 0;
+ BOOL bHeaderOn = FALSE;
+ BOOL bFooterOn = FALSE;
+
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ Size aPaintPageSize;
+ if ( nPageNo < nTotalPages )
+ {
+ ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
+
+ ScPrintFunc* pPrintFunc;
+ if ( bStateValid )
+ pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions );
+ else
+ pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
+
+ pPrintFunc->SetOffset(aOffset);
+ pPrintFunc->SetManualZoom(nZoom);
+ pPrintFunc->SetDateTime(aDate,aTime);
+ pPrintFunc->SetClearFlag(TRUE);
+ pPrintFunc->SetUseStyleColor( pScMod->GetAccessOptions().GetIsForPagePreviews() );
+ pPrintFunc->SetDrawView( pDrawView );
+
+ // Multi Selection for one side must be something umstaendlich generated ...
+ Range aPageRange( nPageNo+1, nPageNo+1 );
+ MultiSelection aPage( aPageRange );
+ aPage.SetTotalRange( Range(0,RANGE_MAX) );
+ aPage.Select( aPageRange );
+
+ long nPrinted = pPrintFunc->DoPrint( aPage, nTabStart, nDisplayStart );
+ DBG_ASSERT(nPrinted<=1, "was'n nu los?");
+
+ SetMapMode(aMMMode);
+
+ //init nLeftMargin ... in the ScPrintFunc::InitParam!!!
+ nLeftMargin = pPrintFunc->GetLeftMargin();
+ nRightMargin = pPrintFunc->GetRightMargin();
+ nTopMargin = pPrintFunc->GetTopMargin();
+ nBottomMargin = pPrintFunc->GetBottomMargin();
+ nHeaderHeight = pPrintFunc->GetHeader().nHeight;
+ nFooterHeight = pPrintFunc->GetFooter().nHeight;
+ bHeaderOn = pPrintFunc->GetHeader().bEnable;
+ bFooterOn = pPrintFunc->GetFooter().bEnable;
+ mnScale = pPrintFunc->GetZoom();
+
+ Rectangle aPixRect;
+ Rectangle aRectCellPosition;
+ Rectangle aRectPosition;
+ GetLocationData().GetMainCellRange( aPageArea, aPixRect );
+ if( !bLayoutRTL )
+ {
+ GetLocationData().GetCellPosition( aPageArea.aStart, aRectPosition );
+ nLeftPosition = aRectPosition.Left();
+ for( SCCOL i = aPageArea.aStart.Col(); i <= aPageArea.aEnd.Col(); i++ )
+ {
+ GetLocationData().GetCellPosition( ScAddress( i,aPageArea.aStart.Row(),aPageArea.aStart.Tab()),aRectCellPosition );
+ nRight[i] = aRectCellPosition.Right();
+ }
+ }
+ else
+ {
+ GetLocationData().GetCellPosition( aPageArea.aEnd, aRectPosition );
+ nLeftPosition = aRectPosition.Right()+1;
+
+ GetLocationData().GetCellPosition( aPageArea.aStart,aRectCellPosition );
+ nRight[ aPageArea.aEnd.Col() ] = aRectCellPosition.Left();
+ for( SCCOL i = aPageArea.aEnd.Col(); i > aPageArea.aStart.Col(); i-- )
+ {
+ GetLocationData().GetCellPosition( ScAddress( i,aPageArea.aEnd.Row(),aPageArea.aEnd.Tab()),aRectCellPosition );
+ nRight[ i-1 ] = nRight[ i ] + aRectCellPosition.Right() - aRectCellPosition.Left() + 1;
+ }
+ }
+
+ if ( nPrinted ) // If nothing, all gray draw
+ {
+ aPaintPageSize = pPrintFunc->GetPageSize();
+ aPaintPageSize.Width() = (long) (aPaintPageSize.Width() * HMM_PER_TWIPS );
+ aPaintPageSize.Height() = (long) (aPaintPageSize.Height() * HMM_PER_TWIPS );
+
+ nLeftMargin = (long) ( nLeftMargin * HMM_PER_TWIPS );
+ nRightMargin = (long) ( nRightMargin * HMM_PER_TWIPS );
+ nTopMargin = (long) ( nTopMargin * HMM_PER_TWIPS );
+ nBottomMargin = (long) ( nBottomMargin * HMM_PER_TWIPS );
+ nHeaderHeight = (long) ( nHeaderHeight * HMM_PER_TWIPS * mnScale / 100 + nTopMargin );
+ nFooterHeight = (long) ( nFooterHeight * HMM_PER_TWIPS * mnScale / 100 + nBottomMargin );
+ }
+
+ if ( !bStateValid )
+ {
+ pPrintFunc->GetPrintState( aState );
+ aState.nDocPages = nTotalPages;
+ bStateValid = TRUE;
+ }
+
+ delete pPrintFunc;
+ }
+
+
+ long nPageEndX = aPaintPageSize.Width() - aOffset.X();
+ long nPageEndY = aPaintPageSize.Height() - aOffset.Y();
+ Size aWinSize = GetOutputSize();
+ Point aWinEnd( aWinSize.Width(), aWinSize.Height() );
+ BOOL bRight = nPageEndX <= aWinEnd.X();
+ BOOL bBottom = nPageEndY <= aWinEnd.Y();
+
+ if( bPageMargin )
+ {
+ SetMapMode(aMMMode);
+ SetLineColor( COL_BLACK );
+ DrawInvert( (long)( nTopMargin - aOffset.Y() ), POINTER_VSIZEBAR );
+ DrawInvert( (long)(nPageEndY - nBottomMargin ), POINTER_VSIZEBAR );
+ DrawInvert( (long)( nLeftMargin - aOffset.X() ), POINTER_HSIZEBAR );
+ DrawInvert( (long)( nPageEndX - nRightMargin ) , POINTER_HSIZEBAR );
+ if( bHeaderOn )
+ {
+ DrawInvert( nHeaderHeight - aOffset.Y(), POINTER_VSIZEBAR );
+ }
+ if( bFooterOn )
+ {
+ DrawInvert( nPageEndY - nFooterHeight, POINTER_VSIZEBAR );
+ }
+
+ SetMapMode( MapMode( MAP_PIXEL ) );
+ for( int i= aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
+ {
+ Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
+ SetLineColor( COL_BLACK );
+ SetFillColor( COL_BLACK );
+ DrawRect( Rectangle( Point( nRight[i] - 2, aColumnTop.Y() ),Point( nRight[i] + 2 , 4 + aColumnTop.Y()) ));
+ DrawLine( Point( nRight[i], aColumnTop.Y() ), Point( nRight[i], 10 + aColumnTop.Y()) );
+ }
+ SetMapMode( aMMMode );
+ }
+
+ if (bRight || bBottom)
+ {
+ SetMapMode(aMMMode);
+ SetLineColor();
+ SetFillColor(aBackColor);
+ if (bRight)
+ DrawRect(Rectangle(nPageEndX,0, aWinEnd.X(),aWinEnd.Y()));
+ if (bBottom)
+ {
+ if (bRight)
+ DrawRect(Rectangle(0,nPageEndY, nPageEndX,aWinEnd.Y())); // Ecke nicht doppelt
+ else
+ DrawRect(Rectangle(0,nPageEndY, aWinEnd.X(),aWinEnd.Y()));
+ }
+ }
+ pViewShell->UpdateScrollBars();
+}
+//Issue51656 Add resizeable margin on page preview from maoyg
+
+void __EXPORT ScPreview::Command( const CommandEvent& rCEvt )
+{
+ USHORT nCmd = rCEvt.GetCommand();
+ if ( nCmd == COMMAND_WHEEL || nCmd == COMMAND_STARTAUTOSCROLL || nCmd == COMMAND_AUTOSCROLL )
+ {
+ BOOL bDone = pViewShell->ScrollCommand( rCEvt );
+ if (!bDone)
+ Window::Command(rCEvt);
+ }
+ else if ( nCmd == COMMAND_CONTEXTMENU )
+ SfxDispatcher::ExecutePopup();
+ else
+ Window::Command( rCEvt );
+}
+
+
+void __EXPORT ScPreview::KeyInput( const KeyEvent& rKEvt )
+{
+ // The + and - keys can't be configured as accelerator entries, so they must be handled directly
+ // (in ScPreview, not ScPreviewShell -> only if the preview window has the focus)
+
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ USHORT nKey = rKeyCode.GetCode();
+ BOOL bHandled = FALSE;
+ if(!rKeyCode.GetModifier())
+ {
+ USHORT nSlot = 0;
+ switch(nKey)
+ {
+ case KEY_ADD: nSlot = SID_PREVIEW_ZOOMIN; break;
+ case KEY_ESCAPE: nSlot = ScViewUtil::IsFullScreen( *pViewShell ) ? SID_CANCEL : SID_PREVIEW_CLOSE; break;
+ case KEY_SUBTRACT: nSlot = SID_PREVIEW_ZOOMOUT; break;
+ }
+ if(nSlot)
+ {
+ bHandled = TRUE;
+ pViewShell->GetViewFrame()->GetDispatcher()->Execute( nSlot, SFX_CALLMODE_ASYNCHRON );
+ }
+ }
+
+ if ( !bHandled && !pViewShell->KeyInput(rKEvt) )
+ Window::KeyInput(rKEvt);
+}
+
+
+const ScPreviewLocationData& ScPreview::GetLocationData()
+{
+ if ( !pLocationData )
+ {
+ pLocationData = new ScPreviewLocationData( pDocShell->GetDocument(), this );
+ bLocationValid = FALSE;
+ }
+ if ( !bLocationValid )
+ {
+ pLocationData->Clear();
+ DoPrint( pLocationData );
+ bLocationValid = TRUE;
+ }
+ return *pLocationData;
+}
+
+
+void ScPreview::DataChanged(BOOL bNewTime)
+{
+ if (bNewTime)
+ {
+ aDate = Date();
+ aTime = Time();
+ }
+
+ bValid = FALSE;
+ InvalidateLocationData( SC_HINT_DATACHANGED );
+ Invalidate();
+}
+
+
+String ScPreview::GetPosString()
+{
+ if (!bValid)
+ {
+ CalcPages(nTab);
+ UpdateDrawView(); // Tabelle evtl. geaendert
+ }
+
+ String aString( ScGlobal::GetRscString( STR_PAGE ) );
+ aString += ' ';
+ aString += String::CreateFromInt32(nPageNo+1);
+
+ if (nTabsTested >= nTabCount)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aString += String::CreateFromInt32(nTotalPages);
+ }
+
+ return aString;
+}
+
+
+void ScPreview::SetZoom(USHORT nNewZoom)
+{
+ if (nNewZoom < 20)
+ nNewZoom = 20;
+ if (nNewZoom > 400)
+ nNewZoom = 400;
+ if (nNewZoom != nZoom)
+ {
+ nZoom = nNewZoom;
+
+ // apply new MapMode and call UpdateScrollBars to update aOffset
+
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+ SetMapMode( aMMMode );
+
+ bInPaint = TRUE; // don't scroll during SetYOffset in UpdateScrollBars
+ pViewShell->UpdateScrollBars();
+ bInPaint = FALSE;
+
+ bStateValid = FALSE;
+ InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
+ DoInvalidate();
+ Invalidate();
+ }
+}
+
+
+void ScPreview::SetPageNo( long nPage )
+{
+ nPageNo = nPage;
+ RecalcPages();
+ UpdateDrawView(); // Tabelle evtl. geaendert
+ InvalidateLocationData( SC_HINT_DATACHANGED );
+ Invalidate();
+}
+
+
+long ScPreview::GetFirstPage(SCTAB nTabP)
+{
+ SCTAB nDocTabCount = pDocShell->GetDocument()->GetTableCount();
+ if (nTabP >= nDocTabCount)
+ nTabP = nDocTabCount-1;
+
+ long nPage = 0;
+ if (nTabP>0)
+ {
+ CalcPages( nTabP );
+ UpdateDrawView(); // Tabelle evtl. geaendert
+
+ for (SCTAB i=0; i<nTabP; i++)
+ nPage += nPages[i];
+
+ // bei leerer Tabelle vorhergehende Seite
+
+ if ( nPages[nTabP]==0 && nPage > 0 )
+ --nPage;
+ }
+
+ return nPage;
+}
+
+
+Size lcl_GetDocPageSize( ScDocument* pDoc, SCTAB nTab )
+{
+ String aName = pDoc->GetPageStyle( nTab );
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aName, SFX_STYLE_FAMILY_PAGE );
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+ return ((const SvxSizeItem&) rStyleSet.Get(ATTR_PAGE_SIZE)).GetSize();
+ }
+ else
+ {
+ DBG_ERROR( "PageStyle not found" );
+ return Size();
+ }
+}
+
+
+USHORT ScPreview::GetOptimalZoom(BOOL bWidthOnly)
+{
+ double nWinScaleX = ScGlobal::nScreenPPTX / pDocShell->GetOutputFactor();
+ double nWinScaleY = ScGlobal::nScreenPPTY;
+ Size aWinSize = GetOutputSizePixel();
+
+ // desired margin is 0.25cm in default MapMode (like Writer),
+ // but some additional margin is introduced by integer scale values
+ // -> add only 0.10cm, so there is some margin in all cases.
+ Size aMarginSize( LogicToPixel( Size( 100, 100 ), MAP_100TH_MM ) );
+ aWinSize.Width() -= 2 * aMarginSize.Width();
+ aWinSize.Height() -= 2 * aMarginSize.Height();
+
+ Size aLocalPageSize = lcl_GetDocPageSize( pDocShell->GetDocument(), nTab );
+ if ( aLocalPageSize.Width() && aLocalPageSize.Height() )
+ {
+ long nZoomX = (long) ( aWinSize.Width() * 100 / ( aLocalPageSize.Width() * nWinScaleX ));
+ long nZoomY = (long) ( aWinSize.Height() * 100 / ( aLocalPageSize.Height() * nWinScaleY ));
+
+ long nOptimal = nZoomX;
+ if (!bWidthOnly && nZoomY<nOptimal)
+ nOptimal = nZoomY;
+
+ if (nOptimal<20)
+ nOptimal = 20;
+ if (nOptimal>400)
+ nOptimal = 400;
+
+ return (USHORT) nOptimal;
+ }
+ else
+ return nZoom;
+}
+
+
+void ScPreview::SetXOffset( long nX )
+{
+ if ( aOffset.X() == nX )
+ return;
+
+ if (bValid)
+ {
+ long nDif = LogicToPixel(aOffset).X() - LogicToPixel(Point(nX,0)).X();
+ aOffset.X() = nX;
+ if (nDif && !bInPaint)
+ {
+ MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL);
+ Scroll( nDif, 0 );
+ SetMapMode(aOldMode);
+ }
+ }
+ else
+ {
+ aOffset.X() = nX;
+ if (!bInPaint)
+ Invalidate();
+ }
+ InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
+ Paint(Rectangle());
+}
+
+
+void ScPreview::SetYOffset( long nY )
+{
+ if ( aOffset.Y() == nY )
+ return;
+
+ if (bValid)
+ {
+ long nDif = LogicToPixel(aOffset).Y() - LogicToPixel(Point(0,nY)).Y();
+ aOffset.Y() = nY;
+ if (nDif && !bInPaint)
+ {
+ MapMode aOldMode = GetMapMode(); SetMapMode(MAP_PIXEL);
+ Scroll( 0, nDif );
+ SetMapMode(aOldMode);
+ }
+ }
+ else
+ {
+ aOffset.Y() = nY;
+ if (!bInPaint)
+ Invalidate();
+ }
+ InvalidateLocationData( SC_HINT_ACC_VISAREACHANGED );
+ Paint(Rectangle());
+}
+
+
+void ScPreview::DoInvalidate()
+{
+ // Wenn das ganze aus dem GetState der Shell gerufen wird,
+ // muss das Invalidate hinterher asynchron kommen...
+
+ if (bInGetState)
+ Application::PostUserEvent( STATIC_LINK( this, ScPreview, InvalidateHdl ) );
+ else
+ StaticInvalidate(); // sofort
+}
+
+void ScPreview::StaticInvalidate()
+{
+ // static method, because it's called asynchronously
+ // -> must use current viewframe
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (!pViewFrm)
+ return;
+
+ SfxBindings& rBindings = pViewFrm->GetBindings();
+ rBindings.Invalidate(SID_STATUS_DOCPOS);
+ rBindings.Invalidate(SID_STATUS_PAGESTYLE);
+ rBindings.Invalidate(SID_PREVIEW_PREVIOUS);
+ rBindings.Invalidate(SID_PREVIEW_NEXT);
+ rBindings.Invalidate(SID_PREVIEW_FIRST);
+ rBindings.Invalidate(SID_PREVIEW_LAST);
+ rBindings.Invalidate(SID_ATTR_ZOOM);
+ rBindings.Invalidate(SID_PREVIEW_ZOOMIN);
+ rBindings.Invalidate(SID_PREVIEW_ZOOMOUT);
+ rBindings.Invalidate(SID_PREVIEW_SCALINGFACTOR);
+ rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
+}
+
+IMPL_STATIC_LINK( ScPreview, InvalidateHdl, void*, EMPTYARG )
+{
+ (void)pThis; // avoid warning
+
+ StaticInvalidate();
+ return 0;
+}
+
+void ScPreview::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged(rDCEvt);
+
+ if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ if ( rDCEvt.GetType() == DATACHANGED_FONTS )
+ pDocShell->UpdateFontList();
+
+ if ( rDCEvt.GetType() == DATACHANGED_SETTINGS &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ // scroll bar size may have changed
+ pViewShell->InvalidateBorder(); // calls OuterResizePixel
+ }
+
+ Invalidate();
+ InvalidateLocationData( SC_HINT_DATACHANGED );
+ }
+}
+
+//Issue51656 Add resizeable margin on page preview from maoyg
+void __EXPORT ScPreview::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+
+ aButtonDownChangePoint = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
+ aButtonDownPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
+
+ CaptureMouse();
+
+ if( rMEvt.IsLeft() && GetPointer() == POINTER_HSIZEBAR )
+ {
+ SetMapMode( aMMMode );
+ if( bLeftRulerChange )
+ {
+ DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
+ bLeftRulerMove = TRUE;
+ bRightRulerMove = FALSE;
+ }
+ else if( bRightRulerChange )
+ {
+ DrawInvert( aButtonDownChangePoint.X(), POINTER_HSIZEBAR );
+ bLeftRulerMove = FALSE;
+ bRightRulerMove = TRUE;
+ }
+ }
+
+ if( rMEvt.IsLeft() && GetPointer() == POINTER_VSIZEBAR )
+ {
+ SetMapMode( aMMMode );
+ if( bTopRulerChange )
+ {
+ DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
+ bTopRulerMove = TRUE;
+ bBottomRulerMove = FALSE;
+ }
+ else if( bBottomRulerChange )
+ {
+ DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
+ bTopRulerMove = FALSE;
+ bBottomRulerMove = TRUE;
+ }
+ else if( bHeaderRulerChange )
+ {
+ DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
+ bHeaderRulerMove = TRUE;
+ bFooterRulerMove = FALSE;
+ }
+ else if( bFooterRulerChange )
+ {
+ DrawInvert( aButtonDownChangePoint.Y(), POINTER_VSIZEBAR );
+ bHeaderRulerMove = FALSE;
+ bFooterRulerMove = TRUE;
+ }
+ }
+
+ if( rMEvt.IsLeft() && GetPointer() == POINTER_HSPLIT )
+ {
+ Point aNowPt = rMEvt.GetPosPixel();
+ SCCOL i = 0;
+ for( i = aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
+ {
+ if( aNowPt.X() < nRight[i] + 2 && aNowPt.X() > nRight[i] - 2 )
+ {
+ nColNumberButttonDown = i;
+ break;
+ }
+ }
+ if( i == aPageArea.aEnd.Col()+1 )
+ return;
+
+ SetMapMode( aMMMode );
+ if( nColNumberButttonDown == aPageArea.aStart.Col() )
+ DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,POINTER_HSPLIT );
+ else
+ DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
+
+ DrawInvert( aButtonDownChangePoint.X(), POINTER_HSPLIT );
+ bColRulerMove = TRUE;
+ }
+}
+
+void __EXPORT ScPreview::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+
+ aButtonUpPt = PixelToLogic( rMEvt.GetPosPixel(),aMMMode );
+
+ long nWidth = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width();
+ long nHeight = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height();
+
+ if( rMEvt.IsLeft() && GetPointer() == POINTER_HSIZEBAR )
+ {
+ SetPointer( Pointer( POINTER_ARROW ) );
+
+ BOOL bMoveRulerAction= TRUE;
+
+ ScDocument * pDoc = pDocShell->GetDocument();
+ String aOldName = pDoc->GetPageStyle( nTab );
+ BOOL bUndo( pDoc->IsUndoEnabled() );
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
+
+ if ( pStyleSheet )
+ {
+ ScStyleSaveData aOldData;
+ if( bUndo )
+ aOldData.InitFromStyle( pStyleSheet );
+
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+
+ SvxLRSpaceItem aLRItem = ( const SvxLRSpaceItem& ) rStyleSet.Get( ATTR_LRSPACE );
+
+ if(( bLeftRulerChange || bRightRulerChange ) && ( aButtonUpPt.X() <= ( 0 - aOffset.X() ) || aButtonUpPt.X() > nWidth * HMM_PER_TWIPS - aOffset.X() ) )
+ {
+ bMoveRulerAction = FALSE;
+ Paint(Rectangle(0,0,10000,10000));
+ }
+ else if( bLeftRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS > nWidth - aLRItem.GetRight() - aOffset.X() / HMM_PER_TWIPS ) )
+ {
+ bMoveRulerAction = FALSE;
+ Paint(Rectangle(0,0,10000,10000));
+ }
+ else if( bRightRulerChange && ( aButtonUpPt.X() / HMM_PER_TWIPS < aLRItem.GetLeft() - aOffset.X() / HMM_PER_TWIPS ) )
+ {
+ bMoveRulerAction = FALSE;
+ Paint(Rectangle(0,0,10000,10000));
+ }
+ else if( aButtonDownPt.X() == aButtonUpPt.X() )
+ {
+ bMoveRulerAction = FALSE;
+ DrawInvert( aButtonUpPt.X(), POINTER_HSIZEBAR );
+ }
+ if( bMoveRulerAction )
+ {
+ if( bLeftRulerChange && bLeftRulerMove )
+ {
+ aLRItem.SetLeft( (long)( aButtonUpPt.X() / HMM_PER_TWIPS + aOffset.X() / HMM_PER_TWIPS ));
+ rStyleSet.Put( aLRItem );
+ pDocShell->SetModified(true);
+ }
+ else if( bRightRulerChange && bRightRulerMove )
+ {
+ aLRItem.SetRight( (long)( nWidth - aButtonUpPt.X() / HMM_PER_TWIPS - aOffset.X() / HMM_PER_TWIPS ));
+ rStyleSet.Put( aLRItem );
+ pDocShell->SetModified(true);
+ }
+
+ ScStyleSaveData aNewData;
+ aNewData.InitFromStyle( pStyleSheet );
+ if( bUndo )
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoModifyStyle( pDocShell, SFX_STYLE_FAMILY_PAGE,
+ aOldData, aNewData ) );
+ }
+
+ if ( ValidTab( nTab ) )
+ {
+ ScPrintFunc aPrintFunc( pDocShell, this, nTab );
+ aPrintFunc.UpdatePages();
+ }
+
+ Rectangle aRect(0,0,10000,10000);
+ Paint( aRect );
+ bLeftRulerChange = FALSE;
+ bRightRulerChange = FALSE;
+ }
+ }
+ bLeftRulerMove = FALSE;
+ bRightRulerMove = FALSE;
+ }
+
+ if( rMEvt.IsLeft() && GetPointer() == POINTER_VSIZEBAR )
+ {
+ SetPointer( POINTER_ARROW );
+
+ BOOL bMoveRulerAction = TRUE;
+ if( ( bTopRulerChange || bBottomRulerChange || bHeaderRulerChange || bFooterRulerChange ) && ( aButtonUpPt.Y() <= ( 0 - aOffset.Y() ) || aButtonUpPt.Y() > nHeight * HMM_PER_TWIPS -aOffset.Y() ) )
+ {
+ bMoveRulerAction = FALSE;
+ Paint( Rectangle(0,0,10000,10000) );
+ }
+ else if( aButtonDownPt.Y() == aButtonUpPt.Y() )
+ {
+ bMoveRulerAction = FALSE;
+ DrawInvert( aButtonUpPt.Y(), POINTER_VSIZEBAR );
+ }
+ if( bMoveRulerAction )
+ {
+ ScDocument * pDoc = pDocShell->GetDocument();
+ BOOL bUndo( pDoc->IsUndoEnabled() );
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found" );
+ if ( pStyleSheet )
+ {
+ ScStyleSaveData aOldData;
+ if( bUndo )
+ aOldData.InitFromStyle( pStyleSheet );
+
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+
+ SvxULSpaceItem aULItem = ( const SvxULSpaceItem&)rStyleSet.Get( ATTR_ULSPACE );
+
+ if( bTopRulerMove && bTopRulerChange )
+ {
+ aULItem.SetUpperValue( (USHORT)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS ) );
+ rStyleSet.Put( aULItem );
+ pDocShell->SetModified(true);
+ }
+ else if( bBottomRulerMove && bBottomRulerChange )
+ {
+ aULItem.SetLowerValue( (USHORT)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS ) );
+ rStyleSet.Put( aULItem );
+ pDocShell->SetModified(true);
+ }
+ else if( bHeaderRulerMove && bHeaderRulerChange )
+ {
+ const SfxPoolItem* pItem = NULL;
+ if ( rStyleSet.GetItemState( ATTR_PAGE_HEADERSET, FALSE, &pItem ) == SFX_ITEM_SET )
+ {
+ SfxItemSet& pHeaderSet = ((SvxSetItem*)pItem)->GetItemSet();
+ Size aHeaderSize = ((const SvxSizeItem&)pHeaderSet.Get(ATTR_PAGE_SIZE)).GetSize();
+ aHeaderSize.Height() = (long)( aButtonUpPt.Y() / HMM_PER_TWIPS + aOffset.Y() / HMM_PER_TWIPS - aULItem.GetUpper());
+ aHeaderSize.Height() = aHeaderSize.Height() * 100 / mnScale;
+ SvxSetItem aNewHeader( (const SvxSetItem&)rStyleSet.Get(ATTR_PAGE_HEADERSET) );
+ aNewHeader.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aHeaderSize ) );
+ rStyleSet.Put( aNewHeader );
+ pDocShell->SetModified(true);
+ }
+ }
+ else if( bFooterRulerMove && bFooterRulerChange )
+ {
+ const SfxPoolItem* pItem = NULL;
+ if( rStyleSet.GetItemState( ATTR_PAGE_FOOTERSET, FALSE, &pItem ) == SFX_ITEM_SET )
+ {
+ SfxItemSet& pFooterSet = ((SvxSetItem*)pItem)->GetItemSet();
+ Size aFooterSize = ((const SvxSizeItem&)pFooterSet.Get(ATTR_PAGE_SIZE)).GetSize();
+ aFooterSize.Height() = (long)( nHeight - aButtonUpPt.Y() / HMM_PER_TWIPS - aOffset.Y() / HMM_PER_TWIPS - aULItem.GetLower() );
+ aFooterSize.Height() = aFooterSize.Height() * 100 / mnScale;
+ SvxSetItem aNewFooter( (const SvxSetItem&)rStyleSet.Get(ATTR_PAGE_FOOTERSET) );
+ aNewFooter.GetItemSet().Put( SvxSizeItem( ATTR_PAGE_SIZE, aFooterSize ) );
+ rStyleSet.Put( aNewFooter );
+ pDocShell->SetModified(true);
+ }
+ }
+
+ ScStyleSaveData aNewData;
+ aNewData.InitFromStyle( pStyleSheet );
+ if( bUndo )
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoModifyStyle( pDocShell, SFX_STYLE_FAMILY_PAGE,
+ aOldData, aNewData ) );
+ }
+
+ if ( ValidTab( nTab ) )
+ {
+ ScPrintFunc aPrintFunc( pDocShell, this, nTab );
+ aPrintFunc.UpdatePages();
+ }
+
+ Rectangle aRect(0,0,10000,10000);
+ Paint( aRect );
+ bTopRulerChange = FALSE;
+ bBottomRulerChange = FALSE;
+ bHeaderRulerChange = FALSE;
+ bFooterRulerChange = FALSE;
+ }
+ }
+ bTopRulerMove = FALSE;
+ bBottomRulerMove = FALSE;
+ bHeaderRulerMove = FALSE;
+ bFooterRulerMove = FALSE;
+ }
+ if( rMEvt.IsLeft() && GetPointer() == POINTER_HSPLIT )
+ {
+ SetPointer(POINTER_ARROW);
+ ScDocument* pDoc = pDocShell->GetDocument();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ BOOL bMoveRulerAction = TRUE;
+ if( aButtonDownPt.X() == aButtonUpPt.X() )
+ {
+ bMoveRulerAction = FALSE;
+ if( nColNumberButttonDown == aPageArea.aStart.Col() )
+ DrawInvert( PixelToLogic( Point( nLeftPosition, 0 ),aMMMode ).X() ,POINTER_HSPLIT );
+ else
+ DrawInvert( PixelToLogic( Point( nRight[ nColNumberButttonDown-1 ], 0 ),aMMMode ).X() ,POINTER_HSPLIT );
+ DrawInvert( aButtonUpPt.X(), POINTER_HSPLIT );
+ }
+ if( bMoveRulerAction )
+ {
+ long nNewColWidth = 0;
+ ScDocFunc aFunc(*pDocShell);
+ SCCOLROW nCols[2] = { nColNumberButttonDown, nColNumberButttonDown };
+
+ if( !bLayoutRTL )
+ {
+ nNewColWidth = (long) ( PixelToLogic( Point( rMEvt.GetPosPixel().X() - nRight[ nColNumberButttonDown ], 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
+ nNewColWidth += pDocShell->GetDocument()->GetColWidth( nColNumberButttonDown, nTab );
+ }
+ else
+ {
+
+ nNewColWidth = (long) ( PixelToLogic( Point( nRight[ nColNumberButttonDown ] - rMEvt.GetPosPixel().X(), 0), aMMMode ).X() / HMM_PER_TWIPS ) * 100 / mnScale;
+ nNewColWidth += pDocShell->GetDocument()->GetColWidth( nColNumberButttonDown, nTab );
+ }
+
+ if( nNewColWidth >= 0 )
+ {
+ aFunc.SetWidthOrHeight( TRUE, 1,nCols, nTab, SC_SIZE_DIRECT, (USHORT)nNewColWidth, TRUE, TRUE);
+ pDocShell->SetModified(true);
+ }
+ if ( ValidTab( nTab ) )
+ {
+ ScPrintFunc aPrintFunc( pDocShell, this, nTab );
+ aPrintFunc.UpdatePages();
+ }
+ Rectangle nRect(0,0,10000,10000);
+ Paint( nRect );
+ }
+ bColRulerMove = FALSE;
+ }
+ ReleaseMouse();
+}
+
+void __EXPORT ScPreview::MouseMove( const MouseEvent& rMEvt )
+{
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+ Point aMouseMovePoint = PixelToLogic( rMEvt.GetPosPixel(), aMMMode );
+
+ long nLeftMargin = 0;
+ long nRightMargin = 0;
+ long nTopMargin = 0;
+ long nBottomMargin = 0;
+ Size PageSize;
+
+ long nWidth = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Width();
+ long nHeight = (long) lcl_GetDocPageSize(pDocShell->GetDocument(), nTab).Height();
+
+ if ( nPageNo < nTotalPages )
+ {
+ ScPrintOptions aOptions = SC_MOD()->GetPrintOptions();
+
+ ScPrintFunc* pPrintFunc;
+
+ if (bStateValid)
+ pPrintFunc = new ScPrintFunc( pDocShell, this, aState, &aOptions );
+ else
+ pPrintFunc = new ScPrintFunc( pDocShell, this, nTab, nFirstAttr[nTab], nTotalPages, NULL, &aOptions );
+
+ nLeftMargin = (long)( pPrintFunc->GetLeftMargin() * HMM_PER_TWIPS - aOffset.X() );
+ nRightMargin = (long)( pPrintFunc->GetRightMargin() * HMM_PER_TWIPS );
+ nRightMargin = (long)( nWidth * HMM_PER_TWIPS - nRightMargin - aOffset.X() );
+ nTopMargin = (long)( pPrintFunc->GetTopMargin() * HMM_PER_TWIPS - aOffset.Y() );
+ nBottomMargin = (long)( pPrintFunc->GetBottomMargin() * HMM_PER_TWIPS );
+ nBottomMargin = (long)( nHeight * HMM_PER_TWIPS - nBottomMargin - aOffset.Y() );
+ if( mnScale > 0 )
+ {
+ nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS * mnScale / 100 );
+ nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS * mnScale / 100 );
+ }
+ else
+ {
+ nHeaderHeight = (long)( nTopMargin + pPrintFunc->GetHeader().nHeight * HMM_PER_TWIPS );
+ nFooterHeight = (long)( nBottomMargin - pPrintFunc->GetFooter().nHeight * HMM_PER_TWIPS );
+ }
+ delete pPrintFunc;
+ }
+
+ Point aPixPt( rMEvt.GetPosPixel() );
+ Point aLeftTop = LogicToPixel( Point( nLeftMargin, -aOffset.Y() ) , aMMMode );
+ Point aLeftBottom = LogicToPixel( Point( nLeftMargin ,(long)(nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
+ Point aRightTop = LogicToPixel( Point( nRightMargin, -aOffset.Y() ), aMMMode );
+ Point aTopLeft = LogicToPixel( Point( -aOffset.X(), nTopMargin ), aMMMode );
+ Point aTopRight = LogicToPixel( Point( (long)(nWidth * HMM_PER_TWIPS - aOffset.X()), nTopMargin ), aMMMode );
+ Point aBottomLeft = LogicToPixel( Point( -aOffset.X(), nBottomMargin ), aMMMode );
+ Point aHeaderLeft = LogicToPixel( Point( -aOffset.X(), nHeaderHeight ), aMMMode );
+ Point aFooderLeft = LogicToPixel( Point( -aOffset.X(), nFooterHeight ), aMMMode );
+
+ BOOL bOnColRulerChange = FALSE;
+
+ for( SCCOL i=aPageArea.aStart.Col(); i<= aPageArea.aEnd.Col(); i++ )
+ {
+ Point aColumnTop = LogicToPixel( Point( 0, -aOffset.Y() ) ,aMMMode );
+ Point aColumnBottom = LogicToPixel( Point( 0, (long)( nHeight * HMM_PER_TWIPS - aOffset.Y()) ), aMMMode );
+ if( aPixPt.X() < ( nRight[i] + 2 ) && ( aPixPt.X() > ( nRight[i] - 2 ) ) && ( aPixPt.X() < aRightTop.X() ) && ( aPixPt.X() > aLeftTop.X() )
+ && ( aPixPt.Y() > aColumnTop.Y() ) && ( aPixPt.Y() < aColumnBottom.Y() ) && !bLeftRulerMove && !bRightRulerMove
+ && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
+ {
+ bOnColRulerChange = TRUE;
+ if( !rMEvt.GetButtons() && GetPointer() == POINTER_HSPLIT )
+ nColNumberButttonDown = i;
+ break;
+ }
+ }
+
+ if( aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 ) && !bRightRulerMove )
+ {
+ bLeftRulerChange = TRUE;
+ bRightRulerChange = FALSE;
+ }
+ else if( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) && !bLeftRulerMove )
+ {
+ bLeftRulerChange = FALSE;
+ bRightRulerChange = TRUE;
+ }
+ else if( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
+ {
+ bTopRulerChange = TRUE;
+ bBottomRulerChange = FALSE;
+ bHeaderRulerChange = FALSE;
+ bFooterRulerChange = FALSE;
+ }
+ else if( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) && !bTopRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
+ {
+ bTopRulerChange = FALSE;
+ bBottomRulerChange = TRUE;
+ bHeaderRulerChange = FALSE;
+ bFooterRulerChange = FALSE;
+ }
+ else if( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bFooterRulerMove )
+ {
+ bTopRulerChange = FALSE;
+ bBottomRulerChange = FALSE;
+ bHeaderRulerChange = TRUE;
+ bFooterRulerChange = FALSE;
+ }
+ else if( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove )
+ {
+ bTopRulerChange = FALSE;
+ bBottomRulerChange = FALSE;
+ bHeaderRulerChange = FALSE;
+ bFooterRulerChange = TRUE;
+ }
+
+ if( bPageMargin )
+ {
+ if(( (aPixPt.X() < ( aLeftTop.X() + 2 ) && aPixPt.X() > ( aLeftTop.X() - 2 )) || bLeftRulerMove ||
+ ( aPixPt.X() < ( aRightTop.X() + 2 ) && aPixPt.X() > ( aRightTop.X() - 2 ) ) || bRightRulerMove || bOnColRulerChange || bColRulerMove )
+ && aPixPt.Y() > aLeftTop.Y() && aPixPt.Y() < aLeftBottom.Y() )
+ {
+ if( bOnColRulerChange || bColRulerMove )
+ {
+ SetPointer( Pointer( POINTER_HSPLIT ) );
+ if( bColRulerMove )
+ {
+ if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
+ DragMove( aMouseMovePoint.X(), POINTER_HSPLIT );
+ }
+ }
+ else
+ {
+ if( bLeftRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
+ {
+ SetPointer( Pointer( POINTER_HSIZEBAR ) );
+ if( bLeftRulerMove )
+ {
+ if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
+ DragMove( aMouseMovePoint.X(), POINTER_HSIZEBAR );
+ }
+ }
+ else if( bRightRulerChange && !bTopRulerMove && !bBottomRulerMove && !bHeaderRulerMove && !bFooterRulerMove )
+ {
+ SetPointer( Pointer( POINTER_HSIZEBAR ) );
+ if( bRightRulerMove )
+ {
+ if( aMouseMovePoint.X() > -aOffset.X() && aMouseMovePoint.X() < nWidth * HMM_PER_TWIPS - aOffset.X() )
+ DragMove( aMouseMovePoint.X(), POINTER_HSIZEBAR );
+ }
+ }
+ }
+ }
+ else
+ {
+ if( ( ( aPixPt.Y() < ( aTopLeft.Y() + 2 ) && aPixPt.Y() > ( aTopLeft.Y() - 2 ) ) || bTopRulerMove ||
+ ( aPixPt.Y() < ( aBottomLeft.Y() + 2 ) && aPixPt.Y() > ( aBottomLeft.Y() - 2 ) ) || bBottomRulerMove ||
+ ( aPixPt.Y() < ( aHeaderLeft.Y() + 2 ) && aPixPt.Y() > ( aHeaderLeft.Y() - 2 ) ) || bHeaderRulerMove ||
+ ( aPixPt.Y() < ( aFooderLeft.Y() + 2 ) && aPixPt.Y() > ( aFooderLeft.Y() - 2 ) ) || bFooterRulerMove )
+ && aPixPt.X() > aTopLeft.X() && aPixPt.X() < aTopRight.X() )
+ {
+ if( bTopRulerChange )
+ {
+ SetPointer( Pointer( POINTER_VSIZEBAR ) );
+ if( bTopRulerMove )
+ {
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
+ }
+ }
+ else if( bBottomRulerChange )
+ {
+ SetPointer( Pointer( POINTER_VSIZEBAR ) );
+ if( bBottomRulerMove )
+ {
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
+ }
+ }
+ else if( bHeaderRulerChange )
+ {
+ SetPointer( Pointer( POINTER_VSIZEBAR ) );
+ if( bHeaderRulerMove )
+ {
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
+ }
+ }
+ else if( bFooterRulerChange )
+ {
+ SetPointer( Pointer( POINTER_VSIZEBAR ) );
+ if( bFooterRulerMove )
+ {
+ if( aMouseMovePoint.Y() > -aOffset.Y() && aMouseMovePoint.Y() < nHeight * HMM_PER_TWIPS - aOffset.Y() )
+ DragMove( aMouseMovePoint.Y(), POINTER_VSIZEBAR );
+ }
+ }
+ }
+ else
+ SetPointer( Pointer( POINTER_ARROW ) );
+ }
+ }
+}
+//Issue51656 Add resizeable margin on page preview from maoyg
+void ScPreview::InvalidateLocationData(ULONG nId)
+{
+ bLocationValid = FALSE;
+ if (pViewShell->HasAccessibilityObjects())
+ pViewShell->BroadcastAccessibility( SfxSimpleHint( nId ) );
+}
+
+void ScPreview::GetFocus()
+{
+ if (pViewShell->HasAccessibilityObjects())
+ pViewShell->BroadcastAccessibility( ScAccWinFocusGotHint(GetAccessible()) );
+}
+
+void ScPreview::LoseFocus()
+{
+ if (pViewShell->HasAccessibilityObjects())
+ pViewShell->BroadcastAccessibility( ScAccWinFocusLostHint(GetAccessible()) );
+}
+
+com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible> ScPreview::CreateAccessible()
+{
+ ScAccessibleDocumentPagePreview* pAccessible =
+ new ScAccessibleDocumentPagePreview( GetAccessibleParentWindow()->GetAccessible(), pViewShell );
+ com::sun::star::uno::Reference < com::sun::star::accessibility::XAccessible > xAccessible = pAccessible;
+ pAccessible->Init();
+ return xAccessible;
+}
+
+//Issue51656 Add resizeable margin on page preview from maoyg
+void ScPreview::DragMove( long nDragMovePos, USHORT nFlags )
+{
+ Fraction aPreviewZoom( nZoom, 100 );
+ Fraction aHorPrevZoom( (long)( 100 * nZoom / pDocShell->GetOutputFactor() ), 10000 );
+ MapMode aMMMode( MAP_100TH_MM, Point(), aHorPrevZoom, aPreviewZoom );
+ SetMapMode( aMMMode );
+ long nPos = nDragMovePos;
+ if( nFlags == POINTER_HSIZEBAR || nFlags == POINTER_HSPLIT )
+ {
+ if( nDragMovePos != aButtonDownChangePoint.X() )
+ {
+ DrawInvert( aButtonDownChangePoint.X(), nFlags );
+ aButtonDownChangePoint.X() = nPos;
+ DrawInvert( aButtonDownChangePoint.X(), nFlags );
+ }
+ }
+ else if( nFlags == POINTER_VSIZEBAR )
+ {
+ if( nDragMovePos != aButtonDownChangePoint.Y() )
+ {
+ DrawInvert( aButtonDownChangePoint.Y(), nFlags );
+ aButtonDownChangePoint.Y() = nPos;
+ DrawInvert( aButtonDownChangePoint.Y(), nFlags );
+ }
+ }
+}
+
+void ScPreview::DrawInvert( long nDragPos, USHORT nFlags )
+{
+ long nHeight = (long) lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ).Height();
+ long nWidth = (long) lcl_GetDocPageSize( pDocShell->GetDocument(), nTab ).Width();
+ if( nFlags == POINTER_HSIZEBAR || nFlags == POINTER_HSPLIT )
+ {
+ Rectangle aRect( nDragPos, -aOffset.Y(), nDragPos + 1,(long)( ( nHeight * HMM_PER_TWIPS ) - aOffset.Y()));
+ Invert( aRect,INVERT_50 );
+ }
+ else if( nFlags == POINTER_VSIZEBAR )
+ {
+ Rectangle aRect( -aOffset.X(), nDragPos,(long)( ( nWidth * HMM_PER_TWIPS ) - aOffset.X() ), nDragPos + 1 );
+ Invert( aRect,INVERT_50 );
+ }
+}
+//Issue51656 Add resizeable margin on page preview from maoyg
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx
new file mode 100644
index 000000000000..94580c084ca1
--- /dev/null
+++ b/sc/source/ui/view/prevloc.cxx
@@ -0,0 +1,756 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/outdev.hxx>
+#include <tools/debug.hxx>
+
+#include "prevloc.hxx"
+#include "document.hxx"
+
+//==================================================================
+
+enum ScPreviewLocationType
+{
+ SC_PLOC_CELLRANGE,
+ SC_PLOC_COLHEADER,
+ SC_PLOC_ROWHEADER,
+ SC_PLOC_LEFTHEADER,
+ SC_PLOC_RIGHTHEADER,
+ SC_PLOC_LEFTFOOTER,
+ SC_PLOC_RIGHTFOOTER,
+ SC_PLOC_NOTEMARK,
+ SC_PLOC_NOTETEXT
+};
+
+struct ScPreviewLocationEntry
+{
+ ScPreviewLocationType eType;
+ Rectangle aPixelRect;
+ ScRange aCellRange;
+ BOOL bRepeatCol;
+ BOOL bRepeatRow;
+
+ ScPreviewLocationEntry( ScPreviewLocationType eNewType, const Rectangle& rPixel, const ScRange& rRange,
+ BOOL bRepCol, BOOL bRepRow ) :
+ eType( eNewType ),
+ aPixelRect( rPixel ),
+ aCellRange( rRange ),
+ bRepeatCol( bRepCol ),
+ bRepeatRow( bRepRow )
+ {
+ }
+};
+
+//==================================================================
+
+ScPreviewTableInfo::ScPreviewTableInfo() :
+ nTab(0),
+ nCols(0),
+ nRows(0),
+ pColInfo(NULL),
+ pRowInfo(NULL)
+{
+}
+
+ScPreviewTableInfo::~ScPreviewTableInfo()
+{
+ delete[] pColInfo;
+ delete[] pRowInfo;
+}
+
+void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
+{
+ nTab = nNewTab;
+}
+
+void ScPreviewTableInfo::SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo )
+{
+ delete[] pColInfo;
+ pColInfo = pNewInfo;
+ nCols = nCount;
+}
+
+void ScPreviewTableInfo::SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo )
+{
+ delete[] pRowInfo;
+ pRowInfo = pNewInfo;
+ nRows = nCount;
+}
+
+void ScPreviewTableInfo::LimitToArea( const Rectangle& rPixelArea )
+{
+ if ( pColInfo )
+ {
+ // cells completely left of the visible area
+ SCCOL nStart = 0;
+ while ( nStart < nCols && pColInfo[nStart].nPixelEnd < rPixelArea.Left() )
+ ++nStart;
+
+ // cells completely right of the visible area
+ SCCOL nEnd = nCols;
+ while ( nEnd > 0 && pColInfo[nEnd-1].nPixelStart > rPixelArea.Right() )
+ --nEnd;
+
+ if ( nStart > 0 || nEnd < nCols )
+ {
+ if ( nEnd > nStart )
+ {
+ SCCOL nNewCount = nEnd - nStart;
+ ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
+ for (SCCOL i=0; i<nNewCount; i++)
+ pNewInfo[i] = pColInfo[nStart + i];
+ SetColInfo( nNewCount, pNewInfo );
+ }
+ else
+ SetColInfo( 0, NULL ); // all invisible
+ }
+ }
+
+ if ( pRowInfo )
+ {
+ // cells completely above the visible area
+ SCROW nStart = 0;
+ while ( nStart < nRows && pRowInfo[nStart].nPixelEnd < rPixelArea.Top() )
+ ++nStart;
+
+ // cells completely below the visible area
+ SCROW nEnd = nRows;
+ while ( nEnd > 0 && pRowInfo[nEnd-1].nPixelStart > rPixelArea.Bottom() )
+ --nEnd;
+
+ if ( nStart > 0 || nEnd < nRows )
+ {
+ if ( nEnd > nStart )
+ {
+ SCROW nNewCount = nEnd - nStart;
+ ScPreviewColRowInfo* pNewInfo = new ScPreviewColRowInfo[nNewCount];
+ for (SCROW i=0; i<nNewCount; i++)
+ pNewInfo[i] = pRowInfo[nStart + i];
+ SetRowInfo( nNewCount, pNewInfo );
+ }
+ else
+ SetRowInfo( 0, NULL ); // all invisible
+ }
+ }
+}
+
+//------------------------------------------------------------------
+
+ScPreviewLocationData::ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin ) :
+ pWindow( pWin ),
+ pDoc( pDocument ),
+ nDrawRanges( 0 ),
+ nPrintTab( 0 )
+{
+}
+
+ScPreviewLocationData::~ScPreviewLocationData()
+{
+ Clear();
+}
+
+void ScPreviewLocationData::SetCellMapMode( const MapMode& rMapMode )
+{
+ aCellMapMode = rMapMode;
+}
+
+void ScPreviewLocationData::SetPrintTab( SCTAB nNew )
+{
+ nPrintTab = nNew;
+}
+
+void ScPreviewLocationData::Clear()
+{
+ void* pEntry = aEntries.First();
+ while ( pEntry )
+ {
+ delete (ScPreviewLocationEntry*) pEntry;
+ pEntry = aEntries.Next();
+ }
+ aEntries.Clear();
+
+ nDrawRanges = 0;
+}
+
+void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange& rRange, BOOL bRepCol, BOOL bRepRow,
+ const MapMode& rDrawMap )
+{
+ Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
+ aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) );
+
+ DBG_ASSERT( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" );
+ if ( nDrawRanges < SC_PREVIEW_MAXRANGES )
+ {
+ aDrawRectangle[nDrawRanges] = aPixelRect;
+ aDrawMapMode[nDrawRanges] = rDrawMap;
+ if (bRepCol)
+ if (bRepRow)
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_EDGE;
+ else
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPCOL;
+ else
+ if (bRepRow)
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_REPROW;
+ else
+ aDrawRangeId[nDrawRanges] = SC_PREVIEW_RANGE_TAB;
+ ++nDrawRanges;
+ }
+}
+
+void ScPreviewLocationData::AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, BOOL bRepCol )
+{
+ SCTAB nTab = 0; //! ?
+ ScRange aRange( nStartCol, 0, nTab, nEndCol, 0, nTab );
+ Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
+ aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_COLHEADER, aPixelRect, aRange, bRepCol, FALSE ) );
+}
+
+void ScPreviewLocationData::AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, BOOL bRepRow )
+{
+ SCTAB nTab = 0; //! ?
+ ScRange aRange( 0, nStartRow, nTab, 0, nEndRow, nTab );
+ Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
+ aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER, aPixelRect, aRange, FALSE, bRepRow ) );
+}
+
+void ScPreviewLocationData::AddHeaderFooter( const Rectangle& rRect, BOOL bHeader, BOOL bLeft )
+{
+ ScRange aRange; //! ?
+ Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
+
+ ScPreviewLocationType eType = bHeader ?
+ ( bLeft ? SC_PLOC_LEFTHEADER : SC_PLOC_RIGHTHEADER ) :
+ ( bLeft ? SC_PLOC_LEFTFOOTER : SC_PLOC_RIGHTFOOTER );
+ aEntries.Insert( new ScPreviewLocationEntry( eType, aPixelRect, aRange, FALSE, FALSE ) );
+}
+
+void ScPreviewLocationData::AddNoteMark( const Rectangle& rRect, const ScAddress& rPos )
+{
+ ScRange aRange( rPos );
+ Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
+ aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK, aPixelRect, aRange, FALSE, FALSE ) );
+}
+
+void ScPreviewLocationData::AddNoteText( const Rectangle& rRect, const ScAddress& rPos )
+{
+ ScRange aRange( rPos );
+ Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) );
+ aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT, aPixelRect, aRange, FALSE, FALSE ) );
+}
+
+//------------------------------------------------------------------
+
+void ScPreviewLocationData::GetDrawRange( USHORT nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const
+{
+ DBG_ASSERT( nPos < nDrawRanges, "wrong position" );
+ if ( nPos < nDrawRanges )
+ {
+ rPixelRect = aDrawRectangle[nPos];
+ rMapMode = aDrawMapMode[nPos];
+ rRangeId = aDrawRangeId[nPos];
+ }
+}
+
+ScPreviewLocationEntry* lcl_GetEntryByAddress( const List& rEntries, const ScAddress& rPos, ScPreviewLocationType eType )
+{
+ ULONG nCount = rEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)rEntries.GetObject(nListPos);
+ if ( pEntry->eType == eType && pEntry->aCellRange.In( rPos ) )
+ return pEntry;
+ }
+ return NULL;
+}
+
+
+Rectangle ScPreviewLocationData::GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const
+{
+ const double nScaleX = HMM_PER_TWIPS;
+ const double nScaleY = HMM_PER_TWIPS;
+ SCTAB nTab = rRange.aStart.Tab();
+
+ long nPosX = 0;
+ SCCOL nEndCol = rCellPos.Col();
+ for (SCCOL nCol = rRange.aStart.Col(); nCol < nEndCol; nCol++)
+ {
+ USHORT nDocW = pDoc->GetColWidth( nCol, nTab );
+ if (nDocW)
+ nPosX += (long) (nDocW * nScaleX);
+ }
+ long nSizeX = (long) ( pDoc->GetColWidth( nEndCol, nTab ) * nScaleX );
+
+ SCROW nEndRow = rCellPos.Row();
+ long nPosY = (long) pDoc->GetScaledRowHeight( rRange.aStart.Row(),
+ nEndRow, nTab, nScaleY);
+ long nSizeY = (long) ( pDoc->GetRowHeight( nEndRow, nTab ) * nScaleY );
+
+ Size aOffsetLogic( nPosX, nPosY );
+ Size aSizeLogic( nSizeX, nSizeY );
+ Size aOffsetPixel = pWindow->LogicToPixel( aOffsetLogic, aCellMapMode );
+ Size aSizePixel = pWindow->LogicToPixel( aSizeLogic, aCellMapMode );
+
+ return Rectangle( Point( aOffsetPixel.Width(), aOffsetPixel.Height() ), aSizePixel );
+}
+
+BOOL ScPreviewLocationData::GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const
+{
+ ScPreviewLocationEntry* pEntry = lcl_GetEntryByAddress( aEntries, rCellPos, SC_PLOC_CELLRANGE );
+ if ( pEntry )
+ {
+ Rectangle aOffsetRect = GetOffsetPixel( rCellPos, pEntry->aCellRange );
+ rCellRect = Rectangle( aOffsetRect.Left() + pEntry->aPixelRect.Left(),
+ aOffsetRect.Top() + pEntry->aPixelRect.Top(),
+ aOffsetRect.Right() + pEntry->aPixelRect.Left(),
+ aOffsetRect.Bottom() + pEntry->aPixelRect.Top() );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL ScPreviewLocationData::HasCellsInRange( const Rectangle& rVisiblePixel ) const
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ ScPreviewLocationType eType = pEntry->eType;
+ if ( eType == SC_PLOC_CELLRANGE || eType == SC_PLOC_COLHEADER || eType == SC_PLOC_ROWHEADER )
+ if ( pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL ScPreviewLocationData::GetHeaderPosition( Rectangle& rRect ) const
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == SC_PLOC_LEFTHEADER || pEntry->eType == SC_PLOC_RIGHTHEADER )
+ {
+ rRect = pEntry->aPixelRect;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL ScPreviewLocationData::GetFooterPosition( Rectangle& rRect ) const
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == SC_PLOC_LEFTFOOTER || pEntry->eType == SC_PLOC_RIGHTFOOTER )
+ {
+ rRect = pEntry->aPixelRect;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+BOOL ScPreviewLocationData::IsHeaderLeft() const
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == SC_PLOC_LEFTHEADER )
+ return TRUE;
+ if ( pEntry->eType == SC_PLOC_RIGHTHEADER )
+ return FALSE;
+ }
+ return FALSE;
+}
+
+BOOL ScPreviewLocationData::IsFooterLeft() const
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == SC_PLOC_LEFTFOOTER )
+ return TRUE;
+ if ( pEntry->eType == SC_PLOC_RIGHTFOOTER )
+ return FALSE;
+ }
+ return FALSE;
+}
+
+long ScPreviewLocationData::GetNoteCountInRange( const Rectangle& rVisiblePixel, BOOL bNoteMarks ) const
+{
+ ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
+
+ ULONG nRet = 0;
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ ++nRet;
+ }
+ return nRet;
+}
+
+BOOL ScPreviewLocationData::GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, BOOL bNoteMarks,
+ ScAddress& rCellPos, Rectangle& rNoteRect ) const
+{
+ ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
+
+ ULONG nPos = 0;
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ {
+ if ( nPos == sal::static_int_cast<ULONG>(nIndex) )
+ {
+ rCellPos = pEntry->aCellRange.aStart;
+ rNoteRect = pEntry->aPixelRect;
+ return TRUE;
+ }
+ ++nPos;
+ }
+ }
+ return FALSE;
+}
+
+Rectangle ScPreviewLocationData::GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, BOOL bNoteMarks, const ScAddress& aCellPos) const
+{
+ ScPreviewLocationType eType = bNoteMarks ? SC_PLOC_NOTEMARK : SC_PLOC_NOTETEXT;
+
+ ULONG nPos = 0;
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == eType && pEntry->aPixelRect.IsOver( rVisiblePixel ) )
+ {
+ if ( aCellPos == pEntry->aCellRange.aStart )
+ return pEntry->aPixelRect;
+ ++nPos;
+ }
+ }
+ return Rectangle();
+}
+
+void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const
+{
+ const double nScaleX = HMM_PER_TWIPS;
+ const double nScaleY = HMM_PER_TWIPS;
+
+ // from left to right:
+ BOOL bHasHeaderCol = FALSE;
+ BOOL bHasRepCols = FALSE;
+ BOOL bHasMainCols = FALSE;
+ SCCOL nRepeatColStart = 0;
+ SCCOL nRepeatColEnd = 0;
+ SCCOL nMainColStart = 0;
+ SCCOL nMainColEnd = 0;
+
+ // from top to bottom:
+ BOOL bHasHeaderRow = FALSE;
+ BOOL bHasRepRows = FALSE;
+ BOOL bHasMainRows = FALSE;
+ SCROW nRepeatRowStart = 0;
+ SCROW nRepeatRowEnd = 0;
+ SCROW nMainRowStart = 0;
+ SCROW nMainRowEnd = 0;
+
+ Rectangle aHeaderRect, aRepeatRect, aMainRect;
+ SCTAB nTab = 0;
+
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == SC_PLOC_CELLRANGE )
+ {
+ if ( pEntry->bRepeatCol )
+ {
+ bHasRepCols = TRUE;
+ nRepeatColStart = pEntry->aCellRange.aStart.Col();
+ nRepeatColEnd = pEntry->aCellRange.aEnd.Col();
+ aRepeatRect.Left() = pEntry->aPixelRect.Left();
+ aRepeatRect.Right() = pEntry->aPixelRect.Right();
+ }
+ else
+ {
+ bHasMainCols = TRUE;
+ nMainColStart = pEntry->aCellRange.aStart.Col();
+ nMainColEnd = pEntry->aCellRange.aEnd.Col();
+ aMainRect.Left() = pEntry->aPixelRect.Left();
+ aMainRect.Right() = pEntry->aPixelRect.Right();
+ }
+ if ( pEntry->bRepeatRow )
+ {
+ bHasRepRows = TRUE;
+ nRepeatRowStart = pEntry->aCellRange.aStart.Row();
+ nRepeatRowEnd = pEntry->aCellRange.aEnd.Row();
+ aRepeatRect.Top() = pEntry->aPixelRect.Top();
+ aRepeatRect.Bottom() = pEntry->aPixelRect.Bottom();
+ }
+ else
+ {
+ bHasMainRows = TRUE;
+ nMainRowStart = pEntry->aCellRange.aStart.Row();
+ nMainRowEnd = pEntry->aCellRange.aEnd.Row();
+ aMainRect.Top() = pEntry->aPixelRect.Top();
+ aMainRect.Bottom() = pEntry->aPixelRect.Bottom();
+ }
+ nTab = pEntry->aCellRange.aStart.Tab(); //! store separately?
+ }
+ else if ( pEntry->eType == SC_PLOC_ROWHEADER )
+ {
+ // row headers result in an additional column
+ bHasHeaderCol = TRUE;
+ aHeaderRect.Left() = pEntry->aPixelRect.Left();
+ aHeaderRect.Right() = pEntry->aPixelRect.Right();
+ }
+ else if ( pEntry->eType == SC_PLOC_COLHEADER )
+ {
+ // column headers result in an additional row
+ bHasHeaderRow = TRUE;
+ aHeaderRect.Top() = pEntry->aPixelRect.Top();
+ aHeaderRect.Bottom() = pEntry->aPixelRect.Bottom();
+ }
+ }
+
+ //
+ // get column info
+ //
+
+ SCCOL nColCount = 0;
+ SCCOL nCol;
+ if ( bHasHeaderCol )
+ ++nColCount;
+ if ( bHasRepCols )
+ for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
+ if (!pDoc->ColHidden(nCol, nTab))
+ ++nColCount;
+ if ( bHasMainCols )
+ for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
+ if (!pDoc->ColHidden(nCol, nTab))
+ ++nColCount;
+
+ if ( nColCount > 0 )
+ {
+ ScPreviewColRowInfo* pColInfo = new ScPreviewColRowInfo[ nColCount ];
+ SCCOL nColPos = 0;
+
+ if ( bHasHeaderCol )
+ {
+ pColInfo[nColPos].Set( TRUE, 0, aHeaderRect.Left(), aHeaderRect.Right() );
+ ++nColPos;
+ }
+ if ( bHasRepCols )
+ {
+ long nPosX = 0;
+ for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
+ if (!pDoc->ColHidden(nCol, nTab))
+ {
+ USHORT nDocW = pDoc->GetColWidth( nCol, nTab );
+ long nNextX = nPosX + (long) (nDocW * nScaleX);
+
+ long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
+ long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
+ pColInfo[nColPos].Set( FALSE, nCol,
+ aRepeatRect.Left() + nPixelStart,
+ aRepeatRect.Left() + nPixelEnd );
+
+ nPosX = nNextX;
+ ++nColPos;
+ }
+ }
+ if ( bHasMainCols )
+ {
+ long nPosX = 0;
+ for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
+ if (!pDoc->ColHidden(nCol, nTab))
+ {
+ USHORT nDocW = pDoc->GetColWidth( nCol, nTab );
+ long nNextX = nPosX + (long) (nDocW * nScaleX);
+
+ long nPixelStart = pWindow->LogicToPixel( Size( nPosX, 0 ), aCellMapMode ).Width();
+ long nPixelEnd = pWindow->LogicToPixel( Size( nNextX, 0 ), aCellMapMode ).Width() - 1;
+ pColInfo[nColPos].Set( FALSE, nCol,
+ aMainRect.Left() + nPixelStart,
+ aMainRect.Left() + nPixelEnd );
+
+ nPosX = nNextX;
+ ++nColPos;
+ }
+ }
+ rInfo.SetColInfo( nColCount, pColInfo );
+ }
+ else
+ rInfo.SetColInfo( 0, NULL );
+
+ //
+ // get row info
+ //
+
+ SCROW nRowCount = 0;
+ if ( bHasHeaderRow )
+ ++nRowCount;
+ if ( bHasRepRows )
+ nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
+ if ( bHasMainRows )
+ nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
+
+ if ( nRowCount > 0 )
+ {
+ ScPreviewColRowInfo* pRowInfo = new ScPreviewColRowInfo[ nRowCount ];
+ SCROW nRowPos = 0;
+
+ if ( bHasHeaderRow )
+ {
+ pRowInfo[nRowPos].Set( TRUE, 0, aHeaderRect.Top(), aHeaderRect.Bottom() );
+ ++nRowPos;
+ }
+ if ( bHasRepRows )
+ {
+ long nPosY = 0;
+ for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
+ {
+ if (pDoc->RowHidden(nRow, nTab))
+ continue;
+
+ USHORT nDocH = pDoc->GetOriginalHeight( nRow, nTab );
+ long nNextY = nPosY + (long) (nDocH * nScaleY);
+
+ long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
+ long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
+ pRowInfo[nRowPos].Set( FALSE, nRow,
+ aRepeatRect.Top() + nPixelStart,
+ aRepeatRect.Top() + nPixelEnd );
+
+ nPosY = nNextY;
+ ++nRowPos;
+ }
+ }
+ if ( bHasMainRows )
+ {
+ long nPosY = 0;
+ for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
+ {
+ if (pDoc->RowHidden(nRow, nTab))
+ continue;
+
+ USHORT nDocH = pDoc->GetOriginalHeight( nRow, nTab );
+ long nNextY = nPosY + (long) (nDocH * nScaleY);
+
+ long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
+ long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
+ pRowInfo[nRowPos].Set( FALSE, nRow,
+ aMainRect.Top() + nPixelStart,
+ aMainRect.Top() + nPixelEnd );
+
+ nPosY = nNextY;
+ ++nRowPos;
+ }
+ }
+ rInfo.SetRowInfo( nRowCount, pRowInfo );
+ }
+ else
+ rInfo.SetRowInfo( 0, NULL );
+
+ //
+ // limit to visible area
+ //
+
+ rInfo.SetTab( nTab );
+ rInfo.LimitToArea( rVisiblePixel );
+}
+
+Rectangle ScPreviewLocationData::GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const
+{
+ // first a stupid implementation
+ // NN says here should be done more
+ Rectangle aClipRect;
+ ScPreviewTableInfo aTableInfo;
+ GetTableInfo( rVisRect, aTableInfo );
+
+ if ( (rCellPos.Col() >= 0) &&
+ (rCellPos.Row() >= 0) && (rCellPos.Col() < aTableInfo.GetCols()) &&
+ (rCellPos.Row() < aTableInfo.GetRows()) )
+ {
+ SCCOL nCol(0);
+ SCROW nRow(0);
+ if (bColHeader)
+ nCol = rCellPos.Col();
+ else
+ nRow = rCellPos.Row();
+ const ScPreviewColRowInfo& rColInfo = aTableInfo.GetColInfo()[nCol];
+ const ScPreviewColRowInfo& rRowInfo = aTableInfo.GetRowInfo()[nRow];
+
+ if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
+ aClipRect = Rectangle( rColInfo.nPixelStart, rRowInfo.nPixelStart, rColInfo.nPixelEnd, rRowInfo.nPixelEnd );
+ }
+ return aClipRect;
+}
+
+Rectangle ScPreviewLocationData::GetCellOutputRect(const ScAddress& rCellPos) const
+{
+ // first a stupid implementation
+ // NN says here should be done more
+ Rectangle aRect;
+ GetCellPosition(rCellPos, aRect);
+ return aRect;
+}
+
+// GetMainCellRange is used for links in PDF export
+
+BOOL ScPreviewLocationData::GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const
+{
+ ULONG nCount = aEntries.Count();
+ for (ULONG nListPos=0; nListPos<nCount; nListPos++)
+ {
+ ScPreviewLocationEntry* pEntry = (ScPreviewLocationEntry*)aEntries.GetObject(nListPos);
+ if ( pEntry->eType == SC_PLOC_CELLRANGE && !pEntry->bRepeatCol && !pEntry->bRepeatRow )
+ {
+ rRange = pEntry->aCellRange;
+ rPixRect = pEntry->aPixelRect;
+ return TRUE;
+ }
+ }
+ return FALSE; // not found
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
new file mode 100644
index 000000000000..ca75165ebb2b
--- /dev/null
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -0,0 +1,1236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svx/svdview.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/request.hxx>
+#include <svtools/printdlg.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/help.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/printer.hxx>
+
+#include <svx/zoomslideritem.hxx>
+#include "prevwsh.hxx"
+#include "preview.hxx"
+#include "printfun.hxx"
+#include "attrib.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "docsh.hxx"
+#include "tabvwsh.hxx"
+#include "stlpool.hxx"
+#include "editutil.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+#include "ViewSettingsSequenceDefines.hxx"
+#include "tpprint.hxx"
+#include "printopt.hxx"
+#include <xmloff/xmluconv.hxx>
+#include <rtl/ustrbuf.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include <svx/zoom_def.hxx>
+
+#include "sc.hrc"
+#include "scabstdlg.hxx"
+// fuer Rad-Maus
+#define SC_DELTA_ZOOM 10
+#define MINZOOM_SLIDER 10
+#define MAXZOOM_SLIDER 400
+
+#define SC_USERDATA_SEP ';'
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+#define ScPreviewShell
+#include "scslots.hxx"
+
+TYPEINIT1( ScPreviewShell, SfxViewShell );
+
+SFX_IMPL_INTERFACE( ScPreviewShell, SfxViewShell, ScResId(SCSTR_PREVIEWSHELL) )
+{
+ SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|
+ SFX_VISIBILITY_SERVER|SFX_VISIBILITY_READONLYDOC,
+ ScResId(RID_OBJECTBAR_PREVIEW));
+ SFX_POPUPMENU_REGISTRATION(ScResId(RID_POPUP_PREVIEW));
+}
+
+SFX_IMPL_NAMED_VIEWFACTORY( ScPreviewShell, "PrintPreview" )
+{
+ SFX_VIEW_REGISTRATION(ScDocShell);
+}
+
+//------------------------------------------------------------------
+
+void ScPreviewShell::Construct( Window* pParent )
+{
+ eZoom = SVX_ZOOM_WHOLEPAGE;
+
+ pCorner = new ScrollBarBox( pParent, WB_SIZEABLE );
+
+ pHorScroll = new ScrollBar(pParent, WB_HSCROLL );
+ pVerScroll = new ScrollBar(pParent, WB_VSCROLL);
+
+ // SSA: --- RTL --- no mirroring for horizontal scrollbars
+ pHorScroll->EnableRTL( FALSE );
+
+ pHorScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) );
+ pVerScroll->SetEndScrollHdl( LINK( this, ScPreviewShell, ScrollHandler ) );
+
+ pPreview = new ScPreview( pParent, pDocShell, this );
+
+ SetPool( &SC_MOD()->GetPool() );
+ SetWindow( pPreview );
+ StartListening(*pDocShell,TRUE);
+ StartListening(*SFX_APP(),TRUE); // #i62045# #i62046# application is needed for Calc's own hints
+ SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ StartListening(*pDrawBC);
+
+// pPreview->Show(); // wird vom Sfx angezeigt
+ pHorScroll->Show();
+ pVerScroll->Show();
+ pCorner->Show();
+ SetHelpId( HID_SCSHELL_PREVWSH );
+ SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Preview")));
+}
+
+ScPreviewShell::ScPreviewShell( SfxViewFrame* pViewFrame,
+ SfxViewShell* pOldSh ) :
+ SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
+ pDocShell( (ScDocShell*)pViewFrame->GetObjectShell() ),
+ nSourceDesignMode( SC_FORCEMODE_NONE ),
+ pAccessibilityBroadcaster( NULL )
+{
+ Construct( &pViewFrame->GetWindow() );
+
+ if ( pOldSh && pOldSh->ISA( ScTabViewShell ) )
+ {
+ // store view settings, show table from TabView
+ //! store live ScViewData instead, and update on ScTablesHint?
+ //! or completely forget aSourceData on ScTablesHint?
+
+ ScTabViewShell* pTabViewShell = ((ScTabViewShell*)pOldSh);
+ ScViewData* pData = pTabViewShell->GetViewData();
+ pData->WriteUserDataSequence( aSourceData );
+ InitStartTable( pData->GetTabNo() );
+
+ // #106334# also have to store the TabView's DesignMode state
+ // (only if draw view exists)
+ SdrView* pDrawView = pTabViewShell->GetSdrView();
+ if ( pDrawView )
+ nSourceDesignMode = pDrawView->IsDesignMode();
+ }
+}
+
+__EXPORT ScPreviewShell::~ScPreviewShell()
+{
+ // #108333#; notify Accessibility that Shell is dying and before destroy all
+ BroadcastAccessibility( SfxSimpleHint( SFX_HINT_DYING ) );
+ DELETEZ(pAccessibilityBroadcaster);
+
+ SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ EndListening(*pDrawBC);
+ EndListening(*SFX_APP());
+ EndListening(*pDocShell);
+
+ SetWindow(0);
+ delete pPreview;
+ delete pHorScroll;
+ delete pVerScroll;
+ delete pCorner;
+
+ // #97612# normal mode of operation is switching back to default view in the same frame,
+ // so there's no need to activate any other window here anymore
+}
+
+void ScPreviewShell::InitStartTable(SCTAB nTab)
+{
+ pPreview->SetPageNo( pPreview->GetFirstPage(nTab) );
+}
+
+//------------------------------------------------------------------
+
+String __EXPORT ScPreviewShell::GetDescription() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** "));
+}
+
+Size __EXPORT ScPreviewShell::GetOptimalSizePixel() const
+{
+ Size aOptSize(100,100);
+
+ ScTabViewShell* pViewSh = pDocShell->GetBestViewShell();
+
+ if ( pViewSh )
+ {
+ ScViewData* pViewData = pViewSh->GetViewData();
+ SCTAB nCurTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
+ pDoc->GetPageStyle( nCurTab ),
+ SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" );
+
+ if ( pStyleSheet )
+ {
+ const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ const SvxSizeItem& rItem = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE );
+ const Size& rPageSize = rItem.GetSize();
+
+ aOptSize.Width() = (long) (rPageSize.Width() * pViewData->GetPPTX());
+ aOptSize.Height() = (long) (rPageSize.Height() * pViewData->GetPPTY());
+ }
+ }
+ else
+ {
+ DBG_ERROR( "TabViewShell not found :-/" );
+ }
+
+ return aOptSize;
+}
+
+void __EXPORT ScPreviewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
+{
+ long nBarW = GetViewFrame()->GetWindow().GetSettings().GetStyleSettings().GetScrollBarSize();
+ long nBarH = nBarW;
+// long nBarW = pVerScroll->GetSizePixel().Width();
+// long nBarH = pHorScroll->GetSizePixel().Height();
+
+ Size aOutSize( rSize.Width()-nBarW, rSize.Height()-nBarH );
+ pPreview->SetPosSizePixel( rPos, aOutSize );
+ pHorScroll->SetPosSizePixel( Point( rPos.X(), rPos.Y() + aOutSize.Height() ),
+ Size( aOutSize.Width(), nBarH ) );
+ pVerScroll->SetPosSizePixel( Point( rPos.X() + aOutSize.Width(), rPos.Y() ),
+ Size( nBarW, aOutSize.Height() ) );
+ pCorner->SetPosSizePixel( Point( rPos.X() + aOutSize.Width(), rPos.Y() + aOutSize.Height() ),
+ Size( nBarW, nBarH ) );
+
+ if ( SVX_ZOOM_WHOLEPAGE == eZoom )
+ pPreview->SetZoom( pPreview->GetOptimalZoom(FALSE) );
+ else if ( SVX_ZOOM_PAGEWIDTH == eZoom )
+ pPreview->SetZoom( pPreview->GetOptimalZoom(TRUE) );
+
+ UpdateScrollBars();
+}
+
+void __EXPORT ScPreviewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
+{
+ AdjustPosSizePixel( rOfs,rSize );
+}
+
+void __EXPORT ScPreviewShell::OuterResizePixel( const Point &rOfs, const Size &rSize )
+{
+ AdjustPosSizePixel( rOfs,rSize );
+}
+
+void ScPreviewShell::UpdateScrollBars()
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTab = pPreview->GetTab();
+
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ),
+ SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT(pStyleSheet,"StyleSheet nicht gefunden");
+ if (!pStyleSheet) return;
+ const SfxItemSet* pParamSet = &pStyleSheet->GetItemSet();
+
+ Size aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
+ aPageSize.Width() = (long) (aPageSize.Width() * HMM_PER_TWIPS );
+ aPageSize.Height() = (long) (aPageSize.Height() * HMM_PER_TWIPS );
+
+ // for centering, page size without the shadow is used
+
+ Size aWindowSize = pPreview->GetOutputSize();
+
+ Point aOfs = pPreview->GetOffset();
+ long nMaxPos;
+
+ if( pHorScroll )
+ {
+ pHorScroll->SetRange( Range( 0, aPageSize.Width() ) );
+ pHorScroll->SetLineSize( aWindowSize.Width() / 16 );
+ pHorScroll->SetPageSize( aWindowSize.Width() );
+ pHorScroll->SetVisibleSize( aWindowSize.Width() );
+ nMaxPos = aPageSize.Width() - aWindowSize.Width();
+ if ( nMaxPos<0 )
+ {
+ // page smaller than window -> center (but put scrollbar to 0)
+ aOfs.X() = 0;
+ pPreview->SetXOffset( nMaxPos / 2 );
+ }
+ else if (aOfs.X() < 0)
+ {
+ // page larger than window -> never use negative offset
+ aOfs.X() = 0;
+ pPreview->SetXOffset( 0 );
+ }
+ else if (aOfs.X() > nMaxPos)
+ {
+ // limit offset to align with right edge of window
+ aOfs.X() = nMaxPos;
+ pPreview->SetXOffset(nMaxPos);
+ }
+ pHorScroll->SetThumbPos( aOfs.X() );
+ }
+
+ if( pVerScroll )
+ {
+ long nPageNo = pPreview->GetPageNo();
+ long nTotalPages = pPreview->GetTotalPages();
+
+ nMaxVertPos = aPageSize.Height() - aWindowSize.Height();
+ pVerScroll->SetLineSize( aWindowSize.Height() / 16 );
+ pVerScroll->SetPageSize( aWindowSize.Height() );
+ pVerScroll->SetVisibleSize( aWindowSize.Height() );
+ if ( nMaxVertPos < 0 )
+ {
+ // page smaller than window -> center (but put scrollbar to 0)
+ aOfs.Y() = 0;
+ pPreview->SetYOffset( nMaxVertPos / 2 );
+ pVerScroll->SetThumbPos( nPageNo * aWindowSize.Height() );
+ pVerScroll->SetRange( Range( 0, aWindowSize.Height() * nTotalPages ));
+ }
+ else if (aOfs.Y() < 0)
+ {
+ // page larger than window -> never use negative offset
+ pVerScroll->SetRange( Range( 0, aPageSize.Height() ) );
+ aOfs.Y() = 0;
+ pPreview->SetYOffset( 0 );
+ pVerScroll->SetThumbPos( aOfs.Y() );
+ }
+ else if (aOfs.Y() > nMaxVertPos )
+ {
+ // limit offset to align with window bottom
+ pVerScroll->SetRange( Range( 0, aPageSize.Height() ) );
+ aOfs.Y() = nMaxVertPos;
+ pPreview->SetYOffset( nMaxVertPos );
+ pVerScroll->SetThumbPos( aOfs.Y() );
+ }
+ }
+}
+
+IMPL_LINK (ScPreviewShell,ScrollHandler, ScrollBar* ,pScroll )
+{
+ long nPos = pScroll->GetThumbPos();
+ long nDelta = pScroll->GetDelta();
+ long nMaxRange = pScroll->GetRangeMax();
+ long nTotalPages = pPreview->GetTotalPages();
+ long nPageNo = 0;
+ long nPerPageLength = 0;
+ BOOL bIsDivide = TRUE;
+
+ if( nTotalPages )
+ nPerPageLength = nMaxRange / nTotalPages;
+
+ if( nPerPageLength )
+ {
+ nPageNo = nPos / nPerPageLength;
+ if( nPos % nPerPageLength )
+ {
+ bIsDivide = FALSE;
+ nPageNo ++;
+ }
+ }
+
+ BOOL bHoriz = ( pScroll == pHorScroll );
+
+ if( bHoriz )
+ pPreview->SetXOffset( nPos );
+ else
+ {
+ if( nMaxVertPos > 0 )
+ pPreview->SetYOffset( nPos );
+ else
+ {
+ Point aMousePos = pScroll->OutputToNormalizedScreenPixel( pScroll->GetPointerPosPixel() );
+ Point aPos = pScroll->GetParent()->OutputToNormalizedScreenPixel( pScroll->GetPosPixel() );
+ String aHelpStr;
+ Rectangle aRect;
+ USHORT nAlign;
+
+ if( nDelta < 0 )
+ {
+ if ( nTotalPages && nPageNo > 0 && !bIsDivide )
+ pPreview->SetPageNo( nPageNo-1 );
+ if( bIsDivide )
+ pPreview->SetPageNo( nPageNo );
+
+ aHelpStr = ScGlobal::GetRscString( STR_PAGE );
+ aHelpStr += ' ';
+ aHelpStr += String::CreateFromInt32( nPageNo );
+
+ aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aHelpStr += String::CreateFromInt32( nTotalPages );
+ }
+ else if( nDelta > 0 )
+ {
+ BOOL bAllTested = pPreview->AllTested();
+ if ( nTotalPages && ( nPageNo < nTotalPages || !bAllTested ) )
+ pPreview->SetPageNo( nPageNo );
+
+ aHelpStr = ScGlobal::GetRscString( STR_PAGE );
+ aHelpStr += ' ';
+ aHelpStr += String::CreateFromInt32( nPageNo+1 );
+
+ aHelpStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aHelpStr += String::CreateFromInt32( nTotalPages );
+ }
+
+ aRect.Left() = aPos.X() - 8;
+ aRect.Top() = aMousePos.Y();
+ aRect.Right() = aRect.Left();
+ aRect.Top() = aRect.Top();
+ nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
+ Help::ShowQuickHelp( pScroll->GetParent(), aRect, aHelpStr, nAlign );
+ }
+ }
+
+ return 0;
+}
+
+BOOL ScPreviewShell::ScrollCommand( const CommandEvent& rCEvt )
+{
+ BOOL bDone = FALSE;
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM )
+ {
+ long nOld = pPreview->GetZoom();
+ long nNew = nOld;
+ if ( pData->GetDelta() < 0 )
+ nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) );
+ else
+ nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) );
+
+ if ( nNew != nOld )
+ {
+ eZoom = SVX_ZOOM_PERCENT;
+ pPreview->SetZoom( (USHORT)nNew );
+ }
+
+ bDone = TRUE;
+ }
+ else
+ {
+ bDone = pPreview->HandleScrollCommand( rCEvt, pHorScroll, pVerScroll );
+ }
+
+ return bDone;
+}
+
+SfxPrinter* __EXPORT ScPreviewShell::GetPrinter( BOOL bCreate )
+{
+ return pDocShell->GetPrinter(bCreate);
+}
+
+USHORT __EXPORT ScPreviewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags, bool )
+{
+ return pDocShell->SetPrinter( pNewPrinter, nDiffFlags );
+}
+
+PrintDialog* __EXPORT ScPreviewShell::CreatePrintDialog( Window* pParent )
+{
+ pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen
+ (void)GetPrinter();
+
+ const long nCurPage = pPreview->GetPageNo()+1;
+ const long nDocPageMax = pPreview->GetTotalPages();
+ PrintDialog* pDlg = new PrintDialog( pParent, true );
+// wenn zu langsam wieder einbauen
+// if ( pPreview->AllTested() )
+// nPageMax = pPreview->GetTotalPages();
+
+ pDlg->EnableSheetRange( true, PRINTSHEETS_ALL );
+ pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_SHEETS );
+ pDlg->EnableSheetRange( false, PRINTSHEETS_SELECTED_CELLS );
+ bool bAllTabs = SC_MOD()->GetPrintOptions().GetAllSheets();
+ pDlg->CheckSheetRange( bAllTabs ? PRINTSHEETS_ALL : PRINTSHEETS_SELECTED_SHEETS );
+
+ if ( nDocPageMax > 0 )
+ pDlg->SetRangeText( String::CreateFromInt32( nCurPage ) );
+
+ pDlg->EnableRange ( PRINTDIALOG_ALL );
+ pDlg->EnableRange ( PRINTDIALOG_RANGE );
+ pDlg->SetFirstPage ( 1 );
+ pDlg->SetMinPage ( 1 );
+ pDlg->SetLastPage ( (USHORT)nDocPageMax );
+ pDlg->SetMaxPage ( (USHORT)nDocPageMax );
+ pDlg->EnableCollate ();
+
+ // Selektion hier nicht
+
+ return pDlg;
+}
+
+SfxTabPage* ScPreviewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions )
+{
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
+ if ( ScTpPrintOptionsCreate )
+ return (*ScTpPrintOptionsCreate)( pParent, rOptions);
+ return 0;
+}
+
+void __EXPORT ScPreviewShell::PreparePrint( PrintDialog* pPrintDialog )
+{
+ SfxViewShell::PreparePrint( pPrintDialog );
+
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( static_cast< SCTAB >( pPreview->GetTab() ), TRUE );
+ pDocShell->PreparePrint( pPrintDialog, &aMarkData );
+}
+
+ErrCode ScPreviewShell::DoPrint( SfxPrinter *pPrinter,
+ PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI )
+{
+ ErrCode nRet = ERRCODE_IO_ABORT;
+
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( static_cast< SCTAB >( pPreview->GetTab() ), TRUE );
+
+ if ( pDocShell->CheckPrint( pPrintDialog, &aMarkData, false, bIsAPI ) )
+ {
+ // SfxViewShell::DoPrint calls Print (after StartJob etc.)
+ nRet = SfxViewShell::DoPrint( pPrinter, pPrintDialog, bSilent, bIsAPI );
+ }
+
+ return nRet;
+}
+
+USHORT __EXPORT ScPreviewShell::Print( SfxProgress& rProgress, BOOL bIsAPI, PrintDialog* pPrintDialog )
+{
+ pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen
+
+ // get the list of affected sheets before SfxViewShell::Print
+ bool bAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() );
+
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( static_cast< SCTAB >( pPreview->GetTab() ), TRUE );
+
+ uno::Sequence< sal_Int32 > aSheets;
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
+ sal_Int32 nPrinted = 0;
+ for ( SCTAB nTab = 0; nTab < nTabCount; ++nTab )
+ {
+ if ( bAllTabs || aMarkData.GetTableSelect( nTab ) )
+ {
+ aSheets.realloc( nPrinted + 1 );
+ aSheets[nPrinted] = nTab;
+ ++nPrinted;
+ }
+ }
+
+ uno::Sequence < beans::PropertyValue > aProps(1);
+ aProps[0].Name = ::rtl::OUString::createFromAscii( "PrintSheets" );
+ aProps[0].Value <<= aSheets;
+ SetAdditionalPrintOptions( aProps );
+
+ SfxViewShell::Print( rProgress, bIsAPI, pPrintDialog );
+ pDocShell->Print( rProgress, pPrintDialog, &aMarkData, pPreview, FALSE, bIsAPI );
+
+ return 0;
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScPreviewShell::Activate(BOOL bMDI)
+{
+ SfxViewShell::Activate(bMDI);
+
+ //! Basic etc. -> auslagern in eigene Datei (s. tabvwsh4)
+
+ if (bMDI)
+ {
+ // InputHdl ist jetzt meistens Null, keine Assertion mehr!
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+ }
+}
+
+void __EXPORT ScPreviewShell::Deactivate(BOOL bMDI)
+{
+ SfxViewShell::Deactivate(bMDI);
+
+ if (bMDI)
+ {
+ }
+}
+
+//------------------------------------------------------------------------
+
+void __EXPORT ScPreviewShell::Execute( SfxRequest& rReq )
+{
+ USHORT nSlot = rReq.GetSlot();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ switch ( nSlot )
+ {
+ case SID_FORMATPAGE:
+ case SID_STATUS_PAGESTYLE:
+ case SID_HFEDIT:
+ pDocShell->ExecutePageStyle( *this, rReq, pPreview->GetTab() );
+ break;
+ case SID_REPAINT:
+ pPreview->Invalidate();
+ rReq.Done();
+ break;
+ case SID_PREV_TABLE: // Accelerator
+ case SID_PREVIEW_PREVIOUS:
+ {
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ if (nTotal && nPage > 0)
+ pPreview->SetPageNo( nPage-1 );
+ }
+ break;
+ case SID_NEXT_TABLE: // Accelerator
+ case SID_PREVIEW_NEXT:
+ {
+ BOOL bAllTested = pPreview->AllTested();
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ if (nTotal && (nPage+1 < nTotal || !bAllTested))
+ pPreview->SetPageNo( nPage+1 );
+ }
+ break;
+ case SID_CURSORTOPOFFILE: // Accelerator
+ case SID_PREVIEW_FIRST:
+ {
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ if (nTotal && nPage != 0)
+ pPreview->SetPageNo( 0 );
+ }
+ break;
+ case SID_CURSORENDOFFILE: // Accelerator
+ case SID_PREVIEW_LAST:
+ {
+ if (!pPreview->AllTested())
+ pPreview->CalcAll();
+
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ if (nTotal && nPage+1 != nTotal)
+ pPreview->SetPageNo( nTotal-1 );
+ }
+ break;
+ case SID_ATTR_ZOOM:
+ case FID_SCALE:
+ {
+ USHORT nZoom = 100;
+ BOOL bCancel = FALSE;
+
+ eZoom = SVX_ZOOM_PERCENT;
+
+ if ( pReqArgs )
+ {
+
+ const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
+ pReqArgs->Get(SID_ATTR_ZOOM);
+
+ eZoom = rZoomItem.GetType();
+ nZoom = rZoomItem.GetValue();
+ }
+ else
+ {
+ SfxItemSet aSet ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
+ SvxZoomItem aZoomItem( SVX_ZOOM_PERCENT, pPreview->GetZoom(), SID_ATTR_ZOOM );
+
+ aSet.Put( aZoomItem );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ AbstractSvxZoomDialog* pDlg = pFact->CreateSvxZoomDialog(NULL, aSet);
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ pDlg->SetLimits( 20, 400 );
+ pDlg->HideButton( ZOOMBTN_OPTIMAL );
+ bCancel = ( RET_CANCEL == pDlg->Execute() );
+
+ if ( !bCancel )
+ {
+ const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
+ pDlg->GetOutputItemSet()->
+ Get( SID_ATTR_ZOOM );
+
+ eZoom = rZoomItem.GetType();
+ nZoom = rZoomItem.GetValue();
+ }
+
+ delete pDlg;
+ }
+ }
+
+ if ( !bCancel )
+ {
+ switch ( eZoom )
+ {
+ case SVX_ZOOM_OPTIMAL:
+ case SVX_ZOOM_WHOLEPAGE:
+ nZoom = pPreview->GetOptimalZoom(FALSE);
+ break;
+ case SVX_ZOOM_PAGEWIDTH:
+ nZoom = pPreview->GetOptimalZoom(TRUE);
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ pPreview->SetZoom( nZoom );
+ rReq.Done();
+ }
+ }
+ break;
+ case SID_PREVIEW_ZOOMIN:
+ {
+ USHORT nNew = pPreview->GetZoom() + 20 ;
+ nNew -= nNew % 20;
+ pPreview->SetZoom( nNew );
+ eZoom = SVX_ZOOM_PERCENT;
+ rReq.Done();
+ }
+ break;
+ case SID_PREVIEW_ZOOMOUT:
+ {
+ USHORT nNew = pPreview->GetZoom() - 1;
+ nNew -= nNew % 20;
+ pPreview->SetZoom( nNew );
+ eZoom = SVX_ZOOM_PERCENT;
+ rReq.Done();
+ }
+ break;
+ case SID_PREVIEW_MARGIN:
+ {
+ BOOL bMargin = pPreview->GetPageMargins();
+ pPreview->SetPageMargins( !bMargin );
+ pPreview->Invalidate();
+ rReq.Done();
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ const SfxPoolItem* pItem;
+ eZoom = SVX_ZOOM_PERCENT;
+ if( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( SID_ATTR_ZOOMSLIDER, TRUE, &pItem ) )
+ {
+ const USHORT nCurrentZoom = ((const SvxZoomSliderItem*)pItem)->GetValue();
+ if( nCurrentZoom )
+ {
+ pPreview->SetZoom( nCurrentZoom );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+ case SID_PREVIEW_SCALINGFACTOR:
+ {
+ const SfxPoolItem* pItem;
+ SCTAB nTab = pPreview->GetTab();
+ String aOldName = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() );
+ ScStyleSheetPool* pStylePool = pDocShell->GetDocument()->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
+
+ if ( pReqArgs && pStyleSheet && SFX_ITEM_SET == pReqArgs->GetItemState( SID_PREVIEW_SCALINGFACTOR, TRUE, &pItem ) )
+ {
+ const USHORT nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ rSet.Put( SfxUInt16Item( ATTR_PAGE_SCALE, nCurrentZoom ) );
+ ScPrintFunc aPrintFunc( pDocShell, pDocShell->GetPrinter(), nTab );
+ aPrintFunc.UpdatePages();
+ rReq.Done();
+ }
+ GetViewFrame()->GetBindings().Invalidate( nSlot );
+ }
+ break;
+ case SID_PRINTPREVIEW:
+ case SID_PREVIEW_CLOSE:
+ // print preview is now always in the same frame as the tab view
+ // -> always switch this frame back to normal view
+ // (ScTabViewShell ctor reads stored view data)
+
+ GetViewFrame()->GetDispatcher()->Execute( SID_VIEWSHELL0, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case SID_CURSORPAGEUP:
+ case SID_CURSORPAGEDOWN:
+ case SID_CURSORHOME:
+ case SID_CURSOREND:
+ case SID_CURSORUP:
+ case SID_CURSORDOWN:
+ case SID_CURSORLEFT:
+ case SID_CURSORRIGHT:
+ DoScroll( nSlot );
+ break;
+ case SID_CANCEL:
+ if( ScViewUtil::IsFullScreen( *this ) )
+ ScViewUtil::SetFullScreen( *this, false );
+ break;
+
+ default:
+ break;
+ }
+}
+
+void __EXPORT ScPreviewShell::GetState( SfxItemSet& rSet )
+{
+ pPreview->SetInGetState(TRUE);
+
+ SCTAB nTab = pPreview->GetTab();
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ USHORT nZoom = pPreview->GetZoom();
+ BOOL bAllTested = pPreview->AllTested();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch (nWhich)
+ {
+ case SID_STATUS_PAGESTYLE:
+ case SID_HFEDIT:
+ pDocShell->GetStatePageStyle( *this, rSet, nTab );
+ break;
+ case SID_UNDO:
+ case SID_REDO:
+ case SID_REPEAT:
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_PREVIEW_PREVIOUS:
+ case SID_PREVIEW_FIRST:
+ if (!nTotal || nPage==0)
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_PREVIEW_NEXT:
+ case SID_PREVIEW_LAST:
+ if (bAllTested)
+ if (!nTotal || nPage==nTotal-1)
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_PREVIEW_ZOOMIN:
+ if (nZoom >= 400)
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_PREVIEW_ZOOMOUT:
+ if (nZoom <= 20)
+ rSet.DisableItem(nWhich);
+ break;
+ case SID_ATTR_ZOOM:
+ {
+ SvxZoomItem aZoom( eZoom, nZoom, nWhich );
+ aZoom.SetValueSet( SVX_ZOOM_ENABLE_ALL & ~SVX_ZOOM_ENABLE_OPTIMAL );
+ rSet.Put( aZoom );
+ }
+ break;
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ SvxZoomSliderItem aZoomSliderItem( nZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+ rSet.Put( aZoomSliderItem );
+ }
+ break;
+ case SID_PREVIEW_SCALINGFACTOR:
+ {
+ if( pDocShell->IsReadOnly() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ String aOldName = pDocShell->GetDocument()->GetPageStyle( pPreview->GetTab() );
+ ScStyleSheetPool* pStylePool = pDocShell->GetDocument()->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aOldName, SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found! :-/" );
+
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+ USHORT nCurrentZoom = ((const SfxUInt16Item&)rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
+ if( nCurrentZoom )
+ {
+ SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM_SLIDER, MAXZOOM_SLIDER, SID_PREVIEW_SCALINGFACTOR );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+ rSet.Put( aZoomSliderItem );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ }
+ }
+ }
+ break;
+ case SID_STATUS_DOCPOS:
+ rSet.Put( SfxStringItem( nWhich, pPreview->GetPosString() ) );
+ break;
+ case SID_PRINTPREVIEW:
+ rSet.Put( SfxBoolItem( nWhich, TRUE ) );
+ break;
+ case SID_FORMATPAGE:
+ case SID_PREVIEW_MARGIN:
+ if( pDocShell->IsReadOnly() )
+ rSet.DisableItem( nWhich );
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+
+ pPreview->SetInGetState(FALSE);
+}
+
+void ScPreviewShell::FillFieldData( ScHeaderFieldData& rData )
+{
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTab = pPreview->GetTab();
+ pDoc->GetName( nTab, rData.aTabName );
+
+ rData.aTitle = pDocShell->GetTitle();
+ const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
+ rData.aLongDocName = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+ if ( rData.aLongDocName.Len() )
+ rData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
+ else
+ rData.aShortDocName = rData.aLongDocName = rData.aTitle;
+ rData.nPageNo = pPreview->GetPageNo() + 1;
+
+ BOOL bAllTested = pPreview->AllTested();
+ if (bAllTested)
+ rData.nTotalPages = pPreview->GetTotalPages();
+ else
+ rData.nTotalPages = 99;
+
+ // eNumType kennt der Dialog selber
+}
+
+void __EXPORT ScPreviewShell::WriteUserData(String& rData, BOOL /* bBrowse */)
+{
+ // nZoom
+ // nPageNo
+
+ rData = String::CreateFromInt32(pPreview->GetZoom());
+ rData += (sal_Unicode) SC_USERDATA_SEP;
+ rData += String::CreateFromInt32(pPreview->GetPageNo());
+}
+
+void __EXPORT ScPreviewShell::ReadUserData(const String& rData, BOOL /* bBrowse */)
+{
+ xub_StrLen nCount = rData.GetTokenCount();
+ if (nCount)
+ {
+ xub_StrLen nIndex = 0;
+ pPreview->SetZoom((USHORT)rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32());
+ pPreview->SetPageNo(rData.GetToken( 0, SC_USERDATA_SEP, nIndex ).ToInt32());
+ eZoom = SVX_ZOOM_PERCENT;
+ }
+}
+
+void __EXPORT ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue >& rSeq, sal_Bool /* bBrowse */)
+{
+ rSeq.realloc(3);
+ beans::PropertyValue* pSeq = rSeq.getArray();
+ if(pSeq)
+ {
+ sal_uInt16 nViewID(GetViewFrame()->GetCurViewId());
+ pSeq[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID));
+ rtl::OUStringBuffer sBuffer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW)));
+ SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
+ pSeq[0].Value <<= sBuffer.makeStringAndClear();
+ pSeq[1].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
+ pSeq[1].Value <<= sal_Int32 (pPreview->GetZoom());
+ pSeq[2].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageNumber"));
+ pSeq[2].Value <<= pPreview->GetPageNo();
+ }
+}
+
+void __EXPORT ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyValue >& rSeq, sal_Bool /* bBrowse */)
+{
+ sal_Int32 nCount(rSeq.getLength());
+ if (nCount)
+ {
+ sal_Int32 nTemp = 0;
+ const beans::PropertyValue* pSeq = rSeq.getConstArray();
+ if(pSeq)
+ {
+ for(sal_Int32 i = 0; i < nCount; i++, pSeq++)
+ {
+ rtl::OUString sName(pSeq->Name);
+ if(sName.compareToAscii(SC_ZOOMVALUE) == 0)
+ {
+ if (pSeq->Value >>= nTemp)
+ pPreview->SetZoom(sal_uInt16(nTemp));
+ }
+ else if (sName.compareToAscii("PageNumber") == 0)
+ {
+ if (pSeq->Value >>= nTemp)
+ pPreview->SetPageNo(nTemp);
+ }
+ }
+ }
+ }
+}
+
+void ScPreviewShell::DoScroll( USHORT nMode )
+{
+ Point aCurPos, aPrevPos;
+
+ long nHRange = pHorScroll->GetRange().Max();
+ long nHLine = pHorScroll->GetLineSize();
+ long nHPage = pHorScroll->GetPageSize();
+ long nVRange = pVerScroll->GetRange().Max();
+ long nVLine = pVerScroll->GetLineSize();
+ long nVPage = pVerScroll->GetPageSize();
+
+ aCurPos.X() = pHorScroll->GetThumbPos();
+ aCurPos.Y() = pVerScroll->GetThumbPos();
+ aPrevPos = aCurPos;
+
+ long nThumbPos = pVerScroll->GetThumbPos();
+ long nRangeMax = pVerScroll->GetRangeMax();
+
+ switch( nMode )
+ {
+ case SID_CURSORUP:
+ if( nMaxVertPos<0 )
+ {
+ long nPage = pPreview->GetPageNo();
+
+ if( nPage>0 )
+ {
+ SfxViewFrame* pSfxViewFrame = GetViewFrame();
+ SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
+ Execute( aSfxRequest );
+ }
+ }
+ else
+ aCurPos.Y() -= nVLine;
+ break;
+ case SID_CURSORDOWN:
+ if( nMaxVertPos<0 )
+ {
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+
+ // before testing for last page, make sure all page counts are calculated
+ if ( nPage+1 == nTotal && !pPreview->AllTested() )
+ {
+ pPreview->CalcAll();
+ nTotal = pPreview->GetTotalPages();
+ }
+
+ if( nPage<nTotal-1 )
+ {
+ SfxViewFrame* pSfxViewFrame = GetViewFrame();
+ SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
+ Execute( aSfxRequest );
+ }
+ }
+ else
+ aCurPos.Y() += nVLine;
+ break;
+ case SID_CURSORLEFT:
+ aCurPos.X() -= nHLine;
+ break;
+ case SID_CURSORRIGHT:
+ aCurPos.X() += nHLine;
+ break;
+ case SID_CURSORPAGEUP:
+ if( nThumbPos==0 || nMaxVertPos<0 )
+ {
+ long nPage = pPreview->GetPageNo();
+
+ if( nPage>0 )
+ {
+ SfxViewFrame* pSfxViewFrame = GetViewFrame();
+ SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_PREVIOUS );
+ Execute( aSfxRequest );
+ aCurPos.Y() = nVRange;
+ }
+ }
+ else
+ aCurPos.Y() -= nVPage;
+ break;
+ case SID_CURSORPAGEDOWN:
+ if( (abs(nVPage+nThumbPos-nRangeMax)<10) || nMaxVertPos<0 )
+ {
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+
+ // before testing for last page, make sure all page counts are calculated
+ if ( nPage+1 == nTotal && !pPreview->AllTested() )
+ {
+ pPreview->CalcAll();
+ nTotal = pPreview->GetTotalPages();
+ }
+ if( nPage<nTotal-1 )
+ {
+ SfxViewFrame* pSfxViewFrame = GetViewFrame();
+ SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_NEXT );
+ Execute( aSfxRequest );
+ aCurPos.Y() = 0;
+ }
+ }
+ else
+ aCurPos.Y() += nVPage;
+ break;
+ case SID_CURSORHOME:
+ if( nMaxVertPos<0 )
+ {
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ if( nTotal && nPage != 0 )
+ {
+ SfxViewFrame* pSfxViewFrame = GetViewFrame();
+ SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_FIRST );
+ Execute( aSfxRequest );
+ }
+ }
+ else
+ {
+ aCurPos.Y() = 0;
+ aCurPos.X() = 0;
+ }
+ break;
+ case SID_CURSOREND:
+ if( nMaxVertPos<0 )
+ {
+ if( !pPreview->AllTested() )
+ pPreview->CalcAll();
+ long nPage = pPreview->GetPageNo();
+ long nTotal = pPreview->GetTotalPages();
+ if( nTotal && nPage+1 != nTotal )
+ {
+ SfxViewFrame* pSfxViewFrame = GetViewFrame();
+ SfxRequest aSfxRequest( pSfxViewFrame, SID_PREVIEW_LAST );
+ Execute( aSfxRequest );
+ }
+ }
+ else
+ {
+ aCurPos.Y() = nVRange;
+ aCurPos.X() = nHRange;
+ }
+ break;
+ }
+
+ // nHRange-nHPage kann negativ sein, deshalb Abfrage auf < 0 hinterher
+
+ if( aCurPos.Y() > (nVRange-nVPage) )
+ aCurPos.Y() = (nVRange-nVPage);
+ if( aCurPos.Y() < 0 )
+ aCurPos.Y() = 0;
+ if( aCurPos.X() > (nHRange-nHPage) )
+ aCurPos.X() = (nHRange-nHPage);
+ if( aCurPos.X() < 0 )
+ aCurPos.X() = 0;
+
+ if( nMaxVertPos>=0 )
+ {
+ if( aCurPos.Y() != aPrevPos.Y() )
+ {
+ pVerScroll->SetThumbPos( aCurPos.Y() );
+ pPreview->SetYOffset( aCurPos.Y() );
+ }
+ }
+
+ if( aCurPos.X() != aPrevPos.X() )
+ {
+ pHorScroll->SetThumbPos( aCurPos.X() );
+ pPreview->SetXOffset( aCurPos.X() );
+ }
+
+}
+
+void ScPreviewShell::AddAccessibilityObject( SfxListener& rObject )
+{
+ if (!pAccessibilityBroadcaster)
+ pAccessibilityBroadcaster = new SfxBroadcaster;
+
+ rObject.StartListening( *pAccessibilityBroadcaster );
+}
+
+void ScPreviewShell::RemoveAccessibilityObject( SfxListener& rObject )
+{
+ if (pAccessibilityBroadcaster)
+ rObject.EndListening( *pAccessibilityBroadcaster );
+ else
+ {
+ DBG_ERROR("kein Accessibility-Broadcaster?");
+ }
+}
+
+void ScPreviewShell::BroadcastAccessibility( const SfxHint &rHint )
+{
+ if (pAccessibilityBroadcaster)
+ pAccessibilityBroadcaster->Broadcast( rHint );
+}
+
+BOOL ScPreviewShell::HasAccessibilityObjects()
+{
+ return pAccessibilityBroadcaster && pAccessibilityBroadcaster->HasListeners();
+}
+
+const ScPreviewLocationData& ScPreviewShell::GetLocationData()
+{
+ return pPreview->GetLocationData();
+}
+
+ScDocument* ScPreviewShell::GetDocument()
+{
+ return pDocShell->GetDocument();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/prevwsh2.cxx b/sc/source/ui/view/prevwsh2.cxx
new file mode 100644
index 000000000000..72a7a7aa4a32
--- /dev/null
+++ b/sc/source/ui/view/prevwsh2.cxx
@@ -0,0 +1,359 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// TOOLS
+#define _BIGINT_HXX
+#define _SFXMULTISEL_HXX
+#define _STACK_HXX
+#define _QUEUE_HXX
+#define _DYNARR_HXX
+#define _TREELIST_HXX
+#define _CACHESTR_HXX
+#define _NEW_HXX
+//#define _SHL_HXX
+//#define _LINK_HXX
+//#define _ERRCODE_HXX
+//#define _GEN_HXX
+//#define _FRACT_HXX
+//#define _STRING_HXX
+//#define _MTF_HXX
+//#define _CONTNR_HXX
+//#define _LIST_HXX
+//#define _TABLE_HXX
+#define _DYNARY_HXX
+//#define _UNQIDX_HXX
+#define _SVMEMPOOL_HXX
+//#define _UNQID_HXX
+//#define _DEBUG_HXX
+//#define _DATE_HXX
+//#define _TIME_HXX
+//#define _DATETIME_HXX
+//#define _INTN_HXX
+//#define _WLDCRD_HXX
+//#define _FSYS_HXX
+//#define _STREAM_HXX
+#define _CACHESTR_HXX
+//#define _SV_MULTISEL_HXX
+
+//SV
+//#define _CLIP_HXX ***
+#define _CONFIG_HXX
+#define _CURSOR_HXX
+#define _FONTDLG_HXX
+#define _PRVWIN_HXX
+//#define _COLOR_HXX
+//#define _PAL_HXX
+//#define _BITMAP_HXX
+//#define _GDIOBJ_HXX
+//#define _POINTR_HXX
+//#define _ICON_HXX
+//#define _IMAGE_HXX
+//#define _KEYCOD_HXX
+//#define _EVENT_HXX
+#define _HELP_HXX
+//#define _APP_HXX
+//#define _MDIAPP_HXX
+//#define _TIMER_HXX
+//#define _METRIC_HXX
+//#define _REGION_HXX
+//#define _OUTDEV_HXX
+//#define _SYSTEM_HXX
+//#define _VIRDEV_HXX
+//#define _JOBSET_HXX
+//#define _PRINT_HXX
+//#define _WINDOW_HXX
+//#define _SYSWIN_HXX
+//#define _WRKWIN_HXX
+#define _MDIWIN_HXX
+//#define _FLOATWIN_HXX
+//#define _DOCKWIN_HXX
+//#define _CTRL_HXX
+//#define _SCRBAR_HXX
+//#define _BUTTON_HXX
+//#define _IMAGEBTN_HXX
+//#define _FIXED_HXX
+//#define _GROUP_HXX
+//#define _EDIT_HXX
+//#define _COMBOBOX_HXX
+//#define _LSTBOX_HXX
+//#define _SELENG_HXX ***
+//#define _SPLIT_HXX
+#define _SPIN_HXX
+//#define _FIELD_HXX
+//#define _MOREBTN_HXX ***
+//#define _TOOLBOX_HXX
+//#define _STATUS_HXX ***
+//#define _DIALOG_HXX
+//#define _MSGBOX_HXX
+//#define _SYSDLG_HXX
+//#define _PRNDLG_HXX
+#define _COLDLG_HXX
+//#define _TABDLG_HXX
+//#define _GDIMTF_HXX
+//#define _POLY_HXX
+//#define _ACCEL_HXX
+//#define _GRAPH_HXX
+#define _SOUND_HXX
+
+#if defined WIN
+#define _MENUBTN_HXX
+#endif
+
+//svtools
+#define _SCRWIN_HXX
+#define _RULER_HXX
+//#define _TABBAR_HXX
+//#define _VALUESET_HXX
+#define _STDMENU_HXX
+//#define _STDCTRL_HXX
+//#define _CTRLBOX_HXX
+#define _CTRLTOOL_HXX
+#define _EXTATTR_HXX
+#define _FRM3D_HXX
+#define _EXTATTR_HXX
+
+//SVTOOLS
+//#define _SVTREELIST_HXX ***
+#define _FILTER_HXX
+//#define _SVLBOXITM_HXX ***
+//#define _SVTREEBOX_HXX ***
+#define _SVICNVW_HXX
+#define _SVTABBX_HXX
+
+//sfxcore.hxx
+//#define _SFXINIMGR_HXX ***
+//#define _SFXCFGITEM_HXX
+//#define _SFX_PRINTER_HXX
+#define _SFXGENLINK_HXX
+#define _SFXHINTPOST_HXX
+#define _SFXDOCINF_HXX
+#define _SFXLINKHDL_HXX
+//#define _SFX_PROGRESS_HXX
+
+//sfxsh.hxx
+//#define _SFX_SHELL_HXX
+//#define _SFXAPP_HXX
+//#define _SFXDISPATCH_HXX
+//#define _SFXMSG_HXX ***
+//#define _SFXOBJFACE_HXX ***
+//#define _SFXREQUEST_HXX
+#define _SFXMACRO_HXX
+
+// SFX
+//#define _SFXAPPWIN_HXX ***
+#define _SFX_SAVEOPT_HXX
+//#define _SFX_CHILDWIN_HXX
+//#define _SFXCTRLITEM_HXX
+#define _SFXPRNMON_HXX
+#define _INTRO_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSGPOOL_HXX
+#define _SFXFILEDLG_HXX
+#define _PASSWD_HXX
+#define _SFXTBXCTRL_HXX
+#define _SFXSTBITEM_HXX
+#define _SFXMNUITEM_HXX
+#define _SFXIMGMGR_HXX
+#define _SFXTBXMGR_HXX
+#define _SFXSTBMGR_HXX
+#define _SFX_MINFITEM_HXX
+#define _SFXEVENT_HXX
+
+//sfxdoc.hxx
+//#define _SFX_OBJSH_HXX
+//#define _SFX_CLIENTSH_HXX
+//#define _SFXDOCINF_HXX
+//#define _SFX_OBJFAC_HXX
+#define _SFX_DOCFILT_HXX
+//#define _SFXDOCFILE_HXX ***
+//define _VIEWFAC_HXX
+//#define _SFXVIEWFRM_HXX
+//#define _SFXVIEWSH_HXX
+//#define _MDIFRM_HXX ***
+#define _SFX_IPFRM_HXX
+//#define _SFX_INTERNO_HXX
+
+//sfxdlg.hxx
+//#define _SFXTABDLG_HXX
+//#define _BASEDLGS_HXX ***
+#define _SFX_DINFDLG_HXX
+#define _SFXDINFEDT_HXX
+#define _SFX_MGETEMPL_HXX
+#define _SFX_TPLPITEM_HXX
+//#define _SFX_STYLEDLG_HXX
+#define _NEWSTYLE_HXX
+//#define _SFXDOCTEMPL_HXX ***
+//#define _SFXDOCTDLG_HXX ***
+//#define _SFX_TEMPLDLG_HXX ***
+//#define _SFXNEW_HXX ***
+#define _SFXDOCMAN_HXX
+#define _SFXDOCKWIN_HXX
+
+//sfxitems.hxx
+#define _SFX_WHMAP_HXX
+//#define _ARGS_HXX ***
+//#define _SFXPOOLITEM_HXX
+//#define _SFXINTITEM_HXX
+//#define _SFXENUMITEM_HXX
+#define _SFXFLAGITEM_HXX
+//#define _SFXSTRITEM_HXX
+#define _SFXPTITEM_HXX
+#define _SFXRECTITEM_HXX
+//#define _SFXITEMPOOL_HXX
+//#define _SFXITEMSET_HXX
+#define _SFXITEMITER_HXX
+#define _SFX_WHITER_HXX
+#define _SFXPOOLCACH_HXX
+//#define _AEITEM_HXX
+#define _SFXRNGITEM_HXX
+//#define _SFXSLSTITM_HXX
+//#define _SFXSTYLE_HXX
+
+//xout.hxx
+//#define _XENUM_HXX
+//#define _XPOLY_HXX
+//#define _XATTR_HXX
+//#define _XOUTX_HXX
+//#define _XPOOL_HXX
+//#define _XTABLE_HXX
+
+//svdraw.hxx
+#define _SDR_NOITEMS
+#define _SDR_NOTOUCH
+#define _SDR_NOTRANSFORM
+//#define _SDR_NOOBJECTS
+//#define _SDR_NOVIEWS
+#define _SDR_NOTRANSFORM
+#define _SDR_NOVIEWMARKER
+#define _SDR_NODRAGMETHODS
+#define _SDR_NOUNDO
+#define _SDR_NOXOUTDEV
+
+
+//#define SI_NOITEMS
+//#define SI_NODRW
+#define _SI_NOSBXCONTROLS
+//#define _VCATTR_HXX
+#define _VCONT_HXX
+//#define _VCSBX_HXX
+#define _SI_NOOTHERFORMS
+#define _VCTRLS_HXX
+//#define _VCDRWOBJ_HXX
+#define _SI_NOCONTROL
+#define _SETBRW_HXX
+#define _VCBRW_HXX
+#define _SI_NOSBXCONTROLS
+//#define _SIDLL_HXX ***
+
+#define _SVX_DAILDLL_HXX
+#define _SVX_HYPHEN_HXX
+#define _SVX_IMPGRF_HXX
+#define _SVX_OPTITEMS_HXX
+#define _SVX_OPTGERL_HXX
+#define _SVX_OPTSAVE_HXX
+#define _SVX_OPTSPELL_HXX
+#define _SVX_OPTPATH_HXX
+#define _SVX_OPTLINGU_HXX
+#define _SVX_RULER_HXX
+#define _SVX_RULRITEM_HXX
+#define _SVX_SPLWRAP_HXX
+#define _SVX_SPLDLG_HXX
+#define _SVX_THESDLG_HXX
+
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdmodel.hxx>
+#include <svl/smplhint.hxx>
+
+#include "prevwsh.hxx"
+#include "docsh.hxx"
+#include "preview.hxx"
+#include "hints.hxx"
+#include "sc.hrc"
+
+// STATIC DATA -----------------------------------------------------------
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScPreviewShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
+{
+ BOOL bDataChanged = FALSE;
+
+ if (rHint.ISA(SfxSimpleHint))
+ {
+ ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId();
+ switch ( nSlot )
+ {
+ case FID_DATACHANGED:
+ case SID_SCPRINTOPTIONS:
+ bDataChanged = TRUE;
+ break;
+ case SC_HINT_DRWLAYER_NEW:
+ {
+ SfxBroadcaster* pDrawBC = pDocShell->GetDocument()->GetDrawBroadcaster();
+ if (pDrawBC)
+ StartListening(*pDrawBC);
+ }
+ break;
+ }
+ }
+ else if (rHint.ISA(ScPaintHint))
+ {
+ if ( ((const ScPaintHint&)rHint).GetPrintFlag() )
+ {
+ USHORT nParts = ((const ScPaintHint&)rHint).GetParts();
+ if (nParts & ( PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE ))
+ bDataChanged = TRUE;
+ }
+ }
+ else if (rHint.ISA(SdrHint))
+ {
+ // SdrHints are no longer used for invalidating, thus react on objectchange instead
+ if(HINT_OBJCHG == ((const SdrHint&)rHint).GetKind())
+ bDataChanged = TRUE;
+ }
+
+ if (bDataChanged)
+ pPreview->DataChanged(TRUE);
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
new file mode 100644
index 000000000000..a3e4832b81b1
--- /dev/null
+++ b/sc/source/ui/view/printfun.cxx
@@ -0,0 +1,3204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include "printfun.hxx"
+
+#include <svx/svxids.hrc>
+#include <editeng/adjitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/editstat.hxx> // EE_CNTRL_RTFSTYLESHEETS
+#include <svx/fmview.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/paperinf.hxx>
+#include <editeng/pbinitem.hxx>
+#include <editeng/shaditem.hxx>
+#include <editeng/sizeitem.hxx>
+#include <svx/svdpagv.hxx>
+#include <editeng/ulspitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/progress.hxx>
+#include <tools/multisel.hxx>
+#include <sfx2/docfile.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/xoutbmp.hxx>
+
+#include "editutil.hxx"
+#include "docsh.hxx"
+#include "output.hxx"
+#include "viewdata.hxx"
+#include "viewopti.hxx"
+#include "stlpool.hxx"
+#include "pagepar.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "dociter.hxx"
+#include "cell.hxx"
+#include "drawutil.hxx"
+#include "globstr.hrc"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "pagedata.hxx"
+#include "printopt.hxx"
+#include "prevloc.hxx"
+#include "scmod.hxx"
+#include "drwlayer.hxx"
+#include "fillinfo.hxx"
+#include "postit.hxx"
+
+#include <vcl/lineinfo.hxx>
+#include <tools/pstm.hxx>
+
+#include <boost/scoped_ptr.hpp>
+
+#define ZOOM_MIN 10
+
+#define GET_BOOL(set,which) ((const SfxBoolItem&)(set)->Get((which))).GetValue()
+#define GET_USHORT(set,which) ((const SfxUInt16Item&)(set)->Get((which))).GetValue()
+#define GET_SHOW(set,which) ( VOBJ_MODE_SHOW == ScVObjMode( ((const ScViewObjectModeItem&)(set)->Get((which))).GetValue()) )
+
+//------------------------------------------------------------------------
+
+ScPageRowEntry::ScPageRowEntry(const ScPageRowEntry& r)
+{
+ nStartRow = r.nStartRow;
+ nEndRow = r.nEndRow;
+ nPagesX = r.nPagesX;
+ if (r.pHidden && nPagesX)
+ {
+ pHidden = new BOOL[nPagesX];
+ memcpy( pHidden, r.pHidden, nPagesX * sizeof(BOOL) );
+ }
+ else
+ pHidden = NULL;
+}
+
+const ScPageRowEntry& ScPageRowEntry::operator=(const ScPageRowEntry& r)
+{
+ delete[] pHidden;
+
+ nStartRow = r.nStartRow;
+ nEndRow = r.nEndRow;
+ nPagesX = r.nPagesX;
+ if (r.pHidden && nPagesX)
+ {
+ pHidden = new BOOL[nPagesX];
+ memcpy( pHidden, r.pHidden, nPagesX * sizeof(BOOL) );
+ }
+ else
+ pHidden = NULL;
+
+ return *this;
+}
+
+void ScPageRowEntry::SetPagesX(size_t nNew)
+{
+ if (pHidden)
+ {
+ DBG_ERROR("SetPagesX nicht nach SetHidden");
+ delete[] pHidden;
+ pHidden = NULL;
+ }
+ nPagesX = nNew;
+}
+
+void ScPageRowEntry::SetHidden(size_t nX)
+{
+ if ( nX < nPagesX )
+ {
+ if ( nX+1 == nPagesX ) // letzte Seite?
+ --nPagesX;
+ else
+ {
+ if (!pHidden)
+ {
+ pHidden = new BOOL[nPagesX];
+ memset( pHidden, FALSE, nPagesX * sizeof(BOOL) );
+ }
+ pHidden[nX] = TRUE;
+ }
+ }
+}
+
+BOOL ScPageRowEntry::IsHidden(size_t nX) const
+{
+ return nX>=nPagesX || ( pHidden && pHidden[nX] ); //! inline?
+}
+
+size_t ScPageRowEntry::CountVisible() const
+{
+ if ( pHidden )
+ {
+ size_t nVis = 0;
+ for (size_t i=0; i<nPagesX; i++)
+ if (!pHidden[i])
+ ++nVis;
+ return nVis;
+ }
+ else
+ return nPagesX;
+}
+
+//------------------------------------------------------------------------
+
+long lcl_LineTotal(const SvxBorderLine* pLine)
+{
+ return pLine ? ( pLine->GetOutWidth() + pLine->GetInWidth() + pLine->GetDistance() ) : 0;
+}
+
+void ScPrintFunc::Construct( const ScPrintOptions* pOptions )
+{
+ pDocShell->UpdatePendingRowHeights( nPrintTab );
+ pDoc = pDocShell->GetDocument();
+
+ SfxPrinter* pDocPrinter = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen
+ if (pDocPrinter)
+ aOldPrinterMode = pDocPrinter->GetMapMode();
+
+ // einheitlicher MapMode ueber alle Aufrufe (z.B. Repaint !!!),
+ // weil die EditEngine sonst unterschiedliche Texthoehen liefert
+ pDev->SetMapMode(MAP_PIXEL);
+
+ pPageEndX = NULL;
+ pPageEndY = NULL;
+ pPageRows = NULL;
+ pBorderItem = NULL;
+ pBackgroundItem = NULL;
+ pShadowItem = NULL;
+
+ pEditEngine = NULL;
+ pEditDefaults = NULL;
+
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
+ pDoc->GetPageStyle( nPrintTab ),
+ SFX_STYLE_FAMILY_PAGE );
+ if (pStyleSheet)
+ pParamSet = &pStyleSheet->GetItemSet();
+ else
+ {
+ DBG_ERROR("Seitenvorlage nicht gefunden" );
+ pParamSet = NULL;
+ }
+
+ if (!bState)
+ nZoom = 100;
+ nManualZoom = 100;
+ bClearWin = FALSE;
+ bUseStyleColor = FALSE;
+ bIsRender = FALSE;
+
+ InitParam(pOptions);
+
+ pPageData = NULL; // wird nur zur Initialisierung gebraucht
+}
+
+ScPrintFunc::ScPrintFunc( ScDocShell* pShell, SfxPrinter* pNewPrinter, SCTAB nTab,
+ long nPage, long nDocP, const ScRange* pArea,
+ const ScPrintOptions* pOptions,
+ ScPageBreakData* pData )
+ : pDocShell ( pShell ),
+ pPrinter ( pNewPrinter ),
+ pDrawView ( NULL ),
+ nPrintTab ( nTab ),
+ nPageStart ( nPage ),
+ nDocPages ( nDocP ),
+ pUserArea ( pArea ),
+ bState ( FALSE ),
+ bSourceRangeValid ( FALSE ),
+ bPrintCurrentTable ( FALSE ),
+ bMultiArea ( FALSE ),
+ nTabPages ( 0 ),
+ nTotalPages ( 0 ),
+ pPageData ( pData )
+{
+ pDev = pPrinter;
+ aSrcOffset = pPrinter->PixelToLogic( pPrinter->GetPageOffsetPixel(), MAP_100TH_MM );
+ Construct( pOptions );
+}
+
+ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell, SCTAB nTab,
+ long nPage, long nDocP, const ScRange* pArea,
+ const ScPrintOptions* pOptions )
+ : pDocShell ( pShell ),
+ pPrinter ( NULL ),
+ pDrawView ( NULL ),
+ nPrintTab ( nTab ),
+ nPageStart ( nPage ),
+ nDocPages ( nDocP ),
+ pUserArea ( pArea ),
+ bState ( FALSE ),
+ bSourceRangeValid ( FALSE ),
+ bPrintCurrentTable ( FALSE ),
+ bMultiArea ( FALSE ),
+ nTabPages ( 0 ),
+ nTotalPages ( 0 ),
+ pPageData ( NULL )
+{
+ pDev = pOutDev;
+ Construct( pOptions );
+}
+
+ScPrintFunc::ScPrintFunc( OutputDevice* pOutDev, ScDocShell* pShell,
+ const ScPrintState& rState, const ScPrintOptions* pOptions )
+ : pDocShell ( pShell ),
+ pPrinter ( NULL ),
+ pDrawView ( NULL ),
+ pUserArea ( NULL ),
+ bSourceRangeValid ( FALSE ),
+ bPrintCurrentTable ( FALSE ),
+ bMultiArea ( FALSE ),
+ pPageData ( NULL )
+{
+ pDev = pOutDev;
+
+ nPrintTab = rState.nPrintTab;
+ nStartCol = rState.nStartCol;
+ nStartRow = rState.nStartRow;
+ nEndCol = rState.nEndCol;
+ nEndRow = rState.nEndRow;
+ nZoom = rState.nZoom;
+ nPagesX = rState.nPagesX;
+ nPagesY = rState.nPagesY;
+ nTabPages = rState.nTabPages;
+ nTotalPages = rState.nTotalPages;
+ nPageStart = rState.nPageStart;
+ nDocPages = rState.nDocPages;
+ bState = TRUE;
+
+ Construct( pOptions );
+}
+ScPrintFunc::ScPrintFunc( ScDocShell* pShell, Window* pWindow, SCTAB nTab,
+ long nPage, long nDocP, const ScRange* pArea,
+ const ScPrintOptions* pOptions )
+ : pDocShell ( pShell ),
+ pPrinter ( NULL ),
+ pDrawView ( NULL ),
+ nPrintTab ( nTab ),
+ nPageStart ( nPage ),
+ nDocPages ( nDocP ),
+ pUserArea ( pArea ),
+ bState ( FALSE ),
+ bPrintCurrentTable ( FALSE ),
+ bMultiArea ( FALSE ),
+ nTabPages ( 0 ),
+ nTotalPages ( 0 ),
+ pPageData ( NULL )
+{
+ pDev = pWindow;
+ Construct( pOptions );
+}
+ScPrintFunc::ScPrintFunc( ScDocShell* pShell, Window* pWindow,
+ const ScPrintState& rState, const ScPrintOptions* pOptions )
+ : pDocShell ( pShell ),
+ pPrinter ( NULL ),
+ pDrawView ( NULL ),
+ pUserArea ( NULL ),
+ bPrintCurrentTable ( FALSE ),
+ bMultiArea ( FALSE ),
+ pPageData ( NULL )
+{
+ pDev = pWindow;
+
+ nPrintTab = rState.nPrintTab;
+ nStartCol = rState.nStartCol;
+ nStartRow = rState.nStartRow;
+ nEndCol = rState.nEndCol;
+ nEndRow = rState.nEndRow;
+ nZoom = rState.nZoom;
+ nPagesX = rState.nPagesX;
+ nPagesY = rState.nPagesY;
+ nTabPages = rState.nTabPages;
+ nTotalPages = rState.nTotalPages;
+ nPageStart = rState.nPageStart;
+ nDocPages = rState.nDocPages;
+ bState = TRUE;
+
+ Construct( pOptions );
+}
+
+void ScPrintFunc::GetPrintState( ScPrintState& rState )
+{
+ rState.nPrintTab = nPrintTab;
+ rState.nStartCol = nStartCol;
+ rState.nStartRow = nStartRow;
+ rState.nEndCol = nEndCol;
+ rState.nEndRow = nEndRow;
+ rState.nZoom = nZoom;
+ rState.nPagesX = nPagesX;
+ rState.nPagesY = nPagesY;
+ rState.nTabPages = nTabPages;
+ rState.nTotalPages = nTotalPages;
+ rState.nPageStart = nPageStart;
+ rState.nDocPages = nDocPages;
+}
+
+BOOL ScPrintFunc::GetLastSourceRange( ScRange& rRange ) const
+{
+ rRange = aLastSourceRange;
+ return bSourceRangeValid;
+}
+
+void ScPrintFunc::FillPageData()
+{
+ if (pPageData)
+ {
+ USHORT nCount = sal::static_int_cast<USHORT>( pPageData->GetCount() );
+ ScPrintRangeData& rData = pPageData->GetData(nCount); // hochzaehlen
+
+ rData.SetPrintRange( ScRange( nStartCol, nStartRow, nPrintTab,
+ nEndCol, nEndRow, nPrintTab ) );
+ rData.SetPagesX( nPagesX, pPageEndX );
+ rData.SetPagesY( nTotalY, pPageEndY );
+
+ // Einstellungen
+ rData.SetTopDown( aTableParam.bTopDown );
+ rData.SetAutomatic( !aAreaParam.bPrintArea );
+ }
+}
+
+ScPrintFunc::~ScPrintFunc()
+{
+ ScAddress* pTripel = (ScAddress*) aNotePosList.First();
+ while (pTripel)
+ {
+ delete pTripel;
+ pTripel = (ScAddress*) aNotePosList.Next();
+ }
+ aNotePosList.Clear();
+
+ delete[] pPageEndX;
+ delete[] pPageEndY;
+ delete[] pPageRows;
+ delete pEditDefaults;
+ delete pEditEngine;
+
+ // Druckereinstellungen werden jetzt von aussen wiederhergestellt
+
+ // #64294# Fuer DrawingLayer/Charts muss der MapMode am Drucker (RefDevice) immer stimmen
+ SfxPrinter* pDocPrinter = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen
+ if (pDocPrinter)
+ pDocPrinter->SetMapMode(aOldPrinterMode);
+}
+
+void ScPrintFunc::SetDrawView( FmFormView* pNew )
+{
+ pDrawView = pNew;
+}
+
+void lcl_HidePrint( ScTableInfo& rTabInfo, SCCOL nX1, SCCOL nX2 )
+{
+ for (SCSIZE nArrY=1; nArrY+1<rTabInfo.mnArrCount; nArrY++)
+ {
+ RowInfo* pThisRowInfo = &rTabInfo.mpRowInfo[nArrY];
+ for (SCCOL nX=nX1; nX<=nX2; nX++)
+ {
+ const CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nX+1];
+ if (!rCellInfo.bEmptyCellText)
+ if (((const ScProtectionAttr&)rCellInfo.pPatternAttr->
+ GetItem(ATTR_PROTECTION, rCellInfo.pConditionSet)).GetHidePrint())
+ {
+ pThisRowInfo->pCellInfo[nX+1].pCell = NULL;
+ pThisRowInfo->pCellInfo[nX+1].bEmptyCellText = TRUE;
+ }
+ }
+ }
+}
+
+//
+// Ausgabe auf Device (static)
+//
+// wird benutzt fuer:
+// - Clipboard/Bitmap
+// - Ole-Object (DocShell::Draw)
+// - Vorschau bei Vorlagen
+
+void ScPrintFunc::DrawToDev( ScDocument* pDoc, OutputDevice* pDev, double /* nPrintFactor */,
+ const Rectangle& rBound, ScViewData* pViewData, BOOL bMetaFile )
+{
+ //! nPrintFactor auswerten !!!
+
+ SCTAB nTab = 0;
+ if (pViewData)
+ nTab = pViewData->GetTabNo();
+
+ BOOL bDoGrid, bNullVal, bFormula;
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( pDoc->GetPageStyle( nTab ), SFX_STYLE_FAMILY_PAGE );
+ if (pStyleSheet)
+ {
+ SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ bDoGrid = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_GRID)).GetValue();
+ bNullVal = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_NULLVALS)).GetValue();
+ bFormula = ((const SfxBoolItem&)rSet.Get(ATTR_PAGE_FORMULAS)).GetValue();
+ }
+ else
+ {
+ const ScViewOptions& rOpt = pDoc->GetViewOptions();
+ bDoGrid = rOpt.GetOption(VOPT_GRID);
+ bNullVal = rOpt.GetOption(VOPT_NULLVALS);
+ bFormula = rOpt.GetOption(VOPT_FORMULAS);
+ }
+
+ MapMode aMode = pDev->GetMapMode();
+
+ Rectangle aRect = rBound;
+
+ if (aRect.Right() < aRect.Left() || aRect.Bottom() < aRect.Top())
+ aRect = Rectangle( Point(), pDev->GetOutputSize() );
+
+ SCCOL nX1 = 0;
+ SCROW nY1 = 0;
+ SCCOL nX2 = OLE_STD_CELLS_X - 1;
+ SCROW nY2 = OLE_STD_CELLS_Y - 1;
+ if (bMetaFile)
+ {
+ ScRange aRange = pDoc->GetRange( nTab, rBound );
+ nX1 = aRange.aStart.Col();
+ nY1 = aRange.aStart.Row();
+ nX2 = aRange.aEnd.Col();
+ nY2 = aRange.aEnd.Row();
+ }
+ else if (pViewData)
+ {
+ ScSplitPos eWhich = pViewData->GetActivePart();
+ ScHSplitPos eHWhich = WhichH(eWhich);
+ ScVSplitPos eVWhich = WhichV(eWhich);
+ nX1 = pViewData->GetPosX(eHWhich);
+ nY1 = pViewData->GetPosY(eVWhich);
+ nX2 = nX1 + pViewData->VisibleCellsX(eHWhich);
+ if (nX2>nX1) --nX2;
+ nY2 = nY1 + pViewData->VisibleCellsY(eVWhich);
+ if (nY2>nY1) --nY2;
+ }
+
+ if (nX1 > MAXCOL) nX1 = MAXCOL;
+ if (nX2 > MAXCOL) nX2 = MAXCOL;
+ if (nY1 > MAXROW) nY1 = MAXROW;
+ if (nY2 > MAXROW) nY2 = MAXROW;
+
+ long nDevSizeX = aRect.Right()-aRect.Left()+1;
+ long nDevSizeY = aRect.Bottom()-aRect.Top()+1;
+
+ Rectangle aLines;
+ ScRange aRange( nX1,nY1,nTab, nX2,nY2,nTab );
+// BOOL bAddLines = pDoc->HasLines( aRange, aLines );
+
+ long nTwipsSizeX = 0;
+ for (SCCOL i=nX1; i<=nX2; i++)
+ nTwipsSizeX += pDoc->GetColWidth( i, nTab );
+ long nTwipsSizeY = (long) pDoc->GetRowHeight( nY1, nY2, nTab );
+
+ // wenn keine Linien, dann trotzdem Platz fuer den Aussenrahmen (20 Twips = 1pt)
+ // (HasLines initalisiert aLines auf 0,0,0,0)
+ nTwipsSizeX += aLines.Left() + Max( aLines.Right(), 20L );
+ nTwipsSizeY += aLines.Top() + Max( aLines.Bottom(), 20L );
+
+ double nScaleX = (double) nDevSizeX / nTwipsSizeX;
+ double nScaleY = (double) nDevSizeY / nTwipsSizeY;
+
+ //! Flag bei FillInfo uebergeben !!!!!
+ ScRange aERange;
+ BOOL bEmbed = pDoc->IsEmbedded();
+ if (bEmbed)
+ {
+ pDoc->GetEmbedded(aERange);
+ pDoc->ResetEmbedded();
+ }
+
+ // Daten zusammenstellen
+
+ ScTableInfo aTabInfo;
+ pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nTab,
+ nScaleX, nScaleY, FALSE, bFormula );
+ lcl_HidePrint( aTabInfo, nX1, nX2 );
+
+ if (bEmbed)
+ pDoc->SetEmbedded(aERange);
+
+/* if (!bMetaFile)
+ pDev->SetMapMode(MAP_PIXEL);
+*/
+ long nScrX = aRect.Left();
+ long nScrY = aRect.Top();
+
+ // Wenn keine Linien, trotzdem Platz fuer Gitterlinien lassen
+ // (werden sonst abgeschnitten)
+ long nAddX = (long)( aLines.Left() * nScaleX );
+ nScrX += ( nAddX ? nAddX : 1 );
+ long nAddY = (long)( aLines.Top() * nScaleY );
+ nScrY += ( nAddY ? nAddY : 1 );
+
+ ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nTab,
+ nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
+ aOutputData.SetMetaFileMode(bMetaFile);
+ aOutputData.SetShowNullValues(bNullVal);
+ aOutputData.SetShowFormulas(bFormula);
+
+ // #114135#
+ ScDrawLayer* pModel = pDoc->GetDrawLayer();
+ FmFormView* pDrawView = NULL;
+
+ if( pModel )
+ {
+ pDrawView = new FmFormView( pModel, pDev );
+ pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
+ pDrawView->SetPrintPreview( TRUE );
+ aOutputData.SetDrawView( pDrawView );
+ }
+
+ //! SetUseStyleColor ??
+
+ if ( bMetaFile && pDev->GetOutDevType() == OUTDEV_VIRDEV )
+ aOutputData.SetSnapPixel();
+
+ Point aLogStart = pDev->PixelToLogic( Point(nScrX,nScrY), MAP_100TH_MM );
+ long nLogStX = aLogStart.X();
+ long nLogStY = aLogStart.Y();
+
+ //! nZoom fuer GetFont in OutputData ???
+
+ if (!bMetaFile && pViewData)
+ pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
+
+ // #i72502#
+ const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
+ aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
+
+ if (!bMetaFile && pViewData)
+ pDev->SetMapMode(aMode);
+
+ aOutputData.DrawBackground();
+
+#ifdef OS2
+ if (bMetaFile && !bDoGrid)
+ {
+ // unter OS2 fuer Metafiles gesamte Flaeche benutzen,
+ // weil sonst die Groesse nicht erkannt wird
+ pDev->SetLineColor();
+ pDev->SetFillColor();
+ pDev->DrawRect( Rectangle( nScrX,nScrY,
+ nScrX+aOutputData.GetScrW(), nScrY+aOutputData.GetScrH() ) );
+ }
+#endif
+
+ aOutputData.DrawShadow();
+ aOutputData.DrawFrame();
+ aOutputData.DrawStrings();
+
+ if (!bMetaFile && pViewData)
+ pDev->SetMapMode(pViewData->GetLogicMode(pViewData->GetActivePart()));
+
+ aOutputData.DrawEdit(!bMetaFile);
+
+ if (bDoGrid)
+ {
+ if (!bMetaFile && pViewData)
+ pDev->SetMapMode(aMode);
+
+ aOutputData.DrawGrid( TRUE, FALSE ); // keine Seitenumbrueche
+
+ pDev->SetLineColor( COL_BLACK );
+
+ Size aOne = pDev->PixelToLogic( Size(1,1) );
+ if (bMetaFile)
+ aOne = Size(1,1); // compatible with DrawGrid
+ long nRight = nScrX + aOutputData.GetScrW() - aOne.Width();
+ long nBottom = nScrY + aOutputData.GetScrH() - aOne.Height();
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ // extra line at the left edge for left-to-right, right for right-to-left
+ if ( bLayoutRTL )
+ pDev->DrawLine( Point(nRight,nScrY), Point(nRight,nBottom) );
+ else
+ pDev->DrawLine( Point(nScrX,nScrY), Point(nScrX,nBottom) );
+ // extra line at the top in both cases
+ pDev->DrawLine( Point(nScrX,nScrY), Point(nRight,nScrY) );
+ }
+
+ // #i72502#
+ aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
+ aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
+ aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
+
+ // #114135#
+ delete pDrawView;
+}
+
+//
+// Drucken
+//
+
+void lcl_FillHFParam( ScPrintHFParam& rParam, const SfxItemSet* pHFSet )
+{
+ // nDistance muss vorher unterschiedlich initalisiert sein
+
+ if ( pHFSet == NULL )
+ {
+ rParam.bEnable = FALSE;
+ rParam.pBorder = NULL;
+ rParam.pBack = NULL;
+ rParam.pShadow = NULL;
+ }
+ else
+ {
+ rParam.bEnable = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_ON)).GetValue();
+ rParam.bDynamic = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_DYNAMIC)).GetValue();
+ rParam.bShared = ((const SfxBoolItem&) pHFSet->Get(ATTR_PAGE_SHARED)).GetValue();
+ rParam.nHeight = ((const SvxSizeItem&) pHFSet->Get(ATTR_PAGE_SIZE)).GetSize().Height();
+ const SvxLRSpaceItem* pHFLR = &(const SvxLRSpaceItem&) pHFSet->Get(ATTR_LRSPACE);
+ long nTmp;
+ nTmp = pHFLR->GetLeft();
+ rParam.nLeft = nTmp < 0 ? 0 : USHORT(nTmp);
+ nTmp = pHFLR->GetRight();
+ rParam.nRight = nTmp < 0 ? 0 : USHORT(nTmp);
+ rParam.pBorder = (const SvxBoxItem*) &pHFSet->Get(ATTR_BORDER);
+ rParam.pBack = (const SvxBrushItem*) &pHFSet->Get(ATTR_BACKGROUND);
+ rParam.pShadow = (const SvxShadowItem*)&pHFSet->Get(ATTR_SHADOW);;
+
+// jetzt doch wieder schon im Dialog:
+// rParam.nHeight += rParam.nDistance; // nicht mehr im Dialog ???
+
+ if (rParam.pBorder)
+ rParam.nHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
+ lcl_LineTotal( rParam.pBorder->GetBottom() );
+
+ rParam.nManHeight = rParam.nHeight;
+ }
+
+ if (!rParam.bEnable)
+ rParam.nHeight = 0;
+}
+
+// bNew = TRUE: benutzten Bereich aus dem Dokument suchen
+// bNew = FALSE: nur ganze Zeilen/Spalten begrenzen
+
+BOOL ScPrintFunc::AdjustPrintArea( BOOL bNew )
+{
+ SCCOL nOldEndCol = nEndCol; // nur wichtig bei !bNew
+ SCROW nOldEndRow = nEndRow;
+ BOOL bChangeCol = TRUE; // bei bNew werden beide angepasst
+ BOOL bChangeRow = TRUE;
+
+ BOOL bNotes = aTableParam.bNotes;
+ if ( bNew )
+ {
+ nStartCol = 0;
+ nStartRow = 0;
+ if (!pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ))
+ return FALSE; // nix
+ }
+ else
+ {
+ BOOL bFound = TRUE;
+ bChangeCol = ( nStartCol == 0 && nEndCol == MAXCOL );
+ bChangeRow = ( nStartRow == 0 && nEndRow == MAXROW );
+ BOOL bForcedChangeRow = FALSE;
+
+ // #i53558# Crop entire column of old row limit to real print area with
+ // some fuzzyness.
+ if (!bChangeRow && nStartRow == 0)
+ {
+ SCROW nPAEndRow;
+ bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nPAEndRow, bNotes );
+ // Say we don't want to print more than ~1000 empty rows, which are
+ // about 14 pages intentionally left blank..
+ const SCROW nFuzzy = 23*42;
+ if (nPAEndRow + nFuzzy < nEndRow)
+ {
+ bForcedChangeRow = TRUE;
+ nEndRow = nPAEndRow;
+ }
+ else
+ bFound = TRUE; // user seems to _want_ to print some empty rows
+ }
+ // TODO: in case we extend the number of columns we may have to do the
+ // same for horizontal cropping.
+
+ if ( bChangeCol && bChangeRow )
+ bFound = pDoc->GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes );
+ else if ( bChangeCol )
+ bFound = pDoc->GetPrintAreaHor( nPrintTab, nStartRow, nEndRow, nEndCol, bNotes );
+ else if ( bChangeRow )
+ bFound = pDoc->GetPrintAreaVer( nPrintTab, nStartCol, nEndCol, nEndRow, bNotes );
+
+ if (!bFound)
+ return FALSE; // leer
+
+ if (bForcedChangeRow)
+ bChangeRow = TRUE;
+ }
+
+ pDoc->ExtendMerge( nStartCol,nStartRow, nEndCol,nEndRow, nPrintTab,
+ FALSE, TRUE ); // kein Refresh, incl. Attrs
+
+ if ( bChangeCol )
+ {
+ OutputDevice* pRefDev = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen
+ pRefDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize
+
+ pDoc->ExtendPrintArea( pRefDev,
+ nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow );
+ // nEndCol wird veraendert
+ }
+
+ if ( nEndCol < MAXCOL && pDoc->HasAttrib(
+ nEndCol,nStartRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_RIGHT ) )
+ ++nEndCol;
+ if ( nEndRow < MAXROW && pDoc->HasAttrib(
+ nStartCol,nEndRow,nPrintTab, nEndCol,nEndRow,nPrintTab, HASATTR_SHADOW_DOWN ) )
+ ++nEndRow;
+
+ if (!bChangeCol) nEndCol = nOldEndCol;
+ if (!bChangeRow) nEndRow = nOldEndRow;
+
+ return TRUE;
+}
+
+long ScPrintFunc::TextHeight( const EditTextObject* pObject )
+{
+ if (!pObject)
+ return 0;
+
+// pEditEngine->SetPageNo( nTotalPages );
+ pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE );
+
+ return (long) pEditEngine->GetTextHeight();
+}
+
+// nZoom muss gesetzt sein !!!
+// und der entsprechende Twip-MapMode eingestellt
+
+void ScPrintFunc::UpdateHFHeight( ScPrintHFParam& rParam )
+{
+ DBG_ASSERT( aPageSize.Width(), "UpdateHFHeight ohne aPageSize");
+
+ if (rParam.bEnable && rParam.bDynamic)
+ {
+ // nHeight aus Inhalten berechnen
+
+ MakeEditEngine();
+ long nPaperWidth = ( aPageSize.Width() - nLeftMargin - nRightMargin -
+ rParam.nLeft - rParam.nRight ) * 100 / nZoom;
+ if (rParam.pBorder)
+ nPaperWidth -= ( rParam.pBorder->GetDistance(BOX_LINE_LEFT) +
+ rParam.pBorder->GetDistance(BOX_LINE_RIGHT) +
+ lcl_LineTotal(rParam.pBorder->GetLeft()) +
+ lcl_LineTotal(rParam.pBorder->GetRight()) ) * 100 / nZoom;
+
+ if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
+ nPaperWidth -= ( rParam.pShadow->CalcShadowSpace(SHADOW_LEFT) +
+ rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT) ) * 100L / nZoom;
+
+ pEditEngine->SetPaperSize( Size( nPaperWidth, 10000 ) );
+
+ long nMaxHeight = 0;
+ if ( rParam.pLeft )
+ {
+ nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetLeftArea() ) );
+ nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetCenterArea() ) );
+ nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pLeft->GetRightArea() ) );
+ }
+ if ( rParam.pRight )
+ {
+ nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetLeftArea() ) );
+ nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetCenterArea() ) );
+ nMaxHeight = Max( nMaxHeight, TextHeight( rParam.pRight->GetRightArea() ) );
+ }
+
+ rParam.nHeight = nMaxHeight + rParam.nDistance;
+ if (rParam.pBorder)
+ rParam.nHeight += rParam.pBorder->GetDistance(BOX_LINE_TOP) +
+ rParam.pBorder->GetDistance(BOX_LINE_BOTTOM) +
+ lcl_LineTotal( rParam.pBorder->GetTop() ) +
+ lcl_LineTotal( rParam.pBorder->GetBottom() );
+ if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
+ rParam.nHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
+ rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
+
+ if (rParam.nHeight < rParam.nManHeight)
+ rParam.nHeight = rParam.nManHeight; // eingestelltes Minimum
+ }
+}
+
+void ScPrintFunc::InitParam( const ScPrintOptions* pOptions )
+{
+ if (!pParamSet)
+ return;
+
+ // TabPage "Seite"
+ const SvxLRSpaceItem* pLRItem = (const SvxLRSpaceItem*) &pParamSet->Get( ATTR_LRSPACE );
+ long nTmp;
+ nTmp = pLRItem->GetLeft();
+ nLeftMargin = nTmp < 0 ? 0 : USHORT(nTmp);
+ nTmp = pLRItem->GetRight();
+ nRightMargin = nTmp < 0 ? 0 : USHORT(nTmp);
+ const SvxULSpaceItem* pULItem = (const SvxULSpaceItem*) &pParamSet->Get( ATTR_ULSPACE );
+ nTopMargin = pULItem->GetUpper();
+ nBottomMargin = pULItem->GetLower();
+
+ const SvxPageItem* pPageItem = (const SvxPageItem*) &pParamSet->Get( ATTR_PAGE );
+ nPageUsage = pPageItem->GetPageUsage();
+ bLandscape = pPageItem->IsLandscape();
+ aFieldData.eNumType = pPageItem->GetNumType();
+
+ bCenterHor = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_HORCENTER)).GetValue();
+ bCenterVer = ((const SfxBoolItem&) pParamSet->Get(ATTR_PAGE_VERCENTER)).GetValue();
+
+ aPageSize = ((const SvxSizeItem&) pParamSet->Get(ATTR_PAGE_SIZE)).GetSize();
+ if ( !aPageSize.Width() || !aPageSize.Height() )
+ {
+ DBG_ERROR("PageSize Null ?!?!?");
+ aPageSize = SvxPaperInfo::GetPaperSize( PAPER_A4 );
+ }
+
+ pBorderItem = (const SvxBoxItem*) &pParamSet->Get(ATTR_BORDER);
+ pBackgroundItem = (const SvxBrushItem*) &pParamSet->Get(ATTR_BACKGROUND);
+ pShadowItem = (const SvxShadowItem*) &pParamSet->Get(ATTR_SHADOW);
+
+ // TabPage "Kopfzeile"
+
+ aHdr.pLeft = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_HEADERLEFT); // Inhalt
+ aHdr.pRight = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_HEADERRIGHT);
+
+ const SvxSetItem* pHeaderSetItem;
+ const SfxItemSet* pHeaderSet = NULL;
+ if ( pParamSet->GetItemState( ATTR_PAGE_HEADERSET, FALSE,
+ (const SfxPoolItem**)&pHeaderSetItem ) == SFX_ITEM_SET )
+ {
+ pHeaderSet = &pHeaderSetItem->GetItemSet();
+ // Kopfzeile hat unteren Abstand
+ aHdr.nDistance = ((const SvxULSpaceItem&) pHeaderSet->Get(ATTR_ULSPACE)).GetLower();
+ }
+ lcl_FillHFParam( aHdr, pHeaderSet );
+
+ // TabPage "Fusszeile"
+
+ aFtr.pLeft = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_FOOTERLEFT); // Inhalt
+ aFtr.pRight = (const ScPageHFItem*) &pParamSet->Get(ATTR_PAGE_FOOTERRIGHT);
+
+ const SvxSetItem* pFooterSetItem;
+ const SfxItemSet* pFooterSet = NULL;
+ if ( pParamSet->GetItemState( ATTR_PAGE_FOOTERSET, FALSE,
+ (const SfxPoolItem**)&pFooterSetItem ) == SFX_ITEM_SET )
+ {
+ pFooterSet = &pFooterSetItem->GetItemSet();
+ // Fusszeile hat oberen Abstand
+ aFtr.nDistance = ((const SvxULSpaceItem&) pFooterSet->Get(ATTR_ULSPACE)).GetUpper();
+ }
+ lcl_FillHFParam( aFtr, pFooterSet );
+
+ //------------------------------------------------------
+ // Table-/Area-Params aus einzelnen Items zusammenbauen:
+ //------------------------------------------------------
+ // TabPage "Tabelle"
+
+ const SfxUInt16Item* pScaleItem = NULL;
+ const ScPageScaleToItem* pScaleToItem = NULL;
+ const SfxUInt16Item* pScaleToPagesItem = NULL;
+ SfxItemState eState;
+
+ eState = pParamSet->GetItemState( ATTR_PAGE_SCALE, FALSE,
+ (const SfxPoolItem**)&pScaleItem );
+ if ( SFX_ITEM_DEFAULT == eState )
+ pScaleItem = (const SfxUInt16Item*)
+ &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALE );
+
+ eState = pParamSet->GetItemState( ATTR_PAGE_SCALETO, FALSE,
+ (const SfxPoolItem**)&pScaleToItem );
+ if ( SFX_ITEM_DEFAULT == eState )
+ pScaleToItem = (const ScPageScaleToItem*)
+ &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETO );
+
+ eState = pParamSet->GetItemState( ATTR_PAGE_SCALETOPAGES, FALSE,
+ (const SfxPoolItem**)&pScaleToPagesItem );
+ if ( SFX_ITEM_DEFAULT == eState )
+ pScaleToPagesItem = (const SfxUInt16Item*)
+ &pParamSet->GetPool()->GetDefaultItem( ATTR_PAGE_SCALETOPAGES );
+
+ DBG_ASSERT( pScaleItem && pScaleToItem && pScaleToPagesItem, "Missing ScaleItem! :-/" );
+
+ aTableParam.bCellContent = TRUE;
+ aTableParam.bNotes = GET_BOOL(pParamSet,ATTR_PAGE_NOTES);
+ aTableParam.bGrid = GET_BOOL(pParamSet,ATTR_PAGE_GRID);
+ aTableParam.bHeaders = GET_BOOL(pParamSet,ATTR_PAGE_HEADERS);
+ aTableParam.bFormulas = GET_BOOL(pParamSet,ATTR_PAGE_FORMULAS);
+ aTableParam.bNullVals = GET_BOOL(pParamSet,ATTR_PAGE_NULLVALS);
+ aTableParam.bCharts = GET_SHOW(pParamSet,ATTR_PAGE_CHARTS);
+ aTableParam.bObjects = GET_SHOW(pParamSet,ATTR_PAGE_OBJECTS);
+ aTableParam.bDrawings = GET_SHOW(pParamSet,ATTR_PAGE_DRAWINGS);
+ aTableParam.bTopDown = GET_BOOL(pParamSet,ATTR_PAGE_TOPDOWN);
+ aTableParam.bLeftRight = !aTableParam.bLeftRight;
+ aTableParam.nFirstPageNo = GET_USHORT(pParamSet,ATTR_PAGE_FIRSTPAGENO);
+ if (!aTableParam.nFirstPageNo)
+ aTableParam.nFirstPageNo = (USHORT) nPageStart; // von vorheriger Tabelle
+
+ if ( pScaleItem && pScaleToItem && pScaleToPagesItem )
+ {
+ UINT16 nScaleAll = pScaleItem->GetValue();
+ UINT16 nScaleToPages = pScaleToPagesItem->GetValue();
+
+ aTableParam.bScaleNone = (nScaleAll == 100);
+ aTableParam.bScaleAll = (nScaleAll > 0 );
+ aTableParam.bScaleTo = pScaleToItem->IsValid();
+ aTableParam.bScalePageNum = (nScaleToPages > 0 );
+ aTableParam.nScaleAll = nScaleAll;
+ aTableParam.nScaleWidth = pScaleToItem->GetWidth();
+ aTableParam.nScaleHeight = pScaleToItem->GetHeight();
+ aTableParam.nScalePageNum = nScaleToPages;
+ }
+ else
+ {
+ aTableParam.bScaleNone = TRUE;
+ aTableParam.bScaleAll = FALSE;
+ aTableParam.bScaleTo = FALSE;
+ aTableParam.bScalePageNum = FALSE;
+ aTableParam.nScaleAll = 0;
+ aTableParam.nScaleWidth = 0;
+ aTableParam.nScaleHeight = 0;
+ aTableParam.nScalePageNum = 0;
+ }
+
+ // skip empty pages only if options with that flag are passed
+ aTableParam.bSkipEmpty = pOptions && pOptions->GetSkipEmpty();
+ if ( pPageData )
+ aTableParam.bSkipEmpty = FALSE;
+ // Wenn pPageData gesetzt ist, interessieren fuer die Umbruch-Vorschau
+ // nur die Umbrueche, leere Seiten werden nicht speziell behandelt
+
+ //------------------------------------------------------
+ // TabPage "Bereiche":
+ //------------------------------------------------------
+
+ //! alle PrintAreas der Tabelle durchgehen !!!
+ const ScRange* pPrintArea = pDoc->GetPrintRange( nPrintTab, 0 );
+ const ScRange* pRepeatCol = pDoc->GetRepeatColRange( nPrintTab );
+ const ScRange* pRepeatRow = pDoc->GetRepeatRowRange( nPrintTab );
+
+ // ATTR_PAGE_PRINTTABLES wird ignoriert
+
+ if ( pUserArea ) // UserArea (Selektion) hat Vorrang
+ {
+ bPrintCurrentTable =
+ aAreaParam.bPrintArea = TRUE; // Selektion
+ aAreaParam.aPrintArea = *pUserArea;
+
+ // Die Tabellen-Abfrage ist schon in DocShell::Print, hier immer
+ aAreaParam.aPrintArea.aStart.SetTab(nPrintTab);
+ aAreaParam.aPrintArea.aEnd.SetTab(nPrintTab);
+
+// lcl_LimitRange( aAreaParam.aPrintArea, nPrintTab ); // ganze Zeilen/Spalten...
+ }
+ else if ( pDoc->HasPrintRange() )
+ {
+ if ( pPrintArea ) // mindestens eine gesetzt ?
+ {
+ bPrintCurrentTable =
+ aAreaParam.bPrintArea = TRUE;
+ aAreaParam.aPrintArea = *pPrintArea;
+
+ bMultiArea = ( pDoc->GetPrintRangeCount(nPrintTab) > 1 );
+ }
+ else
+ {
+ // do not print hidden sheets with "Print entire sheet" flag
+ bPrintCurrentTable = pDoc->IsPrintEntireSheet( nPrintTab ) && pDoc->IsVisible( nPrintTab );
+ aAreaParam.bPrintArea = !bPrintCurrentTable; // otherwise the table is always counted
+ }
+ }
+ else
+ {
+ // #74834# don't print hidden tables if there's no print range defined there
+ if ( pDoc->IsVisible( nPrintTab ) )
+ {
+ aAreaParam.bPrintArea = FALSE;
+ bPrintCurrentTable = TRUE;
+ }
+ else
+ {
+ aAreaParam.bPrintArea = TRUE; // otherwise the table is always counted
+ bPrintCurrentTable = FALSE;
+ }
+ }
+
+ if ( pRepeatCol )
+ {
+ aAreaParam.bRepeatCol = TRUE;
+ aAreaParam.aRepeatCol = *pRepeatCol;
+ nRepeatStartCol = pRepeatCol->aStart.Col();
+ nRepeatEndCol = pRepeatCol->aEnd .Col();
+ }
+ else
+ {
+ aAreaParam.bRepeatCol = FALSE;
+ nRepeatStartCol = nRepeatEndCol = SCCOL_REPEAT_NONE;
+ }
+
+ if ( pRepeatRow )
+ {
+ aAreaParam.bRepeatRow = TRUE;
+ aAreaParam.aRepeatRow = *pRepeatRow;
+ nRepeatStartRow = pRepeatRow->aStart.Row();
+ nRepeatEndRow = pRepeatRow->aEnd .Row();
+ }
+ else
+ {
+ aAreaParam.bRepeatRow = FALSE;
+ nRepeatStartRow = nRepeatEndRow = SCROW_REPEAT_NONE;
+ }
+
+ //
+ // Seiten aufteilen
+ //
+
+ if (!bState)
+ {
+ nTabPages = CountPages(); // berechnet auch Zoom
+ nTotalPages = nTabPages;
+ nTotalPages += CountNotePages();
+ }
+ else
+ {
+ CalcPages(); // nur Umbrueche suchen
+ CountNotePages(); // Notizen zaehlen, auch wenn Seitenzahl schon bekannt
+ }
+
+ if (nDocPages)
+ aFieldData.nTotalPages = nDocPages;
+ else
+ aFieldData.nTotalPages = nTotalPages;
+
+ SetDateTime( Date(), Time() );
+
+ aFieldData.aTitle = pDocShell->GetTitle();
+ const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
+ aFieldData.aLongDocName = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+ if ( aFieldData.aLongDocName.Len() )
+ aFieldData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
+ else
+ aFieldData.aShortDocName = aFieldData.aLongDocName = aFieldData.aTitle;
+
+ // Druckereinstellungen (Orientation, Paper) jetzt erst bei DoPrint
+}
+
+Size ScPrintFunc::GetDataSize() const
+{
+ Size aSize = aPageSize;
+ aSize.Width() -= nLeftMargin + nRightMargin;
+ aSize.Height() -= nTopMargin + nBottomMargin;
+ aSize.Height() -= aHdr.nHeight + aFtr.nHeight;
+ return aSize;
+}
+
+void ScPrintFunc::GetScaleData( Size& rPhysSize, long& rDocHdr, long& rDocFtr )
+{
+ rPhysSize = aPageSize;
+ rPhysSize.Width() -= nLeftMargin + nRightMargin;
+ rPhysSize.Height() -= nTopMargin + nBottomMargin;
+
+ rDocHdr = aHdr.nHeight;
+ rDocFtr = aFtr.nHeight;
+}
+
+void ScPrintFunc::SetDateTime( const Date& rDate, const Time& rTime )
+{
+ aFieldData.aDate = rDate;
+ aFieldData.aTime = rTime;
+}
+
+void lcl_DrawGraphic( const Graphic &rGraphic, OutputDevice *pOut,
+ const Rectangle &rGrf, const Rectangle &rOut )
+{
+ const bool bNotInside = !rOut.IsInside( rGrf );
+ if ( bNotInside )
+ {
+ pOut->Push();
+ pOut->IntersectClipRegion( rOut );
+ }
+
+ ((Graphic&)rGraphic).Draw( pOut, rGrf.TopLeft(), rGrf.GetSize() );
+
+ if ( bNotInside )
+ pOut->Pop();
+}
+
+void lcl_DrawGraphic( const SvxBrushItem &rBrush, OutputDevice *pOut, OutputDevice* pRefDev,
+ const Rectangle &rOrg, const Rectangle &rOut )
+{
+ Size aGrfSize(0,0);
+ const Graphic *pGraphic = rBrush.GetGraphic();
+ SvxGraphicPosition ePos;
+ if ( pGraphic && pGraphic->IsSupportedGraphic() )
+ {
+ const MapMode aMapMM( MAP_100TH_MM );
+ if ( pGraphic->GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ aGrfSize = pRefDev->PixelToLogic( pGraphic->GetPrefSize(), aMapMM );
+ else
+ aGrfSize = OutputDevice::LogicToLogic( pGraphic->GetPrefSize(),
+ pGraphic->GetPrefMapMode(), aMapMM );
+ ePos = rBrush.GetGraphicPos();
+ }
+ else
+ ePos = GPOS_NONE;
+
+ Point aPos;
+ Size aDrawSize = aGrfSize;
+
+ bool bDraw = TRUE;
+// bool bRetouche = TRUE;
+ switch ( ePos )
+ {
+ case GPOS_LT: aPos = rOrg.TopLeft();
+ break;
+ case GPOS_MT: aPos.Y() = rOrg.Top();
+ aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
+ break;
+ case GPOS_RT: aPos.Y() = rOrg.Top();
+ aPos.X() = rOrg.Right() - aGrfSize.Width();
+ break;
+
+ case GPOS_LM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
+ aPos.X() = rOrg.Left();
+ break;
+ case GPOS_MM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
+ aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
+ break;
+ case GPOS_RM: aPos.Y() = rOrg.Top() + rOrg.GetSize().Height()/2 - aGrfSize.Height()/2;
+ aPos.X() = rOrg.Right() - aGrfSize.Width();
+ break;
+
+ case GPOS_LB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
+ aPos.X() = rOrg.Left();
+ break;
+ case GPOS_MB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
+ aPos.X() = rOrg.Left() + rOrg.GetSize().Width()/2 - aGrfSize.Width()/2;
+ break;
+ case GPOS_RB: aPos.Y() = rOrg.Bottom() - aGrfSize.Height();
+ aPos.X() = rOrg.Right() - aGrfSize.Width();
+ break;
+
+ case GPOS_AREA:
+ aPos = rOrg.TopLeft();
+ aDrawSize = rOrg.GetSize();
+// bRetouche = FALSE;
+ break;
+ case GPOS_TILED:
+ {
+ // #104004# use GraphicObject::DrawTiled instead of an own loop
+ // (pixel rounding is handled correctly, and a very small bitmap
+ // is duplicated into a bigger one for better performance)
+
+ GraphicObject aObject( *pGraphic );
+
+ if( pOut->GetPDFWriter() &&
+ (aObject.GetType() == GRAPHIC_BITMAP || aObject.GetType() == GRAPHIC_DEFAULT) )
+ {
+ // #104004# For PDF export, every draw
+ // operation for bitmaps takes a noticeable
+ // amount of place (~50 characters). Thus,
+ // optimize between tile bitmap size and
+ // number of drawing operations here.
+ //
+ // A_out
+ // n_chars = k1 * ---------- + k2 * A_bitmap
+ // A_bitmap
+ //
+ // minimum n_chars is obtained for (derive for
+ // A_bitmap, set to 0, take positive
+ // solution):
+ // k1
+ // A_bitmap = Sqrt( ---- A_out )
+ // k2
+ //
+ // where k1 is the number of chars per draw
+ // operation, and k2 is the number of chars
+ // per bitmap pixel. This is approximately 50
+ // and 7 for current PDF writer, respectively.
+ //
+ const double k1( 50 );
+ const double k2( 7 );
+ const Size aSize( rOrg.GetSize() );
+ const double Abitmap( k1/k2 * aSize.Width()*aSize.Height() );
+
+ aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0),
+ NULL, GRFMGR_DRAW_STANDARD,
+ ::std::max( 128, static_cast<int>( sqrt(sqrt( Abitmap)) + .5 ) ) );
+ }
+ else
+ {
+ aObject.DrawTiled( pOut, rOrg, aGrfSize, Size(0,0) );
+ }
+
+ bDraw = FALSE;
+// bRetouche = FALSE;
+ }
+ break;
+
+ case GPOS_NONE:
+ bDraw = FALSE;
+ break;
+
+ default: DBG_ASSERT( !pOut, "new Graphic position?" );
+ }
+ Rectangle aGrf( aPos,aDrawSize );
+ if ( bDraw && aGrf.IsOver( rOut ) )
+ {
+ lcl_DrawGraphic( *pGraphic, pOut, aGrf, rOut );
+ }
+}
+
+// Rahmen wird nach innen gezeichnet
+
+void ScPrintFunc::DrawBorder( long nScrX, long nScrY, long nScrW, long nScrH,
+ const SvxBoxItem* pBorderData, const SvxBrushItem* pBackground,
+ const SvxShadowItem* pShadow )
+{
+ //! direkte Ausgabe aus SvxBoxItem !!!
+
+ if (pBorderData)
+ if ( !pBorderData->GetTop() && !pBorderData->GetBottom() && !pBorderData->GetLeft() &&
+ !pBorderData->GetRight() )
+ pBorderData = NULL;
+
+ if (!pBorderData && !pBackground && !pShadow)
+ return; // nichts zu tun
+
+ long nLeft = 0;
+ long nRight = 0;
+ long nTop = 0;
+ long nBottom = 0;
+
+ // aFrameRect - aussen um die Umrandung, ohne Schatten
+ if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE )
+ {
+ nLeft += (long) ( pShadow->CalcShadowSpace(SHADOW_LEFT) * nScaleX );
+ nRight += (long) ( pShadow->CalcShadowSpace(SHADOW_RIGHT) * nScaleX );
+ nTop += (long) ( pShadow->CalcShadowSpace(SHADOW_TOP) * nScaleY );
+ nBottom += (long) ( pShadow->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY );
+ }
+ Rectangle aFrameRect( Point(nScrX+nLeft, nScrY+nTop),
+ Size(nScrW-nLeft-nRight, nScrH-nTop-nBottom) );
+
+ // Mitte der Umrandung, um Linien ueber OutputData zu zeichnen:
+ if (pBorderData)
+ {
+ nLeft += (long) ( lcl_LineTotal(pBorderData->GetLeft()) * nScaleX / 2 );
+ nRight += (long) ( lcl_LineTotal(pBorderData->GetRight()) * nScaleX / 2 );
+ nTop += (long) ( lcl_LineTotal(pBorderData->GetTop()) * nScaleY / 2 );
+ nBottom += (long) ( lcl_LineTotal(pBorderData->GetBottom()) * nScaleY / 2 );
+ }
+ long nEffHeight = nScrH - nTop - nBottom;
+ long nEffWidth = nScrW - nLeft - nRight;
+ if (nEffHeight<=0 || nEffWidth<=0)
+ return; // leer
+
+ // #105733# SvtAccessibilityOptions::GetIsForBorders is no longer used (always assumed TRUE)
+ BOOL bCellContrast = bUseStyleColor &&
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+
+ if ( pBackground && !bCellContrast )
+ {
+// Rectangle aBackRect( Point(nScrX+nLeft, nScrY+nTop), Size(nEffWidth,nEffHeight) );
+ if (pBackground->GetGraphicPos() != GPOS_NONE)
+ {
+ OutputDevice* pRefDev;
+ if ( bIsRender )
+ pRefDev = pDev; // don't use printer for PDF
+ else
+ pRefDev = pDoc->GetPrinter(); // use printer also for preview
+
+ lcl_DrawGraphic( *pBackground, pDev, pRefDev, aFrameRect, aFrameRect );
+ }
+ else
+ {
+ pDev->SetFillColor(pBackground->GetColor());
+ pDev->SetLineColor();
+ pDev->DrawRect(aFrameRect);
+ }
+ }
+
+ if ( pShadow && pShadow->GetLocation() != SVX_SHADOW_NONE )
+ {
+ if ( bCellContrast )
+ pDev->SetFillColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ else
+ pDev->SetFillColor(pShadow->GetColor());
+ pDev->SetLineColor();
+ long nShadowX = (long) ( pShadow->GetWidth() * nScaleX );
+ long nShadowY = (long) ( pShadow->GetWidth() * nScaleY );
+ switch (pShadow->GetLocation())
+ {
+ case SVX_SHADOW_TOPLEFT:
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
+ aFrameRect.Right()-nShadowX, aFrameRect.Top() ) );
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Left()-nShadowX, aFrameRect.Top()-nShadowY,
+ aFrameRect.Left(), aFrameRect.Bottom()-nShadowY ) );
+ break;
+ case SVX_SHADOW_TOPRIGHT:
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Left()+nShadowX, aFrameRect.Top()-nShadowY,
+ aFrameRect.Right()+nShadowX, aFrameRect.Top() ) );
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Right(), aFrameRect.Top()-nShadowY,
+ aFrameRect.Right()+nShadowX, aFrameRect.Bottom()-nShadowY ) );
+ break;
+ case SVX_SHADOW_BOTTOMLEFT:
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Left()-nShadowX, aFrameRect.Bottom(),
+ aFrameRect.Right()-nShadowX, aFrameRect.Bottom()+nShadowY ) );
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Left()-nShadowX, aFrameRect.Top()+nShadowY,
+ aFrameRect.Left(), aFrameRect.Bottom()+nShadowY ) );
+ break;
+ case SVX_SHADOW_BOTTOMRIGHT:
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Left()+nShadowX, aFrameRect.Bottom(),
+ aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
+ pDev->DrawRect( Rectangle(
+ aFrameRect.Right(), aFrameRect.Top()+nShadowY,
+ aFrameRect.Right()+nShadowX, aFrameRect.Bottom()+nShadowY ) );
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+
+ if (pBorderData)
+ {
+ ScDocument* pBorderDoc = new ScDocument( SCDOCMODE_UNDO );
+ pBorderDoc->InitUndo( pDoc, 0,0, TRUE,TRUE );
+ if (pBorderData)
+ pBorderDoc->ApplyAttr( 0,0,0, *pBorderData );
+
+ ScTableInfo aTabInfo;
+ pBorderDoc->FillInfo( aTabInfo, 0,0, 0,0, 0,
+ nScaleX, nScaleY, FALSE, FALSE );
+ DBG_ASSERT(aTabInfo.mnArrCount,"nArrCount == 0");
+
+ aTabInfo.mpRowInfo[1].nHeight = (USHORT) nEffHeight;
+ aTabInfo.mpRowInfo[0].pCellInfo[1].nWidth =
+ aTabInfo.mpRowInfo[1].pCellInfo[1].nWidth = (USHORT) nEffWidth;
+
+ ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pBorderDoc, 0,
+ nScrX+nLeft, nScrY+nTop, 0,0, 0,0, nScaleX, nScaleY );
+ aOutputData.SetUseStyleColor( bUseStyleColor );
+
+// pDev->SetMapMode(aTwipMode);
+
+ if (pBorderData)
+ aOutputData.DrawFrame();
+
+ delete pBorderDoc;
+ }
+}
+
+void ScPrintFunc::PrintColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY )
+{
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+ SCCOL nCol;
+
+ long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
+ long nEndY = nScrY + nHeight - nOneY;
+
+ long nPosX = nScrX;
+ if ( bLayoutRTL )
+ {
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ nPosX += (long)( pDoc->GetColWidth( nCol, nPrintTab ) * nScaleX );
+ }
+ else
+ nPosX -= nOneX;
+ long nPosY = nScrY - nOneY;
+ String aText;
+
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ {
+ USHORT nDocW = pDoc->GetColWidth( nCol, nPrintTab );
+ if (nDocW)
+ {
+ long nWidth = (long) (nDocW * nScaleX);
+ long nEndX = nPosX + nWidth * nLayoutSign;
+
+ pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) );
+
+ aText = ::ScColToAlpha( nCol);
+ long nTextWidth = pDev->GetTextWidth(aText);
+ long nTextHeight = pDev->GetTextHeight();
+ long nAddX = ( nWidth - nTextWidth ) / 2;
+ long nAddY = ( nHeight - nTextHeight ) / 2;
+ long nTextPosX = nPosX+nAddX;
+ if ( bLayoutRTL )
+ nTextPosX -= nWidth;
+ pDev->DrawText( Point( nTextPosX,nPosY+nAddY ), aText );
+
+ nPosX = nEndX;
+ }
+ }
+}
+
+void ScPrintFunc::PrintRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY )
+{
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
+
+ long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
+ long nEndX = nScrX + nWidth;
+ long nPosX = nScrX;
+ if ( !bLayoutRTL )
+ {
+ nEndX -= nOneX;
+ nPosX -= nOneX;
+ }
+ long nPosY = nScrY - nOneY;
+ String aText;
+
+ for (SCROW nRow=nY1; nRow<=nY2; nRow++)
+ {
+ USHORT nDocH = pDoc->GetRowHeight( nRow, nPrintTab );
+ if (nDocH)
+ {
+ long nHeight = (long) (nDocH * nScaleY);
+ long nEndY = nPosY + nHeight;
+
+ pDev->DrawRect( Rectangle( nPosX,nPosY,nEndX,nEndY ) );
+
+ aText = String::CreateFromInt32( nRow+1 );
+ long nTextWidth = pDev->GetTextWidth(aText);
+ long nTextHeight = pDev->GetTextHeight();
+ long nAddX = ( nWidth - nTextWidth ) / 2;
+ long nAddY = ( nHeight - nTextHeight ) / 2;
+ pDev->DrawText( Point( nPosX+nAddX,nPosY+nAddY ), aText );
+
+ nPosY = nEndY;
+ }
+ }
+}
+
+void ScPrintFunc::LocateColHdr( SCCOL nX1, SCCOL nX2, long nScrX, long nScrY,
+ BOOL bRepCol, ScPreviewLocationData& rLocationData )
+{
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ long nHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
+ long nEndY = nScrY + nHeight - nOneY;
+
+ long nPosX = nScrX - nOneX;
+ for (SCCOL nCol=nX1; nCol<=nX2; nCol++)
+ {
+ USHORT nDocW = pDoc->GetColWidth( nCol, nPrintTab );
+ if (nDocW)
+ nPosX += (long) (nDocW * nScaleX);
+ }
+ Rectangle aCellRect( nScrX, nScrY, nPosX, nEndY );
+ rLocationData.AddColHeaders( aCellRect, nX1, nX2, bRepCol );
+}
+
+void ScPrintFunc::LocateRowHdr( SCROW nY1, SCROW nY2, long nScrX, long nScrY,
+ BOOL bRepRow, ScPreviewLocationData& rLocationData )
+{
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
+
+ long nWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
+ long nEndX = nScrX + nWidth;
+ if ( !bLayoutRTL )
+ nEndX -= nOneX;
+
+ long nPosY = nScrY - nOneY;
+ nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
+ Rectangle aCellRect( nScrX, nScrY, nEndX, nPosY );
+ rLocationData.AddRowHeaders( aCellRect, nY1, nY2, bRepRow );
+}
+
+void ScPrintFunc::LocateArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ long nScrX, long nScrY, BOOL bRepCol, BOOL bRepRow,
+ ScPreviewLocationData& rLocationData )
+{
+ // get MapMode for drawing objects (same MapMode as in ScOutputData::PrintDrawingLayer)
+
+ Point aLogPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
+ long nLogStX = aLogPos.X();
+ long nLogStY = aLogPos.Y();
+
+ SCCOL nCol;
+ Point aTwipOffset;
+ for (nCol=0; nCol<nX1; nCol++)
+ aTwipOffset.X() -= pDoc->GetColWidth( nCol, nPrintTab );
+ aTwipOffset.Y() -= pDoc->GetRowHeight( 0, nY1-1, nPrintTab );
+
+ Point aMMOffset( aTwipOffset );
+ aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS);
+ aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS);
+ aMMOffset += Point( nLogStX, nLogStY );
+ MapMode aDrawMapMode( MAP_100TH_MM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() );
+
+ // get pixel rectangle
+
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ long nPosX = nScrX - nOneX;
+ for (nCol=nX1; nCol<=nX2; nCol++)
+ {
+ USHORT nDocW = pDoc->GetColWidth( nCol, nPrintTab );
+ if (nDocW)
+ nPosX += (long) (nDocW * nScaleX);
+ }
+
+ long nPosY = nScrY - nOneY;
+ nPosY += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab, nScaleY);
+ Rectangle aCellRect( nScrX, nScrY, nPosX, nPosY );
+ rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ),
+ bRepCol, bRepRow, aDrawMapMode );
+}
+
+void ScPrintFunc::PrintArea( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ long nScrX, long nScrY,
+ BOOL bShLeft, BOOL bShTop, BOOL bShRight, BOOL bShBottom )
+{
+ // #i47547# nothing to do if the end of the print area is before the end of
+ // the repeat columns/rows (don't use negative size for ScOutputData)
+ if ( nX2 < nX1 || nY2 < nY1 )
+ return;
+
+ //! Flag bei FillInfo uebergeben !!!!!
+ ScRange aERange;
+ BOOL bEmbed = pDoc->IsEmbedded();
+ if (bEmbed)
+ {
+ pDoc->GetEmbedded(aERange);
+ pDoc->ResetEmbedded();
+ }
+
+ Point aPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode);
+ long nLogStX = aPos.X();
+ long nLogStY = aPos.Y();
+
+ // Daten zusammenstellen
+
+ ScTableInfo aTabInfo;
+ pDoc->FillInfo( aTabInfo, nX1, nY1, nX2, nY2, nPrintTab,
+ nScaleX, nScaleY, TRUE, aTableParam.bFormulas );
+ lcl_HidePrint( aTabInfo, nX1, nX2 );
+
+ if (bEmbed)
+ pDoc->SetEmbedded(aERange);
+
+ ScOutputData aOutputData( pDev, OUTTYPE_PRINTER, aTabInfo, pDoc, nPrintTab,
+ nScrX, nScrY, nX1, nY1, nX2, nY2, nScaleX, nScaleY );
+
+ // #114135#
+ aOutputData.SetDrawView( pDrawView );
+
+ // test if all paint parts are hidden, then a paint is not necessary at all
+ const Point aMMOffset(aOutputData.PrePrintDrawingLayer(nLogStX, nLogStY));
+ const bool bHideAllDrawingLayer( pDrawView && pDrawView->getHideOle() && pDrawView->getHideChart()
+ && pDrawView->getHideDraw() && pDrawView->getHideFormControl() );
+
+ if(!bHideAllDrawingLayer)
+ {
+ pDev->SetMapMode(aLogicMode);
+ // hier kein Clipping setzen (Mapmode wird verschoben)
+
+ // #i72502#
+ aOutputData.PrintDrawingLayer(SC_LAYER_BACK, aMMOffset);
+ }
+
+ pDev->SetMapMode(aOffsetMode);
+
+ aOutputData.SetShowFormulas( aTableParam.bFormulas );
+ aOutputData.SetShowNullValues( aTableParam.bNullVals );
+ aOutputData.SetUseStyleColor( bUseStyleColor );
+
+ Color aGridColor( COL_BLACK );
+ if ( bUseStyleColor )
+ aGridColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+ aOutputData.SetGridColor( aGridColor );
+
+ if ( !pPrinter )
+ {
+ OutputDevice* pRefDev = pDoc->GetPrinter(); // auch fuer Preview den Drucker nehmen
+ Fraction aPrintFrac( nZoom, 100 ); // ohne nManualZoom
+ // MapMode, wie er beim Drucken herauskommen wuerde:
+ pRefDev->SetMapMode( MapMode( MAP_100TH_MM, Point(), aPrintFrac, aPrintFrac ) );
+
+ // when rendering (PDF), don't use printer as ref device, but printer's MapMode
+ // has to be set anyway, as charts still use it (#106409#)
+ if ( !bIsRender )
+ aOutputData.SetRefDevice( pRefDev );
+ }
+
+// aOutputData.SetMetaFileMode(TRUE);
+ if( aTableParam.bCellContent )
+ aOutputData.DrawBackground();
+
+ pDev->SetClipRegion( Rectangle( aPos, Size( aOutputData.GetScrW(), aOutputData.GetScrH() ) ) );
+ pDev->SetClipRegion();
+
+// aOutputData.SetMetaFileMode(FALSE);
+ if( aTableParam.bCellContent )
+ {
+ aOutputData.DrawExtraShadow( bShLeft, bShTop, bShRight, bShBottom );
+ aOutputData.DrawFrame();
+ aOutputData.DrawStrings();
+
+ // pDev->SetMapMode(aLogicMode);
+ aOutputData.DrawEdit(FALSE);
+ }
+
+// pDev->SetMapMode(aOffsetMode);
+ if (aTableParam.bGrid)
+ aOutputData.DrawGrid( TRUE, FALSE ); // keine Seitenumbrueche
+
+/*!!!!!!!!!!! Notizen in Tabelle markieren ??????????????????????????
+
+ if (aTableParam.bNotes)
+ {
+ pDev->SetMapMode(aOffsetMode);
+ aOutputData.PrintNoteMarks(aNotePosList);
+ pDev->SetMapMode(aLogicMode);
+ }
+*/
+
+ aOutputData.AddPDFNotes(); // has no effect if not rendering PDF with notes enabled
+
+// pDev->SetMapMode(aDrawMode);
+
+ // test if all paint parts are hidden, then a paint is not necessary at all
+ if(!bHideAllDrawingLayer)
+ {
+ // #i72502#
+ aOutputData.PrintDrawingLayer(SC_LAYER_FRONT, aMMOffset);
+ }
+
+ // #i72502#
+ aOutputData.PrintDrawingLayer(SC_LAYER_INTERN, aMMOffset);
+ aOutputData.PostPrintDrawingLayer(aMMOffset); // #i74768#
+}
+
+BOOL ScPrintFunc::IsMirror( long nPageNo ) // Raender spiegeln ?
+{
+ SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
+ return ( eUsage == SVX_PAGE_MIRROR && (nPageNo & 1) );
+}
+
+BOOL ScPrintFunc::IsLeft( long nPageNo ) // linke Fussnoten ?
+{
+ SvxPageUsage eUsage = (SvxPageUsage) ( nPageUsage & 0x000f );
+ BOOL bLeft;
+ if (eUsage == SVX_PAGE_LEFT)
+ bLeft = TRUE;
+ else if (eUsage == SVX_PAGE_RIGHT)
+ bLeft = FALSE;
+ else
+ bLeft = (nPageNo & 1) != 0;
+ return bLeft;
+}
+
+void ScPrintFunc::MakeTableString()
+{
+ pDoc->GetName( nPrintTab, aFieldData.aTabName );
+}
+
+void ScPrintFunc::MakeEditEngine()
+{
+ if (!pEditEngine)
+ {
+ // can't use document's edit engine pool here,
+ // because pool must have twips as default metric
+ pEditEngine = new ScHeaderEditEngine( EditEngine::CreatePool(), TRUE );
+
+ pEditEngine->EnableUndo(FALSE);
+ pEditEngine->SetRefDevice( pDev );
+ pEditEngine->SetWordDelimiters(
+ ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) );
+ pEditEngine->SetControlWord( pEditEngine->GetControlWord() & ~EE_CNTRL_RTFSTYLESHEETS );
+ pEditEngine->EnableAutoColor( bUseStyleColor );
+
+ // Default-Set fuer Ausrichtung
+ pEditDefaults = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+
+ const ScPatternAttr& rPattern = (const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN);
+ rPattern.FillEditItemSet( pEditDefaults );
+ // FillEditItemSet adjusts font height to 1/100th mm,
+ // but for header/footer twips is needed, as in the PatternAttr:
+ pEditDefaults->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
+ pEditDefaults->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
+ pEditDefaults->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+ // #69193# dont use font color, because background color is not used
+ //! there's no way to set the background for note pages
+ pEditDefaults->ClearItem( EE_CHAR_COLOR );
+ if (ScGlobal::IsSystemRTL())
+ pEditDefaults->Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
+ }
+
+ pEditEngine->SetData( aFieldData ); // Seitennummer etc. setzen
+}
+
+// nStartY = logic
+void ScPrintFunc::PrintHF( long nPageNo, BOOL bHeader, long nStartY,
+ BOOL bDoPrint, ScPreviewLocationData* pLocationData )
+{
+ const ScPrintHFParam& rParam = bHeader ? aHdr : aFtr;
+
+ pDev->SetMapMode( aTwipMode ); // Kopf-/Fusszeilen in Twips
+
+ BOOL bLeft = IsLeft(nPageNo) && !rParam.bShared;
+ const ScPageHFItem* pHFItem = bLeft ? rParam.pLeft : rParam.pRight;
+
+ long nLineStartX = aPageRect.Left() + rParam.nLeft;
+ long nLineEndX = aPageRect.Right() - rParam.nRight;
+ long nLineWidth = nLineEndX - nLineStartX + 1;
+
+ // Edit-Engine
+
+ Point aStart( nLineStartX, nStartY );
+ Size aPaperSize( nLineWidth, rParam.nHeight-rParam.nDistance );
+ if ( rParam.pBorder )
+ {
+ long nLeft = lcl_LineTotal( rParam.pBorder->GetLeft() ) + rParam.pBorder->GetDistance(BOX_LINE_LEFT);
+ long nTop = lcl_LineTotal( rParam.pBorder->GetTop() ) + rParam.pBorder->GetDistance(BOX_LINE_TOP);
+ aStart.X() += nLeft;
+ aStart.Y() += nTop;
+ aPaperSize.Width() -= nLeft + lcl_LineTotal( rParam.pBorder->GetRight() ) + rParam.pBorder->GetDistance(BOX_LINE_RIGHT);
+ aPaperSize.Height() -= nTop + lcl_LineTotal( rParam.pBorder->GetBottom() ) + rParam.pBorder->GetDistance(BOX_LINE_BOTTOM);
+ }
+
+ if ( rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE )
+ {
+ long nLeft = rParam.pShadow->CalcShadowSpace(SHADOW_LEFT);
+ long nTop = rParam.pShadow->CalcShadowSpace(SHADOW_TOP);
+ aStart.X() += nLeft;
+ aStart.Y() += nTop;
+ aPaperSize.Width() -= nLeft + rParam.pShadow->CalcShadowSpace(SHADOW_RIGHT);
+ aPaperSize.Height() -= nTop + rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
+ }
+
+ aFieldData.nPageNo = nPageNo+aTableParam.nFirstPageNo;
+ MakeEditEngine();
+
+ pEditEngine->SetPaperSize(aPaperSize);
+ const EditTextObject* pObject;
+
+ // Rahmen / Hintergrund
+
+ Point aBorderStart( nLineStartX, nStartY );
+ Size aBorderSize( nLineWidth, rParam.nHeight-rParam.nDistance );
+ if ( rParam.bDynamic )
+ {
+ // hier nochmal anpassen, wegen geraden/ungeraden Kopf/Fusszeilen
+ // und evtl. anderen Umbruechen durch Variablen (Seitennummer etc.)
+
+ long nMaxHeight = 0;
+ nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetLeftArea() ) );
+ nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetCenterArea() ) );
+ nMaxHeight = Max( nMaxHeight, TextHeight( pHFItem->GetRightArea() ) );
+ if (rParam.pBorder)
+ nMaxHeight += lcl_LineTotal( rParam.pBorder->GetTop() ) +
+ lcl_LineTotal( rParam.pBorder->GetBottom() ) +
+ rParam.pBorder->GetDistance(BOX_LINE_TOP) +
+ rParam.pBorder->GetDistance(BOX_LINE_BOTTOM);
+ if (rParam.pShadow && rParam.pShadow->GetLocation() != SVX_SHADOW_NONE)
+ nMaxHeight += rParam.pShadow->CalcShadowSpace(SHADOW_TOP) +
+ rParam.pShadow->CalcShadowSpace(SHADOW_BOTTOM);
+
+ if (nMaxHeight < rParam.nManHeight-rParam.nDistance)
+ nMaxHeight = rParam.nManHeight-rParam.nDistance; // eingestelltes Minimum
+
+ aBorderSize.Height() = nMaxHeight;
+ }
+
+ if ( bDoPrint )
+ {
+ double nOldScaleX = nScaleX;
+ double nOldScaleY = nScaleY;
+ nScaleX = nScaleY = 1.0; // direkt in Twips ausgeben
+ DrawBorder( aBorderStart.X(), aBorderStart.Y(), aBorderSize.Width(), aBorderSize.Height(),
+ rParam.pBorder, rParam.pBack, rParam.pShadow );
+ nScaleX = nOldScaleX;
+ nScaleY = nOldScaleY;
+
+ // Clipping fuer Text
+
+ pDev->SetClipRegion( Rectangle( aStart, aPaperSize ) );
+
+ // links
+
+ pObject = pHFItem->GetLeftArea();
+ if (pObject)
+ {
+ pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE );
+ Point aDraw = aStart;
+ long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
+ if (nDif > 0)
+ aDraw.Y() += nDif / 2;
+ pEditEngine->Draw( pDev, aDraw, 0 );
+ }
+
+ // Mitte
+
+ pObject = pHFItem->GetCenterArea();
+ if (pObject)
+ {
+ pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
+ pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE );
+ Point aDraw = aStart;
+ long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
+ if (nDif > 0)
+ aDraw.Y() += nDif / 2;
+ pEditEngine->Draw( pDev, aDraw, 0 );
+ }
+
+ // rechts
+
+ pObject = pHFItem->GetRightArea();
+ if (pObject)
+ {
+ pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ pEditEngine->SetTextNewDefaults( *pObject, *pEditDefaults, FALSE );
+ Point aDraw = aStart;
+ long nDif = aPaperSize.Height() - (long) pEditEngine->GetTextHeight();
+ if (nDif > 0)
+ aDraw.Y() += nDif / 2;
+ pEditEngine->Draw( pDev, aDraw, 0 );
+ }
+
+ pDev->SetClipRegion();
+ }
+
+ if ( pLocationData )
+ {
+ Rectangle aHeaderRect( aBorderStart, aBorderSize );
+ pLocationData->AddHeaderFooter( aHeaderRect, bHeader, bLeft );
+ }
+}
+
+long ScPrintFunc::DoNotes( long nNoteStart, BOOL bDoPrint, ScPreviewLocationData* pLocationData )
+{
+ if (bDoPrint)
+ pDev->SetMapMode(aTwipMode);
+
+ MakeEditEngine();
+ pEditDefaults->Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ pEditEngine->SetDefaults( *pEditDefaults );
+
+ Font aMarkFont;
+ ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT;
+ ((const ScPatternAttr&)pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)).GetFont( aMarkFont, eColorMode );
+//? aMarkFont.SetWeight( WEIGHT_BOLD );
+ pDev->SetFont( aMarkFont );
+ long nMarkLen = pDev->GetTextWidth(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GW99999:")));
+ // ohne Space, weil's eh selten so weit kommt
+
+ Size aDataSize = aPageRect.GetSize();
+ if ( nMarkLen > aDataSize.Width() / 2 ) // alles viel zu klein?
+ nMarkLen = aDataSize.Width() / 2; // Seite bruederlich aufteilen
+ aDataSize.Width() -= nMarkLen;
+
+ pEditEngine->SetPaperSize( aDataSize );
+ long nPosX = aPageRect.Left() + nMarkLen;
+ long nPosY = aPageRect.Top();
+
+ long nCount = 0;
+ BOOL bOk;
+ do
+ {
+ bOk = FALSE;
+ ScAddress* pPos = (ScAddress*) aNotePosList.GetObject( nNoteStart+nCount );
+ if (pPos)
+ {
+ ScBaseCell* pCell = pDoc->GetCell( *pPos);
+ if( const ScPostIt* pNote = pCell->GetNote() )
+ {
+ if(const EditTextObject *pEditText = pNote->GetEditTextObject())
+ pEditEngine->SetText(*pEditText);
+ long nTextHeight = pEditEngine->GetTextHeight();
+ if ( nPosY + nTextHeight < aPageRect.Bottom() )
+ {
+ if (bDoPrint)
+ {
+ pEditEngine->Draw( pDev, Point( nPosX, nPosY ), 0 );
+
+ String aMarkStr;
+ pPos->Format( aMarkStr, SCA_VALID, pDoc, pDoc->GetAddressConvention() );
+ aMarkStr += ':';
+
+ // Zellposition auch per EditEngine, damit die Position stimmt
+ pEditEngine->SetText(aMarkStr);
+ pEditEngine->Draw( pDev, Point( aPageRect.Left(), nPosY ), 0 );
+ }
+
+ if ( pLocationData )
+ {
+ Rectangle aTextRect( Point( nPosX, nPosY ), Size( aDataSize.Width(), nTextHeight ) );
+ pLocationData->AddNoteText( aTextRect, *pPos );
+ Rectangle aMarkRect( Point( aPageRect.Left(), nPosY ), Size( nMarkLen, nTextHeight ) );
+ pLocationData->AddNoteMark( aMarkRect, *pPos );
+ }
+
+ nPosY += nTextHeight;
+ nPosY += 200; // Abstand
+ ++nCount;
+ bOk = TRUE;
+ }
+ }
+ }
+ }
+ while (bOk);
+
+ return nCount;
+}
+
+long ScPrintFunc::PrintNotes( long nPageNo, long nNoteStart, BOOL bDoPrint, ScPreviewLocationData* pLocationData )
+{
+ if ( nNoteStart >= (long) aNotePosList.Count() || !aTableParam.bNotes )
+ return 0;
+
+ if ( bDoPrint && bClearWin )
+ {
+ //! mit PrintPage zusammenfassen !!!
+
+ Color aBackgroundColor( COL_WHITE );
+ if ( bUseStyleColor )
+ aBackgroundColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+
+ pDev->SetMapMode(aOffsetMode);
+ pDev->SetLineColor();
+ pDev->SetFillColor(aBackgroundColor);
+ pDev->DrawRect(Rectangle(Point(),
+ Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom),
+ (long)(aPageSize.Height() * nScaleY * 100 / nZoom))));
+ }
+
+
+ // aPageRect auf linke / rechte Seiten anpassen
+
+ Rectangle aTempRect = Rectangle( Point(), aPageSize );
+ if (IsMirror(nPageNo))
+ {
+ aPageRect.Left() = ( aTempRect.Left() + nRightMargin ) * 100 / nZoom;
+ aPageRect.Right() = ( aTempRect.Right() - nLeftMargin ) * 100 / nZoom;
+ }
+ else
+ {
+ aPageRect.Left() = ( aTempRect.Left() + nLeftMargin ) * 100 / nZoom;
+ aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom;
+ }
+
+ if ( pPrinter && bDoPrint )
+ {
+ DBG_ERROR( "StartPage does not exist anymore" );
+ // pPrinter->StartPage();
+ }
+
+ if ( bDoPrint || pLocationData )
+ {
+ // Kopf- und Fusszeilen
+
+ if (aHdr.bEnable)
+ {
+ long nHeaderY = aPageRect.Top()-aHdr.nHeight;
+ PrintHF( nPageNo, TRUE, nHeaderY, bDoPrint, pLocationData );
+ }
+ if (aFtr.bEnable)
+ {
+ long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
+ PrintHF( nPageNo, FALSE, nFooterY, bDoPrint, pLocationData );
+ }
+ }
+
+ long nCount = DoNotes( nNoteStart, bDoPrint, pLocationData );
+
+ if ( pPrinter && bDoPrint )
+ {
+ DBG_ERROR( "EndPage does not exist anymore" );
+ // pPrinter->EndPage();
+ }
+
+ return nCount;
+}
+
+void ScPrintFunc::PrintPage( long nPageNo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
+ BOOL bDoPrint, ScPreviewLocationData* pLocationData )
+{
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nPrintTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ // nPageNo is the page number within all sheets of one "start page" setting
+
+ if ( bClearWin && bDoPrint )
+ {
+ // muss genau zum Zeichnen des Rahmens in preview.cxx passen !!!
+
+ Color aBackgroundColor( COL_WHITE );
+ if ( bUseStyleColor )
+ aBackgroundColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+
+ pDev->SetMapMode(aOffsetMode);
+ pDev->SetLineColor();
+ pDev->SetFillColor(aBackgroundColor);
+ pDev->DrawRect(Rectangle(Point(),
+ Size((long)(aPageSize.Width() * nScaleX * 100 / nZoom),
+ (long)(aPageSize.Height() * nScaleY * 100 / nZoom))));
+ }
+
+
+ // aPageRect auf linke / rechte Seiten anpassen
+
+ Rectangle aTempRect = Rectangle( Point(), aPageSize );
+ if (IsMirror(nPageNo))
+ {
+ aPageRect.Left() = ( aTempRect.Left() + nRightMargin ) * 100 / nZoom;
+ aPageRect.Right() = ( aTempRect.Right() - nLeftMargin ) * 100 / nZoom;
+ }
+ else
+ {
+ aPageRect.Left() = ( aTempRect.Left() + nLeftMargin ) * 100 / nZoom;
+ aPageRect.Right() = ( aTempRect.Right() - nRightMargin ) * 100 / nZoom;
+ }
+
+ if ( aAreaParam.bRepeatCol )
+ if ( nX1 > nRepeatStartCol && nX1 <= nRepeatEndCol )
+ nX1 = nRepeatEndCol + 1;
+ BOOL bDoRepCol = (aAreaParam.bRepeatCol && nX1 > nRepeatEndCol);
+ if ( aAreaParam.bRepeatRow )
+ if ( nY1 > nRepeatStartRow && nY1 <= nRepeatEndRow )
+ nY1 = nRepeatEndRow + 1;
+ BOOL bDoRepRow = (aAreaParam.bRepeatRow && nY1 > nRepeatEndRow);
+
+ // use new object hide flags in SdrPaintView
+ if(pDrawView)
+ {
+ pDrawView->setHideOle(!aTableParam.bObjects);
+ pDrawView->setHideChart(!aTableParam.bCharts);
+ pDrawView->setHideDraw(!aTableParam.bDrawings);
+ pDrawView->setHideFormControl(!aTableParam.bDrawings);
+ }
+
+ if ( pPrinter && bDoPrint )
+ {
+ DBG_ERROR( "StartPage does not exist anymore" );
+ // pPrinter->StartPage();
+ }
+
+ // Kopf- und Fusszeilen (ohne Zentrierung)
+
+ if (aHdr.bEnable)
+ {
+ long nHeaderY = aPageRect.Top()-aHdr.nHeight;
+ PrintHF( nPageNo, TRUE, nHeaderY, bDoPrint, pLocationData );
+ }
+ if (aFtr.bEnable)
+ {
+ long nFooterY = aPageRect.Bottom()+aFtr.nDistance;
+ PrintHF( nPageNo, FALSE, nFooterY, bDoPrint, pLocationData );
+ }
+
+ // Position ( Raender / zentrieren )
+
+ long nLeftSpace = aPageRect.Left(); // Document-Twips
+ long nTopSpace = aPageRect.Top();
+ if ( bCenterHor || bLayoutRTL )
+ {
+ long nDataWidth = 0;
+ SCCOL i;
+ for (i=nX1; i<=nX2; i++)
+ nDataWidth += pDoc->GetColWidth( i,nPrintTab );
+ if (bDoRepCol)
+ for (i=nRepeatStartCol; i<=nRepeatEndCol; i++)
+ nDataWidth += pDoc->GetColWidth( i,nPrintTab );
+ if (aTableParam.bHeaders)
+ nDataWidth += (long) PRINT_HEADER_WIDTH;
+ if (pBorderItem)
+ nDataWidth += pBorderItem->GetDistance(BOX_LINE_LEFT) +
+ pBorderItem->GetDistance(BOX_LINE_RIGHT); //! Line width?
+ if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
+ nDataWidth += pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
+ pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
+ if ( bCenterHor )
+ {
+ nLeftSpace += ( aPageRect.GetWidth() - nDataWidth ) / 2; // LTR or RTL
+ if (pBorderItem)
+ nLeftSpace -= lcl_LineTotal(pBorderItem->GetLeft());
+ }
+ else if ( bLayoutRTL )
+ nLeftSpace += aPageRect.GetWidth() - nDataWidth; // align to the right edge of the page
+ }
+ if ( bCenterVer )
+ {
+ long nDataHeight = pDoc->GetRowHeight( nY1, nY2, nPrintTab);
+ if (bDoRepRow)
+ nDataHeight += pDoc->GetRowHeight( nRepeatStartRow,
+ nRepeatEndRow, nPrintTab);
+ if (aTableParam.bHeaders)
+ nDataHeight += (long) PRINT_HEADER_HEIGHT;
+ if (pBorderItem)
+ nDataHeight += pBorderItem->GetDistance(BOX_LINE_TOP) +
+ pBorderItem->GetDistance(BOX_LINE_BOTTOM); //! Line width?
+ if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
+ nDataHeight += pShadowItem->CalcShadowSpace(SHADOW_TOP) +
+ pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
+ nTopSpace += ( aPageRect.GetHeight() - nDataHeight ) / 2;
+ if (pBorderItem)
+ nTopSpace -= lcl_LineTotal(pBorderItem->GetTop());
+ }
+
+ // calculate sizes of the elements for partitioning
+ // (header, repeat, data)
+
+ long nHeaderWidth = 0;
+ long nHeaderHeight = 0;
+ long nRepeatWidth = 0;
+ long nRepeatHeight = 0;
+ long nContentWidth = 0; // scaled - not the same as nDataWidth above
+ long nContentHeight = 0;
+ if (aTableParam.bHeaders)
+ {
+ nHeaderWidth = (long) (PRINT_HEADER_WIDTH * nScaleX);
+ nHeaderHeight = (long) (PRINT_HEADER_HEIGHT * nScaleY);
+ }
+ if (bDoRepCol)
+ for (SCCOL i=nRepeatStartCol; i<=nRepeatEndCol; i++)
+ nRepeatWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX);
+ if (bDoRepRow)
+ nRepeatHeight += pDoc->GetScaledRowHeight( nRepeatStartRow,
+ nRepeatEndRow, nPrintTab, nScaleY);
+ for (SCCOL i=nX1; i<=nX2; i++)
+ nContentWidth += (long) (pDoc->GetColWidth(i,nPrintTab) * nScaleX);
+ nContentHeight += pDoc->GetScaledRowHeight( nY1, nY2, nPrintTab,
+ nScaleY);
+
+ // partition the page
+
+ long nStartX = ((long) ( nLeftSpace * nScaleX ));
+ long nStartY = ((long) ( nTopSpace * nScaleY ));
+// nStartX -= aOffset.X(); // schon im MapMode
+// nStartY -= aOffset.Y();
+
+ long nInnerStartX = nStartX;
+ long nInnerStartY = nStartY;
+ if (pBorderItem)
+ {
+ nInnerStartX += (long) ( ( lcl_LineTotal(pBorderItem->GetLeft()) +
+ pBorderItem->GetDistance(BOX_LINE_LEFT) ) * nScaleX );
+ nInnerStartY += (long) ( ( lcl_LineTotal(pBorderItem->GetTop()) +
+ pBorderItem->GetDistance(BOX_LINE_TOP) ) * nScaleY );
+ }
+ if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
+ {
+ nInnerStartX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_LEFT) * nScaleX );
+ nInnerStartY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_TOP) * nScaleY );
+ }
+
+ if ( bLayoutRTL )
+ {
+ // arrange elements starting from the right edge
+ nInnerStartX += nHeaderWidth + nRepeatWidth + nContentWidth;
+
+ // make rounding easier so the elements are really next to each other in preview
+ Size aOffsetOnePixel = pDev->PixelToLogic( Size(1,1), aOffsetMode );
+ long nOffsetOneX = aOffsetOnePixel.Width();
+ nInnerStartX += nOffsetOneX / 2;
+ }
+
+ long nFrameStartX = nInnerStartX;
+ long nFrameStartY = nInnerStartY;
+
+ long nRepStartX = nInnerStartX + nHeaderWidth * nLayoutSign; // widths/heights are 0 if not used
+ long nRepStartY = nInnerStartY + nHeaderHeight;
+ long nDataX = nRepStartX + nRepeatWidth * nLayoutSign;
+ long nDataY = nRepStartY + nRepeatHeight;
+ long nEndX = nDataX + nContentWidth * nLayoutSign;
+ long nEndY = nDataY + nContentHeight;
+ long nFrameEndX = nEndX;
+ long nFrameEndY = nEndY;
+
+ if ( bLayoutRTL )
+ {
+ // each element's start position is its left edge
+ //! subtract one pixel less?
+ nInnerStartX -= nHeaderWidth; // used for header
+ nRepStartX -= nRepeatWidth;
+ nDataX -= nContentWidth;
+
+ // continue right of the main elements again
+ nEndX += nHeaderWidth + nRepeatWidth + nContentWidth;
+ }
+
+ // Seiten-Rahmen / Hintergrund
+
+ //! nEndX/Y anpassen
+
+ long nBorderEndX = nEndX;
+ long nBorderEndY = nEndY;
+ if (pBorderItem)
+ {
+ nBorderEndX += (long) ( ( lcl_LineTotal(pBorderItem->GetRight()) +
+ pBorderItem->GetDistance(BOX_LINE_RIGHT) ) * nScaleX );
+ nBorderEndY += (long) ( ( lcl_LineTotal(pBorderItem->GetBottom()) +
+ pBorderItem->GetDistance(BOX_LINE_BOTTOM) ) * nScaleY );
+ }
+ if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
+ {
+ nBorderEndX += (long) ( pShadowItem->CalcShadowSpace(SHADOW_RIGHT) * nScaleX );
+ nBorderEndY += (long) ( pShadowItem->CalcShadowSpace(SHADOW_BOTTOM) * nScaleY );
+ }
+
+ if ( bDoPrint )
+ {
+ pDev->SetMapMode( aOffsetMode );
+ DrawBorder( nStartX, nStartY, nBorderEndX-nStartX, nBorderEndY-nStartY,
+ pBorderItem, pBackgroundItem, pShadowItem );
+
+ pDev->SetMapMode( aTwipMode );
+ }
+
+ pDev->SetMapMode( aOffsetMode );
+
+ // Wiederholungszeilen/Spalten ausgeben
+
+ if (bDoRepCol && bDoRepRow)
+ {
+ if ( bDoPrint )
+ PrintArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow,
+ nRepStartX,nRepStartY, TRUE,TRUE,FALSE,FALSE );
+ if ( pLocationData )
+ LocateArea( nRepeatStartCol,nRepeatStartRow, nRepeatEndCol,nRepeatEndRow,
+ nRepStartX,nRepStartY, TRUE,TRUE, *pLocationData );
+ }
+ if (bDoRepCol)
+ {
+ if ( bDoPrint )
+ PrintArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY,
+ TRUE,!bDoRepRow,FALSE,TRUE );
+ if ( pLocationData )
+ LocateArea( nRepeatStartCol,nY1, nRepeatEndCol,nY2, nRepStartX,nDataY, TRUE,FALSE, *pLocationData );
+ }
+ if (bDoRepRow)
+ {
+ if ( bDoPrint )
+ PrintArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY,
+ !bDoRepCol,TRUE,TRUE,FALSE );
+ if ( pLocationData )
+ LocateArea( nX1,nRepeatStartRow, nX2,nRepeatEndRow, nDataX,nRepStartY, FALSE,TRUE, *pLocationData );
+ }
+
+ // Daten ausgeben
+
+ if ( bDoPrint )
+ PrintArea( nX1,nY1, nX2,nY2, nDataX,nDataY, !bDoRepCol,!bDoRepRow,TRUE,TRUE );
+ if ( pLocationData )
+ LocateArea( nX1,nY1, nX2,nY2, nDataX,nDataY, FALSE,FALSE, *pLocationData );
+
+ // Spalten-/Zeilenkoepfe ausgeben
+ // nach den Daten (ueber evtl. weitergezeichneten Schatten)
+
+ Color aGridColor( COL_BLACK );
+ if ( bUseStyleColor )
+ aGridColor.SetColor( SC_MOD()->GetColorConfig().GetColorValue(svtools::FONTCOLOR).nColor );
+
+ if (aTableParam.bHeaders)
+ {
+ if ( bDoPrint )
+ {
+ pDev->SetLineColor( aGridColor );
+ pDev->SetFillColor();
+ pDev->SetMapMode(aOffsetMode);
+ }
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ Font aFont;
+ ScAutoFontColorMode eColorMode = bUseStyleColor ? SC_AUTOCOL_DISPLAY : SC_AUTOCOL_PRINT;
+ aPattern.GetFont( aFont, eColorMode, pDev );
+ pDev->SetFont( aFont );
+
+ if (bDoRepCol)
+ {
+ if ( bDoPrint )
+ PrintColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY );
+ if ( pLocationData )
+ LocateColHdr( nRepeatStartCol,nRepeatEndCol, nRepStartX,nInnerStartY, TRUE, *pLocationData );
+ }
+ if ( bDoPrint )
+ PrintColHdr( nX1,nX2, nDataX,nInnerStartY );
+ if ( pLocationData )
+ LocateColHdr( nX1,nX2, nDataX,nInnerStartY, FALSE, *pLocationData );
+ if (bDoRepRow)
+ {
+ if ( bDoPrint )
+ PrintRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY );
+ if ( pLocationData )
+ LocateRowHdr( nRepeatStartRow,nRepeatEndRow, nInnerStartX,nRepStartY, TRUE, *pLocationData );
+ }
+ if ( bDoPrint )
+ PrintRowHdr( nY1,nY2, nInnerStartX,nDataY );
+ if ( pLocationData )
+ LocateRowHdr( nY1,nY2, nInnerStartX,nDataY, FALSE, *pLocationData );
+ }
+
+ // einfacher Rahmen
+
+ if ( bDoPrint && ( aTableParam.bGrid || aTableParam.bHeaders ) )
+ {
+ Size aOnePixel = pDev->PixelToLogic(Size(1,1));
+ long nOneX = aOnePixel.Width();
+ long nOneY = aOnePixel.Height();
+
+ long nLeftX = nFrameStartX;
+ long nTopY = nFrameStartY - nOneY;
+ long nRightX = nFrameEndX;
+ long nBottomY = nFrameEndY - nOneY;
+ if ( !bLayoutRTL )
+ {
+ nLeftX -= nOneX;
+ nRightX -= nOneX;
+ }
+ pDev->SetMapMode(aOffsetMode);
+ pDev->SetLineColor( aGridColor );
+ pDev->SetFillColor();
+ pDev->DrawRect( Rectangle( nLeftX, nTopY, nRightX, nBottomY ) );
+ // nEndX/Y ohne Rahmen-Anpassung
+ }
+
+ if ( pPrinter && bDoPrint )
+ {
+ DBG_ERROR( "EndPage does not exist anymore" );
+ // pPrinter->EndPage();
+ }
+
+ aLastSourceRange = ScRange( nX1, nY1, nPrintTab, nX2, nY2, nPrintTab );
+ bSourceRangeValid = TRUE;
+}
+
+void ScPrintFunc::SetOffset( const Point& rOfs )
+{
+ aSrcOffset = rOfs;
+}
+
+void ScPrintFunc::SetManualZoom( USHORT nNewZoom )
+{
+ nManualZoom = nNewZoom;
+}
+
+void ScPrintFunc::SetClearFlag( BOOL bFlag )
+{
+ bClearWin = bFlag;
+}
+
+void ScPrintFunc::SetUseStyleColor( BOOL bFlag )
+{
+ bUseStyleColor = bFlag;
+ if (pEditEngine)
+ pEditEngine->EnableAutoColor( bUseStyleColor );
+}
+
+void ScPrintFunc::SetRenderFlag( BOOL bFlag )
+{
+ bIsRender = bFlag; // set when using XRenderable (PDF)
+}
+
+void ScPrintFunc::SetExclusivelyDrawOleAndDrawObjects()
+{
+ aTableParam.bCellContent = false;
+ aTableParam.bNotes = false;
+ aTableParam.bGrid = false;
+ aTableParam.bHeaders = false;
+ aTableParam.bFormulas = false;;
+ aTableParam.bNullVals = false;;
+ aTableParam.bNullVals = false;;
+}
+
+//
+// UpdatePages wird nur von aussen gerufen, um die Umbrueche fuer die Anzeige
+// richtig zu setzen - immer ohne UserArea
+//
+
+BOOL ScPrintFunc::UpdatePages()
+{
+ if (!pParamSet)
+ return FALSE;
+
+ // Zoom
+
+ nZoom = 100;
+ if (aTableParam.bScalePageNum || aTableParam.bScaleTo)
+ nZoom = ZOOM_MIN; // stimmt fuer Umbrueche
+ else if (aTableParam.bScaleAll)
+ {
+ nZoom = aTableParam.nScaleAll;
+ if ( nZoom <= ZOOM_MIN )
+ nZoom = ZOOM_MIN;
+ }
+
+ String aName = pDoc->GetPageStyle( nPrintTab );
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if ( nTab==nPrintTab || pDoc->GetPageStyle(nTab)==aName )
+ {
+ // Wiederholungszeilen / Spalten
+ pDoc->SetRepeatArea( nTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
+
+ // Umbrueche setzen
+ ResetBreaks(nTab);
+ pDocShell->PostPaint(0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID);
+ }
+
+ return TRUE;
+}
+
+long ScPrintFunc::CountPages() // setzt auch nPagesX, nPagesY
+{
+ BOOL bAreaOk = FALSE;
+
+ if (pDoc->HasTable( nPrintTab ))
+ {
+ if (aAreaParam.bPrintArea) // Druckbereich angegeben?
+ {
+ if ( bPrintCurrentTable )
+ {
+ ScRange& rRange = aAreaParam.aPrintArea;
+
+ // hier kein Vergleich der Tabellen mehr, die Area gilt immer fuer diese Tabelle
+ // wenn hier verglichen werden soll, muss die Tabelle der Druckbereiche beim
+ // Einfuegen von Tabellen etc. angepasst werden !
+
+ nStartCol = rRange.aStart.Col();
+ nStartRow = rRange.aStart.Row();
+ nEndCol = rRange.aEnd .Col();
+ nEndRow = rRange.aEnd .Row();
+ bAreaOk = AdjustPrintArea(FALSE); // begrenzen
+ }
+ else
+ bAreaOk = FALSE;
+ }
+ else // aus Dokument suchen
+ bAreaOk = AdjustPrintArea(TRUE);
+ }
+
+ if (bAreaOk)
+ {
+ long nPages = 0;
+ size_t nY;
+ if (bMultiArea)
+ {
+ USHORT nRCount = pDoc->GetPrintRangeCount( nPrintTab );
+ for (USHORT i=0; i<nRCount; i++)
+ {
+ CalcZoom(i);
+ if ( aTableParam.bSkipEmpty )
+ for (nY=0; nY<nPagesY; nY++)
+ nPages += pPageRows[nY].CountVisible();
+ else
+ nPages += ((long) nPagesX) * nPagesY;
+ if ( pPageData )
+ FillPageData();
+ }
+ }
+ else
+ {
+ CalcZoom(RANGENO_NORANGE); // Zoom berechnen
+ if ( aTableParam.bSkipEmpty )
+ for (nY=0; nY<nPagesY; nY++)
+ nPages += pPageRows[nY].CountVisible();
+ else
+ nPages += ((long) nPagesX) * nPagesY;
+ if ( pPageData )
+ FillPageData();
+ }
+ return nPages;
+ }
+ else
+ {
+// nZoom = 100; // nZoom auf letztem Wert stehenlassen !!!
+ nPagesX = nPagesY = nTotalY = 0;
+ return 0;
+ }
+}
+
+long ScPrintFunc::CountNotePages()
+{
+ if ( !aTableParam.bNotes || !bPrintCurrentTable )
+ return 0;
+
+ long nCount=0;
+ SCCOL nCol;
+ SCROW nRow;
+
+ BOOL bError = FALSE;
+ if (!aAreaParam.bPrintArea)
+ bError = !AdjustPrintArea(TRUE); // komplett aus Dok suchen
+
+ USHORT nRepeats = 1; // wie oft durchgehen ?
+ if (bMultiArea)
+ nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
+ if (bError)
+ nRepeats = 0;
+
+ for (USHORT nStep=0; nStep<nRepeats; nStep++)
+ {
+ BOOL bDoThis = TRUE;
+ if (bMultiArea) // alle Areas durchgehen
+ {
+ const ScRange* pThisRange = pDoc->GetPrintRange( nPrintTab, nStep );
+ if ( pThisRange )
+ {
+ nStartCol = pThisRange->aStart.Col();
+ nStartRow = pThisRange->aStart.Row();
+ nEndCol = pThisRange->aEnd .Col();
+ nEndRow = pThisRange->aEnd .Row();
+ bDoThis = AdjustPrintArea(FALSE);
+ }
+ }
+
+ if (bDoThis)
+ {
+ ScHorizontalCellIterator aIter( pDoc, nPrintTab, nStartCol,nStartRow, nEndCol,nEndRow );
+ ScBaseCell* pCell = aIter.GetNext( nCol, nRow );
+ while (pCell)
+ {
+ if (pCell->HasNote())
+ {
+ aNotePosList.Insert( new ScAddress( nCol,nRow,nPrintTab ), LIST_APPEND );
+ ++nCount;
+ }
+
+ pCell = aIter.GetNext( nCol, nRow );
+ }
+ }
+ }
+
+ long nPages = 0;
+ long nNoteNr = 0;
+ long nNoteAdd;
+ do
+ {
+ nNoteAdd = PrintNotes( nPages, nNoteNr, FALSE, NULL );
+ if (nNoteAdd)
+ {
+ nNoteNr += nNoteAdd;
+ ++nPages;
+ }
+ }
+ while (nNoteAdd);
+
+ return nPages;
+}
+
+void ScPrintFunc::InitModes() // aus nZoom etc. die MapModes setzen
+{
+ aOffset = Point( aSrcOffset.X()*100/nZoom, aSrcOffset.Y()*100/nZoom );
+
+ long nEffZoom = nZoom * (long) nManualZoom;
+
+// nScaleX = nScaleY = 1.0; // Ausgabe in Twips
+ nScaleX = nScaleY = HMM_PER_TWIPS; // Ausgabe in 1/100 mm
+
+ Fraction aZoomFract( nEffZoom,10000 );
+ Fraction aHorFract = aZoomFract;
+
+ if ( !pPrinter && !bIsRender ) // adjust scale for preview
+ {
+ double nFact = pDocShell->GetOutputFactor();
+ aHorFract = Fraction( (long)( nEffZoom / nFact ), 10000 );
+ }
+
+ aLogicMode = MapMode( MAP_100TH_MM, Point(), aHorFract, aZoomFract );
+
+ Point aLogicOfs( -aOffset.X(), -aOffset.Y() );
+ aOffsetMode = MapMode( MAP_100TH_MM, aLogicOfs, aHorFract, aZoomFract );
+
+ Point aTwipsOfs( (long) ( -aOffset.X() / nScaleX + 0.5 ), (long) ( -aOffset.Y() / nScaleY + 0.5 ) );
+ aTwipMode = MapMode( MAP_TWIP, aTwipsOfs, aHorFract, aZoomFract );
+}
+
+//--------------------------------------------------------------------
+
+void ScPrintFunc::ApplyPrintSettings()
+{
+ if ( pPrinter )
+ {
+ //
+ // Printer zum Drucken umstellen
+ //
+
+ Size aEnumSize = aPageSize;
+
+
+ pPrinter->SetOrientation( bLandscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT );
+ if ( bLandscape )
+ {
+ // landscape is always interpreted as a rotation by 90 degrees !
+ // this leads to non WYSIWIG but at least it prints!
+ // #i21775#
+ long nTemp = aEnumSize.Width();
+ aEnumSize.Width() = aEnumSize.Height();
+ aEnumSize.Height() = nTemp;
+ }
+ Paper ePaper = SvxPaperInfo::GetSvxPaper( aEnumSize, MAP_TWIP, TRUE );
+ USHORT nPaperBin = ((const SvxPaperBinItem&)pParamSet->Get(ATTR_PAGE_PAPERBIN)).GetValue();
+
+ pPrinter->SetPaper( ePaper );
+ if ( PAPER_USER == ePaper )
+ {
+ MapMode aPrinterMode = pPrinter->GetMapMode();
+ MapMode aLocalMode( MAP_TWIP );
+ pPrinter->SetMapMode( aLocalMode );
+ pPrinter->SetPaperSizeUser( aEnumSize );
+ pPrinter->SetMapMode( aPrinterMode );
+ }
+
+ pPrinter->SetPaperBin( nPaperBin );
+ }
+}
+
+//--------------------------------------------------------------------
+// rPageRanges = Range fuer alle Tabellen
+// nStartPage = in rPageRanges beginnen bei nStartPage
+// nDisplayStart = lfd. Nummer fuer Anzeige der Seitennummer
+
+long ScPrintFunc::DoPrint( const MultiSelection& rPageRanges,
+ long nStartPage, long nDisplayStart, BOOL bDoPrint,
+ SfxProgress* pProgress, ScPreviewLocationData* pLocationData )
+{
+ DBG_ASSERT(pDev,"Device == NULL");
+ if (!pParamSet)
+ return 0;
+
+ if ( pPrinter && bDoPrint )
+ ApplyPrintSettings();
+
+ //--------------------------------------------------------------------
+
+ InitModes();
+ if ( pLocationData )
+ {
+ pLocationData->SetCellMapMode( aOffsetMode );
+ pLocationData->SetPrintTab( nPrintTab );
+ }
+
+ MakeTableString();
+
+ if ( pProgress )
+ pProgress->SetText( String( ScResId( SCSTR_STAT_PRINT ) ) );
+
+ //--------------------------------------------------------------------
+
+ long nPageNo = 0;
+ long nPrinted = 0;
+ long nEndPage = rPageRanges.GetTotalRange().Max();
+
+ USHORT nRepeats = 1; // wie oft durchgehen ?
+ if (bMultiArea)
+ nRepeats = pDoc->GetPrintRangeCount(nPrintTab);
+ for (USHORT nStep=0; nStep<nRepeats; nStep++)
+ {
+ if (bMultiArea) // Bereich neu belegen ?
+ {
+ CalcZoom(nStep); // setzt auch nStartCol etc. neu
+ InitModes();
+ }
+
+ SCCOL nX1;
+ SCROW nY1;
+ SCCOL nX2;
+ SCROW nY2;
+ size_t nCountX;
+ size_t nCountY;
+
+ if (aTableParam.bTopDown) // von oben nach unten
+ {
+ nX1 = nStartCol;
+ for (nCountX=0; nCountX<nPagesX; nCountX++)
+ {
+ nX2 = pPageEndX[nCountX];
+ for (nCountY=0; nCountY<nPagesY; nCountY++)
+ {
+ nY1 = pPageRows[nCountY].GetStartRow();
+ nY2 = pPageRows[nCountY].GetEndRow();
+ if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) )
+ {
+ if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
+ {
+ PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
+ bDoPrint, pLocationData );
+
+ if ( pProgress )
+ {
+ pProgress->SetState( nPageNo+nStartPage+1, nEndPage );
+ pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug?
+ }
+ ++nPrinted;
+ }
+ ++nPageNo;
+ }
+ }
+ nX1 = nX2 + 1;
+ }
+ }
+ else // von links nach rechts
+ {
+ for (nCountY=0; nCountY<nPagesY; nCountY++)
+ {
+ nY1 = pPageRows[nCountY].GetStartRow();
+ nY2 = pPageRows[nCountY].GetEndRow();
+ nX1 = nStartCol;
+ for (nCountX=0; nCountX<nPagesX; nCountX++)
+ {
+ nX2 = pPageEndX[nCountX];
+ if ( !aTableParam.bSkipEmpty || !pPageRows[nCountY].IsHidden(nCountX) )
+ {
+ if ( rPageRanges.IsSelected( nPageNo+nStartPage+1 ) )
+ {
+ PrintPage( nPageNo+nDisplayStart, nX1, nY1, nX2, nY2,
+ bDoPrint, pLocationData );
+
+ if ( pProgress )
+ {
+ pProgress->SetState( nPageNo+nStartPage+1, nEndPage );
+ pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug?
+ }
+ ++nPrinted;
+ }
+ ++nPageNo;
+ }
+ nX1 = nX2 + 1;
+ }
+ }
+ }
+ }
+
+ aFieldData.aTabName = ScGlobal::GetRscString( STR_NOTES );
+
+ long nNoteNr = 0;
+ long nNoteAdd;
+ do
+ {
+ if ( nPageNo+nStartPage <= nEndPage )
+ {
+ BOOL bPageSelected = rPageRanges.IsSelected( nPageNo+nStartPage+1 );
+ nNoteAdd = PrintNotes( nPageNo+nStartPage, nNoteNr, bDoPrint && bPageSelected,
+ ( bPageSelected ? pLocationData : NULL ) );
+ if ( nNoteAdd )
+ {
+ nNoteNr += nNoteAdd;
+ if ( pProgress && bPageSelected )
+ {
+ pProgress->SetState( nPageNo+nStartPage+1, nEndPage );
+ pProgress->Reschedule(); //Mag der Anwender noch oder hat er genug?
+ }
+ if (bPageSelected)
+ {
+ ++nPrinted;
+ bSourceRangeValid = FALSE; // last page was no cell range
+ }
+ ++nPageNo;
+ }
+ }
+ else
+ nNoteAdd = 0;
+ }
+ while (nNoteAdd);
+
+ if ( bMultiArea )
+ ResetBreaks(nPrintTab); // Breaks fuer Anzeige richtig
+
+ return nPrinted;
+}
+
+void ScPrintFunc::CalcZoom( USHORT nRangeNo ) // Zoom berechnen
+{
+ USHORT nRCount = pDoc->GetPrintRangeCount( nPrintTab );
+ const ScRange* pThisRange = NULL;
+ if ( nRangeNo != RANGENO_NORANGE || nRangeNo < nRCount )
+ pThisRange = pDoc->GetPrintRange( nPrintTab, nRangeNo );
+ if ( pThisRange )
+ {
+ nStartCol = pThisRange->aStart.Col();
+ nStartRow = pThisRange->aStart.Row();
+ nEndCol = pThisRange->aEnd .Col();
+ nEndRow = pThisRange->aEnd .Row();
+ }
+
+ if (!AdjustPrintArea(FALSE)) // leer
+ {
+ nZoom = 100;
+ nPagesX = nPagesY = nTotalY = 0;
+ return;
+ }
+
+ pDoc->SetRepeatArea( nPrintTab, nRepeatStartCol,nRepeatEndCol, nRepeatStartRow,nRepeatEndRow );
+
+ if (aTableParam.bScalePageNum)
+ {
+ nZoom = 100;
+ USHORT nPagesToFit = aTableParam.nScalePageNum;
+
+ sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
+ while (true)
+ {
+ if (nZoom <= ZOOM_MIN)
+ break;
+
+ CalcPages();
+ bool bFitsPage = (nPagesX * nPagesY <= nPagesToFit);
+
+ if (bFitsPage)
+ {
+ if (nZoom == 100)
+ // If it fits at 100 %, it's good enough for me.
+ break;
+
+ nLastFitZoom = nZoom;
+ nZoom = (nLastNonFitZoom + nZoom) / 2;
+
+ if (nLastFitZoom == nZoom)
+ // It converged. Use this zoom level.
+ break;
+ }
+ else
+ {
+ if (nZoom - nLastFitZoom <= 1)
+ {
+ nZoom = nLastFitZoom;
+ CalcPages();
+ break;
+ }
+
+ nLastNonFitZoom = nZoom;
+ nZoom = (nLastFitZoom + nZoom) / 2;
+ }
+ }
+ }
+ else if (aTableParam.bScaleTo)
+ {
+ nZoom = 100;
+ USHORT nW = aTableParam.nScaleWidth;
+ USHORT nH = aTableParam.nScaleHeight;
+
+ sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
+ while (true)
+ {
+ if (nZoom <= ZOOM_MIN)
+ break;
+
+ CalcPages();
+ bool bFitsPage = ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH)));
+
+ if (bFitsPage)
+ {
+ if (nZoom == 100)
+ // If it fits at 100 %, it's good enough for me.
+ break;
+
+ nLastFitZoom = nZoom;
+ nZoom = (nLastNonFitZoom + nZoom) / 2;
+
+ if (nLastFitZoom == nZoom)
+ // It converged. Use this zoom level.
+ break;
+ }
+ else
+ {
+ if (nZoom - nLastFitZoom <= 1)
+ {
+ nZoom = nLastFitZoom;
+ CalcPages();
+ break;
+ }
+
+ nLastNonFitZoom = nZoom;
+ nZoom = (nLastFitZoom + nZoom) / 2;
+ }
+ }
+ }
+ else if (aTableParam.bScaleAll)
+ {
+ nZoom = aTableParam.nScaleAll;
+ if ( nZoom <= ZOOM_MIN )
+ nZoom = ZOOM_MIN;
+ CalcPages();
+ }
+ else
+ {
+ DBG_ASSERT( aTableParam.bScaleNone, "kein Scale-Flag gesetzt" );
+ nZoom = 100;
+ CalcPages();
+ }
+}
+
+Size ScPrintFunc::GetDocPageSize()
+{
+ // Hoehe Kopf-/Fusszeile anpassen
+
+ InitModes(); // aTwipMode aus nZoom initialisieren
+ pDev->SetMapMode( aTwipMode ); // Kopf-/Fusszeilen in Twips
+ UpdateHFHeight( aHdr );
+ UpdateHFHeight( aFtr );
+
+ // Seitengroesse in Document-Twips
+ // Berechnung Left / Right auch in PrintPage
+
+ aPageRect = Rectangle( Point(), aPageSize );
+ aPageRect.Left() = ( aPageRect.Left() + nLeftMargin ) * 100 / nZoom;
+ aPageRect.Right() = ( aPageRect.Right() - nRightMargin ) * 100 / nZoom;
+ aPageRect.Top() = ( aPageRect.Top() + nTopMargin ) * 100 / nZoom + aHdr.nHeight;
+ aPageRect.Bottom() = ( aPageRect.Bottom() - nBottomMargin ) * 100 / nZoom - aFtr.nHeight;
+
+ Size aDocPageSize = aPageRect.GetSize();
+ if (aTableParam.bHeaders)
+ {
+ aDocPageSize.Width() -= (long) PRINT_HEADER_WIDTH;
+ aDocPageSize.Height() -= (long) PRINT_HEADER_HEIGHT;
+ }
+ if (pBorderItem)
+ {
+ aDocPageSize.Width() -= lcl_LineTotal(pBorderItem->GetLeft()) +
+ lcl_LineTotal(pBorderItem->GetRight()) +
+ pBorderItem->GetDistance(BOX_LINE_LEFT) +
+ pBorderItem->GetDistance(BOX_LINE_RIGHT);
+ aDocPageSize.Height() -= lcl_LineTotal(pBorderItem->GetTop()) +
+ lcl_LineTotal(pBorderItem->GetBottom()) +
+ pBorderItem->GetDistance(BOX_LINE_TOP) +
+ pBorderItem->GetDistance(BOX_LINE_BOTTOM);
+ }
+ if (pShadowItem && pShadowItem->GetLocation() != SVX_SHADOW_NONE)
+ {
+ aDocPageSize.Width() -= pShadowItem->CalcShadowSpace(SHADOW_LEFT) +
+ pShadowItem->CalcShadowSpace(SHADOW_RIGHT);
+ aDocPageSize.Height() -= pShadowItem->CalcShadowSpace(SHADOW_TOP) +
+ pShadowItem->CalcShadowSpace(SHADOW_BOTTOM);
+ }
+ return aDocPageSize;
+}
+
+void ScPrintFunc::ResetBreaks( SCTAB nTab ) // Breaks fuer Anzeige richtig setzen
+{
+ pDoc->SetPageSize( nTab, GetDocPageSize() );
+ pDoc->UpdatePageBreaks( nTab, NULL );
+}
+
+void lcl_SetHidden( ScDocument* pDoc, SCTAB nPrintTab, ScPageRowEntry& rPageRowEntry,
+ SCCOL nStartCol, const SCCOL* pPageEndX )
+{
+ size_t nPagesX = rPageRowEntry.GetPagesX();
+ SCROW nStartRow = rPageRowEntry.GetStartRow();
+ SCROW nEndRow = rPageRowEntry.GetEndRow();
+
+ BOOL bLeftIsEmpty = FALSE;
+ ScRange aTempRange;
+ Rectangle aTempRect = pDoc->GetMMRect( 0,0, 0,0, 0 );
+
+ for (size_t i=0; i<nPagesX; i++)
+ {
+ SCCOL nEndCol = pPageEndX[i];
+ if ( pDoc->IsPrintEmpty( nPrintTab, nStartCol, nStartRow, nEndCol, nEndRow,
+ bLeftIsEmpty, &aTempRange, &aTempRect ) )
+ {
+ rPageRowEntry.SetHidden(i);
+ bLeftIsEmpty = TRUE;
+ }
+ else
+ bLeftIsEmpty = FALSE;
+
+ nStartCol = nEndCol+1;
+ }
+}
+
+void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
+{
+ if (!pPageEndX) pPageEndX = new SCCOL[MAXCOL+1];
+ if (!pPageEndY) pPageEndY = new SCROW[MAXROW+1];
+ if (!pPageRows) pPageRows = new ScPageRowEntry[MAXROW+1]; //! vorher zaehlen !!!!
+
+ pDoc->SetPageSize( nPrintTab, GetDocPageSize() );
+ if (aAreaParam.bPrintArea)
+ {
+ ScRange aRange( nStartCol, nStartRow, nPrintTab, nEndCol, nEndRow, nPrintTab );
+ pDoc->UpdatePageBreaks( nPrintTab, &aRange );
+ }
+ else
+ pDoc->UpdatePageBreaks( nPrintTab, NULL ); // sonst wird das Ende markiert
+
+ //
+ // Seiteneinteilung nach Umbruechen in Col/RowFlags
+ // Von mehreren Umbruechen in einem ausgeblendeten Bereich zaehlt nur einer.
+ //
+
+ nPagesX = 0;
+ nPagesY = 0;
+ nTotalY = 0;
+
+ bool bVisCol = false;
+ SCCOL nLastCol = -1;
+ for (SCCOL i=nStartCol; i<=nEndCol; i++)
+ {
+ bool bHidden = pDoc->ColHidden(i, nPrintTab, nLastCol);
+ bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE);
+ if ( i>nStartCol && bVisCol && bPageBreak )
+ {
+ pPageEndX[nPagesX] = i-1;
+ ++nPagesX;
+ bVisCol = false;
+ }
+ if (!bHidden)
+ bVisCol = true;
+ }
+ if (bVisCol) // auch am Ende keine leeren Seiten
+ {
+ pPageEndX[nPagesX] = nEndCol;
+ ++nPagesX;
+ }
+
+ bool bVisRow = false;
+ SCROW nPageStartRow = nStartRow;
+ SCROW nLastVisibleRow = -1;
+
+ ::boost::scoped_ptr<ScRowBreakIterator> pRowBreakIter(pDoc->GetRowBreakIterator(nPrintTab));
+ SCROW nNextPageBreak = pRowBreakIter->first();
+ while (nNextPageBreak != ScRowBreakIterator::NOT_FOUND && nNextPageBreak < nStartRow)
+ // Skip until the page break position is at the start row or greater.
+ nNextPageBreak = pRowBreakIter->next();
+
+ for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
+ {
+ bool bPageBreak = (nNextPageBreak == nRow);
+ if (bPageBreak)
+ nNextPageBreak = pRowBreakIter->next();
+
+ if (nRow > nStartRow && bVisRow && bPageBreak )
+ {
+ pPageEndY[nTotalY] = nRow-1;
+ ++nTotalY;
+
+ if ( !aTableParam.bSkipEmpty ||
+ !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1 ) )
+ {
+ pPageRows[nPagesY].SetStartRow( nPageStartRow );
+ pPageRows[nPagesY].SetEndRow( nRow-1 );
+ pPageRows[nPagesY].SetPagesX( nPagesX );
+ if (aTableParam.bSkipEmpty)
+ lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
+ ++nPagesY;
+ }
+
+ nPageStartRow = nRow;
+ bVisRow = false;
+ }
+
+ if (nRow <= nLastVisibleRow)
+ {
+ // This row is still visible. Don't bother calling RowHidden() to
+ // find out, for speed optimization.
+ bVisRow = true;
+ continue;
+ }
+
+ SCROW nLastRow = -1;
+ if (!pDoc->RowHidden(nRow, nPrintTab, NULL, &nLastRow))
+ {
+ bVisRow = true;
+ nLastVisibleRow = nLastRow;
+ }
+ else
+ // skip all hidden rows.
+ nRow = nLastRow;
+ }
+
+ if (bVisRow)
+ {
+ pPageEndY[nTotalY] = nEndRow;
+ ++nTotalY;
+
+ if ( !aTableParam.bSkipEmpty ||
+ !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nEndRow ) )
+ {
+ pPageRows[nPagesY].SetStartRow( nPageStartRow );
+ pPageRows[nPagesY].SetEndRow( nEndRow );
+ pPageRows[nPagesY].SetPagesX( nPagesX );
+ if (aTableParam.bSkipEmpty)
+ lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
+ ++nPagesY;
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+// class ScJobSetup
+//------------------------------------------------------------------------
+
+ScJobSetup::ScJobSetup( SfxPrinter* pPrinter )
+{
+ eOrientation = pPrinter->GetOrientation();
+ nPaperBin = pPrinter->GetPaperBin();
+ ePaper = pPrinter->GetPaper();
+
+ if ( PAPER_USER == ePaper )
+ {
+ aUserSize = pPrinter->GetPaperSize();
+ aUserMapMode = pPrinter->GetMapMode();
+ }
+};
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/reffact.cxx b/sc/source/ui/view/reffact.cxx
new file mode 100644
index 000000000000..6c31e3b41d32
--- /dev/null
+++ b/sc/source/ui/view/reffact.cxx
@@ -0,0 +1,437 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/app.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "reffact.hxx"
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "acredlin.hxx"
+#include "simpref.hxx"
+#include "scmod.hxx"
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+#include "validate.hxx"
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+
+// -----------------------------------------------------------------------
+
+SFX_IMPL_MODELESSDIALOG(ScNameDlgWrapper, FID_DEFINE_NAME )
+SFX_IMPL_MODELESSDIALOG(ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
+SFX_IMPL_MODELESSDIALOG(ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
+SFX_IMPL_MODELESSDIALOG(ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
+SFX_IMPL_MODELESSDIALOG(ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
+SFX_IMPL_MODELESSDIALOG(ScFilterDlgWrapper, SID_FILTER )
+SFX_IMPL_MODELESSDIALOG(ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
+SFX_IMPL_MODELESSDIALOG(ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
+SFX_IMPL_MODELESSDIALOG(ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
+SFX_IMPL_MODELESSDIALOG(ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
+SFX_IMPL_MODELESSDIALOG(ScCondFormatDlgWrapper, SID_OPENDLG_CONDFRMT )
+SFX_IMPL_MODELESSDIALOG(ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
+SFX_IMPL_MODELESSDIALOG(ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
+SFX_IMPL_MODELESSDIALOG(ScAcceptChgDlgWrapper, FID_CHG_ACCEPT )
+SFX_IMPL_MODELESSDIALOG(ScHighlightChgDlgWrapper, FID_CHG_SHOW )
+SFX_IMPL_MODELESSDIALOG(ScSimpleRefDlgWrapper, WID_SIMPLE_REF )
+/*!!! dafuer muss der Funktionsautopilot noch umgebaut werden
+SFX_IMPL_CHILDWINDOW(ScFunctionDlgWrapper, SID_OPENDLG_FUNCTION )
+SFX_IMPL_CHILDWINDOW(ScEditFunctionDlgWrapper, SID_OPENDLG_EDITFUNCTION )
+SFX_IMPL_CHILDWINDOW(ScArgumentDlgWrapper, SID_OPENDLG_ARGUMENT )
+*/
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+//SFX_IMPL_MODELESSDIALOG(ScValidityRefChildWin, SID_VALIDITY_REFERENCE )
+SFX_IMPL_CHILDWINDOW(ScValidityRefChildWin, SID_VALIDITY_REFERENCE)
+SfxChildWinInfo __EXPORT ScValidityRefChildWin::GetInfo() const
+{
+ SfxChildWinInfo anInfo = SfxChildWindow::GetInfo();
+
+ if( Window *pWnd = GetWindow() )
+ {
+ anInfo.aSize = pWnd->GetSizePixel();
+
+ if( pWnd->IsDialog() )
+ if ( static_cast<Dialog*>(pWnd)->IsRollUp() )
+ anInfo.nFlags |= SFX_CHILDWIN_ZOOMIN;
+ }
+
+ return anInfo;
+}
+
+namespace { ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings ); }
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+
+#define IMPL_CHILD_CTOR(Class,sid) \
+ Class::Class( Window* pParentP, \
+ USHORT nId, \
+ SfxBindings* p, \
+ SfxChildWinInfo* pInfo ) \
+ : SfxChildWindow(pParentP, nId) \
+ { \
+ /*//<!--Added by PengYunQuan for Validity Cell Range Picker*/\
+ /************************************************************************************/\
+ /* When a new document is creating, the SfxViewFrame may be ready, */\
+ /* But the ScTabViewShell may have not been activated yet. In this */\
+ /* situation, SfxViewShell::Current() does not get the correct shell, */\
+ /* and we should lcl_GetTabViewShell( p ) instead of SfxViewShell::Current() */\
+ /************************************************************************************/\
+ ScTabViewShell* pViewShell = lcl_GetTabViewShell( p ); \
+ /*//-->Added by PengYunQuan for Validity Cell Range Picker*/\
+ if (!pViewShell) \
+ pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); \
+ DBG_ASSERT( pViewShell, "missing view shell :-(" ); \
+ pWindow = pViewShell ? \
+ pViewShell->CreateRefDialog( p, this, pInfo, pParentP, sid ) : NULL; \
+ if (pViewShell && !pWindow) \
+ pViewShell->GetViewFrame()->SetChildWindow( nId, FALSE ); \
+ }
+
+
+//=========================================================================
+
+//-------------------------------------------------------------------------
+// ScNameDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScNameDlgWrapper, FID_DEFINE_NAME )
+
+//-------------------------------------------------------------------------
+// ScSolverDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScSolverDlgWrapper, SID_OPENDLG_SOLVE )
+
+//-------------------------------------------------------------------------
+// ScOptSolverDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScOptSolverDlgWrapper, SID_OPENDLG_OPTSOLVER )
+
+//-------------------------------------------------------------------------
+// ScPivotLayoutWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScPivotLayoutWrapper, SID_OPENDLG_PIVOTTABLE )
+
+//-------------------------------------------------------------------------
+// ScTabOpDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScTabOpDlgWrapper, SID_OPENDLG_TABOP )
+
+//-------------------------------------------------------------------------
+// ScFilterDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScFilterDlgWrapper, SID_FILTER )
+
+//-------------------------------------------------------------------------
+// ScSpecialFilterDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScSpecialFilterDlgWrapper, SID_SPECIAL_FILTER )
+
+//-------------------------------------------------------------------------
+// ScDbNameDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScDbNameDlgWrapper, SID_DEFINE_DBNAME )
+
+//-------------------------------------------------------------------------
+// ScColRowNameRangesDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScColRowNameRangesDlgWrapper, SID_DEFINE_COLROWNAMERANGES )
+
+//-------------------------------------------------------------------------
+// ScConsolidateDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScConsolidateDlgWrapper, SID_OPENDLG_CONSOLIDATE )
+
+//-------------------------------------------------------------------------
+// ScPrintAreasDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScPrintAreasDlgWrapper, SID_OPENDLG_EDIT_PRINTAREA )
+
+//-------------------------------------------------------------------------
+// ScCondFormatDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScCondFormatDlgWrapper, SID_OPENDLG_CONDFRMT )
+
+//-------------------------------------------------------------------------
+// ScFormulaDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScFormulaDlgWrapper, SID_OPENDLG_FUNCTION )
+
+
+//-------------------------------------------------------------------------
+// ScSimpleRefDlgWrapper
+//-------------------------------------------------------------------------
+
+static BOOL bScSimpleRefFlag;
+static long nScSimpleRefHeight;
+static long nScSimpleRefWidth;
+static long nScSimpleRefX;
+static long nScSimpleRefY;
+static BOOL bAutoReOpen=TRUE;
+
+ScSimpleRefDlgWrapper::ScSimpleRefDlgWrapper( Window* pParentP,
+ USHORT nId,
+ SfxBindings* p,
+ SfxChildWinInfo* pInfo )
+ : SfxChildWindow(pParentP, nId)
+{
+// ScTabViewShell* pViewShell =
+// PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+
+ ScTabViewShell* pViewShell = NULL;
+ SfxDispatcher* pDisp = p->GetDispatcher();
+ if ( pDisp )
+ {
+ SfxViewFrame* pViewFrm = pDisp->GetFrame();
+ if ( pViewFrm )
+ pViewShell = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() );
+ }
+
+ DBG_ASSERT( pViewShell, "missing view shell :-(" );
+
+ if(pInfo!=NULL && bScSimpleRefFlag)
+ {
+ pInfo->aPos.X()=nScSimpleRefX;
+ pInfo->aPos.Y()=nScSimpleRefY;
+ pInfo->aSize.Height()=nScSimpleRefHeight;
+ pInfo->aSize.Width()=nScSimpleRefWidth;
+ }
+ pWindow = NULL;
+
+ if(bAutoReOpen && pViewShell)
+ pWindow = pViewShell->CreateRefDialog( p, this, pInfo, pParentP, WID_SIMPLE_REF);
+
+ if (!pWindow)
+ {
+ SC_MOD()->SetRefDialog( nId, FALSE );
+ }
+}
+
+void ScSimpleRefDlgWrapper::SetDefaultPosSize(Point aPos, Size aSize, BOOL bSet)
+{
+ bScSimpleRefFlag=bSet;
+ if(bScSimpleRefFlag)
+ {
+ nScSimpleRefX=aPos.X();
+ nScSimpleRefY=aPos.Y();
+ nScSimpleRefHeight=aSize.Height();
+ nScSimpleRefWidth=aSize.Width();
+ }
+}
+
+
+String ScSimpleRefDlgWrapper::GetRefString()
+{
+ String aResult;
+ if(pWindow!=NULL)
+ {
+ aResult=((ScSimpleRefDlg*)pWindow)->GetRefString();
+ }
+ return aResult;
+}
+
+void ScSimpleRefDlgWrapper::SetAutoReOpen(BOOL bFlag)
+{
+ bAutoReOpen=bFlag;
+}
+
+void ScSimpleRefDlgWrapper::SetRefString(const String& rStr)
+{
+ if(pWindow!=NULL)
+ {
+ ((ScSimpleRefDlg*)pWindow)->SetRefString(rStr);
+ }
+}
+
+void ScSimpleRefDlgWrapper::SetCloseHdl( const Link& rLink )
+{
+ if(pWindow!=NULL)
+ {
+ ((ScSimpleRefDlg*)pWindow)->SetCloseHdl( rLink );
+ }
+}
+
+void ScSimpleRefDlgWrapper::SetUnoLinks( const Link& rDone,
+ const Link& rAbort, const Link& rChange )
+{
+ if(pWindow!=NULL)
+ {
+ ((ScSimpleRefDlg*)pWindow)->SetUnoLinks( rDone, rAbort, rChange );
+ }
+}
+
+void ScSimpleRefDlgWrapper::SetFlags( BOOL bCloseOnButtonUp, BOOL bSingleCell, BOOL bMultiSelection )
+{
+ if(pWindow!=NULL)
+ {
+ ((ScSimpleRefDlg*)pWindow)->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
+ }
+}
+
+void ScSimpleRefDlgWrapper::StartRefInput()
+{
+ if(pWindow!=NULL)
+ {
+ ((ScSimpleRefDlg*)pWindow)->StartRefInput();
+ }
+}
+
+
+
+//-------------------------------------------------------------------------
+// ScAcceptChgDlgWrapper //Kommentar: sollte in die ViewShell
+//-------------------------------------------------------------------------
+
+ScAcceptChgDlgWrapper::ScAcceptChgDlgWrapper( Window* pParentP,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( pParentP, nId )
+{
+ ScTabViewShell* pViewShell =
+ PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ DBG_ASSERT( pViewShell, "missing view shell :-(" );
+ pWindow = pViewShell ?
+ new ScAcceptChgDlg( pBindings, this, pParentP, pViewShell->GetViewData() ) :
+ NULL;
+ if(pWindow!=NULL)
+ {
+ ((ScAcceptChgDlg*)pWindow)->Initialize( pInfo );
+ }
+ if (pViewShell && !pWindow)
+ pViewShell->GetViewFrame()->SetChildWindow( nId, FALSE );
+}
+
+void ScAcceptChgDlgWrapper::ReInitDlg()
+{
+ ScTabViewShell* pViewShell =
+ PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ DBG_ASSERT( pViewShell, "missing view shell :-(" );
+
+ if(pWindow!=NULL && pViewShell)
+ {
+ ((ScAcceptChgDlg*)pWindow)->ReInit(pViewShell->GetViewData());
+ }
+}
+
+//-------------------------------------------------------------------------
+// ScHighlightChgDlgWrapper
+//-------------------------------------------------------------------------
+
+IMPL_CHILD_CTOR( ScHighlightChgDlgWrapper, FID_CHG_SHOW )
+
+/*------------------------------------------------------------------------*/
+/*@@@
+ //-------------------------------------------------------------------------
+ // ScFunctionDlgWrapper
+ //-------------------------------------------------------------------------
+
+ IMPL_CHILD_CTOR( ScFunctionDlgWrapper, SID_OPENDLG_FUNCTION )
+
+ //-------------------------------------------------------------------------
+ // ScEditFunctionDlgWrapper
+ //-------------------------------------------------------------------------
+
+ IMPL_CHILD_CTOR( ScEditFunctionDlgWrapper, SID_OPENDLG_EDITFUNCTION )
+
+ //-------------------------------------------------------------------------
+ // ScArgumentDlgWrapper
+ //-------------------------------------------------------------------------
+
+ IMPL_CHILD_CTOR( ScArgumentDlgWrapper, SID_OPENDLG_ARGUMENT )
+@@@*/
+/*------------------------------------------------------------------------*/
+
+
+//<!--Added by PengYunQuan for Validity Cell Range Picker
+namespace
+{
+ ScTabViewShell * lcl_GetTabViewShell( SfxBindings *pBindings )
+ {
+ if( pBindings )
+ if( SfxDispatcher* pDisp = pBindings ->GetDispatcher() )
+ if( SfxViewFrame *pFrm = pDisp->GetFrame() )
+ if( SfxViewShell* pViewSh = pFrm->GetViewShell() )
+ return dynamic_cast<ScTabViewShell*>( pViewSh );
+
+ return NULL;
+ }
+}
+
+ScValidityRefChildWin::ScValidityRefChildWin( Window* pParentP, \
+ USHORT nId, \
+ SfxBindings* p, \
+ SfxChildWinInfo* /*pInfo*/ ) \
+ : SfxChildWindow(pParentP, nId),
+ m_bVisibleLock( false ),
+ m_bFreeWindowLock( false ),
+ m_pSavedWndParent( NULL )
+{
+ SetWantsFocus( FALSE );\
+ ScTabViewShell* pViewShell = \
+ NULL != ( pWindow = ScValidationDlg::Find1AliveObject( pParentP ) ) ? static_cast<ScValidationDlg*>(pWindow)->GetTabViewShell() :
+ lcl_GetTabViewShell( p );
+ if (!pViewShell)
+ pViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
+ DBG_ASSERT( pViewShell, "missing view shell :-(" ); \
+ if (pViewShell && !pWindow) \
+ pViewShell->GetViewFrame()->SetChildWindow( nId, FALSE ); \
+ else if( pWindow /*&& pWindow->ISA(ScValidationDlg)*/ )
+ {}//pWindow = new Window( pParentP, WB_HIDE );
+
+ if( pWindow ) m_pSavedWndParent = pWindow->GetParent();
+}
+
+ScValidityRefChildWin::~ScValidityRefChildWin()
+{
+ if( pWindow ) pWindow->SetParent( m_pSavedWndParent );
+
+ if( m_bFreeWindowLock )
+ pWindow = NULL;
+}
+//-->Added by PengYunQuan for Validity Cell Range Picker
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx
new file mode 100644
index 000000000000..1d0fb518e09c
--- /dev/null
+++ b/sc/source/ui/view/scextopt.cxx
@@ -0,0 +1,227 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "scextopt.hxx"
+
+#include <vector>
+#include <map>
+#include <boost/shared_ptr.hpp>
+
+// ============================================================================
+
+ScExtDocSettings::ScExtDocSettings() :
+ mfTabBarWidth( -1.0 ),
+ mnLinkCnt( 0 ),
+ mnDisplTab( 0 )
+{
+}
+
+// ============================================================================
+
+ScExtTabSettings::ScExtTabSettings() :
+ maUsedArea( ScAddress::INITIALIZE_INVALID ),
+ maCursor( ScAddress::INITIALIZE_INVALID ),
+ maFirstVis( ScAddress::INITIALIZE_INVALID ),
+ maSecondVis( ScAddress::INITIALIZE_INVALID ),
+ maFreezePos( 0, 0, 0 ),
+ maSplitPos( 0, 0 ),
+ meActivePane( SCEXT_PANE_TOPLEFT ),
+ maGridColor( COL_AUTO ),
+ mnNormalZoom( 0 ),
+ mnPageZoom( 0 ),
+ mbSelected( false ),
+ mbFrozenPanes( false ),
+ mbPageMode( false ),
+ mbShowGrid( true )
+{
+}
+
+// ============================================================================
+
+/** A container for ScExtTabSettings objects.
+ @descr Internally, a std::map with shared pointers to ScExtTabSettings is
+ used. The copy constructor and assignment operator make deep copies of the
+ objects. */
+class ScExtTabSettingsCont
+{
+public:
+ explicit ScExtTabSettingsCont();
+ ScExtTabSettingsCont( const ScExtTabSettingsCont& rSrc );
+ ScExtTabSettingsCont& operator=( const ScExtTabSettingsCont& rSrc );
+
+ const ScExtTabSettings* GetTabSettings( SCTAB nTab ) const;
+ ScExtTabSettings& GetOrCreateTabSettings( SCTAB nTab );
+
+private:
+ typedef ::boost::shared_ptr< ScExtTabSettings > ScExtTabSettingsRef;
+ typedef ::std::map< SCTAB, ScExtTabSettingsRef > ScExtTabSettingsMap;
+
+ /** Makes a deep copy of all objects in the passed map. */
+ void CopyFromMap( const ScExtTabSettingsMap& rMap );
+
+ ScExtTabSettingsMap maMap;
+};
+
+// ----------------------------------------------------------------------------
+
+ScExtTabSettingsCont::ScExtTabSettingsCont()
+{
+}
+
+ScExtTabSettingsCont::ScExtTabSettingsCont( const ScExtTabSettingsCont& rSrc )
+{
+ CopyFromMap( rSrc.maMap );
+}
+
+ScExtTabSettingsCont& ScExtTabSettingsCont::operator=( const ScExtTabSettingsCont& rSrc )
+{
+ CopyFromMap( rSrc.maMap );
+ return *this;
+}
+
+const ScExtTabSettings* ScExtTabSettingsCont::GetTabSettings( SCTAB nTab ) const
+{
+ ScExtTabSettingsMap::const_iterator aIt = maMap.find( nTab );
+ return (aIt == maMap.end()) ? 0 : aIt->second.get();
+}
+
+ScExtTabSettings& ScExtTabSettingsCont::GetOrCreateTabSettings( SCTAB nTab )
+{
+ ScExtTabSettingsRef& rxTabSett = maMap[ nTab ];
+ if( !rxTabSett )
+ rxTabSett.reset( new ScExtTabSettings );
+ return *rxTabSett;
+}
+
+void ScExtTabSettingsCont::CopyFromMap( const ScExtTabSettingsMap& rMap )
+{
+ maMap.clear();
+ for( ScExtTabSettingsMap::const_iterator aIt = rMap.begin(), aEnd = rMap.end(); aIt != aEnd; ++aIt )
+ maMap[ aIt->first ].reset( new ScExtTabSettings( *aIt->second ) );
+}
+
+// ============================================================================
+
+/** Implementation struct for ScExtDocOptions containing all members. */
+struct ScExtDocOptionsImpl
+{
+ typedef ::std::vector< String > StringVec;
+
+ ScExtDocSettings maDocSett; /// Global document settings.
+ ScExtTabSettingsCont maTabSett; /// Settings for all sheets.
+ StringVec maCodeNames; /// Codenames for all sheets (VBA module names).
+ bool mbChanged; /// Use only if something has been changed.
+
+ explicit ScExtDocOptionsImpl();
+};
+
+ScExtDocOptionsImpl::ScExtDocOptionsImpl() :
+ mbChanged( false )
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScExtDocOptions::ScExtDocOptions() :
+ mxImpl( new ScExtDocOptionsImpl )
+{
+}
+
+ScExtDocOptions::ScExtDocOptions( const ScExtDocOptions& rSrc ) :
+ mxImpl( new ScExtDocOptionsImpl( *rSrc.mxImpl ) )
+{
+}
+
+ScExtDocOptions::~ScExtDocOptions()
+{
+}
+
+ScExtDocOptions& ScExtDocOptions::operator=( const ScExtDocOptions& rSrc )
+{
+ *mxImpl = *rSrc.mxImpl;
+ return *this;
+}
+
+bool ScExtDocOptions::IsChanged() const
+{
+ return mxImpl->mbChanged;
+}
+
+void ScExtDocOptions::SetChanged( bool bChanged )
+{
+ mxImpl->mbChanged = bChanged;
+}
+
+const ScExtDocSettings& ScExtDocOptions::GetDocSettings() const
+{
+ return mxImpl->maDocSett;
+}
+
+ScExtDocSettings& ScExtDocOptions::GetDocSettings()
+{
+ return mxImpl->maDocSett;
+}
+
+const ScExtTabSettings* ScExtDocOptions::GetTabSettings( SCTAB nTab ) const
+{
+ return mxImpl->maTabSett.GetTabSettings( nTab );
+}
+
+ScExtTabSettings& ScExtDocOptions::GetOrCreateTabSettings( SCTAB nTab )
+{
+ return mxImpl->maTabSett.GetOrCreateTabSettings( nTab );
+}
+
+SCTAB ScExtDocOptions::GetCodeNameCount() const
+{
+ return static_cast< SCTAB >( mxImpl->maCodeNames.size() );
+}
+
+const String& ScExtDocOptions::GetCodeName( SCTAB nTab ) const
+{
+ DBG_ASSERT( (0 <= nTab) && (nTab < GetCodeNameCount()), "ScExtDocOptions::GetCodeName - invalid sheet index" );
+ return ((0 <= nTab) && (nTab < GetCodeNameCount())) ? mxImpl->maCodeNames[ static_cast< size_t >( nTab ) ] : EMPTY_STRING;
+}
+
+void ScExtDocOptions::SetCodeName( SCTAB nTab, const String& rCodeName )
+{
+ DBG_ASSERT( nTab >= 0, "ScExtDocOptions::SetCodeName - invalid sheet index" );
+ if( nTab >= 0 )
+ {
+ size_t nIndex = static_cast< size_t >( nTab );
+ if( nIndex >= mxImpl->maCodeNames.size() )
+ mxImpl->maCodeNames.resize( nIndex + 1 );
+ mxImpl->maCodeNames[ nIndex ] = rCodeName;
+ }
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/select.cxx b/sc/source/ui/view/select.cxx
new file mode 100644
index 000000000000..cae66699b717
--- /dev/null
+++ b/sc/source/ui/view/select.cxx
@@ -0,0 +1,871 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <tools/urlobj.hxx>
+#include <vcl/sound.hxx>
+#include <sfx2/docfile.hxx>
+
+#include "select.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "scmod.hxx"
+#include "document.hxx"
+#include "transobj.hxx"
+#include "docsh.hxx"
+#include "tabprotection.hxx"
+
+extern USHORT nScFillModeMouseModifier; // global.cxx
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+static Point aSwitchPos; //! Member
+static BOOL bDidSwitch = FALSE;
+
+// -----------------------------------------------------------------------
+
+//
+// View (Gridwin / Tastatur)
+//
+
+ScViewFunctionSet::ScViewFunctionSet( ScViewData* pNewViewData ) :
+ pViewData( pNewViewData ),
+ pEngine( NULL ),
+ bAnchor( FALSE ),
+ bStarted( FALSE )
+{
+ DBG_ASSERT(pViewData, "ViewData==0 bei FunctionSet");
+}
+
+ScSplitPos ScViewFunctionSet::GetWhich()
+{
+ if (pEngine)
+ return pEngine->GetWhich();
+ else
+ return pViewData->GetActivePart();
+}
+
+void ScViewFunctionSet::SetSelectionEngine( ScViewSelectionEngine* pSelEngine )
+{
+ pEngine = pSelEngine;
+}
+
+// Drag & Drop
+
+void __EXPORT ScViewFunctionSet::BeginDrag()
+{
+ SCTAB nTab = pViewData->GetTabNo();
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ if (pEngine)
+ {
+ Point aMPos = pEngine->GetMousePosPixel();
+ pViewData->GetPosFromPixel( aMPos.X(), aMPos.Y(), GetWhich(), nPosX, nPosY );
+ }
+ else
+ {
+ nPosX = pViewData->GetCurX();
+ nPosY = pViewData->GetCurY();
+ }
+
+ ScModule* pScMod = SC_MOD();
+ BOOL bRefMode = pScMod->IsFormulaMode();
+ if (!bRefMode)
+ {
+ pViewData->GetView()->FakeButtonUp( GetWhich() ); // ButtonUp is swallowed
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+ rMark.MarkToSimple();
+ if ( rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ // bApi = TRUE -> no error messages
+ BOOL bCopied = pViewData->GetView()->CopyToClip( pClipDoc, FALSE, TRUE );
+ if ( bCopied )
+ {
+ sal_Int8 nDragActions = pViewData->GetView()->SelectionEditable() ?
+ ( DND_ACTION_COPYMOVE | DND_ACTION_LINK ) :
+ ( DND_ACTION_COPY | DND_ACTION_LINK );
+
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScTransferObj ctor
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ // set position of dragged cell within range
+ ScRange aMarkRange = pTransferObj->GetRange();
+ SCCOL nStartX = aMarkRange.aStart.Col();
+ SCROW nStartY = aMarkRange.aStart.Row();
+ SCCOL nHandleX = (nPosX >= (SCsCOL) nStartX) ? nPosX - nStartX : 0;
+ SCROW nHandleY = (nPosY >= (SCsROW) nStartY) ? nPosY - nStartY : 0;
+ pTransferObj->SetDragHandlePos( nHandleX, nHandleY );
+ pTransferObj->SetVisibleTab( nTab );
+
+ pTransferObj->SetDragSource( pDocSh, rMark );
+
+ Window* pWindow = pViewData->GetActiveWin();
+ if ( pWindow->IsTracking() )
+ pWindow->EndTracking( ENDTRACK_CANCEL ); // abort selecting
+
+ SC_MOD()->SetDragObject( pTransferObj, NULL ); // for internal D&D
+ pTransferObj->StartDrag( pWindow, nDragActions );
+
+ return; // dragging started
+ }
+ else
+ delete pClipDoc;
+ }
+ }
+
+ Sound::Beep(); // can't drag
+}
+
+// Selection
+
+void __EXPORT ScViewFunctionSet::CreateAnchor()
+{
+ if (bAnchor) return;
+
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ if (bRefMode)
+ SetAnchor( pViewData->GetRefStartX(), pViewData->GetRefStartY() );
+ else
+ SetAnchor( pViewData->GetCurX(), pViewData->GetCurY() );
+}
+
+void ScViewFunctionSet::SetAnchor( SCCOL nPosX, SCROW nPosY )
+{
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ ScTabView* pView = pViewData->GetView();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ if (bRefMode)
+ {
+ pView->DoneRefMode( FALSE );
+ aAnchorPos.Set( nPosX, nPosY, nTab );
+ pView->InitRefMode( aAnchorPos.Col(), aAnchorPos.Row(), aAnchorPos.Tab(),
+ SC_REFTYPE_REF );
+ bStarted = TRUE;
+ }
+ else if (pViewData->IsAnyFillMode())
+ {
+ aAnchorPos.Set( nPosX, nPosY, nTab );
+ bStarted = TRUE;
+ }
+ else
+ {
+ // nicht weg und gleich wieder hin
+ if ( bStarted && pView->IsMarking( nPosX, nPosY, nTab ) )
+ {
+ // nix
+ }
+ else
+ {
+ pView->DoneBlockMode( TRUE );
+ aAnchorPos.Set( nPosX, nPosY, nTab );
+ ScMarkData& rMark = pViewData->GetMarkData();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ pView->InitBlockMode( aAnchorPos.Col(), aAnchorPos.Row(),
+ aAnchorPos.Tab(), TRUE );
+ bStarted = TRUE;
+ }
+ else
+ bStarted = FALSE;
+ }
+ }
+ bAnchor = TRUE;
+}
+
+void __EXPORT ScViewFunctionSet::DestroyAnchor()
+{
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ if (bRefMode)
+ pViewData->GetView()->DoneRefMode( TRUE );
+ else
+ pViewData->GetView()->DoneBlockMode( TRUE );
+
+ bAnchor = FALSE;
+}
+
+void ScViewFunctionSet::SetAnchorFlag( BOOL bSet )
+{
+ bAnchor = bSet;
+}
+
+BOOL __EXPORT ScViewFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOOL /* bDontSelectAtCursor */ )
+{
+ if ( bDidSwitch )
+ {
+ if ( rPointPixel == aSwitchPos )
+ return FALSE; // nicht auf falschem Fenster scrollen
+ else
+ bDidSwitch = FALSE;
+ }
+ aSwitchPos = rPointPixel; // nur wichtig, wenn bDidSwitch
+
+ // treat position 0 as -1, so scrolling is always possible
+ // (with full screen and hidden headers, the top left border may be at 0)
+ // (moved from ScViewData::GetPosFromPixel)
+
+ Point aEffPos = rPointPixel;
+ if ( aEffPos.X() == 0 )
+ aEffPos.X() = -1;
+ if ( aEffPos.Y() == 0 )
+ aEffPos.Y() = -1;
+
+ // Scrolling
+
+ Size aWinSize = pEngine->GetWindow()->GetOutputSizePixel();
+ BOOL bRightScroll = ( aEffPos.X() >= aWinSize.Width() );
+ BOOL bBottomScroll = ( aEffPos.Y() >= aWinSize.Height() );
+ BOOL bNegScroll = ( aEffPos.X() < 0 || aEffPos.Y() < 0 );
+ BOOL bScroll = bRightScroll || bBottomScroll || bNegScroll;
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( aEffPos.X(), aEffPos.Y(), GetWhich(),
+ nPosX, nPosY, TRUE, TRUE ); // mit Repair
+
+ // fuer AutoFill in der Mitte der Zelle umschalten
+ // dabei aber nicht das Scrolling nach rechts/unten verhindern
+ if ( pViewData->IsFillMode() || pViewData->GetFillMode() == SC_FILL_MATRIX )
+ {
+ BOOL bLeft, bTop;
+ pViewData->GetMouseQuadrant( aEffPos, GetWhich(), nPosX, nPosY, bLeft, bTop );
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ if ( bLeft && !bRightScroll )
+ do --nPosX; while ( nPosX>=0 && pDoc->ColHidden( nPosX, nTab ) );
+ if ( bTop && !bBottomScroll )
+ {
+ if (--nPosY >= 0)
+ {
+ nPosY = pDoc->LastVisibleRow(0, nPosY, nTab);
+ if (!ValidRow(nPosY))
+ nPosY = -1;
+ }
+ }
+ // negativ ist erlaubt
+ }
+
+ // ueber Fixier-Grenze bewegt?
+
+ ScSplitPos eWhich = GetWhich();
+ if ( eWhich == pViewData->GetActivePart() )
+ {
+ if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX )
+ if ( aEffPos.X() >= aWinSize.Width() )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ), bScroll = FALSE, bDidSwitch = TRUE;
+ else if ( eWhich == SC_SPLIT_BOTTOMLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bScroll = FALSE, bDidSwitch = TRUE;
+ }
+
+ if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX )
+ if ( aEffPos.Y() >= aWinSize.Height() )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ), bScroll = FALSE, bDidSwitch = TRUE;
+ else if ( eWhich == SC_SPLIT_TOPRIGHT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bScroll = FALSE, bDidSwitch = TRUE;
+ }
+ }
+
+ pViewData->ResetOldCursor();
+ return SetCursorAtCell( nPosX, nPosY, bScroll );
+}
+
+BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScroll )
+{
+ ScTabView* pView = pViewData->GetView();
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ if ( pDoc->IsTabProtected(nTab) )
+ {
+ if (nPosX < 0 || nPosY < 0)
+ return false;
+
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ bool bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bool bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+
+ if ( bSkipProtected && bSkipUnprotected )
+ return FALSE;
+
+ bool bCellProtected = pDoc->HasAttrib(nPosX, nPosY, nTab, nPosX, nPosY, nTab, HASATTR_PROTECTED);
+ if ( (bCellProtected && bSkipProtected) || (!bCellProtected && bSkipUnprotected) )
+ // Don't select this cell!
+ return FALSE;
+ }
+
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewShell = pViewData->GetViewShell();
+ bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false );
+
+ BOOL bHide = !bRefMode && !pViewData->IsAnyFillMode() &&
+ ( nPosX != (SCsCOL) pViewData->GetCurX() || nPosY != (SCsROW) pViewData->GetCurY() );
+
+ if (bHide)
+ pView->HideAllCursors();
+
+ if (bScroll)
+ {
+ if (bRefMode)
+ {
+ ScSplitPos eWhich = GetWhich();
+ pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE, &eWhich );
+ }
+ else
+ pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE );
+ }
+
+ if (bRefMode)
+ {
+ // #90910# if no input is possible from this doc, don't move the reference cursor around
+ if ( !pScMod->IsModalMode(pViewData->GetSfxDocShell()) )
+ {
+ if (!bAnchor)
+ {
+ pView->DoneRefMode( TRUE );
+ pView->InitRefMode( nPosX, nPosY, pViewData->GetTabNo(), SC_REFTYPE_REF );
+ }
+
+ pView->UpdateRef( nPosX, nPosY, pViewData->GetTabNo() );
+ }
+ }
+ else if (pViewData->IsFillMode() ||
+ (pViewData->GetFillMode() == SC_FILL_MATRIX && (nScFillModeMouseModifier & KEY_MOD1) ))
+ {
+ // Wenn eine Matrix angefasst wurde, kann mit Ctrl auf AutoFill zurueckgeschaltet werden
+
+ SCCOL nStartX, nEndX;
+ SCROW nStartY, nEndY; // Block
+ SCTAB nDummy;
+ pViewData->GetSimpleArea( nStartX, nStartY, nDummy, nEndX, nEndY, nDummy );
+
+ if (pViewData->GetRefType() != SC_REFTYPE_FILL)
+ {
+ pView->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL );
+ CreateAnchor();
+ }
+
+ ScRange aDelRange;
+ BOOL bOldDelMark = pViewData->GetDelMark( aDelRange );
+
+ if ( nPosX+1 >= (SCsCOL) nStartX && nPosX <= (SCsCOL) nEndX &&
+ nPosY+1 >= (SCsROW) nStartY && nPosY <= (SCsROW) nEndY &&
+ ( nPosX != nEndX || nPosY != nEndY ) ) // verkleinern ?
+ {
+ // Richtung (links oder oben)
+
+ long nSizeX = 0;
+ for (SCCOL i=nPosX+1; i<=nEndX; i++)
+ nSizeX += pDoc->GetColWidth( i, nTab );
+ long nSizeY = (long) pDoc->GetRowHeight( nPosY+1, nEndY, nTab );
+
+ SCCOL nDelStartX = nStartX;
+ SCROW nDelStartY = nStartY;
+ if ( nSizeX > nSizeY )
+ nDelStartX = nPosX + 1;
+ else
+ nDelStartY = nPosY + 1;
+ // 0 braucht nicht mehr getrennt abgefragt zu werden, weil nPosX/Y auch negativ wird
+
+ if ( nDelStartX < nStartX )
+ nDelStartX = nStartX;
+ if ( nDelStartY < nStartY )
+ nDelStartY = nStartY;
+
+ // Bereich setzen
+
+ pViewData->SetDelMark( ScRange( nDelStartX,nDelStartY,nTab,
+ nEndX,nEndY,nTab ) );
+ pViewData->GetView()->UpdateShrinkOverlay();
+
+ pViewData->GetView()->
+ PaintArea( nStartX,nDelStartY, nEndX,nEndY, SC_UPDATE_MARKS );
+
+ nPosX = nEndX; // roten Rahmen um ganzen Bereich lassen
+ nPosY = nEndY;
+
+ // Referenz wieder richtigherum, falls unten umgedreht
+ if ( nStartX != pViewData->GetRefStartX() || nStartY != pViewData->GetRefStartY() )
+ {
+ pViewData->GetView()->DoneRefMode();
+ pViewData->GetView()->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL );
+ }
+ }
+ else
+ {
+ if ( bOldDelMark )
+ {
+ pViewData->ResetDelMark();
+ pViewData->GetView()->UpdateShrinkOverlay();
+ }
+
+ BOOL bNegX = ( nPosX < (SCsCOL) nStartX );
+ BOOL bNegY = ( nPosY < (SCsROW) nStartY );
+
+ long nSizeX = 0;
+ if ( bNegX )
+ {
+ // #94321# in SetCursorAtPoint hidden columns are skipped.
+ // They must be skipped here too, or the result will always be the first hidden column.
+ do ++nPosX; while ( nPosX<nStartX && pDoc->ColHidden(nPosX, nTab) );
+ for (SCCOL i=nPosX; i<nStartX; i++)
+ nSizeX += pDoc->GetColWidth( i, nTab );
+ }
+ else
+ for (SCCOL i=nEndX+1; i<=nPosX; i++)
+ nSizeX += pDoc->GetColWidth( i, nTab );
+
+ long nSizeY = 0;
+ if ( bNegY )
+ {
+ // #94321# in SetCursorAtPoint hidden rows are skipped.
+ // They must be skipped here too, or the result will always be the first hidden row.
+ if (++nPosY < nStartY)
+ {
+ nPosY = pDoc->FirstVisibleRow(nPosY, nStartY-1, nTab);
+ if (!ValidRow(nPosY))
+ nPosY = nStartY;
+ }
+ nSizeY += pDoc->GetRowHeight( nPosY, nStartY-1, nTab );
+ }
+ else
+ nSizeY += pDoc->GetRowHeight( nEndY+1, nPosY, nTab );
+
+ if ( nSizeX > nSizeY ) // Fill immer nur in einer Richtung
+ {
+ nPosY = nEndY;
+ bNegY = FALSE;
+ }
+ else
+ {
+ nPosX = nEndX;
+ bNegX = FALSE;
+ }
+
+ SCCOL nRefStX = bNegX ? nEndX : nStartX;
+ SCROW nRefStY = bNegY ? nEndY : nStartY;
+ if ( nRefStX != pViewData->GetRefStartX() || nRefStY != pViewData->GetRefStartY() )
+ {
+ pViewData->GetView()->DoneRefMode();
+ pViewData->GetView()->InitRefMode( nRefStX, nRefStY, nTab, SC_REFTYPE_FILL );
+ }
+ }
+
+ pView->UpdateRef( nPosX, nPosY, nTab );
+ }
+ else if (pViewData->IsAnyFillMode())
+ {
+ BYTE nMode = pViewData->GetFillMode();
+ if ( nMode == SC_FILL_EMBED_LT || nMode == SC_FILL_EMBED_RB )
+ {
+ DBG_ASSERT( pDoc->IsEmbedded(), "!pDoc->IsEmbedded()" );
+ ScRange aRange;
+ pDoc->GetEmbedded( aRange);
+ ScRefType eRefMode = (nMode == SC_FILL_EMBED_LT) ? SC_REFTYPE_EMBED_LT : SC_REFTYPE_EMBED_RB;
+ if (pViewData->GetRefType() != eRefMode)
+ {
+ if ( nMode == SC_FILL_EMBED_LT )
+ pView->InitRefMode( aRange.aEnd.Col(), aRange.aEnd.Row(), nTab, eRefMode );
+ else
+ pView->InitRefMode( aRange.aStart.Col(), aRange.aStart.Row(), nTab, eRefMode );
+ CreateAnchor();
+ }
+
+ pView->UpdateRef( nPosX, nPosY, nTab );
+ }
+ else if ( nMode == SC_FILL_MATRIX )
+ {
+ SCCOL nStartX, nEndX;
+ SCROW nStartY, nEndY; // Block
+ SCTAB nDummy;
+ pViewData->GetSimpleArea( nStartX, nStartY, nDummy, nEndX, nEndY, nDummy );
+
+ if (pViewData->GetRefType() != SC_REFTYPE_FILL)
+ {
+ pView->InitRefMode( nStartX, nStartY, nTab, SC_REFTYPE_FILL );
+ CreateAnchor();
+ }
+
+ if ( nPosX < nStartX ) nPosX = nStartX;
+ if ( nPosY < nStartY ) nPosY = nStartY;
+
+ pView->UpdateRef( nPosX, nPosY, nTab );
+ }
+ // else neue Modi
+ }
+ else // normales Markieren
+ {
+ BOOL bHideCur = bAnchor && ( (SCCOL)nPosX != pViewData->GetCurX() ||
+ (SCROW)nPosY != pViewData->GetCurY() );
+ if (bHideCur)
+ pView->HideAllCursors(); // sonst zweimal: Block und SetCursor
+
+ if (bAnchor)
+ {
+ if (!bStarted)
+ {
+ BOOL bMove = ( nPosX != (SCsCOL) aAnchorPos.Col() ||
+ nPosY != (SCsROW) aAnchorPos.Row() );
+ if ( bMove || ( pEngine && pEngine->GetMouseEvent().IsShift() ) )
+ {
+ pView->InitBlockMode( aAnchorPos.Col(), aAnchorPos.Row(),
+ aAnchorPos.Tab(), TRUE );
+ bStarted = TRUE;
+ }
+ }
+ if (bStarted)
+ // If the selection is already started, don't set the cursor.
+ pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab, FALSE, FALSE, TRUE );
+ else
+ pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
+ }
+ else
+ {
+ ScMarkData& rMark = pViewData->GetMarkData();
+ if (rMark.IsMarked() || rMark.IsMultiMarked())
+ {
+ pView->DoneBlockMode(TRUE);
+ pView->InitBlockMode( nPosX, nPosY, nTab, TRUE );
+ pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab );
+
+ aAnchorPos.Set( nPosX, nPosY, nTab );
+ bStarted = TRUE;
+ }
+ // #i3875# *Hack* When a new cell is Ctrl-clicked with no pre-selected cells,
+ // it highlights that new cell as well as the old cell where the cursor is
+ // positioned prior to the click. A selection mode via Shift-F8 should also
+ // follow the same behavior.
+ else if ( pViewData->IsSelCtrlMouseClick() )
+ {
+ SCCOL nOldX = pViewData->GetCurX();
+ SCROW nOldY = pViewData->GetCurY();
+
+ pView->InitBlockMode( nOldX, nOldY, nTab, TRUE );
+ pView->MarkCursor( (SCCOL) nOldX, (SCROW) nOldY, nTab );
+
+ if ( nOldX != nPosX || nOldY != nPosY )
+ {
+ pView->DoneBlockMode( TRUE );
+ pView->InitBlockMode( nPosX, nPosY, nTab, TRUE );
+ pView->MarkCursor( (SCCOL) nPosX, (SCROW) nPosY, nTab );
+ aAnchorPos.Set( nPosX, nPosY, nTab );
+ }
+
+ bStarted = TRUE;
+ }
+ pView->SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
+ }
+
+ pViewData->SetRefStart( nPosX, nPosY, nTab );
+ if (bHideCur)
+ pView->ShowAllCursors();
+ }
+
+ if (bHide)
+ pView->ShowAllCursors();
+
+ return TRUE;
+}
+
+BOOL __EXPORT ScViewFunctionSet::IsSelectionAtPoint( const Point& rPointPixel )
+{
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ if (bRefMode)
+ return FALSE;
+
+ if (pViewData->IsAnyFillMode())
+ return FALSE;
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+ if (bAnchor || !rMark.IsMultiMarked())
+ {
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), GetWhich(), nPosX, nPosY );
+ return pViewData->GetMarkData().IsCellMarked( (SCCOL) nPosX, (SCROW) nPosY );
+ }
+
+ return FALSE;
+}
+
+void __EXPORT ScViewFunctionSet::DeselectAtPoint( const Point& /* rPointPixel */ )
+{
+ // gibt's nicht
+}
+
+void __EXPORT ScViewFunctionSet::DeselectAll()
+{
+ if (pViewData->IsAnyFillMode())
+ return;
+
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ if (bRefMode)
+ {
+ pViewData->GetView()->DoneRefMode( FALSE );
+ }
+ else
+ {
+ pViewData->GetView()->DoneBlockMode( FALSE );
+ pViewData->GetViewShell()->UpdateInputHandler();
+ }
+
+ bAnchor = FALSE;
+}
+
+//------------------------------------------------------------------------
+
+ScViewSelectionEngine::ScViewSelectionEngine( Window* pWindow, ScTabView* pView,
+ ScSplitPos eSplitPos ) :
+ SelectionEngine( pWindow, pView->GetFunctionSet() ),
+ eWhich( eSplitPos )
+{
+ // Parameter einstellen
+ SetSelectionMode( MULTIPLE_SELECTION );
+ EnableDrag( TRUE );
+}
+
+
+//------------------------------------------------------------------------
+
+//
+// Spalten- / Zeilenheader
+//
+
+ScHeaderFunctionSet::ScHeaderFunctionSet( ScViewData* pNewViewData ) :
+ pViewData( pNewViewData ),
+ bColumn( FALSE ),
+ eWhich( SC_SPLIT_TOPLEFT ),
+ bAnchor( FALSE ),
+ nCursorPos( 0 )
+{
+ DBG_ASSERT(pViewData, "ViewData==0 bei FunctionSet");
+}
+
+void ScHeaderFunctionSet::SetColumn( BOOL bSet )
+{
+ bColumn = bSet;
+}
+
+void ScHeaderFunctionSet::SetWhich( ScSplitPos eNew )
+{
+ eWhich = eNew;
+}
+
+void __EXPORT ScHeaderFunctionSet::BeginDrag()
+{
+ // gippsnich
+}
+
+void __EXPORT ScHeaderFunctionSet::CreateAnchor()
+{
+ if (bAnchor)
+ return;
+
+ ScTabView* pView = pViewData->GetView();
+ pView->DoneBlockMode( TRUE );
+ if (bColumn)
+ {
+ pView->InitBlockMode( static_cast<SCCOL>(nCursorPos), 0, pViewData->GetTabNo(), TRUE, TRUE, FALSE );
+ pView->MarkCursor( static_cast<SCCOL>(nCursorPos), MAXROW, pViewData->GetTabNo() );
+ }
+ else
+ {
+ pView->InitBlockMode( 0, nCursorPos, pViewData->GetTabNo(), TRUE, FALSE, TRUE );
+ pView->MarkCursor( MAXCOL, nCursorPos, pViewData->GetTabNo() );
+ }
+ bAnchor = TRUE;
+}
+
+void __EXPORT ScHeaderFunctionSet::DestroyAnchor()
+{
+ pViewData->GetView()->DoneBlockMode( TRUE );
+ bAnchor = FALSE;
+}
+
+BOOL __EXPORT ScHeaderFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOOL /* bDontSelectAtCursor */ )
+{
+ if ( bDidSwitch )
+ {
+ // die naechste gueltige Position muss vom anderen Fenster kommen
+ if ( rPointPixel == aSwitchPos )
+ return FALSE; // nicht auf falschem Fenster scrollen
+ else
+ bDidSwitch = FALSE;
+ }
+
+ // Scrolling
+
+ Size aWinSize = pViewData->GetActiveWin()->GetOutputSizePixel();
+ BOOL bScroll;
+ if (bColumn)
+ bScroll = ( rPointPixel.X() < 0 || rPointPixel.X() >= aWinSize.Width() );
+ else
+ bScroll = ( rPointPixel.Y() < 0 || rPointPixel.Y() >= aWinSize.Height() );
+
+ // ueber Fixier-Grenze bewegt?
+
+ BOOL bSwitched = FALSE;
+ if ( bColumn )
+ {
+ if ( pViewData->GetHSplitMode() == SC_SPLIT_FIX )
+ {
+ if ( rPointPixel.X() > aWinSize.Width() )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_TOPRIGHT ), bSwitched = TRUE;
+ else if ( eWhich == SC_SPLIT_BOTTOMLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bSwitched = TRUE;
+ }
+ }
+ }
+ else // Zeilenkoepfe
+ {
+ if ( pViewData->GetVSplitMode() == SC_SPLIT_FIX )
+ {
+ if ( rPointPixel.Y() > aWinSize.Height() )
+ {
+ if ( eWhich == SC_SPLIT_TOPLEFT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMLEFT ), bSwitched = TRUE;
+ else if ( eWhich == SC_SPLIT_TOPRIGHT )
+ pViewData->GetView()->ActivatePart( SC_SPLIT_BOTTOMRIGHT ), bSwitched = TRUE;
+ }
+ }
+ }
+ if (bSwitched)
+ {
+ aSwitchPos = rPointPixel;
+ bDidSwitch = TRUE;
+ return FALSE; // nicht mit falschen Positionen rechnen
+ }
+
+ //
+
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), pViewData->GetActivePart(),
+ nPosX, nPosY, FALSE );
+ if (bColumn)
+ {
+ nCursorPos = static_cast<SCCOLROW>(nPosX);
+ nPosY = pViewData->GetPosY(WhichV(pViewData->GetActivePart()));
+ }
+ else
+ {
+ nCursorPos = static_cast<SCCOLROW>(nPosY);
+ nPosX = pViewData->GetPosX(WhichH(pViewData->GetActivePart()));
+ }
+
+ ScTabView* pView = pViewData->GetView();
+ BOOL bHide = pViewData->GetCurX() != nPosX ||
+ pViewData->GetCurY() != nPosY;
+ if (bHide)
+ pView->HideAllCursors();
+
+ if (bScroll)
+ pView->AlignToCursor( nPosX, nPosY, SC_FOLLOW_LINE );
+ pView->SetCursor( nPosX, nPosY );
+
+ if ( !bAnchor || !pView->IsBlockMode() )
+ {
+ pView->DoneBlockMode( TRUE );
+ pViewData->GetMarkData().MarkToMulti(); //! wer verstellt das ???
+ pView->InitBlockMode( nPosX, nPosY, pViewData->GetTabNo(), TRUE, bColumn, !bColumn );
+
+ bAnchor = TRUE;
+ }
+
+ pView->MarkCursor( nPosX, nPosY, pViewData->GetTabNo(), bColumn, !bColumn );
+
+ // SelectionChanged innerhalb von HideCursor wegen UpdateAutoFillMark
+ pView->SelectionChanged();
+
+ if (bHide)
+ pView->ShowAllCursors();
+
+ return TRUE;
+}
+
+BOOL __EXPORT ScHeaderFunctionSet::IsSelectionAtPoint( const Point& rPointPixel )
+{
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ pViewData->GetPosFromPixel( rPointPixel.X(), rPointPixel.Y(), pViewData->GetActivePart(),
+ nPosX, nPosY, FALSE );
+
+ ScMarkData& rMark = pViewData->GetMarkData();
+ if (bColumn)
+ return rMark.IsColumnMarked( nPosX );
+ else
+ return rMark.IsRowMarked( nPosY );
+}
+
+void __EXPORT ScHeaderFunctionSet::DeselectAtPoint( const Point& /* rPointPixel */ )
+{
+}
+
+void __EXPORT ScHeaderFunctionSet::DeselectAll()
+{
+ pViewData->GetView()->DoneBlockMode( FALSE );
+ bAnchor = FALSE;
+}
+
+//------------------------------------------------------------------------
+
+ScHeaderSelectionEngine::ScHeaderSelectionEngine( Window* pWindow, ScHeaderFunctionSet* pFuncSet ) :
+ SelectionEngine( pWindow, pFuncSet )
+{
+ // Parameter einstellen
+ SetSelectionMode( MULTIPLE_SELECTION );
+ EnableDrag( FALSE );
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/selectionstate.cxx b/sc/source/ui/view/selectionstate.cxx
new file mode 100644
index 000000000000..0fd4a1720959
--- /dev/null
+++ b/sc/source/ui/view/selectionstate.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "selectionstate.hxx"
+
+#include <editeng/editview.hxx>
+#include "viewdata.hxx"
+
+// ============================================================================
+
+ScSelectionState::ScSelectionState( ScViewData& rViewData ) :
+ meType( SC_SELECTTYPE_NONE )
+{
+ maCursor.SetTab( rViewData.GetTabNo() );
+ ScSplitPos eWhich = rViewData.GetActivePart();
+
+ if( rViewData.HasEditView( eWhich ) )
+ {
+ meType = SC_SELECTTYPE_EDITCELL;
+ maCursor.SetCol( rViewData.GetEditViewCol() );
+ maCursor.SetRow( rViewData.GetEditViewRow() );
+ maEditSel = rViewData.GetEditView( eWhich )->GetSelection();
+ }
+ else
+ {
+ maCursor.SetCol( rViewData.GetCurX() );
+ maCursor.SetRow( rViewData.GetCurY() );
+
+ ScMarkData& rMarkData = rViewData.GetMarkData();
+ rMarkData.MarkToMulti();
+ if( rMarkData.IsMultiMarked() )
+ {
+ meType = SC_SELECTTYPE_SHEET;
+ rMarkData.FillRangeListWithMarks( &maSheetSel, FALSE );
+ }
+ // else type is SC_SELECTTYPE_NONE - already initialized
+ }
+}
+
+bool operator==( const ScSelectionState& rL, const ScSelectionState& rR )
+{
+ bool bEqual = rL.GetSelectionType() == rR.GetSelectionType();
+ if( bEqual ) switch( rL.GetSelectionType() )
+ {
+ case SC_SELECTTYPE_EDITCELL:
+ bEqual &= ( rL.GetEditSelection().IsEqual( rR.GetEditSelection() ) != FALSE );
+ // run through!
+ case SC_SELECTTYPE_SHEET:
+ bEqual &= (rL.GetSheetSelection() == rR.GetSheetSelection()) == TRUE;
+ // run through!
+ case SC_SELECTTYPE_NONE:
+ bEqual &= rL.GetCellCursor() == rR.GetCellCursor();
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return bEqual;
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/spelldialog.cxx b/sc/source/ui/view/spelldialog.cxx
new file mode 100644
index 000000000000..69070bea47f2
--- /dev/null
+++ b/sc/source/ui/view/spelldialog.cxx
@@ -0,0 +1,281 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "spelldialog.hxx"
+
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/editstat.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/unolingu.hxx>
+#include "selectionstate.hxx"
+
+#include "spelleng.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "editable.hxx"
+#include "undoblk.hxx"
+
+// ============================================================================
+
+SFX_IMPL_CHILDWINDOW( ScSpellDialogChildWindow, SID_SPELL_DIALOG )
+
+ScSpellDialogChildWindow::ScSpellDialogChildWindow( Window* pParentP, USHORT nId,
+ SfxBindings* pBindings, SfxChildWinInfo* pInfo ) :
+ ::svx::SpellDialogChildWindow( pParentP, nId, pBindings, pInfo ),
+ mpViewShell( 0 ),
+ mpViewData( 0 ),
+ mpDocShell( 0 ),
+ mpDoc( 0 ),
+ mbNeedNextObj( false ),
+ mbOldIdleDisabled( false )
+{
+ Init();
+}
+
+ScSpellDialogChildWindow::~ScSpellDialogChildWindow()
+{
+ Reset();
+}
+
+SfxChildWinInfo ScSpellDialogChildWindow::GetInfo() const
+{
+ return ::svx::SpellDialogChildWindow::GetInfo();
+}
+
+void ScSpellDialogChildWindow::InvalidateSpellDialog()
+{
+ ::svx::SpellDialogChildWindow::InvalidateSpellDialog();
+}
+
+// protected ------------------------------------------------------------------
+
+::svx::SpellPortions ScSpellDialogChildWindow::GetNextWrongSentence( bool /*bRecheck*/ )
+{
+ ::svx::SpellPortions aPortions;
+ if( mxEngine.get() && mpViewData )
+ {
+ if( EditView* pEditView = mpViewData->GetSpellingView() )
+ {
+ // edit engine handles cell iteration internally
+ do
+ {
+ if( mbNeedNextObj )
+ mxEngine->SpellNextDocument();
+ mbNeedNextObj = !mxEngine->IsFinished() && !mxEngine->SpellSentence( *pEditView, aPortions, false );
+ }
+ while( mbNeedNextObj );
+ }
+
+ // finished? - close the spelling dialog
+ if( mxEngine->IsFinished() )
+ GetBindings().GetDispatcher()->Execute( SID_SPELL_DIALOG, SFX_CALLMODE_ASYNCHRON );
+ }
+ return aPortions;
+}
+
+void ScSpellDialogChildWindow::ApplyChangedSentence( const ::svx::SpellPortions& rChanged, bool bRecheck )
+{
+ if( mxEngine.get() && mpViewData )
+ if( EditView* pEditView = mpViewData->GetSpellingView() )
+ mxEngine->ApplyChangedSentence( *pEditView, rChanged, bRecheck );
+}
+
+void ScSpellDialogChildWindow::GetFocus()
+{
+ if( IsSelectionChanged() )
+ {
+ Reset();
+ InvalidateSpellDialog();
+ Init();
+ }
+}
+
+void ScSpellDialogChildWindow::LoseFocus()
+{
+}
+
+// private --------------------------------------------------------------------
+
+void ScSpellDialogChildWindow::Reset()
+{
+ if( mpViewShell && (mpViewShell == PTR_CAST( ScTabViewShell, SfxViewShell::Current() )) )
+ {
+ if( mxEngine.get() && mxEngine->IsAnyModified() )
+ {
+ const ScAddress& rCursor = mxOldSel->GetCellCursor();
+ SCTAB nTab = rCursor.Tab();
+ SCCOL nOldCol = rCursor.Col();
+ SCROW nOldRow = rCursor.Row();
+ SCCOL nNewCol = mpViewData->GetCurX();
+ SCROW nNewRow = mpViewData->GetCurY();
+ mpDocShell->GetUndoManager()->AddUndoAction( new ScUndoConversion(
+ mpDocShell, mpViewData->GetMarkData(),
+ nOldCol, nOldRow, nTab, mxUndoDoc.release(),
+ nNewCol, nNewRow, nTab, mxRedoDoc.release(),
+ ScConversionParam( SC_CONVERSION_SPELLCHECK ) ) );
+ mpDoc->SetDirty();
+ mpDocShell->SetDocumentModified();
+ }
+
+ mpViewData->SetSpellingView( 0 );
+ mpViewShell->KillEditView( TRUE );
+ mpDocShell->PostPaintGridAll();
+ mpViewShell->UpdateInputHandler();
+ mpDoc->DisableIdle( mbOldIdleDisabled );
+ }
+ mxEngine.reset();
+ mxUndoDoc.reset();
+ mxRedoDoc.reset();
+ mxOldSel.reset();
+ mpViewShell = 0;
+ mpViewData = 0;
+ mpDocShell = 0;
+ mpDoc = 0;
+ mbNeedNextObj = false;
+ mbOldIdleDisabled = false;
+}
+
+void ScSpellDialogChildWindow::Init()
+{
+ if( mpViewShell )
+ return;
+ if( (mpViewShell = PTR_CAST( ScTabViewShell, SfxViewShell::Current() )) == 0 )
+ return;
+
+ mpViewData = mpViewShell->GetViewData();
+
+ // exit edit mode - TODO support spelling in edit mode
+ if( mpViewData->HasEditView( mpViewData->GetActivePart() ) )
+ SC_MOD()->InputEnterHandler();
+
+ mxOldSel.reset( new ScSelectionState( *mpViewData ) );
+
+ mpDocShell = mpViewData->GetDocShell();
+ mpDoc = mpDocShell->GetDocument();
+
+ const ScAddress& rCursor = mxOldSel->GetCellCursor();
+ SCCOL nCol = rCursor.Col();
+ SCROW nRow = rCursor.Row();
+ SCTAB nTab = rCursor.Tab();
+
+ ScMarkData& rMarkData = mpViewData->GetMarkData();
+ rMarkData.MarkToMulti();
+
+ switch( mxOldSel->GetSelectionType() )
+ {
+ case SC_SELECTTYPE_NONE:
+ case SC_SELECTTYPE_SHEET:
+ {
+ // test if there is something editable
+ ScEditableTester aTester( mpDoc, rMarkData );
+ if( !aTester.IsEditable() )
+ {
+ // #i85751# Don't show a ErrorMessage here, because the vcl
+ // parent of the InfoBox is not fully initialized yet.
+ // This leads to problems in the modality behaviour of the
+ // ScSpellDialogChildWindow.
+
+ //mpViewShell->ErrorMessage( aTester.GetMessageId() );
+ return;
+ }
+ }
+ break;
+
+ // edit mode exited, see TODO above
+// case SC_SELECTTYPE_EDITCELL:
+// break;
+
+ default:
+ DBG_ERRORFILE( "ScSpellDialogChildWindow::Init - unknown selection type" );
+ }
+
+ mbOldIdleDisabled = mpDoc->IsIdleDisabled();
+ mpDoc->DisableIdle( TRUE ); // #42726# stop online spelling
+
+ // *** create Undo/Redo documents *** -------------------------------------
+
+ mxUndoDoc.reset( new ScDocument( SCDOCMODE_UNDO ) );
+ mxUndoDoc->InitUndo( mpDoc, nTab, nTab );
+ mxRedoDoc.reset( new ScDocument( SCDOCMODE_UNDO ) );
+ mxRedoDoc->InitUndo( mpDoc, nTab, nTab );
+
+ if ( rMarkData.GetSelectCount() > 1 )
+ {
+ SCTAB nTabCount = mpDoc->GetTableCount();
+ for( SCTAB nOtherTab = 0; nOtherTab < nTabCount; ++nOtherTab )
+ {
+ if( rMarkData.GetTableSelect( nOtherTab ) && (nOtherTab != nTab) )
+ {
+ mxUndoDoc->AddUndoTab( nOtherTab, nOtherTab );
+ mxRedoDoc->AddUndoTab( nOtherTab, nOtherTab );
+ }
+ }
+ }
+
+ // *** create and init the edit engine *** --------------------------------
+
+ mxEngine.reset( new ScSpellingEngine(
+ mpDoc->GetEnginePool(), *mpViewData, mxUndoDoc.get(), mxRedoDoc.get(), LinguMgr::GetSpellChecker() ) );
+ mxEngine->SetRefDevice( mpViewData->GetActiveWin() );
+
+ mpViewShell->MakeEditView( mxEngine.get(), nCol, nRow );
+ EditView* pEditView = mpViewData->GetEditView( mpViewData->GetActivePart() );
+ mpViewData->SetSpellingView( pEditView );
+ Rectangle aRect( Point( 0, 0 ), Point( 0, 0 ) );
+ pEditView->SetOutputArea( aRect );
+ mxEngine->SetControlWord( EE_CNTRL_USECHARATTRIBS );
+ mxEngine->EnableUndo( FALSE );
+ mxEngine->SetPaperSize( aRect.GetSize() );
+ mxEngine->SetText( EMPTY_STRING );
+ mxEngine->ClearModifyFlag();
+
+ mbNeedNextObj = true;
+}
+
+bool ScSpellDialogChildWindow::IsSelectionChanged()
+{
+ if( !mxOldSel.get() || !mpViewShell || (mpViewShell != PTR_CAST( ScTabViewShell, SfxViewShell::Current() )) )
+ return true;
+
+ if( EditView* pEditView = mpViewData->GetSpellingView() )
+ if( pEditView->GetEditEngine() != mxEngine.get() )
+ return true;
+
+ ScSelectionState aNewSel( *mpViewData );
+ return mxOldSel->GetSheetSelection() != aNewSel.GetSheetSelection();
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx
new file mode 100644
index 000000000000..bbfb856848a9
--- /dev/null
+++ b/sc/source/ui/view/spelleng.cxx
@@ -0,0 +1,460 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include "spelleng.hxx"
+#include <com/sun/star/i18n/TextConversionOption.hpp>
+
+#include <memory>
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <editeng/langitem.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/editview.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+
+#include "spelldialog.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "cell.hxx"
+#include "patattr.hxx"
+#include "waitoff.hxx"
+#include "globstr.hrc"
+
+
+using namespace ::com::sun::star;
+
+// ============================================================================
+
+namespace {
+
+bool lclHasString( ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString )
+{
+ String aCompStr;
+ rDoc.GetString( nCol, nRow, nTab, aCompStr );
+ return aCompStr == rString; //! case-insensitive?
+}
+
+} // namespace
+
+// ----------------------------------------------------------------------------
+
+ScConversionEngineBase::ScConversionEngineBase(
+ SfxItemPool* pEnginePoolP, ScViewData& rViewData,
+ ScDocument* pUndoDoc, ScDocument* pRedoDoc ) :
+ ScEditEngineDefaulter( pEnginePoolP ),
+ mrViewData( rViewData ),
+ mrDocShell( *rViewData.GetDocShell() ),
+ mrDoc( *rViewData.GetDocShell()->GetDocument() ),
+ maSelState( rViewData ),
+ mpUndoDoc( pUndoDoc ),
+ mpRedoDoc( pRedoDoc ),
+ meCurrLang( LANGUAGE_ENGLISH_US ),
+ mbIsAnyModified( false ),
+ mbInitialState( true ),
+ mbWrappedInTable( false ),
+ mbFinished( false )
+{
+ maSelState.GetCellCursor().GetVars( mnStartCol, mnStartRow, mnStartTab );
+ // start with cell A1 in cell/range/multi-selection, will seek to first selected
+ if( maSelState.GetSelectionType() == SC_SELECTTYPE_SHEET )
+ {
+ mnStartCol = 0;
+ mnStartRow = 0;
+ }
+ mnCurrCol = mnStartCol;
+ mnCurrRow = mnStartRow;
+}
+
+ScConversionEngineBase::~ScConversionEngineBase()
+{
+}
+
+bool ScConversionEngineBase::FindNextConversionCell()
+{
+ ScMarkData& rMark = mrViewData.GetMarkData();
+ ScTabViewShell* pViewShell = mrViewData.GetViewShell();
+ ScBaseCell* pCell = NULL;
+ const ScPatternAttr* pPattern = NULL;
+ const ScPatternAttr* pLastPattern = NULL;
+ ::std::auto_ptr< SfxItemSet > pEditDefaults( new SfxItemSet( GetEmptyItemSet() ) );
+
+ if( IsModified() )
+ {
+ mbIsAnyModified = true;
+
+ String aNewStr = GetText();
+
+ BOOL bMultiTab = (rMark.GetSelectCount() > 1);
+ String aVisibleStr;
+ if( bMultiTab )
+ mrDoc.GetString( mnCurrCol, mnCurrRow, mnStartTab, aVisibleStr );
+
+ for( SCTAB nTab = 0, nTabCount = mrDoc.GetTableCount(); nTab < nTabCount; ++nTab )
+ {
+ // #69965# always change the cell on the visible tab,
+ // on the other selected tabs only if they contain the same text
+
+ if( (nTab == mnStartTab) ||
+ (bMultiTab && rMark.GetTableSelect( nTab ) &&
+ lclHasString( mrDoc, mnCurrCol, mnCurrRow, nTab, aVisibleStr )) )
+ {
+ ScAddress aPos( mnCurrCol, mnCurrRow, nTab );
+ CellType eCellType = mrDoc.GetCellType( aPos );
+ pCell = mrDoc.GetCell( aPos );
+
+ if( mpUndoDoc && pCell )
+ {
+ ScBaseCell* pUndoCell = pCell->CloneWithoutNote( *mpUndoDoc );
+ mpUndoDoc->PutCell( aPos, pUndoCell );
+ }
+
+ if( eCellType == CELLTYPE_EDIT )
+ {
+ if( pCell )
+ {
+ ScEditCell* pEditCell = static_cast< ScEditCell* >( pCell );
+ ::std::auto_ptr< EditTextObject > pEditObj( CreateTextObject() );
+ pEditCell->SetData( pEditObj.get(), GetEditTextObjectPool() );
+ }
+ }
+ else
+ {
+ mrDoc.SetString( mnCurrCol, mnCurrRow, nTab, aNewStr );
+ pCell = mrDoc.GetCell( aPos );
+ }
+
+ if( mpRedoDoc && pCell )
+ {
+ ScBaseCell* pRedoCell = pCell->CloneWithoutNote( *mpRedoDoc );
+ mpRedoDoc->PutCell( aPos, pRedoCell );
+ }
+
+ mrDocShell.PostPaintCell( mnCurrCol, mnCurrRow, nTab );
+ }
+ }
+ }
+ pCell = NULL;
+ SCCOL nNewCol = mnCurrCol;
+ SCROW nNewRow = mnCurrRow;
+
+ if( mbInitialState )
+ {
+ /* On very first call, decrement row to let GetNextSpellingCell() find
+ the first cell of current range. */
+ mbInitialState = false;
+ --nNewRow;
+ }
+
+ bool bSheetSel = maSelState.GetSelectionType() == SC_SELECTTYPE_SHEET;
+ bool bLoop = true;
+ bool bFound = false;
+ while( bLoop && !bFound )
+ {
+ bLoop = mrDoc.GetNextSpellingCell( nNewCol, nNewRow, mnStartTab, bSheetSel, rMark );
+ if( bLoop )
+ {
+ FillFromCell( mnCurrCol, mnCurrRow, mnStartTab );
+
+ if( mbWrappedInTable && ((nNewCol > mnStartCol) || ((nNewCol == mnStartCol) && (nNewRow >= mnStartRow))) )
+ {
+ ShowFinishDialog();
+ bLoop = false;
+ mbFinished = true;
+ }
+ else if( nNewCol > MAXCOL )
+ {
+ // no more cells in the sheet - try to restart at top of sheet
+
+ if( bSheetSel || ((mnStartCol == 0) && (mnStartRow == 0)) )
+ {
+ // conversion started at cell A1 or in selection, do not query to restart at top
+ ShowFinishDialog();
+ bLoop = false;
+ mbFinished = true;
+ }
+ else if( ShowTableWrapDialog() )
+ {
+ // conversion started anywhere but in cell A1, user wants to restart
+ nNewRow = MAXROW + 2;
+ mbWrappedInTable = true;
+ }
+ else
+ {
+ bLoop = false;
+ mbFinished = true;
+ }
+ }
+ else
+ {
+ pPattern = mrDoc.GetPattern( nNewCol, nNewRow, mnStartTab );
+ if( pPattern && (pPattern != pLastPattern) )
+ {
+ pPattern->FillEditItemSet( pEditDefaults.get() );
+ SetDefaults( *pEditDefaults );
+ pLastPattern = pPattern;
+ }
+
+ // language changed?
+ const SfxPoolItem* pItem = mrDoc.GetAttr( nNewCol, nNewRow, mnStartTab, ATTR_FONT_LANGUAGE );
+ if( const SvxLanguageItem* pLangItem = PTR_CAST( SvxLanguageItem, pItem ) )
+ {
+ LanguageType eLang = static_cast< LanguageType >( pLangItem->GetValue() );
+ if( eLang == LANGUAGE_SYSTEM )
+ eLang = Application::GetSettings().GetLanguage(); // never use SYSTEM for spelling
+ if( eLang != meCurrLang )
+ {
+ meCurrLang = eLang;
+ SetDefaultLanguage( eLang );
+ }
+ }
+
+ FillFromCell( nNewCol, nNewRow, mnStartTab );
+
+ bFound = bLoop && NeedsConversion();
+ }
+ }
+ }
+
+ if( bFound )
+ {
+ pViewShell->AlignToCursor( nNewCol, nNewRow, SC_FOLLOW_JUMP );
+ pViewShell->SetCursor( nNewCol, nNewRow, TRUE );
+ mrViewData.GetView()->MakeEditView( this, nNewCol, nNewRow );
+ EditView* pEditView = mrViewData.GetSpellingView();
+ // maSelState.GetEditSelection() returns (0,0) if not in edit mode -> ok
+ pEditView->SetSelection( maSelState.GetEditSelection() );
+
+ ClearModifyFlag();
+ mnCurrCol = nNewCol;
+ mnCurrRow = nNewRow;
+ }
+
+ return bFound;
+}
+
+void ScConversionEngineBase::RestoreCursorPos()
+{
+ const ScAddress& rPos = maSelState.GetCellCursor();
+ mrViewData.GetViewShell()->SetCursor( rPos.Col(), rPos.Row() );
+}
+
+bool ScConversionEngineBase::ShowTableWrapDialog()
+{
+ // default: no dialog, always restart at top
+ return true;
+}
+
+void ScConversionEngineBase::ShowFinishDialog()
+{
+ // default: no dialog
+}
+
+// private --------------------------------------------------------------------
+
+void ScConversionEngineBase::FillFromCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
+{
+ CellType eCellType;
+ mrDoc.GetCellType( nCol, nRow, nTab, eCellType );
+
+ switch( eCellType )
+ {
+ case CELLTYPE_STRING:
+ {
+ String aText;
+ mrDoc.GetString( nCol, nRow, nTab, aText );
+ SetText( aText );
+ }
+ break;
+ case CELLTYPE_EDIT:
+ {
+ ScBaseCell* pCell = NULL;
+ mrDoc.GetCell( nCol, nRow, nTab, pCell );
+ if( pCell )
+ {
+ const EditTextObject* pNewEditObj = NULL;
+ static_cast< ScEditCell* >( pCell )->GetData( pNewEditObj );
+ if( pNewEditObj )
+ SetText( *pNewEditObj );
+ }
+ }
+ break;
+ default:
+ SetText( EMPTY_STRING );
+ }
+}
+
+// ============================================================================
+
+ScSpellingEngine::ScSpellingEngine(
+ SfxItemPool* pEnginePoolP, ScViewData& rViewData,
+ ScDocument* pUndoDoc, ScDocument* pRedoDoc,
+ XSpellCheckerRef xSpeller ) :
+ ScConversionEngineBase( pEnginePoolP, rViewData, pUndoDoc, pRedoDoc )
+{
+ SetSpeller( xSpeller );
+}
+
+void ScSpellingEngine::ConvertAll( EditView& rEditView )
+{
+ EESpellState eState = EE_SPELL_OK;
+ if( FindNextConversionCell() )
+ eState = rEditView.StartSpeller( static_cast< BOOL >( TRUE ) );
+
+ DBG_ASSERT( eState != EE_SPELL_NOSPELLER, "ScSpellingEngine::Convert - no spell checker" );
+ if( eState == EE_SPELL_NOLANGUAGE )
+ {
+ Window* pParent = GetDialogParent();
+ ScWaitCursorOff aWaitOff( pParent );
+ InfoBox( pParent, ScGlobal::GetRscString( STR_NOLANGERR ) ).Execute();
+ }
+}
+
+BOOL ScSpellingEngine::SpellNextDocument()
+{
+ return FindNextConversionCell();
+}
+
+bool ScSpellingEngine::NeedsConversion()
+{
+ return HasSpellErrors() != EE_SPELL_OK;
+}
+
+bool ScSpellingEngine::ShowTableWrapDialog()
+{
+ Window* pParent = GetDialogParent();
+ ScWaitCursorOff aWaitOff( pParent );
+ MessBox aMsgBox( pParent, WinBits( WB_YES_NO | WB_DEF_YES ),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
+ ScGlobal::GetRscString( STR_SPELLING_BEGIN_TAB) );
+ return aMsgBox.Execute() == RET_YES;
+}
+
+void ScSpellingEngine::ShowFinishDialog()
+{
+ Window* pParent = GetDialogParent();
+ ScWaitCursorOff aWaitOff( pParent );
+ InfoBox( pParent, ScGlobal::GetRscString( STR_SPELLING_STOP_OK ) ).Execute();
+}
+
+Window* ScSpellingEngine::GetDialogParent()
+{
+ USHORT nWinId = ScSpellDialogChildWindow::GetChildWindowId();
+ SfxViewFrame* pViewFrm = mrViewData.GetViewShell()->GetViewFrame();
+ if( pViewFrm->HasChildWindow( nWinId ) )
+ if( SfxChildWindow* pChild = pViewFrm->GetChildWindow( nWinId ) )
+ if( Window* pWin = pChild->GetWindow() )
+ if( pWin->IsVisible() )
+ return pWin;
+
+ // fall back to standard dialog parent
+ return mrDocShell.GetActiveDialogParent();
+}
+
+// ============================================================================
+
+ScConversionParam::ScConversionParam( ScConversionType eConvType ) :
+ meConvType( eConvType ),
+ meSourceLang( LANGUAGE_NONE ),
+ meTargetLang( LANGUAGE_NONE ),
+ mnOptions( 0 ),
+ mbUseTargetFont( false ),
+ mbIsInteractive( false )
+{
+}
+
+ScConversionParam::ScConversionParam( ScConversionType eConvType,
+ LanguageType eLang, sal_Int32 nOptions, bool bIsInteractive ) :
+ meConvType( eConvType ),
+ meSourceLang( eLang ),
+ meTargetLang( eLang ),
+ mnOptions( nOptions ),
+ mbUseTargetFont( false ),
+ mbIsInteractive( bIsInteractive )
+{
+ if (LANGUAGE_KOREAN == eLang)
+ mnOptions = i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+}
+
+ScConversionParam::ScConversionParam( ScConversionType eConvType,
+ LanguageType eSourceLang, LanguageType eTargetLang, const Font& rTargetFont,
+ sal_Int32 nOptions, bool bIsInteractive ) :
+ meConvType( eConvType ),
+ meSourceLang( eSourceLang ),
+ meTargetLang( eTargetLang ),
+ maTargetFont( rTargetFont ),
+ mnOptions( nOptions ),
+ mbUseTargetFont( true ),
+ mbIsInteractive( bIsInteractive )
+{
+ if (LANGUAGE_KOREAN == meSourceLang && LANGUAGE_KOREAN == meTargetLang)
+ mnOptions = i18n::TextConversionOption::CHARACTER_BY_CHARACTER;
+}
+
+// ----------------------------------------------------------------------------
+
+ScTextConversionEngine::ScTextConversionEngine(
+ SfxItemPool* pEnginePoolP, ScViewData& rViewData,
+ const ScConversionParam& rConvParam,
+ ScDocument* pUndoDoc, ScDocument* pRedoDoc ) :
+ ScConversionEngineBase( pEnginePoolP, rViewData, pUndoDoc, pRedoDoc ),
+ maConvParam( rConvParam )
+{
+}
+
+void ScTextConversionEngine::ConvertAll( EditView& rEditView )
+{
+ if( FindNextConversionCell() )
+ {
+ rEditView.StartTextConversion(
+ maConvParam.GetSourceLang(), maConvParam.GetTargetLang(), maConvParam.GetTargetFont(),
+ maConvParam.GetOptions(), maConvParam.IsInteractive(), TRUE );
+ // #i34769# restore initial cursor position
+ RestoreCursorPos();
+ }
+}
+
+BOOL ScTextConversionEngine::ConvertNextDocument()
+{
+ return FindNextConversionCell();
+}
+
+bool ScTextConversionEngine::NeedsConversion()
+{
+ return HasConvertibleTextPortion( maConvParam.GetSourceLang() );
+}
+
+// ============================================================================
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabcont.cxx b/sc/source/ui/view/tabcont.cxx
new file mode 100644
index 000000000000..14d0a334caaf
--- /dev/null
+++ b/sc/source/ui/view/tabcont.cxx
@@ -0,0 +1,665 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <vcl/sound.hxx>
+#include <tools/urlobj.hxx>
+#include <vcl/svapp.hxx>
+#include "tabcont.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "scresid.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "transobj.hxx"
+#include "clipparam.hxx"
+
+
+// STATIC DATA -----------------------------------------------------------
+
+//==================================================================
+
+ScTabControl::ScTabControl( Window* pParent, ScViewData* pData ) :
+ TabBar( pParent,
+ WinBits(WB_BORDER | WB_3DLOOK | WB_SCROLL | WB_RANGESELECT |
+ WB_MULTISELECT | WB_DRAG | WB_SIZEABLE) ),
+ DropTargetHelper( this ),
+ DragSourceHelper( this ),
+ pViewData( pData ),
+ nMouseClickPageId( TabBar::PAGE_NOT_FOUND ),
+ nSelPageIdByMouse( TabBar::PAGE_NOT_FOUND ),
+ bErrorShown( FALSE )
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ String aString;
+ Color aTabBgColor;
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nCount; i++)
+ {
+ if (pDoc->IsVisible(i))
+ {
+ if (pDoc->GetName(i,aString))
+ {
+ if ( pDoc->IsScenario(i) )
+ InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL );
+ else
+ InsertPage( static_cast<sal_uInt16>(i)+1, aString );
+ if ( !pDoc->IsDefaultTabBgColor(i) )
+ {
+ aTabBgColor = pDoc->GetTabBgColor(i);
+ SetTabBgColor( static_cast<sal_uInt16>(i)+1, aTabBgColor );
+ }
+ }
+ }
+ }
+
+ SetCurPageId( static_cast<sal_uInt16>(pViewData->GetTabNo()) + 1 );
+
+ SetSizePixel( Size(SC_TABBAR_DEFWIDTH, 0) );
+
+ SetSplitHdl( LINK( pViewData->GetView(), ScTabView, TabBarResize ) );
+
+ EnableEditMode();
+ UpdateInputContext();
+}
+
+ScTabControl::~ScTabControl()
+{
+}
+
+USHORT ScTabControl::GetMaxId() const
+{
+ USHORT nVisCnt = GetPageCount();
+ if (nVisCnt)
+ return GetPageId(nVisCnt-1);
+
+ return 0;
+}
+
+SCTAB ScTabControl::GetPrivatDropPos(const Point& rPos )
+{
+ USHORT nPos = ShowDropPos(rPos);
+
+ SCTAB nRealPos = static_cast<SCTAB>(nPos);
+
+ if(nPos !=0 )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ SCTAB nCount = pDoc->GetTableCount();
+
+ USHORT nViewPos=0;
+ nRealPos = nCount;
+ for (SCTAB i=0; i<nCount; i++)
+ {
+ if (pDoc->IsVisible(i))
+ {
+ nViewPos++;
+ if(nViewPos==nPos)
+ {
+ SCTAB j;
+ for (j=i+1; j<nCount; j++)
+ {
+ if (pDoc->IsVisible(j))
+ {
+ break;
+ }
+ }
+ nRealPos =j;
+ break;
+ }
+ }
+ }
+ }
+ return nRealPos ;
+}
+
+void ScTabControl::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ ScModule* pScMod = SC_MOD();
+ if ( !pScMod->IsModalMode() && !pScMod->IsFormulaMode() && !IsInEditMode() )
+ {
+ // View aktivieren
+ pViewData->GetViewShell()->SetActive(); // Appear und SetViewFrame
+ pViewData->GetView()->ActiveGrabFocus();
+ }
+
+ /* #47745# Click into free area -> insert new sheet (like in Draw).
+ Needing clean left click without modifiers (may be context menu).
+ #106948# Remember clicks to all pages, to be able to move mouse pointer later. */
+ if( rMEvt.IsLeft() && (rMEvt.GetModifier() == 0) )
+ nMouseClickPageId = GetPageId( rMEvt.GetPosPixel(), true );
+ else
+ nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
+
+ TabBar::MouseButtonDown( rMEvt );
+}
+
+void ScTabControl::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ Point aPos = PixelToLogic( rMEvt.GetPosPixel() );
+
+ // mouse button down and up on same page?
+ if( nMouseClickPageId != GetPageId( aPos, true ) )
+ nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
+
+ if (nMouseClickPageId == TabBar::INSERT_TAB_POS)
+ {
+ // Insert a new sheet at the right end, with default name.
+ ScDocument* pDoc = pViewData->GetDocument();
+ String aName;
+ pDoc->CreateValidTabName(aName);
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pViewData->GetViewShell()->InsertTable(aName, nTabCount);
+ return;
+ }
+
+ if ( rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && nMouseClickPageId != 0 && nMouseClickPageId != TAB_PAGE_NOTFOUND )
+ {
+ SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute( FID_TAB_MENU_RENAME, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ return;
+ }
+
+ if( nMouseClickPageId == 0 )
+ {
+ // Click in the area next to the existing tabs:
+ // #i70320# if several sheets are selected, deselect all ecxept the current sheet,
+ // otherwise add new sheet
+ USHORT nSlot = ( GetSelectPageCount() > 1 ) ? FID_TAB_DESELECTALL : FID_INS_TABLE;
+ SfxDispatcher* pDispatcher = pViewData->GetViewShell()->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute( nSlot, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ // forget page ID, to be really sure that the dialog is not called twice
+ nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
+ }
+
+ TabBar::MouseButtonUp( rMEvt );
+}
+
+void ScTabControl::Select()
+{
+ /* Remember last clicked page ID. */
+ nSelPageIdByMouse = nMouseClickPageId;
+ /* Reset nMouseClickPageId, so that next Select() call may invalidate
+ nSelPageIdByMouse (i.e. if called from keyboard). */
+ nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
+
+ ScModule* pScMod = SC_MOD();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nCount = pDoc->GetTableCount();
+ SCTAB i;
+
+ if ( pScMod->IsTableLocked() ) // darf jetzt nicht umgeschaltet werden ?
+ {
+ // den alten Zustand des TabControls wiederherstellen:
+
+ for (i=0; i<nCount; i++)
+ SelectPage( static_cast<sal_uInt16>(i)+1, rMark.GetTableSelect(i) );
+ SetCurPageId( static_cast<sal_uInt16>(pViewData->GetTabNo()) + 1 );
+
+ Sound::Beep();
+ return;
+ }
+
+ USHORT nCurId = GetCurPageId();
+ if (!nCurId) return; // kann vorkommen, wenn bei Excel-Import alles versteckt ist
+ USHORT nPage = nCurId - 1;
+
+ // OLE-inplace deaktivieren
+ if ( nPage != static_cast<sal_uInt16>(pViewData->GetTabNo()) )
+ pViewData->GetView()->DrawMarkListHasChanged();
+
+ // InputEnterHandler nur wenn nicht Referenzeingabe
+
+ BOOL bRefMode = pScMod->IsFormulaMode();
+ if (!bRefMode)
+ pScMod->InputEnterHandler();
+
+ for (i=0; i<nCount; i++)
+ rMark.SelectTable( i, IsPageSelected(static_cast<sal_uInt16>(i)+1) );
+
+/* Markierungen werden per Default nicht pro Tabelle gehalten
+ USHORT nSelCnt = GetSelectPageCount();
+ if (nSelCnt>1)
+ pDoc->ExtendMarksFromTable( nPage );
+*/
+
+ SfxDispatcher& rDisp = pViewData->GetDispatcher();
+ if (rDisp.IsLocked())
+ pViewData->GetView()->SetTabNo( static_cast<SCTAB>(nPage) );
+ else
+ {
+ // Tabelle fuer Basic ist 1-basiert
+ SfxUInt16Item aItem( SID_CURRENTTAB, nPage + 1 );
+ rDisp.Execute( SID_CURRENTTAB, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD,
+ &aItem, (void*) NULL );
+ }
+
+ SfxBindings& rBind = pViewData->GetBindings();
+ rBind.Invalidate( FID_FILL_TAB );
+ rBind.Invalidate( FID_TAB_DESELECTALL );
+
+ rBind.Invalidate( FID_INS_TABLE );
+ rBind.Invalidate( FID_TAB_APPEND );
+ rBind.Invalidate( FID_TAB_MOVE );
+ rBind.Invalidate( FID_TAB_RENAME );
+ rBind.Invalidate( FID_DELETE_TABLE );
+ rBind.Invalidate( FID_TABLE_SHOW );
+ rBind.Invalidate( FID_TABLE_HIDE );
+ rBind.Invalidate( FID_TAB_SET_TAB_BG_COLOR );
+
+ // SetReference nur wenn der Konsolidieren-Dialog offen ist
+ // (fuer Referenzen ueber mehrere Tabellen)
+ // bei anderen gibt das nur unnoetiges Gezappel
+
+ if ( bRefMode && pViewData->GetRefType() == SC_REFTYPE_REF )
+ if ( pViewData->GetViewShell()->GetViewFrame()->HasChildWindow(SID_OPENDLG_CONSOLIDATE) )
+ {
+ ScRange aRange(
+ pViewData->GetRefStartX(), pViewData->GetRefStartY(), pViewData->GetRefStartZ(),
+ pViewData->GetRefEndX(), pViewData->GetRefEndY(), pViewData->GetRefEndZ() );
+ pScMod->SetReference( aRange, pDoc, &rMark );
+ pScMod->EndReference(); // wegen Auto-Hide
+ }
+}
+
+void ScTabControl::UpdateInputContext()
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ WinBits nStyle = GetStyle();
+ if (pDoc->GetDocumentShell()->IsReadOnly())
+ // no insert sheet tab for readonly doc.
+ SetStyle((nStyle & ~WB_INSERTTAB));
+ else
+ SetStyle((nStyle | WB_INSERTTAB));
+}
+
+void ScTabControl::UpdateStatus()
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ BOOL bActive = pViewData->IsActive();
+
+ SCTAB nCount = pDoc->GetTableCount();
+ SCTAB i;
+ String aString;
+ SCTAB nMaxCnt = Max( nCount, static_cast<SCTAB>(GetMaxId()) );
+ Color aTabBgColor;
+
+ BOOL bModified = FALSE; // Tabellen-Namen
+ for (i=0; i<nMaxCnt && !bModified; i++)
+ {
+ if (pDoc->IsVisible(i))
+ {
+ pDoc->GetName(i,aString);
+ aTabBgColor = pDoc->GetTabBgColor(i);
+ }
+ else
+ {
+ aString.Erase();
+ }
+
+ if ( (GetPageText(static_cast<sal_uInt16>(i)+1) != aString) || (GetTabBgColor(static_cast<sal_uInt16>(i)+1) != aTabBgColor) )
+ bModified = TRUE;
+ }
+
+ if (bModified)
+ {
+ Clear();
+ for (i=0; i<nCount; i++)
+ {
+ if (pDoc->IsVisible(i))
+ {
+ if (pDoc->GetName(i,aString))
+ {
+ if ( pDoc->IsScenario(i) )
+ InsertPage( static_cast<sal_uInt16>(i)+1, aString, TPB_SPECIAL );
+ else
+ InsertPage( static_cast<sal_uInt16>(i)+1, aString );
+ if ( !pDoc->IsDefaultTabBgColor(i) )
+ {
+ aTabBgColor = pDoc->GetTabBgColor(i);
+ SetTabBgColor( static_cast<sal_uInt16>(i)+1, aTabBgColor );
+ }
+ }
+ }
+ }
+ }
+ SetCurPageId( static_cast<sal_uInt16>(pViewData->GetTabNo()) + 1 );
+
+ if (bActive)
+ {
+ bModified = FALSE; // Selektion
+ for (i=0; i<nMaxCnt && !bModified; i++)
+ if ( rMark.GetTableSelect(i) != IsPageSelected(static_cast<sal_uInt16>(i)+1) )
+ bModified = TRUE;
+
+ // #i99576# the following loop is mis-optimized on unxsoli4 and the reason
+ // why this file is in NOOPTFILES.
+ if ( bModified )
+ for (i=0; i<nCount; i++)
+ SelectPage( static_cast<sal_uInt16>(i)+1, rMark.GetTableSelect(i) );
+ }
+ else
+ {
+ }
+}
+
+void ScTabControl::ActivateView(BOOL bActivate)
+{
+// ScDocument* pDoc = pViewData->GetDocument();
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+// ResetMark direkt in TabView
+// pDoc->ResetMark();
+
+ USHORT nCurId = GetCurPageId();
+ if (!nCurId) return; // kann vorkommen, wenn bei Excel-Import alles versteckt ist
+ USHORT nPage = nCurId - 1;
+// USHORT nCount = GetMaxId();
+
+ /*
+ USHORT i;
+ for (i=0; i<nCount; i++)
+ {
+ SelectPage( i+1, FALSE );
+ if (bActivate)
+ rMark.SelectTable( i, FALSE );
+ }
+ */
+ if (bActivate)
+ {
+ SelectPage( nPage+1, TRUE );
+ rMark.SelectTable( static_cast<SCTAB>(nPage), TRUE );
+ }
+ Invalidate();
+}
+
+void ScTabControl::SetSheetLayoutRTL( BOOL bSheetRTL )
+{
+ SetEffectiveRTL( bSheetRTL );
+ nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND;
+}
+
+
+void ScTabControl::Command( const CommandEvent& rCEvt )
+{
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+ BOOL bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode();
+
+ // ViewFrame erstmal aktivieren (Bug 19493):
+ pViewSh->SetActive();
+
+ USHORT nCmd = rCEvt.GetCommand();
+ if ( nCmd == COMMAND_CONTEXTMENU )
+ {
+ if (!bDisable)
+ {
+ // #i18735# select the page that is under the mouse cursor
+ // if multiple tables are selected and the one under the cursor
+ // is not part of them then unselect them
+ USHORT nId = GetPageId( rCEvt.GetMousePosPixel() );
+ if (nId)
+ {
+ BOOL bAlreadySelected = IsPageSelected( nId );
+ //make the clicked page the current one
+ SetCurPageId( nId );
+ //change the selection when the current one is not already
+ //selected or part of a multi selection
+ if(!bAlreadySelected)
+ {
+ USHORT nCount = GetMaxId();
+
+ for (USHORT i=1; i<=nCount; i++)
+ SelectPage( i, i==nId );
+ Select();
+ }
+ }
+
+ // #i52073# OLE inplace editing has to be stopped before showing the sheet tab context menu
+ pViewSh->DeactivateOle();
+
+ // Popup-Menu:
+ // get Dispatcher from ViewData (ViewFrame) instead of Shell (Frame), so it can't be null
+ pViewData->GetDispatcher().ExecutePopup( ScResId(RID_POPUP_TAB) );
+ }
+ }
+}
+
+void ScTabControl::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel )
+{
+ ScModule* pScMod = SC_MOD();
+ BOOL bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode();
+
+ if (!bDisable)
+ {
+ Region aRegion( Rectangle(0,0,0,0) );
+ CommandEvent aCEvt( rPosPixel, COMMAND_STARTDRAG, TRUE ); // needed for StartDrag
+ if (TabBar::StartDrag( aCEvt, aRegion ))
+ DoDrag( aRegion );
+ }
+}
+
+void ScTabControl::DoDrag( const Region& /* rRegion */ )
+{
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ SCTAB nTab = pViewData->GetTabNo();
+ ScMarkData aTabMark = pViewData->GetMarkData();
+ aTabMark.ResetMark(); // doesn't change marked table information
+ aTabMark.SetMarkArea( ScRange(0,0,nTab,MAXCOL,MAXROW,nTab) );
+
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ ScClipParam aClipParam(ScRange(0, 0, 0, MAXCOL, MAXROW, 0), false);
+ pDoc->CopyToClip(aClipParam, pClipDoc, &aTabMark, false);
+
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScTransferObj ctor
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ com::sun::star::uno::Reference<com::sun::star::datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ pTransferObj->SetDragSourceFlags( SC_DROP_TABLE );
+
+ pTransferObj->SetDragSource( pDocSh, aTabMark );
+
+ Window* pWindow = pViewData->GetActiveWin();
+ SC_MOD()->SetDragObject( pTransferObj, NULL ); // for internal D&D
+ pTransferObj->StartDrag( pWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+}
+
+USHORT lcl_DocShellNr( ScDocument* pDoc )
+{
+ USHORT nShellCnt = 0;
+ SfxObjectShell* pShell = SfxObjectShell::GetFirst();
+ while ( pShell )
+ {
+ if ( pShell->Type() == TYPE(ScDocShell) )
+ {
+ if ( ((ScDocShell*)pShell)->GetDocument() == pDoc )
+ return nShellCnt;
+
+ ++nShellCnt;
+ }
+ pShell = SfxObjectShell::GetNext( *pShell );
+ }
+
+ DBG_ERROR("Dokument nicht gefunden");
+ return 0;
+}
+
+sal_Int8 ScTabControl::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ EndSwitchPage();
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ const ScDragData& rData = SC_MOD()->GetDragData();
+ if ( rData.pCellTransfer && ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) &&
+ rData.pCellTransfer->GetSourceDocument() == pDoc )
+ {
+ // moving of tables within the document
+ SCTAB nPos = GetPrivatDropPos( rEvt.maPosPixel );
+ HideDropPos();
+
+ if ( nPos == rData.pCellTransfer->GetVisibleTab() && rEvt.mnAction == DND_ACTION_MOVE )
+ {
+ // #i83005# do nothing - don't move to the same position
+ // (too easily triggered unintentionally, and might take a long time in large documents)
+ }
+ else
+ {
+ if ( !pDoc->GetChangeTrack() && pDoc->IsDocEditable() )
+ {
+ //! use table selection from the tab control where dragging was started?
+ pViewData->GetView()->MoveTable( lcl_DocShellNr(pDoc), nPos, rEvt.mnAction != DND_ACTION_MOVE );
+
+ rData.pCellTransfer->SetDragWasInternal(); // don't delete
+ return TRUE;
+ }
+ else
+ Sound::Beep();
+ }
+ }
+
+ return 0;
+}
+
+sal_Int8 ScTabControl::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ if ( rEvt.mbLeaving )
+ {
+ EndSwitchPage();
+ HideDropPos();
+ return rEvt.mnAction;
+ }
+
+ const ScDocument* pDoc = pViewData->GetDocument();
+ const ScDragData& rData = SC_MOD()->GetDragData();
+ if ( rData.pCellTransfer && ( rData.pCellTransfer->GetDragSourceFlags() & SC_DROP_TABLE ) &&
+ rData.pCellTransfer->GetSourceDocument() == pDoc )
+ {
+ // moving of tables within the document
+ if ( !pDoc->GetChangeTrack() && pDoc->IsDocEditable() )
+ {
+ ShowDropPos( rEvt.maPosPixel );
+ return rEvt.mnAction;
+ }
+ }
+ else // switch sheets for all formats
+ {
+ SwitchPage( rEvt.maPosPixel ); // switch sheet after timeout
+ return 0; // nothing can be dropped here
+ }
+
+ return 0;
+}
+
+long ScTabControl::StartRenaming()
+{
+ if ( pViewData->GetDocument()->IsDocEditable() )
+ return TABBAR_RENAMING_YES;
+ else
+ return TABBAR_RENAMING_NO;
+}
+
+long ScTabControl::AllowRenaming()
+{
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+ DBG_ASSERT( pViewSh, "pViewData->GetViewShell()" );
+
+ long nRet = TABBAR_RENAMING_CANCEL;
+ USHORT nId = GetEditPageId();
+ if ( nId )
+ {
+ SCTAB nTab = nId - 1;
+ String aNewName = GetEditText();
+ BOOL bDone = pViewSh->RenameTable( aNewName, nTab );
+ if ( bDone )
+ nRet = TABBAR_RENAMING_YES;
+ else if ( bErrorShown )
+ {
+ // if the error message from this TabControl is currently visible,
+ // don't end edit mode now, to avoid problems when returning to
+ // the other call (showing the error) - this should not happen
+ DBG_ERROR("ScTabControl::AllowRenaming: nested calls");
+ nRet = TABBAR_RENAMING_NO;
+ }
+ else if ( Application::IsInModalMode() )
+ {
+ // #73472# don't show error message above any modal dialog
+ // instead cancel renaming without error message
+ nRet = TABBAR_RENAMING_CANCEL;
+ }
+ else
+ {
+ bErrorShown = TRUE;
+ pViewSh->ErrorMessage( STR_INVALIDTABNAME );
+ bErrorShown = FALSE;
+ nRet = TABBAR_RENAMING_NO;
+ }
+ }
+ return nRet;
+}
+
+void ScTabControl::EndRenaming()
+{
+ if ( HasFocus() )
+ pViewData->GetView()->ActiveGrabFocus();
+}
+
+void ScTabControl::Mirror()
+{
+ TabBar::Mirror();
+ if( nSelPageIdByMouse != TabBar::PAGE_NOT_FOUND )
+ {
+ Rectangle aRect( GetPageRect( GetCurPageId() ) );
+ if( !aRect.IsEmpty() )
+ SetPointerPosPixel( aRect.Center() );
+ nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND; // only once after a Select()
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabpopsh.cxx b/sc/source/ui/view/tabpopsh.cxx
new file mode 100644
index 000000000000..7974bb8acbf4
--- /dev/null
+++ b/sc/source/ui/view/tabpopsh.cxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+#include "tabpopsh.hxx"
+#include "sc.hrc"
+
+#undef ShellClass
+#define ShellClass ScTabPopShell
+SFX_SLOTMAP(ScTabPopShell)
+{
+ SFX_SLOT( 0,0, DummyExec, DummyState, 0, SfxVoidItem )
+};
+
+
+TYPEINIT1(ScTabPopShell,SfxShell);
+
+//SFX_IMPL_IDL_INTERFACE(ScTabPopShell, SfxShell, 0)
+SFX_IMPL_INTERFACE(ScTabPopShell, SfxShell, ResId( 0, NULL))
+{
+ SFX_POPUPMENU_REGISTRATION( RID_POPUP_TAB );
+}
+
+
+
+
+ScTabPopShell::ScTabPopShell(SfxItemPool& rItemPool)
+{
+ SetPool( &rItemPool );
+}
+
+
+ScTabPopShell::~ScTabPopShell()
+{
+}
+
+
+void ScTabPopShell::DummyExec( SfxRequest& rReq )
+{
+}
+
+
+void ScTabPopShell::DummyState( SfxItemSet& rSet )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabsplit.cxx b/sc/source/ui/view/tabsplit.cxx
new file mode 100644
index 000000000000..eda248c8fcb0
--- /dev/null
+++ b/sc/source/ui/view/tabsplit.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "tabsplit.hxx"
+#include "viewdata.hxx"
+#include "dbfunc.hxx"
+
+//==================================================================
+
+ScTabSplitter::ScTabSplitter( Window* pParent, WinBits nWinStyle, ScViewData* pData ) :
+ Splitter( pParent, nWinStyle ),
+ pViewData(pData)
+{
+ SetFixed(FALSE);
+ EnableRTL( FALSE );
+}
+
+
+ScTabSplitter::~ScTabSplitter()
+{
+}
+
+void __EXPORT ScTabSplitter::MouseMove( const MouseEvent& rMEvt )
+{
+ if (bFixed)
+ Window::MouseMove( rMEvt );
+ else
+ Splitter::MouseMove( rMEvt );
+}
+
+void __EXPORT ScTabSplitter::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if (bFixed)
+ Window::MouseButtonUp( rMEvt );
+ else
+ Splitter::MouseButtonUp( rMEvt );
+}
+
+void __EXPORT ScTabSplitter::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if (bFixed)
+ Window::MouseButtonDown( rMEvt );
+ else
+ Splitter::MouseButtonDown( rMEvt );
+}
+
+void __EXPORT ScTabSplitter::Splitting( Point& rSplitPos )
+{
+ Window* pParent = GetParent();
+ Point aScreenPos = pParent->OutputToNormalizedScreenPixel( rSplitPos );
+ pViewData->GetView()->SnapSplitPos( aScreenPos );
+ Point aNew = pParent->NormalizedScreenToOutputPixel( aScreenPos );
+ if ( IsHorizontal() )
+ rSplitPos.X() = aNew.X();
+ else
+ rSplitPos.Y() = aNew.Y();
+}
+
+
+void ScTabSplitter::SetFixed(BOOL bSet)
+{
+ bFixed = bSet;
+ if (bSet)
+ SetPointer(POINTER_ARROW);
+ else if (IsHorizontal())
+ SetPointer(POINTER_HSPLIT);
+ else
+ SetPointer(POINTER_VSPLIT);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
new file mode 100644
index 000000000000..d465f80ac9db
--- /dev/null
+++ b/sc/source/ui/view/tabview.cxx
@@ -0,0 +1,2457 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+//------------------------------------------------------------------
+#include <vcl/svapp.hxx>
+
+///////////////////////////////////////////////////////////////////////////
+// NODRAW.HXX
+// Erweiterte Konstanten, um CLOKs mit SVDRAW.HXX zu vermeiden
+// Die u.a. Aenderungen nehmen vorgeschlagene Konstante vorweg
+///////////////////////////////////////////////////////////////////////////
+
+// Dieses define entfernt die VCControls aus SI.HXX
+
+#define _SI_HXX // VCControls
+
+////////////////////// Umsetzen der Standard-Defines //////////////////////
+
+//#define _SVDDRAG_HXX // SdrDragStat
+#define _SVDPAGE_HXX // SdrPage
+
+#ifdef _SDR_NOSURROGATEOBJ
+ #undef _SDR_NOSURROGATEOBJ
+ #define _SVDSURO_HXX
+#endif
+
+#ifdef _SDR_NOPAGEOBJ
+ #undef _SDR_NOPAGEOBJ
+ #define _SVDOPAGE_HXX
+#endif
+
+#ifdef _SDR_NOVIRTOBJ
+ #undef _SDR_NOVIRTOBJ
+ #define _SVDOVIRT_HXX
+#endif
+
+#ifdef _SDR_NOGROUPOBJ
+ #undef _SDR_NOGROUPOBJ
+ #define _SVDOGRP_HXX
+#endif
+
+#ifdef _SDR_NOTEXTOBJ
+ #undef _SDR_NOTEXTOBJ
+ #define _SVDOTEXT_HXX
+#endif
+
+#ifdef _SDR_NOPATHOBJ
+ #undef _SDR_NOPATHOBJ
+ #define _SVDOPATH_HXX
+#endif
+
+#ifdef _SDR_NOEDGEOBJ
+ #undef _SDR_NOEDGEOBJ
+ #define _SVDOEDGE_HXX
+#endif
+
+#ifdef _SDR_NORECTOBJ
+ #undef _SDR_NORECTOBJ
+ #define _SVDORECT_HXX
+#else
+ #undef _SDVOTEXT_OBJ
+#endif
+
+#ifdef _SDR_NOCAPTIONOBJ
+ #undef _SDR_NOCAPTIONOBJ
+ #define _SVDCAPT_HXX
+#endif
+
+#ifdef _SDR_NOCIRCLEOBJ
+ #undef _SDR_NOCIRCLEOBJ
+ #define _SVDOCIRC_HXX
+#endif
+
+#ifdef _SDR_NOGRAFOBJ
+ #undef _SDR_NOGRAFOBJ
+ #define _SVDOGRAF_HXX
+#else
+ #undef _SVDOTEXT_HXX
+ #undef _SVDORECT_HXX
+#endif
+
+#ifdef _SDR_NOOLE2OBJ
+ #undef _SDR_NOOLE2OBJ
+ #define _SVDOOLE2_HXX
+#else
+ #undef _SVDOTEXT_HXX
+ #undef _SVDORECT_HXX
+#endif
+
+//#ifdef _SDR_NOVIEWS
+// #define _SVDDRAG_HXX
+//#endif
+
+////////////////////// Ende der SVDRAW-Modifikationen /////////////////////
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <vcl/help.hxx>
+#include <rtl/logfile.hxx>
+
+#include "tabview.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "gridwin.hxx"
+#include "olinewin.hxx"
+#include "olinetab.hxx"
+#include "tabsplit.hxx"
+#include "colrowba.hxx"
+#include "tabcont.hxx"
+#include "scmod.hxx"
+#include "sc.hrc"
+#include "viewutil.hxx"
+#include "globstr.hrc"
+#include "drawview.hxx"
+#include "docsh.hxx"
+#include "viewuno.hxx"
+#include "AccessibilityHints.hxx"
+#include "appoptio.hxx"
+
+#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp>
+
+#include <string>
+#include <algorithm>
+
+#define SPLIT_MARGIN 30
+#define SC_ICONSIZE 36
+
+#define SC_SCROLLBAR_MIN 30
+#define SC_TABBAR_MIN 6
+
+// fuer Rad-Maus
+#define SC_DELTA_ZOOM 10
+
+using namespace ::com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+
+//==================================================================
+
+// Corner-Button
+
+ScCornerButton::ScCornerButton( Window* pParent, ScViewData* pData, BOOL bAdditional ) :
+ Window( pParent, WinBits( 0 ) ),
+ pViewData( pData ),
+ bAdd( bAdditional )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SetBackground( rStyleSettings.GetFaceColor() );
+ EnableRTL( FALSE );
+}
+
+__EXPORT ScCornerButton::~ScCornerButton()
+{
+}
+
+void __EXPORT ScCornerButton::Paint( const Rectangle& rRect )
+{
+ Size aSize = GetOutputSizePixel();
+ long nPosX = aSize.Width()-1;
+ long nPosY = aSize.Height()-1;
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ Window::Paint(rRect);
+
+ BOOL bLayoutRTL = pViewData->GetDocument()->IsLayoutRTL( pViewData->GetTabNo() );
+ long nDarkX = bLayoutRTL ? 0 : nPosX;
+
+ if ( !bAdd && !rStyleSettings.GetHighContrastMode() )
+ {
+ // match the shaded look of column/row headers
+
+ Color aFace( rStyleSettings.GetFaceColor() );
+ Color aWhite( COL_WHITE );
+ Color aCenter( aFace );
+ aCenter.Merge( aWhite, 0xd0 ); // lighten up a bit
+ Color aOuter( aFace );
+ aOuter.Merge( aWhite, 0xa0 ); // lighten up more
+
+ long nCenterX = (aSize.Width() / 2) - 1;
+ long nCenterY = (aSize.Height() / 2) - 1;
+
+ SetLineColor();
+ SetFillColor(aCenter);
+ DrawRect( Rectangle( nCenterX, nCenterY, nCenterX, nPosY ) );
+ DrawRect( Rectangle( nCenterX, nCenterY, nDarkX, nCenterY ) );
+ SetFillColor(aOuter);
+ DrawRect( Rectangle( 0, 0, nPosX, nCenterY-1 ) );
+ if ( bLayoutRTL )
+ DrawRect( Rectangle( nCenterX+1, nCenterY, nPosX, nPosY ) );
+ else
+ DrawRect( Rectangle( 0, nCenterY, nCenterX-1, nPosY ) );
+ }
+
+ // both buttons have the same look now - only dark right/bottom lines
+ SetLineColor( rStyleSettings.GetDarkShadowColor() );
+ DrawLine( Point(0,nPosY), Point(nPosX,nPosY) );
+ DrawLine( Point(nDarkX,0), Point(nDarkX,nPosY) );
+}
+
+void ScCornerButton::StateChanged( StateChangedType nType )
+{
+ Window::StateChanged( nType );
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SetBackground( rStyleSettings.GetFaceColor() );
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void ScCornerButton::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ Window::DataChanged( rDCEvt );
+
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SetBackground( rStyleSettings.GetFaceColor() );
+ Invalidate();
+}
+
+
+void __EXPORT ScCornerButton::Resize()
+{
+ Invalidate();
+}
+
+void __EXPORT ScCornerButton::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ ScModule* pScMod = SC_MOD();
+ BOOL bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode();
+ if (!bDisable)
+ {
+ ScTabViewShell* pViewSh = pViewData->GetViewShell();
+ pViewSh->SetActive(); // Appear und SetViewFrame
+ pViewSh->ActiveGrabFocus();
+
+ BOOL bControl = rMEvt.IsMod1();
+ pViewSh->SelectAll( bControl );
+ }
+}
+
+//==================================================================
+
+BOOL lcl_HasColOutline( const ScViewData& rViewData )
+{
+ const ScOutlineTable* pTable = rViewData.GetDocument()->GetOutlineTable(rViewData.GetTabNo());
+ if (pTable)
+ {
+ const ScOutlineArray* pArray = pTable->GetColArray();
+ if ( pArray->GetDepth() > 0 )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL lcl_HasRowOutline( const ScViewData& rViewData )
+{
+ const ScOutlineTable* pTable = rViewData.GetDocument()->GetOutlineTable(rViewData.GetTabNo());
+ if (pTable)
+ {
+ const ScOutlineArray* pArray = pTable->GetRowArray();
+ if ( pArray->GetDepth() > 0 )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//==================================================================
+
+// Init und Konstruktoren
+// ScTabView::Init() in tabview5.cxx wegen out of keys
+
+
+#define TABVIEW_INIT \
+ pSelEngine( NULL ), \
+ aFunctionSet( &aViewData ), \
+ pHdrSelEng( NULL ), \
+ aHdrFunc( &aViewData ), \
+ pDrawView( NULL ), \
+ bDrawSelMode( FALSE ), \
+ aVScrollTop( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ), \
+ aVScrollBottom( pFrameWin, WinBits( WB_VSCROLL | WB_DRAG ) ), \
+ aHScrollLeft( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ), \
+ aHScrollRight( pFrameWin, WinBits( WB_HSCROLL | WB_DRAG ) ), \
+ aCornerButton( pFrameWin, &aViewData, FALSE ), \
+ aTopButton( pFrameWin, &aViewData, TRUE ), \
+ aScrollBarBox( pFrameWin, WB_SIZEABLE ), \
+ pInputHintWindow( NULL ), \
+ pPageBreakData( NULL ), \
+ pHighlightRanges( NULL ), \
+ pBrushDocument( NULL ), \
+ pDrawBrushSet( NULL ), \
+ bLockPaintBrush( FALSE ), \
+ pTimerWindow( NULL ), \
+ nTipVisible( 0 ), \
+ bDragging( FALSE ), \
+ bIsBlockMode( FALSE ), \
+ bBlockNeg( FALSE ), \
+ bBlockCols( FALSE ), \
+ bBlockRows( FALSE ), \
+ mfPendingTabBarWidth( -1.0 ), \
+ bMinimized( FALSE ), \
+ bInUpdateHeader( FALSE ), \
+ bInActivatePart( FALSE ), \
+ bInZoomUpdate( FALSE ), \
+ bMoveIsShift( FALSE )
+
+
+ScTabView::ScTabView( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
+ pFrameWin( pParent ),
+ aViewData( &rDocSh, pViewShell ),
+ TABVIEW_INIT
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScTabView::ScTabView" );
+
+ Init();
+}
+
+
+void ScTabView::InitScrollBar( ScrollBar& rScrollBar, long nMaxVal )
+{
+ rScrollBar.SetRange( Range( 0, nMaxVal ) );
+ rScrollBar.SetLineSize( 1 );
+ rScrollBar.SetPageSize( 1 ); // wird getrennt abgefragt
+ rScrollBar.SetVisibleSize( 10 ); // wird bei Resize neu gesetzt
+
+ rScrollBar.SetScrollHdl( LINK(this, ScTabView, ScrollHdl) );
+ rScrollBar.SetEndScrollHdl( LINK(this, ScTabView, EndScrollHdl) );
+}
+
+// Scroll-Timer
+
+void ScTabView::SetTimer( ScGridWindow* pWin, const MouseEvent& rMEvt )
+{
+ pTimerWindow = pWin;
+ aTimerMEvt = rMEvt;
+ aScrollTimer.Start();
+}
+
+void ScTabView::ResetTimer()
+{
+ aScrollTimer.Stop();
+ pTimerWindow = NULL;
+}
+
+IMPL_LINK( ScTabView, TimerHdl, Timer*, EMPTYARG )
+{
+// aScrollTimer.Stop();
+ if (pTimerWindow)
+ pTimerWindow->MouseMove( aTimerMEvt );
+
+ return 0;
+}
+
+// --- Resize ---------------------------------------------------------------------
+
+void lcl_SetPosSize( Window& rWindow, const Point& rPos, const Size& rSize,
+ long nTotalWidth, BOOL bLayoutRTL )
+{
+ Point aNewPos = rPos;
+ if ( bLayoutRTL )
+ {
+ aNewPos.X() = nTotalWidth - rPos.X() - rSize.Width();
+ if ( aNewPos == rWindow.GetPosPixel() && rSize.Width() != rWindow.GetSizePixel().Width() )
+ {
+ // Document windows are manually painted right-to-left, so they need to
+ // be repainted if the size changes.
+ rWindow.Invalidate();
+ }
+ }
+ rWindow.SetPosSizePixel( aNewPos, rSize );
+}
+
+void ScTabView::DoResize( const Point& rOffset, const Size& rSize, BOOL bInner )
+{
+ HideListBox();
+
+ BOOL bHasHint = ( pInputHintWindow != NULL );
+ if (bHasHint)
+ RemoveHintWindow();
+
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+ long nTotalWidth = rSize.Width();
+ if ( bLayoutRTL )
+ nTotalWidth += 2*rOffset.X();
+
+ BOOL bVScroll = aViewData.IsVScrollMode();
+ BOOL bHScroll = aViewData.IsHScrollMode();
+ BOOL bTabControl = aViewData.IsTabMode();
+ BOOL bHeaders = aViewData.IsHeaderMode();
+ BOOL bOutlMode = aViewData.IsOutlineMode();
+ BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
+ BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
+
+ // Scrollbar-Einstellungen koennen vom Sfx ueberschrieben werden:
+ SfxScrollingMode eMode = aViewData.GetViewShell()->GetScrollingMode();
+ if ( eMode == SCROLLING_NO )
+ bHScroll = bVScroll = FALSE;
+ else if ( eMode == SCROLLING_YES || eMode == SCROLLING_AUTO ) //! Auto ???
+ bHScroll = bVScroll = TRUE;
+
+ if ( aViewData.GetDocShell()->IsPreview() )
+ bHScroll = bVScroll = bTabControl = bHeaders = bOutlMode = bHOutline = bVOutline = FALSE;
+
+ long nBarX = 0;
+ long nBarY = 0;
+ long nOutlineX = 0;
+ long nOutlineY = 0;
+ long nOutPosX;
+ long nOutPosY;
+
+ long nPosX = rOffset.X();
+ long nPosY = rOffset.Y();
+ long nSizeX = rSize.Width();
+ long nSizeY = rSize.Height();
+ long nSize1;
+
+ bMinimized = ( nSizeX<=SC_ICONSIZE || nSizeY<=SC_ICONSIZE );
+ if ( bMinimized )
+ return;
+
+ long nSplitSizeX = SPLIT_HANDLE_SIZE;
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ nSplitSizeX = 1;
+ long nSplitSizeY = SPLIT_HANDLE_SIZE;
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ nSplitSizeY = 1;
+
+ const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel();
+
+ aBorderPos = rOffset;
+ aFrameSize = rSize;
+
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
+ if ( aViewData.GetHSplitPos() > nSizeX - SPLIT_MARGIN )
+ {
+ aViewData.SetHSplitMode( SC_SPLIT_NONE );
+ if ( WhichH( aViewData.GetActivePart() ) == SC_SPLIT_RIGHT )
+ ActivatePart( SC_SPLIT_BOTTOMLEFT );
+ InvalidateSplit();
+// UpdateShow();
+ }
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ if ( aViewData.GetVSplitPos() > nSizeY - SPLIT_MARGIN )
+ {
+ aViewData.SetVSplitMode( SC_SPLIT_NONE );
+ if ( WhichV( aViewData.GetActivePart() ) == SC_SPLIT_TOP )
+ ActivatePart( SC_SPLIT_BOTTOMLEFT );
+ InvalidateSplit();
+// UpdateShow();
+ }
+
+ UpdateShow();
+
+ if (bHScroll || bVScroll) // Scrollbars horizontal oder vertikal
+ {
+ long nScrollBarSize = pFrameWin->GetSettings().GetStyleSettings().GetScrollBarSize();
+ if (bVScroll)
+ {
+// nBarX = aVScrollBottom.GetSizePixel().Width();
+ nBarX = nScrollBarSize;
+ nSizeX -= nBarX - nOverlap;
+ }
+ if (bHScroll)
+ {
+// nBarY = aHScrollLeft.GetSizePixel().Height();
+ nBarY = nScrollBarSize;
+ nSizeY -= nBarY - nOverlap;
+ }
+
+ // window at the bottom right
+ lcl_SetPosSize( aScrollBarBox, Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ),
+ nTotalWidth, bLayoutRTL );
+
+ if (bHScroll) // Scrollbars horizontal
+ {
+ long nSizeLt = 0; // left scroll bar
+ long nSizeRt = 0; // right scroll bar
+ long nSizeSp = 0; // splitter
+
+ switch (aViewData.GetHSplitMode())
+ {
+ case SC_SPLIT_NONE:
+ nSizeSp = nSplitSizeX;
+ nSizeLt = nSizeX - nSizeSp + nOverlap; // Ecke ueberdecken
+ break;
+ case SC_SPLIT_NORMAL:
+ nSizeSp = nSplitSizeX;
+ nSizeLt = aViewData.GetHSplitPos();
+ break;
+ case SC_SPLIT_FIX:
+ nSizeSp = 0;
+ nSizeLt = 0;
+ break;
+ }
+ nSizeRt = nSizeX - nSizeLt - nSizeSp;
+
+ long nTabSize = 0;
+ if (bTabControl)
+ {
+ // pending relative tab bar width from extended document options
+ if( mfPendingTabBarWidth >= 0.0 )
+ {
+ SetRelTabBarWidth( mfPendingTabBarWidth );
+ mfPendingTabBarWidth = -1.0;
+ }
+
+ nTabSize = pTabControl->GetSizePixel().Width()-nOverlap;
+
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_FIX ) // bei linkem Scrollbar
+ {
+ if (nTabSize > nSizeLt-SC_SCROLLBAR_MIN) nTabSize = nSizeLt-SC_SCROLLBAR_MIN;
+ if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN;
+ nSizeLt -= nTabSize;
+ }
+ else // bei rechtem Scrollbar
+ {
+ if (nTabSize > nSizeRt-SC_SCROLLBAR_MIN) nTabSize = nSizeRt-SC_SCROLLBAR_MIN;
+ if (nTabSize < SC_TABBAR_MIN) nTabSize = SC_TABBAR_MIN;
+ nSizeRt -= nTabSize;
+ }
+ }
+
+ lcl_SetPosSize( *pTabControl, Point(nPosX-nOverlap, nPosY+nSizeY),
+ Size(nTabSize+nOverlap, nBarY), nTotalWidth, bLayoutRTL );
+ pTabControl->SetSheetLayoutRTL( bLayoutRTL );
+
+ lcl_SetPosSize( aHScrollLeft, Point(nPosX+nTabSize-nOverlap, nPosY+nSizeY),
+ Size(nSizeLt+2*nOverlap, nBarY), nTotalWidth, bLayoutRTL );
+ lcl_SetPosSize( *pHSplitter, Point( nPosX+nTabSize+nSizeLt, nPosY+nSizeY ),
+ Size( nSizeSp, nBarY ), nTotalWidth, bLayoutRTL );
+ lcl_SetPosSize( aHScrollRight, Point(nPosX+nTabSize+nSizeLt+nSizeSp-nOverlap,
+ nPosY+nSizeY),
+ Size(nSizeRt+2*nOverlap, nBarY), nTotalWidth, bLayoutRTL );
+
+ // SetDragRectPixel is done below
+ }
+
+ if (bVScroll) // Scrollbars vertikal
+ {
+ long nSizeUp = 0; // upper scroll bar
+ long nSizeSp = 0; // splitter
+ long nSizeDn; // unterer Scrollbar
+
+ switch (aViewData.GetVSplitMode())
+ {
+ case SC_SPLIT_NONE:
+ nSizeUp = 0;
+ nSizeSp = nSplitSizeY;
+ break;
+ case SC_SPLIT_NORMAL:
+ nSizeUp = aViewData.GetVSplitPos();
+ nSizeSp = nSplitSizeY;
+ break;
+ case SC_SPLIT_FIX:
+ nSizeUp = 0;
+ nSizeSp = 0;
+ break;
+ }
+ nSizeDn = nSizeY - nSizeUp - nSizeSp;
+
+ lcl_SetPosSize( aVScrollTop, Point(nPosX+nSizeX, nPosY-nOverlap),
+ Size(nBarX,nSizeUp+2*nOverlap), nTotalWidth, bLayoutRTL );
+ lcl_SetPosSize( *pVSplitter, Point( nPosX+nSizeX, nPosY+nSizeUp ),
+ Size( nBarX, nSizeSp ), nTotalWidth, bLayoutRTL );
+ lcl_SetPosSize( aVScrollBottom, Point(nPosX+nSizeX,
+ nPosY+nSizeUp+nSizeSp-nOverlap),
+ Size(nBarX, nSizeDn+2*nOverlap), nTotalWidth, bLayoutRTL );
+
+ // SetDragRectPixel is done below
+ }
+ }
+
+ // SetDragRectPixel auch ohne Scrollbars etc., wenn schon gesplittet ist
+ if ( bHScroll || aViewData.GetHSplitMode() != SC_SPLIT_NONE )
+ pHSplitter->SetDragRectPixel(
+ Rectangle( nPosX, nPosY, nPosX+nSizeX, nPosY+nSizeY ), pFrameWin );
+ if ( bVScroll || aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ pVSplitter->SetDragRectPixel(
+ Rectangle( nPosX, nPosY, nPosX+nSizeX, nPosY+nSizeY ), pFrameWin );
+
+ if (bTabControl && ! bHScroll )
+ {
+ nBarY = aHScrollLeft.GetSizePixel().Height();
+ nBarX = aVScrollBottom.GetSizePixel().Width();
+
+ nSize1 = nSizeX + nOverlap;
+
+ long nTabSize = nSize1;
+ if (nTabSize < 0) nTabSize = 0;
+
+ lcl_SetPosSize( *pTabControl, Point(nPosX-nOverlap, nPosY+nSizeY-nBarY),
+ Size(nTabSize+nOverlap, nBarY), nTotalWidth, bLayoutRTL );
+ nSizeY -= nBarY - nOverlap;
+ lcl_SetPosSize( aScrollBarBox, Point( nPosX+nSizeX, nPosY+nSizeY ), Size( nBarX, nBarY ),
+ nTotalWidth, bLayoutRTL );
+
+ if( bVScroll )
+ {
+ Size aVScrSize = aVScrollBottom.GetSizePixel();
+ aVScrSize.Height() -= nBarY;
+ aVScrollBottom.SetSizePixel( aVScrSize );
+ }
+ }
+
+ nOutPosX = nPosX;
+ nOutPosY = nPosY;
+
+ // Outline-Controls
+ if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM])
+ {
+ nOutlineX = pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize();
+ nSizeX -= nOutlineX;
+ nPosX += nOutlineX;
+ }
+ if (bHOutline && pColOutline[SC_SPLIT_LEFT])
+ {
+ nOutlineY = pColOutline[SC_SPLIT_LEFT]->GetDepthSize();
+ nSizeY -= nOutlineY;
+ nPosY += nOutlineY;
+ }
+
+ if (bHeaders) // Spalten/Zeilen-Header
+ {
+ nBarX = pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
+ nBarY = pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
+ nSizeX -= nBarX;
+ nSizeY -= nBarY;
+ nPosX += nBarX;
+ nPosY += nBarY;
+ }
+ else
+ nBarX = nBarY = 0;
+
+ //
+ // Splitter auswerten
+ //
+
+ long nLeftSize = nSizeX;
+ long nRightSize = 0;
+ long nTopSize = 0;
+ long nBottomSize = nSizeY;
+ long nSplitPosX = nPosX;
+ long nSplitPosY = nPosY;
+
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
+ {
+ long nSplitHeight = rSize.Height();
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ {
+ // Fixier-Splitter nicht mit Scrollbar/TabBar ueberlappen lassen
+ if ( bHScroll )
+ nSplitHeight -= aHScrollLeft.GetSizePixel().Height();
+ else if ( bTabControl && pTabControl )
+ nSplitHeight -= pTabControl->GetSizePixel().Height();
+ }
+ nSplitPosX = aViewData.GetHSplitPos();
+ lcl_SetPosSize( *pHSplitter,
+ Point( nSplitPosX, nOutPosY ), Size( nSplitSizeX, nSplitHeight ), nTotalWidth, bLayoutRTL );
+ nLeftSize = nSplitPosX - nPosX;
+ nSplitPosX += nSplitSizeX;
+ nRightSize = nSizeX - nLeftSize - nSplitSizeX;
+ }
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ {
+ long nSplitWidth = rSize.Width();
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && bVScroll )
+ nSplitWidth -= aVScrollBottom.GetSizePixel().Width();
+ nSplitPosY = aViewData.GetVSplitPos();
+ lcl_SetPosSize( *pVSplitter,
+ Point( nOutPosX, nSplitPosY ), Size( nSplitWidth, nSplitSizeY ), nTotalWidth, bLayoutRTL );
+ nTopSize = nSplitPosY - nPosY;
+ nSplitPosY += nSplitSizeY;
+ nBottomSize = nSizeY - nTopSize - nSplitSizeY;
+ }
+
+ // ShowHide fuer pColOutline / pRowOutline passiert in UpdateShow
+
+ if (bHOutline) // Outline-Controls
+ {
+ if (pColOutline[SC_SPLIT_LEFT])
+ {
+ pColOutline[SC_SPLIT_LEFT]->SetHeaderSize( nBarX );
+ lcl_SetPosSize( *pColOutline[SC_SPLIT_LEFT],
+ Point(nPosX-nBarX,nOutPosY), Size(nLeftSize+nBarX,nOutlineY), nTotalWidth, bLayoutRTL );
+ }
+ if (pColOutline[SC_SPLIT_RIGHT])
+ {
+ pColOutline[SC_SPLIT_RIGHT]->SetHeaderSize( 0 ); // always call to update RTL flag
+ lcl_SetPosSize( *pColOutline[SC_SPLIT_RIGHT],
+ Point(nSplitPosX,nOutPosY), Size(nRightSize,nOutlineY), nTotalWidth, bLayoutRTL );
+ }
+ }
+ if (bVOutline)
+ {
+ if (nTopSize)
+ {
+ if (pRowOutline[SC_SPLIT_TOP] && pRowOutline[SC_SPLIT_BOTTOM])
+ {
+ pRowOutline[SC_SPLIT_TOP]->SetHeaderSize( nBarY );
+ lcl_SetPosSize( *pRowOutline[SC_SPLIT_TOP],
+ Point(nOutPosX,nPosY-nBarY), Size(nOutlineX,nTopSize+nBarY), nTotalWidth, bLayoutRTL );
+ pRowOutline[SC_SPLIT_BOTTOM]->SetHeaderSize( 0 );
+ lcl_SetPosSize( *pRowOutline[SC_SPLIT_BOTTOM],
+ Point(nOutPosX,nSplitPosY), Size(nOutlineX,nBottomSize), nTotalWidth, bLayoutRTL );
+ }
+ }
+ else if (pRowOutline[SC_SPLIT_BOTTOM])
+ {
+ pRowOutline[SC_SPLIT_BOTTOM]->SetHeaderSize( nBarY );
+ lcl_SetPosSize( *pRowOutline[SC_SPLIT_BOTTOM],
+ Point(nOutPosX,nSplitPosY-nBarY), Size(nOutlineX,nBottomSize+nBarY), nTotalWidth, bLayoutRTL );
+ }
+ }
+ if (bHOutline && bVOutline)
+ {
+ lcl_SetPosSize( aTopButton, Point(nOutPosX,nOutPosY), Size(nOutlineX,nOutlineY), nTotalWidth, bLayoutRTL );
+ aTopButton.Show();
+ }
+ else
+ aTopButton.Hide();
+
+ if (bHeaders) // Spalten/Zeilen-Header
+ {
+ lcl_SetPosSize( *pColBar[SC_SPLIT_LEFT],
+ Point(nPosX,nPosY-nBarY), Size(nLeftSize,nBarY), nTotalWidth, bLayoutRTL );
+ if (pColBar[SC_SPLIT_RIGHT])
+ lcl_SetPosSize( *pColBar[SC_SPLIT_RIGHT],
+ Point(nSplitPosX,nPosY-nBarY), Size(nRightSize,nBarY), nTotalWidth, bLayoutRTL );
+
+ if (pRowBar[SC_SPLIT_TOP])
+ lcl_SetPosSize( *pRowBar[SC_SPLIT_TOP],
+ Point(nPosX-nBarX,nPosY), Size(nBarX,nTopSize), nTotalWidth, bLayoutRTL );
+ lcl_SetPosSize( *pRowBar[SC_SPLIT_BOTTOM],
+ Point(nPosX-nBarX,nSplitPosY), Size(nBarX,nBottomSize), nTotalWidth, bLayoutRTL );
+
+ lcl_SetPosSize( aCornerButton, Point(nPosX-nBarX,nPosY-nBarY), Size(nBarX,nBarY), nTotalWidth, bLayoutRTL );
+ aCornerButton.Show();
+ pColBar[SC_SPLIT_LEFT]->Show();
+ pRowBar[SC_SPLIT_BOTTOM]->Show();
+ }
+ else
+ {
+ aCornerButton.Hide();
+ pColBar[SC_SPLIT_LEFT]->Hide(); // immer da
+ pRowBar[SC_SPLIT_BOTTOM]->Hide();
+ }
+
+
+ // Grid-Windows
+
+ if (bInner)
+ {
+ long nInnerPosX = bLayoutRTL ? ( nTotalWidth - nPosX - nLeftSize ) : nPosX;
+ pGridWin[SC_SPLIT_BOTTOMLEFT]->SetPosPixel( Point(nInnerPosX,nSplitPosY) );
+ }
+ else
+ {
+ lcl_SetPosSize( *pGridWin[SC_SPLIT_BOTTOMLEFT],
+ Point(nPosX,nSplitPosY), Size(nLeftSize,nBottomSize), nTotalWidth, bLayoutRTL );
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
+ lcl_SetPosSize( *pGridWin[SC_SPLIT_BOTTOMRIGHT],
+ Point(nSplitPosX,nSplitPosY), Size(nRightSize,nBottomSize), nTotalWidth, bLayoutRTL );
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ lcl_SetPosSize( *pGridWin[SC_SPLIT_TOPLEFT],
+ Point(nPosX,nPosY), Size(nLeftSize,nTopSize), nTotalWidth, bLayoutRTL );
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE && aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ lcl_SetPosSize( *pGridWin[SC_SPLIT_TOPRIGHT],
+ Point(nSplitPosX,nPosY), Size(nRightSize,nTopSize), nTotalWidth, bLayoutRTL );
+ }
+
+ //
+ // Scrollbars updaten
+ //
+
+ if (!bInUpdateHeader)
+ {
+ UpdateScrollBars(); // Scrollbars nicht beim Scrollen neu setzen
+ UpdateHeaderWidth();
+
+ InterpretVisible(); // #69343# have everything calculated before painting
+ }
+
+ if (bHasHint)
+ TestHintWindow(); // neu positionieren
+
+ UpdateVarZoom(); // update variable zoom types (after resizing GridWindows)
+
+ if (aViewData.GetViewShell()->HasAccessibilityObjects())
+ aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_WINDOWRESIZED));
+}
+
+void ScTabView::UpdateVarZoom()
+{
+ // update variable zoom types
+
+ SvxZoomType eZoomType = GetZoomType();
+ if ( eZoomType != SVX_ZOOM_PERCENT && !bInZoomUpdate )
+ {
+ bInZoomUpdate = TRUE;
+ const Fraction& rOldX = GetViewData()->GetZoomX();
+ const Fraction& rOldY = GetViewData()->GetZoomY();
+ long nOldPercent = ( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator();
+ USHORT nNewZoom = CalcZoom( eZoomType, (USHORT)nOldPercent );
+ Fraction aNew( nNewZoom, 100 );
+
+ if ( aNew != rOldX || aNew != rOldY )
+ {
+ SetZoom( aNew, aNew, FALSE ); // always separately per sheet
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ aViewData.GetViewShell()->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+ }
+ bInZoomUpdate = FALSE;
+ }
+}
+
+void ScTabView::UpdateFixPos()
+{
+ BOOL bResize = FALSE;
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ if (aViewData.UpdateFixX())
+ bResize = TRUE;
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ if (aViewData.UpdateFixY())
+ bResize = TRUE;
+ if (bResize)
+ RepeatResize(FALSE);
+}
+
+void ScTabView::RepeatResize( BOOL bUpdateFix )
+{
+ if ( bUpdateFix )
+ {
+ ScSplitMode eHSplit = aViewData.GetHSplitMode();
+ ScSplitMode eVSplit = aViewData.GetVSplitMode();
+
+ // #i46796# UpdateFixX / UpdateFixY uses GetGridOffset, which requires the
+ // outline windows to be available. So UpdateShow has to be called before
+ // (also called from DoResize).
+ if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX )
+ UpdateShow();
+
+ if ( eHSplit == SC_SPLIT_FIX )
+ aViewData.UpdateFixX();
+ if ( eVSplit == SC_SPLIT_FIX )
+ aViewData.UpdateFixY();
+ }
+
+ DoResize( aBorderPos, aFrameSize );
+
+ //! Border muss neu gesetzt werden ???
+}
+
+void ScTabView::GetBorderSize( SvBorder& rBorder, const Size& /* rSize */ )
+{
+ BOOL bScrollBars = aViewData.IsVScrollMode();
+ BOOL bHeaders = aViewData.IsHeaderMode();
+ BOOL bOutlMode = aViewData.IsOutlineMode();
+ BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
+ BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+
+ rBorder = SvBorder();
+
+ if (bScrollBars) // Scrollbars horizontal oder vertikal
+ {
+ rBorder.Right() += aVScrollBottom.GetSizePixel().Width();
+ rBorder.Bottom() += aHScrollLeft.GetSizePixel().Height();
+ }
+
+ // Outline-Controls
+ if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM])
+ rBorder.Left() += pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize();
+ if (bHOutline && pColOutline[SC_SPLIT_LEFT])
+ rBorder.Top() += pColOutline[SC_SPLIT_LEFT]->GetDepthSize();
+
+ if (bHeaders) // Spalten/Zeilen-Header
+ {
+ rBorder.Left() += pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
+ rBorder.Top() += pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
+ }
+
+ if ( bLayoutRTL )
+ ::std::swap( rBorder.Left(), rBorder.Right() );
+}
+
+IMPL_LINK( ScTabView, TabBarResize, void*, EMPTYARG )
+{
+ BOOL bHScrollMode = aViewData.IsHScrollMode();
+
+ // Scrollbar-Einstellungen koennen vom Sfx ueberschrieben werden:
+ SfxScrollingMode eMode = aViewData.GetViewShell()->GetScrollingMode();
+ if ( eMode == SCROLLING_NO )
+ bHScrollMode = FALSE;
+ else if ( eMode == SCROLLING_YES || eMode == SCROLLING_AUTO ) //! Auto ???
+ bHScrollMode = TRUE;
+
+ if( bHScrollMode )
+ {
+ const long nOverlap = 0; // ScrollBar::GetWindowOverlapPixel();
+ long nSize = pTabControl->GetSplitSize();
+
+ if (aViewData.GetHSplitMode() != SC_SPLIT_FIX)
+ {
+ long nMax = pHSplitter->GetPosPixel().X();
+ if( pTabControl->IsEffectiveRTL() )
+ nMax = pFrameWin->GetSizePixel().Width() - nMax;
+ --nMax;
+ if (nSize>nMax) nSize = nMax;
+ }
+
+ if ( nSize != pTabControl->GetSizePixel().Width() )
+ {
+ pTabControl->SetSizePixel( Size( nSize+nOverlap,
+ pTabControl->GetSizePixel().Height() ) );
+ RepeatResize();
+ }
+ }
+
+ return 0;
+}
+
+void ScTabView::SetTabBarWidth( long nNewWidth )
+{
+ Size aSize = pTabControl->GetSizePixel();
+
+ if ( aSize.Width() != nNewWidth )
+ {
+ aSize.Width() = nNewWidth;
+ pTabControl->SetSizePixel( aSize );
+ }
+}
+
+void ScTabView::SetRelTabBarWidth( double fRelTabBarWidth )
+{
+ if( (0.0 <= fRelTabBarWidth) && (fRelTabBarWidth <= 1.0) )
+ if( long nFrameWidth = pFrameWin->GetSizePixel().Width() )
+ SetTabBarWidth( static_cast< long >( fRelTabBarWidth * nFrameWidth + 0.5 ) );
+}
+
+void ScTabView::SetPendingRelTabBarWidth( double fRelTabBarWidth )
+{
+ mfPendingTabBarWidth = fRelTabBarWidth;
+ SetRelTabBarWidth( fRelTabBarWidth );
+}
+
+long ScTabView::GetTabBarWidth() const
+{
+ return pTabControl->GetSizePixel().Width();
+}
+
+double ScTabView::GetRelTabBarWidth() const
+{
+ if( long nFrameWidth = pFrameWin->GetSizePixel().Width() )
+ return static_cast< double >( GetTabBarWidth() ) / nFrameWidth;
+ return 0.0;
+}
+
+double ScTabView::GetPendingRelTabBarWidth() const
+{
+ return mfPendingTabBarWidth;
+}
+
+Window* ScTabView::GetActiveWin()
+{
+ ScSplitPos ePos = aViewData.GetActivePart();
+ DBG_ASSERT(pGridWin[ePos],"kein aktives Fenster");
+ return pGridWin[ePos];
+}
+
+Window* ScTabView::GetWindowByPos( ScSplitPos ePos )
+{
+ return pGridWin[ePos];
+}
+
+void ScTabView::SetActivePointer( const Pointer& rPointer )
+{
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ pGridWin[i]->SetPointer( rPointer );
+
+/* ScSplitPos ePos = aViewData.GetActivePart();
+ if (pGridWin[ePos])
+ pGridWin[ePos]->SetPointer( rPointer );
+*/
+}
+
+
+void ScTabView::ActiveGrabFocus()
+{
+ ScSplitPos ePos = aViewData.GetActivePart();
+ if (pGridWin[ePos])
+ pGridWin[ePos]->GrabFocus();
+}
+
+
+ScSplitPos ScTabView::FindWindow( Window* pWindow ) const
+{
+ ScSplitPos eVal = SC_SPLIT_BOTTOMLEFT; // Default
+ for (USHORT i=0; i<4; i++)
+ if ( pGridWin[i] == pWindow )
+ eVal = (ScSplitPos) i;
+
+ return eVal;
+}
+
+Point ScTabView::GetGridOffset() const
+{
+ Point aPos;
+
+ // Groessen hier wie in DoResize
+
+ BOOL bHeaders = aViewData.IsHeaderMode();
+ BOOL bOutlMode = aViewData.IsOutlineMode();
+ BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
+ BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
+
+ // Outline-Controls
+ if (bVOutline && pRowOutline[SC_SPLIT_BOTTOM])
+ aPos.X() += pRowOutline[SC_SPLIT_BOTTOM]->GetDepthSize();
+ if (bHOutline && pColOutline[SC_SPLIT_LEFT])
+ aPos.Y() += pColOutline[SC_SPLIT_LEFT]->GetDepthSize();
+
+ if (bHeaders) // Spalten/Zeilen-Header
+ {
+ if (pRowBar[SC_SPLIT_BOTTOM])
+ aPos.X() += pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
+ if (pColBar[SC_SPLIT_LEFT])
+ aPos.Y() += pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
+ }
+
+ return aPos;
+}
+
+// --- Scroll-Bars --------------------------------------------------------
+
+BOOL ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos )
+{
+ HideNoteMarker();
+
+ BOOL bDone = FALSE;
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if ( pData && pData->GetMode() == COMMAND_WHEEL_ZOOM )
+ {
+ if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ // for ole inplace editing, the scale is defined by the visarea and client size
+ // and can't be changed directly
+
+ const Fraction& rOldY = aViewData.GetZoomY();
+ long nOld = (long)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
+ long nNew = nOld;
+ if ( pData->GetDelta() < 0 )
+ nNew = Max( (long) MINZOOM, (long)( nOld - SC_DELTA_ZOOM ) );
+ else
+ nNew = Min( (long) MAXZOOM, (long)( nOld + SC_DELTA_ZOOM ) );
+
+ if ( nNew != nOld )
+ {
+ // scroll wheel doesn't set the AppOptions default
+
+ BOOL bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
+ SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom );
+ Fraction aFract( nNew, 100 );
+ SetZoom( aFract, aFract, bSyncZoom );
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM );
+ aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+ }
+
+ bDone = TRUE;
+ }
+ }
+ else
+ {
+ ScHSplitPos eHPos = WhichH(ePos);
+ ScVSplitPos eVPos = WhichV(ePos);
+ ScrollBar* pHScroll = ( eHPos == SC_SPLIT_LEFT ) ? &aHScrollLeft : &aHScrollRight;
+ ScrollBar* pVScroll = ( eVPos == SC_SPLIT_TOP ) ? &aVScrollTop : &aVScrollBottom;
+ if ( pGridWin[ePos] )
+ bDone = pGridWin[ePos]->HandleScrollCommand( rCEvt, pHScroll, pVScroll );
+ }
+ return bDone;
+}
+
+IMPL_LINK( ScTabView, EndScrollHdl, ScrollBar*, pScroll )
+{
+ BOOL bOnlineScroll = TRUE; //! Optionen
+
+ if ( bDragging )
+ {
+ if ( bOnlineScroll ) // nur Ranges aktualisieren
+ UpdateScrollBars();
+ else
+ {
+ long nScrollMin = 0; // RangeMin simulieren
+ if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight )
+ nScrollMin = aViewData.GetFixPosX();
+ if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom )
+ nScrollMin = aViewData.GetFixPosY();
+
+ if ( pScroll == &aHScrollLeft || pScroll == &aHScrollRight )
+ {
+ BOOL bMirror = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() ) != Application::GetSettings().GetLayoutRTL();
+ ScHSplitPos eWhich = (pScroll == &aHScrollLeft) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT;
+ long nDelta = GetScrollBarPos( *pScroll, bMirror ) + nScrollMin - aViewData.GetPosX(eWhich);
+ if (nDelta) ScrollX( nDelta, eWhich );
+ }
+ else // VScroll...
+ {
+ ScVSplitPos eWhich = (pScroll == &aVScrollTop) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM;
+ long nDelta = GetScrollBarPos( *pScroll, FALSE ) + nScrollMin - aViewData.GetPosY(eWhich);
+ if (nDelta) ScrollY( nDelta, eWhich );
+ }
+ }
+ bDragging = FALSE;
+ }
+ return 0;
+}
+
+IMPL_LINK( ScTabView, ScrollHdl, ScrollBar*, pScroll )
+{
+ BOOL bOnlineScroll = TRUE; //! Optionen
+
+ BOOL bHoriz = ( pScroll == &aHScrollLeft || pScroll == &aHScrollRight );
+ long nViewPos;
+ if ( bHoriz )
+ nViewPos = aViewData.GetPosX( (pScroll == &aHScrollLeft) ?
+ SC_SPLIT_LEFT : SC_SPLIT_RIGHT );
+ else
+ nViewPos = aViewData.GetPosY( (pScroll == &aVScrollTop) ?
+ SC_SPLIT_TOP : SC_SPLIT_BOTTOM );
+
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+ BOOL bMirror = bHoriz && (bLayoutRTL != Application::GetSettings().GetLayoutRTL());
+
+ ScrollType eType = pScroll->GetType();
+ if ( eType == SCROLL_DRAG )
+ {
+ if (!bDragging)
+ {
+ bDragging = TRUE;
+ nPrevDragPos = nViewPos;
+ }
+
+ // Scroll-Position anzeigen
+ // (nur QuickHelp, in der Statuszeile gibt es keinen Eintrag dafuer)
+
+ if (Help::IsQuickHelpEnabled())
+ {
+ Size aSize = pScroll->GetSizePixel();
+
+ /* Convert scrollbar mouse position to screen position. If RTL
+ mode of scrollbar differs from RTL mode of its parent, then the
+ direct call to Window::OutputToNormalizedScreenPixel() will
+ give unusable results, because calcualtion of screen position
+ is based on parent orientation and expects equal orientation of
+ the child position. Need to mirror mouse position before. */
+ Point aMousePos = pScroll->GetPointerPosPixel();
+ if( pScroll->IsRTLEnabled() != pScroll->GetParent()->IsRTLEnabled() )
+ aMousePos.X() = aSize.Width() - aMousePos.X() - 1;
+ aMousePos = pScroll->OutputToNormalizedScreenPixel( aMousePos );
+
+ // convert top-left position of scrollbar to screen position
+ Point aPos = pScroll->OutputToNormalizedScreenPixel( Point() );
+
+ // get scrollbar scroll position for help text (row number/column name)
+ long nScrollMin = 0; // RangeMin simulieren
+ if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight )
+ nScrollMin = aViewData.GetFixPosX();
+ if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom )
+ nScrollMin = aViewData.GetFixPosY();
+ long nScrollPos = GetScrollBarPos( *pScroll, bMirror ) + nScrollMin;
+
+ String aHelpStr;
+ Rectangle aRect;
+ USHORT nAlign;
+ if (bHoriz)
+ {
+ aHelpStr = ScGlobal::GetRscString(STR_COLUMN);
+ aHelpStr += ' ';
+ aHelpStr += ScColToAlpha((SCCOL) nScrollPos);
+
+ aRect.Left() = aMousePos.X();
+ aRect.Top() = aPos.Y() - 4;
+ nAlign = QUICKHELP_BOTTOM|QUICKHELP_CENTER;
+ }
+ else
+ {
+ aHelpStr = ScGlobal::GetRscString(STR_ROW);
+ aHelpStr += ' ';
+ aHelpStr += String::CreateFromInt32(nScrollPos + 1);
+
+ // show quicktext always inside sheet area
+ aRect.Left() = bLayoutRTL ? (aPos.X() + aSize.Width() + 8) : (aPos.X() - 8);
+ aRect.Top() = aMousePos.Y();
+ nAlign = (bLayoutRTL ? QUICKHELP_LEFT : QUICKHELP_RIGHT) | QUICKHELP_VCENTER;
+ }
+ aRect.Right() = aRect.Left();
+ aRect.Bottom() = aRect.Top();
+
+ Help::ShowQuickHelp(pScroll->GetParent(), aRect, aHelpStr, nAlign);
+ }
+ }
+
+ if ( bOnlineScroll || eType != SCROLL_DRAG )
+ {
+ if ( bMirror )
+ {
+ // change scroll type so visible/previous cells calculation below remains the same
+ switch ( eType )
+ {
+ case SCROLL_LINEUP: eType = SCROLL_LINEDOWN; break;
+ case SCROLL_LINEDOWN: eType = SCROLL_LINEUP; break;
+ case SCROLL_PAGEUP: eType = SCROLL_PAGEDOWN; break;
+ case SCROLL_PAGEDOWN: eType = SCROLL_PAGEUP; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+ long nDelta = pScroll->GetDelta();
+ switch ( eType )
+ {
+ case SCROLL_LINEUP:
+ nDelta = -1;
+ break;
+ case SCROLL_LINEDOWN:
+ nDelta = 1;
+ break;
+ case SCROLL_PAGEUP:
+ if ( pScroll == &aHScrollLeft ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_LEFT );
+ if ( pScroll == &aHScrollRight ) nDelta = -(long) aViewData.PrevCellsX( SC_SPLIT_RIGHT );
+ if ( pScroll == &aVScrollTop ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_TOP );
+ if ( pScroll == &aVScrollBottom ) nDelta = -(long) aViewData.PrevCellsY( SC_SPLIT_BOTTOM );
+ if (nDelta==0) nDelta=-1;
+ break;
+ case SCROLL_PAGEDOWN:
+ if ( pScroll == &aHScrollLeft ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_LEFT );
+ if ( pScroll == &aHScrollRight ) nDelta = aViewData.VisibleCellsX( SC_SPLIT_RIGHT );
+ if ( pScroll == &aVScrollTop ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_TOP );
+ if ( pScroll == &aVScrollBottom ) nDelta = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM );
+ if (nDelta==0) nDelta=1;
+ break;
+ case SCROLL_DRAG:
+ {
+ // nur in die richtige Richtung scrollen, nicht um ausgeblendete
+ // Bereiche herumzittern
+
+ long nScrollMin = 0; // RangeMin simulieren
+ if ( aViewData.GetHSplitMode()==SC_SPLIT_FIX && pScroll == &aHScrollRight )
+ nScrollMin = aViewData.GetFixPosX();
+ if ( aViewData.GetVSplitMode()==SC_SPLIT_FIX && pScroll == &aVScrollBottom )
+ nScrollMin = aViewData.GetFixPosY();
+
+ long nScrollPos = GetScrollBarPos( *pScroll, bMirror ) + nScrollMin;
+ nDelta = nScrollPos - nViewPos;
+ if ( nScrollPos > nPrevDragPos )
+ {
+ if (nDelta<0) nDelta=0;
+ }
+ else if ( nScrollPos < nPrevDragPos )
+ {
+ if (nDelta>0) nDelta=0;
+ }
+ else
+ nDelta = 0;
+ nPrevDragPos = nScrollPos;
+ }
+ break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+
+ if (nDelta)
+ {
+ BOOL bUpdate = ( eType != SCROLL_DRAG ); // bei Drag die Ranges nicht aendern
+ if ( bHoriz )
+ ScrollX( nDelta, (pScroll == &aHScrollLeft) ? SC_SPLIT_LEFT : SC_SPLIT_RIGHT, bUpdate );
+ else
+ ScrollY( nDelta, (pScroll == &aVScrollTop) ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM, bUpdate );
+ }
+ }
+
+ return 0;
+}
+
+void ScTabView::ScrollX( long nDeltaX, ScHSplitPos eWhich, BOOL bUpdBars )
+{
+ BOOL bHasHint = ( pInputHintWindow != NULL );
+ if (bHasHint)
+ RemoveHintWindow();
+
+ SCCOL nOldX = aViewData.GetPosX(eWhich);
+ SCsCOL nNewX = static_cast<SCsCOL>(nOldX) + static_cast<SCsCOL>(nDeltaX);
+ if ( nNewX < 0 )
+ {
+ nDeltaX -= nNewX;
+ nNewX = 0;
+ }
+ if ( nNewX > MAXCOL )
+ {
+ nDeltaX -= nNewX - MAXCOL;
+ nNewX = MAXCOL;
+ }
+
+ SCsCOL nDir = ( nDeltaX > 0 ) ? 1 : -1;
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ while ( pDoc->ColHidden(nNewX, nTab) &&
+ nNewX+nDir >= 0 && nNewX+nDir <= MAXCOL )
+ nNewX = sal::static_int_cast<SCsCOL>( nNewX + nDir );
+
+ // Fixierung
+
+ if (aViewData.GetHSplitMode() == SC_SPLIT_FIX)
+ {
+ if (eWhich == SC_SPLIT_LEFT)
+ nNewX = static_cast<SCsCOL>(nOldX); // links immer stehenlassen
+ else
+ {
+ SCsCOL nFixX = static_cast<SCsCOL>(aViewData.GetFixPosX());
+ if (nNewX < nFixX)
+ nNewX = nFixX;
+ }
+ }
+ if (nNewX == static_cast<SCsCOL>(nOldX))
+ return;
+
+ HideAllCursors();
+
+ if ( nNewX >= 0 && nNewX <= MAXCOL && nDeltaX )
+ {
+ SCCOL nTrackX = std::max( nOldX, static_cast<SCCOL>(nNewX) );
+
+ // Mit VCL wirkt Update() im Moment immer auf alle Fenster, beim Update
+ // nach dem Scrollen des GridWindow's wuerde darum der Col-/RowBar evtl.
+ // mit schon geaenderter Pos. gepainted werden -
+ // darum vorher einmal Update am Col-/RowBar
+
+ if (pColBar[eWhich])
+ pColBar[eWhich]->Update();
+
+ long nOldPos = aViewData.GetScrPos( nTrackX, 0, eWhich ).X();
+ aViewData.SetPosX( eWhich, static_cast<SCCOL>(nNewX) );
+ long nDiff = aViewData.GetScrPos( nTrackX, 0, eWhich ).X() - nOldPos;
+
+ if ( eWhich==SC_SPLIT_LEFT )
+ {
+ pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel( nDiff, 0 );
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel( nDiff, 0 );
+ }
+ else
+ {
+ pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel( nDiff, 0 );
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel( nDiff, 0 );
+ }
+ if (pColBar[eWhich]) { pColBar[eWhich]->Scroll( nDiff,0 ); pColBar[eWhich]->Update(); }
+ if (pColOutline[eWhich]) pColOutline[eWhich]->ScrollPixel( nDiff );
+ if (bUpdBars)
+ UpdateScrollBars();
+ }
+
+ if (nDeltaX==1 || nDeltaX==-1)
+ pGridWin[aViewData.GetActivePart()]->Update();
+
+ ShowAllCursors();
+
+ SetNewVisArea(); // MapMode muss schon gesetzt sein
+
+ if (bHasHint)
+ TestHintWindow(); // neu positionieren
+}
+
+void ScTabView::ScrollY( long nDeltaY, ScVSplitPos eWhich, BOOL bUpdBars )
+{
+ BOOL bHasHint = ( pInputHintWindow != NULL );
+ if (bHasHint)
+ RemoveHintWindow();
+
+ SCROW nOldY = aViewData.GetPosY(eWhich);
+ SCsROW nNewY = static_cast<SCsROW>(nOldY) + static_cast<SCsROW>(nDeltaY);
+ if ( nNewY < 0 )
+ {
+ nDeltaY -= nNewY;
+ nNewY = 0;
+ }
+ if ( nNewY > MAXROW )
+ {
+ nDeltaY -= nNewY - MAXROW;
+ nNewY = MAXROW;
+ }
+
+ SCsROW nDir = ( nDeltaY > 0 ) ? 1 : -1;
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ while ( pDoc->RowHidden(nNewY, nTab) &&
+ nNewY+nDir >= 0 && nNewY+nDir <= MAXROW )
+ nNewY += nDir;
+
+ // Fixierung
+
+ if (aViewData.GetVSplitMode() == SC_SPLIT_FIX)
+ {
+ if (eWhich == SC_SPLIT_TOP)
+ nNewY = static_cast<SCsROW>(nOldY); // oben immer stehenlassen
+ else
+ {
+ SCsROW nFixY = static_cast<SCsROW>(aViewData.GetFixPosY());
+ if (nNewY < nFixY)
+ nNewY = nFixY;
+ }
+ }
+ if (nNewY == static_cast<SCsROW>(nOldY))
+ return;
+
+ HideAllCursors();
+
+ if ( nNewY >= 0 && nNewY <= MAXROW && nDeltaY )
+ {
+ SCROW nTrackY = std::max( nOldY, static_cast<SCROW>(nNewY) );
+
+ // Zeilenkoepfe anpassen vor dem eigentlichen Scrolling, damit nicht
+ // doppelt gepainted werden muss
+ // PosY darf dann auch noch nicht umgesetzt sein, neuen Wert uebergeben
+ SCROW nUNew = static_cast<SCROW>(nNewY);
+ UpdateHeaderWidth( &eWhich, &nUNew ); // Zeilenkoepfe anpassen
+
+ if (pRowBar[eWhich])
+ pRowBar[eWhich]->Update();
+
+ long nOldPos = aViewData.GetScrPos( 0, nTrackY, eWhich ).Y();
+ aViewData.SetPosY( eWhich, static_cast<SCROW>(nNewY) );
+ long nDiff = aViewData.GetScrPos( 0, nTrackY, eWhich ).Y() - nOldPos;
+
+ if ( eWhich==SC_SPLIT_TOP )
+ {
+ pGridWin[SC_SPLIT_TOPLEFT]->ScrollPixel( 0, nDiff );
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
+ pGridWin[SC_SPLIT_TOPRIGHT]->ScrollPixel( 0, nDiff );
+ }
+ else
+ {
+ pGridWin[SC_SPLIT_BOTTOMLEFT]->ScrollPixel( 0, nDiff );
+ if ( aViewData.GetHSplitMode() != SC_SPLIT_NONE )
+ pGridWin[SC_SPLIT_BOTTOMRIGHT]->ScrollPixel( 0, nDiff );
+ }
+ if (pRowBar[eWhich]) { pRowBar[eWhich]->Scroll( 0,nDiff ); pRowBar[eWhich]->Update(); }
+ if (pRowOutline[eWhich]) pRowOutline[eWhich]->ScrollPixel( nDiff );
+ if (bUpdBars)
+ UpdateScrollBars();
+ }
+
+ if (nDeltaY==1 || nDeltaY==-1)
+ pGridWin[aViewData.GetActivePart()]->Update();
+
+ ShowAllCursors();
+
+ SetNewVisArea(); // MapMode muss schon gesetzt sein
+
+ if (bHasHint)
+ TestHintWindow(); // neu positionieren
+}
+
+void ScTabView::ScrollLines( long nDeltaX, long nDeltaY )
+{
+ ScSplitPos eWhich = aViewData.GetActivePart();
+ if (nDeltaX)
+ ScrollX(nDeltaX,WhichH(eWhich));
+ if (nDeltaY)
+ ScrollY(nDeltaY,WhichV(eWhich));
+}
+
+SCROW lcl_LastVisible( ScViewData& rViewData )
+{
+ // wenn am Dokumentende viele Zeilen ausgeblendet sind (welcher Trottel macht sowas?),
+ // soll dadurch nicht auf breite Zeilenkoepfe geschaltet werden
+ //! als Member ans Dokument ???
+
+ ScDocument* pDoc = rViewData.GetDocument();
+ SCTAB nTab = rViewData.GetTabNo();
+
+ SCROW nVis = MAXROW;
+ while ( nVis > 0 && pDoc->GetRowHeight( nVis, nTab ) == 0 )
+ --nVis;
+ return nVis;
+}
+
+void ScTabView::UpdateHeaderWidth( const ScVSplitPos* pWhich, const SCROW* pPosY )
+{
+ if ( !pRowBar[SC_SPLIT_BOTTOM] || MAXROW < 10000 )
+ return;
+
+ SCROW nEndPos = MAXROW;
+ if ( !aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ // fuer OLE Inplace immer MAXROW
+
+ if ( pWhich && *pWhich == SC_SPLIT_BOTTOM && pPosY )
+ nEndPos = *pPosY;
+ else
+ nEndPos = aViewData.GetPosY( SC_SPLIT_BOTTOM );
+ nEndPos += aViewData.CellsAtY( nEndPos, 1, SC_SPLIT_BOTTOM, SC_SIZE_NONE ); // VisibleCellsY
+ if (nEndPos > MAXROW)
+ nEndPos = lcl_LastVisible( aViewData );
+
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ {
+ SCROW nTopEnd;
+ if ( pWhich && *pWhich == SC_SPLIT_TOP && pPosY )
+ nTopEnd = *pPosY;
+ else
+ nTopEnd = aViewData.GetPosY( SC_SPLIT_TOP );
+ nTopEnd += aViewData.CellsAtY( nTopEnd, 1, SC_SPLIT_TOP, SC_SIZE_NONE );// VisibleCellsY
+ if (nTopEnd > MAXROW)
+ nTopEnd = lcl_LastVisible( aViewData );
+
+ if ( nTopEnd > nEndPos )
+ nEndPos = nTopEnd;
+ }
+ }
+
+ long nSmall = pRowBar[SC_SPLIT_BOTTOM]->GetSmallWidth();
+ long nBig = pRowBar[SC_SPLIT_BOTTOM]->GetBigWidth();
+ long nDiff = nBig - nSmall;
+
+ if (nEndPos>10000)
+ nEndPos = 10000;
+ else if (nEndPos<1) // avoid extra step at 0 (when only one row is visible)
+ nEndPos = 1;
+ long nWidth = nBig - ( 10000 - nEndPos ) * nDiff / 10000;
+
+ if ( nWidth != pRowBar[SC_SPLIT_BOTTOM]->GetWidth() && !bInUpdateHeader )
+ {
+ bInUpdateHeader = TRUE;
+
+ pRowBar[SC_SPLIT_BOTTOM]->SetWidth( nWidth );
+ if (pRowBar[SC_SPLIT_TOP])
+ pRowBar[SC_SPLIT_TOP]->SetWidth( nWidth );
+
+ RepeatResize();
+
+ // auf VCL gibt's Update ohne Ende (jedes Update gilt fuer alle Fenster)
+ //aCornerButton.Update(); // der bekommt sonst nie ein Update
+
+ bInUpdateHeader = FALSE;
+ }
+}
+
+inline void ShowHide( Window* pWin, BOOL bShow )
+{
+ DBG_ASSERT(pWin || !bShow, "Fenster ist nicht da");
+ if (pWin)
+ pWin->Show(bShow);
+}
+
+void ScTabView::UpdateShow()
+{
+ BOOL bHScrollMode = aViewData.IsHScrollMode();
+ BOOL bVScrollMode = aViewData.IsVScrollMode();
+ BOOL bTabMode = aViewData.IsTabMode();
+ BOOL bOutlMode = aViewData.IsOutlineMode();
+ BOOL bHOutline = bOutlMode && lcl_HasColOutline(aViewData);
+ BOOL bVOutline = bOutlMode && lcl_HasRowOutline(aViewData);
+ BOOL bHeader = aViewData.IsHeaderMode();
+
+ BOOL bShowH = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE );
+ BOOL bShowV = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE );
+
+ // Scrollbar-Einstellungen koennen vom Sfx ueberschrieben werden:
+ SfxScrollingMode eMode = aViewData.GetViewShell()->GetScrollingMode();
+ if ( eMode == SCROLLING_NO )
+ bHScrollMode = bVScrollMode = FALSE;
+ else if ( eMode == SCROLLING_YES || eMode == SCROLLING_AUTO ) //! Auto ???
+ bHScrollMode = bVScrollMode = TRUE;
+
+ if ( aViewData.GetDocShell()->IsPreview() )
+ bHScrollMode = bVScrollMode = bTabMode = bHeader = bOutlMode = bHOutline = bVOutline = FALSE;
+
+ //
+ // Windows anlegen
+ //
+
+ if (bShowH && !pGridWin[SC_SPLIT_BOTTOMRIGHT])
+ {
+ pGridWin[SC_SPLIT_BOTTOMRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMRIGHT );
+ DoAddWin( pGridWin[SC_SPLIT_BOTTOMRIGHT] );
+ }
+ if (bShowV && !pGridWin[SC_SPLIT_TOPLEFT])
+ {
+ pGridWin[SC_SPLIT_TOPLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPLEFT );
+ DoAddWin( pGridWin[SC_SPLIT_TOPLEFT] );
+ }
+ if (bShowH && bShowV && !pGridWin[SC_SPLIT_TOPRIGHT])
+ {
+ pGridWin[SC_SPLIT_TOPRIGHT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_TOPRIGHT );
+ DoAddWin( pGridWin[SC_SPLIT_TOPRIGHT] );
+ }
+
+ if (bHOutline && !pColOutline[SC_SPLIT_LEFT])
+ pColOutline[SC_SPLIT_LEFT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMLEFT );
+ if (bShowH && bHOutline && !pColOutline[SC_SPLIT_RIGHT])
+ pColOutline[SC_SPLIT_RIGHT] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_HOR, &aViewData, SC_SPLIT_BOTTOMRIGHT );
+
+ if (bVOutline && !pRowOutline[SC_SPLIT_BOTTOM])
+ pRowOutline[SC_SPLIT_BOTTOM] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_BOTTOMLEFT );
+ if (bShowV && bVOutline && !pRowOutline[SC_SPLIT_TOP])
+ pRowOutline[SC_SPLIT_TOP] = new ScOutlineWindow( pFrameWin, SC_OUTLINE_VER, &aViewData, SC_SPLIT_TOPLEFT );
+
+ if (bShowH && bHeader && !pColBar[SC_SPLIT_RIGHT])
+ pColBar[SC_SPLIT_RIGHT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_RIGHT,
+ &aHdrFunc, pHdrSelEng );
+ if (bShowV && bHeader && !pRowBar[SC_SPLIT_TOP])
+ pRowBar[SC_SPLIT_TOP] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_TOP,
+ &aHdrFunc, pHdrSelEng );
+
+ //
+ // Windows anzeigen
+ //
+
+ ShowHide( &aHScrollLeft, bHScrollMode );
+ ShowHide( &aHScrollRight, bShowH && bHScrollMode );
+ ShowHide( &aVScrollBottom, bVScrollMode );
+ ShowHide( &aVScrollTop, bShowV && bVScrollMode );
+ ShowHide( &aScrollBarBox, bVScrollMode || bHScrollMode );
+
+ ShowHide( pHSplitter, bHScrollMode || bShowH ); // immer angelegt
+ ShowHide( pVSplitter, bVScrollMode || bShowV );
+ ShowHide( pTabControl, bTabMode );
+
+ // ab hier dynamisch angelegte
+
+ ShowHide( pGridWin[SC_SPLIT_BOTTOMRIGHT], bShowH );
+ ShowHide( pGridWin[SC_SPLIT_TOPLEFT], bShowV );
+ ShowHide( pGridWin[SC_SPLIT_TOPRIGHT], bShowH && bShowV );
+
+ ShowHide( pColOutline[SC_SPLIT_LEFT], bHOutline );
+ ShowHide( pColOutline[SC_SPLIT_RIGHT], bShowH && bHOutline );
+
+ ShowHide( pRowOutline[SC_SPLIT_BOTTOM], bVOutline );
+ ShowHide( pRowOutline[SC_SPLIT_TOP], bShowV && bVOutline );
+
+ ShowHide( pColBar[SC_SPLIT_RIGHT], bShowH && bHeader );
+ ShowHide( pRowBar[SC_SPLIT_TOP], bShowV && bHeader );
+
+
+ //! neue Gridwindows eintragen
+}
+
+void ScTabView::UpdateVisibleRange()
+{
+ for (int i = 0; i < 4; ++i)
+ {
+ if (!pGridWin[i] || !pGridWin[i]->IsVisible())
+ continue;
+
+ pGridWin[i]->UpdateVisibleRange();
+ }
+}
+
+// --- Splitter --------------------------------------------------------
+
+IMPL_LINK( ScTabView, SplitHdl, Splitter*, pSplitter )
+{
+ if ( pSplitter == pHSplitter )
+ DoHSplit( pHSplitter->GetSplitPosPixel() );
+ else
+ DoVSplit( pVSplitter->GetSplitPosPixel() );
+
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX || aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ FreezeSplitters( TRUE );
+
+ DoResize( aBorderPos, aFrameSize );
+
+ return 0;
+}
+
+void ScTabView::DoHSplit(long nSplitPos)
+{
+ // nSplitPos is the real pixel position on the frame window,
+ // mirroring for RTL has to be done here.
+
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+ if ( bLayoutRTL )
+ nSplitPos = pFrameWin->GetOutputSizePixel().Width() - nSplitPos - 1;
+
+ long nMinPos;
+ long nMaxPos;
+ SCCOL nOldDelta;
+ SCCOL nNewDelta;
+
+ nMinPos = SPLIT_MARGIN;
+ if ( pRowBar[SC_SPLIT_BOTTOM] && pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() >= nMinPos )
+ nMinPos = pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width() + 1;
+ nMaxPos = aFrameSize.Width() - SPLIT_MARGIN;
+
+ ScSplitMode aOldMode = aViewData.GetHSplitMode();
+ ScSplitMode aNewMode = SC_SPLIT_NORMAL;
+
+ aViewData.SetHSplitPos( nSplitPos );
+ if ( nSplitPos < nMinPos || nSplitPos > nMaxPos )
+ aNewMode = SC_SPLIT_NONE;
+
+ aViewData.SetHSplitMode( aNewMode );
+
+ if ( aNewMode != aOldMode )
+ {
+ UpdateShow(); // vor ActivatePart !!
+
+ if ( aNewMode == SC_SPLIT_NONE )
+ {
+ if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT)
+ ActivatePart( SC_SPLIT_TOPLEFT );
+ if (aViewData.GetActivePart() == SC_SPLIT_BOTTOMRIGHT)
+ ActivatePart( SC_SPLIT_BOTTOMLEFT );
+ }
+ else
+ {
+ nOldDelta = aViewData.GetPosX( SC_SPLIT_LEFT );
+// aViewData.SetPosX( SC_SPLIT_LEFT, nOldDelta );
+ long nLeftWidth = nSplitPos - pRowBar[SC_SPLIT_BOTTOM]->GetSizePixel().Width();
+ if ( nLeftWidth < 0 ) nLeftWidth = 0;
+ nNewDelta = nOldDelta + aViewData.CellsAtX( nOldDelta, 1, SC_SPLIT_LEFT,
+ (USHORT) nLeftWidth );
+ if ( nNewDelta > MAXCOL )
+ nNewDelta = MAXCOL;
+ aViewData.SetPosX( SC_SPLIT_RIGHT, nNewDelta );
+ if ( nNewDelta > aViewData.GetCurX() )
+ ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ?
+ SC_SPLIT_BOTTOMLEFT : SC_SPLIT_TOPLEFT );
+ else
+ ActivatePart( (WhichV(aViewData.GetActivePart()) == SC_SPLIT_BOTTOM) ?
+ SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_TOPRIGHT );
+ }
+
+ // #61410# Form-Layer muss den sichtbaren Ausschnitt aller Fenster kennen
+ // dafuer muss hier schon der MapMode stimmen
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+ SetNewVisArea();
+
+ PaintGrid();
+ PaintTop();
+
+ InvalidateSplit();
+ }
+}
+
+void ScTabView::DoVSplit(long nSplitPos)
+{
+ long nMinPos;
+ long nMaxPos;
+ SCROW nOldDelta;
+ SCROW nNewDelta;
+
+ nMinPos = SPLIT_MARGIN;
+ if ( pColBar[SC_SPLIT_LEFT] && pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() >= nMinPos )
+ nMinPos = pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height() + 1;
+ nMaxPos = aFrameSize.Height() - SPLIT_MARGIN;
+
+ ScSplitMode aOldMode = aViewData.GetVSplitMode();
+ ScSplitMode aNewMode = SC_SPLIT_NORMAL;
+
+ aViewData.SetVSplitPos( nSplitPos );
+ if ( nSplitPos < nMinPos || nSplitPos > nMaxPos )
+ aNewMode = SC_SPLIT_NONE;
+
+ aViewData.SetVSplitMode( aNewMode );
+
+ if ( aNewMode != aOldMode )
+ {
+ UpdateShow(); // vor ActivatePart !!
+
+ if ( aNewMode == SC_SPLIT_NONE )
+ {
+ nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP );
+ aViewData.SetPosY( SC_SPLIT_BOTTOM, nOldDelta );
+
+ if (aViewData.GetActivePart() == SC_SPLIT_TOPLEFT)
+ ActivatePart( SC_SPLIT_BOTTOMLEFT );
+ if (aViewData.GetActivePart() == SC_SPLIT_TOPRIGHT)
+ ActivatePart( SC_SPLIT_BOTTOMRIGHT );
+ }
+ else
+ {
+ if ( aOldMode == SC_SPLIT_NONE )
+ nOldDelta = aViewData.GetPosY( SC_SPLIT_BOTTOM );
+ else
+ nOldDelta = aViewData.GetPosY( SC_SPLIT_TOP );
+
+ aViewData.SetPosY( SC_SPLIT_TOP, nOldDelta );
+ long nTopHeight = nSplitPos - pColBar[SC_SPLIT_LEFT]->GetSizePixel().Height();
+ if ( nTopHeight < 0 ) nTopHeight = 0;
+ nNewDelta = nOldDelta + aViewData.CellsAtY( nOldDelta, 1, SC_SPLIT_TOP,
+ (USHORT) nTopHeight );
+ if ( nNewDelta > MAXROW )
+ nNewDelta = MAXROW;
+ aViewData.SetPosY( SC_SPLIT_BOTTOM, nNewDelta );
+ if ( nNewDelta > aViewData.GetCurY() )
+ ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ?
+ SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT );
+ else
+ ActivatePart( (WhichH(aViewData.GetActivePart()) == SC_SPLIT_LEFT) ?
+ SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
+ }
+
+ // #61410# Form-Layer muss den sichtbaren Ausschnitt aller Fenster kennen
+ // dafuer muss hier schon der MapMode stimmen
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+ SetNewVisArea();
+
+ PaintGrid();
+ PaintLeft();
+
+ InvalidateSplit();
+ }
+}
+
+Point ScTabView::GetInsertPos()
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCCOL nCol = aViewData.GetCurX();
+ SCROW nRow = aViewData.GetCurY();
+ SCTAB nTab = aViewData.GetTabNo();
+ long nPosX = 0;
+ for (SCCOL i=0; i<nCol; i++)
+ nPosX += pDoc->GetColWidth(i,nTab);
+ nPosX = (long)(nPosX * HMM_PER_TWIPS);
+ if ( pDoc->IsNegativePage( nTab ) )
+ nPosX = -nPosX;
+ long nPosY = (long) pDoc->GetRowHeight( 0, nRow-1, nTab);
+ nPosY = (long)(nPosY * HMM_PER_TWIPS);
+ return Point(nPosX,nPosY);
+}
+
+Point ScTabView::GetChartInsertPos( const Size& rSize, const ScRange& rCellRange )
+{
+ Point aInsertPos;
+ const long nBorder = 100; // leave 1mm for border
+ long nNeededWidth = rSize.Width() + 2 * nBorder;
+ long nNeededHeight = rSize.Height() + 2 * nBorder;
+
+ // use the active window, or lower/right if frozen (as in CalcZoom)
+ ScSplitPos eUsedPart = aViewData.GetActivePart();
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+
+ ScGridWindow* pWin = pGridWin[eUsedPart];
+ DBG_ASSERT( pWin, "Window not found" );
+ if (pWin)
+ {
+ ActivatePart( eUsedPart );
+
+ // get the visible rectangle in logic units
+
+ MapMode aDrawMode = pWin->GetDrawMapMode();
+ Rectangle aVisible( pWin->PixelToLogic( Rectangle( Point(0,0), pWin->GetOutputSizePixel() ), aDrawMode ) );
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ long nDocX = (long)( (double) pDoc->GetColOffset( MAXCOL + 1, nTab ) * HMM_PER_TWIPS ) * nLayoutSign;
+ long nDocY = (long)( (double) pDoc->GetRowOffset( MAXROW + 1, nTab ) * HMM_PER_TWIPS );
+
+ if ( aVisible.Left() * nLayoutSign > nDocX * nLayoutSign )
+ aVisible.Left() = nDocX;
+ if ( aVisible.Right() * nLayoutSign > nDocX * nLayoutSign )
+ aVisible.Right() = nDocX;
+ if ( aVisible.Top() > nDocY )
+ aVisible.Top() = nDocY;
+ if ( aVisible.Bottom() > nDocY )
+ aVisible.Bottom() = nDocY;
+
+ // get the logic position of the selection
+
+ Rectangle aSelection = pDoc->GetMMRect( rCellRange.aStart.Col(), rCellRange.aStart.Row(),
+ rCellRange.aEnd.Col(), rCellRange.aEnd.Row(), nTab );
+
+ long nLeftSpace = aSelection.Left() - aVisible.Left();
+ long nRightSpace = aVisible.Right() - aSelection.Right();
+ long nTopSpace = aSelection.Top() - aVisible.Top();
+ long nBottomSpace = aVisible.Bottom() - aSelection.Bottom();
+
+ bool bFitLeft = ( nLeftSpace >= nNeededWidth );
+ bool bFitRight = ( nRightSpace >= nNeededWidth );
+
+ if ( bFitLeft || bFitRight )
+ {
+ // first preference: completely left or right of the selection
+
+ // if both fit, prefer left in RTL mode, right otherwise
+ bool bPutLeft = bFitLeft && ( bLayoutRTL || !bFitRight );
+
+ if ( bPutLeft )
+ aInsertPos.X() = aSelection.Left() - nNeededWidth;
+ else
+ aInsertPos.X() = aSelection.Right() + 1;
+
+ // align with top of selection (is moved again if it doesn't fit)
+ aInsertPos.Y() = std::max( aSelection.Top(), aVisible.Top() );
+ }
+ else if ( nTopSpace >= nNeededHeight || nBottomSpace >= nNeededHeight )
+ {
+ // second preference: completely above or below the selection
+
+ if ( nBottomSpace > nNeededHeight ) // bottom is preferred
+ aInsertPos.Y() = aSelection.Bottom() + 1;
+ else
+ aInsertPos.Y() = aSelection.Top() - nNeededHeight;
+
+ // align with (logic) left edge of selection (moved again if it doesn't fit)
+ if ( bLayoutRTL )
+ aInsertPos.X() = std::min( aSelection.Right(), aVisible.Right() ) - nNeededWidth + 1;
+ else
+ aInsertPos.X() = std::max( aSelection.Left(), aVisible.Left() );
+ }
+ else
+ {
+ // place to the (logic) right of the selection and move so it fits
+
+ if ( bLayoutRTL )
+ aInsertPos.X() = aSelection.Left() - nNeededWidth;
+ else
+ aInsertPos.X() = aSelection.Right() + 1;
+ aInsertPos.Y() = std::max( aSelection.Top(), aVisible.Top() );
+ }
+
+ // move the position if the object doesn't fit in the screen
+
+ Rectangle aCompareRect( aInsertPos, Size( nNeededWidth, nNeededHeight ) );
+ if ( aCompareRect.Right() > aVisible.Right() )
+ aInsertPos.X() -= aCompareRect.Right() - aVisible.Right();
+ if ( aCompareRect.Bottom() > aVisible.Bottom() )
+ aInsertPos.Y() -= aCompareRect.Bottom() - aVisible.Bottom();
+
+ if ( aInsertPos.X() < aVisible.Left() )
+ aInsertPos.X() = aVisible.Left();
+ if ( aInsertPos.Y() < aVisible.Top() )
+ aInsertPos.Y() = aVisible.Top();
+
+ // nNeededWidth / nNeededHeight includes all borders - move aInsertPos to the
+ // object position, inside the border
+
+ aInsertPos.X() += nBorder;
+ aInsertPos.Y() += nBorder;
+ }
+ return aInsertPos;
+}
+
+Point ScTabView::GetChartDialogPos( const Size& rDialogSize, const Rectangle& rLogicChart )
+{
+ // rDialogSize must be in pixels, rLogicChart in 1/100 mm. Return value is in pixels.
+
+ Point aRet;
+
+ // use the active window, or lower/right if frozen (as in CalcZoom)
+ ScSplitPos eUsedPart = aViewData.GetActivePart();
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+
+ ScGridWindow* pWin = pGridWin[eUsedPart];
+ DBG_ASSERT( pWin, "Window not found" );
+ if (pWin)
+ {
+ MapMode aDrawMode = pWin->GetDrawMapMode();
+ Rectangle aObjPixel = pWin->LogicToPixel( rLogicChart, aDrawMode );
+ Rectangle aObjAbs( pWin->OutputToAbsoluteScreenPixel( aObjPixel.TopLeft() ),
+ pWin->OutputToAbsoluteScreenPixel( aObjPixel.BottomRight() ) );
+
+ Rectangle aDesktop = pWin->GetDesktopRectPixel();
+ Size aSpace = pWin->LogicToPixel( Size( 8, 12 ), MAP_APPFONT );
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTab );
+
+ bool bCenterHor = false;
+
+ if ( aDesktop.Bottom() - aObjAbs.Bottom() >= rDialogSize.Height() + aSpace.Height() )
+ {
+ // first preference: below the chart
+
+ aRet.Y() = aObjAbs.Bottom() + aSpace.Height();
+ bCenterHor = true;
+ }
+ else if ( aObjAbs.Top() - aDesktop.Top() >= rDialogSize.Height() + aSpace.Height() )
+ {
+ // second preference: above the chart
+
+ aRet.Y() = aObjAbs.Top() - rDialogSize.Height() - aSpace.Height();
+ bCenterHor = true;
+ }
+ else
+ {
+ bool bFitLeft = ( aObjAbs.Left() - aDesktop.Left() >= rDialogSize.Width() + aSpace.Width() );
+ bool bFitRight = ( aDesktop.Right() - aObjAbs.Right() >= rDialogSize.Width() + aSpace.Width() );
+
+ if ( bFitLeft || bFitRight )
+ {
+ // if both fit, prefer right in RTL mode, left otherwise
+ bool bPutRight = bFitRight && ( bLayoutRTL || !bFitLeft );
+ if ( bPutRight )
+ aRet.X() = aObjAbs.Right() + aSpace.Width();
+ else
+ aRet.X() = aObjAbs.Left() - rDialogSize.Width() - aSpace.Width();
+
+ // center vertically
+ aRet.Y() = aObjAbs.Top() + ( aObjAbs.GetHeight() - rDialogSize.Height() ) / 2;
+ }
+ else
+ {
+ // doesn't fit on any edge - put at the bottom of the screen
+ aRet.Y() = aDesktop.Bottom() - rDialogSize.Height();
+ bCenterHor = true;
+ }
+ }
+ if ( bCenterHor )
+ aRet.X() = aObjAbs.Left() + ( aObjAbs.GetWidth() - rDialogSize.Width() ) / 2;
+
+ // limit to screen (centering might lead to invalid positions)
+ if ( aRet.X() + rDialogSize.Width() - 1 > aDesktop.Right() )
+ aRet.X() = aDesktop.Right() - rDialogSize.Width() + 1;
+ if ( aRet.X() < aDesktop.Left() )
+ aRet.X() = aDesktop.Left();
+ if ( aRet.Y() + rDialogSize.Height() - 1 > aDesktop.Bottom() )
+ aRet.Y() = aDesktop.Bottom() - rDialogSize.Height() + 1;
+ if ( aRet.Y() < aDesktop.Top() )
+ aRet.Y() = aDesktop.Top();
+ }
+
+ return aRet;
+}
+
+void ScTabView::LockModifiers( USHORT nModifiers )
+{
+ pSelEngine->LockModifiers( nModifiers );
+ pHdrSelEng->LockModifiers( nModifiers );
+}
+
+USHORT ScTabView::GetLockedModifiers() const
+{
+ return pSelEngine->GetLockedModifiers();
+}
+
+Point ScTabView::GetMousePosPixel()
+{
+ Point aPos;
+ ScGridWindow* pWin = (ScGridWindow*)GetActiveWin();
+
+ if ( pWin )
+ aPos = pWin->GetMousePosPixel();
+
+ return aPos;
+}
+
+BOOL lcl_MouseIsOverWin( const Point& rScreenPosPixel, Window* pWin )
+{
+ if (pWin)
+ {
+ // SPLIT_HANDLE_SIZE draufaddieren, damit das Einrasten genau
+ // auf dem Splitter nicht aussetzt
+
+ Point aRel = pWin->NormalizedScreenToOutputPixel( rScreenPosPixel );
+ Size aWinSize = pWin->GetOutputSizePixel();
+ if ( aRel.X() >= 0 && aRel.X() < aWinSize.Width() + SPLIT_HANDLE_SIZE &&
+ aRel.Y() >= 0 && aRel.Y() < aWinSize.Height() + SPLIT_HANDLE_SIZE )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void ScTabView::SnapSplitPos( Point& rScreenPosPixel )
+{
+ BOOL bOverWin = FALSE;
+ USHORT i;
+ for (i=0; i<4; i++)
+ if (lcl_MouseIsOverWin(rScreenPosPixel,pGridWin[i]))
+ bOverWin = TRUE;
+
+ if (!bOverWin)
+ return;
+
+ // #74761# don't snap to cells if the scale will be modified afterwards
+ if ( GetZoomType() != SVX_ZOOM_PERCENT )
+ return;
+
+ ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ ePos = SC_SPLIT_TOPLEFT;
+
+ Window* pWin = pGridWin[ePos];
+ if (!pWin)
+ {
+ DBG_ERROR("Window NULL");
+ return;
+ }
+
+ Point aMouse = pWin->NormalizedScreenToOutputPixel( rScreenPosPixel );
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ // #52949# bNextIfLarge=FALSE: nicht auf naechste Zelle, wenn ausserhalb des Fensters
+ aViewData.GetPosFromPixel( aMouse.X(), aMouse.Y(), ePos, nPosX, nPosY, TRUE, FALSE, FALSE );
+ BOOL bLeft;
+ BOOL bTop;
+ aViewData.GetMouseQuadrant( aMouse, ePos, nPosX, nPosY, bLeft, bTop );
+ if (!bLeft)
+ ++nPosX;
+ if (!bTop)
+ ++nPosY;
+ aMouse = aViewData.GetScrPos( static_cast<SCCOL>(nPosX), static_cast<SCROW>(nPosY), ePos, TRUE );
+ rScreenPosPixel = pWin->OutputToNormalizedScreenPixel( aMouse );
+}
+
+void ScTabView::FreezeSplitters( BOOL bFreeze )
+{
+ ScSplitMode eOldH = aViewData.GetHSplitMode();
+ ScSplitMode eOldV = aViewData.GetVSplitMode();
+
+ ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
+ if ( eOldV != SC_SPLIT_NONE )
+ ePos = SC_SPLIT_TOPLEFT;
+ Window* pWin = pGridWin[ePos];
+
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+
+ if ( bFreeze )
+ {
+ Point aWinStart = pWin->GetPosPixel();
+
+ Point aSplit;
+ SCsCOL nPosX;
+ SCsROW nPosY;
+ if (eOldH != SC_SPLIT_NONE || eOldV != SC_SPLIT_NONE)
+ {
+ if (eOldH != SC_SPLIT_NONE)
+ {
+ long nSplitPos = aViewData.GetHSplitPos();
+ if ( bLayoutRTL )
+ nSplitPos = pFrameWin->GetOutputSizePixel().Width() - nSplitPos - 1;
+ aSplit.X() = nSplitPos - aWinStart.X();
+ }
+ if (eOldV != SC_SPLIT_NONE)
+ aSplit.Y() = aViewData.GetVSplitPos() - aWinStart.Y();
+
+ aViewData.GetPosFromPixel( aSplit.X(), aSplit.Y(), ePos, nPosX, nPosY );
+ BOOL bLeft;
+ BOOL bTop;
+ aViewData.GetMouseQuadrant( aSplit, ePos, nPosX, nPosY, bLeft, bTop );
+ if (!bLeft)
+ ++nPosX;
+ if (!bTop)
+ ++nPosY;
+ }
+ else
+ {
+ nPosX = static_cast<SCsCOL>( aViewData.GetCurX());
+ nPosY = static_cast<SCsROW>( aViewData.GetCurY());
+ }
+
+ SCCOL nLeftPos = aViewData.GetPosX(SC_SPLIT_LEFT);
+ SCROW nTopPos = aViewData.GetPosY(SC_SPLIT_BOTTOM);
+ SCCOL nRightPos = static_cast<SCCOL>(nPosX);
+ SCROW nBottomPos = static_cast<SCROW>(nPosY);
+ if (eOldH != SC_SPLIT_NONE)
+ if (aViewData.GetPosX(SC_SPLIT_RIGHT) > nRightPos)
+ nRightPos = aViewData.GetPosX(SC_SPLIT_RIGHT);
+ if (eOldV != SC_SPLIT_NONE)
+ {
+ nTopPos = aViewData.GetPosY(SC_SPLIT_TOP);
+ if (aViewData.GetPosY(SC_SPLIT_BOTTOM) > nBottomPos)
+ nBottomPos = aViewData.GetPosY(SC_SPLIT_BOTTOM);
+ }
+
+ aSplit = aViewData.GetScrPos( static_cast<SCCOL>(nPosX), static_cast<SCROW>(nPosY), ePos, TRUE );
+ if (nPosX > aViewData.GetPosX(SC_SPLIT_LEFT)) // (aSplit.X() > 0) doesn't work for RTL
+ {
+ long nSplitPos = aSplit.X() + aWinStart.X();
+ if ( bLayoutRTL )
+ nSplitPos = pFrameWin->GetOutputSizePixel().Width() - nSplitPos - 1;
+
+ aViewData.SetHSplitMode( SC_SPLIT_FIX );
+ aViewData.SetHSplitPos( nSplitPos );
+ aViewData.SetFixPosX( nPosX );
+
+ aViewData.SetPosX(SC_SPLIT_LEFT, nLeftPos);
+ aViewData.SetPosX(SC_SPLIT_RIGHT, nRightPos);
+ }
+ else
+ aViewData.SetHSplitMode( SC_SPLIT_NONE );
+ if (aSplit.Y() > 0)
+ {
+ aViewData.SetVSplitMode( SC_SPLIT_FIX );
+ aViewData.SetVSplitPos( aSplit.Y() + aWinStart.Y() );
+ aViewData.SetFixPosY( nPosY );
+
+ aViewData.SetPosY(SC_SPLIT_TOP, nTopPos);
+ aViewData.SetPosY(SC_SPLIT_BOTTOM, nBottomPos);
+ }
+ else
+ aViewData.SetVSplitMode( SC_SPLIT_NONE );
+ }
+ else // Fixierung aufheben
+ {
+ if ( eOldH == SC_SPLIT_FIX )
+ aViewData.SetHSplitMode( SC_SPLIT_NORMAL );
+ if ( eOldV == SC_SPLIT_FIX )
+ aViewData.SetVSplitMode( SC_SPLIT_NORMAL );
+ }
+
+ // #61410# Form-Layer muss den sichtbaren Ausschnitt aller Fenster kennen
+ // dafuer muss hier schon der MapMode stimmen
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+ SetNewVisArea();
+
+ RepeatResize(FALSE);
+
+ UpdateShow();
+ PaintLeft();
+ PaintTop();
+ PaintGrid();
+
+ // SC_FOLLOW_NONE: only update active part
+ AlignToCursor( aViewData.GetCurX(), aViewData.GetCurY(), SC_FOLLOW_NONE );
+ UpdateAutoFillMark();
+
+ InvalidateSplit();
+}
+
+void ScTabView::RemoveSplit()
+{
+ DoHSplit( 0 );
+ DoVSplit( 0 );
+ RepeatResize();
+}
+
+void ScTabView::SplitAtCursor()
+{
+ ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
+ if ( aViewData.GetVSplitMode() != SC_SPLIT_NONE )
+ ePos = SC_SPLIT_TOPLEFT;
+ Window* pWin = pGridWin[ePos];
+ Point aWinStart = pWin->GetPosPixel();
+
+ SCCOL nPosX = aViewData.GetCurX();
+ SCROW nPosY = aViewData.GetCurY();
+ Point aSplit = aViewData.GetScrPos( nPosX, nPosY, ePos, TRUE );
+ if ( nPosX > 0 )
+ DoHSplit( aSplit.X() + aWinStart.X() );
+ else
+ DoHSplit( 0 );
+ if ( nPosY > 0 )
+ DoVSplit( aSplit.Y() + aWinStart.Y() );
+ else
+ DoVSplit( 0 );
+ RepeatResize();
+}
+
+void ScTabView::SplitAtPixel( const Point& rPixel, BOOL bHor, BOOL bVer ) // fuer API
+{
+ // Pixel ist auf die ganze View bezogen, nicht auf das erste GridWin
+
+ if (bHor)
+ {
+ if ( rPixel.X() > 0 )
+ DoHSplit( rPixel.X() );
+ else
+ DoHSplit( 0 );
+ }
+ if (bVer)
+ {
+ if ( rPixel.Y() > 0 )
+ DoVSplit( rPixel.Y() );
+ else
+ DoVSplit( 0 );
+ }
+ RepeatResize();
+}
+
+void ScTabView::InvalidateSplit()
+{
+ SfxBindings& rBindings = aViewData.GetBindings();
+ rBindings.Invalidate( SID_WINDOW_SPLIT );
+ rBindings.Invalidate( SID_WINDOW_FIX );
+
+ pHSplitter->SetFixed( aViewData.GetHSplitMode() == SC_SPLIT_FIX );
+ pVSplitter->SetFixed( aViewData.GetVSplitMode() == SC_SPLIT_FIX );
+}
+
+void ScTabView::SetNewVisArea()
+{
+ // #63854# fuer die Controls muss bei VisAreaChanged der Draw-MapMode eingestellt sein
+ // (auch wenn ansonsten der Edit-MapMode gesetzt ist)
+ MapMode aOldMode[4];
+ MapMode aDrawMode[4];
+ USHORT i;
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ {
+ aOldMode[i] = pGridWin[i]->GetMapMode();
+ aDrawMode[i] = pGridWin[i]->GetDrawMapMode();
+ if (aDrawMode[i] != aOldMode[i])
+ pGridWin[i]->SetMapMode(aDrawMode[i]);
+ }
+
+ Window* pActive = pGridWin[aViewData.GetActivePart()];
+ if (pActive)
+ aViewData.GetViewShell()->VisAreaChanged(
+ pActive->PixelToLogic(Rectangle(Point(),pActive->GetOutputSizePixel())) );
+ if (pDrawView)
+ pDrawView->VisAreaChanged(); // kein Window uebergeben -> alle Fenster
+
+ UpdateAllOverlays(); // #i79909# with drawing MapMode set
+
+ for (i=0; i<4; i++)
+ if (pGridWin[i] && aDrawMode[i] != aOldMode[i])
+ {
+ pGridWin[i]->flushOverlayManager(); // #i79909# flush overlays before switching to edit MapMode
+ pGridWin[i]->SetMapMode(aOldMode[i]);
+ }
+
+ SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
+ if (pViewFrame)
+ {
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ com::sun::star::uno::Reference<com::sun::star::frame::XController> xController = rFrame.GetController();
+ if (xController.is())
+ {
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->VisAreaChanged();
+ }
+ }
+ if (aViewData.GetViewShell()->HasAccessibilityObjects())
+ aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_VISAREACHANGED));
+}
+
+sal_Bool ScTabView::HasPageFieldDataAtCursor() const
+{
+ ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
+ SCCOL nCol = aViewData.GetCurX();
+ SCROW nRow = aViewData.GetCurY();
+ if (pWin)
+ return pWin->GetDPFieldOrientation( nCol, nRow ) == sheet::DataPilotFieldOrientation_PAGE;
+
+ return sal_False;
+}
+
+void ScTabView::StartDataSelect()
+{
+ ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
+ SCCOL nCol = aViewData.GetCurX();
+ SCROW nRow = aViewData.GetCurY();
+
+ if (!pWin)
+ return;
+
+ switch (pWin->GetDPFieldOrientation(nCol, nRow))
+ {
+ case sheet::DataPilotFieldOrientation_PAGE:
+ // #i36598# If the cursor is on a page field's data cell,
+ // no meaningful input is possible anyway, so this function
+ // can be used to select a page field entry.
+ pWin->LaunchPageFieldMenu( nCol, nRow );
+ break;
+ case sheet::DataPilotFieldOrientation_COLUMN:
+ case sheet::DataPilotFieldOrientation_ROW:
+ pWin->LaunchDPFieldMenu( nCol, nRow );
+ break;
+ default:
+ pWin->DoAutoFilterMenue( nCol, nRow, TRUE );
+ }
+}
+
+void ScTabView::EnableRefInput(BOOL bFlag)
+{
+ aHScrollLeft.EnableInput(bFlag);
+ aHScrollRight.EnableInput(bFlag);
+ aVScrollBottom.EnableInput(bFlag);
+ aVScrollTop.EnableInput(bFlag);
+ aScrollBarBox.EnableInput(bFlag);
+
+ // ab hier dynamisch angelegte
+
+ if(pTabControl!=NULL) pTabControl->EnableInput(bFlag,TRUE);
+
+ if(pGridWin[SC_SPLIT_BOTTOMLEFT]!=NULL)
+ pGridWin[SC_SPLIT_BOTTOMLEFT]->EnableInput(bFlag,FALSE);
+ if(pGridWin[SC_SPLIT_BOTTOMRIGHT]!=NULL)
+ pGridWin[SC_SPLIT_BOTTOMRIGHT]->EnableInput(bFlag,FALSE);
+ if(pGridWin[SC_SPLIT_TOPLEFT]!=NULL)
+ pGridWin[SC_SPLIT_TOPLEFT]->EnableInput(bFlag,FALSE);
+ if(pGridWin[SC_SPLIT_TOPRIGHT]!=NULL)
+ pGridWin[SC_SPLIT_TOPRIGHT]->EnableInput(bFlag,FALSE);
+ if(pColBar[SC_SPLIT_RIGHT]!=NULL)
+ pColBar[SC_SPLIT_RIGHT]->EnableInput(bFlag,FALSE);
+ if(pRowBar[SC_SPLIT_TOP]!=NULL)
+ pRowBar[SC_SPLIT_TOP]->EnableInput(bFlag,FALSE);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
new file mode 100644
index 000000000000..a42cb4667c1a
--- /dev/null
+++ b/sc/source/ui/view/tabview2.cxx
@@ -0,0 +1,1434 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <vcl/timer.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/childwin.hxx>
+
+#include "attrib.hxx"
+#include "pagedata.hxx"
+#include "tabview.hxx"
+#include "tabvwsh.hxx"
+#include "printfun.hxx"
+#include "stlpool.hxx"
+#include "docsh.hxx"
+#include "gridwin.hxx"
+#include "olinewin.hxx"
+#include "uiitems.hxx"
+#include "sc.hrc"
+#include "viewutil.hxx"
+#include "colrowba.hxx"
+#include "waitoff.hxx"
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "tabprotection.hxx"
+
+#define SC_BLOCKMODE_NONE 0
+#define SC_BLOCKMODE_NORMAL 1
+#define SC_BLOCKMODE_OWN 2
+
+
+
+//
+// Markier - Funktionen
+//
+
+void ScTabView::PaintMarks(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
+{
+ if (!ValidCol(nStartCol)) nStartCol = MAXCOL;
+ if (!ValidRow(nStartRow)) nStartRow = MAXROW;
+ if (!ValidCol(nEndCol)) nEndCol = MAXCOL;
+ if (!ValidRow(nEndRow)) nEndRow = MAXROW;
+
+ BOOL bLeft = (nStartCol==0 && nEndCol==MAXCOL);
+ BOOL bTop = (nStartRow==0 && nEndRow==MAXROW);
+
+ if (bLeft)
+ PaintLeftArea( nStartRow, nEndRow );
+ if (bTop)
+ PaintTopArea( nStartCol, nEndCol );
+
+ aViewData.GetDocument()->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow,
+ aViewData.GetTabNo() );
+ PaintArea( nStartCol, nStartRow, nEndCol, nEndRow, SC_UPDATE_MARKS );
+}
+
+BOOL ScTabView::IsMarking( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
+{
+ return bIsBlockMode
+ && nBlockStartX == nCol
+ && nBlockStartY == nRow
+ && nBlockStartZ == nTab;
+}
+
+void ScTabView::InitOwnBlockMode()
+{
+ if (!bIsBlockMode)
+ {
+ // Wenn keine (alte) Markierung mehr da ist, Anker in SelectionEngine loeschen:
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ if (!rMark.IsMarked() && !rMark.IsMultiMarked())
+ GetSelEngine()->CursorPosChanging( FALSE, FALSE );
+
+// bIsBlockMode = TRUE;
+ bIsBlockMode = SC_BLOCKMODE_OWN; //! Variable umbenennen!
+ nBlockStartX = 0;
+ nBlockStartY = 0;
+ nBlockStartZ = 0;
+ nBlockEndX = 0;
+ nBlockEndY = 0;
+ nBlockEndZ = 0;
+
+ SelectionChanged(); // Status wird mit gesetzer Markierung abgefragt
+ }
+}
+
+void ScTabView::InitBlockMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
+ BOOL bTestNeg, BOOL bCols, BOOL bRows )
+{
+ if (!bIsBlockMode)
+ {
+ if (!ValidCol(nCurX)) nCurX = MAXCOL;
+ if (!ValidRow(nCurY)) nCurY = MAXROW;
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ // Teil von Markierung aufheben?
+ if (bTestNeg)
+ {
+ if ( bCols )
+ bBlockNeg = rMark.IsColumnMarked( nCurX );
+ else if ( bRows )
+ bBlockNeg = rMark.IsRowMarked( nCurY );
+ else
+ bBlockNeg = rMark.IsCellMarked( nCurX, nCurY );
+ }
+ else
+ bBlockNeg = FALSE;
+ rMark.SetMarkNegative(bBlockNeg);
+
+// bIsBlockMode = TRUE;
+ bIsBlockMode = SC_BLOCKMODE_NORMAL; //! Variable umbenennen!
+ bBlockCols = bCols;
+ bBlockRows = bRows;
+ nBlockStartX = nBlockStartXOrig = nCurX;
+ nBlockStartY = nBlockStartYOrig = nCurY;
+ nBlockStartZ = nCurZ;
+ nBlockEndX = nOldCurX = nBlockStartX;
+ nBlockEndY = nOldCurY = nBlockStartY;
+ nBlockEndZ = nBlockStartZ;
+
+ if (bBlockCols)
+ {
+ nBlockStartY = nBlockStartYOrig = 0;
+ nBlockEndY = MAXROW;
+ }
+
+ if (bBlockRows)
+ {
+ nBlockStartX = nBlockStartXOrig = 0;
+ nBlockEndX = MAXCOL;
+ }
+
+ rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab, nBlockEndX,nBlockEndY, nTab ) );
+
+#ifdef OLD_SELECTION_PAINT
+ InvertBlockMark( nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY );
+#endif
+ UpdateSelectionOverlay();
+ }
+}
+
+void ScTabView::DoneBlockMode( BOOL bContinue ) // Default FALSE
+{
+ // Wenn zwischen Tabellen- und Header SelectionEngine gewechselt wird,
+ // wird evtl. DeselectAll gerufen, weil die andere Engine keinen Anker hat.
+ // Mit bMoveIsShift wird verhindert, dass dann die Selektion aufgehoben wird.
+
+ if (bIsBlockMode && !bMoveIsShift)
+ {
+ ScMarkData& rMark = aViewData.GetMarkData();
+ BOOL bFlag = rMark.GetMarkingFlag();
+ rMark.SetMarking(FALSE);
+
+ if (bBlockNeg && !bContinue)
+ rMark.MarkToMulti();
+
+ if (bContinue)
+ rMark.MarkToMulti();
+ else
+ {
+ // Die Tabelle kann an dieser Stelle ungueltig sein, weil DoneBlockMode
+ // aus SetTabNo aufgerufen wird
+ // (z.B. wenn die aktuelle Tabelle von einer anderen View aus geloescht wird)
+
+ SCTAB nTab = aViewData.GetTabNo();
+ ScDocument* pDoc = aViewData.GetDocument();
+ if ( pDoc->HasTable(nTab) )
+ PaintBlock( TRUE ); // TRUE -> Block loeschen
+ else
+ rMark.ResetMark();
+ }
+// bIsBlockMode = FALSE;
+ bIsBlockMode = SC_BLOCKMODE_NONE; //! Variable umbenennen!
+
+ rMark.SetMarking(bFlag);
+ rMark.SetMarkNegative(FALSE);
+ }
+}
+
+void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
+ BOOL bCols, BOOL bRows, BOOL bCellSelection )
+{
+ if (!ValidCol(nCurX)) nCurX = MAXCOL;
+ if (!ValidRow(nCurY)) nCurY = MAXROW;
+
+ if (!bIsBlockMode)
+ {
+ DBG_ERROR( "MarkCursor nicht im BlockMode" );
+ InitBlockMode( nCurX, nCurY, nCurZ, FALSE, bCols, bRows );
+ }
+
+ if (bCols)
+ nCurY = MAXROW;
+ if (bRows)
+ nCurX = MAXCOL;
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ DBG_ASSERT(rMark.IsMarked() || rMark.IsMultiMarked(), "MarkCursor, !IsMarked()");
+ ScRange aMarkRange;
+ rMark.GetMarkArea(aMarkRange);
+ if (( aMarkRange.aStart.Col() != nBlockStartX && aMarkRange.aEnd.Col() != nBlockStartX ) ||
+ ( aMarkRange.aStart.Row() != nBlockStartY && aMarkRange.aEnd.Row() != nBlockStartY ) ||
+ ( bIsBlockMode == SC_BLOCKMODE_OWN ))
+ {
+ // Markierung ist veraendert worden
+ // (z.B. MarkToSimple, wenn per negativ alles bis auf ein Rechteck geloescht wurde)
+ // oder nach InitOwnBlockMode wird mit Shift-Klick weitermarkiert...
+
+ BOOL bOldShift = bMoveIsShift;
+ bMoveIsShift = FALSE; // wirklich umsetzen
+ DoneBlockMode(FALSE); //! direkt Variablen setzen? (-> kein Geflacker)
+ bMoveIsShift = bOldShift;
+
+ InitBlockMode( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+ nBlockStartZ, rMark.IsMarkNegative(), bCols, bRows );
+ }
+
+ SCCOL nOldBlockEndX = nBlockEndX;
+ SCROW nOldBlockEndY = nBlockEndY;
+
+ if ( nCurX != nOldCurX || nCurY != nOldCurY )
+ {
+ // Current cursor has moved
+
+ SCTAB nTab = nCurZ;
+
+#ifdef OLD_SELECTION_PAINT
+ SCCOL nDrawStartCol;
+ SCROW nDrawStartRow;
+ SCCOL nDrawEndCol;
+ SCROW nDrawEndRow;
+#endif
+
+ // Set old selection area
+ ScUpdateRect aRect( nBlockStartX, nBlockStartY, nOldBlockEndX, nOldBlockEndY );
+
+ if ( bCellSelection )
+ {
+ // Expand selection area accordingly when the current selection ends
+ // with a merged cell.
+ SCsCOL nCurXOffset = 0;
+ SCsCOL nBlockStartXOffset = 0;
+ SCsROW nCurYOffset = 0;
+ SCsROW nBlockStartYOffset = 0;
+ BOOL bBlockStartMerged = FALSE;
+ const ScMergeAttr* pMergeAttr = NULL;
+ ScDocument* pDocument = aViewData.GetDocument();
+
+ // The following block checks whether or not the "BlockStart" (anchor)
+ // cell is merged. If it's merged, it'll then move the position of the
+ // anchor cell to the corner that's diagonally opposite of the
+ // direction of a current selection area. For instance, if a current
+ // selection is moving in the upperleft direction, the anchor cell will
+ // move to the lower-right corner of the merged anchor cell, and so on.
+
+ pMergeAttr = static_cast<const ScMergeAttr*>(
+ pDocument->GetAttr( nBlockStartXOrig, nBlockStartYOrig, nTab, ATTR_MERGE ) );
+ if ( pMergeAttr->IsMerged() )
+ {
+ SCsCOL nColSpan = pMergeAttr->GetColMerge();
+ SCsROW nRowSpan = pMergeAttr->GetRowMerge();
+
+ if ( !( nCurX >= nBlockStartXOrig + nColSpan - 1 && nCurY >= nBlockStartYOrig + nRowSpan - 1 ) )
+ {
+ nBlockStartX = nCurX >= nBlockStartXOrig ? nBlockStartXOrig : nBlockStartXOrig + nColSpan - 1;
+ nBlockStartY = nCurY >= nBlockStartYOrig ? nBlockStartYOrig : nBlockStartYOrig + nRowSpan - 1;
+ nCurXOffset = nCurX >= nBlockStartXOrig && nCurX < nBlockStartXOrig + nColSpan - 1 ?
+ nBlockStartXOrig - nCurX + nColSpan - 1 : 0;
+ nCurYOffset = nCurY >= nBlockStartYOrig && nCurY < nBlockStartYOrig + nRowSpan - 1 ?
+ nBlockStartYOrig - nCurY + nRowSpan - 1 : 0;
+ bBlockStartMerged = TRUE;
+ }
+ }
+
+ // The following block checks whether or not the current cell is
+ // merged. If it is, it'll then set the appropriate X & Y offset
+ // values (nCurXOffset & nCurYOffset) such that the selection area will
+ // grow by those specified offset amounts. Note that the values of
+ // nCurXOffset/nCurYOffset may also be specified in the previous code
+ // block, in which case whichever value is greater will take on.
+
+ pMergeAttr = static_cast<const ScMergeAttr*>(
+ pDocument->GetAttr( nCurX, nCurY, nTab, ATTR_MERGE ) );
+ if ( pMergeAttr->IsMerged() )
+ {
+ SCsCOL nColSpan = pMergeAttr->GetColMerge();
+ SCsROW nRowSpan = pMergeAttr->GetRowMerge();
+
+ if ( !( nBlockStartX >= nCurX + nColSpan - 1 && nBlockStartY >= nCurY + nRowSpan - 1 ) )
+ {
+ if ( nBlockStartX <= nCurX + nColSpan - 1 )
+ {
+ SCsCOL nCurXOffsetTemp = nCurX < nCurX + nColSpan - 1 ? nColSpan - 1 : 0;
+ nCurXOffset = nCurXOffset > nCurXOffsetTemp ? nCurXOffset : nCurXOffsetTemp;
+ }
+ if ( nBlockStartY <= nCurY + nRowSpan - 1 )
+ {
+ SCsROW nCurYOffsetTemp = nCurY < nCurY + nRowSpan - 1 ? nRowSpan - 1 : 0;
+ nCurYOffset = nCurYOffset > nCurYOffsetTemp ? nCurYOffset : nCurYOffsetTemp;
+ }
+ if ( !( nBlockStartX <= nCurX && nBlockStartY <= nCurY ) &&
+ !( nBlockStartX > nCurX + nColSpan - 1 && nBlockStartY > nCurY + nRowSpan - 1 ) )
+ {
+ nBlockStartXOffset = nBlockStartX > nCurX && nBlockStartX <= nCurX + nColSpan - 1 ? nCurX - nBlockStartX : 0;
+ nBlockStartYOffset = nBlockStartY > nCurY && nBlockStartY <= nCurY + nRowSpan - 1 ? nCurY - nBlockStartY : 0;
+ }
+ }
+ }
+ else
+ {
+ // The current cell is not merged. Move the anchor cell to its
+ // original position.
+ if ( !bBlockStartMerged )
+ {
+ nBlockStartX = nBlockStartXOrig;
+ nBlockStartY = nBlockStartYOrig;
+ }
+ }
+
+ nBlockStartX = nBlockStartX + nBlockStartXOffset >= 0 ? nBlockStartX + nBlockStartXOffset : 0;
+ nBlockStartY = nBlockStartY + nBlockStartYOffset >= 0 ? nBlockStartY + nBlockStartYOffset : 0;
+ nBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
+ nBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
+ }
+ else
+ {
+ nBlockEndX = nCurX;
+ nBlockEndY = nCurY;
+ }
+ // end of "if ( bCellSelection )"
+
+ // Set new selection area
+ aRect.SetNew( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY );
+ rMark.SetMarkArea( ScRange( nBlockStartX, nBlockStartY, nTab, nBlockEndX, nBlockEndY, nTab ) );
+
+#ifdef OLD_SELECTION_PAINT
+ BOOL bCont;
+ BOOL bDraw = aRect.GetXorDiff( nDrawStartCol, nDrawStartRow,
+ nDrawEndCol, nDrawEndRow, bCont );
+ if ( bDraw )
+ {
+//? PutInOrder( nDrawStartCol, nDrawEndCol );
+//? PutInOrder( nDrawStartRow, nDrawEndRow );
+
+ HideAllCursors();
+ InvertBlockMark( nDrawStartCol, nDrawStartRow, nDrawEndCol, nDrawEndRow );
+ if (bCont)
+ {
+ aRect.GetContDiff( nDrawStartCol, nDrawStartRow, nDrawEndCol, nDrawEndRow );
+ InvertBlockMark( nDrawStartCol, nDrawStartRow, nDrawEndCol, nDrawEndRow );
+ }
+ ShowAllCursors();
+ }
+#endif
+ UpdateSelectionOverlay();
+
+ nOldCurX = nCurX;
+ nOldCurY = nCurY;
+
+ aViewData.GetViewShell()->UpdateInputHandler();
+// InvalidateAttribs();
+ }
+
+ if ( !bCols && !bRows )
+ aHdrFunc.SetAnchorFlag( FALSE );
+}
+
+void ScTabView::GetPageMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, SCsCOL& rPageX, SCsROW& rPageY)
+{
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+
+ ScSplitPos eWhich = aViewData.GetActivePart();
+ ScHSplitPos eWhichX = WhichH( eWhich );
+ ScVSplitPos eWhichY = WhichV( eWhich );
+
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ if (nMovX >= 0)
+ nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, 1, eWhichX )) * nMovX;
+ else
+ nPageX = ((SCsCOL) aViewData.CellsAtX( nCurX, -1, eWhichX )) * nMovX;
+
+ if (nMovY >= 0)
+ nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, 1, eWhichY )) * nMovY;
+ else
+ nPageY = ((SCsROW) aViewData.CellsAtY( nCurY, -1, eWhichY )) * nMovY;
+
+ if (nMovX != 0 && nPageX == 0) nPageX = (nMovX>0) ? 1 : -1;
+ if (nMovY != 0 && nPageY == 0) nPageY = (nMovY>0) ? 1 : -1;
+
+ rPageX = nPageX;
+ rPageY = nPageY;
+}
+
+void ScTabView::GetAreaMoveEndPosition(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ SCsCOL& rAreaX, SCsROW& rAreaY, ScFollowMode& rMode)
+{
+ SCCOL nNewX = -1;
+ SCROW nNewY = -1;
+ SCCOL nCurX = -1;
+ SCROW nCurY = -1;
+
+ if (aViewData.IsRefMode())
+ {
+ nNewX = aViewData.GetRefEndX();
+ nNewY = aViewData.GetRefEndY();
+ }
+ else if (IsBlockMode())
+ {
+ nNewX = nBlockEndX;
+ nNewY = nBlockEndY;
+ }
+ else
+ {
+ nNewX = nCurX = aViewData.GetCurX();
+ nNewY = nCurY = aViewData.GetCurY();
+ }
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ // FindAreaPos kennt nur -1 oder 1 als Richtung
+
+ SCsCOLROW i;
+ if ( nMovX > 0 )
+ for ( i=0; i<nMovX; i++ )
+ pDoc->FindAreaPos( nNewX, nNewY, nTab, 1, 0 );
+ if ( nMovX < 0 )
+ for ( i=0; i<-nMovX; i++ )
+ pDoc->FindAreaPos( nNewX, nNewY, nTab, -1, 0 );
+ if ( nMovY > 0 )
+ for ( i=0; i<nMovY; i++ )
+ pDoc->FindAreaPos( nNewX, nNewY, nTab, 0, 1 );
+ if ( nMovY < 0 )
+ for ( i=0; i<-nMovY; i++ )
+ pDoc->FindAreaPos( nNewX, nNewY, nTab, 0, -1 );
+
+ if (eMode==SC_FOLLOW_JUMP) // unten/rechts nicht zuviel grau anzeigen
+ {
+ if (nMovX != 0 && nNewX == MAXCOL)
+ eMode = SC_FOLLOW_LINE;
+ if (nMovY != 0 && nNewY == MAXROW)
+ eMode = SC_FOLLOW_LINE;
+ }
+
+ if (aViewData.IsRefMode())
+ {
+ rAreaX = nNewX - aViewData.GetRefEndX();
+ rAreaY = nNewY - aViewData.GetRefEndY();
+ }
+ else if (IsBlockMode())
+ {
+ rAreaX = nNewX - nBlockEndX;
+ rAreaY = nNewY - nBlockEndY;
+ }
+ else
+ {
+ rAreaX = nNewX - nCurX;
+ rAreaY = nNewY - nCurY;
+ }
+ rMode = eMode;
+}
+
+void ScTabView::SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX)
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ bool bSkipProtected = false, bSkipUnprotected = false;
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect && pProtect->isProtected())
+ {
+ bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ bool bSkipCell = false;
+ bool bHFlip = false;
+ do
+ {
+ SCCOL nLastCol = -1;
+ bSkipCell = pDoc->ColHidden(rCurX, nTab, nLastCol) || pDoc->IsHorOverlapped(rCurX, rCurY, nTab);
+ if (bSkipProtected && !bSkipCell)
+ bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+ if (bSkipUnprotected && !bSkipCell)
+ bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+
+ if (bSkipCell)
+ {
+ if (rCurX <= 0 || rCurX >= MAXCOL)
+ {
+ if (bHFlip)
+ {
+ rCurX = nOldX;
+ bSkipCell = false;
+ }
+ else
+ {
+ nMovX = -nMovX;
+ if (nMovX > 0)
+ ++rCurX;
+ else
+ --rCurX;
+ bHFlip = true;
+ }
+ }
+ else
+ if (nMovX > 0)
+ ++rCurX;
+ else
+ --rCurX;
+ }
+ }
+ while (bSkipCell);
+
+ if (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
+ {
+ aViewData.SetOldCursor(rCurX, rCurY);
+ while (pDoc->IsVerOverlapped(rCurX, rCurY, nTab))
+ --rCurY;
+ }
+}
+
+void ScTabView::SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY)
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ bool bSkipProtected = false, bSkipUnprotected = false;
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect && pProtect->isProtected())
+ {
+ bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ bool bSkipCell = false;
+ bool bVFlip = false;
+ do
+ {
+ SCROW nLastRow = -1;
+ bSkipCell = pDoc->RowHidden(rCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( rCurX, rCurY, nTab );
+ if (bSkipProtected && !bSkipCell)
+ bSkipCell = pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+ if (bSkipUnprotected && !bSkipCell)
+ bSkipCell = !pDoc->HasAttrib(rCurX, rCurY, nTab, rCurX, rCurY, nTab, HASATTR_PROTECTED);
+
+ if (bSkipCell)
+ {
+ if (rCurY <= 0 || rCurY >= MAXROW)
+ {
+ if (bVFlip)
+ {
+ rCurY = nOldY;
+ bSkipCell = false;
+ }
+ else
+ {
+ nMovY = -nMovY;
+ if (nMovY > 0)
+ ++rCurY;
+ else
+ --rCurY;
+ bVFlip = true;
+ }
+ }
+ else
+ if (nMovY > 0)
+ ++rCurY;
+ else
+ --rCurY;
+ }
+ }
+ while (bSkipCell);
+
+ if (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
+ {
+ aViewData.SetOldCursor(rCurX, rCurY);
+ while (pDoc->IsHorOverlapped(rCurX, rCurY, nTab))
+ --rCurX;
+ }
+}
+
+namespace {
+
+bool lcl_isCellQualified(ScDocument* pDoc, SCCOL nCol, SCROW nRow, SCTAB nTab, bool bSelectLocked, bool bSelectUnlocked)
+{
+ bool bCellProtected = pDoc->HasAttrib(
+ nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_PROTECTED);
+
+ if (bCellProtected && !bSelectLocked)
+ return false;
+
+ if (!bCellProtected && !bSelectUnlocked)
+ return false;
+
+ return true;
+}
+
+void skipHiddenRows(ScDocument* pDoc, SCTAB nTab, SCROW& rRow, bool bForward)
+{
+ SCROW nFirst, nLast;
+ if (!pDoc->RowHidden(rRow, nTab, &nFirst, &nLast))
+ // This row is visible. Nothing to do.
+ return;
+
+ if (bForward)
+ rRow = nLast < MAXROW ? nLast + 1 : MAXROW;
+ else
+ rRow = nFirst > 0 ? nFirst - 1 : 0;
+}
+
+void skipHiddenCols(ScDocument* pDoc, SCTAB nTab, SCCOL& rCol, bool bForward)
+{
+ SCCOL nFirst, nLast;
+ if (!pDoc->ColHidden(rCol, nTab, &nFirst, &nLast))
+ // This row is visible. Nothing to do.
+ return;
+
+ if (bForward)
+ rCol = nLast < MAXCOL ? nLast + 1 : MAXCOL;
+ else
+ rCol = nFirst > 0 ? nFirst - 1 : 0;
+}
+
+void lcl_moveCursorByProtRule(
+ SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY, SCTAB nTab, ScDocument* pDoc)
+{
+ bool bSelectLocked = true;
+ bool bSelectUnlocked = true;
+ ScTableProtection* pTabProtection = pDoc->GetTabProtection(nTab);
+ if (pTabProtection && pTabProtection->isProtected())
+ {
+ bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ if (nMovX > 0)
+ {
+ if (rCol < MAXCOL)
+ {
+ for (SCCOL i = 0; i < nMovX; ++i)
+ {
+ if (!lcl_isCellQualified(pDoc, rCol+1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ ++rCol;
+ skipHiddenCols(pDoc, nTab, rCol, true);
+ }
+ }
+ }
+ else if (nMovX < 0)
+ {
+ if (rCol > 0)
+ {
+ nMovX = -nMovX;
+ for (SCCOL i = 0; i < nMovX; ++i)
+ {
+ if (!lcl_isCellQualified(pDoc, rCol-1, rRow, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ --rCol;
+ skipHiddenCols(pDoc, nTab, rCol, false);
+ }
+ }
+ }
+
+ if (nMovY > 0)
+ {
+ if (rRow < MAXROW)
+ {
+ for (SCROW i = 0; i < nMovY; ++i)
+ {
+ if (!lcl_isCellQualified(pDoc, rCol, rRow+1, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ ++rRow;
+ skipHiddenRows(pDoc, nTab, rRow, true);
+ }
+ }
+ }
+ else if (nMovY < 0)
+ {
+ if (rRow > 0)
+ {
+ nMovY = -nMovY;
+ for (SCROW i = 0; i < nMovY; ++i)
+ {
+ if (!lcl_isCellQualified(pDoc, rCol, rRow-1, nTab, bSelectLocked, bSelectUnlocked))
+ break;
+ --rRow;
+ skipHiddenRows(pDoc, nTab, rRow, false);
+ }
+ }
+ }
+}
+
+}
+
+void ScTabView::ExpandBlock(SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode)
+{
+ if (!nMovX && !nMovY)
+ // Nothing to do. Bail out.
+ return;
+
+ ScTabViewShell* pViewShell = aViewData.GetViewShell();
+ bool bRefInputMode = pViewShell && pViewShell->IsRefInputMode();
+ if (bRefInputMode && !aViewData.IsRefMode())
+ // initialize formula reference mode if it hasn't already.
+ InitRefMode(aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo(), SC_REFTYPE_REF);
+
+ ScDocument* pDoc = aViewData.GetDocument();
+
+ if (aViewData.IsRefMode())
+ {
+ // formula reference mode
+
+ SCCOL nNewX = aViewData.GetRefEndX();
+ SCROW nNewY = aViewData.GetRefEndY();
+ SCTAB nRefTab = aViewData.GetRefEndZ();
+
+ bool bSelectLocked = true;
+ bool bSelectUnlocked = true;
+ ScTableProtection* pTabProtection = pDoc->GetTabProtection(nRefTab);
+ if (pTabProtection && pTabProtection->isProtected())
+ {
+ bSelectLocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSelectUnlocked = pTabProtection->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ lcl_moveCursorByProtRule(nNewX, nNewY, nMovX, nMovY, nRefTab, pDoc);
+
+ if (nMovX)
+ {
+ SCCOL nTempX = nNewX;
+ while (pDoc->IsHorOverlapped(nTempX, nNewY, nRefTab))
+ {
+ if (nMovX > 0)
+ ++nTempX;
+ else
+ --nTempX;
+ }
+ if (lcl_isCellQualified(pDoc, nTempX, nNewY, nRefTab, bSelectLocked, bSelectUnlocked))
+ nNewX = nTempX;
+ }
+
+ if (nMovY)
+ {
+ SCROW nTempY = nNewY;
+ while (pDoc->IsVerOverlapped(nNewX, nTempY, nRefTab))
+ {
+ if (nMovY > 0)
+ ++nTempY;
+ else
+ --nTempY;
+ }
+ if (lcl_isCellQualified(pDoc, nNewX, nTempY, nRefTab, bSelectLocked, bSelectUnlocked))
+ nNewY = nTempY;
+ }
+
+ pDoc->SkipOverlapped(nNewX, nNewY, nRefTab);
+ UpdateRef(nNewX, nNewY, nRefTab);
+ AlignToCursor(nNewX, nNewY, eMode);
+ }
+ else
+ {
+ // normal selection mode
+
+ SCTAB nTab = aViewData.GetTabNo();
+
+ if (!IsBlockMode())
+ InitBlockMode(aViewData.GetCurX(), aViewData.GetCurY(), nTab, true);
+
+ lcl_moveCursorByProtRule(nBlockEndX, nBlockEndY, nMovX, nMovY, nTab, pDoc);
+
+ if (nBlockEndX < 0)
+ nBlockEndX = 0;
+ else if (nBlockEndX > MAXCOL)
+ nBlockEndX = MAXCOL;
+
+ if (nBlockEndY < 0)
+ nBlockEndY = 0;
+ else if (nBlockEndY > MAXROW)
+ nBlockEndY = MAXROW;
+
+ pDoc->SkipOverlapped(nBlockEndX, nBlockEndY, nTab);
+ MarkCursor(nBlockEndX, nBlockEndY, nTab, false, false, true);
+
+ // Check if the entire row(s) or column(s) are selected.
+ ScSplitPos eActive = aViewData.GetActivePart();
+ bool bRowSelected = (nBlockStartX == 0 && nBlockEndX == MAXCOL);
+ bool bColSelected = (nBlockStartY == 0 && nBlockEndY == MAXROW);
+ SCsCOL nAlignX = bRowSelected ? aViewData.GetPosX(WhichH(eActive)) : nBlockEndX;
+ SCsROW nAlignY = bColSelected ? aViewData.GetPosY(WhichV(eActive)) : nBlockEndY;
+ AlignToCursor(nAlignX, nAlignY, eMode);
+
+ SelectionChanged();
+ }
+}
+
+void ScTabView::ExpandBlockPage(SCsCOL nMovX, SCsROW nMovY)
+{
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
+ ExpandBlock(nPageX, nPageY, SC_FOLLOW_FIX);
+}
+
+void ScTabView::ExpandBlockArea(SCsCOL nMovX, SCsROW nMovY)
+{
+ SCsCOL nAreaX;
+ SCsROW nAreaY;
+ ScFollowMode eMode;
+ GetAreaMoveEndPosition(nMovX, nMovY, SC_FOLLOW_JUMP, nAreaX, nAreaY, eMode);
+ ExpandBlock(nAreaX, nAreaY, eMode);
+}
+
+void ScTabView::UpdateCopySourceOverlay()
+{
+ for (sal_uInt8 i = 0; i < 4; ++i)
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ pGridWin[i]->UpdateCopySourceOverlay();
+}
+
+void ScTabView::UpdateSelectionOverlay()
+{
+ for (USHORT i=0; i<4; i++)
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ pGridWin[i]->UpdateSelectionOverlay();
+}
+
+void ScTabView::UpdateShrinkOverlay()
+{
+ for (USHORT i=0; i<4; i++)
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ pGridWin[i]->UpdateShrinkOverlay();
+}
+
+void ScTabView::UpdateAllOverlays()
+{
+ for (USHORT i=0; i<4; i++)
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ pGridWin[i]->UpdateAllOverlays();
+}
+
+//!
+//! PaintBlock in zwei Methoden aufteilen: RepaintBlock und RemoveBlock o.ae.
+//!
+
+void ScTabView::PaintBlock( BOOL bReset )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ ScMarkData& rMark = aViewData.GetMarkData();
+ SCTAB nTab = aViewData.GetTabNo();
+ BOOL bMark = rMark.IsMarked();
+ BOOL bMulti = rMark.IsMultiMarked();
+ if (bMark || bMulti)
+ {
+ ScRange aMarkRange;
+ HideAllCursors();
+ if (bMulti)
+ {
+ BOOL bFlag = rMark.GetMarkingFlag();
+ rMark.SetMarking(FALSE);
+ rMark.MarkToMulti();
+ rMark.GetMultiMarkArea(aMarkRange);
+ rMark.MarkToSimple();
+ rMark.SetMarking(bFlag);
+
+ bMark = rMark.IsMarked();
+ bMulti = rMark.IsMultiMarked();
+ }
+ else
+ rMark.GetMarkArea(aMarkRange);
+
+ nBlockStartX = aMarkRange.aStart.Col();
+ nBlockStartY = aMarkRange.aStart.Row();
+ nBlockStartZ = aMarkRange.aStart.Tab();
+ nBlockEndX = aMarkRange.aEnd.Col();
+ nBlockEndY = aMarkRange.aEnd.Row();
+ nBlockEndZ = aMarkRange.aEnd.Tab();
+
+ BOOL bDidReset = FALSE;
+
+ if ( nTab>=nBlockStartZ && nTab<=nBlockEndZ )
+ {
+ if ( bReset )
+ {
+ // Invertieren beim Loeschen nur auf aktiver View
+ if ( aViewData.IsActive() )
+ {
+ USHORT i;
+ if ( bMulti )
+ {
+#ifdef OLD_SELECTION_PAINT
+ for (i=0; i<4; i++)
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ pGridWin[i]->InvertSimple( nBlockStartX, nBlockStartY,
+ nBlockEndX, nBlockEndY,
+ TRUE, TRUE );
+#endif
+ rMark.ResetMark();
+ UpdateSelectionOverlay();
+ bDidReset = TRUE;
+ }
+ else
+ {
+#ifdef OLD_SELECTION_PAINT
+ // (mis)use InvertBlockMark to remove all of the selection
+ // -> set bBlockNeg (like when removing parts of a selection)
+ // and convert everything to Multi
+
+ rMark.MarkToMulti();
+ BOOL bOld = bBlockNeg;
+ bBlockNeg = TRUE;
+ // #73130# (negative) MarkArea must be set in case of repaint
+ rMark.SetMarkArea( ScRange( nBlockStartX,nBlockStartY, nTab,
+ nBlockEndX,nBlockEndY, nTab ) );
+
+ InvertBlockMark( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY );
+
+ bBlockNeg = bOld;
+#endif
+ rMark.ResetMark();
+ UpdateSelectionOverlay();
+ bDidReset = TRUE;
+ }
+
+ // repaint if controls are touched (#69680# in both cases)
+ // #i74768# Forms are rendered by DrawingLayer's EndDrawLayers()
+ static bool bSuppressControlExtraStuff(true);
+
+ if(!bSuppressControlExtraStuff)
+ {
+ Rectangle aMMRect = pDoc->GetMMRect(nBlockStartX,nBlockStartY,nBlockEndX,nBlockEndY, nTab);
+ if (pDoc->HasControl( nTab, aMMRect ))
+ {
+ for (i=0; i<4; i++)
+ {
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ {
+ // MapMode muss logischer (1/100mm) sein !!!
+ pDoc->InvalidateControls( pGridWin[i], nTab, aMMRect );
+ pGridWin[i]->Update();
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ PaintMarks( nBlockStartX, nBlockStartY, nBlockEndX, nBlockEndY );
+ }
+
+ if ( bReset && !bDidReset )
+ rMark.ResetMark();
+
+ ShowAllCursors();
+ }
+}
+
+void ScTabView::SelectAll( BOOL bContinue )
+{
+ ScMarkData& rMark = aViewData.GetMarkData();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ if (rMark.IsMarked())
+ {
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+ if ( aMarkRange == ScRange( 0,0,nTab, MAXCOL,MAXROW,nTab ) )
+ return;
+ }
+
+ DoneBlockMode( bContinue );
+ InitBlockMode( 0,0,nTab );
+ MarkCursor( MAXCOL,MAXROW,nTab );
+
+ SelectionChanged();
+}
+
+void ScTabView::SelectAllTables()
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ ScMarkData& rMark = aViewData.GetMarkData();
+// SCTAB nTab = aViewData.GetTabNo();
+ SCTAB nCount = pDoc->GetTableCount();
+
+ if (nCount>1)
+ {
+ for (SCTAB i=0; i<nCount; i++)
+ rMark.SelectTable( i, TRUE );
+
+ // Markierungen werden per Default nicht pro Tabelle gehalten
+// pDoc->ExtendMarksFromTable( nTab );
+
+ aViewData.GetDocShell()->PostPaintExtras();
+ SfxBindings& rBind = aViewData.GetBindings();
+ rBind.Invalidate( FID_FILL_TAB );
+ rBind.Invalidate( FID_TAB_DESELECTALL );
+ }
+}
+
+void ScTabView::DeselectAllTables()
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ ScMarkData& rMark = aViewData.GetMarkData();
+ SCTAB nTab = aViewData.GetTabNo();
+ SCTAB nCount = pDoc->GetTableCount();
+
+ for (SCTAB i=0; i<nCount; i++)
+ rMark.SelectTable( i, ( i == nTab ) );
+
+ aViewData.GetDocShell()->PostPaintExtras();
+ SfxBindings& rBind = aViewData.GetBindings();
+ rBind.Invalidate( FID_FILL_TAB );
+ rBind.Invalidate( FID_TAB_DESELECTALL );
+}
+
+BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom,
+ long nWindowX, long nWindowY, ScDocument* pDoc, SCTAB nTab,
+ SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ SCCOL nFixPosX, SCROW nFixPosY )
+{
+ double fZoomFactor = (double)Fraction(nZoom,100);
+ fScaleX *= fZoomFactor;
+ fScaleY *= fZoomFactor;
+
+ long nBlockX = 0;
+ SCCOL nCol;
+ for (nCol=0; nCol<nFixPosX; nCol++)
+ {
+ // for frozen panes, add both parts
+ USHORT nColTwips = pDoc->GetColWidth( nCol, nTab );
+ if (nColTwips)
+ {
+ nBlockX += (long)(nColTwips * fScaleX);
+ if (nBlockX > nWindowX)
+ return FALSE;
+ }
+ }
+ for (nCol=nStartCol; nCol<=nEndCol; nCol++)
+ {
+ USHORT nColTwips = pDoc->GetColWidth( nCol, nTab );
+ if (nColTwips)
+ {
+ nBlockX += (long)(nColTwips * fScaleX);
+ if (nBlockX > nWindowX)
+ return FALSE;
+ }
+ }
+
+ long nBlockY = 0;
+ for (SCROW nRow = 0; nRow <= nFixPosY-1; ++nRow)
+ {
+ if (pDoc->RowHidden(nRow, nTab))
+ continue;
+
+ // for frozen panes, add both parts
+ USHORT nRowTwips = pDoc->GetRowHeight(nRow, nTab);
+ if (nRowTwips)
+ {
+ nBlockY += (long)(nRowTwips * fScaleY);
+ if (nBlockY > nWindowY)
+ return FALSE;
+ }
+ }
+ for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
+ {
+ USHORT nRowTwips = pDoc->GetRowHeight(nRow, nTab);
+ if (nRowTwips)
+ {
+ nBlockY += (long)(nRowTwips * fScaleY);
+ if (nBlockY > nWindowY)
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+USHORT ScTabView::CalcZoom( SvxZoomType eType, USHORT nOldZoom )
+{
+ USHORT nZoom = 0; // Ergebnis
+
+ switch ( eType )
+ {
+ case SVX_ZOOM_PERCENT: // rZoom ist kein besonderer prozentualer Wert
+ nZoom = nOldZoom;
+ break;
+
+ case SVX_ZOOM_OPTIMAL: // nZoom entspricht der optimalen Gr"o\se
+ {
+ ScMarkData& rMark = aViewData.GetMarkData();
+ ScDocument* pDoc = aViewData.GetDocument();
+
+ if (!rMark.IsMarked() && !rMark.IsMultiMarked())
+ nZoom = 100; // nothing selected
+ else
+ {
+ SCTAB nTab = aViewData.GetTabNo();
+ ScRange aMarkRange;
+ if ( aViewData.GetSimpleArea( aMarkRange ) != SC_MARK_SIMPLE )
+ rMark.GetMultiMarkArea( aMarkRange );
+
+ SCCOL nStartCol = aMarkRange.aStart.Col();
+ SCROW nStartRow = aMarkRange.aStart.Row();
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCCOL nEndCol = aMarkRange.aEnd.Col();
+ SCROW nEndRow = aMarkRange.aEnd.Row();
+ SCTAB nEndTab = aMarkRange.aEnd.Tab();
+
+ if ( nTab < nStartTab && nTab > nEndTab )
+ nTab = nStartTab;
+
+ ScSplitPos eUsedPart = aViewData.GetActivePart();
+
+ SCCOL nFixPosX = 0;
+ SCROW nFixPosY = 0;
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ {
+ // use right part
+ eUsedPart = (WhichV(eUsedPart)==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT;
+ nFixPosX = aViewData.GetFixPosX();
+ if ( nStartCol < nFixPosX )
+ nStartCol = nFixPosX;
+ }
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ {
+ // use bottom part
+ eUsedPart = (WhichH(eUsedPart)==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+ nFixPosY = aViewData.GetFixPosY();
+ if ( nStartRow < nFixPosY )
+ nStartRow = nFixPosY;
+ }
+
+ if (pGridWin[eUsedPart])
+ {
+ // Because scale is rounded to pixels, the only reliable way to find
+ // the right scale is to check if a zoom fits
+
+ Size aWinSize = pGridWin[eUsedPart]->GetOutputSizePixel();
+
+ // for frozen panes, use sum of both parts for calculation
+
+ if ( nFixPosX != 0 )
+ aWinSize.Width() += GetGridWidth( SC_SPLIT_LEFT );
+ if ( nFixPosY != 0 )
+ aWinSize.Height() += GetGridHeight( SC_SPLIT_TOP );
+
+ ScDocShell* pDocSh = aViewData.GetDocShell();
+ double nPPTX = ScGlobal::nScreenPPTX / pDocSh->GetOutputFactor();
+ double nPPTY = ScGlobal::nScreenPPTY;
+
+ USHORT nMin = MINZOOM;
+ USHORT nMax = MAXZOOM;
+ while ( nMax > nMin )
+ {
+ USHORT nTest = (nMin+nMax+1)/2;
+ if ( lcl_FitsInWindow(
+ nPPTX, nPPTY, nTest, aWinSize.Width(), aWinSize.Height(),
+ pDoc, nTab, nStartCol, nStartRow, nEndCol, nEndRow,
+ nFixPosX, nFixPosY ) )
+ nMin = nTest;
+ else
+ nMax = nTest-1;
+ }
+ DBG_ASSERT( nMin == nMax, "Schachtelung ist falsch" );
+ nZoom = nMin;
+
+ if ( nZoom != nOldZoom )
+ {
+ // scroll to block only in active split part
+ // (the part for which the size was calculated)
+
+ if ( nStartCol <= nEndCol )
+ aViewData.SetPosX( WhichH(eUsedPart), nStartCol );
+ if ( nStartRow <= nEndRow )
+ aViewData.SetPosY( WhichV(eUsedPart), nStartRow );
+ }
+ }
+ }
+ }
+ break;
+
+ case SVX_ZOOM_WHOLEPAGE: // nZoom entspricht der ganzen Seite oder
+ case SVX_ZOOM_PAGEWIDTH: // nZoom entspricht der Seitenbreite
+ {
+ SCTAB nCurTab = aViewData.GetTabNo();
+ ScDocument* pDoc = aViewData.GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet =
+ pStylePool->Find( pDoc->GetPageStyle( nCurTab ),
+ SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" );
+
+ if ( pStyleSheet )
+ {
+ ScPrintFunc aPrintFunc( aViewData.GetDocShell(),
+ aViewData.GetViewShell()->GetPrinter(TRUE),
+ nCurTab );
+
+ Size aPageSize = aPrintFunc.GetDataSize();
+
+ // use the size of the largest GridWin for normal split,
+ // or both combined for frozen panes, with the (document) size
+ // of the frozen part added to the page size
+ // (with frozen panes, the size of the individual parts
+ // depends on the scale that is to be calculated)
+
+ if ( !pGridWin[SC_SPLIT_BOTTOMLEFT] ) return 0;
+ Size aWinSize = pGridWin[SC_SPLIT_BOTTOMLEFT]->GetOutputSizePixel();
+ ScSplitMode eHMode = aViewData.GetHSplitMode();
+ if ( eHMode != SC_SPLIT_NONE && pGridWin[SC_SPLIT_BOTTOMRIGHT] )
+ {
+ long nOtherWidth = pGridWin[SC_SPLIT_BOTTOMRIGHT]->
+ GetOutputSizePixel().Width();
+ if ( eHMode == SC_SPLIT_FIX )
+ {
+ aWinSize.Width() += nOtherWidth;
+ for ( SCCOL nCol = aViewData.GetPosX(SC_SPLIT_LEFT);
+ nCol < aViewData.GetFixPosX(); nCol++ )
+ aPageSize.Width() += pDoc->GetColWidth( nCol, nCurTab );
+ }
+ else if ( nOtherWidth > aWinSize.Width() )
+ aWinSize.Width() = nOtherWidth;
+ }
+ ScSplitMode eVMode = aViewData.GetVSplitMode();
+ if ( eVMode != SC_SPLIT_NONE && pGridWin[SC_SPLIT_TOPLEFT] )
+ {
+ long nOtherHeight = pGridWin[SC_SPLIT_TOPLEFT]->
+ GetOutputSizePixel().Height();
+ if ( eVMode == SC_SPLIT_FIX )
+ {
+ aWinSize.Height() += nOtherHeight;
+ aPageSize.Height() += pDoc->GetRowHeight(
+ aViewData.GetPosY(SC_SPLIT_TOP),
+ aViewData.GetFixPosY()-1, nCurTab);
+ }
+ else if ( nOtherHeight > aWinSize.Height() )
+ aWinSize.Height() = nOtherHeight;
+ }
+
+ double nPPTX = ScGlobal::nScreenPPTX / aViewData.GetDocShell()->GetOutputFactor();
+ double nPPTY = ScGlobal::nScreenPPTY;
+
+ long nZoomX = (long) ( aWinSize.Width() * 100 /
+ ( aPageSize.Width() * nPPTX ) );
+ long nZoomY = (long) ( aWinSize.Height() * 100 /
+ ( aPageSize.Height() * nPPTY ) );
+ long nNew = nZoomX;
+
+ if (eType == SVX_ZOOM_WHOLEPAGE && nZoomY < nNew)
+ nNew = nZoomY;
+
+ nZoom = (USHORT) nNew;
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR("Unknown Zoom-Revision");
+ nZoom = 0;
+ }
+
+ return nZoom;
+}
+
+// wird z.B. gerufen, wenn sich das View-Fenster verschiebt:
+
+void ScTabView::StopMarking()
+{
+ ScSplitPos eActive = aViewData.GetActivePart();
+ if (pGridWin[eActive])
+ pGridWin[eActive]->StopMarking();
+
+ ScHSplitPos eH = WhichH(eActive);
+ if (pColBar[eH])
+ pColBar[eH]->StopMarking();
+
+ ScVSplitPos eV = WhichV(eActive);
+ if (pRowBar[eV])
+ pRowBar[eV]->StopMarking();
+}
+
+void ScTabView::HideNoteMarker()
+{
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ pGridWin[i]->HideNoteMarker();
+}
+
+void ScTabView::MakeDrawLayer()
+{
+ if (!pDrawView)
+ {
+ aViewData.GetDocShell()->MakeDrawLayer();
+
+ // pDrawView wird per Notify gesetzt
+ DBG_ASSERT(pDrawView,"ScTabView::MakeDrawLayer funktioniert nicht");
+
+ // #114409#
+ for(sal_uInt16 a(0); a < 4; a++)
+ {
+ if(pGridWin[a])
+ {
+ pGridWin[a]->DrawLayerCreated();
+ }
+ }
+ }
+}
+
+void ScTabView::ErrorMessage( USHORT nGlobStrId )
+{
+ if ( SC_MOD()->IsInExecuteDrop() )
+ {
+ // #i28468# don't show error message when called from Drag&Drop, silently abort instead
+ return;
+ }
+
+ StopMarking(); // falls per Focus aus MouseButtonDown aufgerufen
+
+ Window* pParent = aViewData.GetDialogParent();
+ ScWaitCursorOff aWaitOff( pParent );
+ BOOL bFocus = pParent && pParent->HasFocus();
+
+ if(nGlobStrId==STR_PROTECTIONERR)
+ {
+ if(aViewData.GetDocShell()->IsReadOnly())
+ {
+ nGlobStrId=STR_READONLYERR;
+ }
+ }
+
+ InfoBox aBox( pParent, ScGlobal::GetRscString( nGlobStrId ) );
+ aBox.Execute();
+ if (bFocus)
+ pParent->GrabFocus();
+}
+
+Window* ScTabView::GetParentOrChild( USHORT nChildId )
+{
+ SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame();
+
+ if ( pViewFrm->HasChildWindow(nChildId) )
+ {
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow(nChildId);
+ if (pChild)
+ {
+ Window* pWin = pChild->GetWindow();
+ if (pWin && pWin->IsVisible())
+ return pWin;
+ }
+ }
+
+ return aViewData.GetDialogParent();
+}
+
+void ScTabView::UpdatePageBreakData( BOOL bForcePaint )
+{
+ ScPageBreakData* pNewData = NULL;
+
+ if (aViewData.IsPagebreakMode())
+ {
+ ScDocShell* pDocSh = aViewData.GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ USHORT nCount = pDoc->GetPrintRangeCount(nTab);
+ if (!nCount)
+ nCount = 1;
+ pNewData = new ScPageBreakData(nCount);
+
+ ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab, 0,0,NULL, NULL, pNewData );
+ // ScPrintFunc fuellt im ctor die PageBreakData
+ if ( nCount > 1 )
+ {
+ aPrintFunc.ResetBreaks(nTab);
+ pNewData->AddPages();
+ }
+
+ // Druckbereiche veraendert?
+ if ( bForcePaint || ( pPageBreakData && !pPageBreakData->IsEqual( *pNewData ) ) )
+ PaintGrid();
+ }
+
+ delete pPageBreakData;
+ pPageBreakData = pNewData;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
new file mode 100644
index 000000000000..d5a6f41f4aa7
--- /dev/null
+++ b/sc/source/ui/view/tabview3.cxx
@@ -0,0 +1,2641 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// System - Includes -----------------------------------------------------
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <rangelst.hxx>
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <editeng/brshitem.hxx>
+#include <editeng/editview.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/svdoole2.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/cursor.hxx>
+
+#include "tabview.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "gridwin.hxx"
+#include "olinewin.hxx"
+#include "colrowba.hxx"
+#include "tabcont.hxx"
+#include "scmod.hxx"
+#include "uiitems.hxx"
+#include "sc.hrc"
+#include "viewutil.hxx"
+#include "editutil.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "validat.hxx"
+#include "hintwin.hxx"
+#include "inputopt.hxx"
+#include "rfindlst.hxx"
+#include "hiranges.hxx"
+#include "viewuno.hxx"
+#include "chartarr.hxx"
+#include "anyrefdg.hxx"
+#include "dpobject.hxx"
+#include "patattr.hxx"
+#include "dociter.hxx"
+#include "seltrans.hxx"
+#include "fillinfo.hxx"
+#include "AccessibilityHints.hxx"
+#include "rangeutl.hxx"
+#include "client.hxx"
+#include "tabprotection.hxx"
+#include "formula/FormulaCompiler.hxx"
+
+#include <com/sun/star/chart2/data/HighlightedRange.hpp>
+
+namespace
+{
+
+ScRange lcl_getSubRangeByIndex( const ScRange& rRange, sal_Int32 nIndex )
+{
+ ScAddress aResult( rRange.aStart );
+
+ SCCOL nWidth = rRange.aEnd.Col() - rRange.aStart.Col() + 1;
+ SCROW nHeight = rRange.aEnd.Row() - rRange.aStart.Row() + 1;
+ SCTAB nDepth = rRange.aEnd.Tab() - rRange.aStart.Tab() + 1;
+ if( (nWidth > 0) && (nHeight > 0) && (nDepth > 0) )
+ {
+ // row by row from first to last sheet
+ sal_Int32 nArea = nWidth * nHeight;
+ aResult.IncCol( static_cast< SCsCOL >( nIndex % nWidth ) );
+ aResult.IncRow( static_cast< SCsROW >( (nIndex % nArea) / nWidth ) );
+ aResult.IncTab( static_cast< SCsTAB >( nIndex / nArea ) );
+ if( !rRange.In( aResult ) )
+ aResult = rRange.aStart;
+ }
+
+ return ScRange( aResult );
+}
+
+} // anonymous namespace
+
+using namespace com::sun::star;
+
+// -----------------------------------------------------------------------
+
+//
+// --- Public-Funktionen
+//
+
+void ScTabView::ClickCursor( SCCOL nPosX, SCROW nPosY, BOOL bControl )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ pDoc->SkipOverlapped(nPosX, nPosY, nTab);
+
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+
+ if ( bRefMode )
+ {
+ DoneRefMode( FALSE );
+
+ if (bControl)
+ SC_MOD()->AddRefEntry();
+
+ InitRefMode( nPosX, nPosY, nTab, SC_REFTYPE_REF );
+ }
+ else
+ {
+ DoneBlockMode( bControl );
+ aViewData.ResetOldCursor();
+ SetCursor( (SCCOL) nPosX, (SCROW) nPosY );
+ }
+}
+
+void ScTabView::UpdateAutoFillMark()
+{
+ // single selection or cursor
+ ScRange aMarkRange;
+ BOOL bMarked = (aViewData.GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
+
+ USHORT i;
+ for (i=0; i<4; i++)
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ pGridWin[i]->UpdateAutoFillMark( bMarked, aMarkRange );
+
+ for (i=0; i<2; i++)
+ {
+ if (pColBar[i] && pColBar[i]->IsVisible())
+ pColBar[i]->SetMark( bMarked, aMarkRange.aStart.Col(), aMarkRange.aEnd.Col() );
+ if (pRowBar[i] && pRowBar[i]->IsVisible())
+ pRowBar[i]->SetMark( bMarked, aMarkRange.aStart.Row(), aMarkRange.aEnd.Row() );
+ }
+
+ // selection transfer object is checked together with AutoFill marks,
+ // because it has the same requirement of a single continuous block.
+ CheckSelectionTransfer(); // update selection transfer object
+}
+
+void ScTabView::FakeButtonUp( ScSplitPos eWhich )
+{
+ if (pGridWin[eWhich])
+ pGridWin[eWhich]->FakeButtonUp();
+}
+
+void ScTabView::HideAllCursors()
+{
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ {
+ Cursor* pCur = pGridWin[i]->GetCursor();
+ if (pCur)
+ if (pCur->IsVisible())
+ pCur->Hide();
+ pGridWin[i]->HideCursor();
+ }
+}
+
+void ScTabView::ShowAllCursors()
+{
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ {
+ pGridWin[i]->ShowCursor();
+
+ // #114409#
+ pGridWin[i]->CursorChanged();
+ }
+}
+
+void ScTabView::HideCursor()
+{
+ pGridWin[aViewData.GetActivePart()]->HideCursor();
+}
+
+void ScTabView::ShowCursor()
+{
+ pGridWin[aViewData.GetActivePart()]->ShowCursor();
+
+ // #114409#
+ pGridWin[aViewData.GetActivePart()]->CursorChanged();
+}
+
+void ScTabView::InvalidateAttribs()
+{
+ SfxBindings& rBindings = aViewData.GetBindings();
+
+ rBindings.Invalidate( SID_STYLE_APPLY );
+ rBindings.Invalidate( SID_STYLE_FAMILY2 );
+ // StarCalc kennt nur Absatz- bzw. Zellformat-Vorlagen
+
+ rBindings.Invalidate( SID_ATTR_CHAR_FONT );
+ rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_COLOR );
+
+ rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT );
+ rBindings.Invalidate( SID_ATTR_CHAR_POSTURE );
+ rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE );
+ rBindings.Invalidate( SID_ULINE_VAL_NONE );
+ rBindings.Invalidate( SID_ULINE_VAL_SINGLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOUBLE );
+ rBindings.Invalidate( SID_ULINE_VAL_DOTTED );
+
+ rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE );
+
+ rBindings.Invalidate( SID_ALIGNLEFT );
+ rBindings.Invalidate( SID_ALIGNRIGHT );
+ rBindings.Invalidate( SID_ALIGNBLOCK );
+ rBindings.Invalidate( SID_ALIGNCENTERHOR );
+
+ rBindings.Invalidate( SID_ALIGNTOP );
+ rBindings.Invalidate( SID_ALIGNBOTTOM );
+ rBindings.Invalidate( SID_ALIGNCENTERVER );
+
+ rBindings.Invalidate( SID_BACKGROUND_COLOR );
+
+ rBindings.Invalidate( SID_ATTR_ALIGN_LINEBREAK );
+ rBindings.Invalidate( SID_NUMBER_FORMAT );
+
+ rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT );
+
+ // pseudo slots for Format menu
+ rBindings.Invalidate( SID_ALIGN_ANY_HDEFAULT );
+ rBindings.Invalidate( SID_ALIGN_ANY_LEFT );
+ rBindings.Invalidate( SID_ALIGN_ANY_HCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_RIGHT );
+ rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED );
+ rBindings.Invalidate( SID_ALIGN_ANY_VDEFAULT );
+ rBindings.Invalidate( SID_ALIGN_ANY_TOP );
+ rBindings.Invalidate( SID_ALIGN_ANY_VCENTER );
+ rBindings.Invalidate( SID_ALIGN_ANY_BOTTOM );
+
+ rBindings.Invalidate( SID_NUMBER_CURRENCY );
+ rBindings.Invalidate( SID_NUMBER_SCIENTIFIC );
+ rBindings.Invalidate( SID_NUMBER_DATE );
+ rBindings.Invalidate( SID_NUMBER_CURRENCY );
+ rBindings.Invalidate( SID_NUMBER_PERCENT );
+ rBindings.Invalidate( SID_NUMBER_TIME );
+
+// rBindings.Invalidate( SID_RANGE_VALUE );
+// rBindings.Invalidate( SID_RANGE_FORMULA );
+}
+
+// SetCursor - Cursor setzen, zeichnen, InputWin updaten
+// oder Referenz verschicken
+// ohne Optimierung wegen BugId 29307
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, BOOL bNew )
+{
+ SCCOL nOldX = aViewData.GetCurX();
+ SCROW nOldY = aViewData.GetCurY();
+
+ // DeactivateIP nur noch bei MarkListHasChanged
+
+ if ( nPosX != nOldX || nPosY != nOldY || bNew )
+ {
+ ScTabViewShell* pViewShell = aViewData.GetViewShell();
+ bool bRefMode = ( pViewShell ? pViewShell->IsRefInputMode() : false );
+ if ( aViewData.HasEditView( aViewData.GetActivePart() ) && !bRefMode ) // 23259 oder so
+ {
+ UpdateInputLine();
+ }
+
+ HideAllCursors();
+
+ aViewData.SetCurX( nPosX );
+ aViewData.SetCurY( nPosY );
+
+ ShowAllCursors();
+
+ CursorPosChanged();
+ }
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+void ScTabView::CheckSelectionTransfer()
+{
+ if ( aViewData.IsActive() ) // only for active view
+ {
+ ScModule* pScMod = SC_MOD();
+ ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
+ if ( pOld && pOld->GetView() == this && pOld->StillValid() )
+ {
+ // selection not changed - nothing to do
+ }
+ else
+ {
+ ScSelectionTransferObj* pNew = ScSelectionTransferObj::CreateFromView( this );
+ if ( pNew )
+ {
+ // create new selection
+
+ if (pOld)
+ pOld->ForgetView();
+
+ uno::Reference<datatransfer::XTransferable> xRef( pNew );
+ pScMod->SetSelectionTransfer( pNew );
+ pNew->CopyToSelection( GetActiveWin() ); // may delete pOld
+ }
+ else if ( pOld && pOld->GetView() == this )
+ {
+ // remove own selection
+
+ pOld->ForgetView();
+ pScMod->SetSelectionTransfer( NULL );
+ TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
+ }
+ // else: selection from outside: leave unchanged
+ }
+ }
+}
+
+// Eingabezeile / Menues updaten
+// CursorPosChanged ruft SelectionChanged
+// SelectionChanged ruft CellContentChanged
+
+void ScTabView::CellContentChanged()
+{
+ SfxBindings& rBindings = aViewData.GetBindings();
+
+ rBindings.Invalidate( SID_ATTR_SIZE ); // -> Fehlermeldungen anzeigen
+ rBindings.Invalidate( SID_THESAURUS );
+ rBindings.Invalidate( SID_HYPERLINK_GETLINK );
+
+ InvalidateAttribs(); // Attribut-Updates
+ TestHintWindow(); // Eingabemeldung (Gueltigkeit)
+
+ aViewData.GetViewShell()->UpdateInputHandler();
+}
+
+void ScTabView::SelectionChanged()
+{
+ SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
+ if (pViewFrame)
+ {
+ uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
+ if (xController.is())
+ {
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SelectionChanged();
+ }
+ }
+
+ UpdateAutoFillMark(); // also calls CheckSelectionTransfer
+
+ SfxBindings& rBindings = aViewData.GetBindings();
+
+ rBindings.Invalidate( SID_CURRENTCELL ); // -> Navigator
+ rBindings.Invalidate( SID_AUTO_FILTER ); // -> Menue
+ rBindings.Invalidate( FID_NOTE_VISIBLE );
+ rBindings.Invalidate( SID_DELETE_NOTE );
+
+ // Funktionen, die evtl disabled werden muessen
+
+ rBindings.Invalidate( FID_INS_ROWBRK );
+ rBindings.Invalidate( FID_INS_COLBRK );
+ rBindings.Invalidate( FID_DEL_ROWBRK );
+ rBindings.Invalidate( FID_DEL_COLBRK );
+ rBindings.Invalidate( FID_MERGE_ON );
+ rBindings.Invalidate( FID_MERGE_OFF );
+ rBindings.Invalidate( FID_MERGE_TOGGLE );
+ rBindings.Invalidate( SID_AUTOFILTER_HIDE );
+ rBindings.Invalidate( SID_UNFILTER );
+// rBindings.Invalidate( SID_IMPORT_DATA ); // jetzt wieder immer moeglich
+ rBindings.Invalidate( SID_REIMPORT_DATA );
+ rBindings.Invalidate( SID_REFRESH_DBAREA );
+ rBindings.Invalidate( SID_OUTLINE_SHOW );
+ rBindings.Invalidate( SID_OUTLINE_HIDE );
+ rBindings.Invalidate( SID_OUTLINE_REMOVE );
+ rBindings.Invalidate( FID_FILL_TO_BOTTOM );
+ rBindings.Invalidate( FID_FILL_TO_RIGHT );
+ rBindings.Invalidate( FID_FILL_TO_TOP );
+ rBindings.Invalidate( FID_FILL_TO_LEFT );
+ rBindings.Invalidate( FID_FILL_SERIES );
+ rBindings.Invalidate( SID_SCENARIOS );
+ rBindings.Invalidate( SID_AUTOFORMAT );
+ rBindings.Invalidate( SID_OPENDLG_TABOP );
+ rBindings.Invalidate( SID_DATA_SELECT );
+
+ rBindings.Invalidate( SID_CUT );
+ rBindings.Invalidate( SID_COPY );
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+
+ rBindings.Invalidate( FID_INS_ROW );
+ rBindings.Invalidate( FID_INS_COLUMN );
+ rBindings.Invalidate( FID_INS_CELL );
+ rBindings.Invalidate( FID_INS_CELLSDOWN );
+ rBindings.Invalidate( FID_INS_CELLSRIGHT );
+
+ rBindings.Invalidate( FID_CHG_COMMENT );
+
+ // nur wegen Zellschutz:
+
+ rBindings.Invalidate( SID_CELL_FORMAT_RESET );
+ rBindings.Invalidate( SID_DELETE );
+ rBindings.Invalidate( SID_DELETE_CONTENTS );
+ rBindings.Invalidate( FID_DELETE_CELL );
+ rBindings.Invalidate( FID_CELL_FORMAT );
+ rBindings.Invalidate( SID_ENABLE_HYPHENATION );
+ rBindings.Invalidate( SID_INSERT_POSTIT );
+ rBindings.Invalidate( SID_CHARMAP );
+ rBindings.Invalidate( SID_OPENDLG_FUNCTION );
+// rBindings.Invalidate( FID_CONDITIONAL_FORMAT );
+ rBindings.Invalidate( SID_OPENDLG_CONDFRMT );
+ rBindings.Invalidate( FID_VALIDATION );
+ rBindings.Invalidate( SID_EXTERNAL_SOURCE );
+ rBindings.Invalidate( SID_TEXT_TO_COLUMNS );
+ rBindings.Invalidate( SID_SORT_ASCENDING );
+ rBindings.Invalidate( SID_SORT_DESCENDING );
+
+ if (aViewData.GetViewShell()->HasAccessibilityObjects())
+ aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_CURSORCHANGED));
+
+ CellContentChanged();
+}
+
+void ScTabView::CursorPosChanged()
+{
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
+ aViewData.GetDocShell()->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
+
+ // Broadcast, damit andere Views des Dokuments auch umschalten
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ bool bDP = NULL != pDoc->GetDPAtCursor(
+ aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
+ aViewData.GetViewShell()->SetPivotShell(bDP);
+
+ // UpdateInputHandler jetzt in CellContentChanged
+
+ SelectionChanged();
+
+ aViewData.SetTabStartCol( SC_TABSTART_NONE );
+}
+
+void ScTabView::TestHintWindow()
+{
+ // show input help window and list drop-down button for validity
+
+ BOOL bListValButton = FALSE;
+ ScAddress aListValPos;
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ const SfxUInt32Item* pItem = (const SfxUInt32Item*)
+ pDoc->GetAttr( aViewData.GetCurX(),
+ aViewData.GetCurY(),
+ aViewData.GetTabNo(),
+ ATTR_VALIDDATA );
+ if ( pItem->GetValue() )
+ {
+ const ScValidationData* pData = pDoc->GetValidationEntry( pItem->GetValue() );
+ DBG_ASSERT(pData,"ValidationData nicht gefunden");
+ String aTitle, aMessage;
+ if ( pData && pData->GetInput( aTitle, aMessage ) && aMessage.Len() > 0 )
+ {
+ //! Abfrage, ob an gleicher Stelle !!!!
+
+ DELETEZ(pInputHintWindow);
+
+ ScSplitPos eWhich = aViewData.GetActivePart();
+ Window* pWin = pGridWin[eWhich];
+ SCCOL nCol = aViewData.GetCurX();
+ SCROW nRow = aViewData.GetCurY();
+ Point aPos = aViewData.GetScrPos( nCol, nRow, eWhich );
+ Size aWinSize = pWin->GetOutputSizePixel();
+ // Cursor sichtbar?
+ if ( nCol >= aViewData.GetPosX(WhichH(eWhich)) &&
+ nRow >= aViewData.GetPosY(WhichV(eWhich)) &&
+ aPos.X() < aWinSize.Width() && aPos.Y() < aWinSize.Height() )
+ {
+ aPos += pWin->GetPosPixel(); // Position auf Frame
+ long nSizeXPix;
+ long nSizeYPix;
+ aViewData.GetMergeSizePixel( nCol, nRow, nSizeXPix, nSizeYPix );
+
+ // HintWindow anlegen, bestimmt seine Groesse selbst
+ pInputHintWindow = new ScHintWindow( pFrameWin, aTitle, aMessage );
+ Size aHintSize = pInputHintWindow->GetSizePixel();
+ Size aFrameWinSize = pFrameWin->GetOutputSizePixel();
+
+ // passende Position finden
+ // erster Versuch: unter dem Cursor
+ Point aHintPos( aPos.X() + nSizeXPix / 2, aPos.Y() + nSizeYPix + 3 );
+ if ( aHintPos.Y() + aHintSize.Height() > aFrameWinSize.Height() )
+ {
+ // zweiter Versuch: rechts vom Cursor
+ aHintPos = Point( aPos.X() + nSizeXPix + 3, aPos.Y() + nSizeYPix / 2 );
+ if ( aHintPos.X() + aHintSize.Width() > aFrameWinSize.Width() )
+ {
+ // dritter Versuch: ueber dem Cursor
+ aHintPos = Point( aPos.X() + nSizeXPix / 2,
+ aPos.Y() - aHintSize.Height() - 3 );
+ if ( aHintPos.Y() < 0 )
+ {
+ // oben und unten kein Platz - dann Default und abschneiden
+ aHintPos = Point( aPos.X() + nSizeXPix / 2, aPos.Y() + nSizeYPix + 3 );
+ aHintSize.Height() = aFrameWinSize.Height() - aHintPos.Y();
+ pInputHintWindow->SetSizePixel( aHintSize );
+ }
+ }
+ }
+
+ // X anpassen
+ if ( aHintPos.X() + aHintSize.Width() > aFrameWinSize.Width() )
+ aHintPos.X() = aFrameWinSize.Width() - aHintSize.Width();
+ // Y anpassen
+ if ( aHintPos.Y() + aHintSize.Height() > aFrameWinSize.Height() )
+ aHintPos.Y() = aFrameWinSize.Height() - aHintSize.Height();
+
+ pInputHintWindow->SetPosPixel( aHintPos );
+ pInputHintWindow->ToTop();
+ pInputHintWindow->Show();
+ }
+ }
+ else
+ DELETEZ(pInputHintWindow);
+
+ // list drop-down button
+ if ( pData && pData->HasSelectionList() )
+ {
+ aListValPos.Set( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
+ bListValButton = TRUE;
+ }
+ }
+ else
+ DELETEZ(pInputHintWindow);
+
+ for ( USHORT i=0; i<4; i++ )
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ pGridWin[i]->UpdateListValPos( bListValButton, aListValPos );
+}
+
+void ScTabView::RemoveHintWindow()
+{
+ DELETEZ(pInputHintWindow);
+}
+
+
+// find window that should not be over the cursor
+Window* lcl_GetCareWin(SfxViewFrame* pViewFrm)
+{
+ //! auch Spelling ??? (dann beim Aufruf Membervariable setzen)
+
+ // Suchen & Ersetzen
+ if ( pViewFrm->HasChildWindow(SID_SEARCH_DLG) )
+ {
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow(SID_SEARCH_DLG);
+ if (pChild)
+ {
+ Window* pWin = pChild->GetWindow();
+ if (pWin && pWin->IsVisible())
+ return pWin;
+ }
+ }
+
+ // Aenderungen uebernehmen
+ if ( pViewFrm->HasChildWindow(FID_CHG_ACCEPT) )
+ {
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_CHG_ACCEPT);
+ if (pChild)
+ {
+ Window* pWin = pChild->GetWindow();
+ if (pWin && pWin->IsVisible())
+ return pWin;
+ }
+ }
+
+ return NULL;
+}
+
+ //
+ // Bildschirm an Cursorposition anpassen
+ //
+
+void ScTabView::AlignToCursor( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
+ const ScSplitPos* pWhich )
+{
+ //
+ // aktiven Teil umschalten jetzt hier
+ //
+
+ ScSplitPos eActive = aViewData.GetActivePart();
+ ScHSplitPos eActiveX = WhichH(eActive);
+ ScVSplitPos eActiveY = WhichV(eActive);
+ BOOL bHFix = (aViewData.GetHSplitMode() == SC_SPLIT_FIX);
+ BOOL bVFix = (aViewData.GetVSplitMode() == SC_SPLIT_FIX);
+ if (bHFix)
+ if (eActiveX == SC_SPLIT_LEFT && nCurX >= (SCsCOL)aViewData.GetFixPosX())
+ {
+ ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT );
+ eActiveX = SC_SPLIT_RIGHT;
+ }
+ if (bVFix)
+ if (eActiveY == SC_SPLIT_TOP && nCurY >= (SCsROW)aViewData.GetFixPosY())
+ {
+ ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT );
+ eActiveY = SC_SPLIT_BOTTOM;
+ }
+
+ //
+ // eigentliches Align
+ //
+
+ if ( eMode != SC_FOLLOW_NONE )
+ {
+ ScSplitPos eAlign;
+ if (pWhich)
+ eAlign = *pWhich;
+ else
+ eAlign = aViewData.GetActivePart();
+ ScHSplitPos eAlignX = WhichH(eAlign);
+ ScVSplitPos eAlignY = WhichV(eAlign);
+
+ SCsCOL nDeltaX = (SCsCOL) aViewData.GetPosX(eAlignX);
+ SCsROW nDeltaY = (SCsROW) aViewData.GetPosY(eAlignY);
+ SCsCOL nSizeX = (SCsCOL) aViewData.VisibleCellsX(eAlignX);
+ SCsROW nSizeY = (SCsROW) aViewData.VisibleCellsY(eAlignY);
+
+ long nCellSizeX;
+ long nCellSizeY;
+ if ( nCurX >= 0 && nCurY >= 0 )
+ aViewData.GetMergeSizePixel( (SCCOL)nCurX, (SCROW)nCurY, nCellSizeX, nCellSizeY );
+ else
+ nCellSizeX = nCellSizeY = 0;
+ Size aScrSize = aViewData.GetScrSize();
+ long nSpaceX = ( aScrSize.Width() - nCellSizeX ) / 2;
+ long nSpaceY = ( aScrSize.Height() - nCellSizeY ) / 2;
+ // nSpaceY: desired start position of cell for FOLLOW_JUMP, modified if dialog interferes
+
+ BOOL bForceNew = FALSE; // force new calculation of JUMP position (vertical only)
+
+ // VisibleCellsY == CellsAtY( GetPosY( eWhichY ), 1, eWhichY )
+
+ //-------------------------------------------------------------------------------
+ // falls z.B. Suchen-Dialog offen ist, Cursor nicht hinter den Dialog stellen
+ // wenn moeglich, die Zeile mit dem Cursor oberhalb oder unterhalb des Dialogs
+
+ //! nicht, wenn schon komplett sichtbar
+
+ if ( eMode == SC_FOLLOW_JUMP )
+ {
+ Window* pCare = lcl_GetCareWin( aViewData.GetViewShell()->GetViewFrame() );
+ if (pCare)
+ {
+ BOOL bLimit = FALSE;
+ Rectangle aDlgPixel;
+ Size aWinSize;
+ Window* pWin = GetActiveWin();
+ if (pWin)
+ {
+ aDlgPixel = pCare->GetWindowExtentsRelative( pWin );
+ aWinSize = pWin->GetOutputSizePixel();
+ // ueberdeckt der Dialog das GridWin?
+ if ( aDlgPixel.Right() >= 0 && aDlgPixel.Left() < aWinSize.Width() )
+ {
+ if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX ||
+ nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
+ bLimit = TRUE; // es wird sowieso gescrollt
+ else
+ {
+ // Cursor ist auf dem Bildschirm
+ Point aStart = aViewData.GetScrPos( nCurX, nCurY, eAlign );
+ long nCSX, nCSY;
+ aViewData.GetMergeSizePixel( nCurX, nCurY, nCSX, nCSY );
+ Rectangle aCursor( aStart, Size( nCSX, nCSY ) );
+ if ( aCursor.IsOver( aDlgPixel ) )
+ bLimit = TRUE; // Zelle vom Dialog ueberdeckt
+ }
+ }
+ }
+
+ if (bLimit)
+ {
+ BOOL bBottom = FALSE;
+ long nTopSpace = aDlgPixel.Top();
+ long nBotSpace = aWinSize.Height() - aDlgPixel.Bottom();
+ if ( nBotSpace > 0 && nBotSpace > nTopSpace )
+ {
+ long nDlgBot = aDlgPixel.Bottom();
+ SCsCOL nWPosX;
+ SCsROW nWPosY;
+ aViewData.GetPosFromPixel( 0,nDlgBot, eAlign, nWPosX, nWPosY );
+ ++nWPosY; // unter der letzten betroffenen Zelle
+
+ SCsROW nDiff = nWPosY - nDeltaY;
+ if ( nCurY >= nDiff ) // Pos. kann nicht negativ werden
+ {
+ nSpaceY = nDlgBot + ( nBotSpace - nCellSizeY ) / 2;
+ bBottom = TRUE;
+ bForceNew = TRUE;
+ }
+ }
+ if ( !bBottom && nTopSpace > 0 )
+ {
+ nSpaceY = ( nTopSpace - nCellSizeY ) / 2;
+ bForceNew = TRUE;
+ }
+ }
+ }
+ }
+ //-------------------------------------------------------------------------------
+
+ SCsCOL nNewDeltaX = nDeltaX;
+ SCsROW nNewDeltaY = nDeltaY;
+ BOOL bDoLine = FALSE;
+
+ switch (eMode)
+ {
+ case SC_FOLLOW_JUMP:
+ if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
+ {
+ nNewDeltaX = nCurX - static_cast<SCsCOL>(aViewData.CellsAtX( nCurX, -1, eAlignX, static_cast<USHORT>(nSpaceX) ));
+ if (nNewDeltaX < 0) nNewDeltaX = 0;
+ nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
+ }
+ if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY || bForceNew )
+ {
+ nNewDeltaY = nCurY - static_cast<SCsROW>(aViewData.CellsAtY( nCurY, -1, eAlignY, static_cast<USHORT>(nSpaceY) ));
+ if (nNewDeltaY < 0) nNewDeltaY = 0;
+ nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
+ }
+ bDoLine = TRUE;
+ break;
+
+ case SC_FOLLOW_LINE:
+ bDoLine = TRUE;
+ break;
+
+ case SC_FOLLOW_FIX:
+ if ( nCurX < nDeltaX || nCurX >= nDeltaX+nSizeX )
+ {
+ nNewDeltaX = nDeltaX + nCurX - aViewData.GetCurX();
+ nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
+ }
+ if ( nCurY < nDeltaY || nCurY >= nDeltaY+nSizeY )
+ {
+ nNewDeltaY = nDeltaY + nCurY - aViewData.GetCurY();
+ nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
+ }
+
+ // like old version of SC_FOLLOW_JUMP:
+
+ if ( nCurX < nNewDeltaX || nCurX >= nNewDeltaX+nSizeX )
+ {
+ nNewDeltaX = nCurX - (nSizeX / 2);
+ if (nNewDeltaX < 0) nNewDeltaY = 0;
+ nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
+ }
+ if ( nCurY < nNewDeltaY || nCurY >= nNewDeltaY+nSizeY )
+ {
+ nNewDeltaY = nCurY - (nSizeY / 2);
+ if (nNewDeltaY < 0) nNewDeltaY = 0;
+ nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
+ }
+
+ bDoLine = TRUE;
+ break;
+
+ case SC_FOLLOW_NONE:
+ break;
+ default:
+ DBG_ERROR("Falscher Cursormodus");
+ break;
+ }
+
+ if (bDoLine)
+ {
+ while ( nCurX >= nNewDeltaX+nSizeX )
+ {
+ nNewDeltaX = nCurX-nSizeX+1;
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ while ( nNewDeltaX < MAXCOL && !pDoc->GetColWidth( nNewDeltaX, nTab ) )
+ ++nNewDeltaX;
+ nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
+ }
+ while ( nCurY >= nNewDeltaY+nSizeY )
+ {
+ nNewDeltaY = nCurY-nSizeY+1;
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ while ( nNewDeltaY < MAXROW && !pDoc->GetRowHeight( nNewDeltaY, nTab ) )
+ ++nNewDeltaY;
+ nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
+ }
+ if ( nCurX < nNewDeltaX ) nNewDeltaX = nCurX;
+ if ( nCurY < nNewDeltaY ) nNewDeltaY = nCurY;
+ }
+
+ if ( nNewDeltaX != nDeltaX )
+ nSizeX = (SCsCOL) aViewData.CellsAtX( nNewDeltaX, 1, eAlignX );
+ if (nNewDeltaX+nSizeX-1 > MAXCOL) nNewDeltaX = MAXCOL-nSizeX+1;
+ if (nNewDeltaX < 0) nNewDeltaX = 0;
+
+ if ( nNewDeltaY != nDeltaY )
+ nSizeY = (SCsROW) aViewData.CellsAtY( nNewDeltaY, 1, eAlignY );
+ if (nNewDeltaY+nSizeY-1 > MAXROW) nNewDeltaY = MAXROW-nSizeY+1;
+ if (nNewDeltaY < 0) nNewDeltaY = 0;
+
+ if ( nNewDeltaX != nDeltaX ) ScrollX( nNewDeltaX - nDeltaX, eAlignX );
+ if ( nNewDeltaY != nDeltaY ) ScrollY( nNewDeltaY - nDeltaY, eAlignY );
+ }
+
+ //
+ // nochmal aktiven Teil umschalten
+ //
+
+ if (bHFix)
+ if (eActiveX == SC_SPLIT_RIGHT && nCurX < (SCsCOL)aViewData.GetFixPosX())
+ {
+ ActivatePart( (eActiveY==SC_SPLIT_TOP) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT );
+ eActiveX = SC_SPLIT_LEFT;
+ }
+ if (bVFix)
+ if (eActiveY == SC_SPLIT_BOTTOM && nCurY < (SCsROW)aViewData.GetFixPosY())
+ {
+ ActivatePart( (eActiveX==SC_SPLIT_LEFT) ? SC_SPLIT_TOPLEFT : SC_SPLIT_TOPRIGHT );
+ eActiveY = SC_SPLIT_TOP;
+ }
+}
+
+BOOL ScTabView::SelMouseButtonDown( const MouseEvent& rMEvt )
+{
+ BOOL bRet = FALSE;
+
+ // #i3875# *Hack*
+ BOOL bMod1Locked = aViewData.GetViewShell()->GetLockedModifiers() & KEY_MOD1 ? TRUE : FALSE;
+ aViewData.SetSelCtrlMouseClick( rMEvt.IsMod1() || bMod1Locked );
+
+ if ( pSelEngine )
+ {
+ bMoveIsShift = rMEvt.IsShift();
+ bRet = pSelEngine->SelMouseButtonDown( rMEvt );
+ bMoveIsShift = FALSE;
+ }
+
+ aViewData.SetSelCtrlMouseClick( FALSE ); // #i3875# *Hack*
+
+ return bRet;
+}
+
+ //
+ // MoveCursor - mit Anpassung des Bildausschnitts
+ //
+
+void ScTabView::MoveCursorAbs( SCsCOL nCurX, SCsROW nCurY, ScFollowMode eMode,
+ BOOL bShift, BOOL bControl, BOOL bKeepOld, BOOL bKeepSel )
+{
+ if (!bKeepOld)
+ aViewData.ResetOldCursor();
+
+ if (nCurX < 0) nCurX = 0;
+ if (nCurY < 0) nCurY = 0;
+ if (nCurX > MAXCOL) nCurX = MAXCOL;
+ if (nCurY > MAXROW) nCurY = MAXROW;
+
+ HideAllCursors();
+
+ // aktiven Teil umschalten jetzt in AlignToCursor
+
+ AlignToCursor( nCurX, nCurY, eMode );
+ //! auf OS/2: SC_FOLLOW_JUMP statt SC_FOLLOW_LINE, um Nachlaufen zu verhindern ???
+
+ if (bKeepSel)
+ {
+ SetCursor( nCurX, nCurY ); // Markierung stehenlassen
+
+ // If the cursor is in existing selection, it's a cursor movement by
+ // ENTER or TAB. If not, then it's a new selection during ADD
+ // selection mode.
+
+ const ScMarkData& rMark = aViewData.GetMarkData();
+ ScRangeList aSelList;
+ rMark.FillRangeListWithMarks(&aSelList, false);
+ if (!aSelList.In(ScRange(nCurX, nCurY, aViewData.GetTabNo())))
+ // Cursor not in existing selection. Start a new selection.
+ DoneBlockMode(true);
+ }
+ else
+ {
+ if (!bShift)
+ {
+ // Remove all marked data on cursor movement unless the Shift is locked.
+ ScMarkData aData(aViewData.GetMarkData());
+ aData.ResetMark();
+ SetMarkData(aData);
+ }
+
+ BOOL bSame = ( nCurX == aViewData.GetCurX() && nCurY == aViewData.GetCurY() );
+ bMoveIsShift = bShift;
+ pSelEngine->CursorPosChanging( bShift, bControl );
+ bMoveIsShift = FALSE;
+ aFunctionSet.SetCursorAtCell( nCurX, nCurY, FALSE );
+
+ // Wenn der Cursor nicht bewegt wurde, muss das SelectionChanged fuer das
+ // Aufheben der Selektion hier einzeln passieren:
+ if (bSame)
+ SelectionChanged();
+ }
+
+ ShowAllCursors();
+}
+
+void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
+ BOOL bShift, BOOL bKeepSel )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ bool bSkipProtected = false, bSkipUnprotected = false;
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if ( pProtect && pProtect->isProtected() )
+ {
+ bSkipProtected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS);
+ bSkipUnprotected = !pProtect->isOptionEnabled(ScTableProtection::SELECT_UNLOCKED_CELLS);
+ }
+
+ if ( bSkipProtected && bSkipUnprotected )
+ return;
+
+ SCsCOL nOldX;
+ SCsROW nOldY;
+ SCsCOL nCurX;
+ SCsROW nCurY;
+ if ( aViewData.IsRefMode() )
+ {
+ nOldX = (SCsCOL) aViewData.GetRefEndX();
+ nOldY = (SCsROW) aViewData.GetRefEndY();
+ nCurX = nOldX + nMovX;
+ nCurY = nOldY + nMovY;
+ }
+ else
+ {
+ nOldX = (SCsCOL) aViewData.GetCurX();
+ nOldY = (SCsROW) aViewData.GetCurY();
+ nCurX = (nMovX != 0) ? nOldX+nMovX : (SCsCOL) aViewData.GetOldCurX();
+ nCurY = (nMovY != 0) ? nOldY+nMovY : (SCsROW) aViewData.GetOldCurY();
+ }
+
+ BOOL bSkipCell = FALSE;
+ aViewData.ResetOldCursor();
+
+ if (nMovX != 0 && VALIDCOLROW(nCurX,nCurY))
+ SkipCursorHorizontal(nCurX, nCurY, nOldX, nMovX);
+
+ if (nMovY != 0 && VALIDCOLROW(nCurX,nCurY))
+ SkipCursorVertical(nCurX, nCurY, nOldY, nMovY);
+
+ MoveCursorAbs( nCurX, nCurY, eMode, bShift, FALSE, TRUE, bKeepSel );
+}
+
+void ScTabView::MoveCursorPage( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift, BOOL bKeepSel )
+{
+ SCsCOL nPageX;
+ SCsROW nPageY;
+ GetPageMoveEndPosition(nMovX, nMovY, nPageX, nPageY);
+ MoveCursorRel( nPageX, nPageY, eMode, bShift, bKeepSel );
+}
+
+void ScTabView::MoveCursorArea( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift, BOOL bKeepSel )
+{
+ SCsCOL nNewX;
+ SCsROW nNewY;
+ GetAreaMoveEndPosition(nMovX, nMovY, eMode, nNewX, nNewY, eMode);
+ MoveCursorRel(nNewX, nNewY, eMode, bShift, bKeepSel);
+}
+
+void ScTabView::MoveCursorEnd( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift, BOOL bKeepSel )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+ SCCOL nNewX = nCurX;
+ SCROW nNewY = nCurY;
+
+ SCCOL nUsedX = 0;
+ SCROW nUsedY = 0;
+ if ( nMovX > 0 || nMovY > 0 )
+ pDoc->GetPrintArea( nTab, nUsedX, nUsedY ); // Ende holen
+
+ if (nMovX<0)
+ nNewX=0;
+ else if (nMovX>0)
+ nNewX=nUsedX; // letzter benutzter Bereich
+
+ if (nMovY<0)
+ nNewY=0;
+ else if (nMovY>0)
+ nNewY=nUsedY;
+
+ aViewData.ResetOldCursor();
+ MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY, eMode, bShift, bKeepSel );
+}
+
+void ScTabView::MoveCursorScreen( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode, BOOL bShift )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+ SCCOL nNewX = nCurX;
+ SCROW nNewY = nCurY;
+
+ ScSplitPos eWhich = aViewData.GetActivePart();
+ SCCOL nPosX = aViewData.GetPosX( WhichH(eWhich) );
+ SCROW nPosY = aViewData.GetPosY( WhichV(eWhich) );
+
+ SCCOL nAddX = aViewData.VisibleCellsX( WhichH(eWhich) );
+ if (nAddX != 0)
+ --nAddX;
+ SCROW nAddY = aViewData.VisibleCellsY( WhichV(eWhich) );
+ if (nAddY != 0)
+ --nAddY;
+
+ if (nMovX<0)
+ nNewX=nPosX;
+ else if (nMovX>0)
+ nNewX=nPosX+nAddX;
+
+ if (nMovY<0)
+ nNewY=nPosY;
+ else if (nMovY>0)
+ nNewY=nPosY+nAddY;
+
+ aViewData.SetOldCursor( nNewX,nNewY );
+ pDoc->SkipOverlapped(nNewX, nNewY, nTab);
+ MoveCursorAbs( nNewX, nNewY, eMode, bShift, FALSE, TRUE );
+}
+
+void ScTabView::MoveCursorEnter( BOOL bShift ) // bShift -> hoch/runter
+{
+ const ScInputOptions& rOpt = SC_MOD()->GetInputOptions();
+ if (!rOpt.GetMoveSelection())
+ {
+ aViewData.UpdateInputHandler(TRUE);
+ return;
+ }
+
+ SCsCOL nMoveX = 0;
+ SCsROW nMoveY = 0;
+ switch ((ScDirection)rOpt.GetMoveDir())
+ {
+ case DIR_BOTTOM:
+ nMoveY = bShift ? -1 : 1;
+ break;
+ case DIR_RIGHT:
+ nMoveX = bShift ? -1 : 1;
+ break;
+ case DIR_TOP:
+ nMoveY = bShift ? 1 : -1;
+ break;
+ case DIR_LEFT:
+ nMoveX = bShift ? 1 : -1;
+ break;
+ }
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ if (rMark.IsMarked() || rMark.IsMultiMarked())
+ {
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+ SCCOL nNewX = nCurX;
+ SCROW nNewY = nCurY;
+ SCTAB nTab = aViewData.GetTabNo();
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ pDoc->GetNextPos( nNewX,nNewY, nTab, nMoveX,nMoveY, TRUE,FALSE, rMark );
+
+ MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
+ SC_FOLLOW_LINE, FALSE, TRUE );
+
+ // update input line even if cursor was not moved
+ if ( nNewX == nCurX && nNewY == nCurY )
+ aViewData.UpdateInputHandler(TRUE);
+ }
+ else
+ {
+ if ( nMoveY != 0 && !nMoveX )
+ {
+ // nach Tab und Enter wieder zur Ausgangsspalte
+ SCCOL nTabCol = aViewData.GetTabStartCol();
+ if (nTabCol != SC_TABSTART_NONE)
+ {
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+ nMoveX = ((SCsCOL)nTabCol)-(SCsCOL)nCurX;
+ }
+ }
+
+ MoveCursorRel( nMoveX,nMoveY, SC_FOLLOW_LINE, FALSE );
+ }
+}
+
+
+BOOL ScTabView::MoveCursorKeyInput( const KeyEvent& rKeyEvent )
+{
+ const KeyCode& rKCode = rKeyEvent.GetKeyCode();
+
+ enum { MOD_NONE, MOD_CTRL, MOD_ALT, MOD_BOTH } eModifier =
+ rKCode.IsMod1() ?
+ (rKCode.IsMod2() ? MOD_BOTH : MOD_CTRL) :
+ (rKCode.IsMod2() ? MOD_ALT : MOD_NONE);
+
+ BOOL bSel = rKCode.IsShift();
+ USHORT nCode = rKCode.GetCode();
+
+ // CURSOR keys
+ SCsCOL nDX = 0;
+ SCsROW nDY = 0;
+ switch( nCode )
+ {
+ case KEY_LEFT: nDX = -1; break;
+ case KEY_RIGHT: nDX = 1; break;
+ case KEY_UP: nDY = -1; break;
+ case KEY_DOWN: nDY = 1; break;
+ }
+ if( nDX != 0 || nDY != 0 )
+ {
+ switch( eModifier )
+ {
+ case MOD_NONE: MoveCursorRel( nDX, nDY, SC_FOLLOW_LINE, bSel ); break;
+ case MOD_CTRL: MoveCursorArea( nDX, nDY, SC_FOLLOW_JUMP, bSel ); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ // always TRUE to suppress changes of col/row size (ALT+CURSOR)
+ return TRUE;
+ }
+
+ // PAGEUP/PAGEDOWN
+ if( (nCode == KEY_PAGEUP) || (nCode == KEY_PAGEDOWN) )
+ {
+ nDX = (nCode == KEY_PAGEUP) ? -1 : 1;
+ switch( eModifier )
+ {
+ case MOD_NONE: MoveCursorPage( 0, static_cast<SCsCOLROW>(nDX), SC_FOLLOW_FIX, bSel ); break;
+ case MOD_ALT: MoveCursorPage( nDX, 0, SC_FOLLOW_FIX, bSel ); break;
+ case MOD_CTRL: SelectNextTab( nDX ); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return TRUE;
+ }
+
+ // HOME/END
+ if( (nCode == KEY_HOME) || (nCode == KEY_END) )
+ {
+ nDX = (nCode == KEY_HOME) ? -1 : 1;
+ ScFollowMode eMode = (nCode == KEY_HOME) ? SC_FOLLOW_LINE : SC_FOLLOW_JUMP;
+ switch( eModifier )
+ {
+ case MOD_NONE: MoveCursorEnd( nDX, 0, eMode, bSel ); break;
+ case MOD_CTRL: MoveCursorEnd( nDX, static_cast<SCsCOLROW>(nDX), eMode, bSel ); break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+ // naechste/vorherige nicht geschuetzte Zelle
+void ScTabView::FindNextUnprot( BOOL bShift, BOOL bInSelection )
+{
+ short nMove = bShift ? -1 : 1;
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ BOOL bMarked = bInSelection && (rMark.IsMarked() || rMark.IsMultiMarked());
+
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+ SCCOL nNewX = nCurX;
+ SCROW nNewY = nCurY;
+ SCTAB nTab = aViewData.GetTabNo();
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ pDoc->GetNextPos( nNewX,nNewY, nTab, nMove,0, bMarked,TRUE, rMark );
+
+ SCCOL nTabCol = aViewData.GetTabStartCol();
+ if ( nTabCol == SC_TABSTART_NONE )
+ nTabCol = nCurX; // auf diese Spalte zurueck bei Enter
+
+ MoveCursorRel( ((SCsCOL)nNewX)-(SCsCOL)nCurX, ((SCsROW)nNewY)-(SCsROW)nCurY,
+ SC_FOLLOW_LINE, FALSE, TRUE );
+
+ // in MoveCursorRel wird die TabCol zurueckgesetzt...
+ aViewData.SetTabStartCol( nTabCol );
+}
+
+void ScTabView::MarkColumns()
+{
+ SCCOL nStartCol;
+ SCCOL nEndCol;
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ if (rMark.IsMarked())
+ {
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+ nStartCol = aMarkRange.aStart.Col();
+ nEndCol = aMarkRange.aEnd.Col();
+ }
+ else
+ {
+ SCROW nDummy;
+ aViewData.GetMoveCursor( nStartCol, nDummy );
+ nEndCol=nStartCol;
+ }
+
+ SCTAB nTab = aViewData.GetTabNo();
+ DoneBlockMode();
+ InitBlockMode( nStartCol,0, nTab );
+ MarkCursor( nEndCol,MAXROW, nTab );
+ SelectionChanged();
+}
+
+void ScTabView::MarkRows()
+{
+ SCROW nStartRow;
+ SCROW nEndRow;
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ if (rMark.IsMarked())
+ {
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+ nStartRow = aMarkRange.aStart.Row();
+ nEndRow = aMarkRange.aEnd.Row();
+ }
+ else
+ {
+ SCCOL nDummy;
+ aViewData.GetMoveCursor( nDummy, nStartRow );
+ nEndRow=nStartRow;
+ }
+
+ SCTAB nTab = aViewData.GetTabNo();
+ DoneBlockMode();
+ InitBlockMode( 0,nStartRow, nTab );
+ MarkCursor( MAXCOL,nEndRow, nTab );
+ SelectionChanged();
+}
+
+void ScTabView::MarkDataArea( BOOL bIncludeCursor )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ SCCOL nStartCol = aViewData.GetCurX();
+ SCROW nStartRow = aViewData.GetCurY();
+ SCCOL nEndCol = nStartCol;
+ SCROW nEndRow = nStartRow;
+
+ pDoc->GetDataArea( nTab, nStartCol, nStartRow, nEndCol, nEndRow, bIncludeCursor, false );
+
+ HideAllCursors();
+ DoneBlockMode();
+ InitBlockMode( nStartCol, nStartRow, nTab );
+ MarkCursor( nEndCol, nEndRow, nTab );
+ ShowAllCursors();
+
+ SelectionChanged();
+}
+
+void ScTabView::MarkMatrixFormula()
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ ScAddress aCursor( aViewData.GetCurX(), aViewData.GetCurY(), aViewData.GetTabNo() );
+ ScRange aMatrix;
+ if ( pDoc->GetMatrixFormulaRange( aCursor, aMatrix ) )
+ {
+ MarkRange( aMatrix, FALSE ); // cursor is already within the range
+ }
+}
+
+void ScTabView::MarkRange( const ScRange& rRange, BOOL bSetCursor, BOOL bContinue )
+{
+ SCTAB nTab = rRange.aStart.Tab();
+ SetTabNo( nTab );
+
+ HideAllCursors();
+ DoneBlockMode( bContinue ); // bContinue==TRUE -> clear old mark
+ if (bSetCursor) // Wenn Cursor gesetzt wird, immer auch alignen
+ {
+ SCCOL nAlignX = rRange.aStart.Col();
+ SCROW nAlignY = rRange.aStart.Row();
+ bool bCol = ( rRange.aStart.Col() == 0 && rRange.aEnd.Col() == MAXCOL ) && !aViewData.GetDocument()->IsInVBAMode();
+ bool bRow = ( rRange.aStart.Row() == 0 && rRange.aEnd.Row() == MAXROW );
+ if ( bCol )
+ nAlignX = aViewData.GetPosX(WhichH(aViewData.GetActivePart()));
+ if ( bRow )
+ nAlignY = aViewData.GetPosY(WhichV(aViewData.GetActivePart()));
+ AlignToCursor( nAlignX, nAlignY, SC_FOLLOW_JUMP );
+ }
+ InitBlockMode( rRange.aStart.Col(), rRange.aStart.Row(), nTab );
+ MarkCursor( rRange.aEnd.Col(), rRange.aEnd.Row(), nTab );
+ if (bSetCursor)
+ {
+ SCCOL nPosX = rRange.aStart.Col();
+ SCROW nPosY = rRange.aStart.Row();
+ ScDocument* pDoc = aViewData.GetDocument();
+ pDoc->SkipOverlapped(nPosX, nPosY, nTab);
+
+ aViewData.ResetOldCursor();
+ SetCursor( nPosX, nPosY );
+ }
+ ShowAllCursors();
+
+ SelectionChanged();
+}
+
+void ScTabView::Unmark()
+{
+ ScMarkData& rMark = aViewData.GetMarkData();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ SCCOL nCurX;
+ SCROW nCurY;
+ aViewData.GetMoveCursor( nCurX,nCurY );
+ MoveCursorAbs( nCurX, nCurY, SC_FOLLOW_NONE, FALSE, FALSE );
+
+ SelectionChanged();
+ }
+}
+
+void ScTabView::SetMarkData( const ScMarkData& rNew )
+{
+ DoneBlockMode();
+ InitOwnBlockMode();
+ aViewData.GetMarkData() = rNew;
+
+ MarkDataChanged();
+}
+
+void ScTabView::MarkDataChanged()
+{
+ // has to be called after making direct changes to mark data (not via MarkCursor etc)
+
+ UpdateSelectionOverlay();
+}
+
+void ScTabView::SelectNextTab( short nDir, BOOL bExtendSelection )
+{
+ if (!nDir) return;
+ DBG_ASSERT( nDir==-1 || nDir==1, "SelectNextTab: falscher Wert");
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ if (nDir<0)
+ {
+ if (!nTab) return;
+ --nTab;
+ while (!pDoc->IsVisible(nTab))
+ {
+ if (!nTab) return;
+ --nTab;
+ }
+ }
+ else
+ {
+ SCTAB nCount = pDoc->GetTableCount();
+ ++nTab;
+ if (nTab >= nCount) return;
+ while (!pDoc->IsVisible(nTab))
+ {
+ ++nTab;
+ if (nTab >= nCount) return;
+ }
+ }
+
+ SetTabNo( nTab, FALSE, bExtendSelection );
+ PaintExtras();
+}
+
+
+// SetTabNo - angezeigte Tabelle
+
+void ScTabView::SetTabNo( SCTAB nTab, BOOL bNew, BOOL bExtendSelection )
+{
+ if ( !ValidTab(nTab) )
+ {
+ DBG_ERROR("SetTabNo: falsche Tabelle");
+ return;
+ }
+
+ if ( nTab != aViewData.GetTabNo() || bNew )
+ {
+ // #57724# Die FormShell moechte vor dem Umschalten benachrichtigt werden
+ FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
+ if (pFormSh)
+ {
+ BOOL bAllowed = sal::static_int_cast<BOOL>( pFormSh->PrepareClose( TRUE ) );
+ if (!bAllowed)
+ {
+ //! Fehlermeldung? oder macht das die FormShell selber?
+ //! Fehler-Flag zurueckgeben und Aktionen abbrechen
+
+ return; // Die FormShell sagt, es kann nicht umgeschaltet werden
+ }
+ }
+
+ // nicht InputEnterHandler wegen Referenzeingabe !
+
+ ScDocument* pDoc = aViewData.GetDocument();
+
+ pDoc->MakeTable( nTab );
+
+ // Update pending row heights before switching the sheet, so Reschedule from the progress bar
+ // doesn't paint the new sheet with old heights
+ aViewData.GetDocShell()->UpdatePendingRowHeights( nTab );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nOldPos = nTab;
+ while (!pDoc->IsVisible(nTab)) // naechste sichtbare suchen
+ {
+ BOOL bUp = (nTab>=nOldPos);
+ if (bUp)
+ {
+ ++nTab;
+ if (nTab>=nTabCount)
+ {
+ nTab = nOldPos;
+ bUp = FALSE;
+ }
+ }
+
+ if (!bUp)
+ {
+ if (nTab != 0)
+ --nTab;
+ else
+ {
+ DBG_ERROR("keine sichtbare Tabelle");
+ pDoc->SetVisible( 0, TRUE );
+ }
+ }
+ }
+
+ // #i71490# Deselect drawing objects before changing the sheet number in view data,
+ // so the handling of notes still has the sheet selected on which the notes are.
+ DrawDeselectAll();
+
+ ScModule* pScMod = SC_MOD();
+ BOOL bRefMode = pScMod->IsFormulaMode();
+ if ( !bRefMode ) // Abfrage, damit RefMode bei Tabellenwechsel funktioniert
+ {
+ DoneBlockMode();
+ pSelEngine->Reset(); // reset all flags, including locked modifiers
+ aViewData.SetRefTabNo( nTab );
+ }
+
+ ScSplitPos eOldActive = aViewData.GetActivePart(); // before switching
+ BOOL bFocus = pGridWin[eOldActive]->HasFocus();
+
+ aViewData.SetTabNo( nTab );
+ // UpdateShow noch vor SetCursor, damit UpdateAutoFillMark die richtigen
+ // Fenster findet (wird aus SetCursor gerufen)
+ UpdateShow();
+ aViewData.ResetOldCursor();
+ SetCursor( aViewData.GetCurX(), aViewData.GetCurY(), TRUE );
+
+ SfxBindings& rBindings = aViewData.GetBindings();
+ ScMarkData& rMark = aViewData.GetMarkData();
+
+ bool bAllSelected = true;
+ for (SCTAB nSelTab = 0; nSelTab < nTabCount; ++nSelTab)
+ {
+ if (!pDoc->IsVisible(nSelTab) || rMark.GetTableSelect(nSelTab))
+ {
+ if (nTab == nSelTab)
+ // This tab is already in selection. Keep the current
+ // selection.
+ bExtendSelection = true;
+ }
+ else
+ {
+ bAllSelected = false;
+ if (bExtendSelection)
+ // We got what we need. No need to stay in the loop.
+ break;
+ }
+ }
+ if (bAllSelected && !bNew)
+ // #i6327# if all tables are selected, a selection event (#i6330#) will deselect all
+ // (not if called with bNew to update settings)
+ bExtendSelection = false;
+
+ if (bExtendSelection)
+ rMark.SelectTable( nTab, TRUE );
+ else
+ {
+ rMark.SelectOneTable( nTab );
+ rBindings.Invalidate( FID_FILL_TAB );
+ rBindings.Invalidate( FID_TAB_DESELECTALL );
+ }
+
+ bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
+
+ // recalc zoom-dependent values (before TabChanged, before UpdateEditViewPos)
+ RefreshZoom();
+ UpdateVarZoom();
+
+ if ( bRefMode ) // hide EditView if necessary (after aViewData.SetTabNo !)
+ {
+ for (USHORT i = 0; i < 4; ++i)
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ pGridWin[i]->UpdateEditViewPos();
+ }
+
+ TabChanged(); // DrawView
+ UpdateVisibleRange();
+
+ aViewData.GetViewShell()->WindowChanged(); // falls das aktive Fenster anders ist
+ if ( !bUnoRefDialog )
+ aViewData.GetViewShell()->DisconnectAllClients(); // important for floating frames
+ else
+ {
+ // hide / show inplace client
+
+ ScClient* pClient = static_cast<ScClient*>(aViewData.GetViewShell()->GetIPClient());
+ if ( pClient && pClient->IsObjectInPlaceActive() )
+ {
+ Rectangle aObjArea = pClient->GetObjArea();
+ if ( nTab == aViewData.GetRefTabNo() )
+ {
+ // move to its original position
+
+ SdrOle2Obj* pDrawObj = pClient->GetDrawObj();
+ if ( pDrawObj )
+ {
+ Rectangle aRect = pDrawObj->GetLogicRect();
+ MapMode aMapMode( MAP_100TH_MM );
+ Size aOleSize = pDrawObj->GetOrigObjSize( &aMapMode );
+ aRect.SetSize( aOleSize );
+ aObjArea = aRect;
+ }
+ }
+ else
+ {
+ // move to an invisible position
+
+ aObjArea.SetPos( Point( 0, -2*aObjArea.GetHeight() ) );
+ }
+ pClient->SetObjArea( aObjArea );
+ }
+ }
+
+ if ( bFocus && aViewData.GetActivePart() != eOldActive && !bRefMode )
+ ActiveGrabFocus(); // grab focus to the pane that's active now
+
+ // Fixierungen
+
+ BOOL bResize = FALSE;
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX )
+ if (aViewData.UpdateFixX())
+ bResize = TRUE;
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX )
+ if (aViewData.UpdateFixY())
+ bResize = TRUE;
+ if (bResize)
+ RepeatResize();
+ InvalidateSplit();
+
+ if ( aViewData.IsPagebreakMode() )
+ UpdatePageBreakData(); //! asynchron ??
+
+ // #53551# Form-Layer muss den sichtbaren Ausschnitt der neuen Tabelle kennen
+ // dafuer muss hier schon der MapMode stimmen
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ pGridWin[i]->SetMapMode( pGridWin[i]->GetDrawMapMode() );
+ SetNewVisArea();
+
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ PaintExtras();
+
+ DoResize( aBorderPos, aFrameSize );
+ rBindings.Invalidate( SID_DELETE_PRINTAREA ); // Menue
+ rBindings.Invalidate( FID_DEL_MANUALBREAKS );
+ rBindings.Invalidate( FID_RESET_PRINTZOOM );
+ rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
+ rBindings.Invalidate( SID_STATUS_PAGESTYLE ); // Statusbar
+ rBindings.Invalidate( SID_CURRENTTAB ); // Navigator
+ rBindings.Invalidate( SID_STYLE_FAMILY2 ); // Gestalter
+ rBindings.Invalidate( SID_STYLE_FAMILY4 ); // Gestalter
+ rBindings.Invalidate( SID_TABLES_COUNT );
+
+ if(pScMod->IsRefDialogOpen())
+ {
+ USHORT nCurRefDlgId=pScMod->GetCurRefDlgId();
+ SfxViewFrame* pViewFrm = aViewData.GetViewShell()->GetViewFrame();
+ SfxChildWindow* pChildWnd = pViewFrm->GetChildWindow( nCurRefDlgId );
+ if ( pChildWnd )
+ {
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+ pRefDlg->ViewShellChanged(NULL);
+ }
+ }
+ }
+}
+
+//
+// Paint-Funktionen - nur fuer diese View
+//
+
+void ScTabView::MakeEditView( ScEditEngineDefaulter* pEngine, SCCOL nCol, SCROW nRow )
+{
+ DrawDeselectAll();
+
+ if (pDrawView)
+ DrawEnableAnim( FALSE );
+
+ EditView* pSpellingView = aViewData.GetSpellingView();
+
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ if ( pGridWin[i]->IsVisible() && !aViewData.HasEditView((ScSplitPos)i) )
+ {
+ ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
+ ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
+ SCCOL nScrX = aViewData.GetPosX( eHWhich );
+ SCROW nScrY = aViewData.GetPosY( eVWhich );
+
+ BOOL bPosVisible =
+ ( nCol >= nScrX && nCol <= nScrX + aViewData.VisibleCellsX(eHWhich) + 1 &&
+ nRow >= nScrY && nRow <= nScrY + aViewData.VisibleCellsY(eVWhich) + 1 );
+
+ // #102421# for the active part, create edit view even if outside the visible area,
+ // so input isn't lost (and the edit view may be scrolled into the visible area)
+
+ // #i26433# during spelling, the spelling view must be active
+ if ( bPosVisible || aViewData.GetActivePart() == (ScSplitPos) i ||
+ ( pSpellingView && aViewData.GetEditView((ScSplitPos) i) == pSpellingView ) )
+ {
+ pGridWin[i]->HideCursor();
+
+ pGridWin[i]->DeleteCursorOverlay();
+ pGridWin[i]->DeleteAutoFillOverlay();
+ pGridWin[i]->DeleteCopySourceOverlay();
+
+ // flush OverlayManager before changing MapMode to text edit
+ pGridWin[i]->flushOverlayManager();
+
+ // MapMode must be set after HideCursor
+ pGridWin[i]->SetMapMode(aViewData.GetLogicMode());
+
+ aViewData.SetEditEngine( (ScSplitPos) i, pEngine, pGridWin[i], nCol, nRow );
+
+ if ( !bPosVisible )
+ {
+ // move the edit view area to the real (possibly negative) position,
+ // or hide if completely above or left of the window
+ pGridWin[i]->UpdateEditViewPos();
+ }
+ }
+ }
+
+ if (aViewData.GetViewShell()->HasAccessibilityObjects())
+ aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_ENTEREDITMODE));
+}
+
+void ScTabView::UpdateEditView()
+{
+ ScSplitPos eActive = aViewData.GetActivePart();
+ for (USHORT i=0; i<4; i++)
+ if (aViewData.HasEditView( (ScSplitPos) i ))
+ {
+ EditView* pEditView = aViewData.GetEditView( (ScSplitPos) i );
+ aViewData.SetEditEngine( (ScSplitPos) i,
+ static_cast<ScEditEngineDefaulter*>(pEditView->GetEditEngine()),
+ pGridWin[i], GetViewData()->GetCurX(), GetViewData()->GetCurY() );
+ if ( (ScSplitPos)i == eActive )
+ pEditView->ShowCursor( FALSE );
+ }
+}
+
+void ScTabView::KillEditView( BOOL bNoPaint )
+{
+ USHORT i;
+ SCCOL nCol1 = aViewData.GetEditStartCol();
+ SCROW nRow1 = aViewData.GetEditStartRow();
+ SCCOL nCol2 = aViewData.GetEditEndCol();
+ SCROW nRow2 = aViewData.GetEditEndRow();
+ BOOL bPaint[4];
+ BOOL bNotifyAcc(false);
+
+ BOOL bExtended = nRow1 != nRow2; // Col wird sowieso bis zum Ende gezeichnet
+ BOOL bAtCursor = nCol1 <= aViewData.GetCurX() &&
+ nCol2 >= aViewData.GetCurX() &&
+ nRow1 == aViewData.GetCurY();
+ for (i=0; i<4; i++)
+ {
+ bPaint[i] = aViewData.HasEditView( (ScSplitPos) i );
+ if (bPaint[i])
+ bNotifyAcc = true;
+ }
+
+ // #108931#; notify accessibility before all things happen
+ if ((bNotifyAcc) && (aViewData.GetViewShell()->HasAccessibilityObjects()))
+ aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_LEAVEEDITMODE));
+
+ aViewData.ResetEditView();
+ for (i=0; i<4; i++)
+ if (pGridWin[i] && bPaint[i])
+ if (pGridWin[i]->IsVisible())
+ {
+ pGridWin[i]->ShowCursor();
+
+ pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
+
+ // #i73567# the cell still has to be repainted
+ if (bExtended || ( bAtCursor && !bNoPaint ))
+ {
+ pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2 );
+ pGridWin[i]->UpdateSelectionOverlay();
+ }
+ }
+
+ if (pDrawView)
+ DrawEnableAnim( TRUE );
+
+ // GrabFocus immer dann, wenn diese View aktiv ist und
+ // die Eingabezeile den Focus hat
+
+ BOOL bGrabFocus = FALSE;
+ if (aViewData.IsActive())
+ {
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
+ if ( pInputHdl )
+ {
+ ScInputWindow* pInputWin = pInputHdl->GetInputWindow();
+ if (pInputWin && pInputWin->IsInputActive())
+ bGrabFocus = TRUE;
+ }
+ }
+
+ if (bGrabFocus)
+ {
+// So soll es gemacht werden, damit der Sfx es mitbekommt, klappt aber nicht:
+//! aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus();
+// deshalb erstmal so:
+ GetActiveWin()->GrabFocus();
+ }
+
+ // Cursor-Abfrage erst nach GrabFocus
+
+ for (i=0; i<4; i++)
+ if (pGridWin[i] && pGridWin[i]->IsVisible())
+ {
+ Cursor* pCur = pGridWin[i]->GetCursor();
+ if (pCur && pCur->IsVisible())
+ pCur->Hide();
+
+ if(bPaint[i])
+ {
+ pGridWin[i]->UpdateCursorOverlay();
+ pGridWin[i]->UpdateAutoFillOverlay();
+ // pGridWin[i]->UpdateAllOverlays();
+ }
+ }
+}
+
+void ScTabView::UpdateFormulas()
+{
+ if ( aViewData.GetDocument()->IsAutoCalcShellDisabled() )
+ return ;
+
+ USHORT i;
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ pGridWin[i]->UpdateFormulas();
+
+ if ( aViewData.IsPagebreakMode() )
+ UpdatePageBreakData(); //! asynchron
+
+ UpdateHeaderWidth();
+
+ // if in edit mode, adjust edit view area because widths/heights may have changed
+ if ( aViewData.HasEditView( aViewData.GetActivePart() ) )
+ UpdateEditView();
+}
+
+// PaintArea -Block neu zeichnen
+
+void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ ScUpdateMode eMode )
+{
+ USHORT i;
+ SCCOL nCol1;
+ SCROW nRow1;
+ SCCOL nCol2;
+ SCROW nRow2;
+
+ PutInOrder( nStartCol, nEndCol );
+ PutInOrder( nStartRow, nEndRow );
+
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ {
+ ScHSplitPos eHWhich = WhichH( (ScSplitPos) i );
+ ScVSplitPos eVWhich = WhichV( (ScSplitPos) i );
+ BOOL bOut = FALSE;
+
+ nCol1 = nStartCol;
+ nRow1 = nStartRow;
+ nCol2 = nEndCol;
+ nRow2 = nEndRow;
+
+ SCCOL nScrX = aViewData.GetPosX( eHWhich );
+ SCROW nScrY = aViewData.GetPosY( eVWhich );
+ if (nCol1 < nScrX) nCol1 = nScrX;
+ if (nCol2 < nScrX)
+ {
+ if ( eMode == SC_UPDATE_ALL ) // #91240# for UPDATE_ALL, paint anyway
+ nCol2 = nScrX; // (because of extending strings to the right)
+ else
+ bOut = TRUE; // completely outside the window
+ }
+ if (nRow1 < nScrY) nRow1 = nScrY;
+ if (nRow2 < nScrY) bOut = TRUE;
+
+ SCCOL nLastX = nScrX + aViewData.VisibleCellsX( eHWhich ) + 1;
+ SCROW nLastY = nScrY + aViewData.VisibleCellsY( eVWhich ) + 1;
+ if (nCol1 > nLastX) bOut = TRUE;
+ if (nCol2 > nLastX) nCol2 = nLastX;
+ if (nRow1 > nLastY) bOut = TRUE;
+ if (nRow2 > nLastY) nRow2 = nLastY;
+
+ if (!bOut)
+ {
+ if ( eMode == SC_UPDATE_CHANGED )
+ pGridWin[i]->Draw( nCol1, nRow1, nCol2, nRow2, eMode );
+ else // ALL oder MARKS
+ {
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ Point aStart = aViewData.GetScrPos( nCol1, nRow1, (ScSplitPos) i );
+ Point aEnd = aViewData.GetScrPos( nCol2+1, nRow2+1, (ScSplitPos) i );
+ if ( eMode == SC_UPDATE_ALL )
+ aEnd.X() = bLayoutRTL ? 0 : (pGridWin[i]->GetOutputSizePixel().Width());
+ aEnd.X() -= nLayoutSign;
+ aEnd.Y() -= 1;
+
+ // #i85232# include area below cells (could be done in GetScrPos?)
+ if ( eMode == SC_UPDATE_ALL && nRow2 >= MAXROW )
+ aEnd.Y() = pGridWin[i]->GetOutputSizePixel().Height();
+
+ BOOL bShowChanges = TRUE; //! ...
+ if (bShowChanges)
+ {
+ aStart.X() -= nLayoutSign; // include change marks
+ aStart.Y() -= 1;
+ }
+
+ BOOL bMarkClipped = aViewData.GetOptions().GetOption( VOPT_CLIPMARKS );
+ if (bMarkClipped)
+ {
+ // dazu muesste ScColumn::IsEmptyBlock optimiert werden
+ // (auf Search() umstellen)
+ //!if ( nCol1 > 0 && !aViewData.GetDocument()->IsBlockEmpty(
+ //! aViewData.GetTabNo(),
+ //! 0, nRow1, nCol1-1, nRow2 ) )
+ {
+ long nMarkPixel = (long)( SC_CLIPMARK_SIZE * aViewData.GetPPTX() );
+ aStart.X() -= nMarkPixel * nLayoutSign;
+ if (!bShowChanges)
+ aStart.X() -= nLayoutSign; // cell grid
+ }
+ }
+
+ pGridWin[i]->Invalidate( pGridWin[i]->PixelToLogic( Rectangle( aStart,aEnd ) ) );
+ }
+ }
+ }
+
+ // #i79909# Calling UpdateAllOverlays here isn't necessary and would lead to overlay calls from a timer,
+ // with a wrong MapMode if editing in a cell (reference input).
+ // #i80499# Overlays need updates in a lot of cases, e.g. changing row/column size,
+ // or showing/hiding outlines. TODO: selections in inactive windows are vanishing.
+ // #i84689# With relative conditional formats, PaintArea may be called often (for each changed cell),
+ // so UpdateAllOverlays was moved to ScTabViewShell::Notify and is called only if PAINT_LEFT/PAINT_TOP
+ // is set (width or height changed).
+}
+
+void ScTabView::PaintRangeFinder( long nNumber )
+{
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() );
+ if (pHdl)
+ {
+ ScRangeFindList* pRangeFinder = pHdl->GetRangeFindList();
+ if ( pRangeFinder && pRangeFinder->GetDocName() == aViewData.GetDocShell()->GetTitle() )
+ {
+ SCTAB nTab = aViewData.GetTabNo();
+ USHORT nCount = (USHORT)pRangeFinder->Count();
+ for (USHORT i=0; i<nCount; i++)
+ if ( nNumber < 0 || nNumber == i )
+ {
+ ScRangeFindData* pData = pRangeFinder->GetObject(i);
+ if (pData)
+ {
+ ScRange aRef = pData->aRef;
+ aRef.Justify(); // Justify fuer die Abfragen unten
+
+ if ( aRef.aStart == aRef.aEnd ) //! Tab ignorieren?
+ aViewData.GetDocument()->ExtendMerge(aRef);
+
+ if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
+ {
+ SCCOL nCol1 = aRef.aStart.Col();
+ SCROW nRow1 = aRef.aStart.Row();
+ SCCOL nCol2 = aRef.aEnd.Col();
+ SCROW nRow2 = aRef.aEnd.Row();
+
+ // wegnehmen -> Repaint
+ // SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende
+
+ BOOL bHiddenEdge = FALSE;
+ SCROW nTmp;
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCCOL nLastCol = -1;
+ while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab, nLastCol) )
+ {
+ --nCol1;
+ bHiddenEdge = TRUE;
+ }
+ while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab, nLastCol) )
+ {
+ ++nCol2;
+ bHiddenEdge = TRUE;
+ }
+ nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
+ if (!ValidRow(nTmp))
+ nTmp = 0;
+ if (nTmp < nRow1)
+ {
+ nRow1 = nTmp;
+ bHiddenEdge = TRUE;
+ }
+ nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
+ if (!ValidRow(nTmp))
+ nTmp = MAXROW;
+ if (nTmp > nRow2)
+ {
+ nRow2 = nTmp;
+ bHiddenEdge = TRUE;
+ }
+
+ if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge )
+ {
+ // nur an den Raendern entlang
+ PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS );
+ PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS );
+ PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS );
+ PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS );
+ }
+ else // alles am Stueck
+ PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS );
+ }
+ }
+ }
+ }
+ }
+}
+
+// fuer Chart-Daten-Markierung
+
+void ScTabView::AddHighlightRange( const ScRange& rRange, const Color& rColor )
+{
+ if (!pHighlightRanges)
+ pHighlightRanges = new ScHighlightRanges;
+ pHighlightRanges->Insert( new ScHighlightEntry( rRange, rColor ) );
+
+ SCTAB nTab = aViewData.GetTabNo();
+ if ( nTab >= rRange.aStart.Tab() && nTab <= rRange.aEnd.Tab() )
+ PaintArea( rRange.aStart.Col(), rRange.aStart.Row(),
+ rRange.aEnd.Col(), rRange.aEnd.Row(), SC_UPDATE_MARKS );
+}
+
+void ScTabView::ClearHighlightRanges()
+{
+ if (pHighlightRanges)
+ {
+ ScHighlightRanges* pTemp = pHighlightRanges;
+ pHighlightRanges = NULL; // Repaint ohne Highlight
+
+ SCTAB nTab = aViewData.GetTabNo();
+ ULONG nCount = pTemp->Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScHighlightEntry* pEntry = pTemp->GetObject( i );
+ if (pEntry)
+ {
+ ScRange aRange = pEntry->aRef;
+ if ( nTab >= aRange.aStart.Tab() && nTab <= aRange.aEnd.Tab() )
+ PaintArea( aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(), SC_UPDATE_MARKS );
+ }
+ }
+ delete pTemp;
+ }
+}
+
+void ScTabView::DoChartSelection(
+ const uno::Sequence< chart2::data::HighlightedRange > & rHilightRanges )
+{
+ ClearHighlightRanges();
+ const sal_Unicode sep = ::formula::FormulaCompiler::GetNativeSymbol(ocSep).GetChar(0);
+
+ for( sal_Int32 i=0; i<rHilightRanges.getLength(); ++i )
+ {
+ Color aSelColor( rHilightRanges[i].PreferredColor );
+ ScRangeList aRangeList;
+ ScDocument* pDoc = aViewData.GetDocShell()->GetDocument();
+ if( ScRangeStringConverter::GetRangeListFromString(
+ aRangeList, rHilightRanges[i].RangeRepresentation, pDoc, pDoc->GetAddressConvention(), sep ))
+ {
+ for ( ScRangePtr p = aRangeList.First(); p; p = aRangeList.Next())
+ {
+ if( rHilightRanges[i].Index == - 1 )
+ AddHighlightRange( *p, aSelColor );
+ else
+ AddHighlightRange( lcl_getSubRangeByIndex( *p, rHilightRanges[i].Index ), aSelColor );
+ }
+ }
+ }
+}
+
+// PaintGrid - Datenbereiche neu zeichnen
+
+void ScTabView::PaintGrid()
+{
+ USHORT i;
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ pGridWin[i]->Invalidate();
+}
+
+// PaintTop - obere Kontrollelemente neu zeichnen
+
+void ScTabView::PaintTop()
+{
+ USHORT i;
+ for (i=0; i<2; i++)
+ {
+ if (pColBar[i])
+ pColBar[i]->Invalidate();
+ if (pColOutline[i])
+ pColOutline[i]->Invalidate();
+ }
+}
+
+void ScTabView::CreateAnchorHandles(SdrHdlList& rHdl, const ScAddress& rAddress)
+{
+ UINT16 i;
+
+ for(i=0; i<4; i++)
+ {
+ if(pGridWin[i])
+ {
+ if(pGridWin[i]->IsVisible())
+ {
+ pGridWin[i]->CreateAnchorHandle(rHdl, rAddress);
+ }
+ }
+ }
+}
+
+void ScTabView::PaintTopArea( SCCOL nStartCol, SCCOL nEndCol )
+{
+ // Pixel-Position der linken Kante
+
+ if ( nStartCol < aViewData.GetPosX(SC_SPLIT_LEFT) ||
+ nStartCol < aViewData.GetPosX(SC_SPLIT_RIGHT) )
+ aViewData.RecalcPixPos();
+
+ // Fixierung anpassen (UpdateFixX setzt HSplitPos neu)
+
+ if ( aViewData.GetHSplitMode() == SC_SPLIT_FIX && nStartCol < aViewData.GetFixPosX() )
+ if (aViewData.UpdateFixX())
+ RepeatResize();
+
+ // zeichnen
+
+ if (nStartCol>0)
+ --nStartCol; //! allgemeiner ?
+
+ BOOL bLayoutRTL = aViewData.GetDocument()->IsLayoutRTL( aViewData.GetTabNo() );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ for (USHORT i=0; i<2; i++)
+ {
+ ScHSplitPos eWhich = (ScHSplitPos) i;
+ if (pColBar[eWhich])
+ {
+ Size aWinSize = pColBar[eWhich]->GetSizePixel();
+ long nStartX = aViewData.GetScrPos( nStartCol, 0, eWhich ).X();
+ long nEndX;
+ if (nEndCol >= MAXCOL)
+ nEndX = bLayoutRTL ? 0 : ( aWinSize.Width()-1 );
+ else
+ nEndX = aViewData.GetScrPos( nEndCol+1, 0, eWhich ).X() - nLayoutSign;
+ pColBar[eWhich]->Invalidate(
+ Rectangle( nStartX, 0, nEndX, aWinSize.Height()-1 ) );
+ }
+ if (pColOutline[eWhich])
+ pColOutline[eWhich]->Invalidate();
+ }
+}
+
+
+// PaintLeft - linke Kontrollelemente neu zeichnen
+
+void ScTabView::PaintLeft()
+{
+ USHORT i;
+ for (i=0; i<2; i++)
+ {
+ if (pRowBar[i])
+ pRowBar[i]->Invalidate();
+ if (pRowOutline[i])
+ pRowOutline[i]->Invalidate();
+ }
+}
+
+void ScTabView::PaintLeftArea( SCROW nStartRow, SCROW nEndRow )
+{
+ // Pixel-Position der oberen Kante
+
+ if ( nStartRow < aViewData.GetPosY(SC_SPLIT_TOP) ||
+ nStartRow < aViewData.GetPosY(SC_SPLIT_BOTTOM) )
+ aViewData.RecalcPixPos();
+
+ // Fixierung anpassen (UpdateFixY setzt VSplitPos neu)
+
+ if ( aViewData.GetVSplitMode() == SC_SPLIT_FIX && nStartRow < aViewData.GetFixPosY() )
+ if (aViewData.UpdateFixY())
+ RepeatResize();
+
+ // zeichnen
+
+ if (nStartRow>0)
+ --nStartRow;
+
+ for (USHORT i=0; i<2; i++)
+ {
+ ScVSplitPos eWhich = (ScVSplitPos) i;
+ if (pRowBar[eWhich])
+ {
+ Size aWinSize = pRowBar[eWhich]->GetSizePixel();
+ long nStartY = aViewData.GetScrPos( 0, nStartRow, eWhich ).Y();
+ long nEndY;
+ if (nEndRow >= MAXROW)
+ nEndY = aWinSize.Height()-1;
+ else
+ nEndY = aViewData.GetScrPos( 0, nEndRow+1, eWhich ).Y() - 1;
+ pRowBar[eWhich]->Invalidate(
+ Rectangle( 0, nStartY, aWinSize.Width()-1, nEndY ) );
+ }
+ if (pRowOutline[eWhich])
+ pRowOutline[eWhich]->Invalidate();
+ }
+}
+
+// InvertBlockMark - Block invertieren
+
+void ScTabView::InvertBlockMark(SCCOL nStartX, SCROW nStartY,
+ SCCOL nEndX, SCROW nEndY)
+{
+ if ( !aViewData.IsActive() )
+ return; // invertiert wird nur auf aktiver View
+
+ PutInOrder( nStartX, nEndX );
+ PutInOrder( nStartY, nEndY );
+
+ ScMarkData& rMark = aViewData.GetMarkData();
+ ScDocShell* pDocSh = aViewData.GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ if ( pDocSh->GetLockCount() )
+ {
+ // if paint is locked, avoid repeated inverting
+ // add repaint areas to paint lock data instead
+ pDocSh->PostPaint( nStartX,nStartY,nTab, nEndX,nEndY,nTab, PAINT_GRID );
+ return;
+ }
+
+ BOOL bSingle = rMark.IsMultiMarked();
+ BOOL bMerge = pDoc->HasAttrib( nStartX, nStartY, nTab, nEndX, nEndY, nTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED );
+
+ USHORT i;
+ if ( bMerge || bSingle )
+ {
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ pGridWin[i]->InvertSimple( nStartX, nStartY, nEndX, nEndY,
+ bMerge, bBlockNeg );
+ }
+ else
+ {
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ if (pGridWin[i]->IsVisible())
+ {
+ ScSplitPos ePos = (ScSplitPos) i;
+ Point aStartPoint = aViewData.GetScrPos( nStartX, nStartY, ePos );
+ Point aEndPoint = aViewData.GetScrPos( nEndX+1, nEndY+1, ePos );
+ if ( pDoc->IsLayoutRTL( nTab ) )
+ {
+ long nTemp = aStartPoint.X();
+ aStartPoint.X() = aEndPoint.X() + 1; // +1 - excluding start of nEndX+1
+ aEndPoint.X() = nTemp;
+ }
+ else
+ aEndPoint.X() -= 1;
+ aEndPoint.Y() -= 1;
+ if ( aEndPoint.X() >= aStartPoint.X() && aEndPoint.Y() >= aStartPoint.Y() )
+ {
+ MapMode aOld = pGridWin[ePos]->GetMapMode();
+ pGridWin[ePos]->SetMapMode(MAP_PIXEL);
+ pGridWin[ePos]->Invert( Rectangle(aStartPoint,aEndPoint), INVERT_HIGHLIGHT );
+ pGridWin[ePos]->SetMapMode(aOld);
+ pGridWin[ePos]->CheckInverted();
+ }
+ }
+ }
+
+ //
+ // wenn Controls betroffen, neu malen
+ //
+
+ BOOL bHide = TRUE; // wird Teil der Markierung aufgehoben ?
+ if (rMark.IsMarked())
+ {
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+ if ( aMarkRange.aStart.Col() <= nStartX && aMarkRange.aEnd.Col() >= nEndX &&
+ aMarkRange.aStart.Row() <= nStartY && aMarkRange.aEnd.Row() >= nEndY )
+ {
+ bHide = FALSE; // der ganze Bereich ist markiert
+ }
+ }
+}
+
+BOOL ScTabView::PaintExtras()
+{
+ BOOL bRet = FALSE;
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ if (!pDoc->HasTable(nTab)) // Tabelle geloescht ?
+ {
+ SCTAB nCount = pDoc->GetTableCount();
+ aViewData.SetTabNo(nCount-1);
+ bRet = TRUE;
+ }
+ pTabControl->UpdateStatus(); // TRUE = active
+ return bRet;
+}
+
+void ScTabView::RecalcPPT()
+{
+ // called after changes that require the PPT values to be recalculated
+ // (currently from detective operations)
+
+ double nOldX = aViewData.GetPPTX();
+ double nOldY = aViewData.GetPPTY();
+
+ aViewData.RefreshZoom(); // pre-calculate new PPT values
+
+ BOOL bChangedX = ( aViewData.GetPPTX() != nOldX );
+ BOOL bChangedY = ( aViewData.GetPPTY() != nOldY );
+ if ( bChangedX || bChangedY )
+ {
+ // call view SetZoom (including draw scale, split update etc)
+ // and paint only if values changed
+
+ Fraction aZoomX = aViewData.GetZoomX();
+ Fraction aZoomY = aViewData.GetZoomY();
+ SetZoom( aZoomX, aZoomY, FALSE );
+
+ PaintGrid();
+ if (bChangedX)
+ PaintTop();
+ if (bChangedY)
+ PaintLeft();
+ }
+}
+
+void ScTabView::ActivateView( BOOL bActivate, BOOL bFirst )
+{
+ if ( bActivate == aViewData.IsActive() && !bFirst )
+ {
+ // keine Assertion mehr - kommt vor, wenn vorher im Drag&Drop
+ // auf ein anderes Dokument umgeschaltet wurde
+ return;
+ }
+
+ // wird nur bei MDI-(De)Activate gerufen
+ // aViewData.Activate hinten wegen Cursor-Show bei KillEditView
+ // Markierung nicht mehr loeschen - wenn an der ViewData Activate(FALSE) gesetzt ist,
+ // wird die Markierung nicht ausgegeben
+
+ if (!bActivate)
+ {
+ ScModule* pScMod = SC_MOD();
+ BOOL bRefMode = pScMod->IsFormulaMode();
+
+ // Referenzeingabe nicht abbrechen, um Referenzen auf
+ // andere Dokumente zuzulassen
+
+ if (!bRefMode)
+ {
+ //pScMod->InputEnterHandler();
+
+ // #80843# pass view to GetInputHdl, this view may not be current anymore
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
+ if (pHdl)
+ pHdl->EnterHandler();
+ }
+ }
+ pTabControl->ActivateView(bActivate);
+ PaintExtras();
+
+ aViewData.Activate(bActivate);
+
+ PaintBlock(FALSE); // Repaint, Markierung je nach Active-Status
+
+ if (!bActivate)
+ HideAllCursors(); // Cursor
+ else if (!bFirst)
+ ShowAllCursors();
+
+ //HMHif (pDrawView)
+ //HMH DrawShowMarkHdl(bActivate); // Drawing-Markierung
+
+ if (bActivate)
+ {
+ if ( bFirst )
+ {
+ ScSplitPos eWin = aViewData.GetActivePart();
+ DBG_ASSERT( pGridWin[eWin], "rottes Dokument, nicht alle SplitPos in GridWin" );
+ if ( !pGridWin[eWin] )
+ {
+ eWin = SC_SPLIT_BOTTOMLEFT;
+ if ( !pGridWin[eWin] )
+ {
+ short i;
+ for ( i=0; i<4; i++ )
+ {
+ if ( pGridWin[i] )
+ {
+ eWin = (ScSplitPos) i;
+ break; // for
+ }
+ }
+ DBG_ASSERT( i<4, "und BUMM" );
+ }
+ aViewData.SetActivePart( eWin );
+ }
+ }
+ // hier nicht mehr selber GrabFocus rufen!
+ // Wenn das Doc bearbeitet wird, ruft der Sfx selber GrabFocus am Fenster der Shell.
+ // Wenn es z.B. ein Mailbody ist, darf es den Focus nicht bekommen (Bug #43638#)
+
+ UpdateInputContext();
+ }
+ else
+ pGridWin[aViewData.GetActivePart()]->ClickExtern();
+}
+
+void ScTabView::ActivatePart( ScSplitPos eWhich )
+{
+ ScSplitPos eOld = aViewData.GetActivePart();
+ if ( eOld != eWhich )
+ {
+ bInActivatePart = TRUE;
+
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+
+ // #40565# the HasEditView call during SetCursor would fail otherwise
+ if ( aViewData.HasEditView(eOld) && !bRefMode )
+ UpdateInputLine();
+
+ ScHSplitPos eOldH = WhichH(eOld);
+ ScVSplitPos eOldV = WhichV(eOld);
+ ScHSplitPos eNewH = WhichH(eWhich);
+ ScVSplitPos eNewV = WhichV(eWhich);
+ BOOL bTopCap = pColBar[eOldH] && pColBar[eOldH]->IsMouseCaptured();
+ BOOL bLeftCap = pRowBar[eOldV] && pRowBar[eOldV]->IsMouseCaptured();
+
+ BOOL bFocus = pGridWin[eOld]->HasFocus();
+ BOOL bCapture = pGridWin[eOld]->IsMouseCaptured();
+ if (bCapture)
+ pGridWin[eOld]->ReleaseMouse();
+ pGridWin[eOld]->ClickExtern();
+ pGridWin[eOld]->HideCursor();
+ pGridWin[eWhich]->HideCursor();
+ aViewData.SetActivePart( eWhich );
+
+ ScTabViewShell* pShell = aViewData.GetViewShell();
+ pShell->WindowChanged();
+
+ pSelEngine->SetWindow(pGridWin[eWhich]);
+ pSelEngine->SetWhich(eWhich);
+ pSelEngine->SetVisibleArea( Rectangle(Point(), pGridWin[eWhich]->GetOutputSizePixel()) );
+
+ pGridWin[eOld]->MoveMouseStatus(*pGridWin[eWhich]);
+
+ if ( bCapture || pGridWin[eWhich]->IsMouseCaptured() )
+ {
+ // Tracking statt CaptureMouse, damit sauber abgebrochen werden kann
+ // (SelectionEngine ruft CaptureMouse beim SetWindow)
+ //! Irgendwann sollte die SelectionEngine selber StartTracking rufen!?!
+ pGridWin[eWhich]->ReleaseMouse();
+ pGridWin[eWhich]->StartTracking();
+ }
+
+ if ( bTopCap && pColBar[eNewH] )
+ {
+ pColBar[eOldH]->SetIgnoreMove(TRUE);
+ pColBar[eNewH]->SetIgnoreMove(FALSE);
+ pHdrSelEng->SetWindow( pColBar[eNewH] );
+ long nWidth = pColBar[eNewH]->GetOutputSizePixel().Width();
+ pHdrSelEng->SetVisibleArea( Rectangle( 0, LONG_MIN, nWidth-1, LONG_MAX ) );
+ pColBar[eNewH]->CaptureMouse();
+ }
+ if ( bLeftCap && pRowBar[eNewV] )
+ {
+ pRowBar[eOldV]->SetIgnoreMove(TRUE);
+ pRowBar[eNewV]->SetIgnoreMove(FALSE);
+ pHdrSelEng->SetWindow( pRowBar[eNewV] );
+ long nHeight = pRowBar[eNewV]->GetOutputSizePixel().Height();
+ pHdrSelEng->SetVisibleArea( Rectangle( LONG_MIN, 0, LONG_MAX, nHeight-1 ) );
+ pRowBar[eNewV]->CaptureMouse();
+ }
+ aHdrFunc.SetWhich(eWhich);
+
+ pGridWin[eOld]->ShowCursor();
+ pGridWin[eWhich]->ShowCursor();
+
+ SfxInPlaceClient* pClient = aViewData.GetViewShell()->GetIPClient();
+ BOOL bOleActive = ( pClient && pClient->IsObjectInPlaceActive() );
+
+ // #103823# don't switch ViewShell's active window during RefInput, because the focus
+ // might change, and subsequent SetReference calls wouldn't find the right EditView
+ if ( !bRefMode && !bOleActive )
+ aViewData.GetViewShell()->SetWindow( pGridWin[eWhich] );
+
+ if ( bFocus && !aViewData.IsAnyFillMode() && !bRefMode )
+ {
+ // GrabFocus nur, wenn vorher das andere GridWindow den Focus hatte
+ // (z.B. wegen Suchen & Ersetzen)
+//! aViewData.GetViewShell()->GetViewFrame()->GetWindow().GrabFocus();
+ pGridWin[eWhich]->GrabFocus();
+ }
+
+ bInActivatePart = FALSE;
+ }
+}
+
+void ScTabView::HideListBox()
+{
+ for (USHORT i=0; i<4; i++)
+ if (pGridWin[i])
+ pGridWin[i]->ClickExtern();
+}
+
+void ScTabView::UpdateInputContext()
+{
+ ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
+ if (pWin)
+ pWin->UpdateInputContext();
+
+ if (pTabControl)
+ pTabControl->UpdateInputContext();
+}
+
+// GetGridWidth - Breite eines Ausgabebereichs (fuer ViewData)
+
+long ScTabView::GetGridWidth( ScHSplitPos eWhich )
+{
+ ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+ if (pGridWin[eGridWhich])
+ return pGridWin[eGridWhich]->GetSizePixel().Width();
+ else
+ return 0;
+}
+
+// GetGridHeight - Hoehe eines Ausgabebereichs (fuer ViewData)
+
+long ScTabView::GetGridHeight( ScVSplitPos eWhich )
+{
+ ScSplitPos eGridWhich = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
+ if (pGridWin[eGridWhich])
+ return pGridWin[eGridWhich]->GetSizePixel().Height();
+ else
+ return 0;
+}
+
+void ScTabView::UpdateInputLine()
+{
+ SC_MOD()->InputEnterHandler();
+}
+
+void ScTabView::ZoomChanged()
+{
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl(aViewData.GetViewShell());
+ if (pHdl)
+ pHdl->SetRefScale( aViewData.GetZoomX(), aViewData.GetZoomY() );
+
+ UpdateFixPos();
+
+ UpdateScrollBars();
+
+ // VisArea...
+ // AW: Discussed with NN if there is a reason that new map mode was only set for one window,
+ // but is not. Setting only on one window causes the first repaint to have the old mapMode
+ // in three of four views, so the overlay will save the wrong content e.g. when zooming out.
+ // Changing to setting map mode at all windows.
+ sal_uInt32 a;
+
+ for(a = 0L; a < 4L; a++)
+ {
+ if(pGridWin[a])
+ {
+ pGridWin[a]->SetMapMode(pGridWin[a]->GetDrawMapMode());
+ }
+ }
+
+ SetNewVisArea();
+
+ /* the old code
+ ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
+ if (pWin)
+ {
+ pWin->SetMapMode( pWin->GetDrawMapMode() ); // mit neuem Zoom
+ SetNewVisArea(); // benutzt den gesetzten MapMode
+ } */
+
+ InterpretVisible(); // #69343# have everything calculated before painting
+
+ SfxBindings& rBindings = aViewData.GetBindings();
+ rBindings.Invalidate( SID_ATTR_ZOOM );
+ rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
+
+ HideNoteMarker();
+
+ // AW: To not change too much, use pWin here
+ ScGridWindow* pWin = pGridWin[aViewData.GetActivePart()];
+
+ if ( pWin && aViewData.HasEditView( aViewData.GetActivePart() ) )
+ {
+ // flush OverlayManager before changing the MapMode
+ pWin->flushOverlayManager();
+
+ // #93650# make sure the EditView's position and size are updated
+ // with the right (logic, not drawing) MapMode
+ pWin->SetMapMode( aViewData.GetLogicMode() );
+ UpdateEditView();
+ }
+}
+
+void ScTabView::CheckNeedsRepaint()
+{
+ USHORT i;
+ for (i=0; i<4; i++)
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ pGridWin[i]->CheckNeedsRepaint();
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
new file mode 100644
index 000000000000..100e641c396a
--- /dev/null
+++ b/sc/source/ui/view/tabview4.cxx
@@ -0,0 +1,567 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <vcl/help.hxx>
+#include <vcl/svapp.hxx>
+
+#include "tabview.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "gridwin.hxx"
+#include "globstr.hrc"
+#include "cell.hxx"
+#include "dociter.hxx"
+
+extern USHORT nScFillModeMouseModifier; // global.cxx
+
+// STATIC DATA -----------------------------------------------------------
+
+//==================================================================
+
+//
+// --- Referenz-Eingabe / Fill-Cursor
+//
+
+void ScTabView::HideTip()
+{
+ if ( nTipVisible )
+ {
+ Help::HideTip( nTipVisible );
+ nTipVisible = 0;
+ }
+}
+
+void ScTabView::ShowRefTip()
+{
+ BOOL bDone = FALSE;
+ if ( aViewData.GetRefType() == SC_REFTYPE_REF && Help::IsQuickHelpEnabled() )
+ {
+ SCCOL nStartX = aViewData.GetRefStartX();
+ SCROW nStartY = aViewData.GetRefStartY();
+ SCCOL nEndX = aViewData.GetRefEndX();
+ SCROW nEndY = aViewData.GetRefEndY();
+ if ( nEndX != nStartX || nEndY != nStartY ) // nicht fuer einzelne Zelle
+ {
+ BOOL bLeft = ( nEndX < nStartX );
+ BOOL bTop = ( nEndY < nStartY );
+ PutInOrder( nStartX, nEndX );
+ PutInOrder( nStartY, nEndY );
+ SCCOL nCols = nEndX+1-nStartX;
+ SCROW nRows = nEndY+1-nStartY;
+
+ String aHelp = ScGlobal::GetRscString( STR_QUICKHELP_REF );
+ aHelp.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%1")),
+ String::CreateFromInt32(nRows) );
+ aHelp.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%2")),
+ String::CreateFromInt32(nCols) );
+
+ ScSplitPos eWhich = aViewData.GetActivePart();
+ Window* pWin = pGridWin[eWhich];
+ if ( pWin )
+ {
+ Point aStart = aViewData.GetScrPos( nStartX, nStartY, eWhich );
+ Point aEnd = aViewData.GetScrPos( nEndX+1, nEndY+1, eWhich );
+
+ Point aPos( bLeft ? aStart.X() : ( aEnd.X() + 3 ),
+ bTop ? aStart.Y() : ( aEnd.Y() + 3 ) );
+ USHORT nFlags = ( bLeft ? QUICKHELP_RIGHT : QUICKHELP_LEFT ) |
+ ( bTop ? QUICKHELP_BOTTOM : QUICKHELP_TOP );
+
+ // nicht ueber die editierte Formel
+ if ( !bTop && aViewData.HasEditView( eWhich ) &&
+ nEndY+1 == aViewData.GetEditViewRow() )
+ {
+ // dann an der oberen Kante der editierten Zelle ausrichten
+ aPos.Y() -= 2; // die 3 von oben
+ nFlags = ( nFlags & ~QUICKHELP_TOP ) | QUICKHELP_BOTTOM;
+ }
+
+ Rectangle aRect( pWin->OutputToScreenPixel( aPos ), Size(1,1) );
+
+ //! Test, ob geaendert ??
+
+ HideTip();
+ nTipVisible = Help::ShowTip( pWin, aRect, aHelp, nFlags );
+ bDone = TRUE;
+ }
+ }
+ }
+
+ if (!bDone)
+ HideTip();
+}
+
+void ScTabView::StopRefMode()
+{
+ if (aViewData.IsRefMode())
+ {
+ aViewData.SetRefMode( FALSE, SC_REFTYPE_NONE );
+
+ HideTip();
+ UpdateShrinkOverlay();
+
+ if ( aViewData.GetTabNo() >= aViewData.GetRefStartZ() &&
+ aViewData.GetTabNo() <= aViewData.GetRefEndZ() )
+ {
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCCOL nStartX = aViewData.GetRefStartX();
+ SCROW nStartY = aViewData.GetRefStartY();
+ SCCOL nEndX = aViewData.GetRefEndX();
+ SCROW nEndY = aViewData.GetRefEndY();
+ if ( nStartX == nEndX && nStartY == nEndY )
+ pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() );
+
+ PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS );
+ }
+
+ pSelEngine->Reset();
+ pSelEngine->SetAddMode( FALSE ); //! sollte das nicht bei Reset passieren?
+
+ ScSplitPos eOld = pSelEngine->GetWhich();
+ ScSplitPos eNew = aViewData.GetActivePart();
+ if ( eNew != eOld )
+ {
+ pSelEngine->SetWindow( pGridWin[ eNew ] );
+ pSelEngine->SetWhich( eNew );
+ pSelEngine->SetVisibleArea( Rectangle(Point(),
+ pGridWin[eNew]->GetOutputSizePixel()) );
+ pGridWin[eOld]->MoveMouseStatus(*pGridWin[eNew]);
+ }
+ }
+
+ // AlignToCursor(SC_FOLLOW_NONE): Only switch active part.
+ // This must also be done if no RefMode was active (for RangeFinder dragging),
+ // but if RefMode was set, AlignToCursor must be after SelectionEngine reset,
+ // so the SelectionEngine SetWindow call from AlignToCursor doesn't capture
+ // the mouse again when called from Tracking/MouseButtonUp (#94562#).
+ AlignToCursor( aViewData.GetCurX(), aViewData.GetCurY(), SC_FOLLOW_NONE );
+}
+
+void ScTabView::DoneRefMode( BOOL bContinue )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ if ( aViewData.GetRefType() == SC_REFTYPE_REF && bContinue )
+ SC_MOD()->AddRefEntry();
+
+ BOOL bWasRef = aViewData.IsRefMode();
+ aViewData.SetRefMode( FALSE, SC_REFTYPE_NONE );
+
+ HideTip();
+ UpdateShrinkOverlay();
+
+ // Paint:
+ if ( bWasRef && aViewData.GetTabNo() >= aViewData.GetRefStartZ() &&
+ aViewData.GetTabNo() <= aViewData.GetRefEndZ() )
+ {
+ SCCOL nStartX = aViewData.GetRefStartX();
+ SCROW nStartY = aViewData.GetRefStartY();
+ SCCOL nEndX = aViewData.GetRefEndX();
+ SCROW nEndY = aViewData.GetRefEndY();
+ if ( nStartX == nEndX && nStartY == nEndY )
+ pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() );
+
+ PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS );
+ }
+}
+
+void ScTabView::UpdateRef( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+
+ if (!aViewData.IsRefMode())
+ {
+ // Das kommt vor, wenn bei einem Referenz-Dialog als erstes mit Control in die
+ // die Tabelle geklickt wird. Dann die neue Referenz an den alten Inhalt anhaengen:
+
+ ScModule* pScMod = SC_MOD();
+ if (pScMod->IsFormulaMode())
+ pScMod->AddRefEntry();
+
+ InitRefMode( nCurX, nCurY, nCurZ, SC_REFTYPE_REF );
+ }
+
+ if ( nCurX != aViewData.GetRefEndX() || nCurY != aViewData.GetRefEndY() ||
+ nCurZ != aViewData.GetRefEndZ() )
+ {
+ ScMarkData& rMark = aViewData.GetMarkData();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ SCCOL nStartX = aViewData.GetRefStartX();
+ SCROW nStartY = aViewData.GetRefStartY();
+ SCCOL nEndX = aViewData.GetRefEndX();
+ SCROW nEndY = aViewData.GetRefEndY();
+ if ( nStartX == nEndX && nStartY == nEndY )
+ pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, nTab );
+ ScUpdateRect aRect( nStartX, nStartY, nEndX, nEndY );
+
+ aViewData.SetRefEnd( nCurX, nCurY, nCurZ );
+
+ nStartX = aViewData.GetRefStartX();
+ nStartY = aViewData.GetRefStartY();
+ nEndX = aViewData.GetRefEndX();
+ nEndY = aViewData.GetRefEndY();
+ if ( nStartX == nEndX && nStartY == nEndY )
+ pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, nTab );
+ aRect.SetNew( nStartX, nStartY, nEndX, nEndY );
+
+ ScRefType eType = aViewData.GetRefType();
+ if ( eType == SC_REFTYPE_REF )
+ {
+ ScRange aRef(
+ aViewData.GetRefStartX(), aViewData.GetRefStartY(), aViewData.GetRefStartZ(),
+ aViewData.GetRefEndX(), aViewData.GetRefEndY(), aViewData.GetRefEndZ() );
+ SC_MOD()->SetReference( aRef, pDoc, &rMark );
+ ShowRefTip();
+ }
+ else if ( eType == SC_REFTYPE_EMBED_LT || eType == SC_REFTYPE_EMBED_RB )
+ {
+ PutInOrder(nStartX,nEndX);
+ PutInOrder(nStartY,nEndY);
+ pDoc->SetEmbedded( ScRange(nStartX,nStartY,nTab, nEndX,nEndY,nTab) );
+ ScDocShell* pDocSh = aViewData.GetDocShell();
+ pDocSh->UpdateOle( &aViewData, TRUE );
+ pDocSh->SetDocumentModified();
+ }
+
+ SCCOL nPaintStartX;
+ SCROW nPaintStartY;
+ SCCOL nPaintEndX;
+ SCROW nPaintEndY;
+ if (aRect.GetDiff( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY ))
+ PaintArea( nPaintStartX, nPaintStartY, nPaintEndX, nPaintEndY, SC_UPDATE_MARKS );
+ }
+
+ // Tip-Hilfe fuer Auto-Fill
+
+ if ( aViewData.GetRefType() == SC_REFTYPE_FILL && Help::IsQuickHelpEnabled() )
+ {
+ String aHelpStr;
+ ScRange aMarkRange;
+ aViewData.GetSimpleArea( aMarkRange );
+ SCCOL nEndX = aViewData.GetRefEndX();
+ SCROW nEndY = aViewData.GetRefEndY();
+ ScRange aDelRange;
+ if ( aViewData.GetFillMode() == SC_FILL_MATRIX && !(nScFillModeMouseModifier & KEY_MOD1) )
+ {
+ aHelpStr = ScGlobal::GetRscString( STR_TIP_RESIZEMATRIX );
+ SCCOL nCols = nEndX + 1 - aViewData.GetRefStartX(); // Reihenfolge ist richtig
+ SCROW nRows = nEndY + 1 - aViewData.GetRefStartY();
+ aHelpStr.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%1")),
+ String::CreateFromInt32(nRows) );
+ aHelpStr.SearchAndReplace( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("%2")),
+ String::CreateFromInt32(nCols) );
+ }
+ else if ( aViewData.GetDelMark( aDelRange ) )
+ aHelpStr = ScGlobal::GetRscString( STR_QUICKHELP_DELETE );
+ else if ( nEndX != aMarkRange.aEnd.Col() || nEndY != aMarkRange.aEnd.Row() )
+ aHelpStr = pDoc->GetAutoFillPreview( aMarkRange, nEndX, nEndY );
+
+ // je nach Richtung die obere oder untere Ecke:
+ SCCOL nAddX = ( nEndX >= aMarkRange.aEnd.Col() ) ? 1 : 0;
+ SCROW nAddY = ( nEndY >= aMarkRange.aEnd.Row() ) ? 1 : 0;
+ Point aPos = aViewData.GetScrPos( nEndX+nAddX, nEndY+nAddY, aViewData.GetActivePart() );
+ aPos.X() += 8;
+ aPos.Y() += 4;
+ Window* pWin = GetActiveWin();
+ if ( pWin )
+ aPos = pWin->OutputToScreenPixel( aPos );
+ Rectangle aRect( aPos, aPos );
+ USHORT nAlign = QUICKHELP_LEFT|QUICKHELP_TOP;
+ Help::ShowQuickHelp(pWin, aRect, aHelpStr, nAlign);
+ }
+}
+
+void ScTabView::InitRefMode( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScRefType eType, BOOL bPaint )
+{
+ ScDocument* pDoc = aViewData.GetDocument();
+ ScMarkData& rMark = aViewData.GetMarkData();
+ if (!aViewData.IsRefMode())
+ {
+ aViewData.SetRefMode( TRUE, eType );
+ aViewData.SetRefStart( nCurX, nCurY, nCurZ );
+ aViewData.SetRefEnd( nCurX, nCurY, nCurZ );
+
+ if (nCurZ == aViewData.GetTabNo() && bPaint)
+ {
+ SCCOL nStartX = nCurX;
+ SCROW nStartY = nCurY;
+ SCCOL nEndX = nCurX;
+ SCROW nEndY = nCurY;
+ pDoc->ExtendMerge( nStartX, nStartY, nEndX, nEndY, aViewData.GetTabNo() );
+
+ //! nur Markierung ueber Inhalte zeichnen!
+ PaintArea( nStartX,nStartY,nEndX,nEndY, SC_UPDATE_MARKS );
+
+ // SetReference ohne Merge-Anpassung
+ ScRange aRef( nCurX,nCurY,nCurZ, nCurX,nCurY,nCurZ );
+ SC_MOD()->SetReference( aRef, pDoc, &rMark );
+ }
+ }
+}
+
+// static
+void ScTabView::SetScrollBar( ScrollBar& rScroll, long nRangeMax, long nVisible, long nPos, BOOL bLayoutRTL )
+{
+ if ( nVisible == 0 )
+ nVisible = 1; // #i59893# don't use visible size 0
+
+ // RTL layout uses a negative range to simulate a mirrored scroll bar.
+ // SetScrollBar/GetScrollBarPos hide this so outside of these functions normal cell
+ // addresses can be used.
+
+ if ( bLayoutRTL )
+ {
+ rScroll.SetRange( Range( -nRangeMax, 0 ) );
+ rScroll.SetVisibleSize( nVisible );
+ rScroll.SetThumbPos( -nPos - nVisible );
+ }
+ else
+ {
+ rScroll.SetRange( Range( 0, nRangeMax ) );
+ rScroll.SetVisibleSize( nVisible );
+ rScroll.SetThumbPos( nPos );
+ }
+}
+
+// static
+long ScTabView::GetScrollBarPos( ScrollBar& rScroll, BOOL bLayoutRTL )
+{
+ if ( bLayoutRTL )
+ return -rScroll.GetThumbPos() - rScroll.GetVisibleSize();
+ else
+ return rScroll.GetThumbPos();
+}
+
+// UpdateScrollBars - sichtbaren Bereich und Scrollweite der Scrollbars einstellen
+
+long lcl_UpdateBar( ScrollBar& rScroll, SCCOLROW nSize ) // Size = (komplette) Zellen
+{
+ long nOldPos;
+ long nNewPos;
+
+ nOldPos = rScroll.GetThumbPos();
+ rScroll.SetPageSize( static_cast<long>(nSize) );
+ nNewPos = rScroll.GetThumbPos();
+#ifndef UNX
+ rScroll.SetPageSize( 1 ); // immer moeglich !
+#endif
+
+ return nNewPos - nOldPos;
+}
+
+long lcl_GetScrollRange( SCCOLROW nDocEnd, SCCOLROW nPos, SCCOLROW nVis, SCCOLROW nMax, SCCOLROW nStart )
+{
+ // get the end (positive) of a scroll bar range that always starts at 0
+
+ ++nVis;
+ ++nMax; // for partially visible cells
+ SCCOLROW nEnd = Max(nDocEnd, (SCCOLROW)(nPos+nVis)) + nVis;
+ if (nEnd > nMax)
+ nEnd = nMax;
+
+ return ( nEnd - nStart ); // for range starting at 0
+}
+
+void ScTabView::UpdateScrollBars()
+{
+ long nDiff;
+ BOOL bTop = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE );
+ BOOL bRight = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE );
+ ScDocument* pDoc = aViewData.GetDocument();
+ SCTAB nTab = aViewData.GetTabNo();
+ BOOL bMirror = pDoc->IsLayoutRTL( nTab ) != Application::GetSettings().GetLayoutRTL();
+ SCCOL nUsedX;
+ SCROW nUsedY;
+ pDoc->GetTableArea( nTab, nUsedX, nUsedY ); //! cachen !!!!!!!!!!!!!!!
+
+ SCCOL nVisXL = 0;
+ SCCOL nVisXR = 0;
+ SCROW nVisYB = 0;
+ SCROW nVisYT = 0;
+
+ SCCOL nStartX = 0;
+ SCROW nStartY = 0;
+ if (aViewData.GetHSplitMode()==SC_SPLIT_FIX)
+ nStartX = aViewData.GetFixPosX();
+ if (aViewData.GetVSplitMode()==SC_SPLIT_FIX)
+ nStartY = aViewData.GetFixPosY();
+
+ nVisXL = aViewData.VisibleCellsX( SC_SPLIT_LEFT );
+ long nMaxXL = lcl_GetScrollRange( nUsedX, aViewData.GetPosX(SC_SPLIT_LEFT), nVisXL, MAXCOL, 0 );
+ SetScrollBar( aHScrollLeft, nMaxXL, nVisXL, aViewData.GetPosX( SC_SPLIT_LEFT ), bMirror );
+
+ nVisYB = aViewData.VisibleCellsY( SC_SPLIT_BOTTOM );
+ long nMaxYB = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_BOTTOM), nVisYB, MAXROW, nStartY );
+ SetScrollBar( aVScrollBottom, nMaxYB, nVisYB, aViewData.GetPosY( SC_SPLIT_BOTTOM ) - nStartY, FALSE );
+
+ if (bRight)
+ {
+ nVisXR = aViewData.VisibleCellsX( SC_SPLIT_RIGHT );
+ long nMaxXR = lcl_GetScrollRange( nUsedX, aViewData.GetPosX(SC_SPLIT_RIGHT), nVisXR, MAXCOL, nStartX );
+ SetScrollBar( aHScrollRight, nMaxXR, nVisXR, aViewData.GetPosX( SC_SPLIT_RIGHT ) - nStartX, bMirror );
+ }
+
+ if (bTop)
+ {
+ nVisYT = aViewData.VisibleCellsY( SC_SPLIT_TOP );
+ long nMaxYT = lcl_GetScrollRange( nUsedY, aViewData.GetPosY(SC_SPLIT_TOP), nVisYT, MAXROW, 0 );
+ SetScrollBar( aVScrollTop, nMaxYT, nVisYT, aViewData.GetPosY( SC_SPLIT_TOP ), FALSE );
+ }
+
+ // Bereich testen
+
+ nDiff = lcl_UpdateBar( aHScrollLeft, nVisXL );
+ if (nDiff) ScrollX( nDiff, SC_SPLIT_LEFT );
+ if (bRight)
+ {
+ nDiff = lcl_UpdateBar( aHScrollRight, nVisXR );
+ if (nDiff) ScrollX( nDiff, SC_SPLIT_RIGHT );
+ }
+
+ nDiff = lcl_UpdateBar( aVScrollBottom, nVisYB );
+ if (nDiff) ScrollY( nDiff, SC_SPLIT_BOTTOM );
+ if (bTop)
+ {
+ nDiff = lcl_UpdateBar( aVScrollTop, nVisYT );
+ if (nDiff) ScrollY( nDiff, SC_SPLIT_TOP );
+ }
+
+ // set visible area for online spelling
+
+ if ( aViewData.IsActive() )
+ {
+ ScSplitPos eActive = aViewData.GetActivePart();
+ ScHSplitPos eHWhich = WhichH( eActive );
+ ScVSplitPos eVWhich = WhichV( eActive );
+ SCCOL nPosX = aViewData.GetPosX(eHWhich);
+ SCROW nPosY = aViewData.GetPosY(eVWhich);
+ SCCOL nEndX = nPosX + ( ( eHWhich == SC_SPLIT_LEFT ) ? nVisXL : nVisXR );
+ SCROW nEndY = nPosY + ( ( eVWhich == SC_SPLIT_TOP ) ? nVisYT : nVisYB );
+ if ( nEndX > MAXCOL ) nEndX = MAXCOL;
+ if ( nEndY > MAXROW ) nEndY = MAXROW;
+ ScRange aVisible( nPosX, nPosY, nTab, nEndX, nEndY, nTab );
+ if ( pDoc->SetVisibleSpellRange( aVisible ) )
+ SC_MOD()->AnythingChanged(); // if visible area has changed
+ }
+}
+
+#ifndef HDR_SLIDERSIZE
+#define HDR_SLIDERSIZE 2
+#endif
+
+void ScTabView::InvertHorizontal( ScVSplitPos eWhich, long nDragPos )
+{
+ for (USHORT i=0; i<4; i++)
+ if (WhichV((ScSplitPos)i)==eWhich)
+ {
+ ScGridWindow* pWin = pGridWin[i];
+ if (pWin)
+ {
+ Rectangle aRect( 0,nDragPos, pWin->GetOutputSizePixel().Width()-1,nDragPos+HDR_SLIDERSIZE-1 );
+ pWin->Update();
+ pWin->DoInvertRect( aRect ); // Pixel
+ }
+ }
+}
+
+void ScTabView::InvertVertical( ScHSplitPos eWhich, long nDragPos )
+{
+ for (USHORT i=0; i<4; i++)
+ if (WhichH((ScSplitPos)i)==eWhich)
+ {
+ ScGridWindow* pWin = pGridWin[i];
+ if (pWin)
+ {
+ Rectangle aRect( nDragPos,0, nDragPos+HDR_SLIDERSIZE-1,pWin->GetOutputSizePixel().Height()-1 );
+ pWin->Update();
+ pWin->DoInvertRect( aRect ); // Pixel
+ }
+ }
+}
+
+//==================================================================
+
+void ScTabView::InterpretVisible()
+{
+ // make sure all visible cells are interpreted,
+ // so the next paint will not execute a macro function
+
+ ScDocument* pDoc = aViewData.GetDocument();
+ if ( !pDoc->GetAutoCalc() )
+ return;
+
+ SCTAB nTab = aViewData.GetTabNo();
+ for (USHORT i=0; i<4; i++)
+ {
+ // rely on gridwin pointers to find used panes
+ // no IsVisible test in case the whole view is not yet shown
+
+ if (pGridWin[i])
+ {
+ ScHSplitPos eHWhich = WhichH( ScSplitPos(i) );
+ ScVSplitPos eVWhich = WhichV( ScSplitPos(i) );
+
+ SCCOL nX1 = aViewData.GetPosX( eHWhich );
+ SCROW nY1 = aViewData.GetPosY( eVWhich );
+ SCCOL nX2 = nX1 + aViewData.VisibleCellsX( eHWhich );
+ SCROW nY2 = nY1 + aViewData.VisibleCellsY( eVWhich );
+
+ if (nX2 > MAXCOL) nX2 = MAXCOL;
+ if (nY2 > MAXROW) nY2 = MAXROW;
+
+ ScCellIterator aIter( pDoc, nX1, nY1, nTab, nX2, nY2, nTab );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while ( pCell )
+ {
+ if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetDirty() )
+ ((ScFormulaCell*)pCell)->Interpret();
+
+ pCell = aIter.GetNext();
+ }
+ }
+ }
+
+ // #i65047# repaint during the above loop may have set the bNeedsRepaint flag
+ CheckNeedsRepaint();
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabview5.cxx b/sc/source/ui/view/tabview5.cxx
new file mode 100644
index 000000000000..0c83060d1649
--- /dev/null
+++ b/sc/source/ui/view/tabview5.cxx
@@ -0,0 +1,690 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <svx/fmshell.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdoutl.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <tools/ref.hxx>
+
+#include "tabview.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "gridwin.hxx"
+#include "olinewin.hxx"
+#include "tabsplit.hxx"
+#include "colrowba.hxx"
+#include "tabcont.hxx"
+#include "hintwin.hxx"
+#include "sc.hrc"
+#include "pagedata.hxx"
+#include "hiranges.hxx"
+#include "drawview.hxx"
+#include "drwlayer.hxx"
+#include "fusel.hxx" // Start-Function
+#include "seltrans.hxx"
+#include "scmod.hxx"
+#include "AccessibilityHints.hxx"
+#include "docsh.hxx"
+#include "viewuno.hxx"
+
+#include <vcl/svapp.hxx>
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+
+void __EXPORT ScTabView::Init()
+{
+ /* RTL layout of the view windows is done manually, because it depends on
+ the sheet orientation, not the UI setting. Note: controls that are
+ already constructed (e.g. scroll bars) have the RTL setting of the GUI.
+ Eventually this has to be disabled manually (see below). */
+ pFrameWin->EnableRTL( FALSE );
+
+ USHORT i;
+
+ aScrollTimer.SetTimeout(10);
+ aScrollTimer.SetTimeoutHdl( LINK( this, ScTabView, TimerHdl ) );
+
+ for (i=0; i<4; i++)
+ pGridWin[i] = NULL;
+ pGridWin[SC_SPLIT_BOTTOMLEFT] = new ScGridWindow( pFrameWin, &aViewData, SC_SPLIT_BOTTOMLEFT );
+
+ pSelEngine = new ScViewSelectionEngine( pGridWin[SC_SPLIT_BOTTOMLEFT], this,
+ SC_SPLIT_BOTTOMLEFT );
+ aFunctionSet.SetSelectionEngine( pSelEngine );
+
+ pHdrSelEng = new ScHeaderSelectionEngine( pFrameWin, &aHdrFunc );
+
+ pColBar[SC_SPLIT_LEFT] = new ScColBar( pFrameWin, &aViewData, SC_SPLIT_LEFT,
+ &aHdrFunc, pHdrSelEng );
+ pColBar[SC_SPLIT_RIGHT] = NULL;
+ pRowBar[SC_SPLIT_BOTTOM] = new ScRowBar( pFrameWin, &aViewData, SC_SPLIT_BOTTOM,
+ &aHdrFunc, pHdrSelEng );
+ pRowBar[SC_SPLIT_TOP] = NULL;
+ for (i=0; i<2; i++)
+ pColOutline[i] = pRowOutline[i] = NULL;
+
+ pHSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_HSCROLL ), &aViewData );
+ pVSplitter = new ScTabSplitter( pFrameWin, WinBits( WB_VSCROLL ), &aViewData );
+
+ // SSA: override default keyboard step size to allow snap to row/column
+ pHSplitter->SetKeyboardStepSize( 1 );
+ pVSplitter->SetKeyboardStepSize( 1 );
+
+ pTabControl = new ScTabControl( pFrameWin, &aViewData );
+ /* #i97900# The tab control has to remain in RTL mode if GUI is RTL, this
+ is needed to draw the 3D effect correctly. The base TabBar implementes
+ mirroring independent from the GUI direction. Have to set RTL mode
+ explicitly because the parent frame window is already RTL disabled. */
+ pTabControl->EnableRTL( Application::GetSettings().GetLayoutRTL() );
+
+ InitScrollBar( aHScrollLeft, MAXCOL+1 );
+ InitScrollBar( aHScrollRight, MAXCOL+1 );
+ InitScrollBar( aVScrollTop, MAXROW+1 );
+ InitScrollBar( aVScrollBottom, MAXROW+1 );
+ /* #i97900# scrollbars remain in correct RTL mode, needed mirroring etc.
+ is now handled correctly at the respective places. */
+
+ // Hier noch nichts anzeigen (Show), weil noch falsch angeordnet ist
+ // Show kommt dann aus UpdateShow beim ersten Resize
+ // pTabControl, pGridWin, aHScrollLeft, aVScrollBottom,
+ // aCornerButton, aScrollBarBox, pHSplitter, pVSplitter
+
+ // Splitter
+
+ pHSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
+ pVSplitter->SetSplitHdl( LINK( this, ScTabView, SplitHdl ) );
+
+ // UpdateShow kommt beim Resize, oder bei Kopie einer bestehenden View aus dem ctor
+
+ pDrawActual = NULL;
+ pDrawOld = NULL;
+
+ // DrawView darf nicht im TabView - ctor angelegt werden,
+ // wenn die ViewShell noch nicht konstruiert ist...
+ // Das gilt auch fuer ViewOptionsHasChanged()
+
+ TestHintWindow();
+}
+
+__EXPORT ScTabView::~ScTabView()
+{
+ USHORT i;
+
+ // remove selection object
+ ScModule* pScMod = SC_MOD();
+ ScSelectionTransferObj* pOld = pScMod->GetSelectionTransfer();
+ if ( pOld && pOld->GetView() == this )
+ {
+ pOld->ForgetView();
+ pScMod->SetSelectionTransfer( NULL );
+ TransferableHelper::ClearSelection( GetActiveWin() ); // may delete pOld
+ }
+
+ DELETEZ(pBrushDocument);
+ DELETEZ(pDrawBrushSet);
+
+ DELETEZ(pPageBreakData);
+ DELETEZ(pHighlightRanges);
+
+ DELETEZ(pDrawOld);
+ DELETEZ(pDrawActual);
+
+ aViewData.KillEditView(); // solange GridWin's noch existieren
+
+ DELETEZ(pInputHintWindow);
+
+ if (pDrawView)
+ {
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ {
+ pDrawView->VCRemoveWin(pGridWin[i]);
+ pDrawView->DeleteWindowFromPaintView(pGridWin[i]);
+ }
+
+ pDrawView->HideSdrPage();
+ delete pDrawView;
+ }
+
+ delete pSelEngine;
+
+ for (i=0; i<4; i++)
+ delete pGridWin[i];
+
+ delete pHdrSelEng;
+
+ for (i=0; i<2; i++)
+ {
+ delete pColBar[i];
+ delete pRowBar[i];
+ delete pColOutline[i];
+ delete pRowOutline[i];
+ }
+
+ delete pHSplitter;
+ delete pVSplitter;
+
+ delete pTabControl;
+}
+
+void ScTabView::MakeDrawView( BYTE nForceDesignMode )
+{
+ if (!pDrawView)
+ {
+ ScDrawLayer* pLayer = aViewData.GetDocument()->GetDrawLayer();
+ DBG_ASSERT(pLayer, "wo ist der Draw Layer ??");
+
+ USHORT i;
+ pDrawView = new ScDrawView( pGridWin[SC_SPLIT_BOTTOMLEFT], &aViewData );
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ {
+ if ( SC_SPLIT_BOTTOMLEFT != (ScSplitPos)i )
+ pDrawView->AddWindowToPaintView(pGridWin[i]);
+ pDrawView->VCAddWin(pGridWin[i]);
+ }
+ pDrawView->RecalcScale();
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ {
+ pGridWin[i]->SetMapMode(pGridWin[i]->GetDrawMapMode());
+
+ pGridWin[i]->Update(); // wegen Invalidate im DrawView ctor (ShowPage),
+ // damit gleich gezeichnet werden kann
+ }
+ SfxRequest aSfxRequest(SID_OBJECT_SELECT, 0,aViewData.GetViewShell()->GetPool());
+ SetDrawFuncPtr(new FuSelection( aViewData.GetViewShell(), GetActiveWin(), pDrawView,
+ pLayer,aSfxRequest));
+
+ // #106334# used when switching back from page preview: restore saved design mode state
+ // (otherwise, keep the default from the draw view ctor)
+ if ( nForceDesignMode != SC_FORCEMODE_NONE )
+ pDrawView->SetDesignMode( (BOOL)nForceDesignMode );
+
+ // an der FormShell anmelden
+ FmFormShell* pFormSh = aViewData.GetViewShell()->GetFormShell();
+ if (pFormSh)
+ pFormSh->SetView(pDrawView);
+
+ if (aViewData.GetViewShell()->HasAccessibilityObjects())
+ aViewData.GetViewShell()->BroadcastAccessibility(SfxSimpleHint(SC_HINT_ACC_MAKEDRAWLAYER));
+
+ }
+}
+
+void ScTabView::DoAddWin( ScGridWindow* pWin )
+{
+ if (pDrawView)
+ {
+ pDrawView->AddWindowToPaintView(pWin);
+ pDrawView->VCAddWin(pWin);
+
+ // #114409#
+ pWin->DrawLayerCreated();
+ }
+}
+
+//==================================================================
+
+void ScTabView::TabChanged()
+{
+ if (pDrawView)
+ {
+ DrawDeselectAll(); // beendet auch Text-Edit-Modus
+
+ USHORT i;
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ pDrawView->VCRemoveWin(pGridWin[i]); // fuer alte Page
+
+ SCTAB nTab = aViewData.GetTabNo();
+ pDrawView->HideSdrPage();
+ pDrawView->ShowSdrPage(pDrawView->GetModel()->GetPage(nTab));
+
+ UpdateLayerLocks();
+
+ pDrawView->RecalcScale();
+ pDrawView->UpdateWorkArea(); // #54782# PageSize ist pro Page unterschiedlich
+
+ for (i=0; i<4; i++)
+ if (pGridWin[i])
+ pDrawView->VCAddWin(pGridWin[i]); // fuer neue Page
+ }
+
+ SfxBindings& rBindings = aViewData.GetBindings();
+
+ // Es gibt keine einfache Moeglichkeit, alle Slots der FormShell zu invalidieren
+ // (fuer disablete Slots auf geschuetzten Tabellen), darum hier einfach alles...
+ rBindings.InvalidateAll(FALSE);
+
+ if (aViewData.GetViewShell()->HasAccessibilityObjects())
+ {
+ SfxSimpleHint aAccHint(SC_HINT_ACC_TABLECHANGED);
+ aViewData.GetViewShell()->BroadcastAccessibility(aAccHint);
+ }
+
+ // notification for XActivationBroadcaster
+ SfxViewFrame* pViewFrame = aViewData.GetViewShell()->GetViewFrame();
+ if (pViewFrame)
+ {
+ uno::Reference<frame::XController> xController = pViewFrame->GetFrame().GetController();
+ if (xController.is())
+ {
+ ScTabViewObj* pImp = ScTabViewObj::getImplementation( xController );
+ if (pImp)
+ pImp->SheetChanged();
+ }
+ }
+}
+
+void ScTabView::UpdateLayerLocks()
+{
+ if (pDrawView)
+ {
+ SCTAB nTab = aViewData.GetTabNo();
+ BOOL bEx = aViewData.GetViewShell()->IsDrawSelMode();
+ BOOL bProt = aViewData.GetDocument()->IsTabProtected( nTab ) ||
+ aViewData.GetSfxDocShell()->IsReadOnly();
+ BOOL bShared = aViewData.GetDocShell()->IsDocShared();
+
+ SdrLayer* pLayer;
+ SdrLayerAdmin& rAdmin = pDrawView->GetModel()->GetLayerAdmin();
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_BACK);
+ if (pLayer)
+ pDrawView->SetLayerLocked( pLayer->GetName(), bProt || !bEx || bShared );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_INTERN);
+ if (pLayer)
+ pDrawView->SetLayerLocked( pLayer->GetName(), TRUE );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_FRONT);
+ if (pLayer)
+ pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_CONTROLS);
+ if (pLayer)
+ pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
+ pLayer = rAdmin.GetLayerPerID(SC_LAYER_HIDDEN);
+ if (pLayer)
+ {
+ pDrawView->SetLayerLocked( pLayer->GetName(), bProt || bShared );
+ pDrawView->SetLayerVisible( pLayer->GetName(), sal_False);
+ }
+ }
+}
+
+void ScTabView::DrawDeselectAll()
+{
+ if (pDrawView)
+ {
+ ScTabViewShell* pViewSh = aViewData.GetViewShell();
+ if ( pDrawActual &&
+ ( pViewSh->IsDrawTextShell() || pDrawActual->GetSlotID() == SID_DRAW_NOTEEDIT ) )
+ {
+ // end text edit (as if escape pressed, in FuDraw)
+ aViewData.GetDispatcher().Execute( pDrawActual->GetSlotID(),
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ }
+
+ pDrawView->ScEndTextEdit();
+ pDrawView->UnmarkAll();
+
+ if (!pViewSh->IsDrawSelMode())
+ pViewSh->SetDrawShell( FALSE );
+ }
+}
+
+BOOL ScTabView::IsDrawTextEdit() const
+{
+ if (pDrawView)
+ return pDrawView->IsTextEdit();
+ else
+ return FALSE;
+}
+
+SvxZoomType ScTabView::GetZoomType() const
+{
+ return aViewData.GetZoomType();
+}
+
+void ScTabView::SetZoomType( SvxZoomType eNew, BOOL bAll )
+{
+ aViewData.SetZoomType( eNew, bAll );
+}
+
+void ScTabView::SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll )
+{
+ aViewData.SetZoom( rNewX, rNewY, bAll );
+ if (pDrawView)
+ pDrawView->RecalcScale();
+ ZoomChanged(); // einzeln wegen CLOOKs
+}
+
+void ScTabView::RefreshZoom()
+{
+ aViewData.RefreshZoom();
+ if (pDrawView)
+ pDrawView->RecalcScale();
+ ZoomChanged();
+}
+
+void ScTabView::SetPagebreakMode( BOOL bSet )
+{
+ aViewData.SetPagebreakMode(bSet);
+ if (pDrawView)
+ pDrawView->RecalcScale();
+ ZoomChanged(); // einzeln wegen CLOOKs
+}
+
+void ScTabView::ResetDrawDragMode()
+{
+ if (pDrawView)
+ pDrawView->SetDragMode( SDRDRAG_MOVE );
+}
+
+void ScTabView::ViewOptionsHasChanged( BOOL bHScrollChanged, BOOL bGraphicsChanged )
+{
+ // DrawView erzeugen, wenn Gitter angezeigt werden soll
+ if ( !pDrawView && aViewData.GetOptions().GetGridOptions().GetGridVisible() )
+ MakeDrawLayer();
+
+ if (pDrawView)
+ pDrawView->UpdateUserViewOptions();
+
+ if (bGraphicsChanged)
+ DrawEnableAnim(TRUE); // DrawEnableAnim checks the options state
+
+ // if TabBar is set to visible, make sure its size is not 0
+ BOOL bGrow = ( aViewData.IsTabMode() && pTabControl->GetSizePixel().Width() <= 0 );
+
+ // if ScrollBar is set to visible, TabBar must make room
+ BOOL bShrink = ( bHScrollChanged && aViewData.IsTabMode() && aViewData.IsHScrollMode() &&
+ pTabControl->GetSizePixel().Width() > SC_TABBAR_DEFWIDTH );
+
+ if ( bGrow || bShrink )
+ {
+ Size aSize = pTabControl->GetSizePixel();
+ aSize.Width() = SC_TABBAR_DEFWIDTH; // initial size
+ pTabControl->SetSizePixel(aSize); // DoResize is called later...
+ }
+}
+
+// Helper-Funktion gegen das Include des Drawing Layers
+
+SdrView* ScTabView::GetSdrView()
+{
+ return pDrawView;
+}
+
+void ScTabView::DrawMarkListHasChanged()
+{
+ if ( pDrawView )
+ pDrawView->MarkListHasChanged();
+}
+
+void ScTabView::UpdateAnchorHandles()
+{
+ if ( pDrawView )
+ pDrawView->AdjustMarkHdl();
+}
+
+void ScTabView::UpdateIMap( SdrObject* pObj )
+{
+ if ( pDrawView )
+ pDrawView->UpdateIMap( pObj );
+}
+
+void ScTabView::DrawMarkRect( const Rectangle& rRect )
+{
+ //! store rectangle for repaint during drag
+
+ for (USHORT i=0; i<4; i++)
+ {
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ {
+ RasterOp aROp = pGridWin[i]->GetRasterOp();
+ BOOL bHasLine = pGridWin[i]->IsLineColor();
+ Color aLine = pGridWin[i]->GetLineColor();
+ BOOL bHasFill = pGridWin[i]->IsFillColor();
+ Color aFill = pGridWin[i]->GetFillColor();
+
+ pGridWin[i]->SetRasterOp( ROP_INVERT );
+ pGridWin[i]->SetLineColor( COL_BLACK );
+ pGridWin[i]->SetFillColor();
+
+ pGridWin[i]->DrawRect(rRect);
+
+ pGridWin[i]->SetRasterOp(aROp);
+ if (bHasLine)
+ pGridWin[i]->SetLineColor(aLine);
+ else
+ pGridWin[i]->SetLineColor();
+ if (bHasFill)
+ pGridWin[i]->SetFillColor(aFill);
+ else
+ pGridWin[i]->SetFillColor();
+ }
+ }
+}
+
+void ScTabView::DrawEnableAnim(BOOL bSet)
+{
+ USHORT i;
+ if ( pDrawView )
+ {
+ // #71040# dont start animations if display of graphics is disabled
+ // graphics are controlled by VOBJ_TYPE_OLE
+ if ( bSet && aViewData.GetOptions().GetObjMode(VOBJ_TYPE_OLE) == VOBJ_MODE_SHOW )
+ {
+ if ( !pDrawView->IsAnimationEnabled() )
+ {
+ pDrawView->SetAnimationEnabled(TRUE);
+
+ // Animierte GIFs muessen wieder gestartet werden:
+ ScDocument* pDoc = aViewData.GetDocument();
+ for (i=0; i<4; i++)
+ if ( pGridWin[i] && pGridWin[i]->IsVisible() )
+ pDoc->StartAnimations( aViewData.GetTabNo(), pGridWin[i] );
+ }
+ }
+ else
+ {
+ pDrawView->SetAnimationEnabled(FALSE);
+ }
+ }
+}
+
+//HMHvoid ScTabView::DrawShowMarkHdl(BOOL bShow)
+//HMH{
+ //HMHif (!pDrawView)
+ //HMH return;
+
+ //HMHif (bShow)
+ //HMH{
+ //HMH if (!pDrawView->IsDisableHdl())
+ //HMH pDrawView->ShowMarkHdl();
+ //HMH}
+ //HMHelse
+ //HMH pDrawView->HideMarkHdl();
+//HMH}
+
+void ScTabView::UpdateDrawTextOutliner()
+{
+ if ( pDrawView )
+ {
+ Outliner* pOL = pDrawView->GetTextEditOutliner();
+ if (pOL)
+ aViewData.UpdateOutlinerFlags( *pOL );
+ }
+}
+
+void ScTabView::DigitLanguageChanged()
+{
+ LanguageType eNewLang = SC_MOD()->GetOptDigitLanguage();
+ for (USHORT i=0; i<4; i++)
+ if ( pGridWin[i] )
+ pGridWin[i]->SetDigitLanguage( eNewLang );
+}
+
+//---------------------------------------------------------------
+
+void ScTabView::ScrollToObject( SdrObject* pDrawObj )
+{
+ if ( pDrawObj )
+ MakeVisible( pDrawObj->GetLogicRect() );
+}
+
+void ScTabView::MakeVisible( const Rectangle& rHMMRect )
+{
+ Window* pWin = GetActiveWin();
+ Size aWinSize = pWin->GetOutputSizePixel();
+ SCTAB nTab = aViewData.GetTabNo();
+
+ Rectangle aRect = pWin->LogicToPixel( rHMMRect );
+
+ long nScrollX=0, nScrollY=0; // Pixel
+
+ if ( aRect.Right() >= aWinSize.Width() ) // rechts raus
+ {
+ nScrollX = aRect.Right() - aWinSize.Width() + 1; // rechter Rand sichtbar
+ if ( aRect.Left() < nScrollX )
+ nScrollX = aRect.Left(); // links sichtbar (falls zu gross)
+ }
+ if ( aRect.Bottom() >= aWinSize.Height() ) // unten raus
+ {
+ nScrollY = aRect.Bottom() - aWinSize.Height() + 1; // unterer Rand sichtbar
+ if ( aRect.Top() < nScrollY )
+ nScrollY = aRect.Top(); // oben sichtbar (falls zu gross)
+ }
+
+ if ( aRect.Left() < 0 ) // links raus
+ nScrollX = aRect.Left(); // linker Rand sichtbar
+ if ( aRect.Top() < 0 ) // oben raus
+ nScrollY = aRect.Top(); // oberer Rand sichtbar
+
+ if (nScrollX || nScrollY)
+ {
+ ScDocument* pDoc = aViewData.GetDocument();
+ if ( pDoc->IsNegativePage( nTab ) )
+ nScrollX = -nScrollX;
+
+ double nPPTX = aViewData.GetPPTX();
+ double nPPTY = aViewData.GetPPTY();
+ ScSplitPos eWhich = aViewData.GetActivePart();
+ SCCOL nPosX = aViewData.GetPosX(WhichH(eWhich));
+ SCROW nPosY = aViewData.GetPosY(WhichV(eWhich));
+
+ long nLinesX=0, nLinesY=0; // Spalten/Zeilen - um mindestens nScrollX/Y scrollen
+
+ if (nScrollX > 0)
+ while (nScrollX > 0 && nPosX < MAXCOL)
+ {
+ nScrollX -= (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX );
+ ++nPosX;
+ ++nLinesX;
+ }
+ else if (nScrollX < 0)
+ while (nScrollX < 0 && nPosX > 0)
+ {
+ --nPosX;
+ nScrollX += (long) ( pDoc->GetColWidth(nPosX, nTab) * nPPTX );
+ --nLinesX;
+ }
+
+ if (nScrollY > 0)
+ while (nScrollY > 0 && nPosY < MAXROW)
+ {
+ nScrollY -= (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY );
+ ++nPosY;
+ ++nLinesY;
+ }
+ else if (nScrollY < 0)
+ while (nScrollY < 0 && nPosY > 0)
+ {
+ --nPosY;
+ nScrollY += (long) ( pDoc->GetRowHeight(nPosY, nTab) * nPPTY );
+ --nLinesY;
+ }
+
+ ScrollLines( nLinesX, nLinesY ); // ausfuehren
+ }
+}
+
+//---------------------------------------------------------------
+
+void ScTabView::SetBrushDocument( ScDocument* pNew, BOOL bLock )
+{
+ delete pBrushDocument;
+ delete pDrawBrushSet;
+
+ pBrushDocument = pNew;
+ pDrawBrushSet = NULL;
+
+ bLockPaintBrush = bLock;
+
+ aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+}
+
+void ScTabView::SetDrawBrushSet( SfxItemSet* pNew, BOOL bLock )
+{
+ delete pBrushDocument;
+ delete pDrawBrushSet;
+
+ pBrushDocument = NULL;
+ pDrawBrushSet = pNew;
+
+ bLockPaintBrush = bLock;
+
+ aViewData.GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+}
+
+void ScTabView::ResetBrushDocument()
+{
+ if ( HasPaintBrush() )
+ {
+ SetBrushDocument( NULL, FALSE );
+ SetActivePointer( Pointer( POINTER_ARROW ) ); // switch pointers also when ended with escape key
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh.cxx b/sc/source/ui/view/tabvwsh.cxx
new file mode 100644
index 000000000000..fdbd07b86cff
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh.cxx
@@ -0,0 +1,120 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/galbrws.hxx>
+#include <svx/imapdlg.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/app.hxx>
+#include <avmedia/mediaplayer.hxx>
+
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "reffact.hxx"
+#include "scresid.hxx"
+#include "dwfunctr.hxx"
+#include "sc.hrc" // -> SID_TOOL_xxx
+#include "drawattr.hxx" // -> SvxDrawToolItem
+#include "spelldialog.hxx"
+
+
+#define ScTabViewShell
+#include "scslots.hxx"
+
+#define SearchSettings
+#include <svx/svxslots.hxx>
+
+TYPEINIT2(ScTabViewShell,SfxViewShell,SfxListener);
+
+SFX_IMPL_INTERFACE(ScTabViewShell,SfxViewShell,ScResId(SCSTR_TABVIEWSHELL))
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER,
+ ScResId(RID_OBJECTBAR_TOOLS) );
+
+ SFX_CHILDWINDOW_REGISTRATION(FID_INPUTLINE_STATUS);
+ SFX_CHILDWINDOW_REGISTRATION(SfxTemplateDialogWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_CONTEXT_REGISTRATION(SID_NAVIGATOR);
+ SFX_CHILDWINDOW_REGISTRATION(SID_TASKPANE);
+ SFX_CHILDWINDOW_REGISTRATION(ScNameDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScSolverDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScOptSolverDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScPivotLayoutWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScTabOpDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScFilterDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScSpecialFilterDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScDbNameDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScConsolidateDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScPrintAreasDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScCondFormatDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScColRowNameRangesDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScFormulaDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SvxIMapDlgChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScFunctionChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScFormulaDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScAcceptChgDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScHighlightChgDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScSimpleRefDlgWrapper::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(SID_SEARCH_DLG);
+ SFX_CHILDWINDOW_REGISTRATION(SID_HYPERLINK_DIALOG);
+ SFX_CHILDWINDOW_REGISTRATION(GalleryChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION(ScSpellDialogChildWindow::GetChildWindowId());
+ SFX_CHILDWINDOW_REGISTRATION( ::avmedia::MediaPlayer::GetChildWindowId() );
+
+ //<!--Added by PengYunQuan for Validity Cell Range Picker
+ SFX_CHILDWINDOW_REGISTRATION(ScValidityRefChildWin::GetChildWindowId());
+ //-->Added by PengYunQuan for Validity Cell Range Picker
+}
+
+SFX_IMPL_NAMED_VIEWFACTORY( ScTabViewShell, "Default" )
+{
+ SFX_VIEW_REGISTRATION(ScDocShell);
+}
+
+//------------------------------------------------------------------
+
+IMPL_LINK( ScTabViewShell, HtmlOptionsHdl, void*, EMPTYARG )
+{
+ // Invalidierung, falls blinkender Text erlaubt/verboten wurde
+ GetViewFrame()->GetBindings().Invalidate(SID_DRAW_TEXT_MARQUEE);
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh2.cxx b/sc/source/ui/view/tabvwsh2.cxx
new file mode 100644
index 000000000000..c9069b543ad5
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh2.cxx
@@ -0,0 +1,482 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ("", off)
+#endif
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svl/languageoptions.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include "tabvwsh.hxx"
+#include "drawattr.hxx"
+#include "drawsh.hxx"
+#include "drawview.hxx"
+#include "fupoor.hxx"
+#include "fuconrec.hxx"
+#include "fuconpol.hxx"
+#include "fuconarc.hxx"
+#include "fuconuno.hxx"
+#include "fusel.hxx"
+#include "futext.hxx"
+#include "fumark.hxx"
+#include "fuinsert.hxx"
+#include "global.hxx"
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+
+// #98185# Create default drawing objects via keyboard
+#include <svx/svdpagv.hxx>
+#include <svl/stritem.hxx>
+#include <svx/svdpage.hxx>
+#include <fuconcustomshape.hxx>
+
+// -----------------------------------------------------------------------
+
+SdrView* __EXPORT ScTabViewShell::GetDrawView() const
+{
+ return ((ScTabViewShell*)this)->GetScDrawView(); // GetScDrawView ist nicht-const
+}
+
+void ScTabViewShell::WindowChanged()
+{
+ Window* pWin = GetActiveWin();
+
+ ScDrawView* pDrView = GetScDrawView();
+ if (pDrView)
+ pDrView->SetActualWin(pWin);
+
+ FuPoor* pFunc = GetDrawFuncPtr();
+ if (pFunc)
+ pFunc->SetWindow(pWin);
+
+ // when font from InputContext is used,
+ // this must be moved to change of cursor position:
+ UpdateInputContext();
+}
+
+void ScTabViewShell::ExecDraw(SfxRequest& rReq)
+{
+ SC_MOD()->InputEnterHandler();
+ UpdateInputHandler();
+
+ MakeDrawLayer();
+
+ ScTabView* pTabView = GetViewData()->GetView();
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+
+ Window* pWin = pTabView->GetActiveWin();
+ ScDrawView* pView = pTabView->GetScDrawView();
+ SdrModel* pDoc = pView->GetModel();
+
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ USHORT nNewId = rReq.GetSlot();
+
+ if ( nNewId == SID_DRAW_CHART )
+ {
+ // #i71254# directly insert a chart instead of drawing its output rectangle
+ FuInsertChart(this, pWin, pView, pDoc, rReq);
+ return;
+ }
+
+ //
+ // Pseudo-Slots von Draw-Toolbox auswerten
+ //! wird das ueberhaupt noch gebraucht ?????
+ //
+
+ if (nNewId == SID_INSERT_DRAW && pArgs)
+ {
+ const SfxPoolItem* pItem;
+ if ( pArgs->GetItemState( SID_INSERT_DRAW, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA( SvxDrawToolItem ) )
+ {
+ SvxDrawToolEnum eSel = (SvxDrawToolEnum)((const SvxDrawToolItem*)pItem)->GetValue();
+ switch (eSel)
+ {
+ case SVX_SNAP_DRAW_SELECT: nNewId = SID_OBJECT_SELECT; break;
+ case SVX_SNAP_DRAW_LINE: nNewId = SID_DRAW_LINE; break;
+ case SVX_SNAP_DRAW_RECT: nNewId = SID_DRAW_RECT; break;
+ case SVX_SNAP_DRAW_ELLIPSE: nNewId = SID_DRAW_ELLIPSE; break;
+ case SVX_SNAP_DRAW_POLYGON_NOFILL: nNewId = SID_DRAW_POLYGON_NOFILL; break;
+ case SVX_SNAP_DRAW_BEZIER_NOFILL: nNewId = SID_DRAW_BEZIER_NOFILL; break;
+ case SVX_SNAP_DRAW_FREELINE_NOFILL: nNewId = SID_DRAW_FREELINE_NOFILL; break;
+ case SVX_SNAP_DRAW_ARC: nNewId = SID_DRAW_ARC; break;
+ case SVX_SNAP_DRAW_PIE: nNewId = SID_DRAW_PIE; break;
+ case SVX_SNAP_DRAW_CIRCLECUT: nNewId = SID_DRAW_CIRCLECUT; break;
+ case SVX_SNAP_DRAW_TEXT: nNewId = SID_DRAW_TEXT; break;
+ case SVX_SNAP_DRAW_TEXT_VERTICAL: nNewId = SID_DRAW_TEXT_VERTICAL; break;
+ case SVX_SNAP_DRAW_TEXT_MARQUEE: nNewId = SID_DRAW_TEXT_MARQUEE; break;
+ case SVX_SNAP_DRAW_CAPTION: nNewId = SID_DRAW_CAPTION; break;
+ case SVX_SNAP_DRAW_CAPTION_VERTICAL: nNewId = SID_DRAW_CAPTION_VERTICAL; break;
+ }
+ }
+ else // USHORT-Item vom Controller
+ {
+ rReq.Done();
+ return;
+ }
+ }
+
+ if ( nNewId == SID_DRAW_SELECT )
+ nNewId = SID_OBJECT_SELECT;
+
+ USHORT nNewFormId = 0;
+ if ( nNewId == SID_FM_CREATE_CONTROL && pArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pArgs->GetItemState( SID_FM_CONTROL_IDENTIFIER, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA( SfxUInt16Item ) )
+ nNewFormId = ((const SfxUInt16Item*)pItem)->GetValue();
+ }
+
+ String sStringItemValue;
+ if ( pArgs )
+ {
+ const SfxPoolItem* pItem;
+ if ( pArgs->GetItemState( nNewId, TRUE, &pItem ) == SFX_ITEM_SET && pItem->ISA( SfxStringItem ) )
+ sStringItemValue = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ }
+ bool bSwitchCustom = ( sStringItemValue.Len() && sDrawCustom.Len() && sStringItemValue != sDrawCustom );
+
+ if (nNewId == SID_INSERT_FRAME) // vom Tbx-Button
+ nNewId = SID_DRAW_TEXT;
+
+ // #97016# CTRL-SID_OBJECT_SELECT is used to select the first object,
+ // but not if SID_OBJECT_SELECT is the result of clicking a create function again,
+ // so this must be tested before changing nNewId below.
+ BOOL bSelectFirst = ( nNewId == SID_OBJECT_SELECT && (rReq.GetModifier() & KEY_MOD1) );
+
+ BOOL bEx = IsDrawSelMode();
+ if ( rReq.GetModifier() & KEY_MOD1 )
+ {
+ // #97016# always allow keyboard selection also on background layer
+ // #98185# also allow creation of default objects if the same object type
+ // was already active
+ bEx = TRUE;
+ }
+ else if ( nNewId == nDrawSfxId && ( nNewId != SID_FM_CREATE_CONTROL ||
+ nNewFormId == nFormSfxId || nNewFormId == 0 ) && !bSwitchCustom )
+ {
+ // #i52871# if a different custom shape is selected, the slot id can be the same,
+ // so the custom shape type string has to be compared, too.
+
+ // SID_FM_CREATE_CONTROL mit nNewFormId==0 (ohne Parameter) kommt beim Deaktivieren
+ // aus FuConstruct::SimpleMouseButtonUp
+ // #59280# Execute fuer die Form-Shell, um im Controller zu deselektieren
+ if ( nNewId == SID_FM_CREATE_CONTROL )
+ {
+ GetViewData()->GetDispatcher().Execute(SID_FM_LEAVE_CREATE);
+ GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ //! was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen????
+ }
+
+ bEx = !bEx;
+ nNewId = SID_OBJECT_SELECT;
+ }
+ else
+ bEx = TRUE;
+
+ if ( nDrawSfxId == SID_FM_CREATE_CONTROL && nNewId != nDrawSfxId )
+ {
+ // Wechsel von Control- zu Zeichenfunktion -> im Control-Controller deselektieren
+ GetViewData()->GetDispatcher().Execute(SID_FM_LEAVE_CREATE);
+ GetViewFrame()->GetBindings().InvalidateAll(FALSE);
+ //! was fuer einen Slot braucht der komische Controller wirklich, um das anzuzeigen????
+ }
+
+ SetDrawSelMode(bEx);
+
+ pView->LockBackgroundLayer( !bEx );
+
+ if ( bSelectFirst )
+ {
+ // #97016# select first draw object if none is selected yet
+ if(!pView->AreObjectsMarked())
+ {
+ // select first object
+ pView->UnmarkAllObj();
+ pView->MarkNextObj(TRUE);
+
+ // ...and make it visible
+ if(pView->AreObjectsMarked())
+ pView->MakeVisible(pView->GetAllMarkedRect(), *pWin);
+ }
+ }
+
+ nDrawSfxId = nNewId;
+ sDrawCustom.Erase(); // value is set below for custom shapes
+
+ if ( nNewId != SID_DRAW_CHART ) // Chart nicht mit DrawShell
+ {
+ if ( nNewId == SID_DRAW_TEXT || nNewId == SID_DRAW_TEXT_VERTICAL ||
+ nNewId == SID_DRAW_TEXT_MARQUEE || nNewId == SID_DRAW_NOTEEDIT )
+ SetDrawTextShell( TRUE );
+ else
+ {
+ if ( bEx || pView->GetMarkedObjectList().GetMarkCount() != 0 )
+ SetDrawShellOrSub();
+ else
+ SetDrawShell( FALSE );
+ }
+ }
+
+ if (pTabView->GetDrawFuncPtr())
+ {
+ if (pTabView->GetDrawFuncOldPtr() != pTabView->GetDrawFuncPtr())
+ delete pTabView->GetDrawFuncOldPtr();
+
+ pTabView->GetDrawFuncPtr()->Deactivate();
+ pTabView->SetDrawFuncOldPtr(pTabView->GetDrawFuncPtr());
+ pTabView->SetDrawFuncPtr(NULL);
+ }
+
+ SfxRequest aNewReq(rReq);
+ aNewReq.SetSlot(nDrawSfxId);
+
+ switch (nNewId)
+ {
+ case SID_OBJECT_SELECT:
+ //@#70206# Nicht immer zurueckschalten
+ if(pView->GetMarkedObjectList().GetMarkCount() == 0) SetDrawShell(bEx);
+ pTabView->SetDrawFuncPtr(new FuSelection(this, pWin, pView, pDoc, aNewReq));
+ break;
+
+ case SID_DRAW_LINE:
+ case SID_DRAW_RECT:
+ case SID_DRAW_ELLIPSE:
+ pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq));
+ break;
+
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ pTabView->SetDrawFuncPtr(new FuConstRectangle(this, pWin, pView, pDoc, aNewReq));
+ pView->SetFrameDragSingles( FALSE );
+ rBindings.Invalidate( SID_BEZIER_EDIT );
+ break;
+
+ case SID_DRAW_POLYGON:
+ case SID_DRAW_POLYGON_NOFILL:
+ case SID_DRAW_BEZIER_NOFILL:
+ case SID_DRAW_FREELINE_NOFILL:
+ pTabView->SetDrawFuncPtr(new FuConstPolygon(this, pWin, pView, pDoc, aNewReq));
+ break;
+
+ case SID_DRAW_ARC:
+ case SID_DRAW_PIE:
+ case SID_DRAW_CIRCLECUT:
+ pTabView->SetDrawFuncPtr(new FuConstArc(this, pWin, pView, pDoc, aNewReq));
+ break;
+
+ case SID_DRAW_TEXT:
+ case SID_DRAW_TEXT_VERTICAL:
+ case SID_DRAW_TEXT_MARQUEE:
+ case SID_DRAW_NOTEEDIT:
+ pTabView->SetDrawFuncPtr(new FuText(this, pWin, pView, pDoc, aNewReq));
+ break;
+
+ case SID_FM_CREATE_CONTROL:
+ SetDrawFormShell(TRUE);
+ pTabView->SetDrawFuncPtr(new FuConstUnoControl(this, pWin, pView, pDoc, aNewReq));
+ nFormSfxId = nNewFormId;
+ break;
+
+ case SID_DRAW_CHART:
+ pTabView->SetDrawFuncPtr(new FuMarkRect(this, pWin, pView, pDoc, aNewReq));
+ break;
+
+ case SID_DRAWTBX_CS_BASIC :
+ case SID_DRAWTBX_CS_SYMBOL :
+ case SID_DRAWTBX_CS_ARROW :
+ case SID_DRAWTBX_CS_FLOWCHART :
+ case SID_DRAWTBX_CS_CALLOUT :
+ case SID_DRAWTBX_CS_STAR :
+ case SID_DRAW_CS_ID :
+ {
+ pTabView->SetDrawFuncPtr( new FuConstCustomShape( this, pWin, pView, pDoc, aNewReq ));
+ if ( nNewId != SID_DRAW_CS_ID )
+ {
+ SFX_REQUEST_ARG( rReq, pEnumCommand, SfxStringItem, nNewId, sal_False );
+ if ( pEnumCommand )
+ {
+ aCurrShapeEnumCommand[ nNewId - SID_DRAWTBX_CS_BASIC ] = pEnumCommand->GetValue();
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nNewId );
+ rBind.Update( nNewId );
+
+ sDrawCustom = pEnumCommand->GetValue(); // to detect when a different shape type is selected
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (pTabView->GetDrawFuncPtr())
+ pTabView->GetDrawFuncPtr()->Activate();
+
+ rReq.Done();
+
+ rBindings.Invalidate( SID_INSERT_DRAW );
+ rBindings.Update( SID_INSERT_DRAW );
+
+ // #98185# Create default drawing objects via keyboard
+ // with qualifier construct directly
+ FuPoor* pFuActual = GetDrawFuncPtr();
+
+ if(pFuActual && (rReq.GetModifier() & KEY_MOD1))
+ {
+ // #98185# Create default drawing objects via keyboard
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ sal_uInt32 nDefaultObjectSizeWidth = rAppOpt.GetDefaultObjectSizeWidth();
+ sal_uInt32 nDefaultObjectSizeHeight = rAppOpt.GetDefaultObjectSizeHeight();
+
+ // calc position and size
+ Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
+ Point aPagePos = aVisArea.Center();
+ aPagePos.X() -= nDefaultObjectSizeWidth / 2;
+ aPagePos.Y() -= nDefaultObjectSizeHeight / 2;
+ Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
+
+ ScDrawView* pDrView = GetScDrawView();
+
+ if(pDrView)
+ {
+ SdrPageView* pPageView = pDrView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ // create the default object
+ SdrObject* pObj = pFuActual->CreateDefaultObject(nNewId, aNewObjectRectangle);
+
+ if(pObj)
+ {
+ // insert into page
+ pView->InsertObjectAtView(pObj, *pPageView);
+
+ if ( nNewId == SID_DRAW_CAPTION || nNewId == SID_DRAW_CAPTION_VERTICAL )
+ {
+ // #105815# use KeyInput to start edit mode (FuText is created).
+ // For FuText objects, edit mode is handled within CreateDefaultObject.
+ // KEY_F2 is handled in FuDraw::KeyInput.
+
+ pFuActual->KeyInput( KeyEvent( 0, KeyCode( KEY_F2 ) ) );
+ }
+ }
+ }
+ }
+ }
+}
+
+void ScTabViewShell::GetDrawState(SfxItemSet &rSet)
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_INSERT_DRAW:
+ {
+ // SID_OBJECT_SELECT nur, wenn "harter" Selektionsmodus
+ USHORT nPutId = nDrawSfxId;
+ if ( nPutId == SID_OBJECT_SELECT && !IsDrawSelMode() )
+ nPutId = USHRT_MAX;
+ // nur die Images, die auch auf dem Controller liegen
+ if ( nPutId != SID_OBJECT_SELECT &&
+ nPutId != SID_DRAW_LINE &&
+ nPutId != SID_DRAW_RECT &&
+ nPutId != SID_DRAW_ELLIPSE &&
+ nPutId != SID_DRAW_POLYGON_NOFILL &&
+ nPutId != SID_DRAW_BEZIER_NOFILL &&
+ nPutId != SID_DRAW_FREELINE_NOFILL &&
+ nPutId != SID_DRAW_ARC &&
+ nPutId != SID_DRAW_PIE &&
+ nPutId != SID_DRAW_CIRCLECUT &&
+ nPutId != SID_DRAW_TEXT &&
+ nPutId != SID_DRAW_TEXT_VERTICAL &&
+ nPutId != SID_DRAW_TEXT_MARQUEE &&
+ nPutId != SID_DRAW_CAPTION &&
+ nPutId != SID_DRAW_CAPTION_VERTICAL )
+ nPutId = USHRT_MAX;
+ SfxAllEnumItem aItem( nWhich, nPutId );
+ if ( !SvtLanguageOptions().IsVerticalTextEnabled() )
+ {
+ aItem.DisableValue( SID_DRAW_TEXT_VERTICAL );
+ aItem.DisableValue( SID_DRAW_CAPTION_VERTICAL );
+ }
+ rSet.Put( aItem );
+ }
+ break;
+
+ case SID_DRAW_CHART:
+ {
+ BOOL bOle = GetViewFrame()->GetFrame().IsInPlace();
+ if ( bOle || !SvtModuleOptions().IsChart() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_OBJECT_SELECT: // wichtig fuer den ollen Control-Controller
+ rSet.Put( SfxBoolItem( nWhich, nDrawSfxId == SID_OBJECT_SELECT && IsDrawSelMode() ) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+BOOL ScTabViewShell::SelectObject( const String& rName )
+{
+ ScDrawView* pView = GetViewData()->GetScDrawView();
+ if (!pView)
+ return FALSE;
+
+ BOOL bFound = pView->SelectObject( rName );
+ // DrawShell etc. is handled in MarkListHasChanged
+
+ return bFound;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
new file mode 100644
index 000000000000..d12aa430fbfa
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh3.cxx
@@ -0,0 +1,1237 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/passwd.hxx>
+#include <sfx2/request.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/stritem.hxx>
+#include <tools/urlobj.hxx>
+
+#include <vcl/msgbox.hxx>
+#include <vcl/vclenum.hxx>
+
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+#include "inputwin.hxx"
+#include "scresid.hxx"
+#include "printfun.hxx"
+#include "docsh.hxx"
+#include "rangelst.hxx"
+#include "prevwsh.hxx"
+#include "rangeutl.hxx"
+#include "reffact.hxx"
+#include "uiitems.hxx"
+#include "cell.hxx"
+#include "inputhdl.hxx"
+#include "autoform.hxx"
+#include "autofmt.hxx"
+#include "dwfunctr.hxx"
+#include "shtabdlg.hxx"
+#include "tabprotection.hxx"
+#include "protectiondlg.hxx"
+
+#include <svl/ilstitem.hxx>
+#define _SVSTDARR_ULONGS
+#include <svl/svstdarr.hxx>
+
+#include <svx/zoomslideritem.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include "scabstdlg.hxx"
+
+#include <memory>
+
+using ::std::auto_ptr;
+
+#define IS_EDITMODE() GetViewData()->HasEditView( GetViewData()->GetActivePart() )
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+#define GET_STRING(nid) ((const SfxStringItem&)pReqArgs->Get(nid)).GetValue()
+#define GET_UINT16(nid) ((const SfxUInt16Item&)pReqArgs->Get(nid)).GetValue()
+#define GET_BOOL(nid) ((const SfxBoolItem&)pReqArgs->Get(nid)).GetValue()
+#define RECALC_PAGE(pDocSh) ScPrintFunc( pDocSh, GetPrinter(), nCurTab ).UpdatePages()
+
+//------------------------------------------------------------------
+
+/** Try to parse the given range using Calc-style syntax first, then
+ Excel-style if that fails. */
+USHORT lcl_ParseRange(ScRange& rScRange, const String& aAddress, ScDocument* pDoc, USHORT /* nSlot */)
+{
+ USHORT nResult = rScRange.Parse(aAddress, pDoc);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ return rScRange.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
+}
+
+/** Try to parse the given address using Calc-style syntax first, then
+ Excel-style if that fails. */
+USHORT lcl_ParseAddress(ScAddress& rScAddress, const String& aAddress, ScDocument* pDoc, USHORT /* nSlot */)
+{
+ USHORT nResult = rScAddress.Parse(aAddress, pDoc);
+ if ( (nResult & SCA_VALID) )
+ return nResult;
+
+ return rScAddress.Parse(aAddress, pDoc, ScAddress::Details(formula::FormulaGrammar::CONV_XL_A1, 0, 0));
+}
+
+void ScTabViewShell::Execute( SfxRequest& rReq )
+{
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ SfxBindings& rBindings = pThisFrame->GetBindings();
+ ScModule* pScMod = SC_MOD();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+
+ if (nSlot != SID_CURRENTCELL) // der kommt beim MouseButtonUp
+ HideListBox(); // Autofilter-DropDown-Listbox
+
+ switch ( nSlot )
+ {
+ case FID_INSERT_FILE:
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState(FID_INSERT_FILE,TRUE,&pItem) == SFX_ITEM_SET )
+ {
+ String aFileName = ((const SfxStringItem*)pItem)->GetValue();
+
+ // Einfuege-Position
+
+ Point aInsertPos;
+ if ( pReqArgs->GetItemState(FN_PARAM_1,TRUE,&pItem) == SFX_ITEM_SET )
+ aInsertPos = ((const SfxPointItem*)pItem)->GetValue();
+ else
+ aInsertPos = GetInsertPos();
+
+ // als Link?
+
+ BOOL bAsLink = FALSE;
+ if ( pReqArgs->GetItemState(FN_PARAM_2,TRUE,&pItem) == SFX_ITEM_SET )
+ bAsLink = ((const SfxBoolItem*)pItem)->GetValue();
+
+ // ausfuehren
+
+ PasteFile( aInsertPos, aFileName, bAsLink );
+ }
+ }
+ break;
+
+ case SID_OPENDLG_EDIT_PRINTAREA:
+ {
+ USHORT nId = ScPrintAreasDlgWrapper::GetChildWindowId();
+ SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case SID_CHANGE_PRINTAREA:
+ {
+ if ( pReqArgs ) // OK aus Dialog
+ {
+ String aPrintStr;
+ String aRowStr;
+ String aColStr;
+ BOOL bEntire = FALSE;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_CHANGE_PRINTAREA, TRUE, &pItem ) == SFX_ITEM_SET )
+ aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if ( pReqArgs->GetItemState( FN_PARAM_2, TRUE, &pItem ) == SFX_ITEM_SET )
+ aRowStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if ( pReqArgs->GetItemState( FN_PARAM_3, TRUE, &pItem ) == SFX_ITEM_SET )
+ aColStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if ( pReqArgs->GetItemState( FN_PARAM_4, TRUE, &pItem ) == SFX_ITEM_SET )
+ bEntire = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+
+ SetPrintRanges( bEntire, &aPrintStr, &aColStr, &aRowStr, FALSE );
+
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_ADD_PRINTAREA:
+ case SID_DEFINE_PRINTAREA: // Menue oder Basic
+ {
+ BOOL bAdd = ( nSlot == SID_ADD_PRINTAREA );
+ if ( pReqArgs )
+ {
+ String aPrintStr;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( SID_DEFINE_PRINTAREA, TRUE, &pItem ) == SFX_ITEM_SET )
+ aPrintStr = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ SetPrintRanges( FALSE, &aPrintStr, NULL, NULL, bAdd );
+ }
+ else
+ {
+ SetPrintRanges( FALSE, NULL, NULL, NULL, bAdd ); // aus Selektion
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_DELETE_PRINTAREA:
+ {
+ String aEmpty;
+ SetPrintRanges( FALSE, &aEmpty, NULL, NULL, FALSE ); // Druckbereich loeschen
+ rReq.Done();
+ }
+ break;
+
+ case FID_DEL_MANUALBREAKS:
+ RemoveManualBreaks();
+ rReq.Done();
+ break;
+
+ case FID_ADJUST_PRINTZOOM:
+ AdjustPrintZoom();
+ rReq.Done();
+ break;
+
+ case FID_RESET_PRINTZOOM:
+ SetPrintZoom( 100, 0 ); // 100%, nicht auf Seiten
+ rReq.Done();
+ break;
+
+ case SID_FORMATPAGE:
+ case SID_STATUS_PAGESTYLE:
+ case SID_HFEDIT:
+ GetViewData()->GetDocShell()->
+ ExecutePageStyle( *this, rReq, GetViewData()->GetTabNo() );
+ break;
+
+ case SID_JUMPTOMARK:
+ case SID_CURRENTCELL:
+ if ( pReqArgs )
+ {
+ String aAddress;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ aAddress = ((const SfxStringItem*)pItem)->GetValue();
+ else if ( nSlot == SID_JUMPTOMARK && pReqArgs->GetItemState(
+ SID_JUMPTOMARK, TRUE, &pItem ) == SFX_ITEM_SET )
+ aAddress = ((const SfxStringItem*)pItem)->GetValue();
+
+ // #i14927# SID_CURRENTCELL with a single cell must unmark if FN_PARAM_1
+ // isn't set (for recorded macros, because IsAPI is no longer available).
+ // ScGridWindow::MouseButtonUp no longer executes the slot for a single
+ // cell if there is a multi selection.
+ BOOL bUnmark = ( nSlot == SID_CURRENTCELL );
+ if ( pReqArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET )
+ bUnmark = ((const SfxBoolItem*)pItem)->GetValue();
+
+ bool bAlignToCursor = true;
+ if (pReqArgs->GetItemState(FN_PARAM_2, true, &pItem) == SFX_ITEM_SET)
+ bAlignToCursor = static_cast<const SfxBoolItem*>(pItem)->GetValue();
+
+ if ( nSlot == SID_JUMPTOMARK )
+ {
+ // #106586# URL has to be decoded for escaped characters (%20)
+ aAddress = INetURLObject::decode( aAddress, INET_HEX_ESCAPE,
+ INetURLObject::DECODE_WITH_CHARSET,
+ RTL_TEXTENCODING_UTF8 );
+ }
+
+ BOOL bFound = FALSE;
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ ScRange aScRange;
+ ScAddress aScAddress;
+ USHORT nResult = lcl_ParseRange(aScRange, aAddress, pDoc, nSlot);
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bMark = TRUE;
+
+ // Is this a range ?
+ if( nResult & SCA_VALID )
+ {
+ if ( nResult & SCA_TAB_3D )
+ {
+ if( aScRange.aStart.Tab() != nTab )
+ SetTabNo( nTab = aScRange.aStart.Tab() );
+ }
+ else
+ {
+ aScRange.aStart.SetTab( nTab );
+ aScRange.aEnd.SetTab( nTab );
+ }
+ }
+ // Is this a cell ?
+ else if ( (nResult = lcl_ParseAddress(aScAddress, aAddress, pDoc, nSlot)) & SCA_VALID )
+ {
+ if ( nResult & SCA_TAB_3D )
+ {
+ if( aScAddress.Tab() != nTab )
+ SetTabNo( nTab = aScAddress.Tab() );
+ }
+ else
+ aScAddress.SetTab( nTab );
+
+ aScRange = ScRange( aScAddress, aScAddress );
+ // Zellen sollen nicht markiert werden
+ bMark = FALSE;
+ }
+ // Ist es benahmster Bereich (erst Namen dann DBBereiche) ?
+ else
+ {
+ ScRangeUtil aRangeUtil;
+ formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention();
+ if( aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_NAMES, eConv ) ||
+ aRangeUtil.MakeRangeFromName( aAddress, pDoc, nTab, aScRange, RUTL_DBASE, eConv ) )
+ {
+ nResult |= SCA_VALID;
+ if( aScRange.aStart.Tab() != nTab )
+ SetTabNo( nTab = aScRange.aStart.Tab() );
+ }
+ }
+
+ if ( !(nResult & SCA_VALID) &&
+ ByteString(aAddress, RTL_TEXTENCODING_ASCII_US).IsNumericAscii() )
+ {
+ sal_Int32 nNumeric = aAddress.ToInt32();
+ if ( nNumeric > 0 && nNumeric <= MAXROW+1 )
+ {
+ // 1-basierte Zeilennummer
+
+ aScAddress.SetRow( (SCROW)(nNumeric - 1) );
+ aScAddress.SetCol( pViewData->GetCurX() );
+ aScAddress.SetTab( nTab );
+ aScRange = ScRange( aScAddress, aScAddress );
+ bMark = FALSE;
+ nResult = SCA_VALID;
+ }
+ }
+
+ if ( !ValidRow(aScRange.aStart.Row()) || !ValidRow(aScRange.aEnd.Row()) )
+ nResult = 0;
+
+ // wir haben was gefunden
+ if( nResult & SCA_VALID )
+ {
+ bFound = TRUE;
+ SCCOL nCol = aScRange.aStart.Col();
+ SCROW nRow = aScRange.aStart.Row();
+ BOOL bNothing = ( pViewData->GetCurX()==nCol && pViewData->GetCurY()==nRow );
+
+ // markieren
+ if( bMark )
+ {
+ if (rMark.IsMarked()) // ist derselbe Bereich schon markiert?
+ {
+ ScRange aOldMark;
+ rMark.GetMarkArea( aOldMark );
+ aOldMark.Justify();
+ ScRange aCurrent = aScRange;
+ aCurrent.Justify();
+ bNothing = ( aCurrent == aOldMark );
+ }
+ else
+ bNothing = FALSE;
+
+ if (!bNothing)
+ MarkRange( aScRange, FALSE ); // Cursor kommt hinterher...
+ }
+ else
+ {
+ // remove old selection, unless bUnmark argument is FALSE (from navigator)
+ if( bUnmark )
+ {
+ MoveCursorAbs( nCol, nRow,
+ SC_FOLLOW_NONE, FALSE, FALSE );
+ }
+ }
+
+ // und Cursor setzen
+
+ // zusammengefasste Zellen beruecksichtigen:
+ pDoc->SkipOverlapped(nCol, nRow, nTab);
+
+ // Navigator-Aufrufe sind nicht API!!!
+
+ if( bNothing )
+ {
+ if (rReq.IsAPI())
+ rReq.Ignore(); // wenn Makro, dann gar nix
+ else
+ rReq.Done(); // sonst wenigstens aufzeichnen
+ }
+ else
+ {
+ pViewData->ResetOldCursor();
+ SetCursor( nCol, nRow );
+ rBindings.Invalidate( SID_CURRENTCELL );
+ rBindings.Update( nSlot );
+
+ if (!rReq.IsAPI())
+ rReq.Done();
+ }
+
+ if (bAlignToCursor)
+ {
+ // align to cursor even if the cursor position hasn't changed,
+ // because the cursor may be set outside the visible area.
+ AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
+ }
+
+ rReq.SetReturnValue( SfxStringItem( SID_CURRENTCELL, aAddress ) );
+ }
+
+ if (!bFound) // kein gueltiger Bereich
+ {
+ // wenn es ein Tabellenname ist, umschalten (fuer Navigator/URL's)
+
+ SCTAB nNameTab;
+ if ( pDoc->GetTable( aAddress, nNameTab ) )
+ {
+ bFound = TRUE;
+ if ( nNameTab != nTab )
+ SetTabNo( nNameTab );
+ }
+ }
+
+ if ( !bFound && nSlot == SID_JUMPTOMARK )
+ {
+ // Grafik-Objekte probieren (nur bei URL's)
+
+ bFound = SelectObject( aAddress );
+ }
+
+ if (!bFound && !rReq.IsAPI())
+ ErrorMessage( STR_ERR_INVALID_AREA );
+ }
+ break;
+
+ case SID_CURRENTOBJECT:
+ if ( pReqArgs )
+ {
+ String aName = ((const SfxStringItem&)pReqArgs->Get(nSlot)).GetValue();
+ SelectObject( aName );
+ }
+ break;
+
+ case SID_CURRENTTAB:
+ if ( pReqArgs )
+ {
+ // Tabelle fuer Basic ist 1-basiert
+ SCTAB nTab = ((const SfxUInt16Item&)pReqArgs->Get(nSlot)).GetValue() - 1;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( nTab < pDoc->GetTableCount() )
+ {
+ SetTabNo( nTab );
+ rBindings.Update( nSlot );
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ //! sonst Fehler ?
+ }
+ break;
+
+ case SID_CURRENTDOC:
+ if ( pReqArgs )
+ {
+ String aStrDocName( ((const SfxStringItem&)pReqArgs->
+ Get(nSlot)).GetValue() );
+
+ SfxViewFrame* pViewFrame = NULL;
+ ScDocShell* pDocSh = (ScDocShell*)SfxObjectShell::GetFirst();
+ BOOL bFound = FALSE;
+
+ // zu aktivierenden ViewFrame suchen
+
+ while ( pDocSh && !bFound )
+ {
+ if ( pDocSh->GetTitle() == aStrDocName )
+ {
+ pViewFrame = SfxViewFrame::GetFirst( pDocSh );
+ bFound = ( NULL != pViewFrame );
+ }
+
+ pDocSh = (ScDocShell*)SfxObjectShell::GetNext( *pDocSh );
+ }
+
+ if ( bFound )
+ pViewFrame->GetFrame().Appear();
+
+ rReq.Ignore();//XXX wird von SFX erledigt
+ }
+
+ case SID_ATTR_SIZE://XXX ???
+ break;
+
+
+ case SID_PRINTPREVIEW:
+ {
+ if ( !pThisFrame->GetFrame().IsInPlace() ) // nicht bei OLE
+ {
+ // print preview is now always in the same frame as the tab view
+ // -> always switch this frame back to normal view
+ // (ScPreviewShell ctor reads view data)
+
+ // #102785#; finish input
+ pScMod->InputEnterHandler();
+
+ pThisFrame->GetDispatcher()->Execute( SID_VIEWSHELL1, SFX_CALLMODE_ASYNCHRON );
+ }
+ // else Fehler (z.B. Ole)
+ }
+ break;
+
+ case SID_DETECTIVE_DEL_ALL:
+ DetectiveDelAll();
+ rReq.Done();
+ break;
+
+ // SID_TABLE_ACTIVATE und SID_MARKAREA werden von Basic aus an der versteckten
+ // View aufgerufen, um auf der sichtbaren View zu markieren/umzuschalten:
+
+ case SID_TABLE_ACTIVATE:
+ DBG_ERROR("old slot SID_TABLE_ACTIVATE");
+ break;
+
+ case SID_REPAINT:
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ PaintExtras();
+ rReq.Done();
+ break;
+
+ case FID_NORMALVIEWMODE:
+ case FID_PAGEBREAKMODE:
+ {
+ BOOL bWantPageBreak = nSlot == FID_PAGEBREAKMODE;
+
+ // check whether there is an explicit argument, use it
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
+ {
+ BOOL bItemValue = ((const SfxBoolItem*)pItem)->GetValue();
+ bWantPageBreak = (nSlot == FID_PAGEBREAKMODE) == bItemValue;
+ }
+
+ if( GetViewData()->IsPagebreakMode() != bWantPageBreak )
+ {
+ SetPagebreakMode( bWantPageBreak );
+ UpdatePageBreakData();
+ SetCurSubShell( GetCurObjectSelectionType(), TRUE );
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ rBindings.Invalidate( nSlot );
+ rReq.AppendItem( SfxBoolItem( nSlot, TRUE ) );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case FID_FUNCTION_BOX:
+ {
+ USHORT nChildId = ScFunctionChildWindow::GetChildWindowId();
+ if ( rReq.GetArgs() )
+ pThisFrame->SetChildWindow( nChildId, ((const SfxBoolItem&) (rReq.GetArgs()->Get(FID_FUNCTION_BOX))).GetValue());
+ else
+ {
+ pThisFrame->ToggleChildWindow( nChildId );
+ rReq.AppendItem( SfxBoolItem( FID_FUNCTION_BOX , pThisFrame->HasChildWindow( nChildId ) ) );
+ }
+
+ GetViewFrame()->GetBindings().Invalidate(FID_FUNCTION_BOX);
+ rReq.Done ();
+ }
+ break;
+
+
+ case FID_TOGGLESYNTAX:
+ {
+ BOOL bSet = !GetViewData()->IsSyntaxMode();
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
+ bSet = ((const SfxBoolItem*)pItem)->GetValue();
+ GetViewData()->SetSyntaxMode( bSet );
+ PaintGrid();
+ rBindings.Invalidate( FID_TOGGLESYNTAX );
+ rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
+ rReq.Done();
+ }
+ break;
+ case FID_TOGGLEHEADERS:
+ {
+ BOOL bSet = !GetViewData()->IsHeaderMode();
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
+ bSet = ((const SfxBoolItem*)pItem)->GetValue();
+ GetViewData()->SetHeaderMode( bSet );
+ RepeatResize();
+ rBindings.Invalidate( FID_TOGGLEHEADERS );
+ rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
+ rReq.Done();
+ }
+ break;
+
+ case FID_TOGGLEFORMULA:
+ {
+ ScViewData* pViewData = GetViewData();
+ const ScViewOptions& rOpts = pViewData->GetOptions();
+ BOOL bFormulaMode = !rOpts.GetOption( VOPT_FORMULAS );
+ const SfxPoolItem *pItem;
+ if( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
+ bFormulaMode = ((const SfxBoolItem *)pItem)->GetValue();
+
+ ScViewOptions rSetOpts = ScViewOptions( rOpts );
+ rSetOpts.SetOption( VOPT_FORMULAS, bFormulaMode );
+ pViewData->SetOptions( rSetOpts );
+
+ pViewData->GetDocShell()->PostPaintGridAll();
+
+ rBindings.Invalidate( FID_TOGGLEFORMULA );
+ rReq.AppendItem( SfxBoolItem( nSlot, bFormulaMode ) );
+ rReq.Done();
+ }
+ break;
+
+ case FID_TOGGLEINPUTLINE:
+ {
+ USHORT nId = ScInputWindowWrapper::GetChildWindowId();
+ SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
+ BOOL bSet = ( pWnd == NULL );
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET )
+ bSet = ((const SfxBoolItem*)pItem)->GetValue();
+
+ pThisFrame->SetChildWindow( nId, bSet );
+ rBindings.Invalidate( FID_TOGGLEINPUTLINE );
+ rReq.AppendItem( SfxBoolItem( nSlot, bSet ) );
+ rReq.Done();
+ }
+ break;
+
+ case SID_ATTR_ZOOM: // Statuszeile
+ case FID_SCALE:
+ {
+ BOOL bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
+ SvxZoomType eOldZoomType = GetZoomType();
+ SvxZoomType eNewZoomType = eOldZoomType;
+ const Fraction& rOldY = GetViewData()->GetZoomY(); // Y wird angezeigt
+ USHORT nOldZoom = (USHORT)(( rOldY.GetNumerator() * 100 )
+ / rOldY.GetDenominator());
+ USHORT nZoom = nOldZoom;
+ BOOL bCancel = FALSE;
+
+ if ( pReqArgs )
+ {
+ const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
+ pReqArgs->Get(SID_ATTR_ZOOM);
+
+ eNewZoomType = rZoomItem.GetType();
+ nZoom = rZoomItem.GetValue();
+ }
+ else
+ {
+ SfxItemSet aSet ( GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
+ SvxZoomItem aZoomItem( eOldZoomType, nOldZoom, SID_ATTR_ZOOM );
+ AbstractSvxZoomDialog* pDlg = NULL;
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ USHORT nBtnFlags = SVX_ZOOM_ENABLE_50
+ | SVX_ZOOM_ENABLE_75
+ | SVX_ZOOM_ENABLE_100
+ | SVX_ZOOM_ENABLE_150
+ | SVX_ZOOM_ENABLE_200
+ | SVX_ZOOM_ENABLE_WHOLEPAGE
+ | SVX_ZOOM_ENABLE_PAGEWIDTH;
+
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ nBtnFlags = nBtnFlags | SVX_ZOOM_ENABLE_OPTIMAL;
+
+ aZoomItem.SetValueSet( nBtnFlags );
+ aSet.Put( aZoomItem );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ pDlg = pFact->CreateSvxZoomDialog(GetDialogParent(), aSet );
+ DBG_ASSERT(pDlg, "Dialogdiet fail!");
+ }
+ pDlg->SetLimits( MINZOOM, MAXZOOM );
+
+ bCancel = ( RET_CANCEL == pDlg->Execute() );
+
+ if ( !bCancel )
+ {
+ const SvxZoomItem& rZoomItem = (const SvxZoomItem&)
+ pDlg->GetOutputItemSet()->
+ Get( SID_ATTR_ZOOM );
+
+ eNewZoomType = rZoomItem.GetType();
+ nZoom = rZoomItem.GetValue();
+ }
+
+ delete pDlg;
+ }
+
+ if ( !bCancel )
+ {
+ if ( eNewZoomType == SVX_ZOOM_PERCENT )
+ {
+ if ( nZoom < MINZOOM ) nZoom = MINZOOM;
+ if ( nZoom > MAXZOOM ) nZoom = MAXZOOM;
+ }
+ else
+ {
+ nZoom = CalcZoom( eNewZoomType, nOldZoom );
+ bCancel = nZoom == 0;
+ }
+
+ switch ( eNewZoomType )
+ {
+ case SVX_ZOOM_WHOLEPAGE:
+ case SVX_ZOOM_PAGEWIDTH:
+ SetZoomType( eNewZoomType, bSyncZoom );
+ break;
+
+ default:
+ SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom );
+ }
+ }
+
+ if ( nZoom != nOldZoom && !bCancel )
+ {
+ if (!GetViewData()->IsPagebreakMode())
+ {
+ ScAppOptions aNewOpt = pScMod->GetAppOptions();
+ aNewOpt.SetZoom( nZoom );
+ aNewOpt.SetZoomType( GetZoomType() );
+ pScMod->SetAppOptions( aNewOpt );
+ }
+ Fraction aFract( nZoom, 100 );
+ SetZoom( aFract, aFract, bSyncZoom );
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ rBindings.Invalidate( SID_ATTR_ZOOM );
+ rReq.AppendItem( SvxZoomItem( GetZoomType(), nZoom, nSlot ) );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ const SfxPoolItem* pItem = NULL;
+ BOOL bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom();
+ if ( pReqArgs && pReqArgs->GetItemState(SID_ATTR_ZOOMSLIDER, TRUE, &pItem) == SFX_ITEM_SET )
+ {
+ const USHORT nCurrentZoom = ((const SvxZoomSliderItem *)pItem)->GetValue();
+ if( nCurrentZoom )
+ {
+ SetZoomType( SVX_ZOOM_PERCENT, bSyncZoom );
+ if (!GetViewData()->IsPagebreakMode())
+ {
+ ScAppOptions aNewOpt = pScMod->GetAppOptions();
+ aNewOpt.SetZoom( nCurrentZoom );
+ aNewOpt.SetZoomType( GetZoomType() );
+ pScMod->SetAppOptions( aNewOpt );
+ }
+ Fraction aFract( nCurrentZoom,100 );
+ SetZoom( aFract, aFract, bSyncZoom );
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+ rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ //----------------------------------------------------------------
+
+ case FID_TAB_SELECTALL:
+ SelectAllTables();
+ rReq.Done();
+ break;
+
+ case FID_TAB_DESELECTALL:
+ DeselectAllTables();
+ rReq.Done();
+ break;
+
+ case SID_SELECT_TABLES:
+ {
+ ScViewData& rViewData = *GetViewData();
+ ScDocument& rDoc = *rViewData.GetDocument();
+ ScMarkData& rMark = rViewData.GetMarkData();
+ SCTAB nTabCount = rDoc.GetTableCount();
+ SCTAB nTab;
+
+ SvULongs aIndexList( 4, 4 );
+ SFX_REQUEST_ARG( rReq, pItem, SfxIntegerListItem, SID_SELECT_TABLES, sal_False );
+ if ( pItem )
+ pItem->GetList( aIndexList );
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScShowTabDlg* pDlg = pFact->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ pDlg->SetDescription(
+ String( ScResId( STR_DLG_SELECTTABLES_TITLE ) ),
+ String( ScResId( STR_DLG_SELECTTABLES_LBNAME ) ),
+ SID_SELECT_TABLES, HID_SELECTTABLES );
+
+ // fill all table names with selection state
+ String aTabName;
+ for( nTab = 0; nTab < nTabCount; ++nTab )
+ {
+ rDoc.GetName( nTab, aTabName );
+ pDlg->Insert( aTabName, rMark.GetTableSelect( nTab ) );
+ }
+
+ if( pDlg->Execute() == RET_OK )
+ {
+ sal_uInt16 nSelCount = pDlg->GetSelectEntryCount();
+ sal_uInt16 nSelIx;
+ for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
+ aIndexList.Insert( pDlg->GetSelectEntryPos( nSelIx ), nSelIx );
+ delete pDlg;
+ rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, aIndexList ) );
+ }
+ else
+ rReq.Ignore();
+ }
+
+ if ( aIndexList.Count() )
+ {
+ sal_uInt16 nSelCount = aIndexList.Count();
+ sal_uInt16 nSelIx;
+ SCTAB nFirstVisTab = 0;
+
+ // special case: only hidden tables selected -> do nothing
+ sal_Bool bVisSelected = sal_False;
+ for( nSelIx = 0; !bVisSelected && (nSelIx < nSelCount); ++nSelIx )
+ bVisSelected = rDoc.IsVisible( nFirstVisTab = static_cast<SCTAB>(aIndexList[nSelIx]) );
+ if( !bVisSelected )
+ nSelCount = 0;
+
+ // select the tables
+ if( nSelCount )
+ {
+ for( nTab = 0; nTab < nTabCount; ++nTab )
+ rMark.SelectTable( nTab, sal_False );
+
+ for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
+ rMark.SelectTable( static_cast<SCTAB>(aIndexList[nSelIx]), sal_True );
+
+ // activate another table, if current is deselected
+ if( !rMark.GetTableSelect( rViewData.GetTabNo() ) )
+ {
+ rMark.SelectTable( nFirstVisTab, sal_True );
+ SetTabNo( nFirstVisTab );
+ }
+
+ rViewData.GetDocShell()->PostPaintExtras();
+ SfxBindings& rBind = rViewData.GetBindings();
+ rBind.Invalidate( FID_FILL_TAB );
+ rBind.Invalidate( FID_TAB_DESELECTALL );
+ }
+
+ rReq.Done();
+ }
+ }
+ break;
+
+
+ case SID_OUTLINE_DELETEALL:
+ RemoveAllOutlines();
+ rReq.Done();
+ break;
+
+ case SID_AUTO_OUTLINE:
+ AutoOutline();
+ rReq.Done();
+ break;
+
+
+ case SID_WINDOW_SPLIT:
+ {
+ ScSplitMode eHSplit = GetViewData()->GetHSplitMode();
+ ScSplitMode eVSplit = GetViewData()->GetVSplitMode();
+ if ( eHSplit == SC_SPLIT_NORMAL || eVSplit == SC_SPLIT_NORMAL ) // aufheben
+ RemoveSplit();
+ else if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // normal
+ FreezeSplitters( FALSE );
+ else // erzeugen
+ SplitAtCursor();
+ rReq.Done();
+
+ InvalidateSplit();
+ }
+ break;
+
+ case SID_WINDOW_FIX:
+ {
+ ScSplitMode eHSplit = GetViewData()->GetHSplitMode();
+ ScSplitMode eVSplit = GetViewData()->GetVSplitMode();
+ if ( eHSplit == SC_SPLIT_FIX || eVSplit == SC_SPLIT_FIX ) // aufheben
+ RemoveSplit();
+ else
+ FreezeSplitters( TRUE ); // erzeugen oder fixieren
+ rReq.Done();
+
+ InvalidateSplit();
+ }
+ break;
+
+ // ----------------------------------------------------------------
+
+ case FID_CHG_SHOW:
+ {
+ USHORT nId = ScHighlightChgDlgWrapper::GetChildWindowId();
+ SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ }
+ break;
+
+ case FID_CHG_ACCEPT:
+ {
+ pThisFrame->ToggleChildWindow(ScAcceptChgDlgWrapper::GetChildWindowId());
+ GetViewFrame()->GetBindings().Invalidate(FID_CHG_ACCEPT);
+ rReq.Done ();
+
+ /*
+ USHORT nId = ScAcceptChgDlgWrapper::GetChildWindowId();
+ SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
+
+ pScMod->SetRefDialog( nId, pWnd ? FALSE : TRUE );
+ */
+ }
+ break;
+
+ case FID_CHG_COMMENT:
+ {
+ ScViewData* pData = GetViewData();
+ ScAddress aCursorPos( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+ ScDocShell* pDocSh = pData->GetDocShell();
+
+ ScChangeAction* pAction = pDocSh->GetChangeAction( aCursorPos );
+ if ( pAction )
+ {
+ const SfxPoolItem* pItem;
+ if ( pReqArgs &&
+ pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET &&
+ pItem->ISA( SfxStringItem ) )
+ {
+ String aComment = ((const SfxStringItem*)pItem)->GetValue();
+ pDocSh->SetChangeComment( pAction, aComment );
+ rReq.Done();
+ }
+ else
+ {
+ pDocSh->ExecuteChangeCommentDialog( pAction, GetDialogParent() );
+ rReq.Done();
+ }
+ }
+ }
+ break;
+
+ case SID_CREATE_SW_DRAWVIEW:
+ // wird von den Forms gerufen, wenn die DrawView mit allem Zubehoer
+ // angelegt werden muss
+ if (!GetScDrawView())
+ {
+ GetViewData()->GetDocShell()->MakeDrawLayer();
+ rBindings.InvalidateAll(FALSE);
+ }
+ break;
+
+ case FID_PROTECT_DOC:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SfxPasswordDialog* pDlg;
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_PROTECT_DOC, &pItem ) &&
+ ((const SfxBoolItem*)pItem)->GetValue() == pDoc->IsDocProtected() )
+ {
+ rReq.Ignore();
+ break;
+ }
+ }
+
+ ScDocProtection* pProtect = pDoc->GetDocProtection();
+ if (pProtect && pProtect->isProtected())
+ {
+ BOOL bCancel = FALSE;
+ String aPassword;
+
+ if (pProtect->isProtectedWithPass())
+ {
+ String aText( ScResId(SCSTR_PASSWORD) );
+
+ pDlg = new SfxPasswordDialog( GetDialogParent(), &aText );
+ pDlg->SetText( ScResId(SCSTR_UNPROTECTDOC) );
+ pDlg->SetMinLen( 0 );
+ pDlg->SetHelpId( FID_PROTECT_DOC );
+ pDlg->SetEditHelpId( HID_PASSWD_DOC );
+
+ if (pDlg->Execute() == RET_OK)
+ aPassword = pDlg->GetPassword();
+ else
+ bCancel = TRUE;
+ delete pDlg;
+ }
+ if (!bCancel)
+ {
+ Unprotect( TABLEID_DOC, aPassword );
+ rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, FALSE ) );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ String aText( ScResId(SCSTR_PASSWORDOPT) );
+
+ pDlg = new SfxPasswordDialog( GetDialogParent(), &aText );
+ pDlg->SetText( ScResId(SCSTR_PROTECTDOC) );
+ pDlg->SetMinLen( 0 );
+ pDlg->SetHelpId( FID_PROTECT_DOC );
+ pDlg->SetEditHelpId( HID_PASSWD_DOC );
+ pDlg->ShowExtras( SHOWEXTRAS_CONFIRM );
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ String aPassword = pDlg->GetPassword();
+ Protect( TABLEID_DOC, aPassword );
+ rReq.AppendItem( SfxBoolItem( FID_PROTECT_DOC, TRUE ) );
+ rReq.Done();
+ }
+
+ delete pDlg;
+ }
+ rBindings.Invalidate( FID_PROTECT_DOC );
+ }
+ break;
+
+
+ case FID_PROTECT_TABLE:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ bool bOldProtection = pDoc->IsTabProtected(nTab);
+
+#if ENABLE_SHEET_PROTECTION
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ bool bNewProtection = !bOldProtection;
+ if( IS_AVAILABLE( FID_PROTECT_TABLE, &pItem ) )
+ bNewProtection = ((const SfxBoolItem*)pItem)->GetValue();
+ if( bNewProtection == bOldProtection )
+ {
+ rReq.Ignore();
+ break;
+ }
+ }
+
+ if (bOldProtection)
+ {
+ // Unprotect a protected sheet.
+
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect && pProtect->isProtectedWithPass())
+ {
+ String aText( ScResId(SCSTR_PASSWORDOPT) );
+ auto_ptr<SfxPasswordDialog> pDlg(new SfxPasswordDialog(GetDialogParent(), &aText));
+ pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) );
+ pDlg->SetMinLen( 0 );
+ pDlg->SetHelpId( FID_PROTECT_TABLE );
+ pDlg->SetEditHelpId( HID_PASSWD_TABLE );
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ String aPassword = pDlg->GetPassword();
+ Unprotect(nTab, aPassword);
+ }
+ }
+ else
+ // this sheet is not password-protected.
+ Unprotect(nTab, String());
+
+ if (!pReqArgs)
+ {
+ rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ // Protect a current sheet.
+
+ auto_ptr<ScTableProtectionDlg> pDlg(new ScTableProtectionDlg(GetDialogParent()));
+
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect)
+ pDlg->SetDialogData(*pProtect);
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ pScMod->InputEnterHandler();
+
+ ScTableProtection aNewProtect;
+ pDlg->WriteData(aNewProtect);
+ ProtectSheet(nTab, aNewProtect);
+ if (!pReqArgs)
+ {
+ rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, true) );
+ rReq.Done();
+ }
+ }
+ }
+#else
+ auto_ptr<SfxPasswordDialog> pDlg;
+ String aPassword;
+ BOOL bCancel = FALSE;
+ bool bNewProtection = ! bOldProtection;
+
+ if( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_PROTECT_TABLE, &pItem ) )
+ bNewProtection = ((const SfxBoolItem*)pItem)->GetValue();
+ if( bNewProtection == bOldProtection )
+ {
+ rReq.Ignore();
+ break;
+ }
+ }
+
+ if ( bOldProtection)
+ {
+ // Unprotect a protected sheet.
+
+ ScTableProtection* pProtect = pDoc->GetTabProtection(nTab);
+ if (pProtect && pProtect->isProtectedWithPass())
+ {
+ String aText( ScResId(SCSTR_PASSWORDOPT) );
+ pDlg.reset(new SfxPasswordDialog(GetDialogParent(), &aText));
+ pDlg->SetText( ScResId(SCSTR_UNPROTECTTAB) );
+ pDlg->SetMinLen( 0 );
+ pDlg->SetHelpId( FID_PROTECT_TABLE );
+ pDlg->SetEditHelpId( HID_PASSWD_TABLE );
+
+ if (pDlg->Execute() == RET_OK)
+ aPassword = pDlg->GetPassword();
+ else
+ bCancel = TRUE;
+ }
+
+ if (!pReqArgs)
+ {
+ rReq.AppendItem( SfxBoolItem(FID_PROTECT_TABLE, false) );
+ rReq.Done();
+ }
+ }
+ else
+ {
+ String aText( ScResId(SCSTR_PASSWORDOPT) );
+
+ pDlg.reset(new SfxPasswordDialog(GetDialogParent(), &aText));
+ pDlg->SetText( ScResId(SCSTR_PROTECTTAB) );
+ pDlg->SetMinLen( 0 );
+ pDlg->SetHelpId( FID_PROTECT_TABLE );
+ pDlg->SetEditHelpId( HID_PASSWD_TABLE );
+ pDlg->ShowExtras( SHOWEXTRAS_CONFIRM );
+
+ if (pDlg->Execute() == RET_OK)
+ aPassword = pDlg->GetPassword();
+ else
+ bCancel = TRUE;
+ }
+
+ if( !bCancel )
+ {
+ if ( bOldProtection )
+ Unprotect( nTab, aPassword );
+ else
+ {
+ pScMod->InputEnterHandler();
+
+ Protect( nTab, aPassword );
+ }
+
+ if( !pReqArgs )
+ {
+ rReq.AppendItem( SfxBoolItem( FID_PROTECT_TABLE, bNewProtection ) );
+ rReq.Done();
+ }
+ }
+#endif
+ TabChanged();
+ UpdateInputHandler(true); // damit sofort wieder eingegeben werden kann
+ SelectionChanged();
+ }
+ break;
+
+ case SID_OPT_LOCALE_CHANGED :
+ { // locale changed, SYSTEM number formats changed => repaint cell contents
+ PaintGrid();
+ rReq.Done();
+ }
+ break;
+
+ default:
+ DBG_ERROR("Unbekannter Slot bei ScTabViewShell::Execute");
+ break;
+ }
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
new file mode 100644
index 000000000000..e6d047e81e32
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -0,0 +1,2028 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <editeng/boxitem.hxx>
+#include <svx/fmshell.hxx>
+#include <editeng/sizeitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <svx/prtqry.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/printdlg.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <rtl/logfile.hxx>
+#include <tools/urlobj.hxx>
+#include <sfx2/docfile.hxx>
+
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "stlpool.hxx"
+#include "stlsheet.hxx"
+#include "docsh.hxx"
+#include "scmod.hxx"
+#include "appoptio.hxx"
+#include "rangeutl.hxx"
+#include "printfun.hxx"
+#include "drawsh.hxx"
+#include "drformsh.hxx"
+#include "editsh.hxx"
+#include "pivotsh.hxx"
+#include "auditsh.hxx"
+#include "drtxtob.hxx"
+#include "inputhdl.hxx"
+#include "editutil.hxx"
+#include "inputopt.hxx"
+#include "inputwin.hxx"
+#include "scresid.hxx"
+#include "dbcolect.hxx" // fuer ReImport
+#include "reffact.hxx"
+#include "viewuno.hxx"
+#include "dispuno.hxx"
+#include "anyrefdg.hxx"
+#include "chgtrack.hxx"
+#include "cellsh.hxx"
+#include "oleobjsh.hxx"
+#include "chartsh.hxx"
+#include "graphsh.hxx"
+#include "mediash.hxx"
+#include "pgbrksh.hxx"
+#include "dpobject.hxx"
+#include "prevwsh.hxx"
+#include "tpprint.hxx"
+#include "scextopt.hxx"
+#include "printopt.hxx"
+#include "drawview.hxx"
+#include "fupoor.hxx"
+#include "navsett.hxx"
+#include "sc.hrc"
+#include "scabstdlg.hxx"
+#include "externalrefmgr.hxx"
+
+void ActivateOlk( ScViewData* pViewData );
+void DeActivateOlk( ScViewData* pViewData );
+
+extern SfxViewShell* pScActiveViewShell; // global.cxx
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+USHORT ScTabViewShell::nInsertCtrlState = SID_INSERT_GRAPHIC;
+USHORT ScTabViewShell::nInsCellsCtrlState = 0;
+USHORT ScTabViewShell::nInsObjCtrlState = SID_INSERT_DIAGRAM;
+
+// -----------------------------------------------------------------------
+
+void __EXPORT ScTabViewShell::Activate(BOOL bMDI)
+{
+ SfxViewShell::Activate(bMDI);
+
+ // hier kein GrabFocus, sonst gibt's Probleme wenn etwas inplace editiert wird!
+
+ if ( bMDI )
+ {
+ // fuer Eingabezeile (ClearCache)
+ ScModule* pScMod = SC_MOD();
+ pScMod->ViewShellChanged();
+
+ ActivateView( TRUE, bFirstActivate );
+ ActivateOlk( GetViewData() );
+
+ // #56870# AutoCorrect umsetzen, falls der Writer seins neu angelegt hat
+ UpdateDrawTextOutliner();
+
+ // RegisterNewTargetNames gibts nicht mehr
+
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ if ( pInputHandler && pThisFrame->HasChildWindow(FID_INPUTLINE_STATUS) )
+ {
+ // eigentlich nur beim Reload (letzte Version) noetig:
+ // Das InputWindow bleibt stehen, aber die View mitsamt InputHandler wird
+ // neu angelegt, darum muss der InputHandler am InputWindow gesetzt werden.
+ SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_INPUTLINE_STATUS);
+ if (pChild)
+ {
+ ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow();
+ if (pWin && pWin->IsVisible())
+ {
+
+ ScInputHandler* pOldHdl=pWin->GetInputHandler();
+
+ TypeId aScType = TYPE(ScTabViewShell);
+
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh!=NULL && pOldHdl!=NULL)
+ {
+ if (((ScTabViewShell*)pSh)->GetInputHandler() == pOldHdl)
+ {
+ pOldHdl->ResetDelayTimer();
+ break;
+ }
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+
+ pWin->SetInputHandler( pInputHandler );
+ }
+ }
+ }
+
+ UpdateInputHandler( TRUE );
+
+ if ( bFirstActivate )
+ {
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_NAVIGATOR_UPDATEALL ) );
+ bFirstActivate = FALSE;
+
+ // #116278# ReadExtOptions (view settings from Excel import) must also be done
+ // after the ctor, because of the potential calls to Window::Show.
+ // Even after the fix for #104887# (Window::Show no longer notifies the access
+ // bridge, it's done in ImplSetReallyVisible), there are problems if Window::Show
+ // is called during the ViewShell ctor and reschedules asynchronous calls
+ // (for example from the FmFormShell ctor).
+ ScExtDocOptions* pExtOpt = GetViewData()->GetDocument()->GetExtDocOptions();
+ if ( pExtOpt && pExtOpt->IsChanged() )
+ {
+ GetViewData()->ReadExtOptions(*pExtOpt); // Excel view settings
+ SetTabNo( GetViewData()->GetTabNo(), TRUE );
+ pExtOpt->SetChanged( false );
+ }
+ }
+
+ pScActiveViewShell = this;
+
+ ScInputHandler* pHdl = pScMod->GetInputHdl(this);
+ if (pHdl)
+ {
+ pHdl->SetRefScale( GetViewData()->GetZoomX(), GetViewData()->GetZoomY() );
+ }
+
+ // Aenderungs-Dialog aktualisieren
+
+ if ( pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
+ {
+ SfxChildWindow* pChild = pThisFrame->GetChildWindow(FID_CHG_ACCEPT);
+ if (pChild)
+ {
+ ((ScAcceptChgDlgWrapper*)pChild)->ReInitDlg();
+ }
+ }
+
+ if(pScMod->IsRefDialogOpen())
+ {
+ USHORT nModRefDlgId=pScMod->GetCurRefDlgId();
+ SfxChildWindow* pChildWnd = pThisFrame->GetChildWindow( nModRefDlgId );
+ if ( pChildWnd )
+ {
+ IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
+ pRefDlg->ViewShellChanged(this);
+ }
+ }
+ }
+
+ // don't call CheckSelectionTransfer here - activating a view should not change the
+ // primary selection (may be happening just because the mouse was moved over the window)
+
+ // Wenn Referenzeingabe-Tip-Hilfe hier wieder angezeigt werden soll (ShowRefTip),
+ // muss sie beim Verschieben der View angepasst werden (gibt sonst Probleme unter OS/2
+ // beim Umschalten zwischen Dokumenten)
+}
+
+void __EXPORT ScTabViewShell::Deactivate(BOOL bMDI)
+{
+ HideTip();
+
+ ScDocument* pDoc=GetViewData()->GetDocument();
+
+ ScChangeTrack* pChanges=pDoc->GetChangeTrack();
+
+ if(pChanges!=NULL)
+ {
+ Link aLink;
+ pChanges->SetModifiedLink(aLink);
+ }
+
+ SfxViewShell::Deactivate(bMDI);
+
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl(this);
+
+ if( bMDI )
+ {
+ // #85421# during shell deactivation, shells must not be switched, or the loop
+ // through the shell stack (in SfxDispatcher::DoDeactivate_Impl) will not work
+ BOOL bOldDontSwitch = bDontSwitch;
+ bDontSwitch = TRUE;
+
+ DeActivateOlk( GetViewData() );
+ ActivateView( FALSE, FALSE );
+
+ if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
+ GetViewData()->GetDocShell()->UpdateOle(GetViewData(),TRUE);
+
+ if ( pHdl )
+ pHdl->NotifyChange( NULL, TRUE ); // Timer-verzoegert wg. Dokumentwechsel
+
+ if (pScActiveViewShell == this)
+ pScActiveViewShell = NULL;
+
+ bDontSwitch = bOldDontSwitch;
+ }
+ else
+ {
+ HideNoteMarker(); // Notiz-Anzeige
+
+ if ( pHdl )
+ pHdl->HideTip(); // Formel-AutoEingabe-Tip abschalten
+ }
+}
+
+void ScTabViewShell::SetActive()
+{
+ // Die Sfx-View moechte sich gerne selbst aktivieren, weil dabei noch
+ // magische Dinge geschehen (z.B. stuerzt sonst evtl. der Gestalter ab)
+ ActiveGrabFocus();
+}
+
+USHORT __EXPORT ScTabViewShell::PrepareClose(BOOL bUI, BOOL bForBrowsing)
+{
+ // Call EnterHandler even in formula mode here,
+ // so a formula change in an embedded object isn't lost
+ // (ScDocShell::PrepareClose isn't called then).
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl( this );
+ if ( pHdl && pHdl->IsInputMode() )
+ pHdl->EnterHandler();
+
+ // #110797# draw text edit mode must be closed
+ FuPoor* pPoor = GetDrawFuncPtr();
+ if ( pPoor && ( IsDrawTextShell() || pPoor->GetSlotID() == SID_DRAW_NOTEEDIT ) )
+ {
+ // "clean" end of text edit, including note handling, subshells and draw func switching,
+ // as in FuDraw and ScTabView::DrawDeselectAll
+ GetViewData()->GetDispatcher().Execute( pPoor->GetSlotID(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ }
+ ScDrawView* pDrView = GetScDrawView();
+ if ( pDrView )
+ {
+ // force end of text edit, to be safe
+ // #128314# ScEndTextEdit must always be used, to ensure correct UndoManager
+ pDrView->ScEndTextEdit();
+ }
+
+ if ( pFormShell )
+ {
+ USHORT nRet = pFormShell->PrepareClose(bUI, bForBrowsing);
+ if (nRet!=TRUE)
+ return nRet;
+ }
+ return SfxViewShell::PrepareClose(bUI,bForBrowsing);
+}
+
+//------------------------------------------------------------------
+
+Size __EXPORT ScTabViewShell::GetOptimalSizePixel() const
+{
+ Size aOptSize;
+
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find(
+ pDoc->GetPageStyle( nCurTab ),
+ SFX_STYLE_FAMILY_PAGE );
+
+ DBG_ASSERT( pStyleSheet, "PageStyle not found :-/" );
+
+ if ( pStyleSheet )
+ {
+ const SfxItemSet& rSet = pStyleSheet->GetItemSet();
+ const SvxSizeItem& rItem = (const SvxSizeItem&)rSet.Get( ATTR_PAGE_SIZE );
+ const Size& rPageSize = rItem.GetSize();
+
+ aOptSize.Width() = (long) (rPageSize.Width() * GetViewData()->GetPPTX());
+ aOptSize.Height() = (long) (rPageSize.Height() * GetViewData()->GetPPTY());
+ }
+
+ return aOptSize;
+}
+
+//------------------------------------------------------------------
+
+// Zoom fuer In-Place berechnen
+// aus Verhaeltnis von VisArea und Fenstergroesse des GridWin
+
+void ScTabViewShell::UpdateOleZoom()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ //TODO/LATER: is there a difference between the two GetVisArea methods?
+ Size aObjSize = ((const SfxObjectShell*)pDocSh)->GetVisArea().GetSize();
+ if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
+ {
+ Window* pWin = GetActiveWin();
+ Size aWinHMM = pWin->PixelToLogic( pWin->GetOutputSizePixel(), MAP_100TH_MM );
+ SetZoomFactor( Fraction( aWinHMM.Width(),aObjSize.Width() ),
+ Fraction( aWinHMM.Height(),aObjSize.Height() ) );
+ }
+ }
+}
+
+void __EXPORT ScTabViewShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
+{
+ OuterResizePixel( rPos, rSize );
+}
+
+void __EXPORT ScTabViewShell::InnerResizePixel( const Point &rOfs, const Size &rSize )
+{
+ Size aNewSize( rSize );
+ if ( GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ SvBorder aBorder;
+ GetBorderSize( aBorder, rSize );
+ SetBorderPixel( aBorder );
+
+ Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
+
+ Size aSize( rSize );
+ aSize.Width() -= (aBorder.Left() + aBorder.Right());
+ aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
+
+ if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
+ {
+ Size aLogicSize = GetWindow()->PixelToLogic( aSize, MAP_100TH_MM );
+ SfxViewShell::SetZoomFactor( Fraction( aLogicSize.Width(),aObjSize.Width() ),
+ Fraction( aLogicSize.Height(),aObjSize.Height() ) );
+ }
+
+ Point aPos( rOfs );
+ aPos.X() += aBorder.Left();
+ aPos.Y() += aBorder.Top();
+ GetWindow()->SetPosSizePixel( aPos, aSize );
+ }
+ else
+ {
+ SvBorder aBorder;
+ GetBorderSize( aBorder, rSize );
+ SetBorderPixel( aBorder );
+ aNewSize.Width() += aBorder.Left() + aBorder.Right();
+ aNewSize.Height() += aBorder.Top() + aBorder.Bottom();
+ }
+
+ DoResize( rOfs, aNewSize, TRUE ); // rSize = Groesse von gridwin
+
+ UpdateOleZoom(); // Zoom fuer In-Place berechnen
+
+// GetViewData()->GetDocShell()->UpdateOle( GetViewData() );
+ GetViewData()->GetDocShell()->SetDocumentModified();
+}
+
+void __EXPORT ScTabViewShell::OuterResizePixel( const Point &rOfs, const Size &rSize )
+{
+ SvBorder aBorder;
+ GetBorderSize( aBorder, rSize );
+ SetBorderPixel( aBorder );
+
+ DoResize( rOfs, rSize ); // Position und Groesse von tabview wie uebergeben
+
+ // ForceMove als Ersatz fuer den Sfx-Move-Mechanismus
+ // (aWinPos muss aktuell gehalten werden, damit ForceMove beim Ole-Deaktivieren klappt)
+
+ ForceMove();
+}
+
+void __EXPORT ScTabViewShell::SetZoomFactor( const Fraction &rZoomX, const Fraction &rZoomY )
+{
+ // fuer OLE...
+
+ Fraction aFrac20( 1,5 );
+ Fraction aFrac400( 4,1 );
+
+ Fraction aNewX( rZoomX );
+ if ( aNewX < aFrac20 )
+ aNewX = aFrac20;
+ if ( aNewX > aFrac400 )
+ aNewX = aFrac400;
+ Fraction aNewY( rZoomY );
+ if ( aNewY < aFrac20 )
+ aNewY = aFrac20;
+ if ( aNewY > aFrac400 )
+ aNewY = aFrac400;
+
+ GetViewData()->UpdateScreenZoom( aNewX, aNewY );
+ SetZoom( aNewX, aNewY, TRUE );
+
+ PaintGrid();
+ PaintTop();
+ PaintLeft();
+
+ SfxViewShell::SetZoomFactor( rZoomX, rZoomY );
+}
+
+void __EXPORT ScTabViewShell::QueryObjAreaPixel( Rectangle& rRect ) const
+{
+ // auf ganze Zellen anpassen (in 1/100 mm)
+
+ Size aPixelSize = rRect.GetSize();
+ Window* pWin = ((ScTabViewShell*)this)->GetActiveWin();
+ Size aLogicSize = pWin->PixelToLogic( aPixelSize );
+
+ const ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScSplitPos ePos = pViewData->GetActivePart();
+ SCCOL nCol = pViewData->GetPosX(WhichH(ePos));
+ SCROW nRow = pViewData->GetPosY(WhichV(ePos));
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bNegativePage = pDoc->IsNegativePage( nTab );
+
+ Rectangle aLogicRect = pDoc->GetMMRect( nCol, nRow, nCol, nRow, nTab );
+ if ( bNegativePage )
+ {
+ // use right edge of aLogicRect, and aLogicSize
+ aLogicRect.Left() = aLogicRect.Right() - aLogicSize.Width() + 1; // Right() is set below
+ }
+ aLogicRect.SetSize( aLogicSize );
+
+ pDoc->SnapVisArea( aLogicRect );
+
+ rRect.SetSize( pWin->LogicToPixel( aLogicRect.GetSize() ) );
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScTabViewShell::Move()
+{
+ Point aNewPos = GetViewFrame()->GetWindow().OutputToScreenPixel(Point());
+
+ if (aNewPos != aWinPos)
+ {
+ StopMarking();
+ aWinPos = aNewPos;
+ }
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScTabViewShell::ShowCursor(bool /* bOn */)
+{
+/*!!! ShowCursor wird nicht paarweise wie im gridwin gerufen.
+ Der CursorLockCount am Gridwin muss hier direkt auf 0 gesetzt werden
+
+ if (bOn)
+ ShowAllCursors();
+ else
+ HideAllCursors();
+*/
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScTabViewShell::WriteUserData(String& rData, BOOL /* bBrowse */)
+{
+ GetViewData()->WriteUserData(rData);
+}
+
+void ScTabViewShell::WriteUserDataSequence (uno::Sequence < beans::PropertyValue >& rSettings, sal_Bool /* bBrowse */ )
+{
+ GetViewData()->WriteUserDataSequence (rSettings);
+}
+
+void __EXPORT ScTabViewShell::ReadUserData(const String& rData, BOOL /* bBrowse */)
+{
+ if ( !GetViewData()->GetDocShell()->IsPreview() )
+ DoReadUserData( rData );
+}
+
+void ScTabViewShell::ReadUserDataSequence (const uno::Sequence < beans::PropertyValue >& rSettings, sal_Bool /* bBrowse */ )
+{
+ if ( !GetViewData()->GetDocShell()->IsPreview() )
+ DoReadUserDataSequence( rSettings );
+}
+
+void ScTabViewShell::DoReadUserDataSequence( const uno::Sequence < beans::PropertyValue >& rSettings )
+{
+ Window* pOldWin = GetActiveWin();
+ BOOL bFocus = pOldWin && pOldWin->HasFocus();
+
+ GetViewData()->ReadUserDataSequence(rSettings);
+ SetTabNo( GetViewData()->GetTabNo(), TRUE );
+
+ if ( GetViewData()->IsPagebreakMode() )
+ SetCurSubShell( GetCurObjectSelectionType(), TRUE );
+
+ Window* pNewWin = GetActiveWin();
+ if (pNewWin && pNewWin != pOldWin)
+ {
+ SetWindow( pNewWin ); //! ist diese ViewShell immer aktiv???
+ if (bFocus)
+ pNewWin->GrabFocus();
+ WindowChanged(); // Drawing-Layer (z.B. #56771#)
+ }
+
+ if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
+ GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)
+ {
+ InvalidateSplit();
+ }
+
+ ZoomChanged();
+
+ TestHintWindow();
+
+ //! if ViewData has more tables than document, remove tables in ViewData
+}
+
+// DoReadUserData is also called from ctor when switching from print preview
+
+void ScTabViewShell::DoReadUserData( const String& rData )
+{
+ Window* pOldWin = GetActiveWin();
+ BOOL bFocus = pOldWin && pOldWin->HasFocus();
+
+ GetViewData()->ReadUserData(rData);
+ SetTabNo( GetViewData()->GetTabNo(), TRUE );
+
+ if ( GetViewData()->IsPagebreakMode() )
+ SetCurSubShell( GetCurObjectSelectionType(), TRUE );
+
+ Window* pNewWin = GetActiveWin();
+ if (pNewWin && pNewWin != pOldWin)
+ {
+ SetWindow( pNewWin ); //! ist diese ViewShell immer aktiv???
+ if (bFocus)
+ pNewWin->GrabFocus();
+ WindowChanged(); // Drawing-Layer (z.B. #56771#)
+ }
+
+ if (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
+ GetViewData()->GetVSplitMode() == SC_SPLIT_FIX)
+ {
+ InvalidateSplit();
+ }
+
+ ZoomChanged();
+
+ TestHintWindow();
+
+ //! if ViewData has more tables than document, remove tables in ViewData
+}
+
+//------------------------------------------------------------------
+
+
+void ScTabViewShell::SetDrawShellOrSub()
+{
+ bActiveDrawSh = TRUE;
+
+ if(bActiveDrawFormSh)
+ {
+ SetCurSubShell(OST_DrawForm);
+ }
+ else if(bActiveGraphicSh)
+ {
+ SetCurSubShell(OST_Graphic);
+ }
+ else if(bActiveMediaSh)
+ {
+ SetCurSubShell(OST_Media);
+ }
+ else if(bActiveChartSh)
+ {
+ SetCurSubShell(OST_Chart);
+ }
+ else if(bActiveOleObjectSh)
+ {
+ SetCurSubShell(OST_OleObject);
+ }
+ else
+ {
+ SetCurSubShell(OST_Drawing, true /* force: different toolbars are
+ visible concerning shape type
+ and shape state */);
+ }
+}
+
+void ScTabViewShell::SetDrawShell( BOOL bActive )
+{
+ if(bActive)
+ {
+ SetCurSubShell(OST_Drawing, true /* force: different toolbars are
+ visible concerning shape type
+ and shape state */);
+ }
+ else
+ {
+ if(bActiveDrawFormSh || bActiveDrawSh ||
+ bActiveGraphicSh || bActiveMediaSh || bActiveOleObjectSh||
+ bActiveChartSh || bActiveDrawTextSh)
+ {
+ SetCurSubShell(OST_Cell);
+ }
+ bActiveDrawFormSh=FALSE;
+ bActiveGraphicSh=FALSE;
+ bActiveMediaSh=FALSE;
+ bActiveOleObjectSh=FALSE;
+ bActiveChartSh=FALSE;
+ }
+
+ BOOL bWasDraw = bActiveDrawSh || bActiveDrawTextSh;
+
+ bActiveDrawSh = bActive;
+ bActiveDrawTextSh = FALSE;
+
+ if ( !bActive )
+ {
+ ResetDrawDragMode(); // Mirror / Rotate aus
+
+ if (bWasDraw && (GetViewData()->GetHSplitMode() == SC_SPLIT_FIX ||
+ GetViewData()->GetVSplitMode() == SC_SPLIT_FIX))
+ {
+ // Aktiven Teil an Cursor anpassen, etc.
+ MoveCursorAbs( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ SC_FOLLOW_NONE, FALSE, FALSE, TRUE );
+ }
+ }
+}
+
+void ScTabViewShell::SetDrawTextShell( BOOL bActive )
+{
+ bActiveDrawTextSh = bActive;
+ if ( bActive )
+ {
+ bActiveDrawFormSh=FALSE;
+ bActiveGraphicSh=FALSE;
+ bActiveMediaSh=FALSE;
+ bActiveOleObjectSh=FALSE;
+ bActiveChartSh=FALSE;
+ bActiveDrawSh = FALSE;
+ SetCurSubShell(OST_DrawText);
+ }
+ else
+ SetCurSubShell(OST_Cell);
+
+}
+
+void ScTabViewShell::SetPivotShell( BOOL bActive )
+{
+ bActivePivotSh = bActive;
+
+ // #68771# #76198# SetPivotShell is called from CursorPosChanged every time
+ // -> don't change anything except switching between cell and pivot shell
+
+ if ( eCurOST == OST_Pivot || eCurOST == OST_Cell )
+ {
+ if ( bActive )
+ {
+ bActiveDrawTextSh = bActiveDrawSh = FALSE;
+ bActiveDrawFormSh=FALSE;
+ bActiveGraphicSh=FALSE;
+ bActiveMediaSh=FALSE;
+ bActiveOleObjectSh=FALSE;
+ bActiveChartSh=FALSE;
+ SetCurSubShell(OST_Pivot);
+ }
+ else
+ SetCurSubShell(OST_Cell);
+ }
+}
+
+void ScTabViewShell::SetAuditShell( BOOL bActive )
+{
+ bActiveAuditingSh = bActive;
+ if ( bActive )
+ {
+ bActiveDrawTextSh = bActiveDrawSh = FALSE;
+ bActiveDrawFormSh=FALSE;
+ bActiveGraphicSh=FALSE;
+ bActiveMediaSh=FALSE;
+ bActiveOleObjectSh=FALSE;
+ bActiveChartSh=FALSE;
+ SetCurSubShell(OST_Auditing);
+ }
+ else
+ SetCurSubShell(OST_Cell);
+}
+
+void ScTabViewShell::SetDrawFormShell( BOOL bActive )
+{
+ bActiveDrawFormSh = bActive;
+
+ if(bActiveDrawFormSh)
+ SetCurSubShell(OST_DrawForm);
+}
+void ScTabViewShell::SetChartShell( BOOL bActive )
+{
+ bActiveChartSh = bActive;
+
+ if(bActiveChartSh)
+ SetCurSubShell(OST_Chart);
+}
+
+void ScTabViewShell::SetGraphicShell( BOOL bActive )
+{
+ bActiveGraphicSh = bActive;
+
+ if(bActiveGraphicSh)
+ SetCurSubShell(OST_Graphic);
+}
+
+void ScTabViewShell::SetMediaShell( BOOL bActive )
+{
+ bActiveMediaSh = bActive;
+
+ if(bActiveMediaSh)
+ SetCurSubShell(OST_Media);
+}
+
+void ScTabViewShell::SetOleObjectShell( BOOL bActive )
+{
+ bActiveOleObjectSh = bActive;
+
+ if(bActiveOleObjectSh)
+ SetCurSubShell(OST_OleObject);
+ else
+ SetCurSubShell(OST_Cell);
+}
+
+void ScTabViewShell::SetEditShell(EditView* pView, BOOL bActive )
+{
+ if(bActive)
+ {
+ if (pEditShell)
+ pEditShell->SetEditView( pView );
+ else
+ pEditShell = new ScEditShell( pView, GetViewData() );
+
+ SetCurSubShell(OST_Editing);
+ }
+ else if(bActiveEditSh)
+ {
+ SetCurSubShell(OST_Cell);
+ }
+ bActiveEditSh = bActive;
+}
+
+void ScTabViewShell::SetCurSubShell(ObjectSelectionType eOST, BOOL bForce)
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ if(bDontSwitch) return;
+
+ if(!pCellShell) //Wird eh immer gebraucht.
+ {
+ pCellShell = new ScCellShell( GetViewData() );
+ pCellShell->SetRepeatTarget( &aTarget );
+ }
+
+ BOOL bPgBrk=pViewData->IsPagebreakMode();
+
+ if(bPgBrk && !pPageBreakShell)
+ {
+ pPageBreakShell = new ScPageBreakShell( this );
+ pPageBreakShell->SetRepeatTarget( &aTarget );
+ }
+
+
+ if ( eOST!=eCurOST || bForce )
+ {
+ BOOL bCellBrush = FALSE; // "format paint brush" allowed for cells
+ BOOL bDrawBrush = FALSE; // "format paint brush" allowed for drawing objects
+
+ if(eCurOST!=OST_NONE) RemoveSubShell();
+
+ if (pFormShell && !bFormShellAtTop)
+ AddSubShell(*pFormShell); // add below own subshells
+
+ switch(eOST)
+ {
+ case OST_Cell:
+ {
+ AddSubShell(*pCellShell);
+ if(bPgBrk) AddSubShell(*pPageBreakShell);
+ bCellBrush = TRUE;
+ }
+ break;
+ case OST_Editing:
+ {
+ AddSubShell(*pCellShell);
+ if(bPgBrk) AddSubShell(*pPageBreakShell);
+
+ if(pEditShell)
+ {
+ AddSubShell(*pEditShell);
+ }
+ }
+ break;
+ case OST_DrawText:
+ {
+ if ( !pDrawTextShell )
+ {
+ pDocSh->MakeDrawLayer();
+ pDrawTextShell = new ScDrawTextObjectBar( GetViewData() );
+ }
+ AddSubShell(*pDrawTextShell);
+ }
+ break;
+ case OST_Drawing:
+ {
+ if (svx::checkForSelectedCustomShapes(
+ GetScDrawView(), true /* bOnlyExtruded */ )) {
+ if (pExtrusionBarShell == 0)
+ pExtrusionBarShell = new svx::ExtrusionBar(this);
+ AddSubShell( *pExtrusionBarShell );
+ }
+ sal_uInt32 nCheckStatus = 0;
+ if (svx::checkForSelectedFontWork(
+ GetScDrawView(), nCheckStatus )) {
+ if (pFontworkBarShell == 0)
+ pFontworkBarShell = new svx::FontworkBar(this);
+ AddSubShell( *pFontworkBarShell );
+ }
+
+ if ( !pDrawShell )
+ {
+ pDocSh->MakeDrawLayer();
+ pDrawShell = new ScDrawShell( GetViewData() );
+ pDrawShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pDrawShell);
+ bDrawBrush = TRUE;
+ }
+ break;
+
+ case OST_DrawForm:
+ {
+ if ( !pDrawFormShell )
+ {
+ pDocSh->MakeDrawLayer();
+ pDrawFormShell = new ScDrawFormShell( GetViewData() );
+ pDrawFormShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pDrawFormShell);
+ bDrawBrush = TRUE;
+ }
+ break;
+
+ case OST_Chart:
+ {
+ if ( !pChartShell )
+ {
+ pDocSh->MakeDrawLayer();
+ pChartShell = new ScChartShell( GetViewData() );
+ pChartShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pChartShell);
+ bDrawBrush = TRUE;
+ }
+ break;
+
+ case OST_OleObject:
+ {
+ if ( !pOleObjectShell )
+ {
+ pDocSh->MakeDrawLayer();
+ pOleObjectShell = new ScOleObjectShell( GetViewData() );
+ pOleObjectShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pOleObjectShell);
+ bDrawBrush = TRUE;
+ }
+ break;
+
+ case OST_Graphic:
+ {
+ if ( !pGraphicShell)
+ {
+ pDocSh->MakeDrawLayer();
+ pGraphicShell = new ScGraphicShell( GetViewData() );
+ pGraphicShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pGraphicShell);
+ bDrawBrush = TRUE;
+ }
+ break;
+
+ case OST_Media:
+ {
+ if ( !pMediaShell)
+ {
+ pDocSh->MakeDrawLayer();
+ pMediaShell = new ScMediaShell( GetViewData() );
+ pMediaShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pMediaShell);
+ }
+ break;
+
+ case OST_Pivot:
+ {
+ AddSubShell(*pCellShell);
+ if(bPgBrk) AddSubShell(*pPageBreakShell);
+
+ if ( !pPivotShell )
+ {
+ pPivotShell = new ScPivotShell( this );
+ pPivotShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pPivotShell);
+ bCellBrush = TRUE;
+ }
+ break;
+ case OST_Auditing:
+ {
+ AddSubShell(*pCellShell);
+ if(bPgBrk) AddSubShell(*pPageBreakShell);
+
+ if ( !pAuditingShell )
+ {
+ pDocSh->MakeDrawLayer(); // die Wartezeit lieber jetzt als beim Klick
+
+ pAuditingShell = new ScAuditingShell( GetViewData() );
+ pAuditingShell->SetRepeatTarget( &aTarget );
+ }
+ AddSubShell(*pAuditingShell);
+ bCellBrush = TRUE;
+ }
+ break;
+ default:
+ DBG_ERROR("Falsche Shell angefordert");
+ break;
+ }
+
+ if (pFormShell && bFormShellAtTop)
+ AddSubShell(*pFormShell); // add on top of own subshells
+
+ eCurOST=eOST;
+
+ // abort "format paint brush" when switching to an incompatible shell
+ if ( ( GetBrushDocument() && !bCellBrush ) || ( GetDrawBrushSet() && !bDrawBrush ) )
+ ResetBrushDocument();
+ }
+}
+
+void ScTabViewShell::SetFormShellAtTop( BOOL bSet )
+{
+ if ( pFormShell && !bSet )
+ pFormShell->ForgetActiveControl(); // let the FormShell know it no longer has the focus
+
+ if ( bFormShellAtTop != bSet )
+ {
+ bFormShellAtTop = bSet;
+ SetCurSubShell( GetCurObjectSelectionType(), TRUE );
+ }
+}
+
+IMPL_LINK( ScTabViewShell, FormControlActivated, FmFormShell*, EMPTYARG )
+{
+ // a form control got the focus, so the form shell has to be on top
+ SetFormShellAtTop( TRUE );
+ return 0;
+}
+
+ObjectSelectionType ScTabViewShell::GetCurObjectSelectionType()
+{
+ return eCurOST;
+}
+
+// GetMySubShell / SetMySubShell: altes Verhalten simulieren,
+// dass es nur eine SubShell gibt (nur innerhalb der 5 eignenen SubShells)
+
+SfxShell* ScTabViewShell::GetMySubShell() const
+{
+ // GetSubShell() war frueher const, und GetSubShell(USHORT) sollte es auch sein...
+
+ USHORT nPos = 0;
+ SfxShell* pSub = ((ScTabViewShell*)this)->GetSubShell(nPos);
+ while (pSub)
+ {
+ if ( pSub == pDrawShell || pSub == pDrawTextShell || pSub == pEditShell ||
+ pSub == pPivotShell || pSub == pAuditingShell || pSub == pDrawFormShell ||
+ pSub == pCellShell || pSub == pOleObjectShell|| pSub == pChartShell ||
+ pSub == pGraphicShell || pSub == pMediaShell || pSub == pPageBreakShell)
+ return pSub; // gefunden
+
+ pSub = ((ScTabViewShell*)this)->GetSubShell(++nPos);
+ }
+ return NULL; // keine von meinen dabei
+}
+
+
+BOOL ScTabViewShell::IsDrawTextShell() const
+{
+ return ( pDrawTextShell && ( GetMySubShell() == pDrawTextShell ) );
+}
+
+BOOL ScTabViewShell::IsAuditShell() const
+{
+ return ( pAuditingShell && ( GetMySubShell() == pAuditingShell ) );
+}
+
+void ScTabViewShell::SetDrawTextUndo( SfxUndoManager* pNewUndoMgr )
+{
+ // Default: Undo-Manager der DocShell
+ if (!pNewUndoMgr)
+ pNewUndoMgr = GetViewData()->GetDocShell()->GetUndoManager();
+
+ if (pDrawTextShell)
+ {
+ pDrawTextShell->SetUndoManager(pNewUndoMgr);
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ if ( pNewUndoMgr == pDocSh->GetUndoManager() &&
+ !pDocSh->GetDocument()->IsUndoEnabled() )
+ {
+ pNewUndoMgr->SetMaxUndoActionCount( 0 );
+ }
+ }
+ else
+ {
+ DBG_ERROR("SetDrawTextUndo ohne DrawTextShell");
+ }
+}
+
+//------------------------------------------------------------------
+
+ScTabViewShell* ScTabViewShell::GetActiveViewShell()
+{
+ return PTR_CAST(ScTabViewShell,Current());
+}
+
+//------------------------------------------------------------------
+
+SfxPrinter* __EXPORT ScTabViewShell::GetPrinter( BOOL bCreate )
+{
+ // Drucker ist immer da (wird fuer die FontListe schon beim Starten angelegt)
+ return GetViewData()->GetDocShell()->GetPrinter(bCreate);
+}
+
+USHORT __EXPORT ScTabViewShell::SetPrinter( SfxPrinter *pNewPrinter, USHORT nDiffFlags, bool )
+{
+ return GetViewData()->GetDocShell()->SetPrinter( pNewPrinter, nDiffFlags );
+}
+
+PrintDialog* __EXPORT ScTabViewShell::CreatePrintDialog( Window *pParent )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+
+ pDoc->SetPrintOptions(); // Optionen aus OFA am Printer setzen
+ SfxPrinter* pPrinter = GetPrinter();
+
+ String aStrRange;
+ PrintDialog* pDlg = new PrintDialog( pParent, true );
+ SCTAB nTabCount = pDoc->GetTableCount();
+ long nDocPageMax = 0;
+
+ pDlg->EnableSheetRange( true, PRINTSHEETS_ALL );
+ pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_SHEETS );
+ pDlg->EnableSheetRange( true, PRINTSHEETS_SELECTED_CELLS );
+ bool bAllTabs = SC_MOD()->GetPrintOptions().GetAllSheets();
+ pDlg->CheckSheetRange( bAllTabs ? PRINTSHEETS_ALL : PRINTSHEETS_SELECTED_SHEETS );
+
+ // update all pending row heights with a single progress bar,
+ // instead of a separate progress for each sheet from ScPrintFunc
+ pDocShell->UpdatePendingRowHeights( MAXTAB, true );
+
+ ScMarkData aMarkData;
+ aMarkData.SelectTable( GetViewData()->GetTabNo(), TRUE );
+
+ for ( SCTAB i=0; i<nTabCount; i++ )
+ {
+ if ( !bAllTabs && !aMarkData.GetTableSelect( i ) )
+ continue;
+ ScPrintFunc aPrintFunc( pDocShell, pPrinter, i );
+ nDocPageMax += aPrintFunc.GetTotalPages();
+ }
+
+ if ( nDocPageMax > 0 )
+ {
+ aStrRange = '1';
+ if ( nDocPageMax > 1 )
+ {
+ aStrRange += '-';
+ aStrRange += String::CreateFromInt32( nDocPageMax );
+ }
+ }
+
+ pDlg->SetRangeText ( aStrRange );
+ pDlg->EnableRange ( PRINTDIALOG_ALL );
+ pDlg->EnableRange ( PRINTDIALOG_RANGE );
+ pDlg->SetFirstPage ( 1 );
+ pDlg->SetMinPage ( 1 );
+ pDlg->SetLastPage ( (USHORT)nDocPageMax );
+ pDlg->SetMaxPage ( (USHORT)nDocPageMax );
+ pDlg->EnableCollate ();
+
+ return pDlg;
+}
+
+SfxTabPage* ScTabViewShell::CreatePrintOptionsPage( Window *pParent, const SfxItemSet &rOptions )
+{
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ ::CreateTabPage ScTpPrintOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
+ if ( ScTpPrintOptionsCreate )
+ return (*ScTpPrintOptionsCreate)( pParent, rOptions);
+ return 0;
+}
+
+void __EXPORT ScTabViewShell::PreparePrint( PrintDialog* pPrintDialog )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+
+ SfxViewShell::PreparePrint( pPrintDialog );
+ pDocShell->PreparePrint( pPrintDialog, &GetViewData()->GetMarkData() );
+}
+
+ErrCode ScTabViewShell::DoPrint( SfxPrinter *pPrinter,
+ PrintDialog *pPrintDialog, BOOL bSilent, BOOL bIsAPI )
+{
+ // #72527# if SID_PRINTDOCDIRECT is executed and there's a selection,
+ // ask if only the selection should be printed
+
+ const ScMarkData& rMarkData = GetViewData()->GetMarkData();
+ if ( !pPrintDialog && !bSilent && !bIsAPI && ( rMarkData.IsMarked() || rMarkData.IsMultiMarked() ) )
+ {
+ SvxPrtQryBox aQuery( GetDialogParent() );
+ short nBtn = aQuery.Execute();
+
+ if ( nBtn == RET_CANCEL )
+ return ERRCODE_IO_ABORT;
+
+ if ( nBtn == RET_OK )
+ bPrintSelected = TRUE;
+ }
+
+ ErrCode nRet = ERRCODE_IO_ABORT;
+
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ if ( pDocShell->CheckPrint( pPrintDialog, &GetViewData()->GetMarkData(), bPrintSelected, bIsAPI ) )
+ {
+ // get the list of affected sheets before SfxViewShell::Print
+ bool bAllTabs = ( pPrintDialog ? ( pPrintDialog->GetCheckedSheetRange() == PRINTSHEETS_ALL ) : SC_MOD()->GetPrintOptions().GetAllSheets() );
+
+ uno::Sequence<sal_Int32> aSheets;
+ SCTAB nTabCount = pDocShell->GetDocument()->GetTableCount();
+ USHORT nPrinted = 0;
+ for ( SCTAB nTab=0; nTab<nTabCount; nTab++ )
+ if ( bAllTabs || rMarkData.GetTableSelect(nTab) )
+ {
+ aSheets.realloc( nPrinted + 1 );
+ aSheets[nPrinted] = nTab;
+ ++nPrinted;
+ }
+
+ uno::Sequence < beans::PropertyValue > aProps(1);
+ aProps[0].Name=::rtl::OUString::createFromAscii("PrintSheets");
+ aProps[0].Value <<= aSheets;
+ SetAdditionalPrintOptions( aProps );
+
+ // SfxViewShell::DoPrint calls Print (after StartJob etc.)
+ nRet = SfxViewShell::DoPrint( pPrinter, pPrintDialog, bSilent, bIsAPI );
+ }
+
+ bPrintSelected = FALSE;
+
+ return nRet;
+}
+
+USHORT __EXPORT ScTabViewShell::Print( SfxProgress& rProgress, BOOL bIsAPI,
+ PrintDialog* pPrintDialog )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ pDocShell->GetDocument()->SetPrintOptions(); // Optionen aus OFA am Printer setzen
+
+ SfxViewShell::Print( rProgress, bIsAPI, pPrintDialog );
+ pDocShell->Print( rProgress, pPrintDialog, &GetViewData()->GetMarkData(),
+ GetDialogParent(), bPrintSelected, bIsAPI );
+ return 0;
+}
+
+void ScTabViewShell::StopEditShell()
+{
+ if ( pEditShell != NULL && !bDontSwitch )
+ SetEditShell(NULL, FALSE );
+}
+
+//------------------------------------------------------------------
+
+// close handler to ensure function of dialog:
+
+IMPL_LINK( ScTabViewShell, SimpleRefClose, String*, EMPTYARG )
+{
+ SfxInPlaceClient* pClient = GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() )
+ {
+ // If range selection was started with an active embedded object,
+ // switch back to original sheet (while the dialog is still open).
+
+ SetTabNo( GetViewData()->GetRefTabNo() );
+ }
+
+ ScSimpleRefDlgWrapper::SetAutoReOpen( TRUE );
+ return 0;
+}
+
+// handlers to call UNO listeners:
+
+ScTabViewObj* lcl_GetViewObj( ScTabViewShell& rShell )
+{
+ ScTabViewObj* pRet = NULL;
+ SfxViewFrame* pViewFrame = rShell.GetViewFrame();
+ if (pViewFrame)
+ {
+ SfxFrame& rFrame = pViewFrame->GetFrame();
+ uno::Reference<frame::XController> xController = rFrame.GetController();
+ if (xController.is())
+ pRet = ScTabViewObj::getImplementation( xController );
+ }
+ return pRet;
+}
+
+IMPL_LINK( ScTabViewShell, SimpleRefDone, String*, pResult )
+{
+ ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
+ if ( pImpObj && pResult )
+ pImpObj->RangeSelDone( *pResult );
+ return 0;
+}
+
+IMPL_LINK( ScTabViewShell, SimpleRefAborted, String*, pResult )
+{
+ ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
+ if ( pImpObj && pResult )
+ pImpObj->RangeSelAborted( *pResult );
+ return 0;
+}
+
+IMPL_LINK( ScTabViewShell, SimpleRefChange, String*, pResult )
+{
+ ScTabViewObj* pImpObj = lcl_GetViewObj( *this );
+ if ( pImpObj && pResult )
+ pImpObj->RangeSelChanged( *pResult );
+ return 0;
+}
+
+void ScTabViewShell::StartSimpleRefDialog(
+ const String& rTitle, const String& rInitVal,
+ BOOL bCloseOnButtonUp, BOOL bSingleCell, BOOL bMultiSelection )
+{
+ SfxViewFrame* pViewFrm = GetViewFrame();
+
+ if ( GetActiveViewShell() != this )
+ {
+ // #i18833# / #i34499# The API method can be called for a view that's not active.
+ // Then the view has to be activated first, the same way as in Execute for SID_CURRENTDOC.
+ // Can't use GrabFocus here, because it needs to take effect immediately.
+
+ pViewFrm->GetFrame().Appear();
+ }
+
+ USHORT nId = ScSimpleRefDlgWrapper::GetChildWindowId();
+
+ SC_MOD()->SetRefDialog( nId, TRUE, pViewFrm );
+
+ ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+ if (pWnd)
+ {
+ pWnd->SetCloseHdl( LINK( this, ScTabViewShell, SimpleRefClose ) );
+ pWnd->SetUnoLinks( LINK( this, ScTabViewShell, SimpleRefDone ),
+ LINK( this, ScTabViewShell, SimpleRefAborted ),
+ LINK( this, ScTabViewShell, SimpleRefChange ) );
+ pWnd->SetRefString( rInitVal );
+ pWnd->SetFlags( bCloseOnButtonUp, bSingleCell, bMultiSelection );
+ pWnd->SetAutoReOpen( FALSE );
+ Window* pWin = pWnd->GetWindow();
+ pWin->SetText( rTitle );
+ pWnd->StartRefInput();
+ }
+}
+
+void ScTabViewShell::StopSimpleRefDialog()
+{
+ SfxViewFrame* pViewFrm = GetViewFrame();
+ USHORT nId = ScSimpleRefDlgWrapper::GetChildWindowId();
+
+ ScSimpleRefDlgWrapper* pWnd = (ScSimpleRefDlgWrapper*)pViewFrm->GetChildWindow( nId );
+ if (pWnd)
+ {
+ Window* pWin = pWnd->GetWindow();
+ if (pWin && pWin->IsSystemWindow())
+ ((SystemWindow*)pWin)->Close(); // calls abort handler
+ }
+}
+
+//------------------------------------------------------------------
+
+BOOL ScTabViewShell::TabKeyInput(const KeyEvent& rKEvt)
+{
+ ScModule* pScMod = SC_MOD();
+
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ if ( pThisFrame->GetChildWindow( SID_OPENDLG_FUNCTION ) )
+ return FALSE;
+
+ KeyCode aCode = rKEvt.GetKeyCode();
+ BOOL bShift = aCode.IsShift();
+ BOOL bControl = aCode.IsMod1();
+ BOOL bAlt = aCode.IsMod2();
+ USHORT nCode = aCode.GetCode();
+ BOOL bUsed = FALSE;
+ BOOL bInPlace = pScMod->IsEditMode(); // Editengine bekommt alles
+ BOOL bAnyEdit = pScMod->IsInputMode(); // nur Zeichen & Backspace
+ BOOL bDraw = IsDrawTextEdit();
+
+ HideNoteMarker(); // Notiz-Anzeige
+
+ // don't do extra HideCursor/ShowCursor calls if EnterHandler will switch to a different sheet
+ BOOL bOnRefSheet = ( GetViewData()->GetRefTabNo() == GetViewData()->GetTabNo() );
+ BOOL bHideCursor = ( ( nCode == KEY_RETURN && bInPlace ) || nCode == KEY_TAB ) && bOnRefSheet;
+
+ if (bHideCursor)
+ HideAllCursors();
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( pDoc )
+ pDoc->KeyInput( rKEvt ); // TimerDelays etc.
+
+ if( bInPlace )
+ {
+ bUsed = pScMod->InputKeyEvent( rKEvt ); // Eingabe
+ if( !bUsed )
+ bUsed = sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKEvt )); // accelerators
+ }
+ else if( bAnyEdit )
+ {
+ BOOL bIsType = FALSE;
+ USHORT nModi = aCode.GetModifier();
+ USHORT nGroup = aCode.GetGroup();
+
+ if ( nGroup == KEYGROUP_NUM || nGroup == KEYGROUP_ALPHA || nGroup == 0 )
+ if ( !bControl && !bAlt )
+ bIsType = TRUE;
+
+ if ( nGroup == KEYGROUP_MISC )
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ bIsType = bControl && !bAlt; // Control, Shift-Control-Return
+ if ( !bIsType && nModi == 0 )
+ {
+ // Will der InputHandler auch ein einfaches Return?
+
+ ScInputHandler* pHdl = pScMod->GetInputHdl(this);
+ bIsType = pHdl && pHdl->TakesReturn();
+ }
+ break;
+ case KEY_SPACE:
+ bIsType = !bControl && !bAlt; // ohne Modifier oder Shift-Space
+ break;
+ case KEY_ESCAPE:
+ case KEY_BACKSPACE:
+ bIsType = (nModi == 0); // nur ohne Modifier
+ break;
+ default:
+ bIsType = TRUE;
+ }
+
+ if( bIsType )
+ bUsed = pScMod->InputKeyEvent( rKEvt ); // Eingabe
+
+ if( !bUsed )
+ bUsed = sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKEvt )); // accelerators
+
+ if ( !bUsed && !bIsType && nCode != KEY_RETURN ) // Eingabe nochmal hinterher
+ bUsed = pScMod->InputKeyEvent( rKEvt );
+ }
+ else
+ {
+ // #51889# Spezialfall: Copy/Cut bei Mehrfachselektion -> Fehlermeldung
+ // (Slot ist disabled, SfxViewShell::KeyInput wuerde also kommentarlos verschluckt)
+ KeyFuncType eFunc = aCode.GetFunction();
+ if ( eFunc == KEYFUNC_CUT )
+ {
+ ScRange aDummy;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aDummy );
+ if ( eMarkType != SC_MARK_SIMPLE &&
+ !(eFunc == KEYFUNC_COPY && eMarkType == SC_MARK_SIMPLE_FILTERED) )
+ {
+ ErrorMessage(STR_NOMULTISELECT);
+ bUsed = TRUE;
+ }
+ }
+ if (!bUsed)
+ bUsed = sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKEvt )); // accelerators
+
+ // #74696# during inplace editing, some slots are handled by the
+ // container app and are executed during Window::KeyInput.
+ // -> don't pass keys to input handler that would be used there
+ // but should call slots instead.
+ BOOL bParent = ( GetViewFrame()->GetFrame().IsInPlace() && eFunc != KEYFUNC_DONTKNOW );
+
+ if( !bUsed && !bDraw && nCode != KEY_RETURN && !bParent )
+ bUsed = pScMod->InputKeyEvent( rKEvt, TRUE ); // Eingabe
+ }
+
+ if (!bInPlace && !bUsed && !bDraw)
+ {
+ switch (nCode)
+ {
+ case KEY_RETURN:
+ {
+ BOOL bNormal = !bControl && !bAlt;
+ if ( !bAnyEdit && bNormal )
+ {
+ // je nach Optionen mit Enter in den Edit-Modus schalten
+
+ const ScInputOptions& rOpt = pScMod->GetInputOptions();
+ if ( rOpt.GetEnterEdit() )
+ {
+ pScMod->SetInputMode( SC_INPUT_TABLE );
+ bUsed = TRUE;
+ }
+ }
+
+ BOOL bEditReturn = bControl && !bShift; // An Edit-Engine weiter
+ if ( !bUsed && !bEditReturn )
+ {
+ if ( bOnRefSheet )
+ HideAllCursors();
+
+ BYTE nMode = SC_ENTER_NORMAL;
+ if ( bShift && bControl )
+ nMode = SC_ENTER_MATRIX;
+ else if ( bAlt )
+ nMode = SC_ENTER_BLOCK;
+ pScMod->InputEnterHandler(nMode);
+
+ if (nMode == SC_ENTER_NORMAL)
+ {
+ if( bShift )
+ GetViewData()->GetDispatcher().Execute( SID_CURSORENTERUP,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ else
+ GetViewData()->GetDispatcher().Execute( SID_CURSORENTERDOWN,
+ SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ }
+ else
+ UpdateInputHandler(TRUE);
+
+ if ( bOnRefSheet )
+ ShowAllCursors();
+
+ // hier kein UpdateInputHandler, weil bei Referenzeingabe auf ein
+ // anderes Dokument diese ViewShell nicht die ist, auf der eingegeben
+ // wird!
+
+ bUsed = TRUE;
+ }
+ }
+ break;
+ }
+ }
+
+ // Alt-Cursortasten hart codiert, weil Alt nicht konfigurierbar ist
+
+ if ( !bUsed && bAlt && !bControl )
+ {
+ USHORT nSlotId = 0;
+ switch (nCode)
+ {
+ case KEY_UP:
+ ModifyCellSize( DIR_TOP, bShift );
+ bUsed = TRUE;
+ break;
+ case KEY_DOWN:
+ ModifyCellSize( DIR_BOTTOM, bShift );
+ bUsed = TRUE;
+ break;
+ case KEY_LEFT:
+ ModifyCellSize( DIR_LEFT, bShift );
+ bUsed = TRUE;
+ break;
+ case KEY_RIGHT:
+ ModifyCellSize( DIR_RIGHT, bShift );
+ bUsed = TRUE;
+ break;
+ case KEY_PAGEUP:
+ nSlotId = bShift ? SID_CURSORPAGELEFT_SEL : SID_CURSORPAGELEFT_;
+ break;
+ case KEY_PAGEDOWN:
+ nSlotId = bShift ? SID_CURSORPAGERIGHT_SEL : SID_CURSORPAGERIGHT_;
+ break;
+ }
+ if ( nSlotId )
+ {
+ GetViewData()->GetDispatcher().Execute( nSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD );
+ bUsed = TRUE;
+ }
+ }
+
+ if (bHideCursor)
+ ShowAllCursors();
+
+ return bUsed;
+}
+
+BOOL ScTabViewShell::SfxKeyInput(const KeyEvent& rKeyEvent)
+{
+ return sal::static_int_cast<BOOL>(SfxViewShell::KeyInput( rKeyEvent ));
+}
+
+bool __EXPORT ScTabViewShell::KeyInput( const KeyEvent &rKeyEvent )
+{
+// return SfxViewShell::KeyInput( rKeyEvent );
+ return TabKeyInput( rKeyEvent );
+}
+
+//------------------------------------------------------------------
+
+#define __INIT_ScTabViewShell \
+ eCurOST(OST_NONE), \
+ nDrawSfxId(0), \
+ nCtrlSfxId(USHRT_MAX), \
+ nFormSfxId(USHRT_MAX), \
+ pDrawShell(NULL), \
+ pDrawTextShell(NULL), \
+ pEditShell(NULL), \
+ pPivotShell(NULL), \
+ pAuditingShell(NULL), \
+ pDrawFormShell(NULL), \
+ pCellShell(NULL), \
+ pOleObjectShell(NULL), \
+ pChartShell(NULL), \
+ pGraphicShell(NULL), \
+ pMediaShell(NULL), \
+ pPageBreakShell(NULL), \
+ pExtrusionBarShell(NULL), \
+ pFontworkBarShell(NULL), \
+ pFormShell(NULL), \
+ pInputHandler(NULL), \
+ pCurFrameLine(NULL), \
+ aTarget( this ), \
+ pDialogDPObject(NULL), \
+ pNavSettings(NULL), \
+ bActiveDrawSh(FALSE), \
+ bActiveDrawTextSh(FALSE), \
+ bActivePivotSh(FALSE), \
+ bActiveAuditingSh(FALSE), \
+ bActiveDrawFormSh(FALSE), \
+ bActiveOleObjectSh(FALSE), \
+ bActiveChartSh(FALSE), \
+ bActiveGraphicSh(FALSE), \
+ bActiveMediaSh(FALSE), \
+ bActiveEditSh(FALSE), \
+ bFormShellAtTop(FALSE), \
+ bDontSwitch(FALSE), \
+ bInFormatDialog(FALSE), \
+ bPrintSelected(FALSE), \
+ bReadOnly(FALSE), \
+ pScSbxObject(NULL), \
+ /*bChartDlgIsEdit(FALSE),*/ \
+ bChartAreaValid(FALSE), \
+ nCurRefDlgId(0), \
+ pAccessibilityBroadcaster(NULL)
+
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::Construct( BYTE nForceDesignMode )
+{
+ SfxApplication* pSfxApp = SFX_APP();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ bReadOnly = pDocSh->IsReadOnly();
+
+ SetName( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("View")) ); // fuer SBX
+ Color aColBlack( COL_BLACK );
+// SetPool( &pSfxApp->GetPool() );
+ SetPool( &SC_MOD()->GetPool() );
+ SetWindow( GetActiveWin() );
+
+ pCurFrameLine = new SvxBorderLine( &aColBlack, 20, 0, 0 );
+ pPivotSource = new ScArea;
+ StartListening(*GetViewData()->GetDocShell(),TRUE);
+ StartListening(*GetViewFrame(),TRUE);
+ StartListening(*pSfxApp,TRUE); // #i62045# #i62046# application is needed for Calc's own hints
+
+ SfxViewFrame* pFirst = SfxViewFrame::GetFirst(pDocSh);
+ BOOL bFirstView = !pFirst
+ || (pFirst == GetViewFrame() && !SfxViewFrame::GetNext(*pFirst,pDocSh));
+
+ if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ //TODO/LATER: is there a difference between the two GetVisArea methods?
+ Rectangle aVisArea = ((const SfxObjectShell*)pDocSh)->GetVisArea();
+
+ SCTAB nVisTab = pDoc->GetVisibleTab();
+ if (!pDoc->HasTable(nVisTab))
+ {
+ nVisTab = 0;
+ pDoc->SetVisibleTab(nVisTab);
+ }
+ SetTabNo( nVisTab );
+ BOOL bNegativePage = pDoc->IsNegativePage( nVisTab );
+ // show the right cells
+ GetViewData()->SetScreenPos( bNegativePage ? aVisArea.TopRight() : aVisArea.TopLeft() );
+
+ if ( GetViewFrame()->GetFrame().IsInPlace() ) // inplace
+ {
+ pDocSh->SetInplace( TRUE ); // schon so initialisiert
+ if (pDoc->IsEmbedded())
+ pDoc->ResetEmbedded(); // keine blaue Markierung
+ }
+ else if ( bFirstView )
+ {
+ pDocSh->SetInplace( FALSE );
+ GetViewData()->RefreshZoom(); // recalculate PPT
+ if (!pDoc->IsEmbedded())
+ pDoc->SetEmbedded( aVisArea ); // VisArea markieren
+ }
+ }
+
+ // ViewInputHandler
+ // #48721# jeder Task hat neuerdings sein eigenes InputWindow,
+ // darum muesste eigentlich entweder jeder Task seinen InputHandler bekommen,
+ // oder das InputWindow muesste sich beim App-InputHandler anmelden, wenn der
+ // Task aktiv wird, oder das InputWindow muesste sich den InputHandler selbst
+ // anlegen (dann immer ueber das InputWindow suchen, und nur wenn das nicht da
+ // ist, den InputHandler von der App nehmen).
+ // Als Sofortloesung bekommt erstmal jede View ihren Inputhandler, das gibt
+ // nur noch Probleme, wenn zwei Views in einem Task-Fenster sind.
+
+ pInputHandler = new ScInputHandler;
+
+ // Alte Version:
+ // if ( !GetViewFrame()->ISA(SfxTopViewFrame) ) // OLE oder Plug-In
+ // pInputHandler = new ScInputHandler;
+
+ // FormShell vor MakeDrawView anlegen, damit die DrawView auf jeden Fall
+ // an der FormShell angemeldet werden kann
+ // Gepusht wird die FormShell im ersten Activate
+ pFormShell = new FmFormShell(this);
+ pFormShell->SetControlActivationHandler( LINK( this, ScTabViewShell, FormControlActivated ) );
+
+ // DrawView darf nicht im TabView - ctor angelegt werden,
+ // wenn die ViewShell noch nicht kostruiert ist...
+ if (pDoc->GetDrawLayer())
+ MakeDrawView( nForceDesignMode );
+ ViewOptionsHasChanged(FALSE); // legt auch evtl. DrawView an
+
+ SfxUndoManager* pMgr = pDocSh->GetUndoManager();
+ SetUndoManager( pMgr );
+ pFormShell->SetUndoManager( pMgr );
+ if ( !pDoc->IsUndoEnabled() )
+ {
+ pMgr->SetMaxUndoActionCount( 0 );
+ }
+ SetRepeatTarget( &aTarget );
+ pFormShell->SetRepeatTarget( &aTarget );
+ SetHelpId( HID_SCSHELL_TABVWSH );
+
+ if ( bFirstView ) // first view?
+ {
+ pDoc->SetDocVisible( TRUE ); // used when creating new sheets
+ if ( pDocSh->IsEmpty() )
+ {
+ // set first sheet's RTL flag (following will already be initialized because of SetDocVisible)
+ pDoc->SetLayoutRTL( 0, ScGlobal::IsSystemRTL() );
+
+ // append additional sheets (not for OLE object)
+ if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
+ {
+ SCTAB nInitTabCount = 3; //! konfigurierbar !!!
+ // Get the customized initial tab count, we only can set the count by VBA API currently.
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ SCTAB nNewTabCount = rAppOpt.GetTabCountInNewSpreadsheet();
+ if ( nNewTabCount >= 1 && nNewTabCount <= MAXTAB )
+ {
+ nInitTabCount = nNewTabCount;
+ }
+ for (SCTAB i=1; i<nInitTabCount; i++)
+ pDoc->MakeTable(i,false);
+ }
+
+ pDocSh->SetEmpty( FALSE ); // #i6232# make sure this is done only once
+ }
+
+ // ReadExtOptions is now in Activate
+
+ // Link-Update nicht verschachteln
+ if ( pDocSh->GetCreateMode() != SFX_CREATE_MODE_INTERNAL &&
+ pDocSh->IsUpdateEnabled() ) // #105575#; update only in the first creation of the ViewShell
+ {
+ // Check if there are any external data.
+ bool bLink = pDoc->GetExternalRefManager()->hasExternalData();
+ if (!bLink)
+ {
+ // #i100042# sheet links can still exist independently from external formula references
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount && !bLink; i++)
+ if (pDoc->IsLinked(i))
+ bLink = true;
+ }
+ if (!bLink)
+ if (pDoc->HasDdeLinks() || pDoc->HasAreaLinks())
+ bLink = TRUE;
+ if (bLink)
+ {
+ if ( !pFirst )
+ pFirst = GetViewFrame();
+
+ if(SC_MOD()->GetCurRefDlgId()==0)
+ {
+ pFirst->GetDispatcher()->Execute( SID_UPDATETABLINKS,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ }
+ }
+
+ BOOL bReImport = FALSE; // importierte Daten aktualisieren
+ ScDBCollection* pDBColl = pDoc->GetDBCollection();
+ if ( pDBColl )
+ {
+ USHORT nCount = pDBColl->GetCount();
+ for (USHORT i=0; i<nCount && !bReImport; i++)
+ {
+ ScDBData* pData = (*pDBColl)[i];
+ if ( pData->IsStripData() &&
+ pData->HasImportParam() && !pData->HasImportSelection() )
+ bReImport = TRUE;
+ }
+ }
+ if (bReImport)
+ {
+ if ( !pFirst )
+ pFirst = GetViewFrame();
+ if(SC_MOD()->GetCurRefDlgId()==0)
+ {
+ pFirst->GetDispatcher()->Execute( SID_REIMPORT_AFTER_LOAD,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ }
+ }
+ }
+ }
+
+ UpdateAutoFillMark();
+
+ // ScDispatchProviderInterceptor registers itself in ctor
+ xDisProvInterceptor = new ScDispatchProviderInterceptor( this );
+
+ bFirstActivate = TRUE; // NavigatorUpdate aufschieben bis Activate()
+
+ // #105575#; update only in the first creation of the ViewShell
+ pDocSh->SetUpdateEnabled(FALSE);
+
+ if ( GetViewFrame()->GetFrame().IsInPlace() )
+ UpdateHeaderWidth(); // The implace activation requires headers to be calculated
+
+ SvBorder aBorder;
+ GetBorderSize( aBorder, Size() );
+ SetBorderPixel( aBorder );
+}
+
+//------------------------------------------------------------------
+
+
+//------------------------------------------------------------------
+
+ScTabViewShell::ScTabViewShell( SfxViewFrame* pViewFrame,
+ SfxViewShell* pOldSh ) :
+ SfxViewShell( pViewFrame, SFX_VIEW_CAN_PRINT | SFX_VIEW_HAS_PRINTOPTIONS ),
+ ScDBFunc( &pViewFrame->GetWindow(), (ScDocShell&)*pViewFrame->GetObjectShell(), this ),
+ __INIT_ScTabViewShell
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "nn93723", "ScTabViewShell::ScTabViewShell" );
+
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+
+ // if switching back from print preview,
+ // restore the view settings that were active when creating the preview
+ // #89897# ReadUserData must not happen from ctor, because the view's edit window
+ // has to be shown by the sfx. ReadUserData is deferred until the first Activate call.
+ // #106334# old DesignMode state from form layer must be restored, too
+
+ BYTE nForceDesignMode = SC_FORCEMODE_NONE;
+ if ( pOldSh && pOldSh->ISA( ScPreviewShell ) )
+ {
+ ScPreviewShell* pPreviewShell = ((ScPreviewShell*)pOldSh);
+ nForceDesignMode = pPreviewShell->GetSourceDesignMode();
+ }
+
+ Construct( nForceDesignMode );
+
+ if ( GetViewData()->GetDocShell()->IsPreview() )
+ {
+ // preview for template dialog: always show whole page
+ SetZoomType( SVX_ZOOM_WHOLEPAGE, TRUE ); // zoom value is recalculated at next Resize
+ }
+ else
+ {
+ Fraction aFract( rAppOpt.GetZoom(), 100 );
+ SetZoom( aFract, aFract, TRUE );
+ SetZoomType( rAppOpt.GetZoomType(), TRUE );
+ }
+
+ /*uno::Reference<frame::XFrame> xFrame = pViewFrame->GetFrame().GetFrameInterface();
+ if (xFrame.is())
+ xFrame->setComponent( uno::Reference<awt::XWindow>(), new ScTabViewObj( this ) );*/
+ // make Controller known to SFX
+ new ScTabViewObj( this );
+
+ SetCurSubShell(OST_Cell);
+ SvBorder aBorder;
+ GetBorderSize( aBorder, Size() );
+ SetBorderPixel( aBorder );
+
+ // #114409#
+ MakeDrawLayer();
+}
+
+#undef __INIT_ScTabViewShell
+
+//------------------------------------------------------------------
+
+__EXPORT ScTabViewShell::~ScTabViewShell()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ EndListening(*pDocSh);
+ EndListening(*GetViewFrame());
+ EndListening(*SFX_APP()); // #i62045# #i62046# needed now - SfxViewShell no longer does it
+
+ SC_MOD()->ViewShellGone(this);
+
+ RemoveSubShell(); // alle
+ SetWindow(0);
+
+ // #54104# alles auf NULL, falls aus dem TabView-dtor noch darauf zugegriffen wird
+ //! (soll eigentlich nicht !??!?!)
+
+ DELETEZ(pFontworkBarShell);
+ DELETEZ(pExtrusionBarShell);
+ DELETEZ(pCellShell);
+ DELETEZ(pPageBreakShell);
+ DELETEZ(pDrawShell);
+ DELETEZ(pDrawFormShell);
+ DELETEZ(pOleObjectShell);
+ DELETEZ(pChartShell);
+ DELETEZ(pGraphicShell);
+ DELETEZ(pMediaShell);
+ DELETEZ(pDrawTextShell);
+ DELETEZ(pEditShell);
+ DELETEZ(pPivotShell);
+ DELETEZ(pAuditingShell);
+ DELETEZ(pCurFrameLine);
+ DELETEZ(pInputHandler);
+ DELETEZ(pPivotSource);
+ DELETEZ(pDialogDPObject);
+ DELETEZ(pNavSettings);
+
+ DELETEZ(pFormShell);
+ DELETEZ(pAccessibilityBroadcaster);
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::SetDialogDPObject( const ScDPObject* pObj )
+{
+ delete pDialogDPObject;
+ if (pObj)
+ pDialogDPObject = new ScDPObject( *pObj );
+ else
+ pDialogDPObject = NULL;
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::FillFieldData( ScHeaderFieldData& rData )
+{
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocShell->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ pDoc->GetName( nTab, rData.aTabName );
+
+ rData.aTitle = pDocShell->GetTitle();
+ const INetURLObject& rURLObj = pDocShell->GetMedium()->GetURLObject();
+ rData.aLongDocName = rURLObj.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+ if ( rData.aLongDocName.Len() )
+ rData.aShortDocName = rURLObj.GetName( INetURLObject::DECODE_UNAMBIGUOUS );
+ else
+ rData.aShortDocName = rData.aLongDocName = rData.aTitle;
+ rData.nPageNo = 1;
+ rData.nTotalPages = 99;
+
+ // eNumType kennt der Dialog selber
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::SetChartArea( const ScRangeListRef& rSource, const Rectangle& rDest )
+{
+ bChartAreaValid = TRUE;
+ aChartSource = rSource;
+ aChartPos = rDest;
+ nChartDestTab = GetViewData()->GetTabNo();
+}
+
+BOOL ScTabViewShell::GetChartArea( ScRangeListRef& rSource, Rectangle& rDest, SCTAB& rTab ) const
+{
+ rSource = aChartSource;
+ rDest = aChartPos;
+ rTab = nChartDestTab;
+ return bChartAreaValid;
+}
+
+ScNavigatorSettings* ScTabViewShell::GetNavigatorSettings()
+{
+ if( !pNavSettings )
+ pNavSettings = new ScNavigatorSettings;
+ return pNavSettings;
+}
+
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecTbx( SfxRequest& rReq )
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ const SfxPoolItem* pItem = NULL;
+ if ( pReqArgs )
+ pReqArgs->GetItemState( nSlot, TRUE, &pItem );
+
+ switch ( nSlot )
+ {
+ case SID_TBXCTL_INSERT:
+ if ( pItem )
+ nInsertCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
+ break;
+ case SID_TBXCTL_INSCELLS:
+ if ( pItem )
+ nInsCellsCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
+ break;
+ case SID_TBXCTL_INSOBJ:
+ if ( pItem )
+ nInsObjCtrlState = ((const SfxUInt16Item*)pItem)->GetValue();
+ break;
+ default:
+ DBG_ERROR("Slot im Wald");
+ }
+ GetViewFrame()->GetBindings().Invalidate( nSlot );
+}
+
+void ScTabViewShell::GetTbxState( SfxItemSet& rSet )
+{
+ rSet.Put( SfxUInt16Item( SID_TBXCTL_INSERT, nInsertCtrlState ) );
+ rSet.Put( SfxUInt16Item( SID_TBXCTL_INSCELLS, nInsCellsCtrlState ) );
+
+ // ohne installiertes Chart darf Chart nicht Default sein...
+ if ( nInsObjCtrlState == SID_DRAW_CHART && !SvtModuleOptions().IsChart() )
+ nInsObjCtrlState = SID_INSERT_OBJECT;
+
+ rSet.Put( SfxUInt16Item( SID_TBXCTL_INSOBJ, nInsObjCtrlState ) );
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx
new file mode 100644
index 000000000000..920a6e3ee18b
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh5.cxx
@@ -0,0 +1,430 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#define _ZFORLIST_DECLARE_TABLE
+#include "scitems.hxx"
+#include <svl/smplhint.hxx>
+#include <svl/zforlist.hxx>
+#include <svx/numfmtsh.hxx>
+#include <svx/numinf.hxx>
+#include <svx/svxids.hrc>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "global.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "uiitems.hxx"
+#include "editsh.hxx"
+#include "hints.hxx"
+
+
+//==================================================================
+
+void __EXPORT ScTabViewShell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if (rHint.ISA(SfxSimpleHint)) // ohne Parameter
+ {
+ ULONG nSlot = ((SfxSimpleHint&)rHint).GetId();
+ switch ( nSlot )
+ {
+ case FID_DATACHANGED:
+ UpdateFormulas();
+ break;
+
+ case FID_REFMODECHANGED:
+ {
+ BOOL bRefMode = SC_MOD()->IsFormulaMode();
+ if (!bRefMode)
+ StopRefMode();
+ else
+ {
+ GetSelEngine()->Reset();
+ GetFunctionSet()->SetAnchorFlag(TRUE);
+ // AnchorFlag, damit gleich mit Control angehaengt werden kann
+ }
+ }
+ break;
+
+ case FID_KILLEDITVIEW:
+ case FID_KILLEDITVIEW_NOPAINT:
+ StopEditShell();
+ KillEditView( nSlot == FID_KILLEDITVIEW_NOPAINT );
+ break;
+
+ case SFX_HINT_DOCCHANGED:
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if (!pDoc->HasTable( GetViewData()->GetTabNo() ))
+ {
+ SetTabNo(0);
+ }
+ }
+ break;
+
+ case SC_HINT_DRWLAYER_NEW:
+ MakeDrawView();
+ break;
+
+ case SC_HINT_DOC_SAVED:
+ {
+ // beim "Save as" kann ein vorher schreibgeschuetztes Dokument
+ // bearbeitbar werden, deshalb die Layer-Locks neu (#39884#)
+ // (Invalidate etc. passiert schon vom Sfx her)
+ // #42091# bei SID_EDITDOC kommt kein SFX_HINT_TITLECHANGED, darum
+ // der eigene Hint aus DoSaveCompleted
+ //! was ist mit SFX_HINT_SAVECOMPLETED ?
+
+ UpdateLayerLocks();
+
+ // #54891# Design-Modus bei jedem Speichern anzupassen, waere zuviel
+ // (beim Speichern unter gleichem Namen soll er unveraendert bleiben)
+ // Darum nur bei SFX_HINT_MODECHANGED (vom ViewFrame)
+ }
+ break;
+
+ case SFX_HINT_MODECHANGED:
+ // #54891#/#58510# Da man sich nicht mehr darauf verlassen kann, woher
+ // dieser Hint kommt, den Design-Modus immer dann umschalten, wenn der
+ // ReadOnly-Status sich wirklich geaendert hat:
+
+ if ( GetViewData()->GetSfxDocShell()->IsReadOnly() != bReadOnly )
+ {
+ bReadOnly = GetViewData()->GetSfxDocShell()->IsReadOnly();
+
+ SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadOnly);
+ GetViewData()->GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON,
+ &aItem, 0L );
+
+ UpdateInputContext();
+ }
+ break;
+
+ case SC_HINT_SHOWRANGEFINDER:
+ PaintRangeFinder();
+ break;
+
+ case SC_HINT_FORCESETTAB:
+ SetTabNo( GetViewData()->GetTabNo(), TRUE );
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (rHint.ISA(ScPaintHint)) // neu zeichnen
+ {
+ ScPaintHint* pHint = (ScPaintHint*) &rHint;
+ USHORT nParts = pHint->GetParts();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ if (pHint->GetStartTab() <= nTab && pHint->GetEndTab() >= nTab)
+ {
+ if (nParts & PAINT_EXTRAS) // zuerst, falls Tabelle weg ist !!!
+ if (PaintExtras())
+ nParts = PAINT_ALL;
+
+ // if the current sheet has pending row height updates (sheet links refreshed),
+ // execute them before invalidating the window
+ GetViewData()->GetDocShell()->UpdatePendingRowHeights( GetViewData()->GetTabNo() );
+
+ if (nParts & PAINT_SIZE)
+ RepeatResize(); //! InvalidateBorder ???
+ if (nParts & PAINT_GRID)
+ PaintArea( pHint->GetStartCol(), pHint->GetStartRow(),
+ pHint->GetEndCol(), pHint->GetEndRow() );
+ if (nParts & PAINT_MARKS)
+ PaintArea( pHint->GetStartCol(), pHint->GetStartRow(),
+ pHint->GetEndCol(), pHint->GetEndRow(), SC_UPDATE_MARKS );
+ if (nParts & PAINT_LEFT)
+ PaintLeftArea( pHint->GetStartRow(), pHint->GetEndRow() );
+ if (nParts & PAINT_TOP)
+ PaintTopArea( pHint->GetStartCol(), pHint->GetEndCol() );
+ if (nParts & PAINT_INVERT)
+ InvertBlockMark( pHint->GetStartCol(), pHint->GetStartRow(),
+ pHint->GetEndCol(), pHint->GetEndRow() );
+
+ // #i84689# call UpdateAllOverlays here instead of in ScTabView::PaintArea
+ if (nParts & ( PAINT_LEFT | PAINT_TOP )) // only if widths or heights changed
+ UpdateAllOverlays();
+
+ HideNoteMarker();
+ }
+ }
+ else if (rHint.ISA(ScEditViewHint)) // Edit-View anlegen
+ {
+ // ScEditViewHint kommt nur an aktiver View an
+
+ ScEditViewHint* pHint = (ScEditViewHint*) &rHint;
+ SCTAB nTab = GetViewData()->GetTabNo();
+ if ( pHint->GetTab() == nTab )
+ {
+ SCCOL nCol = pHint->GetCol();
+ SCROW nRow = pHint->GetRow();
+ {
+ HideNoteMarker();
+
+ MakeEditView( pHint->GetEngine(), nCol, nRow );
+
+ StopEditShell(); // sollte nicht gesetzt sein
+
+ ScSplitPos eActive = GetViewData()->GetActivePart();
+ if ( GetViewData()->HasEditView(eActive) )
+ {
+ // MakeEditView geht schief, wenn der Cursor ausserhalb des
+ // Bildschirms steht. GetEditView gibt dann eine nicht aktive
+ // View zurueck, darum die Abfrage HasEditView.
+
+ EditView* pView = GetViewData()->GetEditView(eActive); // ist nicht 0
+
+ SetEditShell(pView ,TRUE);
+ }
+ }
+ }
+ }
+ else if (rHint.ISA(ScTablesHint)) // Tabelle eingefuegt / geloescht
+ {
+ // aktuelle Tabelle zuerst holen (kann bei DeleteTab an ViewData geaendert werden)
+ SCTAB nActiveTab = GetViewData()->GetTabNo();
+
+ const ScTablesHint& rTabHint = (const ScTablesHint&)rHint;
+ SCTAB nTab1 = rTabHint.GetTab1();
+ SCTAB nTab2 = rTabHint.GetTab2();
+ USHORT nId = rTabHint.GetId();
+ switch (nId)
+ {
+ case SC_TAB_INSERTED:
+ GetViewData()->InsertTab( nTab1 );
+ break;
+ case SC_TAB_DELETED:
+ GetViewData()->DeleteTab( nTab1 );
+ break;
+ case SC_TAB_MOVED:
+ GetViewData()->MoveTab( nTab1, nTab2 );
+ break;
+ case SC_TAB_COPIED:
+ GetViewData()->CopyTab( nTab1, nTab2 );
+ break;
+ case SC_TAB_HIDDEN:
+ break;
+ default:
+ DBG_ERROR("unbekannter ScTablesHint");
+ }
+
+ // hier keine Abfrage auf IsActive() mehr, weil die Aktion von Basic ausgehen
+ // kann und dann auch die aktive View umgeschaltet werden muss.
+
+ SCTAB nNewTab = nActiveTab;
+ BOOL bForce = FALSE;
+ switch (nId)
+ {
+ case SC_TAB_INSERTED:
+ if ( nTab1 <= nNewTab ) // vorher eingefuegt
+ ++nNewTab;
+ break;
+ case SC_TAB_DELETED:
+ if ( nTab1 < nNewTab ) // vorher geloescht
+ --nNewTab;
+ else if ( nTab1 == nNewTab ) // aktuelle geloescht
+ bForce = TRUE;
+ break;
+ case SC_TAB_MOVED:
+ if ( nNewTab == nTab1 ) // verschobene Tabelle
+ nNewTab = nTab2;
+ else if ( nTab1 < nTab2 ) // nach hinten verschoben
+ {
+ if ( nNewTab > nTab1 && nNewTab <= nTab2 ) // nachrueckender Bereich
+ --nNewTab;
+ }
+ else // nach vorne verschoben
+ {
+ if ( nNewTab >= nTab2 && nNewTab < nTab1 ) // nachrueckender Bereich
+ ++nNewTab;
+ }
+ break;
+ case SC_TAB_COPIED:
+ if ( nNewTab >= nTab2 ) // vorher eingefuegt
+ ++nNewTab;
+ break;
+ case SC_TAB_HIDDEN:
+ if ( nTab1 == nNewTab ) // aktuelle ausgeblendet
+ bForce = TRUE;
+ break;
+ }
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( nNewTab >= pDoc->GetTableCount() )
+ nNewTab = pDoc->GetTableCount() - 1;
+
+ SetTabNo( nNewTab, bForce );
+ }
+ else if (rHint.ISA(ScIndexHint))
+ {
+ const ScIndexHint& rIndexHint = (const ScIndexHint&)rHint;
+ USHORT nId = rIndexHint.GetId();
+ USHORT nIndex = rIndexHint.GetIndex();
+ switch (nId)
+ {
+ case SC_HINT_SHOWRANGEFINDER:
+ PaintRangeFinder( nIndex );
+ break;
+ }
+ }
+
+ SfxViewShell::Notify( rBC, rHint );
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc,
+ ScViewData* pViewData,
+ SvxNumberInfoItem** ppItem )
+{
+ //------------------------------
+ // NumberInfo-Item konstruieren:
+ //------------------------------
+ ScBaseCell* pCell = NULL;
+ SvxNumberValueType eValType = SVX_VALUE_TYPE_UNDEFINED;
+ double nCellValue = 0;
+ String aCellString;
+
+ pDoc->GetCell( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo(),
+ pCell );
+
+ if ( pCell )
+ {
+ switch ( pCell->GetCellType() )
+ {
+ case CELLTYPE_VALUE:
+ {
+ nCellValue = ((ScValueCell*)pCell)->GetValue();
+ eValType = SVX_VALUE_TYPE_NUMBER;
+ aCellString.Erase();
+ }
+ break;
+
+ case CELLTYPE_STRING:
+ {
+ ((ScStringCell*)pCell)->GetString( aCellString );
+ eValType = SVX_VALUE_TYPE_STRING;
+ }
+ break;
+
+ case CELLTYPE_FORMULA:
+ {
+ if ( ((ScFormulaCell*)pCell)->IsValue() )
+ {
+ nCellValue = ((ScFormulaCell*)pCell)->GetValue();
+ eValType = SVX_VALUE_TYPE_NUMBER;
+ }
+ else
+ {
+ nCellValue = 0;
+ eValType = SVX_VALUE_TYPE_UNDEFINED;
+ }
+ aCellString.Erase();
+ }
+ break;
+
+ default:
+ nCellValue = 0;
+ eValType = SVX_VALUE_TYPE_UNDEFINED;
+ aCellString.Erase();
+ }
+ }
+ else // Zelle noch leer (== nicht erzeugt)
+ {
+ nCellValue = 0;
+ eValType = SVX_VALUE_TYPE_UNDEFINED;
+ aCellString.Erase();
+ }
+
+ switch ( eValType )
+ {
+ case SVX_VALUE_TYPE_STRING:
+ *ppItem = new SvxNumberInfoItem(
+ pDoc->GetFormatTable(),
+ aCellString,
+ SID_ATTR_NUMBERFORMAT_INFO );
+ break;
+
+ case SVX_VALUE_TYPE_NUMBER:
+ *ppItem = new SvxNumberInfoItem(
+ pDoc->GetFormatTable(),
+ nCellValue,
+ SID_ATTR_NUMBERFORMAT_INFO );
+ break;
+
+ case SVX_VALUE_TYPE_UNDEFINED:
+ default:
+ *ppItem = new SvxNumberInfoItem(
+ pDoc->GetFormatTable(),
+ (const USHORT)
+ SID_ATTR_NUMBERFORMAT_INFO );
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::UpdateNumberFormatter(
+ ScDocument* pDoc,
+ const SvxNumberInfoItem& rInfoItem )
+{
+ const sal_uInt32 nDelCount = rInfoItem.GetDelCount();
+
+ if ( nDelCount > 0 )
+ {
+ const sal_uInt32* pDelArr = rInfoItem.GetDelArray();
+
+ for ( USHORT i=0; i<nDelCount; i++ )
+ rInfoItem.GetNumberFormatter()->DeleteEntry( pDelArr[i] );
+ }
+
+ // sollte besser UpdateNumberFormats() heissen ?
+ pDoc->DeleteNumberFormat( rInfoItem.GetDelArray(),
+ rInfoItem.GetDelCount() );
+}
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh8.cxx b/sc/source/ui/view/tabvwsh8.cxx
new file mode 100644
index 000000000000..9ab882efbdba
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh8.cxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/boxitem.hxx>
+
+#include "tabvwsh.hxx"
+#include "document.hxx"
+
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::SetDefaultFrameLine( const SvxBorderLine* pLine )
+{
+ if ( pLine )
+ {
+ delete pCurFrameLine;
+ pCurFrameLine = new SvxBorderLine( &pLine->GetColor(),
+ pLine->GetOutWidth(),
+ pLine->GetInWidth(),
+ pLine->GetDistance() );
+ }
+ else if ( pCurFrameLine )
+ {
+ delete pCurFrameLine;
+ pCurFrameLine = NULL;
+ }
+}
+
+//------------------------------------------------------------------
+
+BOOL __EXPORT ScTabViewShell::HasSelection( BOOL bText ) const
+{
+ BOOL bHas = FALSE;
+ ScViewData* pData = (ScViewData*)GetViewData(); // const weggecasted
+ if ( bText )
+ {
+ // Text enthalten: Anzahl2 >= 1
+ ScDocument* pDoc = pData->GetDocument();
+ ScMarkData& rMark = pData->GetMarkData();
+ ScAddress aCursor( pData->GetCurX(), pData->GetCurY(), pData->GetTabNo() );
+ double fVal = 0.0;
+ if ( pDoc->GetSelectionFunction( SUBTOTAL_FUNC_CNT2, aCursor, rMark, fVal ) )
+ bHas = ( fVal > 0.5 );
+ }
+ else
+ {
+ ScRange aRange;
+ ScMarkType eMarkType = pData->GetSimpleArea( aRange );
+ if ( eMarkType == SC_MARK_SIMPLE )
+ bHas = ( aRange.aStart != aRange.aEnd ); // more than 1 cell
+ else
+ bHas = TRUE; // multiple selection or filtered
+ }
+ return bHas;
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::UIDeactivated( SfxInPlaceClient* pClient )
+{
+ ClearHighlightRanges();
+
+ // Move an der ViewShell soll eigentlich vom Sfx gerufen werden, wenn sich
+ // das Frame-Window wegen unterschiedlicher Toolboxen o.ae. verschiebt
+ // (um nicht aus Versehen z.B. Zeichenobjekte zu verschieben, #56515#).
+ // Dieser Mechanismus funktioniert aber momentan nicht, darum hier der Aufruf
+ // per Hand (im Move wird verglichen, ob die Position wirklich geaendert ist).
+ ForceMove();
+ SfxViewShell::UIDeactivated( pClient );
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsh9.cxx b/sc/source/ui/view/tabvwsh9.cxx
new file mode 100644
index 000000000000..e320c5604f99
--- /dev/null
+++ b/sc/source/ui/view/tabvwsh9.cxx
@@ -0,0 +1,297 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdmark.hxx>
+#include <svx/svdview.hxx>
+#include <svx/galbrws.hxx>
+#include <svx/gallery.hxx>
+#include <svx/hlnkitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svl/whiter.hxx>
+#include <avmedia/mediaplayer.hxx>
+
+#include "tabvwsh.hxx"
+#include "viewdata.hxx"
+#include "tabview.hxx"
+#include "drwlayer.hxx"
+#include "userdat.hxx"
+#include "docsh.hxx"
+
+// forwards -> galwrap.cxx (wg. CLOOKs)
+
+USHORT GallerySGA_FORMAT_GRAPHIC();
+Graphic GalleryGetGraphic ();
+BOOL GalleryIsLinkage ();
+String GalleryGetFullPath ();
+String GalleryGetFilterName ();
+
+// forwards -> imapwrap.cxx (wg. CLOOKs)
+
+class SvxIMapDlg;
+
+USHORT ScIMapChildWindowId();
+SvxIMapDlg* ScGetIMapDlg();
+const void* ScIMapDlgGetObj( SvxIMapDlg* pDlg );
+const ImageMap& ScIMapDlgGetMap( SvxIMapDlg* pDlg );
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecChildWin(SfxRequest& rReq)
+{
+ USHORT nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case SID_GALLERY:
+ {
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ pThisFrame->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
+ pThisFrame->GetBindings().Invalidate( SID_GALLERY );
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_AVMEDIA_PLAYER:
+ {
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ pThisFrame->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() );
+ pThisFrame->GetBindings().Invalidate( SID_AVMEDIA_PLAYER );
+ rReq.Ignore();
+ }
+ break;
+ }
+}
+
+void ScTabViewShell::GetChildWinState( SfxItemSet& rSet )
+{
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
+ {
+ USHORT nId = GalleryChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
+ {
+ USHORT nId = ::avmedia::MediaPlayer::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecGallery( SfxRequest& rReq )
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if ( pArgs )
+ {
+ const SfxPoolItem* pItem = NULL;
+ SfxItemState eState = pArgs->GetItemState(SID_GALLERY_FORMATS, TRUE, &pItem);
+ if ( eState == SFX_ITEM_SET )
+ {
+ UINT32 nFormats = ((const SfxUInt32Item*)pItem)->GetValue();
+
+ /******************************************************************
+ * Graphik einfuegen
+ ******************************************************************/
+ if ( nFormats & GallerySGA_FORMAT_GRAPHIC() )
+ {
+ MakeDrawLayer();
+
+ Graphic aGraphic = GalleryGetGraphic();
+ Point aPos = GetInsertPos();
+
+ String aPath, aFilter;
+ if ( GalleryIsLinkage() ) // als Link einfuegen?
+ {
+ aPath = GalleryGetFullPath();
+ aFilter = GalleryGetFilterName();
+ }
+
+ PasteGraphic( aPos, aGraphic, aPath, aFilter );
+ }
+ else if ( nFormats & SGA_FORMAT_SOUND )
+ {
+ // #98115# for sounds (linked or not), insert a hyperlink button,
+ // like in Impress and Writer
+
+ GalleryExplorer* pGal = SVX_GALLERY();
+ if ( pGal )
+ {
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
+ GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
+ }
+ }
+ }
+ }
+}
+
+void ScTabViewShell::GetGalleryState( SfxItemSet& /* rSet */ )
+{
+}
+
+//------------------------------------------------------------------
+
+ScInputHandler* ScTabViewShell::GetInputHandler() const
+{
+ return pInputHandler;
+}
+
+//------------------------------------------------------------------
+
+String __EXPORT ScTabViewShell::GetDescription() const
+{
+ return String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(" ** Test ** "));
+}
+
+void ScTabViewShell::ExecImageMap( SfxRequest& rReq )
+{
+ USHORT nSlot = rReq.GetSlot();
+ switch(nSlot)
+ {
+ case SID_IMAP:
+ {
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ USHORT nId = ScIMapChildWindowId();
+ pThisFrame->ToggleChildWindow( nId );
+ GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
+
+ if ( pThisFrame->HasChildWindow( nId ) )
+ {
+ SvxIMapDlg* pDlg = ScGetIMapDlg();
+ if ( pDlg )
+ {
+ SdrView* pDrView = GetSdrView();
+ if ( pDrView )
+ {
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ if ( rMarkList.GetMarkCount() == 1 )
+ UpdateIMap( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
+ }
+ }
+ }
+
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_IMAP_EXEC:
+ {
+ SdrView* pDrView = GetSdrView();
+ SdrMark* pMark = pDrView ? pDrView->GetMarkedObjectList().GetMark(0) : 0;
+
+ if ( pMark )
+ {
+ SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
+ SvxIMapDlg* pDlg = ScGetIMapDlg();
+
+ if ( ScIMapDlgGetObj(pDlg) == (void*) pSdrObj )
+ {
+ const ImageMap& rImageMap = ScIMapDlgGetMap(pDlg);
+ ScIMapInfo* pIMapInfo = ScDrawLayer::GetIMapInfo( pSdrObj );
+
+ if ( !pIMapInfo )
+ pSdrObj->InsertUserData( new ScIMapInfo( rImageMap ) );
+ else
+ pIMapInfo->SetImageMap( rImageMap );
+
+ GetViewData()->GetDocShell()->SetDrawModified();
+ }
+ }
+ }
+ break;
+ }
+}
+
+void ScTabViewShell::GetImageMapState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_IMAP:
+ {
+ // Disabled wird nicht mehr...
+
+ BOOL bThere = FALSE;
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ USHORT nId = ScIMapChildWindowId();
+ if ( pThisFrame->KnowsChildWindow(nId) )
+ if ( pThisFrame->HasChildWindow(nId) )
+ bThere = TRUE;
+
+ ObjectSelectionType eType=GetCurObjectSelectionType();
+ BOOL bEnable=(eType==OST_OleObject) ||(eType==OST_Graphic);
+ if(!bThere && !bEnable)
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ rSet.Put( SfxBoolItem( nWhich, bThere ) );
+ }
+ }
+ break;
+
+ case SID_IMAP_EXEC:
+ {
+ BOOL bDisable = TRUE;
+
+ SdrView* pDrView = GetSdrView();
+ if ( pDrView )
+ {
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ if ( rMarkList.GetMarkCount() == 1 )
+ if ( ScIMapDlgGetObj(ScGetIMapDlg()) ==
+ (void*) rMarkList.GetMark(0)->GetMarkedSdrObj() )
+ bDisable = FALSE;
+ }
+
+ rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
+ }
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx
new file mode 100644
index 000000000000..0cdce33d3213
--- /dev/null
+++ b/sc/source/ui/view/tabvwsha.cxx
@@ -0,0 +1,894 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#define _ZFORLIST_DECLARE_TABLE
+#include "scitems.hxx"
+#include <svl/slstitm.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <svl/zformat.hxx>
+#include <editeng/boxitem.hxx>
+#include <svx/numinf.hxx>
+#include <svl/srchitem.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "global.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "document.hxx"
+#include "cell.hxx" // Input Status Edit-Zellen
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "docsh.hxx"
+#include "viewdata.hxx"
+#include "appoptio.hxx"
+#include "sc.hrc"
+#include "stlpool.hxx"
+#include "tabvwsh.hxx"
+#include "dwfunctr.hxx"
+#include "scabstdlg.hxx"
+#include "compiler.hxx"
+
+
+BOOL ScTabViewShell::GetFunction( String& rFuncStr, sal_uInt16 nErrCode )
+{
+ String aStr;
+
+ ScSubTotalFunc eFunc = (ScSubTotalFunc) SC_MOD()->GetAppOptions().GetStatusFunc();
+ ScViewData* pViewData = GetViewData();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ bool bIgnoreError = (rMark.IsMarked() || rMark.IsMultiMarked());
+
+ if (bIgnoreError && (eFunc == SUBTOTAL_FUNC_CNT || eFunc == SUBTOTAL_FUNC_CNT2))
+ nErrCode = 0;
+
+ if (nErrCode)
+ {
+ rFuncStr = ScGlobal::GetLongErrorString(nErrCode);
+ return true;
+ }
+
+ USHORT nGlobStrId = 0;
+ switch (eFunc)
+ {
+ case SUBTOTAL_FUNC_AVE: nGlobStrId = STR_FUN_TEXT_AVG; break;
+ case SUBTOTAL_FUNC_CNT: nGlobStrId = STR_FUN_TEXT_COUNT; break;
+ case SUBTOTAL_FUNC_CNT2: nGlobStrId = STR_FUN_TEXT_COUNT2; break;
+ case SUBTOTAL_FUNC_MAX: nGlobStrId = STR_FUN_TEXT_MAX; break;
+ case SUBTOTAL_FUNC_MIN: nGlobStrId = STR_FUN_TEXT_MIN; break;
+ case SUBTOTAL_FUNC_SUM: nGlobStrId = STR_FUN_TEXT_SUM; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ if (nGlobStrId)
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCCOL nPosX = pViewData->GetCurX();
+ SCROW nPosY = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ aStr = ScGlobal::GetRscString(nGlobStrId);
+ aStr += '=';
+
+ ScAddress aCursor( nPosX, nPosY, nTab );
+ double nVal;
+ if ( pDoc->GetSelectionFunction( eFunc, aCursor, rMark, nVal ) )
+ {
+ if ( nVal == 0.0 )
+ aStr += '0';
+ else
+ {
+ // Anzahl im Standardformat, die anderen nach Cursorposition
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nNumFmt = 0;
+ if ( eFunc != SUBTOTAL_FUNC_CNT && eFunc != SUBTOTAL_FUNC_CNT2 )
+ {
+ // Zahlformat aus Attributen oder Formel
+ pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
+ if ( (nNumFmt % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ {
+ ScBaseCell* pCell;
+ pDoc->GetCell( nPosX, nPosY, nTab, pCell );
+ if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+
+ nNumFmt = ((ScFormulaCell*)pCell)->GetStandardFormat(*pFormatter, nNumFmt );
+ }
+ }
+ }
+
+ String aValStr;
+ Color* pDummy;
+ pFormatter->GetOutputString( nVal, nNumFmt, aValStr, &pDummy );
+ aStr += aValStr;
+ }
+ }
+
+ rFuncStr = aStr;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+
+// Funktionen, die je nach Selektion disabled sind
+// Default:
+// SID_DELETE,
+// SID_DELETE_CONTENTS,
+// FID_DELETE_CELL
+// FID_VALIDATION
+
+
+void __EXPORT ScTabViewShell::GetState( SfxItemSet& rSet )
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCCOL nPosX = pViewData->GetCurX();
+ SCROW nPosY = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ USHORT nMyId = 0;
+
+ SfxViewFrame* pThisFrame = GetViewFrame();
+ BOOL bOle = GetViewFrame()->GetFrame().IsInPlace();
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case FID_CHG_COMMENT:
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScAddress aPos( nPosX, nPosY, nTab );
+ if ( pDocSh->IsReadOnly() || !pDocSh->GetChangeAction(aPos) || pDocSh->IsDocShared() )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_OPENDLG_EDIT_PRINTAREA:
+ case SID_ADD_PRINTAREA:
+ case SID_DEFINE_PRINTAREA:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_DELETE_PRINTAREA:
+ if ( nTabSelCount > 1 )
+ {
+ // #i22589# also take "Print Entire Sheet" into account here
+ BOOL bHas = FALSE;
+ for (SCTAB i=0; !bHas && i<nTabCount; i++)
+ bHas = rMark.GetTableSelect(i) && (pDoc->GetPrintRangeCount(i) || pDoc->IsPrintEntireSheet(i));
+ if (!bHas)
+ rSet.DisableItem( nWhich );
+ }
+ else if ( !pDoc->GetPrintRangeCount( nTab ) && !pDoc->IsPrintEntireSheet( nTab ) )
+ rSet.DisableItem( nWhich );
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_STATUS_PAGESTYLE:
+ case SID_HFEDIT:
+ GetViewData()->GetDocShell()->GetStatePageStyle( *this, rSet, nTab );
+ break;
+
+ case SID_SEARCH_ITEM:
+ {
+ SvxSearchItem aItem(ScGlobal::GetSearchItem()); // make a copy.
+ // Search on current selection if a range is marked.
+ aItem.SetSelection(rMark.IsMarked());
+ rSet.Put(aItem);
+ break;
+ }
+
+ case SID_SEARCH_OPTIONS:
+ {
+ USHORT nOptions = 0xffff; // alles erlaubt
+ // wenn ReadOnly, kein Ersetzen:
+ if (GetViewData()->GetDocShell()->IsReadOnly())
+ nOptions &= ~( SEARCH_OPTIONS_REPLACE | SEARCH_OPTIONS_REPLACE_ALL );
+ rSet.Put( SfxUInt16Item( nWhich, nOptions ) );
+ }
+ break;
+
+ case SID_CURRENTCELL:
+ {
+ ScAddress aScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), 0 );
+ String aAddr;
+ aScAddress.Format( aAddr, SCA_ABS, NULL, pDoc->GetAddressConvention() );
+ SfxStringItem aPosItem( SID_CURRENTCELL, aAddr );
+
+ rSet.Put( aPosItem );
+ }
+ break;
+
+ case SID_CURRENTTAB:
+ // Tabelle fuer Basic ist 1-basiert
+ rSet.Put( SfxUInt16Item( nWhich, static_cast<sal_uInt16>(GetViewData()->GetTabNo()) + 1 ) );
+ break;
+
+ case SID_CURRENTDOC:
+ rSet.Put( SfxStringItem( nWhich, GetViewData()->GetDocShell()->GetTitle() ) );
+ break;
+
+ case FID_TOGGLEINPUTLINE:
+ {
+ USHORT nId = ScInputWindowWrapper::GetChildWindowId();
+
+ if ( pThisFrame->KnowsChildWindow( nId ) )
+ {
+ SfxChildWindow* pWnd = pThisFrame->GetChildWindow( nId );
+ rSet.Put( SfxBoolItem( nWhich, pWnd ? TRUE : FALSE ) );
+ }
+ else
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FID_DEL_MANUALBREAKS:
+ if (!pDoc->HasManualBreaks(nTab))
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_RESET_PRINTZOOM:
+ {
+ // disablen, wenn schon Default eingestellt
+
+ String aStyleName = pDoc->GetPageStyle( nTab );
+ ScStyleSheetPool* pStylePool = pDoc->GetStyleSheetPool();
+ SfxStyleSheetBase* pStyleSheet = pStylePool->Find( aStyleName,
+ SFX_STYLE_FAMILY_PAGE );
+ DBG_ASSERT( pStyleSheet, "PageStyle not found" );
+ if ( pStyleSheet )
+ {
+ SfxItemSet& rStyleSet = pStyleSheet->GetItemSet();
+ USHORT nScale = ((const SfxUInt16Item&)
+ rStyleSet.Get(ATTR_PAGE_SCALE)).GetValue();
+ USHORT nPages = ((const SfxUInt16Item&)
+ rStyleSet.Get(ATTR_PAGE_SCALETOPAGES)).GetValue();
+ if ( nScale == 100 && nPages == 0 )
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FID_SCALE:
+ case SID_ATTR_ZOOM:
+ if ( bOle )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ const Fraction& rOldY = GetViewData()->GetZoomY();
+ USHORT nZoom = (USHORT)(( rOldY.GetNumerator() * 100 )
+ / rOldY.GetDenominator());
+ rSet.Put( SvxZoomItem( SVX_ZOOM_PERCENT, nZoom, nWhich ) );
+ }
+ break;
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ if ( bOle )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ const Fraction& rOldY = GetViewData()->GetZoomY();
+ USHORT nCurrentZoom = (USHORT)(( rOldY.GetNumerator() * 100 ) / rOldY.GetDenominator());
+
+ if( nCurrentZoom )
+ {
+ SvxZoomSliderItem aZoomSliderItem( nCurrentZoom, MINZOOM, MAXZOOM, SID_ATTR_ZOOMSLIDER );
+ aZoomSliderItem.AddSnappingPoint( 100 );
+ rSet.Put( aZoomSliderItem );
+ }
+ }
+ }
+ break;
+
+ case FID_TOGGLESYNTAX:
+ rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsSyntaxMode()));
+ break;
+
+ case FID_TOGGLEHEADERS:
+ rSet.Put(SfxBoolItem(nWhich, GetViewData()->IsHeaderMode()));
+ break;
+
+ case FID_TOGGLEFORMULA:
+ {
+ const ScViewOptions& rOpts = pViewData->GetOptions();
+ BOOL bFormulaMode = rOpts.GetOption( VOPT_FORMULAS );
+ rSet.Put(SfxBoolItem(nWhich, bFormulaMode ));
+ }
+ break;
+
+ case FID_NORMALVIEWMODE:
+ case FID_PAGEBREAKMODE:
+ // always handle both slots - they exclude each other
+ if ( bOle )
+ {
+ rSet.DisableItem( FID_NORMALVIEWMODE );
+ rSet.DisableItem( FID_PAGEBREAKMODE );
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(FID_NORMALVIEWMODE, !GetViewData()->IsPagebreakMode()));
+ rSet.Put(SfxBoolItem(FID_PAGEBREAKMODE, GetViewData()->IsPagebreakMode()));
+ }
+ break;
+
+ case FID_FUNCTION_BOX:
+ nMyId = ScFunctionChildWindow::GetChildWindowId();
+ rSet.Put(SfxBoolItem(FID_FUNCTION_BOX, pThisFrame->HasChildWindow(nMyId)));
+ break;
+
+ case FID_PROTECT_DOC:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ rSet.Put( SfxBoolItem( nWhich, pDoc->IsDocProtected() ) );
+ }
+ }
+ break;
+
+ case FID_PROTECT_TABLE:
+ {
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ else
+ {
+ rSet.Put( SfxBoolItem( nWhich, pDoc->IsTabProtected( nTab ) ) );
+ }
+ }
+ break;
+
+ case SID_AUTO_OUTLINE:
+ {
+ if (pDoc->GetChangeTrack()!=NULL || GetViewData()->IsMultiMarked())
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_OUTLINE_DELETEALL:
+ {
+ SCTAB nOlTab = GetViewData()->GetTabNo();
+ ScOutlineTable* pOlTable = pDoc->GetOutlineTable( nOlTab );
+ if (pOlTable == NULL)
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_WINDOW_SPLIT:
+ rSet.Put(SfxBoolItem(nWhich,
+ pViewData->GetHSplitMode() == SC_SPLIT_NORMAL ||
+ pViewData->GetVSplitMode() == SC_SPLIT_NORMAL ));
+ break;
+
+ case SID_WINDOW_FIX:
+ rSet.Put(SfxBoolItem(nWhich,
+ pViewData->GetHSplitMode() == SC_SPLIT_FIX ||
+ pViewData->GetVSplitMode() == SC_SPLIT_FIX ));
+ break;
+
+ case FID_CHG_SHOW:
+ {
+ if ( pDoc->GetChangeTrack() == NULL || ( pDocShell && pDocShell->IsDocShared() ) )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+ case FID_CHG_ACCEPT:
+ {
+ rSet.Put(SfxBoolItem(FID_CHG_ACCEPT,
+ pThisFrame->HasChildWindow(FID_CHG_ACCEPT)));
+ if(pDoc->GetChangeTrack()==NULL)
+ {
+ if ( !pThisFrame->HasChildWindow(FID_CHG_ACCEPT) )
+ {
+ rSet.DisableItem( nWhich);
+ }
+ }
+ if ( pDocShell && pDocShell->IsDocShared() )
+ {
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_FORMATPAGE:
+ //! bei geschuetzten Tabellen ???
+ if ( pDocShell && ( pDocShell->IsReadOnly() || pDocShell->IsDocShared() ) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_PRINTPREVIEW:
+ // #58924# Toggle-Slot braucht einen State
+ rSet.Put( SfxBoolItem( nWhich, FALSE ) );
+ break;
+
+ case SID_READONLY_MODE:
+ rSet.Put( SfxBoolItem( nWhich, GetViewData()->GetDocShell()->IsReadOnly() ) );
+ break;
+
+ case FID_TAB_DESELECTALL:
+ if ( nTabSelCount == 1 )
+ rSet.DisableItem( nWhich ); // enabled only if several sheets are selected
+ break;
+
+ } // switch ( nWitch )
+ nWhich = aIter.NextWhich();
+ } // while ( nWitch )
+}
+
+//------------------------------------------------------------------
+void ScTabViewShell::ExecuteCellFormatDlg( SfxRequest& rReq, USHORT nTabPage )
+{
+ SfxAbstractTabDialog * pDlg = NULL;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ SvxBoxItem aLineOuter( ATTR_BORDER );
+ SvxBoxInfoItem aLineInner( ATTR_BORDER_INNER );
+
+ SvxNumberInfoItem* pNumberInfoItem = NULL;
+ const ScPatternAttr* pOldAttrs = GetSelectionPattern();
+ SfxItemSet* pOldSet = new SfxItemSet(
+ pOldAttrs->GetItemSet() );
+
+
+ // Umrandungs-Items holen und in den Set packen:
+ GetSelectionFrame( aLineOuter, aLineInner );
+ pOldSet->Put( aLineOuter );
+ pOldSet->Put( aLineInner );
+
+ // NumberFormat Value aus Value und Language erzeugen und eintueten
+ pOldSet->Put( SfxUInt32Item( ATTR_VALUE_FORMAT,
+ pOldAttrs->GetNumberFormat( pDoc->GetFormatTable() ) ) );
+
+ MakeNumberInfoItem( pDoc, GetViewData(), &pNumberInfoItem );
+
+ pOldSet->MergeRange( SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO );
+ pOldSet->Put(*pNumberInfoItem );
+
+ bInFormatDialog = TRUE;
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ pDlg = pFact->CreateScAttrDlg( GetViewFrame(), GetDialogParent(), pOldSet, RID_SCDLG_ATTR);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( nTabPage != 0xffff )
+ pDlg->SetCurPageId( nTabPage );
+ short nResult = pDlg->Execute();
+ bInFormatDialog = FALSE;
+
+ if ( nResult == RET_OK )
+ {
+ const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+
+ const SfxPoolItem* pItem=NULL;
+ if(pOutSet->GetItemState(SID_ATTR_NUMBERFORMAT_INFO,TRUE,&pItem)==SFX_ITEM_SET)
+ {
+
+ UpdateNumberFormatter( pDoc,(const SvxNumberInfoItem&)*pItem);
+ }
+
+ ApplyAttributes( pOutSet, pOldSet );
+
+ rReq.Done( *pOutSet );
+ }
+ delete pOldSet;
+ delete pNumberInfoItem;
+ delete pDlg;
+}
+
+//------------------------------------------------------------------
+
+bool ScTabViewShell::IsRefInputMode() const
+{
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod )
+ {
+ if( pScMod->IsRefDialogOpen() )
+ return pScMod->IsFormulaMode();
+ if( pScMod->IsFormulaMode() )
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl();
+ if ( pHdl )
+ {
+ String aString = pHdl->GetEditString();
+ if ( !pHdl->GetSelIsRef() && aString.Len() > 1 &&
+ ( aString.GetChar(0) == '+' || aString.GetChar(0) == '-' ) )
+ {
+ const ScViewData* pViewData = GetViewData();
+ if ( pViewData )
+ {
+ ScDocument* pDoc = pViewData->GetDocument();
+ if ( pDoc )
+ {
+ const ScAddress aPos( pViewData->GetCurPos() );
+ ScCompiler aComp( pDoc, aPos );
+ aComp.SetGrammar(pDoc->GetGrammar());
+ aComp.SetCloseBrackets( false );
+ ScTokenArray* pArr = aComp.CompileString( aString );
+ if ( pArr && pArr->MayReferenceFollow() )
+ {
+ return true;
+ }
+ }
+ }
+ }
+ else
+ {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecuteInputDirect()
+{
+ if ( !IsRefInputMode() )
+ {
+ ScModule* pScMod = SC_MOD();
+ if ( pScMod )
+ {
+ pScMod->InputEnterHandler();
+ }
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::UpdateInputHandler( BOOL bForce /* = FALSE */, BOOL bStopEditing /* = TRUE */ )
+{
+ ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl();
+
+ if ( pHdl )
+ {
+ String aString;
+ const EditTextObject* pObject = NULL;
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ CellType eType;
+ SCCOL nPosX = pViewData->GetCurX();
+ SCROW nPosY = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ SCTAB nStartTab = 0;
+ SCTAB nEndTab = 0;
+ SCCOL nStartCol = 0;
+ SCROW nStartRow = 0;
+ SCCOL nEndCol = 0;
+ SCROW nEndRow = 0;
+
+ pViewData->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ PutInOrder( nStartCol, nEndCol );
+ PutInOrder( nStartRow, nEndRow );
+ PutInOrder( nStartTab, nEndTab );
+
+ BOOL bHideFormula = FALSE;
+ BOOL bHideAll = FALSE;
+
+ if (pDoc->IsTabProtected(nTab))
+ {
+ const ScProtectionAttr* pProt = (const ScProtectionAttr*)
+ pDoc->GetAttr( nPosX,nPosY,nTab,
+ ATTR_PROTECTION);
+ bHideFormula = pProt->GetHideFormula();
+ bHideAll = pProt->GetHideCell();
+ }
+
+ if (!bHideAll)
+ {
+ pDoc->GetCellType( nPosX, nPosY, nTab, eType );
+ if (eType == CELLTYPE_FORMULA)
+ {
+ if (!bHideFormula)
+ pDoc->GetFormula( nPosX, nPosY, nTab, aString );
+ }
+ else if (eType == CELLTYPE_EDIT)
+ {
+ ScBaseCell* pCell;
+ pDoc->GetCell( nPosX, nPosY, nTab, pCell );
+ ((ScEditCell*)pCell)->GetData( pObject );
+ }
+ else
+ {
+ pDoc->GetInputString( nPosX, nPosY, nTab, aString );
+ if (eType == CELLTYPE_STRING)
+ {
+ // Bei Bedarf ein ' vorneweg, damit der String nicht ungewollt
+ // als Zahl interpretiert wird, und um dem Benutzer zu zeigen,
+ // dass es ein String ist (#35060#).
+ //! Auch bei Zahlformat "Text"? -> dann beim Editieren wegnehmen
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ sal_uInt32 nNumFmt;
+ pDoc->GetNumberFormat( nPosX, nPosY, nTab, nNumFmt );
+ double fDummy;
+ if ( pFormatter->IsNumberFormat(aString, nNumFmt, fDummy) )
+ aString.Insert('\'',0);
+ }
+ }
+ }
+
+ ScInputHdlState aState( ScAddress( nPosX, nPosY, nTab ),
+ ScAddress( nStartCol, nStartRow, nTab ),
+ ScAddress( nEndCol, nEndRow, nTab ),
+ aString,
+ pObject );
+
+ // if using the view's local input handler, this view can always be set
+ // as current view inside NotifyChange.
+ ScTabViewShell* pSourceSh = pInputHandler ? this : NULL;
+
+ pHdl->NotifyChange( &aState, bForce, pSourceSh, bStopEditing );
+ }
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_STATUS_SUM ); // immer zusammen mit Eingabezeile
+ rBindings.Invalidate( SID_ATTR_SIZE );
+ rBindings.Invalidate( SID_TABLE_CELL );
+}
+
+void ScTabViewShell::UpdateInputHandlerCellAdjust( SvxCellHorJustify eJust )
+{
+ if( ScInputHandler* pHdl = pInputHandler ? pInputHandler : SC_MOD()->GetInputHdl() )
+ pHdl->UpdateCellAdjust( eJust );
+}
+
+//------------------------------------------------------------------
+
+void __EXPORT ScTabViewShell::ExecuteSave( SfxRequest& rReq )
+{
+ // nur SID_SAVEDOC / SID_SAVEASDOC
+
+ // Eingabe auf jeden Fall abschliessen, auch wenn eine Formel bearbeitet wird
+ SC_MOD()->InputEnterHandler();
+
+ if ( GetViewData()->GetDocShell()->IsDocShared() )
+ {
+ GetViewData()->GetDocShell()->SetDocumentModified();
+ }
+
+ // ansonsten normal weiter
+ GetViewData()->GetDocShell()->ExecuteSlot( rReq );
+}
+
+void __EXPORT ScTabViewShell::GetSaveState( SfxItemSet& rSet )
+{
+ SfxShell* pDocSh = GetViewData()->GetDocShell();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while( nWhich )
+ {
+ if ( nWhich != SID_SAVEDOC || !GetViewData()->GetDocShell()->IsDocShared() )
+ {
+ // get state from DocShell
+ pDocSh->GetSlotState( nWhich, NULL, &rSet );
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecuteUndo(SfxRequest& rReq)
+{
+ SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
+ SfxUndoManager* pUndoManager = pSh->GetUndoManager();
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+
+ USHORT nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_UNDO:
+ case SID_REDO:
+ if ( pUndoManager )
+ {
+ BOOL bIsUndo = ( nSlot == SID_UNDO );
+
+ USHORT nCount = 1;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState( nSlot, TRUE, &pItem ) == SFX_ITEM_SET )
+ nCount = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ // lock paint for more than one cell undo action (not for editing within a cell)
+ BOOL bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() );
+ if ( bLockPaint )
+ pDocSh->LockPaint();
+
+ for (USHORT i=0; i<nCount; i++)
+ {
+ if ( bIsUndo )
+ pUndoManager->Undo(0);
+ else
+ pUndoManager->Redo(0);
+ }
+
+ if ( bLockPaint )
+ pDocSh->UnlockPaint();
+
+ GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+ }
+ break;
+// default:
+// GetViewFrame()->ExecuteSlot( rReq );
+ }
+}
+
+void ScTabViewShell::GetUndoState(SfxItemSet &rSet)
+{
+ SfxShell* pSh = GetViewData()->GetDispatcher().GetShell(0);
+ SfxUndoManager* pUndoManager = pSh->GetUndoManager();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch (nWhich)
+ {
+ case SID_GETUNDOSTRINGS:
+ case SID_GETREDOSTRINGS:
+ {
+ SfxStringListItem aStrLst( nWhich );
+ if ( pUndoManager )
+ {
+ List* pList = aStrLst.GetList();
+ BOOL bIsUndo = ( nWhich == SID_GETUNDOSTRINGS );
+ USHORT nCount = bIsUndo ? pUndoManager->GetUndoActionCount() : pUndoManager->GetRedoActionCount();
+ for (USHORT i=0; i<nCount; i++)
+ pList->Insert( new String( bIsUndo ? pUndoManager->GetUndoActionComment(i) :
+ pUndoManager->GetRedoActionComment(i) ),
+ LIST_APPEND );
+ }
+ rSet.Put( aStrLst );
+ }
+ break;
+ default:
+ // get state from sfx view frame
+ GetViewFrame()->GetSlotState( nWhich, NULL, &rSet );
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecDrawOpt( SfxRequest& rReq )
+{
+ ScViewOptions aViewOptions = GetViewData()->GetOptions();
+ ScGridOptions aGridOptions = aViewOptions.GetGridOptions();
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+ USHORT nSlotId = rReq.GetSlot();
+ switch (nSlotId)
+ {
+ case SID_GRID_VISIBLE:
+ if ( pArgs && pArgs->GetItemState(nSlotId,TRUE,&pItem) == SFX_ITEM_SET )
+ {
+ aGridOptions.SetGridVisible( ((const SfxBoolItem*)pItem)->GetValue() );
+ aViewOptions.SetGridOptions(aGridOptions);
+ rBindings.Invalidate(SID_GRID_VISIBLE);
+ }
+ break;
+
+ case SID_GRID_USE:
+ if ( pArgs && pArgs->GetItemState(nSlotId,TRUE,&pItem) == SFX_ITEM_SET )
+ {
+ aGridOptions.SetUseGridSnap( ((const SfxBoolItem*)pItem)->GetValue() );
+ aViewOptions.SetGridOptions(aGridOptions);
+ rBindings.Invalidate(SID_GRID_USE);
+ }
+ break;
+
+ case SID_HELPLINES_MOVE:
+ if ( pArgs && pArgs->GetItemState(nSlotId,TRUE,&pItem) == SFX_ITEM_SET )
+ {
+ aViewOptions.SetOption( VOPT_HELPLINES, ((const SfxBoolItem*)pItem)->GetValue() );
+ rBindings.Invalidate(SID_HELPLINES_MOVE);
+ }
+ break;
+ }
+
+ GetViewData()->SetOptions(aViewOptions);
+}
+
+void ScTabViewShell::GetDrawOptState( SfxItemSet& rSet )
+{
+ SfxBoolItem aBool;
+
+ const ScViewOptions& rViewOptions = GetViewData()->GetOptions();
+ const ScGridOptions& rGridOptions = rViewOptions.GetGridOptions();
+
+ aBool.SetValue(rGridOptions.GetGridVisible());
+ aBool.SetWhich( SID_GRID_VISIBLE );
+ rSet.Put( aBool );
+
+ aBool.SetValue(rGridOptions.GetUseGridSnap());
+ aBool.SetWhich( SID_GRID_USE );
+ rSet.Put( aBool );
+
+ aBool.SetValue(rViewOptions.GetOption( VOPT_HELPLINES ));
+ aBool.SetWhich( SID_HELPLINES_MOVE );
+ rSet.Put( aBool );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
new file mode 100644
index 000000000000..e663fbbeb7bc
--- /dev/null
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -0,0 +1,502 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/chart2/data/XDataReceiver.hpp>
+
+
+
+//------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ("", off)
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <com/sun/star/embed/EmbedStates.hpp>
+#include <sfx2/app.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <svx/pfiledlg.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdmark.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdview.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <svx/fontworkbar.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svtools/soerr.hxx>
+#include <svl/rectitem.hxx>
+#include <svl/whiter.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <sot/exchange.hxx>
+
+#include "tabvwsh.hxx"
+#include "globstr.hrc"
+#include "scmod.hxx"
+#include "document.hxx"
+#include "sc.hrc"
+#include "client.hxx"
+#include "fuinsert.hxx"
+#include "docsh.hxx"
+#include "chartarr.hxx"
+#include "drawview.hxx"
+#include "ChartRangeSelectionListener.hxx"
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+void ScTabViewShell::ConnectObject( SdrOle2Obj* pObj )
+{
+ // wird aus dem Paint gerufen
+
+ uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
+ Window* pWin = GetActiveWin();
+
+ // #41412# wenn schon connected ist, nicht nochmal SetObjArea/SetSizeScale
+
+ SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
+ if ( !pClient )
+ {
+ pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
+ Rectangle aRect = pObj->GetLogicRect();
+ Size aDrawSize = aRect.GetSize();
+
+ Size aOleSize = pObj->GetOrigObjSize();
+
+ Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() );
+ Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
+ aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
+ aScaleHeight.ReduceInaccurate(10);
+ pClient->SetSizeScale(aScaleWidth,aScaleHeight);
+
+ // sichtbarer Ausschnitt wird nur inplace veraendert!
+ // the object area must be set after the scaling since it triggers the resizing
+ aRect.SetSize( aOleSize );
+ pClient->SetObjArea( aRect );
+
+ ((ScClient*)pClient)->SetGrafEdit( NULL );
+ }
+}
+
+BOOL ScTabViewShell::ActivateObject( SdrOle2Obj* pObj, long nVerb )
+{
+ // #41081# Gueltigkeits-Hinweisfenster nicht ueber dem Objekt stehenlassen
+ RemoveHintWindow();
+
+ uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
+ Window* pWin = GetActiveWin();
+ ErrCode nErr = ERRCODE_NONE;
+ BOOL bErrorShown = FALSE;
+
+ // linked objects aren't supported
+// if ( xIPObj->IsLink() )
+// nErr = xIPObj->DoVerb(nVerb); // gelinkt -> ohne Client etc.
+// else
+ {
+ SfxInPlaceClient* pClient = FindIPClient( xObj, pWin );
+ if ( !pClient )
+ pClient = new ScClient( this, pWin, GetSdrView()->GetModel(), pObj );
+
+ if ( !(nErr & ERRCODE_ERROR_MASK) && xObj.is() )
+ {
+ Rectangle aRect = pObj->GetLogicRect();
+ Size aDrawSize = aRect.GetSize();
+
+ MapMode aMapMode( MAP_100TH_MM );
+ Size aOleSize = pObj->GetOrigObjSize( &aMapMode );
+
+ if ( pClient->GetAspect() != embed::Aspects::MSOLE_ICON
+ && ( xObj->getStatus( pClient->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
+ {
+ // scale must always be 1 - change VisArea if different from client size
+
+ if ( aDrawSize != aOleSize )
+ {
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( pClient->GetAspect() ) );
+ aOleSize = OutputDevice::LogicToLogic( aDrawSize,
+ MAP_100TH_MM, aUnit );
+ awt::Size aSz( aOleSize.Width(), aOleSize.Height() );
+ xObj->setVisualAreaSize( pClient->GetAspect(), aSz );
+ }
+ Fraction aOne( 1, 1 );
+ pClient->SetSizeScale( aOne, aOne );
+ }
+ else
+ {
+ // calculate scale from client and VisArea size
+
+ Fraction aScaleWidth (aDrawSize.Width(), aOleSize.Width() );
+ Fraction aScaleHeight(aDrawSize.Height(), aOleSize.Height() );
+ aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
+ aScaleHeight.ReduceInaccurate(10);
+ pClient->SetSizeScale(aScaleWidth,aScaleHeight);
+ }
+
+ // sichtbarer Ausschnitt wird nur inplace veraendert!
+ // the object area must be set after the scaling since it triggers the resizing
+ aRect.SetSize( aOleSize );
+ pClient->SetObjArea( aRect );
+
+ ((ScClient*)pClient)->SetGrafEdit( NULL );
+
+ nErr = pClient->DoVerb( nVerb );
+ bErrorShown = TRUE;
+ // SfxViewShell::DoVerb zeigt seine Fehlermeldungen selber an
+
+ // attach listener to selection changes in chart that affect cell
+ // ranges, so those can be highlighted
+ // note: do that after DoVerb, so that the chart controller exists
+ if ( SvtModuleOptions().IsChart() )
+ {
+ SvGlobalName aObjClsId ( xObj->getClassID() );
+ if (SotExchange::IsChart( aObjClsId ))
+ {
+ try
+ {
+ uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::data::XDataReceiver > xDataReceiver(
+ xSup->getComponent(), uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::data::XRangeHighlighter > xRangeHightlighter(
+ xDataReceiver->getRangeHighlighter());
+ if( xRangeHightlighter.is())
+ {
+ uno::Reference< view::XSelectionChangeListener > xListener(
+ new ScChartRangeSelectionListener( this ));
+ xRangeHightlighter->addSelectionChangeListener( xListener );
+ }
+ }
+ catch( const uno::Exception & )
+ {
+ DBG_ERROR( "Exception caught while querying chart" );
+ }
+ }
+ }
+ }
+ }
+ if (nErr != ERRCODE_NONE && !bErrorShown)
+ ErrorHandler::HandleError(nErr);
+
+ //! SetDocumentName sollte schon im Sfx passieren ???
+ //TODO/LATER: how "SetDocumentName"?
+ //xIPObj->SetDocumentName( GetViewData()->GetDocShell()->GetTitle() );
+
+ return ( !(nErr & ERRCODE_ERROR_MASK) );
+}
+
+ErrCode __EXPORT ScTabViewShell::DoVerb(long nVerb)
+{
+ SdrView* pView = GetSdrView();
+ if (!pView)
+ return ERRCODE_SO_NOTIMPL; // soll nicht sein
+
+ SdrOle2Obj* pOle2Obj = NULL;
+ SdrGrafObj* pGrafObj = NULL;
+ SdrObject* pObj = NULL;
+ ErrCode nErr = ERRCODE_NONE;
+
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if (pObj->GetObjIdentifier() == OBJ_OLE2)
+ pOle2Obj = (SdrOle2Obj*) pObj;
+ else if (pObj->GetObjIdentifier() == OBJ_GRAF)
+ {
+ pGrafObj = (SdrGrafObj*) pObj;
+ }
+ }
+
+ if (pOle2Obj)
+ {
+ ActivateObject( pOle2Obj, nVerb );
+ }
+ else
+ {
+ DBG_ERROR("kein Objekt fuer Verb gefunden");
+ }
+
+ return nErr;
+}
+
+void ScTabViewShell::DeactivateOle()
+{
+ // deactivate inplace editing if currently active
+
+ ScModule* pScMod = SC_MOD();
+ bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF;
+
+ ScClient* pClient = (ScClient*) GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() && !bUnoRefDialog )
+ pClient->DeactivateObject();
+}
+
+void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
+{
+ USHORT nSlot = rReq.GetSlot();
+ if (nSlot != SID_OBJECTRESIZE )
+ {
+ SC_MOD()->InputEnterHandler();
+ UpdateInputHandler();
+ }
+
+ // Rahmen fuer Chart einfuegen wird abgebrochen:
+ FuPoor* pPoor = GetDrawFuncPtr();
+ if ( pPoor && pPoor->GetSlotID() == SID_DRAW_CHART )
+ GetViewData()->GetDispatcher().Execute(SID_DRAW_CHART, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD);
+
+ MakeDrawLayer();
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ ScTabView* pTabView = GetViewData()->GetView();
+ Window* pWin = pTabView->GetActiveWin();
+ ScDrawView* pView = pTabView->GetScDrawView();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+// SdrModel* pDrModel = pDocSh->MakeDrawLayer();
+ SdrModel* pDrModel = pView->GetModel();
+
+ switch ( nSlot )
+ {
+ case SID_INSERT_GRAPHIC:
+ FuInsertGraphic(this, pWin, pView, pDrModel, rReq);
+ // shell is set in MarkListHasChanged
+ break;
+
+ case SID_INSERT_AVMEDIA:
+ FuInsertMedia(this, pWin, pView, pDrModel, rReq);
+ // shell is set in MarkListHasChanged
+ break;
+
+ case SID_INSERT_DIAGRAM:
+ FuInsertChart(this, pWin, pView, pDrModel, rReq);
+//? SC_MOD()->SetFunctionDlg( NULL );//XXX
+ break;
+
+ case SID_INSERT_OBJECT:
+ case SID_INSERT_PLUGIN:
+ case SID_INSERT_SOUND:
+ case SID_INSERT_VIDEO:
+ case SID_INSERT_APPLET:
+ case SID_INSERT_SMATH:
+ case SID_INSERT_FLOATINGFRAME:
+ FuInsertOLE(this, pWin, pView, pDrModel, rReq);
+ break;
+
+ case SID_OBJECTRESIZE:
+ {
+ // Der Server moechte die Clientgrosse verandern
+
+ SfxInPlaceClient* pClient = GetIPClient();
+
+ if ( pClient && pClient->IsObjectInPlaceActive() )
+ {
+ const SfxRectangleItem& rRect =
+ (SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE);
+ Rectangle aRect( pWin->PixelToLogic( rRect.GetValue() ) );
+
+ if ( pView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = pView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ UINT16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ if (nSdrObjKind == OBJ_OLE2)
+ {
+ if ( ( (SdrOle2Obj*) pObj)->GetObjRef().is() )
+ {
+ pObj->SetLogicRect(aRect);
+ }
+ }
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_LINKS:
+ {
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( pWin, pDoc->GetLinkManager() );
+ if ( pDlg )
+ {
+ pDlg->Execute();
+ rBindings.Invalidate( nSlot );
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) ); // Navigator
+ rReq.Done();
+ }
+ }
+ break;
+
+ // #98721#
+ case SID_FM_CREATE_FIELDCONTROL:
+ {
+ SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
+ DBG_ASSERT( pDescriptorItem, "SID_FM_CREATE_FIELDCONTROL: invalid request args!" );
+
+ if(pDescriptorItem)
+ {
+ //! merge with ScViewFunc::PasteDataFormat (SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE)?
+
+ ScDrawView* pDrView = GetScDrawView();
+ SdrPageView* pPageView = pDrView ? pDrView->GetSdrPageView() : NULL;
+ if(pPageView)
+ {
+ ::svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
+ SdrObject* pNewDBField = pDrView->CreateFieldControl(aDescriptor);
+
+ if(pNewDBField)
+ {
+ Rectangle aVisArea = pWin->PixelToLogic(Rectangle(Point(0,0), pWin->GetOutputSizePixel()));
+ Point aObjPos(aVisArea.Center());
+ Size aObjSize(pNewDBField->GetLogicRect().GetSize());
+ aObjPos.X() -= aObjSize.Width() / 2;
+ aObjPos.Y() -= aObjSize.Height() / 2;
+ Rectangle aNewObjectRectangle(aObjPos, aObjSize);
+
+ pNewDBField->SetLogicRect(aNewObjectRectangle);
+
+ // controls must be on control layer, groups on front layer
+ if ( pNewDBField->ISA(SdrUnoObj) )
+ pNewDBField->NbcSetLayer(SC_LAYER_CONTROLS);
+ else
+ pNewDBField->NbcSetLayer(SC_LAYER_FRONT);
+ if (pNewDBField->ISA(SdrObjGroup))
+ {
+ SdrObjListIter aIter( *pNewDBField, IM_DEEPWITHGROUPS );
+ SdrObject* pSubObj = aIter.Next();
+ while (pSubObj)
+ {
+ if ( pSubObj->ISA(SdrUnoObj) )
+ pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
+ else
+ pSubObj->NbcSetLayer(SC_LAYER_FRONT);
+ pSubObj = aIter.Next();
+ }
+ }
+
+ pView->InsertObjectAtView(pNewDBField, *pPageView);
+ }
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_FONTWORK_GALLERY_FLOATER:
+ svx::FontworkBar::execute( pView, rReq, GetViewFrame()->GetBindings() );
+ rReq.Ignore();
+ break;
+ }
+}
+
+void ScTabViewShell::GetDrawInsState(SfxItemSet &rSet)
+{
+ BOOL bOle = GetViewFrame()->GetFrame().IsInPlace();
+ BOOL bTabProt = GetViewData()->GetDocument()->IsTabProtected(GetViewData()->GetTabNo());
+ ScDocShell* pDocShell = ( GetViewData() ? GetViewData()->GetDocShell() : NULL );
+ bool bShared = ( pDocShell ? pDocShell->IsDocShared() : false );
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+ case SID_INSERT_DIAGRAM:
+ if ( bOle || bTabProt || !SvtModuleOptions().IsChart() || bShared )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_INSERT_SMATH:
+ if ( bOle || bTabProt || !SvtModuleOptions().IsMath() || bShared )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_INSERT_OBJECT:
+ case SID_INSERT_PLUGIN:
+ case SID_INSERT_FLOATINGFRAME:
+ if ( bOle || bTabProt || bShared )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_INSERT_SOUND:
+ case SID_INSERT_VIDEO:
+ /* #i102735# discussed with NN: removed for performance reasons
+ || !SvxPluginFileDlg::IsAvailable(nWhich)
+ */
+ if ( bOle || bTabProt || bShared )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_INSERT_APPLET:
+ // wenn SOLAR_JAVA nicht definiert ist, immer disablen
+#ifdef SOLAR_JAVA
+ if (bOle || bTabProt)
+#endif
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_INSERT_GRAPHIC:
+ case SID_INSERT_AVMEDIA:
+ case SID_FONTWORK_GALLERY_FLOATER:
+ if ( bTabProt || bShared )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case SID_LINKS:
+ {
+ if (GetViewData()->GetDocument()->GetLinkManager()->GetLinks().Count() == 0 )
+ rSet.DisableItem( SID_LINKS );
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
new file mode 100644
index 000000000000..7d79c148b403
--- /dev/null
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -0,0 +1,335 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+#include "scitems.hxx"
+#include <vcl/msgbox.hxx>
+#include <sfx2/childwin.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "uiitems.hxx"
+#include "pivot.hxx"
+#include "namedlg.hxx"
+#include "solvrdlg.hxx"
+#include "optsolver.hxx"
+#include "tabopdlg.hxx"
+#include "autoform.hxx" // Core
+#include "autofmt.hxx" // Dialog
+#include "consdlg.hxx"
+#include "filtdlg.hxx"
+#include "dbnamdlg.hxx"
+#include "pvlaydlg.hxx"
+#include "areasdlg.hxx"
+#include "condfrmt.hxx"
+#include "rangeutl.hxx"
+#include "crnrdlg.hxx"
+#include "formula.hxx"
+#include "cell.hxx" // Input Status Edit-Zellen
+#include "acredlin.hxx"
+#include "highred.hxx"
+#include "simpref.hxx"
+#include "funcdesc.hxx"
+#include "dpobject.hxx"
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::SetCurRefDlgId( USHORT nNew )
+{
+ // CurRefDlgId is stored in ScModule to find if a ref dialog is open,
+ // and in the view to identify the view that has opened the dialog
+ nCurRefDlgId = nNew;
+}
+
+SfxModelessDialog* ScTabViewShell::CreateRefDialog(
+ SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
+ Window* pParent, USHORT nSlotId )
+{
+ // Dialog nur aufmachen, wenn ueber ScModule::SetRefDialog gerufen, damit
+ // z.B. nach einem Absturz offene Ref-Dialoge nicht wiederkommen (#42341#).
+
+ if ( SC_MOD()->GetCurRefDlgId() != nSlotId )
+ return NULL;
+
+ if ( nCurRefDlgId != nSlotId )
+ {
+ // the dialog has been opened in a different view
+ // -> lock the dispatcher for this view (modal mode)
+
+ GetViewData()->GetDispatcher().Lock( TRUE ); // lock is reset when closing dialog
+ return NULL;
+ }
+
+ SfxModelessDialog* pResult = 0;
+
+ if(pCW)
+ pCW->SetHideNotDelete(TRUE);
+
+ switch( nSlotId )
+ {
+ case FID_DEFINE_NAME:
+ pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
+ ScAddress( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() ) );
+ break;
+
+ case SID_DEFINE_COLROWNAMERANGES:
+ {
+ pResult = new ScColRowNameRangesDlg( pB, pCW, pParent, GetViewData() );
+ }
+ break;
+
+ case SID_OPENDLG_CONSOLIDATE:
+ {
+ SfxItemSet aArgSet( GetPool(),
+ SCITEM_CONSOLIDATEDATA,
+ SCITEM_CONSOLIDATEDATA );
+
+ const ScConsolidateParam* pDlgData =
+ GetViewData()->GetDocument()->GetConsolidateDlgData();
+
+ if ( !pDlgData )
+ {
+ ScConsolidateParam aConsParam;
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ SCTAB nStartTab, nEndTab;
+
+ GetViewData()->GetSimpleArea( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab );
+
+ PutInOrder( nStartCol, nEndCol );
+ PutInOrder( nStartRow, nEndRow );
+ PutInOrder( nStartTab, nEndTab );
+
+ aConsParam.nCol = nStartCol;
+ aConsParam.nRow = nStartRow;
+ aConsParam.nTab = nStartTab;
+
+ aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA,
+ &aConsParam ) );
+ }
+ else
+ {
+ aArgSet.Put( ScConsolidateItem( SCITEM_CONSOLIDATEDATA, pDlgData ) );
+ }
+ pResult = new ScConsolidateDlg( pB, pCW, pParent, aArgSet );
+ }
+ break;
+
+ case SID_DEFINE_DBNAME:
+ {
+ // wenn auf einem bestehenden Bereich aufgerufen, den markieren
+ GetDBData( TRUE, SC_DB_OLD );
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ MarkDataArea( FALSE );
+
+ pResult = new ScDbNameDlg( pB, pCW, pParent, GetViewData() );
+ }
+ break;
+
+ case SID_SPECIAL_FILTER:
+ {
+ ScQueryParam aQueryParam;
+ SfxItemSet aArgSet( GetPool(),
+ SCITEM_QUERYDATA,
+ SCITEM_QUERYDATA );
+
+ ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, SC_DBSEL_ROW_DOWN, true, true);
+ pDBData->GetQueryParam( aQueryParam );
+ aQueryParam.bUseDynamicRange = true;
+
+ ScQueryItem aItem( SCITEM_QUERYDATA, GetViewData(), &aQueryParam );
+ ScRange aAdvSource;
+ if (pDBData->GetAdvancedQuerySource(aAdvSource))
+ aItem.SetAdvancedQuerySource( &aAdvSource );
+
+ aArgSet.Put( aItem );
+
+ // aktuelle Tabelle merken (wg. RefInput im Dialog)
+ GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
+
+ pResult = new ScSpecialFilterDlg( pB, pCW, pParent, aArgSet );
+ }
+ break;
+
+ case SID_FILTER:
+ {
+
+ ScQueryParam aQueryParam;
+ SfxItemSet aArgSet( GetPool(),
+ SCITEM_QUERYDATA,
+ SCITEM_QUERYDATA );
+
+ ScDBData* pDBData = GetDBData(true, SC_DB_MAKE, SC_DBSEL_ROW_DOWN, true, true);
+ pDBData->GetQueryParam( aQueryParam );
+ aQueryParam.bUseDynamicRange = true;
+
+ aArgSet.Put( ScQueryItem( SCITEM_QUERYDATA,
+ GetViewData(),
+ &aQueryParam ) );
+
+ // aktuelle Tabelle merken (wg. RefInput im Dialog)
+ GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
+
+ pResult = new ScFilterDlg( pB, pCW, pParent, aArgSet );
+ }
+ break;
+
+ case SID_OPENDLG_TABOP:
+ {
+ ScViewData* pViewData = GetViewData();
+ ScRefAddress aCurPos ( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo(),
+ FALSE, FALSE, FALSE );
+
+ pResult = new ScTabOpDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
+ }
+ break;
+
+ case SID_OPENDLG_SOLVE:
+ {
+ ScViewData* pViewData = GetViewData();
+ ScAddress aCurPos( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo());
+ pResult = new ScSolverDlg( pB, pCW, pParent, pViewData->GetDocument(), aCurPos );
+ }
+ break;
+
+ case SID_OPENDLG_OPTSOLVER:
+ {
+ ScViewData* pViewData = GetViewData();
+ ScAddress aCurPos( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
+ pResult = new ScOptSolverDlg( pB, pCW, pParent, pViewData->GetDocShell(), aCurPos );
+ }
+ break;
+
+ case SID_OPENDLG_PIVOTTABLE:
+ {
+ // all settings must be in pDialogDPObject
+
+ if( pDialogDPObject )
+ {
+ // Check for an existing datapilot output.
+ ScViewData* pViewData = GetViewData();
+ ScDPObject* pObj = GetViewData()->GetDocument()->GetDPAtCursor(
+ pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
+
+ GetViewData()->SetRefTabNo( GetViewData()->GetTabNo() );
+ pResult = new ScDPLayoutDlg( pB, pCW, pParent, *pDialogDPObject, pObj == NULL);
+ }
+ }
+ break;
+
+ case SID_OPENDLG_EDIT_PRINTAREA:
+ {
+ pResult = new ScPrintAreasDlg( pB, pCW, pParent );
+ }
+ break;
+
+ case SID_OPENDLG_CONDFRMT:
+ {
+ ScViewData* pViewData = GetViewData();
+
+ ScDocument* pDoc = pViewData->GetDocument();
+ const ScConditionalFormat* pForm = pDoc->GetCondFormat(
+ pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() );
+
+ // aktuelle Tabelle merken (wg. RefInput im Dialog)
+ pViewData->SetRefTabNo( pViewData->GetTabNo() );
+
+ pResult = new ScConditionalFormatDlg( pB, pCW, pParent, pDoc, pForm );
+ }
+ break;
+
+ case SID_OPENDLG_FUNCTION:
+ {
+ // Dialog schaut selber, was in der Zelle steht
+
+ pResult = new ScFormulaDlg( pB, pCW, pParent, GetViewData(),ScGlobal::GetStarCalcFunctionMgr() );
+ }
+ break;
+
+ case FID_CHG_SHOW:
+ {
+ // Dialog schaut selber, was in der Zelle steht
+
+ pResult = new ScHighlightChgDlg( pB, pCW, pParent, GetViewData() );
+ }
+ break;
+
+ case WID_SIMPLE_REF:
+ {
+ // Dialog schaut selber, was in der Zelle steht
+
+ ScViewData* pViewData = GetViewData();
+ pViewData->SetRefTabNo( pViewData->GetTabNo() );
+ pResult = new ScSimpleRefDlg( pB, pCW, pParent, pViewData );
+ }
+ break;
+
+
+ default:
+ DBG_ERROR( "ScTabViewShell::CreateRefDialog: unbekannte ID" );
+ break;
+ }
+
+ if (pResult)
+ {
+ // Die Dialoge gehen immer mit eingeklapptem Zusaetze-Button auf,
+ // darum muss die Groesse ueber das Initialize gerettet werden
+ // (oder den Zusaetze-Status mit speichern !!!)
+
+ Size aSize = pResult->GetSizePixel();
+ pResult->Initialize( pInfo );
+ pResult->SetSizePixel(aSize);
+ }
+
+ return pResult;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshd.cxx b/sc/source/ui/view/tabvwshd.cxx
new file mode 100644
index 000000000000..b70237f47265
--- /dev/null
+++ b/sc/source/ui/view/tabvwshd.cxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+#ifdef _MSC_VER
+#pragma optimize ("", off)
+#endif
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <sfx2/childwin.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+
+#include "tabvwsh.hxx"
+#include "global.hxx"
+#include "scmod.hxx"
+#include "docsh.hxx"
+#include "sc.hrc"
+
+
+// STATIC DATA -----------------------------------------------------------
+
+//------------------------------------------------------------------
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+//! Parent-Window fuer Dialoge
+//! Problem: OLE Server!
+
+Window* ScTabViewShell::GetDialogParent()
+{
+ // #95513# if a ref-input dialog is open, use it as parent
+ // (necessary when a slot is executed from the dialog's OK handler)
+ if ( nCurRefDlgId && nCurRefDlgId == SC_MOD()->GetCurRefDlgId() )
+ {
+ SfxViewFrame* pViewFrm = GetViewFrame();
+ if ( pViewFrm->HasChildWindow(nCurRefDlgId) )
+ {
+ SfxChildWindow* pChild = pViewFrm->GetChildWindow(nCurRefDlgId);
+ if (pChild)
+ {
+ Window* pWin = pChild->GetWindow();
+ if (pWin && pWin->IsVisible())
+ return pWin;
+ }
+ }
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ if ( pDocSh->IsOle() )
+ {
+ //TODO/LATER: how to GetEditWindow in embedded document?!
+ //It should be OK to return the VieShell Window!
+ return GetWindow();
+ //SvInPlaceEnvironment* pEnv = pDocSh->GetIPEnv();
+ //if (pEnv)
+ // return pEnv->GetEditWin();
+ }
+
+ return GetActiveWin(); // for normal views, too
+}
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshe.cxx b/sc/source/ui/view/tabvwshe.cxx
new file mode 100644
index 000000000000..554611b4dcae
--- /dev/null
+++ b/sc/source/ui/view/tabvwshe.cxx
@@ -0,0 +1,343 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <editeng/eeitem.hxx>
+
+#include "scitems.hxx"
+#include <editeng/editview.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/stritem.hxx>
+#include <vcl/sound.hxx>
+
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "scmod.hxx"
+#include "impex.hxx"
+#include "editsh.hxx"
+#include "dociter.hxx"
+#include "inputhdl.hxx"
+#include "document.hxx"
+
+//==================================================================
+
+String __EXPORT ScTabViewShell::GetSelectionText( BOOL bWholeWord )
+{
+ String aStrSelection;
+
+ if ( pEditShell && pEditShell == GetMySubShell() )
+ {
+ aStrSelection = pEditShell->GetSelectionText( bWholeWord );
+ }
+ else
+ {
+ ScRange aRange;
+
+ if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( bInFormatDialog && aRange.aStart.Row() != aRange.aEnd.Row() )
+ {
+ // Range auf eine Datenzeile begrenzen
+ // (#48613# nur wenn der Aufruf aus einem Format-Dialog kommt)
+ ScHorizontalCellIterator aIter( pDoc, aRange.aStart.Tab(),
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row() );
+ SCCOL nCol;
+ SCROW nRow;
+ if ( aIter.GetNext( nCol, nRow ) )
+ {
+ aRange.aStart.SetCol( nCol );
+ aRange.aStart.SetRow( nRow );
+ aRange.aEnd.SetRow( nRow );
+ }
+ else
+ aRange.aEnd = aRange.aStart;
+ }
+ else
+ {
+ // #i111531# with 1M rows it was necessary to limit the range
+ // to the actually used data area.
+ SCCOL nCol1, nCol2;
+ SCROW nRow1, nRow2;
+ SCTAB nTab1, nTab2;
+ aRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2);
+ if (pDoc->ShrinkToUsedDataArea( nTab1, nCol1, nRow1, nCol2, nRow2, false))
+ {
+ aRange.aStart.SetCol( nCol1 );
+ aRange.aStart.SetRow( nRow1 );
+ aRange.aEnd.SetCol( nCol2 );
+ aRange.aEnd.SetRow( nRow2 );
+ }
+ }
+
+ ScImportExport aObj( pDoc, aRange );
+ aObj.SetFormulas( GetViewData()->GetOptions().GetOption( VOPT_FORMULAS ) );
+ rtl::OUString aExportOUString;
+ aObj.ExportString( aExportOUString );
+ aStrSelection = aExportOUString;
+
+ aStrSelection.ConvertLineEnd( LINEEND_CR );
+
+ // Tab/CR durch Space ersetzen, wenn fuer Dialog oder per Basic/SelectionTextExt,
+ // oder wenn es eine einzelne Zeile ist.
+ // Sonst mehrzeilig mit Tabs beibehalten (z.B. Mail oder Basic/SelectionText).
+ // Fuer Mail werden die Tabs dann spaeter in (mehrere) Spaces gewandelt.
+
+ if ( bInFormatDialog || bWholeWord || aRange.aEnd.Row() == aRange.aStart.Row() )
+ {
+ xub_StrLen nAt;
+ while ( (nAt = aStrSelection.Search( CHAR_CR )) != STRING_NOTFOUND )
+ aStrSelection.SetChar( nAt, ' ' );
+ while ( (nAt = aStrSelection.Search( '\t' )) != STRING_NOTFOUND )
+ aStrSelection.SetChar( nAt, ' ' );
+
+ aStrSelection.EraseTrailingChars( ' ' );
+ }
+ }
+ }
+
+ return aStrSelection;
+}
+
+//------------------------------------------------------------------------
+
+void ScTabViewShell::InsertURL( const String& rName, const String& rURL, const String& rTarget,
+ USHORT nMode )
+{
+ SvxLinkInsertMode eMode = (SvxLinkInsertMode) nMode;
+ BOOL bAsText = ( eMode != HLINK_BUTTON ); // Default ist jetzt Text
+
+ if ( bAsText )
+ {
+ if ( GetViewData()->IsActive() )
+ {
+ // if the view is active, always use InsertURLField, which starts EditMode
+ // and selects the URL, so it can be changed from the URL bar / dialog
+
+ InsertURLField( rName, rURL, rTarget );
+ }
+ else
+ {
+ // #91216# if the view is not active, InsertURLField doesn't work
+ // -> use InsertBookmark to directly manipulate cell content
+ // bTryReplace=TRUE -> if cell contains only one URL, replace it
+
+ SCCOL nPosX = GetViewData()->GetCurX();
+ SCROW nPosY = GetViewData()->GetCurY();
+ InsertBookmark( rName, rURL, nPosX, nPosY, &rTarget, TRUE );
+ }
+ }
+ else
+ {
+ SC_MOD()->InputEnterHandler();
+ InsertURLButton( rName, rURL, rTarget );
+ }
+}
+
+//------------------------------------------------------------------------
+
+// wenn CLOOKs: -> mit <editview.hxx> <flditem.hxx>in neue tabvwsh
+
+void lcl_SelectFieldAfterInsert( EditView& rView )
+{
+ ESelection aSel = rView.GetSelection();
+ if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 )
+ {
+ // Cursor is behind the inserted field -> extend selection to the left
+
+ --aSel.nStartPos;
+ rView.SetSelection( aSel );
+ }
+}
+
+void ScTabViewShell::InsertURLField( const String& rName, const String& rURL, const String& rTarget )
+{
+ SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR );
+ aURLField.SetTargetFrame( rTarget );
+ SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD );
+
+ ScViewData* pViewData = GetViewData();
+ ScModule* pScMod = SC_MOD();
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewData->GetViewShell() );
+
+ BOOL bSelectFirst = FALSE;
+ if ( !pScMod->IsEditMode() )
+ {
+ if ( !SelectionEditable() )
+ {
+ // no error message (may be called from drag&drop)
+ Sound::Beep();
+ return;
+ }
+
+ // single url in cell is shown in the dialog and replaced
+ bSelectFirst = HasBookmarkAtCursor( NULL );
+ pScMod->SetInputMode( SC_INPUT_TABLE );
+ }
+
+ EditView* pTopView = pHdl->GetTopView();
+ EditView* pTableView = pHdl->GetTableView();
+ DBG_ASSERT( pTopView || pTableView, "No EditView" );
+
+ if ( bSelectFirst )
+ {
+ if ( pTopView )
+ pTopView->SetSelection( ESelection(0,0,0,1) );
+ if ( pTableView )
+ pTableView->SetSelection( ESelection(0,0,0,1) );
+ }
+
+ pHdl->DataChanging();
+
+ if ( pTopView )
+ {
+ pTopView->InsertField( aURLItem );
+ lcl_SelectFieldAfterInsert( *pTopView );
+ }
+ if ( pTableView )
+ {
+ pTableView->InsertField( aURLItem );
+ lcl_SelectFieldAfterInsert( *pTableView );
+ }
+
+ pHdl->DataChanged();
+}
+
+void ScTabViewShell::ExecSearch( SfxRequest& rReq )
+{
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ USHORT nSlot = rReq.GetSlot();
+ const SfxPoolItem* pItem;
+
+ switch ( nSlot )
+ {
+ case FID_SEARCH_NOW:
+ {
+ if ( pReqArgs &&
+ SFX_ITEM_SET == pReqArgs->GetItemState(SID_SEARCH_ITEM, FALSE, &pItem) )
+ {
+ DBG_ASSERT( pItem->ISA(SvxSearchItem), "falsches Item" );
+ const SvxSearchItem* pSearchItem = (const SvxSearchItem*) pItem;
+
+ ScGlobal::SetSearchItem( *pSearchItem );
+ SearchAndReplace( pSearchItem, TRUE, rReq.IsAPI() );
+ rReq.Done();
+ }
+ }
+ break;
+
+ case SID_SEARCH_ITEM:
+ if (pReqArgs && SFX_ITEM_SET ==
+ pReqArgs->GetItemState(SID_SEARCH_ITEM, FALSE, &pItem))
+ {
+ // Search-Item merken
+ DBG_ASSERT( pItem->ISA(SvxSearchItem), "falsches Item" );
+ ScGlobal::SetSearchItem( *(const SvxSearchItem*) pItem );
+ }
+ else
+ {
+ DBG_ERROR("SID_SEARCH_ITEM ohne Parameter");
+ }
+ break;
+ case FID_SEARCH:
+ case FID_REPLACE:
+ case FID_REPLACE_ALL:
+ case FID_SEARCH_ALL:
+ {
+ if (pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState(nSlot, FALSE, &pItem))
+ {
+ // SearchItem holen
+
+ SvxSearchItem aSearchItem = ScGlobal::GetSearchItem();
+
+ // SearchItem fuellen
+
+ aSearchItem.SetSearchString(((SfxStringItem*)pItem)->GetValue());
+ if(SFX_ITEM_SET == pReqArgs->GetItemState(FN_PARAM_1, FALSE, &pItem))
+ aSearchItem.SetReplaceString(((SfxStringItem*)pItem)->GetValue());
+
+ if (nSlot == FID_SEARCH)
+ aSearchItem.SetCommand(SVX_SEARCHCMD_FIND);
+ else if(nSlot == FID_REPLACE)
+ aSearchItem.SetCommand(SVX_SEARCHCMD_REPLACE);
+ else if(nSlot == FID_REPLACE_ALL)
+ aSearchItem.SetCommand(SVX_SEARCHCMD_REPLACE_ALL);
+ else
+ aSearchItem.SetCommand(SVX_SEARCHCMD_FIND_ALL);
+
+ // Request ausfuehren (dabei wird das SearchItem gespeichert)
+
+ aSearchItem.SetWhich(SID_SEARCH_ITEM);
+ GetViewData()->GetDispatcher().Execute( FID_SEARCH_NOW,
+ rReq.IsAPI() ? SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON :
+ SFX_CALLMODE_STANDARD,
+ &aSearchItem, 0L );
+ }
+ else
+ {
+ GetViewData()->GetDispatcher().Execute(
+ SID_SEARCH_DLG, SFX_CALLMODE_ASYNCHRON|SFX_CALLMODE_RECORD );
+ }
+ }
+ break;
+ case FID_REPEAT_SEARCH:
+ {
+ // nochmal mit ScGlobal::GetSearchItem()
+
+ SvxSearchItem aSearchItem = ScGlobal::GetSearchItem();
+ aSearchItem.SetWhich(SID_SEARCH_ITEM);
+ GetViewData()->GetDispatcher().Execute( FID_SEARCH_NOW,
+ rReq.IsAPI() ? SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON :
+ SFX_CALLMODE_STANDARD,
+ &aSearchItem, 0L );
+ }
+ break;
+// case FID_SEARCH_COUNT:
+ }
+}
+
+//--------------------------------------------------------------------
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
new file mode 100644
index 000000000000..e38cb88d9491
--- /dev/null
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -0,0 +1,954 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <boost/scoped_ptr.hpp>
+
+#include "scitems.hxx"
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <basic/sbstar.hxx>
+#include <layout/layout.hxx>
+#include <svl/languageoptions.hxx>
+#include <svl/stritem.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+#include <svx/svxdlg.hxx>
+#include <editeng/colritem.hxx>
+
+#include "tabvwsh.hxx"
+#include "sc.hrc"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "shtabdlg.hxx"
+#include "scresid.hxx"
+#include "globstr.hrc"
+#include "docfunc.hxx"
+#include "eventuno.hxx"
+
+#include "scabstdlg.hxx"
+
+#include "tabbgcolor.hxx"
+#include "tabbgcolordlg.hxx"
+
+using ::boost::scoped_ptr;
+using namespace com::sun::star;
+
+#define IS_AVAILABLE(WhichId,ppItem) \
+ (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET)
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+
+ SCTAB nCurrentTab = pViewData->GetTabNo();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ USHORT nSlot = rReq.GetSlot();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ HideListBox(); // Autofilter-DropDown-Listbox
+
+ switch ( nSlot )
+ {
+ case FID_TABLE_VISIBLE:
+ {
+ String aName;
+ pDoc->GetName( nCurrentTab, aName );
+
+ BOOL bVisible=TRUE;
+ if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_TABLE_VISIBLE, &pItem ) )
+ bVisible = ((const SfxBoolItem*)pItem)->GetValue();
+ }
+
+ if( ! bVisible ) // ausblenden
+ {
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+ USHORT nVis = 0;
+ for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
+ if (pDoc->IsVisible(i))
+ ++nVis;
+ if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 )
+ break;
+
+ SCTAB nHideTab;
+ if (pDoc->GetTable( aName, nHideTab ))
+ HideTable( nHideTab );
+ }
+ else // einblenden
+ {
+ ShowTable( aName );
+ }
+ }
+ break;
+
+ case FID_TABLE_HIDE:
+ {
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+ USHORT nVis = 0;
+ for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
+ if (pDoc->IsVisible(i))
+ ++nVis;
+ if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 )
+ break;
+
+
+ String aName;
+ if( pReqArgs != NULL )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_TABLE_HIDE, &pItem ) )
+ aName = ((const SfxStringItem*)pItem)->GetValue();
+ }
+
+ if (!aName.Len())
+ {
+ pDoc->GetName( nCurrentTab, aName ); // aktuelle Tabelle
+ rReq.AppendItem( SfxStringItem( FID_TABLE_HIDE, aName ) );
+ }
+
+ SCTAB nHideTab;
+ if (pDoc->GetTable( aName, nHideTab ))
+ HideTable( nHideTab );
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ break;
+
+ case FID_TABLE_SHOW:
+ {
+ String aName;
+ if ( pReqArgs )
+ {
+ const SfxPoolItem* pItem;
+ if( IS_AVAILABLE( FID_TABLE_SHOW, &pItem ) )
+ {
+ aName = ((const SfxStringItem*)pItem)->GetValue();
+
+ ShowTable( aName );
+
+ if( ! rReq.IsAPI() )
+ rReq.Done();
+ }
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScShowTabDlg* pDlg = pFact->CreateScShowTabDlg( GetDialogParent(), RID_SCDLG_SHOW_TAB);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ String aTabName;
+ BOOL bFirst = TRUE;
+ for ( SCTAB i=0; i != nTabCount; i++ )
+ {
+ if (!pDoc->IsVisible(i))
+ {
+ pDoc->GetName( i, aTabName );
+ pDlg->Insert( aTabName, bFirst );
+ bFirst = FALSE;
+ }
+ }
+
+ if ( pDlg->Execute() == RET_OK )
+ {
+ USHORT nCount = pDlg->GetSelectEntryCount();
+ for (USHORT nPos=0; nPos<nCount; nPos++)
+ {
+ aName = pDlg->GetSelectEntry(nPos);
+ ShowTable( aName );
+ }
+ rReq.AppendItem( SfxStringItem( FID_TABLE_SHOW, aName ) );
+ rReq.Done();
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_INS_TABLE:
+ case FID_INS_TABLE_EXT:
+ {
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+ SCTAB nTabNr = nCurrentTab;
+
+ if ( !pDoc->IsDocEditable() )
+ break; // gesperrt
+
+ if ( pReqArgs != NULL ) // von Basic
+ {
+ BOOL bOk = FALSE;
+ const SfxPoolItem* pTabItem;
+ const SfxPoolItem* pNameItem;
+ String aName;
+
+ if ( IS_AVAILABLE( FN_PARAM_1, &pTabItem ) &&
+ IS_AVAILABLE( nSlot, &pNameItem ) )
+ {
+ // Tabellennr. von Basic: 1-basiert
+
+ aName = ((const SfxStringItem*)pNameItem)->GetValue();
+ nTabNr = ((const SfxUInt16Item*)pTabItem)->GetValue() - 1;
+ if ( nTabNr < nTabCount )
+ bOk = InsertTable( aName, nTabNr );
+ }
+
+ if (bOk)
+ rReq.Done( *pReqArgs );
+ //! sonst Fehler setzen
+ }
+ else // Dialog
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScInsertTableDlg* pDlg = pFact->CreateScInsertTableDlg( GetDialogParent(), *pViewData,
+ nTabSelCount, nSlot == FID_INS_TABLE_EXT,
+ RID_SCDLG_INSERT_TABLE);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+ if ( RET_OK == pDlg->Execute() )
+ {
+ if (pDlg->GetTablesFromFile())
+ {
+ SCTAB nTabs[MAXTABCOUNT];
+ SCTAB nCount = 0;
+ USHORT n = 0;
+ const String* pStr = pDlg->GetFirstTable( &n );
+ while ( pStr )
+ {
+ nTabs[nCount++] = static_cast<SCTAB>(n);
+ pStr = pDlg->GetNextTable( &n );
+ }
+ BOOL bLink = pDlg->GetTablesAsLink();
+ if (nCount != 0)
+ {
+ if(pDlg->IsTableBefore())
+ {
+ ImportTables( pDlg->GetDocShellTables(), nCount, nTabs,
+ bLink,nTabNr );
+ }
+ else
+ {
+ SCTAB nTabAfter = nTabNr+1;
+
+ for(SCTAB j=nCurrentTab+1;j<nTabCount;j++)
+ {
+ if(!pDoc->IsScenario(j))
+ {
+ nTabAfter=j;
+ break;
+ }
+ }
+
+ ImportTables( pDlg->GetDocShellTables(), nCount, nTabs,
+ bLink,nTabAfter );
+ }
+ }
+ }
+ else
+ {
+ SCTAB nCount=pDlg->GetTableCount();
+ if(pDlg->IsTableBefore())
+ {
+ if(nCount==1 && pDlg->GetFirstTable()->Len()>0)
+ {
+ rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabNr) + 1 ) ); // 1-based
+ rReq.Done();
+
+ InsertTable( *pDlg->GetFirstTable(), nTabNr );
+ }
+ else
+ InsertTables( NULL, nTabNr,nCount );
+ }
+ else
+ {
+ SCTAB nTabAfter = nTabNr+1;
+ SCTAB nSelHigh=0;
+
+ for(SCTAB i=0;i<nTabCount;i++)
+ {
+ if(rMark.GetTableSelect(i))
+ {
+ nSelHigh=i;
+ }
+ }
+
+ for(SCTAB j=nSelHigh+1;j<nTabCount;j++)
+ {
+ if(!pDoc->IsScenario(j))
+ {
+ nTabAfter=j;
+ break;
+ }
+ else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
+ nTabAfter = j + 1;
+ }
+
+ if(nCount==1 && pDlg->GetFirstTable()->Len()>0)
+ {
+ rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabAfter) + 1 ) ); // 1-based
+ rReq.Done();
+
+ InsertTable( *pDlg->GetFirstTable(), nTabAfter);
+ }
+ else
+ {
+ InsertTables( NULL, nTabAfter,nCount);
+ }
+ }
+ }
+ }
+
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_TAB_APPEND:
+ case FID_TAB_RENAME:
+ case FID_TAB_MENU_RENAME:
+ {
+ // FID_TAB_MENU_RENAME - "umbenennen" im Menu
+ // FID_TAB_RENAME - "Name"-Property fuer Basic
+ // Execute ist gleich, aber im GetState wird MENU_RENAME evtl. disabled
+
+ if ( nSlot == FID_TAB_MENU_RENAME )
+ nSlot = FID_TAB_RENAME; // Execute ist gleich
+
+ SCTAB nTabNr = pViewData->GetTabNo();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+ if ( !pDoc->IsDocEditable() )
+ break; // alles gesperrt
+
+ if ( nSlot != FID_TAB_APPEND &&
+ ( pDoc->IsTabProtected( nTabNr ) || nTabSelCount > 1 ) )
+ break; // kein Rename
+
+ if( pReqArgs != NULL )
+ {
+ BOOL bDone = FALSE;
+ const SfxPoolItem* pItem;
+ String aName;
+
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ nTabNr = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( nSlot, &pItem ) )
+ aName = ((const SfxStringItem*)pItem)->GetValue();
+
+ switch ( nSlot )
+ {
+ case FID_TAB_APPEND:
+ bDone = AppendTable( aName );
+ break;
+ case FID_TAB_RENAME:
+ bDone = RenameTable( aName, nTabNr );
+ break;
+ }
+
+ if( bDone )
+ {
+ rReq.Done( *pReqArgs );
+ }
+ }
+ else
+ {
+ USHORT nRet = RET_OK;
+ BOOL bDone = FALSE;
+ String aErrMsg ( ScGlobal::GetRscString( STR_INVALIDTABNAME ) );
+ String aName;
+ String aDlgTitle;
+
+ switch ( nSlot )
+ {
+ case FID_TAB_APPEND:
+ aDlgTitle = String(ScResId(SCSTR_APDTABLE));
+ pDoc->CreateValidTabName( aName );
+ break;
+
+ case FID_TAB_RENAME:
+ aDlgTitle = String(ScResId(SCSTR_RENAMETAB));
+ pDoc->GetName( pViewData->GetTabNo(), aName );
+ break;
+ }
+
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScStringInputDlg* pDlg = pFact->CreateScStringInputDlg( GetDialogParent(),
+ aDlgTitle,
+ String(ScResId(SCSTR_NAME)),
+ aName,
+ nSlot,RID_SCDLG_STRINPUT);
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ while ( !bDone && nRet == RET_OK )
+ {
+ nRet = pDlg->Execute();
+
+ if ( nRet == RET_OK )
+ {
+ pDlg->GetInputString( aName );
+
+
+ switch ( nSlot )
+ {
+ case FID_TAB_APPEND:
+ bDone = AppendTable( aName );
+ break;
+ case FID_TAB_RENAME:
+ bDone = RenameTable( aName, nTabNr );
+ break;
+ }
+
+ if ( bDone )
+ {
+ rReq.AppendItem( SfxStringItem( nSlot, aName ) );
+ rReq.Done();
+ }
+ else
+ {
+ if( rReq.IsAPI() )
+ {
+ StarBASIC::Error( SbERR_SETPROP_FAILED ); // XXX Fehlerbehandlung???
+ }
+ else
+ {
+ nRet = ErrorBox( GetDialogParent(),
+ WinBits( WB_OK | WB_DEF_OK ),
+ aErrMsg
+ ).Execute();
+ }
+ }
+ }
+ }
+ delete pDlg;
+ }
+ }
+ break;
+
+ case FID_TAB_MOVE:
+ {
+ if ( pDoc->GetChangeTrack() != NULL )
+ break; // bei aktiviertem ChangeTracking kein TabMove
+
+ BOOL bDoIt = FALSE;
+ USHORT nDoc = 0;
+ SCTAB nTab = pViewData->GetTabNo();
+ BOOL bCpy = FALSE;
+ String aDocName;
+
+ if( pReqArgs != NULL )
+ {
+ SCTAB nTableCount = pDoc->GetTableCount();
+ const SfxPoolItem* pItem;
+
+ if( IS_AVAILABLE( FID_TAB_MOVE, &pItem ) )
+ aDocName = ((const SfxStringItem*)pItem)->GetValue();
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ {
+ // Tabelle ist 1-basiert
+ nTab = ((const SfxUInt16Item*)pItem)->GetValue() - 1;
+ if ( nTab >= nTableCount )
+ nTab = SC_TAB_APPEND;
+ }
+ if( IS_AVAILABLE( FN_PARAM_2, &pItem ) )
+ bCpy = ((const SfxBoolItem*)pItem)->GetValue();
+
+ if( aDocName.Len() )
+ {
+ SfxObjectShell* pSh = SfxObjectShell::GetFirst();
+ ScDocShell* pScSh = NULL;
+ USHORT i=0;
+
+ while ( pSh )
+ {
+ pScSh = PTR_CAST( ScDocShell, pSh );
+
+ if( pScSh )
+ {
+ pScSh->GetTitle();
+
+ if( pScSh->GetTitle() == aDocName )
+ {
+ nDoc = i;
+ ScDocument* pDestDoc = pScSh->GetDocument();
+ nTableCount = pDestDoc->GetTableCount();
+ bDoIt = pDestDoc->IsDocEditable();
+ break;
+ }
+
+ i++; // nur die ScDocShell's zaehlen
+ }
+ pSh = SfxObjectShell::GetNext( *pSh );
+ }
+ }
+ else // Kein Dokumentname -> neues Dokument
+ {
+ nDoc = SC_DOC_NEW;
+ bDoIt = TRUE;
+ }
+
+ if ( bDoIt && nTab >= nTableCount ) // ggf. anhaengen
+ nTab = SC_TAB_APPEND;
+ }
+ else
+ {
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+
+ AbstractScMoveTableDlg* pDlg = pFact->CreateScMoveTableDlg( GetDialogParent(), RID_SCDLG_MOVETAB );
+ DBG_ASSERT(pDlg, "Dialog create fail!");
+
+ SCTAB nTableCount = pDoc->GetTableCount();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+
+ if(nTableCount==nTabSelCount)
+ {
+ pDlg->SetCopyTable();
+ pDlg->EnableCopyTable(FALSE);
+ }
+ if ( pDlg->Execute() == RET_OK )
+ {
+ nDoc = pDlg->GetSelectedDocument();
+ nTab = pDlg->GetSelectedTable();
+ bCpy = pDlg->GetCopyTable();
+ bDoIt = TRUE;
+
+ String aFoundDocName;
+ if ( nDoc != SC_DOC_NEW )
+ {
+ ScDocShell* pSh = ScDocShell::GetShellByNum( nDoc );
+ if (pSh)
+ {
+ aFoundDocName = pSh->GetTitle();
+ if ( !pSh->GetDocument()->IsDocEditable() )
+ {
+ ErrorMessage(STR_READONLYERR);
+ bDoIt = FALSE;
+ }
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_TAB_MOVE, aFoundDocName ) );
+ // Tabelle ist 1-basiert, wenn nicht APPEND
+ SCTAB nBasicTab = ( nTab <= MAXTAB ) ? (nTab+1) : nTab;
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nBasicTab) ) );
+ rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bCpy ) );
+ }
+ delete pDlg;
+ }
+
+ if( bDoIt )
+ {
+ rReq.Done(); // aufzeichnen, solange das Dokument noch aktiv ist
+
+ MoveTable( nDoc, nTab, bCpy );
+ }
+ }
+ break;
+
+ case FID_DELETE_TABLE:
+ {
+ // Parameter war ueberfluessig, weil die Methode an der Table haengt
+
+ BOOL bDoIt = rReq.IsAPI();
+ if( !bDoIt )
+ {
+ // wenn's nicht von Basic kommt, nochmal nachfragen:
+
+#if ENABLE_LAYOUT
+// Using layout::QueryBox without client code modification is
+// deprecated, rather add HIG-complient buttons with verbs.
+#define QueryBox( parent, winbits, question ) layout::QueryBox (parent, question, ScGlobal::GetRscString (STR_UNDO_DELETE_TAB))
+#endif /* ENABLE_LAYOUT */
+
+ bDoIt = ( RET_YES ==
+ QueryBox( GetDialogParent(),
+ WinBits( WB_YES_NO | WB_DEF_YES ),
+ ScGlobal::GetRscString(STR_QUERY_DELTAB)
+ ).Execute() );
+ }
+ if( bDoIt )
+ {
+ SCTAB nNewTab = nCurrentTab;
+ SCTAB nFirstTab=0;
+ BOOL bTabFlag=FALSE;
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SvShorts TheTabs;
+ for(SCTAB i=0;i<nTabCount;i++)
+ {
+ if(rMark.GetTableSelect(i) &&!pDoc->IsTabProtected(i))
+ {
+ TheTabs.Insert(i,TheTabs.Count());
+ bTabFlag=TRUE;
+ if(nNewTab==i) nNewTab++;
+ }
+ if(!bTabFlag) nFirstTab=i;
+ }
+ if(nNewTab>=nTabCount) nNewTab=nFirstTab;
+
+ pViewData->SetTabNo(nNewTab);
+ DeleteTables(TheTabs);
+ TheTabs.Remove(0,TheTabs.Count());
+ rReq.Done();
+ }
+ }
+ break;
+
+ case FID_TAB_RTL:
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocFunc aFunc(*pDocSh);
+ BOOL bSet = !pDoc->IsLayoutRTL( nCurrentTab );
+
+ const ScMarkData& rMark = pViewData->GetMarkData();
+ if ( rMark.GetSelectCount() != 0 )
+ {
+ // handle several sheets
+
+ SfxUndoManager* pUndoManager = pDocSh->GetUndoManager();
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_TAB_RTL );
+ pUndoManager->EnterListAction( aUndo, aUndo );
+
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if ( rMark.GetTableSelect(nTab) )
+ aFunc.SetLayoutRTL( nTab, bSet, FALSE );
+
+ pUndoManager->LeaveListAction();
+ }
+ else
+ aFunc.SetLayoutRTL( nCurrentTab, bSet, FALSE );
+ }
+ break;
+
+ case FID_TAB_TOGGLE_GRID:
+ {
+ bool bShowGrid = pViewData->GetShowGrid();
+ pViewData->SetShowGrid(!bShowGrid);
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( FID_TAB_TOGGLE_GRID );
+ PaintGrid();
+ rReq.Done();
+ }
+ break;
+
+ case FID_TAB_SET_TAB_BG_COLOR:
+ case FID_TAB_MENU_SET_TAB_BG_COLOR:
+ {
+ if ( nSlot == FID_TAB_MENU_SET_TAB_BG_COLOR )
+ nSlot = FID_TAB_SET_TAB_BG_COLOR;
+ SCTAB nTabNr = pViewData->GetTabNo();
+ ScMarkData& rMark = pViewData->GetMarkData();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+ if ( !pDoc->IsDocEditable() )
+ break;
+
+ if ( pDoc->IsTabProtected( nTabNr ) ) // ||nTabSelCount > 1
+ break;
+
+ if( pReqArgs != NULL )
+ {
+ BOOL bDone = FALSE;
+ const SfxPoolItem* pItem;
+ Color aColor;
+ if( IS_AVAILABLE( FN_PARAM_1, &pItem ) )
+ nTabNr = ((const SfxUInt16Item*)pItem)->GetValue();
+
+ if( IS_AVAILABLE( nSlot, &pItem ) )
+ aColor = ((const SvxColorItem*)pItem)->GetValue();
+
+ if ( nTabSelCount > 1 )
+ {
+ scoped_ptr<ScUndoTabColorInfo::List>
+ pTabColorList(new ScUndoTabColorInfo::List);
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ if ( rMark.GetTableSelect(nTab) && !pDoc->IsTabProtected(nTab) )
+ {
+ ScUndoTabColorInfo aTabColorInfo(nTab);
+ aTabColorInfo.maNewTabBgColor = aColor;
+ pTabColorList->push_back(aTabColorInfo);
+ }
+ }
+ bDone = SetTabBgColor( *pTabColorList );
+ }
+ else
+ {
+ bDone = SetTabBgColor( aColor, nCurrentTab ); //ScViewFunc.SetTabBgColor
+ }
+ if( bDone )
+ {
+ rReq.Done( *pReqArgs );
+ }
+ }
+ else
+ {
+ USHORT nRet = RET_OK; /// temp
+ BOOL bDone = FALSE; /// temp
+ Color aTabBgColor;
+ Color aNewTabBgColor;
+
+ aTabBgColor = pDoc->GetTabBgColor( nCurrentTab );
+ ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "ScAbstractFactory create fail!");
+ AbstractScTabBgColorDlg* pDlg = pFact->CreateScTabBgColorDlg(
+ GetDialogParent(),
+ String(ScResId(SCSTR_SET_TAB_BG_COLOR)),
+ String(ScResId(SCSTR_NO_TAB_BG_COLOR)),
+ aTabBgColor,
+ nSlot,RID_SCDLG_TAB_BG_COLOR);
+ while ( !bDone && nRet == RET_OK )
+ {
+ nRet = pDlg->Execute();
+ if( nRet == RET_OK )
+ {
+ Color aSelectedColor;
+ pDlg->GetSelectedColor(aSelectedColor);
+ scoped_ptr<ScUndoTabColorInfo::List>
+ pTabColorList(new ScUndoTabColorInfo::List);
+ if ( nTabSelCount > 1 )
+ {
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ if ( rMark.GetTableSelect(nTab) && !pDoc->IsTabProtected(nTab) )
+ {
+ ScUndoTabColorInfo aTabColorInfo(nTab);
+ aTabColorInfo.maNewTabBgColor = aSelectedColor;
+ pTabColorList->push_back(aTabColorInfo);
+ }
+ }
+ bDone = SetTabBgColor( *pTabColorList );
+ }
+ else
+ {
+ bDone = SetTabBgColor( aSelectedColor, nCurrentTab ); //ScViewFunc.SetTabBgColor
+ }
+ if ( bDone )
+ {
+ rReq.AppendItem( SvxColorItem( aTabBgColor, nSlot ) );
+ rReq.Done();
+ }
+ else
+ {
+ if( rReq.IsAPI() )
+ {
+ StarBASIC::Error( SbERR_SETPROP_FAILED );
+ }
+ }
+ }
+ }
+ delete( pDlg );
+ }
+ }
+ break;
+
+ case FID_TAB_EVENTS:
+ {
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ uno::Reference<container::XNameReplace> xEvents( new ScSheetEventsObj( pDocSh, nCurrentTab ) );
+ uno::Reference<frame::XFrame> xFrame = GetViewFrame()->GetFrame().GetFrameInterface();
+ SvxAbstractDialogFactory* pDlgFactory = SvxAbstractDialogFactory::Create();
+ if (pDlgFactory)
+ {
+ std::auto_ptr<VclAbstractDialog> pDialog( pDlgFactory->CreateSvxMacroAssignDlg(
+ GetDialogParent(), xFrame, false, xEvents, 0 ) );
+ if ( pDialog.get() && pDialog->Execute() == RET_OK )
+ {
+ // the dialog modifies the settings directly
+ }
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR("Unbekannte Message bei ViewShell");
+ break;
+ }
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::GetStateTable( SfxItemSet& rSet )
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDocShell* pDocShell = pViewData->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+
+ while ( nWhich )
+ {
+ switch ( nWhich )
+ {
+
+ case FID_TABLE_VISIBLE:
+ rSet.Put( SfxBoolItem( nWhich, pDoc->IsVisible(nTab) ));
+ break;
+
+ case FID_TABLE_HIDE:
+ {
+ USHORT nVis = 0;
+ for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
+ if (pDoc->IsVisible(i))
+ ++nVis;
+
+ if ( nVis<2 || !pDoc->IsDocEditable() || nTabSelCount > 1 )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FID_TABLE_SHOW:
+ {
+ BOOL bHasHidden = FALSE;
+ for ( SCTAB i=0; i < nTabCount && !bHasHidden; i++ )
+ if (!pDoc->IsVisible(i))
+ bHasHidden = TRUE;
+ if ( !bHasHidden || pDoc->IsDocProtected() || nTabSelCount > 1 )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FID_DELETE_TABLE:
+ {
+ if ( pDoc->GetChangeTrack() )
+ rSet.DisableItem( nWhich );
+ else
+ {
+ USHORT nVis = 0;
+ for ( SCTAB i=0; i < nTabCount && nVis<2; i++ )
+ if (pDoc->IsVisible(i))
+ ++nVis;
+ if ( pDoc->IsTabProtected(nTab)
+ || !pDoc->IsDocEditable()
+ || nVis < 2
+ || nTabSelCount == nTabCount)
+ rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case FID_INS_TABLE:
+ case FID_INS_TABLE_EXT:
+ case FID_TAB_APPEND:
+ if ( !pDoc->IsDocEditable() ||
+ nTabCount > MAXTAB ||
+ ( nWhich == FID_INS_TABLE_EXT && pDocShell && pDocShell->IsDocShared() ) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_TAB_MOVE:
+ if ( !pDoc->IsDocEditable()
+ || pDoc->GetChangeTrack() != NULL
+ || nTabCount > MAXTAB)
+ rSet.DisableItem( nWhich );
+ break;
+
+ // FID_TAB_MENU_RENAME - "umbenennen" im Menu
+ // FID_TAB_RENAME - "Name"-Property fuer Basic
+
+ case FID_TAB_MENU_RENAME:
+ if ( !pDoc->IsDocEditable() ||
+ pDoc->IsTabProtected(nTab) ||nTabSelCount > 1 ||
+ ( pDocShell && pDocShell->IsDocShared() ) )
+ rSet.DisableItem( nWhich );
+ break;
+
+ case FID_TAB_RENAME:
+ {
+ String aTabName;
+ pDoc->GetName( nTab, aTabName );
+
+ rSet.Put( SfxStringItem( nWhich, aTabName ));
+
+ }
+ break;
+
+ case FID_TAB_RTL:
+ {
+ SvtLanguageOptions aLangOpt;
+ if ( !aLangOpt.IsCTLFontEnabled() )
+ rSet.DisableItem( nWhich );
+ else
+ rSet.Put( SfxBoolItem( nWhich, pDoc->IsLayoutRTL( nTab ) ) );
+ }
+ break;
+
+ case FID_TAB_MENU_SET_TAB_BG_COLOR:
+ {
+ if ( !pDoc->IsDocEditable()
+ || ( pDocShell && pDocShell->IsDocShared() )
+ || pDoc->IsTabProtected(nTab) )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case FID_TAB_SET_TAB_BG_COLOR:
+ {
+ Color aColor;
+ aColor = pDoc->GetTabBgColor( nTab );
+ rSet.Put( SvxColorItem( aColor, nWhich ) );
+ }
+ break;
+
+ case FID_TAB_TOGGLE_GRID:
+ rSet.Put( SfxBoolItem(nWhich, pViewData->GetShowGrid()) );
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshg.cxx b/sc/source/ui/view/tabvwshg.cxx
new file mode 100644
index 000000000000..c937109baa99
--- /dev/null
+++ b/sc/source/ui/view/tabvwshg.cxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+//#define SI_VCDRAWOBJ
+
+#include <tools/urlobj.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpagv.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/docfile.hxx>
+
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+
+using namespace com::sun::star;
+
+#include "tabvwsh.hxx"
+#include "document.hxx"
+#include "drawview.hxx"
+#include "globstr.hrc"
+#include <avmedia/mediawindow.hxx>
+
+//------------------------------------------------------------------------
+
+void ScTabViewShell::InsertURLButton( const String& rName, const String& rURL,
+ const String& rTarget,
+ const Point* pInsPos )
+{
+ // Tabelle geschuetzt ?
+
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCTAB nTab = pViewData->GetTabNo();
+ if ( pDoc->IsTabProtected(nTab) )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ MakeDrawLayer();
+
+ ScTabView* pView = pViewData->GetView();
+// SdrView* pDrView = pView->GetSdrView();
+ ScDrawView* pDrView = pView->GetScDrawView();
+ SdrModel* pModel = pDrView->GetModel();
+
+ SdrObject* pObj = SdrObjFactory::MakeNewObject(FmFormInventor, OBJ_FM_BUTTON,
+ pDrView->GetSdrPageView()->GetPage(), pModel);
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj);
+
+ uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel();
+ DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" );
+ if( !xControlModel.is() )
+ return;
+
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
+ uno::Any aAny;
+
+ aAny <<= rtl::OUString(rName);
+ xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "Label" ), aAny );
+
+ ::rtl::OUString aTmp = INetURLObject::GetAbsURL( pDoc->GetDocumentShell()->GetMedium()->GetBaseURL(), rURL );
+ aAny <<= aTmp;
+ xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "TargetURL" ), aAny );
+
+ if( rTarget.Len() )
+ {
+ aAny <<= rtl::OUString(rTarget);
+ xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "TargetFrame" ), aAny );
+ }
+
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ aAny <<= eButtonType;
+ xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "ButtonType" ), aAny );
+
+ if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
+ {
+ // #105638# OJ
+ aAny <<= sal_True;
+ xPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), aAny );
+ }
+
+ Point aPos;
+ if (pInsPos)
+ aPos = *pInsPos;
+ else
+ aPos = GetInsertPos();
+
+ // Groesse wie in 3.1:
+ Size aSize = GetActiveWin()->PixelToLogic(Size(140, 20));
+
+ if ( pDoc->IsNegativePage(nTab) )
+ aPos.X() -= aSize.Width();
+
+ pObj->SetLogicRect(Rectangle(aPos, aSize));
+// pObj->Resize(Point(), Fraction(1, 1), Fraction(1, 1));
+
+ // am alten VC-Button musste die Position/Groesse nochmal explizit
+ // gesetzt werden - das scheint mit UnoControls nicht noetig zu sein
+
+ // nicht markieren wenn Ole
+ pDrView->InsertObjectSafe( pObj, *pDrView->GetSdrPageView() );
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshh.cxx b/sc/source/ui/view/tabvwshh.cxx
new file mode 100644
index 000000000000..e536781a841f
--- /dev/null
+++ b/sc/source/ui/view/tabvwshh.cxx
@@ -0,0 +1,295 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svdmark.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdview.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <basic/sbxcore.hxx>
+#include <svl/whiter.hxx>
+#include <vcl/msgbox.hxx>
+
+#include "tabvwsh.hxx"
+#include "client.hxx"
+#include "document.hxx"
+#include "docsh.hxx"
+#include "sc.hrc"
+#include "drwlayer.hxx" // GetVisibleName
+#include "retypepassdlg.hxx"
+#include "tabprotection.hxx"
+
+#include <memory>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecuteSbx( SfxRequest& /* rReq */ )
+{
+ // SID_RANGE_OFFSET (Offset),
+ // SID_PIVOT_CREATE (DataPilotCreate) - removed (old Basic)
+}
+
+void ScTabViewShell::GetSbxState( SfxItemSet& /* rSet */ )
+{
+ // SID_RANGE_REGION (CurrentRegion) - removed (old Basic)
+}
+
+//------------------------------------------------------------------
+
+void ScTabViewShell::ExecuteObject( SfxRequest& rReq )
+{
+ USHORT nSlotId = rReq.GetSlot();
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ // Objekte aktivieren/deaktivieren immer auf der sichtbaren View
+
+ ScTabViewShell* pVisibleSh = this;
+ if ( nSlotId == SID_OLE_SELECT || nSlotId == SID_OLE_ACTIVATE || nSlotId == SID_OLE_DEACTIVATE )
+ {
+ DBG_ERROR("old slot SID_OLE...");
+ }
+
+ switch (nSlotId)
+ {
+ case SID_OLE_SELECT:
+ case SID_OLE_ACTIVATE:
+ {
+ // in beiden Faellen erstmal auf der sichtbaren View selektieren
+
+ String aName;
+ SdrView* pDrView = GetSdrView();
+ if (pDrView)
+ {
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ aName = ScDrawLayer::GetVisibleName( rMarkList.GetMark(0)->GetMarkedSdrObj() );
+ }
+ pVisibleSh->SelectObject( aName );
+
+ // aktivieren
+
+ if ( nSlotId == SID_OLE_ACTIVATE )
+ pVisibleSh->DoVerb( 0 );
+ }
+ break;
+ case SID_OLE_DEACTIVATE:
+ pVisibleSh->DeactivateOle();
+ break;
+
+ case SID_OBJECT_LEFT:
+ case SID_OBJECT_TOP:
+ case SID_OBJECT_WIDTH:
+ case SID_OBJECT_HEIGHT:
+ {
+ BOOL bDone = FALSE;
+ const SfxPoolItem* pItem;
+ if ( pReqArgs && pReqArgs->GetItemState( nSlotId, TRUE, &pItem ) == SFX_ITEM_SET )
+ {
+ long nNewVal = ((const SfxInt32Item*)pItem)->GetValue();
+ if ( nNewVal < 0 )
+ nNewVal = 0;
+
+ //! von irgendwas in 1/100mm umrechnen ??????
+
+ SdrView* pDrView = GetSdrView();
+ if ( pDrView )
+ {
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ Rectangle aRect = pObj->GetLogicRect();
+
+ if ( nSlotId == SID_OBJECT_LEFT )
+ pDrView->MoveMarkedObj( Size( nNewVal - aRect.Left(), 0 ) );
+ else if ( nSlotId == SID_OBJECT_TOP )
+ pDrView->MoveMarkedObj( Size( 0, nNewVal - aRect.Top() ) );
+ else if ( nSlotId == SID_OBJECT_WIDTH )
+ pDrView->ResizeMarkedObj( aRect.TopLeft(),
+ Fraction( nNewVal, aRect.GetWidth() ),
+ Fraction( 1, 1 ) );
+ else // if ( nSlotId == SID_OBJECT_HEIGHT )
+ pDrView->ResizeMarkedObj( aRect.TopLeft(),
+ Fraction( 1, 1 ),
+ Fraction( nNewVal, aRect.GetHeight() ) );
+ bDone = TRUE;
+ }
+ }
+ }
+ if (!bDone)
+ SbxBase::SetError( SbxERR_BAD_PARAMETER ); // Basic-Fehler
+ }
+ break;
+
+ }
+}
+
+uno::Reference < embed::XEmbeddedObject > lcl_GetSelectedObj( SdrView* pDrView ) //! Member von ScDrawView?
+{
+ uno::Reference < embed::XEmbeddedObject > xRet;
+ if (pDrView)
+ {
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if (pObj->GetObjIdentifier() == OBJ_OLE2)
+ {
+ SdrOle2Obj* pOle2Obj = (SdrOle2Obj*) pObj;
+ xRet = pOle2Obj->GetObjRef();
+ }
+ }
+ }
+
+ return xRet;
+}
+
+void ScTabViewShell::GetObjectState( SfxItemSet& rSet )
+{
+ // SID_OLE_OBJECT - removed (old Basic)
+
+ SfxWhichIter aIter(rSet);
+ USHORT nWhich = aIter.FirstWhich();
+ while ( nWhich )
+ {
+ switch (nWhich)
+ {
+ case SID_ACTIVE_OBJ_NAME:
+ {
+ String aName;
+ uno::Reference < embed::XEmbeddedObject > xOLE = lcl_GetSelectedObj( GetSdrView() );
+ if (xOLE.is())
+ {
+ aName = GetViewData()->GetSfxDocShell()->GetEmbeddedObjectContainer().GetEmbeddedObjectName( xOLE );
+ }
+ rSet.Put( SfxStringItem( nWhich, aName ) );
+ }
+ break;
+ case SID_OBJECT_LEFT:
+ case SID_OBJECT_TOP:
+ case SID_OBJECT_WIDTH:
+ case SID_OBJECT_HEIGHT:
+ {
+ SdrView* pDrView = GetSdrView();
+ if ( pDrView )
+ {
+ const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList();
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ Rectangle aRect = pObj->GetLogicRect();
+
+ long nVal;
+ if ( nWhich == SID_OBJECT_LEFT )
+ nVal = aRect.Left();
+ else if ( nWhich == SID_OBJECT_TOP )
+ nVal = aRect.Top();
+ else if ( nWhich == SID_OBJECT_WIDTH )
+ nVal = aRect.GetWidth();
+ else // if ( nWhich == SID_OBJECT_HEIGHT )
+ nVal = aRect.GetHeight();
+
+ //! von 1/100mm in irgendwas umrechnen ??????
+
+ rSet.Put( SfxInt32Item( nWhich, nVal ) );
+ }
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+void ScTabViewShell::AddAccessibilityObject( SfxListener& rObject )
+{
+ if (!pAccessibilityBroadcaster)
+ pAccessibilityBroadcaster = new SfxBroadcaster;
+
+ rObject.StartListening( *pAccessibilityBroadcaster );
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if (pDoc)
+ pDoc->AddUnoObject(rObject);
+}
+
+void ScTabViewShell::RemoveAccessibilityObject( SfxListener& rObject )
+{
+ if (pAccessibilityBroadcaster)
+ {
+ rObject.EndListening( *pAccessibilityBroadcaster );
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if (pDoc)
+ pDoc->RemoveUnoObject(rObject);
+ }
+ else
+ {
+ DBG_ERROR("kein Accessibility-Broadcaster?");
+ }
+}
+
+void ScTabViewShell::BroadcastAccessibility( const SfxHint &rHint )
+{
+ if (pAccessibilityBroadcaster)
+ pAccessibilityBroadcaster->Broadcast( rHint );
+}
+
+BOOL ScTabViewShell::HasAccessibilityObjects()
+{
+ return pAccessibilityBroadcaster != NULL;
+}
+
+bool ScTabViewShell::ExecuteRetypePassDlg(ScPasswordHash eDesiredHash)
+{
+ using ::std::auto_ptr;
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ auto_ptr<ScRetypePassDlg> pDlg(new ScRetypePassDlg(GetDialogParent()));
+ pDlg->SetDataFromDocument(*pDoc);
+ pDlg->SetDesiredHash(eDesiredHash);
+ if (pDlg->Execute() != RET_OK)
+ return false;
+
+ pDlg->WriteNewDataToDocument(*pDoc);
+ return true;
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
new file mode 100644
index 000000000000..a73247266067
--- /dev/null
+++ b/sc/source/ui/view/viewdata.cxx
@@ -0,0 +1,3118 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+
+#include <sfx2/viewfrm.hxx>
+#include <editeng/adjitem.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/brshitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/justifyitem.hxx>
+
+#include <vcl/svapp.hxx>
+#include <rtl/math.hxx>
+
+#include "viewdata.hxx"
+#include "docoptio.hxx"
+#include "scmod.hxx"
+#include "global.hxx"
+#include "document.hxx"
+#include "attrib.hxx"
+#include "tabview.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "sc.hrc"
+#include "patattr.hxx"
+#include "editutil.hxx"
+#include "scextopt.hxx"
+#include "miscuno.hxx"
+#include "unonames.hxx"
+#include "inputopt.hxx"
+#include "viewutil.hxx"
+#include <xmloff/xmluconv.hxx>
+#include "ViewSettingsSequenceDefines.hxx"
+#include <rtl/ustrbuf.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+
+using namespace com::sun::star;
+
+#define SC_GROWY_SMALL_EXTRA 100
+#define SC_GROWY_BIG_EXTRA 200
+
+#define TAG_TABBARWIDTH "tw:"
+
+static BOOL bMoveArea = FALSE; //! Member?
+USHORT nEditAdjust = SVX_ADJUST_LEFT; //! Member !!!
+
+ScViewDataTable::ScViewDataTable() :
+ eZoomType( SVX_ZOOM_PERCENT ),
+ aZoomX( 1,1 ),
+ aZoomY( 1,1 ),
+ aPageZoomX( 3,5 ), // Page-Default: 60%
+ aPageZoomY( 3,5 ),
+ nHSplitPos( 0 ),
+ nVSplitPos( 0 ),
+ eHSplitMode( SC_SPLIT_NONE ),
+ eVSplitMode( SC_SPLIT_NONE ),
+ eWhichActive( SC_SPLIT_BOTTOMLEFT ),
+ nFixPosX( 0 ),
+ nFixPosY( 0 ),
+ nCurX( 0 ),
+ nCurY( 0 ),
+ bShowGrid( true ),
+ bOldCurValid( FALSE )
+{
+ nPosX[0]=nPosX[1]=0;
+ nPosY[0]=nPosY[1]=0;
+ nTPosX[0]=nTPosX[1]=0;
+ nTPosY[0]=nTPosY[1]=0;
+ nMPosX[0]=nMPosX[1]=0;
+ nMPosY[0]=nMPosY[1]=0;
+ nPixPosX[0]=nPixPosX[1]=0;
+ nPixPosY[0]=nPixPosY[1]=0;
+}
+
+ScViewDataTable::~ScViewDataTable()
+{
+}
+
+void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& /*rViewData*/, SCTAB /*nTab*/)
+{
+ rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
+ beans::PropertyValue* pSettings = rSettings.getArray();
+ if (pSettings)
+ {
+ pSettings[SC_CURSOR_X].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONX));
+ pSettings[SC_CURSOR_X].Value <<= sal_Int32(nCurX);
+ pSettings[SC_CURSOR_Y].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_CURSORPOSITIONY));
+ pSettings[SC_CURSOR_Y].Value <<= sal_Int32(nCurY);
+ pSettings[SC_HORIZONTAL_SPLIT_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITMODE));
+ pSettings[SC_HORIZONTAL_SPLIT_MODE].Value <<= sal_Int16(eHSplitMode);
+ pSettings[SC_VERTICAL_SPLIT_MODE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITMODE));
+ pSettings[SC_VERTICAL_SPLIT_MODE].Value <<= sal_Int16(eVSplitMode);
+ pSettings[SC_HORIZONTAL_SPLIT_POSITION].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSPLITPOSITION));
+ if (eHSplitMode == SC_SPLIT_FIX)
+ pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosX);
+ else
+ pSettings[SC_HORIZONTAL_SPLIT_POSITION].Value <<= sal_Int32(nHSplitPos);
+ pSettings[SC_VERTICAL_SPLIT_POSITION].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VERTICALSPLITPOSITION));
+ if (eVSplitMode == SC_SPLIT_FIX)
+ pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nFixPosY);
+ else
+ pSettings[SC_VERTICAL_SPLIT_POSITION].Value <<= sal_Int32(nVSplitPos);
+ pSettings[SC_ACTIVE_SPLIT_RANGE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVESPLITRANGE));
+ pSettings[SC_ACTIVE_SPLIT_RANGE].Value <<= sal_Int16(eWhichActive);
+ pSettings[SC_POSITION_LEFT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONLEFT));
+ pSettings[SC_POSITION_LEFT].Value <<= sal_Int32(nPosX[SC_SPLIT_LEFT]);
+ pSettings[SC_POSITION_RIGHT].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONRIGHT));
+ pSettings[SC_POSITION_RIGHT].Value <<= sal_Int32(nPosX[SC_SPLIT_RIGHT]);
+ pSettings[SC_POSITION_TOP].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONTOP));
+ pSettings[SC_POSITION_TOP].Value <<= sal_Int32(nPosY[SC_SPLIT_TOP]);
+ pSettings[SC_POSITION_BOTTOM].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_POSITIONBOTTOM));
+ pSettings[SC_POSITION_BOTTOM].Value <<= sal_Int32(nPosY[SC_SPLIT_BOTTOM]);
+
+ sal_Int32 nZoomValue ((aZoomY.GetNumerator() * 100) / aZoomY.GetDenominator());
+ sal_Int32 nPageZoomValue ((aPageZoomY.GetNumerator() * 100) / aPageZoomY.GetDenominator());
+ pSettings[SC_TABLE_ZOOM_TYPE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
+ pSettings[SC_TABLE_ZOOM_TYPE].Value <<= sal_Int16(eZoomType);
+ pSettings[SC_TABLE_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
+ pSettings[SC_TABLE_ZOOM_VALUE].Value <<= nZoomValue;
+ pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
+ pSettings[SC_TABLE_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
+
+ pSettings[SC_TABLE_SHOWGRID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
+ pSettings[SC_TABLE_SHOWGRID].Value <<= static_cast<sal_Bool>(bShowGrid);
+ }
+}
+
+void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& aSettings, ScViewData& rViewData, SCTAB nTab, bool& rHasZoom )
+{
+ rHasZoom = false;
+
+ sal_Int32 nCount(aSettings.getLength());
+ sal_Int32 nTemp32(0);
+ sal_Int16 nTemp16(0);
+ sal_Int32 nTempPosV(0);
+ sal_Int32 nTempPosH(0);
+ sal_Int32 nTempPosVTw(0);
+ sal_Int32 nTempPosHTw(0);
+ bool bHasVSplitInTwips = false;
+ bool bHasHSplitInTwips = false;
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ rtl::OUString sName(aSettings[i].Name);
+ if (sName.compareToAscii(SC_CURSORPOSITIONX) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ nCurX = SanitizeCol( static_cast<SCCOL>(nTemp32));
+ }
+ else if (sName.compareToAscii(SC_CURSORPOSITIONY) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ nCurY = SanitizeRow( static_cast<SCROW>(nTemp32));
+ }
+ else if (sName.compareToAscii(SC_HORIZONTALSPLITMODE) == 0)
+ {
+ aSettings[i].Value >>= nTemp16;
+ eHSplitMode = static_cast<ScSplitMode>(nTemp16);
+ }
+ else if (sName.compareToAscii(SC_VERTICALSPLITMODE) == 0)
+ {
+ aSettings[i].Value >>= nTemp16;
+ eVSplitMode = static_cast<ScSplitMode>(nTemp16);
+ }
+ else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION) == 0)
+ {
+ aSettings[i].Value >>= nTempPosH;
+ bHasHSplitInTwips = false;
+ }
+ else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION) == 0)
+ {
+ aSettings[i].Value >>= nTempPosV;
+ bHasVSplitInTwips = false;
+ }
+ else if (sName.compareToAscii(SC_HORIZONTALSPLITPOSITION_TWIPS) == 0)
+ {
+ aSettings[i].Value >>= nTempPosHTw;
+ bHasHSplitInTwips = true;
+ }
+ else if (sName.compareToAscii(SC_VERTICALSPLITPOSITION_TWIPS) == 0)
+ {
+ aSettings[i].Value >>= nTempPosVTw;
+ bHasVSplitInTwips = true;
+ }
+ else if (sName.compareToAscii(SC_ACTIVESPLITRANGE) == 0)
+ {
+ aSettings[i].Value >>= nTemp16;
+ eWhichActive = static_cast<ScSplitPos>(nTemp16);
+ }
+ else if (sName.compareToAscii(SC_POSITIONLEFT) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ nPosX[SC_SPLIT_LEFT] = SanitizeCol( static_cast<SCCOL>(nTemp32));
+ }
+ else if (sName.compareToAscii(SC_POSITIONRIGHT) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ nPosX[SC_SPLIT_RIGHT] = SanitizeCol( static_cast<SCCOL>(nTemp32));
+ }
+ else if (sName.compareToAscii(SC_POSITIONTOP) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ nPosY[SC_SPLIT_TOP] = SanitizeRow( static_cast<SCROW>(nTemp32));
+ }
+ else if (sName.compareToAscii(SC_POSITIONBOTTOM) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ nPosY[SC_SPLIT_BOTTOM] = SanitizeRow( static_cast<SCROW>(nTemp32));
+ }
+ else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
+ {
+ aSettings[i].Value >>= nTemp16;
+ eZoomType = SvxZoomType(nTemp16);
+ rHasZoom = true; // set if there is any zoom information
+ }
+ else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ Fraction aZoom(nTemp32, 100);
+ aZoomX = aZoomY = aZoom;
+ rHasZoom = true;
+ }
+ else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
+ {
+ aSettings[i].Value >>= nTemp32;
+ Fraction aZoom(nTemp32, 100);
+ aPageZoomX = aPageZoomY = aZoom;
+ rHasZoom = true;
+ }
+ else if (sName.compareToAscii(SC_UNO_SHOWGRID) == 0)
+ {
+ aSettings[i].Value >>= bShowGrid;
+ }
+ else if (sName.compareToAscii(SC_TABLESELECTED) == 0)
+ {
+ bool bSelected = false;
+ aSettings[i].Value >>= bSelected;
+ rViewData.GetMarkData().SelectTable( nTab, bSelected );
+ }
+ else if (sName.compareToAscii(SC_UNONAME_TABCOLOR) == 0)
+ {
+ // There are documents out there that have their tab color defined as a view setting.
+ sal_Int32 nColor = COL_AUTO;
+ aSettings[i].Value >>= nColor;
+ if (static_cast<ColorData>(nColor) != COL_AUTO)
+ {
+ ScDocument* pDoc = rViewData.GetDocument();
+ pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor)));
+ }
+ }
+ }
+ if (eHSplitMode == SC_SPLIT_FIX)
+ nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
+ else
+ nHSplitPos = bHasHSplitInTwips ? static_cast< long >( nTempPosHTw * rViewData.GetPPTX() ) : nTempPosH;
+
+ if (eVSplitMode == SC_SPLIT_FIX)
+ nFixPosY = SanitizeRow( static_cast<SCROW>( bHasVSplitInTwips ? nTempPosVTw : nTempPosV ));
+ else
+ nVSplitPos = bHasVSplitInTwips ? static_cast< long >( nTempPosVTw * rViewData.GetPPTY() ) : nTempPosV;
+}
+
+ScViewData::ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh )
+ : pDocShell ( pDocSh ),
+ pDoc ( NULL ),
+ pView ( pViewSh ),
+ pViewShell ( pViewSh ),
+ pOptions ( new ScViewOptions ),
+ pSpellingView ( NULL ),
+ aLogicMode ( MAP_100TH_MM ),
+ eDefZoomType( SVX_ZOOM_PERCENT ),
+ aDefZoomX ( 1,1 ),
+ aDefZoomY ( 1,1 ),
+ aDefPageZoomX( 3,5 ),
+ aDefPageZoomY( 3,5 ),
+ eRefType ( SC_REFTYPE_NONE ),
+ nTabNo ( 0 ),
+ nRefTabNo ( 0 ),
+ nPasteFlags ( SC_PASTE_NONE ),
+ eEditActivePart( SC_SPLIT_BOTTOMLEFT ),
+ bActive ( TRUE ), //! wie initialisieren?
+ bIsRefMode ( FALSE ),
+ bDelMarkValid( FALSE ),
+ nFillMode ( SC_FILL_NONE ),
+ bPagebreak ( FALSE ),
+ bSelCtrlMouseClick( FALSE )
+{
+
+ SetGridMode ( TRUE );
+ SetSyntaxMode ( FALSE );
+ SetHeaderMode ( TRUE );
+ SetTabMode ( TRUE );
+ SetVScrollMode ( TRUE );
+ SetHScrollMode ( TRUE );
+ SetOutlineMode ( TRUE );
+
+ aScrSize = Size( (long) ( STD_COL_WIDTH * PIXEL_PER_TWIPS * OLE_STD_CELLS_X ),
+ (long) ( ScGlobal::nStdRowHeight * PIXEL_PER_TWIPS * OLE_STD_CELLS_Y ) );
+ pTabData[0] = new ScViewDataTable;
+ for ( SCTAB i = 1; i <= MAXTAB; i++ )
+ pTabData[i] = NULL;
+ pThisTab = pTabData[nTabNo];
+ for (USHORT j=0; j<4; j++)
+ {
+ pEditView[j] = NULL;
+ bEditActive[j] = FALSE;
+ }
+
+ nEditEndCol = nEditStartCol = nEditCol = 0;
+ nEditEndRow = nEditRow = 0;
+ nTabStartCol = SC_TABSTART_NONE;
+
+ if (pDocShell)
+ {
+ pDoc = pDocShell->GetDocument();
+ *pOptions = pDoc->GetViewOptions();
+ }
+
+ // keine ausgeblendete Tabelle anzeigen:
+ if (pDoc && !pDoc->IsVisible(nTabNo))
+ {
+ while ( !pDoc->IsVisible(nTabNo) && pDoc->HasTable(nTabNo+1) )
+ ++nTabNo;
+
+ pTabData[nTabNo] = new ScViewDataTable;
+ pThisTab = pTabData[nTabNo];
+ }
+
+ CalcPPT();
+}
+
+ScViewData::ScViewData( const ScViewData& rViewData )
+ : pDocShell ( rViewData.pDocShell ),
+ pDoc ( rViewData.pDoc ),
+ pView ( rViewData.pView ),
+ pViewShell ( rViewData.pViewShell ),
+ pOptions ( new ScViewOptions( *(rViewData.pOptions) ) ),
+ pSpellingView ( rViewData.pSpellingView ),
+ aLogicMode ( rViewData.aLogicMode ),
+ eDefZoomType( rViewData.eDefZoomType ),
+ aDefZoomX ( rViewData.aDefZoomX ),
+ aDefZoomY ( rViewData.aDefZoomY ),
+ aDefPageZoomX( rViewData.aDefPageZoomX ),
+ aDefPageZoomY( rViewData.aDefPageZoomY ),
+ eRefType ( SC_REFTYPE_NONE ),
+ nTabNo ( rViewData.nTabNo ),
+ nRefTabNo ( rViewData.nTabNo ), // kein RefMode
+ eEditActivePart( rViewData.eEditActivePart ),
+ bActive ( TRUE ), //! wie initialisieren?
+ bIsRefMode ( FALSE ),
+ bDelMarkValid( FALSE ),
+ nFillMode ( SC_FILL_NONE ),
+ bPagebreak ( rViewData.bPagebreak ),
+ bSelCtrlMouseClick( rViewData.bSelCtrlMouseClick )
+{
+
+ SetGridMode ( rViewData.IsGridMode() );
+ SetSyntaxMode ( rViewData.IsSyntaxMode() );
+ SetHeaderMode ( rViewData.IsHeaderMode() );
+ SetTabMode ( rViewData.IsTabMode() );
+ SetVScrollMode ( rViewData.IsVScrollMode() );
+ SetHScrollMode ( rViewData.IsHScrollMode() );
+ SetOutlineMode ( rViewData.IsOutlineMode() );
+
+ aScrSize = rViewData.aScrSize;
+ for ( SCTAB i = 0; i <= MAXTAB; i++ )
+ if (rViewData.pTabData[i])
+ pTabData[i] = new ScViewDataTable( *rViewData.pTabData[i] );
+ else
+ pTabData[i] = NULL;
+ pThisTab = pTabData[nTabNo];
+ for (USHORT j=0; j<4; j++)
+ {
+ pEditView[j] = NULL;
+ bEditActive[j] = FALSE;
+ }
+
+ nEditEndCol = nEditStartCol = nEditCol = 0;
+ nEditEndRow = nEditRow = 0;
+ nTabStartCol = SC_TABSTART_NONE;
+ CalcPPT();
+}
+
+void ScViewData::InitData( ScDocument* pDocument )
+{
+ pDoc = pDocument;
+ *pOptions = pDoc->GetViewOptions();
+}
+
+
+ScDocument* ScViewData::GetDocument() const
+{
+ if (pDoc)
+ return pDoc;
+ else if (pDocShell)
+ return pDocShell->GetDocument();
+
+ DBG_ERROR("kein Document an ViewData");
+ return NULL;
+}
+
+ScViewData::~ScViewData()
+{
+ for (SCTAB i=0; i<=MAXTAB; i++)
+ if (pTabData[i])
+ delete pTabData[i];
+
+ KillEditView();
+ delete pOptions;
+}
+
+void ScViewData::UpdateThis()
+{
+ do
+ {
+ pThisTab = pTabData[nTabNo];
+ if (!pThisTab)
+ {
+ if (nTabNo>0)
+ --nTabNo;
+ else
+ pThisTab = pTabData[0] = new ScViewDataTable;
+
+ // hier keine Assertion, weil sonst Paints kommen, bevor alles initialisiert ist!
+ }
+ }
+ while (!pThisTab);
+}
+
+void ScViewData::InsertTab( SCTAB nTab )
+{
+ delete pTabData[MAXTAB];
+
+ for (SCTAB i=MAXTAB; i>nTab; i--)
+ pTabData[i] = pTabData[i-1];
+
+ pTabData[nTab] = NULL; // force creating new
+ CreateTabData( nTab );
+
+ UpdateThis();
+ aMarkData.InsertTab( nTab );
+}
+
+void ScViewData::DeleteTab( SCTAB nTab )
+{
+ delete pTabData[nTab];
+
+ for (SCTAB i=nTab; i<MAXTAB; i++)
+ pTabData[i] = pTabData[i+1];
+
+ pTabData[MAXTAB] = NULL;
+
+ UpdateThis();
+ aMarkData.DeleteTab( nTab );
+}
+
+void ScViewData::CopyTab( SCTAB nSrcTab, SCTAB nDestTab )
+{
+ if (nDestTab==SC_TAB_APPEND)
+ nDestTab = pDoc->GetTableCount() - 1; // am Doc muss vorher kopiert worden sein
+
+ if (nDestTab > MAXTAB)
+ {
+ DBG_ERROR("Zuviele Tabellen");
+ return;
+ }
+
+ delete pTabData[MAXTAB];
+
+ for (SCTAB i=MAXTAB; i>nDestTab; i--)
+ pTabData[i] = pTabData[i-1];
+
+ if ( pTabData[nSrcTab] )
+ pTabData[nDestTab] = new ScViewDataTable( *pTabData[nSrcTab] );
+ else
+ pTabData[nDestTab] = NULL;
+
+ UpdateThis();
+ aMarkData.InsertTab( nDestTab );
+}
+
+void ScViewData::MoveTab( SCTAB nSrcTab, SCTAB nDestTab )
+{
+ if (nDestTab==SC_TAB_APPEND)
+ nDestTab = pDoc->GetTableCount() - 1;
+
+ SCTAB i;
+ ScViewDataTable* pTab = pTabData[nSrcTab];
+
+ SCTAB nInsTab = nDestTab;
+ if ( nSrcTab < nDestTab )
+ {
+ --nInsTab;
+ for (i=nSrcTab; i<nDestTab; i++)
+ pTabData[i] = pTabData[i+1];
+ }
+ else
+ for (i=nSrcTab; i>nDestTab; i--)
+ pTabData[i] = pTabData[i-1];
+
+ pTabData[nDestTab] = pTab;
+
+ UpdateThis();
+ aMarkData.DeleteTab( nSrcTab );
+ aMarkData.InsertTab( nInsTab ); // ggf. angepasst
+}
+
+void ScViewData::SetViewShell( ScTabViewShell* pViewSh )
+{
+ if (pViewSh)
+ {
+ pViewShell = pViewSh;
+ pView = pViewSh;
+ }
+ else
+ {
+ pViewShell = NULL;
+ pView = NULL;
+ }
+}
+void ScViewData::CreateTabData( std::vector< SCTAB >& rvTabs )
+{
+ std::vector< SCTAB >::iterator it_end = rvTabs.end();
+ for ( std::vector< SCTAB >::iterator it = rvTabs.begin(); it != it_end; ++it )
+ if ( !pTabData[*it] )
+ CreateTabData( *it );
+}
+
+void ScViewData::SetZoomType( SvxZoomType eNew, std::vector< SCTAB >& tabs )
+{
+ BOOL bAll = ( tabs.size() == 0 );
+
+ if ( !bAll ) // create associated table data
+ CreateTabData( tabs );
+
+ if ( bAll )
+ {
+ for ( SCTAB i = 0; i <= MAXTAB; ++i )
+ {
+ if ( pTabData[i] )
+ pTabData[i]->eZoomType = eNew;
+ }
+ eDefZoomType = eNew;
+ }
+ else
+ {
+ std::vector< SCTAB >::iterator it_end = tabs.end();
+ std::vector< SCTAB >::iterator it = tabs.begin();
+ for ( ; it != it_end; ++it )
+ {
+ SCTAB i = *it;
+ if ( pTabData[i] )
+ pTabData[i]->eZoomType = eNew;
+ }
+ }
+}
+
+void ScViewData::SetZoomType( SvxZoomType eNew, BOOL bAll )
+{
+ std::vector< SCTAB > vTabs; // Empty for all tabs
+ if ( !bAll ) // get selected tabs
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ {
+ if ( aMarkData.GetTableSelect(i) )
+ vTabs.push_back( i );
+ }
+ }
+ SetZoomType( eNew, vTabs );
+}
+
+void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, std::vector< SCTAB >& tabs )
+{
+ BOOL bAll = ( tabs.size() == 0 );
+ if ( !bAll ) // create associated table data
+ CreateTabData( tabs );
+ Fraction aFrac20( 1,5 );
+ Fraction aFrac400( 4,1 );
+
+ Fraction aValidX = rNewX;
+ if (aValidX<aFrac20)
+ aValidX = aFrac20;
+ if (aValidX>aFrac400)
+ aValidX = aFrac400;
+
+ Fraction aValidY = rNewY;
+ if (aValidY<aFrac20)
+ aValidY = aFrac20;
+ if (aValidY>aFrac400)
+ aValidY = aFrac400;
+
+ if ( bAll )
+ {
+ for ( SCTAB i = 0; i <= MAXTAB; ++i )
+ {
+ if ( pTabData[i] )
+ {
+ if ( bPagebreak )
+ {
+ pTabData[i]->aPageZoomX = aValidX;
+ pTabData[i]->aPageZoomY = aValidY;
+ }
+ else
+ {
+ pTabData[i]->aZoomX = aValidX;
+ pTabData[i]->aZoomY = aValidY;
+ }
+ }
+ }
+ if ( bPagebreak )
+ {
+ aDefPageZoomX = aValidX;
+ aDefPageZoomY = aValidY;
+ }
+ else
+ {
+ aDefZoomX = aValidX;
+ aDefZoomY = aValidY;
+ }
+ }
+ else
+ {
+ std::vector< SCTAB >::iterator it_end = tabs.end();
+ std::vector< SCTAB >::iterator it = tabs.begin();
+ for ( ; it != it_end; ++it )
+ {
+ SCTAB i = *it;
+ if ( pTabData[i] )
+ {
+ if ( bPagebreak )
+ {
+ pTabData[i]->aPageZoomX = aValidX;
+ pTabData[i]->aPageZoomY = aValidY;
+ }
+ else
+ {
+ pTabData[i]->aZoomX = aValidX;
+ pTabData[i]->aZoomY = aValidY;
+ }
+ }
+ }
+ }
+ RefreshZoom();
+}
+
+void ScViewData::SetZoom( const Fraction& rNewX, const Fraction& rNewY, BOOL bAll )
+{
+ std::vector< SCTAB > vTabs;
+ if ( !bAll ) // get selected tabs
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ {
+ if ( aMarkData.GetTableSelect(i) )
+ vTabs.push_back( i );
+ }
+ }
+ SetZoom( rNewX, rNewY, vTabs );
+}
+
+void ScViewData::SetShowGrid( bool bShow )
+{
+ CreateSelectedTabData();
+ pTabData[nTabNo]->bShowGrid = bShow;
+}
+
+void ScViewData::RefreshZoom()
+{
+ // recalculate zoom-dependent values (only for current sheet)
+
+ CalcPPT();
+ RecalcPixPos();
+ aScenButSize = Size(0,0);
+ aLogicMode.SetScaleX( GetZoomX() );
+ aLogicMode.SetScaleY( GetZoomY() );
+}
+
+void ScViewData::SetPagebreakMode( BOOL bSet )
+{
+ bPagebreak = bSet;
+
+ RefreshZoom();
+}
+
+
+ScMarkType ScViewData::GetSimpleArea( ScRange & rRange, ScMarkData & rNewMark ) const
+{
+ ScMarkType eMarkType = SC_MARK_NONE;
+
+ if ( rNewMark.IsMarked() || rNewMark.IsMultiMarked() )
+ {
+ if ( rNewMark.IsMultiMarked() )
+ rNewMark.MarkToSimple();
+
+ if ( rNewMark.IsMarked() && !rNewMark.IsMultiMarked() )
+ {
+ rNewMark.GetMarkArea( rRange );
+ if (ScViewUtil::HasFiltered( rRange, GetDocument()))
+ eMarkType = SC_MARK_SIMPLE_FILTERED;
+ else
+ eMarkType = SC_MARK_SIMPLE;
+ }
+ else
+ eMarkType = SC_MARK_MULTI;
+ }
+ if (eMarkType != SC_MARK_SIMPLE && eMarkType != SC_MARK_SIMPLE_FILTERED)
+ {
+ if (eMarkType == SC_MARK_NONE)
+ eMarkType = SC_MARK_SIMPLE;
+ rRange = ScRange( GetCurX(), GetCurY(), GetTabNo() );
+ }
+ return eMarkType;
+}
+
+
+ScMarkType ScViewData::GetSimpleArea( SCCOL& rStartCol, SCROW& rStartRow, SCTAB& rStartTab,
+ SCCOL& rEndCol, SCROW& rEndRow, SCTAB& rEndTab ) const
+{
+ // parameter bMergeMark is no longer needed: The view's selection is never modified
+ // (a local copy is used), and a multi selection that adds to a single range can always
+ // be treated like a single selection (#108266# - GetSimpleArea isn't used in selection
+ // handling itself)
+
+ ScRange aRange;
+ ScMarkData aNewMark( aMarkData ); // use a local copy for MarkToSimple
+ ScMarkType eMarkType = GetSimpleArea( aRange, aNewMark);
+ aRange.GetVars( rStartCol, rStartRow, rStartTab, rEndCol, rEndRow, rEndTab);
+ return eMarkType;
+}
+
+ScMarkType ScViewData::GetSimpleArea( ScRange& rRange ) const
+{
+ // parameter bMergeMark is no longer needed, see above
+
+ ScMarkData aNewMark( aMarkData ); // use a local copy for MarkToSimple
+ return GetSimpleArea( rRange, aNewMark);
+}
+
+void ScViewData::GetMultiArea( ScRangeListRef& rRange ) const
+{
+ // parameter bMergeMark is no longer needed, see GetSimpleArea
+
+ ScMarkData aNewMark( aMarkData ); // use a local copy for MarkToSimple
+
+ BOOL bMulti = aNewMark.IsMultiMarked();
+ if (bMulti)
+ {
+ aNewMark.MarkToSimple();
+ bMulti = aNewMark.IsMultiMarked();
+ }
+ if (bMulti)
+ {
+ rRange = new ScRangeList;
+ aNewMark.FillRangeListWithMarks( rRange, FALSE );
+ }
+ else
+ {
+ ScRange aSimple;
+ GetSimpleArea(aSimple);
+ rRange = new ScRangeList;
+ rRange->Append(aSimple);
+ }
+}
+
+BOOL ScViewData::SimpleColMarked()
+{
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+ if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ if (nStartRow==0 && nEndRow==MAXROW)
+ return TRUE;
+
+ return FALSE;
+}
+
+BOOL ScViewData::SimpleRowMarked()
+{
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+ if (GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ if (nStartCol==0 && nEndCol==MAXCOL)
+ return TRUE;
+
+ return FALSE;
+}
+
+BOOL ScViewData::IsMultiMarked()
+{
+ // Test for "real" multi selection, calling MarkToSimple on a local copy,
+ // and taking filtered in simple area marks into account.
+
+ ScRange aDummy;
+ ScMarkType eType = GetSimpleArea(aDummy);
+ return (eType & SC_MARK_SIMPLE) != SC_MARK_SIMPLE;
+}
+
+void ScViewData::SetFillMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow )
+{
+ nFillMode = SC_FILL_FILL;
+ nFillStartX = nStartCol;
+ nFillStartY = nStartRow;
+ nFillEndX = nEndCol;
+ nFillEndY = nEndRow;
+}
+
+void ScViewData::SetDragMode( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow,
+ BYTE nMode )
+{
+ nFillMode = nMode;
+ nFillStartX = nStartCol;
+ nFillStartY = nStartRow;
+ nFillEndX = nEndCol;
+ nFillEndY = nEndRow;
+}
+
+void ScViewData::ResetFillMode()
+{
+ nFillMode = SC_FILL_NONE;
+}
+
+void ScViewData::GetFillData( SCCOL& rStartCol, SCROW& rStartRow,
+ SCCOL& rEndCol, SCROW& rEndRow )
+{
+ rStartCol = nFillStartX;
+ rStartRow = nFillStartY;
+ rEndCol = nFillEndX;
+ rEndRow = nFillEndY;
+}
+
+SCCOL ScViewData::GetOldCurX() const
+{
+ if (pThisTab->bOldCurValid)
+ return pThisTab->nOldCurX;
+ else
+ return pThisTab->nCurX;
+}
+
+SCROW ScViewData::GetOldCurY() const
+{
+ if (pThisTab->bOldCurValid)
+ return pThisTab->nOldCurY;
+ else
+ return pThisTab->nCurY;
+}
+
+void ScViewData::SetOldCursor( SCCOL nNewX, SCROW nNewY )
+{
+ pThisTab->nOldCurX = nNewX;
+ pThisTab->nOldCurY = nNewY;
+ pThisTab->bOldCurValid = TRUE;
+}
+
+void ScViewData::ResetOldCursor()
+{
+ pThisTab->bOldCurValid = FALSE;
+}
+
+Rectangle ScViewData::GetEditArea( ScSplitPos eWhich, SCCOL nPosX, SCROW nPosY,
+ Window* pWin, const ScPatternAttr* pPattern,
+ BOOL bForceToTop )
+{
+ return ScEditUtil( pDoc, nPosX, nPosY, nTabNo, GetScrPos(nPosX,nPosY,eWhich,TRUE),
+ pWin, nPPTX, nPPTY, GetZoomX(), GetZoomY() ).
+ GetEditArea( pPattern, bForceToTop );
+}
+
+void ScViewData::SetEditEngine( ScSplitPos eWhich,
+ ScEditEngineDefaulter* pNewEngine,
+ Window* pWin, SCCOL nNewX, SCROW nNewY )
+{
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTabNo );
+ ScHSplitPos eHWhich = WhichH(eWhich);
+
+ BOOL bWasThere = FALSE;
+ if (pEditView[eWhich])
+ {
+ // Wenn die View schon da ist, nichts aufrufen, was die Cursorposition aendert
+
+ if (bEditActive[eWhich])
+ bWasThere = TRUE;
+ else
+ pEditView[eWhich]->SetEditEngine(pNewEngine);
+
+ if (pEditView[eWhich]->GetWindow() != pWin)
+ {
+ pEditView[eWhich]->SetWindow(pWin);
+ DBG_ERROR("EditView Window geaendert");
+ }
+ }
+ else
+ {
+ pEditView[eWhich] = new EditView( pNewEngine, pWin );
+ }
+
+ // bei IdleFormat wird manchmal ein Cursor gemalt, wenn die View schon weg ist (23576)
+
+ ULONG nEC = pNewEngine->GetControlWord();
+ pNewEngine->SetControlWord(nEC & ~EE_CNTRL_DOIDLEFORMAT);
+
+ ULONG nVC = pEditView[eWhich]->GetControlWord();
+ pEditView[eWhich]->SetControlWord(nVC & ~EV_CNTRL_AUTOSCROLL);
+
+ bEditActive[eWhich] = TRUE;
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nNewX, nNewY, nTabNo );
+ SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
+ pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
+
+ BOOL bBreak = ( eJust == SVX_HOR_JUSTIFY_BLOCK ) ||
+ ((SfxBoolItem&)pPattern->GetItem(ATTR_LINEBREAK)).GetValue();
+
+ BOOL bAsianVertical = pNewEngine->IsVertical(); // set by InputHandler
+
+ Rectangle aPixRect = ScEditUtil( pDoc, nNewX,nNewY,nTabNo, GetScrPos(nNewX,nNewY,eWhich),
+ pWin, nPPTX,nPPTY,GetZoomX(),GetZoomY() ).
+ GetEditArea( pPattern, TRUE );
+
+ // when right-aligned, leave space for the cursor
+ // in vertical mode, editing is always right-aligned
+ if ( nEditAdjust == SVX_ADJUST_RIGHT || bAsianVertical )
+ aPixRect.Right() += 1;
+
+ Rectangle aOutputArea = pWin->PixelToLogic( aPixRect, GetLogicMode() );
+ pEditView[eWhich]->SetOutputArea( aOutputArea );
+
+ if ( bActive && eWhich == GetActivePart() )
+ {
+ // keep the part that has the active edit view available after
+ // switching sheets or reference input on a different part
+ eEditActivePart = eWhich;
+
+ // modify members nEditCol etc. only if also extending for needed area
+ nEditCol = nNewX;
+ nEditRow = nNewY;
+ const ScMergeAttr* pMergeAttr = (ScMergeAttr*)&pPattern->GetItem(ATTR_MERGE);
+ nEditEndCol = nEditCol;
+ if (pMergeAttr->GetColMerge() > 1)
+ nEditEndCol += pMergeAttr->GetColMerge() - 1;
+ nEditEndRow = nEditRow;
+ if (pMergeAttr->GetRowMerge() > 1)
+ nEditEndRow += pMergeAttr->GetRowMerge() - 1;
+ nEditStartCol = nEditCol;
+
+ // For growing use only the alignment value from the attribute, numbers
+ // (existing or started) with default aligment extend to the right.
+ BOOL bGrowCentered = ( eJust == SVX_HOR_JUSTIFY_CENTER );
+ BOOL bGrowToLeft = ( eJust == SVX_HOR_JUSTIFY_RIGHT ); // visual left
+ BOOL bGrowBackwards = bGrowToLeft; // logical left
+ if ( bLayoutRTL )
+ bGrowBackwards = !bGrowBackwards; // invert on RTL sheet
+ if ( bAsianVertical )
+ bGrowCentered = bGrowToLeft = bGrowBackwards = FALSE; // keep old behavior for asian mode
+
+ long nSizeXPix;
+ if (bBreak && !bAsianVertical)
+ nSizeXPix = aPixRect.GetWidth(); // Papersize -> kein H-Scrolling
+ else
+ {
+ DBG_ASSERT(pView,"keine View fuer EditView");
+
+ if ( bGrowCentered )
+ {
+ // growing into both directions until one edge is reached
+ //! should be limited to whole cells in both directions
+ long nLeft = aPixRect.Left();
+ long nRight = pView->GetGridWidth(eHWhich) - aPixRect.Right();
+ nSizeXPix = aPixRect.GetWidth() + 2 * Min( nLeft, nRight );
+ }
+ else if ( bGrowToLeft )
+ nSizeXPix = aPixRect.Right(); // space that's available in the window when growing to the left
+ else
+ nSizeXPix = pView->GetGridWidth(eHWhich) - aPixRect.Left();
+
+ if ( nSizeXPix <= 0 )
+ nSizeXPix = aPixRect.GetWidth(); // editing outside to the right of the window -> keep cell width
+ }
+ DBG_ASSERT(pView,"keine View fuer EditView");
+ long nSizeYPix = pView->GetGridHeight(WhichV(eWhich)) - aPixRect.Top();
+ if ( nSizeYPix <= 0 )
+ nSizeYPix = aPixRect.GetHeight(); // editing outside below the window -> keep cell height
+
+ Size aPaperSize = pView->GetActiveWin()->PixelToLogic( Size( nSizeXPix, nSizeYPix ), GetLogicMode() );
+ if ( bBreak && !bAsianVertical && SC_MOD()->GetInputOptions().GetTextWysiwyg() )
+ {
+ // #95593# if text is formatted for printer, use the exact same paper width
+ // (and same line breaks) as for output.
+
+ Fraction aFract(1,1);
+ Rectangle aUtilRect = ScEditUtil( pDoc,nNewX,nNewY,nTabNo, Point(0,0), pWin,
+ HMM_PER_TWIPS, HMM_PER_TWIPS, aFract, aFract ).GetEditArea( pPattern, FALSE );
+ aPaperSize.Width() = aUtilRect.GetWidth();
+ }
+ pNewEngine->SetPaperSize( aPaperSize );
+
+ // sichtbarer Ausschnitt
+ Size aPaper = pNewEngine->GetPaperSize();
+ Rectangle aVis = pEditView[eWhich]->GetVisArea();
+ long nDiff = aVis.Right() - aVis.Left();
+ if ( nEditAdjust == SVX_ADJUST_RIGHT )
+ {
+ aVis.Right() = aPaper.Width() - 1;
+ bMoveArea = !bLayoutRTL;
+ }
+ else if ( nEditAdjust == SVX_ADJUST_CENTER )
+ {
+ aVis.Right() = ( aPaper.Width() - 1 + nDiff ) / 2;
+ bMoveArea = TRUE; // always
+ }
+ else
+ {
+ aVis.Right() = nDiff;
+ bMoveArea = bLayoutRTL;
+ }
+ aVis.Left() = aVis.Right() - nDiff;
+ // #i49561# Important note:
+ // The set offset of the visible area of the EditView for centered and
+ // right alignment in horizontal layout is consider by instances of
+ // class <ScEditObjectViewForwarder> in its methods <LogicToPixel(..)>
+ // and <PixelToLogic(..)>. This is needed for the correct visibility
+ // of paragraphs in edit mode at the accessibility API.
+ pEditView[eWhich]->SetVisArea(aVis);
+ // UpdateMode has been disabled in ScInputHandler::StartTable
+ // must be enabled before EditGrowY (GetTextHeight)
+ pNewEngine->SetUpdateMode( TRUE );
+
+ pNewEngine->SetStatusEventHdl( LINK( this, ScViewData, EditEngineHdl ) );
+
+ EditGrowY( TRUE ); // adjust to existing text content
+ EditGrowX();
+
+ Point aDocPos = pEditView[eWhich]->GetWindowPosTopLeft(0);
+ if (aDocPos.Y() < aOutputArea.Top())
+ pEditView[eWhich]->Scroll( 0, aOutputArea.Top() - aDocPos.Y() );
+ }
+
+ // hier muss bEditActive schon gesetzt sein
+ // (wegen Map-Mode bei Paint)
+ if (!bWasThere)
+ pNewEngine->InsertView(pEditView[eWhich]);
+
+ // Hintergrundfarbe der Zelle
+ Color aBackCol = ((const SvxBrushItem&)pPattern->GetItem(ATTR_BACKGROUND)).GetColor();
+
+ ScModule* pScMod = SC_MOD();
+ if ( aBackCol.GetTransparency() > 0 ||
+ Application::GetSettings().GetStyleSettings().GetHighContrastMode() )
+ {
+ aBackCol.SetColor( pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor );
+ }
+ pEditView[eWhich]->SetBackgroundColor( aBackCol );
+
+ pEditView[eWhich]->Invalidate(); // noetig ??
+ // noetig, wenn Position geaendert
+}
+
+IMPL_LINK_INLINE_START( ScViewData, EmptyEditHdl, EditStatus *, EMPTYARG )
+{
+ return 0;
+}
+IMPL_LINK_INLINE_END( ScViewData, EmptyEditHdl, EditStatus *, EMPTYARG )
+
+IMPL_LINK( ScViewData, EditEngineHdl, EditStatus *, pStatus )
+{
+ ULONG nStatus = pStatus->GetStatusWord();
+ if (nStatus & (EE_STAT_HSCROLL | EE_STAT_TEXTHEIGHTCHANGED | EE_STAT_TEXTWIDTHCHANGED | EE_STAT_CURSOROUT))
+ {
+ EditGrowY();
+ EditGrowX();
+
+ if (nStatus & EE_STAT_CURSOROUT)
+ {
+ ScSplitPos eWhich = GetActivePart();
+ if (pEditView[eWhich])
+ pEditView[eWhich]->ShowCursor(FALSE);
+ }
+ }
+ return 0;
+}
+
+void ScViewData::EditGrowX()
+{
+ ScDocument* pLocalDoc = GetDocument();
+
+ ScSplitPos eWhich = GetActivePart();
+ ScHSplitPos eHWhich = WhichH(eWhich);
+ EditView* pCurView = pEditView[eWhich];
+
+ if ( !pCurView || !bEditActive[eWhich])
+ return;
+
+ BOOL bLayoutRTL = pLocalDoc->IsLayoutRTL( nTabNo );
+
+ ScEditEngineDefaulter* pEngine =
+ (ScEditEngineDefaulter*) pCurView->GetEditEngine();
+ Window* pWin = pCurView->GetWindow();
+
+ SCCOL nLeft = GetPosX(eHWhich);
+ SCCOL nRight = nLeft + VisibleCellsX(eHWhich);
+
+ Size aSize = pEngine->GetPaperSize();
+ Rectangle aArea = pCurView->GetOutputArea();
+ long nOldRight = aArea.Right();
+
+ // Margin ist schon bei der urspruenglichen Breite beruecksichtigt
+ long nTextWidth = pEngine->CalcTextWidth();
+
+ BOOL bChanged = FALSE;
+ BOOL bAsianVertical = pEngine->IsVertical();
+
+ // get bGrow... variables the same way as in SetEditEngine
+ const ScPatternAttr* pPattern = pLocalDoc->GetPattern( nEditCol, nEditRow, nTabNo );
+ SvxCellHorJustify eJust = (SvxCellHorJustify)((const SvxHorJustifyItem&)
+ pPattern->GetItem( ATTR_HOR_JUSTIFY )).GetValue();
+ BOOL bGrowCentered = ( eJust == SVX_HOR_JUSTIFY_CENTER );
+ BOOL bGrowToLeft = ( eJust == SVX_HOR_JUSTIFY_RIGHT ); // visual left
+ BOOL bGrowBackwards = bGrowToLeft; // logical left
+ if ( bLayoutRTL )
+ bGrowBackwards = !bGrowBackwards; // invert on RTL sheet
+ if ( bAsianVertical )
+ bGrowCentered = bGrowToLeft = bGrowBackwards = FALSE; // keep old behavior for asian mode
+
+ BOOL bUnevenGrow = FALSE;
+ if ( bGrowCentered )
+ {
+ while (aArea.GetWidth() + 0 < nTextWidth && ( nEditStartCol > nLeft || nEditEndCol < nRight ) )
+ {
+ long nLogicLeft = 0;
+ if ( nEditStartCol > nLeft )
+ {
+ --nEditStartCol;
+ long nLeftPix = ToPixel( pLocalDoc->GetColWidth( nEditStartCol, nTabNo ), nPPTX );
+ nLogicLeft = pWin->PixelToLogic(Size(nLeftPix,0)).Width();
+ }
+ long nLogicRight = 0;
+ if ( nEditEndCol < nRight )
+ {
+ ++nEditEndCol;
+ long nRightPix = ToPixel( pLocalDoc->GetColWidth( nEditEndCol, nTabNo ), nPPTX );
+ nLogicRight = pWin->PixelToLogic(Size(nRightPix,0)).Width();
+ }
+
+ aArea.Left() -= bLayoutRTL ? nLogicRight : nLogicLeft;
+ aArea.Right() += bLayoutRTL ? nLogicLeft : nLogicRight;
+
+ if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
+ {
+ long nCenter = ( aArea.Left() + aArea.Right() ) / 2;
+ long nHalf = aSize.Width() / 2;
+ aArea.Left() = nCenter - nHalf + 1;
+ aArea.Right() = nCenter + aSize.Width() - nHalf - 1;
+ }
+
+ bChanged = TRUE;
+ if ( nLogicLeft != nLogicRight )
+ bUnevenGrow = TRUE;
+ }
+ }
+ else if ( bGrowBackwards )
+ {
+ while (aArea.GetWidth() + 0 < nTextWidth && nEditStartCol > nLeft)
+ {
+ --nEditStartCol;
+ long nPix = ToPixel( pLocalDoc->GetColWidth( nEditStartCol, nTabNo ), nPPTX );
+ long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
+ if ( !bLayoutRTL )
+ aArea.Left() -= nLogicWidth;
+ else
+ aArea.Right() += nLogicWidth;
+
+ if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
+ {
+ if ( !bLayoutRTL )
+ aArea.Left() = aArea.Right() - aSize.Width() + 1;
+ else
+ aArea.Right() = aArea.Left() + aSize.Width() - 1;
+ }
+
+ bChanged = TRUE;
+ }
+ }
+ else
+ {
+ while (aArea.GetWidth() + 0 < nTextWidth && nEditEndCol < nRight)
+ {
+ ++nEditEndCol;
+ long nPix = ToPixel( pLocalDoc->GetColWidth( nEditEndCol, nTabNo ), nPPTX );
+ long nLogicWidth = pWin->PixelToLogic(Size(nPix,0)).Width();
+ if ( bLayoutRTL )
+ aArea.Left() -= nLogicWidth;
+ else
+ aArea.Right() += nLogicWidth;
+
+ if ( aArea.Right() > aArea.Left() + aSize.Width() - 1 )
+ {
+ if ( bLayoutRTL )
+ aArea.Left() = aArea.Right() - aSize.Width() + 1;
+ else
+ aArea.Right() = aArea.Left() + aSize.Width() - 1;
+ }
+
+ bChanged = TRUE;
+ }
+ }
+
+ if (bChanged)
+ {
+ if ( bMoveArea || bGrowCentered || bGrowBackwards || bLayoutRTL )
+ {
+ Rectangle aVis = pCurView->GetVisArea();
+
+ if ( bGrowCentered )
+ {
+ // switch to center-aligned (undo?) and reset VisArea to center
+
+ pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
+
+ long nCenter = aSize.Width() / 2;
+ long nVisSize = aArea.GetWidth();
+ aVis.Left() = nCenter - nVisSize / 2;
+ aVis.Right() = aVis.Left() + nVisSize - 1;
+ }
+ else if ( bGrowToLeft )
+ {
+ // switch to right-aligned (undo?) and reset VisArea to the right
+
+ pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+
+ aVis.Right() = aSize.Width() - 1;
+ aVis.Left() = aSize.Width() - aArea.GetWidth(); // with the new, increased area
+ }
+ else
+ {
+ // switch to left-aligned (undo?) and reset VisArea to the left
+
+ pEngine->SetDefaultItem( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+
+ long nMove = aVis.Left();
+ aVis.Left() = 0;
+ aVis.Right() -= nMove;
+ }
+ pCurView->SetVisArea( aVis );
+ bMoveArea = FALSE;
+ }
+
+ pCurView->SetOutputArea(aArea);
+
+ // In vertical mode, the whole text is moved to the next cell (right-aligned),
+ // so everything must be repainted. Otherwise, paint only the new area.
+ // If growing in centered alignment, if the cells left and right have different sizes,
+ // the whole text will move, and may not even obscure all of the original display.
+ if ( bUnevenGrow )
+ {
+ aArea.Left() = pWin->PixelToLogic( Point(0,0) ).X();
+ aArea.Right() = pWin->PixelToLogic( aScrSize ).Width();
+ }
+ else if ( !bAsianVertical && !bGrowToLeft && !bGrowCentered )
+ aArea.Left() = nOldRight;
+ pWin->Invalidate(aArea);
+ }
+}
+
+void ScViewData::EditGrowY( BOOL bInitial )
+{
+ ScSplitPos eWhich = GetActivePart();
+ ScVSplitPos eVWhich = WhichV(eWhich);
+ EditView* pCurView = pEditView[eWhich];
+
+ if ( !pCurView || !bEditActive[eWhich])
+ return;
+
+ ULONG nControl = pEditView[eWhich]->GetControlWord();
+ if ( nControl & EV_CNTRL_AUTOSCROLL )
+ {
+ // if end of screen had already been reached and scrolling enabled,
+ // don't further try to grow the edit area
+
+ pCurView->SetOutputArea( pCurView->GetOutputArea() ); // re-align to pixels
+ return;
+ }
+
+ EditEngine* pEngine = pCurView->GetEditEngine();
+ Window* pWin = pCurView->GetWindow();
+
+ SCROW nBottom = GetPosY(eVWhich) + VisibleCellsY(eVWhich);
+
+ Size aSize = pEngine->GetPaperSize();
+ Rectangle aArea = pCurView->GetOutputArea();
+ long nOldBottom = aArea.Bottom();
+ long nTextHeight = pEngine->GetTextHeight();
+
+ // #106635# When editing a formula in a cell with optimal height, allow a larger portion
+ // to be clipped before extending to following rows, to avoid obscuring cells for
+ // reference input (next row is likely to be useful in formulas).
+ long nAllowedExtra = SC_GROWY_SMALL_EXTRA;
+ if ( nEditEndRow == nEditRow && !( pDoc->GetRowFlags( nEditRow, nTabNo ) & CR_MANUALSIZE ) &&
+ pEngine->GetParagraphCount() <= 1 )
+ {
+ // If the (only) paragraph starts with a '=', it's a formula.
+ // If this is the initial call and the text is empty, allow the larger value, too,
+ // because this occurs in the normal progress of editing a formula.
+ // Subsequent calls with empty text might involve changed attributes (including
+ // font height), so they are treated like normal text.
+ String aText = pEngine->GetText( (USHORT) 0 );
+ if ( ( aText.Len() == 0 && bInitial ) || aText.GetChar(0) == (sal_Unicode)'=' )
+ nAllowedExtra = SC_GROWY_BIG_EXTRA;
+ }
+
+ BOOL bChanged = FALSE;
+ BOOL bMaxReached = FALSE;
+ while (aArea.GetHeight() + nAllowedExtra < nTextHeight && nEditEndRow < nBottom && !bMaxReached)
+ {
+ ++nEditEndRow;
+ ScDocument* pLocalDoc = GetDocument();
+ long nPix = ToPixel( pLocalDoc->GetRowHeight( nEditEndRow, nTabNo ), nPPTY );
+ aArea.Bottom() += pWin->PixelToLogic(Size(0,nPix)).Height();
+
+ if ( aArea.Bottom() > aArea.Top() + aSize.Height() - 1 )
+ {
+ aArea.Bottom() = aArea.Top() + aSize.Height() - 1;
+ bMaxReached = TRUE; // don't occupy more cells beyond paper size
+ }
+
+ bChanged = TRUE;
+ nAllowedExtra = SC_GROWY_SMALL_EXTRA; // larger value is only for first row
+ }
+
+ if (bChanged)
+ {
+ pCurView->SetOutputArea(aArea);
+
+ if (nEditEndRow >= nBottom || bMaxReached)
+ {
+ if ((nControl & EV_CNTRL_AUTOSCROLL) == 0)
+ pCurView->SetControlWord( nControl | EV_CNTRL_AUTOSCROLL );
+ }
+
+ aArea.Top() = nOldBottom;
+ pWin->Invalidate(aArea);
+ }
+}
+
+void ScViewData::ResetEditView()
+{
+ EditEngine* pEngine = NULL;
+ for (USHORT i=0; i<4; i++)
+ if (pEditView[i])
+ {
+ if (bEditActive[i])
+ {
+ pEngine = pEditView[i]->GetEditEngine();
+ pEngine->RemoveView(pEditView[i]);
+ pEditView[i]->SetOutputArea( Rectangle() );
+ }
+ bEditActive[i] = FALSE;
+ }
+
+ if (pEngine)
+ pEngine->SetStatusEventHdl( LINK( this, ScViewData, EmptyEditHdl ) );
+}
+
+void ScViewData::KillEditView()
+{
+ for (USHORT i=0; i<4; i++)
+ if (pEditView[i])
+ {
+ if (bEditActive[i])
+ pEditView[i]->GetEditEngine()->RemoveView(pEditView[i]);
+ delete pEditView[i];
+ pEditView[i] = NULL;
+ }
+}
+
+void ScViewData::GetEditView( ScSplitPos eWhich, EditView*& rViewPtr, SCCOL& rCol, SCROW& rRow )
+{
+ rViewPtr = pEditView[eWhich];
+ rCol = nEditCol;
+ rRow = nEditRow;
+}
+
+void ScViewData::CreateTabData( SCTAB nNewTab )
+{
+ if (!pTabData[nNewTab])
+ {
+ pTabData[nNewTab] = new ScViewDataTable;
+
+ pTabData[nNewTab]->eZoomType = eDefZoomType;
+ pTabData[nNewTab]->aZoomX = aDefZoomX;
+ pTabData[nNewTab]->aZoomY = aDefZoomY;
+ pTabData[nNewTab]->aPageZoomX = aDefPageZoomX;
+ pTabData[nNewTab]->aPageZoomY = aDefPageZoomY;
+ }
+}
+
+void ScViewData::CreateSelectedTabData()
+{
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( aMarkData.GetTableSelect(i) && !pTabData[i] )
+ CreateTabData( i );
+}
+
+void ScViewData::SetTabNo( SCTAB nNewTab )
+{
+ if (!ValidTab(nNewTab))
+ {
+ DBG_ERROR("falsche Tabellennummer");
+ return;
+ }
+
+ nTabNo = nNewTab;
+ CreateTabData(nTabNo);
+ pThisTab = pTabData[nTabNo];
+
+ CalcPPT(); // for common column width correction
+ RecalcPixPos(); //! nicht immer noetig!
+}
+
+void ScViewData::SetActivePart( ScSplitPos eNewActive )
+{
+ pThisTab->eWhichActive = eNewActive;
+}
+
+Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScHSplitPos eWhich ) const
+{
+ DBG_ASSERT( eWhich==SC_SPLIT_LEFT || eWhich==SC_SPLIT_RIGHT, "Falsche Position" );
+ ScSplitPos ePos = ( eWhich == SC_SPLIT_LEFT ) ? SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT;
+ return GetScrPos( nWhereX, nWhereY, ePos );
+}
+
+Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScVSplitPos eWhich ) const
+{
+ DBG_ASSERT( eWhich==SC_SPLIT_TOP || eWhich==SC_SPLIT_BOTTOM, "Falsche Position" );
+ ScSplitPos ePos = ( eWhich == SC_SPLIT_TOP ) ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
+ return GetScrPos( nWhereX, nWhereY, ePos );
+}
+
+Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
+ BOOL bAllowNeg ) const
+{
+ ScHSplitPos eWhichX = SC_SPLIT_LEFT;
+ ScVSplitPos eWhichY = SC_SPLIT_BOTTOM;
+ switch( eWhich )
+ {
+ case SC_SPLIT_TOPLEFT:
+ eWhichX = SC_SPLIT_LEFT;
+ eWhichY = SC_SPLIT_TOP;
+ break;
+ case SC_SPLIT_TOPRIGHT:
+ eWhichX = SC_SPLIT_RIGHT;
+ eWhichY = SC_SPLIT_TOP;
+ break;
+ case SC_SPLIT_BOTTOMLEFT:
+ eWhichX = SC_SPLIT_LEFT;
+ eWhichY = SC_SPLIT_BOTTOM;
+ break;
+ case SC_SPLIT_BOTTOMRIGHT:
+ eWhichX = SC_SPLIT_RIGHT;
+ eWhichY = SC_SPLIT_BOTTOM;
+ break;
+ }
+
+ if (pView)
+ {
+ ((ScViewData*)this)->aScrSize.Width() = pView->GetGridWidth(eWhichX);
+ ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
+ }
+
+ USHORT nTSize;
+
+ SCCOL nPosX = GetPosX(eWhichX);
+ SCCOL nX;
+
+ long nScrPosX=0;
+ if (nWhereX >= nPosX)
+ for (nX=nPosX; nX<nWhereX && (bAllowNeg || nScrPosX<=aScrSize.Width()); nX++)
+ {
+ if ( nX > MAXCOL )
+ nScrPosX = 65535;
+ else
+ {
+ nTSize = pDoc->GetColWidth( nX, nTabNo );
+ if (nTSize)
+ {
+ long nSizeXPix = ToPixel( nTSize, nPPTX );
+ nScrPosX += nSizeXPix;
+ }
+ }
+ }
+ else if (bAllowNeg)
+ for (nX=nPosX; nX>nWhereX;)
+ {
+ --nX;
+ nTSize = pDoc->GetColWidth( nX, nTabNo );
+ if (nTSize)
+ {
+ long nSizeXPix = ToPixel( nTSize, nPPTX );
+ nScrPosX -= nSizeXPix;
+ }
+ }
+
+ SCROW nPosY = GetPosY(eWhichY);
+ SCROW nY;
+
+ long nScrPosY=0;
+ if (nWhereY >= nPosY)
+ for (nY=nPosY; nY<nWhereY && (bAllowNeg || nScrPosY<=aScrSize.Height()); nY++)
+ {
+ if ( nY > MAXROW )
+ nScrPosY = 65535;
+ else
+ {
+ nTSize = pDoc->GetRowHeight( nY, nTabNo );
+ if (nTSize)
+ {
+ long nSizeYPix = ToPixel( nTSize, nPPTY );
+ nScrPosY += nSizeYPix;
+ }
+ else if ( nY < MAXROW )
+ {
+ // skip multiple hidden rows (forward only for now)
+ SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo);
+ if ( nNext > MAXROW )
+ nY = MAXROW;
+ else
+ nY = nNext - 1; // +=nDir advances to next visible row
+ }
+ }
+ }
+ else if (bAllowNeg)
+ for (nY=nPosY; nY>nWhereY;)
+ {
+ --nY;
+ nTSize = pDoc->GetRowHeight( nY, nTabNo );
+ if (nTSize)
+ {
+ long nSizeYPix = ToPixel( nTSize, nPPTY );
+ nScrPosY -= nSizeYPix;
+ }
+ }
+
+ if ( pDoc->IsLayoutRTL( nTabNo ) )
+ {
+ // mirror horizontal position
+ nScrPosX = aScrSize.Width() - 1 - nScrPosX;
+ }
+
+ if (nScrPosX > 32767) nScrPosX=32767;
+ if (nScrPosY > 32767) nScrPosY=32767;
+ return Point( nScrPosX, nScrPosY );
+}
+
+//
+// Anzahl Zellen auf einem Bildschirm
+//
+
+SCCOL ScViewData::CellsAtX( SCsCOL nPosX, SCsCOL nDir, ScHSplitPos eWhichX, USHORT nScrSizeX ) const
+{
+ DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
+
+ if (pView)
+ ((ScViewData*)this)->aScrSize.Width() = pView->GetGridWidth(eWhichX);
+
+ SCsCOL nX;
+ USHORT nScrPosX = 0;
+ if (nScrSizeX == SC_SIZE_NONE) nScrSizeX = (USHORT) aScrSize.Width();
+
+ if (nDir==1)
+ nX = nPosX; // vorwaerts
+ else
+ nX = nPosX-1; // rueckwaerts
+
+ BOOL bOut = FALSE;
+ for ( ; nScrPosX<=nScrSizeX && !bOut; nX = sal::static_int_cast<SCsCOL>(nX + nDir) )
+ {
+ SCsCOL nColNo = nX;
+ if ( nColNo < 0 || nColNo > MAXCOL )
+ bOut = TRUE;
+ else
+ {
+ USHORT nTSize = pDoc->GetColWidth( nColNo, nTabNo );
+ if (nTSize)
+ {
+ long nSizeXPix = ToPixel( nTSize, nPPTX );
+ nScrPosX = sal::static_int_cast<USHORT>( nScrPosX + (USHORT) nSizeXPix );
+ }
+ }
+ }
+
+ if (nDir==1)
+ nX = sal::static_int_cast<SCsCOL>( nX - nPosX );
+ else
+ nX = (nPosX-1)-nX;
+
+ if (nX>0) --nX;
+ return nX;
+}
+
+SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHORT nScrSizeY ) const
+{
+ DBG_ASSERT( nDir==1 || nDir==-1, "falscher CellsAt Aufruf" );
+
+ if (pView)
+ ((ScViewData*)this)->aScrSize.Height() = pView->GetGridHeight(eWhichY);
+
+ if (nScrSizeY == SC_SIZE_NONE) nScrSizeY = (USHORT) aScrSize.Height();
+
+ SCROW nY;
+
+ if (nDir==1)
+ {
+ // forward
+ nY = nPosY;
+ long nScrPosY = 0;
+ AddPixelsWhile( nScrPosY, nScrSizeY, nY, MAXROW, nPPTY, pDoc, nTabNo);
+ // Original loop ended on last evaluated +1 or if that was MAXROW even
+ // on MAXROW+2.
+ nY += (nY == MAXROW ? 2 : 1);
+ nY -= nPosY;
+ }
+ else
+ {
+ // backward
+ nY = nPosY-1;
+ long nScrPosY = 0;
+ AddPixelsWhileBackward( nScrPosY, nScrSizeY, nY, 0, nPPTY, pDoc, nTabNo);
+ // Original loop ended on last evaluated -1 or if that was 0 even on
+ // -2.
+ nY -= (nY == 0 ? 2 : 1);
+ nY = (nPosY-1)-nY;
+ }
+
+ if (nY>0) --nY;
+ return nY;
+}
+
+SCCOL ScViewData::VisibleCellsX( ScHSplitPos eWhichX ) const
+{
+ return CellsAtX( GetPosX( eWhichX ), 1, eWhichX, SC_SIZE_NONE );
+}
+
+SCROW ScViewData::VisibleCellsY( ScVSplitPos eWhichY ) const
+{
+ return CellsAtY( GetPosY( eWhichY ), 1, eWhichY, SC_SIZE_NONE );
+}
+
+SCCOL ScViewData::PrevCellsX( ScHSplitPos eWhichX ) const
+{
+ return CellsAtX( GetPosX( eWhichX ), -1, eWhichX, SC_SIZE_NONE );
+}
+
+SCROW ScViewData::PrevCellsY( ScVSplitPos eWhichY ) const
+{
+ return CellsAtY( GetPosY( eWhichY ), -1, eWhichY, SC_SIZE_NONE );
+}
+
+
+BOOL ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& rSizeYPix )
+{
+ const ScMergeAttr* pMerge = (const ScMergeAttr*) pDoc->GetAttr( nX,nY,nTabNo, ATTR_MERGE );
+ if ( pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1 )
+ {
+ long nOutWidth = 0;
+ long nOutHeight = 0;
+ SCCOL nCountX = pMerge->GetColMerge();
+ for (SCCOL i=0; i<nCountX; i++)
+ nOutWidth += ToPixel( pDoc->GetColWidth(nX+i,nTabNo), nPPTX );
+ SCROW nCountY = pMerge->GetRowMerge();
+
+ for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
+ {
+ SCROW nLastRow = nRow;
+ if (pDoc->RowHidden(nRow, nTabNo, NULL, &nLastRow))
+ {
+ nRow = nLastRow;
+ continue;
+ }
+
+ USHORT nHeight = pDoc->GetRowHeight(nRow, nTabNo);
+ nOutHeight += ToPixel(nHeight, nPPTY);
+ }
+
+ rSizeXPix = nOutWidth;
+ rSizeYPix = nOutHeight;
+ return TRUE;
+ }
+ else
+ {
+ rSizeXPix = ToPixel( pDoc->GetColWidth( nX, nTabNo ), nPPTX );
+ rSizeYPix = ToPixel( pDoc->GetRowHeight( nY, nTabNo ), nPPTY );
+ return FALSE;
+ }
+}
+
+BOOL ScViewData::GetPosFromPixel( long nClickX, long nClickY, ScSplitPos eWhich,
+ SCsCOL& rPosX, SCsROW& rPosY,
+ BOOL bTestMerge, BOOL bRepair, BOOL bNextIfLarge )
+{
+ // special handling of 0 is now in ScViewFunctionSet::SetCursorAtPoint
+
+ ScHSplitPos eHWhich = WhichH(eWhich);
+ ScVSplitPos eVWhich = WhichV(eWhich);
+
+ if ( pDoc->IsLayoutRTL( nTabNo ) )
+ {
+ // mirror horizontal position
+ if (pView)
+ aScrSize.Width() = pView->GetGridWidth(eHWhich);
+ nClickX = aScrSize.Width() - 1 - nClickX;
+ }
+
+ SCsCOL nStartPosX = GetPosX(eHWhich);
+ SCsROW nStartPosY = GetPosY(eVWhich);
+ rPosX = nStartPosX;
+ rPosY = nStartPosY;
+ long nScrX = 0;
+ long nScrY = 0;
+
+ if (nClickX > 0)
+ {
+ while ( rPosX<=MAXCOL && nClickX >= nScrX )
+ {
+ nScrX += ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
+ ++rPosX;
+ }
+ --rPosX;
+ }
+ else
+ {
+ while ( rPosX>0 && nClickX < nScrX )
+ {
+ --rPosX;
+ nScrX -= ToPixel( pDoc->GetColWidth( rPosX, nTabNo ), nPPTX );
+ }
+ }
+
+ if (nClickY > 0)
+ AddPixelsWhile( nScrY, nClickY, rPosY, MAXROW, nPPTY, pDoc, nTabNo );
+ else
+ {
+ /* TODO: could need some "SubPixelsWhileBackward" method */
+ while ( rPosY>0 && nClickY < nScrY )
+ {
+ --rPosY;
+ nScrY -= ToPixel( pDoc->GetRowHeight( rPosY, nTabNo ), nPPTY );
+ }
+ }
+
+ if (bNextIfLarge) // zu grosse Zellen ?
+ {
+ if ( rPosX == nStartPosX && nClickX > 0 )
+ {
+ if (pView)
+ aScrSize.Width() = pView->GetGridWidth(eHWhich);
+ if ( nClickX > aScrSize.Width() )
+ ++rPosX;
+ }
+ if ( rPosY == nStartPosY && nClickY > 0 )
+ {
+ if (pView)
+ aScrSize.Height() = pView->GetGridHeight(eVWhich);
+ if ( nClickY > aScrSize.Height() )
+ ++rPosY;
+ }
+ }
+
+ if (rPosX<0) rPosX=0;
+ if (rPosX>MAXCOL) rPosX=MAXCOL;
+ if (rPosY<0) rPosY=0;
+ if (rPosY>MAXROW) rPosY=MAXROW;
+
+ if (bTestMerge)
+ {
+ //! public Methode um Position anzupassen
+
+ SCCOL nOrigX = rPosX;
+ SCROW nOrigY = rPosY;
+ pDoc->SkipOverlapped(rPosX, rPosY, nTabNo);
+ bool bHOver = (nOrigX != rPosX);
+ bool bVOver = (nOrigY != rPosY);
+
+ if ( bRepair && ( bHOver || bVOver ) )
+ {
+ const ScMergeAttr* pMerge = (const ScMergeAttr*)
+ pDoc->GetAttr( rPosX, rPosY, nTabNo, ATTR_MERGE );
+ if ( ( bHOver && pMerge->GetColMerge() <= 1 ) ||
+ ( bVOver && pMerge->GetRowMerge() <= 1 ) )
+ {
+ DBG_ERROR("Merge-Fehler gefunden");
+
+ pDoc->RemoveFlagsTab( 0,0, MAXCOL,MAXROW, nTabNo, SC_MF_HOR | SC_MF_VER );
+ SCCOL nEndCol = MAXCOL;
+ SCROW nEndRow = MAXROW;
+ pDoc->ExtendMerge( 0,0, nEndCol,nEndRow, nTabNo, TRUE, FALSE );
+ if (pDocShell)
+ pDocShell->PostPaint( ScRange(0,0,nTabNo,MAXCOL,MAXROW,nTabNo), PAINT_GRID );
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+void ScViewData::GetMouseQuadrant( const Point& rClickPos, ScSplitPos eWhich,
+ SCsCOL nPosX, SCsROW nPosY, BOOL& rLeft, BOOL& rTop )
+{
+ BOOL bLayoutRTL = pDoc->IsLayoutRTL( nTabNo );
+ long nLayoutSign = bLayoutRTL ? -1 : 1;
+
+ Point aCellStart = GetScrPos( nPosX, nPosY, eWhich, TRUE );
+ long nSizeX;
+ long nSizeY;
+ GetMergeSizePixel( nPosX, nPosY, nSizeX, nSizeY );
+ rLeft = ( rClickPos.X() - aCellStart.X() ) * nLayoutSign <= nSizeX / 2;
+ rTop = rClickPos.Y() - aCellStart.Y() <= nSizeY / 2;
+}
+
+void ScViewData::SetPosX( ScHSplitPos eWhich, SCCOL nNewPosX )
+{
+ if (nNewPosX != 0)
+ {
+ SCCOL nOldPosX = pThisTab->nPosX[eWhich];
+ long nTPosX = pThisTab->nTPosX[eWhich];
+ long nPixPosX = pThisTab->nPixPosX[eWhich];
+ SCCOL i;
+ if ( nNewPosX > nOldPosX )
+ for ( i=nOldPosX; i<nNewPosX; i++ )
+ {
+ long nThis = pDoc->GetColWidth( i,nTabNo );
+ nTPosX -= nThis;
+ nPixPosX -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTX);
+ }
+ else
+ for ( i=nNewPosX; i<nOldPosX; i++ )
+ {
+ long nThis = pDoc->GetColWidth( i,nTabNo );
+ nTPosX += nThis;
+ nPixPosX += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTX);
+ }
+
+ pThisTab->nPosX[eWhich] = nNewPosX;
+ pThisTab->nTPosX[eWhich] = nTPosX;
+ pThisTab->nMPosX[eWhich] = (long) (nTPosX * HMM_PER_TWIPS);
+ pThisTab->nPixPosX[eWhich] = nPixPosX;
+ }
+ else
+ pThisTab->nPixPosX[eWhich] =
+ pThisTab->nTPosX[eWhich] =
+ pThisTab->nMPosX[eWhich] =
+ pThisTab->nPosX[eWhich] = 0;
+}
+
+void ScViewData::SetPosY( ScVSplitPos eWhich, SCROW nNewPosY )
+{
+ if (nNewPosY != 0)
+ {
+ SCROW nOldPosY = pThisTab->nPosY[eWhich];
+ long nTPosY = pThisTab->nTPosY[eWhich];
+ long nPixPosY = pThisTab->nPixPosY[eWhich];
+ SCROW i, nHeightEndRow;
+ if ( nNewPosY > nOldPosY )
+ for ( i=nOldPosY; i<nNewPosY; i++ )
+ {
+ long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow );
+ SCROW nRows = std::min( nNewPosY, nHeightEndRow + 1) - i;
+ i = nHeightEndRow;
+ nTPosY -= nThis * nRows;
+ nPixPosY -= ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY) * nRows;
+ }
+ else
+ for ( i=nNewPosY; i<nOldPosY; i++ )
+ {
+ long nThis = pDoc->GetRowHeight( i, nTabNo, NULL, &nHeightEndRow );
+ SCROW nRows = std::min( nOldPosY, nHeightEndRow + 1) - i;
+ i = nHeightEndRow;
+ nTPosY += nThis * nRows;
+ nPixPosY += ToPixel(sal::static_int_cast<USHORT>(nThis), nPPTY) * nRows;
+ }
+
+ pThisTab->nPosY[eWhich] = nNewPosY;
+ pThisTab->nTPosY[eWhich] = nTPosY;
+ pThisTab->nMPosY[eWhich] = (long) (nTPosY * HMM_PER_TWIPS);
+ pThisTab->nPixPosY[eWhich] = nPixPosY;
+ }
+ else
+ pThisTab->nPixPosY[eWhich] =
+ pThisTab->nTPosY[eWhich] =
+ pThisTab->nMPosY[eWhich] =
+ pThisTab->nPosY[eWhich] = 0;
+}
+
+void ScViewData::RecalcPixPos() // nach Zoom-Aenderungen
+{
+ for (USHORT eWhich=0; eWhich<2; eWhich++)
+ {
+ long nPixPosX = 0;
+ SCCOL nPosX = pThisTab->nPosX[eWhich];
+ for (SCCOL i=0; i<nPosX; i++)
+ nPixPosX -= ToPixel(pDoc->GetColWidth(i,nTabNo), nPPTX);
+ pThisTab->nPixPosX[eWhich] = nPixPosX;
+
+ long nPixPosY = 0;
+ SCROW nPosY = pThisTab->nPosY[eWhich];
+ for (SCROW j=0; j<nPosY; j++)
+ nPixPosY -= ToPixel(pDoc->GetRowHeight(j,nTabNo), nPPTY);
+ pThisTab->nPixPosY[eWhich] = nPixPosY;
+ }
+}
+
+const MapMode& ScViewData::GetLogicMode( ScSplitPos eWhich )
+{
+ aLogicMode.SetOrigin( Point( pThisTab->nMPosX[WhichH(eWhich)],
+ pThisTab->nMPosY[WhichV(eWhich)] ) );
+ return aLogicMode;
+}
+
+const MapMode& ScViewData::GetLogicMode()
+{
+ aLogicMode.SetOrigin( Point() );
+ return aLogicMode;
+}
+
+void ScViewData::SetScreen( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
+{
+ SCCOL nCol;
+ SCROW nRow;
+ USHORT nTSize;
+ long nSizePix;
+ long nScrPosX = 0;
+ long nScrPosY = 0;
+
+ SetActivePart( SC_SPLIT_BOTTOMLEFT );
+ SetPosX( SC_SPLIT_LEFT, nCol1 );
+ SetPosY( SC_SPLIT_BOTTOM, nRow1 );
+
+ for (nCol=nCol1; nCol<=nCol2; nCol++)
+ {
+ nTSize = pDoc->GetColWidth( nCol, nTabNo );
+ if (nTSize)
+ {
+ nSizePix = ToPixel( nTSize, nPPTX );
+ nScrPosX += (USHORT) nSizePix;
+ }
+ }
+
+ for (nRow=nRow1; nRow<=nRow2; nRow++)
+ {
+ nTSize = pDoc->GetRowHeight( nRow, nTabNo );
+ if (nTSize)
+ {
+ nSizePix = ToPixel( nTSize, nPPTY );
+ nScrPosY += (USHORT) nSizePix;
+ }
+ }
+
+ aScrSize = Size( nScrPosX, nScrPosY );
+}
+
+void ScViewData::SetScreenPos( const Point& rVisAreaStart )
+{
+ long nSize;
+ long nTwips;
+ long nAdd;
+ BOOL bEnd;
+
+ nSize = 0;
+ nTwips = (long) (rVisAreaStart.X() / HMM_PER_TWIPS);
+ if ( pDoc->IsLayoutRTL( nTabNo ) )
+ nTwips = -nTwips;
+ SCCOL nX1 = 0;
+ bEnd = FALSE;
+ while (!bEnd)
+ {
+ nAdd = (long) pDoc->GetColWidth(nX1,nTabNo);
+ if (nSize+nAdd <= nTwips+1 && nX1<MAXCOL)
+ {
+ nSize += nAdd;
+ ++nX1;
+ }
+ else
+ bEnd = TRUE;
+ }
+
+ nSize = 0;
+ nTwips = (long) (rVisAreaStart.Y() / HMM_PER_TWIPS);
+ SCROW nY1 = 0;
+ bEnd = FALSE;
+ while (!bEnd)
+ {
+ nAdd = (long) pDoc->GetRowHeight(nY1,nTabNo);
+ if (nSize+nAdd <= nTwips+1 && nY1<MAXROW)
+ {
+ nSize += nAdd;
+ ++nY1;
+ }
+ else
+ bEnd = TRUE;
+ }
+
+ SetActivePart( SC_SPLIT_BOTTOMLEFT );
+ SetPosX( SC_SPLIT_LEFT, nX1 );
+ SetPosY( SC_SPLIT_BOTTOM, nY1 );
+
+ SetCurX( nX1 );
+ SetCurY( nY1 );
+}
+
+void ScViewData::SetScreen( const Rectangle& rVisArea )
+{
+ SetScreenPos( rVisArea.TopLeft() );
+
+ // hier ohne GetOutputFactor(), weil fuer Ausgabe in Metafile
+
+ aScrSize = rVisArea.GetSize();
+ aScrSize.Width() = (long)
+ ( aScrSize.Width() * ScGlobal::nScreenPPTX / HMM_PER_TWIPS );
+ aScrSize.Height() = (long)
+ ( aScrSize.Height() * ScGlobal::nScreenPPTY / HMM_PER_TWIPS );
+}
+
+SfxObjectShell* ScViewData::GetSfxDocShell() const
+{
+ return pDocShell;
+}
+
+SfxBindings& ScViewData::GetBindings()
+{
+ DBG_ASSERT( pViewShell, "GetBindings() without ViewShell" );
+ return pViewShell->GetViewFrame()->GetBindings();
+}
+
+SfxDispatcher& ScViewData::GetDispatcher()
+{
+ DBG_ASSERT( pViewShell, "GetDispatcher() without ViewShell" );
+ return *pViewShell->GetViewFrame()->GetDispatcher();
+}
+
+Window* ScViewData::GetDialogParent()
+{
+ DBG_ASSERT( pViewShell, "GetDialogParent() ohne ViewShell" );
+ return pViewShell->GetDialogParent();
+}
+
+Window* ScViewData::GetActiveWin()
+{
+ DBG_ASSERT( pView, "GetActiveWin() ohne View" );
+ return pView->GetActiveWin();
+}
+
+ScDrawView* ScViewData::GetScDrawView()
+{
+ DBG_ASSERT( pView, "GetScDrawView() ohne View" );
+ return pView->GetScDrawView();
+}
+
+BOOL ScViewData::IsMinimized()
+{
+ DBG_ASSERT( pView, "IsMinimized() ohne View" );
+ return pView->IsMinimized();
+}
+
+void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY )
+{
+ Fraction aOldX = GetZoomX();
+ Fraction aOldY = GetZoomY();
+
+ SetZoom( rNewX, rNewY, FALSE );
+
+ Fraction aWidth = GetZoomX();
+ aWidth *= Fraction( aScrSize.Width(),1 );
+ aWidth /= aOldX;
+
+ Fraction aHeight = GetZoomY();
+ aHeight *= Fraction( aScrSize.Height(),1 );
+ aHeight /= aOldY;
+
+ aScrSize.Width() = (long) aWidth;
+ aScrSize.Height() = (long) aHeight;
+}
+
+void ScViewData::CalcPPT()
+{
+ nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX();
+ if (pDocShell)
+ nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Faktor ist Drucker zu Bildschirm
+ nPPTY = ScGlobal::nScreenPPTY * (double) GetZoomY();
+
+ // #83616# if detective objects are present,
+ // try to adjust horizontal scale so the most common column width has minimal rounding errors,
+ // to avoid differences between cell and drawing layer output
+
+ if ( pDoc && pDoc->HasDetectiveObjects(nTabNo) )
+ {
+ SCCOL nEndCol = 0;
+ SCROW nDummy = 0;
+ pDoc->GetTableArea( nTabNo, nEndCol, nDummy );
+ if (nEndCol<20)
+ nEndCol = 20; // same end position as when determining draw scale
+
+ USHORT nTwips = pDoc->GetCommonWidth( nEndCol, nTabNo );
+ if ( nTwips )
+ {
+ double fOriginal = nTwips * nPPTX;
+ if ( fOriginal < static_cast<double>(nEndCol) )
+ {
+ // if one column is smaller than the column count,
+ // rounding errors are likely to add up to a whole column.
+
+ double fRounded = ::rtl::math::approxFloor( fOriginal + 0.5 );
+ if ( fRounded > 0.0 )
+ {
+ double fScale = fRounded / fOriginal + 1E-6;
+ if ( fScale >= 0.9 && fScale <= 1.1 )
+ nPPTX *= fScale;
+ }
+ }
+ }
+ }
+}
+
+#define SC_OLD_TABSEP '/'
+#define SC_NEW_TABSEP '+'
+
+void ScViewData::WriteUserData(String& rData)
+{
+ // nZoom (bis 364v) oder nZoom/nPageZoom/bPageMode (ab 364w)
+ // nTab
+ // Tab-ControlBreite
+ // pro Tabelle:
+ // CursorX/CursorY/HSplitMode/VSplitMode/HSplitPos/VSplitPos/SplitActive/
+ // PosX[links]/PosX[rechts]/PosY[oben]/PosY[unten]
+ // wenn Zeilen groesser 8192, "+" statt "/"
+
+ USHORT nZoom = (USHORT)((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator());
+ rData = String::CreateFromInt32( nZoom );
+ rData += '/';
+ nZoom = (USHORT)((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator());
+ rData += String::CreateFromInt32( nZoom );
+ rData += '/';
+ if (bPagebreak)
+ rData += '1';
+ else
+ rData += '0';
+
+ rData += ';';
+ rData += String::CreateFromInt32( nTabNo );
+ rData += ';';
+ rData.AppendAscii(RTL_CONSTASCII_STRINGPARAM( TAG_TABBARWIDTH ));
+ rData += String::CreateFromInt32( pView->GetTabBarWidth() );
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ {
+ rData += ';'; // Numerierung darf auf keinen Fall durcheinanderkommen
+ if (pTabData[i])
+ {
+ sal_Unicode cTabSep = SC_OLD_TABSEP; // wie 3.1
+ if ( pTabData[i]->nCurY > MAXROW_30 ||
+ pTabData[i]->nPosY[0] > MAXROW_30 || pTabData[i]->nPosY[1] > MAXROW_30 ||
+ ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX &&
+ pTabData[i]->nFixPosY > MAXROW_30 ) )
+ {
+ cTabSep = SC_NEW_TABSEP; // um eine 3.1-Version nicht umzubringen
+ }
+
+
+ rData += String::CreateFromInt32( pTabData[i]->nCurX );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->nCurY );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->eHSplitMode );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->eVSplitMode );
+ rData += cTabSep;
+ if ( pTabData[i]->eHSplitMode == SC_SPLIT_FIX )
+ rData += String::CreateFromInt32( pTabData[i]->nFixPosX );
+ else
+ rData += String::CreateFromInt32( pTabData[i]->nHSplitPos );
+ rData += cTabSep;
+ if ( pTabData[i]->eVSplitMode == SC_SPLIT_FIX )
+ rData += String::CreateFromInt32( pTabData[i]->nFixPosY );
+ else
+ rData += String::CreateFromInt32( pTabData[i]->nVSplitPos );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->eWhichActive );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->nPosX[0] );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->nPosX[1] );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->nPosY[0] );
+ rData += cTabSep;
+ rData += String::CreateFromInt32( pTabData[i]->nPosY[1] );
+ }
+ }
+}
+
+void ScViewData::ReadUserData(const String& rData)
+{
+ if (!rData.Len()) // Leerer String kommt bei "neu Laden"
+ return; // dann auch ohne Assertion beenden
+
+ xub_StrLen nCount = rData.GetTokenCount(';');
+ if ( nCount <= 2 )
+ {
+ // #45208# beim Reload in der Seitenansicht sind evtl. die Preview-UserData
+ // stehengelassen worden. Den Zoom von der Preview will man hier nicht...
+ DBG_ERROR("ReadUserData: das sind nicht meine Daten");
+ return;
+ }
+
+ String aTabOpt;
+ xub_StrLen nTagLen = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM(TAG_TABBARWIDTH)).Len();
+
+ // nicht pro Tabelle:
+ SCTAB nTabStart = 2;
+
+ Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY; //! evaluate (all sheets?)
+
+ String aZoomStr = rData.GetToken(0); // Zoom/PageZoom/Modus
+ USHORT nNormZoom = sal::static_int_cast<USHORT>(aZoomStr.GetToken(0,'/').ToInt32());
+ if ( nNormZoom >= MINZOOM && nNormZoom <= MAXZOOM )
+ aZoomX = aZoomY = Fraction( nNormZoom, 100 ); // "normaler" Zoom (immer)
+ USHORT nPageZoom = sal::static_int_cast<USHORT>(aZoomStr.GetToken(1,'/').ToInt32());
+ if ( nPageZoom >= MINZOOM && nPageZoom <= MAXZOOM )
+ aPageZoomX = aPageZoomY = Fraction( nPageZoom, 100 ); // Pagebreak-Zoom, wenn gesetzt
+ sal_Unicode cMode = aZoomStr.GetToken(2,'/').GetChar(0); // 0 oder "0"/"1"
+ SetPagebreakMode( cMode == '1' );
+ // SetPagebreakMode muss immer gerufen werden wegen CalcPPT / RecalcPixPos()
+
+ //
+ // Tabelle kann ungueltig geworden sein (z.B. letzte Version):
+ //
+ SCTAB nNewTab = static_cast<SCTAB>(rData.GetToken(1).ToInt32());
+ if (pDoc->HasTable( nNewTab ))
+ SetTabNo(nNewTab);
+
+ //
+ // wenn vorhanden, TabBar-Breite holen:
+ //
+ aTabOpt = rData.GetToken(2);
+
+ if ( nTagLen && aTabOpt.Copy(0,nTagLen).EqualsAscii(TAG_TABBARWIDTH) )
+ {
+ pView->SetTabBarWidth( aTabOpt.Copy(nTagLen).ToInt32() );
+ nTabStart = 3;
+ }
+
+ // pro Tabelle:
+ SCTAB nPos = 0;
+ while ( nCount > nPos+nTabStart )
+ {
+ aTabOpt = rData.GetToken(static_cast<xub_StrLen>(nPos+nTabStart));
+ if (!pTabData[nPos])
+ pTabData[nPos] = new ScViewDataTable;
+
+ sal_Unicode cTabSep = 0;
+ if (aTabOpt.GetTokenCount(SC_OLD_TABSEP) >= 11)
+ cTabSep = SC_OLD_TABSEP;
+#ifndef SC_LIMIT_ROWS
+ else if (aTabOpt.GetTokenCount(SC_NEW_TABSEP) >= 11)
+ cTabSep = SC_NEW_TABSEP;
+ // '+' ist nur erlaubt, wenn wir mit Zeilen > 8192 umgehen koennen
+#endif
+
+ if (cTabSep)
+ {
+ pTabData[nPos]->nCurX = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(0,cTabSep).ToInt32()));
+ pTabData[nPos]->nCurY = SanitizeRow( aTabOpt.GetToken(1,cTabSep).ToInt32());
+ pTabData[nPos]->eHSplitMode = (ScSplitMode) aTabOpt.GetToken(2,cTabSep).ToInt32();
+ pTabData[nPos]->eVSplitMode = (ScSplitMode) aTabOpt.GetToken(3,cTabSep).ToInt32();
+
+ if ( pTabData[nPos]->eHSplitMode == SC_SPLIT_FIX )
+ {
+ pTabData[nPos]->nFixPosX = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(4,cTabSep).ToInt32()));
+ UpdateFixX(nPos);
+ }
+ else
+ pTabData[nPos]->nHSplitPos = aTabOpt.GetToken(4,cTabSep).ToInt32();
+
+ if ( pTabData[nPos]->eVSplitMode == SC_SPLIT_FIX )
+ {
+ pTabData[nPos]->nFixPosY = SanitizeRow( aTabOpt.GetToken(5,cTabSep).ToInt32());
+ UpdateFixY(nPos);
+ }
+ else
+ pTabData[nPos]->nVSplitPos = aTabOpt.GetToken(5,cTabSep).ToInt32();
+
+ pTabData[nPos]->eWhichActive = (ScSplitPos) aTabOpt.GetToken(6,cTabSep).ToInt32();
+ pTabData[nPos]->nPosX[0] = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(7,cTabSep).ToInt32()));
+ pTabData[nPos]->nPosX[1] = SanitizeCol( static_cast<SCCOL>(aTabOpt.GetToken(8,cTabSep).ToInt32()));
+ pTabData[nPos]->nPosY[0] = SanitizeRow( aTabOpt.GetToken(9,cTabSep).ToInt32());
+ pTabData[nPos]->nPosY[1] = SanitizeRow( aTabOpt.GetToken(10,cTabSep).ToInt32());
+
+ // Test, ob der aktive Teil laut SplitMode ueberhaupt existiert
+ // (Bug #44516#)
+ ScSplitPos eTest = pTabData[nPos]->eWhichActive;
+ if ( ( WhichH( eTest ) == SC_SPLIT_RIGHT &&
+ pTabData[nPos]->eHSplitMode == SC_SPLIT_NONE ) ||
+ ( WhichV( eTest ) == SC_SPLIT_TOP &&
+ pTabData[nPos]->eVSplitMode == SC_SPLIT_NONE ) )
+ {
+ // dann wieder auf Default (unten links)
+ pTabData[nPos]->eWhichActive = SC_SPLIT_BOTTOMLEFT;
+ DBG_ERROR("SplitPos musste korrigiert werden");
+ }
+ }
+ ++nPos;
+ }
+
+ RecalcPixPos();
+}
+
+void ScViewData::WriteExtOptions( ScExtDocOptions& rDocOpt ) const
+{
+ // *** Fill extended document data for export filters ***
+
+ // document settings
+ ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
+
+ // displayed sheet
+ rDocSett.mnDisplTab = GetTabNo();
+
+ // width of the tabbar, relative to frame window width
+ rDocSett.mfTabBarWidth = pView->GetPendingRelTabBarWidth();
+ if( rDocSett.mfTabBarWidth < 0.0 )
+ rDocSett.mfTabBarWidth = pView->GetRelTabBarWidth();
+
+ // sheet settings
+ for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
+ {
+ if( const ScViewDataTable* pViewTab = pTabData[ nTab ] )
+ {
+ ScExtTabSettings& rTabSett = rDocOpt.GetOrCreateTabSettings( nTab );
+
+ // split mode
+ ScSplitMode eHSplit = pViewTab->eHSplitMode;
+ ScSplitMode eVSplit = pViewTab->eVSplitMode;
+ bool bHSplit = eHSplit != SC_SPLIT_NONE;
+ bool bVSplit = eVSplit != SC_SPLIT_NONE;
+ bool bRealSplit = (eHSplit == SC_SPLIT_NORMAL) || (eVSplit == SC_SPLIT_NORMAL);
+ bool bFrozen = (eHSplit == SC_SPLIT_FIX) || (eVSplit == SC_SPLIT_FIX);
+ DBG_ASSERT( !bRealSplit || !bFrozen, "ScViewData::WriteExtOptions - split and freeze in same sheet" );
+ rTabSett.mbFrozenPanes = !bRealSplit && bFrozen;
+
+ // split and freeze position
+ rTabSett.maSplitPos = Point( 0, 0 );
+ rTabSett.maFreezePos.Set( 0, 0, nTab );
+ if( bRealSplit )
+ {
+ Point& rSplitPos = rTabSett.maSplitPos;
+ rSplitPos = Point( bHSplit ? pViewTab->nHSplitPos : 0, bVSplit ? pViewTab->nVSplitPos : 0 );
+ rSplitPos = Application::GetDefaultDevice()->PixelToLogic( rSplitPos, MapMode( MAP_TWIP ) );
+ if( pDocShell )
+ rSplitPos.X() = (long)((double)rSplitPos.X() / pDocShell->GetOutputFactor());
+ }
+ else if( bFrozen )
+ {
+ if( bHSplit ) rTabSett.maFreezePos.SetCol( pViewTab->nFixPosX );
+ if( bVSplit ) rTabSett.maFreezePos.SetRow( pViewTab->nFixPosY );
+ }
+
+ // first visible cell in top-left and additional panes
+ rTabSett.maFirstVis.Set( pViewTab->nPosX[ SC_SPLIT_LEFT ], pViewTab->nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ], nTab );
+ rTabSett.maSecondVis.Set( pViewTab->nPosX[ SC_SPLIT_RIGHT ], pViewTab->nPosY[ SC_SPLIT_BOTTOM ], nTab );
+
+ // active pane
+ switch( pViewTab->eWhichActive )
+ {
+ // no horizontal split -> always use left panes
+ // no vertical split -> always use top panes
+ case SC_SPLIT_TOPLEFT:
+ rTabSett.meActivePane = SCEXT_PANE_TOPLEFT;
+ break;
+ case SC_SPLIT_TOPRIGHT:
+ rTabSett.meActivePane = bHSplit ? SCEXT_PANE_TOPRIGHT : SCEXT_PANE_TOPLEFT;
+ break;
+ case SC_SPLIT_BOTTOMLEFT:
+ rTabSett.meActivePane = bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT;
+ break;
+ case SC_SPLIT_BOTTOMRIGHT:
+ rTabSett.meActivePane = bHSplit ?
+ (bVSplit ? SCEXT_PANE_BOTTOMRIGHT : SCEXT_PANE_TOPRIGHT) :
+ (bVSplit ? SCEXT_PANE_BOTTOMLEFT : SCEXT_PANE_TOPLEFT);
+ break;
+ }
+
+ // cursor position
+ rTabSett.maCursor.Set( pViewTab->nCurX, pViewTab->nCurY, nTab );
+
+ // sheet selection and selected ranges
+ const ScMarkData& rMarkData = GetMarkData();
+ rTabSett.mbSelected = rMarkData.GetTableSelect( nTab );
+ rMarkData.FillRangeListWithMarks( &rTabSett.maSelection, TRUE );
+
+ // grid color
+ rTabSett.maGridColor.SetColor( COL_AUTO );
+ if( pOptions )
+ {
+ const Color& rGridColor = pOptions->GetGridColor();
+ if( rGridColor.GetColor() != SC_STD_GRIDCOLOR )
+ rTabSett.maGridColor = rGridColor;
+ }
+ rTabSett.mbShowGrid = pViewTab->bShowGrid;
+
+ // view mode and zoom
+ rTabSett.mbPageMode = bPagebreak;
+ rTabSett.mnNormalZoom = static_cast< long >( pViewTab->aZoomY * Fraction( 100.0 ) );
+ rTabSett.mnPageZoom = static_cast< long >( pViewTab->aPageZoomY * Fraction( 100.0 ) );
+ }
+ }
+}
+
+void ScViewData::ReadExtOptions( const ScExtDocOptions& rDocOpt )
+{
+ // *** Get extended document data from import filters ***
+
+ if( !rDocOpt.IsChanged() ) return;
+
+ // document settings
+ const ScExtDocSettings& rDocSett = rDocOpt.GetDocSettings();
+
+ // displayed sheet
+ SetTabNo( rDocSett.mnDisplTab );
+
+ /* Width of the tabbar, relative to frame window width. We do not have the
+ correct width of the frame window here -> store in ScTabView, which sets
+ the size in the next resize. */
+ pView->SetPendingRelTabBarWidth( rDocSett.mfTabBarWidth );
+
+ // sheet settings
+ for( SCTAB nTab = 0, nTabCount = pDoc->GetTableCount(); nTab < nTabCount; ++nTab )
+ {
+ if( const ScExtTabSettings* pTabSett = rDocOpt.GetTabSettings( nTab ) )
+ {
+ if( !pTabData[ nTab ] )
+ pTabData[ nTab ] = new ScViewDataTable;
+
+ const ScExtTabSettings& rTabSett = *pTabSett;
+ ScViewDataTable& rViewTab = *pTabData[ nTab ];
+
+ // split mode initialization
+ bool bFrozen = rTabSett.mbFrozenPanes;
+ bool bHSplit = bFrozen ? (rTabSett.maFreezePos.Col() > 0) : (rTabSett.maSplitPos.X() > 0);
+ bool bVSplit = bFrozen ? (rTabSett.maFreezePos.Row() > 0) : (rTabSett.maSplitPos.Y() > 0);
+
+ // first visible cell of top-left pane and additional panes
+ rViewTab.nPosX[ SC_SPLIT_LEFT ] = rTabSett.maFirstVis.Col();
+ rViewTab.nPosY[ bVSplit ? SC_SPLIT_TOP : SC_SPLIT_BOTTOM ] = rTabSett.maFirstVis.Row();
+ if( bHSplit ) rViewTab.nPosX[ SC_SPLIT_RIGHT ] = rTabSett.maSecondVis.Col();
+ if( bVSplit ) rViewTab.nPosY[ SC_SPLIT_BOTTOM ] = rTabSett.maSecondVis.Row();
+
+ // split mode, split and freeze position
+ rViewTab.eHSplitMode = rViewTab.eVSplitMode = SC_SPLIT_NONE;
+ rViewTab.nHSplitPos = rViewTab.nVSplitPos = 0;
+ rViewTab.nFixPosX = 0;
+ rViewTab.nFixPosY = 0;
+ if( bFrozen )
+ {
+ if( bHSplit )
+ {
+ rViewTab.eHSplitMode = SC_SPLIT_FIX;
+ rViewTab.nFixPosX = rTabSett.maFreezePos.Col();
+ UpdateFixX( nTab );
+ }
+ if( bVSplit )
+ {
+ rViewTab.eVSplitMode = SC_SPLIT_FIX;
+ rViewTab.nFixPosY = rTabSett.maFreezePos.Row();
+ UpdateFixY( nTab );
+ }
+ }
+ else
+ {
+ Point aPixel = Application::GetDefaultDevice()->LogicToPixel(
+ rTabSett.maSplitPos, MapMode( MAP_TWIP ) ); //! Zoom?
+ // #109648# - the test for use of printer metrics for text formatting here
+ // effectively results in the nFactor = 1.0 regardless of the Option setting.
+ if( pDocShell && SC_MOD()->GetInputOptions().GetTextWysiwyg())
+ {
+ double nFactor = pDocShell->GetOutputFactor();
+ aPixel.X() = (long)( aPixel.X() * nFactor + 0.5 );
+ }
+ if( bHSplit )
+ {
+ rViewTab.eHSplitMode = SC_SPLIT_NORMAL;
+ rViewTab.nHSplitPos = aPixel.X();
+ }
+ if( bVSplit )
+ {
+ rViewTab.eVSplitMode = SC_SPLIT_NORMAL;
+ rViewTab.nVSplitPos = aPixel.Y();
+ }
+ }
+
+ // active pane
+ ScSplitPos ePos = SC_SPLIT_BOTTOMLEFT;
+ switch( rTabSett.meActivePane )
+ {
+ // no horizontal split -> always use left panes
+ // no vertical split -> always use *bottom* panes
+ case SCEXT_PANE_TOPLEFT:
+ ePos = bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT;
+ break;
+ case SCEXT_PANE_TOPRIGHT:
+ ePos = bHSplit ?
+ (bVSplit ? SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT) :
+ (bVSplit ? SC_SPLIT_TOPLEFT : SC_SPLIT_BOTTOMLEFT);
+ break;
+ case SCEXT_PANE_BOTTOMLEFT:
+ ePos = SC_SPLIT_BOTTOMLEFT;
+ break;
+ case SCEXT_PANE_BOTTOMRIGHT:
+ ePos = bHSplit ? SC_SPLIT_BOTTOMRIGHT : SC_SPLIT_BOTTOMLEFT;
+ break;
+ }
+ rViewTab.eWhichActive = ePos;
+
+ // cursor position
+ const ScAddress& rCursor = rTabSett.maCursor;
+ if( rCursor.IsValid() )
+ {
+ rViewTab.nCurX = rCursor.Col();
+ rViewTab.nCurY = rCursor.Row();
+ }
+
+ // sheet selection and selected ranges
+ ScMarkData& rMarkData = GetMarkData();
+ rMarkData.SelectTable( nTab, rTabSett.mbSelected );
+
+ // zoom for each sheet
+ if( rTabSett.mnNormalZoom )
+ rViewTab.aZoomX = rViewTab.aZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
+ if( rTabSett.mnPageZoom )
+ rViewTab.aPageZoomX = rViewTab.aPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
+
+ rViewTab.bShowGrid = rTabSett.mbShowGrid;
+
+ // get some settings from displayed Excel sheet, set at Calc document
+ if( nTab == GetTabNo() )
+ {
+ // selection only for displayed sheet, do not select single cell
+// Disabled, does not work correctly. Anyway, our own XML filters do not import a selection at all.
+// const ScRangeList& rSel = rTabSett.maSelection;
+// if( (rSel.Count() >= 2) || ((rSel.Count() == 1) && (*rSel.GetObject( 0 ) != ScRange( rCursor ))) )
+// rMarkData.MarkFromRangeList( rTabSett.maSelection, FALSE );
+
+ // grid color -- #i47435# set automatic grid color explicitly
+ if( pOptions )
+ {
+ Color aGridColor( rTabSett.maGridColor );
+ if( aGridColor.GetColor() == COL_AUTO )
+ aGridColor.SetColor( SC_STD_GRIDCOLOR );
+ pOptions->SetGridColor( aGridColor, EMPTY_STRING );
+ }
+
+ // view mode and default zoom (for new sheets) from current sheet
+ if( rTabSett.mnNormalZoom )
+ aDefZoomX = aDefZoomY = Fraction( rTabSett.mnNormalZoom, 100L );
+ if( rTabSett.mnPageZoom )
+ aDefPageZoomX = aDefPageZoomY = Fraction( rTabSett.mnPageZoom, 100L );
+ /* #i46820# set pagebreak mode via SetPagebreakMode(), this will
+ update map modes that are needed to draw text correctly. */
+ SetPagebreakMode( rTabSett.mbPageMode );
+ }
+ }
+ }
+
+ // RecalcPixPos oder so - auch nMPos - auch bei ReadUserData ??!?!
+}
+
+void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings)
+{
+ rSettings.realloc(SC_VIEWSETTINGS_COUNT);
+ // + 1, because we have to put the view id in the sequence
+ beans::PropertyValue* pSettings = rSettings.getArray();
+ if (pSettings)
+ {
+ sal_uInt16 nViewID(pViewShell->GetViewFrame()->GetCurViewId());
+ pSettings[SC_VIEW_ID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEWID));
+ rtl::OUStringBuffer sBuffer(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_VIEW)));
+ SvXMLUnitConverter::convertNumber(sBuffer, static_cast<sal_Int32>(nViewID));
+ pSettings[SC_VIEW_ID].Value <<= sBuffer.makeStringAndClear();
+
+ SCTAB nTabCount (pDoc->GetTableCount());
+ uno::Reference<lang::XMultiServiceFactory> xServiceFactory =
+ comphelper::getProcessServiceFactory();
+ DBG_ASSERT( xServiceFactory.is(), "got no service manager" );
+ if( xServiceFactory.is() )
+ {
+ rtl::OUString sName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.NamedPropertyValues"));
+ uno::Reference<container::XNameContainer> xNameContainer = uno::Reference<container::XNameContainer>(xServiceFactory->createInstance(sName), uno::UNO_QUERY);
+ if (xNameContainer.is())
+ {
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ if (pTabData[nTab])
+ {
+ uno::Sequence <beans::PropertyValue> aTableViewSettings;
+ pTabData[nTab]->WriteUserDataSequence(aTableViewSettings, *this, nTab);
+ String sTabName;
+ GetDocument()->GetName( nTab, sTabName );
+ rtl::OUString sOUName(sTabName);
+ uno::Any aAny;
+ aAny <<= aTableViewSettings;
+ try
+ {
+ xNameContainer->insertByName(sTabName, aAny);
+ }
+ //#101739#; two tables with the same name are possible
+ catch ( container::ElementExistException& )
+ {
+ DBG_ERRORFILE("seems there are two tables with the same name");
+ }
+ catch ( uno::RuntimeException& )
+ {
+ DBG_ERRORFILE("something went wrong");
+ }
+ }
+ }
+ pSettings[SC_TABLE_VIEWSETTINGS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_TABLES));
+ pSettings[SC_TABLE_VIEWSETTINGS].Value <<= xNameContainer;
+ }
+ }
+
+ String sName;
+ GetDocument()->GetName( nTabNo, sName );
+ rtl::OUString sOUName(sName);
+ pSettings[SC_ACTIVE_TABLE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ACTIVETABLE));
+ pSettings[SC_ACTIVE_TABLE].Value <<= sOUName;
+ pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_HORIZONTALSCROLLBARWIDTH));
+ pSettings[SC_HORIZONTAL_SCROLL_BAR_WIDTH].Value <<= sal_Int32(pView->GetTabBarWidth());
+ sal_Int32 nZoomValue ((pThisTab->aZoomY.GetNumerator() * 100) / pThisTab->aZoomY.GetDenominator());
+ sal_Int32 nPageZoomValue ((pThisTab->aPageZoomY.GetNumerator() * 100) / pThisTab->aPageZoomY.GetDenominator());
+ pSettings[SC_ZOOM_TYPE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMTYPE));
+ pSettings[SC_ZOOM_TYPE].Value <<= sal_Int16(pThisTab->eZoomType);
+ pSettings[SC_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_ZOOMVALUE));
+ pSettings[SC_ZOOM_VALUE].Value <<= nZoomValue;
+ pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_PAGEVIEWZOOMVALUE));
+ pSettings[SC_PAGE_VIEW_ZOOM_VALUE].Value <<= nPageZoomValue;
+ pSettings[SC_PAGE_BREAK_PREVIEW].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_SHOWPAGEBREAKPREVIEW));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_PAGE_BREAK_PREVIEW].Value, bPagebreak);
+
+ if (pOptions)
+ {
+ pSettings[SC_SHOWZERO].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWZERO));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWZERO].Value, pOptions->GetOption( VOPT_NULLVALS ) );
+ pSettings[SC_SHOWNOTES].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWNOTES));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWNOTES].Value, pOptions->GetOption( VOPT_NOTES ) );
+ pSettings[SC_SHOWGRID].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWGRID));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWGRID].Value, pOptions->GetOption( VOPT_GRID ) );
+ pSettings[SC_GRIDCOLOR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_GRIDCOLOR));
+ String aColorName;
+ Color aColor = pOptions->GetGridColor(&aColorName);
+ pSettings[SC_GRIDCOLOR].Value <<= static_cast<sal_Int64>(aColor.GetColor());
+ pSettings[SC_SHOWPAGEBR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHOWPAGEBR));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHOWPAGEBR].Value, pOptions->GetOption( VOPT_PAGEBREAKS ) );
+ pSettings[SC_COLROWHDR].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COLROWHDR));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_COLROWHDR].Value, pOptions->GetOption( VOPT_HEADER ) );
+ pSettings[SC_SHEETTABS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SHEETTABS));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SHEETTABS].Value, pOptions->GetOption( VOPT_TABCONTROLS ) );
+ pSettings[SC_OUTLSYMB].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_OUTLSYMB));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_OUTLSYMB].Value, pOptions->GetOption( VOPT_OUTLINER ) );
+
+ const ScGridOptions& aGridOpt = pOptions->GetGridOptions();
+ pSettings[SC_SNAPTORASTER].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_SNAPTORASTER));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_SNAPTORASTER].Value, aGridOpt.GetUseGridSnap() );
+ pSettings[SC_RASTERVIS].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERVIS));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERVIS].Value, aGridOpt.GetGridVisible() );
+ pSettings[SC_RASTERRESX].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESX));
+ pSettings[SC_RASTERRESX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawX() );
+ pSettings[SC_RASTERRESY].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERRESY));
+ pSettings[SC_RASTERRESY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDrawY() );
+ pSettings[SC_RASTERSUBX].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBX));
+ pSettings[SC_RASTERSUBX].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionX() );
+ pSettings[SC_RASTERSUBY].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSUBY));
+ pSettings[SC_RASTERSUBY].Value <<= static_cast<sal_Int32> ( aGridOpt.GetFldDivisionY() );
+ pSettings[SC_RASTERSYNC].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_RASTERSYNC));
+ ScUnoHelpFunctions::SetBoolInAny( pSettings[SC_RASTERSYNC].Value, aGridOpt.GetSynchronize() );
+ }
+ }
+}
+
+void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
+{
+ Fraction aZoomX, aZoomY, aPageZoomX, aPageZoomY; //! evaluate (all sheets?)
+
+ std::vector<bool> aHasZoomVect( GetDocument()->GetTableCount(), false );
+
+ sal_Int32 nCount(rSettings.getLength());
+ sal_Int32 nTemp32(0);
+ sal_Int16 nTemp16(0);
+ sal_Bool bPageMode(sal_False);
+ for (sal_Int32 i = 0; i < nCount; i++)
+ {
+ // SC_VIEWID has to parse and use by mba
+ rtl::OUString sName(rSettings[i].Name);
+ if (sName.compareToAscii(SC_TABLES) == 0)
+ {
+ uno::Reference<container::XNameContainer> xNameContainer;
+ if ((rSettings[i].Value >>= xNameContainer) && xNameContainer->hasElements())
+ {
+ uno::Sequence< rtl::OUString > aNames(xNameContainer->getElementNames());
+ for (sal_Int32 nTabPos = 0; nTabPos < aNames.getLength(); nTabPos++)
+ {
+ String sTabName(aNames[nTabPos]);
+ SCTAB nTab(0);
+ if (GetDocument()->GetTable(sTabName, nTab))
+ {
+ uno::Any aAny = xNameContainer->getByName(aNames[nTabPos]);
+ uno::Sequence<beans::PropertyValue> aTabSettings;
+ if (aAny >>= aTabSettings)
+ {
+ pTabData[nTab] = new ScViewDataTable;
+ bool bHasZoom = false;
+ pTabData[nTab]->ReadUserDataSequence(aTabSettings, *this, nTab, bHasZoom);
+ aHasZoomVect[nTab] = bHasZoom;
+ }
+ }
+ }
+ }
+ }
+ else if (sName.compareToAscii(SC_ACTIVETABLE) == 0)
+ {
+ rtl::OUString sValue;
+ if(rSettings[i].Value >>= sValue)
+ {
+ String sTabName(sValue);
+ SCTAB nTab(0);
+ if (GetDocument()->GetTable(sTabName, nTab))
+ nTabNo = nTab;
+ }
+ }
+ else if (sName.compareToAscii(SC_HORIZONTALSCROLLBARWIDTH) == 0)
+ {
+ if (rSettings[i].Value >>= nTemp32)
+ pView->SetTabBarWidth(nTemp32);
+ }
+ else if (sName.compareToAscii(SC_RELHORIZONTALTABBARWIDTH) == 0)
+ {
+ double fWidth = 0.0;
+ if (rSettings[i].Value >>= fWidth)
+ pView->SetPendingRelTabBarWidth( fWidth );
+ }
+ else if (sName.compareToAscii(SC_ZOOMTYPE) == 0)
+ {
+ if (rSettings[i].Value >>= nTemp16)
+ eDefZoomType = SvxZoomType(nTemp16);
+ }
+ else if (sName.compareToAscii(SC_ZOOMVALUE) == 0)
+ {
+ if (rSettings[i].Value >>= nTemp32)
+ {
+ Fraction aZoom(nTemp32, 100);
+ aDefZoomX = aDefZoomY = aZoom;
+ }
+ }
+ else if (sName.compareToAscii(SC_PAGEVIEWZOOMVALUE) == 0)
+ {
+ if (rSettings[i].Value >>= nTemp32)
+ {
+ Fraction aZoom(nTemp32, 100);
+ aDefPageZoomX = aDefPageZoomY = aZoom;
+ }
+ }
+ else if (sName.compareToAscii(SC_SHOWPAGEBREAKPREVIEW) == 0)
+ bPageMode = ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value );
+ else if ( sName.compareToAscii( SC_UNO_SHOWZERO ) == 0 )
+ pOptions->SetOption(VOPT_NULLVALS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_SHOWNOTES ) == 0 )
+ pOptions->SetOption(VOPT_NOTES, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_SHOWGRID ) == 0 )
+ pOptions->SetOption(VOPT_GRID, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_GRIDCOLOR ) == 0 )
+ {
+ sal_Int64 nColor = 0;
+ if (rSettings[i].Value >>= nColor)
+ {
+ String aColorName;
+ Color aColor(static_cast<sal_uInt32>(nColor));
+ // #i47435# set automatic grid color explicitly
+ if( aColor.GetColor() == COL_AUTO )
+ aColor.SetColor( SC_STD_GRIDCOLOR );
+ pOptions->SetGridColor(aColor, aColorName);
+ }
+ }
+ else if ( sName.compareToAscii( SC_UNO_SHOWPAGEBR ) == 0 )
+ pOptions->SetOption(VOPT_PAGEBREAKS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_COLROWHDR ) == 0 )
+ pOptions->SetOption(VOPT_HEADER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_SHEETTABS ) == 0 )
+ pOptions->SetOption(VOPT_TABCONTROLS, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_OUTLSYMB ) == 0 )
+ pOptions->SetOption(VOPT_OUTLINER, ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_SHOWOBJ ) == 0 )
+ {
+ // #i80528# placeholders not supported anymore
+ if ( rSettings[i].Value >>= nTemp16 )
+ pOptions->SetObjMode( VOBJ_TYPE_OLE, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
+ }
+ else if ( sName.compareToAscii( SC_UNO_SHOWCHARTS ) == 0 )
+ {
+ // #i80528# placeholders not supported anymore
+ if ( rSettings[i].Value >>= nTemp16 )
+ pOptions->SetObjMode( VOBJ_TYPE_CHART, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
+ }
+ else if ( sName.compareToAscii( SC_UNO_SHOWDRAW ) == 0 )
+ {
+ // #i80528# placeholders not supported anymore
+ if ( rSettings[i].Value >>= nTemp16 )
+ pOptions->SetObjMode( VOBJ_TYPE_DRAW, (nTemp16 == 1) ? VOBJ_MODE_HIDE : VOBJ_MODE_SHOW );
+ }
+ else
+ {
+ ScGridOptions aGridOpt(pOptions->GetGridOptions());
+ if ( sName.compareToAscii( SC_UNO_SNAPTORASTER ) == 0 )
+ aGridOpt.SetUseGridSnap( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_RASTERVIS ) == 0 )
+ aGridOpt.SetGridVisible( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ else if ( sName.compareToAscii( SC_UNO_RASTERRESX ) == 0 )
+ aGridOpt.SetFldDrawX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
+ else if ( sName.compareToAscii( SC_UNO_RASTERRESY ) == 0 )
+ aGridOpt.SetFldDrawY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
+ else if ( sName.compareToAscii( SC_UNO_RASTERSUBX ) == 0 )
+ aGridOpt.SetFldDivisionX( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
+ else if ( sName.compareToAscii( SC_UNO_RASTERSUBY ) == 0 )
+ aGridOpt.SetFldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
+ else if ( sName.compareToAscii( SC_UNO_RASTERSYNC ) == 0 )
+ aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ pOptions->SetGridOptions(aGridOpt);
+ }
+ }
+
+ // copy default zoom to sheets where a different one wasn't specified
+ for (SCTAB nZoomTab=0; nZoomTab<=MAXTAB; ++nZoomTab)
+ if (pTabData[nZoomTab] && ( nZoomTab >= static_cast<SCTAB>(aHasZoomVect.size()) || !aHasZoomVect[nZoomTab] ))
+ {
+ pTabData[nZoomTab]->eZoomType = eDefZoomType;
+ pTabData[nZoomTab]->aZoomX = aDefZoomX;
+ pTabData[nZoomTab]->aZoomY = aDefZoomY;
+ pTabData[nZoomTab]->aPageZoomX = aDefPageZoomX;
+ pTabData[nZoomTab]->aPageZoomY = aDefPageZoomY;
+ }
+
+ if (nCount)
+ SetPagebreakMode( bPageMode );
+
+ // #i47426# write view options to document, needed e.g. for Excel export
+ pDoc->SetViewOptions( *pOptions );
+}
+
+void ScViewData::SetOptions( const ScViewOptions& rOpt )
+{
+ // if visibility of horiz. ScrollBar is changed, TabBar may have to be resized...
+ BOOL bHScrollChanged = ( rOpt.GetOption(VOPT_HSCROLL) != pOptions->GetOption(VOPT_HSCROLL) );
+
+ // if graphics are turned on or off, animation has to be started or stopped
+ // graphics are controlled by VOBJ_TYPE_OLE
+ BOOL bGraphicsChanged = ( pOptions->GetObjMode(VOBJ_TYPE_OLE) !=
+ rOpt.GetObjMode(VOBJ_TYPE_OLE) );
+
+ *pOptions = rOpt;
+ DBG_ASSERT( pView, "No View" );
+
+ if( pView )
+ {
+ pView->ViewOptionsHasChanged( bHScrollChanged, bGraphicsChanged );
+ }
+}
+
+Point ScViewData::GetMousePosPixel()
+{
+ DBG_ASSERT( pView, "GetMousePosPixel() ohne View" );
+ return pView->GetMousePosPixel();
+}
+
+void ScViewData::UpdateInputHandler( BOOL bForce, BOOL bStopEditing )
+{
+ if (pViewShell)
+ pViewShell->UpdateInputHandler( bForce, bStopEditing );
+}
+
+BOOL ScViewData::IsOle()
+{
+ return pDocShell && pDocShell->IsOle();
+}
+
+BOOL ScViewData::UpdateFixX( SCTAB nTab ) // TRUE = Wert geaendert
+{
+ if (!ValidTab(nTab)) // Default
+ nTab=nTabNo; // akuelle Tabelle
+
+ if (!pView || pTabData[nTab]->eHSplitMode != SC_SPLIT_FIX)
+ return FALSE;
+
+ ScDocument* pLocalDoc = GetDocument();
+ if (!pLocalDoc->HasTable(nTab)) // #114007# if called from reload, the sheet may not exist
+ return FALSE;
+
+ SCCOL nFix = pTabData[nTab]->nFixPosX;
+ long nNewPos = 0;
+ for (SCCOL nX=pTabData[nTab]->nPosX[SC_SPLIT_LEFT]; nX<nFix; nX++)
+ {
+ USHORT nTSize = pLocalDoc->GetColWidth( nX, nTab );
+ if (nTSize)
+ {
+ long nPix = ToPixel( nTSize, nPPTX );
+ nNewPos += nPix;
+ }
+ }
+ nNewPos += pView->GetGridOffset().X();
+ if (nNewPos != pTabData[nTab]->nHSplitPos)
+ {
+ pTabData[nTab]->nHSplitPos = nNewPos;
+ if (nTab == nTabNo)
+ RecalcPixPos(); //! sollte nicht noetig sein !!!
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOL ScViewData::UpdateFixY( SCTAB nTab ) // TRUE = Wert geaendert
+{
+ if (!ValidTab(nTab)) // Default
+ nTab=nTabNo; // akuelle Tabelle
+
+ if (!pView || pTabData[nTab]->eVSplitMode != SC_SPLIT_FIX)
+ return FALSE;
+
+ ScDocument* pLocalDoc = GetDocument();
+ if (!pLocalDoc->HasTable(nTab)) // #114007# if called from reload, the sheet may not exist
+ return FALSE;
+
+ SCROW nFix = pTabData[nTab]->nFixPosY;
+ long nNewPos = 0;
+ for (SCROW nY=pTabData[nTab]->nPosY[SC_SPLIT_TOP]; nY<nFix; nY++)
+ {
+ USHORT nTSize = pLocalDoc->GetRowHeight( nY, nTab );
+ if (nTSize)
+ {
+ long nPix = ToPixel( nTSize, nPPTY );
+ nNewPos += nPix;
+ }
+ }
+ nNewPos += pView->GetGridOffset().Y();
+ if (nNewPos != pTabData[nTab]->nVSplitPos)
+ {
+ pTabData[nTab]->nVSplitPos = nNewPos;
+ if (nTab == nTabNo)
+ RecalcPixPos(); //! sollte nicht noetig sein !!!
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+void ScViewData::UpdateOutlinerFlags( Outliner& rOutl ) const
+{
+ ScDocument* pLocalDoc = GetDocument();
+ BOOL bOnlineSpell = pLocalDoc->GetDocOptions().IsAutoSpell();
+
+ ULONG nCntrl = rOutl.GetControlWord();
+ nCntrl |= EE_CNTRL_URLSFXEXECUTE;
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ nCntrl |= EE_CNTRL_AUTOCORRECT;
+ if( bOnlineSpell )
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ rOutl.SetControlWord(nCntrl);
+
+ rOutl.SetCalcFieldValueHdl( LINK( SC_MOD(), ScModule, CalcFieldValueHdl ) );
+
+ // #97417# don't call GetSpellChecker if online spelling isn't enabled.
+ // The language for AutoCorrect etc. is taken from the pool defaults
+ // (set in ScDocument::UpdateDrawLanguages)
+
+ if ( bOnlineSpell )
+ {
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1> xXSpellChecker1( LinguMgr::GetSpellChecker() );
+ rOutl.SetSpeller( xXSpellChecker1 );
+ }
+
+ rOutl.SetDefaultHorizontalTextDirection(
+ (EEHorizontalTextDirection)pLocalDoc->GetEditTextDirection( nTabNo ) );
+}
+
+ScAddress ScViewData::GetCurPos() const
+{
+ return ScAddress( GetCurX(), GetCurY(), GetTabNo() );
+}
+
+
+// static
+void ScViewData::AddPixelsWhile( long & rScrY, long nEndPixels, SCROW & rPosY,
+ SCROW nEndRow, double nPPTY, const ScDocument * pDoc, SCTAB nTabNo )
+{
+ SCROW nRow = rPosY;
+ while (rScrY <= nEndPixels && nRow <= nEndRow)
+ {
+ SCROW nHeightEndRow;
+ USHORT nHeight = pDoc->GetRowHeight( nRow, nTabNo, NULL, &nHeightEndRow);
+ if (nHeightEndRow > nEndRow)
+ nHeightEndRow = nEndRow;
+ if (!nHeight)
+ nRow = nHeightEndRow + 1;
+ else
+ {
+ SCROW nRows = nHeightEndRow - nRow + 1;
+ sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
+ sal_Int64 nAdd = nPixel * nRows;
+ if (nAdd + rScrY > nEndPixels)
+ {
+ sal_Int64 nDiff = rScrY + nAdd - nEndPixels;
+ nRows -= static_cast<SCROW>(nDiff / nPixel);
+ nAdd = nPixel * nRows;
+ // We're looking for a value that satisfies loop condition.
+ if (nAdd + rScrY <= nEndPixels)
+ {
+ ++nRows;
+ nAdd += nPixel;
+ }
+ }
+ rScrY += static_cast<long>(nAdd);
+ nRow += nRows;
+ }
+ }
+ if (nRow > rPosY)
+ --nRow;
+ rPosY = nRow;
+}
+
+
+// static
+void ScViewData::AddPixelsWhileBackward( long & rScrY, long nEndPixels,
+ SCROW & rPosY, SCROW nStartRow, double nPPTY, const ScDocument * pDoc,
+ SCTAB nTabNo )
+{
+ SCROW nRow = rPosY;
+ while (rScrY <= nEndPixels && nRow >= nStartRow)
+ {
+ SCROW nHeightStartRow;
+ USHORT nHeight = pDoc->GetRowHeight( nRow, nTabNo, &nHeightStartRow, NULL);
+ if (nHeightStartRow < nStartRow)
+ nHeightStartRow = nStartRow;
+ if (!nHeight)
+ nRow = nHeightStartRow - 1;
+ else
+ {
+ SCROW nRows = nRow - nHeightStartRow + 1;
+ sal_Int64 nPixel = ToPixel( nHeight, nPPTY);
+ sal_Int64 nAdd = nPixel * nRows;
+ if (nAdd + rScrY > nEndPixels)
+ {
+ sal_Int64 nDiff = nAdd + rScrY - nEndPixels;
+ nRows -= static_cast<SCROW>(nDiff / nPixel);
+ nAdd = nPixel * nRows;
+ // We're looking for a value that satisfies loop condition.
+ if (nAdd + rScrY <= nEndPixels)
+ {
+ ++nRows;
+ nAdd += nPixel;
+ }
+ }
+ rScrY += static_cast<long>(nAdd);
+ nRow -= nRows;
+ }
+ }
+ if (nRow < rPosY)
+ ++nRow;
+ rPosY = nRow;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
new file mode 100644
index 000000000000..04ebe2d42c09
--- /dev/null
+++ b/sc/source/ui/view/viewfun2.cxx
@@ -0,0 +1,3159 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#define _SVSTDARR_STRINGS
+#include <editeng/boxitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <svl/srchitem.hxx>
+#include <sfx2/linkmgr.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/objitem.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/stritem.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/svstdarr.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/waitobj.hxx>
+
+#include <basic/sbstar.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+using namespace com::sun::star;
+
+#include "viewfunc.hxx"
+
+#include "sc.hrc"
+#include "globstr.hrc"
+
+#include "attrib.hxx"
+#include "autoform.hxx"
+#include "cell.hxx" // EnterAutoSum
+#include "cellmergeoption.hxx"
+#include "compiler.hxx"
+#include "docfunc.hxx"
+#include "docpool.hxx"
+#include "docsh.hxx"
+#include "global.hxx"
+#include "patattr.hxx"
+#include "printfun.hxx"
+#include "rangenam.hxx"
+#include "rangeutl.hxx"
+#include "refundo.hxx"
+#include "tablink.hxx"
+#include "tabvwsh.hxx"
+#include "uiitems.hxx"
+#include "undoblk.hxx"
+#include "undocell.hxx"
+#include "undotab.hxx"
+#include "sizedev.hxx"
+#include "editable.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "inputwin.hxx"
+#include "funcdesc.hxx"
+#include "docuno.hxx"
+#include "charthelper.hxx"
+#include "tabbgcolor.hxx"
+
+#include <basic/sbstar.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/script/XLibraryContainer.hpp>
+
+#include <boost/scoped_ptr.hpp>
+
+using namespace com::sun::star;
+using ::rtl::OUStringBuffer;
+using ::rtl::OUString;
+
+// helper func defined in docfunc.cxx
+void VBA_DeleteModule( ScDocShell& rDocSh, String& sModuleName );
+
+// STATIC DATA ---------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::AdjustBlockHeight( BOOL bPaint, ScMarkData* pMarkData )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ if (!pMarkData)
+ pMarkData = &GetViewData()->GetMarkData();
+
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
+ SCCOLROW nRangeCnt = pMarkData->GetMarkRowRanges( pRanges );
+ if (nRangeCnt == 0)
+ {
+ pRanges[0] = pRanges[1] = GetViewData()->GetCurY();
+ nRangeCnt = 1;
+ }
+
+ double nPPTX = GetViewData()->GetPPTX();
+ double nPPTY = GetViewData()->GetPPTY();
+ Fraction aZoomX = GetViewData()->GetZoomX();
+ Fraction aZoomY = GetViewData()->GetZoomY();
+
+ ScSizeDeviceProvider aProv(pDocSh);
+ if (aProv.IsPrinter())
+ {
+ nPPTX = aProv.GetPPTX();
+ nPPTY = aProv.GetPPTY();
+ aZoomX = aZoomY = Fraction( 1, 1 );
+ }
+
+ BOOL bAnyChanged = FALSE;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ {
+ if (pMarkData->GetTableSelect(nTab))
+ {
+ SCCOLROW* pOneRange = pRanges;
+ BOOL bChanged = FALSE;
+ SCROW nPaintY = 0;
+ for (SCROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCROW nStartNo = *(pOneRange++);
+ SCROW nEndNo = *(pOneRange++);
+ if (pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, 0, aProv.GetDevice(),
+ nPPTX, nPPTY, aZoomX, aZoomY, FALSE ))
+ {
+ if (!bChanged)
+ nPaintY = nStartNo;
+ bAnyChanged = bChanged = TRUE;
+ }
+ }
+ if ( bPaint && bChanged )
+ pDocSh->PostPaint( 0, nPaintY, nTab, MAXCOL, MAXROW, nTab,
+ PAINT_GRID | PAINT_LEFT );
+ }
+ }
+ delete[] pRanges;
+
+ if ( bPaint && bAnyChanged )
+ pDocSh->UpdateOle(GetViewData());
+
+ return bAnyChanged;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, BOOL bPaint )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ double nPPTX = GetViewData()->GetPPTX();
+ double nPPTY = GetViewData()->GetPPTY();
+ Fraction aZoomX = GetViewData()->GetZoomX();
+ Fraction aZoomY = GetViewData()->GetZoomY();
+ USHORT nOldPixel = 0;
+ if (nStartRow == nEndRow)
+ nOldPixel = (USHORT) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY);
+
+ ScSizeDeviceProvider aProv(pDocSh);
+ if (aProv.IsPrinter())
+ {
+ nPPTX = aProv.GetPPTX();
+ nPPTY = aProv.GetPPTY();
+ aZoomX = aZoomY = Fraction( 1, 1 );
+ }
+ BOOL bChanged = pDoc->SetOptimalHeight( nStartRow, nEndRow, nTab, 0, aProv.GetDevice(),
+ nPPTX, nPPTY, aZoomX, aZoomY, FALSE );
+
+ if (bChanged && ( nStartRow == nEndRow ))
+ {
+ USHORT nNewPixel = (USHORT) (pDoc->GetRowHeight(nStartRow,nTab) * nPPTY);
+ if ( nNewPixel == nOldPixel )
+ bChanged = FALSE;
+ }
+
+ if ( bPaint && bChanged )
+ pDocSh->PostPaint( 0, nStartRow, nTab, MAXCOL, MAXROW, nTab,
+ PAINT_GRID | PAINT_LEFT );
+
+ return bChanged;
+}
+
+
+//----------------------------------------------------------------------------
+
+enum ScAutoSum
+{
+ ScAutoSumNone = 0,
+ ScAutoSumData,
+ ScAutoSumSum
+};
+
+
+ScAutoSum lcl_IsAutoSumData( ScDocument* pDoc, SCCOL nCol, SCROW nRow,
+ SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
+{
+ ScBaseCell* pCell;
+ pDoc->GetCell( nCol, nRow, nTab, pCell );
+ if ( pCell && pCell->HasValueData() )
+ {
+ if ( pCell->GetCellType() == CELLTYPE_FORMULA )
+ {
+ ScTokenArray* pCode = ((ScFormulaCell*)pCell)->GetCode();
+ if ( pCode && pCode->GetOuterFuncOpCode() == ocSum )
+ {
+ if ( pCode->GetAdjacentExtendOfOuterFuncRefs( nExtend,
+ ScAddress( nCol, nRow, nTab ), eDir ) )
+ return ScAutoSumSum;
+ }
+ }
+ return ScAutoSumData;
+ }
+ return ScAutoSumNone;
+}
+
+
+//----------------------------------------------------------------------------
+
+#define SC_AUTOSUM_MAXCOUNT 20
+
+ScAutoSum lcl_SeekAutoSumData( ScDocument* pDoc, SCCOL& nCol, SCROW& nRow,
+ SCTAB nTab, ScDirection eDir, SCCOLROW& nExtend )
+{
+ USHORT nCount = 0;
+ while (nCount < SC_AUTOSUM_MAXCOUNT)
+ {
+ if ( eDir == DIR_TOP )
+ {
+ if (nRow > 0)
+ --nRow;
+ else
+ return ScAutoSumNone;
+ }
+ else
+ {
+ if (nCol > 0)
+ --nCol;
+ else
+ return ScAutoSumNone;
+ }
+ ScAutoSum eSum;
+ if ( (eSum = lcl_IsAutoSumData(
+ pDoc, nCol, nRow, nTab, eDir, nExtend )) != ScAutoSumNone )
+ return eSum;
+ ++nCount;
+ }
+ return ScAutoSumNone;
+}
+
+#undef SC_AUTOSUM_MAXCOUNT
+
+//----------------------------------------------------------------------------
+
+bool lcl_FindNextSumEntryInColumn( ScDocument* pDoc, SCCOL nCol, SCROW& nRow,
+ SCTAB nTab, SCCOLROW& nExtend, SCROW nMinRow )
+{
+ const SCROW nTmp = nRow;
+ ScAutoSum eSkip = ScAutoSumNone;
+ while ( ( eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_TOP, nExtend ) ) == ScAutoSumData &&
+ nRow > nMinRow )
+ {
+ --nRow;
+ }
+ if ( eSkip == ScAutoSumSum && nRow < nTmp )
+ {
+ return true;
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
+
+bool lcl_FindNextSumEntryInRow( ScDocument* pDoc, SCCOL& nCol, SCROW nRow,
+ SCTAB nTab, SCCOLROW& nExtend, SCROW nMinCol )
+{
+ const SCCOL nTmp = nCol;
+ ScAutoSum eSkip = ScAutoSumNone;
+ while ( ( eSkip = lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_LEFT, nExtend ) ) == ScAutoSumData &&
+ nCol > nMinCol )
+ {
+ --nCol;
+ }
+ if ( eSkip == ScAutoSumSum && nCol < nTmp )
+ {
+ return true;
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
+
+bool lcl_GetAutoSumForColumnRange( ScDocument* pDoc, ScRangeList& rRangeList, const ScRange& rRange )
+{
+ const ScAddress aStart = rRange.aStart;
+ const ScAddress aEnd = rRange.aEnd;
+ if ( aStart.Col() != aEnd.Col() )
+ {
+ return false;
+ }
+
+ const SCTAB nTab = aEnd.Tab();
+ const SCCOL nCol = aEnd.Col();
+ SCROW nEndRow = aEnd.Row();
+ SCROW nStartRow = nEndRow;
+ SCCOLROW nExtend = 0;
+ const ScAutoSum eSum = lcl_IsAutoSumData( pDoc, nCol, nEndRow, nTab, DIR_TOP, nExtend /*out*/ );
+
+ if ( eSum == ScAutoSumSum )
+ {
+ bool bContinue = false;
+ do
+ {
+ rRangeList.Append( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
+ nEndRow = static_cast< SCROW >( nExtend );
+ if ( ( bContinue = lcl_FindNextSumEntryInColumn( pDoc, nCol, nEndRow /*inout*/, nTab, nExtend /*out*/, aStart.Row() ) ) == true )
+ {
+ nStartRow = nEndRow;
+ }
+ } while ( bContinue );
+ }
+ else
+ {
+ while ( nStartRow > aStart.Row() &&
+ lcl_IsAutoSumData( pDoc, nCol, nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ ) != ScAutoSumSum )
+ {
+ --nStartRow;
+ }
+ rRangeList.Append( ScRange( nCol, nStartRow, nTab, nCol, nEndRow, nTab ) );
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+bool lcl_GetAutoSumForRowRange( ScDocument* pDoc, ScRangeList& rRangeList, const ScRange& rRange )
+{
+ const ScAddress aStart = rRange.aStart;
+ const ScAddress aEnd = rRange.aEnd;
+ if ( aStart.Row() != aEnd.Row() )
+ {
+ return false;
+ }
+
+ const SCTAB nTab = aEnd.Tab();
+ const SCROW nRow = aEnd.Row();
+ SCCOL nEndCol = aEnd.Col();
+ SCCOL nStartCol = nEndCol;
+ SCCOLROW nExtend = 0;
+ const ScAutoSum eSum = lcl_IsAutoSumData( pDoc, nEndCol, nRow, nTab, DIR_LEFT, nExtend /*out*/ );
+
+ if ( eSum == ScAutoSumSum )
+ {
+ bool bContinue = false;
+ do
+ {
+ rRangeList.Append( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
+ nEndCol = static_cast< SCCOL >( nExtend );
+ if ( ( bContinue = lcl_FindNextSumEntryInRow( pDoc, nEndCol /*inout*/, nRow, nTab, nExtend /*out*/, aStart.Col() ) ) == true )
+ {
+ nStartCol = nEndCol;
+ }
+ } while ( bContinue );
+ }
+ else
+ {
+ while ( nStartCol > aStart.Col() &&
+ lcl_IsAutoSumData( pDoc, nStartCol-1, nRow, nTab, DIR_LEFT, nExtend /*out*/ ) != ScAutoSumSum )
+ {
+ --nStartCol;
+ }
+ rRangeList.Append( ScRange( nStartCol, nRow, nTab, nEndCol, nRow, nTab ) );
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::GetAutoSumArea( ScRangeList& rRangeList )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+
+ SCCOL nStartCol = nCol;
+ SCROW nStartRow = nRow;
+ SCCOL nEndCol = nCol;
+ SCROW nEndRow = nRow;
+ SCCOL nSeekCol = nCol;
+ SCROW nSeekRow = nRow;
+ SCCOLROW nExtend; // wird per Reference gueltig bei ScAutoSumSum
+
+ BOOL bCol = FALSE;
+ BOOL bRow = FALSE;
+
+ ScAutoSum eSum;
+ if ( nRow != 0
+ && ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab,
+ DIR_TOP, nExtend /*out*/ )) == ScAutoSumData )
+ && ((eSum = lcl_IsAutoSumData( pDoc, nCol, nRow-1, nTab,
+ DIR_LEFT, nExtend /*out*/ )) == ScAutoSumData )
+ )
+ {
+ bRow = TRUE;
+ nSeekRow = nRow - 1;
+ }
+ else if ( nCol != 0 && (eSum = lcl_IsAutoSumData( pDoc, nCol-1, nRow, nTab,
+ DIR_LEFT, nExtend /*out*/ )) == ScAutoSumData )
+ {
+ bCol = TRUE;
+ nSeekCol = nCol - 1;
+ }
+ else if ( (eSum = lcl_SeekAutoSumData( pDoc, nCol, nSeekRow, nTab, DIR_TOP, nExtend /*out*/ )) != ScAutoSumNone )
+ bRow = TRUE;
+ else if (( eSum = lcl_SeekAutoSumData( pDoc, nSeekCol, nRow, nTab, DIR_LEFT, nExtend /*out*/ )) != ScAutoSumNone )
+ bCol = TRUE;
+
+ if ( bCol || bRow )
+ {
+ if ( bRow )
+ {
+ nStartRow = nSeekRow; // nSeekRow evtl. per Reference angepasst
+ if ( eSum == ScAutoSumSum )
+ nEndRow = nStartRow; // nur Summen summieren
+ else
+ nEndRow = nRow - 1; // Datenbereich evtl. nach unten erweitern
+ }
+ else
+ {
+ nStartCol = nSeekCol; // nSeekCol evtl. per Reference angepasst
+ if ( eSum == ScAutoSumSum )
+ nEndCol = nStartCol; // nur Summen summieren
+ else
+ nEndCol = nCol - 1; // Datenbereich evtl. nach rechts erweitern
+ }
+ BOOL bContinue = FALSE;
+ do
+ {
+ if ( eSum == ScAutoSumData )
+ {
+ if ( bRow )
+ {
+ while ( nStartRow != 0 && lcl_IsAutoSumData( pDoc, nCol,
+ nStartRow-1, nTab, DIR_TOP, nExtend /*out*/ ) == eSum )
+ --nStartRow;
+ }
+ else
+ {
+ while ( nStartCol != 0 && lcl_IsAutoSumData( pDoc, nStartCol-1,
+ nRow, nTab, DIR_LEFT, nExtend /*out*/ ) == eSum )
+ --nStartCol;
+ }
+ }
+ rRangeList.Append(
+ ScRange( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab ) );
+ if ( eSum == ScAutoSumSum )
+ {
+ if ( bRow )
+ {
+ nEndRow = static_cast< SCROW >( nExtend );
+ if ( ( bContinue = lcl_FindNextSumEntryInColumn( pDoc, nCol, nEndRow /*inout*/, nTab, nExtend /*out*/, 0 ) ) == true )
+ {
+ nStartRow = nEndRow;
+ }
+ }
+ else
+ {
+ nEndCol = static_cast< SCCOL >( nExtend );
+ if ( ( bContinue = lcl_FindNextSumEntryInRow( pDoc, nEndCol /*inout*/, nRow, nTab, nExtend /*out*/, 0 ) ) == true )
+ {
+ nStartCol = nEndCol;
+ }
+ }
+ }
+ } while ( bContinue );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::EnterAutoSum(const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr)
+{
+ String aFormula = GetAutoSumFormula( rRangeList, bSubTotal, rAddr );
+ EnterBlock( aFormula, NULL );
+}
+
+//----------------------------------------------------------------------------
+
+bool ScViewFunc::AutoSum( const ScRange& rRange, bool bSubTotal, bool bSetCursor, bool bContinue )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ const SCTAB nTab = rRange.aStart.Tab();
+ SCCOL nStartCol = rRange.aStart.Col();
+ SCROW nStartRow = rRange.aStart.Row();
+ const SCCOL nEndCol = rRange.aEnd.Col();
+ const SCROW nEndRow = rRange.aEnd.Row();
+ SCCOLROW nExtend = 0; // out parameter for lcl_IsAutoSumData
+
+ // ignore rows at the top of the given range which don't contain autosum data
+ bool bRowData = false;
+ for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
+ {
+ for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
+ {
+ if ( lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_TOP, nExtend ) != ScAutoSumNone )
+ {
+ bRowData = true;
+ break;
+ }
+ }
+ if ( bRowData )
+ {
+ nStartRow = nRow;
+ break;
+ }
+ }
+ if ( !bRowData )
+ {
+ return false;
+ }
+
+ // ignore columns at the left of the given range which don't contain autosum data
+ bool bColData = false;
+ for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
+ {
+ for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
+ {
+ if ( lcl_IsAutoSumData( pDoc, nCol, nRow, nTab, DIR_LEFT, nExtend ) != ScAutoSumNone )
+ {
+ bColData = true;
+ break;
+ }
+ }
+ if ( bColData )
+ {
+ nStartCol = nCol;
+ break;
+ }
+ }
+ if ( !bColData )
+ {
+ return false;
+ }
+
+ const bool bEndRowEmpty = pDoc->IsBlockEmpty( nTab, nStartCol, nEndRow, nEndCol, nEndRow );
+ const bool bEndColEmpty = pDoc->IsBlockEmpty( nTab, nEndCol, nStartRow, nEndCol, nEndRow );
+ bool bRow = ( ( nStartRow != nEndRow ) && ( bEndRowEmpty || ( !bEndRowEmpty && !bEndColEmpty ) ) );
+ bool bCol = ( ( nStartCol != nEndCol ) && ( bEndColEmpty || nStartRow == nEndRow ) );
+
+ // find an empty row for entering the result
+ SCROW nInsRow = nEndRow;
+ if ( bRow && !bEndRowEmpty )
+ {
+ if ( nInsRow < MAXROW )
+ {
+ ++nInsRow;
+ while ( !pDoc->IsBlockEmpty( nTab, nStartCol, nInsRow, nEndCol, nInsRow ) )
+ {
+ if ( nInsRow < MAXROW )
+ {
+ ++nInsRow;
+ }
+ else
+ {
+ bRow = false;
+ break;
+ }
+ }
+ }
+ else
+ {
+ bRow = false;
+ }
+ }
+
+ // find an empty column for entering the result
+ SCCOL nInsCol = nEndCol;
+ if ( bCol && !bEndColEmpty )
+ {
+ if ( nInsCol < MAXCOL )
+ {
+ ++nInsCol;
+ while ( !pDoc->IsBlockEmpty( nTab, nInsCol, nStartRow, nInsCol, nEndRow ) )
+ {
+ if ( nInsCol < MAXCOL )
+ {
+ ++nInsCol;
+ }
+ else
+ {
+ bCol = false;
+ break;
+ }
+ }
+ }
+ else
+ {
+ bCol = false;
+ }
+ }
+
+ if ( !bRow && !bCol )
+ {
+ return false;
+ }
+
+ SCCOL nMarkEndCol = nEndCol;
+ SCROW nMarkEndRow = nEndRow;
+
+ if ( bRow )
+ {
+ // calculate the row sums for all columns of the given range
+
+ SCROW nSumEndRow = nEndRow;
+
+ if ( bEndRowEmpty )
+ {
+ // the last row of the given range is empty;
+ // don't take into account for calculating the autosum
+ --nSumEndRow;
+ }
+ else
+ {
+ // increase mark range
+ ++nMarkEndRow;
+ }
+
+ for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
+ {
+ if ( !pDoc->IsBlockEmpty( nTab, nCol, nStartRow, nCol, nSumEndRow ) )
+ {
+ ScRangeList aRangeList;
+ const ScRange aRange( nCol, nStartRow, nTab, nCol, nSumEndRow, nTab );
+ if ( lcl_GetAutoSumForColumnRange( pDoc, aRangeList, aRange ) )
+ {
+ const String aFormula = GetAutoSumFormula(
+ aRangeList, bSubTotal, ScAddress(nCol, nInsRow, nTab));
+ EnterData( nCol, nInsRow, nTab, aFormula );
+ }
+ }
+ }
+ }
+
+ if ( bCol )
+ {
+ // calculate the column sums for all rows of the given range
+
+ SCCOL nSumEndCol = nEndCol;
+
+ if ( bEndColEmpty )
+ {
+ // the last column of the given range is empty;
+ // don't take into account for calculating the autosum
+ --nSumEndCol;
+ }
+ else
+ {
+ // increase mark range
+ ++nMarkEndCol;
+ }
+
+ for ( SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow )
+ {
+ if ( !pDoc->IsBlockEmpty( nTab, nStartCol, nRow, nSumEndCol, nRow ) )
+ {
+ ScRangeList aRangeList;
+ const ScRange aRange( nStartCol, nRow, nTab, nSumEndCol, nRow, nTab );
+ if ( lcl_GetAutoSumForRowRange( pDoc, aRangeList, aRange ) )
+ {
+ const String aFormula = GetAutoSumFormula( aRangeList, bSubTotal, ScAddress(nInsCol, nRow, nTab) );
+ EnterData( nInsCol, nRow, nTab, aFormula );
+ }
+ }
+ }
+ }
+
+ // set new mark range and cursor position
+ const ScRange aMarkRange( nStartCol, nStartRow, nTab, nMarkEndCol, nMarkEndRow, nTab );
+ MarkRange( aMarkRange, FALSE, bContinue );
+ if ( bSetCursor )
+ {
+ SetCursor( nMarkEndCol, nMarkEndRow );
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+
+String ScViewFunc::GetAutoSumFormula( const ScRangeList& rRangeList, bool bSubTotal, const ScAddress& rAddr )
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ::boost::scoped_ptr<ScTokenArray> pArray(new ScTokenArray);
+
+ pArray->AddOpCode(bSubTotal ? ocSubTotal : ocSum);
+ pArray->AddOpCode(ocOpen);
+
+ if (bSubTotal)
+ {
+ pArray->AddDouble(9);
+ pArray->AddOpCode(ocSep);
+ }
+
+ ScRangeList aRangeList = rRangeList;
+ const ScRange* pFirst = aRangeList.First();
+ for (const ScRange* p = pFirst; p; p = aRangeList.Next())
+ {
+ if (p != pFirst)
+ pArray->AddOpCode(ocSep);
+ ScComplexRefData aRef;
+ aRef.InitRangeRel(*p, rAddr);
+ pArray->AddDoubleReference(aRef);
+ }
+
+ pArray->AddOpCode(ocClose);
+
+ ScCompiler aComp(pDoc, rAddr, *pArray);
+ aComp.SetGrammar(pDoc->GetGrammar());
+ OUStringBuffer aBuf;
+ aComp.CreateStringFromTokenArray(aBuf);
+ OUString aFormula = aBuf.makeStringAndClear();
+ aBuf.append(sal_Unicode('='));
+ aBuf.append(aFormula);
+ return aBuf.makeStringAndClear();
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::EnterBlock( const String& rString, const EditTextObject* pData )
+{
+ // Mehrfachselektion vorher abfragen...
+
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( rMark.IsMultiMarked() )
+ {
+ rMark.MarkToSimple();
+ if ( rMark.IsMultiMarked() )
+ { // "Einfuegen auf Mehrfachselektion nicht moeglich"
+ ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
+
+ // insert into single cell
+ if ( pData )
+ EnterData( nCol, nRow, nTab, pData );
+ else
+ EnterData( nCol, nRow, nTab, rString );
+ return;
+ }
+ }
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ String aNewStr = rString;
+ if ( pData )
+ {
+ const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() );
+ aEngine.SetText(*pData);
+
+ ScEditAttrTester aTester( &aEngine );
+ if (!aTester.NeedsObject())
+ {
+ aNewStr = aEngine.GetText();
+ pData = NULL;
+ }
+ }
+
+ // Einfuegen per PasteFromClip
+
+ WaitObject aWait( GetFrameWin() );
+
+ ScAddress aPos( nCol, nRow, nTab );
+
+ ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP );
+ pInsDoc->ResetClip( pDoc, nTab );
+
+ if (aNewStr.GetChar(0) == '=') // Formel ?
+ {
+ // SetString geht nicht, weil in Clipboard-Dokumenten nicht kompiliert wird!
+ ScFormulaCell* pFCell = new ScFormulaCell( pDoc, aPos, aNewStr );
+ pInsDoc->PutCell( nCol, nRow, nTab, pFCell );
+ }
+ else if ( pData )
+ pInsDoc->PutCell( nCol, nRow, nTab, new ScEditCell( pData, pDoc, NULL ) );
+ else
+ pInsDoc->SetString( nCol, nRow, nTab, aNewStr );
+
+ pInsDoc->SetClipArea( ScRange(aPos) );
+ // auf Block einfuegen, mit Undo etc.
+ if ( PasteFromClip( IDF_CONTENTS, pInsDoc, PASTE_NOFUNC, FALSE, FALSE,
+ FALSE, INS_NONE, IDF_ATTRIB ) )
+ {
+ const SfxUInt32Item* pItem = (SfxUInt32Item*) pInsDoc->GetAttr(
+ nCol, nRow, nTab, ATTR_VALUE_FORMAT );
+ if ( pItem )
+ { // Numberformat setzen wenn inkompatibel
+ // MarkData wurde bereits in PasteFromClip MarkToSimple'ed
+ ScRange aRange;
+ rMark.GetMarkArea( aRange );
+ ScPatternAttr* pPattern = new ScPatternAttr( pDoc->GetPool() );
+ pPattern->GetItemSet().Put( *pItem );
+ short nNewType = pDoc->GetFormatTable()->GetType( pItem->GetValue() );
+ pDoc->ApplyPatternIfNumberformatIncompatible( aRange, rMark,
+ *pPattern, nNewType );
+ delete pPattern;
+ }
+ }
+
+ delete pInsDoc;
+}
+
+
+//----------------------------------------------------------------------------
+// manueller Seitenumbruch
+
+void ScViewFunc::InsertPageBreak( BOOL bColumn, BOOL bRecord, const ScAddress* pPos,
+ BOOL bSetModified )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aCursor;
+ if (pPos)
+ aCursor = *pPos;
+ else
+ aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
+
+ BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
+ InsertPageBreak( bColumn, aCursor, bRecord, bSetModified, FALSE );
+
+ if ( bSuccess && bSetModified )
+ UpdatePageBreakData( TRUE ); // fuer PageBreak-Modus
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::DeletePageBreak( BOOL bColumn, BOOL bRecord, const ScAddress* pPos,
+ BOOL bSetModified )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aCursor;
+ if (pPos)
+ aCursor = *pPos;
+ else
+ aCursor = ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
+
+ BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
+ RemovePageBreak( bColumn, aCursor, bRecord, bSetModified, FALSE );
+
+ if ( bSuccess && bSetModified )
+ UpdatePageBreakData( TRUE ); // fuer PageBreak-Modus
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::RemoveManualBreaks()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ if (bUndo)
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, TRUE );
+ pDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, FALSE, pUndoDoc );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRemoveBreaks( pDocSh, nTab, pUndoDoc ) );
+ }
+
+ pDoc->RemoveManualBreaks(nTab);
+ pDoc->UpdatePageBreaks(nTab);
+
+ UpdatePageBreakData( TRUE );
+ pDocSh->SetDocumentModified();
+ pDocSh->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::SetPrintZoom(USHORT nScale, USHORT nPages)
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ pDocSh->SetPrintZoom( nTab, nScale, nPages );
+}
+
+void ScViewFunc::AdjustPrintZoom()
+{
+ ScRange aRange;
+ if ( GetViewData()->GetSimpleArea( aRange ) != SC_MARK_SIMPLE )
+ GetViewData()->GetMarkData().GetMultiMarkArea( aRange );
+ GetViewData()->GetDocShell()->AdjustPrintZoom( aRange );
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::SetPrintRanges( BOOL bEntireSheet, const String* pPrint,
+ const String* pRepCol, const String* pRepRow,
+ BOOL bAddPrint )
+{
+ // on all selected tables
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab;
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ ScPrintRangeSaver* pOldRanges = pDoc->CreatePrintRangeSaver();
+
+ ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
+
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (rMark.GetTableSelect(nTab))
+ {
+ ScRange aRange( 0,0,nTab );
+
+ // print ranges
+
+ if( !bAddPrint )
+ pDoc->ClearPrintRanges( nTab );
+
+ if( bEntireSheet )
+ {
+ pDoc->SetPrintEntireSheet( nTab );
+ }
+ else if ( pPrint )
+ {
+ if ( pPrint->Len() )
+ {
+ const sal_Unicode sep = ScCompiler::GetNativeSymbol(ocSep).GetChar(0);
+ USHORT nTCount = pPrint->GetTokenCount(sep);
+ for (USHORT i=0; i<nTCount; i++)
+ {
+ String aToken = pPrint->GetToken(i, sep);
+ if ( aRange.ParseAny( aToken, pDoc, aDetails ) & SCA_VALID )
+ pDoc->AddPrintRange( nTab, aRange );
+ }
+ }
+ }
+ else // NULL = use selection (print range is always set), use empty string to delete all ranges
+ {
+ if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ pDoc->AddPrintRange( nTab, aRange );
+ }
+ else if ( rMark.IsMultiMarked() )
+ {
+ rMark.MarkToMulti();
+ ScRangeListRef aList( new ScRangeList );
+ rMark.FillRangeListWithMarks( aList, FALSE );
+ USHORT nCnt = (USHORT) aList->Count();
+ if ( nCnt )
+ {
+ ScRangePtr pR;
+ USHORT i;
+ for ( pR = aList->First(), i=0; i < nCnt;
+ pR = aList->Next(), i++ )
+ {
+ pDoc->AddPrintRange( nTab, *pR );
+ }
+ }
+ }
+ }
+
+ // repeat columns
+
+ if ( pRepCol )
+ {
+ if ( !pRepCol->Len() )
+ pDoc->SetRepeatColRange( nTab, NULL );
+ else
+ if ( aRange.ParseAny( *pRepCol, pDoc, aDetails ) & SCA_VALID )
+ pDoc->SetRepeatColRange( nTab, &aRange );
+ }
+
+ // repeat rows
+
+ if ( pRepRow )
+ {
+ if ( !pRepRow->Len() )
+ pDoc->SetRepeatRowRange( nTab, NULL );
+ else
+ if ( aRange.ParseAny( *pRepRow, pDoc, aDetails ) & SCA_VALID )
+ pDoc->SetRepeatRowRange( nTab, &aRange );
+ }
+ }
+
+ // undo (for all tables)
+ if (bUndo)
+ {
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoPrintRange( pDocSh, nCurTab, pOldRanges, pNewRanges ) );
+ }
+
+ // update page breaks
+
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (rMark.GetTableSelect(nTab))
+ ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_DELETE_PRINTAREA );
+
+ pDocSh->SetDocumentModified();
+}
+
+//----------------------------------------------------------------------------
+// Zellen zusammenfassen
+
+BOOL ScViewFunc::TestMergeCells() // Vorab-Test (fuer Menue)
+{
+ // simple test: TRUE if there's a selection but no multi selection and not filtered
+
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ ScRange aDummy;
+ return GetViewData()->GetSimpleArea( aDummy) == SC_MARK_SIMPLE;
+ }
+ else
+ return FALSE;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::MergeCells( BOOL bApi, BOOL& rDoContents, BOOL bRecord, BOOL bCenter )
+{
+ // Editable- und Verschachtelungs-Abfrage muss vorneweg sein (auch in DocFunc),
+ // damit dann nicht die Inhalte-QueryBox kommt
+ ScEditableTester aTester( this );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ rMark.MarkToSimple();
+ if (!rMark.IsMarked())
+ {
+ ErrorMessage(STR_NOMULTISELECT);
+ return FALSE;
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ ScRange aMarkRange;
+ rMark.GetMarkArea( aMarkRange );
+ SCCOL nStartCol = aMarkRange.aStart.Col();
+ SCROW nStartRow = aMarkRange.aStart.Row();
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCCOL nEndCol = aMarkRange.aEnd.Col();
+ SCROW nEndRow = aMarkRange.aEnd.Row();
+ SCTAB nEndTab = aMarkRange.aEnd.Tab();
+ if ( nStartCol == nEndCol && nStartRow == nEndRow )
+ {
+ // nichts zu tun
+ return TRUE;
+ }
+
+ if ( pDoc->HasAttrib( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ) )
+ { // "Zusammenfassen nicht verschachteln !"
+ ErrorMessage(STR_MSSG_MERGECELLS_0);
+ return FALSE;
+ }
+
+ // Check for the contents of all selected tables.
+ bool bAskDialog = false;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScCellMergeOption aMergeOption(nStartCol, nStartRow, nEndCol, nEndRow, bCenter);
+ for (SCTAB i = 0; i < nTabCount; ++i)
+ {
+ if (!rMark.GetTableSelect(i))
+ // this table is not selected.
+ continue;
+
+ aMergeOption.maTabs.insert(i);
+
+ if (!pDoc->IsBlockEmpty(i, nStartCol, nStartRow+1, nStartCol, nEndRow) ||
+ !pDoc->IsBlockEmpty(i, nStartCol+1, nStartRow, nEndCol, nEndRow))
+ bAskDialog = true;
+ }
+
+ BOOL bOk = TRUE;
+
+ if (bAskDialog)
+ {
+ if (!bApi)
+ {
+ MessBox aBox( GetViewData()->GetDialogParent(),
+ WinBits(WB_YES_NO_CANCEL | WB_DEF_NO),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ),
+ ScGlobal::GetRscString( STR_MERGE_NOTEMPTY ) );
+ USHORT nRetVal = aBox.Execute();
+
+ if ( nRetVal == RET_YES )
+ rDoContents = TRUE;
+ else if ( nRetVal == RET_CANCEL )
+ bOk = FALSE;
+ }
+ }
+
+ if (bOk)
+ {
+ HideCursor();
+ bOk = pDocSh->GetDocFunc().MergeCells( aMergeOption, rDoContents, bRecord, bApi );
+ ShowCursor();
+
+ if (bOk)
+ {
+ SetCursor( nStartCol, nStartRow );
+ //DoneBlockMode( FALSE);
+ Unmark();
+
+ pDocSh->UpdateOle(GetViewData());
+ UpdateInputLine();
+ }
+ }
+
+ return bOk;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::TestRemoveMerge()
+{
+ BOOL bMerged = FALSE;
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( pDoc->HasAttrib( aRange, HASATTR_MERGED ) )
+ bMerged = TRUE;
+ }
+ return bMerged;
+}
+
+
+//----------------------------------------------------------------------------
+
+static bool lcl_extendMergeRange(ScCellMergeOption& rOption, const ScRange& rRange)
+{
+ bool bExtended = false;
+ if (rOption.mnStartCol > rRange.aStart.Col())
+ {
+ rOption.mnStartCol = rRange.aStart.Col();
+ bExtended = true;
+ }
+ if (rOption.mnStartRow > rRange.aStart.Row())
+ {
+ rOption.mnStartRow = rRange.aStart.Row();
+ bExtended = true;
+ }
+ if (rOption.mnEndCol < rRange.aEnd.Col())
+ {
+ rOption.mnEndCol = rRange.aEnd.Col();
+ bExtended = true;
+ }
+ if (rOption.mnEndRow < rRange.aEnd.Row())
+ {
+ rOption.mnEndRow = rRange.aEnd.Row();
+ bExtended = true;
+ }
+ return bExtended;
+}
+
+BOOL ScViewFunc::RemoveMerge( BOOL bRecord )
+{
+ ScRange aRange;
+ ScEditableTester aTester( this );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+ else if (GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE)
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScRange aExtended( aRange );
+ pDoc->ExtendMerge( aExtended );
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ ScCellMergeOption aOption(aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row());
+ bool bExtended = false;
+ do
+ {
+ bExtended = false;
+ for (SCTAB i = 0; i < nTabCount; ++i)
+ {
+ if (!rMark.GetTableSelect(i))
+ // This table is not selected.
+ continue;
+
+ aOption.maTabs.insert(i);
+ aExtended.aStart.SetTab(i);
+ aExtended.aEnd.SetTab(i);
+ pDoc->ExtendMerge(aExtended);
+ pDoc->ExtendOverlapped(aExtended);
+
+ // Expand the current range to be inclusive of all merged
+ // areas on all sheets.
+ bExtended = lcl_extendMergeRange(aOption, aExtended);
+ }
+ }
+ while (bExtended);
+
+ HideCursor();
+ BOOL bOk = pDocSh->GetDocFunc().UnmergeCells(aOption, bRecord, FALSE );
+ aExtended = aOption.getFirstSingleRange();
+ MarkRange( aExtended );
+ ShowCursor();
+
+ if (bOk)
+ pDocSh->UpdateOle(GetViewData());
+ }
+ return TRUE; //! bOk ??
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::FillSimple( FillDir eDir, BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ BOOL bSuccess = pDocSh->GetDocFunc().FillSimple( aRange, &rMark, eDir, bRecord, FALSE );
+ if (bSuccess)
+ {
+ pDocSh->UpdateOle(GetViewData());
+ UpdateScrollBars();
+ }
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::FillSeries( FillDir eDir, FillCmd eCmd, FillDateCmd eDateCmd,
+ double fStart, double fStep, double fMax, BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ BOOL bSuccess = pDocSh->GetDocFunc().
+ FillSeries( aRange, &rMark, eDir, eCmd, eDateCmd,
+ fStart, fStep, fMax, bRecord, FALSE );
+ if (bSuccess)
+ {
+ pDocSh->UpdateOle(GetViewData());
+ UpdateScrollBars();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ aChangeRanges.Append( aRange );
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+ }
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::FillAuto( FillDir eDir, SCCOL nStartCol, SCROW nStartRow,
+ SCCOL nEndCol, SCROW nEndRow, ULONG nCount, BOOL bRecord )
+{
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScRange aRange( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab );
+ ScRange aSourceRange( aRange );
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ BOOL bSuccess = pDocSh->GetDocFunc().
+ FillAuto( aRange, &rMark, eDir, nCount, bRecord, FALSE );
+ if (bSuccess)
+ {
+ MarkRange( aRange, FALSE ); // aRange ist in FillAuto veraendert worden
+ pDocSh->UpdateOle(GetViewData());
+ UpdateScrollBars();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ ScRange aChangeRange( aRange );
+ switch ( eDir )
+ {
+ case FILL_TO_BOTTOM:
+ {
+ aChangeRange.aStart.SetRow( aSourceRange.aEnd.Row() + 1 );
+ }
+ break;
+ case FILL_TO_TOP:
+ {
+ aChangeRange.aEnd.SetRow( aSourceRange.aStart.Row() - 1 );
+ }
+ break;
+ case FILL_TO_RIGHT:
+ {
+ aChangeRange.aStart.SetCol( aSourceRange.aEnd.Col() + 1 );
+ }
+ break;
+ case FILL_TO_LEFT:
+ {
+ aChangeRange.aEnd.SetCol( aSourceRange.aStart.Col() - 1 );
+ }
+ break;
+ default:
+ {
+
+ }
+ break;
+ }
+ aChangeRanges.Append( aChangeRange );
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::FillTab( USHORT nFlags, USHORT nFunction, BOOL bSkipEmpty, BOOL bAsLink )
+{
+ //! allow source sheet to be protected
+ ScEditableTester aTester( this );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ ScRange aMarkRange;
+ rMark.MarkToSimple();
+ BOOL bMulti = rMark.IsMultiMarked();
+ if (bMulti)
+ rMark.GetMultiMarkArea( aMarkRange );
+ else if (rMark.IsMarked())
+ rMark.GetMarkArea( aMarkRange );
+ else
+ aMarkRange = ScRange( GetViewData()->GetCurX(), GetViewData()->GetCurY(), nTab );
+
+ ScDocument* pUndoDoc = NULL;
+// if ( bRecord )
+ if (bUndo)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+// pUndoDoc->SelectTable( nTab, TRUE ); // nur fuer Markierung
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nTab && rMark.GetTableSelect(i))
+ {
+ pUndoDoc->AddUndoTab( i, i );
+ aMarkRange.aStart.SetTab( i );
+ aMarkRange.aEnd.SetTab( i );
+ pDoc->CopyToDocument( aMarkRange, IDF_ALL, bMulti, pUndoDoc );
+// pUndoDoc->SelectTable( i, TRUE );
+ }
+ }
+
+ if (bMulti)
+ pDoc->FillTabMarked( nTab, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
+ else
+ {
+ aMarkRange.aStart.SetTab( nTab );
+ aMarkRange.aEnd.SetTab( nTab );
+ pDoc->FillTab( aMarkRange, rMark, nFlags, nFunction, bSkipEmpty, bAsLink );
+ }
+
+// if ( bRecord )
+ if (bUndo)
+ { //! fuer ChangeTrack erst zum Schluss
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoFillTable( pDocSh, rMark,
+ aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), nTab,
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), nTab,
+ pUndoDoc, bMulti, nTab, nFlags, nFunction, bSkipEmpty, bAsLink ) );
+ }
+
+ pDocSh->PostPaintGridAll();
+ pDocSh->PostDataChanged();
+}
+
+//----------------------------------------------------------------------------
+
+/** Downward fill of selected cell(s) by double-clicking cross-hair cursor
+
+ Extends a current selection down to the last non-empty cell of an adjacent
+ column when the lower-right corner of the selection is double-clicked. It
+ uses a left-adjoining non-empty column as a guide if such is available,
+ otherwise a right-adjoining non-empty column is used.
+
+ @author Kohei Yoshida (kohei@openoffice.org)
+
+ @return No return value
+
+ @see #i12313#
+*/
+void ScViewFunc::FillCrossDblClick()
+{
+ ScRange aRange;
+ GetViewData()->GetSimpleArea( aRange );
+ aRange.Justify();
+
+ SCTAB nTab = GetViewData()->GetCurPos().Tab();
+ SCCOL nStartX = aRange.aStart.Col();
+ SCROW nStartY = aRange.aStart.Row();
+ SCCOL nEndX = aRange.aEnd.Col();
+ SCROW nEndY = aRange.aEnd.Row();
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ // Make sure the selection is not empty
+ if ( pDoc->IsBlockEmpty( nTab, nStartX, nStartY, nEndX, nEndY ) )
+ return;
+
+ if ( nEndY < MAXROW )
+ {
+ if ( nStartX > 0 )
+ {
+ SCCOL nMovX = nStartX - 1;
+ SCROW nMovY = nStartY;
+
+ if ( pDoc->HasData( nMovX, nStartY, nTab ) &&
+ pDoc->HasData( nMovX, nStartY + 1, nTab ) )
+ {
+ pDoc->FindAreaPos( nMovX, nMovY, nTab, 0, 1 );
+
+ if ( nMovY > nEndY )
+ {
+ FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY,
+ nMovY - nEndY );
+ return;
+ }
+ }
+ }
+
+ if ( nEndX < MAXCOL )
+ {
+ SCCOL nMovX = nEndX + 1;
+ SCROW nMovY = nStartY;
+
+ if ( pDoc->HasData( nMovX, nStartY, nTab ) &&
+ pDoc->HasData( nMovX, nStartY + 1, nTab ) )
+ {
+ pDoc->FindAreaPos( nMovX, nMovY, nTab, 0, 1 );
+
+ if ( nMovY > nEndY )
+ {
+ FillAuto( FILL_TO_BOTTOM, nStartX, nStartY, nEndX, nEndY,
+ nMovY - nEndY );
+ return;
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::TransliterateText( sal_Int32 nType )
+{
+ ScMarkData aFuncMark = GetViewData()->GetMarkData();
+ if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
+ {
+ // no selection -> use cursor position
+
+ ScAddress aCursor( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ aFuncMark.SetMarkArea( ScRange( aCursor ) );
+ }
+
+ BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
+ TransliterateText( aFuncMark, nType, TRUE, FALSE );
+ if (bSuccess)
+ {
+ GetViewData()->GetViewShell()->UpdateInputHandler();
+ }
+}
+
+//----------------------------------------------------------------------------
+// AutoFormat
+
+ScAutoFormatData* ScViewFunc::CreateAutoFormatData()
+{
+ ScAutoFormatData* pData = NULL;
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ {
+ if ( nEndCol-nStartCol >= 3 && nEndRow-nStartRow >= 3 )
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ pData = new ScAutoFormatData;
+ pDoc->GetAutoFormatData( nStartTab, nStartCol,nStartRow,nEndCol,nEndRow, *pData );
+ }
+ }
+ return pData;
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::AutoFormat( USHORT nFormatNo, BOOL bRecord )
+{
+#if 1
+
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+
+ BOOL bSuccess = pDocSh->GetDocFunc().AutoFormat( aRange, &rMark, nFormatNo, bRecord, FALSE );
+ if (bSuccess)
+ pDocSh->UpdateOle(GetViewData());
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+
+#else
+
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nStartTab,nEndCol,nEndRow,nEndTab) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ BOOL bSize = (*ScGlobal::GetAutoFormat())[nFormatNo]->GetIncludeWidthHeight();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab, bSize, bSize );
+ pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
+ IDF_ATTRIB, FALSE, pUndoDoc );
+ if (bSize)
+ {
+ pDoc->CopyToDocument( nStartCol,0,nStartTab, nEndCol,MAXROW,nEndTab,
+ IDF_NONE, FALSE, pUndoDoc );
+ pDoc->CopyToDocument( 0,nStartRow,nStartTab, MAXCOL,nEndRow,nEndTab,
+ IDF_NONE, FALSE, pUndoDoc );
+ }
+ pDoc->BeginDrawUndo();
+ }
+
+ GetFrameWin()->EnterWait();
+ pDoc->AutoFormat( nStartCol, nStartRow, nEndCol, nEndRow, nFormatNo, rMark );
+ GetFrameWin()->LeaveWait();
+
+ if (bSize)
+ {
+ SetMarkedWidthOrHeight( TRUE, SC_SIZE_VISOPT, STD_EXTRA_WIDTH, FALSE, FALSE );
+ SetMarkedWidthOrHeight( FALSE, SC_SIZE_VISOPT, 0, FALSE, FALSE );
+ pDocSh->PostPaint( 0,0,nStartTab, MAXCOL,MAXROW,nStartTab,
+ PAINT_GRID | PAINT_LEFT | PAINT_TOP );
+ }
+ else
+ {
+ BOOL bAdj = AdjustBlockHeight( FALSE );
+ if (bAdj)
+ pDocSh->PostPaint( 0,nStartRow,nStartTab, MAXCOL,MAXROW,nStartTab,
+ PAINT_GRID | PAINT_LEFT );
+ else
+ pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab, PAINT_GRID );
+ }
+
+ if ( bRecord ) // Draw-Undo erst jetzt verfuegbar
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoAutoFormat( pDocSh,
+ ScRange(nStartCol,nStartRow,nStartTab, nEndCol,nEndRow,nEndTab),
+ pUndoDoc, rMark, bSize, nFormatNo ) );
+ }
+
+ pDocSh->UpdateOle(GetViewData());
+ pDocSh->SetDocumentModified();
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+
+#endif
+}
+
+
+//----------------------------------------------------------------------------
+// Suchen & Ersetzen
+
+void ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
+ BOOL bAddUndo, BOOL bIsApi )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if (bAddUndo && !pDoc->IsUndoEnabled())
+ bAddUndo = FALSE;
+
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+// BOOL bAttrib = pSearchItem->GetPattern();
+ USHORT nCommand = pSearchItem->GetCommand();
+ BOOL bAllTables = pSearchItem->IsAllTables();
+ BOOL* pOldSelectedTables = NULL;
+ USHORT nOldSelectedCount = 0;
+ SCTAB nOldTab = nTab;
+ SCTAB nLastTab = pDoc->GetTableCount() - 1;
+ SCTAB nStartTab, nEndTab;
+ if ( bAllTables )
+ {
+ nStartTab = 0;
+ nEndTab = nLastTab;
+ pOldSelectedTables = new BOOL [ nEndTab + 1 ];
+ for ( SCTAB j = 0; j <= nEndTab; j++ )
+ {
+ pOldSelectedTables[j] = rMark.GetTableSelect( j );
+ if ( pOldSelectedTables[j] )
+ ++nOldSelectedCount;
+ }
+ }
+ else
+ { //! mindestens eine ist immer selektiert
+ nStartTab = nEndTab = rMark.GetFirstSelected();
+ for ( SCTAB j = nStartTab + 1; j <= nLastTab; j++ )
+ {
+ if ( rMark.GetTableSelect( j ) )
+ nEndTab = j;
+ }
+ }
+
+ if ( nCommand == SVX_SEARCHCMD_REPLACE
+ || nCommand == SVX_SEARCHCMD_REPLACE_ALL )
+ {
+ for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
+ {
+ if ( (bAllTables || rMark.GetTableSelect( j )) &&
+ pDoc->IsTabProtected( j ) )
+ {
+ if ( pOldSelectedTables )
+ delete [] pOldSelectedTables;
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+ }
+ }
+
+ if ( nCommand == SVX_SEARCHCMD_FIND
+ || nCommand == SVX_SEARCHCMD_FIND_ALL)
+ bAddUndo = FALSE;
+
+ //! bAttrib bei Undo beruecksichtigen !!!
+
+ ScDocument* pUndoDoc = NULL;
+ ScMarkData* pUndoMark = NULL;
+ String aUndoStr;
+ if (bAddUndo)
+ {
+ pUndoMark = new ScMarkData( rMark ); // Markierung wird veraendert
+ if ( nCommand == SVX_SEARCHCMD_REPLACE_ALL )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nEndTab );
+ }
+ }
+
+ if ( bAllTables )
+ { //! alles selektieren, erst nachdem pUndoMark erzeugt wurde
+ for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
+ {
+ rMark.SelectTable( j, TRUE );
+ }
+ }
+
+ DoneBlockMode(TRUE); // Markierung nicht loeschen!
+ InitOwnBlockMode();
+
+ // wenn vom Anfang an gesucht wird, nicht nochmal fragen ob vom Anfang gesucht werden soll
+ BOOL bFirst = TRUE;
+ if ( nCol == 0 && nRow == 0 && nTab == nStartTab && !pSearchItem->GetBackward() )
+ bFirst = FALSE;
+
+ BOOL bFound = FALSE;
+ while (TRUE)
+ {
+ GetFrameWin()->EnterWait();
+ if (pDoc->SearchAndReplace( *pSearchItem, nCol, nRow, nTab, rMark, aUndoStr, pUndoDoc ) )
+ {
+ bFound = TRUE;
+ bFirst = TRUE;
+ if (bAddUndo)
+ {
+ GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction(
+ new ScUndoReplace( GetViewData()->GetDocShell(), *pUndoMark,
+ nCol, nRow, nTab,
+ aUndoStr, pUndoDoc, pSearchItem ) );
+ pUndoDoc = NULL;
+ }
+
+ break; // Abbruch while True
+ }
+ else if ( bFirst && (nCommand == SVX_SEARCHCMD_FIND ||
+ nCommand == SVX_SEARCHCMD_REPLACE) )
+ {
+ bFirst = FALSE;
+ USHORT nRetVal;
+ GetFrameWin()->LeaveWait();
+ if ( bIsApi )
+ nRetVal = RET_NO;
+ else
+ {
+ // Suchen-Dialog als Parent, wenn vorhanden
+ Window* pParent = GetParentOrChild(SID_SEARCH_DLG);
+ USHORT nStrId;
+ if ( pSearchItem->GetBackward() )
+ {
+ if ( nStartTab == nEndTab )
+ nStrId = STR_MSSG_SEARCHANDREPLACE_1;
+ else
+ nStrId = STR_MSSG_SEARCHANDREPLACE_4;
+ }
+ else
+ {
+ if ( nStartTab == nEndTab )
+ nStrId = STR_MSSG_SEARCHANDREPLACE_2;
+ else
+ nStrId = STR_MSSG_SEARCHANDREPLACE_5;
+ }
+ MessBox aBox( pParent, WinBits(WB_YES_NO | WB_DEF_YES),
+ ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_3 ),
+ ScGlobal::GetRscString( nStrId ) );
+ nRetVal = aBox.Execute();
+ }
+
+ if ( nRetVal == RET_YES )
+ {
+ ScDocument::GetSearchAndReplaceStart( *pSearchItem, nCol, nRow );
+ if (pSearchItem->GetBackward())
+ nTab = nEndTab;
+ else
+ nTab = nStartTab;
+ }
+ else
+ {
+ break; // Abbruch while True
+ }
+ }
+ else // nichts gefunden
+ {
+ if ( nCommand == SVX_SEARCHCMD_FIND_ALL || nCommand == SVX_SEARCHCMD_REPLACE_ALL )
+ {
+ pDocSh->PostPaintGridAll(); // Markierung
+ }
+
+ GetFrameWin()->LeaveWait();
+ if (!bIsApi)
+ {
+ // Suchen-Dialog als Parent, wenn vorhanden
+ Window* pParent = GetParentOrChild(SID_SEARCH_DLG);
+ // "nichts gefunden"
+ InfoBox aBox( pParent, ScGlobal::GetRscString( STR_MSSG_SEARCHANDREPLACE_0 ) );
+ aBox.Execute();
+ }
+
+ break; // Abbruch while True
+ }
+ } // of while TRUE
+
+ if ( pOldSelectedTables )
+ { // urspruenglich selektierte Tabellen wiederherstellen
+ for ( SCTAB j = nStartTab; j <= nEndTab; j++ )
+ {
+ rMark.SelectTable( j, pOldSelectedTables[j] );
+ }
+ if ( bFound )
+ { // durch Fundstelle neu selektierte Tabelle bleibt
+ rMark.SelectTable( nTab, TRUE );
+ // wenn vorher nur eine selektiert war, ist es ein Tausch
+ //! wenn nicht, ist jetzt evtl. eine mehr selektiert
+ if ( nOldSelectedCount == 1 && nTab != nOldTab )
+ rMark.SelectTable( nOldTab, FALSE );
+ }
+ delete [] pOldSelectedTables;
+ }
+
+ MarkDataChanged();
+
+ if ( bFound )
+ {
+ if ( nTab != GetViewData()->GetTabNo() )
+ SetTabNo( nTab );
+
+ // wenn nichts markiert ist, DoneBlockMode, damit von hier aus
+ // direkt per Shift-Cursor markiert werden kann:
+ if (!rMark.IsMarked() && !rMark.IsMultiMarked())
+ DoneBlockMode(TRUE);
+
+ AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP );
+ SetCursor( nCol, nRow, TRUE );
+
+ if ( nCommand == SVX_SEARCHCMD_REPLACE
+ || nCommand == SVX_SEARCHCMD_REPLACE_ALL )
+ {
+ if ( nCommand == SVX_SEARCHCMD_REPLACE )
+ pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID );
+ else
+ pDocSh->PostPaintGridAll();
+ pDocSh->SetDocumentModified();
+ }
+ else if ( nCommand == SVX_SEARCHCMD_FIND_ALL )
+ pDocSh->PostPaintGridAll(); // Markierung
+ GetFrameWin()->LeaveWait();
+ }
+
+ delete pUndoDoc; // loeschen wenn nicht benutzt
+ delete pUndoMark; // kann immer geloescht werden
+}
+
+
+//----------------------------------------------------------------------------
+// Zielwertsuche
+
+void ScViewFunc::Solve( const ScSolveParam& rParam )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+
+ SCCOL nDestCol = rParam.aRefVariableCell.Col();
+ SCROW nDestRow = rParam.aRefVariableCell.Row();
+ SCTAB nDestTab = rParam.aRefVariableCell.Tab();
+
+ ScEditableTester aTester( pDoc, nDestTab, nDestCol,nDestRow, nDestCol,nDestRow );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ if ( pDoc )
+ {
+ String aTargetValStr;
+ if ( rParam.pStrTargetVal != NULL )
+ aTargetValStr = *(rParam.pStrTargetVal);
+
+ String aMsgStr;
+ String aResStr;
+ double nSolveResult;
+
+ GetFrameWin()->EnterWait();
+
+ BOOL bExact =
+ pDoc->Solver(
+ rParam.aRefFormulaCell.Col(),
+ rParam.aRefFormulaCell.Row(),
+ rParam.aRefFormulaCell.Tab(),
+ nDestCol, nDestRow, nDestTab,
+ aTargetValStr,
+ nSolveResult );
+
+ GetFrameWin()->LeaveWait();
+
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ ULONG nFormat = 0;
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nDestCol, nDestRow, nDestTab );
+ if ( pPattern )
+ nFormat = pPattern->GetNumberFormat( pFormatter );
+ Color* p;
+ pFormatter->GetOutputString( nSolveResult, nFormat, aResStr, &p );
+
+ if ( bExact )
+ {
+ aMsgStr = ScGlobal::GetRscString( STR_MSSG_SOLVE_0 );
+ aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_1 );
+ aMsgStr += String( aResStr );
+ aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_2 );
+ }
+ else
+ {
+ aMsgStr = ScGlobal::GetRscString( STR_MSSG_SOLVE_3 );
+ aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_4 );
+ aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_5 );
+ aMsgStr += String( aResStr );
+ aMsgStr += ScGlobal::GetRscString( STR_MSSG_SOLVE_6 );
+ }
+
+ MessBox aBox( GetViewData()->GetDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_NO),
+ ScGlobal::GetRscString( STR_MSSG_DOSUBTOTALS_0 ), aMsgStr );
+ USHORT nRetVal = aBox.Execute();
+
+ if ( RET_YES == nRetVal )
+ EnterValue( nDestCol, nDestRow, nDestTab, nSolveResult );
+
+ GetViewData()->GetViewShell()->UpdateInputHandler( TRUE );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Mehrfachoperation
+
+void ScViewFunc::TabOp( const ScTabOpParam& rParam, BOOL bRecord )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ pDocSh->GetDocFunc().TabOp( aRange, &rMark, rParam, bRecord, FALSE );
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::MakeScenario( const String& rName, const String& rComment,
+ const Color& rColor, USHORT nFlags )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ SCTAB nNewTab = pDocSh->MakeScenario( nTab, rName, rComment, rColor, nFlags, rMark );
+ if (nFlags & SC_SCENARIO_COPYALL)
+ SetTabNo( nNewTab, TRUE ); // SC_SCENARIO_COPYALL -> sichtbar
+ else
+ {
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_STATUS_DOCPOS ); // Statusbar
+ rBindings.Invalidate( SID_TABLES_COUNT );
+ rBindings.Invalidate( SID_SELECT_SCENARIO );
+ rBindings.Invalidate( FID_TABLE_SHOW );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::ExtendScenario()
+{
+ ScEditableTester aTester( this );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ // Undo: Attribute anwenden
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( ScMergeFlagAttr( SC_MF_SCENARIO ) );
+ aPattern.GetItemSet().Put( ScProtectionAttr( TRUE ) );
+ ApplySelectionPattern(aPattern);
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::UseScenario( const String& rName )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ DoneBlockMode();
+ InitOwnBlockMode();
+ pDocSh->UseScenario( nTab, rName );
+}
+
+
+//----------------------------------------------------------------------------
+// Tabelle einfuegen
+
+BOOL ScViewFunc::InsertTable( const String& rName, SCTAB nTab, BOOL bRecord )
+{
+ // Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt
+ BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
+ InsertTable( nTab, rName, bRecord, FALSE );
+ if (bSuccess)
+ SetTabNo( nTab, TRUE );
+
+ return bSuccess;
+}
+
+//----------------------------------------------------------------------------
+// Tabellen einfuegen
+
+BOOL ScViewFunc::InsertTables(SvStrings *pNames, SCTAB nTab,
+ SCTAB nCount, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ SvStrings *pNameList= NULL;
+
+ WaitObject aWait( GetFrameWin() );
+
+ if (bRecord)
+ {
+ pNameList= new SvStrings;
+ pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
+ }
+
+ BOOL bFlag=FALSE;
+
+ String aValTabName;
+ String *pStr;
+
+ for(SCTAB i=0;i<nCount;i++)
+ {
+ if(pNames!=NULL)
+ {
+ pStr=pNames->GetObject(static_cast<USHORT>(i));
+ }
+ else
+ {
+ aValTabName.Erase();
+ pDoc->CreateValidTabName( aValTabName);
+ pStr=&aValTabName;
+ }
+
+ if(pDoc->InsertTab( nTab+i,*pStr))
+ {
+ bFlag=TRUE;
+ pDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nTab+i ) );
+ }
+ else
+ {
+ break;
+ }
+
+ if(pNameList!=NULL)
+ pNameList->Insert(new String(*pStr),pNameList->Count());
+
+ }
+
+ if (bFlag)
+ {
+ if (bRecord)
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTables( pDocSh, nTab, FALSE, pNameList));
+
+ // Views updaten:
+
+ SetTabNo( nTab, TRUE );
+ pDocSh->PostPaintExtras();
+ pDocSh->SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::AppendTable( const String& rName, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ WaitObject aWait( GetFrameWin() );
+
+ if (bRecord)
+ pDoc->BeginDrawUndo(); // InsertTab erzeugt ein SdrUndoNewPage
+
+ if (pDoc->InsertTab( SC_TAB_APPEND, rName ))
+ {
+ SCTAB nTab = pDoc->GetTableCount()-1;
+ if (bRecord)
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( pDocSh, nTab, TRUE, rName));
+ GetViewData()->InsertTab( nTab );
+ SetTabNo( nTab, TRUE );
+ pDocSh->PostPaintExtras();
+ pDocSh->SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::DeleteTable( SCTAB nTab, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ BOOL bSuccess = pDocSh->GetDocFunc().DeleteTable( nTab, bRecord, FALSE );
+ if (bSuccess)
+ {
+ SCTAB nNewTab = nTab;
+ if ( nNewTab >= pDoc->GetTableCount() )
+ --nNewTab;
+ SetTabNo( nNewTab, TRUE );
+ }
+ return bSuccess;
+}
+
+BOOL ScViewFunc::DeleteTables(const SvShorts &TheTabs, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bVbaEnabled = pDoc ? pDoc->IsInVBAMode() : FALSE;
+ SCTAB nNewTab = TheTabs[0];
+ int i;
+ WaitObject aWait( GetFrameWin() );
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ if ( bVbaEnabled )
+ bRecord = FALSE;
+
+ while ( nNewTab > 0 && !pDoc->IsVisible( nNewTab ) )
+ --nNewTab;
+
+ BOOL bWasLinked = FALSE;
+ ScDocument* pUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+// pUndoDoc->InitDrawLayer( pDocSh );
+ SCTAB nCount = pDoc->GetTableCount();
+
+// pUndoDoc->InitUndo( pDoc, 0, nCount-1 ); // incl. Ref.
+
+ String aOldName;
+ for(i=0;i<TheTabs.Count();i++)
+ {
+ SCTAB nTab = TheTabs[sal::static_int_cast<USHORT>(i)];
+ if (i==0)
+ pUndoDoc->InitUndo( pDoc, nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags
+ else
+ pUndoDoc->AddUndoTab( nTab,nTab, TRUE,TRUE ); // incl. Spalten/Zeilenflags
+
+ pDoc->CopyToDocument(0,0,nTab, MAXCOL,MAXROW,nTab, IDF_ALL,FALSE, pUndoDoc );
+ pDoc->GetName( nTab, aOldName );
+ pUndoDoc->RenameTab( nTab, aOldName, FALSE );
+ if (pDoc->IsLinked(nTab))
+ {
+ bWasLinked = TRUE;
+ pUndoDoc->SetLink( nTab, pDoc->GetLinkMode(nTab), pDoc->GetLinkDoc(nTab),
+ pDoc->GetLinkFlt(nTab), pDoc->GetLinkOpt(nTab),
+ pDoc->GetLinkTab(nTab),
+ pDoc->GetLinkRefreshDelay(nTab) );
+ }
+ if ( pDoc->IsScenario(nTab) )
+ {
+ pUndoDoc->SetScenario( nTab, TRUE );
+ String aComment;
+ Color aColor;
+ USHORT nScenFlags;
+ pDoc->GetScenarioData( nTab, aComment, aColor, nScenFlags );
+ pUndoDoc->SetScenarioData( nTab, aComment, aColor, nScenFlags );
+ BOOL bActive = pDoc->IsActiveScenario( nTab );
+ pUndoDoc->SetActiveScenario( nTab, bActive );
+ }
+ pUndoDoc->SetVisible( nTab, pDoc->IsVisible( nTab ) );
+ pUndoDoc->SetTabBgColor( nTab, pDoc->GetTabBgColor(nTab) );
+ pUndoDoc->SetSheetEvents( nTab, pDoc->GetSheetEvents( nTab ) );
+
+ if ( pDoc->IsTabProtected( nTab ) )
+ pUndoDoc->SetTabProtection(nTab, pDoc->GetTabProtection(nTab));
+
+ // Drawing-Layer muss sein Undo selbst in der Hand behalten !!!
+ // pUndoDoc->TransferDrawPage(pDoc, nTab,nTab);
+ }
+
+ pUndoDoc->AddUndoTab( 0, nCount-1 ); // alle Tabs fuer Referenzen
+
+ pDoc->BeginDrawUndo(); // DeleteTab erzeugt ein SdrUndoDelPage
+
+ pUndoData = new ScRefUndoData( pDoc );
+ }
+
+ BOOL bDelDone = FALSE;
+
+ for(i=TheTabs.Count()-1;i>=0;i--)
+ {
+ String sCodeName;
+ BOOL bHasCodeName = pDoc->GetCodeName( TheTabs[sal::static_int_cast<USHORT>(i)], sCodeName );
+ if (pDoc->DeleteTab( TheTabs[sal::static_int_cast<USHORT>(i)], pUndoDoc ))
+ {
+ bDelDone = TRUE;
+ if( bVbaEnabled )
+ {
+ if( bHasCodeName )
+ {
+ VBA_DeleteModule( *pDocSh, sCodeName );
+ }
+ }
+ pDocSh->Broadcast( ScTablesHint( SC_TAB_DELETED, TheTabs[sal::static_int_cast<USHORT>(i)] ) );
+ }
+ }
+ if (bRecord)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoDeleteTab( GetViewData()->GetDocShell(), TheTabs,
+ pUndoDoc, pUndoData ));
+ }
+
+
+ if (bDelDone)
+ {
+ if ( nNewTab >= pDoc->GetTableCount() )
+ nNewTab = pDoc->GetTableCount() - 1;
+
+ SetTabNo( nNewTab, TRUE );
+
+ if (bWasLinked)
+ {
+ pDocSh->UpdateLinks(); // Link-Manager updaten
+ GetViewData()->GetBindings().Invalidate(SID_LINKS);
+ }
+
+ pDocSh->PostPaintExtras();
+ pDocSh->SetDocumentModified();
+
+
+ SfxApplication* pSfxApp = SFX_APP(); // Navigator
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+ }
+ else
+ {
+ delete pUndoDoc;
+ delete pUndoData;
+ }
+ return bDelDone;
+}
+
+
+//----------------------------------------------------------------------------
+
+BOOL ScViewFunc::RenameTable( const String& rName, SCTAB nTab )
+{
+ // Reihenfolge Tabelle/Name ist bei DocFunc umgekehrt
+ BOOL bSuccess = GetViewData()->GetDocShell()->GetDocFunc().
+ RenameTable( nTab, rName, TRUE, FALSE );
+ if (bSuccess)
+ {
+ // Der Tabellenname koennte in einer Formel vorkommen...
+ GetViewData()->GetViewShell()->UpdateInputHandler();
+ }
+ return bSuccess;
+}
+
+
+//----------------------------------------------------------------------------
+
+bool ScViewFunc::SetTabBgColor( const Color& rColor, SCTAB nTab )
+{
+ bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( nTab, rColor, TRUE, FALSE );
+ if (bSuccess)
+ {
+ GetViewData()->GetViewShell()->UpdateInputHandler();
+ }
+ return bSuccess;
+}
+
+bool ScViewFunc::SetTabBgColor( ScUndoTabColorInfo::List& rUndoSetTabBgColorInfoList )
+{
+ bool bSuccess = GetViewData()->GetDocShell()->GetDocFunc().SetTabBgColor( rUndoSetTabBgColorInfoList, TRUE, FALSE );
+ if (bSuccess)
+ {
+ GetViewData()->GetViewShell()->UpdateInputHandler();
+ }
+ return bSuccess;
+}
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::InsertAreaLink( const String& rFile,
+ const String& rFilter, const String& rOptions,
+ const String& rSource, ULONG nRefresh )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCCOL nPosX = GetViewData()->GetCurX();
+ SCROW nPosY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aPos( nPosX, nPosY, nTab );
+
+ pDocSh->GetDocFunc().InsertAreaLink( rFile, rFilter, rOptions, rSource, aPos, nRefresh, FALSE, FALSE );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::InsertTableLink( const String& rFile,
+ const String& rFilter, const String& rOptions,
+ const String& rTabName )
+{
+ String aFilterName = rFilter;
+ String aOpt = rOptions;
+ ScDocumentLoader aLoader( rFile, aFilterName, aOpt );
+ if (!aLoader.IsError())
+ {
+ ScDocShell* pSrcSh = aLoader.GetDocShell();
+ ScDocument* pSrcDoc = pSrcSh->GetDocument();
+ SCTAB nTab = MAXTAB+1;
+ if (!rTabName.Len()) // kein Name angegeben -> erste Tabelle
+ nTab = 0;
+ else
+ {
+ String aTemp;
+ SCTAB nCount = pSrcDoc->GetTableCount();
+ for (SCTAB i=0; i<nCount; i++)
+ {
+ pSrcDoc->GetName( i, aTemp );
+ if ( aTemp == rTabName )
+ nTab = i;
+ }
+ }
+
+ if ( nTab <= MAXTAB )
+ ImportTables( pSrcSh, 1, &nTab, TRUE,
+ GetViewData()->GetTabNo() );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// Tabellen aus anderem Dokument kopieren / linken
+
+void ScViewFunc::ImportTables( ScDocShell* pSrcShell,
+ SCTAB nCount, const SCTAB* pSrcTabs, BOOL bLink,SCTAB nTab )
+{
+ ScDocument* pSrcDoc = pSrcShell->GetDocument();
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ //SCTAB nTab = GetViewData()->GetTabNo();
+
+ BOOL bError = FALSE;
+ BOOL bRefs = FALSE;
+ BOOL bName = FALSE;
+
+ if (pSrcDoc->GetDrawLayer())
+ pDocSh->MakeDrawLayer();
+
+ if (bUndo)
+ pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
+
+ SCTAB nInsCount = 0;
+ SCTAB i;
+ for( i=0; i<nCount; i++ )
+ { // #63304# insert sheets first and update all references
+ String aName;
+ pSrcDoc->GetName( pSrcTabs[i], aName );
+ pDoc->CreateValidTabName( aName );
+ if ( !pDoc->InsertTab( nTab+i, aName ) )
+ {
+ bError = TRUE; // total error
+ break; // for
+ }
+ ++nInsCount;
+ }
+ for (i=0; i<nCount && !bError; i++)
+ {
+ SCTAB nSrcTab = pSrcTabs[i];
+ SCTAB nDestTab1=nTab+i;
+ ULONG nErrVal = pDocSh->TransferTab( *pSrcShell, nSrcTab, nDestTab1,
+ FALSE, FALSE ); // no insert
+
+ switch (nErrVal)
+ {
+ case 0: // interner Fehler oder voll Fehler
+ bError = TRUE;
+ break;
+ case 2:
+ bRefs = TRUE;
+ break;
+ case 3:
+ bName = TRUE;
+ break;
+ case 4:
+ bRefs = bName = TRUE;
+ break;
+ }
+
+ }
+
+ if (bLink)
+ {
+ sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
+
+ SfxMedium* pMed = pSrcShell->GetMedium();
+ String aFileName = pMed->GetName();
+ String aFilterName;
+ if (pMed->GetFilter())
+ aFilterName = pMed->GetFilter()->GetFilterName();
+ String aOptions = ScDocumentLoader::GetOptions(*pMed);
+
+ BOOL bWasThere = pDoc->HasLink( aFileName, aFilterName, aOptions );
+
+ ULONG nRefresh = 0;
+ String aTabStr;
+ for (i=0; i<nInsCount; i++)
+ {
+ pSrcDoc->GetName( pSrcTabs[i], aTabStr );
+ pDoc->SetLink( nTab+i, SC_LINK_NORMAL,
+ aFileName, aFilterName, aOptions, aTabStr, nRefresh );
+ }
+
+ if (!bWasThere) // Link pro Quelldokument nur einmal eintragen
+ {
+ ScTableLink* pLink = new ScTableLink( pDocSh, aFileName, aFilterName, aOptions, nRefresh );
+ pLink->SetInCreate( TRUE );
+ pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, aFileName, &aFilterName );
+ pLink->Update();
+ pLink->SetInCreate( FALSE );
+
+ SfxBindings& rBindings = GetViewData()->GetBindings();
+ rBindings.Invalidate( SID_LINKS );
+ }
+ }
+
+
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoImportTab( pDocSh, nTab, nCount, bLink ) );
+ }
+
+ for (i=0; i<nInsCount; i++)
+ GetViewData()->InsertTab(nTab);
+ SetTabNo(nTab,TRUE);
+ pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
+ PAINT_GRID | PAINT_TOP | PAINT_LEFT | PAINT_EXTRAS );
+
+ SfxApplication* pSfxApp = SFX_APP();
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pSfxApp->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+
+ pDocSh->PostPaintExtras();
+ pDocSh->PostPaintGridAll();
+ pDocSh->SetDocumentModified();
+
+ if (bRefs)
+ ErrorMessage(STR_ABSREFLOST);
+ if (bName)
+ ErrorMessage(STR_NAMECONFLICT);
+}
+
+
+//----------------------------------------------------------------------------
+// Tabelle in anderes Dokument verschieben / kopieren
+
+void ScViewFunc::MoveTable( USHORT nDestDocNo, SCTAB nDestTab, BOOL bCopy )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocShell = GetViewData()->GetDocShell();
+ ScDocument* pDestDoc = NULL;
+ ScDocShell* pDestShell = NULL;
+ ScTabViewShell* pDestViewSh = NULL;
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ BOOL bNewDoc = ( nDestDocNo == SC_DOC_NEW );
+ if ( bNewDoc )
+ {
+ nDestTab = 0; // als erstes einfuegen
+
+ // ohne SFX_CALLMODE_RECORD ausfuehren, weil schon im Move-Befehl enthalten:
+
+ String aUrl = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("private:factory/"));
+ aUrl.AppendAscii(RTL_CONSTASCII_STRINGPARAM( STRING_SCAPP )); // "scalc"
+ SfxStringItem aItem( SID_FILE_NAME, aUrl );
+ SfxStringItem aTarget( SID_TARGETNAME, String::CreateFromAscii("_blank") );
+
+ const SfxPoolItem* pRetItem = GetViewData()->GetDispatcher().Execute(
+ SID_OPENDOC, SFX_CALLMODE_API|SFX_CALLMODE_SYNCHRON, &aItem, &aTarget, 0L );
+ if ( pRetItem )
+ {
+ if ( pRetItem->ISA( SfxObjectItem ) )
+ pDestShell = PTR_CAST( ScDocShell, ((const SfxObjectItem*)pRetItem)->GetShell() );
+ else if ( pRetItem->ISA( SfxViewFrameItem ) )
+ {
+ SfxViewFrame* pFrm = ((const SfxViewFrameItem*)pRetItem)->GetFrame();
+ if (pFrm)
+ pDestShell = PTR_CAST( ScDocShell, pFrm->GetObjectShell() );
+ }
+ if (pDestShell)
+ pDestViewSh = pDestShell->GetBestViewShell();
+ }
+ }
+ else
+ pDestShell = ScDocShell::GetShellByNum( nDestDocNo );
+
+ if (!pDestShell)
+ {
+ DBG_ERROR("Dest-Doc nicht gefunden !!!");
+ return;
+ }
+
+ pDestDoc = pDestShell->GetDocument();
+
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ if (pDestDoc != pDoc)
+ {
+ if (bNewDoc)
+ {
+ while (pDestDoc->GetTableCount() > 1)
+ pDestDoc->DeleteTab(0);
+ pDestDoc->RenameTab( 0,
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("______42_____")),
+ FALSE );
+ }
+
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nTabSelCount = rMark.GetSelectCount();
+
+ SvShorts TheTabs;
+
+ for(SCTAB i=0;i<nTabCount;i++)
+ {
+ if(rMark.GetTableSelect(i))
+ {
+ String aTabName;
+ pDoc->GetName( i, aTabName);
+ TheTabs.Insert(i,TheTabs.Count());
+ for(SCTAB j=i+1;j<nTabCount;j++)
+ {
+ if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
+ {
+ pDoc->GetName( j, aTabName);
+ TheTabs.Insert(j,TheTabs.Count());
+ i=j;
+ }
+ else break;
+ }
+ }
+ }
+
+ GetFrameWin()->EnterWait();
+
+ if (pDoc->GetDrawLayer())
+ pDestShell->MakeDrawLayer();
+
+ if (!bNewDoc && bUndo)
+ pDestDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
+
+ ULONG nErrVal =1;
+ if(nDestTab==SC_TAB_APPEND)
+ nDestTab=pDestDoc->GetTableCount();
+ SCTAB nDestTab1=nDestTab;
+ for( USHORT j=0; j<TheTabs.Count(); j++, nDestTab1++ )
+ { // #63304# insert sheets first and update all references
+ String aName;
+ pDoc->GetName( TheTabs[j], aName );
+ pDestDoc->CreateValidTabName( aName );
+ if ( !pDestDoc->InsertTab( nDestTab1, aName ) )
+ {
+ nErrVal = 0; // total error
+ break; // for
+ }
+ }
+ if ( nErrVal > 0 )
+ {
+ nDestTab1 = nDestTab;
+ for(USHORT i=0;i<TheTabs.Count();i++)
+ {
+ nErrVal = pDestShell->TransferTab( *pDocShell, static_cast<SCTAB>(TheTabs[i]), static_cast<SCTAB>(nDestTab1), FALSE, FALSE );
+ nDestTab1++;
+ }
+ }
+ String sName;
+ if (!bNewDoc && bUndo)
+ {
+ pDestDoc->GetName(nDestTab, sName);
+ pDestShell->GetUndoManager()->AddUndoAction(
+ new ScUndoImportTab( pDestShell, nDestTab,
+ static_cast<SCTAB>(TheTabs.Count()), FALSE));
+
+ }
+ else
+ {
+ pDestShell->GetUndoManager()->Clear();
+ }
+
+ GetFrameWin()->LeaveWait();
+ switch (nErrVal)
+ {
+ case 0: // interner Fehler oder voll Fehler
+ {
+ ErrorMessage(STR_TABINSERT_ERROR);
+ return;
+ }
+ //break;
+ case 2:
+ ErrorMessage(STR_ABSREFLOST);
+ break;
+ case 3:
+ ErrorMessage(STR_NAMECONFLICT);
+ break;
+ case 4:
+ {
+ ErrorMessage(STR_ABSREFLOST);
+ ErrorMessage(STR_NAMECONFLICT);
+ }
+ break;
+ default:
+ break;
+ }
+ //pDestShell->GetUndoManager()->Clear(); //! Undo implementieren !!!
+/*
+ String sName;
+ pDestDoc->GetName(nDestTab, sName);
+ pDestShell->GetUndoManager()->AddUndoAction(
+ new ScUndoInsertTab( pDestShell, nDestTab, TRUE, sName ) );
+*/
+ if (!bCopy)
+ {
+ if(nTabCount!=nTabSelCount)
+ DeleteTables(TheTabs);// incl. Paint & Undo
+ else
+ ErrorMessage(STR_TABREMOVE_ERROR);
+ }
+
+ if (bNewDoc)
+ {
+ // ChartListenerCollection must be updated before DeleteTab
+ if ( pDestDoc->IsChartListenerCollectionNeedsUpdate() )
+ pDestDoc->UpdateChartListenerCollection();
+
+ pDestDoc->DeleteTab(static_cast<SCTAB>(TheTabs.Count())); // alte erste Tabelle
+//? pDestDoc->SelectTable(0, TRUE); // neue erste Tabelle selektieren
+ if (pDestViewSh)
+ pDestViewSh->TabChanged(); // Pages auf dem Drawing-Layer
+ pDestShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB,
+ PAINT_GRID | PAINT_TOP | PAINT_LEFT |
+ PAINT_EXTRAS | PAINT_SIZE );
+ // PAINT_SIZE fuer Gliederung
+ }
+ else
+ {
+ pDestShell->Broadcast( ScTablesHint( SC_TAB_INSERTED, nDestTab ) );
+ pDestShell->PostPaintExtras();
+ pDestShell->PostPaintGridAll();
+ }
+
+ TheTabs.Remove(0,TheTabs.Count());
+
+ pDestShell->SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ }
+ else // innerhalb des Dokuments
+ {
+
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDoc->GetTableCount();
+
+ SvShorts TheTabs;
+ SvShorts TheDestTabs;
+ SvStrings TheTabNames;
+ String aDestName;
+ String *pString;
+
+ for(SCTAB i=0;i<nTabCount;i++)
+ {
+ if(rMark.GetTableSelect(i))
+ {
+ String aTabName;
+ pDoc->GetName( i, aTabName);
+ TheTabNames.Insert(new String(aTabName),TheTabNames.Count());
+
+ for(SCTAB j=i+1;j<nTabCount;j++)
+ {
+ if((!pDoc->IsVisible(j))&&(pDoc->IsScenario(j)))
+ {
+ pDoc->GetName( j, aTabName);
+ TheTabNames.Insert(new String(aTabName),TheTabNames.Count());
+ i=j;
+ }
+ else break;
+ }
+
+ }
+ }
+
+ if (bCopy && bUndo)
+ pDoc->BeginDrawUndo(); // drawing layer must do its own undo actions
+
+ pDoc->GetName( nDestTab, aDestName);
+ SCTAB nDestTab1=nDestTab;
+ SCTAB nMovTab=0;
+ for(int j=0;j<TheTabNames.Count();j++)
+ {
+ nTabCount = pDoc->GetTableCount();
+ pString=TheTabNames[sal::static_int_cast<USHORT>(j)];
+ if(!pDoc->GetTable(*pString,nMovTab))
+ {
+ nMovTab=nTabCount;
+ }
+ if(!pDoc->GetTable(aDestName,nDestTab1))
+ {
+ nDestTab1=nTabCount;
+ }
+ pDocShell->MoveTable( nMovTab, nDestTab1, bCopy, FALSE ); // Undo ist hier
+
+ if(bCopy && pDoc->IsScenario(nMovTab))
+ {
+ String aComment;
+ Color aColor;
+ USHORT nFlags;
+
+ pDoc->GetScenarioData(nMovTab, aComment,aColor, nFlags);
+ pDoc->SetScenario(nDestTab1,TRUE);
+ pDoc->SetScenarioData(nDestTab1,aComment,aColor,nFlags);
+ BOOL bActive = pDoc->IsActiveScenario(nMovTab );
+ pDoc->SetActiveScenario( nDestTab1, bActive );
+ BOOL bVisible=pDoc->IsVisible(nMovTab);
+ pDoc->SetVisible(nDestTab1,bVisible );
+ }
+
+ TheTabs.Insert(nMovTab,TheTabs.Count());
+
+ if(!bCopy)
+ {
+ if(!pDoc->GetTable(*pString,nDestTab1))
+ {
+ nDestTab1=nTabCount;
+ }
+ }
+
+ TheDestTabs.Insert(nDestTab1,TheDestTabs.Count());
+ delete pString;
+ }
+
+ nTab = GetViewData()->GetTabNo();
+
+ if (bUndo)
+ {
+ if (bCopy)
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoCopyTab( pDocShell, TheTabs, TheDestTabs));
+ }
+ else
+ {
+ pDocShell->GetUndoManager()->AddUndoAction(
+ new ScUndoMoveTab( pDocShell, TheTabs, TheDestTabs));
+ }
+ }
+
+ SCTAB nNewTab = nDestTab;
+ if (nNewTab == SC_TAB_APPEND)
+ nNewTab = pDoc->GetTableCount()-1;
+ else if (!bCopy && nTab<nDestTab)
+ nNewTab--;
+
+ SetTabNo( nNewTab, TRUE );
+
+ //#i29848# adjust references to data on the copied sheet
+ if( bCopy )
+ ScChartHelper::AdjustRangesOfChartsOnDestinationPage( pDoc, pDestDoc, nTab, nNewTab );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::ShowTable( const String& rName )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ BOOL bFound = FALSE;
+ SCTAB nPos = 0;
+ String aTabName;
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nCount; i++)
+ {
+ pDoc->GetName( i, aTabName );
+ if ( aTabName == rName )
+ {
+ nPos = i;
+ bFound = TRUE;
+ }
+ }
+
+ if (bFound)
+ {
+ pDoc->SetVisible( nPos, TRUE );
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nPos, TRUE ) );
+ }
+ SetTabNo( nPos, TRUE );
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
+ pDocSh->SetDocumentModified();
+ }
+ else
+ Sound::Beep();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::HideTable( SCTAB nTab )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ BOOL bUndo(pDoc->IsUndoEnabled());
+ SCTAB nVisible = 0;
+ SCTAB nCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nCount; i++)
+ {
+ if (pDoc->IsVisible(i))
+ ++nVisible;
+ }
+
+ if (nVisible > 1)
+ {
+ pDoc->SetVisible( nTab, FALSE );
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction( new ScUndoShowHideTab( pDocSh, nTab, FALSE ) );
+ }
+
+ // Views updaten:
+ pDocSh->Broadcast( ScTablesHint( SC_TAB_HIDDEN, nTab ) );
+
+ SetTabNo( nTab, TRUE );
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_TABLES_CHANGED ) );
+ pDocSh->PostPaint(0,0,0,MAXCOL,MAXROW,MAXTAB, PAINT_EXTRAS);
+ pDocSh->SetDocumentModified();
+ }
+ else
+ Sound::Beep();
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::InsertSpecialChar( const String& rStr, const Font& rFont )
+{
+ ScEditableTester aTester( this );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ const sal_Unicode* pChar = rStr.GetBuffer();
+ ScTabViewShell* pViewShell = GetViewData()->GetViewShell();
+ SvxFontItem aFontItem( rFont.GetFamily(),
+ rFont.GetName(),
+ rFont.GetStyleName(),
+ rFont.GetPitch(),
+ rFont.GetCharSet(),
+ ATTR_FONT );
+
+ // if string contains WEAK characters, set all fonts
+ BYTE nScript;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( pDoc->HasStringWeakCharacters( rStr ) )
+ nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ else
+ nScript = pDoc->GetStringScriptType( rStr );
+
+ SvxScriptSetItem aSetItem( SID_ATTR_CHAR_FONT, pViewShell->GetPool() );
+ aSetItem.PutItemForScriptType( nScript, aFontItem );
+ ApplyUserItemSet( aSetItem.GetItemSet() );
+
+ while ( *pChar )
+ pViewShell->TabKeyInput( KeyEvent( *(pChar++), KeyCode() ) );
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::UpdateLineAttrs( SvxBorderLine& rLine,
+ const SvxBorderLine* pDestLine,
+ const SvxBorderLine* pSrcLine,
+ BOOL bColor )
+{
+ if ( pSrcLine && pDestLine )
+ {
+ if ( bColor )
+ {
+ rLine.SetColor ( pSrcLine->GetColor() );
+ rLine.SetOutWidth ( pDestLine->GetOutWidth() );
+ rLine.SetInWidth ( pDestLine->GetInWidth() );
+ rLine.SetDistance ( pDestLine->GetDistance() );
+ rLine.SetStyle ( pDestLine->GetStyle() );
+ }
+ else
+ {
+ rLine.SetColor ( pDestLine->GetColor() );
+ rLine.SetOutWidth ( pSrcLine->GetOutWidth() );
+ rLine.SetInWidth ( pSrcLine->GetInWidth() );
+ rLine.SetDistance ( pSrcLine->GetDistance() );
+ rLine.SetStyle ( pSrcLine->GetStyle() );
+ }
+ }
+}
+
+
+#define SET_LINE_ATTRIBUTES(LINE,BOXLINE) \
+ pBoxLine = aBoxItem.Get##LINE(); \
+ if ( pBoxLine ) \
+ { \
+ if ( pLine ) \
+ { \
+ UpdateLineAttrs( aLine, pBoxLine, pLine, bColorOnly ); \
+ aBoxItem.SetLine( &aLine, BOXLINE ); \
+ } \
+ else \
+ aBoxItem.SetLine( NULL, BOXLINE ); \
+ }
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine,
+ BOOL bColorOnly )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData aFuncMark( GetViewData()->GetMarkData() ); // local copy for UnmarkFiltered
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScPatternAttr* pSelAttrs = GetSelectionPattern();
+ const SfxItemSet& rSelItemSet = pSelAttrs->GetItemSet();
+
+ const SfxPoolItem* pBorderAttr = NULL;
+ SfxItemState eItemState = rSelItemSet.GetItemState( ATTR_BORDER, TRUE, &pBorderAttr );
+
+ const SfxPoolItem* pTLBRItem = 0;
+ SfxItemState eTLBRState = rSelItemSet.GetItemState( ATTR_BORDER_TLBR, TRUE, &pTLBRItem );
+
+ const SfxPoolItem* pBLTRItem = 0;
+ SfxItemState eBLTRState = rSelItemSet.GetItemState( ATTR_BORDER_BLTR, TRUE, &pBLTRItem );
+
+ // any of the lines visible?
+ if( (eItemState != SFX_ITEM_DEFAULT) || (eTLBRState != SFX_ITEM_DEFAULT) || (eBLTRState != SFX_ITEM_DEFAULT) )
+ {
+ // none of the lines don't care?
+ if( (eItemState != SFX_ITEM_DONTCARE) && (eTLBRState != SFX_ITEM_DONTCARE) && (eBLTRState != SFX_ITEM_DONTCARE) )
+ {
+ SfxItemSet* pOldSet = new SfxItemSet(
+ *(pDoc->GetPool()),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+ SfxItemSet* pNewSet = new SfxItemSet(
+ *(pDoc->GetPool()),
+ ATTR_PATTERN_START,
+ ATTR_PATTERN_END );
+
+ //------------------------------------------------------------
+ const SvxBorderLine* pBoxLine = NULL;
+ SvxBorderLine aLine;
+
+ // hier wird die pBoxLine benutzt:
+
+ if( pBorderAttr )
+ {
+ SvxBoxItem aBoxItem( *(const SvxBoxItem*)pBorderAttr );
+ SvxBoxInfoItem aBoxInfoItem( ATTR_BORDER_INNER );
+
+ SET_LINE_ATTRIBUTES(Top,BOX_LINE_TOP)
+ SET_LINE_ATTRIBUTES(Bottom,BOX_LINE_BOTTOM)
+ SET_LINE_ATTRIBUTES(Left,BOX_LINE_LEFT)
+ SET_LINE_ATTRIBUTES(Right,BOX_LINE_RIGHT)
+
+ aBoxInfoItem.SetLine( aBoxItem.GetTop(), BOXINFO_LINE_HORI );
+ aBoxInfoItem.SetLine( aBoxItem.GetLeft(), BOXINFO_LINE_VERT );
+ aBoxInfoItem.ResetFlags(); // Lines auf Valid setzen
+
+ pOldSet->Put( *pBorderAttr );
+ pNewSet->Put( aBoxItem );
+ pNewSet->Put( aBoxInfoItem );
+ }
+
+ if( pTLBRItem && ((const SvxLineItem*)pTLBRItem)->GetLine() )
+ {
+ SvxLineItem aTLBRItem( *(const SvxLineItem*)pTLBRItem );
+ UpdateLineAttrs( aLine, aTLBRItem.GetLine(), pLine, bColorOnly );
+ aTLBRItem.SetLine( &aLine );
+ pOldSet->Put( *pTLBRItem );
+ pNewSet->Put( aTLBRItem );
+ }
+
+ if( pBLTRItem && ((const SvxLineItem*)pBLTRItem)->GetLine() )
+ {
+ SvxLineItem aBLTRItem( *(const SvxLineItem*)pBLTRItem );
+ UpdateLineAttrs( aLine, aBLTRItem.GetLine(), pLine, bColorOnly );
+ aBLTRItem.SetLine( &aLine );
+ pOldSet->Put( *pBLTRItem );
+ pNewSet->Put( aBLTRItem );
+ }
+
+ ApplyAttributes( pNewSet, pOldSet );
+
+ delete pOldSet;
+ delete pNewSet;
+ }
+ else // if ( eItemState == SFX_ITEM_DONTCARE )
+ {
+ aFuncMark.MarkToMulti();
+ pDoc->ApplySelectionLineStyle( aFuncMark, pLine, bColorOnly );
+ }
+
+ ScRange aMarkRange;
+ aFuncMark.GetMultiMarkArea( aMarkRange );
+ SCCOL nStartCol = aMarkRange.aStart.Col();
+ SCROW nStartRow = aMarkRange.aStart.Row();
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCCOL nEndCol = aMarkRange.aEnd.Col();
+ SCROW nEndRow = aMarkRange.aEnd.Row();
+ SCTAB nEndTab = aMarkRange.aEnd.Tab();
+ pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab,
+ PAINT_GRID, SC_PF_LINES | SC_PF_TESTMERGE );
+
+ pDocSh->UpdateOle( GetViewData() );
+ pDocSh->SetDocumentModified();
+ }
+}
+
+#undef SET_LINE_ATTRIBUTES
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::SetConditionalFormat( const ScConditionalFormat& rNew )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ULONG nIndex = pDoc->AddCondFormat(rNew); // dafuer gibt's kein Undo
+ SfxUInt32Item aItem( ATTR_CONDITIONAL, nIndex );
+
+ ApplyAttr( aItem ); // mit Paint und Undo...
+}
+
+
+//----------------------------------------------------------------------------
+
+void ScViewFunc::SetValidation( const ScValidationData& rNew )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ULONG nIndex = pDoc->AddValidationEntry(rNew); // dafuer gibt's kein Undo
+ SfxUInt32Item aItem( ATTR_VALIDDATA, nIndex );
+
+ ApplyAttr( aItem ); // mit Paint und Undo...
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
new file mode 100644
index 000000000000..69d608d4a7ee
--- /dev/null
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -0,0 +1,1947 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#define _SV_NOXSOUND
+
+#ifdef WIN
+ #define _MENUBTN_HXX
+#endif
+
+#define _BASE_DLGS_HXX
+#define _BIGINT_HXX
+#define _CACHESTR_HXX
+#define _CONFIG_HXX
+#define _CURSOR_HXX
+#define _CTRLTOOL_HXX
+#define _DLGCFG_HXX
+#define _DYNARR_HXX
+#define _EXTATTR_HXX
+#define _FILDLG_HXX
+#define _FONTDLG_HXX
+#define _FRM3D_HXX
+#define _INTRO_HXX
+#define _ISETBWR_HXX
+#define _NO_SVRTF_PARSER_HXX
+#define _MACRODLG_HXX
+#define _MODALDLG_HXX
+#define _MOREBUTTON_HXX
+#define _OUTLINER_HXX
+//#define _PRNDLG_HXX
+//#define _POLY_HXX
+#define _PVRWIN_HXX
+//#define _QUEUE_HXX
+#define _RULER_HXX
+#define _SCRWIN_HXX
+#define _SETBRW_HXX
+//#define _STACK_HXX
+//#define _STATUS_HXX ***
+#define _STDCTRL_HXX
+#define _STDMENU_HXX
+//#define _TAB_HXX
+#define _TABBAR_HXX
+#define _TREELIST_HXX
+#define _VALUESET_HXX
+#define _VCATTR_HXX
+#define _VCBRW_HXX
+#define _VCTRLS_HXX
+#define _VCSBX_HXX
+#define _VCONT_HXX
+#define _VDRWOBJ_HXX
+
+//#define _SELENG_HXX
+//#define _SOUND_HXX
+//#define _SYSDLG_HXX
+
+
+
+
+#define _PASSWD_HXX
+
+#define _SFX_DOCFILE_HXX
+//#define _SFX_DOCFILT_HXX
+#define _SFX_DOCINF_HXX
+#define _SFX_DOCSH_HXX
+//#define _SFXDOCFILT_HXX
+//#define _SFXDOCINF_HXX
+//#define _SFXDOCSH_HXX
+#define _SFX_PRNMON_HXX
+#define _SFX_RESMGR_HXX
+#define _SFX_TEMPLDLG_HXX
+//#define _SFXAPPWIN_HXX
+#define _SFXBASIC_HXX
+#define _SFXCTRLITEM
+#define _SFXDLGCFG_HXX
+//#define _SFXDISPATCH_HXX
+#define _SFXFILEDLG_HXX
+//#define _SFXIMGMGR_HXX
+#define _SFXIPFRM_HXX
+#define _SFX_MACRO_HXX
+#define _SFXMNUITEM_HXX
+#define _SFXMNUMGR_HXX
+#define _SFXMULTISEL_HXX
+//#define _SFXMSG_HXX
+#define _SFXMSGDESCR_HXX
+#define _SFXMSGPOOL_HXX
+#define _SFX_MINFITEM_HXX
+#define _SFXOBJFACE_HXX
+#define _SFXOBJFAC_HXX
+#define _SFX_SAVEOPT_HXX
+#define _SFXSTBITEM_HXX
+#define _SFXSTBMGR_HXX
+#define _SFXTBXCTRL_HXX
+#define _SFXTBXMGR_HXX
+
+#define _SI_HXX
+//#define _SI_DLL_HXX
+//#define _SIDLL_HXX
+//#define _SI_NOITEMS
+//#define _SI_NOOTHERFORMS
+//#define _SI_NOSBXCONTROLS
+//#define _SINOSBXCONTROLS
+//#define _SI_NODRW
+//#define _SI_NOCONTROL
+
+#define _SVBOXITM_HXX
+#define _SVCONTNR_HXX //
+
+#define _SDR_NOTRANSFORM
+
+#define _SVDRAG_HXX
+#define _SVINCVW_HXX
+//#define _SV_MULTISEL_HXX
+#define _SVRTV_HXX
+#define _SVTABBX_HXX
+#define _SVTREEBOX_HXX
+#define _SVTREELIST_HXX
+
+#define _SVX_DAILDLL_HXX
+#define _SVX_HYPHEN_HXX
+#define _SVX_IMPGRF_HXX
+#define _SVX_LAYCTRL_HXX
+#define _SVX_OPTITEMS_HXX
+#define _SVX_OPTGERL_HXX
+#define _SVX_OPTSAVE_HXX
+#define _SVX_OPTSPELL_HXX
+#define _SVX_OPTPATH_HXX
+#define _SVX_OPTLINGU_HXX
+#define _SVX_RULER_HXX
+#define _SVX_RULRITEM_HXX
+#define _SVX_SELCTRL_HXX
+#define _SVX_SPLWRAP_HXX
+#define _SVX_SPLDLG_HXX
+#define _SVX_STDDLG_HXX
+#define _SVX_THESDLG_HXX
+
+// INCLUDE -------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <svx/dbexch.hrc>
+#include <svx/svdetc.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/stritem.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/urlbmk.hxx>
+#include <sot/clsids.hxx>
+#include <sot/formats.hxx>
+#include <vcl/graph.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/urlobj.hxx>
+#include <sot/exchange.hxx>
+#include <memory>
+
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "dociter.hxx"
+#include "viewfunc.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "docfunc.hxx"
+#include "undoblk.hxx"
+#include "refundo.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "rangenam.hxx"
+#include "dbcolect.hxx"
+#include "impex.hxx" // Sylk-ID fuer CB
+#include "chgtrack.hxx"
+#include "waitoff.hxx"
+#include "scmod.hxx"
+#include "sc.hrc"
+#include "inputopt.hxx"
+#include "warnbox.hxx"
+#include "drwlayer.hxx"
+#include "editable.hxx"
+#include "transobj.hxx"
+#include "drwtrans.hxx"
+#include "docuno.hxx"
+#include "clipparam.hxx"
+#include "undodat.hxx" // Amelia Wang
+
+using namespace com::sun::star;
+
+// STATIC DATA ---------------------------------------------------------------
+
+
+//============================================================================
+
+// GlobalName der Writer-DocShell kommt jetzt aus comphelper/classids.hxx
+
+//----------------------------------------------------------------------------
+// C U T
+
+void ScViewFunc::CutToClip( ScDocument* pClipDoc, BOOL bIncludeObjects )
+{
+ UpdateInputLine();
+
+ ScEditableTester aTester( this );
+ if (!aTester.IsEditable()) // selection editable?
+ {
+ ErrorMessage( aTester.GetMessageId() );
+ return;
+ }
+
+ ScRange aRange; // zu loeschender Bereich
+ if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ const BOOL bRecord(pDoc->IsUndoEnabled()); // Undo/Redo
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) // mark the range if not marked yet
+ {
+ DoneBlockMode();
+ InitOwnBlockMode();
+ rMark.SetMarkArea( aRange );
+ MarkDataChanged();
+ }
+
+ CopyToClip( pClipDoc, TRUE, FALSE, bIncludeObjects ); // Ab ins Clipboard
+
+ ScAddress aOldEnd( aRange.aEnd ); // Zusammengefasste Zellen im Bereich?
+ pDoc->ExtendMerge( aRange, TRUE );
+
+ ScDocument* pUndoDoc = NULL;
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndoSelected( pDoc, rMark );
+ // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
+ ScRange aCopyRange = aRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(pDoc->GetTableCount()-1);
+ pDoc->CopyToDocument( aCopyRange, (IDF_ALL & ~IDF_OBJECTS) | IDF_NOCAPTIONS, FALSE, pUndoDoc );
+ pDoc->BeginDrawUndo();
+ }
+
+ USHORT nExtFlags = 0;
+ pDocSh->UpdatePaintExt( nExtFlags, aRange );
+
+ HideCursor(); // Cursor aendert sich !
+
+ rMark.MarkToMulti();
+ pDoc->DeleteSelection( IDF_ALL, rMark );
+ if ( bIncludeObjects )
+ pDoc->DeleteObjectsInSelection( rMark );
+ rMark.MarkToSimple();
+
+ if ( !AdjustRowHeight( aRange.aStart.Row(), aRange.aEnd.Row() ) )
+ pDocSh->PostPaint( aRange, PAINT_GRID, nExtFlags );
+
+ if ( bRecord ) // erst jetzt ist Draw-Undo verfuegbar
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoCut( pDocSh, aRange, aOldEnd, rMark, pUndoDoc ) );
+
+ aModificator.SetDocumentModified();
+ ShowCursor(); // Cursor aendert sich !
+ pDocSh->UpdateOle(GetViewData());
+
+ CellContentChanged();
+ }
+ else
+ ErrorMessage( STR_NOMULTISELECT );
+}
+
+
+//----------------------------------------------------------------------------
+// C O P Y
+
+BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, BOOL bCut, BOOL bApi, BOOL bIncludeObjects, BOOL bStopEdit )
+{
+ BOOL bDone = FALSE;
+ if ( bStopEdit )
+ UpdateInputLine();
+
+ ScRange aRange;
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aRange );
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED )
+ {
+ if ( !pDoc->HasSelectedBlockMatrixFragment(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(),
+ rMark ) )
+ {
+ BOOL bSysClip = FALSE;
+ if ( !pClipDoc ) // no clip doc specified
+ {
+ pClipDoc = new ScDocument( SCDOCMODE_CLIP ); // create one (deleted by ScTransferObj)
+ bSysClip = TRUE; // and copy into system
+ }
+
+ if ( !bCut )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut(); // kein CutMode mehr
+ }
+
+ if ( bSysClip && bIncludeObjects )
+ {
+ BOOL bAnyOle = pDoc->HasOLEObjectsInArea( aRange, &rMark );
+ // update ScGlobal::pDrawClipDocShellRef
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ }
+
+ ScClipParam aClipParam(aRange, bCut);
+ pDoc->CopyToClip(aClipParam, pClipDoc, &rMark, false, false, bIncludeObjects);
+ if (bSysClip)
+ {
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+
+ ScGlobal::SetClipDocName( pDoc->GetDocumentShell()->GetTitle( SFX_TITLE_FULLNAME ) );
+ }
+ pClipDoc->ExtendMerge( aRange, TRUE );
+
+ if (bSysClip)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScTransferObj ctor
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ SfxObjectShellRef aPersistRef( &(*ScGlobal::pDrawClipDocShellRef) );
+ pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive
+ }
+
+ pTransferObj->CopyToClipboard( GetActiveWin() ); // system clipboard
+ SC_MOD()->SetClipObject( pTransferObj, NULL ); // internal clipboard
+ }
+
+ bDone = TRUE;
+ }
+ else
+ {
+ if (!bApi)
+ ErrorMessage(STR_MATRIXFRAGMENTERR);
+ }
+ }
+ else if (eMarkType == SC_MARK_MULTI)
+ {
+ bool bSuccess = false;
+ ScClipParam aClipParam;
+ aClipParam.mbCutMode = false;
+ rMark.MarkToSimple();
+ rMark.FillRangeListWithMarks(&aClipParam.maRanges, false);
+
+ do
+ {
+ if (bCut)
+ // We con't support cutting of multi-selections.
+ break;
+
+ if (pClipDoc)
+ // TODO: What's this for?
+ break;
+
+ ::std::auto_ptr<ScDocument> pDocClip(new ScDocument(SCDOCMODE_CLIP));
+
+ // Check for geometrical feasibility of the ranges.
+ bool bValidRanges = true;
+ ScRangePtr p = aClipParam.maRanges.First();
+ SCCOL nPrevColDelta = 0;
+ SCROW nPrevRowDelta = 0;
+ SCCOL nPrevCol = p->aStart.Col();
+ SCROW nPrevRow = p->aStart.Row();
+ SCCOL nPrevColSize = p->aEnd.Col() - p->aStart.Col() + 1;
+ SCROW nPrevRowSize = p->aEnd.Row() - p->aStart.Row() + 1;
+ for (p = aClipParam.maRanges.Next(); p; p = aClipParam.maRanges.Next())
+ {
+ if (pDoc->HasSelectedBlockMatrixFragment(
+ p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), rMark))
+ {
+ if (!bApi)
+ ErrorMessage(STR_MATRIXFRAGMENTERR);
+ return false;
+ }
+
+ SCCOL nColDelta = p->aStart.Col() - nPrevCol;
+ SCROW nRowDelta = p->aStart.Row() - nPrevRow;
+
+ if ((nColDelta && nRowDelta) || (nPrevColDelta && nRowDelta) || (nPrevRowDelta && nColDelta))
+ {
+ bValidRanges = false;
+ break;
+ }
+
+ if (aClipParam.meDirection == ScClipParam::Unspecified)
+ {
+ if (nColDelta)
+ aClipParam.meDirection = ScClipParam::Column;
+ if (nRowDelta)
+ aClipParam.meDirection = ScClipParam::Row;
+ }
+
+ SCCOL nColSize = p->aEnd.Col() - p->aStart.Col() + 1;
+ SCROW nRowSize = p->aEnd.Row() - p->aStart.Row() + 1;
+
+ if (aClipParam.meDirection == ScClipParam::Column && nRowSize != nPrevRowSize)
+ {
+ // column-oriented ranges must have identical row size.
+ bValidRanges = false;
+ break;
+ }
+ if (aClipParam.meDirection == ScClipParam::Row && nColSize != nPrevColSize)
+ {
+ // likewise, row-oriented ranges must have identical
+ // column size.
+ bValidRanges = false;
+ break;
+ }
+
+ nPrevCol = p->aStart.Col();
+ nPrevRow = p->aStart.Row();
+ nPrevColDelta = nColDelta;
+ nPrevRowDelta = nRowDelta;
+ nPrevColSize = nColSize;
+ nPrevRowSize = nRowSize;
+ }
+ if (!bValidRanges)
+ break;
+
+ pDoc->CopyToClip(aClipParam, pDocClip.get(), &rMark, false, false, bIncludeObjects);
+
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut(); // kein CutMode mehr
+
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ // maSize is set in ScTransferObj ctor
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pDocClip.release(), aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ SfxObjectShellRef aPersistRef( &(*ScGlobal::pDrawClipDocShellRef) );
+ pTransferObj->SetDrawPersist( aPersistRef ); // keep persist for ole objects alive
+ }
+
+ pTransferObj->CopyToClipboard( GetActiveWin() ); // system clipboard
+ SC_MOD()->SetClipObject( pTransferObj, NULL ); // internal clipboard
+ }
+
+ bSuccess = true;
+ }
+ while (false);
+
+ if (!bSuccess && !bApi)
+ ErrorMessage(STR_NOMULTISELECT);
+
+ bDone = bSuccess;
+ }
+ else
+ {
+ if (!bApi)
+ ErrorMessage(STR_NOMULTISELECT);
+ }
+
+ return bDone;
+}
+
+// Copy the content of the Range into clipboard. Adding this method for VBA API: Range.Copy().
+BOOL ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRange& rRange, BOOL bCut, BOOL bApi, BOOL bIncludeObjects, BOOL bStopEdit )
+{
+ BOOL bDone = FALSE;
+ if ( bStopEdit )
+ UpdateInputLine();
+
+ ScRange aRange = rRange;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( pDoc && !pDoc->HasSelectedBlockMatrixFragment( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aEnd.Col(), aRange.aEnd.Row(), aRange.aStart.Tab() ) )
+ {
+ BOOL bSysClip = FALSE;
+ if ( !pClipDoc )
+ {
+ // Create one (deleted by ScTransferObj).
+ pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ bSysClip = TRUE;
+ }
+ if ( !bCut )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut();
+ }
+
+ if ( bSysClip && bIncludeObjects )
+ {
+ BOOL bAnyOle = pDoc->HasOLEObjectsInArea( aRange );
+ // Update ScGlobal::pDrawClipDocShellRef.
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+ }
+
+ ScClipParam aClipParam( aRange, bCut );
+ pDoc->CopyToClip4VBA( aClipParam, pClipDoc, false, bIncludeObjects );
+ if ( bSysClip )
+ {
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+ ScGlobal::SetClipDocName( pDoc->GetDocumentShell()->GetTitle( SFX_TITLE_FULLNAME ) );
+ }
+ pClipDoc->ExtendMerge( aRange, TRUE );
+
+ if ( bSysClip )
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ uno::Reference<datatransfer::XTransferable> xTransferable( pTransferObj );
+ if ( ScGlobal::pDrawClipDocShellRef )
+ {
+ SfxObjectShellRef aPersistRef( &(*ScGlobal::pDrawClipDocShellRef) );
+ pTransferObj->SetDrawPersist( aPersistRef );
+ }
+ pTransferObj->CopyToClipboard( GetActiveWin() );
+ SC_MOD()->SetClipObject( pTransferObj, NULL );
+ }
+
+ bDone = TRUE;
+ }
+ else
+ {
+ if ( !bApi )
+ ErrorMessage(STR_MATRIXFRAGMENTERR);
+ }
+
+ return bDone;
+}
+
+ScTransferObj* ScViewFunc::CopyToTransferable()
+{
+ ScRange aRange;
+ if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !pDoc->HasSelectedBlockMatrixFragment(
+ aRange.aStart.Col(), aRange.aStart.Row(),
+ aRange.aEnd.Col(), aRange.aEnd.Row(),
+ rMark ) )
+ {
+ ScDocument *pClipDoc = new ScDocument( SCDOCMODE_CLIP ); // create one (deleted by ScTransferObj)
+
+ BOOL bAnyOle = pDoc->HasOLEObjectsInArea( aRange, &rMark );
+ ScDrawLayer::SetGlobalDrawPersist( ScTransferObj::SetDrawClipDoc( bAnyOle ) );
+
+ ScClipParam aClipParam(aRange, false);
+ pDoc->CopyToClip(aClipParam, pClipDoc, &rMark, false, false, true);
+
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+ pClipDoc->ExtendMerge( aRange, TRUE );
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ TransferableObjectDescriptor aObjDesc;
+ pDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ aObjDesc.maDisplayName = pDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ ScTransferObj* pTransferObj = new ScTransferObj( pClipDoc, aObjDesc );
+ return pTransferObj;
+ }
+ }
+
+ return NULL;
+}
+
+//----------------------------------------------------------------------------
+// P A S T E
+
+void ScViewFunc::PasteDraw()
+{
+ ScViewData* pViewData = GetViewData();
+ SCCOL nPosX = pViewData->GetCurX();
+ SCROW nPosY = pViewData->GetCurY();
+ Window* pWin = GetActiveWin();
+ Point aPos = pWin->PixelToLogic( pViewData->GetScrPos( nPosX, nPosY,
+ pViewData->GetActivePart() ) );
+ ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard( pWin );
+ if (pDrawClip)
+ PasteDraw( aPos, pDrawClip->GetModel(), FALSE,
+ pDrawClip->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() );
+}
+
+void ScViewFunc::PasteFromSystem()
+{
+ UpdateInputLine();
+
+ Window* pWin = GetActiveWin();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ ScDrawTransferObj* pDrawClip = ScDrawTransferObj::GetOwnClipboard( pWin );
+
+ if (pOwnClip)
+ {
+ // #129384# keep a reference in case the clipboard is changed during PasteFromClip
+ uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip );
+ PasteFromClip( IDF_ALL, pOwnClip->GetDocument(),
+ PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
+ TRUE ); // allow warning dialog
+ }
+ else if (pDrawClip)
+ PasteDraw();
+ else
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+
+// if (pClipObj.Is())
+ {
+ ULONG nBiff8 = SotExchange::RegisterFormatName(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff8")));
+ ULONG nBiff5 = SotExchange::RegisterFormatName(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5")));
+
+ // als erstes SvDraw-Model, dann Grafik
+ // (Grafik darf nur bei einzelner Grafik drinstehen)
+
+ if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))
+ {
+ // special case for tables from drawing
+ if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) )
+ {
+ PasteFromSystem( FORMAT_RTF );
+ }
+ else
+ {
+ PasteFromSystem( SOT_FORMATSTR_ID_DRAWING );
+ }
+ }
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ))
+ PasteFromSystem( SOT_FORMATSTR_ID_SVXB );
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))
+ {
+ // If it's a Writer object, insert RTF instead of OLE
+
+ // Else, if the class id is all-zero, and SYLK is available,
+ // it probably is spreadsheet cells that have been put
+ // on the clipboard by OOo, so use the SYLK. (fdo#31077)
+
+ BOOL bDoRtf = FALSE;
+ TransferableObjectDescriptor aObjDesc;
+ if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
+ {
+ bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) ||
+ aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) )
+ && aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+ if ( bDoRtf )
+ PasteFromSystem( FORMAT_RTF );
+ else if ( aObjDesc.maClassName == SvGlobalName( 0,0,0,0,0,0,0,0,0,0,0 )
+ && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SYLK ))
+ PasteFromSystem( SOT_FORMATSTR_ID_SYLK );
+ else
+ PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE );
+ }
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE );
+ // the following format can not affect scenario from #89579#
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE );
+ // FORMAT_PRIVATE no longer here (can't work if pOwnClip is NULL)
+ else if (aDataHelper.HasFormat(nBiff8)) // before xxx_OLE formats
+ PasteFromSystem(nBiff8);
+ else if (aDataHelper.HasFormat(nBiff5))
+ PasteFromSystem(nBiff5);
+ else if (aDataHelper.HasFormat(FORMAT_RTF))
+ PasteFromSystem(FORMAT_RTF);
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML))
+ PasteFromSystem(SOT_FORMATSTR_ID_HTML);
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE))
+ PasteFromSystem(SOT_FORMATSTR_ID_HTML_SIMPLE);
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_SYLK))
+ PasteFromSystem(SOT_FORMATSTR_ID_SYLK);
+ else if (aDataHelper.HasFormat(FORMAT_STRING))
+ PasteFromSystem(FORMAT_STRING);
+ else if (aDataHelper.HasFormat(FORMAT_GDIMETAFILE))
+ PasteFromSystem(FORMAT_GDIMETAFILE);
+ else if (aDataHelper.HasFormat(FORMAT_BITMAP))
+ PasteFromSystem(FORMAT_BITMAP);
+ // #89579# xxx_OLE formats come last, like in SotExchange tables
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE );
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ))
+ PasteFromSystem( SOT_FORMATSTR_ID_LINK_SOURCE_OLE );
+// else
+// ErrorMessage(STR_PASTE_ERROR);
+ }
+// else
+// ErrorMessage(STR_PASTE_ERROR);
+ }
+
+ // keine Fehlermeldung, weil SID_PASTE in der idl das FastCall-Flag hat,
+ // also auch gerufen wird, wenn nichts im Clipboard steht (#42531#)
+}
+
+void ScViewFunc::PasteFromTransferable( const uno::Reference<datatransfer::XTransferable>& rxTransferable )
+{
+ ScTransferObj *pOwnClip=0;
+ ScDrawTransferObj *pDrawClip=0;
+ uno::Reference<lang::XUnoTunnel> xTunnel( rxTransferable, uno::UNO_QUERY );
+ if ( xTunnel.is() )
+ {
+ sal_Int64 nHandle = xTunnel->getSomething( ScTransferObj::getUnoTunnelId() );
+ if ( nHandle )
+ pOwnClip = (ScTransferObj*) (sal_IntPtr) nHandle;
+ else
+ {
+ nHandle = xTunnel->getSomething( ScDrawTransferObj::getUnoTunnelId() );
+ if ( nHandle )
+ pDrawClip = (ScDrawTransferObj*) (sal_IntPtr) nHandle;
+ }
+ }
+
+ if (pOwnClip)
+ {
+ PasteFromClip( IDF_ALL, pOwnClip->GetDocument(),
+ PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
+ TRUE ); // allow warning dialog
+ }
+ else if (pDrawClip)
+ {
+ ScViewData* pViewData = GetViewData();
+ SCCOL nPosX = pViewData->GetCurX();
+ SCROW nPosY = pViewData->GetCurY();
+ Window* pWin = GetActiveWin();
+ Point aPos = pWin->PixelToLogic( pViewData->GetScrPos( nPosX, nPosY, pViewData->GetActivePart() ) );
+ PasteDraw( aPos, pDrawClip->GetModel(), FALSE, pDrawClip->GetSourceDocID() == pViewData->GetDocument()->GetDocumentID() );
+ }
+ else
+ {
+ TransferableDataHelper aDataHelper( rxTransferable );
+ {
+ ULONG nBiff8 = SotExchange::RegisterFormatName(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff8")));
+ ULONG nBiff5 = SotExchange::RegisterFormatName(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Biff5")));
+ ULONG nFormatId = 0;
+ // als erstes SvDraw-Model, dann Grafik
+ // (Grafik darf nur bei einzelner Grafik drinstehen)
+
+ if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ))
+ nFormatId = SOT_FORMATSTR_ID_DRAWING;
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ))
+ nFormatId = SOT_FORMATSTR_ID_SVXB;
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))
+ {
+ // If it's a Writer object, insert RTF instead of OLE
+ BOOL bDoRtf = FALSE;
+ TransferableObjectDescriptor aObjDesc;
+ if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) )
+ {
+ bDoRtf = ( ( aObjDesc.maClassName == SvGlobalName( SO3_SW_CLASSID ) ||
+ aObjDesc.maClassName == SvGlobalName( SO3_SWWEB_CLASSID ) )
+ && aDataHelper.HasFormat( SOT_FORMAT_RTF ) );
+ }
+ if ( bDoRtf )
+ nFormatId = FORMAT_RTF;
+ else
+ nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE;
+ }
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE ))
+ nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE;
+ // the following format can not affect scenario from #89579#
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ))
+ nFormatId = SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE;
+ // FORMAT_PRIVATE no longer here (can't work if pOwnClip is NULL)
+ else if (aDataHelper.HasFormat(nBiff8)) // before xxx_OLE formats
+ nFormatId = nBiff8;
+ else if (aDataHelper.HasFormat(nBiff5))
+ nFormatId = nBiff5;
+ else if (aDataHelper.HasFormat(FORMAT_RTF))
+ nFormatId = FORMAT_RTF;
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML))
+ nFormatId = SOT_FORMATSTR_ID_HTML;
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_HTML_SIMPLE))
+ nFormatId = SOT_FORMATSTR_ID_HTML_SIMPLE;
+ else if (aDataHelper.HasFormat(SOT_FORMATSTR_ID_SYLK))
+ nFormatId = SOT_FORMATSTR_ID_SYLK;
+ else if (aDataHelper.HasFormat(FORMAT_STRING))
+ nFormatId = FORMAT_STRING;
+ else if (aDataHelper.HasFormat(FORMAT_GDIMETAFILE))
+ nFormatId = FORMAT_GDIMETAFILE;
+ else if (aDataHelper.HasFormat(FORMAT_BITMAP))
+ nFormatId = FORMAT_BITMAP;
+ // #89579# xxx_OLE formats come last, like in SotExchange tables
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ))
+ nFormatId = SOT_FORMATSTR_ID_EMBED_SOURCE_OLE;
+ else if (aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK_SOURCE_OLE ))
+ nFormatId = SOT_FORMATSTR_ID_LINK_SOURCE_OLE;
+ else
+ return;
+
+ PasteDataFormat( nFormatId, aDataHelper.GetTransferable(),
+ GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ NULL, FALSE, FALSE );
+ }
+ }
+}
+
+BOOL ScViewFunc::PasteFromSystem( ULONG nFormatId, BOOL bApi )
+{
+ UpdateInputLine();
+
+ BOOL bRet = TRUE;
+ Window* pWin = GetActiveWin();
+ ScTransferObj* pOwnClip = ScTransferObj::GetOwnClipboard( pWin );
+ if ( nFormatId == 0 && pOwnClip )
+ {
+ // #129384# keep a reference in case the clipboard is changed during PasteFromClip
+ uno::Reference<datatransfer::XTransferable> aOwnClipRef( pOwnClip );
+ PasteFromClip( IDF_ALL, pOwnClip->GetDocument(),
+ PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
+ !bApi ); // allow warning dialog
+ }
+ else
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pWin ) );
+ if ( !aDataHelper.GetTransferable().is() )
+ return FALSE;
+
+ bRet = PasteDataFormat( nFormatId, aDataHelper.GetTransferable(),
+ GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ NULL, FALSE, !bApi ); // allow warning dialog
+
+ if ( !bRet && !bApi )
+ ErrorMessage(STR_PASTE_ERROR);
+ }
+ return bRet;
+}
+
+
+//----------------------------------------------------------------------------
+// P A S T E
+
+BOOL ScViewFunc::PasteOnDrawObject( const uno::Reference<datatransfer::XTransferable>& rxTransferable,
+ SdrObject* pHitObj, BOOL bLink )
+{
+ BOOL bRet = FALSE;
+ if ( bLink )
+ {
+ TransferableDataHelper aDataHelper( rxTransferable );
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB ) )
+ {
+ SotStorageStreamRef xStm;
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
+ {
+ Graphic aGraphic;
+ *xStm >> aGraphic;
+ bRet = ApplyGraphicToObject( pHitObj, aGraphic );
+ }
+ }
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_GDIMETAFILE ) )
+ {
+ GDIMetaFile aMtf;
+ if( aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) )
+ bRet = ApplyGraphicToObject( pHitObj, Graphic(aMtf) );
+ }
+ else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) )
+ {
+ Bitmap aBmp;
+ if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
+ bRet = ApplyGraphicToObject( pHitObj, Graphic(aBmp) );
+ }
+ }
+ else
+ {
+ // ham' wa noch nich
+ }
+ return bRet;
+}
+
+BOOL lcl_SelHasAttrib( ScDocument* pDoc, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+ const ScMarkData& rTabSelection, USHORT nMask )
+{
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if ( rTabSelection.GetTableSelect(nTab) && pDoc->HasAttrib( nCol1, nRow1, nTab, nCol2, nRow2, nTab, nMask ) )
+ return TRUE;
+ return FALSE;
+}
+
+//
+// Einfuegen auf Tabelle:
+//
+
+// internes Paste
+
+namespace {
+
+class CursorSwitcher
+{
+public:
+ CursorSwitcher(ScViewFunc* pViewFunc) :
+ mpViewFunc(pViewFunc)
+ {
+ mpViewFunc->HideCursor();
+ }
+
+ ~CursorSwitcher()
+ {
+ mpViewFunc->ShowCursor();
+ }
+private:
+ ScViewFunc* mpViewFunc;
+};
+
+bool lcl_checkDestRangeForOverwrite(const ScRange& rDestRange, const ScDocument* pDoc, const ScMarkData& rMark, Window* pParentWnd)
+{
+ bool bIsEmpty = true;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab < nTabCount && bIsEmpty; ++nTab)
+ {
+ if (!rMark.GetTableSelect(nTab))
+ continue;
+
+ bIsEmpty = pDoc->IsBlockEmpty(nTab, rDestRange.aStart.Col(), rDestRange.aStart.Row(),
+ rDestRange.aEnd.Col(), rDestRange.aEnd.Row());
+ }
+
+ if (!bIsEmpty)
+ {
+ ScReplaceWarnBox aBox(pParentWnd);
+ if (aBox.Execute() != RET_YES)
+ {
+ // changing the configuration is within the ScReplaceWarnBox
+ return false;
+ }
+ }
+ return true;
+}
+
+}
+
+BOOL ScViewFunc::PasteFromClip( USHORT nFlags, ScDocument* pClipDoc,
+ USHORT nFunction, BOOL bSkipEmpty,
+ BOOL bTranspose, BOOL bAsLink,
+ InsCellCmd eMoveMode, USHORT nUndoExtraFlags,
+ BOOL bAllowDialogs )
+{
+ if (!pClipDoc)
+ {
+ DBG_ERROR("PasteFromClip: pClipDoc=0 not allowed");
+ return FALSE;
+ }
+
+ // fuer Undo etc. immer alle oder keine Inhalte sichern
+ USHORT nContFlags = IDF_NONE;
+ if (nFlags & IDF_CONTENTS)
+ nContFlags |= IDF_CONTENTS;
+ if (nFlags & IDF_ATTRIB)
+ nContFlags |= IDF_ATTRIB;
+ // evtl. Attribute ins Undo ohne sie vom Clip ins Doc zu kopieren
+ USHORT nUndoFlags = nContFlags;
+ if (nUndoExtraFlags & IDF_ATTRIB)
+ nUndoFlags |= IDF_ATTRIB;
+ // do not copy note captions into undo document
+ nUndoFlags |= IDF_NOCAPTIONS;
+
+ ScClipParam& rClipParam = pClipDoc->GetClipParam();
+ if (rClipParam.isMultiRange())
+ return PasteMultiRangesFromClip(
+ nFlags, pClipDoc, nFunction, bSkipEmpty, bTranspose, bAsLink, bAllowDialogs,
+ eMoveMode, nContFlags, nUndoFlags);
+
+ BOOL bCutMode = pClipDoc->IsCutMode(); // if transposing, take from original clipdoc
+ BOOL bIncludeFiltered = bCutMode;
+
+ // paste drawing: also if IDF_NOTE is set (to create drawing layer for note captions)
+ BOOL bPasteDraw = ( pClipDoc->GetDrawLayer() && ( nFlags & (IDF_OBJECTS|IDF_NOTE) ) );
+
+ ScDocShellRef aTransShellRef; // for objects in xTransClip - must remain valid as long as xTransClip
+ ScDocument* pOrigClipDoc = NULL;
+ ::std::auto_ptr< ScDocument > xTransClip;
+ if ( bTranspose )
+ {
+ SCCOL nX;
+ SCROW nY;
+ // include filtered rows until TransposeClip can skip them
+ bIncludeFiltered = TRUE;
+ pClipDoc->GetClipArea( nX, nY, TRUE );
+ if ( nY > static_cast<sal_Int32>(MAXCOL) ) // zuviele Zeilen zum Transponieren
+ {
+ ErrorMessage(STR_PASTE_FULL);
+ return FALSE;
+ }
+ pOrigClipDoc = pClipDoc; // fuer Referenzen
+
+ if ( bPasteDraw )
+ {
+ aTransShellRef = new ScDocShell; // DocShell needs a Ref immediately
+ aTransShellRef->DoInitNew(NULL);
+ }
+ ScDrawLayer::SetGlobalDrawPersist(aTransShellRef);
+
+ xTransClip.reset( new ScDocument( SCDOCMODE_CLIP ));
+ pClipDoc->TransposeClip( xTransClip.get(), nFlags, bAsLink );
+ pClipDoc = xTransClip.get();
+
+ ScDrawLayer::SetGlobalDrawPersist(NULL);
+ }
+
+ SCCOL nStartCol;
+ SCROW nStartRow;
+ SCTAB nStartTab;
+ SCCOL nEndCol;
+ SCROW nEndRow;
+ SCTAB nEndTab;
+ SCCOL nClipSizeX;
+ SCROW nClipSizeY;
+ pClipDoc->GetClipArea( nClipSizeX, nClipSizeY, TRUE ); // size in clipboard doc
+
+ // size in target doc: include filtered rows only if CutMode is set
+ SCCOL nDestSizeX;
+ SCROW nDestSizeY;
+ pClipDoc->GetClipArea( nDestSizeX, nDestSizeY, bIncludeFiltered );
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+ const BOOL bRecord(pDoc->IsUndoEnabled());
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScRange aMarkRange;
+ ScMarkData aFilteredMark( rMark); // local copy for all modifications
+ ScMarkType eMarkType = GetViewData()->GetSimpleArea( aMarkRange, aFilteredMark);
+ bool bMarkIsFiltered = (eMarkType == SC_MARK_SIMPLE_FILTERED);
+ bool bNoPaste = ((eMarkType != SC_MARK_SIMPLE && !bMarkIsFiltered) ||
+ (bMarkIsFiltered && (eMoveMode != INS_NONE || bAsLink)));
+ if (!bNoPaste && !rMark.IsMarked())
+ {
+ // Create a selection with clipboard row count and check that for
+ // filtered.
+ nStartCol = GetViewData()->GetCurX();
+ nStartRow = GetViewData()->GetCurY();
+ nStartTab = GetViewData()->GetTabNo();
+ nEndCol = nStartCol + nDestSizeX;
+ nEndRow = nStartRow + nDestSizeY;
+ nEndTab = nStartTab;
+ aMarkRange = ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
+ if (ScViewUtil::HasFiltered( aMarkRange, pDoc))
+ {
+ bMarkIsFiltered = true;
+ // Fit to clipboard's row count unfiltered rows. If there is no
+ // fit assume that pasting is not possible. Note that nDestSizeY is
+ // size-1 (difference).
+ if (!ScViewUtil::FitToUnfilteredRows( aMarkRange, pDoc, nDestSizeY+1))
+ bNoPaste = true;
+ }
+ aFilteredMark.SetMarkArea( aMarkRange);
+ }
+ if (bNoPaste)
+ {
+ ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
+ return FALSE;
+ }
+
+ SCROW nUnfilteredRows = aMarkRange.aEnd.Row() - aMarkRange.aStart.Row() + 1;
+ ScRangeList aRangeList;
+ if (bMarkIsFiltered)
+ {
+ ScViewUtil::UnmarkFiltered( aFilteredMark, pDoc);
+ aFilteredMark.FillRangeListWithMarks( &aRangeList, FALSE);
+ nUnfilteredRows = 0;
+ for (ScRange* p = aRangeList.First(); p; p = aRangeList.Next())
+ {
+ nUnfilteredRows += p->aEnd.Row() - p->aStart.Row() + 1;
+ }
+#if 0
+ /* This isn't needed but could be a desired restriction. */
+ // For filtered, destination rows have to be an exact multiple of
+ // source rows. Note that nDestSizeY is size-1 (difference), so
+ // nDestSizeY==0 fits always.
+ if ((nUnfilteredRows % (nDestSizeY+1)) != 0)
+ {
+ /* FIXME: this should be a more descriptive error message then. */
+ ErrorMessage(STR_MSSG_PASTEFROMCLIP_0);
+ return FALSE;
+ }
+#endif
+ }
+
+ SCCOL nMarkAddX = 0;
+ SCROW nMarkAddY = 0;
+
+ // Also for a filtered selection the area is used, for undo et al.
+ if ( aFilteredMark.IsMarked() || bMarkIsFiltered )
+ {
+ aMarkRange.GetVars( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
+ SCCOL nBlockAddX = nEndCol-nStartCol;
+ SCROW nBlockAddY = nEndRow-nStartRow;
+
+ // #58422# Nachfrage, wenn die Selektion groesser als 1 Zeile/Spalte, aber kleiner
+ // als das Clipboard ist (dann wird ueber die Selektion hinaus eingefuegt)
+
+ // ClipSize is not size, but difference
+ if ( ( nBlockAddX != 0 && nBlockAddX < nDestSizeX ) ||
+ ( nBlockAddY != 0 && nBlockAddY < nDestSizeY ) ||
+ ( bMarkIsFiltered && nUnfilteredRows < nDestSizeY+1 ) )
+ {
+ ScWaitCursorOff aWaitOff( GetFrameWin() );
+ String aMessage = ScGlobal::GetRscString( STR_PASTE_BIGGER );
+ QueryBox aBox( GetViewData()->GetDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_NO), aMessage );
+ if ( aBox.Execute() != RET_YES )
+ {
+ return FALSE;
+ }
+ }
+
+ if (nBlockAddX > nDestSizeX)
+ nMarkAddX = nBlockAddX - nDestSizeX; // fuer Merge-Test
+ else
+ nEndCol = nStartCol + nDestSizeX;
+
+ if (nBlockAddY > nDestSizeY)
+ nMarkAddY = nBlockAddY - nDestSizeY; // fuer Merge-Test
+ else
+ {
+ nEndRow = nStartRow + nDestSizeY;
+ if (bMarkIsFiltered || nEndRow > aMarkRange.aEnd.Row())
+ {
+ // Same as above if nothing was marked: re-fit selection to
+ // unfiltered rows. Extending the selection actually may
+ // introduce filtered rows where there weren't any before, so
+ // we also need to test for that.
+ aMarkRange = ScRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
+ if (bMarkIsFiltered || ScViewUtil::HasFiltered( aMarkRange, pDoc))
+ {
+ bMarkIsFiltered = true;
+ // Worst case: all rows up to the end of the sheet are filtered.
+ if (!ScViewUtil::FitToUnfilteredRows( aMarkRange, pDoc, nDestSizeY+1))
+ {
+ ErrorMessage(STR_PASTE_FULL);
+ return FALSE;
+ }
+ }
+ aMarkRange.GetVars( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab);
+ aFilteredMark.SetMarkArea( aMarkRange);
+ if (bMarkIsFiltered)
+ {
+ ScViewUtil::UnmarkFiltered( aFilteredMark, pDoc);
+ aFilteredMark.FillRangeListWithMarks( &aRangeList, TRUE);
+ }
+ }
+ }
+ }
+ else
+ {
+ nStartCol = GetViewData()->GetCurX();
+ nStartRow = GetViewData()->GetCurY();
+ nStartTab = GetViewData()->GetTabNo();
+ nEndCol = nStartCol + nDestSizeX;
+ nEndRow = nStartRow + nDestSizeY;
+ nEndTab = nStartTab;
+ }
+
+ bool bOffLimits = !ValidCol(nEndCol) || !ValidRow(nEndRow);
+
+ // Zielbereich, wie er angezeigt wird:
+ ScRange aUserRange( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab );
+
+ // Sollen Zellen eingefuegt werden?
+ // (zu grosse nEndCol/nEndRow werden weiter unten erkannt)
+ BOOL bInsertCells = ( eMoveMode != INS_NONE && !bOffLimits );
+ if ( bInsertCells )
+ {
+ // #94115# Instead of EnterListAction, the paste undo action is merged into the
+ // insert action, so Repeat can insert the right cells
+
+ MarkRange( aUserRange ); // wird vor CopyFromClip sowieso gesetzt
+
+ // #72930# CutMode is reset on insertion of cols/rows but needed again on cell move
+ BOOL bCut = pClipDoc->IsCutMode();
+ if (!InsertCells( eMoveMode, bRecord, TRUE )) // is inserting possible?
+ {
+ return FALSE;
+ // #i21036# EnterListAction isn't used, and InsertCells doesn't insert
+ // its undo action on failure, so no undo handling is needed here
+ }
+ if ( bCut )
+ pClipDoc->SetCutMode( bCut );
+ }
+ else if (!bOffLimits)
+ {
+ BOOL bAskIfNotEmpty = bAllowDialogs &&
+ ( nFlags & IDF_CONTENTS ) &&
+ nFunction == PASTE_NOFUNC &&
+ SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
+ if ( bAskIfNotEmpty )
+ {
+ if (!lcl_checkDestRangeForOverwrite(aUserRange, pDoc, aFilteredMark, GetViewData()->GetDialogParent()))
+ return false;
+ }
+ }
+
+ SCCOL nClipStartX; // Clipboard-Bereich erweitern
+ SCROW nClipStartY;
+ pClipDoc->GetClipStart( nClipStartX, nClipStartY );
+ SCCOL nUndoEndCol = nClipStartX + nClipSizeX;
+ SCROW nUndoEndRow = nClipStartY + nClipSizeY; // end of source area in clipboard document
+ BOOL bClipOver = FALSE;
+ // #i68690# ExtendMerge for the clip doc must be called with the clipboard's sheet numbers.
+ // The same end column/row can be used for all calls because the clip doc doesn't contain
+ // content outside the clip area.
+ for (SCTAB nClipTab=0; nClipTab<=MAXTAB; nClipTab++)
+ if ( pClipDoc->HasTable(nClipTab) )
+ if ( pClipDoc->ExtendMerge( nClipStartX,nClipStartY, nUndoEndCol,nUndoEndRow, nClipTab, FALSE ) )
+ bClipOver = TRUE;
+ nUndoEndCol -= nClipStartX + nClipSizeX;
+ nUndoEndRow -= nClipStartY + nClipSizeY; // now contains only the difference added by ExtendMerge
+ nUndoEndCol = sal::static_int_cast<SCCOL>( nUndoEndCol + nEndCol );
+ nUndoEndRow = sal::static_int_cast<SCROW>( nUndoEndRow + nEndRow ); // destination area, expanded for merged cells
+
+// if (nUndoEndCol < nEndCol) nUndoEndCol = nEndCol;
+// if (nUndoEndRow < nEndRow) nUndoEndRow = nEndRow;
+
+// nUndoEndCol += nMarkAddX;
+// nUndoEndRow += nMarkAddY;
+
+ if (nUndoEndCol>MAXCOL || nUndoEndRow>MAXROW)
+ {
+ ErrorMessage(STR_PASTE_FULL);
+ return FALSE;
+ }
+
+ pDoc->ExtendMergeSel( nStartCol,nStartRow, nUndoEndCol,nUndoEndRow, aFilteredMark, FALSE );
+
+ // Test auf Zellschutz
+
+ ScEditableTester aTester( pDoc, nStartTab, nStartCol,nStartRow, nUndoEndCol,nUndoEndRow );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return FALSE;
+ }
+
+ //! Test auf Ueberlappung
+ //! nur wirkliche Schnittmenge testen !!!!!!!
+
+ // pDoc->HasCommonAttr( StartCol,nStartRow, nUndoEndCol,nUndoEndRow, nStartTab,
+ // pClipDoc, nClipStartX, nClipStartY );
+
+ ScDocFunc& rDocFunc = pDocSh->GetDocFunc();
+ if ( bRecord )
+ {
+ String aUndo = ScGlobal::GetRscString( pClipDoc->IsCutMode() ? STR_UNDO_MOVE : STR_UNDO_COPY );
+ pUndoMgr->EnterListAction( aUndo, aUndo );
+ }
+
+ if (bClipOver)
+ if (lcl_SelHasAttrib( pDoc, nStartCol,nStartRow, nUndoEndCol,nUndoEndRow, aFilteredMark, HASATTR_OVERLAPPED ))
+ { // "Cell merge not possible if cells already merged"
+ ScDocAttrIterator aIter( pDoc, nStartTab, nStartCol, nStartRow, nUndoEndCol, nUndoEndRow );
+ const ScPatternAttr* pPattern = NULL;
+ const ScMergeAttr* pMergeFlag = NULL;
+ const ScMergeFlagAttr* pMergeFlagAttr = NULL;
+ SCCOL nCol = -1;
+ SCROW nRow1 = -1;
+ SCROW nRow2 = -1;
+ while ( ( pPattern = aIter.GetNext( nCol, nRow1, nRow2 ) ) != NULL )
+ {
+ pMergeFlag = (const ScMergeAttr*) &pPattern->GetItem(ATTR_MERGE);
+ pMergeFlagAttr = (const ScMergeFlagAttr*) &pPattern->GetItem(ATTR_MERGE_FLAG);
+ if( ( pMergeFlag && pMergeFlag->IsMerged() ) || ( pMergeFlagAttr && pMergeFlagAttr->IsOverlapped() ) )
+ {
+ ScRange aRange(nCol, nRow1, nStartTab);
+ pDoc->ExtendOverlapped(aRange);
+ pDoc->ExtendMerge(aRange, TRUE, TRUE);
+ rDocFunc.UnmergeCells(aRange, bRecord, TRUE);
+ }
+ }
+ }
+
+ if ( !bCutMode )
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut(); // kein CutMode mehr
+ }
+
+ BOOL bColInfo = ( nStartRow==0 && nEndRow==MAXROW );
+ BOOL bRowInfo = ( nStartCol==0 && nEndCol==MAXCOL );
+
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRefUndoDoc = NULL;
+ ScDocument* pRedoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndoSelected( pDoc, aFilteredMark, bColInfo, bRowInfo );
+
+ // all sheets - CopyToDocument skips those that don't exist in pUndoDoc
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pDoc->CopyToDocument( nStartCol, nStartRow, 0, nUndoEndCol, nUndoEndRow, nTabCount-1,
+ nUndoFlags, FALSE, pUndoDoc );
+
+ if ( bCutMode )
+ {
+ pRefUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRefUndoDoc->InitUndo( pDoc, 0, nTabCount-1, FALSE, FALSE );
+
+ pUndoData = new ScRefUndoData( pDoc );
+ }
+ }
+
+ USHORT nExtFlags = 0;
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab ); // content before the change
+
+ if (GetViewData()->IsActive())
+ {
+ DoneBlockMode();
+ InitOwnBlockMode();
+ }
+ rMark.SetMarkArea( aUserRange );
+ MarkDataChanged();
+
+ HideCursor(); // Cursor aendert sich !
+
+ //
+ // Aus Clipboard kopieren,
+ // wenn gerechnet werden soll, Originaldaten merken
+ //
+
+ ScDocument* pMixDoc = NULL;
+ if ( bSkipEmpty || nFunction )
+ {
+ if ( nFlags & IDF_CONTENTS )
+ {
+ pMixDoc = new ScDocument( SCDOCMODE_UNDO );
+ pMixDoc->InitUndo( pDoc, nStartTab, nEndTab );
+ pDoc->CopyToDocument( nStartCol, nStartRow, nStartTab, nEndCol, nEndRow, nEndTab,
+ IDF_CONTENTS, FALSE, pMixDoc );
+ }
+ }
+
+ /* Make draw layer and start drawing undo.
+ - Needed before AdjustBlockHeight to track moved drawing objects.
+ - Needed before pDoc->CopyFromClip to track inserted note caption objects.
+ */
+ if ( bPasteDraw )
+ pDocSh->MakeDrawLayer();
+ if ( bRecord )
+ pDoc->BeginDrawUndo();
+
+ USHORT nNoObjFlags = nFlags & ~IDF_OBJECTS;
+ if (!bAsLink)
+ {
+ // copy normally (original range)
+ pDoc->CopyFromClip( aUserRange, aFilteredMark, nNoObjFlags,
+ pRefUndoDoc, pClipDoc, TRUE, FALSE, bIncludeFiltered,
+ bSkipEmpty, (bMarkIsFiltered ? &aRangeList : NULL) );
+
+ // bei Transpose Referenzen per Hand anpassen
+ if ( bTranspose && bCutMode && (nFlags & IDF_CONTENTS) )
+ pDoc->UpdateTranspose( aUserRange.aStart, pOrigClipDoc, aFilteredMark, pRefUndoDoc );
+ }
+ else if (!bTranspose)
+ {
+ // copy with bAsLink=TRUE
+ pDoc->CopyFromClip( aUserRange, aFilteredMark, nNoObjFlags, pRefUndoDoc, pClipDoc,
+ TRUE, TRUE, bIncludeFiltered, bSkipEmpty );
+ }
+ else
+ {
+ // alle Inhalte kopieren (im TransClipDoc stehen nur Formeln)
+ pDoc->CopyFromClip( aUserRange, aFilteredMark, nContFlags, pRefUndoDoc, pClipDoc );
+ }
+
+ // skipped rows and merged cells don't mix
+ if ( !bIncludeFiltered && pClipDoc->HasClipFilteredRows() )
+ rDocFunc.UnmergeCells( aUserRange, FALSE, TRUE );
+
+ pDoc->ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, aFilteredMark, TRUE ); // Refresh
+ // und Bereich neu
+
+ if ( pMixDoc ) // Rechenfunktionen mit Original-Daten auszufuehren ?
+ {
+ pDoc->MixDocument( aUserRange, nFunction, bSkipEmpty, pMixDoc );
+ }
+ delete pMixDoc;
+
+ AdjustBlockHeight(); // update row heights before pasting objects
+
+ if ( nFlags & IDF_OBJECTS )
+ {
+ // Paste the drawing objects after the row heights have been updated.
+
+ pDoc->CopyFromClip( aUserRange, aFilteredMark, IDF_OBJECTS, pRefUndoDoc, pClipDoc,
+ TRUE, FALSE, bIncludeFiltered );
+ }
+
+ //
+ //
+ //
+
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab ); // content after the change
+
+
+ // ggf. Autofilter-Koepfe loeschen
+ if (bCutMode)
+ if (pDoc->RefreshAutoFilter( nClipStartX,nClipStartY, nClipStartX+nClipSizeX,
+ nClipStartY+nClipSizeY, nStartTab ))
+ pDocSh->PostPaint( nClipStartX,nClipStartY,nStartTab,
+ nClipStartX+nClipSizeX,nClipStartY,nStartTab,
+ PAINT_GRID );
+
+ ShowCursor(); // Cursor aendert sich !
+
+ //! Block-Bereich bei RefUndoDoc weglassen !!!
+
+ if ( bRecord )
+ {
+ // Redo-Daten werden erst beim ersten Undo kopiert
+ // ohne RefUndoDoc muss das Redo-Doc noch nicht angelegt werden
+
+ if (pRefUndoDoc)
+ {
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, nStartTab, nEndTab, bColInfo, bRowInfo );
+
+ // angepasste Referenzen ins Redo-Doc
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pRedoDoc->AddUndoTab( 0, nTabCount-1 );
+ pDoc->CopyUpdated( pRefUndoDoc, pRedoDoc );
+
+ // alte Referenzen ins Undo-Doc
+
+ //! Tabellen selektieren ?
+ pUndoDoc->AddUndoTab( 0, nTabCount-1 );
+ pRefUndoDoc->DeleteArea( nStartCol, nStartRow, nEndCol, nEndRow, aFilteredMark, IDF_ALL );
+ pRefUndoDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,nTabCount-1,
+ IDF_FORMULA, FALSE, pUndoDoc );
+ delete pRefUndoDoc;
+ }
+
+ // DeleteUnchanged for pUndoData is in ScUndoPaste ctor,
+ // UndoData for redo is made during first undo
+
+ ScUndoPasteOptions aOptions; // store options for repeat
+ aOptions.nFunction = nFunction;
+ aOptions.bSkipEmpty = bSkipEmpty;
+ aOptions.bTranspose = bTranspose;
+ aOptions.bAsLink = bAsLink;
+ aOptions.eMoveMode = eMoveMode;
+
+ SfxUndoAction* pUndo = new ScUndoPaste( pDocSh,
+ nStartCol, nStartRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, aFilteredMark,
+ pUndoDoc, pRedoDoc, nFlags | nUndoFlags,
+ pUndoData, NULL, NULL, NULL,
+ FALSE, &aOptions ); // FALSE = Redo data not yet copied
+
+ if ( bInsertCells )
+ {
+ // Merge the paste undo action into the insert action.
+ // Use ScUndoWrapper so the ScUndoPaste pointer can be stored in the insert action.
+
+ pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), TRUE );
+ }
+ else
+ pUndoMgr->AddUndoAction( pUndo );
+ pUndoMgr->LeaveListAction();
+ }
+
+ USHORT nPaint = PAINT_GRID;
+ if (bColInfo)
+ {
+ nPaint |= PAINT_TOP;
+ nUndoEndCol = MAXCOL; // nur zum Zeichnen !
+ }
+ if (bRowInfo)
+ {
+ nPaint |= PAINT_LEFT;
+ nUndoEndRow = MAXROW; // nur zum Zeichnen !
+ }
+ pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, nPaint, nExtFlags );
+ // AdjustBlockHeight has already been called above
+
+ aModificator.SetDocumentModified();
+ PostPasteFromClip(aUserRange, rMark);
+ return TRUE;
+}
+
+bool ScViewFunc::PasteMultiRangesFromClip(
+ sal_uInt16 nFlags, ScDocument* pClipDoc, sal_uInt16 nFunction,
+ bool bSkipEmpty, bool bTranspose, bool bAsLink, bool bAllowDialogs,
+ InsCellCmd eMoveMode, sal_uInt16 /*nContFlags*/, sal_uInt16 nUndoFlags)
+{
+ ScViewData& rViewData = *GetViewData();
+ ScDocument* pDoc = rViewData.GetDocument();
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ ScMarkData aMark(rViewData.GetMarkData());
+ const ScAddress& rCurPos = rViewData.GetCurPos();
+ ScClipParam& rClipParam = pClipDoc->GetClipParam();
+ SCCOL nColSize = rClipParam.getPasteColSize();
+ SCROW nRowSize = rClipParam.getPasteRowSize();
+
+ if (bTranspose)
+ {
+ if (static_cast<SCROW>(rCurPos.Col()) + nRowSize-1 > static_cast<SCROW>(MAXCOL))
+ {
+ ErrorMessage(STR_PASTE_FULL);
+ return false;
+ }
+
+ ::std::auto_ptr<ScDocument> pTransClip(new ScDocument(SCDOCMODE_CLIP));
+ pClipDoc->TransposeClip(pTransClip.get(), nFlags, bAsLink);
+ pClipDoc = pTransClip.release();
+ SCCOL nTempColSize = nColSize;
+ nColSize = static_cast<SCCOL>(nRowSize);
+ nRowSize = static_cast<SCROW>(nTempColSize);
+ }
+
+ if (!ValidCol(rCurPos.Col()+nColSize-1) || !ValidRow(rCurPos.Row()+nRowSize-1))
+ {
+ ErrorMessage(STR_PASTE_FULL);
+ return false;
+ }
+
+ // Determine the first and last selected sheet numbers.
+ SCTAB nTab1 = aMark.GetFirstSelected();
+ SCTAB nTab2 = nTab1;
+ for (SCTAB i = nTab1+1; i <= MAXTAB; ++i)
+ if (aMark.GetTableSelect(i))
+ nTab2 = i;
+
+ ScDocShellModificator aModificator(*pDocSh);
+
+ // For multi-selection paste, we don't support cell duplication for larger
+ // destination range. In case the destination is marked, we reset it to
+ // the clip size.
+ ScRange aMarkedRange(rCurPos.Col(), rCurPos.Row(), nTab1,
+ rCurPos.Col()+nColSize-1, rCurPos.Row()+nRowSize-1, nTab2);
+
+ // Extend the marked range to account for filtered rows in the destination
+ // area.
+ if (ScViewUtil::HasFiltered(aMarkedRange, pDoc))
+ {
+ if (!ScViewUtil::FitToUnfilteredRows(aMarkedRange, pDoc, nRowSize))
+ return false;
+ }
+
+ bool bAskIfNotEmpty =
+ bAllowDialogs && (nFlags & IDF_CONTENTS) &&
+ nFunction == PASTE_NOFUNC && SC_MOD()->GetInputOptions().GetReplaceCellsWarn();
+
+ if (bAskIfNotEmpty)
+ {
+ if (!lcl_checkDestRangeForOverwrite(aMarkedRange, pDoc, aMark, rViewData.GetDialogParent()))
+ return false;
+ }
+
+ aMark.SetMarkArea(aMarkedRange);
+ MarkRange(aMarkedRange);
+
+ bool bInsertCells = (eMoveMode != INS_NONE);
+ if (bInsertCells)
+ {
+ if (!InsertCells(eMoveMode, pDoc->IsUndoEnabled(), true))
+ return false;
+ }
+
+ ::std::auto_ptr<ScDocument> pUndoDoc;
+ if (pDoc->IsUndoEnabled())
+ {
+ pUndoDoc.reset(new ScDocument(SCDOCMODE_UNDO));
+ pUndoDoc->InitUndoSelected(pDoc, aMark, false, false);
+ pDoc->CopyToDocument(aMarkedRange, nUndoFlags, false, pUndoDoc.get(), &aMark, true);
+ }
+
+ ::std::auto_ptr<ScDocument> pMixDoc;
+ if ( bSkipEmpty || nFunction )
+ {
+ if ( nFlags & IDF_CONTENTS )
+ {
+ pMixDoc.reset(new ScDocument(SCDOCMODE_UNDO));
+ pMixDoc->InitUndoSelected(pDoc, aMark, false, false);
+ pDoc->CopyToDocument(aMarkedRange, IDF_CONTENTS, false, pMixDoc.get(), &aMark, true);
+ }
+ }
+
+ /* Make draw layer and start drawing undo.
+ - Needed before AdjustBlockHeight to track moved drawing objects.
+ - Needed before pDoc->CopyFromClip to track inserted note caption objects.
+ */
+ if (nFlags & IDF_OBJECTS)
+ pDocSh->MakeDrawLayer();
+ if (pDoc->IsUndoEnabled())
+ pDoc->BeginDrawUndo();
+
+ CursorSwitcher aCursorSwitch(this);
+ sal_uInt16 nNoObjFlags = nFlags & ~IDF_OBJECTS;
+ pDoc->CopyMultiRangeFromClip(rCurPos, aMark, nNoObjFlags, pClipDoc,
+ true, bAsLink, false, bSkipEmpty);
+
+ if (pMixDoc.get())
+ pDoc->MixDocument(aMarkedRange, nFunction, bSkipEmpty, pMixDoc.get());
+
+ AdjustBlockHeight(); // update row heights before pasting objects
+
+ if (nFlags & IDF_OBJECTS)
+ {
+ // Paste the drawing objects after the row heights have been updated.
+ pDoc->CopyMultiRangeFromClip(rCurPos, aMark, IDF_OBJECTS, pClipDoc,
+ true, false, false, true);
+ }
+
+ pDocSh->PostPaint(
+ aMarkedRange.aStart.Col(), aMarkedRange.aStart.Row(), nTab1,
+ aMarkedRange.aEnd.Col(), aMarkedRange.aEnd.Row(), nTab1, PAINT_GRID);
+
+ if (pDoc->IsUndoEnabled())
+ {
+ SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+ String aUndo = ScGlobal::GetRscString(
+ pClipDoc->IsCutMode() ? STR_UNDO_CUT : STR_UNDO_COPY);
+ pUndoMgr->EnterListAction(aUndo, aUndo);
+
+ ScUndoPasteOptions aOptions; // store options for repeat
+ aOptions.nFunction = nFunction;
+ aOptions.bSkipEmpty = bSkipEmpty;
+ aOptions.bTranspose = bTranspose;
+ aOptions.bAsLink = bAsLink;
+ aOptions.eMoveMode = eMoveMode;
+
+ ScUndoPaste* pUndo = new ScUndoPaste(pDocSh,
+ aMarkedRange.aStart.Col(),
+ aMarkedRange.aStart.Row(),
+ aMarkedRange.aStart.Tab(),
+ aMarkedRange.aEnd.Col(),
+ aMarkedRange.aEnd.Row(),
+ aMarkedRange.aEnd.Tab(),
+ aMark, pUndoDoc.release(), NULL, nFlags|nUndoFlags, NULL, NULL, NULL, NULL, false, &aOptions);
+
+ if (bInsertCells)
+ pUndoMgr->AddUndoAction(new ScUndoWrapper(pUndo), true);
+ else
+ pUndoMgr->AddUndoAction(pUndo, false);
+
+ pUndoMgr->LeaveListAction();
+ }
+ aModificator.SetDocumentModified();
+ PostPasteFromClip(aMarkedRange, aMark);
+ return true;
+}
+
+void ScViewFunc::PostPasteFromClip(const ScRange& rPasteRange, const ScMarkData& rMark)
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pViewData->GetDocument();
+ pDocSh->UpdateOle(pViewData);
+
+ SelectionChanged();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for ( SCTAB i = 0; i < nTabCount; ++i )
+ {
+ if ( rMark.GetTableSelect( i ) )
+ {
+ ScRange aChangeRange(rPasteRange);
+ aChangeRange.aStart.SetTab( i );
+ aChangeRange.aEnd.SetTab( i );
+ aChangeRanges.Append( aChangeRange );
+ }
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// D R A G A N D D R O P
+//
+// innerhalb des Dokuments
+
+BOOL ScViewFunc::MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
+ BOOL bCut, BOOL bRecord, BOOL bPaint, BOOL bApi )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ HideAllCursors(); // wegen zusammengefassten
+
+ BOOL bSuccess = TRUE;
+ SCTAB nDestTab = rDestPos.Tab();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( rSource.aStart.Tab() == nDestTab && rSource.aEnd.Tab() == nDestTab && rMark.GetSelectCount() > 1 )
+ {
+ // moving within one table and several tables selected -> apply to all selected tables
+
+ if ( bRecord )
+ {
+ String aUndo = ScGlobal::GetRscString( bCut ? STR_UNDO_MOVE : STR_UNDO_COPY );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ }
+
+ // collect ranges of consecutive selected tables
+
+ ScRange aLocalSource = rSource;
+ ScAddress aLocalDest = rDestPos;
+ SCTAB nTabCount = pDocSh->GetDocument()->GetTableCount();
+ SCTAB nStartTab = 0;
+ while ( nStartTab < nTabCount && bSuccess )
+ {
+ while ( nStartTab < nTabCount && !rMark.GetTableSelect(nStartTab) )
+ ++nStartTab;
+ if ( nStartTab < nTabCount )
+ {
+ SCTAB nEndTab = nStartTab;
+ while ( nEndTab+1 < nTabCount && rMark.GetTableSelect(nEndTab+1) )
+ ++nEndTab;
+
+ aLocalSource.aStart.SetTab( nStartTab );
+ aLocalSource.aEnd.SetTab( nEndTab );
+ aLocalDest.SetTab( nStartTab );
+
+ bSuccess = pDocSh->GetDocFunc().MoveBlock(
+ aLocalSource, aLocalDest, bCut, bRecord, bPaint, bApi );
+
+ nStartTab = nEndTab + 1;
+ }
+ }
+
+ if ( bRecord )
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+ else
+ {
+ // move the block as specified
+ bSuccess = pDocSh->GetDocFunc().MoveBlock(
+ rSource, rDestPos, bCut, bRecord, bPaint, bApi );
+ }
+
+ ShowAllCursors();
+ if (bSuccess)
+ {
+ // Zielbereich markieren
+ ScAddress aDestEnd(
+ rDestPos.Col() + rSource.aEnd.Col() - rSource.aStart.Col(),
+ rDestPos.Row() + rSource.aEnd.Row() - rSource.aStart.Row(),
+ nDestTab );
+
+ BOOL bIncludeFiltered = bCut;
+ if ( !bIncludeFiltered )
+ {
+ // find number of non-filtered rows
+ SCROW nPastedCount = pDocSh->GetDocument()->CountNonFilteredRows(
+ rSource.aStart.Row(), rSource.aEnd.Row(), rSource.aStart.Tab());
+
+ if ( nPastedCount == 0 )
+ nPastedCount = 1;
+ aDestEnd.SetRow( rDestPos.Row() + nPastedCount - 1 );
+ }
+
+ MarkRange( ScRange( rDestPos, aDestEnd ), FALSE ); //! FALSE ???
+
+ pDocSh->UpdateOle(GetViewData());
+ SelectionChanged();
+ }
+ return bSuccess;
+}
+
+// Link innerhalb des Dokuments
+
+BOOL ScViewFunc::LinkBlock( const ScRange& rSource, const ScAddress& rDestPos, BOOL bApi )
+{
+ // Test auf Ueberlappung
+
+ if ( rSource.aStart.Tab() == rDestPos.Tab() )
+ {
+ SCCOL nDestEndCol = rDestPos.Col() + ( rSource.aEnd.Col() - rSource.aStart.Col() );
+ SCROW nDestEndRow = rDestPos.Row() + ( rSource.aEnd.Row() - rSource.aStart.Row() );
+
+ if ( rSource.aStart.Col() <= nDestEndCol && rDestPos.Col() <= rSource.aEnd.Col() &&
+ rSource.aStart.Row() <= nDestEndRow && rDestPos.Row() <= rSource.aEnd.Row() )
+ {
+ if (!bApi)
+ ErrorMessage( STR_ERR_LINKOVERLAP );
+ return FALSE;
+ }
+ }
+
+ // Ausfuehren per Paste
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+ pDoc->CopyTabToClip( rSource.aStart.Col(), rSource.aStart.Row(),
+ rSource.aEnd.Col(), rSource.aEnd.Row(),
+ rSource.aStart.Tab(), pClipDoc );
+
+ // Zielbereich markieren (Cursor setzen, keine Markierung)
+
+ if ( GetViewData()->GetTabNo() != rDestPos.Tab() )
+ SetTabNo( rDestPos.Tab() );
+
+ MoveCursorAbs( rDestPos.Col(), rDestPos.Row(), SC_FOLLOW_NONE, FALSE, FALSE );
+
+ // Paste
+
+ PasteFromClip( IDF_ALL, pClipDoc, PASTE_NOFUNC, FALSE, FALSE, TRUE ); // als Link
+
+ delete pClipDoc;
+
+ return TRUE;
+}
+
+void ScViewFunc::DataFormPutData( SCROW nCurrentRow ,
+ SCROW nStartRow , SCCOL nStartCol ,
+ SCROW nEndRow , SCCOL nEndCol ,
+ Edit** pEdits ,
+ sal_uInt16 aColLength )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocShellModificator aModificator( *pDocSh );
+ SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+ if ( pDoc )
+ {
+ const BOOL bRecord( pDoc->IsUndoEnabled());
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRedoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ SCTAB nTab = GetViewData()->GetTabNo();
+ SCTAB nStartTab = nTab;
+ SCTAB nEndTab = nTab;
+
+ {
+ ScChangeTrack* pChangeTrack = pDoc->GetChangeTrack();
+ if ( pChangeTrack )
+ pChangeTrack->ResetLastCut(); // kein CutMode mehr
+ }
+ ScRange aUserRange( nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab );
+ BOOL bColInfo = ( nStartRow==0 && nEndRow==MAXROW );
+ BOOL bRowInfo = ( nStartCol==0 && nEndCol==MAXCOL );
+ SCCOL nUndoEndCol = nStartCol+aColLength-1;
+ SCROW nUndoEndRow = nCurrentRow;
+ USHORT nUndoFlags = IDF_NONE;
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndoSelected( pDoc , rMark , bColInfo , bRowInfo );
+ pDoc->CopyToDocument( aUserRange , 1 , FALSE , pUndoDoc );
+ }
+ USHORT nExtFlags = 0;
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nStartRow, nStartTab , nEndCol, nEndRow, nEndTab ); // content before the change
+ //rMark.SetMarkArea( aUserRange );
+ pDoc->BeginDrawUndo();
+
+ for(sal_uInt16 i = 0; i < aColLength; i++)
+ {
+ if (pEdits[i])
+ {
+ String aFieldName=pEdits[i]->GetText();
+ pDoc->SetString( nStartCol + i, nCurrentRow, nTab, aFieldName );
+ }
+ }
+ //pDoc->ExtendMergeSel( nStartCol, nStartRow, nEndCol, nEndRow, rMark, TRUE ); // Refresh
+ pDocSh->UpdatePaintExt( nExtFlags, nStartCol, nCurrentRow, nStartTab, nEndCol, nCurrentRow, nEndTab ); // content after the change
+ SfxUndoAction* pUndo = new ScUndoDataForm( pDocSh,
+ nStartCol, nCurrentRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, rMark,
+ pUndoDoc, pRedoDoc, nUndoFlags,
+ pUndoData, NULL, NULL, NULL,
+ FALSE ); // FALSE = Redo data not yet copied
+ pUndoMgr->AddUndoAction( new ScUndoWrapper( pUndo ), TRUE );
+
+ USHORT nPaint = PAINT_GRID;
+ if (bColInfo)
+ {
+ nPaint |= PAINT_TOP;
+ nUndoEndCol = MAXCOL; // nur zum Zeichnen !
+ }
+ if (bRowInfo)
+ {
+ nPaint |= PAINT_LEFT;
+ nUndoEndRow = MAXROW; // nur zum Zeichnen !
+ }
+
+ pDocSh->PostPaint( nStartCol, nCurrentRow, nStartTab,
+ nUndoEndCol, nUndoEndRow, nEndTab, nPaint, nExtFlags );
+ pDocSh->UpdateOle(GetViewData());
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
new file mode 100644
index 000000000000..58ca33611584
--- /dev/null
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -0,0 +1,830 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <editeng/editobj.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/hlnkitem.hxx>
+#include <editeng/langitem.hxx>
+#include <svx/svxerr.hxx>
+#include <editeng/unolingu.hxx>
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <svtools/langtab.hxx>
+#include <svtools/filter.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/transfer.hxx>
+#include <svl/urlbmk.hxx>
+#include <vcl/msgbox.hxx>
+#include <avmedia/mediawindow.hxx>
+
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include "viewfunc.hxx"
+#include "docsh.hxx"
+#include "docsh.hxx"
+#include "document.hxx"
+#include "docpool.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "undoblk.hxx"
+#include "undocell.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "spelleng.hxx"
+#include "patattr.hxx"
+#include "sc.hrc"
+#include "tabvwsh.hxx"
+#include "impex.hxx"
+#include "editutil.hxx"
+#include "editable.hxx"
+#include "dociter.hxx"
+#include "reffind.hxx"
+#include "compiler.hxx"
+
+using namespace com::sun::star;
+
+// STATIC DATA -----------------------------------------------------------
+
+BOOL bPasteIsDrop = FALSE;
+
+//==================================================================
+
+void ScViewFunc::PasteRTF( SCCOL nStartCol, SCROW nStartRow,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable )
+{
+ TransferableDataHelper aDataHelper( rxTransferable );
+ if ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_EDITENGINE ) )
+ {
+ HideAllCursors();
+
+ ScDocument* pUndoDoc = NULL;
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ const BOOL bRecord (pDoc->IsUndoEnabled());
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nStartCol, nStartRow, nTab );
+ ScTabEditEngine* pEngine = new ScTabEditEngine( *pPattern, pDoc->GetEnginePool() );
+ pEngine->EnableUndo( FALSE );
+
+ Window* pActWin = GetActiveWin();
+ if (pActWin)
+ {
+ pEngine->SetPaperSize(Size(100000,100000));
+ Window aWin( pActWin );
+ EditView aEditView( pEngine, &aWin );
+ aEditView.SetOutputArea(Rectangle(0,0,100000,100000));
+
+ // same method now for clipboard or drag&drop
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ aEditView.InsertText( rxTransferable, String(), TRUE );
+ }
+
+ ULONG nParCnt = pEngine->GetParagraphCount();
+ if (nParCnt)
+ {
+ SCROW nEndRow = nStartRow + static_cast<SCROW>(nParCnt) - 1;
+ if (nEndRow > MAXROW)
+ nEndRow = MAXROW;
+
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, IDF_ALL, FALSE, pUndoDoc );
+ }
+
+ SCROW nRow = nStartRow;
+ for( USHORT n = 0; n < nParCnt; n++ )
+ {
+ EditTextObject* pObject = pEngine->CreateTextObject( n );
+ EnterData( nStartCol, nRow, nTab, pObject, FALSE, TRUE );
+ // kein Undo, auf einfache Strings testen
+ delete pObject;
+ if( ++nRow > MAXROW )
+ break;
+ }
+
+ if (bRecord)
+ {
+ ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, nTab, nTab );
+ pDoc->CopyToDocument( nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab, IDF_ALL|IDF_NOCAPTIONS, FALSE, pRedoDoc );
+
+ ScMarkData aDestMark;
+ aDestMark.SelectOneTable( nTab );
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoPaste( pDocSh, nStartCol,nStartRow,nTab, nStartCol,nEndRow,nTab,
+ aDestMark,
+ pUndoDoc, pRedoDoc, IDF_ALL, NULL,NULL,NULL,NULL ) );
+ }
+ }
+
+ delete pEngine;
+
+ ShowAllCursors();
+ }
+ else
+ {
+ HideAllCursors();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScImportExport aImpEx( pDocSh->GetDocument(),
+ ScAddress( nStartCol, nStartRow, GetViewData()->GetTabNo() ) );
+
+ ::rtl::OUString aStr;
+ SotStorageStreamRef xStream;
+ if ( aDataHelper.GetSotStorageStream( SOT_FORMAT_RTF, xStream ) && xStream.Is() )
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ aImpEx.ImportStream( *xStream, String(), SOT_FORMAT_RTF );
+ else if ( aDataHelper.GetString( SOT_FORMAT_RTF, aStr ) )
+ aImpEx.ImportString( aStr, SOT_FORMAT_RTF );
+
+ AdjustRowHeight( nStartRow, aImpEx.GetRange().aEnd.Row() );
+ pDocSh->UpdateOle(GetViewData());
+ ShowAllCursors();
+ }
+}
+void ScViewFunc::DoRefConversion( BOOL bRecord )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScRange aMarkRange;
+ rMark.MarkToSimple();
+ BOOL bMulti = rMark.IsMultiMarked();
+ if (bMulti)
+ rMark.GetMultiMarkArea( aMarkRange );
+ else if (rMark.IsMarked())
+ rMark.GetMarkArea( aMarkRange );
+ else
+ {
+ aMarkRange = ScRange( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ }
+ ScEditableTester aTester( pDoc, aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),rMark );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ return;
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bOk = FALSE;
+
+ ScDocument* pUndoDoc = NULL;
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nTab = aMarkRange.aStart.Tab();
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if ( rMark.GetSelectCount() > 1 )
+ {
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( rMark.GetTableSelect(i) && i != nTab )
+ pUndoDoc->AddUndoTab( i, i );
+ }
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ALL, bMulti, pUndoDoc, &rMark );
+ }
+
+ ScRangeListRef xRanges;
+ GetViewData()->GetMultiArea( xRanges );
+ ULONG nCount = xRanges->Count();
+
+ for (SCTAB i=0; i<nTabCount; i++)
+ {
+ if (rMark.GetTableSelect(i))
+ {
+ for (ULONG j=0; j<nCount; j++)
+ {
+ ScRange aRange = *xRanges->GetObject(j);
+ aRange.aStart.SetTab(i);
+ aRange.aEnd.SetTab(i);
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while ( pCell )
+ {
+ if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ {
+ String aOld;
+ ((ScFormulaCell*)pCell)->GetFormula(aOld);
+ xub_StrLen nLen = aOld.Len();
+ ScRefFinder aFinder( aOld, pDoc );
+ aFinder.ToggleRel( 0, nLen );
+ if (aFinder.GetFound())
+ {
+ ScAddress aPos = ((ScFormulaCell*)pCell)->aPos;
+ String aNew = aFinder.GetText();
+ ScCompiler aComp( pDoc, aPos);
+ aComp.SetGrammar(pDoc->GetGrammar());
+ ScTokenArray* pArr = aComp.CompileString( aNew );
+ ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos,
+ pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
+ pDoc->PutCell( aPos, pNewCell );
+ bOk = TRUE;
+ }
+ }
+ pCell = aIter.GetNext();
+ }
+ }
+ }
+ }
+ if (bRecord)
+ {
+ ScDocument* pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nTab = aMarkRange.aStart.Tab();
+ pRedoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if ( rMark.GetSelectCount() > 1 )
+ {
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( rMark.GetTableSelect(i) && i != nTab )
+ pRedoDoc->AddUndoTab( i, i );
+ }
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ALL, bMulti, pRedoDoc, &rMark );
+
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoRefConversion( pDocSh,
+ aMarkRange, rMark, pUndoDoc, pRedoDoc, bMulti, IDF_ALL) );
+ }
+
+ pDocSh->PostPaint( aMarkRange, PAINT_GRID );
+ pDocSh->UpdateOle(GetViewData());
+ pDocSh->SetDocumentModified();
+ CellContentChanged();
+
+ if (!bOk)
+ ErrorMessage(STR_ERR_NOREF);
+}
+// Thesaurus - Undo ok
+void ScViewFunc::DoThesaurus( BOOL bRecord )
+{
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScSplitPos eWhich = GetViewData()->GetActivePart();
+ CellType eCellType;
+ EESpellState eState;
+ String sOldText, sNewString;
+ EditTextObject* pOldTObj = NULL;
+ const EditTextObject* pTObject = NULL;
+ ScBaseCell* pCell = NULL;
+ EditView* pEditView = NULL;
+ ESelection* pEditSel = NULL;
+ ScEditEngineDefaulter* pThesaurusEngine;
+ BOOL bIsEditMode = GetViewData()->HasEditView(eWhich);
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ if (bIsEditMode) // Edit-Mode aktiv
+ {
+ GetViewData()->GetEditView(eWhich, pEditView, nCol, nRow);
+ pEditSel = new ESelection(pEditView->GetSelection());
+ SC_MOD()->InputEnterHandler();
+ GetViewData()->GetBindings().Update(); // sonst kommt der Sfx durcheinander...
+ }
+ else
+ {
+ nCol = GetViewData()->GetCurX();
+ nRow = GetViewData()->GetCurY();
+ }
+ nTab = GetViewData()->GetTabNo();
+
+ ScEditableTester aTester( pDoc, nCol, nRow, nCol, nRow, rMark );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ delete pEditSel;
+ return;
+ }
+ pDoc->GetCellType(nCol, nRow, nTab, eCellType);
+ if (eCellType != CELLTYPE_STRING && eCellType != CELLTYPE_EDIT)
+ {
+ ErrorMessage(STR_THESAURUS_NO_STRING);
+ return;
+ }
+
+ com::sun::star::uno::Reference<com::sun::star::linguistic2::XSpellChecker1>
+ xSpeller = LinguMgr::GetSpellChecker();
+ //! if (...) // thesaurus not available
+ //! {
+ //! ErrorMessage(STR_EXPORT_ASCII_WARNING);
+ //! delete pEditSel;
+ //! return;
+ //! }
+
+ pThesaurusEngine = new ScEditEngineDefaulter( pDoc->GetEnginePool() );
+ pThesaurusEngine->SetEditTextObjectPool( pDoc->GetEditPool() );
+ pThesaurusEngine->SetRefDevice(GetViewData()->GetActiveWin());
+ pThesaurusEngine->SetSpeller(xSpeller);
+ MakeEditView(pThesaurusEngine, nCol, nRow );
+ const ScPatternAttr* pPattern = NULL;
+ SfxItemSet* pEditDefaults = new SfxItemSet(pThesaurusEngine->GetEmptyItemSet());
+ pPattern = pDoc->GetPattern(nCol, nRow, nTab);
+ if (pPattern )
+ {
+ pPattern->FillEditItemSet( pEditDefaults );
+ pThesaurusEngine->SetDefaults( *pEditDefaults );
+ }
+
+ if (eCellType == CELLTYPE_STRING)
+ {
+ pDoc->GetString(nCol, nRow, nTab, sOldText);
+ pThesaurusEngine->SetText(sOldText);
+ }
+ else if (eCellType == CELLTYPE_EDIT)
+ {
+ pDoc->GetCell(nCol, nRow, nTab, pCell);
+ if (pCell)
+ {
+ ((ScEditCell*) pCell)->GetData(pTObject);
+ pOldTObj = pTObject->Clone();
+ if (pTObject)
+ pThesaurusEngine->SetText(*pTObject);
+ }
+ }
+ else
+ {
+ DBG_ERROR("DoThesaurus: Keine String oder Editzelle");
+ }
+ pEditView = GetViewData()->GetEditView(GetViewData()->GetActivePart());;
+ if (pEditSel)
+ pEditView->SetSelection(*pEditSel);
+ else
+ pEditView->SetSelection(ESelection(0,0,0,0));
+
+ pThesaurusEngine->ClearModifyFlag();
+
+ // language is now in EditEngine attributes -> no longer passed to StartThesaurus
+
+ eState = pEditView->StartThesaurus();
+ DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
+
+ if (eState == EE_SPELL_ERRORFOUND) // sollte spaeter durch Wrapper geschehen!
+ {
+ LanguageType eLnge = ScViewUtil::GetEffLanguage( pDoc, ScAddress( nCol, nRow, nTab ) );
+ SvtLanguageTable aLangTab;
+ String aErr = aLangTab.GetString(eLnge);
+ aErr += ScGlobal::GetRscString( STR_SPELLING_NO_LANG );
+ InfoBox aBox( GetViewData()->GetDialogParent(), aErr );
+ aBox.Execute();
+ }
+ if (pThesaurusEngine->IsModified())
+ {
+ EditTextObject* pNewTObj = NULL;
+ if (pCell && pTObject)
+ {
+ pNewTObj = pThesaurusEngine->CreateTextObject();
+ pCell = new ScEditCell( pNewTObj, pDoc,
+ pThesaurusEngine->GetEditTextObjectPool() );
+ pDoc->PutCell( nCol, nRow, nTab, pCell );
+ }
+ else
+ {
+ sNewString = pThesaurusEngine->GetText();
+ pDoc->SetString(nCol, nRow, nTab, sNewString);
+ }
+// erack! it's broadcasted
+// pDoc->SetDirty();
+ pDocSh->SetDocumentModified();
+ if (bRecord)
+ {
+ GetViewData()->GetDocShell()->GetUndoManager()->AddUndoAction(
+ new ScUndoThesaurus( GetViewData()->GetDocShell(),
+ nCol, nRow, nTab,
+ sOldText, pOldTObj, sNewString, pNewTObj));
+ }
+ delete pNewTObj;
+ }
+ KillEditView(TRUE);
+ delete pEditDefaults;
+ delete pThesaurusEngine;
+ delete pOldTObj;
+ delete pEditSel;
+ pDocSh->PostPaintGridAll();
+}
+
+void ScViewFunc::DoHangulHanjaConversion( BOOL bRecord )
+{
+ ScConversionParam aConvParam( SC_CONVERSION_HANGULHANJA, LANGUAGE_KOREAN, 0, true );
+ DoSheetConversion( aConvParam, bRecord );
+}
+
+void ScViewFunc::DoSheetConversion( const ScConversionParam& rConvParam, BOOL bRecord )
+{
+ SCCOL nCol;
+ SCROW nRow;
+ SCTAB nTab;
+ ScViewData& rViewData = *GetViewData();
+ ScDocShell* pDocSh = rViewData.GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = rViewData.GetMarkData();
+ ScSplitPos eWhich = rViewData.GetActivePart();
+ EditView* pEditView = NULL;
+ ESelection* pEditSel = NULL;
+ BOOL bIsEditMode = rViewData.HasEditView(eWhich);
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ if (bIsEditMode) // Edit-Mode aktiv
+ {
+ rViewData.GetEditView(eWhich, pEditView, nCol, nRow);
+ pEditSel = new ESelection(pEditView->GetSelection());
+ SC_MOD()->InputEnterHandler();
+ }
+ else
+ {
+ nCol = rViewData.GetCurX();
+ nRow = rViewData.GetCurY();
+
+ AlignToCursor( nCol, nRow, SC_FOLLOW_JUMP);
+ }
+ nTab = rViewData.GetTabNo();
+
+ rMark.MarkToMulti();
+ BOOL bMarked = rMark.IsMultiMarked();
+ if (bMarked)
+ {
+ ScEditableTester aTester( pDoc, rMark );
+ if (!aTester.IsEditable())
+ {
+ ErrorMessage(aTester.GetMessageId());
+ delete pEditSel;
+ return;
+ }
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ ScDocument* pRedoDoc = NULL;
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ pRedoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pRedoDoc->InitUndo( pDoc, nTab, nTab );
+
+ if ( rMark.GetSelectCount() > 1 )
+ {
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if ( rMark.GetTableSelect(i) && i != nTab )
+ {
+ pUndoDoc->AddUndoTab( i, i );
+ pRedoDoc->AddUndoTab( i, i );
+ }
+ }
+ }
+
+ // ab hier kein return mehr
+
+ BOOL bOldDis = pDoc->IsIdleDisabled();
+ pDoc->DisableIdle( TRUE ); // #42726# stop online spelling
+
+ // *** create and init the edit engine *** --------------------------------
+
+ ScConversionEngineBase* pEngine = NULL;
+ switch( rConvParam.GetType() )
+ {
+ case SC_CONVERSION_SPELLCHECK:
+ pEngine = new ScSpellingEngine(
+ pDoc->GetEnginePool(), rViewData, pUndoDoc, pRedoDoc, LinguMgr::GetSpellChecker() );
+ break;
+ case SC_CONVERSION_HANGULHANJA:
+ case SC_CONVERSION_CHINESE_TRANSL:
+ pEngine = new ScTextConversionEngine(
+ pDoc->GetEnginePool(), rViewData, rConvParam, pUndoDoc, pRedoDoc );
+ break;
+ default:
+ DBG_ERRORFILE( "ScViewFunc::DoSheetConversion - unknown conversion type" );
+ }
+
+ MakeEditView( pEngine, nCol, nRow );
+ pEngine->SetRefDevice( rViewData.GetActiveWin() );
+ // dummy Zelle simulieren:
+ pEditView = rViewData.GetEditView( rViewData.GetActivePart() );
+ rViewData.SetSpellingView( pEditView );
+ Rectangle aRect( Point( 0, 0 ), Point( 0, 0 ) );
+ pEditView->SetOutputArea( aRect );
+ pEngine->SetControlWord( EE_CNTRL_USECHARATTRIBS );
+ pEngine->EnableUndo( FALSE );
+ pEngine->SetPaperSize( aRect.GetSize() );
+ pEngine->SetText( EMPTY_STRING );
+
+ // *** do the conversion *** ----------------------------------------------
+
+ pEngine->ClearModifyFlag();
+ pEngine->ConvertAll( *pEditView );
+
+ // *** undo/redo *** ------------------------------------------------------
+
+ if( pEngine->IsAnyModified() )
+ {
+ if (bRecord)
+ {
+ SCCOL nNewCol = rViewData.GetCurX();
+ SCROW nNewRow = rViewData.GetCurY();
+ rViewData.GetDocShell()->GetUndoManager()->AddUndoAction(
+ new ScUndoConversion(
+ pDocSh, rMark,
+ nCol, nRow, nTab, pUndoDoc,
+ nNewCol, nNewRow, nTab, pRedoDoc, rConvParam ) );
+ }
+ pDoc->SetDirty();
+ pDocSh->SetDocumentModified();
+ }
+ else
+ {
+ delete pUndoDoc;
+ delete pRedoDoc;
+ }
+
+ // *** final cleanup *** --------------------------------------------------
+
+ rViewData.SetSpellingView( NULL );
+ KillEditView(TRUE);
+ delete pEngine;
+ delete pEditSel;
+ pDocSh->PostPaintGridAll();
+ rViewData.GetViewShell()->UpdateInputHandler();
+ pDoc->DisableIdle(bOldDis);
+}
+
+// Pasten von FORMAT_FILE-Items
+// wird nicht direkt aus Drop aufgerufen, sondern asynchron -> Dialoge sind erlaubt
+
+BOOL ScViewFunc::PasteFile( const Point& rPos, const String& rFile, BOOL bLink )
+{
+ INetURLObject aURL;
+ aURL.SetSmartURL( rFile );
+ String aStrURL = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ // is it a media URL?
+ if( ::avmedia::MediaWindow::isMediaURL( aStrURL ) )
+ {
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, aStrURL );
+ return BOOL( 0 != GetViewData()->GetDispatcher().Execute(
+ SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON,
+ &aMediaURLItem, 0L ) );
+ }
+
+ if (!bLink) // bei bLink nur Grafik oder URL
+ {
+ // 1. Kann ich die Datei oeffnen?
+ const SfxFilter* pFlt = NULL;
+
+ // nur nach eigenen Filtern suchen, ohne Auswahlbox (wie in ScDocumentLoader)
+ SfxFilterMatcher aMatcher( ScDocShell::Factory().GetFilterContainer()->GetName() );
+ SfxMedium aSfxMedium( aStrURL, (STREAM_READ | STREAM_SHARE_DENYNONE), FALSE );
+ // #i73992# GuessFilter no longer calls UseInteractionHandler.
+ // This is UI, so it can be called here.
+ aSfxMedium.UseInteractionHandler(TRUE);
+ ErrCode nErr = aMatcher.GuessFilter( aSfxMedium, &pFlt );
+
+ if ( pFlt && !nErr )
+ {
+ // Code aus dem SFX geklaut!
+ SfxDispatcher &rDispatcher = GetViewData()->GetDispatcher();
+ SfxStringItem aFileNameItem( SID_FILE_NAME, aStrURL );
+ SfxStringItem aFilterItem( SID_FILTER_NAME, pFlt->GetName() );
+ // #i69524# add target, as in SfxApplication when the Open dialog is used
+ SfxStringItem aTargetItem( SID_TARGETNAME, String::CreateFromAscii("_default") );
+
+ // Asynchron oeffnen, kann naemlich auch aus D&D heraus passieren
+ // und das bekommt dem MAC nicht so gut ...
+ return BOOL( 0 != rDispatcher.Execute( SID_OPENDOC,
+ SFX_CALLMODE_ASYNCHRON, &aFileNameItem, &aFilterItem, &aTargetItem, 0L) );
+ }
+ }
+
+ // 2. Kann die Datei ueber die Grafik-Filter eingefuegt werden?
+ // (als Link, weil Gallery das so anbietet)
+
+ USHORT nFilterFormat;
+ Graphic aGraphic;
+ GraphicFilter* pGraphicFilter = GraphicFilter::GetGraphicFilter();
+
+// GraphicProgress aGraphicProgress(&aGraphicFilter);
+
+ if (!pGraphicFilter->ImportGraphic(aGraphic, aURL,
+ GRFILTER_FORMAT_DONTKNOW, &nFilterFormat ))
+ {
+ if ( bLink )
+ {
+ String aFltName = pGraphicFilter->GetImportFormatName(nFilterFormat);
+ return PasteGraphic( rPos, aGraphic, aStrURL, aFltName );
+ }
+ else
+ {
+ // #i76709# if bLink isn't set, pass empty URL/filter, so a non-linked image is inserted
+ return PasteGraphic( rPos, aGraphic, EMPTY_STRING, EMPTY_STRING );
+ }
+ }
+
+ if (bLink) // bei bLink alles, was nicht Grafik ist, als URL
+ {
+ Rectangle aRect( rPos, Size(0,0) );
+ ScRange aRange = GetViewData()->GetDocument()->
+ GetRange( GetViewData()->GetTabNo(), aRect );
+ SCCOL nPosX = aRange.aStart.Col();
+ SCROW nPosY = aRange.aStart.Row();
+
+ InsertBookmark( aStrURL, aStrURL, nPosX, nPosY );
+ return TRUE;
+ }
+ else
+ {
+ // 3. Kann die Datei als OLE eingefuegt werden?
+ // auch nicht-Storages, z.B. Sounds (#38282#)
+ uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
+
+ //TODO/LATER: what about "bLink"?
+
+ uno::Sequence < beans::PropertyValue > aMedium(1);
+ aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aMedium[0].Value <<= ::rtl::OUString( aStrURL );
+
+ comphelper::EmbeddedObjectContainer aCnt( xStorage );
+ ::rtl::OUString aName;
+ uno::Reference < embed::XEmbeddedObject > xObj = aCnt.InsertEmbeddedObject( aMedium, aName );
+ if( xObj.is() )
+ return PasteObject( rPos, xObj );
+
+ // #105851# If an OLE object can't be created, insert a URL button
+
+ GetViewData()->GetViewShell()->InsertURLButton( aStrURL, aStrURL, EMPTY_STRING, &rPos );
+ return TRUE;
+ }
+}
+
+BOOL ScViewFunc::PasteBookmark( ULONG nFormatId,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::datatransfer::XTransferable >& rxTransferable,
+ SCCOL nPosX, SCROW nPosY )
+{
+ INetBookmark aBookmark;
+ TransferableDataHelper aDataHelper( rxTransferable );
+ if ( !aDataHelper.GetINetBookmark( nFormatId, aBookmark ) )
+ return FALSE;
+
+ InsertBookmark( aBookmark.GetDescription(), aBookmark.GetURL(), nPosX, nPosY );
+ return TRUE;
+}
+
+void ScViewFunc::InsertBookmark( const String& rDescription, const String& rURL,
+ SCCOL nPosX, SCROW nPosY, const String* pTarget,
+ BOOL bTryReplace )
+{
+ ScViewData* pViewData = GetViewData();
+ if ( pViewData->HasEditView( pViewData->GetActivePart() ) &&
+ nPosX >= pViewData->GetEditStartCol() && nPosX <= pViewData->GetEditEndCol() &&
+ nPosY >= pViewData->GetEditStartRow() && nPosY <= pViewData->GetEditEndRow() )
+ {
+ // in die gerade editierte Zelle einfuegen
+
+ String aTargetFrame;
+ if (pTarget)
+ aTargetFrame = *pTarget;
+ pViewData->GetViewShell()->InsertURLField( rDescription, rURL, aTargetFrame );
+ return;
+ }
+
+ // in nicht editierte Zelle einfuegen
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aCellPos( nPosX, nPosY, nTab );
+ ScBaseCell* pCell = pDoc->GetCell( aCellPos );
+ EditEngine aEngine( pDoc->GetEnginePool() );
+ if (pCell)
+ {
+ if (pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ const EditTextObject* pOld = ((ScEditCell*)pCell)->GetData();
+ if (pOld)
+ aEngine.SetText(*pOld);
+ }
+ else
+ {
+ String aOld;
+ pDoc->GetInputString( nPosX, nPosY, nTab, aOld );
+ if (aOld.Len())
+ aEngine.SetText(aOld);
+ }
+ }
+
+ USHORT nPara = aEngine.GetParagraphCount();
+ if (nPara)
+ --nPara;
+ xub_StrLen nTxtLen = aEngine.GetTextLen(nPara);
+ ESelection aInsSel( nPara, nTxtLen, nPara, nTxtLen );
+
+ if ( bTryReplace && HasBookmarkAtCursor( NULL ) )
+ {
+ // if called from hyperlink slot and cell contains only a URL,
+ // replace old URL with new one
+
+ aInsSel = ESelection( 0, 0, 0, 1 ); // replace first character (field)
+ }
+
+ SvxURLField aField( rURL, rDescription, SVXURLFORMAT_APPDEFAULT );
+ if (pTarget)
+ aField.SetTargetFrame(*pTarget);
+ aEngine.QuickInsertField( SvxFieldItem( aField, EE_FEATURE_FIELD ), aInsSel );
+
+ EditTextObject* pData = aEngine.CreateTextObject();
+ EnterData( nPosX, nPosY, nTab, pData );
+ delete pData;
+}
+
+BOOL ScViewFunc::HasBookmarkAtCursor( SvxHyperlinkItem* pContent )
+{
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ ScDocument* pDoc = GetViewData()->GetDocShell()->GetDocument();
+
+ ScBaseCell* pCell = pDoc->GetCell( aPos );
+ if ( pCell && pCell->GetCellType() == CELLTYPE_EDIT )
+ {
+ const EditTextObject* pData = ((ScEditCell*)pCell)->GetData();
+ if (pData)
+ {
+ BOOL bField = pData->IsFieldObject();
+ if (bField)
+ {
+ const SvxFieldItem* pFieldItem = pData->GetField();
+ if (pFieldItem)
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField && pField->ISA(SvxURLField) )
+ {
+ if (pContent)
+ {
+ const SvxURLField* pURLField = (const SvxURLField*)pField;
+ pContent->SetName( pURLField->GetRepresentation() );
+ pContent->SetURL( pURLField->GetURL() );
+ pContent->SetTargetFrame( pURLField->GetTargetFrame() );
+ }
+ return TRUE;
+ }
+ }
+ }
+ }
+ }
+ return FALSE;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
new file mode 100644
index 000000000000..818b602dad41
--- /dev/null
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -0,0 +1,732 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+
+
+#include <svx/unomodel.hxx>
+#include <unotools/streamwrap.hxx>
+
+//------------------------------------------------------------------
+
+#include <svx/dbexch.hrc>
+#include <svx/fmmodel.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdobj.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdpage.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sot/clsids.hxx>
+#include <sot/formats.hxx>
+#include <sot/filelist.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/transfer.hxx>
+#include <vcl/graph.hxx>
+
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <sot/formats.hxx>
+#define SOT_FORMATSTR_ID_STARCALC_CURRENT SOT_FORMATSTR_ID_STARCALC_50
+
+#include "viewfunc.hxx"
+#include "docsh.hxx"
+#include "drawview.hxx"
+#include "impex.hxx"
+#include "dbfunc.hxx"
+#include "dbcolect.hxx"
+#include "sc.hrc"
+#include "filter.hxx"
+#include "scextopt.hxx"
+#include "tabvwsh.hxx" // wegen GetViewFrame
+#include "compiler.hxx"
+
+#include "asciiopt.hxx"
+#include "scabstdlg.hxx"
+#include "clipparam.hxx"
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/dbaexchange.hxx>
+
+using namespace com::sun::star;
+
+//------------------------------------------------------------------
+
+BOOL ScViewFunc::PasteDataFormat( ULONG nFormatId,
+ const uno::Reference<datatransfer::XTransferable>& rxTransferable,
+ SCCOL nPosX, SCROW nPosY, Point* pLogicPos, BOOL bLink, BOOL bAllowDialogs )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ pDoc->SetPastingDrawFromOtherDoc( TRUE );
+
+ Point aPos; // inserting position (1/100 mm)
+ if (pLogicPos)
+ aPos = *pLogicPos;
+ else
+ {
+ // inserting position isn't needed for text formats
+ BOOL bIsTextFormat = ( ScImportExport::IsFormatSupported( nFormatId ) ||
+ nFormatId == FORMAT_RTF );
+ if ( !bIsTextFormat )
+ {
+ // Window MapMode isn't drawing MapMode if DrawingLayer hasn't been created yet
+
+ SCTAB nTab = GetViewData()->GetTabNo();
+ long nXT = 0;
+ for (SCCOL i=0; i<nPosX; i++)
+ nXT += pDoc->GetColWidth(i,nTab);
+ if (pDoc->IsNegativePage(nTab))
+ nXT = -nXT;
+ ULONG nYT = pDoc->GetRowHeight( 0, nPosY-1, nTab);
+ aPos = Point( (long)(nXT * HMM_PER_TWIPS), (long)(nYT * HMM_PER_TWIPS) );
+ }
+ }
+
+ TransferableDataHelper aDataHelper( rxTransferable );
+ BOOL bRet = FALSE;
+
+ //
+ // handle individual formats
+ //
+
+ if ( nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE ||
+ nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE ||
+ nFormatId == SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ||
+ nFormatId == SOT_FORMATSTR_ID_LINK_SOURCE_OLE ||
+ nFormatId == SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE )
+ {
+ uno::Reference < io::XInputStream > xStm;
+ TransferableObjectDescriptor aObjDesc;
+
+ if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
+ aDataHelper.GetInputStream( nFormatId, xStm ) )
+ {
+ if ( aObjDesc.maClassName == SvGlobalName( SO3_SC_CLASSID_60 ) )
+ {
+ uno::Reference < embed::XStorage > xStore = ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm );
+
+ // mba: BaseURL doesn't make sense for clipboard
+ // #i43716# Medium must be allocated with "new".
+ // DoLoad stores the pointer and deletes it with the SfxObjectShell.
+ SfxMedium* pMedium = new SfxMedium( xStore, String() );
+
+ // TODO/LATER: is it a problem that we don't support binary formats here?
+ ScDocShellRef xDocShRef = new ScDocShell(SFX_CREATE_MODE_EMBEDDED);
+ if (xDocShRef->DoLoad(pMedium))
+ {
+ ScDocument* pSrcDoc = xDocShRef->GetDocument();
+ SCTAB nSrcTab = pSrcDoc->GetVisibleTab();
+ if (!pSrcDoc->HasTable(nSrcTab))
+ nSrcTab = 0;
+
+ ScMarkData aSrcMark;
+ aSrcMark.SelectOneTable( nSrcTab ); // for CopyToClip
+ ScDocument* pClipDoc = new ScDocument( SCDOCMODE_CLIP );
+
+ SCCOL nFirstCol, nLastCol;
+ SCROW nFirstRow, nLastRow;
+ if ( pSrcDoc->GetDataStart( nSrcTab, nFirstCol, nFirstRow ) )
+ pSrcDoc->GetCellArea( nSrcTab, nLastCol, nLastRow );
+ else
+ {
+ nFirstCol = nLastCol = 0;
+ nFirstRow = nLastRow = 0;
+ }
+ ScClipParam aClipParam(ScRange(nFirstCol, nFirstRow, 0, nLastCol, nLastRow, 0), false);
+ pSrcDoc->CopyToClip(aClipParam, pClipDoc, &aSrcMark);
+ ScGlobal::SetClipDocName( xDocShRef->GetTitle( SFX_TITLE_FULLNAME ) );
+
+ SetCursor( nPosX, nPosY );
+ Unmark();
+ PasteFromClip( IDF_ALL, pClipDoc,
+ PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
+ bAllowDialogs );
+ delete pClipDoc;
+ bRet = TRUE;
+ }
+
+ xDocShRef->DoClose();
+ xDocShRef.Clear();
+ }
+ else
+ {
+ ::rtl::OUString aName;
+ uno::Reference < embed::XEmbeddedObject > xObj = GetViewData()->GetViewShell()->GetObjectShell()->
+ GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
+ if ( xObj.is() )
+ {
+ // try to get the replacement image from the clipboard
+ Graphic aGraphic;
+ ULONG nGrFormat = 0;
+// (wg. Selection Manager bei Trustet Solaris)
+#ifndef SOLARIS
+/*
+ if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
+ nGrFormat = SOT_FORMATSTR_ID_SVXB;
+ else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
+ nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
+ nGrFormat = SOT_FORMAT_BITMAP;
+*/
+#endif
+
+ // insert replacement image ( if there is one ) into the object helper
+ if ( nGrFormat )
+ {
+ datatransfer::DataFlavor aDataFlavor;
+ SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
+ PasteObject( aPos, xObj, &aObjDesc.maSize, &aGraphic, aDataFlavor.MimeType, aObjDesc.mnViewAspect );
+ }
+ else
+ PasteObject( aPos, xObj, &aObjDesc.maSize );
+
+ bRet = TRUE;
+ }
+ else
+ {
+ DBG_ERROR("Error in CreateAndLoad");
+ }
+ }
+ }
+ else
+ {
+// uno::Reference < io::XInputStream > xStm;
+// TransferableObjectDescriptor aObjDesc;
+
+ if ( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aObjDesc ) )
+ {
+ ::rtl::OUString aName;
+ uno::Reference < embed::XEmbeddedObject > xObj;
+
+ if ( aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm )
+ || aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) )
+ {
+ xObj = GetViewData()->GetDocShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
+ }
+ else
+ {
+ try
+ {
+ uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
+ uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
+ ::comphelper::getProcessServiceFactory()->createInstance( ::rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator") ) ),
+ uno::UNO_QUERY_THROW );
+
+ embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
+ xTmpStor,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
+ uno::Sequence< beans::PropertyValue >() );
+
+ // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
+ // for example whether the object should be an iconified one
+ xObj = aInfo.Object;
+ if ( xObj.is() )
+ GetViewData()->GetDocShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
+ }
+ catch( uno::Exception& )
+ {}
+ }
+
+ if ( xObj.is() )
+ {
+ // try to get the replacement image from the clipboard
+ Graphic aGraphic;
+ ULONG nGrFormat = 0;
+
+// (wg. Selection Manager bei Trustet Solaris)
+#ifndef SOLARIS
+ if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
+ nGrFormat = SOT_FORMATSTR_ID_SVXB;
+ else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
+ nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
+ nGrFormat = SOT_FORMAT_BITMAP;
+#endif
+
+ // insert replacement image ( if there is one ) into the object helper
+ if ( nGrFormat )
+ {
+ datatransfer::DataFlavor aDataFlavor;
+ SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
+ PasteObject( aPos, xObj, &aObjDesc.maSize, &aGraphic, aDataFlavor.MimeType, aObjDesc.mnViewAspect );
+ }
+ else
+ PasteObject( aPos, xObj, &aObjDesc.maSize );
+
+ // let object stay in loaded state after insertion
+ SdrOle2Obj::Unload( xObj, embed::Aspects::MSOLE_CONTENT );
+ bRet = TRUE;
+ }
+ else
+ {
+ DBG_ERROR("Error creating external OLE object");
+ }
+ }
+ //TODO/LATER: if format is not available, create picture
+ }
+ }
+ else if ( nFormatId == SOT_FORMATSTR_ID_LINK ) // LINK is also in ScImportExport
+ {
+ bRet = PasteDDE( rxTransferable );
+ }
+ else if ( ScImportExport::IsFormatSupported( nFormatId ) || nFormatId == SOT_FORMAT_RTF )
+ {
+ if ( nFormatId == SOT_FORMAT_RTF && aDataHelper.HasFormat( SOT_FORMATSTR_ID_EDITENGINE ) )
+ {
+ // use EditView's PasteSpecial / Drop
+ PasteRTF( nPosX, nPosY, rxTransferable );
+ bRet = TRUE;
+ }
+ else
+ {
+ ScAddress aCellPos( nPosX, nPosY, GetViewData()->GetTabNo() );
+ ScImportExport aObj( GetViewData()->GetDocument(), aCellPos );
+
+ ::rtl::OUString aStr;
+ SotStorageStreamRef xStream;
+ if ( aDataHelper.GetSotStorageStream( nFormatId, xStream ) && xStream.Is() )
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ bRet = aObj.ImportStream( *xStream, String(), nFormatId );
+ else if (nFormatId == FORMAT_STRING && aDataHelper.GetString( nFormatId, aStr ))
+ {
+ // Do CSV dialog if more than one line.
+ sal_Int32 nDelim = aStr.indexOf('\n');
+ if (nDelim >= 0 && nDelim != aStr.getLength () - 1)
+ {
+ ScImportStringStream aStrm( aStr);
+ ScAbstractDialogFactory* pFact =
+ ScAbstractDialogFactory::Create();
+ AbstractScImportAsciiDlg *pDlg =
+ pFact->CreateScImportAsciiDlg( NULL, String(), &aStrm,
+ RID_SCDLG_ASCII);
+
+ if (pDlg->Execute() == RET_OK)
+ {
+ ScAsciiOptions aOptions;
+ pDlg->GetOptions( aOptions );
+ aObj.SetExtOptions( aOptions );
+
+ bRet = aObj.ImportString( aStr, nFormatId );
+
+ // TODO: what if (aObj.IsOverflow())
+ // Content was partially pasted, which can be undone by
+ // the user though.
+ if (aObj.IsOverflow())
+ bRet = FALSE;
+ }
+ else
+ bRet = TRUE;
+ // Yes, no failure, don't raise a "couldn't paste"
+ // dialog if user cancelled.
+ delete pDlg;
+ }
+ else
+ bRet = aObj.ImportString( aStr, nFormatId );
+ }
+ else if (nFormatId != FORMAT_STRING && aDataHelper.GetString( nFormatId, aStr ))
+ bRet = aObj.ImportString( aStr, nFormatId );
+
+ InvalidateAttribs();
+ GetViewData()->UpdateInputHandler();
+ }
+ }
+ else if (nFormatId == SOT_FORMATSTR_ID_SBA_DATAEXCHANGE)
+ {
+ // import of database data into table
+
+ String sDataDesc;
+ if ( aDataHelper.GetString( nFormatId, sDataDesc ) )
+ {
+ SfxStringItem aDataDesc(SID_SBA_IMPORT, sDataDesc);
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ ClickCursor(nPosX, nPosY, FALSE); // set cursor position
+
+ // Creation of database area "Import1" isn't here, but in the DocShell
+ // slot execute, so it can be added to the undo action
+
+ ScDBData* pDBData = pDocSh->GetDBData( ScRange(nPosX,nPosY,nTab), SC_DB_OLD, SC_DBSEL_KEEP );
+ String sTarget;
+ if (pDBData)
+ sTarget = pDBData->GetName();
+ else
+ {
+ ScAddress aCellPos( nPosX,nPosY,nTab );
+ aCellPos.Format( sTarget, SCA_ABS_3D, pDoc, pDoc->GetAddressConvention() );
+ }
+ SfxStringItem aTarget(FN_PARAM_1, sTarget);
+
+ BOOL bAreaIsNew = !pDBData;
+ SfxBoolItem aAreaNew(FN_PARAM_2, bAreaIsNew);
+
+ ::svx::ODataAccessDescriptor aDesc;
+ DataFlavorExVector& rVector = aDataHelper.GetDataFlavorExVector();
+ ::std::auto_ptr<SfxUsrAnyItem> pCursorItem;
+ if ( ::svx::ODataAccessObjectTransferable::canExtractObjectDescriptor(rVector) )
+ {
+ aDesc = ::svx::ODataAccessObjectTransferable::extractObjectDescriptor(aDataHelper);
+ if ( aDesc.has(::svx::daCursor) )
+ pCursorItem.reset(new SfxUsrAnyItem(FN_PARAM_3, aDesc[::svx::daCursor]));
+ }
+
+ // asynchronous, to avoid doing the whole import in drop handler
+ SfxDispatcher& rDisp = GetViewData()->GetDispatcher();
+ rDisp.Execute(SID_SBA_IMPORT, SFX_CALLMODE_ASYNCHRON,
+ &aDataDesc, &aTarget, &aAreaNew, pCursorItem.get(), (void*)0 );
+
+ bRet = TRUE;
+ }
+ }
+ else if (nFormatId == SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE)
+ {
+ // insert database field control
+
+ if ( ::svx::OColumnTransferable::canExtractColumnDescriptor( aDataHelper.GetDataFlavorExVector(), CTF_COLUMN_DESCRIPTOR | CTF_CONTROL_EXCHANGE ) )
+ {
+ MakeDrawLayer();
+ ScDrawView* pScDrawView = GetScDrawView();
+ SdrObject* pObj = pScDrawView->CreateFieldControl( ::svx::OColumnTransferable::extractColumnDescriptor( aDataHelper ) );
+ if (pObj)
+ {
+ Point aInsPos = aPos;
+ Rectangle aRect(pObj->GetLogicRect());
+ aInsPos.X() -= aRect.GetSize().Width() / 2;
+ aInsPos.Y() -= aRect.GetSize().Height() / 2;
+ if ( aInsPos.X() < 0 ) aInsPos.X() = 0;
+ if ( aInsPos.Y() < 0 ) aInsPos.Y() = 0;
+ aRect.SetPos(aInsPos);
+ pObj->SetLogicRect(aRect);
+
+ if ( pObj->ISA(SdrUnoObj) )
+ pObj->NbcSetLayer(SC_LAYER_CONTROLS);
+ else
+ pObj->NbcSetLayer(SC_LAYER_FRONT);
+ if (pObj->ISA(SdrObjGroup))
+ {
+ SdrObjListIter aIter( *pObj, IM_DEEPWITHGROUPS );
+ SdrObject* pSubObj = aIter.Next();
+ while (pSubObj)
+ {
+ if ( pSubObj->ISA(SdrUnoObj) )
+ pSubObj->NbcSetLayer(SC_LAYER_CONTROLS);
+ else
+ pSubObj->NbcSetLayer(SC_LAYER_FRONT);
+ pSubObj = aIter.Next();
+ }
+ }
+
+ pScDrawView->InsertObjectSafe(pObj, *pScDrawView->GetSdrPageView());
+
+ GetViewData()->GetViewShell()->SetDrawShell( TRUE );
+ bRet = TRUE;
+ }
+ }
+ }
+ else if (nFormatId == SOT_FORMAT_BITMAP)
+ {
+ Bitmap aBmp;
+ if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
+ bRet = PasteBitmap( aPos, aBmp );
+ }
+ else if (nFormatId == SOT_FORMAT_GDIMETAFILE)
+ {
+ GDIMetaFile aMtf;
+ if( aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) )
+ bRet = PasteMetaFile( aPos, aMtf );
+ }
+ else if (nFormatId == SOT_FORMATSTR_ID_SVXB)
+ {
+ SotStorageStreamRef xStm;
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
+ {
+ Graphic aGraphic;
+ *xStm >> aGraphic;
+ bRet = PasteGraphic( aPos, aGraphic, EMPTY_STRING, EMPTY_STRING );
+ }
+ }
+ else if ( nFormatId == SOT_FORMATSTR_ID_DRAWING )
+ {
+ SotStorageStreamRef xStm;
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
+ {
+ MakeDrawLayer(); // before loading model, so 3D factory has been created
+
+ SvtPathOptions aPathOpt;
+ String aPath = aPathOpt.GetPalettePath();
+
+ ScDocShellRef aDragShellRef( new ScDocShell );
+ aDragShellRef->DoInitNew(NULL);
+ FmFormModel* pModel = new FmFormModel( aPath, NULL, aDragShellRef );
+
+ pModel->GetItemPool().FreezeIdRanges();
+ xStm->Seek(0);
+
+ com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
+ SvxDrawingLayerImport( pModel, xInputStream );
+
+ // set everything to right layer:
+ ULONG nObjCount = 0;
+ USHORT nPages = pModel->GetPageCount();
+ for (USHORT i=0; i<nPages; i++)
+ {
+ SdrPage* pPage = pModel->GetPage(i);
+ SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->ISA(SdrUnoObj) )
+ pObject->NbcSetLayer(SC_LAYER_CONTROLS);
+ else
+ pObject->NbcSetLayer(SC_LAYER_FRONT);
+ pObject = aIter.Next();
+ }
+
+ nObjCount += pPage->GetObjCount(); // #105888# count group object only once
+ }
+
+ PasteDraw( aPos, pModel, (nObjCount > 1) ); // grouped if more than 1 object
+ delete pModel;
+ aDragShellRef->DoClose();
+ bRet = TRUE;
+ }
+ }
+ else if ( (nFormatId == SOT_FORMATSTR_ID_BIFF_5) || (nFormatId == SOT_FORMATSTR_ID_BIFF_8) )
+ {
+ // do excel import into a clipboard document
+ //TODO/MBA: testing
+ uno::Reference < io::XInputStream > xStm;
+ if( aDataHelper.GetInputStream( nFormatId, xStm ) )
+ {
+ ScDocument* pInsDoc = new ScDocument( SCDOCMODE_CLIP );
+ SCTAB nSrcTab = 0; // Biff5 in clipboard: always sheet 0
+ pInsDoc->ResetClip( pDoc, nSrcTab );
+
+ SfxMedium aMed;
+ aMed.GetItemSet()->Put( SfxUsrAnyItem( SID_INPUTSTREAM, uno::makeAny( xStm ) ) );
+ FltError eErr = ScFormatFilter::Get().ScImportExcel( aMed, pInsDoc, EIF_AUTO );
+ if ( eErr == eERR_OK )
+ {
+ ScRange aSource;
+ const ScExtDocOptions* pExtOpt = pInsDoc->GetExtDocOptions();
+ const ScExtTabSettings* pTabSett = pExtOpt ? pExtOpt->GetTabSettings( nSrcTab ) : 0;
+ if( pTabSett && pTabSett->maUsedArea.IsValid() )
+ {
+ aSource = pTabSett->maUsedArea;
+ // ensure correct sheet indexes
+ aSource.aStart.SetTab( nSrcTab );
+ aSource.aEnd.SetTab( nSrcTab );
+// #92240# don't use selection area: if cursor is moved in Excel after Copy, selection
+// represents the new cursor position and not the copied area
+ }
+ else
+ {
+ DBG_ERROR("no dimension"); //! possible?
+ SCCOL nFirstCol, nLastCol;
+ SCROW nFirstRow, nLastRow;
+ if ( pInsDoc->GetDataStart( nSrcTab, nFirstCol, nFirstRow ) )
+ pInsDoc->GetCellArea( nSrcTab, nLastCol, nLastRow );
+ else
+ {
+ nFirstCol = nLastCol = 0;
+ nFirstRow = nLastRow = 0;
+ }
+ aSource = ScRange( nFirstCol, nFirstRow, nSrcTab,
+ nLastCol, nLastRow, nSrcTab );
+ }
+
+ if ( pLogicPos )
+ {
+ // position specified (Drag&Drop) - change selection
+ MoveCursorAbs( nPosX, nPosY, SC_FOLLOW_NONE, FALSE, FALSE );
+ Unmark();
+ }
+
+ pInsDoc->SetClipArea( aSource );
+ PasteFromClip( IDF_ALL, pInsDoc,
+ PASTE_NOFUNC, FALSE, FALSE, FALSE, INS_NONE, IDF_NONE,
+ bAllowDialogs );
+ delete pInsDoc;
+
+ bRet = TRUE;
+ }
+ }
+ }
+ else if ( nFormatId == SOT_FORMAT_FILE )
+ {
+ String aFile;
+ if ( aDataHelper.GetString( nFormatId, aFile ) )
+ bRet = PasteFile( aPos, aFile, bLink );
+ }
+ else if ( nFormatId == SOT_FORMAT_FILE_LIST )
+ {
+ FileList aFileList;
+ if ( aDataHelper.GetFileList( nFormatId, aFileList ) )
+ {
+ ULONG nCount = aFileList.Count();
+ for( ULONG i = 0; i < nCount ; i++ )
+ {
+ String aFile = aFileList.GetFile( i );
+
+ PasteFile( aPos, aFile, bLink );
+
+ aPos.X() += 400;
+ aPos.Y() += 400;
+ }
+ bRet = TRUE;
+ }
+ }
+ else if ( nFormatId == SOT_FORMATSTR_ID_SOLK ||
+ nFormatId == SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ||
+ nFormatId == SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ||
+ nFormatId == SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR )
+ {
+ bRet = PasteBookmark( nFormatId, rxTransferable, nPosX, nPosY );
+ }
+
+ pDoc->SetPastingDrawFromOtherDoc( FALSE );
+
+ return bRet;
+}
+
+ByteString lcl_GetSubString( sal_Char* pData, long nStart, long nDataSize )
+{
+ if ( nDataSize <= nStart /* || pData[nDataSize] != 0 */ )
+ {
+ DBG_ERROR("DDE Data: invalid data");
+ return ByteString();
+ }
+ return ByteString( pData + nStart );
+}
+
+BOOL ScViewFunc::PasteDDE( const uno::Reference<datatransfer::XTransferable>& rxTransferable )
+{
+ TransferableDataHelper aDataHelper( rxTransferable );
+
+ // get link data from transferable before string data,
+ // so the source knows it will be used for a link
+
+ uno::Sequence<sal_Int8> aSequence;
+ if ( !aDataHelper.GetSequence( SOT_FORMATSTR_ID_LINK, aSequence ) )
+ {
+ DBG_ERROR("DDE Data not found.");
+ return FALSE;
+ }
+
+ // check size (only if string is available in transferable)
+
+ USHORT nCols = 1;
+ USHORT nRows = 1;
+ if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) )
+ {
+ String aDataStr;
+ if ( aDataHelper.GetString( SOT_FORMAT_STRING, aDataStr ) )
+ {
+ // get size from string the same way as in ScDdeLink::DataChanged
+
+ aDataStr.ConvertLineEnd(LINEEND_LF);
+ xub_StrLen nLen = aDataStr.Len();
+ if (nLen && aDataStr.GetChar(nLen-1) == '\n')
+ aDataStr.Erase(nLen-1);
+
+ if (aDataStr.Len())
+ {
+ nRows = aDataStr.GetTokenCount( '\n' );
+ String aLine = aDataStr.GetToken( 0, '\n' );
+ if (aLine.Len())
+ nCols = aLine.GetTokenCount( '\t' );
+ }
+ }
+ }
+
+ // create formula
+
+ long nSeqLen = aSequence.getLength();
+ sal_Char* pData = (sal_Char*)aSequence.getConstArray();
+
+ rtl_TextEncoding eSysEnc = gsl_getSystemTextEncoding();
+
+ ByteString aByteApp = lcl_GetSubString( pData, 0, nSeqLen );
+ ByteString aByteTopic = lcl_GetSubString( pData, aByteApp.Len() + 1, nSeqLen );
+ ByteString aByteItem = lcl_GetSubString( pData, aByteApp.Len() + aByteTopic.Len() + 2, nSeqLen );
+
+ String aApp( aByteApp, eSysEnc );
+ String aTopic( aByteTopic, eSysEnc );
+ String aItem( aByteItem, eSysEnc );
+
+ // TODO: we could define ocQuote for "
+ const String aQuote( '"' );
+ const String& sSep = ScCompiler::GetNativeSymbol( ocSep);
+ String aFormula( '=' );
+ aFormula += ScCompiler::GetNativeSymbol( ocDde);
+ aFormula += ScCompiler::GetNativeSymbol( ocOpen);
+ aFormula += aQuote;
+ aFormula += aApp;
+ aFormula += aQuote;
+ aFormula += sSep;
+ aFormula += aQuote;
+ aFormula += aTopic;
+ aFormula += aQuote;
+ aFormula += sSep;
+ aFormula += aQuote;
+ aFormula += aItem;
+ aFormula += aQuote;
+ aFormula += ScCompiler::GetNativeSymbol( ocClose);
+
+ // mark range
+
+ SCTAB nTab = GetViewData()->GetTabNo();
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ HideAllCursors();
+ DoneBlockMode();
+ InitBlockMode( nCurX, nCurY, nTab );
+ MarkCursor( nCurX+static_cast<SCCOL>(nCols)-1, nCurY+static_cast<SCROW>(nRows)-1, nTab );
+ ShowAllCursors();
+
+ // enter formula
+
+ EnterMatrix( aFormula );
+ CursorPosChanged();
+
+ return TRUE;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun6.cxx b/sc/source/ui/view/viewfun6.cxx
new file mode 100644
index 000000000000..13e3da52dc21
--- /dev/null
+++ b/sc/source/ui/view/viewfun6.cxx
@@ -0,0 +1,363 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+#include <svx/svdundo.hxx>
+#include <svx/svdocapt.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include "svl/zforlist.hxx"
+
+#include "viewfunc.hxx"
+#include "detfunc.hxx"
+#include "detdata.hxx"
+#include "viewdata.hxx"
+#include "drwlayer.hxx"
+#include "docsh.hxx"
+#include "undocell.hxx"
+#include "futext.hxx"
+#include "docfunc.hxx"
+#include "globstr.hrc"
+#include "sc.hrc"
+#include "fusel.hxx"
+#include "reftokenhelper.hxx"
+#include "externalrefmgr.hxx"
+#include "cell.hxx"
+
+#include <vector>
+
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::std::vector;
+
+#define D_TIMEFACTOR 86400.0
+
+//==================================================================
+
+void ScViewFunc::DetectiveAddPred()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveAddPred( GetViewData()->GetCurPos() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT(); //! use broadcast in DocFunc instead?
+}
+
+void ScViewFunc::DetectiveDelPred()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveDelPred( GetViewData()->GetCurPos() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+void ScViewFunc::DetectiveAddSucc()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveAddSucc( GetViewData()->GetCurPos() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+void ScViewFunc::DetectiveDelSucc()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveDelSucc( GetViewData()->GetCurPos() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+void ScViewFunc::DetectiveAddError()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveAddError( GetViewData()->GetCurPos() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+void ScViewFunc::DetectiveDelAll()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveDelAll( GetViewData()->GetTabNo() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+void ScViewFunc::DetectiveMarkInvalid()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().
+ DetectiveMarkInvalid( GetViewData()->GetTabNo() );
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+void ScViewFunc::DetectiveRefresh()
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bDone = pDocSh->GetDocFunc().DetectiveRefresh();
+ if (!bDone)
+ Sound::Beep();
+
+ RecalcPPT();
+}
+
+static void lcl_jumpToRange(const ScRange& rRange, ScViewData* pView, ScDocument* pDoc)
+{
+ String aAddrText;
+ rRange.Format(aAddrText, SCR_ABS_3D, pDoc);
+ SfxStringItem aPosItem(SID_CURRENTCELL, aAddrText);
+ SfxBoolItem aUnmarkItem(FN_PARAM_1, TRUE); // remove existing selection
+ pView->GetDispatcher().Execute(
+ SID_CURRENTCELL, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
+ &aPosItem, &aUnmarkItem, 0L);
+}
+
+void ScViewFunc::MarkAndJumpToRanges(const ScRangeList& rRanges)
+{
+ ScViewData* pView = GetViewData();
+ ScDocShell* pDocSh = pView->GetDocShell();
+
+ ScRangeList aRanges(rRanges);
+ ScRange* p = aRanges.First();
+ ScRangeList aRangesToMark;
+ ScAddress aCurPos = pView->GetCurPos();
+ for (; p; p = aRanges.Next())
+ {
+ // Collect only those ranges that are on the same sheet as the current
+ // cursor.
+
+ if (p->aStart.Tab() == aCurPos.Tab())
+ aRangesToMark.Append(*p);
+ }
+
+ if (!aRangesToMark.Count())
+ return;
+
+ // Jump to the first range of all precedent ranges.
+ p = aRangesToMark.First();
+ lcl_jumpToRange(*p, pView, pDocSh->GetDocument());
+
+ for (; p; p = aRangesToMark.Next())
+ MarkRange(*p, false, true);
+}
+
+void ScViewFunc::DetectiveMarkPred()
+{
+ ScViewData* pView = GetViewData();
+ ScDocShell* pDocSh = pView->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMarkData = pView->GetMarkData();
+ ScAddress aCurPos = pView->GetCurPos();
+ ScRangeList aRanges;
+ if (rMarkData.IsMarked() || rMarkData.IsMultiMarked())
+ rMarkData.FillRangeListWithMarks(&aRanges, false);
+ else
+ aRanges.Append(aCurPos);
+
+ vector<ScSharedTokenRef> aRefTokens;
+ pDocSh->GetDocFunc().DetectiveCollectAllPreds(aRanges, aRefTokens);
+
+ if (aRefTokens.empty())
+ // No precedents found. Nothing to do.
+ return;
+
+ ScSharedTokenRef p = aRefTokens.front();
+ if (ScRefTokenHelper::isExternalRef(p))
+ {
+ // This is external. Open the external document if available, and
+ // jump to the destination.
+
+ sal_uInt16 nFileId = p->GetIndex();
+ ScExternalRefManager* pRefMgr = pDoc->GetExternalRefManager();
+ const String* pPath = pRefMgr->getExternalFileName(nFileId);
+
+ ScRange aRange;
+ if (pPath && ScRefTokenHelper::getRangeFromToken(aRange, p, true))
+ {
+ const String& rTabName = p->GetString();
+ OUStringBuffer aBuf;
+ aBuf.append(*pPath);
+ aBuf.append(sal_Unicode('#'));
+ aBuf.append(rTabName);
+ aBuf.append(sal_Unicode('.'));
+
+ String aRangeStr;
+ aRange.Format(aRangeStr, SCA_VALID);
+ aBuf.append(aRangeStr);
+
+ ScGlobal::OpenURL(aBuf.makeStringAndClear(), String());
+ }
+ return;
+ }
+ else
+ {
+ ScRange aRange;
+ ScRefTokenHelper::getRangeFromToken(aRange, p, false);
+ if (aRange.aStart.Tab() != aCurPos.Tab())
+ {
+ // The first precedent range is on a different sheet. Jump to it
+ // immediately and forget the rest.
+ lcl_jumpToRange(aRange, pView, pDoc);
+ return;
+ }
+ }
+
+ ScRangeList aDestRanges;
+ ScRefTokenHelper::getRangeListFromTokens(aDestRanges, aRefTokens);
+ MarkAndJumpToRanges(aDestRanges);
+}
+
+void ScViewFunc::DetectiveMarkSucc()
+{
+ ScViewData* pView = GetViewData();
+ ScDocShell* pDocSh = pView->GetDocShell();
+ ScMarkData& rMarkData = pView->GetMarkData();
+ ScAddress aCurPos = pView->GetCurPos();
+ ScRangeList aRanges;
+ if (rMarkData.IsMarked() || rMarkData.IsMultiMarked())
+ rMarkData.FillRangeListWithMarks(&aRanges, false);
+ else
+ aRanges.Append(aCurPos);
+
+ vector<ScSharedTokenRef> aRefTokens;
+ pDocSh->GetDocFunc().DetectiveCollectAllSuccs(aRanges, aRefTokens);
+
+ if (aRefTokens.empty())
+ // No dependants found. Nothing to do.
+ return;
+
+ ScRangeList aDestRanges;
+ ScRefTokenHelper::getRangeListFromTokens(aDestRanges, aRefTokens);
+ MarkAndJumpToRanges(aDestRanges);
+}
+
+void ScViewFunc::InsertCurrentTime(short nCellFmt, const OUString& rUndoStr)
+{
+ ScViewData* pViewData = GetViewData();
+ ScAddress aCurPos = pViewData->GetCurPos();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SfxUndoManager* pUndoMgr = pDocSh->GetUndoManager();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ Date aActDate;
+ double fDate = aActDate - *pFormatter->GetNullDate();
+ Time aActTime;
+ double fTime =
+ aActTime.Get100Sec() / 100.0 + aActTime.GetSec() +
+ (aActTime.GetMin() * 60.0) + (aActTime.GetHour() * 3600.0);
+ fTime /= D_TIMEFACTOR;
+ pUndoMgr->EnterListAction(rUndoStr, rUndoStr);
+ pDocSh->GetDocFunc().PutCell(aCurPos, new ScValueCell(fDate+fTime), false);
+ SetNumberFormat(nCellFmt);
+ pUndoMgr->LeaveListAction();
+}
+
+//---------------------------------------------------------------------------
+
+void ScViewFunc::ShowNote( bool bShow )
+{
+ if( bShow )
+ HideNoteMarker();
+ const ScViewData& rViewData = *GetViewData();
+ ScAddress aPos( rViewData.GetCurX(), rViewData.GetCurY(), rViewData.GetTabNo() );
+ // show note moved to ScDocFunc, to be able to use it in notesuno.cxx
+ rViewData.GetDocShell()->GetDocFunc().ShowNote( aPos, bShow );
+}
+
+void ScViewFunc::EditNote()
+{
+ // zum Editieren einblenden und aktivieren
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScAddress aPos( nCol, nRow, nTab );
+
+ // start drawing undo to catch undo action for insertion of the caption object
+ pDocSh->MakeDrawLayer();
+ ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
+ pDrawLayer->BeginCalcUndo();
+ // generated undo action is processed in FuText::StopEditMode
+
+ // get existing note or create a new note (including caption drawing object)
+ if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) )
+ {
+ // hide temporary note caption
+ HideNoteMarker();
+ // show caption object without changing internal visibility state
+ pNote->ShowCaptionTemp( aPos );
+
+ /* Drawing object has been created in ScDocument::GetOrCreateNote() or
+ in ScPostIt::ShowCaptionTemp(), so ScPostIt::GetCaption() should
+ return a caption object. */
+ if( SdrCaptionObj* pCaption = pNote->GetCaption() )
+ {
+ // #i33764# enable the resize handles before starting edit mode
+ if( FuPoor* pDraw = GetDrawFuncPtr() )
+ static_cast< FuSelection* >( pDraw )->ActivateNoteHandles( pCaption );
+
+ // activate object (as in FuSelection::TestComment)
+ GetViewData()->GetDispatcher().Execute( SID_DRAW_NOTEEDIT, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ // jetzt den erzeugten FuText holen und in den EditModus setzen
+ FuPoor* pPoor = GetDrawFuncPtr();
+ if ( pPoor && (pPoor->GetSlotID() == SID_DRAW_NOTEEDIT) ) // hat keine RTTI
+ {
+ ScrollToObject( pCaption ); // Objekt komplett sichtbar machen
+ static_cast< FuText* >( pPoor )->SetInEditMode( pCaption );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
new file mode 100644
index 000000000000..a081ef3558f0
--- /dev/null
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -0,0 +1,456 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <svx/svditer.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/xbitmap.hxx>
+#include <svx/xbtmpit.hxx>
+#include <svx/xoutbmp.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <com/sun/star/embed/Aspects.hpp>
+
+#include "document.hxx" // fuer MapMode Initialisierung in PasteDraw
+#include "viewfunc.hxx"
+#include "tabvwsh.hxx"
+#include "drawview.hxx"
+#include "scmod.hxx"
+#include "drwlayer.hxx"
+#include "drwtrans.hxx"
+#include "globstr.hrc"
+
+extern Point aDragStartDiff;
+
+// STATIC DATA -----------------------------------------------------------
+
+BOOL bPasteIsMove = FALSE;
+
+using namespace com::sun::star;
+
+//==================================================================
+
+void lcl_AdjustInsertPos( ScViewData* pData, Point& rPos, Size& rSize )
+{
+// SdrPage* pPage = pData->GetDocument()->GetDrawLayer()->GetPage( pData->GetTabNo() );
+ SdrPage* pPage = pData->GetScDrawView()->GetModel()->GetPage( static_cast<sal_uInt16>(pData->GetTabNo()) );
+ DBG_ASSERT(pPage,"pPage ???");
+ Size aPgSize( pPage->GetSize() );
+ if (aPgSize.Width() < 0)
+ aPgSize.Width() = -aPgSize.Width();
+ long x = aPgSize.Width() - rPos.X() - rSize.Width();
+ long y = aPgSize.Height() - rPos.Y() - rSize.Height();
+ // ggf. Ajustments (80/200) fuer Pixel-Rundungsfehler
+ if( x < 0 )
+ rPos.X() += x + 80;
+ if( y < 0 )
+ rPos.Y() += y + 200;
+ rPos.X() += rSize.Width() / 2; // Position bei Paste gibt Mittelpunkt an
+ rPos.Y() += rSize.Height() / 2;
+}
+
+void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
+ BOOL bGroup, BOOL bSameDocClipboard )
+{
+ MakeDrawLayer();
+ Point aPos( rLogicPos );
+
+ // #64184# MapMode am Outliner-RefDevice muss stimmen (wie in FuText::MakeOutliner)
+ //! mit FuText::MakeOutliner zusammenfassen?
+ MapMode aOldMapMode;
+ OutputDevice* pRef = GetViewData()->GetDocument()->GetDrawLayer()->GetRefDevice();
+ if (pRef)
+ {
+ aOldMapMode = pRef->GetMapMode();
+ pRef->SetMapMode( MapMode(MAP_100TH_MM) );
+ }
+
+ BOOL bNegativePage = GetViewData()->GetDocument()->IsNegativePage( GetViewData()->GetTabNo() );
+
+ SdrView* pDragEditView = NULL;
+ ScModule* pScMod = SC_MOD();
+ const ScDragData& rData = pScMod->GetDragData();
+ ScDrawTransferObj* pDrawTrans = rData.pDrawTransfer;
+ if (pDrawTrans)
+ {
+ pDragEditView = pDrawTrans->GetDragSourceView();
+
+ aPos -= aDragStartDiff;
+ if ( bNegativePage )
+ {
+ if (aPos.X() > 0) aPos.X() = 0;
+ }
+ else
+ {
+ if (aPos.X() < 0) aPos.X() = 0;
+ }
+ if (aPos.Y() < 0) aPos.Y() = 0;
+ }
+
+ ScDrawView* pScDrawView = GetScDrawView();
+ if (bGroup)
+ pScDrawView->BegUndo( ScGlobal::GetRscString( STR_UNDO_PASTE ) );
+
+ BOOL bSameDoc = ( pDragEditView && pDragEditView->GetModel() == pScDrawView->GetModel() );
+ if (bSameDoc)
+ {
+ // lokal kopieren - incl. Charts
+
+ Point aSourceStart = pDragEditView->GetAllMarkedRect().TopLeft();
+ long nDiffX = aPos.X() - aSourceStart.X();
+ long nDiffY = aPos.Y() - aSourceStart.Y();
+
+ // innerhalb einer Page verschieben?
+
+ if ( bPasteIsMove &&
+ pScDrawView->GetSdrPageView()->GetPage() ==
+ pDragEditView->GetSdrPageView()->GetPage() )
+ {
+ if ( nDiffX != 0 || nDiffY != 0 )
+ pDragEditView->MoveAllMarked(Size(nDiffX,nDiffY), FALSE);
+ }
+ else
+ {
+ SdrModel* pDrawModel = pDragEditView->GetModel();
+ SdrPage* pDestPage = pDrawModel->GetPage( static_cast<sal_uInt16>(GetViewData()->GetTabNo()) );
+ DBG_ASSERT(pDestPage,"nanu, Page?");
+
+ SdrMarkList aMark = pDragEditView->GetMarkedObjectList();
+ aMark.ForceSort();
+ ULONG nMarkAnz=aMark.GetMarkCount();
+ for (ULONG nm=0; nm<nMarkAnz; nm++) {
+ const SdrMark* pM=aMark.GetMark(nm);
+ const SdrObject* pObj=pM->GetMarkedSdrObj();
+
+ // #116235#
+ SdrObject* pNeuObj=pObj->Clone();
+ //SdrObject* pNeuObj=pObj->Clone(pDestPage,pDrawModel);
+
+ if (pNeuObj!=NULL)
+ {
+ pNeuObj->SetModel(pDrawModel);
+ pNeuObj->SetPage(pDestPage);
+
+ // #68787# copy graphics within the same model - always needs new name
+ if ( pNeuObj->ISA(SdrGrafObj) && !bPasteIsMove )
+ pNeuObj->SetName(((ScDrawLayer*)pDrawModel)->GetNewGraphicName());
+
+ if (nDiffX!=0 || nDiffY!=0)
+ pNeuObj->NbcMove(Size(nDiffX,nDiffY));
+ pDestPage->InsertObject( pNeuObj );
+ pScDrawView->AddUndo(new SdrUndoInsertObj( *pNeuObj ));
+
+ // Chart braucht nicht mehr getrennt behandelt zu werden,
+ // weil es seine Daten jetzt selber hat
+ }
+ }
+
+ if (bPasteIsMove)
+ pDragEditView->DeleteMarked();
+ }
+ }
+ else
+ {
+ bPasteIsMove = FALSE; // kein internes Verschieben passiert
+
+ SdrView aView(pModel); // #i71529# never create a base class of SdrView directly!
+ SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0));
+ aView.MarkAllObj(pPv);
+ Size aSize = aView.GetAllMarkedRect().GetSize();
+ lcl_AdjustInsertPos( GetViewData(), aPos, aSize );
+
+ // #41333# Markierung nicht aendern, wenn Ole-Objekt aktiv
+ // (bei Drop aus Ole-Objekt wuerde sonst mitten im ExecuteDrag deaktiviert!)
+
+ ULONG nOptions = 0;
+ SfxInPlaceClient* pClient = GetViewData()->GetViewShell()->GetIPClient();
+ if ( pClient && pClient->IsObjectInPlaceActive() )
+ nOptions |= SDRINSERT_DONTMARK;
+
+ // #89247# Set flag for ScDocument::UpdateChartListeners() which is
+ // called during paste.
+ if ( !bSameDocClipboard )
+ GetViewData()->GetDocument()->SetPastingDrawFromOtherDoc( TRUE );
+
+ pScDrawView->Paste( *pModel, aPos, NULL, nOptions );
+
+ if ( !bSameDocClipboard )
+ GetViewData()->GetDocument()->SetPastingDrawFromOtherDoc( FALSE );
+
+ // #68991# Paste puts all objects on the active (front) layer
+ // controls must be on SC_LAYER_CONTROLS
+
+ SCTAB nTab = GetViewData()->GetTabNo();
+ SdrPage* pPage = pScDrawView->GetModel()->GetPage(static_cast<sal_uInt16>(nTab));
+ DBG_ASSERT(pPage,"Page?");
+ if (pPage)
+ {
+ SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
+ SdrObject* pObject = aIter.Next();
+ while (pObject)
+ {
+ if ( pObject->ISA(SdrUnoObj) && pObject->GetLayer() != SC_LAYER_CONTROLS )
+ pObject->NbcSetLayer(SC_LAYER_CONTROLS);
+ pObject = aIter.Next();
+ }
+ }
+
+ // #75299# all graphics objects must have names
+ GetViewData()->GetDocument()->EnsureGraphicNames();
+ }
+
+ if (bGroup)
+ {
+ pScDrawView->GroupMarked();
+ pScDrawView->EndUndo();
+ }
+
+ if (pRef)
+ pRef->SetMapMode( aOldMapMode );
+
+ // GetViewData()->GetViewShell()->SetDrawShell( TRUE );
+ // #99759# It is not sufficient to just set the DrawShell if we pasted, for
+ // example, a chart. SetDrawShellOrSub() would only work for D&D in the
+ // same document but not if inserting from the clipboard, therefore
+ // MarkListHasChanged() is what we need.
+ pScDrawView->MarkListHasChanged();
+
+}
+
+BOOL ScViewFunc::PasteObject( const Point& rPos, const uno::Reference < embed::XEmbeddedObject >& xObj,
+ const Size* pDescSize, const Graphic* pReplGraph, const ::rtl::OUString& aMediaType, sal_Int64 nAspect )
+{
+ MakeDrawLayer();
+ if ( xObj.is() )
+ {
+ ::rtl::OUString aName;
+ //TODO/MBA: is that OK?
+ comphelper::EmbeddedObjectContainer& aCnt = GetViewData()->GetViewShell()->GetObjectShell()->GetEmbeddedObjectContainer();
+ if ( !aCnt.HasEmbeddedObject( xObj ) )
+ aCnt.InsertEmbeddedObject( xObj, aName );
+ else
+ aName = aCnt.GetEmbeddedObjectName( xObj );
+
+ svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
+ if ( pReplGraph )
+ aObjRef.SetGraphic( *pReplGraph, aMediaType );
+
+ Size aSize;
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ {
+ MapMode aMapMode( MAP_100TH_MM );
+ aSize = aObjRef.GetSize( &aMapMode );
+ }
+ else
+ {
+ // working with visual area can switch object to running state
+ MapUnit aMapObj = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+ MapUnit aMap100 = MAP_100TH_MM;
+
+ if ( pDescSize && pDescSize->Width() && pDescSize->Height() )
+ {
+ // use size from object descriptor if given
+ aSize = OutputDevice::LogicToLogic( *pDescSize, aMap100, aMapObj );
+ awt::Size aSz;
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( nAspect, aSz );
+ }
+
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( nAspect );
+ }
+ catch ( embed::NoVisualAreaSizeException& )
+ {
+ // the default size will be set later
+ }
+
+ aSize = Size( aSz.Width, aSz.Height );
+ aSize = OutputDevice::LogicToLogic( aSize, aMapObj, aMap100 ); // fuer SdrOle2Obj
+
+ if( aSize.Height() == 0 || aSize.Width() == 0 )
+ {
+ DBG_ERROR("SvObjectDescriptor::GetSize == 0");
+ aSize.Width() = 5000;
+ aSize.Height() = 5000;
+ aSize = OutputDevice::LogicToLogic( aSize, aMap100, aMapObj );
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( nAspect, aSz );
+ }
+ }
+
+ // don't call AdjustInsertPos
+ Point aInsPos = rPos;
+ if ( GetViewData()->GetDocument()->IsNegativePage( GetViewData()->GetTabNo() ) )
+ aInsPos.X() -= aSize.Width();
+ Rectangle aRect( aInsPos, aSize );
+
+ ScDrawView* pDrView = GetScDrawView();
+ SdrOle2Obj* pSdrObj = new SdrOle2Obj( aObjRef, aName, aRect );
+
+ SdrPageView* pPV = pDrView->GetSdrPageView();
+ pDrView->InsertObjectSafe( pSdrObj, *pPV ); // nicht markieren wenn Ole
+ GetViewData()->GetViewShell()->SetDrawShell( TRUE );
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+BOOL ScViewFunc::PasteBitmap( const Point& rPos, const Bitmap& rBmp )
+{
+ String aEmpty;
+ Graphic aGraphic(rBmp);
+ return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
+}
+
+BOOL ScViewFunc::PasteMetaFile( const Point& rPos, const GDIMetaFile& rMtf )
+{
+ String aEmpty;
+ Graphic aGraphic(rMtf);
+ return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
+}
+
+BOOL ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic,
+ const String& rFile, const String& rFilter )
+{
+ MakeDrawLayer();
+ ScDrawView* pScDrawView = GetScDrawView();
+
+ Point aPos( rPos );
+ Window* pWin = GetActiveWin();
+ MapMode aSourceMap = rGraphic.GetPrefMapMode();
+ MapMode aDestMap( MAP_100TH_MM );
+
+ if (aSourceMap.GetMapUnit() == MAP_PIXEL)
+ {
+ // Pixel-Korrektur beruecksichtigen, damit Bitmap auf dem Bildschirm stimmt
+
+ Fraction aScaleX, aScaleY;
+ pScDrawView->CalcNormScale( aScaleX, aScaleY );
+ aDestMap.SetScaleX(aScaleX);
+ aDestMap.SetScaleY(aScaleY);
+ }
+
+ Size aSize = pWin->LogicToLogic( rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
+// lcl_AdjustInsertPos( GetViewData(), aPos, aSize );
+ if ( GetViewData()->GetDocument()->IsNegativePage( GetViewData()->GetTabNo() ) )
+ aPos.X() -= aSize.Width();
+
+ GetViewData()->GetViewShell()->SetDrawShell( TRUE );
+
+ Rectangle aRect(aPos, aSize);
+ SdrGrafObj* pGrafObj = new SdrGrafObj(rGraphic, aRect);
+
+ // #118522# calling SetGraphicLink here doesn't work
+
+ // #49961# Pfad wird nicht mehr als Name der Grafik gesetzt
+
+ ScDrawLayer* pLayer = (ScDrawLayer*) pScDrawView->GetModel();
+ String aName = pLayer->GetNewGraphicName(); // "Grafik x"
+ pGrafObj->SetName(aName);
+
+ // nicht markieren wenn Ole
+ pScDrawView->InsertObjectSafe(pGrafObj, *pScDrawView->GetSdrPageView());
+
+ // #118522# SetGraphicLink has to be used after inserting the object,
+ // otherwise an empty graphic is swapped in and the contact stuff crashes.
+ // See #i37444#.
+ if (rFile.Len())
+ pGrafObj->SetGraphicLink( rFile, rFilter );
+
+ return TRUE;
+}
+
+BOOL ScViewFunc::ApplyGraphicToObject( SdrObject* pPickObj, const Graphic& rGraphic )
+{
+ BOOL bRet = FALSE;
+ SdrGrafObj* pNewGrafObj = NULL;
+
+ ScDrawView* pScDrawView = GetScDrawView();
+ if ( pScDrawView && pPickObj )
+ {
+ /**********************************************************************
+ * Objekt neu attributieren
+ **********************************************************************/
+ SdrPageView* pPV = pScDrawView->GetSdrPageView();
+ if (pPickObj->ISA(SdrGrafObj))
+ {
+ /******************************************************************
+ * Das Graphik-Objekt bekommt eine neue Graphik
+ ******************************************************************/
+ pNewGrafObj = (SdrGrafObj*) pPickObj->Clone();
+ pNewGrafObj->SetGraphic(rGraphic);
+
+ pScDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP));
+ pScDrawView->ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj);
+ pScDrawView->EndUndo();
+
+ bRet = TRUE;
+ }
+ else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
+ {
+ /******************************************************************
+ * Das Objekt wird mit der Graphik gefuellt
+ ******************************************************************/
+ //pScDrawView->BegUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP));
+ pScDrawView->AddUndo(new SdrUndoAttrObj(*pPickObj));
+ //pScDrawView->EndUndo();
+
+ XOBitmap aXOBitmap( rGraphic.GetBitmap() );
+ SfxItemSet aSet( pScDrawView->GetModel()->GetItemPool(),
+ XATTR_FILLSTYLE, XATTR_FILLBITMAP );
+ aSet.Put(XFillStyleItem(XFILL_BITMAP));
+ aSet.Put(XFillBitmapItem(String(), aXOBitmap));
+
+ pPickObj->SetMergedItemSetAndBroadcast(aSet);
+
+ bRet = TRUE;
+ }
+ }
+ return bRet;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
new file mode 100644
index 000000000000..e928f68aa49a
--- /dev/null
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -0,0 +1,3035 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------
+
+// INCLUDE ---------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <editeng/eeitem.hxx>
+
+#include <sfx2/app.hxx>
+#include <svx/algitem.hxx>
+#include <editeng/boxitem.hxx>
+#include <editeng/editobj.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/justifyitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/zformat.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/sound.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/waitobj.hxx>
+#include <vcl/wrkwin.hxx>
+#include <stdlib.h> // qsort
+
+#include "viewfunc.hxx"
+#include "tabvwsh.hxx"
+#include "docsh.hxx"
+#include "attrib.hxx"
+#include "patattr.hxx"
+#include "docpool.hxx"
+#include "uiitems.hxx"
+#include "sc.hrc"
+#include "undocell.hxx"
+#include "undoblk.hxx"
+#include "undotab.hxx"
+#include "refundo.hxx"
+#include "dbcolect.hxx"
+#include "olinetab.hxx"
+#include "rangeutl.hxx"
+#include "rangenam.hxx"
+#include "globstr.hrc"
+#include "global.hxx"
+#include "stlsheet.hxx"
+#include "editutil.hxx"
+#include "cell.hxx"
+#include "scresid.hxx"
+#include "inputhdl.hxx"
+#include "scmod.hxx"
+#include "inputopt.hxx"
+#include "compiler.hxx"
+#include "docfunc.hxx"
+#include "appoptio.hxx"
+#include "dociter.hxx"
+#include "sizedev.hxx"
+#include "editable.hxx"
+#include "scui_def.hxx"
+#include "funcdesc.hxx"
+#include "docuno.hxx"
+#include "cellsuno.hxx"
+//==================================================================
+
+ScViewFunc::ScViewFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell ) :
+ ScTabView( pParent, rDocSh, pViewShell ),
+ bFormatValid( FALSE )
+{
+}
+
+ScViewFunc::~ScViewFunc()
+{
+}
+
+//------------------------------------------------------------------------------------
+
+void ScViewFunc::StartFormatArea()
+{
+ // ueberhaupt aktiviert?
+ if ( !SC_MOD()->GetInputOptions().GetExtendFormat() )
+ return;
+
+ // start only with single cell (marked or cursor position)
+ ScRange aMarkRange;
+ BOOL bOk = (GetViewData()->GetSimpleArea( aMarkRange ) == SC_MARK_SIMPLE);
+ if ( bOk && aMarkRange.aStart != aMarkRange.aEnd )
+ bOk = FALSE;
+
+ if (bOk)
+ {
+ bFormatValid = TRUE;
+ aFormatSource = aMarkRange.aStart;
+ aFormatArea = ScRange( aFormatSource );
+ }
+ else
+ bFormatValid = FALSE; // keinen alten Bereich behalten
+}
+
+BOOL ScViewFunc::TestFormatArea( SCCOL nCol, SCROW nRow, SCTAB nTab, BOOL bAttrChanged )
+{
+ // ueberhaupt aktiviert?
+ if ( !SC_MOD()->GetInputOptions().GetExtendFormat() )
+ return FALSE;
+
+ // Test: Eingabe mit Zahlformat (bAttrChanged) immer als neue Attributierung behandeln
+ // (alte Area verwerfen). Wenn das nicht gewollt ist, den if-Teil weglassen:
+ if ( bAttrChanged )
+ {
+ StartFormatArea();
+ return FALSE;
+ }
+
+ //! Abfrage, ob Zelle leer war ???
+
+ BOOL bFound = FALSE;
+ ScRange aNewRange = aFormatArea;
+ if ( bFormatValid && nTab == aFormatSource.Tab() )
+ {
+ if ( nRow >= aFormatArea.aStart.Row() && nRow <= aFormatArea.aEnd.Row() )
+ {
+ // innerhalb ?
+ if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() )
+ {
+ bFound = TRUE; // Bereich nicht aendern
+ }
+ // links ?
+ if ( nCol+1 == aFormatArea.aStart.Col() )
+ {
+ bFound = TRUE;
+ aNewRange.aStart.SetCol( nCol );
+ }
+ // rechts ?
+ if ( nCol == aFormatArea.aEnd.Col()+1 )
+ {
+ bFound = TRUE;
+ aNewRange.aEnd.SetCol( nCol );
+ }
+ }
+ if ( nCol >= aFormatArea.aStart.Col() && nCol <= aFormatArea.aEnd.Col() )
+ {
+ // oben ?
+ if ( nRow+1 == aFormatArea.aStart.Row() )
+ {
+ bFound = TRUE;
+ aNewRange.aStart.SetRow( nRow );
+ }
+ // unten ?
+ if ( nRow == aFormatArea.aEnd.Row()+1 )
+ {
+ bFound = TRUE;
+ aNewRange.aEnd.SetRow( nRow );
+ }
+ }
+ }
+
+ if (bFound)
+ aFormatArea = aNewRange; // erweitern
+ else
+ {
+ bFormatValid = FALSE; // ausserhalb -> abbrechen
+ if ( bAttrChanged ) // Wert mit Zahlformat eingegeben?
+ StartFormatArea(); // dann ggf. neu starten
+ }
+
+ return bFound;
+}
+
+void ScViewFunc::DoAutoAttributes( SCCOL nCol, SCROW nRow, SCTAB nTab,
+ BOOL bAttrChanged, BOOL bAddUndo )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ if (bAddUndo && !pDoc->IsUndoEnabled())
+ bAddUndo = FALSE;
+
+ const ScPatternAttr* pSource = pDoc->GetPattern(
+ aFormatSource.Col(), aFormatSource.Row(), nTab );
+ if ( !((const ScMergeAttr&)pSource->GetItem(ATTR_MERGE)).IsMerged() )
+ {
+ const ScPatternAttr* pDocOld = pDoc->GetPattern( nCol, nRow, nTab );
+ // pDocOld ist nur bis zum Apply... gueltig!
+
+ ScPatternAttr* pOldPattern = NULL;
+ if ( bAddUndo )
+ pOldPattern = new ScPatternAttr( *pDocOld );
+
+ const ScStyleSheet* pSrcStyle = pSource->GetStyleSheet();
+ if ( pSrcStyle && pSrcStyle != pDocOld->GetStyleSheet() )
+ pDoc->ApplyStyle( nCol, nRow, nTab, *pSrcStyle );
+ pDoc->ApplyPattern( nCol, nRow, nTab, *pSource );
+ AdjustRowHeight( nRow, nRow, TRUE ); //! nicht doppelt ?
+
+ if ( bAddUndo )
+ {
+ const ScPatternAttr* pNewPattern = pDoc->GetPattern( nCol, nRow, nTab );
+
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoCursorAttr( pDocSh, nCol, nRow, nTab,
+ pOldPattern, pNewPattern, pSource,
+ TRUE ) );
+
+ delete pOldPattern; // wird im Undo kopiert (Pool)
+ }
+ }
+
+ if ( bAttrChanged ) // Wert mit Zahlformat eingegeben?
+ aFormatSource.Set( nCol, nRow, nTab ); // dann als neue Quelle
+}
+
+//------------------------------------------------------------------------------------
+
+// Hilfsroutinen
+
+USHORT ScViewFunc::GetOptimalColWidth( SCCOL nCol, SCTAB nTab, BOOL bFormula )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+
+ double nPPTX = GetViewData()->GetPPTX();
+ double nPPTY = GetViewData()->GetPPTY();
+ Fraction aZoomX = GetViewData()->GetZoomX();
+ Fraction aZoomY = GetViewData()->GetZoomY();
+
+ ScSizeDeviceProvider aProv(pDocSh);
+ if (aProv.IsPrinter())
+ {
+ nPPTX = aProv.GetPPTX();
+ nPPTY = aProv.GetPPTY();
+ aZoomX = aZoomY = Fraction( 1, 1 );
+ }
+
+ USHORT nTwips = pDoc->GetOptimalColWidth( nCol, nTab, aProv.GetDevice(),
+ nPPTX, nPPTY, aZoomX, aZoomY, bFormula, &rMark );
+ return nTwips;
+}
+
+BOOL ScViewFunc::SelectionEditable( BOOL* pOnlyNotBecauseOfMatrix /* = NULL */ )
+{
+ BOOL bRet;
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ if (rMark.IsMarked() || rMark.IsMultiMarked())
+ bRet = pDoc->IsSelectionEditable( rMark, pOnlyNotBecauseOfMatrix );
+ else
+ {
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ bRet = pDoc->IsBlockEditable( nTab, nCol, nRow, nCol, nRow,
+ pOnlyNotBecauseOfMatrix );
+ }
+ return bRet;
+}
+
+#ifndef LRU_MAX
+#define LRU_MAX 10
+#endif
+
+BOOL lcl_FunctionKnown( USHORT nOpCode )
+{
+ const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList();
+ if ( pFuncList )
+ {
+ ULONG nCount = pFuncList->GetCount();
+ for (ULONG i=0; i<nCount; i++)
+ if ( pFuncList->GetFunction(i)->nFIndex == nOpCode )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL lcl_AddFunction( ScAppOptions& rAppOpt, USHORT nOpCode )
+{
+ USHORT nOldCount = rAppOpt.GetLRUFuncListCount();
+ USHORT* pOldList = rAppOpt.GetLRUFuncList();
+ USHORT nPos;
+ for (nPos=0; nPos<nOldCount; nPos++)
+ if (pOldList[nPos] == nOpCode) // is the function already in the list?
+ {
+ if ( nPos == 0 )
+ return FALSE; // already at the top -> no change
+
+ // count doesn't change, so the original array is modified
+
+ for (USHORT nCopy=nPos; nCopy>0; nCopy--)
+ pOldList[nCopy] = pOldList[nCopy-1];
+ pOldList[0] = nOpCode;
+
+ return TRUE; // list has changed
+ }
+
+ if ( !lcl_FunctionKnown( nOpCode ) )
+ return FALSE; // not in function list -> no change
+
+ USHORT nNewCount = Min( (USHORT)(nOldCount + 1), (USHORT)LRU_MAX );
+ USHORT nNewList[LRU_MAX];
+ nNewList[0] = nOpCode;
+ for (nPos=1; nPos<nNewCount; nPos++)
+ nNewList[nPos] = pOldList[nPos-1];
+ rAppOpt.SetLRUFuncList( nNewList, nNewCount );
+
+ return TRUE; // list has changed
+}
+
+// eigentliche Funktionen
+
+// Eingabe - Undo OK
+
+void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const String& rString,
+ BOOL bRecord, const EditTextObject* pData )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nSelCount = rMark.GetSelectCount();
+ SCTAB i;
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScEditableTester aTester( pDoc, nCol,nRow, nCol,nRow, rMark );
+ if (aTester.IsEditable())
+ {
+ BOOL bEditDeleted = FALSE;
+ BYTE nOldScript = 0;
+
+ ScBaseCell** ppOldCells = NULL;
+ BOOL* pHasFormat = NULL;
+ ULONG* pOldFormats = NULL;
+ SCTAB* pTabs = NULL;
+ SCTAB nUndoPos = 0;
+ EditTextObject* pUndoData = NULL;
+ if ( bRecord )
+ {
+ ppOldCells = new ScBaseCell*[nSelCount];
+ pHasFormat = new BOOL[nSelCount];
+ pOldFormats = new ULONG[nSelCount];
+ pTabs = new SCTAB[nSelCount];
+ nUndoPos = 0;
+
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ {
+ pTabs[nUndoPos] = i;
+ ScBaseCell* pDocCell;
+ pDoc->GetCell( nCol, nRow, i, pDocCell );
+ if ( pDocCell )
+ {
+ ppOldCells[nUndoPos] = pDocCell->CloneWithoutNote( *pDoc );
+ if ( pDocCell->GetCellType() == CELLTYPE_EDIT )
+ bEditDeleted = TRUE;
+
+ BYTE nDocScript = pDoc->GetScriptType( nCol, nRow, i, pDocCell );
+ if ( nOldScript == 0 )
+ nOldScript = nDocScript;
+ else if ( nDocScript != nOldScript )
+ bEditDeleted = TRUE;
+ }
+ else
+ {
+ ppOldCells[nUndoPos] = NULL;
+ }
+
+ const SfxPoolItem* pItem;
+ const ScPatternAttr* pPattern = pDoc->GetPattern(nCol, nRow, i);
+ if ( SFX_ITEM_SET == pPattern->GetItemSet().GetItemState(
+ ATTR_VALUE_FORMAT,FALSE,&pItem) )
+ {
+ pHasFormat[nUndoPos] = TRUE;
+ pOldFormats[nUndoPos] = ((const SfxUInt32Item*)pItem)->GetValue();
+ }
+ else
+ pHasFormat[nUndoPos] = FALSE;
+
+ ++nUndoPos;
+ }
+
+ DBG_ASSERT( nUndoPos==nSelCount, "nUndoPos!=nSelCount" );
+
+ pUndoData = ( pData ? pData->Clone() : NULL );
+ }
+
+ bool bFormula = false;
+
+ // a single '=' character is handled as string (needed for special filters)
+ if ( rString.Len() > 1 )
+ {
+ if ( rString.GetChar(0) == '=' )
+ {
+ // handle as formula
+ bFormula = true;
+ }
+ else if ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' )
+ {
+ // if there is more than one leading '+' or '-' character, remove the additional ones
+ String aString( rString );
+ xub_StrLen nIndex = 1;
+ xub_StrLen nLen = aString.Len();
+ while ( nIndex < nLen && ( aString.GetChar( nIndex ) == '+' || aString.GetChar( nIndex ) == '-' ) )
+ {
+ ++nIndex;
+ }
+ aString.Erase( 1, nIndex - 1 );
+
+ // if the remaining part without the leading '+' or '-' character
+ // is non-empty and not a number, handle as formula
+ if ( aString.Len() > 1 )
+ {
+ sal_uInt32 nFormat = 0;
+ pDoc->GetNumberFormat( nCol, nRow, nTab, nFormat );
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ double fNumber = 0;
+ if ( !pFormatter->IsNumberFormat( aString, nFormat, fNumber ) )
+ {
+ bFormula = true;
+ }
+ }
+ }
+ }
+
+ BOOL bNumFmtChanged = FALSE;
+ if ( bFormula )
+ { // Formel, compile mit AutoCorrection
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ break;
+ ScAddress aPos( nCol, nRow, i );
+ ScCompiler aComp( pDoc, aPos);
+ aComp.SetGrammar(pDoc->GetGrammar());
+//2do: AutoCorrection via CalcOptions abschaltbar machen
+ aComp.SetAutoCorrection( TRUE );
+ if ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' )
+ {
+ aComp.SetExtendedErrorDetection( true );
+ }
+ String aFormula( rString );
+ ScTokenArray* pArr;
+ BOOL bAgain;
+ do
+ {
+ bAgain = FALSE;
+ BOOL bAddEqual = FALSE;
+ ScTokenArray* pArrFirst = pArr = aComp.CompileString( aFormula );
+ BOOL bCorrected = aComp.IsCorrected();
+ if ( bCorrected )
+ { // probieren, mit erster Parser-Korrektur neu zu parsen
+ pArr = aComp.CompileString( aComp.GetCorrectedFormula() );
+ }
+ if ( !pArr->GetCodeError() )
+ {
+ bAddEqual = TRUE;
+ aComp.CompileTokenArray();
+ bCorrected |= aComp.IsCorrected();
+ }
+ if ( bCorrected )
+ {
+ String aCorrectedFormula;
+ if ( bAddEqual )
+ {
+ aCorrectedFormula = '=';
+ aCorrectedFormula += aComp.GetCorrectedFormula();
+ }
+ else
+ aCorrectedFormula = aComp.GetCorrectedFormula();
+ short nResult;
+ if ( aCorrectedFormula.Len() == 1 )
+ nResult = RET_NO; // leere Formel, nur '='
+ else
+ {
+ String aMessage( ScResId( SCSTR_FORMULA_AUTOCORRECTION ) );
+ aMessage += aCorrectedFormula;
+ nResult = QueryBox( GetViewData()->GetDialogParent(),
+ WinBits(WB_YES_NO | WB_DEF_YES),
+ aMessage ).Execute();
+ }
+ if ( nResult == RET_YES )
+ {
+ aFormula = aCorrectedFormula;
+ if ( pArr != pArrFirst )
+ delete pArrFirst;
+ bAgain = TRUE;
+ }
+ else
+ {
+ if ( pArr != pArrFirst )
+ {
+ delete pArr;
+ pArr = pArrFirst;
+ }
+ }
+ }
+ } while ( bAgain );
+ // um in mehreren Tabellen eingesetzt zu werden, muss die Formel
+ // via ScFormulaCell copy-ctor evtl. wegen RangeNames neu kompiliert
+ // werden, gleiches Code-Array fuer alle Zellen geht nicht.
+ // Wenn das Array einen Fehler enthaelt, muss in den neu erzeugten
+ // Zellen RPN geloescht und der Fehler explizit gesetzt werden, da
+ // via FormulaCell copy-ctor und Interpreter das, wenn moeglich,
+ // wieder glattgebuegelt wird, zu intelligent.. z.B.: =1))
+ USHORT nError = pArr->GetCodeError();
+ if ( !nError )
+ {
+ // #68693# update list of recent functions with all functions that
+ // are not within parentheses
+
+ ScModule* pScMod = SC_MOD();
+ ScAppOptions aAppOpt = pScMod->GetAppOptions();
+ BOOL bOptChanged = FALSE;
+
+ formula::FormulaToken** ppToken = pArr->GetArray();
+ USHORT nTokens = pArr->GetLen();
+ USHORT nLevel = 0;
+ for (USHORT nTP=0; nTP<nTokens; nTP++)
+ {
+ formula::FormulaToken* pTok = ppToken[nTP];
+ OpCode eOp = pTok->GetOpCode();
+ if ( eOp == ocOpen )
+ ++nLevel;
+ else if ( eOp == ocClose && nLevel )
+ --nLevel;
+ if ( nLevel == 0 && pTok->IsFunction() &&
+ lcl_AddFunction( aAppOpt, sal::static_int_cast<USHORT>( eOp ) ) )
+ bOptChanged = TRUE;
+ }
+
+ if ( bOptChanged )
+ {
+ pScMod->SetAppOptions(aAppOpt);
+ pScMod->RecentFunctionsChanged();
+ }
+ }
+
+ ScFormulaCell aCell( pDoc, aPos, pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
+ delete pArr;
+ BOOL bAutoCalc = pDoc->GetAutoCalc();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+ for ( ; i<nTabCount; i++)
+ {
+ if (rMark.GetTableSelect(i))
+ {
+ aPos.SetTab( i );
+ ULONG nIndex = (ULONG) ((SfxUInt32Item*) pDoc->GetAttr(
+ nCol, nRow, i, ATTR_VALUE_FORMAT ))->GetValue();
+ if ( pFormatter->GetType( nIndex ) == NUMBERFORMAT_TEXT ||
+ ( ( rString.GetChar(0) == '+' || rString.GetChar(0) == '-' ) && nError && rString.Equals( aFormula ) ) )
+ {
+ if ( pData )
+ {
+ ScEditCell* pCell = new ScEditCell( pData, pDoc, NULL );
+ pDoc->PutCell( aPos, pCell );
+ }
+ else
+ {
+ ScStringCell* pCell = new ScStringCell( aFormula );
+ pDoc->PutCell( aPos, pCell );
+ }
+ }
+ else
+ {
+ DELETEZ(pUndoData);
+ ScFormulaCell* pCell = new ScFormulaCell( aCell, *pDoc, aPos );
+ if ( nError )
+ {
+ pCell->GetCode()->DelRPN();
+ pCell->SetErrCode( nError );
+ if(pCell->GetCode()->IsHyperLink())
+ pCell->GetCode()->SetHyperLink(FALSE);
+ }
+ pDoc->PutCell( aPos, pCell );
+ if ( !bAutoCalc )
+ { // einmal nur die Zelle berechnen und wieder dirty setzen
+ pCell->Interpret();
+ pCell->SetDirtyVar();
+ pDoc->PutInFormulaTree( pCell );
+ }
+ }
+
+ }
+ }
+ }
+ else
+ {
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ if (pDoc->SetString( nCol, nRow, i, rString ))
+ bNumFmtChanged = TRUE;
+ }
+
+ // row height must be changed if new text has a different script type
+ for (i=0; i<nTabCount && !bEditDeleted; i++)
+ if (rMark.GetTableSelect(i))
+ if ( pDoc->GetScriptType( nCol, nRow, i ) != nOldScript )
+ bEditDeleted = TRUE;
+
+ HideAllCursors();
+
+ if (bEditDeleted || pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT ))
+ AdjustRowHeight(nRow,nRow);
+
+ BOOL bAutoFormat = TestFormatArea(nCol, nRow, nTab, bNumFmtChanged);
+ if (bAutoFormat)
+ DoAutoAttributes(nCol, nRow, nTab, bNumFmtChanged, bRecord);
+
+ if ( bRecord )
+ { // wg. ChangeTrack erst jetzt
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoEnterData( pDocSh, nCol, nRow, nTab, nUndoPos, pTabs,
+ ppOldCells, pHasFormat, pOldFormats,
+ rString, pUndoData ) );
+ }
+
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ pDocSh->PostPaintCell( nCol, nRow, i );
+
+ ShowAllCursors();
+
+ pDocSh->UpdateOle(GetViewData());
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ for ( i = 0; i < nTabCount; ++i )
+ {
+ if ( rMark.GetTableSelect( i ) )
+ {
+ aChangeRanges.Append( ScRange( nCol, nRow, i ) );
+ }
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+
+ aModificator.SetDocumentModified();
+ }
+ else
+ {
+ ErrorMessage(aTester.GetMessageId());
+ PaintArea( nCol, nRow, nCol, nRow ); // da steht evtl. noch die Edit-Engine
+ }
+}
+
+// Wert in einzele Zelle eintragen (nur auf nTab)
+
+void ScViewFunc::EnterValue( SCCOL nCol, SCROW nRow, SCTAB nTab, const double& rValue )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ if ( pDoc && pDocSh )
+ {
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow );
+ if (aTester.IsEditable())
+ {
+ ScAddress aPos( nCol, nRow, nTab );
+ ScBaseCell* pOldCell = pDoc->GetCell( aPos );
+ BOOL bNeedHeight = ( pOldCell && pOldCell->GetCellType() == CELLTYPE_EDIT )
+ || pDoc->HasAttrib(
+ nCol,nRow,nTab, nCol,nRow,nTab, HASATTR_NEEDHEIGHT );
+
+ // Undo
+ ScBaseCell* pUndoCell = (bUndo && pOldCell) ? pOldCell->CloneWithoutNote( *pDoc ) : 0;
+
+ pDoc->SetValue( nCol, nRow, nTab, rValue );
+
+ // wg. ChangeTrack nach Aenderung im Dokument
+ if (bUndo)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoEnterValue( pDocSh, aPos, pUndoCell, rValue, bNeedHeight ) );
+ }
+
+/*! Zeilenhoehe anpassen? Dann auch bei Undo...
+ if (bNeedHeight)
+ AdjustRowHeight(nRow,nRow);
+*/
+
+ pDocSh->PostPaintCell( aPos );
+ pDocSh->UpdateOle(GetViewData());
+ aModificator.SetDocumentModified();
+ }
+ else
+ ErrorMessage(aTester.GetMessageId());
+ }
+}
+
+void ScViewFunc::EnterData( SCCOL nCol, SCROW nRow, SCTAB nTab, const EditTextObject* pData,
+ BOOL bRecord, BOOL bTestSimple )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ ScEditableTester aTester( pDoc, nTab, nCol,nRow, nCol,nRow );
+ if (aTester.IsEditable())
+ {
+ //
+ // Test auf Attribute
+ //
+ BOOL bSimple = FALSE;
+ BOOL bCommon = FALSE;
+ ScPatternAttr* pCellAttrs = NULL;
+ EditTextObject* pNewData = NULL;
+ String aString;
+
+ const ScPatternAttr* pOldPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ ScTabEditEngine aEngine( *pOldPattern, pDoc->GetEnginePool() );
+ aEngine.SetText(*pData);
+
+ if (bTestSimple) // Testen, ob einfacher String ohne Attribute
+ {
+ ScEditAttrTester aAttrTester( &aEngine );
+ bSimple = !aAttrTester.NeedsObject();
+ bCommon = aAttrTester.NeedsCellAttr();
+
+ // formulas have to be recognized even if they're formatted
+ // (but commmon attributes are still collected)
+
+ if ( !bSimple && aEngine.GetParagraphCount() == 1 )
+ {
+ String aParStr = aEngine.GetText( (USHORT) 0 );
+ if ( aParStr.GetChar(0) == '=' )
+ bSimple = TRUE;
+ }
+
+ if (bCommon) // Attribute fuer Tabelle
+ {
+ pCellAttrs = new ScPatternAttr( *pOldPattern );
+ pCellAttrs->GetFromEditItemSet( &aAttrTester.GetAttribs() );
+ //! remove common attributes from EditEngine?
+ }
+ }
+
+ // #i97726# always get text for "repeat" of undo action
+ aString = ScEditUtil::GetSpaceDelimitedString(aEngine);
+
+ //
+ // Undo
+ //
+
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nSelCount = rMark.GetSelectCount();
+ SCTAB i;
+ ScBaseCell** ppOldCells = NULL;
+ SCTAB* pTabs = NULL;
+ SCTAB nPos = 0;
+ EditTextObject* pUndoData = NULL;
+ if (bRecord && !bSimple)
+ {
+ ppOldCells = new ScBaseCell*[nSelCount];
+ pTabs = new SCTAB[nSelCount];
+ nPos = 0;
+
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ {
+ pTabs[nPos] = i;
+ ScBaseCell* pDocCell;
+ pDoc->GetCell( nCol, nRow, i, pDocCell );
+ ppOldCells[nPos] = pDocCell ? pDocCell->CloneWithoutNote( *pDoc ) : 0;
+ ++nPos;
+ }
+
+ DBG_ASSERT( nPos==nSelCount, "nPos!=nSelCount" );
+
+ pUndoData = pData->Clone();
+ }
+
+ //
+ // Daten eintragen
+ //
+
+ if (bCommon)
+ pDoc->ApplyPattern(nCol,nRow,nTab,*pCellAttrs); //! Undo
+
+ if (bSimple)
+ {
+ if (bCommon)
+ AdjustRowHeight(nRow,nRow);
+
+ EnterData(nCol,nRow,nTab,aString,bRecord);
+ }
+ else
+ {
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ pDoc->PutCell( nCol, nRow, i, new ScEditCell( pData, pDoc, NULL ) );
+
+ if ( bRecord )
+ { // wg. ChangeTrack erst jetzt
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoEnterData( pDocSh, nCol, nRow, nTab, nPos, pTabs,
+ ppOldCells, NULL, NULL, aString,
+ pUndoData ) );
+ }
+
+ HideAllCursors();
+
+ AdjustRowHeight(nRow,nRow);
+
+ for (i=0; i<nTabCount; i++)
+ if (rMark.GetTableSelect(i))
+ pDocSh->PostPaintCell( nCol, nRow, i );
+
+ ShowAllCursors();
+
+ pDocSh->UpdateOle(GetViewData());
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ for ( i = 0; i < nTabCount; ++i )
+ {
+ if ( rMark.GetTableSelect( i ) )
+ {
+ aChangeRanges.Append( ScRange( nCol, nRow, i ) );
+ }
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+
+ aModificator.SetDocumentModified();
+ }
+
+ delete pCellAttrs;
+ delete pNewData;
+ }
+ else
+ {
+ ErrorMessage(aTester.GetMessageId());
+ PaintArea( nCol, nRow, nCol, nRow ); // da steht evtl. noch die Edit-Engine
+ }
+}
+
+void ScViewFunc::EnterDataAtCursor( const String& rString )
+{
+ SCCOL nPosX = GetViewData()->GetCurX();
+ SCROW nPosY = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ EnterData( nPosX, nPosY, nTab, rString );
+}
+
+void ScViewFunc::EnterMatrix( const String& rString )
+{
+ ScViewData* pData = GetViewData();
+ const ScMarkData& rMark = pData->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ // nichts markiert -> automatisch Block mit Groesse des Ergebnisses
+ // Formel temporaer berechnen, um an die Groesse heranzukommen
+
+ ScDocument* pDoc = pData->GetDocument();
+ SCCOL nCol = pData->GetCurX();
+ SCROW nRow = pData->GetCurY();
+ SCTAB nTab = pData->GetTabNo();
+ ScFormulaCell aFormCell( pDoc, ScAddress(nCol,nRow,nTab), rString,formula::FormulaGrammar::GRAM_DEFAULT, MM_FORMULA );
+
+ SCSIZE nSizeX;
+ SCSIZE nSizeY;
+ aFormCell.GetResultDimensions( nSizeX, nSizeY );
+ if ( nSizeX != 0 && nSizeY != 0 &&
+ nCol+nSizeX-1 <= sal::static_int_cast<SCSIZE>(MAXCOL) &&
+ nRow+nSizeY-1 <= sal::static_int_cast<SCSIZE>(MAXROW) )
+ {
+ ScRange aResult( nCol, nRow, nTab,
+ sal::static_int_cast<SCCOL>(nCol+nSizeX-1),
+ sal::static_int_cast<SCROW>(nRow+nSizeY-1), nTab );
+ MarkRange( aResult, FALSE );
+ }
+ }
+
+ ScRange aRange;
+ if (pData->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = pData->GetDocShell();
+ BOOL bSuccess = pDocSh->GetDocFunc().EnterMatrix( aRange, &rMark, NULL, rString, FALSE, FALSE, EMPTY_STRING, formula::FormulaGrammar::GRAM_DEFAULT );
+ if (bSuccess)
+ pDocSh->UpdateOle(GetViewData());
+ }
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+}
+
+BYTE ScViewFunc::GetSelectionScriptType()
+{
+ BYTE nScript = 0;
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ if ( !rMark.IsMarked() && !rMark.IsMultiMarked() )
+ {
+ // no selection -> cursor
+
+ nScript = pDoc->GetScriptType( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ }
+ else
+ {
+ ScRangeList aRanges;
+ rMark.FillRangeListWithMarks( &aRanges, FALSE );
+ ULONG nCount = aRanges.Count();
+ for (ULONG i=0; i<nCount; i++)
+ {
+ ScRange aRange = *aRanges.GetObject(i);
+ ScCellIterator aIter( pDoc, aRange );
+ ScBaseCell* pCell = aIter.GetFirst();
+ while ( pCell )
+ {
+ nScript |= pDoc->GetScriptType( aIter.GetCol(), aIter.GetRow(), aIter.GetTab(), pCell );
+ pCell = aIter.GetNext();
+ }
+ }
+ }
+
+ if (nScript == 0)
+ nScript = ScGlobal::GetDefaultScriptType();
+
+ return nScript;
+}
+
+const ScPatternAttr* ScViewFunc::GetSelectionPattern()
+{
+ // Don't use UnmarkFiltered in slot state functions, for performance reasons.
+ // The displayed state is always that of the whole selection including filtered rows.
+
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ // MarkToMulti is no longer necessary for pDoc->GetSelectionPattern
+ const ScPatternAttr* pAttr = pDoc->GetSelectionPattern( rMark );
+ return pAttr;
+ }
+ else
+ {
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ ScMarkData aTempMark( rMark ); // copy sheet selection
+ aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
+ const ScPatternAttr* pAttr = pDoc->GetSelectionPattern( aTempMark );
+ return pAttr;
+ }
+}
+
+void ScViewFunc::GetSelectionFrame( SvxBoxItem& rLineOuter,
+ SvxBoxInfoItem& rLineInner )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ {
+ if ( rMark.IsMultiMarked() )
+ {
+ ScMarkData aNewMark( rMark ); // use local copy for MarkToSimple
+ aNewMark.MarkToSimple(); // simple block is needed for GetSelectionFrame
+ pDoc->GetSelectionFrame( aNewMark, rLineOuter, rLineInner );
+ }
+ else
+ pDoc->GetSelectionFrame( rMark, rLineOuter, rLineInner );
+ }
+ else
+ {
+ const ScPatternAttr* pAttrs =
+ pDoc->GetPattern( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(),
+ GetViewData()->GetTabNo() );
+
+ rLineOuter = (const SvxBoxItem&) (pAttrs->GetItem( ATTR_BORDER ));
+ rLineInner = (const SvxBoxInfoItem&)(pAttrs->GetItem( ATTR_BORDER_INNER ));
+ rLineInner.SetTable(FALSE);
+ rLineInner.SetDist(TRUE);
+ rLineInner.SetMinDist(FALSE);
+ }
+}
+
+//
+// Attribute anwenden - Undo OK
+//
+// kompletter Set ( ATTR_STARTINDEX, ATTR_ENDINDEX )
+//
+
+void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet,
+ const SfxItemSet* pOldSet,
+ BOOL bRecord )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ ScPatternAttr aOldAttrs( new SfxItemSet(*pOldSet) );
+ ScPatternAttr aNewAttrs( new SfxItemSet(*pDialogSet) );
+ aNewAttrs.DeleteUnchanged( &aOldAttrs );
+
+ if ( pDialogSet->GetItemState( ATTR_VALUE_FORMAT ) == SFX_ITEM_SET )
+ { // #82521# don't reset to default SYSTEM GENERAL if not intended
+ sal_uInt32 nOldFormat =
+ ((const SfxUInt32Item&)pOldSet->Get( ATTR_VALUE_FORMAT )).GetValue();
+ sal_uInt32 nNewFormat =
+ ((const SfxUInt32Item&)pDialogSet->Get( ATTR_VALUE_FORMAT )).GetValue();
+ if ( nNewFormat != nOldFormat )
+ {
+ SvNumberFormatter* pFormatter =
+ GetViewData()->GetDocument()->GetFormatTable();
+ const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
+ LanguageType eOldLang =
+ pOldEntry ? pOldEntry->GetLanguage() : LANGUAGE_DONTKNOW;
+ const SvNumberformat* pNewEntry = pFormatter->GetEntry( nNewFormat );
+ LanguageType eNewLang =
+ pNewEntry ? pNewEntry->GetLanguage() : LANGUAGE_DONTKNOW;
+ if ( eNewLang != eOldLang )
+ {
+ aNewAttrs.GetItemSet().Put(
+ SvxLanguageItem( eNewLang, ATTR_LANGUAGE_FORMAT ) );
+
+ // #40606# nur die Sprache geaendert -> Zahlformat-Attribut nicht anfassen
+ sal_uInt32 nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET;
+ if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) &&
+ nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE )
+ aNewAttrs.GetItemSet().ClearItem( ATTR_VALUE_FORMAT );
+ }
+ }
+ }
+
+ const SvxBoxItem* pOldOuter = (const SvxBoxItem*) &pOldSet->Get( ATTR_BORDER );
+ const SvxBoxItem* pNewOuter = (const SvxBoxItem*) &pDialogSet->Get( ATTR_BORDER );
+ const SvxBoxInfoItem* pOldInner = (const SvxBoxInfoItem*) &pOldSet->Get( ATTR_BORDER_INNER );
+ const SvxBoxInfoItem* pNewInner = (const SvxBoxInfoItem*) &pDialogSet->Get( ATTR_BORDER_INNER );
+ SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
+ SfxItemPool* pNewPool = rNewSet.GetPool();
+
+ pNewPool->Put( *pNewOuter ); // noch nicht loeschen
+ pNewPool->Put( *pNewInner );
+ rNewSet.ClearItem( ATTR_BORDER );
+ rNewSet.ClearItem( ATTR_BORDER_INNER );
+
+ /*
+ * Feststellen, ob Rahmenattribute zu setzen sind:
+ * 1. Neu != Alt
+ * 2. Ist eine der Linien nicht-DontCare (seit 238.f: IsxxValid())
+ *
+ */
+
+ BOOL bFrame = (pDialogSet->GetItemState( ATTR_BORDER ) != SFX_ITEM_DEFAULT)
+ || (pDialogSet->GetItemState( ATTR_BORDER_INNER ) != SFX_ITEM_DEFAULT);
+
+ if ( pNewOuter==pOldOuter && pNewInner==pOldInner )
+ bFrame = FALSE;
+
+ // das sollte doch der Pool abfangen: ?!??!??
+
+ if ( bFrame && pNewOuter && pNewInner )
+ if ( *pNewOuter == *pOldOuter && *pNewInner == *pOldInner )
+ bFrame = FALSE;
+
+ if ( pNewInner )
+ {
+ bFrame = bFrame
+ && ( pNewInner->IsValid(VALID_LEFT)
+ || pNewInner->IsValid(VALID_RIGHT)
+ || pNewInner->IsValid(VALID_TOP)
+ || pNewInner->IsValid(VALID_BOTTOM)
+ || pNewInner->IsValid(VALID_HORI)
+ || pNewInner->IsValid(VALID_VERT) );
+ }
+ else
+ bFrame = FALSE;
+
+ if (!bFrame)
+ ApplySelectionPattern( aNewAttrs, bRecord ); // nur normale
+ else
+ {
+ // wenn neue Items Default-Items sind, so muessen die
+ // alten Items geputtet werden:
+
+ BOOL bDefNewOuter = ( SFX_ITEMS_STATICDEFAULT == pNewOuter->GetKind() );
+ BOOL bDefNewInner = ( SFX_ITEMS_STATICDEFAULT == pNewInner->GetKind() );
+
+ ApplyPatternLines( aNewAttrs,
+ bDefNewOuter ? pOldOuter : pNewOuter,
+ bDefNewInner ? pOldInner : pNewInner,
+ bRecord );
+ }
+
+ pNewPool->Remove( *pNewOuter ); // freigeben
+ pNewPool->Remove( *pNewInner );
+
+ // Hoehen anpassen
+ AdjustBlockHeight();
+
+ // CellContentChanged wird von ApplySelectionPattern / ApplyPatternLines gerufen
+}
+
+void ScViewFunc::ApplyAttr( const SfxPoolItem& rAttrItem )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ ScPatternAttr aNewAttrs( new SfxItemSet( *GetViewData()->GetDocument()->GetPool(),
+ ATTR_PATTERN_START, ATTR_PATTERN_END ) );
+
+ aNewAttrs.GetItemSet().Put( rAttrItem );
+ // Wenn Ausrichtung eingestellt wird (ueber Buttons), immer Einzug 0
+ if ( rAttrItem.Which() == ATTR_HOR_JUSTIFY )
+ aNewAttrs.GetItemSet().Put( SfxUInt16Item( ATTR_INDENT, 0 ) );
+ ApplySelectionPattern( aNewAttrs );
+
+ AdjustBlockHeight();
+
+ // CellContentChanged wird von ApplySelectionPattern gerufen
+}
+
+
+// Pattern und Rahmen
+
+void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem* pNewOuter,
+ const SvxBoxInfoItem* pNewInner, BOOL bRecord )
+{
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScMarkData aFuncMark( GetViewData()->GetMarkData() ); // local copy for UnmarkFiltered
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScRange aMarkRange;
+ aFuncMark.MarkToSimple();
+ BOOL bMulti = aFuncMark.IsMultiMarked();
+ if (bMulti)
+ aFuncMark.GetMultiMarkArea( aMarkRange );
+ else if (aFuncMark.IsMarked())
+ aFuncMark.GetMarkArea( aMarkRange );
+ else
+ {
+ aMarkRange = ScRange( GetViewData()->GetCurX(),
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ DoneBlockMode();
+ InitOwnBlockMode();
+ aFuncMark.SetMarkArea(aMarkRange);
+ MarkDataChanged();
+ }
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ if (bRecord)
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nStartTab && aFuncMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &aFuncMark );
+
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoSelectionAttr(
+ pDocSh, aFuncMark,
+ aMarkRange.aStart.Col(), aMarkRange.aStart.Row(), aMarkRange.aStart.Tab(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(), aMarkRange.aEnd.Tab(),
+ pUndoDoc, bMulti, &rAttr, pNewOuter, pNewInner ) );
+ }
+
+ USHORT nExt = SC_PF_TESTMERGE;
+ pDocSh->UpdatePaintExt( nExt, aMarkRange ); // content before the change
+
+ pDoc->ApplySelectionFrame( aFuncMark, pNewOuter, pNewInner );
+
+ pDocSh->UpdatePaintExt( nExt, aMarkRange ); // content after the change
+
+ aFuncMark.MarkToMulti();
+ pDoc->ApplySelectionPattern( rAttr, aFuncMark );
+
+ pDocSh->PostPaint( aMarkRange, PAINT_GRID, nExt );
+ pDocSh->UpdateOle(GetViewData());
+ aModificator.SetDocumentModified();
+ CellContentChanged();
+
+ StartFormatArea();
+}
+
+// nur Pattern
+
+void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr,
+ BOOL bRecord, BOOL bCursorOnly )
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData aFuncMark( pViewData->GetMarkData() ); // local copy for UnmarkFiltered
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ // State from old ItemSet doesn't matter for paint flags, as any change will be
+ // from SFX_ITEM_SET in the new ItemSet (default is ignored in ApplyPattern).
+ // New alignment is checked (check in PostPaint isn't enough) in case a right
+ // alignment is changed to left.
+ const SfxItemSet& rNewSet = rAttr.GetItemSet();
+ BOOL bSetLines = rNewSet.GetItemState( ATTR_BORDER, TRUE ) == SFX_ITEM_SET ||
+ rNewSet.GetItemState( ATTR_SHADOW, TRUE ) == SFX_ITEM_SET;
+ BOOL bSetAlign = rNewSet.GetItemState( ATTR_HOR_JUSTIFY, TRUE ) == SFX_ITEM_SET;
+
+ USHORT nExtFlags = 0;
+ if ( bSetLines )
+ nExtFlags |= SC_PF_LINES;
+ if ( bSetAlign )
+ nExtFlags |= SC_PF_WHOLEROWS;
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ BOOL bMulti = aFuncMark.IsMultiMarked();
+ aFuncMark.MarkToMulti();
+ BOOL bOnlyTab = (!aFuncMark.IsMultiMarked() && !bCursorOnly && aFuncMark.GetSelectCount() > 1);
+ if (bOnlyTab)
+ {
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ aFuncMark.SetMarkArea(ScRange(nCol,nRow,nTab));
+ aFuncMark.MarkToMulti();
+ }
+
+ ScRangeList aChangeRanges;
+
+ if (aFuncMark.IsMultiMarked() && !bCursorOnly)
+ {
+ ScRange aMarkRange;
+ aFuncMark.GetMultiMarkArea( aMarkRange );
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for ( SCTAB i = 0; i < nTabCount; ++i )
+ {
+ if ( aFuncMark.GetTableSelect( i ) )
+ {
+ ScRange aChangeRange( aMarkRange );
+ aChangeRange.aStart.SetTab( i );
+ aChangeRange.aEnd.SetTab( i );
+ aChangeRanges.Append( aChangeRange );
+ }
+ }
+
+ SCCOL nStartCol = aMarkRange.aStart.Col();
+ SCROW nStartRow = aMarkRange.aStart.Row();
+ SCTAB nStartTab = aMarkRange.aStart.Tab();
+ SCCOL nEndCol = aMarkRange.aEnd.Col();
+ SCROW nEndRow = aMarkRange.aEnd.Row();
+ SCTAB nEndTab = aMarkRange.aEnd.Tab();
+
+ ScUndoSelectionAttr* pUndoAttr = NULL;
+ ScEditDataArray* pEditDataArray = NULL;
+ if (bRecord)
+ {
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nStartTab, nStartTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nStartTab && aFuncMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, bMulti, pUndoDoc, &aFuncMark );
+
+ aFuncMark.MarkToMulti();
+
+ pUndoAttr = new ScUndoSelectionAttr(
+ pDocSh, aFuncMark, nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab, pUndoDoc, bMulti, &rAttr );
+ pDocSh->GetUndoManager()->AddUndoAction(pUndoAttr);
+ pEditDataArray = pUndoAttr->GetDataArray();
+ }
+
+ pDoc->ApplySelectionPattern( rAttr, aFuncMark, pEditDataArray );
+
+ pDocSh->PostPaint( nStartCol, nStartRow, nStartTab,
+ nEndCol, nEndRow, nEndTab,
+ PAINT_GRID, nExtFlags | SC_PF_TESTMERGE );
+ pDocSh->UpdateOle(GetViewData());
+ aModificator.SetDocumentModified();
+ CellContentChanged();
+ }
+ else // einzelne Zelle - Undo einfacher
+ {
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ ScBaseCell* pCell;
+ pDoc->GetCell(nCol, nRow, nTab, pCell);
+ EditTextObject* pOldEditData = NULL;
+ EditTextObject* pNewEditData = NULL;
+ if (pCell && pCell->GetCellType() == CELLTYPE_EDIT)
+ {
+ ScEditCell* pEditCell = static_cast<ScEditCell*>(pCell);
+ pOldEditData = pEditCell->GetData()->Clone();
+ pEditCell->RemoveCharAttribs(rAttr);
+ pNewEditData = pEditCell->GetData()->Clone();
+ }
+
+ aChangeRanges.Append( ScRange( nCol, nRow, nTab ) );
+ ScPatternAttr* pOldPat = new ScPatternAttr(*pDoc->GetPattern( nCol, nRow, nTab ));
+
+ pDoc->ApplyPattern( nCol, nRow, nTab, rAttr );
+
+ const ScPatternAttr* pNewPat = pDoc->GetPattern( nCol, nRow, nTab );
+
+ if (bRecord)
+ {
+ ScUndoCursorAttr* pUndo = new ScUndoCursorAttr(
+ pDocSh, nCol, nRow, nTab, pOldPat, pNewPat, &rAttr, false );
+ pUndo->SetEditData(pOldEditData, pNewEditData);
+ pDocSh->GetUndoManager()->AddUndoAction(pUndo);
+ }
+ delete pOldPat; // wird im Undo kopiert (Pool)
+
+ pDocSh->PostPaint( nCol,nRow,nTab, nCol,nRow,nTab, PAINT_GRID, nExtFlags | SC_PF_TESTMERGE );
+ pDocSh->UpdateOle(GetViewData());
+ aModificator.SetDocumentModified();
+ CellContentChanged();
+ }
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aProperties;
+ sal_Int32 nCount = 0;
+ const SfxItemPropertyMap* pMap = ScCellObj::GetCellPropertyMap();
+ PropertyEntryVector_t aPropVector = pMap->getPropertyEntries();
+ for ( USHORT nWhich = ATTR_PATTERN_START; nWhich <= ATTR_PATTERN_END; ++nWhich )
+ {
+ const SfxPoolItem* pItem = 0;
+ if ( rNewSet.GetItemState( nWhich, TRUE, &pItem ) == SFX_ITEM_SET && pItem )
+ {
+ PropertyEntryVector_t::const_iterator aIt = aPropVector.begin();
+ while ( aIt != aPropVector.end())
+ {
+ if ( aIt->nWID == nWhich )
+ {
+ ::com::sun::star::uno::Any aVal;
+ pItem->QueryValue( aVal, aIt->nMemberId );
+ aProperties.realloc( nCount + 1 );
+ aProperties[ nCount ].Name = aIt->sName;
+ aProperties[ nCount ].Value <<= aVal;
+ ++nCount;
+ }
+ ++aIt;
+ }
+ }
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "attribute" ) ), aChangeRanges, aProperties );
+ }
+
+ StartFormatArea();
+}
+
+void ScViewFunc::ApplyUserItemSet( const SfxItemSet& rItemSet )
+{
+ // ItemSet from UI, may have different pool
+
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ ScPatternAttr aNewAttrs( GetViewData()->GetDocument()->GetPool() );
+ SfxItemSet& rNewSet = aNewAttrs.GetItemSet();
+ rNewSet.Put( rItemSet, FALSE );
+ ApplySelectionPattern( aNewAttrs );
+
+ AdjustBlockHeight();
+}
+
+const SfxStyleSheet* ScViewFunc::GetStyleSheetFromMarked()
+{
+ // Don't use UnmarkFiltered in slot state functions, for performance reasons.
+ // The displayed state is always that of the whole selection including filtered rows.
+
+ const ScStyleSheet* pSheet = NULL;
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+ if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+ pSheet = pDoc->GetSelectionStyle( rMark ); // MarkToMulti isn't necessary
+ else
+ pSheet = pDoc->GetStyle( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo() );
+
+ return pSheet;
+}
+
+void ScViewFunc::SetStyleSheetToMarked( SfxStyleSheet* pStyleSheet, BOOL bRecord )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ if ( !pStyleSheet) return;
+ // -------------------------------------------------------------------
+
+ ScViewData* pViewData = GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData aFuncMark( pViewData->GetMarkData() ); // local copy for UnmarkFiltered
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+ SCTAB nTabCount = pDoc->GetTableCount();
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ if ( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() )
+ {
+ ScRange aMarkRange;
+ aFuncMark.MarkToMulti();
+ aFuncMark.GetMultiMarkArea( aMarkRange );
+
+ if ( bRecord )
+ {
+ SCTAB nTab = pViewData->GetTabNo();
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nTab && aFuncMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange = aMarkRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, TRUE, pUndoDoc, &aFuncMark );
+ aFuncMark.MarkToMulti();
+
+ String aName = pStyleSheet->GetName();
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoSelectionStyle( pDocSh, aFuncMark, aMarkRange, aName, pUndoDoc ) );
+ }
+
+ pDoc->ApplySelectionStyle( (ScStyleSheet&)*pStyleSheet, aFuncMark );
+
+ if (!AdjustBlockHeight())
+ pViewData->GetDocShell()->PostPaint( aMarkRange, PAINT_GRID );
+
+ aFuncMark.MarkToSimple();
+ }
+ else
+ {
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+
+ if ( bRecord )
+ {
+ ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nTab && aFuncMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+
+ ScRange aCopyRange( nCol, nRow, 0, nCol, nRow, nTabCount-1 );
+ pDoc->CopyToDocument( aCopyRange, IDF_ATTRIB, FALSE, pUndoDoc );
+
+ ScRange aMarkRange ( nCol, nRow, nTab );
+ ScMarkData aUndoMark = aFuncMark;
+ aUndoMark.SetMultiMarkArea( aMarkRange );
+
+ String aName = pStyleSheet->GetName();
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoSelectionStyle( pDocSh, aUndoMark, aMarkRange, aName, pUndoDoc ) );
+ }
+
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (aFuncMark.GetTableSelect(i))
+ pDoc->ApplyStyle( nCol, nRow, i, (ScStyleSheet&)*pStyleSheet );
+
+ if (!AdjustBlockHeight())
+ pViewData->GetDocShell()->PostPaintCell( nCol, nRow, nTab );
+
+ }
+
+ aModificator.SetDocumentModified();
+
+ StartFormatArea();
+}
+
+
+void ScViewFunc::RemoveStyleSheetInUse( SfxStyleSheet* pStyleSheet )
+{
+ if ( !pStyleSheet) return;
+ // -------------------------------------------------------------------
+
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ VirtualDevice aVirtDev;
+ aVirtDev.SetMapMode(MAP_PIXEL);
+ pDoc->StyleSheetChanged( pStyleSheet, TRUE, &aVirtDev,
+ pViewData->GetPPTX(),
+ pViewData->GetPPTY(),
+ pViewData->GetZoomX(),
+ pViewData->GetZoomY() );
+
+ pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+ aModificator.SetDocumentModified();
+
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ if (pHdl)
+ pHdl->ForgetLastPattern();
+}
+
+void ScViewFunc::UpdateStyleSheetInUse( SfxStyleSheet* pStyleSheet )
+{
+ if ( !pStyleSheet) return;
+ // -------------------------------------------------------------------
+
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ VirtualDevice aVirtDev;
+ aVirtDev.SetMapMode(MAP_PIXEL);
+ pDoc->StyleSheetChanged( pStyleSheet, FALSE, &aVirtDev,
+ pViewData->GetPPTX(),
+ pViewData->GetPPTY(),
+ pViewData->GetZoomX(),
+ pViewData->GetZoomY() );
+
+ pDocSh->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PAINT_GRID|PAINT_LEFT );
+ aModificator.SetDocumentModified();
+
+ ScInputHandler* pHdl = SC_MOD()->GetInputHdl();
+ if (pHdl)
+ pHdl->ForgetLastPattern();
+}
+
+// Zellen einfuegen - Undo OK
+
+BOOL ScViewFunc::InsertCells( InsCellCmd eCmd, BOOL bRecord, BOOL bPartOfPaste )
+{
+ ScRange aRange;
+ if (GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+ BOOL bSuccess = pDocSh->GetDocFunc().InsertCells( aRange, &rMark, eCmd, bRecord, FALSE, bPartOfPaste );
+ if (bSuccess)
+ {
+ pDocSh->UpdateOle(GetViewData());
+ CellContentChanged();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ if ( eCmd == INS_INSROWS || eCmd == INS_INSCOLS )
+ {
+ ScRangeList aChangeRanges;
+ aChangeRanges.Append( aRange );
+ ::rtl::OUString aOperation = ( eCmd == INS_INSROWS ?
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert-rows" ) ) :
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "insert-columns" ) ) );
+ pModelObj->NotifyChanges( aOperation, aChangeRanges );
+ }
+ }
+ }
+ return bSuccess;
+ }
+ else
+ {
+ ErrorMessage(STR_NOMULTISELECT);
+ return FALSE;
+ }
+}
+
+// Zellen loeschen - Undo OK
+
+void ScViewFunc::DeleteCells( DelCellCmd eCmd, BOOL bRecord )
+{
+ ScRange aRange;
+ if ( GetViewData()->GetSimpleArea( aRange ) == SC_MARK_SIMPLE )
+ {
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ const ScMarkData& rMark = GetViewData()->GetMarkData();
+
+ // #i94841# [Collaboration] When deleting rows is rejected, the content is sometimes wrong
+ if ( pDocSh->IsDocShared() && ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS ) )
+ {
+ ScRange aDelRange( aRange.aStart );
+ SCCOLROW nCount = 0;
+ if ( eCmd == DEL_DELROWS )
+ {
+ nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
+ }
+ else
+ {
+ nCount = sal::static_int_cast< SCCOLROW >( aRange.aEnd.Col() - aRange.aStart.Col() + 1 );
+ }
+ while ( nCount > 0 )
+ {
+ pDocSh->GetDocFunc().DeleteCells( aDelRange, &rMark, eCmd, bRecord, FALSE );
+ --nCount;
+ }
+ }
+ else
+ {
+ pDocSh->GetDocFunc().DeleteCells( aRange, &rMark, eCmd, bRecord, FALSE );
+ }
+
+ pDocSh->UpdateOle(GetViewData());
+ CellContentChanged();
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ if ( eCmd == DEL_DELROWS || eCmd == DEL_DELCOLS )
+ {
+ ScRangeList aChangeRanges;
+ aChangeRanges.Append( aRange );
+ ::rtl::OUString aOperation = ( eCmd == DEL_DELROWS ?
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete-rows" ) ) :
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "delete-columns" ) ) );
+ pModelObj->NotifyChanges( aOperation, aChangeRanges );
+ }
+ }
+
+ // #58106# Cursor direkt hinter den geloeschten Bereich setzen
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ if ( eCmd==DEL_CELLSLEFT || eCmd==DEL_DELCOLS )
+ nCurX = aRange.aStart.Col();
+ else
+ nCurY = aRange.aStart.Row();
+ SetCursor( nCurX, nCurY );
+ }
+ else
+ {
+ if (eCmd == DEL_DELCOLS)
+ DeleteMulti( FALSE, bRecord );
+ else if (eCmd == DEL_DELROWS)
+ DeleteMulti( TRUE, bRecord );
+ else
+ ErrorMessage(STR_NOMULTISELECT);
+ }
+
+ Unmark();
+}
+
+void ScViewFunc::DeleteMulti( BOOL bRows, BOOL bRecord )
+{
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocShellModificator aModificator( *pDocSh );
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScMarkData aFuncMark( GetViewData()->GetMarkData() ); // local copy for UnmarkFiltered
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+ SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
+ SCCOLROW nRangeCnt = bRows ? aFuncMark.GetMarkRowRanges( pRanges ) :
+ aFuncMark.GetMarkColumnRanges( pRanges );
+ if (nRangeCnt == 0)
+ {
+ pRanges[0] = pRanges[1] = bRows ? static_cast<SCCOLROW>(GetViewData()->GetCurY()) : static_cast<SCCOLROW>(GetViewData()->GetCurX());
+ nRangeCnt = 1;
+ }
+
+ // Test ob erlaubt
+
+ SCCOLROW* pOneRange = pRanges;
+ USHORT nErrorId = 0;
+ BOOL bNeedRefresh = FALSE;
+ SCCOLROW nRangeNo;
+ for (nRangeNo=0; nRangeNo<nRangeCnt && !nErrorId; nRangeNo++)
+ {
+ SCCOLROW nStart = *(pOneRange++);
+ SCCOLROW nEnd = *(pOneRange++);
+
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ if ( bRows )
+ {
+ nStartCol = 0;
+ nEndCol = MAXCOL;
+ nStartRow = static_cast<SCROW>(nStart);
+ nEndRow = static_cast<SCROW>(nEnd);
+ }
+ else
+ {
+ nStartCol = static_cast<SCCOL>(nStart);
+ nEndCol = static_cast<SCCOL>(nEnd);
+ nStartRow = 0;
+ nEndRow = MAXROW;
+ }
+
+ // cell protection (only needed for first range, as all following cells are moved)
+ if ( nRangeNo == 0 )
+ {
+ // test to the end of the sheet
+ ScEditableTester aTester( pDoc, nTab, nStartCol, nStartRow, MAXCOL, MAXROW );
+ if (!aTester.IsEditable())
+ nErrorId = aTester.GetMessageId();
+ }
+
+ // merged cells
+ SCCOL nMergeStartX = nStartCol;
+ SCROW nMergeStartY = nStartRow;
+ SCCOL nMergeEndX = nEndCol;
+ SCROW nMergeEndY = nEndRow;
+ pDoc->ExtendMerge( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
+ pDoc->ExtendOverlapped( nMergeStartX, nMergeStartY, nMergeEndX, nMergeEndY, nTab );
+
+ if ( nMergeStartX != nStartCol || nMergeStartY != nStartRow )
+ {
+ // Disallow deleting parts of a merged cell.
+ // Deleting the start is allowed (merge is removed), so the end doesn't have to be checked.
+
+ nErrorId = STR_MSSG_DELETECELLS_0;
+ }
+ if ( nMergeEndX != nEndCol || nMergeEndY != nEndRow )
+ {
+ // detect if the start of a merged cell is deleted, so the merge flags can be refreshed
+
+ bNeedRefresh = TRUE;
+ }
+ }
+
+ if ( nErrorId )
+ {
+ ErrorMessage( nErrorId );
+ delete[] pRanges;
+ return;
+ }
+
+ // ausfuehren
+
+ WaitObject aWait( GetFrameWin() ); // wichtig wegen TrackFormulas bei UpdateReference
+
+ ScDocument* pUndoDoc = NULL;
+ ScRefUndoData* pUndoData = NULL;
+ if (bRecord)
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, !bRows, bRows ); // Zeilenhoehen
+
+ pOneRange = pRanges;
+ for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nStart = *(pOneRange++);
+ SCCOLROW nEnd = *(pOneRange++);
+ if (bRows)
+ pDoc->CopyToDocument( 0,nStart,nTab, MAXCOL,nEnd,nTab, IDF_ALL,FALSE,pUndoDoc );
+ else
+ pDoc->CopyToDocument( static_cast<SCCOL>(nStart),0,nTab,
+ static_cast<SCCOL>(nEnd),MAXROW,nTab,
+ IDF_ALL,FALSE,pUndoDoc );
+ }
+
+ // alle Formeln wegen Referenzen
+ SCTAB nTabCount = pDoc->GetTableCount();
+ pUndoDoc->AddUndoTab( 0, nTabCount-1, FALSE, FALSE );
+ pDoc->CopyToDocument( 0,0,0, MAXCOL,MAXROW,MAXTAB, IDF_FORMULA,FALSE,pUndoDoc );
+
+ pUndoData = new ScRefUndoData( pDoc );
+
+ pDoc->BeginDrawUndo();
+ }
+
+ pOneRange = &pRanges[2*nRangeCnt]; // rueckwaerts
+ for (nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nEnd = *(--pOneRange);
+ SCCOLROW nStart = *(--pOneRange);
+
+ if (bRows)
+ pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, nStart, static_cast<SCSIZE>(nEnd-nStart+1) );
+ else
+ pDoc->DeleteCol( 0,nTab, MAXROW,nTab, static_cast<SCCOL>(nStart), static_cast<SCSIZE>(nEnd-nStart+1) );
+ }
+
+ if (bNeedRefresh)
+ {
+ SCCOLROW nFirstStart = pRanges[0];
+ SCCOL nStartCol = bRows ? 0 : static_cast<SCCOL>(nFirstStart);
+ SCROW nStartRow = bRows ? static_cast<SCROW>(nFirstStart) : 0;
+ SCCOL nEndCol = MAXCOL;
+ SCROW nEndRow = MAXROW;
+
+ pDoc->RemoveFlagsTab( nStartCol, nStartRow, nEndCol, nEndRow, nTab, SC_MF_HOR | SC_MF_VER );
+ pDoc->ExtendMerge( nStartCol, nStartRow, nEndCol, nEndRow, nTab, TRUE );
+ }
+
+ if (bRecord)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoDeleteMulti( pDocSh, bRows, bNeedRefresh, nTab, pRanges, nRangeCnt,
+ pUndoDoc, pUndoData ) );
+ }
+
+ if (!AdjustRowHeight(0, MAXROW))
+ {
+ if (bRows)
+ pDocSh->PostPaint( 0,pRanges[0],nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT );
+ else
+ pDocSh->PostPaint( static_cast<SCCOL>(pRanges[0]),0,nTab,
+ MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_TOP );
+ }
+ aModificator.SetDocumentModified();
+
+ CellContentChanged();
+
+ // #58106# Cursor direkt hinter den ersten geloeschten Bereich setzen
+ SCCOL nCurX = GetViewData()->GetCurX();
+ SCROW nCurY = GetViewData()->GetCurY();
+ if ( bRows )
+ nCurY = pRanges[0];
+ else
+ nCurX = static_cast<SCCOL>(pRanges[0]);
+ SetCursor( nCurX, nCurY );
+
+ delete[] pRanges;
+
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED ) );
+}
+
+// Inhalte loeschen
+
+void ScViewFunc::DeleteContents( USHORT nFlags, BOOL bRecord )
+{
+ ScViewData* pViewData = GetViewData();
+ pViewData->SetPasteMode( SC_PASTE_NONE );
+ pViewData->GetViewShell()->UpdateCopySourceOverlay();
+
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ BOOL bEditable = SelectionEditable( &bOnlyNotBecauseOfMatrix );
+ if ( !bEditable )
+ {
+ if ( !(bOnlyNotBecauseOfMatrix &&
+ ((nFlags & (IDF_ATTRIB | IDF_EDITATTR)) == nFlags)) )
+ {
+ ErrorMessage(bOnlyNotBecauseOfMatrix ? STR_MATRIXFRAGMENTERR : STR_PROTECTIONERR);
+ return;
+ }
+ }
+
+ ScRange aMarkRange;
+ BOOL bSimple = FALSE;
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScMarkData aFuncMark( GetViewData()->GetMarkData() ); // local copy for UnmarkFiltered
+ ScViewUtil::UnmarkFiltered( aFuncMark, pDoc );
+
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ if ( !aFuncMark.IsMarked() && !aFuncMark.IsMultiMarked() )
+ {
+ aMarkRange.aStart.SetCol(GetViewData()->GetCurX());
+ aMarkRange.aStart.SetRow(GetViewData()->GetCurY());
+ aMarkRange.aStart.SetTab(GetViewData()->GetTabNo());
+ aMarkRange.aEnd = aMarkRange.aStart;
+ if ( pDoc->HasAttrib( aMarkRange, HASATTR_MERGED ) )
+ {
+// InitOwnBlockMode();
+ aFuncMark.SetMarkArea( aMarkRange );
+ }
+ else
+ bSimple = TRUE;
+ }
+
+ aFuncMark.SetMarking(FALSE); // for MarkToMulti
+ aFuncMark.MarkToSimple(); // before bMulti test below
+
+ DBG_ASSERT( aFuncMark.IsMarked() || aFuncMark.IsMultiMarked() || bSimple, "delete what?" );
+
+ ScDocument* pUndoDoc = NULL;
+ BOOL bMulti = !bSimple && aFuncMark.IsMultiMarked();
+ if (!bSimple)
+ {
+ aFuncMark.MarkToMulti();
+ aFuncMark.GetMultiMarkArea( aMarkRange );
+ }
+ ScRange aExtendedRange(aMarkRange);
+ if (!bSimple)
+ {
+ if ( pDoc->ExtendMerge( aExtendedRange, TRUE ) )
+ bMulti = FALSE;
+ }
+
+ // keine Objekte auf geschuetzten Tabellen
+ BOOL bObjects = FALSE;
+ if ( nFlags & IDF_OBJECTS )
+ {
+ bObjects = TRUE;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if (aFuncMark.GetTableSelect(nTab) && pDoc->IsTabProtected(nTab))
+ bObjects = FALSE;
+ }
+
+ USHORT nExtFlags = 0; // extra flags are needed only if attributes are deleted
+ if ( nFlags & IDF_ATTRIB )
+ pDocSh->UpdatePaintExt( nExtFlags, aMarkRange );
+
+ // Reihenfolge:
+ // 1) BeginDrawUndo
+ // 2) Objekte loeschen (DrawUndo wird gefuellt)
+ // 3) Inhalte fuer Undo kopieren
+ // 4) Inhalte loeschen
+ // 5) Undo-Aktion anlegen
+
+ BOOL bDrawUndo = bObjects || ( nFlags & IDF_NOTE ); // needed for shown notes
+ if ( bDrawUndo && bRecord )
+ pDoc->BeginDrawUndo();
+
+ if (bObjects)
+ {
+ if (bMulti)
+ pDoc->DeleteObjectsInSelection( aFuncMark );
+ else
+ pDoc->DeleteObjectsInArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+/*!*/ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),
+ aFuncMark );
+ }
+
+ if ( bRecord )
+ {
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ SCTAB nTab = aMarkRange.aStart.Tab();
+ pUndoDoc->InitUndo( pDoc, nTab, nTab );
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB i=0; i<nTabCount; i++)
+ if (i != nTab && aFuncMark.GetTableSelect(i))
+ pUndoDoc->AddUndoTab( i, i );
+ ScRange aCopyRange = aExtendedRange;
+ aCopyRange.aStart.SetTab(0);
+ aCopyRange.aEnd.SetTab(nTabCount-1);
+
+ // bei "Format/Standard" alle Attribute kopieren, weil CopyToDocument
+ // nur mit IDF_HARDATTR zu langsam ist:
+ USHORT nUndoDocFlags = nFlags;
+ if (nFlags & IDF_ATTRIB)
+ nUndoDocFlags |= IDF_ATTRIB;
+ if (nFlags & IDF_EDITATTR) // Edit-Engine-Attribute
+ nUndoDocFlags |= IDF_STRING; // -> Zellen werden geaendert
+ if (nFlags & IDF_NOTE)
+ nUndoDocFlags |= IDF_CONTENTS; // #68795# copy all cells with their notes
+ // do not copy note captions to undo document
+ nUndoDocFlags |= IDF_NOCAPTIONS;
+ pDoc->CopyToDocument( aCopyRange, nUndoDocFlags, bMulti, pUndoDoc, &aFuncMark );
+ }
+
+ HideAllCursors(); // falls Zusammenfassung aufgehoben wird
+ if (bSimple)
+ pDoc->DeleteArea( aMarkRange.aStart.Col(), aMarkRange.aStart.Row(),
+ aMarkRange.aEnd.Col(), aMarkRange.aEnd.Row(),
+ aFuncMark, nFlags );
+ else
+ {
+ pDoc->DeleteSelection( nFlags, aFuncMark );
+// aFuncMark.MarkToSimple();
+ }
+
+ if ( bRecord )
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoDeleteContents( pDocSh, aFuncMark, aExtendedRange,
+ pUndoDoc, bMulti, nFlags, bDrawUndo ) );
+ }
+
+ if (!AdjustRowHeight( aExtendedRange.aStart.Row(), aExtendedRange.aEnd.Row() ))
+ pDocSh->PostPaint( aExtendedRange, PAINT_GRID, nExtFlags );
+
+ pDocSh->UpdateOle(GetViewData());
+
+ // #i97876# Spreadsheet data changes are not notified
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ if ( bSimple )
+ {
+ aChangeRanges.Append( aMarkRange );
+ }
+ else
+ {
+ aFuncMark.FillRangeListWithMarks( &aChangeRanges, FALSE );
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "cell-change" ) ), aChangeRanges );
+ }
+
+ aModificator.SetDocumentModified();
+ CellContentChanged();
+ ShowAllCursors();
+
+ if ( nFlags & IDF_ATTRIB )
+ {
+ if ( nFlags & IDF_CONTENTS )
+ ForgetFormatArea();
+ else
+ StartFormatArea(); // Attribute loeschen ist auch Attributierung
+ }
+}
+
+// Spaltenbreiten/Zeilenhoehen (ueber Header) - Undo OK
+
+void ScViewFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRanges,
+ ScSizeMode eMode, USHORT nSizeTwips,
+ BOOL bRecord, BOOL bPaint, ScMarkData* pMarkData )
+{
+ if (nRangeCnt == 0)
+ return;
+
+ // use view's mark if none specified
+ if ( !pMarkData )
+ pMarkData = &GetViewData()->GetMarkData();
+
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTabCount = pDoc->GetTableCount();
+ SCTAB nFirstTab = pMarkData->GetFirstSelected();
+ SCTAB nCurTab = GetViewData()->GetTabNo();
+ SCTAB nTab;
+ if (bRecord && !pDoc->IsUndoEnabled())
+ bRecord = FALSE;
+
+ ScDocShellModificator aModificator( *pDocSh );
+
+ BOOL bAllowed = TRUE;
+ for (nTab=0; nTab<nTabCount && bAllowed; nTab++)
+ if (pMarkData->GetTableSelect(nTab))
+ {
+ for ( SCCOLROW i=0; i<nRangeCnt && bAllowed; i++ )
+ {
+ BOOL bOnlyMatrix;
+ if (bWidth)
+ bAllowed = pDoc->IsBlockEditable( nTab,
+ static_cast<SCCOL>(pRanges[2*i]),0,
+ static_cast<SCCOL>(pRanges[2*i+1]),MAXROW,
+ &bOnlyMatrix ) || bOnlyMatrix;
+ else
+ bAllowed = pDoc->IsBlockEditable( nTab, 0,pRanges[2*i],
+ MAXCOL,pRanges[2*i+1], &bOnlyMatrix ) ||
+ bOnlyMatrix;
+ }
+ }
+
+ // Allow users to resize cols/rows in readonly docs despite the r/o state.
+ // It is frustrating to be unable to see content in mis-sized cells.
+ if( !bAllowed && !pDocSh->IsReadOnly() )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ SCCOLROW nStart = pRanges[0];
+ SCCOLROW nEnd = pRanges[2*nRangeCnt-1];
+
+ BOOL bFormula = FALSE;
+ if ( eMode == SC_SIZE_OPTIMAL )
+ {
+ const ScViewOptions& rOpts = GetViewData()->GetOptions();
+ bFormula = rOpts.GetOption( VOPT_FORMULAS );
+ }
+
+ ScDocument* pUndoDoc = NULL;
+ ScOutlineTable* pUndoTab = NULL;
+ SCCOLROW* pUndoRanges = NULL;
+
+ if ( bRecord )
+ {
+ pDoc->BeginDrawUndo(); // Drawing Updates
+
+ pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (pMarkData->GetTableSelect(nTab))
+ {
+ if (bWidth)
+ {
+ if ( nTab == nFirstTab )
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, TRUE, FALSE );
+ else
+ pUndoDoc->AddUndoTab( nTab, nTab, TRUE, FALSE );
+ pDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
+ static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE,
+ FALSE, pUndoDoc );
+ }
+ else
+ {
+ if ( nTab == nFirstTab )
+ pUndoDoc->InitUndo( pDoc, nTab, nTab, FALSE, TRUE );
+ else
+ pUndoDoc->AddUndoTab( nTab, nTab, FALSE, TRUE );
+ pDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, FALSE, pUndoDoc );
+ }
+ }
+
+ pUndoRanges = new SCCOLROW[ 2*nRangeCnt ];
+ memmove( pUndoRanges, pRanges, 2*nRangeCnt*sizeof(SCCOLROW) );
+
+ //! outlines from all tables?
+ ScOutlineTable* pTable = pDoc->GetOutlineTable( nCurTab );
+ if (pTable)
+ pUndoTab = new ScOutlineTable( *pTable );
+ }
+
+ if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
+ pMarkData->MarkToMulti();
+
+ BOOL bShow = nSizeTwips > 0 || eMode != SC_SIZE_DIRECT;
+ BOOL bOutline = FALSE;
+
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (pMarkData->GetTableSelect(nTab))
+ {
+ const SCCOLROW* pTabRanges = pRanges;
+
+ pDoc->IncSizeRecalcLevel( nTab ); // nicht fuer jede Spalte einzeln
+ pDoc->InitializeNoteCaptions( nTab );
+ for (SCCOLROW nRangeNo=0; nRangeNo<nRangeCnt; nRangeNo++)
+ {
+ SCCOLROW nStartNo = *(pTabRanges++);
+ SCCOLROW nEndNo = *(pTabRanges++);
+
+ if ( !bWidth ) // Hoehen immer blockweise
+ {
+ if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
+ {
+ BOOL bAll = ( eMode==SC_SIZE_OPTIMAL );
+ if (!bAll)
+ {
+ // fuer alle eingeblendeten CR_MANUALSIZE loeschen,
+ // dann SetOptimalHeight mit bShrink = FALSE
+ for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow)
+ {
+ SCROW nLastRow = nRow;
+ if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
+ {
+ nRow = nLastRow;
+ continue;
+ }
+
+ BYTE nOld = pDoc->GetRowFlags(nRow, nTab);
+ if (nOld & CR_MANUALSIZE)
+ pDoc->SetRowFlags(nRow, nTab, nOld & ~CR_MANUALSIZE);
+ }
+ }
+
+ double nPPTX = GetViewData()->GetPPTX();
+ double nPPTY = GetViewData()->GetPPTY();
+ Fraction aZoomX = GetViewData()->GetZoomX();
+ Fraction aZoomY = GetViewData()->GetZoomY();
+
+ ScSizeDeviceProvider aProv(pDocSh);
+ if (aProv.IsPrinter())
+ {
+ nPPTX = aProv.GetPPTX();
+ nPPTY = aProv.GetPPTY();
+ aZoomX = aZoomY = Fraction( 1, 1 );
+ }
+
+ pDoc->SetOptimalHeight( nStartNo, nEndNo, nTab, nSizeTwips, aProv.GetDevice(),
+ nPPTX, nPPTY, aZoomX, aZoomY, bAll );
+ if (bAll)
+ pDoc->ShowRows( nStartNo, nEndNo, nTab, TRUE );
+
+ // Manual-Flag wird bei bAll=TRUE schon in SetOptimalHeight gesetzt
+ // (an bei Extra-Height, sonst aus).
+ }
+ else if ( eMode==SC_SIZE_DIRECT )
+ {
+ if (nSizeTwips)
+ {
+ pDoc->SetRowHeightRange( nStartNo, nEndNo, nTab, nSizeTwips );
+ pDoc->SetManualHeight( nStartNo, nEndNo, nTab, TRUE ); // height was set manually
+ }
+ pDoc->ShowRows( nStartNo, nEndNo, nTab, nSizeTwips != 0 );
+ }
+ else if ( eMode==SC_SIZE_SHOW )
+ {
+ pDoc->ShowRows( nStartNo, nEndNo, nTab, TRUE );
+ }
+ }
+ else // Spaltenbreiten
+ {
+ for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
+ {
+ if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) )
+ {
+ USHORT nThisSize = nSizeTwips;
+
+ if ( eMode==SC_SIZE_OPTIMAL || eMode==SC_SIZE_VISOPT )
+ nThisSize = nSizeTwips + GetOptimalColWidth( nCol, nTab, bFormula );
+ if ( nThisSize )
+ pDoc->SetColWidth( nCol, nTab, nThisSize );
+
+ pDoc->ShowCol( nCol, nTab, bShow );
+ }
+ }
+ }
+
+ // Outline anpassen
+
+ if (bWidth)
+ {
+ if ( pDoc->UpdateOutlineCol( static_cast<SCCOL>(nStartNo),
+ static_cast<SCCOL>(nEndNo), nTab, bShow ) )
+ bOutline = TRUE;
+ }
+ else
+ {
+ if ( pDoc->UpdateOutlineRow( nStartNo, nEndNo, nTab, bShow ) )
+ bOutline = TRUE;
+ }
+ }
+ pDoc->DecSizeRecalcLevel( nTab ); // nicht fuer jede Spalte einzeln
+ }
+
+
+ if (!bOutline)
+ DELETEZ(pUndoTab);
+
+ if (bRecord)
+ {
+ pDocSh->GetUndoManager()->AddUndoAction(
+ new ScUndoWidthOrHeight( pDocSh, *pMarkData,
+ nStart, nCurTab, nEnd, nCurTab,
+ pUndoDoc, nRangeCnt, pUndoRanges,
+ pUndoTab, eMode, nSizeTwips, bWidth ) );
+ }
+
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (pMarkData->GetTableSelect(nTab))
+ pDoc->UpdatePageBreaks( nTab );
+
+ GetViewData()->GetView()->UpdateScrollBars();
+
+ if (bPaint)
+ {
+ HideCursor();
+
+ for (nTab=0; nTab<nTabCount; nTab++)
+ if (pMarkData->GetTableSelect(nTab))
+ {
+ if (bWidth)
+ {
+ if (pDoc->HasAttrib( static_cast<SCCOL>(nStart),0,nTab,
+ static_cast<SCCOL>(nEnd),MAXROW,nTab,
+ HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ nStart = 0;
+ if (nStart > 0) // weiter oben anfangen wegen Linien und Cursor
+ --nStart;
+ pDocSh->PostPaint( static_cast<SCCOL>(nStart), 0, nTab,
+ MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_TOP );
+ }
+ else
+ {
+ if (pDoc->HasAttrib( 0,nStart,nTab, MAXCOL,nEnd,nTab, HASATTR_MERGED | HASATTR_OVERLAPPED ))
+ nStart = 0;
+ if (nStart != 0)
+ --nStart;
+ pDocSh->PostPaint( 0, nStart, nTab, MAXCOL, MAXROW, nTab, PAINT_GRID | PAINT_LEFT );
+ }
+ }
+
+ pDocSh->UpdateOle(GetViewData());
+ if( !pDocSh->IsReadOnly() )
+ aModificator.SetDocumentModified();
+
+ ShowCursor();
+ }
+
+ // #i97876# Spreadsheet data changes are not notified
+ if ( bWidth )
+ {
+ ScModelObj* pModelObj = ScModelObj::getImplementation( pDocSh->GetModel() );
+ if ( pModelObj && pModelObj->HasChangesListeners() )
+ {
+ ScRangeList aChangeRanges;
+ for ( nTab = 0; nTab < nTabCount; ++nTab )
+ {
+ if ( pMarkData->GetTableSelect( nTab ) )
+ {
+ const SCCOLROW* pTabRanges = pRanges;
+ for ( SCCOLROW nRange = 0; nRange < nRangeCnt; ++nRange )
+ {
+ SCCOL nStartCol = static_cast< SCCOL >( *(pTabRanges++) );
+ SCCOL nEndCol = static_cast< SCCOL >( *(pTabRanges++) );
+ for ( SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol )
+ {
+ aChangeRanges.Append( ScRange( nCol, 0, nTab ) );
+ }
+ }
+ }
+ }
+ pModelObj->NotifyChanges( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "column-resize" ) ), aChangeRanges );
+ }
+ }
+}
+
+// Spaltenbreiten/Zeilenhoehen (ueber Blockmarken)
+
+void ScViewFunc::SetMarkedWidthOrHeight( BOOL bWidth, ScSizeMode eMode, USHORT nSizeTwips,
+ BOOL bRecord, BOOL bPaint )
+{
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+
+ rMark.MarkToMulti();
+ if (!rMark.IsMultiMarked())
+ {
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ DoneBlockMode();
+ InitOwnBlockMode();
+ rMark.SetMultiMarkArea( ScRange( nCol,nRow,nTab ), TRUE );
+ MarkDataChanged();
+ }
+
+ SCCOLROW* pRanges = new SCCOLROW[MAXCOLROWCOUNT];
+ SCCOLROW nRangeCnt = 0;
+
+ if ( bWidth )
+ nRangeCnt = rMark.GetMarkColumnRanges( pRanges );
+ else
+ nRangeCnt = rMark.GetMarkRowRanges( pRanges );
+
+ SetWidthOrHeight( bWidth, nRangeCnt, pRanges, eMode, nSizeTwips, bRecord, bPaint );
+
+ delete[] pRanges;
+ rMark.MarkToSimple();
+}
+
+void ScViewFunc::ModifyCellSize( ScDirection eDir, BOOL bOptimal )
+{
+ //! Schrittweiten einstellbar
+ // Schrittweite ist auch Minimum
+ USHORT nStepX = STD_COL_WIDTH / 5;
+ USHORT nStepY = ScGlobal::nStdRowHeight;
+
+ ScModule* pScMod = SC_MOD();
+ BOOL bAnyEdit = pScMod->IsInputMode();
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+
+ BOOL bAllowed, bOnlyMatrix;
+ if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
+ bAllowed = pDoc->IsBlockEditable( nTab, nCol,0, nCol,MAXROW, &bOnlyMatrix );
+ else
+ bAllowed = pDoc->IsBlockEditable( nTab, 0,nRow, MAXCOL,nRow, &bOnlyMatrix );
+ if ( !bAllowed && !bOnlyMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ HideAllCursors();
+
+ USHORT nWidth = pDoc->GetColWidth( nCol, nTab );
+ USHORT nHeight = pDoc->GetRowHeight( nRow, nTab );
+ SCCOLROW nRange[2];
+ if ( eDir == DIR_LEFT || eDir == DIR_RIGHT )
+ {
+ if (bOptimal) // Breite dieser einen Zelle
+ {
+ if ( bAnyEdit )
+ {
+ // beim Editieren die aktuelle Breite der Eingabe
+ ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData()->GetViewShell() );
+ if (pHdl)
+ {
+ long nEdit = pHdl->GetTextSize().Width(); // in 1/100mm
+
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ const SvxMarginItem& rMItem =
+ (const SvxMarginItem&)pPattern->GetItem(ATTR_MARGIN);
+ USHORT nMargin = rMItem.GetLeftMargin() + rMItem.GetRightMargin();
+ if ( ((const SvxHorJustifyItem&) pPattern->
+ GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_LEFT )
+ nMargin = sal::static_int_cast<USHORT>(
+ nMargin + ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue() );
+
+ nWidth = (USHORT)(nEdit * pDocSh->GetOutputFactor() / HMM_PER_TWIPS)
+ + nMargin + STD_EXTRA_WIDTH;
+ }
+ }
+ else
+ {
+ double nPPTX = GetViewData()->GetPPTX();
+ double nPPTY = GetViewData()->GetPPTY();
+ Fraction aZoomX = GetViewData()->GetZoomX();
+ Fraction aZoomY = GetViewData()->GetZoomY();
+
+ ScSizeDeviceProvider aProv(pDocSh);
+ if (aProv.IsPrinter())
+ {
+ nPPTX = aProv.GetPPTX();
+ nPPTY = aProv.GetPPTY();
+ aZoomX = aZoomY = Fraction( 1, 1 );
+ }
+
+ long nPixel = pDoc->GetNeededSize( nCol, nRow, nTab, aProv.GetDevice(),
+ nPPTX, nPPTY, aZoomX, aZoomY, TRUE );
+ USHORT nTwips = (USHORT)( nPixel / nPPTX );
+ if (nTwips != 0)
+ nWidth = nTwips + STD_EXTRA_WIDTH;
+ else
+ nWidth = STD_COL_WIDTH;
+ }
+ }
+ else // vergroessern / verkleinern
+ {
+ if ( eDir == DIR_RIGHT )
+ nWidth = sal::static_int_cast<USHORT>( nWidth + nStepX );
+ else if ( nWidth > nStepX )
+ nWidth = sal::static_int_cast<USHORT>( nWidth - nStepX );
+ if ( nWidth < nStepX ) nWidth = nStepX;
+ if ( nWidth > MAX_COL_WIDTH ) nWidth = MAX_COL_WIDTH;
+ }
+ nRange[0] = nRange[1] = nCol;
+ SetWidthOrHeight( TRUE, 1, nRange, SC_SIZE_DIRECT, nWidth );
+
+ // hier bei Breite auch Hoehe anpassen (nur die eine Zeile)
+
+ if (!bAnyEdit)
+ {
+ const ScPatternAttr* pPattern = pDoc->GetPattern( nCol, nRow, nTab );
+ BOOL bNeedHeight =
+ ((const SfxBoolItem&)pPattern->GetItem( ATTR_LINEBREAK )).GetValue() ||
+ ((const SvxHorJustifyItem&)pPattern->
+ GetItem( ATTR_HOR_JUSTIFY )).GetValue() == SVX_HOR_JUSTIFY_BLOCK;
+ if (bNeedHeight)
+ AdjustRowHeight( nRow, nRow );
+ }
+ }
+ else
+ {
+ ScSizeMode eMode;
+ if (bOptimal)
+ {
+ eMode = SC_SIZE_OPTIMAL;
+ nHeight = 0;
+ }
+ else
+ {
+ eMode = SC_SIZE_DIRECT;
+ if ( eDir == DIR_BOTTOM )
+ nHeight = sal::static_int_cast<USHORT>( nHeight + nStepY );
+ else if ( nHeight > nStepY )
+ nHeight = sal::static_int_cast<USHORT>( nHeight - nStepY );
+ if ( nHeight < nStepY ) nHeight = nStepY;
+ if ( nHeight > MAX_COL_HEIGHT ) nHeight = MAX_COL_HEIGHT;
+ //! MAX_COL_HEIGHT umbenennen in MAX_ROW_HEIGHT in global.hxx !!!!!!
+ }
+ nRange[0] = nRange[1] = nRow;
+ SetWidthOrHeight( FALSE, 1, nRange, eMode, nHeight );
+ }
+
+ if ( bAnyEdit )
+ {
+ UpdateEditView();
+ if ( pDoc->HasAttrib( nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_NEEDHEIGHT ) )
+ {
+ ScInputHandler* pHdl = pScMod->GetInputHdl( GetViewData()->GetViewShell() );
+ if (pHdl)
+ pHdl->SetModified(); // damit bei Enter die Hoehe angepasst wird
+ }
+ }
+
+ ShowAllCursors();
+}
+
+void ScViewFunc::ProtectSheet( SCTAB nTab, const ScTableProtection& rProtect )
+{
+ if (nTab == TABLEID_DOC)
+ return;
+
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDocFunc aFunc(*pDocSh);
+ bool bUndo(pDoc->IsUndoEnabled());
+
+ // modifying several tables is handled here
+
+ if (bUndo)
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_PROTECT_TAB );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ }
+
+ SCTAB nCount = pDocSh->GetDocument()->GetTableCount();
+ for ( SCTAB i=0; i<nCount; i++ )
+ if ( rMark.GetTableSelect(i) )
+ aFunc.ProtectSheet(i, rProtect);
+
+ if (bUndo)
+ pDocSh->GetUndoManager()->LeaveListAction();
+
+ UpdateLayerLocks(); //! broadcast to all views
+}
+
+void ScViewFunc::Protect( SCTAB nTab, const String& rPassword )
+{
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDocFunc aFunc(*pDocSh);
+ BOOL bUndo(pDoc->IsUndoEnabled());
+
+ if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 )
+ aFunc.Protect( nTab, rPassword, FALSE );
+ else
+ {
+ // modifying several tables is handled here
+
+ if (bUndo)
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_PROTECT_TAB );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ }
+
+ SCTAB nCount = pDocSh->GetDocument()->GetTableCount();
+ for ( SCTAB i=0; i<nCount; i++ )
+ if ( rMark.GetTableSelect(i) )
+ aFunc.Protect( i, rPassword, FALSE );
+
+ if (bUndo)
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+
+ UpdateLayerLocks(); //! broadcast to all views
+}
+
+BOOL ScViewFunc::Unprotect( SCTAB nTab, const String& rPassword )
+{
+ ScMarkData& rMark = GetViewData()->GetMarkData();
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ ScDocFunc aFunc(*pDocSh);
+ BOOL bChanged = FALSE;
+ BOOL bUndo (pDoc->IsUndoEnabled());
+
+ if ( nTab == TABLEID_DOC || rMark.GetSelectCount() <= 1 )
+ bChanged = aFunc.Unprotect( nTab, rPassword, FALSE );
+ else
+ {
+ // modifying several tables is handled here
+
+ if (bUndo)
+ {
+ String aUndo = ScGlobal::GetRscString( STR_UNDO_UNPROTECT_TAB );
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo );
+ }
+
+ SCTAB nCount = pDocSh->GetDocument()->GetTableCount();
+ for ( SCTAB i=0; i<nCount; i++ )
+ if ( rMark.GetTableSelect(i) )
+ if ( aFunc.Unprotect( i, rPassword, FALSE ) )
+ bChanged = TRUE;
+
+ if (bUndo)
+ pDocSh->GetUndoManager()->LeaveListAction();
+ }
+
+ if (bChanged)
+ UpdateLayerLocks(); //! broadcast to all views
+
+ return bChanged;
+}
+
+void ScViewFunc::SetNoteText( const ScAddress& rPos, const String& rNoteText )
+{
+ GetViewData()->GetDocShell()->GetDocFunc().SetNoteText( rPos, rNoteText, FALSE );
+}
+
+void ScViewFunc::ReplaceNote( const ScAddress& rPos, const String& rNoteText, const String* pAuthor, const String* pDate )
+{
+ GetViewData()->GetDocShell()->GetDocFunc().ReplaceNote( rPos, rNoteText, pAuthor, pDate, FALSE );
+}
+
+void ScViewFunc::SetNumberFormat( short nFormatType, ULONG nAdd )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ sal_uInt32 nNumberFormat = 0;
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
+ LanguageType eLanguage = ScGlobal::eLnge;
+ ScPatternAttr aNewAttrs( pDoc->GetPool() );
+
+ // #67936# always take language from cursor position, even if there is a selection
+
+ sal_uInt32 nCurrentNumberFormat;
+ pDoc->GetNumberFormat( pViewData->GetCurX(),
+ pViewData->GetCurY(),
+ pViewData->GetTabNo(),
+ nCurrentNumberFormat );
+ const SvNumberformat* pEntry = pNumberFormatter->GetEntry( nCurrentNumberFormat );
+ if (pEntry)
+ eLanguage = pEntry->GetLanguage(); // sonst ScGlobal::eLnge behalten
+
+ nNumberFormat = pNumberFormatter->GetStandardFormat( nFormatType, eLanguage ) + nAdd;
+
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
+ // ATTR_LANGUAGE_FORMAT nicht
+ ApplySelectionPattern( aNewAttrs, TRUE );
+}
+
+void ScViewFunc::SetNumFmtByStr( const String& rCode )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ ScViewData* pViewData = GetViewData();
+ ScDocument* pDoc = pViewData->GetDocument();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ // Sprache immer von Cursorposition
+
+ sal_uInt32 nCurrentNumberFormat;
+ pDoc->GetNumberFormat( pViewData->GetCurX(), pViewData->GetCurY(),
+ pViewData->GetTabNo(), nCurrentNumberFormat );
+ const SvNumberformat* pEntry = pFormatter->GetEntry( nCurrentNumberFormat );
+ LanguageType eLanguage = pEntry ? pEntry->GetLanguage() : ScGlobal::eLnge;
+
+ // Index fuer String bestimmen
+
+ BOOL bOk = TRUE;
+ sal_uInt32 nNumberFormat = pFormatter->GetEntryKey( rCode, eLanguage );
+ if ( nNumberFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ // neu eintragen
+
+ String aFormat = rCode; // wird veraendert
+ xub_StrLen nErrPos = 0;
+ short nType = 0; //! ???
+ bOk = pFormatter->PutEntry( aFormat, nErrPos, nType, nNumberFormat, eLanguage );
+ }
+
+ if ( bOk ) // gueltiges Format?
+ {
+ ScPatternAttr aNewAttrs( pDoc->GetPool() );
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNumberFormat ) );
+ rSet.Put( SvxLanguageItem( eLanguage, ATTR_LANGUAGE_FORMAT ) );
+ ApplySelectionPattern( aNewAttrs, TRUE );
+ }
+
+ //! sonst Fehler zuerueckgeben / Meldung ausgeben ???
+}
+
+void ScViewFunc::ChangeNumFmtDecimals( BOOL bIncrement )
+{
+ // nur wegen Matrix nicht editierbar? Attribute trotzdem ok
+ BOOL bOnlyNotBecauseOfMatrix;
+ if ( !SelectionEditable( &bOnlyNotBecauseOfMatrix ) && !bOnlyNotBecauseOfMatrix )
+ {
+ ErrorMessage(STR_PROTECTIONERR);
+ return;
+ }
+
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+
+ SCCOL nCol = GetViewData()->GetCurX();
+ SCROW nRow = GetViewData()->GetCurY();
+ SCTAB nTab = GetViewData()->GetTabNo();
+
+ sal_uInt32 nOldFormat;
+ pDoc->GetNumberFormat( nCol, nRow, nTab, nOldFormat );
+ const SvNumberformat* pOldEntry = pFormatter->GetEntry( nOldFormat );
+ if (!pOldEntry)
+ {
+ DBG_ERROR("Zahlformat nicht gefunden !!!");
+ return;
+ }
+
+ // was haben wir denn da?
+
+ sal_uInt32 nNewFormat = nOldFormat;
+ BOOL bError = FALSE;
+
+ LanguageType eLanguage = pOldEntry->GetLanguage();
+ BOOL bThousand, bNegRed;
+ USHORT nPrecision, nLeading;
+ pOldEntry->GetFormatSpecialInfo( bThousand, bNegRed, nPrecision, nLeading );
+
+ short nOldType = pOldEntry->GetType();
+ if ( 0 == ( nOldType & (
+ NUMBERFORMAT_NUMBER | NUMBERFORMAT_CURRENCY | NUMBERFORMAT_PERCENT ) ) )
+ {
+ // Datum, Zeit, Bruch, logisch, Text kann nicht angepasst werden
+ //! bei Wisssenschaftlich kann es der Numberformatter auch nicht
+ bError = TRUE;
+ }
+
+ //! Das SvNumberformat hat einen Member bStandard, verraet ihn aber nicht
+ BOOL bWasStandard = ( nOldFormat == pFormatter->GetStandardIndex( eLanguage ) );
+ if (bWasStandard)
+ {
+ // bei "Standard" die Nachkommastellen abhaengig vom Zellinhalt
+ // 0 bei leer oder Text -> keine Nachkommastellen
+ double nVal = pDoc->GetValue( ScAddress( nCol, nRow, nTab ) );
+
+ // Die Wege des Numberformatters sind unergruendlich, darum ausprobieren:
+ String aOut;
+ Color* pCol;
+ ((SvNumberformat*)pOldEntry)->GetOutputString( nVal, aOut, &pCol );
+
+ nPrecision = 0;
+ // 'E' fuer Exponential ist fest im Numberformatter
+ if ( aOut.Search('E') != STRING_NOTFOUND )
+ bError = TRUE; // Exponential nicht veraendern
+ else
+ {
+ String aDecSep( pFormatter->GetFormatDecimalSep( nOldFormat ) );
+ xub_StrLen nPos = aOut.Search( aDecSep );
+ if ( nPos != STRING_NOTFOUND )
+ nPrecision = aOut.Len() - nPos - aDecSep.Len();
+ // sonst 0 behalten
+ }
+ }
+
+ if (!bError)
+ {
+ if (bIncrement)
+ {
+ if (nPrecision<20)
+ ++nPrecision; // erhoehen
+ else
+ bError = TRUE; // 20 ist Maximum
+ }
+ else
+ {
+ if (nPrecision)
+ --nPrecision; // vermindern
+ else
+ bError = TRUE; // weniger als 0 geht nicht
+ }
+ }
+
+ if (!bError)
+ {
+ String aNewPicture;
+ pFormatter->GenerateFormat( aNewPicture, nOldFormat, eLanguage,
+ bThousand, bNegRed, nPrecision, nLeading );
+
+ nNewFormat = pFormatter->GetEntryKey( aNewPicture, eLanguage );
+ if ( nNewFormat == NUMBERFORMAT_ENTRY_NOT_FOUND )
+ {
+ xub_StrLen nErrPos = 0;
+ short nNewType = 0;
+ BOOL bOk = pFormatter->PutEntry( aNewPicture, nErrPos,
+ nNewType, nNewFormat, eLanguage );
+ DBG_ASSERT( bOk, "falsches Zahlformat generiert" );
+ if (!bOk)
+ bError = TRUE;
+ }
+ }
+
+ if (!bError)
+ {
+ ScPatternAttr aNewAttrs( pDoc->GetPool() );
+ SfxItemSet& rSet = aNewAttrs.GetItemSet();
+ rSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
+ // ATTR_LANGUAGE_FORMAT nicht
+ ApplySelectionPattern( aNewAttrs, TRUE );
+ }
+ else
+ Sound::Beep(); // war nix
+}
+
+void ScViewFunc::ChangeIndent( BOOL bIncrement )
+{
+ ScViewData* pViewData = GetViewData();
+ ScDocShell* pDocSh = pViewData->GetDocShell();
+ ScMarkData& rMark = pViewData->GetMarkData();
+
+ ScMarkData aWorkMark = rMark;
+ ScViewUtil::UnmarkFiltered( aWorkMark, pDocSh->GetDocument() );
+ aWorkMark.MarkToMulti();
+ if (!aWorkMark.IsMultiMarked())
+ {
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ aWorkMark.SetMultiMarkArea( ScRange(nCol,nRow,nTab) );
+ }
+
+ BOOL bSuccess = pDocSh->GetDocFunc().ChangeIndent( aWorkMark, bIncrement, FALSE );
+ if (bSuccess)
+ {
+ pDocSh->UpdateOle(pViewData);
+ StartFormatArea();
+ }
+}
+
+BOOL ScViewFunc::InsertName( const String& rName, const String& rSymbol,
+ const String& rType )
+{
+ // Type = P,R,C,F (und Kombinationen)
+ //! Undo...
+
+ BOOL bOk = FALSE;
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ ScDocument* pDoc = pDocSh->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ ScRangeName* pList = pDoc->GetRangeName();
+
+ RangeType nType = RT_NAME;
+ ScRangeData* pNewEntry = new ScRangeData( pDoc, rName, rSymbol,
+ ScAddress( GetViewData()->GetCurX(), GetViewData()->GetCurY(),
+ nTab), nType );
+ String aUpType = rType;
+ aUpType.ToUpperAscii();
+ if ( aUpType.Search( 'P' ) != STRING_NOTFOUND )
+ nType |= RT_PRINTAREA;
+ if ( aUpType.Search( 'R' ) != STRING_NOTFOUND )
+ nType |= RT_ROWHEADER;
+ if ( aUpType.Search( 'C' ) != STRING_NOTFOUND )
+ nType |= RT_COLHEADER;
+ if ( aUpType.Search( 'F' ) != STRING_NOTFOUND )
+ nType |= RT_CRITERIA;
+ pNewEntry->AddType(nType);
+
+ if ( !pNewEntry->GetErrCode() ) // Text gueltig?
+ {
+ ScDocShellModificator aModificator( *pDocSh );
+
+ pDoc->CompileNameFormula( TRUE ); // CreateFormulaString
+
+ // Eintrag bereits vorhanden? Dann vorher entfernen (=Aendern)
+ USHORT nFoundAt;
+ if ( pList->SearchName( rName, nFoundAt ) )
+ { // alten Index uebernehmen
+ pNewEntry->SetIndex( ((ScRangeData*)pList->At(nFoundAt))->GetIndex() );
+ pList->AtFree( nFoundAt );
+ }
+
+ if ( pList->Insert( pNewEntry ) )
+ {
+ pNewEntry = NULL; // nicht loeschen
+ bOk = TRUE;
+ }
+
+ pDoc->CompileNameFormula( FALSE ); // CompileFormulaString
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+ }
+
+ delete pNewEntry; // wenn er nicht eingefuegt wurde
+ return bOk;
+}
+
+void ScViewFunc::CreateNames( USHORT nFlags )
+{
+ BOOL bDone = FALSE;
+ ScRange aRange;
+ if ( GetViewData()->GetSimpleArea(aRange) == SC_MARK_SIMPLE )
+ bDone = GetViewData()->GetDocShell()->GetDocFunc().CreateNames( aRange, nFlags, FALSE );
+
+ if (!bDone)
+ ErrorMessage(STR_CREATENAME_MARKERR);
+}
+
+USHORT ScViewFunc::GetCreateNameFlags()
+{
+ USHORT nFlags = 0;
+
+ SCCOL nStartCol, nEndCol;
+ SCROW nStartRow, nEndRow;
+ SCTAB nDummy;
+ if (GetViewData()->GetSimpleArea(nStartCol,nStartRow,nDummy,nEndCol,nEndRow,nDummy) == SC_MARK_SIMPLE)
+ {
+ ScDocument* pDoc = GetViewData()->GetDocument();
+ SCTAB nTab = GetViewData()->GetTabNo();
+ BOOL bOk;
+ SCCOL i;
+ SCROW j;
+
+ bOk = TRUE;
+ SCCOL nFirstCol = nStartCol;
+ SCCOL nLastCol = nEndCol;
+ if (nStartCol+1 < nEndCol) { ++nFirstCol; --nLastCol; }
+ for (i=nFirstCol; i<=nLastCol && bOk; i++)
+ if (!pDoc->HasStringData( i,nStartRow,nTab ))
+ bOk = FALSE;
+ if (bOk)
+ nFlags |= NAME_TOP;
+ else // Bottom nur wenn nicht Top
+ {
+ bOk = TRUE;
+ for (i=nFirstCol; i<=nLastCol && bOk; i++)
+ if (!pDoc->HasStringData( i,nEndRow,nTab ))
+ bOk = FALSE;
+ if (bOk)
+ nFlags |= NAME_BOTTOM;
+ }
+
+ bOk = TRUE;
+ SCROW nFirstRow = nStartRow;
+ SCROW nLastRow = nEndRow;
+ if (nStartRow+1 < nEndRow) { ++nFirstRow; --nLastRow; }
+ for (j=nFirstRow; j<=nLastRow && bOk; j++)
+ if (!pDoc->HasStringData( nStartCol,j,nTab ))
+ bOk = FALSE;
+ if (bOk)
+ nFlags |= NAME_LEFT;
+ else // Right nur wenn nicht Left
+ {
+ bOk = TRUE;
+ for (j=nFirstRow; j<=nLastRow && bOk; j++)
+ if (!pDoc->HasStringData( nEndCol,j,nTab ))
+ bOk = FALSE;
+ if (bOk)
+ nFlags |= NAME_RIGHT;
+ }
+ }
+
+ if (nStartCol == nEndCol)
+ nFlags &= ~( NAME_LEFT | NAME_RIGHT );
+ if (nStartRow == nEndRow)
+ nFlags &= ~( NAME_TOP | NAME_BOTTOM );
+
+ return nFlags;
+}
+
+void ScViewFunc::InsertNameList()
+{
+ ScAddress aPos( GetViewData()->GetCurX(), GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
+ ScDocShell* pDocSh = GetViewData()->GetDocShell();
+ if ( pDocSh->GetDocFunc().InsertNameList( aPos, FALSE ) )
+ pDocSh->UpdateOle(GetViewData());
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
new file mode 100644
index 000000000000..68a6f14389a0
--- /dev/null
+++ b/sc/source/ui/view/viewutil.cxx
@@ -0,0 +1,642 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+#include <tools/list.hxx>
+#include "scitems.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewsh.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <svl/itempool.hxx>
+#include <svl/itemset.hxx>
+#include <svl/cjkoptions.hxx>
+#include <svl/ctloptions.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/wrkwin.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/stritem.hxx>
+#include <svl/eitem.hxx>
+
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+
+
+#include "viewutil.hxx"
+#include "global.hxx"
+#include "chgtrack.hxx"
+#include "chgviset.hxx"
+#include "markdata.hxx"
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+// STATIC DATA -----------------------------------------------------------
+
+//==================================================================
+
+// static
+void ScViewUtil::PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSet,
+ USHORT nWhichId, USHORT nScript )
+{
+ // take the effective item from rCoreSet according to nScript
+ // and put in rShellSet under the (base) nWhichId
+
+ SfxItemPool& rPool = *rShellSet.GetPool();
+ SvxScriptSetItem aSetItem( rPool.GetSlotId(nWhichId), rPool );
+ // use PutExtended with eDefaultAs = SFX_ITEM_SET, so defaults from rCoreSet
+ // (document pool) are read and put into rShellSet (MessagePool)
+ aSetItem.GetItemSet().PutExtended( rCoreSet, SFX_ITEM_DONTCARE, SFX_ITEM_SET );
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
+ if (pI)
+ rShellSet.Put( *pI, nWhichId );
+ else
+ rShellSet.InvalidateItem( nWhichId );
+}
+
+// static
+USHORT ScViewUtil::GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos )
+{
+ // used for thesaurus
+
+ BYTE nScript = pDoc->GetScriptType( rPos.Col(), rPos.Row(), rPos.Tab() );
+ USHORT nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
+ ( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE : ATTR_FONT_LANGUAGE );
+ const SfxPoolItem* pItem = pDoc->GetAttr( rPos.Col(), rPos.Row(), rPos.Tab(), nWhich);
+ SvxLanguageItem* pLangIt = PTR_CAST( SvxLanguageItem, pItem );
+ LanguageType eLnge;
+ if (pLangIt)
+ {
+ eLnge = (LanguageType) pLangIt->GetValue();
+ if (eLnge == LANGUAGE_DONTKNOW) //! can this happen?
+ {
+ LanguageType eLatin, eCjk, eCtl;
+ pDoc->GetLanguage( eLatin, eCjk, eCtl );
+ eLnge = ( nScript == SCRIPTTYPE_ASIAN ) ? eCjk :
+ ( ( nScript == SCRIPTTYPE_COMPLEX ) ? eCtl : eLatin );
+ }
+ }
+ else
+ eLnge = LANGUAGE_ENGLISH_US;
+ if ( eLnge == LANGUAGE_SYSTEM )
+ eLnge = Application::GetSettings().GetLanguage(); // never use SYSTEM for spelling
+
+ return eLnge;
+}
+
+// static
+sal_Int32 ScViewUtil::GetTransliterationType( USHORT nSlotID )
+{
+ sal_Int32 nType = 0;
+ switch ( nSlotID )
+ {
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ nType = com::sun::star::i18n::TransliterationModulesExtra::SENTENCE_CASE;
+ break;
+ case SID_TRANSLITERATE_TITLE_CASE:
+ nType = com::sun::star::i18n::TransliterationModulesExtra::TITLE_CASE;
+ break;
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ nType = com::sun::star::i18n::TransliterationModulesExtra::TOGGLE_CASE;
+ break;
+ case SID_TRANSLITERATE_UPPER:
+ nType = com::sun::star::i18n::TransliterationModules_LOWERCASE_UPPERCASE;
+ break;
+ case SID_TRANSLITERATE_LOWER:
+ nType = com::sun::star::i18n::TransliterationModules_UPPERCASE_LOWERCASE;
+ break;
+ case SID_TRANSLITERATE_HALFWIDTH:
+ nType = com::sun::star::i18n::TransliterationModules_FULLWIDTH_HALFWIDTH;
+ break;
+ case SID_TRANSLITERATE_FULLWIDTH:
+ nType = com::sun::star::i18n::TransliterationModules_HALFWIDTH_FULLWIDTH;
+ break;
+ case SID_TRANSLITERATE_HIRAGANA:
+ nType = com::sun::star::i18n::TransliterationModules_KATAKANA_HIRAGANA;
+ break;
+ case SID_TRANSLITERATE_KATAGANA:
+ nType = com::sun::star::i18n::TransliterationModules_HIRAGANA_KATAKANA;
+ break;
+ }
+ return nType;
+}
+
+// static
+BOOL ScViewUtil::IsActionShown( const ScChangeAction& rAction,
+ const ScChangeViewSettings& rSettings,
+ ScDocument& rDocument )
+{
+ // abgelehnte werden durch eine invertierende akzeptierte Action dargestellt,
+ // die Reihenfolge von ShowRejected/ShowAccepted ist deswegen wichtig
+
+ if ( !rSettings.IsShowRejected() && rAction.IsRejecting() )
+ return FALSE;
+
+ if ( !rSettings.IsShowAccepted() && rAction.IsAccepted() && !rAction.IsRejecting() )
+ return FALSE;
+
+ if ( rSettings.HasAuthor() )
+ {
+ if ( rSettings.IsEveryoneButMe() )
+ {
+ // GetUser() am ChangeTrack ist der aktuelle Benutzer
+ ScChangeTrack* pTrack = rDocument.GetChangeTrack();
+ if ( !pTrack || rAction.GetUser() == pTrack->GetUser() )
+ return FALSE;
+ }
+ else if ( rAction.GetUser() != rSettings.GetTheAuthorToShow() )
+ return FALSE;
+ }
+
+ if ( rSettings.HasComment() )
+ {
+ String aComStr=rAction.GetComment();
+ aComStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " (" ));
+ rAction.GetDescription( aComStr, &rDocument );
+ aComStr+=')';
+
+ if(!rSettings.IsValidComment(&aComStr))
+ return FALSE;
+ }
+
+ if ( rSettings.HasRange() )
+ if ( !rSettings.GetTheRangeList().Intersects( rAction.GetBigRange().MakeRange() ) )
+ return FALSE;
+
+ if ( rSettings.HasDate() && rSettings.GetTheDateMode() != SCDM_NO_DATEMODE )
+ {
+ DateTime aDateTime = rAction.GetDateTime();
+ const DateTime& rFirst = rSettings.GetTheFirstDateTime();
+ const DateTime& rLast = rSettings.GetTheLastDateTime();
+ switch ( rSettings.GetTheDateMode() )
+ { // korrespondiert mit ScHighlightChgDlg::OKBtnHdl
+ case SCDM_DATE_BEFORE:
+ if ( aDateTime > rFirst )
+ return FALSE;
+ break;
+
+ case SCDM_DATE_SINCE:
+ if ( aDateTime < rFirst )
+ return FALSE;
+ break;
+
+ case SCDM_DATE_EQUAL:
+ case SCDM_DATE_BETWEEN:
+ if ( aDateTime < rFirst || aDateTime > rLast )
+ return FALSE;
+ break;
+
+ case SCDM_DATE_NOTEQUAL:
+ if ( aDateTime >= rFirst && aDateTime <= rLast )
+ return FALSE;
+ break;
+
+ case SCDM_DATE_SAVE:
+ {
+ ScChangeTrack* pTrack = rDocument.GetChangeTrack();
+ if ( !pTrack || pTrack->GetLastSavedActionNumber() >=
+ rAction.GetActionNumber() )
+ return FALSE;
+ }
+ break;
+
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ }
+
+ if ( rSettings.HasActionRange() )
+ {
+ ULONG nAction = rAction.GetActionNumber();
+ ULONG nFirstAction;
+ ULONG nLastAction;
+ rSettings.GetTheActionRange( nFirstAction, nLastAction );
+ if ( nAction < nFirstAction || nAction > nLastAction )
+ {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+// static
+void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc )
+{
+ rMark.MarkToMulti();
+
+ ScRange aMultiArea;
+ rMark.GetMultiMarkArea( aMultiArea );
+ SCCOL nStartCol = aMultiArea.aStart.Col();
+ SCROW nStartRow = aMultiArea.aStart.Row();
+ SCCOL nEndCol = aMultiArea.aEnd.Col();
+ SCROW nEndRow = aMultiArea.aEnd.Row();
+
+ bool bChanged = false;
+ SCTAB nTabCount = pDoc->GetTableCount();
+ for (SCTAB nTab=0; nTab<nTabCount; nTab++)
+ if ( rMark.GetTableSelect(nTab ) )
+ {
+ for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
+ {
+ SCROW nLastRow = nRow;
+ if (pDoc->RowFiltered(nRow, nTab, NULL, &nLastRow))
+ {
+ // use nStartCol/nEndCol, so the multi mark area isn't extended to all columns
+ // (visible in repaint for indentation)
+ rMark.SetMultiMarkArea(
+ ScRange(nStartCol, nRow, nTab, nEndCol, nLastRow, nTab), false);
+ bChanged = true;
+ nRow = nLastRow;
+ }
+ }
+ }
+
+ if ( bChanged && !rMark.HasAnyMultiMarks() )
+ rMark.ResetMark();
+
+ rMark.MarkToSimple();
+}
+
+
+// static
+bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows )
+{
+ SCTAB nTab = rRange.aStart.Tab();
+ bool bOneTabOnly = (nTab == rRange.aEnd.Tab());
+ // Always fit the range on its first sheet.
+ DBG_ASSERT( bOneTabOnly, "ScViewUtil::ExtendToUnfilteredRows: works only on one sheet");
+ SCROW nStartRow = rRange.aStart.Row();
+ SCROW nLastRow = pDoc->LastNonFilteredRow(nStartRow, MAXROW, nTab);
+ if (ValidRow(nLastRow))
+ rRange.aEnd.SetRow(nLastRow);
+ SCROW nCount = pDoc->CountNonFilteredRows(nStartRow, MAXROW, nTab);
+ return static_cast<size_t>(nCount) == nRows && bOneTabOnly;
+}
+
+
+// static
+bool ScViewUtil::HasFiltered( const ScRange& rRange, ScDocument* pDoc )
+{
+ SCROW nStartRow = rRange.aStart.Row();
+ SCROW nEndRow = rRange.aEnd.Row();
+ for (SCTAB nTab=rRange.aStart.Tab(); nTab<=rRange.aEnd.Tab(); nTab++)
+ {
+ if (pDoc->HasFilteredRows(nStartRow, nEndRow, nTab))
+ return true;
+ }
+
+ return false;
+}
+
+// static
+void ScViewUtil::HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, USHORT nSlotId )
+{
+ SvtCJKOptions aCJKOptions;
+ SvtCTLOptions aCTLOptions;
+ bool bEnabled = true;
+
+ switch( nSlotId )
+ {
+ case SID_CHINESE_CONVERSION:
+ case SID_HANGUL_HANJA_CONVERSION:
+ bEnabled = aCJKOptions.IsAnyEnabled();
+ break;
+
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ bEnabled = aCJKOptions.IsChangeCaseMapEnabled();
+ break;
+
+ case SID_INSERT_RLM:
+ case SID_INSERT_LRM:
+ case SID_INSERT_ZWNBSP:
+ case SID_INSERT_ZWSP:
+ bEnabled = aCTLOptions.IsCTLFontEnabled();
+ break;
+
+ default:
+ DBG_ERRORFILE( "ScViewUtil::HideDisabledSlot - unknown slot ID" );
+ return;
+ }
+
+ rBindings.SetVisibleState( nSlotId, bEnabled );
+ if( !bEnabled )
+ rSet.DisableItem( nSlotId );
+}
+
+//==================================================================
+
+BOOL ScViewUtil::ExecuteCharMap( const SvxFontItem& rOldFont,
+ SfxViewFrame& rFrame,
+ SvxFontItem& rNewFont,
+ String& rString )
+{
+ BOOL bRet = FALSE;
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if(pFact)
+ {
+ SfxAllItemSet aSet( rFrame.GetObjectShell()->GetPool() );
+ aSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) );
+ aSet.Put( SvxFontItem( rOldFont.GetFamily(), rOldFont.GetFamilyName(), rOldFont.GetStyleName(), rOldFont.GetPitch(), rOldFont.GetCharSet(), aSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ) ) );
+ SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( &rFrame.GetWindow(), aSet, rFrame.GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ if ( pDlg->Execute() == RET_OK )
+ {
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pItem, SfxStringItem, SID_CHARMAP, FALSE );
+ SFX_ITEMSET_ARG( pDlg->GetOutputItemSet(), pFontItem, SvxFontItem, SID_ATTR_CHAR_FONT, FALSE );
+ if ( pItem )
+ rString = pItem->GetValue();
+ if ( pFontItem )
+ rNewFont = SvxFontItem( pFontItem->GetFamily(), pFontItem->GetFamilyName(), pFontItem->GetStyleName(), pFontItem->GetPitch(), pFontItem->GetCharSet(), rNewFont.Which() );
+ bRet = TRUE;
+ }
+ delete pDlg;
+ }
+ return bRet;
+}
+
+bool ScViewUtil::IsFullScreen( SfxViewShell& rViewShell )
+{
+ SfxBindings& rBindings = rViewShell.GetViewFrame()->GetBindings();
+ SfxPoolItem* pItem = 0;
+ bool bIsFullScreen = false;
+
+ if (rBindings.QueryState( SID_WIN_FULLSCREEN, pItem ) >= SFX_ITEM_DEFAULT)
+ bIsFullScreen = static_cast< SfxBoolItem* >( pItem )->GetValue();
+ return bIsFullScreen;
+}
+
+void ScViewUtil::SetFullScreen( SfxViewShell& rViewShell, bool bSet )
+{
+ if( IsFullScreen( rViewShell ) != bSet )
+ {
+ SfxBoolItem aItem( SID_WIN_FULLSCREEN, bSet );
+ rViewShell.GetDispatcher()->Execute( SID_WIN_FULLSCREEN, SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+}
+
+//------------------------------------------------------------------
+
+ScUpdateRect::ScUpdateRect( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
+{
+ PutInOrder( nX1, nX2 );
+ PutInOrder( nY1, nY2 );
+
+ nOldStartX = nX1;
+ nOldStartY = nY1;
+ nOldEndX = nX2;
+ nOldEndY = nY2;
+}
+
+void ScUpdateRect::SetNew( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 )
+{
+ PutInOrder( nX1, nX2 );
+ PutInOrder( nY1, nY2 );
+
+ nNewStartX = nX1;
+ nNewStartY = nY1;
+ nNewEndX = nX2;
+ nNewEndY = nY2;
+}
+
+BOOL ScUpdateRect::GetDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
+{
+ if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX &&
+ nNewStartY == nOldStartY && nNewEndY == nOldEndY )
+ {
+ rX1 = nNewStartX;
+ rY1 = nNewStartY;
+ rX2 = nNewStartX;
+ rY2 = nNewStartY;
+ return FALSE;
+ }
+
+ rX1 = Min(nNewStartX,nOldStartX);
+ rY1 = Min(nNewStartY,nOldStartY);
+ rX2 = Max(nNewEndX,nOldEndX);
+ rY2 = Max(nNewEndY,nOldEndY);
+
+ if ( nNewStartX == nOldStartX && nNewEndX == nOldEndX )
+ {
+ if ( nNewStartY == nOldStartY )
+ {
+ rY1 = Min( nNewEndY, nOldEndY );
+ rY2 = Max( nNewEndY, nOldEndY );
+ }
+ else if ( nNewEndY == nOldEndY )
+ {
+ rY1 = Min( nNewStartY, nOldStartY );
+ rY2 = Max( nNewStartY, nOldStartY );
+ }
+ }
+ else if ( nNewStartY == nOldStartY && nNewEndY == nOldEndY )
+ {
+ if ( nNewStartX == nOldStartX )
+ {
+ rX1 = Min( nNewEndX, nOldEndX );
+ rX2 = Max( nNewEndX, nOldEndX );
+ }
+ else if ( nNewEndX == nOldEndX )
+ {
+ rX1 = Min( nNewStartX, nOldStartX );
+ rX2 = Max( nNewStartX, nOldStartX );
+ }
+ }
+
+ return TRUE;
+}
+
+#ifdef OLD_SELECTION_PAINT
+BOOL ScUpdateRect::GetXorDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2, BOOL& rCont )
+{
+ rCont = FALSE;
+
+ if (nNewStartX == nOldStartX && nNewEndX == nOldEndX &&
+ nNewStartY == nOldStartY && nNewEndY == nOldEndY)
+ {
+ rX1 = nNewStartX;
+ rY1 = nNewStartY;
+ rX2 = nNewStartX;
+ rY2 = nNewStartY;
+ return FALSE;
+ }
+
+ rX1 = Min(nNewStartX,nOldStartX);
+ rY1 = Min(nNewStartY,nOldStartY);
+ rX2 = Max(nNewEndX,nOldEndX);
+ rY2 = Max(nNewEndY,nOldEndY);
+
+ if (nNewStartX == nOldStartX && nNewEndX == nOldEndX) // nur vertikal
+ {
+ if (nNewStartY == nOldStartY)
+ {
+ rY1 = Min( nNewEndY, nOldEndY ) + 1;
+ rY2 = Max( nNewEndY, nOldEndY );
+ }
+ else if (nNewEndY == nOldEndY)
+ {
+ rY1 = Min( nNewStartY, nOldStartY );
+ rY2 = Max( nNewStartY, nOldStartY ) - 1;
+ }
+ else
+ {
+ rY1 = Min( nNewStartY, nOldStartY );
+ rY2 = Max( nNewStartY, nOldStartY ) - 1;
+ rCont = TRUE;
+ nContY1 = Min( nNewEndY, nOldEndY ) + 1;
+ nContY2 = Max( nNewEndY, nOldEndY );
+ nContX1 = rX1;
+ nContX2 = rX2;
+ }
+ }
+ else if (nNewStartY == nOldStartY && nNewEndY == nOldEndY) // nur horizontal
+ {
+ if (nNewStartX == nOldStartX)
+ {
+ rX1 = Min( nNewEndX, nOldEndX ) + 1;
+ rX2 = Max( nNewEndX, nOldEndX );
+ }
+ else if (nNewEndX == nOldEndX)
+ {
+ rX1 = Min( nNewStartX, nOldStartX );
+ rX2 = Max( nNewStartX, nOldStartX ) - 1;
+ }
+ else
+ {
+ rX1 = Min( nNewStartX, nOldStartX );
+ rX2 = Max( nNewStartX, nOldStartX ) - 1;
+ rCont = TRUE;
+ nContX1 = Min( nNewEndX, nOldEndX ) + 1;
+ nContX2 = Max( nNewEndX, nOldEndX );
+ nContY1 = rY1;
+ nContY2 = rY2;
+ }
+ }
+ else if (nNewEndX == nOldEndX && nNewEndY == nOldEndY) // links oben
+ {
+ if ((nNewStartX<nOldStartX) == (nNewStartY<nOldStartY))
+ rX1 = Min( nNewStartX, nOldStartX );
+ else
+ rX1 = Max( nNewStartX, nOldStartX ); // Ecke weglassen
+ rX2 = nOldEndX;
+ rY1 = Min( nNewStartY, nOldStartY ); // oben
+ rY2 = Max( nNewStartY, nOldStartY ) - 1;
+ rCont = TRUE;
+ nContY1 = rY2+1;
+ nContY2 = nOldEndY;
+ nContX1 = Min( nNewStartX, nOldStartX ); // links
+ nContX2 = Max( nNewStartX, nOldStartX ) - 1;
+ }
+ else if (nNewStartX == nOldStartX && nNewEndY == nOldEndY) // rechts oben
+ {
+ if ((nNewEndX<nOldEndX) != (nNewStartY<nOldStartY))
+ rX2 = Max( nNewEndX, nOldEndX );
+ else
+ rX2 = Min( nNewEndX, nOldEndX ); // Ecke weglassen
+ rX1 = nOldStartX;
+ rY1 = Min( nNewStartY, nOldStartY ); // oben
+ rY2 = Max( nNewStartY, nOldStartY ) - 1;
+ rCont = TRUE;
+ nContY1 = rY2+1;
+ nContY2 = nOldEndY;
+ nContX1 = Min( nNewEndX, nOldEndX ) + 1; // rechts
+ nContX2 = Max( nNewEndX, nOldEndX );
+ }
+ else if (nNewEndX == nOldEndX && nNewStartY == nOldStartY) // links unten
+ {
+ if ((nNewStartX<nOldStartX) != (nNewEndY<nOldEndY))
+ rX1 = Min( nNewStartX, nOldStartX );
+ else
+ rX1 = Max( nNewStartX, nOldStartX ); // Ecke weglassen
+ rX2 = nOldEndX;
+ rY1 = Min( nNewEndY, nOldEndY ) + 1; // unten
+ rY2 = Max( nNewEndY, nOldEndY );
+ rCont = TRUE;
+ nContY1 = nOldStartY;
+ nContY2 = rY1-1;
+ nContX1 = Min( nNewStartX, nOldStartX ); // links
+ nContX2 = Max( nNewStartX, nOldStartX ) - 1;
+ }
+ else if (nNewStartX == nOldStartX && nNewStartY == nOldStartY) // rechts unten
+ {
+ if ((nNewEndX<nOldEndX) == (nNewEndY<nOldEndY))
+ rX2 = Max( nNewEndX, nOldEndX );
+ else
+ rX2 = Min( nNewEndX, nOldEndX ); // Ecke weglassen
+ rX1 = nOldStartX;
+ rY1 = Min( nNewEndY, nOldEndY ) + 1; // unten
+ rY2 = Max( nNewEndY, nOldEndY );
+ rCont = TRUE;
+ nContY1 = nOldStartY;
+ nContY2 = rY1-1;
+ nContX1 = Min( nNewEndX, nOldEndX ) + 1; // rechts
+ nContX2 = Max( nNewEndX, nOldEndX );
+ }
+ else // Ueberschlag
+ {
+ rX1 = nOldStartX;
+ rY1 = nOldStartY;
+ rX2 = nOldEndX;
+ rY2 = nOldEndY;
+ rCont = TRUE;
+ nContX1 = nNewStartX;
+ nContY1 = nNewStartY;
+ nContX2 = nNewEndX;
+ nContY2 = nNewEndY;
+ }
+
+ return TRUE;
+}
+
+void ScUpdateRect::GetContDiff( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
+{
+ rX1 = nContX1;
+ rY1 = nContY1;
+ rX2 = nContX2;
+ rY2 = nContY2;
+}
+#endif
+
+
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/waitoff.cxx b/sc/source/ui/view/waitoff.cxx
new file mode 100644
index 000000000000..6d887a5ec8fa
--- /dev/null
+++ b/sc/source/ui/view/waitoff.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sc.hxx"
+
+
+
+//------------------------------------------------------------------------
+
+#include <vcl/window.hxx>
+
+#include "waitoff.hxx"
+
+//------------------------------------------------------------------------
+
+ScWaitCursorOff::ScWaitCursorOff( Window* pWinP )
+ :
+ pWin( pWinP ),
+ nWaiters(0)
+{
+ if ( pWin )
+ {
+ while ( pWin->IsWait() )
+ {
+ nWaiters++;
+ pWin->LeaveWait();
+ }
+ }
+}
+
+ScWaitCursorOff::~ScWaitCursorOff()
+{
+ if ( pWin )
+ {
+ while ( nWaiters )
+ {
+ nWaiters--;
+ pWin->EnterWait();
+ }
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */